Changeset 13833
- Timestamp:
- 10/26/12 10:30:15 (12 years ago)
- Location:
- issm/trunk-jpl/src/c/Container
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk-jpl/src/c/Container/Nodes.cpp
r13813 r13833 55 55 /*FUNCTION Nodes::DistributeDofs{{{*/ 56 56 void Nodes::DistributeDofs(int analysis_type,int setenum){ 57 58 int num_procs;59 int my_rank;60 57 61 58 int i; … … 68 65 69 66 /*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(); 72 69 73 70 /*some check: */ … … 98 95 /* Every cpu should start its own dof count at the end of the dofcount from cpu-1*/ 99 96 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]; 104 99 } 105 100 for (i=0;i<this->Size();i++){ … … 202 197 203 198 int i; 204 int 205 int 206 int 199 int max=0; 200 int allmax; 201 int numdofs=0; 207 202 208 203 /*Now go through all nodes, and get how many dofs they own, unless they are clone nodes: */ … … 215 210 216 211 numdofs=node->GetNumberOfDofs(NoneApproximationEnum,setenum); 217 if 212 if(numdofs>max)max=numdofs; 218 213 } 219 214 } … … 221 216 /*Grab max of all cpus: */ 222 217 #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()); 224 219 max=allmax; 225 220 #endif … … 231 226 int Nodes::NumberOfDofs(int analysis_type,int setenum){ 232 227 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{{{*/ 243 int Nodes::NumberOfDofsLocal(int analysis_type,int setenum){ 234 244 235 245 int numdofs=0; 236 int allnumdofs;237 246 238 247 /*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++){ 240 249 241 250 Node* node=dynamic_cast<Node*>(this->GetObjectByOffset(i)); … … 246 255 /*Ok, this object is a node, ask it to plug values into partition: */ 247 256 if (!node->IsClone()){ 248 249 257 numdofs+=node->GetNumberOfDofs(NoneApproximationEnum,setenum); 250 251 258 } 252 259 } 253 260 } 254 261 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; 262 263 } 263 264 /*}}}*/ … … 267 268 /*Careful! only use once all clones have been setup for all nodes!: */ 268 269 269 int i; 270 271 int numnodes=0; 272 int allnumnodes=0; 270 int numnodes=0; 271 int allnumnodes=0; 273 272 274 273 /*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++){ 276 275 Node* node=dynamic_cast<Node*>(this->GetObjectByOffset(i)); 277 276 … … 333 332 334 333 int my_rank; 335 int 334 int sid; 336 335 337 336 /*recover my_rank:*/ … … 358 357 Node* node=NULL; 359 358 360 for ( 359 for (object=objects.begin() ; object < objects.end(); object++ ){ 361 360 362 361 node=dynamic_cast<Node*>(*object); … … 364 363 365 364 } 366 367 } 368 /*}}}*/ 365 } 366 /*}}}*/ -
issm/trunk-jpl/src/c/Container/Nodes.h
r13797 r13833 23 23 int MaxNumDofs(int analysis_type,int setenum); 24 24 int NumberOfDofs(int analysis_type,int setenum); 25 int NumberOfDofsLocal(int analysis_type,int setenum); 25 26 int NumberOfNodes(int analysis_type); 26 27 int NumberOfNodes(void);
Note:
See TracChangeset
for help on using the changeset viewer.