Cantera  3.1.0b1
Loading...
Searching...
No Matches
Interface.cpp
Go to the documentation of this file.
1//! @file Interface.cpp
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
9
10namespace Cantera
11{
12
13void Interface::setThermo(shared_ptr<ThermoPhase> thermo) {
15 auto surf = std::dynamic_pointer_cast<SurfPhase>(thermo);
16 if (!surf) {
17 throw CanteraError("Interface::setThermo",
18 "Thermo object of type '{}' does not descend from SurfPhase.",
19 thermo->type());
20 }
21 m_surf = surf;
22}
23
24void Interface::setKinetics(shared_ptr<Kinetics> kinetics) {
26 auto surfkin = std::dynamic_pointer_cast<InterfaceKinetics>(kinetics);
27 if (!surfkin) {
28 throw CanteraError("Interface::setKinetics",
29 "Kinetics object of type '{}' does not descend from InterfaceKinetics.",
30 kinetics->kineticsType());
31 }
32 m_surfkin = surfkin;
33}
34
35shared_ptr<Interface> newInterface(const string& infile,
36 const string& name, const vector<string>& adjacent)
37{
38 auto sol = newSolution(infile, name, "default", adjacent);
39 auto iface = std::dynamic_pointer_cast<Interface>(sol);
40 if (!iface) {
41 auto rootNode = AnyMap::fromYamlFile(infile);
42 AnyMap& phaseNode = rootNode["phases"].getMapWhere("name", name);
43 throw InputFileError("newInterface", phaseNode,
44 "Phase definition does not define a surface phase");
45 }
46 return iface;
47}
48
49shared_ptr<Interface> newInterface(const string& infile,
50 const string& name, const vector<shared_ptr<Solution>>& adjacent)
51{
52 auto rootNode = AnyMap::fromYamlFile(infile);
53 AnyMap& phaseNode = rootNode["phases"].getMapWhere("name", name);
54 return newInterface(phaseNode, rootNode, adjacent);
55}
56
57shared_ptr<Interface> newInterface(AnyMap& phaseNode, const AnyMap& rootNode,
58 const vector<shared_ptr<Solution>>& adjacent)
59{
60 auto sol = newSolution(phaseNode, rootNode, "default", adjacent);
61 auto iface = std::dynamic_pointer_cast<Interface>(sol);
62 if (!iface) {
63 throw InputFileError("newInterface", phaseNode,
64 "Phase definition does not define a surface phase");
65 }
66 return iface;
67}
68
69} // end namespace Cantera
Headers for the factory class that can create known ThermoPhase objects (see Thermodynamic Properties...
A map of string keys to values whose type can vary at runtime.
Definition AnyMap.h:431
static AnyMap fromYamlFile(const string &name, const string &parent_name="")
Create an AnyMap from a YAML file.
Definition AnyMap.cpp:1841
Base class for exceptions thrown by Cantera classes.
Error thrown for problems processing information contained in an AnyMap or AnyValue.
Definition AnyMap.h:749
shared_ptr< InterfaceKinetics > m_surfkin
Kinetics manager.
Definition Interface.h:55
void setThermo(shared_ptr< ThermoPhase > thermo) override
Set the reacting phase thermo object.
Definition Interface.cpp:13
shared_ptr< InterfaceKinetics > kinetics()
Get the surface phase Kinetics object.
Definition Interface.h:49
shared_ptr< SurfPhase > thermo()
Get the surface phase thermo object.
Definition Interface.h:44
void setKinetics(shared_ptr< Kinetics > kinetics) override
Set the Kinetics object.
Definition Interface.cpp:24
shared_ptr< SurfPhase > m_surf
Surface phase ThermoPhase manager.
Definition Interface.h:54
virtual void setThermo(shared_ptr< ThermoPhase > thermo)
Set the ThermoPhase object.
Definition Solution.cpp:43
virtual void setKinetics(shared_ptr< Kinetics > kinetics)
Set the Kinetics object.
Definition Solution.cpp:50
shared_ptr< Solution > newSolution(const string &infile, const string &name, const string &transport, const vector< shared_ptr< Solution > > &adjacent)
Create and initialize a new Solution manager from an input file.
Definition Solution.cpp:178
shared_ptr< Interface > newInterface(const string &infile, const string &name, const vector< string > &adjacent)
Create and initialize a new Interface from an input file.
Definition Interface.cpp:35
Namespace for the Cantera kernel.
Definition AnyMap.cpp:595