AMDiS  0.1
The Adaptive Multi-Dimensional Simulation Toolbox
ProblemStat< Traits > Class Template Reference

Inherits ProblemStatBase, and StandardProblemIterationAdaptor< ProblemStat< Traits > >.

Public Types

using GlobalBasis = typename Traits::GlobalBasis
 
using GridView = typename GlobalBasis::GridView
 
using Grid = AdaptiveGrid_t< typename GridView::Grid >
 
using Element = typename GridView::template Codim< 0 >::Entity
 
using WorldVector = typename Element::Geometry::GlobalCoordinate
 
using WorldMatrix = FieldMatrix< typename WorldVector::field_type, WorldVector::dimension, WorldVector::dimension >
 
using LinearSolver = LinearSolverInterface< Mat, Vec >
 
using SystemMatrix = BiLinearForm< GlobalBasis, GlobalBasis, typename Traits::CoefficientType, LinAlgTraits >
 
using SystemVector = LinearForm< GlobalBasis, typename Traits::CoefficientType, LinAlgTraits >
 
using SolutionVector = DOFVector< GlobalBasis, typename Traits::CoefficientType, LinAlgTraits >
 

Public Member Functions

 ProblemStat (std::string const &name)
 Constructor. Takes the name of the problem that is used to access values corresponding to this problem in the parameter file.
 
template<class Grid_ >
 ProblemStat (std::string const &name, Grid_ &&grid)
 
template<class Grid_ , class Basis_ , class B_ = Underlying_t<Basis_>, REQUIRES(Concepts::GlobalBasis< B_ >) >
 ProblemStat (std::string const &name, Grid_ &&grid, Basis_ &&globalBasis)
 Constructor taking a grid and basis. Wraps both in shared pointers.
 
template<class Grid_ , class PBF_ , class GV_ = typename Underlying_t<Grid_>::LeafGridView, REQUIRES(Concepts::PreBasisFactory< PBF_, GV_, MultiIndex_t< PBF_ >>) >
 ProblemStat (std::string const &name, Grid_ &&grid, PBF_ const &preBasisFactory)
 Constructor taking a grid and pre-basis factory to create a global basis on the fly.
 
void initialize (Flag initFlag, Self *adoptProblem=nullptr, Flag adoptFlag=INIT_NOTHING)
 Initialisation of the problem. More...
 
void restore (Flag initFlag)
 Read the grid and solution from backup files and initialize the problem. More...
 
Flag oneIteration (AdaptInfo &adaptInfo, Flag toDo=FULL_ITERATION) override
 Implementation of StandardProblemIteration::oneIteration.
 
void buildAfterAdapt (AdaptInfo &adaptInfo, Flag flag, bool asmMatrix=true, bool asmVector=true) override
 Implementation of ProblemStatBase::buildAfterCoarse.
 
void assemble (AdaptInfo &adaptInfo)
 Assemble the linear system by calling buildAfterAdapt with asmMatrix and asmVector set to true.
 
void solve (AdaptInfo &adaptInfo, bool createMatrixData=true, bool storeMatrixData=false) override
 Implementation of ProblemStatBase::solve.
 
void estimate (AdaptInfo &) override
 Implementation of ProblemStatBase::estimate.
 
Flag adaptGrid (AdaptInfo &adaptInfo) override
 Implementation of ProblemStatBase::refineMesh.
 
Flag markElements (AdaptInfo &adaptInfo) override
 Implementation of ProblemStatBase::markElements.
 
Flag globalCoarsen (int n) override
 Uniform global grid coarsening by up to n level.
 
Flag globalRefine (int n) override
 Uniform global refinement by n level.
 
void writeFiles (AdaptInfo &adaptInfo, bool force=false)
 Writes output files. If force=true write even if timestep out of write rhythm.
 
std::string const & name () const override
 Implementation of ProblemStatBase::name.
 
std::shared_ptr< Grid > grid ()
 Return the grid_.
 
std::shared_ptr< Grid const > grid () const
 
GridView gridView () const
 Return the gridView of the basis.
 
std::shared_ptr< BoundaryManager< Grid > > boundaryManager ()
 Return the boundary manager to identify boundary segments.
 
