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