Skip to content

Commit 479d12a

Browse files
committed
[clib] Retain stflow_ routines but throw error
1 parent bbfa757 commit 479d12a

File tree

4 files changed

+104
-1
lines changed

4 files changed

+104
-1
lines changed

include/cantera/clib/ctonedim.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,16 @@ extern "C" {
6868
size_t m, const double* temp);
6969
CANTERA_CAPI int flow1D_solveEnergyEqn(int i, int flag);
7070

71+
//! @todo: Remove all functions with `stflow` prefix after Cantera 3.1
72+
CANTERA_CAPI int stflow_new(int iph, int ikin, int itr, int itype);
73+
CANTERA_CAPI int stflow_setTransport(int i, int itr);
74+
CANTERA_CAPI int stflow_enableSoret(int i, int iSoret);
75+
CANTERA_CAPI int stflow_setPressure(int i, double p);
76+
CANTERA_CAPI double stflow_pressure(int i);
77+
CANTERA_CAPI int stflow_setFixedTempProfile(int i, size_t n, const double* pos,
78+
size_t m, const double* temp);
79+
CANTERA_CAPI int stflow_solveEnergyEqn(int i, int flag);
80+
7181
CANTERA_CAPI int sim1D_new(size_t nd, const int* domains);
7282
CANTERA_CAPI int sim1D_del(int i);
7383
CANTERA_CAPI int sim1D_setValue(int i, int dom, int comp, int localPoint, double value);

src/clib/ctonedim.cpp

Lines changed: 72 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ extern "C" {
398398
}
399399
}
400400

401-
//------------------ stagnation flow domains --------------------
401+
//------------------ flow domains --------------------
402402

403403
int flow1D_new(int iph, int ikin, int itr, int itype)
404404
{
@@ -490,6 +490,77 @@ extern "C" {
490490
}
491491
}
492492

493+
int stflow_new(int iph, int ikin, int itr, int itype)
494+
{
495+
try {
496+
throw NotImplementedError("stflow_new",
497+
"Function replaced by 'flow1D_new'.");
498+
} catch (...) {
499+
return handleAllExceptions(-1, ERR);
500+
}
501+
}
502+
503+
int stflow_setTransport(int i, int itr)
504+
{
505+
try {
506+
throw NotImplementedError("stflow_setTransport",
507+
"Function replaced by 'flow1D_setTransport'.");
508+
} catch (...) {
509+
return handleAllExceptions(-1, ERR);
510+
}
511+
}
512+
513+
int stflow_enableSoret(int i, int iSoret)
514+
{
515+
try {
516+
throw NotImplementedError("stflow_enableSoret",
517+
"Function replaced by 'flow1D_enableSoret'.");
518+
} catch (...) {
519+
return handleAllExceptions(-1, ERR);
520+
}
521+
}
522+
523+
int stflow_setPressure(int i, double p)
524+
{
525+
try {
526+
throw NotImplementedError("stflow_setPressure",
527+
"Function replaced by 'flow1D_setPressure'.");
528+
} catch (...) {
529+
return handleAllExceptions(-1, ERR);
530+
}
531+
}
532+
533+
double stflow_pressure(int i)
534+
{
535+
try {
536+
throw NotImplementedError("stflow_pressure",
537+
"Function replaced by 'flow1D_pressure'.");
538+
} catch (...) {
539+
return handleAllExceptions(DERR, DERR);
540+
}
541+
}
542+
543+
int stflow_setFixedTempProfile(int i, size_t n, const double* pos,
544+
size_t m, const double* temp)
545+
{
546+
try {
547+
throw NotImplementedError("stflow_setFixedTempProfile",
548+
"Function replaced by 'flow1D_setFixedTempProfile'.");
549+
} catch (...) {
550+
return handleAllExceptions(-1, ERR);
551+
}
552+
}
553+
554+
int stflow_solveEnergyEqn(int i, int flag)
555+
{
556+
try {
557+
throw NotImplementedError("stflow_solveEnergyEqn",
558+
"Function replaced by 'flow1D_solveEnergyEqn'.");
559+
} catch (...) {
560+
return handleAllExceptions(-1, ERR);
561+
}
562+
}
563+
493564
//------------------- Sim1D --------------------------------------
494565

495566
int sim1D_new(size_t nd, const int* domains)

test/clib/test_ctonedim.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,3 +254,25 @@ TEST(ctonedim, freeflame_from_parts)
254254
Tprev = T;
255255
}
256256
}
257+
258+
TEST(ctonedim, stflow_tests)
259+
{
260+
//! @todo: To be removed after Cantera 3.1
261+
ct_resetStorage();
262+
auto gas = newThermo("h2o2.yaml", "ohmech");
263+
264+
int sol = soln_newSolution("h2o2.yaml", "ohmech", "default");
265+
int ph = soln_thermo(sol);
266+
int kin = soln_kinetics(sol);
267+
int tr = soln_transport(sol);
268+
269+
// spot check some errors
270+
int itype = 2; // free flow
271+
int ret = stflow_new(ph, kin, tr, itype);
272+
ASSERT_EQ(ret, -1); // -1 is an error code
273+
274+
int flow = flow1D_new(ph, kin, tr, itype);
275+
ASSERT_EQ(stflow_setTransport(flow, tr), -1);
276+
ASSERT_EQ(stflow_pressure(flow), DERR); // DERR is an error code
277+
ASSERT_EQ(stflow_setPressure(flow, OneAtm), -1);
278+
}

test/clib/utils.h

Whitespace-only changes.

0 commit comments

Comments
 (0)