27int main(
int argc,
char* argv[])
30 "Adds a layer to an existing mesh."
31 "The documentation is available at "
32 "https://www.opengeosys.org/docs/tools/meshing/addlayer."
34 "OpenGeoSys-6 software, version " +
37 "Copyright (c) 2012-2024, OpenGeoSys Community "
38 "(https://www.opengeosys.org)",
40 TCLAP::ValueArg<std::string> mesh_arg(
41 "i",
"input-mesh-file",
"the name of the file containing the mesh",
42 true,
"",
"file name");
45 TCLAP::ValueArg<std::string> mesh_out_arg(
46 "o",
"output-mesh-file",
47 "the name of the file the mesh should be written to (vtu format)",
true,
49 cmd.add(mesh_out_arg);
51 TCLAP::ValueArg<double> layer_thickness_arg(
52 "t",
"layer-tickness",
"the thickness of the new layer",
false, 10,
53 "floating point value");
54 cmd.add(layer_thickness_arg);
56 TCLAP::SwitchArg layer_position_arg(
57 "",
"add-layer-on-bottom",
58 "Per default the layer is add on the top, if this argument is set the "
59 "layer is add on the bottom.",
61 cmd.add(layer_position_arg);
63 TCLAP::SwitchArg copy_material_ids_arg(
64 "",
"copy-material-ids",
65 "Copy the existing material distribution of the layer which is to be "
66 "extended. If the switch isn't given a new material id will be "
69 cmd.add(copy_material_ids_arg);
71 TCLAP::ValueArg<int> set_material_arg(
"",
"set-material-id",
72 "the material id of the new layer",
73 false, 0,
"integer value");
74 cmd.add(set_material_arg);
75 cmd.parse(argc, argv);
77 if (set_material_arg.isSet() && copy_material_ids_arg.isSet())
79 ERR(
"It is not possible to set both options '--copy-material-ids' and "
80 "'--set-material-id'.");
88 MPI_Init(&argc, &argv);
91 INFO(
"Reading mesh '{:s}' ... ", mesh_arg.getValue());
92 auto subsfc_mesh = std::unique_ptr<MeshLib::Mesh>(
96 ERR(
"Error reading mesh '{:s}'.", mesh_arg.getValue());
104 std::optional<int> layer_id;
105 if (set_material_arg.isSet())
107 layer_id = set_material_arg.getValue();
111 *subsfc_mesh, layer_thickness_arg.getValue(), mesh_out_arg.getValue(),
112 layer_position_arg.getValue(), copy_material_ids_arg.getValue(),
116 ERR(
"Failure while adding layer.");
123 INFO(
"Writing mesh '{:s}' ... ", mesh_out_arg.getValue());