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