Loading [MathJax]/extensions/TeX/AMSmath.js

DUNE MultiDomainGrid (2.9)

Dune::mdgrid::MultiDomainGrid< HostGrid_, MDGridTraitsType > Class Template Reference

A meta grid for dividing an existing DUNE grid into subdomains that can be accessed as a grid in their own right. More...

#include <dune/grid/multidomaingrid/multidomaingrid.hh>

Public Types

typedef MDGridTraits::SubDomainIndex SubDomainIndex
 The (integer) type used to identify subdomains.
 
typedef subdomain::SubDomainGrid< ThisTypeSubDomainGrid
 The type used for representing the grid of a subdomain, always a specialization of Dune::mdgrid::subdomain::SubDomainGrid.
 
typedef Traits::LeafSubDomainInterfaceIterator LeafSubDomainInterfaceIterator
 The type of the iterators over the codim 1 interface between two subdomains on the leaf view.
 
typedef Traits::LevelSubDomainInterfaceIterator LevelSubDomainInterfaceIterator
 The type of the iterators over the codim 1 interface between two subdomains on a level view.
 
typedef Traits::LeafAllSubDomainInterfacesIterator LeafAllSubDomainInterfacesIterator
 The type of the iterators over the codim 1 interfaces between all subdomains on the leaf view.
 
typedef Traits::LevelAllSubDomainInterfacesIterator LevelAllSubDomainInterfacesIterator
 The type of the iterators over the codim 1 interfaces between all subdomains on a level view.
 

Public Member Functions

const SubDomainIndex maxSubDomainIndex () const
 The largest allowed index for a subdomain. More...
 
Constructors
 MultiDomainGrid (const std::shared_ptr< HostGrid > &hostGrid, bool supportLevelIndexSets=true)
 Constructs a new MultiDomainGrid from the given host grid. More...
 
 MultiDomainGrid (const std::shared_ptr< HostGrid > &hostGrid, const MDGridTraitsType &traits, bool supportLevelIndexSets=true)
 Constructs a new MultiDomainGrid from the given host grid. More...
 
 MultiDomainGrid (HostGrid &hostGrid, bool supportLevelIndexSets=true)
 Constructs a new MultiDomainGrid from the given host grid. More...
 
 MultiDomainGrid (HostGrid &hostGrid, const MDGridTraitsType &traits, bool supportLevelIndexSets=true)
 Constructs a new MultiDomainGrid from the given host grid. More...
 
Dune grid interface methods
template<typename EntitySeed >
Traits::template Codim< EntitySeed::codimension >::Entity entity (const EntitySeed &entitySeed) const
 
int maxLevel () const
 The current maximum level of the grid.
 
template<int codim>
Traits::template Codim< codim >::LevelIterator lbegin (int level) const
 
template<int codim>
Traits::template Codim< codim >::LevelIterator lend (int level) const
 
template<int codim, PartitionIteratorType pitype>
Traits::template Codim< codim >::template Partition< pitype >::LevelIterator lbegin (int level) const
 
template<int codim, PartitionIteratorType pitype>
Traits::template Codim< codim >::template Partition< pitype >::LevelIterator lend (int level) const
 
template<int codim>
Traits::template Codim< codim >::LeafIterator leafbegin () const
 
template<int codim>
Traits::template Codim< codim >::LeafIterator leafend () const
 
template<int codim, PartitionIteratorType pitype>
Traits::template Codim< codim >::template Partition< pitype >::LeafIterator leafbegin () const
 
template<int codim, PartitionIteratorType pitype>
Traits::template Codim< codim >::template Partition< pitype >::LeafIterator leafend () const
 
int size (int level, int codim) const
 
int size (int codim) const
 
int size (int level, GeometryType type) const
 
int size (GeometryType type) const
 
const Traits::GlobalIdSet & globalIdSet () const
 
const Traits::LocalIdSet & localIdSet () const
 
const Traits::LevelIndexSetlevelIndexSet (int level) const
 
const Traits::LeafIndexSetleafIndexSet () const
 
void globalRefine (int refCount)
 
