jointI.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 | 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 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
27 
28 inline Foam::RBD::joint::joint(const label nDoF)
29 :
30  S_(nDoF),
31  index_(0),
32  qIndex_(0)
33 {}
34 
35 
36 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
37 
39 {
40  return S_.size();
41 }
42 
44 {
45  return false;
46 }
47 
48 inline Foam::label Foam::RBD::joint::index() const
49 {
50  return index_;
51 }
52 
53 inline Foam::label Foam::RBD::joint::qIndex() const
54 {
55  return qIndex_;
56 }
57 
59 {
60  return S_;
61 }
62 
63 
64 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
65 
67 (
68  const scalarField& q
69 ) const
70 {
71  if (!unitQuaternion())
72  {
74  << "Attempt to get the quaternion for a non-spherical joint"
75  << abort(FatalError);
76  }
77 
79 }
80 
81 
83 (
84  const quaternion& quat,
85  scalarField& q
86 ) const
87 {
88  if (!unitQuaternion())
89  {
91  << "Attempt to set quaternion for a non-spherical joint"
92  << abort(FatalError);
93  }
94 
95  q[qIndex_] = quat.v().x();
96  q[qIndex_+1] = quat.v().y();
97  q[qIndex_+2] = quat.v().z();
98 }
99 
100 
101 Foam::autoPtr<Foam::RBD::joint> Foam::RBD::joint::iNew::operator()
102 (
103  Istream& is
104 ) const
105 {
106  dictionary dict(is);
107  return New(dict);
108 }
109 
110 
111 // * * * * * * * * * * * * * * * Ostream Operator * * * * * * * * * * * * * //
112 
114 {
115  os << indent << token::BEGIN_BLOCK << incrIndent << endl;
116  j.write(os);
117  os << decrIndent << indent << token::END_BLOCK;
118 
119  return os;
120 }
121 
122 
123 // ************************************************************************* //
const List< spatialVector > & S() const
Return the joint motion sub-space.
Definition: jointI.H:58
Abstract base-class for all rigid-body joints.
Definition: joint.H:79
Ostream & operator<<(Ostream &, const rigidBody &)
Definition: rigidBodyI.H:73
const Cmpt & z() const
Definition: VectorI.H:87
dictionary dict
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
Ostream & indent(Ostream &os)
Indent stream.
Definition: Ostream.H:223
const vector & v() const
Vector part of the quaternion ( = axis of rotation)
Definition: quaternionI.H:260
const Cmpt & x() const
Definition: VectorI.H:75
error FatalError
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:137
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:319
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: HashTable.H:59
label qIndex_
Index of this joints data in the rigidBodyModel state.
Definition: joint.H:93
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
Definition: Istream.H:57
static quaternion unit(const vector &v)
Return the unit quaternion (versor) from the given vector.
Definition: quaternionI.H:81
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:253
label index_
Index of this joint in the rigidBodyModel.
Definition: joint.H:90
virtual bool unitQuaternion() const
Return true if this joint describes rotation using a quaternion.
Definition: jointI.H:43
VSForm block(const label start) const
Definition: Field.C:698
const Cmpt & y() const
Definition: VectorI.H:81
label nDoF() const
Return the number of degrees of freedom in this joint.
Definition: jointI.H:38
Quaternion class used to perform rotations in 3D space.
Definition: quaternion.H:60
errorManip< error > abort(error &err)
Definition: errorManip.H:131
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:53
List< spatialVector > S_
Joint motion sub-space.
Definition: joint.H:87
Ostream & decrIndent(Ostream &os)
Decrement the indent level.
Definition: Ostream.H:237
virtual void write(Ostream &) const
Write.
Definition: joint.C:81
joint(const label nDoF)
Construct joint setting the size of the motion sub-space.
Definition: jointI.H:28
static autoPtr< joint > New(joint *jointPtr)
Simple selector to return an autoPtr<joint> of the given joint*.
Definition: joint.C:43
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:53
Ostream & incrIndent(Ostream &os)
Increment the indent level.
Definition: Ostream.H:230