Ice Sheet System Model  4.18
Code documentation
Public Member Functions | Data Fields | Private Attributes
AmrBamg Class Reference

#include <AmrBamg.h>

Public Member Functions

 AmrBamg ()
 
 ~AmrBamg ()
 
void Initialize ()
 
void SetMesh (int **elementslist_in, IssmDouble **x_in, IssmDouble **y_in, int *numberofvertices, int *numberofelements)
 
void GetMesh (int **elementslist_out, IssmDouble **x_out, IssmDouble **y_out, int *numberofvertices, int *numberofelements)
 
void ExecuteRefinementBamg (IssmDouble *field, IssmDouble *hmaxVertices, int **pdatalist, IssmDouble **pxylist, int **pelementslist)
 
void SetBamgOpts (IssmDouble hmin_in, IssmDouble hmax_in, IssmDouble err_in, IssmDouble gradation_in)
 
BamgOptsGetBamgOpts ()
 

Data Fields

int fieldenum
 
int keepmetric
 
IssmDouble groundingline_resolution
 
IssmDouble groundingline_distance
 
IssmDouble icefront_resolution
 
IssmDouble icefront_distance
 
IssmDouble thicknesserror_resolution
 
IssmDouble thicknesserror_threshold
 
IssmDouble thicknesserror_groupthreshold
 
IssmDouble thicknesserror_maximum
 
IssmDouble deviatoricerror_resolution
 
IssmDouble deviatoricerror_threshold
 
IssmDouble deviatoricerror_groupthreshold
 
IssmDouble deviatoricerror_maximum
 

Private Attributes

BamgGeomgeometry
 
BamgMeshfathermesh
 
BamgMeshpreviousmesh
 
BamgOptsoptions
 
IssmDoublex
 
IssmDoubley
 
int * elementslist
 
int numberofvertices
 
int numberofelements
 

Detailed Description

Definition at line 12 of file AmrBamg.h.

Constructor & Destructor Documentation

◆ AmrBamg()

AmrBamg::AmrBamg ( )

!!!! VERY IMPORTANT !!!!! This avoid numerical errors when remeshing

Definition at line 19 of file AmrBamg.cpp.

19  {/*{{{*/
20 
21  /*These attributes MUST be setup by FemModel*/
22  this->fieldenum = -1;
23  this->keepmetric = -1;
24  this->groundingline_resolution = -1;
25  this->groundingline_distance = -1;
26  this->icefront_resolution = -1;
27  this->icefront_distance = -1;
28  this->thicknesserror_resolution = -1;
29  this->thicknesserror_threshold = -1;
31  this->thicknesserror_maximum = -1;
32  this->deviatoricerror_resolution = -1;
33  this->deviatoricerror_threshold = -1;
35  this->deviatoricerror_maximum = -1;
36 
37  /*Geometry and mesh as NULL*/
38  this->geometry = NULL;
39  this->fathermesh = NULL;
40  this->previousmesh = NULL;
41  this->elementslist = NULL;
42  this->x = NULL;
43  this->y = NULL;
44  this->numberofvertices = -1;
45  this->numberofelements = -1;
46 
47  /*Only initialize options for now (same as bamg.m)*/
48  this->options = new BamgOpts();
49  this->options->anisomax = 10.e30;
50  this->options->cutoff = 10.e-5;
51  this->options->coeff = 1;
52  this->options->errg = 0.1;
53  this->options->gradation = -1; //MUST be setup by the FemModel
54  this->options->Hessiantype = 0;
55  this->options->maxnbv = 1e6;
56  this->options->maxsubdiv = 10;
57  this->options->Metrictype = 0;
58  this->options->nbjacobi = 1;
59  this->options->nbsmooth = 3;
60  this->options->omega = 1.8;
61  this->options->power = 1;
62  this->options->verbose = 0;
63  this->options->Crack = 0;
64  this->options->KeepVertices = 1;
65  this->options->splitcorners = 1;
66  this->options->hmin = -1;/*MUST be setup by the FemModel*/
67  this->options->hmax = -1;/*MUST be setup by the FemModel*/
68  this->options->err = xNew<IssmDouble>(1);
69  this->options->err[0] = -1;/*MUST be setup by the FemModel*/
70  this->options->errSize[0] = 1;
71  this->options->errSize[1] = 1;
72 }

