1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd.
7 -------------------------------------------------------------------------------
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 the
13 Free Software Foundation; either version 2 of the License, or (at your
14 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
21 You should have received a copy of the GNU General Public License
22 along with OpenFOAM; if not, write to the Free Software Foundation,
23 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 \*---------------------------------------------------------------------------*/
27 #include "fvMotionSolverEngineMesh.H"
28 #include "addToRunTimeSelectionTable.H"
29 #include "fvcMeshPhi.H"
30 #include "surfaceInterpolate.H"
32 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
37 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
39 defineTypeNameAndDebug(fvMotionSolverEngineMesh, 0);
41 addToRunTimeSelectionTable(engineMesh, fvMotionSolverEngineMesh, IOobject);
43 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
45 fvMotionSolverEngineMesh::fvMotionSolverEngineMesh(const IOobject& io)
48 pistonLayers_("pistonLayers", dimLength, 0.0),
49 motionSolver_(*this, engineDB_.engineDict().lookup("motionSolver"))
51 if (engineDB_.engineDict().found("pistonLayers"))
53 engineDB_.engineDict().lookup("pistonLayers") >> pistonLayers_;
58 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
60 fvMotionSolverEngineMesh::~fvMotionSolverEngineMesh()
64 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
66 void fvMotionSolverEngineMesh::move()
68 scalar deltaZ = engineDB_.pistonDisplacement().value();
69 Info<< "deltaZ = " << deltaZ << endl;
71 // Position of the top of the static mesh layers above the piston
72 scalar pistonPlusLayers = pistonPosition_.value() + pistonLayers_.value();
74 motionSolver_.cellMotionU().boundaryField()[pistonIndex_] == deltaZ;
77 scalarField linerPoints =
78 motionSolver_.cellMotionU()
79 .boundaryField()[linerIndex_].patch().Cf().component(vector::Z);
81 motionSolver_.cellMotionU().boundaryField()[linerIndex_] ==
82 deltaZ*pos(deckHeight_.value() - linerPoints)
83 *(deckHeight_.value() - linerPoints)
84 /(deckHeight_.value() - pistonPlusLayers);
87 motionSolver_.solve();
89 if (engineDB_.foundObject<surfaceScalarField>("phi"))
91 surfaceScalarField& phi =
92 const_cast<surfaceScalarField&>
93 (engineDB_.lookupObject<surfaceScalarField>("phi"));
95 const volScalarField& rho =
96 engineDB_.lookupObject<volScalarField>("rho");
98 const volVectorField& U =
99 engineDB_.lookupObject<volVectorField>("U");
101 bool absolutePhi = false;
104 phi += fvc::interpolate(rho)*fvc::meshPhi(rho, U);
108 movePoints(motionSolver_.curPoints());
112 phi -= fvc::interpolate(rho)*fvc::meshPhi(rho, U);
117 movePoints(motionSolver_.curPoints());
121 pistonPosition_.value() += deltaZ;
122 scalar pistonSpeed = deltaZ/engineDB_.deltaT().value();
124 Info<< "clearance: " << deckHeight_.value() - pistonPosition_.value() << nl
125 << "Piston speed = " << pistonSpeed << " m/s" << endl;
129 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
131 } // End namespace Foam
133 // ************************************************************************* //