Skip to content

Commit

Permalink
[oneD] Introduce StFlow::isFree
Browse files Browse the repository at this point in the history
  • Loading branch information
ischoegl authored and speth committed Mar 18, 2023
1 parent 4210e86 commit 4833a88
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 16 deletions.
4 changes: 2 additions & 2 deletions include/cantera/oneD/Domain1D.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
namespace Cantera
{

// domain types
// domain types (deprecated); to be removed after Cantera 3.0
const int cFlowType = 50;
const int cFreeFlow = 51;
const int cAxisymmetricStagnationFlow = 52;
Expand Down Expand Up @@ -552,7 +552,7 @@ class Domain1D
vector_fp m_z;
OneDim* m_container = nullptr;
size_t m_index;
int m_type = 0;
int m_type = 0; //!< @deprecated To be removed after Cantera 3.0

//! Starting location within the solution vector for unknowns that
//! correspond to this domain
Expand Down
6 changes: 6 additions & 0 deletions include/cantera/oneD/StFlow.h
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,12 @@ class StFlow : public Domain1D
m_isFree = false;
}

//! Return flag indicating whether flow is free
//! @see setFreeFlow setAxisymmetricFlow
bool isFree() {
return m_isFree;
}

//! Return the type of flow domain being represented, either "Free Flame" or
//! "Axisymmetric Stagnation".
//! @see setFreeFlow setAxisymmetricFlow
Expand Down
10 changes: 5 additions & 5 deletions src/oneD/Sim1D.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ void Sim1D::setFlatProfile(size_t dom, size_t comp, doublereal v)
void Sim1D::showSolution(ostream& s)
{
for (size_t n = 0; n < nDomains(); n++) {
if (domain(n).domainType() != cEmptyType) {
if (domain(n).type() != "empty") {
domain(n).showSolution_s(s, &m_x[start(n)]);
}
}
Expand All @@ -305,7 +305,7 @@ void Sim1D::showSolution(ostream& s)
void Sim1D::showSolution()
{
for (size_t n = 0; n < nDomains(); n++) {
if (domain(n).domainType() != cEmptyType) {
if (domain(n).type() != "empty") {
writelog("\n\n>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> "+domain(n).id()
+" <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n\n");
domain(n).showSolution(&m_x[start(n)]);
Expand Down Expand Up @@ -591,7 +591,7 @@ int Sim1D::setFixedTemperature(double t)
StFlow* d_free = dynamic_cast<StFlow*>(&domain(n));
size_t npnow = d.nPoints();
size_t nstart = znew.size();
if (d_free && d_free->domainType() == cFreeFlow) {
if (d_free && d_free->isFree()) {
for (size_t m = 0; m < npnow - 1; m++) {
bool fixedpt = false;
double t1 = value(n, 2, m);
Expand Down Expand Up @@ -669,7 +669,7 @@ double Sim1D::fixedTemperature()
double t_fixed = std::numeric_limits<double>::quiet_NaN();
for (size_t n = 0; n < nDomains(); n++) {
StFlow* d = dynamic_cast<StFlow*>(&domain(n));
if (d && d->domainType() == cFreeFlow && d->m_tfixed > 0) {
if (d && d->isFree() && d->m_tfixed > 0) {
t_fixed = d->m_tfixed;
break;
}
Expand All @@ -682,7 +682,7 @@ double Sim1D::fixedTemperatureLocation()
double z_fixed = std::numeric_limits<double>::quiet_NaN();
for (size_t n = 0; n < nDomains(); n++) {
StFlow* d = dynamic_cast<StFlow*>(&domain(n));
if (d && d->domainType() == cFreeFlow && d->m_tfixed > 0) {
if (d && d->isFree() && d->m_tfixed > 0) {
z_fixed = d->m_zfixed;
break;
}
Expand Down
16 changes: 8 additions & 8 deletions src/oneD/StFlow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ void StFlow::setGasAtMidpoint(const doublereal* x, size_t j)
}

bool StFlow::fixed_mdot() {
return (domainType() != cFreeFlow);
return !m_isFree;
}

void StFlow::_finalize(const doublereal* x)
Expand All @@ -321,7 +321,7 @@ void StFlow::_finalize(const doublereal* x)
solveEnergyEqn();
}

if (domainType() == cFreeFlow) {
if (m_isFree) {
// If the domain contains the temperature fixed point, make sure that it
// is correctly set. This may be necessary when the grid has been modified
// externally.
Expand Down Expand Up @@ -729,9 +729,9 @@ bool StFlow::componentActive(size_t n) const
{
switch (n) {
case c_offset_V: // spread_rate
return m_type != cFreeFlow;
return !m_isFree;
case c_offset_L: // lambda
return m_type != cFreeFlow;
return !m_isFree;
case c_offset_E: // eField
return false;
default:
Expand Down Expand Up @@ -999,14 +999,14 @@ void StFlow::evalRightBoundary(double* x, double* rsd, int* diag, double rdt)
}
rsd[index(c_offset_Y + rightExcessSpecies(), j)] = 1.0 - sum;
diag[index(c_offset_Y + rightExcessSpecies(), j)] = 0;
if (domainType() == cAxisymmetricStagnationFlow) {
if (!m_isFree) {
rsd[index(c_offset_U,j)] = rho_u(x,j);
if (m_do_energy[j]) {
rsd[index(c_offset_T,j)] = T(x,j);
} else {
rsd[index(c_offset_T, j)] = T(x,j) - T_fixed(j);
}
} else if (domainType() == cFreeFlow) {
} else {
rsd[index(c_offset_U,j)] = rho_u(x,j) - rho_u(x,j-1);
rsd[index(c_offset_T,j)] = T(x,j) - T(x,j-1);
}
Expand All @@ -1021,14 +1021,14 @@ void StFlow::evalContinuity(size_t j, double* x, double* rsd, int* diag, double
//
// d(\rho u)/dz + 2\rho V = 0
//----------------------------------------------
if (domainType() == cAxisymmetricStagnationFlow) {
if (!m_isFree) {
// Note that this propagates the mass flow rate information to the left
// (j+1 -> j) from the value specified at the right boundary. The
// lambda information propagates in the opposite direction.
rsd[index(c_offset_U,j)] =
-(rho_u(x,j+1) - rho_u(x,j))/m_dz[j]
-(density(j+1)*V(x,j+1) + density(j)*V(x,j));
} else if (domainType() == cFreeFlow) {
} else {
if (grid(j) > m_zfixed) {
rsd[index(c_offset_U,j)] =
- (rho_u(x,j) - rho_u(x,j-1))/m_dz[j-1]
Expand Down
2 changes: 1 addition & 1 deletion src/oneD/refine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ int Refiner::analyze(size_t n, const doublereal* z,
}

// Keep the point where the temperature is fixed
if (fflame && fflame->domainType() == cFreeFlow && z[j] == fflame->m_zfixed) {
if (fflame && fflame->isFree() && z[j] == fflame->m_zfixed) {
m_keep[j] = 1;
}
}
Expand Down

0 comments on commit 4833a88

Please sign in to comment.