1#ifndef DUNE_FEM_SPACE_SHAPEFUNCTIONSET_TUPLE_HH
2#define DUNE_FEM_SPACE_SHAPEFUNCTIONSET_TUPLE_HH
6#include <dune/geometry/type.hh>
9#include <dune/common/tupleutility.hh>
24 template<
class ... ShapeFunctionSets >
32 typedef std::tuple< std::integral_constant< int, I > ... > RangeSizeTuple;
35 static constexpr int size () {
return std::tuple_element< j, RangeSizeTuple >::type::value; }
38 static constexpr std::integer_sequence< int, size< j >() ... > sizes ( std::integer_sequence< int, j ... > )
40 return std::integer_sequence< int, size< j >() ... >();
44 static constexpr int offset ()
46 return sum( sizes( std::make_integer_sequence< int, i >() ) );
51 static constexpr int sum ( std::integer_sequence< int, j ... > )
56 static constexpr int sum ( std::integer_sequence< int > ) {
return 0; }
61 template<
int I >
struct Offsets;
62 template<
class Functor,
class Value,
int I >
struct FunctorWrapper;
64 template<
int I >
struct EvaluateEach;
65 template<
int I >
struct JacobianEach;
66 template<
int I >
struct HessianEach;
68 static const std::size_t dimRange =
Std::sum(
static_cast< int >( ShapeFunctionSets::FunctionSpaceType::dimRange ) ... );
71 template< std::
size_t i >
76 typedef typename FunctionSpaceType::DomainType
DomainType;
77 typedef typename FunctionSpaceType::RangeType
RangeType;
91 template<
class ... Args >
106 int order ()
const {
return order( std::index_sequence_for< ShapeFunctionSets ... >() ); }
108 std::size_t
size ()
const {
return size( std::index_sequence_for< ShapeFunctionSets ... >() ); }
110 template<
class Po
int,
class Functor >
116 template<
class Po
int,
class Functor >
122 template<
class Po
int,
class Functor >
128 template< std::
size_t i >
135 template< std::size_t ... I >
136 int order ( std::index_sequence< I ... > )
const
141 template< std::size_t ... I >
142 std::size_t
size ( std::index_sequence< I ... > )
const
153 template< std::size_t ... I >
154 static std::tuple< decltype( makeGeometryType< I >( std::declval< GeometryType >() ) ) ... >
157 return std::make_tuple( makeGeometryType< I >( type ) ... );
173 template<
class Tuple >
174 static void apply (
const Tuple &tuple, Offset &offset )
176 offset[ I + 1 ] = offset[ I ] + std::get< I >( tuple ).size();
185 template<
class ... ShapeFunctionSets >
186 template<
class Functor,
class Value,
int I >
187 struct TupleShapeFunctionSet< ShapeFunctionSets ... >::FunctorWrapper
189 static const int rangeOffset = RangeOffsets< ShapeFunctionSets::FunctionSpaceType::dimRange ... >::template offset< I >();
191 explicit FunctorWrapper (
const Functor &functor,
const Offset &offset )
192 : functor_( functor ),
offset_( offset ) {}
194 template<
class Scalar >
195 void operator() (
const std::size_t i,
const Scalar &subValue )
197 Value value(
typename FieldTraits< Value >::field_type( 0.0 ) );
198 std::copy( subValue.begin(), subValue.end(), value.begin() + rangeOffset );
199 functor_(
offset_[ I ] + i, value );
203 void operator () (
const std::size_t i,
const Dune::FieldVector< K, 1 > &subValue )
205 MakeVectorialExpression< Dune::FieldVector< K, 1 >, Value > value( rangeOffset, subValue[ 0 ] );
206 functor_(
offset_[ I ] + i, value );
209 template<
class K,
int n >
210 void operator () (
const std::size_t i,
const Dune::FieldMatrix< K, 1, n > &subValue )
212 MakeVectorialExpression< Dune::FieldMatrix< K, 1, n >, Value > value( rangeOffset, subValue[ 0 ] );
213 functor_(
offset_[ I ] + i, value );
216 template<
class Scalar,
class Vectorial >
217 void operator() (
const std::size_t i,
const MakeVectorialExpression< Scalar, Vectorial > &subValue )
219 MakeVectorialExpression< Scalar, Value > value( subValue.component() + rangeOffset, subValue.scalar() );
220 functor_(
offset_[ I ] + i, value );
233 template<
class ... ShapeFunctionSets >
235 struct TupleShapeFunctionSet< ShapeFunctionSets ... >::EvaluateEach
237 template<
class Tuple,
class Po
int,
class Functor >
238 static void apply (
const Tuple &tuple,
const Offset &offset,
const Point &x, Functor functor )
240 FunctorWrapper< Functor, RangeType, I > functorWrapper( functor, offset );
241 std::get< I >( tuple ).evaluateEach( x, functorWrapper );
250 template<
class ... ShapeFunctionSets >
252 struct TupleShapeFunctionSet< ShapeFunctionSets ... >::JacobianEach
254 template<
class Tuple,
class Po
int,
class Functor >
255 static void apply (
const Tuple &tuple,
const Offset &offset,
const Point &x, Functor functor )
257 FunctorWrapper< Functor, JacobianRangeType, I > functorWrapper( functor, offset );
258 std::get< I >( tuple ).jacobianEach( x, functorWrapper );
267 template<
class ... ShapeFunctionSets >
269 struct TupleShapeFunctionSet< ShapeFunctionSets ... >::HessianEach
271 template<
class Tuple,
class Po
int,
class Functor >
272 static void apply (
const Tuple &tuple,
const Offset &offset,
const Point &x, Functor functor )
274 FunctorWrapper< Functor, HessianRangeType, I > functorWrapper( functor, offset );
275 std::get< I >( tuple ).hessianEach( x, functorWrapper );
Definition: bindguard.hh:11
static constexpr T max(T a)
Definition: utility.hh:77
static constexpr std::decay_t< T > sum(T a)
Definition: utility.hh:33
Definition: forloop.hh:17
convert functions space to space with new dim range
Definition: functionspace.hh:250
interface class representing a family of shape function sets
Definition: shapefunctionsets.hh:33
Definition: space/shapefunctionset/tuple.hh:26
int order() const
Definition: space/shapefunctionset/tuple.hh:106
std::tuple< ShapeFunctionSets... > shapeFunctionSetTuple_
Definition: space/shapefunctionset/tuple.hh:160
static std::tuple< decltype(makeGeometryType< I >(std::declval< GeometryType >())) ... > makeGeometryTypeTuple(GeometryType type, std::index_sequence< I ... >)
Definition: space/shapefunctionset/tuple.hh:155
TupleShapeFunctionSet(GeometryType type)
Definition: space/shapefunctionset/tuple.hh:84
const SubShapeFunctionSetType< i > & subShapeFunctionSet(std::integral_constant< std::size_t, i >={}) const
Definition: space/shapefunctionset/tuple.hh:129
FunctionSpaceType::JacobianRangeType JacobianRangeType
Definition: space/shapefunctionset/tuple.hh:78
FunctionSpaceType::RangeType RangeType
Definition: space/shapefunctionset/tuple.hh:77
TupleShapeFunctionSet()
Definition: space/shapefunctionset/tuple.hh:81
Offset offset_
Definition: space/shapefunctionset/tuple.hh:161
void evaluateEach(const Point &x, Functor functor) const
Definition: space/shapefunctionset/tuple.hh:111
FunctionSpaceType::DomainType DomainType
Definition: space/shapefunctionset/tuple.hh:76
static GeometryType makeGeometryType(GeometryType type)
Definition: space/shapefunctionset/tuple.hh:148
ToNewDimRangeFunctionSpace< typenameSubShapeFunctionSetType< 0 >::FunctionSpaceType, dimRange >::Type FunctionSpaceType
Definition: space/shapefunctionset/tuple.hh:74
TupleShapeFunctionSet(const std::tuple< ShapeFunctionSets... > &shapeFunctionSetTuple)
Definition: space/shapefunctionset/tuple.hh:99
std::size_t size() const
Definition: space/shapefunctionset/tuple.hh:108
FunctionSpaceType::HessianRangeType HessianRangeType
Definition: space/shapefunctionset/tuple.hh:79
void hessianEach(const Point &x, Functor functor) const
Definition: space/shapefunctionset/tuple.hh:123
std::tuple_element_t< i, std::tuple< ShapeFunctionSets... > > SubShapeFunctionSetType
Definition: space/shapefunctionset/tuple.hh:72
TupleShapeFunctionSet(Args &&... args)
Definition: space/shapefunctionset/tuple.hh:92
int order(std::index_sequence< I ... >) const
Definition: space/shapefunctionset/tuple.hh:136
std::size_t size(std::index_sequence< I ... >) const
Definition: space/shapefunctionset/tuple.hh:142
void jacobianEach(const Point &x, Functor functor) const
Definition: space/shapefunctionset/tuple.hh:117