Skip to content

Commit 1d51570

Browse files
committed
[oneD] Reorder content for named doxygen section
1 parent 75dd1ee commit 1d51570

File tree

2 files changed

+113
-105
lines changed

2 files changed

+113
-105
lines changed

include/cantera/oneD/Flow1D.h

Lines changed: 41 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -316,11 +316,48 @@ class Flow1D : public Domain1D
316316
AnyMap getMeta() const override;
317317
void setMeta(const AnyMap& state) override;
318318

319+
//! @name Updates of cached properties
320+
//! These methods are called by eval() to update cached properties and data that are
321+
//! used for the evaluation of the governing equations.
322+
//! @{
323+
319324
//! Update the properties (thermo, transport, and diffusion flux).
320325
//! This function is called in eval after the points which need
321326
//! to be updated are defined.
322327
virtual void updateProperties(size_t jg, double* x, size_t jmin, size_t jmax);
323328

329+
/**
330+
* Update the thermodynamic properties from point j0 to point j1
331+
* (inclusive), based on solution x.
332+
*
333+
* The gas state is set to be consistent with the solution at the
334+
* points from j0 to j1.
335+
*
336+
* Properties that are computed and cached are:
337+
* * #m_rho (density)
338+
* * #m_wtm (mean molecular weight)
339+
* * #m_cp (specific heat capacity)
340+
* * #m_hk (species specific enthalpies)
341+
* * #m_wdot (species production rates)
342+
*/
343+
void updateThermo(const double* x, size_t j0, size_t j1) {
344+
for (size_t j = j0; j <= j1; j++) {
345+
setGas(x,j);
346+
m_rho[j] = m_thermo->density();
347+
m_wtm[j] = m_thermo->meanMolecularWeight();
348+
m_cp[j] = m_thermo->cp_mass();
349+
m_thermo->getPartialMolarEnthalpies(&m_hk(0, j));
350+
m_kin->getNetProductionRates(&m_wdot(0, j));
351+
}
352+
}
353+
354+
//! Update the transport properties at grid points in the range from `j0`
355+
//! to `j1`, based on solution `x`.
356+
virtual void updateTransport(double* x, size_t j0, size_t j1);
357+
358+
//! Update the diffusive mass fluxes.
359+
virtual void updateDiffFluxes(const double* x, size_t j0, size_t j1);
360+
324361
/**
325362
* Computes the radiative heat loss vector over points jmin to jmax and stores
326363
* the data in the qdotRadiation variable.
@@ -338,8 +375,11 @@ class Flow1D : public Domain1D
338375
*/
339376
void computeRadiation(double* x, size_t jmin, size_t jmax);
340377

378+
//! @}
379+
341380
//! @name Governing Equations
342-
//! Methods are used to evaluate residuals for each of the governing equations.
381+
//! Methods called by eval() to calculate residuals for individual governing
382+
//! equations.
343383
//! @{
344384

345385
/**
@@ -474,31 +514,6 @@ class Flow1D : public Domain1D
474514
//! @deprecated To be removed after Cantera 3.0.
475515
virtual void evalContinuity(size_t j, double* x, double* r, int* diag, double rdt);
476516

477-
/**
478-
* Update the thermodynamic properties from point j0 to point j1
479-
* (inclusive), based on solution x.
480-
*
481-
* The gas state is set to be consistent with the solution at the
482-
* points from j0 to j1.
483-
*
484-
* Properties that are computed and cached are:
485-
* * #m_rho (density)
486-
* * #m_wtm (mean molecular weight)
487-
* * #m_cp (specific heat capacity)
488-
* * #m_hk (species specific enthalpies)
489-
* * #m_wdot (species production rates)
490-
*/
491-
void updateThermo(const double* x, size_t j0, size_t j1) {
492-
for (size_t j = j0; j <= j1; j++) {
493-
setGas(x,j);
494-
m_rho[j] = m_thermo->density();
495-
m_wtm[j] = m_thermo->meanMolecularWeight();
496-
m_cp[j] = m_thermo->cp_mass();
497-
m_thermo->getPartialMolarEnthalpies(&m_hk(0, j));
498-
m_kin->getNetProductionRates(&m_wdot(0, j));
499-
}
500-
}
501-
502517
//! @name Solution components
503518
//! @{
504519

@@ -588,9 +603,6 @@ class Flow1D : public Domain1D
588603
return m*m_nsp*m_nsp + m_nsp*j + k;
589604
}
590605

