#include <GridLattice.h>
Inheritance diagram for GridLattice::

Public Types | |
| enum | Gridtype { UNIFORM, NONUNIFORM } |
| enum | Component { none = -1, p, u, v, w } |
Public Methods | |
| void | setComponent (GridLattice::Component comp) |
| GridLattice (int nsd=1, enum Gridtype gtype=GridLattice::UNIFORM) | |
| ~GridLattice () | |
| bool | ok () const |
| bool | redim (int nsd) |
| bool | notEqual (const GridLattice &grid) const |
| bool | isUniform () const |
| void | copy (const GridLattice &grid) |
| void | operator= (const GridLattice &grid) |
| void | initBoInds () |
| void | initBoInds (int nbind) |
| real& | xMin (int i) |
| real | xMin (int i) const |
| const Ptv(real)& | xMin () const |
| real& | xMax (int i) |
| real | xMax (int i) const |
| const Ptv(real)& | xMax () const |
| real | Delta (int dir) const |
| real | Delta (int dir, int node) const |
| const Ptv(real) | Delta (const Ptv(int) &node) const |
| real | Delta (int dir, int node, int fict_boundary) const |
| const Ptv(real) | Delta (const Ptv(int) &node, int fict_boundary) const |
| int | getDivisions (int i) const |
| const Ptv(int)& | getDivisions () const |
| Ptv(int) | getNoGridPoints () const |
| int | getNoBoInds () const |
| void | fillCoords (int component, const VecSimple(real) &coords) |
| void | fillSpacing (int component, const VecSimple(real) &spacing) |
| void | setDivisions (int ndiv, int i) |
| void | setDivisions (const Ptv(int) &ndiv) |
| void | setDivisions (const VecSimple(real) &coords, int i) |
| void | setBase (int base_value) |
| int | getBase (int i) const |
| const Ptv(int)& | getBase () const |
| int | getMaxI (int i) const |
| Ptv(int) | getMaxI () const |
| const Ptv(int)& | single2multiple (int single, bool points=true) const |
| int | multiple2single (const Ptv(int) &multiple, bool points=true) const |
| Ptv(real) | getPt (const Ptv(int) &index) const |
| real | getPt (int dir, int index) const |
| Ptv(real) | getPtCellCenter (const Ptv(int) &index) const |
| real | getPtCellCenter (int dir, int index) const |
| void | getMinMaxCellCoord (const Ptv(int) &index, Ptv(real)&mincoord, Ptv(real)&maxcoord) const |
| bool& | scalarInHalfIndex () |
| bool | scalarInHalfIndex () const |
| Ptv(int)& | halfShiftInMax () |
| const Ptv(int)& | halfShiftInMax () const |
| Ptv(int)& | halfShiftInMin () |
| const Ptv(int)& | halfShiftInMin () const |
| bool | wholeIndex (real i) const |
| bool | halfIndex (real i) const |
| virtual void | setIndexBase () |
| virtual real& | indexBase (int i) |
| virtual real | indexBase (int i) const |
| virtual const Ptv(real)& | indexBase () const |
| String | getBoIndName (int indno) const |
| bool | boNode (int node, int indno) const |
| bool | boNode (int node) const |
| bool | boInd (int ind) |
| void | putBoIndName (const String &name, int indno) |
| const Indicators& | boundaryData () const |
| Indicators& | boundaryData () |
| void | attach (const Indicators &boinds) |
| void | redefineBoInds (Is is) |
| void | addBoIndNodes (Is is, bool add=ON) |
| void | setBoInd (int node, int indno) |
| void | clearBoInd (int node, int indno) |
| void | clearBoInds () |
| IndexSet& | createIndexSetInnerNodes () |
| IndexSet& | createIndexSet (int ind) |
| IndexSet& | createIndexSet (const VecSimple(int) &ind) |
| IndexSetCollection& | createIndexSetCollection () |
| bool | insideDomain (const Ptv(real) &x, int fict_boundary=0) const |
| bool | insideDomain (const Ptv(int) &ind, int fict_boundary=0) const |
| bool | getCell (const Ptv(real) &x, Ptv(int) &index) const |
| void | findElmAndLocPt (const Ptv(real) &glob_pt, int &element, Ptv(real) &loc_pt, int &node, bool triangular_element=false) const |
| Ptv(int) | nearestIndex (const Ptv(real) &point, real &distance, bool &exact, const int fict_boundary=0) const |
| virtual int | nearestPoint (const Ptv(real) &point, real &distance, bool &exact) |
| virtual int | getNoPoints () const |
| virtual int | getNoSpaceDim () const |
| String | print () const |
| virtual void | print (Os os) const |
| virtual void | scan (Is is) |
| virtual void | scale () |
| virtual void | unscale () |
| virtual void | startIterator () |
| void | startIterator (const Ptv(int) &index1, const Ptv(int) &index2) |
| virtual bool | nextPt (Ptv(real) &x) |
| bool | nextPt (Ptv(int) &index) |
| bool | nextPt (Ptv(real) &x, Ptv(int) &index) |
| virtual void | getMinMaxCoord (Ptv(real) &mincoord, Ptv(real) &maxcoord) const |
| virtual void | indexCheckOk (real i) const |
| virtual void | indexCheckOk (real i, real j) const |
| virtual void | indexCheckOk (real i, real j, real k) const |
| virtual void | changeGridSize () |
| virtual void | flipAroundSymmetryPlane (int dir, real plane) |
Public Attributes | |
| enum GridLattice::Component | comp_in_staggered_grid |
Protected Methods | |
| IndexSet& | findObstacles (const Ptv(int) &indicators, const Ptv(int) &bmin, const Ptv(int) &bmax) |
Protected Attributes | |
| int | nbind |
| Handle(Indicators) | bind |
NAME: GridLattice - finite difference grid with constant partition
DESCRIPTION:
"GridLattice" enables the programmer to define and manipulate a rectangle/box shaped grid in any number of space dimensions. One may specify UNIFORM or NONUNIFORM in the constructor, depending on the required gridtype. A grid is only UNIFORM when it has uniform partition in all space directions.
|
|
|
|
|
|
|
|
The only constructor available has two arguments indicating the size of internal arrays (ie. the number of space dimensions) and the type of grid (UNIFORM or NONUNIFORM). The constructor can be called with no arguments. The correct dimensions will anyway be set by "redim" or by "scan." The latter function is the usual tool to initialize a "GridLattice" object. Here is an example:
GridLattice g;
g.scan ("d=2 [0,1]x[1,3] index:[0:20]x[0:56]");
All grid parameters must either be set by the "scan" function or the programmer must use the "redim" function and then the functions "xMin", "xMax" and "setDivisions" (and perhaps "setBase"). |
|
|
|
|
|
See documentation of one of the overloaded functions. |
|
|
See documentation of one of the overloaded functions. |
|
|
See documentation of one of the overloaded functions. |
|
|
See documentation of one of the overloaded functions. |
|
|
various versions of this function is implemented. The one that takes one integer argument may only be used if the grid is uniform and returns the spacing in the given direction. The version that takes two integer arguments returns the spacing $x_{i+1}-x_i$ in the given direction, where $i$ is the supplied node number. The version that takes a "Ptv(int)" argument, is the same as the previous version, except it returns the spacing in all space directions. The two functions that also takes an integer specifying a fictional boundary is used if the "FieldLattice" object that uses this grid has a ghost-boundary. This means that one is allowed to request the spacing between nodes that either are inside the grid or outside the grid, but inside the ghost-boundary. The spacings returned for nodes in the ghost-boundary is the value of the corresponding spacings on the grid, symmetrical to the edge of the grid. See class "FieldLattice" for more info on ghost-boundaries. |
|
|
makes it possible to mark new nodes with one of the exisiting boundary indicators. New nodes are given as a domain (hypercube), and the function will process all nodes that are inside this domain. Here is an example of an input string to the function.
"n=2 b1=[0,0]x[1,1] b4=[1,4]x[2,2]"
"n=2 b1=B[0,0]x[1,1] b4=B[1,4]x[2,2]"
The main application of this routine is when simple indication of boundary indicators were made in the preprocessor, for example, only the different sides of the domain were marked, and the user wants to assign boundary conditions to single nodes or to parts of a side. Often the "redefineBoInds" function is called first to extend the number of indicators. The new indicators can then be filled using "addBoIndNodes." It can often be convenient to introduce an indicator that is not used in computations, but only for marking the (whole) boundary. This makes it easier to use the capital B option in front of the hypercubes (the boundary is then already marked, and "addBoIndNodes" sets correct additional markers for computational purposes). (In the input string, the first "=", the "b" and the "=" are the significant characters, strange errors may occur if these characters are missing). The final argument, "bool add", can be given "false" or "OFF" as value. In that case the indicators are turned off instead of on. Often one must make two calls to "addBoIndNodes", first turning some indicators on and then turning other indicators off. |
|
|
attach a set of boundary indicators to the grid. |
|
|
returns true if at least one node in the grid is marked with the given boundary indicator. |
|
|
See documentation of one of the overloaded functions. |
|
|
the version with two arguments returns true if the given node is marked with the given boundary indicator and false otherwise, and the other version of this function returns true if the node is marked with at least one indicator. |
|
|
See documentation of one of the overloaded functions. |
|
|
return a reference to the internal boundary indicator management object. |
|
|
see classes "GridLatticeB" and "GridLatticeC" Reimplemented in GridLatticeB, and GridLatticeC. |
|
|
turn off a particular boundary indicator at a node ("OFF" mode). |
|
|
|
|
|
help function for "operator=" |
|
|
See documentation of one of the overloaded functions. |
|
|
creates an instance of the class "IndexSetBoxObstacles" that contains all the nodes that has the specified/supplied boundary indicator(s) set, but none other than these set. The function also fills the description string of the indexset with information on which boundary indicators the indexset is generated from. |
|
|
creates "IndexSetCollection" that contains one indexset for each combination of boundary indicators, plus one for the inner nodes. The IndexSetCollection is generated by iterating through the grid with "startIterator" and "nextPt". This iteration is done such that 'i' is the fastest varying index, then 'j' and finally 'k' as the slowest varying index (in 3D). Equivalently, in 2D, we have that for each index 'j', we run through all the 'i'-indices. (Here i, j and k are indices in direction 1, 2 and 3 respectively.) The "IndexSet"'s organization are determined by the order in which the boundary indicators are found in the grid through this iteration. For each point in the grid iteration, the boundary indicators set on this point are examined. For each new combination found, a new indexset is added to the collection, where this and future points that have this particular combination are stored, hence the indexsets are stored in the order the boundary indicator-combinations are found in the grid. The indexset covering the inner nodes are always the last indexset in the collection. Remember that one can always use the "getDescription" function in each "IndexSet" for a description of which boundary indicators that where the basis of the index set. |
|
|
creates an instance of the class "IndexSetBoxObstacles" that contains all the nodes that does not have any boundary indicators set. |
|
|
fills the supplied coordinates into the datastructure for the given space direction. The number of coordinates and xMin and xMax values must coinside with the previously set values. |
|
|
builds the coordinates in the given direction on basis of the supplied spacings. Error messages are issued if the number of spacings is incorrect or if the built coordinates do not coinside with the previously set xMax value. |
|
|
finds the cell and a local point in the cell corresponding to a given spatial point. There are similar functions in class "GridFE", but the present version is much more efficient since "GridLattice" is a grid with a very rigid geometric structure. The cells in the "GridLattice" grid are treated as tensor product elements of first order (i.e., bilinear elements in 2D). There is also an optional argument for triangular elements (only in 2D), the diagonal in the cell is then assumed to go from the lower right to the upper left corner (this is compatible with meshes generated by class "PreproBox"). The "findElmAndLocPt" function first checks if the spatial point is a node, if it is the corresponding element is chosen as the element that has the point in the upper right corner. Hence the local element coordinates of the point is typically (1,) (in 2D). If the spatial point is on the lower boundary, "x=xMin(i)", the local point is of course adjusted correspondingly. If the spatial point is not a node, one computes the element and local coordinates from a formula. The "findElmAndLocPt" function is automatically called from "GridFE findElmAndLocPt" if the finite element grid is actually a lattice. |
|
|
|
|
|
Reimplemented from Grid. |
|
|
See documentation of one of the overloaded functions. |
|
|
get the base of the indices counters. |
|
|
get the name of the boundary indicator |
|
|
returns the d-dimensional index of the cell containing the given spatial point. |
|
|
See documentation of one of the overloaded functions. |
|
|
returns the number of divisions (""cells"") in a given or all spatial direction. |
|
|
See documentation of one of the overloaded functions. |
|
|
returns the upper limit of a loop from the base to the maximum number of grid points in a particular direction. For example, in a 2D grid we may easily construct a loop over the grid points:
int i0 = grid.getBase(1); int j0 = grid.getBase(2);
int in = grid.getMaxI(1); int jn = grid.getMaxI(2);
int i,j;
for (i = i0; i <= in; i++)
for (j = 1; j <= jn; j++)
// do something with point (i,j), e.g.
|
|
|
returns the minimun and maximum coordinates of the specified cell. |
|
|
returns the hypercube (with respect to the Cartesian coordinate system where the grid coordinates are defined) that encloses the grid. This function is only meaningful if the grid represents some kind of geometry in the problem. Reimplemented from GridWithPts. |
|
|
returns the number of boundary indicators. |
|
|
returns the number of grid points in each spatial direction. |
|
|
Reimplemented from GridWithPts. |
|
|
returns the number of space dimensions associated with the grid. Reimplemented from GridWithPts. |
|
|
See documentation of one of the overloaded functions. |
|
|
returns the coordinates of point. The point is specified by its index. An overloaded version avoids the use of a "Ptv(int)" for the index, instead one can give a direction and the index in that direction. |
|
|
See documentation of one of the overloaded functions. |
|
|
returns the coordinate of the center/centroid of the cell corresponding to the given index. The numbering of the cells starts at the base and ends with "getMaxI" minus one, in each direction. |
|
|
true if the index "i" is an integer plus one half. |
|
|
See documentation of one of the overloaded functions. |
|
|
same as "halfShiftInMin" but the half grid cell is removed at the end of the grid in the given grid direction. |
|
|
See documentation of one of the overloaded functions. |
|
|
the "half_shift_in_min" variable is 0 by default, i.e no half shift, a half shift is introduced by setting the value 1 in the desired direction. The value must then be specified in all directions by setting 0 in the directions that should not have a half shift. This half shift removes the first half grid cell in the given direction. This is convenient when we have for instance the scalar value given at one end of the grid and a velocity component given at the other end of the grid. |
|
|
See documentation of one of the overloaded functions. |
|
|
See documentation of one of the overloaded functions. |
|
|
various functions returning the index base. |
|
|
See documentation of one of the overloaded functions. Reimplemented in GridLatticeB, and GridLatticeC. |
|
|
See documentation of one of the overloaded functions. Reimplemented in GridLatticeB, and GridLatticeC. |
|
|
checks if the given indices are integers or integers pluss one half, depending on the type of staggered grid given. Reimplemented in GridLatticeB, and GridLatticeC. |
|
|
See documentation of one of the overloaded functions. |
|
|
the version witch takes no argument sets up a set of default boundary indicators along the edge of the grid, numbered such that the first indicator is set on the top edge in the first space-direction, the next at the top edge in the second space direction and so on for all nsd, then the next indicator is set on the lower edge in the first space direction, the next on the lower edge of the second and so on. The version that takes an integer argument does not set any indicators, it just allocates space for the given number of boundary indicators, which must later be set by the function addBoIndNodes. |
|
|
See documentation of one of the overloaded functions. |
|
|
checks if the given point (or the given indices) is inside the grid. The optional argument "fict_boundary" should be used when the corresponding "FieldLattice" object has a fictitious boundary (ghost boundary) around the grid, and one wishes to find out if the point/indices are inside the grid and the imaginary boundary around the grid. See class "FieldLattice" for more info on the effect of fictitious boundary (ghost boundary). |
|
|
returns true if the lattice grid has uniform partition. |
|
|
returns the single index corresponding to the supplied multiple index. See the function "single2multiple" for more information. |
|
|
a la "nearestPoint" (see class "GridWithPts"), but computes the index of the point that is nearest the specified point. The index is an n-tuple (represented as usual by a "Ptv(int)" object). |
|
|
computes the grid point that is nearest to an arbitrarily given point. The input argument is the specified point, while the output arguments are the distance to the point and a boolean variable indicating if the given point coincides with one of the grid points. If the boolean value is true, the distance to the point is zero. The return value is the point number of the point that is nearest to the specified point. There are some overloaded versions of "nearestPoint". These are aimed at various search algorithms required by "valuePt" in finite element meshes. Reimplemented from GridWithPts. |
|
|
|
|
|
|
|
|
gives the coordinates of the next point in the grid. The return value is false when there are no more points in the grid. Here is an example on iteration over the grid points:
grid.startIterator();
while (grid.nextPt(p))
{ .... }
Reimplemented from GridWithPts. |
|
|
returns false if the two grids are equal, otherwise returns true. |
|
|
|
|
|
|
|
|
prints the grid (usually in ascii format). Reimplemented from Grid. |
|
|
|
|
|
assign a name to a boundary indicator. |
|
|
makes it possible to redefine the boundary indicators, that is, define a mapping between old and new boundary indicators. Assume that we have three boundary indicators and that we want to map these three indicators over to a new set of four indicators. The new indicator 1 consists of nodes subjected to old indicator 1 or 3, the new indicator 2 should be empty, the new indicator three is identical to old indicator three, while the new indicator four should consist of all the old indicators. Let the names of the new indicators be "green", "blue", "red" and "black". The mapping is defined by the following string which can be sent as argument to "redefine".
nbind=4, names= green blue red black 1=(1 3) 2=() 3=(3) 4=(1 2 3)
=4 =green blue red black (1 3 ()(3)(1) 2 3)
|
|
|
|
|
|
See documentation of one of the overloaded functions. |
|
|
"true" if the scalar ("p") is located in the centriod of the grid cell in the staggered grid, "false" if the scalar value is evaluated in the vertices of the cells. Where the vecocity components are evaluated is determined by the evaluation point for the scalar value and by the type of staggered grid (B-grid or C-grid). See classes "GridLatticeB" and "GridLatticeC" for more detailes. |
|
|
Reimplemented from GridWithPts. |
|
|
The "scan" function reads an "Is" (string, stream, file) on the following format for uniform partition
grid, d=3, [-1,1]x[0,1]x[0,1] indices=[0:10]x[1:8]x[-6:6]
For a NONUNIFORM grid, the "scan" string is as follows:
grid, d=2 domain = [0,1]x[0,1] grid points = [0:5]x[1:10]
spacing=NONUNIFORM 0.0 0.2 0.4 0.6 0.8 1.0;
0.0 0.15 0.2 0.25 0.3 0.35 0.4 0.6 0.8 1.0;
Reimplemented from Grid. |
|
|
set the base of the indices counters (usually 0 or 1, 1 is default). |
|
|
set a particular boundary indicator at a node ("ON" mode). |
|
|
|
|
|
See documentation of one of the overloaded functions. |
|
|
See documentation of one of the overloaded functions. |
|
|
sets the number of grid points in one or all spatial direction depending on which version of the function is called. This function then reinitializes the internal datamembers that depend upon the number of divisions. The simplest version of this function taking two integers can only be called for uniform grids. The version that takes a "Ptv(int)" can be used for both uniform and non-uniform grids, but if this function is called for a non-uniform grid, it will initialize the coordinates as if the grid was uniform. The default coordinates can then be changed using "fillCoords" or "fillSpacings". The version that takes a "VecSimple(real)" coordinate vector may be used for both uniform and non-uniform grids, but it will set a uniform grid to be non-uniform and use the supplied coordinates in the given direction. An error message is issued if the supplied coordinates do not coinside with the previously set "xMin" and "xMax" values. |
|
|
will usually not need to be called explicitly by the user. Sets the "index_base" to the given values, depending on the location of the various unknowns in the staggered grid. The "index_base" is set such that if its value in the desired direction is subtracted from the users supplied index, the resulting index will always be an integer, allowing the correct array value to be accessed. That is, if the staggered grid is such that a value is evaluated in the center of the grid cell in a given direction, the "index_base" is set to 0.5 in that same direction, otherwise the index_base is set to 0.0. Reimplemented in GridLatticeB, and GridLatticeC. |
|
|
returns the index represented as a "Ptv" corresponding to the single index supplied to the function. If the second argument, ""points"" is true, the indices refer to points/nodes in the grid, if the argument is false, the indices refer to grid cells. |
|
|
|
|
|
initializes an iteration over the grid points. Reimplemented from GridWithPts. |
|
|
Reimplemented from GridWithPts. |
|
|
true if the index "i" is an integer. |
|
|
See documentation of one of the overloaded functions. |
|
|
See documentation of one of the overloaded functions. |
|
|
gives the maximum coordinates of the grid. |
|
|
See documentation of one of the overloaded functions. |
|
|
See documentation of one of the overloaded functions. |
|
|
gives the minimum coordinates of the grid. |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|