Changeset 13833


Ignore:
Timestamp:
10/26/12 10:30:15 (12 years ago)
Author:
Mathieu Morlighem
Message:

NEW: added NumberofDofLocal for matrix allocation

Location:
issm/trunk-jpl/src/c/Container
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk-jpl/src/c/Container/Nodes.cpp

    r13813 r13833  
    5555/*FUNCTION Nodes::DistributeDofs{{{*/
    5656void  Nodes::DistributeDofs(int analysis_type,int setenum){
    57 
    58         int num_procs;
    59         int my_rank;
    6057
    6158        int  i;
     
    6865
    6966        /*recover my_rank:*/
    70         my_rank=IssmComm::GetRank();
    71         num_procs=IssmComm::GetSize();
     67        int my_rank   = IssmComm::GetRank();
     68        int num_procs = IssmComm::GetSize();
    7269
    7370        /*some check: */
     
    9895        /* Every cpu should start its own dof count at the end of the dofcount from cpu-1*/
    9996        dofcount=0;
    100         if(my_rank!=0){
    101                 for(i=0;i<my_rank;i++){
    102                         dofcount+=alldofcount[i];
    103                 }
     97        for(i=0;i<my_rank;i++){
     98                dofcount+=alldofcount[i];
    10499        }
    105100        for (i=0;i<this->Size();i++){
     
    202197
    203198        int i;
    204         int   max=0;
    205         int   allmax;
    206         int   numdofs=0;
     199        int max=0;
     200        int allmax;
     201        int numdofs=0;
    207202
    208203        /*Now go through all nodes, and get how many dofs they own, unless they are clone nodes: */
     
    215210
    216211                        numdofs=node->GetNumberOfDofs(NoneApproximationEnum,setenum);
    217                         if (numdofs>max)max=numdofs;
     212                        if(numdofs>max)max=numdofs;
    218213                }
    219214        }
     
    221216        /*Grab max of all cpus: */
    222217        #ifdef _HAVE_MPI_
    223         MPI_Allreduce ( (void*)&max,(void*)&allmax,1,MPI_INT,MPI_MAX,IssmComm::GetComm());
     218        MPI_Allreduce((void*)&max,(void*)&allmax,1,MPI_INT,MPI_MAX,IssmComm::GetComm());
    224219        max=allmax;
    225220        #endif
     
    231226int   Nodes::NumberOfDofs(int analysis_type,int setenum){
    232227
    233         int i;
     228        int   allnumdofs;
     229
     230        /*Get number of dofs on current cpu (excluding clones)*/
     231        int numdofs=this->NumberOfDofsLocal(analysis_type,setenum);
     232
     233        /*Gather from all cpus: */
     234        #ifdef _HAVE_MPI_
     235        MPI_Allreduce ( (void*)&numdofs,(void*)&allnumdofs,1,MPI_INT,MPI_SUM,IssmComm::GetComm());
     236        #else
     237        allnumdofs=numdofs;
     238        #endif
     239        return allnumdofs;
     240}
     241/*}}}*/
     242/*FUNCTION Nodes::NumberOfDofsLocal{{{*/
     243int   Nodes::NumberOfDofsLocal(int analysis_type,int setenum){
    234244
    235245        int   numdofs=0;
    236         int   allnumdofs;
    237246
    238247        /*Now go through all nodes, and get how many dofs they own, unless they are clone nodes: */
    239         for(i=0;i<this->Size();i++){
     248        for(int i=0;i<this->Size();i++){
    240249
    241250                Node* node=dynamic_cast<Node*>(this->GetObjectByOffset(i));
     
    246255                        /*Ok, this object is a node, ask it to plug values into partition: */
    247256                        if (!node->IsClone()){
    248 
    249257                                numdofs+=node->GetNumberOfDofs(NoneApproximationEnum,setenum);
    250 
    251258                        }
    252259                }
    253260        }
    254261
    255         /*Gather from all cpus: */
    256         #ifdef _HAVE_MPI_
    257         MPI_Allreduce ( (void*)&numdofs,(void*)&allnumdofs,1,MPI_INT,MPI_SUM,IssmComm::GetComm());
    258         #else
    259         allnumdofs=numdofs;
    260         #endif
    261         return allnumdofs;
     262        return numdofs;
    262263}
    263264/*}}}*/
     
    267268        /*Careful! only use once all clones have been setup for all nodes!: */
    268269
    269         int i;
    270 
    271         int   numnodes=0;
    272         int   allnumnodes=0;
     270        int numnodes=0;
     271        int allnumnodes=0;
    273272
    274273        /*Now go through all nodes, and get how many dofs they own, unless they are clone nodes: */
    275         for(i=0;i<this->Size();i++){
     274        for(int i=0;i<this->Size();i++){
    276275                Node* node=dynamic_cast<Node*>(this->GetObjectByOffset(i));
    277276
     
    333332
    334333        int my_rank;
    335         int        sid;
     334        int sid;
    336335
    337336        /*recover my_rank:*/
     
    358357        Node* node=NULL;
    359358
    360         for ( object=objects.begin() ; object < objects.end(); object++ ){
     359        for (object=objects.begin() ; object < objects.end(); object++ ){
    361360
    362361                node=dynamic_cast<Node*>(*object);
     
    364363
    365364        }
    366 
    367 }
    368 /*}}}*/
     365}
     366/*}}}*/
  • issm/trunk-jpl/src/c/Container/Nodes.h

    r13797 r13833  
    2323                int   MaxNumDofs(int analysis_type,int setenum);
    2424                int   NumberOfDofs(int analysis_type,int setenum);
     25                int   NumberOfDofsLocal(int analysis_type,int setenum);
    2526                int   NumberOfNodes(int analysis_type);
    2627                int   NumberOfNodes(void);
Note: See TracChangeset for help on using the changeset viewer.