CrankNicolson.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2015-2018 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 "CrankNicolson.H"
28 
29 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
30 
31 namespace Foam
32 {
33 namespace sixDoFSolvers
34 {
37 }
38 }
39 
40 
41 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
42 
44 (
45  const dictionary& dict,
47 )
48 :
49  sixDoFSolver(body),
50  aoc_(dict.lookupOrDefault<scalar>("aoc", 0.5)),
51  voc_(dict.lookupOrDefault<scalar>("voc", 0.5))
52 {}
53 
54 
55 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
56 
58 {}
59 
60 
61 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
62 
64 (
65  bool firstIter,
66  const vector& fGlobal,
67  const vector& tauGlobal,
68  scalar deltaT,
69  scalar deltaT0
70 )
71 {
72  // Update the linear acceleration and torque
73  updateAcceleration(fGlobal, tauGlobal);
74 
75  // Correct linear velocity
76  v() = tConstraints()
77  & (v0() + aDamp()*deltaT*(aoc_*a() + (1 - aoc_)*a0()));
78 
79  // Correct angular momentum
80  pi() = rConstraints()
81  & (pi0() + aDamp()*deltaT*(aoc_*tau() + (1 - aoc_)*tau0()));
82 
83  // Correct position
84  centreOfRotation() =
85  centreOfRotation0() + deltaT*(voc_*v() + (1 - voc_)*v0());
86 
87  // Correct orientation
89  rotate(Q0(), (voc_*pi() + (1 - voc_)*pi0()), deltaT);
90  Q() = Qpi.first();
91 }
92 
93 
94 // ************************************************************************* //
Six degree of freedom motion for a rigid body.
CrankNicolson(const dictionary &dict, sixDoFRigidBodyMotion &body)
Construct from a dictionary and the body.
Definition: CrankNicolson.C:44
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:137
A 2-tuple for storing two objects of different types.
Definition: HashTable.H:66
virtual void solve(bool firstIter, const vector &fGlobal, const vector &tauGlobal, scalar deltaT, scalar deltaT0)
Drag coefficient.
Definition: CrankNicolson.C:64
defineTypeNameAndDebug(CrankNicolson, 0)
Macros for easy insertion into run-time selection tables.
addToRunTimeSelectionTable(sixDoFSolver, CrankNicolson, dictionary)
Crank-Nicolson 2nd-order time-integrator for 6DoF solid-body motion.
Definition: CrankNicolson.H:69
virtual ~CrankNicolson()
Destructor.
Definition: CrankNicolson.C:57
T lookupOrDefault(const word &, const T &, bool recursive=false, bool patternMatch=true) const
Find and return a T,.
const dimensionedScalar a0
Bohr radius: default SI units: [m].
Namespace for OpenFOAM.