15{
16 TCLAP::CmdLine cmd(
17 "Tool to create gmsh geometry (geo-file) out of a gml geometry.\n\n"
18 "OpenGeoSys-6 software, version " +
20 ".\n"
21 "Copyright (c) 2012-2026, OpenGeoSys Community "
22 "(http://www.opengeosys.org)",
24 TCLAP::ValueArg<std::string> geo_output_arg(
25 "o", "output", "Output (.geo) gmsh geometry file ", true, "",
26 "OUTPUT_FILE");
27 cmd.add(geo_output_arg);
28 TCLAP::MultiArg<std::string> geo_input_arg(
29 "i", "input", "Input (.gml) geometry file", true, "INPUT_FILE");
30 cmd.add(geo_input_arg);
31 TCLAP::ValueArg<unsigned> max_number_of_points_in_quadtree_leaf_arg(
32 "", "max_points_in_quadtree_leaf", "positive number/ (min = 0)", false,
33 2, "POINTS_QUADTREE");
34 cmd.add(max_number_of_points_in_quadtree_leaf_arg);
35 TCLAP::ValueArg<double> mesh_density_scaling_points_arg(
36 "", "mesh_density_scaling_at_points",
37 "positive floating point number, (min = 0)", false, 0.2,
38 "SCALING_POINTS");
39 cmd.add(mesh_density_scaling_points_arg);
40 TCLAP::ValueArg<double> mesh_density_scaling_stations_arg(
41 "", "mesh_density_scaling_at_stations",
42 "positive floating point number, (min = 0)", false, 0.05,
43 "SCALING_STATIONS");
44 cmd.add(mesh_density_scaling_stations_arg);
45 TCLAP::ValueArg<double> average_point_density_arg(
46 "a", "average_point_density",
47 "average point density / average edge length as a positive floating "
48 "point number, (min = 0)",
49 false, 1, "AVERAGE_POINT_DENSITY");
50 cmd.add(average_point_density_arg);
51 TCLAP::SwitchArg homogeneous_flag(
52 "", "homogeneous", "Use Gmsh homogeneous meshing method.", false);
53 cmd.add(homogeneous_flag);
54 TCLAP::ValueArg<std::string> merged_geometries_output(
55 "", "write_merged_geometries",
56 "Output (.gml). File name for the output of the internal created "
57 "geometry (useful for debugging the data)",
58 false, "", "OUTPUT_FILE");
59 cmd.add(merged_geometries_output);
61 cmd.add(log_level_arg);
62
63 cmd.parse(argc, argv);
64
67
69 for (auto const& geometry_name : geo_input_arg.getValue())
70 {
72 try
73 {
74 if (!xml.readFile(geometry_name))
75 {
76 return EXIT_FAILURE;
77 }
78 }
79 catch (std::runtime_error const& err)
80 {
81 ERR(
"Failed to read file '{:s}'.", geometry_name);
82 ERR(
"{:s}", err.what());
83 return EXIT_FAILURE;
84 }
85 INFO(
"Successfully read file '{:s}'.", geometry_name);
86 }
87
89
90 bool const rotate = false;
91 bool const keep_preprocessed_geometry = false;
92
93 try
94 {
95 if (homogeneous_flag.getValue())
96 {
97 double const average_mesh_density =
98 average_point_density_arg.getValue();
100 geo_objects, true,
102 average_mesh_density, 0.0, 0, geo_names, rotate,
103 keep_preprocessed_geometry);
105 geo_output_arg.getValue());
106 }
107 else
108 {
109 unsigned const max_number_of_points_in_quadtree_leaf =
110 max_number_of_points_in_quadtree_leaf_arg.getValue();
111 double const mesh_density_scaling_points =
112 mesh_density_scaling_points_arg.getValue();
113 double const mesh_density_scaling_stations =
114 mesh_density_scaling_stations_arg.getValue();
116 geo_objects, true,
118 mesh_density_scaling_points, mesh_density_scaling_stations,
119 max_number_of_points_in_quadtree_leaf, geo_names, rotate,
120 keep_preprocessed_geometry);
122 geo_output_arg.getValue());
123 }
124 }
125 catch (std::runtime_error& error)
126 {
127 ERR(
"{}", error.what());
128 if (merged_geometries_output.isSet())
129 {
133 merged_geometries_output.getValue());
134 }
135 else
136 {
138 "Hint: Using the command line flag "
139 "'--write_merged_geometries buggy_geometry.gml' allows "
140 "for better analysis of the problem.");
141 }
142 ERR(
"An error has occurred - programme will be terminated.");
143 return EXIT_FAILURE;
144 }
145 return EXIT_SUCCESS;
146}
void INFO(fmt::format_string< Args... > fmt, Args &&... args)
void ERR(fmt::format_string< Args... > fmt, Args &&... args)
Reads and writes GMSH-files to and from OGS data structures.
Container class for geometric objects.
std::vector< std::string > getGeometryNames() const
Returns the names of all geometry vectors.
int writeStringToFile(std::string_view content, std::filesystem::path const &file_path)
TCLAP::ValueArg< std::string > makeLogLevelArg()
void initOGSLogger(std::string const &log_level)
@ AdaptiveMeshDensity
computing the mesh density employing a QuadTree
@ FixedMeshDensity
set the parameter with a fixed value
GITINFOLIB_EXPORT const std::string ogs_version