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; diff --git a/src/rigidBodyMeshMotion/rigidBodyMeshMotion/rigidBodyMeshMotion.C b/src/rigidBodyMeshMotion/rigidBodyMeshMotion/rigidBodyMeshMotion.C index db91877a0c..43690cfcc8 100644 --- a/src/rigidBodyMeshMotion/rigidBodyMeshMotion/rigidBodyMeshMotion.C +++ b/src/rigidBodyMeshMotion/rigidBodyMeshMotion/rigidBodyMeshMotion.C @@ -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 @@ -88,7 +88,7 @@ Foam::rigidBodyMeshMotion::rigidBodyMeshMotion ) : displacementMotionSolver(mesh, dict, typeName), - model_ + RBD::rigidBodyMotion ( coeffDict(), IOobject @@ -141,7 +141,7 @@ Foam::rigidBodyMeshMotion::rigidBodyMeshMotion if (bodyDict.found("patches")) { - const label bodyID = model_.bodyID(iter().keyword()); + const label bodyID = this->bodyID(iter().keyword()); if (bodyID == -1) { @@ -239,7 +239,7 @@ void Foam::rigidBodyMeshMotion::solve() // Store the motion state at the beginning of the time-step if (curTimeIndex_ != this->db().time().timeIndex()) { - model_.newTime(); + newTime(); curTimeIndex_ = this->db().time().timeIndex(); } @@ -247,7 +247,7 @@ void Foam::rigidBodyMeshMotion::solve() if (db().foundObject("g")) { - model_.g() = + g() = ramp*db().lookupObject("g").value(); } @@ -257,18 +257,18 @@ void Foam::rigidBodyMeshMotion::solve() for (label i=0; i(model_.nBodies(), Zero) + scalarField(nDoF(), Zero), + Field(nBodies(), Zero) ); } } else { - Field fx(model_.nBodies(), Zero); + Field fx(nBodies(), Zero); forAll(bodyMeshes_, bi) { @@ -287,27 +287,27 @@ void Foam::rigidBodyMeshMotion::solve() fx[bodyID] = ramp*spatialVector(f.momentEff(), f.forceEff()); } - model_.solve + RBD::rigidBodyMotion::solve ( t.value(), t.deltaTValue(), - scalarField(model_.nDoF(), Zero), + scalarField(nDoF(), Zero), fx ); } - if (Pstream::master() && model_.report()) + if (Pstream::master() && report()) { forAll(bodyMeshes_, bi) { - model_.status(bodyMeshes_[bi].bodyID_); + status(bodyMeshes_[bi].bodyID_); } } // Update the displacements if (bodyMeshes_.size() == 1) { - pointDisplacement_.primitiveFieldRef() = model_.transformPoints + pointDisplacement_.primitiveFieldRef() = transformPoints ( bodyMeshes_[0].bodyID_, bodyMeshes_[0].weight_, @@ -325,7 +325,7 @@ void Foam::rigidBodyMeshMotion::solve() } pointDisplacement_.primitiveFieldRef() = - model_.transformPoints(bodyIDs, weights, points0()) - points0(); + transformPoints(bodyIDs, weights, points0()) - points0(); } // Displacement has changed. Update boundary conditions @@ -358,7 +358,7 @@ bool Foam::rigidBodyMeshMotion::writeObject ) ); - model_.state().write(dict); + state().write(dict); return dict.regIOobject::write(); } @@ -367,7 +367,7 @@ bool Foam::rigidBodyMeshMotion::read() { if (displacementMotionSolver::read()) { - model_.read(coeffDict()); + RBD::rigidBodyMotion::read(coeffDict()); return true; } diff --git a/src/rigidBodyMeshMotion/rigidBodyMeshMotion/rigidBodyMeshMotion.H b/src/rigidBodyMeshMotion/rigidBodyMeshMotion/rigidBodyMeshMotion.H index 62b463c785..a8ab033551 100644 --- a/src/rigidBodyMeshMotion/rigidBodyMeshMotion/rigidBodyMeshMotion.H +++ b/src/rigidBodyMeshMotion/rigidBodyMeshMotion/rigidBodyMeshMotion.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 @@ -53,7 +53,8 @@ namespace Foam class rigidBodyMeshMotion : - public displacementMotionSolver + public displacementMotionSolver, + public RBD::rigidBodyMotion { //- Class containing the patches and point motion weighting for each body class bodyMesh @@ -97,9 +98,6 @@ class rigidBodyMeshMotion // Private data - //- Rigid-body model - RBD::rigidBodyMotion model_; - //- List of the bodyMeshes containing the patches and point motion // weighting for each body PtrList bodyMeshes_; diff --git a/src/rigidBodyMeshMotion/rigidBodyMeshMotionSolver/rigidBodyMeshMotionSolver.C b/src/rigidBodyMeshMotion/rigidBodyMeshMotionSolver/rigidBodyMeshMotionSolver.C index 40399fd2bc..6019a2f96f 100644 --- a/src/rigidBodyMeshMotion/rigidBodyMeshMotionSolver/rigidBodyMeshMotionSolver.C +++ b/src/rigidBodyMeshMotion/rigidBodyMeshMotionSolver/rigidBodyMeshMotionSolver.C @@ -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 @@ -71,7 +71,7 @@ Foam::rigidBodyMeshMotionSolver::rigidBodyMeshMotionSolver ) : motionSolver(mesh, dict, typeName), - model_ + RBD::rigidBodyMotion ( coeffDict(), IOobject @@ -132,7 +132,7 @@ Foam::rigidBodyMeshMotionSolver::rigidBodyMeshMotionSolver if (bodyDict.found("patches")) { - const label bodyID = model_.bodyID(iter().keyword()); + const label bodyID = this->bodyID(iter().keyword()); if (bodyID == -1) { @@ -189,13 +189,13 @@ void Foam::rigidBodyMeshMotionSolver::solve() // Store the motion state at the beginning of the time-step if (curTimeIndex_ != this->db().time().timeIndex()) { - model_.newTime(); + newTime(); curTimeIndex_ = this->db().time().timeIndex(); } if (db().foundObject("g")) { - model_.g() = + g() = db().lookupObject("g").value(); } @@ -205,18 +205,18 @@ void Foam::rigidBodyMeshMotionSolver::solve() for (label i=0; i(model_.nBodies(), Zero) + scalarField(nDoF(), Zero), + Field(nBodies(), Zero) ); } } else { - Field fx(model_.nBodies(), Zero); + Field fx(nBodies(), Zero); forAll(bodyMeshes_, bi) { @@ -235,20 +235,20 @@ void Foam::rigidBodyMeshMotionSolver::solve() fx[bodyID] = spatialVector(f.momentEff(), f.forceEff()); } - model_.solve + RBD::rigidBodyMotion::solve ( t.value(), t.deltaTValue(), - scalarField(model_.nDoF(), Zero), + scalarField(nDoF(), Zero), fx ); } - if (Pstream::master() && model_.report()) + if (Pstream::master() && report()) { forAll(bodyMeshes_, bi) { - model_.status(bodyMeshes_[bi].bodyID_); + status(bodyMeshes_[bi].bodyID_); } } @@ -267,7 +267,7 @@ void Foam::rigidBodyMeshMotionSolver::solve() meshSolver_.pointDisplacement().boundaryFieldRef()[patchi] == ( - model_.transformPoints + transformPoints ( bodyMeshes_[bi].bodyID_, patchPoints0 @@ -302,7 +302,7 @@ bool Foam::rigidBodyMeshMotionSolver::writeObject ) ); - model_.state().write(dict); + state().write(dict); return dict.regIOobject::write(); } @@ -311,7 +311,7 @@ bool Foam::rigidBodyMeshMotionSolver::read() { if (motionSolver::read()) { - model_.read(coeffDict()); + RBD::rigidBodyMotion::read(coeffDict()); return true; } diff --git a/src/rigidBodyMeshMotion/rigidBodyMeshMotionSolver/rigidBodyMeshMotionSolver.H b/src/rigidBodyMeshMotion/rigidBodyMeshMotionSolver/rigidBodyMeshMotionSolver.H index 1dfbdad589..510c8db80e 100644 --- a/src/rigidBodyMeshMotion/rigidBodyMeshMotionSolver/rigidBodyMeshMotionSolver.H +++ b/src/rigidBodyMeshMotion/rigidBodyMeshMotionSolver/rigidBodyMeshMotionSolver.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 @@ -52,7 +52,8 @@ namespace Foam class rigidBodyMeshMotionSolver : - public motionSolver + public motionSolver, + public RBD::rigidBodyMotion { //- Class containing the patches and point motion weighting for each body class bodyMesh @@ -86,9 +87,6 @@ class rigidBodyMeshMotionSolver // Private data - //- Rigid-body model - RBD::rigidBodyMotion model_; - //- List of the bodyMeshes containing the patches and point motion // weighting for each body PtrList bodyMeshes_; diff --git a/src/sixDoFRigidBodyState/Make/options b/src/sixDoFRigidBodyState/Make/options index 2d77c5dda4..4e92d1eec1 100644 --- a/src/sixDoFRigidBodyState/Make/options +++ b/src/sixDoFRigidBodyState/Make/options @@ -2,10 +2,8 @@ EXE_INC = \ -I$(LIB_SRC)/finiteVolume/lnInclude \ -I$(LIB_SRC)/dynamicMesh/lnInclude \ -I$(LIB_SRC)/dynamicFvMesh/lnInclude \ - -I$(LIB_SRC)/sixDoFRigidBodyMotion/lnInclude \ - -I$(LIB_SRC)/OpenFOAM/lnInclude \ - -I$(LIB_SRC)/meshTools/lnInclude + -I$(LIB_SRC)/sixDoFRigidBodyMotion/lnInclude LIB_LIBS = \ -lfiniteVolume \ - -lmeshTools + -ldynamicFvMesh diff --git a/src/sixDoFRigidBodyState/sixDoFRigidBodyState/sixDoFRigidBodyState.H b/src/sixDoFRigidBodyState/sixDoFRigidBodyState/sixDoFRigidBodyState.H index 42267b32da..3a6c77a189 100644 --- a/src/sixDoFRigidBodyState/sixDoFRigidBodyState/sixDoFRigidBodyState.H +++ b/src/sixDoFRigidBodyState/sixDoFRigidBodyState/sixDoFRigidBodyState.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2017-2018 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2017-2019 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -125,9 +125,11 @@ public: // Member Functions - vector velocity() const; + //- Return the current body velocity + vector velocity() const; - vector angularVelocity() const; + //- Return the current body angular velocity + vector angularVelocity() const; //- Read the sixDoFRigidBodyState data virtual bool read(const dictionary&);