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-------------------------------------------------------------------------------
10License
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
33namespace Foam
34{
37}
38
39
40// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
41
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 {
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// ************************************************************************* //
label size() const noexcept
The number of elements in table.
Definition: HashTableI.H:52
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:170
const Type & value() const
Return const reference to value.
Foam::engineMesh.
Definition: engineMesh.H:56
virtual ~engineMesh()
Destructor.
Definition: engineMesh.C:133
dimensionedScalar deckHeight_
Definition: engineMesh.H:76
label pistonIndex_
Definition: engineMesh.H:72
label cylinderHeadIndex_
Definition: engineMesh.H:74
dimensionedScalar pistonPosition_
Definition: engineMesh.H:77
An abstract class for the time description of the piston motion.
Definition: engineTime.H:57
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:91
const fvBoundaryMesh & boundary() const
Return reference to boundary mesh.
Definition: fvMesh.C:712
const word & name() const
Return reference to name.
Definition: fvMesh.H:310
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
Definition: className.H:121
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:453
IOobject io("surfaceFilmProperties", mesh.time().constant(), mesh, IOobject::READ_IF_PRESENT, IOobject::NO_WRITE, false)
Namespace for OpenFOAM.
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
Definition: hashSets.C:47
To & refCast(From &r)
Reference type cast template function.
Definition: typeInfo.H:131
const dimensionSet dimLength(0, 1, 0, 0, 0, 0, 0)
Definition: dimensionSets.H:52
messageStream Info
Information stream (stdout output on master, null elsewhere)
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:372
void reduce(const List< UPstream::commsStruct > &comms, T &value, const BinaryOp &bop, const int tag, const label comm)
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
Definition: hashSets.C:33
error FatalError
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:130
constexpr char nl
The newline '\n' character (0x0a)
Definition: Ostream.H:53
#define defineRunTimeSelectionTable(baseType, argNames)
Define run-time selection table.
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:333