bool mark (int refCount, const typename Traits::template Codim< 0 >::Entity &e)
 
int getMark (const typename Traits::template Codim< 0 >::Entity &e)
 
bool preAdapt ()
 
bool adapt ()
 
void postAdapt ()
 
int overlapSize (int level, int codim) const
 
int overlapSize (int codim) const
 
int ghostSize (int level, int codim) const
 
int ghostSize (int codim) const
 
const Traits::Communication & comm () const
 
template<typename DataHandleImp , typename DataTypeImp >
void communicate (CommDataHandleIF< DataHandleImp, DataTypeImp > &data, InterfaceType iftype, CommunicationDirection dir, int level) const
 
template<typename DataHandleImp , typename DataTypeImp >
void communicate (CommDataHandleIF< DataHandleImp, DataTypeImp > &data, InterfaceType iftype, CommunicationDirection dir) const
 
template<typename DataHandle >
bool loadBalance (DataHandle &dataHandle)
 
bool loadBalance ()
 
size_t numBoundarySegments () const
 
Methods for iterating over subdomain interfaces
LeafSubDomainInterfaceIterator leafSubDomainInterfaceBegin (SubDomainIndex subDomain1, SubDomainIndex subDomain2) const
 Returns an iterator over the leaf interface of two subdomains. More...
 
LeafSubDomainInterfaceIterator leafSubDomainInterfaceEnd (SubDomainIndex subDomain1, SubDomainIndex subDomain2) const
 Returns the corresponding end iterator for leafSubDomainInterfaceBegin().
 
LevelSubDomainInterfaceIterator levelSubDomainInterfaceBegin (SubDomainIndex subDomain1, SubDomainIndex subDomain2, int level) const
 Returns an iterator over the interface of two subdomains at the given level. More...
 
LevelSubDomainInterfaceIterator levelSubDomainInterfaceEnd (SubDomainIndex subDomain1, SubDomainIndex subDomain2, int level) const
 Returns the corresponding end iterator for levelSubDomainInterfaceBegin(). More...
 
LeafAllSubDomainInterfacesIterator leafAllSubDomainInterfacesBegin () const
 Returns an iterator over all subdomain interfaces on the leaf view. More...
 
LeafAllSubDomainInterfacesIterator leafAllSubDomainInterfacesEnd () const
 Returns the corresponding end iterator for leafAllSubDomainInterfacesBegin().
 
LevelAllSubDomainInterfacesIterator levelAllSubDomainInterfacesBegin (int level) const
 Returns an iterator over all subdomain interfaces on the requested level view. More...
 
LevelAllSubDomainInterfacesIterator levelAllSubDomainInterfacesEnd (int level) const
 Returns the corresponding end iterator for levelAllSubDomainInterfacesBegin(). More...
 
Subdomain creation- and adaptation methods
void startSubDomainMarking ()
 Prepares the grid for (re-)assigning cells to subdomains. More...
 
void preUpdateSubDomains ()
 Calculates the new subdomain layout, but does not update the current subdomains yet. More...
 
void updateSubDomains ()
 Switches the subdomain layout over to the new layout.
 
void postUpdateSubDomains ()
 clears the saved state of the subdomain layout that was active before the last call to updateSubDomains().
 
void addToSubDomain (SubDomainIndex subDomain, const typename Traits::template Codim< 0 >::Entity &e)
 Adds the given leaf entity to the specified subdomain.
 
void removeFromSubDomain (SubDomainIndex subDomain, const typename Traits::template Codim< 0 >::Entity &e)
 Removes the given leaf entity from the specified subdomain.
 
void assignToSubDomain (SubDomainIndex subDomain, const typename Traits::template Codim< 0 >::Entity &e)
 Assigns the given leaf entity to the specified subdomain, clearing any previous subdomain assignments.
 
void removeFromAllSubDomains (const typename Traits::template Codim< 0 >::Entity &e)
 Removes the given leaf entity from all subdomains it currently belongs to.
 
Access to the subdomain grids
const SubDomainGridsubDomain (SubDomainIndex subDomain) const
 Returns a reference to the SubDomainGrid associated with the given subdomain.
 
