Changeset 24113


Ignore:
Timestamp:
07/30/19 07:18:02 (6 years ago)
Author:
bdef
Message:

CHG: change the treatment of hVertices to vector

Location:
issm/trunk-jpl/src/c
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk-jpl/src/c/bamg/BamgOpts.cpp

    r21864 r24113  
    2828        this->hminVertices=NULL; this->hminVerticesSize[0]=this->hminVerticesSize[1]=0;
    2929        this->hmaxVertices=NULL; this->hmaxVerticesSize[0]=this->hmaxVerticesSize[1]=0;
    30         this->hVertices=NULL;    this->hVerticesSize[0]=this->hVerticesSize[1]=0;
     30        this->hVertices=NULL;    this->hVerticesLength=0;
    3131        this->metric=NULL;       this->metricSize[0]=this->metricSize[1]=0;
    3232        this->field=NULL;        this->fieldSize[0]=this->fieldSize[1]=0;
     
    7070        if (this->hminVertices && this->hminVerticesSize[1]!=1) _error_("'hminVertices' should be a column");
    7171        if (this->hmaxVertices && this->hmaxVerticesSize[1]!=1) _error_("'hmaxVertices' should be a column");
    72         if (this->hVertices && this->hVerticesSize[1]!=1) _error_("'hVertices' should be a column");
     72        if (this->hVertices && this->hVerticesLength<2) _error_("'hVertices' should be a vector");
    7373        if (this->metric && (this->metricSize[1]!=1 && this->metricSize[1]!=3)) _error_("'metric' should have either 1 (iso) or 3 (aniso) columns.");
    7474        if (this->field){
  • issm/trunk-jpl/src/c/bamg/BamgOpts.h

    r21864 r24113  
    11/*!\file:  BamgOpts.h
    22 * \brief place holder for optimization function arguments
    3  */ 
     3 */
    44
    55#ifndef _BAMGOPTS_H_
     
    3838                int     hmaxVerticesSize[2];
    3939                double* hmaxVertices;
    40                 int     hVerticesSize[2];
     40                int     hVerticesLength;
    4141                double* hVertices;
    4242                int     metricSize[2];
  • issm/trunk-jpl/src/c/bamg/Geometry.cpp

    r22897 r24113  
    5757                nbcurves=0;
    5858
    59                 double Hmin = HUGE_VAL;// the infinie value 
     59                double Hmin = HUGE_VAL;// the infinie value
    6060                int i,j,n,i0,i1,i2,i3;
    6161
     
    9696                        /*coefIcoor is the coefficient used for integer coordinates:
    9797                         *                       (x-pmin.x)
    98                          * Icoor x = (2^30 -1) ------------ 
     98                         * Icoor x = (2^30 -1) ------------
    9999                         *                          D
    100100                         * where D is the longest side of the domain (direction x or y)
     
    155155                        }
    156156
    157                         // definition the default of the given mesh size 
     157                        // definition the default of the given mesh size
    158158                        for (i=0;i<nbv;i++) {
    159                                 if (vertices[i].color > 0) 
     159                                if (vertices[i].color > 0)
    160160                                 vertices[i].m=Metric(verticeslength[i] /(double) vertices[i].color);
    161                                 else 
     161                                else
    162162                                 vertices[i].m=Metric(Hmin);
    163163                        }
     
    170170
    171171                //hVertices
    172                 if(bamgopts->hVertices && bamgopts->hVerticesSize[0]==nbv){
     172                if(bamgopts->hVertices && bamgopts->hVerticesLength==nbv){
    173173                        if(verbose>5) _printf_("      processing hVertices\n");
    174174                        for (i=0;i< nbv;i++){
     
    211211                        if (bamggeom->CornersSize[1]!=1) _error_("Corners should have 1 column");
    212212                        n=bamggeom->CornersSize[0];
    213                         for (i=0;i<n;i++) {     
     213                        for (i=0;i<n;i++) {
    214214                                j=(int)bamggeom->Corners[i]-1; //for C indexing
    215215                                if (j>nbv-1 || j<0) _error_("Bad corner definition: should in [0 " << nbv << "]");
     
    225225                        if (bamggeom->RequiredVerticesSize[1]!=1) _error_("RequiredVertices should have 1 column");
    226226                        n=bamggeom->RequiredVerticesSize[0];
    227                         for (i=0;i<n;i++) {     
     227                        for (i=0;i<n;i++) {
    228228                                j=(int)bamggeom->RequiredVertices[i]-1; //for C indexing
    229229                                if (j>nbv-1 || j<0) _error_("Bad RequiredVerticess  definition: should in [0 " << nbv << "]");
     
    237237                        if (bamggeom->RequiredEdgesSize[1]!=1) _error_("RequiredEdges should have 1 column");
    238238                        n=bamggeom->RequiredEdgesSize[0];
    239                         for (i=0;i<n;i++) {     
     239                        for (i=0;i<n;i++) {
    240240                                j=(int)bamggeom->RequiredEdges[i]-1; //for C indexing
    241241                                if (j>nbe-1 || j<0) _error_("Bad RequiredEdges definition: should in [0 " << nbe << "]");
    242                                 edges[j].SetRequired(); 
     242                                edges[j].SetRequired();
    243243                        }
    244244                }
     
    457457                          the vertices by groups of 5:
    458458                          All the coordinates are transformed to ]0,1[^2
    459                           then, the integer coordinates are computed using 
     459                          then, the integer coordinates are computed using
    460460                          the transformation ]0,1[^2 -> [0 2^30-1[^2 for a quadtree of depth 30*/
    461                         vertices[i].i=R2ToI2(vertices[i].r); 
     461                        vertices[i].i=R2ToI2(vertices[i].r);
    462462
    463463                        /*find nearest vertex already present in the quadtree (NULL if empty)*/
    464                         BamgVertex* v=quadtree.NearestVertex(vertices[i].i.x,vertices[i].i.y); 
     464                        BamgVertex* v=quadtree.NearestVertex(vertices[i].i.x,vertices[i].i.y);
    465465
    466466                        /*if there is a vertex found that is to close to vertices[i] -> error*/
     
    506506                 *       head_F[j]=i;
    507507                 *    }
    508                  * 
     508                 *
    509509                 *    Then, we can go through all the elements that have for image j:
    510510                 *    for(i=head_F[j]; i!=-1; i=next_F[i])
     
    512512                 *    stop the loop when i=-1 (end of the chain)
    513513                 *    iterate using i=next_F[i] (next element that have for image j)
    514                  * 
     514                 *
    515515                 * 2. How to use this algorithm here?
    516                  * 
     516                 *
    517517                 * Here F is a function that associates two vertices v0 and v1 for a given edge E
    518518                 * We want to build the reciprocal function: what are the edges that contains
    519519                 * a vertex v?
    520520                 * To do so, we use the same chaining algorithm but there is a difficulty
    521                  * coming from the fact that for F we have a couple of vertices and not one 
     521                 * coming from the fact that for F we have a couple of vertices and not one
    522522                 * vertex.
    523                  * To overcome this difficulty, we use a global indexing exactly like in 
     523                 * To overcome this difficulty, we use a global indexing exactly like in
    524524                 * C/C++ so that
    525525                 * a member of a 2-column-table can be described by one index p=i*2+j
     
    566566                //sort head_v by order of increasing edges angle
    567567                for (i=0;i<nbv;i++) {
    568                         int exch=1,ord=0;     
     568                        int exch=1,ord=0;
    569569
    570570                        //exchange vertices position in head_v and next_p till tey are sorted
    571571                        while (exch){
    572                                 long *p=head_v+i;               
    573                                 long *po=p;                     
    574                                 long  n=*p;                     
     572                                long *p=head_v+i;
     573                                long *po=p;
     574                                long  n=*p;
    575575                                float angleold=-1000 ; // angle = - infinity
    576576                                ord=0; exch=0;
     
    584584
    585585                                        //Next vertex index
    586                                         n=*pn;                       
     586                                        n=*pn;
    587587
    588588                                        //compute angle between horizontal axis and v0->v1
    589                                         float angle = j1 ? OppositeAngle(eangle[i1]):  eangle[i1]; 
     589                                        float angle = j1 ? OppositeAngle(eangle[i1]):  eangle[i1];
    590590
    591591                                        //exchange if the current edge angle is smaller than the previous one
     
    593593                                                exch=1;
    594594                                                *pn=*po;  // next_p[n] = n + 1
    595                                                 *po=*p;   // 
     595                                                *po=*p;   //
    596596                                                *p=n;     // next_p[n+1] = n
    597597                                                po=pn;    // po now point toward pn (invert next and current)
     
    634634                        else{
    635635                                /*all vertices provided in geometry are corners (ord = number of edges holding i)*/
    636                                 vertices[i].SetCorner() ; 
    637                                 if(ord==2){ 
     636                                vertices[i].SetCorner() ;
     637                                if(ord==2){
    638638                                        long  n1 = head_v[i];
    639639                                        long  n2 = next_p[n1];
     
    652652                        /*close the list around the vertex to have a circular loop*/
    653653                        long no=-1, ne = head_v[i];
    654                         while (ne >=0) ne = next_p[no=ne];       
     654                        while (ne >=0) ne = next_p[no=ne];
    655655                        if(no>=0) next_p[no] = head_v[i];
    656656                }
     
    662662                        for (j=0;j<2;j++){
    663663
    664                                 long n1 = next_p[k++]; 
     664                                long n1 = next_p[k++];
    665665                                long i1 = n1/2 ,j1=n1%2;
    666666
     
    695695                                                ltg= lAB;
    696696                                        }
    697                                         //else:  a Corner no tangent => nothing to do   
     697                                        //else:  a Corner no tangent => nothing to do
    698698                                }
    699699                                else{
     
    710710                        if (ltg2[0]!=0) edges[i].SetTgA();
    711711                        if (ltg2[1]!=0) edges[i].SetTgB();
    712                 } 
     712                }
    713713
    714714                /* generation of  all curves (from corner to corner)*/
     
    726726                                for (i=0;i<nbe;i++){
    727727
    728                                         GeomEdge & ei=edges[i];   
     728                                        GeomEdge & ei=edges[i];
    729729                                        for(j=0;j<2;j++){
    730730                                                /*If current edge ei is unmarked and (level=1 or vertex i is required (corner)):
    731731                                                 * we do have the first edge of a new curve*/
    732                                                 if (!ei.Mark() && (level || ei[j].Required())) { 
     732                                                if (!ei.Mark() && (level || ei[j].Required())) {
    733733                                                        int k0=j,k1;
    734734                                                        GeomEdge   *e=&ei;
    735                                                         GeomVertex *a=(*e)(k0); // begin 
     735                                                        GeomVertex *a=(*e)(k0); // begin
    736736                                                        if(curves){
    737737                                                                curves[nbcurves].FirstEdge=e;
     
    739739                                                        }
    740740                                                        int nee=0;
    741                                                         for(;;){ 
     741                                                        for(;;){
    742742                                                                nee++;
    743                                                                 k1 = 1-k0; // next vertex of the edge 
     743                                                                k1 = 1-k0; // next vertex of the edge
    744744                                                                e->SetMark();
    745745                                                                nb_marked_edges++;
     
    765765                                                }
    766766                                        }
    767                                 } 
     767                                }
    768768                        }
    769769                        _assert_(nb_marked_edges && nbe);
    770770                        //allocate if first step
    771771                        if(step==0) curves=new Curve[nbcurves];
    772                 } 
     772                }
    773773
    774774                /*clean up*/
     
    812812
    813813                //Get edge direction and swap v0 and v1 if necessary
    814                 R2 Ag=(R2)(*on)[0],Bg=(R2)(*on)[1],AB=Bg-Ag; 
     814                R2 Ag=(R2)(*on)[0],Bg=(R2)(*on)[1],AB=Bg-Ag;
    815815                int OppositeSens = (V01,AB)<0;
    816816                int direction0=0,direction1=1;
     
    828828                directionge[bge]=1;
    829829
    830                 while(eg0!=(GeomEdge*)vg0 && (*eg0)(direction0)!=(GeomVertex*)vg0){ 
     830                while(eg0!=(GeomEdge*)vg0 && (*eg0)(direction0)!=(GeomVertex*)vg0){
    831831                        if (bge<=0) {
    832832                                if(NbTry) {
     
    846846                        direction0 = 1-( directionge[bge] = tmpge->AdjVertexIndex[direction0]);
    847847                }
    848                 while (eg1 != (GeomEdge*) vg1  &&  (*eg1)(direction1) != (GeomVertex*) vg1) { 
    849                         if(tge>=mxe ) { 
     848                while (eg1 != (GeomEdge*) vg1  &&  (*eg1)(direction1) != (GeomVertex*) vg1) {
     849                        if(tge>=mxe ) {
    850850                                _printf_("WARNING: on the class Mesh before call Geometry::ProjectOnCurve is having issues (isn't it Eric?)\n");
    851851                                NbTry++;
     
    871871
    872872                double sg;
    873                 if (eg0 == eg1) { 
     873                if (eg0 == eg1) {
    874874                        double s0=vg0,s1=vg1;
    875875                        sg =  s0*(1.0-s) +  s*s1;
     
    886886                                lge[i]=ll += Norme2(AA-BB);
    887887                                AA=BB ;}
    888                                 lge[tge]=ll+=Norme2(AA-V1); 
     888                                lge[tge]=ll+=Norme2(AA-V1);
    889889                                // search the geometrical edge
    890890                                _assert_(s<=1.0);
     
    900900                                }
    901901                                on=ge[i];
    902                                 if (i==tge) 
     902                                if (i==tge)
    903903                                 s1=vg1;
    904904
    905905                                s  =(ls-l0)/(l1-l0);
    906                                 sg =s0*(1.0-s)+s*s1;   
    907                 } 
     906                                sg =s0*(1.0-s)+s*s1;
     907                }
    908908                _assert_(on);
    909909                V.r= on->F(sg);
     
    915915                /*coefIcoor is the coefficient used for integer coordinates:
    916916                 *                       (x-pmin.x)
    917                  * Icoor x = (2^30 -1) ------------ 
     917                 * Icoor x = (2^30 -1) ------------
    918918                 *                          D
    919919                 * where D is the longest side of the domain (direction x or y)
     
    927927                for (int i=0;i<nbe;i++) edges[i].SetUnMark();
    928928        }/*}}}*/
    929 } 
     929}
  • issm/trunk-jpl/src/c/modules/Bamgx/Bamgx.cpp

    r22252 r24113  
    2121        int i;
    2222        int noerr=1;
    23         double hminaniso=1e-100; 
     23        double hminaniso=1e-100;
    2424        Mesh* Thr=NULL;
    2525        Mesh* Thb=NULL;
     
    3131        verbosity=bamgopts->verbose;
    3232
    33         // no metric -> no smoothing 
    34         if (bamgopts->metric==NULL) nbsmooth=0; 
     33        // no metric -> no smoothing
     34        if (bamgopts->metric==NULL) nbsmooth=0;
    3535
    3636        /*If no mesh in input, generate one*/
     
    8484                /*Anisotropic mesh adaptation {{{*/
    8585
    86                 // read background mesh 
     86                // read background mesh
    8787                if (verbosity>0) _printf_("Anisotropic mesh adaptation\n");
    8888                if (verbosity>1) _printf_("   Processing initial mesh and geometry...\n");
    89                 Mesh BTh(bamggeom_in,bamgmesh_in,bamgopts); 
     89                Mesh BTh(bamggeom_in,bamgmesh_in,bamgopts);
    9090
    9191                //Make Quadtree from background mesh
     
    101101                        BTh.ReadMetric(bamgopts);
    102102                }
    103                 else { 
     103                else {
    104104                        if (verbosity>1) _printf_("   Generating initial Metric...\n");
    105105                        Metric Mhmax(bamgopts->hmax);
     
    114114
    115115                // change using hVertices if provided
    116                 if(bamgopts->hVertices && bamgopts->hVerticesSize[0]==BTh.nbv){
     116                if(bamgopts->hVertices && bamgopts->hVerticesLength==BTh.nbv){
    117117                        if (verbosity>1) _printf_("   Merging Metric with hVertices...\n");
    118118                        for (i=0;i<BTh.nbv;i++){
Note: See TracChangeset for help on using the changeset viewer.