Commit 4c2728a4 authored by Kutalmis Bercin's avatar Kutalmis Bercin Committed by Andrew Heather
Browse files

ENH: rigidBodyMotion: new Function1-type accelerationRelaxation

TUT: floatingObject: add Function1-type accelerationRelaxation example
parent 18dd013e
......@@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2016-2017 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
Copyright (C) 2020-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -50,7 +50,7 @@ Foam::RBD::rigidBodyMotion::rigidBodyMotion(const Time& time)
rigidBodyModel(time),
motionState_(*this),
motionState0_(*this),
aRelax_(1.0),
aRelax_(nullptr),
aDamp_(1.0),
report_(false),
solver_(nullptr)
......@@ -66,7 +66,16 @@ Foam::RBD::rigidBodyMotion::rigidBodyMotion
motionState_(*this, dict),
motionState0_(motionState_),
X00_(X0_.size()),
aRelax_(dict.getOrDefault<scalar>("accelerationRelaxation", 1)),
aRelax_
(
Function1<scalar>::NewIfPresent
(
"accelerationRelaxation",
dict,
word::null,
&time
)
),
aDamp_(dict.getOrDefault<scalar>("accelerationDamping", 1)),
report_(dict.getOrDefault<Switch>("report", false)),
solver_(rigidBodySolver::New(*this, dict.subDict("solver")))
......@@ -91,7 +100,16 @@ Foam::RBD::rigidBodyMotion::rigidBodyMotion
motionState_(*this, stateDict),
motionState0_(motionState_),
X00_(X0_.size()),
aRelax_(dict.getOrDefault<scalar>("accelerationRelaxation", 1)),
aRelax_
(
Function1<scalar>::NewIfPresent
(
"accelerationRelaxation",
dict,
word::null,
&time
)
),
aDamp_(dict.getOrDefault<scalar>("accelerationDamping", 1)),
report_(dict.getOrDefault<Switch>("report", false)),
solver_(rigidBodySolver::New(*this, dict.subDict("solver")))
......@@ -139,7 +157,14 @@ void Foam::RBD::rigidBodyMotion::forwardDynamics
{
scalarField qDdotPrev = state.qDdot();
rigidBodyModel::forwardDynamics(state, tau, fx);
state.qDdot() = aDamp_*(aRelax_*state.qDdot() + (1 - aRelax_)*qDdotPrev);
scalar aRelax = 1;
if (aRelax_)
{
aRelax = aRelax_->value(motionState_.t());
}
state.qDdot() = aDamp_*(aRelax*state.qDdot() + (1 - aRelax)*qDdotPrev);
}
......
......@@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2016-2017 OpenFOAM Foundation
Copyright (C) 2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -52,6 +53,7 @@ SourceFiles
#include "rigidBodyModelState.H"
#include "pointField.H"
#include "Switch.H"
#include "Function1.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
......@@ -89,7 +91,7 @@ class rigidBodyMotion
List<spatialTransform> X00_;
//- Acceleration relaxation coefficient
scalar aRelax_;
autoPtr<Function1<scalar>> aRelax_;
//- Acceleration damping coefficient (for steady-state simulations)
scalar aDamp_;
......
......@@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2016 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
Copyright (C) 2020-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -33,13 +33,23 @@ License
bool Foam::RBD::rigidBodyMotion::read(const dictionary& dict)
{
rigidBodyModel::read(dict);
if (rigidBodyModel::read(dict))
{
aRelax_ =
Function1<scalar>::NewIfPresent
(
"accelerationRelaxation",
dict,
word::null,
&time()
);
aDamp_ = dict.getOrDefault<scalar>("accelerationDamping", 1);
report_ = dict.getOrDefault<Switch>("report", false);
aRelax_ = dict.getOrDefault<scalar>("accelerationRelaxation", 1);
aDamp_ = dict.getOrDefault<scalar>("accelerationDamping", 1);
report_ = dict.getOrDefault<Switch>("report", false);
return true;
}
return true;
return false;
}
......@@ -47,7 +57,10 @@ void Foam::RBD::rigidBodyMotion::write(Ostream& os) const
{
rigidBodyModel::write(os);
os.writeEntry("accelerationRelaxation", aRelax_);
if (aRelax_)
{
aRelax_->writeData(os);
}
os.writeEntry("accelerationDamping", aDamp_);
os.writeEntry("report", report_);
}
......
......@@ -29,7 +29,13 @@ rigidBodyMotionCoeffs
type Newmark;
}
accelerationRelaxation 0.7;
accelerationRelaxation table
(
// time relaxation-factor
(0 0)
(3.99999 0)
(4 0.7)
);
bodies
{
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment