mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
Generate Property Object Directly
This commit switches computePropertiesForPressures() to return a Properties object directly instead of populating an object constructed in the caller. There is just a single call site for this function so there's no benefit to using an out parameter here. While here, also collect the property callbacks into a structure to simplify the function signature. This also enables not filling in the solvent properties unless solvent is active in the run. Update caller accordingly.
This commit is contained in:
parent
6f2ee80e41
commit
586d8e2ddc
@ -267,12 +267,13 @@ namespace Opm
|
|||||||
WellState<Scalar>& well_state,
|
WellState<Scalar>& well_state,
|
||||||
DeferredLogger& deferred_logger);
|
DeferredLogger& deferred_logger);
|
||||||
|
|
||||||
// calculate the properties for the well connections
|
|
||||||
// to calulate the pressure difference between well connections.
|
|
||||||
using WellConnectionProps = typename StdWellEval::StdWellConnections::Properties;
|
using WellConnectionProps = typename StdWellEval::StdWellConnections::Properties;
|
||||||
void computePropertiesForWellConnectionPressures(const Simulator& simulator,
|
|
||||||
const WellState<Scalar>& well_state,
|
// Compute connection level PVT properties needed to calulate the
|
||||||
WellConnectionProps& props) const;
|
// pressure difference between well connections.
|
||||||
|
WellConnectionProps
|
||||||
|
computePropertiesForWellConnectionPressures(const Simulator& simulator,
|
||||||
|
const WellState<Scalar>& well_state) const;
|
||||||
|
|
||||||
void computeWellConnectionDensitesPressures(const Simulator& simulator,
|
void computeWellConnectionDensitesPressures(const Simulator& simulator,
|
||||||
const WellState<Scalar>& well_state,
|
const WellState<Scalar>& well_state,
|
||||||
|
@ -420,15 +420,13 @@ initialiseConnectionMixture(const int num_comp,
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<class FluidSystem, class Indices>
|
template<class FluidSystem, class Indices>
|
||||||
void StandardWellConnections<FluidSystem,Indices>::
|
typename StandardWellConnections<FluidSystem, Indices>::Properties
|
||||||
computePropertiesForPressures(const WellState<Scalar>& well_state,
|
StandardWellConnections<FluidSystem,Indices>::
|
||||||
const std::function<Scalar(int,int)>& getTemperature,
|
computePropertiesForPressures(const WellState<Scalar>& well_state,
|
||||||
const std::function<Scalar(int)>& getSaltConcentration,
|
const PressurePropertyFunctions& prop_func) const
|
||||||
const std::function<int(int)>& pvtRegionIdx,
|
|
||||||
const std::function<Scalar(int)>& solventInverseFormationVolumeFactor,
|
|
||||||
const std::function<Scalar(int)>& solventRefDensity,
|
|
||||||
Properties& props) const
|
|
||||||
{
|
{
|
||||||
|
auto props = Properties{};
|
||||||
|
|
||||||
const int nperf = well_.numPerfs();
|
const int nperf = well_.numPerfs();
|
||||||
const PhaseUsage& pu = well_.phaseUsage();
|
const PhaseUsage& pu = well_.phaseUsage();
|
||||||
|
|
||||||
@ -466,9 +464,9 @@ computePropertiesForPressures(const WellState<Scalar>& well_state,
|
|||||||
const int cell_idx = well_.cells()[perf];
|
const int cell_idx = well_.cells()[perf];
|
||||||
|
|
||||||
const Scalar p_avg = (perf_press[perf] + p_above[perf])/2;
|
const Scalar p_avg = (perf_press[perf] + p_above[perf])/2;
|
||||||
const Scalar temperature = getTemperature(cell_idx, FluidSystem::oilPhaseIdx);
|
const Scalar temperature = prop_func.getTemperature(cell_idx, FluidSystem::oilPhaseIdx);
|
||||||
const Scalar saltConcentration = getSaltConcentration(cell_idx);
|
const Scalar saltConcentration = prop_func.getSaltConcentration(cell_idx);
|
||||||
const int region_idx = pvtRegionIdx(cell_idx);
|
const int region_idx = prop_func.pvtRegionIdx(cell_idx);
|
||||||
|
|
||||||
if (waterPresent) {
|
if (waterPresent) {
|
||||||
const unsigned waterCompIdx = Indices::canonicalToActiveComponentIndex(FluidSystem::waterCompIdx);
|
const unsigned waterCompIdx = Indices::canonicalToActiveComponentIndex(FluidSystem::waterCompIdx);
|
||||||
@ -572,10 +570,15 @@ computePropertiesForPressures(const WellState<Scalar>& well_state,
|
|||||||
|
|
||||||
// We use cell values for solvent injector
|
// We use cell values for solvent injector
|
||||||
if constexpr (Indices::enableSolvent) {
|
if constexpr (Indices::enableSolvent) {
|
||||||
props.b_perf[well_.numComponents() * perf + Indices::contiSolventEqIdx] = solventInverseFormationVolumeFactor(cell_idx);
|
props.b_perf[well_.numComponents() * perf + Indices::contiSolventEqIdx] =
|
||||||
props.surf_dens_perf[well_.numComponents() * perf + Indices::contiSolventEqIdx] = solventRefDensity(cell_idx);
|
prop_func.solventInverseFormationVolumeFactor(cell_idx);
|
||||||
|
|
||||||
|
props.surf_dens_perf[well_.numComponents() * perf + Indices::contiSolventEqIdx] =
|
||||||
|
prop_func.solventRefDensity(cell_idx);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return props;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class FluidSystem, class Indices>
|
template <class FluidSystem, class Indices>
|
||||||
|
@ -57,13 +57,18 @@ public:
|
|||||||
std::vector<Scalar> surf_dens_perf{};
|
std::vector<Scalar> surf_dens_perf{};
|
||||||
};
|
};
|
||||||
|
|
||||||
void computePropertiesForPressures(const WellState<Scalar>& well_state,
|
struct PressurePropertyFunctions
|
||||||
const std::function<Scalar(int,int)>& getTemperature,
|
{
|
||||||
const std::function<Scalar(int)>& getSaltConcentration,
|
std::function<Scalar(int,int)> getTemperature{};
|
||||||
const std::function<int(int)>& pvtRegionIdx,
|
std::function<Scalar(int)> getSaltConcentration{};
|
||||||
const std::function<Scalar(int)>& solventInverseFormationVolumeFactor,
|
std::function<int(int)> pvtRegionIdx{};
|
||||||
const std::function<Scalar(int)>& solventRefDensity,
|
std::function<Scalar(int)> solventInverseFormationVolumeFactor{};
|
||||||
Properties& props) const;
|
std::function<Scalar(int)> solventRefDensity{};
|
||||||
|
};
|
||||||
|
|
||||||
|
Properties
|
||||||
|
computePropertiesForPressures(const WellState<Scalar>& well_state,
|
||||||
|
const PressurePropertyFunctions& propFunc) const;
|
||||||
|
|
||||||
//! \brief Compute connection properties (densities, pressure drop, ...)
|
//! \brief Compute connection properties (densities, pressure drop, ...)
|
||||||
void computeProperties(const WellState<Scalar>& well_state,
|
void computeProperties(const WellState<Scalar>& well_state,
|
||||||
|
@ -1133,45 +1133,50 @@ namespace Opm
|
|||||||
|
|
||||||
|
|
||||||
template<typename TypeTag>
|
template<typename TypeTag>
|
||||||
void
|
typename StandardWell<TypeTag>::WellConnectionProps
|
||||||
StandardWell<TypeTag>::
|
StandardWell<TypeTag>::
|
||||||
computePropertiesForWellConnectionPressures(const Simulator& simulator,
|
computePropertiesForWellConnectionPressures(const Simulator& simulator,
|
||||||
const WellState<Scalar>& well_state,
|
const WellState<Scalar>& well_state) const
|
||||||
WellConnectionProps& props) const
|
|
||||||
{
|
{
|
||||||
std::function<Scalar(int,int)> getTemperature =
|
auto prop_func = typename StdWellEval::StdWellConnections::PressurePropertyFunctions {
|
||||||
[&simulator](int cell_idx, int phase_idx)
|
// getTemperature
|
||||||
{
|
[&model = simulator.model()](int cell_idx, int phase_idx)
|
||||||
return simulator.model().intensiveQuantities(cell_idx, 0).fluidState().temperature(phase_idx).value();
|
{
|
||||||
};
|
return model.intensiveQuantities(cell_idx, /* time_idx = */ 0)
|
||||||
std::function<Scalar(int)> getSaltConcentration =
|
.fluidState().temperature(phase_idx).value();
|
||||||
[&simulator](int cell_idx)
|
},
|
||||||
{
|
|
||||||
return simulator.model().intensiveQuantities(cell_idx, 0).fluidState().saltConcentration().value();
|
// getSaltConcentration
|
||||||
};
|
[&model = simulator.model()](int cell_idx)
|
||||||
std::function<int(int)> getPvtRegionIdx =
|
{
|
||||||
[&simulator](int cell_idx)
|
return model.intensiveQuantities(cell_idx, /* time_idx = */ 0)
|
||||||
{
|
.fluidState().saltConcentration().value();
|
||||||
return simulator.model().intensiveQuantities(cell_idx, 0).fluidState().pvtRegionIndex();
|
},
|
||||||
};
|
|
||||||
std::function<Scalar(int)> getInvFac =
|
// getPvtRegionIdx
|
||||||
[&simulator](int cell_idx)
|
[&model = simulator.model()](int cell_idx)
|
||||||
{
|
{
|
||||||
return simulator.model().intensiveQuantities(cell_idx, 0).solventInverseFormationVolumeFactor().value();
|
return model.intensiveQuantities(cell_idx, /* time_idx = */ 0)
|
||||||
};
|
.fluidState().pvtRegionIndex();
|
||||||
std::function<Scalar(int)> getSolventDensity =
|
}
|
||||||
[&simulator](int cell_idx)
|
|
||||||
{
|
|
||||||
return simulator.model().intensiveQuantities(cell_idx, 0).solventRefDensity();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
this->connections_.computePropertiesForPressures(well_state,
|
if constexpr (Indices::enableSolvent) {
|
||||||
getTemperature,
|
prop_func.solventInverseFormationVolumeFactor =
|
||||||
getSaltConcentration,
|
[&model = simulator.model()](int cell_idx)
|
||||||
getPvtRegionIdx,
|
{
|
||||||
getInvFac,
|
return model.intensiveQuantities(cell_idx, /* time_idx = */ 0)
|
||||||
getSolventDensity,
|
.solventInverseFormationVolumeFactor().value();
|
||||||
props);
|
};
|
||||||
|
|
||||||
|
prop_func.solventRefDensity = [&model = simulator.model()](int cell_idx)
|
||||||
|
{
|
||||||
|
return model.intensiveQuantities(cell_idx, /* time_idx = */ 0)
|
||||||
|
.solventRefDensity();
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
return this->connections_.computePropertiesForPressures(well_state, prop_func);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1347,11 +1352,9 @@ namespace Opm
|
|||||||
const WellState<Scalar>& well_state,
|
const WellState<Scalar>& well_state,
|
||||||
DeferredLogger& deferred_logger)
|
DeferredLogger& deferred_logger)
|
||||||
{
|
{
|
||||||
// 1. Compute properties required by computePressureDelta().
|
const auto props = computePropertiesForWellConnectionPressures
|
||||||
// Note that some of the complexity of this part is due to the function
|
(simulator, well_state);
|
||||||
// taking std::vector<Scalar> arguments, and not Eigen objects.
|
|
||||||
WellConnectionProps props;
|
|
||||||
computePropertiesForWellConnectionPressures(simulator, well_state, props);
|
|
||||||
computeWellConnectionDensitesPressures(simulator, well_state,
|
computeWellConnectionDensitesPressures(simulator, well_state,
|
||||||
props, deferred_logger);
|
props, deferred_logger);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user