gridripper::amr1d::Grid Class Reference

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

Inheritance diagram for gridripper::amr1d::Grid:

gridripper::amr1d::BoundedGrid gridripper::amr1d::PeriodicGrid

List of all members.

Public Member Functions

abstract Grid cloneGrid ()
 Clones this grid.
abstract GridGeomInfo getGeomInfo ()
final double getBaseMinX ()
final double getBaseMaxX ()
final double getLocationX ()
 Gets the location of the point with index 0.
GridIterator getXIterator ()
abstract double getSizeX ()
 Gets the grid width.
abstract int getLeftmostI ()
abstract int getRightmostI ()
abstract boolean isPeriodic ()
abstract double getLocationX (int i)
 Gets the location of the point with index i.
final int getIndexFromX (double x, double maxerr) throws IllegalArgumentException
final int getLocationI ()
 Gets the location of the origin relative to the parent grid's origin.
final double getDeltaX ()
final void setTime (double t)
final double getTime ()
final void setTimeStepCount (int tsc)
final int getTimeStepCount ()
final int getLastErrorCheckTime ()
final int getNumComponents ()
 Gets the number of components of the field.
final int getRefinementRatio ()
 Gets the refinement ratio.
abstract int getMarginLeft (int ir)
 Gets the left margin size.
abstract int getMarginRight (int ir)
 Gets the right margin size.
final int getMaxI ()
 Gets the maximum grid index.
int getNumPointsAboveMaxX ()
 Gets number of grid points above infinity (Xmax).
final int getLevel ()
 Gets the level in the tree.
final Grid getParent ()
 Gets the parent grid.
final Grid getOffspring ()
 Gets the first offspring.
final Grid getNextSibling ()
 Gets the sibling grid.
final boolean containsLeftBound ()
final boolean containsRightBound ()
abstract int distanceFromLeft (int i)
 Gets the distance from the left edge.
abstract int distanceFromRight (int i)
 Gets the distance from the right edge.
final int getAbsoluteIndex (int i)
final void getField (int i, FieldWrapper f)
 Gets the field value at the specified grid point.
final void get (int i, double[] v)
 Gets the field value at the specified grid point.
final void setEnergyLosses (double[] e, PDE pde)
final double getEnergyFlow (int i)
 Gets the energy flow in a grid point.
final double getEnergyLoss (int i)
 Gets the integrated energy flow in a grid point.
final void addTo (int i, double[] v)
 Add field values to the components of an array.
final void addMultipliedTo (int i, double c, double[] v)
 Add field values multiplied by a scalar to the components of an array.
final void addMultipliedTo (int i, int exclude, double c, double[] arr, double[] v)
 Add field values multiplied by a scalar to the components of an array.
final void get (int i, double[] v, int off)
 Gets the field value at the specified grid point.
final void set (int i, double[] v)
 Sets the field value at the specified grid point.
final double getComponent (int i, int k)
 Gets a field component at the specified grid point.
abstract void initRefinedDataExistenceArray ()
 Initializes the refinedDataExists array.
int getRefinedMaxI ()
 Gets the maximum index on refined grid.
abstract boolean hasRefinedData (int i)
 Tests whether refined data at the specified index exists or not.
final int getRefinedDataExistence (int i, int n, PDE pde)
 Tests the existence of refined data at the specified indices.
Grid getSubgridAt (int i)
 Gets the refined data at the specified grid point if exists.
Grid getFinestSubgridAt (double x)
 Gets the finest subgrid at the specified location.
abstract void getRefinedData (int i, double[] yout)
 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)
final boolean hasUncoveredFlaggedPoint (int margin)
 Checks if there exists any flagged point which is not covered by a refined subgrid.
abstract Grid createTemporaryGrid (int dmargin_L, int dmargin_R, double xshift)
final void setTemporaryGridShift (Grid p, double xshift)
 Sets the shift for a temporary grid.
