BUG: UListIO: byteSize overflowing on really big faceLists
[OpenFOAM-2.0.x.git] / src / finiteVolume / fields / fvPatchFields / derived / syringePressure / syringePressureFvPatchScalarField.C
blob116de777b46bac04eb44231fd4f7f5b233c6e471
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 2011 OpenFOAM Foundation
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
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
19     for more details.
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"
27 #include "volMesh.H"
28 #include "addToRunTimeSelectionTable.H"
29 #include "fvPatchFieldMapper.H"
30 #include "surfaceFields.H"
32 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
34 Foam::syringePressureFvPatchScalarField::syringePressureFvPatchScalarField
36     const fvPatch& p,
37     const DimensionedField<scalar, volMesh>& iF
40     fixedValueFvPatchScalarField(p, iF),
41     curTimeIndex_(-1)
45 Foam::syringePressureFvPatchScalarField::syringePressureFvPatchScalarField
47     const syringePressureFvPatchScalarField& sppsf,
48     const fvPatch& p,
49     const DimensionedField<scalar, volMesh>& iF,
50     const fvPatchFieldMapper& mapper
53     fixedValueFvPatchScalarField(sppsf, p, iF, mapper),
54     Ap_(sppsf.Ap_),
55     Sp_(sppsf.Sp_),
56     VsI_(sppsf.VsI_),
57     tas_(sppsf.tas_),
58     tae_(sppsf.tae_),
59     tds_(sppsf.tds_),
60     tde_(sppsf.tde_),
61     psI_(sppsf.psI_),
62     psi_(sppsf.psi_),
63     ams_(sppsf.ams_),
64     ams0_(sppsf.ams0_),
65     curTimeIndex_(-1)
69 Foam::syringePressureFvPatchScalarField::syringePressureFvPatchScalarField
71     const fvPatch& p,
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"))),
87     ams0_(ams_),
88     curTimeIndex_(-1)
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),
102     Ap_(sppsf.Ap_),
103     Sp_(sppsf.Sp_),
104     VsI_(sppsf.VsI_),
105     tas_(sppsf.tas_),
106     tae_(sppsf.tae_),
107     tds_(sppsf.tds_),
108     tde_(sppsf.tde_),
109     psI_(sppsf.psI_),
110     psi_(sppsf.psi_),
111     ams_(sppsf.ams_),
112     ams0_(sppsf.ams0_),
113     curTimeIndex_(-1)
117 Foam::syringePressureFvPatchScalarField::syringePressureFvPatchScalarField
119     const syringePressureFvPatchScalarField& sppsf
122     fixedValueFvPatchScalarField(sppsf),
123     Ap_(sppsf.Ap_),
124     Sp_(sppsf.Sp_),
125     VsI_(sppsf.VsI_),
126     tas_(sppsf.tas_),
127     tae_(sppsf.tae_),
128     tds_(sppsf.tds_),
129     tde_(sppsf.tde_),
130     psI_(sppsf.psI_),
131     psi_(sppsf.psi_),
132     ams_(sppsf.ams_),
133     ams0_(sppsf.ams0_),
134     curTimeIndex_(-1)
138 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
140 Foam::scalar Foam::syringePressureFvPatchScalarField::Vs(const scalar t) const
142     if (t < tas_)
143     {
144         return VsI_;
145     }
146     else if (t < tae_)
147     {
148         return
149             VsI_
150           + 0.5*Ap_*Sp_*sqr(t - tas_)/(tae_ - tas_);
151     }
152     else if (t < tds_)
153     {
154         return
155             VsI_
156           + 0.5*Ap_*Sp_*(tae_ - tas_)
157           + Ap_*Sp_*(t - tae_);
158     }
159     else if (t < tde_)
160     {
161         return
162             VsI_
163           + 0.5*Ap_*Sp_*(tae_ - tas_)
164           + Ap_*Sp_*(tds_ - tae_)
165           + Ap_*Sp_*(t - tds_)
166           - 0.5*Ap_*Sp_*sqr(t - tds_)/(tde_ - tds_);
167     }
168     else
169     {
170         return
171             VsI_
172           + 0.5*Ap_*Sp_*(tae_ - tas_)
173           + Ap_*Sp_*(tds_ - tae_)
174           + 0.5*Ap_*Sp_*(tde_ - tds_);
175     }
179 void Foam::syringePressureFvPatchScalarField::updateCoeffs()
181     if (updated())
182     {
183         return;
184     }
186     if (curTimeIndex_ != db().time().timeIndex())
187     {
188         ams0_ = ams_;
189         curTimeIndex_ = db().time().timeIndex();
190     }
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)
202     {
203         ams_ = ams0_ + deltaT*sum((*this*psi_)*phip);
204     }
205     else if (phi.dimensions() == dimDensity*dimVelocity*dimArea)
206     {
207         ams_ = ams0_ + deltaT*sum(phip);
208     }
209     else
210     {
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()
216             << exit(FatalError);
217     }
219     scalar ps = (psI_*VsI_ + ams_/psi_)/Vs(t);
221     operator==(ps);
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 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
248 namespace Foam
250     makePatchTypeField
251     (
252         fvPatchScalarField,
253         syringePressureFvPatchScalarField
254     );
257 // ************************************************************************* //