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 | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2016 OpenFOAM Foundation
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 \*---------------------------------------------------------------------------*/
27 
28 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
29 
30 inline Foam::RBD::joint::joint(const label nDoF)
31 :
32  S_(nDoF),
33  index_(0),
34  qIndex_(0)
35 {}
36 
37 
38 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
39 
40 inline Foam::label Foam::RBD::joint::nDoF() const
41 {
42  return S_.size();
43 }
44 
46 {
47  return false;
48 }
49 
50 inline Foam::label Foam::RBD::joint::index() const
51 {
52  return index_;
53 }
54 
55 inline Foam::label Foam::RBD::joint::qIndex() const
56 {
57  return qIndex_;
58 }
59 
61 {
62  return S_;
63 }
64 
65 
66 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
67 
69 (
70  const scalarField& q
71 ) const
72 {
73  if (!unitQuaternion())
74  {
76  << "Attempt to get the quaternion for a non-spherical joint"
77  << abort(FatalError);
78  }
79 
80  return quaternion::unit(q.block<vector>(qIndex_));
81 }
82 
83 
85 (
86  const quaternion& quat,
87  scalarField& q
88 ) const
89 {
90  if (!unitQuaternion())
91  {
93  << "Attempt to set quaternion for a non-spherical joint"
94  << abort(FatalError);
95  }
96 
97  q[qIndex_] = quat.v().x();
98  q[qIndex_+1] = quat.v().y();
99  q[qIndex_+2] = quat.v().z();
100 }
101 
102 
103 Foam::autoPtr<Foam::RBD::joint> Foam::RBD::joint::iNew::operator()
104 (
105  Istream& is
106 ) const
107 {
108  dictionary dict(is);
109  return New(dict);
110 }
111 
112 
113 // * * * * * * * * * * * * * * * Ostream Operator * * * * * * * * * * * * * //
114 
116 {
117  os.beginBlock();
118  j.write(os);
119  os.endBlock();
120 
121  return os;
122 }
123 
124 
125 // ************************************************************************* //
Foam::RBD::joint::write
virtual void write(Ostream &) const
Write.
Definition: joint.C:84
Foam::Vector::x
const Cmpt & x() const
Access to the vector x component.
Definition: VectorI.H:73
Foam::RBD::joint::nDoF
label nDoF() const
Return the number of degrees of freedom in this joint.
Definition: jointI.H:40
Foam::quaternion::v
const vector & v() const
Vector part of the quaternion ( = axis of rotation)
Definition: quaternionI.H:291
Foam::RBD::joint::joint
joint(const label nDoF)
Construct joint setting the size of the motion sub-space.
Definition: jointI.H:30
Foam::Vector::z
const Cmpt & z() const
Access to the vector z component.
Definition: VectorI.H:85
Foam::RBD::operator<<
Ostream & operator<<(Ostream &, const rigidBody &)
Definition: rigidBodyI.H:75
Foam::quaternion
Quaternion class used to perform rotations in 3D space.
Definition: quaternion.H:56
Foam::Field< scalar >
Foam::Istream
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:61
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::FatalError
error FatalError
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:123
os
OBJstream os(runTime.globalPath()/outputName)
Foam::quaternion::unit
static quaternion unit(const vector &v)
Definition: quaternionI.H:87
Foam::abort
errorManip< error > abort(error &err)
Definition: errorManip.H:144
Foam::New
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh >> &tdf1, const word &name, const dimensionSet &dimensions)
Global function forwards to reuseTmpDimensionedField::New.
Definition: DimensionedFieldReuseFunctions.H:105
Foam::autoPtr
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: HashPtrTable.H:53
Foam::Vector::y
const Cmpt & y() const
Access to the vector y component.
Definition: VectorI.H:79
FatalErrorInFunction
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:453
Foam::Vector< scalar >
Foam::List
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: BitOps.H:63
Foam::Field::block
VSForm block(const label start) const
Definition: Field.C:587
Foam::RBD::joint
Abstract base-class for all rigid-body joints.
Definition: joint.H:84
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
Foam::RBD::joint::S
const List< spatialVector > & S() const
Return the joint motion sub-space.
Definition: jointI.H:60
Foam::RBD::joint::unitQuaternion
virtual bool unitQuaternion() const
Return true if this joint describes rotation using a quaternion.
Definition: jointI.H:45