OGS
FileIO::GMSH::GMSHAdaptiveMeshDensity Class Reference

Detailed Description

Definition at line 34 of file GMSHAdaptiveMeshDensity.h.

#include <GMSHAdaptiveMeshDensity.h>

Inheritance diagram for FileIO::GMSH::GMSHAdaptiveMeshDensity:
[legend]
Collaboration diagram for FileIO::GMSH::GMSHAdaptiveMeshDensity:
[legend]

Public Member Functions

 GMSHAdaptiveMeshDensity (double pnt_density, double station_density, std::size_t max_pnts_per_leaf)
 
 ~GMSHAdaptiveMeshDensity () override
 
void initialize (std::vector< GeoLib::Point const * > const &pnts) override
 
double getMeshDensityAtPoint (GeoLib::Point const *const pnt) const override
 
void addPoints (std::vector< GeoLib::Point const * > const &pnts)
 
double getMeshDensityAtStation (GeoLib::Point const *const) const override
 
void getSteinerPoints (std::vector< GeoLib::Point * > &pnts, std::size_t additional_levels=0) const
 
std::string getQuadTreeGeometry (GeoLib::GEOObjects &geo_objs) const
 
- Public Member Functions inherited from FileIO::GMSH::GMSHMeshDensityStrategy
virtual ~GMSHMeshDensityStrategy ()=default
 

Private Attributes

double _pnt_density
 
double _station_density
 
std::size_t _max_pnts_per_leaf
 
GeoLib::QuadTree< GeoLib::Point > * _quad_tree
 

Constructor & Destructor Documentation

◆ GMSHAdaptiveMeshDensity()

FileIO::GMSH::GMSHAdaptiveMeshDensity::GMSHAdaptiveMeshDensity ( double pnt_density,
double station_density,
std::size_t max_pnts_per_leaf )

Definition at line 32 of file GMSHAdaptiveMeshDensity.cpp.

35 : _pnt_density(pnt_density),
36 _station_density(station_density),
37 _max_pnts_per_leaf(max_pnts_per_leaf),
38 _quad_tree(nullptr)
39{
40}
GeoLib::QuadTree< GeoLib::Point > * _quad_tree

◆ ~GMSHAdaptiveMeshDensity()

FileIO::GMSH::GMSHAdaptiveMeshDensity::~GMSHAdaptiveMeshDensity ( )
override

Definition at line 42 of file GMSHAdaptiveMeshDensity.cpp.

43{
44 delete _quad_tree;
45}

References _quad_tree.

Member Function Documentation

◆ addPoints()

void FileIO::GMSH::GMSHAdaptiveMeshDensity::addPoints ( std::vector< GeoLib::Point const * > const & pnts)

Definition at line 89 of file GMSHAdaptiveMeshDensity.cpp.

91{
92 // *** QuadTree - insert points
93 const std::size_t n_pnts(pnts.size());
94 DBUG(
95 "GMSHAdaptiveMeshDensity::addPoints(): Inserting {:d} points into "
96 "quadtree.",
97 n_pnts);
98 for (std::size_t k(0); k < n_pnts; k++)
99 {
100 _quad_tree->addPoint(pnts[k]);
101 }
102 DBUG("GMSHAdaptiveMeshDensity::addPoints(): \tok.");
104}
void DBUG(fmt::format_string< Args... > fmt, Args &&... args)
Definition Logging.h:30
bool addPoint(POINT const *pnt)
Definition QuadTree.h:101

References _quad_tree, GeoLib::QuadTree< POINT >::addPoint(), GeoLib::QuadTree< POINT >::balance(), and DBUG().

Referenced by initialize().

◆ getMeshDensityAtPoint()

double FileIO::GMSH::GMSHAdaptiveMeshDensity::getMeshDensityAtPoint ( GeoLib::Point const *const pnt) const
overridevirtual

Implements FileIO::GMSH::GMSHMeshDensityStrategy.

Definition at line 106 of file GMSHAdaptiveMeshDensity.cpp.

108{
109 GeoLib::Point ll;
110 GeoLib::Point ur;
111 _quad_tree->getLeaf(*pnt, ll, ur);
112 return _pnt_density * (ur[0] - ll[0]);
113}
void getLeaf(const POINT &pnt, POINT &ll, POINT &ur)
Definition QuadTree.h:265

