medialAxisMeshMover.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) 2014-2015 OpenFOAM Foundation
9  Copyright (C) 2015 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 Class
28  Foam::medialAxisMeshMover
29 
30 Description
31  Mesh motion solver that uses a medial axis algorithm to work
32  out a fraction between the (nearest point on a) moving surface
33  and the (nearest point on a) fixed surface.
34 
35  This fraction is then used to scale the motion. Use
36  - fixedValue on all moving patches
37  - zeroFixedValue on stationary patches
38  - slip on all slipping patches
39  Note that the fixedValue boundary conditions might be changed by this
40  solver to enforce consistency and a valid resulting mesh.
41 
42 SourceFiles
43  medialAxisMeshMover.C
44 
45 \*---------------------------------------------------------------------------*/
46 
47 #ifndef medialAxisMeshMover_H
48 #define medialAxisMeshMover_H
49 
51 #include "motionSmootherAlgo.H"
52 #include "snappyLayerDriver.H"
53 #include "fieldSmoother.H"
54 
55 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
56 
57 namespace Foam
58 {
59 
60 template <class DataType>
61 class PointData;
62 
63 /*---------------------------------------------------------------------------*\
64  Class medialAxisMeshMover Declaration
65 \*---------------------------------------------------------------------------*/
66 
68 :
70 {
71  // Private data
72 
73  const labelList adaptPatchIDs_;
74 
75  autoPtr<indirectPrimitivePatch> adaptPatchPtr_;
76 
77  //- Scale factor for displacement
78  pointScalarField scale_;
79 
80  //- Starting mesh position
81  pointField oldPoints_;
82 
83  //- Mesh mover algorithm
84  motionSmootherAlgo meshMover_;
85 
86  //- Field smoothing
87  fieldSmoother fieldSmoother_;
88 
89 
90  // Pre-calculated medial axis information
91 
92  //- Normal of nearest wall. Where this normal changes direction
93  // defines the medial axis
94  pointVectorField dispVec_;
95 
96  //- Ratio of medial distance to wall distance.
97  // (1 at wall, 0 at medial axis)
98  pointScalarField medialRatio_;
99 
100  //- Distance to nearest medial axis point
101  pointScalarField medialDist_;
102 
103  //- Location on nearest medial axis point
104  pointVectorField medialVec_;
105 
106 
107  // Private Member Functions
108 
109  //- Extract bc types. Replace fixedValue derivatives with fixedValue
110  wordList getPatchFieldTypes(const pointVectorField& fld);
111 
112 
113  // Calculation of medial axis information
114 
115  //- Is mesh edge on a cusp of displacement
116  bool isMaxEdge
117  (
118  const List<PointData<vector>>& pointWallDist,
119  const label edgeI,
120  const scalar minCos,
121  const bool checkWall
122  ) const;
123 
124  //- Initialise medial axis. Uses pointDisplacement field only
125  // for boundary types, not values.
126  void update(const dictionary&);
127 
128 
129  // Calculation of mesh movement
130 
131  //- Unmark extrusion at given point
132  static bool unmarkExtrusion
133  (
134  const label patchPointi,
135  pointField& patchDisp,
137  );
138 
139  //- Synchronise extrusion
140  void syncPatchDisplacement
141  (
142  const scalarField& minThickness,
143  pointField& patchDisp,
145  ) const;
146 
147  //- Stop layer growth at feature edges
148  void handleFeatureAngleLayerTerminations
149  (
150  const scalar minCos,
151  const bitSet& isMasterPoint,
152  const labelList& meshEdges,
154  pointField& patchDisp,
155  label& nPointCounter
156  ) const;
157 
158  //- Find isolated islands (points, edges and faces and layer
159  // terminations) in the layer mesh and stop any layer growth
160  // at these points
161  void findIsolatedRegions
162  (
163  const scalar minCosLayerTermination,
164  const bool detectExtrusionIsland,
165  const bitSet& isMasterPoint,
166  const bitSet& isMasterEdge,
167  const labelList& meshEdges,
168  const scalarField& minThickness,
170  pointField& patchDisp
171  ) const;
172 
173 
174  //- Calculate desired displacement. Modifies per-patch displacement
175  // and calculates displacement for whole mesh
176  // (in pointDisplacement)
177  void calculateDisplacement
178  (
179  const dictionary&,
180  const scalarField& minThickness,
182  pointField& patchDisp
183  );
184 
185  //- Move mesh according to calculated displacement
186  bool shrinkMesh
187  (
188  const dictionary& meshQualityDict,
189  const label nAllowableErrors,
190  labelList& checkFaces
191  );
192 
193  //- No copy construct
194  medialAxisMeshMover(const medialAxisMeshMover&) = delete;
195 
196  //- No copy assignment
197  void operator=(const medialAxisMeshMover&) = delete;
198 
199 
200 public:
201 
202  //- Runtime type information
203  TypeName("displacementMedialAxis");
204 
205 
206  // Constructors
207 
208  //- Construct from dictionary and displacement field
210  (
211  const dictionary& dict,
212  const List<labelPair>& baffles,
214  const bool dryRun
215  );
216 
217 
218  // Destructor
219 
220  virtual ~medialAxisMeshMover();
221 
222 
223  // Member Functions
224 
225  //- Move mesh using current pointDisplacement boundary values.
226  // Return true if successful (errors on checkFaces less than
227  // allowable). Updates pointDisplacement.
228  virtual bool move
229  (
230  const dictionary&,
231  const label nAllowableErrors,
232  labelList& checkFaces
233  );
234 
235  //- Update local data for geometry changes
236  virtual void movePoints(const pointField&);
237 
238  //- Update local data for topology changes
239  virtual void updateMesh(const mapPolyMesh&)
240  {
242  }
243 
244 };
245 
246 
247 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
248 
249 } // End namespace Foam
250 
251 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
252 
253 #endif
254 
255 // ************************************************************************* //
Foam::bitSet
A bitSet stores bits (elements with only two states) in packed internal format and supports a variety...
Definition: bitSet.H:63
Foam::fieldSmoother
Utility functions for mesh motion solvers.
Definition: fieldSmoother.H:50
Foam::medialAxisMeshMover::~medialAxisMeshMover
virtual ~medialAxisMeshMover()
Definition: medialAxisMeshMover.C:1362
Foam::PointData
Variant of pointEdgePoint with some transported additional data. Templated on the transported data ty...
Definition: medialAxisMeshMover.H:60
Foam::medialAxisMeshMover
Mesh motion solver that uses a medial axis algorithm to work out a fraction between the (nearest poin...
Definition: medialAxisMeshMover.H:66
Foam::externalDisplacementMeshMover::pointDisplacement
pointVectorField & pointDisplacement()
Return reference to the point motion displacement field.
Definition: externalDisplacementMeshMover.H:159
NotImplemented
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
Definition: error.H:517
Foam::Field< vector >
externalDisplacementMeshMover.H
Foam::motionSmootherAlgo
Given a displacement moves the mesh by scaling the displacement back until there are no more mesh err...
Definition: motionSmootherAlgo.H:100
Foam::externalDisplacementMeshMover
Virtual base class for mesh movers with externally provided displacement field giving the boundary co...
Definition: externalDisplacementMeshMover.H:58
Foam::medialAxisMeshMover::updateMesh
virtual void updateMesh(const mapPolyMesh &)
Update local data for topology changes.
Definition: medialAxisMeshMover.H:238
fld
gmvFile<< "tracers "<< particles.size()<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().x()<< ' ';}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().y()<< ' ';}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().z()<< ' ';}gmvFile<< nl;for(const word &name :lagrangianScalarNames){ IOField< scalar > fld(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
Definition: gmvOutputLagrangian.H:23
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::medialAxisMeshMover::movePoints
virtual void movePoints(const pointField &)
Update local data for geometry changes.
Definition: medialAxisMeshMover.C:1843
fieldSmoother.H
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:123
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::medialAxisMeshMover::TypeName
TypeName("displacementMedialAxis")
Runtime type information.
Foam::autoPtr
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: HashPtrTable.H:53
Foam::List< label >
motionSmootherAlgo.H
Foam::medialAxisMeshMover::move
virtual bool move(const dictionary &, const label nAllowableErrors, labelList &checkFaces)
Move mesh using current pointDisplacement boundary values.
Definition: medialAxisMeshMover.C:1781
Foam::mapPolyMesh
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
Definition: mapPolyMesh.H:161
Foam::GeometricField< scalar, pointPatchField, pointMesh >
snappyLayerDriver.H