FreeFOAM The Cross-Platform CFD Toolkit
Hosted by SourceForge:
Get FreeFOAM at SourceForge.net.
            Fast, secure and Free Open Source software downloads

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-2010 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
00013     the Free Software Foundation, either version 3 of the License, or
00014     (at your 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, see <http://www.gnu.org/licenses/>.
00023 
00024 \*---------------------------------------------------------------------------*/
00025 
00026 #include "engineMesh.H"
00027 #include <OpenFOAM/dimensionedScalar.H>
00028 
00029 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
00030 
00031 defineTypeNameAndDebug(Foam::engineMesh, 0);
00032 
00033 defineRunTimeSelectionTable(Foam::engineMesh, IOobject);
00034 
00035 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00036 
00037 Foam::engineMesh::engineMesh(const IOobject& io)
00038 :
00039     fvMesh(io),
00040     engineDB_(refCast<const engineTime>(time())),
00041     pistonIndex_(-1),
00042     linerIndex_(-1),
00043     cylinderHeadIndex_(-1),
00044     deckHeight_("deckHeight", dimLength, GREAT),
00045     pistonPosition_("pistonPosition", dimLength, -GREAT)
00046 {
00047     bool foundPiston = false;
00048     bool foundLiner = false;
00049     bool foundCylinderHead = false;
00050 
00051     forAll(boundary(), i)
00052     {
00053         if (boundary()[i].name() == "piston")
00054         {
00055             pistonIndex_ = i;
00056             foundPiston = true;
00057         }
00058         else if (boundary()[i].name() == "liner")
00059         {
00060             linerIndex_ = i;
00061             foundLiner = true;
00062         }
00063         else if (boundary()[i].name() == "cylinderHead")
00064         {
00065             cylinderHeadIndex_ = i;
00066             foundCylinderHead = true;
00067         }
00068     }
00069 
00070     reduce(foundPiston, orOp<bool>());
00071     reduce(foundLiner, orOp<bool>());
00072     reduce(foundCylinderHead, orOp<bool>());
00073 
00074     if (!foundPiston)
00075     {
00076         FatalErrorIn("engineMesh::engineMesh(const IOobject& io)")
00077             << "cannot find piston patch"
00078             << exit(FatalError);
00079     }
00080 
00081     if (!foundLiner)
00082     {
00083         FatalErrorIn("engineMesh::engineMesh(const IOobject& io)")
00084             << "cannot find liner patch"
00085             << exit(FatalError);
00086     }
00087 
00088     if (!foundCylinderHead)
00089     {
00090         FatalErrorIn("engineMesh::engineMesh(const IOobject& io)")
00091             << "cannot find cylinderHead patch"
00092             << exit(FatalError);
00093     }
00094 
00095     {
00096         if (pistonIndex_ != -1)
00097         {
00098             pistonPosition_.value() = -GREAT;
00099             if (boundary()[pistonIndex_].patch().localPoints().size())
00100             {
00101                 pistonPosition_.value() =
00102                     max(boundary()[pistonIndex_].patch().localPoints()).z();
00103             }
00104         }
00105         reduce(pistonPosition_.value(), maxOp<scalar>());
00106 
00107         if (cylinderHeadIndex_ != -1)
00108         {
00109             deckHeight_.value() = GREAT;
00110             if (boundary()[cylinderHeadIndex_].patch().localPoints().size())
00111             {
00112                 deckHeight_.value() = min
00113                 (
00114                     boundary()[cylinderHeadIndex_].patch().localPoints()
00115                 ).z();
00116             }
00117         }
00118         reduce(deckHeight_.value(), minOp<scalar>());
00119 
00120         Info<< "deckHeight: " << deckHeight_.value() << nl
00121             << "piston position: " << pistonPosition_.value() << endl;
00122     }
00123 }
00124 
00125 
00126 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
00127 
00128 Foam::engineMesh::~engineMesh()
00129 {}
00130 
00131 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines