1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright held by original author
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 \*---------------------------------------------------------------------------*/
28 #include "twoStrokeEngine.H"
29 #include "slidingInterface.H"
30 #include "layerAdditionRemoval.H"
31 #include "surfaceFields.H"
32 #include "regionSplit.H"
34 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
36 void Foam::twoStrokeEngine::checkAndCalculate()
38 label pistonIndex = -1;
39 bool foundPiston = false;
41 label linerIndex = -1;
42 bool foundLiner = false;
44 label cylinderHeadIndex = -1;
45 bool foundCylinderHead = false;
49 Info << boundary()[i].name() << endl;
50 if (boundary()[i].name() == "piston")
55 else if (boundary()[i].name() == "liner")
60 else if (boundary()[i].name() == "cylinderHead")
62 cylinderHeadIndex = i;
63 foundCylinderHead = true;
67 reduce(foundPiston, orOp<bool>());
68 reduce(foundLiner, orOp<bool>());
69 reduce(foundCylinderHead, orOp<bool>());
73 FatalErrorIn("Foam::twoStrokeEngine::checkAndCalculate()")
74 << " : cannot find piston patch"
80 FatalErrorIn("Foam::twoStrokeEngine::checkAndCalculate()")
81 << " : cannot find liner patch"
85 if (!foundCylinderHead)
87 FatalErrorIn("Foam::twoStrokeEngine::checkAndCalculate()")
88 << " : cannot find cylinderHead patch"
96 max(boundary()[pistonIndex].patch().localPoints()).z();
98 reduce(pistonPosition(), minOp<scalar>());
100 if (cylinderHeadIndex != -1)
104 boundary()[cylinderHeadIndex].patch().localPoints()
107 reduce(deckHeight(), minOp<scalar>());
109 Info<< "deckHeight: " << deckHeight() << nl
110 << "piston position: " << pistonPosition() << endl;
114 void Foam::twoStrokeEngine::setVirtualPistonPosition()
117 label pistonFaceIndex = faceZones().findZoneID("pistonLayerFaces");
119 bool foundPistonFace = (pistonFaceIndex != -1);
121 Info << "piston face index = " << pistonFaceIndex << endl;
125 FatalErrorIn("Foam::twoStrokeEngine::setVirtualPistonPosition()")
126 << " : cannot find the pistonLayerFaces"
130 const labelList& pistonFaces = faceZones()[pistonFaceIndex];
131 forAll(pistonFaces, i)
133 const face& f = faces()[pistonFaces[i]];
135 // should loop over facepoints...
138 virtualPistonPosition() =
139 Foam::max(virtualPistonPosition(), points()[f[j]].z());
143 reduce(virtualPistonPosition(), maxOp<scalar>());