SG++
sgpp::pde::PDESolver Class Referenceabstract

This class provides defines a implements basic task and tools which are useful while solving PDEs. More...

#include <PDESolver.hpp>

Inheritance diagram for sgpp::pde::PDESolver:
sgpp::pde::EllipticPDESolver sgpp::pde::ParabolicPDESolver sgpp::pde::PoissonEquationSolver sgpp::pde::HeatEquationSolver sgpp::pde::HeatEquationSolverWithStretching

Public Member Functions

void coarsenInitialGridSurplus (sgpp::base::DataVector &alpha, double dThreshold)
 Coarsens a grid by taking the grid's coefficients into account. More...
 
virtual void constructGrid (sgpp::base::BoundingBox &myBoundingBox, size_t level)=0
 Use this routine the construct a regular grid to solve a PDE. More...
 
void deleteGrid ()
 deletes the grid created within that solver More...
 
void evaluateCuboid (sgpp::base::DataVector &alpha, sgpp::base::DataVector &FunctionValues, sgpp::base::DataMatrix &EvaluationPoints)
 Evaluates the sparse grid's function given by the stored grid and the alpha coefficients. More...
 
double evaluatePoint (sgpp::base::DataVector &evalPoint, sgpp::base::DataVector &alpha)
 Determines the value of the function in the d-dimensional space. More...
 
std::string getGrid () const
 gets the a string the describes the grid which is currently used to solve More...
 
size_t getNumberDimensions () const
 use this the determine the number of dimensions that are currently used in the solver. More...
 
size_t getNumberGridPoints () const
 use this to determine the number of grid points, used to solve the current problem More...
 
size_t getNumberInnerGridPoints () const
 use this to determine the number of inner grid points, used to solve the current problem More...
 
 PDESolver ()
 Std-Constructor of the solver. More...
 
virtual void printGrid (sgpp::base::DataVector &alpha, size_t PointesPerDimension, std::string tfilename) const
 This is some kind of debug functionality. More...
 
virtual void printGridDomain (sgpp::base::DataVector &alpha, size_t PointesPerDimension, sgpp::base::BoundingBox &GridArea, std::string tfilename) const
 This is some kind of debug functionality. More...
 
virtual void printLevelIndexGrid (std::string tfilename) const
 Prints the level,index pairs of the grid for each Gridpoint to a file. More...
 
virtual void printSparseGrid (sgpp::base::DataVector &alpha, std::string tfilename, bool bSurplus) const
 Prints the sgpp::base::Grid Points of the Sparse sgpp::base::Grid either with their node basis value or their hierarchical surplus. More...
 
virtual void printSparseGridExpTransform (sgpp::base::DataVector &alpha, std::string tfilename, bool bSurplus) const
 Prints the sgpp::base::Grid Points of the Sparse sgpp::base::Grid either with their node basis value or their hierarchical surplus. More...
 
void refineInitialGridSurplus (sgpp::base::DataVector &alpha, int numRefinePoints, double dThreshold)
 Refines a grid by taking the grid's coefficients into account. More...
 
void refineInitialGridSurplusSubDomain (sgpp::base::DataVector &alpha, int numRefinePoints, double dThreshold, std::vector< double > &norm_mu, std::vector< double > &norm_sigma)
 Refines a grid by taking the grid's coefficients into account. More...
 
void refineInitialGridSurplusToMaxLevel (sgpp::base::DataVector &alpha, double dThreshold, sgpp::base::level_t maxLevel)
 Refines a grid by taking the grid's coefficients into account. More...
 
void refineInitialGridSurplusToMaxLevelSubDomain (sgpp::base::DataVector &alpha, double dThreshold, sgpp::base::level_t maxLevel, std::vector< double > &norm_mu, std::vector< double > &norm_sigma)
 Refines a grid by taking the grid's coefficients into account. More...
 
void setGrid (const std::string &serializedGrid)
 Sets the grid used in this BlackScholes Solver by an given serialized string of the grid. More...
 
virtual ~PDESolver ()
 Std-Destructor of the solver. More...
 

Protected Member Functions

virtual void getGridNormalDistribution (sgpp::base::DataVector &alpha, std::vector< double > &norm_mu, std::vector< double > &norm_sigma)
 This function calculates for every grid point the value of a normal distribution given by norm_mu and norm_sigma. More...
 

Protected Attributes

bool bGridConstructed
 stores if the grid was created inside the solver More...
 
size_t dim
 the dimension of the grid More...
 
int levels
 the number of levels used for an regular grid More...
 
