rigidBodyRestraint.H
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) 2016 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 Namespace
27  Foam::RBD::restraints
28 
29 Description
30  Namespace for rigid-body dynamics restraints
31 
32 Class
33  Foam::RBD::restraint
34 
35 Description
36  Base class for defining restraints for rigid-body dynamics
37 
38 SourceFiles
39  rigidBodyRestraint.C
40  rigidBodyRestraintNew.C
41 
42 \*---------------------------------------------------------------------------*/
43 
44 #ifndef RBD_rigidBodyRestraint_H
45 #define RBD_rigidBodyRestraint_H
46 
47 #include "dictionary.H"
48 #include "autoPtr.H"
49 #include "spatialVector.H"
50 #include "point.H"
51 #include "scalarField.H"
52 #include "runTimeSelectionTables.H"
53 #include "rigidBodyModelState.H"
54 
55 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
56 
57 namespace Foam
58 {
59 namespace RBD
60 {
61 
62 // Forward declaration of classes
63 class rigidBodyModel;
64 
65 /*---------------------------------------------------------------------------*\
66  Class restraint Declaration
67 \*---------------------------------------------------------------------------*/
68 
69 class restraint
70 {
71 
72 protected:
73 
74  // Protected data
75 
76  //- Name of the restraint
77  word name_;
78 
79  //- ID of the body the restraint is applied to
80  label bodyID_;
81 
82  //- Index of the body the force is applied to
83  label bodyIndex_;
84 
85  //- Restraint model specific coefficient dictionary
87 
88  //- Reference to the model
89  const rigidBodyModel& model_;
90 
91  //- Transform the given point on the restrained body to the global frame
92  inline point bodyPoint(const point& p) const;
93 
94  //- Transform the velocity of the given point on the restrained body
95  // to the global frame
96  inline spatialVector bodyPointVelocity(const point& p) const;
97 
98 
99 public:
100 
101  //- Runtime type information
102  TypeName("restraint");
103 
104 
105  // Declare run-time constructor selection table
106 
108  (
109  autoPtr,
110  restraint,
111  dictionary,
112  (
113  const word& name,
114  const dictionary& dict,
115  const rigidBodyModel& model
116  ),
117  (name, dict, model)
118  );
119 
120 
121  // Constructors
122 
123  //- Construct from the dict dictionary and Time
124  restraint
125  (
126  const word& name,
127  const dictionary& dict,
128  const rigidBodyModel& model
129  );
130 
131  //- Construct and return a clone
132  virtual autoPtr<restraint> clone() const = 0;
133 
134 
135  // Selectors
136 
137  //- Select constructed from the dict dictionary and Time
138  static autoPtr<restraint> New
139  (
140  const word& name,
141  const dictionary& dict,
142  const rigidBodyModel& model
143  );
144 
145 
146  //- Destructor
147  virtual ~restraint();
148 
149 
150  // Member Functions
151 
152  //- Return the name
153  const word& name() const
154  {
155  return name_;
156  }
157 
158  label bodyID() const
159  {
160  return bodyID_;
161  }
162 
163  //- Accumulate the restraint internal joint forces into the tau field and
164  // external forces into the fx field
165  virtual void restrain
166  (
167  scalarField& tau,
169  const rigidBodyModelState& state
170  ) const = 0;
171 
172  //- Update properties from given dictionary
173  virtual bool read(const dictionary& dict);
174 
175  //- Return access to coeffs
176  const dictionary& coeffDict() const;
177 
178  //- Write
179  virtual void write(Ostream&) const = 0;
180 };
181 
182 
183 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
184 
185 } // End namespace RBD
186 } // End namespace Foam
187 
188 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
189 
190 #include "rigidBodyRestraintI.H"
191 
192 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
193 
194 #endif
195 
196 // ************************************************************************* //
Foam::RBD::restraint::model_
const rigidBodyModel & model_
Reference to the model.
Definition: rigidBodyRestraint.H:88
Foam::RBD::restraint::name
const word & name() const
Return the name.
Definition: rigidBodyRestraint.H:152
Foam::RBD::restraint::restrain
virtual void restrain(scalarField &tau, Field< spatialVector > &fx, const rigidBodyModelState &state) const =0
Accumulate the restraint internal joint forces into the tau field and.
p
volScalarField & p
Definition: createFieldRefs.H:8
Foam::RBD::rigidBodyModelState
Holds the motion state of rigid-body model.
Definition: rigidBodyModelState.H:67
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
Foam::RBD::restraint::clone
virtual autoPtr< restraint > clone() const =0
Construct and return a clone.
scalarField.H
Foam::RBD::restraint::~restraint
virtual ~restraint()
Destructor.
Definition: rigidBodyRestraint.C:62
point.H
Foam::RBD::restraint::bodyID
label bodyID() const
Definition: rigidBodyRestraint.H:157
spatialVector.H
Foam::RBD::restraint::coeffs_
dictionary coeffs_
Restraint model specific coefficient dictionary.
Definition: rigidBodyRestraint.H:85
Foam::RBD::restraint::declareRunTimeSelectionTable
declareRunTimeSelectionTable(autoPtr, restraint, dictionary,(const word &name, const dictionary &dict, const rigidBodyModel &model),(name, dict, model))
Foam::RBD::restraint::bodyID_
label bodyID_
ID of the body the restraint is applied to.
Definition: rigidBodyRestraint.H:79
Foam::RBD::restraint::TypeName
TypeName("restraint")
Runtime type information.
Foam::Field< scalar >
rigidBodyRestraintI.H
Foam::SpatialVector< scalar >
Foam::RBD::restraint::read
virtual bool read(const dictionary &dict)
Update properties from given dictionary.
Definition: rigidBodyRestraint.C:74
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::RBD::rigidBodyModel
Basic rigid-body model representing a system of rigid-bodies connected by 1-6 DoF joints.
Definition: rigidBodyModel.H:83
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:123
Foam::RBD::restraint::bodyPointVelocity
spatialVector bodyPointVelocity(const point &p) const
Transform the velocity of the given point on the restrained body.
Definition: rigidBodyRestraintI.H:42
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
rigidBodyModelState.H
Foam::RBD::restraint::bodyIndex_
label bodyIndex_
Index of the body the force is applied to.
Definition: rigidBodyRestraint.H:82
Foam::autoPtr
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: HashPtrTable.H:53
Foam::RBD::restraint::name_
word name_
Name of the restraint.
Definition: rigidBodyRestraint.H:76
runTimeSelectionTables.H
Macros to ease declaration of run-time selection tables.
Foam::Vector< scalar >
Foam::RBD::restraint::write
virtual void write(Ostream &) const =0
Write.
Definition: rigidBodyRestraint.C:81
Foam::RBD::restraint
Base class for defining restraints for rigid-body dynamics.
Definition: rigidBodyRestraint.H:68
dictionary.H
Foam::RBD::restraint::restraint
restraint(const word &name, const dictionary &dict, const rigidBodyModel &model)
Construct from the dict dictionary and Time.
Definition: rigidBodyRestraint.C:46
Foam::RBD::restraint::bodyPoint
point bodyPoint(const point &p) const
Transform the given point on the restrained body to the global frame.
Definition: rigidBodyRestraintI.H:33
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
Foam::RBD::restraint::New
static autoPtr< restraint > New(const word &name, const dictionary &dict, const rigidBodyModel &model)
Select constructed from the dict dictionary and Time.
Definition: rigidBodyRestraintNew.C:35
Foam::RBD::restraint::coeffDict
const dictionary & coeffDict() const
Return access to coeffs.
Definition: rigidBodyRestraint.C:68
autoPtr.H