Skip to content

Commit 4b879f2

Browse files
committed
[oneD] Reorder content for named doxygen section
1 parent 049ae1c commit 4b879f2

File tree

2 files changed

+135
-128
lines changed

2 files changed

+135
-128
lines changed

include/cantera/oneD/Flow1D.h

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

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

177176
shared_ptr<SolutionArray> asArray(const double* soln) const override;
@@ -334,11 +333,48 @@ class Flow1D : public Domain1D
334333
AnyMap getMeta() const override;
335334
void setMeta(const AnyMap& state) override;
336335

336+
//! @name Updates of cached properties
337+
//! These methods are called by eval() to update cached properties and data that are
338+
//! used for the evaluation of the governing equations.
339+
//! @{
340+
337341
//! Update the properties (thermo, transport, and diffusion flux).
338342
//! This function is called in eval after the points which need
339343
//! to be updated are defined.
340344
virtual void updateProperties(size_t jg, double* x, size_t jmin, size_t jmax);
341345

346+
/**
347+
* Update the thermodynamic properties from point j0 to point j1
348+
* (inclusive), based on solution x.
349+
*
350+
* The gas state is set to be consistent with the solution at the
351+
* points from j0 to j1.
352+
*
353+
* Properties that are computed and cached are:
354+
* * #m_rho (density)
355+
* * #m_wtm (mean molecular weight)
356+
* * #m_cp (specific heat capacity)
357+
* * #m_hk (species specific enthalpies)
358+
* * #m_wdot (species production rates)
359+
*/
360+
void updateThermo(const double* x, size_t j0, size_t j1) {
361+
for (size_t j = j0; j <= j1; j++) {
362+
setGas(x,j);
363+
m_rho[j] = m_thermo->density();
364+
m_wtm[j] = m_thermo->meanMolecularWeight();
365+
m_cp[j] = m_thermo->cp_mass();
366+
m_thermo->getPartialMolarEnthalpies(&m_hk(0, j));
367+
m_kin->getNetProductionRates(&m_wdot(0, j));
368+
}
369+
}
370+
371+
//! Update the diffusive mass fluxes.
372+
virtual void updateDiffFluxes(const double* x, size_t j0, size_t j1);
373+
374+
//! Update the transport properties at grid points in the range from `j0`
375+
//! to `j1`, based on solution `x`.
376+
virtual void updateTransport(double* x, size_t j0, size_t j1);
377+
342378
/**
343379
* Computes the radiative heat loss vector over points jmin to jmax and stores
344380
* the data in the qdotRadiation variable.
@@ -356,8 +392,11 @@ class Flow1D : public Domain1D
356392
*/
357393
void computeRadiation(double* x, size_t jmin, size_t jmax);
358394

395+
//! @}
396+
359397
//! @name Governing Equations
360-
//! Methods are used to evaluate residuals for each of the governing equations.
398+
//! Methods called by eval() to calculate residuals for individual governing
399+
//! equations.
361400
//! @{
362401

363402
/**
@@ -492,31 +531,6 @@ class Flow1D : public Domain1D
492531
//! @deprecated To be removed after Cantera 3.0.
493532
virtual void evalContinuity(size_t j, double* x, double* r, int* diag, double rdt);
494533

495-
/**
496-
* Update the thermodynamic properties from point j0 to point j1
497-
* (inclusive), based on solution x.
498-
*
499-
* The gas state is set to be consistent with the solution at the
500-
* points from j0 to j1.
501-
*
502-
* Properties that are computed and cached are:
503-
* * #m_rho (density)
504-
* * #m_wtm (mean molecular weight)
505-
* * #m_cp (specific heat capacity)
506-
* * #m_hk (species specific enthalpies)
507-
* * #m_wdot (species production rates)
508-
*/
509-
void updateThermo(const double* x, size_t j0, size_t j1) {
510-
for (size_t j = j0; j <= j1; j++) {
511-
setGas(x,j);
512-
m_rho[j] = m_thermo->density();
513-
m_wtm[j] = m_thermo->meanMolecularWeight();
514-
m_cp[j] = m_thermo->cp_mass();
515-
m_thermo->getPartialMolarEnthalpies(&m_hk(0, j));
516-
m_kin->getNetProductionRates(&m_wdot(0, j));
517-
}
518-
}
519-
520534
//! @name Solution components
521535
//! @{
522536

@@ -606,9 +620,6 @@ class Flow1D : public Domain1D
606620
return m*m_nsp*m_nsp + m_nsp*j + k;
607621
}
608622

609-
//! Update the diffusive mass fluxes.
610-
virtual void updateDiffFluxes(const double* x, size_t j0, size_t j1);
611-
612623
//! Get the gradient of species specific molar enthalpies
613624
virtual void grad_hk(const double* x, size_t j);
614625

@@ -690,10 +701,6 @@ class Flow1D : public Domain1D
690701
bool m_isFree;
691702
bool m_usesLambda;
692703

