Loading...
Searching...
No Matches
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-------------------------------------------------------------------------------
10License
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
30inline Foam::RBD::joint::joint(const label nDoF)
31:
32 S_(nDoF),
34 qIndex_(0)
35{}
36
37
38// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
39
40inline Foam::label Foam::RBD::joint::nDoF() const
41{
42 return S_.size();
44
45inline bool Foam::RBD::joint::unitQuaternion() const
46{
47 return false;
49
50inline Foam::label Foam::RBD::joint::index() const
51{
52 return index_;
54
55inline Foam::label Foam::RBD::joint::qIndex() const
56{
57 return qIndex_;
58}
59
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"
78 }
79
80 return quaternion::unit(q.block<vector>(qIndex_));
81}
82
83
85(
86 const quaternion& quat,
88) const
89{
90 if (!unitQuaternion())
91 {
93 << "Attempt to set quaternion for a non-spherical joint"
94 << abort(FatalError);
95 }
97 q[qIndex_] = quat.v().x();
98 q[qIndex_+1] = quat.v().y();
99 q[qIndex_+2] = quat.v().z();
100}
101
102
103Foam::autoPtr<Foam::RBD::joint> Foam::RBD::joint::iNew::operator()
104(
105 Istream& is
106) const
107{
109 return New(dict);
110}
111
112
113// * * * * * * * * * * * * * * * Ostream Operator * * * * * * * * * * * * * //
114
115inline Foam::Ostream& Foam::RBD::operator<<(Ostream& os, const joint& j)
116{
117 os.beginBlock();
118 j.write(os);
119 os.endBlock();
120
121 return os;
122}
123
124
125// ************************************************************************* //
VSForm block(const label start) const
Definition Field.C:733
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition Istream.H:60
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition List.H:72
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition Ostream.H:59
Abstract base-class for all rigid-body joints.
Definition joint.H:82
List< spatialVector > S_
Joint motion sub-space.
Definition joint.H:91
virtual void write(Ostream &) const
Write.
Definition joint.C:77
label qIndex_
Index of this joints data in the rigidBodyModel state.
Definition joint.H:101
label nDoF() const
Return the number of degrees of freedom in this joint.
Definition jointI.H:33
label qIndex() const
Return start index for the state variables for this joint.
Definition jointI.H:48
const List< spatialVector > & S() const
Return the joint motion sub-space.
Definition jointI.H:53
label index() const
Return the index of this joint in the model.
Definition jointI.H:43
virtual bool unitQuaternion() const
Return true if this joint describes rotation using a quaternion.
Definition jointI.H:38
label index_
Index of this joint in the rigidBodyModel.
Definition joint.H:96
joint(const label nDoF)
Construct joint setting the size of the motion sub-space.
Definition jointI.H:23
const Cmpt & x() const noexcept
Access to the vector x component.
Definition Vector.H:135
const Cmpt & z() const noexcept
Access to the vector z component.
Definition Vector.H:145
const Cmpt & y() const noexcept
Access to the vector y component.
Definition Vector.H:140
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition autoPtr.H:65
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition dictionary.H:133
Quaternion class used to perform rotations in 3D space.
Definition quaternion.H:54
const vector & v() const noexcept
Vector part of the quaternion ( = axis of rotation).
static quaternion unit(const vector &v)
Return the unit quaternion (versor) from the given vector (w = sqrt(1 - |sqr(v)|)).
Definition quaternionI.H:80
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition error.H:600
OBJstream os(runTime.globalPath()/outputName)
Ostream & operator<<(Ostream &, const rigidBody &)
Definition rigidBodyI.H:68
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh > > &tf1, const word &name, const dimensionSet &dimensions, const bool initCopy=false)
Global function forwards to reuseTmpDimensionedField::New.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
errorManip< error > abort(error &err)
Definition errorManip.H:139
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
Vector< scalar > vector
Definition vector.H:57
dictionary dict