sixDoFSolver.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) 2015 OpenFOAM Foundation
9  Copyright (C) 2023 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 Class
28  Foam::sixDoFSolver
29 
30 Group
31  grpSixDoFRigidBodySolvers
32 
33 Description
34 
35 SourceFiles
36  sixDoFSolver.C
37  newSixDoFSolver.C
38 
39 \*---------------------------------------------------------------------------*/
40 
41 #ifndef sixDoFSolver_H
42 #define sixDoFSolver_H
43 
44 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
45 
46 #include "sixDoFRigidBodyMotion.H"
47 #include "runTimeSelectionTables.H"
48 
49 namespace Foam
50 {
51 
52 /*---------------------------------------------------------------------------*\
53  Class sixDoFSolver Declaration
54 \*---------------------------------------------------------------------------*/
55 
56 class sixDoFSolver
57 {
58 protected:
59 
60  // Protected data
61 
62  //- The rigid body
64 
65  //- Model dictionary
67 
68 
69  // Protected member functions
70 
71  //- Return the current centre of rotation
72  inline point& centreOfRotation();
73 
74  //- Return the orientation
75  inline tensor& Q();
76 
77  //- Return non-const access to vector
78  inline vector& v();
79 
80  //- Return non-const access to acceleration
81  inline vector& a();
82 
83  //- Return non-const access to angular momentum
84  inline vector& pi();
85 
86  //- Return non-const access to torque
87  inline vector& tau();
88 
89  //- Return the centre of rotation at previous time-step
90  inline const point& centreOfRotation0() const;
91 
92  //- Return the orientation at previous time-step
93  inline const tensor& Q0() const;
94 
95  //- Return the velocity at previous time-step
96  inline const vector& v0() const;
97 
98  //- Return the acceleration at previous time-step
99  inline const vector& a0() const;
100 
101  //- Return the angular momentum at previous time-step
102  inline const vector& pi0() const;
103 
104  //- Return the torque at previous time-step
105  inline const vector& tau0() const;
106 
107  //- Acceleration damping coefficient (for steady-state simulations)
108  inline scalar aDamp() const;
109 
110  //- Translational constraint tensor
111  inline tensor tConstraints() const;
112 
113  //- Rotational constraint tensor
114  inline tensor rConstraints() const;
115 
116  //- Apply rotation tensors to Q0 for the given torque (pi) and deltaT
117  // and return the rotated Q and pi as a tuple
119  (
120  const tensor& Q0,
121  const vector& pi,
122  const scalar deltaT
123  ) const;
124 
125  //- Update and relax accelerations from the force and torque
126  inline void updateAcceleration
127  (
128  const vector& fGlobal,
129  const vector& tauGlobal
130  );
131 
132  //- Update the constraints to the object
133  inline void updateConstraints();
134 
135 
136 public:
137 
138  //- Runtime type information
139  TypeName("sixDoFSolver");
140 
141 
142  // Declare runtime construction
143 
145  (
146  autoPtr,
147  sixDoFSolver,
148  dictionary,
149  (
150  const dictionary& dict,
152  ),
153  (dict, body)
154  );
155 
156 
157  // Constructors
158 
159  // Construct for given body
161 
162  //- Construct and return a clone
163  virtual autoPtr<sixDoFSolver> clone() const = 0;
164 
165 
166  //- Destructor
167  virtual ~sixDoFSolver();
168 
169 
170  // Selectors
171 
173  (
174  const dictionary& dict,
176  );
177 
178 
179  // Member Functions
180 
181  //- Drag coefficient
182  virtual void solve
183  (
184  bool firstIter,
185  const vector& fGlobal,
186  const vector& tauGlobal,
187  scalar deltaT,
188  scalar deltaT0
189  ) = 0;
190 
191 
192  //- Write
193  void write(Ostream&) const;
194 };
195 
196 
197 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
198 
199 } // End namespace Foam
200 
201 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
202 
203 #include "sixDoFSolverI.H"
204 
205 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
206 
207 #endif
208 
209 // ************************************************************************* //
Six degree of freedom motion for a rigid body.
vector & v()
Return non-const access to vector.
Definition: sixDoFSolverI.H:34
tensor tConstraints() const
Translational constraint tensor.
Definition: sixDoFSolverI.H:94
tensor rConstraints() const
Rotational constraint tensor.
Definition: sixDoFSolverI.H:99
dictionary dict
point & centreOfRotation()
Return the current centre of rotation.
Definition: sixDoFSolverI.H:24
TypeName("sixDoFSolver")
Runtime type information.
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:120
A 2-tuple for storing two objects of dissimilar types. The container is similar in purpose to std::pa...
Definition: stringOps.H:54
virtual void solve(bool firstIter, const vector &fGlobal, const vector &tauGlobal, scalar deltaT, scalar deltaT0)=0
Drag coefficient.
virtual ~sixDoFSolver()
Destructor.
Definition: sixDoFSolver.C:53
dictionary dict_
Model dictionary.
Definition: sixDoFSolver.H:65
const vector & pi0() const
Return the angular momentum at previous time-step.
Definition: sixDoFSolverI.H:78
tensor & Q()
Return the orientation.
Definition: sixDoFSolverI.H:29
Tuple2< tensor, vector > rotate(const tensor &Q0, const vector &pi, const scalar deltaT) const
Apply rotation tensors to Q0 for the given torque (pi) and deltaT.
declareRunTimeSelectionTable(autoPtr, sixDoFSolver, dictionary,(const dictionary &dict, sixDoFRigidBodyMotion &body),(dict, body))
vector & pi()
Return non-const access to angular momentum.
Definition: sixDoFSolverI.H:44
virtual autoPtr< sixDoFSolver > clone() const =0
Construct and return a clone.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:55
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
sixDoFSolver(const dictionary &dict, sixDoFRigidBodyMotion &body)
Definition: sixDoFSolver.C:36
const tensor & Q0() const
Return the orientation at previous time-step.
Definition: sixDoFSolverI.H:60
void updateAcceleration(const vector &fGlobal, const vector &tauGlobal)
Update and relax accelerations from the force and torque.
sixDoFRigidBodyMotion & body_
The rigid body.
Definition: sixDoFSolver.H:60
const point & centreOfRotation0() const
Return the centre of rotation at previous time-step.
Definition: sixDoFSolverI.H:55
const vector & a0() const
Return the acceleration at previous time-step.
Definition: sixDoFSolverI.H:72
void write(Ostream &) const
Write.
Definition: sixDoFSolver.C:46
const vector & tau0() const
Return the torque at previous time-step.
Definition: sixDoFSolverI.H:84
Pointer management similar to std::unique_ptr, with some additional methods and type checking...
Definition: HashPtrTable.H:48
void updateConstraints()
Update the constraints to the object.
Macros to ease declaration of run-time selection tables.
vector & a()
Return non-const access to acceleration.
Definition: sixDoFSolverI.H:39
static autoPtr< sixDoFSolver > New(const dictionary &dict, sixDoFRigidBodyMotion &body)
Tensor of scalars, i.e. Tensor<scalar>.
vector & tau()
Return non-const access to torque.
Definition: sixDoFSolverI.H:49
Namespace for OpenFOAM.
scalar aDamp() const
Acceleration damping coefficient (for steady-state simulations)
Definition: sixDoFSolverI.H:89
const vector & v0() const
Return the velocity at previous time-step.
Definition: sixDoFSolverI.H:66