Rzyx.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) 2016-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 "Rzyx.H"
27 #include "rigidBodyModelState.H"
29 
30 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
31 
32 namespace Foam
33 {
34 namespace RBD
35 {
36 namespace joints
37 {
39 
41  (
42  joint,
43  Rzyx,
45  );
46 }
47 }
48 }
49 
50 
51 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
52 
54 :
55  joint(model, 3)
56 {
57  S_[0] = spatialVector(0, 0, 1, 0, 0, 0);
58  S_[1] = spatialVector(0, 1, 0, 0, 0, 0);
59  S_[2] = spatialVector(1, 0, 0, 0, 0, 0);
60 }
61 
62 
64 (
65  const rigidBodyModel& model,
66  const dictionary& dict
67 )
68 :
69  joint(model, 3)
70 {
71  S_[0] = spatialVector(0, 0, 1, 0, 0, 0);
72  S_[1] = spatialVector(0, 1, 0, 0, 0, 0);
73  S_[2] = spatialVector(1, 0, 0, 0, 0, 0);
74 }
75 
76 
78 {
79  return autoPtr<joint>(new Rzyx(*this));
80 }
81 
82 
83 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
84 
86 {}
87 
88 
89 // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
90 
92 (
93  joint::XSvc& J,
94  const rigidBodyModelState& state
95 ) const
96 {
97  vector qj(state.q().block<vector>(qIndex_));
98 
99  scalar s0 = sin(qj.x());
100  scalar c0 = cos(qj.x());
101  scalar s1 = sin(qj.y());
102  scalar c1 = cos(qj.y());
103  scalar s2 = sin(qj.z());
104  scalar c2 = cos(qj.z());
105 
106  J.X.E() = tensor
107  (
108  c0*c1, s0*c1, -s1,
109  c0*s1*s2 - s0*c2, s0*s1*s2 + c0*c2, c1*s2,
110  c0*s1*c2 + s0*s2, s0*s1*c2 - c0*s2, c1*c2
111  );
112  J.X.r() = Zero;
113 
114  J.S = Zero;
115  J.S.xx() = -s1;
116  J.S.xz() = 1;
117  J.S.yx() = c1*s2;
118  J.S.yy() = c2;
119  J.S.zx() = c1*c2;
120  J.S.zy() = -s2;
121 
122  vector qDotj(state.qDot().block<vector>(qIndex_));
123  J.v = J.S & qDotj;
124 
125  J.c = spatialVector
126  (
127  -c1*qDotj.x()*qDotj.y(),
128 
129  -s1*s2*qDotj.x()*qDotj.y()
130  + c1*c2*qDotj.x()*qDotj.z()
131  - s2*qDotj.y()*qDotj.z(),
132 
133  -s1*c2*qDotj.x()*qDotj.y()
134  - c1*s2*qDotj.x()*qDotj.z()
135  - c2*qDotj.y()*qDotj.z(),
136 
137  0,
138  0,
139  0
140  );
141 }
142 
143 
144 // ************************************************************************* //
Macros for easy insertion into run-time selection tables.
VSForm block(const label start) const
Definition: Field.C:503
const Cmpt & xx() const
Definition: MatrixSpaceI.H:148
const Cmpt & yx() const
Definition: MatrixSpaceI.H:190
const Cmpt & xz() const
Definition: MatrixSpaceI.H:176
const Cmpt & zx() const
Definition: MatrixSpaceI.H:232
const Cmpt & zy() const
Definition: MatrixSpaceI.H:246
const Cmpt & yy() const
Definition: MatrixSpaceI.H:204
Joint state returned by jcalc.
Definition: joint.H:124
spatialVector c
The constrained joint acceleration correction.
Definition: joint.H:141
compactSpatialTensor S
The joint motion sub-space (3-DoF)
Definition: joint.H:131
spatialVector v
The constrained joint velocity.
Definition: joint.H:137
spatialTransform X
The joint transformation.
Definition: joint.H:128
Abstract base-class for all rigid-body joints.
Definition: joint.H:81
List< spatialVector > S_
Joint motion sub-space.
Definition: joint.H:91
Spherical joint for rotation about the x/y/z-axes using Euler-angles in the order z,...
Definition: Rzyx.H:64
Rzyx(const rigidBodyModel &model)
Construct for given model.
Definition: Rzyx.C:53
virtual autoPtr< joint > clone() const
Clone this joint.
Definition: Rzyx.C:77
virtual ~Rzyx()
Destructor.
Definition: Rzyx.C:85
virtual void jcalc(joint::XSvc &J, const rigidBodyModelState &state) const
Update the model state for this joint.
Definition: Rzyx.C:92
Holds the motion state of rigid-body model.
const scalarField & qDot() const
Return access to the joint velocity.
const scalarField & q() const
Return access to the joint position and orientation.
Basic rigid-body model representing a system of rigid-bodies connected by 1-6 DoF joints.
const Cmpt & z() const
Definition: VectorI.H:87
const Cmpt & y() const
Definition: VectorI.H:81
const Cmpt & x() const
Definition: VectorI.H:75
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: autoPtr.H:51
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:160
const vector & r() const
Return the translation vector.
const tensor & E() const
Return the rotation tensor.
defineTypeNameAndDebug(composite, 0)
addToRunTimeSelectionTable(joint, composite, dictionary)
const dimensionedScalar c1
First radiation constant: default SI units: [W/m^2].
const dimensionedScalar c2
Second radiation constant: default SI units: [m K].
Namespace for OpenFOAM.
static const zero Zero
Definition: zero.H:97
Tensor< scalar > tensor
Tensor of scalars.
Definition: tensor.H:51
dimensionedScalar sin(const dimensionedScalar &ds)
SpatialVector< scalar > spatialVector
SpatialVector of scalars.
Definition: spatialVector.H:47
dimensionedScalar cos(const dimensionedScalar &ds)
dictionary dict