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-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 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 class rigidBodyModelState;
62 
63 /*---------------------------------------------------------------------------*\
64  Class restraint Declaration
65 \*---------------------------------------------------------------------------*/
66 
67 class restraint
68 {
69 
70 protected:
71 
72  // Protected data
73 
74  //- Name of the restraint
75  word name_;
76 
77  //- ID of the body the restraint is applied to
78  label bodyID_;
79 
80  //- Index of the body the force is applied to
82 
83  //- Restraint model specific coefficient dictionary
85 
86  //- Reference to the model
87  const rigidBodyModel& model_;
88 
89  //- Transform the given point on the restrained body to the global frame
90  inline point bodyPoint(const point& p) const;
91 
92  //- Transform the velocity of the given point on the restrained body
93  // to the global frame
94  inline spatialVector bodyPointVelocity(const point& p) const;
95 
96 
97 public:
98 
99  //- Runtime type information
100  TypeName("restraint");
101 
102 
103  // Declare run-time constructor selection table
104 
106  (
107  autoPtr,
108  restraint,
109  dictionary,
110  (
111  const word& name,
112  const dictionary& dict,
113  const rigidBodyModel& model
114  ),
115  (name, dict, model)
116  );
117 
118 
119  // Constructors
120 
121  //- Construct from the dict dictionary and Time
122  restraint
123  (
124  const word& name,
125  const dictionary& dict,
126  const rigidBodyModel& model
127  );
128 
129  //- Construct and return a clone
130  virtual autoPtr<restraint> clone() const = 0;
131 
132 
133  // Selectors
134 
135  //- Select constructed from the dict dictionary and Time
136  static autoPtr<restraint> New
137  (
138  const word& name,
139  const dictionary& dict,
140  const rigidBodyModel& model
141  );
142 
143 
144  //- Destructor
145  virtual ~restraint();
146 
147 
148  // Member Functions
149 
150  //- Return the name
151  const word& name() const
152  {
153  return name_;
154  }
156  label bodyID() const
157  {
158  return bodyID_;
159  }
160 
161  //- Accumulate the retraint internal joint forces into the tau field and
162  // external forces into the fx field
163  virtual void restrain
164  (
165  scalarField& tau,
167  const rigidBodyModelState& state
168  ) const = 0;
169 
170  //- Update properties from given dictionary
171  virtual bool read(const dictionary& dict);
172 
173  //- Return access to coeffs
174  const dictionary& coeffDict() const;
175 
176  //- Write
177  virtual void write(Ostream&) const = 0;
178 };
179 
180 
181 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
182 
183 } // End namespace RBD
184 } // End namespace Foam
185 
186 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
187 
188 #include "rigidBodyRestraintI.H"
189 
190 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
191 
192 #endif
193 
194 // ************************************************************************* //
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 retraint internal joint forces into the tau field and.
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.
const rigidBodyModel & model_
Reference to the model.
Holds the motion state of rigid-body 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:54
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.