NAME
GridFEInfo - additional grid data structures for neighbor info
etc
INCLUDE
include "GridFEInfo.h"
SYNTAX
class GridFEInfo
{
friend class GridFE;
public:
GridFEInfo();
void forceInit(); // forces all data structures to be re-initialized
// --- neighbor information ---
private:
bool neighbor_is_initialized;
bool neighbor_n2e_is_initialized;
bool neighbor_n2n_is_initialized;
bool neighbor_e2e_is_initialized;
public:
NeighborFE neighbor;
void initNeighbor (GridFE& grid);
void initNeighbor (GridFE& grid,
bool init_n2e, bool init_n2n, bool init_e2e,
bool special_e2e = false);
// --- first order basis functions? ---
private:
bool first_order_elements_is_initialized;
bool first_order_elements;
bool onlyFirstOrderElmType (GridFE& grid);
public:
bool onlyFirstOrderElements (GridFE& grid);
// --- max and min grid spacing information ---
private:
real max_grid_spacing; // (in all directions)
public:
real getMaxSpacing (GridFE& grid);
static void minmaxGridSpacing (GridFE& grid,
Ptv(real)& hmin, Ptv(real)& hmax,
FieldFunc* formula = NULL);
static void maxSurroundingBox (GridFE& grid, Ptv(real)& length);
static void computeBoxesAndCentroids(GridFE& grid,
MatSimple(real)& bounding_box,
MatSimple(real)& centroids );
real characteristicElmSize (GridFE& grid, bool dimless = true);
// --- efficient look up of boundary elements ---
private:
VecSimple(bool) boundary_elm;
bool boundary_elm_is_initialized;
void initBoundaryElms (const GridFE& grid);
public:
bool isBoundaryElm (int element, const GridFE& grid) const;
// --- efficient data structures for boundary indicators on sides ---
private:
bool side_indicators_are_initialized;
ArrayGenSimple(char) side_ind;
VecSimple(int) boundary_elms; // used for compact storage in sides_ind
bool boSide (int elm, int side, int ind) const; // to be called from GridFE
public:
void initSideIndicators (const GridFE& grid);
};
KEYWORDS
finite element grid, neighbor information
DESCRIPTION
Classs GridFEInfo is an extension of the GridFE class, in the
sense that GridFEInfo contains additional useful grid information
of a type that is not qualified as essential in GridFE. All
GridFE objects have an instance of GridFEInfo. By default, this
instance is empty. If additional information is needed, the user
of the GridFE object asks the GridFEInfo object to generate the
desired information. Only explicit calls to functions in GridFE
Info will allocate the extra data in GridFE's GridFEInfo
attribute. Some of the data structures in class GridFEInfo
require significant memory.
It is recommended that you use the GridFEInfo attribute of GridFE
(the additional_info data member) instead of having a separate
GridFEInfo object.
CONSTRUCTORS AND INITIALIZATION
The various smaller data structures are created if that is neces
sary when the member functions are called. Some member functions
have the name init*. These just allocate and initialize internal
data structures. One can always call the relevant init function
prior to any use of the internal (e.g. NeighborFE) objects to
ensure that the data structures are initialized. Repeated calls
to init* functions will only lead to computations the first time
the routine is invoked.
MEMBER FUNCTIONS
maxSurroundingBox - finds the maximum lengths in each space
direction of all element bounding boxes. The maximum lengths in
different directions do not correspond to the same element. In
other words, length(1) refers to the maximum length of the ele
ment bounding box in x(1) direction, where maximum is taken over
all elements in the mesh.
minmaxGridSpacing - finds the minimum and maximum element size.
The programmer can give an optional argument: A FieldFunc pointer
containing some formula that each element size should be multi
plied by. This is convenient when calculating stability criteria
for time dependent PDEs. The optional argument can be omitted
and only the grid size will then be returned. The algorithm goes
through every element, calls the grid's boundingBox function for
finding characteristic element sizes in each of the cartesian
coordinate directions. The maximum and minimum grid intervales
are computed from these characteristic measures on the spacing.
On a box shaped domain, the grid sizes are exact. In other cases,
consider e.g. a 45 degrees rotated long and tiny element, the
programmer must carefully consider whether this function will
provide relevant results. In the case where NUMT is Complex, the
FieldFunc object returns a complex value, but only the real part
of this number is used in the function. We recommend the user to
read the source code to get complete documentation of the algo
rithm.
characteristicElmSize - returns a measure of the spatial dis
cretization parameter. If dimless is true, one employs the for
mula 1/(n^(1/d)-1), which reflects the number of unknowns n, but
reduces to the distance between nodes in a uniformly partitioned
unit cube with equal partition in the d space dimensions. This
measure is related to the element length divided by a character
istic length of the domain (hence the name dimless). If dimless
is false, the value of minmaxGridSpacing is returned. This is a
true element size. For adaptive grids we recommend to use dimless
true as this reflects the number of unknowns, which is the key
parameter when studiying adaptive methods.
initNeighbor - computes the neighbor information. Repeated calls
will only lead to computation the first time this routine is
invoked. See NeighborFE for documentation on the computed data
and the arguments of the overloaded function.
onlyFirstOrderElements - returns true if all elements are of
first order (triangle, tetrahedra, quadrilateral, hexahedron),
and false otherwise. For example, the bounding box of an ele
ment, computed on basis of the nodal coordinates, is a real
bounding box if the sides are straight, or in other words, if the
elements are of first order Repeated calls will only lead to com
putation the first time this routine is invoked.
getMaxSpacing - finds the maximum length in any direction in any
bounding box of any element. In a sense, getMaxSpacing reflects
the largest grid spacing (among all coordinate directions and all
elements). The function is based on a call to maxSurroundingBox.
Repeated calls to getMaxSpacing will only lead to computation the
first time this routine is invoked.
computeBoxesAndCentroids - computes bounding boxes and centroids
for all the elements in the grid. The result is put in matrices.
The first two columns in the bounding box matrix is the min and
max value of the nodes in the first space dimension. Then follows
the second (and third) space dimension(s) in columns 3 and 4, (5
and 6), respectively. The centroid of an element is computed as
the mean of the the nodes making up the element. See minmax
GridSpacing about the use of bounding boxes.
forceInit - forces all data structures to be re-initialized. Used
by adaptive grid classes to update the neighbor information when
the grid topology has changed. Note that re-computing of the
data structures are only performed for the structures that are
really used (see the comments above).
initSideIndicators - initializes the internal data structure for
efficient look up of boundary indicators on the sides in ele
ments. When initSideIndicators has been called, calls to
GridFE::boSide will automatically invoke array structures in
additional_info (GridFE's GridFEInfo object). If initSideIndica
tors has not been called, GridFE::boSide must apply a more expen
sive algorithm that involves checking that each node on the side
is subject to the given indicator.
SEE ALSO
NeighborFE
DEVELOPED BY
SINTEF Applied Mathematics, Oslo, Norway, and University of Oslo,
Dept. of Mathematics, Norway
AUTHOR
Roger Olafsen, UiO. Extensions by Hans Petter Langtangen, UiO/NO,
and Klas Samuelsson, SINTEF/UiO.