◆ ~AmrBamg()

AmrBamg::~AmrBamg ( )

Definition at line 74 of file AmrBamg.cpp.

74  {/*{{{*/
75 
76  if(this->geometry) delete this->geometry;
77  if(this->fathermesh) delete this->fathermesh;
78  if(this->previousmesh) delete this->previousmesh;
79  if(this->options) delete this->options;
80  if(this->x) xDelete<IssmDouble>(this->x);
81  if(this->y) xDelete<IssmDouble>(this->y);
82  if(this->elementslist) xDelete<int>(this->elementslist);
83 }

Member Function Documentation

◆ Initialize()

void AmrBamg::Initialize ( )

Definition at line 109 of file AmrBamg.cpp.

109  {/*{{{*/
110 
111  /*Check options*/
112  _assert_(this->options);
113  this->options->Check();
114 
115  /*Read father mesh and create geometry*/
116  Mesh* Th=new Mesh(this->elementslist,this->x,this->y,this->numberofvertices,this->numberofelements,this->options);
117 
118  /*Write geometry*/
119  this->geometry = new BamgGeom();
120  Th->Gh.WriteGeometry(this->geometry,this->options);
121 
122  /*Write father mesh*/
123  this->fathermesh = new BamgMesh();
124  Th->WriteMesh(this->fathermesh,this->options);
125 
126  /*Cleanup and return*/
127  delete Th;
128 }/*}}}*/

◆ SetMesh()

void AmrBamg::SetMesh ( int **  elementslist_in,
IssmDouble **  x_in,
IssmDouble **  y_in,
int *  numberofvertices,
int *  numberofelements 
)

Definition at line 87 of file AmrBamg.cpp.

87  {/*{{{*/
88 
89  /*Delete previous mesh and keep the entire mesh*/
90  if(this->elementslist) xDelete<int>(this->elementslist);
91  if(this->x) xDelete<IssmDouble>(this->x);
92  if(this->y) xDelete<IssmDouble>(this->y);
93 
94  this->elementslist = *elementslist_in;
95  this->x = *x_in;
96  this->y = *y_in;
97  this->numberofvertices = *numberofvertices_in;
98  this->numberofelements = *numberofelements_in;
99 }/*}}}*/

◆ GetMesh()

void AmrBamg::GetMesh ( int **  elementslist_out,
IssmDouble **  x_out,
IssmDouble **  y_out,
int *  numberofvertices,
int *  numberofelements 
)

Definition at line 100 of file AmrBamg.cpp.

100  {/*{{{*/
101 
102  /*Get the entire mesh*/
103  *elementslist_out = this->elementslist;
104  *x_out = this->x;
105  *y_out = this->y;
106  *numberofvertices_out= this->numberofvertices;
107  *numberofelements_out= this->numberofelements;
108 }/*}}}*/

◆ ExecuteRefinementBamg()

void AmrBamg::ExecuteRefinementBamg ( IssmDouble field,
IssmDouble hmaxVertices,
int **  pdatalist,
IssmDouble **  pxylist,
int **  pelementslist 
)

Definition at line 129 of file AmrBamg.cpp.

