Changeset 16967


Ignore:
Timestamp:
11/27/13 14:02:26 (11 years ago)
Author:
Mathieu Morlighem
Message:

NEW: added 'rand' option to bamg so that NR tests work on multiple platforms

Location:
issm/trunk-jpl/src
Files:
6 edited

Legend:

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

    r15066 r16967  
    2020        this->omega=0;
    2121        this->power=0;
     22        this->random=0;
    2223        this->verbose=0;
    2324
  • issm/trunk-jpl/src/c/bamg/BamgOpts.h

    r12821 r16967  
    2525                double  omega;
    2626                double  power;
     27                bool    random;
    2728                int     verbose;
    2829
  • issm/trunk-jpl/src/c/bamg/Mesh.cpp

    r16521 r16967  
    27752775        /*}}}*/
    27762776        /*FUNCTION Mesh::Insert{{{*/
    2777         void Mesh::Insert() {
     2777        void Mesh::Insert(bool random) {
    27782778                /*Original code from Frederic Hecht <hecht@ann.jussieu.fr> (BAMG v1.01, Mesh2.cpp/Insert)*/
    27792779
     
    28222822                //Get Prime number
    28232823                const long PrimeNumber= BigPrimeNumber(nbv);
    2824                 int   k0=rand()%nbv;
     2824                int temp = rand(); if(random) temp = 756804110;
     2825                int  k0=temp%nbv;
    28252826
    28262827                //Build orderedvertices
     
    29042905                        _printf_("      NbSwap/nbv:          " << NbSwap/nbv << "\n");
    29052906                }
    2906 
    2907 #ifdef NBLOOPOPTIM
    2908 
    2909                 k0 = rand()%nbv ;
    2910                 for (int is4=0; is4<nbv; is4++)
    2911                  orderedvertices[is4]= &vertices[k0 = (k0 + PrimeNumber)% nbv];
    2912 
    2913                 for(int Nbloop=0;Nbloop<NBLOOPOPTIM;Nbloop++){
    2914                         long  NbSwap = 0;
    2915                         for (int is1=0; is1<nbv; is1++)
    2916                          NbSwap += orderedvertices[is1]->Optim(0,0);
    2917                         if (verbose>3) {
    2918                                 _printf_("      Optim Loop: " << Nbloop << "\n");
    2919                                 _printf_("      NbSwap/nbv:          " << NbSwap/nbv << "\n");
    2920                         }
    2921                         if(!NbSwap) break;
    2922                 }
    2923                 CreateSingleVertexToTriangleConnectivity();
    2924                 // because we break the TriangleContainingTheVertex
    2925 #endif
    29262907        }
    29272908        /*}}}*/
    29282909        /*FUNCTION Mesh::InsertNewPoints{{{*/
    2929         long Mesh::InsertNewPoints(long nbvold,long & NbTSwap) {
     2910        long Mesh::InsertNewPoints(long nbvold,long & NbTSwap,bool random) {
    29302911                /*Original code from Frederic Hecht <hecht@ann.jussieu.fr> (BAMG v1.01, Mesh2.cpp/InsertNewPoints)*/
    29312912
     
    29482929                const long PrimeNumber= BigPrimeNumber(nbv)  ;
    29492930                //remainder of the division of rand() by nbvnew
    2950                 long k3 = rand()%nbvnew;
     2931                int  temp = rand(); if(!random) temp = 1098566905;
     2932                long k3 = temp%nbvnew;
    29512933                //loop over the new points
    29522934                for (int is3=0; is3<nbvnew; is3++){
     
    32123194                        }
    32133195                        Bh.CreateSingleVertexToTriangleConnectivity();     
    3214                         InsertNewPoints(nbvold,NbTSwap)   ;           
     3196                        InsertNewPoints(nbvold,NbTSwap,bamgopts->random);
    32153197                } 
    32163198                else Bh.CreateSingleVertexToTriangleConnectivity();     
     
    32703252                          }// for triangle   
    32713253
    3272                         if (!InsertNewPoints(nbvold,NbTSwap)) break;
     3254                        if (!InsertNewPoints(nbvold,NbTSwap,bamgopts->random)) break;
    32733255                        for (i=nbtold;i<nbt;i++) first_np_or_next_t[i]=iter;
    32743256                        Headt = nbt; // empty list
     
    42314213
    42324214        /*Insert Vertices*/
    4233         Insert();
     4215        Insert(true);
    42344216}
    42354217/*}}}*/
     
    45344516                if (verbose>3) _printf_("      Creating initial Constrained Delaunay Triangulation...\n");
    45354517                if (verbose>3) _printf_("         Inserting boundary points\n");
    4536                 Insert();
     4518                Insert(bamgopts->random);
    45374519
    45384520                //Force the boundary
     
    48624844                if (verbose>3) _printf_("      Creating initial Constrained Delaunay Triangulation...\n");
    48634845                if (verbose>3) _printf_("         Inserting boundary points\n");
    4864                 Insert();
     4846                Insert(bamgopts->random);
    48654847
    48664848                //Force the boundary
  • issm/trunk-jpl/src/c/bamg/Mesh.h

    r16231 r16967  
    7777                        R2 I2ToR2(const I2 & P) const;
    7878                        void AddVertex(BamgVertex & s,Triangle * t,Icoor2 *  =0) ;
    79                         void Insert();
     79                        void Insert(bool random);
    8080                        void Echo(void);
    8181                        void ForceBoundary();
     
    9292                        void MakeBamgQuadtree();
    9393                        void NewPoints(Mesh &,BamgOpts* bamgopts,int KeepVertices=1);
    94                         long InsertNewPoints(long nbvold,long & NbTSwap) ;
     94                        long InsertNewPoints(long nbvold,long & NbTSwap,bool random);
    9595                        void TrianglesRenumberBySubDomain(bool justcompress=false);
    9696                        void SmoothingVertex(int =3,double=0.3);
  • issm/trunk-jpl/src/m/mesh/bamg.m

    r16379 r16967  
    325325bamg_options.splitcorners=getfieldvalue(options,'splitcorners',1);
    326326bamg_options.geometricalmetric=getfieldvalue(options,'geometricalmetric',0);
     327bamg_options.random=getfieldvalue(options,'rand',true);
    327328bamg_options.verbose=getfieldvalue(options,'verbose',1);
    328329%}}}
  • issm/trunk-jpl/src/m/mesh/bamg.py

    r16962 r16967  
    309309        bamg_options['splitcorners']=options.getfieldvalue('splitcorners',1)
    310310        bamg_options['geometricalmetric']=options.getfieldvalue('geometricalmetric',0)
     311        bamg_options['random']=options.getfieldvalue('rand',True)
    311312        bamg_options['verbose']=options.getfieldvalue('verbose',1)
    312313        #}}}
Note: See TracChangeset for help on using the changeset viewer.