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-2023 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 {
40  (
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  namespace TableReaders
109  {
112  }
113 }
114 
115 
116 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
117 
119 (
120  const dictionary& SBMFCoeffs,
121  const Time& runTime
122 )
123 :
124  solidBodyMotionFunction(SBMFCoeffs, runTime)
125 {
126  read(SBMFCoeffs);
127 }
128 
129 
130 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
131 
133 {}
134 
135 
136 // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
137 
140 {
141  const scalar t = time_.value();
142 
143  translationRotationVectors TRV = translationRotation_->value(t);
144 
145  // Convert the rotational motion from deg to rad
146  TRV[1] *= pi/180.0;
147 
148  quaternion R(quaternion::XYZ, TRV[1]);
149  septernion TR(septernion(-CofG_ + -TRV[0])*R*septernion(CofG_));
150 
151  DebugInFunction << "Time = " << t << " transformation: " << TR << endl;
152 
153  return TR;
154 }
155 
156 
158 (
159  const dictionary& SBMFCoeffs
160 )
161 {
162  solidBodyMotionFunction::read(SBMFCoeffs);
163 
164  translationRotation_ = Function1<translationRotationVectors>::New
165  (
166  "translationRotation",
167  SBMFCoeffs_
168  );
169 
170  SBMFCoeffs_.lookup("CofG") >> CofG_;
171 
172  return true;
173 }
174 
175 
176 // ************************************************************************* //
#define makeTableReader(SS, Type)
Definition: TableReader.H:121
Macros for easy insertion into run-time selection tables.
static autoPtr< Function1< Type > > New(const word &name, const dictionary &dict)
Selector.
Definition: Function1New.C:32
Reads an interpolation table from the values entry in OpenFOAM-format.
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:113
static const char *const componentNames[]
Definition: VectorSpace.H:112
static const Form one
Definition: VectorSpace.H:114
static const Form rootMax
Definition: VectorSpace.H:117
static const Form max
Definition: VectorSpace.H:115
static const Form rootMin
Definition: VectorSpace.H:118
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:116
static const char *const typeName
Definition: VectorSpace.H:111
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:160
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:119
virtual septernion transformation() const
Return the solid-body motion transformation septernion.
Definition: sixDoFMotion.C:139
virtual bool read(const dictionary &SBMFCoeffs)
Update properties from given dictionary.
Definition: sixDoFMotion.C:158
#define DebugInFunction
Report an information message using Foam::Info.
mathematical constants.
Namespace for OpenFOAM.
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
makeFunction1s(trvType, nullArg)
defineTypeNameAndDebug(combustionModel, 0)
defineTableReader(trvType)
static scalar R(const scalar a, const scalar x)
Definition: invIncGamma.C:102
addToRunTimeSelectionTable(ensightPart, ensightPartCells, istream)
Foam::solidBodyMotionFunctions::sixDoFMotion::translationRotationVectors trvType
Definition: sixDoFMotion.C:68