Loading...
Searching...
No Matches
equipotentialPointSmoother.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
30// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
31
32namespace Foam
33{
34namespace pointSmoothers
35{
38 (
42 );
43}
44}
45
46
47// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
48
50(
51 const polyMesh& mesh,
52 const dictionary& dict
53)
55 pointSmoother(mesh, dict)
56{}
57
58
59// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
60
62(
63 const labelList& facesToMove,
64 const pointField& oldPoints,
65 const pointField& currentPoints,
66 const pointField& faceCentres,
67 const vectorField& faceAreas,
68 const pointField& cellCentres,
69 const scalarField& cellVolumes,
70 vectorField& pointDisplacement
71) const
72{
73 // Number of points used in each average
74 scalarField weights(mesh().nPoints(), 0);
75
76 // Reset the displacements which are about to be calculated
77 reset(facesToMove, weights, pointDisplacement);
78
79 // Sum the non-internal face displacements
80 forAll(facesToMove, faceToMoveI)
81 {
82 const label faceI(facesToMove[faceToMoveI]);
83
84 if (!isInternalOrProcessorFace(faceI))
85 {
86 const face& fPoints(mesh().faces()[faceI]);
87
88 const scalar area(mag(mesh().faceAreas()[faceI]));
89
90 forAll(fPoints, fPointI)
91 {
92 const label pointI(fPoints[fPointI]);
93
94 pointDisplacement[pointI] +=
95 area
96 *(
97 faceCentres[faceI]
98 - oldPoints[pointI]
99 );
100
101 weights[pointI] += area;
102 }
103 }
104 }
105
106 // Sum the internal face displacements
107 forAll(facesToMove, faceToMoveI)
108 {
109 const label faceI(facesToMove[faceToMoveI]);
110
111 if (isInternalOrProcessorFace(faceI))
112 {
113 const face& fPoints(mesh().faces()[faceI]);
114
115 forAll(fPoints, fPointI)
116 {
117 const label pointI(fPoints[fPointI]);
118
119 if (weights[pointI] < SMALL)
120 {
121 const labelList& pCells(mesh().pointCells()[pointI]);
122
123 forAll(pCells, pCellI)
124 {
125 const label cellI(pCells[pCellI]);
126
127 const scalar volume(mesh().cellVolumes()[cellI]);
128
129 pointDisplacement[pointI] +=
130 volume
131 *(
132 cellCentres[cellI]
133 - oldPoints[pointI]
134 );
135
136 weights[pointI] += volume;
137 }
138 }
139 }
140 }
141 }
142
143 // Average
144 average(facesToMove, weights, pointDisplacement);
145}
146
147
148// ************************************************************************* //
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.
equipotentialPointSmoother(const polyMesh &mesh, const dictionary &dict)
Construct from a dictionary and a polyMesh.
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 displacements.
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
const wordList volume
Standard volume field types (scalar, vector, tensor, etc).
Namespace for OpenFOAM.
List< label > labelList
A List of labels.
Definition List.H:62
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
Field< vector > vectorField
Specialisation of Field<T> for vector.
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