SubDomainGridsubDomain (SubDomainIndex subDomain)
 Returns a reference to the SubDomainGrid associated with the given subdomain.
 
SubDomainIndex maxAssignedSubDomainIndex () const
 Returns the largest subdomain index that was ever assigned to a cell in this grid. More...
 
bool supportLevelIndexSets () const
 Indicates whether this MultiDomainGrid instance supports level index sets on its SubDomainGrids.
 

Static Public Attributes

static const std::size_t maxNumberOfSubDomains = MDGridTraits::maxSubDomainsPerCell
 The largest number of subdomains any given grid cell may belong to.
 

Entity conversion methods

const MDGridTraits & traits () const
 
template<typename Entity >
Traits::template Codim< Entity::codimension >::Entity wrapHostEntity (const Entity &e) const
 
template<int codim>
Traits::template Codim< codim >::Entity wrapHostEntity (const typename HostGrid::template Codim< codim >::Entity &e) const
 
template<typename EntityType >
static const HostEntity< EntityType >::type & hostEntity (const EntityType &e)
 Returns a reference to the corresponding host entity. More...
 
template<typename EntityType >
static const MultiDomainEntity< EntityType >::type & multiDomainEntity (const EntityType &e)
 
template<typename IntersectionType >
static const auto & multiDomainIntersection (const IntersectionType &is)
 

Detailed Description

template<typename HostGrid_, typename MDGridTraitsType>
class Dune::mdgrid::MultiDomainGrid< HostGrid_, MDGridTraitsType >

A meta grid for dividing an existing DUNE grid into subdomains that can be accessed as a grid in their own right.

Template Parameters
HostGridThe type of the underlying grid implementation.
MDGridTraitsTypeA traits type for customizing how the MultiDomainGrid manages the partitioning information.

Constructor & Destructor Documentation

◆ MultiDomainGrid() [1/4]

template<typename HostGrid_ , typename MDGridTraitsType >
Dune::mdgrid::MultiDomainGrid< HostGrid_, MDGridTraitsType >::MultiDomainGrid ( const std::shared_ptr< HostGrid > &  hostGrid,
bool  supportLevelIndexSets = true 
)
inlineexplicit

Constructs a new MultiDomainGrid from the given host grid.

Parameters
hostGridthe host grid that will be wrapped by the MultiDomainGrid
supportLevelIndexSetsflag indicating support for level index sets on subdomains

◆ MultiDomainGrid() [2/4]

template<typename HostGrid_ , typename MDGridTraitsType >
Dune::mdgrid::MultiDomainGrid< HostGrid_, MDGridTraitsType >::MultiDomainGrid ( const std::shared_ptr< HostGrid > &  hostGrid,
const MDGridTraitsType &  traits,
bool  supportLevelIndexSets = true 
)
inlineexplicit

Constructs a new MultiDomainGrid from the given host grid.

Parameters
hostGridthe host grid that will be wrapped by the MultiDomainGrid
traitsan instance of the grid traits, which might contain runtime information
supportLevelIndexSetsflag indicating support for level index sets on subdomains

◆ MultiDomainGrid() [3/4]

template<typename HostGrid_ , typename MDGridTraitsType >
Dune::mdgrid::MultiDomainGrid< HostGrid_, MDGridTraitsType >::MultiDomainGrid ( HostGrid &  hostGrid,
bool  supportLevelIndexSets = true 
)
inlineexplicit

Constructs a new MultiDomainGrid from the given host grid.

Parameters
hostGridthe host grid that will be wrapped by the MultiDomainGrid
supportLevelIndexSetsflag indicating support for level index sets on subdomains

◆ MultiDomainGrid() [4/4]

template<typename HostGrid_ , typename MDGridTraitsType >
Dune::mdgrid::MultiDomainGrid< HostGrid_, MDGridTraitsType >::MultiDomainGrid ( HostGrid &  hostGrid,
const MDGridTraitsType &  traits,
bool  supportLevelIndexSets = true 
)
inlineexplicit

Constructs a new MultiDomainGrid from the given host grid.

