multiValveEngineValveMotion.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-2026 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 
27 #include "multiValveEngine.H"
29 
30 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
31 
32 namespace Foam
33 {
34 namespace solidBodyMotionFunctions
35 {
38  (
42  );
43 }
44 }
45 
46 
47 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
48 
51 (
52  const word& name,
53  const dictionary& SBMFCoeffs,
54  const Time& runTime
55 )
56 :
57  solidBodyMotionFunction(name, SBMFCoeffs, runTime),
58  fluidRegionName_(),
59  valveName_(),
60  valveIndex_(-1)
61 {
62  read(SBMFCoeffs);
63 }
64 
65 
66 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
67 
70 {}
71 
72 
73 // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
74 
77 transformation() const
78 {
79  const fvMesh& fluidMesh = time_.lookupObject<fvMesh>(fluidRegionName_);
80 
81  const fvMeshMover& fluidMover = fluidMesh.mover();
82 
83  if (!isA<fvMeshMovers::multiValveEngine>(fluidMover))
84  {
86  << "The " << typeName << " motion function requires the motion"
87  << " solver for the associated fluid region (i.e., "
88  << fluidRegionName_ << ") to be of type "
90  << exit(FatalError);
91  }
92 
93  const fvMeshMovers::multiValveEngine& fluidEngineMover =
94  refCast<const fvMeshMovers::multiValveEngine>(fluidMover);
95 
96  if (valveIndex_ == -1)
97  {
98  forAll(fluidEngineMover.valves, valvei)
99  {
100  if (fluidEngineMover.valves[valvei].name == valveName_)
101  {
102  valveIndex_ = valvei;
103  break;
104  }
105  }
106  }
107 
108  if (valveIndex_ == -1)
109  {
110  wordList valveNames(fluidEngineMover.valves.size());
111  forAll(fluidEngineMover.valves, valvei)
112  {
113  valveNames[valvei] = fluidEngineMover.valves[valvei].name;
114  }
115 
117  << "A valve named '" << valveName_ << "' was not found in the "
118  << fvMeshMovers::multiValveEngine::typeName << " mover for region "
119  << fluidRegionName_ << nl << nl
120  << "Valid valve names are:" << nl << valveNames
121  << exit(FatalError);
122  }
123 
124  return
125  septernion
126  (
127  fluidEngineMover.valves[valveIndex_].isOpen()
128  ? fluidEngineMover.valves[valveIndex_].lift()
129  *fluidEngineMover.valves[valveIndex_].axis
130  : vector::zero
131  );
132 }
133 
134 
136 (
137  const dictionary& SBMFCoeffs
138 )
139 {
140  solidBodyMotionFunction::read(SBMFCoeffs);
141 
142  fluidRegionName_ = SBMFCoeffs.lookup<word>("fluidRegion");
143 
144  valveName_ = SBMFCoeffs.lookup<word>("valve");
145 
146  valveIndex_ = -1;
147 
148  return true;
149 }
150 
151 
152 // ************************************************************************* //
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:449
Macros for easy insertion into run-time selection tables.
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:76
label size() const
Return the number of elements in the UPtrList.
Definition: UPtrListI.H:29
static const Form zero
Definition: VectorSpace.H:118
A list of keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
Definition: dictionary.H:162
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
Definition: dictionary.C:669
Abstract base class for fvMesh movers.
Definition: fvMeshMover.H:53
A mesh mover using explicit node translation based on scaled distance functions per moving object....
const valveList & valves
Container for all valves.
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:98
const fvMeshMover & mover() const
Return the mover function class.
Definition: fvMesh.C:1125
const Type & lookupObject(const word &name) const
Lookup and return the object of the given Type and name.
Septernion class used to perform translations and rotations in 3D space.
Definition: septernion.H:66
Base class for defining solid-body motions.
virtual bool read(const dictionary &dict)=0
Update properties from given dictionary.
Motion function for solid regions representing a valve. Looks up the multiValveEngine mover from the ...
multiValveEngineValveMotion(const word &name, const dictionary &SBMFCoeffs, const Time &runTime)
Construct from components.
virtual septernion transformation() const
Return the solid-body motion transformation septernion.
virtual bool read(const dictionary &SBMFCoeffs)
Update properties from given dictionary.
Template function which returns the un-mangled name of a given type. Useful for types which do not ha...
A class for handling words, derived from string.
Definition: word.H:63
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:334
addToRunTimeSelectionTable(solidBodyMotionFunction, multiValveEnginePistonMotion, dictionary)
defineTypeNameAndDebug(multiValveEnginePistonMotion, 0)
Namespace for OpenFOAM.
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
String typeName(const std::type_info &info)
Return the un-mangled name given the standard type info.
word name(const LagrangianState state)
Return a string representation of a Lagrangian state enumeration.
error FatalError
static const char nl
Definition: Ostream.H:297