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) 2011 OpenFOAM Foundation
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"
28 #include "fvcMeshPhi.H"
29 #include "surfaceInterpolate.H"
30 
31 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
32 
33 namespace Foam
34 {
35  defineTypeNameAndDebug(layeredEngineMesh, 0);
36  addToRunTimeSelectionTable(engineMesh, layeredEngineMesh, IOobject);
37 }
38 
39 
40 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
41 
43 :
44  engineMesh(io),
45  pistonLayers_("pistonLayers", dimLength, 0.0)
46 {
48 }
49 
50 
51 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
52 
54 {}
55 
56 
57 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
58 
60 {
61  scalar deltaZ = engineDB_.pistonDisplacement().value();
62  Info<< "deltaZ = " << deltaZ << endl;
63 
64  // Position of the top of the static mesh layers above the piston
65  scalar pistonPlusLayers = pistonPosition_.value() + pistonLayers_.value();
66 
67  pointField newPoints(points());
68 
69  forAll(newPoints, pointi)
70  {
71  point& p = newPoints[pointi];
72 
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  }
85 
86  if (engineDB_.foundObject<surfaceScalarField>("phi"))
87  {
89  const_cast<surfaceScalarField&>
90  (engineDB_.lookupObject<surfaceScalarField>("phi"));
91 
92  const volScalarField& rho =
93  engineDB_.lookupObject<volScalarField>("rho");
94 
95  const volVectorField& U =
96  engineDB_.lookupObject<volVectorField>("U");
97 
98  bool absolutePhi = false;
99  if (moving())
100  {
102  absolutePhi = true;
103  }
104 
105  movePoints(newPoints);
106 
107  if (absolutePhi)
108  {
110  }
111  }
112  else
113  {
114  movePoints(newPoints);
115  }
116 
117  pistonPosition_.value() += deltaZ;
118  scalar pistonSpeed = deltaZ/engineDB_.deltaTValue();
119 
120  Info<< "clearance: " << deckHeight_.value() - pistonPosition_.value() << nl
121  << "Piston speed = " << pistonSpeed << " m/s" << endl;
122 }
123 
124 
125 // ************************************************************************* //
Foam::IOobject
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:91
Foam::layeredEngineMesh::~layeredEngineMesh
~layeredEngineMesh()
Destructor.
Definition: layeredEngineMesh.C:53
Foam::engineMesh
Foam::engineMesh.
Definition: engineMesh.H:51
Foam::layeredEngineMesh::layeredEngineMesh
layeredEngineMesh(const layeredEngineMesh &)
Disallow default bitwise copy construct.
p
p
Definition: pEqn.H:62
Foam::dimLength
const dimensionSet dimLength(0, 1, 0, 0, 0, 0, 0)
Definition: dimensionSets.H:50
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:406
Foam::layeredEngineMesh::pistonLayers_
dimensionedScalar pistonLayers_
Definition: layeredEngineMesh.H:55
fvcMeshPhi.H
Calculate the mesh motion flux and convert fluxes from absolute to relative and back.
Foam::dictionary::readIfPresent
bool readIfPresent(const word &, T &, bool recursive=false, bool patternMatch=true) const
Find an entry if present, and assign to T.
Definition: dictionaryTemplates.C:94
Foam::addToRunTimeSelectionTable
addToRunTimeSelectionTable(ensightPart, ensightPartCells, istream)
phi
surfaceScalarField & phi
Definition: setRegionFluidFields.H:8
Foam::fvc::interpolate
tmp< GeometricField< Type, fvsPatchField, surfaceMesh > > interpolate(const GeometricField< Type, fvPatchField, volMesh > &vf, const surfaceScalarField &faceFlux, Istream &schemeData)
Interpolate field onto faces using scheme given by Istream.
Definition: surfaceInterpolate.C:110
Foam::fvc::meshPhi
tmp< surfaceScalarField > meshPhi(const volVectorField &U)
Definition: fvcMeshPhi.C:33
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
U
U
Definition: pEqn.H:46
Foam::Field
Pre-declare SubField and related Field type.
Definition: Field.H:57
Foam::nl
static const char nl
Definition: Ostream.H:260
Foam::Info
messageStream Info
addToRunTimeSelectionTable.H
Macros for easy insertion into run-time selection tables.
surfaceInterpolate.H
Surface Interpolation.
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::engineTime::engineDict
const IOdictionary & engineDict() const
Return the engine geometry dictionary.
Definition: engineTime.H:135
rho
rho
Definition: pEqn.H:3
Foam::layeredEngineMesh::move
void move()
Definition: layeredEngineMesh.C:59
Foam::Vector< scalar >
points
const pointField & points
Definition: gmvOutputHeader.H:1
layeredEngineMesh.H
Foam::GeometricField
Generic GeometricField class.
Definition: surfaceFieldsFwd.H:52
Foam::engineMesh::engineDB_
const engineTime & engineDB_
Definition: engineMesh.H:68
Foam::defineTypeNameAndDebug
defineTypeNameAndDebug(combustionModel, 0)