1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | foam-extend: Open Source CFD
4 \\ / O peration | Version: 3.2
5 \\ / A nd | Web: http://www.foam-extend.org
6 \\/ M anipulation | For copyright notice see file Copyright
7 -------------------------------------------------------------------------------
9 This file is part of foam-extend.
11 foam-extend 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 3 of the License, or (at your
14 option) any later version.
16 foam-extend is distributed in the hope that it will be useful, but
17 WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with foam-extend. If not, see <http://www.gnu.org/licenses/>.
24 \*---------------------------------------------------------------------------*/
26 #include "fvPatchFields.H"
27 #include "syringePressureFvPatchScalarField.H"
28 #include "addToRunTimeSelectionTable.H"
30 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
35 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
37 syringePressureFvPatchScalarField::syringePressureFvPatchScalarField
40 const DimensionedField<scalar, volMesh>& iF
43 fixedValueFvPatchScalarField(p, iF),
48 syringePressureFvPatchScalarField::syringePressureFvPatchScalarField
50 const syringePressureFvPatchScalarField& sppsf,
52 const DimensionedField<scalar, volMesh>& iF,
53 const fvPatchFieldMapper& mapper
56 fixedValueFvPatchScalarField(sppsf, p, iF, mapper),
72 syringePressureFvPatchScalarField::syringePressureFvPatchScalarField
75 const DimensionedField<scalar, volMesh>& iF,
76 const dictionary& dict
79 fixedValueFvPatchScalarField(p, iF),
80 Ap_(readScalar(dict.lookup("Ap"))),
81 Sp_(readScalar(dict.lookup("Sp"))),
82 VsI_(readScalar(dict.lookup("VsI"))),
83 tas_(readScalar(dict.lookup("tas"))),
84 tae_(readScalar(dict.lookup("tae"))),
85 tds_(readScalar(dict.lookup("tds"))),
86 tde_(readScalar(dict.lookup("tde"))),
87 psI_(readScalar(dict.lookup("psI"))),
88 psi_(readScalar(dict.lookup("psi"))),
89 ams_(readScalar(dict.lookup("ams"))),
93 scalar ps = (psI_*VsI_ + ams_/psi_)/Vs(db().time().value());
94 fvPatchField<scalar>::operator=(ps);
98 syringePressureFvPatchScalarField::syringePressureFvPatchScalarField
100 const syringePressureFvPatchScalarField& sppsf,
101 const DimensionedField<scalar, volMesh>& iF
104 fixedValueFvPatchScalarField(sppsf, iF),
120 syringePressureFvPatchScalarField::syringePressureFvPatchScalarField
122 const syringePressureFvPatchScalarField& sppsf
125 fixedValueFvPatchScalarField(sppsf),
141 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
143 scalar syringePressureFvPatchScalarField::Vs(const scalar t) const
153 + 0.5*Ap_*Sp_*sqr(t - tas_)/(tae_ - tas_);
159 + 0.5*Ap_*Sp_*(tae_ - tas_)
160 + Ap_*Sp_*(t - tae_);
166 + 0.5*Ap_*Sp_*(tae_ - tas_)
167 + Ap_*Sp_*(tds_ - tae_)
169 - 0.5*Ap_*Sp_*sqr(t - tds_)/(tde_ - tds_);
175 + 0.5*Ap_*Sp_*(tae_ - tas_)
176 + Ap_*Sp_*(tds_ - tae_)
177 + 0.5*Ap_*Sp_*(tde_ - tds_);
182 void syringePressureFvPatchScalarField::updateCoeffs()
189 if (curTimeIndex_ != db().time().timeIndex())
192 curTimeIndex_ = db().time().timeIndex();
195 scalar t = db().time().value();
196 scalar deltaT = db().time().deltaT().value();
198 const surfaceScalarField& phi =
199 db().lookupObject<surfaceScalarField>("phi");
201 const fvsPatchField<scalar>& phip =
202 patch().patchField<surfaceScalarField, scalar>(phi);
204 if (phi.dimensions() == dimVelocity*dimArea)
206 ams_ = ams0_ + deltaT*sum((*this*psi_)*phip);
208 else if (phi.dimensions() == dimDensity*dimVelocity*dimArea)
210 ams_ = ams0_ + deltaT*sum(phip);
214 FatalErrorIn("syringePressureFvPatchScalarField::updateCoeffs()")
215 << "dimensions of phi are not correct"
216 << "\n on patch " << this->patch().name()
217 << " of field " << this->dimensionedInternalField().name()
218 << " in file " << this->dimensionedInternalField().objectPath()
222 scalar ps = (psI_*VsI_ + ams_/psi_)/Vs(t);
226 fixedValueFvPatchScalarField::updateCoeffs();
230 void syringePressureFvPatchScalarField::write(Ostream& os) const
232 fvPatchScalarField::write(os);
234 os.writeKeyword("Ap") << Ap_ << token::END_STATEMENT << nl;
235 os.writeKeyword("Sp") << Sp_ << token::END_STATEMENT << nl;
236 os.writeKeyword("VsI") << VsI_ << token::END_STATEMENT << nl;
237 os.writeKeyword("tas") << tas_ << token::END_STATEMENT << nl;
238 os.writeKeyword("tae") << tae_ << token::END_STATEMENT << nl;
239 os.writeKeyword("tds") << tds_ << token::END_STATEMENT << nl;
240 os.writeKeyword("tde") << tde_ << token::END_STATEMENT << nl;
241 os.writeKeyword("psI") << psI_ << token::END_STATEMENT << nl;
242 os.writeKeyword("psi") << psi_ << token::END_STATEMENT << nl;
243 os.writeKeyword("ams") << ams_ << token::END_STATEMENT << nl;
245 writeEntry("value", os);
249 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
254 syringePressureFvPatchScalarField
257 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
259 } // End namespace Foam
261 // ************************************************************************* //