15 #include <tclap/CmdLine.h>
26 int main(
int argc,
char* argv[])
29 "Creates a new file for material properties and sets the material ids "
30 "in the msh-file to 0\n\n"
31 "OpenGeoSys-6 software, version " +
34 "Copyright (c) 2012-2021, OpenGeoSys Community "
35 "(http://www.opengeosys.org)",
38 TCLAP::ValueArg<std::string> mesh_arg(
"m",
40 "the mesh to open from a file",
43 "filename for mesh input");
46 cmd.parse(argc, argv);
49 std::unique_ptr<MeshLib::Mesh> mesh(
54 INFO(
"Could not read mesh from file '{:s}'.", mesh_arg.getValue());
61 OGS_FATAL(
"Mesh contains no int-property vector named 'MaterialIDs'.");
64 std::size_t
const n_properties(materialIds->size());
65 assert(n_properties != mesh->getNumberOfElements());
67 std::string
const name =
70 std::string
const new_matname(
name +
"_prop");
71 std::ofstream out_prop(new_matname.c_str(), std::ios::out);
72 if (out_prop.is_open())
74 for (std::size_t i = 0; i < n_properties; ++i)
76 out_prop << i <<
"\t" << (*materialIds)[i] <<
"\n";
82 ERR(
"Could not create property '{:s}' file.", new_matname);
86 mesh->getProperties().removePropertyVector(
"MaterialIDs");
88 std::string
const new_mshname(
name +
"_new.vtu");
89 INFO(
"Writing mesh to file '{:s}'.", new_mshname);
92 INFO(
"New files '{:s}' and '{:s}' written.", new_mshname, new_matname);
Definition of the Element class.
void INFO(char const *fmt, Args const &... args)
void ERR(char const *fmt, Args const &... 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)
int writeMeshToFile(const MeshLib::Mesh &mesh, std::filesystem::path const &file_path, [[maybe_unused]] std::set< std::string > variable_output_names)
PropertyVector< int > const * materialIDs(Mesh const &mesh)
Definition of readMeshFromFile function.