41 "MeshSurfaceExtraction::getSurfaceIntegratedValuesForNodes() - "
42 "Given mesh is no surface mesh (dimension != 2).");
43 return std::vector<double>();
48 ERR(
"Need element property, but the property '{:s}' is not available.",
50 return std::vector<double>();
55 std::vector<double> integrated_node_area_vec;
58 for (
auto const* node : mesh.
getNodes())
60 double integrated_node_area(0);
61 for (
auto const& connected_elem :
64 double const area = connected_elem->getContent() /
65 connected_elem->getNumberOfBaseNodes();
66 integrated_node_area += area * (*elem_pv)[connected_elem->getID()];
70 integrated_node_area_vec.push_back(integrated_node_area);
73 INFO(
"Total surface area: {:g}", total_area);
75 return integrated_node_area_vec;
78int main(
int argc,
char* argv[])
81 "Integrates the given element property and outputs an OGS-5 direct "
82 "Neumann boundary condition. The mesh has to contain a property "
83 "'bulk_node_ids' that stores the original subsurface mesh node ids. "
84 "Such surface meshes can be created using the OGS-6 tool "
86 "OpenGeoSys-6 software, version " +
89 "Copyright (c) 2012-2024, OpenGeoSys Community "
90 "(http://www.opengeosys.org)",
93 TCLAP::ValueArg<std::string> in_mesh(
96 "the surface mesh that has an element property for the Neumann "
100 "filename for surface mesh input");
103 TCLAP::ValueArg<std::string> property_in_arg(
106 "name of an element property used for the computation of the Neumann "
107 "boundary condition",
110 "string (property name)");
111 cmd.add(property_in_arg);
113 TCLAP::ValueArg<std::string> property_out_arg(
116 "name of the node based property used for the output of the Neumann "
117 "boundary condition",
120 "string (property name)");
121 cmd.add(property_out_arg);
123 TCLAP::ValueArg<std::string> result_file(
126 "the file name the result will be written to ",
130 cmd.add(result_file);
131 cmd.parse(argc, argv);
134 MPI_Init(&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());
165 *surface_mesh, property_in_arg.getValue());
166 std::vector<std::pair<std::size_t, double>> direct_values;
167 direct_values.reserve(surface_mesh->getNumberOfNodes());
169 for (
auto const* node : surface_mesh->getNodes())
171 auto const id(node->getID());
172 auto const subsurface_node_id((*node_id_pv)[
id]);
173 auto const val(integrated_values[
id]);
174 direct_values.emplace_back(subsurface_node_id, val);
178 surface_mesh->getProperties().createNewPropertyVector<
double>(
180 pv->resize(surface_mesh->getNodes().size());
181 for (std::size_t k(0); k < surface_mesh->getNodes().size(); ++k)
183 (*pv)[k] = direct_values[k].second;
188 std::ofstream result_out(result_file.getValue() +
".txt");
189 result_out.precision(std::numeric_limits<double>::max_digits10);
190 for (
auto const& p : direct_values)
192 result_out << p.first <<
" " << p.second <<
"\n";