Parameters
hostGridthe host grid that will be wrapped by the MultiDomainGrid
traitsan instance of the grid traits, which might contain runtime information
supportLevelIndexSetsflag indicating support for level index sets on subdomains

Member Function Documentation

◆ hostEntity()

template<typename HostGrid_ , typename MDGridTraitsType >
template<typename EntityType >
static const HostEntity< EntityType >::type & Dune::mdgrid::MultiDomainGrid< HostGrid_, MDGridTraitsType >::hostEntity ( const EntityType &  e)
inlinestatic

Returns a reference to the corresponding host entity.

Warning
The returned reference will only be valid as long as the passed-in reference to the MultiDomainGrid entity! If you need a persistent host entity object , copy the returned reference.

◆ leafAllSubDomainInterfacesBegin()

template<typename HostGrid_ , typename MDGridTraitsType >
LeafAllSubDomainInterfacesIterator Dune::mdgrid::MultiDomainGrid< HostGrid_, MDGridTraitsType >::leafAllSubDomainInterfacesBegin ( ) const
inline

Returns an iterator over all subdomain interfaces on the leaf view.

This method returns an iterator that will visit all pairwise surface interfaces between subdomains on the leaf view. In particular, given to adjacent cells e_1 and e_2 and two subdomains s_1 and s_2, this iterator will visit the intersection between e_1 and e_2 iff all of the following hold:

\begin{eqnarray*} e_1 \in s_1,\ e_1 \not\in s_2,\\ e_2 \not\in s_1,\ e_1 \in s_2.\end{eqnarray*}

In essence, the two subdomains have to be locally disjoint on e_1 and e_2.

The iterator will only traverse the host grid once for visiting all subdomain interfaces. Incrementing the iterator might thus result in an iterator pointing to the same grid intersection, but to a different pair of subdomains. The subdomains pointed to by the iterator can be retrieved by calling LeafAllSubDomainInterfacesIterator::subDomain1() and LeafAllSubDomainInterfacesIterator::subDomain2(), respectively.

◆ leafSubDomainInterfaceBegin()

template<typename HostGrid_ , typename MDGridTraitsType >
LeafSubDomainInterfaceIterator Dune::mdgrid::MultiDomainGrid< HostGrid_, MDGridTraitsType >::leafSubDomainInterfaceBegin ( SubDomainIndex  subDomain1,
SubDomainIndex  subDomain2 
) const
inline

Returns an iterator over the leaf interface of two subdomains.

The resulting iterator will visit all cell intersections that are part of both subdomains.

Attention
The iterator assumes the two subdomains to be non-overlapping! If there is an overlap, some intersections will be iterated over twice!
Parameters
subDomain1the first subdomain
subDomain2the second subdomain

◆ levelAllSubDomainInterfacesBegin()

template<typename HostGrid_ , typename MDGridTraitsType >
LevelAllSubDomainInterfacesIterator Dune::mdgrid::MultiDomainGrid< HostGrid_, MDGridTraitsType >::levelAllSubDomainInterfacesBegin ( int  level) const
inline

Returns an iterator over all subdomain interfaces on the requested level view.

This method returns an iterator that will visit all pairwise surface interfaces between subdomains on the requested level view. In particular, given to adjacent cells e_1 and e_2 and two subdomains s_1 and s_2, this iterator will visit the intersection between e_1 and e_2 iff all of the following hold:

\begin{eqnarray*} e_1 \in s_1,\ e_1 \not\in s_2,\\ e_2 \not\in s_1,\ e_1 \in s_2.\end{eqnarray*}

In essence, the two subdomains have to be locally disjoint on e_1 and e_2.

The iterator will only traverse the host grid once for visiting all subdomain interfaces. Incrementing the iterator might thus result in an iterator pointing to the same grid intersection, but to a different pair of subdomains. The subdomains pointed to by the iterator can be retrieved by calling LevelAllSubDomainInterfacesIterator::subDomain1() and LevelAllSubDomainInterfacesIterator::subDomain2(), respectively.

Parameters
levelthe grid level to be iterated over.

