38 "MeshSurfaceExtraction::getSurfaceIntegratedValuesForNodes() - "
39 "Given mesh is no surface mesh (dimension != 2).");
40 return std::vector<double>();
45 ERR(
"Need element property, but the property '{:s}' is not available.",
47 return std::vector<double>();
52 std::vector<double> integrated_node_area_vec;
55 for (
auto const* node : mesh.
getNodes())
57 double integrated_node_area(0);
58 for (
auto const& connected_elem :
61 double const area = connected_elem->getContent() /
62 connected_elem->getNumberOfBaseNodes();
63 integrated_node_area += area * (*elem_pv)[connected_elem->getID()];
67 integrated_node_area_vec.push_back(integrated_node_area);
70 INFO(
"Total surface area: {:g}", total_area);
72 return integrated_node_area_vec;
75int main(
int argc,
char* argv[])
78 "Integrates the given element property and outputs an OGS-5 direct "
79 "Neumann boundary condition. The mesh has to contain a property "
80 "'bulk_node_ids' that stores the original subsurface mesh node ids. "
81 "Such surface meshes can be created using the OGS-6 tool "
83 "OpenGeoSys-6 software, version " +
86 "Copyright (c) 2012-2024, OpenGeoSys Community "
87 "(http://www.opengeosys.org)",
90 TCLAP::ValueArg<std::string> in_mesh(
93 "the surface mesh that has an element property for the Neumann "
97 "filename for surface mesh input");
100 TCLAP::ValueArg<std::string> property_in_arg(
103 "name of an element property used for the computation of the Neumann "
104 "boundary condition",
107 "string (property name)");
108 cmd.add(property_in_arg);
110 TCLAP::ValueArg<std::string> property_out_arg(
113 "name of the node based property used for the output of the Neumann "
114 "boundary condition",
117 "string (property name)");
118 cmd.add(property_out_arg);
120 TCLAP::ValueArg<std::string> result_file(
123 "the file name the result will be written to ",
127 cmd.add(result_file);
128 cmd.parse(argc, argv);
133 std::unique_ptr<MeshLib::Mesh> surface_mesh(
136 auto const*
const node_id_pv =
141 return surface_mesh->getProperties().getPropertyVector<std::size_t>(
145 catch (std::runtime_error
const& e)
147 WARN(
"{:s}", e.what());
157 *surface_mesh, property_in_arg.getValue());
158 std::vector<std::pair<std::size_t, double>> direct_values;
159 direct_values.reserve(surface_mesh->getNumberOfNodes());
161 for (
auto const* node : surface_mesh->getNodes())
163 auto const id(node->getID());
164 auto const subsurface_node_id((*node_id_pv)[
id]);
165 auto const val(integrated_values[
id]);
166 direct_values.emplace_back(subsurface_node_id, val);
170 surface_mesh->getProperties().createNewPropertyVector<
double>(
172 pv->resize(surface_mesh->getNodes().size());
173 for (std::size_t k(0); k < surface_mesh->getNodes().size(); ++k)
175 (*pv)[k] = direct_values[k].second;
180 std::ofstream result_out(result_file.getValue() +
".txt");
181 result_out.precision(std::numeric_limits<double>::max_digits10);
182 for (
auto const& p : direct_values)
184 result_out << p.first <<
" " << p.second <<
"\n";