sixDoFMotion.C
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) 2011-2024 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 \*---------------------------------------------------------------------------*/
25 
26 #include "sixDoFMotion.H"
27 #include "mathematicalConstants.H"
28 #include "makeFunction1s.H"
29 #include "makeTableReaders.H"
31 
32 using namespace Foam::constant::mathematical;
33 
34 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
35 
36 namespace Foam
37 {
38 namespace solidBodyMotionFunctions
39 {
42  (
46  );
47 }
48 }
49 
50 
51 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
52 
55 
56 template<>
57 const char* const trvType::vsType::typeName = "vector2Vector";
58 
59 template<>
60 const char* const trvType::vsType::componentNames[] = {"x", "y"};
61 
62 template<>
64 (
66 );
67 
68 template<>
70 
71 template<>
73 
74 template<>
76 
77 template<>
79 (
81 );
82 
83 template<>
85 (
86  trvType::uniform(vector::uniform(-rootVGreat))
87 );
88 
89 template<>
91 
92 namespace Foam
93 {
96 }
97 
98 
99 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
100 
102 (
103  const dictionary& SBMFCoeffs,
104  const Time& runTime
105 )
106 :
107  solidBodyMotionFunction(SBMFCoeffs, runTime)
108 {
109  read(SBMFCoeffs);
110 }
111 
112 
113 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
114 
116 {}
117 
118 
119 // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
120 
123 {
124  const scalar t = time_.value();
125 
126  translationRotationVectors TRV = translationRotation_->value(t);
127 
128  // Convert the rotational motion from deg to rad
129  TRV[1] *= pi/180.0;
130 
131  quaternion R(quaternion::XYZ, TRV[1]);
132  septernion TR(septernion(-CofG_ + -TRV[0])*R*septernion(CofG_));
133 
134  DebugInFunction << "Time = " << t << " transformation: " << TR << endl;
135 
136  return TR;
137 }
138 
139 
141 (
142  const dictionary& SBMFCoeffs
143 )
144 {
145  solidBodyMotionFunction::read(SBMFCoeffs);
146 
147  translationRotation_.reset
148  (
150  (
151  "translationRotation",
152  time_.userUnits(),
153  unitNone,
154  SBMFCoeffs_
155  ).ptr()
156  );
157 
158  SBMFCoeffs_.lookup("CofG") >> CofG_;
159 
160  return true;
161 }
162 
163 
164 // ************************************************************************* //
Macros for easy insertion into run-time selection tables.
Run-time selectable general function of one variable.
Definition: Function1.H:125
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:76
Templated 2D Vector derived from VectorSpace adding construction from 2 components,...
Definition: Vector2D.H:54
static const Form zero
Definition: VectorSpace.H:118
static const char *const componentNames[]
Definition: VectorSpace.H:117
static const Form one
Definition: VectorSpace.H:119
static const Form nan
Definition: VectorSpace.H:124
static const Form rootMax
Definition: VectorSpace.H:122
static const Form max
Definition: VectorSpace.H:120
static const Form rootMin
Definition: VectorSpace.H:123
static Vector2D< Cmpt > uniform(const Cmpt &s)
Return a VectorSpace with all elements = s.
Definition: VectorSpaceI.H:168
static const Form min
Definition: VectorSpace.H:121
static const char *const typeName
Definition: VectorSpace.H:116
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:162
Quaternion class used to perform rotations in 3D space.
Definition: quaternion.H:61
Septernion class used to perform translations and rotations in 3D space.
Definition: septernion.H:66
Base class for defining solid-body motions.
virtual bool read(const dictionary &SBMFCoeffs)=0
Update properties from given dictionary.
Tabulated 6DoF motion function.
Definition: sixDoFMotion.H:60
sixDoFMotion(const dictionary &SBMFCoeffs, const Time &runTime)
Construct from components.
Definition: sixDoFMotion.C:102
virtual septernion transformation() const
Return the solid-body motion transformation septernion.
Definition: sixDoFMotion.C:122
virtual bool read(const dictionary &SBMFCoeffs)
Update properties from given dictionary.
Definition: sixDoFMotion.C:141
#define DebugInFunction
Report an information message using Foam::Info.
mathematical constants.
Namespace for OpenFOAM.
addToRunTimeSelectionTable(polyPatch, mergedCyclicPolyPatch, word)
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:257
const unitConversion unitNone
defineTypeNameAndDebug(combustionModel, 0)
static scalar R(const scalar a, const scalar x)
Definition: invIncGamma.C:102
makeFoamTableReaders(avType, nullArg)
makeFunction1s(avType, nullArg)
Foam::solidBodyMotionFunctions::sixDoFMotion::translationRotationVectors trvType
Definition: sixDoFMotion.C:54