FreeFOAM The Cross-Platform CFD Toolkit
Hosted by SourceForge:
Get FreeFOAM at SourceForge.net.
            Fast, secure and Free Open Source software downloads

sixDoFRigidBodyMotionIO.C

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002   =========                 |
00003   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
00004    \\    /   O peration     |
00005     \\  /    A nd           | Copyright (C) 2009-2010 OpenCFD Ltd.
00006      \\/     M anipulation  |
00007 -------------------------------------------------------------------------------
00008 License
00009     This file is part of OpenFOAM.
00010 
00011     OpenFOAM is free software: you can redistribute it and/or modify it
00012     under the terms of the GNU General Public License as published by
00013     the Free Software Foundation, either version 3 of the License, or
00014     (at your option) any later version.
00015 
00016     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
00017     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00019     for more details.
00020 
00021     You should have received a copy of the GNU General Public License
00022     along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
00023 
00024 \*---------------------------------------------------------------------------*/
00025 
00026 #include "sixDoFRigidBodyMotion.H"
00027 #include <OpenFOAM/IOstreams.H>
00028 
00029 // * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * * //
00030 
00031 void Foam::sixDoFRigidBodyMotion::write(Ostream& os) const
00032 {
00033     motionState_.write(os);
00034 
00035     os.writeKeyword("initialCentreOfMass")
00036         << initialCentreOfMass_ << token::END_STATEMENT << nl;
00037     os.writeKeyword("initialOrientation")
00038         << initialQ_ << token::END_STATEMENT << nl;
00039     os.writeKeyword("momentOfInertia")
00040         << momentOfInertia_ << token::END_STATEMENT << nl;
00041     os.writeKeyword("mass")
00042         << mass_ << token::END_STATEMENT << nl;
00043     os.writeKeyword("accelerationDampingCoeff")
00044         << cDamp_ << token::END_STATEMENT << nl;
00045     os.writeKeyword("accelerationLimit")
00046         << aLim_ << token::END_STATEMENT << nl;
00047     os.writeKeyword("report")
00048         << report_ << token::END_STATEMENT << nl;
00049 
00050     if (!restraints_.empty())
00051     {
00052         os  << indent << "restraints" << nl
00053             << indent << token::BEGIN_BLOCK << incrIndent << nl;
00054 
00055         forAll(restraints_, rI)
00056         {
00057             word restraintType = restraints_[rI].type();
00058 
00059             os  << indent << restraintNames_[rI] << nl
00060                 << indent << token::BEGIN_BLOCK << incrIndent << endl;
00061 
00062             os.writeKeyword("sixDoFRigidBodyMotionRestraint")
00063                 << restraintType << token::END_STATEMENT << nl;
00064 
00065             os.writeKeyword(word(restraintType + "Coeffs")) << nl;
00066 
00067             os  << indent << token::BEGIN_BLOCK << nl << incrIndent;
00068 
00069             restraints_[rI].write(os);
00070 
00071             os << decrIndent << indent << token::END_BLOCK << nl;
00072 
00073             os  << decrIndent << indent << token::END_BLOCK << endl;
00074         }
00075 
00076         os  << decrIndent << indent << token::END_BLOCK << nl;
00077     }
00078 
00079     if (!constraints_.empty())
00080     {
00081         os  << indent << "constraints" << nl
00082             << indent << token::BEGIN_BLOCK << incrIndent << nl;
00083 
00084         os.writeKeyword("maxIterations")
00085             << maxConstraintIterations_ << token::END_STATEMENT << nl;
00086 
00087         forAll(constraints_, rI)
00088         {
00089             word constraintType = constraints_[rI].type();
00090 
00091             os  << indent << constraintNames_[rI] << nl
00092                 << indent << token::BEGIN_BLOCK << incrIndent << endl;
00093 
00094             os.writeKeyword("sixDoFRigidBodyMotionConstraint")
00095                 << constraintType << token::END_STATEMENT << nl;
00096 
00097             constraints_[rI].sixDoFRigidBodyMotionConstraint::write(os);
00098 
00099             os.writeKeyword(word(constraintType + "Coeffs")) << nl;
00100 
00101             os  << indent << token::BEGIN_BLOCK << nl << incrIndent;
00102 
00103             constraints_[rI].write(os);
00104 
00105             os << decrIndent << indent << token::END_BLOCK << nl;
00106 
00107             os  << decrIndent << indent << token::END_BLOCK << endl;
00108         }
00109 
00110         os  << decrIndent << indent << token::END_BLOCK << nl;
00111     }
00112 }
00113 
00114 
00115 // * * * * * * * * * * * * * * * IOstream Operators  * * * * * * * * * * * * //
00116 
00117 Foam::Istream& Foam::operator>>(Istream& is, sixDoFRigidBodyMotion& sDoFRBM)
00118 {
00119     is  >> sDoFRBM.motionState_
00120         >> sDoFRBM.initialCentreOfMass_
00121         >> sDoFRBM.initialQ_
00122         >> sDoFRBM.momentOfInertia_
00123         >> sDoFRBM.mass_;
00124 
00125     // Check state of Istream
00126     is.check
00127     (
00128         "Foam::Istream& Foam::operator>>"
00129         "(Foam::Istream&, Foam::sixDoFRigidBodyMotion&)"
00130     );
00131 
00132     return is;
00133 }
00134 
00135 
00136 Foam::Ostream& Foam::operator<<
00137 (
00138     Ostream& os,
00139     const sixDoFRigidBodyMotion& sDoFRBM
00140 )
00141 {
00142     os  << sDoFRBM.motionState()
00143         << token::SPACE << sDoFRBM.initialCentreOfMass()
00144         << token::SPACE << sDoFRBM.initialQ()
00145         << token::SPACE << sDoFRBM.momentOfInertia()
00146         << token::SPACE << sDoFRBM.mass();
00147 
00148     // Check state of Ostream
00149     os.check
00150     (
00151         "Foam::Ostream& Foam::operator<<(Foam::Ostream&, "
00152         "const Foam::sixDoFRigidBodyMotion&)"
00153     );
00154 
00155     return os;
00156 }
00157 
00158 
00159 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines