cylinderHeadPoints.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) 2025 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 "cylinderHeadPoints.H"
27 #include "multiValveEngine.H"
29 
30 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
31 
32 namespace Foam
33 {
34  namespace zoneGenerators
35  {
38  (
42  );
43  }
44 }
45 
46 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
47 
49 (
50  const word& name,
51  const polyMesh& mesh,
52  const dictionary& dict
53 )
54 :
56 {}
57 
58 
59 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
60 
62 {}
63 
64 
65 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
66 
68 {
69  const fvMesh& mesh = refCast<const fvMesh>(mesh_);
70 
72  (
73  refCast<const fvMeshMovers::multiValveEngine>(mesh.mover())
74  );
75 
76  const pointField& points = mesh.points();
77  const polyBoundaryMesh& pbm = mesh.boundaryMesh();
78 
79  // Set the cylinderHead point flags
80  boolList cylinderHeadPoints(points.size(), false);
82  {
84  (
86  pbm[iter.key()].meshPoints()
87  ) = true;
88  }
89 
90  // Set the liner point flags
91  boolList linerPoints(points.size(), false);
93  {
95  (
96  linerPoints,
97  pbm[iter.key()].meshPoints()
98  ) = true;
99  }
100 
101  // Find the minimum axis_ coordinate of the cylinder head region
102  // from the bottom of the intersections with the liner
103  // for which both the cylinderHead and liner point flags are true
104  // Assumes the piston moves in the positive axis direction
105 
106  scalar minZ = great;
107  bool foundIntersection = false;
109  {
110  if (cylinderHeadPoints[pi] && linerPoints[pi])
111  {
112  minZ = min(mve.piston.axis & points[pi], minZ);
113  foundIntersection = true;
114  }
115  }
116 
117  // If the intersection not found on this processor
118  // set minZ to -great so that the reduction sets minZ
119  if (!foundIntersection)
120  {
121  minZ = -great;
122  }
123 
124  reduce(minZ, maxOp<scalar>());
125 
126  // Create the cylinderHead point set
127  labelList pointIndices(points.size());
128  label zpi = 0;
129  forAll(points, pi)
130  {
131  if ((mve.piston.axis & points[pi]) > minZ)
132  {
133  pointIndices[zpi++] = pi;
134  }
135  }
136  pointIndices.setSize(zpi);
137 
138  return zoneSet
139  (
140  new pointZone
141  (
142  dict_.found("name")
143  ? zoneName_
144  : mve.cylinderHeadName,
145  pointIndices,
146  mesh_.pointZones(),
147  moveUpdate_,
148  true
149  )
150  );
151 }
152 
153 
154 // ************************************************************************* //
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:433
#define forAllConstIter(Container, container, iter)
Iterate across all elements in the container object of type.
Definition: UList.H:476
Macros for easy insertion into run-time selection tables.
void setSize(const label)
Reset size of List.
Definition: List.C:281
A List with indirect addressing.
Definition: UIndirectList.H:60
A list of keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
Definition: dictionary.H:162
A mesh mover using explicit node translation based on scaled distance functions per moving object....
const labelHashSet & staticPatchSet
Static patch set.
const labelHashSet & linerPatchSet
User-defined liner patches.
const pistonObject & piston
Piston object.
static word cylinderHeadName
Name of the cylinder head pointZone.
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:96
const fvMeshMover & mover() const
Return the mover function class.
Definition: fvMesh.C:1155
Named list of point indices representing a sub-set of the mesh faces.
Definition: pointZone.H:60
Foam::polyBoundaryMesh.
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:80
const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh.
Definition: polyMesh.H:401
virtual const pointField & points() const
Return raw points.
Definition: polyMesh.C:1331
A class for handling words, derived from string.
Definition: word.H:62
Abstract base class for all zoneGenerators, providing runtime selection.
Definition: zoneGenerator.H:57
A zoneGenerator which selects the points within the engine cylinder head.
cylinderHeadPoints(const word &name, const polyMesh &mesh, const dictionary &dict)
Construct from dictionary.
virtual zoneSet generate() const
Generate and return the zoneSet.
Zone container returned by zoneGenerator::generate.
Definition: zoneSet.H:94
Foam::fvMesh mesh(Foam::IOobject(regionName, runTime.name(), runTime, Foam::IOobject::MUST_READ), false)
const pointField & points
defineTypeNameAndDebug(cylinderHeadPoints, 0)
addToRunTimeSelectionTable(zoneGenerator, cylinderHeadPoints, dictionary)
Namespace for OpenFOAM.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
layerAndWeight min(const layerAndWeight &a, const layerAndWeight &b)
void reduce(const List< UPstream::commsStruct > &comms, T &Value, const BinaryOp &bop, const int tag, const label comm)
word name(const LagrangianState state)
Return a string representation of a Lagrangian state enumeration.
dictionary dict