129  {/*{{{*/
130 
131  /*Intermediaries*/
132  BamgGeom* geomout=new BamgGeom();
133  BamgMesh* meshout=new BamgMesh();
134 
135  /*Some checks*/
136  _assert_(this->geometry);
137  _assert_(this->options);
138  _assert_(this->fathermesh);
139  _assert_(field || hmaxVertices);//at least one is necessary
140 
141  /*Prepare field for metric*/
142  this->options->field = field;
143  this->options->hmaxVertices = hmaxVertices;
144 
145  /*remesh*/
146  if(this->previousmesh){
147  this->options->fieldSize[0] = this->previousmesh->VerticesSize[0];
148  this->options->fieldSize[1] = 1;
149  this->options->hmaxVerticesSize[0] = this->previousmesh->VerticesSize[0];
150  this->options->hmaxVerticesSize[1] = 1;
151  Bamgx(meshout,geomout,this->previousmesh,this->geometry,this->options);
152  }
153  else{
154  this->options->fieldSize[0] = this->fathermesh->VerticesSize[0];
155  this->options->fieldSize[1] = 1;
156  this->options->hmaxVerticesSize[0] = this->fathermesh->VerticesSize[0];
157  this->options->hmaxVerticesSize[1] = 1;
158  Bamgx(meshout,geomout,this->fathermesh,this->geometry,this->options);
159  }
160 
161  /*remove field and hmaxVertices for memory management (FemModel is taking care of deleting it)*/
162  this->options->field = NULL;
163  this->options->fieldSize[0] = 0;
164  this->options->fieldSize[1] = 0;
165  this->options->hmaxVertices = NULL;
166  this->options->hmaxVerticesSize[0] = 0;
167  this->options->hmaxVerticesSize[1] = 0;
168 
169  /*verify if the metric will be reseted or not*/
170  if(this->keepmetric==0){
171  if(this->options->metric) xDelete<IssmDouble>(this->options->metric);
172  this->options->metricSize[0] = 0;
173  this->options->metricSize[1] = 0;
174  }
175 
176  /*Change previous mesh*/
177  if(this->previousmesh) delete this->previousmesh;
178  this->previousmesh = meshout;
179 
180  /*Prepare output*/
181  int nbv = meshout->VerticesSize[0];
182  int nbt = meshout->TrianglesSize[0];
183  int *datalist = xNew<int>(2);
184  IssmDouble *xylist= xNew<IssmDouble>(nbv*2);
185  int* elementslist = xNew<int>(nbt*3);
186 
187  datalist[0] = nbv;
188  datalist[1] = nbt;
189 
190  for(int i=0;i<nbv;i++){
191  xylist[2*i] = meshout->Vertices[i*3+0];
192  xylist[2*i+1] = meshout->Vertices[i*3+1];
193  }
194 
195  for(int i=0;i<nbt;i++){
196  elementslist[3*i+0] = reCast<int>(meshout->Triangles[4*i+0]);
197  elementslist[3*i+1] = reCast<int>(meshout->Triangles[4*i+1]);
198  elementslist[3*i+2] = reCast<int>(meshout->Triangles[4*i+2]);
199  }
200 
201  /*Assign pointers*/
202  *pdatalist = datalist;
203  *pxylist = xylist;
204  *pelementslist = elementslist;
205 
206  /*Cleanup and return*/
207  delete geomout;
208 }/*}}}*/

◆ SetBamgOpts()

void AmrBamg::SetBamgOpts ( IssmDouble  hmin_in,
IssmDouble  hmax_in,
IssmDouble  err_in,
IssmDouble  gradation_in 
)

Definition at line 209 of file AmrBamg.cpp.

209  {/*{{{*/
210 
211  if(!this->options) _error_("AmrBamg->options is NULL!");
212 
213  this->options->hmin = hmin_in;
214  this->options->hmax = hmax_in;
215  this->options->err[0] = err_in;
216  this->options->gradation= gradation_in;
217 }/*}}}*/

◆ GetBamgOpts()

BamgOpts* AmrBamg::GetBamgOpts ( )
inline

Definition at line 44 of file AmrBamg.h.

44 {return this->options;}

Field Documentation

◆ fieldenum

int AmrBamg::fieldenum

Definition at line 15 of file AmrBamg.h.

◆ keepmetric

int AmrBamg::keepmetric

Definition at line 16 of file AmrBamg.h.

◆ groundingline_resolution

IssmDouble AmrBamg::groundingline_resolution

Definition at line 17 of file AmrBamg.h.

◆ groundingline_distance

IssmDouble AmrBamg::groundingline_distance

Definition at line 18 of file AmrBamg.h.

◆ icefront_resolution

IssmDouble AmrBamg::icefront_resolution

Definition at line 19 of file AmrBamg.h.

◆ icefront_distance

IssmDouble AmrBamg::icefront_distance

Definition at line 20 of file AmrBamg.h.

◆ thicknesserror_resolution

IssmDouble AmrBamg::thicknesserror_resolution

Definition at line 21 of file AmrBamg.h.

◆ thicknesserror_threshold

IssmDouble AmrBamg::thicknesserror_threshold

Definition at line 22 of file AmrBamg.h.

◆ thicknesserror_groupthreshold

IssmDouble AmrBamg::thicknesserror_groupthreshold

Definition at line 23 of file AmrBamg.h.

◆ thicknesserror_maximum

IssmDouble AmrBamg::thicknesserror_maximum

Definition at line 24 of file AmrBamg.h.

◆ deviatoricerror_resolution

IssmDouble AmrBamg::deviatoricerror_resolution

Definition at line 25 of file AmrBamg.h.

◆ deviatoricerror_threshold

IssmDouble AmrBamg::deviatoricerror_threshold

Definition at line 26 of file AmrBamg.h.

◆ deviatoricerror_groupthreshold

IssmDouble AmrBamg::deviatoricerror_groupthreshold

Definition at line 27 of file AmrBamg.h.

◆ deviatoricerror_maximum

IssmDouble AmrBamg::deviatoricerror_maximum

Definition at line 28 of file AmrBamg.h.

◆ geometry

BamgGeom* AmrBamg::geometry
private

Definition at line 47 of file AmrBamg.h.

◆ fathermesh

BamgMesh* AmrBamg::fathermesh
private

Definition at line 48 of file AmrBamg.h.

◆ previousmesh

BamgMesh* AmrBamg::previousmesh
private

Definition at line 49 of file AmrBamg.h.

◆ options

BamgOpts* AmrBamg::options
private

Definition at line 50 of file AmrBamg.h.

◆ x

IssmDouble* AmrBamg::x
private

Definition at line 52 of file AmrBamg.h.

◆ y

IssmDouble* AmrBamg::y
private

Definition at line 53 of file AmrBamg.h.

◆ elementslist

int* AmrBamg::elementslist
private

Definition at line 54 of file AmrBamg.h.

◆ numberofvertices

int AmrBamg::numberofvertices
private

Definition at line 55 of file AmrBamg.h.

◆ numberofelements

int AmrBamg::numberofelements
private

Definition at line 56 of file AmrBamg.h.


