Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

For convective mixing, store the saturated dissolution factor. #5774

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions flowexperimental/BlackOilIntensiveQuantitiesGlobalIndex.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
#include <opm/models/blackoil/blackoilenergymodules.hh>
#include <opm/models/blackoil/blackoildiffusionmodule.hh>
#include <opm/models/blackoil/blackoilmicpmodules.hh>
#include <opm/models/blackoil/blackoilconvectivemixingmodule.hh>
#include <opm/models/common/directionalmobility.hh>

#include <opm/utility/CopyablePtr.hpp>
Expand Down Expand Up @@ -78,6 +79,7 @@ class BlackOilIntensiveQuantitiesGlobalIndex
, public BlackOilBrineIntensiveQuantities<TypeTag>
, public BlackOilEnergyIntensiveQuantitiesGlobalIndex<TypeTag>
, public BlackOilMICPIntensiveQuantities<TypeTag>
, public BlackOilConvectiveMixingIntensiveQuantities<TypeTag>
{
using ParentType = GetPropType<TypeTag, Properties::DiscIntensiveQuantities>;
using Implementation = GetPropType<TypeTag, Properties::IntensiveQuantities>;
Expand All @@ -103,6 +105,7 @@ class BlackOilIntensiveQuantitiesGlobalIndex
enum { enableTemperature = getPropValue<TypeTag, Properties::EnableTemperature>() };
enum { enableEnergy = getPropValue<TypeTag, Properties::EnableEnergy>() };
enum { enableDiffusion = getPropValue<TypeTag, Properties::EnableDiffusion>() };
enum { enableConvectiveMixing = getPropValue<TypeTag, Properties::EnableConvectiveMixing>() };
enum { enableMICP = getPropValue<TypeTag, Properties::EnableMICP>() };
enum { numPhases = getPropValue<TypeTag, Properties::NumPhases>() };
enum { numComponents = getPropValue<TypeTag, Properties::NumComponents>() };
Expand Down Expand Up @@ -382,6 +385,10 @@ class BlackOilIntensiveQuantitiesGlobalIndex

rockCompTransMultiplier_ = problem.template rockCompTransMultiplier<Evaluation>(*this, globalSpaceIdx);

if constexpr (enableConvectiveMixing) {
asImp_().updateSaturatedDissolutionFactor_();
}

#ifndef NDEBUG
// some safety checks in debug mode
for (unsigned phaseIdx = 0; phaseIdx < numPhases; ++ phaseIdx) {
Expand Down
58 changes: 49 additions & 9 deletions opm/models/blackoil/blackoilconvectivemixingmodule.hh
Original file line number Diff line number Diff line change
Expand Up @@ -289,15 +289,11 @@ public:
const auto& liquidPhaseIdx = (FluidSystem::phaseIsActive(FluidSystem::waterPhaseIdx)) ?
FluidSystem::waterPhaseIdx :
FluidSystem::oilPhaseIdx;
const Evaluation SoMax = 0.0;

//interiour
const auto& t_in = intQuantsIn.fluidState().temperature(liquidPhaseIdx);
const auto& p_in = intQuantsIn.fluidState().pressure(liquidPhaseIdx);
const auto& rssat_in = FluidSystem::saturatedDissolutionFactor(intQuantsIn.fluidState(),
liquidPhaseIdx,
intQuantsIn.pvtRegionIndex(),
SoMax);
const auto& rssat_in = intQuantsIn.saturatedDissolutionFactor();
const auto& salt_in = intQuantsIn.fluidState().saltSaturation();

const auto bLiquidSatIn = (FluidSystem::phaseIsActive(FluidSystem::waterPhaseIdx)) ?
Expand All @@ -315,10 +311,7 @@ public:
//exteriour
const auto t_ex = Opm::getValue(intQuantsEx.fluidState().temperature(liquidPhaseIdx));
const auto p_ex = Opm::getValue(intQuantsEx.fluidState().pressure(liquidPhaseIdx));
const auto rssat_ex = Opm::getValue(FluidSystem::saturatedDissolutionFactor(intQuantsEx.fluidState(),
liquidPhaseIdx,
intQuantsEx.pvtRegionIndex(),
SoMax));
const auto rssat_ex = Opm::getValue(intQuantsEx.saturatedDissolutionFactor());
const auto salt_ex = Opm::getValue(intQuantsEx.fluidState().saltSaturation());
const auto bLiquidSatEx = (FluidSystem::phaseIsActive(FluidSystem::waterPhaseIdx)) ?
FluidSystem::waterPvt().inverseFormationVolumeFactor(intQuantsEx.pvtRegionIndex(), t_ex, p_ex, rssat_ex, salt_ex):
Expand Down Expand Up @@ -382,6 +375,53 @@ public:
}
};

