rigidBodyRestraint.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) 2016-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 
26 #include "rigidBodyRestraint.H"
27 #include "rigidBodyModel.H"
28 
29 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
30 
31 namespace Foam
32 {
33 namespace RBD
34 {
35  defineTypeNameAndDebug(restraint, 0);
36  defineRunTimeSelectionTable(restraint, dictionary);
37 }
38 }
39 
40 
41 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
42 
44 (
45  const word& name,
46  const dictionary& dict,
47  const rigidBodyModel& model
48 )
49 :
50  name_(name),
51  bodyID_(model.bodyID(dict.lookup("body"))),
52  bodyIndex_(model.master(bodyID_)),
53  coeffs_(dict),
54  model_(model)
55 {}
56 
57 
58 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
59 
61 {}
62 
63 
64 // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
65 
67 {
68  return coeffs_;
69 }
70 
71 
73 {
74  coeffs_ = dict;
75  return true;
76 }
77 
78 
80 {
81  writeEntry(os, "type", type());
82  writeEntry(os, "body", model_.name(bodyID_));
83 }
84 
85 
86 // ************************************************************************* //
dictionary dict
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:156
restraint(const word &name, const dictionary &dict, const rigidBodyModel &model)
Construct from the dict dictionary and Time.
label master(label bodyID) const
Return the ID of the master body for a sub-body otherwise.
virtual bool read(const dictionary &dict)
Update properties from given dictionary.
A class for handling words, derived from string.
Definition: word.H:59
virtual const fileName & name() const
Return the name of the stream.
Definition: IOstream.H:294
defineTypeNameAndDebug(cuboid, 0)
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:54
defineRunTimeSelectionTable(rigidBody, dictionary)
void writeEntry(Ostream &os, const HashTable< T, Key, Hash > &ht)
Definition: HashTableIO.C:96
virtual ~restraint()
Destructor.
fileType type(const fileName &, const bool checkVariants=true, const bool followLink=true)
Return the file type: directory or file.
Definition: POSIX.C:488
const dictionary & coeffDict() const
Return access to coeffs.
label bodyID(const word &name) const
Return the ID of the body with the given name.
Basic rigid-body model representing a system of rigid-bodies connected by 1-6 DoF joints...
virtual void write(Ostream &) const =0
Write.
Namespace for OpenFOAM.
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
Definition: dictionary.C:864