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