sgpp::base::BoundingBoxmyBoundingBox
 Stores Pointer to the sgpp::base::Grid's Bounding Box. More...
 
sgpp::base::GridmyGrid
 The Sparse sgpp::base::Grid needed in this classificator. More...
 
sgpp::base::GridStoragemyGridStorage
 Stores Pointer to the Girs's Storage. More...
 

Detailed Description

This class provides defines a implements basic task and tools which are useful while solving PDEs.

E.g. grid construction, simple grid evaluation tools grid printing, initial grid refinement etc.

Constructor & Destructor Documentation

sgpp::pde::PDESolver::PDESolver ( )

Std-Constructor of the solver.

References bGridConstructed.

sgpp::pde::PDESolver::~PDESolver ( )
virtual

Std-Destructor of the solver.

References bGridConstructed, and myGrid.

Member Function Documentation

void sgpp::pde::PDESolver::coarsenInitialGridSurplus ( sgpp::base::DataVector alpha,
double  dThreshold 
)

Coarsens a grid by taking the grid's coefficients into account.

This coarsen method coarsens the grid based on the surplus by coarsening grid points with small surpluses first.

Parameters
alphaa sgpp::base::DataVector containing the grids coefficients
dThresholdThreshold for a point's surplus for coarsening this point

References bGridConstructed, sgpp::base::GridGenerator::coarsenNFirstOnly(), sgpp::base::Grid::getGenerator(), sgpp::base::GridGenerator::getNumberOfRemovablePoints(), sgpp::base::Grid::getSize(), and myGrid.

virtual void sgpp::pde::PDESolver::constructGrid ( sgpp::base::BoundingBox myBoundingBox,
size_t  level 
)
pure virtual

Use this routine the construct a regular grid to solve a PDE.

Parameters
myBoundingBoxreference to a bounding box that describes the grid
levelnumber of the regular's grid levels

Implemented in sgpp::pde::HeatEquationSolverWithStretching, sgpp::pde::HeatEquationSolver, and sgpp::pde::PoissonEquationSolver.

void sgpp::pde::PDESolver::deleteGrid ( )

deletes the grid created within that solver

References bGridConstructed, myBoundingBox, myGrid, and myGridStorage.

void sgpp::pde::PDESolver::evaluateCuboid ( sgpp::base::DataVector alpha,
sgpp::base::DataVector FunctionValues,
sgpp::base::DataMatrix EvaluationPoints 
)

Evaluates the sparse grid's function given by the stored grid and the alpha coefficients.

on different points specified in EvaluationPoints and stores the result into FunctionValues.

Parameters
alphathe sparse grid's coefficients
FunctionValuessgpp::base::DataVector into the which the result of function's evaluation is stored
EvaluationPointssgpp::base::DataMatrix that contains the points at which the sparse grid's function is evaluated

References bGridConstructed, sgpp::op_factory::createOperationMultipleEval(), sgpp::base::DataMatrix::getNrows(), sgpp::base::DataVector::getSize(), and myGrid.

double sgpp::pde::PDESolver::evaluatePoint ( sgpp::base::DataVector evalPoint,
sgpp::base::DataVector alpha 
)

Determines the value of the function in the d-dimensional space.

Parameters
evalPointcoordinates of the point at which the function should be evaluated
alphathe ansatzfunctions' coefficients
Returns
price of option for given point

References bGridConstructed, sgpp::op_factory::createOperationEval(), and sgpp::base::OperationEval::eval().

std::string sgpp::pde::PDESolver::getGrid ( ) const

gets the a string the describes the grid which is currently used to solve

Returns
a string containing a serialized grid

References bGridConstructed, myGrid, and sgpp::base::Grid::serialize().

void sgpp::pde::PDESolver::getGridNormalDistribution ( sgpp::base::DataVector alpha,
std::vector< double > &  norm_mu,
std::vector< double > &  norm_sigma 
)
protectedvirtual

This function calculates for every grid point the value of a normal distribution given by norm_mu and norm_sigma.

The result is stored dehierarchized in alpha.

Parameters
alphacontains dehierarchized sparse grid coefficients containing the values of the multi dimensional normal distribution after call
norm_muthe expected values of the normal distribution for every grid dimension
norm_sigmathe standard deviation of the normal distribution for every grid dimension

References bGridConstructed, dim, sgpp::base::HashGridStorage::getCoordinates(), sgpp::base::StdNormalDistribution::getDensity(), sgpp::base::HashGridStorage::getPoint(), sgpp::base::Grid::getSize(), myGrid, myGridStorage, and analyse_erg::tmp.

Referenced by refineInitialGridSurplusSubDomain(), and refineInitialGridSurplusToMaxLevelSubDomain().

