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