dune-grid  2.3.0
faceutility.hh
Go to the documentation of this file.
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 
12 namespace 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 >
43  {
45  //- private typedefs
46  typedef typename ImplTraits::HasFaceType HasFaceType;
47  public:
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
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 
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 >
185 
186  template< class Comm >
188  {
189  // this is the original ALUGrid LinearSurfaceMapping,
190  // see mapp_tetra_3d.* in ALUGrid code
191  typedef ALU3DSPACE LinearSurfaceMapping SurfaceMappingType;
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 >
206  {
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  {
232 
233  public:
237 
238  // type of container for reference elements
239  typedef ReferenceElements< alu3d_ctype, 3 > ReferenceElementContainerType;
240  // type of container for reference faces
241  typedef ReferenceElements< alu3d_ctype, 2 > ReferenceFaceContainerType;
242 
243  // type of reference element
244  typedef ReferenceElement<alu3d_ctype, 3> ReferenceElementType;
245  // type of reference face
246  typedef ReferenceElement<alu3d_ctype, 2> ReferenceFaceType;
247 
249  enum { dimworld = 3 }; // ALU is a pure 3d grid
252 
253  //- public typedefs
254  typedef FieldVector<alu3d_ctype, 3> NormalType;
255  typedef FieldMatrix<alu3d_ctype,
258 
260 
261  public:
263 
264  //- constructors and destructors
267 
269  void resetFaceGeom();
270 
271  //- functions
272  const CoordinateType& intersectionSelfLocal() 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
295 
298 
299  mutable bool generatedGlobal_;
300  mutable bool generatedLocal_;
301 
303  {
304  return (type == tetra) ?
307  }
308 
309  inline static const ReferenceFaceType& getReferenceFace()
310  {
311  return (type == tetra) ?
314  }
315  };
316 
319  template< class Comm >
321  : public ALU3dGridGeometricFaceInfoBase< tetra, Comm >
322  {
324 
325  public:
326  //- public typedefs
327  typedef FieldVector<alu3d_ctype, 3> NormalType;
328  typedef typename Base::FaceTopo FaceTopo;
330 
332 
333  //- constructors and destructors
336 
337  NormalType & outerNormal(const FieldVector<alu3d_ctype, 2>& local) const;
338 
340  void resetFaceGeom();
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
371  typedef FieldVector<alu3d_ctype, 3> NormalType;
372  typedef typename Base::FaceTopo FaceTopo;
375 
377 
378  //- constructors and destructors
381 
382  NormalType & outerNormal(const FieldVector<alu3d_ctype, 2>& local) const;
383 
385  void resetFaceGeom();
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
FieldMatrix< alu3d_ctype, numVerticesPerFace, 3 > CoordinateType
Definition: faceutility.hh:212
void resetFaceGeom()
reset status of faceGeomInfo
ElementTopologyMapping< type > ElementTopo
Definition: faceutility.hh:234
ALU3dGridGeometricFaceInfoBase(const ConnectorType &)
ALU3dGridFaceInfo< hexa, Comm >::GEOFaceType GEOFaceType
Definition: faceutility.hh:208
Definition: faceutility.hh:320
ALU3dGridGeometricFaceInfoHexa(const ConnectorType &)
A bilinear surface mapping.
Definition: mappings.hh:144
bool innerBoundary() const
returns true if inside is a ghost entity
Definition: faceutility.hh:48
FieldMatrix< alu3d_ctype, numVerticesPerFace, dimworld > CoordinateType
Definition: faceutility.hh:257
ALU3dGridFaceInfo< type, Comm > ConnectorType
Definition: faceutility.hh:262
ImplTraits::GEOElementType GEOElementType
Definition: faceutility.hh:51
int innerALUFaceIndex() const
Local number of the face in inner element (ALU3dGrid reference element)
bool boundary() const
returns true if the face lies on the domain boundary
bool generatedGlobal_
Definition: faceutility.hh:299
ImplTraits::IMPLElementType IMPLElementType
Definition: faceutility.hh:53
int segmentIndex() const
return boundary segment index if intersection is with domain boundary
A bilinear surface mapping.
Definition: mappings.hh:89
const CoordinateType & intersectionNeighborLocal() const
void resetFaceGeom()
reset status of faceGeomInfo
Definition: faceutility.hh:48
void updateFaceInfo(const GEOFaceType &face, int innerLevel, int innerTwist)
Definition: alugrid/common/declaration.hh:18
Definition: topology.hh:13
void buildGlobalGeom(GeometryImp &geo) const
update global geometry
CoordinateType coordsNeighborLocal_
Definition: faceutility.hh:297
ALU3dGridFaceInfo< tetra, Comm >::GEOFaceType GEOFaceType
Definition: faceutility.hh:192
ALU3dGridFaceInfo(const bool conformingRefinement, const bool ghostCellsEnabled)
constructor creating empty face info
ALU3dGridGeometricFaceInfoTetra(const ConnectorType &ctor)
bool parallel() const
return whether we are in a parallel environment or not
Definition: faceutility.hh:135
const GEOFaceType & face() const
Returns the ALU3dGrid face.
bool isElementLike() const
returns true if outerEntity casts into a helement
int outsideLevel() const
#define ALU3DSPACE
Definition: alu3dinclude.hh:26
Definition: topology.hh:16
ReferenceElements< alu3d_ctype, 3 > ReferenceElementContainerType
Definition: faceutility.hh:239
ALU3dGridFaceInfo< hexa, Comm >::GEOFaceType GEOFaceType
Definition: faceutility.hh:373
static const ReferenceElementType & getReferenceElement()
Definition: faceutility.hh:302
~ALU3dGridFaceInfo()
Destructor.
bool neighbor() const
returns true if outside is something meaningfull
bool ghostBoundary() const
ConformanceState conformanceState() const
Description of conformance on the face.
Definition: faceutility.hh:248
Definition: alu3dinclude.hh:201
Definition: faceutility.hh:364
double alu3d_ctype
Definition: alu3dinclude.hh:59
ImplTraits::GhostPairType GhostPairType
Definition: faceutility.hh:54
bool generatedLocal_
Definition: faceutility.hh:300
FieldMatrix< alu3d_ctype, numVerticesPerFace, 3 > CoordinateType
Definition: faceutility.hh:196
BilinearSurfaceMapping SurfaceMappingType
Definition: faceutility.hh:207
void buildGlobalGeom(GeometryImp &geo) const
update global geometry
const CoordinateType & intersectionSelfLocal() const
ReferenceElements< alu3d_ctype, 2 > ReferenceFaceContainerType
Definition: faceutility.hh:241
NormalType & outerNormal(const FieldVector< alu3d_ctype, 2 > &local) const
CoordinateType coordsSelfLocal_
Definition: faceutility.hh:296
SurfaceNormalCalculator SurfaceMappingType
Definition: faceutility.hh:374
const BNDFaceType & boundaryFace() const
FieldVector< alu3d_ctype, 3 > NormalType
Definition: faceutility.hh:254
ImplTraits::GEOPeriodicType GEOPeriodicType
Definition: faceutility.hh:52
const BNDFaceType & innerFace() const
ALU3dGridFaceInfo< hexa, Comm > ConnectorType
Definition: faceutility.hh:376
Definition: faceutility.hh:248
Definition: topology.hh:40
NonConformingFaceMapping< type, Comm > NonConformingMappingType
Definition: faceutility.hh:236
FaceTopologyMapping< type > FaceTopo
Definition: faceutility.hh:235
NormalType & outerNormal(const FieldVector< alu3d_ctype, 2 > &local) const
ImplTraits::BNDFaceType BNDFaceType
Definition: faceutility.hh:55
Definition: alugrid/common/declaration.hh:18
alu3d_ctype(& fieldVector2alu3d_ctype(FieldVector< alu3d_ctype, dim > &val))[dim]
Definition: faceutility.hh:21
Base::FaceTopo FaceTopo
Definition: faceutility.hh:372
ReferenceElement< alu3d_ctype, 2 > ReferenceFaceType
Definition: faceutility.hh:246
Definition: faceutility.hh:184
Definition: faceutility.hh:228
Base::FaceTopo FaceTopo
Definition: faceutility.hh:328
int boundaryId() const
return boundary id if intersection is with domain boundary
const GEOElementType & innerEntity() const
Returns the inner element at that face.
void resetFaceGeom()
reset status of faceGeomInfo
Definition: mappings.hh:387
FieldVector< alu3d_ctype, 3 > NormalType
Definition: faceutility.hh:327
const GEOElementType & outerEntity() const
int outerTwist() const
Twist of the face seen from the outer element.
Definition: topology.hh:126
const ConnectorType & connector_
Definition: faceutility.hh:294
ImplTraits::GEOFaceType GEOFaceType
Definition: faceutility.hh:50
ReferenceElement< alu3d_ctype, 3 > ReferenceElementType
Definition: faceutility.hh:244
static const ReferenceFaceType & getReferenceFace()
Definition: faceutility.hh:309
bool outerBoundary() const
Definition: faceutility.hh:48
Definition: faceutility.hh:48
FieldVector< alu3d_ctype, 3 > NormalType
Definition: faceutility.hh:371
Definition: faceutility.hh:42
bool conformingRefinement() const
return true if conforming refinement is enabled
Definition: faceutility.hh:140
ConformanceState
Definition: faceutility.hh:48
ALU3dGridFaceInfo< tetra, Comm > ConnectorType
Definition: faceutility.hh:331
int innerTwist() const
Twist of the face seen from the inner element.
ALU3dGridFaceInfo< tetra, Comm >::GEOFaceType GEOFaceType
Definition: faceutility.hh:329
int outerALUFaceIndex() const
Local number of the face in outer element (ALU3dGrid reference element)
ALU3DSPACE LinearSurfaceMapping SurfaceMappingType
Definition: faceutility.hh:191
ALU3dGridFaceInfo< type, Comm >::GEOFaceType GEOFaceType
Definition: faceutility.hh:259
Definition: topology.hh:13
int duneTwist(const int faceIdx, const int aluTwist) const
Twist of the face seen from the inner element.