Changeset 4997


Ignore:
Timestamp:
08/05/10 11:33:17 (15 years ago)
Author:
Mathieu Morlighem
Message:

Some improvements in bamg

Location:
issm/trunk
Files:
2 added
4 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk/src/c/objects/Bamg/Curve.h

    r3913 r4997  
    1313        class Curve {
    1414                public:
    15                         GeometricalEdge * be,*ee; // begin et end edge
     15                        GeometricalEdge *be,*ee; // begin et end edge
    1616                        int kb,ke;  //  begin vetex and end vertex
    1717                        Curve* next; // next curve equi to this
  • issm/trunk/src/c/objects/Bamg/Geometry.cpp

    r3913 r4997  
    726726                                                                 curves[NbOfCurves].ke=k1;
    727727                                                         }
     728
    728729                                                         GeometricalVertex *b=(*e)(k1);
    729730                                                         if (a == b ||  b->Required() ) break;
     
    748749
    749750                /*clean up*/
    750                 delete []next_p;
    751                 delete []head_v;
    752                 delete []eangle;
     751                delete [] next_p;
     752                delete [] head_v;
     753                delete [] eangle;
    753754
    754755        }
     
    941942                                lge[tge]=ll+=Norme2(AA-V1);
    942943                                // search the geometrical edge
    943                                 if (s>1.0){
    944                                         ISSMERROR("s>1.0");
    945                                 }
     944                                ISSMASSERT(s<=1.0);
    946945                                double ls= s*ll;
    947946                                on =0;
     
    951950                                i=bge;
    952951                                while (  (l1=lge[i]) < ls ) {
    953                                         if (i<0 || i>mxe){
    954                                                 ISSMERROR("i<0 || i>mxe");
    955                                         }
     952                                        ISSMASSERT(i>=0 && i<=mxe);
    956953                                        i++,s0=1-(s1=sensge[i]),l0=l1;
    957954                                }
  • issm/trunk/src/c/objects/Bamg/Triangles.cpp

    r3913 r4997  
    27372737                GeometricalVertex *a,*b;
    27382738                MeshVertex *va,*vb;
    2739                 GeometricalEdge * e;
     2739                GeometricalEdge *e;
    27402740
    27412741                /*Get options*/
     
    28382838
    28392839                                                                        //check that edges has been allocated
    2840                                                                         if (!edges){
    2841                                                                                 ISSMERROR("edges has not been allocated...");
    2842                                                                         }
     2840                                                                        if (!edges) ISSMERROR("edges has not been allocated...");
    28432841                                                                        edges[nbe].v[0]=a->to;
    28442842                                                                        edges[nbe].v[1]=b->to;;
     
    28542852                                                /*If Edge is not required: on a curve*/
    28552853                                                else {
    2856                                                         for ( int kstep=0;kstep<=step;kstep++){
     2854                                                        for (int kstep=0;kstep<=step;kstep++){
    28572855                                                                //step=0, do nothing
    28582856                                                                //step=1, compute the length of the curve
     
    30443042
    30453043                /*************************************************************************
    3046                 // methode in 2 step
    3047                 // 1 - compute the number of new edge to allocate
    3048                 // 2 - construct the edge
    3049 remark:
    3050 in this part we suppose to have a background mesh with the same
    3051 geometry
    3052 
    3053 To construct the discretisation of the new mesh we have to
    3054 rediscretize the boundary of background Mesh
    3055 because we have only the pointeur from the background mesh to the geometry.
    3056 We need the abcisse of the background mesh vertices on geometry
    3057 so a vertex is
    3058 0 on GeometricalVertex ;
    3059 1 on GeometricalEdge + abcisse
    3060 2 internal
     3044                 * method in 2 steps
     3045                 * 1 - compute the number of new edges to allocate
     3046                 * 2 - construct the edges
     3047                 * remark:
     3048                 * in this part we suppose to have a background mesh with the same geometry
     3049                 *
     3050                 * To construct the discretization of the new mesh we have to
     3051                 * rediscretize the boundary of background Mesh
     3052                 * because we have only the pointeur from the background mesh to the geometry.
     3053                 * We need the abcisse of the background mesh vertices on geometry
     3054                 * so a vertex is
     3055                 * 0 on GeometricalVertex ;
     3056                 * 1 on GeometricalEdge + abcisse
     3057                 * 2 internal
    30613058                 *************************************************************************/
    30623059
     
    30663063
    30673064                //Initialize new mesh
    3068                 PreInit(inbvx);
     3065                this->PreInit(inbvx);
    30693066                BTh.SetVertexFieldOn();
    30703067                int* bcurve = new int[Gh.NbOfCurves]; //
    30713068
    3072                 // we have 2 ways to make the loop
    3073                 // 1) on the geometry
    3074                 // 2) on the background mesh
    3075                 //  if you do the loop on geometry, we don't have the pointeur on background,
    3076                 //  and if you do the loop in background we have the pointeur on geometry
    3077                 // so do the walk on  background
    3078                 //  long NbVerticesOnGeomVertex;
    3079                 //  VertexOnGeom * VerticesOnGeomVertex; 
    3080                 //  long NbVerticesOnGeomEdge;
    3081                 //  VertexOnGeom * VerticesOnGeomEdge;
     3069                /* There are 2 ways to make the loop
     3070                * 1) on the geometry
     3071                * 2) on the background mesh
     3072                *  if you do the loop on geometry, we don't have the pointeur on background,
     3073                *  and if you do the loop in background we have the pointeur on geometry
     3074                * so do the walk on  background */
    30823075
    30833076                NbVerticesOnGeomVertex=0;
     
    30883081                int i;
    30893082                for (i=0;i<Gh.nbv;i++) if (Gh[i].Required()) NbVerticesOnGeomVertex++;
    3090                 if( NbVerticesOnGeomVertex >= nbvx) { ISSMERROR("too many vertices on geometry: %i >= %i",NbVerticesOnGeomVertex,nbvx);}
     3083                if(NbVerticesOnGeomVertex >= nbvx) { ISSMERROR("too many vertices on geometry: %i >= %i",NbVerticesOnGeomVertex,nbvx);}
    30913084
    30923085                VerticesOnGeomVertex = new VertexOnGeom[  NbVerticesOnGeomVertex];
    30933086                VertexOnBThVertex    = new VertexOnVertex[NbVerticesOnGeomVertex];
    30943087
    3095                 //At this point there is NO vertex but vertices should be have been allocated by PreInit
     3088                //At this point there is NO vertex but vertices should have been allocated by PreInit
    30963089                ISSMASSERT(vertices);
    30973090                for (i=0;i<Gh.nbv;i++){
     
    31173110                ISSMASSERT(NbVertexOnBThVertex==NbVerticesOnGeomVertex);
    31183111
    3119                 /*STEP 2: reseed bounday edges*/
     3112                /*STEP 2: reseed boundary edges*/
    31203113
    31213114                //  find the begining of the curve in BTh
     
    31233116                int bfind=0;
    31243117                for (int i=0;i<Gh.NbOfCurves;i++) bcurve[i]=-1;
     3118
     3119                /*Loop over the backgrounf mesh BTh edges*/
    31253120                for (int iedge=0;iedge<BTh.nbe;iedge++){     
    31263121                        Edge &ei = BTh.edges[iedge];
    3127                         for(int je=0;je<2;je++){ // for the 2 extremities
    3128 
    3129                                 // If one of the vertex is required we are in a new curve
     3122
     3123                        /*Loop over the 2 vertices of the current edge*/
     3124                        for(int je=0;je<2;je++){
     3125
     3126                                /* If one of the vertex is required we are in a new curve*/
    31303127                                if (ei[je].onGeometry->IsRequiredVertex()){
    31313128
    3132                                         //Get curve number
     3129                                        /*Get curve number*/
    31333130                                        int nc=ei.onGeometry->CurveNumber;
    31343131                                       
     3132                                        //printf("Dealing with curve number %i\n",nc);
     3133                                        //printf("edge on geometry is same as GhCurve? %s\n",(ei.onGeometry==Gh.curves[nc].be || ei.onGeometry==Gh.curves[nc].ee)?"yes":"no");
     3134                                        //if(ei.onGeometry==Gh.curves[nc].be || ei.onGeometry==Gh.curves[nc].ee){
     3135                                        //      printf("Do we have the right extremity? curve first vertex -> %s\n",((GeometricalVertex *)*ei[je].onGeometry==&(*Gh.curves[nc].be)[Gh.curves[nc].kb])?"yes":"no");
     3136                                        //      printf("Do we have the right extremity? curve last  vertex -> %s\n",((GeometricalVertex *)*ei[je].onGeometry==&(*Gh.curves[nc].ee)[Gh.curves[nc].ke])?"yes":"no");
     3137                                        //}
    31353138                                        //BUG FIX from original bamg
    3136                                         //Check that we are on the same edge and right extrimity
     3139                                        /*Check that we are on the same edge and right vertex (0 or 1) */
    31373140                                        if(ei.onGeometry==Gh.curves[nc].be  && (GeometricalVertex *)*ei[je].onGeometry==&(*Gh.curves[nc].be)[Gh.curves[nc].kb]){
    31383141                                                bcurve[nc]=iedge*2+je;
     
    31463149                        }
    31473150                }
    3148                 if (bfind!=Gh.NbOfCurves){
    3149                         ISSMERROR("problem generating number of curves (Gh.NbOfCurves=%i bfind=%i)",Gh.NbOfCurves,bfind);
    3150                 }
     3151                if (bfind!=Gh.NbOfCurves) ISSMERROR("problem generating number of curves (Gh.NbOfCurves=%i bfind=%i)",Gh.NbOfCurves,bfind);
    31513152
    31523153                // method in 2 + 1 step
     
    31543155                //  1.0) recompute the length
    31553156                //  1.1) compute the  vertex
     3157
    31563158                long nbex=0,NbVerticesOnGeomEdgex=0;
    31573159                for (int step=0; step <2;step++){
     
    31633165                        double L=0;
    31643166
     3167                        /*Go through all geometrical curve*/
    31653168                        for (int icurve=0;icurve<Gh.NbOfCurves;icurve++){
    31663169
     3170                                /*Get edge and vertex (index) of background mesh on this curve*/
    31673171                                iedge=bcurve[icurve]/2;
    31683172                                int jedge=bcurve[icurve]%2;
    3169                                 if(!Gh.curves[icurve].master) continue; // we skip all equi curve
     3173
     3174                                /*Skip if we are on a equi curve (duplicate)*/
     3175                                if(!Gh.curves[icurve].master) continue;
     3176
     3177                                /*Get edge of Bth with index iedge*/
    31703178                                Edge &ei = BTh.edges[iedge];
    3171                                 // warning: ei.on->Mark() can be change in
    3172                                 // loop for(jedge=0;jedge<2;jedge++)
    31733179                       
     3180                                /*Initialize variables*/
    31743181                                double Lstep=0,Lcurve=0;    // step between two points   (phase==1)
    31753182                                long NbCreatePointOnCurve=0;// Nb of new points on curve (phase==1)
    31763183
     3184                                /*Do phase 0 to step*/
    31773185                                for(int phase=0;phase<=step;phase++){
    31783186
    3179                                         for(Curve * curve= Gh.curves+icurve;curve;curve= curve->next){
    3180 
     3187                                        /*Loop over all curves from icurve till the last curve*/
     3188                                        for(Curve *curve= Gh.curves+icurve;curve;curve= curve->next){
     3189
     3190                                                /*Get index of current curve*/
    31813191                                                int icurveequi= Gh.Number(curve);
    31823192
    3183                                                 if( phase==0 &&  icurveequi!=icurve)  continue;
     3193                                                /*For phase 0, check that we are at the begining of the curve only*/
     3194                                                if(phase==0 &&  icurveequi!=icurve)  continue;
    31843195
    31853196                                                int   k0=jedge,k1;
  • issm/trunk/src/m/classes/public/bamg.m

    r3994 r4997  
    233233
    234234        %process geom
    235         bamg_geometry=processgeometry(bamg_geometry,getfieldvalue(options,'tol',NaN),domain(1));
     235        %bamg_geometry=processgeometry(bamg_geometry,getfieldvalue(options,'tol',NaN),domain(1));
    236236
    237237elseif isstruct(md.bamg),
Note: See TracChangeset for help on using the changeset viewer.