OGS
FileIO::GMSH::GMSHAdaptiveMeshDensity Class Reference

Detailed Description

Definition at line 27 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 = nullptr

Constructor & Destructor Documentation

◆ GMSHAdaptiveMeshDensity()

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

◆ ~GMSHAdaptiveMeshDensity()

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

Definition at line 31 of file GMSHAdaptiveMeshDensity.cpp.

32{
33 delete _quad_tree;
34}
GeoLib::QuadTree< GeoLib::Point > * _quad_tree

References _quad_tree.

Member Function Documentation

◆ addPoints()

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

Definition at line 78 of file GMSHAdaptiveMeshDensity.cpp.

80{
81 // *** QuadTree - insert points
82 const std::size_t n_pnts(pnts.size());
83 DBUG(
84 "GMSHAdaptiveMeshDensity::addPoints(): Inserting {:d} points into "
85 "quadtree.",
86 n_pnts);
87 for (std::size_t k(0); k < n_pnts; k++)
88 {
89 _quad_tree->addPoint(pnts[k]);
90 }
91 DBUG("GMSHAdaptiveMeshDensity::addPoints(): \tok.");
92 _quad_tree->balance();
93}
void DBUG(fmt::format_string< Args... > fmt, Args &&... args)
Definition Logging.h:22

References _quad_tree, 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 95 of file GMSHAdaptiveMeshDensity.cpp.

97{
98 GeoLib::Point ll;
99 GeoLib::Point ur;
100 _quad_tree->getLeaf(*pnt, ll, ur);
101 return _pnt_density * (ur[0] - ll[0]);
102}

References _pnt_density, and _quad_tree.

◆ getMeshDensityAtStation()

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

Implements FileIO::GMSH::GMSHMeshDensityStrategy.

Definition at line 104 of file GMSHAdaptiveMeshDensity.cpp.

106{
107 GeoLib::Point ll;
108 GeoLib::Point ur;
109 _quad_tree->getLeaf(*pnt, ll, ur);
110 return _station_density * (ur[0] - ll[0]);
111}

References _quad_tree, and _station_density.

◆ getQuadTreeGeometry()

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

Definition at line 155 of file GMSHAdaptiveMeshDensity.cpp.

