1 #ifndef DUNE_FEM_SPACE_COMBINEDSPACE_TUPLESPACE_HH 2 #define DUNE_FEM_SPACE_COMBINEDSPACE_TUPLESPACE_HH 7 #include <dune/common/math.hh> 8 #include <dune/common/typetraits.hh> 9 #include <dune/grid/common/grid.hh> 28 template<
class ... DiscreteFunctionSpaces >
35 template<
class ... DiscreteFunctionSpaces >
38 static_assert(
sizeof ... ( DiscreteFunctionSpaces ) > 0,
39 "You should provide at least one space to the TupleDiscreteFunctionSpace" );
49 template<
class Tuple,
class ... Args >
50 static void apply ( Tuple &tuple, Args && ... args )
52 typedef typename std::remove_pointer< typename std::tuple_element< i, Tuple >::type >::type Element;
53 std::get< i >( tuple ) =
new Element( std::forward< Args >( args ) ... );
60 template<
class Tuple >
61 static void apply ( Tuple &tuple ) {
delete std::get< i >( tuple ); }
71 typedef typename std::remove_pointer< typename std::tuple_element< i, DiscreteFunctionSpaceTupleType >::type >::type
Type;
82 assert( std::get< i >( tuple ) );
83 return *( std::get< i >( tuple ) );
88 return subDiscreteFunctionSpace( tuple ).blockMapper();
93 return NonBlockMapperType( subDiscreteFunctionSpace( tuple ).blockMapper() );
97 static_assert(
Std::are_all_same< std::integral_constant< int, DiscreteFunctionSpaces::Traits::codimension > ... >::value,
98 "TupleDiscreteFunctionSpace for spaces with different codimensions is not supported" );
99 static const int codimension = SubDiscreteFunctionSpace< 0 >::Type::Traits::codimension;
102 "TupleDiscreteFunctionSpace works only for common GridPartTypes" );
104 typedef typename SubDiscreteFunctionSpace< 0 >::Type::GridPartType
GridPartType;
107 typedef typename GridPartType::template Codim< 0 >::IteratorType
IteratorType;
129 template<
class DiscreteFunction,
143 return getBlockMapper( spaceTuple, Std::index_sequence_for< DiscreteFunctionSpaces ... >() );
154 CommunicationDirection commDirection )
157 ForLoop< Constructor, 0,
sizeof ... ( DiscreteFunctionSpaces ) -1 >::
apply( tuple, gridPart, commInterface, commDirection );
164 ForLoop< Deleter, 0,
sizeof ... ( DiscreteFunctionSpaces ) -1 >::
apply( tuple );
167 template<
class Entity >
170 return getBasisFunctionSet( entity, tuple, Std::index_sequence_for< DiscreteFunctionSpaces ... >() );
175 return continuous( tuple, Std::index_sequence_for< DiscreteFunctionSpaces ... >() );
180 return continuous( tuple, intersection, Std::index_sequence_for< DiscreteFunctionSpaces ... >() );
184 template< std::size_t ... i >
191 template<
class Entity, std::size_t ... i >
193 Std::index_sequence< i ... > )
198 template< std::size_t ... i >
204 template< std::size_t ... i >
225 template<
class ... DiscreteFunctionSpaces >
245 const InterfaceType commInterface = InteriorBorder_All_Interface,
246 const CommunicationDirection commDirection = ForwardCommunication )
247 :
BaseType( gridPart, commInterface, commDirection )
255 std::tuple<
const DiscreteFunctionSpaces & ... >
spaceTuple ()
const 257 return spaceTuple( Std::index_sequence_for< DiscreteFunctionSpaces ... >() );
261 template< std::size_t ... i >
262 std::tuple<
const DiscreteFunctionSpaces & ... >
spaceTuple ( Std::index_sequence< i ... > )
const 264 return std::tuple<
const DiscreteFunctionSpaces & ... >( BaseType::template subDiscreteFunctionSpace< i >() ... );
272 template<
class ... DiscreteFunctionSpaces >
292 #endif // #ifndef DUNE_FEM_SPACE_COMBINEDSPACE_TUPLESPACE_HH static constexpr int polynomialOrder
Definition: tuplespace.hh:126
TupleMapper< GridPartType, NonBlockMapper< typename DiscreteFunctionSpaces::BlockMapperType, DiscreteFunctionSpaces::localBlockSize >... > BlockMapperType
Definition: tuplespace.hh:118
Definition: tuplespace.hh:273
Definition: tuplespace.hh:29
GridPartType::IntersectionType IntersectionType
Definition: tuplespace.hh:109
std::tuple< DiscreteFunctionSpaces *... > DiscreteFunctionSpaceTupleType
Definition: tuplespace.hh:39
static void apply(Tuple &tuple)
Definition: tuplespace.hh:61
Definition: utility.hh:135
static BasisFunctionSetType getBasisFunctionSet(const Entity &entity, const DiscreteFunctionSpaceTupleType &tuple)
Definition: tuplespace.hh:168
Definition: tuplespace.hh:47
A vector valued function space.
Definition: functionspace.hh:16
GridPartType::IndexSetType IndexSetType
Definition: tuplespace.hh:106
Traits::GridPartType GridPartType
Definition: tuplespace.hh:236
Default communication handler for discrete functions.
Definition: defaultcommhandler.hh:23
static constexpr T max(T a)
Definition: utility.hh:65
BasisFunctionSetType::FunctionSpaceType FunctionSpaceType
Definition: tuplespace.hh:124
static void deleteSpaces(DiscreteFunctionSpaceTupleType &tuple)
Definition: tuplespace.hh:162
static NonBlockMapperType subNonBlockMapper(const DiscreteFunctionSpaceTupleType &tuple)
Definition: tuplespace.hh:91
static BlockMapperType * getBlockMapper(const DiscreteFunctionSpaceTupleType &spaceTuple)
Definition: tuplespace.hh:141
Definition: tuplespace.hh:58
static const int codimension
Definition: tuplespace.hh:99
Definition: tuplespace.hh:121
static DiscreteFunctionSpaceTupleType createSpaces(GridPartType &gridPart, InterfaceType commInterface, CommunicationDirection commDirection)
Definition: tuplespace.hh:153
static BlockMapperType * getBlockMapper(const DiscreteFunctionSpaceTupleType &tuple, Std::index_sequence< i... >)
Definition: tuplespace.hh:185
mapper allocating one DoF per subentity of a given codimension
Definition: tuplemapper.hh:28
Operation OperationType
type of operatation to perform on scatter
Definition: tuplespace.hh:136
static BlockMapperType & subBlockMapper(const DiscreteFunctionSpaceTupleType &tuple)
Definition: tuplespace.hh:86
DefaultLocalRestrictProlong(const DiscreteFunctionSpacesType &space)
Definition: tuplespace.hh:281
Definition: nonblockmapper.hh:19
GridPartType::GridType GridType
Definition: tuplespace.hh:105
static bool continuous(const DiscreteFunctionSpaceTupleType &tuple)
Definition: tuplespace.hh:173
static void apply(Tuple &tuple, Args &&...args)
Definition: tuplespace.hh:50
std::tuple< const DiscreteFunctionSpaces &... > spaceTuple(Std::index_sequence< i... >) const
Definition: tuplespace.hh:262
Type::BlockMapperType BlockMapperType
Definition: tuplespace.hh:74
Definition: tuplelocalrestrictprolong.hh:32
Definition: coordinate.hh:4
std::remove_pointer< typename std::tuple_element< i, DiscreteFunctionSpaceTupleType >::type >::type Type
Definition: tuplespace.hh:71
static bool continuous(const IntersectionType &intersection, const DiscreteFunctionSpaceTupleType &tuple)
Definition: tuplespace.hh:178
just copy data
Definition: commoperations.hh:263
Definition: basisfunctionset/tuple.hh:31
Definition: tuplespace.hh:68
Definition: tuplespace.hh:131
IteratorType::Entity EntityType
Definition: tuplespace.hh:108
TupleBasisFunctionSet< typename DiscreteFunctionSpaces::BasisFunctionSetType... > BasisFunctionSetType
implementation of basefunction set
Definition: tuplespace.hh:115
static bool continuous(const DiscreteFunctionSpaceTupleType &tuple, const IntersectionType &intersection, Std::index_sequence< i... >)
Definition: tuplespace.hh:205
SubDiscreteFunctionSpace< 0 >::Type::GridPartType GridPartType
Definition: tuplespace.hh:102
DefaultCommunicationHandler< DiscreteFunction, Operation > Type
type of data handle
Definition: tuplespace.hh:134
static void deleteBlockMapper(BlockMapperType *blockMapper)
Definition: tuplespace.hh:147
static const Type & subDiscreteFunctionSpace(const DiscreteFunctionSpaceTupleType &tuple)
Definition: tuplespace.hh:80
Definition: tuplespace.hh:36
Definition: common/localrestrictprolong.hh:16
GridPartType::template Codim< 0 >::IteratorType IteratorType
Definition: tuplespace.hh:107
static bool continuous(const DiscreteFunctionSpaceTupleType &tuple, Std::index_sequence< i... >)
Definition: tuplespace.hh:199
TupleDiscreteFunctionSpace< DiscreteFunctionSpaces... > DiscreteFunctionSpaceType
Definition: tuplespace.hh:112
std::tuple< const DiscreteFunctionSpaces &... > spaceTuple() const
return tuple of const References to the contained sub spaces
Definition: tuplespace.hh:255
static constexpr bool And(bool a)
Definition: utility.hh:113
TupleDiscreteFunctionSpace(GridPartType &gridPart, const InterfaceType commInterface=InteriorBorder_All_Interface, const CommunicationDirection commDirection=ForwardCommunication)
constructor
Definition: tuplespace.hh:244
NonBlockMapper< BlockMapperType, Type::localBlockSize > NonBlockMapperType
Definition: tuplespace.hh:77
Definition: combinedspace/generic.hh:24
static BasisFunctionSetType getBasisFunctionSet(const Entity &entity, const DiscreteFunctionSpaceTupleType &tuple, Std::index_sequence< i... >)
Definition: tuplespace.hh:192