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
6#include "cantera/base/Interface.h"
7#include "cantera/thermo/ThermoFactory.h"
8#include "cantera/kinetics/KineticsFactory.h"
9
10 namespace Cantera
11{
12
13 using std::string;
14 using std::vector;
15
16Interface::Interface() {}
17
18 void Interface::setThermo(shared_ptr<ThermoPhase> thermo) {
19 Solution::setThermo(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
29 void Interface::setKinetics(shared_ptr<Kinetics> kinetics) {
30 Solution::setKinetics(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
Interface.h
KineticsFactory.h
ThermoFactory.h
Headers for the factory class that can create known ThermoPhase objects (see Thermodynamic Properties...
Cantera::AnyMap
A map of string keys to values whose type can vary at runtime.
Definition: AnyMap.h:399
Cantera::AnyMap::fromYamlFile
static AnyMap fromYamlFile(const std::string &name, const std::string &parent_name="")
Create an AnyMap from a YAML file.
Definition: AnyMap.cpp:1743
Cantera::CanteraError
Base class for exceptions thrown by Cantera classes.
Definition: ctexceptions.h:61
Cantera::InputFileError
Error thrown for problems processing information contained in an AnyMap or AnyValue.
Definition: AnyMap.h:702
Cantera::Interface::m_surfkin
shared_ptr< InterfaceKinetics > m_surfkin
Kinetics manager.
Definition: Interface.h:50
Cantera::Interface::setThermo
void setThermo(shared_ptr< ThermoPhase > thermo) override
Set the reacting phase thermo object.
Definition: Interface.cpp:18
Cantera::Interface::kinetics
shared_ptr< InterfaceKinetics > kinetics()
Get the surface phase Kinetics object.
Definition: Interface.h:44
Cantera::Interface::thermo
shared_ptr< SurfPhase > thermo()
Get the surface phase thermo object.
Definition: Interface.h:39
Cantera::Interface::setKinetics
void setKinetics(shared_ptr< Kinetics > kinetics) override
Set the Kinetics object.
Definition: Interface.cpp:29
Cantera::Interface::m_surf
shared_ptr< SurfPhase > m_surf
Surface phase ThermoPhase manager.
Definition: Interface.h:49
Cantera::Solution::setThermo
virtual void setThermo(shared_ptr< ThermoPhase > thermo)
Set the ThermoPhase object.
Definition: Solution.cpp:42
Cantera::Solution::setKinetics
virtual void setKinetics(shared_ptr< Kinetics > kinetics)
Set the Kinetics object.
Definition: Solution.cpp:46
Cantera
Namespace for the Cantera kernel.
Definition: AnyMap.cpp:557
Cantera::newSolution
shared_ptr< Solution > newSolution(const std::string &infile, const std::string &name, const std::string &transport, const std::vector< shared_ptr< Solution > > &adjacent)
Create and initialize a new Solution manager from an input file.
Definition: Solution.cpp:122
Cantera::newInterface
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