Dune Core Modules (2.3.1)

faceutility.hh
1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2// vi: set et ts=4 sw=2 sts=2:
3#ifndef DUNE_ALU3DGRIDFACEUTILITY_HH
4#define DUNE_ALU3DGRIDFACEUTILITY_HH
5
6#include <dune/geometry/referenceelements.hh>
7
8#include "mappings.hh"
9#include "alu3dinclude.hh"
10#include "topology.hh"
11
12namespace Dune
13{
14
15 // convert FieldVectors to alu3dtypes
16 // only used for calculating the normals because the method of the
17 // mapping classes want double (&)[3] and we have FieldVectors which store an
18 // double [3] this is why we can cast here
19 // plz say notin' Adrian
20 template< int dim >
21 inline alu3d_ctype (&fieldVector2alu3d_ctype ( FieldVector< alu3d_ctype, dim > &val ))[ dim ]
22 {
23 return ((alu3d_ctype (&)[dim])(*( &(val[0])) ));
24 }
25
26 // convert const FieldVectors to const alu3dtypes
27 template< int dim >
28 inline const alu3d_ctype (&fieldVector2alu3d_ctype ( const FieldVector< alu3d_ctype, dim > &val ))[ dim ]
29 {
30 return ((const alu3d_ctype (&)[dim])(*( &(val[0])) ) );
31 }
32
33
34 // * Note: reconsider lazy evaluation of coordinates
35
36 //- class ALU3dGridFaceInfo
37 /* \brief Stores face and adjoining elements of the underlying ALU3dGrid
38 The class has the same notion of inner and outer element as the
39 intersection iterator.
40 */
41 template< ALU3dGridElementType type, class Comm >
42 class ALU3dGridFaceInfo
43 {
44 typedef ALU3dImplTraits< type, Comm > ImplTraits;
45 //- private typedefs
46 typedef typename ImplTraits::HasFaceType HasFaceType;
47 public:
48 enum ConformanceState {CONFORMING, REFINED_INNER, REFINED_OUTER, UNDEFINED };
49 //- typedefs
50 typedef typename ImplTraits::GEOFaceType GEOFaceType;
51 typedef typename ImplTraits::GEOElementType GEOElementType;
52 typedef typename ImplTraits::GEOPeriodicType GEOPeriodicType;
53 typedef typename ImplTraits::IMPLElementType IMPLElementType;
54 typedef typename ImplTraits::GhostPairType GhostPairType;
55 typedef typename ImplTraits::BNDFaceType BNDFaceType;
56
57 public:
59 ALU3dGridFaceInfo( const bool conformingRefinement, const bool ghostCellsEnabled );
60 void updateFaceInfo(const GEOFaceType& face, int innerLevel, int innerTwist);
61
62 //- constructors and destructors
68 ALU3dGridFaceInfo(const GEOFaceType& face, int innerTwist);
69 ALU3dGridFaceInfo(const ALU3dGridFaceInfo &orig);
71 ~ALU3dGridFaceInfo();
72
73 protected:
75 bool isElementLike() const;
76
78 bool innerBoundary() const;
79
80 public:
81 //- queries
84 bool outerBoundary() const;
85
87 bool boundary() const;
88
90 bool neighbor() const ;
91
94 bool ghostBoundary () const;
95
97 const GEOFaceType& face() const;
99 const GEOElementType& innerEntity() const;
102 const GEOElementType& outerEntity() const;
105 const BNDFaceType& innerFace() const;
108 const BNDFaceType& boundaryFace() const;
109
111 int innerTwist() const;
113 int outerTwist() const;
114
116 int duneTwist(const int faceIdx, const int aluTwist) const;
117
119 int innerALUFaceIndex() const;
121 int outerALUFaceIndex() const;
122
123 int outsideLevel() const;
124
126 int segmentIndex() const;
127
129 int boundaryId() const;
130
132 ConformanceState conformanceState() const;
133
135 bool parallel() const {
136 return ! Conversion< Comm, No_Comm > :: sameType ;
137 }
138
140 bool conformingRefinement () const { return conformingRefinement_; }
141
142 private:
144 ConformanceState getConformanceState(const int innerLevel) const;
145
146 //- forbidden methods
147 const ALU3dGridFaceInfo &
148 operator=(const ALU3dGridFaceInfo &orig);
149
150 private:
151
152 //- member data
153 const GEOFaceType* face_;
154 const HasFaceType* innerElement_;
155 const HasFaceType* outerElement_;
156
157 int innerFaceNumber_;
158 int outerFaceNumber_;
159
160 int innerTwist_;
161 int outerTwist_;
162
163 int segmentIndex_;
164 int bndId_;
165
166 enum boundary_t { noBoundary = 0, // no boundary, outside is normal element
167 periodicBoundary = 1, // periodic boundary
168 innerGhostBoundary = 2, // process boundary, inside is ghost, outside is normal element
169 domainBoundary = 3, // boundary with domain, no outside
170 outerGhostBoundary = 4}; // process boundary, outside might be ghost
171
172 boundary_t bndType_;
173
174 ConformanceState conformanceState_;
175 const bool conformingRefinement_ ; // true if conforming refinement is enabled
176 const bool ghostCellsEnabled_ ; // true if ghost cells are present
177 };
178
179
180 // ALU3dGridSurfaceMappingFactory
181 // ------------------------------
182
183 template< ALU3dGridElementType type, class Comm >
184 struct ALU3dGridSurfaceMappingFactory;
185
186 template< class Comm >
187 struct ALU3dGridSurfaceMappingFactory< tetra, Comm >
188 {
189 // this is the original ALUGrid LinearSurfaceMapping,
190 // see mapp_tetra_3d.* in ALUGrid code
191 typedef ALU3DSPACE LinearSurfaceMapping SurfaceMappingType;
192 typedef typename ALU3dGridFaceInfo< tetra, Comm >::GEOFaceType GEOFaceType;
193
194 static const int numVerticesPerFace = EntityCount< tetra >::numVerticesPerFace;
195
196 typedef FieldMatrix< alu3d_ctype, numVerticesPerFace, 3 > CoordinateType;
197
198 // old method, copies values for tetra twice
199 SurfaceMappingType *buildSurfaceMapping ( const CoordinateType &coords ) const;
200 // get face but doesn't copy values twice
201 SurfaceMappingType *buildSurfaceMapping ( const GEOFaceType &face ) const;
202 };
203
204 template< class Comm >
205 struct ALU3dGridSurfaceMappingFactory< hexa, Comm >
206 {
207 typedef BilinearSurfaceMapping SurfaceMappingType;
208 typedef typename ALU3dGridFaceInfo< hexa, Comm >::GEOFaceType GEOFaceType;
209
210 static const int numVerticesPerFace = EntityCount< hexa >::numVerticesPerFace;
211
212 typedef FieldMatrix< alu3d_ctype, numVerticesPerFace, 3 > CoordinateType;
213
214 // old method, copies values for tetra twice
215 SurfaceMappingType *buildSurfaceMapping ( const CoordinateType &coords ) const;
216 // get face but doesn't copy values twice
217 SurfaceMappingType *buildSurfaceMapping ( const GEOFaceType &face ) const;
218 };
219
220
221
222 // ALU3dGridGeometricFaceInfoBase
223 // ------------------------------
224
227 template< ALU3dGridElementType type, class Comm >
229 : public ALU3dGridSurfaceMappingFactory< type, Comm >
230 {
231 typedef ALU3dGridSurfaceMappingFactory< type, Comm > Base;
232
233 public:
237
238 // type of container for reference elements
240 // type of container for reference faces
242
243 // type of reference element
245 // type of reference face
247
248 enum SideIdentifier { INNER, OUTER };
249 enum { dimworld = 3 }; // ALU is a pure 3d grid
250 enum { numVerticesPerFace =
251 EntityCount<type>::numVerticesPerFace };
252
253 //- public typedefs
255 typedef FieldMatrix<alu3d_ctype,
256 numVerticesPerFace,
257 dimworld> CoordinateType;
258
259 typedef typename ALU3dGridFaceInfo< type, Comm >::GEOFaceType GEOFaceType;
260
261 public:
262 typedef ALU3dGridFaceInfo< type, Comm > ConnectorType;
263
264 //- constructors and destructors
265 ALU3dGridGeometricFaceInfoBase(const ConnectorType &);
267
270
271 //- functions
272 const CoordinateType& intersectionSelfLocal() const;
273 const CoordinateType& intersectionNeighborLocal() const;
274
275 private:
276 //- forbidden methods
278
279 private:
280 //- private methods
281 void generateLocalGeometries() const;
282
283 int globalVertexIndex(const int duneFaceIndex,
284 const int faceTwist,
285 const int duneFaceVertexIndex) const;
286
287 void referenceElementCoordinatesRefined(SideIdentifier side,
288 CoordinateType& result) const;
289 void referenceElementCoordinatesUnrefined(SideIdentifier side,
290 CoordinateType& result) const;
291
292 protected:
293 //- private data
294 const ConnectorType& connector_;
295
296 mutable CoordinateType coordsSelfLocal_;
297 mutable CoordinateType coordsNeighborLocal_;
298
299 mutable bool generatedGlobal_;
300 mutable bool generatedLocal_;
301
302 inline static const ReferenceElementType& getReferenceElement()
303 {
304 return (type == tetra) ?
307 }
308
309 inline static const ReferenceFaceType& getReferenceFace()
310 {
311 return (type == tetra) ?
313 ReferenceFaceContainerType :: cube();
314 }
315 };
316
319 template< class Comm >
321 : public ALU3dGridGeometricFaceInfoBase< tetra, Comm >
322 {
324
325 public:
326 //- public typedefs
328 typedef typename Base::FaceTopo FaceTopo;
329 typedef typename ALU3dGridFaceInfo< tetra, Comm >::GEOFaceType GEOFaceType;
330
331 typedef ALU3dGridFaceInfo< tetra, Comm > ConnectorType;
332
333 //- constructors and destructors
334 ALU3dGridGeometricFaceInfoTetra(const ConnectorType& ctor);
336
337 NormalType & outerNormal(const FieldVector<alu3d_ctype, 2>& local) const;
338
341
343 template <class GeometryImp>
344 void buildGlobalGeom(GeometryImp& geo) const;
345
346 private:
347 //- forbidden methods
349
350 protected:
351 using Base::connector_;
352
353 private:
354 //- private data
355 mutable NormalType outerNormal_;
356
357 // false if surface mapping needs a update
358 mutable bool normalUp2Date_;
359 };
360
363 template< class Comm >
365 : public ALU3dGridGeometricFaceInfoBase< hexa, Comm >
366 {
368
369 public:
370 //- public typedefs
372 typedef typename Base::FaceTopo FaceTopo;
373 typedef typename ALU3dGridFaceInfo< hexa, Comm >::GEOFaceType GEOFaceType;
375
376 typedef ALU3dGridFaceInfo< hexa, Comm > ConnectorType;
377
378 //- constructors and destructors
379 ALU3dGridGeometricFaceInfoHexa(const ConnectorType &);
381
382 NormalType & outerNormal(const FieldVector<alu3d_ctype, 2>& local) const;
383
386
388 template <class GeometryImp>
389 void buildGlobalGeom(GeometryImp& geo) const;
390
391 private:
392 //- forbidden methods
394
395 protected:
396 using Base::connector_;
397
398 private:
399 //- private data
400 mutable NormalType outerNormal_;
401
402 // surface mapping for calculating the outer normal
403 mutable SurfaceMappingType mappingGlobal_;
404
405 // false if surface mapping needs a update
406 mutable bool mappingGlobalUp2Date_;
407 };
408
409} // end namespace Dune
410
411#include "faceutility_imp.cc"
412
413#endif
Definition: faceutility.hh:230
void resetFaceGeom()
reset status of faceGeomInfo
Definition: faceutility.hh:366
void buildGlobalGeom(GeometryImp &geo) const
update global geometry
void resetFaceGeom()
reset status of faceGeomInfo
Definition: faceutility.hh:322
void buildGlobalGeom(GeometryImp &geo) const
update global geometry
void resetFaceGeom()
reset status of faceGeomInfo
Definition: topology.hh:41
Definition: topology.hh:126
A dense n x m matrix.
Definition: fmatrix.hh:67
Definition: mappings.hh:387
This class provides access to geometric and topological properties of a reference element....
Definition: referenceelements.hh:58
A bilinear surface mapping.
Definition: mappings.hh:90
Dune namespace.
Definition: alignment.hh:14
Class providing access to the singletons of the reference elements. Special methods are available for...
Definition: referenceelements.hh:563
static const ReferenceElement< ctype, dim > & simplex()
get simplex reference elements
Definition: referenceelements.hh:574
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Jul 15, 22:36, 2024)