FreeFOAM The Cross-Platform CFD Toolkit
Hosted by SourceForge:
Get FreeFOAM at SourceForge.net.
            Fast, secure and Free Open Source software downloads

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-2010 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
00013     the Free Software Foundation, either version 3 of the License, or
00014     (at your 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, see <http://www.gnu.org/licenses/>.
00023 
00024 \*---------------------------------------------------------------------------*/
00025 
00026 #include "dynamicInkJetFvMesh.H"
00027 #include <OpenFOAM/addToRunTimeSelectionTable.H>
00028 #include <finiteVolume/volFields.H>
00029 #include <OpenFOAM/mathematicalConstants.H>
00030 
00031 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
00032 
00033 namespace Foam
00034 {
00035     defineTypeNameAndDebug(dynamicInkJetFvMesh, 0);
00036     addToRunTimeSelectionTable(dynamicFvMesh, dynamicInkJetFvMesh, IOobject);
00037 }
00038 
00039 
00040 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00041 
00042 Foam::dynamicInkJetFvMesh::dynamicInkJetFvMesh(const IOobject& io)
00043 :
00044     dynamicFvMesh(io),
00045     dynamicMeshCoeffs_
00046     (
00047         IOdictionary
00048         (
00049             IOobject
00050             (
00051                 "dynamicMeshDict",
00052                 io.time().constant(),
00053                 *this,
00054                 IOobject::MUST_READ,
00055                 IOobject::NO_WRITE
00056             )
00057         ).subDict(typeName + "Coeffs")
00058     ),
00059     amplitude_(readScalar(dynamicMeshCoeffs_.lookup("amplitude"))),
00060     frequency_(readScalar(dynamicMeshCoeffs_.lookup("frequency"))),
00061     refPlaneX_(readScalar(dynamicMeshCoeffs_.lookup("refPlaneX"))),
00062     stationaryPoints_
00063     (
00064         IOobject
00065         (
00066             "points",
00067             io.time().constant(),
00068             meshSubDir,
00069             *this,
00070             IOobject::MUST_READ,
00071             IOobject::NO_WRITE
00072         )
00073     )
00074 {
00075     Info<< "Performing a dynamic mesh calculation: " << endl
00076         << "amplitude: " << amplitude_
00077         << " frequency: " << frequency_
00078         << " refPlaneX: " << refPlaneX_ << endl;
00079 }
00080 
00081 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
00082 
00083 Foam::dynamicInkJetFvMesh::~dynamicInkJetFvMesh()
00084 {}
00085 
00086 
00087 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00088 
00089 bool Foam::dynamicInkJetFvMesh::update()
00090 {
00091     scalar scalingFunction =
00092         0.5*(::cos(2*mathematicalConstant::pi*frequency_*time().value()) - 1.0);
00093 
00094     Info<< "Mesh scaling. Time = " << time().value() << " scaling: "
00095         << scalingFunction << endl;
00096 
00097     pointField newPoints = stationaryPoints_;
00098 
00099     newPoints.replace
00100     (
00101         vector::X,
00102         stationaryPoints_.component(vector::X)*
00103         (
00104             1.0
00105           + pos
00106             (
00107               - (stationaryPoints_.component(vector::X))
00108               - refPlaneX_
00109             )*amplitude_*scalingFunction
00110         )
00111     );
00112 
00113     fvMesh::movePoints(newPoints);
00114 
00115     volVectorField& U = 
00116         const_cast<volVectorField&>(lookupObject<volVectorField>("U"));
00117     U.correctBoundaryConditions();
00118 
00119     return true;
00120 }
00121 
00122 
00123 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines