with the run-time selectable engine userTime embedded in Time. All parts of the original engineTime relating to the engine geometry have been moved to engineMesh. This is part of the process of integrating engine simulations within the standard moving-mesh solvers.
97 lines
3.1 KiB
C++
97 lines
3.1 KiB
C++
/*---------------------------------------------------------------------------*\
|
|
========= |
|
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
|
\\ / O peration | Website: https://openfoam.org
|
|
\\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation
|
|
\\/ M anipulation |
|
|
-------------------------------------------------------------------------------
|
|
License
|
|
This file is part of OpenFOAM.
|
|
|
|
OpenFOAM is free software: you can redistribute it and/or modify it
|
|
under the terms of the GNU General Public License as published by
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
(at your option) any later version.
|
|
|
|
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
\*---------------------------------------------------------------------------*/
|
|
|
|
#include "layeredEngineMesh.H"
|
|
#include "addToRunTimeSelectionTable.H"
|
|
#include "fvcMeshPhi.H"
|
|
#include "surfaceInterpolate.H"
|
|
|
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
|
|
|
namespace Foam
|
|
{
|
|
defineTypeNameAndDebug(layeredEngineMesh, 0);
|
|
addToRunTimeSelectionTable(engineMesh, layeredEngineMesh, IOobject);
|
|
}
|
|
|
|
|
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
|
|
|
Foam::layeredEngineMesh::layeredEngineMesh(const IOobject& io)
|
|
:
|
|
engineMesh(io),
|
|
pistonLayers_("pistonLayers", dimLength, 0.0)
|
|
{
|
|
dict_.readIfPresent("pistonLayers", pistonLayers_);
|
|
}
|
|
|
|
|
|
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
|
|
|
Foam::layeredEngineMesh::~layeredEngineMesh()
|
|
{}
|
|
|
|
|
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
|
|
|
void Foam::layeredEngineMesh::move()
|
|
{
|
|
scalar deltaZ = pistonDisplacement().value();
|
|
Info<< "deltaZ = " << deltaZ << endl;
|
|
|
|
// Position of the top of the static mesh layers above the piston
|
|
scalar pistonPlusLayers = pistonPosition_.value() + pistonLayers_.value();
|
|
|
|
pointField newPoints(points());
|
|
|
|
forAll(newPoints, pointi)
|
|
{
|
|
point& p = newPoints[pointi];
|
|
|
|
if (p.z() < pistonPlusLayers) // In piston bowl
|
|
{
|
|
p.z() += deltaZ;
|
|
}
|
|
else if (p.z() < deckHeight_.value()) // In liner region
|
|
{
|
|
p.z() +=
|
|
deltaZ
|
|
*(deckHeight_.value() - p.z())
|
|
/(deckHeight_.value() - pistonPlusLayers);
|
|
}
|
|
}
|
|
|
|
movePoints(newPoints);
|
|
|
|
pistonPosition_.value() += deltaZ;
|
|
scalar pistonSpeed = deltaZ/time().deltaTValue();
|
|
|
|
Info<< "clearance: " << deckHeight_.value() - pistonPosition_.value() << nl
|
|
<< "Piston speed = " << pistonSpeed << " m/s" << endl;
|
|
}
|
|
|
|
|
|
// ************************************************************************* //
|