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

Global index update #731

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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CMakeLists_files.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ list (APPEND PUBLIC_HEADER_FILES
opm/models/blackoil/blackoildiffusionmodule.hh
opm/models/blackoil/blackoilextensivequantities.hh
opm/models/blackoil/blackoilintensivequantities.hh
opm/models/blackoil/blackoilintensivequantitiessimple.hh
opm/models/blackoil/blackoildarcyfluxmodule.hh
opm/models/blackoil/blackoilratevector.hh
opm/models/blackoil/blackoilbrinemodules.hh
Expand Down
10 changes: 10 additions & 0 deletions opm/models/blackoil/blackoilextbomodules.hh
Original file line number Diff line number Diff line change
Expand Up @@ -591,6 +591,11 @@ public:
unsigned timeIdx)
{
const PrimaryVariables& priVars = elemCtx.primaryVars(dofIdx, timeIdx);
this->zFractionUpdate_(priVars,timeIdx);
}
void zFractionUpdate_(const PrimaryVariables& priVars,
unsigned timeIdx){
//const PrimaryVariables& priVars = elemCtx.primaryVars(dofIdx, timeIdx);
unsigned pvtRegionIdx = priVars.pvtRegionIndex();
auto& fs = asImp_().fluidState_;

Expand Down Expand Up @@ -743,6 +748,7 @@ protected:
template <class TypeTag>
class BlackOilExtboIntensiveQuantities<TypeTag, false>
{
using PrimaryVariables = GetPropType<TypeTag, Properties::PrimaryVariables>;
using Evaluation = GetPropType<TypeTag, Properties::Evaluation>;
using ElementContext = GetPropType<TypeTag, Properties::ElementContext>;
using Scalar = GetPropType<TypeTag, Properties::Scalar>;
Expand All @@ -757,6 +763,10 @@ public:
unsigned)
{ }

void zFractionUpdate_(const PrimaryVariables&,
unsigned)
{ }

const Evaluation& xVolume() const
{ throw std::runtime_error("xVolume() called but extbo is disabled"); }

Expand Down
118 changes: 85 additions & 33 deletions opm/models/blackoil/blackoilintensivequantities.hh
Original file line number Diff line number Diff line change
Expand Up @@ -159,27 +159,27 @@ public:
/*!
* \copydoc IntensiveQuantities::update
*/
void update(const ElementContext& elemCtx, unsigned dofIdx, unsigned timeIdx)
{
ParentType::update(elemCtx, dofIdx, timeIdx);

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);

//problem and global index is to avoid to many input, the variables should
// maybe bee only for this index
void updateIndexBased(const Problem& problem,
const PrimaryVariables& priVars,
const LinearizationType linearizationType,
const unsigned globalSpaceIdx,
const unsigned timeIdx){
Scalar RvMax = FluidSystem::enableVaporizedOil()
? problem.maxOilVaporizationFactor(timeIdx, globalSpaceIdx)
: 0.0;
Scalar RsMax = FluidSystem::enableDissolvedGas()
? problem.maxGasDissolutionFactor(timeIdx, globalSpaceIdx)
: 0.0;

asImp_().updateTemperature_(elemCtx, dofIdx, timeIdx);


// keep this to be able to call function standalone for blackoil
unsigned pvtRegionIdx = priVars.pvtRegionIndex();
fluidState_.setPvtRegionIndex(pvtRegionIdx);

asImp_().updateSaltConcentration_(elemCtx, dofIdx, timeIdx);


// extract the water and the gas saturations for convenience
Evaluation Sw = 0.0;
Expand Down Expand Up @@ -240,8 +240,12 @@ public:
if (FluidSystem::phaseIsActive(oilPhaseIdx))
fluidState_.setSaturation(oilPhaseIdx, So);

asImp_().solventPreSatFuncUpdate_(elemCtx, dofIdx, timeIdx);

//asImp_().solventPreSatFuncUpdate_(elemCtx, dofIdx, timeIdx);
asImp_().solventPreSatFuncUpdate_(problem,
priVars,
linearizationType,
globalSpaceIdx,
timeIdx);
// now we compute all phase pressures
std::array<Evaluation, numPhases> pC;
const auto& materialParams = problem.materialLawParams(globalSpaceIdx);
Expand All @@ -264,10 +268,18 @@ public:
}

// update the Saturation functions for the blackoil solvent module.
asImp_().solventPostSatFuncUpdate_(elemCtx, dofIdx, timeIdx);

//asImp_().solventPostSatFuncUpdate_(elemCtx, dofIdx, timeIdx);
asImp_().solventPostSatFuncUpdate_(problem,
priVars,
linearizationType,
globalSpaceIdx,
timeIdx);



// update extBO parameters
asImp_().zFractionUpdate_(elemCtx, dofIdx, timeIdx);
//asImp_().zFractionUpdate_(elemCtx, dofIdx, timeIdx);
asImp_().zFractionUpdate_(priVars,timeIdx);

Evaluation SoMax = 0.0;
if (FluidSystem::phaseIsActive(FluidSystem::oilPhaseIdx)) {
Expand Down Expand Up @@ -478,7 +490,8 @@ public:
}

// retrieve the porosity from the problem
referencePorosity_ = problem.porosity(elemCtx, dofIdx, timeIdx);
//referencePorosity_ = problem.porosity(elemCtx, dofIdx, timeIdx);
referencePorosity_ = problem.porosity(globalSpaceIdx, timeIdx);
porosity_ = referencePorosity_;

// the porosity must be modified by the compressibility of the
Expand Down Expand Up @@ -515,22 +528,8 @@ public:

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

#ifndef NDEBUG
// some safety checks in debug mode
for (unsigned phaseIdx = 0; phaseIdx < numPhases; ++ phaseIdx) {
if (!FluidSystem::phaseIsActive(phaseIdx))
Expand All @@ -546,7 +545,60 @@ public:
assert(isfinite(fluidState_.Rv()));
#endif
}
void update(const Problem& problem,
const PrimaryVariables& priVars,
const LinearizationType linearizationType,
const unsigned globalSpaceIdx,
const unsigned timeIdx){
// TODO: static assert that none of the not handled modules are present
this->updateIndexBased(problem,
priVars,
linearizationType,
globalSpaceIdx,
timeIdx);

}

void update(const ElementContext& elemCtx, unsigned dofIdx, unsigned timeIdx)
{
ParentType::update(elemCtx, dofIdx, timeIdx);
asImp_().updateTemperature_(elemCtx, dofIdx, timeIdx);
const auto& problem = elemCtx.problem();
const auto& priVars = elemCtx.primaryVars(dofIdx, timeIdx);
unsigned pvtRegionIdx = priVars.pvtRegionIndex();
fluidState_.setPvtRegionIndex(pvtRegionIdx);

asImp_().updateSaltConcentration_(elemCtx, dofIdx, timeIdx);


const auto& linearizationType = elemCtx.linearizationType();
unsigned globalSpaceIdx = elemCtx.globalSpaceIndex(dofIdx, timeIdx);
this->updateIndexBased(problem, priVars,linearizationType,globalSpaceIdx, timeIdx);
asImp_().solventPvtUpdate_(elemCtx, dofIdx, timeIdx);
asImp_().zPvtUpdate_();
asImp_().polymerPropertiesUpdate_(elemCtx, dofIdx, timeIdx);
// redo for now when energy is included with tpfa linearizer it can probably be moved
typename FluidSystem::template ParameterCache<Evaluation> paramCache;
paramCache.setRegionIndex(pvtRegionIdx);
if (FluidSystem::phaseIsActive(FluidSystem::oilPhaseIdx)) {
Evaluation SoMax = max(fluidState_.saturation(oilPhaseIdx),
problem.maxOilSaturation(globalSpaceIdx));
paramCache.setMaxOilSat(SoMax);
}
paramCache.updateAll(fluidState_);
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);

}
/*!
* \copydoc ImmiscibleIntensiveQuantities::fluidState
*/
Expand Down