Cantera 2.6.0
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
13using std::string;
14using std::vector;
15
16Interface::Interface() {}
17
18void Interface::setThermo(shared_ptr<ThermoPhase> thermo) {
20 auto surf = std::dynamic_pointer_cast<SurfPhase>(thermo);
21 if (!surf) {
22 throw CanteraError("Interface::setThermo",
23 "Thermo object of type '{}' does not descend from SurfPhase.",
24 thermo->type());
25 }
26 m_surf = surf;
27}
28
29void Interface::setKinetics(shared_ptr<Kinetics> kinetics) {
31 auto surfkin = std::dynamic_pointer_cast<InterfaceKinetics>(kinetics);
32 if (!surfkin) {
33 throw CanteraError("Interface::setKinetics",
34 "Kinetics object of type '{}' does not descend from InterfaceKinetics.",
35 kinetics->kineticsType());
36 }
37 m_surfkin = surfkin;
38}
39
40shared_ptr<Interface> newInterface(const std::string& infile,
41 const std::string& name, const std::vector<std::string>& adjacent)
42{
43 auto sol = newSolution(infile, name, "", adjacent);
44 auto iface = std::dynamic_pointer_cast<Interface>(sol);
45 if (!iface) {
46 auto rootNode = AnyMap::fromYamlFile(infile);
47 AnyMap& phaseNode = rootNode["phases"].getMapWhere("name", name);
48 throw InputFileError("newInterface", phaseNode,
49 "Phase definition does not define a surface phase");
50 }
51 return iface;
52}
53
54shared_ptr<Interface> newInterface(const std::string& infile,
55 const std::string& name, const std::vector<shared_ptr<Solution>>& adjacent)
56{
57 auto rootNode = AnyMap::fromYamlFile(infile);
58 AnyMap& phaseNode = rootNode["phases"].getMapWhere("name", name);
59 return newInterface(phaseNode, rootNode, adjacent);
60}
61
62shared_ptr<Interface> newInterface(AnyMap& phaseNode, const AnyMap& rootNode,
63 const std::vector<shared_ptr<Solution>>& adjacent)
64{
65 auto sol = newSolution(phaseNode, rootNode, "", adjacent);
66 auto iface = std::dynamic_pointer_cast<Interface>(sol);
67 if (!iface) {
68 throw InputFileError("newInterface", phaseNode,
69 "Phase definition does not define a surface phase");
70 }
71 return iface;
72}
73
74} // 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:399
static AnyMap fromYamlFile(const std::string &name, const std::string &parent_name="")
Create an AnyMap from a YAML file.
Definition: AnyMap.cpp:1743
Base class for exceptions thrown by Cantera classes.
Definition: ctexceptions.h:61
Error thrown for problems processing information contained in an AnyMap or AnyValue.
Definition: AnyMap.h:702
shared_ptr< InterfaceKinetics > m_surfkin
Kinetics manager.
Definition: Interface.h:50
void setThermo(shared_ptr< ThermoPhase > thermo) override
Set the reacting phase thermo object.
Definition: Interface.cpp:18
shared_ptr< InterfaceKinetics > kinetics()
Get the surface phase Kinetics object.
Definition: Interface.h:44
shared_ptr< SurfPhase > thermo()
Get the surface phase thermo object.
Definition: Interface.h:39
void setKinetics(shared_ptr< Kinetics > kinetics) override
Set the Kinetics object.
Definition: Interface.cpp:29
shared_ptr< SurfPhase > m_surf
Surface phase ThermoPhase manager.
Definition: Interface.h:49
virtual void setThermo(shared_ptr< ThermoPhase > thermo)
Set the ThermoPhase object.
Definition: Solution.cpp:42
virtual void setKinetics(shared_ptr< Kinetics > kinetics)
Set the Kinetics object.
Definition: Solution.cpp:46
Namespace for the Cantera kernel.
Definition: AnyMap.h:29
shared_ptr< Solution > newSolution(const std::string &infile, const std::string &name, const std::string &transport, const std::vector< std::string > &adjacent)
Create and initialize a new Solution from an input file.
Definition: Solution.cpp:172
shared_ptr< Interface > newInterface(const std::string &infile, const std::string &name="", const std::vector< std::string > &adjacent={})
Create and initialize a new Interface from an input file.
Definition: Interface.cpp:40