Merge remote-tracking branch 'origin/master' into develop

This commit is contained in:
Andrew Heather
2018-08-29 13:51:40 +01:00
11 changed files with 40 additions and 17 deletions

View File

@ -51,7 +51,7 @@ void test(const Type& polynomialEqn, const scalar tol)
case roots::real: case roots::real:
v[i] = polynomialEqn.value(r[i]); v[i] = polynomialEqn.value(r[i]);
e[i] = polynomialEqn.error(r[i]); e[i] = polynomialEqn.error(r[i]);
ok = ok && mag(v[i]) < tol*mag(e[i]); ok = ok && mag(v[i]) <= tol*mag(e[i]);
break; break;
case roots::posInf: case roots::posInf:
v[i] = + inf; v[i] = + inf;
@ -79,8 +79,10 @@ void test(const Type& polynomialEqn, const scalar tol)
int main() int main()
{ {
const int nTests = 1000000; const scalar tol = 5;
for (int t = 0; t < nTests; ++ t)
const label nTests = 1000000;
for (label t = 0; t < nTests; ++ t)
{ {
test test
( (
@ -91,11 +93,26 @@ int main()
randomScalar(1e-50, 1e+50), randomScalar(1e-50, 1e+50),
randomScalar(1e-50, 1e+50) randomScalar(1e-50, 1e+50)
), ),
100 tol
); );
} }
Info << nTests << " random cubics tested" << endl;
Info << nTests << " cubics tested" << endl; const label coeffMin = -9, coeffMax = 10, nCoeff = coeffMax - coeffMin;
for (label a = coeffMin; a < coeffMax; ++ a)
{
for (label b = coeffMin; b < coeffMax; ++ b)
{
for (label c = coeffMin; c < coeffMax; ++ c)
{
for (label d = coeffMin; d < coeffMax; ++ d)
{
test(cubicEqn(a, b, c, d), tol);
}
}
}
}
Info<< nCoeff*nCoeff*nCoeff*nCoeff << " integer cubics tested" << endl;
return 0; return 0;
} }

View File

