syringePressureFvPatchScalarField.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | Copyright (C) 2011 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 "volMesh.H"
29 #include "fvPatchFieldMapper.H"
30 #include "surfaceFields.H"
31 
32 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
33 
35 (
36  const fvPatch& p,
38 )
39 :
40  fixedValueFvPatchScalarField(p, iF),
41  curTimeIndex_(-1)
42 {}
43 
44 
45 Foam::syringePressureFvPatchScalarField::syringePressureFvPatchScalarField
46 (
48  const fvPatch& p,
50  const fvPatchFieldMapper& mapper
51 )
52 :
53  fixedValueFvPatchScalarField(sppsf, p, iF, mapper),
54  Ap_(sppsf.Ap_),
55  Sp_(sppsf.Sp_),
56  VsI_(sppsf.VsI_),
57  tas_(sppsf.tas_),
58  tae_(sppsf.tae_),
59  tds_(sppsf.tds_),
60  tde_(sppsf.tde_),
61  psI_(sppsf.psI_),
62  psi_(sppsf.psi_),
63  ams_(sppsf.ams_),
64  ams0_(sppsf.ams0_),
65  curTimeIndex_(-1)
66 {}
67 
68 
69 Foam::syringePressureFvPatchScalarField::syringePressureFvPatchScalarField
70 (
71  const fvPatch& p,
73  const dictionary& dict
74 )
75 :
76  fixedValueFvPatchScalarField(p, iF),
77  Ap_(readScalar(dict.lookup("Ap"))),
78  Sp_(readScalar(dict.lookup("Sp"))),
79  VsI_(readScalar(dict.lookup("VsI"))),
80  tas_(readScalar(dict.lookup("tas"))),
81  tae_(readScalar(dict.lookup("tae"))),
82  tds_(readScalar(dict.lookup("tds"))),
83  tde_(readScalar(dict.lookup("tde"))),
84  psI_(readScalar(dict.lookup("psI"))),
85  psi_(readScalar(dict.lookup("psi"))),
86  ams_(readScalar(dict.lookup("ams"))),
87  ams0_(ams_),
88  curTimeIndex_(-1)
89 {
90  scalar ps = (psI_*VsI_ + ams_/psi_)/Vs(db().time().value());
92 }
93 
94 
95 Foam::syringePressureFvPatchScalarField::syringePressureFvPatchScalarField
96 (
99 )
100 :
101  fixedValueFvPatchScalarField(sppsf, iF),
102  Ap_(sppsf.Ap_),
103  Sp_(sppsf.Sp_),
104  VsI_(sppsf.VsI_),
105  tas_(sppsf.tas_),
106  tae_(sppsf.tae_),
107  tds_(sppsf.tds_),
108  tde_(sppsf.tde_),
109  psI_(sppsf.psI_),
110  psi_(sppsf.psi_),
111  ams_(sppsf.ams_),
112  ams0_(sppsf.ams0_),
113  curTimeIndex_(-1)
114 {}
115 
116 
117 Foam::syringePressureFvPatchScalarField::syringePressureFvPatchScalarField
118 (
120 )
121 :
122  fixedValueFvPatchScalarField(sppsf),
123  Ap_(sppsf.Ap_),
124  Sp_(sppsf.Sp_),
125  VsI_(sppsf.VsI_),
126  tas_(sppsf.tas_),
127  tae_(sppsf.tae_),
128  tds_(sppsf.tds_),
129  tde_(sppsf.tde_),
130  psI_(sppsf.psI_),
131  psi_(sppsf.psi_),
132  ams_(sppsf.ams_),
133  ams0_(sppsf.ams0_),
134  curTimeIndex_(-1)
135 {}
136 
137 
138 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
139 
140 Foam::scalar Foam::syringePressureFvPatchScalarField::Vs(const scalar t) const
141 {
142  if (t < tas_)
143  {
144  return VsI_;
145  }
146  else if (t < tae_)
147  {
148  return
149  VsI_
150  + 0.5*Ap_*Sp_*sqr(t - tas_)/(tae_ - tas_);
151  }
152  else if (t < tds_)
153  {
154  return
155  VsI_
156  + 0.5*Ap_*Sp_*(tae_ - tas_)
157  + Ap_*Sp_*(t - tae_);
158  }
159  else if (t < tde_)
160  {
161  return
162  VsI_
163  + 0.5*Ap_*Sp_*(tae_ - tas_)
164  + Ap_*Sp_*(tds_ - tae_)
165  + Ap_*Sp_*(t - tds_)
166  - 0.5*Ap_*Sp_*sqr(t - tds_)/(tde_ - tds_);
167  }
168  else
169  {
170  return
171  VsI_
172  + 0.5*Ap_*Sp_*(tae_ - tas_)
173  + Ap_*Sp_*(tds_ - tae_)
174  + 0.5*Ap_*Sp_*(tde_ - tds_);
175  }
176 }
177 
178 
180 {
181  if (updated())
182  {
183  return;
184  }
185 
186  if (curTimeIndex_ != db().time().timeIndex())
187  {
188  ams0_ = ams_;
189  curTimeIndex_ = db().time().timeIndex();
190  }
191 
192  scalar t = db().time().value();
193  scalar deltaT = db().time().deltaTValue();
194 
195  const surfaceScalarField& phi =
196  db().lookupObject<surfaceScalarField>("phi");
197 
198  const fvsPatchField<scalar>& phip =
199  patch().patchField<surfaceScalarField, scalar>(phi);
200 
201  if (phi.dimensions() == dimVelocity*dimArea)
202  {
203  ams_ = ams0_ + deltaT*sum((*this*psi_)*phip);
204  }
205  else if (phi.dimensions() == dimDensity*dimVelocity*dimArea)
206  {
207  ams_ = ams0_ + deltaT*sum(phip);
208  }
209  else
210  {
211  FatalErrorIn("syringePressureFvPatchScalarField::updateCoeffs()")
212  << "dimensions of phi are not correct"
213  << "\n on patch " << this->patch().name()
214  << " of field " << this->dimensionedInternalField().name()
215  << " in file " << this->dimensionedInternalField().objectPath()
216  << exit(FatalError);
217  }
218 
219  scalar ps = (psI_*VsI_ + ams_/psi_)/Vs(t);
220 
221  operator==(ps);
222 
223  fixedValueFvPatchScalarField::updateCoeffs();
224 }
225 
226 
228 {
230 
231  os.writeKeyword("Ap") << Ap_ << token::END_STATEMENT << nl;
232  os.writeKeyword("Sp") << Sp_ << token::END_STATEMENT << nl;
233  os.writeKeyword("VsI") << VsI_ << token::END_STATEMENT << nl;
234  os.writeKeyword("tas") << tas_ << token::END_STATEMENT << nl;
235  os.writeKeyword("tae") << tae_ << token::END_STATEMENT << nl;
236  os.writeKeyword("tds") << tds_ << token::END_STATEMENT << nl;
237  os.writeKeyword("tde") << tde_ << token::END_STATEMENT << nl;
238  os.writeKeyword("psI") << psI_ << token::END_STATEMENT << nl;
239  os.writeKeyword("psi") << psi_ << token::END_STATEMENT << nl;
240  os.writeKeyword("ams") << ams_ << token::END_STATEMENT << nl;
241 
242  writeEntry("value", os);
243 }
244 
245 
246 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
247 
248 namespace Foam
249 {
251  (
254  );
255 }
256 
257 // ************************************************************************* //