Skip to content

Commit

Permalink
[clib] Retain stflow_ routines but throw error
Browse files Browse the repository at this point in the history
  • Loading branch information
ischoegl authored and speth committed Jun 23, 2024
1 parent 37ad4e9 commit ded4513
Show file tree
Hide file tree
Showing 4 changed files with 104 additions and 1 deletion.
10 changes: 10 additions & 0 deletions include/cantera/clib/ctonedim.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,16 @@ extern "C" {
size_t m, const double* temp);
CANTERA_CAPI int flow1D_solveEnergyEqn(int i, int flag);

//! @todo: Remove all functions with `stflow` prefix after Cantera 3.1
CANTERA_CAPI int stflow_new(int iph, int ikin, int itr, int itype);
CANTERA_CAPI int stflow_setTransport(int i, int itr);
CANTERA_CAPI int stflow_enableSoret(int i, int iSoret);
CANTERA_CAPI int stflow_setPressure(int i, double p);
CANTERA_CAPI double stflow_pressure(int i);
CANTERA_CAPI int stflow_setFixedTempProfile(int i, size_t n, const double* pos,
size_t m, const double* temp);
CANTERA_CAPI int stflow_solveEnergyEqn(int i, int flag);

CANTERA_CAPI int sim1D_new(size_t nd, const int* domains);
CANTERA_CAPI int sim1D_del(int i);
CANTERA_CAPI int sim1D_setValue(int i, int dom, int comp, int localPoint, double value);
Expand Down
73 changes: 72 additions & 1 deletion src/clib/ctonedim.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ extern "C" {
}
}

//------------------ stagnation flow domains --------------------
//------------------ flow domains --------------------

int flow1D_new(int iph, int ikin, int itr, int itype)
{
Expand Down Expand Up @@ -490,6 +490,77 @@ extern "C" {
}
}

int stflow_new(int iph, int ikin, int itr, int itype)
{
try {
throw NotImplementedError("stflow_new",
"Function replaced by 'flow1D_new'.");
} catch (...) {
return handleAllExceptions(-1, ERR);
}
}

int stflow_setTransport(int i, int itr)
{
try {
throw NotImplementedError("stflow_setTransport",
"Function replaced by 'flow1D_setTransport'.");
} catch (...) {
return handleAllExceptions(-1, ERR);
}
}

int stflow_enableSoret(int i, int iSoret)
{
try {
throw NotImplementedError("stflow_enableSoret",
"Function replaced by 'flow1D_enableSoret'.");
} catch (...) {
return handleAllExceptions(-1, ERR);
}
}

int stflow_setPressure(int i, double p)
{
try {
throw NotImplementedError("stflow_setPressure",
"Function replaced by 'flow1D_setPressure'.");
} catch (...) {
return handleAllExceptions(-1, ERR);
}
}

double stflow_pressure(int i)
{
try {
throw NotImplementedError("stflow_pressure",
"Function replaced by 'flow1D_pressure'.");
} catch (...) {
return handleAllExceptions(DERR, DERR);
}
}

int stflow_setFixedTempProfile(int i, size_t n, const double* pos,
size_t m, const double* temp)
{
try {
throw NotImplementedError("stflow_setFixedTempProfile",
"Function replaced by 'flow1D_setFixedTempProfile'.");
} catch (...) {
return handleAllExceptions(-1, ERR);
}
}

int stflow_solveEnergyEqn(int i, int flag)
{
try {
throw NotImplementedError("stflow_solveEnergyEqn",
"Function replaced by 'flow1D_solveEnergyEqn'.");
} catch (...) {
return handleAllExceptions(-1, ERR);
}
}

//------------------- Sim1D --------------------------------------

int sim1D_new(size_t nd, const int* domains)
Expand Down
22 changes: 22 additions & 0 deletions test/clib/test_ctonedim.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -254,3 +254,25 @@ TEST(ctonedim, freeflame_from_parts)
Tprev = T;
}
}

TEST(ctonedim, stflow_tests)
{
//! @todo: To be removed after Cantera 3.1
ct_resetStorage();
auto gas = newThermo("h2o2.yaml", "ohmech");

int sol = soln_newSolution("h2o2.yaml", "ohmech", "default");
int ph = soln_thermo(sol);
int kin = soln_kinetics(sol);
int tr = soln_transport(sol);

// spot check some errors
int itype = 2; // free flow
int ret = stflow_new(ph, kin, tr, itype);
ASSERT_EQ(ret, -1); // -1 is an error code

int flow = flow1D_new(ph, kin, tr, itype);
ASSERT_EQ(stflow_setTransport(flow, tr), -1);
ASSERT_EQ(stflow_pressure(flow), DERR); // DERR is an error code
ASSERT_EQ(stflow_setPressure(flow, OneAtm), -1);
}
Empty file added test/clib/utils.h
Empty file.

0 comments on commit ded4513

Please sign in to comment.