diff --git a/src/sixDoFRigidBodyMotion/sixDoFRigidBodyMotion/sixDoFRigidBodyMotion.C b/src/sixDoFRigidBodyMotion/sixDoFRigidBodyMotion/sixDoFRigidBodyMotion.C index 8240a1305cb3969fc767acd297ed58512063166f..349493e09622564876eed2fa9da9dff8c742e95b 100644 --- a/src/sixDoFRigidBodyMotion/sixDoFRigidBodyMotion/sixDoFRigidBodyMotion.C +++ b/src/sixDoFRigidBodyMotion/sixDoFRigidBodyMotion/sixDoFRigidBodyMotion.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2017 OpenFOAM Foundation - Copyright (C) 2016-2020 OpenCFD Ltd. + Copyright (C) 2016-2023 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -90,6 +90,7 @@ Foam::sixDoFRigidBodyMotion::sixDoFRigidBodyMotion(const Time& time) aRelax_(1.0), aDamp_(1.0), report_(false), + updateConstraints_(false), solver_(nullptr) {} @@ -130,6 +131,7 @@ Foam::sixDoFRigidBodyMotion::sixDoFRigidBodyMotion aRelax_(dict.getOrDefault<scalar>("accelerationRelaxation", 1)), aDamp_(dict.getOrDefault<scalar>("accelerationDamping", 1)), report_(dict.getOrDefault("report", false)), + updateConstraints_(dict.getOrDefault("updateConstraints", false)), solver_(sixDoFSolver::New(dict.subDict("solver"), *this)) { addRestraints(dict); @@ -178,6 +180,7 @@ Foam::sixDoFRigidBodyMotion::sixDoFRigidBodyMotion aRelax_(sDoFRBM.aRelax_), aDamp_(sDoFRBM.aDamp_), report_(sDoFRBM.report_), + updateConstraints_(sDoFRBM.updateConstraints_), solver_(sDoFRBM.solver_.clone()) {} @@ -304,6 +307,31 @@ void Foam::sixDoFRigidBodyMotion::updateAcceleration } +void Foam::sixDoFRigidBodyMotion::updateConstraints() +{ + if (!updateConstraints_) + { + return; + } + + pointConstraint pct; + pointConstraint pcr; + + forAll(constraints_, i) + { + constraints_[i].setCentreOfRotation(initialCentreOfRotation_); + constraints_[i].constrainTranslation(pct); + constraints_[i].constrainRotation(pcr); + } + + tConstraints_ = pct.constraintTransformation(); + rConstraints_ = pcr.constraintTransformation(); + + Info<< "Translational constraint tensor " << tConstraints_ << nl + << "Rotational constraint tensor " << rConstraints_ << endl; +} + + void Foam::sixDoFRigidBodyMotion::update ( bool firstIter, diff --git a/src/sixDoFRigidBodyMotion/sixDoFRigidBodyMotion/sixDoFRigidBodyMotion.H b/src/sixDoFRigidBodyMotion/sixDoFRigidBodyMotion/sixDoFRigidBodyMotion.H index c9dd5e7ab7d1490f6d4e8b07cb73eb7b644f6c85..8365882d842757ef3c113e0fe2ce836a6728ef32 100644 --- a/src/sixDoFRigidBodyMotion/sixDoFRigidBodyMotion/sixDoFRigidBodyMotion.H +++ b/src/sixDoFRigidBodyMotion/sixDoFRigidBodyMotion/sixDoFRigidBodyMotion.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2015 OpenFOAM Foundation - Copyright (C) 2016-2019 OpenCFD Ltd. + Copyright (C) 2016-2023 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -119,6 +119,9 @@ class sixDoFRigidBodyMotion //- Reporting of motion data (on or off) bool report_; + //- Flag to enable time-variant constraints + bool updateConstraints_; + //- Motion solver autoPtr<sixDoFSolver> solver_; @@ -152,6 +155,9 @@ class sixDoFRigidBodyMotion //- Update and relax accelerations from the force and torque void updateAcceleration(const vector& fGlobal, const vector& tauGlobal); + //- Update the constraints to the object + void updateConstraints(); + // Access functions retained as private because of the risk of // confusion over what is a body local frame vector and what is global @@ -271,6 +277,9 @@ public: //- Return the report Switch inline bool report() const; + //- Return the update-constraints flag + inline bool updateConstraints() const; + //- Return time inline const Time& time() const; diff --git a/src/sixDoFRigidBodyMotion/sixDoFRigidBodyMotion/sixDoFRigidBodyMotionI.H b/src/sixDoFRigidBodyMotion/sixDoFRigidBodyMotion/sixDoFRigidBodyMotionI.H index 91eabdc34145be4929f366f16fed3259860a6162..f42f3045b5a0ce8639303e93d11242caec0ef1ce 100644 --- a/src/sixDoFRigidBodyMotion/sixDoFRigidBodyMotion/sixDoFRigidBodyMotionI.H +++ b/src/sixDoFRigidBodyMotion/sixDoFRigidBodyMotion/sixDoFRigidBodyMotionI.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2015 OpenFOAM Foundation - Copyright (C) 2016-2019 OpenCFD Ltd. + Copyright (C) 2016-2023 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -275,6 +275,11 @@ inline bool Foam::sixDoFRigidBodyMotion::report() const return report_; } +inline bool Foam::sixDoFRigidBodyMotion::updateConstraints() const +{ + return updateConstraints_; +} + inline void Foam::sixDoFRigidBodyMotion::newTime() { diff --git a/src/sixDoFRigidBodyMotion/sixDoFRigidBodyMotion/sixDoFRigidBodyMotionIO.C b/src/sixDoFRigidBodyMotion/sixDoFRigidBodyMotion/sixDoFRigidBodyMotionIO.C index e6cbb4d59899bb4954b1877b1ac8bf5e992793a2..df005017e1e77027aa9d910e4726219bd54532da 100644 --- a/src/sixDoFRigidBodyMotion/sixDoFRigidBodyMotion/sixDoFRigidBodyMotionIO.C +++ b/src/sixDoFRigidBodyMotion/sixDoFRigidBodyMotion/sixDoFRigidBodyMotionIO.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2014 OpenFOAM Foundation - Copyright (C) 2020 OpenCFD Ltd. + Copyright (C) 2020-2023 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -39,6 +39,7 @@ bool Foam::sixDoFRigidBodyMotion::read(const dictionary& dict) aRelax_ = dict.getOrDefault<scalar>("accelerationRelaxation", 1); aDamp_ = dict.getOrDefault<scalar>("accelerationDamping", 1); report_ = dict.getOrDefault<Switch>("report", false); + updateConstraints_ = dict.getOrDefault("updateConstraints", false); restraints_.clear(); addRestraints(dict); @@ -61,6 +62,7 @@ void Foam::sixDoFRigidBodyMotion::write(Ostream& os) const os.writeEntry("accelerationRelaxation", aRelax_); os.writeEntry("accelerationDamping", aDamp_); os.writeEntry("report", report_); + os.writeEntry("updateConstraints", updateConstraints_); if (!restraints_.empty()) { diff --git a/src/sixDoFRigidBodyMotion/sixDoFSolvers/CrankNicolson/CrankNicolson.C b/src/sixDoFRigidBodyMotion/sixDoFSolvers/CrankNicolson/CrankNicolson.C index 7d446dd6ee6645efc8cedd10fd37e06d98aea172..f9fa6739f12b8cf33c454cb5cd7e8b443a0c7a1e 100644 --- a/src/sixDoFRigidBodyMotion/sixDoFSolvers/CrankNicolson/CrankNicolson.C +++ b/src/sixDoFRigidBodyMotion/sixDoFSolvers/CrankNicolson/CrankNicolson.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2015 OpenFOAM Foundation - Copyright (C) 2020 OpenCFD Ltd. + Copyright (C) 2020-2023 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -75,6 +75,9 @@ void Foam::sixDoFSolvers::CrankNicolson::solve // Update the linear acceleration and torque updateAcceleration(fGlobal, tauGlobal); + // Update the constraints to the object + updateConstraints(); + // Correct linear velocity v() = tConstraints() & (v0() + aDamp()*deltaT*(aoc_*a() + (1 - aoc_)*a0())); diff --git a/src/sixDoFRigidBodyMotion/sixDoFSolvers/Newmark/Newmark.C b/src/sixDoFRigidBodyMotion/sixDoFSolvers/Newmark/Newmark.C index 35e506a8714c92857f0b6538dbbd09628f5f12e6..0ed1ef9beb331ab8a870124189c2a18680e3b36b 100644 --- a/src/sixDoFRigidBodyMotion/sixDoFSolvers/Newmark/Newmark.C +++ b/src/sixDoFRigidBodyMotion/sixDoFSolvers/Newmark/Newmark.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2015-2016 OpenFOAM Foundation - Copyright (C) 2020 OpenCFD Ltd. + Copyright (C) 2020-2023 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -82,6 +82,9 @@ void Foam::sixDoFSolvers::Newmark::solve // Update the linear acceleration and torque updateAcceleration(fGlobal, tauGlobal); + // Update the constraints to the object + updateConstraints(); + // Correct linear velocity v() = tConstraints() diff --git a/src/sixDoFRigidBodyMotion/sixDoFSolvers/sixDoFSolver/sixDoFSolver.H b/src/sixDoFRigidBodyMotion/sixDoFSolvers/sixDoFSolver/sixDoFSolver.H index 800d819d1bb15e7155a4af15c5a63fcbb88e266c..97cc1a12561bb51a99cb347c63cf31e78ca0c906 100644 --- a/src/sixDoFRigidBodyMotion/sixDoFSolvers/sixDoFSolver/sixDoFSolver.H +++ b/src/sixDoFRigidBodyMotion/sixDoFSolvers/sixDoFSolver/sixDoFSolver.H @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2015 OpenFOAM Foundation + Copyright (C) 2023 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -128,6 +129,9 @@ protected: const vector& tauGlobal ); + //- Update the constraints to the object + inline void updateConstraints(); + public: diff --git a/src/sixDoFRigidBodyMotion/sixDoFSolvers/sixDoFSolver/sixDoFSolverI.H b/src/sixDoFRigidBodyMotion/sixDoFSolvers/sixDoFSolver/sixDoFSolverI.H index f059b83c07c45b8a6c9dbb69376f0a7d9dee4555..e7fca2c5d17f1cbe0ed7c1002b7c20b4371a820a 100644 --- a/src/sixDoFRigidBodyMotion/sixDoFSolvers/sixDoFSolver/sixDoFSolverI.H +++ b/src/sixDoFRigidBodyMotion/sixDoFSolvers/sixDoFSolver/sixDoFSolverI.H @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2015 OpenFOAM Foundation + Copyright (C) 2023 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -129,5 +130,10 @@ inline void Foam::sixDoFSolver::updateAcceleration body_.updateAcceleration(fGlobal, tauGlobal); } +inline void Foam::sixDoFSolver::updateConstraints() +{ + body_.updateConstraints(); +} + // ************************************************************************* // diff --git a/src/sixDoFRigidBodyMotion/sixDoFSolvers/symplectic/symplectic.C b/src/sixDoFRigidBodyMotion/sixDoFSolvers/symplectic/symplectic.C index 0fdd3f863238527f300174ebfa33d4db48dec39d..d5875361e7acdeb2c68a63239d822fb7b61bfc59 100644 --- a/src/sixDoFRigidBodyMotion/sixDoFSolvers/symplectic/symplectic.C +++ b/src/sixDoFRigidBodyMotion/sixDoFSolvers/symplectic/symplectic.C @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2015-2016 OpenFOAM Foundation + Copyright (C) 2023 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -85,6 +86,9 @@ void Foam::sixDoFSolvers::symplectic::solve // Update the linear acceleration and torque updateAcceleration(fGlobal, tauGlobal); + // Update the constraints to the object + updateConstraints(); + // Second simplectic step: // Complete update of linear and angular velocities