Changeset 11298
- Timestamp:
- 02/01/12 16:49:22 (13 years ago)
- Location:
- issm/trunk-jpl/src/c/Container
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk-jpl/src/c/Container/Nodes.cpp
r10522 r11298 60 60 61 61 int i; 62 63 62 int dofcount=0; 64 63 int maxdofspernode=0; … … 69 68 70 69 /*some check: */ 71 if ((setenum!=GsetEnum) && (setenum!=FsetEnum) && (setenum!=SsetEnum))_error_("%s%s%s"," dof distribution for set of enum type ",EnumToStringx(setenum)," not supported yet!");72 73 /*Go through objects, and distribute dofs locally, from 0 to numberofdofs :*/70 _assert_(setenum==GsetEnum || setenum==FsetEnum || setenum==SsetEnum); 71 72 /*Go through objects, and distribute dofs locally, from 0 to numberofdofsperobject*/ 74 73 for (i=0;i<this->Size();i++){ 75 74 Node* node=(Node*)this->GetObjectByOffset(i); … … 81 80 } 82 81 83 /* Ok, now every object has distributed dofs, but locally, and with a dof count starting from84 * 0. This means the dofs between all the cpus are not synchronized! We need to synchronize all85 * dof on all cpus, and use those to update the dofs of every object: */86 82 /* Now every object has distributed dofs, but locally, and with a dof count starting from 83 * 0. This means the dofs between all the cpus are not unique. We now offset the dofs of eache 84 * cpus by the total last dofs of the previus cpu, starting from 0. 85 * First: bet number of dofs for each cpu*/ 87 86 alldofcount=(int*)xmalloc(num_procs*sizeof(int)); 88 87 MPI_Gather(&dofcount,1,MPI_INT,alldofcount,1,MPI_INT,0,MPI_COMM_WORLD); 89 88 MPI_Bcast(alldofcount,num_procs,MPI_INT,0,MPI_COMM_WORLD); 90 89 91 /*Ok, now every cpu should start its own dof count at the end of the dofcount 92 * from cpu-1. : */ 90 /* Every cpu should start its own dof count at the end of the dofcount from cpu-1*/ 93 91 dofcount=0; 94 if(my_rank==0){ 95 dofcount=0; 96 } 97 else{ 92 if(my_rank!=0){ 98 93 for(i=0;i<my_rank;i++){ 99 94 dofcount+=alldofcount[i]; 100 95 } 101 96 } 102 103 /*Ok, now every cpu knows where his dofs should start. Update the dof count: */104 97 for (i=0;i<this->Size();i++){ 105 106 98 /*Check that this node corresponds to our analysis currently being carried out: */ 107 99 Node* node=(Node*)this->GetObjectByOffset(i); … … 109 101 node->OffsetDofs(dofcount,setenum); 110 102 } 111 112 } 113 114 /*Finally, remember that cpus may have skipped some objects, because they were clones. For every 103 } 104 105 /* Finally, remember that cpus may have skipped some objects, because they were clones. For every 115 106 * object that is not a clone, tell them to show their dofs, so that later on, they can get picked 116 107 * up by their clones: */ 117 108 maxdofspernode=this->MaxNumDofs(analysis_type,setenum); 118 109 numnodes=this->NumberOfNodes(analysis_type); 119 120 if (numnodes*maxdofspernode){ 121 truedofs=(int*)xcalloc(numnodes*maxdofspernode,sizeof(int)); //initialize to 0, so that we can pick up the max 110 if(numnodes*maxdofspernode){ 111 truedofs= (int*)xcalloc(numnodes*maxdofspernode,sizeof(int)); //initialize to 0, so that we can pick up the max 122 112 alltruedofs=(int*)xcalloc(numnodes*maxdofspernode,sizeof(int)); 123 113 } 124 114 125 115 for (i=0;i<this->Size();i++){ 126 /*Check that this node corresponds to our analysis currently being carried out: */127 116 Node* node=(Node*)this->GetObjectByOffset(i); 128 117 if (node->InAnalysis(analysis_type)){ … … 130 119 } 131 120 } 132 133 121 MPI_Allreduce ( (void*)truedofs,(void*)alltruedofs,numnodes*maxdofspernode,MPI_INT,MPI_MAX,MPI_COMM_WORLD); 134 122 135 /* Ok, now every cpu knows the true dofs of everyone else that is not a clone. Let the clones recover those true dofs:*/123 /* Now every cpu knows the true dofs of everyone else that is not a clone*/ 136 124 for (i=0;i<this->Size();i++){ 137 /*Check that this node corresponds to our analysis currently being carried out: */ 138 Node* node=(Node*)this->GetObjectByOffset(i); 139 if (node->InAnalysis(analysis_type)){ 140 node->UpdateCloneDofs(alltruedofs,maxdofspernode,setenum); //give maxdofspernode, column size, so that nodes can index into alltruedofs 125 Node* node=(Node*)this->GetObjectByOffset(i); 126 if (node->InAnalysis(analysis_type)){ 127 node->UpdateCloneDofs(alltruedofs,maxdofspernode,setenum); 141 128 } 142 129 } … … 146 133 xfree((void**)&truedofs); 147 134 xfree((void**)&alltruedofs); 148 149 150 135 } 151 136 /*}}}*/ -
issm/trunk-jpl/src/c/Container/Vertices.cpp
r10522 r11298 45 45 46 46 int i; 47 48 47 int dofcount=0; 49 48 int* alldofcount=NULL; … … 51 50 int* alltruedofs=NULL; 52 51 53 /*Go through objects, and distribute dofs locally, from 0 to numberofdofsperobject :*/52 /*Go through objects, and distribute dofs locally, from 0 to numberofdofsperobject*/ 54 53 for (i=0;i<this->Size();i++){ 55 54 Vertex* vertex=(Vertex*)this->GetObjectByOffset(i); … … 57 56 } 58 57 59 /* Ok, now every object has distributed dofs, but locally, and with a dof count starting from60 * 0. This means the dofs between all the cpus are not synchronized! We need to synchronize all61 * dof on all cpus, and use those to update the dofs of every object: */62 58 /* Now every object has distributed dofs, but locally, and with a dof count starting from 59 * 0. This means the dofs between all the cpus are not unique. We now offset the dofs of eache 60 * cpus by the total last dofs of the previus cpu, starting from 0. 61 * First: bet number of dofs for each cpu*/ 63 62 alldofcount=(int*)xmalloc(num_procs*sizeof(int)); 64 63 MPI_Gather(&dofcount,1,MPI_INT,alldofcount,1,MPI_INT,0,MPI_COMM_WORLD); 65 64 MPI_Bcast(alldofcount,num_procs,MPI_INT,0,MPI_COMM_WORLD); 66 65 67 /*Ok, now every cpu should start its own dof count at the end of the dofcount 68 * from cpu-1. : */ 66 /* Every cpu should start its own dof count at the end of the dofcount from cpu-1*/ 69 67 dofcount=0; 70 if(my_rank==0){ 71 dofcount=0; 72 } 73 else{ 68 if(my_rank!=0){ 74 69 for(i=0;i<my_rank;i++){ 75 70 dofcount+=alldofcount[i]; 76 71 } 77 72 } 78 79 80 /*Ok, now every cpu knows where his dofs should start. Update the dof count: */81 73 for (i=0;i<this->Size();i++){ 82 74 Vertex* vertex=(Vertex*)this->GetObjectByOffset(i); … … 84 76 } 85 77 86 /* Finally, remember that cpus may have skipped some objects, because they were clones. For every78 /* Finally, remember that cpus may have skipped some objects, because they were clones. For every 87 79 * object that is not a clone, tell them to show their dofs, so that later on, they can get picked 88 80 * up by their clones: */ 89 truedofs =(int*)xcalloc(numberofobjects*numberofdofsperobject,sizeof(int));81 truedofs =(int*)xcalloc(numberofobjects*numberofdofsperobject,sizeof(int)); 90 82 alltruedofs=(int*)xcalloc(numberofobjects*numberofdofsperobject,sizeof(int)); 91 92 83 for (i=0;i<this->Size();i++){ 93 84 Vertex* vertex=(Vertex*)this->GetObjectByOffset(i); 94 85 vertex->ShowTrueDofs(truedofs); 95 86 } 96 97 MPI_Allreduce ( (void*)truedofs,(void*)alltruedofs,numberofobjects*numberofdofsperobject,MPI_INT,MPI_MAX,MPI_COMM_WORLD); 87 MPI_Allreduce((void*)truedofs,(void*)alltruedofs,numberofobjects*numberofdofsperobject,MPI_INT,MPI_MAX,MPI_COMM_WORLD); 98 88 99 /* Ok, now every cpu knows the true dofs of everyone else that is not a clone. Let the clones recover those true dofs:*/89 /* Now every cpu knows the true dofs of everyone else that is not a clone*/ 100 90 for (i=0;i<this->Size();i++){ 101 91 Vertex* vertex=(Vertex*)this->GetObjectByOffset(i); … … 107 97 xfree((void**)&truedofs); 108 98 xfree((void**)&alltruedofs); 109 110 99 } 111 100 /*}}}*/
Note:
See TracChangeset
for help on using the changeset viewer.