forceCoeffs.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 | Copyright (C) 2011-2015 OpenFOAM Foundation
6  \\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 Class
25  Foam::forceCoeffs
26 
27 Group
28  grpForcesFunctionObjects
29 
30 Description
31  This function object extends the Foam::forces function object by providing
32  lift, drag and moment coefficients. The data can optionally be output into
33  bins, defined in a given direction.
34 
35  The binned data provides the total and consitituentcomponents per bin:
36  - total coefficient
37  - pressure coefficient contribution
38  - viscous coefficient contribution
39  - porous coefficient contribution
40 
41  Data is written into multiple files in the
42  postProcessing/<functionObjectName> directory:
43  - coefficient.dat : integrated coefficients over all geometries
44  - CmBin.dat : moment coefficient bins
45  - CdBin.dat : drag coefficient bins
46  - ClBin.dat : lift coefficient bins
47 
48  Example of function object specification:
49  \verbatim
50  forceCoeffs1
51  {
52  type forceCoeffs;
53  functionObjectLibs ("libforces.so");
54  ...
55  log yes;
56  writeFields yes;
57  patches (walls);
58  liftDir (0 1 0);
59  dragDir (-1 0 0);
60  pitchAxis (0 0 1);
61  magUInf 100;
62  lRef 3.5;
63  Aref 2.2;
64 
65  binData
66  {
67  nBin 20;
68  direction (1 0 0);
69  cumulative yes;
70  }
71  }
72  \endverbatim
73 
74  \heading Function object usage
75  \table
76  Property | Description | Required | Default value
77  type | type name: forces | yes |
78  log | write force data to standard output | no | no
79  writeFields | write the force and moment coefficient fields | no | no
80  patches | patches included in the forces calculation | yes |
81  liftDir | lift direction | yes |
82  dragDir | drag direction | yes |
83  pitchAxis | picth axis | yes |
84  magUInf | free stream velocity magnitude | yes |
85  lRef | reference length scale for moment calculations | yes |
86  Aref | reference area | yes |
87  porosity | flag to include porosity contributions | no | no
88  \endtable
89 
90  Bin data is optional, but if the dictionary is present, the entries must
91  be defined according o
92  \table
93  nBin | number of data bins | yes |
94  direction | direction along which bins are defined | yes |
95  cumulative | bin data accumulated with incresing distance | yes |
96  \endtable
97 
98 SeeAlso
99  Foam::functionObject
100  Foam::OutputFilterFunctionObject
101  Foam::forces
102 
103 SourceFiles
104  forceCoeffs.C
105  IOforceCoeffs.H
106 
107 \*---------------------------------------------------------------------------*/
108 
109 #ifndef forceCoeffs_H
110 #define forceCoeffs_H
111 
112 #include "forces.H"
113 
114 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
115 
116 namespace Foam
117 {
118 
119 /*---------------------------------------------------------------------------*\
120  Class forceCoeffs Declaration
121 \*---------------------------------------------------------------------------*/
122 
123 class forceCoeffs
124 :
125  public forces
126 {
127  // Private data
128 
129  // Force coefficient geometry
130 
131  //- Lift
133 
134  //- Drag
136 
137  //- Pitch
139 
140 
141  // Free-stream conditions
142 
143  //- Velocity magnitude
144  scalar magUInf_;
145 
146 
147  // Reference scales
148 
149  //- Length
150  scalar lRef_;
151 
152  //- Area
153  scalar Aref_;
154 
155 
156  // File streams
157 
158  //- Integrated coefficients
159  autoPtr<OFstream> coeffFilePtr_;
160 
161  //- Moment coefficient
162  autoPtr<OFstream> CmBinFilePtr_;
163 
164  //- Drag coefficient
165  autoPtr<OFstream> CdBinFilePtr_;
166 
167  //- Lift coefficient
168  autoPtr<OFstream> ClBinFilePtr_;
169 
170 
171  // Private Member Functions
172 
173  //- Disallow default bitwise copy construct
174  forceCoeffs(const forceCoeffs&);
175 
176  //- Disallow default bitwise assignment
177  void operator=(const forceCoeffs&);
178 
179 
180 protected:
181 
182  // Protected Member Functions
183 
184  //- Create the output files
185  void createFiles();
186 
187  //- Write header for integrated data
188  void writeIntegratedHeader(const word& header, Ostream& os) const;
189 
190  //- Write header for binned data
191  void writeBinHeader(const word& header, Ostream& os) const;
192 
193  //- Write integrated data
195  (
196  const word& title,
198  ) const;
199 
200  //- Write binned data
201  void writeBinData(const List<Field<scalar> > coeffs, Ostream& os) const;
202 
203 
204 public:
205 
206  //- Runtime type information
207  TypeName("forceCoeffs");
208 
209 
210  // Constructors
211 
212  //- Construct for given objectRegistry and dictionary.
213  // Allow the possibility to load fields from files
215  (
216  const word& name,
217  const objectRegistry&,
218  const dictionary&,
219  const bool loadFromFiles = false,
220  const bool readFields = true
221  );
222 
223 
224  //- Destructor
225  virtual ~forceCoeffs();
226 
227 
228  // Member Functions
229 
230  //- Read the forces data
231  virtual void read(const dictionary&);
232 
233  //- Execute, currently does nothing
234  virtual void execute();
235 
236  //- Execute at the final time-loop, currently does nothing
237  virtual void end();
238 
239  //- Called when time was set at the end of the Time::operator++
240  virtual void timeSet();
241 
242  //- Write the forces
243  virtual void write();
244 };
245 
246 
247 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
248 
249 } // End namespace Foam
250 
251 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
252 
253 #endif
254 
255 // ************************************************************************* //
Foam::word
A class for handling words, derived from string.
Definition: word.H:59
Foam::forceCoeffs::liftDir_
vector liftDir_
Lift.
Definition: forceCoeffs.H:206
Foam::forceCoeffs::writeIntegratedHeader
void writeIntegratedHeader(const word &header, Ostream &os) const
Write header for integrated data.
Definition: forceCoeffs.C:68
Foam::forceCoeffs::read
virtual void read(const dictionary &)
Read the forces data.
Definition: forceCoeffs.C:238
Foam::readFields
This function object reads fields from the time directories and adds them to the mesh database for fu...
Definition: readFields.H:104
Foam::objectRegistry
Registry of regIOobjects.
Definition: objectRegistry.H:50
Foam::forceCoeffs::Aref_
scalar Aref_
Area.
Definition: forceCoeffs.H:227
Foam::Field< scalar >
Foam::forceCoeffs::magUInf_
scalar magUInf_
Velocity magnitude.
Definition: forceCoeffs.H:218
Foam::forceCoeffs::timeSet
virtual void timeSet()
Called when time was set at the end of the Time::operator++.
Definition: forceCoeffs.C:432
Foam::forceCoeffs::writeBinHeader
void writeBinHeader(const word &header, Ostream &os) const
Write header for binned data.
Definition: forceCoeffs.C:93
Foam::forceCoeffs::end
virtual void end()
Execute at the final time-loop, currently does nothing.
Definition: forceCoeffs.C:426
Foam::forceCoeffs::writeIntegratedData
void writeIntegratedData(const word &title, const List< Field< scalar > > &coeff) const
Write integrated data.
Definition: forceCoeffs.C:148
Foam::forces::name
virtual const word & name() const
Return name of the set of forces.
Definition: forces.H:484
Foam::dictionary
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:137
Foam::forceCoeffs::createFiles
void createFiles()
Create the output files.
Definition: forceCoeffs.C:45
Foam::forceCoeffs::~forceCoeffs
virtual ~forceCoeffs()
Destructor.
Definition: forceCoeffs.C:232
Foam::forceCoeffs::lRef_
scalar lRef_
Length.
Definition: forceCoeffs.H:224
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
coeff
const scalar coeff[]
Definition: Test-Polynomial.C:38
Foam::vector
Vector< scalar > vector
A scalar version of the templated Vector.
Definition: vector.H:49
Foam::forceCoeffs::operator=
void operator=(const forceCoeffs &)
Disallow default bitwise assignment.
Foam::forceCoeffs::coeffFilePtr_
autoPtr< OFstream > coeffFilePtr_
Integrated coefficients.
Definition: forceCoeffs.H:233
Foam::forceCoeffs::TypeName
TypeName("forceCoeffs")
Runtime type information.
Foam::forceCoeffs::CdBinFilePtr_
autoPtr< OFstream > CdBinFilePtr_
Drag coefficient.
Definition: forceCoeffs.H:239
Foam::forceCoeffs::write
virtual void write()
Write the forces.
Definition: forceCoeffs.C:438
Foam::forces
This function object calculates the forces and moments by integrating the pressure and skin-friction ...
Definition: forces.H:234
Foam::autoPtr
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:117
forces.H
Foam::forceCoeffs
This function object extends the Foam::forces function object by providing lift, drag and moment coef...
Definition: forceCoeffs.H:197
Foam::Vector< scalar >
Foam::forceCoeffs::forceCoeffs
forceCoeffs(const forceCoeffs &)
Disallow default bitwise copy construct.
Foam::List
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: HashTable.H:59
Foam::forceCoeffs::pitchAxis_
vector pitchAxis_
Pitch.
Definition: forceCoeffs.H:212
Foam::forceCoeffs::execute
virtual void execute()
Execute, currently does nothing.
Definition: forceCoeffs.C:304
Foam::forceCoeffs::ClBinFilePtr_
autoPtr< OFstream > ClBinFilePtr_
Lift coefficient.
Definition: forceCoeffs.H:242
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:53
Foam::forceCoeffs::dragDir_
vector dragDir_
Drag.
Definition: forceCoeffs.H:209
Foam::forceCoeffs::CmBinFilePtr_
autoPtr< OFstream > CmBinFilePtr_
Moment coefficient.
Definition: forceCoeffs.H:236
Foam::forceCoeffs::writeBinData
void writeBinData(const List< Field< scalar > > coeffs, Ostream &os) const
Write binned data.
Definition: forceCoeffs.C:176