Cantera
Install
User Guide
Examples
Reference
Develop
Community
4.0.0a2
Toggle main menu visibility
Loading...
Searching...
No Matches
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
//! @defgroup serializeGroup Serialization
22
//! Classes and functions related to serialization of %Cantera objects
23
//! @ingroup ioGroup
24
25
//! A class for generating full YAML input files from multiple data sources
26
//! @ingroup serializeGroup
27
class
YamlWriter
28
{
29
public
:
30
YamlWriter() =
default
;
31
32
//! Include top-level information used in YAML header block
33
void
setHeader
(
const
AnyMap
& header);
34
35
//! Include a phase definition for the specified Solution object
36
void
addPhase
(shared_ptr<Solution> soln,
bool
includeAdjacent=
true
);
37
38
//! Include a phase definition using the specified ThermoPhase, (optional)
39
//! Kinetics, and (optional) Transport objects
40
void
addPhase
(shared_ptr<ThermoPhase> thermo, shared_ptr<Kinetics> kin={},
41
shared_ptr<Transport> tran={});
42
43
//! Return a YAML string that contains the definitions for the added phases,
44
//! species, and reactions
45
string
toYamlString
()
const
;
46
47
//! Write the definitions for the added phases, species and reactions to
48
//! the specified file.
49
void
toYamlFile
(
const
string
& filename)
const
;
50
51
//! For output floating point values, set the maximum number of digits to
52
//! the right of the decimal point. The default is 15 digits.
53
void
setPrecision
(
long
int
n) {
54
m_float_precision
= n;
55
}
56
57
//! By default user-defined data present in the input is preserved on
58
//! output. This method can be used to skip output of user-defined data
59
//! fields which are not directly used by Cantera.
60
void
skipUserDefined
(
bool
skip=
true
) {
61
m_skip_user_defined
= skip;
62
}
63
64
//! Set the units to be used in the output file. Dimensions not specified
65
//! will use Cantera's defaults.
66
//! @param units A map where keys are dimensions (mass, length, time,
67
//! quantity, pressure, energy, activation-energy) and the values are
68
//! corresponding units supported by the UnitSystem class.
69
void
setUnits
(
const
map<string, string>& units={});
70
71
//! Set the units to be used in the output file. Dimensions not specified
72
//! will use Cantera's defaults.
73
//! @param units A UnitSystem object specifying dimensions (mass, length, time,
74
//! quantity, pressure, energy, activation-energy).
75
void
setUnitSystem
(
const
UnitSystem& units=UnitSystem());
76
77
protected
:
78
//! Top-level information used in YAML header block
79
AnyMap
m_header
;
80
81
vector<shared_ptr<Solution>> m_phases;
82
83
//! See setPrecision()
84
long
int
m_float_precision
= 15;
85
86
//! See skipUserDefined()
87
bool
m_skip_user_defined
=
false
;
88
89
//! Top-level units directive for the output file. Defaults to Cantera's
90
//! native SI+kmol system.
91
UnitSystem
m_output_units
;
92
};
93
94
}
95
96
#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:431
Cantera::Kinetics
Public interface for kinetics managers.
Definition
Kinetics.h:124
Cantera::Solution
A container class for chemically-reacting solutions.
Definition
Solution.h:44
Cantera::ThermoPhase
Base class for a phase with thermodynamic properties.
Definition
ThermoPhase.h:391
Cantera::Transport
Base class for transport property managers.
Definition
Transport.h:72
Cantera::UnitSystem
Unit conversion utility.
Definition
Units.h:169
Cantera::YamlWriter::m_skip_user_defined
bool m_skip_user_defined
See skipUserDefined().
Definition
YamlWriter.h:87
Cantera::YamlWriter::toYamlString
string toYamlString() const
Return a YAML string that contains the definitions for the added phases, species, and reactions.
Definition
YamlWriter.cpp:55
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:53
Cantera::YamlWriter::setUnitSystem
void setUnitSystem(const UnitSystem &units=UnitSystem())
Set the units to be used in the output file.
Definition
YamlWriter.cpp:225
Cantera::YamlWriter::m_float_precision
long int m_float_precision
See setPrecision().
Definition
YamlWriter.h:84
Cantera::YamlWriter::skipUserDefined
void skipUserDefined(bool skip=true)
By default user-defined data present in the input is preserved on output.
Definition
YamlWriter.h:60
Cantera::YamlWriter::m_header
AnyMap m_header
Top-level information used in YAML header block.
Definition
YamlWriter.h:79
Cantera::YamlWriter::setHeader
void setHeader(const AnyMap &header)
Include top-level information used in YAML header block.
Definition
YamlWriter.cpp:19
Cantera::YamlWriter::addPhase
void addPhase(shared_ptr< Solution > soln, bool includeAdjacent=true)
Include a phase definition for the specified Solution object.
Definition
YamlWriter.cpp:23
Cantera::YamlWriter::m_output_units
UnitSystem m_output_units
Top-level units directive for the output file.
Definition
YamlWriter.h:91
Cantera::YamlWriter::toYamlFile
void toYamlFile(const string &filename) const
Write the definitions for the added phases, species and reactions to the specified file.
Definition
YamlWriter.cpp:213
Cantera::YamlWriter::setUnits
void setUnits(const map< string, string > &units={})
Set the units to be used in the output file.
Definition
YamlWriter.cpp:219
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:595
include
cantera
base
YamlWriter.h
Generated by
1.17.0