displacementSmartPointSmoothingMotionSolver.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 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 Class
27  Foam::displacementSmartPointSmoothingMotionSolver
28 
29 Description
30  Quality-based under-relaxation for run-time selectable point smoothing. WIP.
31 
32 Usage
33  \table
34  Property | Description | Required | Default value
35  untangler | pointSmoother for untangling | yes |
36  untangleQ | quality below which untangling is applied | yes |
37 
38  pointSmoother | pointSmoother in 'normal' mode | yes
39  minQ | quality below which pointSmoother is applied | yes
40  nPointSmootherIter | max number of iterations
41  \endtable
42 
43  Example of the motion solver specification in dynamicMeshDict:
44  \verbatim
45  motionSolver displacementSmartPointSmoothing;
46  displacementSmartPointSmoothingCoeffs
47  {
48  //- Overall max number of smoothing iterations
49  nPointSmootherIter 10;
50 
51  //- If any faces have quality below untangleQ apply untangler
52  untangleQ 0.001;
53  untangler laplacian;
54 
55  //- If any faces have quality below minQ apply 'normal' smoother
56  minQ 0.9;
57  pointSmoother geometricElementTransform;
58  transformationParameter 0.667;
59  }
60  \endverbatim
61 
62 SourceFiles
63  displacementSmartPointSmoothingMotionSolver.C
64 
65 \*---------------------------------------------------------------------------*/
66 
67 #ifndef displacementSmartPointSmoothingMotionSolver_H
68 #define displacementSmartPointSmoothingMotionSolver_H
69 
71 #include "pointSmoother.H"
72 #include "polyMeshGeometry.H"
73 
74 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
75 
76 namespace Foam
77 {
78 
79 /*---------------------------------------------------------------------------*\
80  Class displacementSmartPointSmoothingMotionSolver Declaration
81 \*---------------------------------------------------------------------------*/
82 
83 class displacementSmartPointSmoothingMotionSolver
84 :
85  public displacementMotionSolver
86 {
87 protected:
88 
89  // Protected Data
90 
91  //- Part-updatable mesh geometry
92  polyMeshGeometry meshGeometry_;
93 
94  //- Point untangler method
95  autoPtr<pointSmoother> pointUntangler_;
96 
97  //- Minimum allowed quality
98  const scalar untangleQ_;
99 
100  //- Minimum allowed quality
101  const scalar minQ_;
102 
103  //- Point smoothing method
104  autoPtr<pointSmoother> pointSmoother_;
105 
106  //- Number of point smoother iterations per timestep
107  const label nPointSmootherIter_;
108 
110  // Mesh quality based relaxation of smoothed position
111 
112  //- Relaxation factors to use in each iteration
114 
115  //- Relaxed point field
117 
118  //- Set of the faces which are to be moved
121  //- Mesh quality dictionary
123 
124 
125  // Private Member Functions
126 
127  //- Mark affected faces
128  void markAffectedFaces
129  (
130  const labelHashSet& changedFaces,
131  labelHashSet& affectedFaces
132  );
133 
134  //- Relax the points
135  bool relax();
136 
137  //- Set all the faces to be moved
138  void virtual setFacesToMove(const dictionary&);
139 
140  //- Handle 2D & empty bcs. Assume in both cases the starting mesh
141  // - has all edges aligned with 3rd dimension
142  // - is on planes of the empty patches
144 
146 public:
147 
148  //- Runtime type information
149  TypeName("displacementSmartPointSmoothing");
150 
151 
152  // Constructors
154  //- Construct from a polyMesh and an IOdictionary
156  (
157  const polyMesh&,
159  );
160 
161  //- Construct from components
163  (
164  const polyMesh& mesh,
165  const IOdictionary& dict,
167  const pointIOField& points0
168  );
169 
170 
171  //- Destructor
173 
174 
175  // Member Functions
176 
177  //- Return point location obtained from the current motion field
178  virtual tmp<pointField> curPoints() const;
179 
180  //- Solve for motion
181  virtual void solve();
182 };
183 
184 
185 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
186 
187 } // End namespace Foam
188 
189 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
190 
191 #endif
192 
193 // ************************************************************************* //
virtual tmp< pointField > curPoints() const
Return point location obtained from the current motion field.
dictionary dict
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:129
virtual ~displacementSmartPointSmoothingMotionSolver()=default
Destructor.
pointVectorField & pointDisplacement() noexcept
Return reference to the point motion displacement field.
virtual void setFacesToMove(const dictionary &)
Set all the faces to be moved.
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
Definition: IOdictionary.H:50
void emptyCorrectPoints(pointVectorField &pointDisplacement)
Handle 2D & empty bcs. Assume in both cases the starting mesh.
const label nPointSmootherIter_
Number of point smoother iterations per timestep.
void markAffectedFaces(const labelHashSet &changedFaces, labelHashSet &affectedFaces)
Mark affected faces.
TypeName("displacementSmartPointSmoothing")
Runtime type information.
displacementSmartPointSmoothingMotionSolver(const polyMesh &, const IOdictionary &)
Construct from a polyMesh and an IOdictionary.
pointField & points0() noexcept
Return reference to the reference (&#39;0&#39;) pointField.
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:75
const polyMesh & mesh() const
Return reference to mesh.
Definition: motionSolver.H:165
labelHashSet facesToMove_
Set of the faces which are to be moved.
A class for managing temporary objects.
Definition: HashPtrTable.H:50
scalarList relaxationFactors_
Relaxation factors to use in each iteration.
A primitive field of type <T> with automated input and output.
Namespace for OpenFOAM.