62 "The tool computes the area per node of the surface mesh and writes "
63 "the information as txt and csv data.\n\n"
64 "OpenGeoSys-6 software, version " +
67 "Copyright (c) 2012-2021, OpenGeoSys Community "
68 "(http://www.opengeosys.org)",
70 TCLAP::ValueArg<std::string> mesh_in(
71 "i",
"mesh-input-file",
72 "the name of the file containing the input mesh",
true,
"",
73 "file name of input mesh");
75 TCLAP::ValueArg<std::string> id_prop_name(
77 "the name of the property containing the id information",
false,
78 "bulk_node_ids",
"property name");
79 cmd.add(id_prop_name);
80 TCLAP::ValueArg<std::string> out_base_fname(
81 "p",
"output-base-name",
82 "the path and base file name the output will be written to",
false,
"",
83 "output path and base name as one string");
84 cmd.add(out_base_fname);
86 cmd.parse(argc, argv);
88 std::unique_ptr<MeshLib::Mesh> surface_mesh(
90 INFO(
"Mesh read: {:d} nodes, {:d} elements.",
91 surface_mesh->getNumberOfNodes(), surface_mesh->getNumberOfElements());
97 if (!surface_mesh->getProperties().existsPropertyVector<std::size_t>(
98 id_prop_name.getValue()))
101 surface_mesh->getProperties().createNewPropertyVector<std::size_t>(
105 ERR(
"Fatal error: could not create property.");
108 orig_node_ids->resize(surface_mesh->getNumberOfNodes());
109 std::iota(orig_node_ids->begin(), orig_node_ids->end(), 0);
114 surface_mesh->getProperties().getPropertyVector<std::size_t>(
115 id_prop_name.getValue());
118 std::vector<double> areas(
122 std::vector<std::pair<std::size_t, double>> ids_and_areas;
123 std::transform(orig_node_ids->cbegin(), orig_node_ids->cend(),
124 areas.cbegin(), std::back_inserter(ids_and_areas),
125 std::make_pair<std::size_t const&, double const&>);
128 std::string path(out_base_fname.getValue());
133 std::string
const id_and_area_fname(path +
".txt");
134 std::string
const csv_fname(path +
".csv");
136 writeToFile(id_and_area_fname, csv_fname, ids_and_areas,
137 surface_mesh->getNodes());
static void writeToFile(std::string const &id_area_fname, std::string const &csv_fname, std::vector< std::pair< std::size_t, double >> const &ids_and_areas, std::vector< MeshLib::Node * > const &mesh_nodes)
void INFO(char const *fmt, Args const &... args)
void ERR(char const *fmt, Args const &... args)
std::string dropFileExtension(std::string const &filename)
GITINFOLIB_EXPORT const std::string ogs_version
MeshLib::Mesh * readMeshFromFile(const std::string &file_name)