28{
29 TCLAP::CmdLine cmd(
30 "Tool merges one mesh to a bulk mesh.\n\n"
31 "OpenGeoSys-6 software, version " +
33 ".\n"
34 "Copyright (c) 2012-2026, OpenGeoSys Community "
35 "(http://www.opengeosys.org)",
37 TCLAP::ValueArg<std::string> bulk_mesh_in(
38 "b", "bulk-mesh-input-file",
39 "Input (.vtk | .msh). The name of the file containing the input bulk "
40 "mesh",
41 true, "", "INPUT_FILE");
42 cmd.add(bulk_mesh_in);
43 TCLAP::ValueArg<std::string> mesh_in(
44 "i", "mesh-input-file",
45 "Input (.vtk | .msh). The name of the file containing the input mesh "
46 "to be merged",
47 true, "", "INPUT_FILE");
48 cmd.add(mesh_in);
49 TCLAP::ValueArg<std::string> mesh_out(
50 "o", "mesh-output-file",
51 "Output (.vtk | .msh). The name of the file the merged mesh should be "
52 "written to",
53 true, "", "OUTPUT_FILE");
54 cmd.add(mesh_out);
55
56 TCLAP::ValueArg<double> p("", "pressure",
57 "initial pressure value in the mesh to be merged",
58 false, 0.0, "PRESSURE");
59 cmd.add(p);
60
61 TCLAP::ValueArg<double> pg(
62 "", "gas_pressure",
63 "initial gas pressure value in the mesh to be merged", false, 0.0,
64 "GAS_PRESSURE");
65 cmd.add(pg);
66
67 TCLAP::ValueArg<double> pc(
68 "", "capillary_pressure",
69 "initial capillary pressure value in the mesh to be merged", false, 0.0,
70 "CAPILLARY_PRESSURE");
71 cmd.add(pc);
72
73 TCLAP::ValueArg<double> T(
74 "", "temperature", "initial temperature value in the mesh to be merged",
75 false, 290.0, "TEMPERATURE");
76 cmd.add(T);
77
78 TCLAP::ValueArg<double> sxx(
79 "", "sigma_xx", "initial stress xx value in the mesh to be merged",
80 false, 0.0, "SIGMA_XX");
81 cmd.add(sxx);
82 TCLAP::ValueArg<double> syy(
83 "", "sigma_yy", "initial stress yy value in the mesh to be merged",
84 false, 0.0, "SIGMA_YY");
85 cmd.add(syy);
86 TCLAP::ValueArg<double> szz(
87 "", "sigma_zz", "initial stress zz value in the mesh to be merged",
88 false, 0.0, "SIGMA_ZZ");
89 cmd.add(szz);
90
91 TCLAP::ValueArg<int> mat_id(
92 "", "material_id", "Material ID of the mesh to be merged, (min = 0)",
93 false, 0.0, "MATERIAL_ID");
94 cmd.add(mat_id);
96 cmd.add(log_level_arg);
97
98 cmd.parse(argc, argv);
99
102
105
106 std::unordered_map<std::string, double> initial_value_dict;
107 initial_value_dict.insert({"p", p.getValue()});
108 initial_value_dict.insert({"pg", pg.getValue()});
109 initial_value_dict.insert({"pc", pc.getValue()});
110 initial_value_dict.insert({"T", T.getValue()});
111 initial_value_dict.insert({"sxx", sxx.getValue()});
112 initial_value_dict.insert({"syy", syy.getValue()});
113 initial_value_dict.insert({"szz", szz.getValue()});
114 initial_value_dict.insert({"mat_id", mat_id.getValue()});
115
116 auto read_mesh = [](std::string const& mesh_file_name)
117 {
119 mesh_file_name, true ));
120
121 if (!mesh)
122 {
123 OGS_FATAL(
"Could not read the mesh {:s}", mesh_file_name);
124 }
125
126 INFO(
"Read {:s}: {:d} nodes, {:d} elements.", mesh_file_name,
127 mesh->getNumberOfNodes(), mesh->getNumberOfElements());
128 return mesh;
129 };
130
131 auto bulk_mesh = read_mesh(bulk_mesh_in.getValue());
132 auto const mesh_to_be_merged = read_mesh(mesh_in.getValue());
133
135 *bulk_mesh, *mesh_to_be_merged, initial_value_dict);
136
138 0)
139 {
140 ERR(
"Could not write mesh to '{:s}'.", mesh_out.getValue());
141 return EXIT_FAILURE;
142 }
144
145
146
147
148
149
150 mesh_to_be_merged->shallowClean();
151 bulk_mesh->shallowClean();
152
153 return EXIT_SUCCESS;
154}
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.
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 > output_variable_names, bool const use_compression, int const data_mode)