STYLE: avoid unrestricted dictionary lookup in randomProcesses, waveModels

- ref issue #762

STYLE: consistency in file vs files for pointNoise and surfaceNoise

- use "files" when available, fallback to "file" otherwise.
This commit is contained in:
Mark Olesen
2018-07-23 18:13:43 +02:00
parent 18b134319d
commit 9f0a80a655
56 changed files with 153 additions and 312 deletions

View File

@ -144,8 +144,8 @@ Foam::fft::realTransform1D(const scalarField& field)
fftw_execute(plan);
// field[0] = DC component
tmp<complexField> tresult(new complexField(nBy2 + 1));
complexField& result = tresult.ref();
auto tresult = tmp<complexField>::New(nBy2 + 1);
auto& result = tresult.ref();
result[0].Re() = out[0];
result[nBy2].Re() = out[nBy2];
@ -237,7 +237,7 @@ Foam::tmp<Foam::complexField> Foam::fft::forwardTransform
const UList<int>& nn
)
{
tmp<complexField> tresult(new complexField(tfield));
auto tresult = tmp<complexField>::New(tfield);
transform(tresult.ref(), nn, FORWARD_TRANSFORM);
@ -253,7 +253,7 @@ Foam::tmp<Foam::complexField> Foam::fft::reverseTransform
const UList<int>& nn
)
{
tmp<complexField> tresult(new complexField(tfield));
auto tresult = tmp<complexField>::New(tfield);
transform(tresult.ref(), nn, REVERSE_TRANSFORM);

View File

@ -43,10 +43,10 @@ Foam::tmp<Foam::scalarField> Foam::noiseFFT::frequencies
const scalar deltaT
)
{
tmp<scalarField> tf(new scalarField(N/2, 0));
scalarField& f = tf.ref();
auto tf = tmp<scalarField>::New(N/2, Zero);
auto& f = tf.ref();
scalar deltaf = 1.0/(N*deltaT);
const scalar deltaf = 1.0/(N*deltaT);
forAll(f, i)
{
f[i] = i*deltaf;
@ -297,8 +297,8 @@ Foam::tmp<Foam::scalarField> Foam::noiseFFT::Pf
const label n = planInfo_.windowSize;
const label nBy2 = n/2;
tmp<scalarField> tresult(new scalarField(nBy2 + 1));
scalarField& result = tresult.ref();
auto tresult = tmp<scalarField>::New(nBy2 + 1);
auto& result = tresult.ref();
// 0 th value = DC component
// nBy2 th value = real only if n is even
@ -312,10 +312,8 @@ Foam::tmp<Foam::scalarField> Foam::noiseFFT::Pf
return tresult;
}
else
{
return mag(fft::realTransform1D(tpn));
}
return mag(fft::realTransform1D(tpn));
}

View File

@ -109,7 +109,7 @@ public:
//- Construct from pressure field
noiseFFT(const scalar deltaT, const label windowSize = -1);
//- Destructor
//- Destructor. Cleanup/destroy plan
~noiseFFT();

View File

