Changeset 2941
- Timestamp:
- 02/01/10 14:57:22 (15 years ago)
- Location:
- issm/trunk/src
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk/src/c/Bamgx/Bamgx.cpp
r2937 r2941 33 33 34 34 /*Bamg options*/ 35 int iso;35 double anisomax; 36 36 int maxnbv; 37 37 double hmin,hmax; 38 double err,errg,coef;38 double coef; 39 39 int verbosity; 40 40 int NbSmooth; … … 46 46 int allquad=0; 47 47 double costheta=2; 48 double anisomax = 1e6;49 48 int KeepBackVertices=1; 50 49 double hminaniso=1e-100; … … 56 55 57 56 /*Bamg options*/ 58 iso=bamgopts->iso; 59 err=bamgopts->err; 60 errg=bamgopts->errg; 57 anisomax=bamgopts->anisomax; 61 58 NbSmooth=bamgopts->NbSmooth; 62 59 omega=bamgopts->omega; … … 71 68 throw ErrorException(__FUNCT__,exprintf("maxsubdiv %g is should be in ]1,%g]",maxsubdiv,boundmaxsubdiv)); 72 69 } 73 // if iso, then anisomax = 1;74 if (iso) anisomax=1;75 70 // no metric -> no smoothing 76 71 if (bamgopts->metric==NULL){ … … 159 154 } 160 155 161 BTh.IntersectGeomMetric( errg,iso);156 BTh.IntersectGeomMetric(bamgopts); 162 157 if (verbosity>1) printf(" Smoothing Metric..."); 163 158 if(bamgopts->gradation) BTh.SmoothMetric(bamgopts->gradation); -
issm/trunk/src/c/Bamgx/Mesh2.h
r2940 r2941 137 137 // ~Vertex(){} 138 138 Real8 Smoothing(Triangles & ,const Triangles & ,Triangle * & ,Real8 =1); 139 void MetricFromHessian(const double Hxx,const double Hyx, const double Hyy, const double smin,const double smax,const double s, BamgOpts* bamgopts);139 void MetricFromHessian(const double Hxx,const double Hyx, const double Hyy, const double smin,const double smax,const double s,const double err,BamgOpts* bamgopts); 140 140 void Echo(); 141 141 int ref() const { return ReferenceNumber;} … … 802 802 void BuildMetric0(BamgOpts* bamgopts); 803 803 void BuildMetric1(BamgOpts* bamgopts); 804 void IntersectGeomMetric( const Real8 err,const int iso);804 void IntersectGeomMetric(BamgOpts* bamgopts); 805 805 806 806 … … 1078 1078 } 1079 1079 1080 inline void Triangles::SetVertexFieldOn() 1081 { 1080 inline void Triangles::SetVertexFieldOn(){ 1082 1081 for (Int4 i=0;i<nbv;i++) 1083 1082 vertices[i].on=0; … … 1087 1086 VerticesOnGeomEdge[k].SetOn(); 1088 1087 } 1089 inline void Triangles::SetVertexFieldOnBTh() 1090 { 1088 inline void Triangles::SetVertexFieldOnBTh(){ 1091 1089 for (Int4 i=0;i<nbv;i++) 1092 1090 vertices[i].on=0; -
issm/trunk/src/c/Bamgx/objects/Triangles.cpp
r2940 r2941 712 712 int i; 713 713 xfree((void**)&bamgopts->metric); 714 if (bamgopts->iso){ 715 bamgopts->metric=(double*)xmalloc(1*nbv*sizeof(double)); 716 for (i=0;i<nbv;i++){ 717 MatVVP2x2 V=vertices[i].m; 718 bamgopts->metric[i]=V.hmin(); 719 } 720 } 721 else { 722 bamgopts->metric=(double*)xmalloc(3*nbv*sizeof(double)); 723 for (i=0;i<nbv;i++){ 724 bamgopts->metric[i*3+0]=vertices[i].m.a11; 725 bamgopts->metric[i*3+1]=vertices[i].m.a21; 726 bamgopts->metric[i*3+2]=vertices[i].m.a22; 727 } 714 bamgopts->metric=(double*)xmalloc(3*nbv*sizeof(double)); 715 for (i=0;i<nbv;i++){ 716 bamgopts->metric[i*3+0]=vertices[i].m.a11; 717 bamgopts->metric[i*3+1]=vertices[i].m.a21; 718 bamgopts->metric[i*3+2]=vertices[i].m.a22; 728 719 } 729 720 } … … 1068 1059 /*Compute Metric from Hessian*/ 1069 1060 for ( iv=0;iv<nbv;iv++){ 1070 vertices[iv].MetricFromHessian(dxdx_vertex[iv],dxdy_vertex[iv],dydy_vertex[iv],smin,smax,ss[iv*nbsol+nusol],bamgopts );1061 vertices[iv].MetricFromHessian(dxdx_vertex[iv],dxdy_vertex[iv],dydy_vertex[iv],smin,smax,ss[iv*nbsol+nusol],bamgopts->err[nusol],bamgopts); 1071 1062 } 1072 1063 … … 1361 1352 /*Compute Metric from Hessian*/ 1362 1353 for ( iv=0;iv<nbv;iv++){ 1363 vertices[iv].MetricFromHessian(dxdx[iv],dxdy[iv],dydy[iv],smin,smax,ss[iv*nbsol+nusol],bamgopts );1354 vertices[iv].MetricFromHessian(dxdx[iv],dxdy[iv],dydy[iv],smin,smax,ss[iv*nbsol+nusol],bamgopts->err[nusol],bamgopts); 1364 1355 } 1365 1356 … … 3242 3233 /*FUNCTION Triangles::IntersectConsMetric{{{1*/ 3243 3234 void Triangles::IntersectConsMetric(BamgOpts* bamgopts){ 3244 // the array of solution s is store 3245 // sol0,sol1,...,soln on vertex 0 3246 // sol0,sol1,...,soln on vertex 1 3247 // etc. 3248 // Hessiantype = 0 => H is computed with green formula 3249 // Hessiantype = 1 => H is computed from P2 on 4T 3235 // Hessiantype = 0 => H is computed using double P2 projection 3236 // Hessiantype = 1 => H is computed with green formula 3250 3237 3251 3238 /*Options*/ … … 3264 3251 /*}}}1*/ 3265 3252 /*FUNCTION Triangles::IntersectGeomMetric{{{1*/ 3266 void Triangles::IntersectGeomMetric(const Real8 err=1,const int iso=0){ 3267 long int verbosity=0; 3253 void Triangles::IntersectGeomMetric(BamgOpts* bamgopts){ 3254 3255 /*Get options*/ 3256 int verbosity=bamgopts->verbose; 3257 double anisomax =bamgopts->anisomax; 3258 double err =bamgopts->err[0]; //to be changed... 3259 3268 3260 Real8 ss[2]={0.00001,0.99999}; 3269 3261 Real8 errC = 2*sqrt(2*err); 3270 3262 Real8 hmax = Gh.MaximalHmax(); 3271 3263 Real8 hmin = Gh.MinimalHmin(); 3272 Real8 maxaniso = 1e6; 3264 3265 //check that hmax is positive 3273 3266 if (hmax<=0){ 3274 3267 throw ErrorException(__FUNCT__,exprintf("hmax<=0")); 3275 3268 } 3269 3270 //errC cannot be higher than 1 3271 if (errC > 1) errC = 1; 3272 3273 //Set all vertices to "on" 3276 3274 SetVertexFieldOn(); 3277 if (errC > 1) errC = 1; 3278 for (Int4 i=0;i<nbe;i++)3279 for (int j=0;j<2;j++)3280 {3281 3282 3283 3284 3285 { 3286 3287 3288 3289 3290 Real8 ht =hmax;3291 if (R1>1.0e-20) {// err relative to the length of the edge3292 ht = Min(Max(errC/R1,hmin),hmax);3293 }3294 Real8 hn = iso? ht : Min(hmax,ht*maxaniso);3295 if (ht<=0 || hn<=0){3296 throw ErrorException(__FUNCT__,exprintf("ht<=0 || hn<=0"));3297 }3298 MatVVP2x2 Vp(1/(ht*ht),1/(hn*hn),tg);3299 Metric MVp(Vp);3300 edges[i][j].m.IntersectWith(MVp);3301 }3302 3303 3275 3276 //loop over all the vertices on edges 3277 for (Int4 i=0;i<nbe;i++){ 3278 for (int j=0;j<2;j++){ 3279 3280 Vertex V; 3281 VertexOnGeom GV; 3282 Gh.ProjectOnCurve(edges[i],ss[j],V,GV); 3283 3284 GeometricalEdge * eg = GV; 3285 Real8 s = GV; 3286 R2 tg; 3287 Real8 R1= eg->R1tg(s,tg); 3288 Real8 ht=hmax; 3289 // err relative to the length of the edge 3290 if (R1>1.0e-20) { 3291 ht = Min(Max(errC/R1,hmin),hmax); 3292 } 3293 Real8 hn=Min(hmax,ht*anisomax); 3294 if (ht<=0 || hn<=0){ 3295 throw ErrorException(__FUNCT__,exprintf("ht<=0 || hn<=0")); 3296 } 3297 MatVVP2x2 Vp(1/(ht*ht),1/(hn*hn),tg); 3298 Metric MVp(Vp); 3299 edges[i][j].m.IntersectWith(MVp); 3300 } 3301 } 3304 3302 // the problem is for the vertex on vertex 3305 3303 } -
issm/trunk/src/c/Bamgx/objects/Vertex.cpp
r2940 r2941 128 128 /*}}}1*/ 129 129 /*FUNCTION Vertex::MetricFromHessian{{{1*/ 130 void Vertex::MetricFromHessian(const double Hxx,const double Hyx, const double Hyy,const double smin,const double smax,const double s, BamgOpts* bamgopts){130 void Vertex::MetricFromHessian(const double Hxx,const double Hyx, const double Hyy,const double smin,const double smax,const double s,double err,BamgOpts* bamgopts){ 131 131 /*Compute Metric from Hessian*/ 132 132 … … 152 152 */ 153 153 if (Metrictype==0){ 154 ci= 2.0/9.0 * 1/( bamgopts->err*coef*coef);154 ci= 2.0/9.0 * 1/(err*coef*coef); 155 155 } 156 156 … … 163 163 */ 164 164 else if (Metrictype==1){ 165 ci= 2.0/9.0 * 1/( bamgopts->err*coef*coef) * 1/Max( Abs(s), CutOff*(Max(Abs(smin),Abs(smax))));165 ci= 2.0/9.0 * 1/(err*coef*coef) * 1/Max( Abs(s), CutOff*(Max(Abs(smin),Abs(smax)))); 166 166 } 167 167 … … 173 173 */ 174 174 else if (Metrictype==2){ 175 ci= 2.0/9.0 * 1/( bamgopts->err*coef*coef) * 1/(smax-smin);175 ci= 2.0/9.0 * 1/(err*coef*coef) * 1/(smax-smin); 176 176 } 177 177 else{ -
issm/trunk/src/c/objects/BamgOpts.h
r2938 r2941 17 17 int Metrictype; 18 18 int nbjacobi; 19 int AbsError;20 19 double omega; 21 20 double hmin; … … 25 24 int splitcorners; 26 25 int verbose; 27 double err; 28 double errg; 26 double* err; 29 27 double coef; 30 28 double* metric; -
issm/trunk/src/m/classes/public/bamg.m
r2940 r2941 76 76 77 77 % Bamg Options {{{1 78 bamg_options.iso=getfieldvalue(options,'iso',0);79 78 bamg_options.err=getfieldvalue(options,'err',0.01); 80 bamg_options.errg=getfieldvalue(options,'errg',0.1);81 79 bamg_options.coef=getfieldvalue(options,'coef',1); 82 80 bamg_options.power=getfieldvalue(options,'power',1); 83 81 bamg_options.nbjacobi=getfieldvalue(options,'nbjacobi',1); 84 bamg_options.AbsError=getfieldvalue(options,'AbsError',0);85 82 bamg_options.Hessiantype=getfieldvalue(options,'Hessiantype',0); 86 83 bamg_options.Metrictype=getfieldvalue(options,'Metrictype',0); … … 100 97 %}}} 101 98 99 %check bamg options 100 fieldsize=size(bamg_options.field); 101 if fieldsize(1), 102 if fieldsize(1)~=md.numberofgrids, 103 error(['bamg error message, ''field'' should have ' num2str(md.numberofgrids) ' lines (numberofgrids)']); 104 end 105 if (fieldsize(2)~=0 & length(bamg_options.err)~=fieldsize(2)), 106 error(['bamg error message, ''err'' should be of length ' num2str(fieldsize(2)) ' (As many as fields)']); 107 end 108 end 109 110 102 111 %call Bamg 103 112 [triangles vertices metric]=Bamg(bamg_mesh,bamg_geometry,bamg_options); -
issm/trunk/src/mex/Bamg/Bamg.cpp
r2940 r2941 32 32 33 33 /*Options inputs*/ 34 int iso,maxnbv,verbose,splitcorners;34 int maxnbv,verbose,splitcorners; 35 35 double hmin,hmax,anisomax; 36 double err,errg,coef;36 double coef; 37 37 double power; 38 38 int Hessiantype,Metrictype,NbSmooth; 39 int nbjacobi ,AbsError;39 int nbjacobi; 40 40 double omega; 41 41 double gradation; … … 43 43 double* metric=NULL; 44 44 double* field=NULL; 45 int numfields=0; 45 double* err; 46 int numfields=0,numerr=0; 46 47 47 48 /*Boot module: */ … … 108 109 109 110 /*create bamg options input*/ 110 FetchData(&iso,mxGetField(BAMGOPTIONS,0,"iso"));111 bamgopts.iso=iso;112 FetchData(&err,mxGetField(BAMGOPTIONS,0,"err"));113 bamgopts.err=err;114 FetchData(&errg,mxGetField(BAMGOPTIONS,0,"errg"));115 bamgopts.errg=errg;116 111 FetchData(&coef,mxGetField(BAMGOPTIONS,0,"coef")); 117 112 bamgopts.coef=coef; … … 124 119 FetchData(&nbjacobi,mxGetField(BAMGOPTIONS,0,"nbjacobi")); 125 120 bamgopts.nbjacobi=nbjacobi; 126 FetchData(&AbsError,mxGetField(BAMGOPTIONS,0,"AbsError"));127 bamgopts.AbsError=AbsError;128 121 FetchData(&NbSmooth,mxGetField(BAMGOPTIONS,0,"NbSmooth")); 129 122 bamgopts.NbSmooth=NbSmooth; … … 153 146 bamgopts.numfields=numfields; 154 147 bamgopts.field=field; 148 FetchData(&err,NULL,&numerr,mxGetField(BAMGOPTIONS,0,"err")); 149 bamgopts.err=err; 150 151 /*Some checks*/ 152 if (numfields!=0 && numerr!=numfields){ 153 throw ErrorException(__FUNCT__,exprintf("the size of 'err' should be the same as 'field'")); 154 } 155 155 156 156 /*!Generate internal degree of freedom numbers: */
Note:
See TracChangeset
for help on using the changeset viewer.