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-2022 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;
57
58/*---------------------------------------------------------------------------*\
59 Class binModel Declaration
60\*---------------------------------------------------------------------------*/
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_;
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 (
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 (
129 Ostream& os
130 ) const;
131
132
133public:
134
135 //- Runtime type information
136 TypeName("binModel");
137
138
139 // Declare runtime constructor selection table
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
159 (
160 const dictionary& dict,
161 const fvMesh& mesh,
162 const word& outputPrefix
163 );
164
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 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
220template<>
222(
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
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:62
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers....
Definition: PtrList.H:73
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: autoPtr.H:66
Base class for bin models to handle general bin characteristics.
Definition: binModel.H:64
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:70
PtrList< OFstream > filePtrs_
List of file pointers; 1 file per field.
Definition: binModel.H:95
void writeBinnedData(List< List< Type > > &data, Ostream &os) const
Write binned data to stream.
wordList fieldNames_
Names of operand fields.
Definition: binModel.H:89
TypeName("binModel")
Runtime type information.
label nBin_
Total number of bins.
Definition: binModel.H:83
bool decomposePatchValues(List< List< Type > > &data, const label bini, const Type &v, const vector &n) const
virtual void movePoints(const polyMesh &mesh)
Update for changes of mesh.
Definition: binModel.C:201
label nBin() const noexcept
Return the total number of bins.
Definition: binModel.H:195
virtual bool read(const dictionary &dict)
Read the dictionary.
Definition: binModel.C:149
autoPtr< coordinateSystem > coordSysPtr_
Local coordinate system of bins.
Definition: binModel.H:80
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:34
virtual ~binModel()=default
Destructor.
virtual void updateMesh(const mapPolyMesh &mpm)
Update for changes of mesh.
Definition: binModel.C:197
labelHashSet patchSet_
Indices of operand patches.
Definition: binModel.H:86
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:92
bool cumulative_
Definition: binModel.H:77
void operator=(const binModel &)=delete
No copy assignment.
virtual void initialise()=0
Initialise bin properties.
virtual void apply()=0
Apply bins.
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:74
binModel(const binModel &)=delete
No copy construct.
Database for solution data, solver performance and other reduced data.
Definition: data.H:58
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
Base class for writing single files from the function objects.
Definition: writeFile.H:120
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:91
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
Definition: mapPolyMesh.H:162
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:81
A class for handling words, derived from Foam::string.
Definition: word.H:68
dynamicFvMesh & mesh
OBJstream os(runTime.globalPath()/outputName)
Namespace for OpenFOAM.
const direction noexcept
Definition: Scalar.H:223
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:73