FreeFOAM The Cross-Platform CFD Toolkit
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) 1991-2010 OpenCFD Ltd.
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 <finiteVolume/fvMesh.H>
29 
30 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
31 
32 template<class Type>
35 (
37 ) const
38 {
39  const fvMesh& mesh = this->mesh();
40 
42  (
44  (
45  IOobject
46  (
47  "linearUpwindCorrection(" + vf.name() + ')',
48  mesh.time().timeName(),
49  mesh,
50  IOobject::NO_READ,
51  IOobject::NO_WRITE,
52  false
53  ),
54  mesh,
56  )
57  );
58 
60 
61  const surfaceScalarField& faceFlux = this->faceFlux_;
62 
63  const labelList& owner = mesh.owner();
64  const labelList& neighbour = mesh.neighbour();
65 
66  const volVectorField& C = mesh.C();
67  const surfaceVectorField& Cf = mesh.Cf();
68 
71  gradVf = gradScheme_().grad(vf);
72 
73  forAll(faceFlux, facei)
74  {
75  if (faceFlux[facei] > 0)
76  {
77  label own = owner[facei];
78  sfCorr[facei] = (Cf[facei] - C[own]) & gradVf[own];
79  }
80  else
81  {
82  label nei = neighbour[facei];
83  sfCorr[facei] = (Cf[facei] - C[nei]) & gradVf[nei];
84  }
85  }
86 
87 
89  GeometricBoundaryField& bSfCorr = sfCorr.boundaryField();
90 
91  forAll(bSfCorr, patchi)
92  {
93  fvsPatchField<Type>& pSfCorr = bSfCorr[patchi];
94 
95  if (pSfCorr.coupled())
96  {
97  const unallocLabelList& pOwner =
98  mesh.boundary()[patchi].faceCells();
99 
100  const vectorField& pCf = Cf.boundaryField()[patchi];
101 
102  const scalarField& pFaceFlux = faceFlux.boundaryField()[patchi];
103 
105  gradVf.boundaryField()[patchi].patchNeighbourField();
106 
107  // Build the d-vectors
108  vectorField pd =
109  mesh.Sf().boundaryField()[patchi]
110  /(
111  mesh.magSf().boundaryField()[patchi]
112  *mesh.deltaCoeffs().boundaryField()[patchi]
113  );
114 
115  if (!mesh.orthogonal())
116  {
117  pd -= mesh.correctionVectors().boundaryField()[patchi]
118  /mesh.deltaCoeffs().boundaryField()[patchi];
119  }
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(linearUpwind)
147 }
148 
149 // ************************ vim: set sw=4 sts=4 et: ************************ //