OOFEM
2.4
OOFEM.org - Object Oriented Finite Element Solver
|
Class that solves certain problems on a regular 2D grid, consisting of n x m nodes. More...
#include <grid.h>
Public Member Functions | |
Grid (int N, int M) | |
Constructor (N = horizontal dimension, M = vertical dimension) More... | |
~Grid () | |
Destructor. More... | |
int | giveSizeHorizontal () |
Size information. More... | |
int | giveSizeVertical () |
int | giveSize (int dir) |
void | unFreeze () |
Set all flags to "unfrozen". More... | |
void | setMethod (int o, double i, int c) |
Set the details of the algorithm to be used. More... | |
void | setPrescribedFieldValue (int i, int j, double val) |
Method setting the values of the prescribed field (e.g., front velocities) More... | |
FloatMatrix * | givePrescribedField () |
void | setZeroValues (FloatMatrix *gridCoords) |
Methods setting the values of the unknown field at selected points (e.g., zero times) More... | |
void | setSolutionValueAt (int i, int j, double value) |
double | giveSolutionValueAt (int i, int j) |
Output methods. More... | |
void | printSolutionAsData () |
Private Member Functions | |
void | fastMarch (int &eFlag) |
Fast marching method, solving the eikonal equation. More... | |
double | calcTime (int i, int j, double Fij, int ord, int &eFlag) |
Auxiliary function that evaluates the tentative value at one grid point, exploited by the fast marching method. More... | |
int | ij2ind (int i, int j, int m) |
Utility methods. More... | |
int | ind2i (int ind, int m) |
int | ind2j (int ind, int m) |
bool | isInDomain (int i, int j, int m, int n) |
Private Attributes | |
int | n |
Grid dimensions: number of grid nodes horizontally (n) and vertically (m) More... | |
int | m |
int | order |
Algorithmic parameters. More... | |
double | initDiag |
int | centDiff |
bool | solutionAvailable |
Flag indicating whether the solution has been computed. More... | |
FloatMatrix * | T |
Matrix storing the values of the unknown (computed) field (e.g., arrival times) More... | |
FloatMatrix * | F |
Matrix storing the values of the prescribed field (e.g., front velocities) More... | |
bool * | Frozen |
Array storing indicators of frozen points (at which the solution is already known) More... | |
Heap * | narrowBand |
Heap used for efficient sorting and detection of smallest candidate. More... | |
Class that solves certain problems on a regular 2D grid, consisting of n x m nodes.
Currently it implements the fast marching algorithm that solves the eikonal equation. This can be useful for instance for tracing evolving curves. One could also implement finite differences or similar techniques.
The indexing convention is a bit unusual but it follows the original code, which was developed for image analysis. Subscripts "i" and "j" refer to rows and columns of the matrix, but this means that "i" grows in the vertical direction and corresponds to physical coordinate "y". i ... from 1 to m, corresponds to coordinate y j ... from 1 to n, corresponds to coordinate x Actually, for the numerical method it does not matter which direction is horizontal and which one is vertical, but the user should know how to interpret the data. The constructor should get the horizontal dimension first and the vertical one second (n,m). The coordinates of points at which zero value is prescribed should be passed as (x,y). The prescribed field (e.g., propagating front velocity) should be stored by rows, i.e., (1,1), (1,2), (1,3), ... (1,m), (2,1), (2,2,) ... (n,m). If the solution is printed as a matrix, it is arranged on the screen in the natural way. If the solution is printed as data, each output line corresponds to (x,y,value), where x=j and y=i. Conversion to grids with non-unit spacing and shifter corner must be done by the user.
oofem::Grid::Grid | ( | int | N, |
int | M | ||
) |
Constructor (N = horizontal dimension, M = vertical dimension)
Definition at line 46 of file grid.C.
References F, Frozen, m, n, N, narrowBand, solutionAvailable, and T.
oofem::Grid::~Grid | ( | ) |
|
private |
Auxiliary function that evaluates the tentative value at one grid point, exploited by the fast marching method.
Definition at line 303 of file grid.C.
References oofem::FloatMatrix::at(), centDiff, F, Frozen, ij2ind(), isInDomain(), m, MAX, MIN, n, and T.
Referenced by fastMarch().
|
private |
Fast marching method, solving the eikonal equation.
Definition at line 228 of file grid.C.
References oofem::FloatMatrix::at(), calcTime(), F, Frozen, oofem::Heap::getSmallest(), ij2ind(), ind2i(), ind2j(), oofem::Heap::insert(), isInDomain(), oofem::Heap::isInHeap(), m, n, narrowBand, oofem::Heap::nElems(), order, solutionAvailable, T, and oofem::Heap::update().
Referenced by giveSolutionValueAt().
|
inline |
Definition at line 54 of file grid.h.
References F, giveSolutionValueAt(), printSolutionAsData(), setSolutionValueAt(), and setZeroValues().
Referenced by oofem::NonlocalMaterialExtensionInterface::modifyNonlocalWeightFunctionAround().
int oofem::Grid::giveSize | ( | int | dir | ) |
|
inline |
|
inline |
Definition at line 42 of file grid.h.
References giveSize(), m, and unFreeze().
double oofem::Grid::giveSolutionValueAt | ( | int | i, |
int | j | ||
) |
Output methods.
Definition at line 204 of file grid.C.
References oofem::FloatMatrix::at(), fastMarch(), solutionAvailable, and T.
Referenced by givePrescribedField(), and oofem::NonlocalMaterialExtensionInterface::modifyNonlocalWeightFunctionAround().
|
inlineprivate |
Utility methods.
Definition at line 96 of file grid.h.
Referenced by calcTime(), fastMarch(), and setZeroValues().
|
inlineprivate |
|
inlineprivate |
Definition at line 98 of file grid.h.
Referenced by fastMarch().
|
inlineprivate |
Definition at line 99 of file grid.h.
Referenced by calcTime(), fastMarch(), and setZeroValues().
void oofem::Grid::printSolutionAsData | ( | ) |
Definition at line 216 of file grid.C.
References oofem::FloatMatrix::at(), m, n, and T.
Referenced by givePrescribedField().
|
inline |
|
inline |
Method setting the values of the prescribed field (e.g., front velocities)
Definition at line 53 of file grid.h.
References oofem::FloatMatrix::at(), and F.
void oofem::Grid::setSolutionValueAt | ( | int | i, |
int | j, | ||
double | value | ||
) |
Definition at line 196 of file grid.C.
References oofem::FloatMatrix::at(), solutionAvailable, and T.
Referenced by givePrescribedField().
void oofem::Grid::setZeroValues | ( | FloatMatrix * | gridCoords | ) |
Methods setting the values of the unknown field at selected points (e.g., zero times)
Definition at line 105 of file grid.C.
References oofem::FloatMatrix::at(), centDiff, F, Frozen, oofem::FloatMatrix::giveNumberOfColumns(), oofem::FloatMatrix::giveNumberOfRows(), ij2ind(), initDiag, isInDomain(), m, MIN, n, OOFEM_ERROR, solutionAvailable, and T.
Referenced by givePrescribedField(), and oofem::NonlocalMaterialExtensionInterface::modifyNonlocalWeightFunctionAround().
void oofem::Grid::unFreeze | ( | ) |
Set all flags to "unfrozen".
Definition at line 95 of file grid.C.
References Frozen, m, n, narrowBand, oofem::Heap::setToEmpty(), and solutionAvailable.
Referenced by giveSizeVertical(), and oofem::NonlocalMaterialExtensionInterface::modifyNonlocalWeightFunctionAround().
|
private |
Definition at line 72 of file grid.h.
Referenced by calcTime(), setMethod(), and setZeroValues().
|
private |
Matrix storing the values of the prescribed field (e.g., front velocities)
Definition at line 81 of file grid.h.
Referenced by calcTime(), fastMarch(), givePrescribedField(), Grid(), setPrescribedFieldValue(), setZeroValues(), and ~Grid().
|
private |
Array storing indicators of frozen points (at which the solution is already known)
Definition at line 84 of file grid.h.
Referenced by calcTime(), fastMarch(), Grid(), setZeroValues(), unFreeze(), and ~Grid().
|
private |
Definition at line 71 of file grid.h.
Referenced by setMethod(), and setZeroValues().
|
private |
Definition at line 67 of file grid.h.
Referenced by calcTime(), fastMarch(), giveSize(), giveSizeVertical(), Grid(), ind2i(), printSolutionAsData(), setZeroValues(), and unFreeze().
|
private |
Grid dimensions: number of grid nodes horizontally (n) and vertically (m)
Definition at line 67 of file grid.h.
Referenced by calcTime(), fastMarch(), giveSize(), giveSizeHorizontal(), Grid(), printSolutionAsData(), setZeroValues(), and unFreeze().
|
private |
Heap used for efficient sorting and detection of smallest candidate.
Definition at line 87 of file grid.h.
Referenced by fastMarch(), Grid(), unFreeze(), and ~Grid().
|
private |
Algorithmic parameters.
Definition at line 70 of file grid.h.
Referenced by fastMarch(), and setMethod().
|
private |
Flag indicating whether the solution has been computed.
Definition at line 75 of file grid.h.
Referenced by fastMarch(), giveSolutionValueAt(), Grid(), setSolutionValueAt(), setZeroValues(), and unFreeze().
|
private |
Matrix storing the values of the unknown (computed) field (e.g., arrival times)
Definition at line 78 of file grid.h.
Referenced by calcTime(), fastMarch(), giveSolutionValueAt(), Grid(), printSolutionAsData(), setSolutionValueAt(), setZeroValues(), and ~Grid().