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

pointLinear.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) 2004-2011 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 "pointLinear.H"
00027 #include <finiteVolume/fvMesh.H>
00028 #include <finiteVolume/volPointInterpolation.H>
00029 
00030 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00031 
00032 template<class Type>
00033 Foam::tmp<Foam::GeometricField<Type, Foam::fvsPatchField, Foam::surfaceMesh> >
00034 Foam::pointLinear<Type>::
00035 correction
00036 (
00037     const GeometricField<Type, fvPatchField, volMesh>& vf
00038 ) const
00039 {
00040     const fvMesh& mesh = this->mesh();
00041 
00042     GeometricField<Type, pointPatchField, pointMesh> pvf =
00043         volPointInterpolation::New(mesh).interpolate(vf);
00044 
00045     tmp<GeometricField<Type, fvsPatchField, surfaceMesh> > tsfCorr =
00046         linearInterpolate(vf);
00047 
00048     Field<Type>& sfCorr = tsfCorr().internalField();
00049 
00050     const pointField& points = mesh.points();
00051     const pointField& C = mesh.C().internalField();
00052     const faceList& faces = mesh.faces();
00053     const scalarField& w = mesh.weights().internalField();
00054     const labelList& owner = mesh.owner();
00055     const labelList& neighbour = mesh.neighbour();
00056 
00057     forAll(sfCorr, facei)
00058     {
00059         point pi =
00060             w[owner[facei]]*C[owner[facei]]
00061           + (1.0 - w[owner[facei]])*C[neighbour[facei]];
00062 
00063         scalar at = triangle<point, const point&>
00064         (
00065             pi,
00066             points[faces[facei][0]],
00067             points[faces[facei][faces[facei].size()-1]]
00068         ).mag();
00069 
00070         scalar sumAt = at;
00071         Type sumPsip = at*(1.0/3.0)*
00072         (
00073             sfCorr[facei]
00074           + pvf[faces[facei][0]]
00075           + pvf[faces[facei][faces[facei].size()-1]]
00076         );
00077 
00078         for (label pointi=1; pointi<faces[facei].size(); pointi++)
00079         {
00080             at = triangle<point, const point&>
00081             (
00082                 pi,
00083                 points[faces[facei][pointi]],
00084                 points[faces[facei][pointi-1]]
00085             ).mag();
00086 
00087             sumAt += at;
00088             sumPsip += at*(1.0/3.0)*
00089             (
00090                 sfCorr[facei]
00091               + pvf[faces[facei][pointi]]
00092               + pvf[faces[facei][pointi-1]]
00093             );
00094 
00095         }
00096 
00097         sfCorr[facei] = sumPsip/sumAt - sfCorr[facei];
00098     }
00099 
00100     tsfCorr().boundaryField() = pTraits<Type>::zero;
00101 
00102     return tsfCorr;
00103 }
00104 
00105 
00106 namespace Foam
00107 {
00108     makeSurfaceInterpolationScheme(pointLinear);
00109 }
00110 
00111 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines