syringePressureFvPatchScalarField.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) 2011-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 "fieldMapper.H"
28 #include "surfaceFields.H"
30 
31 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
32 
34 (
35  const fvPatch& p,
37  const dictionary& dict
38 )
39 :
40  fixedValueFvPatchScalarField(p, iF, dict, false),
41  Ap_(dict.lookup<scalar>("Ap")),
42  Sp_(dict.lookup<scalar>("Sp")),
43  VsI_(dict.lookup<scalar>("VsI")),
44  tas_(dict.lookup<scalar>("tas")),
45  tae_(dict.lookup<scalar>("tae")),
46  tds_(dict.lookup<scalar>("tds")),
47  tde_(dict.lookup<scalar>("tde")),
48  psI_(dict.lookup<scalar>("psI")),
49  psi_(dict.lookup<scalar>("psi")),
50  ams_(dict.lookup<scalar>("ams")),
51  ams0_(ams_),
52  phiName_(dict.lookupOrDefault<word>("phi", "phi")),
53  curTimeIndex_(-1)
54 {
55  scalar ps = (psI_*VsI_ + ams_/psi_)/Vs(time().value());
57 }
58 
59 
61 (
63  const fvPatch& p,
65  const fieldMapper& mapper
66 )
67 :
68  fixedValueFvPatchScalarField(sppsf, p, iF, mapper),
69  Ap_(sppsf.Ap_),
70  Sp_(sppsf.Sp_),
71  VsI_(sppsf.VsI_),
72  tas_(sppsf.tas_),
73  tae_(sppsf.tae_),
74  tds_(sppsf.tds_),
75  tde_(sppsf.tde_),
76  psI_(sppsf.psI_),
77  psi_(sppsf.psi_),
78  ams_(sppsf.ams_),
79  ams0_(sppsf.ams0_),
80  phiName_(sppsf.phiName_),
81  curTimeIndex_(-1)
82 {}
83 
84 
86 (
89 )
90 :
91  fixedValueFvPatchScalarField(sppsf, iF),
92  Ap_(sppsf.Ap_),
93  Sp_(sppsf.Sp_),
94  VsI_(sppsf.VsI_),
95  tas_(sppsf.tas_),
96  tae_(sppsf.tae_),
97  tds_(sppsf.tds_),
98  tde_(sppsf.tde_),
99  psI_(sppsf.psI_),
100  psi_(sppsf.psi_),
101  ams_(sppsf.ams_),
102  ams0_(sppsf.ams0_),
103  phiName_(sppsf.phiName_),
104  curTimeIndex_(-1)
105 {}
106 
107 
108 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
109 
110 Foam::scalar Foam::syringePressureFvPatchScalarField::Vs(const scalar t) const
111 {
112  if (t < tas_)
113  {
114  return VsI_;
115  }
116  else if (t < tae_)
117  {
118  return
119  VsI_
120  + 0.5*Ap_*Sp_*sqr(t - tas_)/(tae_ - tas_);
121  }
122  else if (t < tds_)
123  {
124  return
125  VsI_
126  + 0.5*Ap_*Sp_*(tae_ - tas_)
127  + Ap_*Sp_*(t - tae_);
128  }
129  else if (t < tde_)
130  {
131  return
132  VsI_
133  + 0.5*Ap_*Sp_*(tae_ - tas_)
134  + Ap_*Sp_*(tds_ - tae_)
135  + Ap_*Sp_*(t - tds_)
136  - 0.5*Ap_*Sp_*sqr(t - tds_)/(tde_ - tds_);
137  }
138  else
139  {
140  return
141  VsI_
142  + 0.5*Ap_*Sp_*(tae_ - tas_)
143  + Ap_*Sp_*(tds_ - tae_)
144  + 0.5*Ap_*Sp_*(tde_ - tds_);
145  }
146 }
147 
148 
150 {
151  if (updated())
152  {
153  return;
154  }
155 
156  if (curTimeIndex_ != time().timeIndex())
157  {
158  ams0_ = ams_;
159  curTimeIndex_ = time().timeIndex();
160  }
161 
162  scalar t = time().value();
163  scalar deltaT = time().deltaTValue();
164 
165  const surfaceScalarField& phi =
166  db().lookupObject<surfaceScalarField>(phiName_);
167 
168  const fvsPatchField<scalar>& phip =
169  patch().patchField<surfaceScalarField, scalar>(phi);
170 
171  if (phi.dimensions() == dimVolumetricFlux)
172  {
173  ams_ = ams0_ + deltaT*sum((*this*psi_)*phip);
174  }
175  else if (phi.dimensions() == dimMassFlux)
176  {
177  ams_ = ams0_ + deltaT*sum(phip);
178  }
179  else
180  {
182  << "dimensions of phi are not correct"
183  << "\n on patch " << this->patch().name()
184  << " of field " << this->internalField().name()
185  << " in file " << this->internalField().objectPath()
186  << exit(FatalError);
187  }
188 
189  scalar ps = (psI_*VsI_ + ams_/psi_)/Vs(t);
190 
191  operator==(ps);
192 
193  fixedValueFvPatchScalarField::updateCoeffs();
194 }
195 
196 
198 {
200 
201  writeEntry(os, "Ap", Ap_);
202  writeEntry(os, "Sp", Sp_);
203  writeEntry(os, "VsI", VsI_);
204  writeEntry(os, "tas", tas_);
205  writeEntry(os, "tae", tae_);
206  writeEntry(os, "tds", tds_);
207  writeEntry(os, "tde", tde_);
208  writeEntry(os, "psI", psI_);
209  writeEntry(os, "psi", psi_);
210  writeEntry(os, "ams", ams_);
211  writeEntryIfDifferent<word>(os, "phi", "phi", phiName_);
212 
213  writeEntry(os, "value", *this);
214 }
215 
216 
217 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
218 
219 namespace Foam
220 {
222  (
225  );
226 }
227 
228 // ************************************************************************* //
Macros for easy insertion into run-time selection tables.
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
const dimensionSet & dimensions() const
Return dimensions.
Generic GeometricField class.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:57
A list of keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
Definition: dictionary.H:162
Abstract base class for field mapping.
Definition: fieldMapper.H:48
Abstract base class with a fat-interface to all derived classes covering all possible ways in which t...
Definition: fvPatchField.H:90
virtual void write(Ostream &) const
Write.
Definition: fvPatchField.C:235
virtual void operator=(const UList< Type > &)
Definition: fvPatchField.C:255
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:58
An abstract base class with a fat-interface to all derived classes covering all possible ways in whic...
Definition: fvsPatchField.H:86
This boundary condition provides a pressure condition, obtained from a zero-D model of the cylinder o...
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
syringePressureFvPatchScalarField(const fvPatch &, const DimensionedField< scalar, fvMesh > &, const dictionary &)
Construct from patch, internal field and dictionary.
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
const dimensionSet time
const unitSet & lookup(const word &unitName)
Lookup and return the named unit from the table.
Definition: units.C:346
Namespace for OpenFOAM.
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
tmp< fvMatrix< Type > > operator==(const fvMatrix< Type > &, const fvMatrix< Type > &)
const dimensionSet & dimMassFlux
Definition: dimensions.C:179
makePatchTypeField(fvPatchScalarField, atmosphericBoundaryLayerTurbulentEpsilonFvPatchScalarField)
SurfaceField< scalar > surfaceScalarField
tmp< DimensionedField< typename outerProduct< Type, Type >::type, GeoMesh, Field >> sqr(const DimensionedField< Type, GeoMesh, PrimitiveField > &df)
dimensioned< Type > sum(const DimensionedField< Type, GeoMesh, PrimitiveField > &df)
error FatalError
void writeEntry(Ostream &os, const word &key, const DimensionedFieldFunction< DimensionedFieldType > &f)
const dimensionSet & dimVolumetricFlux
Definition: dimensions.C:178
label timeIndex
Definition: getTimeIndex.H:4
dictionary dict
volScalarField & p
Foam::surfaceFields.