@ -183,12 +183,6 @@ Foam::noiseModel::noiseModel(const dictionary& dict, const bool readFields)
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::noiseModel::~noiseModel()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool Foam::noiseModel::read(const dictionary& dict)

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2015-2017 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2015-2018 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -66,7 +66,6 @@ Description
writeOctaves | Write octaves data | no | yes
\endtable
SourceFiles
noiseModel.C
@ -92,18 +91,6 @@ namespace Foam
class noiseModel
{
private:
// Private Member Functions
//- No copy construct
noiseModel(const noiseModel&) = delete;
//- No copy assignment
void operator=(const noiseModel&) = delete;
protected:
// Protected Data
@ -196,6 +183,13 @@ protected:
fileName baseFileDir(const label dataseti) const;
//- No copy construct
noiseModel(const noiseModel&) = delete;
//- No copy assignment
void operator=(const noiseModel&) = delete;
public:
//- Runtime type information
@ -220,7 +214,7 @@ public:
noiseModel(const dictionary& dict, const bool readFields = true);
//- Destructor
virtual ~noiseModel();
virtual ~noiseModel() = default;
// Public Member Functions

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2016 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2016-2018 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -29,7 +29,7 @@ License
Foam::autoPtr<Foam::noiseModel> Foam::noiseModel::New(const dictionary& dict)
{
const word modelType(dict.lookup("noiseModel"));
const word modelType(dict.get<word>("noiseModel"));
Info<< "Selecting noiseModel " << modelType << endl;

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2015-2017 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2015-2018 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -226,12 +226,6 @@ pointNoise::pointNoise(const dictionary& dict, const bool readFields)
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
pointNoise::~pointNoise()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void pointNoise::calculate()
@ -242,7 +236,6 @@ void pointNoise::calculate()
return;
}
forAll(inputFileNames_, filei)
{
fileName fName = inputFileNames_[filei];
@ -264,10 +257,10 @@ bool pointNoise::read(const dictionary& dict)
{
if (!dict.readIfPresent("files", inputFileNames_))
{
inputFileNames_.setSize(1);
inputFileNames_.resize(1);
// Note: lookup uses same keyword as used by the CSV constructor
dict.lookup("file") >> inputFileNames_[0];
dict.read("file", inputFileNames_.first());
}
return true;

View File

@ -130,7 +130,7 @@ public:
pointNoise(const dictionary& dict, const bool readFields = true);
//- Destructor
virtual ~pointNoise();
virtual ~pointNoise() = default;
// Public Member Functions

View File

@ -428,22 +428,18 @@ bool surfaceNoise::read(const dictionary& dict)
{
if (noiseModel::read(dict))
{
if (dict.found("file"))
if (!dict.readIfPresent("files", inputFileNames_))
{
inputFileNames_.setSize(1);
dict.lookup("file") >> inputFileNames_[0];
}
else
{
dict.lookup("files") >> inputFileNames_;
inputFileNames_.resize(1);
dict.read("file", inputFileNames_.first());
}
dict.readIfPresent("fftWriteInterval", fftWriteInterval_);
dict.readIfPresent("p", pName_);
dict.lookup("reader") >> readerType_;
dict.read("reader", readerType_);
word writerType(dict.lookup("writer"));
const word writerType(dict.get<word>("writer"));
dictionary optDict
(
dict.subOrEmptyDict("writeOptions").subOrEmptyDict(writerType)

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2015-2017 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2015-2018 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License

View File

@ -63,10 +63,10 @@ UOprocess::UOprocess
RootDeltaT(sqrt(DeltaT)),
UOfield(Mesh.size()),
Alpha(readScalar(UOdict.lookup("UOalpha"))),
Sigma(readScalar(UOdict.lookup("UOsigma"))),
Kupper(readScalar(UOdict.lookup("UOKupper"))),
Klower(readScalar(UOdict.lookup("UOKlower"))),
Alpha(UOdict.get<scalar>("UOalpha")),
Sigma(UOdict.get<scalar>("UOsigma")),
Kupper(UOdict.get<scalar>("UOKupper")),
Klower(UOdict.get<scalar>("UOKlower")),
Scale((Kupper - Klower)*pow(scalar(Mesh.size()), 1.0/vector::dim))
{
const vectorField& K = Mesh;

View File

@ -45,13 +45,13 @@ addToRunTimeSelectionTable(windowModel, Hanning, dictionary);
Hanning::Hanning(const dictionary& dict, const label nSamples)
:
windowModel(dict, nSamples),
symmetric_(readBool(dict.lookup("symmetric"))),
extended_(readBool(dict.lookup("extended"))),
symmetric_(dict.get<bool>("symmetric")),
extended_(dict.get<bool>("extended")),
alpha_(dict.lookupOrDefault("alpha", 0.5)) // Hamming = 0.54
{
// Extend range if required
label offset = extended_ ? 1 : 0;
scalar m = nSamples - 1 + 2*offset;
const label offset = extended_ ? 1 : 0;
const scalar m = nSamples - 1 + 2*offset;
scalarField t(nSamples);
forAll(t, i)
@ -81,19 +81,13 @@ Hanning::Hanning(const dictionary& dict, const label nSamples)
}
}
scalar sumSqr = sum(sqr(wf));
const scalar sumSqr = sum(sqr(wf));
// Normalisation
wf *= sqrt(nSamples/sumSqr);
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Hanning::~Hanning()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool Hanning::symmetric() const

View File

@ -97,7 +97,7 @@ public:
Hanning(const dictionary& dict, const label nSamples);
//- Destructor
virtual ~Hanning();
virtual ~Hanning() = default;
// Public Member Functions

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2016 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2016-2018 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -45,19 +45,13 @@ addToRunTimeSelectionTable(windowModel, uniform, dictionary);
uniform::uniform(const dictionary& dict, const label nSamples)
:
windowModel(dict, nSamples),
value_(readScalar(dict.lookup("value")))
value_(dict.get<scalar>("value"))
{
scalarField& wf = *this;
wf = value_;
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
uniform::~uniform()
{}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace windowModels

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2016 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2016-2018 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -73,7 +73,7 @@ public:
uniform(const dictionary& dict, const label nSamples);
//- Destructor
virtual ~uniform();
virtual ~uniform() = default;
};

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2015-2016 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2015-2018 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -42,17 +42,13 @@ Foam::windowModel::windowModel(const dictionary& dict, const label nSamples)
nOverlapSamples_(0),
nWindow_(dict.lookupOrDefault("nWindow", -1))
{
scalar prc = readScalar(dict.lookup("overlapPercent"));
nOverlapSamples_ = floor(prc/scalar(100)*nSamples);
nOverlapSamples_ = floor
(
dict.get<scalar>("overlapPercent")/scalar(100)*nSamples
);
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::windowModel::~windowModel()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam::label Foam::windowModel::nSamples() const
@ -87,7 +83,7 @@ Foam::label Foam::windowModel::validate(const label nSamplesTotal)
<< exit(FatalError);
}
label nWindowAvailable = nWindowsTotal(nSamplesTotal);
const label nWindowAvailable = nWindowsTotal(nSamplesTotal);
if (nWindow_ == -1)
{
@ -107,7 +103,7 @@ Foam::label Foam::windowModel::validate(const label nSamplesTotal)
<< exit(FatalError);
}
label nRequiredSamples =
const label nRequiredSamples =
nWindow_*nSamples - (nWindow_ - 1)*nOverlapSamples_;
Info<< "Windowing:" << nl

View File

@ -2,8 +2,8 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2016-2018 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -98,7 +98,7 @@ public:
//- Destructor
virtual ~windowModel();
virtual ~windowModel() = default;
// Public Member Functions

View File

@ -33,7 +33,7 @@ Foam::autoPtr<Foam::windowModel> Foam::windowModel::New
const label nSamples
)
{
const word modelType(dict.lookup("windowModel"));
const word modelType(dict.get<word>("windowModel"));
Info<< "Selecting windowModel " << modelType << endl;
@ -53,7 +53,6 @@ Foam::autoPtr<Foam::windowModel> Foam::windowModel::New
(
cstrIter()(dict.subDict(modelType + "Coeffs"), nSamples)
);
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2015-2016 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2015-2018 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -48,8 +48,8 @@ Foam::tmp<Foam::Field<Type>> Foam::windowModel::apply
}
tmp<Field<Type>> tresult(new Field<Type>(nSamples, pTraits<Type>::zero));
Field<Type>& result = tresult.ref();
auto tresult = tmp<Field<Type>>::New(nSamples, Zero);
auto& result = tresult.ref();
label nWindow = nWindowsTotal(fld.size());
if (windowI >= nWindow)

View File

@ -53,7 +53,7 @@ namespace fv
Foam::tmp<Foam::volScalarField>
Foam::fv::multiphaseMangrovesSource::dragCoeff(const volVectorField& U) const
{
tmp<volScalarField> tdragCoeff = tmp<volScalarField>::New
auto tdragCoeff = tmp<volScalarField>::New
(
IOobject
(
@ -66,8 +66,7 @@ Foam::fv::multiphaseMangrovesSource::dragCoeff(const volVectorField& U) const
mesh_,
dimensionedScalar(dimless/dimTime, Zero)
);
volScalarField& dragCoeff = tdragCoeff.ref();
auto& dragCoeff = tdragCoeff.ref();
forAll(zoneIDs_, i)
{
@ -99,7 +98,7 @@ Foam::fv::multiphaseMangrovesSource::dragCoeff(const volVectorField& U) const
Foam::tmp<Foam::volScalarField>
Foam::fv::multiphaseMangrovesSource::inertiaCoeff() const
{
tmp<volScalarField> tinertiaCoeff = tmp<volScalarField>::New
auto tinertiaCoeff = tmp<volScalarField>::New
(
IOobject
(
@ -112,8 +111,7 @@ Foam::fv::multiphaseMangrovesSource::inertiaCoeff() const
mesh_,
dimensionedScalar(dimless, Zero)
);
volScalarField& inertiaCoeff = tinertiaCoeff.ref();
auto& inertiaCoeff = tinertiaCoeff.ref();
const scalar pi = constant::mathematical::pi;
@ -229,7 +227,7 @@ bool Foam::fv::multiphaseMangrovesSource::read(const dictionary& dict)
const word& regionName = regionNames[i];
const dictionary& modelDict = regionsDict.subDict(regionName);
const word& zoneName = modelDict.lookup("cellZone");
const word zoneName(modelDict.get<word>("cellZone"));
zoneIDs_[i] = mesh_.cellZones().findIndices(zoneName);
if (zoneIDs_[i].empty())
{
@ -239,18 +237,16 @@ bool Foam::fv::multiphaseMangrovesSource::read(const dictionary& dict)
<< exit(FatalError);
}
modelDict.lookup("a") >> aZone_[i];
modelDict.lookup("N") >> NZone_[i];
modelDict.lookup("Cm") >> CmZone_[i];
modelDict.lookup("Cd") >> CdZone_[i];
modelDict.read("a", aZone_[i]);
modelDict.read("N", NZone_[i]);
modelDict.read("Cm", CmZone_[i]);
modelDict.read("Cd", CdZone_[i]);
}
return true;
}
else
{
return false;
}
return false;
}

View File

@ -47,12 +47,12 @@ SourceFiles
namespace Foam
{
// Forward declarations
class MangrovesModel;
namespace fv
{
/*---------------------------------------------------------------------------*\
Class multiphaseMangrovesSource Declaration
\*---------------------------------------------------------------------------*/
@ -63,12 +63,11 @@ class multiphaseMangrovesSource
{
// Private Member Functions
//- Disallow default bitwise copy construct
multiphaseMangrovesSource(const multiphaseMangrovesSource&);
//- Disallow default bitwise assignment
void operator=(const multiphaseMangrovesSource&);
//- No copy construct
multiphaseMangrovesSource(const multiphaseMangrovesSource&) = delete;
//- No copy assignment
void operator=(const multiphaseMangrovesSource&) = delete;
protected:
@ -124,8 +123,7 @@ public:
//- Destructor
virtual ~multiphaseMangrovesSource()
{}
virtual ~multiphaseMangrovesSource() = default;
// Member Functions

View File

@ -55,7 +55,7 @@ Foam::fv::multiphaseMangrovesTurbulenceModel::kCoeff
const volVectorField& U
) const
{
tmp<volScalarField> tkCoeff = tmp<volScalarField>::New
auto tkCoeff = tmp<volScalarField>::New
(
IOobject
(
@ -101,7 +101,7 @@ Foam::fv::multiphaseMangrovesTurbulenceModel::epsilonCoeff
const volVectorField& U
) const
{
tmp<volScalarField> tepsilonCoeff = tmp<volScalarField>::New
auto tepsilonCoeff = tmp<volScalarField>::New
(
IOobject
(
@ -177,16 +177,16 @@ void Foam::fv::multiphaseMangrovesTurbulenceModel::addSup
if (eqn.psi().name() == epsilonName_)
{
fvMatrix<scalar> epsilonEqn
(
fvMatrix<scalar> epsilonEqn
(
- fvm::Sp(epsilonCoeff(U), eqn.psi())
);
eqn += epsilonEqn;
}
else if (eqn.psi().name() == kName_)
{
fvMatrix<scalar> kEqn
(
fvMatrix<scalar> kEqn
(
- fvm::Sp(kCoeff(U), eqn.psi())
);
eqn += kEqn;
@ -258,7 +258,8 @@ bool Foam::fv::multiphaseMangrovesTurbulenceModel::read(const dictionary& dict)
const word& regionName = regionNames[i];
const dictionary& modelDict = regionsDict.subDict(regionName);
const word& zoneName = modelDict.lookup("cellZone");
const word zoneName(modelDict.get<word>("cellZone"));
zoneIDs_[i] = mesh_.cellZones().findIndices(zoneName);
if (zoneIDs_[i].empty())
{
@ -268,19 +269,17 @@ bool Foam::fv::multiphaseMangrovesTurbulenceModel::read(const dictionary& dict)
<< exit(FatalError);
}
modelDict.lookup("a") >> aZone_[i];
modelDict.lookup("N") >> NZone_[i];
modelDict.lookup("Ckp") >> CkpZone_[i];
modelDict.lookup("Cep") >> CepZone_[i];
modelDict.lookup("Cd") >> CdZone_[i];
modelDict.read("a", aZone_[i]);
modelDict.read("N", NZone_[i]);
modelDict.read("Ckp", CkpZone_[i]);
modelDict.read("Cep", CepZone_[i]);
modelDict.read("Cd", CdZone_[i]);
}
return true;
}
else
{
return false;
}
return false;
}

View File

@ -50,7 +50,6 @@ namespace Foam
namespace fv
{
/*---------------------------------------------------------------------------*\
Class multiphaseMangrovesTurbulenceModel Declaration
\*---------------------------------------------------------------------------*/
@ -61,14 +60,14 @@ class multiphaseMangrovesTurbulenceModel
{
// Private Member Functions
//- Disallow default bitwise copy construct
//- No copy construct
multiphaseMangrovesTurbulenceModel
(
const multiphaseMangrovesTurbulenceModel&
);
) = delete;
//- Disallow default bitwise assignment
void operator=(const multiphaseMangrovesTurbulenceModel&);
//- No copy assignment
void operator=(const multiphaseMangrovesTurbulenceModel&) = delete;
@ -137,8 +136,7 @@ public:
//- Destructor
virtual ~multiphaseMangrovesTurbulenceModel()
{}
virtual ~multiphaseMangrovesTurbulenceModel() = default;
// Member Functions

View File

@ -43,7 +43,7 @@ Foam::scalar Foam::waveModels::waveAbsorptionModel::timeCoeff
const scalar t
) const
{
// No time ramping applied applied for absorption
// No time ramping applied for absorption
return 1;
}
@ -67,12 +67,6 @@ Foam::waveModels::waveAbsorptionModel::waveAbsorptionModel
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::waveModels::waveAbsorptionModel::~waveAbsorptionModel()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool Foam::waveModels::waveAbsorptionModel::readDict

View File

@ -71,7 +71,7 @@ public:
);
//- Destructor
virtual ~waveAbsorptionModel();
virtual ~waveAbsorptionModel() = default;
// Public Member Functions

View File

@ -101,12 +101,6 @@ Foam::waveModels::shallowWaterAbsorption::shallowWaterAbsorption
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::waveModels::shallowWaterAbsorption::~shallowWaterAbsorption()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool Foam::waveModels::shallowWaterAbsorption::readDict

View File

@ -88,7 +88,7 @@ public:
);
//- Destructor
virtual ~shallowWaterAbsorption();
virtual ~shallowWaterAbsorption() = default;
// Public Member Functions

View File

@ -24,9 +24,6 @@ License
\*---------------------------------------------------------------------------*/
#include "irregularWaveModel.H"
#include "mathematicalConstants.H"
using namespace Foam::constant;
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
@ -70,12 +67,6 @@ Foam::waveModels::irregularWaveModel::irregularWaveModel
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::waveModels::irregularWaveModel::~irregularWaveModel()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool Foam::waveModels::irregularWaveModel::readDict
@ -85,7 +76,7 @@ bool Foam::waveModels::irregularWaveModel::readDict
{
if (waveGenerationModel::readDict(overrideDict))
{
lookup("rampTime") >> rampTime_;
rampTime_ = get<scalar>("rampTime");
return true;
}

View File

@ -48,13 +48,11 @@ class irregularWaveModel
:
public waveGenerationModel
{
// Private Member Functions
//- No copy construct
irregularWaveModel(const irregularWaveModel&) = delete;
//- Disallow default bitwise copy construct
irregularWaveModel(const irregularWaveModel&);
//- Disallow default bitwise assignment
void operator=(const irregularWaveModel&);
//- No copy assignment
void operator=(const irregularWaveModel&) = delete;
protected:
@ -86,7 +84,7 @@ public:
);
//- Destructor
virtual ~irregularWaveModel();
virtual ~irregularWaveModel() = default;
// Public Member Functions

View File

@ -24,7 +24,7 @@ License
\*---------------------------------------------------------------------------*/
#include "regularWaveModel.H"
#include "mathematicalConstants.H"
#include "unitConversion.H"
using namespace Foam::constant;
@ -83,12 +83,6 @@ Foam::waveModels::regularWaveModel::regularWaveModel
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::waveModels::regularWaveModel::~regularWaveModel()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool Foam::waveModels::regularWaveModel::readDict
@ -101,7 +95,7 @@ bool Foam::waveModels::regularWaveModel::readDict
waveHeight_ = readWaveHeight();
waveAngle_ = readWaveAngle();
lookup("wavePeriod") >> wavePeriod_;
wavePeriod_ = get<scalar>("wavePeriod");
if (wavePeriod_ < 0)
{
FatalIOErrorInFunction(*this)
@ -126,7 +120,7 @@ void Foam::waveModels::regularWaveModel::info(Ostream& os) const
irregularWaveModel::info(os);
os << " Wave height : " << waveHeight_ << nl
<< " Wave angle : " << 180/mathematical::pi*waveAngle_ << nl
<< " Wave angle : " << radToDeg(waveAngle_) << nl
<< " Wave period : " << wavePeriod_ << nl
<< " Wave length : " << waveLength_ << nl
<< " Wave phase : " << wavePhase_ << nl;

View File

@ -99,7 +99,7 @@ public:
);
//- Destructor
virtual ~regularWaveModel();
virtual ~regularWaveModel() = default;
// Public Member Functions

View File

@ -26,11 +26,7 @@ License
#include "solitaryWaveModel.H"
#include "polyPatch.H"
#include "SubField.H"
#include "mathematicalConstants.H"
using namespace Foam::constant;
#include "unitConversion.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
@ -82,12 +78,6 @@ Foam::waveModels::solitaryWaveModel::solitaryWaveModel
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::waveModels::solitaryWaveModel::~solitaryWaveModel()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool Foam::waveModels::solitaryWaveModel::readDict
@ -112,7 +102,7 @@ void Foam::waveModels::solitaryWaveModel::info(Ostream& os) const
waveGenerationModel::info(os);
os << " Wave height : " << waveHeight_ << nl
<< " Wave angle : " << 180/mathematical::pi*waveAngle_ << nl
<< " Wave angle : " << radToDeg(waveAngle_) << nl
<< " x0: " << x0_ << nl;
}

View File

@ -87,7 +87,7 @@ public:
);
//- Destructor
virtual ~solitaryWaveModel();
virtual ~solitaryWaveModel() = default;
// Public Member Functions

View File

@ -24,9 +24,7 @@ License
\*---------------------------------------------------------------------------*/
#include "waveGenerationModel.H"
#include "mathematicalConstants.H"
using namespace Foam::constant;
#include "unitConversion.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
@ -43,7 +41,7 @@ namespace waveModels
Foam::scalar Foam::waveModels::waveGenerationModel::readWaveHeight() const
{
scalar h(readScalar(lookup("waveHeight")));
const scalar h(get<scalar>("waveHeight"));
if (h < 0)
{
FatalIOErrorInFunction(*this)
@ -58,8 +56,7 @@ Foam::scalar Foam::waveModels::waveGenerationModel::readWaveHeight() const
Foam::scalar Foam::waveModels::waveGenerationModel::readWaveAngle() const
{
scalar angle(readScalar(lookup("waveAngle")));
return angle* mathematical::pi/180;
return degToRad(get<scalar>("waveAngle"));
}
@ -82,12 +79,6 @@ Foam::waveModels::waveGenerationModel::waveGenerationModel
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::waveModels::waveGenerationModel::~waveGenerationModel()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool Foam::waveModels::waveGenerationModel::readDict
@ -97,7 +88,7 @@ bool Foam::waveModels::waveGenerationModel::readDict
{
if (waveModel::readDict(overrideDict))
{
lookup("activeAbsorption") >> activeAbsorption_;
activeAbsorption_ = get<bool>("activeAbsorption");
return true;
}

View File

@ -74,7 +74,7 @@ public:
);
//- Destructor
virtual ~waveGenerationModel();
virtual ~waveGenerationModel() = default;
// Public Member Functions

View File

@ -225,12 +225,6 @@ Foam::waveModels::Boussinesq::Boussinesq
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::waveModels::Boussinesq::~Boussinesq()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool Foam::waveModels::Boussinesq::readDict(const dictionary& overrideDict)

View File

@ -127,7 +127,7 @@ public:
);
//- Destructor
virtual ~Boussinesq();
virtual ~Boussinesq() = default;
// Public Member Functions

View File

@ -192,12 +192,6 @@ Foam::waveModels::Grimshaw::Grimshaw
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::waveModels::Grimshaw::~Grimshaw()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool Foam::waveModels::Grimshaw::readDict(const dictionary& overrideDict)

View File

@ -117,7 +117,7 @@ public:
);
//- Destructor
virtual ~Grimshaw();
virtual ~Grimshaw() = default;
// Public Member Functions

View File

@ -282,12 +282,6 @@ Foam::waveModels::McCowan::McCowan
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::waveModels::McCowan::~McCowan()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool Foam::waveModels::McCowan::readDict(const dictionary& overrideDict)

View File

@ -133,7 +133,7 @@ public:
);
//- Destructor
virtual ~McCowan();
virtual ~McCowan() = default;
// Public Member Functions

View File

@ -209,12 +209,6 @@ Foam::waveModels::StokesI::StokesI
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::waveModels::StokesI::~StokesI()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool Foam::waveModels::StokesI::readDict(const dictionary& overrideDict)

View File

@ -121,7 +121,7 @@ public:
);
//- Destructor
virtual ~StokesI();
virtual ~StokesI() = default;
// Public Member Functions

View File

@ -155,12 +155,6 @@ Foam::waveModels::StokesII::StokesII
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::waveModels::StokesII::~StokesII()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool Foam::waveModels::StokesII::readDict(const dictionary& overrideDict)

View File

@ -111,7 +111,7 @@ public:
);
//- Destructor
virtual ~StokesII();
virtual ~StokesII() = default;
// Public Member Functions

View File

@ -846,12 +846,6 @@ Foam::waveModels::StokesV::StokesV
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::waveModels::StokesV::~StokesV()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool Foam::waveModels::StokesV::readDict(const dictionary& overrideDict)

View File

@ -195,7 +195,7 @@ public:
);
//- Destructor
virtual ~StokesV();
virtual ~StokesV() = default;
// Public Member Functions

View File

@ -329,12 +329,6 @@ Foam::waveModels::cnoidal::cnoidal
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::waveModels::cnoidal::~cnoidal()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool Foam::waveModels::cnoidal::readDict(const dictionary& overrideDict)

View File

@ -160,7 +160,7 @@ public:
);
//- Destructor
virtual ~cnoidal();
virtual ~cnoidal() = default;
// Public Member Functions

View File

@ -24,7 +24,7 @@ License
\*---------------------------------------------------------------------------*/
#include "irregularMultiDirectionalWaveModel.H"
#include "mathematicalConstants.H"
#include "unitConversion.H"
#include "addToRunTimeSelectionTable.H"
using namespace Foam::constant;
@ -253,12 +253,6 @@ Foam::waveModels::irregularMultiDirectional::irregularMultiDirectional
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::waveModels::irregularMultiDirectional::~irregularMultiDirectional()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool Foam::waveModels::irregularMultiDirectional::readDict
@ -268,10 +262,10 @@ bool Foam::waveModels::irregularMultiDirectional::readDict
{
if (irregularWaveModel::readDict(overrideDict))
{
lookup("wavePeriods") >> irregWavePeriods_;
lookup("waveHeights") >> irregWaveHeights_;
lookup("wavePhases") >> irregWavePhases_;
lookup("waveDirs") >> irregWaveDirs_;
dictionary::read("wavePeriods", irregWavePeriods_);
dictionary::read("waveHeights", irregWaveHeights_);
dictionary::read("wavePhases", irregWavePhases_);
dictionary::read("waveDirs", irregWaveDirs_);
irregWaveLengths_ = irregWaveHeights_;
@ -282,7 +276,7 @@ bool Foam::waveModels::irregularMultiDirectional::readDict
irregWaveLengths_[ii][jj] =
waveLength(waterDepthRef_, irregWavePeriods_[ii][jj]);
irregWaveDirs_[ii][jj] =
irregWaveDirs_[ii][jj]*mathematical::pi/180;
degToRad(irregWaveDirs_[ii][jj]);
}
}

View File

@ -33,6 +33,7 @@ Description
#define waveModels_irregularMultiDirectional_H
#include "irregularWaveModel.H"
#include "scalarList.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -54,20 +55,20 @@ private:
// Proteced Data
//- Wave periods for irregularMultiDirectional case [seconds]
List<List<scalar>> irregWavePeriods_;
List<scalarList> irregWavePeriods_;
//- Wave heights for irregularMultiDirectional case [metres]
List<List<scalar>> irregWaveHeights_;
List<scalarList> irregWaveHeights_;
//- Wave lengths for irregularMultiDirectional case [metres]
List<List<scalar>> irregWaveLengths_;
List<scalarList> irregWaveLengths_;
//- Wave phases for irregularMultiDirectional case [radians]
List<List<scalar>> irregWavePhases_;
List<scalarList> irregWavePhases_;
//- Direction of propagation for irregularMultiDirectional case
//- [degrees] from X axis
List<List<scalar>> irregWaveDirs_;
List<scalarList> irregWaveDirs_;
// Private Member Functions
@ -151,7 +152,7 @@ public:
);
//- Destructor
virtual ~irregularMultiDirectional();
virtual ~irregularMultiDirectional() = default;
// Public Member Functions

View File

@ -67,8 +67,7 @@ Foam::scalar Foam::waveModels::streamFunction::eta
forAll(Ejs_, iterSF)
{
strfnAux +=
Ejs_[iterSF]*cos((iterSF + 1)
*(kx*x + ky*y - omega*t + phase));
Ejs_[iterSF]*cos((iterSF + 1) *(kx*x + ky*y - omega*t + phase));
}
return (1/k)*strfnAux;
@ -135,12 +134,12 @@ void Foam::waveModels::streamFunction::setLevel
this->eta
(
waterDepthRef_,
waveKx,
waveKx,
waveKy,
wavePeriod_,
xPaddle_[paddlei],
yPaddle_[paddlei],
waveOmega,
waveOmega,
t,
wavePhase_
);
@ -184,7 +183,7 @@ void Foam::waveModels::streamFunction::setVelocity
wavePeriod_,
xPaddle_[paddlei],
yPaddle_[paddlei],
waveOmega,
waveOmega,
t,
wavePhase_,
z
@ -218,22 +217,16 @@ Foam::waveModels::streamFunction::streamFunction
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::waveModels::streamFunction::~streamFunction()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool Foam::waveModels::streamFunction::readDict(const dictionary& overrideDict)
{
if (regularWaveModel::readDict(overrideDict))
{
overrideDict.lookup("uMean") >> uMean_;
overrideDict.lookup("waveLength") >> waveLength_;
overrideDict.lookup("Bjs") >> Bjs_;
overrideDict.lookup("Ejs") >> Ejs_;
overrideDict.read("uMean", uMean_);
overrideDict.read("waveLength", waveLength_);
overrideDict.read("Bjs", Bjs_);
overrideDict.read("Ejs", Ejs_);
return true;
}

View File

@ -132,7 +132,7 @@ public:
);
//- Destructor
virtual ~streamFunction();
virtual ~streamFunction() = default;
// Public Member Functions

View File

@ -126,8 +126,8 @@ void Foam::waveModel::initialiseGeometry()
Foam::tmp<Foam::scalarField> Foam::waveModel::waterLevel() const
{
// Note: initialising as initial depth
tmp<scalarField> tlevel(new scalarField(nPaddle_, initialDepth_));
scalarField& level = tlevel.ref();
auto tlevel = tmp<scalarField>::New(nPaddle_, initialDepth_);
auto& level = tlevel.ref();
const volScalarField& alpha =
mesh_.lookupObject<volScalarField>(alphaName_);
@ -288,12 +288,6 @@ Foam::waveModel::waveModel
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::waveModel::~waveModel()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool Foam::waveModel::readDict(const dictionary& overrideDict)
@ -309,7 +303,7 @@ bool Foam::waveModel::readDict(const dictionary& overrideDict)
readIfPresent("U", UName_);
readIfPresent("alpha", alphaName_);
lookup("nPaddle") >> nPaddle_;
nPaddle_ = get<label>("nPaddle");
if (nPaddle_ < 1)
{
FatalIOErrorInFunction(*this)

View File

@ -222,7 +222,7 @@ public:
//- Destructor
virtual ~waveModel();
virtual ~waveModel() = default;
//- Dictionary name
static const word dictName;

View File

@ -51,7 +51,7 @@ Foam::autoPtr<Foam::waveModel> Foam::waveModel::New
if (waveDict.found(patch.name()))
{
patchDict = waveDict.subDict(patch.name());
patchDict.lookup("waveModel") >> modelType;
patchDict.read("waveModel", modelType);
}
else
{