Dune Core Modules (2.11.0)

Dune::FoamGrid< dimgrid, dimworld, ct > Class Template Reference

An implementation of the Dune grid interface: a 1- or 2-dimensional simplicial grid in an n-dimensional world. More...

#include <dune/foamgrid/foamgrid.hh>

Public Types

typedef FoamGridFamily< dimgrid, dimworld, ct > GridFamily
 FoamGrid is only implemented for 1 and 2 dimension. More...
 
typedef FoamGridFamily< dimgrid, dimworld, ct >::Traits Traits
 Exports various types belonging to this grid class.
 
typedef ct ctype
 The type used to store coordinates.
 
Exported types
typedef GridFamily::Traits::LeafGridView LeafGridView
 type of view for leaf grid
 
typedef GridFamily::Traits::LevelGridView LevelGridView
 type of view for level grid
 
typedef GridFamily::Traits::LeafIntersection LeafIntersection
 A type that is a model of Dune::Intersection, an intersections of two codimension 1 of two codimension 0 entities in the leaf view.
 
typedef GridFamily::Traits::LevelIntersection LevelIntersection
 A type that is a model of Dune::Intersection, an intersections of two codimension 1 of two codimension 0 entities in a level view.
 
typedef GridFamily::Traits::LeafIntersectionIterator LeafIntersectionIterator
 A type that is a model of Dune::IntersectionIterator which is an iterator that allows to examine, but not to modify, the intersections of codimension 1 of an leaf element (entity of codimension 0) with other leaf elements.
 
typedef GridFamily::Traits::LevelIntersectionIterator LevelIntersectionIterator
 A type that is a model of Dune::IntersectionIterator which is an iterator that allows to examine, but not to modify, the intersections of codimension 1 of an element (entity of codimension 0) with other elements on the same level.
 
typedef GridFamily::Traits::HierarchicIterator HierarchicIterator
 A type that is a model of Dune::HierarchicIterator A type of iterator that allows to examine, but not to modify, entities of codimension 0 that result from refinement of an entity of codimension 0.
 
typedef GridFamily::Traits::LevelIndexSet LevelIndexSet
 A type that is a model of Dune::IndexSet which provides a consecutive, but non persistent, numbering for entities on a grid level.
 
typedef GridFamily::Traits::LeafIndexSet LeafIndexSet
 A type that is a model of Dune::IndexSet which provides a consecutive, but non persistent, numbering for entities in the leaf grid.
 
typedef GridFamily::Traits::GlobalIdSet GlobalIdSet
 A type that is a model of Dune::IdSet which provides a unique and persistent numbering for all entities in the grid. The numbering is unique over all processes over which the grid is partitioned. The numbering is not necessarily consecutive.
 
typedef GridFamily::Traits::LocalIdSet LocalIdSet
 A type that is a model of Dune::IdSet which provides a unique and persistent numbering for all entities in the grid. The numbering is only unique in a single process and it is not necessarily consecutive.
 
using Communication = typename GridFamily::Traits::Communication
 A type that is a model of Dune::Communication. It provides a portable way for communication on the set of processes used by the grid.
 

Public Member Functions

 FoamGrid ()
 Constructor, constructs an empty grid.
 
 ~FoamGrid ()
 Destructor.
 
int maxLevel () const
 
template<int codim>
Traits::template Codim< codim >::LevelIterator lbegin (int level) const
 Iterator to first entity of given codim on level.
 
template<int codim>
Traits::template Codim< codim >::LevelIterator lend (int level) const
 one past the end on this level
 
template<int codim, PartitionIteratorType PiType>
Traits::template Codim< codim >::template Partition< PiType >::LevelIterator lbegin (int level) const
 Iterator to first entity of given codim on level.
 
template<int codim, PartitionIteratorType PiType>
Traits::template Codim< codim >::template Partition< PiType >::LevelIterator lend (int level) const
 one past the end on this level
 
template<int codim>
Traits::template Codim< codim >::LeafIterator leafbegin () const
 Iterator to first leaf entity of given codim.
 
template<int codim>
Traits::template Codim< codim >::LeafIterator leafend () const
 one past the end of the sequence of leaf entities
 
template<int codim, PartitionIteratorType PiType>
Traits::template Codim< codim >::template Partition< PiType >::LeafIterator leafbegin () const
 Iterator to first leaf entity of given codim.
 
template<int codim, PartitionIteratorType PiType>
Traits::template Codim< codim >::template Partition< PiType >::LeafIterator leafend () const
 one past the end of the sequence of leaf entities
 
int size (int level, int codim) const
 Number of grid entities per level and codim.
 
int size (int codim) const
 number of leaf entities per codim in this process
 
int size (int level, GeometryType type) const
 number of entities per level, codim and geometry type in this process
 
int size (GeometryType type) const
 number of leaf entities per codim and geometry type in this process
 
size_t numBoundarySegments () const
 The number of boundary edges on the coarsest level.
 
const Traits::GlobalIdSetglobalIdSet () const
 Access to the GlobalIdSet.
 
const Traits::LocalIdSetlocalIdSet () const
 Access to the LocalIdSet.
 
const Traits::LevelIndexSetlevelIndexSet (int level) const
 Access to the LevelIndexSets.
 
const Traits::LeafIndexSetleafIndexSet () const
 Access to the LeafIndexSet.
 
template<class EntitySeed >
Traits::template Codim< EntitySeed::codimension >::Entity entity (const EntitySeed &seed) const
 Create an Entity from an EntitySeed.
 
Traits::LevelGridView levelGridView (int level) const
 View for a grid level for All_Partition.
 
Traits::LeafGridView leafGridView () const
 View for the leaf grid for All_Partition.
 
Traits::LeafIntersectionIterator ileafbegin (const typename Traits::template Codim< 0 >::Entity &entity) const
 obtain begin intersection iterator on the leaf level
 
Traits::LeafIntersectionIterator ileafend (const typename Traits::template Codim< 0 >::Entity &entity) const
 obtain end intersection iterator on the leaf level
 
Traits::LevelIntersectionIterator ilevelbegin (const typename Traits::template Codim< 0 >::Entity &entity) const
 obtain begin intersection iterator on the entity level
 
Traits::LevelIntersectionIterator ilevelend (const typename Traits::template Codim< 0 >::Entity &entity) const
 obtain end intersection iterator on the entity level
 
bool mark (int, const typename Traits ::template Codim< 0 >::Entity &)
 Marks an entity to be refined/coarsened in a subsequent adapt. More...
 
Grid Refinement Methods
void globalRefine (int refCount=1)
 Refine the grid uniformly. More...
 
bool mark (int refCount, const typename Traits::template Codim< 0 >::Entity &e)
 Mark entity for refinement. More...
 
int getMark (const typename Traits::template Codim< 0 >::Entity &e) const
 Return refinement mark for entity. More...
 
bool preAdapt ()
 Book-keeping routine to be called before adaptation.
 
bool adapt ()
 Triggers the grid refinement process.
 
void postAdapt ()
 Clean up refinement markers.
 
void setPosition (const typename Traits::template Codim< dimgrid >::Entity &e, const FieldVector< ctype, dimworld > &pos)
 Sets a (leaf) vertex to a new position. More...
 
Grid Growth Methods
unsigned int insertVertex (const FieldVector< ctype, dimworld > &pos)
 Add new vertex to be added the grid. More...
 
unsigned int insertElement (const GeometryType &type, const std::vector< unsigned int > &vertices)
 Add a new element to be added to the grid. More...
 
unsigned int insertElement (const GeometryType &type, const std::vector< unsigned int > &vertices, std::function< FieldVector< ctype, dimworld >(FieldVector< ctype, dimgrid >)> elementParametrization)
 Add a new element to be added to the grid. More...
 
void removeElement (const typename Traits::template Codim< 0 >::Entity &e)
 Mark an element for removal from the grid. More...
 
bool preGrow ()
 Book-keeping routine to be called before growth.
 
bool grow ()
 Triggers the grid growth process.
 
void postGrow ()
 Clean up isNew markers.
 
unsigned int growthInsertionIndex (const typename Traits::template Codim< 0 >::Entity &e) const
 The index of insertion if the element was created in the current growth step. If this is the first element added to the growth queue by calling insertElement the index is 0 and so on. The index will be valid until postGrow is called. More...
 
