Skip to content
Permalink
Browse files

waves: Added atmospheric boundary layer modelling to the gas

An atmospheric boundary layer velocity can now be added to the gas side
of the wave modelling. The wave superposition class has been given a
run-time selection mechanism, and a derivation added which includes gas
atmospheric boundary layer modelling. This modelling is therefore
available in both the wave boundary conditions, and in setWaves.

This functionality can be selected in the constant/waveProperties file
by supplying a "type" entry and a number of parameters controlling the
boundary layer. For example:

    In constant/waveProperties:

        type            waveAtmBoundaryLayer;

        // properties specifying the wave modelling ...

        UGasRef         (10 0 0);
        hRef            20;
        hWaveMin        -2;
        hWaveMax        3;

UGasRef is the gas velocity relative to the liquid, at the height, hRef,
relative to the wave model origin. hWaveMin and hWaveMax describe the
range of the wave elevation; it is non-trivial to calculate this from
the wave models themselves, so it is required as an input.

The base wave superposition class can be selected with "type wave;", but
also selects by default when the "type" entry is omitted, so the change
is backwards compatible.
  • Loading branch information...
Will Bainbridge
Will Bainbridge committed Dec 17, 2018
1 parent b66cad3 commit 4d6b99faa704e298f112302c82bc13c8245e05b5
@@ -25,14 +25,35 @@ License

#include "atmBoundaryLayer.H"

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //

namespace Foam
const Foam::scalar Foam::atmBoundaryLayer::kappaDefault_ = 0.41;

const Foam::scalar Foam::atmBoundaryLayer::CmuDefault_ = 0.09;


// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //

void Foam::atmBoundaryLayer::init()
{
if (mag(flowDir_) < small || mag(zDir_) < small)
{
FatalErrorInFunction
<< "magnitude of n or z must be greater than zero"
<< abort(FatalError);
}

// Ensure direction vectors are normalized
flowDir_ /= mag(flowDir_);
zDir_ /= mag(zDir_);

Ustar_ = kappa_*Uref_/(log((Zref_ + z0_)/z0_));
}


// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //

atmBoundaryLayer::atmBoundaryLayer()
Foam::atmBoundaryLayer::atmBoundaryLayer()
:
flowDir_(Zero),
zDir_(Zero),
@@ -50,12 +71,49 @@ atmBoundaryLayer::atmBoundaryLayer()
{}


atmBoundaryLayer::atmBoundaryLayer(const vectorField& p, const dictionary& dict)
Foam::atmBoundaryLayer::atmBoundaryLayer
(
const vector& flowDir,
const vector& zDir,
const scalar Uref,
const scalar Zref,
const scalarField& z0,
const scalarField& zGround,
const scalar kappa,
const scalar Cmu,
const scalar Ulower,
const scalar kLower,
const scalar epsilonLower
)
:
flowDir_(flowDir),
zDir_(zDir),
kappa_(kappa),
Cmu_(Cmu),
Uref_(Uref),
Zref_(Zref),
z0_(z0),
zGround_(zGround),
Ustar_(z0.size()),
offset_(Ulower != 0),
Ulower_(Ulower),
kLower_(kLower),
epsilonLower_(epsilonLower)
{
init();
}


Foam::atmBoundaryLayer::atmBoundaryLayer
(
const vectorField& p,
const dictionary& dict
)
:
flowDir_(dict.lookup("flowDir")),
zDir_(dict.lookup("zDir")),
kappa_(dict.lookupOrDefault<scalar>("kappa", 0.41)),
Cmu_(dict.lookupOrDefault<scalar>("Cmu", 0.09)),
kappa_(dict.lookupOrDefault<scalar>("kappa", kappaDefault_)),
Cmu_(dict.lookupOrDefault<scalar>("Cmu", CmuDefault_)),
Uref_(readScalar(dict.lookup("Uref"))),
Zref_(readScalar(dict.lookup("Zref"))),
z0_("z0", dict, p.size()),
@@ -66,22 +124,11 @@ atmBoundaryLayer::atmBoundaryLayer(const vectorField& p, const dictionary& dict)
kLower_(dict.lookupOrDefault<scalar>("kLower", 0)),
epsilonLower_(dict.lookupOrDefault<scalar>("epsilonLower", 0))
{
if (mag(flowDir_) < small || mag(zDir_) < small)
{
FatalErrorInFunction
<< "magnitude of n or z must be greater than zero"
<< abort(FatalError);
}

// Ensure direction vectors are normalized
flowDir_ /= mag(flowDir_);
zDir_ /= mag(zDir_);

Ustar_ = kappa_*Uref_/(log((Zref_ + z0_)/z0_));
init();
}


