sixDoFRigidBodyMotionAxisConstraint.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) 2011-2014 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::sixDoFRigidBodyMotionConstraints::axis
29 
30 Description
31  This constraint imposes an orientation limitation where bodies
32  are restricted to rotate only around a fixed axis, optionally with
33  the inclusion of maximum and minimum rotation angle constraints.
34 
35 Usage
36  Minimal example by \c constant/dynamicMeshDict.sixDoFRigidBodyMotionCoeffs:
37  \verbatim
38  constraints
39  {
40  constrainRotation1
41  {
42  // Mandatory entries
43  sixDoFRigidBodyMotionConstraint axis;
44  axis <vector>;
45 
46  // Optional entries
47  maxClockwiseTheta <Function1<scalar>>;
48  maxCounterclockwiseTheta <Function1<scalar>>;
49  thetaUnits <word>;
50  referenceOrientation <tensor>;
51  }
52  }
53  \endverbatim
54 
55  where the entries mean:
56  \table
57  Property | Description | Type | Reqd | Deflt
58  sixDoFRigidBodyMotionConstraint | Type name: axis | word | yes | -
59  axis | Reference rotation axis fixed in global space <!--
60  --> | vector | yes | -
61  maxClockwiseTheta | Maximum clockwise rotation angle about the <!--
62  --> rotation axis | Function1<scalar> | no | -
63  maxCounterlockwiseTheta | Maximum counterclockwise rotation <!--
64  --> angle about the rotation axis | Function1<scalar> | no | -
65  thetaUnits | Units of theta angles | word | no | radians
66  referenceOrientation | Reference orientation where there is no moment <!--
67  --> | tensor | no | I
68  \endtable
69 
70  The inherited entries are elaborated in:
71  - \link Function1.H \endlink
72 
73 Notes
74  - The units for \c thetaUnits can be specified
75  as either \c degrees or \c radians.
76  - The \c maxClockwiseTheta and \c maxCounterlockwiseTheta
77  are always non-negative.
78  - Negative and positive \c theta correspond to clockwise
79  and counterclockwise rotation sectors with respect to
80  the reference orientation, respectively.
81 
82 SourceFiles
83  sixDoFRigidBodyMotionAxisConstraint.C
84 
85 \*---------------------------------------------------------------------------*/
86 
87 #ifndef Foam_sixDoFRigidBodyMotionAxisConstraint_H
88 #define Foam_sixDoFRigidBodyMotionAxisConstraint_H
89 
91 #include "Function1.H"
92 
93 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
94 
95 namespace Foam
96 {
97 
98 namespace sixDoFRigidBodyMotionConstraints
99 {
100 
101 /*---------------------------------------------------------------------------*\
102  Class axis Declaration
103 \*---------------------------------------------------------------------------*/
104 
105 class axis
106 :
107  public sixDoFRigidBodyMotionConstraint
108 {
109  // Private Data
110 
111  //- Reference orientation where there is no moment
112  tensor refQ_;
113 
114  //- Reference rotation axis fixed in global space
115  vector axis_;
116 
117  //- Maximum clockwise rotation angle around the rotation axis
118  autoPtr<Function1<scalar>> maxCWThetaPtr_;
119 
120  //- Maximum counterclockwise rotation angle around the rotation axis
121  autoPtr<Function1<scalar>> maxCCWThetaPtr_;
122 
123  //- Flag to enable to use maxTheta in degrees rather than in radians
124  bool degrees_;
125 
126 
127  // Private Member Functions
128 
129  //- Return the index of the rotation sector that the
130  //- body resides with respect to the reference orientation
131  // -1: clockwise, 0: reference orientation, 1: counterclockwise
132  label rotationSector(const vector& oldDir, const vector& newDir) const;
133 
134  //- Return the direction of the given force or momentum
135  // false: clockwise, true: counterclockwise
136  bool calcDir(const vector& fm, const bool rotationSector) const;
137 
138 
139 public:
140 
141  //- Runtime type information
142  TypeName("axis");
143 
144 
145  // Constructors
146 
147  //- Construct from components
148  axis
149  (
150  const word& name,
151  const dictionary& sDoFRBMCDict,
153  );
154 
155  //- Construct and return a clone
157  {
159  (
160  new axis(*this)
161  );
162  }
163 
164  //- No copy assignment
165  void operator=(const sixDoFRigidBodyMotionConstraint&) = delete;
166 
167 
168  //- Destructor
169  virtual ~axis() = default;
170 
171 
172  // Member Functions
173 
174  //- Apply and accumulate translational constraints
175  virtual void constrainTranslation(pointConstraint&) const;
176 
177  //- Apply and accumulate rotational constraints
178  virtual void constrainRotation(pointConstraint&) const;
179 
180  //- Update properties from given dictionary
181  virtual bool read(const dictionary& sDoFRBMCCoeff);
182 
183  //- Write
184  virtual void write(Ostream&) const;
185 };
186 
187 
188 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
189 
190 } // End namespace solidBodyMotionFunctions
191 } // End namespace Foam
192 
193 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
194 
195 #endif
196 
197 // ************************************************************************* //
Six degree of freedom motion for a rigid body.
const sixDoFRigidBodyMotion & motion() const noexcept
Return const access to motion.
virtual autoPtr< sixDoFRigidBodyMotionConstraint > clone() const
Construct and return a clone.
TypeName("axis")
Runtime type information.
const word & name() const
Return the name.
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:129
Tensor< scalar > tensor
Definition: symmTensor.H:57
Base class for defining constraints for sixDoF motions.
A class for handling words, derived from Foam::string.
Definition: word.H:63
virtual bool read(const dictionary &sDoFRBMCCoeff)
Update properties from given dictionary.
Vector< scalar > vector
Definition: vector.H:57
Accumulates point constraints through successive applications of the applyConstraint function...
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:56
axis(const word &name, const dictionary &sDoFRBMCDict, const sixDoFRigidBodyMotion &motion)
Construct from components.
virtual void constrainTranslation(pointConstraint &) const
Apply and accumulate translational constraints.
virtual ~axis()=default
Destructor.
void operator=(const sixDoFRigidBodyMotionConstraint &)=delete
No copy assignment.
Pointer management similar to std::unique_ptr, with some additional methods and type checking...
Definition: HashPtrTable.H:48
virtual void constrainRotation(pointConstraint &) const
Apply and accumulate rotational constraints.
Namespace for OpenFOAM.