All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
medialAxisMeshMover.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2014-2019 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 Class
25  Foam::medialAxisMeshMover
26 
27 Description
28  Mesh motion solver that uses a medial axis algorithm to work
29  out a fraction between the (nearest point on a) moving surface
30  and the (nearest point on a) fixed surface.
31  This fraction is then used to scale the motion. Use
32  - fixedValue on all moving patches
33  - zeroFixedValue on stationary patches
34  - slip on all slipping patches
35 
36 SourceFiles
37  medialAxisMeshMover.C
38 
39 \*---------------------------------------------------------------------------*/
40 
41 #ifndef medialAxisMeshMover_H
42 #define medialAxisMeshMover_H
43 
45 #include "motionSmootherAlgo.H"
46 #include "snappyLayerDriver.H"
47 
48 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
49 
50 namespace Foam
51 {
52 
53 class pointData;
54 
55 /*---------------------------------------------------------------------------*\
56  Class medialAxisMeshMover Declaration
57 \*---------------------------------------------------------------------------*/
58 
60 :
62 {
63  // Private Data
64 
65  const labelList adaptPatchIDs_;
66 
67  autoPtr<indirectPrimitivePatch> adaptPatchPtr_;
68 
69  //- Scale factor for displacement
70  pointScalarField scale_;
71 
72  //- Starting mesh position
73  pointField oldPoints_;
74 
75  //- Mesh mover algorithm
76  motionSmootherAlgo meshMover_;
77 
78 
79  // Pre-calculated medial axis information
80 
81  //- Normal of nearest wall. Where this normal changes direction
82  // defines the medial axis
83  pointVectorField dispVec_;
84 
85  //- Ratio of medial distance to wall distance.
86  // (1 at wall, 0 at medial axis)
87  pointScalarField medialRatio_;
88 
89  //- Distance to nearest medial axis point
90  pointScalarField medialDist_;
91 
92  //- Location on nearest medial axis point
93  pointVectorField medialVec_;
94 
95 
96  // Private Member Functions
97 
98  //- Extract fixed-value patchfields
99  static labelList getFixedValueBCs(const pointVectorField&);
100 
101  //- Extract bc types. Replace fixedValue derivatives with fixedValue
102  wordList getPatchFieldTypes(const pointVectorField& fld);
103 
104  //- Construct patch on selected patches
105  static autoPtr<indirectPrimitivePatch> getPatch
106  (
107  const polyMesh&,
108  const labelList&
109  );
110 
111 
112  // Calculation of medial axis information
113 
114  //- Smooth normals on patch
115  void smoothPatchNormals
116  (
117  const label nSmoothDisp,
118  const PackedBoolList& isMasterPoint,
119  const PackedBoolList& isMasterEdge,
120  pointField& normals
121  ) const;
122 
123  //- Smooth normals on interior
124  void smoothNormals
125  (
126  const label nSmoothDisp,
127  const PackedBoolList& isMasterPoint,
128  const PackedBoolList& isMasterEdge,
129  const labelList& fixedPoints,
130  pointVectorField& normals
131  ) const;
132 
133  //- Is mesh edge on a cusp of displacement
134  bool isMaxEdge
135  (
136  const List<pointData>& pointWallDist,
137  const label edgeI,
138  const scalar minCos
139  ) const;
140 
141  //- Initialise medial axis. Uses pointDisplacement field only
142  // for boundary types, not values.
143  void update(const dictionary&);
144 
145 
146  // Calculation of mesh movement
147 
148  //- Unmark extrusion at given point
149  static bool unmarkExtrusion
150  (
151  const label patchPointi,
152  pointField& patchDisp,
154  );
155 
156  //- Synchronise extrusion
157  void syncPatchDisplacement
158  (
159  const scalarField& minThickness,
160  pointField& patchDisp,
162  ) const;
163 
164  void smoothLambdaMuDisplacement
165  (
166  const label nSmoothDisp,
167  const PackedBoolList& isMasterPoint,
168  const PackedBoolList& isMasterEdge,
169  vectorField& displacement
170  ) const;
171 
172  void minSmoothField
173  (
174  const label nSmoothDisp,
175  const PackedBoolList& isMasterPoint,
176  const PackedBoolList& isMasterEdge,
177  const scalarField& fieldMin,
179  ) const;
180 
181  //- Stop layer growth at feature edges
182  void handleFeatureAngleLayerTerminations
183  (
184  const scalar minCos,
185  const PackedBoolList& isMasterPoint,
186  const labelList& meshEdges,
188  pointField& patchDisp,
189  label& nPointCounter
190  ) const;
191 
192  //- Find isolated islands (points, edges and faces and layer
193  // terminations) in the layer mesh and stop any layer growth
194  // at these points
195  void findIsolatedRegions
196  (
197  const scalar minCosLayerTermination,
198  const bool detectExtrusionIsland,
199  const PackedBoolList& isMasterPoint,
200  const PackedBoolList& isMasterEdge,
201  const labelList& meshEdges,
202  const scalarField& minThickness,
204  pointField& patchDisp
205  ) const;
206 
207 
208  //- Calculate desired displacement. Modifies per-patch displacement
209  // and calculates displacement for whole mesh
210  // (in pointDisplacement)
211  void calculateDisplacement
212  (
213  const dictionary&,
214  const scalarField& minThickness,
216  pointField& patchDisp
217  );
218 
219  //- Move mesh according to calculated displacement
220  bool shrinkMesh
221  (
222  const dictionary& meshQualityDict,
223  const label nAllowableErrors,
224  labelList& checkFaces
225  );
226 
227 
228 public:
229 
230  //- Runtime type information
231  TypeName("displacementMedialAxis");
232 
233 
234  // Constructors
235 
236  //- Construct from dictionary and displacement field
238  (
239  const dictionary& dict,
240  const List<labelPair>& baffles,
242  );
243 
244  //- Disallow default bitwise copy construction
245  medialAxisMeshMover(const medialAxisMeshMover&) = delete;
246 
247 
248  // Destructor
249 
250  virtual ~medialAxisMeshMover();
251 
252 
253  // Member Functions
254 
255  //- Move mesh using current pointDisplacement boundary values.
256  // Return true if successful (errors on checkFaces less than
257  // allowable). Updates pointDisplacement.
258  virtual bool move
259  (
260  const dictionary&,
261  const label nAllowableErrors,
262  labelList& checkFaces
263  );
264 
265  //- Update local data for geometry changes
266  virtual void movePoints(const pointField&);
267 
268  //- Update local data for topology changes
269  virtual void updateMesh(const mapPolyMesh&)
270  {
272  }
273 
274 
275  // Member Operators
276 
277  //- Disallow default bitwise assignment
278  void operator=(const medialAxisMeshMover&) = delete;
279 };
280 
281 
282 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
283 
284 } // End namespace Foam
285 
286 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
287 
288 #endif
289 
290 // ************************************************************************* //
dictionary dict
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:158
Mesh motion solver that uses a medial axis algorithm to work out a fraction between the (nearest poin...
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
Definition: mapPolyMesh.H:158
medialAxisMeshMover(const dictionary &dict, const List< labelPair > &baffles, pointVectorField &pointDisplacement)
Construct from dictionary and displacement field.
gmvFile<< "tracers "<< particles.size()<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().x()<< ' ';}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().y()<< ' ';}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().z()<< ' ';}gmvFile<< nl;forAll(lagrangianScalarNames, i){ const word &name=lagrangianScalarNames[i];IOField< scalar > fld(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
pointVectorField & pointDisplacement()
Return reference to the point motion displacement field.
virtual bool move(const dictionary &, const label nAllowableErrors, labelList &checkFaces)
Move mesh using current pointDisplacement boundary values.
virtual void updateMesh(const mapPolyMesh &)
Update local data for topology changes.
virtual void movePoints(const pointField &)
Update local data for geometry changes.
Virtual base class for mesh movers with externally provided displacement field giving the boundary co...
A bit-packed bool list.
TypeName("displacementMedialAxis")
Runtime type information.
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:52
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:74
rDeltaTY field()
Given a displacement moves the mesh by scaling the displacement back until there are no more mesh err...
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
Definition: error.H:366
void operator=(const medialAxisMeshMover &)=delete
Disallow default bitwise assignment.
Namespace for OpenFOAM.