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

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