37{
38 TCLAP::CmdLine cmd(
39 "Tool merges one mesh to a bulk mesh.\n\n"
40 "OpenGeoSys-6 software, version " +
42 ".\n"
43 "Copyright (c) 2012-2025, OpenGeoSys Community "
44 "(http://www.opengeosys.org)",
46 TCLAP::ValueArg<std::string> bulk_mesh_in(
47 "b", "bulk-mesh-input-file",
48 "Input (.vtk | .msh). The name of the file containing the input bulk "
49 "mesh",
50 true, "", "INPUT_FILE");
51 cmd.add(bulk_mesh_in);
52 TCLAP::ValueArg<std::string> mesh_in(
53 "i", "mesh-input-file",
54 "Input (.vtk | .msh). The name of the file containing the input mesh "
55 "to be merged",
56 true, "", "INPUT_FILE");
57 cmd.add(mesh_in);
58 TCLAP::ValueArg<std::string> mesh_out(
59 "o", "mesh-output-file",
60 "Output (.vtk | .msh). The name of the file the merged mesh should be "
61 "written to",
62 true, "", "OUTPUT_FILE");
63 cmd.add(mesh_out);
64
65 TCLAP::ValueArg<double> p("", "pressure",
66 "initial pressure value in the mesh to be merged",
67 false, 0.0, "PRESSURE");
68 cmd.add(p);
69
70 TCLAP::ValueArg<double> pg(
71 "", "gas_pressure",
72 "initial gas pressure value in the mesh to be merged", false, 0.0,
73 "GAS_PRESSURE");
74 cmd.add(pg);
75
76 TCLAP::ValueArg<double> pc(
77 "", "capillary_pressure",
78 "initial capillary pressure value in the mesh to be merged", false, 0.0,
79 "CAPILLARY_PRESSURE");
80 cmd.add(pc);
81
82 TCLAP::ValueArg<double> T(
83 "", "temperature", "initial temperature value in the mesh to be merged",
84 false, 290.0, "TEMPERATURE");
85 cmd.add(T);
86
87 TCLAP::ValueArg<double> sxx(
88 "", "sigma_xx", "initial stress xx value in the mesh to be merged",
89 false, 0.0, "SIGMA_XX");
90 cmd.add(sxx);
91 TCLAP::ValueArg<double> syy(
92 "", "sigma_yy", "initial stress yy value in the mesh to be merged",
93 false, 0.0, "SIGMA_YY");
94 cmd.add(syy);
95 TCLAP::ValueArg<double> szz(
96 "", "sigma_zz", "initial stress zz value in the mesh to be merged",
97 false, 0.0, "SIGMA_ZZ");
98 cmd.add(szz);
99
100 TCLAP::ValueArg<int> mat_id(
101 "", "material_id", "Material ID of the mesh to be merged, (min = 0)",
102 false, 0.0, "MATERIAL_ID");
103 cmd.add(mat_id);
105 cmd.add(log_level_arg);
106
107 cmd.parse(argc, argv);
108
111
114
115 std::unordered_map<std::string, double> initial_value_dict;
116 initial_value_dict.insert({"p", p.getValue()});
117 initial_value_dict.insert({"pg", pg.getValue()});
118 initial_value_dict.insert({"pc", pc.getValue()});
119 initial_value_dict.insert({"T", T.getValue()});
120 initial_value_dict.insert({"sxx", sxx.getValue()});
121 initial_value_dict.insert({"syy", syy.getValue()});
122 initial_value_dict.insert({"szz", szz.getValue()});
123 initial_value_dict.insert({"mat_id", mat_id.getValue()});
124
125 auto read_mesh = [](std::string const& mesh_file_name)
126 {
128 mesh_file_name, true ));
129
130 if (!mesh)
131 {
132 OGS_FATAL(
"Could not read the mesh {:s}", mesh_file_name);
133 }
134
135 INFO(
"Read {:s}: {:d} nodes, {:d} elements.", mesh_file_name,
136 mesh->getNumberOfNodes(), mesh->getNumberOfElements());
137 return mesh;
138 };
139
140 auto bulk_mesh = read_mesh(bulk_mesh_in.getValue());
141 auto const mesh_to_be_merged = read_mesh(mesh_in.getValue());
142
144 *bulk_mesh, *mesh_to_be_merged, initial_value_dict);
145
147
148 auto const result = writer.writeToFile(mesh_out.getValue());
149 if (!result)
150 {
151 ERR(
"Could not write mesh to '{:s}'.", mesh_out.getValue());
152 return EXIT_FAILURE;
153 }
155
156
157
158
159
160
161 mesh_to_be_merged->shallowClean();
162 bulk_mesh->shallowClean();
163
164 return EXIT_SUCCESS;
165}
void INFO(fmt::format_string< Args... > fmt, Args &&... args)
void ERR(fmt::format_string< Args... > fmt, Args &&... args)
double elapsed() const
Get the elapsed time in seconds.
void start()
Start the timer.
Reads and writes VtkXMLUnstructuredGrid-files (vtu) to and from OGS data structures....
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)