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-2023 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::binModels::uniformBin
28 
29 Description
30  Calculates binned data in multiple segments according to
31  a specified Cartesian or cylindrical coordinate system.
32 
33 Usage
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 
74 Note
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 
96 SourceFiles
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 
111 namespace Foam
112 {
113 namespace binModels
114 {
115 
116 /*---------------------------------------------------------------------------*\
117  Class uniformBin Declaration
118 \*---------------------------------------------------------------------------*/
119 
120 class uniformBin
121 :
122  public binModel
123 {
124 protected:
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  //- The geometric min/max bounds for the bins
135  MinMax<vector> binLimits_;
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 
164 public:
165 
166  //- Runtime type information
167  TypeName("uniformBin");
169 
170  // Constructors
171 
172  //- Construct from components
174  (
175  const dictionary& dict,
176  const fvMesh& mesh,
177  const word& outputPrefix
178  );
179 
180  //- No copy construct
181  uniformBin(const uniformBin&) = delete;
182 
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 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
208 
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 // ************************************************************************* //
dictionary dict
Calculates binned data in multiple segments according to a specified Cartesian or cylindrical coordin...
Definition: uniformBin.H:157
uniformBin(const dictionary &dict, const fvMesh &mesh, const word &outputPrefix)
Construct from components.
Definition: uniformBin.C:217
MinMax< vector > binLimits_
The geometric min/max bounds for the bins.
Definition: uniformBin.H:178
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:129
bool processField(const label fieldi)
Apply the binning to field fieldi.
virtual void initialise()
Initialise bin properties.
Definition: uniformBin.C:37
virtual ~uniformBin()=default
Destructor.
virtual void updateMesh(const mapPolyMesh &mpm)
Update for changes of mesh.
Definition: uniformBin.C:325
labelList faceToBin_
Face index to bin index addressing.
Definition: uniformBin.H:183
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
Definition: mapPolyMesh.H:157
virtual void movePoints(const polyMesh &mesh)
Update for changes of mesh.
Definition: uniformBin.C:329
dynamicFvMesh & mesh
void writeFileHeader(OFstream &os) const
Write header for an binned-data file.
void operator=(const uniformBin &)=delete
No copy assignment.
A class for handling words, derived from Foam::string.
Definition: word.H:63
virtual labelList binAddr(const vectorField &d) const
Return list of bin indices corresponding to positions given by d.
Definition: uniformBin.C:132
Vector< scalar > vector
Definition: vector.H:57
OBJstream os(runTime.globalPath()/outputName)
vector binWidth_
Equidistant bin widths in binning directions.
Definition: uniformBin.H:173
labelList cellToBin_
Cell index to bin index addressing.
Definition: uniformBin.H:188
TypeName("uniformBin")
Runtime type information.
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:78
virtual bool read(const dictionary &dict)
Read the dictionary.
Definition: uniformBin.C:234
Field< vector > vectorField
Specialisation of Field<T> for vector.
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:74
List< label > labelList
A List of labels.
Definition: List.H:62
virtual void setBinsAddressing()
Set/cache the bin addressing.
Definition: uniformBin.C:180
Vector< label > nBins_
Numbers of bins in binning directions.
Definition: uniformBin.H:168
Namespace for OpenFOAM.
virtual void apply()
Apply bins.
Definition: uniformBin.C:301