Changeset 9374


Ignore:
Timestamp:
08/23/11 08:55:48 (14 years ago)
Author:
Mathieu Morlighem
Message:

some fixing with new iomodel interface

Location:
issm/trunk/src/c
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk/src/c/modules/ModelProcessorx/CreateElementsVerticesAndMaterials.cpp

    r9370 r9374  
    2020        int numberofelements;
    2121        int numberofvertices;
     22        bool control_analysis;
    2223
    2324        /*DataSets: */
     
    3031        iomodel->constants->FindParam(&numberofelements,NumberOfElementsEnum);
    3132        iomodel->constants->FindParam(&numberofvertices,NumberOfVerticesEnum);
     33        iomodel->constants->FindParam(&control_analysis,ControlAnalysisEnum);
    3234
    3335        /*Did we already create the elements? : */
     
    4345       
    4446        /*Fetch data needed: */
    45         iomodel->FetchData(9,ElementsEnum,ElementconnectivityEnum,UpperelementsEnum,LowerelementsEnum,
    46                                 RheologyBEnum,RheologyNEnum,ControlTypeEnum,CmMinEnum,CmMaxEnum);
     47        iomodel->FetchData(4,ElementsEnum,ElementconnectivityEnum,RheologyBEnum,RheologyNEnum);
     48        if(dim==3)          iomodel->FetchData(2,UpperelementsEnum,LowerelementsEnum);
     49        if(control_analysis)iomodel->FetchData(3,ControlTypeEnum,CmMinEnum,CmMaxEnum);
    4750       
    4851        /*Create elements and materials: */
    4952        for (i=0;i<numberofelements;i++){
    50 
    5153                if(iomodel->my_elements[i]){
    5254
  • issm/trunk/src/c/modules/ModelProcessorx/DiagnosticHoriz/CreateLoadsDiagnosticHoriz.cpp

    r9370 r9374  
    3939        double *nodeonstokes   = NULL;
    4040        double *nodeonicesheet = NULL;
    41         double *elements       = NULL;
    42         double *spcvx          = NULL;
    43         double *spcvy          = NULL;
    44         double *spcvz          = NULL;
    4541        double *vertices_type  = NULL;
    4642        double *penalties      = NULL;
     
    5248        iomodel->constants->FindParam(&isstokes,IsstokesEnum);
    5349        iomodel->constants->FindParam(&ismacayealpattyn,IsmacayealpattynEnum);
     50        iomodel->constants->FindParam(&numrifts,NumRiftsEnum);
     51        iomodel->constants->FindParam(&numrifts,NumRiftsEnum);
    5452
    5553        /*Recover pointer: */
     
    136134        iomodel->FetchData(&nodeonicesheet,NULL,NULL,NodeOnIceSheetEnum);
    137135        iomodel->FetchData(&nodeonstokes,NULL,NULL,NodeOnStokesEnum);
    138         iomodel->FetchData(&elements,NULL,NULL,ElementsEnum);
    139         iomodel->FetchData(&spcvx,NULL,NULL,SpcvxEnum);
    140         iomodel->FetchData(&spcvy,NULL,NULL,SpcvyEnum);
    141         iomodel->FetchData(&spcvz,NULL,NULL,SpcvzEnum);
    142136        iomodel->FetchData(&vertices_type,NULL,NULL,VerticesTypeEnum);
     137        iomodel->FetchData(1,ElementsEnum);
    143138        CreateSingleNodeToElementConnectivity(iomodel);
    144139       
    145140        for (i=0;i<numberofvertices;i++){
    146                
    147141                if(iomodel->my_vertices[i]==1 && iomodel->singlenodetoelementconnectivity[i]!=0){
    148142
     
    153147                                count++;
    154148                        }
    155                 } //if((iomodel->my_vertices[i]==1))
     149                }
    156150        }
    157 
    158151        xfree((void**)&nodeonbed);
    159152        xfree((void**)&nodeonstokes);
    160153        xfree((void**)&nodeonicesheet);
    161         xfree((void**)&elements);
    162         xfree((void**)&spcvx);
    163         xfree((void**)&spcvy);
    164         xfree((void**)&spcvz);
    165154        xfree((void**)&vertices_type);
     155        iomodel->DeleteData(1,ElementsEnum);
    166156
    167157        /*Create Penpair for penalties: */
     
    189179
    190180        /*Create Riffront loads for rifts: */
    191         iomodel->FetchData(&riftinfo,&numrifts,NULL,RiftinfoEnum);
    192         iomodel->FetchData(&thickness,NULL,NULL,ThicknessEnum);
    193         iomodel->FetchData(&bed,NULL,NULL,BedEnum);
    194         iomodel->FetchData(&surface,NULL,NULL,SurfaceEnum);
    195         iomodel->FetchData(&nodeoniceshelf,NULL,NULL,NodeOnIceShelfEnum);
    196 
    197         for(i=0;i<numrifts;i++){
    198                 if(iomodel->my_elements[(int)*(riftinfo+RIFTINFOSIZE*i+2)-1]){
    199                         loads->AddObject(new Riftfront(iomodel->loadcounter+count+1,i,iomodel,DiagnosticHorizAnalysisEnum));
    200                         count++;
     181        if(numrifts){
     182                iomodel->FetchData(5,RiftinfoEnum,ThicknessEnum,BedEnum,SurfaceEnum,NodeOnIceShelfEnum);
     183                for(i=0;i<numrifts;i++){
     184                        if(iomodel->my_elements[(int)(iomodel->f(RiftinfoEnum)[RIFTINFOSIZE*i+2])-1]){
     185                                loads->AddObject(new Riftfront(iomodel->loadcounter+count+1,i,iomodel,DiagnosticHorizAnalysisEnum));
     186                                count++;
     187                        }
    201188                }
     189                iomodel->DeleteData(5,RiftinfoEnum,ThicknessEnum,BedEnum,SurfaceEnum,NodeOnIceShelfEnum);
    202190        }
    203                                
    204         /*free ressources: */
    205         xfree((void**)&riftinfo);
    206         xfree((void**)&thickness);
    207         xfree((void**)&bed);
    208         xfree((void**)&surface);
    209         xfree((void**)&nodeoniceshelf);
    210191
    211192        /*Assign output pointer: */
  • issm/trunk/src/c/modules/ModelProcessorx/DiagnosticHoriz/CreateNodesDiagnosticHoriz.cpp

    r9370 r9374  
    2525
    2626        /*Fetch parameters: */
     27        printf("-------------- file: CreateNodesDiagnosticHoriz.cpp line: %i\n",__LINE__);
    2728        iomodel->constants->FindParam(&numberofvertices,NumberOfVerticesEnum);
     29        printf("-------------- file: CreateNodesDiagnosticHoriz.cpp line: %i\n",__LINE__);
    2830        iomodel->constants->FindParam(&isstokes,IsstokesEnum);
     31        printf("-------------- file: CreateNodesDiagnosticHoriz.cpp line: %i\n",__LINE__);
    2932        iomodel->constants->FindParam(&ismacayealpattyn,IsmacayealpattynEnum);
     33        printf("-------------- file: CreateNodesDiagnosticHoriz.cpp line: %i\n",__LINE__);
    3034
    3135        /*Recover pointer: */
     
    4246
    4347        /*Continuous Galerkin partition of nodes: */
     48        printf("-------------- file: CreateNodesDiagnosticHoriz.cpp line: %i\n",__LINE__);
    4449        NodesPartitioning(&iomodel->my_nodes,iomodel->my_elements,iomodel->my_vertices,iomodel,continuous_galerkin);
     50        printf("-------------- file: CreateNodesDiagnosticHoriz.cpp line: %i\n",__LINE__);
    4551
    4652        /*Create nodes: */
    4753        iomodel->FetchData(10,NodeOnBedEnum,NodeOnSurfaceEnum,NodeOnHutterEnum,NodeOnMacayealEnum,NodeOnStokesEnum,
    4854                                NodeOnIceSheetEnum,NodeOnIceShelfEnum,NodeOnWaterEnum,VerticesTypeEnum,DiagnosticRefEnum);
     55        printf("-------------- file: CreateNodesDiagnosticHoriz.cpp line: %i\n",__LINE__);
    4956       
    5057        for (i=0;i<numberofvertices;i++){
  • issm/trunk/src/c/modules/ModelProcessorx/ElementsAndVerticesPartitioning.cpp

    r9362 r9374  
    8686
    8787        /*Deal with rifts, they have to be included into one partition only, not several: */
    88         iomodel->FetchData(&riftinfo,&numrifts,NULL,RiftinfoEnum);
    89 
    90         for(i=0;i<numrifts;i++){
    91                 el1=(int)*(riftinfo+RIFTINFOSIZE*i+2)-1; //matlab indexing to c indexing
    92                 el2=(int)*(riftinfo+RIFTINFOSIZE*i+3)-1; //matlab indexing to c indexing
    93                 epart[el2]=epart[el1]; //ensures that this pair of elements will be in the same partition, as well as the corresponding vertices;
     88        if(numrifts){
     89                iomodel->FetchData(&riftinfo,&numrifts,NULL,RiftinfoEnum);
     90                for(i=0;i<numrifts;i++){
     91                        el1=(int)*(riftinfo+RIFTINFOSIZE*i+2)-1; //matlab indexing to c indexing
     92                        el2=(int)*(riftinfo+RIFTINFOSIZE*i+3)-1; //matlab indexing to c indexing
     93                        epart[el2]=epart[el1]; //ensures that this pair of elements will be in the same partition, as well as the corresponding vertices;
     94                }
     95                xfree((void**)&riftinfo);
    9496        }
    95 
    96         /*Free rifts: */
    97         xfree((void**)&riftinfo);
    9897
    9998        /*Used later on: */
  • issm/trunk/src/c/objects/Elements/Penta.cpp

    r9362 r9374  
    51635163
    51645164        double  yts;
    5165         int     control_analysis;
     5165        bool    control_analysis;
    51665166        int     num_control_type;
    51675167        int     num_cm_responses;
     
    51835183        }
    51845184
    5185        
    51865185        /*Control Inputs*/
    51875186        if (control_analysis && iomodel->f(ControlTypeEnum)){
  • issm/trunk/src/c/objects/Elements/Tria.cpp

    r9362 r9374  
    32763276        int    num_cm_responses;
    32773277   
    3278 
    3279         /*Checks if debuging*/
    3280         /*{{{2*/
    3281         _assert_(iomodel->f(ElementEnum));
    3282         /*}}}*/
    3283 
    32843278        /*Get parameters: */
    32853279        iomodel->constants->FindParam(&control_analysis,ControlAnalysisEnum);
  • issm/trunk/src/c/objects/IoModel.cpp

    r9370 r9374  
    9292        fid=this->SetFilePointerToData(&code,NULL,data_enum);
    9393
    94         if(code!=1)_error_("%s%s","IoModel::FetchData expecting a boolean for enum ",EnumToStringx(data_enum));
     94        if(code!=1)_error_("expecting a boolean for enum %s",EnumToStringx(data_enum));
    9595       
    9696        /*We have to read a boolean from disk. */
     
    120120        fid=this->SetFilePointerToData(&code,NULL,data_enum);
    121121       
    122         if(code!=2)_error_("%s%s","IoModel::FetchData expecting an integer for enum ",EnumToStringx(data_enum));
     122        if(code!=2)_error_("expecting an integer for enum %s",EnumToStringx(data_enum));
    123123       
    124124        /*We have to read a integer from disk. First read the dimensions of the integer, then the integer: */
     
    149149        fid=this->SetFilePointerToData(&code,NULL,data_enum);
    150150       
    151         if(code!=3)_error_("%s%s","IoModel::FetchData expecting a double for enum ",EnumToStringx(data_enum));
     151        if(code!=3)_error_("expecting a double for enum %s",EnumToStringx(data_enum));
    152152       
    153153        /*We have to read a scalar from disk. First read the dimensions of the scalar, then the scalar: */
     
    177177        fid=this->SetFilePointerToData(&code,NULL,data_enum);
    178178       
    179         if(code!=4)_error_("%s%s","IoModel::FetchData expecting a string for enum ",EnumToStringx(data_enum));
     179        if(code!=4)_error_("expecting a string for enum %s",EnumToStringx(data_enum));
    180180       
    181181        /*Now fetch: */
     
    227227        fid=this->SetFilePointerToData(&code,&vector_type,data_enum);
    228228
    229         if((code!=5) && (code!=6) && (code!=7))_error_("%s%s","IoModel::FetchData expecting a double, integer or boolean matrix for enum ",EnumToStringx(data_enum));
     229        if((code!=5) && (code!=6) && (code!=7))_error_("expecting a double, integer or boolean matrix for enum %s",EnumToStringx(data_enum));
    230230       
    231231        /*Now fetch: */
     
    290290        int vector_type=0;
    291291       
    292        
    293        
    294292        /*Set file pointer to beginning of the data: */
    295293        fid=this->SetFilePointerToData(&code,&vector_type,data_enum);
    296 
    297         if((code!=5) && (code!=6) && (code!=7))_error_("%s%s","IoModel::FetchData expecting a double, integer or boolean matrix for enum ",EnumToStringx(data_enum));
     294        if((code!=5) && (code!=6) && (code!=7))_error_("expecting a double, integer or boolean matrix for enum %s",EnumToStringx(data_enum));
    298295       
    299296        /*Now fetch: */
     
    304301                if(fread(&M,sizeof(int),1,fid)!=1) _error_("could not read number of rows for matrix ");
    305302        }
    306 
    307303        MPI_Bcast(&M,1,MPI_INT,0,MPI_COMM_WORLD);
    308304
     
    320316                        if(fread(matrix,M*N*sizeof(double),1,fid)!=1) _error_("could not read matrix ");
    321317                }
    322                
    323318                MPI_Bcast(matrix,M*N,MPI_DOUBLE,0,MPI_COMM_WORLD);
    324319        }
     
    328323        if (pM)*pM=M;
    329324        if (pN)*pN=N;
    330 
    331325}
    332326/*}}}*/
     
    351345        fid=this->SetFilePointerToData(&code,NULL,data_enum);
    352346       
    353         if(code!=9)_error_("%s%s","IoModel::FetchData expecting a string array for enum ",EnumToStringx(data_enum));
     347        if(code!=9)_error_("expecting a string array for enum %s",EnumToStringx(data_enum));
    354348       
    355349        /*We have to read a bunch of strings from disk. First read the number of strings, and allocate: */
     
    410404
    411405        /*intermediary: */
    412         int M,N;
    413         double* matrix=NULL;
    414        
    415        
    416         int   code;
     406        int     M, N;
     407        double *matrix = NULL;
     408        int     code;
    417409       
    418410        /*Set file pointer to beginning of the data: */
    419411        fid=this->SetFilePointerToData(&code,NULL,data_enum);
    420        
    421         if(code!=8)_error_("%s%s","IoModel::FetchData expecting a double mat  array for enum ",EnumToStringx(data_enum));
     412        if(code!=8)_error_("expecting a double mat array for enum %s",EnumToStringx(data_enum));
    422413       
    423414        /*Now fetch: */
     
    496487                dataenum=va_arg(ap, int); _assert_(this->data->Exist(dataenum)==false);
    497488                this->FetchData(&matrix,&M,&N,dataenum);
     489                if(M*N==0){
     490                        _error_("Cannot add %s to Iomodel->data because the matrix found is empty",EnumToStringx(dataenum));
     491                }
     492
    498493
    499494                /*Add to this->data: */
  • issm/trunk/src/c/objects/Materials/Matice.cpp

    r9362 r9374  
    656656
    657657        int    dim;
    658         int    control_analysis;
     658        bool   control_analysis;
    659659        int    num_control_type;
    660660
     
    663663        iomodel->constants->FindParam(&control_analysis,ControlAnalysisEnum);
    664664        iomodel->constants->FindParam(&num_control_type,NumControlTypeEnum);
    665 
    666665
    667666        /*if 2d*/
Note: See TracChangeset for help on using the changeset viewer.