GasLiftCommon: template Scalar type

This commit is contained in:
Arne Morten Kvarving 2024-02-19 15:46:29 +01:00
parent e7f208a84a
commit 37fa8cc5b8
5 changed files with 43 additions and 50 deletions

View File

@ -28,30 +28,27 @@
namespace Opm {
GasLiftCommon::
GasLiftCommon(
WellState<double>& well_state,
const GroupState<double>& group_state,
DeferredLogger &deferred_logger,
const Parallel::Communication& comm,
bool glift_debug
) :
well_state_{well_state},
group_state_{group_state},
deferred_logger_{deferred_logger},
comm_{comm},
debug{glift_debug}
{
}
template<class Scalar>
GasLiftCommon<Scalar>::
GasLiftCommon(WellState<Scalar>& well_state,
const GroupState<Scalar>& group_state,
DeferredLogger& deferred_logger,
const Parallel::Communication& comm,
bool glift_debug)
: well_state_{well_state}
, group_state_{group_state}
, deferred_logger_{deferred_logger}
, comm_{comm}
, debug{glift_debug}
{}
/****************************************
* Protected methods in alphabetical order
****************************************/
template<class Scalar>
int
GasLiftCommon::
debugUpdateGlobalCounter_() const
GasLiftCommon<Scalar>::debugUpdateGlobalCounter_() const
{
auto count = this->well_state_.gliftUpdateDebugCounter();
const std::string msg = fmt::format("global counter = {}", count);
@ -59,9 +56,9 @@ debugUpdateGlobalCounter_() const
return count;
}
void
GasLiftCommon::
displayDebugMessageOnRank0_(const std::string &msg) const
template<class Scalar>
void GasLiftCommon<Scalar>::
displayDebugMessageOnRank0_(const std::string& msg) const
{
// This output should be identical for all ranks.
@ -71,12 +68,13 @@ displayDebugMessageOnRank0_(const std::string &msg) const
}
}
void
GasLiftCommon::
logMessage_(
const std::string& prefix, const std::string& msg, MessageType msg_type) const
template<class Scalar>
void GasLiftCommon<Scalar>::
logMessage_(const std::string& prefix,
const std::string& msg,
MessageType msg_type) const
{
std::string rank = "";
std::string rank;
if (this->comm_.size() > 1) {
rank = fmt::format(" Rank #{} :", this->comm_.rank());
}
@ -105,9 +103,6 @@ logMessage_(
}
}
/****************************************
* Private methods in alphabetical order
****************************************/
template class GasLiftCommon<double>;
} // namespace Opm

View File

@ -24,39 +24,37 @@
#include <string>
namespace Opm
{
namespace Opm {
class DeferredLogger;
template<class Scalar> class GroupState;
template<class Scalar> class WellState;
template<class Scalar>
class GasLiftCommon
{
public:
virtual ~GasLiftCommon() = default;
protected:
GasLiftCommon(
WellState<double>& well_state,
const GroupState<double>& group_state,
DeferredLogger &deferred_logger,
const Parallel::Communication& comm,
bool debug
);
GasLiftCommon(WellState<Scalar>& well_state,
const GroupState<Scalar>& group_state,
DeferredLogger& deferred_logger,
const Parallel::Communication& comm,
bool glift_debug);
enum class MessageType { INFO, WARNING };
int debugUpdateGlobalCounter_() const;
virtual void displayDebugMessage_(const std::string& msg) const = 0;
void displayDebugMessageOnRank0_(const std::string &msg) const;
void logMessage_(
const std::string& prefix,
const std::string& msg,
MessageType msg_type = MessageType::INFO) const;
void displayDebugMessageOnRank0_(const std::string& msg) const;
void logMessage_(const std::string& prefix,
const std::string& msg,
MessageType msg_type = MessageType::INFO) const;
WellState<double>& well_state_;
const GroupState<double>& group_state_;
DeferredLogger &deferred_logger_;
WellState<Scalar>& well_state_;
const GroupState<Scalar>& group_state_;
DeferredLogger& deferred_logger_;
const Parallel::Communication& comm_;
bool debug;
// By setting this variable to true we restrict some debug output

View File

@ -41,7 +41,7 @@ class SummaryState;
class Well;
template<class Scalar> class WellState;
class GasLiftGroupInfo : public GasLiftCommon
class GasLiftGroupInfo : public GasLiftCommon<double>
{
protected:
class GroupRates;

View File

@ -45,7 +45,7 @@ class WellInterfaceGeneric;
template<class Scalar> class WellState;
template<class Scalar> class GroupState;
class GasLiftSingleWellGeneric : public GasLiftCommon
class GasLiftSingleWellGeneric : public GasLiftCommon<double>
{
protected:
static constexpr int Water = BlackoilPhases::Aqua;

View File

@ -42,7 +42,7 @@ class Schedule;
class WellInterfaceGeneric;
template<class Scalar> class WellState;
class GasLiftStage2 : public GasLiftCommon {
class GasLiftStage2 : public GasLiftCommon<double> {
using GasLiftSingleWell = GasLiftSingleWellGeneric;
using GLiftOptWells = std::map<std::string,std::unique_ptr<GasLiftSingleWell>>;
using GLiftProdWells = std::map<std::string,const WellInterfaceGeneric*>;