mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
Also distribute the centroids when loadbalancing CpGrid.
They are attached to the cells as well and are now distributed during CpGrid::loadBalance. Due to this change we also rename FieldPropsDataHandle to PropsCentroidsDataHandle.
This commit is contained in:
@@ -149,47 +149,7 @@ public:
|
||||
for (unsigned dimIdx = 0; dimIdx < dimWorld; ++dimIdx)
|
||||
axisCentroids[dimIdx].resize(numElements);
|
||||
|
||||
std::vector<double> centroids;
|
||||
#if HAVE_MPI
|
||||
size_t cells = vanguard_.grid().numCells();
|
||||
if (global && comm.size() > 1) {
|
||||
std::vector<size_t> sizes(comm.size());
|
||||
if (comm.rank() == 0) {
|
||||
const auto& eclGrid = eclState.getInputGrid();
|
||||
comm.gather(&cells, sizes.data(), 1, 0);
|
||||
for (int i = 1; i < comm.size(); ++i) {
|
||||
std::vector<int> cell_id(sizes[i]);
|
||||
MPI_Recv(cell_id.data(), sizes[i], MPI_INT,
|
||||
i, 0, MPI_COMM_WORLD, MPI_STATUS_IGNORE);
|
||||
centroids.resize(dimWorld * sizes[i]);
|
||||
|
||||
auto cIt = centroids.begin();
|
||||
for (int idx : cell_id) {
|
||||
const auto& centroid = eclGrid.getCellCenter(idx);
|
||||
for (const auto& it : centroid)
|
||||
*cIt++ = it;
|
||||
}
|
||||
MPI_Send(centroids.data(), dimWorld * sizes[i],
|
||||
MPI_DOUBLE, i, 0, MPI_COMM_WORLD);
|
||||
}
|
||||
centroids.clear();
|
||||
} else {
|
||||
comm.gather(&cells, sizes.data(), 1, 0);
|
||||
std::vector<int> cell_ids;
|
||||
cell_ids.reserve(cells);
|
||||
auto elemIt = gridView.template begin</*codim=*/ 0>();
|
||||
const auto& elemEndIt = gridView.template end</*codim=*/ 0>();
|
||||
for (; elemIt != elemEndIt; ++elemIt) {
|
||||
const auto& elem = *elemIt;
|
||||
cell_ids.push_back(cartMapper.cartesianIndex(elemMapper.index(elem)));
|
||||
}
|
||||
MPI_Send(cell_ids.data(), cells, MPI_INT, 0, 0, MPI_COMM_WORLD);
|
||||
centroids.resize(cells * dimWorld);
|
||||
MPI_Recv(centroids.data(), dimWorld * cells, MPI_DOUBLE,
|
||||
0, 0, MPI_COMM_WORLD, MPI_STATUS_IGNORE);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
const std::vector<double>& centroids = vanguard_.cellCentroids();
|
||||
|
||||
auto elemIt = gridView.template begin</*codim=*/ 0>();
|
||||
const auto& elemEndIt = gridView.template end</*codim=*/ 0>();
|
||||
|
||||
Reference in New Issue
Block a user