OGS
FileIO::GMSH::GMSHAdaptiveMeshDensity Class Reference

Detailed Description

Definition at line 30 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
 
void getQuadTreeGeometry (std::vector< GeoLib::Point * > &pnts, std::vector< GeoLib::Polyline * > &plys) 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 31 of file GMSHAdaptiveMeshDensity.cpp.

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

◆ ~GMSHAdaptiveMeshDensity()

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

Definition at line 41 of file GMSHAdaptiveMeshDensity.cpp.

42 {
43  delete _quad_tree;
44 }

References _quad_tree.

Member Function Documentation

◆ addPoints()

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

Definition at line 88 of file GMSHAdaptiveMeshDensity.cpp.

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

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 105 of file GMSHAdaptiveMeshDensity.cpp.

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

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 114 of file GMSHAdaptiveMeshDensity.cpp.

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

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

◆ getQuadTreeGeometry()

void FileIO::GMSH::GMSHAdaptiveMeshDensity::getQuadTreeGeometry ( std::vector< GeoLib::Point * > &  pnts,
std::vector< GeoLib::Polyline * > &  plys 
) const

Definition at line 165 of file GMSHAdaptiveMeshDensity.cpp.

168 {
169  std::list<GeoLib::QuadTree<GeoLib::Point>*> leaf_list;
170  _quad_tree->getLeafs(leaf_list);
171 
172  for (std::list<GeoLib::QuadTree<GeoLib::Point>*>::const_iterator it(
173  leaf_list.begin());
174  it != leaf_list.end();
175  ++it)
176  {
177  // fetch corner points from leaf
178  GeoLib::Point ll;
179  GeoLib::Point ur;
180  (*it)->getSquarePoints(ll, ur);
181  std::size_t const pnt_offset(pnts.size());
182  pnts.push_back(new GeoLib::Point(ll, pnt_offset));
183  pnts.push_back(new GeoLib::Point(ur[0], ll[1], 0.0, pnt_offset + 1));
184  pnts.push_back(new GeoLib::Point(ur, pnt_offset + 2));
185  pnts.push_back(new GeoLib::Point(ll[0], ur[1], 0.0, pnt_offset + 3));
186  plys.push_back(new GeoLib::Polyline(pnts));
187  plys[plys.size() - 1]->addPoint(pnt_offset);
188  plys[plys.size() - 1]->addPoint(pnt_offset + 1);
189  plys[plys.size() - 1]->addPoint(pnt_offset + 2);
190  plys[plys.size() - 1]->addPoint(pnt_offset + 3);
191  plys[plys.size() - 1]->addPoint(pnt_offset);
192  }
193 }
Class Polyline consists mainly of a reference to a point vector and a vector that stores the indices ...
Definition: Polyline.h:42
void getLeafs(std::list< QuadTree< POINT > * > &leaf_list)
Definition: QuadTree.h:243

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

◆ getSteinerPoints()

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

Definition at line 123 of file GMSHAdaptiveMeshDensity.cpp.

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

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 46 of file GMSHAdaptiveMeshDensity.cpp.

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

Referenced by initialize().

◆ _pnt_density

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

Definition at line 50 of file GMSHAdaptiveMeshDensity.h.

Referenced by getMeshDensityAtPoint().

◆ _quad_tree

◆ _station_density

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

Definition at line 51 of file GMSHAdaptiveMeshDensity.h.

Referenced by getMeshDensityAtStation().


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