dune-grid
2.2.0
|
00001 #ifndef DUNE_ALU3DGRIDFACEUTILITY_HH 00002 #define DUNE_ALU3DGRIDFACEUTILITY_HH 00003 00004 #include <dune/common/misc.hh> 00005 #include <dune/geometry/referenceelements.hh> 00006 00007 #include "mappings.hh" 00008 #include "alu3dinclude.hh" 00009 #include "topology.hh" 00010 00011 namespace Dune 00012 { 00013 00014 // convert FieldVectors to alu3dtypes 00015 // only used for calculating the normals because the method of the 00016 // mapping classes want double (&)[3] and we have FieldVectors which store an 00017 // double [3] this is why we can cast here 00018 // plz say notin' Adrian 00019 template< int dim > 00020 inline alu3d_ctype (&fieldVector2alu3d_ctype ( FieldVector< alu3d_ctype, dim > &val ))[ dim ] 00021 { 00022 return ((alu3d_ctype (&)[dim]) (*( &(val[0])) )); 00023 } 00024 00025 // convert const FieldVectors to const alu3dtypes 00026 template< int dim > 00027 inline const alu3d_ctype (&fieldVector2alu3d_ctype ( const FieldVector< alu3d_ctype, dim > &val ))[ dim ] 00028 { 00029 return ((const alu3d_ctype (&)[dim]) (*( &(val[0])) ) ); 00030 } 00031 00032 00033 // * Note: reconsider lazy evaluation of coordinates 00034 00035 //- class ALU3dGridFaceInfo 00036 /* \brief Stores face and adjoining elements of the underlying ALU3dGrid 00037 The class has the same notion of inner and outer element as the 00038 intersection iterator. 00039 */ 00040 template< ALU3dGridElementType type, class Comm > 00041 class ALU3dGridFaceInfo 00042 { 00043 typedef ALU3dImplTraits< type, Comm > ImplTraits; 00044 //- private typedefs 00045 typedef typename ImplTraits::HasFaceType HasFaceType; 00046 public: 00047 enum ConformanceState {CONFORMING, REFINED_INNER, REFINED_OUTER, UNDEFINED }; 00048 //- typedefs 00049 typedef typename ImplTraits::GEOFaceType GEOFaceType; 00050 typedef typename ImplTraits::GEOElementType GEOElementType; 00051 typedef typename ImplTraits::GEOPeriodicType GEOPeriodicType; 00052 typedef typename ImplTraits::IMPLElementType IMPLElementType; 00053 typedef typename ImplTraits::GhostPairType GhostPairType; 00054 typedef typename ImplTraits::BNDFaceType BNDFaceType; 00055 00056 public: 00058 ALU3dGridFaceInfo(); 00059 void updateFaceInfo(const GEOFaceType& face, int innerLevel, int innerTwist); 00060 00061 //- constructors and destructors 00066 ALU3dGridFaceInfo(const GEOFaceType& face, int innerTwist); 00068 ALU3dGridFaceInfo(const ALU3dGridFaceInfo &orig); 00070 ~ALU3dGridFaceInfo(); 00071 00072 protected: 00074 bool isElementLike() const; 00075 00077 bool innerBoundary() const; 00078 00079 public: 00080 //- queries 00083 bool outerBoundary() const; 00084 00086 bool boundary() const; 00087 00089 bool neighbor() const ; 00090 00093 bool ghostBoundary () const; 00094 00096 const GEOFaceType& face() const; 00098 const GEOElementType& innerEntity() const; 00101 const GEOElementType& outerEntity() const; 00104 const BNDFaceType& innerFace() const; 00107 const BNDFaceType& boundaryFace() const; 00108 00110 int innerTwist() const; 00112 int outerTwist() const; 00113 00115 int duneTwist(const int faceIdx, const int aluTwist) const; 00116 00118 int innerALUFaceIndex() const; 00120 int outerALUFaceIndex() const; 00121 00122 int outsideLevel() const; 00123 00125 int segmentIndex() const; 00126 00128 int boundaryId() const; 00129 00131 ConformanceState conformanceState() const; 00132 00134 bool parallel() const { 00135 return ! Conversion< Comm, No_Comm > :: sameType ; 00136 } 00137 00138 private: 00140 ConformanceState getConformanceState(const int innerLevel) const; 00141 00142 //- forbidden methods 00143 const ALU3dGridFaceInfo & 00144 operator=(const ALU3dGridFaceInfo &orig); 00145 00146 private: 00147 00148 //- member data 00149 const GEOFaceType* face_; 00150 const HasFaceType* innerElement_; 00151 const HasFaceType* outerElement_; 00152 00153 int innerFaceNumber_; 00154 int outerFaceNumber_; 00155 00156 int innerTwist_; 00157 int outerTwist_; 00158 00159 int segmentIndex_; 00160 int bndId_; 00161 00162 enum boundary_t { noBoundary = 0, // no boundary, outside is normal element 00163 periodicBoundary = 1, // periodic boundary 00164 innerGhostBoundary = 2, // process boundary, inside is ghost, outside is normal element 00165 domainBoundary = 3, // boundary with domain, no outside 00166 outerGhostBoundary = 4};// process boundary, outside is ghost 00167 00168 boundary_t bndType_; 00169 00170 ConformanceState conformanceState_; 00171 }; 00172 00173 00174 // ALU3dGridSurfaceMappingFactory 00175 // ------------------------------ 00176 00177 template< ALU3dGridElementType type, class Comm > 00178 struct ALU3dGridSurfaceMappingFactory; 00179 00180 template< class Comm > 00181 struct ALU3dGridSurfaceMappingFactory< tetra, Comm > 00182 { 00183 // this is the original ALUGrid LinearSurfaceMapping, 00184 // see mapp_tetra_3d.* in ALUGrid code 00185 typedef ALU3DSPACE LinearSurfaceMapping SurfaceMappingType; 00186 typedef typename ALU3dGridFaceInfo< tetra, Comm >::GEOFaceType GEOFaceType; 00187 00188 static const int numVerticesPerFace = EntityCount< tetra >::numVerticesPerFace; 00189 00190 typedef FieldMatrix< alu3d_ctype, numVerticesPerFace, 3 > CoordinateType; 00191 00192 // old method, copies values for tetra twice 00193 SurfaceMappingType *buildSurfaceMapping ( const CoordinateType &coords ) const; 00194 // get face but doesn't copy values twice 00195 SurfaceMappingType *buildSurfaceMapping ( const GEOFaceType &face ) const; 00196 }; 00197 00198 template< class Comm > 00199 struct ALU3dGridSurfaceMappingFactory< hexa, Comm > 00200 { 00201 typedef BilinearSurfaceMapping SurfaceMappingType; 00202 typedef typename ALU3dGridFaceInfo< hexa, Comm >::GEOFaceType GEOFaceType; 00203 00204 static const int numVerticesPerFace = EntityCount< hexa >::numVerticesPerFace; 00205 00206 typedef FieldMatrix< alu3d_ctype, numVerticesPerFace, 3 > CoordinateType; 00207 00208 // old method, copies values for tetra twice 00209 SurfaceMappingType *buildSurfaceMapping ( const CoordinateType &coords ) const; 00210 // get face but doesn't copy values twice 00211 SurfaceMappingType *buildSurfaceMapping ( const GEOFaceType &face ) const; 00212 }; 00213 00214 00215 00216 // ALU3dGridGeometricFaceInfoBase 00217 // ------------------------------ 00218 00221 template< ALU3dGridElementType type, class Comm > 00222 class ALU3dGridGeometricFaceInfoBase 00223 : public ALU3dGridSurfaceMappingFactory< type, Comm > 00224 { 00225 typedef ALU3dGridSurfaceMappingFactory< type, Comm > Base; 00226 00227 public: 00228 typedef ElementTopologyMapping<type> ElementTopo; 00229 typedef FaceTopologyMapping<type> FaceTopo; 00230 typedef NonConformingFaceMapping< type, Comm > NonConformingMappingType; 00231 00232 // type of container for reference elements 00233 typedef GenericReferenceElements< alu3d_ctype, 3 > ReferenceElementContainerType; 00234 // type of container for reference faces 00235 typedef GenericReferenceElements< alu3d_ctype, 2 > ReferenceFaceContainerType; 00236 00237 // type of reference element 00238 typedef GenericReferenceElement<alu3d_ctype, 3> ReferenceElementType; 00239 // type of reference face 00240 typedef GenericReferenceElement<alu3d_ctype, 2> ReferenceFaceType; 00241 00242 enum SideIdentifier { INNER, OUTER }; 00243 enum { dimworld = 3 }; // ALU is a pure 3d grid 00244 enum { numVerticesPerFace = 00245 EntityCount<type>::numVerticesPerFace }; 00246 00247 //- public typedefs 00248 typedef FieldVector<alu3d_ctype, 3> NormalType; 00249 typedef FieldMatrix<alu3d_ctype, 00250 numVerticesPerFace, 00251 dimworld> CoordinateType; 00252 00253 typedef typename ALU3dGridFaceInfo< type, Comm >::GEOFaceType GEOFaceType; 00254 00255 public: 00256 typedef ALU3dGridFaceInfo< type, Comm > ConnectorType; 00257 00258 //- constructors and destructors 00259 ALU3dGridGeometricFaceInfoBase(const ConnectorType &); 00260 ALU3dGridGeometricFaceInfoBase(const ALU3dGridGeometricFaceInfoBase &); 00261 00263 void resetFaceGeom(); 00264 00265 //- functions 00266 const CoordinateType& intersectionSelfLocal() const; 00267 const CoordinateType& intersectionNeighborLocal() const; 00268 00269 private: 00270 //- forbidden methods 00271 const ALU3dGridGeometricFaceInfoBase &operator=(const ALU3dGridGeometricFaceInfoBase &); 00272 00273 private: 00274 //- private methods 00275 void generateLocalGeometries() const; 00276 00277 int globalVertexIndex(const int duneFaceIndex, 00278 const int faceTwist, 00279 const int duneFaceVertexIndex) const; 00280 00281 void referenceElementCoordinatesRefined(SideIdentifier side, 00282 CoordinateType& result) const; 00283 void referenceElementCoordinatesUnrefined(SideIdentifier side, 00284 CoordinateType& result) const; 00285 00286 protected: 00287 //- private data 00288 const ConnectorType& connector_; 00289 00290 mutable CoordinateType coordsSelfLocal_; 00291 mutable CoordinateType coordsNeighborLocal_; 00292 00293 mutable bool generatedGlobal_; 00294 mutable bool generatedLocal_; 00295 00296 inline static const ReferenceElementType& getReferenceElement() 00297 { 00298 return (type == tetra) ? 00299 ReferenceElementContainerType :: simplex() : 00300 ReferenceElementContainerType :: cube(); 00301 } 00302 00303 inline static const ReferenceFaceType& getReferenceFace() 00304 { 00305 return (type == tetra) ? 00306 ReferenceFaceContainerType :: simplex() : 00307 ReferenceFaceContainerType :: cube(); 00308 } 00309 }; 00310 00313 template< class Comm > 00314 class ALU3dGridGeometricFaceInfoTetra 00315 : public ALU3dGridGeometricFaceInfoBase< tetra, Comm > 00316 { 00317 typedef ALU3dGridGeometricFaceInfoBase< tetra, Comm > Base; 00318 00319 public: 00320 //- public typedefs 00321 typedef FieldVector<alu3d_ctype, 3> NormalType; 00322 typedef typename Base::FaceTopo FaceTopo; 00323 typedef typename ALU3dGridFaceInfo< tetra, Comm >::GEOFaceType GEOFaceType; 00324 00325 typedef ALU3dGridFaceInfo< tetra, Comm > ConnectorType; 00326 00327 //- constructors and destructors 00328 ALU3dGridGeometricFaceInfoTetra(const ConnectorType& ctor); 00329 ALU3dGridGeometricFaceInfoTetra(const ALU3dGridGeometricFaceInfoTetra & orig); 00330 00331 NormalType & outerNormal(const FieldVector<alu3d_ctype, 2>& local) const; 00332 00334 void resetFaceGeom(); 00335 00337 template <class GeometryImp> 00338 void buildGlobalGeom(GeometryImp& geo) const; 00339 00340 private: 00341 //- forbidden methods 00342 const ALU3dGridGeometricFaceInfoTetra & operator=(const ALU3dGridGeometricFaceInfoTetra &); 00343 00344 protected: 00345 using Base::connector_; 00346 00347 private: 00348 //- private data 00349 mutable NormalType outerNormal_; 00350 00351 // false if surface mapping needs a update 00352 mutable bool normalUp2Date_; 00353 }; 00354 00357 template< class Comm > 00358 class ALU3dGridGeometricFaceInfoHexa 00359 : public ALU3dGridGeometricFaceInfoBase< hexa, Comm > 00360 { 00361 typedef ALU3dGridGeometricFaceInfoBase< hexa, Comm > Base; 00362 00363 public: 00364 //- public typedefs 00365 typedef FieldVector<alu3d_ctype, 3> NormalType; 00366 typedef typename Base::FaceTopo FaceTopo; 00367 typedef typename ALU3dGridFaceInfo< hexa, Comm >::GEOFaceType GEOFaceType; 00368 typedef SurfaceNormalCalculator SurfaceMappingType; 00369 00370 typedef ALU3dGridFaceInfo< hexa, Comm > ConnectorType; 00371 00372 //- constructors and destructors 00373 ALU3dGridGeometricFaceInfoHexa(const ConnectorType &); 00374 ALU3dGridGeometricFaceInfoHexa(const ALU3dGridGeometricFaceInfoHexa &); 00375 00376 NormalType & outerNormal(const FieldVector<alu3d_ctype, 2>& local) const; 00377 00379 void resetFaceGeom(); 00380 00382 template <class GeometryImp> 00383 void buildGlobalGeom(GeometryImp& geo) const; 00384 00385 private: 00386 //- forbidden methods 00387 const ALU3dGridGeometricFaceInfoHexa & operator=(const ALU3dGridGeometricFaceInfoHexa &); 00388 00389 protected: 00390 using Base::connector_; 00391 00392 private: 00393 //- private data 00394 mutable NormalType outerNormal_; 00395 00396 // surface mapping for calculating the outer normal 00397 mutable SurfaceMappingType mappingGlobal_; 00398 00399 // false if surface mapping needs a update 00400 mutable bool mappingGlobalUp2Date_; 00401 }; 00402 00403 } // end namespace Dune 00404 00405 #include "faceutility_imp.cc" 00406 00407 #endif