46 void Foam::RBD::rigidBodyModel::initializeRootBody()
48 bodies_.append(
new masslessBody(
"root"));
50 bodyIDs_.insert(
"root", 0);
51 joints_.append(
new joints::null());
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);
123 initializeRootBody();
131 initializeRootBody();
139 if (bodyDict.
found(
"mergeWith"))
144 bodyDict.
lookup(
"transform"),
153 bodyDict.
lookup(
"transform"),
175 const label parentID,
206 curJoint.qIndex() = prevJoint.qIndex() + prevJoint.
nDoF();
220 const label parentID,
226 if (isA<joints::composite>(jointPtr()))
234 dynamic_cast<joints::composite*>(jointPtr.
ptr())
254 const label parentID,
260 label parent = parentID;
287 cJoint.setLastJoint();
293 void Foam::RBD::rigidBodyModel::makeComposite(
const label bodyID)
295 if (!isA<compositeBody>(
bodies_[bodyID]))
312 const label parentID,
341 makeComposite(parentID);
355 const subBody& sBody = sBodyPtr();
395 if (!isType<jointBody>(
bodies_[i]))
436 os <<
indent <<
"restraints" << nl
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 &)
void append(T *)
Append an element at the end of the list.
#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...
const subBody & mergedBody(label mergedBodyID) const
Return the merged body for the given body ID.
label bodyID(const word &name) const
Return the ID of the body with the given name.
label merge(const label parentID, const spatialTransform &X, autoPtr< rigidBody > bodyPtr)
Merge the given body with transform X into the parent with ID.
const dictionary & subDict(const word &) const
Find and return a sub-dictionary.
label masterID() const
Return the master body Id.
Ostream & endl(Ostream &os)
Add newline and flush stream.
const word & name() const
Return name.
bool merged(label bodyID) const
Return true if the body with given ID has been merged with a parent.
static const SpatialTensor I
Identity matrix for square matrices.
T * ptr()
Return object pointer for reuse.
const word & name() const
Return the body name.
label nBodies() const
Return the number of bodies in the model (bodies().size())
HashTable< label, word > bodyIDs_
Lookup-table of the IDs of the bodies.
virtual bool unitQuaternion() const
Return true if this joint describes rotation using a quaternion.
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.
A class for handling words, derived from string.
spatialTransform X0(const label bodyId) const
Return the current transform to the global frame for the given body.
label nDoF_
The number of degrees of freedom of the model.
DynamicList< T, SizeInc, SizeMult, SizeDiv > & append(const T &)
Append an element at the end of the list.
label nDoF() const
Return the number of degrees of freedom in this joint.
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.
bool found(const word &, bool recursive=false, bool patternMatch=true) const
Search dictionary for given keyword.
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)
An Ostream is an abstract base class for all output systems (streams, files, token lists...
virtual void write(Ostream &) const
Write.
DynamicList< label > lambda_
List of indices of the parent of each body.
void set(T *)
Set pointer to that given.
Ostream & decrIndent(Ostream &os)
Decrement the indent level.
Ostream & writeKeyword(const keyType &)
Write the keyword followed by an appropriate indentation.
const spatialTransform & masterXT() const
Return the transform with respect to the master body.
bool unitQuaternions_
True if any of the joints using quaternions.
label mergedBodyID(const label mergedBodyIndex) const
Return the merged body ID for the given merged body index.
PtrList< subBody > mergedBodies_
Bodies may be merged into existing bodies, the inertia of which is.
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...
Basic rigid-body model representing a system of rigid-bodies connected by 1-6 DoF joints...
const word & name(const label bodyID) const
Return the name of body with the given ID.
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.
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.
label size() const
Return the number of elements in the UPtrList.
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.