43 |
|
* Purpose: To calculate an alpha-shape hull. |
44 |
|
*/ |
45 |
|
|
46 |
+ |
#ifdef IS_MPI |
47 |
+ |
#include <mpi.h> |
48 |
+ |
#endif |
49 |
+ |
|
50 |
|
/* Standard includes independent of library */ |
51 |
|
|
52 |
|
#include <iostream> |
57 |
|
#include "math/AlphaHull.hpp" |
58 |
|
#include "utils/simError.h" |
59 |
|
|
56 |
– |
#ifdef IS_MPI |
57 |
– |
#include <mpi.h> |
58 |
– |
#endif |
59 |
– |
|
60 |
|
#include "math/qhull.hpp" |
61 |
|
|
62 |
|
#ifdef HAVE_QHULL |
112 |
|
#ifdef IS_MPI |
113 |
|
//If we are doing the mpi version, set up some vectors for data communication |
114 |
|
|
115 |
< |
int nproc = MPI::COMM_WORLD.Get_size(); |
116 |
< |
int myrank = MPI::COMM_WORLD.Get_rank(); |
115 |
> |
int nproc; |
116 |
> |
int myrank; |
117 |
> |
MPI_Comm_size( MPI_COMM_WORLD, &nproc); |
118 |
> |
MPI_Comm_rank( MPI_COMM_WORLD, &myrank); |
119 |
> |
|
120 |
|
int localHullSites = 0; |
121 |
|
|
122 |
|
vector<int> hullSitesOnProc(nproc, 0); |
133 |
|
localHullSites++; |
134 |
|
|
135 |
|
int idx = qh_pointid(vertex->point); |
136 |
< |
|
136 |
> |
|
137 |
|
indexMap.push_back(idx); |
138 |
|
|
139 |
|
coords.push_back(ptArray[dim_ * idx]); |
150 |
|
masses.push_back(sd->getMass()); |
151 |
|
} |
152 |
|
|
153 |
< |
MPI::COMM_WORLD.Allgather(&localHullSites, 1, MPI::INT, &hullSitesOnProc[0], |
154 |
< |
1, MPI::INT); |
153 |
> |
MPI_Allgather(&localHullSites, 1, MPI_INT, &hullSitesOnProc[0], |
154 |
> |
1, MPI_INT, MPI_COMM_WORLD); |
155 |
|
|
156 |
|
int globalHullSites = 0; |
157 |
|
for (int iproc = 0; iproc < nproc; iproc++){ |
173 |
|
|
174 |
|
int count = coordsOnProc[myrank]; |
175 |
|
|
176 |
< |
MPI::COMM_WORLD.Allgatherv(&coords[0], count, MPI::DOUBLE, &globalCoords[0], |
177 |
< |
&coordsOnProc[0], &vectorDisplacements[0], |
178 |
< |
MPI::DOUBLE); |
179 |
< |
|
180 |
< |
MPI::COMM_WORLD.Allgatherv(&vels[0], count, MPI::DOUBLE, &globalVels[0], |
181 |
< |
&coordsOnProc[0], &vectorDisplacements[0], |
182 |
< |
MPI::DOUBLE); |
183 |
< |
|
184 |
< |
MPI::COMM_WORLD.Allgatherv(&masses[0], localHullSites, MPI::DOUBLE, |
185 |
< |
&globalMasses[0], &hullSitesOnProc[0], |
186 |
< |
&displacements[0], MPI::DOUBLE); |
187 |
< |
|
176 |
> |
MPI_Allgatherv(&coords[0], count, MPI_DOUBLE, &globalCoords[0], |
177 |
> |
&coordsOnProc[0], &vectorDisplacements[0], |
178 |
> |
MPI_DOUBLE, MPI_COMM_WORLD); |
179 |
> |
|
180 |
> |
MPI_Allgatherv(&vels[0], count, MPI_DOUBLE, &globalVels[0], |
181 |
> |
&coordsOnProc[0], &vectorDisplacements[0], |
182 |
> |
MPI_DOUBLE, MPI_COMM_WORLD); |
183 |
> |
|
184 |
> |
MPI_Allgatherv(&masses[0], localHullSites, MPI_DOUBLE, |
185 |
> |
&globalMasses[0], &hullSitesOnProc[0], |
186 |
> |
&displacements[0], MPI_DOUBLE, MPI_COMM_WORLD); |
187 |
> |
|
188 |
|
// Free previous hull |
189 |
|
qh_freeqhull(!qh_ALL); |
190 |
|
qh_memfreeshort(&curlong, &totlong); |