1 #ifndef DUNE_FEM_SPACE_SHAPEFUNCTIONSET_TUPLE_HH 2 #define DUNE_FEM_SPACE_SHAPEFUNCTIONSET_TUPLE_HH 4 #include <dune/geometry/type.hh> 6 #include <dune/common/forloop.hh> 7 #include <dune/common/tuples.hh> 8 #include <dune/common/tupleutility.hh> 23 template<
class ... ShapeFunctionSets >
31 typedef tuple< std::integral_constant< int, I > ... > RangeSizeTuple;
34 static constexpr
int size () {
return tuple_element< j, RangeSizeTuple >::type::value; }
37 static constexpr Std::integer_sequence< int, size< j >() ... > sizes ( Std::integer_sequence< int, j ... > )
39 return Std::integer_sequence< int, size< j >() ... >();
43 static constexpr
int offset ()
45 return sum( sizes( Std::make_integer_sequence< int, i >() ) );
50 static constexpr
int sum ( Std::integer_sequence< int, j ... > )
55 static constexpr
int sum ( Std::integer_sequence< int > ) {
return 0; }
60 template<
int I >
struct Offsets;
61 template<
class Functor,
class Value,
int I >
struct FunctorWrapper;
63 template<
int I >
struct EvaluateEach;
64 template<
int I >
struct JacobianEach;
65 template<
int I >
struct HessianEach;
67 static const std::size_t dimRange =
Std::sum( static_cast< int >( ShapeFunctionSets::FunctionSpaceType::dimRange ) ... );
73 typedef typename FunctionSpaceType::DomainType
DomainType;
74 typedef typename FunctionSpaceType::RangeType
RangeType;
87 template<
class ... Args >
102 int order ()
const {
return order( Std::index_sequence_for< ShapeFunctionSets ... >() ); }
104 std::size_t
size ()
const {
return size( Std::index_sequence_for< ShapeFunctionSets ... >() ); }
106 template<
class Po
int,
class Functor >
112 template<
class Po
int,
class Functor >
118 template<
class Po
int,
class Functor >
125 template< std::size_t ... I >
126 int order ( Std::index_sequence< I ... > )
const 131 template< std::size_t ... I >
132 std::size_t
size ( Std::index_sequence< I ... > )
const 143 template< std::size_t ... I >
144 static tuple< decltype( makeGeometryType< I >( std::declval< GeometryType >() ) ) ... >
147 return std::make_tuple( makeGeometryType< I >( type ) ... );
163 template<
class Tuple >
164 static void apply (
const Tuple &tuple, Offset &offset )
166 offset[ I + 1 ] = offset[ I ] + std::get< I >( tuple ).
size();
176 template<
class Functor,
class Value,
int I >
179 static const int rangeOffset = RangeOffsets< ShapeFunctionSets::FunctionSpaceType::dimRange ... >::template offset< I >();
181 explicit FunctorWrapper (
const Functor &functor,
const Offset &offset )
182 : functor_( functor ),
offset_( offset ) {}
184 template<
class Scalar >
185 void operator() (
const std::size_t i,
const Scalar &subValue )
187 Value value(
typename FieldTraits< Value >::field_type( 0.0 ) );
188 std::copy( subValue.begin(), subValue.end(), value.begin() + rangeOffset );
189 functor_(
offset_[ I ] + i, value );
192 template<
class Scalar,
class Vectorial >
196 functor_(
offset_[ I ] + i, value );
209 template<
class ... ShapeFunctionSets >
213 template<
class Tuple,
class Po
int,
class Functor >
214 static void apply (
const Tuple &tuple,
const Offset &offset,
const Point &x, Functor functor )
216 FunctorWrapper< Functor, RangeType, I > functorWrapper( functor, offset );
217 std::get< I >( tuple ).
evaluateEach( x, functorWrapper );
226 template<
class ... ShapeFunctionSets >
230 template<
class Tuple,
class Po
int,
class Functor >
231 static void apply (
const Tuple &tuple,
const Offset &offset,
const Point &x, Functor functor )
233 FunctorWrapper< Functor, JacobianRangeType, I > functorWrapper( functor, offset );
234 std::get< I >( tuple ).
jacobianEach( x, functorWrapper );
243 template<
class ... ShapeFunctionSets >
247 template<
class Tuple,
class Po
int,
class Functor >
248 static void apply (
const Tuple &tuple,
const Offset &offset,
const Point &x, Functor functor )
250 FunctorWrapper< Functor, HessianRangeType, I > functorWrapper( functor, offset );
251 std::get< I >( tuple ).
hessianEach( x, functorWrapper );
260 #endif // #ifndef DUNE_FEM_SPACE_SHAPEFUNCTIONSET_TUPLE_HH void jacobianEach(const Point &x, Functor functor) const
Definition: shapefunctionset/tuple.hh:113
FunctionSpaceType::HessianRangeType HessianRangeType
Definition: shapefunctionset/tuple.hh:76
const ComponentType & component() const
Definition: shapefunctionset/vectorial.hh:121
Definition: shapefunctionset/vectorial.hh:137
static constexpr T max(T a)
Definition: utility.hh:65
interface class representing a family of shape function sets
Definition: shapefunctionsets.hh:32
static constexpr T sum(T a)
Definition: utility.hh:33
const ScalarType & scalar() const
Definition: shapefunctionset/vectorial.hh:123
tuple< ShapeFunctionSets... > ShapeFunctionSetTupleType
Definition: shapefunctionset/tuple.hh:70
static const int numShapeFunctions
Definition: shapefunctionset/tuple.hh:78
ShapeFunctionSetTupleType shapeFunctionSetTuple_
Definition: shapefunctionset/tuple.hh:150
Definition: coordinate.hh:4
FunctionSpaceType::DomainType DomainType
Definition: shapefunctionset/tuple.hh:73
std::size_t size(Std::index_sequence< I... >) const
Definition: shapefunctionset/tuple.hh:132
Offset offset_
Definition: shapefunctionset/tuple.hh:151
TupleShapeFunctionSet(Args &&...args)
Definition: shapefunctionset/tuple.hh:88
int order() const
Definition: shapefunctionset/tuple.hh:102
std::size_t size() const
Definition: shapefunctionset/tuple.hh:104
FunctionSpaceType::JacobianRangeType JacobianRangeType
Definition: shapefunctionset/tuple.hh:75
ToNewDimRangeFunctionSpace< typename tuple_element< 0, ShapeFunctionSetTupleType >::type::FunctionSpaceType, dimRange >::Type FunctionSpaceType
Definition: shapefunctionset/tuple.hh:71
FunctionSpaceType::RangeType RangeType
Definition: shapefunctionset/tuple.hh:74
int order(Std::index_sequence< I... >) const
Definition: shapefunctionset/tuple.hh:126
void hessianEach(const Point &x, Functor functor) const
Definition: shapefunctionset/tuple.hh:119
Definition: shapefunctionset/tuple.hh:24
TupleShapeFunctionSet(GeometryType type)
Definition: shapefunctionset/tuple.hh:80
convert functions space to space with new dim range
Definition: functionspace.hh:246
void evaluateEach(const Point &x, Functor functor) const
Definition: shapefunctionset/tuple.hh:107
static tuple< decltype(makeGeometryType< I > std::declval< GeometryType >)))... > makeGeometryTypeTuple(GeometryType type, Std::index_sequence< I... >)
Definition: shapefunctionset/tuple.hh:145
TupleShapeFunctionSet(const ShapeFunctionSetTupleType &shapeFunctionSetTuple=ShapeFunctionSetTupleType())
Definition: shapefunctionset/tuple.hh:95
static GeometryType makeGeometryType(GeometryType type)
Definition: shapefunctionset/tuple.hh:138