unsigned int growthInsertionIndex (const typename Traits::template Codim< dimgrid >::Entity &e) const
 The index of insertion if the vertex was created in the current growth step. If this is the first vertex added to the growth queue by calling insertVertex the index is 0 and so on. The index will be valid until postGrow is called. More...
 
Adaptivity and grid refinement
bool mark (int refCount, const typename Codim< 0 >::Entity &e)
 Marks an entity to be refined/coarsened in a subsequent adapt. More...
 
int getMark (const typename Codim< 0 >::Entity &e) const
 returns adaptation mark for given entity More...
 

Static Public Attributes

Exported constants
static constexpr int dimension
 The dimension of the grid.
 
static constexpr int dimensionworld
 The dimension of the world the grid lives in.
 

Protected Member Functions

Parallel data distribution and communication
GridImp & asImp ()
 Barton-Nackman trick.
 
const GridImp & asImp () const
 Barton-Nackman trick.
 

Methods for parallel computations

unsigned int overlapSize (int codim) const
 Size of the overlap on the leaf level.
 
unsigned int ghostSize (int codim) const
 Size of the ghost cell layer on the leaf level.
 
unsigned int overlapSize (int level, int codim) const
 Size of the overlap on a given level.
 
unsigned int ghostSize (int level, int codim) const
 Size of the ghost cell layer on a given level.
 
template<class DataHandle >
bool loadBalance (DataHandle &data)
 Distributes this grid over the available nodes in a distributed machine.
 
bool loadBalance ()
 
template<class T , template< class > class P, int codim>
void communicate (T &t, InterfaceType iftype, CommunicationDirection dir, int level) const
 The communication interface. More...
 
template<class DataHandle >
void communicate (DataHandle &data, InterfaceType iftype, CommunicationDirection dir, int level) const
 
template<class DataHandle >
void communicate (DataHandle &data, InterfaceType iftype, CommunicationDirection dir) const
 
const Traits::Communicationcomm () const
 

Detailed Description

template<int dimgrid, int dimworld, class ct>
class Dune::FoamGrid< dimgrid, dimworld, ct >

An implementation of the Dune grid interface: a 1- or 2-dimensional simplicial grid in an n-dimensional world.

Template Parameters
dimgridDimension of the grid; must be either 1 or 2
dimworldDimension of the world space

Member Typedef Documentation

◆ GridFamily

template<int dimgrid, int dimworld, class ct >
typedef FoamGridFamily<dimgrid, dimworld, ct> Dune::FoamGrid< dimgrid, dimworld, ct >::GridFamily

FoamGrid is only implemented for 1 and 2 dimension.

type of the used GridFamily for this grid

Member Function Documentation

◆ comm()

template<int dimgrid, int dimworld, class ct >
const Traits::Communication & Dune::FoamGrid< dimgrid, dimworld, ct >::comm ( ) const
inline

dummy collective communication

◆ communicate() [1/2]

template<int dimgrid, int dimworld, class ct >
template<class DataHandle >
void Dune::FoamGrid< dimgrid, dimworld, ct >::communicate ( DataHandle &  data,
InterfaceType  iftype,
CommunicationDirection  dir,
int  level 
) const
inline

The new communication interface communicate objects for all codims on a given level

◆ communicate() [2/2]

template<int dimgrid, int dimworld, class ct >
template<class T , template< class > class P, int codim>
void Dune::FoamGrid< dimgrid, dimworld, ct >::communicate ( T &  t,
InterfaceType  iftype,
CommunicationDirection  dir,
int  level 
) const
inline

The communication interface.

Parameters
Tarray class holding data associated with the entities
Ptype used to gather/scatter data in and out of the message buffer
codimcommunicate entites of given codim
ifone of the predifined interface types, throws error if it is not implemented
levelcommunicate for entities on the given level

Implements a generic communication function sending an object of type P for each entity in the intersection of two processors. P has two methods gather and scatter that implement the protocol. Therefore P is called the "protocol class".

◆ getMark() [1/2]

int Dune::Grid< dim, dimworld, ct, FoamGridFamily< dimgrid, dimworld, ct > >::getMark ( const typename Codim< 0 >::Entity &  e) const
inlineinherited

returns adaptation mark for given entity

Parameters
[in]eEntity for which adaptation mark should be determined
Returns
int adaptation mark currently set for given Entity e

◆ getMark() [2/2]

