linearUpwind.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2026 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
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
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
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.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
26 #include "linearUpwind.H"
27 
28 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
29 
30 template<>
33 (
34  const volVectorField& vf
35 ) const
36 {
37  const fvMesh& mesh = this->mesh();
38 
40  (
42  (
43  "linearUpwind::correction(" + vf.name() + ')',
44  mesh,
46  )
47  );
48 
49  surfaceVectorField& sfCorr = tsfCorr.ref();
50 
51  const surfaceScalarField& faceFlux = this->faceFlux_;
52 
53  const labelList& owner = mesh.owner();
54  const labelList& neighbour = mesh.neighbour();
55 
56  const volVectorField& C = mesh.C();
57  const surfaceVectorField& Cf = mesh.Cf();
58 
59  tmp<fv::gradScheme<vector>> gradScheme_
60  (
62  (
63  mesh,
64  mesh.schemes().grad(gradSchemeName_)
65  )
66  );
67 
68  tmp<volTensorField> tgradVf = gradScheme_().grad(vf, gradSchemeName_);
69  const volTensorField& gradVf = tgradVf();
70 
71  forAll(faceFlux, facei)
72  {
73  const label celli =
74  (faceFlux[facei] > 0) ? owner[facei] : neighbour[facei];
75 
76  sfCorr[facei] = (Cf[facei] - C[celli]) & gradVf[celli];
77  }
78 
79 
80  typename surfaceVectorField::Boundary& bSfCorr = sfCorr.boundaryFieldRef();
81 
82  forAll(bSfCorr, patchi)
83  {
84  fvsPatchVectorField& pSfCorr = bSfCorr[patchi];
85 
86  if (pSfCorr.coupled())
87  {
88  const labelUList& pOwner = mesh.boundary()[patchi].faceCells();
89  const vectorField& pCf = Cf.boundaryField()[patchi];
90  const scalarField& pFaceFlux = faceFlux.boundaryField()[patchi];
91 
92  const tensorField pGradVfNei
93  (
94  gradVf.boundaryField()[patchi].patchNeighbourField()
95  );
96 
97  // Build the d-vectors
98  vectorField pd(Cf.boundaryField()[patchi].patch().delta());
99 
100  forAll(pOwner, facei)
101  {
102  const label own = pOwner[facei];
103 
104  if (pFaceFlux[facei] > 0)
105  {
106  pSfCorr[facei] = (pCf[facei] - C[own]) & gradVf[own];
107  }
108  else
109  {
110  pSfCorr[facei] =
111  (pCf[facei] - pd[facei] - C[own]) & pGradVfNei[facei];
112  }
113  }
114  }
115  }
116 
117  return tsfCorr;
118 }
119 
120 
121 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
122 
123 namespace Foam
124 {
126 }
127 
128 // ************************************************************************* //
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:449
Graphite solid properties.
Definition: C.H:51
const dimensionSet & dimensions() const
Return dimensions.
Generic GeometricBoundaryField class.
Generic GeometricField class.
const Boundary & boundaryField() const
Return const-reference to the boundary field.
Boundary & boundaryFieldRef()
Return a reference to the boundary field.
const word & name() const
Return name.
Definition: IOobject.H:307
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:98
const volVectorField & C() const
Return cell centres.
const labelUList & owner() const
Internal face owner.
Definition: fvMesh.H:490
const fvBoundaryMesh & boundary() const
Return reference to boundary mesh.
Definition: fvMesh.C:934
const fvSchemes & schemes() const
Return the fvSchemes.
Definition: fvMesh.C:1795
const surfaceVectorField & Cf() const
Return face centres.
const labelUList & neighbour() const
Internal face neighbour.
Definition: fvMesh.H:496
ITstream & grad(const word &name) const
Definition: fvSchemes.C:416
Abstract base class for gradient schemes.
Definition: gradScheme.H:63
An abstract base class with a fat-interface to all derived classes covering all possible ways in whic...
Definition: fvsPatchField.H:86
virtual bool coupled() const
Return true if this patch field is coupled.
linearUpwind interpolation scheme class derived from upwind and returns upwind weighting factors and ...
Definition: linearUpwind.H:54
virtual tmp< SurfaceField< Type > > correction(const VolField< Type > &) const
Return the explicit correction to the face-interpolate.
A class for managing temporary objects.
Definition: tmp.H:55
T & ref() const
Return non-const reference or generate a fatal error.
Definition: tmpI.H:197
Foam::fvMesh mesh(Foam::IOobject(regionName, runTime.name(), runTime, Foam::IOobject::MUST_READ), false)
label patchi
#define makelimitedSurfaceInterpolationScheme(SS)
Namespace for OpenFOAM.
static const zero Zero
Definition: zero.H:97
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
tmp< DimensionedField< TypeR, GeoMesh, Field > > New(const tmp< DimensionedField< TypeR, GeoMesh, Field >> &tdf1, const word &name, const dimensionSet &dimensions)