41{
44
45 TCLAP::CmdLine cmd(
46 "Checks if the subdomain meshes are part of the bulk mesh and writes "
47 "the 'bulk_node_ids' and the 'bulk_element_ids' in each of them. The "
48 "documentation is available at "
49 "https://www.opengeosys.org/docs/tools/meshing-submeshes/"
50 "identifysubdomains/.\n\n"
51 "OpenGeoSys-6 software, version " +
53 ".\n"
54 "Copyright (c) 2012-2026, OpenGeoSys Community "
55 "(http://www.opengeosys.org)",
57
58 TCLAP::SwitchArg force_overwrite_arg(
59 "f", "force", "Overwriting existing subdomain meshes.");
60 cmd.add(force_overwrite_arg);
61
62 TCLAP::ValueArg<std::string> output_prefix_arg(
63 "o",
64 "output_prefix",
65 "Output. Prefix the subdomain meshes' filenames with the output "
66 "prefix/path.",
67 false,
68 "",
69 "BASE_FILENAME_OUTPUT");
70 cmd.add(output_prefix_arg);
71
72 TCLAP::ValueArg<double> search_length_arg(
73 "s",
74 "searchlength",
75 "search length determining radius for the node search algorithm. "
76 "Non-negative floating point number (min = 0) ",
77 false,
78 1e-16,
79 "SEARCH_LENGTH");
80 cmd.add(search_length_arg);
81
82 TCLAP::ValueArg<std::string> bulk_mesh_arg(
83 "m", "mesh", "Input (.vtu). The file name of the bulk mesh", true, "",
84 "INPUT_FILE");
85 cmd.add(bulk_mesh_arg);
86
87
88
89 TCLAP::UnlabeledMultiArg<std::string> subdomain_meshes_filenames_arg(
90 "subdomain_meshes_filenames", "mesh file names.", true,
91 "SUBDOMAIN_NAME");
92 cmd.add(subdomain_meshes_filenames_arg);
94 cmd.add(log_level_arg);
95 cmd.parse(argc, argv);
96
99
100
101
102
104 mesh_reading_time.
start();
105 std::unique_ptr<MeshLib::Mesh> bulk_mesh{
107 if (bulk_mesh == nullptr)
108 {
109 OGS_FATAL(
"Could not read bulk mesh from '{:s}'",
110 bulk_mesh_arg.getValue());
111 }
112
113
114
115
116 auto const subdomain_meshes =
117 readMeshes(subdomain_meshes_filenames_arg.getValue());
118 INFO(
"Mesh reading time: {:g} s", mesh_reading_time.
elapsed());
119
120
121
122
124 mesh_node_searcher_construction_time.
start();
125 auto const& mesh_node_searcher =
127 *bulk_mesh,
128 std::make_unique<MeshGeoToolsLib::SearchLength>(
129 search_length_arg.getValue()));
130 INFO(
"MeshNodeSearcher construction time: {:g} s",
131 mesh_node_searcher_construction_time.
elapsed());
132
133
134
135
137 identify_subdomain_time.
start();
138 for (auto& mesh_ptr : subdomain_meshes)
139 {
140
141
142 bool const overwrite_property_vectors =
143 force_overwrite_arg.getValue() ||
144 !output_prefix_arg.getValue().empty();
146 overwrite_property_vectors);
147 }
148 INFO(
"identifySubdomains time: {:g} s", identify_subdomain_time.
elapsed());
149
150
151
152
154 writing_time.
start();
155 for (auto const& mesh_ptr : subdomain_meshes)
156 {
158 *mesh_ptr,
159 output_prefix_arg.getValue() + mesh_ptr->getName() + ".vtu");
160 }
161 INFO(
"writing time: {:g} s", writing_time.
elapsed());
162
163 INFO(
"Entire run time: {:g} s", run_time.
elapsed());
164 return EXIT_SUCCESS;
165}
void INFO(fmt::format_string< Args... > fmt, Args &&... args)
double elapsed() const
Get the elapsed time in seconds.
void start()
Start the timer.
std::vector< std::unique_ptr< MeshLib::Mesh > > readMeshes(std::vector< std::string > const &filenames)
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)