diff --git a/src/randomProcesses/windowModels/Hanning/Hanning.C b/src/randomProcesses/windowModels/Hanning/Hanning.C index 19a48258ac4ffa8962aaaf8d8d89d83fd26101b1..8bafcf9bc574b986e8765824eedcaa60f726e6ba 100644 --- a/src/randomProcesses/windowModels/Hanning/Hanning.C +++ b/src/randomProcesses/windowModels/Hanning/Hanning.C @@ -47,7 +47,7 @@ Hanning::Hanning(const dictionary& dict, const label nSamples) windowModel(dict, nSamples), symmetric_(readBool(dict.lookup("symmetric"))), extended_(readBool(dict.lookup("extended"))), - alpha_(dict.lookupOrDefault("alpha", 0.5)) + alpha_(dict.lookupOrDefault("alpha", 0.5)) // Hamming = 0.54 { // Extend range if required label offset = extended_ ? 1 : 0; @@ -60,7 +60,7 @@ Hanning::Hanning(const dictionary& dict, const label nSamples) } scalarField& wf = *this; - wf = (1 - alpha_)*cos(constant::mathematical::twoPi*t/m); + wf = alpha_ - (1 - alpha_)*cos(constant::mathematical::twoPi*t/m); // Reset second half of window if symmetric if (symmetric_) @@ -83,7 +83,7 @@ Hanning::Hanning(const dictionary& dict, const label nSamples) scalar sumSqr = sum(sqr(wf)); - // Normalisation (if required) + // Normalisation wf *= sqrt(nSamples/sumSqr); } diff --git a/src/randomProcesses/windowModels/Hanning/Hanning.H b/src/randomProcesses/windowModels/Hanning/Hanning.H index 8a0ca618ed62ab74c9c66ddb0532a581fadfc60c..5522e6a04d9121827948d9870ff6a54b67755a74 100644 --- a/src/randomProcesses/windowModels/Hanning/Hanning.H +++ b/src/randomProcesses/windowModels/Hanning/Hanning.H @@ -29,7 +29,7 @@ Description The window is described by the function \f[ - wf = (1 - \alpha) cos(2 \pi t/m); + wf = (1 - \alpha) - \alpha cos(2 \pi t/m); \f] Where: diff --git a/src/randomProcesses/windowModels/uniform/uniform.C b/src/randomProcesses/windowModels/uniform/uniform.C new file mode 100644 index 0000000000000000000000000000000000000000..6bc75b31a8f93e79cabe4e4fac62ea8c7219e904 --- /dev/null +++ b/src/randomProcesses/windowModels/uniform/uniform.C @@ -0,0 +1,66 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2016 OpenCFD Ltd. + \\/ 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 "uniform.H" +#include "addToRunTimeSelectionTable.H" +#include "mathematicalConstants.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace windowModels +{ + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +defineTypeNameAndDebug(uniform, 0); +addToRunTimeSelectionTable(windowModel, uniform, dictionary); + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +uniform::uniform(const dictionary& dict, const label nSamples) +: + windowModel(dict, nSamples), + value_(readScalar(dict.lookup("value"))) +{ + scalarField& wf = *this; + wf = value_; +} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +uniform::~uniform() +{} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace windowModels +} // End namespace Foam + +// ************************************************************************* // diff --git a/src/randomProcesses/windowModels/uniform/uniform.H b/src/randomProcesses/windowModels/uniform/uniform.H new file mode 100644 index 0000000000000000000000000000000000000000..c422df79d35b2f944c324ed918eaeb26370a68d1 --- /dev/null +++ b/src/randomProcesses/windowModels/uniform/uniform.H @@ -0,0 +1,89 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2016 OpenCFD Ltd. + \\/ 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/>. + +Class + Foam::windowModels::uniform + +Description + A window that applies uniform scaling. + +SourceFiles + uniform.C + +\*---------------------------------------------------------------------------*/ + +#ifndef uniform_H +#define uniform_H + +#include "autoPtr.H" +#include "runTimeSelectionTables.H" +#include "windowModel.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace windowModels +{ + +/*---------------------------------------------------------------------------*\ + Class uniform Declaration +\*---------------------------------------------------------------------------*/ + +class uniform +: + public windowModel +{ + +protected: + + // Protected data + + //- Uniform value + scalar value_; + + +public: + + //- Runtime type information + TypeName("uniform"); + + + //- Construct from dictionary + uniform(const dictionary& dict, const label nSamples); + + //- Destuctor + virtual ~uniform(); +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace windowModels +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/randomProcesses/windowModels/windowModel/windowModel.C b/src/randomProcesses/windowModels/windowModel/windowModel.C index 9b0e0658ff2c9a116828727c78d348e86e4ccf20..dcaae9afd99318359f57808141545e1592be90b1 100644 --- a/src/randomProcesses/windowModels/windowModel/windowModel.C +++ b/src/randomProcesses/windowModels/windowModel/windowModel.C @@ -1,3 +1,28 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2015-2016 OpenCFD Ltd. + \\/ 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 "windowModel.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // diff --git a/src/randomProcesses/windowModels/windowModel/windowModelTemplates.C b/src/randomProcesses/windowModels/windowModel/windowModelTemplates.C index 1343b55bb9a5b2200ed61d4d7b41043e72d3ffad..76f1241a8314f43a05dad315b303039bfd8765be 100644 --- a/src/randomProcesses/windowModels/windowModel/windowModelTemplates.C +++ b/src/randomProcesses/windowModels/windowModel/windowModelTemplates.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2015 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2015-2016 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -34,15 +34,7 @@ Foam::tmp<Foam::Field<Type> > Foam::windowModel::apply if (nSamples > fld.size()) { - FatalErrorIn - ( - "template<class Type> " - "Foam::tmp<Foam::Field<Type> > Foam::windowModel::apply" - "(" - "const Field<Type>&, " - "const label" - ") const" - ) + FatalErrorInFunction << "Number of samples in sampling window is greater than the " << "size of the input field" << nl << " input field size = " << fld.size() << nl @@ -53,20 +45,12 @@ Foam::tmp<Foam::Field<Type> > Foam::windowModel::apply tmp<Field<Type> > tresult(new Field<Type>(nSamples, pTraits<Type>::zero)); - Field<Type>& result = tresult(); + Field<Type>& result = tresult.ref(); label nWindow = nWindowsTotal(fld.size()); if (windowI >= nWindow) { - FatalErrorIn - ( - "template<class Type> " - "Foam::tmp<Foam::Field<Type> > Foam::windowModel::apply" - "(" - "const Field<Type>&, " - "const label" - ") const" - ) + FatalErrorInFunction << "Requested window " << windowI << " outside of range. " << "Number of available windows is " << nWindow << abort(FatalError);