35void Foam::sixDoFRigidBodyMotion::applyRestraints()
37 if (restraints_.empty())
48 Info<<
"Restraint " << restraints_[rI].name() <<
": ";
61 restraints_[rI].restrain(*
this, rP, rF, rM);
85 initialCentreOfMass_(
Zero),
86 initialCentreOfRotation_(
Zero),
93 updateConstraints_(false),
106 motionState_(stateDict),
116 "initialCentreOfMass",
120 initialCentreOfRotation_(initialCentreOfMass_),
125 "initialOrientation",
129 mass_(
dict.get<scalar>(
"mass")),
131 aRelax_(
dict.getOrDefault<scalar>(
"accelerationRelaxation", 1)),
132 aDamp_(
dict.getOrDefault<scalar>(
"accelerationDamping", 1)),
133 report_(
dict.getOrDefault(
"report", false)),
134 updateConstraints_(
dict.getOrDefault(
"updateConstraints", false)),
144 vector R(initialCentreOfMass_ - initialCentreOfRotation_);
152 if (!stateDict.
found(
"centreOfRotation"))
159 motionState0_ = motionState_;
165 const sixDoFRigidBodyMotion& sDoFRBM
168 time_(sDoFRBM.time_),
169 motionState_(sDoFRBM.motionState_),
170 motionState0_(sDoFRBM.motionState0_),
171 restraints_(sDoFRBM.restraints_),
172 constraints_(sDoFRBM.constraints_),
173 tConstraints_(sDoFRBM.tConstraints_),
174 rConstraints_(sDoFRBM.rConstraints_),
175 initialCentreOfMass_(sDoFRBM.initialCentreOfMass_),
176 initialCentreOfRotation_(sDoFRBM.initialCentreOfRotation_),
177 initialQ_(sDoFRBM.initialQ_),
178 mass_(sDoFRBM.mass_),
179 momentOfInertia_(sDoFRBM.momentOfInertia_),
180 aRelax_(sDoFRBM.aRelax_),
181 aDamp_(sDoFRBM.aDamp_),
182 report_(sDoFRBM.report_),
183 updateConstraints_(sDoFRBM.updateConstraints_),
184 solver_(sDoFRBM.solver_.clone())
201 if (
dict.found(
"restraints"))
207 restraints_.setSize(restraintDict.
size());
209 for (
const entry& dEntry : restraintDict)
225 restraints_.setSize(i);
241 constraints_.setSize(constraintDict.size());
246 for (
const entry& dEntry : constraintDict)
261 constraints_[i].setCentreOfRotation(initialCentreOfRotation_);
262 constraints_[i].constrainTranslation(pct);
263 constraints_[i].constrainRotation(pcr);
269 constraints_.setSize(i);
272 rConstraints_ = pcr.constraintTransformation();
274 Info<<
"Translational constraint tensor " << tConstraints_ <<
nl
275 <<
"Rotational constraint tensor " << rConstraints_ <<
endl;
280void Foam::sixDoFRigidBodyMotion::updateAcceleration
286 static bool first =
true;
290 vector tauPrevIter = tau();
294 tau() = (Q().T() & tauGlobal);
300 a() = aRelax_*a() + (1 - aRelax_)*aPrevIter;
301 tau() = aRelax_*tau() + (1 - aRelax_)*tauPrevIter;
312 if (!updateConstraints_)
322 constraints_[i].setCentreOfRotation(initialCentreOfRotation_);
323 constraints_[i].constrainTranslation(pct);
324 constraints_[i].constrainRotation(pcr);
328 rConstraints_ = pcr.constraintTransformation();
330 Info<<
"Translational constraint tensor " << tConstraints_ <<
nl
331 <<
"Rotational constraint tensor " << rConstraints_ <<
endl;
346 solver_->solve(firstIter, fGlobal, tauGlobal, deltaT, deltaT0);
360 Info<<
"6-DoF rigid body motion" <<
nl
361 <<
" Centre of rotation: " << centreOfRotation() <<
nl
362 <<
" Centre of mass: " << centreOfMass() <<
nl
364 <<
" Linear velocity: " <<
v() <<
nl
365 <<
" Angular velocity: " <<
omega()
378 + (Q() & initialQ_.T() & (initialPoints - initialCentreOfRotation_))
392 centreOfRotation() - initialCentreOfRotation(),
397 auto&
points = tpoints.ref();
402 if (scale[pointi] > SMALL)
405 if (scale[pointi] > 1 - SMALL)
415 initialCentreOfRotation()
418 initialPoints[pointi]
419 - initialCentreOfRotation()
#define R(A, B, C, D, E, F, K, M)
label size() const noexcept
The number of elements in list.
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
static bool master(const label communicator=worldComm)
True if process corresponds to the master rank in the communicator.
@ broadcast
broadcast [MPI]
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
const dictionary & subDict(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a sub-dictionary.
bool found(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find an entry (const access) with the given keyword.
A keyword and a list of tokens is an 'entry'.
A class representing the concept of 1 (one) that can be used to avoid manipulating objects known to b...
Accumulates point constraints through successive applications of the applyConstraint function.
tensor constraintTransformation() const
Return the accumulated constraint transformation tensor.
Quaternion class used to perform rotations in 3D space.
Septernion class used to perform translations and rotations in 3D space.
vector invTransformPoint(const vector &v) const
Inverse Transform the given coordinate point.
static const septernion I
static autoPtr< sixDoFRigidBodyMotionConstraint > New(const word &name, const dictionary &sDoFRBMCDict, const sixDoFRigidBodyMotion &motion)
Select constructed from the sDoFRBMCDict dictionary and Time.
static autoPtr< sixDoFRigidBodyMotionRestraint > New(const word &name, const dictionary &sDoFRBMRDict)
Select constructed from the sDoFRBMRDict dictionary and Time.
const point & centreOfRotation() const
Return access to the centre of mass.
point centreOfMass() const
Return the current centre of mass.
void update(bool firstIter, const vector &fGlobal, const vector &tauGlobal, scalar deltaT, scalar deltaT0)
Symplectic integration of velocities, orientation and position.
const vector & v() const
Return the current velocity.
const Time & time() const
Return time.
void status() const
Report the status of the motion.
const tensor & orientation() const
Return the orientation tensor, Q.
void addConstraints(const dictionary &dict)
Add restraints to the motion, public to allow external.
bool updateConstraints() const
Return the update-constraints flag.
sixDoFRigidBodyMotion(const Time &)
Construct null.
point transform(const point &initialPoints) const
Transform the given initial state point by the current motion.
~sixDoFRigidBodyMotion()
Destructor.
vector omega() const
Return the angular velocity in the global frame.
void addRestraints(const dictionary &dict)
Add restraints to the motion, public to allow external.
const point & centreOfRotation() const
Return the current centre of rotation.
friend class sixDoFSolver
A class for managing temporary objects.
static tmp< T > New(Args &&... args)
Construct tmp with forwarding arguments.
gmvFile<< "tracers "<< particles.size()<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().x()<< " ";}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().y()<< " ";}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().z()<< " ";}gmvFile<< nl;forAll(lagrangianScalarNames, i){ word name=lagrangianScalarNames[i];IOField< scalar > s(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh > > &tf1, const word &name, const dimensionSet &dimensions, const bool initCopy=false)
Global function forwards to reuseTmpDimensionedField::New.
DiagTensor< scalar > diagTensor
DiagTensor of scalars, i.e. DiagTensor<scalar>.
dimensionedSymmTensor sqr(const dimensionedVector &dv)
refinementData transform(const tensor &, const refinementData val)
No-op rotational transform for base types.
messageStream Info
Information stream (stdout output on master, null elsewhere).
static const Identity< scalar > I
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
Ostream & endl(Ostream &os)
Add newline and flush stream.
vector point
Point is a vector.
static constexpr const zero Zero
Global zero (0).
vectorField pointField
pointField is a vectorField.
quaternion slerp(const quaternion &qa, const quaternion &qb, const scalar t)
Spherical linear interpolation of quaternions.
void diag(pointPatchField< vector > &, const pointPatchField< tensor > &)
dimensioned< typename typeOfMag< Type >::type > magSqr(const dimensioned< Type > &dt)
constexpr char nl
The newline '\n' character (0x0a).
#define forAll(list, i)
Loop across all elements in list.