Changeset 3148
- Timestamp:
- 03/02/10 10:14:45 (15 years ago)
- Location:
- issm/trunk/src/c/Bamgx
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk/src/c/Bamgx/Bamgx.cpp
r3126 r3148 95 95 if(bamgopts->splitcorners) Th.SplitInternalEdgeWithBorderVertices(); 96 96 Th.ReNumberingTheTriangleBySubDomain(); 97 //if(NbSmooth>0) Th.SmoothingVertex(NbSmooth,omega);98 Th.SmoothingVertex(3,omega);99 97 100 98 //Build output … … 159 157 if (verbosity>1) printf(" Generating Mesh...\n"); 160 158 Thr=&BTh,Thb=0; 161 Triangles & Th( *(0 ? new Triangles(*Thr,&Thr->Gh,Thb,maxnbv) : new Triangles(maxnbv,BTh,bamgopts ->KeepVertices)));159 Triangles & Th( *(0 ? new Triangles(*Thr,&Thr->Gh,Thb,maxnbv) : new Triangles(maxnbv,BTh,bamgopts,bamgopts->KeepVertices))); 162 160 if (Thr != &BTh) delete Thr; 163 161 if(costheta<=1.0) Th.MakeQuadrangles(costheta); -
issm/trunk/src/c/Bamgx/Mesh2.h
r3126 r3148 367 367 class IntersectionTriangles { 368 368 public: 369 Triangle *t;369 Triangle* t; 370 370 Real8 bary[3]; // use if t != 0 371 371 R2 x; 372 372 Metric m; 373 Real8 s; // abscisse curviline374 Real8 sp; // len of the previous segin m375 Real8 sn;// len of the next segin m373 Real8 s; // curvilinear coordinate 374 Real8 sp;// length of the previous segment in m 375 Real8 sn;// length of the next segment in m 376 376 }; 377 377 … … 380 380 GeometricalEdge * e; 381 381 Real8 sBegin,sEnd; // abscisse of the seg on edge parameter 382 Real8 lBegin,lEnd; // length abscisse 382 Real8 lBegin,lEnd; // length abscisse set in ListofIntersectionTriangles::Length 383 383 int last;// last index in ListofIntersectionTriangles for this Sub seg of edge 384 384 R2 F(Real8 s){ … … 390 390 }; 391 391 392 int MaxSize; //393 int Size; //394 Real8 len; //392 int MaxSize; 393 int Size; 394 Real8 len; 395 395 int state; 396 396 IntersectionTriangles * lIntTria; … … 403 403 404 404 ListofIntersectionTriangles(int n=256,int m=16) 405 : MaxSize(n), Size(0), len(-1),state(-1),lIntTria(new IntersectionTriangles[n]) , 406 NbSeg(0), MaxNbSeg(m), lSegsI(new SegInterpolation[m]) 407 { 408 long int verbosity=0; 409 if (verbosity>9) printf(" construct ListofIntersectionTriangles %i %i\n",MaxSize,MaxNbSeg); 405 : MaxSize(n), Size(0), len(-1),state(-1),lIntTria(new IntersectionTriangles[n]) , 406 NbSeg(0), MaxNbSeg(m), lSegsI(new SegInterpolation[m]){ 407 long int verbosity=0; 408 if (verbosity>9) printf(" construct ListofIntersectionTriangles %i %i\n",MaxSize,MaxNbSeg); 410 409 }; 411 410 … … 417 416 int NewItem(Triangle * tt,Real8 d0,Real8 d1,Real8 d2); 418 417 int NewItem(R2,const Metric & ); 419 void NewSubSeg(GeometricalEdge *e,Real8 s0,Real8 s1) 420 { 418 void NewSubSeg(GeometricalEdge *e,Real8 s0,Real8 s1){ 421 419 long int verbosity=0; 422 420 … … 436 434 lSegsI = lEn; 437 435 } 438 if (NbSeg) 439 lSegsI[NbSeg-1].last=Size; 436 if (NbSeg) lSegsI[NbSeg-1].last=Size; 440 437 lSegsI[NbSeg].e=e; 441 438 lSegsI[NbSeg].sBegin=s0; … … 443 440 NbSeg++; 444 441 } 445 446 // void CopyMetric(int i,int j){ lIntTria[j].m=lIntTria[i].m;}447 // void CopyMetric(const Metric & mm,int j){ lIntTria[j].m=mm;}448 442 449 443 void ReShape() { … … 453 447 throw ErrorException(__FUNCT__,exprintf("!nw")); 454 448 } 455 for (int i=0;i<MaxSize;i++)// recopy456 nw[i] = lIntTria[i];449 // recopy 450 for (int i=0;i<MaxSize;i++) nw[i] = lIntTria[i]; 457 451 long int verbosity=0; 458 452 if(verbosity>3) printf(" ListofIntersectionTriangles ReShape Maxsize %i -> %i\n",MaxSize,MaxNbSeg); … … 597 591 public: 598 592 599 int static counter; // to kown the number of mesh in memory600 593 Geometry & Gh; // Geometry 601 594 Triangles & BTh; // Background Mesh Bth==*this =>no background … … 650 643 Triangles(double* index,double* x,double* y,int nods,int nels); 651 644 652 Triangles(Int4 nbvx,Triangles & BT, int keepBackVertices=1) :Gh(BT.Gh),BTh(BT) {653 try {GeomToTriangles1(nbvx, keepBackVertices);}645 Triangles(Int4 nbvx,Triangles & BT,BamgOpts* bamgopts,int keepBackVertices=1) :Gh(BT.Gh),BTh(BT) { 646 try {GeomToTriangles1(nbvx,bamgopts,keepBackVertices);} 654 647 catch(...) { this->~Triangles(); throw; } 655 648 } … … 700 693 int SplitElement(int choice); 701 694 void MakeQuadTree(); 702 void NewPoints( Triangles &,int KeepVertices =1);695 void NewPoints(Triangles &,BamgOpts* bamgopts,int KeepVertices=1); 703 696 Int4 InsertNewPoints(Int4 nbvold,Int4 & NbTSwap) ; 704 void NewPoints(int KeepVertices=1){ NewPoints(*this,KeepVertices);}705 697 void ReNumberingTheTriangleBySubDomain(bool justcompress=false); 706 698 void ReNumberingVertex(Int4 * renu); … … 744 736 int CrackMesh(); 745 737 private: 746 void GeomToTriangles1(Int4 nbvx, int KeepVertices=1);// the real constructor mesh adaption738 void GeomToTriangles1(Int4 nbvx,BamgOpts* bamgopts,int KeepVertices=1);// the real constructor mesh adaption 747 739 void GeomToTriangles0(Int4 nbvx,BamgOpts* bamgopts);// the real constructor mesh generator 748 740 void PreInit(Int4); -
issm/trunk/src/c/Bamgx/objects/ListofIntersectionTriangles.cpp
r2965 r3148 263 263 /*FUNCTION ListofIntersectionTriangles::Length{{{1*/ 264 264 Real8 ListofIntersectionTriangles::Length(){ 265 // computation of the length 266 267 // check Size 265 268 if (Size<=0){ 266 269 throw ErrorException(__FUNCT__,exprintf("Size<=0")); 267 270 } 268 // computation of the length 269 R2 C; 271 270 272 Metric Mx,My; 271 273 int ii,jj; 272 274 R2 x,y,xy; 273 275 274 SegInterpolation *SegI=lSegsI;276 SegInterpolation* SegI=lSegsI; 275 277 SegI=lSegsI; 276 lSegsI[NbSeg].last=Size;// improvement 277 278 lSegsI[NbSeg].last=Size; 278 279 int EndSeg=Size; 279 280 … … 285 286 for (jj=0,ii=1;ii<Size;jj=ii++) { 286 287 // seg jj,ii 287 x =y;288 y = lIntTria[ii].x;288 x = y; 289 y = lIntTria[ii].x; 289 290 xy = y-x; 290 291 Mx = lIntTria[ii].m; 291 292 My = lIntTria[jj].m; 292 sxy =LengthInterpole(Mx,My,xy);293 sxy= LengthInterpole(Mx,My,xy); 293 294 s += sxy; 294 295 lIntTria[ii].s = s; 295 if (ii == EndSeg) 296 SegI->lEnd=s,297 SegI++ ,298 EndSeg=SegI->last ,296 if (ii == EndSeg){ 297 SegI->lEnd=s; 298 SegI++; 299 EndSeg=SegI->last; 299 300 SegI->lBegin=s; 300 301 301 } 302 } 302 303 len = s; 303 304 SegI->lEnd=s; … … 307 308 /*}}}1*/ 308 309 /*FUNCTION ListofIntersectionTriangles::NewPoints{{{1*/ 309 Int4 ListofIntersectionTriangles::NewPoints(Vertex * vertices,Int4 & nbv,Int4 nbvx){ 310 long int verbosity=0; 311 312 313 const Int4 nbvold = nbv; 314 Real8 s = Length(); 315 if (s < 1.5 ) return 0; 316 ////////////////////// 310 Int4 ListofIntersectionTriangles::NewPoints(Vertex* vertices,Int4 &nbv,Int4 nbvx){ 311 312 //If length<1.5, do nothing 313 Real8 s=Length(); 314 if (s<1.5) return 0; 315 316 const Int4 nbvold=nbv; 317 317 int ii = 1 ; 318 318 R2 y,x; 319 319 Metric My,Mx ; 320 320 Real8 sx =0,sy; 321 int nbi =Max(2,(int) (s+0.5));322 Real8 sint =s/nbi;323 Real8 si =sint;321 int nbi=Max(2,(int) (s+0.5)); 322 Real8 sint=s/nbi; 323 Real8 si =sint; 324 324 325 325 int EndSeg=Size; 326 SegInterpolation *SegI=0; 327 if (NbSeg) 328 SegI=lSegsI,EndSeg=SegI->last; 329 330 for (int k=1;k<nbi;k++) 331 { 332 while ((ii < Size) && ( lIntTria[ii].s <= si )) 333 if (ii++ == EndSeg) 334 SegI++,EndSeg=SegI->last; 326 SegInterpolation* SegI=NULL; 327 if (NbSeg) SegI=lSegsI,EndSeg=SegI->last; 328 329 for (int k=1;k<nbi;k++){ 330 while ((ii < Size) && ( lIntTria[ii].s <= si )){ 331 if (ii++ == EndSeg){ 332 SegI++; 333 EndSeg=SegI->last; 334 } 335 } 335 336 336 337 int ii1=ii-1; … … 347 348 Real8 cx = 1-cy; 348 349 C = SegI ? SegI->F(si): x * cx + y *cy; 350 //C.Echo(); 351 //x.Echo(); 352 //y.Echo(); 353 //printf("cx = %g, cy=%g\n",cx,cy); 349 354 350 355 si += sint; -
issm/trunk/src/c/Bamgx/objects/Triangle.cpp
r2970 r3148 98 98 /*FUNCTION Triangle::Optim{{{1*/ 99 99 Int4 Triangle::Optim(Int2 i,int koption) { 100 // turne around in positif sens 100 // turn around (positive direction) 101 Triangle *t=this; 101 102 Int4 NbSwap =0; 102 Triangle *t = this; 103 int k=0,j =OppositeEdge[i]; 104 int jp = PreviousEdge[j]; 105 // initialise tp, jp the previous triangle & edge 106 Triangle *tp= TriaAdjTriangles[jp]; 103 int k = 0; 104 int j = OppositeEdge[i]; 105 int jp= PreviousEdge[j]; 106 107 // initialize tp, jp the previous triangle & edge 108 Triangle *tp=TriaAdjTriangles[jp]; 107 109 jp = TriaAdjSharedEdge[jp]&3; 108 110 do { 109 while (t->swap(j,koption)) 110 {111 while (t->swap(j,koption)){ 112 if (k>=20000) throw ErrorException(__FUNCT__,exprintf("k>=20000")); 111 113 NbSwap++; 112 114 k++; 113 if (k>=20000){114 throw ErrorException(__FUNCT__,exprintf("k>=20000"));115 }116 115 t= tp->TriaAdjTriangles[jp]; // set unchange t qnd j for previous triangles 117 116 j= NextEdge[tp->TriaAdjSharedEdge[jp]&3]; 118 117 } 119 118 // end on this Triangle 120 119 tp = t; … … 187 186 break; 188 187 } 189 else 190 { 188 else { 191 189 // critere de Delaunay anisotrope 192 190 Real8 som; -
issm/trunk/src/c/Bamgx/objects/Triangles.cpp
r3126 r3148 19 19 static const Direction NoDirOfSearch=Direction(); 20 20 long NbUnSwap =0; 21 int Triangles::counter = 0;22 21 23 22 /*Constructors/Destructors*/ … … 3151 3150 if (verbose>4) printf(" -- current number of vertices = %i\n",nbv); 3152 3151 if (verbose>3) printf(" Creating initial Constrained Delaunay Triangulation...\n"); 3153 if (verbose>3) printf(" Inserting points\n");3152 if (verbose>3) printf(" Inserting boundary points\n"); 3154 3153 Insert(); 3155 3154 … … 3164 3163 // NewPointsOld(*this) ; 3165 3164 if (verbose>3) printf(" Inserting internal points\n"); 3166 NewPoints(*this, 0) ;3165 NewPoints(*this,bamgopts,0) ; 3167 3166 if (verbose>4) printf(" -- current number of vertices = %i\n",nbv); 3168 3167 } 3169 3168 /*}}}1*/ 3170 3169 /*FUNCTION Triangles::GeomToTriangles1{{{1*/ 3171 void Triangles::GeomToTriangles1(Int4 inbvx,int KeepVertices) { 3170 void Triangles::GeomToTriangles1(Int4 inbvx,BamgOpts* bamgopts,int KeepVertices){ 3171 3172 /*Get options*/ 3173 int verbosity=bamgopts->verbose; 3174 3172 3175 Gh.NbRef++;// add a ref to Gh 3173 3176 … … 3194 3197 } 3195 3198 3196 long int verbosity=0;3197 3199 BTh.NbRef++; // add a ref to BackGround Mesh 3198 3200 PreInit(inbvx); … … 3501 3503 FindSubDomain(); 3502 3504 3503 NewPoints(BTh, KeepVertices) ;3505 NewPoints(BTh,bamgopts,KeepVertices) ; 3504 3506 } 3505 3507 /*}}}1*/ … … 3973 3975 /*}}}1*/ 3974 3976 /*FUNCTION Triangles::NewPoints{{{1*/ 3975 void Triangles::NewPoints(Triangles & Bh,int KeepVertices) { 3976 3977 long int verbosity=2; 3978 Int4 nbtold(nbt),nbvold(nbv); 3979 Int4 i,k; 3980 int j; 3981 Int4 *first_np_or_next_t = new Int4[nbtx]; 3982 Int4 NbTSwap =0; 3983 3984 //display info 3985 if (verbosity>2) printf(" Triangles::NewPoints\n"); 3986 3987 /*First, insert old points*/ 3988 3989 nbtold = nbt; 3990 3977 void Triangles::NewPoints(Triangles & Bh,BamgOpts* bamgopts,int KeepVertices){ 3978 3979 int i,j,k; 3980 Int4 NbTSwap=0; 3981 Int4 nbtold=nbt; 3982 Int4 nbvold=nbv; 3983 Int4 Headt=0; 3984 Int4 next_t; 3985 Int4* first_np_or_next_t=new Int4[nbtx]; 3986 Triangle* t=NULL; 3987 3988 /*Recover options*/ 3989 int verbosity=bamgopts->verbose; 3990 3991 /*First, insert old points if requested*/ 3991 3992 if (KeepVertices && (&Bh != this) && (nbv+Bh.nbv< nbvx)){ 3992 // Bh.SetVertexFieldOn();3993 if (verbosity>5) printf(" Inserting initial mesh points\n"); 3993 3994 for (i=0;i<Bh.nbv;i++){ 3994 3995 Vertex &bv=Bh[i]; 3995 3996 if (!bv.onGeometry){ 3996 vertices[nbv].r = bv.r;3997 vertices[nbv].r = bv.r; 3997 3998 vertices[nbv++].m = bv.m; 3998 3999 } 3999 4000 } 4000 int nbv1=nbv;4001 4001 Bh.ReMakeTriangleContainingTheVertex(); 4002 4002 InsertNewPoints(nbvold,NbTSwap) ; … … 4004 4004 else Bh.ReMakeTriangleContainingTheVertex(); 4005 4005 4006 Triangle *t;4007 4006 // generation of the list of next Triangle 4008 // at 1 time we test all the triangles 4009 Int4 Headt =0,next_t; 4010 for(i=0;i<nbt;i++) 4011 first_np_or_next_t[i]=-(i+1); 4012 // end list i >= nbt 4013 // the list of test triangle is 4014 // the next traingle on i is -first_np_or_next_t[i] 4007 for(i=0;i<nbt;i++) first_np_or_next_t[i]=-(i+1); 4008 // the next traingle of i is -first_np_or_next_t[i] 4009 4010 // Big loop (most time consuming) 4015 4011 int iter=0; 4016 4017 // Big loop (most time consuming) 4012 if (verbosity>5) printf(" Big loop\n"); 4018 4013 do { 4014 /*Update variables*/ 4019 4015 iter++; 4020 nbtold =nbt;4021 nbvold =nbv;4022 4023 / / default size of IntersectionTriangle4016 nbtold=nbt; 4017 nbvold=nbv; 4018 4019 /*We test all triangles*/ 4024 4020 i=Headt; 4025 4021 next_t=-first_np_or_next_t[i]; 4026 4022 for(t=&triangles[i];i<nbt;t=&triangles[i=next_t],next_t=-first_np_or_next_t[i]){ 4027 // for each triangle t 4028 // we can change first_np_or_next_t[i]4023 4024 //check i 4029 4025 if (i<0 || i>=nbt ){ 4030 throw ErrorException(__FUNCT__,exprintf("i<0 || i>=nbt")); 4031 } 4026 throw ErrorException(__FUNCT__,exprintf("Index problem in NewPoints (i=%i not in [0 %i])",i,nbt-1)); 4027 } 4028 //change first_np_or_next_t[i] 4032 4029 first_np_or_next_t[i] = iter; 4030 4031 //Loop over the edges of t 4033 4032 for(j=0;j<3;j++){ 4034 // for each edge4035 4033 TriangleAdjacent tj(t,j); 4036 Vertex & vA = * tj.EdgeVertex(0); 4037 Vertex & vB = * tj.EdgeVertex(1); 4038 4039 if (!t->link) continue;// boundary 4040 if (t->det <0) continue; 4034 Vertex &vA = *tj.EdgeVertex(0); 4035 Vertex &vB = *tj.EdgeVertex(1); 4036 4037 //if t is a boundary triangle, or tj locked, continue 4038 if (!t->link) continue; 4039 if (t->det <0) continue; 4041 4040 if (t->Locked(j)) continue; 4042 4041 4043 4042 TriangleAdjacent tadjj = t->Adj(j); 4044 Triangle * ta=tadjj;4045 4046 if (ta->det <0) continue;4047 4048 R2 A = vA; 4049 R2 B = vB;4050 4043 Triangle* ta=tadjj; 4044 4045 //if the adjacent triangle is a boundary triangle, continur 4046 if (ta->det<0) continue; 4047 4048 R2 A=vA; 4049 R2 B=vB; 4051 4050 k=Number(ta); 4052 4051 4053 if(first_np_or_next_t[k]==iter) // this edge is done before 4054 continue; // next edge of the triangle 4055 4056 //const Int4 NbvOld = nbv; 4052 //if this edge has already been done, go to next edge of triangle 4053 if(first_np_or_next_t[k]==iter) continue; 4054 4057 4055 lIntTria.SplitEdge(Bh,A,B); 4058 4056 lIntTria.NewPoints(vertices,nbv,nbvx); 4059 4057 } // end loop for each edge 4060 4061 4058 }// for triangle 4062 4059 4063 if (!InsertNewPoints(nbvold,NbTSwap)) 4064 break; 4065 4060 if (!InsertNewPoints(nbvold,NbTSwap)) break; 4066 4061 for (i=nbtold;i<nbt;i++) first_np_or_next_t[i]=iter; 4067 4068 4062 Headt = nbt; // empty list 4069 4063 4070 // for all the triangle cont ening the vertex i4064 // for all the triangle containing the vertex i 4071 4065 for (i=nbvold;i<nbv;i++){ 4072 4066 Vertex* s = vertices + i; … … 4085 4079 ta = Next(Adj(ta)); 4086 4080 } while ( (tbegin != (Triangle*) ta)); 4087 } 4081 } 4088 4082 4089 4083 } while (nbv!=nbvold);
Note:
See TracChangeset
for help on using the changeset viewer.