Newmark.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 "Newmark.H"
28 
29 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
30 
31 namespace Foam
32 {
33 namespace RBD
34 {
35 namespace rigidBodySolvers
36 {
37  defineTypeNameAndDebug(Newmark, 0);
38  addToRunTimeSelectionTable(rigidBodySolver, Newmark, dictionary);
39 }
40 }
41 }
42 
43 
44 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
45 
47 (
48  rigidBodyMotion& body,
49  const dictionary& dict
50 )
51 :
52  rigidBodySolver(body),
53  gamma_(dict.lookupOrDefault<scalar>("gamma", 0.5)),
54  beta_
55  (
56  max
57  (
58  0.25*sqr(gamma_ + 0.5),
59  dict.lookupOrDefault<scalar>("beta", 0.25)
60  )
61  )
62 {}
63 
64 
65 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
66 
68 {}
69 
70 
71 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
72 
74 (
75  const scalarField& tau,
76  const Field<spatialVector>& fx
77 )
78 {
79  // Accumulate the restraint forces
80  scalarField rtau(tau);
81  Field<spatialVector> rfx(fx);
82  model_.applyRestraints(rtau, rfx);
83 
84  // Calculate the accelerations for the given state and forces
85  model_.forwardDynamics(state(), rtau, rfx);
86 
87  // Correct velocity
88  qDot() = qDot0()
89  + deltaT()*(gamma_*qDdot() + (1 - gamma_)*qDdot0());
90 
91  // Correct position
92  q() = q0()
93  + deltaT()*qDot0()
94  + sqr(deltaT())*(beta_*qDdot() + (0.5 - beta_)*qDdot0());
95 
96  correctQuaternionJoints();
97 }
98 
99 
100 // ************************************************************************* //
addToRunTimeSelectionTable(rigidBodySolver, CrankNicolson, dictionary)
virtual ~Newmark()
Destructor.
Definition: Newmark.C:67
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:137
dimensioned< Type > max(const dimensioned< Type > &, const dimensioned< Type > &)
dimensionedSymmTensor sqr(const dimensionedVector &dv)
Newmark(rigidBodyMotion &body, const dictionary &dict)
Construct for the given body from dictionary.
Definition: Newmark.C:47
defineTypeNameAndDebug(CrankNicolson, 0)
Macros for easy insertion into run-time selection tables.
Six degree of freedom motion for a rigid body.
T lookupOrDefault(const word &, const T &, bool recursive=false, bool patternMatch=true) const
Find and return a T,.
Namespace for OpenFOAM.
virtual void solve(const scalarField &tau, const Field< spatialVector > &fx)
Integrate the rigid-body motion for one time-step.
Definition: Newmark.C:74