/[escript]/branches/doubleplusgood/dudley/src/Mesh_optimizeDOFDistribution.cpp
ViewVC logotype

Diff of /branches/doubleplusgood/dudley/src/Mesh_optimizeDOFDistribution.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 4331 by jfenwick, Wed Feb 27 06:09:33 2013 UTC revision 4332 by jfenwick, Thu Mar 21 04:21:14 2013 UTC
# Line 102  void Dudley_Mesh_optimizeDOFDistribution Line 102  void Dudley_Mesh_optimizeDOFDistribution
102      len = 0;      len = 0;
103      for (p = 0; p < mpiSize; ++p)      for (p = 0; p < mpiSize; ++p)
104      len = MAX(len, distribution[p + 1] - distribution[p]);      len = MAX(len, distribution[p + 1] - distribution[p]);
105      partition = TMPMEMALLOC(len, index_t);  /* len is used for the sending around of partition later on */      partition = new  index_t[len];  /* len is used for the sending around of partition later on */
106      xyz = TMPMEMALLOC(myNumVertices * dim, float);      xyz = new  float[myNumVertices * dim];
107      partition_count = TMPMEMALLOC(mpiSize + 1, dim_t);      partition_count = new  dim_t[mpiSize + 1];
108      new_distribution = TMPMEMALLOC(mpiSize + 1, dim_t);      new_distribution = new  dim_t[mpiSize + 1];
109      newGlobalDOFID = TMPMEMALLOC(len, index_t);      newGlobalDOFID = new  index_t[len];
110      setNewDOFId = TMPMEMALLOC(in->Nodes->numNodes, bool_t);      setNewDOFId = new  bool_t[in->Nodes->numNodes];
111      if (!      if (!
112      (Dudley_checkPtr(partition) || Dudley_checkPtr(xyz) || Dudley_checkPtr(partition_count)      (Dudley_checkPtr(partition) || Dudley_checkPtr(xyz) || Dudley_checkPtr(partition_count)
113       || Dudley_checkPtr(partition_count) || Dudley_checkPtr(newGlobalDOFID) || Dudley_checkPtr(setNewDOFId)))       || Dudley_checkPtr(partition_count) || Dudley_checkPtr(newGlobalDOFID) || Dudley_checkPtr(setNewDOFId)))
114      {      {
115      dim_t *recvbuf = TMPMEMALLOC(mpiSize * mpiSize, dim_t);      dim_t *recvbuf = new  dim_t[mpiSize * mpiSize];
116    
117      /* set the coordinates: */      /* set the coordinates: */
118      /* it is assumed that at least one node on this processor provides a coordinate */      /* it is assumed that at least one node on this processor provides a coordinate */
# Line 127  void Dudley_Mesh_optimizeDOFDistribution Line 127  void Dudley_Mesh_optimizeDOFDistribution
127          }          }
128      }      }
129    
130      index_list = TMPMEMALLOC(myNumVertices, Dudley_IndexList);      index_list = new  Dudley_IndexList[myNumVertices];
131      /* ksteube CSR of DOF IDs */      /* ksteube CSR of DOF IDs */
132      /* create the adjacency structure xadj and adjncy */      /* create the adjacency structure xadj and adjncy */
133      if (!Dudley_checkPtr(index_list))      if (!Dudley_checkPtr(index_list))
# Line 179  void Dudley_Mesh_optimizeDOFDistribution Line 179  void Dudley_Mesh_optimizeDOFDistribution
179              int ncon = 1;              int ncon = 1;
180              int edgecut;              int edgecut;
181              int options[2];              int options[2];
182              float *tpwgts = TMPMEMALLOC(ncon * mpiSize, float);              float *tpwgts = new  float[ncon * mpiSize];
183              float *ubvec = TMPMEMALLOC(ncon, float);              float *ubvec = new  float[ncon];
184              for (i = 0; i < ncon * mpiSize; i++)              for (i = 0; i < ncon * mpiSize; i++)
185              tpwgts[i] = 1.0 / (float)mpiSize;              tpwgts[i] = 1.0 / (float)mpiSize;
186              for (i = 0; i < ncon; i++)              for (i = 0; i < ncon; i++)
# Line 190  void Dudley_Mesh_optimizeDOFDistribution Line 190  void Dudley_Mesh_optimizeDOFDistribution
190              ParMETIS_V3_PartGeomKway(distribution, pattern->ptr, pattern->index, NULL, NULL, &wgtflag, &numflag, &dim, xyz, &ncon, &mpiSize, tpwgts, ubvec, options, &edgecut, partition,   /* new CPU ownership of elements */              ParMETIS_V3_PartGeomKway(distribution, pattern->ptr, pattern->index, NULL, NULL, &wgtflag, &numflag, &dim, xyz, &ncon, &mpiSize, tpwgts, ubvec, options, &edgecut, partition,   /* new CPU ownership of elements */
191                           &(in->MPIInfo->comm));                           &(in->MPIInfo->comm));
192              /* printf("ParMETIS number of edges cut by partitioning per processor: %d\n", edgecut/MAX(in->MPIInfo->size,1)); */              /* printf("ParMETIS number of edges cut by partitioning per processor: %d\n", edgecut/MAX(in->MPIInfo->size,1)); */
193              TMPMEMFREE(ubvec);              delete[] ubvec;
194              TMPMEMFREE(tpwgts);              delete[] tpwgts;
195          }          }
196          else          else
197          {          {
# Line 248  void Dudley_Mesh_optimizeDOFDistribution Line 248  void Dudley_Mesh_optimizeDOFDistribution
248              c += recvbuf[rank + mpiSize * i];              c += recvbuf[rank + mpiSize * i];
249          new_distribution[rank + 1] = new_distribution[rank] + c;          new_distribution[rank + 1] = new_distribution[rank] + c;
250          }          }
251          TMPMEMFREE(recvbuf);          delete[] recvbuf;
252    
253          /* now the overlap needs to be created by sending the partition around */          /* now the overlap needs to be created by sending the partition around */
254  #ifdef ESYS_MPI  #ifdef ESYS_MPI
# Line 290  void Dudley_Mesh_optimizeDOFDistribution Line 290  void Dudley_Mesh_optimizeDOFDistribution
290          for (i = 0; i < mpiSize + 1; ++i)          for (i = 0; i < mpiSize + 1; ++i)
291          distribution[i] = new_distribution[i];          distribution[i] = new_distribution[i];
292      }      }
293      TMPMEMFREE(index_list);      delete[] index_list;
294      }      }
295      TMPMEMFREE(newGlobalDOFID);      delete[] newGlobalDOFID;
296      TMPMEMFREE(setNewDOFId);      delete[] setNewDOFId;
297      TMPMEMFREE(new_distribution);      delete[] new_distribution;
298      TMPMEMFREE(partition_count);      delete[] partition_count;
299      TMPMEMFREE(partition);      delete[] partition;
300      TMPMEMFREE(xyz);      delete[] xyz;
301      return;      return;
302  }  }

Legend:
Removed from v.4331  
changed lines
  Added in v.4332

  ViewVC Help
Powered by ViewVC 1.1.26