OpenFOAM logo
The Open Source CFD Toolbox
  Source Guide OpenCFD Solutions Contact OpenFOAM

dynamicInkJetFvMesh.C

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002   =========                 |
00003   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
00004    \\    /   O peration     |
00005     \\  /    A nd           | Copyright (C) 1991-2009 OpenCFD Ltd.
00006      \\/     M anipulation  |
00007 -------------------------------------------------------------------------------
00008 License
00009     This file is part of OpenFOAM.
00010 
00011     OpenFOAM is free software; you can redistribute it and/or modify it
00012     under the terms of the GNU General Public License as published by the
00013     Free Software Foundation; either version 2 of the License, or (at your
00014     option) any later version.
00015 
00016     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
00017     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00019     for more details.
00020 
00021     You should have received a copy of the GNU General Public License
00022     along with OpenFOAM; if not, write to the Free Software Foundation,
00023     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
00024 
00025 \*---------------------------------------------------------------------------*/
00026 
00027 #include "dynamicInkJetFvMesh.H"
00028 #include "addToRunTimeSelectionTable.H"
00029 #include "volFields.H"
00030 #include "mathematicalConstants.H"
00031 
00032 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
00033 
00034 namespace Foam
00035 {
00036     defineTypeNameAndDebug(dynamicInkJetFvMesh, 0);
00037     addToRunTimeSelectionTable(dynamicFvMesh, dynamicInkJetFvMesh, IOobject);
00038 }
00039 
00040 
00041 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00042 
00043 Foam::dynamicInkJetFvMesh::dynamicInkJetFvMesh(const IOobject& io)
00044 :
00045     dynamicFvMesh(io),
00046     dynamicMeshCoeffs_
00047     (
00048         IOdictionary
00049         (
00050             IOobject
00051             (
00052                 "dynamicMeshDict",
00053                 io.time().constant(),
00054                 *this,
00055                 IOobject::MUST_READ,
00056                 IOobject::NO_WRITE
00057             )
00058         ).subDict(typeName + "Coeffs")
00059     ),
00060     amplitude_(readScalar(dynamicMeshCoeffs_.lookup("amplitude"))),
00061     frequency_(readScalar(dynamicMeshCoeffs_.lookup("frequency"))),
00062     refPlaneX_(readScalar(dynamicMeshCoeffs_.lookup("refPlaneX"))),
00063     stationaryPoints_
00064     (
00065         IOobject
00066         (
00067             "points",
00068             io.time().constant(),
00069             meshSubDir,
00070             *this,
00071             IOobject::MUST_READ,
00072             IOobject::NO_WRITE
00073         )
00074     )
00075 {
00076     Info<< "Performing a dynamic mesh calculation: " << endl
00077         << "amplitude: " << amplitude_
00078         << " frequency: " << frequency_
00079         << " refPlaneX: " << refPlaneX_ << endl;
00080 }
00081 
00082 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
00083 
00084 Foam::dynamicInkJetFvMesh::~dynamicInkJetFvMesh()
00085 {}
00086 
00087 
00088 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00089 
00090 bool Foam::dynamicInkJetFvMesh::update()
00091 {
00092     scalar scalingFunction =
00093         0.5*(::cos(2*mathematicalConstant::pi*frequency_*time().value()) - 1.0);
00094 
00095     Info<< "Mesh scaling. Time = " << time().value() << " scaling: "
00096         << scalingFunction << endl;
00097 
00098     pointField newPoints = stationaryPoints_;
00099 
00100     newPoints.replace
00101     (
00102         vector::X,
00103         stationaryPoints_.component(vector::X)*
00104         (
00105             1.0
00106           + pos
00107             (
00108               - (stationaryPoints_.component(vector::X))
00109               - refPlaneX_
00110             )*amplitude_*scalingFunction
00111         )
00112     );
00113 
00114     fvMesh::movePoints(newPoints);
00115 
00116     volVectorField& U = 
00117         const_cast<volVectorField&>(lookupObject<volVectorField>("U"));
00118     U.correctBoundaryConditions();
00119 
00120     return true;
00121 }
00122 
00123 
00124 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd