From c0a417355df37b32596761c61311d833793789ff Mon Sep 17 00:00:00 2001 From: laurence Date: Tue, 8 Jan 2013 10:48:45 +0000 Subject: [PATCH 001/136] Revert "COMP: cvMesh and cv2DMesh removed" This reverts commit e4c1409679f29a4e90ae01ef731465d45beff624. --- applications/test/vectorTools/Make/files | 3 + applications/test/vectorTools/Make/options | 1 + .../test/vectorTools/Test-vectorTools.C | 71 + .../mesh/advanced/collapseEdges/collapseDict | 18 +- .../utilities/mesh/generation/Allwmake | 5 + .../mesh/generation/cv2DMesh/Allwclean | 8 + .../mesh/generation/cv2DMesh/Allwmake | 8 + .../cv2DMesh/CGALTriangulation2DKernel.H | 60 + .../cv2DMesh/CGALTriangulation2Ddefs.H | 76 + .../utilities/mesh/generation/cv2DMesh/CV2D.C | 997 + .../utilities/mesh/generation/cv2DMesh/CV2D.H | 474 + .../mesh/generation/cv2DMesh/CV2DI.H | 227 + .../mesh/generation/cv2DMesh/CV2DIO.C | 386 + .../mesh/generation/cv2DMesh/Make/files | 12 + .../mesh/generation/cv2DMesh/Make/options | 43 + .../conformalVoronoi2DMesh/Make/files | 3 + .../conformalVoronoi2DMesh/Make/options | 3 + .../cv2DControls/cv2DControls.C | 154 + .../cv2DControls/cv2DControls.H | 260 + .../cv2DControls/cv2DControlsI.H | 158 + .../mesh/generation/cv2DMesh/cv2DMesh.C | 230 + .../mesh/generation/cv2DMesh/cv2DMeshDict | 208 + .../mesh/generation/cv2DMesh/indexedFace.H | 135 + .../mesh/generation/cv2DMesh/indexedFaceI.H | 110 + .../mesh/generation/cv2DMesh/indexedVertex.H | 210 + .../mesh/generation/cv2DMesh/indexedVertexI.H | 233 + .../insertBoundaryConformPointPairs.C | 323 + .../generation/cv2DMesh/insertFeaturePoints.C | 394 + .../cv2DMesh/insertSurfaceNearPointPairs.C | 114 + .../cv2DMesh/insertSurfaceNearestPointPairs.C | 244 + .../generation/cv2DMesh/shortEdgeFilter2D.C | 533 + .../generation/cv2DMesh/shortEdgeFilter2D.H | 133 + .../mesh/generation/cvMesh/Allwclean | 10 + .../utilities/mesh/generation/cvMesh/Allwmake | 11 + .../mesh/generation/cvMesh/Make/files | 3 + .../mesh/generation/cvMesh/Make/options | 38 + .../cellSizeAndAlignmentGrid/Make/files | 2 + .../cellSizeAndAlignmentGrid/Make/options | 40 + .../cellSizeAndAlignmentGrid.C | 716 + .../cvMesh/checkCvMesh/meshQualityDict | 73 + .../DelaunayMesh/DelaunayMesh.C | 233 + .../DelaunayMesh/DelaunayMesh.H | 238 + .../DelaunayMesh/DelaunayMeshI.H | 119 + .../DelaunayMesh/DelaunayMeshIO.C | 391 + .../DelaunayMesh/DistributedDelaunayMesh.C | 938 + .../DelaunayMesh/DistributedDelaunayMesh.H | 208 + .../cvMesh/conformalVoronoiMesh/Make/files | 66 + .../cvMesh/conformalVoronoiMesh/Make/options | 33 + .../PrintTable/PrintTable.C | 234 + .../PrintTable/PrintTable.H | 140 + .../PrintTable/PrintTableI.H | 42 + .../backgroundMeshDecomposition.C | 1804 ++ .../backgroundMeshDecomposition.H | 340 + .../backgroundMeshDecompositionI.H | 67 + .../cellAspectRatioControl.C | 110 + .../cellAspectRatioControl.H | 115 + .../cellShapeControl/cellShapeControl.C | 930 + .../cellShapeControl/cellShapeControl.H | 213 + .../cellShapeControl/cellShapeControlI.H | 55 + .../cellShapeControlMesh.C | 760 + .../cellShapeControlMesh.H | 168 + .../cellShapeControlMeshI.H | 68 + .../cellSizeAndAlignmentControl.C | 120 + .../cellSizeAndAlignmentControl.H | 160 + .../cellSizeAndAlignmentControls.C | 177 + .../cellSizeAndAlignmentControls.H | 119 + .../fileControl/fileControl.C | 242 + .../fileControl/fileControl.H | 140 + .../searchableSurfaceControl.C | 666 + .../searchableSurfaceControl.H | 173 + .../cellSizeFunction/cellSizeFunction.C | 146 + .../cellSizeFunction/cellSizeFunction.H | 201 + .../linearDistance/linearDistance.C | 200 + .../linearDistance/linearDistance.H | 121 + .../linearSpatial/linearSpatial.C | 142 + .../linearSpatial/linearSpatial.H | 119 + .../surfaceOffsetLinearDistance.C | 224 + .../surfaceOffsetLinearDistance.H | 119 + .../cellSizeFunction/uniform/uniform.C | 175 + .../cellSizeFunction/uniform/uniform.H | 106 + .../uniformDistance/uniformDistance.C | 164 + .../uniformDistance/uniformDistance.H | 112 + .../automatic/automatic.C | 292 + .../automatic/automatic.H | 129 + .../cellSizeCalculationType.C | 97 + .../cellSizeCalculationType.H | 134 + .../fieldFromFile/fieldFromFile.C | 88 + .../fieldFromFile/fieldFromFile.H | 105 + .../nonUniformField/nonUniformField.C | 167 + .../nonUniformField/nonUniformField.H | 123 + .../surfaceCellSizeFunction.C | 102 + .../surfaceCellSizeFunction.H | 159 + .../uniformValue/uniformValue.C | 86 + .../uniformValue/uniformValue.H | 105 + .../CGALTriangulation3DKernel.H | 62 + .../CGALTriangulation3Ddefs.H | 60 + .../conformalVoronoiMesh.C | 2224 ++ .../conformalVoronoiMesh.H | 1197 + .../conformalVoronoiMeshCalcDualMesh.C | 2571 ++ .../conformalVoronoiMeshConformToSurface.C | 2106 ++ ...alVoronoiMeshFeaturePointSpecialisations.C | 436 + .../conformalVoronoiMeshFeaturePoints.C | 1235 + .../conformalVoronoiMeshI.H | 692 + .../conformalVoronoiMeshIO.C | 1784 ++ .../indexedCell/indexedCell.C | 89 + .../indexedCell/indexedCell.H | 262 + .../indexedCell/indexedCellChecks.C | 128 + .../indexedCell/indexedCellChecks.H | 77 + .../indexedCell/indexedCellEnum.C | 46 + .../indexedCell/indexedCellEnum.H | 80 + .../indexedCell/indexedCellI.H | 538 + .../indexedVertex/indexedVertex.C | 185 + .../indexedVertex/indexedVertex.H | 354 + .../indexedVertex/indexedVertexEnum.C | 88 + .../indexedVertex/indexedVertexEnum.H | 95 + .../indexedVertex/indexedVertexI.H | 334 + .../conformalVoronoiMesh/pointConversion.H | 99 + .../pointFeatureEdgesTypes.H | 93 + .../conformationSurfaces.C | 895 + .../conformationSurfaces.H | 328 + .../conformationSurfacesI.H | 71 + .../cvControls/cvControls.C | 227 + .../cvControls/cvControls.H | 333 + .../cvControls/cvControlsI.H | 203 + .../faceAreaWeightModel/faceAreaWeightModel.C | 99 + .../faceAreaWeightModel/faceAreaWeightModel.H | 142 + .../piecewiseLinearRamp/piecewiseLinearRamp.C | 80 + .../piecewiseLinearRamp/piecewiseLinearRamp.H | 98 + .../autoDensity/autoDensity.C | 947 + .../autoDensity/autoDensity.H | 171 + .../bodyCentredCubic/bodyCentredCubic.C | 194 + .../bodyCentredCubic/bodyCentredCubic.H | 104 + .../faceCentredCubic/faceCentredCubic.C | 255 + .../faceCentredCubic/faceCentredCubic.H | 104 + .../initialPointsMethod/initialPointsMethod.C | 112 + .../initialPointsMethod/initialPointsMethod.H | 154 + .../initialPointsMethod/pointFile/pointFile.C | 174 + .../initialPointsMethod/pointFile/pointFile.H | 100 + .../uniformGrid/uniformGrid.C | 171 + .../uniformGrid/uniformGrid.H | 104 + .../adaptiveLinear/adaptiveLinear.C | 87 + .../adaptiveLinear/adaptiveLinear.H | 110 + .../rampHoldFall/rampHoldFall.C | 103 + .../rampHoldFall/rampHoldFall.H | 115 + .../relaxationModel/relaxationModel.C | 102 + .../relaxationModel/relaxationModel.H | 147 + .../utilities/mesh/generation/cvMesh/cvMesh.C | 124 + .../cvMesh/cvMeshBackgroundMesh/Make/files | 3 + .../cvMesh/cvMeshBackgroundMesh/Make/options | 33 + .../cvMeshBackgroundMesh.C | 775 + .../mesh/generation/cvMesh/cvMeshDict | 533 + .../cvMesh/cvMeshSurfaceSimplify/Allwmake | 10 + .../cvMesh/cvMeshSurfaceSimplify/Make/files | 22 + .../cvMesh/cvMeshSurfaceSimplify/Make/options | 28 + .../cvMeshSurfaceSimplify.C | 639 + .../cvMeshSurfaceSimplify_non_octree.C | 352 + .../cvMesh/vectorTools/vectorTools.H | 157 + .../extrude2DMesh/extrude2DMesh.C | 3 +- .../extrude2DMesh/extrude2DMesh.H | 59 +- .../extrude2DMesh/extrude2DMeshDict | 36 +- tutorials/mesh/cv2DMesh/OpenCFD/0.org/T | 50 + tutorials/mesh/cv2DMesh/OpenCFD/0.org/U | 59 + tutorials/mesh/cv2DMesh/OpenCFD/0.org/p | 51 + tutorials/mesh/cv2DMesh/OpenCFD/Allclean | 15 + tutorials/mesh/cv2DMesh/OpenCFD/Allrun | 15 + .../cv2DMesh/OpenCFD/Allrun-rhoCentralFoam | 18 + .../OpenCFD/constant/thermophysicalProperties | 43 + .../constant/triSurface/opencfd_box.stl | 96 + .../constant/triSurface/opencfd_text.stl | 16466 ++++++++++++ .../OpenCFD/constant/turbulenceProperties | 21 + .../mesh/cv2DMesh/OpenCFD/system/controlDict | 55 + .../OpenCFD/system/controlDict.mesher | 55 + .../OpenCFD/system/controlDict.rhoCentralFoam | 55 + .../mesh/cv2DMesh/OpenCFD/system/cv2DMeshDict | 158 + .../cv2DMesh/OpenCFD/system/decomposeParDict | 45 + .../cv2DMesh/OpenCFD/system/extrude2DMeshDict | 42 + .../mesh/cv2DMesh/OpenCFD/system/fvSchemes | 61 + .../mesh/cv2DMesh/OpenCFD/system/fvSolution | 42 + .../OpenCFD/system/surfaceFeatureExtractDict | 87 + .../mesh/cv2DMesh/jaggedBoundary/Allclean | 16 + tutorials/mesh/cv2DMesh/jaggedBoundary/Allrun | 13 + .../constant/triSurface/jaggedBoundary.stl | 954 + .../jaggedBoundary/system/controlDict | 47 + .../jaggedBoundary/system/cv2DMeshDict | 147 + .../jaggedBoundary/system/extrude2DMeshDict | 42 + .../cv2DMesh/jaggedBoundary/system/fvSchemes | 54 + .../cv2DMesh/jaggedBoundary/system/fvSolution | 22 + .../system/surfaceFeatureExtractDict | 52 + tutorials/mesh/cv2DMesh/square/Allclean | 16 + tutorials/mesh/cv2DMesh/square/Allrun | 13 + .../square/constant/triSurface/unit_cube.stl | 88 + .../mesh/cv2DMesh/square/system/controlDict | 52 + .../mesh/cv2DMesh/square/system/cv2DMeshDict | 165 + .../cv2DMesh/square/system/extrude2DMeshDict | 42 + .../mesh/cv2DMesh/square/system/fvSchemes | 54 + .../mesh/cv2DMesh/square/system/fvSolution | 22 + .../square/system/surfaceFeatureExtractDict | 52 + tutorials/mesh/cvMesh/blob/Allclean | 14 + tutorials/mesh/cvMesh/blob/Allrun | 11 + tutorials/mesh/cvMesh/blob/Allrun-parallel | 19 + tutorials/mesh/cvMesh/blob/Alltest | 18 + .../blob/constant/polyMesh/blockMeshDict | 69 + .../cvMesh/blob/constant/polyMesh/boundary | 28 + .../cvMesh/blob/constant/triSurface/blob.stl | 21506 ++++++++++++++++ .../mesh/cvMesh/blob/system/collapseDict | 54 + tutorials/mesh/cvMesh/blob/system/controlDict | 53 + tutorials/mesh/cvMesh/blob/system/cvMeshDict | 212 + .../mesh/cvMesh/blob/system/decomposeParDict | 47 + tutorials/mesh/cvMesh/blob/system/fvSchemes | 54 + tutorials/mesh/cvMesh/blob/system/fvSolution | 22 + .../mesh/cvMesh/blob/system/meshQualityDict | 73 + .../mesh/cvMesh/blob/system/snappyHexMeshDict | 310 + tutorials/mesh/cvMesh/blob/system/topoSetDict | 149 + tutorials/mesh/cvMesh/flange/Allclean | 14 + tutorials/mesh/cvMesh/flange/Allrun | 19 + tutorials/mesh/cvMesh/flange/Allrun-parallel | 26 + tutorials/mesh/cvMesh/flange/Alltest | 21 + .../flange/constant/polyMesh/blockMeshDict | 69 + .../cvMesh/flange/constant/polyMesh/boundary | 28 + .../flange/constant/triSurface/flange.obj | 9710 +++++++ .../mesh/cvMesh/flange/system/collapseDict | 52 + .../mesh/cvMesh/flange/system/controlDict | 58 + .../mesh/cvMesh/flange/system/cvMeshDict | 200 + .../cvMesh/flange/system/decomposeParDict | 46 + .../mesh/cvMesh/flange/system/faceSetDict | 35 + tutorials/mesh/cvMesh/flange/system/fvSchemes | 55 + .../mesh/cvMesh/flange/system/fvSolution | 29 + .../mesh/cvMesh/flange/system/meshQualityDict | 73 + .../cvMesh/flange/system/snappyHexMeshDict | 308 + .../flange/system/surfaceFeatureExtractDict | 38 + .../flange/system/topoSetDict-background | 319 + .../cvMesh/flange/system/topoSetDict-slices | 152 + tutorials/mesh/cvMesh/simpleShapes/Allclean | 18 + tutorials/mesh/cvMesh/simpleShapes/Allrun | 43 + .../simpleShapes/constant/triSurface/cone.stl | 828 + .../constant/triSurface/coneAndSphere.obj | 1489 ++ .../constant/triSurface/domain.stl | 86 + .../constant/triSurface/sphere.stl | 5042 ++++ .../cvMesh/simpleShapes/system/collapseDict | 52 + .../cvMesh/simpleShapes/system/controlDict | 54 + .../cvMesh/simpleShapes/system/cvMeshDict | 371 + .../mesh/cvMesh/simpleShapes/system/fvSchemes | 55 + .../cvMesh/simpleShapes/system/fvSolution | 41 + .../simpleShapes/system/meshQualityDict | 73 + .../system/surfaceFeatureExtractDict | 57 + .../cvMesh/simpleShapes/system/topoSetDict | 148 + 246 files changed, 104021 insertions(+), 63 deletions(-) create mode 100644 applications/test/vectorTools/Make/files create mode 100644 applications/test/vectorTools/Make/options create mode 100644 applications/test/vectorTools/Test-vectorTools.C create mode 100755 applications/utilities/mesh/generation/cv2DMesh/Allwclean create mode 100755 applications/utilities/mesh/generation/cv2DMesh/Allwmake create mode 100644 applications/utilities/mesh/generation/cv2DMesh/CGALTriangulation2DKernel.H create mode 100644 applications/utilities/mesh/generation/cv2DMesh/CGALTriangulation2Ddefs.H create mode 100644 applications/utilities/mesh/generation/cv2DMesh/CV2D.C create mode 100644 applications/utilities/mesh/generation/cv2DMesh/CV2D.H create mode 100644 applications/utilities/mesh/generation/cv2DMesh/CV2DI.H create mode 100644 applications/utilities/mesh/generation/cv2DMesh/CV2DIO.C create mode 100755 applications/utilities/mesh/generation/cv2DMesh/Make/files create mode 100755 applications/utilities/mesh/generation/cv2DMesh/Make/options create mode 100755 applications/utilities/mesh/generation/cv2DMesh/conformalVoronoi2DMesh/Make/files create mode 100755 applications/utilities/mesh/generation/cv2DMesh/conformalVoronoi2DMesh/Make/options create mode 100644 applications/utilities/mesh/generation/cv2DMesh/conformalVoronoi2DMesh/cv2DControls/cv2DControls.C create mode 100644 applications/utilities/mesh/generation/cv2DMesh/conformalVoronoi2DMesh/cv2DControls/cv2DControls.H create mode 100644 applications/utilities/mesh/generation/cv2DMesh/conformalVoronoi2DMesh/cv2DControls/cv2DControlsI.H create mode 100644 applications/utilities/mesh/generation/cv2DMesh/cv2DMesh.C create mode 100644 applications/utilities/mesh/generation/cv2DMesh/cv2DMeshDict create mode 100644 applications/utilities/mesh/generation/cv2DMesh/indexedFace.H create mode 100644 applications/utilities/mesh/generation/cv2DMesh/indexedFaceI.H create mode 100644 applications/utilities/mesh/generation/cv2DMesh/indexedVertex.H create mode 100644 applications/utilities/mesh/generation/cv2DMesh/indexedVertexI.H create mode 100644 applications/utilities/mesh/generation/cv2DMesh/insertBoundaryConformPointPairs.C create mode 100644 applications/utilities/mesh/generation/cv2DMesh/insertFeaturePoints.C create mode 100644 applications/utilities/mesh/generation/cv2DMesh/insertSurfaceNearPointPairs.C create mode 100644 applications/utilities/mesh/generation/cv2DMesh/insertSurfaceNearestPointPairs.C create mode 100644 applications/utilities/mesh/generation/cv2DMesh/shortEdgeFilter2D.C create mode 100644 applications/utilities/mesh/generation/cv2DMesh/shortEdgeFilter2D.H create mode 100755 applications/utilities/mesh/generation/cvMesh/Allwclean create mode 100755 applications/utilities/mesh/generation/cvMesh/Allwmake create mode 100644 applications/utilities/mesh/generation/cvMesh/Make/files create mode 100644 applications/utilities/mesh/generation/cvMesh/Make/options create mode 100644 applications/utilities/mesh/generation/cvMesh/cellSizeAndAlignmentGrid/Make/files create mode 100644 applications/utilities/mesh/generation/cvMesh/cellSizeAndAlignmentGrid/Make/options create mode 100644 applications/utilities/mesh/generation/cvMesh/cellSizeAndAlignmentGrid/cellSizeAndAlignmentGrid.C create mode 100644 applications/utilities/mesh/generation/cvMesh/checkCvMesh/meshQualityDict create mode 100644 applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/DelaunayMesh/DelaunayMesh.C create mode 100644 applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/DelaunayMesh/DelaunayMesh.H create mode 100644 applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/DelaunayMesh/DelaunayMeshI.H create mode 100644 applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/DelaunayMesh/DelaunayMeshIO.C create mode 100644 applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/DelaunayMesh/DistributedDelaunayMesh.C create mode 100644 applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/DelaunayMesh/DistributedDelaunayMesh.H create mode 100644 applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/Make/files create mode 100644 applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/Make/options create mode 100644 applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/PrintTable/PrintTable.C create mode 100644 applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/PrintTable/PrintTable.H create mode 100644 applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/PrintTable/PrintTableI.H create mode 100644 applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/backgroundMeshDecomposition/backgroundMeshDecomposition.C create mode 100644 applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/backgroundMeshDecomposition/backgroundMeshDecomposition.H create mode 100644 applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/backgroundMeshDecomposition/backgroundMeshDecompositionI.H create mode 100644 applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/cellShapeControl/cellAspectRatioControl/cellAspectRatioControl.C create mode 100644 applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/cellShapeControl/cellAspectRatioControl/cellAspectRatioControl.H create mode 100644 applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/cellShapeControl/cellShapeControl/cellShapeControl.C create mode 100644 applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/cellShapeControl/cellShapeControl/cellShapeControl.H create mode 100644 applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/cellShapeControl/cellShapeControl/cellShapeControlI.H create mode 100644 applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/cellShapeControl/cellShapeControlMesh/cellShapeControlMesh.C create mode 100644 applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/cellShapeControl/cellShapeControlMesh/cellShapeControlMesh.H create mode 100644 applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/cellShapeControl/cellShapeControlMesh/cellShapeControlMeshI.H create mode 100644 applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/cellShapeControl/cellSizeAndAlignmentControl/cellSizeAndAlignmentControl/cellSizeAndAlignmentControl.C create mode 100644 applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/cellShapeControl/cellSizeAndAlignmentControl/cellSizeAndAlignmentControl/cellSizeAndAlignmentControl.H create mode 100644 applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/cellShapeControl/cellSizeAndAlignmentControl/cellSizeAndAlignmentControls.C create mode 100644 applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/cellShapeControl/cellSizeAndAlignmentControl/cellSizeAndAlignmentControls.H create mode 100644 applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/cellShapeControl/cellSizeAndAlignmentControl/fileControl/fileControl.C create mode 100644 applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/cellShapeControl/cellSizeAndAlignmentControl/fileControl/fileControl.H create mode 100644 applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/cellShapeControl/cellSizeAndAlignmentControl/searchableSurfaceControl/searchableSurfaceControl.C create mode 100644 applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/cellShapeControl/cellSizeAndAlignmentControl/searchableSurfaceControl/searchableSurfaceControl.H create mode 100644 applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/cellSizeControlSurfaces/cellSizeFunction/cellSizeFunction/cellSizeFunction.C create mode 100644 applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/cellSizeControlSurfaces/cellSizeFunction/cellSizeFunction/cellSizeFunction.H create mode 100644 applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/cellSizeControlSurfaces/cellSizeFunction/linearDistance/linearDistance.C create mode 100644 applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/cellSizeControlSurfaces/cellSizeFunction/linearDistance/linearDistance.H create mode 100644 applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/cellSizeControlSurfaces/cellSizeFunction/linearSpatial/linearSpatial.C create mode 100644 applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/cellSizeControlSurfaces/cellSizeFunction/linearSpatial/linearSpatial.H create mode 100644 applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/cellSizeControlSurfaces/cellSizeFunction/surfaceOffsetLinearDistance/surfaceOffsetLinearDistance.C create mode 100644 applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/cellSizeControlSurfaces/cellSizeFunction/surfaceOffsetLinearDistance/surfaceOffsetLinearDistance.H create mode 100644 applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/cellSizeControlSurfaces/cellSizeFunction/uniform/uniform.C create mode 100644 applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/cellSizeControlSurfaces/cellSizeFunction/uniform/uniform.H create mode 100644 applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/cellSizeControlSurfaces/cellSizeFunction/uniformDistance/uniformDistance.C create mode 100644 applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/cellSizeControlSurfaces/cellSizeFunction/uniformDistance/uniformDistance.H create mode 100644 applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/cellSizeControlSurfaces/surfaceCellSizeFunction/cellSizeCalculationType/automatic/automatic.C create mode 100644 applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/cellSizeControlSurfaces/surfaceCellSizeFunction/cellSizeCalculationType/automatic/automatic.H create mode 100644 applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/cellSizeControlSurfaces/surfaceCellSizeFunction/cellSizeCalculationType/cellSizeCalculationType/cellSizeCalculationType.C create mode 100644 applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/cellSizeControlSurfaces/surfaceCellSizeFunction/cellSizeCalculationType/cellSizeCalculationType/cellSizeCalculationType.H create mode 100644 applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/cellSizeControlSurfaces/surfaceCellSizeFunction/cellSizeCalculationType/fieldFromFile/fieldFromFile.C create mode 100644 applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/cellSizeControlSurfaces/surfaceCellSizeFunction/cellSizeCalculationType/fieldFromFile/fieldFromFile.H create mode 100644 applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/cellSizeControlSurfaces/surfaceCellSizeFunction/nonUniformField/nonUniformField.C create mode 100644 applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/cellSizeControlSurfaces/surfaceCellSizeFunction/nonUniformField/nonUniformField.H create mode 100644 applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/cellSizeControlSurfaces/surfaceCellSizeFunction/surfaceCellSizeFunction/surfaceCellSizeFunction.C create mode 100644 applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/cellSizeControlSurfaces/surfaceCellSizeFunction/surfaceCellSizeFunction/surfaceCellSizeFunction.H create mode 100644 applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/cellSizeControlSurfaces/surfaceCellSizeFunction/uniformValue/uniformValue.C create mode 100644 applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/cellSizeControlSurfaces/surfaceCellSizeFunction/uniformValue/uniformValue.H create mode 100644 applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/conformalVoronoiMesh/CGALTriangulation3DKernel.H create mode 100644 applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/conformalVoronoiMesh/CGALTriangulation3Ddefs.H create mode 100644 applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.C create mode 100644 applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.H create mode 100644 applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshCalcDualMesh.C create mode 100644 applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshConformToSurface.C create mode 100644 applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshFeaturePointSpecialisations.C create mode 100644 applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshFeaturePoints.C create mode 100644 applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshI.H create mode 100644 applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshIO.C create mode 100644 applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/conformalVoronoiMesh/indexedCell/indexedCell.C create mode 100644 applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/conformalVoronoiMesh/indexedCell/indexedCell.H create mode 100644 applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/conformalVoronoiMesh/indexedCell/indexedCellChecks.C create mode 100644 applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/conformalVoronoiMesh/indexedCell/indexedCellChecks.H create mode 100644 applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/conformalVoronoiMesh/indexedCell/indexedCellEnum.C create mode 100644 applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/conformalVoronoiMesh/indexedCell/indexedCellEnum.H create mode 100644 applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/conformalVoronoiMesh/indexedCell/indexedCellI.H create mode 100644 applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/conformalVoronoiMesh/indexedVertex/indexedVertex.C create mode 100644 applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/conformalVoronoiMesh/indexedVertex/indexedVertex.H create mode 100644 applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/conformalVoronoiMesh/indexedVertex/indexedVertexEnum.C create mode 100644 applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/conformalVoronoiMesh/indexedVertex/indexedVertexEnum.H create mode 100644 applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/conformalVoronoiMesh/indexedVertex/indexedVertexI.H create mode 100644 applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/conformalVoronoiMesh/pointConversion.H create mode 100644 applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/conformalVoronoiMesh/pointFeatureEdgesTypes.H create mode 100644 applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/conformationSurfaces/conformationSurfaces.C create mode 100644 applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/conformationSurfaces/conformationSurfaces.H create mode 100644 applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/conformationSurfaces/conformationSurfacesI.H create mode 100644 applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/cvControls/cvControls.C create mode 100644 applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/cvControls/cvControls.H create mode 100644 applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/cvControls/cvControlsI.H create mode 100644 applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/faceAreaWeightModel/faceAreaWeightModel/faceAreaWeightModel.C create mode 100644 applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/faceAreaWeightModel/faceAreaWeightModel/faceAreaWeightModel.H create mode 100644 applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/faceAreaWeightModel/piecewiseLinearRamp/piecewiseLinearRamp.C create mode 100644 applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/faceAreaWeightModel/piecewiseLinearRamp/piecewiseLinearRamp.H create mode 100644 applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/initialPointsMethod/autoDensity/autoDensity.C create mode 100644 applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/initialPointsMethod/autoDensity/autoDensity.H create mode 100644 applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/initialPointsMethod/bodyCentredCubic/bodyCentredCubic.C create mode 100644 applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/initialPointsMethod/bodyCentredCubic/bodyCentredCubic.H create mode 100644 applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/initialPointsMethod/faceCentredCubic/faceCentredCubic.C create mode 100644 applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/initialPointsMethod/faceCentredCubic/faceCentredCubic.H create mode 100644 applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/initialPointsMethod/initialPointsMethod/initialPointsMethod.C create mode 100644 applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/initialPointsMethod/initialPointsMethod/initialPointsMethod.H create mode 100644 applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/initialPointsMethod/pointFile/pointFile.C create mode 100644 applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/initialPointsMethod/pointFile/pointFile.H create mode 100644 applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/initialPointsMethod/uniformGrid/uniformGrid.C create mode 100644 applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/initialPointsMethod/uniformGrid/uniformGrid.H create mode 100644 applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/relaxationModel/adaptiveLinear/adaptiveLinear.C create mode 100644 applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/relaxationModel/adaptiveLinear/adaptiveLinear.H create mode 100644 applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/relaxationModel/rampHoldFall/rampHoldFall.C create mode 100644 applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/relaxationModel/rampHoldFall/rampHoldFall.H create mode 100644 applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/relaxationModel/relaxationModel/relaxationModel.C create mode 100644 applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/relaxationModel/relaxationModel/relaxationModel.H create mode 100644 applications/utilities/mesh/generation/cvMesh/cvMesh.C create mode 100644 applications/utilities/mesh/generation/cvMesh/cvMeshBackgroundMesh/Make/files create mode 100644 applications/utilities/mesh/generation/cvMesh/cvMeshBackgroundMesh/Make/options create mode 100644 applications/utilities/mesh/generation/cvMesh/cvMeshBackgroundMesh/cvMeshBackgroundMesh.C create mode 100644 applications/utilities/mesh/generation/cvMesh/cvMeshDict create mode 100755 applications/utilities/mesh/generation/cvMesh/cvMeshSurfaceSimplify/Allwmake create mode 100644 applications/utilities/mesh/generation/cvMesh/cvMeshSurfaceSimplify/Make/files create mode 100644 applications/utilities/mesh/generation/cvMesh/cvMeshSurfaceSimplify/Make/options create mode 100644 applications/utilities/mesh/generation/cvMesh/cvMeshSurfaceSimplify/cvMeshSurfaceSimplify.C create mode 100644 applications/utilities/mesh/generation/cvMesh/cvMeshSurfaceSimplify/cvMeshSurfaceSimplify_non_octree.C create mode 100644 applications/utilities/mesh/generation/cvMesh/vectorTools/vectorTools.H create mode 100644 tutorials/mesh/cv2DMesh/OpenCFD/0.org/T create mode 100644 tutorials/mesh/cv2DMesh/OpenCFD/0.org/U create mode 100644 tutorials/mesh/cv2DMesh/OpenCFD/0.org/p create mode 100755 tutorials/mesh/cv2DMesh/OpenCFD/Allclean create mode 100755 tutorials/mesh/cv2DMesh/OpenCFD/Allrun create mode 100755 tutorials/mesh/cv2DMesh/OpenCFD/Allrun-rhoCentralFoam create mode 100644 tutorials/mesh/cv2DMesh/OpenCFD/constant/thermophysicalProperties create mode 100644 tutorials/mesh/cv2DMesh/OpenCFD/constant/triSurface/opencfd_box.stl create mode 100644 tutorials/mesh/cv2DMesh/OpenCFD/constant/triSurface/opencfd_text.stl create mode 100644 tutorials/mesh/cv2DMesh/OpenCFD/constant/turbulenceProperties create mode 100644 tutorials/mesh/cv2DMesh/OpenCFD/system/controlDict create mode 100644 tutorials/mesh/cv2DMesh/OpenCFD/system/controlDict.mesher create mode 100644 tutorials/mesh/cv2DMesh/OpenCFD/system/controlDict.rhoCentralFoam create mode 100644 tutorials/mesh/cv2DMesh/OpenCFD/system/cv2DMeshDict create mode 100644 tutorials/mesh/cv2DMesh/OpenCFD/system/decomposeParDict create mode 100644 tutorials/mesh/cv2DMesh/OpenCFD/system/extrude2DMeshDict create mode 100644 tutorials/mesh/cv2DMesh/OpenCFD/system/fvSchemes create mode 100644 tutorials/mesh/cv2DMesh/OpenCFD/system/fvSolution create mode 100644 tutorials/mesh/cv2DMesh/OpenCFD/system/surfaceFeatureExtractDict create mode 100755 tutorials/mesh/cv2DMesh/jaggedBoundary/Allclean create mode 100755 tutorials/mesh/cv2DMesh/jaggedBoundary/Allrun create mode 100644 tutorials/mesh/cv2DMesh/jaggedBoundary/constant/triSurface/jaggedBoundary.stl create mode 100644 tutorials/mesh/cv2DMesh/jaggedBoundary/system/controlDict create mode 100644 tutorials/mesh/cv2DMesh/jaggedBoundary/system/cv2DMeshDict create mode 100644 tutorials/mesh/cv2DMesh/jaggedBoundary/system/extrude2DMeshDict create mode 100644 tutorials/mesh/cv2DMesh/jaggedBoundary/system/fvSchemes create mode 100644 tutorials/mesh/cv2DMesh/jaggedBoundary/system/fvSolution create mode 100644 tutorials/mesh/cv2DMesh/jaggedBoundary/system/surfaceFeatureExtractDict create mode 100755 tutorials/mesh/cv2DMesh/square/Allclean create mode 100755 tutorials/mesh/cv2DMesh/square/Allrun create mode 100644 tutorials/mesh/cv2DMesh/square/constant/triSurface/unit_cube.stl create mode 100644 tutorials/mesh/cv2DMesh/square/system/controlDict create mode 100644 tutorials/mesh/cv2DMesh/square/system/cv2DMeshDict create mode 100644 tutorials/mesh/cv2DMesh/square/system/extrude2DMeshDict create mode 100644 tutorials/mesh/cv2DMesh/square/system/fvSchemes create mode 100644 tutorials/mesh/cv2DMesh/square/system/fvSolution create mode 100644 tutorials/mesh/cv2DMesh/square/system/surfaceFeatureExtractDict create mode 100755 tutorials/mesh/cvMesh/blob/Allclean create mode 100755 tutorials/mesh/cvMesh/blob/Allrun create mode 100755 tutorials/mesh/cvMesh/blob/Allrun-parallel create mode 100755 tutorials/mesh/cvMesh/blob/Alltest create mode 100644 tutorials/mesh/cvMesh/blob/constant/polyMesh/blockMeshDict create mode 100644 tutorials/mesh/cvMesh/blob/constant/polyMesh/boundary create mode 100644 tutorials/mesh/cvMesh/blob/constant/triSurface/blob.stl create mode 100644 tutorials/mesh/cvMesh/blob/system/collapseDict create mode 100644 tutorials/mesh/cvMesh/blob/system/controlDict create mode 100644 tutorials/mesh/cvMesh/blob/system/cvMeshDict create mode 100644 tutorials/mesh/cvMesh/blob/system/decomposeParDict create mode 100644 tutorials/mesh/cvMesh/blob/system/fvSchemes create mode 100644 tutorials/mesh/cvMesh/blob/system/fvSolution create mode 100644 tutorials/mesh/cvMesh/blob/system/meshQualityDict create mode 100644 tutorials/mesh/cvMesh/blob/system/snappyHexMeshDict create mode 100644 tutorials/mesh/cvMesh/blob/system/topoSetDict create mode 100755 tutorials/mesh/cvMesh/flange/Allclean create mode 100755 tutorials/mesh/cvMesh/flange/Allrun create mode 100755 tutorials/mesh/cvMesh/flange/Allrun-parallel create mode 100755 tutorials/mesh/cvMesh/flange/Alltest create mode 100644 tutorials/mesh/cvMesh/flange/constant/polyMesh/blockMeshDict create mode 100644 tutorials/mesh/cvMesh/flange/constant/polyMesh/boundary create mode 100644 tutorials/mesh/cvMesh/flange/constant/triSurface/flange.obj create mode 100644 tutorials/mesh/cvMesh/flange/system/collapseDict create mode 100644 tutorials/mesh/cvMesh/flange/system/controlDict create mode 100644 tutorials/mesh/cvMesh/flange/system/cvMeshDict create mode 100644 tutorials/mesh/cvMesh/flange/system/decomposeParDict create mode 100644 tutorials/mesh/cvMesh/flange/system/faceSetDict create mode 100644 tutorials/mesh/cvMesh/flange/system/fvSchemes create mode 100644 tutorials/mesh/cvMesh/flange/system/fvSolution create mode 100644 tutorials/mesh/cvMesh/flange/system/meshQualityDict create mode 100644 tutorials/mesh/cvMesh/flange/system/snappyHexMeshDict create mode 100644 tutorials/mesh/cvMesh/flange/system/surfaceFeatureExtractDict create mode 100644 tutorials/mesh/cvMesh/flange/system/topoSetDict-background create mode 100644 tutorials/mesh/cvMesh/flange/system/topoSetDict-slices create mode 100755 tutorials/mesh/cvMesh/simpleShapes/Allclean create mode 100755 tutorials/mesh/cvMesh/simpleShapes/Allrun create mode 100644 tutorials/mesh/cvMesh/simpleShapes/constant/triSurface/cone.stl create mode 100644 tutorials/mesh/cvMesh/simpleShapes/constant/triSurface/coneAndSphere.obj create mode 100644 tutorials/mesh/cvMesh/simpleShapes/constant/triSurface/domain.stl create mode 100644 tutorials/mesh/cvMesh/simpleShapes/constant/triSurface/sphere.stl create mode 100644 tutorials/mesh/cvMesh/simpleShapes/system/collapseDict create mode 100644 tutorials/mesh/cvMesh/simpleShapes/system/controlDict create mode 100644 tutorials/mesh/cvMesh/simpleShapes/system/cvMeshDict create mode 100644 tutorials/mesh/cvMesh/simpleShapes/system/fvSchemes create mode 100644 tutorials/mesh/cvMesh/simpleShapes/system/fvSolution create mode 100644 tutorials/mesh/cvMesh/simpleShapes/system/meshQualityDict create mode 100644 tutorials/mesh/cvMesh/simpleShapes/system/surfaceFeatureExtractDict create mode 100644 tutorials/mesh/cvMesh/simpleShapes/system/topoSetDict diff --git a/applications/test/vectorTools/Make/files b/applications/test/vectorTools/Make/files new file mode 100644 index 0000000000..0b30b98f8f --- /dev/null +++ b/applications/test/vectorTools/Make/files @@ -0,0 +1,3 @@ +Test-vectorTools.C + +EXE = $(FOAM_USER_APPBIN)/Test-vectorTools diff --git a/applications/test/vectorTools/Make/options b/applications/test/vectorTools/Make/options new file mode 100644 index 0000000000..9e015e6078 --- /dev/null +++ b/applications/test/vectorTools/Make/options @@ -0,0 +1 @@ +EXE_INC = -I$(FOAM_APP)/utilities/mesh/generation/cvMesh/vectorTools diff --git a/applications/test/vectorTools/Test-vectorTools.C b/applications/test/vectorTools/Test-vectorTools.C new file mode 100644 index 0000000000..85d18ed989 --- /dev/null +++ b/applications/test/vectorTools/Test-vectorTools.C @@ -0,0 +1,71 @@ +#include "vector.H" +#include "IOstreams.H" +#include "vectorTools.H" +#include "unitConversion.H" + +using namespace Foam; + + +void test(const vector& a, const vector& b, const scalar tolerance) +{ + Info<< "Vectors " << a << " and " << b + << " are (to tolerance of " << tolerance << "): "; + + if (vectorTools::areParallel(a, b, tolerance)) + Info<< " parallel "; + + if (vectorTools::areOrthogonal(a, b, tolerance)) + Info<< " orthogonal "; + + if (vectorTools::areAcute(a, b)) + Info<< " acute "; + + if (vectorTools::areObtuse(a, b)) + Info<< " obtuse "; + + Info<< ", angle = " << vectorTools::degAngleBetween(a, b); + + Info<< endl; +} + + +int main() +{ + vector a(1.0, 1.0, 1.0); + vector b(2.0, 2.0, 2.0); + + test(a, b, 0.0); + test(a, b, VSMALL); + test(a, b, SMALL); + test(a, b, 1e-3); + test(a, b, 1e-1); + + a = vector(1,0,0); + b = vector(0,2,0); + + test(a, b, 0.0); + test(a, b, VSMALL); + test(a, b, SMALL); + test(a, b, 1e-3); + test(a, b, 1e-1); + + a = vector(1,0,0); + b = vector(-1,0,0); + + test(a, b, 0.0); + test(a, b, VSMALL); + test(a, b, SMALL); + test(a, b, 1e-3); + test(a, b, 1e-1); + + a = vector(1,0,0); + b = vector(-1,2,0); + + test(a, b, 0.0); + test(a, b, VSMALL); + test(a, b, SMALL); + test(a, b, 1e-3); + test(a, b, 1e-1); + + return 0; +} diff --git a/applications/utilities/mesh/advanced/collapseEdges/collapseDict b/applications/utilities/mesh/advanced/collapseEdges/collapseDict index 170a0a890d..75f04740ef 100644 --- a/applications/utilities/mesh/advanced/collapseEdges/collapseDict +++ b/applications/utilities/mesh/advanced/collapseEdges/collapseDict @@ -2,16 +2,24 @@ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | | \\ / O peration | Version: dev | -| \\ / A nd | Web: www.OpenFOAM.org | +| \\ / A nd | Web: http://www.openfoam.org | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ + FoamFile { - version 2.0; - format ascii; - class dictionary; - object collapseDict; + version 2.0; + format ascii; + + root ""; + case ""; + instance ""; + local ""; + + class dictionary; + object collapseDict; } + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // If on, after collapsing check the quality of the mesh. If bad faces are diff --git a/applications/utilities/mesh/generation/Allwmake b/applications/utilities/mesh/generation/Allwmake index d557fa34f8..48ca530c96 100755 --- a/applications/utilities/mesh/generation/Allwmake +++ b/applications/utilities/mesh/generation/Allwmake @@ -9,5 +9,10 @@ extrude2DMesh/Allwmake wmake snappyHexMesh +if [ -d "$CGAL_ARCH_PATH" ] +then + cvMesh/Allwmake + cv2DMesh/Allwmake +fi # ----------------------------------------------------------------- end-of-file diff --git a/applications/utilities/mesh/generation/cv2DMesh/Allwclean b/applications/utilities/mesh/generation/cv2DMesh/Allwclean new file mode 100755 index 0000000000..d0ae53e415 --- /dev/null +++ b/applications/utilities/mesh/generation/cv2DMesh/Allwclean @@ -0,0 +1,8 @@ +#!/bin/sh +cd ${0%/*} || exit 1 # run from this directory +set -x + +wclean libso conformalVoronoi2DMesh +wclean + +# ----------------------------------------------------------------- end-of-file diff --git a/applications/utilities/mesh/generation/cv2DMesh/Allwmake b/applications/utilities/mesh/generation/cv2DMesh/Allwmake new file mode 100755 index 0000000000..5486849957 --- /dev/null +++ b/applications/utilities/mesh/generation/cv2DMesh/Allwmake @@ -0,0 +1,8 @@ +#!/bin/sh +cd ${0%/*} || exit 1 # run from this directory +set -x + +wmake libso conformalVoronoi2DMesh +wmake + +# ----------------------------------------------------------------- end-of-file diff --git a/applications/utilities/mesh/generation/cv2DMesh/CGALTriangulation2DKernel.H b/applications/utilities/mesh/generation/cv2DMesh/CGALTriangulation2DKernel.H new file mode 100644 index 0000000000..28002f962f --- /dev/null +++ b/applications/utilities/mesh/generation/cv2DMesh/CGALTriangulation2DKernel.H @@ -0,0 +1,60 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2013 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 . + +Typedefs + CGALTriangulation2DKernel + +Description + +\*---------------------------------------------------------------------------*/ + +#ifndef CGALTriangulation2DKernel_H +#define CGALTriangulation2DKernel_H + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#include "CGAL/Delaunay_triangulation_2.h" + +#ifdef CGAL_INEXACT + + // Fast kernel using a double as the storage type but the triangulation + // may fail + #include "CGAL/Exact_predicates_inexact_constructions_kernel.h" + + typedef CGAL::Exact_predicates_inexact_constructions_kernel K; + +#else + + // Very robust but expensive kernel + #include "CGAL/Exact_predicates_exact_constructions_kernel.h" + + typedef CGAL::Exact_predicates_exact_constructions_kernel K; + +#endif + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/applications/utilities/mesh/generation/cv2DMesh/CGALTriangulation2Ddefs.H b/applications/utilities/mesh/generation/cv2DMesh/CGALTriangulation2Ddefs.H new file mode 100644 index 0000000000..8731926548 --- /dev/null +++ b/applications/utilities/mesh/generation/cv2DMesh/CGALTriangulation2Ddefs.H @@ -0,0 +1,76 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2013 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 . + +Typedefs + CGALTriangulation2Ddefs + +Description + CGAL data structures used for 2D Delaunay meshing. + + Define CGAL_INEXACT to use Exact_predicates_inexact_constructions kernel + otherwise the more robust but much less efficient + Exact_predicates_exact_constructions will be used. + + Define CGAL_HIERARCHY to use hierarchical Delaunay triangulation which is + faster but uses more memory than the standard Delaunay triangulation. + +\*---------------------------------------------------------------------------*/ + +#ifndef CGALTriangulation2Ddefs_H +#define CGALTriangulation2Ddefs_H + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#include "CGALTriangulation2DKernel.H" + +#include "indexedVertex.H" +#include "indexedFace.H" + +typedef CGAL::indexedVertex Vb; +typedef CGAL::indexedFace Fb; + +#ifdef CGAL_HIERARCHY + + // Data structures for hierarchical Delaunay triangulation which is more + // efficient but also uses more storage + #include "CGAL/Triangulation_hierarchy_2.h" + + typedef CGAL::Triangulation_hierarchy_vertex_base_2 Vbh; + typedef CGAL::Triangulation_data_structure_2 Tds; + typedef CGAL::Delaunay_triangulation_2 DT; + typedef CGAL::Triangulation_hierarchy_2
Delaunay; + +#else + + // Data structures for standard Delaunay triangulation + typedef CGAL::Triangulation_data_structure_2 Tds; + typedef CGAL::Delaunay_triangulation_2 Delaunay; + +#endif + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/applications/utilities/mesh/generation/cv2DMesh/CV2D.C b/applications/utilities/mesh/generation/cv2DMesh/CV2D.C new file mode 100644 index 0000000000..8a5931df61 --- /dev/null +++ b/applications/utilities/mesh/generation/cv2DMesh/CV2D.C @@ -0,0 +1,997 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2013 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 . + +\*----------------------------------------------------------------------------*/ + +#include "CV2D.H" +#include "Random.H" +#include "transform.H" +#include "IFstream.H" +#include "uint.H" +#include "ulong.H" + +namespace Foam +{ + defineTypeNameAndDebug(CV2D, 0); +} + +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // + +void Foam::CV2D::insertBoundingBox() +{ + Info<< "insertBoundingBox: creating bounding mesh" << endl; + scalar bigSpan = 10*meshControls().span(); + insertPoint(point2D(-bigSpan, -bigSpan), Vb::FAR_POINT); + insertPoint(point2D(-bigSpan, bigSpan), Vb::FAR_POINT); + insertPoint(point2D(bigSpan, -bigSpan), Vb::FAR_POINT); + insertPoint(point2D(bigSpan, bigSpan), Vb::FAR_POINT); +} + + +void Foam::CV2D::fast_restore_Delaunay(Vertex_handle vh) +{ + int i; + Face_handle f = vh->face(), next, start(f); + + do + { + i=f->index(vh); + if (!is_infinite(f)) + { + if (!internal_flip(f, cw(i))) external_flip(f, i); + if (f->neighbor(i) == start) start = f; + } + f = f->neighbor(cw(i)); + } while (f != start); +} + + +void Foam::CV2D::external_flip(Face_handle& f, int i) +{ + Face_handle n = f->neighbor(i); + + if + ( + CGAL::ON_POSITIVE_SIDE + != side_of_oriented_circle(n, f->vertex(i)->point()) + ) return; + + flip(f, i); + i = n->index(f->vertex(i)); + external_flip(n, i); +} + + +bool Foam::CV2D::internal_flip(Face_handle& f, int i) +{ + Face_handle n = f->neighbor(i); + + if + ( + CGAL::ON_POSITIVE_SIDE + != side_of_oriented_circle(n, f->vertex(i)->point()) + ) + { + return false; + } + + flip(f, i); + + return true; +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::CV2D::CV2D +( + const Time& runTime, + const dictionary& cvMeshDict +) +: + Delaunay(), + runTime_(runTime), + rndGen_(64293*Pstream::myProcNo()), + allGeometry_ + ( + IOobject + ( + "cvSearchableSurfaces", + runTime_.constant(), + "triSurface", + runTime_, + IOobject::MUST_READ, + IOobject::NO_WRITE + ), + cvMeshDict.subDict("geometry") + ), + qSurf_ + ( + runTime_, + rndGen_, + allGeometry_, + cvMeshDict.subDict("surfaceConformation") + ), + controls_(cvMeshDict, qSurf_.globalBounds()), + cellSizeControl_ + ( + runTime, + cvMeshDict.subDict("motionControl").subDict("shapeControlFunctions"), + qSurf_, + controls_.minCellSize() + ), + relaxationModel_ + ( + relaxationModel::New + ( + cvMeshDict.subDict("motionControl"), + runTime + ) + ), + z_ + ( + point + ( + cvMeshDict.subDict("surfaceConformation").lookup("locationInMesh") + ).z() + ), + startOfInternalPoints_(0), + startOfSurfacePointPairs_(0), + startOfBoundaryConformPointPairs_(0), + featurePoints_() +{ + Info<< meshControls() << endl; + + insertBoundingBox(); + insertFeaturePoints(); +} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +Foam::CV2D::~CV2D() +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void Foam::CV2D::insertPoints +( + const point2DField& points, + const scalar nearness +) +{ + Info<< "insertInitialPoints(const point2DField& points): "; + + startOfInternalPoints_ = number_of_vertices(); + label nVert = startOfInternalPoints_; + + // Add the points and index them + forAll(points, i) + { + const point2D& p = points[i]; + + if (qSurf_.wellInside(toPoint3D(p), nearness)) + { + insert(toPoint(p))->index() = nVert++; + } + else + { + Warning + << "Rejecting point " << p << " outside surface" << endl; + } + } + + Info<< nVert << " vertices inserted" << endl; + + if (meshControls().objOutput()) + { + // Checking validity of triangulation + assert(is_valid()); + + writeTriangles("initial_triangles.obj", true); + writeFaces("initial_faces.obj", true); + } +} + + +void Foam::CV2D::insertPoints(const fileName& pointFileName) +{ + IFstream pointsFile(pointFileName); + + if (pointsFile.good()) + { + insertPoints + ( + point2DField(pointsFile), + 0.5*meshControls().minCellSize2() + ); + } + else + { + FatalErrorIn("insertInitialPoints") + << "Could not open pointsFile " << pointFileName + << exit(FatalError); + } +} + + +void Foam::CV2D::insertGrid() +{ + Info<< "insertInitialGrid: "; + + startOfInternalPoints_ = number_of_vertices(); + label nVert = startOfInternalPoints_; + + scalar x0 = qSurf_.globalBounds().min().x(); + scalar xR = qSurf_.globalBounds().max().x() - x0; + int ni = int(xR/meshControls().minCellSize()) + 1; + scalar deltax = xR/ni; + + scalar y0 = qSurf_.globalBounds().min().y(); + scalar yR = qSurf_.globalBounds().max().y() - y0; + int nj = int(yR/meshControls().minCellSize()) + 1; + scalar deltay = yR/nj; + + Random rndGen(1321); + scalar pert = meshControls().randomPerturbation()*min(deltax, deltay); + + for (int i=0; iindex() = nVert++; + } + } + } + + Info<< nVert << " vertices inserted" << endl; + + if (meshControls().objOutput()) + { + // Checking validity of triangulation + assert(is_valid()); + + writeTriangles("initial_triangles.obj", true); + writeFaces("initial_faces.obj", true); + } +} + + +void Foam::CV2D::insertSurfacePointPairs() +{ + startOfSurfacePointPairs_ = number_of_vertices(); + + if (meshControls().insertSurfaceNearestPointPairs()) + { + insertSurfaceNearestPointPairs(); + } + + write("nearest"); + + // Insertion of point-pairs for near-points may cause protrusions + // so insertBoundaryConformPointPairs must be executed last + if (meshControls().insertSurfaceNearPointPairs()) + { + insertSurfaceNearPointPairs(); + } + + startOfBoundaryConformPointPairs_ = number_of_vertices(); +} + + +void Foam::CV2D::boundaryConform() +{ + if (!meshControls().insertSurfaceNearestPointPairs()) + { + markNearBoundaryPoints(); + } + + // Mark all the faces as SAVE_CHANGED + for + ( + Triangulation::Finite_faces_iterator fit = finite_faces_begin(); + fit != finite_faces_end(); + fit++ + ) + { + fit->faceIndex() = Fb::SAVE_CHANGED; + } + + for (label iter=1; iter<=meshControls().maxBoundaryConformingIter(); iter++) + { + label nIntersections = insertBoundaryConformPointPairs + ( + "surfaceIntersections_" + Foam::name(iter) + ".obj" + ); + + if (nIntersections == 0) + { + break; + } + else + { + Info<< "BC iteration " << iter << ": " + << nIntersections << " point-pairs inserted" << endl; + } + + // Any faces changed by insertBoundaryConformPointPairs will now + // be marked CHANGED, mark those as SAVE_CHANGED and those that + // remained SAVE_CHANGED as UNCHANGED + for + ( + Triangulation::Finite_faces_iterator fit = finite_faces_begin(); + fit != finite_faces_end(); + fit++ + ) + { + if (fit->faceIndex() == Fb::SAVE_CHANGED) + { + fit->faceIndex() = Fb::UNCHANGED; + } + else if (fit->faceIndex() == Fb::CHANGED) + { + fit->faceIndex() = Fb::SAVE_CHANGED; + } + } + } + + Info<< nl; + + write("boundary"); +} + + +void Foam::CV2D::removeSurfacePointPairs() +{ + for + ( + Triangulation::Finite_vertices_iterator vit = finite_vertices_begin(); + vit != finite_vertices_end(); + ++vit + ) + { + if (vit->index() >= startOfSurfacePointPairs_) + { + remove(vit); + } + } +} + + +void Foam::CV2D::newPoints() +{ + const scalar relaxation = relaxationModel_->relaxation(); + + Info<< "Relaxation = " << relaxation << endl; + + Field dualVertices(number_of_faces()); + + label dualVerti = 0; + + // Find the dual point of each tetrahedron and assign it an index. + for + ( + Triangulation::Finite_faces_iterator fit = finite_faces_begin(); + fit != finite_faces_end(); + ++fit + ) + { + fit->faceIndex() = -1; + + if + ( + fit->vertex(0)->internalOrBoundaryPoint() + || fit->vertex(1)->internalOrBoundaryPoint() + || fit->vertex(2)->internalOrBoundaryPoint() + ) + { + fit->faceIndex() = dualVerti; + + dualVertices[dualVerti] = toPoint2D(circumcenter(fit)); + + dualVerti++; + } + } + + dualVertices.setSize(dualVerti); + + Field displacementAccumulator + ( + startOfSurfacePointPairs_, + vector2D::zero + ); + + // Calculate target size and alignment for vertices + scalarField sizes + ( + number_of_vertices(), + meshControls().minCellSize() + ); + + Field alignments + ( + number_of_vertices(), + vector2D(1, 0) + ); + + for + ( + Triangulation::Finite_vertices_iterator vit = finite_vertices_begin(); + vit != finite_vertices_end(); + ++vit + ) + { + if (vit->internalOrBoundaryPoint()) + { + point2D vert = toPoint2D(vit->point()); + + // alignment and size determination + pointIndexHit pHit; + label hitSurface = -1; + + qSurf_.findSurfaceNearest + ( + toPoint3D(vert), + meshControls().span2(), + pHit, + hitSurface + ); + + if (pHit.hit()) + { + vectorField norm(1); + allGeometry_[hitSurface].getNormal + ( + List(1, pHit), + norm + ); + + alignments[vit->index()] = toPoint2D(norm[0]); + + sizes[vit->index()] = + cellSizeControl_.cellSize(toPoint3D(vit->point())); + } + } + } + + // Info<< "Calculated alignments" << endl; + + scalar cosAlignmentAcceptanceAngle = 0.68; + + // Upper and lower edge length ratios for weight + scalar u = 1.0; + scalar l = 0.7; + + PackedBoolList pointToBeRetained(startOfSurfacePointPairs_, true); + + std::list pointsToInsert; + + for + ( + Triangulation::Finite_edges_iterator eit = finite_edges_begin(); + eit != finite_edges_end(); + eit++ + ) + { + Vertex_handle vA = eit->first->vertex(cw(eit->second)); + Vertex_handle vB = eit->first->vertex(ccw(eit->second)); + + if (!vA->internalOrBoundaryPoint() || !vB->internalOrBoundaryPoint()) + { + continue; + } + + const point2D& dualV1 = dualVertices[eit->first->faceIndex()]; + const point2D& dualV2 = + dualVertices[eit->first->neighbor(eit->second)->faceIndex()]; + + scalar dualEdgeLength = mag(dualV1 - dualV2); + + point2D dVA = toPoint2D(vA->point()); + point2D dVB = toPoint2D(vB->point()); + + Field alignmentDirsA(2); + + alignmentDirsA[0] = alignments[vA->index()]; + alignmentDirsA[1] = vector2D + ( + -alignmentDirsA[0].y(), + alignmentDirsA[0].x() + ); + + Field alignmentDirsB(2); + + alignmentDirsB[0] = alignments[vB->index()]; + alignmentDirsB[1] = vector2D + ( + -alignmentDirsB[0].y(), + alignmentDirsB[0].x() + ); + + Field alignmentDirs(2); + + forAll(alignmentDirsA, aA) + { + const vector2D& a(alignmentDirsA[aA]); + + scalar maxDotProduct = 0.0; + + forAll(alignmentDirsB, aB) + { + const vector2D& b(alignmentDirsB[aB]); + + scalar dotProduct = a & b; + + if (mag(dotProduct) > maxDotProduct) + { + maxDotProduct = mag(dotProduct); + + alignmentDirs[aA] = a + sign(dotProduct)*b; + + alignmentDirs[aA] /= mag(alignmentDirs[aA]); + } + } + } + + vector2D rAB = dVA - dVB; + + scalar rABMag = mag(rAB); + + forAll(alignmentDirs, aD) + { + vector2D& alignmentDir = alignmentDirs[aD]; + + if ((rAB & alignmentDir) < 0) + { + // swap the direction of the alignment so that has the + // same sense as rAB + alignmentDir *= -1; + } + + scalar alignmentDotProd = ((rAB/rABMag) & alignmentDir); + + if (alignmentDotProd > cosAlignmentAcceptanceAngle) + { + scalar targetFaceSize = + 0.5*(sizes[vA->index()] + sizes[vB->index()]); + + // Test for changing aspect ratio on second alignment (first + // alignment is neartest surface normal) + // if (aD == 1) + // { + // targetFaceSize *= 2.0; + // } + + alignmentDir *= 0.5*targetFaceSize; + + vector2D delta = alignmentDir - 0.5*rAB; + + if (dualEdgeLength < 0.7*targetFaceSize) + { + delta *= 0; + } + else if (dualEdgeLength < targetFaceSize) + { + delta *= + ( + dualEdgeLength + /(targetFaceSize*(u - l)) + - 1/((u/l) - 1) + ); + } + + if + ( + vA->internalPoint() + && vB->internalPoint() + && rABMag > 1.75*targetFaceSize + && dualEdgeLength > 0.05*targetFaceSize + && alignmentDotProd > 0.93 + ) + { + // Point insertion + pointsToInsert.push_back(toPoint(0.5*(dVA + dVB))); + } + else if + ( + (vA->internalPoint() || vB->internalPoint()) + && rABMag < 0.65*targetFaceSize + ) + { + // Point removal + + // Only insert a point at the midpoint of the short edge + // if neither attached point has already been identified + // to be removed. + if + ( + pointToBeRetained[vA->index()] == true + && pointToBeRetained[vB->index()] == true + ) + { + pointsToInsert.push_back(toPoint(0.5*(dVA + dVB))); + } + + if (vA->internalPoint()) + { + pointToBeRetained[vA->index()] = false; + } + + if (vB->internalPoint()) + { + pointToBeRetained[vB->index()] = false; + } + } + else + { + if (vA->internalPoint()) + { + displacementAccumulator[vA->index()] += delta; + } + + if (vB->internalPoint()) + { + displacementAccumulator[vB->index()] += -delta; + } + } + } + } + } + + vector2D totalDisp = sum(displacementAccumulator); + scalar totalDist = sum(mag(displacementAccumulator)); + + // Relax the calculated displacement + displacementAccumulator *= relaxation; + + label numberOfNewPoints = pointsToInsert.size(); + + for + ( + Triangulation::Finite_vertices_iterator vit = finite_vertices_begin(); + vit != finite_vertices_end(); + ++vit + ) + { + if (vit->internalPoint()) + { + if (pointToBeRetained[vit->index()]) + { + pointsToInsert.push_front + ( + toPoint + ( + toPoint2D(vit->point()) + + displacementAccumulator[vit->index()] + ) + ); + } + } + } + + // Clear the triangulation and reinsert the bounding box and feature points. + // This is faster than removing and moving points. + this->clear(); + + insertBoundingBox(); + + reinsertFeaturePoints(); + + startOfInternalPoints_ = number_of_vertices(); + + label nVert = startOfInternalPoints_; + + Info<< "Inserting " << numberOfNewPoints << " new points" << endl; + + // Use the range insert as it is faster than individually inserting points. + insert(pointsToInsert.begin(), pointsToInsert.end()); + + for + ( + Delaunay::Finite_vertices_iterator vit = finite_vertices_begin(); + vit != finite_vertices_end(); + ++vit + ) + { + if + ( + vit->type() == Vb::INTERNAL_POINT + && vit->index() == Vb::INTERNAL_POINT + ) + { + vit->index() = nVert++; + } + } + + Info<< " Total displacement = " << totalDisp << nl + << " Total distance = " << totalDist << nl + << " Points added = " << pointsToInsert.size() + << endl; + + write("internal"); + + insertSurfacePointPairs(); + + boundaryConform(); + + +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// Old Method +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +// for +// ( +// Triangulation::Finite_vertices_iterator vit = finite_vertices_begin(); +// vit != finite_vertices_end(); +// ++vit +// ) +// { +// if (vit->internalPoint()) +// { +// // Current dual-cell defining vertex ("centre") +// point2DFromPoint defVert0 = toPoint2D(vit->point()); + +// Triangulation::Edge_circulator ec = incident_edges(vit); +// Triangulation::Edge_circulator ecStart = ec; + +// // Circulate around the edges to find the first which is not +// // infinite +// do +// { +// if (!is_infinite(ec)) break; +// } while (++ec != ecStart); + +// // Store the start-end of the first non-infinte edge +// point2D de0 = toPoint2D(circumcenter(ec->first)); + +// // Keep track of the maximum edge length^2 +// scalar maxEdgeLen2 = 0.0; + +// // Keep track of the index of the longest edge +// label edgecd0i = -1; + +// // Edge counter +// label edgei = 0; + +// do +// { +// if (!is_infinite(ec)) +// { +// // Get the end of the current edge +// point2D de1 = toPoint2D +// ( +// circumcenter(ec->first->neighbor(ec->second)) +// ); + +// // Store the current edge vector +// edges[edgei] = de1 - de0; + +// // Store the edge mid-point in the vertices array +// vertices[edgei] = 0.5*(de1 + de0); + +// // Move the current edge end into the edge start for the +// // next iteration +// de0 = de1; + +// // Keep track of the longest edge + +// scalar edgeLen2 = magSqr(edges[edgei]); + +// if (edgeLen2 > maxEdgeLen2) +// { +// maxEdgeLen2 = edgeLen2; +// edgecd0i = edgei; +// } + +// edgei++; +// } +// } while (++ec != ecStart); + +// // Initialise cd0 such that the mesh will align +// // in in the x-y directions +// vector2D cd0(1, 0); + +// if (meshControls().relaxOrientation()) +// { +// // Get the longest edge from the array and use as the primary +// // direction of the coordinate system of the "square" cell +// cd0 = edges[edgecd0i]; +// } + +// if (meshControls().nearWallAlignedDist() > 0) +// { +// pointIndexHit pHit = qSurf_.tree().findNearest +// ( +// toPoint3D(defVert0), +// meshControls().nearWallAlignedDist2() +// ); + +// if (pHit.hit()) +// { +// cd0 = toPoint2D(faceNormals[pHit.index()]); +// } +// } + +// // Rotate by 45deg needed to create an averaging procedure which +// // encourages the cells to be square +// cd0 = vector2D(cd0.x() + cd0.y(), cd0.y() - cd0.x()); + +// // Normalise the primary coordinate direction +// cd0 /= mag(cd0); + +// // Calculate the orthogonal coordinate direction +// vector2D cd1(-cd0.y(), cd0.x()); + + +// // Restart the circulator +// ec = ecStart; + +// // ... and the counter +// edgei = 0; + +// // Initialise the displacement for the centre and sum-weights +// vector2D disp = vector2D::zero; +// scalar sumw = 0; + +// do +// { +// if (!is_infinite(ec)) +// { +// // Pick up the current edge +// const vector2D& ei = edges[edgei]; + +// // Calculate the centre to edge-centre vector +// vector2D deltai = vertices[edgei] - defVert0; + +// // Set the weight for this edge contribution +// scalar w = 1; + +// if (meshControls().squares()) +// { +// w = magSqr(deltai.x()*ei.y() - deltai.y()*ei.x()); +// // alternative weights +// //w = mag(deltai.x()*ei.y() - deltai.y()*ei.x()); +// //w = magSqr(ei)*mag(deltai); + +// // Use the following for an ~square mesh +// // Find the coordinate contributions for this edge delta +// scalar cd0deltai = cd0 & deltai; +// scalar cd1deltai = cd1 & deltai; + +// // Create a "square" displacement +// if (mag(cd0deltai) > mag(cd1deltai)) +// { +// disp += (w*cd0deltai)*cd0; +// } +// else +// { +// disp += (w*cd1deltai)*cd1; +// } +// } +// else +// { +// // Use this for a hexagon/pentagon mesh +// disp += w*deltai; +// } + +// // Sum the weights +// sumw += w; +// } +// else +// { +// FatalErrorIn("CV2D::newPoints() const") +// << "Infinite triangle found in internal mesh" +// << exit(FatalError); +// } + +// edgei++; + +// } while (++ec != ecStart); + +// // Calculate the average displacement +// disp /= sumw; +// totalDisp += disp; +// totalDist += mag(disp); + +// // Move the point by a fraction of the average displacement +// movePoint(vit, defVert0 + relaxation*disp); +// } +// } + +// Info << "\nTotal displacement = " << totalDisp +// << " total distance = " << totalDist << endl; +} + + +//void Foam::CV2D::moveInternalPoints(const point2DField& newPoints) +//{ +// label pointI = 0; + +// for +// ( +// Triangulation::Finite_vertices_iterator vit = finite_vertices_begin(); +// vit != finite_vertices_end(); +// ++vit +// ) +// { +// if (vit->internalPoint()) +// { +// movePoint(vit, newPoints[pointI++]); +// } +// } +//} + + +void Foam::CV2D::write() const +{ + if (meshControls().objOutput()) + { + writeFaces("allFaces.obj", false); + writeFaces("faces.obj", true); + writeTriangles("allTriangles.obj", false); + writeTriangles("triangles.obj", true); + writePatch("patch.pch"); + } +} + + +void Foam::CV2D::write(const word& stage) const +{ + if (meshControls().objOutput()) + { + Foam::mkDir(stage + "Faces"); + Foam::mkDir(stage + "Triangles"); + + writeFaces + ( + stage + + "Faces/allFaces_" + + runTime_.timeName() + + ".obj", + false + ); + + writeTriangles + ( + stage + + "Triangles/allTriangles_" + + runTime_.timeName() + + ".obj", + false + ); + } +} + + +// ************************************************************************* // diff --git a/applications/utilities/mesh/generation/cv2DMesh/CV2D.H b/applications/utilities/mesh/generation/cv2DMesh/CV2D.H new file mode 100644 index 0000000000..4948196fc2 --- /dev/null +++ b/applications/utilities/mesh/generation/cv2DMesh/CV2D.H @@ -0,0 +1,474 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2013 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 "relaxationModel.H" +#include "cellSizeAndAlignmentControls.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 + cellSizeAndAlignmentControls cellSizeControl_; + + //- Relaxation coefficient model. Runtime selectable. + autoPtr relaxationModel_; + + //- 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
Delaunay; + +#else + + // Data structures for standard Delaunay triangulation + typedef CGAL::Triangulation_data_structure_2 Tds; + typedef CGAL::Delaunay_triangulation_2 Delaunay; + +#endif + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/applications/utilities/mesh/generation/cv2DMesh/CV2D.C b/applications/utilities/mesh/generation/cv2DMesh/CV2D.C new file mode 100644 index 0000000000..8a5931df61 --- /dev/null +++ b/applications/utilities/mesh/generation/cv2DMesh/CV2D.C @@ -0,0 +1,997 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2013 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 . + +\*----------------------------------------------------------------------------*/ + +#include "CV2D.H" +#include "Random.H" +#include "transform.H" +#include "IFstream.H" +#include "uint.H" +#include "ulong.H" + +namespace Foam +{ + defineTypeNameAndDebug(CV2D, 0); +} + +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // + +void Foam::CV2D::insertBoundingBox() +{ + Info<< "insertBoundingBox: creating bounding mesh" << endl; + scalar bigSpan = 10*meshControls().span(); + insertPoint(point2D(-bigSpan, -bigSpan), Vb::FAR_POINT); + insertPoint(point2D(-bigSpan, bigSpan), Vb::FAR_POINT); + insertPoint(point2D(bigSpan, -bigSpan), Vb::FAR_POINT); + insertPoint(point2D(bigSpan, bigSpan), Vb::FAR_POINT); +} + + +void Foam::CV2D::fast_restore_Delaunay(Vertex_handle vh) +{ + int i; + Face_handle f = vh->face(), next, start(f); + + do + { + i=f->index(vh); + if (!is_infinite(f)) + { + if (!internal_flip(f, cw(i))) external_flip(f, i); + if (f->neighbor(i) == start) start = f; + } + f = f->neighbor(cw(i)); + } while (f != start); +} + + +void Foam::CV2D::external_flip(Face_handle& f, int i) +{ + Face_handle n = f->neighbor(i); + + if + ( + CGAL::ON_POSITIVE_SIDE + != side_of_oriented_circle(n, f->vertex(i)->point()) + ) return; + + flip(f, i); + i = n->index(f->vertex(i)); + external_flip(n, i); +} + + +bool Foam::CV2D::internal_flip(Face_handle& f, int i) +{ + Face_handle n = f->neighbor(i); + + if + ( + CGAL::ON_POSITIVE_SIDE + != side_of_oriented_circle(n, f->vertex(i)->point()) + ) + { + return false; + } + + flip(f, i); + + return true; +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::CV2D::CV2D +( + const Time& runTime, + const dictionary& cvMeshDict +) +: + Delaunay(), + runTime_(runTime), + rndGen_(64293*Pstream::myProcNo()), + allGeometry_ + ( + IOobject + ( + "cvSearchableSurfaces", + runTime_.constant(), + "triSurface", + runTime_, + IOobject::MUST_READ, + IOobject::NO_WRITE + ), + cvMeshDict.subDict("geometry") + ), + qSurf_ + ( + runTime_, + rndGen_, + allGeometry_, + cvMeshDict.subDict("surfaceConformation") + ), + controls_(cvMeshDict, qSurf_.globalBounds()), + cellSizeControl_ + ( + runTime, + cvMeshDict.subDict("motionControl").subDict("shapeControlFunctions"), + qSurf_, + controls_.minCellSize() + ), + relaxationModel_ + ( + relaxationModel::New + ( + cvMeshDict.subDict("motionControl"), + runTime + ) + ), + z_ + ( + point + ( + cvMeshDict.subDict("surfaceConformation").lookup("locationInMesh") + ).z() + ), + startOfInternalPoints_(0), + startOfSurfacePointPairs_(0), + startOfBoundaryConformPointPairs_(0), + featurePoints_() +{ + Info<< meshControls() << endl; + + insertBoundingBox(); + insertFeaturePoints(); +} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +Foam::CV2D::~CV2D() +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void Foam::CV2D::insertPoints +( + const point2DField& points, + const scalar nearness +) +{ + Info<< "insertInitialPoints(const point2DField& points): "; + + startOfInternalPoints_ = number_of_vertices(); + label nVert = startOfInternalPoints_; + + // Add the points and index them + forAll(points, i) + { + const point2D& p = points[i]; + + if (qSurf_.wellInside(toPoint3D(p), nearness)) + { + insert(toPoint(p))->index() = nVert++; + } + else + { + Warning + << "Rejecting point " << p << " outside surface" << endl; + } + } + + Info<< nVert << " vertices inserted" << endl; + + if (meshControls().objOutput()) + { + // Checking validity of triangulation + assert(is_valid()); + + writeTriangles("initial_triangles.obj", true); + writeFaces("initial_faces.obj", true); + } +} + + +void Foam::CV2D::insertPoints(const fileName& pointFileName) +{ + IFstream pointsFile(pointFileName); + + if (pointsFile.good()) + { + insertPoints + ( + point2DField(pointsFile), + 0.5*meshControls().minCellSize2() + ); + } + else + { + FatalErrorIn("insertInitialPoints") + << "Could not open pointsFile " << pointFileName + << exit(FatalError); + } +} + + +void Foam::CV2D::insertGrid() +{ + Info<< "insertInitialGrid: "; + + startOfInternalPoints_ = number_of_vertices(); + label nVert = startOfInternalPoints_; + + scalar x0 = qSurf_.globalBounds().min().x(); + scalar xR = qSurf_.globalBounds().max().x() - x0; + int ni = int(xR/meshControls().minCellSize()) + 1; + scalar deltax = xR/ni; + + scalar y0 = qSurf_.globalBounds().min().y(); + scalar yR = qSurf_.globalBounds().max().y() - y0; + int nj = int(yR/meshControls().minCellSize()) + 1; + scalar deltay = yR/nj; + + Random rndGen(1321); + scalar pert = meshControls().randomPerturbation()*min(deltax, deltay); + + for (int i=0; iindex() = nVert++; + } + } + } + + Info<< nVert << " vertices inserted" << endl; + + if (meshControls().objOutput()) + { + // Checking validity of triangulation + assert(is_valid()); + + writeTriangles("initial_triangles.obj", true); + writeFaces("initial_faces.obj", true); + } +} + + +void Foam::CV2D::insertSurfacePointPairs() +{ + startOfSurfacePointPairs_ = number_of_vertices(); + + if (meshControls().insertSurfaceNearestPointPairs()) + { + insertSurfaceNearestPointPairs(); + } + + write("nearest"); + + // Insertion of point-pairs for near-points may cause protrusions + // so insertBoundaryConformPointPairs must be executed last + if (meshControls().insertSurfaceNearPointPairs()) + { + insertSurfaceNearPointPairs(); + } + + startOfBoundaryConformPointPairs_ = number_of_vertices(); +} + + +void Foam::CV2D::boundaryConform() +{ + if (!meshControls().insertSurfaceNearestPointPairs()) + { + markNearBoundaryPoints(); + } + + // Mark all the faces as SAVE_CHANGED + for + ( + Triangulation::Finite_faces_iterator fit = finite_faces_begin(); + fit != finite_faces_end(); + fit++ + ) + { + fit->faceIndex() = Fb::SAVE_CHANGED; + } + + for (label iter=1; iter<=meshControls().maxBoundaryConformingIter(); iter++) + { + label nIntersections = insertBoundaryConformPointPairs + ( + "surfaceIntersections_" + Foam::name(iter) + ".obj" + ); + + if (nIntersections == 0) + { + break; + } + else + { + Info<< "BC iteration " << iter << ": " + << nIntersections << " point-pairs inserted" << endl; + } + + // Any faces changed by insertBoundaryConformPointPairs will now + // be marked CHANGED, mark those as SAVE_CHANGED and those that + // remained SAVE_CHANGED as UNCHANGED + for + ( + Triangulation::Finite_faces_iterator fit = finite_faces_begin(); + fit != finite_faces_end(); + fit++ + ) + { + if (fit->faceIndex() == Fb::SAVE_CHANGED) + { + fit->faceIndex() = Fb::UNCHANGED; + } + else if (fit->faceIndex() == Fb::CHANGED) + { + fit->faceIndex() = Fb::SAVE_CHANGED; + } + } + } + + Info<< nl; + + write("boundary"); +} + + +void Foam::CV2D::removeSurfacePointPairs() +{ + for + ( + Triangulation::Finite_vertices_iterator vit = finite_vertices_begin(); + vit != finite_vertices_end(); + ++vit + ) + { + if (vit->index() >= startOfSurfacePointPairs_) + { + remove(vit); + } + } +} + + +void Foam::CV2D::newPoints() +{ + const scalar relaxation = relaxationModel_->relaxation(); + + Info<< "Relaxation = " << relaxation << endl; + + Field dualVertices(number_of_faces()); + + label dualVerti = 0; + + // Find the dual point of each tetrahedron and assign it an index. + for + ( + Triangulation::Finite_faces_iterator fit = finite_faces_begin(); + fit != finite_faces_end(); + ++fit + ) + { + fit->faceIndex() = -1; + + if + ( + fit->vertex(0)->internalOrBoundaryPoint() + || fit->vertex(1)->internalOrBoundaryPoint() + || fit->vertex(2)->internalOrBoundaryPoint() + ) + { + fit->faceIndex() = dualVerti; + + dualVertices[dualVerti] = toPoint2D(circumcenter(fit)); + + dualVerti++; + } + } + + dualVertices.setSize(dualVerti); + + Field displacementAccumulator + ( + startOfSurfacePointPairs_, + vector2D::zero + ); + + // Calculate target size and alignment for vertices + scalarField sizes + ( + number_of_vertices(), + meshControls().minCellSize() + ); + + Field alignments + ( + number_of_vertices(), + vector2D(1, 0) + ); + + for + ( + Triangulation::Finite_vertices_iterator vit = finite_vertices_begin(); + vit != finite_vertices_end(); + ++vit + ) + { + if (vit->internalOrBoundaryPoint()) + { + point2D vert = toPoint2D(vit->point()); + + // alignment and size determination + pointIndexHit pHit; + label hitSurface = -1; + + qSurf_.findSurfaceNearest + ( + toPoint3D(vert), + meshControls().span2(), + pHit, + hitSurface + ); + + if (pHit.hit()) + { + vectorField norm(1); + allGeometry_[hitSurface].getNormal + ( + List(1, pHit), + norm + ); + + alignments[vit->index()] = toPoint2D(norm[0]); + + sizes[vit->index()] = + cellSizeControl_.cellSize(toPoint3D(vit->point())); + } + } + } + + // Info<< "Calculated alignments" << endl; + + scalar cosAlignmentAcceptanceAngle = 0.68; + + // Upper and lower edge length ratios for weight + scalar u = 1.0; + scalar l = 0.7; + + PackedBoolList pointToBeRetained(startOfSurfacePointPairs_, true); + + std::list pointsToInsert; + + for + ( + Triangulation::Finite_edges_iterator eit = finite_edges_begin(); + eit != finite_edges_end(); + eit++ + ) + { + Vertex_handle vA = eit->first->vertex(cw(eit->second)); + Vertex_handle vB = eit->first->vertex(ccw(eit->second)); + + if (!vA->internalOrBoundaryPoint() || !vB->internalOrBoundaryPoint()) + { + continue; + } + + const point2D& dualV1 = dualVertices[eit->first->faceIndex()]; + const point2D& dualV2 = + dualVertices[eit->first->neighbor(eit->second)->faceIndex()]; + + scalar dualEdgeLength = mag(dualV1 - dualV2); + + point2D dVA = toPoint2D(vA->point()); + point2D dVB = toPoint2D(vB->point()); + + Field alignmentDirsA(2); + + alignmentDirsA[0] = alignments[vA->index()]; + alignmentDirsA[1] = vector2D + ( + -alignmentDirsA[0].y(), + alignmentDirsA[0].x() + ); + + Field alignmentDirsB(2); + + alignmentDirsB[0] = alignments[vB->index()]; + alignmentDirsB[1] = vector2D + ( + -alignmentDirsB[0].y(), + alignmentDirsB[0].x() + ); + + Field alignmentDirs(2); + + forAll(alignmentDirsA, aA) + { + const vector2D& a(alignmentDirsA[aA]); + + scalar maxDotProduct = 0.0; + + forAll(alignmentDirsB, aB) + { + const vector2D& b(alignmentDirsB[aB]); + + scalar dotProduct = a & b; + + if (mag(dotProduct) > maxDotProduct) + { + maxDotProduct = mag(dotProduct); + + alignmentDirs[aA] = a + sign(dotProduct)*b; + + alignmentDirs[aA] /= mag(alignmentDirs[aA]); + } + } + } + + vector2D rAB = dVA - dVB; + + scalar rABMag = mag(rAB); + + forAll(alignmentDirs, aD) + { + vector2D& alignmentDir = alignmentDirs[aD]; + + if ((rAB & alignmentDir) < 0) + { + // swap the direction of the alignment so that has the + // same sense as rAB + alignmentDir *= -1; + } + + scalar alignmentDotProd = ((rAB/rABMag) & alignmentDir); + + if (alignmentDotProd > cosAlignmentAcceptanceAngle) + { + scalar targetFaceSize = + 0.5*(sizes[vA->index()] + sizes[vB->index()]); + + // Test for changing aspect ratio on second alignment (first + // alignment is neartest surface normal) + // if (aD == 1) + // { + // targetFaceSize *= 2.0; + // } + + alignmentDir *= 0.5*targetFaceSize; + + vector2D delta = alignmentDir - 0.5*rAB; + + if (dualEdgeLength < 0.7*targetFaceSize) + { + delta *= 0; + } + else if (dualEdgeLength < targetFaceSize) + { + delta *= + ( + dualEdgeLength + /(targetFaceSize*(u - l)) + - 1/((u/l) - 1) + ); + } + + if + ( + vA->internalPoint() + && vB->internalPoint() + && rABMag > 1.75*targetFaceSize + && dualEdgeLength > 0.05*targetFaceSize + && alignmentDotProd > 0.93 + ) + { + // Point insertion + pointsToInsert.push_back(toPoint(0.5*(dVA + dVB))); + } + else if + ( + (vA->internalPoint() || vB->internalPoint()) + && rABMag < 0.65*targetFaceSize + ) + { + // Point removal + + // Only insert a point at the midpoint of the short edge + // if neither attached point has already been identified + // to be removed. + if + ( + pointToBeRetained[vA->index()] == true + && pointToBeRetained[vB->index()] == true + ) + { + pointsToInsert.push_back(toPoint(0.5*(dVA + dVB))); + } + + if (vA->internalPoint()) + { + pointToBeRetained[vA->index()] = false; + } + + if (vB->internalPoint()) + { + pointToBeRetained[vB->index()] = false; + } + } + else + { + if (vA->internalPoint()) + { + displacementAccumulator[vA->index()] += delta; + } + + if (vB->internalPoint()) + { + displacementAccumulator[vB->index()] += -delta; + } + } + } + } + } + + vector2D totalDisp = sum(displacementAccumulator); + scalar totalDist = sum(mag(displacementAccumulator)); + + // Relax the calculated displacement + displacementAccumulator *= relaxation; + + label numberOfNewPoints = pointsToInsert.size(); + + for + ( + Triangulation::Finite_vertices_iterator vit = finite_vertices_begin(); + vit != finite_vertices_end(); + ++vit + ) + { + if (vit->internalPoint()) + { + if (pointToBeRetained[vit->index()]) + { + pointsToInsert.push_front + ( + toPoint + ( + toPoint2D(vit->point()) + + displacementAccumulator[vit->index()] + ) + ); + } + } + } + + // Clear the triangulation and reinsert the bounding box and feature points. + // This is faster than removing and moving points. + this->clear(); + + insertBoundingBox(); + + reinsertFeaturePoints(); + + startOfInternalPoints_ = number_of_vertices(); + + label nVert = startOfInternalPoints_; + + Info<< "Inserting " << numberOfNewPoints << " new points" << endl; + + // Use the range insert as it is faster than individually inserting points. + insert(pointsToInsert.begin(), pointsToInsert.end()); + + for + ( + Delaunay::Finite_vertices_iterator vit = finite_vertices_begin(); + vit != finite_vertices_end(); + ++vit + ) + { + if + ( + vit->type() == Vb::INTERNAL_POINT + && vit->index() == Vb::INTERNAL_POINT + ) + { + vit->index() = nVert++; + } + } + + Info<< " Total displacement = " << totalDisp << nl + << " Total distance = " << totalDist << nl + << " Points added = " << pointsToInsert.size() + << endl; + + write("internal"); + + insertSurfacePointPairs(); + + boundaryConform(); + + +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// Old Method +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +// for +// ( +// Triangulation::Finite_vertices_iterator vit = finite_vertices_begin(); +// vit != finite_vertices_end(); +// ++vit +// ) +// { +// if (vit->internalPoint()) +// { +// // Current dual-cell defining vertex ("centre") +// point2DFromPoint defVert0 = toPoint2D(vit->point()); + +// Triangulation::Edge_circulator ec = incident_edges(vit); +// Triangulation::Edge_circulator ecStart = ec; + +// // Circulate around the edges to find the first which is not +// // infinite +// do +// { +// if (!is_infinite(ec)) break; +// } while (++ec != ecStart); + +// // Store the start-end of the first non-infinte edge +// point2D de0 = toPoint2D(circumcenter(ec->first)); + +// // Keep track of the maximum edge length^2 +// scalar maxEdgeLen2 = 0.0; + +// // Keep track of the index of the longest edge +// label edgecd0i = -1; + +// // Edge counter +// label edgei = 0; + +// do +// { +// if (!is_infinite(ec)) +// { +// // Get the end of the current edge +// point2D de1 = toPoint2D +// ( +// circumcenter(ec->first->neighbor(ec->second)) +// ); + +// // Store the current edge vector +// edges[edgei] = de1 - de0; + +// // Store the edge mid-point in the vertices array +// vertices[edgei] = 0.5*(de1 + de0); + +// // Move the current edge end into the edge start for the +// // next iteration +// de0 = de1; + +// // Keep track of the longest edge + +// scalar edgeLen2 = magSqr(edges[edgei]); + +// if (edgeLen2 > maxEdgeLen2) +// { +// maxEdgeLen2 = edgeLen2; +// edgecd0i = edgei; +// } + +// edgei++; +// } +// } while (++ec != ecStart); + +// // Initialise cd0 such that the mesh will align +// // in in the x-y directions +// vector2D cd0(1, 0); + +// if (meshControls().relaxOrientation()) +// { +// // Get the longest edge from the array and use as the primary +// // direction of the coordinate system of the "square" cell +// cd0 = edges[edgecd0i]; +// } + +// if (meshControls().nearWallAlignedDist() > 0) +// { +// pointIndexHit pHit = qSurf_.tree().findNearest +// ( +// toPoint3D(defVert0), +// meshControls().nearWallAlignedDist2() +// ); + +// if (pHit.hit()) +// { +// cd0 = toPoint2D(faceNormals[pHit.index()]); +// } +// } + +// // Rotate by 45deg needed to create an averaging procedure which +// // encourages the cells to be square +// cd0 = vector2D(cd0.x() + cd0.y(), cd0.y() - cd0.x()); + +// // Normalise the primary coordinate direction +// cd0 /= mag(cd0); + +// // Calculate the orthogonal coordinate direction +// vector2D cd1(-cd0.y(), cd0.x()); + + +// // Restart the circulator +// ec = ecStart; + +// // ... and the counter +// edgei = 0; + +// // Initialise the displacement for the centre and sum-weights +// vector2D disp = vector2D::zero; +// scalar sumw = 0; + +// do +// { +// if (!is_infinite(ec)) +// { +// // Pick up the current edge +// const vector2D& ei = edges[edgei]; + +// // Calculate the centre to edge-centre vector +// vector2D deltai = vertices[edgei] - defVert0; + +// // Set the weight for this edge contribution +// scalar w = 1; + +// if (meshControls().squares()) +// { +// w = magSqr(deltai.x()*ei.y() - deltai.y()*ei.x()); +// // alternative weights +// //w = mag(deltai.x()*ei.y() - deltai.y()*ei.x()); +// //w = magSqr(ei)*mag(deltai); + +// // Use the following for an ~square mesh +// // Find the coordinate contributions for this edge delta +// scalar cd0deltai = cd0 & deltai; +// scalar cd1deltai = cd1 & deltai; + +// // Create a "square" displacement +// if (mag(cd0deltai) > mag(cd1deltai)) +// { +// disp += (w*cd0deltai)*cd0; +// } +// else +// { +// disp += (w*cd1deltai)*cd1; +// } +// } +// else +// { +// // Use this for a hexagon/pentagon mesh +// disp += w*deltai; +// } + +// // Sum the weights +// sumw += w; +// } +// else +// { +// FatalErrorIn("CV2D::newPoints() const") +// << "Infinite triangle found in internal mesh" +// << exit(FatalError); +// } + +// edgei++; + +// } while (++ec != ecStart); + +// // Calculate the average displacement +// disp /= sumw; +// totalDisp += disp; +// totalDist += mag(disp); + +// // Move the point by a fraction of the average displacement +// movePoint(vit, defVert0 + relaxation*disp); +// } +// } + +// Info << "\nTotal displacement = " << totalDisp +// << " total distance = " << totalDist << endl; +} + + +//void Foam::CV2D::moveInternalPoints(const point2DField& newPoints) +//{ +// label pointI = 0; + +// for +// ( +// Triangulation::Finite_vertices_iterator vit = finite_vertices_begin(); +// vit != finite_vertices_end(); +// ++vit +// ) +// { +// if (vit->internalPoint()) +// { +// movePoint(vit, newPoints[pointI++]); +// } +// } +//} + + +void Foam::CV2D::write() const +{ + if (meshControls().objOutput()) + { + writeFaces("allFaces.obj", false); + writeFaces("faces.obj", true); + writeTriangles("allTriangles.obj", false); + writeTriangles("triangles.obj", true); + writePatch("patch.pch"); + } +} + + +void Foam::CV2D::write(const word& stage) const +{ + if (meshControls().objOutput()) + { + Foam::mkDir(stage + "Faces"); + Foam::mkDir(stage + "Triangles"); + + writeFaces + ( + stage + + "Faces/allFaces_" + + runTime_.timeName() + + ".obj", + false + ); + + writeTriangles + ( + stage + + "Triangles/allTriangles_" + + runTime_.timeName() + + ".obj", + false + ); + } +} + + +// ************************************************************************* // diff --git a/applications/utilities/mesh/generation/cv2DMesh/CV2D.H b/applications/utilities/mesh/generation/cv2DMesh/CV2D.H new file mode 100644 index 0000000000..4948196fc2 --- /dev/null +++ b/applications/utilities/mesh/generation/cv2DMesh/CV2D.H @@ -0,0 +1,474 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2013 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 "relaxationModel.H" +#include "cellSizeAndAlignmentControls.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 + cellSizeAndAlignmentControls cellSizeControl_; + + //- Relaxation coefficient model. Runtime selectable. + autoPtr relaxationModel_; + + //- 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