25{
26 TCLAP::CmdLine cmd(
27 "Adds a layer to an existing mesh."
28 "The documentation is available at "
29 "https://www.opengeosys.org/docs/tools/meshing/addlayer."
30 "\n"
31 "OpenGeoSys-6 software, version " +
33 ".\n"
34 "Copyright (c) 2012-2024, OpenGeoSys Community "
35 "(https://www.opengeosys.org)",
37 TCLAP::ValueArg<std::string> mesh_arg(
38 "i", "input-mesh-file", "the name of the file containing the mesh",
39 true, "", "file name");
40 cmd.add(mesh_arg);
41
42 TCLAP::ValueArg<std::string> mesh_out_arg(
43 "o", "output-mesh-file",
44 "the name of the file the mesh should be written to (vtu format)", true,
45 "", "file name");
46 cmd.add(mesh_out_arg);
47
48 TCLAP::ValueArg<double> layer_thickness_arg(
49 "t", "layer-tickness", "the thickness of the new layer", false, 10,
50 "floating point value");
51 cmd.add(layer_thickness_arg);
52
53 TCLAP::SwitchArg layer_position_arg(
54 "", "add-layer-on-bottom",
55 "Per default the layer is add on the top, if this argument is set the "
56 "layer is add on the bottom.",
57 true);
58 cmd.add(layer_position_arg);
59
60 TCLAP::SwitchArg copy_material_ids_arg(
61 "", "copy-material-ids",
62 "Copy the existing material distribution of the layer which is to be "
63 "extended. If the switch isn't given a new material id will be "
64 "created.",
65 false);
66 cmd.add(copy_material_ids_arg);
67
68 TCLAP::ValueArg<int> set_material_arg("", "set-material-id",
69 "the material id of the new layer",
70 false, 0, "integer value");
71 cmd.add(set_material_arg);
72 cmd.parse(argc, argv);
73
74 if (set_material_arg.isSet() && copy_material_ids_arg.isSet())
75 {
76 ERR(
"It is not possible to set both options '--copy-material-ids' and "
77 "'--set-material-id'.");
78 return EXIT_FAILURE;
79 }
80
82
83 INFO(
"Reading mesh '{:s}' ... ", mesh_arg.getValue());
84 auto subsfc_mesh = std::unique_ptr<MeshLib::Mesh>(
86 if (!subsfc_mesh)
87 {
88 ERR(
"Error reading mesh '{:s}'.", mesh_arg.getValue());
89 return EXIT_FAILURE;
90 }
92
93 std::optional<int> layer_id;
94 if (set_material_arg.isSet())
95 {
96 layer_id = set_material_arg.getValue();
97 }
98
100 *subsfc_mesh, layer_thickness_arg.getValue(), mesh_out_arg.getValue(),
101 layer_position_arg.getValue(), copy_material_ids_arg.getValue(),
102 layer_id));
103 if (!result)
104 {
105 ERR(
"Failure while adding layer.");
106 return EXIT_FAILURE;
107 }
108
109 INFO(
"Writing mesh '{:s}' ... ", mesh_out_arg.getValue());
112
113 return EXIT_SUCCESS;
114}
void INFO(fmt::format_string< Args... > fmt, Args &&... args)
void ERR(fmt::format_string< Args... > fmt, Args &&... args)
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)