added reference pressure to forces calc (ref FDelCitto)
[OpenFOAM-1.6.x.git] / src / postProcessing / functionObjects / forces / forces / forces.H
blob42bb67c23bb699b3a38bdef018e5b9e206ff8214
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 1991-2009 OpenCFD Ltd.
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
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
19     for more details.
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
25 Class
26     Foam::forces
28 Description
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
33     moments.
35     Member function forces::write() calls calcForcesMoment() and writes the
36     forces and moments into the file \<timeDir\>/forces.dat
38 SourceFiles
39     forces.C
40     IOforces.H
42 \*---------------------------------------------------------------------------*/
44 #ifndef forces_H
45 #define forces_H
47 #include "primitiveFieldsFwd.H"
48 #include "volFieldsFwd.H"
49 #include "HashSet.H"
50 #include "Tuple2.H"
51 #include "OFstream.H"
52 #include "Switch.H"
53 #include "pointFieldFwd.H"
55 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
57 namespace Foam
60 // Forward declaration of classes
61 class objectRegistry;
62 class dictionary;
63 class mapPolyMesh;
65 /*---------------------------------------------------------------------------*\
66                            Class forces Declaration
67 \*---------------------------------------------------------------------------*/
69 class forces
71 public:
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
81     class sumOp
82     {
83     public:
85         forcesMoments operator()
86         (
87             const forcesMoments& fm1,
88             const forcesMoments& fm2
89         ) const
90         {
91             return forcesMoments
92             (
93                 pressureViscous
94                 (
95                     fm1.first().first() + fm2.first().first(),
96                     fm1.first().second() + fm2.first().second()
97                 ),
98                 pressureViscous
99                 (
100                     fm1.second().first() + fm2.second().first(),
101                     fm1.second().second() + fm2.second().second()
102                 )
103             );
104         }
105     };
108 protected:
110     // Private data
112         //- Name of this set of forces,
113         //  Also used as the name of the probes directory.
114         word name_;
116         const objectRegistry& obr_;
118         //- on/off switch
119         bool active_;
121         //- Switch to send output to Info as well as to file
122         Switch log_;
124         // Read from dictionary
126             //- Patches to integrate forces over
127             labelHashSet patchSet_;
129             //- Name of pressure field
130             word pName_;
132             //- Name of velocity field
133             word UName_;
135             //- Name of density field (optional)
136             word rhoName_;
138             //- Is the force density being supplied directly?
139             Switch directForceDensity_;
141             //- The name of the force density (fD) field
142             word fDName_;
144             //- Reference density needed for incompressible calculations
145             scalar rhoRef_;
147             //- Reference pressure
148             scalar pRef_;
150             //- Centre of rotation
151             vector CofR_;
154         //- Forces/moment file ptr
155         autoPtr<OFstream> forcesFilePtr_;
158     // Private Member Functions
160         //- If the forces file has not been created create it
161         void makeFile();
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();
183 public:
185     //- Runtime type information
186     TypeName("forces");
189     // Constructors
191         //- Construct for given objectRegistry and dictionary.
192         //  Allow the possibility to load fields from files
193         forces
194         (
195             const word& name,
196             const objectRegistry&,
197             const dictionary&,
198             const bool loadFromFiles = false
199         );
202     //- Destructor
203     virtual ~forces();
206     // Member Functions
208         //- Return name of the set of forces
209         virtual const word& name() const
210         {
211             return name_;
212         }
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
221         virtual void end();
223         //- Write the forces
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&)
231         {}
233         //- Update for changes of mesh
234         virtual void movePoints(const pointField&)
235         {}
239 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
241 } // End namespace Foam
243 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
245 #endif
247 // ************************************************************************* //