| 1 | #ifndef ADAPTIVEMESHREFINEMENT | 
|---|
| 2 | #define ADAPTIVEMESHREFINEMENT | 
|---|
| 3 |  | 
|---|
| 4 | /*Includes*/ | 
|---|
| 5 | /*{{{*/ | 
|---|
| 6 | /*Common includes*/ | 
|---|
| 7 | #include <iostream> | 
|---|
| 8 | #include <fstream> | 
|---|
| 9 | #include <string> | 
|---|
| 10 | #include <climits> | 
|---|
| 11 | #include <cfloat> | 
|---|
| 12 |  | 
|---|
| 13 | /*NeoPZ includes*/ | 
|---|
| 14 | #include <pz_config.h> | 
|---|
| 15 | #include <pzreal.h> | 
|---|
| 16 | #include <pzgmesh.h> | 
|---|
| 17 | #include <pzvec.h> | 
|---|
| 18 | #include <pzeltype.h> | 
|---|
| 19 |  | 
|---|
| 20 | #include <TPZRefPatternTools.h> | 
|---|
| 21 | #include <TPZRefPatternDataBase.h> | 
|---|
| 22 | #include <TPZRefPattern.h> | 
|---|
| 23 |  | 
|---|
| 24 | #include <tpzchangeel.h> | 
|---|
| 25 | #include <TPZGeoElement.h> | 
|---|
| 26 | #include <pzreftriangle.h> | 
|---|
| 27 | #include <pzgeotriangle.h> | 
|---|
| 28 | #include <tpzgeoelrefpattern.h> | 
|---|
| 29 | #include <pzgraphmesh.h> | 
|---|
| 30 | #include <TPZVTKGeoMesh.h> | 
|---|
| 31 |  | 
|---|
| 32 | #include "../shared/shared.h" | 
|---|
| 33 |  | 
|---|
| 34 | /*}}}*/ | 
|---|
| 35 |  | 
|---|
| 36 | class AdaptiveMeshRefinement{ | 
|---|
| 37 |  | 
|---|
| 38 | public: | 
|---|
| 39 | /*Public attributes{{{*/ | 
|---|
| 40 | /* | 
|---|
| 41 | * to refine: | 
|---|
| 42 | * distance_h = initial_distance * gradation ^ (level_max-h) | 
|---|
| 43 | * to unrefine: | 
|---|
| 44 | * distance_h = lag * initial_distance * gradation ^ (level_max-h) | 
|---|
| 45 | */ | 
|---|
| 46 | int refinement_type;                                            //0 uniform (faster); 1 refpattern | 
|---|
| 47 | int level_max;                                                          //max level of refinement | 
|---|
| 48 | double gradation;                                                       //geometric progression ratio to calculate radius of level h | 
|---|
| 49 | double lag;                                                                     //lag used in the unrefine process | 
|---|
| 50 | /*Target and estimators*/ | 
|---|
| 51 | double groundingline_distance;          //all elements with distance from grounding line <= groundingline_distance will be refined | 
|---|
| 52 | double icefront_distance;                               //all elements with distance from ice front <= icefront_distance will be refined | 
|---|
| 53 | double thicknesserror_threshold;                //if ==0, it will not be used | 
|---|
| 54 | double thicknesserror_groupthreshold;//group threshold | 
|---|
| 55 | double thicknesserror_maximum;          //max value of the error estimator; in general, it is defined in the first time step. Attention with restart | 
|---|
| 56 | double deviatoricerror_threshold;       //if ==0, it will not be used | 
|---|
| 57 | double deviatoricerror_groupthreshold;//group threshold | 
|---|
| 58 | double deviatoricerror_maximum;         //max value of the error estimator; in general, it is defined in the first time step. Attention with restart | 
|---|
| 59 | /*}}}*/ | 
|---|
| 60 | /*Public methods{{{*/ | 
|---|
| 61 | /* Constructor, destructor etc*/ | 
|---|
| 62 | AdaptiveMeshRefinement(); | 
|---|
| 63 | AdaptiveMeshRefinement(const AdaptiveMeshRefinement &cp); | 
|---|
| 64 | AdaptiveMeshRefinement & operator= (const AdaptiveMeshRefinement &cp); | 
|---|
| 65 | virtual ~AdaptiveMeshRefinement(); | 
|---|
| 66 | /*General methods*/ | 
|---|
| 67 | void CleanUp(); | 
|---|
| 68 | void Initialize(); | 
|---|
| 69 | void ExecuteRefinement(double* gl_distance,double* if_distance,double* deviatoricerror,double* thicknesserror,int** pdatalist,double** pxy,int** pelementslist); | 
|---|
| 70 | void CreateInitialMesh(int &nvertices,int &nelements,double* x,double* y,int* elements); | 
|---|
| 71 | void CheckMesh(int** pdata,double** pxy,int** pelements); | 
|---|
| 72 | /*}}}*/ | 
|---|
| 73 | private: | 
|---|
| 74 | /*Private attributes{{{*/ | 
|---|
| 75 | std::vector<int> sid2index;                                     // Vector that keeps index of PZGeoMesh elements used in the ISSM mesh (sid) | 
|---|
| 76 | std::vector<int> index2sid;                                     // Vector that keeps sid of issm mesh elements used in the neopz mesh (index) | 
|---|
| 77 | std::vector<int> specialelementsindex;          // Vector that keeps index of the special elements (created to avoid haning nodes) | 
|---|
| 78 | TPZGeoMesh *fathermesh;                                                 // Entire mesh without refinement if refinement_type==1; refined with hanging nodes if efinement_type==0 | 
|---|
| 79 | TPZGeoMesh *previousmesh;                                               // Refined mesh without hanging nodes (it is always refpattern type), used to generate ISSM mesh | 
|---|
| 80 | /*}}}*/ | 
|---|
| 81 | /*Private methods{{{*/ | 
|---|
| 82 | void RefineMeshOneLevel(bool &verbose,double* gl_distance,double* if_distance,double* deviatoricerror,double* thicknesserror); | 
|---|
| 83 | void RefineMeshWithSmoothing(bool &verbose,TPZGeoMesh* gmesh); | 
|---|
| 84 | void RefineMeshToAvoidHangingNodes(bool &verbose,TPZGeoMesh* gmesh); | 
|---|
| 85 | void DeleteSpecialElements(bool &verbose,TPZGeoMesh* gmesh); | 
|---|
| 86 | void GetMesh(TPZGeoMesh* gmesh,int** pdata,double** pxy,int** pelements); | 
|---|
| 87 | TPZGeoMesh* CreateRefPatternMesh(TPZGeoMesh* gmesh); | 
|---|
| 88 | inline int GetElemMaterialID(){return 1;} | 
|---|
| 89 | inline int GetNumberOfNodes(){return 3;} | 
|---|
| 90 | void PrintGMeshVTK(TPZGeoMesh *gmesh,std::ofstream &file,bool matColor=true); | 
|---|
| 91 | int GetVTK_ElType(TPZGeoEl* gel); | 
|---|
| 92 | int VerifyRefinementType(TPZGeoEl* geoel); | 
|---|
| 93 | /*}}}*/ | 
|---|
| 94 | }; | 
|---|
| 95 |  | 
|---|
| 96 | #endif | 
|---|