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

layeredEngineMesh.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 "layeredEngineMesh.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(layeredEngineMesh, 0);
00040 
00041 addToRunTimeSelectionTable(engineMesh, layeredEngineMesh, IOobject);
00042 
00043 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00044 
00045 layeredEngineMesh::layeredEngineMesh(const IOobject& io)
00046 :
00047     engineMesh(io),
00048     pistonLayers_("pistonLayers", dimLength, 0.0)
00049 {
00050     if (engineDB_.engineDict().found("pistonLayers"))
00051     {
00052         engineDB_.engineDict().lookup("pistonLayers") >> pistonLayers_;
00053     }
00054 }
00055 
00056 
00057 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
00058 
00059 layeredEngineMesh::~layeredEngineMesh()
00060 {}
00061 
00062 
00063 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00064 
00065 void layeredEngineMesh::move()
00066 {
00067     scalar deltaZ = engineDB_.pistonDisplacement().value();
00068     Info<< "deltaZ = " << deltaZ << endl;
00069 
00070     // Position of the top of the static mesh layers above the piston
00071     scalar pistonPlusLayers = pistonPosition_.value() + pistonLayers_.value();
00072 
00073     pointField newPoints = points();
00074 
00075     forAll (newPoints, pointi)
00076     {
00077         point& p = newPoints[pointi];
00078 
00079         if (p.z() < pistonPlusLayers)           // In piston bowl
00080         {
00081             p.z() += deltaZ;
00082         }
00083         else if (p.z() < deckHeight_.value())   // In liner region
00084         {
00085             p.z() += 
00086                 deltaZ
00087                *(deckHeight_.value() - p.z())
00088                /(deckHeight_.value() - pistonPlusLayers);
00089         }
00090     }
00091 
00092     if (engineDB_.foundObject<surfaceScalarField>("phi"))
00093     {
00094         surfaceScalarField& phi = 
00095             const_cast<surfaceScalarField&>
00096             (engineDB_.lookupObject<surfaceScalarField>("phi"));
00097 
00098         const volScalarField& rho =
00099             engineDB_.lookupObject<volScalarField>("rho");
00100 
00101         const volVectorField& U = 
00102             engineDB_.lookupObject<volVectorField>("U");
00103 
00104         bool absolutePhi = false;
00105         if (moving())
00106         {
00107             phi += fvc::interpolate(rho)*fvc::meshPhi(rho, U);
00108             absolutePhi = true;
00109         }
00110 
00111         movePoints(newPoints);
00112 
00113         if (absolutePhi)
00114         {
00115             phi -= fvc::interpolate(rho)*fvc::meshPhi(rho, U);
00116         }
00117     }
00118     else
00119     {
00120         movePoints(newPoints);
00121     }
00122 
00123     pistonPosition_.value() += deltaZ;
00124     scalar pistonSpeed = deltaZ/engineDB_.deltaT().value();
00125 
00126     Info<< "clearance: " << deckHeight_.value() - pistonPosition_.value() << nl
00127         << "Piston speed = " << pistonSpeed << " m/s" << endl;
00128 }
00129 
00130 
00131 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00132 
00133 } // End namespace Foam
00134 
00135 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd