autoLayerDriverTemplates.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-2012 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 "autoLayerDriver.H"
27 #include "syncTools.H"
28 
29 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
30 
31 template<class Type>
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,
42 )
43 {
44  const pointField& pts = mesh.points();
45 
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 
74  syncTools::syncPointList
75  (
76  mesh,
77  meshPoints,
78  average,
80  pTraits<Type>::zero // null value
81  );
82 
83  average *= invSumWeight;
84 }
85 
86 
87 // ************************************************************************* //
Foam::PackedBoolList
A bit-packed bool list.
Definition: PackedBoolList.H:63
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:406
Foam::edge
An edge is a list of two point labels. The functionality it provides supports the discretisation on a...
Definition: edge.H:58
Foam::mag
dimensioned< scalar > mag(const dimensioned< Type > &)
Foam::fvc::average
tmp< GeometricField< Type, fvPatchField, volMesh > > average(const GeometricField< Type, fvsPatchField, surfaceMesh > &ssf)
Area-weighted average a surfaceField creating a volField.
Definition: fvcAverage.C:46
syncTools.H
Foam::polyMesh
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:74
Foam::autoLayerDriver::averageNeighbours
static void averageNeighbours(const polyMesh &mesh, const PackedBoolList &isMasterEdge, const labelList &meshEdges, const labelList &meshPoints, const edgeList &edges, const scalarField &invSumWeight, const Field< Type > &data, Field< Type > &average)
Average field (over all subset of mesh points) by.
Definition: autoLayerDriverTemplates.C:33
Foam::label
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
Foam::Field
Pre-declare SubField and related Field type.
Definition: Field.H:57
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:18
Foam::plusEqOp
Definition: ops.H:71
Foam::PackedList::get
unsigned int get(const label) const
Get value at index I.
Definition: PackedListI.H:964
Foam::max
dimensioned< Type > max(const dimensioned< Type > &, const dimensioned< Type > &)
Foam::List
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
Foam::pTraits
Traits class for primitives.
Definition: pTraits.H:50
Foam::constant::electromagnetic::e
const dimensionedScalar e
Elementary charge.
Definition: doubleFloat.H:94
autoLayerDriver.H
Foam::data
Database for solution data, solver performance and other reduced data.
Definition: data.H:52