Skip to content

Commit 065704e

Browse files
committed
[oneD] Reorder content for named doxygen section
1 parent b72d3d1 commit 065704e

File tree

2 files changed

+135
-129
lines changed

2 files changed

+135
-129
lines changed

include/cantera/oneD/Flow1D.h

Lines changed: 41 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,6 @@ class Flow1D : public Domain1D
172172
//! Returns true if the specified component is an active part of the solver state
173173
virtual bool componentActive(size_t n) const;
174174

175-
//! Print the solution.
176175
void show(const double* x) override;
177176

178177
shared_ptr<SolutionArray> asArray(const double* soln) const override;
@@ -396,6 +395,43 @@ class Flow1D : public Domain1D
396395
AnyMap getMeta() const override;
397396
void setMeta(const AnyMap& state) override;
398397

398+
//! @name Updates of cached properties
399+
//! These methods are called by eval() to update cached properties and data that are
400+
//! used for the evaluation of the governing equations.
401+
//! @{
402+
403+
/**
404+
* Update the thermodynamic properties from point j0 to point j1
405+
* (inclusive), based on solution x.
406+
*
407+
* The gas state is set to be consistent with the solution at the
408+
* points from j0 to j1.
409+
*
410+
* Properties that are computed and cached are:
411+
* * #m_rho (density)
412+
* * #m_wtm (mean molecular weight)
413+
* * #m_cp (specific heat capacity)
414+
* * #m_hk (species specific enthalpies)
415+
* * #m_wdot (species production rates)
416+
*/
417+
void updateThermo(const double* x, size_t j0, size_t j1) {
418+
for (size_t j = j0; j <= j1; j++) {
419+
setGas(x,j);
420+
m_rho[j] = m_thermo->density();
421+
m_wtm[j] = m_thermo->meanMolecularWeight();
422+
m_cp[j] = m_thermo->cp_mass();
423+
m_thermo->getPartialMolarEnthalpies(&m_hk(0, j));
424+
m_kin->getNetProductionRates(&m_wdot(0, j));
425+
}
426+
}
427+
428+
//! Update the transport properties at grid points in the range from `j0`
429+
//! to `j1`, based on solution `x`.
430+
virtual void updateTransport(double* x, size_t j0, size_t j1);
431+
432+
//! Update the diffusive mass fluxes.
433+
virtual void updateDiffFluxes(const double* x, size_t j0, size_t j1);
434+
399435
//! Update the properties (thermo, transport, and diffusion flux).
400436
//! This function is called in eval after the points which need
401437
//! to be updated are defined.
@@ -418,9 +454,11 @@ class Flow1D : public Domain1D
418454
*/
419455
void computeRadiation(double* x, size_t jmin, size_t jmax);
420456

457+
//! @}
458+
421459
//! @name Governing Equations
422-
//! Methods are used to evaluate residuals for each of the governing equations.
423-
//! @{
460+
//! Methods called by eval() to calculate residuals for individual governing
461+
//! equations.
424462

425463
/**
426464
* Evaluate the continuity equation residual.
@@ -572,31 +610,6 @@ class Flow1D : public Domain1D
572610
virtual void evalUo(double* x, double* rsd, int* diag,
573611
double rdt, size_t jmin, size_t jmax);
574612

575-
/**
576-
* Update the thermodynamic properties from point j0 to point j1
577-
* (inclusive), based on solution x.
578-
*
579-
* The gas state is set to be consistent with the solution at the
580-
* points from j0 to j1.
581-
*
582-
* Properties that are computed and cached are:
583-
* * #m_rho (density)
584-
* * #m_wtm (mean molecular weight)
585-
* * #m_cp (specific heat capacity)
586-
* * #m_hk (species specific enthalpies)
587-
* * #m_wdot (species production rates)
588-
*/
589-
void updateThermo(const double* x, size_t j0, size_t j1) {
590-
for (size_t j = j0; j <= j1; j++) {
591-
setGas(x,j);
592-
m_rho[j] = m_thermo->density();
593-
m_wtm[j] = m_thermo->meanMolecularWeight();
594-
m_cp[j] = m_thermo->cp_mass();
595-
m_thermo->getPartialMolarEnthalpies(&m_hk(0, j));
596-
m_kin->getNetProductionRates(&m_wdot(0, j));
597-
}
598-
}
599-
600613
//! @name Solution components
601614
//! @{
602615

@@ -691,9 +704,6 @@ class Flow1D : public Domain1D
691704
return m*m_nsp*m_nsp + m_nsp*j + k;
692705
}
693706

694-
//! Update the diffusive mass fluxes.
695-
virtual void updateDiffFluxes(const double* x, size_t j0, size_t j1);
696-
697707
//! Get the gradient of species specific molar enthalpies
698708
virtual void grad_hk(const double* x, size_t j);
699709

@@ -775,10 +785,6 @@ class Flow1D : public Domain1D
775785
bool m_isFree;
776786
bool m_usesLambda;
777787

