FreeFOAM The Cross-Platform CFD Toolkit
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) 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 
30 
31 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
32 
33 namespace Foam
34 {
35 
36 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
37 
38 defineTypeNameAndDebug(fvMotionSolverEngineMesh, 0);
39 
40 addToRunTimeSelectionTable(engineMesh, fvMotionSolverEngineMesh, IOobject);
41 
42 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
43 
44 fvMotionSolverEngineMesh::fvMotionSolverEngineMesh(const IOobject& io)
45 :
46  engineMesh(io),
47  pistonLayers_("pistonLayers", dimLength, 0.0),
48  motionSolver_(*this, engineDB_.engineDict().lookup("motionSolver"))
49 {
50  if (engineDB_.engineDict().found("pistonLayers"))
51  {
52  engineDB_.engineDict().lookup("pistonLayers") >> pistonLayers_;
53  }
54 }
55 
56 
57 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
58 
60 {}
61 
62 
63 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
64 
66 {
67  scalar deltaZ = engineDB_.pistonDisplacement().value();
68  Info<< "deltaZ = " << deltaZ << endl;
69 
70  // Position of the top of the static mesh layers above the piston
71  scalar pistonPlusLayers = pistonPosition_.value() + pistonLayers_.value();
72 
73  motionSolver_.cellMotionU().boundaryField()[pistonIndex_] == deltaZ;
74 
75  {
76  scalarField linerPoints =
77  motionSolver_.cellMotionU()
78  .boundaryField()[linerIndex_].patch().Cf().component(vector::Z);
79 
80  motionSolver_.cellMotionU().boundaryField()[linerIndex_] ==
81  deltaZ*pos(deckHeight_.value() - linerPoints)
82  *(deckHeight_.value() - linerPoints)
83  /(deckHeight_.value() - pistonPlusLayers);
84  }
85 
86  motionSolver_.solve();
87 
89  {
91  const_cast<surfaceScalarField&>
93 
94  const volScalarField& rho =
96 
97  const volVectorField& U =
99 
100  bool absolutePhi = false;
101  if (moving())
102  {
103  phi += fvc::interpolate(rho)*fvc::meshPhi(rho, U);
104  absolutePhi = true;
105  }
106 
107  movePoints(motionSolver_.curPoints());
108 
109  if (absolutePhi)
110  {
111  phi -= fvc::interpolate(rho)*fvc::meshPhi(rho, U);
112  }
113  }
114  else
115  {
116  movePoints(motionSolver_.curPoints());
117  }
118 
119 
120  pistonPosition_.value() += deltaZ;
121  scalar pistonSpeed = deltaZ/engineDB_.deltaT().value();
122 
123  Info<< "clearance: " << deckHeight_.value() - pistonPosition_.value() << nl
124  << "Piston speed = " << pistonSpeed << " m/s" << endl;
125 }
126 
127 
128 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
129 
130 } // End namespace Foam
131 
132 // ************************ vim: set sw=4 sts=4 et: ************************ //