linearUpwindV.C
Go to the documentation of this file.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 #include "linearUpwindV.H"
00028 #include "fvMesh.H"
00029 #include "volFields.H"
00030 #include "surfaceFields.H"
00031
00032
00033
00034 template<class Type>
00035 Foam::tmp<Foam::GeometricField<Type, Foam::fvsPatchField, Foam::surfaceMesh> >
00036 Foam::linearUpwindV<Type>::correction
00037 (
00038 const GeometricField<Type, fvPatchField, volMesh>& vf
00039 ) const
00040 {
00041 const fvMesh& mesh = this->mesh();
00042
00043 tmp<GeometricField<Type, fvsPatchField, surfaceMesh> > tsfCorr
00044 (
00045 new GeometricField<Type, fvsPatchField, surfaceMesh>
00046 (
00047 IOobject
00048 (
00049 vf.name(),
00050 mesh.time().timeName(),
00051 mesh
00052 ),
00053 mesh,
00054 dimensioned<Type>
00055 (
00056 vf.name(),
00057 vf.dimensions(),
00058 pTraits<Type>::zero
00059 )
00060 )
00061 );
00062
00063 GeometricField<Type, fvsPatchField, surfaceMesh>& sfCorr = tsfCorr();
00064
00065 const surfaceScalarField& faceFlux = this->faceFlux_;
00066 const surfaceScalarField& w = mesh.weights();
00067
00068 const labelList& own = mesh.owner();
00069 const labelList& nei = mesh.neighbour();
00070
00071 const vectorField& C = mesh.C();
00072 const vectorField& Cf = mesh.Cf();
00073
00074 GeometricField
00075 <typename outerProduct<vector, Type>::type, fvPatchField, volMesh>
00076 gradVf = gradScheme_().grad(vf);
00077
00078 forAll(faceFlux, facei)
00079 {
00080 vector maxCorr;
00081
00082 if (faceFlux[facei] > 0.0)
00083 {
00084 maxCorr =
00085 (1.0 - w[facei])
00086 *(vf[nei[facei]] - vf[own[facei]]);
00087
00088 sfCorr[facei] =
00089 (Cf[facei] - C[own[facei]]) & gradVf[own[facei]];
00090 }
00091 else
00092 {
00093 maxCorr =
00094 w[facei]*(vf[own[facei]] - vf[nei[facei]]);
00095
00096 sfCorr[facei] =
00097 (Cf[facei] - C[nei[facei]]) & gradVf[nei[facei]];
00098 }
00099
00100 scalar sfCorrs = magSqr(sfCorr[facei]);
00101 scalar maxCorrs = sfCorr[facei] & maxCorr;
00102
00103 if (sfCorrs > 0)
00104 {
00105 if (maxCorrs < 0)
00106 {
00107 sfCorr[facei] = vector::zero;
00108 }
00109 else if (sfCorrs > maxCorrs)
00110 {
00111 sfCorr[facei] *= maxCorrs/(sfCorrs + VSMALL);
00112 }
00113 }
00114 else if (sfCorrs < 0)
00115 {
00116 if (maxCorrs > 0)
00117 {
00118 sfCorr[facei] = vector::zero;
00119 }
00120 else if (sfCorrs < maxCorrs)
00121 {
00122 sfCorr[facei] *= maxCorrs/(sfCorrs - VSMALL);
00123 }
00124 }
00125 }
00126
00127 return tsfCorr;
00128 }
00129
00130
00131 namespace Foam
00132 {
00133 makelimitedSurfaceInterpolationTypeScheme(linearUpwindV, vector)
00134 }
00135
00136
Copyright © 2000-2009 OpenCFD Ltd