Formatting
[foam-extend-3.2.git] / src / engine / engineTopoChangerMesh / layerSmooth / layerSmoothInitialize.C
blob31617735cfd0ec10a124e9883e01bd29094c8184
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | foam-extend: Open Source CFD
4    \\    /   O peration     | Version:     3.2
5     \\  /    A nd           | Web:         http://www.foam-extend.org
6      \\/     M anipulation  | For copyright notice see file Copyright
7 -------------------------------------------------------------------------------
8 License
9     This file is part of foam-extend.
11     foam-extend 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 3 of the License, or (at your
14     option) any later version.
16     foam-extend is distributed in the hope that it will be useful, but
17     WITHOUT ANY WARRANTY; without even the implied warranty of
18     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
19     General Public License for more details.
21     You should have received a copy of the GNU General Public License
22     along with foam-extend.  If not, see <http://www.gnu.org/licenses/>.
24 \*---------------------------------------------------------------------------*/
26 #include "layerSmooth.H"
27 #include "slidingInterface.H"
28 #include "layerAdditionRemoval.H"
29 #include "surfaceFields.H"
30 #include "regionSplit.H"
32 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
34 void Foam::layerSmooth::checkAndCalculate()
36     label pistonIndex = -1;
37     bool foundPiston = false;
39     label linerIndex = -1;
40     bool foundLiner = false;
42     label cylinderHeadIndex = -1;
43     bool foundCylinderHead = false;
46     forAll(boundary(), i)
47     {
48         if (boundary()[i].name() == "piston")
49         {
50             pistonIndex = i;
51             foundPiston = true;
52         }
53         else if (boundary()[i].name() == "liner")
54         {
55             linerIndex = i;
56             foundLiner = true;
57         }
58         else if (boundary()[i].name() == "cylinderHead")
59         {
60             cylinderHeadIndex = i;
61             foundCylinderHead = true;
62         }
63     }
65     reduce(foundPiston, orOp<bool>());
66     reduce(foundLiner, orOp<bool>());
67     reduce(foundCylinderHead, orOp<bool>());
69     if (!foundPiston)
70     {
71         FatalErrorIn("Foam::layerSmooth::checkAndCalculate()")
72             << " : cannot find piston patch"
73             << abort(FatalError);
74     }
76     if (!foundLiner)
77     {
78         FatalErrorIn("Foam::layerSmooth::checkAndCalculate()")
79             << " : cannot find liner patch"
80             << abort(FatalError);
81     }
83     if (!foundCylinderHead)
84     {
85         FatalErrorIn("Foam::layerSmooth::checkAndCalculate()")
86             << " : cannot find cylinderHead patch"
87             << exit(FatalError);
88     }
90     {
91         if (linerIndex != -1)
92         {
93             pistonPosition() =
94                 max(boundary()[pistonIndex].patch().localPoints()).z();
95         }
96         reduce(pistonPosition(), minOp<scalar>());
98         if (cylinderHeadIndex != -1)
99         {
100             deckHeight() = min
101             (
102                 boundary()[cylinderHeadIndex].patch().localPoints()
103             ).z();
105  /*
106            deckHeight() = max
107             (
108                 boundary()[linerIndex].patch().localPoints()
109             ).z();
111         }
112         reduce(deckHeight(), minOp<scalar>());
114         Info<< "deckHeight: " << deckHeight() << nl
115             << "piston position: " << pistonPosition() << endl;
116     }
119 void Foam::layerSmooth::setVirtualPositions()
121     {
122         virtualPistonPosition() = -GREAT;
124         label pistonFaceIndex = faceZones().findZoneID("pistonLayerFaces");
126         bool foundPistonFace = (pistonFaceIndex != -1);
128         if(!foundPistonFace)
129         {
130             FatalErrorIn("Foam::layerSmooth::setVirtualPistonPosition()")
131                 << " : cannot find the pistonLayerFaces"
132                 << exit(FatalError);
133         }
135         const labelList& pistonFaces = faceZones()[pistonFaceIndex];
136         forAll(pistonFaces, i)
137         {
138             const face& f = faces()[pistonFaces[i]];
140             // should loop over facepoints...
141             forAll(f, j)
142             {
143                 virtualPistonPosition() =
144                     max(virtualPistonPosition(), points()[f[j]].z());
145             }
146         }
148         reduce(virtualPistonPosition(), maxOp<scalar>());
149     }
153 // ************************************************************************* //