Changeset 13915


Ignore:
Timestamp:
11/08/12 15:11:19 (13 years ago)
Author:
Mathieu Morlighem
Message:

NEW: added memory allocation methods for loads

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

Legend:

Unmodified
Added
Removed
  • issm/trunk-jpl/src/c/classes/objects/Loads/Icefront.cpp

    r13813 r13915  
    271271}
    272272/*}}}*/
     273/*FUNCTION Icefront::GetNodesSidList{{{*/
     274void Icefront::GetNodesSidList(int* sidlist){
     275
     276        int type;
     277        inputs->GetInputValue(&type,TypeEnum);
     278        _assert_(sidlist);
     279        _assert_(nodes);
     280
     281        switch(type){
     282                case MacAyeal2dIceFrontEnum:
     283                case MacAyeal3dIceFrontEnum:
     284                        for(int i=0;i<NUMVERTICESSEG;i++) sidlist[i]=nodes[i]->Sid();
     285                        return;
     286#ifdef _HAVE_3D_
     287                case PattynIceFrontEnum:
     288                case StokesIceFrontEnum:
     289                        for(int i=0;i<NUMVERTICESQUA;i++) sidlist[i]=nodes[i]->Sid();
     290                        return;
     291#endif
     292                default:
     293                        _error_("Icefront type " << EnumToStringx(type) << " not supported yet");
     294        }
     295}
     296/*}}}*/
     297/*FUNCTION Icefront::GetNumberOfNodes{{{*/
     298int Icefront::GetNumberOfNodes(void){
     299
     300        int type;
     301        inputs->GetInputValue(&type,TypeEnum);
     302
     303        switch(type){
     304                case MacAyeal2dIceFrontEnum:
     305                        return NUMVERTICESSEG;
     306#ifdef _HAVE_3D_
     307                case MacAyeal3dIceFrontEnum:
     308                        return NUMVERTICESSEG;
     309                case PattynIceFrontEnum:
     310                        return NUMVERTICESQUA;
     311                case StokesIceFrontEnum:
     312                        return NUMVERTICESQUA;
     313#endif
     314                default:
     315                        _error_("Icefront type " << EnumToStringx(type) << " not supported yet");
     316        }
     317
     318}
     319/*}}}*/
    273320/*FUNCTION Icefront::PenaltyCreateKMatrix {{{*/
    274321void  Icefront::PenaltyCreateKMatrix(Matrix<IssmDouble>* Kff, Matrix<IssmDouble>* Kfs, IssmDouble kmax){
     
    286333void  Icefront::PenaltyCreateJacobianMatrix(Matrix<IssmDouble>* Jff,IssmDouble kmax){
    287334        this->PenaltyCreateKMatrix(Jff,NULL,kmax);
     335}
     336/*}}}*/
     337/*FUNCTION Icefront::SetwiseNodeConnectivity{{{*/
     338void Icefront::SetwiseNodeConnectivity(int* pd_nz,int* po_nz,Node* node,bool* flags,int set1_enum,int set2_enum){
     339
     340        /*Output */
     341        int d_nz = 0;
     342        int o_nz = 0;
     343
     344        /*Loop over all nodes*/
     345        for(int i=0;i<this->GetNumberOfNodes();i++){
     346
     347                if(!flags[this->nodes[i]->Sid()]){
     348
     349                        /*flag current node so that no other element processes it*/
     350                        flags[this->nodes[i]->Sid()]=true;
     351
     352                        /*if node is clone, we have an off-diagonal non-zero, else it is a diagonal non-zero*/
     353                        switch(set2_enum){
     354                                case FsetEnum:
     355                                        if(nodes[i]->indexing.fsize){
     356                                                if(this->nodes[i]->IsClone())
     357                                                 o_nz += 1;
     358                                                else
     359                                                 d_nz += 1;
     360                                        }
     361                                        break;
     362                                case GsetEnum:
     363                                        if(nodes[i]->indexing.gsize){
     364                                                if(this->nodes[i]->IsClone())
     365                                                 o_nz += 1;
     366                                                else
     367                                                 d_nz += 1;
     368                                        }
     369                                        break;
     370                                case SsetEnum:
     371                                        if(nodes[i]->indexing.ssize){
     372                                                if(this->nodes[i]->IsClone())
     373                                                 o_nz += 1;
     374                                                else
     375                                                 d_nz += 1;
     376                                        }
     377                                        break;
     378                                default: _error_("not supported");
     379                        }
     380                }
     381        }
     382
     383        /*Assign output pointers: */
     384        *pd_nz=d_nz;
     385        *po_nz=o_nz;
    288386}
    289387/*}}}*/
  • issm/trunk-jpl/src/c/classes/objects/Loads/Icefront.h

    r13414 r13915  
    7171                void  CreatePVector(Vector<IssmDouble>* pf);
    7272                void  CreateJacobianMatrix(Matrix<IssmDouble>* Jff);
     73                int   GetNumberOfNodes(void);
     74                void  GetNodesSidList(int* sidlist);
    7375                void  PenaltyCreateKMatrix(Matrix<IssmDouble>* Kff, Matrix<IssmDouble>* kfs, IssmDouble kmax);
    7476                void  PenaltyCreatePVector(Vector<IssmDouble>*  pf, IssmDouble kmax);
    7577                void  PenaltyCreateJacobianMatrix(Matrix<IssmDouble>* Jff,IssmDouble kmax);
     78                void  SetwiseNodeConnectivity(int* d_nz,int* o_nz,Node* node,bool* flags,int set1_enum,int set2_enum);
    7679                bool  InAnalysis(int analysis_type);
    7780                /*}}}*/
  • issm/trunk-jpl/src/c/classes/objects/Loads/Load.h

    r13414 r13915  
    2525                virtual       ~Load(){};
    2626                virtual void  Configure(Elements* elements,Loads* loads,Nodes* nodes,Vertices* vertices,Materials* materials,Parameters* parameters)=0;
     27                virtual int   GetNumberOfNodes(void)=0;
     28                virtual void  GetNodesSidList(int* sidlist)=0;
    2729                virtual void  SetCurrentConfiguration(Elements* elements,Loads* loads,Nodes* nodes,Vertices* vertices,Materials* materials,Parameters* parameters)=0;
    2830                virtual void  CreateKMatrix(Matrix<IssmDouble>* Kff, Matrix<IssmDouble>* Kfs)=0;
     
    3335                virtual void  PenaltyCreatePVector(Vector<IssmDouble>* pf, IssmDouble kmax)=0;
    3436                virtual bool  InAnalysis(int analysis_type)=0;
     37                virtual void  SetwiseNodeConnectivity(int* d_nz,int* o_nz,Node* node,bool* flags,int set1_enum,int set2_enum)=0;
    3538};
    3639#endif
  • issm/trunk-jpl/src/c/classes/objects/Loads/Numericalflux.cpp

    r13761 r13915  
    3434}
    3535/*}}}*/
    36 /*}}}*//*FUNCTION Numericalflux::Numericalflux(int id, int i, IoModel* iomodel, int analysis_type) {{{*/
     36/*FUNCTION Numericalflux::Numericalflux(int id, int i, IoModel* iomodel, int analysis_type) {{{*/
    3737Numericalflux::Numericalflux(int numericalflux_id,int i, IoModel* iomodel, int in_analysis_type){
    3838
     
    305305}
    306306/*}}}*/
     307/*FUNCTION Numericalflux::GetNodesSidList{{{*/
     308void Numericalflux::GetNodesSidList(int* sidlist){
     309
     310        int type;
     311        inputs->GetInputValue(&type,TypeEnum);
     312        _assert_(sidlist);
     313        _assert_(nodes);
     314
     315        switch(type){
     316                case InternalEnum:
     317                        for(int i=0;i<NUMVERTICES_INTERNAL;i++) sidlist[i]=nodes[i]->Sid();
     318                        return;
     319                case BoundaryEnum:
     320                        for(int i=0;i<NUMVERTICES_BOUNDARY;i++) sidlist[i]=nodes[i]->Sid();
     321                        return;
     322                default:
     323                        _error_("Numericalflux type " << EnumToStringx(type) << " not supported yet");
     324        }
     325}
     326/*}}}*/
     327/*FUNCTION Numericalflux::GetNumberOfNodes{{{*/
     328int Numericalflux::GetNumberOfNodes(void){
     329
     330        int type;
     331        inputs->GetInputValue(&type,TypeEnum);
     332
     333        switch(type){
     334                case InternalEnum:
     335                        return NUMVERTICES_INTERNAL;
     336                case BoundaryEnum:
     337                        return NUMVERTICES_BOUNDARY;
     338                default:
     339                        _error_("Numericalflux type " << EnumToStringx(type) << " not supported yet");
     340        }
     341
     342}
     343/*}}}*/
    307344/*FUNCTION Numericalflux::PenaltyCreateKMatrix {{{*/
    308345void  Numericalflux::PenaltyCreateKMatrix(Matrix<IssmDouble>* Kff, Matrix<IssmDouble>* Kfs,IssmDouble kmax){
     
    325362        if (in_analysis_type==this->analysis_type) return true;
    326363        else return false;
     364}
     365/*}}}*/
     366/*FUNCTION Numericalflux::SetwiseNodeConnectivity{{{*/
     367void Numericalflux::SetwiseNodeConnectivity(int* pd_nz,int* po_nz,Node* node,bool* flags,int set1_enum,int set2_enum){
     368
     369        /*Output */
     370        int d_nz = 0;
     371        int o_nz = 0;
     372
     373        /*Loop over all nodes*/
     374        for(int i=0;i<this->GetNumberOfNodes();i++){
     375
     376                if(!flags[this->nodes[i]->Sid()]){
     377
     378                        /*flag current node so that no other element processes it*/
     379                        flags[this->nodes[i]->Sid()]=true;
     380
     381                        /*if node is clone, we have an off-diagonal non-zero, else it is a diagonal non-zero*/
     382                        switch(set2_enum){
     383                                case FsetEnum:
     384                                        if(nodes[i]->indexing.fsize){
     385                                                if(this->nodes[i]->IsClone())
     386                                                 o_nz += 1;
     387                                                else
     388                                                 d_nz += 1;
     389                                        }
     390                                        break;
     391                                case GsetEnum:
     392                                        if(nodes[i]->indexing.gsize){
     393                                                if(this->nodes[i]->IsClone())
     394                                                 o_nz += 1;
     395                                                else
     396                                                 d_nz += 1;
     397                                        }
     398                                        break;
     399                                case SsetEnum:
     400                                        if(nodes[i]->indexing.ssize){
     401                                                if(this->nodes[i]->IsClone())
     402                                                 o_nz += 1;
     403                                                else
     404                                                 d_nz += 1;
     405                                        }
     406                                        break;
     407                                default: _error_("not supported");
     408                        }
     409                }
     410        }
     411
     412        /*Assign output pointers: */
     413        *pd_nz=d_nz;
     414        *po_nz=o_nz;
    327415}
    328416/*}}}*/
  • issm/trunk-jpl/src/c/classes/objects/Loads/Numericalflux.h

    r13414 r13915  
    6464                void  CreateKMatrix(Matrix<IssmDouble>* Kff, Matrix<IssmDouble>* Kfs);
    6565                void  CreatePVector(Vector<IssmDouble>* pf);
     66                void  GetNodesSidList(int* sidlist);
     67                int   GetNumberOfNodes(void);
    6668                void  CreateJacobianMatrix(Matrix<IssmDouble>* Jff){_error_("Not implemented yet");};
    6769                void  PenaltyCreateJacobianMatrix(Matrix<IssmDouble>* Jff,IssmDouble kmax){_error_("Not implemented yet");};
    6870                void  PenaltyCreateKMatrix(Matrix<IssmDouble>* Kff, Matrix<IssmDouble>* kfs, IssmDouble kmax);
    6971                void  PenaltyCreatePVector(Vector<IssmDouble>* pf, IssmDouble kmax);
     72                void  SetwiseNodeConnectivity(int* d_nz,int* o_nz,Node* node,bool* flags,int set1_enum,int set2_enum);
    7073                bool  InAnalysis(int analysis_type);
    7174                /*}}}*/
  • issm/trunk-jpl/src/c/classes/objects/Loads/Pengrid.cpp

    r13761 r13915  
    207207        return;
    208208
     209}
     210/*}}}*/
     211/*FUNCTION Pengrid::GetNodesSidList{{{*/
     212void Pengrid::GetNodesSidList(int* sidlist){
     213
     214        _assert_(sidlist);
     215        _assert_(node);
     216
     217        sidlist[0]=node->Sid();
     218}
     219/*}}}*/
     220/*FUNCTION Pengrid::GetNumberOfNodes{{{*/
     221int Pengrid::GetNumberOfNodes(void){
     222
     223        return NUMVERTICES;
    209224}
    210225/*}}}*/
     
    280295}
    281296/*}}}*/
     297/*FUNCTION Pengrid::SetwiseNodeConnectivity{{{*/
     298void Pengrid::SetwiseNodeConnectivity(int* pd_nz,int* po_nz,Node* node,bool* flags,int set1_enum,int set2_enum){
     299
     300        /*Output */
     301        int d_nz = 0;
     302        int o_nz = 0;
     303
     304        if(!flags[this->node->Sid()]){
     305
     306                /*flag current node so that no other element processes it*/
     307                flags[this->node->Sid()]=true;
     308
     309                /*if node is clone, we have an off-diagonal non-zero, else it is a diagonal non-zero*/
     310                switch(set2_enum){
     311                        case FsetEnum:
     312                                if(node->indexing.fsize){
     313                                        if(this->node->IsClone())
     314                                         o_nz += 1;
     315                                        else
     316                                         d_nz += 1;
     317                                }
     318                                break;
     319                        case GsetEnum:
     320                                if(node->indexing.gsize){
     321                                        if(this->node->IsClone())
     322                                         o_nz += 1;
     323                                        else
     324                                         d_nz += 1;
     325                                }
     326                                break;
     327                        case SsetEnum:
     328                                if(node->indexing.ssize){
     329                                        if(this->node->IsClone())
     330                                         o_nz += 1;
     331                                        else
     332                                         d_nz += 1;
     333                                }
     334                                break;
     335                        default: _error_("not supported");
     336                }
     337        }
     338
     339        /*Assign output pointers: */
     340        *pd_nz=d_nz;
     341        *po_nz=o_nz;
     342}
     343/*}}}*/
    282344
    283345/*Update virtual functions definitions:*/
  • issm/trunk-jpl/src/c/classes/objects/Loads/Pengrid.h

    r13623 r13915  
    7272                void  CreatePVector(Vector<IssmDouble>* pf);
    7373                void  CreateJacobianMatrix(Matrix<IssmDouble>* Jff){_error_("Not implemented yet");};
     74                void  GetNodesSidList(int* sidlist);
     75                int   GetNumberOfNodes(void);
    7476                void  PenaltyCreateJacobianMatrix(Matrix<IssmDouble>* Jff,IssmDouble kmax){_error_("Not implemented yet");};
    7577                void  PenaltyCreateKMatrix(Matrix<IssmDouble>* Kff, Matrix<IssmDouble>* kfs, IssmDouble kmax);
    7678                void  PenaltyCreatePVector(Vector<IssmDouble>* pf, IssmDouble kmax);
     79                void  SetwiseNodeConnectivity(int* d_nz,int* o_nz,Node* node,bool* flags,int set1_enum,int set2_enum);
    7780                bool  InAnalysis(int analysis_type);
    7881                /*}}}*/
  • issm/trunk-jpl/src/c/classes/objects/Loads/Penpair.cpp

    r13761 r13915  
    146146void  Penpair::CreateJacobianMatrix(Matrix<IssmDouble>* Jff){
    147147        this->CreateKMatrix(Jff,NULL);
     148}
     149/*}}}*/
     150/*FUNCTION Penpair::GetNodesSidList{{{*/
     151void Penpair::GetNodesSidList(int* sidlist){
     152
     153        _assert_(sidlist);
     154        _assert_(nodes);
     155
     156        for(int i=0;i<NUMVERTICES;i++) sidlist[i]=nodes[i]->Sid();
     157}
     158/*}}}*/
     159/*FUNCTION Penpair::GetNumberOfNodes{{{*/
     160int Penpair::GetNumberOfNodes(void){
     161
     162        return NUMVERTICES;
    148163}
    149164/*}}}*/
     
    189204        if (in_analysis_type==this->analysis_type)return true;
    190205        else return false;
     206}
     207/*}}}*/
     208/*FUNCTION Penpair::SetwiseNodeConnectivity{{{*/
     209void Penpair::SetwiseNodeConnectivity(int* pd_nz,int* po_nz,Node* node,bool* flags,int set1_enum,int set2_enum){
     210
     211        /*Output */
     212        int d_nz = 0;
     213        int o_nz = 0;
     214
     215        /*Loop over all nodes*/
     216        for(int i=0;i<NUMVERTICES;i++){
     217
     218                if(!flags[this->nodes[i]->Sid()]){
     219
     220                        /*flag current node so that no other element processes it*/
     221                        flags[this->nodes[i]->Sid()]=true;
     222
     223                        /*if node is clone, we have an off-diagonal non-zero, else it is a diagonal non-zero*/
     224                        switch(set2_enum){
     225                                case FsetEnum:
     226                                        if(nodes[i]->indexing.fsize){
     227                                                if(this->nodes[i]->IsClone())
     228                                                 o_nz += 1;
     229                                                else
     230                                                 d_nz += 1;
     231                                        }
     232                                        break;
     233                                case GsetEnum:
     234                                        if(nodes[i]->indexing.gsize){
     235                                                if(this->nodes[i]->IsClone())
     236                                                 o_nz += 1;
     237                                                else
     238                                                 d_nz += 1;
     239                                        }
     240                                        break;
     241                                case SsetEnum:
     242                                        if(nodes[i]->indexing.ssize){
     243                                                if(this->nodes[i]->IsClone())
     244                                                 o_nz += 1;
     245                                                else
     246                                                 d_nz += 1;
     247                                        }
     248                                        break;
     249                                default: _error_("not supported");
     250                        }
     251                }
     252        }
     253
     254        /*Assign output pointers: */
     255        *pd_nz=d_nz;
     256        *po_nz=o_nz;
    191257}
    192258/*}}}*/
  • issm/trunk-jpl/src/c/classes/objects/Loads/Penpair.h

    r13623 r13915  
    5757                void  CreatePVector(Vector<IssmDouble>* pf);
    5858                void  CreateJacobianMatrix(Matrix<IssmDouble>* Jff);
     59                void  GetNodesSidList(int* sidlist);
     60                int   GetNumberOfNodes(void);
    5961                void  PenaltyCreateKMatrix(Matrix<IssmDouble>* Kff,Matrix<IssmDouble>* Kfs,IssmDouble kmax);
    6062                void  PenaltyCreatePVector(Vector<IssmDouble>* pf, IssmDouble kmax);
    6163                void  PenaltyCreateJacobianMatrix(Matrix<IssmDouble>* Jff,IssmDouble kmax);
     64                void  SetwiseNodeConnectivity(int* d_nz,int* o_nz,Node* node,bool* flags,int set1_enum,int set2_enum);
    6265                bool  InAnalysis(int analysis_type);
    6366                /*}}}*/
  • issm/trunk-jpl/src/c/classes/objects/Loads/Riftfront.cpp

    r13787 r13915  
    364364}
    365365/*}}}*/
     366/*FUNCTION Riftfront::GetNodesSidList{{{*/
     367void Riftfront::GetNodesSidList(int* sidlist){
     368
     369        _assert_(sidlist);
     370        _assert_(nodes);
     371
     372        for(int i=0;i<NUMVERTICES;i++) sidlist[i]=nodes[i]->Sid();
     373}
     374/*}}}*/
     375/*FUNCTION Riftfront::GetNumberOfNodes{{{*/
     376int Riftfront::GetNumberOfNodes(void){
     377
     378        return NUMVERTICES;
     379}
     380/*}}}*/
    366381/*FUNCTION Riftfront::InAnalysis{{{*/
    367382bool Riftfront::InAnalysis(int in_analysis_type){
    368383        if (in_analysis_type==this->analysis_type) return true;
    369384        else return false;
     385}
     386/*}}}*/
     387/*FUNCTION Riftfront::SetwiseNodeConnectivity{{{*/
     388void Riftfront::SetwiseNodeConnectivity(int* pd_nz,int* po_nz,Node* node,bool* flags,int set1_enum,int set2_enum){
     389
     390        /*Output */
     391        int d_nz = 0;
     392        int o_nz = 0;
     393
     394        /*Loop over all nodes*/
     395        for(int i=0;i<NUMVERTICES;i++){
     396
     397                if(!flags[this->nodes[i]->Sid()]){
     398
     399                        /*flag current node so that no other element processes it*/
     400                        flags[this->nodes[i]->Sid()]=true;
     401
     402                        /*if node is clone, we have an off-diagonal non-zero, else it is a diagonal non-zero*/
     403                        switch(set2_enum){
     404                                case FsetEnum:
     405                                        if(nodes[i]->indexing.fsize){
     406                                                if(this->nodes[i]->IsClone())
     407                                                 o_nz += 1;
     408                                                else
     409                                                 d_nz += 1;
     410                                        }
     411                                        break;
     412                                case GsetEnum:
     413                                        if(nodes[i]->indexing.gsize){
     414                                                if(this->nodes[i]->IsClone())
     415                                                 o_nz += 1;
     416                                                else
     417                                                 d_nz += 1;
     418                                        }
     419                                        break;
     420                                case SsetEnum:
     421                                        if(nodes[i]->indexing.ssize){
     422                                                if(this->nodes[i]->IsClone())
     423                                                 o_nz += 1;
     424                                                else
     425                                                 d_nz += 1;
     426                                        }
     427                                        break;
     428                                default: _error_("not supported");
     429                        }
     430                }
     431        }
     432
     433        /*Assign output pointers: */
     434        *pd_nz=d_nz;
     435        *po_nz=o_nz;
    370436}
    371437/*}}}*/
  • issm/trunk-jpl/src/c/classes/objects/Loads/Riftfront.h

    r13623 r13915  
    7878                void  CreatePVector(Vector<IssmDouble>* pf);
    7979                void  CreateJacobianMatrix(Matrix<IssmDouble>* Jff){_error_("Not implemented yet");};
     80                void  GetNodesSidList(int* sidlist);
     81                int   GetNumberOfNodes(void);
    8082                void  PenaltyCreateJacobianMatrix(Matrix<IssmDouble>* Jff,IssmDouble kmax){_error_("Not implemented yet");};
    8183                void  PenaltyCreateKMatrix(Matrix<IssmDouble>* Kff, Matrix<IssmDouble>* kfs, IssmDouble kmax);
    8284                void  PenaltyCreatePVector(Vector<IssmDouble>* pf, IssmDouble kmax);
     85                void  SetwiseNodeConnectivity(int* d_nz,int* o_nz,Node* node,bool* flags,int set1_enum,int set2_enum);
    8386                bool  InAnalysis(int analysis_type);
    8487                /*}}}*/
Note: See TracChangeset for help on using the changeset viewer.