Changeset 16149


Ignore:
Timestamp:
09/17/13 13:51:02 (12 years ago)
Author:
Mathieu Morlighem
Message:

CHG: fixing cppcheck errors

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

Legend:

Unmodified
Added
Removed
  • issm/trunk-jpl/src/c/analyses/DakotaSpawnCore.cpp

    r15849 r16149  
    4141        char     **responses_descriptors    = NULL;      //these are our! there are only numresponsedescriptors of them, not d_numresponses!!!
    4242        int        numresponsedescriptors;
    43         char      *string                   = NULL;
    4443        int        solution_type;
    4544        bool       control_analysis         = false;
  • issm/trunk-jpl/src/c/analyses/ResetBoundaryConditions.cpp

    r15849 r16149  
    1818        femmodel->SetCurrentConfiguration(analysis_type);
    1919
    20         /*recover nodes: */
    21         nodes=femmodel->nodes;
    22 
    2320        /*retrieve boundary conditions from element inputs :*/
    2421        GetSolutionFromInputsx(&yg,femmodel);
  • issm/trunk-jpl/src/c/classes/Elements/Penta.cpp

    r16145 r16149  
    82208220
    82218221        /*Intermediaries */
    8222         int        i,j,approximation;
     8222        int        i,j;
    82238223        IssmDouble Jdet,viscosity,FSreconditioning,diameter,rigidity;
    82248224        IssmDouble xyz_list[NUMVERTICES][3];
    82258225        IssmDouble epsilon[6]; /* epsilon=[exx,eyy,ezz,exy,exz,eyz];*/
    8226         IssmDouble B[8][24];
    8227         IssmDouble B_prime[8][24];
    8228         IssmDouble B_stab[3][NUMVERTICES];
    8229         IssmDouble D_scalar,D_scalar_stab;
    8230         IssmDouble D[8][8]={0.0};
    8231         IssmDouble D_stab[3][3]={0.0};
    8232         IssmDouble Ke_temp[24][24]={0.0}; //for the six nodes
    8233         IssmDouble Ke_temp_stab[6][6]={0.0}; //for the six nodes
    82348226        GaussPenta *gauss=NULL;
    82358227
    82368228        /*Stabilization*/
    8237         bool       stabilization = true;
     8229        IssmDouble D_scalar;
    82388230        IssmDouble dbasis[3][6];
    82398231        IssmDouble dmu[3];
     
    83318323
    83328324        /*Intermediaries */
    8333         int        i,j,approximation;
     8325        int        i,approximation;
    83348326        IssmDouble Jdet,viscosity,FSreconditioning,D_scalar;
    83358327        IssmDouble xyz_list[NUMVERTICES][3];
     
    1094010932        int*         pdoflist=NULL;
    1094110933        IssmDouble   FSreconditioning;
    10942         GaussPenta  *gauss;
    1094310934
    1094410935        /*Fetch number of nodes and dof for this finite element*/
     
    1127611267        IssmDouble h[NUMVERTICES],s[NUMVERTICES],b[NUMVERTICES],r[NUMVERTICES];
    1127711268        IssmDouble melting[NUMVERTICES],phi[NUMVERTICES];
    11278         bool       grounded[NUMVERTICES],floating[NUMVERTICES];
    1127911269
    1128011270        if(!IsOnBed()) return;
     
    1130111291                                b[i]        = r[i];
    1130211292                                s[i]        = b[i]+h[i];
    11303                                 floating[i] = false;
    11304                                 grounded[i] = true;
    1130511293                        }
    1130611294                }
     
    1131411302                                        s[i]        = (1-density)*h[i];
    1131511303                                        b[i]        = -density*h[i];
    11316                                         floating[i] = true;
    11317                                         grounded[i] = false;
    1131811304                                }
    1131911305                                else if(migration_style==SoftMigrationEnum && phi_ungrounding[vertices[i]->Pid()]<0.){
    1132011306                                        s[i]        = (1-density)*h[i];
    1132111307                                        b[i]        = -density*h[i];
    11322                                         floating[i] = true;
    11323                                         grounded[i] = false;
    1132411308                                }
    1132511309                                else{
  • issm/trunk-jpl/src/c/classes/Elements/Tria.cpp

    r16148 r16149  
    17771777        switch(type){
    17781778        case VertexPIdEnum:
    1779                 for (int i=0;i<NUMVERTICES;i++){
     1779                values = xNew<IssmDouble>(NUMVERTICES);
     1780                for(int i=0;i<NUMVERTICES;i++){
    17801781                        values[i]=vector[this->vertices[i]->Pid()];
    17811782                }
     
    17871788                        this->inputs->AddInput(new TriaInput(name,values,P1Enum));
    17881789                }
    1789                 return;
    17901790
    17911791        case VertexSIdEnum:
    1792                 for (int i=0;i<NUMVERTICES;i++){
     1792                values = xNew<IssmDouble>(NUMVERTICES);
     1793                for(int i=0;i<NUMVERTICES;i++){
    17931794                        values[i]=vector[this->vertices[i]->Sid()];
    17941795                }
    17951796                /*update input*/
    1796                 if (name==MaterialsRheologyBbarEnum || name==MaterialsRheologyBEnum || name==MaterialsDamageDEnum || name==MaterialsDamageDbarEnum){
     1797                if(name==MaterialsRheologyBbarEnum || name==MaterialsRheologyBEnum || name==MaterialsDamageDEnum || name==MaterialsDamageDbarEnum){
    17971798                        material->inputs->AddInput(new TriaInput(name,values,P1Enum));
    17981799                }
     
    18001801                        this->inputs->AddInput(new TriaInput(name,values,P1Enum));
    18011802                }
    1802                 return;
    18031803
    18041804        case NodesEnum:
     
    18091809                GetDofList(&doflist,NoneApproximationEnum,GsetEnum);
    18101810
    1811                 /*Use the dof list to index into the vector: */
    18121811                for(int i=0;i<numnodes;i++){
    18131812                        values[i]=vector[doflist[i]];
    18141813                        if(xIsNan<IssmDouble>(values[i])) _error_("NaN found in vector");
    18151814                }
    1816 
    1817                 /*Add input to the element: */
    18181815                this->inputs->AddInput(new TriaInput(name,values,this->element_type));
    1819 
    1820                 /*Free ressources:*/
    1821                 xDelete<int>(doflist);
    1822                 return;
    18231816
    18241817        case NodeSIdEnum:
     
    18321825                        if(xIsNan<IssmDouble>(values[i])) _error_("NaN found in vector");
    18331826                }
    1834                 /*Add input to the element: */
    18351827                this->inputs->AddInput(new TriaInput(name,values,this->element_type));
    1836                 return;
    18371828
    18381829        default:
     
    76187609        IssmDouble melting[NUMVERTICES],phi[NUMVERTICES];;
    76197610        IssmDouble h[NUMVERTICES],s[NUMVERTICES],b[NUMVERTICES],r[NUMVERTICES];
    7620         bool       grounded[NUMVERTICES],floating[NUMVERTICES];
    76217611
    76227612        /*Recover info at the vertices: */
     
    76417631                                b[i]        = r[i];
    76427632                                s[i]        = b[i]+h[i];
    7643                                 floating[i] = false;
    7644                                 grounded[i] = true;
    76457633                        }
    76467634                }
     
    76547642                                        s[i]        = (1-density)*h[i];
    76557643                                        b[i]        = -density*h[i];
    7656                                         floating[i] = true;
    7657                                         grounded[i] = false;
    76587644                                }
    76597645                                else if(migration_style==SoftMigrationEnum && phi_ungrounding[vertices[i]->Pid()]<0.){
    76607646                                        s[i]        = (1-density)*h[i];
    76617647                                        b[i]        = -density*h[i];
    7662                                         floating[i] = true;
    7663                                         grounded[i] = false;
    76647648                                }
    76657649                                else{
  • issm/trunk-jpl/src/c/classes/ExternalResults/GenericExternalResult.h

    r15104 r16149  
    2222
    2323        private:
    24                 int id;
    25                 int enum_type;
     24                int        id;
     25                int        enum_type;
    2626                ResultType value;
    27                 int M;
    28                 int N;
    29                 int step;
     27                int        M;
     28                int        N;
     29                int        step;
    3030                IssmDouble time;
    3131
     
    6060                /*GenericExternalResult constructors and  destructors*/
    6161                GenericExternalResult(){ /*{{{*/
    62                         id  = 0;
     62                        id        = 0;
    6363                        enum_type = NoneEnum;
    64                         M=0;
    65                         N=0;
    66                         step=0;
    67                         time=0;
     64                        M         = 0;
     65                        N         = 0;
     66                        step      = 0;
     67                        time      = 0;
    6868                } /*}}}*/
    6969                GenericExternalResult(int in_id, int in_enum_type,ResultType in_values, int in_M,int in_N,int in_step,IssmDouble in_time){/*{{{*/
     70                        id        = 0;
     71                        enum_type = NoneEnum;
     72                        M         = 0;
     73                        N         = 0;
     74                        step      = 0;
     75                        time      = 0;
    7076                        _error_("template GenericExternalResult(int in_id, int in_enum_type,double* in_values, int in_M,int in_N,int in_step,IssmDouble in_time) not implemented for this ResultType\n");
    7177                }
    7278/*}}}*/
    7379                GenericExternalResult(int in_id, int in_enum_type,ResultType in_value,int in_step, IssmDouble in_time){ /*{{{*/
    74                         id=in_id;
    75                         enum_type=in_enum_type;
    76                         value=in_value;
    77                         step=in_step;
    78                         time=in_time;
     80                        id        = in_id;
     81                        enum_type = in_enum_type;
     82                        value     = in_value;
     83                        step      = in_step;
     84                        time      = in_time;
    7985                }
    8086                /*}}}*/
  • issm/trunk-jpl/src/c/classes/Inputs/Inputs.cpp

    r15737 r16149  
    396396/*}}}*/
    397397/*FUNCTION Inputs::AXPY{{{*/
    398 void  Inputs::AXPY(int MeshYEnum, IssmDouble scalar, int MeshXEnum){
     398void  Inputs::AXPY(int inputy_enum, IssmDouble scalar, int inputx_enum){
    399399
    400400        /*Find x and y inputs: */
    401         Input* xinput=dynamic_cast<Input*>(this->GetInput(MeshXEnum));
    402         Input* yinput=dynamic_cast<Input*>(this->GetInput(MeshYEnum));
     401        Input* xinput=dynamic_cast<Input*>(this->GetInput(inputx_enum));
     402        Input* yinput=dynamic_cast<Input*>(this->GetInput(inputy_enum));
    403403
    404404        /*some checks: */
    405         if(!xinput) _error_("input " << EnumToStringx(MeshXEnum) << " could not be found!");
    406         if(!yinput) _error_("input " << EnumToStringx(MeshYEnum) << " could not be found!");
     405        if(!xinput) _error_("input " << EnumToStringx(inputx_enum) << " could not be found!");
     406        if(!yinput) _error_("input " << EnumToStringx(inputy_enum) << " could not be found!");
    407407
    408408        /*Apply AXPY: */
  • issm/trunk-jpl/src/c/classes/Inputs/Inputs.h

    r15737 r16149  
    2222
    2323                /*numerics*/
    24                 int        AddInput(Input* in_input);
    25                 void       ChangeEnum(int enumtype,int new_enumtype);
    26                 void       ConstrainMin(int constrain_enum, IssmDouble minimum);
    27                 int        DeleteInput(int enum_type);
    28                 void       DuplicateInput(int original_enum,int new_enum);
    29                 Input*     GetInput(int enum_name);
    30                 Inputs*    SpawnTriaInputs(int position);
    31                 void       AXPY(int MeshYEnum, IssmDouble scalar, int MeshXEnum);
     24                int         AddInput(Input* in_input);
     25                void        ChangeEnum(int enumtype,int new_enumtype);
     26                void        ConstrainMin(int constrain_enum, IssmDouble minimum);
     27                int         DeleteInput(int enum_type);
     28                void        DuplicateInput(int original_enum,int new_enum);
     29                Input*      GetInput(int enum_name);
     30                Inputs*     SpawnTriaInputs(int position);
     31                void        AXPY(int inputy_enum, IssmDouble scalar, int inputx_enum);
    3232                IssmDouble  InfinityNorm(int enumtype);
    3333                IssmDouble  Max(int enumtype);
     
    3535                IssmDouble  Min(int enumtype);
    3636                IssmDouble  MinAbs(int enumtype);
    37                 void GetInputAverage(IssmDouble* pvalue, int enum_type);
    38                 void GetInputValue(bool* pvalue,int enum_type);
    39                 void GetInputValue(int* pvalue,int enum_type);
    40                 void GetInputValue(IssmDouble* pvalue,int enum_type);
    41                 void Configure(Parameters* parameters);
     37                void        GetInputAverage(IssmDouble* pvalue, int enum_type);
     38                void        GetInputValue(bool* pvalue,int enum_type);
     39                void        GetInputValue(int* pvalue,int enum_type);
     40                void        GetInputValue(IssmDouble* pvalue,int enum_type);
     41                void        Configure(Parameters* parameters);
    4242
    4343};
  • issm/trunk-jpl/src/c/classes/Params/DoubleMatParam.cpp

    r15128 r16149  
    5858        _printf_("   matrix size: " << this->M << "x" << this->N << "\n");
    5959        for(i=0;i<this->M;i++){
    60                 for(i=0;i<this->N;i++){
     60                for(j=0;j<this->N;j++){
    6161                        _printf_(i << " " << j << " " << *(this->value+N*i+j) << "\n");
    6262                }
  • issm/trunk-jpl/src/c/classes/Params/IntMatParam.cpp

    r15128 r16149  
    5858        _printf_("   matrix size: " << this->M << "x" << this->N << "\n");
    5959        for(i=0;i<this->M;i++){
    60                 for(i=0;i<this->N;i++){
     60                for(j=0;j<this->N;j++){
    6161                        _printf_("(" << i << "," << j << ") " << *(this->value+N*i+j) << "\n");
    6262                }
  • issm/trunk-jpl/src/c/modules/Shp2Expx/Shp2Expx.cpp

    r15164 r16149  
    1212        #ifdef _HAVE_SHAPELIB_ //only works if Shapelib library has been compiled in.
    1313
    14         return(Shp2Expx(filshp,filexp,
    15                                         0));
     14        return(Shp2Expx(filshp,filexp,0));
    1615
    1716        #else //ifdef _HAVE_SHAPELIB_
     
    2019}
    2120
    22 int Shp2Expx(char* filshp,char* filexp,
    23                          int sgn){
     21int Shp2Expx(char* filshp,char* filexp,int sgn){
    2422
    2523        #ifdef _HAVE_SHAPELIB_ //only works if Shapelib library has been compiled in.
    2624
    2725        double  cm,sp;
    28 
    29         if (sgn)
    30                 Xy2lldef(&cm,&sp,sgn);
    31 
    32         return(Shp2Expx(filshp,filexp,
    33                                         sgn,cm,sp));
     26        Xy2lldef(&cm,&sp,sgn);
     27
     28        return(Shp2Expx(filshp,filexp,sgn,cm,sp));
    3429
    3530        #else //ifdef _HAVE_SHAPELIB_
     
    3833}
    3934
    40 int Shp2Expx(char* filshp,char* filexp,
    41                          int sgn,double cm,double sp){
     35int Shp2Expx(char* filshp,char* filexp,int sgn,double cm,double sp){
    4236
    4337        #ifdef _HAVE_SHAPELIB_ //only works if Shapelib library has been compiled in.
  • issm/trunk-jpl/src/c/modules/Shp2Kmlx/Shp2Kmlx.cpp

    r15164 r16149  
    88#include "../../kml/kmlobjects.h"
    99
    10 int Shp2Kmlx(char* filshp,char* filkml,
    11                          int sgn){
     10int Shp2Kmlx(char* filshp,char* filkml,int sgn){
    1211
    1312        #ifdef _HAVE_SHAPELIB_ //only works if Shapelib library has been compiled in.
    1413
    1514        double  cm,sp;
    16 
    17         if (sgn)
    18                 Xy2lldef(&cm,&sp,sgn);
    19 
    20         return(Shp2Kmlx(filshp,filkml,
    21                                         sgn,cm,sp));
     15        Xy2lldef(&cm,&sp,sgn);
     16
     17        return(Shp2Kmlx(filshp,filkml,sgn,cm,sp));
    2218
    2319        #else //ifdef _HAVE_SHAPELIB_
     
    2622}
    2723
    28 int Shp2Kmlx(char* filshp,char* filkml,
    29                          int sgn,double cm,double sp){
     24int Shp2Kmlx(char* filshp,char* filkml,int sgn,double cm,double sp){
    3025
    3126        #ifdef _HAVE_SHAPELIB_ //only works if Shapelib library has been compiled in.
     
    10398        pshapm=xNew<double*>(nshape);
    10499
    105 /*  loop over the list of shapes  */
    106 
    107         for( i = 0; i < nEntities; i++ )
    108         {
    109 //      int     j;
     100        /* loop over the list of shapes  */
     101        for(i=0;i<nEntities;i++ ){
    110102                SHPObject   *psShape;
    111103
  • issm/trunk-jpl/src/c/toolkits/mumps/MpiDenseMumpsSolve.cpp

    r16132 r16149  
    33 */
    44
    5 /*Header files: {{{*/
     5/*Header files: */
    66#ifdef HAVE_CONFIG_H
    77        #include <config.h>
     
    2121
    2222/*Mumps header files: */
    23 #include "dmumps_c.h"
    24 /*}}}*/
    25 
    26 void MumpsInit(DMUMPS_STRUC_C &theMumpsStruc) {
     23#include <dmumps_c.h>
     24
     25void MumpsInit(DMUMPS_STRUC_C &theMumpsStruc){
    2726        theMumpsStruc.par          = 1; 
    2827        theMumpsStruc.sym          = 0;
     
    7170}
    7271
    73 void MumpsSolve(int n,
    74                 int nnz,
    75                 int local_nnz,
    76                 int* irn_loc,
    77                 int* jcn_loc,
    78                 IssmPDouble *a_loc,
    79                 IssmPDouble *rhs,
    80                 Parameters* parameters=0 /*unused here*/) {
    81         /*Initialize mumps: {{{*/
     72void MumpsSolve(int n,int nnz,int local_nnz,int* irn_loc,int* jcn_loc, IssmPDouble *a_loc, IssmPDouble *rhs, Parameters* parameters=0 /*unused here*/){
     73        /*Initialize mumps*/
    8274        DMUMPS_STRUC_C theMumpsStruc;
    8375        MumpsInit(theMumpsStruc);
    8476        MumpsSettings(theMumpsStruc);
    85         /*}}}*/
    86         // now setup the rest of theMumpsStruc
     77
     78        /*now setup the rest of theMumpsStruc */
    8779        theMumpsStruc.n=n;
    8880        theMumpsStruc.nz=nnz;
     
    9486        theMumpsStruc.nrhs=1;
    9587        theMumpsStruc.lrhs=1;
    96         /*Solve system: {{{*/
     88
     89        /*Solve system*/
    9790        MumpsAnalyze(theMumpsStruc);
    9891        MumpsFactorize(theMumpsStruc);
    9992        MumpsBacksubstitute(theMumpsStruc);
    100         /*}}}*/
    10193        MumpsFinalize(theMumpsStruc);
    10294}
     
    116108void MpiDenseMumpsSolve( /*output: */ IssmDouble* uf, int uf_M, int uf_m, /*matrix input: */ IssmDouble* Kff, int Kff_M, int Kff_N, int Kff_m, /*right hand side vector: */ IssmDouble* pf, int pf_M, int pf_m, Parameters* parameters){ /*{{{*/
    117109
    118         /*Variables: {{{*/
    119 
    120         ISSM_MPI_Comm   comm;
    121         int        my_rank;
    122         int        num_procs;
    123         int        i;
    124         int        j;
    125         int         nnz       ,local_nnz;
    126         int        *irn_loc = NULL;
    127         int        *jcn_loc = NULL;
    128         IssmDouble *a_loc   = NULL;
    129         int         count;
    130         int         lower_row;
    131         int         upper_row;
    132         IssmDouble* rhs=NULL;
    133         int*        recvcounts=NULL;
    134         int*        displs=NULL;
    135         /*}}}*/
    136         /*Communicator info:{{{ */
    137         my_rank=IssmComm::GetRank();
    138         num_procs=IssmComm::GetSize();
    139         comm=IssmComm::GetComm();
    140         /*}}}*/
    141         /*First, some checks:{{{ */
     110        /*Variables*/
     111        ISSM_MPI_Comm  comm;
     112        int            my_rank;
     113        int            num_procs;
     114        int            i,j;
     115        int            nnz,local_nnz;
     116        int           *irn_loc    = NULL;
     117        int           *jcn_loc    = NULL;
     118        IssmDouble    *a_loc      = NULL;
     119        int            count;
     120        int            lower_row;
     121        int            upper_row;
     122        IssmDouble    *rhs        = NULL;
     123        int           *recvcounts = NULL;
     124        int           *displs     = NULL;
     125
     126        /*Communicator info */
     127        my_rank   = IssmComm::GetRank();
     128        num_procs = IssmComm::GetSize();
     129        comm      = IssmComm::GetComm();
     130
     131        /*First, some checks*/
    142132        if (Kff_M!=Kff_N)_error_("stiffness matrix Kff should be square");
    143133        if (uf_M!=Kff_M | uf_M!=pf_M)_error_("solution vector should be the same size as stiffness matrix Kff and load vector pf");
    144134        if (uf_m!=Kff_m | uf_m!=pf_m)_error_("solution vector should be locally the same size as stiffness matrix Kff and load vector pf");
    145         /*}}}*/
    146         /*Initialize matrix:{{{ */
    147 
     135
     136        /*Initialize matrix */
    148137        /*figure out number of non-zero entries: */
    149138        local_nnz=0;
     
    192181        ISSM_MPI_Gatherv(pf, pf_m, ISSM_MPI_DOUBLE, rhs, recvcounts, displs, ISSM_MPI_DOUBLE,0,comm);
    193182
    194         MumpsSolve(Kff_M,
    195                    nnz,
    196                    local_nnz,
    197                    irn_loc,
    198                    jcn_loc,
    199                    a_loc,
    200                    rhs,
    201                    parameters);
    202 
    203         /*Now scatter from cpu 0 to all other cpus: {{{*/
     183        MumpsSolve(Kff_M,nnz,local_nnz,irn_loc,jcn_loc,a_loc,rhs,parameters);
     184
     185        /*Now scatter from cpu 0 to all other cpus*/
    204186        ISSM_MPI_Scatterv( rhs, recvcounts, displs, ISSM_MPI_DOUBLE, uf, uf_m, ISSM_MPI_DOUBLE, 0, comm);
    205187
    206         /*}}}*/
    207         /*Cleanup: {{{*/
     188        /*Cleanup*/
    208189        xDelete<int>(irn_loc);
    209190        xDelete<int>(jcn_loc);
     
    212193        xDelete<int>(recvcounts);
    213194        xDelete<int>(displs);
    214         /*}}}*/
    215195} /*}}}*/
    216196
     
    245225}
    246226
    247 void MumpsSolve(int n,
    248                 int nnz,
    249                 int local_nnz,
    250                 int* irn_loc,
    251                 int* jcn_loc,
    252                 IssmDouble *a_loc,
    253                 IssmDouble *rhs,
    254                 Parameters* parameters) {
     227void MumpsSolve(int n,int nnz,int local_nnz,int* irn_loc,int* jcn_loc,IssmDouble *a_loc,IssmDouble *rhs,Parameters* parameters){
    255228  int packedDimsSparseArrLength=1+1+1+local_nnz+local_nnz;
    256229  int *packedDimsSparseArr=xNew<int>(packedDimsSparseArrLength);
  • issm/trunk-jpl/src/c/toolkits/petsc/objects/PetscSolver.cpp

    r15839 r16149  
    170170        IssmDouble*     df_local=NULL;
    171171        int         df_local_size;
    172         int         i;
    173172
    174173        int*     pressure_indices=NULL;
     
    188187                pressure_num=0;
    189188                velocity_num=0;
    190                 for(i=0;i<df_local_size;i++){
     189                for(int i=0;i<df_local_size;i++){
    191190                        if (df_local[i]==PressureEnum)pressure_num++;
    192191                        else velocity_num++;
     
    199198                pressure_count=0;
    200199                velocity_count=0;
    201                 for(i=0;i<df_local_size;i++){
     200                for(int i=0;i<df_local_size;i++){
    202201                        if (df_local[i]==PressureEnum){
    203202                                pressure_indices[pressure_count]=start+i;
Note: See TracChangeset for help on using the changeset viewer.