1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
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
13 the Free Software Foundation, either version 3 of the License, or
14 (at your 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, see <http://www.gnu.org/licenses/>.
24 \*---------------------------------------------------------------------------*/
26 #include "syringePressureFvPatchScalarField.H"
28 #include "addToRunTimeSelectionTable.H"
29 #include "fvPatchFieldMapper.H"
30 #include "surfaceFields.H"
32 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
34 Foam::syringePressureFvPatchScalarField::syringePressureFvPatchScalarField
37 const DimensionedField<scalar, volMesh>& iF
40 fixedValueFvPatchScalarField(p, iF),
45 Foam::syringePressureFvPatchScalarField::syringePressureFvPatchScalarField
47 const syringePressureFvPatchScalarField& sppsf,
49 const DimensionedField<scalar, volMesh>& iF,
50 const fvPatchFieldMapper& mapper
53 fixedValueFvPatchScalarField(sppsf, p, iF, mapper),
69 Foam::syringePressureFvPatchScalarField::syringePressureFvPatchScalarField
72 const DimensionedField<scalar, volMesh>& iF,
73 const dictionary& dict
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"))),
90 scalar ps = (psI_*VsI_ + ams_/psi_)/Vs(db().time().value());
91 fvPatchField<scalar>::operator=(ps);
95 Foam::syringePressureFvPatchScalarField::syringePressureFvPatchScalarField
97 const syringePressureFvPatchScalarField& sppsf,
98 const DimensionedField<scalar, volMesh>& iF
101 fixedValueFvPatchScalarField(sppsf, iF),
117 Foam::syringePressureFvPatchScalarField::syringePressureFvPatchScalarField
119 const syringePressureFvPatchScalarField& sppsf
122 fixedValueFvPatchScalarField(sppsf),
138 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
140 Foam::scalar Foam::syringePressureFvPatchScalarField::Vs(const scalar t) const
150 + 0.5*Ap_*Sp_*sqr(t - tas_)/(tae_ - tas_);
156 + 0.5*Ap_*Sp_*(tae_ - tas_)
157 + Ap_*Sp_*(t - tae_);
163 + 0.5*Ap_*Sp_*(tae_ - tas_)
164 + Ap_*Sp_*(tds_ - tae_)
166 - 0.5*Ap_*Sp_*sqr(t - tds_)/(tde_ - tds_);
172 + 0.5*Ap_*Sp_*(tae_ - tas_)
173 + Ap_*Sp_*(tds_ - tae_)
174 + 0.5*Ap_*Sp_*(tde_ - tds_);
179 void Foam::syringePressureFvPatchScalarField::updateCoeffs()
186 if (curTimeIndex_ != db().time().timeIndex())
189 curTimeIndex_ = db().time().timeIndex();
192 scalar t = db().time().value();
193 scalar deltaT = db().time().deltaTValue();
195 const surfaceScalarField& phi =
196 db().lookupObject<surfaceScalarField>("phi");
198 const fvsPatchField<scalar>& phip =
199 patch().patchField<surfaceScalarField, scalar>(phi);
201 if (phi.dimensions() == dimVelocity*dimArea)
203 ams_ = ams0_ + deltaT*sum((*this*psi_)*phip);
205 else if (phi.dimensions() == dimDensity*dimVelocity*dimArea)
207 ams_ = ams0_ + deltaT*sum(phip);
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()
219 scalar ps = (psI_*VsI_ + ams_/psi_)/Vs(t);
223 fixedValueFvPatchScalarField::updateCoeffs();
227 void Foam::syringePressureFvPatchScalarField::write(Ostream& os) const
229 fvPatchScalarField::write(os);
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;
242 writeEntry("value", os);
246 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
253 syringePressureFvPatchScalarField
257 // ************************************************************************* //