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

View File

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

View File

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

View File

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

View File

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