[clib] Switch to ConnectorCabinet

This commit is contained in:
Ingmar Schoegl 2024-08-22 10:19:49 -05:00
parent 7659c1e9b4
commit f5455271c2

View File

@ -19,8 +19,7 @@ using namespace Cantera;
typedef Cabinet<ReactorBase> ReactorCabinet;
typedef Cabinet<ReactorNet> NetworkCabinet;
typedef Cabinet<FlowDevice> FlowDeviceCabinet;
typedef Cabinet<WallBase> WallCabinet;
typedef Cabinet<ConnectorNode> ConnectorCabinet;
typedef Cabinet<Func1> FuncCabinet;
typedef Cabinet<ThermoPhase> ThermoCabinet;
typedef Cabinet<Kinetics> KineticsCabinet;
@ -29,8 +28,7 @@ typedef Cabinet<ReactorSurface> ReactorSurfaceCabinet;
template<> ReactorCabinet* ReactorCabinet::s_storage = 0;
template<> NetworkCabinet* NetworkCabinet::s_storage = 0;
template<> FlowDeviceCabinet* FlowDeviceCabinet::s_storage = 0;
template<> WallCabinet* WallCabinet::s_storage = 0;
template<> ConnectorCabinet* ConnectorCabinet::s_storage = 0;
template<> ReactorSurfaceCabinet* ReactorSurfaceCabinet::s_storage = 0;
template<> FuncCabinet* FuncCabinet::s_storage; // defined in ctfunc.cpp
template<> ThermoCabinet* ThermoCabinet::s_storage; // defined in ct.cpp
@ -353,7 +351,7 @@ extern "C" {
int flowdev_new(const char* type, const char* name)
{
try {
return FlowDeviceCabinet::add(newFlowDevice(type, name));
return ConnectorCabinet::add(newFlowDevice(type, name));
} catch (...) {
return handleAllExceptions(-1, ERR);
}
@ -362,7 +360,7 @@ extern "C" {
int flowdev_del(int i)
{
try {
FlowDeviceCabinet::del(i);
ConnectorCabinet::del(i);
return 0;
} catch (...) {
return handleAllExceptions(-1, ERR);
@ -373,7 +371,7 @@ extern "C" {
{
try {
return static_cast<int>(
copyString(FlowDeviceCabinet::at(i)->name(), nbuf, len));
copyString(ConnectorCabinet::at(i)->name(), nbuf, len));
} catch (...) {
return handleAllExceptions(-1, ERR);
}
@ -382,7 +380,7 @@ extern "C" {
int flowdev_setName(int i, const char* name)
{
try {
FlowDeviceCabinet::at(i)->setName(name);
ConnectorCabinet::at(i)->setName(name);
return 0;
} catch (...) {
return handleAllExceptions(-1, ERR);
@ -392,8 +390,8 @@ extern "C" {
int flowdev_install(int i, int n, int m)
{
try {
bool ok = FlowDeviceCabinet::at(i)->install(*ReactorCabinet::at(n),
*ReactorCabinet::at(m));
bool ok = ConnectorCabinet::as<FlowDevice>(i)->install(
*ReactorCabinet::at(n), *ReactorCabinet::at(m));
if (!ok) {
throw CanteraError("flowdev_install",
"Could not install flow device.");
@ -407,8 +405,8 @@ extern "C" {
int flowdev_setPrimary(int i, int n)
{
try {
FlowDeviceCabinet::as<PressureController>(i)->setPrimary(
FlowDeviceCabinet::at(n).get());
ConnectorCabinet::as<PressureController>(i)->setPrimary(
ConnectorCabinet::as<FlowDevice>(n).get());
return 0;
} catch (...) {
return handleAllExceptions(-1, ERR);
@ -418,7 +416,7 @@ extern "C" {
double flowdev_massFlowRate(int i)
{
try {
return FlowDeviceCabinet::at(i)->massFlowRate();
return ConnectorCabinet::as<FlowDevice>(i)->massFlowRate();
} catch (...) {
return handleAllExceptions(DERR, DERR);
}
@ -427,7 +425,7 @@ extern "C" {
int flowdev_setMassFlowCoeff(int i, double v)
{
try {
FlowDeviceCabinet::as<MassFlowController>(i)->setMassFlowCoeff(v);
ConnectorCabinet::as<MassFlowController>(i)->setMassFlowCoeff(v);
return 0;
} catch (...) {
return handleAllExceptions(-1, ERR);
@ -437,7 +435,7 @@ extern "C" {
int flowdev_setValveCoeff(int i, double v)
{
try {
FlowDeviceCabinet::as<Valve>(i)->setValveCoeff(v);
ConnectorCabinet::as<Valve>(i)->setValveCoeff(v);
return 0;
} catch (...) {
return handleAllExceptions(-1, ERR);
@ -447,7 +445,7 @@ extern "C" {
int flowdev_setPressureCoeff(int i, double v)
{
try {
FlowDeviceCabinet::as<PressureController>(i)->setPressureCoeff(v);
ConnectorCabinet::as<PressureController>(i)->setPressureCoeff(v);
return 0;
} catch (...) {
return handleAllExceptions(-1, ERR);
@ -457,7 +455,8 @@ extern "C" {
int flowdev_setPressureFunction(int i, int n)
{
try {
FlowDeviceCabinet::at(i)->setPressureFunction(FuncCabinet::at(n).get());
ConnectorCabinet::as<FlowDevice>(i)->setPressureFunction(
FuncCabinet::at(n).get());
return 0;
} catch (...) {
return handleAllExceptions(-1, ERR);
@ -467,7 +466,8 @@ extern "C" {
int flowdev_setTimeFunction(int i, int n)
{
try {
FlowDeviceCabinet::at(i)->setTimeFunction(FuncCabinet::at(n).get());
ConnectorCabinet::as<FlowDevice>(i)->setTimeFunction(
FuncCabinet::at(n).get());
return 0;
} catch (...) {
return handleAllExceptions(-1, ERR);
@ -479,7 +479,7 @@ extern "C" {
int wall_new(const char* type, const char* name)
{
try {
return WallCabinet::add(newWall(type, name));
return ConnectorCabinet::add(newWall(type, name));
} catch (...) {
return handleAllExceptions(-1, ERR);
}
@ -488,7 +488,7 @@ extern "C" {
int wall_del(int i)
{
try {
WallCabinet::del(i);
ConnectorCabinet::del(i);
return 0;
} catch (...) {
return handleAllExceptions(-1, ERR);
@ -499,7 +499,7 @@ extern "C" {
{
try {
return static_cast<int>(
copyString(WallCabinet::at(i)->name(), nbuf, len));
copyString(ConnectorCabinet::at(i)->name(), nbuf, len));
} catch (...) {
return handleAllExceptions(-1, ERR);
}
@ -508,7 +508,7 @@ extern "C" {
int wall_setName(int i, const char* name)
{
try {
WallCabinet::at(i)->setName(name);
ConnectorCabinet::at(i)->setName(name);
return 0;
} catch (...) {
return handleAllExceptions(-1, ERR);
@ -518,8 +518,8 @@ extern "C" {
int wall_install(int i, int n, int m)
{
try {
WallCabinet::at(i)->install(*ReactorCabinet::at(n),
*ReactorCabinet::at(m));
ConnectorCabinet::as<Wall>(i)->install(
*ReactorCabinet::at(n), *ReactorCabinet::at(m));
return 0;
} catch (...) {
return handleAllExceptions(-1, ERR);
@ -529,7 +529,7 @@ extern "C" {
double wall_expansionRate(int i)
{
try {
return WallCabinet::at(i)->expansionRate();
return ConnectorCabinet::as<Wall>(i)->expansionRate();
} catch (...) {
return handleAllExceptions(DERR, DERR);
}
@ -538,7 +538,7 @@ extern "C" {
double wall_heatRate(int i)
{
try {
return WallCabinet::at(i)->heatRate();
return ConnectorCabinet::as<Wall>(i)->heatRate();
} catch (...) {
return handleAllExceptions(DERR, DERR);
}
@ -547,7 +547,7 @@ extern "C" {
double wall_area(int i)
{
try {
return WallCabinet::at(i)->area();
return ConnectorCabinet::as<Wall>(i)->area();
} catch (...) {
return handleAllExceptions(DERR, DERR);
}
@ -556,7 +556,7 @@ extern "C" {
int wall_setArea(int i, double v)
{
try {
WallCabinet::at(i)->setArea(v);
ConnectorCabinet::as<Wall>(i)->setArea(v);
return 0;
} catch (...) {
return handleAllExceptions(-1, ERR);
@ -566,7 +566,7 @@ extern "C" {
int wall_setThermalResistance(int i, double rth)
{
try {
WallCabinet::as<Wall>(i)->setThermalResistance(rth);
ConnectorCabinet::as<Wall>(i)->setThermalResistance(rth);
return 0;
} catch (...) {
return handleAllExceptions(-1, ERR);
@ -576,7 +576,7 @@ extern "C" {
int wall_setHeatTransferCoeff(int i, double u)
{
try {
WallCabinet::as<Wall>(i)->setHeatTransferCoeff(u);
ConnectorCabinet::as<Wall>(i)->setHeatTransferCoeff(u);
return 0;
} catch (...) {
return handleAllExceptions(-1, ERR);
@ -586,7 +586,7 @@ extern "C" {
int wall_setHeatFlux(int i, int n)
{
try {
WallCabinet::as<Wall>(i)->setHeatFlux(FuncCabinet::at(n).get());
ConnectorCabinet::as<Wall>(i)->setHeatFlux(FuncCabinet::at(n).get());
return 0;
} catch (...) {
return handleAllExceptions(-1, ERR);
@ -596,7 +596,7 @@ extern "C" {
int wall_setExpansionRateCoeff(int i, double k)
{
try {
WallCabinet::as<Wall>(i)->setExpansionRateCoeff(k);
ConnectorCabinet::as<Wall>(i)->setExpansionRateCoeff(k);
return 0;
} catch (...) {
return handleAllExceptions(-1, ERR);
@ -606,7 +606,7 @@ extern "C" {
int wall_setVelocity(int i, int n)
{
try {
WallCabinet::as<Wall>(i)->setVelocity(FuncCabinet::at(n).get());
ConnectorCabinet::as<Wall>(i)->setVelocity(FuncCabinet::at(n).get());
return 0;
} catch (...) {
return handleAllExceptions(-1, ERR);
@ -616,7 +616,7 @@ extern "C" {
int wall_setEmissivity(int i, double epsilon)
{
try {
WallCabinet::as<Wall>(i)->setEmissivity(epsilon);
ConnectorCabinet::as<Wall>(i)->setEmissivity(epsilon);
return 0;
} catch (...) {
return handleAllExceptions(-1, ERR);
@ -626,7 +626,7 @@ extern "C" {
int wall_ready(int i)
{
try {
return int(WallCabinet::at(i)->ready());
return int(ConnectorCabinet::as<Wall>(i)->ready());
} catch (...) {
return handleAllExceptions(-1, ERR);
}
@ -727,8 +727,7 @@ extern "C" {
try {
ReactorCabinet::clear();
NetworkCabinet::clear();
FlowDeviceCabinet::clear();
WallCabinet::clear();
ConnectorCabinet::clear();
ReactorSurfaceCabinet::clear();
return 0;
} catch (...) {