[refactor] Move cell centroid lookup magic to vanguard for reuse.

In addition to transmissibilities We will need this for the tracers,
too, and should prevent code duplication.
This commit is contained in:
Markus Blatt
2021-09-30 11:50:22 +02:00
parent 2168b8c296
commit 457d270bdf
7 changed files with 83 additions and 39 deletions

View File

@@ -88,7 +88,7 @@ EclTransmissibility(const EclipseState& eclState,
const GridView& gridView,
const Dune::CartesianIndexMapper<Grid>& cartMapper,
const Grid& grid,
const std::vector<double>& centroids,
std::function<std::array<double,dimWorld>(int)> centroids,
bool enableEnergy,
bool enableDiffusivity)
: eclState_(eclState)
@@ -174,15 +174,7 @@ update(bool global)
// compute the axis specific "centroids" used for the transmissibilities. for
// consistency with the flow simulator, we use the element centers as
// computed by opm-parser's Opm::EclipseGrid class for all axes.
std::array<double, 3> centroid;
if (gridView_.comm().rank() == 0) {
const auto& eclGrid = eclState_.getInputGrid();
unsigned cartesianCellIdx = cartMapper_.cartesianIndex(elemIdx);
centroid = eclGrid.getCellCenter(cartesianCellIdx);
} else
std::copy(centroids_.begin() + centroidIdx * dimWorld,
centroids_.begin() + (centroidIdx + 1) * dimWorld,
centroid.begin());
std::array<double, dimWorld> centroid = centroids_(elemIdx);
for (unsigned axisIdx = 0; axisIdx < dimWorld; ++axisIdx)
for (unsigned dimIdx = 0; dimIdx < dimWorld; ++dimIdx)