28{
29 TCLAP::CmdLine cmd(
30 "Adds a layer to an existing mesh."
31 "The documentation is available at "
32 "https://www.opengeosys.org/docs/tools/meshing/addlayer."
33 "\n"
34 "OpenGeoSys-6 software, version " +
36 ".\n"
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");
43 cmd.add(mesh_arg);
44
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,
48 "", "file name");
49 cmd.add(mesh_out_arg);
50
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);
55
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.",
60 true);
61 cmd.add(layer_position_arg);
62
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 "
67 "created.",
68 false);
69 cmd.add(copy_material_ids_arg);
70
71 cmd.parse(argc, argv);
72
73#ifdef USE_PETSC
74 MPI_Init(&argc, &argv);
75#endif
76
77 INFO(
"Reading mesh '{:s}' ... ", mesh_arg.getValue());
78 auto subsfc_mesh = std::unique_ptr<MeshLib::Mesh>(
80 if (!subsfc_mesh)
81 {
82 ERR(
"Error reading mesh '{:s}'.", mesh_arg.getValue());
83#ifdef USE_PETSC
84 MPI_Finalize();
85#endif
86 return EXIT_FAILURE;
87 }
89
91 *subsfc_mesh, layer_thickness_arg.getValue(), mesh_out_arg.getValue(),
92 layer_position_arg.getValue(), copy_material_ids_arg.getValue()));
93 if (!result)
94 {
95 ERR(
"Failure while adding layer.");
96#ifdef USE_PETSC
97 MPI_Finalize();
98#endif
99 return EXIT_FAILURE;
100 }
101
102 INFO(
"Writing mesh '{:s}' ... ", mesh_out_arg.getValue());
105
106#ifdef USE_PETSC
107 MPI_Finalize();
108#endif
109 return EXIT_SUCCESS;
110}
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)