1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
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.
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
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/>.
28 All to do with snapping to surface
32 autoSnapDriverFeature.C
34 \*---------------------------------------------------------------------------*/
36 #ifndef autoSnapDriver_H
37 #define autoSnapDriver_H
39 #include "meshRefinement.H"
41 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
46 // Forward declaration of classes
49 class pointConstraint;
51 /*---------------------------------------------------------------------------*\
52 Class autoSnapDriver Declaration
53 \*---------------------------------------------------------------------------*/
60 meshRefinement& meshRefiner_;
62 //- From surface region to patch
63 const labelList globalToPatch_;
66 // Private Member Functions
71 //- Calculates (geometric) shared points
72 static label getCollocatedPoints
79 //- Calculate displacement per patch point to smooth out patch.
80 // Quite complicated in determining which points to move where.
81 pointField smoothPatchDisplacement
83 const motionSmoother&,
84 const List<labelPair>&
87 //- Check that face zones are synced
88 void checkCoupledFaceZones() const;
90 //- Per edge distance to patch
91 static tmp<scalarField> edgePatchDist
94 const indirectPrimitivePatch&
97 //- Write displacement as .obj file.
105 //- Check displacement is outwards pointing
106 static bool outwardsDisplacement
108 const indirectPrimitivePatch&,
112 // Feature line snapping
114 void smoothAndConstrain
116 const indirectPrimitivePatch& pp,
117 const List<pointConstraint>& constraints,
122 // const pointField& points,
123 // vectorField& disp,
124 // vectorField& surfaceNormal
129 const indirectPrimitivePatch& pp,
130 vectorField& faceDisp,
131 vectorField& faceSurfaceNormal,
132 vectorField& faceRotation
134 void interpolateFaceToPoint
137 const indirectPrimitivePatch& pp,
138 const vectorField& faceSurfaceNormal,
140 const vectorField& faceDisp,
141 const vectorField& faceRotation,
143 vectorField& patchDisp,
144 vectorField& patchRotationDisp
146 void correctAttraction
148 const DynamicList<point>& surfacePoints,
149 const DynamicList<label>& surfaceCount,
151 const vector& edgeNormal, // normalised normal
153 vector& edgeOffset // offset from pt to point on edge
158 const scalar featureCos,
160 const indirectPrimitivePatch& pp,
161 const scalar snapDist,
164 const vector& faceSurfaceNormal,
165 const vector& faceDisp,
167 DynamicList<point>& surfacePoints,
168 DynamicList<vector>& surfaceNormals,
169 DynamicList<label>& surfaceCount
174 const scalar featureCos,
176 const indirectPrimitivePatch& pp,
177 const scalarField& snapDist,
180 const List<List<point> >& pointFaceNormals,
181 const List<List<point> >& pointFaceDisp,
182 const List<List<point> >& pointFaceCentres,
184 DynamicList<point>& surfacePoints,
185 DynamicList<vector>& surfaceNormals,
186 DynamicList<label>& surfaceCount
189 void featureAttractionUsingReconstruction
192 const scalar featureCos,
193 const indirectPrimitivePatch& pp,
194 const scalarField& snapDist,
196 const List<List<point> >& pointFaceNormals,
197 const List<List<point> >& pointFaceDisp,
198 const List<List<point> >& pointFaceCentres,
200 vectorField& patchAttraction,
201 List<pointConstraint>& patchConstraints
204 void determineAllFeatures
207 const scalar featureCos,
209 const indirectPrimitivePatch&,
212 const List<List<point> >& pointFaceNormals,
213 const List<List<point> >& pointFaceDisp,
214 const List<List<point> >& pointFaceCentres,
216 List<labelList>& pointAttractor,
217 List<List<pointConstraint> >& pointConstraints,
218 // Feature-edge to pp point
219 List<List<DynamicList<point> > >& edgeAttractors,
220 List<List<DynamicList<pointConstraint> > >& edgeConstraints,
221 vectorField& patchAttraction,
222 List<pointConstraint>& patchConstraints
224 void determineFeatures
227 const scalar featureCos,
229 const indirectPrimitivePatch&,
232 const List<List<point> >& pointFaceNormals,
233 const List<List<point> >& pointFaceDisp,
234 const List<List<point> >& pointFaceCentres,
236 List<labelList>& pointAttractor,
237 List<List<pointConstraint> >& pointConstraints,
238 // Feature-edge to pp point
239 List<List<DynamicList<point> > >& edgeAttractors,
240 List<List<DynamicList<pointConstraint> > >& edgeConstraints,
241 vectorField& patchAttraction,
242 List<pointConstraint>& patchConstraints
245 void featureAttractionUsingFeatureEdges
248 const scalar featureCos,
249 const indirectPrimitivePatch& pp,
250 const scalarField& snapDist,
252 const List<List<point> >& pointFaceNormals,
253 const List<List<point> >& pointFaceDisp,
254 const List<List<point> >& pointFaceCentres,
256 vectorField& patchAttraction,
257 List<pointConstraint>& patchConstraints
259 void preventFaceSqueeze
262 const scalar featureCos,
263 const indirectPrimitivePatch& pp,
264 const scalarField& snapDist,
266 vectorField& patchAttraction,
267 List<pointConstraint>& patchConstraints
270 vectorField calcNearestSurfaceFeature
273 const scalar featureCos,
274 const scalar featureAttract,
275 const scalarField& snapDist,
276 const vectorField& nearestDisp,
277 motionSmoother& meshMover
281 //- Disallow default bitwise copy construct
282 autoSnapDriver(const autoSnapDriver&);
284 //- Disallow default bitwise assignment
285 void operator=(const autoSnapDriver&);
290 //- Runtime type information
291 ClassName("autoSnapDriver");
296 //- Construct from components
299 meshRefinement& meshRefiner,
300 const labelList& globalToPatch
309 autoPtr<mapPolyMesh> mergeZoneBaffles(const List<labelPair>&);
311 //- Calculate edge length per patch point.
312 scalarField calcSnapDistance
314 const snapParameters& snapParams,
315 const indirectPrimitivePatch&
318 //- Smooth the mesh (patch and internal) to increase visibility
319 // of surface points (on castellated mesh) w.r.t. surface.
322 const snapParameters& snapParams,
323 const label nInitErrors,
324 const List<labelPair>& baffles,
328 //- Get points both on patch and facezone.
329 labelList getZoneSurfacePoints
331 const indirectPrimitivePatch&,
335 //- Per patch point calculate point on nearest surface. Set as
336 // boundary conditions of motionSmoother displacement field. Return
337 // displacement of patch points.
338 vectorField calcNearestSurface
340 const scalarField& snapDist,
341 motionSmoother& meshMover
345 //- Smooth the displacement field to the internal.
346 void smoothDisplacement
348 const snapParameters& snapParams,
352 //- Do the hard work: move the mesh according to displacement,
353 // locally relax the displacement. Return true if ended up with
354 // correct mesh, false if not.
357 const snapParameters& snapParams,
358 const label nInitErrors,
359 const List<labelPair>& baffles,
363 //- Repatch faces according to surface nearest the face centre
364 autoPtr<mapPolyMesh> repatchToSurface
366 const snapParameters& snapParams,
367 const labelList& adaptPatchIDs
372 const dictionary& snapDict,
373 const dictionary& motionDict,
374 const scalar featureCos,
375 const snapParameters& snapParams
381 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
383 } // End namespace Foam
385 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
389 // ************************************************************************* //