template<int dimgrid, int dimworld, class ct >
int Dune::FoamGrid< dimgrid, dimworld, ct >::getMark ( const typename Traits::template Codim< 0 >::Entity &  e) const
inline

Return refinement mark for entity.

Returns
refinement mark (1,0,-1)

◆ globalRefine()

template<int dimgrid, int dimworld, class ctype >
void Dune::FoamGrid< dimgrid, dimworld, ctype >::globalRefine ( int  refCount = 1)

Refine the grid uniformly.

Parameters
refCountNumber of times the grid is to be refined uniformly

References DUNE_THROW, Dune::Functions::Experimental::elements(), and Dune::leafGridView().

◆ growthInsertionIndex() [1/2]

template<int dimgrid, int dimworld, class ct >
unsigned int Dune::FoamGrid< dimgrid, dimworld, ct >::growthInsertionIndex ( const typename Traits::template Codim< 0 >::Entity &  e) const
inline

The index of insertion if the element was created in the current growth step. If this is the first element added to the growth queue by calling insertElement the index is 0 and so on. The index will be valid until postGrow is called.

Note
This is useful to attach user data to a created element. The data might only known at element creation time. As the final element index and id are not known yet when the element is added to the insertion queue, this index can be used to attach user data that can (after calling postGrow) be attached to the real element index/id.

Referenced by Dune::FoamGrid< dimgrid, dimworld, ct >::insertElement().

◆ growthInsertionIndex() [2/2]

template<int dimgrid, int dimworld, class ct >
unsigned int Dune::FoamGrid< dimgrid, dimworld, ct >::growthInsertionIndex ( const typename Traits::template Codim< dimgrid >::Entity &  e) const
inline

The index of insertion if the vertex was created in the current growth step. If this is the first vertex added to the growth queue by calling insertVertex the index is 0 and so on. The index will be valid until postGrow is called.

Note
This is useful to attach user data to a created vertex. The data might only known at vertex creation time. As the final vertex index and id are not known yet when the vertex is added to the insertion queue, this index can be used to attach user data that can (after calling postGrow) be attached to the real vertex index/id.

◆ insertElement() [1/2]

template<int dimgrid, int dimworld, class ct >
unsigned int Dune::FoamGrid< dimgrid, dimworld, ct >::insertElement ( const GeometryType type,
const std::vector< unsigned int > &  vertices 
)
inline

Add a new element to be added to the grid.

Parameters
typeThe GeometryType of the new element
verticesThe vertices of the new element, using the DUNE numbering
Returns
The growthInsertionIndex that can be used to attach user data to this element. It is valid between until calling postGrow.

References Dune::GeometryType::isLine(), Dune::GeometryType::isTriangle(), Dune::GridDefaultImplementation< dimgrid, dimworld, ct, FoamGridFamily< dimgrid, dimworld, ct > >::leafGridView(), and Dune::FoamGrid< dimgrid, dimworld, ct >::size().

Referenced by Dune::FoamGrid< dimgrid, dimworld, ct >::insertElement().

◆ insertElement() [2/2]

template<int dimgrid, int dimworld, class ct >
unsigned int Dune::FoamGrid< dimgrid, dimworld, ct >::insertElement ( const GeometryType type,
const std::vector< unsigned int > &  vertices,
std::function< FieldVector< ctype, dimworld >(FieldVector< ctype, dimgrid >)>  elementParametrization 
)
inline

Add a new element to be added to the grid.

Parameters
typeThe GeometryType of the new element
verticesThe vertices of the new element, using the DUNE numbering
elementParametrizationA function prescribing the shape of this element
Returns
The growthInsertionIndex that can be used to attach user data to this element. It is valid between until calling postGrow.

References Dune::FoamGrid< dimgrid, dimworld, ct >::growthInsertionIndex(), and Dune::FoamGrid< dimgrid, dimworld, ct >::insertElement().

◆ insertVertex()

template<int dimgrid, int dimworld, class ct >
unsigned int Dune::FoamGrid< dimgrid, dimworld, ct >::insertVertex ( const FieldVector< ctype, dimworld > &  pos)
inline

Add new vertex to be added the grid.

Parameters
posThe position vector of the vertex
Returns
The index of the newly inserted vertex (to be able to insert elements with it)

References Dune::FoamGridEntityImp< 0, dimgrid, dimworld, ctype >::growthInsertionIndex_, Dune::FoamGridEntityImp< 0, dimgrid, dimworld, ctype >::isNew_, Dune::GridDefaultImplementation< dimgrid, dimworld, ct, FoamGridFamily< dimgrid, dimworld, ct > >::leafGridView(), and Dune::GridView< ViewTraits >::size().

◆ mark() [1/3]

bool Dune::Grid< dim, dimworld, ct, FoamGridFamily< dimgrid, dimworld, ct > >::mark ( int  refCount,
const typename Codim< 0 >::Entity &  e 
)
inlineinherited

Marks an entity to be refined/coarsened in a subsequent adapt.

Parameters
[in]refCountNumber of subdivisions that should be applied. Negative value means coarsening.
[in]eEntity that should be marked
Returns
true if Entity was marked, false otherwise.

◆ mark() [2/3]

template<int dimgrid, int dimworld, class ct >
bool Dune::FoamGrid< dimgrid, dimworld, ct >::mark ( int  refCount,
const typename Traits::template Codim< 0 >::Entity &  e 
)
inline

Mark entity for refinement.

This only works for entities of codim 0. The parameter is currently ignored

Returns
  • true, if marking was successful
  • false, if marking was not possible

◆ mark() [3/3]

bool Dune::GridDefaultImplementation< dim, dimworld, ct, FoamGridFamily< dimgrid, dimworld, ct > >::mark ( int  ,
const typename Traits ::template Codim< 0 >::Entity &   
)
inlineinherited

Marks an entity to be refined/coarsened in a subsequent adapt.

Parameters
[in]refCountNumber of subdivisions that should be applied. Negative value means coarsening.
[in]eEntity to Entity that should be refined
Returns
true if Entity was marked, false otherwise.
Note
  • default implementation is: return false; for grids with no adaptation.
  • for the grid programmer: this method is implemented as a template method, because the Entity type is not defined when the class is instantiated You won't need this trick in the implementation. In your implementation you should use it as
    bool mark( int refCount,
    typename Traits::template Codim<0>::Entity & e ).
    bool mark(int refCount, const typename Traits::template Codim< 0 >::Entity &e)
    Mark entity for refinement.
    Definition: foamgrid.hh:329
    Static tag representing a codimension.
    Definition: dimension.hh:24
    This template method will vanish due to the inheritance rules.

◆ maxLevel()

template<int dimgrid, int dimworld, class ct >
int Dune::FoamGrid< dimgrid, dimworld, ct >::maxLevel ( ) const
inline

Return maximum level defined in this grid. Levels are numbered 0 ... maxlevel with 0 the coarsest level.

Referenced by Dune::FoamGrid< dimgrid, dimworld, ct >::lbegin(), Dune::FoamGrid< dimgrid, dimworld, ct >::lend(), and Dune::FoamGrid< dimgrid, dimworld, ct >::levelIndexSet().

◆ removeElement()

template<int dimgrid, int dimworld, class ct >
void Dune::FoamGrid< dimgrid, dimworld, ct >::removeElement ( const typename Traits::template Codim< 0 >::Entity &  e)
inline

Mark an element for removal from the grid.

Parameters
eThe codim 0 entity to be removed from the grid

◆ setPosition()

template<int dimgrid, int dimworld, class ctype >
void Dune::FoamGrid< dimgrid, dimworld, ctype >::setPosition ( const typename Traits::template Codim< dimgrid >::Entity &  e,
const FieldVector< ctype, dimworld > &  pos 
)

Sets a (leaf) vertex to a new position.

Parameters
eThe codim dimgrid entity (vertex) to be moved. Note: The vertex must be a leaf vertex. The implementation stores copies of vertices for each level they exist on. Changing a vertex' position changes its position on all coarser grid levels, too! We could not think of an application for moving non-leaf vertices, write us if you need that feature.
posThe new global position of the vertex

References DUNE_THROW, and Dune::GeometryTypes::vertex.


The documentation for this class was generated from the following files:
  • dune/foamgrid/foamgrid.hh
  • dune/foamgrid/foamgrid/foamgrid.cc
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden & Uni Heidelberg  |  generated with Hugo v0.111.3 (Feb 14, 23:39, 2026)