26{
27 constexpr int mat_not_set = std::numeric_limits<int>::max();
28
29 TCLAP::CmdLine cmd(
30 "Marks all elements in a voxel grid (i.e. a structured hex grid, for "
31 "instance created with Layers2Grid or Vtu2Grid) that are intersected "
32 "by a triangulated 2D mesh representing a fault or some other "
33 "significant structure. The material group for those intersected "
34 "elements can be explicitly specified, otherwise the largest existing "
35 "MaterialID will be increased by one.\n\n"
36 "OpenGeoSys-6 software, version " +
38 ".\n"
39 "Copyright (c) 2012-2025, OpenGeoSys Community "
40 "(http://www.opengeosys.org)",
42 TCLAP::ValueArg<int> id_arg(
43 "m", "material",
44 "material id for cells intersected by fault, (min = 0)", false,
45 mat_not_set, "MATERIAL_ID");
46 cmd.add(id_arg);
47
48 TCLAP::ValueArg<std::string> output_arg(
49 "o", "output", "Output (.vtu). Name of output mesh file", true, "",
50 "OUTPUT_FILE");
51 cmd.add(output_arg);
52
53 TCLAP::ValueArg<std::string> fault_arg(
54 "f", "fault", "Input (.vtu). Name of mesh file representing fault",
55 true, "", "INPUT_FILE");
56 cmd.add(fault_arg);
57
58 TCLAP::ValueArg<std::string> input_arg(
59 "i", "input",
60 "Input (.vtu). Name of the input file containing the paths the "
61 "all input "
62 "in correct order from top to bottom",
63 true, "", "INPUT_FILE");
64 cmd.add(input_arg);
65 cmd.parse(argc, argv);
66
68
69 std::string const input_name = input_arg.getValue();
70 std::string const fault_name = fault_arg.getValue();
71 std::string const output_name = output_arg.getValue();
72
74
75 std::unique_ptr<MeshLib::Mesh> mesh(
77 std::unique_ptr<MeshLib::Mesh> fault(
79 if (mesh == nullptr)
80 {
81 ERR(
"Input mesh not found...");
82 return EXIT_FAILURE;
83 }
85 if (!mat_ids)
86 {
87 ERR(
"Input mesh has no material IDs");
88 return EXIT_FAILURE;
89 }
90 int fault_id = id_arg.getValue();
91 if (!id_arg.isSet())
92 {
93 auto it = std::max_element(mat_ids->cbegin(), mat_ids->cend());
94 fault_id = *it + 1;
95 }
97 {
99 vtu.writeToFile(output_name);
100 INFO(
"The fault was successfully added.");
101 return EXIT_SUCCESS;
102 }
103 ERR(
"No fault could be added.");
104 return EXIT_FAILURE;
105}
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)