Commit bcc32e15 authored by graham's avatar graham
Browse files

BUG: sixDoFRigidBodyMotion. Adding autoMap and rmap to BC.

parent b98a01b2
......@@ -114,6 +114,32 @@ sixDoFRigidBodyDisplacementPointPatchVectorField
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void sixDoFRigidBodyDisplacementPointPatchVectorField::autoMap
(
const pointPatchFieldMapper& m
)
{
fixedValuePointPatchField<vector>::autoMap(m);
p0_.autoMap(m);
}
void sixDoFRigidBodyDisplacementPointPatchVectorField::rmap
(
const pointPatchField<vector>& ptf,
const labelList& addr
)
{
const sixDoFRigidBodyDisplacementPointPatchVectorField& sDoFptf =
refCast<const sixDoFRigidBodyDisplacementPointPatchVectorField>(ptf);
fixedValuePointPatchField<vector>::rmap(sDoFptf, addr);
p0_.rmap(sDoFptf.p0_, addr);
}
void sixDoFRigidBodyDisplacementPointPatchVectorField::updateCoeffs()
{
if (this->updated())
......@@ -160,26 +186,6 @@ void sixDoFRigidBodyDisplacementPointPatchVectorField::updateCoeffs()
t.deltaTValue()
);
// ----------------------------------------
// vector rotationAxis(0, 1, 0);
// vector torque
// (
// (
// (fm.second().first() + fm.second().second())
// & rotationAxis
// )
// *rotationAxis
// );
// motion_.updateForce
// (
// vector::zero, // Force no centre of mass motion
// torque, // Only rotation allowed around the unit rotationAxis
// t.deltaTValue()
// );
// ----------------------------------------
Field<vector>::operator=(motion_.currentPosition(p0_) - p0_);
fixedValuePointPatchField<vector>::updateCoeffs();
......
......@@ -135,6 +135,22 @@ public:
// Member functions
// Mapping functions
//- Map (and resize as needed) from self given a mapping object
virtual void autoMap
(
const pointPatchFieldMapper&
);
//- Reverse map the given pointPatchField onto this pointPatchField
virtual void rmap
(
const pointPatchField<vector>&,
const labelList&
);
// Evaluation functions
//- Update the coefficients associated with the patch field
......
......@@ -30,7 +30,7 @@ License
void Foam::sixDoFRigidBodyMotion::applyRestraints()
{
if (restraints_.size() == 0)
if (restraints_.empty())
{
return;
}
......@@ -62,14 +62,14 @@ void Foam::sixDoFRigidBodyMotion::applyRestraints()
void Foam::sixDoFRigidBodyMotion::applyConstraints(scalar deltaT)
{
if (constraints_.size() == 0)
if (constraints_.empty())
{
return;
}
if (Pstream::master())
{
label iter = 0;
label iteration = 0;
bool allConverged = true;
......@@ -114,9 +114,9 @@ void Foam::sixDoFRigidBodyMotion::applyConstraints(scalar deltaT)
cMA += cM + ((cP - centreOfMass()) ^ cF);
}
} while(++iter < maxConstraintIters_ && !allConverged);
} while(++iteration < maxConstraintIterations_ && !allConverged);
if (iter >= maxConstraintIters_)
if (iteration >= maxConstraintIterations_)
{
FatalErrorIn
(
......@@ -124,13 +124,15 @@ void Foam::sixDoFRigidBodyMotion::applyConstraints(scalar deltaT)
"(scalar deltaT)"
)
<< nl << "Maximum number of sixDoFRigidBodyMotion constraint "
<< "iterations (" << maxConstraintIters_ << ") exceeded." << nl
<< "iterations ("
<< maxConstraintIterations_
<< ") exceeded." << nl
<< exit(FatalError);
}
else if (report_)
{
Info<< "sixDoFRigidBodyMotion constraints converged in "
<< iter << " iterations"
<< iteration << " iterations"
<< nl << "Constraint force: " << cFA << nl
<< "Constraint moment: " << cMA
<< endl;
......@@ -154,7 +156,7 @@ Foam::sixDoFRigidBodyMotion::sixDoFRigidBodyMotion()
motionState_(),
restraints_(),
constraints_(),
maxConstraintIters_(0),
maxConstraintIterations_(0),
refCentreOfMass_(vector::zero),
momentOfInertia_(diagTensor::one*VSMALL),
mass_(VSMALL),
......@@ -187,7 +189,7 @@ Foam::sixDoFRigidBodyMotion::sixDoFRigidBodyMotion
),
restraints_(),
constraints_(),
maxConstraintIters_(0),
maxConstraintIterations_(0),
refCentreOfMass_(refCentreOfMass),
momentOfInertia_(momentOfInertia),
mass_(mass),
......@@ -200,7 +202,7 @@ Foam::sixDoFRigidBodyMotion::sixDoFRigidBodyMotion(const dictionary& dict)
motionState_(dict),
restraints_(),
constraints_(),
maxConstraintIters_(0),
maxConstraintIterations_(0),
refCentreOfMass_(dict.lookupOrDefault("refCentreOfMass", centreOfMass())),
momentOfInertia_(dict.lookup("momentOfInertia")),
mass_(readScalar(dict.lookup("mass"))),
......@@ -220,7 +222,7 @@ Foam::sixDoFRigidBodyMotion::sixDoFRigidBodyMotion
motionState_(sDoFRBM.motionState()),
restraints_(sDoFRBM.restraints()),
constraints_(sDoFRBM.constraints()),
maxConstraintIters_(sDoFRBM.maxConstraintIters()),
maxConstraintIterations_(sDoFRBM.maxConstraintIterations()),
refCentreOfMass_(sDoFRBM.refCentreOfMass()),
momentOfInertia_(sDoFRBM.momentOfInertia()),
mass_(sDoFRBM.mass()),
......
......@@ -96,7 +96,7 @@ class sixDoFRigidBodyMotion
//- Maximum number of iterations allowed to attempt to obey
// constraints
label maxConstraintIters_;
label maxConstraintIterations_;
//- Centre of mass of reference state
point refCentreOfMass_;
......@@ -152,7 +152,7 @@ class sixDoFRigidBodyMotion
//- Return access to the maximum allowed number of
// constraint iterations
inline label maxConstraintIters() const;
inline label maxConstraintIterations() const;
//- Return access to the centre of mass
inline const point& refCentreOfMass() const;
......
......@@ -114,9 +114,9 @@ Foam::sixDoFRigidBodyMotion::constraints() const
}
inline Foam::label Foam::sixDoFRigidBodyMotion::maxConstraintIters() const
inline Foam::label Foam::sixDoFRigidBodyMotion::maxConstraintIterations() const
{
return maxConstraintIters_;
return maxConstraintIterations_;
}
......
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