pointSmootherTemplates.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 | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2024-2025 OpenCFD Ltd.
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 \*---------------------------------------------------------------------------*/
27 
28 #include "pointSmoother.H"
29 #include "syncTools.H"
30 
31 // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
32 
33 template <class weightType>
35 (
36  const labelList& facesToMove,
37  Field<weightType>& weights,
38  vectorField& pointDisplacement,
39  const bool resetInternalFaces
40 ) const
41 {
42  bitSet resetPoints
43  (
44  pointsToMove(facesToMove, resetInternalFaces)
45  );
46 
47  for (const label pointi: resetPoints)
48  {
49  weights[pointi] = pTraits<weightType>::zero;
50  pointDisplacement[pointi] = vector::zero;
51  }
52 }
53 
54 
55 template <class weightType>
57 (
58  const labelList& facesToMove,
59  Field<weightType>& weights,
60  vectorField& pointDisplacement
61 ) const
62 {
64  (
65  mesh(),
66  weights,
67  plusEqOp<weightType>(),
68  pTraits<weightType>::zero
69  );
70 
72  (
73  mesh(),
74  pointDisplacement,
75  plusEqOp<vector>(),
76  vector::zero
77  );
78 
79  bitSet averagePoints
80  (
81  pointsToMove(facesToMove, true)
82  );
83 
84  for (const label pointi : averagePoints)
85  {
86  if (weights[pointi] != pTraits<weightType>::zero)
87  {
88  pointDisplacement[pointi] /= weights[pointi];
89  }
90  }
91 }
92 
93 
94 // ************************************************************************* //
A traits class, which is primarily used for primitives and vector-space.
Definition: pTraits.H:61
bitSet pointsToMove(const labelList &facesToMove, const bool moveInternalFaces) const
Get list of the points to be moved.
Definition: pointSmoother.C:62
dynamicFvMesh & mesh
Generic templated field type.
Definition: Field.H:63
static void syncPointList(const polyMesh &mesh, List< T > &pointValues, const CombineOp &cop, const T &nullValue, const TransformOp &top)
Synchronize values on all mesh points.
A bitSet stores bits (elements with only two states) in packed internal format and supports a variety...
Definition: bitSet.H:59
void reset(const labelList &facesToMove, Field< weightType > &weights, vectorField &pointDisplacement, const bool resetInternalFaces=true) const
Reset the relevant weights and displacements to zero.
Field< vector > vectorField
Specialisation of Field<T> for vector.
void average(const labelList &facesToMove, Field< weightType > &weights, vectorField &pointDisplacement) const
Average the displacements using the weights provided.
List< label > labelList
A List of labels.
Definition: List.H:61