Changeset 16166


Ignore:
Timestamp:
09/18/13 10:13:56 (12 years ago)
Author:
Mathieu Morlighem
Message:

CHG: cppcheck errors

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

Legend:

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

    r16158 r16166  
    499499                double        eps      = 1e-20;
    500500                BamgQuadtree  quadtree;                            // build quadtree to find duplicates
    501                 BamgVertex   *v0       = vertices;
    502501
    503502                k=0;
  • issm/trunk-jpl/src/c/bamg/Mesh.cpp

    r16158 r16166  
    522522                                head=(int)bamgmesh->SubDomains[i*3+1]-1;//C indexing
    523523                                direction=(int)bamgmesh->SubDomains[i*3+2];
    524                                 if (i3!=23) _error_("Bad Subdomain definition: first number should be 3");
     524                                if (i3!=3) _error_("Bad Subdomain definition: first number should be 3");
    525525                                if (head<0 || head>=nbt) _error_("Bad Subdomain definition: head should in [1 " << nbt << "] (triangle number)");
    526526                                subdomains[i].head = triangles+head;
     527                                subdomains[i].direction = direction;
     528                                subdomains[i].ReferenceNumber = i3;
    527529                        }
    528530                }
     
    10511053
    10521054                /*Get options*/
    1053                 int    verbose=bamgopts->verbose;
    1054                 double anisomax =bamgopts->anisomax;
    1055                 double errg     =bamgopts->errg;
     1055                int    verbose  = bamgopts->verbose;
     1056                double anisomax = bamgopts->anisomax;
     1057                double errg     = bamgopts->errg;
    10561058
    10571059                double ss[2]={0.00001,0.99999};
     
    10611063
    10621064                //check that hmax is positive
    1063                 if (hmax<=0){
    1064                         _error_("hmax<=0");
    1065                 }
     1065                _assert_(hmax>0);
    10661066
    10671067                //errC cannot be higher than 1
    1068                 if (errC>1) errC=1;
     1068                if(errC>1) errC=1;
    10691069
    10701070                //Set all vertices to "on"
     
    10721072
    10731073                //loop over all the vertices on edges
    1074                 for (int  i=0;i<nbe;i++){
     1074                for(int  i=0;i<nbe;i++){
    10751075                        for (int j=0;j<2;j++){
    10761076
     
    26212621
    26222622                          }
    2623                         else
    2624                           { // find the head for all sub domaine
     2623                        else{ // find the head for all subdomains
    26252624                                if (Gh.nbsubdomains != nbsubdomains && subdomains)
    26262625                                 delete [] subdomains, subdomains=0;
     
    26282627                                 subdomains = new SubDomain[ Gh.nbsubdomains];
    26292628                                nbsubdomains =Gh.nbsubdomains;
    2630                                 long err=0;
    26312629                                CreateSingleVertexToTriangleConnectivity();
    26322630                                long * mark = new long[nbt];
     
    26392637                                        GeomEdge &eg = *Gh.subdomains[i].edge;
    26402638                                        subdomains[i].ReferenceNumber = Gh.subdomains[i].ReferenceNumber;
    2641                                         int ssdlab = subdomains[i].ReferenceNumber;
    26422639                                        // by carefull is not easy to find a edge create from a GeomEdge
    26432640                                        // see routine MakeGeomEdgeToEdge
     
    31093106        void Mesh::MakeBamgQuadtree() { 
    31103107                /*Original code from Frederic Hecht <hecht@ann.jussieu.fr> (BAMG v1.01, Mesh2.cpp/MakeBamgQuadtree)*/
    3111 
    3112                 long int verbose=0;
    3113                 if (  !quadtree )  quadtree = new BamgQuadtree(this);
    3114 
     3108                if(!quadtree) quadtree = new BamgQuadtree(this);
    31153109        }
    31163110        /*}}}*/
     
    33143308                        }
    33153309
    3316                 } while (nbv!=nbvold);
    3317 
    3318                 delete []  first_np_or_next_t;
    3319 
    3320                 long NbSwapf =0,NbSwp;
    3321 
    3322                 NbSwp = NbSwapf;
    3323                 for (i=0;i<nbv;i++)
    3324                  NbSwapf += vertices[i].Optim(0);
    3325                 NbTSwap +=  NbSwapf ;
    3326         }
    3327         /*}}}*/
     3310                }while(nbv!=nbvold);
     3311                delete [] first_np_or_next_t;
     3312
     3313                long NbSwapf =0;
     3314
     3315                for(i=0;i<nbv;i++) NbSwapf += vertices[i].Optim(0);
     3316        }/*}}}*/
    33283317        /*FUNCTION Mesh::ProjectOnCurve{{{*/
    33293318        GeomEdge*   Mesh::ProjectOnCurve( Edge & BhAB, BamgVertex &  vA, BamgVertex & vB,
     
    37663755                /*Original code from Frederic Hecht <hecht@ann.jussieu.fr> (BAMG v1.01, Mesh2.cpp/ReNumberingTheTriangleBySubDomain)*/
    37673756
    3768                 long int verbose=0;
    37693757                long *renu= new long[nbt];
    37703758                register Triangle *t0,*t,*te=triangles+nbt;
     
    48894877        /*Original code from Frederic Hecht <hecht@ann.jussieu.fr> (BAMG v1.01, Mesh2.cpp/ConsRefTriangle)*/
    48904878
    4891         long int verbose=0;
    48924879        register Triangle *t0,*t;
    48934880        register long k=0, num;   
     
    54165403
    54175404                                /*Initialize variables*/
    5418                                 double Lstep=0,Lcurve=0;    // step between two points   (phase==1)
     5405                                double Lstep=0;             // step between two points   (phase==1)
    54195406                                long NbCreatePointOnCurve=0;// Nb of new points on curve (phase==1)
    54205407
     
    55495536                                                long NbSegOnCurve = Max((long)(L+0.5),(long) 1);// nb of seg
    55505537                                                Lstep = L/NbSegOnCurve;
    5551                                                 Lcurve = L;
    55525538                                                NbCreatePointOnCurve = NbSegOnCurve-1;
    55535539                                                NbOfNewEdge += NbSegOnCurve;
     
    56805666                                _error_("!v1 || !v2");
    56815667                        }
    5682                         Icoor2 detss = 0,l=0,ks;
    5683                         while ((ks=SwapForForcingEdge(  va,  vb, tc, detss, det1,det2,NbSwap)))
     5668                        Icoor2 detss = 0,l=0;
     5669                        while ((SwapForForcingEdge(  va,  vb, tc, detss, det1,det2,NbSwap)))
    56845670                         if(l++ > 10000000) {
    56855671                                 _error_("Loop in forcing Egde, nb de swap=" << NbSwap << ", nb of try swap (" << l << ") too big");
  • issm/trunk-jpl/src/c/classes/Elements/Penta.cpp

    r16164 r16166  
    157157void Penta::BasalFrictionCreateInput(void){
    158158
    159         /*Constants*/
    160         const int  numdof=NUMVERTICES*NDOF1;
    161 
    162159        /*Intermediaries */
    163         int    count;
    164         IssmDouble basalfriction[NUMVERTICES]={0,0,0,0,0,0};
    165         IssmDouble alpha2,vx,vy;
    166         Friction*  friction=NULL;
    167         GaussPenta* gauss=NULL;
     160        int         count;
     161        IssmDouble  basalfriction[NUMVERTICES];
     162        IssmDouble  alpha2                       ,vx,vy;
     163        Friction   *friction                   = NULL;
     164        GaussPenta *gauss                      = NULL;
    168165
    169166        /* Basal friction can only be found at the base of an ice sheet: */
     
    567564
    568565        /*retrieve parameters: */
    569         ElementMatrix* Ke=NULL;
    570566        ElementVector* De=NULL;
    571567        int analysis_type;
    572568        parameters->FindParam(&analysis_type,AnalysisTypeEnum);
    573569
    574         /*Checks in debugging {{{*/
     570        /*Checks in debugging*/
    575571        _assert_(this->nodes && this->material && this->matpar && this->verticalneighbors && this->parameters && this->inputs);
    576         /*}}}*/
    577572
    578573        switch(analysis_type){
     
    21442139void  Penta::InputToResult(int enum_type,int step,IssmDouble time){
    21452140
    2146         bool   found = false;
    21472141        Input *input = NULL;
    21482142
    21492143        /*Go through all the input objects, and find the one corresponding to enum_type, if it exists: */
    2150         if (enum_type==MaterialsRheologyBbarEnum) input=this->material->inputs->GetInput(MaterialsRheologyBEnum);
    2151         else if (enum_type==MaterialsRheologyZbarEnum) input=this->material->inputs->GetInput(MaterialsRheologyZEnum);
    2152         else input=this->inputs->GetInput(enum_type);
     2144        if      (enum_type==MaterialsRheologyBbarEnum)
     2145         input=this->material->inputs->GetInput(MaterialsRheologyBEnum);
     2146        else if (enum_type==MaterialsRheologyZbarEnum)
     2147         input=this->material->inputs->GetInput(MaterialsRheologyZEnum);
     2148        else
     2149         input=this->inputs->GetInput(enum_type);
    21532150        //if (!input) _error_("Input " << EnumToStringx(enum_type) << " not found in penta->inputs"); why error out? if the requested input does not exist, we should still
    21542151        //try and output whatever we can instead of just failing.
     
    28522849
    28532850        /*Intermediaries*/
    2854         int     i;
    2855         int     numberofresults = 0;
    2856         int     *resultsenums   = NULL;
    2857         int     *resultssizes   = NULL;
    2858         IssmDouble  *resultstimes   = NULL;
    2859         int     *resultssteps   = NULL;
     2851        int        *resultsenums    = NULL;
     2852        int        *resultssizes    = NULL;
     2853        IssmDouble *resultstimes    = NULL;
     2854        int        *resultssteps    = NULL;
    28602855
    28612856        /*Checks*/
     
    28632858
    28642859        /*Count number of results*/
    2865         for(i=0;i<this->results->Size();i++){
    2866                 ElementResult* elementresult=(ElementResult*)this->results->GetObjectByOffset(i);
    2867                 numberofresults++;
    2868         }
     2860        int numberofresults = this->results->Size();
    28692861
    28702862        if(numberofresults){
    2871 
    28722863                /*Allocate output*/
    28732864                resultsenums=xNew<int>(numberofresults);
     
    28772868
    28782869                /*populate enums*/
    2879                 for(i=0;i<this->results->Size();i++){
     2870                for(int i=0;i<this->results->Size();i++){
    28802871                        ElementResult* elementresult=(ElementResult*)this->results->GetObjectByOffset(i);
    28812872                        resultsenums[i]=elementresult->InstanceEnum();
     
    37813772void Penta::ViscousHeatingCreateInput(void){
    37823773
    3783         /*Constants*/
    3784         const int  numdof=NUMVERTICES*NDOF1;
    3785 
    37863774        /*Intermediaries*/
    37873775        IssmDouble phi;
     
    37893777        IssmDouble xyz_list[NUMVERTICES][3];
    37903778        IssmDouble epsilon[6];
    3791         IssmDouble viscousheating[NUMVERTICES]={0,0,0,0,0,0};
     3779        IssmDouble viscousheating[NUMVERTICES];
    37923780        IssmDouble thickness;
    3793         GaussPenta *gauss=NULL;
    3794 
    3795         /*Initialize Element vector*/
    3796         ElementVector* pe=new ElementVector(nodes,NUMVERTICES,this->parameters);
    37973781
    37983782        /*Retrieve all inputs and parameters*/
     
    38043788
    38053789        /*loop over vertices: */
    3806         gauss=new GaussPenta();
     3790        GaussPenta* gauss=new GaussPenta();
    38073791        for (int iv=0;iv<NUMVERTICES;iv++){
    38083792                gauss->GaussVertex(iv);
     
    41014085        IssmDouble D[3][3];
    41024086        IssmDouble K[3][3]={0.0};
    4103         Tria*      tria=NULL;
    41044087        GaussPenta *gauss=NULL;
    41054088
     
    43344317        IssmDouble D[3][3];
    43354318        IssmDouble K[3][3]={0.0};
    4336         Tria*      tria=NULL;
    43374319        GaussPenta *gauss=NULL;
    43384320
  • issm/trunk-jpl/src/c/classes/Loads/Pengrid.cpp

    r16164 r16166  
    441441
    442442        //   The penalty is stable if it doesn't change during to successive iterations.   
    443         const int  numnodes=1;
    444443        IssmDouble pressure;
    445444        IssmDouble temperature;
     
    623622
    624623        //   The penalty is stable if it doesn't change during two consecutive iterations.   
    625         const int  numnodes        = 1;
    626624        int        unstable        = 0;
    627625        int        new_active;
  • issm/trunk-jpl/src/c/classes/kriging/Quadtree.cpp

    r16164 r16166  
    205205        QuadtreeBox  *box  = NULL;
    206206        int           xi,yi;
    207         int           level,levelbin;
     207        int           levelbin;
    208208        int           index;
    209209        double        length,length2;
     
    212212        this->IntergerCoordinates(&xi,&yi,x,y);
    213213
    214         /*Initialize levels*/
    215         level    = 0;
     214        /*Initialize level*/
    216215        levelbin = (1L<<this->MaxDepth);// = 2^30
    217216
     
    221220        /*Find the smallest box where this point is located*/
    222221        while((box=*pbox) && (box->nbitems<0)){
    223 
    224                 levelbin>>=1; level+=1;
    225 
     222                levelbin>>=1;
    226223                pbox = &box->box[IJ(xi,yi,levelbin)];
    227224        }
  • issm/trunk-jpl/src/c/modules/ContourToMeshx/ContourToMeshx.cpp

    r15335 r16166  
    1313
    1414        /*Contour:*/
    15         double   value;
    16 
    17         /*threading: */
    18         ContourToMeshxThreadStruct gate;
    19         int num=1;
    20         #ifdef _MULTITHREADING_
    21         num=_NUMTHREADS_;
    22         #endif
     15        double value;
    2316
    2417        /*output: */
     
    2922
    3023        /*initialize thread parameters: */
    31         gate.contours=contours;
    32         gate.nods=nods;
    33         gate.edgevalue=edgevalue;
    34         gate.in_nod=in_nod;
    35         gate.x=x;
    36         gate.y=y;
     24        ContourToMeshxThreadStruct gate;
     25        gate.contours  = contours;
     26        gate.nods      = nods;
     27        gate.edgevalue = edgevalue;
     28        gate.in_nod    = in_nod;
     29        gate.x         = x;
     30        gate.y         = y;
    3731
    3832        /*launch the thread manager with ContourToMeshxt as a core: */
    39         LaunchThread(ContourToMeshxt,(void*)&gate,num);
     33        LaunchThread(ContourToMeshxt,(void*)&gate,_NUMTHREADS_);
    4034
    4135        /*Take care of the case where an element interpolation has been requested: */
     
    4337                for(int n=0;n<nel;n++){
    4438                        if ( (in_nod[ (int)*(index+3*n+0) -1] == 1) && (in_nod[ (int)*(index+3*n+1) -1] == 1) && (in_nod[ (int)*(index+3*n+2) -1] == 1) ){
    45                                 value=1; in_elem[n]=value;
     39                                value=1.; in_elem[n]=value;
    4640                        }
    4741                }
  • issm/trunk-jpl/src/c/modules/InterpFromGridToMeshx/InterpFromGridToMeshx.cpp

    r16164 r16166  
    2626        int     i;
    2727
    28         /*threading: */
    29         InterpFromGridToMeshxThreadStruct gate;
    30         int num=1;
    31         #ifdef _MULTITHREADING_
    32         num=_NUMTHREADS_;
    33         #endif
    34 
    3528        /*Some checks on arguments: */
    3629        if ((M<2) || (N<2) || (nods<=0)){
     
    5346                x=xNew<double>(N);
    5447                y=xNew<double>(M);
    55                 for (i=0;i<N;i++) x[i]=(x_in[i]+x_in[i+1])/2;
    56                 for (i=0;i<M;i++) y[i]=(y_in[i]+y_in[i+1])/2;
     48                for(i=0;i<N;i++) x[i]=(x_in[i]+x_in[i+1])/2.;
     49                for(i=0;i<M;i++) y[i]=(y_in[i]+y_in[i+1])/2.;
    5750                x_rows=x_rows-1;
    5851                y_rows=y_rows-1;
     
    6356                x=xNew<double>(N);
    6457                y=xNew<double>(M);
    65                 for (i=0;i<N;i++) x[i]=x_in[i];
    66                 for (i=0;i<M;i++) y[i]=y_in[i];
     58                for(i=0;i<N;i++) x[i]=x_in[i];
     59                for(i=0;i<M;i++) y[i]=y_in[i];
    6760        }
    6861        else{
     
    7164
    7265        /*initialize thread parameters: */
    73         gate.x_mesh=x_mesh;
    74         gate.y_mesh=y_mesh;
    75         gate.x_rows=x_rows;
    76         gate.y_rows=y_rows;
    77         gate.x=x;
    78         gate.y=y;
    79         gate.nods=nods;
    80         gate.data_mesh=data_mesh;
    81         gate.data=data;
    82         gate.default_value=default_value;
    83         gate.interp=interpenum;
    84         gate.M=M;
    85         gate.N=N;
     66        InterpFromGridToMeshxThreadStruct gate;
     67        gate.x_mesh        = x_mesh;
     68        gate.y_mesh        = y_mesh;
     69        gate.x_rows        = x_rows;
     70        gate.y_rows        = y_rows;
     71        gate.x             = x;
     72        gate.y             = y;
     73        gate.nods          = nods;
     74        gate.data_mesh     = data_mesh;
     75        gate.data          = data;
     76        gate.default_value = default_value;
     77        gate.interp        = interpenum;
     78        gate.M             = M;
     79        gate.N             = N;
    8680
    8781        /*launch the thread manager with InterpFromGridToMeshxt as a core: */
    88         LaunchThread(InterpFromGridToMeshxt,(void*)&gate,num);
     82        LaunchThread(InterpFromGridToMeshxt,(void*)&gate,_NUMTHREADS_);
    8983        _printf_("\r      interpolation progress: "<<fixed<<setw(6)<<setprecision(2)<<100.<<"%  \n");
    9084
  • issm/trunk-jpl/src/c/modules/InterpFromMesh2dx/InterpFromMesh2dx.cpp

    r15217 r16166  
    2525
    2626        /*contours: */
    27         double              *incontour     = NULL;
    28 
    29         /*threading: */
    30         InterpFromMesh2dxThreadStruct gate;
    31         int num=1;
    32 
    33         #ifdef _MULTITHREADING_
    34         num=_NUMTHREADS_;
    35         #endif
     27        double *incontour     = NULL;
    3628
    3729        /*some checks*/
     
    8476
    8577        /*initialize thread parameters: */
    86         gate.interpolation_type=interpolation_type;
    87         gate.debug=debug;
    88         gate.nels_data=nels_data;
    89         gate.index_data=index_data;
    90         gate.x_data=x_data;
    91         gate.y_data=y_data;
    92         gate.data=data;
    93         gate.xmin=xmin;
    94         gate.xmax=xmax;
    95         gate.ymin=ymin;
    96         gate.ymax=ymax;
    97         gate.nods_prime=nods_prime;
    98         gate.data_prime=data_prime;
    99         gate.x_prime=x_prime;
    100         gate.y_prime=y_prime;
    101         gate.default_values=default_values;
    102         gate.num_default_values=num_default_values;
    103         gate.incontour=incontour;
     78        InterpFromMesh2dxThreadStruct gate;
     79        gate.interpolation_type = interpolation_type;
     80        gate.debug              = debug;
     81        gate.nels_data          = nels_data;
     82        gate.index_data         = index_data;
     83        gate.x_data             = x_data;
     84        gate.y_data             = y_data;
     85        gate.data               = data;
     86        gate.xmin               = xmin;
     87        gate.xmax               = xmax;
     88        gate.ymin               = ymin;
     89        gate.ymax               = ymax;
     90        gate.nods_prime         = nods_prime;
     91        gate.data_prime         = data_prime;
     92        gate.x_prime            = x_prime;
     93        gate.y_prime            = y_prime;
     94        gate.default_values     = default_values;
     95        gate.num_default_values = num_default_values;
     96        gate.incontour          = incontour;
    10497
    10598        /*launch the thread manager with InterpFromGridToMeshxt as a core: */
    106         LaunchThread(InterpFromMesh2dxt,(void*)&gate,num);
     99        LaunchThread(InterpFromMesh2dxt,(void*)&gate,_NUMTHREADS_);
    107100
    108101        /*Assign output pointers:*/
  • issm/trunk-jpl/src/c/modules/Krigingx/Krigingx.cpp

    r15557 r16166  
    2828        /*threading: */
    2929        KrigingxThreadStruct gate;
    30         int num=1;
    31 #ifdef _MULTITHREADING_
    32         num=_NUMTHREADS_;
    33 #endif
     30        int num = _NUMTHREADS_;
    3431
    3532        /*Get Variogram from Options*/
  • issm/trunk-jpl/src/c/modules/ModelProcessorx/Stressbalance/CreateConstraintsStressbalance.cpp

    r16164 r16166  
    4040        /*Output*/
    4141        Constraints *constraints      = NULL;
    42         SpcStatic   *spcstatic        = NULL;
    4342
    4443        /*Fetch parameters: */
  • issm/trunk-jpl/src/c/modules/PointCloudFindNeighborsx/PointCloudFindNeighborsx.cpp

    r16164 r16166  
    1111
    1212        /*threading: */
    13         PointCloudFindNeighborsThreadStruct gate;
    14 
    15         #ifdef _MULTITHREADING_
    1613        int num=_NUMTHREADS_;
    17         #else
    18         int num=1;
    19         #endif
    20 
    2114        if(!multithread)num=1;
    2215
    2316        /*initialize thread parameters: */
    24         gate.x=x;
    25         gate.y=y;
    26         gate.nods=nods;
    27         gate.mindistance=mindistance;
    28         gate.flags=flags;
     17        PointCloudFindNeighborsThreadStruct gate;
     18        gate.x           = x;
     19        gate.y           = y;
     20        gate.nods        = nods;
     21        gate.mindistance = mindistance;
     22        gate.flags       = flags;
    2923
    3024        /*launch the thread manager with InterpFromGridToMeshxt as a core: */
Note: See TracChangeset for help on using the changeset viewer.