ENH: sixDoFRigidBodyMotion. Variable renaming and addition of

initialOrientation.

Rename of IO to more understandable terms.  Rename ref to initial
where correct - ref is to do with the object being in Q = I state,
inital is to do with where things are when the motion starts and
pointDisplacement and value are zero.

Adding initialOrientation so that non Q = I initial states are
correct.
This commit is contained in:
graham
2010-02-08 19:10:04 +00:00
parent ea36c756d4
commit 86de68de76
8 changed files with 117 additions and 68 deletions

View File

@ -49,7 +49,7 @@ sixDoFRigidBodyDisplacementPointPatchVectorField
: :
fixedValuePointPatchField<vector>(p, iF), fixedValuePointPatchField<vector>(p, iF),
motion_(), motion_(),
p0_(p.localPoints()), initialPoints_(p.localPoints()),
rhoInf_(1.0) rhoInf_(1.0)
{} {}
@ -71,13 +71,13 @@ sixDoFRigidBodyDisplacementPointPatchVectorField
updateCoeffs(); updateCoeffs();
} }
if (dict.found("p0")) if (dict.found("initialPoints"))
{ {
p0_ = vectorField("p0", dict , p.size()); initialPoints_ = vectorField("initialPoints", dict , p.size());
} }
else else
{ {
p0_ = p.localPoints(); initialPoints_ = p.localPoints();
} }
} }
@ -93,7 +93,7 @@ sixDoFRigidBodyDisplacementPointPatchVectorField
: :
fixedValuePointPatchField<vector>(ptf, p, iF, mapper), fixedValuePointPatchField<vector>(ptf, p, iF, mapper),
motion_(ptf.motion_), motion_(ptf.motion_),
p0_(ptf.p0_, mapper), initialPoints_(ptf.initialPoints_, mapper),
rhoInf_(ptf.rhoInf_) rhoInf_(ptf.rhoInf_)
{} {}
@ -107,7 +107,7 @@ sixDoFRigidBodyDisplacementPointPatchVectorField
: :
fixedValuePointPatchField<vector>(ptf, iF), fixedValuePointPatchField<vector>(ptf, iF),
motion_(ptf.motion_), motion_(ptf.motion_),
p0_(ptf.p0_), initialPoints_(ptf.initialPoints_),
rhoInf_(ptf.rhoInf_) rhoInf_(ptf.rhoInf_)
{} {}
@ -121,7 +121,7 @@ void sixDoFRigidBodyDisplacementPointPatchVectorField::autoMap
{ {
fixedValuePointPatchField<vector>::autoMap(m); fixedValuePointPatchField<vector>::autoMap(m);
p0_.autoMap(m); initialPoints_.autoMap(m);
} }
@ -136,7 +136,7 @@ void sixDoFRigidBodyDisplacementPointPatchVectorField::rmap
fixedValuePointPatchField<vector>::rmap(sDoFptf, addr); fixedValuePointPatchField<vector>::rmap(sDoFptf, addr);
p0_.rmap(sDoFptf.p0_, addr); initialPoints_.rmap(sDoFptf.initialPoints_, addr);
} }
@ -186,7 +186,10 @@ void sixDoFRigidBodyDisplacementPointPatchVectorField::updateCoeffs()
t.deltaTValue() t.deltaTValue()
); );
Field<vector>::operator=(motion_.currentPosition(p0_) - p0_); Field<vector>::operator=
(
motion_.currentPosition(initialPoints_) - initialPoints_
);
fixedValuePointPatchField<vector>::updateCoeffs(); fixedValuePointPatchField<vector>::updateCoeffs();
} }
@ -198,7 +201,7 @@ void sixDoFRigidBodyDisplacementPointPatchVectorField::write(Ostream& os) const
motion_.write(os); motion_.write(os);
os.writeKeyword("rhoInf") os.writeKeyword("rhoInf")
<< rhoInf_ << token::END_STATEMENT << nl; << rhoInf_ << token::END_STATEMENT << nl;
p0_.writeEntry("p0", os); initialPoints_.writeEntry("initialPoints", os);
writeEntry("value", os); writeEntry("value", os);
} }

View File

@ -57,8 +57,8 @@ class sixDoFRigidBodyDisplacementPointPatchVectorField
//- Six dof motion object //- Six dof motion object
sixDoFRigidBodyMotion motion_; sixDoFRigidBodyMotion motion_;
//- Reference positions of points on the patch //- Initial positions of points on the patch
pointField p0_; pointField initialPoints_;
//- Reference density required by the forces object for //- Reference density required by the forces object for
// incompressible calculations // incompressible calculations

View File

@ -15,7 +15,7 @@ License
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License FITNESS FOR A PARTICLUAR PURPOSE. See the GNU General Public License
for more details. for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
@ -169,7 +169,8 @@ Foam::sixDoFRigidBodyMotion::sixDoFRigidBodyMotion()
constraints_(), constraints_(),
constraintNames_(), constraintNames_(),
maxConstraintIterations_(0), maxConstraintIterations_(0),
refCentreOfMass_(vector::zero), initialCentreOfMass_(vector::zero),
initialQ_(I),
momentOfInertia_(diagTensor::one*VSMALL), momentOfInertia_(diagTensor::one*VSMALL),
mass_(VSMALL), mass_(VSMALL),
report_(false) report_(false)
@ -185,7 +186,8 @@ Foam::sixDoFRigidBodyMotion::sixDoFRigidBodyMotion
const vector& pi, const vector& pi,
const vector& tau, const vector& tau,
scalar mass, scalar mass,
const point& refCentreOfMass, const point& initialCentreOfMass,
const tensor& initialQ,
const diagTensor& momentOfInertia, const diagTensor& momentOfInertia,
bool report bool report
) )
@ -204,7 +206,8 @@ Foam::sixDoFRigidBodyMotion::sixDoFRigidBodyMotion
constraints_(), constraints_(),
constraintNames_(), constraintNames_(),
maxConstraintIterations_(0), maxConstraintIterations_(0),
refCentreOfMass_(refCentreOfMass), initialCentreOfMass_(initialCentreOfMass),
initialQ_(initialQ),
momentOfInertia_(momentOfInertia), momentOfInertia_(momentOfInertia),
mass_(mass), mass_(mass),
report_(report) report_(report)
@ -219,7 +222,14 @@ Foam::sixDoFRigidBodyMotion::sixDoFRigidBodyMotion(const dictionary& dict)
constraints_(), constraints_(),
constraintNames_(), constraintNames_(),
maxConstraintIterations_(0), maxConstraintIterations_(0),
refCentreOfMass_(dict.lookupOrDefault("refCentreOfMass", centreOfMass())), initialCentreOfMass_
(
dict.lookupOrDefault("initialCentreOfMass", centreOfMass())
),
initialQ_
(
dict.lookupOrDefault("initialOrientation", Q())
),
momentOfInertia_(dict.lookup("momentOfInertia")), momentOfInertia_(dict.lookup("momentOfInertia")),
mass_(readScalar(dict.lookup("mass"))), mass_(readScalar(dict.lookup("mass"))),
report_(dict.lookupOrDefault<Switch>("report", false)) report_(dict.lookupOrDefault<Switch>("report", false))
@ -241,7 +251,8 @@ Foam::sixDoFRigidBodyMotion::sixDoFRigidBodyMotion
constraints_(sDoFRBM.constraints()), constraints_(sDoFRBM.constraints()),
constraintNames_(sDoFRBM.constraintNames()), constraintNames_(sDoFRBM.constraintNames()),
maxConstraintIterations_(sDoFRBM.maxConstraintIterations()), maxConstraintIterations_(sDoFRBM.maxConstraintIterations()),
refCentreOfMass_(sDoFRBM.refCentreOfMass()), initialCentreOfMass_(sDoFRBM.initialCentreOfMass()),
initialQ_(sDoFRBM.initialQ()),
momentOfInertia_(sDoFRBM.momentOfInertia()), momentOfInertia_(sDoFRBM.momentOfInertia()),
mass_(sDoFRBM.mass()), mass_(sDoFRBM.mass()),
report_(sDoFRBM.report()) report_(sDoFRBM.report())
@ -433,7 +444,7 @@ void Foam::sixDoFRigidBodyMotion::updateForce
Foam::point Foam::sixDoFRigidBodyMotion::predictedPosition Foam::point Foam::sixDoFRigidBodyMotion::predictedPosition
( (
const point& pt, const point& p0,
const vector& deltaForce, const vector& deltaForce,
const vector& deltaMoment, const vector& deltaMoment,
scalar deltaT scalar deltaT
@ -449,13 +460,17 @@ Foam::point Foam::sixDoFRigidBodyMotion::predictedPosition
rotate(QTemp, piTemp, deltaT); rotate(QTemp, piTemp, deltaT);
return (centreOfMassTemp + (QTemp & (pt - refCentreOfMass_))); return
(
centreOfMassTemp
+ (QTemp & initialQ_.T() & (p0 - initialCentreOfMass_))
);
} }
Foam::vector Foam::sixDoFRigidBodyMotion::predictedOrientation Foam::vector Foam::sixDoFRigidBodyMotion::predictedOrientation
( (
const vector& v, const vector& v0,
const vector& deltaMoment, const vector& deltaMoment,
scalar deltaT scalar deltaT
) const ) const
@ -466,7 +481,7 @@ Foam::vector Foam::sixDoFRigidBodyMotion::predictedOrientation
rotate(QTemp, piTemp, deltaT); rotate(QTemp, piTemp, deltaT);
return (QTemp & v); return (QTemp & initialQ_.T() & v0);
} }

