Capture Bulk Connection Fluxes to Accumlate Inter-Region Flows

This commit adds a new grid traversal that computes fluxes-presently
surface level component fluxes-for all bulk connections on the
current MPI rank.  We aggregate those fluxes, if applicable, into a
container for inter-region flows, but this support could be extended
to capturing the full 3D vector flow rates for restart output if
needed.
This commit is contained in:
Bård Skaflestad
2022-02-14 12:30:32 +01:00
parent 1e121799c8
commit ecec83349b
4 changed files with 263 additions and 3 deletions

View File

@@ -38,8 +38,11 @@
#include <ebos/eclgenericwriter.hh>
#include <string>
#include <dune/grid/common/partitionset.hh>
#include <functional>
#include <limits>
#include <string>
namespace Opm::Properties {
@@ -181,11 +184,12 @@ public:
const auto localGroupAndNetworkData = simulator_.problem().wellModel()
.groupAndNetworkData(reportStepNum);
const auto localAquiferData = simulator_.problem().aquiferModel().aquiferData();
const auto localWellTestState = simulator_.problem().wellModel().wellTestState();
this->prepareLocalCellData(isSubStep, reportStepNum);
this->captureLocalFluxData();
if (this->collectToIORank_.isParallel())
this->collectToIORank_.collect({},
eclOutputModule_->getBlockData(),
@@ -435,6 +439,42 @@ private:
OPM_END_PARALLEL_TRY_CATCH("EclWriter::prepareLocalCellData() failed: ", simulator_.vanguard().grid().comm())
}
void captureLocalFluxData()
{
const auto& gridView = this->simulator_.vanguard().gridView();
const auto timeIdx = 0u;
auto elemCtx = ElementContext { this->simulator_ };
const auto elemMapper = ElementMapper { gridView, Dune::mcmgElementLayout() };
const auto activeIndex = [&elemMapper](const Element& e)
{
return elemMapper.index(e);
};
const auto cartesianIndex = [this](const int elemIndex)
{
return this->cartMapper_.cartesianIndex(elemIndex);
};
this->eclOutputModule_->initializeFluxData();
OPM_BEGIN_PARALLEL_TRY_CATCH();
for (const auto& elem : elements(gridView, Dune::Partitions::interiorBorder)) {
elemCtx.updateStencil(elem);
elemCtx.updateIntensiveQuantities(timeIdx);
elemCtx.updateExtensiveQuantities(timeIdx);
this->eclOutputModule_->processFluxes(elemCtx, activeIndex, cartesianIndex);
}
OPM_END_PARALLEL_TRY_CATCH("EclWriter::captureLocalFluxData() failed: ",
this->simulator_.vanguard().grid().comm())
this->eclOutputModule_->finalizeFluxData();
}
Simulator& simulator_;
std::unique_ptr<EclOutputBlackOilModule<TypeTag>> eclOutputModule_;
Scalar restartTimeStepSize_;