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),
33 index_(0),
34 qIndex_(0)
35{}
36
37
38// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
39
40inline Foam::label Foam::RBD::joint::nDoF() const
41{
42 return S_.size();
43}
44
46{
47 return false;
48}
49
50inline Foam::label Foam::RBD::joint::index() const
51{
52 return index_;
53}
54
55inline 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,
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
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// ************************************************************************* //
VSForm block(const label start) const
Definition: Field.C:593
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:64
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: List.H:77
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:62
Abstract base-class for all rigid-body joints.
Definition: joint.H:85
virtual void write(Ostream &) const
Write.
Definition: joint.C:84
label nDoF() const
Return the number of degrees of freedom in this joint.
Definition: jointI.H:40
const List< spatialVector > & S() const
Return the joint motion sub-space.
Definition: jointI.H:60
virtual bool unitQuaternion() const
Return true if this joint describes rotation using a quaternion.
Definition: jointI.H:45
const Cmpt & z() const
Access to the vector z component.
Definition: VectorI.H:85
const Cmpt & y() const
Access to the vector y component.
Definition: VectorI.H:79
const Cmpt & x() const
Access to the vector x component.
Definition: VectorI.H:73
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: autoPtr.H:66
virtual word unit() const
Return time unit.
Definition: crankConRod.C:143
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
friend Ostream & operator(Ostream &, const faMatrix< Type > &)
Quaternion class used to perform rotations in 3D space.
Definition: quaternion.H:58
const vector & v() const noexcept
Vector part of the quaternion ( = axis of rotation)
Definition: quaternionI.H:291
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:453
OBJstream os(runTime.globalPath()/outputName)
Ostream & operator<<(Ostream &, const rigidBody &)
Definition: rigidBodyI.H:75
errorManip< error > abort(error &err)
Definition: errorManip.H:144
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh > > &tdf1, const word &name, const dimensionSet &dimensions)
Global function forwards to reuseTmpDimensionedField::New.
error FatalError
dictionary dict