1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd.
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
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 the
13 Free Software Foundation; either version 2 of the License, or (at your
14 option) any later version.
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
21 You should have received a copy of the GNU General Public License
22 along with OpenFOAM; if not, write to the Free Software Foundation,
23 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
29 Calculates the forces and moments by integrating the pressure and
30 skin-friction forces over a given list of patches.
32 Member function calcForcesMoment()calculates and returns the forces and
35 Member function forces::write() calls calcForcesMoment() and writes the
36 forces and moments into the file \<timeDir\>/forces.dat
42 \*---------------------------------------------------------------------------*/
47 #include "primitiveFieldsFwd.H"
48 #include "volFieldsFwd.H"
49 #include "labelHashSet.H"
53 #include "pointFieldFwd.H"
55 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
60 // Forward declaration of classes
65 /*---------------------------------------------------------------------------*\
66 Class forces Declaration
67 \*---------------------------------------------------------------------------*/
73 // Tuple which holds the pressure (.first()) and viscous (.second) forces
74 typedef Tuple2<vector, vector> pressureViscous;
76 // Tuple which holds the forces (.first()) and moment (.second)
77 // pressure/viscous forces Tuples.
78 typedef Tuple2<pressureViscous, pressureViscous> forcesMoments;
80 //- Sum operation class to accumulate the pressure, viscous forces and moments
85 forcesMoments operator()
87 const forcesMoments& fm1,
88 const forcesMoments& fm2
95 fm1.first().first() + fm2.first().first(),
96 fm1.first().second() + fm2.first().second()
100 fm1.second().first() + fm2.second().first(),
101 fm1.second().second() + fm2.second().second()
112 //- Name of this set of forces,
113 // Also used as the name of the probes directory.
116 const objectRegistry& obr_;
121 //- Switch to send output to Info as well as to file
124 // Read from dictonary
126 //- Patches to integrate forces over
127 labelHashSet patchSet_;
129 //- Name of pressure field
132 //- Name of velocity field
135 //- Reference density needed for incompressible calculations
138 //- Centre of rotation
142 //- Forces/moment file ptr
143 autoPtr<OFstream> forcesFilePtr_;
146 // Private Member Functions
148 //- If the forces file has not been created create it
151 //- Return the effective viscous stress (laminar + turbulent).
152 tmp<volSymmTensorField> devRhoReff() const;
154 //- Return rhoRef if the pressure field is dynamic, i.e. p/rho
155 // otherwise return 1
156 scalar rho(const volScalarField& p) const;
158 //- Disallow default bitwise copy construct
159 forces(const forces&);
161 //- Disallow default bitwise assignment
162 void operator=(const forces&);
164 //- Output file header information
165 virtual void writeFileHeader();
170 //- Runtime type information
176 //- Construct for given objectRegistry and dictionary.
177 // Allow the possibility to load fields from files
181 const objectRegistry&,
183 const bool loadFromFiles = false
194 //- Return name of the set of forces
195 virtual const word& name() const
200 //- Read the forces data
201 virtual void read(const dictionary&);
203 //- Calculate the forces and write
204 virtual void write();
206 //- Calculate and return forces and moment
207 virtual forcesMoments calcForcesMoment() const;
209 //- Update for changes of mesh
210 virtual void updateMesh(const mapPolyMesh&)
213 //- Update for changes of mesh
214 virtual void movePoints(const pointField&)
219 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
221 } // End namespace Foam
223 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
227 // ************************************************************************* //