DUNE-FEM (unstable)

generic.hh
1#ifndef DUNE_FEM_SPACE_COMBINEDSPACE_GENERIC_HH
2#define DUNE_FEM_SPACE_COMBINEDSPACE_GENERIC_HH
3
4#include <algorithm>
5#include <memory>
6
7#include <dune/common/hybridutilities.hh>
8
9#include <dune/fem/space/common/discretefunctionspace.hh>
10#include <dune/fem/space/common/dofmanager.hh>
11
12namespace Dune
13{
14
15 namespace Fem
16 {
17 // GenericCombinedDiscreteFunctionSpace
18 // ------------------------------------
19
20 template< class Traits >
21 class GenericCombinedDiscreteFunctionSpace
22 : public DiscreteFunctionSpaceDefault< Traits >
23 {
24 typedef GenericCombinedDiscreteFunctionSpace< Traits > ThisType;
26
27 typedef typename Traits::DiscreteFunctionSpaceTupleType DiscreteFunctionSpaceTupleType;
28
29 public:
30 // type of i-th contained sub space
31 template< int i >
32 using SubDiscreteFunctionSpace = typename Traits::template SubDiscreteFunctionSpace< i >;
33
36 typedef typename Traits::GridPartType GridPartType;
37 typedef typename Traits::GridType GridType;
38 typedef typename GridPartType::IntersectionType IntersectionType;
40 typedef typename Traits::IndexSetType IndexSetType;
41 typedef typename Traits::IteratorType IteratorType;
43 enum { dimension = GridType::dimension };
44
46 typedef typename Traits::FunctionSpaceType FunctionSpaceType;
47
49 typedef typename Traits::BasisFunctionSetType BasisFunctionSetType;
50
52 typedef typename Traits::BlockMapperType BlockMapperType;
53
55 typedef int IdentifierType;
57 static const IdentifierType id = 669;
58
60 typedef DofManager< GridType > DofManagerType;
61
63 static const InterfaceType defaultInterface = InteriorBorder_All_Interface;
64
66 static const CommunicationDirection defaultDirection = ForwardCommunication;
67 // this ctor is problematic: assume that one space is a DynamicLS
68 // then this constructor uses some default order (=1) silently.
69 // Not sure if we want that.
77 GenericCombinedDiscreteFunctionSpace ( GridPartType &gridPart,
78 const InterfaceType commInterface = defaultInterface,
79 const CommunicationDirection commDirection = defaultDirection )
80 : BaseType( gridPart, commInterface, commDirection ),
81 spaceTuple_( Traits::createSpaces( gridPart, commInterface, commDirection ) ),
82 blockMapper_( Traits::getBlockMapper( spaceTuple_ ) )
83 {}
84
85 protected:
86
87 GenericCombinedDiscreteFunctionSpace ( DiscreteFunctionSpaceTupleType &&spaceTuple )
88 : BaseType(
89 Traits::template SubDiscreteFunctionSpace< 0 >::subDiscreteFunctionSpace( spaceTuple ).gridPart(),
90 Traits::template SubDiscreteFunctionSpace< 0 >::subDiscreteFunctionSpace( spaceTuple ).communicationInterface(),
91 Traits::template SubDiscreteFunctionSpace< 0 >::subDiscreteFunctionSpace( spaceTuple ).communicationDirection() ),
92 spaceTuple_( std::move( spaceTuple ) ),
93 blockMapper_( Traits::getBlockMapper( spaceTuple_ ) )
94 {}
95
96 public:
97
98 GenericCombinedDiscreteFunctionSpace ( const ThisType & ) = delete;
99 ThisType &operator= ( const ThisType & ) = delete;
100
101 using BaseType::gridPart;
102
104 bool contains ( const int codim ) const
105 {
106 // forward to mapper since this information is held there
107 return blockMapper().contains( codim );
108 }
109
111 bool continuous () const
112 {
113 return Traits::accumulate( spaceTuple_, true, [] ( bool c, const auto &s ) { return c && s.continuous(); } );
114 }
115
117 bool continuous ( const IntersectionType &intersection ) const
118 {
119 return Traits::accumulate( spaceTuple_, true, [ &intersection ] ( bool c, const auto &s ) { return c && s.continuous( intersection ); } );
120 }
121
125 DFSpaceIdentifier type () const
126 {
127 return DFSpaceIdentifier( -1 );
128 }
129
131 int order () const
132 {
133 return Traits::accumulate( spaceTuple_, int( 0 ), [] ( int o, const auto &s ) { return std::max( o, s.order() ); } );
134 }
135
137 template< class Entity >
138 int order ( const Entity &entity ) const
139 {
140 return Traits::accumulate( spaceTuple_, int( 0 ), [ &entity ] ( int o, const auto &s ) { return std::max( o, s.order( entity ) ); } );
141 }
142
144 template< class EntityType >
145 BasisFunctionSetType basisFunctionSet ( const EntityType &entity ) const
146 {
147 return Traits::getBasisFunctionSet( entity, spaceTuple_ );
148 }
149
153 BlockMapperType &blockMapper () const
154 {
155 return *blockMapper_;
156 }
157
159 template< int i >
160 const typename SubDiscreteFunctionSpace< i >::Type& subDiscreteFunctionSpace() const
161 {
162 return SubDiscreteFunctionSpace< i >::subDiscreteFunctionSpace( spaceTuple_ );
163 }
164 private:
166 DiscreteFunctionSpaceTupleType spaceTuple_;
167
169 std::unique_ptr< BlockMapperType > blockMapper_;
170 };
171
172 } // namespace Fem
173
174} // namespace Dune
175
176#endif // #ifndef DUNE_FEM_SPACE_COMBINEDSPACE_GENERIC_HH
IntersectionIteratorType::Intersection IntersectionType
type of intersection
Definition: adaptiveleafgridpart.hh:95
int order(const EntityType &entity) const
default implementation of the method order
Definition: discretefunctionspace.hh:748
InterfaceType communicationInterface() const
return the communication interface appropriate for this space
Definition: discretefunctionspace.hh:855
GridPartType & gridPart() const
Definition: discretefunctionspace.hh:766
CommunicationDirection communicationDirection() const
return the communication interface appropriate for this space
Definition: discretefunctionspace.hh:861
A vector valued function space.
Definition: functionspace.hh:60
DFSpaceIdentifier
enumerator for identification of spaces
Definition: discretefunctionspace.hh:95
CommunicationDirection
Define a type for communication direction parameter.
Definition: gridenums.hh:170
InterfaceType
Parameter to be used for the communication functions.
Definition: gridenums.hh:86
@ ForwardCommunication
communicate as given in InterfaceType
Definition: gridenums.hh:171
@ InteriorBorder_All_Interface
send interior and border, receive all entities
Definition: gridenums.hh:88
constexpr T accumulate(Range &&range, T value, F &&f)
Accumulate values.
Definition: hybridutilities.hh:279
Dune namespace.
Definition: alignedallocator.hh:13
constexpr std::bool_constant<((II==value)||...)> contains(std::integer_sequence< T, II... >, std::integral_constant< T, value >)
Checks whether or not a given sequence contains a value.
Definition: integersequence.hh:137
STL namespace.
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Jul 27, 22:29, 2024)