KASKADE 7 development version
Loading...
Searching...
No Matches
Kaskade::GridManager< Grd > Class Template Reference

Class that takes care of the transfer of data (of each FunctionSpaceElement) after modification of the grid. More...

#include <gridmanager.hh>

Inheritance diagram for Kaskade::GridManager< Grd >:
Kaskade::GridManagerBase< Grd >

Public Types

typedef Grd Grid
typedef GridManagerBase< Grid > Self

Public Member Functions

 GridManager (Dune::GridPtr< Grid > grid_, bool verbose=false)
 Construction from a GridPtr<Grid>
 GridManager (std::unique_ptr< Grid > &&grid_, bool verbose=false)
 Construction from a unique_ptr<Grid>
 GridManager (Grid *&&grid_, bool verbose=false)
 Construction from a Grid*.
virtual void update ()
 Must be overloaded by derived classes to adjust internal state immediately after mesh refinement.
Self & enforceConcurrentReads (bool enforceConcurrentReads)
 Tells the grid manager that concurrent reads of the grid are safe.
Self & setVerbosity (const bool verbosity)
 sets the verbosity level of the grid manager
bool gridIsThreadSafe () const
 Returns true if concurrent read accesses to the grid do not lead to data races.
CellRanges< typename Grid::LeafGridView > const & cellRanges (typename Grid::LeafGridView const &) const
 Returns a CellRanges object for the given grid view. The cell ranges are created on demand, with a maximum number of ranges twice the number of cores as reported by the NumaThreadPool. The reference is valid up to the next mesh modification. This method is thread-safe.
CellRanges< typename Grid::LevelGridView > const & cellRanges (typename Grid::LevelGridView const &gridView) const
 Returns a CellRanges object for the given grid view.
EntityNumbering< typename Grid::LeafGridView > const & entityNumbering (typename Grid::LeafGridView const &) const
 Returns an EntityNumbering object for the given grid view.
Access to the managed grid.
Grid const & grid () const
 Returns a const reference on the owned grid.
std::shared_ptr< Grid const > gridShared () const
 Provides a read-only shared pointer to the underlying grid.
Grid adaptation
bool mark (int refCount, typename Grid::template Codim< 0 >::Entity const &cell)
 Marks the given cell for refinement or coarsening.
template<class S>
void mark (CellData< Grid, S > const &cellData)
 Marks all Entities of a grid according to the corresponding entries in a CellData.
size_t countMarked () const
 Reports the number of marked elements.
bool preAdapt ()
 Calls grid.preAdapt().
void postAdapt ()
 Calls grid.postAdapt().
bool adaptAtOnce ()
 Performs grid refinement.
void flushMarks ()
 Remove all cell marks from the grid.
bool adapt ()
 Refines each marked leaf cell of the grid and prolongates registered FE functions to the new leaf grid view.
void globalRefine (int refCount)
 Refines each leaf cell of the grid and prolongates registered FE functions to the new leaf grid view.

Public Attributes

GridSignals signals

Protected Member Functions

void beforeRefinement ()
void afterRefinement ()

Protected Attributes

std::shared_ptr< Grid > gridptr
 The grid itself.
bool verbose

Detailed Description

template<class Grd>
class Kaskade::GridManager< Grd >

Class that takes care of the transfer of data (of each FunctionSpaceElement) after modification of the grid.

Class that owns a grid. It takes care that all grid functions stay consistent, when the grid is refined. A Gridmanager<Grid> is constructed with a GridPointer<Grid>, a std::unique_ptr<Grid>&& or an r-value reference on a Grid*. After this, all modifications on the grid have to be done via the GridManager, in particular refinement. If the grid is refined, the GridManager sends a boost::signal to each FEFunctionSpace, which themselves send a boost::signal to each FunctionSpaceElement, such that their transfer from one grid to the other is organized.

The grid manager can print status and progress information to std::cout, see setVerbosity.

Examples for usage

  • Construction
* Dune::GridPtr<Grid> gridptr("MyDomain.dgf");
* GridManager<Grid> gm(gridptr);
* 
  • Alternative construction
* std::unique_ptr<Grid> gridptr(new ...);
* GridManager<Grid> gm(gridptr);
* 
* MySpace mySpace(gm,gm.grid().leafIndexSet(),order) //instead of: MySpace mySpace(grid,grid().leafIndexSet(),order)
* 
  • Uniform Refinement:
* gm.globalRefine(nTimes) //instead of: grid.globalRefine(nTimes)
* 
  • Adaptivity

Cf. detailed description of averaging_errorest.hh

Definition at line 690 of file gridmanager.hh.

Member Typedef Documentation

◆ Grid

template<class Grd>
typedef Grd Kaskade::GridManager< Grd >::Grid

