ExtraConvergenceOutputThread.hpp
Go to the documentation of this file.
1/*
2 Copyright 2022 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 EXTRA_CONVERGENCE_OUTPUT_THREAD_HPP
21#define EXTRA_CONVERGENCE_OUTPUT_THREAD_HPP
22
24
25#include <condition_variable>
26#include <functional>
27#include <memory>
28#include <mutex>
29#include <string_view>
30#include <vector>
31
32namespace Opm {
33 class ConvergenceOutputConfiguration;
34} // namespace Opm
35
42
43namespace Opm
44{
45
47class ConvergenceOutputThread;
48
56{
57public:
63 {
65 int reportStep{-1};
66
69 int currentStep{-1};
70
73 std::vector<ConvergenceReport> reports{};
74 };
75
80 void enqueue(std::vector<OutputRequest>&& requests);
81
88
90
91private:
93 std::mutex mtx_{};
94
96 std::condition_variable cv_{};
97
99 std::vector<OutputRequest> requests_{};
100};
101
105{
106public:
109 using ComponentToPhaseName = std::function<std::string_view(int)>;
110
115 using ConvertToTimeUnits = std::function<double(double)>;
116
141 explicit ConvergenceOutputThread(std::string_view outputDir,
142 std::string_view baseName,
143 ComponentToPhaseName getPhaseName,
144 ConvertToTimeUnits convertTime,
147
150
153
156
159
164
170 void writeSynchronous(std::vector<ConvergenceReportQueue::OutputRequest>&& requests);
171
180
181private:
183 class Impl;
184
186 std::unique_ptr<Impl> pImpl_;
187};
188
189} // namespace Opm
190
191#endif // EXTRA_CONVERGENCE_OUTPUT_THREAD_HPP
Definition: ConvergenceOutputConfiguration.hpp:46
Definition: ExtraConvergenceOutputThread.hpp:105
std::function< std::string_view(int)> ComponentToPhaseName
Definition: ExtraConvergenceOutputThread.hpp:109
ConvergenceOutputThread & operator=(const ConvergenceOutputThread &src)=delete
Deleted assignment operator.
ConvergenceOutputThread & operator=(ConvergenceOutputThread &&src)=delete
Deleted move-assignment operator.
void writeSynchronous(std::vector< ConvergenceReportQueue::OutputRequest > &&requests)
ConvergenceOutputThread(ConvergenceOutputThread &&src)
Move constructor.
std::function< double(double)> ConvertToTimeUnits
Definition: ExtraConvergenceOutputThread.hpp:115
ConvergenceOutputThread(const ConvergenceOutputThread &src)=delete
Deleted copy constructor.
ConvergenceOutputThread(std::string_view outputDir, std::string_view baseName, ComponentToPhaseName getPhaseName, ConvertToTimeUnits convertTime, ConvergenceOutputConfiguration config, ConvergenceReportQueue &queue)
Definition: ExtraConvergenceOutputThread.hpp:56
void enqueue(std::vector< OutputRequest > &&requests)
Definition: BlackoilPhases.hpp:27
Definition: ExtraConvergenceOutputThread.hpp:63
int currentStep
Definition: ExtraConvergenceOutputThread.hpp:69
int reportStep
Current report step.
Definition: ExtraConvergenceOutputThread.hpp:65
std::vector< ConvergenceReport > reports
Definition: ExtraConvergenceOutputThread.hpp:73