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

fvcSurfaceIntegrate.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 "fvcSurfaceIntegrate.H"
00027 #include <finiteVolume/fvMesh.H>
00028 #include <finiteVolume/zeroGradientFvPatchFields.H>
00029 
00030 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00031 
00032 namespace Foam
00033 {
00034 
00035 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00036 
00037 namespace fvc
00038 {
00039 
00040 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00041 
00042 template<class Type>
00043 void surfaceIntegrate
00044 (
00045     Field<Type>& ivf,
00046     const GeometricField<Type, fvsPatchField, surfaceMesh>& ssf
00047 )
00048 {
00049     const fvMesh& mesh = ssf.mesh();
00050 
00051     const unallocLabelList& owner = mesh.owner();
00052     const unallocLabelList& neighbour = mesh.neighbour();
00053 
00054     const Field<Type>& issf = ssf;
00055 
00056     forAll(owner, facei)
00057     {
00058         ivf[owner[facei]] += issf[facei];
00059         ivf[neighbour[facei]] -= issf[facei];
00060     }
00061 
00062     forAll(mesh.boundary(), patchi)
00063     {
00064         const unallocLabelList& pFaceCells =
00065             mesh.boundary()[patchi].faceCells();
00066 
00067         const fvsPatchField<Type>& pssf = ssf.boundaryField()[patchi];
00068 
00069         forAll(mesh.boundary()[patchi], facei)
00070         {
00071             ivf[pFaceCells[facei]] += pssf[facei];
00072         }
00073     }
00074 
00075     ivf /= mesh.V();
00076 }
00077 
00078 
00079 template<class Type>
00080 tmp<GeometricField<Type, fvPatchField, volMesh> >
00081 surfaceIntegrate
00082 (
00083     const GeometricField<Type, fvsPatchField, surfaceMesh>& ssf
00084 )
00085 {
00086     const fvMesh& mesh = ssf.mesh();
00087 
00088     tmp<GeometricField<Type, fvPatchField, volMesh> > tvf
00089     (
00090         new GeometricField<Type, fvPatchField, volMesh>
00091         (
00092             IOobject
00093             (
00094                 "surfaceIntegrate("+ssf.name()+')',
00095                 ssf.instance(),
00096                 mesh,
00097                 IOobject::NO_READ,
00098                 IOobject::NO_WRITE
00099             ),
00100             mesh,
00101             dimensioned<Type>
00102             (
00103                 "0",
00104                 ssf.dimensions()/dimVol,
00105                 pTraits<Type>::zero
00106             ),
00107             zeroGradientFvPatchField<Type>::typeName
00108         )
00109     );
00110     GeometricField<Type, fvPatchField, volMesh>& vf = tvf();
00111 
00112     surfaceIntegrate(vf.internalField(), ssf);
00113     vf.correctBoundaryConditions();
00114 
00115     return tvf;
00116 }
00117 
00118 
00119 template<class Type>
00120 tmp<GeometricField<Type, fvPatchField, volMesh> >
00121 surfaceIntegrate
00122 (
00123     const tmp<GeometricField<Type, fvsPatchField, surfaceMesh> >& tssf
00124 )
00125 {
00126     tmp<GeometricField<Type, fvPatchField, volMesh> > tvf
00127     (
00128         fvc::surfaceIntegrate(tssf())
00129     );
00130     tssf.clear();
00131     return tvf;
00132 }
00133 
00134 
00135 template<class Type>
00136 tmp<GeometricField<Type, fvPatchField, volMesh> >
00137 surfaceSum
00138 (
00139     const GeometricField<Type, fvsPatchField, surfaceMesh>& ssf
00140 )
00141 {
00142     const fvMesh& mesh = ssf.mesh();
00143 
00144     tmp<GeometricField<Type, fvPatchField, volMesh> > tvf
00145     (
00146         new GeometricField<Type, fvPatchField, volMesh>
00147         (
00148             IOobject
00149             (
00150                 "surfaceSum("+ssf.name()+')',
00151                 ssf.instance(),
00152                 mesh,
00153                 IOobject::NO_READ,
00154                 IOobject::NO_WRITE
00155             ),
00156             mesh,
00157             dimensioned<Type>("0", ssf.dimensions(), pTraits<Type>::zero),
00158             zeroGradientFvPatchField<Type>::typeName
00159         )
00160     );
00161     GeometricField<Type, fvPatchField, volMesh>& vf = tvf();
00162 
00163     const unallocLabelList& owner = mesh.owner();
00164     const unallocLabelList& neighbour = mesh.neighbour();
00165 
00166     forAll(owner, facei)
00167     {
00168         vf[owner[facei]] += ssf[facei];
00169         vf[neighbour[facei]] += ssf[facei];
00170     }
00171 
00172     forAll(mesh.boundary(), patchi)
00173     {
00174         const unallocLabelList& pFaceCells =
00175             mesh.boundary()[patchi].faceCells();
00176 
00177         const fvsPatchField<Type>& pssf = ssf.boundaryField()[patchi];
00178 
00179         forAll(mesh.boundary()[patchi], facei)
00180         {
00181             vf[pFaceCells[facei]] += pssf[facei];
00182         }
00183     }
00184 
00185     vf.correctBoundaryConditions();
00186 
00187     return tvf;
00188 }
00189 
00190 
00191 template<class Type>
00192 tmp<GeometricField<Type, fvPatchField, volMesh> > surfaceSum
00193 (
00194     const tmp<GeometricField<Type, fvsPatchField, surfaceMesh> >& tssf
00195 )
00196 {
00197     tmp<GeometricField<Type, fvPatchField, volMesh> > tvf = surfaceSum(tssf());
00198     tssf.clear();
00199     return tvf;
00200 }
00201 
00202 
00203 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00204 
00205 } // End namespace fvc
00206 
00207 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00208 
00209 } // End namespace Foam
00210 
00211 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines