OpenFOAM logo
The Open Source CFD Toolbox
  Source Guide OpenCFD Solutions Contact OpenFOAM

engineMesh.C

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002   =========                 |
00003   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
00004    \\    /   O peration     |
00005     \\  /    A nd           | Copyright (C) 1991-2009 OpenCFD Ltd.
00006      \\/     M anipulation  |
00007 -------------------------------------------------------------------------------
00008 License
00009     This file is part of OpenFOAM.
00010 
00011     OpenFOAM is free software; you can redistribute it and/or modify it
00012     under the terms of the GNU General Public License as published by the
00013     Free Software Foundation; either version 2 of the License, or (at your
00014     option) any later version.
00015 
00016     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
00017     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00019     for more details.
00020 
00021     You should have received a copy of the GNU General Public License
00022     along with OpenFOAM; if not, write to the Free Software Foundation,
00023     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
00024 
00025 \*---------------------------------------------------------------------------*/
00026 
00027 #include "engineMesh.H"
00028 #include "dimensionedScalar.H"
00029 
00030 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
00031 
00032 defineTypeNameAndDebug(Foam::engineMesh, 0);
00033 
00034 defineRunTimeSelectionTable(Foam::engineMesh, IOobject);
00035 
00036 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00037 
00038 Foam::engineMesh::engineMesh(const IOobject& io)
00039 :
00040     fvMesh(io),
00041     engineDB_(refCast<const engineTime>(time())),
00042     pistonIndex_(-1),
00043     linerIndex_(-1),
00044     cylinderHeadIndex_(-1),
00045     deckHeight_("deckHeight", dimLength, GREAT),
00046     pistonPosition_("pistonPosition", dimLength, -GREAT)
00047 {
00048     bool foundPiston = false;
00049     bool foundLiner = false;
00050     bool foundCylinderHead = false;
00051 
00052     forAll(boundary(), i)
00053     {
00054         if (boundary()[i].name() == "piston")
00055         {
00056             pistonIndex_ = i;
00057             foundPiston = true;
00058         }
00059         else if (boundary()[i].name() == "liner")
00060         {
00061             linerIndex_ = i;
00062             foundLiner = true;
00063         }
00064         else if (boundary()[i].name() == "cylinderHead")
00065         {
00066             cylinderHeadIndex_ = i;
00067             foundCylinderHead = true;
00068         }
00069     }
00070 
00071     reduce(foundPiston, orOp<bool>());
00072     reduce(foundLiner, orOp<bool>());
00073     reduce(foundCylinderHead, orOp<bool>());
00074 
00075     if (!foundPiston)
00076     {
00077         FatalErrorIn("engineMesh::engineMesh(const IOobject& io)")
00078             << "cannot find piston patch"
00079             << exit(FatalError);
00080     }
00081 
00082     if (!foundLiner)
00083     {
00084         FatalErrorIn("engineMesh::engineMesh(const IOobject& io)")
00085             << "cannot find liner patch"
00086             << exit(FatalError);
00087     }
00088 
00089     if (!foundCylinderHead)
00090     {
00091         FatalErrorIn("engineMesh::engineMesh(const IOobject& io)")
00092             << "cannot find cylinderHead patch"
00093             << exit(FatalError);
00094     }
00095 
00096     {
00097         if (pistonIndex_ != -1)
00098         {
00099             pistonPosition_.value() = -GREAT;
00100             if (boundary()[pistonIndex_].patch().localPoints().size())
00101             {
00102                 pistonPosition_.value() =
00103                     max(boundary()[pistonIndex_].patch().localPoints()).z();
00104             }
00105         }
00106         reduce(pistonPosition_.value(), maxOp<scalar>());
00107 
00108         if (cylinderHeadIndex_ != -1)
00109         {
00110             deckHeight_.value() = GREAT;
00111             if (boundary()[cylinderHeadIndex_].patch().localPoints().size())
00112             {
00113                 deckHeight_.value() = min
00114                 (
00115                     boundary()[cylinderHeadIndex_].patch().localPoints()
00116                 ).z();
00117             }
00118         }
00119         reduce(deckHeight_.value(), minOp<scalar>());
00120 
00121         Info<< "deckHeight: " << deckHeight_.value() << nl
00122             << "piston position: " << pistonPosition_.value() << endl;
00123     }
00124 }
00125 
00126 
00127 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
00128 
00129 Foam::engineMesh::~engineMesh()
00130 {}
00131 
00132 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd