linearDamper.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) 2013-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 "linearDamper.H"
28 #include "sixDoFRigidBodyMotion.H"
29 
30 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
31 
32 namespace Foam
33 {
34 namespace sixDoFRigidBodyMotionRestraints
35 {
36  defineTypeNameAndDebug(linearDamper, 0);
37 
39  (
40  sixDoFRigidBodyMotionRestraint,
41  linearDamper,
42  dictionary
43  );
44 }
45 }
46 
47 
48 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
49 
51 (
52  const word& name,
53  const dictionary& sDoFRBMRDict
54 )
55 :
56  sixDoFRigidBodyMotionRestraint(name, sDoFRBMRDict),
57  coeff_()
58 {
59  read(sDoFRBMRDict);
60 }
61 
62 
63 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
64 
66 {}
67 
68 
69 // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
70 
72 (
73  const sixDoFRigidBodyMotion& motion,
74  vector& restraintPosition,
75  vector& restraintForce,
76  vector& restraintMoment
77 ) const
78 {
79  restraintForce = -coeff_*motion.v();
80  restraintMoment = Zero;
81 
82  if (motion.report())
83  {
84  Info<< " force " << restraintForce
85  << endl;
86  }
87 }
88 
89 
91 (
92  const dictionary& sDoFRBMRDict
93 )
94 {
96 
97  sDoFRBMRCoeffs_.lookup("coeff") >> coeff_;
98 
99  return true;
100 }
101 
102 
104 (
105  Ostream& os
106 ) const
107 {
108  os.writeKeyword("coeff")
109  << coeff_ << token::END_STATEMENT << nl;
110 }
111 
112 
113 // ************************************************************************* //
Six degree of freedom motion for a rigid body.
bool report() const
Return the report Switch.
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:137
virtual void restrain(const sixDoFRigidBodyMotion &motion, vector &restraintPosition, vector &restraintForce, vector &restraintMoment) const
Calculate the restraint position, force and moment.
Definition: linearDamper.C:72
Base class for defining restraints for sixDoF motions.
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:253
linearDamper(const word &name, const dictionary &sDoFRBMRDict)
Construct from components.
Definition: linearDamper.C:51
virtual bool read(const dictionary &sDoFRBMRCoeff)
Update properties from given dictionary.
Definition: linearDamper.C:91
Macros for easy insertion into run-time selection tables.
bool read(const char *, int32_t &)
Definition: int32IO.C:85
A class for handling words, derived from string.
Definition: word.H:59
virtual bool read(const dictionary &sDoFRBMRDict)
Update properties from given dictionary.
defineTypeNameAndDebug(linearAxialAngularSpring, 0)
static const zero Zero
Definition: zero.H:91
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:53
static const char nl
Definition: Ostream.H:262
Ostream & writeKeyword(const keyType &)
Write the keyword followed by an appropriate indentation.
Definition: Ostream.C:54
addToRunTimeSelectionTable(sixDoFRigidBodyMotionRestraint, linearAxialAngularSpring, dictionary)
messageStream Info
virtual void write(Ostream &) const
Write.
Definition: linearDamper.C:104
Namespace for OpenFOAM.