591-
//! Update the diffusive mass fluxes.
592-
virtual void updateDiffFluxes(const double* x, size_t j0, size_t j1);
593-
594606
//! Get the gradient of species specific molar enthalpies
595607
virtual void grad_hk(const double* x, size_t j);
596608

@@ -669,10 +681,6 @@ class Flow1D : public Domain1D
669681
bool m_isFree;
670682
bool m_usesLambda;
671683

672-
//! Update the transport properties at grid points in the range from `j0`
673-
//! to `j1`, based on solution `x`.
674-
virtual void updateTransport(double* x, size_t j0, size_t j1);
675-
676684
public:
677685
//! Location of the point where temperature is fixed
678686
double m_zfixed = Undef;

src/oneD/Flow1D.cpp

Lines changed: 72 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,78 @@ void Flow1D::updateProperties(size_t jg, double* x, size_t jmin, size_t jmax)
355355
updateDiffFluxes(x, j0, j1);
356356
}
357357

358+
void Flow1D::updateTransport(double* x, size_t j0, size_t j1)
359+
{
360+
if (m_do_multicomponent) {
361+
for (size_t j = j0; j < j1; j++) {
362+
setGasAtMidpoint(x,j);
363+
double wtm = m_thermo->meanMolecularWeight();
364+
double rho = m_thermo->density();
365+
m_visc[j] = (m_dovisc ? m_trans->viscosity() : 0.0);
366+
m_trans->getMultiDiffCoeffs(m_nsp, &m_multidiff[mindex(0,0,j)]);
367+
368+
// Use m_diff as storage for the factor outside the summation
369+
for (size_t k = 0; k < m_nsp; k++) {
370+
m_diff[k+j*m_nsp] = m_wt[k] * rho / (wtm*wtm);
371+
}
372+
373+
m_tcon[j] = m_trans->thermalConductivity();
374+
if (m_do_soret) {
375+
m_trans->getThermalDiffCoeffs(m_dthermal.ptrColumn(0) + j*m_nsp);
376+
}
377+
}
378+
} else { // mixture averaged transport
379+
for (size_t j = j0; j < j1; j++) {
380+
setGasAtMidpoint(x,j);
381+
m_visc[j] = (m_dovisc ? m_trans->viscosity() : 0.0);
382+
m_trans->getMixDiffCoeffs(&m_diff[j*m_nsp]);
383+
m_tcon[j] = m_trans->thermalConductivity();
384+
}
385+
}
386+
}
387+
388+
void Flow1D::updateDiffFluxes(const double* x, size_t j0, size_t j1)
389+
{
390+
if (m_do_multicomponent) {
391+
for (size_t j = j0; j < j1; j++) {
392+
double dz = z(j+1) - z(j);
393+
for (size_t k = 0; k < m_nsp; k++) {
394+
double sum = 0.0;
395+
for (size_t m = 0; m < m_nsp; m++) {
396+
sum += m_wt[m] * m_multidiff[mindex(k,m,j)] * (X(x,m,j+1)-X(x,m,j));
397+
}
398+
m_flux(k,j) = sum * m_diff[k+j*m_nsp] / dz;
399+
}
400+
}
401+
} else {
402+
for (size_t j = j0; j < j1; j++) {
403+
double sum = 0.0;
404+
double wtm = m_wtm[j];
405+
double rho = density(j);
406+
double dz = z(j+1) - z(j);
407+
for (size_t k = 0; k < m_nsp; k++) {
408+
m_flux(k,j) = m_wt[k]*(rho*m_diff[k+m_nsp*j]/wtm);
409+
m_flux(k,j) *= (X(x,k,j) - X(x,k,j+1))/dz;
410+
sum -= m_flux(k,j);
411+
}
412+
// correction flux to insure that \sum_k Y_k V_k = 0.
413+
for (size_t k = 0; k < m_nsp; k++) {
414+
m_flux(k,j) += sum*Y(x,k,j);
415+
}
416+
}
417+
}
418+
419+
if (m_do_soret) {
420+
for (size_t m = j0; m < j1; m++) {
421+
double gradlogT = 2.0 * (T(x,m+1) - T(x,m)) /
422+
((T(x,m+1) + T(x,m)) * (z(m+1) - z(m)));
423+
for (size_t k = 0; k < m_nsp; k++) {
424+
m_flux(k,m) -= m_dthermal(k,m)*gradlogT;
425+
}
426+
}
427+
}
428+
}
429+
358430
void Flow1D::computeRadiation(double* x, size_t jmin, size_t jmax)
359431
{
360432
// Variable definitions for the Planck absorption coefficient and the
@@ -611,36 +683,6 @@ void Flow1D::evalContinuity(size_t j, double* x, double* rsd, int* diag, double
611683
"Overloaded by StFlow; to be removed after Cantera 3.0");
612684
}
613685