693-
//! Update the transport properties at grid points in the range from `j0`
694-
//! to `j1`, based on solution `x`.
695-
virtual void updateTransport(double* x, size_t j0, size_t j1);
696-
697704
public:
698705
//! Location of the point where temperature is fixed
699706
double m_zfixed = Undef;

src/oneD/Flow1D.cpp

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

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

625-
void Flow1D::updateTransport(double* x, size_t j0, size_t j1)
626-
{
627-
if (m_do_multicomponent) {
628-
for (size_t j = j0; j < j1; j++) {
629-
setGasAtMidpoint(x,j);
630-
double wtm = m_thermo->meanMolecularWeight();
631-
double rho = m_thermo->density();
632-
m_visc[j] = (m_dovisc ? m_trans->viscosity() : 0.0);
633-
m_trans->getMultiDiffCoeffs(m_nsp, &m_multidiff[mindex(0,0,j)]);
634-
635-
// Use m_diff as storage for the factor outside the summation
636-
for (size_t k = 0; k < m_nsp; k++) {
637-
m_diff[k+j*m_nsp] = m_wt[k] * rho / (wtm*wtm);
638-
}
639-
640-
m_tcon[j] = m_trans->thermalConductivity();
641-
if (m_do_soret) {
642-
m_trans->getThermalDiffCoeffs(m_dthermal.ptrColumn(0) + j*m_nsp);
643-
}
644-
}
645-
} else { // mixture averaged transport
646-
for (size_t j = j0; j < j1; j++) {
647-
setGasAtMidpoint(x,j);
648-
m_visc[j] = (m_dovisc ? m_trans->viscosity() : 0.0);
649-
650-
if (m_fluxGradientBasis == ThermoBasis::molar) {
651-
m_trans->getMixDiffCoeffs(&m_diff[j*m_nsp]);
652-
} else {
653-
m_trans->getMixDiffCoeffsMass(&m_diff[j*m_nsp]);
654-
}
655-
656-
double rho = m_thermo->density();
657-
658-
if (m_fluxGradientBasis == ThermoBasis::molar) {
659-
double wtm = m_thermo->meanMolecularWeight();
660-
for (size_t k=0; k < m_nsp; k++) {
661-
m_diff[k+j*m_nsp] *= m_wt[k] * rho / wtm;
662-
}
663-
} else {
664-
for (size_t k=0; k < m_nsp; k++) {
665-
m_diff[k+j*m_nsp] *= rho;
666-
}
667-
}
668-
m_tcon[j] = m_trans->thermalConductivity();
669-
}
670-
}
671-
}
672-
673719
void Flow1D::show(const double* x)
674720
{
675721
writelog(" Pressure: {:10.4g} Pa\n", m_press);
@@ -687,52 +733,6 @@ void Flow1D::show(const double* x)
687733
}
688734
}
689735

690-
void Flow1D::updateDiffFluxes(const double* x, size_t j0, size_t j1)
691-
{
692-
if (m_do_multicomponent) {
693-
for (size_t j = j0; j < j1; j++) {
694-
double dz = z(j+1) - z(j);
695-
for (size_t k = 0; k < m_nsp; k++) {
696-
double sum = 0.0;
697-
for (size_t m = 0; m < m_nsp; m++) {
698-
sum += m_wt[m] * m_multidiff[mindex(k,m,j)] * (X(x,m,j+1)-X(x,m,j));
699-
}
700-
m_flux(k,j) = sum * m_diff[k+j*m_nsp] / dz;
701-
}
702-
}
703-
} else {
704-
for (size_t j = j0; j < j1; j++) {
705-
double sum = 0.0;
706-
double dz = z(j+1) - z(j);
707-
if (m_fluxGradientBasis == ThermoBasis::molar) {
708-
for (size_t k = 0; k < m_nsp; k++) {
709-
m_flux(k,j) = m_diff[k+m_nsp*j] * (X(x,k,j) - X(x,k,j+1))/dz;
710-
sum -= m_flux(k,j);
711-
}
712-
} else {
713-
for (size_t k = 0; k < m_nsp; k++) {
714-
m_flux(k,j) = m_diff[k+m_nsp*j] * (Y(x,k,j) - Y(x,k,j+1))/dz;
715-
sum -= m_flux(k,j);
716-
}
717-
}
718-
// correction flux to insure that \sum_k Y_k V_k = 0.
719-
for (size_t k = 0; k < m_nsp; k++) {
720-
m_flux(k,j) += sum*Y(x,k,j);
721-
}
722-
}
723-
}
724-
725-
if (m_do_soret) {
726-
for (size_t m = j0; m < j1; m++) {
727-
double gradlogT = 2.0 * (T(x,m+1) - T(x,m)) /
728-
((T(x,m+1) + T(x,m)) * (z(m+1) - z(m)));
729-
for (size_t k = 0; k < m_nsp; k++) {
730-
m_flux(k,m) -= m_dthermal(k,m)*gradlogT;
731-
}
732-
}
733-
}
734-
}
735-
736736
string Flow1D::componentName(size_t n) const
737737
{
738738
switch (n) {

0 commit comments

Comments
 (0)