Loading...
Searching...
No Matches
WDFAC.hpp
/*
Copyright 2023 Equinor.
This file is part of the Open Porous Media project (OPM).
OPM is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OPM is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OPM. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef WDFAC_HPP_HEADER_INCLUDED
#define WDFAC_HPP_HEADER_INCLUDED
#include <stdexcept>
#include <fmt/format.h>
namespace Opm {
class Connection;
class DeckRecord;
class WellConnections;
} // namespace Opm
namespace Opm { namespace RestartIO {
struct RstWell;
}} // namespace Opm::RestartIO
namespace Opm {
class WDFAC
{
public:
struct Correlation
{
double coeff_a{0.0};
double exponent_b{0.0};
double exponent_c{0.0};
static Correlation serializationTestObject();
bool operator==(const Correlation& other) const;
bool operator!=(const Correlation& other) const
{
return ! (*this == other);
}
template <class Serializer>
void serializeOp(Serializer& serializer)
{
serializer(this->coeff_a);
serializer(this->exponent_b);
serializer(this->exponent_c);
}
};
WDFAC() = default;
explicit WDFAC(const RestartIO::RstWell& rst_well);
static WDFAC serializationTestObject();
void updateWDFAC(const DeckRecord& record);
void updateWDFACCOR(const DeckRecord& record);
void updateWDFACType(const WellConnections& connections);
void updateTotalCF(const WellConnections& connections);
template <typename DensityCallback, typename GasViscCallback>
double getDFactor(DensityCallback&& rhoGS,
GasViscCallback&& gas_visc,
const Connection& conn) const
{
switch (this->m_type) {
case WDFacType::NONE:
return 0.0;
case WDFacType::DFACTOR:
return this->scaledWellLevelDFactor(this->m_d, conn);
case WDFacType::DAKEMODEL:
return this->dakeModelDFactor(rhoGS(), gas_visc(), conn);
case WDFacType::CON_DFACTOR:
return this->connectionLevelDFactor(conn);
}
throw std::runtime_error {
fmt::format("Unknown D-Factor model '{}'",
static_cast<int>(this->m_type))
};
}
const Correlation& getDFactorCorrelationCoefficients() const
{
return this->m_corr;
}
bool useDFactor() const;
bool operator==(const WDFAC& other) const;
bool operator!=(const WDFAC& other) const
{
return ! (*this == other);
}
template <class Serializer>
void serializeOp(Serializer& serializer)
{
serializer(this->m_type);
serializer(this->m_d);
serializer(this->m_total_cf);
serializer(this->m_corr);
}
private:
enum class WDFacType
{
NONE = 1,
DFACTOR = 2,
DAKEMODEL = 3,
CON_DFACTOR = 4,
};
WDFacType m_type { WDFacType::NONE };
double m_d{0.0};
double m_total_cf{-1.0};
Correlation m_corr{};
double connectionLevelDFactor(const Connection& conn) const;
double dakeModelDFactor(const double rhoGS,
const double gas_visc,
const Connection& conn) const;
double scaledWellLevelDFactor(const double dfac,
const Connection& conn) const;
};
} // namespace Opm
#endif // WDFAC_HPP_HEADER_INCLUDED
Opm::Connection
Definition Connection.hpp:53
Opm::DeckRecord
Definition DeckRecord.hpp:32
Opm::Serializer
Class for (de-)serializing.
Definition Serializer.hpp:94
Opm::WDFAC
Definition WDFAC.hpp:40
Opm::WDFAC::operator!=
bool operator!=(const WDFAC &other) const
Inequality operator.
Definition WDFAC.hpp:220
Opm::WDFAC::updateWDFACType
void updateWDFACType(const WellConnections &connections)
Check if any input-level connctions have a non-trivial D-factor and update this well's D-factor categ...
Definition WDFAC.cpp:99
Opm::WDFAC::updateWDFACCOR
void updateWDFACCOR(const DeckRecord &record)
Configure D-factor calculation from Dake correlation model (keyword WDFACCOR).
Definition WDFAC.cpp:90
Opm::WDFAC::updateWDFAC
void updateWDFAC(const DeckRecord &record)
Configure D-factor calculation from well-level D-factor description (keyword 'WDFAC').
Definition WDFAC.cpp:83
Opm::WDFAC::getDFactor
double getDFactor(DensityCallback &&rhoGS, GasViscCallback &&gas_visc, const Connection &conn) const
Retrieve currently configured D-factor for single connection.
Definition WDFAC.hpp:178
Opm::WDFAC::WDFAC
WDFAC()=default
Default constructor.
Opm::WDFAC::operator==
bool operator==(const WDFAC &other) const
Equality operator.
Definition WDFAC.cpp:123
Opm::WDFAC::updateTotalCF
void updateTotalCF(const WellConnections &connections)
Capture sum of all CTFs for the purpose of translating well-level D-factors to connection-level D-fac...
Definition WDFAC.cpp:112
Opm::WDFAC::getDFactorCorrelationCoefficients
const Correlation & getDFactorCorrelationCoefficients() const
Retrieve current D-factor correlation model coefficients.
Definition WDFAC.hpp:203
Opm::WDFAC::serializationTestObject
static WDFAC serializationTestObject()
Serialisation test object.
Definition WDFAC.cpp:71
Opm::WDFAC::serializeOp
void serializeOp(Serializer &serializer)
Serialisation operator.
Definition WDFAC.hpp:232
Opm::WDFAC::useDFactor
bool useDFactor() const
Whether or not a flow-dependent skin factor ('D') has been configured for the current well.
Definition WDFAC.cpp:118
Opm::WellConnections
Definition WellConnections.hpp:48
Opm
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition Exceptions.hpp:30
Opm::RestartIO::RstWell
Definition well.hpp:43
Opm::WDFAC::Correlation
Parameters for Dake's D-factor correlation model.
Definition WDFAC.hpp:66
Opm::WDFAC::Correlation::operator==
bool operator==(const Correlation &other) const
Equality operator.
Definition WDFAC.cpp:49
Opm::WDFAC::Correlation::operator!=
bool operator!=(const Correlation &other) const
Inequality operator.
Definition WDFAC.hpp:87
Opm::WDFAC::Correlation::coeff_a
double coeff_a
Multiplicative coefficient 'A'.
Definition WDFAC.hpp:68
Opm::WDFAC::Correlation::serializeOp
void serializeOp(Serializer &serializer)
Serialisation operator.
Definition WDFAC.hpp:100
Opm::WDFAC::Correlation::serializationTestObject
static Correlation serializationTestObject()
Serialisation test object.
Definition WDFAC.cpp:44
Opm::WDFAC::Correlation::exponent_b
double exponent_b
Power coefficient 'B' for the effective permeability.
Definition WDFAC.hpp:71
Opm::WDFAC::Correlation::exponent_c
double exponent_c
Power coefficient 'C' for the porosity term.
Definition WDFAC.hpp:74