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 "linearUpwindV.H"
29 #include "volFields.H"
30 #include "surfaceFields.H"
32 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
35 Foam::tmp<Foam::GeometricField<Type, Foam::fvsPatchField, Foam::surfaceMesh> >
36 Foam::linearUpwindV<Type>::correction
38 const GeometricField<Type, fvPatchField, volMesh>& vf
41 const fvMesh& mesh = this->mesh();
43 tmp<GeometricField<Type, fvsPatchField, surfaceMesh> > tsfCorr
45 new GeometricField<Type, fvsPatchField, surfaceMesh>
50 mesh.time().timeName(),
63 GeometricField<Type, fvsPatchField, surfaceMesh>& sfCorr = tsfCorr();
65 const surfaceScalarField& faceFlux = this->faceFlux_;
66 const surfaceScalarField& w = mesh.weights();
68 const labelList& own = mesh.owner();
69 const labelList& nei = mesh.neighbour();
71 const vectorField& C = mesh.C();
72 const vectorField& Cf = mesh.Cf();
75 <typename outerProduct<vector, Type>::type, fvPatchField, volMesh>
76 gradVf = gradScheme_().grad(vf);
78 // Note: in order for the patchNeighbourField to be correct on coupled
79 // boundaries, correctBoundaryConditions needs to be called.
80 // The call shall be moved into the library fvc operators
81 gradVf.correctBoundaryConditions();
83 forAll(faceFlux, facei)
87 if (faceFlux[facei] > 0.0)
91 *(vf[nei[facei]] - vf[own[facei]]);
94 (Cf[facei] - C[own[facei]]) & gradVf[own[facei]];
99 w[facei]*(vf[own[facei]] - vf[nei[facei]]);
102 (Cf[facei] - C[nei[facei]]) & gradVf[nei[facei]];
105 scalar sfCorrs = magSqr(sfCorr[facei]);
106 scalar maxCorrs = sfCorr[facei] & maxCorr;
112 sfCorr[facei] = vector::zero;
114 else if (sfCorrs > maxCorrs)
116 sfCorr[facei] *= maxCorrs/(sfCorrs + VSMALL);
119 else if (sfCorrs < 0)
123 sfCorr[facei] = vector::zero;
125 else if (sfCorrs < maxCorrs)
127 sfCorr[facei] *= maxCorrs/(sfCorrs - VSMALL);
138 makelimitedSurfaceInterpolationTypeScheme(linearUpwindV, vector)
141 // ************************************************************************* //