Loading...
Searching...
No Matches
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-------------------------------------------------------------------------------
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::binModel
28
29Description
30 Base class for bin models to handle general bin characteristics.
31
32SourceFiles
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"
46#include "OFstream.H"
47#include "coordinateSystem.H"
48#include "writeFile.H"
49
50// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
51
52namespace Foam
53{
54
55// Forward Declarations
56class fvMesh;
58/*---------------------------------------------------------------------------*\
59 Class binModel Declaration
60\*---------------------------------------------------------------------------*/
61
62class binModel
63:
65{
66protected:
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_;
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
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 (
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
133public:
134
135 //- Runtime type information
136 TypeName("binModel");
137
138
139 // Declare runtime constructor selection table
140
142 (
143 autoPtr,
144 binModel,
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
160 const dictionary& dict,
161 const fvMesh& mesh,
162 const word& outputPrefix
163 );
165
166 // Constructors
167
168 //- Construct from components
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 function-object 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;
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
218// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
219
220template<>
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// ************************************************************************* //
label n
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition List.H:72
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition Ostream.H:59
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers....
Definition PtrList.H:67
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition autoPtr.H:65
string writeComponents(const word &stem) const
Helper function to construct a string description for a given type.
const fvMesh & mesh_
Reference to the mesh.
Definition binModel.H:68
PtrList< OFstream > filePtrs_
List of file pointers; 1 file per field.
Definition binModel.H:109
void writeBinnedData(List< List< Type > > &data, Ostream &os) const
Write binned data to stream.
wordList fieldNames_
Names of operand fields.
Definition binModel.H:99
TypeName("binModel")
Runtime type information.
label nBin_
Total number of bins.
Definition binModel.H:89
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.
virtual void movePoints(const polyMesh &mesh)
Update for changes of mesh.
Definition binModel.C:186
label nBin() const noexcept
Return the total number of bins.
Definition binModel.H:233
virtual bool read(const dictionary &dict)
Read the function-object dictionary.
Definition binModel.C:125
autoPtr< coordinateSystem > coordSysPtr_
Local coordinate system of bins.
Definition binModel.H:84
bool decomposePatchValues_
Decompose patch values into normal and tangential components.
Definition binModel.H:73
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
virtual ~binModel()=default
Destructor.
virtual void updateMesh(const mapPolyMesh &mpm)
Update for changes of mesh.
Definition binModel.C:182
declareRunTimeSelectionTable(autoPtr, binModel, dictionary,(const dictionary &dict, const fvMesh &mesh, const word &outputPrefix),(dict, mesh, outputPrefix))
labelList cellZoneIDs_
Indices of operand cell zones.
Definition binModel.H:104
bool cumulative_
Flag to accumulate bin data with increasing distance in binning direction.
Definition binModel.H:79
void operator=(const binModel &)=delete
No copy assignment.
virtual void initialise()=0
Initialise bin properties.
virtual void apply()=0
Apply bins.
binModel(const dictionary &dict, const fvMesh &mesh, const word &outputPrefix)
Construct from components.
Definition binModel.C:108
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
binModel(const binModel &)=delete
No copy construct.
labelList patchIDs_
Indices of operand patches.
Definition binModel.H:94
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition dictionary.H:133
Base class for writing single files from the function objects.
Definition writeFile.H:113
Mesh data needed to do the Finite Volume discretisation.
Definition fvMesh.H:85
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
Mesh consisting of general polyhedral cells.
Definition polyMesh.H:79
A class for handling words, derived from Foam::string.
Definition word.H:66
static const word null
An empty word.
Definition word.H:84
dynamicFvMesh & mesh
OBJstream os(runTime.globalPath()/outputName)
Namespace for OpenFOAM.
List< word > wordList
List of word.
Definition fileName.H:60
List< label > labelList
A List of labels.
Definition List.H:62
const direction noexcept
Definition scalarImpl.H:265
Vector< scalar > vector
Definition vector.H:57
Macros to ease declaration of run-time selection tables.
#define declareRunTimeSelectionTable(ptrWrapper, baseType, argNames, argList, parList)
Declare a run-time selection (variables and adder classes).
dictionary dict
#define TypeName(TypeNameString)
Declare a ClassName() with extra virtual type info.
Definition typeInfo.H:68