19int main(
int argc,
char* argv[])
22 "Creates a new file for material properties and sets the material ids "
23 "in the msh-file to 0\n\n"
24 "OpenGeoSys-6 software, version " +
27 "Copyright (c) 2012-2026, OpenGeoSys Community "
28 "(http://www.opengeosys.org)",
31 TCLAP::ValueArg<std::string> mesh_arg(
34 "Input (.msh). The mesh to open from a file",
40 cmd.add(log_level_arg);
42 cmd.parse(argc, argv);
48 std::unique_ptr<MeshLib::Mesh> mesh(
53 INFO(
"Could not read mesh from file '{:s}'.", mesh_arg.getValue());
57 auto const materialIds = materialIDs(*mesh);
60 OGS_FATAL(
"Mesh contains no int-property vector named 'MaterialIDs'.");
63 std::size_t
const n_properties(materialIds->size());
64 assert(n_properties != mesh->getNumberOfElements());
66 std::string
const name =
69 std::string
const new_matname(name +
"_prop");
70 std::ofstream out_prop(new_matname.c_str(), std::ios::out);
71 if (out_prop.is_open())
73 for (std::size_t i = 0; i < n_properties; ++i)
75 out_prop << i <<
"\t" << (*materialIds)[i] <<
"\n";
81 ERR(
"Could not create property '{:s}' file.", new_matname);
85 mesh->getProperties().removePropertyVector(
"MaterialIDs");
87 std::string
const new_mshname(name +
"_new.vtu");
88 INFO(
"Writing mesh to file '{:s}'.", new_mshname);
91 INFO(
"New files '{:s}' and '{:s}' written.", new_mshname, new_matname);