mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: window models - updated and added uniform window
This commit is contained in:
@ -47,7 +47,7 @@ Hanning::Hanning(const dictionary& dict, const label nSamples)
|
|||||||
windowModel(dict, nSamples),
|
windowModel(dict, nSamples),
|
||||||
symmetric_(readBool(dict.lookup("symmetric"))),
|
symmetric_(readBool(dict.lookup("symmetric"))),
|
||||||
extended_(readBool(dict.lookup("extended"))),
|
extended_(readBool(dict.lookup("extended"))),
|
||||||
alpha_(dict.lookupOrDefault("alpha", 0.5))
|
alpha_(dict.lookupOrDefault("alpha", 0.5)) // Hamming = 0.54
|
||||||
{
|
{
|
||||||
// Extend range if required
|
// Extend range if required
|
||||||
label offset = extended_ ? 1 : 0;
|
label offset = extended_ ? 1 : 0;
|
||||||
@ -60,7 +60,7 @@ Hanning::Hanning(const dictionary& dict, const label nSamples)
|
|||||||
}
|
}
|
||||||
|
|
||||||
scalarField& wf = *this;
|
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
|
// Reset second half of window if symmetric
|
||||||
if (symmetric_)
|
if (symmetric_)
|
||||||
@ -83,7 +83,7 @@ Hanning::Hanning(const dictionary& dict, const label nSamples)
|
|||||||
|
|
||||||
scalar sumSqr = sum(sqr(wf));
|
scalar sumSqr = sum(sqr(wf));
|
||||||
|
|
||||||
// Normalisation (if required)
|
// Normalisation
|
||||||
wf *= sqrt(nSamples/sumSqr);
|
wf *= sqrt(nSamples/sumSqr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -29,7 +29,7 @@ Description
|
|||||||
|
|
||||||
The window is described by the function
|
The window is described by the function
|
||||||
\f[
|
\f[
|
||||||
wf = (1 - \alpha) cos(2 \pi t/m);
|
wf = (1 - \alpha) - \alpha cos(2 \pi t/m);
|
||||||
\f]
|
\f]
|
||||||
|
|
||||||
Where:
|
Where:
|
||||||
|
|||||||
66
src/randomProcesses/windowModels/uniform/uniform.C
Normal file
66
src/randomProcesses/windowModels/uniform/uniform.C
Normal file
@ -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
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
89
src/randomProcesses/windowModels/uniform/uniform.H
Normal file
89
src/randomProcesses/windowModels/uniform/uniform.H
Normal file
@ -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
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -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"
|
#include "windowModel.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||||
|
|||||||
@ -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) 2015 OpenCFD Ltd.
|
\\ / A nd | Copyright (C) 2015-2016 OpenCFD Ltd.
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -34,15 +34,7 @@ Foam::tmp<Foam::Field<Type> > Foam::windowModel::apply
|
|||||||
|
|
||||||
if (nSamples > fld.size())
|
if (nSamples > fld.size())
|
||||||
{
|
{
|
||||||
FatalErrorIn
|
FatalErrorInFunction
|
||||||
(
|
|
||||||
"template<class Type> "
|
|
||||||
"Foam::tmp<Foam::Field<Type> > Foam::windowModel::apply"
|
|
||||||
"("
|
|
||||||
"const Field<Type>&, "
|
|
||||||
"const label"
|
|
||||||
") const"
|
|
||||||
)
|
|
||||||
<< "Number of samples in sampling window is greater than the "
|
<< "Number of samples in sampling window is greater than the "
|
||||||
<< "size of the input field" << nl
|
<< "size of the input field" << nl
|
||||||
<< " input field size = " << fld.size() << 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));
|
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());
|
label nWindow = nWindowsTotal(fld.size());
|
||||||
if (windowI >= nWindow)
|
if (windowI >= nWindow)
|
||||||
{
|
{
|
||||||
FatalErrorIn
|
FatalErrorInFunction
|
||||||
(
|
|
||||||
"template<class Type> "
|
|
||||||
"Foam::tmp<Foam::Field<Type> > Foam::windowModel::apply"
|
|
||||||
"("
|
|
||||||
"const Field<Type>&, "
|
|
||||||
"const label"
|
|
||||||
") const"
|
|
||||||
)
|
|
||||||
<< "Requested window " << windowI << " outside of range. "
|
<< "Requested window " << windowI << " outside of range. "
|
||||||
<< "Number of available windows is " << nWindow
|
<< "Number of available windows is " << nWindow
|
||||||
<< abort(FatalError);
|
<< abort(FatalError);
|
||||||
|
|||||||
Reference in New Issue
Block a user