Changeset 3267
- Timestamp:
- 03/12/10 07:27:15 (15 years ago)
- Location:
- issm/trunk/src/c/Bamgx
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk/src/c/Bamgx/Bamgx.cpp
r3263 r3267 113 113 if (verbosity>0) printf("Anisotropic mesh adaptation\n"); 114 114 if (verbosity>1) printf(" Processing initial mesh and geometry...\n"); 115 Triangles BTh(bamg mesh_in,bamgopts);115 Triangles BTh(bamggeom_in,bamgmesh_in,bamgopts); 116 116 hmin = Max(hmin,BTh.MinimalHmin()); 117 117 hmax = Min(hmax,BTh.MaximalHmax()); -
issm/trunk/src/c/Bamgx/objects/BamgObjects.h
r3263 r3267 2 2 #define _BAMGOBEJECTS_H_ 3 3 4 /*Bamg objects (Must be compiled in this order!! */4 /*Bamg objects (Must be compiled in this order!!)*/ 5 5 #include "./Metric.h" 6 6 #include "./DoubleAndInt.h" … … 22 22 #include "./Triangles.h" 23 23 #include "./Geometry.h" 24 #include "./QuadTree.h" 25 #include "./SetOfE4.h" 24 26 25 27 #endif -
issm/trunk/src/c/Bamgx/objects/QuadTree.cpp
r3263 r3267 220 220 register long n0; 221 221 register QuadTreeBox* b; 222 IntQuadh=MaxISize,h0;223 IntQuadhb=MaxISize;222 long h=MaxISize,h0; 223 long hb=MaxISize; 224 224 Icoor1 i0=0,j0=0; 225 225 //iplus= i projected in [0,MaxISize-1] (example: if i<0, i=0) … … 356 356 int l; // level 357 357 QuadTreeBox * b; 358 IntQuad h=MaxISize,h0;359 IntQuad hb =MaxISize;358 long h =MaxISize,h0; 359 long hb=MaxISize; 360 360 Icoor1 i0=0,j0=0; 361 361 Icoor1 iplus( i<MaxISize?(i<0?0:i):MaxISize-1); -
issm/trunk/src/c/Bamgx/objects/QuadTree.h
r3246 r3267 10 10 namespace bamg { 11 11 12 typedef long IntQuad; 13 14 const int MaxDeep = 30; 15 const IntQuad MaxISize = ( 1L << MaxDeep); 12 const int MaxDeep = 30; 13 const long MaxISize = ( 1L << MaxDeep); 16 14 17 15 class Triangles; -
issm/trunk/src/c/Bamgx/objects/Triangles.cpp
r3263 r3267 3 3 #include <cmath> 4 4 #include <ctime> 5 #include <assert.h> 5 6 6 7 #include "BamgObjects.h" 7 8 #include "../shared/shared.h" 8 #include "QuadTree.h"9 #include "SetOfE4.h"10 9 11 10 #undef __FUNCT__ … … 18 17 19 18 /*Constructors/Destructors*/ 20 /*FUNCTION Triangles::Triangles(BamgMesh* bamgmesh, BamgOpts* bamgopts){{{1*/ 21 Triangles::Triangles(BamgMesh* bamgmesh, BamgOpts* bamgopts):Gh(*(new Geometry())),BTh(*this){ 19 /*FUNCTION Triangles::Triangles(BamgGeom* bamggeom,BamgMesh* bamgmesh, BamgOpts* bamgopts){{{1*/ 20 Triangles::Triangles(BamgGeom* bamggeom,BamgMesh* bamgmesh, BamgOpts* bamgopts):Gh(*(new Geometry())),BTh(*this){ 21 22 /*Initialize fields*/ 22 23 PreInit(0); 24 25 /*Read background mesh*/ 23 26 ReadMesh(bamgmesh,bamgopts); 27 28 /*Read Geometry*/ 29 if(bamggeom->NumEdges==0) { 30 /*Recreate geometry if needed*/ 31 printf("WARNING: mesh present but no geometry found. Reconstructing...\n"); 32 BuildGeometryFromMesh(bamgopts); 33 Gh.AfterRead(); 34 } 35 else{ 36 Gh.ReadGeometry(bamggeom,bamgopts); 37 Gh.AfterRead(); 38 } 39 40 /*Set integer coordinates*/ 24 41 SetIntCoor(); 25 GenerateMeshProperties(); 42 43 /*Fill holes and generate mesh properties*/ 44 ReconstructExistingMesh(); 26 45 } 27 46 /*}}}1*/ … … 32 51 ReadMesh(index,x,y,nods,nels); 33 52 SetIntCoor(); 34 GenerateMeshProperties();53 ReconstructExistingMesh(); 35 54 } 36 55 /*}}}1*/ … … 127 146 Gh.AfterRead(); 128 147 SetIntCoor(); 129 GenerateMeshProperties();148 ReconstructExistingMesh(); 130 149 131 150 if (!NbSubDomains){ … … 523 542 } 524 543 525 /*Recreate geometry if needed*/526 if(1!=0) {527 printf("WARNING: mesh present but no geometry found. Reconstructing...\n");528 /*Recreate geometry: */529 BuildGeometryFromMesh(bamgopts);530 Gh.AfterRead();531 }532 544 } 533 545 /*}}}1*/ … … 2604 2616 } 2605 2617 /*}}}1*/ 2606 /*FUNCTION Triangles:: GenerateMeshProperties{{{1*/2607 void Triangles:: GenerateMeshProperties() {2618 /*FUNCTION Triangles::ReconstructExistingMesh{{{1*/ 2619 void Triangles::ReconstructExistingMesh() { 2608 2620 /*Original code from Frederic Hecht <hecht@ann.jussieu.fr> (BAMG v1.01, Mesh2.cpp/FillHoleInMesh)*/ 2621 2622 /*This routine reconstruct an existing mesh to make it CONVEX: 2623 * -all the holes are filled 2624 * -concave boundaries are filled 2625 * A convex mesh is required for a lot of operations. This is why every mesh 2626 * goes through this process. 2627 * This routine also generates mesh properties such as adjencies,... 2628 */ 2609 2629 2610 2630 int verbosity=0; … … 2614 2634 // find extrema coordinates of vertices pmin,pmax 2615 2635 long i; 2616 if(verbosity>2) printf(" Filling holes inmesh of %i vertices\n",nbv);2636 if(verbosity>2) printf(" Completing Triangles structure for a mesh of %i vertices\n",nbv); 2617 2637 2618 2638 //initialize ordre 2619 if (!ordre){ 2620 throw ErrorException(__FUNCT__,exprintf("!ordre")); 2621 } 2639 assert(ordre); 2622 2640 for (i=0;i<nbv;i++) ordre[i]=0; 2623 2641 … … 2651 2669 } 2652 2670 else if(st[k]>=0) { 2653 if (triangles[i].TriangleAdj(j) || triangles[st[k] / 3].TriangleAdj((int) (st[k]%3))){ 2654 throw ErrorException(__FUNCT__,exprintf("(triangles[i].TriangleAdj(j) || triangles[st[k] / 3].TriangleAdj((int) (st[k]%3)))")); 2655 } 2671 assert(!triangles[i].TriangleAdj(j)); 2672 assert(!triangles[st[k]/3].TriangleAdj((int) (st[k]%3))); 2656 2673 2657 2674 triangles[i].SetAdj2(j,triangles + st[k] / 3,(int) (st[k]%3)); … … 2681 2698 for (i=0;i<edge4->nb();i++){ 2682 2699 if (st[i] >=0){ // edge alone 2683 if (i < nbe){2700 if (i<nbe){ 2684 2701 long i0=edge4->i(i); 2685 2702 ordre[i0] = vertices+i0; … … 2689 2706 else { 2690 2707 k=k+1; 2691 if (k <20) { 2692 throw ErrorException(__FUNCT__,exprintf("Lost boundary edges %i : %i %i",i,edge4->i(i),edge4->j(i))); 2708 if (k<10) { 2709 //print only 10 edges 2710 printf("Lost boundary edges %i : %i %i\n",i,edge4->i(i),edge4->j(i)); 2693 2711 } 2694 } 2695 } 2696 } 2697 if(k != 0) { 2698 throw ErrorException(__FUNCT__,exprintf("%i boundary edges are not defined as edges",k)); 2712 else if (k==10){ 2713 printf("Other lost boundary edges not shown...\n"); 2714 } 2715 } 2716 } 2717 } 2718 if(k) { 2719 throw ErrorException(__FUNCT__,exprintf("%i boundary edges (from the geometry) are not defined as mesh edges",k)); 2699 2720 } 2700 2721 … … 2705 2726 vertices[i].vint=0; 2706 2727 if (ordre[i]){ 2707 ordre[nbvb++] =ordre[i];2708 } 2709 } 2710 2711 Triangle* savetriangles= 2728 ordre[nbvb++]=ordre[i]; 2729 } 2730 } 2731 2732 Triangle* savetriangles=triangles; 2712 2733 long savenbt=nbt; 2713 2734 long savenbtx=nbtx; 2714 SubDomain * savesubdomains =subdomains;2715 subdomains =0;2735 SubDomain* savesubdomains=subdomains; 2736 subdomains=0; 2716 2737 2717 2738 long Nbtriafillhole = 2*nbvb; … … 2723 2744 2724 2745 for (i=2 ; det( ordre[0]->i, ordre[1]->i, ordre[i]->i ) == 0;) 2725 if ( ++i >=nbvb) {2726 throw ErrorException(__FUNCT__,exprintf(" GenerateMeshProperties: All the vertices are aligned"));2746 if (++i>=nbvb) { 2747 throw ErrorException(__FUNCT__,exprintf("ReconstructExistingMesh: All the vertices are aligned")); 2727 2748 } 2728 Exchange( 2749 Exchange(ordre[2], ordre[i]); 2729 2750 2730 2751 Vertex * v0=ordre[0], *v1=ordre[1]; 2731 2752 2732 2733 triangles[0](0) = 0; // sommet pour infini 2753 triangles[0](0) = NULL; // Infinite vertex 2734 2754 triangles[0](1) = v0; 2735 2755 triangles[0](2) = v1; 2736 2756 2737 triangles[1](0) = 0;// sommet pour infini2757 triangles[1](0) = NULL;// Infinite vertex 2738 2758 triangles[1](2) = v0; 2739 2759 triangles[1](1) = v1; … … 2745 2765 triangles[0].SetAdj2(e2, &triangles[1] ,e1); 2746 2766 2747 triangles[0].det = -1; // fauxtriangles2748 triangles[1].det = -1; // fauxtriangles2767 triangles[0].det = -1; // boundary triangles 2768 triangles[1].det = -1; // boundary triangles 2749 2769 2750 2770 triangles[0].SetTriangleContainingTheVertex(); … … 2881 2901 SetVertexFieldOn(); 2882 2902 2883 for (i=0;i<nbe;i++) 2884 if(edges[i].onGeometry) 2885 for(int j=0;j<2;j++) 2886 if (!edges[i].adj[j]) 2887 if(!edges[i][j].onGeometry->IsRequiredVertex()) { 2888 throw ErrorException(__FUNCT__,exprintf("adj and vertex required esge(?)")); 2889 } 2903 /*Check requirements consistency*/ 2904 for (i=0;i<nbe;i++){ 2905 /*If the current mesh edge is on Geometry*/ 2906 if(edges[i].onGeometry){ 2907 for(int j=0;j<2;j++){ 2908 if (!edges[i].adj[j]){ 2909 if(!edges[i][j].onGeometry->IsRequiredVertex()) { 2910 printf("Error: adj and vertex requires edges [%i %i]=%i on = %i\n",i,j,Number(edges[i][j]),Gh.Number(edges[i].onGeometry)); 2911 if (edges[i][j].onGeometry->OnGeomVertex()) 2912 printf(" Vertex %i\n",Gh.Number(edges[i][j].onGeometry->gv)); 2913 else if (edges[i][j].onGeometry->OnGeomEdge()) 2914 printf(" Edges %i \n",Gh.Number(edges[i][j].onGeometry->ge)); 2915 else 2916 printf(" = %p\n",edges[i][j].onGeometry); 2917 throw ErrorException(__FUNCT__,exprintf("See above (might be cryptic...)")); 2918 } 2919 } 2920 } 2921 } 2922 } 2890 2923 } 2891 2924 /*}}}1*/ … … 5271 5304 // ReMakeTriangleContainingTheVertex(); 5272 5305 5273 GenerateMeshProperties();5306 ReconstructExistingMesh(); 5274 5307 5275 5308 if (verbosity>2){ -
issm/trunk/src/c/Bamgx/objects/Triangles.h
r3263 r3267 68 68 69 69 //Constructors/Destructors 70 Triangles(Bamg Mesh* bamgmesh,BamgOpts* bamgopts);70 Triangles(BamgGeom* bamggeom,BamgMesh* bamgmesh,BamgOpts* bamgopts); 71 71 Triangles(double* index,double* x,double* y,int nods,int nels); 72 72 Triangles(Triangles &,Geometry * pGh=0,Triangles* pBTh=0,long nbvxx=0 ); //copy operator … … 145 145 int UnCrack(); 146 146 void BuildGeometryFromMesh(BamgOpts* bamgopts=NULL); 147 void GenerateMeshProperties();147 void ReconstructExistingMesh(); 148 148 int CrackMesh(); 149 149 -
issm/trunk/src/c/Bamgx/objects/VertexOnGeom.h
r3263 r3267 24 24 double abscisse; 25 25 union{ 26 GeometricalVertex 27 GeometricalEdge * ge;// if abscisse in [0..1]26 GeometricalVertex* gv; // if abscisse <0; 27 GeometricalEdge* ge; // if abscisse in [0..1] 28 28 }; 29 29 … … 46 46 47 47 //Inline methods 48 //inline void Set(const Triangles &,long,Triangles &);49 48 void Set(const VertexOnGeom&,const Triangles &,Triangles &); 50 49
Note:
See TracChangeset
for help on using the changeset viewer.