windowModel.H
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) 2016-2022 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 Class
27  Foam::windowModel
28 
29 Description
30  Base class for windowing models
31 
32 SourceFiles
33  windowModel.C
34 
35 \*---------------------------------------------------------------------------*/
36 
37 #ifndef windowModel_H
38 #define windowModel_H
39 
40 #include "autoPtr.H"
41 #include "runTimeSelectionTables.H"
42 #include "scalarField.H"
43 
44 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
45 
46 namespace Foam
47 {
48 
49 /*---------------------------------------------------------------------------*\
50  Class windowModel Declaration
51 \*---------------------------------------------------------------------------*/
52 
53 class windowModel
54 :
55  public scalarField
56 {
57 
58 protected:
59 
60  // Protected Data
61 
62  //- Overlap percent
63  scalar overlapPercent_;
64 
65  //- Number of overlap samples per window
66  label nOverlapSamples_;
67 
68  //- Number of windows
69  label nWindow_;
70 
71 
72 public:
73 
74  //- Runtime type information
75  TypeName("windowModel");
76 
77  // Declare runtime constructor selection table
79  (
80  autoPtr,
82  dictionary,
83  (
84  const dictionary& dict,
85  const label nSamples
86  ),
87  (dict, nSamples)
88  );
89 
90 
91  //- Construct from dictionary
92  windowModel(const dictionary& dict, const label nSamples);
93 
94 
95  // Selectors
96 
97  //- Return a reference to the selected window model
99  (
100  const dictionary& dict,
101  const label nSamples
102  );
103 
104 
105  //- Destructor
106  virtual ~windowModel() = default;
107 
108 
109  // Public Member Functions
110 
111  //- Return the number of samples in the window
112  label nSamples() const;
113 
114  //- Return the overlap percent
115  scalar overlapPercent() const;
116 
117  //- Return number of overlap samples per window
118  label nOverlapSamples() const;
119 
120  //- Return the number of windows
121  label nWindow() const;
122 
123  //- Return the total number of windows for a given number of samples
124  label nWindowsTotal(label nSamplesTotal) const;
125 
126  //- Validate that the window is applicable to the data set size, and
127  // return the number of required data points
128  label validate(label n);
129 
130  //- Return the windowed data
131  template<class Type>
133  (
134  const Field<Type>& fld,
135  const label windowI
136  ) const;
137 };
138 
139 
140 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
141 
142 } // End namespace Foam
143 
144 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
145 
146 #ifdef NoRepository
147  #include "windowModelTemplates.C"
148 #endif
149 
150 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
151 
152 #endif
153 
154 // ************************************************************************* //
dictionary dict
label validate(label n)
Validate that the window is applicable to the data set size, and.
Definition: windowModel.C:77
scalar overlapPercent_
Overlap percent.
Definition: windowModel.H:60
label nWindowsTotal(label nSamplesTotal) const
Return the total number of windows for a given number of samples.
Definition: windowModel.C:69
virtual ~windowModel()=default
Destructor.
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:129
label nOverlapSamples_
Number of overlap samples per window.
Definition: windowModel.H:65
label nWindow() const
Return the number of windows.
Definition: windowModel.C:63
TypeName("windowModel")
Runtime type information.
windowModel(const dictionary &dict, const label nSamples)
Construct from dictionary.
Definition: windowModel.C:34
Base class for windowing models.
Definition: windowModel.H:48
label nSamples() const
Return the number of samples in the window.
Definition: windowModel.C:45
scalar overlapPercent() const
Return the overlap percent.
Definition: windowModel.C:51
label nOverlapSamples() const
Return number of overlap samples per window.
Definition: windowModel.C:57
gmvFile<< "tracers "<< particles.size()<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().x()<< ' ';}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().y()<< ' ';}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().z()<< ' ';}gmvFile<< nl;for(const word &name :lagrangianScalarNames){ IOField< scalar > fld(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
tmp< Field< Type > > apply(const Field< Type > &fld, const label windowI) const
Return the windowed data.
static autoPtr< windowModel > New(const dictionary &dict, const label nSamples)
Return a reference to the selected window model.
label nWindow_
Number of windows.
Definition: windowModel.H:70
label n
Pointer management similar to std::unique_ptr, with some additional methods and type checking...
Definition: HashPtrTable.H:48
Macros to ease declaration of run-time selection tables.
A class for managing temporary objects.
Definition: HashPtrTable.H:50
Namespace for OpenFOAM.
declareRunTimeSelectionTable(autoPtr, windowModel, dictionary,(const dictionary &dict, const label nSamples),(dict, nSamples))