edu.jhu.cs.cisst.algorithms.optimize.fmg.pde
Class CachingPDE

java.lang.Object
  extended by edu.jhu.cs.cisst.algorithms.optimize.fmg.pde.CachingPDE
All Implemented Interfaces:
PDE
Direct Known Subclasses:
VectorFieldDiffusion2D

public abstract class CachingPDE
extends java.lang.Object
implements PDE

An abstract class that has the same public interface as class PDE but adds caching for improved performance of classes that dervie from it.

Caching is supported for the right hand side (source term) f and for a representation of the matrix A which is allmost always needed by the methods evaluateLHS() and evaluate().

Author:
Gerald Loeffler (Gerald.Loeffler@univie.ac.at)

Constructor Summary
CachingPDE()
           
 
Method Summary
protected abstract  java.lang.Object actuallySampleMatrix(int sx, int sy, int sz, int level)
          sample the matrix A in a way that it can later be used by methods evaluate() and evaluateLHS() on a grid of the given size.
protected abstract  NoBoundaryGrid actuallySampleRHS(int sx, int sy, int sz, int level)
          sample the right hand side f on a cubic grid of the given size.
protected  java.lang.Object sampleMatrix(int sx, int sy, int sz, int level)
          a caching frontend to calculating a representation of the matrix A of the PDE for a specific grid size.
 NoBoundaryGrid sampleRHS(int sx, int sy, int sz, int level)
          implements method from PDE.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface edu.jhu.cs.cisst.algorithms.optimize.fmg.pde.PDE
evaluate, evaluateLHS, getGridSpacing, solve
 

Constructor Detail

CachingPDE

public CachingPDE()
Method Detail

sampleRHS

public NoBoundaryGrid sampleRHS(int sx,
                                int sy,
                                int sz,
                                int level)
implements method from PDE.

Sampling the right hand side f of a PDE for a given grid size (as this method does) is usually a time-consuming task. This implementation improves performance for those cases where sampleRHS() is called more than once for a specific grid size because it caches the right hand side (source term) f for every grid size. This may lead to space inefficiencies in general but not in the context of the (Full) Multigrid algorithm, where the right hand side is needed at all grid levels over and over again.

The actual calculation of the right hand side f is re-routed to method actuallySampleRHS().

Specified by:
sampleRHS in interface PDE
Parameters:
sx - the sx
sy - the sy
sz - the sz
level - the level
Returns:
the no boundary grid
See Also:
actuallySampleRHS(int, int, int, int), PDE.sampleRHS(int, int, int, int)

actuallySampleRHS

protected abstract NoBoundaryGrid actuallySampleRHS(int sx,
                                                    int sy,
                                                    int sz,
                                                    int level)
sample the right hand side f on a cubic grid of the given size.

It is not necessary to know the value of f at the boundary of the grid, so the return type of this method is of type NoBoundaryGrid. But note that the size of the grid passed to this method includes (as always) the boundary. E.g., a 65x65x65 grid would be described by a size of 65 and its interior values (the one to be set by this method) would comprise the grid elements (1,1,1) to (63,63,63). The boundary elements (where at least one index is either 0 or 64) are non-existent in a NoBoundaryGrid.

Parameters:
sx - the sx
sy - the sy
sz - the sz
level - the level
Returns:
the right hand side (source term) f sampled on a cubic grid of the given size

sampleMatrix

protected java.lang.Object sampleMatrix(int sx,
                                        int sy,
                                        int sz,
                                        int level)
a caching frontend to calculating a representation of the matrix A of the PDE for a specific grid size.

Methods evaluateLHS() and evaluate() are supposed to call this method if they need a representation of the matrix A for doing their job for a grid of a certain size.

The actual calculation of the representation of the matrix A is re-routed to method actuallySampleMatrix().

Parameters:
sx - the sx
sy - the sy
sz - the sz
level - the level
Returns:
a representation of matrix A sampled on a grid of the given size
See Also:
actuallySampleMatrix(int, int, int, int)

actuallySampleMatrix

protected abstract java.lang.Object actuallySampleMatrix(int sx,
                                                         int sy,
                                                         int sz,
                                                         int level)
sample the matrix A in a way that it can later be used by methods evaluate() and evaluateLHS() on a grid of the given size.

The implementer of this method is entirely free in choosing any suitable representation for the matrix A as long as the methods evaluate() and evaluateLHS() are able to fulfill their job when passed the output of this method later in the course of the execution of the FMG algorithm.

Parameters:
sx - the sx
sy - the sy
sz - the sz
level - the level
Returns:
a representation of matrix A sampled on a grid of the given size