constTransport: Avoid /0 in + and - operators averaging 1/Pr when the number of moles = 0
Resolves bug-report http://www.openfoam.org/mantisbt/view.php?id=1348
This commit is contained in:
parent
24f0273b92
commit
3087fcbb1e
1 changed files with 40 additions and 16 deletions
|
|
@ -203,15 +203,27 @@ inline Foam::constTransport<Thermo> Foam::operator+
|
|||
static_cast<const Thermo&>(ct1) + static_cast<const Thermo&>(ct2)
|
||||
);
|
||||
|
||||
scalar molr1 = ct1.nMoles()/t.nMoles();
|
||||
scalar molr2 = ct2.nMoles()/t.nMoles();
|
||||
if (mag(ct1.nMoles()) + mag(ct2.nMoles()) < SMALL)
|
||||
{
|
||||
return constTransport<Thermo>
|
||||
(
|
||||
t,
|
||||
0,
|
||||
ct1.rPr_
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
scalar molr1 = ct1.nMoles()/t.nMoles();
|
||||
scalar molr2 = ct2.nMoles()/t.nMoles();
|
||||
|
||||
return constTransport<Thermo>
|
||||
(
|
||||
t,
|
||||
molr1*ct1.mu_ + molr2*ct2.mu_,
|
||||
1.0/(molr1/ct1.rPr_ + molr2/ct2.rPr_)
|
||||
);
|
||||
return constTransport<Thermo>
|
||||
(
|
||||
t,
|
||||
molr1*ct1.mu_ + molr2*ct2.mu_,
|
||||
1.0/(molr1/ct1.rPr_ + molr2/ct2.rPr_)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -227,15 +239,27 @@ inline Foam::constTransport<Thermo> Foam::operator-
|
|||
static_cast<const Thermo&>(ct1) - static_cast<const Thermo&>(ct2)
|
||||
);
|
||||
|
||||
scalar molr1 = ct1.nMoles()/t.nMoles();
|
||||
scalar molr2 = ct2.nMoles()/t.nMoles();
|
||||
if (mag(ct1.nMoles()) + mag(ct2.nMoles()) < SMALL)
|
||||
{
|
||||
return constTransport<Thermo>
|
||||
(
|
||||
t,
|
||||
0,
|
||||
ct1.rPr_
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
scalar molr1 = ct1.nMoles()/t.nMoles();
|
||||
scalar molr2 = ct2.nMoles()/t.nMoles();
|
||||
|
||||
return constTransport<Thermo>
|
||||
(
|
||||
t,
|
||||
molr1*ct1.mu_ - molr2*ct2.mu_,
|
||||
1.0/(molr1/ct1.rPr_ - molr2/ct2.rPr_)
|
||||
);
|
||||
return constTransport<Thermo>
|
||||
(
|
||||
t,
|
||||
molr1*ct1.mu_ - molr2*ct2.mu_,
|
||||
1.0/(molr1/ct1.rPr_ - molr2/ct2.rPr_)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue