00001
00002
00003
00004
00005
00006
00007
00008
00009 #ifndef __CHARM_FEM_ADAPT_ALGS_H
00010 #define __CHARM_FEM_ADAPT_ALGS_H
00011
00012 #include "charm++.h"
00013 #include "tcharm.h"
00014 #include "charm-api.h"
00015 #include "ckvector3d.h"
00016 #include "fem.h"
00017 #include "fem_mesh.h"
00018 #include "vector2d.h"
00019
00020 #define SLIVERAREA 1.0e-18
00021 #define REFINE_TOL 1.1 // Refine elements with average edge length >
00022
00023 #define COARSEN_TOL 0.8 // Coarsen element with average edge length <
00024
00025 #define QUALITY_MIN 0.6
00026
00027 class FEM_Adapt_Algs;
00028 CtvExtern(FEM_Adapt_Algs *, _adaptAlgs);
00029
00030 class femMeshModify;
00031 class FEM_Adapt;
00032 class FEM_AdaptL;
00033
00034 class FEM_Adapt_Algs {
00035 friend class FEM_AdaptL;
00036 friend class FEM_Adapt;
00037 friend class femMeshModify;
00038 friend class FEM_Interpolate;
00039 friend class FEM_MUtil;
00040
00041 public:
00042 int coord_attr;
00043 int bc_attr;
00044
00045 protected:
00046 FEM_Mesh *theMesh;
00047 femMeshModify *theMod;
00048
00049 FEM_AdaptL *theAdaptor;
00050 int numNodes, numElements, dim;
00051
00052 typedef struct {
00053 int elID;
00054 double len;
00055 } elemHeap;
00056 elemHeap *coarsenElements;
00057 elemHeap *refineElements;
00058 elemHeap *refineStack;
00059 int refineTop, refineHeapSize, coarsenHeapSize;
00060
00061 public:
00062 FEM_Adapt_Algs() {
00063 theMesh = NULL; theMod = NULL; theAdaptor = NULL;
00064 }
00066 FEM_Adapt_Algs(FEM_Mesh *m, femMeshModify *fm, int dimension);
00067 void FEM_Adapt_Algs_Init(int coord_at, int bc_at) {
00068 coord_attr = coord_at;
00069 bc_attr = bc_at;
00070 }
00072
00077 void FEM_Refine(int qm, int method, double factor, double *sizes);
00079
00084 void FEM_Coarsen(int qm, int method, double factor, double *sizes);
00086
00087 void FEM_AdaptMesh(int qm, int method, double factor, double *sizes);
00089 void FEM_Smooth(int qm, int method);
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101 void FEM_mesh_smooth(FEM_Mesh *meshP, int *nodes, int nNodes, int attrNo);
00102
00103 void FEM_Repair(int qm);
00105
00109 void FEM_Remesh(int qm, int method, double factor, double *sizes);
00110
00112 void SetReferenceMesh();
00114 void GradateMesh(double smoothness);
00115 private:
00116
00118 int Refine(int qm, int method, double factor, double *sizes);
00120 int Coarsen(int qm, int method, double factor, double *sizes);
00122 void SetMeshSize(int method, double factor, double *sizes);
00124 void Insert(int elID, double len, int cFlag);
00126 int Delete_Min(int cFlag);
00127 public:
00129
00132 virtual int refine_element_leb(int e);
00133 virtual void refine_flip_element_leb(int e, int p, int n1, int n2,
00134 double le);
00135
00136 int simple_refine(double targetA, double xmin=0.0, double ymin=0.0, double xmax=1.0, double ymax=1.0);
00137 int simple_coarsen(double targetA, double xmin=0.0, double ymin=0.0, double xmax=1.0, double ymax=1.0);
00138 double length(int n1, int n2);
00139 double getArea(int n1, int n2, int n3);
00140 double length(double *n1_coord, double *n2_coord);
00141 double getArea(double *n1_coord, double *n2_coord, double *n3_coord);
00142 int getCoord(int n1, double *crds);
00143 int getShortestEdge(int n1, int n2, int n3, int* shortestEdge);
00144 double getAreaQuality(int elem);
00145 bool didItFlip(int n1, int n2, int n3, double *n4_coord);
00146 bool didItFlip(double *n1_coord, double *n2_coord, double *n3_coord, double *n4_coord);
00147 double getSignedArea(double *n1_coord, double *n2_coord, double *n3_coord);
00148 void tests(void);
00149 };
00150
00151
00152 #endif