BUG: UListIO: byteSize overflowing on really big faceLists
[OpenFOAM-2.0.x.git] / src / engine / engineMesh / layeredEngineMesh / layeredEngineMesh.C
blob390994257ca569115547876235f58d2d49d20ffa
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 2011 OpenFOAM Foundation
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
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
19     for more details.
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 * * * * * * * * * * * * * //
33 namespace Foam
35     defineTypeNameAndDebug(layeredEngineMesh, 0);
36     addToRunTimeSelectionTable(engineMesh, layeredEngineMesh, IOobject);
40 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
42 Foam::layeredEngineMesh::layeredEngineMesh(const IOobject& io)
44     engineMesh(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)
70     {
71         point& p = newPoints[pointi];
73         if (p.z() < pistonPlusLayers)           // In piston bowl
74         {
75             p.z() += deltaZ;
76         }
77         else if (p.z() < deckHeight_.value())   // In liner region
78         {
79             p.z() +=
80                 deltaZ
81                *(deckHeight_.value() - p.z())
82                /(deckHeight_.value() - pistonPlusLayers);
83         }
84     }
86     if (engineDB_.foundObject<surfaceScalarField>("phi"))
87     {
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;
99         if (moving())
100         {
101             phi += fvc::interpolate(rho)*fvc::meshPhi(rho, U);
102             absolutePhi = true;
103         }
105         movePoints(newPoints);
107         if (absolutePhi)
108         {
109             phi -= fvc::interpolate(rho)*fvc::meshPhi(rho, U);
110         }
111     }
112     else
113     {
114         movePoints(newPoints);
115     }
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 // ************************************************************************* //