46 void Foam::RBD::rigidBodyModel::initializeRootBody()
48 bodies_.append(
new masslessBody(
"root"));
50 bodyIDs_.insert(
"root", 0);
51 joints_.append(
new joints::null(*
this));
52 XT_.append(spatialTransform());
55 unitQuaternions_ =
false;
61 void Foam::RBD::rigidBodyModel::resizeState()
63 Xlambda_.append(spatialTransform());
64 X0_.append(spatialTransform());
82 void Foam::RBD::rigidBodyModel::addRestraints
84 const dictionary& dict
87 if (dict.found(
"restraints"))
89 const dictionary& restraintDict = dict.subDict(
"restraints");
93 restraints_.setSize(restraintDict.size());
112 restraints_.setSize(i);
121 const label parentID,
129 bodies_.append(bodyPtr);
130 const label bodyID = nBodies()-1;
131 bodyIDs_.insert(body.
name(), bodyID);
135 if (merged(parentID))
137 const subBody& sBody = mergedBody(parentID);
143 lambda_.append(parentID);
148 const joint& prevJoint = joints_[joints_.size() - 1];
149 joints_.append(jointPtr);
150 joint& curJoint = joints_[joints_.size() - 1];
151 curJoint.index() = joints_.size() - 1;
152 curJoint.qIndex() = prevJoint.qIndex() + prevJoint.
nDoF();
155 nDoF_ += curJoint.
nDoF();
170 initializeRootBody();
178 initializeRootBody();
186 if (bodyDict.
found(
"mergeWith"))
191 bodyDict.
lookup(
"transform"),
200 bodyDict.
lookup(
"transform"),
222 const label parentID,
228 if (isA<joints::composite>(jointPtr()))
236 dynamic_cast<joints::composite*>(jointPtr.
ptr())
256 const label parentID,
262 label parent = parentID;
289 cJoint.setLastJoint();
295 void Foam::RBD::rigidBodyModel::makeComposite(
const label bodyID)
297 if (!isA<compositeBody>(
bodies_[bodyID]))
314 const label parentID,
343 makeComposite(parentID);
357 const subBody& sBody = sBodyPtr();
394 if (!isType<jointBody>(
bodies_[i]))
396 names[j++] =
bodies_[i].name();
416 if (!isType<jointBody>(
bodies_[i]))
451 os <<
indent <<
"restraints" << nl
Template class for intrusive linked lists.
const subBody & mergedBody(label mergedBodyID) const
Return the merged body for the given body ID.
Abstract base-class for all rigid-body joints.
static autoPtr< rigidBody > New(const word &name, const scalar &m, const vector &c, const symmTensor &Ic)
Select constructed from components.
Ostream & operator<<(Ostream &, const rigidBody &)
bool found(const word &, bool recursive=false, bool patternMatch=true) const
Search dictionary for given keyword.
#define forAll(list, i)
Loop across all elements in list.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Ostream & indent(Ostream &os)
Indent stream.
DynamicList< spatialTransform > X0_
Transform for external forces to the bodies reference frame.
A list of keyword definitions, which are a keyword followed by any number of values (e...
label merge(const label parentID, const spatialTransform &X, autoPtr< rigidBody > bodyPtr)
Merge the given body with transform X into the parent with ID.
const word & name() const
Return name.
Ostream & endl(Ostream &os)
Add newline and flush stream.
static const SpatialTensor I
Identity matrix for square matrices.
T * ptr()
Return object pointer for reuse.
label nBodies() const
Return the number of bodies in the model (bodies().size())
label mergedBodyID(const label mergedBodyIndex) const
Return the merged body ID for the given merged body index.
const word & name() const
Return the body name.
const dictionary & subDict(const word &) const
Find and return a sub-dictionary.
HashTable< label, word > bodyIDs_
Lookup-table of the IDs of the bodies.
Prismatic joint for translation along the specified arbitrary axis.
PtrList< restraint > restraints_
Motion restraints.
PtrList< joint > joints_
Each body it attached with a joint which are held on this list.
PtrList< rigidBody > bodies_
List of the bodies.
This specialized rigidBody holds the original body after it has been merged into a master...
A class for handling words, derived from string.
const word & name(const label bodyID) const
Return the name of body with the given ID.
bool read(const dictionary &dict)
Read coefficients dictionary and update system parameters,.
DynamicList< spatialTransform > XT_
Transform from the parent body frame to the joint frame.
This specialized rigidBody holds the original body after it has been merged into a parent...
defineTypeNameAndDebug(cuboid, 0)
virtual label join(const label parentID, const spatialTransform &XT, autoPtr< joint > jointPtr, autoPtr< rigidBody > bodyPtr)
Join the given body to the parent with ID parentID via the given.
forAllConstIter(PtrDictionary< phaseModel >, mixture.phases(), phase)
virtual void write(Ostream &) const
Write.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
label nDoF() const
Return the number of degrees of freedom in this joint.
DynamicList< label > lambda_
List of indices of the parent of each body.
label masterID() const
Return the master body Id.
void set(T *)
Set pointer to that given.
Ostream & decrIndent(Ostream &os)
Decrement the indent level.
void writeEntry(Ostream &os, const HashTable< T, Key, Hash > &ht)
label size() const
Return the number of elements in the UPtrList.
PtrList< subBody > mergedBodies_
Bodies may be merged into existing bodies, the inertia of which is.
void setSize(const label)
Reset size of List.
wordList movingBodyNames() const
Return the names of the moving bodies.
virtual ~rigidBodyModel()
Destructor.
static autoPtr< joint > New(joint *jointPtr)
Simple selector to return an autoPtr<joint> of the given joint*.
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
label bodyID(const word &name) const
Return the ID of the body with the given name.
Basic rigid-body model representing a system of rigid-bodies connected by 1-6 DoF joints...
spatialTransform X0(const label bodyId) const
Return the current transform to the global frame for the given body.
rigidBodyModel()
Null-constructor which adds the single root-body at the origin.
Ostream & incrIndent(Ostream &os)
Increment the indent level.
virtual label join_(const label parentID, const spatialTransform &XT, autoPtr< joint > jointPtr, autoPtr< rigidBody > bodyPtr)
Join the given body to the parent with ID parentID via the given.
virtual bool unitQuaternion() const
Return true if this joint describes rotation using a quaternion.
bool merged(label bodyID) const
Return true if the body with given ID has been merged with a parent.
static autoPtr< restraint > New(const word &name, const dictionary &dict, const rigidBodyModel &model)
Select constructed from the dict dictionary and Time.
vector g_
Acceleration due to gravity.
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
const spatialTransform & masterXT() const
Return the transform with respect to the master body.