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-------------------------------------------------------------------------------
11License
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
37inline 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
64inline 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
104inline const Foam::RBD::rigidBodyInertia&
106{
107 return bodies_[i];
108}
109
110
111inline const Foam::spatialVector&
113{
114 return v_[i];
115}
116
117inline const Foam::spatialVector&
119{
120 return a_[i];
121}
122
123inline bool Foam::RBD::rigidBodyModel::merged(label bodyID) const
124{
125 return bodyID < 0;
126}
127
128
129inline 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
142inline Foam::label
143Foam::RBD::rigidBodyModel::mergedBodyID(const label mergedBodyIndex) const
144{
145 return -1 - mergedBodyIndex;
146}
147
148
149inline Foam::label
150Foam::RBD::rigidBodyModel::mergedBodyIndex(const label mergedBodyID) const
151{
152 return -1 - mergedBodyID;
153}
154
155
156inline const Foam::RBD::subBody&
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
170inline 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// ************************************************************************* //
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
Definition: DynamicList.H:72
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers....
Definition: PtrList.H:73
spatialVector v
The constrained joint velocity.
Definition: joint.H:138
const Time & time_
Reference to time database.
label nBodies() const
Return the number of bodies in the model (bodies().size())
const Time & time() const
Return the time.
label mergedBodyID(const label mergedBodyIndex) const
Return the merged body ID for the given merged body index.
bool unitQuaternions() const
Return true if any of the joints using quaternions.
vector masterPoint(const label bodyID, const vector &p) const
const subBody & mergedBody(label mergedBodyID) const
Return the merged body for the given body ID.
const vector & g() const
Return the acceleration due to gravity.
label nDoF() const
Return the number of degrees of freedom of the model.
PtrList< rigidBody > bodies() const
Return the list of the bodies in the model.
label mergedBodyIndex(const label mergedBodyID) const
Return the index of the merged body in the mergedBody list.
const DynamicList< label > & lambda() const
List of indices of the parent of each body.
const PtrList< joint > & joints() const
Return the list of joints in the model.
bool merged(label bodyID) const
Return true if the body with given ID has been merged with a parent.
const STLpoint & a() const
Definition: STLtriangleI.H:68
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:80
Compact representation of the Pl├╝cker spatial transformation tensor in terms of the rotation tensor E...
splitCell * master() const
Definition: splitCell.H:113
static const vectorTensorTransform I
A class for handling words, derived from Foam::string.
Definition: word.H:68
volScalarField & p
const volScalarField & T
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:453
SpatialVector< scalar > spatialVector
SpatialVector of scalars.
Definition: spatialVector.H:50
errorManip< error > abort(error &err)
Definition: errorManip.H:144
static constexpr const zero Zero
Global zero (0)
Definition: zero.H:131
error FatalError
dimensionedSphericalTensor inv(const dimensionedSphericalTensor &dt)
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
Definition: exprTraits.C:59