forked from Cantera/cantera
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathInterface.cpp
More file actions
69 lines (60 loc) · 2.31 KB
/
Interface.cpp
File metadata and controls
69 lines (60 loc) · 2.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
//! @file Interface.cpp
// This file is part of Cantera. See License.txt in the top-level directory or
// at https://cantera.org/license.txt for license and copyright information.
#include "cantera/base/Interface.h"
#include "cantera/thermo/ThermoFactory.h"
#include "cantera/kinetics/KineticsFactory.h"
namespace Cantera
{
void Interface::setThermo(shared_ptr<ThermoPhase> thermo) {
Solution::setThermo(thermo);
auto surf = std::dynamic_pointer_cast<SurfPhase>(thermo);
if (!surf) {
throw CanteraError("Interface::setThermo",
"Thermo object of type '{}' does not descend from SurfPhase.",
thermo->type());
}
m_surf = surf;
}
void Interface::setKinetics(shared_ptr<Kinetics> kinetics) {
Solution::setKinetics(kinetics);
auto surfkin = std::dynamic_pointer_cast<InterfaceKinetics>(kinetics);
if (!surfkin) {
throw CanteraError("Interface::setKinetics",
"Kinetics object of type '{}' does not descend from InterfaceKinetics.",
kinetics->kineticsType());
}
m_surfkin = surfkin;
}
shared_ptr<Interface> newInterface(const string& infile,
const string& name, const vector<string>& adjacent)
{
auto sol = newSolution(infile, name, "", adjacent);
auto iface = std::dynamic_pointer_cast<Interface>(sol);
if (!iface) {
auto rootNode = AnyMap::fromYamlFile(infile);
AnyMap& phaseNode = rootNode["phases"].getMapWhere("name", name);
throw InputFileError("newInterface", phaseNode,
"Phase definition does not define a surface phase");
}
return iface;
}
shared_ptr<Interface> newInterface(const string& infile,
const string& name, const vector<shared_ptr<Solution>>& adjacent)
{
auto rootNode = AnyMap::fromYamlFile(infile);
AnyMap& phaseNode = rootNode["phases"].getMapWhere("name", name);
return newInterface(phaseNode, rootNode, adjacent);
}
shared_ptr<Interface> newInterface(AnyMap& phaseNode, const AnyMap& rootNode,
const vector<shared_ptr<Solution>>& adjacent)
{
auto sol = newSolution(phaseNode, rootNode, "", adjacent);
auto iface = std::dynamic_pointer_cast<Interface>(sol);
if (!iface) {
throw InputFileError("newInterface", phaseNode,
"Phase definition does not define a surface phase");
}
return iface;
}
} // end namespace Cantera