View File

@ -104,10 +104,14 @@ class sixDoFRigidBodyMotion
// constraints // constraints
label maxConstraintIterations_; label maxConstraintIterations_;
//- Centre of mass of reference state //- Centre of mass of initial state
point refCentreOfMass_; point initialCentreOfMass_;
//- Orientation of initial state
tensor initialQ_;
//- Moment of inertia of the body in reference configuration //- Moment of inertia of the body in reference configuration
// (Q = I)
diagTensor momentOfInertia_; diagTensor momentOfInertia_;
//- Mass of the body //- Mass of the body
@ -166,8 +170,11 @@ class sixDoFRigidBodyMotion
// constraint iterations // constraint iterations
inline label maxConstraintIterations() const; inline label maxConstraintIterations() const;
//- Return access to the centre of mass //- Return access to the initial centre of mass
inline const point& refCentreOfMass() const; inline const point& initialCentreOfMass() const;
//- Return access to the initial orientation
inline const tensor& initialQ() const;
//- Return access to the orientation //- Return access to the orientation
inline const tensor& Q() const; inline const tensor& Q() const;
@ -188,7 +195,10 @@ class sixDoFRigidBodyMotion
// Edit // Edit
//- Return access to the centre of mass //- Return access to the centre of mass
inline point& refCentreOfMass(); inline point& initialCentreOfMass();
//- Return access to the centre of mass
inline tensor& initialQ();
//- Return non-const access to the orientation //- Return non-const access to the orientation
inline tensor& Q(); inline tensor& Q();
@ -223,7 +233,8 @@ public:
const vector& pi, const vector& pi,
const vector& tau, const vector& tau,
scalar mass, scalar mass,
const point& refCentreOfMass, const point& initialCentreOfMass,
const tensor& initialQ,
const diagTensor& momentOfInertia, const diagTensor& momentOfInertia,
bool report = false bool report = false
); );
@ -274,40 +285,40 @@ public:
scalar deltaT scalar deltaT
); );
//- Transform the given reference state pointField by the //- Transform the given initial state pointField by the current
// current motion state
inline tmp<pointField> currentPosition(const pointField& refPts) const;
//- Transform the given reference state point by the current
// motion state // motion state
inline point currentPosition(const point& refPt) const; inline tmp<pointField> currentPosition(const pointField& p0) const;
//- Transform the given reference state direction by the current //- Transform the given initial state point by the current motion
// state
inline point currentPosition(const point& p0) const;
//- Transform the given initial state direction by the current
// motion state // motion state
inline vector currentOrientation(const vector& refDir) const; inline vector currentOrientation(const vector& dir0) const;
//- Access the orientation tensor, Q. //- Access the orientation tensor, Q.
// globalVector = Q & bodyLocalVector // globalVector = Q & bodyLocalVector
// bodyLocalVector = Q.T() & globalVector // bodyLocalVector = Q.T() & globalVector
inline const tensor& currentOrientation() const; inline const tensor& currentOrientation() const;
//- Predict the position of the supplied point after deltaT //- Predict the position of the supplied initial state point
// given the current motion state and the additional supplied // after deltaT given the current motion state and the
// force and moment // additional supplied force and moment
point predictedPosition point predictedPosition
( (
const point& pt, const point& p0,
const vector& deltaForce, const vector& deltaForce,
const vector& deltaMoment, const vector& deltaMoment,
scalar deltaT scalar deltaT
) const; ) const;
//- Predict the orientation of the supplied vector after deltaT //- Predict the orientation of the supplied initial state
// given the current motion state and the additional supplied // vector after deltaT given the current motion state and the
// moment // additional supplied moment
vector predictedOrientation vector predictedOrientation
( (
const vector& v, const vector& v0,
const vector& deltaMoment, const vector& deltaMoment,
scalar deltaT scalar deltaT
) const; ) const;

