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:

## 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
 alpha a sgpp::base::DataVector containing the grids coefficients dThreshold Threshold for a point's surplus for coarsening this point
 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
 myBoundingBox reference to a bounding box that describes the grid level number of the regular's grid levels
 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
 alpha the sparse grid's coefficients FunctionValues sgpp::base::DataVector into the which the result of function's evaluation is stored EvaluationPoints sgpp::base::DataMatrix that contains the points at which the sparse grid's function is evaluated
 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
 evalPoint coordinates of the point at which the function should be evaluated alpha the ansatzfunctions' coefficients
Returns
price of option for given point
 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
 alpha contains dehierarchized sparse grid coefficients containing the values of the multi dimensional normal distribution after call norm_mu the expected values of the normal distribution for every grid dimension norm_sigma the standard deviation of the normal distribution for every grid dimension
 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
 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
 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
 alpha the coefficients of the Sparse Gird's basis functions PointesPerDimension the distance between evaluation points tfilename absolute 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
 alpha the coefficients of the Sparse Gird's basis functions PointesPerDimension the distance between evaluation points GridArea the area in which the function should be plotted tfilename absolute 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
 tfilename relative 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
 alpha the coefficients of the grid's ansatzfunctions tfilename absoulte path to the file the grid is written into bSurplus specifies 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
 alpha the coefficients of the grid's ansatzfunctions tfilename absoulte path to the file the grid is written into bSurplus specifies 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
 alpha a sgpp::base::DataVector containing the grids coefficients numRefinePoints the number of grid points that should be refined; if this smaller than zero -> all refineable points will be refined dThreshold Threshold for a point's surplus for refining this point
 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
 alpha a sgpp::base::DataVector containing the grids coefficients numRefinePoints the number of grid points that should be refined; if this smaller than zero -> all refineable points will be refined dThreshold Threshold for a point's surplus for refining this point norm_mu the expected values of the normal distribution for every grid dimension norm_sigma the standard deviation of the normal distribution for every grid dimension
 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
 alpha a sgpp::base::DataVector containing the grids coefficients dThreshold Threshold for a point's surplus for refining this point maxLevel maxLevel of refinement
 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
 alpha a sgpp::base::DataVector containing the grids coefficients dThreshold Threshold for a point's surplus for refining this point maxLevel maxLevel of refinement norm_mu the expected values of the normal distribution for every grid dimension norm_sigma the standard deviation of the normal distribution for every grid dimension
 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
 serializedGrid a string that describes the grid that should be used in this solver

## Member Data Documentation

 int sgpp::pde::PDESolver::levels
protected

the number of levels used for an regular grid

 sgpp::base::BoundingBox* sgpp::pde::PDESolver::myBoundingBox
protected

Stores Pointer to the sgpp::base::Grid's Bounding Box.

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