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 <finiteVolume/volFields.H>
00027 #include <finiteVolume/surfaceFields.H>
00028 #include <finiteVolume/fvcGrad.H>
00029 #include <finiteVolume/coupledFvPatchFields.H>
00030 
00031 
00032 
00033 namespace Foam
00034 {
00035 
00036 
00037 
00038 template<class Type, class Limiter, template<class> class LimitFunc>
00039 tmp<surfaceScalarField> LimitedScheme<Type, Limiter, LimitFunc>::limiter
00040 (
00041     const GeometricField<Type, fvPatchField, volMesh>& phi
00042 ) const
00043 {
00044     const fvMesh& mesh = this->mesh();
00045 
00046     tmp<surfaceScalarField> tLimiter
00047     (
00048         new surfaceScalarField
00049         (
00050             IOobject
00051             (
00052                 type() + "Limiter(" + phi.name() + ')',
00053                 mesh.time().timeName(),
00054                 mesh
00055             ),
00056             mesh,
00057             dimless
00058         )
00059     );
00060     surfaceScalarField& lim = tLimiter();
00061 
00062     tmp<GeometricField<typename Limiter::phiType, fvPatchField, volMesh> >
00063         tlPhi = LimitFunc<Type>()(phi);
00064 
00065     const GeometricField<typename Limiter::phiType, fvPatchField, volMesh>&
00066         lPhi = tlPhi();
00067 
00068     GeometricField<typename Limiter::gradPhiType, fvPatchField, volMesh>
00069         gradc(fvc::grad(lPhi));
00070 
00071     const surfaceScalarField& CDweights = mesh.surfaceInterpolation::weights();
00072 
00073     const unallocLabelList& owner = mesh.owner();
00074     const unallocLabelList& neighbour = mesh.neighbour();
00075 
00076     const vectorField& C = mesh.C();
00077 
00078     scalarField& pLim = lim.internalField();
00079 
00080     forAll(pLim, face)
00081     {
00082         label own = owner[face];
00083         label nei = neighbour[face];
00084 
00085         pLim[face] = Limiter::limiter
00086         (
00087             CDweights[face],
00088             this->faceFlux_[face],
00089             lPhi[own],
00090             lPhi[nei],
00091             gradc[own],
00092             gradc[nei],
00093             C[nei] - C[own]
00094         );
00095     }
00096 
00097     surfaceScalarField::GeometricBoundaryField& bLim = lim.boundaryField();
00098 
00099     forAll(bLim, patchi)
00100     {
00101         scalarField& pLim = bLim[patchi];
00102 
00103         if (bLim[patchi].coupled())
00104         {
00105             const scalarField& pCDweights = CDweights.boundaryField()[patchi];
00106             const scalarField& pFaceFlux =
00107                 this->faceFlux_.boundaryField()[patchi];
00108             Field<typename Limiter::phiType> plPhiP =
00109                 lPhi.boundaryField()[patchi].patchInternalField();
00110             Field<typename Limiter::phiType> plPhiN =
00111                 lPhi.boundaryField()[patchi].patchNeighbourField();
00112             Field<typename Limiter::gradPhiType> pGradcP =
00113                 gradc.boundaryField()[patchi].patchInternalField();
00114             Field<typename Limiter::gradPhiType> pGradcN =
00115                 gradc.boundaryField()[patchi].patchNeighbourField();
00116 
00117             
00118             vectorField pd = 
00119                 mesh.Sf().boundaryField()[patchi]
00120                /(
00121                    mesh.magSf().boundaryField()[patchi]
00122                   *mesh.deltaCoeffs().boundaryField()[patchi]
00123                 );
00124 
00125             if (!mesh.orthogonal())
00126             {
00127                 pd -= mesh.correctionVectors().boundaryField()[patchi]
00128                     /mesh.deltaCoeffs().boundaryField()[patchi];
00129             }
00130 
00131             forAll(pLim, face)
00132             {
00133                 pLim[face] = Limiter::limiter
00134                 (
00135                     pCDweights[face],
00136                     pFaceFlux[face],
00137                     plPhiP[face],
00138                     plPhiN[face],
00139                     pGradcP[face],
00140                     pGradcN[face],
00141                     pd[face]
00142                 );
00143             }
00144         }
00145         else
00146         {
00147             pLim = 1.0;
00148         }
00149     }
00150 
00151     return tLimiter;
00152 }
00153 
00154 
00155 
00156 
00157 } 
00158 
00159