View File

@ -133,9 +133,17 @@ inline Foam::label Foam::sixDoFRigidBodyMotion::maxConstraintIterations() const
} }
inline const Foam::point& Foam::sixDoFRigidBodyMotion::refCentreOfMass() const inline const Foam::point&
Foam::sixDoFRigidBodyMotion::initialCentreOfMass() const
{ {
return refCentreOfMass_; return initialCentreOfMass_;
}
inline const Foam::tensor&
Foam::sixDoFRigidBodyMotion::initialQ() const
{
return initialQ_;
} }
@ -169,9 +177,15 @@ inline const Foam::vector& Foam::sixDoFRigidBodyMotion::tau() const
} }
inline Foam::point& Foam::sixDoFRigidBodyMotion::refCentreOfMass() inline Foam::point& Foam::sixDoFRigidBodyMotion::initialCentreOfMass()
{ {
return refCentreOfMass_; return initialCentreOfMass_;
}
inline Foam::tensor& Foam::sixDoFRigidBodyMotion::initialQ()
{
return initialQ_;
} }
@ -208,27 +222,29 @@ inline Foam::vector& Foam::sixDoFRigidBodyMotion::tau()
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
inline Foam::tmp<Foam::pointField> inline Foam::tmp<Foam::pointField>
Foam::sixDoFRigidBodyMotion::currentPosition(const pointField& refPts) const Foam::sixDoFRigidBodyMotion::currentPosition(const pointField& p0) const
{ {
return (centreOfMass() + (Q() & (refPts - refCentreOfMass_))); return
(centreOfMass() + (Q() & initialQ_.T() & (p0 - initialCentreOfMass_)));
} }
inline Foam::point Foam::sixDoFRigidBodyMotion::currentPosition inline Foam::point Foam::sixDoFRigidBodyMotion::currentPosition
( (
const point& refPt const point& p0
) const ) const
{ {
return (centreOfMass() + (Q() & (refPt - refCentreOfMass_))); return
(centreOfMass() + (Q() & initialQ_.T() & (p0 - initialCentreOfMass_)));
} }
inline Foam::vector Foam::sixDoFRigidBodyMotion::currentOrientation inline Foam::vector Foam::sixDoFRigidBodyMotion::currentOrientation
( (
const vector& refDir const vector& dir0
) const ) const
{ {
return (Q() & refDir); return (Q() & initialQ_.T() & dir0);
} }

View File