abstract void setTemporaryGridMargins (Grid p, int dmargin_L, int dmargin_R)
 Sets the margins and the shift for a temporary grid.
final Integrator getIntegrator ()
 Gets the grid integrator method.
final void injectFineToCoarse (PDE pde)
 Sets this "coarse" grid's values from values on the finer subgrids.
final void checkErrors (double critical)
 Flag points where error is larger than critical.
final int generateRefinedGrids (int minLevel, int maxLevel, int numVelocity, int bufzoneradius, int thislevel, int gridi)
 Generates a list of new subgrids from the flagged points.
final void interpolateNewSubgrids (PDE pde)
 Set the new grid's initial values by interpolation.
void initConstraints (PDE pde, FieldWrapper tmp, int opts)
final boolean isEnergyLossStored ()
double[][] getDensityData (PDE.DensityQuantity q, double xmin, double xmax)
String getDataAsString ()
String toString ()
String sprintHierarchy ()
abstract void interpolateMargins (PDE pde)

Static Public Member Functions

static String toString (Grid[][] grids)

Static Public Attributes

static int LEFT_BOUND_FLAG = 1
static int RIGHT_BOUND_FLAG = 2
static final int IC_CONSTR_MASK = 3
 Constraints mask in options.
static final int IC_CONSTR_NONE = 0
 Constraints are not applied in the points of the new subgrid.
static final int IC_CONSTR_INTERPOLATED_ONLY = 1
 Constraints are applied in the interpolated points of the new subgrid.
static final int IC_CONSTR_ALL = 2
 Constraints are applied in all points of the new subgrid.

Protected Member Functions

 Grid (Grid g)
 Copy constructor.
 Grid (double minx, double maxx, int maxi, int nc, Regridder refproto, int r, double dx)
 Creates a base grid.
 Grid (Grid p, double 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, HashMap< Grid, Grid > gridmap)
 Copy fields of class Grid.
abstract int getAbsoluteIndex (int i, int mul)
abstract int getInternalIndex (int i)
 Gets the internal array index.
int getRealIndex (int i)
 Gets the "real" index.
abstract int getSubgridIndexFromIndex (Grid g, int i)
abstract int getIndexFromSubgridIndex (Grid g, int i)
abstract void fillRefinedDataArray ()
 Fills the refinedData array.
abstract Grid createRefinedGrid (IntervalList iv, int margin, int vmargin, int minLevel, int r1)
 Creates a refined grid.
final void init (Integrator proto, Sigma sigma, int n)
 Initialization of the integrator and the field data array.
void initConstraints (PDE pde, int left, int right, FieldWrapper tmp, int opts)
final void initEnergyLoss (PDE pde)
final void updateEnergyLoss (PDE pde, int j, Grid baseg, int jbase, double epsilon)
abstract void blur (byte[] pf, int i)
 Both neighbors of points with the specified value in an array are set to value plus 1.
abstract int getFirstIndexForRefinement (byte[] pf)
 Gets the first point to start refinement interval searching.
abstract int findIntervalEndForRefinement (byte[] pf, int i)
 Finds the right edge of an interval that needs refinement.
abstract int intervalRefinedSize (IntervalList iv, int r)
abstract int gridIndexLeftOf (int i, int dmax)
abstract int gridIndexRightOf (int i, int dmax)
abstract void fixSubgridNearBounds (IntervalList l, IntervalList r, int margin)
abstract int calcNewSubSubgridLocation (int ssloc, int osloc, int nsloc)
 Calculates the new location of a sub-subgrid (relative to the parent) if its parent (a subgrid) changed.

Protected Attributes

int flags = 0
double[] theData
 Grid data.
boolean[] refinedDataExists = null

Package Attributes

int timeStepCount = 0
 Number of time steps performed.

Classes

interface  Interpolator
 Interpolates margin points using values from the parent grid. More...


Detailed Description

1 dimensional grid for the adaptive mesh refinement algorithm.

Version:
0.5, 06/12/2009
Author:
Peter Csizmadia

