binModel.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::binModel
28 
29 Description
30  Base class for bin models to handle general bin characteristics.
31 
32 SourceFiles
33  binModel.C
34  binModelNew.C
35  binModelTemplates.C
36 
37 \*---------------------------------------------------------------------------*/
38 
39 #ifndef Foam_binModel_H
40 #define Foam_binModel_H
41 
42 #include "dictionary.H"
43 #include "HashSet.H"
44 #include "volFields.H"
45 #include "runTimeSelectionTables.H"
46 #include "OFstream.H"
47 #include "coordinateSystem.H"
48 #include "writeFile.H"
49 
50 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
51 
52 namespace Foam
53 {
54 
55 // Forward Declarations
56 class fvMesh;
57 
58 /*---------------------------------------------------------------------------*\
59  Class binModel Declaration
60 \*---------------------------------------------------------------------------*/
61 
62 class binModel
63 :
65 {
66 protected:
67 
68  // Protected Data
69 
70  //- Reference to the mesh
71  const fvMesh& mesh_;
72 
73  //- Decompose patch values into normal and tangential components
75 
76  //- Flag to accumulate bin data with
77  //- increasing distance in binning direction
78  bool cumulative_;
79 
80  //- Local coordinate system of bins
82 
83  //- Total number of bins
84  label nBin_;
85 
86  //- Indices of operand patches
88 
89  //- Names of operand fields
91 
92  //- Indices of operand cell zones
94 
95  //- List of file pointers; 1 file per field
97 
98 
99  // Protected Member Functions
100 
101  //- Set the co-ordinate system from dictionary and axes names
103  (
104  const dictionary& dict,
105  const word& e3Name = word::null,
106  const word& e1Name = word::null
107  );
108 
109  //- Helper function to decompose patch values
110  //- into normal and tangential components
111  template<class Type>
113  (
114  List<List<Type>>& data,
115  const label bini,
116  const Type& v,
117  const vector& n
118  ) const;
119 
120  //- Helper function to construct a string description for a given type
121  template<class Type>
122  string writeComponents(const word& stem) const;
123 
124  //- Write binned data to stream
125  template<class Type>
126  void writeBinnedData
127  (
128  List<List<Type>>& data,
129  Ostream& os
130  ) const;
131 
132 
133 public:
134 
135  //- Runtime type information
136  TypeName("binModel");
137 
138 
139  // Declare runtime constructor selection table
140 
142  (
143  autoPtr,
144  binModel,
145  dictionary,
146  (
147  const dictionary& dict,
148  const fvMesh& mesh,
149  const word& outputPrefix
150  ),
151  (dict, mesh, outputPrefix)
152  );
153 
154 
155  // Selectors
156 
157  //- Return a reference to the selected bin model
158  static autoPtr<binModel> New
159  (
160  const dictionary& dict,
161  const fvMesh& mesh,
162  const word& outputPrefix
163  );
164 
165 
166  // Constructors
167 
168  //- Construct from components
169  binModel
170  (
171  const dictionary& dict,
172  const fvMesh& mesh,
173  const word& outputPrefix
174  );
175 
176  //- No copy construct
177  binModel(const binModel&) = delete;
178 
179  //- No copy assignment
180  void operator=(const binModel&) = delete;
181 
182 
183  //- Destructor
184  virtual ~binModel() = default;
185 
186 
187  // Member Functions
188 
189  //- Read the dictionary
190  virtual bool read(const dictionary& dict);
191 
192 
193  // Access
194 
195  //- Return the total number of bins
196  label nBin() const noexcept
197  {
198  return nBin_;
199  };
200 
201 
202  // Evaluation
203 
204  //- Initialise bin properties
205  virtual void initialise() = 0;
206 
207  //- Apply bins
208  virtual void apply() = 0;
209 
210  //- Update for changes of mesh
211  virtual void updateMesh(const mapPolyMesh& mpm);
212 
213  //- Update for changes of mesh
214  virtual void movePoints(const polyMesh& mesh);
215 };
216 
217 
218 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
219 
220 template<>
222 (
223  List<List<vector>>& data,
224  const label bini,
225  const vector& v,
226  const vector& n
227 ) const;
228 
229 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
230 
231 } // End namespace Foam
232 
233 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
234 
235 #ifdef NoRepository
236  #include "binModelTemplates.C"
237 #endif
238 
239 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
240 
241 #endif
242 
243 // ************************************************************************* //
dictionary dict
const fvMesh & mesh_
Reference to the mesh.
Definition: binModel.H:68
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:129
void writeBinnedData(List< List< Type >> &data, Ostream &os) const
Write binned data to stream.
virtual ~binModel()=default
Destructor.
wordList fieldNames_
Names of operand fields.
Definition: binModel.H:99
bool decomposePatchValues_
Decompose patch values into normal and tangential components.
Definition: binModel.H:73
label nBin_
Total number of bins.
Definition: binModel.H:89
declareRunTimeSelectionTable(autoPtr, binModel, dictionary,(const dictionary &dict, const fvMesh &mesh, const word &outputPrefix),(dict, mesh, outputPrefix))
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
Definition: mapPolyMesh.H:157
virtual void initialise()=0
Initialise bin properties.
Base class for bin models to handle general bin characteristics.
Definition: binModel.H:57
dynamicFvMesh & mesh
void setCoordinateSystem(const dictionary &dict, const word &e3Name=word::null, const word &e1Name=word::null)
Set the co-ordinate system from dictionary and axes names.
Definition: binModel.C:67
A class for handling words, derived from Foam::string.
Definition: word.H:63
binModel(const dictionary &dict, const fvMesh &mesh, const word &outputPrefix)
Construct from components.
Definition: binModel.C:108
labelList patchIDs_
Indices of operand patches.
Definition: binModel.H:94
PtrList< OFstream > filePtrs_
List of file pointers; 1 file per field.
Definition: binModel.H:109
virtual void apply()=0
Apply bins.
virtual void updateMesh(const mapPolyMesh &mpm)
Update for changes of mesh.
Definition: binModel.C:182
static const word null
An empty word.
Definition: word.H:84
Vector< scalar > vector
Definition: vector.H:57
autoPtr< coordinateSystem > coordSysPtr_
Local coordinate system of bins.
Definition: binModel.H:84
label nBin() const noexcept
Return the total number of bins.
Definition: binModel.H:233
bool cumulative_
Flag to accumulate bin data with increasing distance in binning direction.
Definition: binModel.H:79
static autoPtr< binModel > New(const dictionary &dict, const fvMesh &mesh, const word &outputPrefix)
Return a reference to the selected bin model.
Definition: binModelNew.C:27
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:56
const direction noexcept
Definition: Scalar.H:258
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
string writeComponents(const word &stem) const
Helper function to construct a string description for a given type.
OBJstream os(runTime.globalPath()/outputName)
void operator=(const binModel &)=delete
No copy assignment.
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers...
Definition: List.H:55
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:78
virtual bool read(const dictionary &dict)
Read the dictionary.
Definition: binModel.C:125
bool decomposePatchValues(List< List< Type >> &data, const label bini, const Type &v, const vector &n) const
Helper function to decompose patch values into normal and tangential components.
label n
Pointer management similar to std::unique_ptr, with some additional methods and type checking...
Definition: HashPtrTable.H:48
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:74
Macros to ease declaration of run-time selection tables.
labelList cellZoneIDs_
Indices of operand cell zones.
Definition: binModel.H:104
TypeName("binModel")
Runtime type information.
Base class for writing single files from the function objects.
Definition: writeFile.H:112
virtual void movePoints(const polyMesh &mesh)
Update for changes of mesh.
Definition: binModel.C:186
Namespace for OpenFOAM.