Loading...
Searching...
No Matches
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-------------------------------------------------------------------------------
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\*---------------------------------------------------------------------------*/
27
31// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
32
33namespace Foam
34{
35namespace pointSmoothers
36{
39 (
43 );
44}
45}
46
47
48// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
49
51(
52 const polyMesh& mesh,
53 const dictionary& dict
54)
56 pointSmoother(mesh, dict)
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// ************************************************************************* //
Macros for easy insertion into run-time selection tables.
#define addToRunTimeSelectionTable(baseType, thisType, argNames)
Add to construction table with typeName as the key.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition dictionary.H:133
A face is a list of labels corresponding to mesh vertices.
Definition face.H:71
Smooth ATC in cells having a point to a set of patches supplied by type.
Definition pointCells.H:55
Abstract base class for point smoothing methods. Handles parallel communication via reset and average...
void reset(const labelList &facesToMove, Field< weightType > &weights, vectorField &pointDisplacement, const bool resetInternalFaces=true) const
Reset the relevant weights and displacements to zero.
bool isInternalOrProcessorFace(const label faceI) const
Test if the given face is internal or on a processor boundary.
void average(const labelList &facesToMove, Field< weightType > &weights, vectorField &pointDisplacement) const
Average the displacements using the weights provided.
const polyMesh & mesh() const noexcept
Access the mesh.
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.
laplacianPointSmoother(const polyMesh &mesh, const dictionary &dict)
Construct from a dictionary and a polyMesh.
Mesh consisting of general polyhedral cells.
Definition polyMesh.H:79
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
Definition className.H:142
limits reset(1/(limits.max()+VSMALL), 1/(limits.min()+VSMALL))
dynamicFvMesh & mesh
label nPoints
Namespace for OpenFOAM.
List< label > labelList
A List of labels.
Definition List.H:62
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
Field< vector > vectorField
Specialisation of Field<T> for vector.
Field< label > labelField
Specialisation of Field<T> for label.
Definition labelField.H:48
vectorField pointField
pointField is a vectorField.
dimensioned< Type > average(const DimensionedField< Type, GeoMesh > &f1, const label comm)
dictionary dict
#define forAll(list, i)
Loop across all elements in list.
Definition stdFoam.H:299