Cleaning the initialization code

-remove whitespaces
-fix documentation
This commit is contained in:
Tor Harald Sandve 2017-11-21 12:27:09 +01:00 committed by Andreas Lauser
parent 2ce881e2e7
commit d27c43bf61
3 changed files with 64 additions and 94 deletions

View File

@ -41,36 +41,33 @@ namespace Opm
{ {
namespace EQUIL { namespace EQUIL {
template <class Props>
class DensityCalculator;
template <>
class DensityCalculator< BlackoilPropertiesInterface >;
namespace Miscibility { namespace Miscibility {
class RsFunction; class RsFunction;
class NoMixing; class NoMixing;
template <class FluidSystem>
class RsVD; class RsVD;
template <class FluidSystem>
class RsSatAtContact; class RsSatAtContact;
} }
template <class DensCalc>
class EquilReg; class EquilReg;
template <class FluidSystem, class MaterialLaw, class MaterialLawManager>
struct PcEq; struct PcEq;
inline double satFromPc(const BlackoilPropertiesInterface& props, template <class FluidSystem, class MaterialLaw, class 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,
const bool increasing = false); const bool increasing = false)
struct PcEqSum template <class FluidSystem, class MaterialLaw, class MaterialLawManager>
inline double satFromSumOfPcs(const BlackoilPropertiesInterface& props, inline double satFromSumOfPcs(const MaterialLawManager& materialLawManager,
const int phase1, const int phase1,
const int phase2, const int phase2,
const int cell, const int cell,
const double target_pc); const double target_pc)
} // namespace Equil } // namespace Equil
} // namespace Opm } // namespace Opm
@ -183,8 +180,7 @@ namespace Opm
/** /**
* Constructor. * Constructor.
* *
* \param[in] props property object * \param[in] pvtRegionIdx The pvt region index
* \param[in] cell any cell in the pvt region
* \param[in] depth Depth nodes. * \param[in] depth Depth nodes.
* \param[in] rs Dissolved gas-oil ratio at @c depth. * \param[in] rs Dissolved gas-oil ratio at @c depth.
*/ */
@ -195,7 +191,6 @@ namespace Opm
, depth_(depth) , depth_(depth)
, rs_(rs) , rs_(rs)
{ {
} }
/** /**
@ -249,8 +244,7 @@ namespace Opm
/** /**
* Constructor. * Constructor.
* *
* \param[in] props property object * \param[in] pvtRegionIdx The pvt region index
* \param[in] cell any cell in the pvt region
* \param[in] depth Depth nodes. * \param[in] depth Depth nodes.
* \param[in] rv Dissolved gas-oil ratio at @c depth. * \param[in] rv Dissolved gas-oil ratio at @c depth.
*/ */
@ -261,7 +255,6 @@ namespace Opm
, depth_(depth) , depth_(depth)
, rv_(rv) , rv_(rv)
{ {
} }
/** /**
@ -324,8 +317,7 @@ namespace Opm
/** /**
* Constructor. * Constructor.
* *
* \param[in] props property object * \param[in] pvtRegionIdx The pvt region index
* \param[in] cell any cell in the pvt region
* \param[in] p_contact oil pressure at the contact * \param[in] p_contact oil pressure at the contact
* \param[in] T_contact temperature at the contact * \param[in] T_contact temperature at the contact
*/ */
@ -394,8 +386,7 @@ namespace Opm
/** /**
* Constructor. * Constructor.
* *
* \param[in] props property object * \param[in] pvtRegionIdx The pvt region index
* \param[in] cell any cell in the pvt region
* \param[in] p_contact oil pressure at the contact * \param[in] p_contact oil pressure at the contact
* \param[in] T_contact temperature at the contact * \param[in] T_contact temperature at the contact
*/ */
@ -470,10 +461,9 @@ namespace Opm
* Constructor. * Constructor.
* *
* \param[in] rec Equilibration data of current region. * \param[in] rec Equilibration data of current region.
* \param[in] density Density calculator of current region.
* \param[in] rs Calculator of dissolved gas-oil ratio. * \param[in] rs Calculator of dissolved gas-oil ratio.
* \param[in] rv Calculator of vapourised oil-gas ratio. * \param[in] rv Calculator of vapourised oil-gas ratio.
* \param[in] pu Summary of current active phases. * \param[in] pvtRegionIdx The pvt region index
*/ */
EquilReg(const EquilRecord& rec, EquilReg(const EquilRecord& rec,
std::shared_ptr<Miscibility::RsFunction> rs, std::shared_ptr<Miscibility::RsFunction> rs,
@ -483,7 +473,6 @@ namespace Opm
, rs_ (rs) , rs_ (rs)
, rv_ (rv) , rv_ (rv)
, pvtIdx_ (pvtIdx) , pvtIdx_ (pvtIdx)
{ {
} }
@ -547,7 +536,7 @@ namespace Opm
evaporationCalculator() const { return *this->rv_; } evaporationCalculator() const { return *this->rv_; }
/** /**
* Retrieve active fluid phase summary. * Retrieve pvtIdx of the region.
*/ */
const int const int
pvtIdx() const { return this->pvtIdx_; } pvtIdx() const { return this->pvtIdx_; }
@ -581,10 +570,7 @@ namespace Opm
fluidState_.setSaturation(FluidSystem::oilPhaseIdx, 0.0); fluidState_.setSaturation(FluidSystem::oilPhaseIdx, 0.0);
fluidState_.setSaturation(FluidSystem::gasPhaseIdx, 0.0); fluidState_.setSaturation(FluidSystem::gasPhaseIdx, 0.0);
std::fill(pc_, pc_ + FluidSystem::numPhases, 0.0); std::fill(pc_, pc_ + FluidSystem::numPhases, 0.0);
} }
double operator()(double s) const double operator()(double s) const
{ {
const auto& matParams = materialLawManager_.materialLawParams(cell_); const auto& matParams = materialLawManager_.materialLawParams(cell_);
@ -595,7 +581,6 @@ namespace Opm
return pc - target_pc_; return pc - target_pc_;
} }
private: private:
const MaterialLawManager& materialLawManager_; const MaterialLawManager& materialLawManager_;
const int phase_; const int phase_;
const int cell_; const int cell_;
@ -656,11 +641,9 @@ namespace Opm
default: OPM_THROW(std::runtime_error, "Unknown phaseIdx ."); default: OPM_THROW(std::runtime_error, "Unknown phaseIdx .");
} }
return -1.0; return -1.0;
} }
/// 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 >
@ -727,7 +710,6 @@ namespace Opm
double pc1 = pc_[FluidSystem::oilPhaseIdx] + sign1 * pc_[phase1_]; double pc1 = pc_[FluidSystem::oilPhaseIdx] + sign1 * pc_[phase1_];
double sign2 = (phase2_ == FluidSystem::waterPhaseIdx)? -1.0 : 1.0; double sign2 = (phase2_ == FluidSystem::waterPhaseIdx)? -1.0 : 1.0;
double pc2 = pc_[FluidSystem::oilPhaseIdx] + sign2 * pc_[phase2_]; double pc2 = pc_[FluidSystem::oilPhaseIdx] + sign2 * pc_[phase2_];
return pc1 + pc2 - target_pc_; return pc1 + pc2 - target_pc_;
} }
private: private:
@ -746,7 +728,6 @@ namespace Opm
/// Compute saturation of some phase corresponding to a given /// Compute saturation of some phase corresponding to a given
/// capillary pressure, where the capillary pressure function /// capillary pressure, where the capillary pressure function
/// 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(const MaterialLawManager& materialLawManager, inline double satFromSumOfPcs(const MaterialLawManager& materialLawManager,
const int phase1, const int phase1,
@ -809,8 +790,6 @@ namespace Opm
return std::abs(f0 - f1) < std::numeric_limits<double>::epsilon(); return std::abs(f0 - f1) < std::numeric_limits<double>::epsilon();
} }
} // namespace Equil } // namespace Equil
} // namespace Opm } // namespace Opm

View File

@ -2,6 +2,7 @@
Copyright 2014 SINTEF ICT, Applied Mathematics. Copyright 2014 SINTEF ICT, Applied Mathematics.
Copyright 2015 Dr. Blatt - HPC-Simulation-Software & Services Copyright 2015 Dr. Blatt - HPC-Simulation-Software & Services
Copyright 2015 NTNU Copyright 2015 NTNU
Copyright 2017 IRIS
This file is part of the Open Porous Media project (OPM). This file is part of the Open Porous Media project (OPM).
@ -39,12 +40,10 @@
#include <opm/common/OpmLog/OpmLog.hpp> #include <opm/common/OpmLog/OpmLog.hpp>
#include <opm/common/data/SimulationDataContainer.hpp> #include <opm/common/data/SimulationDataContainer.hpp>
#include <opm/material/fluidsystems/BlackOilFluidSystem.hpp> #include <opm/material/fluidsystems/BlackOilFluidSystem.hpp>
#include <opm/material/fluidstates/SimpleModularFluidState.hpp> #include <opm/material/fluidstates/SimpleModularFluidState.hpp>
#include <opm/material/fluidmatrixinteractions/EclMaterialLawManager.hpp> #include <opm/material/fluidmatrixinteractions/EclMaterialLawManager.hpp>
#include <array> #include <array>
#include <cassert> #include <cassert>
#include <utility> #include <utility>
@ -70,7 +69,6 @@ namespace Opm
*/ */
namespace EQUIL { namespace EQUIL {
/** /**
* Compute initial phase pressures by means of equilibration. * Compute initial phase pressures by means of equilibration.
* *
@ -121,6 +119,11 @@ namespace Opm
/** /**
* Compute initial phase saturations by means of equilibration. * Compute initial phase saturations by means of equilibration.
* *
* \tparam FluidSystem The FluidSystem from opm-material
* Must be initialized before used.
*
* \tparam Grid Type of the grid
*
* \tparam Region Type of an equilibration region information * \tparam Region Type of an equilibration region information
* base. Typically an instance of the EquilReg * base. Typically an instance of the EquilReg
* class template. * class template.
@ -132,10 +135,15 @@ namespace Opm
* as well as provide an inner type, * as well as provide an inner type,
* const_iterator, to traverse the range. * const_iterator, to traverse the range.
* *
* \tparam MaterialLawManager The MaterialLawManager from opm-material
*
* \param[in] G Grid.
* \param[in] reg Current equilibration region. * \param[in] reg Current equilibration region.
* \param[in] cells Range that spans the cells of the current * \param[in] cells Range that spans the cells of the current
* equilibration region. * equilibration region.
* \param[in] props Property object, needed for capillary functions. * \param[in] materialLawManager The MaterialLawManager from opm-material
* \param[in] swat_init A vector of initial water saturations.
* The capillary pressure is scaled to fit these values
* \param[in] phase_pressures Phase pressures, one vector for each active phase, * \param[in] phase_pressures Phase pressures, one vector for each active phase,
* of pressure values in each cell in the current * of pressure values in each cell in the current
* equilibration region. * equilibration region.
@ -201,7 +209,6 @@ namespace Opm
const Grid& G ) const Grid& G )
{ {
std::vector<int> eqlnum; std::vector<int> eqlnum;
if (eclipseState.get3DProperties().hasDeckIntGridProperty("EQLNUM")) { if (eclipseState.get3DProperties().hasDeckIntGridProperty("EQLNUM")) {
const int nc = UgGridHelpers::numCells(G); const int nc = UgGridHelpers::numCells(G);
eqlnum.resize(nc); eqlnum.resize(nc);
@ -239,7 +246,6 @@ namespace Opm
rs_(UgGridHelpers::numCells(G)), rs_(UgGridHelpers::numCells(G)),
rv_(UgGridHelpers::numCells(G)) rv_(UgGridHelpers::numCells(G))
{ {
//Check for presence of kw SWATINIT //Check for presence of kw SWATINIT
if (eclipseState.get3DProperties().hasDeckDoubleGridProperty("SWATINIT") && applySwatInit) { if (eclipseState.get3DProperties().hasDeckDoubleGridProperty("SWATINIT") && applySwatInit) {
const std::vector<double>& swat_init_ecl = eclipseState. const std::vector<double>& swat_init_ecl = eclipseState.
@ -252,13 +258,11 @@ namespace Opm
swat_init_[c] = swat_init_ecl[deck_pos]; swat_init_[c] = swat_init_ecl[deck_pos];
} }
} }
// Get the equilibration records. // Get the equilibration records.
const std::vector<EquilRecord> rec = getEquil(eclipseState); const std::vector<EquilRecord> rec = getEquil(eclipseState);
const auto& tables = eclipseState.getTableManager(); const auto& tables = eclipseState.getTableManager();
// Create (inverse) region mapping. // Create (inverse) region mapping.
const RegionMapping<> eqlmap(equilnum(eclipseState, G)); const RegionMapping<> eqlmap(equilnum(eclipseState, G));
setRegionPvtIdx(G, eclipseState, eqlmap); setRegionPvtIdx(G, eclipseState, eqlmap);
// Create Rs functions. // Create Rs functions.
@ -272,7 +276,6 @@ namespace Opm
continue; continue;
} }
const int pvtIdx = regionPvtIdx_[i]; const int pvtIdx = regionPvtIdx_[i];
if (!rec[i].liveOilInitConstantRs()) { if (!rec[i].liveOilInitConstantRs()) {
if (rsvdTables.size() <= 0 ) { if (rsvdTables.size() <= 0 ) {
OPM_THROW(std::runtime_error, "Cannot initialise: RSVD table not available."); OPM_THROW(std::runtime_error, "Cannot initialise: RSVD table not available.");
@ -355,14 +358,10 @@ namespace Opm
const Vec& rv() const { return rv_; } const Vec& rv() const { return rv_; }
private: private:
typedef EquilReg EqReg; typedef EquilReg EqReg;
std::vector< std::shared_ptr<Miscibility::RsFunction> > rs_func_; std::vector< std::shared_ptr<Miscibility::RsFunction> > rs_func_;
std::vector< std::shared_ptr<Miscibility::RsFunction> > rv_func_; std::vector< std::shared_ptr<Miscibility::RsFunction> > rv_func_;
std::vector<int> regionPvtIdx_; std::vector<int> regionPvtIdx_;
PVec pp_; PVec pp_;
PVec sat_; PVec sat_;
Vec rs_; Vec rs_;
@ -410,10 +409,8 @@ namespace Opm
copyFromRegion(pressures[p], cells, pp_[p]); copyFromRegion(pressures[p], cells, pp_[p]);
copyFromRegion(sat[p], cells, sat_[p]); copyFromRegion(sat[p], cells, sat_[p]);
} }
const bool oil = FluidSystem::phaseIsActive(FluidSystem::oilPhaseIdx); const bool oil = FluidSystem::phaseIsActive(FluidSystem::oilPhaseIdx);
const bool gas = FluidSystem::phaseIsActive(FluidSystem::gasPhaseIdx); const bool gas = FluidSystem::phaseIsActive(FluidSystem::gasPhaseIdx);
if (oil && gas) { if (oil && gas) {
const int oilpos = FluidSystem::oilPhaseIdx; const int oilpos = FluidSystem::oilPhaseIdx;
const int gaspos = FluidSystem::gasPhaseIdx; const int gaspos = FluidSystem::gasPhaseIdx;

View File

@ -2,6 +2,7 @@
Copyright 2014 SINTEF ICT, Applied Mathematics. Copyright 2014 SINTEF ICT, Applied Mathematics.
Copyright 2015 Dr. Blatt - HPC-Simulation-Software & Services Copyright 2015 Dr. Blatt - HPC-Simulation-Software & Services
Copyright 2015 NTNU Copyright 2015 NTNU
Copyright 2017 IRIS
This file is part of the Open Porous Media project (OPM). This file is part of the Open Porous Media project (OPM).
@ -35,9 +36,6 @@
namespace Opm namespace Opm
{ {
namespace Details { namespace Details {
template <class RHS> template <class RHS>
class RK4IVP { class RK4IVP {
public: public:
@ -317,7 +315,6 @@ namespace Opm
class Grid, class Grid,
class Region, class Region,
class CellRange> class CellRange>
void void
oil(const Grid& G , oil(const Grid& G ,
const Region& reg , const Region& reg ,
@ -332,7 +329,6 @@ namespace Opm
typedef Oil<FluidSystem, typename Region::CalcDissolution> ODE; typedef Oil<FluidSystem, typename Region::CalcDissolution> ODE;
const double T = 273.15 + 20; // standard temperature for now const double T = 273.15 + 20; // standard temperature for now
ODE drho(T, reg.dissolutionCalculator(), ODE drho(T, reg.dissolutionCalculator(),
reg.pvtIdx(), grav); reg.pvtIdx(), grav);
@ -690,7 +686,6 @@ namespace Opm
sg = 1.0 - sw; sg = 1.0 - sw;
phase_saturations[waterpos][local_index] = sw; phase_saturations[waterpos][local_index] = sw;
phase_saturations[gaspos][local_index] = sg; phase_saturations[gaspos][local_index] = sg;
if ( water ) { if ( water ) {
fluidState.setSaturation(FluidSystem::waterPhaseIdx, sw); fluidState.setSaturation(FluidSystem::waterPhaseIdx, sw);
} }
@ -712,7 +707,6 @@ namespace Opm
double so = 1.0; double so = 1.0;
double pC[FluidSystem::numPhases] = { 0.0, 0.0, 0.0 }; double pC[FluidSystem::numPhases] = { 0.0, 0.0, 0.0 };
if (water) { if (water) {
double swu = scaledDrainageInfo.Swu; double swu = scaledDrainageInfo.Swu;
fluidState.setSaturation(FluidSystem::waterPhaseIdx, swu); fluidState.setSaturation(FluidSystem::waterPhaseIdx, swu);