engineMesh.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
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
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
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.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
26 #include "engineMesh.H"
27 #include "dimensionedScalar.H"
28 
29 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
30 
31 namespace Foam
32 {
33 defineTypeNameAndDebug(engineMesh, 0);
34 defineRunTimeSelectionTable(engineMesh, IOobject);
35 }
36 
37 
38 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
39 
41 :
42  fvMesh(io),
43  engineDB_(refCast<const engineTime>(time())),
44  pistonIndex_(-1),
45  linerIndex_(-1),
46  cylinderHeadIndex_(-1),
47  deckHeight_("deckHeight", dimLength, great),
48  pistonPosition_("pistonPosition", dimLength, -great)
49 {
50  bool foundPiston = false;
51  bool foundLiner = false;
52  bool foundCylinderHead = false;
53 
54  forAll(boundary(), i)
55  {
56  if (boundary()[i].name() == "piston")
57  {
58  pistonIndex_ = i;
59  foundPiston = true;
60  }
61  else if (boundary()[i].name() == "liner")
62  {
63  linerIndex_ = i;
64  foundLiner = true;
65  }
66  else if (boundary()[i].name() == "cylinderHead")
67  {
69  foundCylinderHead = true;
70  }
71  }
72 
73  reduce(foundPiston, orOp<bool>());
74  reduce(foundLiner, orOp<bool>());
75  reduce(foundCylinderHead, orOp<bool>());
76 
77  if (!foundPiston)
78  {
80  << "cannot find piston patch"
81  << exit(FatalError);
82  }
83 
84  if (!foundLiner)
85  {
87  << "cannot find liner patch"
88  << exit(FatalError);
89  }
90 
91  if (!foundCylinderHead)
92  {
94  << "cannot find cylinderHead patch"
95  << exit(FatalError);
96  }
97 
98  {
99  if (pistonIndex_ != -1)
100  {
101  pistonPosition_.value() = -great;
102  if (boundary()[pistonIndex_].patch().localPoints().size())
103  {
105  max(boundary()[pistonIndex_].patch().localPoints()).z();
106  }
107  }
109 
110  if (cylinderHeadIndex_ != -1)
111  {
112  deckHeight_.value() = great;
113  if (boundary()[cylinderHeadIndex_].patch().localPoints().size())
114  {
115  deckHeight_.value() = min
116  (
117  boundary()[cylinderHeadIndex_].patch().localPoints()
118  ).z();
119  }
120  }
122 
123  Info<< "deckHeight: " << deckHeight_.value() << nl
124  << "piston position: " << pistonPosition_.value() << endl;
125  }
126 }
127 
128 
129 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
130 
132 {}
133 
134 // ************************************************************************* //
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:434
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
error FatalError
dimensioned< Type > max(const dimensioned< Type > &, const dimensioned< Type > &)
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:319
To & refCast(From &r)
Reference type cast template function.
Definition: typeInfo.H:106
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:256
engineMesh(const IOobject &io)
Construct from objectRegistry, and read/write options.
Definition: engineMesh.C:40
virtual ~engineMesh()
Destructor.
Definition: engineMesh.C:131
An abstract class for the time description of the piston motion.
Definition: engineTime.H:51
label size() const
Return number of elements in table.
Definition: HashTableI.H:65
dimensionedScalar deckHeight_
Definition: engineMesh.H:65
label pistonIndex_
Definition: engineMesh.H:61
const Type & value() const
Return const reference to value.
static const char nl
Definition: Ostream.H:265
defineRunTimeSelectionTable(reactionRateFlameArea, dictionary)
defineTypeNameAndDebug(combustionModel, 0)
dimensioned< Type > min(const dimensioned< Type > &, const dimensioned< Type > &)
const word & name() const
Return reference to name.
Definition: fvMesh.H:253
const dimensionSet dimLength(0, 1, 0, 0, 0, 0, 0)
Definition: dimensionSets.H:50
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:78
messageStream Info
label cylinderHeadIndex_
Definition: engineMesh.H:63
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:92
dimensionedScalar pistonPosition_
Definition: engineMesh.H:66
void reduce(T &Value, const BinaryOp &bop) const
Helper: reduce with current communicator.
Namespace for OpenFOAM.
const fvBoundaryMesh & boundary() const
Return reference to boundary mesh.
Definition: fvMesh.C:540