29{
30 constexpr int mat_not_set = std::numeric_limits<int>::max();
31
32 TCLAP::CmdLine cmd(
33 "Marks all elements in a voxel grid (i.e. a structured hex grid, for "
34 "instance created with Layers2Grid or Vtu2Grid) that are intersected "
35 "by a triangulated 2D mesh representing a fault or some other "
36 "significant structure. The material group for those intersected "
37 "elements can be explicitly specified, otherwise the largest existing "
38 "MaterialID will be increased by one.\n\n"
39 "OpenGeoSys-6 software, version " +
41 ".\n"
42 "Copyright (c) 2012-2024, OpenGeoSys Community "
43 "(http://www.opengeosys.org)",
45 TCLAP::ValueArg<int> id_arg("m", "material",
46 "material id for cells intersected by fault",
47 false, mat_not_set, "non-negative integer");
48 cmd.add(id_arg);
49
50 TCLAP::ValueArg<std::string> output_arg(
51 "o", "output", "name of output mesh (*.vtu)", true, "", "string");
52 cmd.add(output_arg);
53
54 TCLAP::ValueArg<std::string> fault_arg(
55 "f", "fault", "name of mesh representing fault (*.vtu)", true, "",
56 "string");
57 cmd.add(fault_arg);
58
59 TCLAP::ValueArg<std::string> input_arg(
60 "i", "input",
61 "name of the input file list containing the paths the all input layers "
62 "in correct order from top to bottom",
63 true, "", "string");
64 cmd.add(input_arg);
65 cmd.parse(argc, argv);
66
67#ifdef USE_PETSC
68 MPI_Init(&argc, &argv);
69#endif
70
71 std::string const input_name = input_arg.getValue();
72 std::string const fault_name = fault_arg.getValue();
73 std::string const output_name = output_arg.getValue();
74
76
77 std::unique_ptr<MeshLib::Mesh> mesh(
79 std::unique_ptr<MeshLib::Mesh> fault(
81 if (mesh == nullptr)
82 {
83 ERR(
"Input mesh not found...");
84#ifdef USE_PETSC
85 MPI_Finalize();
86#endif
87 return EXIT_FAILURE;
88 }
90 if (!mat_ids)
91 {
92#ifdef USE_PETSC
93 MPI_Finalize();
94#endif
95 ERR(
"Input mesh has no material IDs");
96 return EXIT_FAILURE;
97 }
98 int fault_id = id_arg.getValue();
99 if (!id_arg.isSet())
100 {
101 auto it = std::max_element(mat_ids->cbegin(), mat_ids->cend());
102 fault_id = *it + 1;
103 }
105 {
107 vtu.writeToFile(output_name);
108#ifdef USE_PETSC
109 MPI_Finalize();
110#endif
111 INFO(
"The fault was successfully added.");
112 return EXIT_SUCCESS;
113 }
114#ifdef USE_PETSC
115 MPI_Finalize();
116#endif
117 ERR(
"No fault could be added.");
118 return EXIT_FAILURE;
119}
void INFO(fmt::format_string< Args... > fmt, Args &&... args)
void ERR(fmt::format_string< Args... > fmt, Args &&... args)
Reads and writes VtkXMLUnstructuredGrid-files (vtu) to and from OGS data structures....
GITINFOLIB_EXPORT const std::string ogs_version
MeshLib::Mesh * readMeshFromFile(const std::string &file_name, bool const compute_element_neighbors)
PropertyVector< int > const * materialIDs(Mesh const &mesh)