linearUpwind.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 "linearUpwind.H"
00028 #include "fvMesh.H"
00029 #include "zeroGradientFvPatchField.H"
00030
00031
00032
00033 template<class Type>
00034 Foam::tmp<Foam::GeometricField<Type, Foam::fvsPatchField, Foam::surfaceMesh> >
00035 Foam::linearUpwind<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 "linearUpwindCorrection(" + vf.name() + ')',
00049 mesh.time().timeName(),
00050 mesh,
00051 IOobject::NO_READ,
00052 IOobject::NO_WRITE,
00053 false
00054 ),
00055 mesh,
00056 dimensioned<Type>(vf.name(), vf.dimensions(), pTraits<Type>::zero)
00057 )
00058 );
00059
00060 GeometricField<Type, fvsPatchField, surfaceMesh>& sfCorr = tsfCorr();
00061
00062 const surfaceScalarField& faceFlux = this->faceFlux_;
00063
00064 const labelList& owner = mesh.owner();
00065 const labelList& neighbour = mesh.neighbour();
00066
00067 const volVectorField& C = mesh.C();
00068 const surfaceVectorField& Cf = mesh.Cf();
00069
00070 GeometricField
00071 <typename outerProduct<vector, Type>::type, fvPatchField, volMesh>
00072 gradVf = gradScheme_().grad(vf);
00073
00074 forAll(faceFlux, facei)
00075 {
00076 if (faceFlux[facei] > 0)
00077 {
00078 label own = owner[facei];
00079 sfCorr[facei] = (Cf[facei] - C[own]) & gradVf[own];
00080 }
00081 else
00082 {
00083 label nei = neighbour[facei];
00084 sfCorr[facei] = (Cf[facei] - C[nei]) & gradVf[nei];
00085 }
00086 }
00087
00088
00089 typename GeometricField<Type, fvsPatchField, surfaceMesh>::
00090 GeometricBoundaryField& bSfCorr = sfCorr.boundaryField();
00091
00092 forAll(bSfCorr, patchi)
00093 {
00094 fvsPatchField<Type>& pSfCorr = bSfCorr[patchi];
00095
00096 if (pSfCorr.coupled())
00097 {
00098 const unallocLabelList& pOwner =
00099 mesh.boundary()[patchi].faceCells();
00100
00101 const vectorField& pCf = Cf.boundaryField()[patchi];
00102
00103 const scalarField& pFaceFlux = faceFlux.boundaryField()[patchi];
00104
00105 Field<typename outerProduct<vector, Type>::type> pGradVfNei =
00106 gradVf.boundaryField()[patchi].patchNeighbourField();
00107
00108
00109 vectorField pd =
00110 mesh.Sf().boundaryField()[patchi]
00111 /(
00112 mesh.magSf().boundaryField()[patchi]
00113 *mesh.deltaCoeffs().boundaryField()[patchi]
00114 );
00115
00116 if (!mesh.orthogonal())
00117 {
00118 pd -= mesh.correctionVectors().boundaryField()[patchi]
00119 /mesh.deltaCoeffs().boundaryField()[patchi];
00120 }
00121
00122 forAll(pOwner, facei)
00123 {
00124 label own = pOwner[facei];
00125
00126 if (pFaceFlux[facei] > 0)
00127 {
00128 pSfCorr[facei] = (pCf[facei] - C[own]) & gradVf[own];
00129 }
00130 else
00131 {
00132 pSfCorr[facei] =
00133 (pCf[facei] - pd[facei] - C[own]) & pGradVfNei[facei];
00134 }
00135 }
00136 }
00137 }
00138
00139 return tsfCorr;
00140 }
00141
00142
00143 namespace Foam
00144 {
00145
00146 makelimitedSurfaceInterpolationTypeScheme(linearUpwind, scalar)
00147 makelimitedSurfaceInterpolationTypeScheme(linearUpwind, vector)
00148 }
00149
00150
Copyright © 2000-2009 OpenCFD Ltd