singleDirectionUniformBin.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 -------------------------------------------------------------------------------
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::singleDirectionUniformBin
28 
29 Description
30  Calculates binned data in a specified direction.
31 
32  For example, a 10cm-long patch extending only in the x-direction
33  can be binned into 5 bins in the same direction, so that
34  local information can be output for each 2cm-long segment.
35 
36 Usage
37  Minimal example by using \c system/controlDict.functions:
38  \verbatim
39  binField1
40  {
41  // Other binField entries
42  ...
43 
44  // Mandatory entries
45  binModel singleDirectionUniformBin;
46 
47  binData
48  {
49  // Mandatory entries
50  nBin <label>;
51  direction <vector>;
52 
53  // Optional entries
54  cumulative <bool>;
55  min <scalar>;
56  max <scalar>;
57  }
58  }
59  \endverbatim
60 
61  where the entries mean:
62  \table
63  Property | Description | Type | Reqd | Deflt
64  binModel | Type name: singleDirectionUniformBin | word | yes | -
65  binData | Entries of the chosen bin model | dict | yes | -
66  nBin | Number of bins in binning direction | label | yes | -
67  direction | Binning direction | vector | yes | -
68  cumulative | Flag to bin data accumulated with increasing distance <!--
69  --> in binning direction | bool | no | false
70  min | Min-bound in the binning direction with respect to <!--
71  --> the global coordinate system's origin | scalar | no | GREAT
72  max | Max-bound in the binning direction with respect to <!--
73  --> the global coordinate system's origin | scalar | no | GREAT
74  \endtable
75 
76 SourceFiles
77  singleDirectionUniformBin.C
78  singleDirectionUniformBinTemplates.C
79 
80 \*---------------------------------------------------------------------------*/
81 
82 #ifndef Foam_binModels_singleDirectionUniformBin_H
83 #define Foam_binModels_singleDirectionUniformBin_H
84 
85 #include "binModel.H"
86 #include "writeFile.H"
87 
88 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
89 
90 namespace Foam
91 {
92 namespace binModels
93 {
94 
95 /*---------------------------------------------------------------------------*\
96  Class singleDirectionUniformBin Declaration
97 \*---------------------------------------------------------------------------*/
98 
99 class singleDirectionUniformBin
100 :
101  public binModel
102 {
103 protected:
104 
105  // Protected Data
106 
107  //- Distance between bin divisions
108  scalar binDx_;
109 
110  //- Minimum bin bound
111  scalar binMin_;
112 
113  //- Maximum bin bound
114  scalar binMax_;
115 
116  //- Binning direction
117  vector binDir_;
118 
119 
120  // Protected Member Functions
121 
122  //- Write header for a binned-data file
123  template<class Type>
124  void writeFileHeader(OFstream& os) const;
125 
126  //- Initialise bin properties
127  virtual void initialise();
128 
129  //- Apply the binning to field fieldi
130  template<class Type>
131  bool processField(const label fieldi);
132 
133 
134 public:
135 
136  //- Runtime type information
137  TypeName("singleDirectionUniformBin");
138 
139 
140  // Constructors
141 
142  //- Construct from components
144  (
145  const dictionary& dict,
146  const fvMesh& mesh,
147  const word& outputPrefix
148  );
149 
150  //- No copy construct
152 
153  //- No copy assignment
154  void operator=(const singleDirectionUniformBin&) = delete;
155 
156 
157  //- Destructor
158  virtual ~singleDirectionUniformBin() = default;
160 
161  // Member Functions
162 
163  //- Read the dictionary
164  virtual bool read(const dictionary& dict);
165 
166  //- Apply bins
167  virtual void apply();
168 };
170 
171 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
172 
173 } // End namespace binModels
174 } // End namespace Foam
175 
176 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
177 
178 #ifdef NoRepository
180 #endif
181 
182 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
183 
184 #endif
185 
186 // ************************************************************************* //
dictionary dict
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:120
void operator=(const singleDirectionUniformBin &)=delete
No copy assignment.
virtual bool read(const dictionary &dict)
Read the dictionary.
bool processField(const label fieldi)
Apply the binning to field fieldi.
dynamicFvMesh & mesh
Calculates binned data in a specified direction.
Vector< scalar > vector
Definition: vector.H:57
TypeName("singleDirectionUniformBin")
Runtime type information.
OBJstream os(runTime.globalPath()/outputName)
virtual ~singleDirectionUniformBin()=default
Destructor.
void writeFileHeader(OFstream &os) const
Write header for a binned-data file.
scalar binDx_
Distance between bin divisions.
virtual void initialise()
Initialise bin properties.
singleDirectionUniformBin(const dictionary &dict, const fvMesh &mesh, const word &outputPrefix)
Construct from components.
Namespace for OpenFOAM.