/*!
* \ingroup BlackOil
* \class Opm::BlackOilConvectiveMixingIntensiveQuantities
*
* \brief Provides the volumetric quantities required for the equations needed by the
* convective mixing (DRSDTCON) model.
*/
template <class TypeTag, bool enableConvectiveMixingV = getPropValue<TypeTag, Properties::EnableConvectiveMixing>()>
class BlackOilConvectiveMixingIntensiveQuantities
{
using Implementation = GetPropType<TypeTag, Properties::IntensiveQuantities>;
using Evaluation = GetPropType<TypeTag, Properties::Evaluation>;
using FluidSystem = GetPropType<TypeTag, Properties::FluidSystem>;

public:
/*!
* \brief Compute the intensive quantities needed to handle convective dissolution
*
*/
void updateSaturatedDissolutionFactor_()
{
auto& fs = asImp_().fluidState();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another tiny nit: The fs object is used in just a single location–the call to saturatedDissolutionFactor()–so I guess you could just as well use asImp_().fluidState() directly in that function call.

const auto& liquidPhaseIdx = (FluidSystem::phaseIsActive(FluidSystem::waterPhaseIdx)) ?
FluidSystem::waterPhaseIdx :
FluidSystem::oilPhaseIdx;
Comment on lines +400 to +402
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think you need references here–i.e., auto&. The phase indices are integers so you can just store them by value.

const Evaluation SoMax = 0.0;
saturatedDissolutionFactor_ = FluidSystem::saturatedDissolutionFactor(fs,
liquidPhaseIdx,
asImp_().pvtRegionIndex(),
SoMax);
}

const Evaluation& saturatedDissolutionFactor() const
{ return saturatedDissolutionFactor_; }

protected:
Implementation& asImp_()
{ return *static_cast<Implementation*>(this); }

Evaluation saturatedDissolutionFactor_;
};

template <class TypeTag>
class BlackOilConvectiveMixingIntensiveQuantities<TypeTag, false>
{
};

}

#endif
7 changes: 7 additions & 0 deletions opm/models/blackoil/blackoilintensivequantities.hh
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
#include "blackoildiffusionmodule.hh"
#include "blackoildispersionmodule.hh"
#include "blackoilmicpmodules.hh"
#include "blackoilconvectivemixingmodule.hh"

#include <opm/common/TimingMacros.hpp>
#include <opm/common/OpmLog/OpmLog.hpp>
Expand Down Expand Up @@ -79,6 +80,7 @@ class BlackOilIntensiveQuantities
, public BlackOilBrineIntensiveQuantities<TypeTag>
, public BlackOilEnergyIntensiveQuantities<TypeTag>
, public BlackOilMICPIntensiveQuantities<TypeTag>
, public BlackOilConvectiveMixingIntensiveQuantities<TypeTag>
{
using ParentType = GetPropType<TypeTag, Properties::DiscIntensiveQuantities>;
using Implementation = GetPropType<TypeTag, Properties::IntensiveQuantities>;
Expand Down Expand Up @@ -106,6 +108,7 @@ class BlackOilIntensiveQuantities
enum { enableEnergy = getPropValue<TypeTag, Properties::EnableEnergy>() };
enum { enableDiffusion = getPropValue<TypeTag, Properties::EnableDiffusion>() };
enum { enableDispersion = getPropValue<TypeTag, Properties::EnableDispersion>() };
enum { enableConvectiveMixing = getPropValue<TypeTag, Properties::EnableConvectiveMixing>() };
enum { enableMICP = getPropValue<TypeTag, Properties::EnableMICP>() };
enum { numPhases = getPropValue<TypeTag, Properties::NumPhases>() };
enum { numComponents = getPropValue<TypeTag, Properties::NumComponents>() };
Expand Down Expand Up @@ -497,6 +500,10 @@ public:
// update the dispersion specific quantities of the intensive quantities
DispersionIntensiveQuantities::update_(elemCtx, dofIdx, timeIdx);

if constexpr (enableConvectiveMixing) {
asImp_().updateSaturatedDissolutionFactor_();
}

#ifndef NDEBUG
// some safety checks in debug mode
for (unsigned phaseIdx = 0; phaseIdx < numPhases; ++ phaseIdx) {
Expand Down