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 | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2011-2014 OpenFOAM Foundation
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 \*---------------------------------------------------------------------------*/
27 
28 #include "sixDoFRigidBodyMotion.H"
29 #include "IOstreams.H"
30 #include "sixDoFSolver.H"
31 
32 // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
33 
35 {
36  dict.readEntry("mass", mass_);
37  dict.readEntry("momentOfInertia", momentOfInertia_);
38  aRelax_ = dict.lookupOrDefault<scalar>("accelerationRelaxation", 1.0);
39  aDamp_ = dict.lookupOrDefault<scalar>("accelerationDamping", 1.0);
40  report_ = dict.lookupOrDefault<Switch>("report", false);
41 
42  restraints_.clear();
44 
45  constraints_.clear();
47 
48  return true;
49 }
50 
51 
53 {
54  motionState_.write(os);
55 
56  os.writeEntry("centreOfMass", initialCentreOfMass_);
57  os.writeEntry("initialOrientation", initialQ_);
58  os.writeEntry("mass", mass_);
59  os.writeEntry("momentOfInertia", momentOfInertia_);
60  os.writeEntry("accelerationRelaxation", aRelax_);
61  os.writeEntry("accelerationDamping", aDamp_);
62  os.writeEntry("report", report_);
63 
64  if (!restraints_.empty())
65  {
66  os.beginBlock("restraints");
67 
68  forAll(restraints_, rI)
69  {
70  const word& restraintType(restraints_[rI].type());
71 
72  os.beginBlock(restraints_[rI].name());
73 
74  os.writeEntry("sixDoFRigidBodyMotionRestraint", restraintType);
75 
76  restraints_[rI].write(os);
77 
78  os.endBlock();
79  }
80 
81  os.endBlock();
82  }
83 
84  if (!constraints_.empty())
85  {
86  os.beginBlock("constraints");
87 
88  forAll(constraints_, rI)
89  {
90  const word& constraintType(constraints_[rI].type());
91 
92  os.beginBlock(constraints_[rI].name());
93 
94  os.writeEntry("sixDoFRigidBodyMotionConstraint", constraintType);
95 
96  constraints_[rI].sixDoFRigidBodyMotionConstraint::write(os);
97 
98  constraints_[rI].write(os);
99 
100  os.endBlock();
101  }
102 
103  os.endBlock();
104  }
105 
106  if (!solver_.empty())
107  {
108  os << indent << "solver";
109  solver_->write(os);
110  }
111 }
112 
113 
114 // ************************************************************************* //
Foam::Switch
A simple wrapper around bool so that it can be read as a word: true/false, on/off,...
Definition: Switch.H:70
IOstreams.H
Useful combination of include files which define Sin, Sout and Serr and the use of IO streams general...
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:62
Foam::Ostream::beginBlock
virtual Ostream & beginBlock(const keyType &kw)
Write begin block group with the given name.
Definition: Ostream.C:91
Foam::sixDoFRigidBodyMotion::addRestraints
void addRestraints(const dictionary &dict)
Add restraints to the motion, public to allow external.
Definition: sixDoFRigidBodyMotion.C:194
sixDoFRigidBodyMotion.H
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:290
Foam::sixDoFRigidBodyMotion::write
void write(Ostream &) const
Write.
Definition: sixDoFRigidBodyMotionIO.C:52
Foam::sixDoFRigidBodyMotion::addConstraints
void addConstraints(const dictionary &dict)
Add restraints to the motion, public to allow external.
Definition: sixDoFRigidBodyMotion.C:228
Foam::name
word name(const complex &c)
Return string representation of complex.
Definition: complex.C:76
Foam::sixDoFRigidBodyMotion::read
bool read(const dictionary &dict)
Read coefficients dictionary and update system parameters,.
Definition: sixDoFRigidBodyMotionIO.C:34
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::Ostream::endBlock
virtual Ostream & endBlock()
Write end block group.
Definition: Ostream.C:109
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:121
Foam::Ostream::write
virtual bool write(const token &tok)=0
Write token to stream or otherwise handle it.
Foam::indent
Ostream & indent(Ostream &os)
Indent stream.
Definition: Ostream.H:307
Foam::type
fileName::Type type(const fileName &name, const bool followLink=true)
Return the file type: DIRECTORY or FILE, normally following symbolic links.
Definition: MSwindows.C:590
sixDoFSolver.H
Foam::Ostream::writeEntry
Ostream & writeEntry(const keyType &key, const T &value)
Write a keyword/value entry.
Definition: Ostream.H:219
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56