|
Programmierpraktikum NPDGL I
|
a simple adaptive and therefore unstructured grid for 1d problems Mehr ...
#include <mygrid.hh>
Ö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 | |
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:
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)\} \]
| enum Grid::MARK |
| 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
| filename | name of the gnuplot file where information is to be stored |
| dofs | a vector of degrees of freedom to be stored |
| t | optional parameter for time instances |
1.7.3