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-2025, 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, (min = 0)",
54 false,
55 1e-16,
56 "float");
57 cmd.add(search_length_arg);
58
59 TCLAP::ValueArg<std::string> geometry_arg(
60 "g",
61 "geometry",
62 "Input (.gml | .gli). The file name of the input geometry",
63 true,
64 "",
65 "INPUT_FILE");
66 cmd.add(geometry_arg);
67
68 TCLAP::ValueArg<std::string> mesh_arg(
69 "m",
70 "mesh",
71 "Input (.vtu). "
72 "The file name of the input mesh where the geometry is defined",
73 true,
74 "",
75 "INPUT_FILE");
76 cmd.add(mesh_arg);
77
78 TCLAP::SwitchArg multiple_nodes_allowed_arg(
79 "", "multiple-nodes-allowed",
80 "Allows multiple mesh nodes in eps environment.");
81 cmd.add(multiple_nodes_allowed_arg);
82
84 cmd.add(log_level_arg);
85 cmd.parse(argc, argv);
86
89
90 std::unique_ptr<MeshLib::Mesh> mesh{
92
93 auto const geo_objects =
readGeometry(geometry_arg.getValue());
94
95 double const search_length = search_length_arg.getValue();
96
98 *geo_objects,
99 *mesh,
100 std::make_unique<MeshGeoToolsLib::SearchLength>(search_length),
101 multiple_nodes_allowed_arg.getValue());
102
103 for (auto const& m_ptr : extracted_meshes)
104 {
105 if (!m_ptr)
106 {
107 ERR(
"Could not create a mesh for each given geometry.");
108 return EXIT_FAILURE;
109 }
110 if (m_ptr->getNodes().empty())
111 {
113 "The created mesh '{:s}' hasn't any nodes or elements and thus "
114 "it isn't written to file.",
115 m_ptr->getName());
116 continue;
117 }
119 }
120
121 return EXIT_SUCCESS;
122}
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)
TCLAP::ValueArg< std::string > makeLogLevelArg()
void initOGSLogger(std::string const &log_level)
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)