diff --git a/opm/simulators/flow/AluGridVanguard.hpp b/opm/simulators/flow/AluGridVanguard.hpp index d0b39013a..d65fd8bdf 100644 --- a/opm/simulators/flow/AluGridVanguard.hpp +++ b/opm/simulators/flow/AluGridVanguard.hpp @@ -190,7 +190,8 @@ public: getPropValue()); // Re-ordering for ALUGrid - globalTrans_->update(false, [&](unsigned int i) { return gridEquilIdxToGridIdx(i);}); + globalTrans_->update(false, TransmissibilityType::TransUpdateQuantities::Trans, + [&](unsigned int i) { return gridEquilIdxToGridIdx(i);}); } } @@ -351,6 +352,10 @@ protected: std::unique_ptr cartesianIndexMapper_; std::unique_ptr equilCartesianIndexMapper_; std::unique_ptr factory_; + // \Note: this globalTrans_ is used for domain decomposition and INIT file output. + // It only contains trans_ due to permeability and does not contain thermalHalfTrans_, + // diffusivity_ abd dispersivity_. The main reason is to reduce the memory usage for rank 0 + // during parallel running. std::unique_ptr globalTrans_; int mpiRank; }; diff --git a/opm/simulators/flow/CpGridVanguard.hpp b/opm/simulators/flow/CpGridVanguard.hpp index 2e37c5a73..04cccfce7 100644 --- a/opm/simulators/flow/CpGridVanguard.hpp +++ b/opm/simulators/flow/CpGridVanguard.hpp @@ -285,7 +285,7 @@ protected: getPropValue(), getPropValue(), getPropValue())); - globalTrans_->update(false); + globalTrans_->update(false, TransmissibilityType::TransUpdateQuantities::Trans); } double getTransmissibility(unsigned I, unsigned J) const override @@ -306,6 +306,10 @@ protected: this->doFilterConnections_(this->schedule()); } + // \Note: this globalTrans_ is used for domain decomposition and INIT file output. + // It only contains trans_ due to permeability and does not contain thermalHalfTrans_, + // diffusivity_ abd dispersivity_. The main reason is to reduce the memory usage for rank 0 + // during parallel running. std::unique_ptr globalTrans_; }; diff --git a/opm/simulators/flow/FlowProblem.hpp b/opm/simulators/flow/FlowProblem.hpp index cf430b28a..7e39e5ce3 100644 --- a/opm/simulators/flow/FlowProblem.hpp +++ b/opm/simulators/flow/FlowProblem.hpp @@ -538,7 +538,8 @@ public: }; // re-compute all quantities which may possibly be affected. - transmissibilities_.update(true, equilGridToGrid); + using TransUpdateQuantities = typename Vanguard::TransmissibilityType::TransUpdateQuantities; + transmissibilities_.update(true, TransUpdateQuantities::All, equilGridToGrid); this->referencePorosity_[1] = this->referencePorosity_[0]; updateReferencePorosity_(); updatePffDofData_(); @@ -700,8 +701,9 @@ public: .applyActions(episodeIdx, simulator.time() + simulator.timeStepSize(), [this](const bool global) { + using TransUpdateQuantities = typename Vanguard::TransmissibilityType::TransUpdateQuantities; this->transmissibilities_ - .update(global, [&vg = this->simulator().vanguard()] + .update(global, TransUpdateQuantities::All, [&vg = this->simulator().vanguard()] (const unsigned int i) { return vg.gridIdxToEquilGridIdx(i); diff --git a/opm/simulators/flow/Transmissibility.hpp b/opm/simulators/flow/Transmissibility.hpp index 9838231a0..02bfc19e6 100644 --- a/opm/simulators/flow/Transmissibility.hpp +++ b/opm/simulators/flow/Transmissibility.hpp @@ -128,7 +128,7 @@ public: */ void finishInit(const std::function& map = {}) { - this->update(true, map, /*applyNncMultRegT = */ true); + this->update(true, TransUpdateQuantities::All, map, /*applyNncMultRegT = */ true); } /*! @@ -138,6 +138,13 @@ public: * processes. Also, this updates the "thermal half * transmissibilities" if energy is enabled. * + * \param[in] trans Indicating whether we only allocate and upate trans_ without considering + * thermalHalfTrans_, diffusivity_, dispersivity_. For many usage, we only need trans_, + * e.g. weights for domain decomposition, INIT file output. It might change following + * further development. + * Trans only update the trans_, which is related to permeability + * All upate rans_, thermalHalfTrans_, diffusivity_ and dispersivity_. + * * \param[in] map Undocumented. * * \param[in] applyNncMultRegT Whether or not to apply regional @@ -147,7 +154,9 @@ public: * numerical aquifers. Default value: \c false, meaning do not apply * regional multipliers to explicit NNCs. */ - void update(bool global, const std::function& map = {}, bool applyNncMultRegT = false); + enum class TransUpdateQuantities { Trans, All }; + void update(bool global, TransUpdateQuantities update_quantities = TransUpdateQuantities::All, + const std::function& map = {}, bool applyNncMultRegT = false); protected: void updateFromEclState_(bool global); diff --git a/opm/simulators/flow/Transmissibility_impl.hpp b/opm/simulators/flow/Transmissibility_impl.hpp index 310a8c61a..ce138966b 100644 --- a/opm/simulators/flow/Transmissibility_impl.hpp +++ b/opm/simulators/flow/Transmissibility_impl.hpp @@ -159,8 +159,11 @@ dispersivity(unsigned elemIdx1, unsigned elemIdx2) const template void Transmissibility:: -update(bool global, const std::function& map, const bool applyNncMultregT) +update(bool global, const TransUpdateQuantities update_quantities, + const std::function& map, const bool applyNncMultregT) { + // whether only update the permeability related transmissibility + const bool onlyTrans = (update_quantities == TransUpdateQuantities::Trans); const auto& cartDims = cartMapper_.cartesianDimensions(); const auto& transMult = eclState_.getTransMult(); const auto& comm = gridView_.comm(); @@ -208,7 +211,7 @@ update(bool global, const std::function& map, const transBoundary_.clear(); // if energy is enabled, let's do the same for the "thermal half transmissibilities" - if (enableEnergy_) { + if (enableEnergy_ && !onlyTrans) { thermalHalfTrans_.clear(); thermalHalfTrans_.reserve(numElements*6*1.05); @@ -216,14 +219,14 @@ update(bool global, const std::function& map, const } // if diffusion is enabled, let's do the same for the "diffusivity" - if (updateDiffusivity) { + if (updateDiffusivity && !onlyTrans) { diffusivity_.clear(); diffusivity_.reserve(numElements*3*1.05); extractPorosity_(); } // if dispersion is enabled, let's do the same for the "dispersivity" - if (updateDispersivity) { + if (updateDispersivity && !onlyTrans) { dispersivity_.clear(); dispersivity_.reserve(numElements*3*1.05); extractDispersion_(); @@ -283,7 +286,7 @@ update(bool global, const std::function& map, const // for boundary intersections we also need to compute the thermal // half transmissibilities - if (enableEnergy_) { + if (enableEnergy_ && !onlyTrans) { Scalar transBoundaryEnergyIs; computeHalfDiffusivity_(transBoundaryEnergyIs, faceAreaNormal, @@ -334,15 +337,15 @@ update(bool global, const std::function& map, const // *added to* by applyNncToGridTrans_() later. assert(outsideFaceIdx == -1); trans_[details::isId(elemIdx, outsideElemIdx)] = 0.0; - if (enableEnergy_){ + if (enableEnergy_ && !onlyTrans){ thermalHalfTrans_[details::directionalIsId(elemIdx, outsideElemIdx)] = 0.0; thermalHalfTrans_[details::directionalIsId(outsideElemIdx, elemIdx)] = 0.0; } - if (updateDiffusivity) { + if (updateDiffusivity && !onlyTrans) { diffusivity_[details::isId(elemIdx, outsideElemIdx)] = 0.0; } - if (updateDispersivity) { + if (updateDispersivity && !onlyTrans) { dispersivity_[details::isId(elemIdx, outsideElemIdx)] = 0.0; } continue; @@ -459,7 +462,7 @@ update(bool global, const std::function& map, const trans_[details::isId(elemIdx, outsideElemIdx)] = trans; // update the "thermal half transmissibility" for the intersection - if (enableEnergy_) { + if (enableEnergy_ && !onlyTrans) { Scalar halfDiffusivity1; Scalar halfDiffusivity2; @@ -484,7 +487,7 @@ update(bool global, const std::function& map, const } // update the "diffusive half transmissibility" for the intersection - if (updateDiffusivity) { + if (updateDiffusivity && !onlyTrans) { Scalar halfDiffusivity1; Scalar halfDiffusivity2; @@ -520,7 +523,7 @@ update(bool global, const std::function& map, const } // update the "dispersivity half transmissibility" for the intersection - if (updateDispersivity) { + if (updateDispersivity && !onlyTrans) { Scalar halfDispersivity1; Scalar halfDispersivity2;