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