Dune Core Modules (2.9.0)

faceutility.hh
1#ifndef DUNE_ALU3DGRIDFACEUTILITY_HH
2#define DUNE_ALU3DGRIDFACEUTILITY_HH
3
4#include <type_traits>
5#include <utility>
6
7#include <dune/geometry/referenceelements.hh>
8
9#include "mappings.hh"
10#include "alu3dinclude.hh"
11#include "topology.hh"
12
13namespace Dune
14{
15
16 // convert FieldVectors to alu3dtypes
17 // only used for calculating the normals because the method of the
18 // mapping classes want double (&)[3] and we have FieldVectors which store an
19 // double [3] this is why we can cast here
20 // plz say notin' Adrian
21 template< int dim >
22 inline alu3d_ctype (&fieldVector2alu3d_ctype ( FieldVector< alu3d_ctype, dim > &val ))[ dim ]
23 {
24 return ((alu3d_ctype (&)[dim]) (*( &(val[0])) ));
25 }
26
27 // convert const FieldVectors to const alu3dtypes
28 template< int dim >
29 inline const alu3d_ctype (&fieldVector2alu3d_ctype ( const FieldVector< alu3d_ctype, dim > &val ))[ dim ]
30 {
31 return ((const alu3d_ctype (&)[dim]) (*( &(val[0])) ) );
32 }
33
34
35 // * Note: reconsider lazy evaluation of coordinates
36
37 //- class ALU3dGridFaceInfo
38 /* \brief Stores face and adjoining elements of the underlying ALU3dGrid
39 The class has the same notion of inner and outer element as the
40 intersection iterator.
41 */
42 template< int dim, int dimworld, ALU3dGridElementType type, class Comm >
43 class ALU3dGridFaceInfo
44 {
45 typedef ALU3dImplTraits< type, Comm > ImplTraits;
46 //- private typedefs
47 typedef typename ImplTraits::HasFaceType HasFaceType;
48 public:
49 enum ConformanceState {CONFORMING, REFINED_INNER, REFINED_OUTER, UNDEFINED };
50 //- typedefs
51 typedef typename ImplTraits::GEOFaceType GEOFaceType;
52 typedef typename ImplTraits::GEOElementType GEOElementType;
53 typedef typename ImplTraits::GEOPeriodicType GEOPeriodicType;
54 typedef typename ImplTraits::IMPLElementType IMPLElementType;
55 typedef typename ImplTraits::GhostPairType GhostPairType;
56 typedef typename ImplTraits::BNDFaceType BNDFaceType;
57
58 public:
60 ALU3dGridFaceInfo( const bool levelIntersection = false );
61 void updateFaceInfo(const GEOFaceType& face, int innerLevel, int innerTwist);
62
63 //- constructors and destructors
69 ALU3dGridFaceInfo(const GEOFaceType& face, int innerTwist);
70 ALU3dGridFaceInfo(const ALU3dGridFaceInfo &orig);
72 ~ALU3dGridFaceInfo();
73
74 protected:
76 bool isElementLike() const;
77
78 public:
79 //- queries
81 bool innerBoundary() const;
82
85 bool outerBoundary() const;
86
88 bool boundary() const;
89
91 bool neighbor() const ;
92
95 bool ghostBoundary () const;
96
98 const GEOFaceType& face() const;
100 const GEOElementType& innerEntity() const;
103 const GEOElementType& outerEntity() const;
106 const BNDFaceType& innerFace() const;
109 const BNDFaceType& boundaryFace() const;
110
112 int innerTwist() const;
114 int outerTwist() const;
115
117 int duneTwist(const int faceIdx, const int aluTwist) const;
118
120 int innerALUFaceIndex() const;
122 int outerALUFaceIndex() const;
123
124 int outsideLevel() const;
125
127 int segmentId() const;
128
130 int boundaryId() const;
131
133 ConformanceState conformanceState() const;
134
136 bool parallel() const { return !std::is_same< Comm, ALUGridNoComm >::value; }
137
139 bool conformingRefinement () const { return conformingRefinement_; }
140
142 bool ghostCellsEnabled () const { return ghostCellsEnabled_; }
143
145 void setFlags( const bool conformingRefinement, const bool ghostCellsEnabled );
146
147 private:
149 ConformanceState getConformanceState(const int innerLevel) const;
150
151 //- forbidden methods
152 const ALU3dGridFaceInfo &
153 operator=(const ALU3dGridFaceInfo &orig);
154
155 private:
156
157 //- member data
158 const GEOFaceType* face_;
159 const HasFaceType* innerElement_;
160 const HasFaceType* outerElement_;
161
162 int innerFaceNumber_;
163 int outerFaceNumber_;
164
165 int innerTwist_;
166 int outerTwist_;
167
168 mutable int segmentId_;
169 int bndId_;
170
171 enum boundary_t { noBoundary = 0, // no boundary, outside is normal element
172 periodicBoundary = 1, // periodic boundary
173 innerGhostBoundary = 2, // process boundary, inside is ghost, outside is normal element
174 domainBoundary = 3, // boundary with domain, no outside
175 outerGhostBoundary = 4};// process boundary, outside might be ghost
176
177 boundary_t bndType_;
178
179 ConformanceState conformanceState_;
180 bool conformingRefinement_ ; // true if conforming refinement is enabled
181 bool ghostCellsEnabled_ ; // true if ghost cells are present
182 const bool levelIntersection_ ; // true if called from a levelintersection iterator
183 };
184
185
186 // ALU3dGridSurfaceMappingFactory
187 // ------------------------------
188
189 template< int dim, int dimworld, ALU3dGridElementType type, class Comm >
190 struct ALU3dGridSurfaceMappingFactory;
191
192 template< int dim, int dimworld, class Comm >
193 struct ALU3dGridSurfaceMappingFactory< dim, dimworld, tetra, Comm >
194 {
195 // this is the original ALUGrid LinearSurfaceMapping,
196 // see mapp_tetra_3d.* in ALUGrid code
197 typedef ALU3DSPACE LinearSurfaceMapping SurfaceMappingType;
198 typedef typename ALU3dGridFaceInfo< dim, dimworld, tetra, Comm >::GEOFaceType GEOFaceType;
199
200 static const int numVerticesPerFace = EntityCount< tetra >::numVerticesPerFace;
201
202 typedef FieldMatrix< alu3d_ctype, numVerticesPerFace, 3 > CoordinateType;
203
204 // old method, copies values for tetra twice
205 SurfaceMappingType *buildSurfaceMapping ( const CoordinateType &coords ) const;
206 // get face but doesn't copy values twice
207 SurfaceMappingType *buildSurfaceMapping ( const GEOFaceType &face ) const;
208 };
209
210 template< int dim, int dimworld, class Comm >
211 struct ALU3dGridSurfaceMappingFactory< dim, dimworld, hexa, Comm >
212 {
213 typedef BilinearSurfaceMapping SurfaceMappingType;
214 typedef typename ALU3dGridFaceInfo< dim, dimworld, hexa, Comm >::GEOFaceType GEOFaceType;
215
216 static const int numVerticesPerFace = EntityCount< hexa >::numVerticesPerFace;
217
218 typedef FieldMatrix< alu3d_ctype, numVerticesPerFace, 3 > CoordinateType;
219
220 // old method, copies values for tetra twice
221 SurfaceMappingType *buildSurfaceMapping ( const CoordinateType &coords ) const;
222 // get face but doesn't copy values twice
223 SurfaceMappingType *buildSurfaceMapping ( const GEOFaceType &face ) const;
224 };
225
226
227
228 // ALU3dGridGeometricFaceInfoBase
229 // ------------------------------
230
233 template< int dim, int dimworld, ALU3dGridElementType type, class Comm >
235 : public ALU3dGridSurfaceMappingFactory< dim, dimworld, type, Comm >
236 {
237 typedef ALU3dGridSurfaceMappingFactory< dim, dimworld, type, Comm > Base;
238
239 public:
243
244 // type of container for reference elements
246 // type of container for reference faces
248
249 // type of reference element
250 typedef std::decay_t< decltype( ReferenceElementContainerType::general( std::declval< const Dune::GeometryType & >() ) ) > ReferenceElementType;
251 // type of reference face
252 typedef std::decay_t< decltype( ReferenceFaceContainerType::general( std::declval< const Dune::GeometryType & >() ) ) > ReferenceFaceType;
253
254 enum SideIdentifier { INNER, OUTER };
255 enum { numVerticesPerFace =
256 EntityCount<type>::numVerticesPerFace };
257
258 //- public typedefs
260 typedef FieldMatrix<alu3d_ctype,
261 numVerticesPerFace,
262 dimworld> CoordinateType;
263
264 typedef typename ALU3dGridFaceInfo< dim, dimworld, type, Comm >::GEOFaceType GEOFaceType;
265
266 public:
267 typedef ALU3dGridFaceInfo< dim, dimworld, type, Comm > ConnectorType;
268
269 //- constructors and destructors
270 ALU3dGridGeometricFaceInfoBase(const ConnectorType &);
272
274 void resetFaceGeom();
275
276 //- functions
277 const CoordinateType& intersectionSelfLocal() const;
278 const CoordinateType& intersectionNeighborLocal() const;
279
280 private:
281 //- forbidden methods
283
284 private:
285 //- private methods
286 void generateLocalGeometries() const;
287
288 int globalVertexIndex(const int duneFaceIndex,
289 const int faceTwist,
290 const int duneFaceVertexIndex) const;
291
292 void referenceElementCoordinatesRefined(SideIdentifier side,
293 CoordinateType& result) const;
294 void referenceElementCoordinatesUnrefined(SideIdentifier side,
295 CoordinateType& result) const;
296
297 protected:
298 //- private data
299 const ConnectorType& connector_;
300
301 std::array< FieldVector< alu3d_ctype, 2 >, type == tetra ? 3 : 4 > childLocal_;
302
303 mutable CoordinateType coordsSelfLocal_;
304 mutable CoordinateType coordsNeighborLocal_;
305
306 mutable bool generatedGlobal_;
307 mutable bool generatedLocal_;
308
309 inline static const ReferenceElementType& getReferenceElement()
310 {
311
312 return (type == tetra) ?
315 }
316 };
317
320 template< int dim, int dimworld, class Comm >
322 : public ALU3dGridGeometricFaceInfoBase< dim, dimworld, tetra, Comm >
323 {
325
326 public:
327 //- public typedefs
329 typedef typename Base::FaceTopo FaceTopo;
330 typedef typename ALU3dGridFaceInfo< dim, dimworld, tetra, Comm >::GEOFaceType GEOFaceType;
331
332 typedef ALU3dGridFaceInfo< dim, dimworld, tetra, Comm > ConnectorType;
333
334 //- constructors and destructors
335 ALU3dGridGeometricFaceInfoTetra(const ConnectorType& ctor);
337
338 NormalType & outerNormal(const FieldVector<alu3d_ctype, 2>& local) const;
339
341 void resetFaceGeom();
342
344 template <class GeometryImp>
345 void buildGlobalGeom(GeometryImp& geo) const;
346
347 private:
348 //- forbidden methods
350
351 protected:
352 using Base::connector_;
353
354 private:
355 //- private data
356 mutable NormalType outerNormal_;
357
358 // false if surface mapping needs a update
359 mutable bool normalUp2Date_;
360 };
361
364 template< int dim, int dimworld, class Comm >
366 : public ALU3dGridGeometricFaceInfoBase< dim, dimworld, hexa, Comm >
367 {
369
370 public:
371 //- public typedefs
373 typedef typename Base::FaceTopo FaceTopo;
374 typedef typename ALU3dGridFaceInfo< dim, dimworld, hexa, Comm >::GEOFaceType GEOFaceType;
376
377 typedef ALU3dGridFaceInfo< dim, dimworld, hexa, Comm > ConnectorType;
378
379 //- constructors and destructors
380 ALU3dGridGeometricFaceInfoHexa(const ConnectorType &);
382
383 NormalType & outerNormal(const FieldVector<alu3d_ctype, 2>& local) const;
384
386 void resetFaceGeom();
387
389 template <class GeometryImp>
390 void buildGlobalGeom(GeometryImp& geo) const;
391
392 private:
393 //- forbidden methods
395
396 protected:
397 using Base::connector_;
398
399 private:
400 //- private data
401 mutable NormalType outerNormal_;
402
403 // surface mapping for calculating the outer normal
404 mutable SurfaceMappingType mappingGlobal_;
405
406 // false if surface mapping needs a update
407 mutable bool mappingGlobalUp2Date_;
408 };
409
410 // ALU3dGridGeometricFaceInfoBase
411 // ------------------------------
412
415 template< int dimworld, ALU3dGridElementType type, class Comm >
416 class ALU3dGridGeometricFaceInfoBase<2, dimworld, type, Comm>
417 {
418
419 public:
422
423 // type of container for reference elements
425 // type of container for reference faces
427
428 // type of reference element
429 typedef std::decay_t< decltype( ReferenceElementContainerType::general( std::declval< const Dune::GeometryType & >() ) ) > ReferenceElementType;
430 // type of reference face
431 typedef std::decay_t< decltype( ReferenceFaceContainerType::general( std::declval< const Dune::GeometryType & >() ) ) > ReferenceFaceType;
432
433 enum SideIdentifier { INNER, OUTER };
434 enum { numVerticesPerFace = 2 }; // A face in 2d is an edge
435
436 //- public typedefs
438 typedef FieldMatrix<alu3d_ctype,
439 numVerticesPerFace,
440 dimworld> CoordinateType;
441 typedef FieldMatrix<alu3d_ctype,
442 numVerticesPerFace,
444
445 typedef typename ALU3dGridFaceInfo< 2, dimworld, type, Comm >::GEOFaceType GEOFaceType;
446
447 public:
448 typedef ALU3dGridFaceInfo< 2, dimworld, type, Comm > ConnectorType;
449
450 //- constructors and destructors
451 ALU3dGridGeometricFaceInfoBase(const ConnectorType &);
453
455 void resetFaceGeom();
456
457 //- functions
458 const LocalCoordinateType& intersectionSelfLocal() const;
459 const LocalCoordinateType& intersectionNeighborLocal() const;
460
461 private:
462 //- forbidden methods
464
465 protected:
466 //- protected methods
467 void generateLocalGeometries() const;
468
469 private:
470 //- private methods
471
472 int globalVertexIndex(const int duneFaceIndex,
473 const int faceTwist,
474 const int duneFaceVertexIndex) const;
475
476 void referenceElementCoordinatesRefined(SideIdentifier side,
477 LocalCoordinateType& result) const;
478 void referenceElementCoordinatesUnrefined(SideIdentifier side,
479 LocalCoordinateType& result) const;
480
481 protected:
482 //- private data
483 const ConnectorType& connector_;
484
485 mutable LocalCoordinateType coordsSelfLocal_;
486 mutable LocalCoordinateType coordsNeighborLocal_;
487
488 mutable bool generatedGlobal_;
489 mutable bool generatedLocal_;
490
491 inline static const ReferenceElementType& getReferenceElement()
492 {
493 return (type == tetra) ?
496 }
497
498 };
499
502 template< int dimworld, class Comm >
503 class ALU3dGridGeometricFaceInfoTetra<2, dimworld, Comm>
504 : public ALU3dGridGeometricFaceInfoBase< 2, dimworld, tetra, Comm >
505 {
507
508 public:
509 //- public typedefs
511 typedef typename Base::FaceTopo FaceTopo;
512 typedef typename ALU3dGridFaceInfo< 2, dimworld, tetra, Comm >::GEOFaceType GEOFaceType;
513 typedef typename ALU3dGridFaceInfo< 2, dimworld, tetra, Comm >::GEOElementType GEOElementType;
514 typedef ALU3dGridFaceInfo< 2, dimworld, tetra, Comm > ConnectorType;
515
516 //- constructors and destructors
517 ALU3dGridGeometricFaceInfoTetra(const ConnectorType& ctor);
519
520 NormalType & outerNormal(const FieldVector<alu3d_ctype, 1>& local) const;
521
523 void resetFaceGeom();
524
526 template <class GeometryImp>
527 void buildGlobalGeom(GeometryImp& geo) const;
528
529 private:
530 //- forbidden methods
532
533 protected:
534 using Base::connector_;
535
536 private:
537 //- private data
538 mutable NormalType outerNormal_;
539
540 // false if surface mapping needs a update
541 mutable bool normalUp2Date_;
542 };
543
546 template< int dimworld, class Comm >
547 class ALU3dGridGeometricFaceInfoHexa<2, dimworld, Comm>
548 : public ALU3dGridGeometricFaceInfoBase< 2, dimworld, hexa, Comm >
549 {
551
552 public:
553 //- public typedefs
555 typedef typename Base::FaceTopo FaceTopo;
556 typedef typename ALU3dGridFaceInfo< 2, dimworld, hexa, Comm >::GEOFaceType GEOFaceType;
557 typedef typename ALU3dGridFaceInfo< 2, dimworld, hexa, Comm >::GEOElementType GEOElementType;
558
559 typedef ALU3dGridFaceInfo< 2, dimworld, hexa, Comm > ConnectorType;
560
561 //- constructors and destructors
562 ALU3dGridGeometricFaceInfoHexa(const ConnectorType &);
564
565 NormalType & outerNormal(const FieldVector<alu3d_ctype, 1>& local) const;
566
568 void resetFaceGeom();
569
571 template <class GeometryImp>
572 void buildGlobalGeom(GeometryImp& geo) const;
573
574 private:
575 //- forbidden methods
577
578 protected:
579 using Base::connector_;
580
581 private:
582 //- private data
583 mutable NormalType outerNormal_;
584
585 // false if surface mapping needs a update
586 mutable bool normalUp2Date_;
587 };
588
589
590} // end namespace Dune
591
592#include "faceutility_imp.cc"
593
594#endif
Definition: faceutility.hh:236
void resetFaceGeom()
reset status of faceGeomInfo
Definition: faceutility_imp.cc:500
Definition: faceutility.hh:367
void buildGlobalGeom(GeometryImp &geo) const
update global geometry
Definition: faceutility_imp.cc:622
void resetFaceGeom()
reset status of faceGeomInfo
Definition: faceutility_imp.cc:604
Definition: faceutility.hh:323
void resetFaceGeom()
reset status of faceGeomInfo
Definition: faceutility_imp.cc:533
void buildGlobalGeom(GeometryImp &geo) const
update global geometry
Definition: faceutility_imp.cc:549
Definition: topology.hh:40
Definition: topology.hh:151
A dense n x m matrix.
Definition: fmatrix.hh:117
Definition: mappings.hh:385
A bilinear surface mapping.
Definition: mappings.hh:88
topology of a Cartesian grid
Dune namespace.
Definition: alignedallocator.hh:13
Class providing access to the singletons of the reference elements.
Definition: referenceelements.hh:170
static const ReferenceElement & cube()
get hypercube reference elements
Definition: referenceelements.hh:210
static const ReferenceElement & simplex()
get simplex reference elements
Definition: referenceelements.hh:204
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Dec 21, 23:30, 2024)