initial commit for version 1.6.x patch release
[OpenFOAM-1.6.x.git] / src / postProcessing / functionObjects / forces / forces / forces.H
blob96651af97e0d8c0da030c59b7fbb7486e539257a
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             //- Is the force density being supplied directly?
136             Switch directForceDensity_;
138             //- The name of the force density (fD) field
139             word fDName_;
141             //- Reference density needed for incompressible calculations
142             scalar rhoRef_;
144             //- Centre of rotation
145             vector CofR_;
148         //- Forces/moment file ptr
149         autoPtr<OFstream> forcesFilePtr_;
152     // Private Member Functions
154         //- If the forces file has not been created create it
155         void makeFile();
157         //- Return the effective viscous stress (laminar + turbulent).
158         tmp<volSymmTensorField> devRhoReff() const;
160         //- Return rhoRef if the pressure field is dynamic, i.e. p/rho
161         //  otherwise return 1
162         scalar rho(const volScalarField& p) const;
164         //- Disallow default bitwise copy construct
165         forces(const forces&);
167         //- Disallow default bitwise assignment
168         void operator=(const forces&);
170         //- Output file header information
171         virtual void writeFileHeader();
174 public:
176     //- Runtime type information
177     TypeName("forces");
180     // Constructors
182         //- Construct for given objectRegistry and dictionary.
183         //  Allow the possibility to load fields from files
184         forces
185         (
186             const word& name,
187             const objectRegistry&,
188             const dictionary&,
189             const bool loadFromFiles = false
190         );
193     // Destructor
195         virtual ~forces();
198     // Member Functions
200         //- Return name of the set of forces
201         virtual const word& name() const
202         {
203             return name_;
204         }
206         //- Read the forces data
207         virtual void read(const dictionary&);
209         //- Execute, currently does nothing
210         virtual void execute();
212         //- Execute at the final time-loop, currently does nothing
213         virtual void end();
215         //- Write the forces
216         virtual void write();
218         //- Calculate and return forces and moment
219         virtual forcesMoments calcForcesMoment() const;
221         //- Update for changes of mesh
222         virtual void updateMesh(const mapPolyMesh&)
223         {}
225         //- Update for changes of mesh
226         virtual void movePoints(const pointField&)
227         {}
231 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
233 } // End namespace Foam
235 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
237 #endif
239 // ************************************************************************* //