1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2009 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"
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 dictionary
126 //- Patches to integrate forces over
127 labelHashSet patchSet_;
129 //- Name of pressure field
132 //- Name of velocity field
135 //- Name of density field (optional)
138 //- Is the force density being supplied directly?
139 Switch directForceDensity_;
141 //- The name of the force density (fD) field
144 //- Reference density needed for incompressible calculations
147 //- Reference pressure
150 //- Centre of rotation
154 //- Forces/moment file ptr
155 autoPtr<OFstream> forcesFilePtr_;
158 // Private Member Functions
160 //- If the forces file has not been created create it
163 //- Return the effective viscous stress (laminar + turbulent).
164 tmp<volSymmTensorField> devRhoReff() const;
166 //- Return rho if rhoName is specified otherwise rhoRef
167 tmp<volScalarField> rho() const;
169 //- Return rhoRef if the pressure field is dynamic, i.e. p/rho
170 // otherwise return 1
171 scalar rho(const volScalarField& p) const;
173 //- Disallow default bitwise copy construct
174 forces(const forces&);
176 //- Disallow default bitwise assignment
177 void operator=(const forces&);
179 //- Output file header information
180 virtual void writeFileHeader();
185 //- Runtime type information
191 //- Construct for given objectRegistry and dictionary.
192 // Allow the possibility to load fields from files
196 const objectRegistry&,
198 const bool loadFromFiles = false
208 //- Return name of the set of forces
209 virtual const word& name() const
214 //- Read the forces data
215 virtual void read(const dictionary&);
217 //- Execute, currently does nothing
218 virtual void execute();
220 //- Execute at the final time-loop, currently does nothing
224 virtual void write();
226 //- Calculate and return forces and moment
227 virtual forcesMoments calcForcesMoment() const;
229 //- Update for changes of mesh
230 virtual void updateMesh(const mapPolyMesh&)
233 //- Update for changes of mesh
234 virtual void movePoints(const pointField&)
239 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
241 } // End namespace Foam
243 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
247 // ************************************************************************* //