laplacianPointSmoother.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 "laplacianPointSmoother.H"
30 
31 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
32 
33 namespace Foam
34 {
35 namespace pointSmoothers
36 {
37  defineTypeNameAndDebug(laplacianPointSmoother, 0);
39  (
40  pointSmoother,
41  laplacianPointSmoother,
42  dictionary
43  );
44 }
45 }
46 
47 
48 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
49 
51 (
52  const polyMesh& mesh,
53  const dictionary& dict
54 )
55 :
57 {}
58 
59 
60 // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
61 
63 (
64  const labelList& facesToMove,
65  const pointField& oldPoints,
66  const pointField& currentPoints,
67  const pointField& faceCentres,
68  const vectorField& faceAreas,
69  const pointField& cellCentres,
70  const scalarField& cellVolumes,
71  vectorField& pointDisplacement
72 ) const
73 {
74  // Number of points used in each average
75  labelField counts(mesh().nPoints(), 0);
76 
77  // Reset the displacements which are about to be calculated
78  reset(facesToMove, counts, pointDisplacement);
79 
80  // Sum the non-internal face displacements
81  forAll(facesToMove, faceToMoveI)
82  {
83  const label faceI(facesToMove[faceToMoveI]);
84 
85  if (!isInternalOrProcessorFace(faceI))
86  {
87  const face& fPoints(mesh().faces()[faceI]);
88 
89  forAll(fPoints, fPointI)
90  {
91  const label pointI(fPoints[fPointI]);
92 
93  pointDisplacement[pointI] +=
94  faceCentres[faceI]
95  - oldPoints[pointI];
96 
97  ++ counts[pointI];
98  }
99  }
100  }
101 
102  // Sum the internal face displacements
103  forAll(facesToMove, faceToMoveI)
104  {
105  const label faceI(facesToMove[faceToMoveI]);
106 
107  if (isInternalOrProcessorFace(faceI))
108  {
109  const face& fPoints(mesh().faces()[faceI]);
110 
111  forAll(fPoints, fPointI)
112  {
113  const label pointI(fPoints[fPointI]);
114 
115  if (counts[pointI] == 0)
116  {
117  const labelList& pCells(mesh().pointCells()[pointI]);
118 
119  forAll(pCells, pCellI)
120  {
121  const label cellI(pCells[pCellI]);
122 
123  pointDisplacement[pointI] +=
124  cellCentres[cellI]
125  - oldPoints[pointI];
126 
127  ++ counts[pointI];
128  }
129  }
130  }
131  }
132  }
133 
134  // Average
135  average(facesToMove, counts, pointDisplacement);
136 }
137 
138 
139 // ************************************************************************* //
const polyMesh & mesh() const
dictionary dict
A face is a list of labels corresponding to mesh vertices.
Definition: face.H:68
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:129
laplacianPointSmoother(const polyMesh &mesh, const dictionary &dict)
Construct from a dictionary and a polyMesh.
Abstract base class for point smoothing methods. Handles parallel communication via reset and average...
Definition: pointSmoother.H:50
Macros for easy insertion into run-time selection tables.
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:421
dynamicFvMesh & mesh
addToRunTimeSelectionTable(pointSmoother, equipotentialPointSmoother, dictionary)
label nPoints
virtual void calculate(const labelList &facesToMove, const pointField &oldPoints, const pointField &currentPoints, const pointField &faceCentres, const vectorField &faceAreas, const pointField &cellCentres, const scalarField &cellVolumes, vectorField &pointDisplacement) const
Calculate the point displacement.
bool isInternalOrProcessorFace(const label faceI) const
Test if the given face is internal or on a processor boundary.
Definition: pointSmoother.C:36
void reset(const labelList &facesToMove, Field< weightType > &weights, vectorField &pointDisplacement, const bool resetInternalFaces=true) const
Reset the relevant weights and displacements to zero.
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:75
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
defineTypeNameAndDebug(equipotentialPointSmoother, 0)
Namespace for OpenFOAM.