BUG: waveModels - corrected wavelength calculation for StokesV model; code clean-up

This commit is contained in:
Andrew Heather
2017-02-03 12:17:42 +00:00
parent b4f0b2930d
commit 417ff3bc2a
22 changed files with 397 additions and 343 deletions

View File

@ -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) 2016 OpenCFD Ltd. \\ / A nd | Copyright (C) 2016-2017 OpenCFD Ltd.
\\/ M anipulation | Copyright (C) 2015 IH-Cantabria \\/ M anipulation | Copyright (C) 2015 IH-Cantabria
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -62,7 +62,7 @@ Foam::waveModels::waveAbsorptionModel::waveAbsorptionModel
{ {
if (readFields) if (readFields)
{ {
read(dict); readDict(dict);
} }
} }
@ -75,9 +75,12 @@ Foam::waveModels::waveAbsorptionModel::~waveAbsorptionModel()
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool Foam::waveModels::waveAbsorptionModel::read(const dictionary& overrideDict) bool Foam::waveModels::waveAbsorptionModel::readDict
(
const dictionary& overrideDict
)
{ {
if (waveModel::read(overrideDict)) if (waveModel::readDict(overrideDict))
{ {
// Note: always set to true // Note: always set to true
activeAbsorption_ = true; activeAbsorption_ = true;

View File

@ -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) 2016 OpenCFD Ltd. \\ / A nd | Copyright (C) 2016-2017 OpenCFD Ltd.
\\/ M anipulation | Copyright (C) 2015 IH-Cantabria \\/ M anipulation | Copyright (C) 2015 IH-Cantabria
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -77,7 +77,7 @@ public:
// Public Member Functions // Public Member Functions
//- Read from dictionary //- Read from dictionary
virtual bool read(const dictionary& overrideDict); virtual bool readDict(const dictionary& overrideDict);
}; };

View File

@ -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) 2016 OpenCFD Ltd. \\ / A nd | Copyright (C) 2016-2017 OpenCFD Ltd.
\\/ M anipulation | Copyright (C) 2015 IH-Cantabria \\/ M anipulation | Copyright (C) 2015 IH-Cantabria
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -96,7 +96,7 @@ Foam::waveModels::shallowWaterAbsorption::shallowWaterAbsorption
{ {
if (readFields) if (readFields)
{ {
read(dict); readDict(dict);
} }
} }
@ -109,12 +109,12 @@ Foam::waveModels::shallowWaterAbsorption::~shallowWaterAbsorption()
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool Foam::waveModels::shallowWaterAbsorption::read bool Foam::waveModels::shallowWaterAbsorption::readDict
( (
const dictionary& overrideDict const dictionary& overrideDict
) )
{ {
return waveAbsorptionModel::read(overrideDict); return waveAbsorptionModel::readDict(overrideDict);
} }

View File

@ -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) 2016 OpenCFD Ltd. \\ / A nd | Copyright (C) 2016-2017 OpenCFD Ltd.
\\/ M anipulation | Copyright (C) 2015 IH-Cantabria \\/ M anipulation | Copyright (C) 2015 IH-Cantabria
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -94,7 +94,7 @@ public:
// Public Member Functions // Public Member Functions
//- Read from dictionary //- Read from dictionary
virtual bool read(const dictionary& overrideDict); virtual bool readDict(const dictionary& overrideDict);
}; };

View File

@ -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) 2016 OpenCFD Ltd. \\ / A nd | Copyright (C) 2016-2017 OpenCFD Ltd.
\\/ M anipulation | Copyright (C) 2015 IH-Cantabria \\/ M anipulation | Copyright (C) 2015 IH-Cantabria
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -86,7 +86,7 @@ Foam::waveModels::regularWaveModel::regularWaveModel
{ {
if (readFields) if (readFields)
{ {
read(dict); readDict(dict);
} }
} }
@ -99,9 +99,12 @@ Foam::waveModels::regularWaveModel::~regularWaveModel()
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool Foam::waveModels::regularWaveModel::read(const dictionary& overrideDict) bool Foam::waveModels::regularWaveModel::readDict
(
const dictionary& overrideDict
)
{ {
if (waveGenerationModel::read(overrideDict)) if (waveGenerationModel::readDict(overrideDict))
{ {
lookup("rampTime") >> rampTime_; lookup("rampTime") >> rampTime_;

View File

@ -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) 2016 OpenCFD Ltd. \\ / A nd | Copyright (C) 2016-2017 OpenCFD Ltd.
\\/ M anipulation | Copyright (C) 2015 IH-Cantabria \\/ M anipulation | Copyright (C) 2015 IH-Cantabria
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -105,12 +105,13 @@ public:
// Public Member Functions // Public Member Functions
//- Read from dictionary //- Read from dictionary
virtual bool read(const dictionary& overrideDict); virtual bool readDict(const dictionary& overrideDict);
//- Info //- Info
virtual void info(Ostream& os) const; virtual void info(Ostream& os) const;
}; };
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace waveModels } // End namespace waveModels

