mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-12-28 03:37:59 +00:00
Adding report Switch to turn on reporting. Renaming linearSphericalAngularSpring to sphericalAngularSpring and getting a moment contribution from each axis. Can supply a reference orientation.
154 lines
4.3 KiB
C
154 lines
4.3 KiB
C
/*---------------------------------------------------------------------------*\
|
|
========= |
|
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
|
\\ / O peration |
|
|
\\ / A nd | Copyright (C) 2009-2009 OpenCFD Ltd.
|
|
\\/ M anipulation |
|
|
-------------------------------------------------------------------------------
|
|
License
|
|
This file is part of OpenFOAM.
|
|
|
|
OpenFOAM is free software; you can redistribute it and/or modify it
|
|
under the terms of the GNU General Public License as published by the
|
|
Free Software Foundation; either version 2 of the License, or (at your
|
|
option) any later version.
|
|
|
|
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
|
|
for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with OpenFOAM; if not, write to the Free Software Foundation,
|
|
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
\*---------------------------------------------------------------------------*/
|
|
|
|
#include "sixDoFRigidBodyMotion.H"
|
|
#include "IOstreams.H"
|
|
|
|
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
|
|
|
|
void Foam::sixDoFRigidBodyMotion::write(Ostream& os) const
|
|
{
|
|
motionState_.write(os);
|
|
|
|
os.writeKeyword("refCentreOfMass")
|
|
<< refCentreOfMass_ << token::END_STATEMENT << nl;
|
|
os.writeKeyword("momentOfInertia")
|
|
<< momentOfInertia_ << token::END_STATEMENT << nl;
|
|
os.writeKeyword("mass")
|
|
<< mass_ << token::END_STATEMENT << nl;
|
|
os.writeKeyword("report")
|
|
<< report_ << 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;
|
|
}
|
|
}
|
|
|
|
|
|
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
|
|
|
|
Foam::Istream& Foam::operator>>(Istream& is, sixDoFRigidBodyMotion& sDoFRBM)
|
|
{
|
|
is >> sDoFRBM.motionState_
|
|
>> sDoFRBM.refCentreOfMass_
|
|
>> sDoFRBM.momentOfInertia_
|
|
>> sDoFRBM.mass_;
|
|
|
|
// Check state of Istream
|
|
is.check
|
|
(
|
|
"Foam::Istream& Foam::operator>>"
|
|
"(Foam::Istream&, Foam::sixDoFRigidBodyMotion&)"
|
|
);
|
|
|
|
return is;
|
|
}
|
|
|
|
|
|
Foam::Ostream& Foam::operator<<
|
|
(
|
|
Ostream& os,
|
|
const sixDoFRigidBodyMotion& sDoFRBM
|
|
)
|
|
{
|
|
os << sDoFRBM.motionState()
|
|
<< token::SPACE << sDoFRBM.refCentreOfMass()
|
|
<< token::SPACE << sDoFRBM.momentOfInertia()
|
|
<< token::SPACE << sDoFRBM.mass();
|
|
|
|
// Check state of Ostream
|
|
os.check
|
|
(
|
|
"Foam::Ostream& Foam::operator<<(Foam::Ostream&, "
|
|
"const Foam::sixDoFRigidBodyMotion&)"
|
|
);
|
|
|
|
return os;
|
|
}
|
|
|
|
|
|
// ************************************************************************* //
|