Commit a415752e authored by Andrew Heather's avatar Andrew Heather
Browse files

ENH: window models - updated and added uniform window

parent 0efe8b8f
......@@ -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);
}
......
......@@ -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:
......
/*---------------------------------------------------------------------------*\
========= |
\\ / 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
// ************************************************************************* //
/*---------------------------------------------------------------------------*\
========= |
\\ / 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
// ************************************************************************* //
/*---------------------------------------------------------------------------*\
========= |
\\ / 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 * * * * * * * * * * * * * //
......
......@@ -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);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment