opm-simulators
SimulatorConvergenceOutput.hpp
1 /*
2  Copyright 2013, 2015, 2020 SINTEF Digital, Mathematics and Cybernetics.
3  Copyright 2015 Andreas Lauser
4  Copyright 2017 IRIS
5 
6  This file is part of the Open Porous Media project (OPM).
7 
8  OPM is free software: you can redistribute it and/or modify
9  it under the terms of the GNU General Public License as published by
10  the Free Software Foundation, either version 3 of the License, or
11  (at your option) any later version.
12 
13  OPM is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  GNU General Public License for more details.
17 
18  You should have received a copy of the GNU General Public License
19  along with OPM. If not, see <http://www.gnu.org/licenses/>.
20 */
21 
22 #ifndef OPM_SIMULATOR_CONVERGENCE_OUTPUT_HEADER_INCLUDED
23 #define OPM_SIMULATOR_CONVERGENCE_OUTPUT_HEADER_INCLUDED
24 
25 #include <opm/simulators/flow/ExtraConvergenceOutputThread.hpp>
26 
27 #include <cstddef>
28 #include <optional>
29 #include <string_view>
30 #include <thread>
31 #include <vector>
32 
33 namespace Opm {
34 
35  class EclipseState;
36  struct StepReport;
37 
38 } // namespace Opm
39 
40 namespace Opm {
41 
44 {
45 public:
61  void startThread(const EclipseState& eclState,
62  std::string_view convOutputOptions,
63  std::string_view optionName,
65 
77  void write(const std::vector<StepReport>& reports);
78 
83  void endThread();
84 
85 private:
87  std::vector<StepReport>::size_type alreadyReportedSteps_ = 0;
88 
94  std::optional<ConvergenceReportQueue> convergenceOutputQueue_{};
95 
100  std::optional<ConvergenceOutputThread> convergenceOutputObject_{};
101 
109  std::optional<std::thread> convergenceOutputThread_{};
110 };
111 
112 } // namespace Opm
113 
114 #endif // OPM_SIMULATOR_CONVERGENCE_OUTPUT_HEADER_INCLUDED
void startThread(const EclipseState &eclState, std::string_view convOutputOptions, std::string_view optionName, ConvergenceOutputThread::ComponentToPhaseName getPhaseName)
Start convergence output thread.
Definition: SimulatorConvergenceOutput.cpp:40
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
void endThread()
Request that convergence output thread be shut down.
Definition: SimulatorConvergenceOutput.cpp:100
This file contains a set of helper functions used by VFPProd / VFPInj.
Definition: blackoilbioeffectsmodules.hh:45
Class handling convergence history output for a simulator.
Definition: SimulatorConvergenceOutput.hpp:43
void write(const std::vector< StepReport > &reports)
Create convergence output requests.
Definition: SimulatorConvergenceOutput.cpp:72