View File

@ -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) 2016 OpenCFD Ltd. \\ / A nd | Copyright (C) 2016-2017 OpenCFD Ltd.
\\/ M anipulation | Copyright (C) 2015 IH-Cantabria \\/ M anipulation | Copyright (C) 2015 IH-Cantabria
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -70,7 +70,7 @@ Foam::waveModels::solitaryWaveModel::solitaryWaveModel
{ {
if (readFields) if (readFields)
{ {
read(dict); readDict(dict);
} }
} }
@ -83,9 +83,12 @@ Foam::waveModels::solitaryWaveModel::~solitaryWaveModel()
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool Foam::waveModels::solitaryWaveModel::read(const dictionary& overrideDict) bool Foam::waveModels::solitaryWaveModel::readDict
(
const dictionary& overrideDict
)
{ {
if (waveGenerationModel::read(overrideDict)) if (waveGenerationModel::readDict(overrideDict))
{ {
return true; return true;
} }

View File

@ -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) 2016 OpenCFD Ltd. \\ / A nd | Copyright (C) 2016-2017 OpenCFD Ltd.
\\/ M anipulation | Copyright (C) 2015 IH-Cantabria \\/ M anipulation | Copyright (C) 2015 IH-Cantabria
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -87,12 +87,13 @@ public:
// Public Member Functions // Public Member Functions
//- Read from dictionary //- Read from dictionary
virtual bool read(const dictionary& overrideDict); virtual bool readDict(const dictionary& overrideDict);
//- Info //- Info
virtual void info(Ostream& os) const; virtual void info(Ostream& os) const;
}; };
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace waveModels } // End namespace waveModels

View File

