Fix tutorials: typo in tutorials/viscoelastic/viscoelasticFluidFoam/S-MDCPP/constant...
[OpenFOAM-1.6-ext.git] / src / engine / engineTopoChangerMesh / accordionEngineMesh / accordionEngineMeshInitialize.C
blobcf396c0712c0060dfca47e0c0d2a1362e518411e
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 "accordionEngineMesh.H"
28 #include "slidingInterface.H"
29 #include "layerAdditionRemoval.H"
30 #include "surfaceFields.H"
31 #include "regionSplit.H"
33 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
35 void Foam::accordionEngineMesh::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().patchID().name())
51         {
52             pistonIndex = i;
53             foundPiston = true;
54         }
55         else if (boundary()[i].name() == linerName_)
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::accordionEngineMesh::checkAndCalculate()")
75             << " : cannot find piston patch"
76             << abort(FatalError);
77     }
79     if (!foundLiner)
80     { 
81         FatalErrorIn("Foam::accordionEngineMesh::checkAndCalculate()")
82             << " : cannot find liner patch"
83             << abort(FatalError);
84     }
86     if (!foundCylinderHead)
87     { 
88         FatalErrorIn("Foam::accordionEngineMesh::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::accordionEngineMesh::setVirtualPositions()