Changeset 26144


Ignore:
Timestamp:
03/23/21 20:50:30 (4 years ago)
Author:
Mathieu Morlighem
Message:

CHG: simplifying node as well

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

Legend:

Unmodified
Added
Removed
  • TabularUnified issm/trunk-jpl/src/c/classes/Elements/Element.cpp

    r26138 r26144  
    5656
    5757        for(int i=0;i<numnodes;i++){
    58                 if(nodes[i]->fsize) return true;
     58                if(nodes[i]->FSize()) return true;
    5959        }
    6060        return false;
     
    33833383                        switch(set2_enum){
    33843384                                case FsetEnum:
    3385                                         if(nodes[i]->fsize){
     3385                                        if(nodes[i]->FSize()){
    33863386                                                if(this->nodes[i]->IsClone())
    33873387                                                 o_nz += 1;
     
    33993399                                        break;
    34003400                                case SsetEnum:
    3401                                         if(nodes[i]->ssize){
     3401                                        if(nodes[i]->SSize()){
    34023402                                                if(this->nodes[i]->IsClone())
    34033403                                                 o_nz += 1;
  • TabularUnified issm/trunk-jpl/src/c/classes/Loads/Channel.cpp

    r25778 r26144  
    320320                        switch(set2_enum){
    321321                                case FsetEnum:
    322                                         if(nodes[i]->fsize){
     322                                        if(nodes[i]->FSize()){
    323323                                                if(this->nodes[i]->IsClone())
    324324                                                 o_nz += 1;
     
    336336                                        break;
    337337                                case SsetEnum:
    338                                         if(nodes[i]->ssize){
     338                                        if(nodes[i]->SSize()){
    339339                                                if(this->nodes[i]->IsClone())
    340340                                                 o_nz += 1;
  • TabularUnified issm/trunk-jpl/src/c/classes/Loads/Moulin.cpp

    r25697 r26144  
    291291                switch(set2_enum){
    292292                        case FsetEnum:
    293                                 if(node->fsize){
     293                                if(node->FSize()){
    294294                                        if(this->node->IsClone())
    295295                                         o_nz += 1;
     
    307307                                break;
    308308                        case SsetEnum:
    309                                 if(node->ssize){
     309                                if(node->SSize()){
    310310                                        if(this->node->IsClone())
    311311                                         o_nz += 1;
  • TabularUnified issm/trunk-jpl/src/c/classes/Loads/Neumannflux.cpp

    r25508 r26144  
    306306                        switch(set2_enum){
    307307                                case FsetEnum:
    308                                         if(nodes[i]->fsize){
     308                                        if(nodes[i]->FSize()){
    309309                                                if(this->nodes[i]->IsClone())
    310310                                                 o_nz += 1;
     
    322322                                        break;
    323323                                case SsetEnum:
    324                                         if(nodes[i]->ssize){
     324                                        if(nodes[i]->SSize()){
    325325                                                if(this->nodes[i]->IsClone())
    326326                                                 o_nz += 1;
  • TabularUnified issm/trunk-jpl/src/c/classes/Loads/Numericalflux.cpp

    r25508 r26144  
    430430                        switch(set2_enum){
    431431                                case FsetEnum:
    432                                         if(nodes[i]->fsize){
     432                                        if(nodes[i]->FSize()){
    433433                                                if(this->nodes[i]->IsClone())
    434434                                                 o_nz += 1;
     
    446446                                        break;
    447447                                case SsetEnum:
    448                                         if(nodes[i]->ssize){
     448                                        if(nodes[i]->SSize()){
    449449                                                if(this->nodes[i]->IsClone())
    450450                                                 o_nz += 1;
  • TabularUnified issm/trunk-jpl/src/c/classes/Loads/Pengrid.cpp

    r25508 r26144  
    294294                switch(set2_enum){
    295295                        case FsetEnum:
    296                                 if(node->fsize){
     296                                if(node->FSize()){
    297297                                        if(this->node->IsClone())
    298298                                         o_nz += 1;
     
    310310                                break;
    311311                        case SsetEnum:
    312                                 if(node->ssize){
     312                                if(node->SSize()){
    313313                                        if(this->node->IsClone())
    314314                                         o_nz += 1;
  • TabularUnified issm/trunk-jpl/src/c/classes/Loads/Penpair.cpp

    r25508 r26144  
    235235                        switch(set2_enum){
    236236                                case FsetEnum:
    237                                         if(nodes[i]->fsize){
     237                                        if(nodes[i]->FSize()){
    238238                                                if(this->nodes[i]->IsClone())
    239239                                                 o_nz += 1;
     
    251251                                        break;
    252252                                case SsetEnum:
    253                                         if(nodes[i]->ssize){
     253                                        if(nodes[i]->SSize()){
    254254                                                if(this->nodes[i]->IsClone())
    255255                                                 o_nz += 1;
  • TabularUnified issm/trunk-jpl/src/c/classes/Loads/Riftfront.cpp

    r25508 r26144  
    392392                        switch(set2_enum){
    393393                                case FsetEnum:
    394                                         if(nodes[i]->fsize){
     394                                        if(nodes[i]->FSize()){
    395395                                                if(this->nodes[i]->IsClone())
    396396                                                 o_nz += 1;
     
    408408                                        break;
    409409                                case SsetEnum:
    410                                         if(nodes[i]->ssize){
     410                                        if(nodes[i]->SSize()){
    411411                                                if(this->nodes[i]->IsClone())
    412412                                                 o_nz += 1;
  • TabularUnified issm/trunk-jpl/src/c/classes/Node.cpp

    r26136 r26144  
    2020        this->approximation  = 0;
    2121        this->gsize          = -1;
    22         this->fsize          = -1;
    23         this->ssize          = -1;
    2422        this->clone          = false;
    2523        this->active         = true;
     
    6967                this->gdoflist       = xNew<int>(this->gsize);
    7068                this->gdoflist_local = xNew<int>(this->gsize);
    71                 this->fsize          = -1;
    72                 this->ssize          = -1;
    7369                this->fdoflist       = xNew<int>(this->gsize);
    7470                this->sdoflist       = xNew<int>(this->gsize);
     
    8278                this->gdoflist       = NULL;
    8379                this->gdoflist_local = NULL;
    84                 this->fsize          = -1;
    85                 this->ssize          = -1;
    8680                this->fdoflist       = NULL;
    8781                this->sdoflist       = NULL;
     
    215209        output->indexingupdate = this->indexingupdate;
    216210        output->gsize  = this->gsize;
    217         output->fsize  = this->fsize;
    218         output->ssize  = this->ssize;
    219211        output->clone  = this->clone;
    220212        output->active = this->active;
     
    264256
    265257        marshallhandle->call(this->gsize);
    266         marshallhandle->call(this->fsize);
    267         marshallhandle->call(this->ssize);
    268258        marshallhandle->call(this->clone);
    269259        marshallhandle->call(this->active);
     
    292282        _printf_("   indexingupdate: " << indexingupdate << "\n");
    293283        _printf_("   gsize:  " << gsize << "\n");
    294         _printf_("   fsize:  " << fsize << "\n");
    295         _printf_("   ssize:  " << ssize << "\n");
    296284        _printf_("   clone:  " << clone << "\n");
    297285        _printf_("   active: " << active << "\n");
     
    303291        for(i=0;i<gsize;i++) _printf_((s_set[i]?1:0)<< " ");
    304292        _printf_("]\n");
    305         _printf_("   svalues (" << this->ssize << "): |");
     293        _printf_("   svalues: |");
    306294        for(i=0;i<this->gsize;i++){
    307295                if(this->s_set[i])_printf_(" " << svalues[i] << " |");
     
    351339        _printf_("   indexingupdate: " << indexingupdate << "\n");
    352340        _printf_("   gsize:  " << gsize << "\n");
    353         _printf_("   fsize:  " << fsize << "\n");
    354         _printf_("   ssize:  " << ssize << "\n");
    355341        _printf_("   clone:  " << clone << "\n");
    356342        _printf_("   active: " << active << "\n");
     
    479465void Node::CreateNodalConstraints(Vector<IssmDouble>* ys){/*{{{*/
    480466
    481         if(this->ssize){
     467        if(this->SSize()){
    482468                /*Add values into constraint vector: */
    483469                ys->SetValues(this->gsize,this->sdoflist,this->svalues,INS_VAL);
     
    555541        if(approximation_enum==NoneApproximationEnum){
    556542                if      (setenum==GsetEnum) numdofs=this->gsize;
    557                 else if (setenum==FsetEnum) numdofs=this->fsize;
    558                 else if (setenum==SsetEnum) numdofs=this->ssize;
     543                else if (setenum==FsetEnum) numdofs=this->FSize();
     544                else if (setenum==SsetEnum) numdofs=this->SSize();
    559545                else _error_("set of enum type " << EnumToStringx(setenum) << " not supported yet!");
    560546        }
     
    576562                                }
    577563                        }
    578                         else numdofs=this->fsize;
     564                        else numdofs=this->FSize();
    579565                }
    580566                else if (setenum==SsetEnum){
     
    585571                                }
    586572                        }
    587                         else numdofs=this->ssize;
     573                        else numdofs=this->SSize();
    588574                }
    589575                else _error_("set of enum type " << EnumToStringx(setenum) << " not supported yet!");
     
    628614        if(this->IsClone()) return;
    629615
    630         if(this->fsize){
    631                 int*        indices = xNew<int>(this->fsize);
    632                 IssmDouble* values  = xNew<IssmDouble>(this->fsize);
     616        /*Get F size and S size*/
     617        int fsize = this->FSize();
     618        int ssize = this->SSize();
     619
     620        if(fsize){
     621                int*        indices = xNew<int>(fsize);
     622                IssmDouble* values  = xNew<IssmDouble>(fsize);
    633623
    634624                int count = 0;
     
    643633                        }
    644634                }
    645                 ug->SetValues(this->fsize,indices,values,INS_VAL);
     635                ug->SetValues(fsize,indices,values,INS_VAL);
    646636
    647637                xDelete<IssmDouble>(values);
    648638                xDelete<int>(indices);
    649639        }
    650         if(this->ssize){
    651                 int*        indices = xNew<int>(this->ssize);
    652                 IssmDouble* values  = xNew<IssmDouble>(this->ssize);
     640        if(ssize){
     641                int*        indices = xNew<int>(ssize);
     642                IssmDouble* values  = xNew<IssmDouble>(ssize);
    653643
    654644                int count = 0;
     
    663653                        }
    664654                }
    665                 ug->SetValues(this->ssize,indices,values,INS_VAL);
     655                ug->SetValues(ssize,indices,values,INS_VAL);
    666656               
    667657                xDelete<IssmDouble>(values);
     
    676666        if(this->IsClone()) return;
    677667
    678         if(this->fsize){
    679                 int*        indices = xNew<int>(this->fsize);
    680                 IssmDouble* values  = xNew<IssmDouble>(this->fsize);
     668        /*Get F size*/
     669        int fsize = this->FSize();
     670
     671        if(fsize){
     672                int*        indices = xNew<int>(fsize);
     673                IssmDouble* values  = xNew<IssmDouble>(fsize);
    681674
    682675                int count = 0;
     
    692685                        }
    693686                }
    694                 _assert_(count==this->fsize);
    695                 uf->SetValues(this->fsize,indices,values,INS_VAL);
     687                _assert_(count==fsize);
     688                uf->SetValues(fsize,indices,values,INS_VAL);
    696689
    697690                xDelete<IssmDouble>(values);
     
    702695
    703696/* indexing routines:*/
    704 void Node::AllocateDofLists(int setenum){/*{{{*/
    705 
    706         /*Initialize: */
    707         int size=0;
    708 
    709         if(setenum==FsetEnum){
    710                 for(int i=0;i<this->gsize;i++) if(f_set[i])size++;
    711                 this->fsize=size;
    712         }
    713         else if(setenum==SsetEnum){
    714                 for(int i=0;i<this->gsize;i++) if(s_set[i])size++;
    715                 this->ssize=size;
    716         }
    717         /*TODO, we should never be here for GSET! add an assert and track down whether this happens*/
    718 }
    719 /*}}}*/
    720697void Node::DistributeLocalDofs(int* pdofcount,int setenum){/*{{{*/
    721698
     
    729706        }
    730707        else if(setenum==FsetEnum){
    731                 _assert_(this->fsize==0 || this->fdoflist_local);
    732708                for(int i=0;i<this->gsize;i++){
    733709                        if(this->f_set[i]) fdoflist_local[i]=dofcount++;
     
    736712        }
    737713        else if(setenum==SsetEnum){
    738                 _assert_(this->ssize==0 || this->sdoflist_local);
    739714                for(int i=0;i<this->gsize;i++){
    740715                        if(this->s_set[i]) sdoflist_local[i]=dofcount++;
     
    758733        }
    759734        else if(setenum==FsetEnum){
    760                 _assert_(this->fsize==0 || this->fdoflist);
    761735                for(int i=0;i<this->gsize;i++){
    762736                        if(this->f_set[i]) fdoflist[i]=this->fdoflist_local[i]+dofcount;
     
    765739        }
    766740        else if(setenum==SsetEnum){
    767                 _assert_(this->ssize==0 || this->sdoflist);
    768741                for(int i=0;i<this->gsize;i++){
    769742                        if(this->s_set[i]) sdoflist[i]=this->sdoflist_local[i]+dofcount;
     
    816789}
    817790/*}}}*/
     791int  Node::FSize(void){/*{{{*/
     792
     793        _assert_(this && this->gdoflist);
     794
     795        int fsize = 0;
     796        for(int i=0;i<this->gsize;i++) if(this->f_set[i]) fsize++;
     797        return fsize;
     798}
     799/*}}}*/
     800int  Node::SSize(void){/*{{{*/
     801
     802        _assert_(this && this->s_set);
     803
     804        int ssize = 0;
     805        for(int i=0;i<this->gsize;i++) if(this->s_set[i]) ssize++;
     806        return ssize;
     807}
     808/*}}}*/
    818809
    819810/*Methods inherent to Node: */
  • TabularUnified issm/trunk-jpl/src/c/classes/Node.h

    r26131 r26144  
    4343                /*sizes: */
    4444                int gsize;   //number of dofs for a node
    45                 int fsize;   //number of dofs solver for
    46                 int ssize;   //number of constrained dofs
    4745
    4846                /*Activation*/
     
    5654
    5755                /*types of dofs: */
    58                 int        *doftype;   //approximation type of the dofs (used only for coupling), size g_size
     56                int  *doftype;   //approximation type of the dofs (used only for coupling), size g_size
    5957
    6058                /*list of degrees of freedom: */
     
    8078
    8179                /*Node numerical routines*/
    82                 void  AllocateDofLists(int setenum);
    8380                void  Activate(void);
    8481                void  ApplyConstraint(int dof,IssmDouble value);
     
    113110                void  VecReduce(Vector<IssmDouble>* uf, IssmDouble* local_ug,int* indices_ug);
    114111                void  SetApproximation(int in_approximation);
     112                int   SSize();
     113                int   FSize();
    115114};
    116115
  • TabularUnified issm/trunk-jpl/src/c/classes/Nodes.cpp

    r26131 r26144  
    146146        int my_rank   = IssmComm::GetRank();
    147147        int num_procs = IssmComm::GetSize();
    148 
    149         /*First, allocate dof lists based on fset and sset*/
    150         for(Object* & object : this->objects){
    151       Node* node = xDynamicCast<Node*>(object);
    152                 node->AllocateDofLists(setenum);
    153         }
    154148
    155149        /*Now, Build local dofs for masters first*/
  • TabularUnified issm/trunk-jpl/src/c/classes/matrix/ElementMatrix.cpp

    r26131 r26144  
    2222        this->nrows=0;
    2323        this->values=NULL;
    24 
    25         this->fsize=0;
    2624        this->fglobaldoflist=NULL;
    27         this->ssize=0;
    2825        this->sglobaldoflist=NULL;
    2926}
     
    4037        /*intermediaries*/
    4138        int i,j,counter;
    42         int gsize,fsize,ssize;
    4339
    4440        /*If one of the two matrix is NULL, we copy the other one*/
     
    6157
    6258        /*1: Get the new numbering of Ke2 and get size of the new matrix*/
    63         gsize=Ke1->nrows;
     59        int gsize=Ke1->nrows;
    6460        for(i=0;i<Ke2->nrows;i++){
    6561                bool found=false;
     
    9995        }
    10096
    101         /*Fset*/
    102         this->fsize=0;
    103         for(i=0;i<this->nrows;i++) if(this->fglobaldoflist[i]>=0) this->fsize++;
    104 
    105         /*Sset*/
    106         this->ssize=0;
    107         for(i=0;i<this->nrows;i++) if(this->sglobaldoflist[i]>=0) this->ssize++;
    108 
    10997        /*clean-up*/
    11098        xDelete<int>(P);
     
    133121        this->values=xNewZeroInit<IssmDouble>(this->nrows*this->nrows);
    134122
    135         /*g list*/
    136123        this->gglobaldoflist=GetGlobalDofList(nodes,numnodes,GsetEnum,approximation);
    137 
    138         /*get dof lists for f and s set: */
    139         this->fsize=GetNumberOfDofs(nodes,numnodes,FsetEnum,approximation);
    140124        this->fglobaldoflist=GetGlobalDofList(nodes,numnodes,FsetEnum,approximation);
    141         this->ssize=GetNumberOfDofs(nodes,numnodes,SsetEnum,approximation);
    142125        this->sglobaldoflist=GetGlobalDofList(nodes,numnodes,SsetEnum,approximation);
    143126}
     
    163146        this->CheckConsistency();
    164147
    165         if(this->fsize){
     148        /*do we have any component in the F set?*/
     149        int fsize = 0;
     150        for(int i=0;i<this->nrows;i++){
     151                if(this->fglobaldoflist[i]>=0) fsize++;
     152        }
     153
     154        if(fsize){
    166155                /*first, retrieve values that are in the f-set from the g-set values matrix: */
    167156                localvalues=xNew<IssmDouble>(this->nrows);
     
    171160
    172161                /*add local values into global  matrix, using the fglobaldoflist: */
    173                 pf->SetValues(this->fsize,this->fglobaldoflist,localvalues,ADD_VAL);
     162                pf->SetValues(fsize,this->fglobaldoflist,localvalues,ADD_VAL);
    174163
    175164                /*Free ressources:*/
     
    193182        this->CheckConsistency();
    194183
     184        /*do we have any component in the F or S set?*/
     185   bool is_fset= false;
     186        bool is_sset= false;
     187   for(int i=0;i<this->nrows;i++){
     188      if(this->fglobaldoflist[i]>=0){
     189         is_fset = true;
     190      }
     191                else{
     192                        _assert_(this->sglobaldoflist[i]>=0);
     193                        is_sset = true;
     194                }
     195   }
     196
    195197        /*only use row dofs to add values into global matrices: */
    196         if(this->fsize){
    197                 /*add local values into global  matrix, using the fglobaldoflist: */
     198        if(is_fset){
    198199                Kff->SetValues(this->nrows,this->fglobaldoflist,this->nrows,this->fglobaldoflist,this->values,ADD_VAL);
    199200        }
    200 
    201         if((this->ssize!=0) && (this->fsize!=0)){
     201        if(is_fset && is_sset){
    202202                Kfs->SetValues(this->nrows,this->fglobaldoflist,this->nrows,this->sglobaldoflist,this->values,ADD_VAL);
    203203        }
     
    212212        this->CheckConsistency();
    213213
    214         if(this->fsize){
     214        /*do we have any component in the F set?*/
     215        bool isfset= false;
     216        for(int i=0;i<this->nrows;i++){
     217                if(this->fglobaldoflist[i]>=0){
     218                        isfset = true;
     219                        break;
     220                }
     221   }
     222
     223        if(isfset){
    215224                Jff->SetValues(this->nrows,this->fglobaldoflist,this->nrows,this->fglobaldoflist,this->values,ADD_VAL);
    216225        }
     
    246255        if(gglobaldoflist) for(i=0;i<nrows;i++) _printf_(" " << gglobaldoflist[i]); _printf_("\n");
    247256
    248         _printf_("   fsize: " << fsize << "\n");
    249257        _printf_("   fglobaldoflist  (" << fglobaldoflist << "): ");
    250258        for(i=0;i<nrows;i++)_printf_(" " << fglobaldoflist[i]); _printf_(" \n");
    251259
    252         _printf_("   ssize: " << ssize << "\n");
    253260        _printf_("   sglobaldoflist  (" << sglobaldoflist << "): ");
    254261        for(i=0;i<nrows;i++)_printf_(" " << sglobaldoflist[i]); _printf_(" \n");
     
    267274        this->gglobaldoflist=xNew<int>(this->nrows);
    268275        xMemCpy<int>(this->gglobaldoflist,Ke->gglobaldoflist,this->nrows);
    269 
    270         this->fsize=Ke->fsize;
    271276        this->fglobaldoflist=xNew<int>(this->nrows);
    272277        xMemCpy<int>(this->fglobaldoflist,Ke->fglobaldoflist,this->nrows);
    273 
    274         this->ssize=Ke->ssize;
    275278        this->sglobaldoflist=xNew<int>(this->nrows);
    276279        xMemCpy<int>(this->sglobaldoflist,Ke->sglobaldoflist,this->nrows);
  • TabularUnified issm/trunk-jpl/src/c/classes/matrix/ElementMatrix.h

    r26143 r26144  
    2323                int *fglobaldoflist;
    2424                int *sglobaldoflist;
    25                 int  fsize;
    26                 int  ssize;
    2725
    2826        public:
  • TabularUnified issm/trunk-jpl/src/c/classes/matrix/ElementVector.cpp

    r26143 r26144  
    120120        this->CheckConsistency();
    121121
    122         /*Get size of Fset*/
    123    int fsize = 0; for(int i=0;i<this->nrows;i++) if(this->fglobaldoflist[i]>=0) fsize++;
    124 
    125         if(fsize){
     122        /*do we have any component in the F set?*/
     123        bool isfset= false;
     124        for(int i=0;i<this->nrows;i++){
     125                if(this->fglobaldoflist[i]>=0){
     126                        isfset = true;
     127                        break;
     128                }
     129        }
     130
     131        if(isfset){
    126132                pf->SetValues(this->nrows,this->fglobaldoflist,this->values,ADD_VAL);
    127133        }
     
    176182void ElementVector::InsertIntoGlobal(Vector<IssmDouble>* pf){/*{{{*/
    177183
    178         /*Get size of Fset*/
    179         int fsize = 0; for(int i=0;i<this->nrows;i++) if(this->fglobaldoflist[i]>=0) fsize++;
    180 
    181         if(fsize){
     184        /*do we have any component in the F set?*/
     185        bool isfset= false;
     186        for(int i=0;i<this->nrows;i++){
     187                if(this->fglobaldoflist[i]>=0){
     188                        isfset = true;
     189                        break;
     190                }
     191        }
     192
     193        if(isfset){
    182194                /*add local values into global  vector, using the fglobaldoflist: */
    183195                pf->SetValues(this->nrows,this->fglobaldoflist,this->values,INS_VAL);
  • TabularUnified issm/trunk-jpl/src/c/modules/AllocateSystemMatricesx/AllocateSystemMatricesx.cpp

    r25554 r26144  
    256256                        int   lid = node->Lid();
    257257                        if(!node->IsClone()){
    258                                 for(j=0;j<node->fsize;j++){
     258                                int node_fsize = node->FSize();
     259                                for(j=0;j<node_fsize;j++){
    259260                                        _assert_(count<m);
    260261                                        d_nnz[count]=numberofdofspernode*(d_connectivity[lid] + reCast<int>(serial_connectivity_clone[lid]));
Note: See TracChangeset for help on using the changeset viewer.