mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
Merge pull request #4778 from aritorto/cellCentroid
Refactor element centroids lookup
This commit is contained in:
@@ -31,7 +31,7 @@
|
||||
|
||||
#include <opm/grid/common/GridEnums.hpp>
|
||||
#include <opm/grid/common/CartesianIndexMapper.hpp>
|
||||
|
||||
#include <opm/grid/LookUpCellCentroid.hh>
|
||||
#include <opm/input/eclipse/EclipseState/Aquifer/NumericalAquifer/NumericalAquiferCell.hpp>
|
||||
#include <opm/input/eclipse/EclipseState/EclipseState.hpp>
|
||||
|
||||
@@ -42,6 +42,8 @@
|
||||
|
||||
#include <opm/simulators/flow/BlackoilModelParametersEbos.hpp>
|
||||
|
||||
|
||||
|
||||
#include <array>
|
||||
#include <cstddef>
|
||||
#include <optional>
|
||||
@@ -51,6 +53,7 @@
|
||||
namespace Opm {
|
||||
template <class TypeTag>
|
||||
class EclBaseVanguard;
|
||||
template<typename Grid, typename GridView> struct LookUpCellCentroid;
|
||||
}
|
||||
|
||||
namespace Opm::Properties {
|
||||
@@ -476,20 +479,18 @@ protected:
|
||||
cellCentroids_(const CartMapper& cartMapper) const
|
||||
{
|
||||
return [this, cartMapper](int elemIdx) {
|
||||
const auto& centroids = this->centroids_;
|
||||
auto rank = this->gridView().comm().rank();
|
||||
std::array<double,dimensionworld> centroid;
|
||||
if (rank == 0) {
|
||||
unsigned cartesianCellIdx = cartMapper.cartesianIndex(elemIdx);
|
||||
centroid = this->eclState().getInputGrid().getCellCenter(cartesianCellIdx);
|
||||
} else
|
||||
{
|
||||
std::copy(centroids.begin() + elemIdx * dimensionworld,
|
||||
centroids.begin() + (elemIdx + 1) * dimensionworld,
|
||||
centroid.begin());
|
||||
}
|
||||
return centroid;
|
||||
};
|
||||
std::array<double,dimensionworld> centroid;
|
||||
if (this->gridView().comm().rank() == 0)
|
||||
{
|
||||
centroid = this->eclState().getInputGrid().getCellCenter(cartMapper.cartesianIndex(elemIdx));
|
||||
}
|
||||
else
|
||||
{
|
||||
LookUpCellCentroid<Grid,GridView> lookUpCellCentroid(this->gridView(), cartMapper, nullptr);
|
||||
centroid = lookUpCellCentroid(elemIdx);
|
||||
}
|
||||
return centroid;
|
||||
};
|
||||
}
|
||||
|
||||
void callImplementationInit()
|
||||
@@ -506,7 +507,7 @@ protected:
|
||||
{
|
||||
std::size_t num_cells = asImp_().grid().leafGridView().size(0);
|
||||
is_interior_.resize(num_cells);
|
||||
|
||||
|
||||
ElementMapper elemMapper(this->gridView(), Dune::mcmgElementLayout());
|
||||
for (const auto& element : elements(this->gridView()))
|
||||
{
|
||||
@@ -578,7 +579,7 @@ private:
|
||||
|
||||
return zz/Scalar(corners);
|
||||
}
|
||||
|
||||
|
||||
Scalar computeCellThickness(const typename GridView::template Codim<0>::Entity& element) const
|
||||
{
|
||||
typedef typename Element::Geometry Geometry;
|
||||
@@ -609,11 +610,6 @@ private:
|
||||
{ return *static_cast<const Implementation*>(this); }
|
||||
|
||||
protected:
|
||||
/*! \brief The cell centroids after loadbalance was called.
|
||||
* Empty otherwise. Used by EclTransmissibilty.
|
||||
*/
|
||||
std::vector<double> centroids_;
|
||||
|
||||
/*! \brief Mapping between cartesian and compressed cells.
|
||||
* It is initialized the first time it is called
|
||||
*/
|
||||
|
||||
@@ -208,8 +208,8 @@ public:
|
||||
this->doLoadBalance_(this->edgeWeightsMethod(), this->ownersFirst(),
|
||||
this->serialPartitioning(), this->enableDistributedWells(),
|
||||
this->zoltanImbalanceTol(), this->gridView(),
|
||||
this->schedule(), this->centroids_,
|
||||
this->eclState(), this->parallelWells_, this->numJacobiBlocks());
|
||||
this->schedule(), this->eclState(),
|
||||
this->parallelWells_, this->numJacobiBlocks());
|
||||
#endif
|
||||
|
||||
this->updateGridView_();
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
|
||||
#include <opm/simulators/utils/ParallelEclipseState.hpp>
|
||||
#include <opm/simulators/utils/ParallelSerialization.hpp>
|
||||
#include <opm/simulators/utils/PropsCentroidsDataHandle.hpp>
|
||||
#include <opm/simulators/utils/PropsDataHandle.hpp>
|
||||
#include <opm/simulators/utils/SetupZoltanParams.hpp>
|
||||
|
||||
#include <opm/grid/cpgrid/GridHelpers.hpp>
|
||||
@@ -94,7 +94,6 @@ doLoadBalance_(const Dune::EdgeWeightMethod edgeWeightsMethod,
|
||||
const double zoltanImbalanceTol,
|
||||
const GridView& gridView,
|
||||
const Schedule& schedule,
|
||||
std::vector<double>& centroids,
|
||||
EclipseState& eclState1,
|
||||
EclGenericVanguard::ParallelWellStruct& parallelWells,
|
||||
const int numJacobiBlocks)
|
||||
@@ -143,7 +142,7 @@ doLoadBalance_(const Dune::EdgeWeightMethod edgeWeightsMethod,
|
||||
this->distributeGrid(edgeWeightsMethod, ownersFirst,
|
||||
serialPartitioning, enableDistributedWells,
|
||||
zoltanImbalanceTol, loadBalancerSet != 0,
|
||||
faceTrans, wells, centroids,
|
||||
faceTrans, wells,
|
||||
eclState1, parallelWells);
|
||||
}
|
||||
|
||||
@@ -230,7 +229,6 @@ distributeGrid(const Dune::EdgeWeightMethod edgeWeightsMethod,
|
||||
const bool loadBalancerSet,
|
||||
const std::vector<double>& faceTrans,
|
||||
const std::vector<Well>& wells,
|
||||
std::vector<double>& centroids,
|
||||
EclipseState& eclState1,
|
||||
EclGenericVanguard::ParallelWellStruct& parallelWells)
|
||||
{
|
||||
@@ -240,7 +238,7 @@ distributeGrid(const Dune::EdgeWeightMethod edgeWeightsMethod,
|
||||
this->distributeGrid(edgeWeightsMethod, ownersFirst,
|
||||
serialPartitioning, enableDistributedWells,
|
||||
zoltanImbalanceTol, loadBalancerSet, faceTrans,
|
||||
wells, centroids, eclState, parallelWells);
|
||||
wells, eclState, parallelWells);
|
||||
}
|
||||
else {
|
||||
const auto message = std::string {
|
||||
@@ -267,20 +265,14 @@ distributeGrid(const Dune::EdgeWeightMethod edgeWeightsMethod,
|
||||
const bool loadBalancerSet,
|
||||
const std::vector<double>& faceTrans,
|
||||
const std::vector<Well>& wells,
|
||||
std::vector<double>& centroids,
|
||||
ParallelEclipseState* eclState,
|
||||
EclGenericVanguard::ParallelWellStruct& parallelWells)
|
||||
{
|
||||
OPM_TIMEBLOCK(gridDistribute);
|
||||
const auto isIORank = this->grid_->comm().rank() == 0;
|
||||
|
||||
const auto* eclGrid = isIORank
|
||||
? &eclState->getInputGrid()
|
||||
: nullptr;
|
||||
|
||||
PropsCentroidsDataHandle<Dune::CpGrid> handle {
|
||||
*this->grid_, *eclState, eclGrid, centroids,
|
||||
this->cartesianIndexMapper()
|
||||
PropsDataHandle<Dune::CpGrid> handle {
|
||||
*this->grid_, *eclState
|
||||
};
|
||||
|
||||
const auto addCornerCells = false;
|
||||
|
||||
@@ -131,7 +131,6 @@ protected:
|
||||
const double zoltanImbalanceTol,
|
||||
const GridView& gridView,
|
||||
const Schedule& schedule,
|
||||
std::vector<double>& centroids,
|
||||
EclipseState& eclState,
|
||||
EclGenericVanguard::ParallelWellStruct& parallelWells,
|
||||
const int numJacobiBlocks);
|
||||
@@ -149,7 +148,6 @@ private:
|
||||
const bool loadBalancerSet,
|
||||
const std::vector<double>& faceTrans,
|
||||
const std::vector<Well>& wells,
|
||||
std::vector<double>& centroids,
|
||||
EclipseState& eclState,
|
||||
EclGenericVanguard::ParallelWellStruct& parallelWells);
|
||||
|
||||
@@ -161,7 +159,6 @@ private:
|
||||
const bool loadBalancerSet,
|
||||
const std::vector<double>& faceTrans,
|
||||
const std::vector<Well>& wells,
|
||||
std::vector<double>& centroids,
|
||||
ParallelEclipseState* eclState,
|
||||
EclGenericVanguard::ParallelWellStruct& parallelWells);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user