SG++-Doxygen-Documentation
|
This class provides defines a implements basic task and tools which are useful while solving PDEs. More...
#include <PDESolver.hpp>
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::BoundingBox * | myBoundingBox |
Stores Pointer to the sgpp::base::Grid's Bounding Box. More... | |
sgpp::base::Grid * | myGrid |
The Sparse sgpp::base::Grid needed in this classificator. More... | |
sgpp::base::GridStorage * | myGridStorage |
Stores Pointer to the Girs's Storage. More... | |
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.
sgpp::pde::PDESolver::PDESolver | ( | ) |
Std-Constructor of the solver.
References bGridConstructed.
|
virtual |
Std-Destructor of the solver.
References bGridConstructed, and myGrid.
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.
alpha | a sgpp::base::DataVector containing the grids coefficients |
dThreshold | Threshold 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.
|
pure virtual |
Use this routine the construct a regular grid to solve a PDE.
myBoundingBox | reference to a bounding box that describes the grid |
level | number 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.
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 |
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.
evalPoint | coordinates of the point at which the function should be evaluated |
alpha | the ansatzfunctions' coefficients |
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
References bGridConstructed, myGrid, and sgpp::base::Grid::serialize().
|
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.
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 |
References bGridConstructed, dim, sgpp::base::HashGridStorage::getCoordinates(), sgpp::base::StdNormalDistribution::getDensity(), sgpp::base::HashGridStorage::getPoint(), sgpp::base::Grid::getSize(), python.statsfileInfo::i, python.utils.statsfile2gnuplot::j, 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.
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
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
References bGridConstructed, sgpp::base::HashGridStorage::getNumberOfInnerPoints(), and myGridStorage.
|
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!
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().
|
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!
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().
|
virtual |
Prints the level,index pairs of the grid for each Gridpoint to a file.
tfilename | relative path to file into which the grid's evaluation is written |
References myGrid, and sgpp::base::GridPrinter::printLevelIndexGrid().
|
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
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().
|
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.
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.
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 |
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.
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 |
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!
alpha | a sgpp::base::DataVector containing the grids coefficients |
dThreshold | Threshold for a point's surplus for refining this point |
maxLevel | maxLevel 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.
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 |
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.
serializedGrid | a 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().
|
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().
|
protected |
the dimension of the grid
Referenced by sgpp::pde::PoissonEquationSolver::constructGrid(), sgpp::pde::HeatEquationSolver::constructGrid(), sgpp::pde::HeatEquationSolverWithStretching::constructGrid(), python.uq.dists.KDEDist.KDEDist::cov(), python.uq.dists.NatafDist.NatafDist::getDim(), 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(), python.uq.dists.KDEDist.KDEDist::rvs(), python.uq.dists.NatafDist.NatafDist::rvs(), and setGrid().
|
protected |
the number of levels used for an regular grid
Referenced by sgpp::pde::PoissonEquationSolver::constructGrid(), sgpp::pde::HeatEquationSolver::constructGrid(), sgpp::pde::HeatEquationSolverWithStretching::constructGrid(), and setGrid().
|
protected |
Stores Pointer to the sgpp::base::Grid's Bounding Box.
Referenced by sgpp::pde::PoissonEquationSolver::constructGrid(), sgpp::pde::HeatEquationSolver::constructGrid(), deleteGrid(), sgpp::pde::PoissonEquationSolver::initGridWithExpHeat(), sgpp::pde::PoissonEquationSolver::initGridWithSmoothHeat(), and setGrid().
|
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().
|
protected |
Stores Pointer to the Girs's Storage.
Referenced by sgpp::pde::PoissonEquationSolver::constructGrid(), sgpp::pde::HeatEquationSolver::constructGrid(), sgpp::pde::HeatEquationSolverWithStretching::constructGrid(), deleteGrid(), getGridNormalDistribution(), getNumberDimensions(), getNumberGridPoints(), getNumberInnerGridPoints(), sgpp::pde::PoissonEquationSolver::initGridWithExpHeat(), sgpp::pde::PoissonEquationSolver::initGridWithExpHeatFullDomain(), sgpp::pde::PoissonEquationSolver::initGridWithSmoothHeat(), sgpp::pde::HeatEquationSolver::initGridWithSmoothHeat(), sgpp::pde::HeatEquationSolverWithStretching::initGridWithSmoothHeat(), sgpp::pde::PoissonEquationSolver::initGridWithSmoothHeatFullDomain(), refineInitialGridSurplus(), refineInitialGridSurplusSubDomain(), refineInitialGridSurplusToMaxLevel(), refineInitialGridSurplusToMaxLevelSubDomain(), and setGrid().