1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
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
13 the Free Software Foundation, either version 3 of the License, or
14 (at your 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, see <http://www.gnu.org/licenses/>.
24 \*---------------------------------------------------------------------------*/
26 #include "layeredEngineMesh.H"
27 #include "addToRunTimeSelectionTable.H"
28 #include "fvcMeshPhi.H"
29 #include "surfaceInterpolate.H"
31 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
35 defineTypeNameAndDebug(layeredEngineMesh, 0);
36 addToRunTimeSelectionTable(engineMesh, layeredEngineMesh, IOobject);
40 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
42 Foam::layeredEngineMesh::layeredEngineMesh(const IOobject& io)
45 pistonLayers_("pistonLayers", dimLength, 0.0)
47 engineDB_.engineDict().readIfPresent("pistonLayers", pistonLayers_);
51 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
53 Foam::layeredEngineMesh::~layeredEngineMesh()
57 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
59 void Foam::layeredEngineMesh::move()
61 scalar deltaZ = engineDB_.pistonDisplacement().value();
62 Info<< "deltaZ = " << deltaZ << endl;
64 // Position of the top of the static mesh layers above the piston
65 scalar pistonPlusLayers = pistonPosition_.value() + pistonLayers_.value();
67 pointField newPoints(points());
69 forAll(newPoints, pointi)
71 point& p = newPoints[pointi];
73 if (p.z() < pistonPlusLayers) // In piston bowl
77 else if (p.z() < deckHeight_.value()) // In liner region
81 *(deckHeight_.value() - p.z())
82 /(deckHeight_.value() - pistonPlusLayers);
86 if (engineDB_.foundObject<surfaceScalarField>("phi"))
88 surfaceScalarField& phi =
89 const_cast<surfaceScalarField&>
90 (engineDB_.lookupObject<surfaceScalarField>("phi"));
92 const volScalarField& rho =
93 engineDB_.lookupObject<volScalarField>("rho");
95 const volVectorField& U =
96 engineDB_.lookupObject<volVectorField>("U");
98 bool absolutePhi = false;
101 phi += fvc::interpolate(rho)*fvc::meshPhi(rho, U);
105 movePoints(newPoints);
109 phi -= fvc::interpolate(rho)*fvc::meshPhi(rho, U);
114 movePoints(newPoints);
117 pistonPosition_.value() += deltaZ;
118 scalar pistonSpeed = deltaZ/engineDB_.deltaTValue();
120 Info<< "clearance: " << deckHeight_.value() - pistonPosition_.value() << nl
121 << "Piston speed = " << pistonSpeed << " m/s" << endl;
125 // ************************************************************************* //