dune-grid
2.1.1
|
00001 #ifndef DUNE_ALU3DGRIDFACEUTILITY_HH 00002 #define DUNE_ALU3DGRIDFACEUTILITY_HH 00003 00004 #include <dune/common/misc.hh> 00005 #include <dune/grid/common/genericreferenceelements.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 00123 int segmentIndex() const; 00124 00126 int boundaryId() const; 00127 00129 ConformanceState conformanceState() const; 00130 00132 const bool parallel() const { 00133 return ! Conversion< Comm, No_Comm > :: sameType ; 00134 } 00135 00136 private: 00138 ConformanceState getConformanceState(const int innerLevel) const; 00139 00140 //- forbidden methods 00141 const ALU3dGridFaceInfo & 00142 operator=(const ALU3dGridFaceInfo &orig); 00143 00144 private: 00145 00146 //- member data 00147 const GEOFaceType* face_; 00148 const HasFaceType* innerElement_; 00149 const HasFaceType* outerElement_; 00150 00151 int innerFaceNumber_; 00152 int outerFaceNumber_; 00153 00154 int innerTwist_; 00155 int outerTwist_; 00156 00157 int segmentIndex_; 00158 00159 enum boundary_t { noBoundary = 0, // no boundary, outside is normal element 00160 periodicBoundary = 1, // periodic boundary 00161 innerGhostBoundary = 2, // process boundary, inside is ghost, outside is normal element 00162 domainBoundary = 3, // boundary with domain, no outside 00163 outerGhostBoundary = 4};// process boundary, outside is ghost 00164 00165 boundary_t bndType_; 00166 00167 ConformanceState conformanceState_; 00168 }; 00169 00170 00171 // ALU3dGridSurfaceMappingFactory 00172 // ------------------------------ 00173 00174 template< ALU3dGridElementType type, class Comm > 00175 struct ALU3dGridSurfaceMappingFactory; 00176 00177 template< class Comm > 00178 struct ALU3dGridSurfaceMappingFactory< tetra, Comm > 00179 { 00180 // this is the original ALUGrid LinearSurfaceMapping, 00181 // see mapp_tetra_3d.* in ALUGrid code 00182 typedef ALU3DSPACE LinearSurfaceMapping SurfaceMappingType; 00183 typedef typename ALU3dGridFaceInfo< tetra, Comm >::GEOFaceType GEOFaceType; 00184 00185 static const int numVerticesPerFace = EntityCount< tetra >::numVerticesPerFace; 00186 00187 typedef FieldMatrix< alu3d_ctype, numVerticesPerFace, 3 > CoordinateType; 00188 00189 // old method, copies values for tetra twice 00190 SurfaceMappingType *buildSurfaceMapping ( const CoordinateType &coords ) const; 00191 // get face but doesn't copy values twice 00192 SurfaceMappingType *buildSurfaceMapping ( const GEOFaceType &face ) const; 00193 }; 00194 00195 template< class Comm > 00196 struct ALU3dGridSurfaceMappingFactory< hexa, Comm > 00197 { 00198 typedef BilinearSurfaceMapping SurfaceMappingType; 00199 typedef typename ALU3dGridFaceInfo< hexa, Comm >::GEOFaceType GEOFaceType; 00200 00201 static const int numVerticesPerFace = EntityCount< hexa >::numVerticesPerFace; 00202 00203 typedef FieldMatrix< alu3d_ctype, numVerticesPerFace, 3 > CoordinateType; 00204 00205 // old method, copies values for tetra twice 00206 SurfaceMappingType *buildSurfaceMapping ( const CoordinateType &coords ) const; 00207 // get face but doesn't copy values twice 00208 SurfaceMappingType *buildSurfaceMapping ( const GEOFaceType &face ) const; 00209 }; 00210 00211 00212 00213 // ALU3dGridGeometricFaceInfoBase 00214 // ------------------------------ 00215 00218 template< ALU3dGridElementType type, class Comm > 00219 class ALU3dGridGeometricFaceInfoBase 00220 : public ALU3dGridSurfaceMappingFactory< type, Comm > 00221 { 00222 typedef ALU3dGridSurfaceMappingFactory< type, Comm > Base; 00223 00224 public: 00225 typedef ElementTopologyMapping<type> ElementTopo; 00226 typedef FaceTopologyMapping<type> FaceTopo; 00227 typedef NonConformingFaceMapping< type, Comm > NonConformingMappingType; 00228 00229 // type of container for reference elements 00230 typedef GenericReferenceElements< alu3d_ctype, 3 > ReferenceElementContainerType; 00231 // type of container for reference faces 00232 typedef GenericReferenceElements< alu3d_ctype, 2 > ReferenceFaceContainerType; 00233 00234 // type of reference element 00235 typedef GenericReferenceElement<alu3d_ctype, 3> ReferenceElementType; 00236 // type of reference face 00237 typedef GenericReferenceElement<alu3d_ctype, 2> ReferenceFaceType; 00238 00239 enum SideIdentifier { INNER, OUTER }; 00240 enum { dimworld = 3 }; // ALU is a pure 3d grid 00241 enum { numVerticesPerFace = 00242 EntityCount<type>::numVerticesPerFace }; 00243 00244 //- public typedefs 00245 typedef FieldVector<alu3d_ctype, 3> NormalType; 00246 typedef FieldMatrix<alu3d_ctype, 00247 numVerticesPerFace, 00248 dimworld> CoordinateType; 00249 00250 typedef typename ALU3dGridFaceInfo< type, Comm >::GEOFaceType GEOFaceType; 00251 00252 public: 00253 typedef ALU3dGridFaceInfo< type, Comm > ConnectorType; 00254 00255 //- constructors and destructors 00256 ALU3dGridGeometricFaceInfoBase(const ConnectorType &); 00257 ALU3dGridGeometricFaceInfoBase(const ALU3dGridGeometricFaceInfoBase &); 00258 00260 void resetFaceGeom(); 00261 00262 //- functions 00263 const CoordinateType& intersectionSelfLocal() const; 00264 const CoordinateType& intersectionNeighborLocal() const; 00265 00266 private: 00267 //- forbidden methods 00268 const ALU3dGridGeometricFaceInfoBase &operator=(const ALU3dGridGeometricFaceInfoBase &); 00269 00270 private: 00271 //- private methods 00272 void generateLocalGeometries() const; 00273 00274 int globalVertexIndex(const int duneFaceIndex, 00275 const int faceTwist, 00276 const int duneFaceVertexIndex) const; 00277 00278 void referenceElementCoordinatesRefined(SideIdentifier side, 00279 CoordinateType& result) const; 00280 void referenceElementCoordinatesUnrefined(SideIdentifier side, 00281 CoordinateType& result) const; 00282 00283 protected: 00284 //- private data 00285 const ConnectorType& connector_; 00286 00287 mutable CoordinateType coordsSelfLocal_; 00288 mutable CoordinateType coordsNeighborLocal_; 00289 00290 mutable bool generatedGlobal_; 00291 mutable bool generatedLocal_; 00292 00293 inline static const ReferenceElementType& getReferenceElement() 00294 { 00295 return (type == tetra) ? 00296 ReferenceElementContainerType :: simplex() : 00297 ReferenceElementContainerType :: cube(); 00298 } 00299 00300 inline static const ReferenceFaceType& getReferenceFace() 00301 { 00302 return (type == tetra) ? 00303 ReferenceFaceContainerType :: simplex() : 00304 ReferenceFaceContainerType :: cube(); 00305 } 00306 }; 00307 00310 template< class Comm > 00311 class ALU3dGridGeometricFaceInfoTetra 00312 : public ALU3dGridGeometricFaceInfoBase< tetra, Comm > 00313 { 00314 typedef ALU3dGridGeometricFaceInfoBase< tetra, Comm > Base; 00315 00316 public: 00317 //- public typedefs 00318 typedef FieldVector<alu3d_ctype, 3> NormalType; 00319 typedef typename Base::FaceTopo FaceTopo; 00320 typedef typename ALU3dGridFaceInfo< tetra, Comm >::GEOFaceType GEOFaceType; 00321 00322 typedef ALU3dGridFaceInfo< tetra, Comm > ConnectorType; 00323 00324 //- constructors and destructors 00325 ALU3dGridGeometricFaceInfoTetra(const ConnectorType& ctor); 00326 ALU3dGridGeometricFaceInfoTetra(const ALU3dGridGeometricFaceInfoTetra & orig); 00327 00328 NormalType & outerNormal(const FieldVector<alu3d_ctype, 2>& local) const; 00329 00331 void resetFaceGeom(); 00332 00334 template <class GeometryImp> 00335 void buildGlobalGeom(GeometryImp& geo) const; 00336 00337 private: 00338 //- forbidden methods 00339 const ALU3dGridGeometricFaceInfoTetra & operator=(const ALU3dGridGeometricFaceInfoTetra &); 00340 00341 protected: 00342 using Base::connector_; 00343 00344 private: 00345 //- private data 00346 mutable NormalType outerNormal_; 00347 00348 // false if surface mapping needs a update 00349 mutable bool normalUp2Date_; 00350 }; 00351 00354 template< class Comm > 00355 class ALU3dGridGeometricFaceInfoHexa 00356 : public ALU3dGridGeometricFaceInfoBase< hexa, Comm > 00357 { 00358 typedef ALU3dGridGeometricFaceInfoBase< hexa, Comm > Base; 00359 00360 public: 00361 //- public typedefs 00362 typedef FieldVector<alu3d_ctype, 3> NormalType; 00363 typedef typename Base::FaceTopo FaceTopo; 00364 typedef typename ALU3dGridFaceInfo< hexa, Comm >::GEOFaceType GEOFaceType; 00365 typedef SurfaceNormalCalculator SurfaceMappingType; 00366 00367 typedef ALU3dGridFaceInfo< hexa, Comm > ConnectorType; 00368 00369 //- constructors and destructors 00370 ALU3dGridGeometricFaceInfoHexa(const ConnectorType &); 00371 ALU3dGridGeometricFaceInfoHexa(const ALU3dGridGeometricFaceInfoHexa &); 00372 00373 NormalType & outerNormal(const FieldVector<alu3d_ctype, 2>& local) const; 00374 00376 void resetFaceGeom(); 00377 00379 template <class GeometryImp> 00380 void buildGlobalGeom(GeometryImp& geo) const; 00381 00382 private: 00383 //- forbidden methods 00384 const ALU3dGridGeometricFaceInfoHexa & operator=(const ALU3dGridGeometricFaceInfoHexa &); 00385 00386 protected: 00387 using Base::connector_; 00388 00389 private: 00390 //- private data 00391 mutable NormalType outerNormal_; 00392 00393 // surface mapping for calculating the outer normal 00394 mutable SurfaceMappingType mappingGlobal_; 00395 00396 // false if surface mapping needs a update 00397 mutable bool mappingGlobalUp2Date_; 00398 }; 00399 00400 } // end namespace Dune 00401 00402 #include "faceutility_imp.cc" 00403 00404 #endif