1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2005 OpenCFD Ltd.
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
25 \*---------------------------------------------------------------------------*/
27 #include "excentreRotationFvMesh.H"
28 #include "addToRunTimeSelectionTable.H"
29 #include "volFields.H"
30 #include "mathematicalConstants.H"
33 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
37 defineTypeNameAndDebug(excentreRotationFvMesh, 0);
38 addToRunTimeSelectionTable(dynamicFvMesh, excentreRotationFvMesh, IOobject);
42 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
44 Foam::excentreRotationFvMesh::excentreRotationFvMesh(const IOobject& io)
59 ).subDict(typeName + "Coeffs")
63 readScalar(dynamicMeshCoeffs_.lookup("rpm"))
67 readScalar(dynamicMeshCoeffs_.lookup("excentre"))
71 readScalar(dynamicMeshCoeffs_.lookup("rotAxis"))
75 readScalar(dynamicMeshCoeffs_.lookup("time0"))
79 readScalar(dynamicMeshCoeffs_.lookup("time1"))
84 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
86 Foam::excentreRotationFvMesh::~excentreRotationFvMesh()
90 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
92 bool Foam::excentreRotationFvMesh::update()
96 scalar localTime = time().value();
98 scalar deltaT1 = time1_ - time0_ ;
100 if (localTime >= 0.0 && localTime < time0_)
104 else if (localTime < time1_)
106 scalar tempTime = localTime - time0_;
110 3.0*sqr(tempTime)/deltaT1/deltaT1
111 - 2.0*pow3(tempTime)/pow3(deltaT1)
114 else if (localTime > time1_)
119 Info << "Eccentricity = " << excentre_ << endl;
120 Info << " Local Time = " << localTime << endl;
121 Info << " rpm = " << omega << nl << endl;
123 scalar theta = (omega*360.0*time().value()/60.0)*
124 mathematicalConstant::pi/180.0;
126 scalar deltaTheta = (omega*360.0*time().deltaT().value()/60.0)*
127 mathematicalConstant::pi/180.0;
129 const pointField& motionPoints = allPoints();
131 pointField newPoints(motionPoints.size(), vector::zero);
138 motionPoints.component(vector::X)
139 + excentre_*(cos(theta) - cos(theta + deltaTheta))
145 motionPoints.component(vector::Y)
151 motionPoints.component(vector::Z)
152 + excentre_*(-sin(theta) + sin(theta + deltaTheta))
155 else if (rotAxis_ == 2)
160 motionPoints.component(vector::X)
161 + excentre_*(cos(theta) - cos(theta + deltaTheta))
167 motionPoints.component(vector::Y)
168 + excentre_*(-sin(theta) + sin(theta + deltaTheta))
174 motionPoints.component(vector::Z)
177 else if (rotAxis_ == 3)
182 motionPoints.component(vector::X)
188 motionPoints.component(vector::Y)
189 + excentre_*(cos(theta) - cos(theta + deltaTheta))
195 motionPoints.component(vector::Z)
196 + excentre_*(-sin(theta) + sin(theta + deltaTheta))
200 fvMesh::movePoints(newPoints);
202 // Mesh motion only - return false
207 // ************************************************************************* //