Loading...
Searching...
No Matches
ITHACAforces18.H
Go to the documentation of this file.
1/*---------------------------------------------------------------------------*\
2 ██╗████████╗██╗ ██╗ █████╗ ██████╗ █████╗ ███████╗██╗ ██╗
3 ██║╚══██╔══╝██║ ██║██╔══██╗██╔════╝██╔══██╗ ██╔════╝██║ ██║
4 ██║ ██║ ███████║███████║██║ ███████║█████╗█████╗ ██║ ██║
5 ██║ ██║ ██╔══██║██╔══██║██║ ██╔══██║╚════╝██╔══╝ ╚██╗ ██╔╝
6 ██║ ██║ ██║ ██║██║ ██║╚██████╗██║ ██║ ██║ ╚████╔╝
7 ╚═╝ ╚═╝ ╚═╝ ╚═╝╚═╝ ╚═╝ ╚═════╝╚═╝ ╚═╝ ╚═╝ ╚═══╝
8
9 * In real Time Highly Advanced Computational Applications for Finite Volumes
10 * Copyright (C) 2017 by the ITHACA-FV authors
11-------------------------------------------------------------------------------
12License
13 This file is part of ITHACA-FV
14 ITHACA-FV is free software: you can redistribute it and/or modify
15 it under the terms of the GNU Lesser General Public License as published by
16 the Free Software Foundation, either version 3 of the License, or
17 (at your option) any later version.
18 ITHACA-FV is distributed in the hope that it will be useful,
19 but WITHOUT ANY WARRANTY; without even the implied warranty of
20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 GNU Lesser General Public License for more details.
22 You should have received a copy of the GNU Lesser General Public License
23 along with ITHACA-FV. If not, see <http://www.gnu.org/licenses/>.
24\*---------------------------------------------------------------------------*/
25
26#ifndef functionObjects_ITHACAforces_H
27#define functionObjects_ITHACAforces_H
28
29#include "fvMeshFunctionObject.H"
30#include "writeFile.H"
31#include "cartesianCS.H"
32#include "volFieldsFwd.H"
33#include "HashSet.H"
34#include "Tuple2.H"
35#include "OFstream.H"
36#include "Switch.H"
37
38// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
39
40namespace Foam
41{
42namespace functionObjects
43{
44
45/*---------------------------------------------------------------------------*\
46 Class forces Declaration
47\*---------------------------------------------------------------------------*/
48
50 :
51 public fvMeshFunctionObject,
52 public writeFile
53{
54
55 protected:
56
57 // Protected data
58
59 //- Pressure, viscous and porous force per bin
60 List<Field<vector>> force_;
61
62 //- Pressure, viscous and porous moment per bin
63 List<Field<vector>> moment_;
64
65 // File streams
66
67 //- Forces
68 autoPtr<OFstream> forceFilePtr_;
69
70 //- Moments
71 autoPtr<OFstream> momentFilePtr_;
72
73 //- Force bins
74 autoPtr<OFstream> forceBinFilePtr_;
75
76 //- Moment bins
77 autoPtr<OFstream> momentBinFilePtr_;
78
79 //- Local force
80 autoPtr<OFstream> localForceFilePtr_;
81
82 //- Local moment
83 autoPtr<OFstream> localMomentFilePtr_;
84
85 //- Local force bins
86 autoPtr<OFstream> localForceBinFilePtr_;
87
88 //- Local moment bins
89 autoPtr<OFstream> localMomentBinFilePtr_;
90
91
92 // Read from dictionary
93
94 //- Patches to integrate forces over
95 labelHashSet patchSet_;
96
97 //- Name of pressure field
98 word pName_;
99
100 //- Name of velocity field
101 word UName_;
102
103 //- Name of density field (optional)
104 word rhoName_;
105
106 //- Is the force density being supplied directly?
107 Switch directForceDensity_;
108
109 //- The name of the force density (fD) field
110 word fDName_;
111
112 //- Reference density needed for incompressible calculations
113 scalar rhoRef_;
114
115 //- Reference pressure
116 scalar pRef_;
117
118 //- Coordinate system used when evaluting forces/moments
119 coordSystem::cartesian coordSys_;
120
121 //- Flag to indicate whether we are using a local coordinates
122 bool localSystem_;
123
124 //- Flag to include porosity effects
125 bool porosity_;
126
127
128 // Bin information
129
130 //- Number of bins
131 label nBin_;
132
133 //- Direction used to determine bin orientation
134 vector binDir_;
135
136 //- Distance between bin divisions
137 scalar binDx_;
138
139 //- Minimum bin bounds
140 scalar binMin_;
141
142 //- Bin positions along binDir
143 List<point> binPoints_;
144
145 //- Should bin data be cumulative?
146 bool binCumulative_;
147
148
149 //- Write fields flag
151
152 //- Initialised flag
153 bool initialised_;
154
155
156 // Protected Member Functions
157
158 //- Create a field name
159 word fieldName(const word& name) const;
160
161 //- Create the output files
163
164 //- Write header for integrated data
165 void writeIntegratedHeader(const word& header, Ostream& os) const;
166
167 //- Write header for binned data
168 void writeBinHeader(const word& header, Ostream& os) const;
169
170 //- Initialise the fields
172
173 //- Initialise the collection bins
175
176 //- Reset the fields prior to accumulation of force/moments
178
179 //- Return the effective viscous stress (laminar + turbulent).
180 tmp<volSymmTensorField> devRhoReff() const;
181
182 //- Dynamic viscosity field
183 tmp<volScalarField> mu() const;
184
185 //- Return rho if specified otherwise rhoRef
186 tmp<volScalarField> rho() const;
187
188 //- Return rhoRef if the pressure field is dynamic, i.e. p/rho
189 // otherwise return 1
190 scalar rho(const volScalarField& p) const;
191
192 //- Accumulate bin data
194 (
195 const vectorField& Md,
196 const vectorField& fN,
197 const vectorField& fT,
198 const vectorField& fP,
199 const vectorField& d
200 );
201
202 //- Add patch contributions to force and moment fields
204 (
205 const label patchi,
206 const vectorField& Md,
207 const vectorField& fN,
208 const vectorField& fT,
209 const vectorField& fP
210 );
211
212 //- Add cell contributions to force and moment fields
214 (
215 const labelList& cellIDs,
216 const vectorField& Md,
217 const vectorField& fN,
218 const vectorField& fT,
219 const vectorField& fP
220 );
221
222 //- Helper function to write integrated forces and moments
224 (
225 const string& descriptor,
226 const vectorField& fm0,
227 const vectorField& fm1,
228 const vectorField& fm2,
229 autoPtr<OFstream>& osPtr
230 ) const;
231
232 //- Write force data
234
235 //- Helper function to write binned forces and moments
237 (
238 const List<Field<vector>>& fm,
239 autoPtr<OFstream>& osPtr
240 ) const;
241
242 //- Write binned data
243 void writeBins();
244
245 //- No copy construct
246 ITHACAforces(const ITHACAforces&) = delete;
247
248 //- No copy assignment
249 void operator=(const ITHACAforces&) = delete;
250
251
252 public:
253
254 //- Runtime type information
255 TypeName("ITHACAforces");
256
257
258 // Constructors
259
260 //- Construct from Time and dictionary
262 (
263 const word& name,
264 const Time& runTime,
265 const dictionary& dict,
266 const bool readFields = true
267 );
268
269 //- Construct from objectRegistry and dictionary
271 (
272 const word& name,
273 const objectRegistry& obr,
274 const dictionary& dict,
275 const bool readFields = true
276 );
277
278
279 //- Destructor
280 virtual ~ITHACAforces();
281
282
283 // Member Functions
284
285 //- Read the forces data
286 virtual bool read(const dictionary&);
287
288 //- Calculate the forces and moments
289 virtual void calcForcesMoment();
290
291 //- Return the total force
292 virtual vector forceEff() const;
293
294 //- Return the total moment
295 virtual vector momentEff() const;
296
297 //- Return the viscous forces
298 virtual vector forceTau() const;
299
300 //- Return the pressure forces
301 virtual vector forcePressure() const;
302
303 //- Execute, currently does nothing
304 virtual bool execute();
305
306 //- Write the forces
307 virtual bool write();
308};
309
310
311// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
312
313} // End namespace functionObjects
314} // End namespace Foam
315
316// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
317
318#endif
319
320// ************************************************************************* //
Foam::Time & runTime
Definition createTime.H:33
autoPtr< OFstream > localForceBinFilePtr_
autoPtr< OFstream > localMomentBinFilePtr_
List< Field< vector > > moment_
virtual vector forceEff() const
void writeBinnedForceMoment(const List< Field< vector > > &fm, autoPtr< OFstream > &osPtr) const
void writeIntegratedForceMoment(const string &descriptor, const vectorField &fm0, const vectorField &fm1, const vectorField &fm2, autoPtr< OFstream > &osPtr) const
void operator=(const ITHACAforces &)=delete
void applyBins(const vectorField &Md, const vectorField &fN, const vectorField &fT, const vectorField &fP, const vectorField &d)
tmp< volScalarField > rho() const
void addToFields(const label patchi, const vectorField &Md, const vectorField &fN, const vectorField &fT, const vectorField &fP)
word fieldName(const word &name) const
void addToFields(const labelList &cellIDs, const vectorField &Md, const vectorField &fN, const vectorField &fT, const vectorField &fP)
tmp< volSymmTensorField > devRhoReff() const
scalar rho(const volScalarField &p) const
autoPtr< OFstream > localMomentFilePtr_
virtual vector forceTau() const
void writeBinHeader(const word &header, Ostream &os) const
List< Field< vector > > force_
void writeIntegratedHeader(const word &header, Ostream &os) const
virtual bool read(const dictionary &)
ITHACAforces(const word &name, const objectRegistry &obr, const dictionary &dict, const bool readFields=true)
tmp< volScalarField > mu() const
ITHACAforces(const word &name, const Time &runTime, const dictionary &dict, const bool readFields=true)
virtual vector momentEff() const
virtual vector forcePressure() const
ITHACAforces(const ITHACAforces &)=delete
volScalarField & p