FreeFOAM The Cross-Platform CFD Toolkit
sixDoFRigidBodyMotionIO.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | Copyright (C) 2009-2010 OpenCFD Ltd.
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
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
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
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
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
26 #include "sixDoFRigidBodyMotion.H"
27 #include <OpenFOAM/IOstreams.H>
28 
29 // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
30 
32 {
33  motionState_.write(os);
34 
35  os.writeKeyword("initialCentreOfMass")
36  << initialCentreOfMass_ << token::END_STATEMENT << nl;
37  os.writeKeyword("initialOrientation")
38  << initialQ_ << token::END_STATEMENT << nl;
39  os.writeKeyword("momentOfInertia")
40  << momentOfInertia_ << token::END_STATEMENT << nl;
41  os.writeKeyword("mass")
42  << mass_ << token::END_STATEMENT << nl;
43  os.writeKeyword("accelerationDampingCoeff")
44  << cDamp_ << token::END_STATEMENT << nl;
45  os.writeKeyword("accelerationLimit")
46  << aLim_ << token::END_STATEMENT << nl;
47  os.writeKeyword("report")
48  << report_ << token::END_STATEMENT << nl;
49 
50  if (!restraints_.empty())
51  {
52  os << indent << "restraints" << nl
54 
55  forAll(restraints_, rI)
56  {
57  word restraintType = restraints_[rI].type();
58 
59  os << indent << restraintNames_[rI] << nl
61 
62  os.writeKeyword("sixDoFRigidBodyMotionRestraint")
63  << restraintType << token::END_STATEMENT << nl;
64 
65  os.writeKeyword(word(restraintType + "Coeffs")) << nl;
66 
67  os << indent << token::BEGIN_BLOCK << nl << incrIndent;
68 
69  restraints_[rI].write(os);
70 
71  os << decrIndent << indent << token::END_BLOCK << nl;
72 
73  os << decrIndent << indent << token::END_BLOCK << endl;
74  }
75 
76  os << decrIndent << indent << token::END_BLOCK << nl;
77  }
78 
79  if (!constraints_.empty())
80  {
81  os << indent << "constraints" << nl
83 
84  os.writeKeyword("maxIterations")
85  << maxConstraintIterations_ << token::END_STATEMENT << nl;
86 
87  forAll(constraints_, rI)
88  {
89  word constraintType = constraints_[rI].type();
90 
91  os << indent << constraintNames_[rI] << nl
93 
94  os.writeKeyword("sixDoFRigidBodyMotionConstraint")
95  << constraintType << token::END_STATEMENT << nl;
96 
97  constraints_[rI].sixDoFRigidBodyMotionConstraint::write(os);
98 
99  os.writeKeyword(word(constraintType + "Coeffs")) << nl;
100 
101  os << indent << token::BEGIN_BLOCK << nl << incrIndent;
102 
103  constraints_[rI].write(os);
104 
105  os << decrIndent << indent << token::END_BLOCK << nl;
106 
107  os << decrIndent << indent << token::END_BLOCK << endl;
108  }
109 
110  os << decrIndent << indent << token::END_BLOCK << nl;
111  }
112 }
113 
114 
115 // * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
116 
118 {
119  is >> sDoFRBM.motionState_
120  >> sDoFRBM.initialCentreOfMass_
121  >> sDoFRBM.initialQ_
122  >> sDoFRBM.momentOfInertia_
123  >> sDoFRBM.mass_;
124 
125  // Check state of Istream
126  is.check
127  (
128  "Foam::Istream& Foam::operator>>"
129  "(Foam::Istream&, Foam::sixDoFRigidBodyMotion&)"
130  );
131 
132  return is;
133 }
134 
135 
136 Foam::Ostream& Foam::operator<<
137 (
138  Ostream& os,
139  const sixDoFRigidBodyMotion& sDoFRBM
140 )
141 {
142  os << sDoFRBM.motionState()
143  << token::SPACE << sDoFRBM.initialCentreOfMass()
144  << token::SPACE << sDoFRBM.initialQ()
145  << token::SPACE << sDoFRBM.momentOfInertia()
146  << token::SPACE << sDoFRBM.mass();
147 
148  // Check state of Ostream
149  os.check
150  (
151  "Foam::Ostream& Foam::operator<<(Foam::Ostream&, "
152  "const Foam::sixDoFRigidBodyMotion&)"
153  );
154 
155  return os;
156 }
157 
158 
159 // ************************ vim: set sw=4 sts=4 et: ************************ //