mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENC: sixDoFRigidBodyMotion. Adding writing of restraints and
constraints to dictionary.
This commit is contained in:
@ -45,7 +45,9 @@ void Foam::sixDoFRigidBodyMotion::applyRestraints()
|
|||||||
|
|
||||||
restraints_[rI].restrain(*this, rP, rF, rM);
|
restraints_[rI].restrain(*this, rP, rF, rM);
|
||||||
|
|
||||||
// Info<< "Restraint " << rI << " force " << rF << endl;
|
// Info<< "Restraint " << rI << " force " << rF << nl
|
||||||
|
// << "Restraint " << rI << " moment " << rM
|
||||||
|
// << endl;
|
||||||
|
|
||||||
a() += rF/mass_;
|
a() += rF/mass_;
|
||||||
|
|
||||||
@ -122,8 +124,8 @@ void Foam::sixDoFRigidBodyMotion::applyConstraints(scalar deltaT)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
Info<< "sixDoFRigidBodyMotion constraints converged in "
|
Info<< "sixDoFRigidBodyMotion constraints converged in "
|
||||||
<< iter << " iterations" << nl
|
<< iter << " iterations"
|
||||||
// << "Constraint force: " << cFA << nl
|
// << nl << "Constraint force: " << cFA << nl
|
||||||
// << "Constraint moment: " << cMA
|
// << "Constraint moment: " << cMA
|
||||||
<< endl;
|
<< endl;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -39,6 +39,7 @@ Foam::sixDoFRigidBodyMotionConstraint::sixDoFRigidBodyMotionConstraint
|
|||||||
const dictionary& sDoFRBMCDict
|
const dictionary& sDoFRBMCDict
|
||||||
)
|
)
|
||||||
:
|
:
|
||||||
|
name_(fileName(sDoFRBMCDict.name().name()).components(token::COLON).last()),
|
||||||
sDoFRBMCCoeffs_
|
sDoFRBMCCoeffs_
|
||||||
(
|
(
|
||||||
sDoFRBMCDict.subDict
|
sDoFRBMCDict.subDict
|
||||||
@ -70,6 +71,12 @@ bool Foam::sixDoFRigidBodyMotionConstraint::read
|
|||||||
{
|
{
|
||||||
tolerance_ = (readScalar(sDoFRBMCDict.lookup("tolerance")));
|
tolerance_ = (readScalar(sDoFRBMCDict.lookup("tolerance")));
|
||||||
|
|
||||||
|
relaxationFactor_ = sDoFRBMCDict.lookupOrDefault<scalar>
|
||||||
|
(
|
||||||
|
"relaxationFactor",
|
||||||
|
1
|
||||||
|
);
|
||||||
|
|
||||||
sDoFRBMCCoeffs_ = sDoFRBMCDict.subDict(type() + "Coeffs");
|
sDoFRBMCCoeffs_ = sDoFRBMCDict.subDict(type() + "Coeffs");
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@ -70,6 +70,9 @@ protected:
|
|||||||
|
|
||||||
// Protected data
|
// Protected data
|
||||||
|
|
||||||
|
//- Name of the constraint in dictionary
|
||||||
|
word name_;
|
||||||
|
|
||||||
//- Constraint model specific coefficient dictionary
|
//- Constraint model specific coefficient dictionary
|
||||||
dictionary sDoFRBMCCoeffs_;
|
dictionary sDoFRBMCCoeffs_;
|
||||||
|
|
||||||
@ -143,6 +146,32 @@ public:
|
|||||||
|
|
||||||
//- Update properties from given dictionary
|
//- Update properties from given dictionary
|
||||||
virtual bool read(const dictionary& sDoFRBMCDict) = 0;
|
virtual bool read(const dictionary& sDoFRBMCDict) = 0;
|
||||||
|
|
||||||
|
// Access
|
||||||
|
|
||||||
|
//- Return access to the name of the restraint
|
||||||
|
inline const word& name() const
|
||||||
|
{
|
||||||
|
return name_;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Return access to sDoFRBMCCoeffs
|
||||||
|
inline const dictionary& coeffDict() const
|
||||||
|
{
|
||||||
|
return sDoFRBMCCoeffs_;
|
||||||
|
}
|
||||||
|
|
||||||
|
//- Return access to the tolerance
|
||||||
|
inline scalar tolerance() const
|
||||||
|
{
|
||||||
|
return tolerance_;
|
||||||
|
}
|
||||||
|
|
||||||
|
//- Return access to the relaxationFactor
|
||||||
|
inline scalar relaxationFactor() const
|
||||||
|
{
|
||||||
|
return relaxationFactor_;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -39,6 +39,70 @@ void Foam::sixDoFRigidBodyMotion::write(Ostream& os) const
|
|||||||
<< momentOfInertia_ << token::END_STATEMENT << nl;
|
<< momentOfInertia_ << token::END_STATEMENT << nl;
|
||||||
os.writeKeyword("mass")
|
os.writeKeyword("mass")
|
||||||
<< mass_ << token::END_STATEMENT << nl;
|
<< mass_ << token::END_STATEMENT << nl;
|
||||||
|
|
||||||
|
if (restraints_.size())
|
||||||
|
{
|
||||||
|
dictionary restraintsDict;
|
||||||
|
|
||||||
|
forAll(restraints_, rI)
|
||||||
|
{
|
||||||
|
word restraintType = restraints_[rI].type();
|
||||||
|
|
||||||
|
dictionary restraintDict;
|
||||||
|
|
||||||
|
restraintDict.add("sixDoFRigidBodyMotionRestraint", restraintType);
|
||||||
|
|
||||||
|
restraintDict.add
|
||||||
|
(
|
||||||
|
word(restraintType + "Coeffs"), restraints_[rI].coeffDict()
|
||||||
|
);
|
||||||
|
|
||||||
|
restraintsDict.add(restraints_[rI].name(), restraintDict);
|
||||||
|
}
|
||||||
|
|
||||||
|
os.writeKeyword("restraints") << restraintsDict;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (constraints_.size())
|
||||||
|
{
|
||||||
|
dictionary constraintsDict;
|
||||||
|
|
||||||
|
constraintsDict.add("maxIterations", maxConstraintIters_);
|
||||||
|
|
||||||
|
forAll(constraints_, rI)
|
||||||
|
{
|
||||||
|
word constraintType = constraints_[rI].type();
|
||||||
|
|
||||||
|
dictionary constraintDict;
|
||||||
|
|
||||||
|
constraintDict.add
|
||||||
|
(
|
||||||
|
"sixDoFRigidBodyMotionConstraint",
|
||||||
|
constraintType
|
||||||
|
);
|
||||||
|
|
||||||
|
constraintDict.add
|
||||||
|
(
|
||||||
|
"tolerance",
|
||||||
|
constraints_[rI].tolerance()
|
||||||
|
);
|
||||||
|
|
||||||
|
constraintDict.add
|
||||||
|
(
|
||||||
|
"relaxationFactor",
|
||||||
|
constraints_[rI].relaxationFactor()
|
||||||
|
);
|
||||||
|
|
||||||
|
constraintDict.add
|
||||||
|
(
|
||||||
|
word(constraintType + "Coeffs"), constraints_[rI].coeffDict()
|
||||||
|
);
|
||||||
|
|
||||||
|
constraintsDict.add(constraints_[rI].name(), constraintDict);
|
||||||
|
}
|
||||||
|
|
||||||
|
os.writeKeyword("constraints") << constraintsDict;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -71,7 +135,7 @@ Foam::Ostream& Foam::operator<<
|
|||||||
os << sDoFRBM.motionState()
|
os << sDoFRBM.motionState()
|
||||||
<< token::SPACE << sDoFRBM.refCentreOfMass()
|
<< token::SPACE << sDoFRBM.refCentreOfMass()
|
||||||
<< token::SPACE << sDoFRBM.momentOfInertia()
|
<< token::SPACE << sDoFRBM.momentOfInertia()
|
||||||
<< token::SPACE << sDoFRBM.mass() ;
|
<< token::SPACE << sDoFRBM.mass();
|
||||||
|
|
||||||
// Check state of Ostream
|
// Check state of Ostream
|
||||||
os.check
|
os.check
|
||||||
|
|||||||
@ -118,6 +118,26 @@ bool Foam::sixDoFRigidBodyMotionRestraints::linearSphericalAngularSpring ::read
|
|||||||
|
|
||||||
sDoFRBMRCoeffs_.lookup("referenceDirection") >> refDir_;
|
sDoFRBMRCoeffs_.lookup("referenceDirection") >> refDir_;
|
||||||
|
|
||||||
|
scalar magRefDir(mag(refDir_));
|
||||||
|
|
||||||
|
if (magRefDir > VSMALL)
|
||||||
|
{
|
||||||
|
refDir_ /= magRefDir;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
FatalErrorIn
|
||||||
|
(
|
||||||
|
"bool Foam::sixDoFRigidBodyMotionRestraints::"
|
||||||
|
"linearSphericalAngularSpring ::read"
|
||||||
|
"("
|
||||||
|
"const dictionary& sDoFRBMRDict"
|
||||||
|
")"
|
||||||
|
)
|
||||||
|
<< "referenceDirection has zero length"
|
||||||
|
<< abort(FatalError);
|
||||||
|
}
|
||||||
|
|
||||||
sDoFRBMRCoeffs_.lookup("stiffness") >> stiffness_;
|
sDoFRBMRCoeffs_.lookup("stiffness") >> stiffness_;
|
||||||
|
|
||||||
sDoFRBMRCoeffs_.lookup("damping") >> damping_;
|
sDoFRBMRCoeffs_.lookup("damping") >> damping_;
|
||||||
|
|||||||
@ -39,6 +39,7 @@ Foam::sixDoFRigidBodyMotionRestraint::sixDoFRigidBodyMotionRestraint
|
|||||||
const dictionary& sDoFRBMRDict
|
const dictionary& sDoFRBMRDict
|
||||||
)
|
)
|
||||||
:
|
:
|
||||||
|
name_(fileName(sDoFRBMRDict.name().name()).components(token::COLON).last()),
|
||||||
sDoFRBMRCoeffs_
|
sDoFRBMRCoeffs_
|
||||||
(
|
(
|
||||||
sDoFRBMRDict.subDict
|
sDoFRBMRDict.subDict
|
||||||
|
|||||||
@ -70,6 +70,10 @@ protected:
|
|||||||
|
|
||||||
// Protected data
|
// Protected data
|
||||||
|
|
||||||
|
//- Name of the constraint in dictionary
|
||||||
|
word name_;
|
||||||
|
|
||||||
|
//- Restraint model specific coefficient dictionary
|
||||||
dictionary sDoFRBMRCoeffs_;
|
dictionary sDoFRBMRCoeffs_;
|
||||||
|
|
||||||
|
|
||||||
@ -131,6 +135,20 @@ public:
|
|||||||
|
|
||||||
//- Update properties from given dictionary
|
//- Update properties from given dictionary
|
||||||
virtual bool read(const dictionary& sDoFRBMRDict) = 0;
|
virtual bool read(const dictionary& sDoFRBMRDict) = 0;
|
||||||
|
|
||||||
|
// Access
|
||||||
|
|
||||||
|
//- Return access to the name of the restraint
|
||||||
|
inline const word& name() const
|
||||||
|
{
|
||||||
|
return name_;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Return access to sDoFRBMRCoeffs
|
||||||
|
inline const dictionary& coeffDict() const
|
||||||
|
{
|
||||||
|
return sDoFRBMRCoeffs_;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user