diff --git a/src/rigidBodyDynamics/restraints/prescribedRotation/prescribedRotation.C b/src/rigidBodyDynamics/restraints/prescribedRotation/prescribedRotation.C index 483e61c29c43c0a9d9dfb89a0f50a35abf2fca03..a2f0f19cfa7c5357bdaa13a42fe30fa9bd3ceca3 100644 --- a/src/rigidBodyDynamics/restraints/prescribedRotation/prescribedRotation.C +++ b/src/rigidBodyDynamics/restraints/prescribedRotation/prescribedRotation.C @@ -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 diff --git a/src/rigidBodyMeshMotion/rigidBodyMeshMotion/rigidBodyMeshMotion.C b/src/rigidBodyMeshMotion/rigidBodyMeshMotion/rigidBodyMeshMotion.C index 93f2fbffdedfa51e10a9e0c224eddd5c3c8f5ab4..d69537ff5e7c087a7f6661a6d463969c628fab65 100644 --- a/src/rigidBodyMeshMotion/rigidBodyMeshMotion/rigidBodyMeshMotion.C +++ b/src/rigidBodyMeshMotion/rigidBodyMeshMotion/rigidBodyMeshMotion.C @@ -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); } diff --git a/src/rigidBodyMeshMotion/rigidBodyMeshMotionSolver/rigidBodyMeshMotionSolver.C b/src/rigidBodyMeshMotion/rigidBodyMeshMotionSolver/rigidBodyMeshMotionSolver.C index 56ac81c80ec5e10774a30bf98dd3b977ba0ac46d..abf0312812483322d1747660686b8fc43d80e93c 100644 --- a/src/rigidBodyMeshMotion/rigidBodyMeshMotionSolver/rigidBodyMeshMotionSolver.C +++ b/src/rigidBodyMeshMotion/rigidBodyMeshMotionSolver/rigidBodyMeshMotionSolver.C @@ -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); } diff --git a/tutorials/multiphase/overInterDyMFoam/boatAndPropeller/Allrun b/tutorials/multiphase/overInterDyMFoam/boatAndPropeller/Allrun index d5979700f56259aa8e38bb03854d1e620833b4bb..787d72a9dced09e6ff75d24acaad56e1fdccfbeb 100755 --- a/tutorials/multiphase/overInterDyMFoam/boatAndPropeller/Allrun +++ b/tutorials/multiphase/overInterDyMFoam/boatAndPropeller/Allrun @@ -5,6 +5,6 @@ cd ${0%/*} || exit 1 # Run from this directory ./Allrun.pre runApplication decomposePar -runParallel overInterDyMFoam +runParallel $(getApplication) #------------------------------------------------------------------------------ diff --git a/tutorials/multiphase/overInterDyMFoam/boatAndPropeller/constant/dynamicMeshDict b/tutorials/multiphase/overInterDyMFoam/boatAndPropeller/constant/dynamicMeshDict index de53a7d4241b0a522cdf2e289481efd5264a13fc..4142814ded25640b610ad0eba1adbb3263e815dc 100644 --- a/tutorials/multiphase/overInterDyMFoam/boatAndPropeller/constant/dynamicMeshDict +++ b/tutorials/multiphase/overInterDyMFoam/boatAndPropeller/constant/dynamicMeshDict @@ -34,6 +34,10 @@ motionSolver rigidBodyMotion; accelerationRelaxation 1.0; + //- prescribedRotation requires some sub-iterations to converge faster + // to desired value. + nIter 3; + bodies { hull