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 "graphSolidMotion.H"
31 #include "addToRunTimeSelectionTable.H"
32 #include "volFields.H"
33 #include "mathematicalConstants.H"
34 #include "axisCoordinateRotation.H"
35 #include "interpolateXY.H"
38 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
42 defineTypeNameAndDebug(graphSolidMotion, 0);
43 addToRunTimeSelectionTable(dynamicFvMesh, graphSolidMotion, IOobject);
47 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
49 Foam::vector Foam::graphSolidMotion::centre() const
51 const scalar t = time().value();
56 interpolateXY(t, x_.x(), x_.y()),
57 interpolateXY(t, y_.x(), y_.y()),
58 interpolateXY(t, z_.x(), z_.y())
63 Foam::vector Foam::graphSolidMotion::rotation() const
65 const scalar t = time().value();
67 scalar xAngle = interpolateXY(t, xRot_.x(), xRot_.y());
68 scalar yAngle = interpolateXY(t, yRot_.x(), yRot_.y());
69 scalar zAngle = interpolateXY(t, zRot_.x(), zRot_.y());
73 xAngle *= mathematicalConstant::pi/180.0;
74 yAngle *= mathematicalConstant::pi/180.0;
75 zAngle *= mathematicalConstant::pi/180.0;
78 return vector(xAngle, yAngle, zAngle);
82 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
84 Foam::graphSolidMotion::graphSolidMotion(const IOobject& io)
99 ).subDict(typeName + "Coeffs")
107 polyMesh::meshSubDir,
113 motionCentre_(dict_.lookup("motionCentre")),
119 IFstream(time().path()/time().caseConstant()/word(dict_.lookup("x")))()
126 IFstream(time().path()/time().caseConstant()/word(dict_.lookup("y")))()
133 IFstream(time().path()/time().caseConstant()/word(dict_.lookup("z")))()
140 IFstream(time().path()/time().caseConstant()/word(dict_.lookup("xRot")))()
147 IFstream(time().path()/time().caseConstant()/word(dict_.lookup("yRot")))()
154 IFstream(time().path()/time().caseConstant()/word(dict_.lookup("zRot")))()
156 inDegrees_(dict_.lookup("inDegrees"))
158 refPoints_.rename("refPoints");
162 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
164 Foam::graphSolidMotion::~graphSolidMotion()
168 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
170 bool Foam::graphSolidMotion::update()
172 Info << "Updating point position" << endl;
175 vector r = rotation();
176 tensor R = axisCoordinateRotation(r.x(), r.y(), r.z(), false);
178 fvMesh::movePoints((R & (refPoints_ - motionCentre_)) + c);
180 // Mesh motion only - return false
185 // ************************************************************************* //