Loading...
Searching...
No Matches
oscillatingLinearMotion.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) 2022 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
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
32// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
33
34namespace Foam
35{
37{
38 defineTypeNameAndDebug(oscillatingLinearMotion, 0);
40 (
42 oscillatingLinearMotion,
44 );
45}
46}
47
48
49// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
50
51Foam::solidBodyMotionFunctions::oscillatingLinearMotion::oscillatingLinearMotion
52(
53 const dictionary& SBMFCoeffs,
54 const Time& runTime
55)
56:
58 omegaPtr_(Function1<scalar>::New("omega", SBMFCoeffs_, &runTime)),
59 phaseShiftPtr_
60 (
61 Function1<scalar>::NewIfPresent
62 (
63 "phaseShift",
64 SBMFCoeffs_,
65 word::null,
66 &runTime
67 )
68 ),
69 amplitudePtr_(Function1<vector>::New("amplitude", SBMFCoeffs_, &runTime)),
70 verticalShiftPtr_
71 (
72 Function1<vector>::NewIfPresent
73 (
74 "verticalShift",
75 SBMFCoeffs_,
76 word::null,
77 &runTime
78 )
79 )
80{
81 read(SBMFCoeffs);
82}
83
84
85// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
86
88Foam::solidBodyMotionFunctions::oscillatingLinearMotion::transformation() const
89{
90 const scalar t = time_.value();
91
92 const vector amplitude(amplitudePtr_->value(t));
93 const scalar omega = omegaPtr_->value(t);
94
95 scalar phaseShift = 0;
96 if (phaseShiftPtr_)
97 {
98 phaseShift = phaseShiftPtr_->value(t);
99 }
100
101 vector verticalShift(Zero);
102 if (verticalShiftPtr_)
103 {
104 verticalShift = verticalShiftPtr_->value(t);
105 }
106
107 const vector displacement
108 (
109 amplitude*sin(omega*(t + phaseShift)) + verticalShift
110 );
111
112 quaternion R(1);
113 septernion TR(septernion(-displacement)*R);
114
115 DebugInFunction << "Time = " << t << " transformation: " << TR << endl;
116
117 return TR;
118}
119
120
121bool Foam::solidBodyMotionFunctions::oscillatingLinearMotion::read
122(
123 const dictionary& SBMFCoeffs
124)
125{
126 if (!solidBodyMotionFunction::read(SBMFCoeffs))
127 {
128 return false;
129 }
130
131 omegaPtr_.reset
132 (
133 Function1<scalar>::New("omega", SBMFCoeffs_, &time_)
134 );
135
136 phaseShiftPtr_.reset
137 (
139 (
140 "phaseShift",
141 SBMFCoeffs_,
143 &time_
144 )
145 );
146
147 amplitudePtr_.reset
148 (
149 Function1<vector>::New("amplitude", SBMFCoeffs_, &time_)
150 );
151
152 verticalShiftPtr_.reset
153 (
155 (
156 "verticalShift",
157 SBMFCoeffs_,
159 &time_
160 )
161 );
162
163 return true;
164}
165
166
167// ************************************************************************* //
#define R(A, B, C, D, E, F, K, M)
Macros for easy insertion into run-time selection tables.
#define addToRunTimeSelectionTable(baseType, thisType, argNames)
Add to construction table with typeName as the key.
Top level data entry class for use in dictionaries. Provides a mechanism to specify a variable as a c...
Definition Function1.H:92
static autoPtr< Function1< Type > > NewIfPresent(const word &entryName, const dictionary &dict, const word &redirectType, const objectRegistry *obrPtr=nullptr)
An optional selector, with fallback redirection.
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition Time.H:75
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition dictionary.H:133
Quaternion class used to perform rotations in 3D space.
Definition quaternion.H:54
Septernion class used to perform translations and rotations in 3D space.
Definition septernion.H:63
Base class for defining solid-body motions.
virtual bool read(const dictionary &SBMFCoeffs)=0
Update properties from given dictionary.
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
A class for handling words, derived from Foam::string.
Definition word.H:66
static const word null
An empty word.
Definition word.H:84
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
Definition className.H:142
engineTime & runTime
#define DebugInFunction
Report an information message using Foam::Info.
Namespace for solid-body motions.
Namespace for OpenFOAM.
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh > > &tf1, const word &name, const dimensionSet &dimensions, const bool initCopy=false)
Global function forwards to reuseTmpDimensionedField::New.
bool read(const char *buf, int32_t &val)
Same as readInt32.
Definition int32.H:127
dimensionedScalar sin(const dimensionedScalar &ds)
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition Ostream.H:519
static constexpr const zero Zero
Global zero (0).
Definition zero.H:127
Vector< scalar > vector
Definition vector.H:57