linearUpwind.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 | Copyright (C) 2011-2016 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 #include "fvMesh.H"
28 
29 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
30 
31 template<class Type>
34 (
36 ) const
37 {
38  const fvMesh& mesh = this->mesh();
39 
41  (
43  (
44  IOobject
45  (
46  "linearUpwind::correction(" + vf.name() + ')',
47  mesh.time().timeName(),
48  mesh,
49  IOobject::NO_READ,
50  IOobject::NO_WRITE,
51  false
52  ),
53  mesh,
55  )
56  );
57 
59 
60  const surfaceScalarField& faceFlux = this->faceFlux_;
61 
62  const labelList& owner = mesh.owner();
63  const labelList& neighbour = mesh.neighbour();
64 
65  const volVectorField& C = mesh.C();
66  const surfaceVectorField& Cf = mesh.Cf();
67 
68  tmp
69  <
71  <
74  volMesh
75  >
76  > tgradVf = gradScheme_().grad(vf, gradSchemeName_);
77 
78  const GeometricField
79  <
80  typename outerProduct<vector, Type>::type,
81  fvPatchField,
82  volMesh
83  >& gradVf = tgradVf();
84 
85  forAll(faceFlux, facei)
86  {
87  label celli = (faceFlux[facei] > 0) ? owner[facei] : neighbour[facei];
88  sfCorr[facei] = (Cf[facei] - C[celli]) & gradVf[celli];
89  }
90 
91 
93  Boundary& bSfCorr = sfCorr.boundaryFieldRef();
94 
95  forAll(bSfCorr, patchi)
96  {
97  fvsPatchField<Type>& pSfCorr = bSfCorr[patchi];
98 
99  if (pSfCorr.coupled())
100  {
101  const labelUList& pOwner =
102  mesh.boundary()[patchi].faceCells();
103 
104  const vectorField& pCf = Cf.boundaryField()[patchi];
105 
106  const scalarField& pFaceFlux = faceFlux.boundaryField()[patchi];
107 
109  (
110  gradVf.boundaryField()[patchi].patchNeighbourField()
111  );
112 
113  // Build the d-vectors
114  vectorField pd(Cf.boundaryField()[patchi].patch().delta());
115 
116  forAll(pOwner, facei)
117  {
118  label own = pOwner[facei];
119 
120  if (pFaceFlux[facei] > 0)
121  {
122  pSfCorr[facei] = (pCf[facei] - C[own]) & gradVf[own];
123  }
124  else
125  {
126  pSfCorr[facei] =
127  (pCf[facei] - pd[facei] - C[own]) & pGradVfNei[facei];
128  }
129  }
130  }
131  }
132 
133  return tsfCorr;
134 }
135 
136 
137 namespace Foam
138 {
139  //makelimitedSurfaceInterpolationScheme(linearUpwind)
142 }
143 
144 // ************************************************************************* //
Graphite solid properties.
Definition: C.H:57
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:428
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
const surfaceVectorField & Cf() const
Return face centres as surfaceVectorField.
Abstract base class with a fat-interface to all derived classes covering all possible ways in which t...
Definition: fvPatchField.H:65
typeOfRank< typename pTraits< arg1 >::cmptType, direction(pTraits< arg1 >::rank)+direction(pTraits< arg2 >::rank) >::type type
Definition: products.H:90
Generic GeometricField class.
static word timeName(const scalar, const int precision=precision_)
Return time name of given scalar time.
Definition: Time.C:715
virtual tmp< GeometricField< Type, fvsPatchField, surfaceMesh > > correction(const GeometricField< Type, fvPatchField, volMesh > &) const
Return the explicit correction to the face-interpolate.
Definition: linearUpwind.C:34
Generic dimensioned Type class.
const volVectorField & C() const
Return cell centres as volVectorField.
virtual bool coupled() const
Return true if this patch field is coupled.
Mesh data needed to do the Finite Volume discretisation.
Definition: volMesh.H:53
dynamicFvMesh & mesh
const Boundary & boundaryField() const
Return const-reference to the boundary field.
const labelUList & neighbour() const
Internal face neighbour.
Definition: fvMesh.H:288
static const zero Zero
Definition: zero.H:91
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
Definition: HashTable.H:60
const dimensionSet & dimensions() const
Return dimensions.
Internal & ref()
Return a reference to the dimensioned internal field.
label patchi
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:78
linearUpwind interpolation scheme class derived from upwind and returns upwind weighting factors and ...
Definition: linearUpwind.H:52
const labelUList & owner() const
Internal face owner.
Definition: fvMesh.H:282
A class for managing temporary objects.
Definition: PtrList.H:54
#define makelimitedSurfaceInterpolationTypeScheme(SS, Type)
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:91
const fvBoundaryMesh & boundary() const
Return reference to boundary mesh.
Definition: fvMesh.C:545
An abstract base class with a fat-interface to all derived classes covering all possible ways in whic...
Definition: fvsPatchField.H:65
const word & name() const
Return name.
Definition: IOobject.H:260
Namespace for OpenFOAM.
const Time & time() const
Return the top-level database.
Definition: fvMesh.H:243