@ -33,8 +33,10 @@ void Foam::sixDoFRigidBodyMotion::write(Ostream& os) const
{ {
motionState_.write(os); motionState_.write(os);
os.writeKeyword("refCentreOfMass") os.writeKeyword("initialCentreOfMass")
<< refCentreOfMass_ << token::END_STATEMENT << nl; << initialCentreOfMass_ << token::END_STATEMENT << nl;
os.writeKeyword("initialOrientation")
<< initialQ_ << token::END_STATEMENT << nl;
os.writeKeyword("momentOfInertia") os.writeKeyword("momentOfInertia")
<< momentOfInertia_ << token::END_STATEMENT << nl; << momentOfInertia_ << token::END_STATEMENT << nl;
os.writeKeyword("mass") os.writeKeyword("mass")
@ -112,7 +114,8 @@ void Foam::sixDoFRigidBodyMotion::write(Ostream& os) const
Foam::Istream& Foam::operator>>(Istream& is, sixDoFRigidBodyMotion& sDoFRBM) Foam::Istream& Foam::operator>>(Istream& is, sixDoFRigidBodyMotion& sDoFRBM)
{ {
is >> sDoFRBM.motionState_ is >> sDoFRBM.motionState_
>> sDoFRBM.refCentreOfMass_ >> sDoFRBM.initialCentreOfMass_
>> sDoFRBM.initialQ_
>> sDoFRBM.momentOfInertia_ >> sDoFRBM.momentOfInertia_
>> sDoFRBM.mass_; >> sDoFRBM.mass_;
@ -134,7 +137,8 @@ Foam::Ostream& Foam::operator<<
) )
{ {
os << sDoFRBM.motionState() os << sDoFRBM.motionState()
<< token::SPACE << sDoFRBM.refCentreOfMass() << token::SPACE << sDoFRBM.initialCentreOfMass()
<< token::SPACE << sDoFRBM.initialQ()
<< token::SPACE << sDoFRBM.momentOfInertia() << token::SPACE << sDoFRBM.momentOfInertia()
<< token::SPACE << sDoFRBM.mass(); << token::SPACE << sDoFRBM.mass();

View File

@ -64,11 +64,11 @@ Foam::sixDoFRigidBodyMotionState::sixDoFRigidBodyMotionState
) )
: :
centreOfMass_(dict.lookup("centreOfMass")), centreOfMass_(dict.lookup("centreOfMass")),
Q_(dict.lookupOrDefault("Q", tensor(I))), Q_(dict.lookupOrDefault("orientation", tensor(I))),
v_(dict.lookupOrDefault("v", vector::zero)), v_(dict.lookupOrDefault("velocity", vector::zero)),
a_(dict.lookupOrDefault("a", vector::zero)), a_(dict.lookupOrDefault("acceleration", vector::zero)),
pi_(dict.lookupOrDefault("pi", vector::zero)), pi_(dict.lookupOrDefault("angularMomentum", vector::zero)),
tau_(dict.lookupOrDefault("tau", vector::zero)) tau_(dict.lookupOrDefault("torque", vector::zero))
{} {}

View File

@ -33,15 +33,15 @@ void Foam::sixDoFRigidBodyMotionState::write(Ostream& os) const
{ {
os.writeKeyword("centreOfMass") os.writeKeyword("centreOfMass")
<< centreOfMass_ << token::END_STATEMENT << nl; << centreOfMass_ << token::END_STATEMENT << nl;
os.writeKeyword("Q") os.writeKeyword("orientation")
<< Q_ << token::END_STATEMENT << nl; << Q_ << token::END_STATEMENT << nl;
os.writeKeyword("v") os.writeKeyword("velocity")
<< v_ << token::END_STATEMENT << nl; << v_ << token::END_STATEMENT << nl;
os.writeKeyword("a") os.writeKeyword("acceleration")
<< a_ << token::END_STATEMENT << nl; << a_ << token::END_STATEMENT << nl;
os.writeKeyword("pi") os.writeKeyword("angularMomentum")
<< pi_ << token::END_STATEMENT << nl; << pi_ << token::END_STATEMENT << nl;
os.writeKeyword("tau") os.writeKeyword("torque")
<< tau_ << token::END_STATEMENT << nl; << tau_ << token::END_STATEMENT << nl;
} }