@ -1,12 +1,13 @@
#!/bin/sh #!/bin/sh
cd ${0%/*} || exit 1 # Run from this directory cd ${0%/*} || exit 1 # Run from this directory
. $WM_PROJECT_DIR/wmake/scripts/AllwmakeParseArguments # (for error catching)
. $WM_PROJECT_DIR/wmake/scripts/have_fftw . $WM_PROJECT_DIR/wmake/scripts/have_fftw
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
if have_fftw if have_fftw
then then
wmake wmake $targetType
else else
echo "==> skip noise utility (no FFTW)" echo "==> skip noise utility (no FFTW)"
fi fi

View File

@ -1,12 +1,13 @@
#!/bin/sh #!/bin/sh
cd ${0%/*} || exit 1 # Run from this directory cd ${0%/*} || exit 1 # Run from this directory
. $WM_PROJECT_DIR/wmake/scripts/AllwmakeParseArguments # (for error catching)
. $WM_PROJECT_DIR/wmake/scripts/have_fftw . $WM_PROJECT_DIR/wmake/scripts/have_fftw
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
if have_fftw if have_fftw
then then
wmake wmake $targetType
else else
echo "==> skip boxTurb utility (no FFTW)" echo "==> skip boxTurb utility (no FFTW)"
fi fi

View File

@ -1,5 +1,6 @@
#!/bin/sh #!/bin/sh
cd ${0%/*} || exit 1 # Run from this directory cd ${0%/*} || exit 1 # Run from this directory
. $WM_PROJECT_DIR/wmake/scripts/AllwmakeParseArguments # (for error catching)
. $WM_PROJECT_DIR/wmake/scripts/have_cgal . $WM_PROJECT_DIR/wmake/scripts/have_cgal
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
@ -14,6 +15,6 @@ else
export COMP_FLAGS="-DNO_CGAL" export COMP_FLAGS="-DNO_CGAL"
fi fi
wmake wmake $targetType
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------

View File

@ -159,9 +159,6 @@ Foam::bitSet& Foam::bitSet::orEq(const bitSet& other, const bool strict)
<< "Perform |= on dissimilar sized bitSets: " << "Perform |= on dissimilar sized bitSets: "
<< size() << " vs. " << other.size() << nl; << size() << " vs. " << other.size() << nl;
} }
{
return *this;
}
label minpos = -1; // Min trim point label minpos = -1; // Min trim point

View File

@ -81,7 +81,7 @@ Foam::Roots<3> Foam::cubicEqn::roots() const
// This is assumed not to over- or under-flow. If it does, all bets are off. // This is assumed not to over- or under-flow. If it does, all bets are off.
const scalar p = c*a - b*b/3; const scalar p = c*a - b*b/3;
const scalar q = b*b*b*(2.0/27.0) - b*c*a/3 + d*a*a; const scalar q = b*b*b*scalar(2)/27 - b*c*a/3 + d*a*a;
const scalar disc = p*p*p/27 + q*q/4; const scalar disc = p*p*p/27 + q*q/4;
// How many roots of what types are available? // How many roots of what types are available?
@ -96,7 +96,7 @@ Foam::Roots<3> Foam::cubicEqn::roots() const
if (oneReal) if (oneReal)
{ {
const Roots<1> r = linearEqn(- a, b/3).roots(); const Roots<1> r = linearEqn(a, b/3).roots();
return Roots<3>(r.type(0), r[0]); return Roots<3>(r.type(0), r[0]);
} }
else if (twoReal) else if (twoReal)

View File

@ -114,7 +114,10 @@ inline Foam::scalar Foam::cubicEqn::derivative(const scalar x) const
inline Foam::scalar Foam::cubicEqn::error(const scalar x) const inline Foam::scalar Foam::cubicEqn::error(const scalar x) const
{ {
return mag(SMALL*x*(x*(x*3*a() + 2*b()) + c())); return
SMALL*magSqr(x)*(mag(x*a()) + mag(b()))
+ SMALL*mag(x)*(mag(x*(x*a() + b())) + mag(c()))
+ SMALL*(mag(x*(x*(x*a() + b()) + c())) + mag(d()));
} }

View File

@ -82,7 +82,7 @@ inline Foam::scalar Foam::linearEqn::derivative(const scalar x) const
inline Foam::scalar Foam::linearEqn::error(const scalar x) const inline Foam::scalar Foam::linearEqn::error(const scalar x) const
{ {
return mag(SMALL*x*a()); return SMALL*(mag(x*a()) + mag(b()));
} }

View File

@ -71,7 +71,7 @@ Foam::Roots<2> Foam::quadraticEqn::roots() const
if (oneReal) if (oneReal)
{ {
const Roots<1> r = linearEqn(- a, b/2).roots(); const Roots<1> r = linearEqn(a, b/2).roots();
return Roots<2>(r, r); return Roots<2>(r, r);
} }
else if (twoReal) else if (twoReal)

View File

@ -100,7 +100,9 @@ inline Foam::scalar Foam::quadraticEqn::derivative(const scalar x) const
inline Foam::scalar Foam::quadraticEqn::error(const scalar x) const inline Foam::scalar Foam::quadraticEqn::error(const scalar x) const
{ {
return mag(SMALL*x*(x*2*a() + b())); return
SMALL*mag(x)*(mag(x*a()) + mag(b()))
+ SMALL*(mag(x*(x*a() + b())) + mag(c()));
} }

View File

@ -215,6 +215,7 @@ externalWallHeatFluxTemperatureFvPatchScalarField
if (qrName_ != "none") if (qrName_ != "none")
{ {
qrPrevious_.setSize(mapper.size());
qrPrevious_.map(ptf.qrPrevious_, mapper); qrPrevious_.map(ptf.qrPrevious_, mapper);
} }
} }