symplectic.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | Copyright (C) 2016 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
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
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
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.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
26 #include "symplectic.H"
28 
29 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
30 
31 namespace Foam
32 {
33 namespace RBD
34 {
35 namespace rigidBodySolvers
36 {
37  defineTypeNameAndDebug(symplectic, 0);
38  addToRunTimeSelectionTable(rigidBodySolver, symplectic, dictionary);
39 }
40 }
41 }
42 
43 
44 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
45 
47 (
48  rigidBodyMotion& body,
49  const dictionary& dict
50 )
51 :
52  rigidBodySolver(body)
53 {}
54 
55 
56 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
57 
59 {}
60 
61 
62 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
63 
65 (
66  const scalarField& tau,
67  const Field<spatialVector>& fx
68 )
69 {
70  // First simplectic step:
71  // Half-step for linear and angular velocities
72  // Update position and orientation
73  qDot() = qDot0() + 0.5*deltaT0()*qDdot();
74  q() = q0() + deltaT()*qDot();
75 
76  correctQuaternionJoints();
77 
78  // Update the body-state prior to the evaluation of the restraints
79  model_.forwardDynamicsCorrection(state());
80 
81  // Accumulate the restraint forces
82  scalarField rtau(tau);
83  Field<spatialVector> rfx(fx);
84  model_.applyRestraints(rtau, rfx);
85 
86  // Calculate the body acceleration for the given state
87  // and restraint forces
88  model_.forwardDynamics(state(), rtau, rfx);
89 
90  // Second simplectic step:
91  // Complete update of linear and angular velocities
92  qDot() += 0.5*deltaT()*qDdot();
93 }
94 
95 
96 // ************************************************************************* //
addToRunTimeSelectionTable(rigidBodySolver, CrankNicolson, dictionary)
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:137
defineTypeNameAndDebug(CrankNicolson, 0)
symplectic(rigidBodyMotion &body, const dictionary &dict)
Construct for the given body from dictionary.
Definition: symplectic.C:47
virtual ~symplectic()
Destructor.
Definition: symplectic.C:58
Macros for easy insertion into run-time selection tables.
Six degree of freedom motion for a rigid body.
virtual void solve(const scalarField &tau, const Field< spatialVector > &fx)
Integrate the rigid-body motion for one time-step.
Definition: symplectic.C:65
Namespace for OpenFOAM.