diff --git a/src/rigidBodyMeshMotion/rigidBodyMeshMotion/rigidBodyMeshMotion.C b/src/rigidBodyMeshMotion/rigidBodyMeshMotion/rigidBodyMeshMotion.C index 490f98873..7854762a8 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 | - \\ / A nd | Copyright (C) 2016 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2016-2017 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -30,6 +30,7 @@ License #include "pointConstraints.H" #include "uniformDimensionedFields.H" #include "forces.H" +#include "OneConstant.H" #include "mathematicalConstants.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -115,6 +116,7 @@ Foam::rigidBodyMeshMotion::rigidBodyMeshMotion test_(coeffDict().lookupOrDefault("test", false)), rhoInf_(1.0), rhoName_(coeffDict().lookupOrDefault("rho", "rho")), + ramp_(nullptr), curTimeIndex_(-1) { if (rhoName_ == "rhoInf") @@ -122,6 +124,15 @@ Foam::rigidBodyMeshMotion::rigidBodyMeshMotion rhoInf_ = readScalar(coeffDict().lookup("rhoInf")); } + if (coeffDict().found("ramp")) + { + ramp_ = Function1::New("ramp", coeffDict()); + } + else + { + ramp_ = new Function1Types::OneConstant("ramp"); + } + const dictionary& bodiesDict = coeffDict().subDict("bodies"); forAllConstIter(IDLList, bodiesDict, iter) @@ -232,10 +243,12 @@ void Foam::rigidBodyMeshMotion::solve() curTimeIndex_ = this->db().time().timeIndex(); } + const scalar ramp = ramp_->value(t.value()); + if (db().foundObject("g")) { model_.g() = - db().lookupObject("g").value(); + ramp*db().lookupObject("g").value(); } if (test_) @@ -270,7 +283,7 @@ void Foam::rigidBodyMeshMotion::solve() functionObjects::forces f("forces", db(), forcesDict); f.calcForcesMoment(); - fx[bodyID] = spatialVector(f.momentEff(), f.forceEff()); + fx[bodyID] = ramp*spatialVector(f.momentEff(), f.forceEff()); } model_.solve diff --git a/src/rigidBodyMeshMotion/rigidBodyMeshMotion/rigidBodyMeshMotion.H b/src/rigidBodyMeshMotion/rigidBodyMeshMotion/rigidBodyMeshMotion.H index c60bdc9a3..d2c85bb73 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 | - \\ / A nd | Copyright (C) 2016 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2016-2017 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -40,6 +40,7 @@ SourceFiles #include "displacementMotionSolver.H" #include "rigidBodyMotion.H" +#include "ramp.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -116,6 +117,9 @@ class rigidBodyMeshMotion // as rhoInf word rhoName_; + //- Ramp the forces according to the specified function and period + autoPtr> ramp_; + //- Current time index (used for updating) label curTimeIndex_;