33 "MeshSurfaceExtraction::getSurfaceIntegratedValuesForNodes() - "
34 "Given mesh is no surface mesh (dimension != 2).");
35 return std::vector<double>();
40 ERR(
"Need element property, but the property '{:s}' is not available.",
42 return std::vector<double>();
47 std::vector<double> integrated_node_area_vec;
50 for (
auto const* node : mesh.
getNodes())
52 double integrated_node_area(0);
53 for (
auto const& connected_elem :
56 double const area = connected_elem->getContent() /
57 connected_elem->getNumberOfBaseNodes();
58 integrated_node_area += area * (*elem_pv)[connected_elem->getID()];
62 integrated_node_area_vec.push_back(integrated_node_area);
65 INFO(
"Total surface area: {:g}", total_area);
67 return integrated_node_area_vec;
70int main(
int argc,
char* argv[])
73 "Integrates the given element property and outputs an OGS-5 direct "
74 "Neumann boundary condition. The mesh has to contain a property "
75 "'bulk_node_ids' that stores the original subsurface mesh node ids. "
76 "Such surface meshes can be created using the OGS-6 tool "
78 "OpenGeoSys-6 software, version " +
81 "Copyright (c) 2012-2026, OpenGeoSys Community "
82 "(http://www.opengeosys.org)",
85 TCLAP::ValueArg<std::string> in_mesh(
88 "Input (.vtu | .msh). The surface mesh input file that has an element "
89 "property for the Neumann boundary condition",
95 TCLAP::ValueArg<std::string> property_in_arg(
98 "name of an element property used for the computation of the Neumann "
103 cmd.add(property_in_arg);
105 TCLAP::ValueArg<std::string> property_out_arg(
108 "name of the node based property used for the output of the Neumann "
109 "boundary condition",
113 cmd.add(property_out_arg);
115 TCLAP::ValueArg<std::string> result_file(
118 "Output (.txt). The output file name the result will be written to",
122 cmd.add(result_file);
124 cmd.add(log_level_arg);
125 cmd.parse(argc, argv);
131 std::unique_ptr<MeshLib::Mesh> surface_mesh(
134 auto const*
const node_id_pv =
139 return surface_mesh->getProperties().getPropertyVector<std::size_t>(
143 catch (std::runtime_error
const& e)
145 WARN(
"{:s}", e.what());
155 *surface_mesh, property_in_arg.getValue());
156 std::vector<std::pair<std::size_t, double>> direct_values;
157 direct_values.reserve(surface_mesh->getNumberOfNodes());
159 for (
auto const* node : surface_mesh->getNodes())
161 auto const id(node->getID());
162 auto const subsurface_node_id((*node_id_pv)[
id]);
163 auto const val(integrated_values[
id]);
164 direct_values.emplace_back(subsurface_node_id, val);
168 surface_mesh->getProperties().createNewPropertyVector<
double>(
170 surface_mesh->getNodes().size(), 1);
171 for (std::size_t k(0); k < surface_mesh->getNodes().size(); ++k)
173 (*pv)[k] = direct_values[k].second;
178 std::ofstream result_out(result_file.getValue() +
".txt");
179 result_out.precision(std::numeric_limits<double>::max_digits10);
180 for (
auto const& p : direct_values)
182 result_out << p.first <<
" " << p.second <<
"\n";