All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
multiValveEngine.H
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) 2024 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 Class
25  Foam::fvMeshMovers::multiValveEngine
26 
27 Description
28  A mesh mover using explicit node translation based on scaled distance
29  functions per moving object. The mover supports any number of valves
30  together with piston motion and following features:
31 
32  - Piston motion: Function1 of user-time, may be set to
33  crankConnectingRodMotion for standard crank and connecting rod motion.
34 
35  - Valve motion: Function1, may be set to table if the valve lift date is
36  provided in the form of a table.
37 
38  - Smooth mesh motion between a moving object and other patches.
39 
40  - linerPatches: the set of patches corresponding to the cylinder liner
41  Used by createEngineZones
42 
43  - slidingPatches: a set of patches along which mesh is allowed
44  to deform. For example, on the cylinder liner, it is desired to
45  slide mesh nodes while piston is moving.
46 
47  - frozenZones: list of pointZones the points of which are frozen,
48  i.e. do not move with respect to any moving object.
49 
50  - Run-time clearance estimation based on patch-to-patch distances printed.
51 
52  - Supports cellSet and cellZone definitions to restrict mesh motion.
53 
54  - Supports domains with nonConformalCoupling (NCC) interfaces,
55  enabling e.g. nodes to slide along with the interface.
56 
57  - Closing the valve can be achieved by meshToMesh mapping onto a new
58  grid with closed valve geometry at user given time.
59 
60  - Mesh motion can be controlled per moving object by setting:
61 
62  - patches: list of patches defining the object.
63 
64  - motion: a Function1 which returns the object position
65  as a function of time.
66 
67  - movingZones: list of pointZones the points of which move with the
68  object.
69 
70  - frozenZones: list of pointZones the points of which are frozen,
71  i.e. do not move with respect to this moving object.
72 
73  - maxMotionDistance: a distance away from the moving object
74  after nodes are not allowed to move. (Default inf.)
75 
76  - movingFrozenLayerThickness: thickness of layer in which points move
77  with the moving object. (Default 0)
78 
79  - staticFrozenLayerThickness: thickness of layer in which points
80  are fixed with respect to static patches (e.g. walls). (Default 0)
81 
82  - cosineScaling: a switch whether nodal translation is weighted by
83  its distance from the moving object. The objective is to yield less
84  deformation near the moving object and sustain e.g. boundary layer.
85  (Default no, i.e. linear weighting)
86 
87  - travelInterval: part of the stroke travelled after
88  which the cached motion scaling weights are recalculated
89 
90  For valve object only:
91 
92  - minLift: a minimum valve lift value after considered closed.
93 
94 
95  Some of the above parameters are highlighted in a given schematic
96  piston-valve configuration w.r.t entries used to control piston motion.
97  Furthermore, an example dictionary entries are provided below.
98  \verbatim
99  | | | |
100  | | | |
101  | | S | |
102  | | T | |
103  | | E | |
104  | | M | |
105  / | | \
106  / | | \
107  / | | \
108  _____________/ | | \_____________
109  | : | | : |
110  | : /``````````````` ```````````````\ : |
111  | : / VALVE HEAD \ : |
112  | L : /_____________________________________________\ : |
113  | I : /\ : |
114  | N : || staticFrozenLayerThickness : |
115  | E : NCC (optional) \/ (w.r.t. piston motion) : |
116  | R : `````````` : |
117  | : : |
118  | : : |
119  |........:.......................................................:........|
120  | : /\ : |
121  | : || movingFrozenLayerThickness : |
122  |________:_________________________\/____________________________:________|
123  PISTON
124  \endverbatim
125 
126  \verbatim
127  mover
128  {
129  type multiValveEngine;
130  libs ("libfvMeshMoversMultiValveEngine.so");
131 
132  frozenZones (frozenZone1 frozenZone2);
133 
134  slidingPatches
135  (
136  liner
137  valveStem
138  "nonCouple.*"
139  );
140 
141  linerPatches (liner);
142 
143  piston
144  {
145  patches (piston);
146  axis (0 0 1);
147 
148  motion
149  {
150  type crankConnectingRodMotion;
151 
152  conRodLength 1e3;
153  stroke 1.0;
154  }
155 
156  // Move the points in the piston bowl with the piston
157  movingZones (pistonBowl);
158 
159  // Freeze the points in the cylinder head
160  frozenZones (cylinderHead);
161 
162  // Optional
163  maxMotionDistance 1e30;
164  movingFrozenLayerThickness 0;
165  staticFrozenLayerThickness 0;
166 
167  travelInterval 0.1;
168 
169  cosineScaling yes;
170  }
171 
172  valves
173  {
174  iv
175  {
176  patches (valveHead);
177  axis (0 0 1);
178 
179  // Optional
180  maxMotionDistance 1e30;
181  movingFrozenLayerThickness 0;
182  staticFrozenLayerThickness 0;
183 
184  travelInterval 0.01;
185 
186  cosineScaling yes;
187 
188  minLift 0.001;
189 
190  motion
191  {
192  type table;
193  values
194  (
195  (0 0)
196  (480 0.1)
197  (720 0)
198  );
199  // For multi-cycle simulations, use repeat
200  outOfBounds repeat;
201  interpolationScheme linear;
202  }
203  }
204  }
205  }
206  \endverbatim
207 
208  Note:
209  The implementation utilises pointDist objects for distance computation,
210  resulting distance fields do not propagate through NCC interfaces. Hence,
211  there should be no horizontal NCC interface separating piston from
212  cylinder head as it would result in potentially ill defined mesh
213  deformation. Due to same feature, in a schematic case setup above, valve
214  motion affects only cells between NCC patches even though no cellSet is
215  explicitly defined.
216 
217 SourceFiles
218  multiValveEngine.C
219 
220 \*---------------------------------------------------------------------------*/
221 
222 #ifndef multiValveEngine_H
223 #define multiValveEngine_H
224 
225 #include "fvMeshMover.H"
226 #include "Function1.H"
227 #include "pointFields.H"
228 
229 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
230 
231 namespace Foam
232 {
233 
234 // Forward declaration of classes
235 class pointDist;
236 
237 namespace fvMeshMovers
238 {
239 
240 /*---------------------------------------------------------------------------*\
241  Class multiValveEngine Declaration
242 \*---------------------------------------------------------------------------*/
243 
244 class multiValveEngine
245 :
246  public fvMeshMover
247 {
248 public:
249 
250  class movingObject
251  {
252  friend class multiValveEngine;
253 
254  protected:
255 
256  // Protected member data
257 
258  //- Coefficients dictionary
260 
261 
262  // Protected Data
263 
264  //- Reference to engine mesh mover
266 
267  public:
268 
269  //- Name of the object
270  const word name;
271 
272  //- Axis
273  const vector axis;
274 
275 
276  protected:
277 
278  // Protected member data
279 
280  //- Piston motion function
282 
283  //- Object patchSet
285 
286  //- Patches which must not deform during mesh motion
288 
289  //- Distance from object beyond which the mesh does not deform
290  scalar maxMotionDistance_;
291 
292  //- Distance from object within mesh nodes move
293  // along with the patch
295 
296  //- Distance from static wall patch at domain perimeter
297  // within mesh nodes do not move
299 
301 
303 
304  //- Points to move when cell zone is supplied
306 
307  //- Interpolation scale (1 at moving patches, 0 at far-field)
309 
310  //- Switch to use cosine-based scaling
311  // for the boundary point motion
312  Switch cosine_;
313 
314  //- Update the scale_ field when the travel exceeds travelInterval
315  const scalar travelInterval_;
316 
317  //- Count of the scale_ field updates
318  mutable label executionCount_;
319 
320  //- Position at last scale update
321  mutable scalar position0_;
322 
323 
324  // Protected Member Functions
325 
326  //- Scale the mesh point deformation with distance functions
327  // w.r.t. moving patches, static patches and a frozen zones.
328  void calcScale
329  (
330  const pointMesh& pMesh,
331  const scalarField& pDistMoving,
332  const scalarField& pDistStatic,
333  scalar dMoving,
334  scalar dMax,
335  scalar dStatic
336  );
337 
338  void transformPoints
339  (
340  pointField& newPoints,
341  const vector& translationVector
342  );
343 
344  //- Generate staticPatchSet_ based on patch entries
345  void createStaticPatchSet();
346 
347  //- Patch-set construction
348  void initPatchSets();
349 
351 
353 
354 
355  public:
356 
357  //- Object patchSet
358  const labelHashSet& patchSet;
359 
360  // Constructors
361 
362  //- Construct from dictionary
364  (
365  const word& name,
366  const multiValveEngine& engine,
367  const dictionary& dict
368  );
369 
370  //- Destructor
371  virtual ~movingObject()
372  {}
373 
374 
375  // Member Functions
376 
377  //- Update from another mesh using the given map
378  virtual void mapMesh(const polyMeshMap&);
379  };
380 
381 
382  class pistonObject
383  :
384  public movingObject
385  {
386  // Private member data
387 
388  //- Bore
389  scalar bore_;
390 
391  //- Clearance
392  scalar clearance_;
393 
394 
395  // Private member functions
396 
397  //- Return the bore
398  // calculated from the lateral extent of the piston
399  scalar bore() const;
400 
401  //- Calculate clearance estimate based on minimum distance
402  // between piston and any other patch excluding slidingPatches.
403  void correctClearance(pointDist&);
404 
405 
406  public:
407 
408  //- Name of the piston bowl pointZone
409  static word pistonBowlName;
410 
411  // Constructors
412 
413  //- Construct from dictionary
415  (
416  const word& name,
417  const multiValveEngine& engine,
418  const dictionary& dict
419  );
420 
421 
422  // Member Functions
423 
424  //- Return the piston position for the given CA theta
425  scalar position(const scalar theta) const;
426 
427  //- Return the current piston position
428  scalar position() const;
429 
430  //- Return piston displacement for current time-step
431  scalar displacement() const;
432 
433  //- Return piston position for current time-step
434  scalar speed() const;
435 
436  //- Return clearance estimate
437  scalar clearance() const;
438 
439  //- update points due to piston motion
440  void updatePoints(pointField&);
441 
442  //- Update from another mesh using the given map
443  virtual void mapMesh(const polyMeshMap&);
444  };
445 
446 
447  class valveObject
448  :
449  public movingObject
450  {
451  // Private member data
452 
453  //- Minimum valve lift.
454  // On this lift the valve is considered closed
455  const scalar minLift_;
456 
457 
458  // Private member functions
459 
460 
461  public:
462 
463  // Constructors
464 
465  //- Construct from dictionary
467  (
468  const word& name,
469  const multiValveEngine& engine,
470  const dictionary& dict
471  );
472 
473  //- Dummy clone function for PtrList
475  {
477  return autoPtr<valveObject>(nullptr);
478  }
479 
480 
481  // Member Functions
482 
483  // Valve position and velocity
484 
485  //- Return valve position for the given time
486  scalar lift(const scalar theta) const;
487 
488  //- Return current valve position
489  scalar lift() const;
490 
491  //- Return current valve speed
492  scalar speed() const;
493 
494  //- Return valve displacement for current time-step
495  scalar displacement() const;
496 
497  //- Is the valve open?
498  bool isOpen() const;
499 
500 
501  //- update points due to valve motion
502  void updatePoints(pointField&);
503  };
504 
505 
506  class valveList
507  :
508  public PtrList<valveObject>
509  {
510  public:
511 
512  // Constructors
513 
514  //- Construct from Istream
515  valveList
516  (
517  const multiValveEngine& engine,
518  const dictionary& dict
519  );
520  };
521 
522 
523  friend class movingObject;
524  friend class pistonObject;
525  friend class valveObject;
526 
527 
528 private:
529 
530  // Private member data
531 
532  //- User-defined liner patches
533  labelHashSet linerPatchSet_;
534 
535  //- User-defined patches which the mesh can slide along
536  labelHashSet slidingPatchSet_;
537 
538  //- Piston object
539  pistonObject piston_;
540 
541  //- Container for all valves
542  valveList valves_;
543 
544  //- Static patch set
545  labelHashSet staticPatchSet_;
546 
547  wordReList frozenPointZones_;
548 
549 
550  // Private member functions
551 
552  //- Lookup and return the liner patch set
553  labelHashSet findLinerPatchSet() const;
554 
555  //- Lookup and return the sliding patch set
556  labelHashSet findSlidingPatchSet();
557 
558  //- Find and return the static patch set
559  labelHashSet findStaticPatchSet();
560 
561 
562 public:
563 
564  //- Runtime type information
565  TypeName("multiValveEngine");
566 
567  //- Name of the cylinder head pointZone
568  static word cylinderHeadName;
569 
570  // Constant access to member data
571 
572  //- User-defined liner patches
574 
575  //- User-defined patches which the mesh can slide along
577 
578  //- Piston object
579  const pistonObject& piston;
580 
581  //- Container for all valves
582  const valveList& valves;
583 
584  //- Static patch set
586 
587 
588  // Constructors
589 
590  //- Construct from fvMesh
592 
593  //- Disallow default bitwise copy construction
594  multiValveEngine(const multiValveEngine&) = delete;
595 
596 
597  //- Destructor
599 
600 
601  // Member Functions
602 
603  //- Return current user-time, CAD, s or ...
604  scalar userTime() const;
605 
606  //- Return current user-time-step, CAD, s, ...
607  scalar userDeltaT() const;
608 
609  //- Update the mesh for both mesh motion and topology change
610  virtual bool update();
611 
612  //- Update corresponding to the given map
613  virtual void topoChange(const polyTopoChangeMap&);
614 
615  //- Update from another mesh using the given map
616  virtual void mapMesh(const polyMeshMap&);
617 
618  //- Update corresponding to the given distribution map
619  virtual void distribute(const polyDistributionMap&);
620 
621 
622  // Member Operators
623 
624  //- Disallow default bitwise assignment
625  void operator=(const multiValveEngine&) = delete;
626 };
627 
628 
629 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
630 } // End namespace fvMeshMovers
631 } // End namespace Foam
632 
633 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
634 
635 #endif
636 
637 // ************************************************************************* //
A templated 1D list of pointers to objects of type <T>, where the size of the array is known and used...
Definition: PtrList.H:75
A simple wrapper around bool so that it can be read as a word: true/false, on/off,...
Definition: Switch.H:61
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: autoPtr.H:51
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:162
Abstract base class for fvMesh movers.
Definition: fvMeshMover.H:53
const dictionary & dict() const
Return the dynamicMeshDict/mover dict.
Definition: fvMeshMover.H:144
fvMesh & mesh()
Return the fvMesh.
Definition: fvMeshMover.H:132
labelList pointIDs_
Points to move when cell zone is supplied.
const multiValveEngine & meshMover_
Reference to engine mesh mover.
label executionCount_
Count of the scale_ field updates.
void calcScale(const pointMesh &pMesh, const scalarField &pDistMoving, const scalarField &pDistStatic, scalar dMoving, scalar dMax, scalar dStatic)
Scale the mesh point deformation with distance functions.
Definition: movingObject.C:34
void createStaticPatchSet()
Generate staticPatchSet_ based on patch entries.
Definition: movingObject.C:141
movingObject(const word &name, const multiValveEngine &engine, const dictionary &dict)
Construct from dictionary.
Definition: movingObject.C:275
pointScalarField scale_
Interpolation scale (1 at moving patches, 0 at far-field)
scalar position0_
Position at last scale update.
virtual void mapMesh(const polyMeshMap &)
Update from another mesh using the given map.
Definition: movingObject.C:337
autoPtr< Function1< scalar > > motion_
Piston motion function.
const labelHashSet & patchSet
Object patchSet.
void transformPoints(pointField &newPoints, const vector &translationVector)
Definition: movingObject.C:116
const scalar travelInterval_
Update the scale_ field when the travel exceeds travelInterval.
scalar movingFrozenLayerThickness_
Distance from object within mesh nodes move.
Switch cosine_
Switch to use cosine-based scaling.
scalar staticFrozenLayerThickness_
Distance from static wall patch at domain perimeter.
labelHashSet staticPatchSet_
Patches which must not deform during mesh motion.
scalar maxMotionDistance_
Distance from object beyond which the mesh does not deform.
pistonObject(const word &name, const multiValveEngine &engine, const dictionary &dict)
Construct from dictionary.
Definition: piston.C:95
static word pistonBowlName
Name of the piston bowl pointZone.
scalar position() const
Return the current piston position.
Definition: piston.C:119
scalar clearance() const
Return clearance estimate.
Definition: piston.C:141
scalar displacement() const
Return piston displacement for current time-step.
Definition: piston.C:126
virtual void mapMesh(const polyMeshMap &)
Update from another mesh using the given map.
Definition: piston.C:216
void updatePoints(pointField &)
update points due to piston motion
Definition: piston.C:158
scalar speed() const
Return piston position for current time-step.
Definition: piston.C:134
valveList(const multiValveEngine &engine, const dictionary &dict)
Construct from Istream.
Definition: valveList.C:31
bool isOpen() const
Is the valve open?
Definition: valve.C:54
valveObject(const word &name, const multiValveEngine &engine, const dictionary &dict)
Construct from dictionary.
Definition: valve.C:32
scalar displacement() const
Return valve displacement for current time-step.
Definition: valve.C:85
void updatePoints(pointField &)
update points due to valve motion
Definition: valve.C:94
autoPtr< valveObject > clone() const
Dummy clone function for PtrList.
scalar speed() const
Return current valve speed.
Definition: valve.C:70
scalar lift() const
Return current valve position.
Definition: valve.C:60
A mesh mover using explicit node translation based on scaled distance functions per moving object....
TypeName("multiValveEngine")
Runtime type information.
void operator=(const multiValveEngine &)=delete
Disallow default bitwise assignment.
scalar userTime() const
Return current user-time, CAD, s or ...
virtual void topoChange(const polyTopoChangeMap &)
Update corresponding to the given map.
const labelHashSet & staticPatchSet
Static patch set.
virtual void distribute(const polyDistributionMap &)
Update corresponding to the given distribution map.
const labelHashSet & linerPatchSet
User-defined liner patches.
const valveList & valves
Container for all valves.
const pistonObject & piston
Piston object.
virtual void mapMesh(const polyMeshMap &)
Update from another mesh using the given map.
static word cylinderHeadName
Name of the cylinder head pointZone.
virtual bool update()
Update the mesh for both mesh motion and topology change.
const labelHashSet & slidingPatchSet
User-defined patches which the mesh can slide along.
multiValveEngine(fvMesh &mesh)
Construct from fvMesh.
scalar userDeltaT() const
Return current user-time-step, CAD, s, ...
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:99
Calculates the distance to the specified sets of patch and pointZone points or for all points.
Definition: pointDist.H:54
Mesh representing a set of points created from polyMesh.
Definition: pointMesh.H:53
Class containing mesh-to-mesh mapping information after a mesh distribution where we send parts of me...
Class containing mesh-to-mesh mapping information.
Definition: polyMeshMap.H:51
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
A class for handling words, derived from string.
Definition: word.H:62
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
Definition: error.H:381
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