1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
7 -------------------------------------------------------------------------------
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
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)
41 engineDB_(refCast<const engineTime>(time())),
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;
54 if (boundary()[i].name() == "piston")
59 else if (boundary()[i].name() == "liner")
64 else if (boundary()[i].name() == "cylinderHead")
66 cylinderHeadIndex_ = i;
67 foundCylinderHead = true;
71 reduce(foundPiston, orOp<bool>());
72 reduce(foundLiner, orOp<bool>());
73 reduce(foundCylinderHead, orOp<bool>());
77 FatalErrorIn("engineMesh::engineMesh(const IOobject& io)")
78 << "cannot find piston patch"
84 FatalErrorIn("engineMesh::engineMesh(const IOobject& io)")
85 << "cannot find liner patch"
89 if (!foundCylinderHead)
91 FatalErrorIn("engineMesh::engineMesh(const IOobject& io)")
92 << "cannot find cylinderHead patch"
97 if (pistonIndex_ != -1)
99 pistonPosition_.value() = -GREAT;
100 if (boundary()[pistonIndex_].patch().localPoints().size())
102 pistonPosition_.value() =
103 max(boundary()[pistonIndex_].patch().localPoints()).z();
106 reduce(pistonPosition_.value(), maxOp<scalar>());
108 if (cylinderHeadIndex_ != -1)
110 deckHeight_.value() = GREAT;
111 if (boundary()[cylinderHeadIndex_].patch().localPoints().size())
113 deckHeight_.value() = min
115 boundary()[cylinderHeadIndex_].patch().localPoints()
119 reduce(deckHeight_.value(), minOp<scalar>());
121 Info<< "deckHeight: " << deckHeight_.value() << nl
122 << "piston position: " << pistonPosition_.value() << endl;
127 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
129 Foam::engineMesh::~engineMesh()
132 // ************************************************************************* //