00001 #ifndef H_HYBRID_MESH_H
00002 #define H_HYBRID_MESH_H
00003
00010 #include <string.h>
00011 #include <vector>
00012 #include <fstream>
00013
00014
00015 #include "StaticPool.hpp"
00016
00017
00018
00019
00020
00021 #include "../MeshRead/IMeshReader.h"
00022 #include "../MeshWrite/IMeshWriter.h"
00023 #include "../GeometryModule/GeometryModule.hpp"
00024
00025 #include "hObj.h"
00026 #include "Vertex.h"
00027 #include "Edge.h"
00028
00029 #include "ElemPrism.h"
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047 #ifdef _MSC_VER
00048
00049 template<>
00050 void StaticPool<Vertex, 0>::rebuildVts2Pos();
00051
00052 template<>
00053 void StaticPool<Vertex, 0>::checkIfInVts2Pos(const uTind verts[]) const ;
00054
00055 template<>
00056 void StaticPool<Vertex, 0>::insertIntoVts2Pos(const uTind verts[],const int pos);
00057
00058 #endif
00059
00060 class hHybridMesh
00061 {
00062 static int lastMesh;
00063 public:
00064 typedef StaticPool<Elem, ElemPrism::nVerts> ElemPool;
00065 typedef StaticPool<Face, Face4::nVerts> FacePool;
00066 typedef StaticPool<Edge, Edge::nVerts> EdgePool;
00067 typedef StaticPool<Vertex, Vertex::nVerts> VertexPool;
00068 typedef ElemPool::Iterator<ElemPool::notBroken> Iterator;
00069 typedef ElemPool::constIterator<ElemPool::notBroken> constIterator;
00070 typedef ElemPool::Iterator<> allIterator;
00071 typedef ElemPool::constIterator<> allConstIterator;
00072
00073 const int meshId_;
00074
00075 hHybridMesh(MeshWrite::IMeshWriter * defaultWriter = NULL,
00076 MeshRead::IMeshReader * defaultReader = NULL);
00077
00078 ~hHybridMesh();
00079
00080 bool read(MeshRead::IMeshReader & reader);
00081 bool read(MeshRead::IMeshReader* readers[],const int noReaders);
00082 bool write(MeshWrite::IMeshWriter & writer) const ;
00083
00084 bool free();
00085
00086 virtual bool normalizationProcessor();
00087 bool printSetup();
00088 bool checkUniqueness() const;
00089 bool checkGeometry() const;
00090 bool checkTypes() const;
00091 bool checkAll() const;
00092
00093 bool createBoundaryLayer(const double thicknessProc=0.1, const int nLayers=1,
00094 const bool quadraticDistribution=false, const double * vecIgnoreNormal=NULL);
00095
00096 bool initRefine() ;
00097 bool refine();
00098 bool refineElem(hObj & el);
00099 bool refineElem(const int elemID);
00100 bool rRefine(const int BC_id, void (*reallocation_func)(double * x,double * y, double * z));
00101 bool derefine();
00102 bool derefineElem(hObj & elx);
00103 bool derefineElem(const int elemID);
00104 bool finalRef();
00105 bool isRefining() const { return isRefining_; }
00106
00107 Edge& edge(const uTind v0, const uTind v1);
00108 hObj& face(const uTind v0, const uTind v1, const uTind v2, const uTind v3=UNKNOWN);
00109 const hObj& face(const uTind v0, const uTind v1, const uTind v2, const uTind v3=UNKNOWN) const ;
00110 hObj& element(const uTind v0, const uTind v1, const uTind v2, const uTind v3, const uTind v4=UNKNOWN, const uTind v5=UNKNOWN);
00111
00112 Edge& edge(const uTind * v);
00113 hObj& face(const uTind v[4]);
00114 const hObj& face(const uTind v[4]) const;
00115
00116 ID faceVertex(const hObj & face, const Tind vertNo) const;
00117 ID elemVertex(const hObj & elem, const Tind vertNo) const;
00118 ID elemNeigh(const hObj & elem, const Tind neighNo) const;
00119 int whichNeighAmI(const hObj& elem, const hObj& otherElem) const;
00120 int whichFaceAmI(const hObj & face, const hObj& elem) const;
00121 int whichNodeAmI(const hObj & node, const hObj& elem) const;
00122 eElemFlag normalizeElem(hObj & elem);
00123 eFaceFlag normalizeFace(hObj & face,hObj & elem);
00124 double elemHSize(const hObj & elem) ;
00125
00126 void faceNormal(IN const hObj& face,OUT double vecNorm[3], OUT double * area) const;
00127
00128 eFaceFlag faceDirection(const hObj& face, const hObj & elem) const;
00129
00130 Iterator begin() { return elements_.begin(); }
00131 constIterator begin() const { return elements_.begin(); }
00132
00133
00134 size_t totalSize() const {return sizeof(*this)+vertices_.totalMemory()+edges_.totalMemory()+faces_.totalMemory()+elements_.totalMemory();}
00135 bool test() const;
00136 void findEdgeElems();
00137 void computeDist2Bound(const int BCs[],const int nBCs);
00138
00139 friend std::ofstream & operator << (std::ofstream & stream, const hHybridMesh & mesh);
00140
00141
00142 VertexPool vertices_;
00143 EdgePool edges_;
00144 FacePool faces_;
00145 ElemPool elements_;
00146
00147 std::string name_;
00148 int gen_,
00149 maxGen_,
00150 maxGenDiff_,
00151 maxEdgesPerVertex_,
00152 maxFacesPerVertex_;
00153
00154 MeshWrite::IMeshWriter* defaultWriter_;
00155 MeshRead::IMeshReader* defaultReader_;
00156
00157 std::vector< std::vector<uTind> > edge_elems;
00158 bool wasNormalized_;
00159
00160 void print() const;
00161
00162
00163
00164 protected:
00165 hHybridMesh(const hHybridMesh & other);
00166 hHybridMesh& operator=(const hHybridMesh & other);
00167
00168 bool actualRefine();
00169 bool actualDerefine();
00170 bool actualDelete();
00171 bool isRefining_;
00172
00173 #ifdef TURBULENTFLOW
00174 void computePlaneCoords(Face & face);
00175 void findNearestBoundFace(Vertex & v,const int BCs[],const int nBCs);
00176 double dist2Face(const Vertex & v,const Face & f);
00177 #endif
00178 };
00179
00181
00183 #endif // H_HYBRID_MESH_H