Merge branch 'master' of ssh://git.code.sf.net/p/foam-extend/foam-extend-3.2
[foam-extend-3.2.git] / src / engine / engineTopoChangerMesh / thoboisMesh / thoboisMeshInitialize.C
blob254a01970334bd99f9e940fcc5c163465478c798
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 "thoboisMesh.H"
27 #include "slidingInterface.H"
28 #include "layerAdditionRemoval.H"
29 #include "surfaceFields.H"
30 #include "regionSplit.H"
32 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
34 void Foam::thoboisMesh::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         else if (boundary()[i].name() == cylinderHeadName_)
61         {
62             cylinderHeadIndex = i;
63             foundCylinderHead = true;
64         }
65     }
67     reduce(foundPiston, orOp<bool>());
68     reduce(foundLiner, orOp<bool>());
69     reduce(foundCylinderHead, orOp<bool>());
71     if (!foundPiston)
72     {
73         FatalErrorIn("Foam::thoboisMesh::checkAndCalculate()")
74             << " : cannot find piston patch"
75             << abort(FatalError);
76     }
78     if (!foundLiner)
79     {
80         FatalErrorIn("Foam::thoboisMesh::checkAndCalculate()")
81             << " : cannot find liner patch"
82             << abort(FatalError);
83     }
85     if (!foundCylinderHead)
86     {
87         FatalErrorIn("Foam::thoboisMesh::checkAndCalculate()")
88             << " : cannot find cylinderHead patch"
89             << exit(FatalError);
90     }
92     {
93         if (linerIndex != -1)
94         {
95             pistonPosition() =
96                 max(boundary()[pistonIndex].patch().localPoints()).z();
97         }
98         reduce(pistonPosition(), minOp<scalar>());
100         if (cylinderHeadIndex != -1)
101         {
102             deckHeight() = min
103             (
104                 boundary()[cylinderHeadIndex].patch().localPoints()
105             ).z();
107  /*
108            deckHeight() = max
109             (
110                 boundary()[linerIndex].patch().localPoints()
111             ).z();
113         }
114         reduce(deckHeight(), minOp<scalar>());
116         Info<< "deckHeight: " << deckHeight() << nl
117             << "piston position: " << pistonPosition() << endl;
118     }
123 void Foam::thoboisMesh::setVirtualPositions()
126     {
127         virtualPistonPosition() = -GREAT;
129         label pistonFaceIndex = faceZones().findZoneID("pistonLayerFaces");
131         bool foundPistonFace = (pistonFaceIndex != -1);
133         if(!foundPistonFace)
134         {
135             FatalErrorIn("Foam::thoboisMesh::setVirtualPistonPosition()")
136                 << " : cannot find the pistonLayerFaces"
137                 << exit(FatalError);
139         }
141         const labelList& pistonFaces = faceZones()[pistonFaceIndex];
142         forAll(pistonFaces, i)
143         {
144             const face& f = faces()[pistonFaces[i]];
146             // should loop over facepoints...
147             forAll(f, j)
148             {
149                 virtualPistonPosition() = max(virtualPistonPosition(), points()[f[j]].z());
150             }
151         }
153         reduce(virtualPistonPosition(), maxOp<scalar>());
155     }