Skip to content

Commit

Permalink
[clib] Create domain_type3 to interface with Domain1D::type
Browse files Browse the repository at this point in the history
  • Loading branch information
ischoegl authored and speth committed Mar 18, 2023
1 parent 8eb0639 commit ee28caa
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
2 changes: 2 additions & 0 deletions include/cantera/clib/ctonedim.h
Expand Up @@ -17,6 +17,7 @@ extern "C" {
CANTERA_CAPI int ct_clearOneDim();
CANTERA_CAPI int domain_del(int i);
CANTERA_CAPI int domain_type(int i);
CANTERA_CAPI int domain_type3(int i, size_t lennm, char* nm);
CANTERA_CAPI size_t domain_index(int i);
CANTERA_CAPI size_t domain_nComponents(int i);
CANTERA_CAPI size_t domain_nPoints(int i);
Expand Down Expand Up @@ -70,6 +71,7 @@ extern "C" {
CANTERA_CAPI int sim1D_setProfile(int i, int dom, int comp,
size_t np, const double* pos, size_t nv, const double* v);
CANTERA_CAPI int sim1D_setFlatProfile(int i, int dom, int comp, double v);
CANTERA_CAPI int sim1D_show(int i, const char* fname);
CANTERA_CAPI int sim1D_showSolution(int i, const char* fname);
CANTERA_CAPI int sim1D_setTimeStep(int i, double stepsize, size_t ns, const int* nsteps);
CANTERA_CAPI int sim1D_getInitialSoln(int i);
Expand Down
25 changes: 25 additions & 0 deletions src/clib/ctonedim.cpp
Expand Up @@ -63,6 +63,15 @@ extern "C" {
}
}

int domain_type3(int i, size_t lennm, char* nm)
{
try {
return static_cast<int>(copyString(DomainCabinet::item(i).type(), nm, lennm));
} catch (...) {
return handleAllExceptions(-1, ERR);
}
}

size_t domain_index(int i)
{
try {
Expand Down Expand Up @@ -525,6 +534,22 @@ extern "C" {
}
}

int sim1D_show(int i, const char* fname)
{
try {
string fn = string(fname);
if (fn == "-") {
SimCabinet::item(i).show();
} else {
ofstream fout(fname);
SimCabinet::item(i).show(fout);
}
return 0;
} catch (...) {
return handleAllExceptions(-1, ERR);
}
}

int sim1D_showSolution(int i, const char* fname)
{
try {
Expand Down

0 comments on commit ee28caa

Please sign in to comment.