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 "simpleTwoStroke.H"
29 #include "slidingInterface.H"
30 #include "layerAdditionRemoval.H"
31 #include "surfaceFields.H"
32 #include "regionSplit.H"
34 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
36 void Foam::simpleTwoStroke::checkAndCalculate()
39 label pistonIndex = -1;
40 bool foundPiston = false;
42 label linerIndex = -1;
43 bool foundLiner = false;
45 label cylinderHeadIndex = -1;
46 bool foundCylinderHead = false;
51 Info << boundary()[i].name() << endl;
52 if (boundary()[i].name() == "piston")
57 else if (boundary()[i].name() == "liner")
62 else if (boundary()[i].name() == "cylinderHead")
64 cylinderHeadIndex = i;
65 foundCylinderHead = true;
69 reduce(foundPiston, orOp<bool>());
70 reduce(foundLiner, orOp<bool>());
71 reduce(foundCylinderHead, orOp<bool>());
75 FatalErrorIn("Foam::simpleTwoStroke::checkAndCalculate()")
76 << " : cannot find piston patch"
82 FatalErrorIn("Foam::simpleTwoStroke::checkAndCalculate()")
83 << " : cannot find liner patch"
87 if (!foundCylinderHead)
89 FatalErrorIn("Foam::simpleTwoStroke::checkAndCalculate()")
90 << " : cannot find cylinderHead patch"
98 max(boundary()[pistonIndex].patch().localPoints()).z();
100 reduce(pistonPosition(), minOp<scalar>());
102 if (cylinderHeadIndex != -1)
106 boundary()[cylinderHeadIndex].patch().localPoints()
109 reduce(deckHeight(), minOp<scalar>());
111 Info<< "deckHeight: " << deckHeight() << nl
112 << "piston position: " << pistonPosition() << endl;
118 void Foam::simpleTwoStroke::setVirtualPistonPosition()
121 label pistonFaceIndex = faceZones().findZoneID("pistonLayerFaces");
123 bool foundPistonFace = (pistonFaceIndex != -1);
125 Info << "piston face index = " << pistonFaceIndex << endl;
129 FatalErrorIn("Foam::simpleTwoStroke::setVirtualPistonPosition()")
130 << " : cannot find the pistonLayerFaces"
135 const labelList& pistonFaces = faceZones()[pistonFaceIndex];
136 forAll(pistonFaces, i)
138 const face& f = faces()[pistonFaces[i]];
140 // should loop over facepoints...
143 virtualPistonPosition() = max(virtualPistonPosition(), points()[f[j]].z());
147 reduce(virtualPistonPosition(), maxOp<scalar>());