gridripper::amr1d::Grid Class Reference

1 dimensional grid for the adaptive mesh refinement algorithm. More...

#include <Grid.h>

Inheritance diagram for gridripper::amr1d::Grid:

gridripper::amr1d::BoundedGrid

List of all members.

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 GridcloneGrid () 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.
GridgetParent () const
 Gets the parent grid.
GridgetOffspring () const
 Gets the first offspring.
GridgetNextSibling () 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 GridgetSubgridAt (int i) const
 Gets the refined data at the specified grid point if exists.
const GridgetFinestSubgridAt (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.
RegriddergetRegridder ()
void setRegridder (Regridder *r)
bool hasUncoveredFlaggedPoint (int margin)
 Checks if there exists any flagged point which is not covered by a refined subgrid.
virtual GridcreateTemporaryGrid (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.
IntegratorgetIntegrator () 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 GridcreateRefinedGrid (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)
XFArraygetDensityData (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_ttheData
 Grid data.
tvalarray< bool > refinedDataExists

Friends

class GridIterator
class Regridder
class Integrator
class AMRCore
class PDE::FiniteIntegral


Detailed Description

1 dimensional grid for the adaptive mesh refinement algorithm.

Version:
0.5, 05/13/2009
Author:
Peter Csizmadia

Constructor & Destructor Documentation

gridripper::amr1d::Grid::Grid ( const Grid g  )  [protected]

Copy constructor.

All fields are copied except those of class Grid.

Parameters:
g the grid to copy
See also:
copy(Grid, HashMap<Grid, Grid>)

gridripper::amr1d::Grid::Grid ( const Grid p,
GReal_t  xshift 
) [protected]

Creates a temporary grid.

Parameters:
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.

Parameters:
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


Member Function Documentation

void gridripper::amr1d::Grid::copy ( Grid orig,
map< Grid *, Grid * > &  gridmap 
) [protected]

Copy fields of class Grid.

Parameters:
orig the original Grid
gridmap old-to-new grid map

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.

Parameters:
i the index
Returns:
the internal array 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.

Parameters:
i the index
Returns:
the real index

virtual Grid* gridripper::amr1d::Grid::createRefinedGrid ( IntervalList iv,
int  margin,
int  vmargin,
int  minLevel,
int  r1 
) [protected, pure virtual]

Creates a refined grid.

Parameters:
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.

Parameters:
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.

Parameters:
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.

Parameters:
pf nonzero values in this array indicate the need of refinement
Returns:
the index

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.

Parameters:
pf nonzero values in this array indicate the need of refinement
i the left edge index
Returns:
the right 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.

Parameters:
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)
Returns:
the new location of the sub-subgrid relative to its new parent

Implemented in gridripper::amr1d::BoundedGrid.

virtual Grid* gridripper::amr1d::Grid::cloneGrid (  )  const [pure virtual]

Clones this grid.

Returns:
the clone

Implemented in gridripper::amr1d::BoundedGrid.

virtual GReal_t gridripper::amr1d::Grid::getSizeX (  )  const [pure virtual]

Gets the grid width.

Returns:
the grid width

Implemented in gridripper::amr1d::BoundedGrid.

virtual GReal_t gridripper::amr1d::Grid::getLocationX ( int  i  )  const [pure virtual]

Gets the location of the point with index i.

Parameters:
i the point index

Implemented in gridripper::amr1d::BoundedGrid.

int gridripper::amr1d::Grid::getNumComponents (  )  const [inline]

Gets the number of components of the field.

Returns:
the number of components

int gridripper::amr1d::Grid::getRefinementRatio (  )  const [inline]

Gets the refinement ratio.

Returns:
the refinement ratio

virtual int gridripper::amr1d::Grid::getMarginLeft ( int  ir  )  const [pure virtual]

Gets the left margin size.

Parameters:
ir step count
Returns:
the margin size

Implemented in gridripper::amr1d::BoundedGrid.

virtual int gridripper::amr1d::Grid::getMarginRight ( int  ir  )  const [pure virtual]

Gets the right margin size.

Parameters:
ir step count
Returns:
the margin size

Implemented in gridripper::amr1d::BoundedGrid.

int gridripper::amr1d::Grid::getMaxI (  )  const [inline]

Gets the maximum grid index.

Returns:
the maximum index

virtual int gridripper::amr1d::Grid::getNumPointsAboveMaxX (  )  const [inline, virtual]

Gets number of grid points above infinity (Xmax).

Returns:
0 in the default implementation

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.

Returns:
the level

Grid* gridripper::amr1d::Grid::getParent (  )  const [inline]

Gets the parent grid.

Returns:
the parent grid

Grid* gridripper::amr1d::Grid::getOffspring (  )  const [inline]

Gets the first offspring.

Returns:
the offspring grid

Grid* gridripper::amr1d::Grid::getNextSibling (  )  const [inline]

Gets the sibling grid.

Returns:
the sibling grid

virtual int gridripper::amr1d::Grid::distanceFromLeft ( int  i  )  const [pure virtual]

Gets the distance from the left edge.

Parameters:
i grid point index
Returns:
the distance (positive or 0), negative number if the point outside the grid

Implemented in gridripper::amr1d::BoundedGrid.

virtual int gridripper::amr1d::Grid::distanceFromRight ( int  i  )  const [pure virtual]

Gets the distance from the right edge.

Parameters:
i grid point index
Returns:
the distance (positive or 0), negative number if the point outside the grid

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.

Parameters:
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.

Parameters:
i the grid point index
Returns:
the energy flow

GReal_t gridripper::amr1d::Grid::getEnergyLoss ( int  i  )  const [inline]

Gets the integrated energy flow in a grid point.

Parameters:
i the grid point index
Returns:
the energy loss

void gridripper::amr1d::Grid::addTo ( int  i,
GReal_t  v[] 
) const [inline]

Add field values to the components of an array.

Parameters:
i grid point index
v target array

void gridripper::amr1d::Grid::addMultipliedTo ( int  i,
GReal_t  c,
GReal_t  v[] 
) const [inline]

Add field values multiplied by a scalar to the components of an array.

Parameters:
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.

Parameters:
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.

Parameters:
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.

Parameters:
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.

Parameters:
i grid point index
k the field component index
Returns:
the field component value

int gridripper::amr1d::Grid::getRefinedMaxI (  )  const [inline]

Gets the maximum index on refined grid.

Returns:
the maximum refined grid point index

virtual bool gridripper::amr1d::Grid::hasRefinedData ( int  i  )  const [pure virtual]

Tests whether refined data at the specified index exists or not.

Parameters:
i refined grid index
Returns:
true if exists, false if not

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.

Parameters:
i start index on refined grid
n number of refined grid points to test
Returns:
integer with its k-th bit set if refined data exists at refined grid point i + k

const Grid* gridripper::amr1d::Grid::getSubgridAt ( int  i  )  const [inline]

Gets the refined data at the specified grid point if exists.

Parameters:
i refined grid index
yout the output array

const Grid* gridripper::amr1d::Grid::getFinestSubgridAt ( GReal_t  x  )  const

Gets the finest subgrid at the specified location.

Parameters:
x the location
Returns:
the finest subgrid

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.

Parameters:
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.

Returns:
true if there are such flagged points, false otherwise

void gridripper::amr1d::Grid::setTemporaryGridShift ( const Grid p,
GReal_t  xshift 
) [inline]

Sets the shift for a temporary grid.

Parameters:
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.

Parameters:
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  ) 

Flag points where error is larger than critical.

Parameters:
critical the critical error value

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.

Parameters:
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
Returns:
the number of subgrids generated

virtual void gridripper::amr1d::Grid::fillRefinedDataArray (  )  [protected, pure virtual]

Fills the refinedData array.

Should only be called after interpolateMargins!

Implemented in gridripper::amr1d::BoundedGrid.


Member Data Documentation

Grid data.


The documentation for this class was generated from the following file:

Generated on Wed Jun 17 18:46:51 2009 for GridRipper by  doxygen 1.5.6