Changeset 23599


Ignore:
Timestamp:
01/03/19 20:42:49 (6 years ago)
Author:
Mathieu Morlighem
Message:

CHG: more cleanup

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

Legend:

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

    r23576 r23599  
    22812281
    22822282}
    2283 /*}}}*/
    2284 void       Penta::SetClone(int* minranks){/*{{{*/
    2285 
    2286         _error_("not implemented yet");
    2287 }
    2288 
    22892283/*}}}*/
    22902284void       Penta::SetControlInputsFromVector(IssmDouble* vector,int control_enum,int control_index,int offset, int N, int M){/*{{{*/
  • issm/trunk-jpl/src/c/classes/Elements/Penta.h

    r23035 r23599  
    149149                void           ResetFSBasalBoundaryCondition(void);
    150150                void           ResetHooks();
    151                 void             SetClone(int* minranks);
    152151                void           SetControlInputsFromVector(IssmDouble* vector,int control_enum,int control_index,int offset, int N,int M);
    153152                void           SetControlInputsFromVector(IssmDouble* vector,int control_enum,int control_index);
  • issm/trunk-jpl/src/c/classes/Elements/Tria.cpp

    r23532 r23599  
    32633263}
    32643264/*}}}*/
    3265 void       Tria::SetClone(int* minranks){/*{{{*/
    3266 
    3267         _error_("not implemented yet");
    3268 }
    3269 /*}}}*/
    32703265void       Tria::SetControlInputsFromVector(IssmDouble* vector,int control_enum,int control_index,int offset,int N, int M){/*{{{*/
    32713266
  • issm/trunk-jpl/src/c/classes/Elements/Tria.h

    r23053 r23599  
    207207                void           NormalSection(IssmDouble* normal,IssmDouble* xyz_list);
    208208                void           NormalTop(IssmDouble* normal,IssmDouble* xyz_list);
    209                 void             SetClone(int* minranks);
    210209                void           SetTemporaryElementType(int element_type_in){_error_("not implemented yet");};
    211210                Seg*             SpawnSeg(int index1,int index2);
  • issm/trunk-jpl/src/c/classes/Node.cpp

    r23588 r23599  
    749749}
    750750/*}}}*/
    751 void Node::SetClone(int* minranks){/*{{{*/
    752 
    753         int my_rank;
    754 
    755         /*recover my_rank:*/
    756         my_rank=IssmComm::GetRank();
    757 
    758         if (minranks[sid]==my_rank){
    759                 indexing.clone=false;
    760         }
    761         else{
    762                 /*!there is a cpu with lower rank that has the same node,
    763                 therefore, I am a clone*/
    764                 indexing.clone=true;   
    765         }
    766 }
    767 /*}}}*/
    768751void Node::ShowTrueDofs(int* truedofs, int ncols,int setenum){/*{{{*/
    769752
  • issm/trunk-jpl/src/c/classes/Node.h

    r23588 r23599  
    7777                void  RelaxConstraint(int dof);
    7878                bool  RequiresDofReindexing(void);
    79                 void  SetClone(int* minranks);
    8079                void  SetCurrentConfiguration(DataSet* nodes,Vertices* vertices);
    8180                void  ShowTrueDofs(int* truerows,int ncols,int setenum);
  • issm/trunk-jpl/src/c/classes/Nodes.cpp

    r23597 r23599  
    133133void  Nodes::DistributeDofs(int setenum){/*{{{*/
    134134
     135        /*some check: */
     136        _assert_(setenum==GsetEnum || setenum==FsetEnum || setenum==SsetEnum);
     137
    135138        int  i;
    136139        int  dofcount=0;
     
    145148        int num_procs = IssmComm::GetSize();
    146149
    147         /*some check: */
    148         _assert_(setenum==GsetEnum || setenum==FsetEnum || setenum==SsetEnum);
    149 
    150150        /*Go through objects, and distribute dofs locally, from 0 to numberofdofsperobject*/
    151151        for(i=0;i<this->Size();i++){
     
    155155
    156156        /* Now every object has distributed dofs, but locally, and with a dof count starting from
    157          * 0. This means the dofs between all the cpus are not unique. We now offset the dofs of eache
     157         * 0. This means the dofs between all the cpus are not unique. We now offset the dofs of each
    158158         * cpus by the total last dofs of the previus cpu, starting from 0.
    159159         * First: get number of dofs for each cpu*/
  • issm/trunk-jpl/src/c/classes/Vertex.cpp

    r23585 r23599  
    138138int        Vertex::Connectivity(void){return connectivity;}/*{{{*/
    139139/*}}}*/
    140 void       Vertex::DistributePids(int* ppidcount){/*{{{*/
    141 
    142         /*retrieve current pid*/
    143         int pidcount=*ppidcount;
    144 
    145         /*This vertex is a clone! Don't distribute pids, it will get them from another cpu!*/
    146         if(this->clone) return;
    147 
    148         /*This vertex should distribute its pid*/
    149         this->pid=pidcount;
    150         pidcount++;
    151 
    152         /*Assign output pointers: */
    153         *ppidcount=pidcount;
    154 }
    155 /*}}}*/
    156140IssmDouble Vertex::GetLatitude(){/*{{{*/
    157141        return this->latitute;
     
    178162}
    179163/*}}}*/
    180 void       Vertex::OffsetPids(int pidcount){/*{{{*/
    181 
    182         /*This vertex is a clone, don't offset the pids*/
    183         if(this->clone) return;
    184 
    185         /*This vertex should offset his pid, go ahead: */
    186         this->pid+=pidcount;
    187 }
    188 /*}}}*/
    189164int        Vertex::Pid(void){ return pid; }/*{{{*/
    190165/*}}}*/
    191166int        Vertex::Lid(void){ return lid; }/*{{{*/
    192167/*}}}*/
    193 void       Vertex::SetClone(int* minranks){/*{{{*/
    194 
    195         int my_rank;
    196 
    197         /*recover my_rank:*/
    198         my_rank=IssmComm::GetRank();
    199 
    200         if (minranks[this->sid]==my_rank){
    201                 this->clone=false;
    202         }
    203         else{
    204                 /*!there is a cpu with lower rank that has the same vertex,
    205                 therefore, I am a clone*/
    206                 this->clone=true;
    207         }
    208 
    209 }
    210 /*}}}*/
    211 void       Vertex::ShowTruePids(int* truepids){/*{{{*/
    212 
    213         /*Are we a clone? : */
    214         if(this->clone)return;
    215 
    216         /*Ok, we are not a clone, just plug our pid into truepids: */
    217         truepids[this->sid]=this->pid;
    218 }
    219 /*}}}*/
    220168int        Vertex::Sid(void){ return sid; }/*{{{*/
    221 /*}}}*/
    222 void       Vertex::UpdateClonePids(int* alltruepids){/*{{{*/
    223 
    224         /*If we are not a clone, don't update, we already have pids: */
    225         if(!this->clone)return;
    226 
    227         /*Ok, we are a clone node, but we did not create the pid for this vertex
    228          * Therefore, our pid is garbage right now. Go pick it up in the alltruepids: */
    229         this->pid=alltruepids[this->sid];
    230 }
    231169/*}}}*/
    232170void       Vertex::UpdatePosition(Vector<IssmDouble>* vx,Vector<IssmDouble>* vy,Vector<IssmDouble>* vz,Parameters* parameters,IssmDouble* surface,IssmDouble* bed){/*{{{*/
  • issm/trunk-jpl/src/c/classes/Vertex.h

    r23585 r23599  
    5151                /*Vertex management:*/
    5252                int        Connectivity(void);
    53                 void       DistributePids(int* ppidcount);
    5453                IssmDouble GetLatitude(void);
    5554                IssmDouble GetLongitude(void);
     
    5857                IssmDouble GetY(void);
    5958                IssmDouble GetZ(void);
    60                 void       OffsetPids(int pidcount);
    6159                int        Pid(void);
    6260                int        Lid(void);
    63                 void       SetClone(int* minranks);
    64                 void       ShowTruePids(int* borderpids);
    6561                int        Sid(void);
    66                 void       UpdateClonePids(int* allborderpids);
    6762                void       UpdatePosition(Vector<IssmDouble>* vx,Vector<IssmDouble>* vy,Vector<IssmDouble>* vz,Parameters* parameters,IssmDouble* thickness,IssmDouble* bed);
    6863                void       VertexCoordinates(Vector<IssmDouble>* vx,Vector<IssmDouble>* vy,Vector<IssmDouble>* vz,bool spherical=false);
  • issm/trunk-jpl/src/c/classes/Vertices.cpp

    r23586 r23599  
    127127}
    128128/*}}}*/
    129 void  Vertices::DistributePids(int numberofobjects){/*{{{*/
    130 
    131         int num_procs;
    132         int my_rank;
    133 
    134         int  i;
    135         int  pidcount    = 0;
    136         int *allpidcount = NULL;
    137         int *truepids    = NULL;
    138         int *alltruepids = NULL;
    139 
    140         /*recover my_rank:*/
    141         my_rank=IssmComm::GetRank();
    142         num_procs=IssmComm::GetSize();
    143 
    144         /*Go through objects, and distribute pids locally, from 0 to numberofpidsperobject*/
    145         for (i=0;i<this->Size();i++){
    146                 Vertex* vertex=xDynamicCast<Vertex*>(this->GetObjectByOffset(i));
    147                 vertex->DistributePids(&pidcount);
    148         }
    149 
    150         /* Now every object has distributed pids, but locally, and with a pid count starting from
    151          * 0. This means the pids between all the cpus are not unique. We now offset the pids of each
    152          * cpus by the total last pids of the previus cpu, starting from 0.
    153          * First: get number of pids for each cpu*/
    154         allpidcount=xNew<int>(num_procs);
    155         ISSM_MPI_Gather(&pidcount,1,ISSM_MPI_INT,allpidcount,1,ISSM_MPI_INT,0,IssmComm::GetComm());
    156         ISSM_MPI_Bcast(allpidcount,num_procs,ISSM_MPI_INT,0,IssmComm::GetComm());
    157 
    158         /* Every cpu should start its own pid count at the end of the pidcount from cpu-1*/
    159         pidcount=0;
    160         if(my_rank!=0){
    161                 for(i=0;i<my_rank;i++){
    162                         pidcount+=allpidcount[i];
    163                 }
    164         }
    165         for (i=0;i<this->Size();i++){
    166                 Vertex* vertex=xDynamicCast<Vertex*>(this->GetObjectByOffset(i));
    167                 vertex->OffsetPids(pidcount);
    168         }
    169 
    170         /* Finally, remember that cpus may have skipped some objects, because they were clones. For every
    171          * object that is not a clone, tell them to show their pids, so that later on, they can get picked
    172          * up by their clones: */
    173         truepids   =xNewZeroInit<int>(numberofobjects);
    174         alltruepids=xNewZeroInit<int>(numberofobjects);
    175         for (i=0;i<this->Size();i++){
    176                 Vertex* vertex=xDynamicCast<Vertex*>(this->GetObjectByOffset(i));
    177                 vertex->ShowTruePids(truepids);
    178         }
    179         ISSM_MPI_Allreduce((void*)truepids,(void*)alltruepids,numberofobjects,ISSM_MPI_INT,ISSM_MPI_MAX,IssmComm::GetComm());
    180 
    181         /* Now every cpu knows the true pids of everyone else that is not a clone*/
    182         for(i=0;i<this->Size();i++){
    183                 Vertex* vertex=xDynamicCast<Vertex*>(this->GetObjectByOffset(i));
    184                 vertex->UpdateClonePids(alltruepids);
    185         }
    186 
    187         /* Free ressources: */
    188         xDelete<int>(allpidcount);
    189         xDelete<int>(truepids);
    190         xDelete<int>(alltruepids);
    191 }
    192 /*}}}*/
    193129int Vertices::NumberOfVertices(void){/*{{{*/
    194130
     
    197133        int vertex_max_sid;
    198134
    199         if (this->Size()==0)return 0;
     135        if(this->Size()==0) return 0;
    200136
    201137        for(i=0;i<this->Size();i++){
  • issm/trunk-jpl/src/c/classes/Vertices.h

    r23586 r23599  
    2929
    3030                /*numerics:*/
    31                 void  DistributePids(int numberofnodes);
    3231                int   NumberOfVertices(void);
    3332                void  LatLonList(IssmDouble** lat,IssmDouble** lon);
Note: See TracChangeset for help on using the changeset viewer.