size_t sgpp::pde::PDESolver::getNumberDimensions ( ) const

use this the determine the number of dimensions that are currently used in the solver.

Returns
returns the number of the grid's dimensions, if the grid isn't constructed, yet it returns 0

References bGridConstructed, sgpp::base::HashGridStorage::getDimension(), and myGridStorage.

size_t sgpp::pde::PDESolver::getNumberGridPoints ( ) const

use this to determine the number of grid points, used to solve the current problem

Returns
the number of grid points

References bGridConstructed, sgpp::base::HashGridStorage::getSize(), and myGridStorage.

size_t sgpp::pde::PDESolver::getNumberInnerGridPoints ( ) const

use this to determine the number of inner grid points, used to solve the current problem

Returns
the number of inner grid points

References bGridConstructed, sgpp::base::HashGridStorage::getNumberOfInnerPoints(), and myGridStorage.

void sgpp::pde::PDESolver::printGrid ( sgpp::base::DataVector alpha,
size_t  PointesPerDimension,
std::string  tfilename 
) const
virtual

This is some kind of debug functionality.

It writes a file, that can be used with gnuplot the print the grid.

Is only implemented for 1D and 2D grids!

Parameters
alphathe coefficients of the Sparse Gird's basis functions
PointesPerDimensionthe distance between evaluation points
tfilenameabsolute path to file into which the grid's evaluation is written

Reimplemented in sgpp::pde::HeatEquationSolverWithStretching.

References myGrid, and sgpp::base::GridPrinter::printGrid().

void sgpp::pde::PDESolver::printGridDomain ( sgpp::base::DataVector alpha,
size_t  PointesPerDimension,
sgpp::base::BoundingBox GridArea,
std::string  tfilename 
) const
virtual

This is some kind of debug functionality.

It writes a file, that can be used with gnuplot the print the grid.

Is only implemented for 2D grids!

Parameters
alphathe coefficients of the Sparse Gird's basis functions
PointesPerDimensionthe distance between evaluation points
GridAreathe area in which the function should be plotted
tfilenameabsolute path to file into which the grid's evaluation is written

Reimplemented in sgpp::pde::HeatEquationSolverWithStretching.

References myGrid, and sgpp::base::GridPrinter::printGridDomain().

void sgpp::pde::PDESolver::printLevelIndexGrid ( std::string  tfilename) const
virtual

Prints the level,index pairs of the grid for each Gridpoint to a file.

Parameters
tfilenamerelative path to file into which the grid's evaluation is written

References myGrid, and sgpp::base::GridPrinter::printLevelIndexGrid().

void sgpp::pde::PDESolver::printSparseGrid ( sgpp::base::DataVector alpha,
std::string  tfilename,
bool  bSurplus 
) const
virtual

Prints the sgpp::base::Grid Points of the Sparse sgpp::base::Grid either with their node basis value or their hierarchical surplus.

This function is available for all dimensions

Parameters
alphathe coefficients of the grid's ansatzfunctions
tfilenameabsoulte path to the file the grid is written into
bSurplusspecifies whether the surplus (true) or the node basis value (false) is written

Reimplemented in sgpp::pde::HeatEquationSolverWithStretching.

References myGrid, and sgpp::base::GridPrinter::printSparseGrid().

void sgpp::pde::PDESolver::printSparseGridExpTransform ( sgpp::base::DataVector alpha,
std::string  tfilename,
bool  bSurplus 
) const
virtual

Prints the sgpp::base::Grid Points of the Sparse sgpp::base::Grid either with their node basis value or their hierarchical surplus.

This function is available for all dimensions.

The coordinates of the grid points are pushed the exp function. So log transformed grids can be plotted in cartesion coordinates.

Parameters
alphathe coefficients of the grid's ansatzfunctions
tfilenameabsoulte path to the file the grid is written into
bSurplusspecifies whether the surplus (true) or the node basis value (false) is written

Reimplemented in sgpp::pde::HeatEquationSolverWithStretching.

References myGrid, and sgpp::base::GridPrinter::printSparseGridExpTransform().

void sgpp::pde::PDESolver::refineInitialGridSurplus ( sgpp::base::DataVector alpha,
int  numRefinePoints,
double  dThreshold 
)

Refines a grid by taking the grid's coefficients into account.

This refinement method refines the grid based on the surplus by refining grid points with big surpluses first. The number of grid points to refine may be specified by the numRefinePoints parameter.

