/*---------------------------------------------------------------------------*\ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License This file is part of OpenFOAM. OpenFOAM is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. OpenFOAM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenFOAM. If not, see . Class CV2D Description Conformal-Voronoi 2D automatic mesher with grid or read initial points and point position relaxation with optional "squarification". There are a substantial number of options to this mesher read from CV2DMesherDict file e.g.: // Min cell size used in tolerances when inserting points for // boundary conforming. // Also used to as the grid spacing usind in insertGrid. minCellSize 0.05; // Feature angle used to inser feature points // 0 = all features, 180 = no features featureAngle 45; // Maximum quadrant angle allowed at a concave corner before // additional "mitering" lines are added maxQuadAngle 110; // Should the mesh be square-dominated or of unbiased hexagons squares yes; // Near-wall region where cells are aligned with the wall specified as a // number of cell layers nearWallAlignedDist 3; // Chose if the cell orientation should relax during the iterations // or remain fixed to the x-y directions relaxOrientation no; // Insert near-boundary point mirror or point-pairs insertSurfaceNearestPointPairs yes; // Mirror near-boundary points rather than insert point-pairs mirrorPoints no; // Insert point-pairs vor dual-cell vertices very near the surface insertSurfaceNearPointPairs yes; // Choose if to randomise the initial grid created by insertGrid. randomiseInitialGrid yes; // Perturbation fraction, 1 = cell-size. randomPurturbation 0.1; // Number of relaxation iterations. nIterations 5; // Relaxation factor at the start of the iteration sequence. // 0.5 is a sensible maximum and < 0.2 converges better. relaxationFactorStart 0.8; // Relaxation factor at the end of the iteration sequence. // Should be <= relaxationFactorStart relaxationFactorEnd 0; writeInitialTriangulation no; writeFeatureTriangulation no; writeNearestTriangulation no; writeInsertedPointPairs no; writeFinalTriangulation yes; // Maximum number of iterations used in boundaryConform. maxBoundaryConformingIter 5; minEdgeLenCoeff 0.5; maxNotchLenCoeff 0.3; minNearPointDistCoeff 0.25; ppDistCoeff 0.05; SourceFiles CGALTriangulation2Ddefs.H indexedVertex.H indexedFace.H CV2DI.H CV2D.C CV2DIO.C tolerances.C controls.C insertFeaturePoints.C insertSurfaceNearestPointPairs.C insertSurfaceNearPointPairs.C insertBoundaryConformPointPairs.C \*---------------------------------------------------------------------------*/ #ifndef CV2D_H #define CV2D_H #define CGAL_INEXACT #define CGAL_HIERARCHY #include "CGALTriangulation2Ddefs.H" #include "Time.H" #include "point2DFieldFwd.H" #include "dictionary.H" #include "Switch.H" #include "PackedBoolList.H" #include "EdgeMap.H" #include "cv2DControls.H" #include "tolerances.H" #include "meshTools.H" #include "triSurface.H" #include "searchableSurfaces.H" #include "conformationSurfaces.H" #include "cellSizeControlSurfaces.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam { /*---------------------------------------------------------------------------*\ Class CV2D Declaration \*---------------------------------------------------------------------------*/ class CV2D : public Delaunay { private: // Private data //- The time registry of the application const Time& runTime_; mutable Random rndGen_; //- The surface to mesh //const querySurface& qSurf_; //- All geometry of the meshing process, including surfaces to be // conformed to and those to be used for refinement searchableSurfaces allGeometry_; conformationSurfaces qSurf_; //- Meshing controls cv2DControls controls_; //- The cell size control object cellSizeControlSurfaces cellSizeControl_; //- z-level scalar z_; //- Keep track of the start of the internal points label startOfInternalPoints_; //- Keep track of the start of the surface point-pairs label startOfSurfacePointPairs_; //- Keep track of the boundary conform point-pairs // stored after the insertion of the surface point-pairs in case // the boundary conform function is called more than once without // removing and insertin the surface point-pairs label startOfBoundaryConformPointPairs_; //- Store the feature points std::list featurePoints_; //- Temporary storage for a dual-cell static const label maxNvert = 20; mutable point2D vertices[maxNvert+1]; mutable vector2D edges[maxNvert+1]; // Private Member Functions //- Disallow default bitwise copy construct CV2D(const CV2D&); //- Disallow default bitwise assignment void operator=(const CV2D&); //- Insert point and return it's index inline label insertPoint ( const point2D& pt, const label type ); //- Insert point and return it's index inline label insertPoint ( const point2D& pt, const label index, const label type ); inline label insertPoint ( const Point& p, const label index, const label type ); inline bool insertMirrorPoint ( const point2D& nearSurfPt, const point2D& surfPt ); //- Insert a point-pair at a distance ppDist either side of // surface point point surfPt in the direction n inline void insertPointPair ( const scalar mirrorDist, const point2D& surfPt, const vector2D& n ); //- Create the initial mesh from the bounding-box void insertBoundingBox(); //- Check if a point is within a line. bool on2DLine(const point2D& p, const linePointRef& line); //- Insert point groups at the feature points. void insertFeaturePoints(); //- Re-insert point groups at the feature points. void reinsertFeaturePoints(); //- Insert point-pairs at the given set of points using the surface // normals corresponding to the given set of surface triangles // and write the inserted point locations to the given file. void insertPointPairs ( const DynamicList& nearSurfacePoints, const DynamicList& surfacePoints, const DynamicList