29{
30 TCLAP::CmdLine cmd(
31 "Converts a geometry defined on a given mesh to distinct meshes. The "
32 "documentation is available at "
33 "https://www.opengeosys.org/docs/tools/meshing-submeshes/"
34 "constructmeshesfromgeometry/.\n\n"
35 "OpenGeoSys-6 software, version " +
37 ".\n"
38 "Copyright (c) 2012-2026, OpenGeoSys Community "
39 "(http://www.opengeosys.org)",
41
42 TCLAP::ValueArg<double> search_length_arg(
43 "s",
44 "searchlength",
45 "search length determining radius for the node search algorithm. "
46 "Non-negative floating point number, (min = 0)",
47 false,
48 1e-16,
49 "float");
50 cmd.add(search_length_arg);
51
52 TCLAP::ValueArg<std::string> geometry_arg(
53 "g",
54 "geometry",
55 "Input (.gml | .gli). The file name of the input geometry",
56 true,
57 "",
58 "INPUT_FILE");
59 cmd.add(geometry_arg);
60
61 TCLAP::ValueArg<std::string> mesh_arg(
62 "m",
63 "mesh",
64 "Input (.vtu). "
65 "The file name of the input mesh where the geometry is defined",
66 true,
67 "",
68 "INPUT_FILE");
69 cmd.add(mesh_arg);
70
71 TCLAP::SwitchArg multiple_nodes_allowed_arg(
72 "", "multiple-nodes-allowed",
73 "Allows multiple mesh nodes in eps environment.");
74 cmd.add(multiple_nodes_allowed_arg);
75
77 cmd.add(log_level_arg);
78 cmd.parse(argc, argv);
79
82
83 std::unique_ptr<MeshLib::Mesh> mesh{
85
86 auto const geo_objects =
readGeometry(geometry_arg.getValue());
87
88 double const search_length = search_length_arg.getValue();
89
91 *geo_objects,
92 *mesh,
93 std::make_unique<MeshGeoToolsLib::SearchLength>(search_length),
94 multiple_nodes_allowed_arg.getValue());
95
96 for (auto const& m_ptr : extracted_meshes)
97 {
98 if (!m_ptr)
99 {
100 ERR(
"Could not create a mesh for each given geometry.");
101 return EXIT_FAILURE;
102 }
103 if (m_ptr->getNodes().empty())
104 {
106 "The created mesh '{:s}' hasn't any nodes or elements and thus "
107 "it isn't written to file.",
108 m_ptr->getName());
109 continue;
110 }
112 }
113
114 return EXIT_SUCCESS;
115}
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)