Parameters
alphaa sgpp::base::DataVector containing the grids coefficients
numRefinePointsthe number of grid points that should be refined; if this smaller than zero -> all refineable points will be refined
dThresholdThreshold for a point's surplus for refining this point

References bGridConstructed, sgpp::base::Grid::getGenerator(), sgpp::base::GridGenerator::getNumberOfRefinablePoints(), sgpp::base::HashGridStorage::getSize(), myGrid, myGridStorage, and sgpp::base::GridGenerator::refine().

void sgpp::pde::PDESolver::refineInitialGridSurplusSubDomain ( sgpp::base::DataVector alpha,
int  numRefinePoints,
double  dThreshold,
std::vector< double > &  norm_mu,
std::vector< double > &  norm_sigma 
)

Refines a grid by taking the grid's coefficients into account.

This refinement method refines the grid based on the surplus by refining grid points with big surpluses first. The number of grid points to refine may be specified by the numRefinePoints parameter.

This functions refines the grid only in subdomain specified by a multi-dimensional normal distribution. The normal distribution is given by the parameters norm_mu and norm_sigma which are d-dimensional vectors.

Parameters
alphaa sgpp::base::DataVector containing the grids coefficients
numRefinePointsthe number of grid points that should be refined; if this smaller than zero -> all refineable points will be refined
dThresholdThreshold for a point's surplus for refining this point
norm_muthe expected values of the normal distribution for every grid dimension
norm_sigmathe standard deviation of the normal distribution for every grid dimension

References bGridConstructed, sgpp::base::Grid::getGenerator(), getGridNormalDistribution(), sgpp::base::GridGenerator::getNumberOfRefinablePoints(), sgpp::base::HashGridStorage::getSize(), sgpp::base::DataVector::getSize(), myGrid, myGridStorage, and sgpp::base::GridGenerator::refine().

void sgpp::pde::PDESolver::refineInitialGridSurplusToMaxLevel ( sgpp::base::DataVector alpha,
double  dThreshold,
sgpp::base::level_t  maxLevel 
)

Refines a grid by taking the grid's coefficients into account.

This refinement method refines the grid based on the surplus by refining grid points with big surpluses first. The grid is refined to max. Level!

Parameters
alphaa sgpp::base::DataVector containing the grids coefficients
dThresholdThreshold for a point's surplus for refining this point
maxLevelmaxLevel of refinement

References bGridConstructed, sgpp::base::Grid::getGenerator(), sgpp::base::GridGenerator::getNumberOfRefinablePointsToMaxLevel(), sgpp::base::HashGridStorage::getSize(), myGrid, myGridStorage, and sgpp::base::GridGenerator::refineMaxLevel().

void sgpp::pde::PDESolver::refineInitialGridSurplusToMaxLevelSubDomain ( sgpp::base::DataVector alpha,
double  dThreshold,
sgpp::base::level_t  maxLevel,
std::vector< double > &  norm_mu,
std::vector< double > &  norm_sigma 
)

Refines a grid by taking the grid's coefficients into account.

This refinement method refines the grid based on the surplus by refining grid points with big surpluses first. The grid is refined to max. Level!

This functions refines the grid only in subdomain specified by a multi-dimensional normal distribution. The normal distribution is given by the parameters norm_mu and norm_sigma which are d-dimensional vectors.

Parameters
alphaa sgpp::base::DataVector containing the grids coefficients
dThresholdThreshold for a point's surplus for refining this point
maxLevelmaxLevel of refinement
norm_muthe expected values of the normal distribution for every grid dimension
norm_sigmathe standard deviation of the normal distribution for every grid dimension

References bGridConstructed, sgpp::base::Grid::getGenerator(), getGridNormalDistribution(), sgpp::base::GridGenerator::getNumberOfRefinablePointsToMaxLevel(), sgpp::base::HashGridStorage::getSize(), sgpp::base::DataVector::getSize(), myGrid, myGridStorage, and sgpp::base::GridGenerator::refineMaxLevel().

void sgpp::pde::PDESolver::setGrid ( const std::string &  serializedGrid)

Sets the grid used in this BlackScholes Solver by an given serialized string of the grid.

Parameters
serializedGrida string that describes the grid that should be used in this solver

References bGridConstructed, dim, sgpp::base::Grid::getBoundingBox(), sgpp::base::Grid::getDimension(), sgpp::base::Grid::getStorage(), levels, myBoundingBox, myGrid, myGridStorage, and sgpp::base::Grid::unserialize().

Member Data Documentation

bool sgpp::pde::PDESolver::bGridConstructed
protected

stores if the grid was created inside the solver

