00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #if !defined(ELEM2D_HPP)
00012 #define ELEM2D_HPP
00013
00014 #include "gtvector.hpp"
00015 #include "gtmatrix.hpp"
00016 #include "gnbasis.hpp"
00017 #include "gmortar1d.hpp"
00018 #include "gneighbor.hpp"
00019 #include "gtlist.hpp"
00020 #include "gmemmgr.hpp"
00021 #include "mtk.hpp"
00022
00023 class GMortar1D;
00024 class Elem2D
00025 {
00026 public:
00027 Elem2D(GSHORT ntmp=2);
00028 virtual ~Elem2D();
00029
00030
00031 virtual ELEMTYPE ElemType(){return elemtype_;}
00032 virtual GINT Dim(){return GDIM;}
00033 GINT GetOrder(const GINT idir);
00034 GINT GetNumNodes();
00035 virtual GDOUBLE Integrate(GVector *v, GDOUBLE *multiplicity=NULL)=0;
00036 virtual GDOUBLE PIntegrate(GVector *v, GDOUBLE *multiplicity=NULL)=0;
00037 virtual GBOOL Differentiate(GVector *dv, GVector *v, GINT idir)=0;
00038 virtual GBOOL DifferentiateWithMass(GVector *dv, GVector *v, GVector* tmp, GINT idir)=0;
00039 virtual GBOOL DifferentiateWeak(GVector *dv, GVector *v,GVector* tmp, GINT idir)=0;
00040 GVector *GetTemp();
00041 GVector *GetTemp(GSHORT i);
00042 GMemMgr *GetTempMgr();
00043 GBOOL TempLock(GVector *vec);
00044 GBOOL TempUnlock(GVector *vec);
00045 GDOUBLE GetArea();
00046 GDOUBLE GetMinEdgeLength();
00047 GDOUBLE GetMaxEdgeLength();
00048 Point3D *GetSpVertices(GINT ivertex=-1);
00049 Point3D *GetSpMidpoints(GINT iEdge=-1);
00050 Point3D *GetElemCenter();
00051 GDOUBLE *GetSpvVertices();
00052 GINT GetNumVertices();
00053 GINT GetNumEdges();
00054 GINT GetNumFaces();
00055 void Vertex2EdgePoint(GINT iedge[], GINT ipoint[], const GINT ivert);
00056 GINT EdgePoint2Vertex(const GINT ie, const GINT ip);
00057 void Edge2Vertex(GINT iv[], const GINT ie);
00058 GBOOL isVirtualVertex(GINT iedge, GINT iendpoint);
00059 GBOOL GetCommonVertex(GINT &icedge, GINT &icendpoint,
00060 const GINT iedge, const GINT iendpoint);
00061 void GetVertexCommonEdges(GINT icedge[], GINT icendpoint[], const GINT ivertex);
00062 GMortar1D *GetEdgeMortar(GINT iedge=-1);
00063 GIBuffer *GetEdgeIndices(GINT iedge=-1);
00064 GIBuffer *GetEdgeIndicesN(GINT iedge=-1);
00065 GIBuffer *GetInteriorIndices();
00066 GIBuffer *GetVertexIndices(GINT iedge=-1);
00067 GVector *GetNodalMultiplicity();
00068 GVector *GetMask();
00069 GVector *GetBdyMask();
00070 GNeighborList *GetVNeighbor (GINT ivertex=-1);
00071 GNeighborList *GetVVNeighbor(GINT ivertex=-1);
00072 GNeighborList *GetENeighbor(GINT iedge=-1);
00073 GIBuffer *GetBdyIndices();
00074 GBTBuffer *GetBdyTypes();
00075 BDYTYPE &GetVertType(GINT i);
00076 BDYTYPE &GetEdgeType(GINT i);
00077 BDYTYPE &GetFaceType(GINT i);
00078 GINT &bGlobalBdyEdge(GINT i);
00079 void ComputeBdyInfo();
00080 #if defined(IS3D)
00081 GINT GetNumFaces();
00082 GMortar2D *GetFaceMortar(GINT iface=-1);
00083 GIBuffer *GetFaceIndices(GINT iface=-1);
00084 BDYTYPE &GetFaceType(GINT i);
00085 #endif
00086 GKEY GetID();
00087 GKEY GetParentID();
00088 GKEY GetRootID();
00089 GDOUBLE GetiRootID();
00090 #if 0
00091 GVector *GetTmp(GINT iwhich=0);
00092 GINT GetNTmp();
00093 #endif
00094 GNBasis *GetDBasisObj(GINT idir);
00095 virtual GNBasis *GetBasisObj(GINT idir)=0;
00096 virtual GVector *Get1DWeights(GINT idir)=0;
00097 virtual GVector *GetXiNodes(GINT idir)=0;
00098 virtual GMatrix *Get1DDerivMatrix(GINT idir, GBOOL bTranspose)=0;
00099 virtual GMatrix *Get1DDerivMatrixWithMass(GINT idir, GBOOL bTranspose)=0;
00100 virtual GMatrix *Get1DDerivMatrixWeak(GINT idir, GBOOL bTranspose)=0;
00101 virtual GMatrix *Get1DStiffMatrix(GINT idir, GBOOL bTranspose)=0;
00102 virtual GVector *Get2DWeights()=0;
00103 virtual GVector *GetMassMatrix()=0;
00104 virtual GVector *GetiMass()=0;
00105 virtual GVector *GetgMass()=0;
00106 virtual GBOOL Assemble()=0;
00107 virtual GVector *GetSpNodes(GINT idir)=0;
00108 virtual GMatrix *GetInterpOp(GINT idir, GBOOL Transpose)=0;
00109 virtual GMatrix *GetInterpDeriv(GINT idir, GBOOL Transpose)=0;
00110
00111
00112
00113
00114
00115
00116 virtual GBOOL XToXi(Point3D pX[], Point3D pXi[], const GINT n)=0;
00117 GBOOL Interp(GVector *Ufrom, Point3D *xto, GINT *ito, GINT nto, GVector *Uto);
00118 GDOUBLE Interp(const GSHORT iLevel, const GDOUBLE x, const GDOUBLE y);
00119
00120 GBOOL Map2NewCoords(GVector *oldU, GVector *newX[], GINT nc, GINT *inew, GINT ni,
00121 GVector *newU, GIBuffer *&iremap);
00122
00123
00124 void SetID(GKEY id);
00125 void SetParentID(GKEY id);
00126 void SetRootID(GKEY id);
00127 void SetBasis(GNBasis *b1, GNBasis *b2) ;
00128 void SetBasis(GNBasis *b, GINT idir) ;
00129 void SetDBasis(GNBasis *b, GINT idir) ;
00130 GVector *GetDMass() ;
00131 GMatrix *GetDJ (GINT idir) ;
00132 GMatrix *GetDJT (GINT idir) ;
00133 GBOOL DealiasingEnabled();
00134
00135 virtual GBOOL ComputeSpNodes()=0;
00136 virtual GBOOL SetVertices(Point3D P[], GINT num)=0;
00137 virtual void SetInterpBasis(GNBasis *b1, GNBasis *b2)=0;
00138 void SetOrder(GINT iorder1, GINT iorder2);
00139 virtual GBOOL Resize(GINT order1, GINT order2)=0;
00140 virtual GINT SolveFE()=0;
00141
00142 virtual GBOOL Point_in_poly(Point3D V[], GINT , Point3D P[], GINT num);
00143 virtual GBOOL Point_in_poly(Point3D P[], GINT num);
00144 virtual GBOOL Point_in_poly(GDOUBLE x, GDOUBLE y);
00145 friend ostream& operator<<(ostream&, Elem2D &);
00146
00147
00148 inline GDOUBLE X1(GDOUBLE xi1, GDOUBLE xi2){ return 0.25*(spVertices[0].x1*(1.0-xi1)*(1.0-xi2)
00149 +spVertices[1].x1*(1.0+xi1)*(1.0-xi2)
00150 +spVertices[3].x1*(1.0-xi1)*(1.0+xi2)
00151 +spVertices[2].x1*(1.0+xi1)*(1.0+xi2)); }
00152
00153
00154
00155 inline GDOUBLE X2(GDOUBLE xi1, GDOUBLE xi2){ return 0.25*(spVertices[0].x2*(1.0-xi1)*(1.0-xi2)
00156 +spVertices[1].x2*(1.0+xi1)*(1.0-xi2)
00157 +spVertices[3].x2*(1.0-xi1)*(1.0+xi2)
00158 +spVertices[2].x2*(1.0+xi1)*(1.0+xi2)); }
00159
00160 inline GBOOL AreEqual(Point3D P1, Point3D P2)
00161 {if ( P1.x1==P2.x1 && P1.x2==P2.x2) return TRUE; else return FALSE;}
00162
00163 inline GBOOL AreEqual(IPoint3D P1, IPoint3D P2)
00164 {if ( P1.i1==P2.i1 && P1.i2==P2.i2) return TRUE; else return FALSE;}
00165
00166
00167 protected:
00168 void CreateElemDynamic();
00169 void InitMortars();
00170 void SetIndices();
00171
00172
00173 GINT Np1;
00174 GINT Np2;
00175 GINT **iep2v_;
00176 GBOOL bInitialized;
00177 GBOOL bSolved;
00178 ELEMTYPE elemtype_;
00179 GKEY elemid_;
00180 GKEY parentid_;
00181 GKEY rootid_;
00182 GINT nVertices_;
00183 GINT nEdges_;
00184 GINT nFaces_;
00185 Point3D *spVertices;
00186 Point3D *spMidpoints;
00187 Point3D *elemCenter;
00188 GDOUBLE area_;
00189 GDOUBLE irootid_;
00190 GDOUBLE *spvVertices;
00191 GVector *spNodes1;
00192 GVector *spNodes2;
00193 GNBasis *basis1;
00194 GNBasis *basis2;
00195 GNBasis *gbasis1;
00196 GNBasis *gbasis2;
00197
00198
00199 GNBasis *dealias_basis_[GDIM];
00200 GMatrix JD_ [GDIM];
00201 GMatrix JDT_[GDIM];
00202 GVector DMassMatrix_;
00203
00204
00205
00206 GMortar1D *edge_mortars_;
00207 GNeighborList *vertex_neighbor_;
00208 GNeighborList *vvertex_neighbor_;
00209 GNeighborList *edge_neighbor_ ;
00210 GIBuffer *vert_indices_;
00211 GIBuffer *edge_indices_;
00212 GIBuffer *edge_indicesn_;
00213 GIBuffer *inter_indices_;
00214 GIBuffer *midpnt_indices_;
00215 GVector *nodal_multiplicity_;
00216 GIBuffer *bdy_indices_;
00217 GBTBuffer *bdy_types_;
00218 GBTBuffer *vert_types_;
00219 GBTBuffer *edge_types_;
00220 GBTBuffer *face_types_;
00221 GIBuffer *bGlobal_edge_;
00222 GVector *mask_;
00223 GVector *bmask_;
00224 #if defined(IS3D)
00225 GINT nFaces_;
00226 GMortar2D *face_mortar_;
00227 GNeighborList *face_neighbor_;
00228 GIBuffer *face_indices_;
00229 GBTBuffer *face_types_;
00230 #endif
00231 GVector vtmp[G_NUM_ELEM_TMP];
00232 GMemMgr *vtmpmgr_;
00233 };
00234
00235 #endif