40 "MeshSurfaceExtraction::getSurfaceIntegratedValuesForNodes() - "
41 "Given mesh is no surface mesh (dimension != 2).");
42 return std::vector<double>();
47 ERR(
"Need element property, but the property '{:s}' is not available.",
49 return std::vector<double>();
54 std::vector<double> integrated_node_area_vec;
57 for (
auto const* node : mesh.
getNodes())
59 double integrated_node_area(0);
60 for (
auto const& connected_elem :
63 double const area = connected_elem->getContent() /
64 connected_elem->getNumberOfBaseNodes();
65 integrated_node_area += area * (*elem_pv)[connected_elem->getID()];
69 integrated_node_area_vec.push_back(integrated_node_area);
72 INFO(
"Total surface area: {:g}", total_area);
74 return integrated_node_area_vec;
77int main(
int argc,
char* argv[])
80 "Integrates the given element property and outputs an OGS-5 direct "
81 "Neumann boundary condition. The mesh has to contain a property "
82 "'bulk_node_ids' that stores the original subsurface mesh node ids. "
83 "Such surface meshes can be created using the OGS-6 tool "
85 "OpenGeoSys-6 software, version " +
88 "Copyright (c) 2012-2025, OpenGeoSys Community "
89 "(http://www.opengeosys.org)",
92 TCLAP::ValueArg<std::string> in_mesh(
95 "Input (.vtu | .msh). The surface mesh input file that has an element "
96 "property for the Neumann boundary condition",
102 TCLAP::ValueArg<std::string> property_in_arg(
105 "name of an element property used for the computation of the Neumann "
106 "boundary condition",
110 cmd.add(property_in_arg);
112 TCLAP::ValueArg<std::string> property_out_arg(
115 "name of the node based property used for the output of the Neumann "
116 "boundary condition",
120 cmd.add(property_out_arg);
122 TCLAP::ValueArg<std::string> result_file(
125 "Output (.txt). The output file name the result will be written to",
129 cmd.add(result_file);
131 cmd.add(log_level_arg);
132 cmd.parse(argc, argv);
138 std::unique_ptr<MeshLib::Mesh> surface_mesh(
141 auto const*
const node_id_pv =
146 return surface_mesh->getProperties().getPropertyVector<std::size_t>(
150 catch (std::runtime_error
const& e)
152 WARN(
"{:s}", e.what());
162 *surface_mesh, property_in_arg.getValue());
163 std::vector<std::pair<std::size_t, double>> direct_values;
164 direct_values.reserve(surface_mesh->getNumberOfNodes());
166 for (
auto const* node : surface_mesh->getNodes())
168 auto const id(node->getID());
169 auto const subsurface_node_id((*node_id_pv)[
id]);
170 auto const val(integrated_values[
id]);
171 direct_values.emplace_back(subsurface_node_id, val);
175 surface_mesh->getProperties().createNewPropertyVector<
double>(
177 surface_mesh->getNodes().size(), 1);
178 for (std::size_t k(0); k < surface_mesh->getNodes().size(); ++k)
180 (*pv)[k] = direct_values[k].second;
185 std::ofstream result_out(result_file.getValue() +
".txt");
186 result_out.precision(std::numeric_limits<double>::max_digits10);
187 for (
auto const& p : direct_values)
189 result_out << p.first <<
" " << p.second <<
"\n";