oscillatingRotatingMotion.C
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-2016 OpenFOAM Foundation
9  Copyright (C) 2019 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 \*---------------------------------------------------------------------------*/
28 
31 #include "unitConversion.H"
32 
33 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
34 
35 namespace Foam
36 {
37 namespace solidBodyMotionFunctions
38 {
39  defineTypeNameAndDebug(oscillatingRotatingMotion, 0);
41  (
42  solidBodyMotionFunction,
43  oscillatingRotatingMotion,
44  dictionary
45  );
46 }
47 }
48 
49 
50 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
51 
52 Foam::solidBodyMotionFunctions::oscillatingRotatingMotion::
53 oscillatingRotatingMotion
54 (
55  const dictionary& SBMFCoeffs,
56  const Time& runTime
57 )
58 :
59  solidBodyMotionFunction(SBMFCoeffs, runTime)
60 {
61  read(SBMFCoeffs);
62 }
63 
64 
65 // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
66 
70 {
71  scalar t = time_.value();
72 
73  vector eulerAngles = amplitude_*sin(omega_*t);
74 
75  // Convert the rotational motion from deg to rad
76  eulerAngles *= degToRad();
77 
78  quaternion R(quaternion::XYZ, eulerAngles);
79  septernion TR(septernion(-origin_)*R*septernion(origin_));
80 
81  DebugInFunction << "Time = " << t << " transformation: " << TR << endl;
82 
83  return TR;
84 }
85 
86 
88 (
89  const dictionary& SBMFCoeffs
90 )
91 {
93 
94  SBMFCoeffs_.readEntry("origin", origin_);
95  SBMFCoeffs_.readEntry("amplitude", amplitude_);
96  SBMFCoeffs_.readEntry("omega", omega_);
97 
98  return true;
99 }
100 
101 
102 // ************************************************************************* //
runTime
engineTime & runTime
Definition: createEngineTime.H:13
Foam::Time
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:73
Foam::septernion
Septernion class used to perform translations and rotations in 3D space.
Definition: septernion.H:66
Foam::solidBodyMotionFunctions::addToRunTimeSelectionTable
addToRunTimeSelectionTable(solidBodyMotionFunction, axisRotationMotion, dictionary)
Foam::sin
dimensionedScalar sin(const dimensionedScalar &ds)
Definition: dimensionedScalar.C:264
unitConversion.H
Unit conversion functions.
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:369
Foam::dimensioned::value
const Type & value() const
Return const reference to value.
Definition: dimensionedType.C:434
Foam::quaternion
Quaternion class used to perform rotations in 3D space.
Definition: quaternion.H:56
Foam::blockMeshTools::read
void read(Istream &, label &val, const dictionary &)
In-place read with dictionary lookup.
Definition: blockMeshTools.C:57
R
#define R(A, B, C, D, E, F, K, M)
DebugInFunction
#define DebugInFunction
Report an information message using Foam::Info.
Definition: messageStream.H:388
Foam::solidBodyMotionFunctions::oscillatingRotatingMotion::read
virtual bool read(const dictionary &SBMFCoeffs)
Update properties from given dictionary.
Definition: oscillatingRotatingMotion.C:88
Foam::solidBodyMotionFunction
Base class for defining solid-body motions.
Definition: solidBodyMotionFunction.H:63
Foam::solidBodyMotionFunctions::defineTypeNameAndDebug
defineTypeNameAndDebug(axisRotationMotion, 0)
Foam::quaternion::XYZ
Definition: quaternion.H:108
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:123
addToRunTimeSelectionTable.H
Macros for easy insertion into run-time selection tables.
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
oscillatingRotatingMotion.H
Foam::degToRad
constexpr scalar degToRad(const scalar deg) noexcept
Conversion from degrees to radians.
Definition: unitConversion.H:48
Foam::solidBodyMotionFunction::read
virtual bool read(const dictionary &SBMFCoeffs)=0
Update properties from given dictionary.
Definition: solidBodyMotionFunction.C:60
Foam::Vector< scalar >
Foam::solidBodyMotionFunction::time_
const Time & time_
Definition: solidBodyMotionFunction.H:71
Foam::solidBodyMotionFunctions::oscillatingRotatingMotion::transformation
virtual septernion transformation() const
Return the solid-body motion transformation septernion.
Definition: oscillatingRotatingMotion.C:69