mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
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:
@ -49,7 +49,7 @@ sixDoFRigidBodyDisplacementPointPatchVectorField
|
||||
:
|
||||
fixedValuePointPatchField<vector>(p, iF),
|
||||
motion_(),
|
||||
p0_(p.localPoints()),
|
||||
initialPoints_(p.localPoints()),
|
||||
rhoInf_(1.0)
|
||||
{}
|
||||
|
||||
@ -71,13 +71,13 @@ sixDoFRigidBodyDisplacementPointPatchVectorField
|
||||
updateCoeffs();
|
||||
}
|
||||
|
||||
if (dict.found("p0"))
|
||||
if (dict.found("initialPoints"))
|
||||
{
|
||||
p0_ = vectorField("p0", dict , p.size());
|
||||
initialPoints_ = vectorField("initialPoints", dict , p.size());
|
||||
}
|
||||
else
|
||||
{
|
||||
p0_ = p.localPoints();
|
||||
initialPoints_ = p.localPoints();
|
||||
}
|
||||
}
|
||||
|
||||
@ -93,7 +93,7 @@ sixDoFRigidBodyDisplacementPointPatchVectorField
|
||||
:
|
||||
fixedValuePointPatchField<vector>(ptf, p, iF, mapper),
|
||||
motion_(ptf.motion_),
|
||||
p0_(ptf.p0_, mapper),
|
||||
initialPoints_(ptf.initialPoints_, mapper),
|
||||
rhoInf_(ptf.rhoInf_)
|
||||
{}
|
||||
|
||||
@ -107,7 +107,7 @@ sixDoFRigidBodyDisplacementPointPatchVectorField
|
||||
:
|
||||
fixedValuePointPatchField<vector>(ptf, iF),
|
||||
motion_(ptf.motion_),
|
||||
p0_(ptf.p0_),
|
||||
initialPoints_(ptf.initialPoints_),
|
||||
rhoInf_(ptf.rhoInf_)
|
||||
{}
|
||||
|
||||
@ -121,7 +121,7 @@ void sixDoFRigidBodyDisplacementPointPatchVectorField::autoMap
|
||||
{
|
||||
fixedValuePointPatchField<vector>::autoMap(m);
|
||||
|
||||
p0_.autoMap(m);
|
||||
initialPoints_.autoMap(m);
|
||||
}
|
||||
|
||||
|
||||
@ -136,7 +136,7 @@ void sixDoFRigidBodyDisplacementPointPatchVectorField::rmap
|
||||
|
||||
fixedValuePointPatchField<vector>::rmap(sDoFptf, addr);
|
||||
|
||||
p0_.rmap(sDoFptf.p0_, addr);
|
||||
initialPoints_.rmap(sDoFptf.initialPoints_, addr);
|
||||
}
|
||||
|
||||
|
||||
@ -186,7 +186,10 @@ void sixDoFRigidBodyDisplacementPointPatchVectorField::updateCoeffs()
|
||||
t.deltaTValue()
|
||||
);
|
||||
|
||||
Field<vector>::operator=(motion_.currentPosition(p0_) - p0_);
|
||||
Field<vector>::operator=
|
||||
(
|
||||
motion_.currentPosition(initialPoints_) - initialPoints_
|
||||
);
|
||||
|
||||
fixedValuePointPatchField<vector>::updateCoeffs();
|
||||
}
|
||||
@ -198,7 +201,7 @@ void sixDoFRigidBodyDisplacementPointPatchVectorField::write(Ostream& os) const
|
||||
motion_.write(os);
|
||||
os.writeKeyword("rhoInf")
|
||||
<< rhoInf_ << token::END_STATEMENT << nl;
|
||||
p0_.writeEntry("p0", os);
|
||||
initialPoints_.writeEntry("initialPoints", os);
|
||||
writeEntry("value", os);
|
||||
}
|
||||
|
||||
|
||||
@ -57,8 +57,8 @@ class sixDoFRigidBodyDisplacementPointPatchVectorField
|
||||
//- Six dof motion object
|
||||
sixDoFRigidBodyMotion motion_;
|
||||
|
||||
//- Reference positions of points on the patch
|
||||
pointField p0_;
|
||||
//- Initial positions of points on the patch
|
||||
pointField initialPoints_;
|
||||
|
||||
//- Reference density required by the forces object for
|
||||
// incompressible calculations
|
||||
|
||||
@ -15,7 +15,7 @@ License
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
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.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
@ -169,7 +169,8 @@ Foam::sixDoFRigidBodyMotion::sixDoFRigidBodyMotion()
|
||||
constraints_(),
|
||||
constraintNames_(),
|
||||
maxConstraintIterations_(0),
|
||||
refCentreOfMass_(vector::zero),
|
||||
initialCentreOfMass_(vector::zero),
|
||||
initialQ_(I),
|
||||
momentOfInertia_(diagTensor::one*VSMALL),
|
||||
mass_(VSMALL),
|
||||
report_(false)
|
||||
@ -185,7 +186,8 @@ Foam::sixDoFRigidBodyMotion::sixDoFRigidBodyMotion
|
||||
const vector& pi,
|
||||
const vector& tau,
|
||||
scalar mass,
|
||||
const point& refCentreOfMass,
|
||||
const point& initialCentreOfMass,
|
||||
const tensor& initialQ,
|
||||
const diagTensor& momentOfInertia,
|
||||
bool report
|
||||
)
|
||||
@ -204,7 +206,8 @@ Foam::sixDoFRigidBodyMotion::sixDoFRigidBodyMotion
|
||||
constraints_(),
|
||||
constraintNames_(),
|
||||
maxConstraintIterations_(0),
|
||||
refCentreOfMass_(refCentreOfMass),
|
||||
initialCentreOfMass_(initialCentreOfMass),
|
||||
initialQ_(initialQ),
|
||||
momentOfInertia_(momentOfInertia),
|
||||
mass_(mass),
|
||||
report_(report)
|
||||
@ -219,7 +222,14 @@ Foam::sixDoFRigidBodyMotion::sixDoFRigidBodyMotion(const dictionary& dict)
|
||||
constraints_(),
|
||||
constraintNames_(),
|
||||
maxConstraintIterations_(0),
|
||||
refCentreOfMass_(dict.lookupOrDefault("refCentreOfMass", centreOfMass())),
|
||||
initialCentreOfMass_
|
||||
(
|
||||
dict.lookupOrDefault("initialCentreOfMass", centreOfMass())
|
||||
),
|
||||
initialQ_
|
||||
(
|
||||
dict.lookupOrDefault("initialOrientation", Q())
|
||||
),
|
||||
momentOfInertia_(dict.lookup("momentOfInertia")),
|
||||
mass_(readScalar(dict.lookup("mass"))),
|
||||
report_(dict.lookupOrDefault<Switch>("report", false))
|
||||
@ -241,7 +251,8 @@ Foam::sixDoFRigidBodyMotion::sixDoFRigidBodyMotion
|
||||
constraints_(sDoFRBM.constraints()),
|
||||
constraintNames_(sDoFRBM.constraintNames()),
|
||||
maxConstraintIterations_(sDoFRBM.maxConstraintIterations()),
|
||||
refCentreOfMass_(sDoFRBM.refCentreOfMass()),
|
||||
initialCentreOfMass_(sDoFRBM.initialCentreOfMass()),
|
||||
initialQ_(sDoFRBM.initialQ()),
|
||||
momentOfInertia_(sDoFRBM.momentOfInertia()),
|
||||
mass_(sDoFRBM.mass()),
|
||||
report_(sDoFRBM.report())
|
||||
@ -433,7 +444,7 @@ void Foam::sixDoFRigidBodyMotion::updateForce
|
||||
|
||||
Foam::point Foam::sixDoFRigidBodyMotion::predictedPosition
|
||||
(
|
||||
const point& pt,
|
||||
const point& p0,
|
||||
const vector& deltaForce,
|
||||
const vector& deltaMoment,
|
||||
scalar deltaT
|
||||
@ -449,13 +460,17 @@ Foam::point Foam::sixDoFRigidBodyMotion::predictedPosition
|
||||
|
||||
rotate(QTemp, piTemp, deltaT);
|
||||
|
||||
return (centreOfMassTemp + (QTemp & (pt - refCentreOfMass_)));
|
||||
return
|
||||
(
|
||||
centreOfMassTemp
|
||||
+ (QTemp & initialQ_.T() & (p0 - initialCentreOfMass_))
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Foam::vector Foam::sixDoFRigidBodyMotion::predictedOrientation
|
||||
(
|
||||
const vector& v,
|
||||
const vector& v0,
|
||||
const vector& deltaMoment,
|
||||
scalar deltaT
|
||||
) const
|
||||
@ -466,7 +481,7 @@ Foam::vector Foam::sixDoFRigidBodyMotion::predictedOrientation
|
||||
|
||||
rotate(QTemp, piTemp, deltaT);
|
||||
|
||||
return (QTemp & v);
|
||||
return (QTemp & initialQ_.T() & v0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -104,10 +104,14 @@ class sixDoFRigidBodyMotion
|
||||
// constraints
|
||||
label maxConstraintIterations_;
|
||||
|
||||
//- Centre of mass of reference state
|
||||
point refCentreOfMass_;
|
||||
//- Centre of mass of initial state
|
||||
point initialCentreOfMass_;
|
||||
|
||||
//- Orientation of initial state
|
||||
tensor initialQ_;
|
||||
|
||||
//- Moment of inertia of the body in reference configuration
|
||||
// (Q = I)
|
||||
diagTensor momentOfInertia_;
|
||||
|
||||
//- Mass of the body
|
||||
@ -166,8 +170,11 @@ class sixDoFRigidBodyMotion
|
||||
// constraint iterations
|
||||
inline label maxConstraintIterations() const;
|
||||
|
||||
//- Return access to the centre of mass
|
||||
inline const point& refCentreOfMass() const;
|
||||
//- Return access to the initial centre of mass
|
||||
inline const point& initialCentreOfMass() const;
|
||||
|
||||
//- Return access to the initial orientation
|
||||
inline const tensor& initialQ() const;
|
||||
|
||||
//- Return access to the orientation
|
||||
inline const tensor& Q() const;
|
||||
@ -188,7 +195,10 @@ class sixDoFRigidBodyMotion
|
||||
// Edit
|
||||
|
||||
//- 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
|
||||
inline tensor& Q();
|
||||
@ -223,7 +233,8 @@ public:
|
||||
const vector& pi,
|
||||
const vector& tau,
|
||||
scalar mass,
|
||||
const point& refCentreOfMass,
|
||||
const point& initialCentreOfMass,
|
||||
const tensor& initialQ,
|
||||
const diagTensor& momentOfInertia,
|
||||
bool report = false
|
||||
);
|
||||
@ -274,40 +285,40 @@ public:
|
||||
scalar deltaT
|
||||
);
|
||||
|
||||
//- Transform the given reference state pointField by the
|
||||
// current motion state
|
||||
inline tmp<pointField> currentPosition(const pointField& refPts) const;
|
||||
|
||||
//- Transform the given reference state point by the current
|
||||
//- Transform the given initial state pointField by the current
|
||||
// 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
|
||||
inline vector currentOrientation(const vector& refDir) const;
|
||||
inline vector currentOrientation(const vector& dir0) const;
|
||||
|
||||
//- Access the orientation tensor, Q.
|
||||
// globalVector = Q & bodyLocalVector
|
||||
// bodyLocalVector = Q.T() & globalVector
|
||||
inline const tensor& currentOrientation() const;
|
||||
|
||||
//- Predict the position of the supplied point after deltaT
|
||||
// given the current motion state and the additional supplied
|
||||
// force and moment
|
||||
//- Predict the position of the supplied initial state point
|
||||
// after deltaT given the current motion state and the
|
||||
// additional supplied force and moment
|
||||
point predictedPosition
|
||||
(
|
||||
const point& pt,
|
||||
const point& p0,
|
||||
const vector& deltaForce,
|
||||
const vector& deltaMoment,
|
||||
scalar deltaT
|
||||
) const;
|
||||
|
||||
//- Predict the orientation of the supplied vector after deltaT
|
||||
// given the current motion state and the additional supplied
|
||||
// moment
|
||||
//- Predict the orientation of the supplied initial state
|
||||
// vector after deltaT given the current motion state and the
|
||||
// additional supplied moment
|
||||
vector predictedOrientation
|
||||
(
|
||||
const vector& v,
|
||||
const vector& v0,
|
||||
const vector& deltaMoment,
|
||||
scalar deltaT
|
||||
) const;
|
||||
|
||||
@ -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 * * * * * * * * * * * * * * //
|
||||
|
||||
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
|
||||
(
|
||||
const point& refPt
|
||||
const point& p0
|
||||
) const
|
||||
{
|
||||
return (centreOfMass() + (Q() & (refPt - refCentreOfMass_)));
|
||||
return
|
||||
(centreOfMass() + (Q() & initialQ_.T() & (p0 - initialCentreOfMass_)));
|
||||
}
|
||||
|
||||
|
||||
inline Foam::vector Foam::sixDoFRigidBodyMotion::currentOrientation
|
||||
(
|
||||
const vector& refDir
|
||||
const vector& dir0
|
||||
) const
|
||||
{
|
||||
return (Q() & refDir);
|
||||
return (Q() & initialQ_.T() & dir0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -33,8 +33,10 @@ void Foam::sixDoFRigidBodyMotion::write(Ostream& os) const
|
||||
{
|
||||
motionState_.write(os);
|
||||
|
||||
os.writeKeyword("refCentreOfMass")
|
||||
<< refCentreOfMass_ << token::END_STATEMENT << nl;
|
||||
os.writeKeyword("initialCentreOfMass")
|
||||
<< initialCentreOfMass_ << token::END_STATEMENT << nl;
|
||||
os.writeKeyword("initialOrientation")
|
||||
<< initialQ_ << token::END_STATEMENT << nl;
|
||||
os.writeKeyword("momentOfInertia")
|
||||
<< momentOfInertia_ << token::END_STATEMENT << nl;
|
||||
os.writeKeyword("mass")
|
||||
@ -112,7 +114,8 @@ void Foam::sixDoFRigidBodyMotion::write(Ostream& os) const
|
||||
Foam::Istream& Foam::operator>>(Istream& is, sixDoFRigidBodyMotion& sDoFRBM)
|
||||
{
|
||||
is >> sDoFRBM.motionState_
|
||||
>> sDoFRBM.refCentreOfMass_
|
||||
>> sDoFRBM.initialCentreOfMass_
|
||||
>> sDoFRBM.initialQ_
|
||||
>> sDoFRBM.momentOfInertia_
|
||||
>> sDoFRBM.mass_;
|
||||
|
||||
@ -134,7 +137,8 @@ Foam::Ostream& Foam::operator<<
|
||||
)
|
||||
{
|
||||
os << sDoFRBM.motionState()
|
||||
<< token::SPACE << sDoFRBM.refCentreOfMass()
|
||||
<< token::SPACE << sDoFRBM.initialCentreOfMass()
|
||||
<< token::SPACE << sDoFRBM.initialQ()
|
||||
<< token::SPACE << sDoFRBM.momentOfInertia()
|
||||
<< token::SPACE << sDoFRBM.mass();
|
||||
|
||||
|
||||
@ -64,11 +64,11 @@ Foam::sixDoFRigidBodyMotionState::sixDoFRigidBodyMotionState
|
||||
)
|
||||
:
|
||||
centreOfMass_(dict.lookup("centreOfMass")),
|
||||
Q_(dict.lookupOrDefault("Q", tensor(I))),
|
||||
v_(dict.lookupOrDefault("v", vector::zero)),
|
||||
a_(dict.lookupOrDefault("a", vector::zero)),
|
||||
pi_(dict.lookupOrDefault("pi", vector::zero)),
|
||||
tau_(dict.lookupOrDefault("tau", vector::zero))
|
||||
Q_(dict.lookupOrDefault("orientation", tensor(I))),
|
||||
v_(dict.lookupOrDefault("velocity", vector::zero)),
|
||||
a_(dict.lookupOrDefault("acceleration", vector::zero)),
|
||||
pi_(dict.lookupOrDefault("angularMomentum", vector::zero)),
|
||||
tau_(dict.lookupOrDefault("torque", vector::zero))
|
||||
{}
|
||||
|
||||
|
||||
|
||||
@ -33,15 +33,15 @@ void Foam::sixDoFRigidBodyMotionState::write(Ostream& os) const
|
||||
{
|
||||
os.writeKeyword("centreOfMass")
|
||||
<< centreOfMass_ << token::END_STATEMENT << nl;
|
||||
os.writeKeyword("Q")
|
||||
os.writeKeyword("orientation")
|
||||
<< Q_ << token::END_STATEMENT << nl;
|
||||
os.writeKeyword("v")
|
||||
os.writeKeyword("velocity")
|
||||
<< v_ << token::END_STATEMENT << nl;
|
||||
os.writeKeyword("a")
|
||||
os.writeKeyword("acceleration")
|
||||
<< a_ << token::END_STATEMENT << nl;
|
||||
os.writeKeyword("pi")
|
||||
os.writeKeyword("angularMomentum")
|
||||
<< pi_ << token::END_STATEMENT << nl;
|
||||
os.writeKeyword("tau")
|
||||
os.writeKeyword("torque")
|
||||
<< tau_ << token::END_STATEMENT << nl;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user