Loading...
Searching...
No Matches
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-------------------------------------------------------------------------------
10License
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
26Class
27 Foam::windowModel
28
29Description
30 Base class for windowing models
31
32SourceFiles
33 windowModel.C
34
35\*---------------------------------------------------------------------------*/
36
37#ifndef windowModel_H
38#define windowModel_H
39
40#include "autoPtr.H"
42#include "scalarField.H"
43
44// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
45
46namespace Foam
47{
49/*---------------------------------------------------------------------------*\
50 Class windowModel Declaration
51\*---------------------------------------------------------------------------*/
52
53class windowModel
54:
55 public scalarField
56{
57
58protected:
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_;
71
72public:
73
74 //- Runtime type information
75 TypeName("windowModel");
76
77 // Declare runtime constructor selection table
79 (
80 autoPtr,
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// ************************************************************************* //
label n
Info<< nl;Info<< "Write faMesh in vtk format:"<< nl;{ vtk::uindirectPatchWriter writer(aMesh.patch(), fileName(aMesh.time().globalPath()/vtkBaseFileName));writer.writeGeometry();globalIndex procAddr(aMesh.nFaces());labelList cellIDs;if(UPstream::master()) { cellIDs.resize(procAddr.totalSize());for(const labelRange &range :procAddr.ranges()) { auto slice=cellIDs.slice(range);slice=identity(range);} } writer.beginCellData(4);writer.writeProcIDs();writer.write("cellID", cellIDs);writer.write("area", aMesh.S().field());writer.write("normal", aMesh.faceAreaNormals());writer.beginPointData(1);writer.write("normal", aMesh.pointAreaNormals());Info<< " "<< writer.output().name()<< nl;}{ vtk::lineWriter writer(aMesh.points(), aMesh.edges(), fileName(aMesh.time().globalPath()/(vtkBaseFileName+"-edges")));writer.writeGeometry();writer.beginCellData(4);writer.writeProcIDs();{ Field< scalar > fld(faMeshTools::flattenEdgeField(aMesh.magLe(), true))
constexpr Field() noexcept
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition autoPtr.H:65
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition dictionary.H:133
A class for managing temporary objects.
Definition tmp.H:75
scalar overlapPercent() const
Return the overlap percent.
Definition windowModel.C:51
label nWindow() const
Return the number of windows.
Definition windowModel.C:63
TypeName("windowModel")
Runtime type information.
tmp< Field< Type > > apply(const Field< Type > &fld, const label windowI) const
Return the windowed data.
virtual ~windowModel()=default
Destructor.
label nWindowsTotal(label nSamplesTotal) const
Return the total number of windows for a given number of samples.
Definition windowModel.C:69
static autoPtr< windowModel > New(const dictionary &dict, const label nSamples)
Return a reference to the selected window model.
label nSamples() const
Return the number of samples in the window.
Definition windowModel.C:45
declareRunTimeSelectionTable(autoPtr, windowModel, dictionary,(const dictionary &dict, const label nSamples),(dict, nSamples))
label nWindow_
Number of windows.
Definition windowModel.H:70
windowModel(const dictionary &dict, const label nSamples)
Construct from dictionary.
Definition windowModel.C:34
label validate(label n)
Validate that the window is applicable to the data set size, and.
Definition windowModel.C:77
label nOverlapSamples_
Number of overlap samples per window.
Definition windowModel.H:65
scalar overlapPercent_
Overlap percent.
Definition windowModel.H:60
label nOverlapSamples() const
Return number of overlap samples per window.
Definition windowModel.C:57
Namespace for OpenFOAM.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
Macros to ease declaration of run-time selection tables.
#define declareRunTimeSelectionTable(ptrWrapper, baseType, argNames, argList, parList)
Declare a run-time selection (variables and adder classes).
dictionary dict
#define TypeName(TypeNameString)
Declare a ClassName() with extra virtual type info.
Definition typeInfo.H:68