10 #include <tclap/CmdLine.h>
36 "MeshSurfaceExtraction::getSurfaceIntegratedValuesForNodes() - "
37 "Given mesh is no surface mesh (dimension != 2).");
38 return std::vector<double>();
43 ERR(
"Need element property, but the property '{:s}' is not available.",
45 return std::vector<double>();
50 std::vector<double> integrated_node_area_vec;
53 for (
auto const* node : mesh.
getNodes())
56 double integrated_node_area(0);
57 for (
auto const& connected_elem :
60 double const area = connected_elem->getContent() /
61 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;
75 int 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-2021, 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);
131 std::unique_ptr<MeshLib::Mesh> surface_mesh(
134 auto const*
const node_id_pv =
139 return surface_mesh->getProperties().getPropertyVector<std::size_t>(
142 catch (std::runtime_error
const& e)
144 WARN(
"{:s}", e.what());
154 *surface_mesh, property_in_arg.getValue());
155 std::vector<std::pair<std::size_t, double>> direct_values;
156 direct_values.reserve(surface_mesh->getNumberOfNodes());
158 for (
auto const* node : surface_mesh->getNodes())
160 auto const id(node->getID());
161 auto const subsurface_node_id((*node_id_pv)[
id]);
162 auto const val(integrated_values[
id]);
163 direct_values.emplace_back(subsurface_node_id, val);
167 surface_mesh->getProperties().createNewPropertyVector<
double>(
169 pv->resize(surface_mesh->getNodes().size());
170 for (std::size_t k(0); k < surface_mesh->getNodes().size(); ++k)
172 (*pv)[k] = direct_values[k].second;
177 std::ofstream result_out(result_file.getValue() +
".txt");
178 result_out.precision(std::numeric_limits<double>::digits10);
179 for (
auto const&
p : direct_values)
181 result_out <<
p.first <<
" " <<
p.second <<
"\n";
Definition of the Element class.
void INFO(char const *fmt, Args const &... args)
void ERR(char const *fmt, Args const &... args)
void WARN(char const *fmt, Args const &... args)
Definition of the Mesh class.
Definition of the Node class.
std::vector< Node * > const & getNodes() const
Get the nodes-vector for the mesh.
unsigned getDimension() const
Returns the dimension of the mesh (determined by the maximum dimension over all elements).
Properties & getProperties()
std::vector< Element const * > const & getElementsConnectedToNode(std::size_t node_id) const
PropertyVector< T > const * getPropertyVector(std::string const &name) const
bool existsPropertyVector(std::string const &name) const
int main(int argc, char *argv[])
std::vector< double > getSurfaceIntegratedValuesForNodes(const MeshLib::Mesh &mesh, std::string const &prop_name)
GITINFOLIB_EXPORT const std::string ogs_version
MeshLib::Mesh * readMeshFromFile(const std::string &file_name)
int writeMeshToFile(const MeshLib::Mesh &mesh, std::filesystem::path const &file_path, [[maybe_unused]] std::set< std::string > variable_output_names)
Definition of readMeshFromFile function.