valve.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) 2024-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 "multiValveEngine.H"
27 #include "pointDist.H"
28 
29 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
30 
32 (
33  const word& name,
34  const multiValveEngine& engine,
35  const dictionary& dict
36 )
37 :
38  movingObject(name, engine, dict),
39  minLift_(dict.lookup<scalar>("minLift", dimLength))
40 {}
41 
42 
43 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
44 
46 (
47  const scalar theta
48 ) const
49 {
50  return motion_->value(theta);
51 }
52 
53 
55 {
56  return lift(meshMover_.userTime()) >= minLift_;
57 }
58 
59 
61 {
62  return max
63  (
64  lift(meshMover_.userTime()),
65  minLift_
66  );
67 }
68 
69 
71 {
72  return
73  -(
74  lift()
75  - max
76  (
77  lift(meshMover_.userTime() - meshMover_.userDeltaT()),
78  minLift_
79  )
80  )/(meshMover_.mesh().time().deltaTValue() + vSmall);
81 }
82 
83 
84 Foam::scalar
86 {
87  return
88  lift(meshMover_.userTime() - meshMover_.userDeltaT())
89  - lift(meshMover_.userTime());
90 }
91 
92 
94 (
95  pointField& newPoints
96 )
97 {
98  // Update points only if valve is moving
99  if (isOpen())
100  {
101  const scalar position = this->lift();
102 
103  // Update a cached scale_ field if needed
104  if
105  (
106  executionCount_ == 0
107  || mag(position - position0_) > travelInterval_
108  )
109  {
110  const pointMesh& pMesh = pointMesh::New(meshMover_.mesh());
111  const pointField& points(meshMover_.mesh().points());
112 
113  const pointDist pDistMoving
114  (
115  pMesh,
116  patchSet,
117  movingPointZones(),
118  staticPatchSet_,
119  staticPointZones(),
120  points,
121  maxMotionDistance_
122  );
123 
124  const pointDist pDistStatic
125  (
126  pMesh,
127  staticPatchSet_,
128  staticPointZones(),
129  patchSet,
130  movingPointZones(),
131  points,
132  maxMotionDistance_
133  );
134 
135  calcScale
136  (
137  pMesh,
138  pDistMoving,
139  pDistStatic,
140  movingFrozenLayerThickness_,
141  maxMotionDistance_,
142  staticFrozenLayerThickness_
143  );
144 
145  position0_ = position;
146  }
147 
148  const vector translationVector(displacement()*axis);
149  transformPoints(newPoints, translationVector);
150  }
151 }
152 
153 
154 // ************************************************************************* //
static pointMesh & New(const word &name, const polyMesh &mesh)
Construct and return the named DemandDrivenMeshObject.
A list of keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
Definition: dictionary.H:162
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
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....
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:52
A class for handling words, derived from string.
Definition: word.H:63
const pointField & points
point position(const polyMesh &mesh, const barycentric &coordinates, const label celli, const label facei, const label faceTrii, const scalar stepFraction)
Return the position given the coordinates and tet topology.
Definition: trackingI.H:224
const unitSet & lookup(const word &unitName)
Lookup and return the named unit from the table.
Definition: units.C:346
void transformPoints(vectorField &, const spatialTransform &, const vectorField &)
Transform given vectorField of coordinates with the given spatialTransform.
const dimensionSet & dimLength
Definition: dimensions.C:141
word name(const LagrangianState state)
Return a string representation of a Lagrangian state enumeration.
tmp< DimensionedField< scalar, GeoMesh, Field > > mag(const DimensionedField< Type, GeoMesh, PrimitiveField > &df)
dimensioned< Type > max(const DimensionedField< Type, GeoMesh, PrimitiveField > &df)
dictionary dict