std::shared_ptr< BoundaryManager< Grid > const > boundaryManager () const
 
std::shared_ptr< GlobalBasis > globalBasis ()
 Return the globalBasis_.
 
std::shared_ptr< GlobalBasis const > globalBasis () const
 
std::shared_ptr< LinearSolversolver ()
 Return a reference to the linear solver, linearSolver.
 
std::shared_ptr< LinearSolver const > solver () const
 
std::shared_ptr< SystemMatrixsystemMatrix ()
 Returns a reference to system-matrix, systemMatrix_.
 
std::shared_ptr< SystemMatrix const > systemMatrix () const
 
std::shared_ptr< SolutionVectorsolutionVector ()
 Returns a reference to the solution vector, solution_.
 
std::shared_ptr< SolutionVector const > solutionVector () const
 
std::shared_ptr< SystemVectorrhsVector ()
 Return a reference to the rhs system-vector, rhs.
 
std::shared_ptr< SystemVector const > rhsVector () const
 
template<class... Indices>
auto solution (Indices... ii)
 Return a mutable view to a solution component.
 
template<class... Indices>
auto solution (Indices... ii) const
 Return a const view to a solution component.
 
template<class Solver_ >
void setSolver (Solver_ &&solver)
 Set a new linear solver for the problem.
 
template<class Grid_ >
void setGrid (Grid_ &&grid)
 
template<class Marker_ >
void addMarker (Marker_ &&m)
 Store the shared_ptr and the name of the marker in the problem. More...
 
void removeMarker (std::string name)
 Remove a marker with the given name from the problem.
 
void removeMarker (Marker< Grid > const &marker)
 Remove a marker from the problem.
 
template<class Operator , class RowTreePath = RootTreePath, class ColTreePath = RootTreePath>
void addMatrixOperator (Operator const &op, RowTreePath row={}, ColTreePath col={})
 Add an operator to A. More...
 
template<class Operator , class RowTreePath = RootTreePath, class ColTreePath = RootTreePath>
void addMatrixOperator (BoundaryType b, Operator const &op, RowTreePath row={}, ColTreePath col={})
 Operator evaluated on the boundary of the domain with boundary index b More...
 
template<class Operator , class TreePath = RootTreePath>
void addVectorOperator (Operator const &op, TreePath path={})
 Add an operator to rhs. More...
 
template<class Operator , class TreePath = RootTreePath>
void addVectorOperator (BoundaryType b, Operator const &op, TreePath path={})
 Operator evaluated on the boundary of the domain with boundary index b More...
 
template<class Predicate , class RowTreePath , class ColTreePath , class Values >
void addDirichletBC (Predicate const &predicate, RowTreePath row, ColTreePath col, Values const &values)
 Add boundary conditions to the system. More...
 
template<class RowTreePath , class ColTreePath , class Values >
void addDirichletBC (BoundaryType id, RowTreePath row, ColTreePath col, Values const &values)
 
template<class Identifier , class Values >
void addDirichletBC (Identifier &&id, Values &&values)
 
void addPeriodicBC (BoundaryType id, WorldMatrix const &A, WorldVector const &b)
 
- Public Member Functions inherited from StandardProblemIterationAdaptor< ProblemStat< Traits > >
 StandardProblemIterationAdaptor (StandardProblemIterationAdaptor const &)
 
 StandardProblemIterationAdaptor (StandardProblemIterationAdaptor &&)
 
- Public Member Functions inherited from StandardProblemIteration
 StandardProblemIteration (ProblemStatBase &prob)
 constructor
 
void beginIteration (AdaptInfo &adaptInfo) override
 Implementation of ProblemIterationIterface::beginIteration()
 
Flag oneIteration (AdaptInfo &adaptInfo, Flag toDo) override
 Implementation of ProblemIterationInterface::oneIteration()
 
void endIteration (AdaptInfo &adaptInfo) override
 Implementation of ProblemIterationInterface::endIteration()
 
std::string const & name () const override
 Returns the name of the problem.
 
int numProblems () const override
 Returns number of managed problems.
 
ProblemStatBaseproblem (int number=0) override
 Return the managed ProblemStat problem, by number.
 
ProblemStatBaseproblem (std::string const &name) override
 Return the managed ProblemStat problem, by name.
 

