1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright held by original author
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
11 OpenFOAM is free software; you can redistribute it and/or modify it
12 under the terms of the GNU General Public License as published by the
13 Free Software Foundation; either version 2 of the License, or (at your
14 option) any later version.
16 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 You should have received a copy of the GNU General Public License
22 along with OpenFOAM; if not, write to the Free Software Foundation,
23 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 \*---------------------------------------------------------------------------*/
27 #include "layeredEngineMesh.H"
28 #include "addToRunTimeSelectionTable.H"
29 #include "fvcMeshPhi.H"
30 #include "surfaceInterpolate.H"
32 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
37 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
39 defineTypeNameAndDebug(layeredEngineMesh, 0);
41 addToRunTimeSelectionTable(engineMesh, layeredEngineMesh, IOobject);
43 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
45 layeredEngineMesh::layeredEngineMesh(const IOobject& io)
48 pistonLayers_("pistonLayers", dimLength, 0.0)
50 if (engineDB_.engineDict().found("pistonLayers"))
52 engineDB_.engineDict().lookup("pistonLayers") >> pistonLayers_;
57 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
59 layeredEngineMesh::~layeredEngineMesh()
63 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
65 void layeredEngineMesh::move()
67 scalar deltaZ = engineDB_.pistonDisplacement().value();
68 Info<< "deltaZ = " << deltaZ << endl;
70 // Position of the top of the static mesh layers above the piston
71 scalar pistonPlusLayers = pistonPosition_.value() + pistonLayers_.value();
73 pointField newPoints = points();
75 forAll (newPoints, pointi)
77 point& p = newPoints[pointi];
79 if (p.z() < pistonPlusLayers) // In piston bowl
83 else if (p.z() < deckHeight_.value()) // In liner region
87 *(deckHeight_.value() - p.z())
88 /(deckHeight_.value() - pistonPlusLayers);
92 if (engineDB_.foundObject<surfaceScalarField>("phi"))
94 surfaceScalarField& phi =
95 const_cast<surfaceScalarField&>
96 (engineDB_.lookupObject<surfaceScalarField>("phi"));
98 const volScalarField& rho =
99 engineDB_.lookupObject<volScalarField>("rho");
101 const volVectorField& U =
102 engineDB_.lookupObject<volVectorField>("U");
104 bool absolutePhi = false;
107 phi += fvc::interpolate(rho)*fvc::meshPhi(rho, U);
111 movePoints(newPoints);
115 phi -= fvc::interpolate(rho)*fvc::meshPhi(rho, U);
120 movePoints(newPoints);
123 pistonPosition_.value() += deltaZ;
124 scalar pistonSpeed = deltaZ/engineDB_.deltaT().value();
126 Info<< "clearance: " << deckHeight_.value() - pistonPosition_.value() << nl
127 << "Piston speed = " << pistonSpeed << " m/s" << endl;
131 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
133 } // End namespace Foam
135 // ************************************************************************* //