Changeset 1834


Ignore:
Timestamp:
08/24/09 17:53:59 (15 years ago)
Author:
Eric.Larour
Message:

Brachning back from issm.controlstatic, by hand

Location:
issm/trunk/src/c/ModelProcessorx
Files:
18 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk/src/c/ModelProcessorx/DiagnosticStokes/CreateConstraintsDiagnosticStokes.cpp

    r586 r1834  
    1111#include "../../objects/objects.h"
    1212#include "../../shared/shared.h"
    13 #include "../Model.h"
     13#include "../IoModel.h"
    1414
    1515
    16 void    CreateConstraintsDiagnosticStokes(DataSet** pconstraints, Model* model,ConstDataHandle model_handle){
     16void    CreateConstraintsDiagnosticStokes(DataSet** pconstraints, IoModel* iomodel,ConstDataHandle iomodel_handle){
    1717
    1818        int i;
     
    3434
    3535        /*Now, is the flag ishutter on? otherwise, do nothing: */
    36         if (!model->isstokes)goto cleanup_and_return;
     36        if (!iomodel->isstokes)goto cleanup_and_return;
    3737
    3838        /*Fetch data: */
    39         ModelFetchData((void**)&gridonstokes,NULL,NULL,model_handle,"gridonstokes","Matrix","Mat");
     39        IoModelFetchData((void**)&gridonstokes,NULL,NULL,iomodel_handle,"gridonstokes","Matrix","Mat");
    4040
    4141        count=0;
    4242        /*Create spcs from x,y,z, as well as the spc values on those spcs: */
    43         for (i=0;i<model->numberofnodes;i++){
     43        for (i=0;i<iomodel->numberofnodes;i++){
    4444        #ifdef _PARALLEL_
    4545        /*keep only this partition's nodes:*/
    46         if((model->my_grids[i]==1)){
     46        if((iomodel->my_grids[i]==1)){
    4747        #endif
    4848
  • issm/trunk/src/c/ModelProcessorx/DiagnosticStokes/CreateElementsNodesAndMaterialsDiagnosticStokes.cpp

    r1651 r1834  
    1212#include "../../shared/shared.h"
    1313#include "../../MeshPartitionx/MeshPartitionx.h"
    14 #include "../Model.h"
    15 
    16 
    17 void    CreateElementsNodesAndMaterialsDiagnosticStokes(DataSet** pelements,DataSet** pnodes, DataSet** pmaterials, Model* model,ConstDataHandle model_handle){
     14#include "../IoModel.h"
     15
     16
     17void    CreateElementsNodesAndMaterialsDiagnosticStokes(DataSet** pelements,DataSet** pnodes, DataSet** pmaterials, IoModel* iomodel,ConstDataHandle iomodel_handle){
    1818
    1919
     
    124124
    125125        /*Now, is the flag ishutter on? otherwise, do nothing: */
    126         if (!model->isstokes)goto cleanup_and_return;
     126        if (!iomodel->isstokes)goto cleanup_and_return;
    127127
    128128        /*Width of elements: */
    129         if(strcmp(model->meshtype,"2d")==0){
     129        if(strcmp(iomodel->meshtype,"2d")==0){
    130130                elements_width=3; //tria elements
    131131        }
     
    137137        #ifdef _PARALLEL_
    138138        /*Determine parallel partitioning of elements: we use Metis for now. First load the data, then partition*/
    139         if(strcmp(model->meshtype,"2d")==0){
     139        if(strcmp(iomodel->meshtype,"2d")==0){
    140140                /*load elements: */
    141                 ModelFetchData((void**)&model->elements,NULL,NULL,model_handle,"elements","Matrix","Mat");
     141                IoModelFetchData((void**)&iomodel->elements,NULL,NULL,iomodel_handle,"elements","Matrix","Mat");
    142142        }
    143143        else{
    144144                /*load elements2d: */
    145                 ModelFetchData((void**)&model->elements2d,NULL,NULL,model_handle,"elements2d","Matrix","Mat");
    146         }
    147 
    148 
    149         MeshPartitionx(&epart, &npart,model->numberofelements,model->numberofnodes,model->elements, model->numberofelements2d,model->numberofnodes2d,model->elements2d,model->numlayers,elements_width, model->meshtype,num_procs);
     145                IoModelFetchData((void**)&iomodel->elements2d,NULL,NULL,iomodel_handle,"elements2d","Matrix","Mat");
     146        }
     147
     148
     149        MeshPartitionx(&epart, &npart,iomodel->numberofelements,iomodel->numberofnodes,iomodel->elements, iomodel->numberofelements2d,iomodel->numberofnodes2d,iomodel->elements2d,iomodel->numlayers,elements_width, iomodel->meshtype,num_procs);
    150150
    151151        /*Free elements and elements2d: */
    152         xfree((void**)&model->elements);
    153         xfree((void**)&model->elements2d);
     152        xfree((void**)&iomodel->elements);
     153        xfree((void**)&iomodel->elements2d);
    154154
    155155        /*Used later on: */
    156         my_grids=(int*)xcalloc(model->numberofnodes,sizeof(int));
     156        my_grids=(int*)xcalloc(iomodel->numberofnodes,sizeof(int));
    157157        #endif
    158158
     
    161161
    162162        /*2d mesh: */
    163         if (strcmp(model->meshtype,"2d")==0){
     163        if (strcmp(iomodel->meshtype,"2d")==0){
    164164
    165165                throw ErrorException(__FUNCT__," stokes elements only supported in 3d!");
     
    169169
    170170                /*Fetch data needed: */
    171                 ModelFetchData((void**)&model->elements,NULL,NULL,model_handle,"elements","Matrix","Mat");
    172                 ModelFetchData((void**)&model->thickness,NULL,NULL,model_handle,"thickness","Matrix","Mat");
    173                 ModelFetchData((void**)&model->surface,NULL,NULL,model_handle,"surface","Matrix","Mat");
    174                 ModelFetchData((void**)&model->bed,NULL,NULL,model_handle,"bed","Matrix","Mat");
    175                 ModelFetchData((void**)&model->drag,NULL,NULL,model_handle,"drag","Matrix","Mat");
    176                 ModelFetchData((void**)&model->p,NULL,NULL,model_handle,"p","Matrix","Mat");
    177                 ModelFetchData((void**)&model->q,NULL,NULL,model_handle,"q","Matrix","Mat");
    178                 ModelFetchData((void**)&model->elementoniceshelf,NULL,NULL,model_handle,"elementoniceshelf","Matrix","Mat");
    179                 ModelFetchData((void**)&model->elementonbed,NULL,NULL,model_handle,"elementonbed","Matrix","Mat");
    180                 ModelFetchData((void**)&model->elementonsurface,NULL,NULL,model_handle,"elementonsurface","Matrix","Mat");
    181                 ModelFetchData((void**)&model->elements_type,NULL,NULL,model_handle,"elements_type","Matrix","Mat");
    182                 ModelFetchData((void**)&model->B,NULL,NULL,model_handle,"B","Matrix","Mat");
    183                 ModelFetchData((void**)&model->n,NULL,NULL,model_handle,"n","Matrix","Mat");
    184                 ModelFetchData((void**)&model->accumulation,NULL,NULL,model_handle,"accumulation","Matrix","Mat");
    185                 ModelFetchData((void**)&model->melting,NULL,NULL,model_handle,"melting","Matrix","Mat");
    186                 ModelFetchData((void**)&model->elementonwater,NULL,NULL,model_handle,"elementonwater","Matrix","Mat");
    187        
    188                 for (i=0;i<model->numberofelements;i++){
     171                IoModelFetchData((void**)&iomodel->elements,NULL,NULL,iomodel_handle,"elements","Matrix","Mat");
     172                IoModelFetchData((void**)&iomodel->thickness,NULL,NULL,iomodel_handle,"thickness","Matrix","Mat");
     173                IoModelFetchData((void**)&iomodel->surface,NULL,NULL,iomodel_handle,"surface","Matrix","Mat");
     174                IoModelFetchData((void**)&iomodel->bed,NULL,NULL,iomodel_handle,"bed","Matrix","Mat");
     175                IoModelFetchData((void**)&iomodel->drag,NULL,NULL,iomodel_handle,"drag","Matrix","Mat");
     176                IoModelFetchData((void**)&iomodel->p,NULL,NULL,iomodel_handle,"p","Matrix","Mat");
     177                IoModelFetchData((void**)&iomodel->q,NULL,NULL,iomodel_handle,"q","Matrix","Mat");
     178                IoModelFetchData((void**)&iomodel->elementoniceshelf,NULL,NULL,iomodel_handle,"elementoniceshelf","Matrix","Mat");
     179                IoModelFetchData((void**)&iomodel->elementonbed,NULL,NULL,iomodel_handle,"elementonbed","Matrix","Mat");
     180                IoModelFetchData((void**)&iomodel->elementonsurface,NULL,NULL,iomodel_handle,"elementonsurface","Matrix","Mat");
     181                IoModelFetchData((void**)&iomodel->elements_type,NULL,NULL,iomodel_handle,"elements_type","Matrix","Mat");
     182                IoModelFetchData((void**)&iomodel->B,NULL,NULL,iomodel_handle,"B","Matrix","Mat");
     183                IoModelFetchData((void**)&iomodel->n,NULL,NULL,iomodel_handle,"n","Matrix","Mat");
     184                IoModelFetchData((void**)&iomodel->accumulation,NULL,NULL,iomodel_handle,"accumulation","Matrix","Mat");
     185                IoModelFetchData((void**)&iomodel->melting,NULL,NULL,iomodel_handle,"melting","Matrix","Mat");
     186                IoModelFetchData((void**)&iomodel->elementonwater,NULL,NULL,iomodel_handle,"elementonwater","Matrix","Mat");
     187       
     188                for (i=0;i<iomodel->numberofelements;i++){
    189189                #ifdef _PARALLEL_
    190190                /*We are using our element partition to decide which elements will be created on this node: */
     
    196196                        penta_id=i+1; //matlab indexing.
    197197                        penta_mid=i+1; //refers to the corresponding material property card
    198                         penta_mparid=model->numberofelements+1;//refers to the corresponding parmat property card
     198                        penta_mparid=iomodel->numberofelements+1;//refers to the corresponding parmat property card
    199199
    200200                        /*vertices,thickness,surface,bed and drag: */
    201201                        for(j=0;j<6;j++){
    202                                 penta_g[j]=(int)*(model->elements+elements_width*i+j);
    203                                 penta_h[j]=*(model->thickness+    ((int)*(model->elements+elements_width*i+j)-1));
    204                                 penta_s[j]=*(model->surface+    ((int)*(model->elements+elements_width*i+j)-1));
    205                                 penta_b[j]=*(model->bed+    ((int)*(model->elements+elements_width*i+j)-1));
    206                                 penta_k[j]=*(model->drag+        ((int)*(model->elements+elements_width*i+j)-1));
    207                                 penta_melting[j]=*(model->melting+        ((int)*(model->elements+elements_width*i+j)-1));
    208                                 penta_accumulation[j]=*(model->accumulation+        ((int)*(model->elements+elements_width*i+j)-1));
     202                                penta_g[j]=(int)*(iomodel->elements+elements_width*i+j);
     203                                penta_h[j]=*(iomodel->thickness+    ((int)*(iomodel->elements+elements_width*i+j)-1));
     204                                penta_s[j]=*(iomodel->surface+    ((int)*(iomodel->elements+elements_width*i+j)-1));
     205                                penta_b[j]=*(iomodel->bed+    ((int)*(iomodel->elements+elements_width*i+j)-1));
     206                                penta_k[j]=*(iomodel->drag+        ((int)*(iomodel->elements+elements_width*i+j)-1));
     207                                penta_melting[j]=*(iomodel->melting+        ((int)*(iomodel->elements+elements_width*i+j)-1));
     208                                penta_accumulation[j]=*(iomodel->accumulation+        ((int)*(iomodel->elements+elements_width*i+j)-1));
    209209                        }
    210210
    211211                        /*basal drag:*/
    212                         penta_friction_type=(int)model->drag_type;
    213        
    214                         penta_p=model->p[i];
    215                         penta_q=model->q[i];
     212                        penta_friction_type=(int)iomodel->drag_type;
     213       
     214                        penta_p=iomodel->p[i];
     215                        penta_q=iomodel->q[i];
    216216
    217217                        /*diverse: */
    218                         penta_shelf=(int)*(model->elementoniceshelf+i);
    219                         penta_onbed=(int)*(model->elementonbed+i);
    220                         penta_onsurface=(int)*(model->elementonsurface+i);
    221                         penta_meanvel=model->meanvel;
    222                         penta_epsvel=model->epsvel;
    223                         penta_onwater=(bool)*(model->elementonwater+i);
     218                        penta_shelf=(int)*(iomodel->elementoniceshelf+i);
     219                        penta_onbed=(int)*(iomodel->elementonbed+i);
     220                        penta_onsurface=(int)*(iomodel->elementonsurface+i);
     221                        penta_meanvel=iomodel->meanvel;
     222                        penta_epsvel=iomodel->epsvel;
     223                        penta_onwater=(bool)*(iomodel->elementonwater+i);
    224224       
    225225                        /*viscosity_overshoot*/
    226                         penta_viscosity_overshoot=model->viscosity_overshoot;
     226                        penta_viscosity_overshoot=iomodel->viscosity_overshoot;
    227227
    228228                        /*stokesreconditioning: */
    229                         penta_stokesreconditioning=model->stokesreconditioning;
    230 
    231                        
    232                         if (*(model->elements_type+2*i+1)==StokesFormulationEnum()){
     229                        penta_stokesreconditioning=iomodel->stokesreconditioning;
     230
     231                       
     232                        if (*(iomodel->elements_type+2*i+1)==StokesFormulationEnum()){
    233233                       
    234234                                /*Create Penta using its constructor:*/
     
    248248                        B_avg=0;
    249249                        for(j=0;j<6;j++){
    250                                 B_avg+=*(model->B+((int)*(model->elements+elements_width*i+j)-1));
     250                                B_avg+=*(iomodel->B+((int)*(iomodel->elements+elements_width*i+j)-1));
    251251                        }
    252252                        B_avg=B_avg/6;
    253253                        matice_B= B_avg;
    254                         matice_n=(double)*(model->n+i);
    255                        
    256                         if (*(model->elements_type+2*i+1)==StokesFormulationEnum()){
     254                        matice_n=(double)*(iomodel->n+i);
     255                       
     256                        if (*(iomodel->elements_type+2*i+1)==StokesFormulationEnum()){
    257257       
    258258                                /*Create matice using its constructor:*/
     
    268268                         into the grid coordinates. If we start plugging 1 into my_grids for each index[n][i] (i=0:2), then my_grids
    269269                         will hold which grids belong to this partition*/
    270                         my_grids[(int)*(model->elements+elements_width*i+0)-1]=1;
    271                         my_grids[(int)*(model->elements+elements_width*i+1)-1]=1;
    272                         my_grids[(int)*(model->elements+elements_width*i+2)-1]=1;
    273                         my_grids[(int)*(model->elements+elements_width*i+3)-1]=1;
    274                         my_grids[(int)*(model->elements+elements_width*i+4)-1]=1;
    275                         my_grids[(int)*(model->elements+elements_width*i+5)-1]=1;
     270                        my_grids[(int)*(iomodel->elements+elements_width*i+0)-1]=1;
     271                        my_grids[(int)*(iomodel->elements+elements_width*i+1)-1]=1;
     272                        my_grids[(int)*(iomodel->elements+elements_width*i+2)-1]=1;
     273                        my_grids[(int)*(iomodel->elements+elements_width*i+3)-1]=1;
     274                        my_grids[(int)*(iomodel->elements+elements_width*i+4)-1]=1;
     275                        my_grids[(int)*(iomodel->elements+elements_width*i+5)-1]=1;
    276276                        #endif
    277277
     
    283283
    284284                /*Free data: */
    285                 xfree((void**)&model->elements);
    286                 xfree((void**)&model->thickness);
    287                 xfree((void**)&model->surface);
    288                 xfree((void**)&model->bed);
    289                 xfree((void**)&model->drag);
    290                 xfree((void**)&model->p);
    291                 xfree((void**)&model->q);
    292                 xfree((void**)&model->elementoniceshelf);
    293                 xfree((void**)&model->elementonbed);
    294                 xfree((void**)&model->elementonsurface);
    295                 xfree((void**)&model->elements_type);
    296                 xfree((void**)&model->n);
    297                 xfree((void**)&model->B);
    298                 xfree((void**)&model->accumulation);
    299                 xfree((void**)&model->melting);
    300                 xfree((void**)&model->elementonwater);
     285                xfree((void**)&iomodel->elements);
     286                xfree((void**)&iomodel->thickness);
     287                xfree((void**)&iomodel->surface);
     288                xfree((void**)&iomodel->bed);
     289                xfree((void**)&iomodel->drag);
     290                xfree((void**)&iomodel->p);
     291                xfree((void**)&iomodel->q);
     292                xfree((void**)&iomodel->elementoniceshelf);
     293                xfree((void**)&iomodel->elementonbed);
     294                xfree((void**)&iomodel->elementonsurface);
     295                xfree((void**)&iomodel->elements_type);
     296                xfree((void**)&iomodel->n);
     297                xfree((void**)&iomodel->B);
     298                xfree((void**)&iomodel->accumulation);
     299                xfree((void**)&iomodel->melting);
     300                xfree((void**)&iomodel->elementonwater);
    301301
    302302        } //if (strcmp(meshtype,"2d")==0)
    303303
    304304        /*Add one constant material property to materials: */
    305         matpar_mid=model->numberofelements+1; //put it at the end of the materials
    306         matpar_g=model->g;
    307         matpar_rho_ice=model->rho_ice;
    308         matpar_rho_water=model->rho_water;
    309         matpar_thermalconductivity=model->thermalconductivity;
    310         matpar_heatcapacity=model->heatcapacity;
    311         matpar_latentheat=model->latentheat;
    312         matpar_beta=model->beta;
    313         matpar_meltingpoint=model->meltingpoint;
    314         matpar_mixed_layer_capacity=model->mixed_layer_capacity;
    315         matpar_thermal_exchange_velocity=model->thermal_exchange_velocity;
     305        matpar_mid=iomodel->numberofelements+1; //put it at the end of the materials
     306        matpar_g=iomodel->g;
     307        matpar_rho_ice=iomodel->rho_ice;
     308        matpar_rho_water=iomodel->rho_water;
     309        matpar_thermalconductivity=iomodel->thermalconductivity;
     310        matpar_heatcapacity=iomodel->heatcapacity;
     311        matpar_latentheat=iomodel->latentheat;
     312        matpar_beta=iomodel->beta;
     313        matpar_meltingpoint=iomodel->meltingpoint;
     314        matpar_mixed_layer_capacity=iomodel->mixed_layer_capacity;
     315        matpar_thermal_exchange_velocity=iomodel->thermal_exchange_velocity;
    316316
    317317        /*Create matpar object using its constructor: */
     
    326326                /*From the element partitioning, we can determine which grids are on the inside of this cpu's
    327327                 *element partition, and which are on its border with other nodes:*/
    328                 gridborder=NewVec(model->numberofnodes);
    329 
    330                 for (i=0;i<model->numberofnodes;i++){
     328                gridborder=NewVec(iomodel->numberofnodes);
     329
     330                for (i=0;i<iomodel->numberofnodes;i++){
    331331                        if(my_grids[i])VecSetValue(gridborder,i,1,ADD_VALUES);
    332332                }
     
    342342                #ifdef _DEBUG_
    343343                if(my_rank==0){
    344                         for (i=0;i<model->numberofnodes;i++){
     344                        for (i=0;i<iomodel->numberofnodes;i++){
    345345                                printf("Grid id %i Border grid %lf\n",i+1,my_bordergrids[i]);
    346346                        }
     
    350350
    351351        /*Partition penalties in 3d: */
    352         if(strcmp(model->meshtype,"3d")==0){
     352        if(strcmp(iomodel->meshtype,"3d")==0){
    353353       
    354354                /*Get penalties: */
    355                 ModelFetchData((void**)&model->penalties,&model->numpenalties,NULL,model_handle,"penalties","Matrix","Mat");
    356 
    357                 if(model->numpenalties){
    358 
    359                         model->penaltypartitioning=(int*)xmalloc(model->numpenalties*sizeof(int));
     355                IoModelFetchData((void**)&iomodel->penalties,&iomodel->numpenalties,NULL,iomodel_handle,"penalties","Matrix","Mat");
     356
     357                if(iomodel->numpenalties){
     358
     359                        iomodel->penaltypartitioning=(int*)xmalloc(iomodel->numpenalties*sizeof(int));
    360360                        #ifdef _SERIAL_
    361                         for(i=0;i<model->numpenalties;i++)model->penaltypartitioning[i]=1;
     361                        for(i=0;i<iomodel->numpenalties;i++)iomodel->penaltypartitioning[i]=1;
    362362                        #else
    363                         for(i=0;i<model->numpenalties;i++)model->penaltypartitioning[i]=-1;
    364 
    365                         for(i=0;i<model->numpenalties;i++){
    366                                 first_grid_index=(int)(*(model->penalties+i*model->numlayers+0)-1);
     363                        for(i=0;i<iomodel->numpenalties;i++)iomodel->penaltypartitioning[i]=-1;
     364
     365                        for(i=0;i<iomodel->numpenalties;i++){
     366                                first_grid_index=(int)(*(iomodel->penalties+i*iomodel->numlayers+0)-1);
    367367                                if((my_grids[first_grid_index]==1) && (my_bordergrids[first_grid_index]<=1.0) ) { //this grid belongs to this node's internal partition  grids
    368368                                        /*All grids that are being penalised belong to this node's internal grid partition.:*/
    369                                         model->penaltypartitioning[i]=1;
     369                                        iomodel->penaltypartitioning[i]=1;
    370370                                }
    371371                                if(my_bordergrids[first_grid_index]>1.0) { //this grid belongs to a partition border
    372                                         model->penaltypartitioning[i]=0;
     372                                        iomodel->penaltypartitioning[i]=0;
    373373                                }
    374374                        }
     
    377377
    378378                /*Free penalties: */
    379                 xfree((void**)&model->penalties);
     379                xfree((void**)&iomodel->penalties);
    380380        }
    381381
     
    388388               
    389389        /*First fetch data: */
    390         if (strcmp(model->meshtype,"3d")==0){
    391                 ModelFetchData((void**)&model->deadgrids,NULL,NULL,model_handle,"deadgrids","Matrix","Mat");
    392                 ModelFetchData((void**)&model->uppernodes,NULL,NULL,model_handle,"uppergrids","Matrix","Mat");
    393         }
    394         ModelFetchData((void**)&model->x,NULL,NULL,model_handle,"x","Matrix","Mat");
    395         ModelFetchData((void**)&model->y,NULL,NULL,model_handle,"y","Matrix","Mat");
    396         ModelFetchData((void**)&model->z,NULL,NULL,model_handle,"z","Matrix","Mat");
    397         ModelFetchData((void**)&model->thickness,NULL,NULL,model_handle,"thickness","Matrix","Mat");
    398         ModelFetchData((void**)&model->bed,NULL,NULL,model_handle,"bed","Matrix","Mat");
    399         ModelFetchData((void**)&model->gridonbed,NULL,NULL,model_handle,"gridonbed","Matrix","Mat");
    400         ModelFetchData((void**)&model->gridonsurface,NULL,NULL,model_handle,"gridonsurface","Matrix","Mat");
    401         ModelFetchData((void**)&model->gridonicesheet,NULL,NULL,model_handle,"gridonicesheet","Matrix","Mat");
    402         ModelFetchData((void**)&model->gridoniceshelf,NULL,NULL,model_handle,"gridoniceshelf","Matrix","Mat");
    403         ModelFetchData((void**)&model->gridonstokes,NULL,NULL,model_handle,"gridonstokes","Matrix","Mat");
    404         ModelFetchData((void**)&model->borderstokes,NULL,NULL,model_handle,"borderstokes","Matrix","Mat");
     390        if (strcmp(iomodel->meshtype,"3d")==0){
     391                IoModelFetchData((void**)&iomodel->deadgrids,NULL,NULL,iomodel_handle,"deadgrids","Matrix","Mat");
     392                IoModelFetchData((void**)&iomodel->uppernodes,NULL,NULL,iomodel_handle,"uppergrids","Matrix","Mat");
     393        }
     394        IoModelFetchData((void**)&iomodel->x,NULL,NULL,iomodel_handle,"x","Matrix","Mat");
     395        IoModelFetchData((void**)&iomodel->y,NULL,NULL,iomodel_handle,"y","Matrix","Mat");
     396        IoModelFetchData((void**)&iomodel->z,NULL,NULL,iomodel_handle,"z","Matrix","Mat");
     397        IoModelFetchData((void**)&iomodel->thickness,NULL,NULL,iomodel_handle,"thickness","Matrix","Mat");
     398        IoModelFetchData((void**)&iomodel->bed,NULL,NULL,iomodel_handle,"bed","Matrix","Mat");
     399        IoModelFetchData((void**)&iomodel->gridonbed,NULL,NULL,iomodel_handle,"gridonbed","Matrix","Mat");
     400        IoModelFetchData((void**)&iomodel->gridonsurface,NULL,NULL,iomodel_handle,"gridonsurface","Matrix","Mat");
     401        IoModelFetchData((void**)&iomodel->gridonicesheet,NULL,NULL,iomodel_handle,"gridonicesheet","Matrix","Mat");
     402        IoModelFetchData((void**)&iomodel->gridoniceshelf,NULL,NULL,iomodel_handle,"gridoniceshelf","Matrix","Mat");
     403        IoModelFetchData((void**)&iomodel->gridonstokes,NULL,NULL,iomodel_handle,"gridonstokes","Matrix","Mat");
     404        IoModelFetchData((void**)&iomodel->borderstokes,NULL,NULL,iomodel_handle,"borderstokes","Matrix","Mat");
    405405
    406406
    407407        /*Get number of dofs per node: */
    408         DistributeNumDofs(&node_numdofs,model->analysis_type,model->sub_analysis_type);
    409 
    410         for (i=0;i<model->numberofnodes;i++){
     408        DistributeNumDofs(&node_numdofs,iomodel->analysis_type,iomodel->sub_analysis_type);
     409
     410        for (i=0;i<iomodel->numberofnodes;i++){
    411411        #ifdef _PARALLEL_
    412412        /*keep only this partition's nodes:*/
     
    429429                #endif
    430430
    431                 node_x[0]=model->x[i];
    432                 node_x[1]=model->y[i];
    433                 node_x[2]=model->z[i];
    434                 node_sigma=(model->z[i]-model->bed[i])/(model->thickness[i]);
    435                
    436                 node_onbed=(int)model->gridonbed[i];
    437                 node_onsurface=(int)model->gridonsurface[i];   
    438                 node_onshelf=(int)model->gridoniceshelf[i];     
    439                 node_onsheet=(int)model->gridonicesheet[i];     
    440 
    441                 if (strcmp(model->meshtype,"3d")==0){
    442                         if (isnan(model->uppernodes[i])){
     431                node_x[0]=iomodel->x[i];
     432                node_x[1]=iomodel->y[i];
     433                node_x[2]=iomodel->z[i];
     434                node_sigma=(iomodel->z[i]-iomodel->bed[i])/(iomodel->thickness[i]);
     435               
     436                node_onbed=(int)iomodel->gridonbed[i];
     437                node_onsurface=(int)iomodel->gridonsurface[i]; 
     438                node_onshelf=(int)iomodel->gridoniceshelf[i];   
     439                node_onsheet=(int)iomodel->gridonicesheet[i];   
     440
     441                if (strcmp(iomodel->meshtype,"3d")==0){
     442                        if (isnan(iomodel->uppernodes[i])){
    443443                                node_upper_node_id=node_id;  //nodes on surface do not have upper nodes, only themselves.
    444444                        }
    445445                        else{
    446                                 node_upper_node_id=(int)model->uppernodes[i];
     446                                node_upper_node_id=(int)iomodel->uppernodes[i];
    447447                        }
    448448                }
     
    457457                /*set single point constraints.: */
    458458                /*On a 3d mesh, in stokes formualtions, only stokes grids are free, the others are frozen: */
    459                 if (model->borderstokes[i]){
     459                if (iomodel->borderstokes[i]){
    460460                        //freeze everything except pressure
    461461                        node->FreezeDof(1);
     
    463463                        node->FreezeDof(3);
    464464                }
    465                 else if (model->gridonstokes[i]==0){
     465                else if (iomodel->gridonstokes[i]==0){
    466466                        for(k=1;k<=node_numdofs;k++){
    467467                                node->FreezeDof(k);
     
    485485
    486486        /*Clean fetched data: */
    487         xfree((void**)&model->deadgrids);
    488         xfree((void**)&model->x);
    489         xfree((void**)&model->y);
    490         xfree((void**)&model->z);
    491         xfree((void**)&model->thickness);
    492         xfree((void**)&model->bed);
    493         xfree((void**)&model->gridonbed);
    494         xfree((void**)&model->gridonsurface);
    495         xfree((void**)&model->uppernodes);
    496         xfree((void**)&model->gridonstokes);
    497         xfree((void**)&model->borderstokes);
    498         xfree((void**)&model->gridonicesheet);
    499         xfree((void**)&model->gridoniceshelf);
    500 
    501 
    502         /*Keep partitioning information into model*/
    503         model->epart=epart;
    504         model->my_grids=my_grids;
    505         model->my_bordergrids=my_bordergrids;
     487        xfree((void**)&iomodel->deadgrids);
     488        xfree((void**)&iomodel->x);
     489        xfree((void**)&iomodel->y);
     490        xfree((void**)&iomodel->z);
     491        xfree((void**)&iomodel->thickness);
     492        xfree((void**)&iomodel->bed);
     493        xfree((void**)&iomodel->gridonbed);
     494        xfree((void**)&iomodel->gridonsurface);
     495        xfree((void**)&iomodel->uppernodes);
     496        xfree((void**)&iomodel->gridonstokes);
     497        xfree((void**)&iomodel->borderstokes);
     498        xfree((void**)&iomodel->gridonicesheet);
     499        xfree((void**)&iomodel->gridoniceshelf);
     500
     501
     502        /*Keep partitioning information into iomodel*/
     503        iomodel->epart=epart;
     504        iomodel->my_grids=my_grids;
     505        iomodel->my_bordergrids=my_bordergrids;
    506506
    507507        /*Free ressources:*/
  • issm/trunk/src/c/ModelProcessorx/DiagnosticStokes/CreateLoadsDiagnosticStokes.cpp

    r1767 r1834  
    1111#include "../../shared/shared.h"
    1212#include "../../include/macros.h"
    13 #include "../Model.h"
     13#include "../IoModel.h"
    1414
    1515
    16 void    CreateLoadsDiagnosticStokes(DataSet** ploads, Model* model,ConstDataHandle model_handle){
     16void    CreateLoadsDiagnosticStokes(DataSet** ploads, IoModel* iomodel,ConstDataHandle iomodel_handle){
    1717
    1818        int i,j,counter;
     
    5858
    5959        /*Now, is the flag ishutter on? otherwise, do nothing: */
    60         if (!model->isstokes)goto cleanup_and_return;
     60        if (!iomodel->isstokes)goto cleanup_and_return;
    6161
    6262        /*Create pressure loads as boundary conditions. Pay attention to the partitioning if we are running in parallel (the grids
    6363         * referenced by a certain load must belong to the cluster node): */
    64         ModelFetchData((void**)&model->pressureload_stokes,&numberofpressureloads_stokes,NULL,model_handle,"pressureload_stokes","Matrix","Mat");
    65         ModelFetchData((void**)&model->elements_type,NULL,NULL,model_handle,"elements_type","Matrix","Mat");
    66         ModelFetchData((void**)&model->thickness,NULL,NULL,model_handle,"thickness","Matrix","Mat");
    67         ModelFetchData((void**)&model->bed,NULL,NULL,model_handle,"bed","Matrix","Mat");
     64        IoModelFetchData((void**)&iomodel->pressureload_stokes,&numberofpressureloads_stokes,NULL,iomodel_handle,"pressureload_stokes","Matrix","Mat");
     65        IoModelFetchData((void**)&iomodel->elements_type,NULL,NULL,iomodel_handle,"elements_type","Matrix","Mat");
     66        IoModelFetchData((void**)&iomodel->thickness,NULL,NULL,iomodel_handle,"thickness","Matrix","Mat");
     67        IoModelFetchData((void**)&iomodel->bed,NULL,NULL,iomodel_handle,"bed","Matrix","Mat");
    6868
    6969        count=0;
     
    7474                segment_width=5;
    7575
    76                 element=(int)(*(model->pressureload_stokes+segment_width*i+segment_width-1)-1); //element is in the last column
     76                element=(int)(*(iomodel->pressureload_stokes+segment_width*i+segment_width-1)-1); //element is in the last column
    7777
    7878                #ifdef _PARALLEL_
    79                 if (model->epart[element]!=my_rank){
     79                if (iomodel->epart[element]!=my_rank){
    8080                        /*This load does not belong to this cluster node, as it references an element
    8181                         *that does not belong to this node's partition. Drop this 'i':*/
     
    8484                #endif
    8585       
    86                 icefront_mparid=model->numberofelements+1; //matlab indexing
     86                icefront_mparid=iomodel->numberofelements+1; //matlab indexing
    8787                icefront_sid=count+1; //matlab indexing
    88                 icefront_eid=(int)*(model->pressureload_stokes+segment_width*i+segment_width-1); //matlab indexing
     88                icefront_eid=(int)*(iomodel->pressureload_stokes+segment_width*i+segment_width-1); //matlab indexing
    8989                icefront_element_type=PentaEnum();
    9090
    91                 i1=(int)*(model->pressureload_stokes+segment_width*i+0);
    92                 i2=(int)*(model->pressureload_stokes+segment_width*i+1);
    93                 i3=(int)*(model->pressureload_stokes+segment_width*i+2);
    94                 i4=(int)*(model->pressureload_stokes+segment_width*i+3);
     91                i1=(int)*(iomodel->pressureload_stokes+segment_width*i+0);
     92                i2=(int)*(iomodel->pressureload_stokes+segment_width*i+1);
     93                i3=(int)*(iomodel->pressureload_stokes+segment_width*i+2);
     94                i4=(int)*(iomodel->pressureload_stokes+segment_width*i+3);
    9595       
    9696                icefront_node_ids[0]=i1;
     
    9999                icefront_node_ids[3]=i4;
    100100       
    101                 icefront_h[0]=model->thickness[i1-1];
    102                 icefront_h[1]=model->thickness[i2-1];
    103                 icefront_h[2]=model->thickness[i3-1];
    104                 icefront_h[3]=model->thickness[i4-1];
     101                icefront_h[0]=iomodel->thickness[i1-1];
     102                icefront_h[1]=iomodel->thickness[i2-1];
     103                icefront_h[2]=iomodel->thickness[i3-1];
     104                icefront_h[3]=iomodel->thickness[i4-1];
    105105
    106                 icefront_b[0]=model->bed[i1-1];
    107                 icefront_b[1]=model->bed[i2-1];
    108                 icefront_b[2]=model->bed[i3-1];
    109                 icefront_b[3]=model->bed[i4-1];
     106                icefront_b[0]=iomodel->bed[i1-1];
     107                icefront_b[1]=iomodel->bed[i2-1];
     108                icefront_b[2]=iomodel->bed[i3-1];
     109                icefront_b[3]=iomodel->bed[i4-1];
    110110       
    111111                icefront = new Icefront(icefront_type,icefront_sid,icefront_mparid,icefront_eid,icefront_element_type,icefront_node_ids,icefront_h,icefront_b);
     
    116116        }
    117117        /*Free data: */
    118         xfree((void**)&model->pressureload_stokes);
    119         xfree((void**)&model->elements_type);
    120         xfree((void**)&model->thickness);
    121         xfree((void**)&model->bed);
     118        xfree((void**)&iomodel->pressureload_stokes);
     119        xfree((void**)&iomodel->elements_type);
     120        xfree((void**)&iomodel->thickness);
     121        xfree((void**)&iomodel->bed);
    122122
    123123
     
    126126        //create penalties for grids on the base of icesheet. We must have wb=ub*db/dx+vb*db/dy
    127127
    128         ModelFetchData((void**)&model->gridonbed,NULL,NULL,model_handle,"gridonbed","Matrix","Mat");
    129         ModelFetchData((void**)&model->gridonicesheet,NULL,NULL,model_handle,"gridonicesheet","Matrix","Mat");
    130         ModelFetchData((void**)&model->gridonstokes,NULL,NULL,model_handle,"gridonstokes","Matrix","Mat");
     128        IoModelFetchData((void**)&iomodel->gridonbed,NULL,NULL,iomodel_handle,"gridonbed","Matrix","Mat");
     129        IoModelFetchData((void**)&iomodel->gridonicesheet,NULL,NULL,iomodel_handle,"gridonicesheet","Matrix","Mat");
     130        IoModelFetchData((void**)&iomodel->gridonstokes,NULL,NULL,iomodel_handle,"gridonstokes","Matrix","Mat");
    131131       
    132         for (i=0;i<model->numberofnodes;i++){
     132        for (i=0;i<iomodel->numberofnodes;i++){
    133133        #ifdef _PARALLEL_
    134134        /*keep only this partition's nodes:*/
    135         if((model->my_grids[i]==1)){
     135        if((iomodel->my_grids[i]==1)){
    136136        #endif
    137137
    138                 if ((model->gridonbed[i]) && (model->gridonicesheet[i]) && (model->gridonstokes[i])){
     138                if ((iomodel->gridonbed[i]) && (iomodel->gridonicesheet[i]) && (iomodel->gridonstokes[i])){
    139139
    140140                        pengrid_id=count+1; //matlab indexing
    141141                        pengrid_node_id=i+1;
    142142                        pengrid_dof=1;
    143                         pengrid_penalty_offset=model->penalty_offset;
    144                         pengrid_mparid=model->numberofelements+1;//refers to the corresponding parmat property card
     143                        pengrid_penalty_offset=iomodel->penalty_offset;
     144                        pengrid_mparid=iomodel->numberofelements+1;//refers to the corresponding parmat property card
    145145
    146146                        pengrid= new Pengrid(pengrid_id, pengrid_node_id,pengrid_mparid,pengrid_dof, pengrid_active, pengrid_penalty_offset,pengrid_thermal_steadystate);
     
    150150                }
    151151        #ifdef _PARALLEL_
    152         } //if((model->my_grids[i]==1))
     152        } //if((iomodel->my_grids[i]==1))
    153153        #endif
    154154        }
     
    156156
    157157
    158         xfree((void**)&model->gridonbed);
    159         xfree((void**)&model->gridonstokes);
    160         xfree((void**)&model->gridonicesheet);
     158        xfree((void**)&iomodel->gridonbed);
     159        xfree((void**)&iomodel->gridonstokes);
     160        xfree((void**)&iomodel->gridonicesheet);
    161161
    162162        /*All our datasets are already order by ids. Set presort flag so that later on, when sorting is requested on these
  • issm/trunk/src/c/ModelProcessorx/DiagnosticVert/CreateConstraintsDiagnosticVert.cpp

    r300 r1834  
    1111#include "../../objects/objects.h"
    1212#include "../../shared/shared.h"
    13 #include "../Model.h"
     13#include "../IoModel.h"
    1414
    1515
    16 void    CreateConstraintsDiagnosticVert(DataSet** pconstraints, Model* model,ConstDataHandle model_handle){
     16void    CreateConstraintsDiagnosticVert(DataSet** pconstraints, IoModel* iomodel,ConstDataHandle iomodel_handle){
    1717
    1818
     
    2222        constraints = new DataSet(ConstraintsEnum());
    2323
    24         /*Now, is the model running in 3d? : */
    25         if (strcmp(model->meshtype,"2d")==0)goto cleanup_and_return;
     24        /*Now, is the iomodel running in 3d? : */
     25        if (strcmp(iomodel->meshtype,"2d")==0)goto cleanup_and_return;
    2626       
    2727        cleanup_and_return:     
  • issm/trunk/src/c/ModelProcessorx/DiagnosticVert/CreateElementsNodesAndMaterialsDiagnosticVert.cpp

    r1648 r1834  
    1212#include "../../shared/shared.h"
    1313#include "../../MeshPartitionx/MeshPartitionx.h"
    14 #include "../Model.h"
    15 
    16 
    17 void    CreateElementsNodesAndMaterialsDiagnosticVert(DataSet** pelements,DataSet** pnodes, DataSet** pmaterials, Model* model,ConstDataHandle model_handle){
     14#include "../IoModel.h"
     15
     16
     17void    CreateElementsNodesAndMaterialsDiagnosticVert(DataSet** pelements,DataSet** pnodes, DataSet** pmaterials, IoModel* iomodel,ConstDataHandle iomodel_handle){
    1818
    1919
     
    132132        materials = new DataSet(MaterialsEnum());
    133133
    134         /*Now, is the model running in 3d? : */
    135         if (strcmp(model->meshtype,"2d")==0)goto cleanup_and_return;
     134        /*Now, is the iomodel running in 3d? : */
     135        if (strcmp(iomodel->meshtype,"2d")==0)goto cleanup_and_return;
    136136
    137137        #ifdef _PARALLEL_
    138138        /*Determine parallel partitioning of elements: we use Metis for now. First load the data, then partition*/
    139         if(strcmp(model->meshtype,"2d")==0){
     139        if(strcmp(iomodel->meshtype,"2d")==0){
    140140                /*load elements: */
    141                 ModelFetchData((void**)&model->elements,NULL,NULL,model_handle,"elements","Matrix","Mat");
     141                IoModelFetchData((void**)&iomodel->elements,NULL,NULL,iomodel_handle,"elements","Matrix","Mat");
    142142        }
    143143        else{
    144144                /*load elements2d: */
    145                 ModelFetchData((void**)&model->elements2d,NULL,NULL,model_handle,"elements2d","Matrix","Mat");
     145                IoModelFetchData((void**)&iomodel->elements2d,NULL,NULL,iomodel_handle,"elements2d","Matrix","Mat");
    146146        }
    147147
    148         MeshPartitionx(&epart, &npart,model->numberofelements,model->numberofnodes,model->elements, model->numberofelements2d,model->numberofnodes2d,model->elements2d,model->numlayers,elements_width, model->meshtype,num_procs);
     148        MeshPartitionx(&epart, &npart,iomodel->numberofelements,iomodel->numberofnodes,iomodel->elements, iomodel->numberofelements2d,iomodel->numberofnodes2d,iomodel->elements2d,iomodel->numlayers,elements_width, iomodel->meshtype,num_procs);
    149149
    150150        /*Free elements and elements2d: */
    151         xfree((void**)&model->elements);
    152         xfree((void**)&model->elements2d);
     151        xfree((void**)&iomodel->elements);
     152        xfree((void**)&iomodel->elements2d);
    153153               
    154154        /*Used later on: */
    155         my_grids=(int*)xcalloc(model->numberofnodes,sizeof(int));
     155        my_grids=(int*)xcalloc(iomodel->numberofnodes,sizeof(int));
    156156        #endif
    157157
     
    159159        /*Create 3d elements: */
    160160        /*Fetch data needed: */
    161         ModelFetchData((void**)&model->elements,NULL,NULL,model_handle,"elements","Matrix","Mat");
    162         ModelFetchData((void**)&model->thickness,NULL,NULL,model_handle,"thickness","Matrix","Mat");
    163         ModelFetchData((void**)&model->surface,NULL,NULL,model_handle,"surface","Matrix","Mat");
    164         ModelFetchData((void**)&model->bed,NULL,NULL,model_handle,"bed","Matrix","Mat");
    165         ModelFetchData((void**)&model->elementoniceshelf,NULL,NULL,model_handle,"elementoniceshelf","Matrix","Mat");
    166         ModelFetchData((void**)&model->elementonbed,NULL,NULL,model_handle,"elementonbed","Matrix","Mat");
    167         ModelFetchData((void**)&model->elementonsurface,NULL,NULL,model_handle,"elementonsurface","Matrix","Mat");
    168         ModelFetchData((void**)&model->elements_type,NULL,NULL,model_handle,"elements_type","Matrix","Mat");
    169         ModelFetchData((void**)&model->melting,NULL,NULL,model_handle,"melting","Matrix","Mat");
    170         ModelFetchData((void**)&model->accumulation,NULL,NULL,model_handle,"accumulation","Matrix","Mat");
    171         ModelFetchData((void**)&model->elementonwater,NULL,NULL,model_handle,"elementonwater","Matrix","Mat");
    172        
    173         for (i=0;i<model->numberofelements;i++){
     161        IoModelFetchData((void**)&iomodel->elements,NULL,NULL,iomodel_handle,"elements","Matrix","Mat");
     162        IoModelFetchData((void**)&iomodel->thickness,NULL,NULL,iomodel_handle,"thickness","Matrix","Mat");
     163        IoModelFetchData((void**)&iomodel->surface,NULL,NULL,iomodel_handle,"surface","Matrix","Mat");
     164        IoModelFetchData((void**)&iomodel->bed,NULL,NULL,iomodel_handle,"bed","Matrix","Mat");
     165        IoModelFetchData((void**)&iomodel->elementoniceshelf,NULL,NULL,iomodel_handle,"elementoniceshelf","Matrix","Mat");
     166        IoModelFetchData((void**)&iomodel->elementonbed,NULL,NULL,iomodel_handle,"elementonbed","Matrix","Mat");
     167        IoModelFetchData((void**)&iomodel->elementonsurface,NULL,NULL,iomodel_handle,"elementonsurface","Matrix","Mat");
     168        IoModelFetchData((void**)&iomodel->elements_type,NULL,NULL,iomodel_handle,"elements_type","Matrix","Mat");
     169        IoModelFetchData((void**)&iomodel->melting,NULL,NULL,iomodel_handle,"melting","Matrix","Mat");
     170        IoModelFetchData((void**)&iomodel->accumulation,NULL,NULL,iomodel_handle,"accumulation","Matrix","Mat");
     171        IoModelFetchData((void**)&iomodel->elementonwater,NULL,NULL,iomodel_handle,"elementonwater","Matrix","Mat");
     172       
     173        for (i=0;i<iomodel->numberofelements;i++){
    174174        #ifdef _PARALLEL_
    175175        /*We are using our element partition to decide which elements will be created on this node: */
     
    181181                penta_id=i+1; //matlab indexing.
    182182                penta_mid=i+1; //refers to the corresponding material property card
    183                 penta_mparid=model->numberofelements+1;//refers to the corresponding parmat property card
     183                penta_mparid=iomodel->numberofelements+1;//refers to the corresponding parmat property card
    184184
    185185                /*vertices,thickness,surface,bed and drag: */
    186186                for(j=0;j<6;j++){
    187                         penta_g[j]=(int)*(model->elements+elements_width*i+j);
    188                         penta_h[j]=*(model->thickness+    ((int)*(model->elements+elements_width*i+j)-1));
    189                         penta_s[j]=*(model->surface+    ((int)*(model->elements+elements_width*i+j)-1));
    190                         penta_b[j]=*(model->bed+    ((int)*(model->elements+elements_width*i+j)-1));
    191                         penta_melting[j]=*(model->melting+        ((int)*(model->elements+elements_width*i+j)-1))/model->yts;
    192                         penta_accumulation[j]=*(model->accumulation+        ((int)*(model->elements+elements_width*i+j)-1))/model->yts;
     187                        penta_g[j]=(int)*(iomodel->elements+elements_width*i+j);
     188                        penta_h[j]=*(iomodel->thickness+    ((int)*(iomodel->elements+elements_width*i+j)-1));
     189                        penta_s[j]=*(iomodel->surface+    ((int)*(iomodel->elements+elements_width*i+j)-1));
     190                        penta_b[j]=*(iomodel->bed+    ((int)*(iomodel->elements+elements_width*i+j)-1));
     191                        penta_melting[j]=*(iomodel->melting+        ((int)*(iomodel->elements+elements_width*i+j)-1))/iomodel->yts;
     192                        penta_accumulation[j]=*(iomodel->accumulation+        ((int)*(iomodel->elements+elements_width*i+j)-1))/iomodel->yts;
    193193                }
    194194
    195195                /*diverse: */
    196                 penta_shelf=(int)*(model->elementoniceshelf+i);
    197                 penta_onbed=(int)*(model->elementonbed+i);
    198                 penta_onsurface=(int)*(model->elementonsurface+i);
     196                penta_shelf=(int)*(iomodel->elementoniceshelf+i);
     197                penta_onbed=(int)*(iomodel->elementonbed+i);
     198                penta_onsurface=(int)*(iomodel->elementonsurface+i);
    199199                penta_collapse=1;
    200                 penta_onwater=(bool)*(model->elementonwater+i);
     200                penta_onwater=(bool)*(iomodel->elementonwater+i);
    201201
    202202                /*Create Penta using its constructor:*/
     
    224224                 into the grid coordinates. If we start plugging 1 into my_grids for each index[n][i] (i=0:2), then my_grids
    225225                 will hold which grids belong to this partition*/
    226                 my_grids[(int)*(model->elements+elements_width*i+0)-1]=1;
    227                 my_grids[(int)*(model->elements+elements_width*i+1)-1]=1;
    228                 my_grids[(int)*(model->elements+elements_width*i+2)-1]=1;
    229                 my_grids[(int)*(model->elements+elements_width*i+3)-1]=1;
    230                 my_grids[(int)*(model->elements+elements_width*i+4)-1]=1;
    231                 my_grids[(int)*(model->elements+elements_width*i+5)-1]=1;
     226                my_grids[(int)*(iomodel->elements+elements_width*i+0)-1]=1;
     227                my_grids[(int)*(iomodel->elements+elements_width*i+1)-1]=1;
     228                my_grids[(int)*(iomodel->elements+elements_width*i+2)-1]=1;
     229                my_grids[(int)*(iomodel->elements+elements_width*i+3)-1]=1;
     230                my_grids[(int)*(iomodel->elements+elements_width*i+4)-1]=1;
     231                my_grids[(int)*(iomodel->elements+elements_width*i+5)-1]=1;
    232232                #endif
    233233
     
    239239
    240240        /*Free data: */
    241         xfree((void**)&model->elements);
    242         xfree((void**)&model->thickness);
    243         xfree((void**)&model->surface);
    244         xfree((void**)&model->bed);
    245         xfree((void**)&model->elementoniceshelf);
    246         xfree((void**)&model->elementonbed);
    247         xfree((void**)&model->elementonsurface);
    248         xfree((void**)&model->elements_type);
    249         xfree((void**)&model->melting);
    250         xfree((void**)&model->accumulation);
    251         xfree((void**)&model->elementonwater);
     241        xfree((void**)&iomodel->elements);
     242        xfree((void**)&iomodel->thickness);
     243        xfree((void**)&iomodel->surface);
     244        xfree((void**)&iomodel->bed);
     245        xfree((void**)&iomodel->elementoniceshelf);
     246        xfree((void**)&iomodel->elementonbed);
     247        xfree((void**)&iomodel->elementonsurface);
     248        xfree((void**)&iomodel->elements_type);
     249        xfree((void**)&iomodel->melting);
     250        xfree((void**)&iomodel->accumulation);
     251        xfree((void**)&iomodel->elementonwater);
    252252
    253253
    254254        /*Add one constant material property to materials: */
    255         matpar_mid=model->numberofelements+1; //put it at the end of the materials
    256         matpar_g=model->g;
    257         matpar_rho_ice=model->rho_ice;
    258         matpar_rho_water=model->rho_water;
    259         matpar_thermalconductivity=model->thermalconductivity;
    260         matpar_heatcapacity=model->heatcapacity;
    261         matpar_latentheat=model->latentheat;
    262         matpar_beta=model->beta;
    263         matpar_meltingpoint=model->meltingpoint;
    264         matpar_mixed_layer_capacity=model->mixed_layer_capacity;
    265         matpar_thermal_exchange_velocity=model->thermal_exchange_velocity;
     255        matpar_mid=iomodel->numberofelements+1; //put it at the end of the materials
     256        matpar_g=iomodel->g;
     257        matpar_rho_ice=iomodel->rho_ice;
     258        matpar_rho_water=iomodel->rho_water;
     259        matpar_thermalconductivity=iomodel->thermalconductivity;
     260        matpar_heatcapacity=iomodel->heatcapacity;
     261        matpar_latentheat=iomodel->latentheat;
     262        matpar_beta=iomodel->beta;
     263        matpar_meltingpoint=iomodel->meltingpoint;
     264        matpar_mixed_layer_capacity=iomodel->mixed_layer_capacity;
     265        matpar_thermal_exchange_velocity=iomodel->thermal_exchange_velocity;
    266266
    267267        /*Create matpar object using its constructor: */
     
    276276                /*From the element partitioning, we can determine which grids are on the inside of this cpu's
    277277                 *element partition, and which are on its border with other nodes:*/
    278                 gridborder=NewVec(model->numberofnodes);
    279 
    280                 for (i=0;i<model->numberofnodes;i++){
     278                gridborder=NewVec(iomodel->numberofnodes);
     279
     280                for (i=0;i<iomodel->numberofnodes;i++){
    281281                        if(my_grids[i])VecSetValue(gridborder,i,1,ADD_VALUES);
    282282                }
     
    292292                #ifdef _DEBUG_
    293293                if(my_rank==0){
    294                         for (i=0;i<model->numberofnodes;i++){
     294                        for (i=0;i<iomodel->numberofnodes;i++){
    295295                                printf("Grid id %i Border grid %lf\n",i+1,my_bordergrids[i]);
    296296                        }
     
    308308               
    309309        /*First fetch data: */
    310         if (strcmp(model->meshtype,"3d")==0){
    311                 ModelFetchData((void**)&model->deadgrids,NULL,NULL,model_handle,"deadgrids","Matrix","Mat");
    312                 ModelFetchData((void**)&model->uppernodes,NULL,NULL,model_handle,"uppergrids","Matrix","Mat");
     310        if (strcmp(iomodel->meshtype,"3d")==0){
     311                IoModelFetchData((void**)&iomodel->deadgrids,NULL,NULL,iomodel_handle,"deadgrids","Matrix","Mat");
     312                IoModelFetchData((void**)&iomodel->uppernodes,NULL,NULL,iomodel_handle,"uppergrids","Matrix","Mat");
    313313        }
    314         ModelFetchData((void**)&model->x,NULL,NULL,model_handle,"x","Matrix","Mat");
    315         ModelFetchData((void**)&model->y,NULL,NULL,model_handle,"y","Matrix","Mat");
    316         ModelFetchData((void**)&model->z,NULL,NULL,model_handle,"z","Matrix","Mat");
    317         ModelFetchData((void**)&model->thickness,NULL,NULL,model_handle,"thickness","Matrix","Mat");
    318         ModelFetchData((void**)&model->bed,NULL,NULL,model_handle,"bed","Matrix","Mat");
    319         ModelFetchData((void**)&model->gridonbed,NULL,NULL,model_handle,"gridonbed","Matrix","Mat");
    320         ModelFetchData((void**)&model->gridonsurface,NULL,NULL,model_handle,"gridonsurface","Matrix","Mat");
    321         ModelFetchData((void**)&model->gridonicesheet,NULL,NULL,model_handle,"gridonicesheet","Matrix","Mat");
    322         ModelFetchData((void**)&model->gridoniceshelf,NULL,NULL,model_handle,"gridoniceshelf","Matrix","Mat");
     314        IoModelFetchData((void**)&iomodel->x,NULL,NULL,iomodel_handle,"x","Matrix","Mat");
     315        IoModelFetchData((void**)&iomodel->y,NULL,NULL,iomodel_handle,"y","Matrix","Mat");
     316        IoModelFetchData((void**)&iomodel->z,NULL,NULL,iomodel_handle,"z","Matrix","Mat");
     317        IoModelFetchData((void**)&iomodel->thickness,NULL,NULL,iomodel_handle,"thickness","Matrix","Mat");
     318        IoModelFetchData((void**)&iomodel->bed,NULL,NULL,iomodel_handle,"bed","Matrix","Mat");
     319        IoModelFetchData((void**)&iomodel->gridonbed,NULL,NULL,iomodel_handle,"gridonbed","Matrix","Mat");
     320        IoModelFetchData((void**)&iomodel->gridonsurface,NULL,NULL,iomodel_handle,"gridonsurface","Matrix","Mat");
     321        IoModelFetchData((void**)&iomodel->gridonicesheet,NULL,NULL,iomodel_handle,"gridonicesheet","Matrix","Mat");
     322        IoModelFetchData((void**)&iomodel->gridoniceshelf,NULL,NULL,iomodel_handle,"gridoniceshelf","Matrix","Mat");
    323323
    324324       
    325325        /*Get number of dofs per node: */
    326         DistributeNumDofs(&node_numdofs,model->analysis_type,model->sub_analysis_type);
    327 
    328         for (i=0;i<model->numberofnodes;i++){
     326        DistributeNumDofs(&node_numdofs,iomodel->analysis_type,iomodel->sub_analysis_type);
     327
     328        for (i=0;i<iomodel->numberofnodes;i++){
    329329        #ifdef _PARALLEL_
    330330        /*keep only this partition's nodes:*/
     
    347347                #endif
    348348
    349                 node_x[0]=model->x[i];
    350                 node_x[1]=model->y[i];
    351                 node_x[2]=model->z[i];
    352                 node_sigma=(model->z[i]-model->bed[i])/(model->thickness[i]);
    353                
    354                 node_onbed=(int)model->gridonbed[i];
    355                 node_onsurface=(int)model->gridonsurface[i];
    356                 node_onshelf=(int)model->gridoniceshelf[i];     
    357                 node_onsheet=(int)model->gridonicesheet[i];     
    358        
    359                 if (isnan(model->uppernodes[i])){
     349                node_x[0]=iomodel->x[i];
     350                node_x[1]=iomodel->y[i];
     351                node_x[2]=iomodel->z[i];
     352                node_sigma=(iomodel->z[i]-iomodel->bed[i])/(iomodel->thickness[i]);
     353               
     354                node_onbed=(int)iomodel->gridonbed[i];
     355                node_onsurface=(int)iomodel->gridonsurface[i];
     356                node_onshelf=(int)iomodel->gridoniceshelf[i];   
     357                node_onsheet=(int)iomodel->gridonicesheet[i];   
     358       
     359                if (isnan(iomodel->uppernodes[i])){
    360360                        node_upper_node_id=node_id;  //nodes on surface do not have upper nodes, only themselves.
    361361                }
    362362                else{
    363                         node_upper_node_id=(int)model->uppernodes[i];
     363                        node_upper_node_id=(int)iomodel->uppernodes[i];
    364364                }
    365365
     
    382382
    383383        /*Clean fetched data: */
    384         xfree((void**)&model->deadgrids);
    385         xfree((void**)&model->x);
    386         xfree((void**)&model->y);
    387         xfree((void**)&model->z);
    388         xfree((void**)&model->thickness);
    389         xfree((void**)&model->bed);
    390         xfree((void**)&model->gridonbed);
    391         xfree((void**)&model->gridonsurface);
    392         xfree((void**)&model->uppernodes);
    393         xfree((void**)&model->gridonicesheet);
    394         xfree((void**)&model->gridoniceshelf);
    395        
    396 
    397         /*Keep partitioning information into model*/
    398         model->epart=epart;
    399         model->my_grids=my_grids;
    400         model->my_bordergrids=my_bordergrids;
     384        xfree((void**)&iomodel->deadgrids);
     385        xfree((void**)&iomodel->x);
     386        xfree((void**)&iomodel->y);
     387        xfree((void**)&iomodel->z);
     388        xfree((void**)&iomodel->thickness);
     389        xfree((void**)&iomodel->bed);
     390        xfree((void**)&iomodel->gridonbed);
     391        xfree((void**)&iomodel->gridonsurface);
     392        xfree((void**)&iomodel->uppernodes);
     393        xfree((void**)&iomodel->gridonicesheet);
     394        xfree((void**)&iomodel->gridoniceshelf);
     395       
     396
     397        /*Keep partitioning information into iomodel*/
     398        iomodel->epart=epart;
     399        iomodel->my_grids=my_grids;
     400        iomodel->my_bordergrids=my_bordergrids;
    401401
    402402        /*Free ressources:*/
  • issm/trunk/src/c/ModelProcessorx/DiagnosticVert/CreateLoadsDiagnosticVert.cpp

    r300 r1834  
    1111#include "../../shared/shared.h"
    1212#include "../../include/macros.h"
    13 #include "../Model.h"
     13#include "../IoModel.h"
    1414
    1515
    16 void    CreateLoadsDiagnosticVert(DataSet** ploads, Model* model,ConstDataHandle model_handle){
     16void    CreateLoadsDiagnosticVert(DataSet** ploads, IoModel* iomodel,ConstDataHandle iomodel_handle){
    1717
    1818        DataSet*    loads    = NULL;
     
    2121        loads   = new DataSet(LoadsEnum());
    2222
    23         /*Now, is the model running in 3d? : */
    24         if (strcmp(model->meshtype,"2d")==0)goto cleanup_and_return;
     23        /*Now, is the iomodel running in 3d? : */
     24        if (strcmp(iomodel->meshtype,"2d")==0)goto cleanup_and_return;
    2525
    2626        cleanup_and_return:
  • issm/trunk/src/c/ModelProcessorx/Melting/CreateConstraintsMelting.cpp

    r483 r1834  
    1111#include "../../objects/objects.h"
    1212#include "../../shared/shared.h"
    13 #include "../Model.h"
     13#include "../IoModel.h"
    1414
    1515
    16 void    CreateConstraintsMelting(DataSet** pconstraints, Model* model,ConstDataHandle model_handle){
     16void    CreateConstraintsMelting(DataSet** pconstraints, IoModel* iomodel,ConstDataHandle iomodel_handle){
    1717
    1818
  • issm/trunk/src/c/ModelProcessorx/Melting/CreateElementsNodesAndMaterialsMelting.cpp

    r1648 r1834  
    1212#include "../../shared/shared.h"
    1313#include "../../MeshPartitionx/MeshPartitionx.h"
    14 #include "../Model.h"
    15 
    16 
    17 void    CreateElementsNodesAndMaterialsMelting(DataSet** pelements,DataSet** pnodes, DataSet** pmaterials, Model* model,ConstDataHandle model_handle){
     14#include "../IoModel.h"
     15
     16
     17void    CreateElementsNodesAndMaterialsMelting(DataSet** pelements,DataSet** pnodes, DataSet** pmaterials, IoModel* iomodel,ConstDataHandle iomodel_handle){
    1818
    1919
     
    123123
    124124        /*Width of elements: */
    125         if(strcmp(model->meshtype,"2d")==0)throw ErrorException(__FUNCT__," error message: 2d temperature computations not supported yet!");
     125        if(strcmp(iomodel->meshtype,"2d")==0)throw ErrorException(__FUNCT__," error message: 2d temperature computations not supported yet!");
    126126        elements_width=6; //penta elements
    127127
     
    129129        #ifdef _PARALLEL_
    130130        /*Determine parallel partitioning of elements: we use Metis for now. First load the data, then partition*/
    131         ModelFetchData((void**)&model->elements2d,NULL,NULL,model_handle,"elements2d","Matrix","Mat");
    132 
    133 
    134         MeshPartitionx(&epart, &npart,model->numberofelements,model->numberofnodes,model->elements, model->numberofelements2d,model->numberofnodes2d,model->elements2d,model->numlayers,elements_width, model->meshtype,num_procs);
     131        IoModelFetchData((void**)&iomodel->elements2d,NULL,NULL,iomodel_handle,"elements2d","Matrix","Mat");
     132
     133
     134        MeshPartitionx(&epart, &npart,iomodel->numberofelements,iomodel->numberofnodes,iomodel->elements, iomodel->numberofelements2d,iomodel->numberofnodes2d,iomodel->elements2d,iomodel->numlayers,elements_width, iomodel->meshtype,num_procs);
    135135
    136136        /*Free elements and elements2d: */
    137         xfree((void**)&model->elements2d);
     137        xfree((void**)&iomodel->elements2d);
    138138
    139139        /*Used later on: */
    140         my_grids=(int*)xcalloc(model->numberofnodes,sizeof(int));
     140        my_grids=(int*)xcalloc(iomodel->numberofnodes,sizeof(int));
    141141        #endif
    142142
     
    146146
    147147        /*Fetch data needed: */
    148         ModelFetchData((void**)&model->elements,NULL,NULL,model_handle,"elements","Matrix","Mat");
    149         ModelFetchData((void**)&model->thickness,NULL,NULL,model_handle,"thickness","Matrix","Mat");
    150         ModelFetchData((void**)&model->surface,NULL,NULL,model_handle,"surface","Matrix","Mat");
    151         ModelFetchData((void**)&model->bed,NULL,NULL,model_handle,"bed","Matrix","Mat");
    152         ModelFetchData((void**)&model->drag,NULL,NULL,model_handle,"drag","Matrix","Mat");
    153         ModelFetchData((void**)&model->p,NULL,NULL,model_handle,"p","Matrix","Mat");
    154         ModelFetchData((void**)&model->q,NULL,NULL,model_handle,"q","Matrix","Mat");
    155         ModelFetchData((void**)&model->elementoniceshelf,NULL,NULL,model_handle,"elementoniceshelf","Matrix","Mat");
    156         ModelFetchData((void**)&model->elementonbed,NULL,NULL,model_handle,"elementonbed","Matrix","Mat");
    157         ModelFetchData((void**)&model->elementonsurface,NULL,NULL,model_handle,"elementonsurface","Matrix","Mat");
    158         ModelFetchData((void**)&model->elements_type,NULL,NULL,model_handle,"elements_type","Matrix","Mat");
    159         ModelFetchData((void**)&model->B,NULL,NULL,model_handle,"B","Matrix","Mat");
    160         ModelFetchData((void**)&model->n,NULL,NULL,model_handle,"n","Matrix","Mat");
    161         ModelFetchData((void**)&model->accumulation,NULL,NULL,model_handle,"accumulation","Matrix","Mat");
    162         ModelFetchData((void**)&model->melting,NULL,NULL,model_handle,"melting","Matrix","Mat");
    163         ModelFetchData((void**)&model->elementonwater,NULL,NULL,model_handle,"elementonwater","Matrix","Mat");
    164        
    165         for (i=0;i<model->numberofelements;i++){
     148        IoModelFetchData((void**)&iomodel->elements,NULL,NULL,iomodel_handle,"elements","Matrix","Mat");
     149        IoModelFetchData((void**)&iomodel->thickness,NULL,NULL,iomodel_handle,"thickness","Matrix","Mat");
     150        IoModelFetchData((void**)&iomodel->surface,NULL,NULL,iomodel_handle,"surface","Matrix","Mat");
     151        IoModelFetchData((void**)&iomodel->bed,NULL,NULL,iomodel_handle,"bed","Matrix","Mat");
     152        IoModelFetchData((void**)&iomodel->drag,NULL,NULL,iomodel_handle,"drag","Matrix","Mat");
     153        IoModelFetchData((void**)&iomodel->p,NULL,NULL,iomodel_handle,"p","Matrix","Mat");
     154        IoModelFetchData((void**)&iomodel->q,NULL,NULL,iomodel_handle,"q","Matrix","Mat");
     155        IoModelFetchData((void**)&iomodel->elementoniceshelf,NULL,NULL,iomodel_handle,"elementoniceshelf","Matrix","Mat");
     156        IoModelFetchData((void**)&iomodel->elementonbed,NULL,NULL,iomodel_handle,"elementonbed","Matrix","Mat");
     157        IoModelFetchData((void**)&iomodel->elementonsurface,NULL,NULL,iomodel_handle,"elementonsurface","Matrix","Mat");
     158        IoModelFetchData((void**)&iomodel->elements_type,NULL,NULL,iomodel_handle,"elements_type","Matrix","Mat");
     159        IoModelFetchData((void**)&iomodel->B,NULL,NULL,iomodel_handle,"B","Matrix","Mat");
     160        IoModelFetchData((void**)&iomodel->n,NULL,NULL,iomodel_handle,"n","Matrix","Mat");
     161        IoModelFetchData((void**)&iomodel->accumulation,NULL,NULL,iomodel_handle,"accumulation","Matrix","Mat");
     162        IoModelFetchData((void**)&iomodel->melting,NULL,NULL,iomodel_handle,"melting","Matrix","Mat");
     163        IoModelFetchData((void**)&iomodel->elementonwater,NULL,NULL,iomodel_handle,"elementonwater","Matrix","Mat");
     164       
     165        for (i=0;i<iomodel->numberofelements;i++){
    166166        #ifdef _PARALLEL_
    167167        /*We are using our element partition to decide which elements will be created on this node: */
     
    173173                penta_id=i+1; //matlab indexing.
    174174                penta_mid=i+1; //refers to the corresponding material property card
    175                 penta_mparid=model->numberofelements+1;//refers to the corresponding parmat property card
     175                penta_mparid=iomodel->numberofelements+1;//refers to the corresponding parmat property card
    176176
    177177                /*vertices,thickness,surface,bed and drag: */
    178178                for(j=0;j<6;j++){
    179                         penta_g[j]=(int)*(model->elements+elements_width*i+j);
    180                         penta_h[j]=*(model->thickness+    ((int)*(model->elements+elements_width*i+j)-1));
    181                         penta_s[j]=*(model->surface+    ((int)*(model->elements+elements_width*i+j)-1));
    182                         penta_b[j]=*(model->bed+    ((int)*(model->elements+elements_width*i+j)-1));
    183                         penta_k[j]=*(model->drag+        ((int)*(model->elements+elements_width*i+j)-1));
    184                         penta_melting[j]=*(model->melting+        ((int)*(model->elements+elements_width*i+j)-1));
    185                         penta_accumulation[j]=*(model->accumulation+        ((int)*(model->elements+elements_width*i+j)-1));
     179                        penta_g[j]=(int)*(iomodel->elements+elements_width*i+j);
     180                        penta_h[j]=*(iomodel->thickness+    ((int)*(iomodel->elements+elements_width*i+j)-1));
     181                        penta_s[j]=*(iomodel->surface+    ((int)*(iomodel->elements+elements_width*i+j)-1));
     182                        penta_b[j]=*(iomodel->bed+    ((int)*(iomodel->elements+elements_width*i+j)-1));
     183                        penta_k[j]=*(iomodel->drag+        ((int)*(iomodel->elements+elements_width*i+j)-1));
     184                        penta_melting[j]=*(iomodel->melting+        ((int)*(iomodel->elements+elements_width*i+j)-1));
     185                        penta_accumulation[j]=*(iomodel->accumulation+        ((int)*(iomodel->elements+elements_width*i+j)-1));
    186186                }
    187187
    188188                /*basal drag:*/
    189                 penta_friction_type=(int)model->drag_type;
    190 
    191                 penta_p=model->p[i];
    192                 penta_q=model->q[i];
     189                penta_friction_type=(int)iomodel->drag_type;
     190
     191                penta_p=iomodel->p[i];
     192                penta_q=iomodel->q[i];
    193193
    194194                /*diverse: */
    195                 penta_shelf=(int)*(model->elementoniceshelf+i);
    196                 penta_onbed=(int)*(model->elementonbed+i);
    197                 penta_onsurface=(int)*(model->elementonsurface+i);
    198                 penta_meanvel=model->meanvel;
    199                 penta_epsvel=model->epsvel;
    200                 penta_onwater=(bool)*(model->elementonwater+i);
     195                penta_shelf=(int)*(iomodel->elementoniceshelf+i);
     196                penta_onbed=(int)*(iomodel->elementonbed+i);
     197                penta_onsurface=(int)*(iomodel->elementonsurface+i);
     198                penta_meanvel=iomodel->meanvel;
     199                penta_epsvel=iomodel->epsvel;
     200                penta_onwater=(bool)*(iomodel->elementonwater+i);
    201201       
    202202                /*viscosity_overshoot*/
    203                 penta_viscosity_overshoot=model->viscosity_overshoot;
     203                penta_viscosity_overshoot=iomodel->viscosity_overshoot;
    204204                penta_collapse=1;
    205205
     
    219219                B_avg=0;
    220220                for(j=0;j<6;j++){
    221                         B_avg+=*(model->B+((int)*(model->elements+elements_width*i+j)-1));
     221                        B_avg+=*(iomodel->B+((int)*(iomodel->elements+elements_width*i+j)-1));
    222222                }
    223223                B_avg=B_avg/6;
    224224                matice_B= B_avg;
    225                 matice_n=(double)*(model->n+i);
     225                matice_n=(double)*(iomodel->n+i);
    226226
    227227                /*Create matice using its constructor:*/
     
    236236                 into the grid coordinates. If we start plugging 1 into my_grids for each index[n][i] (i=0:2), then my_grids
    237237                 will hold which grids belong to this partition*/
    238                 my_grids[(int)*(model->elements+elements_width*i+0)-1]=1;
    239                 my_grids[(int)*(model->elements+elements_width*i+1)-1]=1;
    240                 my_grids[(int)*(model->elements+elements_width*i+2)-1]=1;
    241                 my_grids[(int)*(model->elements+elements_width*i+3)-1]=1;
    242                 my_grids[(int)*(model->elements+elements_width*i+4)-1]=1;
    243                 my_grids[(int)*(model->elements+elements_width*i+5)-1]=1;
     238                my_grids[(int)*(iomodel->elements+elements_width*i+0)-1]=1;
     239                my_grids[(int)*(iomodel->elements+elements_width*i+1)-1]=1;
     240                my_grids[(int)*(iomodel->elements+elements_width*i+2)-1]=1;
     241                my_grids[(int)*(iomodel->elements+elements_width*i+3)-1]=1;
     242                my_grids[(int)*(iomodel->elements+elements_width*i+4)-1]=1;
     243                my_grids[(int)*(iomodel->elements+elements_width*i+5)-1]=1;
    244244                #endif
    245245
     
    251251
    252252        /*Free data: */
    253         xfree((void**)&model->elements);
    254         xfree((void**)&model->thickness);
    255         xfree((void**)&model->surface);
    256         xfree((void**)&model->bed);
    257         xfree((void**)&model->drag);
    258         xfree((void**)&model->p);
    259         xfree((void**)&model->q);
    260         xfree((void**)&model->elementoniceshelf);
    261         xfree((void**)&model->elementonbed);
    262         xfree((void**)&model->elementonsurface);
    263         xfree((void**)&model->elements_type);
    264         xfree((void**)&model->n);
    265         xfree((void**)&model->B);
    266         xfree((void**)&model->accumulation);
    267         xfree((void**)&model->melting);
    268         xfree((void**)&model->elementonwater);
     253        xfree((void**)&iomodel->elements);
     254        xfree((void**)&iomodel->thickness);
     255        xfree((void**)&iomodel->surface);
     256        xfree((void**)&iomodel->bed);
     257        xfree((void**)&iomodel->drag);
     258        xfree((void**)&iomodel->p);
     259        xfree((void**)&iomodel->q);
     260        xfree((void**)&iomodel->elementoniceshelf);
     261        xfree((void**)&iomodel->elementonbed);
     262        xfree((void**)&iomodel->elementonsurface);
     263        xfree((void**)&iomodel->elements_type);
     264        xfree((void**)&iomodel->n);
     265        xfree((void**)&iomodel->B);
     266        xfree((void**)&iomodel->accumulation);
     267        xfree((void**)&iomodel->melting);
     268        xfree((void**)&iomodel->elementonwater);
    269269
    270270
    271271        /*Add one constant material property to materials: */
    272         matpar_mid=model->numberofelements+1; //put it at the end of the materials
    273         matpar_g=model->g;
    274         matpar_rho_ice=model->rho_ice;
    275         matpar_rho_water=model->rho_water;
    276         matpar_thermalconductivity=model->thermalconductivity;
    277         matpar_heatcapacity=model->heatcapacity;
    278         matpar_latentheat=model->latentheat;
    279         matpar_beta=model->beta;
    280         matpar_meltingpoint=model->meltingpoint;
    281         matpar_mixed_layer_capacity=model->mixed_layer_capacity;
    282         matpar_thermal_exchange_velocity=model->thermal_exchange_velocity;
     272        matpar_mid=iomodel->numberofelements+1; //put it at the end of the materials
     273        matpar_g=iomodel->g;
     274        matpar_rho_ice=iomodel->rho_ice;
     275        matpar_rho_water=iomodel->rho_water;
     276        matpar_thermalconductivity=iomodel->thermalconductivity;
     277        matpar_heatcapacity=iomodel->heatcapacity;
     278        matpar_latentheat=iomodel->latentheat;
     279        matpar_beta=iomodel->beta;
     280        matpar_meltingpoint=iomodel->meltingpoint;
     281        matpar_mixed_layer_capacity=iomodel->mixed_layer_capacity;
     282        matpar_thermal_exchange_velocity=iomodel->thermal_exchange_velocity;
    283283
    284284        /*Create matpar object using its constructor: */
     
    293293                /*From the element partitioning, we can determine which grids are on the inside of this cpu's
    294294                 *element partition, and which are on its border with other nodes:*/
    295                 gridborder=NewVec(model->numberofnodes);
    296 
    297                 for (i=0;i<model->numberofnodes;i++){
     295                gridborder=NewVec(iomodel->numberofnodes);
     296
     297                for (i=0;i<iomodel->numberofnodes;i++){
    298298                        if(my_grids[i])VecSetValue(gridborder,i,1,ADD_VALUES);
    299299                }
     
    309309                #ifdef _DEBUG_
    310310                if(my_rank==0){
    311                         for (i=0;i<model->numberofnodes;i++){
     311                        for (i=0;i<iomodel->numberofnodes;i++){
    312312                                printf("Grid id %i Border grid %lf\n",i+1,my_bordergrids[i]);
    313313                        }
     
    317317
    318318        /*Partition penalties in 3d: */
    319         if(strcmp(model->meshtype,"3d")==0){
     319        if(strcmp(iomodel->meshtype,"3d")==0){
    320320       
    321321                /*Get penalties: */
    322                 ModelFetchData((void**)&model->penalties,&model->numpenalties,NULL,model_handle,"penalties","Matrix","Mat");
    323 
    324                 if(model->numpenalties){
    325 
    326                         model->penaltypartitioning=(int*)xmalloc(model->numpenalties*sizeof(int));
     322                IoModelFetchData((void**)&iomodel->penalties,&iomodel->numpenalties,NULL,iomodel_handle,"penalties","Matrix","Mat");
     323
     324                if(iomodel->numpenalties){
     325
     326                        iomodel->penaltypartitioning=(int*)xmalloc(iomodel->numpenalties*sizeof(int));
    327327                        #ifdef _SERIAL_
    328                         for(i=0;i<model->numpenalties;i++)model->penaltypartitioning[i]=1;
     328                        for(i=0;i<iomodel->numpenalties;i++)iomodel->penaltypartitioning[i]=1;
    329329                        #else
    330                         for(i=0;i<model->numpenalties;i++)model->penaltypartitioning[i]=-1;
    331 
    332                         for(i=0;i<model->numpenalties;i++){
    333                                 first_grid_index=(int)(*(model->penalties+i*model->numlayers+0)-1);
     330                        for(i=0;i<iomodel->numpenalties;i++)iomodel->penaltypartitioning[i]=-1;
     331
     332                        for(i=0;i<iomodel->numpenalties;i++){
     333                                first_grid_index=(int)(*(iomodel->penalties+i*iomodel->numlayers+0)-1);
    334334                                if((my_grids[first_grid_index]==1) && (my_bordergrids[first_grid_index]<=1.0) ) { //this grid belongs to this node's internal partition  grids
    335335                                        /*All grids that are being penalised belong to this node's internal grid partition.:*/
    336                                         model->penaltypartitioning[i]=1;
     336                                        iomodel->penaltypartitioning[i]=1;
    337337                                }
    338338                                if(my_bordergrids[first_grid_index]>1.0) { //this grid belongs to a partition border
    339                                         model->penaltypartitioning[i]=0;
     339                                        iomodel->penaltypartitioning[i]=0;
    340340                                }
    341341                        }
     
    344344
    345345                /*Free penalties: */
    346                 xfree((void**)&model->penalties);
     346                xfree((void**)&iomodel->penalties);
    347347        }
    348348
     
    355355               
    356356        /*First fetch data: */
    357         if (strcmp(model->meshtype,"3d")==0){
    358                 ModelFetchData((void**)&model->deadgrids,NULL,NULL,model_handle,"deadgrids","Matrix","Mat");
    359                 ModelFetchData((void**)&model->uppernodes,NULL,NULL,model_handle,"uppergrids","Matrix","Mat");
     357        if (strcmp(iomodel->meshtype,"3d")==0){
     358                IoModelFetchData((void**)&iomodel->deadgrids,NULL,NULL,iomodel_handle,"deadgrids","Matrix","Mat");
     359                IoModelFetchData((void**)&iomodel->uppernodes,NULL,NULL,iomodel_handle,"uppergrids","Matrix","Mat");
    360360        }
    361         ModelFetchData((void**)&model->x,NULL,NULL,model_handle,"x","Matrix","Mat");
    362         ModelFetchData((void**)&model->y,NULL,NULL,model_handle,"y","Matrix","Mat");
    363         ModelFetchData((void**)&model->z,NULL,NULL,model_handle,"z","Matrix","Mat");
    364         ModelFetchData((void**)&model->thickness,NULL,NULL,model_handle,"thickness","Matrix","Mat");
    365         ModelFetchData((void**)&model->bed,NULL,NULL,model_handle,"bed","Matrix","Mat");
    366         ModelFetchData((void**)&model->gridonbed,NULL,NULL,model_handle,"gridonbed","Matrix","Mat");
    367         ModelFetchData((void**)&model->gridonsurface,NULL,NULL,model_handle,"gridonsurface","Matrix","Mat");
    368         ModelFetchData((void**)&model->gridonicesheet,NULL,NULL,model_handle,"gridonicesheet","Matrix","Mat");
    369         ModelFetchData((void**)&model->gridoniceshelf,NULL,NULL,model_handle,"gridoniceshelf","Matrix","Mat");
     361        IoModelFetchData((void**)&iomodel->x,NULL,NULL,iomodel_handle,"x","Matrix","Mat");
     362        IoModelFetchData((void**)&iomodel->y,NULL,NULL,iomodel_handle,"y","Matrix","Mat");
     363        IoModelFetchData((void**)&iomodel->z,NULL,NULL,iomodel_handle,"z","Matrix","Mat");
     364        IoModelFetchData((void**)&iomodel->thickness,NULL,NULL,iomodel_handle,"thickness","Matrix","Mat");
     365        IoModelFetchData((void**)&iomodel->bed,NULL,NULL,iomodel_handle,"bed","Matrix","Mat");
     366        IoModelFetchData((void**)&iomodel->gridonbed,NULL,NULL,iomodel_handle,"gridonbed","Matrix","Mat");
     367        IoModelFetchData((void**)&iomodel->gridonsurface,NULL,NULL,iomodel_handle,"gridonsurface","Matrix","Mat");
     368        IoModelFetchData((void**)&iomodel->gridonicesheet,NULL,NULL,iomodel_handle,"gridonicesheet","Matrix","Mat");
     369        IoModelFetchData((void**)&iomodel->gridoniceshelf,NULL,NULL,iomodel_handle,"gridoniceshelf","Matrix","Mat");
    370370
    371371
    372372        /*Get number of dofs per node: */
    373         DistributeNumDofs(&node_numdofs,model->analysis_type,model->sub_analysis_type);
    374 
    375         for (i=0;i<model->numberofnodes;i++){
     373        DistributeNumDofs(&node_numdofs,iomodel->analysis_type,iomodel->sub_analysis_type);
     374
     375        for (i=0;i<iomodel->numberofnodes;i++){
    376376        #ifdef _PARALLEL_
    377377        /*keep only this partition's nodes:*/
     
    394394                #endif
    395395
    396                 node_x[0]=model->x[i];
    397                 node_x[1]=model->y[i];
    398                 node_x[2]=model->z[i];
    399                 node_sigma=(model->z[i]-model->bed[i])/(model->thickness[i]);
    400                
    401                 node_onbed=(int)model->gridonbed[i];
    402                 node_onsurface=(int)model->gridonsurface[i];   
    403                 node_onshelf=(int)model->gridoniceshelf[i];     
    404                 node_onsheet=(int)model->gridonicesheet[i];     
    405 
    406                 if (strcmp(model->meshtype,"3d")==0){
    407                         if (isnan(model->uppernodes[i])){
     396                node_x[0]=iomodel->x[i];
     397                node_x[1]=iomodel->y[i];
     398                node_x[2]=iomodel->z[i];
     399                node_sigma=(iomodel->z[i]-iomodel->bed[i])/(iomodel->thickness[i]);
     400               
     401                node_onbed=(int)iomodel->gridonbed[i];
     402                node_onsurface=(int)iomodel->gridonsurface[i]; 
     403                node_onshelf=(int)iomodel->gridoniceshelf[i];   
     404                node_onsheet=(int)iomodel->gridonicesheet[i];   
     405
     406                if (strcmp(iomodel->meshtype,"3d")==0){
     407                        if (isnan(iomodel->uppernodes[i])){
    408408                                node_upper_node_id=node_id;  //nodes on surface do not have upper nodes, only themselves.
    409409                        }
    410410                        else{
    411                                 node_upper_node_id=(int)model->uppernodes[i];
     411                                node_upper_node_id=(int)iomodel->uppernodes[i];
    412412                        }
    413413                }
     
    421421
    422422                /*set single point constraints.: */
    423                 if (!model->gridonbed[i]){
     423                if (!iomodel->gridonbed[i]){
    424424                        for(k=1;k<=node_numdofs;k++){
    425425                                node->FreezeDof(k);
     
    441441
    442442        /*Clean fetched data: */
    443         xfree((void**)&model->deadgrids);
    444         xfree((void**)&model->x);
    445         xfree((void**)&model->y);
    446         xfree((void**)&model->z);
    447         xfree((void**)&model->thickness);
    448         xfree((void**)&model->bed);
    449         xfree((void**)&model->gridonbed);
    450         xfree((void**)&model->gridonsurface);
    451         xfree((void**)&model->uppernodes);
    452         xfree((void**)&model->gridonicesheet);
    453         xfree((void**)&model->gridoniceshelf);
    454 
    455         /*Keep partitioning information into model*/
    456         model->epart=epart;
    457         model->my_grids=my_grids;
    458         model->my_bordergrids=my_bordergrids;
     443        xfree((void**)&iomodel->deadgrids);
     444        xfree((void**)&iomodel->x);
     445        xfree((void**)&iomodel->y);
     446        xfree((void**)&iomodel->z);
     447        xfree((void**)&iomodel->thickness);
     448        xfree((void**)&iomodel->bed);
     449        xfree((void**)&iomodel->gridonbed);
     450        xfree((void**)&iomodel->gridonsurface);
     451        xfree((void**)&iomodel->uppernodes);
     452        xfree((void**)&iomodel->gridonicesheet);
     453        xfree((void**)&iomodel->gridoniceshelf);
     454
     455        /*Keep partitioning information into iomodel*/
     456        iomodel->epart=epart;
     457        iomodel->my_grids=my_grids;
     458        iomodel->my_bordergrids=my_bordergrids;
    459459
    460460        /*Free ressources:*/
  • issm/trunk/src/c/ModelProcessorx/Melting/CreateLoadsMelting.cpp

    r483 r1834  
    1111#include "../../shared/shared.h"
    1212#include "../../include/macros.h"
    13 #include "../Model.h"
     13#include "../IoModel.h"
    1414
    1515
    16 void    CreateLoadsMelting(DataSet** ploads, Model* model,ConstDataHandle model_handle){
     16void    CreateLoadsMelting(DataSet** ploads, IoModel* iomodel,ConstDataHandle iomodel_handle){
    1717
    1818        int i,j,counter;
     
    4646
    4747        //create penalties for grids: no grid can have a temperature over the melting point
    48         ModelFetchData((void**)&model->gridonbed,NULL,NULL,model_handle,"gridonbed","Matrix","Mat");
     48        IoModelFetchData((void**)&iomodel->gridonbed,NULL,NULL,iomodel_handle,"gridonbed","Matrix","Mat");
    4949
    50         for (i=0;i<model->numberofnodes;i++){
     50        for (i=0;i<iomodel->numberofnodes;i++){
    5151        #ifdef _PARALLEL_
    5252        /*keep only this partition's nodes:*/
    53         if((model->my_grids[i]==1)){
     53        if((iomodel->my_grids[i]==1)){
    5454        #endif
    5555
    56                 if (model->gridonbed[i]){
     56                if (iomodel->gridonbed[i]){
    5757               
    5858                        pengrid_id=count+1; //matlab indexing
    5959                        pengrid_node_id=i+1;
    6060                        pengrid_dof=1;
    61                         pengrid_penalty_offset=model->penalty_offset;
     61                        pengrid_penalty_offset=iomodel->penalty_offset;
    6262                        pengrid_active=0;
    63                         pengrid_mparid=model->numberofelements+1;//refers to the corresponding parmat property card
     63                        pengrid_mparid=iomodel->numberofelements+1;//refers to the corresponding parmat property card
    6464                       
    6565                        pengrid= new Pengrid(pengrid_id, pengrid_node_id,pengrid_mparid,pengrid_dof, pengrid_active, pengrid_penalty_offset,pengrid_thermal_steadystate);
     
    6969                }
    7070        #ifdef _PARALLEL_
    71         } //if((model->my_grids[i]==1))
     71        } //if((iomodel->my_grids[i]==1))
    7272        #endif
    7373        }
    74         xfree((void**)&model->gridonbed);
     74        xfree((void**)&iomodel->gridonbed);
    7575
    7676        /*All our datasets are already order by ids. Set presort flag so that later on, when sorting is requested on these
  • issm/trunk/src/c/ModelProcessorx/Melting/CreateParametersMelting.cpp

    r1648 r1834  
    1111#include "../../objects/objects.h"
    1212#include "../../shared/shared.h"
    13 #include "../Model.h"
     13#include "../IoModel.h"
    1414
    15 void CreateParametersMelting(DataSet** pparameters,Model* model,ConstDataHandle model_handle){
     15void CreateParametersMelting(DataSet** pparameters,IoModel* iomodel,ConstDataHandle iomodel_handle){
    1616       
    1717        Param*   param = NULL;
     
    2828
    2929        /* get initial melting if transient*/
    30         if(model->sub_analysis_type==TransientAnalysisEnum()){
     30        if(iomodel->sub_analysis_type==TransientAnalysisEnum()){
    3131
    3232                /*Get melting: */
    33                 ModelFetchData((void**)&melting,NULL,NULL,model_handle,"melting","Matrix","Mat");
     33                IoModelFetchData((void**)&melting,NULL,NULL,iomodel_handle,"melting","Matrix","Mat");
    3434                if(melting) {
    35                         for(i=0;i<model->numberofnodes;i++)melting[i]=melting[i]/model->yts;   //m/s instead of m/yr
     35                        for(i=0;i<iomodel->numberofnodes;i++)melting[i]=melting[i]/iomodel->yts;   //m/s instead of m/yr
    3636                }
    3737                else{
    38                         for(i=0;i<model->numberofnodes;i++)melting[i]=0;
     38                        for(i=0;i<iomodel->numberofnodes;i++)melting[i]=0;
    3939                }
    4040
    4141                count++;
    4242                param= new Param(count,"m_g",DOUBLEVEC);
    43                 if(melting) param->SetDoubleVec(melting,model->numberofnodes);
     43                if(melting) param->SetDoubleVec(melting,iomodel->numberofnodes);
    4444                else param->SetDoubleVec(melting,0);
    4545                parameters->AddObject(param);
  • issm/trunk/src/c/ModelProcessorx/Prognostic/CreateConstraintsPrognostic.cpp

    r1763 r1834  
    1111#include "../../objects/objects.h"
    1212#include "../../shared/shared.h"
    13 #include "../Model.h"
     13#include "../IoModel.h"
    1414
    1515
    16 void    CreateConstraintsPrognostic(DataSet** pconstraints, Model* model,ConstDataHandle model_handle){
     16void    CreateConstraintsPrognostic(DataSet** pconstraints, IoModel* iomodel,ConstDataHandle iomodel_handle){
    1717
    1818
     
    3535
    3636        /*Fetch data: */
    37         ModelFetchData((void**)&spcthickness,NULL,NULL,model_handle,"spcthickness","Matrix","Mat");
     37        IoModelFetchData((void**)&spcthickness,NULL,NULL,iomodel_handle,"spcthickness","Matrix","Mat");
    3838
    3939        count=0;
    4040
    4141        /*Create spcs from x,y,z, as well as the spc values on those spcs: */
    42         for (i=0;i<model->numberofnodes;i++){
     42        for (i=0;i<iomodel->numberofnodes;i++){
    4343        #ifdef _PARALLEL_
    4444        /*keep only this partition's nodes:*/
    45         if((model->my_grids[i]==1)){
     45        if((iomodel->my_grids[i]==1)){
    4646        #endif
    4747
  • issm/trunk/src/c/ModelProcessorx/Prognostic/CreateElementsNodesAndMaterialsPrognostic.cpp

    r1648 r1834  
    1212#include "../../shared/shared.h"
    1313#include "../../MeshPartitionx/MeshPartitionx.h"
    14 #include "../Model.h"
    15 
    16 
    17 void    CreateElementsNodesAndMaterialsPrognostic(DataSet** pelements,DataSet** pnodes, DataSet** pmaterials, Model* model,ConstDataHandle model_handle){
     14#include "../IoModel.h"
     15
     16
     17void    CreateElementsNodesAndMaterialsPrognostic(DataSet** pelements,DataSet** pnodes, DataSet** pmaterials, IoModel* iomodel,ConstDataHandle iomodel_handle){
    1818
    1919
     
    146146
    147147        /*Width of elements: */
    148         if(strcmp(model->meshtype,"2d")==0){
     148        if(strcmp(iomodel->meshtype,"2d")==0){
    149149                elements_width=3; //tria elements
    150150        }
     
    155155        #ifdef _PARALLEL_
    156156        /*Determine parallel partitioning of elements: we use Metis for now. First load the data, then partition*/
    157         if(strcmp(model->meshtype,"2d")==0){
     157        if(strcmp(iomodel->meshtype,"2d")==0){
    158158                /*load elements: */
    159                 ModelFetchData((void**)&model->elements,NULL,NULL,model_handle,"elements","Matrix","Mat");
     159                IoModelFetchData((void**)&iomodel->elements,NULL,NULL,iomodel_handle,"elements","Matrix","Mat");
    160160        }
    161161        else{
    162162                /*load elements2d: */
    163                 ModelFetchData((void**)&model->elements2d,NULL,NULL,model_handle,"elements2d","Matrix","Mat");
    164         }
    165 
    166 
    167         MeshPartitionx(&epart, &npart,model->numberofelements,model->numberofnodes,model->elements, model->numberofelements2d,model->numberofnodes2d,model->elements2d,model->numlayers,elements_width, model->meshtype,num_procs);
     163                IoModelFetchData((void**)&iomodel->elements2d,NULL,NULL,iomodel_handle,"elements2d","Matrix","Mat");
     164        }
     165
     166
     167        MeshPartitionx(&epart, &npart,iomodel->numberofelements,iomodel->numberofnodes,iomodel->elements, iomodel->numberofelements2d,iomodel->numberofnodes2d,iomodel->elements2d,iomodel->numlayers,elements_width, iomodel->meshtype,num_procs);
    168168
    169169        /*Free elements and elements2d: */
    170         xfree((void**)&model->elements);
    171         xfree((void**)&model->elements2d);
     170        xfree((void**)&iomodel->elements);
     171        xfree((void**)&iomodel->elements2d);
    172172
    173173        /*Used later on: */
    174         my_grids=(int*)xcalloc(model->numberofnodes,sizeof(int));
     174        my_grids=(int*)xcalloc(iomodel->numberofnodes,sizeof(int));
    175175        #endif
    176176
     
    180180
    181181        /*2d mesh: */
    182         if (strcmp(model->meshtype,"2d")==0){
     182        if (strcmp(iomodel->meshtype,"2d")==0){
    183183
    184184                /*Fetch data needed: */
    185                 ModelFetchData((void**)&model->elements,NULL,NULL,model_handle,"elements","Matrix","Mat");
    186                 ModelFetchData((void**)&model->thickness,NULL,NULL,model_handle,"thickness","Matrix","Mat");
    187                 ModelFetchData((void**)&model->surface,NULL,NULL,model_handle,"surface","Matrix","Mat");
    188                 ModelFetchData((void**)&model->bed,NULL,NULL,model_handle,"bed","Matrix","Mat");
    189                 ModelFetchData((void**)&model->elementoniceshelf,NULL,NULL,model_handle,"elementoniceshelf","Matrix","Mat");
    190                 ModelFetchData((void**)&model->elementonwater,NULL,NULL,model_handle,"elementonwater","Matrix","Mat");
    191                
    192                 for (i=0;i<model->numberofelements;i++){
     185                IoModelFetchData((void**)&iomodel->elements,NULL,NULL,iomodel_handle,"elements","Matrix","Mat");
     186                IoModelFetchData((void**)&iomodel->thickness,NULL,NULL,iomodel_handle,"thickness","Matrix","Mat");
     187                IoModelFetchData((void**)&iomodel->surface,NULL,NULL,iomodel_handle,"surface","Matrix","Mat");
     188                IoModelFetchData((void**)&iomodel->bed,NULL,NULL,iomodel_handle,"bed","Matrix","Mat");
     189                IoModelFetchData((void**)&iomodel->elementoniceshelf,NULL,NULL,iomodel_handle,"elementoniceshelf","Matrix","Mat");
     190                IoModelFetchData((void**)&iomodel->elementonwater,NULL,NULL,iomodel_handle,"elementonwater","Matrix","Mat");
     191               
     192                for (i=0;i<iomodel->numberofelements;i++){
    193193
    194194                #ifdef _PARALLEL_
     
    204204
    205205                        /*vertices offsets: */
    206                         tria_g[0]=(int)*(model->elements+elements_width*i+0);
    207                         tria_g[1]=(int)*(model->elements+elements_width*i+1);
    208                         tria_g[2]=(int)*(model->elements+elements_width*i+2);
     206                        tria_g[0]=(int)*(iomodel->elements+elements_width*i+0);
     207                        tria_g[1]=(int)*(iomodel->elements+elements_width*i+1);
     208                        tria_g[2]=(int)*(iomodel->elements+elements_width*i+2);
    209209
    210210                        /*thickness,surface and bed:*/
    211                         tria_h[0]= *(model->thickness+ ((int)*(model->elements+elements_width*i+0)-1)); //remember, elements is an index of vertices offsets, in matlab indexing.
    212                         tria_h[1]=*(model->thickness+  ((int)*(model->elements+elements_width*i+1)-1));
    213                         tria_h[2]=*(model->thickness+  ((int)*(model->elements+elements_width*i+2)-1)) ;
    214 
    215                         tria_s[0]=*(model->surface+    ((int)*(model->elements+elements_width*i+0)-1));
    216                         tria_s[1]=*(model->surface+    ((int)*(model->elements+elements_width*i+1)-1));
    217                         tria_s[2]=*(model->surface+    ((int)*(model->elements+elements_width*i+2)-1));
    218 
    219                         tria_b[0]=*(model->bed+        ((int)*(model->elements+elements_width*i+0)-1));
    220                         tria_b[1]=*(model->bed+        ((int)*(model->elements+elements_width*i+1)-1));
    221                         tria_b[2]=*(model->bed+        ((int)*(model->elements+elements_width*i+2)-1));
     211                        tria_h[0]= *(iomodel->thickness+ ((int)*(iomodel->elements+elements_width*i+0)-1)); //remember, elements is an index of vertices offsets, in matlab indexing.
     212                        tria_h[1]=*(iomodel->thickness+  ((int)*(iomodel->elements+elements_width*i+1)-1));
     213                        tria_h[2]=*(iomodel->thickness+  ((int)*(iomodel->elements+elements_width*i+2)-1)) ;
     214
     215                        tria_s[0]=*(iomodel->surface+    ((int)*(iomodel->elements+elements_width*i+0)-1));
     216                        tria_s[1]=*(iomodel->surface+    ((int)*(iomodel->elements+elements_width*i+1)-1));
     217                        tria_s[2]=*(iomodel->surface+    ((int)*(iomodel->elements+elements_width*i+2)-1));
     218
     219                        tria_b[0]=*(iomodel->bed+        ((int)*(iomodel->elements+elements_width*i+0)-1));
     220                        tria_b[1]=*(iomodel->bed+        ((int)*(iomodel->elements+elements_width*i+1)-1));
     221                        tria_b[2]=*(iomodel->bed+        ((int)*(iomodel->elements+elements_width*i+2)-1));
    222222
    223223                        /*element on iceshelf?:*/
    224                         tria_shelf=(int)*(model->elementoniceshelf+i);
    225                         tria_onwater=(bool)*(model->elementonwater+i);
    226                         tria_artdiff=model->artificial_diffusivity;
     224                        tria_shelf=(int)*(iomodel->elementoniceshelf+i);
     225                        tria_onwater=(bool)*(iomodel->elementonwater+i);
     226                        tria_artdiff=iomodel->artificial_diffusivity;
    227227
    228228                        /*Create tria element using its constructor:*/
     
    237237                         into the grid coordinates. If we start plugging 1 into my_grids for each index[n][i] (i=0:2), then my_grids
    238238                         will hold which grids belong to this partition*/
    239                         my_grids[(int)*(model->elements+elements_width*i+0)-1]=1;
    240                         my_grids[(int)*(model->elements+elements_width*i+1)-1]=1;
    241                         my_grids[(int)*(model->elements+elements_width*i+2)-1]=1;
     239                        my_grids[(int)*(iomodel->elements+elements_width*i+0)-1]=1;
     240                        my_grids[(int)*(iomodel->elements+elements_width*i+1)-1]=1;
     241                        my_grids[(int)*(iomodel->elements+elements_width*i+2)-1]=1;
    242242                        #endif
    243243
     
    250250       
    251251                /*Free data : */
    252                 xfree((void**)&model->elements);
    253                 xfree((void**)&model->thickness);
    254                 xfree((void**)&model->surface);
    255                 xfree((void**)&model->bed);
    256                 xfree((void**)&model->elementoniceshelf);
    257                 xfree((void**)&model->elementonwater);
     252                xfree((void**)&iomodel->elements);
     253                xfree((void**)&iomodel->thickness);
     254                xfree((void**)&iomodel->surface);
     255                xfree((void**)&iomodel->bed);
     256                xfree((void**)&iomodel->elementoniceshelf);
     257                xfree((void**)&iomodel->elementonwater);
    258258
    259259        }
     
    261261
    262262                /*Fetch data needed: */
    263                 ModelFetchData((void**)&model->elements,NULL,NULL,model_handle,"elements","Matrix","Mat");
    264                 ModelFetchData((void**)&model->thickness,NULL,NULL,model_handle,"thickness","Matrix","Mat");
    265                 ModelFetchData((void**)&model->surface,NULL,NULL,model_handle,"surface","Matrix","Mat");
    266                 ModelFetchData((void**)&model->bed,NULL,NULL,model_handle,"bed","Matrix","Mat");
    267                 ModelFetchData((void**)&model->elementoniceshelf,NULL,NULL,model_handle,"elementoniceshelf","Matrix","Mat");
    268                 ModelFetchData((void**)&model->elementonbed,NULL,NULL,model_handle,"elementonbed","Matrix","Mat");
    269                 ModelFetchData((void**)&model->elementonsurface,NULL,NULL,model_handle,"elementonsurface","Matrix","Mat");
    270                 ModelFetchData((void**)&model->elementonwater,NULL,NULL,model_handle,"elementonwater","Matrix","Mat");
    271        
    272                 for (i=0;i<model->numberofelements;i++){
     263                IoModelFetchData((void**)&iomodel->elements,NULL,NULL,iomodel_handle,"elements","Matrix","Mat");
     264                IoModelFetchData((void**)&iomodel->thickness,NULL,NULL,iomodel_handle,"thickness","Matrix","Mat");
     265                IoModelFetchData((void**)&iomodel->surface,NULL,NULL,iomodel_handle,"surface","Matrix","Mat");
     266                IoModelFetchData((void**)&iomodel->bed,NULL,NULL,iomodel_handle,"bed","Matrix","Mat");
     267                IoModelFetchData((void**)&iomodel->elementoniceshelf,NULL,NULL,iomodel_handle,"elementoniceshelf","Matrix","Mat");
     268                IoModelFetchData((void**)&iomodel->elementonbed,NULL,NULL,iomodel_handle,"elementonbed","Matrix","Mat");
     269                IoModelFetchData((void**)&iomodel->elementonsurface,NULL,NULL,iomodel_handle,"elementonsurface","Matrix","Mat");
     270                IoModelFetchData((void**)&iomodel->elementonwater,NULL,NULL,iomodel_handle,"elementonwater","Matrix","Mat");
     271       
     272                for (i=0;i<iomodel->numberofelements;i++){
    273273                #ifdef _PARALLEL_
    274274                /*We are using our element partition to decide which elements will be created on this node: */
     
    284284                        /*vertices,thickness,surface,bed and drag: */
    285285                        for(j=0;j<6;j++){
    286                                 penta_g[j]=(int)*(model->elements+elements_width*i+j);
    287                                 penta_h[j]=*(model->thickness+    ((int)*(model->elements+elements_width*i+j)-1));
    288                                 penta_s[j]=*(model->surface+    ((int)*(model->elements+elements_width*i+j)-1));
    289                                 penta_b[j]=*(model->bed+    ((int)*(model->elements+elements_width*i+j)-1));
     286                                penta_g[j]=(int)*(iomodel->elements+elements_width*i+j);
     287                                penta_h[j]=*(iomodel->thickness+    ((int)*(iomodel->elements+elements_width*i+j)-1));
     288                                penta_s[j]=*(iomodel->surface+    ((int)*(iomodel->elements+elements_width*i+j)-1));
     289                                penta_b[j]=*(iomodel->bed+    ((int)*(iomodel->elements+elements_width*i+j)-1));
    290290                        }
    291291
    292292                        /*diverse: */
    293                         penta_shelf=(int)*(model->elementoniceshelf+i);
    294                         penta_onbed=(int)*(model->elementonbed+i);
    295                         penta_onsurface=(int)*(model->elementonsurface+i);
     293                        penta_shelf=(int)*(iomodel->elementoniceshelf+i);
     294                        penta_onbed=(int)*(iomodel->elementonbed+i);
     295                        penta_onsurface=(int)*(iomodel->elementonsurface+i);
    296296                        penta_collapse=1;
    297                         penta_artdiff=model->artificial_diffusivity;
    298                         penta_onwater=(bool)*(model->elementonwater+i);
     297                        penta_artdiff=iomodel->artificial_diffusivity;
     298                        penta_onwater=(bool)*(iomodel->elementonwater+i);
    299299       
    300300
     
    313313                         into the grid coordinates. If we start plugging 1 into my_grids for each index[n][i] (i=0:2), then my_grids
    314314                         will hold which grids belong to this partition*/
    315                         my_grids[(int)*(model->elements+elements_width*i+0)-1]=1;
    316                         my_grids[(int)*(model->elements+elements_width*i+1)-1]=1;
    317                         my_grids[(int)*(model->elements+elements_width*i+2)-1]=1;
    318                         my_grids[(int)*(model->elements+elements_width*i+3)-1]=1;
    319                         my_grids[(int)*(model->elements+elements_width*i+4)-1]=1;
    320                         my_grids[(int)*(model->elements+elements_width*i+5)-1]=1;
     315                        my_grids[(int)*(iomodel->elements+elements_width*i+0)-1]=1;
     316                        my_grids[(int)*(iomodel->elements+elements_width*i+1)-1]=1;
     317                        my_grids[(int)*(iomodel->elements+elements_width*i+2)-1]=1;
     318                        my_grids[(int)*(iomodel->elements+elements_width*i+3)-1]=1;
     319                        my_grids[(int)*(iomodel->elements+elements_width*i+4)-1]=1;
     320                        my_grids[(int)*(iomodel->elements+elements_width*i+5)-1]=1;
    321321                        #endif
    322322
     
    328328
    329329                /*Free data: */
    330                 xfree((void**)&model->elements);
    331                 xfree((void**)&model->thickness);
    332                 xfree((void**)&model->surface);
    333                 xfree((void**)&model->bed);
    334                 xfree((void**)&model->elementoniceshelf);
    335                 xfree((void**)&model->elementonbed);
    336                 xfree((void**)&model->elementonsurface);
    337                 xfree((void**)&model->elementonwater);
     330                xfree((void**)&iomodel->elements);
     331                xfree((void**)&iomodel->thickness);
     332                xfree((void**)&iomodel->surface);
     333                xfree((void**)&iomodel->bed);
     334                xfree((void**)&iomodel->elementoniceshelf);
     335                xfree((void**)&iomodel->elementonbed);
     336                xfree((void**)&iomodel->elementonsurface);
     337                xfree((void**)&iomodel->elementonwater);
    338338
    339339        } //if (strcmp(meshtype,"2d")==0)
     
    342342                /*From the element partitioning, we can determine which grids are on the inside of this cpu's
    343343                 *element partition, and which are on its border with other nodes:*/
    344                 gridborder=NewVec(model->numberofnodes);
    345 
    346                 for (i=0;i<model->numberofnodes;i++){
     344                gridborder=NewVec(iomodel->numberofnodes);
     345
     346                for (i=0;i<iomodel->numberofnodes;i++){
    347347                        if(my_grids[i])VecSetValue(gridborder,i,1,ADD_VALUES);
    348348                }
     
    358358                #ifdef _DEBUG_
    359359                if(my_rank==0){
    360                         for (i=0;i<model->numberofnodes;i++){
     360                        for (i=0;i<iomodel->numberofnodes;i++){
    361361                                printf("Grid id %i Border grid %lf\n",i+1,my_bordergrids[i]);
    362362                        }
     
    367367        /*Add one constant material property to materials: */
    368368        matpar_mid=1; //put it at the end of the materials
    369         matpar_g=model->g;
    370         matpar_rho_ice=model->rho_ice;
    371         matpar_rho_water=model->rho_water;
    372         matpar_thermalconductivity=model->thermalconductivity;
    373         matpar_heatcapacity=model->heatcapacity;
    374         matpar_latentheat=model->latentheat;
    375         matpar_beta=model->beta;
    376         matpar_meltingpoint=model->meltingpoint;
    377         matpar_mixed_layer_capacity=model->mixed_layer_capacity;
    378         matpar_thermal_exchange_velocity=model->thermal_exchange_velocity;
     369        matpar_g=iomodel->g;
     370        matpar_rho_ice=iomodel->rho_ice;
     371        matpar_rho_water=iomodel->rho_water;
     372        matpar_thermalconductivity=iomodel->thermalconductivity;
     373        matpar_heatcapacity=iomodel->heatcapacity;
     374        matpar_latentheat=iomodel->latentheat;
     375        matpar_beta=iomodel->beta;
     376        matpar_meltingpoint=iomodel->meltingpoint;
     377        matpar_mixed_layer_capacity=iomodel->mixed_layer_capacity;
     378        matpar_thermal_exchange_velocity=iomodel->thermal_exchange_velocity;
    379379
    380380        /*Create matpar object using its constructor: */
     
    387387
    388388        /*Partition penalties in 3d: */
    389         if(strcmp(model->meshtype,"3d")==0){
     389        if(strcmp(iomodel->meshtype,"3d")==0){
    390390       
    391391                /*Get penalties: */
    392                 ModelFetchData((void**)&model->penalties,&model->numpenalties,NULL,model_handle,"penalties","Matrix","Mat");
    393 
    394                 if(model->numpenalties){
    395 
    396                         model->penaltypartitioning=(int*)xmalloc(model->numpenalties*sizeof(int));
     392                IoModelFetchData((void**)&iomodel->penalties,&iomodel->numpenalties,NULL,iomodel_handle,"penalties","Matrix","Mat");
     393
     394                if(iomodel->numpenalties){
     395
     396                        iomodel->penaltypartitioning=(int*)xmalloc(iomodel->numpenalties*sizeof(int));
    397397                        #ifdef _SERIAL_
    398                         for(i=0;i<model->numpenalties;i++)model->penaltypartitioning[i]=1;
     398                        for(i=0;i<iomodel->numpenalties;i++)iomodel->penaltypartitioning[i]=1;
    399399                        #else
    400                         for(i=0;i<model->numpenalties;i++)model->penaltypartitioning[i]=-1;
    401 
    402                         for(i=0;i<model->numpenalties;i++){
    403                                 first_grid_index=(int)(*(model->penalties+i*model->numlayers+0)-1);
     400                        for(i=0;i<iomodel->numpenalties;i++)iomodel->penaltypartitioning[i]=-1;
     401
     402                        for(i=0;i<iomodel->numpenalties;i++){
     403                                first_grid_index=(int)(*(iomodel->penalties+i*iomodel->numlayers+0)-1);
    404404                                if((my_grids[first_grid_index]==1) && (my_bordergrids[first_grid_index]<=1.0) ) { //this grid belongs to this node's internal partition  grids
    405405                                        /*All grids that are being penalised belong to this node's internal grid partition.:*/
    406                                         model->penaltypartitioning[i]=1;
     406                                        iomodel->penaltypartitioning[i]=1;
    407407                                }
    408408                                if(my_bordergrids[first_grid_index]>1.0) { //this grid belongs to a partition border
    409                                         model->penaltypartitioning[i]=0;
     409                                        iomodel->penaltypartitioning[i]=0;
    410410                                }
    411411                        }
     
    414414
    415415                /*Free penalties: */
    416                 xfree((void**)&model->penalties);
     416                xfree((void**)&iomodel->penalties);
    417417        }
    418418
     
    425425               
    426426        /*First fetch data: */
    427         if (strcmp(model->meshtype,"3d")==0){
    428                 ModelFetchData((void**)&model->deadgrids,NULL,NULL,model_handle,"deadgrids","Matrix","Mat");
    429                 ModelFetchData((void**)&model->uppernodes,NULL,NULL,model_handle,"uppergrids","Matrix","Mat");
    430         }
    431         ModelFetchData((void**)&model->x,NULL,NULL,model_handle,"x","Matrix","Mat");
    432         ModelFetchData((void**)&model->y,NULL,NULL,model_handle,"y","Matrix","Mat");
    433         ModelFetchData((void**)&model->z,NULL,NULL,model_handle,"z","Matrix","Mat");
    434         ModelFetchData((void**)&model->thickness,NULL,NULL,model_handle,"thickness","Matrix","Mat");
    435         ModelFetchData((void**)&model->bed,NULL,NULL,model_handle,"bed","Matrix","Mat");
    436         ModelFetchData((void**)&model->gridonbed,NULL,NULL,model_handle,"gridonbed","Matrix","Mat");
    437         ModelFetchData((void**)&model->gridonsurface,NULL,NULL,model_handle,"gridonsurface","Matrix","Mat");
    438         ModelFetchData((void**)&model->gridonicesheet,NULL,NULL,model_handle,"gridonicesheet","Matrix","Mat");
    439         ModelFetchData((void**)&model->gridoniceshelf,NULL,NULL,model_handle,"gridoniceshelf","Matrix","Mat");
     427        if (strcmp(iomodel->meshtype,"3d")==0){
     428                IoModelFetchData((void**)&iomodel->deadgrids,NULL,NULL,iomodel_handle,"deadgrids","Matrix","Mat");
     429                IoModelFetchData((void**)&iomodel->uppernodes,NULL,NULL,iomodel_handle,"uppergrids","Matrix","Mat");
     430        }
     431        IoModelFetchData((void**)&iomodel->x,NULL,NULL,iomodel_handle,"x","Matrix","Mat");
     432        IoModelFetchData((void**)&iomodel->y,NULL,NULL,iomodel_handle,"y","Matrix","Mat");
     433        IoModelFetchData((void**)&iomodel->z,NULL,NULL,iomodel_handle,"z","Matrix","Mat");
     434        IoModelFetchData((void**)&iomodel->thickness,NULL,NULL,iomodel_handle,"thickness","Matrix","Mat");
     435        IoModelFetchData((void**)&iomodel->bed,NULL,NULL,iomodel_handle,"bed","Matrix","Mat");
     436        IoModelFetchData((void**)&iomodel->gridonbed,NULL,NULL,iomodel_handle,"gridonbed","Matrix","Mat");
     437        IoModelFetchData((void**)&iomodel->gridonsurface,NULL,NULL,iomodel_handle,"gridonsurface","Matrix","Mat");
     438        IoModelFetchData((void**)&iomodel->gridonicesheet,NULL,NULL,iomodel_handle,"gridonicesheet","Matrix","Mat");
     439        IoModelFetchData((void**)&iomodel->gridoniceshelf,NULL,NULL,iomodel_handle,"gridoniceshelf","Matrix","Mat");
    440440
    441441
    442442        /*Get number of dofs per node: */
    443         DistributeNumDofs(&node_numdofs,model->analysis_type,model->sub_analysis_type);
    444 
    445         for (i=0;i<model->numberofnodes;i++){
     443        DistributeNumDofs(&node_numdofs,iomodel->analysis_type,iomodel->sub_analysis_type);
     444
     445        for (i=0;i<iomodel->numberofnodes;i++){
    446446        #ifdef _PARALLEL_
    447447        /*keep only this partition's nodes:*/
     
    464464                #endif
    465465
    466                 node_x[0]=model->x[i];
    467                 node_x[1]=model->y[i];
    468                 node_x[2]=model->z[i];
    469                 node_sigma=(model->z[i]-model->bed[i])/(model->thickness[i]);
    470                
    471                 node_onbed=(int)model->gridonbed[i];
    472                 node_onsurface=(int)model->gridonsurface[i];   
    473                 node_onshelf=(int)model->gridoniceshelf[i];     
    474                 node_onsheet=(int)model->gridonicesheet[i];     
    475 
    476                 if (strcmp(model->meshtype,"3d")==0){
    477                         if (isnan(model->uppernodes[i])){
     466                node_x[0]=iomodel->x[i];
     467                node_x[1]=iomodel->y[i];
     468                node_x[2]=iomodel->z[i];
     469                node_sigma=(iomodel->z[i]-iomodel->bed[i])/(iomodel->thickness[i]);
     470               
     471                node_onbed=(int)iomodel->gridonbed[i];
     472                node_onsurface=(int)iomodel->gridonsurface[i]; 
     473                node_onshelf=(int)iomodel->gridoniceshelf[i];   
     474                node_onsheet=(int)iomodel->gridonicesheet[i];   
     475
     476                if (strcmp(iomodel->meshtype,"3d")==0){
     477                        if (isnan(iomodel->uppernodes[i])){
    478478                                node_upper_node_id=node_id;  //nodes on surface do not have upper nodes, only themselves.
    479479                        }
    480480                        else{
    481                                 node_upper_node_id=(int)model->uppernodes[i];
     481                                node_upper_node_id=(int)iomodel->uppernodes[i];
    482482                        }
    483483                }
     
    491491
    492492                /*set single point constraints.: */
    493                 if (strcmp(model->meshtype,"3d")==0){
     493                if (strcmp(iomodel->meshtype,"3d")==0){
    494494                        /*On a 3d mesh, we may have collapsed elements, hence dead grids. Freeze them out: */
    495                         if (!model->gridonbed[i]){
     495                        if (!iomodel->gridonbed[i]){
    496496                                for(k=1;k<=node_numdofs;k++){
    497497                                        node->FreezeDof(k);
     
    514514
    515515        /*Clean fetched data: */
    516         xfree((void**)&model->deadgrids);
    517         xfree((void**)&model->x);
    518         xfree((void**)&model->y);
    519         xfree((void**)&model->z);
    520         xfree((void**)&model->thickness);
    521         xfree((void**)&model->bed);
    522         xfree((void**)&model->gridonbed);
    523         xfree((void**)&model->gridonsurface);
    524         xfree((void**)&model->uppernodes);
    525         xfree((void**)&model->gridonicesheet);
    526         xfree((void**)&model->gridoniceshelf);
    527        
    528 
    529         /*Keep partitioning information into model*/
    530         model->epart=epart;
    531         model->my_grids=my_grids;
    532         model->my_bordergrids=my_bordergrids;
     516        xfree((void**)&iomodel->deadgrids);
     517        xfree((void**)&iomodel->x);
     518        xfree((void**)&iomodel->y);
     519        xfree((void**)&iomodel->z);
     520        xfree((void**)&iomodel->thickness);
     521        xfree((void**)&iomodel->bed);
     522        xfree((void**)&iomodel->gridonbed);
     523        xfree((void**)&iomodel->gridonsurface);
     524        xfree((void**)&iomodel->uppernodes);
     525        xfree((void**)&iomodel->gridonicesheet);
     526        xfree((void**)&iomodel->gridoniceshelf);
     527       
     528
     529        /*Keep partitioning information into iomodel*/
     530        iomodel->epart=epart;
     531        iomodel->my_grids=my_grids;
     532        iomodel->my_bordergrids=my_bordergrids;
    533533
    534534        /*Free ressources:*/
  • issm/trunk/src/c/ModelProcessorx/Prognostic/CreateLoadsPrognostic.cpp

    r586 r1834  
    1111#include "../../shared/shared.h"
    1212#include "../../include/macros.h"
    13 #include "../Model.h"
     13#include "../IoModel.h"
    1414
    1515
    16 void    CreateLoadsPrognostic(DataSet** ploads, Model* model,ConstDataHandle model_handle){
     16void    CreateLoadsPrognostic(DataSet** ploads, IoModel* iomodel,ConstDataHandle iomodel_handle){
    1717
    1818        DataSet*    loads    = NULL;
  • issm/trunk/src/c/ModelProcessorx/Prognostic/CreateParametersPrognostic.cpp

    r1096 r1834  
    1111#include "../../objects/objects.h"
    1212#include "../../shared/shared.h"
    13 #include "../Model.h"
     13#include "../IoModel.h"
    1414
    15 void CreateParametersPrognostic(DataSet** pparameters,Model* model,ConstDataHandle model_handle){
     15void CreateParametersPrognostic(DataSet** pparameters,IoModel* iomodel,ConstDataHandle iomodel_handle){
    1616       
    1717        Param*   param = NULL;
     
    3939
    4040        /*Get vx and vy: */
    41         ModelFetchData((void**)&vx,NULL,NULL,model_handle,"vx","Matrix","Mat");
    42         ModelFetchData((void**)&vy,NULL,NULL,model_handle,"vy","Matrix","Mat");
    43         ModelFetchData((void**)&vz,NULL,NULL,model_handle,"vz","Matrix","Mat");
     41        IoModelFetchData((void**)&vx,NULL,NULL,iomodel_handle,"vx","Matrix","Mat");
     42        IoModelFetchData((void**)&vy,NULL,NULL,iomodel_handle,"vy","Matrix","Mat");
     43        IoModelFetchData((void**)&vz,NULL,NULL,iomodel_handle,"vz","Matrix","Mat");
    4444
    45         u_g=(double*)xcalloc(model->numberofnodes*3,sizeof(double));
     45        u_g=(double*)xcalloc(iomodel->numberofnodes*3,sizeof(double));
    4646
    47         if(vx) for(i=0;i<model->numberofnodes;i++)u_g[3*i+0]=vx[i]/model->yts;
    48         if(vy) for(i=0;i<model->numberofnodes;i++)u_g[3*i+1]=vy[i]/model->yts;
    49         if(vz) for(i=0;i<model->numberofnodes;i++)u_g[3*i+2]=vz[i]/model->yts;
     47        if(vx) for(i=0;i<iomodel->numberofnodes;i++)u_g[3*i+0]=vx[i]/iomodel->yts;
     48        if(vy) for(i=0;i<iomodel->numberofnodes;i++)u_g[3*i+1]=vy[i]/iomodel->yts;
     49        if(vz) for(i=0;i<iomodel->numberofnodes;i++)u_g[3*i+2]=vz[i]/iomodel->yts;
    5050
    5151        count++;
    5252        param= new Param(count,"u_g",DOUBLEVEC);
    53         param->SetDoubleVec(u_g,3*model->numberofnodes,3);
     53        param->SetDoubleVec(u_g,3*iomodel->numberofnodes,3);
    5454        parameters->AddObject(param);
    5555
     
    6060        xfree((void**)&u_g);
    6161
    62         /*Get pressure if 3d model: */
     62        /*Get pressure if 3d iomodel: */
    6363        parameters->FindParam((void*)&dim,"dim");
    6464        if (dim==3){
    65                 ModelFetchData((void**)&pressure,NULL,NULL,model_handle,"pressure","Matrix","Mat");
     65                IoModelFetchData((void**)&pressure,NULL,NULL,iomodel_handle,"pressure","Matrix","Mat");
    6666               
    6767                count++;
    6868                param= new Param(count,"p_g",DOUBLEVEC);
    69                 if(pressure) param->SetDoubleVec(pressure,model->numberofnodes,1);
     69                if(pressure) param->SetDoubleVec(pressure,iomodel->numberofnodes,1);
    7070                else param->SetDoubleVec(pressure,0,0);
    7171                parameters->AddObject(param);
     
    7575        }
    7676
    77         /*Get temperature if 3d model: */
     77        /*Get temperature if 3d iomodel: */
    7878        parameters->FindParam((void*)&dim,"dim");
    7979        if (dim==3){
    80                 ModelFetchData((void**)&temperature,NULL,NULL,model_handle,"temperature","Matrix","Mat");
     80                IoModelFetchData((void**)&temperature,NULL,NULL,iomodel_handle,"temperature","Matrix","Mat");
    8181               
    8282                count++;
    8383                param= new Param(count,"t_g",DOUBLEVEC);
    84                 if(temperature) param->SetDoubleVec(temperature,model->numberofnodes,1);
     84                if(temperature) param->SetDoubleVec(temperature,iomodel->numberofnodes,1);
    8585                else param->SetDoubleVec(temperature,0,0);
    8686                parameters->AddObject(param);
     
    9191
    9292        /*Get thickness: */
    93         ModelFetchData((void**)&thickness,NULL,NULL,model_handle,"thickness","Matrix","Mat");
     93        IoModelFetchData((void**)&thickness,NULL,NULL,iomodel_handle,"thickness","Matrix","Mat");
    9494       
    9595        count++;
    9696        param= new Param(count,"h_g",DOUBLEVEC);
    97         if(thickness) param->SetDoubleVec(thickness,model->numberofnodes,1);
     97        if(thickness) param->SetDoubleVec(thickness,iomodel->numberofnodes,1);
    9898        else param->SetDoubleVec(thickness,0,0);
    9999        parameters->AddObject(param);
     
    103103
    104104        /*Get surface: */
    105         ModelFetchData((void**)&surface,NULL,NULL,model_handle,"surface","Matrix","Mat");
     105        IoModelFetchData((void**)&surface,NULL,NULL,iomodel_handle,"surface","Matrix","Mat");
    106106       
    107107        count++;
    108108        param= new Param(count,"s_g",DOUBLEVEC);
    109         if(surface) param->SetDoubleVec(surface,model->numberofnodes,1);
     109        if(surface) param->SetDoubleVec(surface,iomodel->numberofnodes,1);
    110110        else param->SetDoubleVec(surface,0,0);
    111111        parameters->AddObject(param);
     
    115115
    116116        /*Get bed: */
    117         ModelFetchData((void**)&bed,NULL,NULL,model_handle,"bed","Matrix","Mat");
     117        IoModelFetchData((void**)&bed,NULL,NULL,iomodel_handle,"bed","Matrix","Mat");
    118118       
    119119        count++;
    120120        param= new Param(count,"b_g",DOUBLEVEC);
    121         if(bed) param->SetDoubleVec(bed,model->numberofnodes,1);
     121        if(bed) param->SetDoubleVec(bed,iomodel->numberofnodes,1);
    122122        else param->SetDoubleVec(bed,0,0);
    123123        parameters->AddObject(param);
     
    127127
    128128        /*Get melting: */
    129         ModelFetchData((void**)&melting,NULL,NULL,model_handle,"melting","Matrix","Mat");
    130         if(melting) for(i=0;i<model->numberofnodes;i++)melting[i]=melting[i]/model->yts;
     129        IoModelFetchData((void**)&melting,NULL,NULL,iomodel_handle,"melting","Matrix","Mat");
     130        if(melting) for(i=0;i<iomodel->numberofnodes;i++)melting[i]=melting[i]/iomodel->yts;
    131131       
    132132        count++;
    133133        param= new Param(count,"m_g",DOUBLEVEC);
    134         if(melting) param->SetDoubleVec(melting,model->numberofnodes,1);
     134        if(melting) param->SetDoubleVec(melting,iomodel->numberofnodes,1);
    135135        else param->SetDoubleVec(melting,0,1);
    136136        parameters->AddObject(param);
     
    140140
    141141        /*Get accumulation: */
    142         ModelFetchData((void**)&accumulation,NULL,NULL,model_handle,"accumulation","Matrix","Mat");
    143         if(accumulation) for(i=0;i<model->numberofnodes;i++)accumulation[i]=accumulation[i]/model->yts;
     142        IoModelFetchData((void**)&accumulation,NULL,NULL,iomodel_handle,"accumulation","Matrix","Mat");
     143        if(accumulation) for(i=0;i<iomodel->numberofnodes;i++)accumulation[i]=accumulation[i]/iomodel->yts;
    144144       
    145145        count++;
    146146        param= new Param(count,"a_g",DOUBLEVEC);
    147         if(accumulation) param->SetDoubleVec(accumulation,model->numberofnodes,1);
     147        if(accumulation) param->SetDoubleVec(accumulation,iomodel->numberofnodes,1);
    148148        else param->SetDoubleVec(accumulation,0,0);
    149149        parameters->AddObject(param);
  • issm/trunk/src/c/ModelProcessorx/Thermal/CreateConstraintsThermal.cpp

    r1765 r1834  
    1111#include "../../objects/objects.h"
    1212#include "../../shared/shared.h"
    13 #include "../Model.h"
     13#include "../IoModel.h"
    1414
    1515
    16 void    CreateConstraintsThermal(DataSet** pconstraints, Model* model,ConstDataHandle model_handle){
     16void    CreateConstraintsThermal(DataSet** pconstraints, IoModel* iomodel,ConstDataHandle iomodel_handle){
    1717
    1818
     
    3535
    3636        /*Fetch data: */
    37         ModelFetchData((void**)&spctemperature,NULL,NULL,model_handle,"spctemperature","Matrix","Mat");
     37        IoModelFetchData((void**)&spctemperature,NULL,NULL,iomodel_handle,"spctemperature","Matrix","Mat");
    3838
    3939        count=0;
    4040
    4141        /*Create spcs from x,y,z, as well as the spc values on those spcs: */
    42         for (i=0;i<model->numberofnodes;i++){
     42        for (i=0;i<iomodel->numberofnodes;i++){
    4343        #ifdef _PARALLEL_
    4444        /*keep only this partition's nodes:*/
    45         if((model->my_grids[i]==1)){
     45        if((iomodel->my_grids[i]==1)){
    4646        #endif
    4747
  • issm/trunk/src/c/ModelProcessorx/Thermal/CreateElementsNodesAndMaterialsThermal.cpp

    r1676 r1834  
    1212#include "../../shared/shared.h"
    1313#include "../../MeshPartitionx/MeshPartitionx.h"
    14 #include "../Model.h"
     14#include "../IoModel.h"
    1515
    1616#undef __FUNCT__
    1717#define __FUNCT__ "CreateElementsNodesAndMaterialsThermal"
    18 void    CreateElementsNodesAndMaterialsThermal(DataSet** pelements,DataSet** pnodes, DataSet** pmaterials, Model* model,ConstDataHandle model_handle){
     18void    CreateElementsNodesAndMaterialsThermal(DataSet** pelements,DataSet** pnodes, DataSet** pmaterials, IoModel* iomodel,ConstDataHandle iomodel_handle){
    1919
    2020
     
    124124
    125125        /*Width of elements: */
    126         if(strcmp(model->meshtype,"2d")==0){
     126        if(strcmp(iomodel->meshtype,"2d")==0){
    127127                throw ErrorException(__FUNCT__," 2d temperature computation not supported yet!");
    128128        }
     
    132132        #ifdef _PARALLEL_
    133133        /*Determine parallel partitioning of elements: we use Metis for now. First load the data, then partition*/
    134         ModelFetchData((void**)&model->elements2d,NULL,NULL,model_handle,"elements2d","Matrix","Mat");
    135 
    136         MeshPartitionx(&epart, &npart,model->numberofelements,model->numberofnodes,model->elements, model->numberofelements2d,model->numberofnodes2d,model->elements2d,model->numlayers,elements_width, model->meshtype,num_procs);
     134        IoModelFetchData((void**)&iomodel->elements2d,NULL,NULL,iomodel_handle,"elements2d","Matrix","Mat");
     135
     136        MeshPartitionx(&epart, &npart,iomodel->numberofelements,iomodel->numberofnodes,iomodel->elements, iomodel->numberofelements2d,iomodel->numberofnodes2d,iomodel->elements2d,iomodel->numlayers,elements_width, iomodel->meshtype,num_procs);
    137137
    138138        /*Free elements and elements2d: */
    139         xfree((void**)&model->elements2d);
     139        xfree((void**)&iomodel->elements2d);
    140140
    141141        /*Used later on: */
    142         my_grids=(int*)xcalloc(model->numberofnodes,sizeof(int));
     142        my_grids=(int*)xcalloc(iomodel->numberofnodes,sizeof(int));
    143143        #endif
    144144
     
    147147
    148148        /*Fetch data needed: */
    149         ModelFetchData((void**)&model->elements,NULL,NULL,model_handle,"elements","Matrix","Mat");
    150         ModelFetchData((void**)&model->thickness,NULL,NULL,model_handle,"thickness","Matrix","Mat");
    151         ModelFetchData((void**)&model->surface,NULL,NULL,model_handle,"surface","Matrix","Mat");
    152         ModelFetchData((void**)&model->bed,NULL,NULL,model_handle,"bed","Matrix","Mat");
    153         ModelFetchData((void**)&model->drag,NULL,NULL,model_handle,"drag","Matrix","Mat");
    154         ModelFetchData((void**)&model->p,NULL,NULL,model_handle,"p","Matrix","Mat");
    155         ModelFetchData((void**)&model->q,NULL,NULL,model_handle,"q","Matrix","Mat");
    156         ModelFetchData((void**)&model->elementoniceshelf,NULL,NULL,model_handle,"elementoniceshelf","Matrix","Mat");
    157         ModelFetchData((void**)&model->elementonbed,NULL,NULL,model_handle,"elementonbed","Matrix","Mat");
    158         ModelFetchData((void**)&model->elementonsurface,NULL,NULL,model_handle,"elementonsurface","Matrix","Mat");
    159         ModelFetchData((void**)&model->elements_type,NULL,NULL,model_handle,"elements_type","Matrix","Mat");
    160         ModelFetchData((void**)&model->geothermalflux,NULL,NULL,model_handle,"geothermalflux","Matrix","Mat");
    161         ModelFetchData((void**)&model->B,NULL,NULL,model_handle,"B","Matrix","Mat");
    162         ModelFetchData((void**)&model->n,NULL,NULL,model_handle,"n","Matrix","Mat");
    163         ModelFetchData((void**)&model->elementonwater,NULL,NULL,model_handle,"elementonwater","Matrix","Mat");
    164        
    165         for (i=0;i<model->numberofelements;i++){
     149        IoModelFetchData((void**)&iomodel->elements,NULL,NULL,iomodel_handle,"elements","Matrix","Mat");
     150        IoModelFetchData((void**)&iomodel->thickness,NULL,NULL,iomodel_handle,"thickness","Matrix","Mat");
     151        IoModelFetchData((void**)&iomodel->surface,NULL,NULL,iomodel_handle,"surface","Matrix","Mat");
     152        IoModelFetchData((void**)&iomodel->bed,NULL,NULL,iomodel_handle,"bed","Matrix","Mat");
     153        IoModelFetchData((void**)&iomodel->drag,NULL,NULL,iomodel_handle,"drag","Matrix","Mat");
     154        IoModelFetchData((void**)&iomodel->p,NULL,NULL,iomodel_handle,"p","Matrix","Mat");
     155        IoModelFetchData((void**)&iomodel->q,NULL,NULL,iomodel_handle,"q","Matrix","Mat");
     156        IoModelFetchData((void**)&iomodel->elementoniceshelf,NULL,NULL,iomodel_handle,"elementoniceshelf","Matrix","Mat");
     157        IoModelFetchData((void**)&iomodel->elementonbed,NULL,NULL,iomodel_handle,"elementonbed","Matrix","Mat");
     158        IoModelFetchData((void**)&iomodel->elementonsurface,NULL,NULL,iomodel_handle,"elementonsurface","Matrix","Mat");
     159        IoModelFetchData((void**)&iomodel->elements_type,NULL,NULL,iomodel_handle,"elements_type","Matrix","Mat");
     160        IoModelFetchData((void**)&iomodel->geothermalflux,NULL,NULL,iomodel_handle,"geothermalflux","Matrix","Mat");
     161        IoModelFetchData((void**)&iomodel->B,NULL,NULL,iomodel_handle,"B","Matrix","Mat");
     162        IoModelFetchData((void**)&iomodel->n,NULL,NULL,iomodel_handle,"n","Matrix","Mat");
     163        IoModelFetchData((void**)&iomodel->elementonwater,NULL,NULL,iomodel_handle,"elementonwater","Matrix","Mat");
     164       
     165        for (i=0;i<iomodel->numberofelements;i++){
    166166        #ifdef _PARALLEL_
    167167        /*We are using our element partition to decide which elements will be created on this node: */
     
    173173                penta_id=i+1; //matlab indexing.
    174174                penta_mid=i+1; //refers to the corresponding material property card
    175                 penta_mparid=model->numberofelements+1;//refers to the corresponding parmat property card
     175                penta_mparid=iomodel->numberofelements+1;//refers to the corresponding parmat property card
    176176
    177177                /*vertices,thickness,surface,bed and drag: */
    178178                for(j=0;j<6;j++){
    179                         penta_g[j]=(int)*(model->elements+elements_width*i+j);
    180                         penta_h[j]=*(model->thickness+    ((int)*(model->elements+elements_width*i+j)-1));
    181                         penta_s[j]=*(model->surface+    ((int)*(model->elements+elements_width*i+j)-1));
    182                         penta_b[j]=*(model->bed+    ((int)*(model->elements+elements_width*i+j)-1));
    183                         penta_k[j]=*(model->drag+        ((int)*(model->elements+elements_width*i+j)-1));
    184                         penta_geothermalflux[j]=*(model->geothermalflux+        ((int)*(model->elements+elements_width*i+j)-1));
     179                        penta_g[j]=(int)*(iomodel->elements+elements_width*i+j);
     180                        penta_h[j]=*(iomodel->thickness+    ((int)*(iomodel->elements+elements_width*i+j)-1));
     181                        penta_s[j]=*(iomodel->surface+    ((int)*(iomodel->elements+elements_width*i+j)-1));
     182                        penta_b[j]=*(iomodel->bed+    ((int)*(iomodel->elements+elements_width*i+j)-1));
     183                        penta_k[j]=*(iomodel->drag+        ((int)*(iomodel->elements+elements_width*i+j)-1));
     184                        penta_geothermalflux[j]=*(iomodel->geothermalflux+        ((int)*(iomodel->elements+elements_width*i+j)-1));
    185185                }
    186186
    187187                /*basal drag:*/
    188                 penta_friction_type=(int)model->drag_type;
    189 
    190                 penta_p=model->p[i];
    191                 penta_q=model->q[i];
     188                penta_friction_type=(int)iomodel->drag_type;
     189
     190                penta_p=iomodel->p[i];
     191                penta_q=iomodel->q[i];
    192192
    193193                /*diverse: */
    194                 penta_shelf=(int)*(model->elementoniceshelf+i);
    195                 penta_onbed=(int)*(model->elementonbed+i);
    196                 penta_onsurface=(int)*(model->elementonsurface+i);
    197                 penta_meanvel=model->meanvel;
    198                 penta_epsvel=model->epsvel;
    199                 penta_onwater=(bool)*(model->elementonwater+i);
    200                 penta_artdiff=model->artificial_diffusivity;
     194                penta_shelf=(int)*(iomodel->elementoniceshelf+i);
     195                penta_onbed=(int)*(iomodel->elementonbed+i);
     196                penta_onsurface=(int)*(iomodel->elementonsurface+i);
     197                penta_meanvel=iomodel->meanvel;
     198                penta_epsvel=iomodel->epsvel;
     199                penta_onwater=(bool)*(iomodel->elementonwater+i);
     200                penta_artdiff=iomodel->artificial_diffusivity;
    201201
    202202                /*We need the field collapse for transient, so that we can use compute B with the average temperature*/
    203                 if (*(model->elements_type+2*i+0)==MacAyealFormulationEnum()){ //elements of type 3 are MacAyeal type Penta. We collapse the formulation on their base.
     203                if (*(iomodel->elements_type+2*i+0)==MacAyealFormulationEnum()){ //elements of type 3 are MacAyeal type Penta. We collapse the formulation on their base.
    204204                        penta_collapse=1;
    205205                }
     
    224224                B_avg=0;
    225225                for(j=0;j<6;j++){
    226                         B_avg+=*(model->B+((int)*(model->elements+elements_width*i+j)-1));
     226                        B_avg+=*(iomodel->B+((int)*(iomodel->elements+elements_width*i+j)-1));
    227227                }
    228228                B_avg=B_avg/6;
    229229                matice_B= B_avg;
    230                 matice_n=(double)*(model->n+i);
     230                matice_n=(double)*(iomodel->n+i);
    231231
    232232                /*Create matice using its constructor:*/
     
    241241                 into the grid coordinates. If we start plugging 1 into my_grids for each index[n][i] (i=0:2), then my_grids
    242242                 will hold which grids belong to this partition*/
    243                 my_grids[(int)*(model->elements+elements_width*i+0)-1]=1;
    244                 my_grids[(int)*(model->elements+elements_width*i+1)-1]=1;
    245                 my_grids[(int)*(model->elements+elements_width*i+2)-1]=1;
    246                 my_grids[(int)*(model->elements+elements_width*i+3)-1]=1;
    247                 my_grids[(int)*(model->elements+elements_width*i+4)-1]=1;
    248                 my_grids[(int)*(model->elements+elements_width*i+5)-1]=1;
     243                my_grids[(int)*(iomodel->elements+elements_width*i+0)-1]=1;
     244                my_grids[(int)*(iomodel->elements+elements_width*i+1)-1]=1;
     245                my_grids[(int)*(iomodel->elements+elements_width*i+2)-1]=1;
     246                my_grids[(int)*(iomodel->elements+elements_width*i+3)-1]=1;
     247                my_grids[(int)*(iomodel->elements+elements_width*i+4)-1]=1;
     248                my_grids[(int)*(iomodel->elements+elements_width*i+5)-1]=1;
    249249                #endif
    250250
     
    256256
    257257        /*Free data: */
    258         xfree((void**)&model->elements);
    259         xfree((void**)&model->thickness);
    260         xfree((void**)&model->surface);
    261         xfree((void**)&model->bed);
    262         xfree((void**)&model->drag);
    263         xfree((void**)&model->p);
    264         xfree((void**)&model->q);
    265         xfree((void**)&model->elementoniceshelf);
    266         xfree((void**)&model->elementonbed);
    267         xfree((void**)&model->elementonsurface);
    268         xfree((void**)&model->elements_type);
    269         xfree((void**)&model->geothermalflux);
    270         xfree((void**)&model->n);
    271         xfree((void**)&model->B);
    272         xfree((void**)&model->elementonwater);
     258        xfree((void**)&iomodel->elements);
     259        xfree((void**)&iomodel->thickness);
     260        xfree((void**)&iomodel->surface);
     261        xfree((void**)&iomodel->bed);
     262        xfree((void**)&iomodel->drag);
     263        xfree((void**)&iomodel->p);
     264        xfree((void**)&iomodel->q);
     265        xfree((void**)&iomodel->elementoniceshelf);
     266        xfree((void**)&iomodel->elementonbed);
     267        xfree((void**)&iomodel->elementonsurface);
     268        xfree((void**)&iomodel->elements_type);
     269        xfree((void**)&iomodel->geothermalflux);
     270        xfree((void**)&iomodel->n);
     271        xfree((void**)&iomodel->B);
     272        xfree((void**)&iomodel->elementonwater);
    273273
    274274        /*Add one constant material property to materials: */
    275         matpar_mid=model->numberofelements+1; //put it at the end of the materials
    276         matpar_g=model->g;
    277         matpar_rho_ice=model->rho_ice;
    278         matpar_rho_water=model->rho_water;
    279         matpar_thermalconductivity=model->thermalconductivity;
    280         matpar_heatcapacity=model->heatcapacity;
    281         matpar_latentheat=model->latentheat;
    282         matpar_beta=model->beta;
    283         matpar_meltingpoint=model->meltingpoint;
    284         matpar_mixed_layer_capacity=model->mixed_layer_capacity;
    285         matpar_thermal_exchange_velocity=model->thermal_exchange_velocity;
     275        matpar_mid=iomodel->numberofelements+1; //put it at the end of the materials
     276        matpar_g=iomodel->g;
     277        matpar_rho_ice=iomodel->rho_ice;
     278        matpar_rho_water=iomodel->rho_water;
     279        matpar_thermalconductivity=iomodel->thermalconductivity;
     280        matpar_heatcapacity=iomodel->heatcapacity;
     281        matpar_latentheat=iomodel->latentheat;
     282        matpar_beta=iomodel->beta;
     283        matpar_meltingpoint=iomodel->meltingpoint;
     284        matpar_mixed_layer_capacity=iomodel->mixed_layer_capacity;
     285        matpar_thermal_exchange_velocity=iomodel->thermal_exchange_velocity;
    286286
    287287        /*Create matpar object using its constructor: */
     
    296296                /*From the element partitioning, we can determine which grids are on the inside of this cpu's
    297297                 *element partition, and which are on its border with other nodes:*/
    298                 gridborder=NewVec(model->numberofnodes);
    299 
    300                 for (i=0;i<model->numberofnodes;i++){
     298                gridborder=NewVec(iomodel->numberofnodes);
     299
     300                for (i=0;i<iomodel->numberofnodes;i++){
    301301                        if(my_grids[i])VecSetValue(gridborder,i,1,ADD_VALUES);
    302302                }
     
    312312                #ifdef _DEBUG_
    313313                if(my_rank==0){
    314                         for (i=0;i<model->numberofnodes;i++){
     314                        for (i=0;i<iomodel->numberofnodes;i++){
    315315                                printf("Grid id %i Border grid %lf\n",i+1,my_bordergrids[i]);
    316316                        }
     
    320320
    321321        /*Partition penalties in 3d: */
    322         if(strcmp(model->meshtype,"3d")==0){
     322        if(strcmp(iomodel->meshtype,"3d")==0){
    323323       
    324324                /*Get penalties: */
    325                 ModelFetchData((void**)&model->penalties,&model->numpenalties,NULL,model_handle,"penalties","Matrix","Mat");
    326 
    327                 if(model->numpenalties){
    328 
    329                         model->penaltypartitioning=(int*)xmalloc(model->numpenalties*sizeof(int));
     325                IoModelFetchData((void**)&iomodel->penalties,&iomodel->numpenalties,NULL,iomodel_handle,"penalties","Matrix","Mat");
     326
     327                if(iomodel->numpenalties){
     328
     329                        iomodel->penaltypartitioning=(int*)xmalloc(iomodel->numpenalties*sizeof(int));
    330330                        #ifdef _SERIAL_
    331                         for(i=0;i<model->numpenalties;i++)model->penaltypartitioning[i]=1;
     331                        for(i=0;i<iomodel->numpenalties;i++)iomodel->penaltypartitioning[i]=1;
    332332                        #else
    333                         for(i=0;i<model->numpenalties;i++)model->penaltypartitioning[i]=-1;
    334 
    335                         for(i=0;i<model->numpenalties;i++){
    336                                 first_grid_index=(int)(*(model->penalties+i*model->numlayers+0)-1);
     333                        for(i=0;i<iomodel->numpenalties;i++)iomodel->penaltypartitioning[i]=-1;
     334
     335                        for(i=0;i<iomodel->numpenalties;i++){
     336                                first_grid_index=(int)(*(iomodel->penalties+i*iomodel->numlayers+0)-1);
    337337                                if((my_grids[first_grid_index]==1) && (my_bordergrids[first_grid_index]<=1.0) ) { //this grid belongs to this node's internal partition  grids
    338338                                        /*All grids that are being penalised belong to this node's internal grid partition.:*/
    339                                         model->penaltypartitioning[i]=1;
     339                                        iomodel->penaltypartitioning[i]=1;
    340340                                }
    341341                                if(my_bordergrids[first_grid_index]>1.0) { //this grid belongs to a partition border
    342                                         model->penaltypartitioning[i]=0;
     342                                        iomodel->penaltypartitioning[i]=0;
    343343                                }
    344344                        }
     
    347347
    348348                /*Free penalties: */
    349                 xfree((void**)&model->penalties);
     349                xfree((void**)&iomodel->penalties);
    350350        }
    351351
     
    358358               
    359359        /*First fetch data: */
    360         if (strcmp(model->meshtype,"3d")==0){
    361                 ModelFetchData((void**)&model->deadgrids,NULL,NULL,model_handle,"deadgrids","Matrix","Mat");
    362                 ModelFetchData((void**)&model->uppernodes,NULL,NULL,model_handle,"uppergrids","Matrix","Mat");
     360        if (strcmp(iomodel->meshtype,"3d")==0){
     361                IoModelFetchData((void**)&iomodel->deadgrids,NULL,NULL,iomodel_handle,"deadgrids","Matrix","Mat");
     362                IoModelFetchData((void**)&iomodel->uppernodes,NULL,NULL,iomodel_handle,"uppergrids","Matrix","Mat");
    363363        }
    364         ModelFetchData((void**)&model->x,NULL,NULL,model_handle,"x","Matrix","Mat");
    365         ModelFetchData((void**)&model->y,NULL,NULL,model_handle,"y","Matrix","Mat");
    366         ModelFetchData((void**)&model->z,NULL,NULL,model_handle,"z","Matrix","Mat");
    367         ModelFetchData((void**)&model->thickness,NULL,NULL,model_handle,"thickness","Matrix","Mat");
    368         ModelFetchData((void**)&model->bed,NULL,NULL,model_handle,"bed","Matrix","Mat");
    369         ModelFetchData((void**)&model->gridonbed,NULL,NULL,model_handle,"gridonbed","Matrix","Mat");
    370         ModelFetchData((void**)&model->gridonsurface,NULL,NULL,model_handle,"gridonsurface","Matrix","Mat");
    371         ModelFetchData((void**)&model->gridonicesheet,NULL,NULL,model_handle,"gridonicesheet","Matrix","Mat");
    372         ModelFetchData((void**)&model->gridoniceshelf,NULL,NULL,model_handle,"gridoniceshelf","Matrix","Mat");
     364        IoModelFetchData((void**)&iomodel->x,NULL,NULL,iomodel_handle,"x","Matrix","Mat");
     365        IoModelFetchData((void**)&iomodel->y,NULL,NULL,iomodel_handle,"y","Matrix","Mat");
     366        IoModelFetchData((void**)&iomodel->z,NULL,NULL,iomodel_handle,"z","Matrix","Mat");
     367        IoModelFetchData((void**)&iomodel->thickness,NULL,NULL,iomodel_handle,"thickness","Matrix","Mat");
     368        IoModelFetchData((void**)&iomodel->bed,NULL,NULL,iomodel_handle,"bed","Matrix","Mat");
     369        IoModelFetchData((void**)&iomodel->gridonbed,NULL,NULL,iomodel_handle,"gridonbed","Matrix","Mat");
     370        IoModelFetchData((void**)&iomodel->gridonsurface,NULL,NULL,iomodel_handle,"gridonsurface","Matrix","Mat");
     371        IoModelFetchData((void**)&iomodel->gridonicesheet,NULL,NULL,iomodel_handle,"gridonicesheet","Matrix","Mat");
     372        IoModelFetchData((void**)&iomodel->gridoniceshelf,NULL,NULL,iomodel_handle,"gridoniceshelf","Matrix","Mat");
    373373
    374374        /*Get number of dofs per node: */
    375         DistributeNumDofs(&node_numdofs,model->analysis_type,model->sub_analysis_type);
    376 
    377         for (i=0;i<model->numberofnodes;i++){
     375        DistributeNumDofs(&node_numdofs,iomodel->analysis_type,iomodel->sub_analysis_type);
     376
     377        for (i=0;i<iomodel->numberofnodes;i++){
    378378        #ifdef _PARALLEL_
    379379        /*keep only this partition's nodes:*/
     
    394394                #endif
    395395
    396                 node_x[0]=model->x[i];
    397                 node_x[1]=model->y[i];
    398                 node_x[2]=model->z[i];
    399                 node_sigma=(model->z[i]-model->bed[i])/(model->thickness[i]);
    400                
    401                 node_onbed=(int)model->gridonbed[i];
    402                 node_onsurface=(int)model->gridonsurface[i];   
    403                 node_onshelf=(int)model->gridoniceshelf[i];     
    404                 node_onsheet=(int)model->gridonicesheet[i];     
    405 
    406                 if (strcmp(model->meshtype,"3d")==0){
    407                         if (isnan(model->uppernodes[i])){
     396                node_x[0]=iomodel->x[i];
     397                node_x[1]=iomodel->y[i];
     398                node_x[2]=iomodel->z[i];
     399                node_sigma=(iomodel->z[i]-iomodel->bed[i])/(iomodel->thickness[i]);
     400               
     401                node_onbed=(int)iomodel->gridonbed[i];
     402                node_onsurface=(int)iomodel->gridonsurface[i]; 
     403                node_onshelf=(int)iomodel->gridoniceshelf[i];   
     404                node_onsheet=(int)iomodel->gridonicesheet[i];   
     405
     406                if (strcmp(iomodel->meshtype,"3d")==0){
     407                        if (isnan(iomodel->uppernodes[i])){
    408408                                node_upper_node_id=node_id;  //nodes on surface do not have upper nodes, only themselves.
    409409                        }
    410410                        else{
    411                                 node_upper_node_id=(int)model->uppernodes[i];
     411                                node_upper_node_id=(int)iomodel->uppernodes[i];
    412412                        }
    413413                }
     
    435435
    436436        /*Clean fetched data: */
    437         xfree((void**)&model->deadgrids);
    438         xfree((void**)&model->x);
    439         xfree((void**)&model->y);
    440         xfree((void**)&model->z);
    441         xfree((void**)&model->thickness);
    442         xfree((void**)&model->bed);
    443         xfree((void**)&model->gridonbed);
    444         xfree((void**)&model->gridonsurface);
    445         xfree((void**)&model->uppernodes);
    446         xfree((void**)&model->gridonicesheet);
    447         xfree((void**)&model->gridoniceshelf);
     437        xfree((void**)&iomodel->deadgrids);
     438        xfree((void**)&iomodel->x);
     439        xfree((void**)&iomodel->y);
     440        xfree((void**)&iomodel->z);
     441        xfree((void**)&iomodel->thickness);
     442        xfree((void**)&iomodel->bed);
     443        xfree((void**)&iomodel->gridonbed);
     444        xfree((void**)&iomodel->gridonsurface);
     445        xfree((void**)&iomodel->uppernodes);
     446        xfree((void**)&iomodel->gridonicesheet);
     447        xfree((void**)&iomodel->gridoniceshelf);
    448448       
    449449        cleanup_and_return:
     
    454454        *pmaterials=materials;
    455455
    456         /*Keep partitioning information into model*/
    457         model->epart=epart;
    458         model->my_grids=my_grids;
    459         model->my_bordergrids=my_bordergrids;
     456        /*Keep partitioning information into iomodel*/
     457        iomodel->epart=epart;
     458        iomodel->my_grids=my_grids;
     459        iomodel->my_bordergrids=my_bordergrids;
    460460
    461461        /*Free ressources:*/
  • issm/trunk/src/c/ModelProcessorx/Thermal/CreateLoadsThermal.cpp

    r1765 r1834  
    1111#include "../../shared/shared.h"
    1212#include "../../include/macros.h"
    13 #include "../Model.h"
     13#include "../IoModel.h"
    1414
    1515
    16 void    CreateLoadsThermal(DataSet** ploads, Model* model,ConstDataHandle model_handle){
     16void    CreateLoadsThermal(DataSet** ploads, IoModel* iomodel,ConstDataHandle iomodel_handle){
    1717
    1818        int i,j,counter;
     
    4747
    4848        //create penalties for grids: no grid can have a temperature over the melting point
    49         ModelFetchData((void**)&model->spctemperature,NULL,NULL,model_handle,"spctemperature","Matrix","Mat");
     49        IoModelFetchData((void**)&iomodel->spctemperature,NULL,NULL,iomodel_handle,"spctemperature","Matrix","Mat");
    5050
    51         for (i=0;i<model->numberofnodes;i++){
     51        for (i=0;i<iomodel->numberofnodes;i++){
    5252        #ifdef _PARALLEL_
    5353        /*keep only this partition's nodes:*/
    54         if((model->my_grids[i]==1)){
     54        if((iomodel->my_grids[i]==1)){
    5555        #endif
    5656
    57                 if (!model->spctemperature[2*i]){ //No penalty applied on spc grids!
     57                if (!iomodel->spctemperature[2*i]){ //No penalty applied on spc grids!
    5858               
    5959                        pengrid_id=count+1; //matlab indexing
    6060                        pengrid_node_id=i+1;
    61                         pengrid_mparid=model->numberofelements+1;//refers to the corresponding parmat property card
     61                        pengrid_mparid=iomodel->numberofelements+1;//refers to the corresponding parmat property card
    6262                        pengrid_dof=1;
    63                         pengrid_penalty_offset=model->penalty_offset;
     63                        pengrid_penalty_offset=iomodel->penalty_offset;
    6464                        pengrid_active=0;
    6565                       
     
    7070                }
    7171        #ifdef _PARALLEL_
    72         } //if((model->my_grids[i]==1))
     72        } //if((iomodel->my_grids[i]==1))
    7373        #endif
    7474        }
    75         xfree((void**)&model->spctemperature);
     75        xfree((void**)&iomodel->spctemperature);
    7676
    7777        /*All our datasets are already order by ids. Set presort flag so that later on, when sorting is requested on these
  • issm/trunk/src/c/ModelProcessorx/Thermal/CreateParametersThermal.cpp

    r1648 r1834  
    1111#include "../../objects/objects.h"
    1212#include "../../shared/shared.h"
    13 #include "../Model.h"
     13#include "../IoModel.h"
    1414
    15 void CreateParametersThermal(DataSet** pparameters,Model* model,ConstDataHandle model_handle){
     15void CreateParametersThermal(DataSet** pparameters,IoModel* iomodel,ConstDataHandle iomodel_handle){
    1616       
    1717        Param*   param = NULL;
     
    3333
    3434        /*Get vx vy and vz: */
    35         ModelFetchData((void**)&vx,NULL,NULL,model_handle,"vx","Matrix","Mat");
    36         ModelFetchData((void**)&vy,NULL,NULL,model_handle,"vy","Matrix","Mat");
    37         ModelFetchData((void**)&vz,NULL,NULL,model_handle,"vz","Matrix","Mat");
     35        IoModelFetchData((void**)&vx,NULL,NULL,iomodel_handle,"vx","Matrix","Mat");
     36        IoModelFetchData((void**)&vy,NULL,NULL,iomodel_handle,"vy","Matrix","Mat");
     37        IoModelFetchData((void**)&vz,NULL,NULL,iomodel_handle,"vz","Matrix","Mat");
    3838
    39         u_g=(double*)xcalloc(model->numberofnodes*3,sizeof(double));
     39        u_g=(double*)xcalloc(iomodel->numberofnodes*3,sizeof(double));
    4040
    41         if(vx) for(i=0;i<model->numberofnodes;i++)u_g[3*i+0]=vx[i]/model->yts;
    42         if(vy) for(i=0;i<model->numberofnodes;i++)u_g[3*i+1]=vy[i]/model->yts;
    43         if(vz) for(i=0;i<model->numberofnodes;i++)u_g[3*i+2]=vz[i]/model->yts;
     41        if(vx) for(i=0;i<iomodel->numberofnodes;i++)u_g[3*i+0]=vx[i]/iomodel->yts;
     42        if(vy) for(i=0;i<iomodel->numberofnodes;i++)u_g[3*i+1]=vy[i]/iomodel->yts;
     43        if(vz) for(i=0;i<iomodel->numberofnodes;i++)u_g[3*i+2]=vz[i]/iomodel->yts;
    4444
    4545        count++;
    4646        param= new Param(count,"u_g",DOUBLEVEC);
    47         param->SetDoubleVec(u_g,3*model->numberofnodes,3);
     47        param->SetDoubleVec(u_g,3*iomodel->numberofnodes,3);
    4848        parameters->AddObject(param);
    4949
     
    5454       
    5555        /*Get pressure: */
    56         ModelFetchData((void**)&pressure,NULL,NULL,model_handle,"pressure","Matrix","Mat");
     56        IoModelFetchData((void**)&pressure,NULL,NULL,iomodel_handle,"pressure","Matrix","Mat");
    5757       
    5858        count++;
    5959        param= new Param(count,"p_g",DOUBLEVEC);
    60         if(pressure) param->SetDoubleVec(pressure,model->numberofnodes,1);
     60        if(pressure) param->SetDoubleVec(pressure,iomodel->numberofnodes,1);
    6161        else param->SetDoubleVec(pressure,0,0);
    6262        parameters->AddObject(param);
     
    6666
    6767        /* get initial temperature and melting if transient*/
    68         if(model->sub_analysis_type==TransientAnalysisEnum()){
     68        if(iomodel->sub_analysis_type==TransientAnalysisEnum()){
    6969
    7070                /*Get melting and temperature: */
    71                 ModelFetchData((void**)&temperature,NULL,NULL,model_handle,"temperature","Matrix","Mat");
     71                IoModelFetchData((void**)&temperature,NULL,NULL,iomodel_handle,"temperature","Matrix","Mat");
    7272
    7373                count++;
    7474                param= new Param(count,"t_g",DOUBLEVEC);
    75                 if(temperature) param->SetDoubleVec(temperature,model->numberofnodes,1);
     75                if(temperature) param->SetDoubleVec(temperature,iomodel->numberofnodes,1);
    7676                else throw ErrorException(__FUNCT__,exprintf("Missing initial temperature"));
    7777                parameters->AddObject(param);
Note: See TracChangeset for help on using the changeset viewer.