Loading...
Searching...
No Matches
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 * * * * * * * * * * * * * //
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
61}
62
64inline Foam::label Foam::RBD::rigidBodyModel::nDoF() const
65{
66 return nDoF_;
67}
68
73}
74
77{
78 return g_;
79}
80
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
112Foam::RBD::rigidBodyModel::v(const label i) const
113{
114 return v_[i];
115}
117inline const Foam::spatialVector&
118Foam::RBD::rigidBodyModel::a(const label i) const
119{
120 return a_[i];
121}
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
137 return bodyID;
138 }
139}
140
141
142inline Foam::label
144{
145 return -1 - mergedBodyIndex;
146}
147
148
149inline Foam::label
151{
152 return -1 - mergedBodyID;
153}
154
155
156inline const Foam::RBD::subBody&
157Foam::RBD::rigidBodyModel::mergedBody(label mergedBodyID) const
158{
159 if (!merged(mergedBodyID))
160 {
162 << "Body " << mergedBodyID << " has not been merged"
164 }
165
166 return mergedBodies_[mergedBodyIndex(mergedBodyID)];
167}
168
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:68
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers....
Definition PtrList.H:67
DynamicList< spatialTransform > X0_
Transform for external forces to the bodies reference frame.
const spatialVector & v(const label i) const
Return the spatial velocity of the bodies.
const Time & time_
Reference to time database.
label nBodies() const
Return the number of bodies in the model (bodies().size()).
DynamicList< spatialVector > a_
The spatial acceleration of the bodies.
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.
label master(label bodyID) const
Return the ID of the master body for a sub-body otherwise.
label nDoF_
The number of degrees of freedom of the model.
const spatialVector & a(const label i) const
Return the spatial acceleration of the bodies.
vector masterPoint(const label bodyID, const vector &p) const
PtrList< subBody > mergedBodies_
Bodies may be merged into existing bodies, the inertia of which is.
const subBody & mergedBody(label mergedBodyID) const
Return the merged body for the given body ID.
PtrList< rigidBody > bodies_
List of the bodies.
bool unitQuaternions_
True if any of the joints using quaternions.
const vector & g() const
Return the acceleration due to gravity.
vector g_
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 bodyID(const word &name) const
Return the ID of the body with the given name.
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 word & name(const label bodyID) const
Return the name of body with the given ID.
PtrList< joint > joints_
Each body it attached with a joint which are held on this list.
const PtrList< joint > & joints() const
Return the list of joints in the model.
HashTable< label > bodyIDs_
Lookup-table of the IDs of the bodies.
DynamicList< spatialVector > v_
The spatial velocity of the bodies.
const rigidBodyInertia & I(const label i) const
Return the inertia of body i.
bool merged(label bodyID) const
Return true if the body with given ID has been merged with a parent.
DynamicList< label > lambda_
List of indices of the parent of each body.
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition Time.H:75
Compact representation of the Plücker spatial transformation tensor in terms of the rotation tensor E...
A class for handling words, derived from Foam::string.
Definition word.H:66
volScalarField & p
const volScalarField & T
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition error.H:600
SpatialVector< scalar > spatialVector
SpatialVector of scalars.
errorManip< error > abort(error &err)
Definition errorManip.H:139
static constexpr const zero Zero
Global zero (0).
Definition zero.H:127
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
dimensionedSphericalTensor inv(const dimensionedSphericalTensor &dt)
Vector< scalar > vector
Definition vector.H:57