1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2009-2009 OpenCFD Ltd.
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
11 OpenFOAM is free software; you can redistribute it and/or modify it
12 under the terms of the GNU General Public License as published by the
13 Free Software Foundation; either version 2 of the License, or (at your
14 option) any later version.
16 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 You should have received a copy of the GNU General Public License
22 along with OpenFOAM; if not, write to the Free Software Foundation,
23 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 \*---------------------------------------------------------------------------*/
27 #include "sixDoFRigidBodyMotion.H"
28 #include "IOstreams.H"
30 // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
32 void Foam::sixDoFRigidBodyMotion::write(Ostream& os) const
34 motionState_.write(os);
36 os.writeKeyword("initialCentreOfMass")
37 << initialCentreOfMass_ << token::END_STATEMENT << nl;
38 os.writeKeyword("initialOrientation")
39 << initialQ_ << token::END_STATEMENT << nl;
40 os.writeKeyword("momentOfInertia")
41 << momentOfInertia_ << token::END_STATEMENT << nl;
42 os.writeKeyword("mass")
43 << mass_ << token::END_STATEMENT << nl;
44 os.writeKeyword("report")
45 << report_ << token::END_STATEMENT << nl;
47 if (!restraints_.empty())
49 os << indent << "restraints" << nl
50 << indent << token::BEGIN_BLOCK << incrIndent << nl;
52 forAll(restraints_, rI)
54 word restraintType = restraints_[rI].type();
56 os << indent << restraintNames_[rI] << nl
57 << indent << token::BEGIN_BLOCK << incrIndent << endl;
59 os.writeKeyword("sixDoFRigidBodyMotionRestraint")
60 << restraintType << token::END_STATEMENT << nl;
62 os.writeKeyword(word(restraintType + "Coeffs")) << nl;
64 os << indent << token::BEGIN_BLOCK << nl << incrIndent;
66 restraints_[rI].write(os);
68 os << decrIndent << indent << token::END_BLOCK << nl;
70 os << decrIndent << indent << token::END_BLOCK << endl;
73 os << decrIndent << indent << token::END_BLOCK << nl;
76 if (!constraints_.empty())
78 os << indent << "constraints" << nl
79 << indent << token::BEGIN_BLOCK << incrIndent << nl;
81 os.writeKeyword("maxIterations")
82 << maxConstraintIterations_ << token::END_STATEMENT << nl;
84 forAll(constraints_, rI)
86 word constraintType = constraints_[rI].type();
88 os << indent << constraintNames_[rI] << nl
89 << indent << token::BEGIN_BLOCK << incrIndent << endl;
91 os.writeKeyword("sixDoFRigidBodyMotionConstraint")
92 << constraintType << token::END_STATEMENT << nl;
94 constraints_[rI].sixDoFRigidBodyMotionConstraint::write(os);
96 os.writeKeyword(word(constraintType + "Coeffs")) << nl;
98 os << indent << token::BEGIN_BLOCK << nl << incrIndent;
100 constraints_[rI].write(os);
102 os << decrIndent << indent << token::END_BLOCK << nl;
104 os << decrIndent << indent << token::END_BLOCK << endl;
107 os << decrIndent << indent << token::END_BLOCK << nl;
112 // * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
114 Foam::Istream& Foam::operator>>(Istream& is, sixDoFRigidBodyMotion& sDoFRBM)
116 is >> sDoFRBM.motionState_
117 >> sDoFRBM.initialCentreOfMass_
119 >> sDoFRBM.momentOfInertia_
122 // Check state of Istream
125 "Foam::Istream& Foam::operator>>"
126 "(Foam::Istream&, Foam::sixDoFRigidBodyMotion&)"
133 Foam::Ostream& Foam::operator<<
136 const sixDoFRigidBodyMotion& sDoFRBM
139 os << sDoFRBM.motionState()
140 << token::SPACE << sDoFRBM.initialCentreOfMass()
141 << token::SPACE << sDoFRBM.initialQ()
142 << token::SPACE << sDoFRBM.momentOfInertia()
143 << token::SPACE << sDoFRBM.mass();
145 // Check state of Ostream
148 "Foam::Ostream& Foam::operator<<(Foam::Ostream&, "
149 "const Foam::sixDoFRigidBodyMotion&)"
156 // ************************************************************************* //