Skip to content

Commit

Permalink
[clib] Explose zeroD object names
Browse files Browse the repository at this point in the history
  • Loading branch information
ischoegl committed Aug 8, 2024
1 parent ba5b3ab commit d39ef1e
Show file tree
Hide file tree
Showing 2 changed files with 87 additions and 0 deletions.
8 changes: 8 additions & 0 deletions include/cantera/clib/ctreactor.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ extern "C" {
CANTERA_CAPI int reactor_new(const char* type); //!< @deprecated: remove after 3.1
CANTERA_CAPI int reactor_new3(const char* type, int n, const char* name);
CANTERA_CAPI int reactor_del(int i);
CANTERA_CAPI int reactor_name(int i, int len, char* nbuf);
CANTERA_CAPI int reactor_setName(int i, const char* name);
CANTERA_CAPI int reactor_setInitialVolume(int i, double v);
CANTERA_CAPI int reactor_setChemistry(int i, int cflag);
CANTERA_CAPI int reactor_setEnergy(int i, int eflag);
Expand Down Expand Up @@ -50,7 +52,10 @@ extern "C" {
CANTERA_CAPI double reactornet_sensitivity(int i, const char* v, int p, int r);

CANTERA_CAPI int flowdev_new(const char* type);
CANTERA_CAPI int flowdev_new3(const char* type, const char* name);
CANTERA_CAPI int flowdev_del(int i);
CANTERA_CAPI int flowdev_name(int i, int len, char* nbuf);
CANTERA_CAPI int flowdev_setName(int i, const char* name);
CANTERA_CAPI int flowdev_install(int i, int n, int m);
CANTERA_CAPI int flowdev_setPrimary(int i, int n);
CANTERA_CAPI double flowdev_massFlowRate(int i);
Expand All @@ -61,7 +66,10 @@ extern "C" {
CANTERA_CAPI int flowdev_setTimeFunction(int i, int n);

CANTERA_CAPI int wall_new(const char* type);
CANTERA_CAPI int wall_new3(const char* type, const char* name);
CANTERA_CAPI int wall_del(int i);
CANTERA_CAPI int wall_name(int i, int len, char* nbuf);
CANTERA_CAPI int wall_setName(int i, const char* name);
CANTERA_CAPI int wall_install(int i, int n, int m);
CANTERA_CAPI double wall_expansionRate(int i);
CANTERA_CAPI double wall_heatRate(int i);
Expand Down
79 changes: 79 additions & 0 deletions src/clib/ctreactor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include "cantera/thermo/ThermoPhase.h"
#include "cantera/kinetics/Kinetics.h"
#include "cantera/zerodim.h"
#include "cantera/base/stringUtils.h"
#include "clib_utils.h"

using namespace Cantera;
Expand Down Expand Up @@ -68,6 +69,26 @@ extern "C" {
}
}

int reactor_name(int i, int len, char* nbuf)
{
try {
return static_cast<int>(
copyString(ReactorCabinet::item(i).name(), nbuf, len));
} catch (...) {
return handleAllExceptions(-1, ERR);
}
}

int reactor_setName(int i, const char* name)
{
try {
ReactorCabinet::item(i).setName(name);
return 0;
} catch (...) {
return handleAllExceptions(-1, ERR);
}
}

int reactor_setInitialVolume(int i, double v)
{
try {
Expand Down Expand Up @@ -367,6 +388,15 @@ extern "C" {
}
}

int flowdev_new3(const char* type, const char* name)
{
try {
return FlowDeviceCabinet::add(newFlowDevice(type, name));
} catch (...) {
return handleAllExceptions(-1, ERR);
}
}

int flowdev_del(int i)
{
try {
Expand All @@ -377,6 +407,26 @@ extern "C" {
}
}

int flowdev_name(int i, int len, char* nbuf)
{
try {
return static_cast<int>(
copyString(FlowDeviceCabinet::item(i).name(), nbuf, len));
} catch (...) {
return handleAllExceptions(-1, ERR);
}
}

int flowdev_setName(int i, const char* name)
{
try {
FlowDeviceCabinet::item(i).setName(name);
return 0;
} catch (...) {
return handleAllExceptions(-1, ERR);
}
}

int flowdev_install(int i, int n, int m)
{
try {
Expand Down Expand Up @@ -473,6 +523,15 @@ extern "C" {
}
}

int wall_new3(const char* type, const char* name)
{
try {
return WallCabinet::add(newWall(type, name));
} catch (...) {
return handleAllExceptions(-1, ERR);
}
}

int wall_del(int i)
{
try {
Expand All @@ -483,6 +542,26 @@ extern "C" {
}
}

int wall_name(int i, int len, char* nbuf)
{
try {
return static_cast<int>(
copyString(WallCabinet::item(i).name(), nbuf, len));
} catch (...) {
return handleAllExceptions(-1, ERR);
}
}

int wall_setName(int i, const char* name)
{
try {
WallCabinet::item(i).setName(name);
return 0;
} catch (...) {
return handleAllExceptions(-1, ERR);
}
}

int wall_install(int i, int n, int m)
{
try {
Expand Down

0 comments on commit d39ef1e

Please sign in to comment.