From 10e75bf28a73bedcc4b15865a69d5cdd96a632dc Mon Sep 17 00:00:00 2001 From: Will Bainbridge Date: Wed, 13 Dec 2017 11:59:46 +0000 Subject: [PATCH] rigidBodyModelState: Added time value member The absolute value of the the time has been added to the rigid body model state. This value is not directly necessary for calculating the evolution of the rigid body system, it just facilitates the implementation of sub-models which are in some way time-dependent. --- .../pendulumAndSpring/pendulumAndSpring.C | 4 ++-- .../sphericalJoint/sphericalJoint.C | 4 ++-- .../test/rigidBodyDynamics/spring/spring.C | 4 ++-- .../rigidBodyModelState/rigidBodyModelState.C | 4 +++- .../rigidBodyModelState/rigidBodyModelState.H | 15 ++++++++++----- .../rigidBodyModelState/rigidBodyModelStateI.H | 14 +++++++++++++- .../rigidBodyModelState/rigidBodyModelStateIO.C | 6 +++++- .../rigidBodyMotion/rigidBodyMotion.C | 7 +++++-- .../rigidBodyMotion/rigidBodyMotion.H | 7 ++++--- .../rigidBodyMeshMotion/rigidBodyMeshMotion.C | 2 ++ .../rigidBodyMeshMotionSolver.C | 2 ++ 11 files changed, 50 insertions(+), 19 deletions(-) diff --git a/applications/test/rigidBodyDynamics/pendulumAndSpring/pendulumAndSpring.C b/applications/test/rigidBodyDynamics/pendulumAndSpring/pendulumAndSpring.C index 94e151f69c..b775b59bb1 100644 --- a/applications/test/rigidBodyDynamics/pendulumAndSpring/pendulumAndSpring.C +++ b/applications/test/rigidBodyDynamics/pendulumAndSpring/pendulumAndSpring.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2016 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2016-2017 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -75,7 +75,7 @@ int main(int argc, char *argv[]) for (label i=0; i("t", -1)), deltaT_(dict.lookupOrDefault("deltaT", 0)) {} diff --git a/src/rigidBodyDynamics/rigidBodyModelState/rigidBodyModelState.H b/src/rigidBodyDynamics/rigidBodyModelState/rigidBodyModelState.H index 6b10ac355e..5bbc716244 100644 --- a/src/rigidBodyDynamics/rigidBodyModelState/rigidBodyModelState.H +++ b/src/rigidBodyDynamics/rigidBodyModelState/rigidBodyModelState.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2016 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2016-2017 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -76,6 +76,9 @@ class rigidBodyModelState //- Joint acceleration scalarField qDdot_; + //- The time + scalar t_; + //- The time-step used to integrate to this state scalar deltaT_; @@ -102,14 +105,15 @@ public: //- Return access to the joint position and orientation inline const scalarField& q() const; - //- Return access to the joint quaternion - //- Return access to the joint velocity inline const scalarField& qDot() const; //- Return access to the joint acceleration inline const scalarField& qDdot() const; + //- Return access to the time + inline scalar t() const; + //- Return access to the time-step inline scalar deltaT() const; @@ -119,14 +123,15 @@ public: //- Return access to the joint position and orientation inline scalarField& q(); - //- Return access to the joint quaternion - //- Return access to the joint velocity inline scalarField& qDot(); //- Return access to the joint acceleration inline scalarField& qDdot(); + //- Return access to the time + inline scalar& t(); + //- Return access to the time-step inline scalar& deltaT(); diff --git a/src/rigidBodyDynamics/rigidBodyModelState/rigidBodyModelStateI.H b/src/rigidBodyDynamics/rigidBodyModelState/rigidBodyModelStateI.H index e3fb2678f4..b14946daea 100644 --- a/src/rigidBodyDynamics/rigidBodyModelState/rigidBodyModelStateI.H +++ b/src/rigidBodyDynamics/rigidBodyModelState/rigidBodyModelStateI.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2016 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2016-2017 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -43,6 +43,12 @@ inline const Foam::scalarField& Foam::RBD::rigidBodyModelState::qDdot() const } +inline Foam::scalar Foam::RBD::rigidBodyModelState::t() const +{ + return t_; +} + + inline Foam::scalar Foam::RBD::rigidBodyModelState::deltaT() const { return deltaT_; @@ -73,4 +79,10 @@ inline Foam::scalar& Foam::RBD::rigidBodyModelState::deltaT() } +inline Foam::scalar& Foam::RBD::rigidBodyModelState::t() +{ + return t_; +} + + // ************************************************************************* // diff --git a/src/rigidBodyDynamics/rigidBodyModelState/rigidBodyModelStateIO.C b/src/rigidBodyDynamics/rigidBodyModelState/rigidBodyModelStateIO.C index c17819b410..fb9ab31970 100644 --- a/src/rigidBodyDynamics/rigidBodyModelState/rigidBodyModelStateIO.C +++ b/src/rigidBodyDynamics/rigidBodyModelState/rigidBodyModelStateIO.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2016 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2016-2017 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -33,6 +33,7 @@ void Foam::RBD::rigidBodyModelState::write(dictionary& dict) const dict.add("q", q_); dict.add("qDot", qDot_); dict.add("qDdot", qDdot_); + dict.add("t", t_); dict.add("deltaT", deltaT_); } @@ -42,6 +43,7 @@ void Foam::RBD::rigidBodyModelState::write(Ostream& os) const os.writeKeyword("q") << q_ << token::END_STATEMENT << nl; os.writeKeyword("qDot") << qDot_ << token::END_STATEMENT << nl; os.writeKeyword("qDdot") << qDdot_ << token::END_STATEMENT << nl; + os.writeKeyword("t") << t_ << token::END_STATEMENT << nl; os.writeKeyword("deltaT") << deltaT_ << token::END_STATEMENT << nl; } @@ -57,6 +59,7 @@ Foam::Istream& Foam::RBD::operator>> is >> state.q_ >> state.qDot_ >> state.qDdot_ + >> state.t_ >> state.deltaT_; // Check state of Istream @@ -79,6 +82,7 @@ Foam::Ostream& Foam::RBD::operator<< os << state.q_ << token::SPACE << state.qDot_ << token::SPACE << state.qDdot_ + << token::SPACE << state.t_ << token::SPACE << state.deltaT_; // Check state of Ostream diff --git a/src/rigidBodyDynamics/rigidBodyMotion/rigidBodyMotion.C b/src/rigidBodyDynamics/rigidBodyMotion/rigidBodyMotion.C index 6cf2514c04..8412867297 100644 --- a/src/rigidBodyDynamics/rigidBodyMotion/rigidBodyMotion.C +++ b/src/rigidBodyDynamics/rigidBodyMotion/rigidBodyMotion.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2016 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2016-2017 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -140,15 +140,18 @@ void Foam::RBD::rigidBodyMotion::forwardDynamics void Foam::RBD::rigidBodyMotion::solve ( - scalar deltaT, + const scalar t, + const scalar deltaT, const scalarField& tau, const Field& fx ) { + motionState_.t() = t; motionState_.deltaT() = deltaT; if (motionState0_.deltaT() < SMALL) { + motionState0_.t() = t; motionState0_.deltaT() = deltaT; } diff --git a/src/rigidBodyDynamics/rigidBodyMotion/rigidBodyMotion.H b/src/rigidBodyDynamics/rigidBodyMotion/rigidBodyMotion.H index d065d9797c..d3fc116477 100644 --- a/src/rigidBodyDynamics/rigidBodyMotion/rigidBodyMotion.H +++ b/src/rigidBodyDynamics/rigidBodyMotion/rigidBodyMotion.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2016 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2016-2017 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -169,10 +169,11 @@ public: ) const; //- Integrate velocities, orientation and position - // for the given time-step + // for the given time and time-step void solve ( - scalar deltaT, + const scalar t, + const scalar deltaT, const scalarField& tau, const Field& fx ); diff --git a/src/rigidBodyMeshMotion/rigidBodyMeshMotion/rigidBodyMeshMotion.C b/src/rigidBodyMeshMotion/rigidBodyMeshMotion/rigidBodyMeshMotion.C index 3676f8dea3..7ccaa928cc 100644 --- a/src/rigidBodyMeshMotion/rigidBodyMeshMotion/rigidBodyMeshMotion.C +++ b/src/rigidBodyMeshMotion/rigidBodyMeshMotion/rigidBodyMeshMotion.C @@ -259,6 +259,7 @@ void Foam::rigidBodyMeshMotion::solve() { model_.solve ( + t.value(), t.deltaTValue(), scalarField(model_.nDoF(), Zero), Field(model_.nBodies(), Zero) @@ -288,6 +289,7 @@ void Foam::rigidBodyMeshMotion::solve() model_.solve ( + t.value(), t.deltaTValue(), scalarField(model_.nDoF(), Zero), fx diff --git a/src/rigidBodyMeshMotion/rigidBodyMeshMotionSolver/rigidBodyMeshMotionSolver.C b/src/rigidBodyMeshMotion/rigidBodyMeshMotionSolver/rigidBodyMeshMotionSolver.C index 6434e69fbb..70b4acbdce 100644 --- a/src/rigidBodyMeshMotion/rigidBodyMeshMotionSolver/rigidBodyMeshMotionSolver.C +++ b/src/rigidBodyMeshMotion/rigidBodyMeshMotionSolver/rigidBodyMeshMotionSolver.C @@ -207,6 +207,7 @@ void Foam::rigidBodyMeshMotionSolver::solve() { model_.solve ( + t.value(), t.deltaTValue(), scalarField(model_.nDoF(), Zero), Field(model_.nBodies(), Zero) @@ -236,6 +237,7 @@ void Foam::rigidBodyMeshMotionSolver::solve() model_.solve ( + t.value(), t.deltaTValue(), scalarField(model_.nDoF(), Zero), fx