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-2020 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"
29 
30 using namespace Foam::constant::mathematical;
31 
32 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
33 
34 namespace Foam
35 {
36 namespace solidBodyMotionFunctions
37 {
38  defineTypeNameAndDebug(sixDoFMotion, 0);
40  (
41  solidBodyMotionFunction,
42  sixDoFMotion,
43  dictionary
44  );
45 }
46 }
47 
48 
49 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
50 
51 #include "None.H"
52 #include "Constant.H"
53 #include "Uniform.H"
54 #include "ZeroConstant.H"
55 #include "OneConstant.H"
56 #include "Polynomial1.H"
57 #include "Sine.H"
58 #include "Square.H"
59 #include "Table.H"
60 #include "UniformTable1.H"
61 #include "NonUniformTable1.H"
62 #include "EmbeddedTableReader.H"
63 #include "FoamTableReader.H"
64 #include "Scale.H"
65 #include "CodedFunction1.H"
66 
69 
70 template<>
71 const char* const trvType::vsType::typeName = "vector2Vector";
72 
73 template<>
74 const char* const trvType::vsType::componentNames[] = {"x", "y"};
75 
76 template<>
78 (
80 );
81 
82 template<>
84 
85 template<>
87 
88 template<>
90 
91 template<>
93 (
95 );
96 
97 template<>
99 (
100  trvType::uniform(vector::uniform(-rootVGreat))
101 );
102 
103 namespace Foam
104 {
106 
108  makeTableReader(Embedded, trvType);
110 }
111 
112 
113 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
114 
116 (
117  const dictionary& SBMFCoeffs,
118  const Time& runTime
119 )
120 :
121  solidBodyMotionFunction(SBMFCoeffs, runTime)
122 {
123  read(SBMFCoeffs);
124 }
125 
126 
127 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
128 
130 {}
131 
132 
133 // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
134 
137 {
138  const scalar t = time_.value();
139 
140  translationRotationVectors TRV = translationRotation_->value(t);
141 
142  // Convert the rotational motion from deg to rad
143  TRV[1] *= pi/180.0;
144 
145  quaternion R(quaternion::XYZ, TRV[1]);
146  septernion TR(septernion(-CofG_ + -TRV[0])*R*septernion(CofG_));
147 
148  DebugInFunction << "Time = " << t << " transformation: " << TR << endl;
149 
150  return TR;
151 }
152 
153 
155 (
156  const dictionary& SBMFCoeffs
157 )
158 {
159  solidBodyMotionFunction::read(SBMFCoeffs);
160 
161  translationRotation_ = Function1<translationRotationVectors>::New
162  (
163  "translationRotation",
164  SBMFCoeffs
165  );
166 
167  SBMFCoeffs_.lookup("CofG") >> CofG_;
168 
169  return true;
170 }
171 
172 
173 // ************************************************************************* //
static const char *const typeName
Definition: VectorSpace.H:111
virtual septernion transformation() const
Return the solid-body motion transformation septernion.
Definition: sixDoFMotion.C:136
static const Form max
Definition: VectorSpace.H:115
makeFunction1s(trvType)
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:156
static const char *const componentNames[]
Definition: VectorSpace.H:112
static const Form rootMin
Definition: VectorSpace.H:118
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
Foam::solidBodyMotionFunctions::sixDoFMotion::translationRotationVectors trvType
Definition: sixDoFMotion.C:68
Septernion class used to perform translations and rotations in 3D space.
Definition: septernion.H:65
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:68
Macros for easy insertion into run-time selection tables.
static const Form min
Definition: VectorSpace.H:116
bool read(const char *, int32_t &)
Definition: int32IO.C:85
Base class for defining solid-body motions.
mathematical constants.
#define DebugInFunction
Report an information message using Foam::Info.
virtual bool read(const dictionary &SBMFCoeffs)=0
Update properties from given dictionary.
Quaternion class used to perform rotations in 3D space.
Definition: quaternion.H:60
addToRunTimeSelectionTable(ensightPart, ensightPartCells, istream)
defineTypeNameAndDebug(combustionModel, 0)
makeTableReader(Embedded, trvType)
static const Form rootMax
Definition: VectorSpace.H:117
#define R(A, B, C, D, E, F, K, M)
sixDoFMotion(const dictionary &SBMFCoeffs, const Time &runTime)
Construct from components.
Definition: sixDoFMotion.C:116
static const Form one
Definition: VectorSpace.H:114
static Vector2D< Cmpt > uniform(const Cmpt &s)
Return a VectorSpace with all elements = s.
Definition: VectorSpaceI.H:168
Templated 2D Vector derived from VectorSpace adding construction from 2 components, element access using x() and y() member functions and the inner-product (dot-product).
Definition: Vector2D.H:51
defineTableReader(trvType)
static const Form zero
Definition: VectorSpace.H:113
virtual bool read(const dictionary &SBMFCoeffs)
Update properties from given dictionary.
Definition: sixDoFMotion.C:155
Namespace for OpenFOAM.
static autoPtr< Function1< Type > > New(const word &name, const dictionary &dict)
Selector.
Definition: Function1New.C:32