The documentation for this class was generated from the following files:
BamgOpts::cutoff
double cutoff
Definition: BamgOpts.h:14
_assert_
#define _assert_(ignore)
Definition: exceptions.h:37
BamgOpts::power
double power
Definition: BamgOpts.h:25
IssmDouble
double IssmDouble
Definition: types.h:37
AmrBamg::y
IssmDouble * y
Definition: AmrBamg.h:53
BamgOpts::err
double * err
Definition: BamgOpts.h:47
AmrBamg::deviatoricerror_threshold
IssmDouble deviatoricerror_threshold
Definition: AmrBamg.h:26
BamgOpts::maxsubdiv
double maxsubdiv
Definition: BamgOpts.h:20
AmrBamg::deviatoricerror_groupthreshold
IssmDouble deviatoricerror_groupthreshold
Definition: AmrBamg.h:27
AmrBamg::groundingline_resolution
IssmDouble groundingline_resolution
Definition: AmrBamg.h:17
AmrBamg::x
IssmDouble * x
Definition: AmrBamg.h:52
BamgOpts::verbose
int verbose
Definition: BamgOpts.h:26
BamgOpts::Crack
int Crack
Definition: BamgOpts.h:29
AmrBamg::deviatoricerror_resolution
IssmDouble deviatoricerror_resolution
Definition: AmrBamg.h:25
BamgMesh::Vertices
double * Vertices
Definition: BamgMesh.h:12
BamgOpts::field
double * field
Definition: BamgOpts.h:45
BamgOpts::Hessiantype
int Hessiantype
Definition: BamgOpts.h:18
AmrBamg::icefront_resolution
IssmDouble icefront_resolution
Definition: AmrBamg.h:19
AmrBamg::deviatoricerror_maximum
IssmDouble deviatoricerror_maximum
Definition: AmrBamg.h:28
AmrBamg::options
BamgOpts * options
Definition: AmrBamg.h:50
BamgMesh
Definition: BamgMesh.h:7
AmrBamg::previousmesh
BamgMesh * previousmesh
Definition: AmrBamg.h:49
BamgOpts::coeff
double coeff
Definition: BamgOpts.h:15
BamgOpts::nbjacobi
int nbjacobi
Definition: BamgOpts.h:22
AmrBamg::fieldenum
int fieldenum
Definition: AmrBamg.h:15
AmrBamg::thicknesserror_maximum
IssmDouble thicknesserror_maximum
Definition: AmrBamg.h:24
AmrBamg::fathermesh
BamgMesh * fathermesh
Definition: AmrBamg.h:48
AmrBamg::icefront_distance
IssmDouble icefront_distance
Definition: AmrBamg.h:20
BamgOpts::omega
double omega
Definition: BamgOpts.h:24
BamgOpts::metricSize
int metricSize[2]
Definition: BamgOpts.h:42
BamgOpts::KeepVertices
int KeepVertices
Definition: BamgOpts.h:30
BamgOpts::gradation
double gradation
Definition: BamgOpts.h:17
BamgMesh::VerticesSize
int VerticesSize[2]
Definition: BamgMesh.h:11
AmrBamg::thicknesserror_resolution
IssmDouble thicknesserror_resolution
Definition: AmrBamg.h:21
BamgOpts::nbsmooth
int nbsmooth
Definition: BamgOpts.h:23
BamgOpts::fieldSize
int fieldSize[2]
Definition: BamgOpts.h:44
BamgOpts::hmaxVerticesSize
int hmaxVerticesSize[2]
Definition: BamgOpts.h:38
BamgOpts::hmaxVertices
double * hmaxVertices
Definition: BamgOpts.h:39
AmrBamg::keepmetric
int keepmetric
Definition: AmrBamg.h:16
BamgOpts::hmax
double hmax
Definition: BamgOpts.h:35
BamgOpts
Definition: BamgOpts.h:8
BamgOpts::errSize
int errSize[2]
Definition: BamgOpts.h:46
BamgOpts::splitcorners
int splitcorners
Definition: BamgOpts.h:31
BamgOpts::maxnbv
int maxnbv
Definition: BamgOpts.h:19
AmrBamg::numberofvertices
int numberofvertices
Definition: AmrBamg.h:55
BamgOpts::metric
double * metric
Definition: BamgOpts.h:43
bamg::Mesh
Definition: Mesh.h:21
BamgMesh::TrianglesSize
int TrianglesSize[2]
Definition: BamgMesh.h:16
BamgGeom
Definition: BamgGeom.h:7
_error_
#define _error_(StreamArgs)
Definition: exceptions.h:49
BamgOpts::hmin
double hmin
Definition: BamgOpts.h:34
bamg::Geometry::WriteGeometry
void WriteGeometry(BamgGeom *bamggeom, BamgOpts *bamgopts)
Definition: Geometry.cpp:266
AmrBamg::geometry
BamgGeom * geometry
Definition: AmrBamg.h:47
BamgOpts::Check
void Check(void)
Definition: BamgOpts.cpp:50
BamgOpts::errg
double errg
Definition: BamgOpts.h:16
AmrBamg::thicknesserror_threshold
IssmDouble thicknesserror_threshold
Definition: AmrBamg.h:22
bamg::Mesh::WriteMesh
void WriteMesh(BamgMesh *bamgmesh, BamgOpts *bamgopts)
Definition: Mesh.cpp:493
bamg::Mesh::Gh
Geometry & Gh
Definition: Mesh.h:25
AmrBamg::elementslist
int * elementslist
Definition: AmrBamg.h:54
BamgOpts::anisomax
double anisomax
Definition: BamgOpts.h:13
BamgOpts::Metrictype
int Metrictype
Definition: BamgOpts.h:21
AmrBamg::thicknesserror_groupthreshold
IssmDouble thicknesserror_groupthreshold
Definition: AmrBamg.h:23
Bamgx
int Bamgx(BamgMesh *bamgmesh_out, BamgGeom *bamggeom_out, BamgMesh *bamgmesh_in, BamgGeom *bamggeom_in, BamgOpts *bamgopts)
Definition: Bamgx.cpp:12
BamgMesh::Triangles
double * Triangles
Definition: BamgMesh.h:17
AmrBamg::groundingline_distance
IssmDouble groundingline_distance
Definition: AmrBamg.h:18
AmrBamg::numberofelements
int numberofelements
Definition: AmrBamg.h:56