EconomicLimitsMessage.hpp
Go to the documentation of this file.
1/*
2 Copyright 2026 Equinor ASA.
3
4 This file is part of the Open Porous Media project (OPM).
5
6 OPM is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
10
11 OPM is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with OPM. If not, see <http://www.gnu.org/licenses/>.
18*/
19
20#ifndef OPM_ECONOMIC_LIMITS_MESSAGE_HEADER_INCLUDED
21#define OPM_ECONOMIC_LIMITS_MESSAGE_HEADER_INCLUDED
22
23#include <opm/common/utility/TimeService.hpp>
24
25#include <opm/input/eclipse/Units/UnitSystem.hpp>
26
27#include <fmt/chrono.h>
28#include <fmt/format.h>
29
30#include <ctime>
31#include <string>
32
33namespace Opm {
34
41inline std::string economicLimitDateString(const std::time_t start_time, const double sim_time)
42{
43 const std::time_t cur_time = TimeService::advance(start_time, sim_time);
44 return fmt::format("{:%d-%b-%Y}", fmt::gmtime(cur_time));
45}
46
49inline std::string economicLimitWhenString(const UnitSystem& unit_system,
50 const std::time_t start_time,
51 const double sim_time)
52{
53 return fmt::format("at time {:.2f} {} (date = {})",
54 unit_system.from_si(UnitSystem::measure::time, sim_time),
55 unit_system.name(UnitSystem::measure::time),
56 economicLimitDateString(start_time, sim_time));
57}
58
61inline const std::string& economicLimitMessageSeparator()
62{
63 static const std::string separator(110, '*');
64 return separator;
65}
66
67} // namespace Opm
68
69#endif // OPM_ECONOMIC_LIMITS_MESSAGE_HEADER_INCLUDED
Definition: blackoilbioeffectsmodules.hh:45
const std::string & economicLimitMessageSeparator()
Separator line used to frame economic-limit workover messages. Built once and returned by reference (...
Definition: EconomicLimitsMessage.hpp:61
std::string economicLimitDateString(const std::time_t start_time, const double sim_time)
Calendar date (DD-Mon-YYYY, UTC) reached at start_time plus sim_time seconds.
Definition: EconomicLimitsMessage.hpp:41
std::string economicLimitWhenString(const UnitSystem &unit_system, const std::time_t start_time, const double sim_time)
The "at time ... (date = ...)" clause shared by the well (WECON) and connection (CECON) economic-limi...
Definition: EconomicLimitsMessage.hpp:49