equil init: re-indent EquilibrationHelpers.hpp

This commit is contained in:
Andreas Lauser 2018-01-02 12:43:56 +01:00
parent 6f07f38fb1
commit 669d3fcd2a

View File

@ -43,10 +43,10 @@
/*
---- synopsis of EquilibrationHelpers.hpp ----
---- synopsis of EquilibrationHelpers.hpp ----
namespace Opm
{
namespace Opm
{
namespace EQUIL {
namespace Miscibility {
@ -77,26 +77,26 @@ namespace Opm
const int cell,
const double target_pc)
} // namespace Equil
} // namespace Opm
} // namespace Opm
---- end of synopsis of EquilibrationHelpers.hpp ----
---- end of synopsis of EquilibrationHelpers.hpp ----
*/
namespace Ewoms
{
/**
/**
* Types and routines that collectively implement a basic
* ECLIPSE-style equilibration-based initialisation scheme.
*
* This namespace is intentionally nested to avoid name clashes
* with other parts of OPM.
*/
namespace EQUIL {
namespace EQUIL {
typedef Opm::FluidSystems::BlackOil<double> FluidSystemSimple;
typedef Opm::FluidSystems::BlackOil<double> FluidSystemSimple;
// Adjust oil pressure according to gas saturation and cap pressure
typedef Opm::SimpleModularFluidState<double,
// Adjust oil pressure according to gas saturation and cap pressure
typedef Opm::SimpleModularFluidState<double,
/*numPhases=*/3,
/*numComponents=*/3,
FluidSystemSimple,
@ -109,18 +109,18 @@ namespace Ewoms
/*storeViscosity=*/false,
/*storeEnthalpy=*/false> SatOnlyFluidState;
/**
/**
* Types and routines relating to phase mixing in
* equilibration calculations.
*/
namespace Miscibility {
namespace Miscibility {
/**
/**
* Base class for phase mixing functions.
*/
class RsFunction
{
public:
class RsFunction
{
public:
/**
* Function call operator.
*
@ -140,14 +140,14 @@ namespace Ewoms
const double press,
const double temp,
const double sat = 0.0) const = 0;
};
};
/**
/**
* Type that implements "no phase mixing" policy.
*/
class NoMixing : public RsFunction {
public:
class NoMixing : public RsFunction {
public:
/**
* Function call.
*
@ -172,17 +172,17 @@ namespace Ewoms
{
return 0.0;
}
};
};
/**
/**
* Type that implements "dissolved gas-oil ratio"
* tabulated as a function of depth policy. Data
* typically taken from keyword 'RSVD'.
*/
template <class FluidSystem>
class RsVD : public RsFunction {
public:
template <class FluidSystem>
class RsVD : public RsFunction {
public:
/**
* Constructor.
*
@ -227,7 +227,7 @@ namespace Ewoms
}
}
private:
private:
const int pvtRegionIdx_;
std::vector<double> depth_; /**< Depth nodes */
std::vector<double> rs_; /**< Dissolved gas-oil ratio */
@ -236,17 +236,17 @@ namespace Ewoms
{
return FluidSystem::oilPvt().saturatedGasDissolutionFactor(pvtRegionIdx_, temp, press);
}
};
};
/**
/**
* Type that implements "vaporized oil-gas ratio"
* tabulated as a function of depth policy. Data
* typically taken from keyword 'RVVD'.
*/
template <class FluidSystem>
class RvVD : public RsFunction {
public:
template <class FluidSystem>
class RvVD : public RsFunction {
public:
/**
* Constructor.
*
@ -291,7 +291,7 @@ namespace Ewoms
}
}
private:
private:
const int pvtRegionIdx_;
std::vector<double> depth_; /**< Depth nodes */
std::vector<double> rv_; /**< Vaporized oil-gas ratio */
@ -300,10 +300,10 @@ namespace Ewoms
{
return FluidSystem::gasPvt().saturatedOilVaporizationFactor(pvtRegionIdx_, temp, press);
}
};
};
/**
/**
* Class that implements "dissolved gas-oil ratio" (Rs)
* as function of depth and pressure as follows:
*
@ -317,9 +317,9 @@ namespace Ewoms
* This should yield Rs-values that are constant below the
* contact, and decreasing above the contact.
*/
template <class FluidSystem>
class RsSatAtContact : public RsFunction {
public:
template <class FluidSystem>
class RsSatAtContact : public RsFunction {
public:
/**
* Constructor.
*
@ -361,7 +361,7 @@ namespace Ewoms
}
}
private:
private:
const int pvtRegionIdx_;
double rs_sat_contact_;
@ -369,10 +369,10 @@ namespace Ewoms
{
return FluidSystem::oilPvt().saturatedGasDissolutionFactor(pvtRegionIdx_, temp, press);
}
};
};
/**
/**
* Class that implements "vaporized oil-gas ratio" (Rv)
* as function of depth and pressure as follows:
*
@ -386,9 +386,9 @@ namespace Ewoms
* This should yield Rv-values that are constant below the
* contact, and decreasing above the contact.
*/
template <class FluidSystem>
class RvSatAtContact : public RsFunction {
public:
template <class FluidSystem>
class RvSatAtContact : public RsFunction {
public:
/**
* Constructor.
*
@ -430,7 +430,7 @@ namespace Ewoms
}
}
private:
private:
const int pvtRegionIdx_;
double rv_sat_contact_;
@ -438,11 +438,11 @@ namespace Ewoms
{
return FluidSystem::gasPvt().saturatedOilVaporizationFactor(pvtRegionIdx_, temp, press);;
}
};
};
} // namespace Miscibility
} // namespace Miscibility
/**
/**
* Aggregate information base of an equilibration region.
*
* Provides inquiry methods for retrieving depths of contacs
@ -461,8 +461,8 @@ namespace Ewoms
* that calculates the phase densities of all phases in @c
* svol at fluid pressure @c press.
*/
class EquilReg {
public:
class EquilReg {
public:
/**
* Constructor.
*
@ -547,21 +547,21 @@ namespace Ewoms
int pvtIdx() const { return this->pvtIdx_; }
private:
private:
Opm::EquilRecord rec_; /**< Equilibration data */
std::shared_ptr<Miscibility::RsFunction> rs_; /**< RS calculator */
std::shared_ptr<Miscibility::RsFunction> rv_; /**< RV calculator */
const int pvtIdx_;
};
};
/// Functor for inverting capillary pressure function.
/// Function represented is
/// f(s) = pc(s) - target_pc
template <class FluidSystem, class MaterialLaw, class MaterialLawManager>
struct PcEq
{
/// Functor for inverting capillary pressure function.
/// Function represented is
/// f(s) = pc(s) - target_pc
template <class FluidSystem, class MaterialLaw, class MaterialLawManager>
struct PcEq
{
PcEq(const MaterialLawManager& materialLawManager,
const int phase,
const int cell,
@ -589,15 +589,15 @@ namespace Ewoms
double pcPhase = pc[FluidSystem::oilPhaseIdx] + sign * pc[phase_];
return pcPhase - target_pc_;
}
private:
private:
const MaterialLawManager& materialLawManager_;
const int phase_;
const int cell_;
const double target_pc_;
};
};
template <class FluidSystem, class MaterialLawManager>
double minSaturations(const MaterialLawManager& materialLawManager, const int phase, const int cell) {
template <class FluidSystem, class MaterialLawManager>
double minSaturations(const MaterialLawManager& materialLawManager, const int phase, const int cell) {
const auto& scaledDrainageInfo =
materialLawManager.oilWaterScaledEpsInfoDrainage(cell);
@ -621,10 +621,10 @@ namespace Ewoms
default: OPM_THROW(std::runtime_error, "Unknown phaseIdx .");
}
return -1.0;
}
}
template <class FluidSystem, class MaterialLawManager>
double maxSaturations(const MaterialLawManager& materialLawManager, const int phase, const int cell) {
template <class FluidSystem, class MaterialLawManager>
double maxSaturations(const MaterialLawManager& materialLawManager, const int phase, const int cell) {
const auto& scaledDrainageInfo =
materialLawManager.oilWaterScaledEpsInfoDrainage(cell);
@ -648,18 +648,18 @@ namespace Ewoms
default: OPM_THROW(std::runtime_error, "Unknown phaseIdx .");
}
return -1.0;
}
}
/// Compute saturation of some phase corresponding to a given
/// capillary pressure.
template <class FluidSystem, class MaterialLaw, class MaterialLawManager >
inline double satFromPc(const MaterialLawManager& materialLawManager,
/// Compute saturation of some phase corresponding to a given
/// capillary pressure.
template <class FluidSystem, class MaterialLaw, class MaterialLawManager >
inline double satFromPc(const MaterialLawManager& materialLawManager,
const int phase,
const int cell,
const double target_pc,
const bool increasing = false)
{
{
// Find minimum and maximum saturations.
const double s0 = increasing ? maxSaturations<FluidSystem>(materialLawManager, phase, cell) : minSaturations<FluidSystem>(materialLawManager, phase, cell);
const double s1 = increasing ? minSaturations<FluidSystem>(materialLawManager, phase, cell) : maxSaturations<FluidSystem>(materialLawManager, phase, cell);
@ -681,15 +681,15 @@ namespace Ewoms
const double sol = ScalarSolver::solve(f, std::min(s0, s1), std::max(s0, s1), max_iter, tol, iter_used);
return sol;
}
}
}
/// Functor for inverting a sum of capillary pressure functions.
/// Function represented is
/// f(s) = pc1(s) + pc2(1 - s) - target_pc
template <class FluidSystem, class MaterialLaw, class MaterialLawManager>
struct PcEqSum
{
/// Functor for inverting a sum of capillary pressure functions.
/// Function represented is
/// f(s) = pc1(s) + pc2(1 - s) - target_pc
template <class FluidSystem, class MaterialLaw, class MaterialLawManager>
struct PcEqSum
{
PcEqSum(const MaterialLawManager& materialLawManager,
const int phase1,
const int phase2,
@ -722,27 +722,27 @@ namespace Ewoms
double pc2 = pc[FluidSystem::oilPhaseIdx] + sign2 * pc[phase2_];
return pc1 + pc2 - target_pc_;
}
private:
private:
const MaterialLawManager& materialLawManager_;
const int phase1_;
const int phase2_;
const int cell_;
const double target_pc_;
};
};
/// Compute saturation of some phase corresponding to a given
/// capillary pressure, where the capillary pressure function
/// is given as a sum of two other functions.
template <class FluidSystem, class MaterialLaw, class MaterialLawManager>
inline double satFromSumOfPcs(const MaterialLawManager& materialLawManager,
/// Compute saturation of some phase corresponding to a given
/// capillary pressure, where the capillary pressure function
/// is given as a sum of two other functions.
template <class FluidSystem, class MaterialLaw, class MaterialLawManager>
inline double satFromSumOfPcs(const MaterialLawManager& materialLawManager,
const int phase1,
const int phase2,
const int cell,
const double target_pc)
{
{
// Find minimum and maximum saturations.
const double smin = minSaturations<FluidSystem>(materialLawManager, phase1, cell);
const double smax = maxSaturations<FluidSystem>(materialLawManager, phase1, cell);
@ -763,17 +763,17 @@ namespace Ewoms
const double sol = ScalarSolver::solve(f, smin, smax, max_iter, tol, iter_used);
return sol;
}
}
}
/// Compute saturation from depth. Used for constant capillary pressure function
template <class FluidSystem, class MaterialLaw, class MaterialLawManager>
inline double satFromDepth(const MaterialLawManager& materialLawManager,
/// Compute saturation from depth. Used for constant capillary pressure function
template <class FluidSystem, class MaterialLaw, class MaterialLawManager>
inline double satFromDepth(const MaterialLawManager& materialLawManager,
const double cellDepth,
const double contactDepth,
const int phase,
const int cell,
const bool increasing = false)
{
{
const double s0 = increasing ? maxSaturations<FluidSystem>(materialLawManager, phase, cell) : minSaturations<FluidSystem>(materialLawManager, phase, cell);
const double s1 = increasing ? minSaturations<FluidSystem>(materialLawManager, phase, cell) : maxSaturations<FluidSystem>(materialLawManager, phase, cell);
@ -783,22 +783,22 @@ namespace Ewoms
return s1;
}
}
}
/// Return true if capillary pressure function is constant
template <class FluidSystem, class MaterialLaw, class MaterialLawManager>
inline bool isConstPc(const MaterialLawManager& materialLawManager,
/// Return true if capillary pressure function is constant
template <class FluidSystem, class MaterialLaw, class MaterialLawManager>
inline bool isConstPc(const MaterialLawManager& materialLawManager,
const int phase,
const int cell)
{
{
// Create the equation f(s) = pc(s);
const PcEq<FluidSystem, MaterialLaw, MaterialLawManager> f(materialLawManager, phase, cell, 0);
const double f0 = f(minSaturations<FluidSystem>(materialLawManager, phase, cell));
const double f1 = f(maxSaturations<FluidSystem>(materialLawManager, phase, cell));
return std::abs(f0 - f1) < std::numeric_limits<double>::epsilon();
}
}
} // namespace Equil
} // namespace Equil
} // namespace Ewoms
#endif // EWOMS_EQUILIBRATIONHELPERS_HEADER_INCLUDED