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-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::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 binWidth_;
109 
110  //- The min/max bounds for the bins
111  MinMax<scalar> binLimits_;
112 
113  //- Binning direction
114  vector binDir_;
115 
116 
117  // Protected Member Functions
118 
119  //- Write header for a binned-data file
120  template<class Type>
121  void writeFileHeader(OFstream& os) const;
122 
123  //- Initialise bin properties
124  virtual void initialise();
125 
126  //- Apply the binning to field fieldi
127  template<class Type>
128  bool processField(const label fieldi);
129 
130 
131 public:
132 
133  //- Runtime type information
134  TypeName("singleDirectionUniformBin");
135 
136 
137  // Constructors
138 
139  //- Construct from components
141  (
142  const dictionary& dict,
143  const fvMesh& mesh,
144  const word& outputPrefix
145  );
146 
147  //- No copy construct
149 
150  //- No copy assignment
151  void operator=(const singleDirectionUniformBin&) = delete;
152 
153 
154  //- Destructor
155  virtual ~singleDirectionUniformBin() = default;
156 
157 
158  // Member Functions
160  //- Read the dictionary
161  virtual bool read(const dictionary& dict);
162 
163  //- Apply bins
164  virtual void apply();
165 };
166 
167 
168 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
170 } // End namespace binModels
171 } // End namespace Foam
172 
173 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
174 
175 #ifdef NoRepository
177 #endif
178 
179 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
180 
181 #endif
182 
183 // ************************************************************************* //
dictionary dict
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:129
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)
scalar binWidth_
Distance between bin divisions.
virtual ~singleDirectionUniformBin()=default
Destructor.
void writeFileHeader(OFstream &os) const
Write header for a binned-data file.
virtual void initialise()
Initialise bin properties.
singleDirectionUniformBin(const dictionary &dict, const fvMesh &mesh, const word &outputPrefix)
Construct from components.
MinMax< scalar > binLimits_
The min/max bounds for the bins.
Namespace for OpenFOAM.