uniformBin.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) 2021-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::binModels::uniformBin
28
29Description
30 Calculates binned data in multiple segments according to
31 a specified Cartesian or cylindrical coordinate system.
32
33Usage
34 Minimal example by using \c system/controlDict.functions:
35 \verbatim
36 binField1
37 {
38 // Other binField entries
39 ...
40
41 // Mandatory entries
42 binModel uniformBin;
43
44 binData
45 {
46 // Mandatory entries
47 nBin <Vector<label>>;
48
49 // Optional entries
50 cumulative <bool>;
51 minMax
52 {
53 e1 (<scalar> <scalar>); // (min max);
54 e2 (<scalar> <scalar>);
55 e3 (<scalar> <scalar>);
56 }
57 }
58 }
59 \endverbatim
60
61 where the entries mean:
62 \table
63 Property | Description | Type | Reqd | Deflt
64 binModel | Type name: uniformBin | word | yes | -
65 binData | Entries of the chosen bin model | dict | yes | -
66 nBin | Numbers of bins in specified directions | Vector<label> <!--
67 --> | yes | -
68 cumulative | Flag to bin data accumulated with increasing distance <!--
69 --> in binning direction | bool | no | false
70 minMax | Min-max bounds in binning directions with respect to <!--
71 --> the coordinateSystem's origin | dict | no | -
72 \endtable
73
74Note
75 - The order of bin numbering is (e1, e2, e3), where the first
76 varies the fastest. For example, for a cylindrical bin with
77 \f$ nBin = (radial, azimuth, height) = (2, 4, 2) \f$, the bin indices
78 may look like as follows - note the counterclockwise increments:
79 \verbatim
80 |-------------------|
81 | 12 | | 14 |
82 | 11 | 13 |
83 | 9 | 15 |
84 | 10 | | 16 |
85 |-------------------|
86 / / / /
87 / / / /
88 |-------------------|
89 | 4 | | 6 |
90 | 3 | 5 |
91 | 1 | 7 |
92 | 2 | | 8 |
93 |-------------------|
94 \endverbatim
95
96SourceFiles
97 uniformBin.C
98 uniformBinTemplates.C
99
100\*---------------------------------------------------------------------------*/
101
102#ifndef Foam_binModels_uniformBin_H
103#define Foam_binModels_uniformBin_H
104
105#include "binModel.H"
106#include "writeFile.H"
107#include "coordinateSystem.H"
108
109// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
110
111namespace Foam
112{
113namespace binModels
114{
115
116/*---------------------------------------------------------------------------*\
117 Class uniformBin Declaration
118\*---------------------------------------------------------------------------*/
119
120class uniformBin
121:
122 public binModel
123{
124protected:
125
126 // Protected Data
127
128 //- Numbers of bins in binning directions
129 Vector<label> nBins_;
130
131 //- Equidistant bin widths in binning directions
133
134 //- Min-max bounds of bins in binning directions
135 Vector<vector2D> binMinMax_;
136
137 //- Face index to bin index addressing
139
140 //- Cell index to bin index addressing
142
143
144 // Protected Member Functions
145
146 //- Write header for an binned-data file
147 template<class Type>
148 void writeFileHeader(OFstream& os) const;
149
150 //- Initialise bin properties
151 virtual void initialise();
152
153 //- Return list of bin indices corresponding to positions given by d
154 virtual labelList binAddr(const vectorField& d) const;
155
156 //- Set/cache the bin addressing
157 virtual void setBinsAddressing();
158
159 //- Apply the binning to field fieldi
160 template<class Type>
161 bool processField(const label fieldi);
162
163
164public:
165
166 //- Runtime type information
167 TypeName("uniformBin");
168
169
170 // Constructors
171
172 //- Construct from components
174 (
175 const dictionary& dict,
176 const fvMesh& mesh,
177 const word& outputPrefix
178 );
180 //- No copy construct
181 uniformBin(const uniformBin&) = delete;
183 //- No copy assignment
184 void operator=(const uniformBin&) = delete;
185
186
187 //- Destructor
188 virtual ~uniformBin() = default;
189
190
191 // Member Functions
192
193 //- Read the dictionary
194 virtual bool read(const dictionary& dict);
195
196 //- Apply bins
197 virtual void apply();
198
199 //- Update for changes of mesh
200 virtual void updateMesh(const mapPolyMesh& mpm);
201
202 //- Update for changes of mesh
203 virtual void movePoints(const polyMesh& mesh);
204};
205
206
207// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
209#ifdef NoRepository
210 #include "uniformBinTemplates.C"
211#endif
212
213// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
214
215} // End namespace binModels
216} // End namespace Foam
217
218// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
219
220#endif
221
222// ************************************************************************* //
Output to file stream, using an OSstream.
Definition: OFstream.H:57
Templated 3D Vector derived from VectorSpace adding construction from 3 components,...
Definition: Vector.H:65
Base class for bin models to handle general bin characteristics.
Definition: binModel.H:64
Calculates binned data in multiple segments according to a specified Cartesian or cylindrical coordin...
Definition: uniformBin.H:164
virtual void setBinsAddressing()
Set/cache the bin addressing.
Definition: uniformBin.C:160
virtual void initialise()
Initialise bin properties.
Definition: uniformBin.C:44
void writeFileHeader(OFstream &os) const
Write header for an binned-data file.
virtual labelList binAddr(const vectorField &d) const
Return list of bin indices corresponding to positions given by d.
Definition: uniformBin.C:120
uniformBin(const uniformBin &)=delete
No copy construct.
Vector< vector2D > binMinMax_
Min-max bounds of bins in binning directions.
Definition: uniformBin.H:176
TypeName("uniformBin")
Runtime type information.
virtual void movePoints(const polyMesh &mesh)
Update for changes of mesh.
Definition: uniformBin.C:309
virtual bool read(const dictionary &dict)
Read the dictionary.
Definition: uniformBin.C:219
labelList cellToBin_
Cell index to bin index addressing.
Definition: uniformBin.H:182
virtual void apply()
Apply bins.
Definition: uniformBin.C:282
bool processField(const label fieldi)
Apply the binning to field fieldi.
vector binW_
Equidistant bin widths in binning directions.
Definition: uniformBin.H:173
virtual void updateMesh(const mapPolyMesh &mpm)
Update for changes of mesh.
Definition: uniformBin.C:305
labelList faceToBin_
Face index to bin index addressing.
Definition: uniformBin.H:179
Vector< label > nBins_
Numbers of bins in binning directions.
Definition: uniformBin.H:170
void operator=(const uniformBin &)=delete
No copy assignment.
virtual ~uniformBin()=default
Destructor.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:91
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
Definition: mapPolyMesh.H:162
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:81
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
A class for handling words, derived from Foam::string.
Definition: word.H:68
dynamicFvMesh & mesh
OBJstream os(runTime.globalPath()/outputName)
Namespace for OpenFOAM.
List< label > labelList
A List of labels.
Definition: List.H:66
Field< vector > vectorField
Specialisation of Field<T> for vector.
dictionary dict
#define TypeName(TypeNameString)
Declare a ClassName() with extra virtual type info.
Definition: typeInfo.H:73