96{
97 DBUG(
"GMSHInterface::writeGMSHInputFile(): get data from GEOObjects.");
98
100 {
101 return 1;
102 }
103
104
106 {
109 {
110 return 2;
111 }
112 }
113 else
114 {
117 }
118
119 auto* merged_pnts(const_cast<std::vector<GeoLib::Point*>*>(
121 if (!merged_pnts)
122 {
123 ERR(
"GMSHInterface::writeGMSHInputFile(): Did not found any points.");
124 return 2;
125 }
126
128 {
129
131
133 }
134 else
135 {
136
138 for (auto pnt : *merged_pnts)
139 {
140 (*pnt)[2] = 0.0;
141 }
142 }
143
144 std::vector<GeoLib::Polyline*> const* merged_plys(
146 DBUG(
"GMSHInterface::writeGMSHInputFile(): Obtained data.");
147
148 if (!merged_plys)
149 {
150 ERR(
"GMSHInterface::writeGMSHInputFile(): Did not find any polylines.");
151 return 2;
152 }
153
154
158 pnt_vec, *(const_cast<std::vector<GeoLib::Polyline*>*>(merged_plys)));
159
160 std::vector<GeoLib::Polyline*> polygons;
161
162
163 for (auto polyline : *merged_plys)
164 {
165 if (!polyline->isClosed())
166 {
167 continue;
168 }
170 }
171 if (polygons.empty())
172 {
173 OGS_FATAL(
"GMSHInterface::writeGMSHInputFile(): no polygons found.");
174 }
175
177
178 std::transform(
179 polygons.begin(), polygons.end(),
181 [this](auto const& polygon)
182 {
183 return new GMSH::GMSHPolygonTree(
184 dynamic_cast<GeoLib::PolygonWithSegmentMarker*>(polygon),
185 nullptr, _geo_objs, _gmsh_geo_name, *_mesh_density_strategy);
186 });
188 "GMSHInterface::writeGMSHInputFile(): Computed topological hierarchy - "
189 "detected {:d} polygons.",
191
194 "GMSHInterface::writeGMSHInputFile(): Computed topological hierarchy - "
195 "calculated {:d} polygon trees.",
197
198
200 {
201 polygon_tree->markSharedSegments();
202 }
203
204
205
206
207
208 std::vector<GeoLib::Point*> gmsh_stations{};
210 {
212 if (stations)
213 {
214 for (auto* station : *stations)
215 {
216 bool found(false);
219 ++it)
220 {
223 if ((*it)->insertStation(gmsh_stations.back()))
224 {
225 found = true;
226 }
227 }
228 }
229 }
230 }
232 if (!gmsh_stations.empty())
233 {
235 }
236
237
238 for (auto polyline : *merged_plys)
239 {
240 if (!polyline->isClosed())
241 {
243 {
244 auto polyline_with_segment_marker =
246 polygon_tree->insertPolyline(polyline_with_segment_marker);
247 }
248 }
249 }
250
251
253 {
254 polygon_tree->initMeshDensityStrategy();
255 }
256
257
258 const std::size_t n_merged_pnts(merged_pnts->size());
260 for (std::size_t k(0); k < n_merged_pnts; k++)
261 {
263 }
265 {
267 }
268
269 std::stringstream error_messages;
270 error_messages.precision(std::numeric_limits<double>::digits10);
271 for (std::size_t k = 0; k <
_gmsh_pnts.size(); ++k)
272 {
274 {
275 error_messages
276 << "The point at (" << *(*merged_pnts)[k]
277 << ") is not part of a polyline, and won't be used in the "
278 "meshing as a constraint. If you want to include it in the "
279 "mesh please create a observation/measurement station for "
280 "the point and include it additional in the meshing "
281 "process.\n";
282 }
283 }
284 auto const error_message = error_messages.str();
285 if (!error_message.empty())
286 {
288 }
289
290
293
296 {
299 polygon_tree->writeSubPolygonsAsLineConstraints(
_n_lines,
303 polygon_tree->writeAdditionalPointData(pnt_id_offset,
_n_plane_sfc - 1,
305 }
306
308 {
313 }
314
315 return 0;
316}
void DBUG(fmt::format_string< Args... > fmt, Args &&... args)
void ERR(fmt::format_string< Args... > fmt, Args &&... args)
bool _write_physical_groups
std::string _gmsh_geo_name
Eigen::Matrix3d _inverse_rot_mat
const std::vector< Point * > * getPointVec(const std::string &name) const
const PointVec * getPointVecObj(const std::string &name) const
bool removePointVec(const std::string &name)
bool removeSurfaceVec(const std::string &name)
void addStationVec(std::vector< Point * > &&stations, std::string &name)
Adds a vector of stations with the given name and colour to GEOObjects.
bool removeStationVec(const std::string &name)
Removes the station vector with the given name from GEOObjects.
int mergeGeometries(std::vector< std::string > const &geo_names, std::string &merged_geo_name)
const std::vector< Polyline * > * getPolylineVec(const std::string &name) const
bool appendPolylineVec(const std::vector< Polyline * > &polylines, const std::string &name)
const std::vector< GeoLib::Point * > * getStationVec(const std::string &name) const
Returns the station vector with the given name.
bool removePolylineVec(const std::string &name)
This class manages pointers to Points in a std::vector along with a name. It also handles the deletio...
A Station (observation site) is basically a Point with some additional information.
void computeAndInsertAllIntersectionPoints(GeoLib::PointVec &pnt_vec, std::vector< GeoLib::Polyline * > &plys)
void rotatePoints(Eigen::Matrix3d const &rot_mat, InputIterator pnts_begin, InputIterator pnts_end)
Eigen::Matrix3d rotatePointsToXY(InputIterator1 p_pnts_begin, InputIterator1 p_pnts_end, InputIterator2 r_pnts_begin, InputIterator2 r_pnts_end)