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
9#include "cantera/base/ct_defs.h"
10#include "cantera/base/AnyMap.h"
11#include "cantera/base/Units.h"
12
13 namespace Cantera
14{
15
16 class Solution;
17 class ThermoPhase;
18 class Kinetics;
19 class Transport;
20
21//! A class for generating full YAML input files from multiple data sources
22 class YamlWriter
23{
24 public:
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) {
49 m_float_precision = 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) {
56 m_skip_user_defined = skip;
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
72 protected:
73 //! Top-level information used in YAML header block
74 AnyMap m_header;
75
76 std::vector<shared_ptr<Solution>> m_phases;
77
78 //! @see setPrecision()
79 long int m_float_precision;
80
81 //! @see skipUserDefined()
82 bool m_skip_user_defined;
83
84 //! Top-level units directive for the output file. Defaults to Cantera's
85 //! native SI+kmol system.
86 UnitSystem m_output_units;
87};
88
89}
90
91#endif
AnyMap.h
Units.h
Header for unit conversion utilities, which are used to translate user input from input files (See In...
Cantera::AnyMap
A map of string keys to values whose type can vary at runtime.
Definition: AnyMap.h:399
Cantera::UnitSystem
Unit conversion utility.
Definition: Units.h:161
Cantera::YamlWriter
A class for generating full YAML input files from multiple data sources.
Definition: YamlWriter.h:23
Cantera::YamlWriter::m_skip_user_defined
bool m_skip_user_defined
Definition: YamlWriter.h:82
Cantera::YamlWriter::toYamlFile
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
Cantera::YamlWriter::setPrecision
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
Cantera::YamlWriter::setUnitSystem
void setUnitSystem(const UnitSystem &units=UnitSystem())
Set the units to be used in the output file.
Definition: YamlWriter.cpp:209
Cantera::YamlWriter::toYamlString
std::string toYamlString() const
Return a YAML string that contains the definitions for the added phases, species, and reactions.
Definition: YamlWriter.cpp:62
Cantera::YamlWriter::m_float_precision
long int m_float_precision
Definition: YamlWriter.h:79
Cantera::YamlWriter::skipUserDefined
void skipUserDefined(bool skip=true)
By default user-defined data present in the input is preserved on output.
Definition: YamlWriter.h:55
Cantera::YamlWriter::setUnits
void setUnits(const std::map< std::string, std::string > &units={})
Set the units to be used in the output file.
Definition: YamlWriter.cpp:203
Cantera::YamlWriter::m_header
AnyMap m_header
Top-level information used in YAML header block.
Definition: YamlWriter.h:74
Cantera::YamlWriter::setHeader
void setHeader(const AnyMap &header)
Include top-level information used in YAML header block.
Definition: YamlWriter.cpp:26
Cantera::YamlWriter::addPhase
void addPhase(shared_ptr< Solution > soln, bool includeAdjacent=true)
Include a phase definition for the specified Solution object.
Definition: YamlWriter.cpp:30
Cantera::YamlWriter::m_output_units
UnitSystem m_output_units
Top-level units directive for the output file.
Definition: YamlWriter.h:86
ct_defs.h
This file contains definitions of constants, types and terms that are used in internal routines and a...
Cantera
Namespace for the Cantera kernel.
Definition: AnyMap.cpp:557