#include <Grid.h>
Public Types | |
enum | { LEFT_BOUND_FLAG = 1, RIGHT_BOUND_FLAG = 2 } |
enum | { IC_CONSTR_MASK = 3, IC_CONSTR_NONE = 0, IC_CONSTR_INTERPOLATED_ONLY = 1, IC_CONSTR_ALL = 2 } |
Public Member Functions | |
virtual Grid * | cloneGrid () const =0 |
Clones this grid. | |
GReal_t | getBaseMinX () const |
GReal_t | getBaseMaxX () const |
GReal_t | getLocationX () const |
Gets the location of the point with index 0. | |
GridIterator | getXIterator () const |
virtual GReal_t | getSizeX () const =0 |
Gets the grid width. | |
virtual int | getLeftmostI () const =0 |
virtual int | getRightmostI () const =0 |
virtual bool | isPeriodic () const =0 |
virtual GReal_t | getLocationX (int i) const =0 |
Gets the location of the point with index i. | |
int | getIndexFromX (GReal_t x, double maxerr) const throw (IllegalArgumentException&) |
int | getLocationI () const |
Gets the location of the origin relative to the parent grid's origin. | |
GReal_t | getDeltaX () const |
void | setTime (GReal_t t) |
GReal_t | getTime () const |
void | setTimeStepCount (int tsc) |
int | getTimeStepCount () const |
int | getLastErrorCheckTime () const |
int | getNumComponents () const |
Gets the number of components of the field. | |
int | getRefinementRatio () const |
Gets the refinement ratio. | |
virtual int | getMarginLeft (int ir) const =0 |
Gets the left margin size. | |
virtual int | getMarginRight (int ir) const =0 |
Gets the right margin size. | |
int | getMaxI () const |
Gets the maximum grid index. | |
virtual int | getNumPointsAboveMaxX () const |
Gets number of grid points above infinity (Xmax). | |
int | getLevel () const |
Gets the level in the tree. | |
Grid * | getParent () const |
Gets the parent grid. | |
Grid * | getOffspring () const |
Gets the first offspring. | |
Grid * | getNextSibling () const |
Gets the sibling grid. | |
bool | containsLeftBound () const |
bool | containsRightBound () const |
virtual int | distanceFromLeft (int i) const =0 |
Gets the distance from the left edge. | |
virtual int | distanceFromRight (int i) const =0 |
Gets the distance from the right edge. | |
int | getAbsoluteIndex (int i) const |
virtual int | getAbsoluteIndex (int i, int mul) const =0 |
void | getField (int i, FieldWrapper &f) const |
Gets the field value at the specified grid point. | |
void | setEnergyLosses (const tvalarray< GReal_t > &e, PDE *pde) |
GReal_t | getEnergyFlow (int i) const |
Gets the energy flow in a grid point. | |
GReal_t | getEnergyLoss (int i) const |
Gets the integrated energy flow in a grid point. | |
void | addTo (int i, GReal_t v[]) const |
Add field values to the components of an array. | |
void | addMultipliedTo (int i, GReal_t c, GReal_t v[]) const |
Add field values multiplied by a scalar to the components of an array. | |
void | addMultipliedTo (int i, int exclude, GReal_t c, const GReal_t arr[], GReal_t v[]) const |
Add field values multiplied by a scalar to the components of an array. | |
void | get (int i, GReal_t v[], int off=0) const |
Gets the field value at the specified grid point. | |
void | set (int i, GReal_t v[]) |
Sets the field value at the specified grid point. | |
GReal_t | getComponent (int i, int k) const |
Gets a field component at the specified grid point. | |
virtual void | initRefinedDataExistenceArray ()=0 |
Initializes the refinedDataExists array. | |
int | getRefinedMaxI () const |
Gets the maximum index on refined grid. | |
virtual bool | hasRefinedData (int i) const =0 |
Tests whether refined data at the specified index exists or not. | |
int | getRefinedDataExistence (int i, int n, const PDE &pde) const |
Tests the existence of refined data at the specified indices. | |
const Grid * | getSubgridAt (int i) const |
Gets the refined data at the specified grid point if exists. | |
const Grid * | getFinestSubgridAt (GReal_t x) const |
Gets the finest subgrid at the specified location. | |
virtual void | getRefinedData (int i, GReal_t yout[]) const =0 |
Gets the refined data at the specified grid point if exists. | |
void | setZero () |
Sets all the grid values to zero. | |
Regridder * | getRegridder () |
void | setRegridder (Regridder *r) |
bool | hasUncoveredFlaggedPoint (int margin) |
Checks if there exists any flagged point which is not covered by a refined subgrid. | |
virtual Grid * | createTemporaryGrid (int dmargin_L, int dmargin_R, GReal_t xshift)=0 |
void | setTemporaryGridShift (const Grid &p, GReal_t xshift) |
Sets the shift for a temporary grid. | |
virtual void | setTemporaryGridMargins (const Grid &p, int dmargin_L, int dmargin_R)=0 |
Sets the margins and the shift for a temporary grid. | |
Integrator * | getIntegrator () const |
Gets the grid integrator method. | |
void | injectFineToCoarse (PDE *pde) |
Sets this "coarse" grid's values from values on the finer subgrids. | |
void | checkErrors (double critical) |
Flag points where error is larger than critical. | |
int | generateRefinedGrids (int minLevel, int maxLevel, int numVelocity, int bufzoneradius, int thislevel, int gridi) |
Generates a list of new subgrids from the flagged points. | |
void | interpolateNewSubgrids (PDE *pde) throw (IllegalArgumentException&) |
Set the new grid's initial values by interpolation. | |
void | initConstraints (PDE *pde, FieldWrapper &tmp, int opts) |
Initializes constrained field components. | |
bool | isEnergyLossStored () const |
string | getDataAsString () const |
string | toString () const |
string | sprintHierarchy () const |
virtual void | interpolateMargins (PDE *pde)=0 |
Protected Member Functions | |
Grid (const Grid &g) | |
Copy constructor. | |
Grid (GReal_t minx, GReal_t maxx, int maxi, int nc, Regridder *refproto, int r, GReal_t dx) | |
Creates a base grid. | |
Grid (const Grid &p, GReal_t xshift) | |
Creates a temporary grid. | |
Grid (Grid *p, int r1, int loci, int maxi, int margin, int vmargin, int minLevel) | |
Creates a refined grid. | |
void | copy (Grid *orig, map< Grid *, Grid * > &gridmap) |
Copy fields of class Grid. | |
virtual int | getInternalIndex (int i) const =0 |
Gets the internal array index. | |
int | getRealIndex (int i) const |
Gets the "real" index. | |
virtual int | getSubgridIndexFromIndex (const Grid *g, int i) const =0 |
virtual int | getIndexFromSubgridIndex (const Grid *g, int i) const =0 |
virtual Grid * | createRefinedGrid (IntervalList *iv, int margin, int vmargin, int minLevel, int r1)=0 |
Creates a refined grid. | |
void | init (Integrator *proto, const Sigma *sigma, int n) |
Initialization of the integrator and the field data array. | |
void | initEnergyLoss (PDE &pde) |
void | updateEnergyLoss (const PDE &pde, int i, Grid &baseg, int jbase, GReal_t epsilon) |
XFArray * | getDensityData (const PDE::DensityQuantity &q, GReal_t xmin, GReal_t xmax) const |
virtual void | blur (tvalarray< unsigned char > &pf, int i) const =0 |
Both neighbors of points with the specified value in an array are set to value plus 1. | |
virtual int | getFirstIndexForRefinement (const tvalarray< unsigned char > &pf) const =0 |
Gets the first point to start refinement interval searching. | |
virtual int | findIntervalEndForRefinement (const tvalarray< unsigned char > &pf, int i) const =0 |
Finds the right edge of an interval that needs refinement. | |
virtual int | intervalRefinedSize (const IntervalList *iv, int r) const =0 |
virtual int | gridIndexLeftOf (int i, int dmax) const =0 |
virtual int | gridIndexRightOf (int i, int dmax) const =0 |
virtual void | fixSubgridNearBounds (IntervalList *l, IntervalList *r, int margin) const =0 |
virtual int | calcNewSubSubgridLocation (int ssloc, int osloc, int nsloc)=0 |
Calculates the new location of a sub-subgrid (relative to the parent) if its parent (a subgrid) changed. | |
virtual void | fillRefinedDataArray ()=0 |
Fills the refinedData array. | |
void | initConstraints (PDE *pde, int left, int right, FieldWrapper &tmp, int opts) |
Initializes constrained field in the given range. | |
Protected Attributes | |
int | flags |
tvalarray< GReal_t > | theData |
Grid data. | |
tvalarray< bool > | refinedDataExists |
Friends | |
class | GridIterator |
class | Regridder |
class | Integrator |
class | AMRCore |
class | PDE::FiniteIntegral |
gridripper::amr1d::Grid::Grid | ( | const Grid & | g | ) | [protected] |
Copy constructor.
All fields are copied except those of class Grid.
g | the grid to copy |
Creates a temporary grid.
p | the parent grid | |
xshift | the shift |
gridripper::amr1d::Grid::Grid | ( | Grid * | p, | |
int | r1, | |||
int | loci, | |||
int | maxi, | |||
int | margin, | |||
int | vmargin, | |||
int | minLevel | |||
) | [protected] |
Creates a refined grid.
p | the parent grid | |
r1 | refinement ratio for the refined grid's future subgrids | |
loci | location of origin in parent grid | |
maxi | maximum grid index | |
margin | the margin size | |
vmargin | numerical error propagation velocity | |
minLevel | set grandparent's sub-subgrid list if its level is larger than or equal to minLevel |
virtual int gridripper::amr1d::Grid::getInternalIndex | ( | int | i | ) | const [protected, pure virtual] |
Gets the internal array index.
The internal array index is the sum of the "real" index and the left margin size if present.
i | the index |
Implemented in gridripper::amr1d::BoundedGrid.
int gridripper::amr1d::Grid::getRealIndex | ( | int | i | ) | const [inline, protected] |
Gets the "real" index.
The real index is normally equal to the argument i, it only differs in case of a periodic grid.
i | the index |
virtual Grid* gridripper::amr1d::Grid::createRefinedGrid | ( | IntervalList * | iv, | |
int | margin, | |||
int | vmargin, | |||
int | minLevel, | |||
int | r1 | |||
) | [protected, pure virtual] |
Creates a refined grid.
p | the parent grid | |
iv | the left and right edge in the parent grid | |
margin | margin size | |
vmargin | numerical error propagation velocity | |
minLevel | set grandparent's sub-subgrid list if its level is larger than or equal to minLevel | |
r1 | the refinement ratio value if the created grid can be refined further, 1 otherwise |
Implemented in gridripper::amr1d::BoundedGrid.
void gridripper::amr1d::Grid::init | ( | Integrator * | proto, | |
const Sigma * | sigma, | |||
int | n | |||
) | [protected] |
Initialization of the integrator and the field data array.
proto | integrator prototype | |
sigma | the dissipation term multiplier | |
n | total grid size |
virtual void gridripper::amr1d::Grid::blur | ( | tvalarray< unsigned char > & | pf, | |
int | i | |||
) | const [protected, pure virtual] |
Both neighbors of points with the specified value in an array are set to value plus 1.
pf | nonzero values in this array indicate the need of refinement | |
i | the value |
Implemented in gridripper::amr1d::BoundedGrid.
virtual int gridripper::amr1d::Grid::getFirstIndexForRefinement | ( | const tvalarray< unsigned char > & | pf | ) | const [protected, pure virtual] |
Gets the first point to start refinement interval searching.
pf | nonzero values in this array indicate the need of refinement |
Implemented in gridripper::amr1d::BoundedGrid.
virtual int gridripper::amr1d::Grid::findIntervalEndForRefinement | ( | const tvalarray< unsigned char > & | pf, | |
int | i | |||
) | const [protected, pure virtual] |
Finds the right edge of an interval that needs refinement.
pf | nonzero values in this array indicate the need of refinement | |
i | the left edge index |
Implemented in gridripper::amr1d::BoundedGrid.
virtual int gridripper::amr1d::Grid::calcNewSubSubgridLocation | ( | int | ssloc, | |
int | osloc, | |||
int | nsloc | |||
) | [protected, pure virtual] |
Calculates the new location of a sub-subgrid (relative to the parent) if its parent (a subgrid) changed.
ssloc | old sub-subgrid's (relative) location | |
osloc | its old parent's location (relative to this grid) | |
nsloc | new parent's location (relative to this grid) |
Implemented in gridripper::amr1d::BoundedGrid.
virtual Grid* gridripper::amr1d::Grid::cloneGrid | ( | ) | const [pure virtual] |
virtual GReal_t gridripper::amr1d::Grid::getSizeX | ( | ) | const [pure virtual] |
virtual GReal_t gridripper::amr1d::Grid::getLocationX | ( | int | i | ) | const [pure virtual] |
Gets the location of the point with index i.
i | the point index |
Implemented in gridripper::amr1d::BoundedGrid.
int gridripper::amr1d::Grid::getNumComponents | ( | ) | const [inline] |
Gets the number of components of the field.
int gridripper::amr1d::Grid::getRefinementRatio | ( | ) | const [inline] |
Gets the refinement ratio.
virtual int gridripper::amr1d::Grid::getMarginLeft | ( | int | ir | ) | const [pure virtual] |
Gets the left margin size.
ir | step count |
Implemented in gridripper::amr1d::BoundedGrid.
virtual int gridripper::amr1d::Grid::getMarginRight | ( | int | ir | ) | const [pure virtual] |
Gets the right margin size.
ir | step count |
Implemented in gridripper::amr1d::BoundedGrid.
int gridripper::amr1d::Grid::getMaxI | ( | ) | const [inline] |
Gets the maximum grid index.
virtual int gridripper::amr1d::Grid::getNumPointsAboveMaxX | ( | ) | const [inline, virtual] |
Gets number of grid points above infinity (Xmax).
Reimplemented in gridripper::amr1d::BoundedGrid.
int gridripper::amr1d::Grid::getLevel | ( | ) | const [inline] |
Gets the level in the tree.
The base grid is at level 0.
Grid* gridripper::amr1d::Grid::getParent | ( | ) | const [inline] |
Gets the parent grid.
Grid* gridripper::amr1d::Grid::getOffspring | ( | ) | const [inline] |
Gets the first offspring.
Grid* gridripper::amr1d::Grid::getNextSibling | ( | ) | const [inline] |
Gets the sibling grid.
virtual int gridripper::amr1d::Grid::distanceFromLeft | ( | int | i | ) | const [pure virtual] |
Gets the distance from the left edge.
i | grid point index |
Implemented in gridripper::amr1d::BoundedGrid.
virtual int gridripper::amr1d::Grid::distanceFromRight | ( | int | i | ) | const [pure virtual] |
Gets the distance from the right edge.
i | grid point index |
Implemented in gridripper::amr1d::BoundedGrid.
void gridripper::amr1d::Grid::getField | ( | int | i, | |
FieldWrapper & | f | |||
) | const [inline] |
Gets the field value at the specified grid point.
i | grid point index | |
v | put the field values into this array |
GReal_t gridripper::amr1d::Grid::getEnergyFlow | ( | int | i | ) | const [inline] |
Gets the energy flow in a grid point.
Energy flow is always calculated if energy loss is calculated.
i | the grid point index |
GReal_t gridripper::amr1d::Grid::getEnergyLoss | ( | int | i | ) | const [inline] |
Gets the integrated energy flow in a grid point.
i | the grid point index |
void gridripper::amr1d::Grid::addTo | ( | int | i, | |
GReal_t | v[] | |||
) | const [inline] |
Add field values to the components of an array.
i | grid point index | |
v | target array |
Add field values multiplied by a scalar to the components of an array.
i | grid point index | |
c | multiplier | |
v | target array |
void gridripper::amr1d::Grid::addMultipliedTo | ( | int | i, | |
int | exclude, | |||
GReal_t | c, | |||
const GReal_t | arr[], | |||
GReal_t | v[] | |||
) | const [inline] |
Add field values multiplied by a scalar to the components of an array.
i | grid point index | |
exclude | do not add the specified components | |
c | multiplier | |
arr | array of multipliers | |
v | target array |
void gridripper::amr1d::Grid::get | ( | int | i, | |
GReal_t | v[], | |||
int | off = 0 | |||
) | const [inline] |
Gets the field value at the specified grid point.
i | grid point index | |
v | put the field values into this array | |
off | offset in output array |
void gridripper::amr1d::Grid::set | ( | int | i, | |
GReal_t | v[] | |||
) | [inline] |
Sets the field value at the specified grid point.
i | grid point index | |
v | the field vector |
GReal_t gridripper::amr1d::Grid::getComponent | ( | int | i, | |
int | k | |||
) | const [inline] |
Gets a field component at the specified grid point.
i | grid point index | |
k | the field component index |
int gridripper::amr1d::Grid::getRefinedMaxI | ( | ) | const [inline] |
Gets the maximum index on refined grid.
virtual bool gridripper::amr1d::Grid::hasRefinedData | ( | int | i | ) | const [pure virtual] |
Tests whether refined data at the specified index exists or not.
i | refined grid index |
Implemented in gridripper::amr1d::BoundedGrid.
int gridripper::amr1d::Grid::getRefinedDataExistence | ( | int | i, | |
int | n, | |||
const PDE & | pde | |||
) | const |
Tests the existence of refined data at the specified indices.
i | start index on refined grid | |
n | number of refined grid points to test |
const Grid* gridripper::amr1d::Grid::getSubgridAt | ( | int | i | ) | const [inline] |
Gets the refined data at the specified grid point if exists.
i | refined grid index | |
yout | the output array |
Gets the finest subgrid at the specified location.
x | the location |
virtual void gridripper::amr1d::Grid::getRefinedData | ( | int | i, | |
GReal_t | yout[] | |||
) | const [pure virtual] |
Gets the refined data at the specified grid point if exists.
i | refined grid index | |
yout | the output array |
Implemented in gridripper::amr1d::BoundedGrid.
void gridripper::amr1d::Grid::setZero | ( | ) |
Sets all the grid values to zero.
bool gridripper::amr1d::Grid::hasUncoveredFlaggedPoint | ( | int | margin | ) |
Checks if there exists any flagged point which is not covered by a refined subgrid.
Sets the shift for a temporary grid.
p | the parent grid | |
xshift | the shift |
virtual void gridripper::amr1d::Grid::setTemporaryGridMargins | ( | const Grid & | p, | |
int | dmargin_L, | |||
int | dmargin_R | |||
) | [pure virtual] |
Sets the margins and the shift for a temporary grid.
p | the parent grid | |
dmargin_L | the left margin | |
dmargin_R | the right margin |
Implemented in gridripper::amr1d::BoundedGrid.
Integrator* gridripper::amr1d::Grid::getIntegrator | ( | ) | const [inline] |
Gets the grid integrator method.
void gridripper::amr1d::Grid::injectFineToCoarse | ( | PDE * | pde | ) |
Sets this "coarse" grid's values from values on the finer subgrids.
void gridripper::amr1d::Grid::checkErrors | ( | double | critical | ) |
int gridripper::amr1d::Grid::generateRefinedGrids | ( | int | minLevel, | |
int | maxLevel, | |||
int | numVelocity, | |||
int | bufzoneradius, | |||
int | thislevel, | |||
int | gridi | |||
) |
Generates a list of new subgrids from the flagged points.
minLevel | the minimum level to regrid, larger than or equal to zero and smaller than Integer.MAX_VALUE if the grids are regenerated, Integer.MAX_VALUE at the first generation | |
maxLevel | the maximum allowed refinement level | |
numVelocity | the error propagation velocity | |
bufzoneradius | size of the buffer zone |
virtual void gridripper::amr1d::Grid::fillRefinedDataArray | ( | ) | [protected, pure virtual] |
Fills the refinedData array.
Should only be called after interpolateMargins!
Implemented in gridripper::amr1d::BoundedGrid.
tvalarray<GReal_t> gridripper::amr1d::Grid::theData [protected] |
Grid data.