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 linearUpwindV_H
00038 #define linearUpwindV_H
00039
00040 #include "upwind.H"
00041 #include "gaussGrad.H"
00042
00043
00044
00045 namespace Foam
00046 {
00047
00048
00049
00050
00051
00052 template<class Type>
00053 class linearUpwindV
00054 :
00055 public upwind<Type>
00056 {
00057
00058
00059 tmp<fv::gradScheme<Type> > gradScheme_;
00060
00061
00062
00063
00064
00065 linearUpwindV(const linearUpwindV&);
00066
00067
00068 void operator=(const linearUpwindV&);
00069
00070
00071 public:
00072
00073
00074 TypeName("linearUpwindV");
00075
00076
00077
00078
00079
00080 linearUpwindV
00081 (
00082 const fvMesh& mesh,
00083 const surfaceScalarField& faceFlux
00084 )
00085 :
00086 upwind<Type>(mesh, faceFlux),
00087 gradScheme_
00088 (
00089 new fv::gaussGrad<Type>(mesh)
00090 )
00091 {}
00092
00093
00094
00095
00096 linearUpwindV
00097 (
00098 const fvMesh& mesh,
00099 Istream& schemeData
00100 )
00101 :
00102 upwind<Type>(mesh, schemeData),
00103 gradScheme_
00104 (
00105 fv::gradScheme<Type>::New
00106 (
00107 mesh,
00108 schemeData
00109 )
00110 )
00111 {}
00112
00113
00114 linearUpwindV
00115 (
00116 const fvMesh& mesh,
00117 const surfaceScalarField& faceFlux,
00118 Istream& schemeData
00119 )
00120 :
00121 upwind<Type>(mesh, faceFlux, schemeData),
00122 gradScheme_
00123 (
00124 fv::gradScheme<Type>::New
00125 (
00126 mesh,
00127 schemeData
00128 )
00129 )
00130 {}
00131
00132
00133
00134
00135
00136 virtual bool corrected() const
00137 {
00138 return true;
00139 }
00140
00141
00142 virtual tmp<GeometricField<Type, fvPatchField, surfaceMesh> >
00143 correction
00144 (
00145 const GeometricField<Type, fvPatchField, volMesh>& vf
00146 ) const
00147 {
00148 const fvMesh& mesh = this->mesh();
00149
00150 tmp<GeometricField<Type, fvPatchField, surfaceMesh> > tsfCorr
00151 (
00152 new GeometricField<Type, fvPatchField, surfaceMesh>
00153 (
00154 IOobject
00155 (
00156 vf.name(),
00157 mesh.time().timeName(),
00158 mesh
00159 ),
00160 mesh,
00161 dimensioned<Type>
00162 (
00163 vf.name(),
00164 vf.dimensions(),
00165 pTraits<Type>::zero
00166 )
00167 )
00168 );
00169
00170 GeometricField<Type, fvPatchField, surfaceMesh>& sfCorr = tsfCorr();
00171
00172 const surfaceScalarField& faceFlux = this->faceFlux_;
00173 const surfaceScalarField& w = mesh.weights();
00174
00175 const labelList& own = mesh.owner();
00176 const labelList& nei = mesh.neighbour();
00177
00178 const vectorField& C = mesh.C();
00179 const vectorField& Cf = mesh.Cf();
00180
00181 GeometricField
00182 <typename outerProduct<vector, Type>::type, fvPatchField, volMesh>
00183 gradVf = gradScheme_().grad(vf);
00184
00185 forAll(faceFlux, facei)
00186 {
00187 vector maxCorr;
00188
00189 if (faceFlux[facei] > 0.0)
00190 {
00191 maxCorr =
00192 (1.0 - w[facei])*(vf[nei[facei]] - vf[own[facei]]);
00193
00194 sfCorr[facei] =
00195 (Cf[facei] - C[own[facei]]) & gradVf[own[facei]];
00196 }
00197 else
00198 {
00199 maxCorr =
00200 w[facei]*(vf[own[facei]] - vf[nei[facei]]);
00201
00202 sfCorr[facei] =
00203 (Cf[facei] - C[nei[facei]]) & gradVf[nei[facei]];
00204 }
00205
00206 scalar sfCorrs = magSqr(sfCorr[facei]);
00207 scalar maxCorrs = sfCorr[facei] & maxCorr;
00208
00209 if (sfCorrs > 0)
00210 {
00211 if (maxCorrs < 0)
00212 {
00213 sfCorr[facei] = vector::zero;
00214 }
00215 else if (sfCorrs > maxCorrs)
00216 {
00217 sfCorr[facei] *= maxCorrs/(sfCorrs + VSMALL);
00218 }
00219 }
00220 else if (sfCorrs < 0)
00221 {
00222 if (maxCorrs > 0)
00223 {
00224 sfCorr[facei] = vector::zero;
00225 }
00226 else if (sfCorrs < maxCorrs)
00227 {
00228 sfCorr[facei] *= maxCorrs/(sfCorrs - VSMALL);
00229 }
00230 }
00231 }
00232
00233 return tsfCorr;
00234 }
00235 };
00236
00237
00238
00239
00240 }
00241
00242
00243
00244 #endif
00245
00246