23 double hminaniso=1e-100;
29 coef =bamgopts->
coeff;
34 if (bamgopts->
metric==NULL) nbsmooth=0;
41 if (verbosity>0)
_printf_(
"Construction of a mesh from a given geometry\n");
42 if (verbosity>1)
_printf_(
" Processing geometry...\n");
46 bamgopts->
hmin =
Max(bamgopts->
hmin,Gh.MinimalHmin());
47 bamgopts->
hmax =
Min(bamgopts->
hmax,Gh.MaximalHmax());
50 if (verbosity>1)
_printf_(
" Generating Metric...\n");
51 for(i=0;i<Gh.nbv;i++){
54 Vp.Maxh(bamgopts->
hmax);
55 Vp.Minh(bamgopts->
hmin);
56 Gh.vertices[i].m = Vp;
60 if (verbosity>1)
_printf_(
" Generating Mesh...\n");
61 Mesh Th(maxnbv,Gh,bamgopts);
64 if(bamgopts->
splitcorners) Th.SplitInternalEdgeWithBorderVertices();
67 Th.TrianglesRenumberBySubDomain();
70 if(bamgopts->
Crack) Th.CrackMesh(bamgopts);
73 if (verbosity>1)
_printf_(
" Write Mesh...\n");
74 Th.WriteMesh(bamgmesh_out,bamgopts);
75 if (verbosity>1)
_printf_(
" Write Geometry...\n");
76 Gh.WriteGeometry(bamggeom_out,bamgopts);
87 if (verbosity>0)
_printf_(
"Anisotropic mesh adaptation\n");
88 if (verbosity>1)
_printf_(
" Processing initial mesh and geometry...\n");
89 Mesh BTh(bamggeom_in,bamgmesh_in,bamgopts);
92 BTh.MakeBamgQuadtree();
95 bamgopts->
hmin=
Max(bamgopts->
hmin,BTh.MinimalHmin());
96 bamgopts->
hmax=
Min(bamgopts->
hmax,BTh.MaximalHmax());
100 if (verbosity>1)
_printf_(
" Processing Metric...\n");
101 BTh.ReadMetric(bamgopts);
104 if (verbosity>1)
_printf_(
" Generating initial Metric...\n");
106 for (
int iv=0;iv<BTh.nbv;iv++) BTh[iv].m = Mhmax;
110 if (bamgopts->
field){
111 if (verbosity>1)
_printf_(
" Merge metric with field provided...\n");
112 BTh.AddMetric(bamgopts);
117 if (verbosity>1)
_printf_(
" Merging Metric with hVertices...\n");
118 for (i=0;i<BTh.nbv;i++){
119 if (!xIsNan<IssmPDouble>(bamgopts->
hVertices[i])){
127 if (verbosity>1)
_printf_(
" Merging Metric with hminVertices...\n");
128 for (i=0;i<BTh.nbv;i++){
130 Metric M=BTh.vertices[i].m;
133 BTh.vertices[i].m=Vp;
140 if (verbosity>1)
_printf_(
" Merging Metric with hmaxVertices...\n");
141 for (i=0;i<BTh.nbv;i++){
143 Metric M=BTh.vertices[i].m;
146 BTh.vertices[i].m=Vp;
152 BTh.SmoothMetric(bamgopts,bamgopts->
gradation);
155 BTh.MaxSubDivision(bamgopts,bamgopts->
maxsubdiv);
158 BTh.BoundAnisotropy(bamgopts,bamgopts->
anisomax,hminaniso);
161 if (verbosity>1)
_printf_(
" Generating Mesh...\n");
164 if (Thr != &BTh)
delete Thr;
170 Th.TrianglesRenumberBySubDomain();
173 if(nbsmooth>0) Th.SmoothingVertex(bamgopts,nbsmooth,bamgopts->
omega);
177 if (Th.nbt-Th.nbtout){
178 _printf_(
" new number of triangles = " << (Th.nbt-Th.nbtout) <<
"\n");
183 if (verbosity>1)
_printf_(
" Write Mesh...\n");
184 Th.WriteMesh(bamgmesh_out,bamgopts);
185 if (verbosity>1)
_printf_(
" Write Geometry...\n");
186 Th.Gh.WriteGeometry(bamggeom_out,bamgopts);
187 if (verbosity>1)
_printf_(
" Write Metric...\n");
188 BTh.WriteMetric(bamgopts);
197 if (verbosity>1)
_printf_(
" Exiting Bamg.\n");