Fix tutorials: typo in tutorials/viscoelastic/viscoelasticFluidFoam/S-MDCPP/constant...
[OpenFOAM-1.6-ext.git] / src / engine / engineTopoChangerMesh / thoboisMesh / thoboisMeshInitialize.C
bloba5d89bd1bd609cb570ee265c6d396f30857e3c15
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 "thoboisMesh.H"
28 #include "slidingInterface.H"
29 #include "layerAdditionRemoval.H"
30 #include "surfaceFields.H"
31 #include "regionSplit.H"
33 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
35 void Foam::thoboisMesh::checkAndCalculate()
37     
38     label pistonIndex = -1;
39     bool foundPiston = false;
41     label linerIndex = -1;
42     bool foundLiner = false;
44     label cylinderHeadIndex = -1;
45     bool foundCylinderHead = false;
46     
47     
48     forAll(boundary(), i)
49     {
50         if (boundary()[i].name() == "piston")
51         {
52             pistonIndex = i;
53             foundPiston = true;
54         }
55         else if (boundary()[i].name() == "liner")
56         {
57             linerIndex = i;
58             foundLiner = true;
59         }
60 //        else if (boundary()[i].name() == "cylinderHead")
61         else if (boundary()[i].name() == cylinderHeadName_)
62         {
63             cylinderHeadIndex = i;
64             foundCylinderHead = true;
65         }
66     }
67     
68     reduce(foundPiston, orOp<bool>());
69     reduce(foundLiner, orOp<bool>());
70     reduce(foundCylinderHead, orOp<bool>());
72     if (!foundPiston)
73     {
74         FatalErrorIn("Foam::thoboisMesh::checkAndCalculate()")
75             << " : cannot find piston patch"
76             << abort(FatalError);
77     }
79     if (!foundLiner)
80     { 
81         FatalErrorIn("Foam::thoboisMesh::checkAndCalculate()")
82             << " : cannot find liner patch"
83             << abort(FatalError);
84     }
86     if (!foundCylinderHead)
87     { 
88         FatalErrorIn("Foam::thoboisMesh::checkAndCalculate()")
89             << " : cannot find cylinderHead patch"
90             << exit(FatalError);
91     }
93     {
94         if (linerIndex != -1)
95         {
96             pistonPosition() =
97                 max(boundary()[pistonIndex].patch().localPoints()).z();
98         }
99         reduce(pistonPosition(), minOp<scalar>());
101         if (cylinderHeadIndex != -1)
102         {
103             deckHeight() = min
104             (
105                 boundary()[cylinderHeadIndex].patch().localPoints()
106             ).z();
108  /*        
109            deckHeight() = max
110             (
111                 boundary()[linerIndex].patch().localPoints()
112             ).z();
113 */                        
114         }
115         reduce(deckHeight(), minOp<scalar>());
117         Info<< "deckHeight: " << deckHeight() << nl
118             << "piston position: " << pistonPosition() << endl;
119     }
120         
121     
124 void Foam::thoboisMesh::setVirtualPositions()
127     {
128         virtualPistonPosition() = -GREAT;
130         label pistonFaceIndex = faceZones().findZoneID("pistonLayerFaces");
131          
132         bool foundPistonFace = (pistonFaceIndex != -1);
133         
134         if(!foundPistonFace)
135         {
136             FatalErrorIn("Foam::thoboisMesh::setVirtualPistonPosition()")
137                 << " : cannot find the pistonLayerFaces"
138                 << exit(FatalError);
139     
140         }
141         
142         const labelList& pistonFaces = faceZones()[pistonFaceIndex];
143         forAll(pistonFaces, i)
144         {
145             const face& f = faces()[pistonFaces[i]];
146         
147             // should loop over facepoints...
148             forAll(f, j)
149             {
150                 virtualPistonPosition() = max(virtualPistonPosition(), points()[f[j]].z());
151             }
152         }
153     
154         reduce(virtualPistonPosition(), maxOp<scalar>());
155     
156     }
157