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