rigidBodyModelI.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  Copyright (C) 2019 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 \*---------------------------------------------------------------------------*/
28 
29 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
30 
32 {
33  return time_;
34 }
35 
36 
37 inline Foam::label Foam::RBD::rigidBodyModel::nBodies() const
38 {
39  return bodies_.size();
40 }
41 
42 
45 {
46  return bodies_;
47 }
48 
49 
52 {
53  return lambda_;
54 }
55 
56 
59 {
60  return joints_;
61 }
62 
63 
64 inline Foam::label Foam::RBD::rigidBodyModel::nDoF() const
65 {
66  return nDoF_;
67 }
68 
69 
71 {
72  return unitQuaternions_;
73 }
74 
75 
77 {
78  return g_;
79 }
80 
81 
83 {
84  return g_;
85 }
86 
87 
89 (
90  const label bodyID
91 ) const
92 {
93  if (merged(bodyID))
94  {
95  return mergedBody(bodyID).name();
96  }
97  else
98  {
99  return bodies_[bodyID].name();
100  }
101 }
102 
103 
104 inline const Foam::RBD::rigidBodyInertia&
105 Foam::RBD::rigidBodyModel::I(const label i) const
106 {
107  return bodies_[i];
108 }
109 
110 
111 inline const Foam::spatialVector&
112 Foam::RBD::rigidBodyModel::v(const label i) const
113 {
114  return v_[i];
115 }
116 
117 inline const Foam::spatialVector&
118 Foam::RBD::rigidBodyModel::a(const label i) const
119 {
120  return a_[i];
121 }
122 
123 inline bool Foam::RBD::rigidBodyModel::merged(label bodyID) const
124 {
125  return bodyID < 0;
126 }
127 
128 
129 inline Foam::label Foam::RBD::rigidBodyModel::master(label bodyID) const
130 {
131  if (bodyID < 0)
132  {
133  return mergedBody(bodyID).masterID();
134  }
135  else
136  {
137  return bodyID;
138  }
139 }
140 
141 
142 inline Foam::label
143 Foam::RBD::rigidBodyModel::mergedBodyID(const label mergedBodyIndex) const
144 {
145  return -1 - mergedBodyIndex;
146 }
147 
148 
149 inline Foam::label
150 Foam::RBD::rigidBodyModel::mergedBodyIndex(const label mergedBodyID) const
151 {
152  return -1 - mergedBodyID;
153 }
154 
155 
156 inline const Foam::RBD::subBody&
157 Foam::RBD::rigidBodyModel::mergedBody(label mergedBodyID) const
158 {
159  if (!merged(mergedBodyID))
160  {
162  << "Body " << mergedBodyID << " has not been merged"
163  << abort(FatalError);
164  }
165 
166  return mergedBodies_[mergedBodyIndex(mergedBodyID)];
167 }
168 
169 
170 inline Foam::label Foam::RBD::rigidBodyModel::bodyID(const word& name) const
171 {
172  return bodyIDs_[name];
173 }
174 
175 
177 (
178  const label bodyID,
179  const vector& p
180 ) const
181 {
182  if (merged(bodyID))
183  {
184  return
185  (
186  mergedBody(bodyID).masterXT().inv()
187  && spatialVector(Zero, p)
188  ).l();
189  }
190  else
191  {
192  return p;
193  }
194 }
195 
196 
198 (
199  const label bodyID,
200  const vector& p
201 ) const
202 {
203  return
204  (
206  (
207  X0_[master(bodyID)].E().T(),
208  masterPoint(bodyID, p)
209  )
210  & v_[master(bodyID)]
211  );
212 }
213 
214 
215 // ************************************************************************* //
p
volScalarField & p
Definition: createFieldRefs.H:8
Foam::Time
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:73
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
Foam::RBD::rigidBodyModel::nBodies
label nBodies() const
Return the number of bodies in the model (bodies().size())
Definition: rigidBodyModelI.H:37
Foam::RBD::rigidBodyModel::merged
bool merged(label bodyID) const
Return true if the body with given ID has been merged with a parent.
Definition: rigidBodyModelI.H:123
Foam::spatialTransform
Compact representation of the Pl├╝cker spatial transformation tensor in terms of the rotation tensor E...
Definition: spatialTransform.H:70
Foam::Zero
static constexpr const zero Zero
Global zero (0)
Definition: zero.H:131
Foam::DynamicList
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
Definition: DynamicList.H:55
Foam::RBD::rigidBodyModel::I
const rigidBodyInertia & I(const label i) const
Return the inertia of body i.
Definition: rigidBodyModelI.H:105
Foam::RBD::rigidBodyModel::mergedBodyIndex
label mergedBodyIndex(const label mergedBodyID) const
Return the index of the merged body in the mergedBody list.
Definition: rigidBodyModelI.H:150
Foam::RBD::rigidBodyModel::v
const spatialVector & v(const label i) const
Return the spatial velocity of the bodies.
Definition: rigidBodyModelI.H:112
Foam::RBD::rigidBodyModel::joints
const PtrList< joint > & joints() const
Return the list of joints in the model.
Definition: rigidBodyModelI.H:58
Foam::RBD::rigidBodyModel::a
const spatialVector & a(const label i) const
Return the spatial acceleration of the bodies.
Definition: rigidBodyModelI.H:118
Foam::inv
dimensionedSphericalTensor inv(const dimensionedSphericalTensor &dt)
Definition: dimensionedSphericalTensor.C:73
Foam::RBD::rigidBodyModel::time
const Time & time() const
Return the time.
Definition: rigidBodyModelI.H:31
Foam::RBD::rigidBodyModel::mergedBodyID
label mergedBodyID(const label mergedBodyIndex) const
Return the merged body ID for the given merged body index.
Definition: rigidBodyModelI.H:143
Foam::T
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
Definition: FieldFieldFunctions.C:58
Foam::SpatialVector< scalar >
Foam::PtrList< Foam::RBD::rigidBody >
Foam::RBD::subBody
Definition: subBody.H:57
Foam::RBD::rigidBodyModel::master
label master(label bodyID) const
Return the ID of the master body for a sub-body otherwise.
Definition: rigidBodyModelI.H:129
Foam::FatalError
error FatalError
Foam::RBD::rigidBodyModel::bodyID
label bodyID(const word &name) const
Return the ID of the body with the given name.
Definition: rigidBodyModelI.H:170
Foam::abort
errorManip< error > abort(error &err)
Definition: errorManip.H:144
Foam::RBD::rigidBodyModel::lambda
const DynamicList< label > & lambda() const
List of indices of the parent of each body.
Definition: rigidBodyModelI.H:51
Foam::RBD::rigidBodyModel::time_
const Time & time_
Reference to time database.
Definition: rigidBodyModel.H:103
Foam::RBD::rigidBodyModel::name
const word & name(const label bodyID) const
Return the name of body with the given ID.
Definition: rigidBodyModelI.H:89
Foam::RBD::rigidBodyModel::masterPoint
vector masterPoint(const label bodyID, const vector &p) const
Definition: rigidBodyModelI.H:177
FatalErrorInFunction
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:453
Foam::Vector< scalar >
Foam::RBD::rigidBodyModel::unitQuaternions
bool unitQuaternions() const
Return true if any of the joints using quaternions.
Definition: rigidBodyModelI.H:70
Foam::RBD::rigidBodyModel::mergedBody
const subBody & mergedBody(label mergedBodyID) const
Return the merged body for the given body ID.
Definition: rigidBodyModelI.H:157
Foam::name
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
Definition: exprTraits.C:59
Foam::RBD::rigidBodyModel::g
const vector & g() const
Return the acceleration due to gravity.
Definition: rigidBodyModelI.H:76
Foam::spatialVector
SpatialVector< scalar > spatialVector
SpatialVector of scalars.
Definition: spatialVector.H:50
Foam::RBD::rigidBodyModel::nDoF
label nDoF() const
Return the number of degrees of freedom of the model.
Definition: rigidBodyModelI.H:64
Foam::RBD::rigidBodyModel::bodies
PtrList< rigidBody > bodies() const
Return the list of the bodies in the model.
Definition: rigidBodyModelI.H:44
Foam::RBD::rigidBodyInertia
Definition: rigidBodyInertia.H:77