| 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 SetMesh(int** elementslist_in,IssmDouble** x_in,IssmDouble** y_in,int* numberofvertices,int* numberofelements);
|
|---|
| 71 | void GetMesh(int** elementslist_out,IssmDouble** x_out,IssmDouble** y_out,int* numberofvertices,int* numberofelements);
|
|---|
| 72 | void CheckMesh(int** pdata,double** pxy,int** pelements);
|
|---|
| 73 | void ReadMesh();
|
|---|
| 74 | void WriteMesh();
|
|---|
| 75 | /*}}}*/
|
|---|
| 76 | private:
|
|---|
| 77 | /*Private attributes{{{*/
|
|---|
| 78 | std::vector<int> sid2index; // Vector that keeps index of PZGeoMesh elements used in the ISSM mesh (sid)
|
|---|
| 79 | std::vector<int> index2sid; // Vector that keeps sid of issm mesh elements used in the neopz mesh (index)
|
|---|
| 80 | std::vector<int> specialelementsindex; // Vector that keeps index of the special elements (created to avoid haning nodes)
|
|---|
| 81 | TPZGeoMesh *fathermesh; // Entire mesh without refinement if refinement_type==1; refined with hanging nodes if efinement_type==0
|
|---|
| 82 | TPZGeoMesh *previousmesh; // Refined mesh without hanging nodes (it is always refpattern type), used to generate ISSM mesh
|
|---|
| 83 | IssmDouble* x; // Entire mesh
|
|---|
| 84 | IssmDouble* y;
|
|---|
| 85 | int* elementslist;
|
|---|
| 86 | int numberofvertices;
|
|---|
| 87 | int numberofelements;
|
|---|
| 88 | /*}}}*/
|
|---|
| 89 | /*Private methods{{{*/
|
|---|
| 90 | void RefineMeshOneLevel(bool &verbose,double* gl_distance,double* if_distance,double* deviatoricerror,double* thicknesserror);
|
|---|
| 91 | void RefineMeshWithSmoothing(bool &verbose,TPZGeoMesh* gmesh);
|
|---|
| 92 | void RefineMeshToAvoidHangingNodes(bool &verbose,TPZGeoMesh* gmesh);
|
|---|
| 93 | void DeleteSpecialElements(bool &verbose,TPZGeoMesh* gmesh);
|
|---|
| 94 | void GetMesh(TPZGeoMesh* gmesh,int** pdata,double** pxy,int** pelements);
|
|---|
| 95 | TPZGeoMesh* CreateRefPatternMesh(TPZGeoMesh* gmesh);
|
|---|
| 96 | inline int GetElemMaterialID(){return 1;}
|
|---|
| 97 | inline int GetNumberOfNodes(){return 3;}
|
|---|
| 98 | void PrintGMeshVTK(TPZGeoMesh *gmesh,std::ofstream &file,bool matColor=true);
|
|---|
| 99 | int GetVTK_ElType(TPZGeoEl* gel);
|
|---|
| 100 | int VerifyRefinementType(TPZGeoEl* geoel,TPZGeoMesh* gmesh);
|
|---|
| 101 | /*}}}*/
|
|---|
| 102 | };
|
|---|
| 103 |
|
|---|
| 104 | #endif
|
|---|