Static Public Attributes

static constexpr int dim = Grid::dimension
 Dimension of the grid.
 
static constexpr int dow = Grid::dimensionworld
 Dimension of the world.
 

Protected Member Functions

void createGlobalBasis ()
 
void createGrid ()
 
void createMatricesAndVectors ()
 
void createSolver ()
 
void createMarker ()
 
void createFileWriter ()
 
void adoptGlobalBasis (std::shared_ptr< GlobalBasis > globalBasis)
 
void adoptGrid (std::shared_ptr< Grid > const &grid, std::shared_ptr< BoundaryManager< Grid >> const &boundaryManager)
 
void adoptGrid (std::shared_ptr< Grid > const &grid)
 
void adoptGrid (std::shared_ptr< typename Grid::HostGrid > const &hostGrid)
 
- Protected Member Functions inherited from StandardProblemIteration
Flag buildAndAdapt (AdaptInfo &adaptInfo, Flag toDo)
 Nested assemblage and mesh adaption.
 

Friends

class ProblemInstat< Traits >
 

Additional Inherited Members

- Protected Attributes inherited from StandardProblemIteration
ProblemStatBaseproblem_
 The problem to solve.
 

Constructor & Destructor Documentation

◆ ProblemStat()

ProblemStat ( std::string const &  name,
Grid_ &&  grid 
)
inline

Constructor taking additionally a grid that is used instead of the default created grid, ProblemStat

References ProblemStat< Traits >::grid(), and AMDiS::wrap_or_share().

Member Function Documentation

◆ addDirichletBC()

void addDirichletBC ( Predicate const &  predicate,
RowTreePath  row,
ColTreePath  col,
Values const &  values 
)

Add boundary conditions to the system.

Dirichlet boundary condition Enforce Dirichlet boundary values for the solution vector on boundary regions identified by the predicate.

Parameters
predicateFunctor bool(WorldVector) returning true for all DOFs on the boundary that should be assigned a value.
rowTreePath identifying the sub-basis in the global basis tree corresponding to the row basis.
See also
makeTreePath()
Parameters
colTreePath identifying the sub-basis in the global basis tree corresponding to the column basis.
See also
makeTreePath()
Parameters
valuesFunctor Range(WorldVector) or any GridFunction that is evaluated in the DOFs identified by the predicate.

Example:

prob.addDirichletBC([](auto const& x) { return x[0] < 1.e-8; }, 0, 0,
[](auto const& x) { return 0.0; });

References ProblemStat< Traits >::addPeriodicBC(), AMDiS::Concepts::Functor, AMDiS::makeGridFunction(), AMDiS::makeUniquePtr(), and AMDiS::Concepts::Predicate.

Referenced by ProblemStat< Traits >::addVectorOperator(), and ProblemStat< Traits >::restore().

◆ addMarker()

void addMarker ( Marker_ &&  m)
inline

Store the shared_ptr and the name of the marker in the problem.

Note: multiple markers can be added but must have different names

References AMDiS::wrap_or_share().

◆ addMatrixOperator() [1/2]

void addMatrixOperator ( Operator const &  op,
RowTreePath  row = {},
ColTreePath  col = {} 
)
inline

Add an operator to A.

Operator evaluated on the whole element Adds an operator to the list of element operators to be assembled in quadrature points inside the element.

Parameters
opA (pre-) local operator,
See also
LocalOperator,
GridFunctionOperator
Parameters
rowTreePath identifying the sub-basis in the global basis tree corresponding to the row basis.
See also
makeTreePath()
Parameters
colTreePath identifying the sub-basis in the global basis tree corresponding to the column basis.
See also
makeTreePath()

Example:

auto op = makeOperator(tag::test_trial{}, 1.0/tau);
prob.addMatrixOperator(op, _0, _0);

◆ addMatrixOperator() [2/2]

void addMatrixOperator ( BoundaryType  b,
Operator const &  op,
RowTreePath  row = {},
ColTreePath  col = {} 
)
inline

Operator evaluated on the boundary of the domain with boundary index b

Adds an operator to the list of boundary operators to be assembled in quadrature points on the boundary intersections.

