Ignore:
Timestamp:
08/09/10 14:48:52 (15 years ago)
Author:
Eric.Larour
Message:

Number of dofs is now allowed to vary per cpu

File:
1 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk/src/c/objects/Elements/Penta.cpp

    r5075 r5096  
    20482048        const int    numdof=2*numgrids;
    20492049        double       xyz_list[numgrids][3];
    2050         int          doflist[numdof];
    2051         int          numberofdofspernode;
     2050        int*         doflist=NULL;
    20522051
    20532052        /* 3d gaussian points: */
     
    21722171                /* Get node coordinates and dof list: */
    21732172                GetVerticesCoordinates(&xyz_list[0][0], nodes, numgrids);
    2174                 GetDofList(&doflist[0],&numberofdofspernode);
     2173                GetDofList(&doflist);
    21752174
    21762175                /*Get gaussian points and weights. Penta is an extrusion of a Tria, we therefore
     
    22742273        xfree((void**)&third_gauss_area_coord2d);
    22752274        xfree((void**)&gauss_weights2d);
    2276 
     2275        xfree((void**)&doflist);
    22772276}
    22782277/*}}}*/
     
    22852284        const int NDOF2=2;
    22862285        const int numdofs=NDOF2*numgrids;
    2287         int       doflist[numdofs];
     2286        int*      doflist=NULL;
    22882287        double    Ke_gg[numdofs][numdofs]={0.0};
    2289         int       numberofdofspernode;
    22902288        bool      onbed;
    22912289        bool      onsurface;
     
    23062304        inputs->GetParameterValue(&onsurface,ElementOnSurfaceEnum);
    23072305
    2308         GetDofList(&doflist[0],&numberofdofspernode);
     2306        GetDofList(&doflist);
    23092307
    23102308        /*Spawn 3 beam elements: */
     
    23572355        MatSetValues(Kgg,numdofs,doflist,numdofs,doflist,(const double*)Ke_gg,ADD_VALUES);
    23582356
     2357        /*Free ressources:*/
     2358        xfree((void**)&doflist);
     2359
    23592360}
    23602361/*}}}*/
     
    23672368        const int DOFPERGRID=4;
    23682369        const int numdof=numgrids*DOFPERGRID;
    2369         int doflist[numdof];
    2370         int numberofdofspernode;
     2370        int*      doflist=NULL;
    23712371
    23722372        const int numgrids2d=3;
     
    24692469        /* Get node coordinates and dof list: */
    24702470        GetVerticesCoordinates(&xyz_list[0][0], nodes, numgrids);
    2471         GetDofList(&doflist[0],&numberofdofspernode);
     2471        GetDofList(&doflist);
    24722472
    24732473        /* Get gaussian points and weights. Penta is an extrusion of a Tria, we therefore
     
    26362636        xfree((void**)&vert_gauss_coord);
    26372637        xfree((void**)&vert_gauss_weights);
     2638        xfree((void**)&doflist);
    26382639
    26392640        return;
     
    26512652        const int    numdof=NDOF1*numgrids;
    26522653        double       xyz_list[numgrids][3];
    2653         int          doflist[numdof];
    2654         int          numberofdofspernode;
     2654        int*         doflist=NULL;
    26552655
    26562656        /* 3d gaussian points: */
     
    27042704        /* Get node coordinates and dof list: */
    27052705        GetVerticesCoordinates(&xyz_list[0][0], nodes, numgrids);
    2706         GetDofList(&doflist[0],&numberofdofspernode);
     2706        GetDofList(&doflist);
    27072707
    27082708        /*Get gaussian points and weights. Penta is an extrusion of a Tria, we therefore
     
    27632763        xfree((void**)&area_gauss_weights);
    27642764        xfree((void**)&vert_gauss_weights);
     2765        xfree((void**)&doflist);
    27652766}
    27662767/*}}}*/
     
    28702871        const int    NDOF1=1;
    28712872        const int    numdof=NDOF1*numgrids;
    2872         double xyz_list[numgrids][3];
    2873         int    doflist[numdof];
    2874         int    numberofdofspernode;
     2873        double       xyz_list[numgrids][3];
     2874        int*         doflist=NULL;
    28752875
    28762876        /* gaussian points: */
     
    29472947        /* Get node coordinates and dof list: */
    29482948        GetVerticesCoordinates(&xyz_list[0][0], nodes, numgrids);
    2949         GetDofList(&doflist[0],&numberofdofspernode);
     2949        GetDofList(&doflist);
    29502950
    29512951        // /*recovre material parameters: */
     
    30883088        MatSetValues(Kgg,numdof,doflist,numdof,doflist,(const double*)K_terms,ADD_VALUES);
    30893089
     3090        //Ice/ocean heat exchange flux on ice shelf base
     3091        if(onbed && shelf){
     3092
     3093                tria=(Tria*)SpawnTria(0,1,2); //grids 0, 1 and 2 make the new tria.
     3094                tria->CreateKMatrixThermal(Kgg);
     3095                delete tria->matice; delete tria;
     3096        }
     3097       
     3098        /*Free ressources:*/
    30903099        xfree((void**)&first_gauss_area_coord);
    30913100        xfree((void**)&second_gauss_area_coord);
     
    30943103        xfree((void**)&vert_gauss_weights);
    30953104        xfree((void**)&vert_gauss_coord);
    3096 
    3097         //Ice/ocean heat exchange flux on ice shelf base
    3098         if(onbed && shelf){
    3099 
    3100                 tria=(Tria*)SpawnTria(0,1,2); //grids 0, 1 and 2 make the new tria.
    3101                 tria->CreateKMatrixThermal(Kgg);
    3102                 delete tria->matice; delete tria;
    3103         }
     3105        xfree((void**)&doflist);
     3106
    31043107}
    31053108/*}}}*/
     
    31863189        const int    numdof=NDOF2*numgrids;
    31873190        double       xyz_list[numgrids][3];
    3188         int          doflist[numdof];
    3189         int          numberofdofspernode;
     3191        int*         doflist=NULL;
    31903192
    31913193        /* parameters: */
     
    32623264                /* Get node coordinates and dof list: */
    32633265                GetVerticesCoordinates(&xyz_list[0][0], nodes, numgrids);
    3264                 GetDofList(&doflist[0],&numberofdofspernode);
     3266                GetDofList(&doflist);
    32653267
    32663268                /*Get gaussian points and weights :*/
     
    33273329        xfree((void**)&area_gauss_weights);
    33283330        xfree((void**)&vert_gauss_weights);
    3329 
     3331        xfree((void**)&doflist);
    33303332}
    33313333/*}}}*/
     
    33833385        const int NDOF2=2;
    33843386        const int numdofs=NDOF2*numgrids;
    3385         int       doflist[numdofs];
    3386         int       numberofdofspernode;
     3387        int*      doflist=NULL;
    33873388        double    pe_g[numdofs]={0.0};
    33883389        double    xyz_list[numgrids][3];
     
    34283429
    34293430        /*recover doflist: */
    3430         GetDofList(&doflist[0],&numberofdofspernode);
     3431        GetDofList(&doflist);
    34313432
    34323433        /*recover some inputs: */
     
    35233524        xfree((void**)&gauss_weights);
    35243525        xfree((void**)&segment_gauss_coord);
     3526        xfree((void**)&doflist);
    35253527}
    35263528/*}}}*/
     
    35353537        const int numdof=numgrids*DOFPERGRID;
    35363538        const int numgrids2d=3;
    3537         int numdof2d=numgrids2d*DOFPERGRID;
    3538         int doflist[numdof];
    3539         int numberofdofspernode;
     3539        int       numdof2d=numgrids2d*DOFPERGRID;
     3540        int*      doflist=NULL;
    35403541
    35413542        /*Material properties: */
     
    36273628        /* Get node coordinates and dof list: */
    36283629        GetVerticesCoordinates(&xyz_list[0][0], nodes, numgrids);
    3629         GetDofList(&doflist[0],&numberofdofspernode);
     3630        GetDofList(&doflist);
    36303631
    36313632        /* Get gaussian points and weights. Penta is an extrusion of a Tria, we therefore
     
    37773778        xfree((void**)&area_gauss_weights);
    37783779        xfree((void**)&vert_gauss_coord);
    3779         xfree((void**)&vert_gauss_weights);
     3780        xfree((void**)&vert_gauss_weights);
     3781        xfree((void**)&doflist);
    37803782
    37813783}
     
    38153817        const int    numdof=NDOF1*numgrids;
    38163818        double       xyz_list[numgrids][3];
    3817         int          doflist[numdof];
    3818         int          numberofdofspernode;
     3819        int*         doflist=NULL;
    38193820
    38203821        /* gaussian points: */
     
    38763877        /* Get node coordinates and dof list: */
    38773878        GetVerticesCoordinates(&xyz_list[0][0], nodes, numgrids);
    3878         GetDofList(&doflist[0],&numberofdofspernode);
     3879        GetDofList(&doflist);
    38793880
    38803881        /*Get gaussian points and weights :*/
     
    39353936        xfree((void**)&area_gauss_weights);
    39363937        xfree((void**)&vert_gauss_weights);
     3938        xfree((void**)&doflist);
    39373939}
    39383940/*}}}*/
     
    40154017        const int  NDOF1=1;
    40164018        const int  numdof=numgrids*NDOF1;
    4017         int        doflist[numdof];
    4018         int        numberofdofspernode;
     4019        int*       doflist=NULL;
    40194020
    40204021        /*Grid data: */
     
    40964097        /* Get node coordinates and dof list: */
    40974098        GetVerticesCoordinates(&xyz_list[0][0], nodes, numgrids);
    4098         GetDofList(&doflist[0],&numberofdofspernode);
     4099        GetDofList(&doflist);
    40994100
    41004101        /*recovre material parameters: */
     
    41914192        xfree((void**)&area_gauss_weights);
    41924193        xfree((void**)&vert_gauss_weights);
     4194        xfree((void**)&doflist);
    41934195
    41944196}
     
    42344236/*}}}*/
    42354237/*FUNCTION Penta::GetDofList {{{1*/
    4236 void  Penta::GetDofList(int* doflist,int* pnumberofdofspernode){
     4238void  Penta::GetDofList(int** pdoflist){
    42374239
    42384240        int i,j;
    4239         int doflist_per_node[MAXDOFSPERNODE];
    4240         int numberofdofspernode;
    4241 
     4241        int numberofdofs=0;
     4242        int count=0;
     4243
     4244        /*output: */
     4245        int* doflist=NULL;
     4246
     4247        /*First, figure out size of doflist: */
    42424248        for(i=0;i<6;i++){
    4243                 nodes[i]->GetDofList(&doflist_per_node[0],&numberofdofspernode);
    4244                 for(j=0;j<numberofdofspernode;j++){
    4245                         doflist[i*numberofdofspernode+j]=doflist_per_node[j];
    4246                 }
     4249                numberofdofs+=nodes[i]->GetNumberOfDofs();
     4250        }
     4251
     4252        /*Allocate: */
     4253        doflist=(int*)xmalloc(numberofdofs*sizeof(int));
     4254
     4255        /*Populate: */
     4256        count=0;
     4257        for(i=0;i<6;i++){
     4258                nodes[i]->GetDofList(doflist+count);
     4259                count+=nodes[i]->GetNumberOfDofs();
    42474260        }
    42484261
    42494262        /*Assign output pointers:*/
    4250         *pnumberofdofspernode=numberofdofspernode;
     4263        *pdoflist=doflist;
    42514264
    42524265}
     
    44404453        const int    numdof=numdofpervertex*numvertices;
    44414454        double       gauss[numvertices][4]={{1,0,0,-1},{0,1,0,-1},{0,0,1,-1},{1,0,0,1},{0,1,0,1},{0,0,1,1}};
    4442 
    4443         int          doflist[numdof];
     4455        int*         doflist=NULL;
    44444456        double       values[numdof];
    44454457        double       vx;
    44464458        double       vy;
    44474459
    4448         int          dummy;
    4449 
    44504460        /*Get dof list: */
    4451         GetDofList(&doflist[0],&dummy);
     4461        GetDofList(&doflist);
    44524462
    44534463        /*Ok, we have vx and vy in values, fill in vx and vy arrays: */
     
    44654475        VecSetValues(solution,numdof,doflist,(const double*)values,INSERT_VALUES);
    44664476
     4477        /*Free ressources:*/
     4478        xfree((void**)&doflist);
    44674479}
    44684480/*}}}*/
     
    44764488        const int    numdof=numdofpervertex*numvertices;
    44774489        double       gauss[numvertices][4]={{1,0,0,-1},{0,1,0,-1},{0,0,1,-1},{1,0,0,1},{0,1,0,1},{0,0,1,1}};
    4478 
    4479         int          doflist[numdof];
     4490        int*         doflist=NULL;
    44804491        double       values[numdof];
    44814492        double       vx;
    44824493        double       vy;
    44834494
    4484         int          dummy;
    4485 
    44864495        /*Get dof list: */
    4487         GetDofList(&doflist[0],&dummy);
     4496        GetDofList(&doflist);
    44884497
    44894498        /*Ok, we have vx and vy in values, fill in vx and vy arrays: */
     
    45014510        VecSetValues(solution,numdof,doflist,(const double*)values,INSERT_VALUES);
    45024511
     4512        /*Free ressources:*/
     4513        xfree((void**)&doflist);
    45034514}
    45044515/*}}}*/
     
    45124523        const int    numdof=numdofpervertex*numvertices;
    45134524        double       gauss[numvertices][4]={{1,0,0,-1},{0,1,0,-1},{0,0,1,-1},{1,0,0,1},{0,1,0,1},{0,0,1,1}};
    4514 
    4515         int          doflist[numdof];
     4525        int*         doflist=NULL;
    45164526        double       values[numdof];
    45174527        double       vz;
    45184528
    4519         int          dummy;
    4520 
    45214529        /*Get dof list: */
    4522         GetDofList(&doflist[0],&dummy);
     4530        GetDofList(&doflist);
    45234531
    45244532        /*Ok, we have vx and vy in values, fill in vx and vy arrays: */
     
    45334541        /*Add value to global vector*/
    45344542        VecSetValues(solution,numdof,doflist,(const double*)values,INSERT_VALUES);
     4543
     4544        /*Free ressources:*/
     4545        xfree((void**)&doflist);
    45354546}
    45364547/*}}}*/
     
    45444555        const int    numdof=numdofpervertex*numvertices;
    45454556        double       gauss[numvertices][4]={{1,0,0,-1},{0,1,0,-1},{0,0,1,-1},{1,0,0,1},{0,1,0,1},{0,0,1,1}};
    4546 
    4547         int          doflist[numdof];
     4557        int*         doflist=NULL;
    45484558        double       values[numdof];
    45494559        double       vx,vy,vz,p;
    4550 
    4551         int          dummy;
    45524560        double       stokesreconditioning;
    45534561
    45544562        /*Get dof list: */
    4555         GetDofList(&doflist[0],&dummy);
     4563        GetDofList(&doflist);
    45564564
    45574565        /*Recondition pressure: */
     
    45764584        VecSetValues(solution,numdof,doflist,(const double*)values,INSERT_VALUES);
    45774585
     4586        /*Free ressources:*/
     4587        xfree((void**)&doflist);
    45784588}
    45794589/*}}}*/
     
    45874597        const int    numdof=numdofpervertex*numvertices;
    45884598        double       gauss[numvertices][4]={{1,0,0,-1},{0,1,0,-1},{0,0,1,-1},{1,0,0,1},{0,1,0,1},{0,0,1,1}};
    4589 
    4590         int          doflist[numdof];
     4599        int*         doflist=NULL;
    45914600        double       values[numdof];
    45924601        double       vz;
    45934602
    4594         int          dummy;
    45954603
    45964604        /*Get dof list: */
    4597         GetDofList(&doflist[0],&dummy);
     4605        GetDofList(&doflist);
    45984606
    45994607        /*Ok, we have vx and vy in values, fill in vx and vy arrays: */
     
    46084616        /*Add value to global vector*/
    46094617        VecSetValues(solution,numdof,doflist,(const double*)values,INSERT_VALUES);
     4618       
     4619        /*Free ressources:*/
     4620        xfree((void**)&doflist);
    46104621}
    46114622/*}}}*/
     
    49074918        const int    numdofpervertex=2;
    49084919        const int    numdof=numdofpervertex*numvertices;
    4909 
    4910         int          doflist[numdof];
     4920        int*         doflist=NULL;
    49114921        double       values[numdof];
    49124922        double       vx[numvertices];
     
    49284938
    49294939        /*Get dof list: */
    4930         GetDofList(&doflist[0],&dummy);
     4940        GetDofList(&doflist);
    49314941
    49324942        /*Use the dof list to index into the solution vector: */
     
    49884998                penta=penta->GetUpperElement(); ISSMASSERT(penta->Id()!=this->id);
    49894999        }
     5000       
     5001        /*Free ressources:*/
     5002        xfree((void**)&doflist);
    49905003}
    49915004/*}}}*/
     
    49985011        const int    numdofpervertex=2;
    49995012        const int    numdof=numdofpervertex*numvertices;
    5000        
    5001         int          doflist[numdof];
     5013        int*         doflist=NULL;
    50025014        double       values[numdof];
    50035015        double       vx[numvertices];
     
    50165028
    50175029        /*Get dof list: */
    5018         GetDofList(&doflist[0],&dummy);
     5030        GetDofList(&doflist);
    50195031
    50205032        /*Get node data: */
     
    50685080        this->inputs->AddInput(new PentaVertexInput(VelEnum,vel));
    50695081        this->inputs->AddInput(new PentaVertexInput(PressureEnum,pressure));
     5082
     5083        /*Free ressources:*/
     5084        xfree((void**)&doflist);
    50705085}
    50715086
     
    50795094        const int    numdofpervertex=2;
    50805095        const int    numdof=numdofpervertex*numvertices;
    5081        
    5082         int          doflist[numdof];
     5096        int*         doflist=NULL;
    50835097        double       values[numdof];
    50845098        double       vx[numvertices];
     
    50975111
    50985112        /*Get dof list: */
    5099         GetDofList(&doflist[0],&dummy);
     5113        GetDofList(&doflist);
    51005114
    51015115        /*Get node data: */
     
    51495163        this->inputs->AddInput(new TriaVertexInput(VelEnum,vel));
    51505164        this->inputs->AddInput(new PentaVertexInput(PressureEnum,pressure));
     5165
     5166        /*Free ressources:*/
     5167        xfree((void**)&doflist);
    51515168}
    51525169
     
    51605177        const int    numdofpervertex=1;
    51615178        const int    numdof=numdofpervertex*numvertices;
    5162 
    5163         int          doflist[numdof];
     5179        int*         doflist=NULL;
    51645180        double       values[numdof];
    51655181        double       vx[numvertices];
     
    51805196
    51815197        /*Get dof list: */
    5182         GetDofList(&doflist[0],&dummy);
     5198        GetDofList(&doflist);
    51835199
    51845200        /*Get node data: */
     
    52335249        this->inputs->AddInput(new PentaVertexInput(VelEnum,vel));
    52345250        this->inputs->AddInput(new PentaVertexInput(PressureEnum,pressure));
    5235 } /*}}}*/
     5251
     5252        /*Free ressources:*/
     5253        xfree((void**)&doflist);
     5254}
     5255/*}}}*/
    52365256/*FUNCTION Penta::InputUpdateFromSolutionDiagnosticStokes {{{1*/
    52375257void  Penta::InputUpdateFromSolutionDiagnosticStokes(double* solution){
     
    52425262        const int    numdofpervertex=4;
    52435263        const int    numdof=numdofpervertex*numvertices;
    5244        
    5245         int          doflist[numdof];
     5264        int*         doflist=NULL;
    52465265        double       values[numdof];
    52475266        double       vx[numvertices];
     
    52505269        double       vel[numvertices];
    52515270        double       pressure[numvertices];
    5252         int          dummy;
    52535271        double       stokesreconditioning;
    52545272
    52555273        /*Get dof list: */
    5256         GetDofList(&doflist[0],&dummy);
     5274        GetDofList(&doflist);
    52575275
    52585276        /*Use the dof list to index into the solution vector: */
     
    52915309        this->inputs->AddInput(new PentaVertexInput(VelEnum,vel));
    52925310        this->inputs->AddInput(new PentaVertexInput(PressureEnum,pressure));
     5311
     5312        /*Free ressources:*/
     5313        xfree((void**)&doflist);
    52935314}
    52945315
     
    53025323        const int    numdofpervertex=4;
    53035324        const int    numdof=numdofpervertex*numvertices;
    5304 
    5305         int          doflist[numdof];
     5325        int*         doflist=NULL;
    53065326        double       values[numdof];
    53075327        double       lambdax[numvertices];
     
    53105330        double       lambdap[numvertices];
    53115331
    5312         int          dummy;
    5313 
    53145332        /*Get dof list: */
    5315         GetDofList(&doflist[0],&dummy);
     5333        GetDofList(&doflist);
    53165334
    53175335        /*Use the dof list to index into the solution vector: */
     
    53345352        this->inputs->AddInput(new PentaVertexInput(AdjointpEnum,lambdap));
    53355353
     5354        /*Free ressources:*/
     5355        xfree((void**)&doflist);
    53365356}
    53375357/*}}}*/
     
    53445364        const int    numdofpervertex=2;
    53455365        const int    numdof=numdofpervertex*numvertices;
    5346 
    5347         int          doflist[numdof];
     5366        int*         doflist=NULL;
    53485367        double       values[numdof];
    53495368        double       lambdax[numvertices];
    53505369        double       lambday[numvertices];
    53515370
    5352         int          dummy;
    5353 
    53545371        /*Get dof list: */
    5355         GetDofList(&doflist[0],&dummy);
     5372        GetDofList(&doflist);
    53565373
    53575374        /*Use the dof list to index into the solution vector: */
     
    53705387        this->inputs->AddInput(new PentaVertexInput(AdjointyEnum,lambday));
    53715388
     5389        /*Free ressources:*/
     5390        xfree((void**)&doflist);
    53725391}
    53735392/*}}}*/
     
    53805399        const int    numdofpervertex=1;
    53815400        const int    numdof=numdofpervertex*numvertices;
    5382 
    5383         int          doflist[numdof];
     5401        int*         doflist=NULL;
    53845402        double       values[numdof];
    53855403        double       B[numdof];
    53865404        double       B_average;
    53875405
    5388         int          dummy;
    5389 
    53905406        /*Get dof list: */
    5391         GetDofList(&doflist[0],&dummy);
     5407        GetDofList(&doflist);
    53925408
    53935409        /*Use the dof list to index into the solution vector: */
     
    54075423        this->matice->inputs->AddInput(new PentaVertexInput(RheologyBEnum,B));
    54085424
     5425        /*Free ressources:*/
     5426        xfree((void**)&doflist);
    54095427}
    54105428/*}}}*/
     
    54155433        const int numdofpervertex = 1;
    54165434        const int numdof          = numdofpervertex *numvertices;
    5417         int       doflist[numdof];
     5435        int*         doflist=NULL;
    54185436        double    values[numdof];
    5419         int       dummy;
    54205437
    54215438        /*Get dof list: */
    5422         GetDofList(&doflist[0],&dummy);
     5439        GetDofList(&doflist);
    54235440
    54245441        /*Use the dof list to index into the solution vector: */
     
    54295446        /*Add input to the element: */
    54305447        this->inputs->AddInput(new PentaVertexInput(enum_type,values));
     5448       
     5449        /*Free ressources:*/
     5450        xfree((void**)&doflist);
    54315451}
    54325452/*}}}*/
     
    54385458        const int  numdof          = numdofpervertex *numvertices;
    54395459        const int  numdof2d        = numdof/2;
    5440         int        doflist[numdof];
     5460        int*         doflist=NULL;
    54415461        double     values[numdof];
    5442         int        dummy;
    54435462        Penta     *penta           = NULL;
    54445463        bool       onbed;
     
    54515470
    54525471        /*Get dof list: */
    5453         GetDofList(&doflist[0],&dummy);
     5472        GetDofList(&doflist);
    54545473
    54555474        /*Use the dof list to index into the solution vector and extrude it */
     
    54725491                penta=penta->GetUpperElement(); ISSMASSERT(penta->Id()!=this->id);
    54735492        }
     5493       
     5494        /*Free ressources:*/
     5495        xfree((void**)&doflist);
    54745496}
    54755497/*}}}*/
Note: See TracChangeset for help on using the changeset viewer.