ENH: waveModels - refactored time scaling coefficient

This commit is contained in:
Andrew Heather
2016-11-25 10:49:53 +00:00
parent 02e9433d73
commit 21b3f88a72
9 changed files with 66 additions and 11 deletions

View File

@ -36,6 +36,18 @@ namespace waveModels
} }
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
Foam::scalar Foam::waveModels::waveAbsorptionModel::timeCoeff
(
const scalar t
) const
{
// No time ramping applied applied for absorption
return 1;
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::waveModels::waveAbsorptionModel::waveAbsorptionModel Foam::waveModels::waveAbsorptionModel::waveAbsorptionModel

View File

@ -41,13 +41,20 @@ namespace waveModels
{ {
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
Class waveAbsorptionModel Declaration Class waveAbsorptionModel Declaration
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
class waveAbsorptionModel class waveAbsorptionModel
: :
public waveModel public waveModel
{ {
protected:
// Protected Member Functions
//- Return the time scaling coefficient
virtual scalar timeCoeff(const scalar t) const;
public: public:

View File

@ -41,6 +41,15 @@ namespace waveModels
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
Foam::scalar Foam::waveModels::regularWaveModel::timeCoeff
(
const scalar t
) const
{
return max(0, min(t/rampTime_, 1));
}
Foam::word Foam::waveModels::regularWaveModel::waveType() const Foam::word Foam::waveModels::regularWaveModel::waveType() const
{ {
scalar waveK = 2.0*mathematical::pi/waveLength_; scalar waveK = 2.0*mathematical::pi/waveLength_;
@ -70,6 +79,7 @@ Foam::waveModels::regularWaveModel::regularWaveModel
) )
: :
waveGenerationModel(dict, mesh, patch, false), waveGenerationModel(dict, mesh, patch, false),
rampTime_(VSMALL),
wavePeriod_(0), wavePeriod_(0),
waveLength_(0), waveLength_(0),
wavePhase_(1.5*mathematical::pi) wavePhase_(1.5*mathematical::pi)
@ -93,6 +103,8 @@ bool Foam::waveModels::regularWaveModel::read(const dictionary& overrideDict)
{ {
if (waveGenerationModel::read(overrideDict)) if (waveGenerationModel::read(overrideDict))
{ {
lookup("rampTime") >> rampTime_;
lookup("wavePeriod") >> wavePeriod_; lookup("wavePeriod") >> wavePeriod_;
if (wavePeriod_ < 0) if (wavePeriod_ < 0)
{ {
@ -117,7 +129,8 @@ void Foam::waveModels::regularWaveModel::info(Ostream& os) const
{ {
waveGenerationModel::info(os); waveGenerationModel::info(os);
os << " Wave period : " << wavePeriod_ << nl os << " Ramp time : " << rampTime_ << nl
<< " Wave period : " << wavePeriod_ << nl
<< " Wave length : " << waveLength_ << nl << " Wave length : " << waveLength_ << nl
<< " Wave phase : " << wavePhase_ << nl; << " Wave phase : " << wavePhase_ << nl;
} }

View File

@ -61,6 +61,9 @@ protected:
// Protected data // Protected data
//- Ramp time
scalar rampTime_;
//- Wave period //- Wave period
scalar wavePeriod_; scalar wavePeriod_;
@ -73,8 +76,11 @@ protected:
// Protected Member Functions // Protected Member Functions
//- Return the time scaling coefficient
virtual scalar timeCoeff(const scalar t) const;
//- Return word description of wave type //- Return word description of wave type
word waveType() const; virtual word waveType() const;
public: public:

View File

@ -27,6 +27,8 @@ License
#include "polyPatch.H" #include "polyPatch.H"
#include "SubField.H" #include "SubField.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam namespace Foam
{ {
namespace waveModels namespace waveModels
@ -36,6 +38,18 @@ namespace waveModels
} }
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
Foam::scalar Foam::waveModels::solitaryWaveModel::timeCoeff
(
const scalar t
) const
{
// Ramping not applicable to solitary waves
return 1;
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::waveModels::solitaryWaveModel::solitaryWaveModel Foam::waveModels::solitaryWaveModel::solitaryWaveModel

View File

@ -59,6 +59,12 @@ protected:
const scalar x0_; const scalar x0_;
// Protected Member Functions
//- Return the time scaling coefficient
virtual scalar timeCoeff(const scalar t) const;
public: public:
//- Runtime type information //- Runtime type information

View File

@ -72,7 +72,6 @@ bool Foam::waveModels::waveGenerationModel::read(const dictionary& overrideDict)
{ {
if (waveModel::read(overrideDict)) if (waveModel::read(overrideDict))
{ {
lookup("rampTime") >> rampTime_;
lookup("activeAbsorption") >> activeAbsorption_; lookup("activeAbsorption") >> activeAbsorption_;
lookup("waveHeight") >> waveHeight_; lookup("waveHeight") >> waveHeight_;
@ -98,8 +97,7 @@ void Foam::waveModels::waveGenerationModel::info(Ostream& os) const
{ {
waveModel::info(os); waveModel::info(os);
os << " Ramp time : " << rampTime_ << nl os << " Wave height : " << waveHeight_ << nl
<< " Wave height : " << waveHeight_ << nl
<< " Wave angle : " << 180/mathematical::pi*waveAngle_ << nl; << " Wave angle : " << 180/mathematical::pi*waveAngle_ << nl;
} }

View File

@ -269,7 +269,6 @@ Foam::waveModel::waveModel
zMax_(), zMax_(),
waterDepthRef_(0), waterDepthRef_(0),
initialDepth_(0), initialDepth_(0),
rampTime_(VSMALL),
currTimeIndex_(-1), currTimeIndex_(-1),
activeAbsorption_(false), activeAbsorption_(false),
U_(patch.size(), vector::zero), U_(patch.size(), vector::zero),
@ -350,7 +349,7 @@ void Foam::waveModel::correct(const scalar t)
<< patch_.name() << endl; << patch_.name() << endl;
// Time ramp weight // Time ramp weight
const scalar tCoeff = max(0, min(t/rampTime_, 1)); const scalar tCoeff = timeCoeff(t);
// Reset the velocity and phase fraction fields // Reset the velocity and phase fraction fields
U_ = vector::zero; U_ = vector::zero;

View File

@ -111,9 +111,6 @@ protected:
//- Initial depth / [m] //- Initial depth / [m]
scalar initialDepth_; scalar initialDepth_;
//- Ramp time
scalar rampTime_;
//- Time index used for updating //- Time index used for updating
label currTimeIndex_; label currTimeIndex_;
@ -138,6 +135,9 @@ protected:
//- Water level //- Water level
virtual tmp<scalarField> waterLevel() const; virtual tmp<scalarField> waterLevel() const;
//- Return the time scaling coefficient
virtual scalar timeCoeff(const scalar t) const = 0;
//- Set the water level //- Set the water level
virtual void setLevel virtual void setLevel
( (