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 | Copyright (C) 2014-2015 OpenFOAM Foundation
6  \\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
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 
32  This fraction is then used to scale the motion. Use
33  - fixedValue on all moving patches
34  - zeroFixedValue on stationary patches
35  - slip on all slipping patches
36  Note that the fixedValue boundary conditions might be changed by this
37  solver to enforce consistency and a valid resulting mesh.
38 
39 SourceFiles
40  medialAxisMeshMover.C
41 
42 \*---------------------------------------------------------------------------*/
43 
44 #ifndef medialAxisMeshMover_H
45 #define medialAxisMeshMover_H
46 
48 #include "motionSmootherAlgo.H"
49 #include "autoLayerDriver.H"
50 #include "fieldSmoother.H"
51 
52 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
53 
54 namespace Foam
55 {
56 
57 template <class DataType>
58 class PointData;
59 
60 /*---------------------------------------------------------------------------*\
61  Class medialAxisMeshMover Declaration
62 \*---------------------------------------------------------------------------*/
63 
65 :
67 {
68  // Private data
69 
71 
73 
74  //- Scale factor for displacement
76 
77  //- Starting mesh position
79 
80  //- Mesh mover algorithm
82 
83  //- Field smoothing
85 
86 
87  // Pre-calculated medial axis information
88 
89  //- Normal of nearest wall. Where this normal changes direction
90  // defines the medial axis
92 
93  //- Ratio of medial distance to wall distance.
94  // (1 at wall, 0 at medial axis)
96 
97  //- Distance to nearest medial axis point
99 
100  //- Location on nearest medial axis point
102 
103 
104  // Private Member Functions
105 
106  //- Extract bc types. Replace fixedValue derivatives with fixedValue
108 
109 
110  // Calculation of medial axis information
111 
112  //- Is mesh edge on a cusp of displacement
113  bool isMaxEdge
114  (
115  const List<PointData<vector> >& pointWallDist,
116  const label edgeI,
117  const scalar minCos
118  ) const;
119 
120  //- Initialise medial axis. Uses pointDisplacement field only
121  // for boundary types, not values.
122  void update(const dictionary&);
123 
124 
125  // Calculation of mesh movement
126 
127  //- Unmark extrusion at given point
128  static bool unmarkExtrusion
129  (
130  const label patchPointI,
131  pointField& patchDisp,
133  );
134 
135  //- Synchronise extrusion
137  (
138  const scalarField& minThickness,
139  pointField& patchDisp,
141  ) const;
142 
143  //- Stop layer growth at feature edges
145  (
146  const scalar minCos,
147  const PackedBoolList& isMasterPoint,
148  const labelList& meshEdges,
149  List<autoLayerDriver::extrudeMode>& extrudeStatus,
150  pointField& patchDisp,
151  label& nPointCounter
152  ) const;
153 
154  //- Find isolated islands (points, edges and faces and layer
155  // terminations) in the layer mesh and stop any layer growth
156  // at these points
158  (
159  const scalar minCosLayerTermination,
160  const bool detectExtrusionIsland,
161  const PackedBoolList& isMasterPoint,
162  const PackedBoolList& isMasterEdge,
163  const labelList& meshEdges,
164  const scalarField& minThickness,
165  List<autoLayerDriver::extrudeMode>& extrudeStatus,
166  pointField& patchDisp
167  ) const;
168 
169 
170  //- Calculate desired displacement. Modifies per-patch displacement
171  // and calculates displacement for whole mesh
172  // (in pointDisplacement)
174  (
175  const dictionary&,
176  const scalarField& minThickness,
177  List<autoLayerDriver::extrudeMode>& extrudeStatus,
178  pointField& patchDisp
179  );
180 
181  //- Move mesh according to calculated displacement
182  bool shrinkMesh
183  (
184  const dictionary& meshQualityDict,
185  const label nAllowableErrors,
186  labelList& checkFaces
187  );
188 
189  //- Disallow default bitwise copy construct
191 
192  //- Disallow default bitwise assignment
193  void operator=(const medialAxisMeshMover&);
194 
195 
196 public:
197 
198  //- Runtime type information
199  TypeName("displacementMedialAxis");
200 
201 
202  // Constructors
203 
204  //- Construct from dictionary and displacement field
206  (
207  const dictionary& dict,
208  const List<labelPair>& baffles,
210  );
211 
212 
213  // Destructor
214 
215  virtual ~medialAxisMeshMover();
216 
217 
218  // Member Functions
219 
220  //- Move mesh using current pointDisplacement boundary values.
221  // Return true if succesful (errors on checkFaces less than
222  // allowable). Updates pointDisplacement.
223  virtual bool move
224  (
225  const dictionary&,
226  const label nAllowableErrors,
227  labelList& checkFaces
228  );
229 
230  //- Update local data for geometry changes
231  virtual void movePoints(const pointField&);
232 
233  //- Update local data for topology changes
234  virtual void updateMesh(const mapPolyMesh&)
235  {
237  }
238 
239 };
240 
241 
242 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
243 
244 } // End namespace Foam
245 
246 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
247 
248 #endif
249 
250 // ************************************************************************* //
Foam::medialAxisMeshMover::handleFeatureAngleLayerTerminations
void handleFeatureAngleLayerTerminations(const scalar minCos, const PackedBoolList &isMasterPoint, const labelList &meshEdges, List< autoLayerDriver::extrudeMode > &extrudeStatus, pointField &patchDisp, label &nPointCounter) const
Stop layer growth at feature edges.
Definition: medialAxisMeshMover.C:769
Foam::medialAxisMeshMover::syncPatchDisplacement
void syncPatchDisplacement(const scalarField &minThickness, pointField &patchDisp, List< autoLayerDriver::extrudeMode > &extrudeStatus) const
Synchronise extrusion.
Definition: medialAxisMeshMover.C:650
Foam::PackedBoolList
A bit-packed bool list.
Definition: PackedBoolList.H:63
Foam::medialAxisMeshMover::medialRatio_
pointScalarField medialRatio_
Ratio of medial distance to wall distance.
Definition: medialAxisMeshMover.H:94
Foam::fieldSmoother
Utility functions for mesh motion solvers.
Definition: fieldSmoother.H:48
Foam::medialAxisMeshMover::~medialAxisMeshMover
virtual ~medialAxisMeshMover()
Definition: medialAxisMeshMover.C:1278
Foam::medialAxisMeshMover::calculateDisplacement
void calculateDisplacement(const dictionary &, const scalarField &minThickness, List< autoLayerDriver::extrudeMode > &extrudeStatus, pointField &patchDisp)
Calculate desired displacement. Modifies per-patch displacement.
Definition: medialAxisMeshMover.C:1285
Foam::medialAxisMeshMover::operator=
void operator=(const medialAxisMeshMover &)
Disallow default bitwise assignment.
Foam::PointData
Variant of pointEdgePoint with some transported additional data. Templated on the transported data ty...
Definition: medialAxisMeshMover.H:57
Foam::medialAxisMeshMover
Mesh motion solver that uses a medial axis algorithm to work out a fraction between the (nearest poin...
Definition: medialAxisMeshMover.H:63
Foam::medialAxisMeshMover::update
void update(const dictionary &)
Initialise medial axis. Uses pointDisplacement field only.
Definition: medialAxisMeshMover.C:115
Foam::externalDisplacementMeshMover::pointDisplacement
pointVectorField & pointDisplacement()
Return reference to the point motion displacement field.
Definition: externalDisplacementMeshMover.H:151
NotImplemented
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
Definition: error.H:365
Foam::medialAxisMeshMover::fieldSmoother_
fieldSmoother fieldSmoother_
Field smoothing.
Definition: medialAxisMeshMover.H:83
Foam::label
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
Foam::Field
Pre-declare SubField and related Field type.
Definition: Field.H:57
Foam::medialAxisMeshMover::isMaxEdge
bool isMaxEdge(const List< PointData< vector > > &pointWallDist, const label edgeI, const scalar minCos) const
Is mesh edge on a cusp of displacement.
Definition: medialAxisMeshMover.C:58
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:97
Foam::externalDisplacementMeshMover
Virtual base class for mesh movers with externally provided displacement field giving the boundary co...
Definition: externalDisplacementMeshMover.H:56
Foam::medialAxisMeshMover::meshMover_
motionSmootherAlgo meshMover_
Mesh mover algorithm.
Definition: medialAxisMeshMover.H:80
Foam::medialAxisMeshMover::updateMesh
virtual void updateMesh(const mapPolyMesh &)
Update local data for topology changes.
Definition: medialAxisMeshMover.H:233
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::medialAxisMeshMover::movePoints
virtual void movePoints(const pointField &)
Update local data for geometry changes.
Definition: medialAxisMeshMover.C:1762
Foam::medialAxisMeshMover::medialDist_
pointScalarField medialDist_
Distance to nearest medial axis point.
Definition: medialAxisMeshMover.H:97
fieldSmoother.H
Foam::dictionary
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:137
fld
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))
Foam::medialAxisMeshMover::dispVec_
pointVectorField dispVec_
Normal of nearest wall. Where this normal changes direction.
Definition: medialAxisMeshMover.H:90
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::medialAxisMeshMover::TypeName
TypeName("displacementMedialAxis")
Runtime type information.
Foam::medialAxisMeshMover::medialAxisMeshMover
medialAxisMeshMover(const medialAxisMeshMover &)
Disallow default bitwise copy construct.
Foam::autoPtr
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:117
Foam::medialAxisMeshMover::oldPoints_
pointField oldPoints_
Starting mesh position.
Definition: medialAxisMeshMover.H:77
Foam::List
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: HashTable.H:59
motionSmootherAlgo.H
Foam::medialAxisMeshMover::unmarkExtrusion
static bool unmarkExtrusion(const label patchPointI, pointField &patchDisp, List< autoLayerDriver::extrudeMode > &extrudeStatus)
Unmark extrusion at given point.
Definition: medialAxisMeshMover.C:624
Foam::medialAxisMeshMover::scale_
pointScalarField scale_
Scale factor for displacement.
Definition: medialAxisMeshMover.H:74
Foam::medialAxisMeshMover::adaptPatchPtr_
autoPtr< indirectPrimitivePatch > adaptPatchPtr_
Definition: medialAxisMeshMover.H:71
Foam::medialAxisMeshMover::move
virtual bool move(const dictionary &, const label nAllowableErrors, labelList &checkFaces)
Move mesh using current pointDisplacement boundary values.
Definition: medialAxisMeshMover.C:1700
Foam::mapPolyMesh
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
Definition: mapPolyMesh.H:158
Foam::medialAxisMeshMover::medialVec_
pointVectorField medialVec_
Location on nearest medial axis point.
Definition: medialAxisMeshMover.H:100
Foam::medialAxisMeshMover::adaptPatchIDs_
const labelList adaptPatchIDs_
Definition: medialAxisMeshMover.H:69
autoLayerDriver.H
Foam::GeometricField
Generic GeometricField class.
Definition: surfaceFieldsFwd.H:52
Foam::medialAxisMeshMover::getPatchFieldTypes
wordList getPatchFieldTypes(const pointVectorField &fld)
Extract bc types. Replace fixedValue derivatives with fixedValue.
Foam::medialAxisMeshMover::findIsolatedRegions
void findIsolatedRegions(const scalar minCosLayerTermination, const bool detectExtrusionIsland, const PackedBoolList &isMasterPoint, const PackedBoolList &isMasterEdge, const labelList &meshEdges, const scalarField &minThickness, List< autoLayerDriver::extrudeMode > &extrudeStatus, pointField &patchDisp) const
Find isolated islands (points, edges and faces and layer.
Definition: medialAxisMeshMover.C:901
Foam::medialAxisMeshMover::shrinkMesh
bool shrinkMesh(const dictionary &meshQualityDict, const label nAllowableErrors, labelList &checkFaces)
Move mesh according to calculated displacement.
Definition: medialAxisMeshMover.C:1638