ramp.patch (3,321 bytes)
diff --git a/src/rigidBodyMeshMotion/rigidBodyMeshMotionSolver/rigidBodyMeshMotionSolver.C b/src/rigidBodyMeshMotion/rigidBodyMeshMotionSolver/rigidBodyMeshMotionSolver.C
index 12ce8d1..214b90a 100644
--- a/src/rigidBodyMeshMotion/rigidBodyMeshMotionSolver/rigidBodyMeshMotionSolver.C
+++ b/src/rigidBodyMeshMotion/rigidBodyMeshMotionSolver/rigidBodyMeshMotionSolver.C
@@ -30,6 +30,7 @@ License
#include "pointConstraints.H"
#include "uniformDimensionedFields.H"
#include "forces.H"
+#include "OneConstant.H"
#include "mathematicalConstants.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
@@ -99,6 +100,7 @@ Foam::rigidBodyMeshMotionSolver::rigidBodyMeshMotionSolver
test_(coeffDict().lookupOrDefault<Switch>("test", false)),
rhoInf_(1.0),
rhoName_(coeffDict().lookupOrDefault<word>("rho", "rho")),
+ ramp_(nullptr),
curTimeIndex_(-1),
meshSolverPtr_
(
@@ -121,7 +123,16 @@ Foam::rigidBodyMeshMotionSolver::rigidBodyMeshMotionSolver
{
if (rhoName_ == "rhoInf")
{
- rhoInf_ = coeffDict().lookup<scalar>("rhoInf");
+ rhoInf_ = readScalar(coeffDict().lookup("rhoInf"));
+ }
+
+ if (coeffDict().found("ramp"))
+ {
+ ramp_ = Function1<scalar>::New("ramp", coeffDict());
+ }
+ else
+ {
+ ramp_ = new Function1s::OneConstant<scalar>("ramp");
}
const dictionary& bodiesDict = coeffDict().subDict("bodies");
@@ -193,15 +204,18 @@ void Foam::rigidBodyMeshMotionSolver::solve()
curTimeIndex_ = t.timeIndex();
}
+ const scalar ramp = ramp_->value(t.value());
+
if (mesh().foundObject<uniformDimensionedVectorField>("g"))
{
g() =
- mesh().lookupObject<uniformDimensionedVectorField>("g").value();
+ ramp
+ *mesh().lookupObject<uniformDimensionedVectorField>("g").value();
}
if (test_)
{
- label nIter(coeffDict().lookup<label>("nIter"));
+ label nIter(readLabel(coeffDict().lookup("nIter")));
for (label i=0; i<nIter; i++)
{
@@ -232,7 +246,7 @@ void Foam::rigidBodyMeshMotionSolver::solve()
functionObjects::forces f("forces", t, forcesDict);
f.calcForcesMoment();
- fx[bodyID] = spatialVector(f.momentEff(), f.forceEff());
+ fx[bodyID] = ramp*spatialVector(f.momentEff(), f.forceEff());
}
RBD::rigidBodyMotion::solve
diff --git a/src/rigidBodyMeshMotion/rigidBodyMeshMotionSolver/rigidBodyMeshMotionSolver.H b/src/rigidBodyMeshMotion/rigidBodyMeshMotionSolver/rigidBodyMeshMotionSolver.H
index dcb8f0a..361d0df 100644
--- a/src/rigidBodyMeshMotion/rigidBodyMeshMotionSolver/rigidBodyMeshMotionSolver.H
+++ b/src/rigidBodyMeshMotion/rigidBodyMeshMotionSolver/rigidBodyMeshMotionSolver.H
@@ -40,6 +40,7 @@ SourceFiles
#include "displacementMotionSolver.H"
#include "rigidBodyMotion.H"
+#include "Function1.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@@ -104,6 +105,9 @@ class rigidBodyMeshMotionSolver
// as rhoInf
word rhoName_;
+ //- Ramp the forces according to the specified function and period
+ autoPtr<Function1<scalar>> ramp_;
+
//- Current time index (used for updating)
label curTimeIndex_;