snappyLayerDriverTemplates.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-2018 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 "snappyLayerDriver.H"
27 #include "syncTools.H"
28 
29 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
30 
31 template<class Type>
32 void Foam::snappyLayerDriver::averageNeighbours
33 (
34  const polyMesh& mesh,
35  const PackedBoolList& isMasterEdge,
36  const labelList& meshEdges,
37  const labelList& meshPoints,
38  const edgeList& edges,
39  const scalarField& invSumWeight,
40  const Field<Type>& data,
41  Field<Type>& average
42 )
43 {
44  const pointField& pts = mesh.points();
45 
46  average = Zero;
47 
48  forAll(edges, edgeI)
49  {
50  if (isMasterEdge.get(meshEdges[edgeI]) == 1)
51  {
52  const edge& e = edges[edgeI];
53  // scalar eWeight = edgeWeights[edgeI];
54  // scalar eWeight = 1.0;
55  scalar eMag = max
56  (
57  vSmall,
58  mag
59  (
60  pts[meshPoints[e[1]]]
61  - pts[meshPoints[e[0]]]
62  )
63  );
64  scalar eWeight = 1.0/eMag;
65 
66  label v0 = e[0];
67  label v1 = e[1];
68 
69  average[v0] += eWeight*data[v1];
70  average[v1] += eWeight*data[v0];
71  }
72  }
73 
75  (
76  mesh,
77  meshPoints,
78  average,
79  plusEqOp<Type>(),
80  Zero // null value
81  );
82 
83  average *= invSumWeight;
84 }
85 
86 
87 // ************************************************************************* //
#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
dimensioned< Type > max(const dimensioned< Type > &, const dimensioned< Type > &)
vectorField pointField
pointField is a vectorField.
Definition: pointFieldFwd.H:42
List< edge > edgeList
Definition: edgeList.H:38
List< label > labelList
A List of labels.
Definition: labelList.H:56
static const zero Zero
Definition: zero.H:97
volScalarField scalarField(fieldObject, mesh)
static void syncPointList(const polyMesh &, List< T > &, const CombineOp &cop, const T &nullValue, const TransformOp &top)
Synchronise values on all mesh points.
dimensioned< scalar > mag(const dimensioned< Type > &)
const doubleScalar e
Elementary charge.
Definition: doubleScalar.H:105