614-
void Flow1D::updateTransport(double* x, size_t j0, size_t j1)
615-
{
616-
if (m_do_multicomponent) {
617-
for (size_t j = j0; j < j1; j++) {
618-
setGasAtMidpoint(x,j);
619-
double wtm = m_thermo->meanMolecularWeight();
620-
double rho = m_thermo->density();
621-
m_visc[j] = (m_dovisc ? m_trans->viscosity() : 0.0);
622-
m_trans->getMultiDiffCoeffs(m_nsp, &m_multidiff[mindex(0,0,j)]);
623-
624-
// Use m_diff as storage for the factor outside the summation
625-
for (size_t k = 0; k < m_nsp; k++) {
626-
m_diff[k+j*m_nsp] = m_wt[k] * rho / (wtm*wtm);
627-
}
628-
629-
m_tcon[j] = m_trans->thermalConductivity();
630-
if (m_do_soret) {
631-
m_trans->getThermalDiffCoeffs(m_dthermal.ptrColumn(0) + j*m_nsp);
632-
}
633-
}
634-
} else { // mixture averaged transport
635-
for (size_t j = j0; j < j1; j++) {
636-
setGasAtMidpoint(x,j);
637-
m_visc[j] = (m_dovisc ? m_trans->viscosity() : 0.0);
638-
m_trans->getMixDiffCoeffs(&m_diff[j*m_nsp]);
639-
m_tcon[j] = m_trans->thermalConductivity();
640-
}
641-
}
642-
}
643-
644686
void Flow1D::show(const double* x)
645687
{
646688
writelog(" Pressure: {:10.4g} Pa\n", m_press);
@@ -658,48 +700,6 @@ void Flow1D::show(const double* x)
658700
}
659701
}
660702

661-
void Flow1D::updateDiffFluxes(const double* x, size_t j0, size_t j1)
662-
{
663-
if (m_do_multicomponent) {
664-
for (size_t j = j0; j < j1; j++) {
665-
double dz = z(j+1) - z(j);
666-
for (size_t k = 0; k < m_nsp; k++) {
667-
double sum = 0.0;
668-
for (size_t m = 0; m < m_nsp; m++) {
669-
sum += m_wt[m] * m_multidiff[mindex(k,m,j)] * (X(x,m,j+1)-X(x,m,j));
670-
}
671-
m_flux(k,j) = sum * m_diff[k+j*m_nsp] / dz;
672-
}
673-
}
674-
} else {
675-
for (size_t j = j0; j < j1; j++) {
676-
double sum = 0.0;
677-
double wtm = m_wtm[j];
678-
double rho = density(j);
679-
double dz = z(j+1) - z(j);
680-
for (size_t k = 0; k < m_nsp; k++) {
681-
m_flux(k,j) = m_wt[k]*(rho*m_diff[k+m_nsp*j]/wtm);
682-
m_flux(k,j) *= (X(x,k,j) - X(x,k,j+1))/dz;
683-
sum -= m_flux(k,j);
684-
}
685-
// correction flux to insure that \sum_k Y_k V_k = 0.
686-
for (size_t k = 0; k < m_nsp; k++) {
687-
m_flux(k,j) += sum*Y(x,k,j);
688-
}
689-
}
690-
}
691-
692-
if (m_do_soret) {
693-
for (size_t m = j0; m < j1; m++) {
694-
double gradlogT = 2.0 * (T(x,m+1) - T(x,m)) /
695-
((T(x,m+1) + T(x,m)) * (z(m+1) - z(m)));
696-
for (size_t k = 0; k < m_nsp; k++) {
697-
m_flux(k,m) -= m_dthermal(k,m)*gradlogT;
698-
}
699-
}
700-
}
701-
}
702-
703703
string Flow1D::componentName(size_t n) const
704704
{
705705
switch (n) {

0 commit comments

Comments
 (0)