atmBoundaryLayer::atmBoundaryLayer
Foam::atmBoundaryLayer::atmBoundaryLayer
(
const atmBoundaryLayer& abl,
const fvPatchFieldMapper& mapper
@@ -103,7 +150,7 @@ atmBoundaryLayer::atmBoundaryLayer
{}


atmBoundaryLayer::atmBoundaryLayer(const atmBoundaryLayer& abl)
Foam::atmBoundaryLayer::atmBoundaryLayer(const atmBoundaryLayer& abl)
:
flowDir_(abl.flowDir_),
zDir_(abl.zDir_),
@@ -123,15 +170,15 @@ atmBoundaryLayer::atmBoundaryLayer(const atmBoundaryLayer& abl)

// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //

void atmBoundaryLayer::autoMap(const fvPatchFieldMapper& m)
void Foam::atmBoundaryLayer::autoMap(const fvPatchFieldMapper& m)
{
z0_.autoMap(m);
zGround_.autoMap(m);
Ustar_.autoMap(m);
}


void atmBoundaryLayer::rmap
void Foam::atmBoundaryLayer::rmap
(
const atmBoundaryLayer& blptf,
const labelList& addr
@@ -143,7 +190,10 @@ void atmBoundaryLayer::rmap
}


tmp<vectorField> atmBoundaryLayer::U(const vectorField& p) const
Foam::tmp<Foam::vectorField> Foam::atmBoundaryLayer::U
(
const vectorField& p
) const
{
const scalarField Un
(
@@ -162,7 +212,10 @@ tmp<vectorField> atmBoundaryLayer::U(const vectorField& p) const
}


tmp<scalarField> atmBoundaryLayer::k(const vectorField& p) const
Foam::tmp<Foam::scalarField> Foam::atmBoundaryLayer::k
(
const vectorField& p
) const
{
tmp<scalarField> tk
(
@@ -179,7 +232,10 @@ tmp<scalarField> atmBoundaryLayer::k(const vectorField& p) const
}


tmp<scalarField> atmBoundaryLayer::epsilon(const vectorField& p) const
Foam::tmp<Foam::scalarField> Foam::atmBoundaryLayer::epsilon
(
const vectorField& p
) const
{
tmp<scalarField> tepsilon
(
@@ -196,7 +252,7 @@ tmp<scalarField> atmBoundaryLayer::epsilon(const vectorField& p) const
}


void atmBoundaryLayer::write(Ostream& os) const
void Foam::atmBoundaryLayer::write(Ostream& os) const
{
z0_.writeEntry("z0", os) ;
os.writeKeyword("flowDir")
@@ -226,8 +282,4 @@ void atmBoundaryLayer::write(Ostream& os) const
}


// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

} // End namespace Foam

// ************************************************************************* //
@@ -128,6 +128,15 @@ namespace Foam

class atmBoundaryLayer
{
// Private static data

//- Default value of the Von Karman constant
static const scalar kappaDefault_;

//- Default value of the turbulent viscosity coefficient
static const scalar CmuDefault_;


// Private data

//- Flow direction
@@ -171,13 +180,35 @@ class atmBoundaryLayer
const scalar epsilonLower_;


// Private member functions

//- Initialisation shared by multiple constructors
void init();


public:

// Constructors

//- Construct null
atmBoundaryLayer();

//- Construct from components
atmBoundaryLayer
(
const vector& flowDir,
const vector& zDir,
const scalar Uref,
const scalar Zref,
const scalarField& z0,
const scalarField& zGround,
const scalar kappa = kappaDefault_,
const scalar Cmu = CmuDefault_,
const scalar ULower = 0,
const scalar kLower = 0,
const scalar epsilonLower = 0
);

//- Construct from the coordinates field and dictionary
atmBoundaryLayer(const vectorField& p, const dictionary&);

@@ -5,7 +5,9 @@ waveModels/Stokes2/Stokes2.C
waveModels/Stokes5/Stokes5.C
waveModels/solitary/solitary.C

waveSuperposition/waveSuperposition.C
waveSuperpositions/waveSuperposition/waveSuperposition.C
waveSuperpositions/waveSuperposition/newWaveSuperposition.C
waveSuperpositions/waveAtmBoundaryLayerSuperposition/waveAtmBoundaryLayerSuperposition.C

derivedFvPatchFields/waveAlpha/waveAlphaFvPatchScalarField.C
derivedFvPatchFields/waveVelocity/waveVelocityFvPatchVectorField.C
@@ -1,9 +1,11 @@
EXE_INC = \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/dynamicMesh/lnInclude
-I$(LIB_SRC)/dynamicMesh/lnInclude \
-I$(LIB_SRC)/atmosphericModels/lnInclude

LIB_LIBS = \
-lfiniteVolume \
-lmeshTools \
-ldynamicMesh
-ldynamicMesh \
-latmosphericModels
@@ -0,0 +1,107 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2017-2018 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/

#include "waveAtmBoundaryLayerSuperposition.H"
#include "uniformDimensionedFields.H"
#include "atmBoundaryLayer.H"
#include "addToRunTimeSelectionTable.H"

// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //

namespace Foam
{
defineTypeNameAndDebug(waveAtmBoundaryLayerSuperposition, 0);
addToRunTimeSelectionTable
(
waveSuperposition,
waveAtmBoundaryLayerSuperposition,
objectRegistry
);
}


// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //

Foam::waveAtmBoundaryLayerSuperposition::waveAtmBoundaryLayerSuperposition
(
const objectRegistry& db
)
:
waveSuperposition(db),
UGasRef_(lookup("UGasRef")),
hRef_(readScalar(lookup("hRef"))),
hWaveMin_(readScalar(lookup("hWaveMin"))),
hWaveMax_(readScalar(lookup("hWaveMax")))
{}


// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //

Foam::waveAtmBoundaryLayerSuperposition::~waveAtmBoundaryLayerSuperposition()
{}


// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //

Foam::tmp<Foam::vectorField> Foam::waveAtmBoundaryLayerSuperposition::UGas
(
const scalar t,
const vectorField& p
) const
{
const vector gHat =
normalised
(
db().lookupObject<uniformDimensionedVectorField>("g").value()
);

const scalar h0 = - gHat & origin();

atmBoundaryLayer atm
(
normalised(UGasRef_),
- gHat,
mag(UGasRef_),
h0 + hRef_,
scalarField(p.size(), hWaveMax_ - hWaveMin_),
scalarField(p.size(), h0 + hWaveMin_)
);

return waveSuperposition::UGas(t, p) + atm.U(p);
}


void Foam::waveAtmBoundaryLayerSuperposition::write(Ostream& os) const
{
waveSuperposition::write(os);

os.writeKeyword("UGasRef") << UGasRef_ << token::END_STATEMENT << nl;
os.writeKeyword("hRef") << hRef_ << token::END_STATEMENT << nl;
os.writeKeyword("hWaveMin") << hWaveMin_ << token::END_STATEMENT << nl;
os.writeKeyword("hWaveMax") << hWaveMax_ << token::END_STATEMENT << nl;
}


// ************************************************************************* //

0 comments on commit 4d6b99f

Please sign in to comment.
You can’t perform that action at this time.