◆ levelAllSubDomainInterfacesEnd()

template<typename HostGrid_ , typename MDGridTraitsType >
LevelAllSubDomainInterfacesIterator Dune::mdgrid::MultiDomainGrid< HostGrid_, MDGridTraitsType >::levelAllSubDomainInterfacesEnd ( int  level) const
inline

Returns the corresponding end iterator for levelAllSubDomainInterfacesBegin().

Parameters
levelthe grid level to be iterated over.

◆ levelSubDomainInterfaceBegin()

template<typename HostGrid_ , typename MDGridTraitsType >
LevelSubDomainInterfaceIterator Dune::mdgrid::MultiDomainGrid< HostGrid_, MDGridTraitsType >::levelSubDomainInterfaceBegin ( SubDomainIndex  subDomain1,
SubDomainIndex  subDomain2,
int  level 
) const
inline

Returns an iterator over the interface of two subdomains at the given level.

The resulting iterator will visit all cell intersections that are part of both subdomains.

Attention
The iterator assumes the two subdomains to be non-overlapping! If there is an overlap, some intersections will be iterated over twice!
Parameters
subDomain1the first subdomain
subDomain2the second subdomain
levelthe grid level over which to iterate

◆ levelSubDomainInterfaceEnd()

template<typename HostGrid_ , typename MDGridTraitsType >
LevelSubDomainInterfaceIterator Dune::mdgrid::MultiDomainGrid< HostGrid_, MDGridTraitsType >::levelSubDomainInterfaceEnd ( SubDomainIndex  subDomain1,
SubDomainIndex  subDomain2,
int  level 
) const
inline

Returns the corresponding end iterator for levelSubDomainInterfaceBegin().

Parameters
levelthe grid level to be iterated over.

◆ maxAssignedSubDomainIndex()

template<typename HostGrid_ , typename MDGridTraitsType >
SubDomainIndex Dune::mdgrid::MultiDomainGrid< HostGrid_, MDGridTraitsType >::maxAssignedSubDomainIndex ( ) const
inline

Returns the largest subdomain index that was ever assigned to a cell in this grid.

This method returns the largest subdomain index that was passed to addToSubDomain() or assignToSubDomain() since this MultiDomainGrid was created. Keep in mind that the subdomain belonging to that index might not contain any entities anymore if all entities have been removed from it at a later point.

◆ maxSubDomainIndex()

template<typename HostGrid_ , typename MDGridTraitsType >
const SubDomainIndex Dune::mdgrid::MultiDomainGrid< HostGrid_, MDGridTraitsType >::maxSubDomainIndex ( ) const
inline

The largest allowed index for a subdomain.

Note
As subdomain indices always start at 0, this also determines the maximum number of possible subdomains.

◆ preUpdateSubDomains()

template<typename HostGrid_ , typename MDGridTraitsType >
void Dune::mdgrid::MultiDomainGrid< HostGrid_, MDGridTraitsType >::preUpdateSubDomains ( )
inline

Calculates the new subdomain layout, but does not update the current subdomains yet.

After calling this method, you can query the grid for the changes that will occur when the new subdomain layout becomes active. This includes the possibility to obtain the new indices entities will be assigned in the modified subdomains.

To switch the grid over to the new layout, call updateSubDomains().

References Dune::mdgrid::MultiDomainGrid< HostGrid_, MDGridTraitsType >::maxLevel().

◆ startSubDomainMarking()

template<typename HostGrid_ , typename MDGridTraitsType >
void Dune::mdgrid::MultiDomainGrid< HostGrid_, MDGridTraitsType >::startSubDomainMarking ( )
inline

Prepares the grid for (re-)assigning cells to subdomains.

After calling this method, it becomes possible to invoke the various methods for cell assignment to subdomains. When you are done marking, call preUpdateSubDomains().

IMPORTANT: Reassigning subdomains and grid adaptation are mutually exclusive, it is not possibly to do both at the same time. This restriction is enforced by the grid.


The documentation for this class was generated from the following files:
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden & Uni Heidelberg  |  generated with Hugo v0.111.3 (Apr 7, 22:57, 2025)