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

fvcAverage.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 "fvcAverage.H"
00027 #include "fvcSurfaceIntegrate.H"
00028 #include <finiteVolume/fvMesh.H>
00029 #include <finiteVolume/linear.H>
00030 
00031 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00032 
00033 namespace Foam
00034 {
00035 
00036 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00037 
00038 namespace fvc
00039 {
00040 
00041 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00042 
00043 template<class Type>
00044 tmp<GeometricField<Type, fvPatchField, volMesh> >
00045 average
00046 (
00047     const GeometricField<Type, fvsPatchField, surfaceMesh>& ssf
00048 )
00049 {
00050     const fvMesh& mesh = ssf.mesh();
00051 
00052     tmp<GeometricField<Type, fvPatchField, volMesh> > taverage
00053     (
00054         new GeometricField<Type, fvPatchField, volMesh>
00055         (
00056             IOobject
00057             (
00058                 "average("+ssf.name()+')',
00059                 ssf.instance(),
00060                 mesh,
00061                 IOobject::NO_READ,
00062                 IOobject::NO_WRITE
00063             ),
00064             mesh,
00065             ssf.dimensions()
00066         )
00067     );
00068 
00069     GeometricField<Type, fvPatchField, volMesh>& av = taverage();
00070 
00071     av.internalField() = 
00072     (
00073         surfaceSum(mesh.magSf()*ssf)/surfaceSum(mesh.magSf())
00074     )().internalField();
00075 
00076     forAll(av.boundaryField(), patchi)
00077     {
00078         av.boundaryField()[patchi] = ssf.boundaryField()[patchi];
00079     }
00080 
00081     av.correctBoundaryConditions();
00082 
00083     return taverage;
00084 }
00085 
00086 
00087 template<class Type>
00088 tmp<GeometricField<Type, fvPatchField, volMesh> >
00089 average
00090 (
00091     const tmp<GeometricField<Type, fvsPatchField, surfaceMesh> >& tssf
00092 )
00093 {
00094     tmp<GeometricField<Type, fvPatchField, volMesh> > taverage
00095     (
00096         fvc::average(tssf())
00097     );
00098     tssf.clear();
00099     return taverage;
00100 }
00101 
00102 
00103 template<class Type>
00104 tmp<GeometricField<Type, fvPatchField, volMesh> >
00105 average
00106 (
00107     const GeometricField<Type, fvPatchField, volMesh>& vtf
00108 )
00109 {
00110     return fvc::average(linearInterpolate(vtf));
00111 }
00112 
00113 
00114 template<class Type> 
00115 tmp<GeometricField<Type, fvPatchField, volMesh> >
00116 average
00117 (
00118     const tmp<GeometricField<Type, fvPatchField, volMesh> >& tvtf
00119 )
00120 {
00121     tmp<GeometricField<Type, fvPatchField, volMesh> > taverage
00122     (
00123         fvc::average(tvtf())
00124     );
00125     tvtf.clear();
00126     return taverage;
00127 }
00128 
00129 
00130 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00131 
00132 } // End namespace fvc
00133 
00134 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00135 
00136 } // End namespace Foam
00137 
00138 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines