Reorganised the location of the "sixDoFRigidBodyDisplacement" BC to avoid unnecessary
[OpenFOAM-1.6.x.git] / src / postProcessing / functionObjects / forces / pointPatchFields / derived / sixDoFRigidBodyDisplacement / sixDoFRigidBodyMotion / sixDoFRigidBodyMotion.H
blob16ea1d42b2cba49d908ed4aadfe896bf4bb937b9
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 2009-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::sixDoFRigidBodyMotion
28 Description
29     Six degree of freedom motion for a rigid body.  Angular momentum stored in
30     body fixed reference frame.  Reference orientation of the body must align
31     with the cartesian axes such that the Inertia tensor is in principle
32     component form.
34     Symplectic motion as per:
36     title = {Symplectic splitting methods for rigid body molecular dynamics},
37     publisher = {AIP},
38     year = {1997},
39     journal = {The Journal of Chemical Physics},
40     volume = {107},
41     number = {15},
42     pages = {5840-5851},
43     url = {http://link.aip.org/link/?JCP/107/5840/1},
44     doi = {10.1063/1.474310}
46 SourceFiles
47     sixDoFRigidBodyMotionI.H
48     sixDoFRigidBodyMotion.C
49     sixDoFRigidBodyMotionIO.C
51 \*---------------------------------------------------------------------------*/
53 #ifndef sixDoFRigidBodyMotion_H
54 #define sixDoFRigidBodyMotion_H
56 #include "sixDoFRigidBodyMotionState.H"
57 #include "pointField.H"
59 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
61 namespace Foam
64 // Forward declaration of classes
65 class Istream;
66 class Ostream;
68 // Forward declaration of friend functions and operators
69 class sixDoFRigidBodyMotion;
70 Istream& operator>>(Istream&, sixDoFRigidBodyMotion&);
71 Ostream& operator<<(Ostream&, const sixDoFRigidBodyMotion&);
74 /*---------------------------------------------------------------------------*\
75                       Class sixDoFRigidBodyMotion Declaration
76 \*---------------------------------------------------------------------------*/
78 class sixDoFRigidBodyMotion
80     // Private data
82         // state data object
83         sixDoFRigidBodyMotionState motionState_;
85         //- Centre of mass of reference state
86         point refCentreOfMass_;
88         //- Moment of inertia of the body in reference configuration
89         diagTensor momentOfInertia_;
91         //- Mass of the body
92         scalar mass_;
95     // Private Member Functions
97         //- Calculate the rotation tensor around the body reference
98         //  frame x-axis by the given angle
99         inline tensor rotationTensorX(scalar deltaT) const;
101         //- Calculate the rotation tensor around the body reference
102         //  frame y-axis by the given angle
103         inline tensor rotationTensorY(scalar deltaT) const;
105         //- Calculate the rotation tensor around the body reference
106         //  frame z-axis by the given angle
107         inline tensor rotationTensorZ(scalar deltaT) const;
110 public:
112     // Constructors
114         //- Construct null
115         sixDoFRigidBodyMotion();
117         //- Construct from components
118         sixDoFRigidBodyMotion
119         (
120             const point& centreOfMass,
121             const tensor& Q,
122             const vector& v,
123             const vector& a,
124             const vector& pi,
125             const vector& tau,
126             scalar mass,
127             const point& refCentreOfMass,
128             const diagTensor& momentOfInertia
129         );
131         //- Construct from dictionary
132         sixDoFRigidBodyMotion(const dictionary& dict);
134         //- Construct as copy
135         sixDoFRigidBodyMotion(const sixDoFRigidBodyMotion&);
138     //- Destructor
139     ~sixDoFRigidBodyMotion();
142     // Member Functions
144         void updatePosition
145         (
146             scalar deltaT
147         );
149         void updateForce
150         (
151             const vector& fGlobal,
152             const vector& tauGlobal,
153             scalar deltaT
154         );
156         void updateForce
157         (
158             const pointField& positions,
159             const vectorField& forces,
160             scalar deltaT
161         );
163         tmp<pointField> generatePositions(const pointField& pts) const;
165         // Access
167             //- Return access to the motion state
168             inline const sixDoFRigidBodyMotionState& motionState() const;
170             //- Return access to the centre of mass
171             inline const point& centreOfMass() const;
173             //- Return access to the centre of mass
174             inline const point& refCentreOfMass() const;
176             //- Return access to the inertia tensor
177             inline const diagTensor& momentOfInertia() const;
179             //- Return access to the mass
180             inline scalar mass() const;
182             //- Return access to the orientation
183             inline const tensor& Q() const;
185             //- Return access to velocity
186             inline const vector& v() const;
188             //- Return access to acceleration
189             inline const vector& a() const;
191             //- Return access to angular momentum
192             inline const vector& pi() const;
194             //- Return access to torque
195             inline const vector& tau() const;
198         // Edit
200             //- Return non-const access to the centre of mass
201             inline point& centreOfMass();
203             //- Return access to the centre of mass
204             inline point& refCentreOfMass();
206             //- Return non-const access to the inertia tensor
207             inline diagTensor& momentOfInertia();
209             //- Return non-const access to the mass
210             inline scalar& mass();
212             //- Return non-const access to the orientation
213             inline tensor& Q();
215             //- Return non-const access to vector
216             inline vector& v();
218             //- Return non-const access to acceleration
219             inline vector& a();
221             //- Return non-const access to angular momentum
222             inline vector& pi();
224             //- Return non-const access to torque
225             inline vector& tau();
228         //- Write
229         void write(Ostream&) const;
232     // IOstream Operators
234         friend Istream& operator>>(Istream&, sixDoFRigidBodyMotion&);
235         friend Ostream& operator<<(Ostream&, const sixDoFRigidBodyMotion&);
239 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
241 } // End namespace Foam
243 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
245 #include "sixDoFRigidBodyMotionI.H"
247 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
249 #endif
251 // ************************************************************************* //