Fix tutorials: typo in tutorials/viscoelastic/viscoelasticFluidFoam/S-MDCPP/constant...
[OpenFOAM-1.6-ext.git] / src / engine / engineTopoChangerMesh / layerSmooth / layerSmoothInitialize.C
blob7706a3d9f7abe5264e7f721b110862d4abb9c660
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright held by original author
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
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
19     for more details.
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;
47     forAll(boundary(), i)
48     {
49         if (boundary()[i].name() == "piston")
50         {
51             pistonIndex = i;
52             foundPiston = true;
53         }
54         else if (boundary()[i].name() == "liner")
55         {
56             linerIndex = i;
57             foundLiner = true;
58         }
59         else if (boundary()[i].name() == "cylinderHead")
60         {
61             cylinderHeadIndex = i;
62             foundCylinderHead = true;
63         }
64     }
66     reduce(foundPiston, orOp<bool>());
67     reduce(foundLiner, orOp<bool>());
68     reduce(foundCylinderHead, orOp<bool>());
70     if (!foundPiston)
71     {
72         FatalErrorIn("Foam::layerSmooth::checkAndCalculate()")
73             << " : cannot find piston patch"
74             << abort(FatalError);
75     }
77     if (!foundLiner)
78     {
79         FatalErrorIn("Foam::layerSmooth::checkAndCalculate()")
80             << " : cannot find liner patch"
81             << abort(FatalError);
82     }
84     if (!foundCylinderHead)
85     {
86         FatalErrorIn("Foam::layerSmooth::checkAndCalculate()")
87             << " : cannot find cylinderHead patch"
88             << exit(FatalError);
89     }
91     {
92         if (linerIndex != -1)
93         {
94             pistonPosition() =
95                 max(boundary()[pistonIndex].patch().localPoints()).z();
96         }
97         reduce(pistonPosition(), minOp<scalar>());
99         if (cylinderHeadIndex != -1)
100         {
101             deckHeight() = min
102             (
103                 boundary()[cylinderHeadIndex].patch().localPoints()
104             ).z();
106  /*
107            deckHeight() = max
108             (
109                 boundary()[linerIndex].patch().localPoints()
110             ).z();
112         }
113         reduce(deckHeight(), minOp<scalar>());
115         Info<< "deckHeight: " << deckHeight() << nl
116             << "piston position: " << pistonPosition() << endl;
117     }
120 void Foam::layerSmooth::setVirtualPositions()
122     {
123         virtualPistonPosition() = -GREAT;
125         label pistonFaceIndex = faceZones().findZoneID("pistonLayerFaces");
127         bool foundPistonFace = (pistonFaceIndex != -1);
129         if(!foundPistonFace)
130         {
131             FatalErrorIn("Foam::layerSmooth::setVirtualPistonPosition()")
132                 << " : cannot find the pistonLayerFaces"
133                 << exit(FatalError);
134         }
136         const labelList& pistonFaces = faceZones()[pistonFaceIndex];
137         forAll(pistonFaces, i)
138         {
139             const face& f = faces()[pistonFaces[i]];
141             // should loop over facepoints...
142             forAll(f, j)
143             {
144                 virtualPistonPosition() =
145                     max(virtualPistonPosition(), points()[f[j]].z());
146             }
147         }
149         reduce(virtualPistonPosition(), maxOp<scalar>());
150     }
154 // ************************************************************************* //