rigidBodyModel: Added movingBodyNames() member function

which returns the list of names of the moving bodies in the model.
This commit is contained in:
Henry Weller
2019-03-01 13:47:22 +00:00
parent e68246b392
commit b294ab1d7c
2 changed files with 23 additions and 1 deletions

View File

@ -384,6 +384,25 @@ Foam::spatialTransform Foam::RBD::rigidBodyModel::X0
}
Foam::wordList Foam::RBD::rigidBodyModel::movingBodyNames() const
{
wordList names(nBodies());
label j = 0;
for (label i=1; i<nBodies(); i++)
{
if (!isType<jointBody>(bodies_[i]))
{
names[j++] = bodies_[i].name();
}
}
names.setSize(j);
return names;
}
void Foam::RBD::rigidBodyModel::write(Ostream& os) const
{
os << indent << "bodies" << nl

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2016-2018 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2016-2019 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -252,6 +252,9 @@ public:
//- Return the name of body with the given ID
inline const word& name(const label bodyID) const;
//- Return the names of the moving bodies
wordList movingBodyNames() const;
//- Return the inertia of body i
inline const rigidBodyInertia& I(const label i) const;