References _pnt_density, _quad_tree, and GeoLib::QuadTree< POINT >::getLeaf().

◆ getMeshDensityAtStation()

double FileIO::GMSH::GMSHAdaptiveMeshDensity::getMeshDensityAtStation ( GeoLib::Point const * const pnt) const
overridevirtual

Implements FileIO::GMSH::GMSHMeshDensityStrategy.

Definition at line 115 of file GMSHAdaptiveMeshDensity.cpp.

117{
118 GeoLib::Point ll;
119 GeoLib::Point ur;
120 _quad_tree->getLeaf(*pnt, ll, ur);
121 return _station_density * (ur[0] - ll[0]);
122}

References _quad_tree, _station_density, and GeoLib::QuadTree< POINT >::getLeaf().

◆ getQuadTreeGeometry()

std::string FileIO::GMSH::GMSHAdaptiveMeshDensity::getQuadTreeGeometry ( GeoLib::GEOObjects & geo_objs) const

Definition at line 166 of file GMSHAdaptiveMeshDensity.cpp.

168{
169 std::list<GeoLib::QuadTree<GeoLib::Point>*> leaf_list;
170 _quad_tree->getLeafs(leaf_list);
171
172 std::string quad_tree_geo("QuadTree");
173 {
174 std::vector<GeoLib::Point*> points{};
175 for (auto const leaf : leaf_list)
176 {
177 // fetch corner points from leaf
178 GeoLib::Point ll;
179 GeoLib::Point ur;
180 leaf->getSquarePoints(ll, ur);
181 std::size_t const pnt_offset(points.size());
182 points.push_back(new GeoLib::Point(ll, pnt_offset));
183 points.push_back(
184 new GeoLib::Point(ur[0], ll[1], 0.0, pnt_offset + 1));
185 points.push_back(new GeoLib::Point(ur, pnt_offset + 2));
186 points.push_back(
187 new GeoLib::Point(ll[0], ur[1], 0.0, pnt_offset + 3));
188 }
189 geo_objs.addPointVec(std::move(points), quad_tree_geo,
191 }
192 auto& points = geo_objs.getPointVecObj(quad_tree_geo)->getVector();
193
194 std::vector<GeoLib::Polyline*> polylines{};
195 for (std::size_t l = 0; l < leaf_list.size(); ++l)
196 {
197 auto* polyline = new GeoLib::Polyline(points);
198 for (std::size_t p = 0; p < 4; ++p)
199 {
200 polyline->addPoint(4 * l + p);
201 }
202 polyline->closePolyline();
203 polylines.push_back(polyline);
204 }
205 geo_objs.addPolylineVec(std::move(polylines), quad_tree_geo,
207
208 return quad_tree_geo;
209}
void addPolylineVec(std::vector< Polyline * > &&lines, std::string const &name, PolylineVec::NameIdMap &&ply_names)
void addPointVec(std::vector< Point * > &&points, std::string &name, PointVec::NameIdMap &&pnt_id_name_map, double const eps=std::sqrt(std::numeric_limits< double >::epsilon()))
const PointVec * getPointVecObj(const std::string &name) const
Class Polyline consists mainly of a reference to a point vector and a vector that stores the indices ...
Definition Polyline.h:40
void getLeafs(std::list< QuadTree< POINT > * > &leaf_list)
Definition QuadTree.h:242
std::map< std::string, std::size_t > NameIdMap
Definition TemplateVec.h:41
std::vector< T * > const & getVector() const

References _quad_tree, GeoLib::GEOObjects::addPointVec(), GeoLib::GEOObjects::addPolylineVec(), GeoLib::QuadTree< POINT >::getLeafs(), GeoLib::GEOObjects::getPointVecObj(), and GeoLib::TemplateVec< T >::getVector().

◆ getSteinerPoints()

void FileIO::GMSH::GMSHAdaptiveMeshDensity::getSteinerPoints ( std::vector< GeoLib::Point * > & pnts,
std::size_t additional_levels = 0 ) const

Definition at line 124 of file GMSHAdaptiveMeshDensity.cpp.

126{
127 // get Steiner points
128 std::size_t max_depth(0);
129 _quad_tree->getMaxDepth(max_depth);
130
131 std::list<GeoLib::QuadTree<GeoLib::Point>*> leaf_list;
132 _quad_tree->getLeafs(leaf_list);
133
134 for (std::list<GeoLib::QuadTree<GeoLib::Point>*>::const_iterator it(
135 leaf_list.begin());
136 it != leaf_list.end();
137 ++it)
138 {
139 if ((*it)->getPoints().empty())
140 {
141 // compute point from square
142 GeoLib::Point ll;
143 GeoLib::Point ur;
144 (*it)->getSquarePoints(ll, ur);
145 if ((*it)->getDepth() + additional_levels > max_depth)
146 {
147 additional_levels = max_depth - (*it)->getDepth();
148 }
149 const std::size_t n_pnts_per_quad_dim = static_cast<std::size_t>(1)
150 << additional_levels;
151 const double delta((ur[0] - ll[0]) / (2 * n_pnts_per_quad_dim));
152 for (std::size_t i(0); i < n_pnts_per_quad_dim; i++)
153 {
154 for (std::size_t j(0); j < n_pnts_per_quad_dim; j++)
155 {
156 pnts.push_back(new GeoLib::Point(
157 ll[0] + (2 * i + 1) * delta,
158 ll[1] + (2 * j + 1) * delta, 0.0, pnts.size()));
159 }
160 }
161 }
162 }
163}
void getMaxDepth(std::size_t &max_depth) const
Definition QuadTree.h:316

References _quad_tree, GeoLib::QuadTree< POINT >::getLeafs(), and GeoLib::QuadTree< POINT >::getMaxDepth().

◆ initialize()

void FileIO::GMSH::GMSHAdaptiveMeshDensity::initialize ( std::vector< GeoLib::Point const * > const & pnts)
overridevirtual

Implements FileIO::GMSH::GMSHMeshDensityStrategy.

Definition at line 47 of file GMSHAdaptiveMeshDensity.cpp.

49{
50 // *** QuadTree - determining bounding box
51 DBUG(
52 "GMSHAdaptiveMeshDensity::init(): computing axis aligned bounding box "
53 "(2D) for quadtree.");
54
55 GeoLib::Point min(*pnts[0]);
56 GeoLib::Point max(*pnts[0]);
57 std::size_t n_pnts(pnts.size());
58 for (std::size_t k(1); k < n_pnts; k++)
59 {
60 for (std::size_t j(0); j < 2; j++)
61 {
62 if ((*(pnts[k]))[j] < min[j])
63 {
64 min[j] = (*(pnts[k]))[j];
65 }
66 }
67 for (std::size_t j(0); j < 2; j++)
68 {
69 if ((*(pnts[k]))[j] > max[j])
70 {
71 max[j] = (*(pnts[k]))[j];
72 }
73 }
74 }
75 min[2] = 0.0;
76 max[2] = 0.0;
77 DBUG("GMSHAdaptiveMeshDensity::init(): \tok");
78
79 // *** QuadTree - create object
80 DBUG("GMSHAdaptiveMeshDensity::init(): Creating quadtree.");
83 DBUG("GMSHAdaptiveMeshDensity::init(): \tok.");
84
85 // *** QuadTree - insert points
86 addPoints(pnts);
87}
void addPoints(std::vector< GeoLib::Point const * > const &pnts)

References _max_pnts_per_leaf, _quad_tree, addPoints(), and DBUG().

Member Data Documentation

◆ _max_pnts_per_leaf

std::size_t FileIO::GMSH::GMSHAdaptiveMeshDensity::_max_pnts_per_leaf
private

Definition at line 55 of file GMSHAdaptiveMeshDensity.h.

Referenced by initialize().

◆ _pnt_density

double FileIO::GMSH::GMSHAdaptiveMeshDensity::_pnt_density
private

Definition at line 53 of file GMSHAdaptiveMeshDensity.h.

Referenced by getMeshDensityAtPoint().

◆ _quad_tree

◆ _station_density

double FileIO::GMSH::GMSHAdaptiveMeshDensity::_station_density
private

Definition at line 54 of file GMSHAdaptiveMeshDensity.h.

Referenced by getMeshDensityAtStation().


The documentation for this class was generated from the following files: