OpenFOAM logo
The Open Source CFD Toolbox
  Source Guide OpenCFD Solutions Contact OpenFOAM

forces.H

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002   =========                 |
00003   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
00004    \\    /   O peration     |
00005     \\  /    A nd           | Copyright (C) 1991-2009 OpenCFD Ltd.
00006      \\/     M anipulation  |
00007 -------------------------------------------------------------------------------
00008 License
00009     This file is part of OpenFOAM.
00010 
00011     OpenFOAM is free software; you can redistribute it and/or modify it
00012     under the terms of the GNU General Public License as published by the
00013     Free Software Foundation; either version 2 of the License, or (at your
00014     option) any later version.
00015 
00016     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
00017     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00019     for more details.
00020 
00021     You should have received a copy of the GNU General Public License
00022     along with OpenFOAM; if not, write to the Free Software Foundation,
00023     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
00024 
00025 Class
00026     Foam::forces
00027 
00028 Description
00029     Calculates the forces and moments by integrating the pressure and
00030     skin-friction forces over a given list of patches.
00031 
00032     Member function calcForcesMoment()calculates and returns the forces and
00033     moments.
00034 
00035     Member function forces::write() calls calcForcesMoment() and writes the
00036     forces and moments into the file <timeDir>/forces.dat
00037 
00038 SourceFiles
00039     forces.C
00040     IOforces.H
00041 
00042 \*---------------------------------------------------------------------------*/
00043 
00044 #ifndef forces_H
00045 #define forces_H
00046 
00047 #include "primitiveFieldsFwd.H"
00048 #include "volFieldsFwd.H"
00049 #include "HashSet.H"
00050 #include "Tuple2.H"
00051 #include "OFstream.H"
00052 #include "Switch.H"
00053 #include "pointFieldFwd.H"
00054 
00055 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00056 
00057 namespace Foam
00058 {
00059 
00060 // Forward declaration of classes
00061 class objectRegistry;
00062 class dictionary;
00063 class mapPolyMesh;
00064 
00065 /*---------------------------------------------------------------------------*\
00066                            Class forces Declaration
00067 \*---------------------------------------------------------------------------*/
00068 
00069 class forces
00070 {
00071 public:
00072 
00073     // Tuple which holds the pressure (.first()) and viscous (.second) forces
00074     typedef Tuple2<vector, vector> pressureViscous;
00075 
00076     // Tuple which holds the forces (.first()) and moment (.second)
00077     // pressure/viscous forces Tuples.
00078     typedef Tuple2<pressureViscous, pressureViscous> forcesMoments;
00079 
00080     //- Sum operation class to accumulate the pressure, viscous forces and moments
00081     class sumOp
00082     {
00083     public:
00084 
00085         forcesMoments operator()
00086         (
00087             const forcesMoments& fm1,
00088             const forcesMoments& fm2
00089         ) const
00090         {
00091             return forcesMoments
00092             (
00093                 pressureViscous
00094                 (
00095                     fm1.first().first() + fm2.first().first(),
00096                     fm1.first().second() + fm2.first().second()
00097                 ),
00098                 pressureViscous
00099                 (
00100                     fm1.second().first() + fm2.second().first(),
00101                     fm1.second().second() + fm2.second().second()
00102                 )
00103             );
00104         }
00105     };
00106 
00107 
00108 protected:
00109 
00110     // Private data
00111 
00112         //- Name of this set of forces,
00113         //  Also used as the name of the probes directory.
00114         word name_;
00115 
00116         const objectRegistry& obr_;
00117 
00118         //- on/off switch
00119         bool active_;
00120 
00121         //- Switch to send output to Info as well as to file
00122         Switch log_;
00123 
00124         // Read from dictionary
00125 
00126             //- Patches to integrate forces over
00127             labelHashSet patchSet_;
00128 
00129             //- Name of pressure field
00130             word pName_;
00131 
00132             //- Name of velocity field
00133             word UName_;
00134 
00135             //- Is the force density being supplied directly?
00136             Switch directForceDensity_;
00137 
00138             //- The name of the force density (fD) field
00139             word fDName_;
00140 
00141             //- Reference density needed for incompressible calculations
00142             scalar rhoRef_;
00143 
00144             //- Centre of rotation
00145             vector CofR_;
00146 
00147 
00148         //- Forces/moment file ptr
00149         autoPtr<OFstream> forcesFilePtr_;
00150 
00151 
00152     // Private Member Functions
00153 
00154         //- If the forces file has not been created create it
00155         void makeFile();
00156 
00157         //- Return the effective viscous stress (laminar + turbulent).
00158         tmp<volSymmTensorField> devRhoReff() const;
00159 
00160         //- Return rhoRef if the pressure field is dynamic, i.e. p/rho
00161         //  otherwise return 1
00162         scalar rho(const volScalarField& p) const;
00163 
00164         //- Disallow default bitwise copy construct
00165         forces(const forces&);
00166 
00167         //- Disallow default bitwise assignment
00168         void operator=(const forces&);
00169 
00170         //- Output file header information
00171         virtual void writeFileHeader();
00172 
00173 
00174 public:
00175 
00176     //- Runtime type information
00177     TypeName("forces");
00178 
00179 
00180     // Constructors
00181 
00182         //- Construct for given objectRegistry and dictionary.
00183         //  Allow the possibility to load fields from files
00184         forces
00185         (
00186             const word& name,
00187             const objectRegistry&,
00188             const dictionary&,
00189             const bool loadFromFiles = false
00190         );
00191 
00192 
00193     // Destructor
00194 
00195         virtual ~forces();
00196 
00197 
00198     // Member Functions
00199 
00200         //- Return name of the set of forces
00201         virtual const word& name() const
00202         {
00203             return name_;
00204         }
00205 
00206         //- Read the forces data
00207         virtual void read(const dictionary&);
00208 
00209         //- Execute, currently does nothing
00210         virtual void execute();
00211 
00212         //- Execute at the final time-loop, currently does nothing
00213         virtual void end();
00214 
00215         //- Write the forces
00216         virtual void write();
00217 
00218         //- Calculate and return forces and moment
00219         virtual forcesMoments calcForcesMoment() const;
00220 
00221         //- Update for changes of mesh
00222         virtual void updateMesh(const mapPolyMesh&)
00223         {}
00224 
00225         //- Update for changes of mesh
00226         virtual void movePoints(const pointField&)
00227         {}
00228 };
00229 
00230 
00231 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00232 
00233 } // End namespace Foam
00234 
00235 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00236 
00237 #endif
00238 
00239 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd