initial commit for version 1.6.x patch release
[OpenFOAM-1.6.x.git] / src / finiteVolume / finiteVolume / fvc / fvcAverage.C
blob6f59b61631c82419c799139772e8a495992096cd
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 1991-2009 OpenCFD Ltd.
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
9     This file is part of OpenFOAM.
11     OpenFOAM is free software; you can redistribute it and/or modify it
12     under the terms of the GNU General Public License as published by the
13     Free Software Foundation; either version 2 of the License, or (at your
14     option) any later version.
16     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
19     for more details.
21     You should have received a copy of the GNU General Public License
22     along with OpenFOAM; if not, write to the Free Software Foundation,
23     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 \*---------------------------------------------------------------------------*/
27 #include "fvcAverage.H"
28 #include "fvcSurfaceIntegrate.H"
29 #include "fvMesh.H"
30 #include "linear.H"
32 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
34 namespace Foam
37 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
39 namespace fvc
42 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
44 template<class Type>
45 tmp<GeometricField<Type, fvPatchField, volMesh> >
46 average
48     const GeometricField<Type, fvsPatchField, surfaceMesh>& ssf
51     const fvMesh& mesh = ssf.mesh();
53     tmp<GeometricField<Type, fvPatchField, volMesh> > taverage
54     (
55         new GeometricField<Type, fvPatchField, volMesh>
56         (
57             IOobject
58             (
59                 "average("+ssf.name()+')',
60                 ssf.instance(),
61                 mesh,
62                 IOobject::NO_READ,
63                 IOobject::NO_WRITE
64             ),
65             mesh,
66             ssf.dimensions()
67         )
68     );
70     GeometricField<Type, fvPatchField, volMesh>& av = taverage();
72     av.internalField() = 
73     (
74         surfaceSum(mesh.magSf()*ssf)/surfaceSum(mesh.magSf())
75     )().internalField();
77     forAll(av.boundaryField(), patchi)
78     {
79         av.boundaryField()[patchi] = ssf.boundaryField()[patchi];
80     }
82     av.correctBoundaryConditions();
84     return taverage;
88 template<class Type>
89 tmp<GeometricField<Type, fvPatchField, volMesh> >
90 average
92     const tmp<GeometricField<Type, fvsPatchField, surfaceMesh> >& tssf
95     tmp<GeometricField<Type, fvPatchField, volMesh> > taverage
96     (
97         fvc::average(tssf())
98     );
99     tssf.clear();
100     return taverage;
104 template<class Type>
105 tmp<GeometricField<Type, fvPatchField, volMesh> >
106 average
108     const GeometricField<Type, fvPatchField, volMesh>& vtf
111     return fvc::average(linearInterpolate(vtf));
115 template<class Type> 
116 tmp<GeometricField<Type, fvPatchField, volMesh> >
117 average
119     const tmp<GeometricField<Type, fvPatchField, volMesh> >& tvtf
122     tmp<GeometricField<Type, fvPatchField, volMesh> > taverage
123     (
124         fvc::average(tvtf())
125     );
126     tvtf.clear();
127     return taverage;
131 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
133 } // End namespace fvc
135 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
137 } // End namespace Foam
139 // ************************************************************************* //