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

fvMotionSolverEngineMesh.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 "fvMotionSolverEngineMesh.H"
00028 #include "addToRunTimeSelectionTable.H"
00029 #include "fvcMeshPhi.H"
00030 #include "surfaceInterpolate.H"
00031 
00032 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00033 
00034 namespace Foam
00035 {
00036 
00037 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
00038 
00039 defineTypeNameAndDebug(fvMotionSolverEngineMesh, 0);
00040 
00041 addToRunTimeSelectionTable(engineMesh, fvMotionSolverEngineMesh, IOobject);
00042 
00043 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00044 
00045 fvMotionSolverEngineMesh::fvMotionSolverEngineMesh(const IOobject& io)
00046 :
00047     engineMesh(io),
00048     pistonLayers_("pistonLayers", dimLength, 0.0),
00049     motionSolver_(*this, engineDB_.engineDict().lookup("motionSolver"))
00050 {
00051     if (engineDB_.engineDict().found("pistonLayers"))
00052     {
00053         engineDB_.engineDict().lookup("pistonLayers") >> pistonLayers_;
00054     }
00055 }
00056 
00057 
00058 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
00059 
00060 fvMotionSolverEngineMesh::~fvMotionSolverEngineMesh()
00061 {}
00062 
00063 
00064 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00065 
00066 void fvMotionSolverEngineMesh::move()
00067 {
00068     scalar deltaZ = engineDB_.pistonDisplacement().value();
00069     Info<< "deltaZ = " << deltaZ << endl;
00070 
00071     // Position of the top of the static mesh layers above the piston
00072     scalar pistonPlusLayers = pistonPosition_.value() + pistonLayers_.value();
00073 
00074     motionSolver_.cellMotionU().boundaryField()[pistonIndex_] == deltaZ;
00075 
00076     {
00077         scalarField linerPoints =
00078             motionSolver_.cellMotionU()
00079            .boundaryField()[linerIndex_].patch().Cf().component(vector::Z);
00080 
00081         motionSolver_.cellMotionU().boundaryField()[linerIndex_] ==
00082             deltaZ*pos(deckHeight_.value() - linerPoints)
00083             *(deckHeight_.value() - linerPoints)
00084             /(deckHeight_.value() - pistonPlusLayers);
00085     }
00086 
00087     motionSolver_.solve();
00088 
00089     if (engineDB_.foundObject<surfaceScalarField>("phi"))
00090     {
00091         surfaceScalarField& phi = 
00092             const_cast<surfaceScalarField&>
00093             (engineDB_.lookupObject<surfaceScalarField>("phi"));
00094 
00095         const volScalarField& rho =
00096             engineDB_.lookupObject<volScalarField>("rho");
00097 
00098         const volVectorField& U = 
00099             engineDB_.lookupObject<volVectorField>("U");
00100 
00101         bool absolutePhi = false;
00102         if (moving())
00103         {
00104             phi += fvc::interpolate(rho)*fvc::meshPhi(rho, U);
00105             absolutePhi = true;
00106         }
00107 
00108         movePoints(motionSolver_.curPoints());
00109 
00110         if (absolutePhi)
00111         {
00112             phi -= fvc::interpolate(rho)*fvc::meshPhi(rho, U);
00113         }
00114     }
00115     else
00116     {
00117         movePoints(motionSolver_.curPoints());
00118     }
00119 
00120 
00121     pistonPosition_.value() += deltaZ;
00122     scalar pistonSpeed = deltaZ/engineDB_.deltaT().value();
00123 
00124     Info<< "clearance: " << deckHeight_.value() - pistonPosition_.value() << nl
00125         << "Piston speed = " << pistonSpeed << " m/s" << endl;
00126 }
00127 
00128 
00129 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00130 
00131 } // End namespace Foam
00132 
00133 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd