1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright held by original author
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
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 the
13 Free Software Foundation; either version 2 of the License, or (at your
14 option) any later version.
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
21 You should have received a copy of the GNU General Public License
22 along with OpenFOAM; if not, write to the Free Software Foundation,
23 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
26 Hrvoje Jasak, Wikki Ltd. All rights reserved.
28 \*---------------------------------------------------------------------------*/
30 #include "harmonicSolidMotion.H"
31 #include "addToRunTimeSelectionTable.H"
32 #include "volFields.H"
33 #include "mathematicalConstants.H"
34 #include "axisCoordinateRotation.H"
36 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
40 defineTypeNameAndDebug(harmonicSolidMotion, 0);
41 addToRunTimeSelectionTable(dynamicFvMesh, harmonicSolidMotion, IOobject);
45 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
47 Foam::vector Foam::harmonicSolidMotion::periodToFreq(const vector period)
52 2.0*mathematicalConstant::pi/(period.x() + SMALL),
53 2.0*mathematicalConstant::pi/(period.y() + SMALL),
54 2.0*mathematicalConstant::pi/(period.z() + SMALL)
59 Foam::vector Foam::harmonicSolidMotion::centre() const
61 const scalar t = time().value();
70 sin(transOmega_.x()*t + transPsi_.x()),
71 sin(transOmega_.y()*t + transPsi_.y()),
72 sin(transOmega_.z()*t + transPsi_.z())
78 Foam::vector Foam::harmonicSolidMotion::rotation() const
80 const scalar t = time().value();
88 sin(rotOmega_.x()*t + rotPsi_.x()),
89 sin(rotOmega_.y()*t + rotPsi_.y()),
90 sin(rotOmega_.z()*t + rotPsi_.z())
96 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
98 Foam::harmonicSolidMotion::harmonicSolidMotion(const IOobject& io)
108 io.time().constant(),
113 ).subDict(typeName + "Coeffs")
121 polyMesh::meshSubDir,
127 motionCentre_(dict_.lookup("motionCentre")),
128 transL_(dict_.lookup("translationAmplitude")),
129 transOmega_(periodToFreq(dict_.lookup("translationPeriod"))),
130 transPsi_(dict_.lookup("translationPhase")),
131 rotL_(dict_.lookup("rotationAmplitude")),
132 rotOmega_(periodToFreq(dict_.lookup("rotationPeriod"))),
133 rotPsi_(dict_.lookup("rotationPhase"))
135 refPoints_.rename("refPoints");
137 Switch inDegrees(dict_.lookup("inDegrees"));
141 transPsi_ *= mathematicalConstant::pi/180.0;
142 rotL_ *= mathematicalConstant::pi/180.0;
143 rotPsi_ *= mathematicalConstant::pi/180.0;
148 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
150 Foam::harmonicSolidMotion::~harmonicSolidMotion()
154 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
156 bool Foam::harmonicSolidMotion::update()
158 Info << "Updating point position" << endl;
161 vector r = rotation();
162 tensor R = axisCoordinateRotation(r.x(), r.y(), r.z(), false);
164 fvMesh::movePoints((R & (refPoints_ - motionCentre_)) + c);
166 // Mesh motion only - return false
171 // ************************************************************************* //