fixed writing out entries in advective bc
[OpenFOAM-1.6-ext.git] / src / engine / engineTopoChangerMesh / pistonSliding / pistonSlidingInitialize.C
blob3a8ba711e0628673c7f3e1d9ecda1564813a44c5
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 2005-2010 Tommaso Lucchini
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 Class
26     verticalValvesGambit
28 \*---------------------------------------------------------------------------*/
30 #include "pistonSliding.H"
31 #include "slidingInterface.H"
32 #include "layerAdditionRemoval.H"
33 #include "surfaceFields.H"
34 #include "regionSplit.H"
36 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
38 void Foam::pistonSliding::checkAndCalculate()
40     
41     label pistonIndex = -1;
42     bool foundPiston = false;
44     label linerIndex = -1;
45     bool foundLiner = false;
47     label cylinderHeadIndex = -1;
48     bool foundCylinderHead = false;
49     
50     
51     forAll(boundary(), i)
52     {
53         if (boundary()[i].name() == "piston")
54         {
55             pistonIndex = i;
56             foundPiston = true;
57         }
58         else if (boundary()[i].name() == "liner")
59         {
60             linerIndex = i;
61             foundLiner = true;
62         }
63         else if (boundary()[i].name() == "cylinderHead")
64         {
65             cylinderHeadIndex = i;
66             foundCylinderHead = true;
67         }
68     }
69     
70     reduce(foundPiston, orOp<bool>());
71     reduce(foundLiner, orOp<bool>());
72     reduce(foundCylinderHead, orOp<bool>());
74     if (!foundPiston)
75     {
76         FatalErrorIn("Foam::verticalValvesGambit::checkAndCalculate()")
77             << " : cannot find piston patch"
78             << abort(FatalError);
79     }
81     if (!foundLiner)
82     { 
83         FatalErrorIn("Foam::verticalValvesGambit::checkAndCalculate()")
84             << " : cannot find liner patch"
85             << abort(FatalError);
86     }
88     if (!foundCylinderHead)
89     { 
90         FatalErrorIn("Foam::verticalValvesGambit::checkAndCalculate()")
91             << " : cannot find cylinderHead patch"
92             << exit(FatalError);
93     }
95     {
96         if (linerIndex != -1)
97         {
98             pistonPosition() =
99                 max(boundary()[pistonIndex].patch().localPoints()).z();
100         }
101         reduce(pistonPosition(), minOp<scalar>());
103         if (cylinderHeadIndex != -1)
104         {
105             deckHeight() = min
106             (
107                 boundary()[cylinderHeadIndex].patch().localPoints()
108             ).z();
110         }
111         reduce(deckHeight(), minOp<scalar>());
113         Info<< "deckHeight: " << deckHeight() << nl
114             << "piston position: " << pistonPosition() << endl;
115     }
116         
117     
120 void Foam::pistonSliding::setVirtualPositions()
123     {
124         virtualPistonPosition() = -GREAT;
126         label pistonFaceIndex = faceZones().findZoneID("pistonLayerFaces");
127          
128         bool foundPistonFace = (pistonFaceIndex != -1);
129         
130         if(!foundPistonFace)
131         {
132             FatalErrorIn("Foam::verticalValvesGambit::setVirtualPistonPosition()")
133                 << " : cannot find the pistonLayerFaces"
134                 << exit(FatalError);
135     
136         }
137         
138         const labelList& pistonFaces = faceZones()[pistonFaceIndex];
139         forAll(pistonFaces, i)
140         {
141             const face& f = faces()[pistonFaces[i]];
142         
143             // should loop over facepoints...
144             forAll(f, j)
145             {
146                 virtualPistonPosition() = max(virtualPistonPosition(), points()[f[j]].z());
147             }
148         }
149     
150         reduce(virtualPistonPosition(), maxOp<scalar>());
151     
152     }
153 */    
154     forAll(valves_, valveI)
155     {
156         if(valves_[valveI].poppetPatchID().active())
157         {
159             valveTopPosition_[valveI] = -GREAT;
160         
161             label valveFaceIndex = faceZones().findZoneID("layeringFacesTopZoneV" + Foam::name(valveI + 1));
162          
163             bool foundValveFace = (valveFaceIndex != -1);
164         
165             if(!foundValveFace)
166             {
167                 FatalErrorIn("Foam::verticalValvesGambit::setVirtualPositions()")
168                     << " : cannot find the poppetValveFaces"
169                     << exit(FatalError);
170             }
171         
172             const labelList& valvePoppetFaces = faceZones()[valveFaceIndex];
173             
174             forAll(valvePoppetFaces, i)
175             {
176                 const face& f = faces()[valvePoppetFaces[i]];
177         
178                 // should loop over facepoints...
179                 forAll(f, j)
180                 {
181                     valveTopPosition_[valveI] = max(valveTopPosition_[valveI], points()[f[j]].z());
182                 }
183             }
184     
185             reduce(valveTopPosition_[valveI], maxOp<scalar>());
186             
187             
188         }
189         if(valves_[valveI].bottomPatchID().active())
190         {
191             valveBottomPosition_[valveI] = GREAT;
192         
193             label valveFaceIndex = faceZones().findZoneID("layeringFacesBottomZoneV" + Foam::name(valveI + 1));
194          
195             bool foundValveFace = (valveFaceIndex != -1);
196         
197             if(!foundValveFace)
198             {
199                 FatalErrorIn("Foam::verticalValvesGambit::setVirtualPositions()")
200                     << " : cannot find the bottomValveFaces"
201                     << exit(FatalError);
202             }
203         
204             const labelList& valveBottomFaces = faceZones()[valveFaceIndex];
205             forAll(valveBottomFaces, i)
206             {
207                 const face& f = faces()[valveBottomFaces[i]];
208         
209                 // should loop over facepoints...
210                 forAll(f, j)
211                 {
212                     valveBottomPosition_[valveI] = min(valveBottomPosition_[valveI], points()[f[j]].z());                    
213                 }
214             }
215    
216         
217         }
218         
219 /*        {
220             valvePistonPosition_[valveI] = -GREAT;
221             
222             label valveFaceIndex = faceZones().findZoneID("pistonLayerFacesV" + Foam::name(valveI + 1));
223                  
224             const labelList& valvePistonFaces = faceZones()[valveFaceIndex];
225             forAll(valvePistonFaces, i)
226             {
227                 const face& f = faces()[valvePistonFaces[i]];
228         
229                 // should loop over facepoints...
230                 forAll(f, j)
231                 {
232                     valvePistonPosition_[valveI] = max(valvePistonPosition_[valveI], points()[f[j]].z());
233                 }
234             }
235     
236             reduce(valvePistonPosition_[valveI], maxOp<scalar>());
237         
238         }
239 */    
240     }
241     
242