some cleaning up related to flowexp

This commit is contained in:
Kai Bao 2024-04-22 14:27:46 +02:00
parent e2cfd0bd34
commit 729be2c658
4 changed files with 13 additions and 141 deletions

View File

@ -33,7 +33,7 @@ namespace Opm {
/*!
* \ingroup BlackOil
* \brief Contains the high level supplements required to extend the black oil
* model by energy.
* model by energy using global indices.
*/
template <class TypeTag, bool enableEnergyV = getPropValue<TypeTag, Properties::EnableEnergy>()>
class BlackOilEnergyIntensiveQuantitiesGlobalIndex: public BlackOilEnergyIntensiveQuantities<TypeTag,enableEnergyV>
@ -58,7 +58,6 @@ public:
unsigned timeIdx)
{
auto& fs = Parent::asImp_().fluidState_;
//const auto& priVars = elemCtx.primaryVars(dofIdx, timeIdx);
// set temperature
fs.setTemperature(priVars.makeEvaluation(temperatureIdx, timeIdx));
}
@ -71,7 +70,7 @@ public:
auto& fs = Parent::asImp_().fluidState_;
// compute the specific enthalpy of the fluids, the specific enthalpy of the rock
// and the thermal condictivity coefficients
// and the thermal conductivity coefficients
for (int phaseIdx = 0; phaseIdx < numPhases; ++ phaseIdx) {
if (!FluidSystem::phaseIsActive(phaseIdx)) {
continue;
@ -115,7 +114,6 @@ class BlackOilEnergyIntensiveQuantitiesGlobalIndex<TypeTag, false>: public Black
if constexpr (enableTemperature) {
// even if energy is conserved, the temperature can vary over the spatial
// domain if the EnableTemperature property is set to true
//auto& fs = Parent::asImp_().fluidState_;
auto& fs = this->asImp_().fluidState_;
Scalar T = problem.temperature(globalSpaceIdx, timeIdx);
fs.setTemperature(T);

View File

@ -57,7 +57,7 @@ namespace Opm {
* \ingroup IntensiveQuantities
*
* \brief Contains the quantities which are are constant within a
* finite volume in the black-oil model.
* finite volume in the black-oil model using global indices
*/
template <class TypeTag>
class BlackOilIntensiveQuantitiesGlobalIndex
@ -132,16 +132,6 @@ public:
enableSaltPrecipitation,
false,
Indices::numPhases>;
using ScalarFluidState = BlackOilFluidState<Scalar,
FluidSystem,
enableTemperature,
enableEnergy,
compositionSwitchEnabled,
enableVapwat,
enableBrine,
enableSaltPrecipitation,
false,// no gas in water
Indices::numPhases>;
using Problem = GetPropType<TypeTag, Properties::Problem>;
BlackOilIntensiveQuantitiesGlobalIndex()
@ -154,6 +144,7 @@ public:
fluidState_.setRvw(0.0);
}
}
BlackOilIntensiveQuantitiesGlobalIndex(const BlackOilIntensiveQuantitiesGlobalIndex& other) = default;
BlackOilIntensiveQuantitiesGlobalIndex& operator=(const BlackOilIntensiveQuantitiesGlobalIndex& other) = default;
@ -167,7 +158,6 @@ public:
const auto& problem = elemCtx.problem();
const auto& priVars = elemCtx.primaryVars(dofIdx, timeIdx);
//const auto& linearizationType = problem.model().linearizer().getLinearizationType();
unsigned globalSpaceIdx = elemCtx.globalSpaceIndex(dofIdx, timeIdx);
this->update(problem,priVars,globalSpaceIdx,timeIdx);
}
@ -180,8 +170,6 @@ public:
this->extrusionFactor_ = 1.0;// to avoid fixing parent update
OPM_TIMEBLOCK_LOCAL(UpdateIntensiveQuantities);
//const auto& priVars = elemCtx.primaryVars(dofIdx, timeIdx);
//const auto& linearizationType = problem.model().linearizer().getLinearizationType();
Scalar RvMax = FluidSystem::enableVaporizedOil()
? problem.maxOilVaporizationFactor(timeIdx, globalSpaceIdx)
: 0.0;
@ -239,10 +227,6 @@ public:
if (FluidSystem::phaseIsActive(oilPhaseIdx))
fluidState_.setSaturation(oilPhaseIdx, So);
//asImp_().solventPreSatFuncUpdate_(elemCtx, dofIdx, timeIdx);
// now we compute all phase pressures
std::array<Evaluation, numPhases> pC;// = {0, 0, 0};
computeRelpermAndPC(mobility_, pC, problem, fluidState_, globalSpaceIdx);
// oil is the reference phase for pressure
@ -251,25 +235,13 @@ public:
for (unsigned phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx)
if (FluidSystem::phaseIsActive(phaseIdx))
fluidState_.setPressure(phaseIdx, pg + (pC[phaseIdx] - pC[gasPhaseIdx]));
//} else if (priVars.primaryVarsMeaningPressure() == PrimaryVariables::Pw) {
// const Evaluation& pw = priVars.makeEvaluation(Indices::pressureSwitchIdx, timeIdx);
// for (unsigned phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx)
// if (FluidSystem::phaseIsActive(phaseIdx))
// fluidState_.setPressure(phaseIdx, pw + (pC[phaseIdx] - pC[waterPhaseIdx]));
} else {
//assert(FluidSystem::phaseIsActive(oilPhaseIdx));
const Evaluation& po = priVars.makeEvaluation(Indices::pressureSwitchIdx, timeIdx);
for (unsigned phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx)
if (FluidSystem::phaseIsActive(phaseIdx))
fluidState_.setPressure(phaseIdx, po + (pC[phaseIdx] - pC[oilPhaseIdx]));
}
// update the Saturation functions for the blackoil solvent module.
//asImp_().solventPostSatFuncUpdate_(elemCtx, dofIdx, timeIdx);
// update extBO parameters
//asImp_().zFractionUpdate_(elemCtx, dofIdx, timeIdx);
Evaluation SoMax = 0.0;
if (FluidSystem::phaseIsActive(FluidSystem::oilPhaseIdx)) {
SoMax = max(fluidState_.saturation(oilPhaseIdx),
@ -327,22 +299,6 @@ public:
}
}
// typename FluidSystem::template ParameterCache<Evaluation> paramCache;
// paramCache.setRegionIndex(pvtRegionIdx);
// if (FluidSystem::phaseIsActive(FluidSystem::oilPhaseIdx)) {
// paramCache.setMaxOilSat(SoMax);
// }
// paramCache.updateAll(fluidState_);
// compute the phase densities and transform the phase permeabilities into mobilities
// int nmobilities = 1;
// std::vector<std::array<Evaluation,numPhases>*> mobilities = {&mobility_};
// if (dirMob_) {
// for (int i=0; i<3; i++) {
// nmobilities += 1;
// mobilities.push_back(&(dirMob_->getArray(i)));
// }
// }
for (unsigned phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx) {
if (!FluidSystem::phaseIsActive(phaseIdx))
continue;
@ -396,7 +352,6 @@ public:
porosity_ = referencePorosity_;
// the porosity must be modified by the compressibility of the
// rock...
Scalar rockCompressibility = problem.rockCompressibility(globalSpaceIdx);
if (rockCompressibility > 0.0) {
OPM_TIMEBLOCK_LOCAL(UpdateRockCompressibility);
@ -415,36 +370,8 @@ public:
// deal with water induced rock compaction
porosity_ *= problem.template rockCompPoroMultiplier<Evaluation>(*this, globalSpaceIdx);
// the MICP processes change the porosity
// if constexpr (enableMICP){
// Evaluation biofilm_ = priVars.makeEvaluation(Indices::biofilmConcentrationIdx, timeIdx, linearizationType);
// Evaluation calcite_ = priVars.makeEvaluation(Indices::calciteConcentrationIdx, timeIdx, linearizationType);
// porosity_ += - biofilm_ - calcite_;
// }
// // deal with salt-precipitation
// if (enableSaltPrecipitation && priVars.primaryVarsMeaningBrine() == PrimaryVariables::BrineMeaning::Sp) {
// Evaluation Sp = priVars.makeEvaluation(Indices::saltConcentrationIdx, timeIdx);
// porosity_ *= (1.0 - Sp);
// }
rockCompTransMultiplier_ = problem.template rockCompTransMultiplier<Evaluation>(*this, globalSpaceIdx);
// asImp_().solventPvtUpdate_(elemCtx, dofIdx, timeIdx);
// asImp_().zPvtUpdate_();
// asImp_().polymerPropertiesUpdate_(elemCtx, dofIdx, timeIdx);
// asImp_().updateEnergyQuantities_(elemCtx, dofIdx, timeIdx, paramCache);
// asImp_().foamPropertiesUpdate_(elemCtx, dofIdx, timeIdx);
// asImp_().MICPPropertiesUpdate_(elemCtx, dofIdx, timeIdx);
// asImp_().saltPropertiesUpdate_(elemCtx, dofIdx, timeIdx);
// update the quantities which are required by the chosen
// velocity model
// FluxIntensiveQuantities::update_(elemCtx, dofIdx, timeIdx);
// update the diffusion specific quantities of the intensive quantities
// DiffusionIntensiveQuantities::update_(fluidState_, paramCache, elemCtx, dofIdx, timeIdx);
#ifndef NDEBUG
// some safety checks in debug mode
for (unsigned phaseIdx = 0; phaseIdx < numPhases; ++ phaseIdx) {
@ -516,20 +443,8 @@ public:
paramCache.updateAll(fluidState_);
const auto& mu = FluidSystem::viscosity(fluidState, paramCache, phaseIdx);
// for (int i = 0; i<nmobilities; i++) {
// if (enableExtbo && phaseIdx == oilPhaseIdx) {
// (*mobilities[i])[phaseIdx] /= asImp_().oilViscosity();
// }
// else if (enableExtbo && phaseIdx == gasPhaseIdx) {
// (*mobilities[i])[phaseIdx] /= asImp_().gasViscosity();
// }
// else {
// (*mobilities[i])[phaseIdx] /= mu;
// }
// }
mobility_[phaseIdx] /=mu;
mobility_[phaseIdx] /= mu;
}
//mobility_[phaseIdx] /= 1e-3;
}
void computeRelpermAndPC(std::array<Evaluation,numPhases>& mobility,
@ -541,10 +456,6 @@ public:
const auto& materialParams = problem.materialLawParams(globalSpaceIdx);
MaterialLaw::capillaryPressures(pC, materialParams, fluidState_);
problem.updateRelperms(mobility, dirMob_, fluidState, globalSpaceIdx);
//mobility_[waterPhaseIdx] = Sw;
//mobility_[oilPhaseIdx] = So;
//mobility_[gasPhaseIdx] = Sg;
}
/*!
* \copydoc ImmiscibleIntensiveQuantities::porosity

View File

@ -23,7 +23,7 @@
/*!
* \file
*
* \brief The common settings for all ebos variants.
* \brief The common settings for all flowexp variants.
*/
#ifndef FLOW_EXP_HPP
#define FLOW_EXP_HPP
@ -58,7 +58,7 @@ struct Problem<TypeTag, TTag::FlowExpTypeTag> {
using type = FlowExpProblem<TypeTag>;
};
// Enable experimental features for ebos: ebos is the research simulator of the OPM
// Enable experimental features for flowexp: flowexp is the research simulator of the OPM
// project. If you're looking for a more stable "production quality" simulator, consider
// using `flow`
template<class TypeTag>
@ -77,9 +77,9 @@ struct NewtonMethod<TypeTag, TTag::FlowExpTypeTag> {
using type = FlowNewtonMethod<TypeTag>;
};
// currently, ebos uses the non-multisegment well model by default to avoid
// currently, flowexp uses the non-multisegment well model by default to avoid
// regressions. the --use-multisegment-well=true|false command line parameter is still
// available in ebos, but hidden from view.
// available in flowexp, but hidden from view.
template<class TypeTag>
struct UseMultisegmentWell<TypeTag, TTag::FlowExpTypeTag> {
static constexpr bool value = false;
@ -185,7 +185,7 @@ struct ThreadsPerProcess<TypeTag, TTag::FlowExpTypeTag> {
};
#endif
// By default, ebos accepts the result of the time integration unconditionally if the
// By default, flowexp accepts the result of the time integration unconditionally if the
// smallest time step size is reached.
template<class TypeTag>
struct ContinueOnConvergenceError<TypeTag, TTag::FlowExpTypeTag> {

View File

@ -17,29 +17,15 @@
along with OPM. If not, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include <opm/simulators/flow/FlowProblem.hpp>
#include "flownewtonmethod.hpp"
#include "flowexp.hpp"
#include <opm/simulators/flow/Main.hpp>
#include <opm/models/blackoil/blackoillocalresidualtpfa.hh>
#include <opm/models/discretization/common/tpfalinearizer.hh>
#include <opm/simulators/flow/Main.hpp>
#include <opm/simulators/flow/FlowProblem.hpp>
#include "BlackOilIntensiveQuantitiesGlobalIndex.hpp"
#include "FIBlackOilModelNoCache.hpp"
// the current code use eclnewtonmethod adding other conditions to proceed_ should do the trick for KA
// adding linearshe sould be chaning the update_ function in the same class with condition that the error is reduced.
// the trick is to be able to recalculate the residual from here.
// unsure where the timestepping is done from suggestedtime??
// suggestTimeStep is taken from newton solver in problem.limitTimestep
/* namespace Opm{
template<typename TypeTag>
class OutputAuxModule : public BaseAuxiliaryModule<TypeTag>
{
};
} */
namespace Opm::Properties {
namespace TTag {
@ -100,38 +86,15 @@ struct EclNewtonRelaxedTolerance<TypeTag, TTag::FlowExpProblemBlackOil> {
static constexpr type value = 10*getPropValue<TypeTag, Properties::NewtonTolerance>();
};
//template<class TypeTag>
//struct Linearizer<TypeTag, TTag::FlowExpProblemBlackOil> { using type = TpfaLinearizer<TypeTag>; };
// template<class TypeTag>
// struct LocalResidual<TypeTag, TTag::FlowExpProblemBlackOil> { using type = BlackOilLocalResidualTPFA<TypeTag>; };
template<class TypeTag>
struct EnableDiffusion<TypeTag, TTag::FlowExpProblemBlackOil> { static constexpr bool value = false; };
template<class TypeTag>
struct EnableDisgasInWater<TypeTag, TTag::FlowExpProblemBlackOil> { static constexpr bool value = false; };
//static constexpr bool has_disgas_in_water = getPropValue<TypeTag, Properties::EnableDisgasInWater>();
template<class TypeTag>
struct Simulator<TypeTag, TTag::FlowExpProblemBlackOil> { using type = Opm::Simulator<TypeTag>; };
// template<class TypeTag>
// struct LinearSolverBackend<TypeTag, TTag::FlowExpProblemBlackOil> {
// using type = ISTLSolver<TypeTag>;
// };
// // Set the problem class
// template<class TypeTag>
// struct Problem<TypeTag, TTag::FlowExpTypeTag> {
// using type = FlowExpProblem<TypeTag>;
// };
// template<class TypeTag>
// struct EclEnableAquifers<TypeTag, TTag::EclFlowProblemTest> {
// static constexpr bool value = false;
// };
}