mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
Merge pull request #896 from akva2/floats
Add necessary changes to build float simulators
This commit is contained in:
commit
f5aeffc8f5
@ -28,15 +28,16 @@
|
|||||||
#ifndef EWOMS_CONVECTIVEMIXING_MODULE_HH
|
#ifndef EWOMS_CONVECTIVEMIXING_MODULE_HH
|
||||||
#define EWOMS_CONVECTIVEMIXING_MODULE_HH
|
#define EWOMS_CONVECTIVEMIXING_MODULE_HH
|
||||||
|
|
||||||
#include <opm/models/discretization/common/fvbaseproperties.hh>
|
#include "opm/material/common/MathToolbox.hpp"
|
||||||
#include <opm/input/eclipse/Schedule/OilVaporizationProperties.hpp>
|
|
||||||
#include <opm/input/eclipse/Schedule/Schedule.hpp>
|
|
||||||
#include <opm/material/common/Valgrind.hpp>
|
|
||||||
|
|
||||||
#include <dune/common/fvector.hh>
|
#include <dune/common/fvector.hh>
|
||||||
|
|
||||||
#include <stdexcept>
|
#include <opm/input/eclipse/Schedule/OilVaporizationProperties.hpp>
|
||||||
#include <iostream>
|
#include <opm/input/eclipse/Schedule/Schedule.hpp>
|
||||||
|
|
||||||
|
#include <opm/material/common/Valgrind.hpp>
|
||||||
|
|
||||||
|
#include <opm/models/common/multiphasebaseproperties.hh>
|
||||||
|
#include <opm/models/discretization/common/fvbaseproperties.hh>
|
||||||
|
|
||||||
namespace Opm {
|
namespace Opm {
|
||||||
|
|
||||||
@ -119,8 +120,8 @@ public:
|
|||||||
const Scalar,
|
const Scalar,
|
||||||
const ConvectiveMixingModuleParam&)
|
const ConvectiveMixingModuleParam&)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class TypeTag>
|
template <class TypeTag>
|
||||||
class BlackOilConvectiveMixingModule<TypeTag, /*enableConvectiveMixing=*/true>
|
class BlackOilConvectiveMixingModule<TypeTag, /*enableConvectiveMixing=*/true>
|
||||||
{
|
{
|
||||||
@ -150,7 +151,10 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
#if HAVE_ECL_INPUT
|
#if HAVE_ECL_INPUT
|
||||||
static void beginEpisode(const EclipseState& eclState, const Schedule& schedule, const int episodeIdx, ConvectiveMixingModuleParam& info)
|
static void beginEpisode(const EclipseState& eclState,
|
||||||
|
const Schedule& schedule,
|
||||||
|
const int episodeIdx,
|
||||||
|
ConvectiveMixingModuleParam& info)
|
||||||
{
|
{
|
||||||
// check that Xhi and Psi didn't change
|
// check that Xhi and Psi didn't change
|
||||||
std::size_t numRegions = eclState.runspec().tabdims().getNumPVTTables();
|
std::size_t numRegions = eclState.runspec().tabdims().getNumPVTTables();
|
||||||
@ -211,8 +215,10 @@ public:
|
|||||||
const auto salt_ex = Toolbox::value(intQuantsEx.fluidState().saltConcentration());
|
const auto salt_ex = Toolbox::value(intQuantsEx.fluidState().saltConcentration());
|
||||||
|
|
||||||
const auto bLiquidEx = (FluidSystem::phaseIsActive(waterPhaseIdx)) ?
|
const auto bLiquidEx = (FluidSystem::phaseIsActive(waterPhaseIdx)) ?
|
||||||
FluidSystem::waterPvt().inverseFormationVolumeFactor(intQuantsEx.pvtRegionIndex(), t_ex, p_ex, 0.0, salt_ex) :
|
FluidSystem::waterPvt().inverseFormationVolumeFactor(intQuantsEx.pvtRegionIndex(),
|
||||||
FluidSystem::oilPvt().inverseFormationVolumeFactor(intQuantsEx.pvtRegionIndex(), t_ex, p_ex, 0.0);
|
t_ex, p_ex, Scalar{0.0}, salt_ex) :
|
||||||
|
FluidSystem::oilPvt().inverseFormationVolumeFactor(intQuantsEx.pvtRegionIndex(),
|
||||||
|
t_ex, p_ex, Scalar{0.0});
|
||||||
|
|
||||||
const auto& refDensityLiquidEx = (FluidSystem::phaseIsActive(waterPhaseIdx)) ?
|
const auto& refDensityLiquidEx = (FluidSystem::phaseIsActive(waterPhaseIdx)) ?
|
||||||
FluidSystem::waterPvt().waterReferenceDensity(intQuantsEx.pvtRegionIndex()) :
|
FluidSystem::waterPvt().waterReferenceDensity(intQuantsEx.pvtRegionIndex()) :
|
||||||
@ -373,12 +379,9 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -127,8 +127,14 @@ public:
|
|||||||
MICPpara.getMaximumUreaConcentration(),
|
MICPpara.getMaximumUreaConcentration(),
|
||||||
MICPpara.getToleranceBeforeClogging());
|
MICPpara.getToleranceBeforeClogging());
|
||||||
// obtain the porosity for the clamp in the blackoilnewtonmethod
|
// obtain the porosity for the clamp in the blackoilnewtonmethod
|
||||||
|
if constexpr (std::is_same_v<Scalar, float>) {
|
||||||
|
const auto phi = eclState.fieldProps().get_double("PORO");
|
||||||
|
params_.phi_.resize(phi.size());
|
||||||
|
std::copy(phi.begin(), phi.end(), params_.phi_.begin());
|
||||||
|
} else {
|
||||||
params_.phi_ = eclState.fieldProps().get_double("PORO");
|
params_.phi_ = eclState.fieldProps().get_double("PORO");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
@ -324,13 +324,13 @@ protected:
|
|||||||
else if (enableExtbo && pvIdx == Indices::zFractionIdx) {
|
else if (enableExtbo && pvIdx == Indices::zFractionIdx) {
|
||||||
// z fraction updates are also subject to the Appleyard chop
|
// z fraction updates are also subject to the Appleyard chop
|
||||||
const auto& curr = currentValue[Indices::zFractionIdx]; // or currentValue[pvIdx] given the block condition
|
const auto& curr = currentValue[Indices::zFractionIdx]; // or currentValue[pvIdx] given the block condition
|
||||||
delta = std::clamp(delta, curr - 1.0, curr);
|
delta = std::clamp(delta, curr - Scalar{1.0}, curr);
|
||||||
}
|
}
|
||||||
else if (enablePolymerWeight && pvIdx == Indices::polymerMoleWeightIdx) {
|
else if (enablePolymerWeight && pvIdx == Indices::polymerMoleWeightIdx) {
|
||||||
const double sign = delta >= 0. ? 1. : -1.;
|
const double sign = delta >= 0. ? 1. : -1.;
|
||||||
// maximum change of polymer molecular weight, the unit is MDa.
|
// maximum change of polymer molecular weight, the unit is MDa.
|
||||||
// applying this limit to stabilize the simulation. The value itself is still experimental.
|
// applying this limit to stabilize the simulation. The value itself is still experimental.
|
||||||
const double maxMolarWeightChange = 100.0;
|
const Scalar maxMolarWeightChange = 100.0;
|
||||||
delta = sign * std::min(std::abs(delta), maxMolarWeightChange);
|
delta = sign * std::min(std::abs(delta), maxMolarWeightChange);
|
||||||
delta *= satAlpha;
|
delta *= satAlpha;
|
||||||
}
|
}
|
||||||
@ -341,8 +341,8 @@ protected:
|
|||||||
else if (enableBrine && pvIdx == Indices::saltConcentrationIdx &&
|
else if (enableBrine && pvIdx == Indices::saltConcentrationIdx &&
|
||||||
enableSaltPrecipitation &&
|
enableSaltPrecipitation &&
|
||||||
currentValue.primaryVarsMeaningBrine() == PrimaryVariables::BrineMeaning::Sp) {
|
currentValue.primaryVarsMeaningBrine() == PrimaryVariables::BrineMeaning::Sp) {
|
||||||
const double maxSaltSaturationChange = 0.1;
|
const Scalar maxSaltSaturationChange = 0.1;
|
||||||
const double sign = delta >= 0. ? 1. : -1.;
|
const Scalar sign = delta >= 0. ? 1. : -1.;
|
||||||
delta = sign * std::min(std::abs(delta), maxSaltSaturationChange);
|
delta = sign * std::min(std::abs(delta), maxSaltSaturationChange);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -352,19 +352,19 @@ protected:
|
|||||||
// keep the solvent saturation between 0 and 1
|
// keep the solvent saturation between 0 and 1
|
||||||
if (enableSolvent && pvIdx == Indices::solventSaturationIdx) {
|
if (enableSolvent && pvIdx == Indices::solventSaturationIdx) {
|
||||||
if (currentValue.primaryVarsMeaningSolvent() == PrimaryVariables::SolventMeaning::Ss )
|
if (currentValue.primaryVarsMeaningSolvent() == PrimaryVariables::SolventMeaning::Ss )
|
||||||
nextValue[pvIdx] = std::min(std::max(nextValue[pvIdx], 0.0), 1.0);
|
nextValue[pvIdx] = std::min(std::max(nextValue[pvIdx], Scalar{0.0}), Scalar{1.0});
|
||||||
}
|
}
|
||||||
|
|
||||||
// keep the z fraction between 0 and 1
|
// keep the z fraction between 0 and 1
|
||||||
if (enableExtbo && pvIdx == Indices::zFractionIdx)
|
if (enableExtbo && pvIdx == Indices::zFractionIdx)
|
||||||
nextValue[pvIdx] = std::min(std::max(nextValue[pvIdx], 0.0), 1.0);
|
nextValue[pvIdx] = std::min(std::max(nextValue[pvIdx], Scalar{0.0}), Scalar{1.0});
|
||||||
|
|
||||||
// keep the polymer concentration above 0
|
// keep the polymer concentration above 0
|
||||||
if (enablePolymer && pvIdx == Indices::polymerConcentrationIdx)
|
if (enablePolymer && pvIdx == Indices::polymerConcentrationIdx)
|
||||||
nextValue[pvIdx] = std::max(nextValue[pvIdx], 0.0);
|
nextValue[pvIdx] = std::max(nextValue[pvIdx], Scalar{0.0});
|
||||||
|
|
||||||
if (enablePolymerWeight && pvIdx == Indices::polymerMoleWeightIdx) {
|
if (enablePolymerWeight && pvIdx == Indices::polymerMoleWeightIdx) {
|
||||||
nextValue[pvIdx] = std::max(nextValue[pvIdx], 0.0);
|
nextValue[pvIdx] = std::max(nextValue[pvIdx], Scalar{0.0});
|
||||||
const double polymerConcentration = nextValue[Indices::polymerConcentrationIdx];
|
const double polymerConcentration = nextValue[Indices::polymerConcentrationIdx];
|
||||||
if (polymerConcentration < 1.e-10)
|
if (polymerConcentration < 1.e-10)
|
||||||
nextValue[pvIdx] = 0.0;
|
nextValue[pvIdx] = 0.0;
|
||||||
@ -372,15 +372,15 @@ protected:
|
|||||||
|
|
||||||
// keep the foam concentration above 0
|
// keep the foam concentration above 0
|
||||||
if (enableFoam && pvIdx == Indices::foamConcentrationIdx)
|
if (enableFoam && pvIdx == Indices::foamConcentrationIdx)
|
||||||
nextValue[pvIdx] = std::max(nextValue[pvIdx], 0.0);
|
nextValue[pvIdx] = std::max(nextValue[pvIdx], Scalar{0.0});
|
||||||
|
|
||||||
if (enableBrine && pvIdx == Indices::saltConcentrationIdx) {
|
if (enableBrine && pvIdx == Indices::saltConcentrationIdx) {
|
||||||
// keep the salt concentration above 0
|
// keep the salt concentration above 0
|
||||||
if (!enableSaltPrecipitation || (enableSaltPrecipitation && currentValue.primaryVarsMeaningBrine() == PrimaryVariables::BrineMeaning::Cs))
|
if (!enableSaltPrecipitation || (enableSaltPrecipitation && currentValue.primaryVarsMeaningBrine() == PrimaryVariables::BrineMeaning::Cs))
|
||||||
nextValue[pvIdx] = std::max(nextValue[pvIdx], 0.0);
|
nextValue[pvIdx] = std::max(nextValue[pvIdx], Scalar{0.0});
|
||||||
// keep the salt saturation below upperlimit
|
// keep the salt saturation below upperlimit
|
||||||
if ((enableSaltPrecipitation && currentValue.primaryVarsMeaningBrine() == PrimaryVariables::BrineMeaning::Sp))
|
if ((enableSaltPrecipitation && currentValue.primaryVarsMeaningBrine() == PrimaryVariables::BrineMeaning::Sp))
|
||||||
nextValue[pvIdx] = std::min(nextValue[pvIdx], 1.0-1.e-8);
|
nextValue[pvIdx] = std::min(nextValue[pvIdx], Scalar{1.0-1.e-8});
|
||||||
}
|
}
|
||||||
|
|
||||||
// keep the temperature within given values
|
// keep the temperature within given values
|
||||||
@ -398,15 +398,15 @@ protected:
|
|||||||
// concentration (the urea concentration has been scaled by 10). For
|
// concentration (the urea concentration has been scaled by 10). For
|
||||||
// the biofilm and calcite, we set this value equal to the porosity minus the clogging tolerance.
|
// the biofilm and calcite, we set this value equal to the porosity minus the clogging tolerance.
|
||||||
if (enableMICP && pvIdx == Indices::microbialConcentrationIdx)
|
if (enableMICP && pvIdx == Indices::microbialConcentrationIdx)
|
||||||
nextValue[pvIdx] = std::clamp(nextValue[pvIdx], 0.0, MICPModule::densityBiofilm());
|
nextValue[pvIdx] = std::clamp(nextValue[pvIdx], Scalar{0.0}, MICPModule::densityBiofilm());
|
||||||
if (enableMICP && pvIdx == Indices::oxygenConcentrationIdx)
|
if (enableMICP && pvIdx == Indices::oxygenConcentrationIdx)
|
||||||
nextValue[pvIdx] = std::clamp(nextValue[pvIdx], 0.0, MICPModule::maximumOxygenConcentration());
|
nextValue[pvIdx] = std::clamp(nextValue[pvIdx], Scalar{0.0}, MICPModule::maximumOxygenConcentration());
|
||||||
if (enableMICP && pvIdx == Indices::ureaConcentrationIdx)
|
if (enableMICP && pvIdx == Indices::ureaConcentrationIdx)
|
||||||
nextValue[pvIdx] = std::clamp(nextValue[pvIdx], 0.0, MICPModule::maximumUreaConcentration());
|
nextValue[pvIdx] = std::clamp(nextValue[pvIdx], Scalar{0.0}, MICPModule::maximumUreaConcentration());
|
||||||
if (enableMICP && pvIdx == Indices::biofilmConcentrationIdx)
|
if (enableMICP && pvIdx == Indices::biofilmConcentrationIdx)
|
||||||
nextValue[pvIdx] = std::clamp(nextValue[pvIdx], 0.0, MICPModule::phi()[globalDofIdx] - MICPModule::toleranceBeforeClogging());
|
nextValue[pvIdx] = std::clamp(nextValue[pvIdx], Scalar{0.0}, MICPModule::phi()[globalDofIdx] - MICPModule::toleranceBeforeClogging());
|
||||||
if (enableMICP && pvIdx == Indices::calciteConcentrationIdx)
|
if (enableMICP && pvIdx == Indices::calciteConcentrationIdx)
|
||||||
nextValue[pvIdx] = std::clamp(nextValue[pvIdx], 0.0, MICPModule::phi()[globalDofIdx] - MICPModule::toleranceBeforeClogging());
|
nextValue[pvIdx] = std::clamp(nextValue[pvIdx], Scalar{0.0}, MICPModule::phi()[globalDofIdx] - MICPModule::toleranceBeforeClogging());
|
||||||
}
|
}
|
||||||
|
|
||||||
// switch the new primary variables to something which is physically meaningful.
|
// switch the new primary variables to something which is physically meaningful.
|
||||||
|
@ -849,7 +849,7 @@ public:
|
|||||||
soMax);
|
soMax);
|
||||||
|
|
||||||
Scalar rs = (*this)[Indices::compositionSwitchIdx];
|
Scalar rs = (*this)[Indices::compositionSwitchIdx];
|
||||||
if (rs > std::min(rsMax, rsSat*(1.0 + eps))) {
|
if (rs > std::min(rsMax, rsSat*(Scalar{1.0} + eps))) {
|
||||||
// the gas phase appears, i.e., switch the primary variables to GasMeaning::Sg
|
// the gas phase appears, i.e., switch the primary variables to GasMeaning::Sg
|
||||||
setPrimaryVarsMeaningGas(GasMeaning::Sg);
|
setPrimaryVarsMeaningGas(GasMeaning::Sg);
|
||||||
(*this)[Indices::compositionSwitchIdx] = 0.0; // hydrocarbon gas saturation
|
(*this)[Indices::compositionSwitchIdx] = 0.0; // hydrocarbon gas saturation
|
||||||
@ -876,7 +876,7 @@ public:
|
|||||||
soMax);
|
soMax);
|
||||||
|
|
||||||
Scalar rv = (*this)[Indices::compositionSwitchIdx];
|
Scalar rv = (*this)[Indices::compositionSwitchIdx];
|
||||||
if (rv > std::min(rvMax, rvSat*(1.0 + eps))) {
|
if (rv > std::min(rvMax, rvSat*(Scalar{1.0} + eps))) {
|
||||||
// switch to phase equilibrium mode because the oil phase appears. here
|
// switch to phase equilibrium mode because the oil phase appears. here
|
||||||
// we also need the capillary pressures to calculate the oil phase
|
// we also need the capillary pressures to calculate the oil phase
|
||||||
// pressure using the gas phase pressure
|
// pressure using the gas phase pressure
|
||||||
@ -925,10 +925,10 @@ public:
|
|||||||
ssol =(*this) [Indices::solventSaturationIdx];
|
ssol =(*this) [Indices::solventSaturationIdx];
|
||||||
|
|
||||||
Scalar so = 1.0 - sw - sg - ssol;
|
Scalar so = 1.0 - sw - sg - ssol;
|
||||||
sw = std::min(std::max(sw,0.0),1.0);
|
sw = std::min(std::max(sw, Scalar{0.0}), Scalar{1.0});
|
||||||
so = std::min(std::max(so,0.0),1.0);
|
so = std::min(std::max(so, Scalar{0.0}), Scalar{1.0});
|
||||||
sg = std::min(std::max(sg,0.0),1.0);
|
sg = std::min(std::max(sg, Scalar{0.0}), Scalar{1.0});
|
||||||
ssol = std::min(std::max(ssol,0.0),1.0);
|
ssol = std::min(std::max(ssol, Scalar{0.0}), Scalar{1.0});
|
||||||
Scalar st = sw + so + sg + ssol;
|
Scalar st = sw + so + sg + ssol;
|
||||||
sw = sw/st;
|
sw = sw/st;
|
||||||
sg = sg/st;
|
sg = sg/st;
|
||||||
@ -981,7 +981,7 @@ public:
|
|||||||
template<class Serializer>
|
template<class Serializer>
|
||||||
void serializeOp(Serializer& serializer)
|
void serializeOp(Serializer& serializer)
|
||||||
{
|
{
|
||||||
using FV = Dune::FieldVector<double,getPropValue<TypeTag, Properties::NumEq>()>;
|
using FV = Dune::FieldVector<Scalar, getPropValue<TypeTag, Properties::NumEq>()>;
|
||||||
serializer(static_cast<FV&>(*this));
|
serializer(static_cast<FV&>(*this));
|
||||||
serializer(primaryVarsMeaningWater_);
|
serializer(primaryVarsMeaningWater_);
|
||||||
serializer(primaryVarsMeaningPressure_);
|
serializer(primaryVarsMeaningPressure_);
|
||||||
|
@ -1633,7 +1633,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
// do the normalization of the relative error
|
// do the normalization of the relative error
|
||||||
Scalar alpha = std::max(1e-20,
|
Scalar alpha = std::max(Scalar{1e-20},
|
||||||
std::max(std::abs(maxRelErr),
|
std::max(std::abs(maxRelErr),
|
||||||
std::abs(minRelErr)));
|
std::abs(minRelErr)));
|
||||||
for (unsigned globalIdx = 0; globalIdx < numGridDof; ++ globalIdx)
|
for (unsigned globalIdx = 0; globalIdx < numGridDof; ++ globalIdx)
|
||||||
|
@ -454,13 +454,13 @@ public:
|
|||||||
if (numIterations_ > targetIterations_()) {
|
if (numIterations_ > targetIterations_()) {
|
||||||
Scalar percent = Scalar(numIterations_ - targetIterations_())/targetIterations_();
|
Scalar percent = Scalar(numIterations_ - targetIterations_())/targetIterations_();
|
||||||
Scalar nextDt = std::max(problem().minTimeStepSize(),
|
Scalar nextDt = std::max(problem().minTimeStepSize(),
|
||||||
oldDt/(1.0 + percent));
|
oldDt / (Scalar{1.0} + percent));
|
||||||
return nextDt;
|
return nextDt;
|
||||||
}
|
}
|
||||||
|
|
||||||
Scalar percent = Scalar(targetIterations_() - numIterations_)/targetIterations_();
|
Scalar percent = Scalar(targetIterations_() - numIterations_)/targetIterations_();
|
||||||
Scalar nextDt = std::max(problem().minTimeStepSize(),
|
Scalar nextDt = std::max(problem().minTimeStepSize(),
|
||||||
oldDt*(1.0 + percent/1.2));
|
oldDt*(Scalar{1.0} + percent / Scalar{1.2}));
|
||||||
return nextDt;
|
return nextDt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user