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,
template<
class >
class >
30 template<
int codim,
class CoordFunction,
class DFSpace =
typename CoordFunction::DiscreteFunctionSpaceType >
33 template<
int codim,
class CoordFunction,
class FunctionSpace,
class Gr
idPart,
template<
class >
class Storage >
37 static_assert( (Conversion< DFSpace, typename CoordFunction::DiscreteFunctionSpaceType >::sameType),
"Invalid use of template argument DFSpace." );
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;
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 typedef typename CoordFunctionType::ConstDofBlockPtrType ConstDofBlockPtrType;
61 ConstDofBlockPtrType block = coordFunction_.block( index );
63 for(
int k = 0; k < dimRange; ++k )
64 y[ k ] = (*block)[ k ];
69 return hostEntity_.type();
74 return ReferenceElements< typename CoordFunctionType::GridPartType::GridType::ctype, mydimension >::general( type() ).size( mydimension );
78 const CoordFunctionType &coordFunction_;
79 const HostEntityType &hostEntity_;
87 template< int codim, class CoordFunction, bool discrete = Conversion< CoordFunction, IsDiscreteFunction >::exists >
90 template<
int codim,
class CoordFunction >
96 typedef typename CoordFunctionType::GridPartType::template Codim< codim >::EntityType
HostEntityType;
97 typedef typename CoordFunctionType::RangeType
RangeType;
100 const HostEntityType &hostEntity )
101 : coordFunction_( coordFunction ),
102 hostCorners_( hostEntity )
105 void evaluate (
unsigned int i, RangeType &y )
const 107 coordFunction_.evaluate( hostCorners_[ i ], y );
112 return hostCorners_.type();
117 return hostCorners_.size();
121 const CoordFunction &coordFunction_;
122 GeoGrid::HostCorners< HostEntityType > hostCorners_;
125 template<
int codim,
class CoordFunction >
136 const HostEntityType &hostEntity )
137 : BaseType( coordFunction, hostEntity )
146 template<
int mydim,
class Gr
idFamily >
149 typedef typename std::remove_const< GridFamily >::type::Traits Traits;
151 typedef typename std::remove_const< GridFamily >::type::ctype ctype;
153 static const int dimension = std::remove_const< GridFamily >::type::dimension;
154 static const int mydimension = mydim;
155 static const int codimension = dimension - mydimension;
156 static const int dimensionworld = std::remove_const< GridFamily >::type::dimensionworld;
158 typedef FieldVector< ctype, dimensionworld > Coordinate;
160 typedef typename Traits::HostGridPartType HostGridPartType;
161 typedef typename Traits::CoordFunctionType CoordFunctionType;
163 typedef typename HostGridPartType::template Codim< codimension >::EntityType HostEntityType;
169 const HostEntityType &hostEntity )
170 : coordFunctionCaller_( coordFunction, hostEntity )
173 template< std::
size_t size >
174 void calculate ( std::array< Coordinate, size > &corners )
const 176 const std::size_t numCorners = coordFunctionCaller_.numCorners();
177 for( std::size_t i = 0; i < numCorners; ++i )
178 coordFunctionCaller_.evaluate( i, corners[ i ] );
182 const CoordFunctionCallerType coordFunctionCaller_;
190 template<
int mydim,
class Gr
idFamily,
class LocalFunction >
193 typedef typename std::remove_const< GridFamily >::type::Traits Traits;
195 typedef typename std::remove_const< GridFamily >::type::ctype ctype;
197 static const int dimension = std::remove_const< GridFamily >::type::dimension;
198 static const int mydimension = mydim;
199 static const int codimension = dimension - mydimension;
200 static const int dimensionworld = std::remove_const< GridFamily >::type::dimensionworld;
202 typedef FieldVector< ctype, dimensionworld > Coordinate;
208 : localCoordFunction_( localCoordFunction )
211 template< std::
size_t size >
212 void calculate ( std::array< Coordinate, size > &corners )
const 214 assert( (localCoordFunction_.numDofs() % dimensionworld) == 0 );
215 const std::size_t numCorners = localCoordFunction_.numDofs() / dimensionworld;
216 assert( size >= numCorners );
217 for( std::size_t i = 0; i < numCorners; ++i )
219 for(
int k = 0; k < dimensionworld; ++k )
220 corners[ i ][ k ] = localCoordFunction_[ i*dimensionworld + k ];
225 static_assert( LocalCoordFunctionType::dimRange == dimensionworld,
"Invalid local coordinate function." );
227 const LocalCoordFunctionType &localCoordFunction_;
235 template<
class Gr
idFamily >
238 typedef typename std::remove_const< GridFamily >::type::Traits Traits;
240 typedef typename std::remove_const< GridFamily >::type::ctype ctype;
242 static const int dimension = std::remove_const< GridFamily >::type::dimension;
243 static const int codimension = 1;
244 static const int mydimension = dimension-codimension;
245 static const int dimensionworld = std::remove_const< GridFamily >::type::dimensionworld;
247 typedef FieldVector< ctype, dimensionworld > Coordinate;
249 typedef typename Traits::template Codim< 0 >::Geometry ElementGeometryType;
250 typedef typename Traits::template Codim< codimension >::LocalGeometry HostLocalGeometryType;
252 typedef typename ElementGeometryType::Implementation ElementGeometryImplType;
256 const HostLocalGeometryType &hostLocalGeometry )
257 : elementGeometry_( elementGeometry ),
258 hostLocalGeometry_( hostLocalGeometry )
261 template< std::
size_t size >
262 void calculate ( std::array< Coordinate, size > &corners )
const 264 const std::size_t numCorners = hostLocalGeometry_.corners();
265 assert( size >= numCorners );
266 for( std::size_t i = 0; i < numCorners; ++i )
267 corners[ i ] = elementGeometry_.global( hostLocalGeometry_.corner( i ) );
271 const ElementGeometryImplType &elementGeometry_;
272 HostLocalGeometryType hostLocalGeometry_;
280 template<
int mydim,
int cdim,
class Gr
idFamily >
283 typedef typename std::remove_const< GridFamily >::type::ctype ctype;
285 typedef FieldVector< ctype, cdim > Coordinate;
287 typedef std::array< Coordinate, (1 << mydim) > Coords;
297 template<
class LCFTraits >
308 const Coordinate &operator[] (
unsigned int i )
const 313 const_iterator
begin ()
const {
return coords_.begin(); }
314 const_iterator
end ()
const {
return coords_.end(); }
324 #endif // #ifndef DUNE_FEM_GRIDPART_GEOGRIDPART_CORNERSTORAGE_HH CoordFunctionType::RangeType RangeType
Definition: cornerstorage.hh:43
GeometryType type() const
Definition: cornerstorage.hh:110
CoordFunction CoordFunctionType
Definition: cornerstorage.hh:94
void evaluate(unsigned int i, RangeType &y) const
Definition: cornerstorage.hh:105
Lagrange discrete function space.
Definition: cornerstorage.hh:23
void calculate(std::array< Coordinate, size > &corners) const
Definition: cornerstorage.hh:262
A vector valued function space.
Definition: functionspace.hh:16
Definition: cornerstorage.hh:147
void evaluate(unsigned int i, RangeType &y) const
Definition: cornerstorage.hh:55
CoordFunctionType::GridPartType::template Codim< codim >::EntityType HostEntityType
Definition: cornerstorage.hh:42
void calculate(std::array< Coordinate, size > &corners) const
Definition: cornerstorage.hh:212
Definition: cornerstorage.hh:31
CoordFunctionType::GridPartType::template Codim< codim >::EntityType HostEntityType
Definition: cornerstorage.hh:96
const_iterator end() const
Definition: cornerstorage.hh:314
CoordFunctionType::RangeType RangeType
Definition: cornerstorage.hh:97
interface for local functions
Definition: localfunction.hh:41
GeoCoordFunctionCaller(const CoordFunctionType &coordFunction, const HostEntityType &hostEntity)
Definition: cornerstorage.hh:135
CoordFunction CoordFunctionType
Definition: cornerstorage.hh:37
std::size_t numCorners() const
Definition: cornerstorage.hh:72
Definition: cornerstorage.hh:88
GeoCornerStorage(const GeoIntersectionCoordVector< GridFamily > &coords)
Definition: cornerstorage.hh:303
LocalFunction LocalCoordFunctionType
Definition: cornerstorage.hh:205
Definition: coordinate.hh:4
BaseType::HostEntityType HostEntityType
Definition: cornerstorage.hh:133
GeoCornerStorage(const GeoCoordVector< mydim, GridFamily > &coords)
Definition: cornerstorage.hh:292
GeoCornerStorage(const GeoLocalCoordVector< mydim, GridFamily, LCFTraits > &coords)
Definition: cornerstorage.hh:298
BaseType::CoordFunctionType CoordFunctionType
Definition: cornerstorage.hh:132
const_iterator begin() const
Definition: cornerstorage.hh:313
GeoCoordFunctionCaller(const CoordFunction &coordFunction, const HostEntityType &hostEntity)
Definition: cornerstorage.hh:99
GeoLocalCoordVector(const LocalCoordFunctionType &localCoordFunction)
Definition: cornerstorage.hh:207
void calculate(std::array< Coordinate, size > &corners) const
Definition: cornerstorage.hh:174
GeometryType type() const
Definition: cornerstorage.hh:67
GeoDiscreteCoordFunctionCaller(const CoordFunction &coordFunction, const HostEntityType &hostEntity)
Definition: cornerstorage.hh:49
Definition: cornerstorage.hh:236
Definition: cornerstorage.hh:281
std::size_t numCorners() const
Definition: cornerstorage.hh:115
Definition: cornerstorage.hh:191
Coords::const_iterator const_iterator
Definition: cornerstorage.hh:290
GeoCoordVector(const CoordFunctionType &coordFunction, const HostEntityType &hostEntity)
Definition: cornerstorage.hh:168
GeoIntersectionCoordVector(const ElementGeometryImplType &elementGeometry, const HostLocalGeometryType &hostLocalGeometry)
Definition: cornerstorage.hh:255