1#ifndef DUNE_FEM_GRIDPART_GEOMETRYGRIDPART_HH
2#define DUNE_FEM_GRIDPART_GEOMETRYGRIDPART_HH
8#include <dune/fem/function/localfunction/const.hh>
10#include <dune/fem/gridpart/common/deaditerator.hh>
11#include <dune/fem/gridpart/common/entitysearch.hh>
12#include <dune/fem/gridpart/common/extendedentity.hh>
13#include <dune/fem/gridpart/common/gridpart.hh>
14#include <dune/fem/gridpart/common/metatwistutility.hh>
15#include <dune/fem/gridpart/idgridpart/indexset.hh>
16#include <dune/fem/gridpart/idgridpart/iterator.hh>
18#include <dune/fem/gridpart/common/compositegeometry.hh>
19#include <dune/fem/gridpart/common/localfunctiongeometry.hh>
20#include <dune/fem/gridpart/common/sharedgeometry.hh>
21#include <dune/fem/gridpart/geometrygridpart/capabilities.hh>
22#include <dune/fem/gridpart/geometrygridpart/entity.hh>
23#include <dune/fem/gridpart/geometrygridpart/datahandle.hh>
24#include <dune/fem/gridpart/geometrygridpart/intersection.hh>
25#include <dune/fem/gridpart/geometrygridpart/intersectioniterator.hh>
36 template<
class Gr
idFunctionType >
37 class GeometryGridPart;
44 template<
class Gr
idFunction >
45 struct GeometryGridPartData
47 typedef GridFunction GridFunctionType;
49 GeometryGridPartData () noexcept = default;
50 GeometryGridPartData ( const GridFunctionType &gridFunction ) noexcept : gridFunction_( &gridFunction ) {}
52 operator const GridFunctionType & ()
const { assert( gridFunction_ );
return *gridFunction_; }
55 const GridFunctionType *gridFunction_ =
nullptr;
63 template<
class Gr
idFunction >
64 struct GeometryGridPartFamily
66 typedef GridFunction GridFunctionType;
67 typedef typename GridFunction::RangeFieldType ctype;
69 constexpr static int dimension = GridFunction::GridPartType::dimension;
70 constexpr static int dimensionworld = GridFunction::FunctionSpaceType::dimRange;
72 typedef GeometryGridPartFamily< GridFunction > GridPartFamily;
76 typedef GeometryGridPartData< GridFunction > ExtraData;
77 typedef GridFunction GridFunctionType;
78 typedef typename GridFunctionType::GridPartType HostGridPartType;
80 typedef SharedGeometry< LocalFunctionGeometry< ConstLocalFunction<GridFunction> > > ElementGeometryImpl;
85 typedef typename HostGridPartType::template Codim< codim >::LocalGeometryType LocalGeometry;
87 template<
int mydim,
int cdim,
class Gr
id >
88 using GeometryImpl = std::conditional_t< mydim == dimension, ElementGeometryImpl, CompositeGeometry< ElementGeometryImpl, LocalGeometry > >;
90 typedef Dune::Geometry< dimension - codim, dimensionworld,
const GridPartFamily, GeometryImpl > Geometry;
93 typedef typename HostGridPartType::GridType::template Codim< codim >::EntitySeed EntitySeed;
96 typedef DeadIntersection< const GridPartFamily > IntersectionImplType;
97 typedef DeadIntersectionIterator< const GridPartFamily > IntersectionIteratorImplType;
108 template<
int codim >
110 :
public Traits::template Codim< codim >
113 typedef typename Traits::LeafIntersectionIterator LeafIntersectionIterator;
114 typedef typename Traits::LevelIntersectionIterator LevelIntersectionIterator;
116 typedef typename Traits::HierarchicIterator HierarchicIterator;
124 template<
class Gr
idFunction >
125 struct GeometryGridPartTraits
127 typedef GridFunction GridFunctionType;
128 typedef typename GridFunction::GridPartType HostGridPartType;
129 typedef GeometryGridPart< GridFunction > GridPartType;
130 typedef GeometryGridPartFamily< GridFunction > GridPartFamily;
131 typedef GeometryGridPartFamily< GridFunction > GridFamily;
133 typedef GridPartType GridViewType;
135 constexpr static int dimension = GridFunction::GridPartType::dimension;
136 constexpr static int dimensionworld = GridFunction::FunctionSpaceType::dimRange;
139 typedef MetaTwistUtility< typename HostGridPartType::TwistUtilityType > TwistUtilityType;
141 typedef IdIndexSet< const GridPartFamily > IndexSetType;
143 typedef typename HostGridPartType::GridType GridType;
146 static const InterfaceType indexSetInterfaceType = HostGridPartType::indexSetInterfaceType;
148 typedef GeometryGridPartIntersectionIterator< const GridFamily > IntersectionIteratorImplType;
149 typedef GeometryGridPartIntersection< const GridFamily > IntersectionImplType;
150 typedef IntersectionIterator< const GridFamily, IntersectionIteratorImplType, IntersectionImplType > IntersectionIteratorType;
152 template<
int codim >
153 struct Codim :
public GridFamily::Traits::template Codim< codim >
155 typedef typename GridFamily::Traits::template Codim< codim > BaseType;
158 typedef typename BaseType::LocalGeometry LocalGeometryType;
160 typedef typename BaseType::Entity EntityType;
161 typedef typename BaseType::EntitySeed EntitySeedType;
163 template< PartitionIteratorType pitype >
166 typedef EntityIterator< codim, const GridFamily, IdIterator< codim, pitype, const GridFamily > > IteratorType;
167 typedef IteratorType Iterator;
171 typedef typename HostGridPartType::CommunicationType CommunicationType;
172 typedef CommunicationType Communication;
173 static const bool conforming = HostGridPartType::Traits::conforming;
181 template<
class Gr
idFunction >
182 class GeometryGridPart
183 :
public GridPartDefault< GeometryGridPartTraits< GridFunction > >
186 typedef GridFunction GridFunctionType;
189 typedef GeometryGridPart< GridFunctionType > ThisType;
190 typedef GridPartDefault< GeometryGridPartTraits< GridFunctionType > > BaseType;
191 typedef typename GeometryGridPartTraits< GridFunctionType >::GridFamily GridFamily;
194 typedef typename GridFunctionType::GridPartType HostGridPartType;
215 typedef typename BaseType::GridViewType GridViewType;
218 constexpr static int dimensionworld = GridFunction::FunctionSpaceType::dimRange;
220 template<
int codim >
222 :
public BaseType::template Codim< codim >
225 explicit GeometryGridPart (
const GridFunctionType &gridFunction )
226 : BaseType( const_cast< GridType& > (gridFunction.gridPart().
grid()) ),
227 gridFunction_( &gridFunction ),
228 indexSet_( hostGridPart().indexSet() )
231 const IndexSetType &indexSet ()
const
236 template<
int codim >
237 typename Codim< codim >::IteratorType
240 return begin< codim, InteriorBorder_Partition >();
243 template<
int codim, PartitionIteratorType pitype >
244 typename Codim< codim >::template Partition< pitype >::IteratorType
247 return IdIterator< codim, pitype, const GridFamily >( gridFunction(), hostGridPart().
template begin< codim, pitype >() );
250 template<
int codim >
251 typename Codim< codim >::IteratorType
254 return end< codim, InteriorBorder_Partition >();
257 template<
int codim, PartitionIteratorType pitype >
258 typename Codim< codim >::template Partition< pitype >::IteratorType
261 return IdIterator< codim, pitype, const GridFamily >( gridFunction(), hostGridPart().
template end< codim, pitype >() );
266 return hostGridPart().level();
269 IntersectionIteratorType ibegin (
const typename Codim< 0 >::EntityType &entity )
const
271 return GeometryGridPartIntersectionIterator< const GridFamily >( entity, hostGridPart().ibegin( entity.impl().hostEntity() ) );
274 IntersectionIteratorType iend (
const typename Codim< 0 >::EntityType &entity )
const
276 return GeometryGridPartIntersectionIterator< const GridFamily >( entity, hostGridPart().iend( entity.impl().hostEntity() ) );
279 template<
class DataHandle,
class Data >
280 void communicate ( CommDataHandleIF< DataHandle, Data > &handle,
283 typedef CommDataHandleIF< DataHandle, Data > HostHandleType;
284 GeometryGridPartDataHandle< GridFamily, HostHandleType > handleWrapper( handle, gridFunction() );
285 hostGridPart().communicate( handleWrapper, iftype, dir );
289 template<
class Entity >
290 MakeableInterfaceObject< typename Codim< Entity::codimension >::EntityType >
291 convert (
const Entity &entity )
const
294 const auto& gridEntity = Fem::gridEntity( entity );
297 typedef typename Codim< Entity::codimension >::EntityType EntityType;
298 typedef typename EntityType::Implementation Implementation;
299 typedef MakeableInterfaceObject< EntityType > EntityObj;
301 return EntityObj( Implementation( gridFunction(), hostGridPart().convert( gridEntity ) ) );
303 template <
class EntitySeed >
304 typename Codim< EntitySeed::codimension >::EntityType
305 entity (
const EntitySeed &seed )
const
307 return convert( hostGridPart().entity(seed) );
310 const HostGridPartType &hostGridPart ()
const
312 return gridFunction().gridPart();
315 const GridFunctionType& gridFunction()
const
317 assert( gridFunction_ );
318 return *gridFunction_;
322 const GridFunctionType *gridFunction_;
323 IndexSetType indexSet_;
331 template<
int codim,
int dim,
class Gr
idFamily >
332 struct GridEntityAccess<
Dune::ExtendedEntity< codim, dim, GridFamily, GeometryGridPartEntity > >
335 typedef GridEntityAccess< typename EntityType::Implementation::HostEntityType > HostAccessType;
336 typedef typename HostAccessType::GridEntityType GridEntityType;
338 static const GridEntityType &gridEntity (
const EntityType &entity )
340 return HostAccessType::gridEntity( entity.impl().hostEntity() );
349 template<
class Gr
idFunction,
int codim, PartitionIteratorType partition >
350 class EntitySearch< GeometryGridPart< GridFunction >, codim, partition >
351 :
public DefaultEntitySearch< GeometryGridPart< GridFunction >, codim, partition >
353 typedef EntitySearch< GeometryGridPart< GridFunction >, codim, partition > ThisType;
354 typedef DefaultEntitySearch< GeometryGridPart< GridFunction >, codim, partition > BaseType;
357 typedef typename BaseType::GridPartType GridPartType;
359 explicit EntitySearch (
const GridPartType &gridPart )
360 : BaseType( gridPart )
interface class for an iterator over grid entities
Definition: entityiterator.hh:32
Wrapper class for wrapped entities added a cast operator to the host entity.
Definition: extendedentity.hh:23
IntersectionIteratorType::Intersection IntersectionType
type of intersection
Definition: gridpart.hh:388
Traits::CommunicationType CommunicationType
Collective communication.
Definition: gridpart.hh:391
const GridType & grid() const
Returns const reference to the underlying grid.
Definition: gridpart.hh:423
Traits::IndexSetType IndexSetType
Index set implementation.
Definition: gridpart.hh:382
Traits::IntersectionIteratorType IntersectionIteratorType
type of intersection iterator
Definition: gridpart.hh:385
Traits::GridType GridType
Grid implementation.
Definition: gridpart.hh:380
void communicate(CommDataHandleIF< DataHandleImp, DataType > &data, InterfaceType iftype, CommunicationDirection dir) const
corresponding communication method for grid part
Definition: gridpart.hh:292
IndexSetType IndexSet
Index set implementation.
Definition: gridpart.hh:94
CommunicationType Communication
Collective communication.
Definition: gridpart.hh:99
IntersectionIteratorType IntersectionIterator
type of IntersectionIterator
Definition: gridpart.hh:113
GridType Grid
type of Grid implementation
Definition: gridpart.hh:89
IntersectionType Intersection
type of Intersection
Definition: gridpart.hh:118
Wrapper class for geometries.
Definition: geometry.hh:71
Mesh entities of codimension 0 ("elements") allow to visit all intersections with "neighboring" eleme...
Definition: intersectioniterator.hh:83
Intersection of a mesh entity of codimension 0 ("element") with a "neighboring" element or with the d...
Definition: intersection.hh:164
Various macros to work with Dune module version numbers.
@ conforming
Output conforming data.
Definition: common.hh:73
GeometryType
Type representing VTK's entity geometry types.
Definition: common.hh:132
Dune namespace.
Definition: alignedallocator.hh:13