1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright held by original author
7 -------------------------------------------------------------------------------
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
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 "reconCentral.H"
30 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
33 Foam::tmp<Foam::GeometricField<Type, Foam::fvsPatchField, Foam::surfaceMesh> >
34 Foam::reconCentral<Type>::interpolate
36 const GeometricField<Type, fvPatchField, volMesh>& vf
39 const fvMesh& mesh = this->mesh();
41 tmp<GeometricField<Type, fvsPatchField, surfaceMesh> > tsf
43 new GeometricField<Type, fvsPatchField, surfaceMesh>
47 "interpolate("+vf.name()+')',
52 dimensioned<Type>(vf.name(), vf.dimensions(), pTraits<Type>::zero)
56 GeometricField<Type, fvsPatchField, surfaceMesh>& sf = tsf();
58 const labelList& owner = mesh.owner();
59 const labelList& neighbour = mesh.neighbour();
61 const volVectorField& C = mesh.C();
62 const surfaceVectorField& Cf = mesh.Cf();
65 <typename outerProduct<vector, Type>::type, fvPatchField, volMesh>
66 gradVf = gradScheme_().grad(vf);
68 // Note: in order for the patchNeighbourField to be correct on coupled
69 // boundaries, correctBoundaryConditions needs to be called.
70 // The call shall be moved into the library fvc operators
71 gradVf.correctBoundaryConditions();
73 Field<Type>& sfIn = sf.internalField();
78 label own = owner[facei];
79 sfIn[facei] += 0.5*(vf[own] + ((Cf[facei] - C[own]) & gradVf[own]));
81 // Neighbour contribution
82 label nei = neighbour[facei];
83 sfIn[facei] += 0.5*(vf[nei] + ((Cf[facei] - C[nei]) & gradVf[nei]));
87 typename GeometricField<Type, fvsPatchField, surfaceMesh>::
88 GeometricBoundaryField& bSf = sf.boundaryField();
92 const fvPatch& p = mesh.boundary()[patchi];
94 fvsPatchField<Type>& pSf = bSf[patchi];
96 const unallocLabelList& pOwner = p.faceCells();
98 const vectorField& pCf = Cf.boundaryField()[patchi];
103 vf.boundaryField()[patchi].patchNeighbourField();
105 Field<typename outerProduct<vector, Type>::type> pGradVfNei =
106 gradVf.boundaryField()[patchi].patchNeighbourField();
108 // Build the d-vectors. Used to calculate neighbour face centre
110 // Better version of d-vectors: Zeljko Tukovic, 25/Apr/2010
111 vectorField pd = p.delta();
113 forAll(pOwner, facei)
115 label own = pOwner[facei];
117 // Owner contribution
119 0.5*(vf[own] + ((pCf[facei] - C[own]) & gradVf[own]));
121 // Neighbour contribution
127 (pCf[facei] - pd[facei] - C[own])
133 else if (vf.boundaryField()[patchi].fixesValue())
135 // For fixed boundary patches copy the value
136 pSf = vf.boundaryField()[patchi];
140 // For patches that do not fix the value, calculate
141 // extrapolated field
142 forAll(pOwner, facei)
144 label own = pOwner[facei];
147 (vf[own] + ((pCf[facei] - C[own]) & gradVf[own]));
157 Foam::tmp<Foam::GeometricField<Type, Foam::fvsPatchField, Foam::surfaceMesh> >
158 Foam::reconCentral<Type>::correction
160 const GeometricField<Type, fvPatchField, volMesh>& vf
163 // Note: Correction is calculated by assembling the complete interpolation
164 // including extrapolated gradient contribution and subtracting the
165 // implicit contribution. HJ, 27/Mar/2010
166 const fvMesh& mesh = this->mesh();
168 tmp<GeometricField<Type, fvsPatchField, surfaceMesh> > tsfCorr
170 new GeometricField<Type, fvsPatchField, surfaceMesh>
174 "reconCentralCorrection(" + vf.name() + ')',
175 mesh.time().timeName(),
181 reconCentral<Type>::interpolate(vf)
182 - surfaceInterpolationScheme<Type>::interpolate
196 //makelimitedSurfaceInterpolationScheme(reconCentral)
197 makelimitedSurfaceInterpolationTypeScheme(reconCentral, scalar)
198 makelimitedSurfaceInterpolationTypeScheme(reconCentral, vector)
201 // ************************************************************************* //