sixDoFRigidBodyMotionStateIO.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation
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 
27 #include "IOstreams.H"
28 
29 // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
30 
32 {
33  dict.add("centreOfRotation", centreOfRotation_);
34  dict.add("orientation", Q_);
35  dict.add("velocity", v_);
36  dict.add("acceleration", a_);
37  dict.add("angularMomentum", pi_);
38  dict.add("torque", tau_);
39 }
40 
41 
43 {
44  writeEntry(os, "centreOfRotation", centreOfRotation_);
45  writeEntry(os, "orientation", Q_);
46  writeEntry(os, "velocity", v_);
47  writeEntry(os, "acceleration", a_);
48  writeEntry(os, "angularMomentum", pi_);
49  writeEntry(os, "torque", tau_);
50 }
51 
52 
53 // * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
54 
55 Foam::Istream& Foam::operator>>
56 (
57  Istream& is, sixDoFRigidBodyMotionState& sDoFRBMS
58 )
59 {
60  is >> sDoFRBMS.centreOfRotation_
61  >> sDoFRBMS.Q_
62  >> sDoFRBMS.v_
63  >> sDoFRBMS.a_
64  >> sDoFRBMS.pi_
65  >> sDoFRBMS.tau_;
66 
67  // Check state of Istream
68  is.check
69  (
70  "Foam::Istream& Foam::operator>>"
71  "(Foam::Istream&, Foam::sixDoFRigidBodyMotionState&)"
72  );
73 
74  return is;
75 }
76 
77 
78 Foam::Ostream& Foam::operator<<
79 (
80  Ostream& os,
81  const sixDoFRigidBodyMotionState& sDoFRBMS
82 )
83 {
84  os << token::SPACE << sDoFRBMS.centreOfRotation()
85  << token::SPACE << sDoFRBMS.Q()
86  << token::SPACE << sDoFRBMS.v()
87  << token::SPACE << sDoFRBMS.a()
88  << token::SPACE << sDoFRBMS.pi()
89  << token::SPACE << sDoFRBMS.tau();
90 
91  // Check state of Ostream
92  os.check
93  (
94  "Foam::Ostream& Foam::operator<<(Foam::Ostream&, "
95  "const Foam::sixDoFRigidBodyMotionState&)"
96  );
97 
98  return os;
99 }
100 
101 
102 // ************************************************************************* //
Useful combination of include files which define Sin, Sout and Serr and the use of IO streams general...
virtual bool check(const char *operation) const
Check IOstream status for given operation.
Definition: IOstream.C:92
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:60
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:57
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:160
Holds the motion state of sixDoF object. Wrapped up together to allow rapid scatter to other processo...
void write(dictionary &dict) const
Write to dictionary.
void writeEntry(Ostream &os, const HashTable< T, Key, Hash > &ht)
Definition: HashTableIO.C:96
dictionary dict