31{
32 TCLAP::CmdLine cmd(
33 "Revises meshes by collapsing duplicate nodes, (optionally) removing "
34 "elements of lower dimension than the mesh itself, and subdividing "
35 "geometrically broken mesh elements.\n\n"
36 "OpenGeoSys-6 software, version " +
38 ".\n"
39 "Copyright (c) 2012-2024, OpenGeoSys Community "
40 "(http://www.opengeosys.org)",
42 TCLAP::ValueArg<unsigned> minDim_arg(
43 "d", "min-ele-dim",
44 "Minimum dimension of elements to be inserted into new mesh", false, 1,
45 "unsigned");
46 cmd.add(minDim_arg);
47
48 TCLAP::ValueArg<double> eps_arg(
49 "e", "eps", "Minimum distance for nodes not to be collapsed", false,
50 std::numeric_limits<double>::epsilon(), "float");
51 cmd.add(eps_arg);
52
53 TCLAP::ValueArg<std::string> output_arg(
54 "o", "output-mesh-file", "output mesh file", true, "", "string");
55 cmd.add(output_arg);
56
57 TCLAP::ValueArg<std::string> input_arg(
58 "i", "input-mesh-file", "input mesh file", true, "", "string");
59 cmd.add(input_arg);
60 cmd.parse(argc, argv);
61
62#ifdef USE_PETSC
63 MPI_Init(&argc, &argv);
64#endif
65
66
67 std::unique_ptr<MeshLib::Mesh> org_mesh(
69 if (!org_mesh)
70 {
71#ifdef USE_PETSC
72 MPI_Finalize();
73#endif
74 return EXIT_FAILURE;
75 }
76 INFO(
"Mesh read: {:d} nodes, {:d} elements.", org_mesh->getNumberOfNodes(),
77 org_mesh->getNumberOfElements());
78
79
80 INFO(
"Simplifying the mesh...");
82 unsigned int minDim =
83 (minDim_arg.isSet() ? minDim_arg.getValue() : org_mesh->getDimension());
84 std::unique_ptr<MeshLib::Mesh> new_mesh(
85 rev.simplifyMesh("revised_mesh", eps_arg.getValue(), minDim));
86
87
88 if (new_mesh)
89 {
90 INFO(
"Revised mesh: {:d} nodes, {:d} elements.",
91 new_mesh->getNumberOfNodes(), new_mesh->getNumberOfElements());
93 }
94
95#ifdef USE_PETSC
96 MPI_Finalize();
97#endif
98 return EXIT_SUCCESS;
99}
void INFO(fmt::format_string< Args... > fmt, Args &&... args)
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)