@ -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) 2016 OpenCFD Ltd. \\ / A nd | Copyright (C) 2016-2017 OpenCFD Ltd.
\\/ M anipulation | Copyright (C) 2015 IH-Cantabria \\/ M anipulation | Copyright (C) 2015 IH-Cantabria
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -55,7 +55,7 @@ Foam::waveModels::waveGenerationModel::waveGenerationModel
{ {
if (readFields) if (readFields)
{ {
read(dict); readDict(dict);
} }
} }
@ -68,9 +68,12 @@ Foam::waveModels::waveGenerationModel::~waveGenerationModel()
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool Foam::waveModels::waveGenerationModel::read(const dictionary& overrideDict) bool Foam::waveModels::waveGenerationModel::readDict
(
const dictionary& overrideDict
)
{ {
if (waveModel::read(overrideDict)) if (waveModel::readDict(overrideDict))
{ {
lookup("activeAbsorption") >> activeAbsorption_; lookup("activeAbsorption") >> activeAbsorption_;

View File

@ -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) 2016 OpenCFD Ltd. \\ / A nd | Copyright (C) 2016-2017 OpenCFD Ltd.
\\/ M anipulation | Copyright (C) 2015 IH-Cantabria \\/ M anipulation | Copyright (C) 2015 IH-Cantabria
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -80,7 +80,7 @@ public:
// Public Member Functions // Public Member Functions
//- Read from dictionary //- Read from dictionary
virtual bool read(const dictionary& overrideDict); virtual bool readDict(const dictionary& overrideDict);
//- Info //- Info
virtual void info(Ostream& os) const; virtual void info(Ostream& os) const;

View File

@ -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) 2016 OpenCFD Ltd. \\ / A nd | Copyright (C) 2016-2017 OpenCFD Ltd.
\\/ M anipulation | Copyright (C) 2015 IH-Cantabria \\/ M anipulation | Copyright (C) 2015 IH-Cantabria
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -101,7 +101,7 @@ Foam::vector Foam::waveModels::Boussinesq::Deta
} }
Foam::vector Foam::waveModels::Boussinesq::U Foam::vector Foam::waveModels::Boussinesq::Uf
( (
const scalar H, const scalar H,
const scalar h, const scalar h,
@ -139,6 +139,8 @@ Foam::vector Foam::waveModels::Boussinesq::U
} }
// * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * * //
void Foam::waveModels::Boussinesq::setLevel void Foam::waveModels::Boussinesq::setLevel
( (
const scalar t, const scalar t,
@ -165,44 +167,6 @@ void Foam::waveModels::Boussinesq::setLevel
} }
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::waveModels::Boussinesq::Boussinesq
(
const dictionary& dict,
const fvMesh& mesh,
const polyPatch& patch,
const bool readFields
)
:
solitaryWaveModel(dict, mesh, patch, false)
{
if (readFields)
{
read(dict);
}
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::waveModels::Boussinesq::~Boussinesq()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool Foam::waveModels::Boussinesq::read(const dictionary& overrideDict)
{
if (solitaryWaveModel::read(overrideDict))
{
return true;
}
return false;
}
void Foam::waveModels::Boussinesq::setVelocity void Foam::waveModels::Boussinesq::setVelocity
( (
const scalar t, const scalar t,
@ -224,7 +188,7 @@ void Foam::waveModels::Boussinesq::setVelocity
{ {
const label paddlei = faceToPaddle_[facei]; const label paddlei = faceToPaddle_[facei];
const vector Uf = U const vector Uf = this->Uf
( (
waveHeight_, waveHeight_,
waterDepthRef_, waterDepthRef_,
@ -242,6 +206,44 @@ void Foam::waveModels::Boussinesq::setVelocity
} }
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::waveModels::Boussinesq::Boussinesq
(
const dictionary& dict,
const fvMesh& mesh,
const polyPatch& patch,
const bool readFields
)
:
solitaryWaveModel(dict, mesh, patch, false)
{
if (readFields)
{
readDict(dict);
}
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::waveModels::Boussinesq::~Boussinesq()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool Foam::waveModels::Boussinesq::readDict(const dictionary& overrideDict)
{
if (solitaryWaveModel::readDict(overrideDict))
{
return true;
}
return false;
}
void Foam::waveModels::Boussinesq::info(Ostream& os) const void Foam::waveModels::Boussinesq::info(Ostream& os) const
{ {
solitaryWaveModel::info(os); solitaryWaveModel::info(os);

View File

@ -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) 2016 OpenCFD Ltd. \\ / A nd | Copyright (C) 2016-2017 OpenCFD Ltd.
\\/ M anipulation | Copyright (C) 2015 IH-Cantabria \\/ M anipulation | Copyright (C) 2015 IH-Cantabria
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -49,12 +49,12 @@ class Boussinesq
: :
public solitaryWaveModel public solitaryWaveModel
{ {
protected: private:
// Protected Member Functions // Private Member Functions
//- Wave height //- Wave height
virtual scalar eta scalar eta
( (
const scalar H, const scalar H,
const scalar h, const scalar h,
@ -66,7 +66,7 @@ protected:
) const; ) const;
//- Wave //- Wave
virtual vector Deta vector Deta
( (
const scalar H, const scalar H,
const scalar h, const scalar h,
@ -78,7 +78,7 @@ protected:
) const; ) const;
//- Wave velocity //- Wave velocity
virtual vector U vector Uf
( (
const scalar H, const scalar H,
const scalar h, const scalar h,
@ -90,6 +90,11 @@ protected:
const scalar z const scalar z
) const; ) const;
protected:
// Protected Member Functions
//- Set the water level //- Set the water level
virtual void setLevel virtual void setLevel
( (
@ -128,12 +133,13 @@ public:
// Public Member Functions // Public Member Functions
//- Read from dictionary //- Read from dictionary
virtual bool read(const dictionary& overrideDict); virtual bool readDict(const dictionary& overrideDict);
//- Info //- Info
virtual void info(Ostream& os) const; virtual void info(Ostream& os) const;
}; };
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace waveModels } // End namespace waveModels

View File

@ -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) 2016 OpenCFD Ltd. \\ / A nd | Copyright (C) 2016-2017 OpenCFD Ltd.
\\/ M anipulation | Copyright (C) 2015 IH-Cantabria \\/ M anipulation | Copyright (C) 2015 IH-Cantabria
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -48,6 +48,26 @@ namespace waveModels
// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * // // * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
Foam::scalar Foam::waveModels::StokesI::eta
(
const scalar H,
const scalar Kx,
const scalar x,
const scalar Ky,
const scalar y,
const scalar omega,
const scalar t,
const scalar phase
) const
{
scalar phaseTot = Kx*x + Ky*y - omega*t + phase;
return H*0.5*cos(phaseTot);
}
// * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * * //
Foam::scalar Foam::waveModels::StokesI::waveLength Foam::scalar Foam::waveModels::StokesI::waveLength
( (
const scalar h, const scalar h,
@ -66,24 +86,7 @@ Foam::scalar Foam::waveModels::StokesI::waveLength
} }
Foam::scalar Foam::waveModels::StokesI::eta Foam::vector Foam::waveModels::StokesI::UfBase
(
const scalar H,
const scalar Kx,
const scalar x,
const scalar Ky,
const scalar y,
const scalar omega,
const scalar t,
const scalar phase
) const
{
scalar phaseTot = Kx*x + Ky*y - omega*t + phase;
return H*0.5*cos(phaseTot);
}
Foam::vector Foam::waveModels::StokesI::U
( (
const scalar H, const scalar H,
const scalar h, const scalar h,
@ -141,46 +144,6 @@ void Foam::waveModels::StokesI::setLevel
} }
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::waveModels::StokesI::StokesI
(
const dictionary& dict,
const fvMesh& mesh,
const polyPatch& patch,
const bool readFields
)
:
regularWaveModel(dict, mesh, patch, false)
{
if (readFields)
{
read(dict);
}
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::waveModels::StokesI::~StokesI()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool Foam::waveModels::StokesI::read(const dictionary& overrideDict)
{
if (regularWaveModel::read(overrideDict))
{
waveLength_ = waveLength(waterDepthRef_, wavePeriod_);
return true;
}
return false;
}
void Foam::waveModels::StokesI::setVelocity void Foam::waveModels::StokesI::setVelocity
( (
const scalar t, const scalar t,
@ -207,7 +170,7 @@ void Foam::waveModels::StokesI::setVelocity
{ {
const label paddlei = faceToPaddle_[facei]; const label paddlei = faceToPaddle_[facei];
const vector Uf = U const vector Uf = UfBase
( (
waveHeight_, waveHeight_,
waterDepthRef_, waterDepthRef_,
@ -227,6 +190,46 @@ void Foam::waveModels::StokesI::setVelocity
} }
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::waveModels::StokesI::StokesI
(
const dictionary& dict,
const fvMesh& mesh,
const polyPatch& patch,
const bool readFields
)
:
regularWaveModel(dict, mesh, patch, false)
{
if (readFields)
{
readDict(dict);
}
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::waveModels::StokesI::~StokesI()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool Foam::waveModels::StokesI::readDict(const dictionary& overrideDict)
{
if (regularWaveModel::readDict(overrideDict))
{
waveLength_ = waveLength(waterDepthRef_, wavePeriod_);
return true;
}
return false;
}
void Foam::waveModels::StokesI::info(Ostream& os) const void Foam::waveModels::StokesI::info(Ostream& os) const
{ {
regularWaveModel::info(os); regularWaveModel::info(os);

View File

@ -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) 2016 OpenCFD Ltd. \\ / A nd | Copyright (C) 2016-2017 OpenCFD Ltd.
\\/ M anipulation | Copyright (C) 2015 IH-Cantabria \\/ M anipulation | Copyright (C) 2015 IH-Cantabria
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -49,15 +49,12 @@ class StokesI
: :
public regularWaveModel public regularWaveModel
{ {
protected: private:
// Protected Member Functions // Private Member Functions
//- Return the wavelength
virtual scalar waveLength(const scalar h, const scalar T) const;
//- Wave height //- Wave height
virtual scalar eta scalar eta
( (
const scalar H, const scalar H,
const scalar Kx, const scalar Kx,
@ -69,8 +66,16 @@ protected:
const scalar phase const scalar phase
) const; ) const;
protected:
// Protected Member Functions
//- Return the wavelength
virtual scalar waveLength(const scalar h, const scalar T) const;
//- Wave velocity //- Wave velocity
virtual vector U virtual vector UfBase
( (
const scalar H, const scalar H,
const scalar h, const scalar h,
@ -84,7 +89,6 @@ protected:
const scalar z const scalar z
) const; ) const;
//- Set the water level //- Set the water level
virtual void setLevel virtual void setLevel
( (
@ -123,12 +127,13 @@ public:
// Public Member Functions // Public Member Functions
//- Read from dictionary //- Read from dictionary
virtual bool read(const dictionary& overrideDict); virtual bool readDict(const dictionary& overrideDict);
//- Info //- Info
virtual void info(Ostream& os) const; virtual void info(Ostream& os) const;
}; };
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace waveModels } // End namespace waveModels

View File

@ -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) 2016 OpenCFD Ltd. \\ / A nd | Copyright (C) 2016-2017 OpenCFD Ltd.
\\/ M anipulation | Copyright (C) 2015 IH-Cantabria \\/ M anipulation | Copyright (C) 2015 IH-Cantabria
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -71,7 +71,9 @@ Foam::scalar Foam::waveModels::StokesII::eta
} }
Foam::vector Foam::waveModels::StokesII::U // * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * * //
Foam::vector Foam::waveModels::StokesII::UfBase
( (
const scalar H, const scalar H,
const scalar h, const scalar h,
@ -148,7 +150,7 @@ Foam::waveModels::StokesII::StokesII
{ {
if (readFields) if (readFields)
{ {
read(dict); readDict(dict);
} }
} }
@ -161,9 +163,9 @@ Foam::waveModels::StokesII::~StokesII()
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool Foam::waveModels::StokesII::read(const dictionary& overrideDict) bool Foam::waveModels::StokesII::readDict(const dictionary& overrideDict)
{ {
if (StokesI::read(overrideDict)) if (StokesI::readDict(overrideDict))
{ {
return true; return true;
} }

View File

@ -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) 2016 OpenCFD Ltd. \\ / A nd | Copyright (C) 2016-2017 OpenCFD Ltd.
\\/ M anipulation | Copyright (C) 2015 IH-Cantabria \\/ M anipulation | Copyright (C) 2015 IH-Cantabria
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -49,12 +49,12 @@ class StokesII
: :
public StokesI public StokesI
{ {
protected: private:
// Protected Member Functions // Private Member Functions
//- Wave height //- Wave height
virtual scalar eta scalar eta
( (
const scalar H, const scalar H,
const scalar h, const scalar h,
@ -67,8 +67,13 @@ protected:
const scalar phase const scalar phase
) const; ) const;
protected:
// Protected Member Functions
//- Wave velocity //- Wave velocity
virtual vector U virtual vector UfBase
( (
const scalar H, const scalar H,
const scalar h, const scalar h,
@ -112,12 +117,13 @@ public:
// Public Member Functions // Public Member Functions
//- Read from dictionary //- Read from dictionary
virtual bool read(const dictionary& overrideDict); virtual bool readDict(const dictionary& overrideDict);
//- Info //- Info
virtual void info(Ostream& os) const; virtual void info(Ostream& os) const;
}; };
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace waveModels } // End namespace waveModels

View File

@ -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) 2016 OpenCFD Ltd. \\ / A nd | Copyright (C) 2016-2017 OpenCFD Ltd.
\\/ M anipulation | Copyright (C) 2015 IH-Cantabria \\/ M anipulation | Copyright (C) 2015 IH-Cantabria
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -680,7 +680,7 @@ Foam::scalar Foam::waveModels::StokesV::eta
} }
Foam::vector Foam::waveModels::StokesV::U Foam::vector Foam::waveModels::StokesV::Uf
( (
const scalar d, const scalar d,
const scalar kx, const scalar kx,
@ -722,17 +722,17 @@ Foam::vector Foam::waveModels::StokesV::U
scalar u = scalar u =
a1u*cosh(k*z)*cos(theta) a1u*cosh(k*z)*cos(theta)
+ a2u*cosh(2.0*k*z)*cos(2.0*(theta)) + a2u*cosh(2*k*z)*cos(2*theta)
+ a3u*cosh(3.0*k*z)*cos(3.0*(theta)) + a3u*cosh(3*k*z)*cos(3*theta)
+ a4u*cosh(4.0*k*z)*cos(4.0*(theta)) + a4u*cosh(4*k*z)*cos(4*theta)
+ a5u*cosh(5.0*k*z)*cos(5.0*(theta)); + a5u*cosh(5*k*z)*cos(5*theta);
scalar w = scalar w =
a1u*sinh(k*z)*sin(theta) a1u*sinh(k*z)*sin(theta)
+ a2u*sinh(2.0*k*z)*sin(2.0*(theta)) + a2u*sinh(2*k*z)*sin(2*theta)
+ a3u*sinh(3.0*k*z)*sin(3.0*(theta)) + a3u*sinh(3*k*z)*sin(3*theta)
+ a4u*sinh(4.0*k*z)*sin(4.0*(theta)) + a4u*sinh(4*k*z)*sin(4*theta)
+ a5u*sinh(5.0*k*z)*sin(5.0*(theta)); + a5u*sinh(5*k*z)*sin(5*theta);
scalar v = u*sin(waveAngle_); scalar v = u*sin(waveAngle_);
u *= cos(waveAngle_); u *= cos(waveAngle_);
@ -741,6 +741,8 @@ Foam::vector Foam::waveModels::StokesV::U
} }
// * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * * //
void Foam::waveModels::StokesV::setLevel void Foam::waveModels::StokesV::setLevel
( (
const scalar t, const scalar t,
@ -773,71 +775,6 @@ void Foam::waveModels::StokesV::setLevel
} }
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::waveModels::StokesV::StokesV
(
const dictionary& dict,
const fvMesh& mesh,
const polyPatch& patch,
const bool readFields
)
:
regularWaveModel(dict, mesh, patch, false),
lambda_(0)
{
if (readFields)
{
read(dict);
}
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::waveModels::StokesV::~StokesV()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool Foam::waveModels::StokesV::read(const dictionary& overrideDict)
{
if (regularWaveModel::read(overrideDict))
{
scalar f1;
scalar f2;
scalar waveK;
initialise
(
waveHeight_,
waterDepthRef_,
wavePeriod_,
waveK,
lambda_,
f1,
f2
);
if (f1 > 0.001 || f2 > 0.001)
{
FatalErrorInFunction
<< "No convergence for Stokes V wave theory" << nl
<< " f1: " << f1 << nl
<< " f2: " << f2 << nl
<< exit(FatalError);
}
waveLength_ = 2.0*mathematical::pi/waveK;
return true;
}
return false;
}
void Foam::waveModels::StokesV::setVelocity void Foam::waveModels::StokesV::setVelocity
( (
const scalar t, const scalar t,
@ -863,7 +800,7 @@ void Foam::waveModels::StokesV::setVelocity
{ {
const label paddlei = faceToPaddle_[facei]; const label paddlei = faceToPaddle_[facei];
const vector Uf = U const vector Uf = this->Uf
( (
waterDepthRef_, waterDepthRef_,
waveKx, waveKx,
@ -883,9 +820,72 @@ void Foam::waveModels::StokesV::setVelocity
} }
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::waveModels::StokesV::StokesV
(
const dictionary& dict,
const fvMesh& mesh,
const polyPatch& patch,
const bool readFields
)
:
StokesI(dict, mesh, patch, false),
lambda_(0)
{
if (readFields)
{
readDict(dict);
}
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::waveModels::StokesV::~StokesV()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool Foam::waveModels::StokesV::readDict(const dictionary& overrideDict)
{
if (StokesI::readDict(overrideDict))
{
scalar f1;
scalar f2;
scalar waveK;
initialise
(
waveHeight_,
waterDepthRef_,
wavePeriod_,
waveK,
lambda_,
f1,
f2
);
if (f1 > 0.001 || f2 > 0.001)
{
FatalErrorInFunction
<< "No convergence for Stokes V wave theory" << nl
<< " f1: " << f1 << nl
<< " f2: " << f2 << nl
<< exit(FatalError);
}
return true;
}
return false;
}
void Foam::waveModels::StokesV::info(Ostream& os) const void Foam::waveModels::StokesV::info(Ostream& os) const
{ {
regularWaveModel::info(os); StokesI::info(os);
os << " Lambda : " << lambda_ << nl os << " Lambda : " << lambda_ << nl
<< " Wave type : " << waveType() << nl; << " Wave type : " << waveType() << nl;

View File

@ -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) 2016 OpenCFD Ltd. \\ / A nd | Copyright (C) 2016-2017 OpenCFD Ltd.
\\/ M anipulation | Copyright (C) 2015 IH-Cantabria \\/ M anipulation | Copyright (C) 2015 IH-Cantabria
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -39,7 +39,7 @@ Description
#ifndef waveModels_StokesV_H #ifndef waveModels_StokesV_H
#define waveModels_StokesV_H #define waveModels_StokesV_H
#include "regularWaveModel.H" #include "StokesIWaveModel.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -54,71 +54,65 @@ namespace waveModels
class StokesV class StokesV
: :
public regularWaveModel public StokesI
{ {
protected: private:
// Proteced Data // Private Member Functions
//-
scalar lambda_;
// Protected Member Functions
// Model coefficients // Model coefficients
virtual scalar A11(const scalar h, const scalar k) const; scalar A11(const scalar h, const scalar k) const;
virtual scalar A13(const scalar h, const scalar k) const; scalar A13(const scalar h, const scalar k) const;
virtual scalar A15(const scalar h, const scalar k) const; scalar A15(const scalar h, const scalar k) const;
virtual scalar A22(const scalar h, const scalar k) const; scalar A22(const scalar h, const scalar k) const;
virtual scalar A24(const scalar h, const scalar k) const; scalar A24(const scalar h, const scalar k) const;
virtual scalar A33(const scalar h, const scalar k) const; scalar A33(const scalar h, const scalar k) const;
virtual scalar A35(const scalar h, const scalar k) const; scalar A35(const scalar h, const scalar k) const;
virtual scalar A44(const scalar h, const scalar k) const; scalar A44(const scalar h, const scalar k) const;
virtual scalar A55(const scalar h, const scalar k) const; scalar A55(const scalar h, const scalar k) const;
virtual scalar B22(const scalar h, const scalar k) const; scalar B22(const scalar h, const scalar k) const;
virtual scalar B24(const scalar h, const scalar k) const; scalar B24(const scalar h, const scalar k) const;
virtual scalar B33(const scalar h, const scalar k) const; scalar B33(const scalar h, const scalar k) const;
virtual scalar B33k(const scalar h, const scalar k) const; scalar B33k(const scalar h, const scalar k) const;
virtual scalar B35(const scalar h, const scalar k) const; scalar B35(const scalar h, const scalar k) const;
virtual scalar B35k(const scalar h, const scalar k) const; scalar B35k(const scalar h, const scalar k) const;
virtual scalar B44(const scalar h, const scalar k) const; scalar B44(const scalar h, const scalar k) const;
virtual scalar B55(const scalar h, const scalar k) const; scalar B55(const scalar h, const scalar k) const;
virtual scalar B55k(const scalar h, const scalar k) const; scalar B55k(const scalar h, const scalar k) const;
virtual scalar C1(const scalar h, const scalar k) const; scalar C1(const scalar h, const scalar k) const;
virtual scalar C1k(const scalar h, const scalar k) const; scalar C1k(const scalar h, const scalar k) const;
virtual scalar C2(const scalar h, const scalar k) const; scalar C2(const scalar h, const scalar k) const;
virtual scalar C2k(const scalar h, const scalar k) const; scalar C2k(const scalar h, const scalar k) const;
virtual scalar C3(const scalar h, const scalar k) const; scalar C3(const scalar h, const scalar k) const;
virtual scalar C4(const scalar h, const scalar k) const; scalar C4(const scalar h, const scalar k) const;
//- Model intialisation //- Model intialisation
virtual void initialise void initialise
( (
const scalar H, const scalar H,
const scalar d, const scalar d,
@ -130,7 +124,7 @@ protected:
) const; ) const;
//- Wave height //- Wave height
virtual scalar eta scalar eta
( (
const scalar h, const scalar h,
const scalar kx, const scalar kx,
@ -144,7 +138,7 @@ protected:
) const; ) const;
//- Wave velocity //- Wave velocity
virtual vector U vector Uf
( (
const scalar d, const scalar d,
const scalar kx, const scalar kx,
@ -158,6 +152,17 @@ protected:
const scalar z const scalar z
) const; ) const;
protected:
// Proteced Data
//-
scalar lambda_;
// Protected Member Functions
//- Set the water level //- Set the water level
virtual void setLevel virtual void setLevel
( (
@ -196,12 +201,13 @@ public:
// Public Member Functions // Public Member Functions
//- Read from dictionary //- Read from dictionary
virtual bool read(const dictionary& overrideDict); virtual bool readDict(const dictionary& overrideDict);
//- Info //- Info
virtual void info(Ostream& os) const; virtual void info(Ostream& os) const;
}; };
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace waveModels } // End namespace waveModels

View File

@ -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) 2016 OpenCFD Ltd. \\ / A nd | Copyright (C) 2016-2017 OpenCFD Ltd.
\\/ M anipulation | Copyright (C) 2015 IH-Cantabria \\/ M anipulation | Copyright (C) 2015 IH-Cantabria
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -189,7 +189,7 @@ Foam::vector Foam::waveModels::cnoidal::dEtaDx
} }
Foam::vector Foam::waveModels::cnoidal::U Foam::vector Foam::waveModels::cnoidal::Uf
( (
const scalar H, const scalar H,
const scalar h, const scalar h,
@ -231,6 +231,8 @@ Foam::vector Foam::waveModels::cnoidal::U
} }
// * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * * //
void Foam::waveModels::cnoidal::setLevel void Foam::waveModels::cnoidal::setLevel
( (
const scalar t, const scalar t,
@ -262,55 +264,6 @@ void Foam::waveModels::cnoidal::setLevel
} }
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::waveModels::cnoidal::cnoidal
(
const dictionary& dict,
const fvMesh& mesh,
const polyPatch& patch,
const bool readFields
)
:
regularWaveModel(dict, mesh, patch, false),
m_(0)
{
if (readFields)
{
read(dict);
}
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::waveModels::cnoidal::~cnoidal()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool Foam::waveModels::cnoidal::read(const dictionary& overrideDict)
{
if (regularWaveModel::read(overrideDict))
{
// Initialise m parameter and wavelength
initialise
(
waveHeight_,
waterDepthRef_,
wavePeriod_,
m_,
waveLength_
);
return true;
}
return false;
}
void Foam::waveModels::cnoidal::setVelocity void Foam::waveModels::cnoidal::setVelocity
( (
const scalar t, const scalar t,
@ -336,7 +289,7 @@ void Foam::waveModels::cnoidal::setVelocity
{ {
const label paddlei = faceToPaddle_[facei]; const label paddlei = faceToPaddle_[facei];
const vector Uf = U const vector Uf = this->Uf
( (
waveHeight_, waveHeight_,
waterDepthRef_, waterDepthRef_,
@ -356,6 +309,55 @@ void Foam::waveModels::cnoidal::setVelocity
} }
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::waveModels::cnoidal::cnoidal
(
const dictionary& dict,
const fvMesh& mesh,
const polyPatch& patch,
const bool readFields
)
:
regularWaveModel(dict, mesh, patch, false),
m_(0)
{
if (readFields)
{
readDict(dict);
}
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::waveModels::cnoidal::~cnoidal()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool Foam::waveModels::cnoidal::readDict(const dictionary& overrideDict)
{
if (regularWaveModel::readDict(overrideDict))
{
// Initialise m parameter and wavelength
initialise
(
waveHeight_,
waterDepthRef_,
wavePeriod_,
m_,
waveLength_
);
return true;
}
return false;
}
void Foam::waveModels::cnoidal::info(Ostream& os) const void Foam::waveModels::cnoidal::info(Ostream& os) const
{ {
regularWaveModel::info(os); regularWaveModel::info(os);

View File

@ -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) 2016 OpenCFD Ltd. \\ / A nd | Copyright (C) 2016-2017 OpenCFD Ltd.
\\/ M anipulation | Copyright (C) 2015 IH-Cantabria \\/ M anipulation | Copyright (C) 2015 IH-Cantabria
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -49,16 +49,11 @@ class cnoidal
: :
public regularWaveModel public regularWaveModel
{ {
protected: private:
// Protected data // Private Member Functions
//- `m' coefficient
scalar m_;
// Protected Member Functions
//- Initialise
void initialise void initialise
( (
const scalar H, const scalar H,
@ -69,7 +64,7 @@ protected:
) const; ) const;
//- Wave height //- Wave height
virtual scalar eta scalar eta
( (
const scalar H, const scalar H,
const scalar Kx, const scalar Kx,
@ -107,7 +102,7 @@ protected:
) const; ) const;
//- Wave velocity //- Wave velocity
virtual vector U vector Uf
( (
const scalar H, const scalar H,
const scalar h, const scalar h,
@ -121,6 +116,18 @@ protected:
const scalar z const scalar z
) const; ) const;
protected:
// Protected data
//- `m' coefficient
scalar m_;
// Protected Member Functions
//- Set the water level //- Set the water level
virtual void setLevel virtual void setLevel
( (
@ -159,12 +166,13 @@ public:
// Public Member Functions // Public Member Functions
//- Read from dictionary //- Read from dictionary
virtual bool read(const dictionary& overrideDict); virtual bool readDict(const dictionary& overrideDict);
//- Info //- Info
virtual void info(Ostream& os) const; virtual void info(Ostream& os) const;
}; };
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace waveModels } // End namespace waveModels

View File

@ -277,7 +277,7 @@ Foam::waveModel::waveModel
{ {
if (readFields) if (readFields)
{ {
read(dict); readDict(dict);
} }
} }
@ -290,7 +290,7 @@ Foam::waveModel::~waveModel()
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool Foam::waveModel::read(const dictionary& overrideDict) bool Foam::waveModel::readDict(const dictionary& overrideDict)
{ {
readOpt() = IOobject::READ_IF_PRESENT; readOpt() = IOobject::READ_IF_PRESENT;
if (headerOk()) if (headerOk())

View File

@ -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) 2016 OpenCFD Ltd. \\ / A nd | Copyright (C) 2016-2017 OpenCFD Ltd.
\\/ M anipulation | Copyright (C) 2015 IH-Cantabria \\/ M anipulation | Copyright (C) 2015 IH-Cantabria
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -231,7 +231,7 @@ public:
static word modelName(const word& patchName); static word modelName(const word& patchName);
//- Read from dictionary //- Read from dictionary
virtual bool read(const dictionary& overrideDict); virtual bool readDict(const dictionary& overrideDict);
//- Return the latest wave velocity prediction //- Return the latest wave velocity prediction
virtual const vectorField& U() const; virtual const vectorField& U() const;