linearUpwindNormal.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2007-2019 PCOpt/NTUA
9  Copyright (C) 2013-2019 FOSS GP
10  Copyright (C) 2019 OpenCFD Ltd.
11 -------------------------------------------------------------------------------
12 License
13  This file is part of OpenFOAM.
14 
15  OpenFOAM is free software: you can redistribute it and/or modify it
16  under the terms of the GNU General Public License as published by
17  the Free Software Foundation, either version 3 of the License, or
18  (at your option) any later version.
19 
20  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
21  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
22  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
23  for more details.
24 
25  You should have received a copy of the GNU General Public License
26  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
27 
28 \*---------------------------------------------------------------------------*/
29 
30 #include "linearUpwindNormal.H"
31 #include "fvMesh.H"
32 
33 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
34 
35 template<class Type>
38 (
40 ) const
41 {
42  const fvMesh& mesh = this->mesh();
43 
45  (
47  (
48  IOobject
49  (
50  "linearUpwind::correction(" + vf.name() + ')',
51  mesh.time().timeName(),
52  mesh,
53  IOobject::NO_READ,
54  IOobject::NO_WRITE,
55  false
56  ),
57  mesh,
58  dimensioned<Type>(vf.dimensions(), Zero)
59  )
60  );
61 
63 
64  const surfaceScalarField& faceFlux = this->faceFlux_;
65 
66  const labelList& owner = mesh.owner();
67  const labelList& neighbour = mesh.neighbour();
68 
69  const volVectorField& C = mesh.C();
70  const surfaceVectorField& Cf = mesh.Cf();
71 
72  tmp
73  <
75  <
78  volMesh
79  >
80  > tgradVf = gradScheme_().grad(vf, gradSchemeName_);
81 
83  <
86  volMesh
87  >& gradVf = tgradVf();
88  gradVf /= mag(gradVf) + 1.e-12;
89 
90  forAll(faceFlux, facei)
91  {
92  label celli = (faceFlux[facei] > 0) ? owner[facei] : neighbour[facei];
93  sfCorr[facei] = (Cf[facei] - C[celli]) & gradVf[celli];
94  }
95 
96 
98  GeometricBoundaryField& bSfCorr = sfCorr.boundaryField();
99 
100  forAll(bSfCorr, patchi)
101  {
102  fvsPatchField<Type>& pSfCorr = bSfCorr[patchi];
103 
104  if (pSfCorr.coupled())
105  {
106  const labelUList& pOwner =
107  mesh.boundary()[patchi].faceCells();
108 
109  const vectorField& pCf = Cf.boundaryField()[patchi];
110 
111  const scalarField& pFaceFlux = faceFlux.boundaryField()[patchi];
112 
114  (
115  gradVf.boundaryField()[patchi].patchNeighbourField()
116  );
117 
118  // Build the d-vectors
119  vectorField pd(Cf.boundaryField()[patchi].patch().delta());
120 
121  forAll(pOwner, facei)
122  {
123  label own = pOwner[facei];
124 
125  if (pFaceFlux[facei] > 0)
126  {
127  pSfCorr[facei] = (pCf[facei] - C[own]) & gradVf[own];
128  }
129  else
130  {
131  pSfCorr[facei] =
132  (pCf[facei] - pd[facei] - C[own]) & pGradVfNei[facei];
133  }
134  }
135  }
136  }
137 
138  return tsfCorr;
139 }
140 
141 
142 namespace Foam
143 {
144  //makelimitedSurfaceInterpolationScheme(linearUpwindNormal)
147 }
148 
149 // ************************************************************************* //
Foam::fvPatchField
Abstract base class with a fat-interface to all derived classes covering all possible ways in which t...
Definition: volSurfaceMapping.H:51
Foam::IOobject
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:169
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:61
Foam::Zero
static constexpr const zero Zero
Global zero (0)
Definition: zero.H:131
Foam::volMesh
Mesh data needed to do the Finite Volume discretisation.
Definition: volMesh.H:51
Foam::outerProduct::type
typeOfRank< typename pTraits< arg1 >::cmptType, direction(pTraits< arg1 >::rank)+direction(pTraits< arg2 >::rank) >::type type
Definition: products.H:114
Foam::fvsPatchField
An abstract base class with a fat-interface to all derived classes covering all possible ways in whic...
Definition: fvsPatchField.H:68
Foam::linearUpwindNormal::correction
virtual tmp< GeometricField< Type, fvsPatchField, surfaceMesh > > correction(const GeometricField< Type, fvPatchField, volMesh > &) const
Return the explicit correction to the face-interpolate.
Definition: linearUpwindNormal.C:38
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:296
Foam::Field< vector >
makelimitedSurfaceInterpolationTypeScheme
#define makelimitedSurfaceInterpolationTypeScheme(SS, Type)
Definition: limitedSurfaceInterpolationScheme.H:207
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:6
Foam::dimensioned
Generic dimensioned Type class.
Definition: dimensionedScalarFwd.H:42
Foam::fvMesh
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:85
fvMesh.H
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::linearUpwindNormal
linearUpwindNormal interpolation scheme class derived from upwind and returns upwind weighting factor...
Definition: linearUpwindNormal.H:57
Foam::Vector< scalar >
Foam::List< label >
linearUpwindNormal.H
Foam::mag
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
Foam::UList< label >
Foam::C
Graphite solid properties.
Definition: C.H:50
Foam::GeometricField< Type, fvPatchField, volMesh >
Foam::fvsPatchField::coupled
virtual bool coupled() const
Return true if this patch field is coupled.
Definition: fvsPatchField.H:310
Foam::GeometricField::boundaryField
const Boundary & boundaryField() const
Return const-reference to the boundary field.
Definition: GeometricFieldI.H:62