36{
37 TCLAP::CmdLine cmd(
38 "Converts a geometry defined on a given mesh to distinct meshes. The "
39 "documentation is available at "
40 "https://www.opengeosys.org/docs/tools/meshing-submeshes/"
41 "constructmeshesfromgeometry/.\n\n"
42 "OpenGeoSys-6 software, version " +
44 ".\n"
45 "Copyright (c) 2012-2024, OpenGeoSys Community "
46 "(http://www.opengeosys.org)",
48
49 TCLAP::ValueArg<double> search_length_arg(
50 "s",
51 "searchlength",
52 "search length determining radius for the node search algorithm. "
53 "Non-negative floating point number (default 1e-16) ",
54 false,
55 1e-16,
56 "float");
57 cmd.add(search_length_arg);
58
59 TCLAP::ValueArg<std::string> geometry_arg("g",
60 "geometry",
61 "the file name the geometry",
62 true,
63 "",
64 "geometry file name");
65 cmd.add(geometry_arg);
66
67 TCLAP::ValueArg<std::string> mesh_arg(
68 "m",
69 "mesh",
70 "the file name of the mesh where the geometry is defined",
71 true,
72 "",
73 "mesh file name");
74 cmd.add(mesh_arg);
75
76 TCLAP::SwitchArg multiple_nodes_allowed_arg(
77 "", "multiple-nodes-allowed",
78 "Allows multiple mesh nodes in eps environment.");
79 cmd.add(multiple_nodes_allowed_arg);
80
81 cmd.parse(argc, argv);
82
83#ifdef USE_PETSC
84 MPI_Init(&argc, &argv);
85#endif
86 std::unique_ptr<MeshLib::Mesh> mesh{
88
89 auto const geo_objects =
readGeometry(geometry_arg.getValue());
90
91 double const search_length = search_length_arg.getValue();
92
94 *geo_objects,
95 *mesh,
96 std::make_unique<MeshGeoToolsLib::SearchLength>(search_length),
97 multiple_nodes_allowed_arg.getValue());
98
99 for (auto const& m_ptr : extracted_meshes)
100 {
101 if (!m_ptr)
102 {
103 ERR(
"Could not create a mesh for each given geometry.");
104#ifdef USE_PETSC
105 MPI_Finalize();
106#endif
107 return EXIT_FAILURE;
108 }
109 if (m_ptr->getNodes().empty())
110 {
112 "The created mesh '{:s}' hasn't any nodes or elements and thus "
113 "it isn't written to file.",
114 m_ptr->getName());
115 continue;
116 }
118 }
119
120#ifdef USE_PETSC
121 MPI_Finalize();
122#endif
123 return EXIT_SUCCESS;
124}
void ERR(fmt::format_string< Args... > fmt, Args &&... args)
void WARN(fmt::format_string< Args... > fmt, Args &&... args)
std::unique_ptr< GeoLib::GEOObjects > readGeometry(std::string const &filename)
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)