Referenced by coarsenInitialGridSurplus(), sgpp::pde::PoissonEquationSolver::constructGrid(), sgpp::pde::HeatEquationSolver::constructGrid(), sgpp::pde::HeatEquationSolverWithStretching::constructGrid(), deleteGrid(), evaluateCuboid(), evaluatePoint(), getGrid(), getGridNormalDistribution(), getNumberDimensions(), getNumberGridPoints(), getNumberInnerGridPoints(), sgpp::pde::HeatEquationSolver::HeatEquationSolver(), sgpp::pde::HeatEquationSolverWithStretching::HeatEquationSolverWithStretching(), sgpp::pde::PoissonEquationSolver::initGridWithExpHeat(), sgpp::pde::PoissonEquationSolver::initGridWithExpHeatFullDomain(), sgpp::pde::PoissonEquationSolver::initGridWithSmoothHeat(), sgpp::pde::HeatEquationSolver::initGridWithSmoothHeat(), sgpp::pde::HeatEquationSolverWithStretching::initGridWithSmoothHeat(), sgpp::pde::PoissonEquationSolver::initGridWithSmoothHeatFullDomain(), PDESolver(), sgpp::pde::PoissonEquationSolver::PoissonEquationSolver(), refineInitialGridSurplus(), refineInitialGridSurplusSubDomain(), refineInitialGridSurplusToMaxLevel(), refineInitialGridSurplusToMaxLevelSubDomain(), setGrid(), sgpp::pde::HeatEquationSolver::solveCrankNicolson(), sgpp::pde::HeatEquationSolverWithStretching::solveCrankNicolson(), sgpp::pde::HeatEquationSolver::solveExplicitEuler(), sgpp::pde::HeatEquationSolverWithStretching::solveExplicitEuler(), sgpp::pde::HeatEquationSolver::solveImplicitEuler(), sgpp::pde::HeatEquationSolverWithStretching::solveImplicitEuler(), sgpp::pde::HeatEquationSolver::storeInnerRHS(), sgpp::pde::HeatEquationSolver::storeInnerSolution(), and ~PDESolver().

int sgpp::pde::PDESolver::levels
protected
sgpp::base::Grid* sgpp::pde::PDESolver::myGrid
protected

The Sparse sgpp::base::Grid needed in this classificator.

Referenced by coarsenInitialGridSurplus(), sgpp::pde::PoissonEquationSolver::constructGrid(), sgpp::pde::HeatEquationSolver::constructGrid(), sgpp::pde::HeatEquationSolverWithStretching::constructGrid(), deleteGrid(), evaluateCuboid(), getGrid(), getGridNormalDistribution(), sgpp::pde::PoissonEquationSolver::initGridWithExpHeat(), sgpp::pde::PoissonEquationSolver::initGridWithExpHeatFullDomain(), sgpp::pde::PoissonEquationSolver::initGridWithSmoothHeat(), sgpp::pde::HeatEquationSolver::initGridWithSmoothHeat(), sgpp::pde::HeatEquationSolverWithStretching::initGridWithSmoothHeat(), sgpp::pde::PoissonEquationSolver::initGridWithSmoothHeatFullDomain(), sgpp::pde::HeatEquationSolverWithStretching::printGrid(), printGrid(), printGridDomain(), sgpp::pde::HeatEquationSolverWithStretching::printGridDomainStretching(), printLevelIndexGrid(), sgpp::pde::HeatEquationSolverWithStretching::printSparseGrid(), printSparseGrid(), sgpp::pde::HeatEquationSolverWithStretching::printSparseGridExpTransform(), printSparseGridExpTransform(), refineInitialGridSurplus(), refineInitialGridSurplusSubDomain(), refineInitialGridSurplusToMaxLevel(), refineInitialGridSurplusToMaxLevelSubDomain(), setGrid(), sgpp::pde::HeatEquationSolver::solveCrankNicolson(), sgpp::pde::HeatEquationSolverWithStretching::solveCrankNicolson(), sgpp::pde::HeatEquationSolver::solveExplicitEuler(), sgpp::pde::HeatEquationSolverWithStretching::solveExplicitEuler(), sgpp::pde::HeatEquationSolver::solveImplicitEuler(), sgpp::pde::HeatEquationSolverWithStretching::solveImplicitEuler(), sgpp::pde::PoissonEquationSolver::solvePDE(), sgpp::pde::HeatEquationSolver::storeInnerRHS(), sgpp::pde::PoissonEquationSolver::storeInnerRHS(), sgpp::pde::HeatEquationSolver::storeInnerSolution(), sgpp::pde::PoissonEquationSolver::storeInnerSolution(), and ~PDESolver().


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