OpenFOAM: API Guide
v2006
The open source CFD toolbox
windowModel.C
Go to the documentation of this file.
1
/*---------------------------------------------------------------------------*\
2
========= |
3
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4
\\ / O peration |
5
\\ / A nd | www.openfoam.com
6
\\/ M anipulation |
7
-------------------------------------------------------------------------------
8
Copyright (C) 2015-2020 OpenCFD Ltd.
9
-------------------------------------------------------------------------------
10
License
11
This file is part of OpenFOAM.
12
13
OpenFOAM is free software: you can redistribute it and/or modify it
14
under the terms of the GNU General Public License as published by
15
the Free Software Foundation, either version 3 of the License, or
16
(at your option) any later version.
17
18
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21
for more details.
22
23
You should have received a copy of the GNU General Public License
24
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25
26
\*---------------------------------------------------------------------------*/
27
28
#include "
windowModel.H
"
29
30
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
31
32
namespace
Foam
33
{
34
defineTypeNameAndDebug
(windowModel, 0);
35
defineRunTimeSelectionTable
(windowModel, dictionary);
36
}
37
38
39
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
40
41
Foam::windowModel::windowModel
(
const
dictionary
&
dict
,
const
label
nSamples
)
42
:
43
scalarField
(
nSamples
),
44
nOverlapSamples_(0),
45
nWindow_(
dict
.getOrDefault(
"nWindow"
, -1))
46
{
47
nOverlapSamples_
= floor
48
(
49
dict
.get<scalar>(
"overlapPercent"
)/scalar(100)*
nSamples
50
);
51
}
52
53
54
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
55
56
Foam::label
Foam::windowModel::nSamples
()
const
57
{
58
return
size();
59
}
60
61
62
Foam::label
Foam::windowModel::nWindow
()
const
63
{
64
return
nWindow_;
65
}
66
67
68
Foam::label
Foam::windowModel::nWindowsTotal
(label nSamplesTotal)
const
69
{
70
const
label
nSamples
= this->
nSamples
();
71
72
return
floor((nSamplesTotal -
nSamples
)/(
nSamples
- nOverlapSamples_)) + 1;
73
}
74
75
76
Foam::label
Foam::windowModel::validate
(
const
label nSamplesTotal)
77
{
78
label
nSamples
= this->
nSamples
();
79
80
if
(nSamplesTotal <
nSamples
)
81
{
82
FatalErrorInFunction
83
<<
"Block size N = "
<<
nSamples
84
<<
" is larger than total number of data points = "
<< nSamplesTotal
85
<<
exit
(
FatalError
);
86
}
87
88
const
label nWindowAvailable = nWindowsTotal(nSamplesTotal);
89
90
if
(nWindow_ == -1)
91
{
92
nWindow_ = nWindowAvailable;
93
}
94
95
if
(nWindow_ > nWindowAvailable)
96
{
97
FatalErrorInFunction
98
<<
"Number of data points calculated with "
<< nWindow_
99
<<
" windows greater than the total number of data points"
100
<<
nl
101
<<
" Block size, N = "
<<
nSamples
<<
nl
102
<<
" Total number of data points = "
<< nSamplesTotal <<
nl
103
<<
" Maximum number of windows = "
<< nWindowAvailable <<
nl
104
<<
" Requested number of windows = "
<< nWindow_
105
<<
exit
(
FatalError
);
106
}
107
108
const
label nRequiredSamples =
109
nWindow_*
nSamples
- (nWindow_ - 1)*nOverlapSamples_;
110
111
Info
<<
"Windowing:"
<<
nl
112
<<
" Total samples : "
<< nSamplesTotal <<
nl
113
<<
" Samples per window : "
<<
nSamples
<<
nl
114
<<
" Number of windows : "
<< nWindow_ <<
nl
115
<<
" Overlap size : "
<< nOverlapSamples_ <<
nl
116
<<
" Required number of samples : "
<< nRequiredSamples
117
<<
endl
;
118
119
return
nRequiredSamples;
120
}
121
122
123
// ************************************************************************* //
Foam::windowModel::windowModel
windowModel(const dictionary &dict, const label nSamples)
Construct from dictionary.
Definition:
windowModel.C:41
Foam::defineRunTimeSelectionTable
defineRunTimeSelectionTable(reactionRateFlameArea, dictionary)
windowModel.H
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition:
Ostream.H:350
Foam::Field< scalar >
Foam::Info
messageStream Info
Information stream (uses stdout - output is on the master only)
Foam::windowModel::nWindowsTotal
label nWindowsTotal(label nSamplesTotal) const
Return the total number of windows for a given number of samples.
Definition:
windowModel.C:68
dict
dictionary dict
Definition:
searchingEngine.H:14
Foam::FatalError
error FatalError
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition:
dictionary.H:121
Foam
Namespace for OpenFOAM.
Definition:
atmBoundaryLayer.C:33
Foam::exit
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition:
errorManip.H:130
Foam::windowModel::nOverlapSamples_
label nOverlapSamples_
Number of overlap samples per window.
Definition:
windowModel.H:62
nSamples
const label nSamples(pdfDictionary.get< label >("nSamples"))
FatalErrorInFunction
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition:
error.H:372
Foam::nl
constexpr char nl
Definition:
Ostream.H:385
Foam::windowModel::nWindow
label nWindow() const
Return the number of windows.
Definition:
windowModel.C:62
Foam::windowModel::nSamples
label nSamples() const
Return the number of samples in the window.
Definition:
windowModel.C:56
Foam::windowModel::validate
label validate(label n)
Validate that the window is applicable to the data set size, and.
Definition:
windowModel.C:76
Foam::defineTypeNameAndDebug
defineTypeNameAndDebug(combustionModel, 0)
src
randomProcesses
windowModels
windowModel
windowModel.C
Generated by
1.8.17
OPENFOAM® is a registered
trademark
of OpenCFD Ltd.