OpenFOAM logo
The Open Source CFD Toolbox
  Source Guide OpenCFD Solutions Contact OpenFOAM

syringePressureFvPatchScalarField.C

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002   =========                 |
00003   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
00004    \\    /   O peration     |
00005     \\  /    A nd           | Copyright (C) 1991-2009 OpenCFD Ltd.
00006      \\/     M anipulation  |
00007 -------------------------------------------------------------------------------
00008 License
00009     This file is part of OpenFOAM.
00010 
00011     OpenFOAM is free software; you can redistribute it and/or modify it
00012     under the terms of the GNU General Public License as published by the
00013     Free Software Foundation; either version 2 of the License, or (at your
00014     option) any later version.
00015 
00016     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
00017     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00019     for more details.
00020 
00021     You should have received a copy of the GNU General Public License
00022     along with OpenFOAM; if not, write to the Free Software Foundation,
00023     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
00024 
00025 \*---------------------------------------------------------------------------*/
00026 
00027 #include "syringePressureFvPatchScalarField.H"
00028 #include "volMesh.H"
00029 #include "addToRunTimeSelectionTable.H"
00030 #include "fvPatchFieldMapper.H"
00031 #include "surfaceFields.H"
00032 
00033 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00034 
00035 namespace Foam
00036 {
00037 
00038 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00039 
00040 syringePressureFvPatchScalarField::syringePressureFvPatchScalarField
00041 (
00042     const fvPatch& p,
00043     const DimensionedField<scalar, volMesh>& iF
00044 )
00045 :
00046     fixedValueFvPatchScalarField(p, iF),
00047     curTimeIndex_(-1)
00048 {}
00049 
00050 
00051 syringePressureFvPatchScalarField::syringePressureFvPatchScalarField
00052 (
00053     const syringePressureFvPatchScalarField& sppsf,
00054     const fvPatch& p,
00055     const DimensionedField<scalar, volMesh>& iF,
00056     const fvPatchFieldMapper& mapper
00057 )
00058 :
00059     fixedValueFvPatchScalarField(sppsf, p, iF, mapper),
00060     Ap_(sppsf.Ap_),
00061     Sp_(sppsf.Sp_),
00062     VsI_(sppsf.VsI_),
00063     tas_(sppsf.tas_),
00064     tae_(sppsf.tae_),
00065     tds_(sppsf.tds_),
00066     tde_(sppsf.tde_),
00067     psI_(sppsf.psI_),
00068     psi_(sppsf.psi_),
00069     ams_(sppsf.ams_),
00070     ams0_(sppsf.ams0_),
00071     curTimeIndex_(-1)
00072 {}
00073 
00074 
00075 syringePressureFvPatchScalarField::syringePressureFvPatchScalarField
00076 (
00077     const fvPatch& p,
00078     const DimensionedField<scalar, volMesh>& iF,
00079     const dictionary& dict
00080 )
00081 :
00082     fixedValueFvPatchScalarField(p, iF),
00083     Ap_(readScalar(dict.lookup("Ap"))),
00084     Sp_(readScalar(dict.lookup("Sp"))),
00085     VsI_(readScalar(dict.lookup("VsI"))),
00086     tas_(readScalar(dict.lookup("tas"))),
00087     tae_(readScalar(dict.lookup("tae"))),
00088     tds_(readScalar(dict.lookup("tds"))),
00089     tde_(readScalar(dict.lookup("tde"))),
00090     psI_(readScalar(dict.lookup("psI"))),
00091     psi_(readScalar(dict.lookup("psi"))),
00092     ams_(readScalar(dict.lookup("ams"))),
00093     ams0_(ams_),
00094     curTimeIndex_(-1)
00095 {
00096     scalar ps = (psI_*VsI_ + ams_/psi_)/Vs(db().time().value());
00097     fvPatchField<scalar>::operator=(ps);
00098 }
00099 
00100 
00101 syringePressureFvPatchScalarField::syringePressureFvPatchScalarField
00102 (
00103     const syringePressureFvPatchScalarField& sppsf,
00104     const DimensionedField<scalar, volMesh>& iF
00105 )
00106 :
00107     fixedValueFvPatchScalarField(sppsf, iF),
00108     Ap_(sppsf.Ap_),
00109     Sp_(sppsf.Sp_),
00110     VsI_(sppsf.VsI_),
00111     tas_(sppsf.tas_),
00112     tae_(sppsf.tae_),
00113     tds_(sppsf.tds_),
00114     tde_(sppsf.tde_),
00115     psI_(sppsf.psI_),
00116     psi_(sppsf.psi_),
00117     ams_(sppsf.ams_),
00118     ams0_(sppsf.ams0_),
00119     curTimeIndex_(-1)
00120 {}
00121 
00122 
00123 syringePressureFvPatchScalarField::syringePressureFvPatchScalarField
00124 (
00125     const syringePressureFvPatchScalarField& sppsf
00126 )
00127 :
00128     fixedValueFvPatchScalarField(sppsf),
00129     Ap_(sppsf.Ap_),
00130     Sp_(sppsf.Sp_),
00131     VsI_(sppsf.VsI_),
00132     tas_(sppsf.tas_),
00133     tae_(sppsf.tae_),
00134     tds_(sppsf.tds_),
00135     tde_(sppsf.tde_),
00136     psI_(sppsf.psI_),
00137     psi_(sppsf.psi_),
00138     ams_(sppsf.ams_),
00139     ams0_(sppsf.ams0_),
00140     curTimeIndex_(-1)
00141 {}
00142 
00143 
00144 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00145 
00146 scalar syringePressureFvPatchScalarField::Vs(const scalar t) const
00147 {
00148     if (t < tas_)
00149     {
00150         return VsI_;
00151     }
00152     else if (t < tae_)
00153     {
00154         return 
00155             VsI_
00156           + 0.5*Ap_*Sp_*sqr(t - tas_)/(tae_ - tas_);
00157     }
00158     else if (t < tds_)
00159     {
00160         return 
00161             VsI_ 
00162           + 0.5*Ap_*Sp_*(tae_ - tas_)
00163           + Ap_*Sp_*(t - tae_);
00164     }
00165     else if (t < tde_)
00166     {
00167         return 
00168             VsI_ 
00169           + 0.5*Ap_*Sp_*(tae_ - tas_) 
00170           + Ap_*Sp_*(tds_ - tae_)
00171           + Ap_*Sp_*(t - tds_)
00172           - 0.5*Ap_*Sp_*sqr(t - tds_)/(tde_ - tds_);
00173     }
00174     else
00175     {
00176         return 
00177             VsI_ 
00178           + 0.5*Ap_*Sp_*(tae_ - tas_) 
00179           + Ap_*Sp_*(tds_ - tae_)
00180           + 0.5*Ap_*Sp_*(tde_ - tds_);
00181     }
00182 }
00183 
00184 
00185 void syringePressureFvPatchScalarField::updateCoeffs()
00186 {
00187     if (updated())
00188     {
00189         return;
00190     }
00191 
00192     if (curTimeIndex_ != db().time().timeIndex())
00193     {
00194         ams0_ = ams_;
00195         curTimeIndex_ = db().time().timeIndex();
00196     }
00197 
00198     scalar t = db().time().value();
00199     scalar deltaT = db().time().deltaT().value();
00200 
00201     const surfaceScalarField& phi =
00202         db().lookupObject<surfaceScalarField>("phi");
00203 
00204     const fvsPatchField<scalar>& phip =
00205         patch().patchField<surfaceScalarField, scalar>(phi);
00206 
00207     if (phi.dimensions() == dimVelocity*dimArea)
00208     {
00209         ams_ = ams0_ + deltaT*sum((*this*psi_)*phip);
00210     }
00211     else if (phi.dimensions() == dimDensity*dimVelocity*dimArea)
00212     {
00213         ams_ = ams0_ + deltaT*sum(phip);
00214     }
00215     else
00216     {
00217         FatalErrorIn("syringePressureFvPatchScalarField::updateCoeffs()")
00218             << "dimensions of phi are not correct"
00219             << "\n    on patch " << this->patch().name()
00220             << " of field " << this->dimensionedInternalField().name()
00221             << " in file " << this->dimensionedInternalField().objectPath()
00222             << exit(FatalError);
00223     }
00224 
00225     scalar ps = (psI_*VsI_ + ams_/psi_)/Vs(t);
00226 
00227     operator==(ps);
00228 
00229     fixedValueFvPatchScalarField::updateCoeffs();
00230 }
00231 
00232 
00233 void syringePressureFvPatchScalarField::write(Ostream& os) const
00234 {
00235     fvPatchScalarField::write(os);
00236 
00237     os.writeKeyword("Ap") << Ap_ << token::END_STATEMENT << nl;
00238     os.writeKeyword("Sp") << Sp_ << token::END_STATEMENT << nl;
00239     os.writeKeyword("VsI") << VsI_ << token::END_STATEMENT << nl;
00240     os.writeKeyword("tas") << tas_ << token::END_STATEMENT << nl;
00241     os.writeKeyword("tae") << tae_ << token::END_STATEMENT << nl;
00242     os.writeKeyword("tds") << tds_ << token::END_STATEMENT << nl;
00243     os.writeKeyword("tde") << tde_ << token::END_STATEMENT << nl;
00244     os.writeKeyword("psI") << psI_ << token::END_STATEMENT << nl;
00245     os.writeKeyword("psi") << psi_ << token::END_STATEMENT << nl;
00246     os.writeKeyword("ams") << ams_ << token::END_STATEMENT << nl;
00247 
00248     writeEntry("value", os);
00249 }
00250 
00251 
00252 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00253 
00254 makePatchTypeField
00255 (
00256     fvPatchScalarField,
00257     syringePressureFvPatchScalarField
00258 );
00259 
00260 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00261 
00262 } // End namespace Foam
00263 
00264 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd