extendedUpwindCellToFaceStencilTemplates.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-2019 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 
27 
28 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
29 
30 template<class Type>
33 (
34  const surfaceScalarField& phi,
36  const List<List<scalar>>& ownWeights,
37  const List<List<scalar>>& neiWeights
38 ) const
39 {
40  const fvMesh& mesh = fld.mesh();
41 
42  // Collect internal and boundary values
43  List<List<Type>> ownFld;
44  collectData(ownMap(), ownStencil(), fld, ownFld);
45  List<List<Type>> neiFld;
46  collectData(neiMap(), neiStencil(), fld, neiFld);
47 
49  (
51  (
52  fld.name(),
53  mesh,
55  (
56  fld.name(),
57  fld.dimensions(),
58  Zero
59  )
60  )
61  );
63 
64  // Internal faces
65  for (label facei = 0; facei < mesh.nInternalFaces(); facei++)
66  {
67  if (phi[facei] > 0)
68  {
69  // Flux out of owner. Use upwind (= owner side) stencil.
70  const List<Type>& stField = ownFld[facei];
71  const List<scalar>& stWeight = ownWeights[facei];
72 
73  forAll(stField, i)
74  {
75  sf[facei] += stField[i]*stWeight[i];
76  }
77  }
78  else
79  {
80  const List<Type>& stField = neiFld[facei];
81  const List<scalar>& stWeight = neiWeights[facei];
82 
83  forAll(stField, i)
84  {
85  sf[facei] += stField[i]*stWeight[i];
86  }
87  }
88  }
89 
90  // Boundaries. Either constrained or calculated so assign value
91  // directly (instead of nicely using operator==)
93  Boundary& bSfCorr = sf.boundaryFieldRef();
94 
95  forAll(bSfCorr, patchi)
96  {
97  fvsPatchField<Type>& pSfCorr = bSfCorr[patchi];
98 
99  if (pSfCorr.coupled())
100  {
101  label facei = pSfCorr.patch().start();
102 
103  forAll(pSfCorr, i)
104  {
105  if (phi.boundaryField()[patchi][i] > 0)
106  {
107  // Flux out of owner. Use upwind (= owner side) stencil.
108  const List<Type>& stField = ownFld[facei];
109  const List<scalar>& stWeight = ownWeights[facei];
110 
111  forAll(stField, j)
112  {
113  pSfCorr[i] += stField[j]*stWeight[j];
114  }
115  }
116  else
117  {
118  const List<Type>& stField = neiFld[facei];
119  const List<scalar>& stWeight = neiWeights[facei];
120 
121  forAll(stField, j)
122  {
123  pSfCorr[i] += stField[j]*stWeight[j];
124  }
125  }
126  facei++;
127  }
128  }
129  }
130 
131  return tsfCorr;
132 }
133 
134 
135 // ************************************************************************* //
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:434
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 word & name() const
Return name.
Definition: IOobject.H:303
label nInternalFaces() const
const Boundary & boundaryField() const
Return const-reference to the boundary field.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: HashTable.H:59
Generic dimensioned Type class.
const dimensionSet & dimensions() const
Return dimensions.
dynamicFvMesh & mesh
virtual bool coupled() const
Return true if this patch field is coupled.
static const zero Zero
Definition: zero.H:97
const Mesh & mesh() const
Return mesh.
volScalarField sf(fieldObject, mesh)
const fvPatch & patch() const
Return patch.
tmp< GeometricField< Type, fvsPatchField, surfaceMesh > > weightedSum(const surfaceScalarField &phi, const GeometricField< Type, fvPatchField, volMesh > &fld, const List< List< scalar >> &ownWeights, const List< List< scalar >> &neiWeights) const
Sum vol field contributions to create face values.
label patchi
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:78
A class for managing temporary objects.
Definition: PtrList.H:53
An abstract base class with a fat-interface to all derived classes covering all possible ways in whic...
Definition: fvsPatchField.H:65