Loading...
Searching...
No Matches
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-2023 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\*---------------------------------------------------------------------------*/
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 updateConstraints_ = dict.getOrDefault("updateConstraints", false);
43
44 restraints_.clear();
46
47 constraints_.clear();
49
50 return true;
51}
52
53
55{
56 motionState_.write(os);
57
58 os.writeEntry("centreOfMass", initialCentreOfMass_);
59 os.writeEntry("initialOrientation", initialQ_);
60 os.writeEntry("mass", mass_);
61 os.writeEntry("momentOfInertia", momentOfInertia_);
62 os.writeEntry("accelerationRelaxation", aRelax_);
63 os.writeEntry("accelerationDamping", aDamp_);
64 os.writeEntry("report", report_);
65 os.writeEntry("updateConstraints", updateConstraints_);
66
67 if (!restraints_.empty())
68 {
69 os.beginBlock("restraints");
70
71 forAll(restraints_, rI)
72 {
73 const word& restraintType(restraints_[rI].type());
74
75 os.beginBlock(restraints_[rI].name());
76
77 os.writeEntry("sixDoFRigidBodyMotionRestraint", restraintType);
78
79 restraints_[rI].write(os);
80
81 os.endBlock();
82 }
83
84 os.endBlock();
85 }
86
87 if (!constraints_.empty())
88 {
89 os.beginBlock("constraints");
90
91 forAll(constraints_, rI)
92 {
93 const word& constraintType(constraints_[rI].type());
94
95 os.beginBlock(constraints_[rI].name());
96
97 os.writeEntry("sixDoFRigidBodyMotionConstraint", constraintType);
98
99 constraints_[rI].sixDoFRigidBodyMotionConstraint::write(os);
100
101 constraints_[rI].write(os);
102
103 os.endBlock();
104 }
105
106 os.endBlock();
107 }
108
109 if (solver_)
110 {
111 os << indent << "solver";
112 solver_->write(os);
113 }
114}
115
116
117// ************************************************************************* //
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:59
virtual Ostream & endBlock()
Write end block group.
Definition Ostream.C:108
Ostream & writeEntry(const keyType &key, const T &value)
Write a keyword/value entry.
Definition Ostream.H:331
virtual Ostream & beginBlock(const keyType &kw)
Write begin block group with the given name.
Definition Ostream.C:90
virtual bool write(const token &tok)=0
Write token to stream or otherwise handle it.
A simple wrapper around bool so that it can be read as a word: true/false, on/off,...
Definition Switch.H:81
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition dictionary.H:133
void addConstraints(const dictionary &dict)
Add restraints to the motion, public to allow external.
void write(Ostream &) const
Write.
bool read(const dictionary &dict)
Read coefficients dictionary and update system parameters,.
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:66
OBJstream os(runTime.globalPath()/outputName)
auto & name
fileName::Type type(const fileName &name, const bool followLink=true)
Return the file type: DIRECTORY or FILE, normally following symbolic links.
Definition POSIX.C:801
Ostream & indent(Ostream &os)
Indent stream.
Definition Ostream.H:481
dictionary dict
#define forAll(list, i)
Loop across all elements in list.
Definition stdFoam.H:299