157{
158 std::list<GeoLib::QuadTree<GeoLib::Point>*> leaf_list;
159 _quad_tree->getLeafs(leaf_list);
160
161 std::string quad_tree_geo("QuadTree");
162 {
163 std::vector<GeoLib::Point*> points{};
164 for (auto const leaf : leaf_list)
165 {
166 // fetch corner points from leaf
167 GeoLib::Point ll;
168 GeoLib::Point ur;
169 leaf->getSquarePoints(ll, ur);
170 std::size_t const pnt_offset(points.size());
171 points.push_back(new GeoLib::Point(ll, pnt_offset));
172 points.push_back(
173 new GeoLib::Point(ur[0], ll[1], 0.0, pnt_offset + 1));
174 points.push_back(new GeoLib::Point(ur, pnt_offset + 2));
175 points.push_back(
176 new GeoLib::Point(ll[0], ur[1], 0.0, pnt_offset + 3));
177 }
178 geo_objs.addPointVec(std::move(points), quad_tree_geo,
180 }
181 auto& points = geo_objs.getPointVecObj(quad_tree_geo)->getVector();
182
183 std::vector<GeoLib::Polyline*> polylines{};
184 for (std::size_t l = 0; l < leaf_list.size(); ++l)
185 {
186 auto* polyline = new GeoLib::Polyline(points);
187 for (std::size_t p = 0; p < 4; ++p)
188 {
189 polyline->addPoint(4 * l + p);
190 }
191 polyline->closePolyline();
192 polylines.push_back(polyline);
193 }
194 geo_objs.addPolylineVec(std::move(polylines), quad_tree_geo,
196
197 return quad_tree_geo;
198}
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
std::map< std::string, std::size_t > NameIdMap
Definition TemplateVec.h:30
std::vector< T * > const & getVector() const
Definition TemplateVec.h:94

References _quad_tree, GeoLib::GEOObjects::addPointVec(), GeoLib::GEOObjects::addPolylineVec(), 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 113 of file GMSHAdaptiveMeshDensity.cpp.

115{
116 // get Steiner points
117 std::size_t max_depth(0);
118 _quad_tree->getMaxDepth(max_depth);
119
120 std::list<GeoLib::QuadTree<GeoLib::Point>*> leaf_list;
121 _quad_tree->getLeafs(leaf_list);
122
123 for (std::list<GeoLib::QuadTree<GeoLib::Point>*>::const_iterator it(
124 leaf_list.begin());
125 it != leaf_list.end();
126 ++it)
127 {
128 if ((*it)->getPoints().empty())
129 {
130 // compute point from square
131 GeoLib::Point ll;
132 GeoLib::Point ur;
133 (*it)->getSquarePoints(ll, ur);
134 if ((*it)->getDepth() + additional_levels > max_depth)
135 {
136 additional_levels = max_depth - (*it)->getDepth();
137 }
138 const std::size_t n_pnts_per_quad_dim = static_cast<std::size_t>(1)
139 << additional_levels;
140 const double delta((ur[0] - ll[0]) / (2 * n_pnts_per_quad_dim));
141 for (std::size_t i(0); i < n_pnts_per_quad_dim; i++)
142 {
143 for (std::size_t j(0); j < n_pnts_per_quad_dim; j++)
144 {
145 pnts.push_back(new GeoLib::Point(
146 ll[0] + (2 * i + 1) * delta,
147 ll[1] + (2 * j + 1) * delta, 0.0, pnts.size()));
148 }
149 }
150 }
151 }
152}

References _quad_tree.

◆ initialize()

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

Implements FileIO::GMSH::GMSHMeshDensityStrategy.

Definition at line 36 of file GMSHAdaptiveMeshDensity.cpp.

38{
39 // *** QuadTree - determining bounding box
40 DBUG(
41 "GMSHAdaptiveMeshDensity::init(): computing axis aligned bounding box "
42 "(2D) for quadtree.");
43
44 GeoLib::Point min(*pnts[0]);
45 GeoLib::Point max(*pnts[0]);
46 std::size_t n_pnts(pnts.size());
47 for (std::size_t k(1); k < n_pnts; k++)
48 {
49 for (std::size_t j(0); j < 2; j++)
50 {
51 if ((*(pnts[k]))[j] < min[j])
52 {
53 min[j] = (*(pnts[k]))[j];
54 }
55 }
56 for (std::size_t j(0); j < 2; j++)
57 {
58 if ((*(pnts[k]))[j] > max[j])
59 {
60 max[j] = (*(pnts[k]))[j];
61 }
62 }
63 }
64 min[2] = 0.0;
65 max[2] = 0.0;
66 DBUG("GMSHAdaptiveMeshDensity::init(): \tok");
67
68 // *** QuadTree - create object
69 DBUG("GMSHAdaptiveMeshDensity::init(): Creating quadtree.");
71 new GeoLib::QuadTree<GeoLib::Point>(min, max, _max_pnts_per_leaf);
72 DBUG("GMSHAdaptiveMeshDensity::init(): \tok.");
73
74 // *** QuadTree - insert points
75 addPoints(pnts);
76}
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 48 of file GMSHAdaptiveMeshDensity.h.

Referenced by GMSHAdaptiveMeshDensity(), and initialize().

◆ _pnt_density

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

Definition at line 46 of file GMSHAdaptiveMeshDensity.h.

Referenced by GMSHAdaptiveMeshDensity(), and getMeshDensityAtPoint().

◆ _quad_tree

GeoLib::QuadTree<GeoLib::Point>* FileIO::GMSH::GMSHAdaptiveMeshDensity::_quad_tree = nullptr
private

◆ _station_density

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

Definition at line 47 of file GMSHAdaptiveMeshDensity.h.

Referenced by GMSHAdaptiveMeshDensity(), and getMeshDensityAtStation().


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