linearSpring.H
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) 2016-2020 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 Class
25  Foam::RBD::restraints::linearSpring
26 
27 Description
28  Linear spring restraint.
29 
30 SourceFiles
31  linearSpring.C
32 
33 \*---------------------------------------------------------------------------*/
34 
35 #ifndef RBD_restraints_linearSpring_H
36 #define RBD_restraints_linearSpring_H
37 
38 #include "rigidBodyRestraint.H"
39 #include "Switch.H"
40 
41 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
42 
43 namespace Foam
44 {
45 namespace RBD
46 {
47 namespace restraints
48 {
49 
50 /*---------------------------------------------------------------------------*\
51  Class linearSpring Declaration
52 \*---------------------------------------------------------------------------*/
53 
54 class linearSpring
55 :
56  public restraint
57 {
58  // Private Data
59 
60  //- Anchor point, where the spring is attached to an immovable
61  // object
62  point anchor_;
63 
64  //- Reference point of attachment to the solid body
65  point refAttachmentPt_;
66 
67  //- Spring stiffness coefficient [N/m]
68  scalar stiffness_;
69 
70  //- Damping coefficient [Ns/m]
71  scalar damping_;
72 
73  //- Rest length - length of spring when no forces are applied to it
74  scalar restLength_;
75 
76  //- Switch to allow no restraint when line is shorter than restLength
77  Switch allowSlack_;
78 
79 
80 public:
81 
82  //- Runtime type information
83  TypeName("linearSpring");
84 
85 
86  // Constructors
87 
88  //- Construct from components
90  (
91  const word& name,
92  const dictionary& dict,
93  const rigidBodyModel& model
94  );
95 
96  //- Construct and return a clone
97  virtual autoPtr<restraint> clone() const
98  {
99  return autoPtr<restraint>
100  (
101  new linearSpring(*this)
102  );
103  }
104 
105 
106  //- Destructor
107  virtual ~linearSpring();
108 
109 
110  // Member Functions
111 
112  //- Accumulate the retraint internal joint forces into the tau field and
113  // external forces into the fx field
114  virtual void restrain
115  (
116  scalarField& tau,
118  const rigidBodyModelState& state
119  ) const;
120 
121  //- Update properties from given dictionary
122  virtual bool read(const dictionary& dict);
123 
124  //- Write
125  virtual void write(Ostream&) const;
126 };
127 
128 
129 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
130 
131 } // End namespace restraints
132 } // End namespace RBD
133 } // End namespace Foam
134 
135 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
136 
137 #endif
138 
139 // ************************************************************************* //
dictionary dict
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:156
linearSpring(const word &name, const dictionary &dict, const rigidBodyModel &model)
Construct from components.
Definition: linearSpring.C:54
Base class for defining restraints for rigid-body dynamics.
virtual void write(Ostream &) const
Write.
Definition: linearSpring.C:136
virtual bool read(const dictionary &dict)
Update properties from given dictionary.
Definition: linearSpring.C:118
Linear spring restraint.
Definition: linearSpring.H:53
A simple wrapper around bool so that it can be read as a word: true/false, on/off, yes/no, y/n, t/f, or none/any.
Definition: Switch.H:60
TypeName("linearSpring")
Runtime type information.
Holds the motion state of rigid-body model.
virtual autoPtr< restraint > clone() const
Construct and return a clone.
Definition: linearSpring.H:96
const word & name() const
Return the name.
A class for handling words, derived from string.
Definition: word.H:59
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:54
virtual void restrain(scalarField &tau, Field< spatialVector > &fx, const rigidBodyModelState &state) const
Accumulate the retraint internal joint forces into the tau field and.
Definition: linearSpring.C:75
virtual ~linearSpring()
Destructor.
Definition: linearSpring.C:68
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:52
Basic rigid-body model representing a system of rigid-bodies connected by 1-6 DoF joints...
Namespace for OpenFOAM.