Loading...
Searching...
No Matches
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-------------------------------------------------------------------------------
10License
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\*---------------------------------------------------------------------------*/
28#include "pointSmoother.H"
29#include "syncTools.H"
30
31// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
32
33template <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
55template <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>(),
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// ************************************************************************* //
Generic templated field type that is much like a Foam::List except that it is expected to hold numeri...
Definition Field.H:172
static const Form zero
A bitSet stores bits (elements with only two states) in packed internal format and supports a variety...
Definition bitSet.H:61
A traits class, which is primarily used for primitives and vector-space.
Definition pTraits.H:64
void reset(const labelList &facesToMove, Field< weightType > &weights, vectorField &pointDisplacement, const bool resetInternalFaces=true) const
Reset the relevant weights and displacements to zero.
bitSet pointsToMove(const labelList &facesToMove, const bool moveInternalFaces) const
Get list of the points to be moved.
void average(const labelList &facesToMove, Field< weightType > &weights, vectorField &pointDisplacement) const
Average the displacements using the weights provided.
static void syncPointList(const polyMesh &mesh, List< T > &pointValues, const CombineOp &cop, const T &nullValue, const TransformOp &top)
Synchronize values on all mesh points.
dynamicFvMesh & mesh
List< label > labelList
A List of labels.
Definition List.H:62
Field< vector > vectorField
Specialisation of Field<T> for vector.