1 #ifndef DUNE_FEM_GRIDPART_GEOGRIDPART_CORNERSTORAGE_HH
2 #define DUNE_FEM_GRIDPART_GEOGRIDPART_CORNERSTORAGE_HH
7 #include <dune/grid/geometrygrid/hostcorners.hh>
8 #include <dune/grid/geometrygrid/coordfunction.hh>
20 class IsDiscreteFunction;
22 template<
class,
class,
int,
class >
23 class LagrangeDiscreteFunctionSpace;
30 template<
int codim,
class CoordFunction,
class DFSpace =
typename CoordFunction::DiscreteFunctionSpaceType >
31 class GeoDiscreteCoordFunctionCaller;
33 template<
int codim,
class CoordFunction,
class FunctionSpace,
class Gr
idPart,
class Storage >
34 class GeoDiscreteCoordFunctionCaller< codim, CoordFunction, LagrangeDiscreteFunctionSpace< FunctionSpace, GridPart, 1, Storage > >
36 typedef LagrangeDiscreteFunctionSpace< FunctionSpace, GridPart, 1, Storage > DFSpace;
37 static_assert( (std::is_same< DFSpace, typename CoordFunction::DiscreteFunctionSpaceType >::value),
"Invalid use of template argument DFSpace." );
40 typedef CoordFunction CoordFunctionType;
42 typedef typename CoordFunctionType::GridPartType::template Codim< codim >::EntityType HostEntityType;
43 typedef typename CoordFunctionType::RangeType RangeType;
45 static const int dimRange = CoordFunctionType::FunctionSpaceType::dimRange;
46 static const int dimension = HostEntityType::dimension;
47 static const int mydimension = HostEntityType::mydimension;
49 GeoDiscreteCoordFunctionCaller (
const CoordFunction &coordFunction,
50 const HostEntityType &hostEntity )
51 : coordFunction_( coordFunction ),
52 hostEntity_( hostEntity )
55 void evaluate (
unsigned int i, RangeType &y )
const
57 const int index = coordFunction_.gridPart().indexSet().subIndex( hostEntity_, i, dimension );
58 assert( (index >= 0) && (index < (
int)(coordFunction_.space().blockMapper().size())) );
60 for(
int k = 0; k < dimRange; ++k )
61 y[ k ] = coordFunction_.dofVector()[ index ][ k ];
66 return hostEntity_.type();
69 std::size_t numCorners ()
const
75 const CoordFunctionType &coordFunction_;
76 const HostEntityType &hostEntity_;
84 template< int codim, class CoordFunction, bool discrete = std::is_convertible< CoordFunction, IsDiscreteFunction >::value >
85 class GeoCoordFunctionCaller;
87 template<
int codim,
class CoordFunction >
88 class GeoCoordFunctionCaller< codim, CoordFunction, false >
91 typedef CoordFunction CoordFunctionType;
93 typedef typename CoordFunctionType::GridPartType::template Codim< codim >::EntityType HostEntityType;
94 typedef typename CoordFunctionType::RangeType RangeType;
96 GeoCoordFunctionCaller (
const CoordFunction &coordFunction,
97 const HostEntityType &hostEntity )
98 : coordFunction_( coordFunction ),
99 hostCorners_( hostEntity )
102 void evaluate (
unsigned int i, RangeType &y )
const
104 coordFunction_.evaluate( hostCorners_[ i ], y );
109 return hostCorners_.type();
112 std::size_t numCorners ()
const
114 return hostCorners_.size();
118 const CoordFunction &coordFunction_;
119 GeoGrid::HostCorners< HostEntityType > hostCorners_;
122 template<
int codim,
class CoordFunction >
123 class GeoCoordFunctionCaller< codim, CoordFunction, true >
124 :
public GeoDiscreteCoordFunctionCaller< codim, CoordFunction >
126 typedef GeoDiscreteCoordFunctionCaller< codim, CoordFunction > BaseType;
129 typedef typename BaseType::CoordFunctionType CoordFunctionType;
130 typedef typename BaseType::HostEntityType HostEntityType;
132 GeoCoordFunctionCaller (
const CoordFunctionType &coordFunction,
133 const HostEntityType &hostEntity )
134 : BaseType( coordFunction, hostEntity )
143 template<
int mydim,
class Gr
idFamily >
146 typedef typename std::remove_const< GridFamily >::type::Traits Traits;
148 typedef typename std::remove_const< GridFamily >::type::ctype ctype;
150 static const int dimension = std::remove_const< GridFamily >::type::dimension;
151 static const int mydimension = mydim;
152 static const int codimension = dimension - mydimension;
153 static const int dimensionworld = std::remove_const< GridFamily >::type::dimensionworld;
155 typedef FieldVector< ctype, dimensionworld > Coordinate;
157 typedef typename Traits::HostGridPartType HostGridPartType;
158 typedef typename Traits::CoordFunctionType CoordFunctionType;
160 typedef typename HostGridPartType::template Codim< codimension >::EntityType HostEntityType;
162 typedef GeoCoordFunctionCaller< codimension, CoordFunctionType > CoordFunctionCallerType;
165 GeoCoordVector (
const CoordFunctionType &coordFunction,
166 const HostEntityType &hostEntity )
167 : coordFunctionCaller_( coordFunction, hostEntity )
170 template< std::
size_t size >
171 void calculate ( std::array< Coordinate, size > &corners )
const
173 const std::size_t numCorners = coordFunctionCaller_.numCorners();
174 for( std::size_t i = 0; i < numCorners; ++i )
175 coordFunctionCaller_.evaluate( i, corners[ i ] );
179 const CoordFunctionCallerType coordFunctionCaller_;
187 template<
int mydim,
class Gr
idFamily,
class LocalFunction >
188 class GeoLocalCoordVector
190 typedef typename std::remove_const< GridFamily >::type::Traits Traits;
192 typedef typename std::remove_const< GridFamily >::type::ctype ctype;
194 static const int dimension = std::remove_const< GridFamily >::type::dimension;
195 static const int mydimension = mydim;
196 static const int codimension = dimension - mydimension;
197 static const int dimensionworld = std::remove_const< GridFamily >::type::dimensionworld;
199 typedef FieldVector< ctype, dimensionworld > Coordinate;
202 typedef LocalFunction LocalCoordFunctionType;
204 explicit GeoLocalCoordVector (
const LocalCoordFunctionType &localCoordFunction )
205 : localCoordFunction_( localCoordFunction )
208 template< std::
size_t size >
209 void calculate ( std::array< Coordinate, size > &corners )
const
211 assert( (localCoordFunction_.numDofs() % dimensionworld) == 0 );
212 const std::size_t numCorners = localCoordFunction_.numDofs() / dimensionworld;
213 assert(
size >= numCorners );
214 for( std::size_t i = 0; i < numCorners; ++i )
216 for(
int k = 0; k < dimensionworld; ++k )
217 corners[ i ][ k ] = localCoordFunction_[ i*dimensionworld + k ];
224 const LocalCoordFunctionType &localCoordFunction_;
232 template<
class Gr
idFamily >
233 class GeoIntersectionCoordVector
235 typedef typename std::remove_const< GridFamily >::type::Traits Traits;
237 typedef typename std::remove_const< GridFamily >::type::ctype ctype;
239 static const int dimension = std::remove_const< GridFamily >::type::dimension;
240 static const int codimension = 1;
241 static const int mydimension = dimension-codimension;
242 static const int dimensionworld = std::remove_const< GridFamily >::type::dimensionworld;
244 typedef FieldVector< ctype, dimensionworld > Coordinate;
247 typedef typename Traits::template Codim< codimension >::LocalGeometry HostLocalGeometryType;
249 typedef typename ElementGeometryType::Implementation ElementGeometryImplType;
252 GeoIntersectionCoordVector (
const ElementGeometryImplType &elementGeometry,
253 const HostLocalGeometryType &hostLocalGeometry )
254 : elementGeometry_( elementGeometry ),
255 hostLocalGeometry_( hostLocalGeometry )
258 template< std::
size_t size >
259 void calculate ( std::array< Coordinate, size > &corners )
const
261 const std::size_t numCorners = hostLocalGeometry_.corners();
262 assert(
size >= numCorners );
263 for( std::size_t i = 0; i < numCorners; ++i )
264 corners[ i ] = elementGeometry_.global( hostLocalGeometry_.corner( i ) );
268 const ElementGeometryImplType &elementGeometry_;
269 HostLocalGeometryType hostLocalGeometry_;
277 template<
int mydim,
int cdim,
class Gr
idFamily >
278 class GeoCornerStorage
280 typedef typename std::remove_const< GridFamily >::type::ctype ctype;
284 typedef std::array< Coordinate, (1 << mydim) > Coords;
287 typedef typename Coords::const_iterator const_iterator;
289 explicit GeoCornerStorage (
const GeoCoordVector< mydim, GridFamily > &coords )
291 coords.calculate( coords_ );
294 template<
class LCFTraits >
295 explicit GeoCornerStorage (
const GeoLocalCoordVector< mydim, GridFamily, LCFTraits > &coords )
297 coords.calculate( coords_ );
300 explicit GeoCornerStorage (
const GeoIntersectionCoordVector< GridFamily > &coords )
302 coords.calculate( coords_ );
305 const Coordinate &operator[] (
unsigned int i )
const
310 const_iterator begin ()
const {
return coords_.begin(); }
311 const_iterator end ()
const {
return coords_.end(); }
static const int dimRange
dimension of the range
Definition: localfunction.hh:119
GeometryType
Type representing VTK's entity geometry types.
Definition: common.hh:132
concept Geometry
Model of a geometry object.
Definition: geometry.hh:29
Dune namespace.
Definition: alignedallocator.hh:13
constexpr std::integral_constant< std::size_t, sizeof...(II)> size(std::integer_sequence< T, II... >)
Return the size of the sequence.
Definition: integersequence.hh:75
static const ReferenceElement & general(const GeometryType &type)
get general reference elements
Definition: referenceelements.hh:156