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