1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2005-2010 Tommaso Lucchini
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
28 \*---------------------------------------------------------------------------*/
30 #include "thoboisSliding.H"
31 #include "slidingInterface.H"
32 #include "layerAdditionRemoval.H"
33 #include "surfaceFields.H"
34 #include "regionSplit.H"
36 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
38 void Foam::thoboisSliding::checkAndCalculate()
41 label pistonIndex = -1;
42 bool foundPiston = false;
44 label linerIndex = -1;
45 bool foundLiner = false;
47 label cylinderHeadIndex = -1;
48 bool foundCylinderHead = false;
53 if (boundary()[i].name() == "piston")
58 else if (boundary()[i].name() == "liner")
63 else if (boundary()[i].name() == "cylinderHead")
65 cylinderHeadIndex = i;
66 foundCylinderHead = true;
70 reduce(foundPiston, orOp<bool>());
71 reduce(foundLiner, orOp<bool>());
72 reduce(foundCylinderHead, orOp<bool>());
76 FatalErrorIn("Foam::verticalValvesGambit::checkAndCalculate()")
77 << " : cannot find piston patch"
83 FatalErrorIn("Foam::verticalValvesGambit::checkAndCalculate()")
84 << " : cannot find liner patch"
88 if (!foundCylinderHead)
90 FatalErrorIn("Foam::verticalValvesGambit::checkAndCalculate()")
91 << " : cannot find cylinderHead patch"
99 max(boundary()[pistonIndex].patch().localPoints()).z();
101 reduce(pistonPosition(), minOp<scalar>());
103 if (cylinderHeadIndex != -1)
107 boundary()[cylinderHeadIndex].patch().localPoints()
111 reduce(deckHeight(), minOp<scalar>());
113 Info<< "deckHeight: " << deckHeight() << nl
114 << "piston position: " << pistonPosition() << endl;
120 void Foam::thoboisSliding::setVirtualPositions()
124 virtualPistonPosition() = -GREAT;
126 label pistonFaceIndex = faceZones().findZoneID("pistonLayerFaces");
128 bool foundPistonFace = (pistonFaceIndex != -1);
132 FatalErrorIn("Foam::verticalValvesGambit::setVirtualPistonPosition()")
133 << " : cannot find the pistonLayerFaces"
138 const labelList& pistonFaces = faceZones()[pistonFaceIndex];
139 forAll(pistonFaces, i)
141 const face& f = faces()[pistonFaces[i]];
143 // should loop over facepoints...
146 virtualPistonPosition() = max(virtualPistonPosition(), points()[f[j]].z());
150 reduce(virtualPistonPosition(), maxOp<scalar>());
154 forAll(valves_, valveI)
156 if(valves_[valveI].poppetPatchID().active())
159 valveTopPosition_[valveI] = -GREAT;
161 label valveFaceIndex = faceZones().findZoneID("layeringFacesTopZoneV" + Foam::name(valveI + 1));
163 bool foundValveFace = (valveFaceIndex != -1);
167 FatalErrorIn("Foam::verticalValvesGambit::setVirtualPositions()")
168 << " : cannot find the poppetValveFaces"
172 const labelList& valvePoppetFaces = faceZones()[valveFaceIndex];
174 forAll(valvePoppetFaces, i)
176 const face& f = faces()[valvePoppetFaces[i]];
178 // should loop over facepoints...
181 valveTopPosition_[valveI] = max(valveTopPosition_[valveI], points()[f[j]].z());
185 reduce(valveTopPosition_[valveI], maxOp<scalar>());
189 if(valves_[valveI].bottomPatchID().active())
191 valveBottomPosition_[valveI] = GREAT;
193 label valveFaceIndex = faceZones().findZoneID("layeringFacesBottomZoneV" + Foam::name(valveI + 1));
195 bool foundValveFace = (valveFaceIndex != -1);
199 FatalErrorIn("Foam::verticalValvesGambit::setVirtualPositions()")
200 << " : cannot find the bottomValveFaces"
204 const labelList& valveBottomFaces = faceZones()[valveFaceIndex];
205 forAll(valveBottomFaces, i)
207 const face& f = faces()[valveBottomFaces[i]];
209 // should loop over facepoints...
212 valveBottomPosition_[valveI] = min(valveBottomPosition_[valveI], points()[f[j]].z());
220 valvePistonPosition_[valveI] = -GREAT;
222 label valveFaceIndex = faceZones().findZoneID("pistonLayerFacesV" + Foam::name(valveI + 1));
224 const labelList& valvePistonFaces = faceZones()[valveFaceIndex];
225 forAll(valvePistonFaces, i)
227 const face& f = faces()[valvePistonFaces[i]];
229 // should loop over facepoints...
232 valvePistonPosition_[valveI] = max(valvePistonPosition_[valveI], points()[f[j]].z());
236 reduce(valvePistonPosition_[valveI], maxOp<scalar>());