Parameters
bBoundary identifier where to assemble this operator. Can be constructed from an integer.
See also
BoundaryType
Parameters
opA (pre-) local operator,
See also
LocalOperator,
GridFunctionOperator
Parameters
rowTreePath identifying the sub-basis in the global basis tree corresponding to the row basis.
See also
makeTreePath()
Parameters
colTreePath identifying the sub-basis in the global basis tree corresponding to the column basis.
See also
makeTreePath()

Example:

auto op = makeOperator(tag::test_trial{}, alpha);
prob.addMatrixOperator(BoundaryType{1}, op, _0, _0);

◆ addPeriodicBC()

void addPeriodicBC ( BoundaryType  id,
WorldMatrix const &  A,
WorldVector const &  b 
)

Add a periodic boundary conditions to the system, by specifying a face transformation y = A*x + b of coordinates. We assume, that A is orthonormal.

References AMDiS::makeUniquePtr(), and ProblemStat< Traits >::solve().

Referenced by ProblemStat< Traits >::addDirichletBC(), and ProblemStat< Traits >::addVectorOperator().

◆ addVectorOperator() [1/2]

void addVectorOperator ( Operator const &  op,
TreePath  path = {} 
)
inline

Add an operator to rhs.

Operator evaluated on the whole element Adds an operator to the list of element operators to be assembled in quadrature points inside the element.

Parameters
opA (pre-) local operator,
See also
LocalOperator,
GridFunctionOperator
Parameters
pathTreePath identifying the sub-basis in the global basis tree corresponding to the row basis.
See also
makeTreePath()

Example:

auto op = makeOperator(tag::test{}, probInstat.getOldSolution(0) / tau);
prob.addVectorOperator(op, _0);

◆ addVectorOperator() [2/2]

void addVectorOperator ( BoundaryType  b,
Operator const &  op,
TreePath  path = {} 
)
inline

Operator evaluated on the boundary of the domain with boundary index b

Adds an operator to the list of boundary operators to be assembled in quadrature points on the boundary intersections.

Parameters
bBoundary identifier where to assemble this operator. Can be constructed from an integer.
See also
BoundaryType
Parameters
opA (pre-) local operator,
See also
LocalOperator,
GridFunctionOperator
Parameters
pathTreePath identifying the sub-basis in the global basis tree corresponding to the row basis.
See also
makeTreePath()

Example:

auto op = makeOperator(tag::test{}, [g](auto const& x) { return g(x); });
prob.addVectorOperator(BoundaryType{1}, op, _0);

References ProblemStat< Traits >::addDirichletBC(), ProblemStat< Traits >::addPeriodicBC(), and AMDiS::Concepts::Predicate.

◆ initialize()

void initialize ( Flag  initFlag,
Self adoptProblem = nullptr,
Flag  adoptFlag = INIT_NOTHING 
)

Initialisation of the problem.

Parameters read in initialize()

  • [GRID_NAME]->global refinements: nr of initial global refinements

References Flag::isSet(), ProblemStat< Traits >::restore(), and AMDiS::test_exit().

Referenced by ProblemStat< Traits >::ProblemStat().

◆ restore()

void restore ( Flag  initFlag)

Read the grid and solution from backup files and initialize the problem.

Parameters read in restore() for problem with name 'PROB'

  • [PROB]->restore->grid: name of the grid backup file
  • [PROB]->restore->solution: name of the solution backup file

References ProblemStat< Traits >::addDirichletBC(), MeshCreator< G >::boundaryIds(), FileWriterCreator< SystemVector >::create(), MeshCreator< G >::create(), EstimatorMarker< Grid >::createMarker(), AMDiS::error_exit(), AMDiS::for_each_node(), Initfile::get(), AMDiS::info(), Flag::isSet(), AMDiS::named(), and AMDiS::test_exit().

Referenced by ProblemStat< Traits >::initialize(), and ProblemStat< Traits >::ProblemStat().

◆ setGrid()

void setGrid ( Grid_ &&  grid)
inline

Set the grid. Stores pointer and initializes feSpaces matrices and vectors, as well as markers and file-writers. If grid is given as reference, wrap it into a non-destroying shared_ptr

References ProblemStat< Traits >::grid(), and AMDiS::wrap_or_share().


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