Commit 25472673 authored by mattijs's avatar mattijs
Browse files

ENH: prescribedRotation: fix testcase. Fixes #872.

parent 78418c87
......@@ -122,19 +122,27 @@ void Foam::RBD::restraints::prescribedRotation::restrain
vector omega = model_.v(model_.master(bodyID_)).w();
scalar Inertia = mag(model_.I(model_.master(bodyID_)).Ic());
// from the definition of the angular momentum:
// moment = Inertia*ddt(omega)
// with time step 1:
// moment = Inertia*(omega_wanted - omega)
const scalar relax = 0.5;
vector moment
(
(Inertia * (omegaSet_.value(model_.time().value()) - omega) & a) * a
(
relax
* Inertia
* (omegaSet_.value(model_.time().value()) - omega)
/ model_.time().deltaTValue()
& a
)
* a
);
if (model_.debug)
{
Info<< " angle " << theta*sign(a & axis_) << endl
<< " omega " << omega << endl
<< " wanted " << omegaSet_.value(model_.time().value()) << endl
<< " moment " << moment << endl
<< " oldDir " << oldDir << endl
<< " newDir " << newDir << endl
......
......@@ -263,32 +263,37 @@ void Foam::rigidBodyMeshMotion::solve()
}
else
{
Field<spatialVector> fx(model_.nBodies(), Zero);
label nIter(coeffDict().lookupOrDefault("nIter", 1));
forAll(bodyMeshes_, bi)
for (label i=0; i<nIter; i++)
{
const label bodyID = bodyMeshes_[bi].bodyID_;
Field<spatialVector> fx(model_.nBodies(), Zero);
dictionary forcesDict;
forcesDict.add("type", functionObjects::forces::typeName);
forcesDict.add("patches", bodyMeshes_[bi].patches_);
forcesDict.add("rhoInf", rhoInf_);
forcesDict.add("rho", rhoName_);
forcesDict.add("CofR", vector::zero);
forAll(bodyMeshes_, bi)
{
const label bodyID = bodyMeshes_[bi].bodyID_;
functionObjects::forces f("forces", db(), forcesDict);
f.calcForcesMoment();
dictionary forcesDict;
forcesDict.add("type", functionObjects::forces::typeName);
forcesDict.add("patches", bodyMeshes_[bi].patches_);
forcesDict.add("rhoInf", rhoInf_);
forcesDict.add("rho", rhoName_);
forcesDict.add("CofR", vector::zero);
fx[bodyID] = ramp*spatialVector(f.momentEff(), f.forceEff());
}
functionObjects::forces f("forces", db(), forcesDict);
f.calcForcesMoment();
model_.solve
(
t.value(),
t.deltaTValue(),
scalarField(model_.nDoF(), Zero),
fx
);
fx[bodyID] = ramp*spatialVector(f.momentEff(), f.forceEff());
}
model_.solve
(
t.value(),
t.deltaTValue(),
scalarField(model_.nDoF(), Zero),
fx
);
}
}
if (Pstream::master() && model_.report())
......@@ -354,7 +359,8 @@ bool Foam::rigidBodyMeshMotion::writeObject
);
model_.state().write(dict);
return dict.regIOobject::write();
// Force ascii writing
return dict.regIOobject::writeObject(IOstream::ASCII, ver, cmp, valid);
}
......
......@@ -296,7 +296,8 @@ bool Foam::rigidBodyMeshMotionSolver::writeObject
);
model_.state().write(dict);
return dict.regIOobject::write();
// Force ascii writing
return dict.regIOobject::writeObject(IOstream::ASCII, ver, cmp, valid);
}
......
......@@ -5,6 +5,6 @@ cd ${0%/*} || exit 1 # Run from this directory
./Allrun.pre
runApplication decomposePar
runParallel overInterDyMFoam
runParallel $(getApplication)
#------------------------------------------------------------------------------
......@@ -34,6 +34,10 @@ motionSolver rigidBodyMotion;
accelerationRelaxation 1.0;
//- prescribedRotation requires some sub-iterations to converge faster
// to desired value.
nIter 3;
bodies
{
hull
......
Supports Markdown
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