DUNE-FEM (unstable)

allgeomtypes.hh
1#ifndef DUNE_FEM_ALLGEOMTYPES_HH
2#define DUNE_FEM_ALLGEOMTYPES_HH
3
4//- system includes
5#include <vector>
6#include <set>
7
8//- Dune includes
9#include <dune/fem/common/forloop.hh>
10#include <dune/geometry/referenceelements.hh>
11#include <dune/geometry/type.hh>
13
14namespace Dune
15{
16
17 // External Forward Declarations
18 // -----------------------------
19
20 namespace Fem
21 {
22
23 // GeometryInformation
24 // -------------------
25
28 template< class GridImp, int codim >
30 {
32
33 public:
35 typedef GridImp GridType;
36
38 static const int dim = GridType::dimension - codim;
39
41 typedef typename GridType::ctype ctype;
42
43 protected:
45
46 public:
48 typedef std::decay_t< decltype( ReferenceElementsType::general( std::declval< const GeometryType & >() ) ) > ReferenceElementType;
49
52
53 protected:
55 GeometryInformation () : isNoneLocalCenter_( 0.5 )
56 {}
57
58 public:
60 explicit GeometryInformation( const std::vector< GeometryType > &geomTypes )
61 {
62 buildMaps( geomTypes );
63 }
64
66 const DomainType localCenter ( const GeometryType &type ) const
67 {
68 return type.isNone() ? isNoneLocalCenter_ : referenceElement( type ).position( 0, 0 );
69 }
70
72 ctype referenceVolume ( const GeometryType &type ) const
73 {
74 return type.isNone() ? ctype(1.0) : referenceElement( type ).volume();
75 }
76
78 static auto referenceElement ( const GeometryType &type )
79 -> decltype( ReferenceElementsType::general( type ) )
80 {
81 assert( ! type.isNone() );
82 return ReferenceElementsType::general( type );
83 }
84
85 protected:
86 DomainType isNoneLocalCenter_;
87
89 void buildMaps ( const std::vector< GeometryType > &geomTypes )
90 {}
91 };
92
93
97 template< class IndexSetImp, class GridImp >
98 class AllGeomTypes : public GeometryInformation< GridImp , 0>
99 {
100 public:
101 typedef IndexSetImp IndexSetType;
102 typedef GridImp GridType;
103
104 private:
106 static const unsigned int ncodim = GridType :: dimension + 1;
107
108 protected:
109 std::vector< std::vector< GeometryType > > geomTypes_;
110
111 public:
112 // insert all types of the reference element into the geomTypes list
113 template <int dim>
114 struct InsertGeometryTypes
115 {
116 static void apply( std::vector< std::set< GeometryType > >& geomTypes )
117 {
118 static const int codim = GridType :: dimension - dim ;
119 typedef Dune::ReferenceElements< typename GridType :: ctype, dim > ReferenceElementContainer ;
120 typedef typename ReferenceElementContainer :: Iterator Iterator ;
121 for( Iterator it = ReferenceElementContainer::begin(),
122 end = ReferenceElementContainer::end(); it != end; ++it )
123 {
124 geomTypes[ codim ].insert( it->type() );
125 }
126 }
127 };
128
130 inline explicit AllGeomTypes( const IndexSetType &indexSet )
131 : geomTypes_( ncodim )
132 {
133 if( multipleGeomTypes() )
134 {
135 std::vector< std::set< GeometryType > > geomTypes( ncodim );
136
137 // store all possible geom types
138 Fem::ForLoop< InsertGeometryTypes, 0, GridType::dimension > :: apply( geomTypes );
139
140 auto types = indexSet.types( 0 );
141 for( const auto type : types )
142 {
143 geomTypes[ 0 ].insert( type );
144 }
145
146 for( unsigned int cd=0; cd < ncodim; ++cd )
147 {
148 geomTypes_[ cd ].reserve( geomTypes[ cd ].size() );
149 for( const auto& type : geomTypes[ cd ] )
150 {
151 geomTypes_[ cd ].push_back( type );
152 }
153 }
154 }
155 else
156 {
157 // single geometry type
158 for( int codim=0; codim<GridType::dimension+1; ++codim )
159 {
160 typename IndexSetType::Types types = indexSet.types( codim );
161 const int size = types.size();
162 geomTypes_[ codim ].resize( size );
163 std::copy_n( types.begin(), size, geomTypes_[ codim ].begin() );
164 }
165 // build geometry information for codim 0
166 this->buildMaps( geomTypes_[ 0 ] );
167 }
168 }
169
171 const std :: vector< GeometryType > &geomTypes ( unsigned int codim ) const
172 {
173 assert( codim < ncodim );
174 return geomTypes_[ codim ];
175 }
176
178 static bool multipleGeomTypes ()
179 {
180 return !Dune::Capabilities :: hasSingleGeometryType < GridType > :: v;
181 }
182 };
183
184 } // namespace Fem
185
186} // namespace Dune
187
188#endif // #ifndef DUNE_FEM_ALLGEOMTYPES_HH
default implementation uses method geomTypes of given index set. Used in DiscreteFunctionSpaces.
Definition: allgeomtypes.hh:99
static bool multipleGeomTypes()
UGGrid might have different geom types.
Definition: allgeomtypes.hh:178
const std ::vector< GeometryType > & geomTypes(unsigned int codim) const
returns vector with geometry tpyes this index set has indices for
Definition: allgeomtypes.hh:171
AllGeomTypes(const IndexSetType &indexSet)
constructor storing index set reference
Definition: allgeomtypes.hh:130
ReferenceVolume and local bary center keeper class.
Definition: allgeomtypes.hh:30
GridType::ctype ctype
coordinate type
Definition: allgeomtypes.hh:41
GeometryInformation()
constructor creating empty geometry information
Definition: allgeomtypes.hh:55
const DomainType localCenter(const GeometryType &type) const
return local bary center for geometry of type type
Definition: allgeomtypes.hh:66
void buildMaps(const std::vector< GeometryType > &geomTypes)
build maps
Definition: allgeomtypes.hh:89
ctype referenceVolume(const GeometryType &type) const
return volume of reference element for geometry of type type
Definition: allgeomtypes.hh:72
static auto referenceElement(const GeometryType &type) -> decltype(ReferenceElementsType::general(type))
return reference element for type
Definition: allgeomtypes.hh:78
static const int dim
dimension
Definition: allgeomtypes.hh:38
GeometryInformation(const std::vector< GeometryType > &geomTypes)
creating geometry information due to given geometry types list
Definition: allgeomtypes.hh:60
std::decay_t< decltype(ReferenceElementsType::general(std::declval< const GeometryType & >())) > ReferenceElementType
type of reference element
Definition: allgeomtypes.hh:48
GridImp GridType
grid type
Definition: allgeomtypes.hh:35
FieldVector< ctype, dim > DomainType
type of domain vector
Definition: allgeomtypes.hh:51
Unique label for each type of entities that can occur in DUNE grids.
Definition: type.hh:114
constexpr bool isNone() const
Return true if entity is a singular of any dimension.
Definition: type.hh:355
A set of traits classes to store static information about grid implementation.
Dune namespace.
Definition: alignedallocator.hh:13
constexpr std::integral_constant< std::size_t, sizeof...(II)> size(std::integer_sequence< T, II... >)
Return the size of the sequence.
Definition: integersequence.hh:75
Class providing access to the singletons of the reference elements.
Definition: referenceelements.hh:128
static const ReferenceElement & general(const GeometryType &type)
get general reference elements
Definition: referenceelements.hh:156
A unique label for each type of element that can occur in a grid.
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Nov 21, 23:30, 2024)