waves: Protected exponential and hyperbolic functions from overflow

Resolves bug report https://bugs.openfoam.org/view.php?id=3397
This commit is contained in:
Will Bainbridge
2019-11-26 16:14:09 +00:00
parent bce61e943e
commit d0768e6039
3 changed files with 17 additions and 7 deletions

View File

@ -80,7 +80,9 @@ Foam::tmp<Foam::vector2DField> Foam::waveModels::Airy::vi
const scalarField z(xz.component(1));
const scalarField phi(angle(t, x));
const scalarField kz(k()*z);
const scalar kzGreat = log(i*great);
const scalarField kz(min(max(k()*z, - kzGreat), kzGreat));
if (deep())
{

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2017-2018 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2017-2019 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -64,7 +64,9 @@ Foam::tmp<Foam::scalarField> Foam::waveModels::Stokes2::elevation
const scalarField& x
) const
{
const scalar kd = k()*depth(), ka = k()*amplitude(t);
static const scalar kdGreat = log(great);
const scalar kd = min(max(k()*depth(), - kdGreat), kdGreat);
const scalar ka = k()*amplitude(t);
const scalar T = deep() ? 1 : tanh(kd);
@ -87,7 +89,9 @@ Foam::tmp<Foam::vector2DField> Foam::waveModels::Stokes2::velocity
const vector2DField& xz
) const
{
const scalar kd = k()*depth(), ka = k()*amplitude(t);
static const scalar kdGreat = log(great);
const scalar kd = min(max(k()*depth(), - kdGreat), kdGreat);
const scalar ka = k()*amplitude(t);
const scalar A22ByA11 = deep() ? 0 : 0.375/pow3(sinh(kd));

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2017-2018 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2017-2019 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -64,7 +64,9 @@ Foam::tmp<Foam::scalarField> Foam::waveModels::Stokes5::elevation
const scalarField& x
) const
{
const scalar kd = k()*depth(), ka = k()*amplitude(t);
static const scalar kdGreat = log(great);
const scalar kd = min(max(k()*depth(), - kdGreat), kdGreat);
const scalar ka = k()*amplitude(t);
const scalar S = deep() ? 0 : 1/cosh(2*kd), T = deep() ? 1 : tanh(kd);
@ -128,7 +130,9 @@ Foam::tmp<Foam::vector2DField> Foam::waveModels::Stokes5::velocity
const vector2DField& xz
) const
{
const scalar kd = k()*depth(), ka = k()*amplitude(t);
static const scalar kdGreat = log(great);
const scalar kd = min(max(k()*depth(), - kdGreat), kdGreat);
const scalar ka = k()*amplitude(t);
const scalar S = deep() ? 0 : 1/cosh(2*kd);
const scalar SByA11 = deep() ? 0 : S*sinh(kd);