Definition at line 693 of file gridmanager.hh.

◆ Self

template<class Grd>
typedef GridManagerBase<Grid> Kaskade::GridManagerBase< Grd >::Self
inherited

Definition at line 277 of file gridmanager.hh.

Constructor & Destructor Documentation

◆ GridManager() [1/3]

template<class Grd>
Kaskade::GridManager< Grd >::GridManager ( Dune::GridPtr< Grid > grid_,
bool verbose = false )
inlineexplicit

Construction from a GridPtr<Grid>

Construct a GridManager<Grid> from a GridPointer<Grid>. The ownership of the grid is transferred to the GridManager. Afterwards the grid can only be modified via the GridManager.

Definition at line 702 of file gridmanager.hh.

◆ GridManager() [2/3]

template<class Grd>
Kaskade::GridManager< Grd >::GridManager ( std::unique_ptr< Grid > && grid_,
bool verbose = false )
inlineexplicit

Construction from a unique_ptr<Grid>

Construct a GridManager<Grid> from a std::unique_ptr<Grid>. The ownership of the grid is transferred to the GridManager. Afterwards the grid can only be modified via the GridManager.

Definition at line 711 of file gridmanager.hh.

◆ GridManager() [3/3]

template<class Grd>
Kaskade::GridManager< Grd >::GridManager ( Grid *&& grid_,
bool verbose = false )
inlineexplicit

Construction from a Grid*.

Construct a GridManager<Grid> from a std::unique_ptr<Grid>. The ownership of the grid is transferred to the GridManager. Afterwards the grid can only be modified via the GridManager.

Definition at line 720 of file gridmanager.hh.

Member Function Documentation

◆ adapt()

template<class Grd>
bool Kaskade::GridManagerBase< Grd >::adapt ( )
inlineinherited

Refines each marked leaf cell of the grid and prolongates registered FE functions to the new leaf grid view.

Definition at line 419 of file gridmanager.hh.

Referenced by Kaskade::GridManagerBase< DeformedGrid >::adaptAtOnce().

◆ adaptAtOnce()

template<class Grd>
bool Kaskade::GridManagerBase< Grd >::adaptAtOnce ( )
inlineinherited

Performs grid refinement.

In contrast to adapt(), this method implicitly calls preAdapt() and postAdapt().

Definition at line 394 of file gridmanager.hh.

Referenced by Kaskade::coarsening(), Kaskade::markAndRefine(), and Kaskade::refineAtBoundary().

◆ afterRefinement()

template<class Grd>
void Kaskade::GridManagerBase< Grd >::afterRefinement ( )
inlineprotectedinherited

◆ beforeRefinement()

template<class Grd>
void Kaskade::GridManagerBase< Grd >::beforeRefinement ( )
inlineprotectedinherited

◆ cellRanges() [1/2]

template<class Grd>
CellRanges< typename Grid::LeafGridView > const & Kaskade::GridManagerBase< Grd >::cellRanges ( typename Grid::LeafGridView const & ) const
inlineinherited

Returns a CellRanges object for the given grid view. The cell ranges are created on demand, with a maximum number of ranges twice the number of cores as reported by the NumaThreadPool. The reference is valid up to the next mesh modification. This method is thread-safe.

Definition at line 541 of file gridmanager.hh.

◆ cellRanges() [2/2]

template<class Grd>
CellRanges< typename Grid::LevelGridView > const & Kaskade::GridManagerBase< Grd >::cellRanges ( typename Grid::LevelGridView const & gridView) const
inlineinherited

Returns a CellRanges object for the given grid view.

Parameters
gridViewa level grid view of the grid managed by this grid manager

The cell ranges are created on demand. The reference is valid up to the next mesh modification. This method is thread-safe.

Definition at line 557 of file gridmanager.hh.

◆ countMarked()

template<class Grd>
size_t Kaskade::GridManagerBase< Grd >::countMarked ( ) const
inlineinherited

Reports the number of marked elements.

Definition at line 364 of file gridmanager.hh.

◆ enforceConcurrentReads()

template<class Grd>
Self & Kaskade::GridManagerBase< Grd >::enforceConcurrentReads ( bool enforceConcurrentReads)
inlineinherited

Tells the grid manager that concurrent reads of the grid are safe.

Definition at line 492 of file gridmanager.hh.

◆ entityNumbering()

template<class Grd>
EntityNumbering< typename Grid::LeafGridView > const & Kaskade::GridManagerBase< Grd >::entityNumbering ( typename Grid::LeafGridView const & ) const
inlineinherited

Returns an EntityNumbering object for the given grid view.

Todo
allow to specify the sorting

Definition at line 573 of file gridmanager.hh.

◆ flushMarks()

template<class Grd>
void Kaskade::GridManagerBase< Grd >::flushMarks ( )
inlineinherited

Remove all cell marks from the grid.

Definition at line 407 of file gridmanager.hh.

Referenced by Kaskade::GridManagerBase< DeformedGrid >::mark().

◆ globalRefine()

template<class Grd>
void Kaskade::GridManagerBase< Grd >::globalRefine ( int refCount)
inlineinherited

Refines each leaf cell of the grid and prolongates registered FE functions to the new leaf grid view.

Definition at line 457 of file gridmanager.hh.

◆ grid()

◆ gridIsThreadSafe()

template<class Grd>
bool Kaskade::GridManagerBase< Grd >::gridIsThreadSafe ( ) const
inlineinherited

Returns true if concurrent read accesses to the grid do not lead to data races.

This is either the case if the grid implementation itself reports that it's thread-safe, or if the user has explicitly stated that concurrent reads are safe (using enforceConcurrentReads) - even if they actually are not.

The thread-safety reported by this method is used e.g. by the assembler to decide how many threads to use during assembly.

If the grid access may not be thread-safe, consider using GridLocking.

Definition at line 524 of file gridmanager.hh.

◆ gridShared()

template<class Grd>
std::shared_ptr< Grid const > Kaskade::GridManagerBase< Grd >::gridShared ( ) const
inlineinherited

Provides a read-only shared pointer to the underlying grid.

Note that only an immutable grid is provided, such that the responsibility for grid modifications remains with the GridManager object. This is necessary for the GridManager to trigger prolongation/interpolation on grid modification.

This can be useful for retaining the grid even after the GridManager is destructed.

Definition at line 315 of file gridmanager.hh.

◆ mark() [1/2]

template<class Grd>
template<class S>
void Kaskade::GridManagerBase< Grd >::mark ( CellData< Grid, S > const & cellData)
inlineinherited

Marks all Entities of a grid according to the corresponding entries in a CellData.

Definition at line 347 of file gridmanager.hh.

◆ mark() [2/2]

template<class Grd>
bool Kaskade::GridManagerBase< Grd >::mark ( int refCount,
typename Grid::template Codim< 0 >::Entity const & cell )
inlineinherited

Marks the given cell for refinement or coarsening.

Parameters
refCountif positive, marks for (multiple) refinement; if negative, for (multiple) coarsening. Not every grid implementation accepts multiple refinement/coarsening.
cellthe affected cell

Definition at line 335 of file gridmanager.hh.

Referenced by Kaskade::coarsening(), Kaskade::GridManagerBase< DeformedGrid >::flushMarks(), Kaskade::GridManagerBase< DeformedGrid >::mark(), Kaskade::markAndRefine(), Kaskade::markCells(), Kaskade::refineAtBoundary(), and Kaskade::uniformEmbeddedErrorEstimation().

◆ postAdapt()

template<class Grd>
void Kaskade::GridManagerBase< Grd >::postAdapt ( )
inlineinherited

Calls grid.postAdapt().

Definition at line 379 of file gridmanager.hh.

Referenced by Kaskade::GridManagerBase< DeformedGrid >::adaptAtOnce().

◆ preAdapt()

template<class Grd>
bool Kaskade::GridManagerBase< Grd >::preAdapt ( )
inlineinherited

Calls grid.preAdapt().

Definition at line 370 of file gridmanager.hh.

Referenced by Kaskade::GridManagerBase< DeformedGrid >::adaptAtOnce().

◆ setVerbosity()

template<class Grd>
Self & Kaskade::GridManagerBase< Grd >::setVerbosity ( const bool verbosity)
inlineinherited

sets the verbosity level of the grid manager

The grid manager prints status and progress information to std::cout. The amount of information depends on the verbosity:

  • 0: no messages are printed
  • 1: mesh size change on refinement is reported

Definition at line 507 of file gridmanager.hh.

◆ update()

template<class Grd>
virtual void Kaskade::GridManager< Grd >::update ( )
inlinevirtual

Must be overloaded by derived classes to adjust internal state immediately after mesh refinement.

Implements Kaskade::GridManagerBase< Grd >.

Definition at line 725 of file gridmanager.hh.

Member Data Documentation

◆ gridptr

template<class Grd>
std::shared_ptr<Grid> Kaskade::GridManagerBase< Grd >::gridptr
protectedinherited

The grid itself.

Definition at line 618 of file gridmanager.hh.

◆ signals

template<class Grd>
GridSignals Kaskade::GridManagerBase< Grd >::signals
inherited

Definition at line 621 of file gridmanager.hh.

◆ verbose

template<class Grd>
bool Kaskade::GridManagerBase< Grd >::verbose
protectedinherited

Definition at line 636 of file gridmanager.hh.


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