prescribedRotation.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2021 OpenCFD Ltd.
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 Class
27  Foam::RBD::restraints::prescribedRotation
28 
29 Group
30  grpRigidBodyDynamicsRestraints
31 
32 Description
33  Restraint setting angular velocity of the rigid body.
34  Developed from the linear axial angular spring restraint.
35 
36  Adds a rotation along given axis to the body.
37  Used for a combination of 6DOF bodies where one is driven by 6DOF and
38  the other attached to it using specified rotation
39  in the local reference frame.
40 
41 Usage
42  \table
43  Property | Description | Required | Default value
44  referenceOrientation | Orientation | no | I
45  axis | Rotation axis (in reference) | yes |
46  omega | Angular velocity (rad/s) | yes |
47  relax | Relax moment with previous iter | yes
48  p | Propoptional corrector for PDI | yes
49  d | Differential corrector for PDI | yes
50  i | Integral corrector for PDI | yes
51  \endtable
52 
53 SourceFiles
54  prescribedRotation.C
55 
56 \*---------------------------------------------------------------------------*/
57 
58 #ifndef prescribedRotation_H
59 #define prescribedRotation_H
60 
61 #include "rigidBodyRestraint.H"
62 #include "Function1.H"
63 
64 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
65 
66 namespace Foam
67 {
68 namespace RBD
69 {
70 namespace restraints
71 {
72 
73 /*---------------------------------------------------------------------------*\
74  Class prescribedRotation Declaration
75 \*---------------------------------------------------------------------------*/
76 
77 class prescribedRotation
78 :
79  public restraint
80 {
81  // Private data
82 
83  //- Reference orientation where there is no moment
84  tensor refQ_;
85 
86  //- Global unit axis around which the motion is sprung
87  vector axis_;
88 
89  //- Rotational velocity [rad/sec]
90  autoPtr<Function1<vector>> omegaSet_;
91 
92  //- Cache omega
93  mutable vector omega_;
94 
95  //- Cache previous momentum
96  mutable vector oldMom_;
97 
98  //- Relax momentum
99  scalar relax_;
100 
101  //- PID constants
102 
103  mutable vector error0_;
104 
105  mutable vector integral0_;
106 
107  mutable scalar p_;
109  mutable scalar i_;
110 
111  mutable scalar d_;
112 
113 public:
114 
115  //- Runtime type information
116  TypeName("prescribedRotation");
117 
118 
119  // Constructors
120 
121  //- Construct from components
123  (
124  const word& name,
125  const dictionary& dict,
126  const rigidBodyModel& model
127  );
128 
129  //- Construct and return a clone
130  virtual autoPtr<restraint> clone() const
131  {
132  return autoPtr<restraint>
133  (
134  new prescribedRotation(*this)
135  );
136  }
137 
138 
139  //- Destructor
140  virtual ~prescribedRotation();
141 
142 
143  // Member Functions
144 
145  //- Accumulate the retraint internal joint forces into the tau field and
146  // external forces into the fx field
147  virtual void restrain
148  (
149  scalarField& tau,
151  const rigidBodyModelState& state
152  ) const;
153 
154  //- Update properties from given dictionary
155  virtual bool read(const dictionary& dict);
156 
157  //- Write
158  virtual void write(Ostream&) const;
159 };
160 
161 
162 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
163 
164 } // End namespace restraints
165 } // End namespace RBD
166 } // End namespace Foam
167 
168 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
169 
170 #endif
171 
172 // ************************************************************************* //
dictionary dict
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:120
TypeName("prescribedRotation")
Runtime type information.
Tensor< scalar > tensor
Definition: symmTensor.H:57
Holds the motion state of rigid-body model.
const word & name() const
Return the name.
prescribedRotation(const word &name, const dictionary &dict, const rigidBodyModel &model)
Construct from components.
virtual bool read(const dictionary &dict)
Update properties from given dictionary.
A class for handling words, derived from Foam::string.
Definition: word.H:63
virtual void write(Ostream &) const
Write.
Vector< scalar > vector
Definition: vector.H:57
virtual void restrain(scalarField &tau, Field< spatialVector > &fx, const rigidBodyModelState &state) const
Accumulate the retraint internal joint forces into the tau field and.
virtual autoPtr< restraint > clone() const
Construct and return a clone.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:55
Pointer management similar to std::unique_ptr, with some additional methods and type checking...
Definition: HashPtrTable.H:48
Basic rigid-body model representing a system of rigid-bodies connected by 1-6 DoF joints...
Namespace for OpenFOAM.