FreeFOAM The Cross-Platform CFD Toolkit
Hosted by SourceForge:
Get FreeFOAM at SourceForge.net.
            Fast, secure and Free Open Source software downloads

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-2010 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
00013     the Free Software Foundation, either version 3 of the License, or
00014     (at your 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, see <http://www.gnu.org/licenses/>.
00023 
00024 \*---------------------------------------------------------------------------*/
00025 
00026 #include "syringePressureFvPatchScalarField.H"
00027 #include <finiteVolume/volMesh.H>
00028 #include <OpenFOAM/addToRunTimeSelectionTable.H>
00029 #include <finiteVolume/fvPatchFieldMapper.H>
00030 #include <finiteVolume/surfaceFields.H>
00031 
00032 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00033 
00034 namespace Foam
00035 {
00036 
00037 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00038 
00039 syringePressureFvPatchScalarField::syringePressureFvPatchScalarField
00040 (
00041     const fvPatch& p,
00042     const DimensionedField<scalar, volMesh>& iF
00043 )
00044 :
00045     fixedValueFvPatchScalarField(p, iF),
00046     curTimeIndex_(-1)
00047 {}
00048 
00049 
00050 syringePressureFvPatchScalarField::syringePressureFvPatchScalarField
00051 (
00052     const syringePressureFvPatchScalarField& sppsf,
00053     const fvPatch& p,
00054     const DimensionedField<scalar, volMesh>& iF,
00055     const fvPatchFieldMapper& mapper
00056 )
00057 :
00058     fixedValueFvPatchScalarField(sppsf, p, iF, mapper),
00059     Ap_(sppsf.Ap_),
00060     Sp_(sppsf.Sp_),
00061     VsI_(sppsf.VsI_),
00062     tas_(sppsf.tas_),
00063     tae_(sppsf.tae_),
00064     tds_(sppsf.tds_),
00065     tde_(sppsf.tde_),
00066     psI_(sppsf.psI_),
00067     psi_(sppsf.psi_),
00068     ams_(sppsf.ams_),
00069     ams0_(sppsf.ams0_),
00070     curTimeIndex_(-1)
00071 {}
00072 
00073 
00074 syringePressureFvPatchScalarField::syringePressureFvPatchScalarField
00075 (
00076     const fvPatch& p,
00077     const DimensionedField<scalar, volMesh>& iF,
00078     const dictionary& dict
00079 )
00080 :
00081     fixedValueFvPatchScalarField(p, iF),
00082     Ap_(readScalar(dict.lookup("Ap"))),
00083     Sp_(readScalar(dict.lookup("Sp"))),
00084     VsI_(readScalar(dict.lookup("VsI"))),
00085     tas_(readScalar(dict.lookup("tas"))),
00086     tae_(readScalar(dict.lookup("tae"))),
00087     tds_(readScalar(dict.lookup("tds"))),
00088     tde_(readScalar(dict.lookup("tde"))),
00089     psI_(readScalar(dict.lookup("psI"))),
00090     psi_(readScalar(dict.lookup("psi"))),
00091     ams_(readScalar(dict.lookup("ams"))),
00092     ams0_(ams_),
00093     curTimeIndex_(-1)
00094 {
00095     scalar ps = (psI_*VsI_ + ams_/psi_)/Vs(db().time().value());
00096     fvPatchField<scalar>::operator=(ps);
00097 }
00098 
00099 
00100 syringePressureFvPatchScalarField::syringePressureFvPatchScalarField
00101 (
00102     const syringePressureFvPatchScalarField& sppsf,
00103     const DimensionedField<scalar, volMesh>& iF
00104 )
00105 :
00106     fixedValueFvPatchScalarField(sppsf, iF),
00107     Ap_(sppsf.Ap_),
00108     Sp_(sppsf.Sp_),
00109     VsI_(sppsf.VsI_),
00110     tas_(sppsf.tas_),
00111     tae_(sppsf.tae_),
00112     tds_(sppsf.tds_),
00113     tde_(sppsf.tde_),
00114     psI_(sppsf.psI_),
00115     psi_(sppsf.psi_),
00116     ams_(sppsf.ams_),
00117     ams0_(sppsf.ams0_),
00118     curTimeIndex_(-1)
00119 {}
00120 
00121 
00122 syringePressureFvPatchScalarField::syringePressureFvPatchScalarField
00123 (
00124     const syringePressureFvPatchScalarField& sppsf
00125 )
00126 :
00127     fixedValueFvPatchScalarField(sppsf),
00128     Ap_(sppsf.Ap_),
00129     Sp_(sppsf.Sp_),
00130     VsI_(sppsf.VsI_),
00131     tas_(sppsf.tas_),
00132     tae_(sppsf.tae_),
00133     tds_(sppsf.tds_),
00134     tde_(sppsf.tde_),
00135     psI_(sppsf.psI_),
00136     psi_(sppsf.psi_),
00137     ams_(sppsf.ams_),
00138     ams0_(sppsf.ams0_),
00139     curTimeIndex_(-1)
00140 {}
00141 
00142 
00143 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00144 
00145 scalar syringePressureFvPatchScalarField::Vs(const scalar t) const
00146 {
00147     if (t < tas_)
00148     {
00149         return VsI_;
00150     }
00151     else if (t < tae_)
00152     {
00153         return 
00154             VsI_
00155           + 0.5*Ap_*Sp_*sqr(t - tas_)/(tae_ - tas_);
00156     }
00157     else if (t < tds_)
00158     {
00159         return 
00160             VsI_ 
00161           + 0.5*Ap_*Sp_*(tae_ - tas_)
00162           + Ap_*Sp_*(t - tae_);
00163     }
00164     else if (t < tde_)
00165     {
00166         return 
00167             VsI_ 
00168           + 0.5*Ap_*Sp_*(tae_ - tas_) 
00169           + Ap_*Sp_*(tds_ - tae_)
00170           + Ap_*Sp_*(t - tds_)
00171           - 0.5*Ap_*Sp_*sqr(t - tds_)/(tde_ - tds_);
00172     }
00173     else
00174     {
00175         return 
00176             VsI_ 
00177           + 0.5*Ap_*Sp_*(tae_ - tas_) 
00178           + Ap_*Sp_*(tds_ - tae_)
00179           + 0.5*Ap_*Sp_*(tde_ - tds_);
00180     }
00181 }
00182 
00183 
00184 void syringePressureFvPatchScalarField::updateCoeffs()
00185 {
00186     if (updated())
00187     {
00188         return;
00189     }
00190 
00191     if (curTimeIndex_ != db().time().timeIndex())
00192     {
00193         ams0_ = ams_;
00194         curTimeIndex_ = db().time().timeIndex();
00195     }
00196 
00197     scalar t = db().time().value();
00198     scalar deltaT = db().time().deltaT().value();
00199 
00200     const surfaceScalarField& phi =
00201         db().lookupObject<surfaceScalarField>("phi");
00202 
00203     const fvsPatchField<scalar>& phip =
00204         patch().patchField<surfaceScalarField, scalar>(phi);
00205 
00206     if (phi.dimensions() == dimVelocity*dimArea)
00207     {
00208         ams_ = ams0_ + deltaT*sum((*this*psi_)*phip);
00209     }
00210     else if (phi.dimensions() == dimDensity*dimVelocity*dimArea)
00211     {
00212         ams_ = ams0_ + deltaT*sum(phip);
00213     }
00214     else
00215     {
00216         FatalErrorIn("syringePressureFvPatchScalarField::updateCoeffs()")
00217             << "dimensions of phi are not correct"
00218             << "\n    on patch " << this->patch().name()
00219             << " of field " << this->dimensionedInternalField().name()
00220             << " in file " << this->dimensionedInternalField().objectPath()
00221             << exit(FatalError);
00222     }
00223 
00224     scalar ps = (psI_*VsI_ + ams_/psi_)/Vs(t);
00225 
00226     operator==(ps);
00227 
00228     fixedValueFvPatchScalarField::updateCoeffs();
00229 }
00230 
00231 
00232 void syringePressureFvPatchScalarField::write(Ostream& os) const
00233 {
00234     fvPatchScalarField::write(os);
00235 
00236     os.writeKeyword("Ap") << Ap_ << token::END_STATEMENT << nl;
00237     os.writeKeyword("Sp") << Sp_ << token::END_STATEMENT << nl;
00238     os.writeKeyword("VsI") << VsI_ << token::END_STATEMENT << nl;
00239     os.writeKeyword("tas") << tas_ << token::END_STATEMENT << nl;
00240     os.writeKeyword("tae") << tae_ << token::END_STATEMENT << nl;
00241     os.writeKeyword("tds") << tds_ << token::END_STATEMENT << nl;
00242     os.writeKeyword("tde") << tde_ << token::END_STATEMENT << nl;
00243     os.writeKeyword("psI") << psI_ << token::END_STATEMENT << nl;
00244     os.writeKeyword("psi") << psi_ << token::END_STATEMENT << nl;
00245     os.writeKeyword("ams") << ams_ << token::END_STATEMENT << nl;
00246 
00247     writeEntry("value", os);
00248 }
00249 
00250 
00251 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00252 
00253 makePatchTypeField
00254 (
00255     fvPatchScalarField,
00256     syringePressureFvPatchScalarField
00257 );
00258 
00259 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00260 
00261 } // End namespace Foam
00262 
00263 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines