33{
34 TCLAP::CmdLine cmd(
35 "Sets the property value of a mesh element to a given new value iff at "
36 "least one node of the element is within a polygonal region that is "
37 "given by a polygon. The documentation is available at "
38 "https://docs.opengeosys.org/docs/tools/model-preparation/"
39 "set-properties-in-polygonal-region.\n\n"
40 "OpenGeoSys-6 software, version " +
42 ".\n"
43 "Copyright (c) 2012-2025, OpenGeoSys Community "
44 "(http://www.opengeosys.org)",
46 TCLAP::ValueArg<std::string> mesh_out(
47 "o", "mesh-output-file",
48 "Output. The name of the file the mesh will be written to, format "
49 "depends on "
50 "the given file name extension",
51 true, "", "OUTPUT_FILE");
52 cmd.add(mesh_out);
53 TCLAP::ValueArg<std::string> polygon_name_arg(
54 "p", "polygon-name", "name of polygon in the geometry", true, "",
55 "string");
56 cmd.add(polygon_name_arg);
57 TCLAP::ValueArg<std::string> geometry_fname(
58 "g", "geometry",
59 "Input (.gli | .gml). The name of the file containing the input "
60 "geometry",
61 true, "", "INPUT_FILE");
62 cmd.add(geometry_fname);
63 TCLAP::SwitchArg any_of_arg(
64 "", "any_of",
65 "all nodes of an element has to be inside the polygon (default "
66 "behaviour without switch) or any node of an element has to be inside "
67 "(switch is given)",
68 false);
69 cmd.add(any_of_arg);
70 TCLAP::ValueArg<char> char_property_arg(
71 "c", "char-property-value", "new property value (data type char)",
72 false, 'A', "CHAR_PROPERTY_VALUE");
73 cmd.add(char_property_arg);
74 TCLAP::ValueArg<int> int_property_arg("i", "int-property-value",
75 "new property value (data type int)",
76 false, 0, "INT_PROPERTY_VALUE");
77 cmd.add(int_property_arg);
78 TCLAP::ValueArg<std::string> property_name_arg(
79 "n", "property-name", "name of property in the mesh", false,
80 "MaterialIDs", "PROPERTY_NAME");
81 cmd.add(property_name_arg);
82 TCLAP::ValueArg<int> restrict_arg(
83 "r", "restrict-to-MaterialID",
84 "Restrict resetting the property to the material id", false, -1,
85 "RESTRICT_MATERIAL_ID");
86 cmd.add(restrict_arg);
87 TCLAP::ValueArg<std::string> mesh_in(
88 "m", "mesh-input-file",
89 "Input (.vtu | .vtk | .msh). The name of the file containing the input "
90 "mesh",
91 true, "", "INPUT_FILE");
92 cmd.add(mesh_in);
93 TCLAP::ValueArg<std::string> gmsh_path_arg(
94 "", "gmsh-path", "Input (.msh). The path to the input binary", false,
95 "", "INPUT_FILE");
96 cmd.add(gmsh_path_arg);
98 cmd.add(log_level_arg);
99 cmd.parse(argc, argv);
100
103
104
107 gmsh_path_arg.getValue());
108
110
111
112
114 if (!plys)
115 {
116 ERR(
"Could not get vector of polylines out of geometry '{:s}'.",
117 geo_name);
118 return EXIT_FAILURE;
119 }
120
121
123 plys->getElementByName(polygon_name_arg.getValue()));
124 if (!ply)
125 {
126 ERR(
"Polyline '{:s}' not found.", polygon_name_arg.getValue());
127 return EXIT_FAILURE;
128 }
129
130
131 if (!ply->isClosed())
132 {
133 ERR(
"Polyline '{:s}' is not closed, i.e. does not describe a region.",
134 polygon_name_arg.getValue());
135 return EXIT_FAILURE;
136 }
137
139
140
141 auto mesh = std::unique_ptr<MeshLib::Mesh>(
143 if (!mesh)
144 {
145
146 return EXIT_FAILURE;
147 }
148 std::string const& property_name(property_name_arg.getValue());
149
150 if (char_property_arg.isSet())
151 {
153 *mesh, polygon, property_name, char_property_arg.getValue(),
154 restrict_arg.getValue(), any_of_arg.getValue());
155 }
156
157 if (int_property_arg.isSet())
158 {
160 *mesh, polygon, property_name, int_property_arg.getValue(),
161 restrict_arg.getValue(), any_of_arg.getValue());
162 }
163
165
167
168 return EXIT_SUCCESS;
169}
void ERR(fmt::format_string< Args... > fmt, Args &&... args)
Container class for geometric objects.
std::vector< std::string > getGeometryNames() const
Returns the names of all geometry vectors.
const PolylineVec * getPolylineVecObj(const std::string &name) const
Class Polyline consists mainly of a reference to a point vector and a vector that stores the indices ...
The class TemplateVec takes a unique name and manages a std::vector of pointers to data elements of t...
TCLAP::ValueArg< std::string > makeLogLevelArg()
void initOGSLogger(std::string const &log_level)
void readGeometryFromFile(std::string const &fname, GeoLib::GEOObjects &geo_objs, std::string const &gmsh_path)
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)