1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright held by original author
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
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 the
13 Free Software Foundation; either version 2 of the License, or (at your
14 option) any later version.
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
21 You should have received a copy of the GNU General Public License
22 along with OpenFOAM; if not, write to the Free Software Foundation,
23 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 \*---------------------------------------------------------------------------*/
27 #include "syringePressureFvPatchScalarField.H"
29 #include "addToRunTimeSelectionTable.H"
30 #include "fvPatchFieldMapper.H"
31 #include "surfaceFields.H"
33 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
38 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
40 syringePressureFvPatchScalarField::syringePressureFvPatchScalarField
43 const DimensionedField<scalar, volMesh>& iF
46 fixedValueFvPatchScalarField(p, iF),
51 syringePressureFvPatchScalarField::syringePressureFvPatchScalarField
53 const syringePressureFvPatchScalarField& sppsf,
55 const DimensionedField<scalar, volMesh>& iF,
56 const fvPatchFieldMapper& mapper
59 fixedValueFvPatchScalarField(sppsf, p, iF, mapper),
75 syringePressureFvPatchScalarField::syringePressureFvPatchScalarField
78 const DimensionedField<scalar, volMesh>& iF,
79 const dictionary& dict
82 fixedValueFvPatchScalarField(p, iF),
83 Ap_(readScalar(dict.lookup("Ap"))),
84 Sp_(readScalar(dict.lookup("Sp"))),
85 VsI_(readScalar(dict.lookup("VsI"))),
86 tas_(readScalar(dict.lookup("tas"))),
87 tae_(readScalar(dict.lookup("tae"))),
88 tds_(readScalar(dict.lookup("tds"))),
89 tde_(readScalar(dict.lookup("tde"))),
90 psI_(readScalar(dict.lookup("psI"))),
91 psi_(readScalar(dict.lookup("psi"))),
92 ams_(readScalar(dict.lookup("ams"))),
96 scalar ps = (psI_*VsI_ + ams_/psi_)/Vs(db().time().value());
97 fvPatchField<scalar>::operator=(ps);
101 syringePressureFvPatchScalarField::syringePressureFvPatchScalarField
103 const syringePressureFvPatchScalarField& sppsf,
104 const DimensionedField<scalar, volMesh>& iF
107 fixedValueFvPatchScalarField(sppsf, iF),
123 syringePressureFvPatchScalarField::syringePressureFvPatchScalarField
125 const syringePressureFvPatchScalarField& sppsf
128 fixedValueFvPatchScalarField(sppsf),
144 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
146 scalar syringePressureFvPatchScalarField::Vs(const scalar t) const
156 + 0.5*Ap_*Sp_*sqr(t - tas_)/(tae_ - tas_);
162 + 0.5*Ap_*Sp_*(tae_ - tas_)
163 + Ap_*Sp_*(t - tae_);
169 + 0.5*Ap_*Sp_*(tae_ - tas_)
170 + Ap_*Sp_*(tds_ - tae_)
172 - 0.5*Ap_*Sp_*sqr(t - tds_)/(tde_ - tds_);
178 + 0.5*Ap_*Sp_*(tae_ - tas_)
179 + Ap_*Sp_*(tds_ - tae_)
180 + 0.5*Ap_*Sp_*(tde_ - tds_);
185 void syringePressureFvPatchScalarField::updateCoeffs()
192 if (curTimeIndex_ != db().time().timeIndex())
195 curTimeIndex_ = db().time().timeIndex();
198 scalar t = db().time().value();
199 scalar deltaT = db().time().deltaT().value();
201 const surfaceScalarField& phi =
202 db().lookupObject<surfaceScalarField>("phi");
204 const fvsPatchField<scalar>& phip =
205 patch().patchField<surfaceScalarField, scalar>(phi);
207 if (phi.dimensions() == dimVelocity*dimArea)
209 ams_ = ams0_ + deltaT*sum((*this*psi_)*phip);
211 else if (phi.dimensions() == dimDensity*dimVelocity*dimArea)
213 ams_ = ams0_ + deltaT*sum(phip);
217 FatalErrorIn("syringePressureFvPatchScalarField::updateCoeffs()")
218 << "dimensions of phi are not correct"
219 << "\n on patch " << this->patch().name()
220 << " of field " << this->dimensionedInternalField().name()
221 << " in file " << this->dimensionedInternalField().objectPath()
225 scalar ps = (psI_*VsI_ + ams_/psi_)/Vs(t);
229 fixedValueFvPatchScalarField::updateCoeffs();
233 void syringePressureFvPatchScalarField::write(Ostream& os) const
235 fvPatchScalarField::write(os);
237 os.writeKeyword("Ap") << Ap_ << token::END_STATEMENT << nl;
238 os.writeKeyword("Sp") << Sp_ << token::END_STATEMENT << nl;
239 os.writeKeyword("VsI") << VsI_ << token::END_STATEMENT << nl;
240 os.writeKeyword("tas") << tas_ << token::END_STATEMENT << nl;
241 os.writeKeyword("tae") << tae_ << token::END_STATEMENT << nl;
242 os.writeKeyword("tds") << tds_ << token::END_STATEMENT << nl;
243 os.writeKeyword("tde") << tde_ << token::END_STATEMENT << nl;
244 os.writeKeyword("psI") << psI_ << token::END_STATEMENT << nl;
245 os.writeKeyword("psi") << psi_ << token::END_STATEMENT << nl;
246 os.writeKeyword("ams") << ams_ << token::END_STATEMENT << nl;
248 writeEntry("value", os);
252 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
257 syringePressureFvPatchScalarField
260 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
262 } // End namespace Foam
264 // ************************************************************************* //