778-
//! Update the transport properties at grid points in the range from `j0`
779-
//! to `j1`, based on solution `x`.
780-
virtual void updateTransport(double* x, size_t j0, size_t j1);
781-
782788
//! Flag for activating two-point flame control
783789
bool m_twoPointControl = false;
784790

src/oneD/Flow1D.cpp

Lines changed: 94 additions & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,100 @@ void Flow1D::updateProperties(size_t jg, double* x, size_t jmin, size_t jmax)
368368
updateDiffFluxes(x, j0, j1);
369369
}
370370

371+
void Flow1D::updateTransport(double* x, size_t j0, size_t j1)
372+
{
373+
if (m_do_multicomponent) {
374+
for (size_t j = j0; j < j1; j++) {
375+
setGasAtMidpoint(x,j);
376+
double wtm = m_thermo->meanMolecularWeight();
377+
double rho = m_thermo->density();
378+
m_visc[j] = (m_dovisc ? m_trans->viscosity() : 0.0);
379+
m_trans->getMultiDiffCoeffs(m_nsp, &m_multidiff[mindex(0,0,j)]);
380+
381+
// Use m_diff as storage for the factor outside the summation
382+
for (size_t k = 0; k < m_nsp; k++) {
383+
m_diff[k+j*m_nsp] = m_wt[k] * rho / (wtm*wtm);
384+
}
385+
386+
m_tcon[j] = m_trans->thermalConductivity();
387+
if (m_do_soret) {
388+
m_trans->getThermalDiffCoeffs(m_dthermal.ptrColumn(0) + j*m_nsp);
389+
}
390+
}
391+
} else { // mixture averaged transport
392+
for (size_t j = j0; j < j1; j++) {
393+
setGasAtMidpoint(x,j);
394+
m_visc[j] = (m_dovisc ? m_trans->viscosity() : 0.0);
395+
396+
if (m_fluxGradientBasis == ThermoBasis::molar) {
397+
m_trans->getMixDiffCoeffs(&m_diff[j*m_nsp]);
398+
} else {
399+
m_trans->getMixDiffCoeffsMass(&m_diff[j*m_nsp]);
400+
}
401+
402+
double rho = m_thermo->density();
403+
404+
if (m_fluxGradientBasis == ThermoBasis::molar) {
405+
double wtm = m_thermo->meanMolecularWeight();
406+
for (size_t k=0; k < m_nsp; k++) {
407+
m_diff[k+j*m_nsp] *= m_wt[k] * rho / wtm;
408+
}
409+
} else {
410+
for (size_t k=0; k < m_nsp; k++) {
411+
m_diff[k+j*m_nsp] *= rho;
412+
}
413+
}
414+
m_tcon[j] = m_trans->thermalConductivity();
415+
}
416+
}
417+
}
418+
419+
void Flow1D::updateDiffFluxes(const double* x, size_t j0, size_t j1)
420+
{
421+
if (m_do_multicomponent) {
422+
for (size_t j = j0; j < j1; j++) {
423+
double dz = z(j+1) - z(j);
424+
for (size_t k = 0; k < m_nsp; k++) {
425+
double sum = 0.0;
426+
for (size_t m = 0; m < m_nsp; m++) {
427+
sum += m_wt[m] * m_multidiff[mindex(k,m,j)] * (X(x,m,j+1)-X(x,m,j));
428+
}
429+
m_flux(k,j) = sum * m_diff[k+j*m_nsp] / dz;
430+
}
431+
}
432+
} else {
433+
for (size_t j = j0; j < j1; j++) {
434+
double sum = 0.0;
435+
double dz = z(j+1) - z(j);
436+
if (m_fluxGradientBasis == ThermoBasis::molar) {
437+
for (size_t k = 0; k < m_nsp; k++) {
438+
m_flux(k,j) = m_diff[k+m_nsp*j] * (X(x,k,j) - X(x,k,j+1))/dz;
439+
sum -= m_flux(k,j);
440+
}
441+
} else {
442+
for (size_t k = 0; k < m_nsp; k++) {
443+
m_flux(k,j) = m_diff[k+m_nsp*j] * (Y(x,k,j) - Y(x,k,j+1))/dz;
444+
sum -= m_flux(k,j);
445+
}
446+
}
447+
// correction flux to insure that \sum_k Y_k V_k = 0.
448+
for (size_t k = 0; k < m_nsp; k++) {
449+
m_flux(k,j) += sum*Y(x,k,j);
450+
}
451+
}
452+
}
453+
454+
if (m_do_soret) {
455+
for (size_t m = j0; m < j1; m++) {
456+
double gradlogT = 2.0 * (T(x,m+1) - T(x,m)) /
457+
((T(x,m+1) + T(x,m)) * (z(m+1) - z(m)));
458+
for (size_t k = 0; k < m_nsp; k++) {
459+
m_flux(k,m) -= m_dthermal(k,m)*gradlogT;
460+
}
461+
}
462+
}
463+
}
464+
371465
void Flow1D::computeRadiation(double* x, size_t jmin, size_t jmax)
372466
{
373467
// Variable definitions for the Planck absorption coefficient and the
@@ -683,54 +777,6 @@ void Flow1D::evalContinuity(size_t j, double* x, double* rsd, int* diag, double
683777
"Overloaded by StFlow; to be removed after Cantera 3.0");
684778
}
685779

