Loading...
Searching...
No Matches
pointSmoother.H
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
26Class
27 Foam::pointSmoother
28
29Description
30 Abstract base class for point smoothing methods. Handles parallel
31 communication via reset and average functions.
32
33SourceFiles
34 pointSmoother.C
35 pointSmootherTemplates.C
36
37\*---------------------------------------------------------------------------*/
38
39#ifndef Foam_pointSmoother_H
40#define Foam_pointSmoother_H
41
42#include "polyMeshGeometry.H"
44#include "bitSet.H"
45
46// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
47
48namespace Foam
49{
51/*---------------------------------------------------------------------------*\
52 Class pointSmoother Declaration
53\*---------------------------------------------------------------------------*/
54
55class pointSmoother
56{
57private:
58
59 // Private Data
60
61 //- Reference to the polyMesh
62 const polyMesh& mesh_;
63
64 //- Set of the processor patch indices
65 labelHashSet processorPatchIDs_;
66
67
68 // Private Member Functions
69
70 //- No copy construct
71 pointSmoother(const pointSmoother&) = delete;
72
73 //- No copy assignment
74 void operator=(const pointSmoother&) = delete;
75
76
77protected:
78
79 // Protected Member Functions
80
81 //- Test if the given face is internal or on a processor boundary
82 bool isInternalOrProcessorFace(const label faceI) const;
83
84 //- Get list of the points to be moved
86 (
87 const labelList& facesToMove,
88 const bool moveInternalFaces
89 ) const;
90
91 //- Reset the relevant weights and displacements to zero
92 template <class weightType>
93 void reset
94 (
95 const labelList& facesToMove,
96 Field<weightType>& weights,
97 vectorField& pointDisplacement,
98 const bool resetInternalFaces = true
99 ) const;
100
101 //- Average the displacements using the weights provided
102 template <class weightType>
103 void average
104 (
105 const labelList& facesToMove,
106 Field<weightType>& weights,
107 vectorField& pointDisplacement
108 ) const;
109
110
111public:
112
113 //- Runtime type information
114 TypeName("pointSmoother");
115
116
117 // Declare run-time constructor selection table
119 (
120 autoPtr,
121 pointSmoother,
123 (const polyMesh& mesh, const dictionary& dict),
124 (mesh, dict)
125 );
126
128 // Constructors
129
130 //- Construct from a dictionary and a point displacement field
131 pointSmoother(const polyMesh& mesh, const dictionary&);
132
133
134 // Selector
135
136 //- Construct given type
138 (
139 const word& pointSmootherType,
140 const polyMesh& mesh,
141 const dictionary& dict
142 );
143
144 //- Construct with type looked up from dictionary
146 (
147 const polyMesh& mesh,
148 const dictionary& dict
149 );
150
151
152 //- Destructor
153 virtual ~pointSmoother() = default;
154
155
156 // Member Functions
157
158 //- Access the mesh
159 const polyMesh& mesh() const noexcept
160 {
161 return mesh_;
162 }
163
164 //- Update the point displacements and apply constraints
165 void update
166 (
167 const labelList& facesToMove,
168 const pointField& oldPoints,
169 const pointField& currentPoints,
170 const pointField& faceCentres,
171 const vectorField& faceAreas,
172 const pointField& cellCentres,
173 const scalarField& cellVolumes,
174 pointVectorField& pointDisplacement,
175 const bool correctBCs = true
176 ) const;
177
178 //- Update the point displacements and apply constraints
179 void update
180 (
181 const labelList& facesToMove,
182 const pointField& oldPoints,
183 const pointField& currentPoints,
184 const polyMeshGeometry& meshGeometry,
185 pointVectorField& pointDisplacement,
186 const bool correctBCs = true
187 ) const
188 {
189 update
190 (
191 facesToMove,
192 oldPoints,
193 currentPoints,
194 meshGeometry.faceCentres(),
195 meshGeometry.faceAreas(),
196 meshGeometry.cellCentres(),
197 meshGeometry.cellVolumes(),
198 pointDisplacement,
199 correctBCs
200 );
201 }
202
203 //- Calculate the point displacement
204 virtual void calculate
205 (
206 const labelList& facesToMove,
207 const pointField& oldPoints,
208 const pointField& currentPoints,
209 const pointField& faceCentres,
210 const vectorField& faceAreas,
211 const pointField& cellCentres,
212 const scalarField& cellVolumes,
213 vectorField& pointDisplacement
214 ) const = 0;
215
216 //- Update the point displacements
217 virtual void calculate
218 (
219 const labelList& facesToMove,
220 const pointField& oldPoints,
221 const pointField& currentPoints,
222 const polyMeshGeometry& meshGeometry,
223 vectorField& pointDisplacement
224 ) const
225 {
227 (
228 facesToMove,
229 oldPoints,
230 currentPoints,
231 meshGeometry.faceCentres(),
232 meshGeometry.faceAreas(),
233 meshGeometry.cellCentres(),
234 meshGeometry.cellVolumes(),
235 pointDisplacement
236 );
237 }
238
239 //- Check element quality: 1 = best, 0 = invalid. (also negative?)
240 //- Topology from mesh, point locations supplied.
241 //- Move to motionSolver level?
243 (
244 const pointField& points,
245 const pointField& faceCentres,
246 const vectorField& faceAreas,
247 const pointField& cellCentres,
248 const scalarField& cellVolumes
249 ) const;
250
251 //- Check element quality: 1 = best, 0 = invalid.
252 //- Topology from mesh, point locations supplied.
253 //- Move to motionSolver level?
255 (
256 const pointField& points,
257 const pointField& faceCentres,
258 const vectorField& faceAreas,
259 const pointField& cellCentres,
260 const scalarField& cellVolumes
261 ) const;
262};
263
264
265// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
266
267} // End namespace Foam
268
269// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
270
271#ifdef NoRepository
272 #include "pointSmootherTemplates.C"
273#endif
274
275// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
276
277#endif
278
279// ************************************************************************* //
Generic templated field type that is much like a Foam::List except that it is expected to hold numeri...
Definition Field.H:172
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition autoPtr.H:65
A bitSet stores bits (elements with only two states) in packed internal format and supports a variety...
Definition bitSet.H:61
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition dictionary.H:133
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 =0
Calculate the point displacement.
declareRunTimeSelectionTable(autoPtr, pointSmoother, dictionary,(const polyMesh &mesh, const dictionary &dict),(mesh, dict))
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.
static autoPtr< pointSmoother > New(const word &pointSmootherType, const polyMesh &mesh, const dictionary &dict)
Construct given type.
bitSet pointsToMove(const labelList &facesToMove, const bool moveInternalFaces) const
Get list of the points to be moved.
virtual ~pointSmoother()=default
Destructor.
void average(const labelList &facesToMove, Field< weightType > &weights, vectorField &pointDisplacement) const
Average the displacements using the weights provided.
virtual tmp< scalarField > cellQuality(const pointField &points, const pointField &faceCentres, const vectorField &faceAreas, const pointField &cellCentres, const scalarField &cellVolumes) const
Check element quality: 1 = best, 0 = invalid. Topology from mesh, point locations supplied....
void update(const labelList &facesToMove, const pointField &oldPoints, const pointField &currentPoints, const polyMeshGeometry &meshGeometry, pointVectorField &pointDisplacement, const bool correctBCs=true) const
Update the point displacements and apply constraints.
const polyMesh & mesh() const noexcept
Access the mesh.
virtual tmp< scalarField > faceQuality(const pointField &points, const pointField &faceCentres, const vectorField &faceAreas, const pointField &cellCentres, const scalarField &cellVolumes) const
Check element quality: 1 = best, 0 = invalid. (also negative?) Topology from mesh,...
TypeName("pointSmoother")
Runtime type information.
virtual void calculate(const labelList &facesToMove, const pointField &oldPoints, const pointField &currentPoints, const polyMeshGeometry &meshGeometry, vectorField &pointDisplacement) const
Update the point displacements.
Updateable mesh geometry and checking routines.
const scalarField & cellVolumes() const
const vectorField & faceAreas() const
const vectorField & faceCentres() const
const vectorField & cellCentres() const
Mesh consisting of general polyhedral cells.
Definition polyMesh.H:79
A class for managing temporary objects.
Definition tmp.H:75
A class for handling words, derived from Foam::string.
Definition word.H:66
mesh update()
const pointField & points
Namespace for OpenFOAM.
List< label > labelList
A List of labels.
Definition List.H:62
HashSet< label, Hash< label > > labelHashSet
A HashSet of labels, uses label hasher.
Definition HashSet.H:85
GeometricField< vector, pointPatchField, pointMesh > pointVectorField
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
Field< vector > vectorField
Specialisation of Field<T> for vector.
const direction noexcept
Definition scalarImpl.H:265
vectorField pointField
pointField is a vectorField.
Macros to ease declaration of run-time selection tables.
#define declareRunTimeSelectionTable(ptrWrapper, baseType, argNames, argList, parList)
Declare a run-time selection (variables and adder classes).
dictionary dict
#define TypeName(TypeNameString)
Declare a ClassName() with extra virtual type info.
Definition typeInfo.H:68