Use &ref not shared_pointer to MaterialLawManager

This commit is contained in:
Tor Harald Sandve 2017-11-21 12:07:59 +01:00
parent 51f48fcd13
commit 0ef82665f5
5 changed files with 45 additions and 45 deletions

View File

@ -148,8 +148,8 @@ try
/*gasPhaseIdx=*/Opm::BlackoilPhases::Vapour> MaterialTraits; /*gasPhaseIdx=*/Opm::BlackoilPhases::Vapour> MaterialTraits;
typedef Opm::EclMaterialLawManager<MaterialTraits> MaterialLawManager; typedef Opm::EclMaterialLawManager<MaterialTraits> MaterialLawManager;
auto materialLawManager = std::make_shared<MaterialLawManager>(); MaterialLawManager materialLawManager = MaterialLawManager();
materialLawManager->initFromDeck(deck, eclipseState, compressedToCartesianIdx); materialLawManager.initFromDeck(deck, eclipseState, compressedToCartesianIdx);
// Initialisation. // Initialisation.
//initBlackoilSurfvolUsingRSorRV(UgGridHelpers::numCells(grid), props, state); //initBlackoilSurfvolUsingRSorRV(UgGridHelpers::numCells(grid), props, state);

View File

@ -568,7 +568,7 @@ namespace Opm
template <class FluidSystem, class MaterialLaw, class MaterialLawManager> template <class FluidSystem, class MaterialLaw, class MaterialLawManager>
struct PcEq struct PcEq
{ {
PcEq(std::shared_ptr<MaterialLawManager> materialLawManager, PcEq(const MaterialLawManager& materialLawManager,
const int phase, const int phase,
const int cell, const int cell,
const double target_pc) const double target_pc)
@ -587,7 +587,7 @@ namespace Opm
double operator()(double s) const double operator()(double s) const
{ {
const auto& matParams = materialLawManager_->materialLawParams(cell_); const auto& matParams = materialLawManager_.materialLawParams(cell_);
fluidState_.setSaturation(phase_, s); fluidState_.setSaturation(phase_, s);
MaterialLaw::capillaryPressures(pc_, matParams, fluidState_); MaterialLaw::capillaryPressures(pc_, matParams, fluidState_);
double sign = (phase_ == FluidSystem::waterPhaseIdx)? -1.0 : 1.0; double sign = (phase_ == FluidSystem::waterPhaseIdx)? -1.0 : 1.0;
@ -596,7 +596,7 @@ namespace Opm
} }
private: private:
std::shared_ptr<MaterialLawManager> materialLawManager_; const MaterialLawManager& materialLawManager_;
const int phase_; const int phase_;
const int cell_; const int cell_;
const double target_pc_; const double target_pc_;
@ -605,9 +605,9 @@ namespace Opm
}; };
template <class FluidSystem, class MaterialLawManager> template <class FluidSystem, class MaterialLawManager>
double minSaturations(std::shared_ptr<MaterialLawManager> materialLawManager, const int phase, const int cell) { double minSaturations(const MaterialLawManager& materialLawManager, const int phase, const int cell) {
const auto& scaledDrainageInfo = const auto& scaledDrainageInfo =
materialLawManager->oilWaterScaledEpsInfoDrainage(cell); materialLawManager.oilWaterScaledEpsInfoDrainage(cell);
// Find minimum and maximum saturations. // Find minimum and maximum saturations.
switch(phase) { switch(phase) {
@ -632,9 +632,9 @@ namespace Opm
} }
template <class FluidSystem, class MaterialLawManager> template <class FluidSystem, class MaterialLawManager>
double maxSaturations(std::shared_ptr<MaterialLawManager> materialLawManager, const int phase, const int cell) { double maxSaturations(const MaterialLawManager& materialLawManager, const int phase, const int cell) {
const auto& scaledDrainageInfo = const auto& scaledDrainageInfo =
materialLawManager->oilWaterScaledEpsInfoDrainage(cell); materialLawManager.oilWaterScaledEpsInfoDrainage(cell);
// Find minimum and maximum saturations. // Find minimum and maximum saturations.
switch(phase) { switch(phase) {
@ -664,7 +664,7 @@ namespace Opm
/// Compute saturation of some phase corresponding to a given /// Compute saturation of some phase corresponding to a given
/// capillary pressure. /// capillary pressure.
template <class FluidSystem, class MaterialLaw, class MaterialLawManager > template <class FluidSystem, class MaterialLaw, class MaterialLawManager >
inline double satFromPc(std::shared_ptr<MaterialLawManager> materialLawManager, inline double satFromPc(const MaterialLawManager& materialLawManager,
const int phase, const int phase,
const int cell, const int cell,
const double target_pc, const double target_pc,
@ -700,7 +700,7 @@ namespace Opm
template <class FluidSystem, class MaterialLaw, class MaterialLawManager> template <class FluidSystem, class MaterialLaw, class MaterialLawManager>
struct PcEqSum struct PcEqSum
{ {
PcEqSum(std::shared_ptr<MaterialLawManager> materialLawManager, PcEqSum(const MaterialLawManager& materialLawManager,
const int phase1, const int phase1,
const int phase2, const int phase2,
const int cell, const int cell,
@ -718,7 +718,7 @@ namespace Opm
} }
double operator()(double s) const double operator()(double s) const
{ {
const auto& matParams = materialLawManager_->materialLawParams(cell_); const auto& matParams = materialLawManager_.materialLawParams(cell_);
fluidState_.setSaturation(phase1_, s); fluidState_.setSaturation(phase1_, s);
fluidState_.setSaturation(phase2_, 1.0 - s); fluidState_.setSaturation(phase2_, 1.0 - s);
@ -731,7 +731,7 @@ namespace Opm
return pc1 + pc2 - target_pc_; return pc1 + pc2 - target_pc_;
} }
private: private:
std::shared_ptr<MaterialLawManager> materialLawManager_; const MaterialLawManager& materialLawManager_;
const int phase1_; const int phase1_;
const int phase2_; const int phase2_;
const int cell_; const int cell_;
@ -748,7 +748,7 @@ namespace Opm
/// is given as a sum of two other functions. /// is given as a sum of two other functions.
template <class FluidSystem, class MaterialLaw, class MaterialLawManager> template <class FluidSystem, class MaterialLaw, class MaterialLawManager>
inline double satFromSumOfPcs(std::shared_ptr<MaterialLawManager> materialLawManager, inline double satFromSumOfPcs(const MaterialLawManager& materialLawManager,
const int phase1, const int phase1,
const int phase2, const int phase2,
const int cell, const int cell,
@ -778,7 +778,7 @@ namespace Opm
/// Compute saturation from depth. Used for constant capillary pressure function /// Compute saturation from depth. Used for constant capillary pressure function
template <class FluidSystem, class MaterialLaw, class MaterialLawManager> template <class FluidSystem, class MaterialLaw, class MaterialLawManager>
inline double satFromDepth(std::shared_ptr<MaterialLawManager> materialLawManager, inline double satFromDepth(const MaterialLawManager& materialLawManager,
const double cellDepth, const double cellDepth,
const double contactDepth, const double contactDepth,
const int phase, const int phase,
@ -798,7 +798,7 @@ namespace Opm
/// Return true if capillary pressure function is constant /// Return true if capillary pressure function is constant
template <class FluidSystem, class MaterialLaw, class MaterialLawManager> template <class FluidSystem, class MaterialLaw, class MaterialLawManager>
inline bool isConstPc(std::shared_ptr<MaterialLawManager> materialLawManager, inline bool isConstPc(const MaterialLawManager& materialLawManager,
const int phase, const int phase,
const int cell) const int cell)
{ {

View File

@ -147,7 +147,7 @@ namespace Opm
phaseSaturations(const Grid& grid, phaseSaturations(const Grid& grid,
const Region& reg, const Region& reg,
const CellRange& cells, const CellRange& cells,
std::shared_ptr<MaterialLawManager> materialLawManager, MaterialLawManager& materialLawManager,
const std::vector<double> swat_init, const std::vector<double> swat_init,
std::vector< std::vector<double> >& phase_pressures); std::vector< std::vector<double> >& phase_pressures);
@ -226,7 +226,7 @@ namespace Opm
class InitialStateComputer { class InitialStateComputer {
public: public:
template<class MaterialLawManager, class Grid> template<class MaterialLawManager, class Grid>
InitialStateComputer(std::shared_ptr<MaterialLawManager> materialLawManager, InitialStateComputer(MaterialLawManager& materialLawManager,
const Opm::EclipseState& eclipseState, const Opm::EclipseState& eclipseState,
const Grid& G , const Grid& G ,
const double grav = unit::gravity, const double grav = unit::gravity,
@ -386,7 +386,7 @@ namespace Opm
void void
calcPressSatRsRv(const RMap& reg , calcPressSatRsRv(const RMap& reg ,
const std::vector< EquilRecord >& rec , const std::vector< EquilRecord >& rec ,
std::shared_ptr<MaterialLawManager> materialLawManager, MaterialLawManager& materialLawManager,
const Grid& G , const Grid& G ,
const double grav) const double grav)
{ {

View File

@ -597,7 +597,7 @@ namespace Opm
phaseSaturations(const Grid& G, phaseSaturations(const Grid& G,
const Region& reg, const Region& reg,
const CellRange& cells, const CellRange& cells,
std::shared_ptr<MaterialLawManager> materialLawManager, MaterialLawManager& materialLawManager,
const std::vector<double> swat_init, const std::vector<double> swat_init,
std::vector< std::vector<double> >& phase_pressures) std::vector< std::vector<double> >& phase_pressures)
{ {
@ -633,8 +633,8 @@ namespace Opm
for (typename CellRange::const_iterator ci = cells.begin(); ci != cells.end(); ++ci, ++local_index) { for (typename CellRange::const_iterator ci = cells.begin(); ci != cells.end(); ++ci, ++local_index) {
const int cell = *ci; const int cell = *ci;
const auto& scaledDrainageInfo = const auto& scaledDrainageInfo =
materialLawManager->oilWaterScaledEpsInfoDrainage(cell); materialLawManager.oilWaterScaledEpsInfoDrainage(cell);
const auto& matParams = materialLawManager->materialLawParams(cell); const auto& matParams = materialLawManager.materialLawParams(cell);
// Find saturations from pressure differences by // Find saturations from pressure differences by
// inverting capillary pressure functions. // inverting capillary pressure functions.
@ -653,7 +653,7 @@ namespace Opm
phase_saturations[waterpos][local_index] = sw; phase_saturations[waterpos][local_index] = sw;
} else { // Scale Pc to reflect imposed sw } else { // Scale Pc to reflect imposed sw
sw = swat_init[cell]; sw = swat_init[cell];
sw = materialLawManager->applySwatinit(cell, pcov, sw); sw = materialLawManager.applySwatinit(cell, pcov, sw);
phase_saturations[waterpos][local_index] = sw; phase_saturations[waterpos][local_index] = sw;
} }
} }
@ -684,7 +684,7 @@ namespace Opm
// Re-scale Pc to reflect imposed sw for vanishing oil phase. // Re-scale Pc to reflect imposed sw for vanishing oil phase.
// This seems consistent with ecl, and fails to honour // This seems consistent with ecl, and fails to honour
// swat_init in case of non-trivial gas-oil cap pressure. // swat_init in case of non-trivial gas-oil cap pressure.
sw = materialLawManager->applySwatinit(cell, pcgw, sw); sw = materialLawManager.applySwatinit(cell, pcgw, sw);
} }
sw = satFromSumOfPcs<FluidSystem, MaterialLaw, MaterialLawManager>(materialLawManager, waterpos, gaspos, cell, pcgw); sw = satFromSumOfPcs<FluidSystem, MaterialLaw, MaterialLawManager>(materialLawManager, waterpos, gaspos, cell, pcgw);
sg = 1.0 - sw; sg = 1.0 - sw;

View File

@ -410,8 +410,8 @@ BOOST_AUTO_TEST_CASE (DeckAllDead)
std::vector<int> compressedToCartesianIdx std::vector<int> compressedToCartesianIdx
= Opm::compressedToCartesian(grid->number_of_cells, grid->global_cell); = Opm::compressedToCartesian(grid->number_of_cells, grid->global_cell);
auto materialLawManager = std::make_shared<MaterialLawManager>(); MaterialLawManager materialLawManager = MaterialLawManager();
materialLawManager->initFromDeck(deck, eclipseState, compressedToCartesianIdx); materialLawManager.initFromDeck(deck, eclipseState, compressedToCartesianIdx);
typedef Opm::FluidSystems::BlackOil<double> FluidSystem; typedef Opm::FluidSystems::BlackOil<double> FluidSystem;
@ -449,8 +449,8 @@ BOOST_AUTO_TEST_CASE (CapillaryInversion)
// Create material law manager. // Create material law manager.
std::vector<int> compressedToCartesianIdx std::vector<int> compressedToCartesianIdx
= Opm::compressedToCartesian(grid.number_of_cells, grid.global_cell); = Opm::compressedToCartesian(grid.number_of_cells, grid.global_cell);
auto materialLawManager = std::make_shared<MaterialLawManager>(); MaterialLawManager materialLawManager = MaterialLawManager();
materialLawManager->initFromDeck(deck, eclipseState, compressedToCartesianIdx); materialLawManager.initFromDeck(deck, eclipseState, compressedToCartesianIdx);
typedef Opm::FluidSystems::BlackOil<double> FluidSystem; typedef Opm::FluidSystems::BlackOil<double> FluidSystem;
typedef MaterialLawManager::MaterialLaw MaterialLaw; typedef MaterialLawManager::MaterialLaw MaterialLaw;
@ -515,8 +515,8 @@ BOOST_AUTO_TEST_CASE (DeckWithCapillary)
// Create material law manager. // Create material law manager.
std::vector<int> compressedToCartesianIdx std::vector<int> compressedToCartesianIdx
= Opm::compressedToCartesian(grid.number_of_cells, grid.global_cell); = Opm::compressedToCartesian(grid.number_of_cells, grid.global_cell);
auto materialLawManager = std::make_shared<MaterialLawManager>(); MaterialLawManager materialLawManager = MaterialLawManager();
materialLawManager->initFromDeck(deck, eclipseState, compressedToCartesianIdx); materialLawManager.initFromDeck(deck, eclipseState, compressedToCartesianIdx);
typedef Opm::FluidSystems::BlackOil<double> FluidSystem; typedef Opm::FluidSystems::BlackOil<double> FluidSystem;
@ -566,8 +566,8 @@ BOOST_AUTO_TEST_CASE (DeckWithCapillaryOverlap)
// Create material law manager. // Create material law manager.
std::vector<int> compressedToCartesianIdx std::vector<int> compressedToCartesianIdx
= Opm::compressedToCartesian(grid.number_of_cells, grid.global_cell); = Opm::compressedToCartesian(grid.number_of_cells, grid.global_cell);
auto materialLawManager = std::make_shared<MaterialLawManager>(); MaterialLawManager materialLawManager = MaterialLawManager();
materialLawManager->initFromDeck(deck, eclipseState, compressedToCartesianIdx); materialLawManager.initFromDeck(deck, eclipseState, compressedToCartesianIdx);
typedef Opm::FluidSystems::BlackOil<double> FluidSystem; typedef Opm::FluidSystems::BlackOil<double> FluidSystem;
@ -639,8 +639,8 @@ BOOST_AUTO_TEST_CASE (DeckWithLiveOil)
// Create material law manager. // Create material law manager.
std::vector<int> compressedToCartesianIdx std::vector<int> compressedToCartesianIdx
= Opm::compressedToCartesian(grid.number_of_cells, grid.global_cell); = Opm::compressedToCartesian(grid.number_of_cells, grid.global_cell);
auto materialLawManager = std::make_shared<MaterialLawManager>(); MaterialLawManager materialLawManager = MaterialLawManager();
materialLawManager->initFromDeck(deck, eclipseState, compressedToCartesianIdx); materialLawManager.initFromDeck(deck, eclipseState, compressedToCartesianIdx);
typedef Opm::FluidSystems::BlackOil<double> FluidSystem; typedef Opm::FluidSystems::BlackOil<double> FluidSystem;
@ -727,8 +727,8 @@ BOOST_AUTO_TEST_CASE (DeckWithLiveGas)
// Create material law manager. // Create material law manager.
std::vector<int> compressedToCartesianIdx std::vector<int> compressedToCartesianIdx
= Opm::compressedToCartesian(grid.number_of_cells, grid.global_cell); = Opm::compressedToCartesian(grid.number_of_cells, grid.global_cell);
auto materialLawManager = std::make_shared<MaterialLawManager>(); MaterialLawManager materialLawManager = MaterialLawManager();
materialLawManager->initFromDeck(deck, eclipseState, compressedToCartesianIdx); materialLawManager.initFromDeck(deck, eclipseState, compressedToCartesianIdx);
typedef Opm::FluidSystems::BlackOil<double> FluidSystem; typedef Opm::FluidSystems::BlackOil<double> FluidSystem;
@ -818,8 +818,8 @@ BOOST_AUTO_TEST_CASE (DeckWithRSVDAndRVVD)
// Create material law manager. // Create material law manager.
std::vector<int> compressedToCartesianIdx std::vector<int> compressedToCartesianIdx
= Opm::compressedToCartesian(grid.number_of_cells, grid.global_cell); = Opm::compressedToCartesian(grid.number_of_cells, grid.global_cell);
auto materialLawManager = std::make_shared<MaterialLawManager>(); MaterialLawManager materialLawManager = MaterialLawManager();
materialLawManager->initFromDeck(deck, eclipseState, compressedToCartesianIdx); materialLawManager.initFromDeck(deck, eclipseState, compressedToCartesianIdx);
typedef Opm::FluidSystems::BlackOil<double> FluidSystem; typedef Opm::FluidSystems::BlackOil<double> FluidSystem;
@ -930,11 +930,11 @@ BOOST_AUTO_TEST_CASE (DeckWithSwatinit)
// Create material law manager. // Create material law manager.
std::vector<int> compressedToCartesianIdx std::vector<int> compressedToCartesianIdx
= Opm::compressedToCartesian(grid.number_of_cells, grid.global_cell); = Opm::compressedToCartesian(grid.number_of_cells, grid.global_cell);
auto materialLawManager = std::make_shared<MaterialLawManager>(); MaterialLawManager materialLawManager = MaterialLawManager();
materialLawManager->initFromDeck(deck, eclipseState, compressedToCartesianIdx); materialLawManager.initFromDeck(deck, eclipseState, compressedToCartesianIdx);
auto materialLawManagerScaled = std::make_shared<MaterialLawManager>(); MaterialLawManager materialLawManagerScaled = MaterialLawManager();
materialLawManagerScaled->initFromDeck(deck, eclipseState, compressedToCartesianIdx); materialLawManagerScaled.initFromDeck(deck, eclipseState, compressedToCartesianIdx);
// reference saturations // reference saturations
const std::vector<double> s[3]{ const std::vector<double> s[3]{
@ -981,7 +981,7 @@ BOOST_AUTO_TEST_CASE (DeckWithSwatinit)
fluidState.setSaturation(FluidSystem::waterPhaseIdx, sw); fluidState.setSaturation(FluidSystem::waterPhaseIdx, sw);
fluidState.setSaturation(FluidSystem::oilPhaseIdx, so); fluidState.setSaturation(FluidSystem::oilPhaseIdx, so);
fluidState.setSaturation(FluidSystem::gasPhaseIdx, sg); fluidState.setSaturation(FluidSystem::gasPhaseIdx, sg);
const auto& matParams = materialLawManager->materialLawParams(c); const auto& matParams = materialLawManager.materialLawParams(c);
MaterialLaw::capillaryPressures(pc, matParams, fluidState); MaterialLaw::capillaryPressures(pc, matParams, fluidState);
pc_original[3*c + 0] = pc[FluidSystem::oilPhaseIdx] - pc[FluidSystem::waterPhaseIdx]; pc_original[3*c + 0] = pc[FluidSystem::oilPhaseIdx] - pc[FluidSystem::waterPhaseIdx];
pc_original[3*c + 1] = 0.0; pc_original[3*c + 1] = 0.0;
@ -1022,7 +1022,7 @@ BOOST_AUTO_TEST_CASE (DeckWithSwatinit)
fluidState.setSaturation(FluidSystem::waterPhaseIdx, sw); fluidState.setSaturation(FluidSystem::waterPhaseIdx, sw);
fluidState.setSaturation(FluidSystem::oilPhaseIdx, so); fluidState.setSaturation(FluidSystem::oilPhaseIdx, so);
fluidState.setSaturation(FluidSystem::gasPhaseIdx, sg); fluidState.setSaturation(FluidSystem::gasPhaseIdx, sg);
const auto& matParams = materialLawManagerScaled->materialLawParams(c); const auto& matParams = materialLawManagerScaled.materialLawParams(c);
MaterialLaw::capillaryPressures(pc, matParams, fluidState); MaterialLaw::capillaryPressures(pc, matParams, fluidState);
pc_scaled[3*c + 0] = pc[FluidSystem::oilPhaseIdx] - pc[FluidSystem::waterPhaseIdx]; pc_scaled[3*c + 0] = pc[FluidSystem::oilPhaseIdx] - pc[FluidSystem::waterPhaseIdx];
pc_scaled[3*c + 1] = 0.0; pc_scaled[3*c + 1] = 0.0;
@ -1039,7 +1039,7 @@ BOOST_AUTO_TEST_CASE (DeckWithSwatinit)
fluidState.setSaturation(FluidSystem::oilPhaseIdx, so); fluidState.setSaturation(FluidSystem::oilPhaseIdx, so);
fluidState.setSaturation(FluidSystem::gasPhaseIdx, sg); fluidState.setSaturation(FluidSystem::gasPhaseIdx, sg);
const auto& matParams = materialLawManager->materialLawParams(c); const auto& matParams = materialLawManager.materialLawParams(c);
MaterialLaw::capillaryPressures(pc, matParams, fluidState); MaterialLaw::capillaryPressures(pc, matParams, fluidState);
pc_unscaled[3*c + 0] = pc[FluidSystem::oilPhaseIdx] - pc[FluidSystem::waterPhaseIdx]; pc_unscaled[3*c + 0] = pc[FluidSystem::oilPhaseIdx] - pc[FluidSystem::waterPhaseIdx];
pc_unscaled[3*c + 1] = 0.0; pc_unscaled[3*c + 1] = 0.0;