Changeset 2789
- Timestamp:
- 01/08/10 16:33:12 (15 years ago)
- Location:
- issm/trunk/src
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk/src/c/Bamgx/Bamgx.cpp
r2787 r2789 53 53 int fileout=0; 54 54 int AbsError=0,nbjacoby=1,allquad=0; 55 int NoMeshReconstruction=0;56 55 int Rescaling = 1; 57 56 double costheta=2; … … 91 90 92 91 // some verification 93 NoMeshReconstruction= fmeshr !=0;94 if (!fmeshback) fmeshback=fmeshr;95 92 if ( maxsubdiv > boundmaxsubdiv || maxsubdiv <= 1.0) 96 93 { … … 113 110 if(bamgmesh->NumTriangles==0){ 114 111 /*Mesh generation {{{1*/ 112 115 113 if (verbosity>0) printf("Construction of a mesh from a given geometry\n"); 116 114 if (verbosity>1) printf(" Processing geometry...\n"); … … 167 165 else{ 168 166 /*Anisotropic mesh adaptation {{{1*/ 167 168 // read background mesh 169 169 if (verbosity>0) printf("Anisotropic mesh adaptation\n"); 170 171 /*Read background mesh from simple delaunay triangulation: */ 172 if (verbosity>1) printf(" Processing initial mesh...\n"); 173 Triangles BTh(bamgmesh,bamgargs); // read the background mesh 174 175 throw ErrorException(__FUNCT__,exprintf("TESTTESTTESTTEST")); 176 printf("ok1\n"); 170 if (verbosity>1) printf(" Processing initial mesh and geometry...\n"); 171 Triangles BTh(bamgmesh,bamgargs); 177 172 hmin = Max(hmin,BTh.MinimalHmin()); 178 printf("ok2\n");179 173 hmax = Min(hmax,BTh.MaximalHmax()); 180 174 175 //?????TEST 181 176 BTh.MakeQuadTree(); 182 if (fmetrix){ 183 BTh.ReadMetric(fmetrix,hmin,hmax,coef); 177 178 //build metric if not given in input 179 if (verbosity>1) printf(" Processing Metric...\n"); 180 if (bamgargs->metric){ 181 BTh.ReadMetric(bamgargs,hmin,hmax,coef); 184 182 } 185 183 else { // init with hmax … … 188 186 BTh[iv].m = Mhmax; 189 187 } 190 if (fMbb) {191 solMbb = ReadbbFile(fMbb,nbsolbb,lsolbb,2,2);192 if (lsolbb != BTh.nbv)193 {194 cerr << "fatal error nbsol " << nbsolbb << " " << lsolbb<< " =! " << BTh.nbv << endl;195 cerr << " size of sol incorrect " << endl;196 MeshError(99);197 }198 assert(lsolbb==BTh.nbv);199 BTh.IntersectConsMetric(solMbb,nbsolbb,0,hmin,hmax,sqrt(err)*coef,1e30,AbsError?0.0:cutoff,200 nbjacoby,Rescaling,power,ChoiseHessien);201 if(!rbbeqMbb)202 delete [] solMbb,solMbb =0;203 204 }205 if (fMBB) {206 solMBB = ReadBBFile(fMBB,nbsolBB,lsolBB,typesolsBB,2,2);207 if (lsolBB != BTh.nbv)208 {209 cerr << "fatal error nbsol " << nbsolBB << " " << lsolBB << " =! " << BTh.nbv << endl;210 cerr << " size of sol incorrect " << endl;211 MeshError(99);212 }213 assert(lsolBB==BTh.nbv);214 BTh.IntersectConsMetric(solMBB,nbsolBB,0,hmin,hmax,sqrt(err)*coef,1e30,AbsError?0.0:cutoff,215 nbjacoby,Rescaling,ChoiseHessien);216 if(!rBBeqMBB)217 delete [] solMBB,solMBB =0;218 219 }220 188 221 189 BTh.IntersectGeomMetric(errg,iso); 222 223 190 if(gradation) BTh.SmoothMetric(gradation); 224 191 BTh.MaxSubDivision(maxsubdiv); 225 192 BTh.BoundAnisotropy(anisomax,hminaniso); 226 193 227 if(foM) { 228 if(verbosity >2) 229 cout << " -- write Metric file " << foM <<endl; 230 231 ofstream f(foM); 232 if(f) BTh.WriteMetric(f,iso); 233 } 234 235 if ( fileout) { 236 if ( NoMeshReconstruction) 237 if (( fmeshback == fmeshr) || (!strcmp(fmeshback,fmeshr))) 238 Thr=&BTh,Thb=0; // back and r mesh are the same 239 else 240 Thr= new Triangles(fmeshr,cutoffradian),Thb=&BTh; // read the new 241 242 243 244 Triangles & Th( *(NoMeshReconstruction 245 ? new Triangles(*Thr,&Thr->Gh,Thb,maxnbv) // copy the mesh + free space to modification 246 : new Triangles(maxnbv,BTh,KeepBackVertices) // construct a new mesh 247 )); 248 if (Thr != &BTh) delete Thr; 249 250 if(costheta<=1.0) 251 Th.MakeQuadrangles(costheta); 252 if (allquad) 253 Th.SplitElement(allquad==2); 254 if(splitcorners) 255 Th.SplitInternalEdgeWithBorderVertices(); 256 Th.ReNumberingTheTriangleBySubDomain(); 257 258 if(verbosity>3) Th.ShowHistogram(); 259 if(NbSmooth>0) Th.SmoothingVertex(NbSmooth,omega); 260 if(verbosity>3 && NbSmooth>0) Th.ShowHistogram(); 261 262 Th.BTh.ReMakeTriangleContainingTheVertex(); 263 264 if (fmeshout) Th.Write(fmeshout ,Triangles::BDMesh); 265 if (famfmt) Th.Write(famfmt ,Triangles::am_fmtMesh); 266 if (fam) Th.Write(fam ,Triangles::amMesh); 267 if (famdba) Th.Write(famdba ,Triangles::amdbaMesh); 268 if (fftq) Th.Write(fftq ,Triangles::ftqMesh); 269 if (fmsh) Th.Write(fmsh ,Triangles::mshMesh); 270 if (fnopo) Th.Write(fnopo ,Triangles::NOPOMesh); 271 272 if ( ( rbb && wbb) ||( rBB && wBB)){ // the code for interpolation 273 274 if(verbosity >1) 275 { 276 if (rbb ) 277 cout << " -- interpolation P1 files : " << rbb << " -> " << wbb <<endl; 278 if (rBB ) 279 cout << " -- interpolation P1 files : " << rBB<< " -> " << wBB <<endl; 280 } 281 const int dim=2; 282 // optimisation read only si rbb != fMbb 283 284 double *solbb=0; 285 double *solBB=0; 286 287 if (rbb) 288 solbb = rbbeqMbb? solMbb : ReadbbFile(rbb,nbsolbb,lsolbb,2,2); 289 if (rBB) 290 solBB = rBBeqMBB? solMBB : ReadBBFile(rBB,nbsolBB,lsolBB,typesolsBB,2,2); 291 292 // cout << " " << rbbeqMbb << " " << sol << " " << nbsol << " " << lsol << endl; 293 if (!solBB && !solbb ) 294 { 295 cerr << " Fatal Error " << "solBB = " << solBB << " solbb= " << solbb << endl; 296 exit(2);} 297 298 ofstream *fbb = wbb ? new ofstream(wbb) :0; 299 ofstream *fBB = wBB ? new ofstream(wBB) :0; 300 Int4 nbfieldBB = 0, nbfieldbb = nbsolbb; 301 if (fbb) 302 *fbb << dim << " " << nbsolbb << " " << Th.nbv <<" " << 2 << endl; 303 if (fBB) 304 { 305 int i; 306 *fBB << dim << " " << nbsolBB ; 307 for ( i=0;i<nbsolBB;i++) 308 *fBB << " " << (typesolsBB ?typesolsBB[i]+1:1) ; 309 *fBB << " " << Th.nbv <<" " << 2 << endl; 310 assert(dim==2); 311 for ( i=0;i<nbsolBB;i++) 312 nbfieldBB += typesolsBB ? typesolsBB[i]+1 : 1; 313 // this code is good only if dim == 2 314 } 315 cout << "nb of field BB " << nbfieldBB << endl; 316 // if(fBB) fBB->precision(15); 317 //if(fbb) fbb->precision(15); 318 for(i=0;i<Th.nbv;i++) 319 { 320 Int4 i0,i1,i2; 321 double a[3]; 322 Icoor2 dete[3]; 323 I2 I = Th.BTh.toI2(Th.vertices[i].r); 324 Triangle & tb = *Th.BTh.FindTriangleContening(I,dete); 325 326 if (tb.det>0) { // internal point 327 a[0]= (Real8) dete[0]/ tb.det; 328 a[1]= (Real8) dete[1] / tb.det; 329 a[2] = (Real8) dete[2] / tb.det; 330 i0=Th.BTh.Number(tb[0]); 331 i1=Th.BTh.Number(tb[1]); 332 i2=Th.BTh.Number(tb[2]);} 333 else { 334 double aa,bb; 335 336 TriangleAdjacent ta=CloseBoundaryEdge(I,&tb,aa,bb).Adj(); 337 338 int k = ta; 339 Triangle & tc = *(Triangle *)ta; 340 i0=Th.BTh.Number(tc[0]); 341 i1=Th.BTh.Number(tc[1]); 342 i2=Th.BTh.Number(tc[2]); 343 a[VerticesOfTriangularEdge[k][1]] =aa; 344 a[VerticesOfTriangularEdge[k][0]] = bb; 345 a[OppositeVertex[k]] = 1- aa -bb;} 346 347 Int4 ibb0 = nbfieldbb*i0; 348 Int4 ibb1 = nbfieldbb*i1; 349 Int4 ibb2 = nbfieldbb*i2; 350 351 Int4 iBB0 = nbfieldBB*i0; 352 Int4 iBB1 = nbfieldBB*i1; 353 Int4 iBB2 = nbfieldBB*i2; 354 Int4 j=0; 355 356 for ( j=0;j<nbfieldbb;j++) 357 *fbb << " " << ( a[0] * solbb[ibb0++] + a[1] * solbb[ibb1++] + a[2]* solbb[ibb2++]) ; 358 359 for (j=0;j<nbfieldBB;j++) 360 *fBB << " " << ( a[0] * solBB[iBB0++] + a[1] * solBB[iBB1++] + a[2]* solBB[iBB2++]) ; 361 362 if (fbb) *fbb << endl; 363 if (fBB) *fBB << endl; 364 } 365 if (fbb) 366 delete fbb ; // close 367 if (fBB) 368 delete fBB ; // close 369 if (solbb) 370 delete [] solbb; 371 if (solBB) 372 delete [] solBB; 373 374 } 375 376 if(verbosity>0) 377 { 378 if (Th.nbt-Th.NbOutT-Th.NbOfQuad*2) 379 cout << " Nb Triangles = " << (Th.nbt-Th.NbOutT-Th.NbOfQuad*2); 380 if (Th.NbOfQuad ) 381 cout << " Nb Quadrilaterals = " << Th.NbOfQuad ; 382 cout << endl; 383 } 384 385 //Build output 386 NumVerticesOut=Th.nbv; 387 VerticesOut=(double*)xmalloc(3*NumVerticesOut*sizeof(double)); 388 for (i=0;i<NumVerticesOut;i++){ 389 VerticesOut[i*3+0]=Th.vertices[i].r.x; 390 VerticesOut[i*3+1]=Th.vertices[i].r.y; 391 VerticesOut[i*3+2]=Th.vertices[i].ReferenceNumber; 392 } 393 394 NumTrianglesOut=Th.nbt-Th.NbOutT; //number of triangles - number of external triangles 395 TrianglesOut=(double*)xmalloc(4*NumTrianglesOut*sizeof(double)); 396 num=0; 397 for(i=0;i<Th.nbt;i++){ 398 Triangle &t=Th.triangles[i]; 399 if (t.link){ 400 //write the element only if it is part of the mesh (no boundary element) 401 TrianglesOut[4*num+0]=Th.Number(t[0])+1; 402 TrianglesOut[4*num+1]=Th.Number(t[1])+1; 403 TrianglesOut[4*num+2]=Th.Number(t[2])+1; 404 TrianglesOut[4*num+3]=t.color; 405 num=num+1; 406 } 407 } 408 409 /*clean up*/ 410 delete &Th; 411 } 194 //Build new mesh Thr 195 Thr=&BTh,Thb=0; 196 Triangles & Th( *(0 ? new Triangles(*Thr,&Thr->Gh,Thb,maxnbv) : new Triangles(maxnbv,BTh,KeepBackVertices))); 197 if (Thr != &BTh) delete Thr; 198 199 if(costheta<=1.0){ 200 Th.MakeQuadrangles(costheta); 201 } 202 if (allquad){ 203 Th.SplitElement(allquad==2); 204 } 205 if(splitcorners){ 206 Th.SplitInternalEdgeWithBorderVertices(); 207 } 208 Th.ReNumberingTheTriangleBySubDomain(); 209 210 if(NbSmooth>0) Th.SmoothingVertex(NbSmooth,omega); 211 212 Th.BTh.ReMakeTriangleContainingTheVertex(); 213 214 //info 215 if(verbosity>0) { 216 if (Th.nbt-Th.NbOutT-Th.NbOfQuad*2){ 217 printf(" new number of triangles = %i\n",(Th.nbt-Th.NbOutT-Th.NbOfQuad*2)); 218 } 219 if (Th.NbOfQuad ){ 220 printf(" new number of quads = %i\n",Th.NbOfQuad); 221 } 222 } 223 224 //Build output 225 NumVerticesOut=Th.nbv; 226 VerticesOut=(double*)xmalloc(3*NumVerticesOut*sizeof(double)); 227 for (i=0;i<NumVerticesOut;i++){ 228 VerticesOut[i*3+0]=Th.vertices[i].r.x; 229 VerticesOut[i*3+1]=Th.vertices[i].r.y; 230 VerticesOut[i*3+2]=Th.vertices[i].ReferenceNumber; 231 } 232 233 NumTrianglesOut=Th.nbt-Th.NbOutT; //number of triangles - number of external triangles 234 TrianglesOut=(double*)xmalloc(4*NumTrianglesOut*sizeof(double)); 235 num=0; 236 for(i=0;i<Th.nbt;i++){ 237 Triangle &t=Th.triangles[i]; 238 if (t.link){ 239 //write the element only if it is part of the mesh (no boundary element) 240 TrianglesOut[4*num+0]=Th.Number(t[0])+1; 241 TrianglesOut[4*num+1]=Th.Number(t[1])+1; 242 TrianglesOut[4*num+2]=Th.Number(t[2])+1; 243 TrianglesOut[4*num+3]=t.color; 244 num=num+1; 245 } 246 } 247 248 /*clean up*/ 249 //delete &Th; 412 250 /*}}}*/ 413 251 } -
issm/trunk/src/c/Bamgx/Mesh2.cpp
r2787 r2789 2629 2629 void Triangles::FindSubDomain(int OutSide=0) 2630 2630 { 2631 long int verbosity=2 ;2631 long int verbosity=20; 2632 2632 //#define DRAWING1 2633 2633 … … 4032 4032 } 4033 4033 4034 Triangles::~Triangles() 4035 { 4034 Triangles::~Triangles() { 4036 4035 long int verbosity=2; 4037 assert(NbRef<=0);4036 //assert(NbRef<=0); 4038 4037 if (CurrentTh == this) CurrentTh=0; 4039 if(verbosity>10) 4040 cout << " ~Triangles "<< this <<" "<< identity << endl; 4041 if(vertices) delete [] vertices; 4038 //if(vertices) delete [] vertices; //TEST crash if not commented 4042 4039 if(edges) delete [] edges; 4043 4040 if(triangles) delete [] triangles; 4044 4041 if(quadtree) delete quadtree; 4045 if(ordre) delete [] ordre;4042 //if(ordre) delete [] ordre; //TEST crash if not commented 4046 4043 if( subdomains) delete [] subdomains; 4047 4044 if (VerticesOnGeomEdge) delete [] VerticesOnGeomEdge; 4048 4045 if (VerticesOnGeomVertex) delete [] VerticesOnGeomVertex; 4049 if (name) delete [] name;4046 //if (name) delete [] name; //TEST crash if not commented 4050 4047 if (identity) delete [] identity; 4051 4048 if (VertexOnBThVertex) delete [] VertexOnBThVertex; 4052 4049 if (VertexOnBThEdge) delete [] VertexOnBThEdge; 4053 4050 4054 if (&Gh) 4055 { 4051 if (&Gh) { 4056 4052 if (Gh.NbRef>0) Gh.NbRef--; 4057 4053 else if (Gh.NbRef==0) delete &Gh; 4058 4054 } 4059 if (&BTh && (&BTh != this)) 4060 { 4055 if (&BTh && (&BTh != this)) { 4061 4056 if (BTh.NbRef>0) BTh.NbRef--; 4062 4057 else if (BTh.NbRef==0) delete &BTh; 4063 4058 } 4064 4059 PreInit(0); // set all to zero 4065 4066 4060 } 4067 4061 … … 4628 4622 void Triangles::MakeQuadTree() 4629 4623 { 4630 long int verbosity= 2;4624 long int verbosity=9; 4631 4625 if(verbosity>8) 4632 4626 cout << " MakeQuadTree" << endl; -
issm/trunk/src/c/Bamgx/Mesh2.h
r2781 r2789 906 906 void Read_msh(MeshIstream &); 907 907 908 void ReadMetric( const char * fmetrix,const Real8 hmin,const Real8 hmax,const Real8 coef);908 void ReadMetric(BamgArgs* bamgargs,const Real8 hmin,const Real8 hmax,const Real8 coef); 909 909 void IntersectConsMetric(const double * s,const Int4 nbsol,const int * typsols, 910 910 const Real8 hmin,const Real8 hmax, const Real8 coef, -
issm/trunk/src/c/Bamgx/MeshRead.cpp
r2787 r2789 1149 1149 SetIntCoor(); 1150 1150 FillHoleInMesh(); 1151 printf("ok0\n");1152 1151 } 1153 1152 -
issm/trunk/src/c/Bamgx/Metric.cpp
r2772 r2789 301 301 void Triangles::BoundAnisotropy(Real8 anisomax,Real8 hminaniso) 302 302 { 303 long int verbosity= 0;303 long int verbosity=10; 304 304 305 305 double lminaniso = 1/ (Max(hminaniso*hminaniso,1e-100)); … … 805 805 806 806 807 void Triangles::ReadMetric( const char * fmetrix,const Real8 hmin1=1.0e-30,const Real8 hmax1=1.0e30,const Real8 coef=1)807 void Triangles::ReadMetric(BamgArgs* bamgargs,const Real8 hmin1=1.0e-30,const Real8 hmax1=1.0e30,const Real8 coef=1) 808 808 { 809 long int verbosity=0; 810 811 Real8 hmin = Max(hmin1,MinimalHmin()); 812 Real8 hmax = Min(hmax1,MaximalHmax()); 813 MeshIstream f_metrix(fmetrix); 814 Int4 k,j; 815 f_metrix >> k >> j ; 816 if(verbosity>1) 817 cout << " metrix: open " << fmetrix 818 << ", le coef = " << coef 819 << ", hmin = " << hmin 820 << ", hmax = " << hmax 821 << ( (j == 1)? " Iso " : " AnIso " )<< endl; 822 823 if (k != nbv || !(j == 1 || j == 3)) 824 { 825 cerr << " Error Pb metrix " << k << " <> " 826 << nbv << " or 1 or 3 <> " << j << endl; 827 MeshError(1002); 828 } 829 830 cout << " j = " << j << endl; 831 // Int4 nberr = 0; 832 for (Int4 iv=0;iv<nbv;iv++) 833 { 834 Real8 h; 835 if (j == 1) 836 { 837 f_metrix >> h ; 838 vertices[iv].m=Metric(Max(hmin,Min(hmax, h*coef))); 809 int i,j; 810 811 if(bamgargs->verbose>3) printf(" processing metric\n"); 812 813 Real8 hmin = Max(hmin1,MinimalHmin()); 814 Real8 hmax = Min(hmax1,MaximalHmax()); 815 816 //for now we only use j==3 817 j=3; 818 819 for (i=0;i<nbv;i++){ 820 Real8 h; 821 if (j == 1){ 822 h=bamgargs->metric[i]; 823 vertices[i].m=Metric(Max(hmin,Min(hmax, h*coef))); 824 } 825 else if (j==3){ 826 Real8 a,b,c; 827 a=bamgargs->metric[i*3+0]; 828 b=bamgargs->metric[i*3+1]; 829 c=bamgargs->metric[i*3+2]; 830 MetricAnIso M(a,b,c); 831 MatVVP2x2 Vp(M/coef); 832 833 Vp.Maxh(hmin); 834 Vp.Minh(hmax); 835 vertices[i].m = Vp; 836 } 839 837 } 840 else if (j==3)841 {842 Real8 a,b,c;843 f_metrix >> a >> b >> c ;844 MetricAnIso M(a,b,c);845 MatVVP2x2 Vp(M/coef);846 847 Vp.Maxh(hmin);848 Vp.Minh(hmax);849 vertices[iv].m = Vp;850 851 }852 }853 854 838 } 855 839 … … 876 860 void Triangles::MaxSubDivision(Real8 maxsubdiv) 877 861 { 878 long int verbosity= 0;862 long int verbosity=10; 879 863 880 864 const Real8 maxsubdiv2 = maxsubdiv*maxsubdiv; … … 958 942 void Triangles::SmoothMetric(Real8 raisonmax) 959 943 { 960 long int verbosity= 0;944 long int verbosity=10; 961 945 962 946 if(raisonmax<1.1) return; -
issm/trunk/src/m/classes/public/bamg.m
r2785 r2789 60 60 bamg_mesh.Vertices=[md.x md.y ones(md.numberofgrids,1)]; 61 61 bamg_mesh.NumTriangles=md.numberofelements; 62 bamg_mesh.Triangles=[md.elements ones(md.numberof grids,1)];62 bamg_mesh.Triangles=[md.elements ones(md.numberofelements,1)]; 63 63 end 64 64 %}}} … … 69 69 bamg_options.hmin=getfieldvalue(options,'hmin',10^-100); 70 70 bamg_options.hmax=getfieldvalue(options,'hmax',10^100); 71 bamg_options.gradation=getfieldvalue(options,'gradation',1. 2);71 bamg_options.gradation=getfieldvalue(options,'gradation',1.5); 72 72 bamg_options.cutoff=getfieldvalue(options,'cutoff',10^-5); 73 73 bamg_options.verbose=getfieldvalue(options,'verbose',1); -
issm/trunk/src/mex/Bamg/Bamg.cpp
r2785 r2789 75 75 FetchData(&VerticesMesh,NULL,NULL,mxGetField(BAMGMESH,0,"Vertices")); 76 76 bamgmesh.Vertices=VerticesMesh; 77 FetchData(&NumTrianglesMesh,mxGetField(BAMGMESH,0,"Num Vertices"));77 FetchData(&NumTrianglesMesh,mxGetField(BAMGMESH,0,"NumTriangles")); 78 78 bamgmesh.NumTriangles=NumTrianglesMesh; 79 FetchData(&TrianglesMesh,NULL,NULL,mxGetField(BAMGMESH,0," Vertices"));79 FetchData(&TrianglesMesh,NULL,NULL,mxGetField(BAMGMESH,0,"Triangles")); 80 80 bamgmesh.Triangles=TrianglesMesh; 81 81 bamgmesh.hVertices=NULL; … … 123 123 xfree((void**)&hVerticesGeom); 124 124 xfree((void**)&SubDomainGeom); 125 xfree((void**)&TrianglesMesh);126 xfree((void**)&VerticesMesh);125 //xfree((void**)&TrianglesMesh); 126 //xfree((void**)&VerticesMesh); 127 127 128 128 /*end module: */
Note:
See TracChangeset
for help on using the changeset viewer.