Constructor & Destructor Documentation

gridripper::amr1d::Grid::Grid ( Grid  g  )  [inline, 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 ( Grid  p,
double  xshift 
) [inline, 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 
) [inline, 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,
HashMap< Grid, Grid gridmap 
) [inline, protected]

Copy fields of class Grid.

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

abstract Grid gridripper::amr1d::Grid::cloneGrid (  )  [pure virtual]

Clones this grid.

Returns:
the clone

Implemented in gridripper::amr1d::BoundedGrid, and gridripper::amr1d::PeriodicGrid.

abstract double gridripper::amr1d::Grid::getSizeX (  )  [pure virtual]

Gets the grid width.

Returns:
the grid width

Implemented in gridripper::amr1d::BoundedGrid, and gridripper::amr1d::PeriodicGrid.

abstract double gridripper::amr1d::Grid::getLocationX ( int  i  )  [pure virtual]

Gets the location of the point with index i.

Parameters:
i the point index

Implemented in gridripper::amr1d::BoundedGrid, and gridripper::amr1d::PeriodicGrid.

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

Gets the number of components of the field.

Returns:
the number of components

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

Gets the refinement ratio.

Returns:
the refinement ratio

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

Gets the left margin size.

Parameters:
ir step count
Returns:
the margin size

Implemented in gridripper::amr1d::BoundedGrid, and gridripper::amr1d::PeriodicGrid.

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

Gets the right margin size.

Parameters:
ir step count
Returns:
the margin size

Implemented in gridripper::amr1d::BoundedGrid, and gridripper::amr1d::PeriodicGrid.

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

Gets the maximum grid index.

Returns:
the maximum index

int gridripper::amr1d::Grid::getNumPointsAboveMaxX (  )  [inline]

Gets number of grid points above infinity (Xmax).

Returns:
0 in the default implementation

Reimplemented in gridripper::amr1d::BoundedGrid.

final int gridripper::amr1d::Grid::getLevel (  )  [inline]

Gets the level in the tree.

The base grid is at level 0.

Returns:
the level

final Grid gridripper::amr1d::Grid::getParent (  )  [inline]

Gets the parent grid.

Returns:
the parent grid

final Grid gridripper::amr1d::Grid::getOffspring (  )  [inline]

Gets the first offspring.

Returns:
the offspring grid

final Grid gridripper::amr1d::Grid::getNextSibling (  )  [inline]

Gets the sibling grid.

Returns:
the sibling grid

abstract int gridripper::amr1d::Grid::distanceFromLeft ( int  i  )  [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, and gridripper::amr1d::PeriodicGrid.

abstract int gridripper::amr1d::Grid::distanceFromRight ( int  i  )  [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, and gridripper::amr1d::PeriodicGrid.

abstract int gridripper::amr1d::Grid::getInternalIndex ( int  i  )  [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, and gridripper::amr1d::PeriodicGrid.

int gridripper::amr1d::Grid::getRealIndex ( int  i  )  [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

Reimplemented in gridripper::amr1d::PeriodicGrid.

final void gridripper::amr1d::Grid::getField ( int  i,
FieldWrapper  f 
) [inline]

Gets the field value at the specified grid point.

Parameters:
i grid point index
v put the field values into this array

final void gridripper::amr1d::Grid::get ( int  i,
double[]  v 
) [inline]

Gets the field value at the specified grid point.

Parameters:
i grid point index
v put the field values into this array

final double gridripper::amr1d::Grid::getEnergyFlow ( int  i  )  [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

final double gridripper::amr1d::Grid::getEnergyLoss ( int  i  )  [inline]

Gets the integrated energy flow in a grid point.

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

final void gridripper::amr1d::Grid::addTo ( int  i,
double[]  v 
) [inline]

Add field values to the components of an array.

Parameters:
i grid point index
v target array

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

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

Parameters:
i grid point index
c multiplier
v target array

final void gridripper::amr1d::Grid::addMultipliedTo ( int  i,
int  exclude,
double  c,
double[]  arr,
double[]  v 
) [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

final void gridripper::amr1d::Grid::get ( int  i,
double[]  v,
int  off 
) [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

final void gridripper::amr1d::Grid::set ( int  i,
double[]  v 
) [inline]

Sets the field value at the specified grid point.

Parameters:
i grid point index
v the field vector

final double gridripper::amr1d::Grid::getComponent ( int  i,
int  k 
) [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

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

Fills the refinedData array.

Should only be called after interpolateMargins!

Implemented in gridripper::amr1d::BoundedGrid, and gridripper::amr1d::PeriodicGrid.

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

Gets the maximum index on refined grid.

Returns:
the maximum refined grid point index

abstract boolean gridripper::amr1d::Grid::hasRefinedData ( int  i  )  [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, and gridripper::amr1d::PeriodicGrid.

final int gridripper::amr1d::Grid::getRefinedDataExistence ( int  i,
int  n,
PDE  pde 
) [inline]

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

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

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

Parameters:
i refined grid index
yout the output array

Grid gridripper::amr1d::Grid::getFinestSubgridAt ( double  x  )  [inline]

Gets the finest subgrid at the specified location.

Parameters:
x the location
Returns:
the finest subgrid

abstract void gridripper::amr1d::Grid::getRefinedData ( int  i,
double[]  yout 
) [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, and gridripper::amr1d::PeriodicGrid.

void gridripper::amr1d::Grid::setZero (  )  [inline]

Sets all the grid values to zero.

final boolean gridripper::amr1d::Grid::hasUncoveredFlaggedPoint ( int  margin  )  [inline]

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

final void gridripper::amr1d::Grid::setTemporaryGridShift ( Grid  p,
double  xshift 
) [inline]

Sets the shift for a temporary grid.

Parameters:
p the parent grid
xshift the shift

abstract void gridripper::amr1d::Grid::setTemporaryGridMargins ( 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, and gridripper::amr1d::PeriodicGrid.

abstract 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, and gridripper::amr1d::PeriodicGrid.

final void gridripper::amr1d::Grid::init ( Integrator  proto,
Sigma  sigma,
int  n 
) [inline, protected]

Initialization of the integrator and the field data array.

Parameters:
proto integrator prototype
sigma the dissipation term multiplier
n total grid size

final Integrator gridripper::amr1d::Grid::getIntegrator (  )  [inline]

Gets the grid integrator method.

final void gridripper::amr1d::Grid::injectFineToCoarse ( PDE  pde  )  [inline]

Sets this "coarse" grid's values from values on the finer subgrids.

final void gridripper::amr1d::Grid::checkErrors ( double  critical  )  [inline]

Flag points where error is larger than critical.

Parameters:
critical the critical error value

final int gridripper::amr1d::Grid::generateRefinedGrids ( int  minLevel,
int  maxLevel,
int  numVelocity,
int  bufzoneradius,
int  thislevel,
int  gridi 
) [inline]

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

abstract void gridripper::amr1d::Grid::blur ( byte[]  pf,
int  i 
) [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, and gridripper::amr1d::PeriodicGrid.

abstract int gridripper::amr1d::Grid::getFirstIndexForRefinement ( byte[]  pf  )  [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, and gridripper::amr1d::PeriodicGrid.

abstract int gridripper::amr1d::Grid::findIntervalEndForRefinement ( byte[]  pf,
int  i 
) [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, and gridripper::amr1d::PeriodicGrid.

abstract 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, and gridripper::amr1d::PeriodicGrid.


Member Data Documentation

Constraints mask in options.

Constraints are not applied in the points of the new subgrid.

Constraints are applied in the interpolated points of the new subgrid.

Constraints are applied in all points of the new subgrid.

double [] gridripper::amr1d::Grid::theData [protected]

Grid data.

Number of time steps performed.


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

Generated on Wed Jun 17 18:47:25 2009 for GridRipper by  doxygen 1.5.6