FreeFOAM The Cross-Platform CFD Toolkit
Hosted by SourceForge:
Get FreeFOAM at SourceForge.net.
            Fast, secure and Free Open Source software downloads

PhiScheme.C

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002   =========                 |
00003   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
00004    \\    /   O peration     |
00005     \\  /    A nd           | Copyright (C) 1991-2010 OpenCFD Ltd.
00006      \\/     M anipulation  |
00007 -------------------------------------------------------------------------------
00008 License
00009     This file is part of OpenFOAM.
00010 
00011     OpenFOAM is free software: you can redistribute it and/or modify it
00012     under the terms of the GNU General Public License as published by
00013     the Free Software Foundation, either version 3 of the License, or
00014     (at your option) any later version.
00015 
00016     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
00017     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00019     for more details.
00020 
00021     You should have received a copy of the GNU General Public License
00022     along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
00023 
00024 \*---------------------------------------------------------------------------*/
00025 
00026 #include <finiteVolume/volFields.H>
00027 #include <finiteVolume/surfaceFields.H>
00028 #include <finiteVolume/fvcGrad.H>
00029 #include <finiteVolume/coupledFvPatchFields.H>
00030 #include <finiteVolume/surfaceInterpolate.H>
00031 
00032 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00033 
00034 namespace Foam
00035 {
00036 
00037 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00038 
00039 template<class Type, class PhiLimiter>
00040 tmp<surfaceScalarField> PhiScheme<Type, PhiLimiter>::limiter
00041 (
00042     const GeometricField<Type, fvPatchField, volMesh>& phi
00043 ) const
00044 {
00045     const fvMesh& mesh = this->mesh();
00046 
00047     tmp<surfaceScalarField> tLimiter
00048     (
00049         new surfaceScalarField
00050         (
00051             IOobject
00052             (
00053                 "PhiLimiter",
00054                 mesh.time().timeName(),
00055                 mesh
00056             ),
00057             mesh,
00058             dimless
00059         )
00060     );
00061     surfaceScalarField& Limiter = tLimiter();
00062 
00063     const surfaceScalarField& CDweights = mesh.surfaceInterpolation::weights();
00064 
00065     const surfaceVectorField& Sf = mesh.Sf();
00066     const surfaceScalarField& magSf = mesh.magSf();
00067 
00068     const unallocLabelList& owner = mesh.owner();
00069     const unallocLabelList& neighbour = mesh.neighbour();
00070 
00071     tmp<surfaceScalarField> tUflux = this->faceFlux_;
00072 
00073     if (this->faceFlux_.dimensions() == dimDensity*dimVelocity*dimArea)
00074     {
00075         const volScalarField& rho = 
00076             phi.db().objectRegistry::lookupObject<volScalarField>("rho");
00077         tUflux = this->faceFlux_/fvc::interpolate(rho);
00078     }
00079     else if (this->faceFlux_.dimensions() != dimVelocity*dimArea)
00080     {
00081         FatalErrorIn
00082         (
00083             "PhiScheme<PhiLimiter>::limiter"
00084             "(const GeometricField<Type, fvPatchField, volMesh>& phi)"
00085         )   << "dimensions of faceFlux are not correct"
00086             << exit(FatalError);
00087     }
00088 
00089     const surfaceScalarField& Uflux = tUflux();
00090 
00091     scalarField& pLimiter = Limiter.internalField();
00092 
00093     forAll(pLimiter, face)
00094     {
00095         pLimiter[face] = PhiLimiter::limiter
00096         (
00097             CDweights[face],
00098             Uflux[face],
00099             phi[owner[face]],
00100             phi[neighbour[face]],
00101             Sf[face],
00102             magSf[face]
00103         );
00104     }
00105 
00106 
00107     surfaceScalarField::GeometricBoundaryField& bLimiter =
00108         Limiter.boundaryField();
00109 
00110     forAll(bLimiter, patchI)
00111     {
00112         scalarField& pLimiter = bLimiter[patchI];
00113 
00114         if (bLimiter[patchI].coupled())
00115         {
00116             const scalarField& pCDweights = CDweights.boundaryField()[patchI];
00117             const vectorField& pSf = Sf.boundaryField()[patchI];
00118             const scalarField& pmagSf = magSf.boundaryField()[patchI];
00119             const scalarField& pFaceFlux = Uflux.boundaryField()[patchI];
00120             Field<Type> pphiP =
00121                 phi.boundaryField()[patchI].patchInternalField();
00122             Field<Type> pphiN =
00123                 phi.boundaryField()[patchI].patchNeighbourField();
00124 
00125             forAll(pLimiter, face)
00126             {
00127                 pLimiter[face] = PhiLimiter::limiter
00128                 (
00129                     pCDweights[face],
00130                     pFaceFlux[face],
00131                     pphiP[face],
00132                     pphiN[face],
00133                     pSf[face],
00134                     pmagSf[face]
00135                 );
00136             }
00137         }
00138         else
00139         {
00140             pLimiter = 1.0;
00141         }
00142     }
00143 
00144     return tLimiter;
00145 }
00146 
00147 
00148 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00149 
00150 } // End namespace Foam
00151 
00152 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines