engineMesh.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2011-2015 OpenFOAM Foundation
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 \*---------------------------------------------------------------------------*/
27 
28 #include "engineMesh.H"
29 #include "dimensionedScalar.H"
30 
31 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
32 
33 namespace Foam
34 {
35 defineTypeNameAndDebug(engineMesh, 0);
36 defineRunTimeSelectionTable(engineMesh, IOobject);
37 }
38 
39 
40 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
41 
42 Foam::engineMesh::engineMesh(const IOobject& io)
43 :
44  fvMesh(io),
45  engineDB_(refCast<const engineTime>(time())),
46  pistonIndex_(-1),
47  linerIndex_(-1),
48  cylinderHeadIndex_(-1),
49  deckHeight_("deckHeight", dimLength, GREAT),
50  pistonPosition_("pistonPosition", dimLength, -GREAT)
51 {
52  bool foundPiston = false;
53  bool foundLiner = false;
54  bool foundCylinderHead = false;
55 
56  forAll(boundary(), i)
57  {
58  if (boundary()[i].name() == "piston")
59  {
60  pistonIndex_ = i;
61  foundPiston = true;
62  }
63  else if (boundary()[i].name() == "liner")
64  {
65  linerIndex_ = i;
66  foundLiner = true;
67  }
68  else if (boundary()[i].name() == "cylinderHead")
69  {
71  foundCylinderHead = true;
72  }
73  }
74 
75  reduce(foundPiston, orOp<bool>());
76  reduce(foundLiner, orOp<bool>());
77  reduce(foundCylinderHead, orOp<bool>());
78 
79  if (!foundPiston)
80  {
82  << "cannot find piston patch"
83  << exit(FatalError);
84  }
85 
86  if (!foundLiner)
87  {
89  << "cannot find liner patch"
90  << exit(FatalError);
91  }
92 
93  if (!foundCylinderHead)
94  {
96  << "cannot find cylinderHead patch"
97  << exit(FatalError);
98  }
99 
100  {
101  if (pistonIndex_ != -1)
102  {
103  pistonPosition_.value() = -GREAT;
104  if (boundary()[pistonIndex_].patch().localPoints().size())
105  {
107  max(boundary()[pistonIndex_].patch().localPoints()).z();
108  }
109  }
111 
112  if (cylinderHeadIndex_ != -1)
113  {
114  deckHeight_.value() = GREAT;
115  if (boundary()[cylinderHeadIndex_].patch().localPoints().size())
116  {
117  deckHeight_.value() = min
118  (
119  boundary()[cylinderHeadIndex_].patch().localPoints()
120  ).z();
121  }
122  }
124 
125  Info<< "deckHeight: " << deckHeight_.value() << nl
126  << "piston position: " << pistonPosition_.value() << endl;
127  }
128 }
129 
130 
131 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
132 
134 {}
135 
136 // ************************************************************************* //
Foam::HashTable< regIOobject * >::size
label size() const noexcept
The number of elements in table.
Definition: HashTableI.H:52
Foam::maxOp
Definition: ops.H:223
Foam::IOobject
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:104
Foam::dimLength
const dimensionSet dimLength(0, 1, 0, 0, 0, 0, 0)
Definition: dimensionSets.H:53
Foam::minOp
Definition: ops.H:224
Foam::defineRunTimeSelectionTable
defineRunTimeSelectionTable(reactionRateFlameArea, dictionary)
Foam::engineMesh::~engineMesh
virtual ~engineMesh()
Destructor.
Definition: engineMesh.C:133
Foam::engineMesh::pistonPosition_
dimensionedScalar pistonPosition_
Definition: engineMesh.H:77
Foam::engineMesh::linerIndex_
label linerIndex_
Definition: engineMesh.H:73
Foam::engineMesh::cylinderHeadIndex_
label cylinderHeadIndex_
Definition: engineMesh.H:74
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:350
Foam::engineMesh::deckHeight_
dimensionedScalar deckHeight_
Definition: engineMesh.H:76
Foam::dimensioned::value
const Type & value() const
Return const reference to value.
Definition: dimensionedType.C:434
Foam::engineMesh::pistonIndex_
label pistonIndex_
Definition: engineMesh.H:72
Foam::min
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
Definition: hashSets.C:33
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:296
Foam::Info
messageStream Info
Information stream (uses stdout - output is on the master only)
Foam::max
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
Definition: hashSets.C:47
engineMesh.H
Foam::FatalError
error FatalError
Foam::engineTime
An abstract class for the time description of the piston motion.
Definition: engineTime.H:54
Foam::fvMesh
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:83
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::refCast
To & refCast(From &r)
Reference type cast template function.
Definition: typeInfo.H:131
Foam::exit
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:130
Foam::fvMesh::boundary
const fvBoundaryMesh & boundary() const
Return reference to boundary mesh.
Definition: fvMesh.C:679
dimensionedScalar.H
FatalErrorInFunction
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:381
Foam::lduMesh::reduce
void reduce(T &Value, const BinaryOp &bop) const
Helper: reduce with current communicator.
Definition: lduMeshTemplates.C:34
Foam::nl
constexpr char nl
Definition: Ostream.H:385
Foam::foamVersion::patch
const std::string patch
OpenFOAM patch number as a std::string.
Foam::orOp
Definition: ops.H:234
Foam::defineTypeNameAndDebug
defineTypeNameAndDebug(combustionModel, 0)
Foam::fvMesh::name
const word & name() const
Return reference to name.
Definition: fvMesh.H:295