FreeFOAM The Cross-Platform CFD Toolkit
layeredEngineMesh.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd.
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
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.
15 
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.
20 
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/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
26 #include "layeredEngineMesh.H"
30 
31 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
32 
33 namespace Foam
34 {
35 
36 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
37 
38 defineTypeNameAndDebug(layeredEngineMesh, 0);
39 
40 addToRunTimeSelectionTable(engineMesh, layeredEngineMesh, IOobject);
41 
42 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
43 
44 layeredEngineMesh::layeredEngineMesh(const IOobject& io)
45 :
46  engineMesh(io),
47  pistonLayers_("pistonLayers", dimLength, 0.0)
48 {
49  if (engineDB_.engineDict().found("pistonLayers"))
50  {
51  engineDB_.engineDict().lookup("pistonLayers") >> pistonLayers_;
52  }
53 }
54 
55 
56 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
57 
59 {}
60 
61 
62 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
63 
65 {
66  scalar deltaZ = engineDB_.pistonDisplacement().value();
67  Info<< "deltaZ = " << deltaZ << endl;
68 
69  // Position of the top of the static mesh layers above the piston
70  scalar pistonPlusLayers = pistonPosition_.value() + pistonLayers_.value();
71 
72  pointField newPoints = points();
73 
74  forAll (newPoints, pointi)
75  {
76  point& p = newPoints[pointi];
77 
78  if (p.z() < pistonPlusLayers) // In piston bowl
79  {
80  p.z() += deltaZ;
81  }
82  else if (p.z() < deckHeight_.value()) // In liner region
83  {
84  p.z() +=
85  deltaZ
86  *(deckHeight_.value() - p.z())
87  /(deckHeight_.value() - pistonPlusLayers);
88  }
89  }
90 
92  {
94  const_cast<surfaceScalarField&>
96 
97  const volScalarField& rho =
99 
100  const volVectorField& U =
102 
103  bool absolutePhi = false;
104  if (moving())
105  {
106  phi += fvc::interpolate(rho)*fvc::meshPhi(rho, U);
107  absolutePhi = true;
108  }
109 
110  movePoints(newPoints);
111 
112  if (absolutePhi)
113  {
114  phi -= fvc::interpolate(rho)*fvc::meshPhi(rho, U);
115  }
116  }
117  else
118  {
119  movePoints(newPoints);
120  }
121 
122  pistonPosition_.value() += deltaZ;
123  scalar pistonSpeed = deltaZ/engineDB_.deltaT().value();
124 
125  Info<< "clearance: " << deckHeight_.value() - pistonPosition_.value() << nl
126  << "Piston speed = " << pistonSpeed << " m/s" << endl;
127 }
128 
129 
130 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
131 
132 } // End namespace Foam
133 
134 // ************************ vim: set sw=4 sts=4 et: ************************ //