Skip to content
Snippets Groups Projects
Commit bea3a7a9 authored by Henry's avatar Henry
Browse files

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
parent f913a7ec
Branches
Tags
No related merge requests found
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
...@@ -203,15 +203,27 @@ inline Foam::constTransport<Thermo> Foam::operator+ ...@@ -203,15 +203,27 @@ inline Foam::constTransport<Thermo> Foam::operator+
static_cast<const Thermo&>(ct1) + static_cast<const Thermo&>(ct2) static_cast<const Thermo&>(ct1) + static_cast<const Thermo&>(ct2)
); );
scalar molr1 = ct1.nMoles()/t.nMoles(); if (mag(ct1.nMoles()) + mag(ct2.nMoles()) < SMALL)
scalar molr2 = ct2.nMoles()/t.nMoles(); {
return constTransport<Thermo>
return constTransport<Thermo> (
( t,
t, 0,
molr1*ct1.mu_ + molr2*ct2.mu_, ct1.rPr_
1.0/(molr1/ct1.rPr_ + molr2/ct2.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_)
);
}
} }
...@@ -227,15 +239,27 @@ inline Foam::constTransport<Thermo> Foam::operator- ...@@ -227,15 +239,27 @@ inline Foam::constTransport<Thermo> Foam::operator-
static_cast<const Thermo&>(ct1) - static_cast<const Thermo&>(ct2) static_cast<const Thermo&>(ct1) - static_cast<const Thermo&>(ct2)
); );
scalar molr1 = ct1.nMoles()/t.nMoles(); if (mag(ct1.nMoles()) + mag(ct2.nMoles()) < SMALL)
scalar molr2 = ct2.nMoles()/t.nMoles(); {
return constTransport<Thermo>
return constTransport<Thermo> (
( t,
t, 0,
molr1*ct1.mu_ - molr2*ct2.mu_, ct1.rPr_
1.0/(molr1/ct1.rPr_ - molr2/ct2.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_)
);
}
} }
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment