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 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  autoPtr<PackedBoolList> resetPointsPtr
43  (
44  pointsToMove(facesToMove, resetInternalFaces)
45  );
46 
47  const PackedBoolList& resetPoints(resetPointsPtr);
48 
49  forAll(resetPoints, pointI)
50  {
51  if (resetPoints[pointI])
52  {
53  weights[pointI] = pTraits<weightType>::zero;
54  pointDisplacement[pointI] = vector::zero;
55  }
56  }
57 }
58 
59 
60 template <class weightType>
62 (
63  const labelList& facesToMove,
64  Field<weightType>& weights,
65  vectorField& pointDisplacement
66 ) const
67 {
69  (
70  mesh(),
71  weights,
72  plusEqOp<weightType>(),
73  pTraits<weightType>::zero
74  );
75 
77  (
78  mesh(),
79  pointDisplacement,
80  plusEqOp<vector>(),
81  vector::zero
82  );
83 
84  autoPtr<PackedBoolList> averagePointsPtr
85  (
86  pointsToMove(facesToMove, true)
87  );
88 
89  const PackedBoolList& averagePoints(averagePointsPtr);
90 
91  forAll(averagePoints, pointI)
92  {
93  if
94  (
95  averagePoints[pointI]
96  && weights[pointI] != pTraits<weightType>::zero
97  )
98  {
99  pointDisplacement[pointI] /= weights[pointI];
100  }
101  }
102 }
103 
104 
105 // ************************************************************************* //
A traits class, which is primarily used for primitives and vector-space.
Definition: pTraits.H:75
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:421
dynamicFvMesh & mesh
Generic templated field type.
Definition: Field.H:62
static void syncPointList(const polyMesh &mesh, List< T > &pointValues, const CombineOp &cop, const T &nullValue, const TransformOp &top)
Synchronize values on all mesh points.
autoPtr< PackedBoolList > pointsToMove(const labelList &facesToMove, const bool moveInternalFaces) const
Get a boolean list of the points to be moved.
Definition: pointSmoother.C:62
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.
Pointer management similar to std::unique_ptr, with some additional methods and type checking...
Definition: HashPtrTable.H:48
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:62
bitSet PackedBoolList