fvMotionSolverEngineMesh.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-2015 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 
28 #include "fvcMeshPhi.H"
29 #include "surfaceInterpolate.H"
30 
31 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
32 
33 namespace Foam
34 {
35  defineTypeNameAndDebug(fvMotionSolverEngineMesh, 0);
36  addToRunTimeSelectionTable(engineMesh, fvMotionSolverEngineMesh, IOobject);
37 }
38 
39 
40 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
41 
43 :
44  engineMesh(io),
45  pistonLayers_("pistonLayers", dimLength, 0.0),
46  motionSolver_
47  (
48  *this,
49  engineDB_.engineDict()
50  )
51 {
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  scalar pistonSpeed = deltaZ/engineDB_.deltaTValue();
73 
74  motionSolver_.pointMotionU().boundaryField()[pistonIndex_] == pistonSpeed;
75 
76  {
77  scalarField linerPoints
78  (
79  boundary()[linerIndex_].patch().localPoints().component(vector::Z)
80  );
81 
82  motionSolver_.pointMotionU().boundaryField()[linerIndex_] ==
83  pistonSpeed*pos(deckHeight_.value() - linerPoints)
84  *(deckHeight_.value() - linerPoints)
85  /(deckHeight_.value() - pistonPlusLayers);
86  }
87 
88  motionSolver_.solve();
89 
90  if (engineDB_.foundObject<surfaceScalarField>("phi"))
91  {
93  const_cast<surfaceScalarField&>
94  (engineDB_.lookupObject<surfaceScalarField>("phi"));
95 
96  const volScalarField& rho =
97  engineDB_.lookupObject<volScalarField>("rho");
98 
99  const volVectorField& U =
100  engineDB_.lookupObject<volVectorField>("U");
101 
102  bool absolutePhi = false;
103  if (moving())
104  {
106  absolutePhi = true;
107  }
108 
109  movePoints(motionSolver_.curPoints());
110 
111  if (absolutePhi)
112  {
114  }
115  }
116  else
117  {
118  movePoints(motionSolver_.curPoints());
119  }
120 
121 
122  pistonPosition_.value() += deltaZ;
123 
124  Info<< "clearance: " << deckHeight_.value() - pistonPosition_.value() << nl
125  << "Piston speed = " << pistonSpeed << " m/s" << endl;
126 }
127 
128 
129 // ************************************************************************* //
Foam::IOobject
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:91
Foam::engineMesh
Foam::engineMesh.
Definition: engineMesh.H:51
Foam::component
void component(FieldField< Field, typename FieldField< Field, Type >::cmptType > &sf, const FieldField< Field, Type > &f, const direction d)
Definition: FieldFieldFunctions.C:41
Foam::Vector< scalar >::Z
@ Z
Definition: Vector.H:89
Foam::dimLength
const dimensionSet dimLength(0, 1, 0, 0, 0, 0, 0)
Definition: dimensionSets.H:50
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)
Foam::fvMotionSolverEngineMesh::move
void move()
Definition: fvMotionSolverEngineMesh.C:64
phi
surfaceScalarField & phi
Definition: setRegionFluidFields.H:8
fvMotionSolverEngineMesh.H
boundary
faceListList boundary(nPatches)
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
Foam::fvMotionSolverEngineMesh::pistonLayers_
dimensionedScalar pistonLayers_
Definition: fvMotionSolverEngineMesh.H:56
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::fvMotionSolverEngineMesh::~fvMotionSolverEngineMesh
~fvMotionSolverEngineMesh()
Destructor.
Definition: fvMotionSolverEngineMesh.C:58
Foam::fvMotionSolverEngineMesh::fvMotionSolverEngineMesh
fvMotionSolverEngineMesh(const fvMotionSolverEngineMesh &)
Disallow default bitwise copy construct.
Foam::GeometricField
Generic GeometricField class.
Definition: surfaceFieldsFwd.H:52
Foam::engineMesh::engineDB_
const engineTime & engineDB_
Definition: engineMesh.H:68
Foam::defineTypeNameAndDebug
defineTypeNameAndDebug(combustionModel, 0)
Foam::pos
dimensionedScalar pos(const dimensionedScalar &ds)
Definition: dimensionedScalar.C:190