initial commit for version 1.6.x patch release
[OpenFOAM-1.6.x.git] / src / engine / engineMesh / layeredEngineMesh / layeredEngineMesh.C
blob8bcdcccf41a69a3e07209a571bcec888dd87de44
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 1991-2009 OpenCFD Ltd.
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
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
19     for more details.
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 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
34 namespace Foam
37 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
39 defineTypeNameAndDebug(layeredEngineMesh, 0);
41 addToRunTimeSelectionTable(engineMesh, layeredEngineMesh, IOobject);
43 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
45 layeredEngineMesh::layeredEngineMesh(const IOobject& io)
47     engineMesh(io),
48     pistonLayers_("pistonLayers", dimLength, 0.0)
50     if (engineDB_.engineDict().found("pistonLayers"))
51     {
52         engineDB_.engineDict().lookup("pistonLayers") >> pistonLayers_;
53     }
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)
76     {
77         point& p = newPoints[pointi];
79         if (p.z() < pistonPlusLayers)           // In piston bowl
80         {
81             p.z() += deltaZ;
82         }
83         else if (p.z() < deckHeight_.value())   // In liner region
84         {
85             p.z() += 
86                 deltaZ
87                *(deckHeight_.value() - p.z())
88                /(deckHeight_.value() - pistonPlusLayers);
89         }
90     }
92     if (engineDB_.foundObject<surfaceScalarField>("phi"))
93     {
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;
105         if (moving())
106         {
107             phi += fvc::interpolate(rho)*fvc::meshPhi(rho, U);
108             absolutePhi = true;
109         }
111         movePoints(newPoints);
113         if (absolutePhi)
114         {
115             phi -= fvc::interpolate(rho)*fvc::meshPhi(rho, U);
116         }
117     }
118     else
119     {
120         movePoints(newPoints);
121     }
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 // ************************************************************************* //