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) 2015 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 sixDoFSolvers
34 {
35  defineTypeNameAndDebug(symplectic, 0);
36  addToRunTimeSelectionTable(sixDoFSolver, symplectic, dictionary);
37 }
38 }
39 
40 
41 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
42 
44 (
45  const dictionary& dict,
47 )
48 :
49  sixDoFSolver(body)
50 {}
51 
52 
53 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
54 
56 {}
57 
58 
59 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
60 
62 (
63  bool firstIter,
64  const vector& fGlobal,
65  const vector& tauGlobal,
66  scalar deltaT,
67  scalar deltaT0
68 )
69 {
70  if (!firstIter)
71  {
72  FatalErrorIn("sixDoFSolvers::symplectic::solve")
73  << "The symplectic integrator is explicit "
74  "and can only be solved once per time-step"
75  << exit(FatalError);
76  }
77 
78  // First simplectic step:
79  // Half-step for linear and angular velocities
80  // Update position and orientation
81 
82  v() = tConstraints() & (v0() + aDamp()*0.5*deltaT0*a0());
83  pi() = rConstraints() & (pi0() + aDamp()*0.5*deltaT0*tau0());
84 
85  centreOfRotation() = centreOfRotation0() + deltaT*v();
86 
87  Tuple2<tensor, vector> Qpi = rotate(Q0(), pi(), deltaT);
88  Q() = Qpi.first();
89  pi() = rConstraints() & Qpi.second();
90 
91  // Update the linear acceleration and torque
92  updateAcceleration(fGlobal, tauGlobal);
93 
94  // Second simplectic step:
95  // Complete update of linear and angular velocities
96 
97  v() += tConstraints() & aDamp()*0.5*deltaT*a();
98  pi() += rConstraints() & aDamp()*0.5*deltaT*tau();
99 }
100 
101 
102 // ************************************************************************* //
const Type2 & second() const
Return second.
Definition: Tuple2.H:106
A 2-tuple for storing two objects of different types.
Definition: Tuple2.H:47
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
const Type1 & first() const
Return first.
Definition: Tuple2.H:94
defineTypeNameAndDebug(CrankNicolson, 0)
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:137
Namespace for OpenFOAM.
addToRunTimeSelectionTable(sixDoFSolver, CrankNicolson, dictionary)
const dimensionedScalar a0
Bohr radius: default SI units: [m].
symplectic(const dictionary &dict, sixDoFRigidBodyMotion &body)
Construct from a dictionary and the body.
Definition: symplectic.C:44
Macros for easy insertion into run-time selection tables.
virtual ~symplectic()
Destructor.
Definition: symplectic.C:55
#define FatalErrorIn(functionName)
Report an error message using Foam::FatalError.
Definition: error.H:314
error FatalError
virtual void solve(bool firstIter, const vector &fGlobal, const vector &tauGlobal, scalar deltaT, scalar deltaT0)
Drag coefficient.
Definition: symplectic.C:62
Six degree of freedom motion for a rigid body.
This function object calculates and outputs the second invariant of the velocity gradient tensor [1/s...
Definition: Q.H:66