equil init: formating fixes to make it more consistent with the rest of ewoms

in particular, this removes excessive whitespace usage.
This commit is contained in:
Andreas Lauser 2018-01-02 12:43:56 +01:00
parent 79856b3b0a
commit 69b1a5ca5a
3 changed files with 258 additions and 259 deletions

View File

@ -62,13 +62,13 @@
struct PcEq;
template <class FluidSystem, class MaterialLaw, class MaterialLawManager>
inline double satFromPc(const MaterialLawManager& materialLawManager,
double satFromPc(const MaterialLawManager& materialLawManager,
const int phase,
const int cell,
const double targetPc,
const bool increasing = false)
template <class FluidSystem, class MaterialLaw, class MaterialLawManager>
inline double satFromSumOfPcs(const MaterialLawManager& materialLawManager,
double satFromSumOfPcs(const MaterialLawManager& materialLawManager,
const int phase1,
const int phase2,
const int cell,
@ -78,8 +78,7 @@
---- end of synopsis of EquilibrationHelpers.hpp ----
*/
namespace Ewoms
{
namespace Ewoms {
/**
* Types and routines that collectively implement a basic
* ECLIPSE-style equilibration-based initialisation scheme.
@ -143,7 +142,8 @@ public:
/**
* Type that implements "no phase mixing" policy.
*/
class NoMixing : public RsFunction {
class NoMixing : public RsFunction
{
public:
/**
* Function call.
@ -178,7 +178,8 @@ public:
* typically taken from keyword 'RSVD'.
*/
template <class FluidSystem>
class RsVD : public RsFunction {
class RsVD : public RsFunction
{
public:
/**
* Constructor.
@ -192,8 +193,7 @@ public:
const std::vector<double>& rs)
: pvtRegionIdx_(pvtRegionIdx)
, rsVsDepth_(depth, rs)
{
}
{}
/**
* Function call.
@ -210,15 +210,15 @@ public:
* \return Dissolved gas-oil ratio (RS) at depth @c
* depth and pressure @c press.
*/
double
operator()(const double depth,
double operator()(const double depth,
const double press,
const double temp,
const double satGas = 0.0) const
{
if (satGas > 0.0) {
return satRs(press, temp);
} else {
}
else {
if (rsVsDepth_.xMin() > depth)
return rsVsDepth_.valueAt(0);
else if (rsVsDepth_.xMax() < depth)
@ -246,7 +246,8 @@ private:
* typically taken from keyword 'RVVD'.
*/
template <class FluidSystem>
class RvVD : public RsFunction {
class RvVD : public RsFunction
{
public:
/**
* Constructor.
@ -260,8 +261,7 @@ public:
const std::vector<double>& rv)
: pvtRegionIdx_(pvtRegionIdx)
, rvVsDepth_(depth, rv)
{
}
{}
/**
* Function call.
@ -278,15 +278,15 @@ public:
* \return Vaporized oil-gas ratio (RV) at depth @c
* depth and pressure @c press.
*/
double
operator()(const double depth,
double operator()(const double depth,
const double press,
const double temp,
const double satOil = 0.0) const
{
if (std::abs(satOil) > 1e-16) {
return satRv(press, temp);
} else {
}
else {
if (rvVsDepth_.xMin() > depth)
return rvVsDepth_.valueAt(0);
else if (rvVsDepth_.xMax() < depth)
@ -323,7 +323,8 @@ private:
* contact, and decreasing above the contact.
*/
template <class FluidSystem>
class RsSatAtContact : public RsFunction {
class RsSatAtContact : public RsFunction
{
public:
/**
* Constructor.
@ -353,15 +354,15 @@ public:
* \return Dissolved gas-oil ratio (RS) at depth @c
* depth and pressure @c press.
*/
double
operator()(const double /* depth */,
double operator()(const double /* depth */,
const double press,
const double temp,
const double satGas = 0.0) const
{
if (satGas > 0.0) {
return satRs(press, temp);
} else {
}
else {
return std::min(satRs(press, temp), rsSatContact_);
}
}
@ -392,7 +393,8 @@ private:
* contact, and decreasing above the contact.
*/
template <class FluidSystem>
class RvSatAtContact : public RsFunction {
class RvSatAtContact : public RsFunction
{
public:
/**
* Constructor.
@ -422,15 +424,15 @@ public:
* \return Dissolved oil-gas ratio (RV) at depth @c
* depth and pressure @c press.
*/
double
operator()(const double /*depth*/,
double operator()(const double /*depth*/,
const double press,
const double temp,
const double satOil = 0.0) const
{
if (satOil > 0.0) {
return satRv(press, temp);
} else {
}
else {
return std::min(satRv(press, temp), rvSatContact_);
}
}
@ -466,7 +468,8 @@ private:
* that calculates the phase densities of all phases in @c
* svol at fluid pressure @c press.
*/
class EquilReg {
class EquilReg
{
public:
/**
* Constructor.
@ -484,8 +487,7 @@ public:
, rs_ (rs)
, rv_ (rv)
, pvtIdx_ (pvtIdx)
{
}
{}
/**
* Type of dissolved gas-oil ratio calculator.
@ -575,9 +577,8 @@ struct PcEq
phase_(phase),
cell_(cell),
targetPc_(targetPc)
{
{}
}
double operator()(double s) const
{
const auto& matParams = materialLawManager_.materialLawParams(cell_);
@ -602,53 +603,47 @@ private:
};
template <class FluidSystem, class MaterialLawManager>
double minSaturations(const MaterialLawManager& materialLawManager, const int phase, const int cell) {
double minSaturations(const MaterialLawManager& materialLawManager, const int phase, const int cell)
{
const auto& scaledDrainageInfo =
materialLawManager.oilWaterScaledEpsInfoDrainage(cell);
// Find minimum and maximum saturations.
switch(phase) {
case FluidSystem::waterPhaseIdx:
{
return scaledDrainageInfo.Swl;
}
case FluidSystem::gasPhaseIdx:
{
return scaledDrainageInfo.Sgl;
}
case FluidSystem::oilPhaseIdx:
{
OPM_THROW(std::runtime_error, "Min saturation not implemented for oil phase.");
break;
}
default: OPM_THROW(std::runtime_error, "Unknown phaseIdx .");
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) {
double maxSaturations(const MaterialLawManager& materialLawManager, const int phase, const int cell)
{
const auto& scaledDrainageInfo =
materialLawManager.oilWaterScaledEpsInfoDrainage(cell);
// Find minimum and maximum saturations.
switch(phase) {
case FluidSystem::waterPhaseIdx:
{
return scaledDrainageInfo.Swu;
break;
}
case FluidSystem::gasPhaseIdx:
{
return scaledDrainageInfo.Sgu;
break;
}
case FluidSystem::oilPhaseIdx:
{
OPM_THROW(std::runtime_error, "Max saturation not implemented for oil phase.");
break;
}
default: OPM_THROW(std::runtime_error, "Unknown phaseIdx .");
default:
OPM_THROW(std::runtime_error, "Unknown phaseIdx .");
}
return -1.0;
}
@ -657,7 +652,7 @@ double maxSaturations(const MaterialLawManager& materialLawManager, const int ph
/// Compute saturation of some phase corresponding to a given
/// capillary pressure.
template <class FluidSystem, class MaterialLaw, class MaterialLawManager>
inline double satFromPc(const MaterialLawManager& materialLawManager,
double satFromPc(const MaterialLawManager& materialLawManager,
const int phase,
const int cell,
const double targetPc,
@ -730,8 +725,8 @@ struct PcEqSum
phase2_(phase2),
cell_(cell),
targetPc_(targetPc)
{
}
{}
double operator()(double s) const
{
const auto& matParams = materialLawManager_.materialLawParams(cell_);
@ -767,7 +762,7 @@ private:
/// 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,
double satFromSumOfPcs(const MaterialLawManager& materialLawManager,
const int phase1,
const int phase2,
const int cell,
@ -824,7 +819,7 @@ inline double satFromSumOfPcs(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,
double satFromDepth(const MaterialLawManager& materialLawManager,
const double cellDepth,
const double contactDepth,
const int phase,
@ -836,7 +831,8 @@ inline double satFromDepth(const MaterialLawManager& materialLawManager,
if (cellDepth < contactDepth) {
return s0;
} else {
}
else {
return s1;
}
@ -844,7 +840,7 @@ inline double satFromDepth(const MaterialLawManager& materialLawManager,
/// Return true if capillary pressure function is constant
template <class FluidSystem, class MaterialLaw, class MaterialLawManager>
inline bool isConstPc(const MaterialLawManager& materialLawManager,
bool isConstPc(const MaterialLawManager& materialLawManager,
const int phase,
const int cell)
{

View File

@ -26,8 +26,7 @@
#include <unordered_map>
#include <vector>
namespace Ewoms
{
namespace Ewoms {
/**
* Forward and reverse mappings between cells and
@ -41,7 +40,8 @@ namespace Ewoms
* 'const_iterator'.
*/
template <class Region = std::vector<int>>
class RegionMapping {
class RegionMapping
{
public:
/**
* Constructor.
@ -80,7 +80,8 @@ public:
typedef CellIter iterator;
typedef CellIter const_iterator;
Range() {};
Range()
{};
Range(const CellIter& beg, const CellIter& en)
: begin_(beg)
@ -116,8 +117,8 @@ public:
* \param[in] c Active cell
* \return Region to which @c c belongs.
*/
RegionId
region(const CellId c) const { return reg_[c]; }
RegionId region(const CellId c) const
{ return reg_[c]; }
const std::vector<RegionId>&
activeRegions() const
@ -133,8 +134,8 @@ public:
* \return Range of active cells in region @c r. Empty if @c r is
* not an active region.
*/
Range
cells(const RegionId r) const {
Range cells(const RegionId r) const
{
const auto id = rev_.binid.find(r);
if (id == rev_.binid.end()) {

View File

@ -139,7 +139,8 @@ private:
namespace PhasePressODE {
template <class FluidSystem>
class Water {
class Water
{
public:
Water(const double temp,
const int pvtRegionIdx,
@ -147,8 +148,7 @@ public:
: temp_(temp)
, pvtRegionIdx_(pvtRegionIdx)
, g_(normGrav)
{
}
{}
double
operator()(const double /* depth */,
@ -172,7 +172,8 @@ private:
};
template <class FluidSystem, class RS>
class Oil {
class Oil
{
public:
Oil(const double temp,
const RS& rs,
@ -182,8 +183,7 @@ public:
, rs_(rs)
, pvtRegionIdx_(pvtRegionIdx)
, g_(normGrav)
{
}
{}
double
operator()(const double depth,
@ -206,7 +206,8 @@ private:
double bOil = 0.0;
if (!FluidSystem::enableDissolvedGas() || rs >= FluidSystem::oilPvt().saturatedGasDissolutionFactor(pvtRegionIdx_, temp_, press)) {
bOil = FluidSystem::oilPvt().saturatedInverseFormationVolumeFactor(pvtRegionIdx_, temp_, press);
} else {
}
else {
bOil = FluidSystem::oilPvt().inverseFormationVolumeFactor(pvtRegionIdx_, temp_, press, rs);
}
double rho = bOil * FluidSystem::referenceDensity(FluidSystem::oilPhaseIdx, pvtRegionIdx_);
@ -219,7 +220,8 @@ private:
};
template <class FluidSystem, class RV>
class Gas {
class Gas
{
public:
Gas(const double temp,
const RV& rv,
@ -229,8 +231,7 @@ public:
, rv_(rv)
, pvtRegionIdx_(pvtRegionIdx)
, g_(normGrav)
{
}
{}
double
operator()(const double depth,
@ -253,7 +254,8 @@ private:
double bGas = 0.0;
if (!FluidSystem::enableVaporizedOil() || rv >= FluidSystem::gasPvt().saturatedOilVaporizationFactor(pvtRegionIdx_, temp_, press)) {
bGas = FluidSystem::gasPvt().saturatedInverseFormationVolumeFactor(pvtRegionIdx_, temp_, press);
} else {
}
else {
bGas = FluidSystem::gasPvt().inverseFormationVolumeFactor(pvtRegionIdx_, temp_, press, rv);
}
double rho = bGas * FluidSystem::referenceDensity(FluidSystem::gasPhaseIdx, pvtRegionIdx_);
@ -271,8 +273,7 @@ namespace PhasePressure {
template <class Grid,
class PressFunction,
class CellRange>
void
assign(const Grid& grid ,
void assign(const Grid& grid,
const std::array<PressFunction, 2>& f ,
const double split,
const CellRange& cells,
@ -297,8 +298,7 @@ template <class FluidSystem,
class Grid,
class Region,
class CellRange>
void
water(const Grid& grid ,
void water(const Grid& grid,
const Region& reg,
const std::array<double,2>& span ,
const double grav,
@ -317,7 +317,8 @@ water(const Grid& grid ,
if (reg.datum() > reg.zwoc()) {//Datum in water zone
z0 = reg.datum();
p0 = reg.pressure();
} else {
}
else {
z0 = reg.zwoc();
p0 = poWoc - reg.pcowWoc(); // Water pressure at contact
}
@ -346,8 +347,7 @@ template <class FluidSystem,
class Grid,
class Region,
class CellRange>
void
oil(const Grid& grid ,
void oil(const Grid& grid,
const Region& reg,
const std::array<double,2>& span ,
const double grav,
@ -368,10 +368,12 @@ oil(const Grid& grid ,
if (reg.datum() > reg.zwoc()) {//Datum in water zone, poWoc given
z0 = reg.zwoc();
p0 = poWoc;
} else if (reg.datum() < reg.zgoc()) {//Datum in gas zone, poGoc given
}
else if (reg.datum() < reg.zgoc()) {//Datum in gas zone, poGoc given
z0 = reg.zgoc();
p0 = poGoc;
} else { //Datum in oil zone
}
else { //Datum in oil zone
z0 = reg.datum();
p0 = reg.pressure();
}
@ -405,8 +407,7 @@ template <class FluidSystem,
class Grid,
class Region,
class CellRange>
void
gas(const Grid& grid ,
void gas(const Grid& grid,
const Region& reg,
const std::array<double,2>& span ,
const double grav,
@ -426,7 +427,8 @@ gas(const Grid& grid ,
if (reg.datum() < reg.zgoc()) {//Datum in gas zone
z0 = reg.datum();
p0 = reg.pressure();
} else {
}
else {
z0 = reg.zgoc();
p0 = poGoc + reg.pcgoGoc(); // Gas pressure at contact
}
@ -456,8 +458,7 @@ template <class FluidSystem,
class Grid,
class Region,
class CellRange>
void
equilibrateOWG(const Grid& grid,
void equilibrateOWG(const Grid& grid,
const Region& reg,
const double grav,
const std::array<double,2>& span,
@ -489,7 +490,8 @@ equilibrateOWG(const Grid& grid,
PhasePressure::gas<FluidSystem>(grid, reg, span, grav, poGoc,
cells, press[gaspos]);
}
} else if (reg.datum() < reg.zgoc()) { // Datum in gas zone
}
else if (reg.datum() < reg.zgoc()) { // Datum in gas zone
double poWoc = -1;
double poGoc = -1;
@ -507,7 +509,8 @@ equilibrateOWG(const Grid& grid,
PhasePressure::water<FluidSystem>(grid, reg, span, grav, poWoc,
cells, press[waterpos]);
}
} else { // Datum in oil zone
}
else { // Datum in oil zone
double poWoc = -1;
double poGoc = -1;
@ -743,7 +746,8 @@ phaseSaturations(const Grid& grid,
if (swatInit.empty()) { // Invert Pc to find sw
sw = satFromPc<FluidSystem, MaterialLaw, MaterialLawManager>(materialLawManager, waterpos, cell, pcov);
phaseSaturations[waterpos][localIndex] = sw;
} else { // Scale Pc to reflect imposed sw
}
else { // Scale Pc to reflect imposed sw
sw = swatInit[cell];
sw = materialLawManager.applySwatinit(cell, pcov, sw);
phaseSaturations[waterpos][localIndex] = sw;
@ -820,7 +824,8 @@ phaseSaturations(const Grid& grid,
MaterialLaw::capillaryPressures(pC, matParams, fluidState);
double pcWat = pC[FluidSystem::oilPhaseIdx] - pC[FluidSystem::waterPhaseIdx];
phasePressures[oilpos][localIndex] = phasePressures[waterpos][localIndex] + pcWat;
} else if (gas && sg > scaledDrainageInfo.Sgu-thresholdSat) {
}
else if (gas && sg > scaledDrainageInfo.Sgu-thresholdSat) {
fluidState.setSaturation(FluidSystem::gasPhaseIdx, scaledDrainageInfo.Sgu);
MaterialLaw::capillaryPressures(pC, matParams, fluidState);
double pcGas = pC[FluidSystem::oilPhaseIdx] + pC[FluidSystem::gasPhaseIdx];
@ -879,8 +884,7 @@ std::vector<double> computeRs(const Grid& grid,
}
namespace DeckDependent {
inline
std::vector<Opm::EquilRecord>
inline std::vector<Opm::EquilRecord>
getEquil(const Opm::EclipseState& state)
{
const auto& init = state.getInitConfig();
@ -894,7 +898,6 @@ getEquil(const Opm::EclipseState& state)
}
template<class Grid>
inline
std::vector<int>
equilnum(const Opm::EclipseState& eclipseState,
const Grid& grid)
@ -933,8 +936,7 @@ public:
const Opm::EclipseState& eclipseState,
const Grid& grid,
const double grav = Opm::unit::gravity,
const bool applySwatInit = true
)
const bool applySwatInit = true)
: pp_(FluidSystem::numPhases,
std::vector<double>(grid.size(/*codim=*/0))),
sat_(FluidSystem::numPhases,
@ -968,8 +970,7 @@ public:
if (FluidSystem::enableDissolvedGas()) {
const Opm::TableContainer& rsvdTables = tables.getRsvdTables();
for (size_t i = 0; i < rec.size(); ++i) {
if (eqlmap.cells(i).empty())
{
if (eqlmap.cells(i).empty()) {
rsFunc_.push_back(std::shared_ptr<Miscibility::RsVD<FluidSystem>>());
continue;
}
@ -983,7 +984,8 @@ public:
std::vector<double> rsColumn = rsvdTable.getColumn("RS").vectorCopy();
rsFunc_.push_back(std::make_shared<Miscibility::RsVD<FluidSystem>>(pvtIdx,
depthColumn, rsColumn));
} else {
}
else {
if (rec[i].gasOilContactDepth() != rec[i].datumDepth()) {
OPM_THROW(std::runtime_error,
"Cannot initialise: when no explicit RSVD table is given, \n"
@ -995,7 +997,8 @@ public:
rsFunc_.push_back(std::make_shared<Miscibility::RsSatAtContact<FluidSystem>>(pvtIdx, pContact, TContact));
}
}
} else {
}
else {
for (size_t i = 0; i < rec.size(); ++i) {
rsFunc_.push_back(std::make_shared<Miscibility::NoMixing>());
}
@ -1005,8 +1008,7 @@ public:
if (FluidSystem::enableVaporizedOil()) {
const Opm::TableContainer& rvvdTables = tables.getRvvdTables();
for (size_t i = 0; i < rec.size(); ++i) {
if (eqlmap.cells(i).empty())
{
if (eqlmap.cells(i).empty()) {
rvFunc_.push_back(std::shared_ptr<Miscibility::RvVD<FluidSystem>>());
continue;
}
@ -1022,7 +1024,8 @@ public:
rvFunc_.push_back(std::make_shared<Miscibility::RvVD<FluidSystem>>(pvtIdx,
depthColumn, rvColumn));
} else {
}
else {
if (rec[i].gasOilContactDepth() != rec[i].datumDepth()) {
OPM_THROW(std::runtime_error,
"Cannot initialise: when no explicit RVVD table is given, \n"
@ -1034,7 +1037,8 @@ public:
rvFunc_.push_back(std::make_shared<Miscibility::RvSatAtContact<FluidSystem>>(pvtIdx,pContact, TContact));
}
}
} else {
}
else {
for (size_t i = 0; i < rec.size(); ++i) {
rvFunc_.push_back(std::make_shared<Miscibility::NoMixing>());
}
@ -1094,8 +1098,7 @@ private:
}
template <class RMap, class MaterialLawManager>
void
calcPressSatRsRv(const RMap& reg ,
void calcPressSatRsRv(const RMap& reg,
const std::vector< Opm::EquilRecord >& rec,
MaterialLawManager& materialLawManager,
const Grid& grid,
@ -1103,8 +1106,7 @@ private:
{
for (const auto& r : reg.activeRegions()) {
const auto& cells = reg.cells(r);
if (cells.empty())
{
if (cells.empty()) {
Opm::OpmLog::warning("Equilibration region " + std::to_string(r + 1)
+ " has no active cells");
continue;