Programmierpraktikum NPDGL I
Öffentliche Typen | Öffentliche Methoden | Freundbeziehungen

Grid Klassenreferenz

a simple adaptive and therefore unstructured grid for 1d problems Mehr ...

#include <mygrid.hh>

Aufstellung aller Elemente

Öffentliche Typen

enum  MARK { COARSEN, DO_NOTHING, REFINE }
 

enumeration of possible adaptation actions on grid cells

Mehr ...

Öffentliche Methoden

 Grid (const double a, const double b, const unsigned int npoints)
 constructor generating a grid on [a,b] with N equidistant points
unsigned int npoints () const
 return number of points
double a () const
 return left boundary a
double b () const
 return right boundary b
double point (const unsigned int i) const
 get the i-th point coordinate (i ranging from 0 to N-1)
double normal_a () const
 return normal in left boundary point a
double normal_b () const
 return normal in right boundary point b
double qpoints () const
 return number of quadrature points for global quadrature rule
double dx (const unsigned int i) const
 return size of surrounding of point i (from 0 to N-1),
double quadraturePoint (const int i) const
 get quadrature point number i for trapezoidal rule (from 0 to Q-1)
double quadratureWeight (const int i) const
 get quadrature weight at point i for trapezoidal rule (from 0 to Q-1)
void mark (const unsigned int i, enum MARK m)
 mark element for refinement or coarsening
bool adapt ()
 adapt that grid where possible and create an index mapping
void gridCompress (std::vector< int > &remap)
 makes the vertices_ array continuous after adaptation phase
bool mightBeCoarsened (int i)
 returns true if the grid entity might be coarsened during the next call to adapt()
void resetMarks ()
 reset the mark_ array
unsigned int mapEntityToDof (int i) const
 An index map for Dof Storage on the grid vertices.
unsigned int mapOldEntityToDof (int i) const
 the previous index map for DoF storage
unsigned int neededDofSize () const
 returns the needed DoF size for storage on grid cells
unsigned int neededCodim0DofSize () const
 returns the needed DoF size for storage on grid vertices
unsigned int numCoarsenedElements () const
 number of coarsened elements after the last adaptation phase
unsigned int numRefinedElements () const
 number of refined elements after the last adaptation phase
int refinedElement (int ri) const
 returns the ri'th refined element
int coarsenedElement (int ci) const
 returns the ci'th coarsened element
std::pair< int, int > getChildren (int fatherI)
 returns a pair of children for father element
int father (int childI)
 returns a child's father element
void write_gnuplot (const std::string &filename, std::vector< double > dofs, double t=0) const
 save dofs of a vector in file to be read in gnuplot
 ~Grid ()
 destructor

Freundbeziehungen

std::ostream & operator<< (std::ostream &out, Grid &g)
 output stream for the grid

Ausführliche Beschreibung

a simple adaptive and therefore unstructured grid for 1d problems

This class provides a one dimensional adaptive grid \(\mathcal{T}^{s}=\{e_i\}_{i=0}^{N^s-1}\), where \(s\) indicates how often the grid has been refined and \(\mathcal{T}^{0}\) being the initial grid. The grid entities (subintervals) are numbered consecutively such that the midpoint of the grid can be accessed by the point(int i) method and the width of a grid entity is returned by dx(int i).

For every grid \(\mathcal{T}^{s}\) we consider two mappings

\[ m^{s}:\{0,\ldots,N^{s}-1\} \to \{1,\ldots,N^{s}-1\} \]

and

\[ {m'}^{s}:\{0,\ldots,N^{s}-1\} \to \{1,\ldots,N'^{s}-1\} \]

that map the consecutive numbering of the grid enitities to its memory positions. These mappings are also used for the numbering of the DoFs in our DiscreteFunction implementation. The mappings fulfill the following "sloppy" constraints:

  1. The mapping \({m'}^{s}\) is an extension of the mapping \(m^{s-1}\) where grid elements added due to coarsening or refinement are mapped to memory indices above or equal to \(N^{s-1}\). Such this mapping is not continuous, as it contains "holes".
  2. During the adaptation phase, we need the old mapping \(m^{s-1}\) as well, in order to find the DoFs of father and children entities where necessary. In this phase, the mappings \(m^{s-1}\) and \({m'}^s\) are both valid mappings and available in the grid's implementation.
  3. After the adaptation phase, the grid needs to be compressed via dofCompress, i.e. holes are filled with the newest elements. DiscreteFunction's marked for adaptation need to be changed accordingly, therefore. The only valid and stored mapping, then, is the continuous one \(m^{s}\).
Zu beachten:
Several mappings are valid, if there are no two of those mapping that map any two different entities on the same DoF number.
Only refined and coarsened grid entities cause changes in the DoF storage array.

For the prolonging step of the adaptive algorithm the class provides a mapping \(f^{S}\) called father for all refined entities \(\mathcal{R}^{S}\subset{T}^{S}\), such that

\[ e_i \in \mathcal{R}^{S}, e_j \in \mathcal{T}^{S-1}, e_i \subset e_j \Rightarrow f^{S}(i) = m^{S-1}(j) \]

For the restriction step, the class provides a mapping \(c^{S}\) called children for all entities produced by a coarsening step \(\mathcal{C}^{S} \subset \mathcal{T}^{S}\), such that

\[ e_i \in \mathcal{R}^{S}, e_j, e_k \in \mathcal{T}^{S-1}, e_j \cup e_k = e_i \Rightarrow c^{S}(i) = \{m^{S-1}(j), m^{S-1}(k)\} \]

Beispiele:

test_projection.cc und test_spaceoperator.cc.


Dokumentation der Aufzählungstypen

enum Grid::MARK

enumeration of possible adaptation actions on grid cells

Aufzählungswerte:
COARSEN 

coarsen this grid cell

DO_NOTHING 

do nothing on this grid cell

REFINE 

refine this grid cell


Dokumentation der Elementfunktionen

unsigned int Grid::mapEntityToDof ( int  i) const

An index map for Dof Storage on the grid vertices.

This is either \({m'}^{s}\) or \(m^s\).

unsigned int Grid::mapOldEntityToDof ( int  i) const

the previous index map for DoF storage

This is \(m^{s-1}\).

unsigned int Grid::npoints ( ) const

return number of points

These points are actually the mid-points of the grid cells (subintervals).

double Grid::point ( const unsigned int  i) const

get the i-th point coordinate (i ranging from 0 to N-1)

The mid-point of the i-th grid cell is returned

void Grid::write_gnuplot ( const std::string &  filename,
std::vector< double >  dofs,
double  t = 0 
) const

save dofs of a vector in file to be read in gnuplot

Parameter:
filenamename of the gnuplot file where information is to be stored
dofsa vector of degrees of freedom to be stored
toptional parameter for time instances

Die Dokumentation für diese Klasse wurde erzeugt aufgrund der Datei: