Reaktoro
A unified framework for modeling chemically reactive systems
ChemicalOutput.hpp
1 // Reaktoro is a unified framework for modeling chemically reactive systems.
2 //
3 // Copyright (C) 2014-2018 Allan Leal
4 //
5 // This library is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU Lesser General Public
7 // License as published by the Free Software Foundation; either
8 // version 2.1 of the License, or (at your option) any later version.
9 //
10 // This library is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 // Lesser General Public License for more details.
14 //
15 // You should have received a copy of the GNU Lesser General Public License
16 // along with this library. If not, see <http://www.gnu.org/licenses/>.
17 
18 #pragma once
19 
20 // C++ includes
21 #include <memory>
22 #include <vector>
23 #include <sstream>
24 #include <string>
25 
26 namespace Reaktoro {
27 
28 // Forward declarations
29 class ChemicalState;
30 class ChemicalSystem;
31 class ReactionSystem;
32 class StringList;
33 
36 {
37 public:
40 
42  explicit ChemicalOutput(const ChemicalSystem& system);
43 
45  explicit ChemicalOutput(const ReactionSystem& reactions);
46 
48  virtual ~ChemicalOutput();
49 
51  auto filename(std::string filename) -> void;
52 
54  auto filename() const -> std::string;
55 
57  auto suffix(std::string name) -> void;
58 
60  auto suffix() const -> std::string;
61 
63  auto basename() const -> std::string;
64 
66  auto extension() const -> std::string;
67 
70  auto add(std::string quantity) -> void;
71 
75  auto add(std::string quantity, std::string label) -> void;
76 
78  auto attachments(std::vector<std::string> titles) -> void;
79 
81  auto attach(int value) -> void;
82 
84  auto attach(double value) -> void;
85 
87  auto attach(std::string value) -> void;
88 
90  auto precision(int val) -> void;
91 
93  auto scientific(bool enable) -> void;
94 
96  auto terminal(bool enabled) -> void;
97 
99  auto quantities() const -> std::vector<std::string>;
100 
102  auto headings() const -> std::vector<std::string>;
103 
105  auto open() -> void;
106 
108  auto update(const ChemicalState& state, double t) -> void;
109 
111  auto close() -> void;
112 
114  operator bool() const;
115 
116 private:
117  struct Impl;
118 
119  std::shared_ptr<Impl> pimpl;
120 };
121 
122 } // namespace Reaktoro
virtual ~ChemicalOutput()
Destroy this ChemicalOutput instance.
Definition: ChemicalOutput.cpp:212
auto attach(int value) -> void
Attach value to extra column data in the output file.
Definition: ChemicalOutput.cpp:265
A class to represent a system and its attributes and properties.
Definition: ChemicalSystem.hpp:38
Provides a computational representation of the state of a multiphase chemical system.
Definition: ChemicalState.hpp:61
auto precision(int val) -> void
Set the floating-point precision in the output.
Definition: ChemicalOutput.cpp:280
auto extension() const -> std::string
Return the extension name of output file name.
Definition: ChemicalOutput.cpp:243
The namespace containing all components of the Reaktoro library.
Definition: ChemicalScalar.hpp:24
A type used to output sequence of chemical states to a file or terminal.
Definition: ChemicalOutput.hpp:36
auto add(std::string quantity) -> void
Add a quantity to be output.
Definition: ChemicalOutput.cpp:248
auto headings() const -> std::vector< std::string >
Return the headings of the output file.
Definition: ChemicalOutput.cpp:300
auto basename() const -> std::string
Return the base name of output file name.
Definition: ChemicalOutput.cpp:238
auto close() -> void
Close the output file.
Definition: ChemicalOutput.cpp:315
A class that represents a system of chemical reactions.
Definition: ReactionSystem.hpp:42
auto attachments(std::vector< std::string > titles) -> void
Set the titles of extra columns in the output file.
Definition: ChemicalOutput.cpp:259
auto filename() const -> std::string
Return the name of the output file.
Definition: ChemicalOutput.cpp:222
auto quantities() const -> std::vector< std::string >
Return the name of the quantities in the output file.
Definition: ChemicalOutput.cpp:295
auto suffix() const -> std::string
Return the suffix word of the output file name.
Definition: ChemicalOutput.cpp:233
auto scientific(bool enable) -> void
Enable or disable output in scientific format.
Definition: ChemicalOutput.cpp:285
auto terminal(bool enabled) -> void
Enable or disable the output to the terminal.
Definition: ChemicalOutput.cpp:290
auto update(const ChemicalState &state, double t) -> void
Update the output with a new chemical state and its tag.
Definition: ChemicalOutput.cpp:310
auto open() -> void
Open the output file.
Definition: ChemicalOutput.cpp:305
ChemicalOutput()
Construct a default ChemicalOutput instance.
Definition: ChemicalOutput.cpp:200