initial commit for version 1.6.x patch release
[OpenFOAM-1.6.x.git] / src / engine / engineMesh / engineMesh / engineMesh.C
blob329c1a3963d68f3ecc8b50a82e151ce5c4fca55d
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 1991-2009 OpenCFD Ltd.
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 "engineMesh.H"
28 #include "dimensionedScalar.H"
30 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
32 defineTypeNameAndDebug(Foam::engineMesh, 0);
34 defineRunTimeSelectionTable(Foam::engineMesh, IOobject);
36 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
38 Foam::engineMesh::engineMesh(const IOobject& io)
40     fvMesh(io),
41     engineDB_(refCast<const engineTime>(time())),
42     pistonIndex_(-1),
43     linerIndex_(-1),
44     cylinderHeadIndex_(-1),
45     deckHeight_("deckHeight", dimLength, GREAT),
46     pistonPosition_("pistonPosition", dimLength, -GREAT)
48     bool foundPiston = false;
49     bool foundLiner = false;
50     bool foundCylinderHead = false;
52     forAll(boundary(), i)
53     {
54         if (boundary()[i].name() == "piston")
55         {
56             pistonIndex_ = i;
57             foundPiston = true;
58         }
59         else if (boundary()[i].name() == "liner")
60         {
61             linerIndex_ = i;
62             foundLiner = true;
63         }
64         else if (boundary()[i].name() == "cylinderHead")
65         {
66             cylinderHeadIndex_ = i;
67             foundCylinderHead = true;
68         }
69     }
71     reduce(foundPiston, orOp<bool>());
72     reduce(foundLiner, orOp<bool>());
73     reduce(foundCylinderHead, orOp<bool>());
75     if (!foundPiston)
76     {
77         FatalErrorIn("engineMesh::engineMesh(const IOobject& io)")
78             << "cannot find piston patch"
79             << exit(FatalError);
80     }
82     if (!foundLiner)
83     {
84         FatalErrorIn("engineMesh::engineMesh(const IOobject& io)")
85             << "cannot find liner patch"
86             << exit(FatalError);
87     }
89     if (!foundCylinderHead)
90     {
91         FatalErrorIn("engineMesh::engineMesh(const IOobject& io)")
92             << "cannot find cylinderHead patch"
93             << exit(FatalError);
94     }
96     {
97         if (pistonIndex_ != -1)
98         {
99             pistonPosition_.value() = -GREAT;
100             if (boundary()[pistonIndex_].patch().localPoints().size())
101             {
102                 pistonPosition_.value() =
103                     max(boundary()[pistonIndex_].patch().localPoints()).z();
104             }
105         }
106         reduce(pistonPosition_.value(), maxOp<scalar>());
108         if (cylinderHeadIndex_ != -1)
109         {
110             deckHeight_.value() = GREAT;
111             if (boundary()[cylinderHeadIndex_].patch().localPoints().size())
112             {
113                 deckHeight_.value() = min
114                 (
115                     boundary()[cylinderHeadIndex_].patch().localPoints()
116                 ).z();
117             }
118         }
119         reduce(deckHeight_.value(), minOp<scalar>());
121         Info<< "deckHeight: " << deckHeight_.value() << nl
122             << "piston position: " << pistonPosition_.value() << endl;
123     }
127 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
129 Foam::engineMesh::~engineMesh()
132 // ************************************************************************* //