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 \*---------------------------------------------------------------------------*/
27 #include "layerSmooth.H"
28 #include "slidingInterface.H"
29 #include "layerAdditionRemoval.H"
30 #include "surfaceFields.H"
31 #include "regionSplit.H"
33 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
35 void Foam::layerSmooth::checkAndCalculate()
37 label pistonIndex = -1;
38 bool foundPiston = false;
40 label linerIndex = -1;
41 bool foundLiner = false;
43 label cylinderHeadIndex = -1;
44 bool foundCylinderHead = false;
49 if (boundary()[i].name() == "piston")
54 else if (boundary()[i].name() == "liner")
59 else if (boundary()[i].name() == "cylinderHead")
61 cylinderHeadIndex = i;
62 foundCylinderHead = true;
66 reduce(foundPiston, orOp<bool>());
67 reduce(foundLiner, orOp<bool>());
68 reduce(foundCylinderHead, orOp<bool>());
72 FatalErrorIn("Foam::layerSmooth::checkAndCalculate()")
73 << " : cannot find piston patch"
79 FatalErrorIn("Foam::layerSmooth::checkAndCalculate()")
80 << " : cannot find liner patch"
84 if (!foundCylinderHead)
86 FatalErrorIn("Foam::layerSmooth::checkAndCalculate()")
87 << " : cannot find cylinderHead patch"
95 max(boundary()[pistonIndex].patch().localPoints()).z();
97 reduce(pistonPosition(), minOp<scalar>());
99 if (cylinderHeadIndex != -1)
103 boundary()[cylinderHeadIndex].patch().localPoints()
109 boundary()[linerIndex].patch().localPoints()
113 reduce(deckHeight(), minOp<scalar>());
115 Info<< "deckHeight: " << deckHeight() << nl
116 << "piston position: " << pistonPosition() << endl;
120 void Foam::layerSmooth::setVirtualPositions()
123 virtualPistonPosition() = -GREAT;
125 label pistonFaceIndex = faceZones().findZoneID("pistonLayerFaces");
127 bool foundPistonFace = (pistonFaceIndex != -1);
131 FatalErrorIn("Foam::layerSmooth::setVirtualPistonPosition()")
132 << " : cannot find the pistonLayerFaces"
136 const labelList& pistonFaces = faceZones()[pistonFaceIndex];
137 forAll(pistonFaces, i)
139 const face& f = faces()[pistonFaces[i]];
141 // should loop over facepoints...
144 virtualPistonPosition() =
145 max(virtualPistonPosition(), points()[f[j]].z());
149 reduce(virtualPistonPosition(), maxOp<scalar>());
154 // ************************************************************************* //