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 };
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 // ************************************************************************* //
declareRunTimeSelectionTable(autoPtr, restraint, dictionary,(const word &name, const dictionary &dict, const rigidBodyModel &model),(name, dict, model))
virtual void restrain(scalarField &tau, Field< spatialVector > &fx, const rigidBodyModelState &state) const =0
Accumulate the restraint internal joint forces into the tau field and.
dictionary dict
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:129
Base class for defining restraints for rigid-body dynamics.
restraint(const word &name, const dictionary &dict, const rigidBodyModel &model)
Construct from the dict dictionary and Time.
spatialVector bodyPointVelocity(const point &p) const
Transform the velocity of the given point on the restrained body.
const rigidBodyModel & model_
Reference to the model.
word name_
Name of the restraint.
virtual bool read(const dictionary &dict)
Update properties from given dictionary.
const word & name() const
Return the name.
A class for handling words, derived from Foam::string.
Definition: word.H:63
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:56
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
point bodyPoint(const point &p) const
Transform the given point on the restrained body to the global frame.
label bodyIndex_
Index of the body the force is applied to.
label bodyID_
ID of the body the restraint is applied to.
virtual autoPtr< restraint > clone() const =0
Construct and return a clone.
virtual ~restraint()
Destructor.
dictionary coeffs_
Restraint model specific coefficient dictionary.
const dictionary & coeffDict() const
Return access to coeffs.
Pointer management similar to std::unique_ptr, with some additional methods and type checking...
Definition: HashPtrTable.H:48
Basic rigid-body model representing a system of rigid-bodies connected by 1-6 DoF joints...
Macros to ease declaration of run-time selection tables.
virtual void write(Ostream &) const =0
Write.
volScalarField & p
static autoPtr< restraint > New(const word &name, const dictionary &dict, const rigidBodyModel &model)
Select constructed from the dict dictionary and Time.
TypeName("restraint")
Runtime type information.
Namespace for OpenFOAM.