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