686-
void Flow1D::updateTransport(double* x, size_t j0, size_t j1)
687-
{
688-
if (m_do_multicomponent) {
689-
for (size_t j = j0; j < j1; j++) {
690-
setGasAtMidpoint(x,j);
691-
double wtm = m_thermo->meanMolecularWeight();
692-
double rho = m_thermo->density();
693-
m_visc[j] = (m_dovisc ? m_trans->viscosity() : 0.0);
694-
m_trans->getMultiDiffCoeffs(m_nsp, &m_multidiff[mindex(0,0,j)]);
695-
696-
// Use m_diff as storage for the factor outside the summation
697-
for (size_t k = 0; k < m_nsp; k++) {
698-
m_diff[k+j*m_nsp] = m_wt[k] * rho / (wtm*wtm);
699-
}
700-
701-
m_tcon[j] = m_trans->thermalConductivity();
702-
if (m_do_soret) {
703-
m_trans->getThermalDiffCoeffs(m_dthermal.ptrColumn(0) + j*m_nsp);
704-
}
705-
}
706-
} else { // mixture averaged transport
707-
for (size_t j = j0; j < j1; j++) {
708-
setGasAtMidpoint(x,j);
709-
m_visc[j] = (m_dovisc ? m_trans->viscosity() : 0.0);
710-
711-
if (m_fluxGradientBasis == ThermoBasis::molar) {
712-
m_trans->getMixDiffCoeffs(&m_diff[j*m_nsp]);
713-
} else {
714-
m_trans->getMixDiffCoeffsMass(&m_diff[j*m_nsp]);
715-
}
716-
717-
double rho = m_thermo->density();
718-
719-
if (m_fluxGradientBasis == ThermoBasis::molar) {
720-
double wtm = m_thermo->meanMolecularWeight();
721-
for (size_t k=0; k < m_nsp; k++) {
722-
m_diff[k+j*m_nsp] *= m_wt[k] * rho / wtm;
723-
}
724-
} else {
725-
for (size_t k=0; k < m_nsp; k++) {
726-
m_diff[k+j*m_nsp] *= rho;
727-
}
728-
}
729-
m_tcon[j] = m_trans->thermalConductivity();
730-
}
731-
}
732-
}
733-
734780
void Flow1D::show(const double* x)
735781
{
736782
writelog(" Pressure: {:10.4g} Pa\n", m_press);
@@ -748,52 +794,6 @@ void Flow1D::show(const double* x)
748794
}
749795
}
750796

751-
void Flow1D::updateDiffFluxes(const double* x, size_t j0, size_t j1)
752-
{
753-
if (m_do_multicomponent) {
754-
for (size_t j = j0; j < j1; j++) {
755-
double dz = z(j+1) - z(j);
756-
for (size_t k = 0; k < m_nsp; k++) {
757-
double sum = 0.0;
758-
for (size_t m = 0; m < m_nsp; m++) {
759-
sum += m_wt[m] * m_multidiff[mindex(k,m,j)] * (X(x,m,j+1)-X(x,m,j));
760-
}
761-
m_flux(k,j) = sum * m_diff[k+j*m_nsp] / dz;
762-
}
763-
}
764-
} else {
765-
for (size_t j = j0; j < j1; j++) {
766-
double sum = 0.0;
767-
double dz = z(j+1) - z(j);
768-
if (m_fluxGradientBasis == ThermoBasis::molar) {
769-
for (size_t k = 0; k < m_nsp; k++) {
770-
m_flux(k,j) = m_diff[k+m_nsp*j] * (X(x,k,j) - X(x,k,j+1))/dz;
771-
sum -= m_flux(k,j);
772-
}
773-
} else {
774-
for (size_t k = 0; k < m_nsp; k++) {
775-
m_flux(k,j) = m_diff[k+m_nsp*j] * (Y(x,k,j) - Y(x,k,j+1))/dz;
776-
sum -= m_flux(k,j);
777-
}
778-
}
779-
// correction flux to insure that \sum_k Y_k V_k = 0.
780-
for (size_t k = 0; k < m_nsp; k++) {
781-
m_flux(k,j) += sum*Y(x,k,j);
782-
}
783-
}
784-
}
785-
786-
if (m_do_soret) {
787-
for (size_t m = j0; m < j1; m++) {
788-
double gradlogT = 2.0 * (T(x,m+1) - T(x,m)) /
789-
((T(x,m+1) + T(x,m)) * (z(m+1) - z(m)));
790-
for (size_t k = 0; k < m_nsp; k++) {
791-
m_flux(k,m) -= m_dthermal(k,m)*gradlogT;
792-
}
793-
}
794-
}
795-
}
796-
797797
string Flow1D::componentName(size_t n) const
798798
{
799799
switch (n) {

0 commit comments

Comments
 (0)