My Project
Loading...
Searching...
No Matches
ExtraConvergenceOutputThread.hpp
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
23#include <opm/simulators/timestepping/ConvergenceReport.hpp>
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
89 friend class ConvergenceOutputThread;
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
179 void writeASynchronous();
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
Parse comma separated option strings into a runtime configuration object for whether to output additi...
Definition ConvergenceOutputConfiguration.hpp:46
Definition ExtraConvergenceOutputThread.cpp:138
Encapsulating object for thread processing producer's convergence output requests.
Definition ExtraConvergenceOutputThread.hpp:105
std::function< std::string_view(int)> ComponentToPhaseName
Protocol for converting a phase/component ID into a human readable phase/component name.
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)
Perform synchronous file output of a sequence of requests.
Definition ExtraConvergenceOutputThread.cpp:283
void writeASynchronous()
Output thread worker function.
Definition ExtraConvergenceOutputThread.cpp:288
~ConvergenceOutputThread()
Destructor.
std::function< double(double)> ConvertToTimeUnits
Protocol for converting an SI elapsed time value into an equivalent time value in the run's output co...
Definition ExtraConvergenceOutputThread.hpp:115
ConvergenceOutputThread(const ConvergenceOutputThread &src)=delete
Deleted copy constructor.
Communication channel between thread creating output requests and consumer thread writing those reque...
Definition ExtraConvergenceOutputThread.hpp:56
void enqueue(std::vector< OutputRequest > &&requests)
Push sequence of output requests, typically all substeps whether converged or not,...
Definition ExtraConvergenceOutputThread.cpp:232
void signalLastOutputRequest()
Signal end of output request stream.
Definition ExtraConvergenceOutputThread.cpp:252
This file contains a set of helper functions used by VFPProd / VFPInj.
Definition BlackoilPhases.hpp:27
Single output request.
Definition ExtraConvergenceOutputThread.hpp:63
int currentStep
Current timestep within reportStep.
Definition ExtraConvergenceOutputThread.hpp:69
int reportStep
Current report step.
Definition ExtraConvergenceOutputThread.hpp:65
std::vector< ConvergenceReport > reports
Convergence metrics for each non-linear ieration in the currentStep.
Definition ExtraConvergenceOutputThread.hpp:73