15#include <tclap/CmdLine.h>
31int main(
int argc,
char* argv[])
34 "Creates a new file for material properties and sets the material ids "
35 "in the msh-file to 0\n\n"
36 "OpenGeoSys-6 software, version " +
39 "Copyright (c) 2012-2024, OpenGeoSys Community "
40 "(http://www.opengeosys.org)",
43 TCLAP::ValueArg<std::string> mesh_arg(
"m",
45 "the mesh to open from a file",
48 "filename for mesh input");
51 cmd.parse(argc, argv);
54 MPI_Init(&argc, &argv);
58 std::unique_ptr<MeshLib::Mesh> mesh(
63 INFO(
"Could not read mesh from file '{:s}'.", mesh_arg.getValue());
70 auto const materialIds = materialIDs(*mesh);
73 OGS_FATAL(
"Mesh contains no int-property vector named 'MaterialIDs'.");
76 std::size_t
const n_properties(materialIds->size());
77 assert(n_properties != mesh->getNumberOfElements());
79 std::string
const name =
82 std::string
const new_matname(name +
"_prop");
83 std::ofstream out_prop(new_matname.c_str(), std::ios::out);
84 if (out_prop.is_open())
86 for (std::size_t i = 0; i < n_properties; ++i)
88 out_prop << i <<
"\t" << (*materialIds)[i] <<
"\n";
94 ERR(
"Could not create property '{:s}' file.", new_matname);
101 mesh->getProperties().removePropertyVector(
"MaterialIDs");
103 std::string
const new_mshname(name +
"_new.vtu");
104 INFO(
"Writing mesh to file '{:s}'.", new_mshname);
107 INFO(
"New files '{:s}' and '{:s}' written.", new_mshname, new_matname);
Definition of the Element class.
void INFO(fmt::format_string< Args... > fmt, Args &&... args)
void ERR(fmt::format_string< Args... > fmt, Args &&... args)
Definition of the Mesh class.
int main(int argc, char *argv[])
std::string extractBaseNameWithoutExtension(std::string const &pathname)
GITINFOLIB_EXPORT const std::string ogs_version
MeshLib::Mesh * readMeshFromFile(const std::string &file_name, bool const compute_element_neighbors)
int writeMeshToFile(const MeshLib::Mesh &mesh, std::filesystem::path const &file_path, std::set< std::string > variable_output_names)
Definition of readMeshFromFile function.