Cantera 2.6.0
YamlWriter.h
Go to the documentation of this file.
1//! @file YamlWriter.h Declaration for class Cantera::YamlWriter.
2
3// This file is part of Cantera. See License.txt in the top-level directory or
4// at https://cantera.org/license.txt for license and copyright information.
5
6#ifndef CT_YAMLWRITER_H
7#define CT_YAMLWRITER_H
8
10#include "cantera/base/AnyMap.h"
11#include "cantera/base/Units.h"
12
13namespace Cantera
14{
15
16class Solution;
17class ThermoPhase;
18class Kinetics;
19class Transport;
20
21//! A class for generating full YAML input files from multiple data sources
23{
24public:
25 YamlWriter();
26
27 //! Include top-level information used in YAML header block
28 void setHeader(const AnyMap& header);
29
30 //! Include a phase definition for the specified Solution object
31 void addPhase(shared_ptr<Solution> soln, bool includeAdjacent=true);
32
33 //! Include a phase definition using the specified ThermoPhase, (optional)
34 //! Kinetics, and (optional) Transport objects
35 void addPhase(shared_ptr<ThermoPhase> thermo, shared_ptr<Kinetics> kin={},
36 shared_ptr<Transport> tran={});
37
38 //! Return a YAML string that contains the definitions for the added phases,
39 //! species, and reactions
40 std::string toYamlString() const;
41
42 //! Write the definitions for the added phases, species and reactions to
43 //! the specified file.
44 void toYamlFile(const std::string& filename) const;
45
46 //! For output floating point values, set the maximum number of digits to
47 //! the right of the decimal point. The default is 15 digits.
48 void setPrecision(long int n) {
50 }
51
52 //! By default user-defined data present in the input is preserved on
53 //! output. This method can be used to skip output of user-defined data
54 //! fields which are not directly used by Cantera.
55 void skipUserDefined(bool skip=true) {
57 }
58
59 //! Set the units to be used in the output file. Dimensions not specified
60 //! will use Cantera's defaults.
61 //! @param units A map where keys are dimensions (mass, length, time,
62 //! quantity, pressure, energy, activation-energy) and the values are
63 //! corresponding units supported by the UnitSystem class.
64 void setUnits(const std::map<std::string, std::string>& units={});
65
66 //! Set the units to be used in the output file. Dimensions not specified
67 //! will use Cantera's defaults.
68 //! @param units A UnitSystem object specifying dimensions (mass, length, time,
69 //! quantity, pressure, energy, activation-energy).
70 void setUnitSystem(const UnitSystem& units=UnitSystem());
71
72protected:
73 //! Top-level information used in YAML header block
75
76 std::vector<shared_ptr<Solution>> m_phases;
77
78 //! @see setPrecision()
80
81 //! @see skipUserDefined()
83
84 //! Top-level units directive for the output file. Defaults to Cantera's
85 //! native SI+kmol system.
87};
88
89}
90
91#endif
Header for unit conversion utilities, which are used to translate user input from input files (See In...
A map of string keys to values whose type can vary at runtime.
Definition: AnyMap.h:399
Unit conversion utility.
Definition: Units.h:161
A class for generating full YAML input files from multiple data sources.
Definition: YamlWriter.h:23
void toYamlFile(const std::string &filename) const
Write the definitions for the added phases, species and reactions to the specified file.
Definition: YamlWriter.cpp:197
void setPrecision(long int n)
For output floating point values, set the maximum number of digits to the right of the decimal point.
Definition: YamlWriter.h:48
void setUnitSystem(const UnitSystem &units=UnitSystem())
Set the units to be used in the output file.
Definition: YamlWriter.cpp:209
std::string toYamlString() const
Return a YAML string that contains the definitions for the added phases, species, and reactions.
Definition: YamlWriter.cpp:62
long int m_float_precision
Definition: YamlWriter.h:79
void skipUserDefined(bool skip=true)
By default user-defined data present in the input is preserved on output.
Definition: YamlWriter.h:55
void setUnits(const std::map< std::string, std::string > &units={})
Set the units to be used in the output file.
Definition: YamlWriter.cpp:203
AnyMap m_header
Top-level information used in YAML header block.
Definition: YamlWriter.h:74
void setHeader(const AnyMap &header)
Include top-level information used in YAML header block.
Definition: YamlWriter.cpp:26
void addPhase(shared_ptr< Solution > soln, bool includeAdjacent=true)
Include a phase definition for the specified Solution object.
Definition: YamlWriter.cpp:30
UnitSystem m_output_units
Top-level units directive for the output file.
Definition: YamlWriter.h:86
This file contains definitions of constants, types and terms that are used in internal routines and a...
Namespace for the Cantera kernel.
Definition: AnyMap.h:29