initial commit for version 1.5.x patch release
[OpenFOAM-1.5.x.git] / src / postProcessing / forces / forces / forces.H
blob7b03805b9c17851ab1027a7eb261c4be11099d62
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 1991-2008 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 "labelHashSet.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 dictonary
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             //- Reference density needed for incompressible calculations
136             scalar rhoRef_;
138             //- Centre of rotation
139             vector CofR_;
142         //- Forces/moment file ptr
143         autoPtr<OFstream> forcesFilePtr_;
146     // Private Member Functions
148         //- If the forces file has not been created create it
149         void makeFile();
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();
168 public:
170     //- Runtime type information
171     TypeName("forces");
174     // Constructors
176         //- Construct for given objectRegistry and dictionary.
177         //  Allow the possibility to load fields from files
178         forces
179         (
180             const word& name,
181             const objectRegistry&,
182             const dictionary&,
183             const bool loadFromFiles = false
184         );
187     // Destructor
189         virtual ~forces();
192     // Member Functions
194         //- Return name of the set of forces
195         virtual const word& name() const
196         {
197             return name_;
198         }
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&)
211         {}
213         //- Update for changes of mesh
214         virtual void movePoints(const pointField&)
215         {}
219 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
221 } // End namespace Foam
223 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
225 #endif
227 // ************************************************************************* //