00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037 #ifndef CrankNicholsonDdtScheme_H
00038 #define CrankNicholsonDdtScheme_H
00039
00040 #include "ddtScheme.H"
00041
00042
00043
00044 namespace Foam
00045 {
00046
00047
00048
00049 namespace fv
00050 {
00051
00052
00053
00054
00055
00056 template<class Type>
00057 class CrankNicholsonDdtScheme
00058 :
00059 public fv::ddtScheme<Type>
00060 {
00061
00062
00063
00064
00065
00066 template<class GeoField>
00067 class DDt0Field
00068 :
00069 public GeoField
00070 {
00071 label startTimeIndex_;
00072
00073 public:
00074
00075
00076 DDt0Field
00077 (
00078 const IOobject& io,
00079 const fvMesh& mesh
00080 );
00081
00082
00083
00084 DDt0Field
00085 (
00086 const IOobject& io,
00087 const fvMesh& mesh,
00088 const dimensioned<typename GeoField::value_type>& dimType
00089 );
00090
00091
00092 label startTimeIndex() const;
00093
00094
00095 GeoField& operator()();
00096
00097
00098 void operator=(const GeoField& gf);
00099 };
00100
00101
00102
00103 scalar ocCoeff_;
00104
00105
00106
00107
00108
00109 CrankNicholsonDdtScheme(const CrankNicholsonDdtScheme&);
00110
00111
00112 void operator=(const CrankNicholsonDdtScheme&);
00113
00114 template<class GeoField>
00115 DDt0Field<GeoField>& ddt0_
00116 (
00117 const word& name,
00118 const dimensionSet& dims
00119 );
00120
00121
00122 template<class GeoField>
00123 bool evaluate(const DDt0Field<GeoField>& ddt0) const;
00124
00125
00126
00127 template<class GeoField>
00128 scalar coef_(const DDt0Field<GeoField>&) const;
00129
00130
00131
00132 template<class GeoField>
00133 scalar coef0_(const DDt0Field<GeoField>&) const;
00134
00135
00136
00137 template<class GeoField>
00138 dimensionedScalar rDtCoef_(const DDt0Field<GeoField>&) const;
00139
00140
00141
00142 template<class GeoField>
00143 dimensionedScalar rDtCoef0_(const DDt0Field<GeoField>&) const;
00144
00145
00146 template<class GeoField>
00147 tmp<GeoField> offCentre_(const GeoField& ddt0) const;
00148
00149
00150 public:
00151
00152
00153 TypeName("CrankNicholson");
00154
00155
00156
00157
00158
00159 CrankNicholsonDdtScheme(const fvMesh& mesh)
00160 :
00161 ddtScheme<Type>(mesh),
00162 ocCoeff_(1.0)
00163 {}
00164
00165
00166 CrankNicholsonDdtScheme(const fvMesh& mesh, Istream& is)
00167 :
00168 ddtScheme<Type>(mesh, is),
00169 ocCoeff_(readScalar(is))
00170 {
00171 if (ocCoeff_ < 0 || ocCoeff_ > 1)
00172 {
00173 FatalIOErrorIn
00174 (
00175 "CrankNicholsonDdtScheme(const fvMesh& mesh, Istream& is)",
00176 is
00177 ) << "coefficient = " << ocCoeff_
00178 << " should be >= 0 and <= 1"
00179 << exit(FatalIOError);
00180 }
00181 }
00182
00183
00184
00185
00186
00187 const fvMesh& mesh() const
00188 {
00189 return fv::ddtScheme<Type>::mesh();
00190 }
00191
00192 tmp<GeometricField<Type, fvPatchField, volMesh> > fvcDdt
00193 (
00194 const dimensioned<Type>&
00195 );
00196
00197 tmp<GeometricField<Type, fvPatchField, volMesh> > fvcDdt
00198 (
00199 const GeometricField<Type, fvPatchField, volMesh>&
00200 );
00201
00202 tmp<GeometricField<Type, fvPatchField, volMesh> > fvcDdt
00203 (
00204 const dimensionedScalar&,
00205 const GeometricField<Type, fvPatchField, volMesh>&
00206 );
00207
00208 tmp<GeometricField<Type, fvPatchField, volMesh> > fvcDdt
00209 (
00210 const volScalarField&,
00211 const GeometricField<Type, fvPatchField, volMesh>&
00212 );
00213
00214 tmp<fvMatrix<Type> > fvmDdt
00215 (
00216 GeometricField<Type, fvPatchField, volMesh>&
00217 );
00218
00219 tmp<fvMatrix<Type> > fvmDdt
00220 (
00221 const dimensionedScalar&,
00222 GeometricField<Type, fvPatchField, volMesh>&
00223 );
00224
00225 tmp<fvMatrix<Type> > fvmDdt
00226 (
00227 const volScalarField&,
00228 GeometricField<Type, fvPatchField, volMesh>&
00229 );
00230
00231 typedef typename ddtScheme<Type>::fluxFieldType fluxFieldType;
00232
00233 tmp<fluxFieldType> fvcDdtPhiCorr
00234 (
00235 const volScalarField& rA,
00236 const GeometricField<Type, fvPatchField, volMesh>& U,
00237 const fluxFieldType& phi
00238 );
00239
00240 tmp<fluxFieldType> fvcDdtPhiCorr
00241 (
00242 const volScalarField& rA,
00243 const volScalarField& rho,
00244 const GeometricField<Type, fvPatchField, volMesh>& U,
00245 const fluxFieldType& phi
00246 );
00247
00248
00249 tmp<surfaceScalarField> meshPhi
00250 (
00251 const GeometricField<Type, fvPatchField, volMesh>&
00252 );
00253 };
00254
00255
00256 template<>
00257 tmp<surfaceScalarField> CrankNicholsonDdtScheme<scalar>::fvcDdtPhiCorr
00258 (
00259 const volScalarField& rA,
00260 const volScalarField& U,
00261 const surfaceScalarField& phi
00262 );
00263
00264
00265 template<>
00266 tmp<surfaceScalarField> CrankNicholsonDdtScheme<scalar>::fvcDdtPhiCorr
00267 (
00268 const volScalarField& rA,
00269 const volScalarField& rho,
00270 const volScalarField& U,
00271 const surfaceScalarField& phi
00272 );
00273
00274
00275
00276
00277 }
00278
00279
00280
00281 }
00282
00283
00284
00285 #ifdef NoRepository
00286 # include "CrankNicholsonDdtScheme.C"
00287 #endif
00288
00289
00290
00291 #endif
00292
00293