From b294ab1d7ccbfcfe1479cc18f461a85be4d8d845 Mon Sep 17 00:00:00 2001 From: Henry Weller Date: Fri, 1 Mar 2019 13:47:22 +0000 Subject: [PATCH] rigidBodyModel: Added movingBodyNames() member function which returns the list of names of the moving bodies in the model. --- .../rigidBodyModel/rigidBodyModel.C | 19 +++++++++++++++++++ .../rigidBodyModel/rigidBodyModel.H | 5 ++++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/src/rigidBodyDynamics/rigidBodyModel/rigidBodyModel.C b/src/rigidBodyDynamics/rigidBodyModel/rigidBodyModel.C index c29efdb7ea..07a1975082 100644 --- a/src/rigidBodyDynamics/rigidBodyModel/rigidBodyModel.C +++ b/src/rigidBodyDynamics/rigidBodyModel/rigidBodyModel.C @@ -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(bodies_[i])) + { + names[j++] = bodies_[i].name(); + } + } + + names.setSize(j); + + return names; +} + + void Foam::RBD::rigidBodyModel::write(Ostream& os) const { os << indent << "bodies" << nl diff --git a/src/rigidBodyDynamics/rigidBodyModel/rigidBodyModel.H b/src/rigidBodyDynamics/rigidBodyModel/rigidBodyModel.H index 7a749d9f41..ac36c7e765 100644 --- a/src/rigidBodyDynamics/rigidBodyModel/rigidBodyModel.H +++ b/src/rigidBodyDynamics/rigidBodyModel/rigidBodyModel.H @@ -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;