From e435aa61e00362e3fd56ae525bc9b47b85499f77 Mon Sep 17 00:00:00 2001 From: franjo <franjo@fdcce57e-7e00-11e2-b579-49867b4cea03> Date: Sat, 2 Mar 2013 22:43:04 +0000 Subject: [PATCH] Replaced all tab characters with spaces git-svn-id: https://pl5.projectlocker.com/igui/meshGeneration/svn@5 fdcce57e-7e00-11e2-b579-49867b4cea03 --- GUI/GTK/generalPage/generalpage.glade | 808 +++---- .../keepcellsintersectingpatches.glade | 450 ++-- GUI/GTK/localRefinement/localrefinement.glade | 860 +++---- .../localsettingsmainwindow.glade | 84 +- GUI/GTK/mainWindow/mainwindow.glade | 240 +- GUI/Make/options | 56 +- GUI/meshGenGTK/helpers/gtkHelpers.C | 64 +- GUI/meshGenGTK/meshGenGTK.C | 50 +- GUI/meshGenGTK/meshGenGTK.H | 82 +- GUI/meshGenGTK/meshGenGTKBndLayers.C | 690 +++--- GUI/meshGenGTK/meshGenGTKBoxRefinement.C | 1802 +++++++------- GUI/meshGenGTK/meshGenGTKConeRefinement.C | 2152 ++++++++--------- GUI/meshGenGTK/meshGenGTKGeneralPage.C | 856 +++---- .../meshGenGTKKeepCellsIntersectingPatches.C | 666 ++--- GUI/meshGenGTK/meshGenGTKLineRefinement.C | 1814 +++++++------- GUI/meshGenGTK/meshGenGTKLocalRefinement.C | 974 ++++---- .../meshGenGTKLocalSettingsMainWindow.C | 164 +- GUI/meshGenGTK/meshGenGTKMainWindow.C | 270 +-- .../meshGenGTKObjectRefinementMainWindow.C | 144 +- GUI/meshGenGTK/meshGenGTKRenameBoundary.C | 2090 ++++++++-------- GUI/meshGenGTK/meshGenGTKSphereRefinement.C | 1548 ++++++------ GUI/meshGenGUI/meshGenGUI.C | 20 +- GUI/meshGenGUI/meshGenGUI.H | 202 +- GUI/meshGenGUI/meshGenGUIBndLayers.C | 88 +- GUI/meshGenGUI/meshGenGUIGeneral.C | 116 +- .../meshGenGUIKeepCellsIntersectingPatches.C | 88 +- GUI/meshGenGUI/meshGenGUIObjectRefinement.C | 134 +- GUI/meshGenGUI/meshGenGUIPatchRefinement.C | 84 +- GUI/meshGenGUI/meshGenGUIRenameBoundary.C | 346 +-- GUI/meshGenQt/meshGenQt.C | 84 +- GUI/meshGenQt/meshGenQt.H | 56 +- GUI/meshGenQt/meshGenQtGeneralSettings.C | 436 ++-- GUI/meshGenQt/meshGenQtGeneralSettings.H | 96 +- executables/cartesianMesh/cartesianMesh.C | 2 +- executables/dualMesh/dualMesh.C | 8 +- executables/hexMesh/hexMesh.C | 2 +- executables/pMesh/pMesh.C | 2 +- executables/tetMesh/tetMesh.C | 2 +- .../cartesianMeshExtractor.C | 42 +- .../cartesianMeshExtractor.H | 44 +- ...artesianMeshExtractorDecomposeSplitHexes.C | 12 +- ...artesianMeshExtractorPointsAndAddressing.C | 8 +- .../cartesianMeshExtractorPolyMesh.C | 28 +- .../cartesianMeshGenerator.C | 310 +-- .../cartesianMeshGenerator.H | 54 +- .../dualMeshExtractor/dualMeshExtractor.C | 64 +- .../dualMeshExtractor/dualMeshExtractor.H | 138 +- .../dualMeshExtractorDecompose.C | 1144 ++++----- .../dualMeshExtractorPolyMesh.C | 218 +- .../dualMeshGenerator/dualMeshGenerator.C | 348 +-- .../dualMeshGenerator/dualMeshGenerator.H | 54 +- .../dualUnfoldConcaveCells.C | 132 +- .../dualUnfoldConcaveCells.H | 142 +- .../dualUnfoldConcaveCellsMergeFaces.C | 486 ++-- ...lUnfoldConcaveCellsMergeFacesConsistency.C | 656 ++--- .../hexMeshExtractor/hexMeshExtractor.C | 18 +- .../hexMeshExtractor/hexMeshExtractor.H | 10 +- .../hexMeshGenerator/hexMeshGenerator.C | 24 +- .../hexMeshGenerator/hexMeshGenerator.H | 48 +- .../boundaryLayers/boundaryLayerCells.C | 1158 ++++----- .../utilities/boundaryLayers/boundaryLayers.C | 264 +- .../utilities/boundaryLayers/boundaryLayers.H | 278 +-- .../boundaryLayersCreateVertices.C | 952 ++++---- .../boundaryLayersFacesAndCells.C | 236 +- .../boundaryLayers/boundaryLayersI.H | 480 ++-- .../boundaryLayersWrapperLayer.C | 48 +- .../utilities/boundaryLayers/extrudeLayer.H | 18 +- .../utilities/checkMeshDict/checkMeshDict.C | 2 +- .../utilities/checkMeshDict/checkMeshDict.H | 30 +- .../utilities/containers/DynList/DynList.H | 24 +- .../utilities/containers/DynList/DynListI.H | 48 +- .../utilities/containers/FRWGraph/FRWGraph.C | 36 +- .../utilities/containers/FRWGraph/FRWGraph.H | 2 +- .../utilities/containers/FRWGraph/FRWGraphI.H | 142 +- .../utilities/containers/Graphs/cellIOGraph.C | 12 +- .../utilities/containers/Graphs/cellIOGraph.H | 4 +- .../utilities/containers/Graphs/faceIOGraph.C | 12 +- .../utilities/containers/Graphs/faceIOGraph.H | 4 +- .../containers/IODynList/IODynList.C | 18 +- .../containers/IOLongList/IOLongList.C | 18 +- .../IOLongList/IOLongListInstances.C | 12 +- .../IOLongList/IOLongListInstances.H | 4 +- .../utilities/containers/Lists/cellListPMG.H | 88 +- .../utilities/containers/Lists/cellListPMGI.H | 82 +- .../utilities/containers/Lists/faceListPMG.C | 10 +- .../utilities/containers/Lists/faceListPMG.H | 112 +- .../utilities/containers/Lists/faceListPMGI.H | 98 +- .../containers/Lists/pointFieldPMG.C | 8 +- .../containers/Lists/pointFieldPMG.H | 112 +- .../containers/Lists/pointFieldPMGI.H | 76 +- .../utilities/containers/LongList/LongList.C | 18 +- .../utilities/containers/LongList/LongList.H | 108 +- .../utilities/containers/LongList/LongListI.H | 258 +- .../utilities/containers/VRWGraph/VRWGraph.C | 100 +- .../utilities/containers/VRWGraph/VRWGraph.H | 232 +- .../utilities/containers/VRWGraph/VRWGraphI.H | 420 ++-- .../containers/VRWGraph/VRWGraphSMPModifier.C | 14 +- .../containers/VRWGraph/VRWGraphSMPModifier.H | 8 +- .../VRWGraph/VRWGraphSMPModifierTemplates.C | 14 +- .../containers/VRWGraphList/VRWGraphList.C | 34 +- .../containers/VRWGraphList/VRWGraphList.H | 84 +- .../containers/VRWGraphList/VRWGraphListI.H | 136 +- .../utilities/containers/graphRow/graphRow.H | 86 +- .../utilities/containers/graphRow/graphRowI.H | 76 +- .../utilities/containers/subGraph/subGraph.H | 80 +- .../utilities/containers/subGraph/subGraphI.H | 124 +- .../foamToEnsight/ensightMesh.C | 202 +- .../foamToEnsight/ensightMesh.H | 22 +- .../foamToEnsight/writeMeshEnsight.C | 64 +- .../dataConversion/foamToFLMA/flmaMesh.C | 38 +- .../dataConversion/foamToFLMA/flmaMesh.H | 20 +- .../dataConversion/foamToFLMA/writeMeshFLMA.C | 26 +- .../dataConversion/foamToFLMA/writeMeshFLMA.H | 2 +- .../dataConversion/foamToFPMA/fpmaMesh.C | 78 +- .../dataConversion/foamToFPMA/fpmaMesh.H | 8 +- .../dataConversion/foamToFPMA/writeMeshFPMA.C | 44 +- .../dataConversion/foamToFPMA/writeMeshFPMA.H | 2 +- .../octreeToEnsight/octreeMesh.C | 254 +- .../octreeToEnsight/octreeMesh.H | 18 +- .../octreeToEnsight/writeOctreeEnsight.C | 174 +- .../octreeToEnsight/writeOctreeEnsight.H | 10 +- .../octreeToFPMA/octreeMeshFPMA.C | 76 +- .../octreeToFPMA/octreeMeshFPMA.H | 22 +- .../octreeToFPMA/writeOctreeFPMA.C | 50 +- .../octreeToFPMA/writeOctreeFPMA.H | 4 +- .../simplexToFLMA/simplexMesh.C | 28 +- .../simplexToFLMA/simplexMesh.H | 20 +- .../simplexToFLMA/writeSimplexFLMA.C | 26 +- .../simplexToFLMA/writeSimplexFLMA.H | 2 +- .../utilities/decomposeCells/decomposeCells.H | 84 +- .../decomposeCellsDecomposition.C | 2 +- .../decomposeCells/decomposeCellsPyramids.C | 72 +- .../faceDecomposition/decomposeFaces.C | 2 +- .../faceDecomposition/decomposeFaces.H | 18 +- .../faceDecomposition/faceDecomposition.C | 30 +- .../faceDecomposition/faceDecomposition.H | 50 +- .../createFacesFromChain.C | 686 +++--- .../createFacesFromChain.H | 106 +- .../helperClasses/inSphereTest/inSphereTest.H | 2 +- .../helperClasses/matrices/matrix2D.H | 56 +- .../helperClasses/matrices/matrix2DI.H | 106 +- .../helperClasses/matrices/matrix3D.H | 72 +- .../helperClasses/matrices/matrix3DI.H | 148 +- .../labelledPair/labelledPair.H | 58 +- .../labelledPoint/labelledPoint.H | 20 +- .../labelledPointScalar/labelledPointScalar.H | 20 +- .../sortEdgesIntoChains/sortEdgesIntoChains.C | 384 +-- .../sortEdgesIntoChains/sortEdgesIntoChains.H | 78 +- .../helperFunctions/helperFunctionsPar.C | 6 +- .../helperFunctionsStringConversion.C | 26 +- .../helperFunctionsTopologyManipulationI.H | 514 ++-- .../meshes/partTetMesh/partTetMesh.C | 262 +- .../meshes/partTetMesh/partTetMesh.H | 146 +- .../partTetMesh/partTetMeshAddressing.C | 268 +- .../partTetMeshParallelAddressing.C | 20 +- .../meshes/partTetMesh/partTetMeshSimplex.C | 230 +- .../meshes/polyMeshGen/polyMeshGen.C | 4 +- .../meshes/polyMeshGen/polyMeshGen.H | 46 +- .../meshes/polyMeshGen/polyMeshGenFaces.C | 346 +-- .../meshes/polyMeshGen/polyMeshGenFaces.H | 148 +- .../meshes/polyMeshGen/polyMeshGenFacesI.H | 30 +- .../meshes/polyMeshGen/polyMeshGenPoints.C | 78 +- .../meshes/polyMeshGen/polyMeshGenPoints.H | 76 +- .../meshes/polyMeshGen/polyMeshGenPointsI.H | 8 +- .../polyMeshGen/writePatch/writePatch.C | 14 +- .../polyMeshGen/writePatch/writePatch.H | 24 +- .../polyMeshGen/writePatch/writePatchBase.C | 6 +- .../polyMeshGen/writePatch/writePatchBase.H | 10 +- .../writePatch/writeProcessorPatch.C | 18 +- .../writePatch/writeProcessorPatch.H | 30 +- .../polyMeshGenAddressing.H | 70 +- .../polyMeshGenAddressingCellCells.C | 2 +- .../polyMeshGenAddressingCellPoints.C | 2 +- .../polyMeshGenAddressingCentresAndAreas.C | 6 +- .../polyMeshGenAddressingCentresAndVols.C | 6 +- .../polyMeshGenAddressingPointFaces.C | 2 +- .../polyMeshGenAddressingPointPoints.C | 4 +- .../polyMeshGenAddressingUpdateGeometry.C | 290 +-- .../polyMeshGenChecksGeometry.C | 30 +- .../polyMeshGenChecksTopology.C | 4 +- .../polyMeshGenModifierAddCellByCell.C | 126 +- .../polyMeshGenModifierAddCellByCell.H | 36 +- .../polyMeshGenModifierRemoveCells.C | 88 +- .../polyMeshGenModifierRemoveFaces.C | 88 +- .../polyMeshGenModifierRemoveUnusedVertices.C | 2 +- .../polyMeshGenModifierRenumberMesh.C | 4 +- .../polyMeshGenModifierReorderBoundaryFaces.C | 4 +- .../polyMeshGenModifierZipUpCells.C | 102 +- .../primitives/meshSubsets/meshSubset.H | 16 +- .../meshes/primitives/partTet/partTet.H | 72 +- .../meshes/primitives/partTet/partTetI.H | 166 +- .../utilities/meshes/triSurf/triSurf.C | 198 +- .../utilities/meshes/triSurf/triSurf.H | 4 +- .../meshOctreeAddressing.C | 192 +- .../meshOctreeAddressing.H | 164 +- .../meshOctreeAddressingCreation.C | 650 ++--- .../meshOctreeAddressingGluedMesh.C | 166 +- .../meshOctreeAddressingI.H | 54 +- ...meshOctreeAddressingIrregularConnections.C | 2 +- .../meshOctreeAutomaticRefinement.C | 8 +- .../meshOctreeAutomaticRefinement.H | 6 +- .../meshOctreeAutomaticRefinementRef.C | 6 +- .../meshOctreeFindNearestSurfacePoint.C | 4 +- .../octrees/meshOctree/meshOctreeI.H | 16 +- .../meshOctreeModifier/meshOctreeModifier.C | 2 +- .../meshOctreeModifierParallelRefinement.C | 4 +- .../meshOctree/meshOctreeNeighbourSearches.C | 2 +- .../objectRefinement/boxRefinement.C | 174 +- .../objectRefinement/boxRefinement.H | 96 +- .../objectRefinement/coneRefinement.C | 144 +- .../objectRefinement/coneRefinement.H | 72 +- .../objectRefinement/lineRefinement.C | 66 +- .../objectRefinement/lineRefinement.H | 60 +- .../objectRefinement/newObjectRefinement.C | 2 +- .../objectRefinement/objectRefinement.C | 12 +- .../objectRefinement/objectRefinementList.H | 2 +- .../objectRefinement/sphereRefinement.C | 68 +- .../objectRefinement/sphereRefinement.H | 60 +- .../patchRefinement/patchRefinement.C | 4 +- .../patchRefinement/patchRefinement.H | 4 +- .../patchRefinement/patchRefinementList.H | 2 +- .../surfaceIntersectionsOctree.C | 4 +- .../surfaceIntersectionsOctreeCube.H | 24 +- .../geometry/meshOptimizer/meshOptimizer.C | 28 +- .../geometry/meshOptimizer/meshOptimizer.H | 46 +- .../meshOptimizerOptimizePoint.C | 4 +- .../meshOptimizerOptimizePointParallel.C | 250 +- .../meshOptimizerOptimizeSurface.C | 12 +- .../geometry/meshOptimizer/optimizeMeshFV.C | 154 +- .../knuppMetric/knuppMetric.C | 62 +- .../knuppMetric/knuppMetric.H | 20 +- .../meshUntangler/meshUntangler.C | 92 +- .../meshUntangler/meshUntangler.H | 160 +- .../meshUntangler/meshUntanglerCutRegion.C | 418 ++-- .../meshUntanglerCutRegionEdges.C | 140 +- .../meshUntanglerCutRegionFaces.C | 334 +-- .../meshUntanglerCutRegionPoints.C | 270 +-- .../meshUntanglerCutRegionTieBreak.C | 294 +-- .../simplexSmoother/simplexSmoother.H | 52 +- .../volumeOptimizer/volumeOptimizer.C | 86 +- .../volumeOptimizer/volumeOptimizer.H | 44 +- .../volumeOptimizerEvaluateGradients.C | 248 +- .../tetMeshOptimisation/tetMeshOptimisation.H | 2 +- .../tetMeshOptimisationParallel.C | 36 +- .../surfaceOptimizer/surfaceOptimizer.C | 292 +-- .../surfaceOptimizer/surfaceOptimizer.H | 10 +- .../meshSurfaceOptimizer.C | 20 +- .../meshSurfaceOptimizer.H | 120 +- ...OptimizerCalculateTrianglesAndAddressing.C | 56 +- .../meshSurfaceOptimizerI.H | 422 ++-- .../meshSurfaceOptimizerOptimizePoint.C | 80 +- ...eshSurfaceOptimizerOptimizePointParallel.C | 156 +- .../meshSurfaceOptimizerOptimizeSurface.C | 154 +- .../checkBoundaryFacesSharingTwoEdges.H | 4 +- .../checkCellConnectionsOverFaces.C | 12 +- .../checkCellConnectionsOverFaces.H | 12 +- .../checkIrregularSurfaceConnections.H | 8 +- ...heckIrregularSurfaceConnectionsFunctions.C | 10 +- .../checkNonMappableCellConnections.H | 4 +- .../topologicalCleaner/topologicalCleaner.H | 44 +- .../topologyCleanerNonMappableCells.C | 178 +- .../boundaryFacesGenerator.C | 158 +- .../boundaryFacesGenerator.H | 114 +- ...oundaryFacesGeneratorCreateBoundaryFaces.C | 342 +-- .../boundaryFacesGeneratorFacesForChain.C | 290 +-- .../boundaryOutwardOrientation.C | 54 +- .../boundaryOutwardOrientation.H | 10 +- .../correctEdgesBetweenPatches.C | 42 +- .../correctEdgesBetweenPatches.H | 48 +- .../decomposeCellsNearConcaveEdges.C | 16 +- .../decomposeCellsNearConcaveEdges.H | 20 +- .../decomposeCellsNearConcaveEdgesDecompose.C | 130 +- .../meshSurfaceCheckInvertedVertices.C | 4 +- .../meshSurfaceCutter/meshSurfaceCutter.C | 32 +- .../meshSurfaceCutter/meshSurfaceCutter.H | 46 +- .../meshSurfaceCutterBoundaryFaces.C | 38 +- .../meshSurfaceCutterCreateEdges.C | 6 +- .../meshSurfaceCutterEdgePoints.C | 38 +- .../meshSurfaceCutterFaceCutter.C | 16 +- .../meshSurfaceCutterFaceDirections.C | 82 +- .../meshSurfaceCutterInternalFaces.C | 150 +- .../meshSurfaceEdgeCreateBoundaryFaces.C | 20 +- .../meshSurfaceEdgeCreateEdgeVertices.C | 208 +- .../meshSurfaceEdgeExtractor.C | 92 +- .../meshSurfaceEdgeExtractor.H | 32 +- .../meshSurfaceEdgeExtractorNonTopo.C | 16 +- .../meshSurfaceEdgeExtractorNonTopo.H | 24 +- ...rfaceEdgeExtractorNonTopoDistributeFaces.C | 98 +- .../meshSurfaceEngine/meshSurfaceEngine.C | 58 +- .../meshSurfaceEngine/meshSurfaceEngine.H | 62 +- ...faceEngineCalculateBoundaryNodesAndFaces.C | 134 +- .../meshSurfaceEngineModifier.C | 120 +- .../meshSurfaceEngineModifier.H | 20 +- .../meshSurfaceEngineParallelAddressing.C | 42 +- .../meshSurfaceMapperCornersAndEdges.C | 2 +- .../meshSurfaceMapperMapVertices.C | 26 +- .../meshSurfacePartitioner.C | 2 +- .../meshSurfacePartitioner.H | 4 +- .../renameBoundaryPatches.C | 76 +- .../renameBoundaryPatches.H | 16 +- .../surfaceMorpherCells/surfaceMorpherCells.C | 210 +- .../surfaceMorpherCells/surfaceMorpherCells.H | 70 +- .../surfaceMorpherCellsCreateBoundaryFaces.C | 362 +-- .../surfaceMorpherCellsMorphInternalFaces.C | 2 +- .../triangulateNonPlanarBoundaryFaces.C | 84 +- .../triangulateNonPlanarBoundaryFaces.H | 8 +- .../tetrahedra/delaunayTessellation.tgz | Bin 22699 -> 23032 bytes .../tetCreatorOctree/tetCreatorOctree.C | 224 +- .../tetCreatorOctree/tetCreatorOctree.H | 164 +- .../tetCreatorOctreeFromFacesWithCentreNode.C | 66 +- .../tetCreatorOctree/tetCreatorOctreeI.H | 22 +- .../tetCreatorOctreePointsAndAddressing.C | 466 ++-- .../tetCreatorOctreeTetsAroundEdges.C | 294 +-- .../tetCreatorOctreeTetsAroundSplitEdges.C | 626 ++--- .../tetCreatorOctreeTetsFromSplitFaces.C | 64 +- .../tetPointsCreator/tetPointsCreator.C | 6 +- .../tetPointsCreator/tetPointsCreator.H | 28 +- .../tetPointsCreatorAddPoints.C | 128 +- .../delaunayTessellation.H | 36 +- .../delaunayTessellationFunctions.C | 194 +- .../subdivisionTessellation.H | 60 +- .../subdivisionTessellationFunctions.C | 468 ++-- .../tetTessellation/tessellationElement.C | 28 +- .../tetTessellation/tessellationElement.H | 60 +- .../tetTessellation/tessellationElementI.H | 64 +- .../tetTessellation/tetTessellation.C | 190 +- .../tetTessellation/tetTessellation.H | 68 +- .../tetTessellationFunctions.C | 24 +- .../tetTessellation/tetTessellationNewElmts.C | 280 +-- .../triSurfaceCleanupDuplicates.H | 2 +- .../triSurfaceCurvatureEstimator.H | 2 +- .../triSurfaceDetectMaterials.C | 4 +- .../triSurfaceDetectMaterials.H | 10 +- .../triSurfacePartitioner.C | 18 +- .../triSurfacePartitioner.H | 50 +- .../triSurfacePartitionerCreateAddressing.C | 80 +- .../voronoiMeshExtractor.C | 54 +- .../voronoiMeshExtractor.H | 64 +- .../voronoiMeshExtractorAddressing.C | 316 +-- .../voronoiMeshExtractorCreateMesh.C | 186 +- .../testBoundaryLayer/testBoundaryLayer.C | 78 +- .../testCartesianMeshExtractor.C | 36 +- .../testCellSurfaceIntersections.C | 20 +- .../testChainFromEdges/testChainFromEdges.C | 38 +- .../testConcaveCellUnfolder.C | 84 +- testingInterfaces/testDelaunay/testDelaunay.C | 40 +- .../testDualMeshExtractor.C | 44 +- .../testDynListHP/testDynListHP.C | 54 +- .../testFacesFromChain/testFacesFromChain.C | 94 +- testingInterfaces/testGraph/testGraph.C | 4 +- .../testMaterialDetector.C | 12 +- .../testParallelMesh/testParallelMesh.C | 10 +- .../testRenumberMesh/testRenumberMesh.C | 74 +- .../testSurfaceEdgeExtractor.C | 68 +- .../testSurfaceMorpher/testSurfaceMorpher.C | 8 +- .../testSurfaceSmoothing.C | 56 +- .../testVoronoiMeshExtractor.C | 38 +- tutorials/FanOctree/system/meshDict | 60 +- tutorials/asmoOctree/system/meshDict | 8 +- tutorials/bunnyOctree/system/meshDict | 52 +- tutorials/cutCubeOctree/system/meshDict | 2 +- tutorials/intakePortOctree/system/meshDict | 18 +- tutorials/sBendOctree/system/meshDict | 6 +- tutorials/sawOctree/system/meshDict | 6 +- tutorials/socketOctree/system/meshDict | 6 +- utilities/FLMAToSurface/FLMAToSurface.C | 232 +- utilities/FPMAToMesh/FPMAToMesh.C | 184 +- utilities/FPMAToMesh/Make/options | 4 +- .../cellSetIntersectedByPlane.C | 136 +- utilities/meshToFPMA/Make/options | 4 +- utilities/meshToFPMA/meshToFPMA.C | 10 +- utilities/patchesToSubsets/patchesToSubsets.C | 20 +- utilities/plyToSurface/Make/options | 2 +- utilities/plyToSurface/plyToSurface.C | 100 +- utilities/preparePar/preparePar.C | 64 +- utilities/printCellsInSet/printCellsInSet.C | 42 +- utilities/starSurfaceToSTL/Make/options | 2 +- utilities/starSurfaceToSTL/starSurfaceToSTL.C | 2 +- utilities/subsetToPatch/subsetToPatch.C | 16 +- utilities/surfaceClosedness/Make/options | 2 +- .../surfaceClosedness/surfaceClosedness.C | 2 +- utilities/surfaceFeatureEdges/Make/options | 4 +- .../surfaceFeatureEdges/surfaceFeatureEdges.C | 6 +- .../surfaceGenerateBoundingBox/Make/options | 4 +- .../surfaceGenerateBoundingBox.C | 2 +- .../surfaceOutwardOrientation/Make/options | 4 +- .../surfaceOutwardOrientation.C | 2 +- utilities/surfaceRefine/Make/options | 2 +- utilities/surfaceRefine/surfaceRefine.C | 2 +- utilities/surfaceStitch/Make/options | 2 +- utilities/surfaceStitch/surfaceStitch.C | 204 +- 391 files changed, 25375 insertions(+), 25375 deletions(-) diff --git a/GUI/GTK/generalPage/generalpage.glade b/GUI/GTK/generalPage/generalpage.glade index 070e41ff..8e60bee7 100644 --- a/GUI/GTK/generalPage/generalpage.glade +++ b/GUI/GTK/generalPage/generalpage.glade @@ -33,435 +33,435 @@ <property name="right_padding">0</property> <child> - <widget class="GtkVBox" id="vbox1"> - <property name="visible">True</property> - <property name="homogeneous">False</property> - <property name="spacing">0</property> + <widget class="GtkVBox" id="vbox1"> + <property name="visible">True</property> + <property name="homogeneous">False</property> + <property name="spacing">0</property> - <child> - <widget class="GtkHBox" id="hbox1"> - <property name="visible">True</property> - <property name="homogeneous">False</property> - <property name="spacing">0</property> + <child> + <widget class="GtkHBox" id="hbox1"> + <property name="visible">True</property> + <property name="homogeneous">False</property> + <property name="spacing">0</property> - <child> - <widget class="GtkLabel" id="label_surfaceFile"> - <property name="visible">True</property> - <property name="label" translatable="yes">Surface file</property> - <property name="use_underline">False</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0.5</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> - <property name="width_chars">-1</property> - <property name="single_line_mode">False</property> - <property name="angle">0</property> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">False</property> - </packing> - </child> + <child> + <widget class="GtkLabel" id="label_surfaceFile"> + <property name="visible">True</property> + <property name="label" translatable="yes">Surface file</property> + <property name="use_underline">False</property> + <property name="use_markup">False</property> + <property name="justify">GTK_JUSTIFY_LEFT</property> + <property name="wrap">False</property> + <property name="selectable">False</property> + <property name="xalign">0.5</property> + <property name="yalign">0.5</property> + <property name="xpad">0</property> + <property name="ypad">0</property> + <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> + <property name="width_chars">-1</property> + <property name="single_line_mode">False</property> + <property name="angle">0</property> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">False</property> + </packing> + </child> - <child> - <widget class="GtkAlignment" id="alignment4"> - <property name="visible">True</property> - <property name="xalign">0.5</property> - <property name="yalign">0.5</property> - <property name="xscale">1</property> - <property name="yscale">1</property> - <property name="top_padding">0</property> - <property name="bottom_padding">0</property> - <property name="left_padding">96</property> - <property name="right_padding">0</property> + <child> + <widget class="GtkAlignment" id="alignment4"> + <property name="visible">True</property> + <property name="xalign">0.5</property> + <property name="yalign">0.5</property> + <property name="xscale">1</property> + <property name="yscale">1</property> + <property name="top_padding">0</property> + <property name="bottom_padding">0</property> + <property name="left_padding">96</property> + <property name="right_padding">0</property> - <child> - <widget class="GtkEntry" id="entry_surfaceFile"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="editable">True</property> - <property name="visibility">True</property> - <property name="max_length">0</property> - <property name="text" translatable="yes"></property> - <property name="has_frame">True</property> - <property name="invisible_char">●</property> - <property name="activates_default">False</property> - <signal name="editing_done" handler="on_entry_surfaceFile_editing_done" last_modification_time="Thu, 18 Oct 2007 20:17:37 GMT"/> - </widget> - </child> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">True</property> - <property name="fill">True</property> - </packing> - </child> + <child> + <widget class="GtkEntry" id="entry_surfaceFile"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="editable">True</property> + <property name="visibility">True</property> + <property name="max_length">0</property> + <property name="text" translatable="yes"></property> + <property name="has_frame">True</property> + <property name="invisible_char">●</property> + <property name="activates_default">False</property> + <signal name="editing_done" handler="on_entry_surfaceFile_editing_done" last_modification_time="Thu, 18 Oct 2007 20:17:37 GMT"/> + </widget> + </child> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">True</property> + <property name="fill">True</property> + </packing> + </child> - <child> - <widget class="GtkButton" id="button1"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="relief">GTK_RELIEF_NORMAL</property> - <property name="focus_on_click">True</property> + <child> + <widget class="GtkButton" id="button1"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="relief">GTK_RELIEF_NORMAL</property> + <property name="focus_on_click">True</property> - <child> - <widget class="GtkImage" id="image1"> - <property name="visible">True</property> - <property name="stock">gtk-open</property> - <property name="icon_size">4</property> - <property name="xalign">0.5</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - </widget> - </child> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">False</property> - </packing> - </child> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">True</property> - <property name="fill">True</property> - </packing> - </child> + <child> + <widget class="GtkImage" id="image1"> + <property name="visible">True</property> + <property name="stock">gtk-open</property> + <property name="icon_size">4</property> + <property name="xalign">0.5</property> + <property name="yalign">0.5</property> + <property name="xpad">0</property> + <property name="ypad">0</property> + </widget> + </child> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">False</property> + </packing> + </child> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">True</property> + <property name="fill">True</property> + </packing> + </child> - <child> - <widget class="GtkHBox" id="hbox2"> - <property name="visible">True</property> - <property name="homogeneous">False</property> - <property name="spacing">0</property> + <child> + <widget class="GtkHBox" id="hbox2"> + <property name="visible">True</property> + <property name="homogeneous">False</property> + <property name="spacing">0</property> - <child> - <widget class="GtkLabel" id="label_maxCellSize"> - <property name="visible">True</property> - <property name="label" translatable="yes">Max cell size [m]</property> - <property name="use_underline">False</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0.5</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> - <property name="width_chars">-1</property> - <property name="single_line_mode">False</property> - <property name="angle">0</property> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">False</property> - </packing> - </child> + <child> + <widget class="GtkLabel" id="label_maxCellSize"> + <property name="visible">True</property> + <property name="label" translatable="yes">Max cell size [m]</property> + <property name="use_underline">False</property> + <property name="use_markup">False</property> + <property name="justify">GTK_JUSTIFY_LEFT</property> + <property name="wrap">False</property> + <property name="selectable">False</property> + <property name="xalign">0.5</property> + <property name="yalign">0.5</property> + <property name="xpad">0</property> + <property name="ypad">0</property> + <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> + <property name="width_chars">-1</property> + <property name="single_line_mode">False</property> + <property name="angle">0</property> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">False</property> + </packing> + </child> - <child> - <widget class="GtkAlignment" id="alignment3"> - <property name="visible">True</property> - <property name="xalign">0.5</property> - <property name="yalign">0.5</property> - <property name="xscale">1</property> - <property name="yscale">1</property> - <property name="top_padding">0</property> - <property name="bottom_padding">0</property> - <property name="left_padding">54</property> - <property name="right_padding">0</property> + <child> + <widget class="GtkAlignment" id="alignment3"> + <property name="visible">True</property> + <property name="xalign">0.5</property> + <property name="yalign">0.5</property> + <property name="xscale">1</property> + <property name="yscale">1</property> + <property name="top_padding">0</property> + <property name="bottom_padding">0</property> + <property name="left_padding">54</property> + <property name="right_padding">0</property> - <child> - <widget class="GtkEntry" id="entry_maxCellSize"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="editable">True</property> - <property name="visibility">True</property> - <property name="max_length">0</property> - <property name="text" translatable="yes"></property> - <property name="has_frame">True</property> - <property name="invisible_char">●</property> - <property name="activates_default">False</property> - </widget> - </child> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">True</property> - <property name="fill">True</property> - </packing> - </child> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">True</property> - <property name="fill">True</property> - </packing> - </child> + <child> + <widget class="GtkEntry" id="entry_maxCellSize"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="editable">True</property> + <property name="visibility">True</property> + <property name="max_length">0</property> + <property name="text" translatable="yes"></property> + <property name="has_frame">True</property> + <property name="invisible_char">●</property> + <property name="activates_default">False</property> + </widget> + </child> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">True</property> + <property name="fill">True</property> + </packing> + </child> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">True</property> + <property name="fill">True</property> + </packing> + </child> - <child> - <widget class="GtkCheckButton" id="checkbutton_boundaryCellSize"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="label" translatable="yes">Use different size for boundary cells</property> - <property name="use_underline">True</property> - <property name="relief">GTK_RELIEF_NORMAL</property> - <property name="focus_on_click">True</property> - <property name="active">False</property> - <property name="inconsistent">False</property> - <property name="draw_indicator">True</property> - <signal name="activate" handler="on_checkbutton_boundaryCellSize_activate" object="meshGui_" last_modification_time="Wed, 17 Oct 2007 18:54:38 GMT"/> - <signal name="clicked" handler="on_checkbutton_boundaryCellSize_clicked" object="meshGui_" last_modification_time="Wed, 17 Oct 2007 18:54:56 GMT"/> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">False</property> - </packing> - </child> + <child> + <widget class="GtkCheckButton" id="checkbutton_boundaryCellSize"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="label" translatable="yes">Use different size for boundary cells</property> + <property name="use_underline">True</property> + <property name="relief">GTK_RELIEF_NORMAL</property> + <property name="focus_on_click">True</property> + <property name="active">False</property> + <property name="inconsistent">False</property> + <property name="draw_indicator">True</property> + <signal name="activate" handler="on_checkbutton_boundaryCellSize_activate" object="meshGui_" last_modification_time="Wed, 17 Oct 2007 18:54:38 GMT"/> + <signal name="clicked" handler="on_checkbutton_boundaryCellSize_clicked" object="meshGui_" last_modification_time="Wed, 17 Oct 2007 18:54:56 GMT"/> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">False</property> + </packing> + </child> - <child> - <widget class="GtkHBox" id="hbox3"> - <property name="visible">True</property> - <property name="homogeneous">False</property> - <property name="spacing">0</property> + <child> + <widget class="GtkHBox" id="hbox3"> + <property name="visible">True</property> + <property name="homogeneous">False</property> + <property name="spacing">0</property> - <child> - <widget class="GtkLabel" id="label_boundaryCellSize"> - <property name="visible">True</property> - <property name="label" translatable="yes">Boundary cell size [m]</property> - <property name="use_underline">False</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0.5</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> - <property name="width_chars">-1</property> - <property name="single_line_mode">False</property> - <property name="angle">0</property> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">False</property> - </packing> - </child> + <child> + <widget class="GtkLabel" id="label_boundaryCellSize"> + <property name="visible">True</property> + <property name="label" translatable="yes">Boundary cell size [m]</property> + <property name="use_underline">False</property> + <property name="use_markup">False</property> + <property name="justify">GTK_JUSTIFY_LEFT</property> + <property name="wrap">False</property> + <property name="selectable">False</property> + <property name="xalign">0.5</property> + <property name="yalign">0.5</property> + <property name="xpad">0</property> + <property name="ypad">0</property> + <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> + <property name="width_chars">-1</property> + <property name="single_line_mode">False</property> + <property name="angle">0</property> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">False</property> + </packing> + </child> - <child> - <widget class="GtkAlignment" id="alignment2"> - <property name="visible">True</property> - <property name="xalign">0.5</property> - <property name="yalign">0.5</property> - <property name="xscale">1</property> - <property name="yscale">1</property> - <property name="top_padding">0</property> - <property name="bottom_padding">0</property> - <property name="left_padding">10</property> - <property name="right_padding">0</property> + <child> + <widget class="GtkAlignment" id="alignment2"> + <property name="visible">True</property> + <property name="xalign">0.5</property> + <property name="yalign">0.5</property> + <property name="xscale">1</property> + <property name="yscale">1</property> + <property name="top_padding">0</property> + <property name="bottom_padding">0</property> + <property name="left_padding">10</property> + <property name="right_padding">0</property> - <child> - <widget class="GtkEntry" id="entry_boundaryCellSize"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="editable">True</property> - <property name="visibility">True</property> - <property name="max_length">0</property> - <property name="text" translatable="yes"></property> - <property name="has_frame">True</property> - <property name="invisible_char">●</property> - <property name="activates_default">False</property> - </widget> - </child> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">True</property> - <property name="fill">True</property> - </packing> - </child> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">True</property> - <property name="fill">True</property> - </packing> - </child> + <child> + <widget class="GtkEntry" id="entry_boundaryCellSize"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="editable">True</property> + <property name="visibility">True</property> + <property name="max_length">0</property> + <property name="text" translatable="yes"></property> + <property name="has_frame">True</property> + <property name="invisible_char">●</property> + <property name="activates_default">False</property> + </widget> + </child> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">True</property> + <property name="fill">True</property> + </packing> + </child> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">True</property> + <property name="fill">True</property> + </packing> + </child> - <child> - <widget class="GtkHSeparator" id="hseparator2"> - <property name="visible">True</property> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">True</property> - <property name="fill">True</property> - </packing> - </child> + <child> + <widget class="GtkHSeparator" id="hseparator2"> + <property name="visible">True</property> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">True</property> + <property name="fill">True</property> + </packing> + </child> - <child> - <widget class="GtkVBox" id="vbox2"> - <property name="visible">True</property> - <property name="homogeneous">False</property> - <property name="spacing">0</property> + <child> + <widget class="GtkVBox" id="vbox2"> + <property name="visible">True</property> + <property name="homogeneous">False</property> + <property name="spacing">0</property> - <child> - <widget class="GtkCheckButton" id="checkbutton_automaticRefinement"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="label" translatable="yes">Use automatic refinement</property> - <property name="use_underline">True</property> - <property name="relief">GTK_RELIEF_NORMAL</property> - <property name="focus_on_click">True</property> - <property name="active">False</property> - <property name="inconsistent">False</property> - <property name="draw_indicator">True</property> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">False</property> - </packing> - </child> + <child> + <widget class="GtkCheckButton" id="checkbutton_automaticRefinement"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="label" translatable="yes">Use automatic refinement</property> + <property name="use_underline">True</property> + <property name="relief">GTK_RELIEF_NORMAL</property> + <property name="focus_on_click">True</property> + <property name="active">False</property> + <property name="inconsistent">False</property> + <property name="draw_indicator">True</property> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">False</property> + </packing> + </child> - <child> - <widget class="GtkHBox" id="hbox4"> - <property name="visible">True</property> - <property name="homogeneous">False</property> - <property name="spacing">0</property> + <child> + <widget class="GtkHBox" id="hbox4"> + <property name="visible">True</property> + <property name="homogeneous">False</property> + <property name="spacing">0</property> - <child> - <widget class="GtkLabel" id="label_minCellSize"> - <property name="visible">True</property> - <property name="label" translatable="yes">Min cell size [m]</property> - <property name="use_underline">False</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0.5</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> - <property name="width_chars">-1</property> - <property name="single_line_mode">False</property> - <property name="angle">0</property> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">False</property> - </packing> - </child> + <child> + <widget class="GtkLabel" id="label_minCellSize"> + <property name="visible">True</property> + <property name="label" translatable="yes">Min cell size [m]</property> + <property name="use_underline">False</property> + <property name="use_markup">False</property> + <property name="justify">GTK_JUSTIFY_LEFT</property> + <property name="wrap">False</property> + <property name="selectable">False</property> + <property name="xalign">0.5</property> + <property name="yalign">0.5</property> + <property name="xpad">0</property> + <property name="ypad">0</property> + <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> + <property name="width_chars">-1</property> + <property name="single_line_mode">False</property> + <property name="angle">0</property> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">False</property> + </packing> + </child> - <child> - <widget class="GtkAlignment" id="alignment5"> - <property name="visible">True</property> - <property name="xalign">0.5</property> - <property name="yalign">0.5</property> - <property name="xscale">1</property> - <property name="yscale">1</property> - <property name="top_padding">0</property> - <property name="bottom_padding">0</property> - <property name="left_padding">61</property> - <property name="right_padding">0</property> + <child> + <widget class="GtkAlignment" id="alignment5"> + <property name="visible">True</property> + <property name="xalign">0.5</property> + <property name="yalign">0.5</property> + <property name="xscale">1</property> + <property name="yscale">1</property> + <property name="top_padding">0</property> + <property name="bottom_padding">0</property> + <property name="left_padding">61</property> + <property name="right_padding">0</property> - <child> - <widget class="GtkEntry" id="entry_minCellSize"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="editable">True</property> - <property name="visibility">True</property> - <property name="max_length">0</property> - <property name="text" translatable="yes"></property> - <property name="has_frame">True</property> - <property name="invisible_char">●</property> - <property name="activates_default">False</property> - </widget> - </child> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">True</property> - <property name="fill">True</property> - </packing> - </child> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">True</property> - <property name="fill">True</property> - </packing> - </child> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">True</property> - <property name="fill">True</property> - </packing> - </child> + <child> + <widget class="GtkEntry" id="entry_minCellSize"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="editable">True</property> + <property name="visibility">True</property> + <property name="max_length">0</property> + <property name="text" translatable="yes"></property> + <property name="has_frame">True</property> + <property name="invisible_char">●</property> + <property name="activates_default">False</property> + </widget> + </child> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">True</property> + <property name="fill">True</property> + </packing> + </child> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">True</property> + <property name="fill">True</property> + </packing> + </child> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">True</property> + <property name="fill">True</property> + </packing> + </child> - <child> - <widget class="GtkHSeparator" id="hseparator1"> - <property name="visible">True</property> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">True</property> - <property name="fill">True</property> - </packing> - </child> + <child> + <widget class="GtkHSeparator" id="hseparator1"> + <property name="visible">True</property> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">True</property> + <property name="fill">True</property> + </packing> + </child> - <child> - <widget class="GtkCheckButton" id="checkbutton_keepCellsIntersectingBoundary"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="label" translatable="yes">Keep octree boxes intersecting the boundary</property> - <property name="use_underline">True</property> - <property name="relief">GTK_RELIEF_NORMAL</property> - <property name="focus_on_click">True</property> - <property name="active">False</property> - <property name="inconsistent">False</property> - <property name="draw_indicator">True</property> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">False</property> - </packing> - </child> + <child> + <widget class="GtkCheckButton" id="checkbutton_keepCellsIntersectingBoundary"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="label" translatable="yes">Keep octree boxes intersecting the boundary</property> + <property name="use_underline">True</property> + <property name="relief">GTK_RELIEF_NORMAL</property> + <property name="focus_on_click">True</property> + <property name="active">False</property> + <property name="inconsistent">False</property> + <property name="draw_indicator">True</property> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">False</property> + </packing> + </child> - <child> - <widget class="GtkCheckButton" id="checkbutton_checkForGluedMesh"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="label" translatable="yes">Remove invalid mesh connections</property> - <property name="use_underline">True</property> - <property name="relief">GTK_RELIEF_NORMAL</property> - <property name="focus_on_click">True</property> - <property name="active">False</property> - <property name="inconsistent">False</property> - <property name="draw_indicator">True</property> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">False</property> - </packing> - </child> - </widget> + <child> + <widget class="GtkCheckButton" id="checkbutton_checkForGluedMesh"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="label" translatable="yes">Remove invalid mesh connections</property> + <property name="use_underline">True</property> + <property name="relief">GTK_RELIEF_NORMAL</property> + <property name="focus_on_click">True</property> + <property name="active">False</property> + <property name="inconsistent">False</property> + <property name="draw_indicator">True</property> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">False</property> + </packing> + </child> + </widget> </child> </widget> </child> diff --git a/GUI/GTK/keepCellsIntersectingPatches/keepcellsintersectingpatches.glade b/GUI/GTK/keepCellsIntersectingPatches/keepcellsintersectingpatches.glade index 34abf26a..bbc0eb12 100644 --- a/GUI/GTK/keepCellsIntersectingPatches/keepcellsintersectingpatches.glade +++ b/GUI/GTK/keepCellsIntersectingPatches/keepcellsintersectingpatches.glade @@ -29,254 +29,254 @@ <property name="column_spacing">0</property> <child> - <widget class="GtkLabel" id="label_keepCellsIntersectingPatches_availablePatches"> - <property name="visible">True</property> - <property name="label" translatable="yes">Available patches</property> - <property name="use_underline">False</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> - <property name="width_chars">-1</property> - <property name="single_line_mode">False</property> - <property name="angle">0</property> - </widget> - <packing> - <property name="left_attach">0</property> - <property name="right_attach">1</property> - <property name="top_attach">0</property> - <property name="bottom_attach">1</property> - <property name="x_options">fill</property> - <property name="y_options"></property> - </packing> + <widget class="GtkLabel" id="label_keepCellsIntersectingPatches_availablePatches"> + <property name="visible">True</property> + <property name="label" translatable="yes">Available patches</property> + <property name="use_underline">False</property> + <property name="use_markup">False</property> + <property name="justify">GTK_JUSTIFY_LEFT</property> + <property name="wrap">False</property> + <property name="selectable">False</property> + <property name="xalign">0</property> + <property name="yalign">0.5</property> + <property name="xpad">0</property> + <property name="ypad">0</property> + <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> + <property name="width_chars">-1</property> + <property name="single_line_mode">False</property> + <property name="angle">0</property> + </widget> + <packing> + <property name="left_attach">0</property> + <property name="right_attach">1</property> + <property name="top_attach">0</property> + <property name="bottom_attach">1</property> + <property name="x_options">fill</property> + <property name="y_options"></property> + </packing> </child> <child> - <widget class="GtkComboBoxEntry" id="comboboxentry_keepCellsIntersectingPatches_availablePatches"> - <property name="visible">True</property> - <property name="add_tearoffs">False</property> - <property name="has_frame">True</property> - <property name="focus_on_click">True</property> - </widget> - <packing> - <property name="left_attach">1</property> - <property name="right_attach">2</property> - <property name="top_attach">0</property> - <property name="bottom_attach">1</property> - <property name="y_options">fill</property> - </packing> + <widget class="GtkComboBoxEntry" id="comboboxentry_keepCellsIntersectingPatches_availablePatches"> + <property name="visible">True</property> + <property name="add_tearoffs">False</property> + <property name="has_frame">True</property> + <property name="focus_on_click">True</property> + </widget> + <packing> + <property name="left_attach">1</property> + <property name="right_attach">2</property> + <property name="top_attach">0</property> + <property name="bottom_attach">1</property> + <property name="y_options">fill</property> + </packing> </child> <child> - <widget class="GtkButton" id="button1"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="relief">GTK_RELIEF_NORMAL</property> - <property name="focus_on_click">True</property> + <widget class="GtkButton" id="button1"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="relief">GTK_RELIEF_NORMAL</property> + <property name="focus_on_click">True</property> - <child> - <widget class="GtkAlignment" id="alignment1"> - <property name="visible">True</property> - <property name="xalign">0.5</property> - <property name="yalign">0.5</property> - <property name="xscale">0</property> - <property name="yscale">0</property> - <property name="top_padding">0</property> - <property name="bottom_padding">0</property> - <property name="left_padding">0</property> - <property name="right_padding">0</property> + <child> + <widget class="GtkAlignment" id="alignment1"> + <property name="visible">True</property> + <property name="xalign">0.5</property> + <property name="yalign">0.5</property> + <property name="xscale">0</property> + <property name="yscale">0</property> + <property name="top_padding">0</property> + <property name="bottom_padding">0</property> + <property name="left_padding">0</property> + <property name="right_padding">0</property> - <child> - <widget class="GtkHBox" id="hbox1"> - <property name="visible">True</property> - <property name="homogeneous">False</property> - <property name="spacing">2</property> + <child> + <widget class="GtkHBox" id="hbox1"> + <property name="visible">True</property> + <property name="homogeneous">False</property> + <property name="spacing">2</property> - <child> - <widget class="GtkImage" id="image1"> - <property name="visible">True</property> - <property name="stock">gtk-add</property> - <property name="icon_size">4</property> - <property name="xalign">0.5</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">False</property> - </packing> - </child> + <child> + <widget class="GtkImage" id="image1"> + <property name="visible">True</property> + <property name="stock">gtk-add</property> + <property name="icon_size">4</property> + <property name="xalign">0.5</property> + <property name="yalign">0.5</property> + <property name="xpad">0</property> + <property name="ypad">0</property> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">False</property> + </packing> + </child> - <child> - <widget class="GtkLabel" id="label3"> - <property name="visible">True</property> - <property name="label" translatable="yes">Add</property> - <property name="use_underline">True</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0.5</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> - <property name="width_chars">-1</property> - <property name="single_line_mode">False</property> - <property name="angle">0</property> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">False</property> - </packing> - </child> - </widget> - </child> - </widget> - </child> - </widget> - <packing> - <property name="left_attach">2</property> - <property name="right_attach">3</property> - <property name="top_attach">0</property> - <property name="bottom_attach">1</property> - <property name="x_options">fill</property> - <property name="y_options"></property> - </packing> + <child> + <widget class="GtkLabel" id="label3"> + <property name="visible">True</property> + <property name="label" translatable="yes">Add</property> + <property name="use_underline">True</property> + <property name="use_markup">False</property> + <property name="justify">GTK_JUSTIFY_LEFT</property> + <property name="wrap">False</property> + <property name="selectable">False</property> + <property name="xalign">0.5</property> + <property name="yalign">0.5</property> + <property name="xpad">0</property> + <property name="ypad">0</property> + <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> + <property name="width_chars">-1</property> + <property name="single_line_mode">False</property> + <property name="angle">0</property> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">False</property> + </packing> + </child> + </widget> + </child> + </widget> + </child> + </widget> + <packing> + <property name="left_attach">2</property> + <property name="right_attach">3</property> + <property name="top_attach">0</property> + <property name="bottom_attach">1</property> + <property name="x_options">fill</property> + <property name="y_options"></property> + </packing> </child> <child> - <widget class="GtkLabel" id="label_keepCellsIntersectingPatches_selectedPatches"> - <property name="visible">True</property> - <property name="label" translatable="yes">Selected patches</property> - <property name="use_underline">False</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> - <property name="width_chars">-1</property> - <property name="single_line_mode">False</property> - <property name="angle">0</property> - </widget> - <packing> - <property name="left_attach">0</property> - <property name="right_attach">1</property> - <property name="top_attach">1</property> - <property name="bottom_attach">2</property> - <property name="x_options">fill</property> - <property name="y_options"></property> - </packing> + <widget class="GtkLabel" id="label_keepCellsIntersectingPatches_selectedPatches"> + <property name="visible">True</property> + <property name="label" translatable="yes">Selected patches</property> + <property name="use_underline">False</property> + <property name="use_markup">False</property> + <property name="justify">GTK_JUSTIFY_LEFT</property> + <property name="wrap">False</property> + <property name="selectable">False</property> + <property name="xalign">0</property> + <property name="yalign">0.5</property> + <property name="xpad">0</property> + <property name="ypad">0</property> + <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> + <property name="width_chars">-1</property> + <property name="single_line_mode">False</property> + <property name="angle">0</property> + </widget> + <packing> + <property name="left_attach">0</property> + <property name="right_attach">1</property> + <property name="top_attach">1</property> + <property name="bottom_attach">2</property> + <property name="x_options">fill</property> + <property name="y_options"></property> + </packing> </child> <child> - <widget class="GtkComboBoxEntry" id="comboboxentry_keepCellsIntersectingPatches_selectedPatches"> - <property name="visible">True</property> - <property name="add_tearoffs">False</property> - <property name="has_frame">True</property> - <property name="focus_on_click">True</property> - </widget> - <packing> - <property name="left_attach">1</property> - <property name="right_attach">2</property> - <property name="top_attach">1</property> - <property name="bottom_attach">2</property> - <property name="x_options">fill</property> - <property name="y_options">fill</property> - </packing> + <widget class="GtkComboBoxEntry" id="comboboxentry_keepCellsIntersectingPatches_selectedPatches"> + <property name="visible">True</property> + <property name="add_tearoffs">False</property> + <property name="has_frame">True</property> + <property name="focus_on_click">True</property> + </widget> + <packing> + <property name="left_attach">1</property> + <property name="right_attach">2</property> + <property name="top_attach">1</property> + <property name="bottom_attach">2</property> + <property name="x_options">fill</property> + <property name="y_options">fill</property> + </packing> </child> <child> - <widget class="GtkButton" id="button2"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="relief">GTK_RELIEF_NORMAL</property> - <property name="focus_on_click">True</property> + <widget class="GtkButton" id="button2"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="relief">GTK_RELIEF_NORMAL</property> + <property name="focus_on_click">True</property> - <child> - <widget class="GtkAlignment" id="alignment2"> - <property name="visible">True</property> - <property name="xalign">0.5</property> - <property name="yalign">0.5</property> - <property name="xscale">0</property> - <property name="yscale">0</property> - <property name="top_padding">0</property> - <property name="bottom_padding">0</property> - <property name="left_padding">0</property> - <property name="right_padding">0</property> + <child> + <widget class="GtkAlignment" id="alignment2"> + <property name="visible">True</property> + <property name="xalign">0.5</property> + <property name="yalign">0.5</property> + <property name="xscale">0</property> + <property name="yscale">0</property> + <property name="top_padding">0</property> + <property name="bottom_padding">0</property> + <property name="left_padding">0</property> + <property name="right_padding">0</property> - <child> - <widget class="GtkHBox" id="hbox2"> - <property name="visible">True</property> - <property name="homogeneous">False</property> - <property name="spacing">2</property> + <child> + <widget class="GtkHBox" id="hbox2"> + <property name="visible">True</property> + <property name="homogeneous">False</property> + <property name="spacing">2</property> - <child> - <widget class="GtkImage" id="image2"> - <property name="visible">True</property> - <property name="stock">gtk-remove</property> - <property name="icon_size">4</property> - <property name="xalign">0.5</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">False</property> - </packing> - </child> + <child> + <widget class="GtkImage" id="image2"> + <property name="visible">True</property> + <property name="stock">gtk-remove</property> + <property name="icon_size">4</property> + <property name="xalign">0.5</property> + <property name="yalign">0.5</property> + <property name="xpad">0</property> + <property name="ypad">0</property> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">False</property> + </packing> + </child> - <child> - <widget class="GtkLabel" id="label5"> - <property name="visible">True</property> - <property name="label" translatable="yes">Remove</property> - <property name="use_underline">True</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0.5</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> - <property name="width_chars">-1</property> - <property name="single_line_mode">False</property> - <property name="angle">0</property> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">False</property> - </packing> - </child> - </widget> - </child> - </widget> - </child> - </widget> - <packing> - <property name="left_attach">2</property> - <property name="right_attach">3</property> - <property name="top_attach">1</property> - <property name="bottom_attach">2</property> - <property name="x_options">fill</property> - <property name="y_options"></property> - </packing> + <child> + <widget class="GtkLabel" id="label5"> + <property name="visible">True</property> + <property name="label" translatable="yes">Remove</property> + <property name="use_underline">True</property> + <property name="use_markup">False</property> + <property name="justify">GTK_JUSTIFY_LEFT</property> + <property name="wrap">False</property> + <property name="selectable">False</property> + <property name="xalign">0.5</property> + <property name="yalign">0.5</property> + <property name="xpad">0</property> + <property name="ypad">0</property> + <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> + <property name="width_chars">-1</property> + <property name="single_line_mode">False</property> + <property name="angle">0</property> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">False</property> + </packing> + </child> + </widget> + </child> + </widget> + </child> + </widget> + <packing> + <property name="left_attach">2</property> + <property name="right_attach">3</property> + <property name="top_attach">1</property> + <property name="bottom_attach">2</property> + <property name="x_options">fill</property> + <property name="y_options"></property> + </packing> </child> </widget> </child> diff --git a/GUI/GTK/localRefinement/localrefinement.glade b/GUI/GTK/localRefinement/localrefinement.glade index 66c70ddb..7a7556c2 100644 --- a/GUI/GTK/localRefinement/localrefinement.glade +++ b/GUI/GTK/localRefinement/localrefinement.glade @@ -33,343 +33,343 @@ <property name="right_padding">0</property> <child> - <widget class="GtkVBox" id="vbox1"> - <property name="visible">True</property> - <property name="homogeneous">False</property> - <property name="spacing">0</property> - - <child> - <widget class="GtkHBox" id="hbox1"> - <property name="visible">True</property> - <property name="homogeneous">False</property> - <property name="spacing">0</property> - - <child> - <widget class="GtkLabel" id="label_localRefinement_availablePatches"> - <property name="visible">True</property> - <property name="label" translatable="yes">Available patches</property> - <property name="use_underline">False</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0.5</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> - <property name="width_chars">-1</property> - <property name="single_line_mode">False</property> - <property name="angle">0</property> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">False</property> - </packing> - </child> - - <child> - <widget class="GtkComboBoxEntry" id="comboboxentry_localRefinement_availablePatches"> - <property name="visible">True</property> - <property name="add_tearoffs">False</property> - <property name="has_frame">True</property> - <property name="focus_on_click">True</property> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">True</property> - <property name="fill">True</property> - </packing> - </child> - - <child> - <widget class="GtkButton" id="button_localRefinement_add"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="relief">GTK_RELIEF_NORMAL</property> - <property name="focus_on_click">True</property> - - <child> - <widget class="GtkAlignment" id="alignment1"> - <property name="visible">True</property> - <property name="xalign">0.5</property> - <property name="yalign">0.5</property> - <property name="xscale">0</property> - <property name="yscale">0</property> - <property name="top_padding">0</property> - <property name="bottom_padding">0</property> - <property name="left_padding">0</property> - <property name="right_padding">0</property> - - <child> - <widget class="GtkHBox" id="hbox3"> - <property name="visible">True</property> - <property name="homogeneous">False</property> - <property name="spacing">2</property> - - <child> - <widget class="GtkImage" id="image1"> - <property name="visible">True</property> - <property name="stock">gtk-add</property> - <property name="icon_size">4</property> - <property name="xalign">0.5</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">False</property> - </packing> - </child> - - <child> - <widget class="GtkLabel" id="label2"> - <property name="visible">True</property> - <property name="label" translatable="yes">Add</property> - <property name="use_underline">True</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0.5</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> - <property name="width_chars">-1</property> - <property name="single_line_mode">False</property> - <property name="angle">0</property> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">False</property> - </packing> - </child> - </widget> - </child> - </widget> - </child> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">False</property> - </packing> - </child> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">True</property> - <property name="fill">True</property> - </packing> - </child> - - <child> - <widget class="GtkAlignment" id="alignment4"> - <property name="visible">True</property> - <property name="xalign">0.5</property> - <property name="yalign">0.5</property> - <property name="xscale">1</property> - <property name="yscale">1</property> - <property name="top_padding">10</property> - <property name="bottom_padding">0</property> - <property name="left_padding">0</property> - <property name="right_padding">0</property> - - <child> - <widget class="GtkHBox" id="hbox4"> - <property name="visible">True</property> - <property name="homogeneous">False</property> - <property name="spacing">0</property> - - <child> - <widget class="GtkVBox" id="vbox2"> - <property name="visible">True</property> - <property name="homogeneous">False</property> - <property name="spacing">0</property> - - <child> - <widget class="GtkLabel" id="label_localRefinement_selectedPatches"> - <property name="visible">True</property> - <property name="label" translatable="yes">Selected patches</property> - <property name="use_underline">False</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0.5</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> - <property name="width_chars">-1</property> - <property name="single_line_mode">False</property> - <property name="angle">0</property> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">False</property> - </packing> - </child> - - <child> - <placeholder/> - </child> - - <child> - <placeholder/> - </child> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">True</property> - <property name="fill">True</property> - </packing> - </child> - - <child> - <widget class="GtkScrolledWindow" id="scrolledwindow2"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="hscrollbar_policy">GTK_POLICY_ALWAYS</property> - <property name="vscrollbar_policy">GTK_POLICY_ALWAYS</property> - <property name="shadow_type">GTK_SHADOW_IN</property> - <property name="window_placement">GTK_CORNER_TOP_LEFT</property> - - <child> - <widget class="GtkTreeView" id="treeview3"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="headers_visible">True</property> - <property name="rules_hint">False</property> - <property name="reorderable">False</property> - <property name="enable_search">True</property> - <property name="fixed_height_mode">False</property> - <property name="hover_selection">False</property> - <property name="hover_expand">False</property> - </widget> - </child> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">True</property> - <property name="fill">True</property> - </packing> - </child> - - <child> - <widget class="GtkVBox" id="vbox3"> - <property name="visible">True</property> - <property name="homogeneous">False</property> - <property name="spacing">0</property> - - <child> - <widget class="GtkButton" id="button_localRefinement_remove"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="relief">GTK_RELIEF_NORMAL</property> - <property name="focus_on_click">True</property> - - <child> - <widget class="GtkAlignment" id="alignment5"> - <property name="visible">True</property> - <property name="xalign">0.5</property> - <property name="yalign">0.5</property> - <property name="xscale">0</property> - <property name="yscale">0</property> - <property name="top_padding">0</property> - <property name="bottom_padding">0</property> - <property name="left_padding">0</property> - <property name="right_padding">0</property> - - <child> - <widget class="GtkHBox" id="hbox5"> - <property name="visible">True</property> - <property name="homogeneous">False</property> - <property name="spacing">2</property> - - <child> - <widget class="GtkImage" id="image2"> - <property name="visible">True</property> - <property name="stock">gtk-remove</property> - <property name="icon_size">4</property> - <property name="xalign">0.5</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">False</property> - </packing> - </child> - - <child> - <widget class="GtkLabel" id="label5"> - <property name="visible">True</property> - <property name="label" translatable="yes">Remove</property> - <property name="use_underline">True</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0.5</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> - <property name="width_chars">-1</property> - <property name="single_line_mode">False</property> - <property name="angle">0</property> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">False</property> - </packing> - </child> - </widget> - </child> - </widget> - </child> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">False</property> - </packing> - </child> - - <child> - <placeholder/> - </child> - - <child> - <placeholder/> - </child> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">True</property> - <property name="fill">True</property> - </packing> - </child> - </widget> - </child> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">True</property> - <property name="fill">True</property> - </packing> - </child> - </widget> + <widget class="GtkVBox" id="vbox1"> + <property name="visible">True</property> + <property name="homogeneous">False</property> + <property name="spacing">0</property> + + <child> + <widget class="GtkHBox" id="hbox1"> + <property name="visible">True</property> + <property name="homogeneous">False</property> + <property name="spacing">0</property> + + <child> + <widget class="GtkLabel" id="label_localRefinement_availablePatches"> + <property name="visible">True</property> + <property name="label" translatable="yes">Available patches</property> + <property name="use_underline">False</property> + <property name="use_markup">False</property> + <property name="justify">GTK_JUSTIFY_LEFT</property> + <property name="wrap">False</property> + <property name="selectable">False</property> + <property name="xalign">0.5</property> + <property name="yalign">0.5</property> + <property name="xpad">0</property> + <property name="ypad">0</property> + <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> + <property name="width_chars">-1</property> + <property name="single_line_mode">False</property> + <property name="angle">0</property> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">False</property> + </packing> + </child> + + <child> + <widget class="GtkComboBoxEntry" id="comboboxentry_localRefinement_availablePatches"> + <property name="visible">True</property> + <property name="add_tearoffs">False</property> + <property name="has_frame">True</property> + <property name="focus_on_click">True</property> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">True</property> + <property name="fill">True</property> + </packing> + </child> + + <child> + <widget class="GtkButton" id="button_localRefinement_add"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="relief">GTK_RELIEF_NORMAL</property> + <property name="focus_on_click">True</property> + + <child> + <widget class="GtkAlignment" id="alignment1"> + <property name="visible">True</property> + <property name="xalign">0.5</property> + <property name="yalign">0.5</property> + <property name="xscale">0</property> + <property name="yscale">0</property> + <property name="top_padding">0</property> + <property name="bottom_padding">0</property> + <property name="left_padding">0</property> + <property name="right_padding">0</property> + + <child> + <widget class="GtkHBox" id="hbox3"> + <property name="visible">True</property> + <property name="homogeneous">False</property> + <property name="spacing">2</property> + + <child> + <widget class="GtkImage" id="image1"> + <property name="visible">True</property> + <property name="stock">gtk-add</property> + <property name="icon_size">4</property> + <property name="xalign">0.5</property> + <property name="yalign">0.5</property> + <property name="xpad">0</property> + <property name="ypad">0</property> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">False</property> + </packing> + </child> + + <child> + <widget class="GtkLabel" id="label2"> + <property name="visible">True</property> + <property name="label" translatable="yes">Add</property> + <property name="use_underline">True</property> + <property name="use_markup">False</property> + <property name="justify">GTK_JUSTIFY_LEFT</property> + <property name="wrap">False</property> + <property name="selectable">False</property> + <property name="xalign">0.5</property> + <property name="yalign">0.5</property> + <property name="xpad">0</property> + <property name="ypad">0</property> + <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> + <property name="width_chars">-1</property> + <property name="single_line_mode">False</property> + <property name="angle">0</property> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">False</property> + </packing> + </child> + </widget> + </child> + </widget> + </child> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">False</property> + </packing> + </child> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">True</property> + <property name="fill">True</property> + </packing> + </child> + + <child> + <widget class="GtkAlignment" id="alignment4"> + <property name="visible">True</property> + <property name="xalign">0.5</property> + <property name="yalign">0.5</property> + <property name="xscale">1</property> + <property name="yscale">1</property> + <property name="top_padding">10</property> + <property name="bottom_padding">0</property> + <property name="left_padding">0</property> + <property name="right_padding">0</property> + + <child> + <widget class="GtkHBox" id="hbox4"> + <property name="visible">True</property> + <property name="homogeneous">False</property> + <property name="spacing">0</property> + + <child> + <widget class="GtkVBox" id="vbox2"> + <property name="visible">True</property> + <property name="homogeneous">False</property> + <property name="spacing">0</property> + + <child> + <widget class="GtkLabel" id="label_localRefinement_selectedPatches"> + <property name="visible">True</property> + <property name="label" translatable="yes">Selected patches</property> + <property name="use_underline">False</property> + <property name="use_markup">False</property> + <property name="justify">GTK_JUSTIFY_LEFT</property> + <property name="wrap">False</property> + <property name="selectable">False</property> + <property name="xalign">0.5</property> + <property name="yalign">0.5</property> + <property name="xpad">0</property> + <property name="ypad">0</property> + <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> + <property name="width_chars">-1</property> + <property name="single_line_mode">False</property> + <property name="angle">0</property> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">False</property> + </packing> + </child> + + <child> + <placeholder/> + </child> + + <child> + <placeholder/> + </child> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">True</property> + <property name="fill">True</property> + </packing> + </child> + + <child> + <widget class="GtkScrolledWindow" id="scrolledwindow2"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="hscrollbar_policy">GTK_POLICY_ALWAYS</property> + <property name="vscrollbar_policy">GTK_POLICY_ALWAYS</property> + <property name="shadow_type">GTK_SHADOW_IN</property> + <property name="window_placement">GTK_CORNER_TOP_LEFT</property> + + <child> + <widget class="GtkTreeView" id="treeview3"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="headers_visible">True</property> + <property name="rules_hint">False</property> + <property name="reorderable">False</property> + <property name="enable_search">True</property> + <property name="fixed_height_mode">False</property> + <property name="hover_selection">False</property> + <property name="hover_expand">False</property> + </widget> + </child> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">True</property> + <property name="fill">True</property> + </packing> + </child> + + <child> + <widget class="GtkVBox" id="vbox3"> + <property name="visible">True</property> + <property name="homogeneous">False</property> + <property name="spacing">0</property> + + <child> + <widget class="GtkButton" id="button_localRefinement_remove"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="relief">GTK_RELIEF_NORMAL</property> + <property name="focus_on_click">True</property> + + <child> + <widget class="GtkAlignment" id="alignment5"> + <property name="visible">True</property> + <property name="xalign">0.5</property> + <property name="yalign">0.5</property> + <property name="xscale">0</property> + <property name="yscale">0</property> + <property name="top_padding">0</property> + <property name="bottom_padding">0</property> + <property name="left_padding">0</property> + <property name="right_padding">0</property> + + <child> + <widget class="GtkHBox" id="hbox5"> + <property name="visible">True</property> + <property name="homogeneous">False</property> + <property name="spacing">2</property> + + <child> + <widget class="GtkImage" id="image2"> + <property name="visible">True</property> + <property name="stock">gtk-remove</property> + <property name="icon_size">4</property> + <property name="xalign">0.5</property> + <property name="yalign">0.5</property> + <property name="xpad">0</property> + <property name="ypad">0</property> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">False</property> + </packing> + </child> + + <child> + <widget class="GtkLabel" id="label5"> + <property name="visible">True</property> + <property name="label" translatable="yes">Remove</property> + <property name="use_underline">True</property> + <property name="use_markup">False</property> + <property name="justify">GTK_JUSTIFY_LEFT</property> + <property name="wrap">False</property> + <property name="selectable">False</property> + <property name="xalign">0.5</property> + <property name="yalign">0.5</property> + <property name="xpad">0</property> + <property name="ypad">0</property> + <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> + <property name="width_chars">-1</property> + <property name="single_line_mode">False</property> + <property name="angle">0</property> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">False</property> + </packing> + </child> + </widget> + </child> + </widget> + </child> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">False</property> + </packing> + </child> + + <child> + <placeholder/> + </child> + + <child> + <placeholder/> + </child> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">True</property> + <property name="fill">True</property> + </packing> + </child> + </widget> + </child> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">True</property> + <property name="fill">True</property> + </packing> + </child> + </widget> </child> </widget> </child> @@ -401,108 +401,108 @@ <property name="column_spacing">0</property> <child> - <widget class="GtkLabel" id="label6"> - <property name="visible">True</property> - <property name="label" translatable="yes">Selected patch</property> - <property name="use_underline">False</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> - <property name="width_chars">-1</property> - <property name="single_line_mode">False</property> - <property name="angle">0</property> - </widget> - <packing> - <property name="left_attach">0</property> - <property name="right_attach">1</property> - <property name="top_attach">0</property> - <property name="bottom_attach">1</property> - <property name="x_options">fill</property> - <property name="y_options"></property> - </packing> + <widget class="GtkLabel" id="label6"> + <property name="visible">True</property> + <property name="label" translatable="yes">Selected patch</property> + <property name="use_underline">False</property> + <property name="use_markup">False</property> + <property name="justify">GTK_JUSTIFY_LEFT</property> + <property name="wrap">False</property> + <property name="selectable">False</property> + <property name="xalign">0</property> + <property name="yalign">0.5</property> + <property name="xpad">0</property> + <property name="ypad">0</property> + <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> + <property name="width_chars">-1</property> + <property name="single_line_mode">False</property> + <property name="angle">0</property> + </widget> + <packing> + <property name="left_attach">0</property> + <property name="right_attach">1</property> + <property name="top_attach">0</property> + <property name="bottom_attach">1</property> + <property name="x_options">fill</property> + <property name="y_options"></property> + </packing> </child> <child> - <widget class="GtkLabel" id="label_localRefinement_cellSize"> - <property name="visible">True</property> - <property name="label" translatable="yes">Cell size [m]</property> - <property name="use_underline">False</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> - <property name="width_chars">-1</property> - <property name="single_line_mode">False</property> - <property name="angle">0</property> - </widget> - <packing> - <property name="left_attach">0</property> - <property name="right_attach">1</property> - <property name="top_attach">1</property> - <property name="bottom_attach">2</property> - <property name="x_options">fill</property> - <property name="y_options"></property> - </packing> + <widget class="GtkLabel" id="label_localRefinement_cellSize"> + <property name="visible">True</property> + <property name="label" translatable="yes">Cell size [m]</property> + <property name="use_underline">False</property> + <property name="use_markup">False</property> + <property name="justify">GTK_JUSTIFY_LEFT</property> + <property name="wrap">False</property> + <property name="selectable">False</property> + <property name="xalign">0</property> + <property name="yalign">0.5</property> + <property name="xpad">0</property> + <property name="ypad">0</property> + <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> + <property name="width_chars">-1</property> + <property name="single_line_mode">False</property> + <property name="angle">0</property> + </widget> + <packing> + <property name="left_attach">0</property> + <property name="right_attach">1</property> + <property name="top_attach">1</property> + <property name="bottom_attach">2</property> + <property name="x_options">fill</property> + <property name="y_options"></property> + </packing> </child> <child> - <widget class="GtkEntry" id="entry_localRefinement_cellSize"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="editable">True</property> - <property name="visibility">True</property> - <property name="max_length">0</property> - <property name="text" translatable="yes"></property> - <property name="has_frame">True</property> - <property name="invisible_char">●</property> - <property name="activates_default">False</property> - </widget> - <packing> - <property name="left_attach">1</property> - <property name="right_attach">2</property> - <property name="top_attach">1</property> - <property name="bottom_attach">2</property> - <property name="y_options"></property> - </packing> + <widget class="GtkEntry" id="entry_localRefinement_cellSize"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="editable">True</property> + <property name="visibility">True</property> + <property name="max_length">0</property> + <property name="text" translatable="yes"></property> + <property name="has_frame">True</property> + <property name="invisible_char">●</property> + <property name="activates_default">False</property> + </widget> + <packing> + <property name="left_attach">1</property> + <property name="right_attach">2</property> + <property name="top_attach">1</property> + <property name="bottom_attach">2</property> + <property name="y_options"></property> + </packing> </child> <child> - <widget class="GtkLabel" id="label_localRefinement_selected"> - <property name="visible">True</property> - <property name="label" translatable="yes"></property> - <property name="use_underline">False</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> - <property name="width_chars">-1</property> - <property name="single_line_mode">False</property> - <property name="angle">0</property> - </widget> - <packing> - <property name="left_attach">1</property> - <property name="right_attach">2</property> - <property name="top_attach">0</property> - <property name="bottom_attach">1</property> - <property name="x_options">fill</property> - <property name="y_options"></property> - </packing> + <widget class="GtkLabel" id="label_localRefinement_selected"> + <property name="visible">True</property> + <property name="label" translatable="yes"></property> + <property name="use_underline">False</property> + <property name="use_markup">False</property> + <property name="justify">GTK_JUSTIFY_LEFT</property> + <property name="wrap">False</property> + <property name="selectable">False</property> + <property name="xalign">0</property> + <property name="yalign">0.5</property> + <property name="xpad">0</property> + <property name="ypad">0</property> + <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> + <property name="width_chars">-1</property> + <property name="single_line_mode">False</property> + <property name="angle">0</property> + </widget> + <packing> + <property name="left_attach">1</property> + <property name="right_attach">2</property> + <property name="top_attach">0</property> + <property name="bottom_attach">1</property> + <property name="x_options">fill</property> + <property name="y_options"></property> + </packing> </child> </widget> </child> diff --git a/GUI/GTK/localSettingsMainWindow/localsettingsmainwindow.glade b/GUI/GTK/localSettingsMainWindow/localsettingsmainwindow.glade index 8178135b..f46f4939 100644 --- a/GUI/GTK/localSettingsMainWindow/localsettingsmainwindow.glade +++ b/GUI/GTK/localSettingsMainWindow/localsettingsmainwindow.glade @@ -30,57 +30,57 @@ <property name="enable_popup">False</property> <child> - <placeholder/> + <placeholder/> </child> <child> - <widget class="GtkLabel" id="label_localRefinement"> - <property name="visible">True</property> - <property name="label" translatable="yes">Local refinement</property> - <property name="use_underline">False</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0.5</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> - <property name="width_chars">-1</property> - <property name="single_line_mode">False</property> - <property name="angle">0</property> - </widget> - <packing> - <property name="type">tab</property> - </packing> + <widget class="GtkLabel" id="label_localRefinement"> + <property name="visible">True</property> + <property name="label" translatable="yes">Local refinement</property> + <property name="use_underline">False</property> + <property name="use_markup">False</property> + <property name="justify">GTK_JUSTIFY_LEFT</property> + <property name="wrap">False</property> + <property name="selectable">False</property> + <property name="xalign">0.5</property> + <property name="yalign">0.5</property> + <property name="xpad">0</property> + <property name="ypad">0</property> + <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> + <property name="width_chars">-1</property> + <property name="single_line_mode">False</property> + <property name="angle">0</property> + </widget> + <packing> + <property name="type">tab</property> + </packing> </child> <child> - <placeholder/> + <placeholder/> </child> <child> - <widget class="GtkLabel" id="label_keepBoxesIntersectingPatches"> - <property name="visible">True</property> - <property name="label" translatable="yes">Keep octree boxes intersecting patches</property> - <property name="use_underline">False</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0.5</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> - <property name="width_chars">-1</property> - <property name="single_line_mode">False</property> - <property name="angle">0</property> - </widget> - <packing> - <property name="type">tab</property> - </packing> + <widget class="GtkLabel" id="label_keepBoxesIntersectingPatches"> + <property name="visible">True</property> + <property name="label" translatable="yes">Keep octree boxes intersecting patches</property> + <property name="use_underline">False</property> + <property name="use_markup">False</property> + <property name="justify">GTK_JUSTIFY_LEFT</property> + <property name="wrap">False</property> + <property name="selectable">False</property> + <property name="xalign">0.5</property> + <property name="yalign">0.5</property> + <property name="xpad">0</property> + <property name="ypad">0</property> + <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> + <property name="width_chars">-1</property> + <property name="single_line_mode">False</property> + <property name="angle">0</property> + </widget> + <packing> + <property name="type">tab</property> + </packing> </child> </widget> </child> diff --git a/GUI/GTK/mainWindow/mainwindow.glade b/GUI/GTK/mainWindow/mainwindow.glade index 8600fad0..9a8b3bce 100644 --- a/GUI/GTK/mainWindow/mainwindow.glade +++ b/GUI/GTK/mainWindow/mainwindow.glade @@ -26,137 +26,137 @@ <property name="spacing">0</property> <child> - <widget class="GtkToolbar" id="toolbar1"> - <property name="visible">True</property> - <property name="orientation">GTK_ORIENTATION_HORIZONTAL</property> - <property name="toolbar_style">GTK_TOOLBAR_ICONS</property> - <property name="tooltips">True</property> - <property name="show_arrow">True</property> + <widget class="GtkToolbar" id="toolbar1"> + <property name="visible">True</property> + <property name="orientation">GTK_ORIENTATION_HORIZONTAL</property> + <property name="toolbar_style">GTK_TOOLBAR_ICONS</property> + <property name="tooltips">True</property> + <property name="show_arrow">True</property> - <child> - <widget class="GtkToolItem" id="toolitem1"> - <property name="visible">True</property> - <property name="visible_horizontal">True</property> - <property name="visible_vertical">True</property> - <property name="is_important">False</property> + <child> + <widget class="GtkToolItem" id="toolitem1"> + <property name="visible">True</property> + <property name="visible_horizontal">True</property> + <property name="visible_vertical">True</property> + <property name="is_important">False</property> - <child> - <widget class="GtkButton" id="button_mainWindow_save"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="label" translatable="yes">Save meshDict</property> - <property name="use_underline">True</property> - <property name="relief">GTK_RELIEF_NORMAL</property> - <property name="focus_on_click">True</property> - </widget> - </child> - </widget> - <packing> - <property name="expand">False</property> - <property name="homogeneous">False</property> - </packing> - </child> + <child> + <widget class="GtkButton" id="button_mainWindow_save"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="label" translatable="yes">Save meshDict</property> + <property name="use_underline">True</property> + <property name="relief">GTK_RELIEF_NORMAL</property> + <property name="focus_on_click">True</property> + </widget> + </child> + </widget> + <packing> + <property name="expand">False</property> + <property name="homogeneous">False</property> + </packing> + </child> - <child> - <widget class="GtkToolItem" id="toolitem2"> - <property name="visible">True</property> - <property name="visible_horizontal">True</property> - <property name="visible_vertical">True</property> - <property name="is_important">False</property> + <child> + <widget class="GtkToolItem" id="toolitem2"> + <property name="visible">True</property> + <property name="visible_horizontal">True</property> + <property name="visible_vertical">True</property> + <property name="is_important">False</property> - <child> - <widget class="GtkButton" id="button_mainWindow_exit"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="label" translatable="yes">Exit</property> - <property name="use_underline">True</property> - <property name="relief">GTK_RELIEF_NORMAL</property> - <property name="focus_on_click">True</property> - </widget> - </child> - </widget> - <packing> - <property name="expand">False</property> - <property name="homogeneous">False</property> - </packing> - </child> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">False</property> - </packing> + <child> + <widget class="GtkButton" id="button_mainWindow_exit"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="label" translatable="yes">Exit</property> + <property name="use_underline">True</property> + <property name="relief">GTK_RELIEF_NORMAL</property> + <property name="focus_on_click">True</property> + </widget> + </child> + </widget> + <packing> + <property name="expand">False</property> + <property name="homogeneous">False</property> + </packing> + </child> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">False</property> + </packing> </child> <child> - <widget class="GtkNotebook" id="notebook1"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="show_tabs">True</property> - <property name="show_border">True</property> - <property name="tab_pos">GTK_POS_TOP</property> - <property name="scrollable">False</property> - <property name="enable_popup">False</property> + <widget class="GtkNotebook" id="notebook1"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="show_tabs">True</property> + <property name="show_border">True</property> + <property name="tab_pos">GTK_POS_TOP</property> + <property name="scrollable">False</property> + <property name="enable_popup">False</property> - <child> - <placeholder/> - </child> + <child> + <placeholder/> + </child> - <child> - <widget class="GtkLabel" id="label_generalSettings"> - <property name="visible">True</property> - <property name="label" translatable="yes">General settings</property> - <property name="use_underline">False</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0.5</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> - <property name="width_chars">-1</property> - <property name="single_line_mode">False</property> - <property name="angle">0</property> - </widget> - <packing> - <property name="type">tab</property> - </packing> - </child> + <child> + <widget class="GtkLabel" id="label_generalSettings"> + <property name="visible">True</property> + <property name="label" translatable="yes">General settings</property> + <property name="use_underline">False</property> + <property name="use_markup">False</property> + <property name="justify">GTK_JUSTIFY_LEFT</property> + <property name="wrap">False</property> + <property name="selectable">False</property> + <property name="xalign">0.5</property> + <property name="yalign">0.5</property> + <property name="xpad">0</property> + <property name="ypad">0</property> + <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> + <property name="width_chars">-1</property> + <property name="single_line_mode">False</property> + <property name="angle">0</property> + </widget> + <packing> + <property name="type">tab</property> + </packing> + </child> - <child> - <placeholder/> - </child> + <child> + <placeholder/> + </child> - <child> - <widget class="GtkLabel" id="label_localSettings"> - <property name="visible">True</property> - <property name="label" translatable="yes">Local settings</property> - <property name="use_underline">False</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0.5</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> - <property name="width_chars">-1</property> - <property name="single_line_mode">False</property> - <property name="angle">0</property> - </widget> - <packing> - <property name="type">tab</property> - </packing> - </child> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">True</property> - <property name="fill">True</property> - </packing> + <child> + <widget class="GtkLabel" id="label_localSettings"> + <property name="visible">True</property> + <property name="label" translatable="yes">Local settings</property> + <property name="use_underline">False</property> + <property name="use_markup">False</property> + <property name="justify">GTK_JUSTIFY_LEFT</property> + <property name="wrap">False</property> + <property name="selectable">False</property> + <property name="xalign">0.5</property> + <property name="yalign">0.5</property> + <property name="xpad">0</property> + <property name="ypad">0</property> + <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> + <property name="width_chars">-1</property> + <property name="single_line_mode">False</property> + <property name="angle">0</property> + </widget> + <packing> + <property name="type">tab</property> + </packing> + </child> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">True</property> + <property name="fill">True</property> + </packing> </child> </widget> </child> diff --git a/GUI/Make/options b/GUI/Make/options index d053162e..bb7c4a81 100644 --- a/GUI/Make/options +++ b/GUI/Make/options @@ -1,34 +1,34 @@ EXE_INC = \ - -g -ggdb -DFULLDEBUG -O0 -Wno-old-style-cast \ + -g -ggdb -DFULLDEBUG -O0 -Wno-old-style-cast \ -I$(FOAM_USER_LIB)/meshGeneration/meshLibrary/lnInclude \ - -I$(FOAM_USER_LIB)/meshGeneration/GUI/lnInclude \ - -I$(FOAM_SRC)/triSurface/lnInclude \ - -I/usr/include/cairo \ - -I/usr/include/freetype2 \ - -I/usr/include/libpng12 \ - -I/opt/gnome/include/gtk-2.0 \ - -I/opt/gnome/lib64/gtk-2.0/include \ - -I/opt/gnome/include/atk-1.0 \ - -I/opt/gnome/include/pango-1.0 \ - -I/opt/gnome/include/glib-2.0 \ - -I/opt/gnome/lib64/glib-2.0/include \ - -I$(QTDIR)/include -I$(QTDIR)/include/QtCore -I$(QTDIR)/include/QtGui \ - -I$(QTDIR)/include/QtOpenGL - + -I$(FOAM_USER_LIB)/meshGeneration/GUI/lnInclude \ + -I$(FOAM_SRC)/triSurface/lnInclude \ + -I/usr/include/cairo \ + -I/usr/include/freetype2 \ + -I/usr/include/libpng12 \ + -I/opt/gnome/include/gtk-2.0 \ + -I/opt/gnome/lib64/gtk-2.0/include \ + -I/opt/gnome/include/atk-1.0 \ + -I/opt/gnome/include/pango-1.0 \ + -I/opt/gnome/include/glib-2.0 \ + -I/opt/gnome/lib64/glib-2.0/include \ + -I$(QTDIR)/include -I$(QTDIR)/include/QtCore -I$(QTDIR)/include/QtGui \ + -I$(QTDIR)/include/QtOpenGL + MOC = $(QTDIR)/bin/moc EXE_LIBS = \ -lMeshLibrary \ - -ltriSurface \ - -L/opt/gnome/lib64 \ - -lgtk-x11-2.0 \ - -lgdk-x11-2.0 \ - -latk-1.0 \ - -lgdk_pixbuf-2.0 \ - -lpangocairo-1.0 \ - -lpango-1.0 -lcairo -lgobject-2.0 -lgmodule-2.0 -ldl \ - -lglib-2.0 -lfreetype -lz -lfontconfig -lexpat -lglitz \ - -lm -lpng12 -lXrender -lX11 -lpthread -lXau -lXdmcp \ - -L/usr/local/lib -L/usr/X11R6/lib \ - -L$(QTDIR)/lib \ - -lGL -lGLU -lqt-mt + -ltriSurface \ + -L/opt/gnome/lib64 \ + -lgtk-x11-2.0 \ + -lgdk-x11-2.0 \ + -latk-1.0 \ + -lgdk_pixbuf-2.0 \ + -lpangocairo-1.0 \ + -lpango-1.0 -lcairo -lgobject-2.0 -lgmodule-2.0 -ldl \ + -lglib-2.0 -lfreetype -lz -lfontconfig -lexpat -lglitz \ + -lm -lpng12 -lXrender -lX11 -lpthread -lXau -lXdmcp \ + -L/usr/local/lib -L/usr/X11R6/lib \ + -L$(QTDIR)/lib \ + -lGL -lGLU -lqt-mt diff --git a/GUI/meshGenGTK/helpers/gtkHelpers.C b/GUI/meshGenGTK/helpers/gtkHelpers.C index 0f76f15e..aefd879a 100644 --- a/GUI/meshGenGTK/helpers/gtkHelpers.C +++ b/GUI/meshGenGTK/helpers/gtkHelpers.C @@ -20,44 +20,44 @@ GtkWidget* lookup_widget ( - GtkWidget* widget, - const gchar* widget_name + GtkWidget* widget, + const gchar* widget_name ) { - GtkWidget *parent, *found_widget; + GtkWidget *parent, *found_widget; - for(;;) + for(;;) { - if( GTK_IS_MENU(widget) ) - { - parent = gtk_menu_get_attach_widget(GTK_MENU(widget)); - std::cout << "Here!" << std::endl; - } - else - { - parent = widget->parent; - std::cout << "Parent " << parent << std::endl; - } - if( !parent ) - { - parent = - (GtkWidget*)g_object_get_data - ( - G_OBJECT(widget), - "GladeParentKey" - ); - } - - if( parent == NULL ) - break; - widget = parent; + if( GTK_IS_MENU(widget) ) + { + parent = gtk_menu_get_attach_widget(GTK_MENU(widget)); + std::cout << "Here!" << std::endl; + } + else + { + parent = widget->parent; + std::cout << "Parent " << parent << std::endl; + } + if( !parent ) + { + parent = + (GtkWidget*)g_object_get_data + ( + G_OBJECT(widget), + "GladeParentKey" + ); + } + + if( parent == NULL ) + break; + widget = parent; } - std::cout << "Start " << widget << std::endl; - found_widget = (GtkWidget*)g_object_get_data(G_OBJECT(widget), widget_name); - - if( !found_widget ) - g_warning("Widget not found: %s", widget_name); + std::cout << "Start " << widget << std::endl; + found_widget = (GtkWidget*)g_object_get_data(G_OBJECT(widget), widget_name); + + if( !found_widget ) + g_warning("Widget not found: %s", widget_name); return found_widget; } diff --git a/GUI/meshGenGTK/meshGenGTK.C b/GUI/meshGenGTK/meshGenGTK.C index 1ca337a5..4cdb06c1 100644 --- a/GUI/meshGenGTK/meshGenGTK.C +++ b/GUI/meshGenGTK/meshGenGTK.C @@ -43,38 +43,38 @@ meshGenGTK::meshGenGTK label argc, char* argv[], const objectRegistry& reg ) : - meshGui_(reg), - generalPageFramePtr_(NULL), - mainWindowPtr_(NULL), - localRefinementFramePtr_(NULL), - keepCellsIntersectingPatchesFramePtr_(NULL), - bndLayersFramePtr_(NULL), - localSettingsMainFramePtr_(NULL), - - boxRefinementFramePtr_(NULL), - lineRefinementFramePtr_(NULL), - coneRefinementFramePtr_(NULL), - sphereRefinementFramePtr_(NULL), - objectRefinementMainFramePtr_(NULL), - - renameBoundaryFramePtr_(NULL) + meshGui_(reg), + generalPageFramePtr_(NULL), + mainWindowPtr_(NULL), + localRefinementFramePtr_(NULL), + keepCellsIntersectingPatchesFramePtr_(NULL), + bndLayersFramePtr_(NULL), + localSettingsMainFramePtr_(NULL), + + boxRefinementFramePtr_(NULL), + lineRefinementFramePtr_(NULL), + coneRefinementFramePtr_(NULL), + sphereRefinementFramePtr_(NULL), + objectRefinementMainFramePtr_(NULL), + + renameBoundaryFramePtr_(NULL) { - gtk_init(&argc, &argv); - - createLocalSettingsMainWindowPage(); - createGeneralPage(); - createObjectRefinementMainWindowPage(); - createRenameBoundaryMainWindowPage(); - createMainWindowPage(); - - gtk_main(); + gtk_init(&argc, &argv); + + createLocalSettingsMainWindowPage(); + createGeneralPage(); + createObjectRefinementMainWindowPage(); + createRenameBoundaryMainWindowPage(); + createMainWindowPage(); + + gtk_main(); } // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // meshGenGTK::~meshGenGTK() { - meshGui_.writeDict(); + meshGui_.writeDict(); gtk_main_quit(); } diff --git a/GUI/meshGenGTK/meshGenGTK.H b/GUI/meshGenGTK/meshGenGTK.H index 505108f7..c5340fc0 100644 --- a/GUI/meshGenGTK/meshGenGTK.H +++ b/GUI/meshGenGTK/meshGenGTK.H @@ -47,7 +47,7 @@ namespace Foam //- Forward declarations class triSurface; - + static meshGenGUI* guiPtr(NULL); /*---------------------------------------------------------------------------*\ @@ -56,49 +56,49 @@ static meshGenGUI* guiPtr(NULL); class meshGenGTK { - // Private data - - //- mesh generation dictionary - meshGenGUI meshGui_; + // Private data + + //- mesh generation dictionary + meshGenGUI meshGui_; - //- pages - GtkWidget* generalPageFramePtr_; - GtkWidget* mainWindowPtr_; - GtkWidget* localRefinementFramePtr_; - GtkWidget* keepCellsIntersectingPatchesFramePtr_; - GtkWidget* bndLayersFramePtr_; - GtkWidget* localSettingsMainFramePtr_; - - GtkWidget* boxRefinementFramePtr_; - GtkWidget* lineRefinementFramePtr_; - GtkWidget* coneRefinementFramePtr_; - GtkWidget* sphereRefinementFramePtr_; - GtkWidget* objectRefinementMainFramePtr_; - - GtkWidget* renameBoundaryFramePtr_; + //- pages + GtkWidget* generalPageFramePtr_; + GtkWidget* mainWindowPtr_; + GtkWidget* localRefinementFramePtr_; + GtkWidget* keepCellsIntersectingPatchesFramePtr_; + GtkWidget* bndLayersFramePtr_; + GtkWidget* localSettingsMainFramePtr_; + + GtkWidget* boxRefinementFramePtr_; + GtkWidget* lineRefinementFramePtr_; + GtkWidget* coneRefinementFramePtr_; + GtkWidget* sphereRefinementFramePtr_; + GtkWidget* objectRefinementMainFramePtr_; + + GtkWidget* renameBoundaryFramePtr_; private: - - // Private member functions - //- create pages - void createGeneralPage(); - void createMainWindowPage(); - - //- pages for local features - void createLocalRefinementWindowPage(); - void createKeepCellsIntersectingPatchesWindowPage(); - void createBndLayersWindowPage(); - void createLocalSettingsMainWindowPage(); - - //- pages for object refinement - void createBoxRefinementWindowPage(); - void createLineRefinementWindowPage(); - void createConeRefinementWindowPage(); - void createSphereRefinementWindowPage(); - void createObjectRefinementMainWindowPage(); - - //- pages for boundary renaming - void createRenameBoundaryMainWindowPage(); + + // Private member functions + //- create pages + void createGeneralPage(); + void createMainWindowPage(); + + //- pages for local features + void createLocalRefinementWindowPage(); + void createKeepCellsIntersectingPatchesWindowPage(); + void createBndLayersWindowPage(); + void createLocalSettingsMainWindowPage(); + + //- pages for object refinement + void createBoxRefinementWindowPage(); + void createLineRefinementWindowPage(); + void createConeRefinementWindowPage(); + void createSphereRefinementWindowPage(); + void createObjectRefinementMainWindowPage(); + + //- pages for boundary renaming + void createRenameBoundaryMainWindowPage(); //- Disallow default bitwise copy construct meshGenGTK(const meshGenGTK&); diff --git a/GUI/meshGenGTK/meshGenGTKBndLayers.C b/GUI/meshGenGTK/meshGenGTKBndLayers.C index 44a383ea..9ca79f6c 100644 --- a/GUI/meshGenGTK/meshGenGTKBndLayers.C +++ b/GUI/meshGenGTK/meshGenGTKBndLayers.C @@ -37,381 +37,381 @@ namespace Foam // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // //- callback functions - + extern "C" { - + static void updateBndLayers(GtkWidget* bndLayersFramePtr) { - GtkWidget* comboboxentry_bndLayers_availablePatches = - (GtkWidget*)g_object_get_data - ( - G_OBJECT(bndLayersFramePtr), - "comboboxentry_bndLayers_availablePatches" - ); - GtkWidget* comboboxentry_bndLayers_selectedPatches = - (GtkWidget*)g_object_get_data - ( - G_OBJECT(bndLayersFramePtr), - "comboboxentry_bndLayers_selectedPatches" - ); - - //- update available patches - wordList alreadyUsed = guiPtr->keepBndLayersPatches(); - wordHashSet usedNames; - forAll(alreadyUsed, nameI) - usedNames.insert(alreadyUsed[nameI]); - - GList* avPatches = 0; - label nAvailable(0); - const triSurface& surf = guiPtr->surface(); - forAll(surf.patches(), patchI) - { - if( usedNames.found(surf.patches()[patchI].name()) ) - continue; - const char* name = surf.patches()[patchI].name().c_str(); - avPatches = g_list_append(avPatches, const_cast<char*>(name)); - ++nAvailable; - } - - gtk_combo_set_popdown_strings - ( - GTK_COMBO - ( - comboboxentry_bndLayers_availablePatches - ), avPatches - ); - - if( nAvailable == 0 ) - { - gtk_entry_set_text - ( - GTK_ENTRY - ( - GTK_COMBO - ( - comboboxentry_bndLayers_availablePatches - )->entry - ), "" - ); - } - - //- update used patches - GList* selPatches = 0; - forAll(alreadyUsed, patchI) - { - const char* name = alreadyUsed[patchI].c_str(); - selPatches = g_list_append(selPatches, const_cast<char*>(name)); - } - - gtk_combo_set_popdown_strings - ( - GTK_COMBO - ( - comboboxentry_bndLayers_selectedPatches - ), selPatches - ); - - if( alreadyUsed.size() == 0 ) - { - gtk_entry_set_text - ( - GTK_ENTRY - ( - GTK_COMBO - ( - comboboxentry_bndLayers_selectedPatches - )->entry - ), "" - ); - } - - g_list_free(avPatches); - g_list_free(selPatches); + GtkWidget* comboboxentry_bndLayers_availablePatches = + (GtkWidget*)g_object_get_data + ( + G_OBJECT(bndLayersFramePtr), + "comboboxentry_bndLayers_availablePatches" + ); + GtkWidget* comboboxentry_bndLayers_selectedPatches = + (GtkWidget*)g_object_get_data + ( + G_OBJECT(bndLayersFramePtr), + "comboboxentry_bndLayers_selectedPatches" + ); + + //- update available patches + wordList alreadyUsed = guiPtr->keepBndLayersPatches(); + wordHashSet usedNames; + forAll(alreadyUsed, nameI) + usedNames.insert(alreadyUsed[nameI]); + + GList* avPatches = 0; + label nAvailable(0); + const triSurface& surf = guiPtr->surface(); + forAll(surf.patches(), patchI) + { + if( usedNames.found(surf.patches()[patchI].name()) ) + continue; + const char* name = surf.patches()[patchI].name().c_str(); + avPatches = g_list_append(avPatches, const_cast<char*>(name)); + ++nAvailable; + } + + gtk_combo_set_popdown_strings + ( + GTK_COMBO + ( + comboboxentry_bndLayers_availablePatches + ), avPatches + ); + + if( nAvailable == 0 ) + { + gtk_entry_set_text + ( + GTK_ENTRY + ( + GTK_COMBO + ( + comboboxentry_bndLayers_availablePatches + )->entry + ), "" + ); + } + + //- update used patches + GList* selPatches = 0; + forAll(alreadyUsed, patchI) + { + const char* name = alreadyUsed[patchI].c_str(); + selPatches = g_list_append(selPatches, const_cast<char*>(name)); + } + + gtk_combo_set_popdown_strings + ( + GTK_COMBO + ( + comboboxentry_bndLayers_selectedPatches + ), selPatches + ); + + if( alreadyUsed.size() == 0 ) + { + gtk_entry_set_text + ( + GTK_ENTRY + ( + GTK_COMBO + ( + comboboxentry_bndLayers_selectedPatches + )->entry + ), "" + ); + } + + g_list_free(avPatches); + g_list_free(selPatches); } - + static void addBndLayersPatches(GtkWidget* widget, GtkWidget* bndLayersFramePtr) { - GtkWidget* comboboxentry_bndLayers_availablePatches = - (GtkWidget*)g_object_get_data - ( - G_OBJECT(bndLayersFramePtr), - "comboboxentry_bndLayers_availablePatches" - ); - const word name = - gtk_entry_get_text - ( - GTK_ENTRY - ( - GTK_COMBO - ( - comboboxentry_bndLayers_availablePatches - )->entry - ) - ); - - if( name == "" ) - return; - - guiPtr->addBndLayersPatches(name); - - updateBndLayers(bndLayersFramePtr); + GtkWidget* comboboxentry_bndLayers_availablePatches = + (GtkWidget*)g_object_get_data + ( + G_OBJECT(bndLayersFramePtr), + "comboboxentry_bndLayers_availablePatches" + ); + const word name = + gtk_entry_get_text + ( + GTK_ENTRY + ( + GTK_COMBO + ( + comboboxentry_bndLayers_availablePatches + )->entry + ) + ); + + if( name == "" ) + return; + + guiPtr->addBndLayersPatches(name); + + updateBndLayers(bndLayersFramePtr); } static void removeBndLayersPatches ( - GtkWidget* widget, - GtkWidget* bndLayersFramePtr + GtkWidget* widget, + GtkWidget* bndLayersFramePtr ) { - GtkWidget* comboboxentry_bndLayers_selectedPatches = - (GtkWidget*)g_object_get_data - ( - G_OBJECT(bndLayersFramePtr), - "comboboxentry_bndLayers_selectedPatches" - ); - - const word name = - gtk_entry_get_text - ( - GTK_ENTRY - ( - GTK_COMBO - ( - comboboxentry_bndLayers_selectedPatches - )->entry - ) - ); - - if( name == "" ) - return; - - guiPtr->removeBndLayersPatches(name); - - updateBndLayers(bndLayersFramePtr); + GtkWidget* comboboxentry_bndLayers_selectedPatches = + (GtkWidget*)g_object_get_data + ( + G_OBJECT(bndLayersFramePtr), + "comboboxentry_bndLayers_selectedPatches" + ); + + const word name = + gtk_entry_get_text + ( + GTK_ENTRY + ( + GTK_COMBO + ( + comboboxentry_bndLayers_selectedPatches + )->entry + ) + ); + + if( name == "" ) + return; + + guiPtr->removeBndLayersPatches(name); + + updateBndLayers(bndLayersFramePtr); } } void meshGenGTK::createBndLayersWindowPage() { - guiPtr = &meshGui_; - - bndLayersFramePtr_ = gtk_frame_new(NULL); + guiPtr = &meshGui_; + + bndLayersFramePtr_ = gtk_frame_new(NULL); // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - //- create a table - GtkWidget* table1 = gtk_table_new(2, 3, FALSE); - gtk_widget_show(table1); - gtk_container_add - ( - GTK_CONTAINER(bndLayersFramePtr_), - table1 - ); + //- create a table + GtkWidget* table1 = gtk_table_new(2, 3, FALSE); + gtk_widget_show(table1); + gtk_container_add + ( + GTK_CONTAINER(bndLayersFramePtr_), + table1 + ); // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - //- set label for available patches - GtkWidget* label_bndLayers_availablePatches = - gtk_label_new("Available patches"); - gtk_widget_show(label_bndLayers_availablePatches); - gtk_table_attach - ( - GTK_TABLE(table1), - label_bndLayers_availablePatches, - 0, 1, 0, 1, - (GtkAttachOptions)(GTK_FILL), - (GtkAttachOptions) (0), 0, 0 - ); - gtk_misc_set_alignment - ( - GTK_MISC(label_bndLayers_availablePatches), - 0, - 0.5 - ); - + //- set label for available patches + GtkWidget* label_bndLayers_availablePatches = + gtk_label_new("Available patches"); + gtk_widget_show(label_bndLayers_availablePatches); + gtk_table_attach + ( + GTK_TABLE(table1), + label_bndLayers_availablePatches, + 0, 1, 0, 1, + (GtkAttachOptions)(GTK_FILL), + (GtkAttachOptions) (0), 0, 0 + ); + gtk_misc_set_alignment + ( + GTK_MISC(label_bndLayers_availablePatches), + 0, + 0.5 + ); + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - //- create the combo box for available patches - GtkWidget* comboboxentry_bndLayers_availablePatches = - gtk_combo_new(); - gtk_widget_show - ( - comboboxentry_bndLayers_availablePatches - ); - gtk_table_attach - ( - GTK_TABLE(table1), - comboboxentry_bndLayers_availablePatches, - 1, 2, 0, 1, - (GtkAttachOptions)(GTK_EXPAND | GTK_FILL), - (GtkAttachOptions)(GTK_FILL), 0, 0 - ); - - gtk_editable_set_editable - ( - GTK_EDITABLE - ( - GTK_COMBO(comboboxentry_bndLayers_availablePatches)->entry - ), - 0 - ); - + //- create the combo box for available patches + GtkWidget* comboboxentry_bndLayers_availablePatches = + gtk_combo_new(); + gtk_widget_show + ( + comboboxentry_bndLayers_availablePatches + ); + gtk_table_attach + ( + GTK_TABLE(table1), + comboboxentry_bndLayers_availablePatches, + 1, 2, 0, 1, + (GtkAttachOptions)(GTK_EXPAND | GTK_FILL), + (GtkAttachOptions)(GTK_FILL), 0, 0 + ); + + gtk_editable_set_editable + ( + GTK_EDITABLE + ( + GTK_COMBO(comboboxentry_bndLayers_availablePatches)->entry + ), + 0 + ); + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - //- set the button for adding patches - GtkWidget* button1 = gtk_button_new(); - gtk_widget_show(button1); - gtk_table_attach - ( - GTK_TABLE(table1), - button1, - 2, 3, 0, 1, - (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0 - ); - - g_signal_connect - ( - G_OBJECT(button1), - "clicked", - G_CALLBACK(addBndLayersPatches), - bndLayersFramePtr_ - ); + //- set the button for adding patches + GtkWidget* button1 = gtk_button_new(); + gtk_widget_show(button1); + gtk_table_attach + ( + GTK_TABLE(table1), + button1, + 2, 3, 0, 1, + (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0 + ); + + g_signal_connect + ( + G_OBJECT(button1), + "clicked", + G_CALLBACK(addBndLayersPatches), + bndLayersFramePtr_ + ); - GtkWidget* alignment1 = gtk_alignment_new(0.5, 0.5, 0, 0); - gtk_widget_show(alignment1); - gtk_container_add(GTK_CONTAINER(button1), alignment1); - - GtkWidget* hbox1 = gtk_hbox_new(FALSE, 2); - gtk_widget_show(hbox1); - gtk_container_add(GTK_CONTAINER(alignment1), hbox1); - - GtkWidget* image1 = - gtk_image_new_from_stock("gtk-add", GTK_ICON_SIZE_BUTTON); - gtk_widget_show(image1); - gtk_box_pack_start(GTK_BOX(hbox1), image1, FALSE, FALSE, 0); - - GtkWidget* label3 = gtk_label_new_with_mnemonic("Add"); - gtk_widget_show(label3); - gtk_box_pack_start(GTK_BOX(hbox1), label3, FALSE, FALSE, 0); - + GtkWidget* alignment1 = gtk_alignment_new(0.5, 0.5, 0, 0); + gtk_widget_show(alignment1); + gtk_container_add(GTK_CONTAINER(button1), alignment1); + + GtkWidget* hbox1 = gtk_hbox_new(FALSE, 2); + gtk_widget_show(hbox1); + gtk_container_add(GTK_CONTAINER(alignment1), hbox1); + + GtkWidget* image1 = + gtk_image_new_from_stock("gtk-add", GTK_ICON_SIZE_BUTTON); + gtk_widget_show(image1); + gtk_box_pack_start(GTK_BOX(hbox1), image1, FALSE, FALSE, 0); + + GtkWidget* label3 = gtk_label_new_with_mnemonic("Add"); + gtk_widget_show(label3); + gtk_box_pack_start(GTK_BOX(hbox1), label3, FALSE, FALSE, 0); + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - //- set label for selected patches - GtkWidget* label_bndLayers_selectedPatches = - gtk_label_new("Selected patches"); - gtk_widget_show(label_bndLayers_selectedPatches); - gtk_table_attach - ( - GTK_TABLE(table1), - label_bndLayers_selectedPatches, - 0, 1, 1, 2, - (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0 - ); - gtk_misc_set_alignment - ( - GTK_MISC(label_bndLayers_selectedPatches), - 0, - 0.5 - ); - + //- set label for selected patches + GtkWidget* label_bndLayers_selectedPatches = + gtk_label_new("Selected patches"); + gtk_widget_show(label_bndLayers_selectedPatches); + gtk_table_attach + ( + GTK_TABLE(table1), + label_bndLayers_selectedPatches, + 0, 1, 1, 2, + (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0 + ); + gtk_misc_set_alignment + ( + GTK_MISC(label_bndLayers_selectedPatches), + 0, + 0.5 + ); + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - //- create the combo box for selected patches - GtkWidget* comboboxentry_bndLayers_selectedPatches = - gtk_combo_new(); - gtk_widget_show(comboboxentry_bndLayers_selectedPatches); - gtk_table_attach - ( - GTK_TABLE(table1), - comboboxentry_bndLayers_selectedPatches, - 1, 2, 1, 2, - (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (GTK_FILL), 0, 0 - ); - - gtk_editable_set_editable - ( - GTK_EDITABLE - ( - GTK_COMBO(comboboxentry_bndLayers_selectedPatches)->entry - ), - 0 - ); - + //- create the combo box for selected patches + GtkWidget* comboboxentry_bndLayers_selectedPatches = + gtk_combo_new(); + gtk_widget_show(comboboxentry_bndLayers_selectedPatches); + gtk_table_attach + ( + GTK_TABLE(table1), + comboboxentry_bndLayers_selectedPatches, + 1, 2, 1, 2, + (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (GTK_FILL), 0, 0 + ); + + gtk_editable_set_editable + ( + GTK_EDITABLE + ( + GTK_COMBO(comboboxentry_bndLayers_selectedPatches)->entry + ), + 0 + ); + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - //- set the button for removing patches - GtkWidget* button2 = gtk_button_new(); - gtk_widget_show(button2); - gtk_table_attach - ( - GTK_TABLE(table1), - button2, - 2, 3, 1, 2, - (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0 - ); - - g_signal_connect - ( - G_OBJECT(button2), - "clicked", - G_CALLBACK(removeBndLayersPatches), - bndLayersFramePtr_ - ); - - GtkWidget* alignment2 = gtk_alignment_new(0.5, 0.5, 0, 0); - gtk_widget_show(alignment2); - gtk_container_add(GTK_CONTAINER(button2), alignment2); - - GtkWidget* hbox2 = gtk_hbox_new(FALSE, 2); - gtk_widget_show(hbox2); - gtk_container_add(GTK_CONTAINER(alignment2), hbox2); - - GtkWidget* image2 = - gtk_image_new_from_stock("gtk-remove", GTK_ICON_SIZE_BUTTON); - gtk_widget_show(image2); - gtk_box_pack_start(GTK_BOX (hbox2), image2, FALSE, FALSE, 0); - - GtkWidget* label5 = gtk_label_new_with_mnemonic("Remove"); - gtk_widget_show(label5); - gtk_box_pack_start(GTK_BOX (hbox2), label5, FALSE, FALSE, 0); - + //- set the button for removing patches + GtkWidget* button2 = gtk_button_new(); + gtk_widget_show(button2); + gtk_table_attach + ( + GTK_TABLE(table1), + button2, + 2, 3, 1, 2, + (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0 + ); + + g_signal_connect + ( + G_OBJECT(button2), + "clicked", + G_CALLBACK(removeBndLayersPatches), + bndLayersFramePtr_ + ); + + GtkWidget* alignment2 = gtk_alignment_new(0.5, 0.5, 0, 0); + gtk_widget_show(alignment2); + gtk_container_add(GTK_CONTAINER(button2), alignment2); + + GtkWidget* hbox2 = gtk_hbox_new(FALSE, 2); + gtk_widget_show(hbox2); + gtk_container_add(GTK_CONTAINER(alignment2), hbox2); + + GtkWidget* image2 = + gtk_image_new_from_stock("gtk-remove", GTK_ICON_SIZE_BUTTON); + gtk_widget_show(image2); + gtk_box_pack_start(GTK_BOX (hbox2), image2, FALSE, FALSE, 0); + + GtkWidget* label5 = gtk_label_new_with_mnemonic("Remove"); + gtk_widget_show(label5); + gtk_box_pack_start(GTK_BOX (hbox2), label5, FALSE, FALSE, 0); + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - /* Store pointers to all widgets, for use by lookup_widget(). */ - GLADE_HOOKUP_OBJECT_NO_REF - ( - bndLayersFramePtr_, - bndLayersFramePtr_, - "Cell intersecting patches frame" - ); - GLADE_HOOKUP_OBJECT - ( - bndLayersFramePtr_, - comboboxentry_bndLayers_availablePatches, - "comboboxentry_bndLayers_availablePatches" - ); - GLADE_HOOKUP_OBJECT - ( - bndLayersFramePtr_, - button1, - "button1" - ); - GLADE_HOOKUP_OBJECT - ( - bndLayersFramePtr_, - label_bndLayers_selectedPatches, - "label_bndLayers_selectedPatches" - ); - GLADE_HOOKUP_OBJECT - ( - bndLayersFramePtr_, - comboboxentry_bndLayers_selectedPatches, - "comboboxentry_bndLayers_selectedPatches" - ); - GLADE_HOOKUP_OBJECT - ( - bndLayersFramePtr_, - button2, - "button2" - ); - - updateBndLayers(bndLayersFramePtr_); - - gtk_widget_show(bndLayersFramePtr_); + /* Store pointers to all widgets, for use by lookup_widget(). */ + GLADE_HOOKUP_OBJECT_NO_REF + ( + bndLayersFramePtr_, + bndLayersFramePtr_, + "Cell intersecting patches frame" + ); + GLADE_HOOKUP_OBJECT + ( + bndLayersFramePtr_, + comboboxentry_bndLayers_availablePatches, + "comboboxentry_bndLayers_availablePatches" + ); + GLADE_HOOKUP_OBJECT + ( + bndLayersFramePtr_, + button1, + "button1" + ); + GLADE_HOOKUP_OBJECT + ( + bndLayersFramePtr_, + label_bndLayers_selectedPatches, + "label_bndLayers_selectedPatches" + ); + GLADE_HOOKUP_OBJECT + ( + bndLayersFramePtr_, + comboboxentry_bndLayers_selectedPatches, + "comboboxentry_bndLayers_selectedPatches" + ); + GLADE_HOOKUP_OBJECT + ( + bndLayersFramePtr_, + button2, + "button2" + ); + + updateBndLayers(bndLayersFramePtr_); + + gtk_widget_show(bndLayersFramePtr_); } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/GUI/meshGenGTK/meshGenGTKBoxRefinement.C b/GUI/meshGenGTK/meshGenGTKBoxRefinement.C index e9ba591e..1fc3806d 100644 --- a/GUI/meshGenGTK/meshGenGTKBoxRefinement.C +++ b/GUI/meshGenGTK/meshGenGTKBoxRefinement.C @@ -37,1007 +37,1007 @@ namespace Foam // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // //- callback functions - + extern "C" { - + static void showDataForBoxRefinement ( - GtkWidget* widget, - GtkWidget* boxRefinementFramePtr + GtkWidget* widget, + GtkWidget* boxRefinementFramePtr ) { - GtkWidget* comboboxentry_boxRefinement_createdBoxes = - (GtkWidget*)g_object_get_data - ( - G_OBJECT(boxRefinementFramePtr), - "comboboxentry_boxRefinement_createdBoxes" - ); - GtkWidget* entry_boxRefinement_selectedCellSize = - (GtkWidget*)g_object_get_data - ( - G_OBJECT(boxRefinementFramePtr), - "entry_boxRefinement_selectedCellSize" - ); - GtkWidget* entry_boxRefinement_selectedCentreX = - (GtkWidget*)g_object_get_data - ( - G_OBJECT(boxRefinementFramePtr), - "entry_boxRefinement_selectedCentreX" - ); - GtkWidget* entry_boxRefinement_selectedCentreY = - (GtkWidget*)g_object_get_data - ( - G_OBJECT(boxRefinementFramePtr), - "entry_boxRefinement_selectedCentreY" - ); - GtkWidget* entry_boxRefinement_selectedCentreZ = - (GtkWidget*)g_object_get_data - ( - G_OBJECT(boxRefinementFramePtr), - "entry_boxRefinement_selectedCentreZ" - ); - GtkWidget* entry_boxRefinement_selectedLengthX = - (GtkWidget*)g_object_get_data - ( - G_OBJECT(boxRefinementFramePtr), - "entry_boxRefinement_selectedLengthX" - ); - GtkWidget* entry_boxRefinement_selectedLengthY = - (GtkWidget*)g_object_get_data - ( - G_OBJECT(boxRefinementFramePtr), - "entry_boxRefinement_selectedLengthY" - ); - GtkWidget* entry_boxRefinement_selectedLengthZ = - (GtkWidget*)g_object_get_data - ( - G_OBJECT(boxRefinementFramePtr), - "entry_boxRefinement_selectedLengthZ" - ); - - //- find the object in the dictionary - const word boxName = - gtk_entry_get_text - ( - GTK_ENTRY - ( - GTK_COMBO(comboboxentry_boxRefinement_createdBoxes)->entry - ) - ); - - const PtrList<entry> refs = guiPtr->objectRefinements(); - - forAll(refs, refI) - if( refs[refI].keyword() == boxName ) - { - const dictionary dict = refs[refI].dict(); - - gtk_entry_set_text - ( - GTK_ENTRY(entry_boxRefinement_selectedCellSize), - help::scalarToText - ( - scalar(readScalar(dict.lookup("cellSize"))) - ).c_str() - ); - const vector centre(dict.lookup("centre")); - gtk_entry_set_text - ( - GTK_ENTRY(entry_boxRefinement_selectedCentreX), - help::scalarToText(centre.x()).c_str() - ); - gtk_entry_set_text - ( - GTK_ENTRY(entry_boxRefinement_selectedCentreY), - help::scalarToText(centre.y()).c_str() - ); - gtk_entry_set_text - ( - GTK_ENTRY(entry_boxRefinement_selectedCentreZ), - help::scalarToText(centre.z()).c_str() - ); - gtk_entry_set_text - ( - GTK_ENTRY(entry_boxRefinement_selectedLengthX), - help::scalarToText(readScalar(dict.lookup("lengthX"))).c_str() - ); - gtk_entry_set_text - ( - GTK_ENTRY(entry_boxRefinement_selectedLengthY), - help::scalarToText(readScalar(dict.lookup("lengthY"))).c_str() - ); - gtk_entry_set_text - ( - GTK_ENTRY(entry_boxRefinement_selectedLengthZ), - help::scalarToText(readScalar(dict.lookup("lengthZ"))).c_str() - ); - - return; - } - - gtk_entry_set_text(GTK_ENTRY(entry_boxRefinement_selectedCellSize), ""); - gtk_entry_set_text(GTK_ENTRY(entry_boxRefinement_selectedCentreX), ""); - gtk_entry_set_text(GTK_ENTRY(entry_boxRefinement_selectedCentreY), ""); - gtk_entry_set_text(GTK_ENTRY(entry_boxRefinement_selectedCentreZ), ""); - gtk_entry_set_text(GTK_ENTRY(entry_boxRefinement_selectedLengthX), ""); - gtk_entry_set_text(GTK_ENTRY(entry_boxRefinement_selectedLengthY), ""); - gtk_entry_set_text(GTK_ENTRY(entry_boxRefinement_selectedLengthZ), ""); + GtkWidget* comboboxentry_boxRefinement_createdBoxes = + (GtkWidget*)g_object_get_data + ( + G_OBJECT(boxRefinementFramePtr), + "comboboxentry_boxRefinement_createdBoxes" + ); + GtkWidget* entry_boxRefinement_selectedCellSize = + (GtkWidget*)g_object_get_data + ( + G_OBJECT(boxRefinementFramePtr), + "entry_boxRefinement_selectedCellSize" + ); + GtkWidget* entry_boxRefinement_selectedCentreX = + (GtkWidget*)g_object_get_data + ( + G_OBJECT(boxRefinementFramePtr), + "entry_boxRefinement_selectedCentreX" + ); + GtkWidget* entry_boxRefinement_selectedCentreY = + (GtkWidget*)g_object_get_data + ( + G_OBJECT(boxRefinementFramePtr), + "entry_boxRefinement_selectedCentreY" + ); + GtkWidget* entry_boxRefinement_selectedCentreZ = + (GtkWidget*)g_object_get_data + ( + G_OBJECT(boxRefinementFramePtr), + "entry_boxRefinement_selectedCentreZ" + ); + GtkWidget* entry_boxRefinement_selectedLengthX = + (GtkWidget*)g_object_get_data + ( + G_OBJECT(boxRefinementFramePtr), + "entry_boxRefinement_selectedLengthX" + ); + GtkWidget* entry_boxRefinement_selectedLengthY = + (GtkWidget*)g_object_get_data + ( + G_OBJECT(boxRefinementFramePtr), + "entry_boxRefinement_selectedLengthY" + ); + GtkWidget* entry_boxRefinement_selectedLengthZ = + (GtkWidget*)g_object_get_data + ( + G_OBJECT(boxRefinementFramePtr), + "entry_boxRefinement_selectedLengthZ" + ); + + //- find the object in the dictionary + const word boxName = + gtk_entry_get_text + ( + GTK_ENTRY + ( + GTK_COMBO(comboboxentry_boxRefinement_createdBoxes)->entry + ) + ); + + const PtrList<entry> refs = guiPtr->objectRefinements(); + + forAll(refs, refI) + if( refs[refI].keyword() == boxName ) + { + const dictionary dict = refs[refI].dict(); + + gtk_entry_set_text + ( + GTK_ENTRY(entry_boxRefinement_selectedCellSize), + help::scalarToText + ( + scalar(readScalar(dict.lookup("cellSize"))) + ).c_str() + ); + const vector centre(dict.lookup("centre")); + gtk_entry_set_text + ( + GTK_ENTRY(entry_boxRefinement_selectedCentreX), + help::scalarToText(centre.x()).c_str() + ); + gtk_entry_set_text + ( + GTK_ENTRY(entry_boxRefinement_selectedCentreY), + help::scalarToText(centre.y()).c_str() + ); + gtk_entry_set_text + ( + GTK_ENTRY(entry_boxRefinement_selectedCentreZ), + help::scalarToText(centre.z()).c_str() + ); + gtk_entry_set_text + ( + GTK_ENTRY(entry_boxRefinement_selectedLengthX), + help::scalarToText(readScalar(dict.lookup("lengthX"))).c_str() + ); + gtk_entry_set_text + ( + GTK_ENTRY(entry_boxRefinement_selectedLengthY), + help::scalarToText(readScalar(dict.lookup("lengthY"))).c_str() + ); + gtk_entry_set_text + ( + GTK_ENTRY(entry_boxRefinement_selectedLengthZ), + help::scalarToText(readScalar(dict.lookup("lengthZ"))).c_str() + ); + + return; + } + + gtk_entry_set_text(GTK_ENTRY(entry_boxRefinement_selectedCellSize), ""); + gtk_entry_set_text(GTK_ENTRY(entry_boxRefinement_selectedCentreX), ""); + gtk_entry_set_text(GTK_ENTRY(entry_boxRefinement_selectedCentreY), ""); + gtk_entry_set_text(GTK_ENTRY(entry_boxRefinement_selectedCentreZ), ""); + gtk_entry_set_text(GTK_ENTRY(entry_boxRefinement_selectedLengthX), ""); + gtk_entry_set_text(GTK_ENTRY(entry_boxRefinement_selectedLengthY), ""); + gtk_entry_set_text(GTK_ENTRY(entry_boxRefinement_selectedLengthZ), ""); } static void resetValuesForSelectedBox ( - GtkWidget* widget, - GtkWidget* boxRefinementFramePtr + GtkWidget* widget, + GtkWidget* boxRefinementFramePtr ) { - GtkWidget* comboboxentry_boxRefinement_createdBoxes = - (GtkWidget*)g_object_get_data - ( - G_OBJECT(boxRefinementFramePtr), - "comboboxentry_boxRefinement_createdBoxes" - ); - GtkWidget* entry_boxRefinement_selectedCellSize = - (GtkWidget*)g_object_get_data - ( - G_OBJECT(boxRefinementFramePtr), - "entry_boxRefinement_selectedCellSize" - ); - GtkWidget* entry_boxRefinement_selectedCentreX = - (GtkWidget*)g_object_get_data - ( - G_OBJECT(boxRefinementFramePtr), - "entry_boxRefinement_selectedCentreX" - ); - GtkWidget* entry_boxRefinement_selectedCentreY = - (GtkWidget*)g_object_get_data - ( - G_OBJECT(boxRefinementFramePtr), - "entry_boxRefinement_selectedCentreY" - ); - GtkWidget* entry_boxRefinement_selectedCentreZ = - (GtkWidget*)g_object_get_data - ( - G_OBJECT(boxRefinementFramePtr), - "entry_boxRefinement_selectedCentreZ" - ); - GtkWidget* entry_boxRefinement_selectedLengthX = - (GtkWidget*)g_object_get_data - ( - G_OBJECT(boxRefinementFramePtr), - "entry_boxRefinement_selectedLengthX" - ); - GtkWidget* entry_boxRefinement_selectedLengthY = - (GtkWidget*)g_object_get_data - ( - G_OBJECT(boxRefinementFramePtr), - "entry_boxRefinement_selectedLengthY" - ); - GtkWidget* entry_boxRefinement_selectedLengthZ = - (GtkWidget*)g_object_get_data - ( - G_OBJECT(boxRefinementFramePtr), - "entry_boxRefinement_selectedLengthZ" - ); - - const word name = - gtk_entry_get_text - ( - GTK_ENTRY - ( - GTK_COMBO - ( - comboboxentry_boxRefinement_createdBoxes - )->entry - ) - ); - - if( name == "" ) - return; - - const PtrList<entry> refs = guiPtr->objectRefinements(); - dictionary dict; - forAll(refs, refI) - if( refs[refI].keyword() == name ) - dict = refs[refI].dict(); - guiPtr->removeObjectRefinement(name); - if( widget == entry_boxRefinement_selectedCellSize ) - { - const word size = - gtk_entry_get_text(GTK_ENTRY(entry_boxRefinement_selectedCellSize)); - dict.remove("cellSize"); - dict.add("cellSize", help::textToScalar(size)); - } - else if( widget == entry_boxRefinement_selectedCentreX ) - { - point centre(dict.lookup("centre")); - const word c = - gtk_entry_get_text(GTK_ENTRY(entry_boxRefinement_selectedCentreX)); - dict.remove("centre"); - centre.x() = help::textToScalar(c); - dict.add("centre", centre); - } - else if( widget == entry_boxRefinement_selectedCentreY ) - { - point centre(dict.lookup("centre")); - const word c = - gtk_entry_get_text(GTK_ENTRY(entry_boxRefinement_selectedCentreY)); - dict.remove("centre"); - centre.y() = help::textToScalar(c); - dict.add("centre", centre); - } - else if( widget == entry_boxRefinement_selectedCentreZ ) - { - point centre(dict.lookup("centre")); - const word c = - gtk_entry_get_text(GTK_ENTRY(entry_boxRefinement_selectedCentreZ)); - dict.remove("centre"); - centre.z() = help::textToScalar(c); - dict.add("centre", centre); - } - else if( widget == entry_boxRefinement_selectedLengthX ) - { - const word l = - gtk_entry_get_text(GTK_ENTRY(entry_boxRefinement_selectedLengthX)); - dict.remove("lengthX"); - dict.add("lengthX", help::textToScalar(l)); - } - else if( widget == entry_boxRefinement_selectedLengthY ) - { - const word l = - gtk_entry_get_text(GTK_ENTRY(entry_boxRefinement_selectedLengthY)); - dict.remove("lengthY"); - dict.add("lengthY", help::textToScalar(l)); - } - else if( widget == entry_boxRefinement_selectedLengthZ ) - { - const word l = - gtk_entry_get_text(GTK_ENTRY(entry_boxRefinement_selectedLengthZ)); - dict.remove("lengthZ"); - dict.add("lengthZ", help::textToScalar(l)); - } - - boxRefinement br(name, dict); - guiPtr->addObjectRefinement(br); + GtkWidget* comboboxentry_boxRefinement_createdBoxes = + (GtkWidget*)g_object_get_data + ( + G_OBJECT(boxRefinementFramePtr), + "comboboxentry_boxRefinement_createdBoxes" + ); + GtkWidget* entry_boxRefinement_selectedCellSize = + (GtkWidget*)g_object_get_data + ( + G_OBJECT(boxRefinementFramePtr), + "entry_boxRefinement_selectedCellSize" + ); + GtkWidget* entry_boxRefinement_selectedCentreX = + (GtkWidget*)g_object_get_data + ( + G_OBJECT(boxRefinementFramePtr), + "entry_boxRefinement_selectedCentreX" + ); + GtkWidget* entry_boxRefinement_selectedCentreY = + (GtkWidget*)g_object_get_data + ( + G_OBJECT(boxRefinementFramePtr), + "entry_boxRefinement_selectedCentreY" + ); + GtkWidget* entry_boxRefinement_selectedCentreZ = + (GtkWidget*)g_object_get_data + ( + G_OBJECT(boxRefinementFramePtr), + "entry_boxRefinement_selectedCentreZ" + ); + GtkWidget* entry_boxRefinement_selectedLengthX = + (GtkWidget*)g_object_get_data + ( + G_OBJECT(boxRefinementFramePtr), + "entry_boxRefinement_selectedLengthX" + ); + GtkWidget* entry_boxRefinement_selectedLengthY = + (GtkWidget*)g_object_get_data + ( + G_OBJECT(boxRefinementFramePtr), + "entry_boxRefinement_selectedLengthY" + ); + GtkWidget* entry_boxRefinement_selectedLengthZ = + (GtkWidget*)g_object_get_data + ( + G_OBJECT(boxRefinementFramePtr), + "entry_boxRefinement_selectedLengthZ" + ); + + const word name = + gtk_entry_get_text + ( + GTK_ENTRY + ( + GTK_COMBO + ( + comboboxentry_boxRefinement_createdBoxes + )->entry + ) + ); + + if( name == "" ) + return; + + const PtrList<entry> refs = guiPtr->objectRefinements(); + dictionary dict; + forAll(refs, refI) + if( refs[refI].keyword() == name ) + dict = refs[refI].dict(); + guiPtr->removeObjectRefinement(name); + if( widget == entry_boxRefinement_selectedCellSize ) + { + const word size = + gtk_entry_get_text(GTK_ENTRY(entry_boxRefinement_selectedCellSize)); + dict.remove("cellSize"); + dict.add("cellSize", help::textToScalar(size)); + } + else if( widget == entry_boxRefinement_selectedCentreX ) + { + point centre(dict.lookup("centre")); + const word c = + gtk_entry_get_text(GTK_ENTRY(entry_boxRefinement_selectedCentreX)); + dict.remove("centre"); + centre.x() = help::textToScalar(c); + dict.add("centre", centre); + } + else if( widget == entry_boxRefinement_selectedCentreY ) + { + point centre(dict.lookup("centre")); + const word c = + gtk_entry_get_text(GTK_ENTRY(entry_boxRefinement_selectedCentreY)); + dict.remove("centre"); + centre.y() = help::textToScalar(c); + dict.add("centre", centre); + } + else if( widget == entry_boxRefinement_selectedCentreZ ) + { + point centre(dict.lookup("centre")); + const word c = + gtk_entry_get_text(GTK_ENTRY(entry_boxRefinement_selectedCentreZ)); + dict.remove("centre"); + centre.z() = help::textToScalar(c); + dict.add("centre", centre); + } + else if( widget == entry_boxRefinement_selectedLengthX ) + { + const word l = + gtk_entry_get_text(GTK_ENTRY(entry_boxRefinement_selectedLengthX)); + dict.remove("lengthX"); + dict.add("lengthX", help::textToScalar(l)); + } + else if( widget == entry_boxRefinement_selectedLengthY ) + { + const word l = + gtk_entry_get_text(GTK_ENTRY(entry_boxRefinement_selectedLengthY)); + dict.remove("lengthY"); + dict.add("lengthY", help::textToScalar(l)); + } + else if( widget == entry_boxRefinement_selectedLengthZ ) + { + const word l = + gtk_entry_get_text(GTK_ENTRY(entry_boxRefinement_selectedLengthZ)); + dict.remove("lengthZ"); + dict.add("lengthZ", help::textToScalar(l)); + } + + boxRefinement br(name, dict); + guiPtr->addObjectRefinement(br); } static void updateBoxRefinements(GtkWidget* boxRefinementFramePtr) { - GtkWidget* comboboxentry_boxRefinement_createdBoxes = - (GtkWidget*)g_object_get_data - ( - G_OBJECT(boxRefinementFramePtr), - "comboboxentry_boxRefinement_createdBoxes" - ); - - const PtrList<entry> refs = guiPtr->objectRefinements(); - label nBoxes(0); - GList* createdBoxes = 0; - forAll(refs, refI) - { - const word& key = refs[refI].keyword(); - const dictionary& dict = refs[refI].dict(); - const word type(dict.lookup("type")); - - if( type == "box" ) - { - ++nBoxes; - boxRefinement br(key, dict); - createdBoxes = - g_list_append - ( - createdBoxes, - const_cast<char*>(br.name().c_str()) - ); - } - } - - gtk_combo_set_popdown_strings - ( - GTK_COMBO - ( - comboboxentry_boxRefinement_createdBoxes - ), createdBoxes - ); - - if( nBoxes == 0 ) - { - gtk_entry_set_text - ( - GTK_ENTRY - ( - GTK_COMBO(comboboxentry_boxRefinement_createdBoxes)->entry - ), - "" - ); - } - - g_list_free(createdBoxes); - - showDataForBoxRefinement(NULL, boxRefinementFramePtr); + GtkWidget* comboboxentry_boxRefinement_createdBoxes = + (GtkWidget*)g_object_get_data + ( + G_OBJECT(boxRefinementFramePtr), + "comboboxentry_boxRefinement_createdBoxes" + ); + + const PtrList<entry> refs = guiPtr->objectRefinements(); + label nBoxes(0); + GList* createdBoxes = 0; + forAll(refs, refI) + { + const word& key = refs[refI].keyword(); + const dictionary& dict = refs[refI].dict(); + const word type(dict.lookup("type")); + + if( type == "box" ) + { + ++nBoxes; + boxRefinement br(key, dict); + createdBoxes = + g_list_append + ( + createdBoxes, + const_cast<char*>(br.name().c_str()) + ); + } + } + + gtk_combo_set_popdown_strings + ( + GTK_COMBO + ( + comboboxentry_boxRefinement_createdBoxes + ), createdBoxes + ); + + if( nBoxes == 0 ) + { + gtk_entry_set_text + ( + GTK_ENTRY + ( + GTK_COMBO(comboboxentry_boxRefinement_createdBoxes)->entry + ), + "" + ); + } + + g_list_free(createdBoxes); + + showDataForBoxRefinement(NULL, boxRefinementFramePtr); } static void addBoxRefinement ( - GtkWidget* button, - GtkWidget* boxRefinementFramePtr + GtkWidget* button, + GtkWidget* boxRefinementFramePtr ) { - GtkWidget* name = - (GtkWidget*)g_object_get_data - ( - G_OBJECT(boxRefinementFramePtr), - "entry_boxName" - ); - GtkWidget* cellSize = - (GtkWidget*)g_object_get_data - ( - G_OBJECT(boxRefinementFramePtr), - "entry_boxRefinement_cellSize" - ); - GtkWidget* centreX = - (GtkWidget*)g_object_get_data - ( - G_OBJECT(boxRefinementFramePtr), - "entry_boxRefinement_centreX" - ); - GtkWidget* centreY = - (GtkWidget*)g_object_get_data - ( - G_OBJECT(boxRefinementFramePtr), - "entry_boxRefinement_centreY" - ); - GtkWidget* centreZ = - (GtkWidget*)g_object_get_data - ( - G_OBJECT(boxRefinementFramePtr), - "entry_boxRefinement_centreZ" - ); - GtkWidget* lengthX = - (GtkWidget*)g_object_get_data - ( - G_OBJECT(boxRefinementFramePtr), - "entry_boxRefinement_lengthX" - ); - GtkWidget* lengthY = - (GtkWidget*)g_object_get_data - ( - G_OBJECT(boxRefinementFramePtr), - "entry_boxRefinement_lengthY" - ); - GtkWidget* lengthZ = - (GtkWidget*)g_object_get_data - ( - G_OBJECT(boxRefinementFramePtr), - "entry_boxRefinement_lengthZ" - ); - - //- create all necessary settings - const word boxName = gtk_entry_get_text(GTK_ENTRY(name)); - gtk_entry_set_text(GTK_ENTRY(name), ""); - const scalar boxCellSize = - help::textToScalar(gtk_entry_get_text(GTK_ENTRY(cellSize))); - gtk_entry_set_text(GTK_ENTRY(cellSize), ""); - point centre; - centre.x() = help::textToScalar(gtk_entry_get_text(GTK_ENTRY(centreX))); - gtk_entry_set_text(GTK_ENTRY(centreX), ""); - centre.y() = help::textToScalar(gtk_entry_get_text(GTK_ENTRY(centreY))); - gtk_entry_set_text(GTK_ENTRY(centreY), ""); - centre.z() = help::textToScalar(gtk_entry_get_text(GTK_ENTRY(centreZ))); - gtk_entry_set_text(GTK_ENTRY(centreZ), ""); - const scalar boxLengthX = - help::textToScalar(gtk_entry_get_text(GTK_ENTRY(lengthX))); - gtk_entry_set_text(GTK_ENTRY(lengthX), ""); - const scalar boxLengthY = - help::textToScalar(gtk_entry_get_text(GTK_ENTRY(lengthY))); - gtk_entry_set_text(GTK_ENTRY(lengthY), ""); - const scalar boxLengthZ = - help::textToScalar(gtk_entry_get_text(GTK_ENTRY(lengthZ))); - gtk_entry_set_text(GTK_ENTRY(lengthZ), ""); - - boxRefinement box - ( - boxName, - boxCellSize, - centre, - boxLengthX, - boxLengthY, - boxLengthZ - ); - - guiPtr->addObjectRefinement(box); - - updateBoxRefinements(boxRefinementFramePtr); + GtkWidget* name = + (GtkWidget*)g_object_get_data + ( + G_OBJECT(boxRefinementFramePtr), + "entry_boxName" + ); + GtkWidget* cellSize = + (GtkWidget*)g_object_get_data + ( + G_OBJECT(boxRefinementFramePtr), + "entry_boxRefinement_cellSize" + ); + GtkWidget* centreX = + (GtkWidget*)g_object_get_data + ( + G_OBJECT(boxRefinementFramePtr), + "entry_boxRefinement_centreX" + ); + GtkWidget* centreY = + (GtkWidget*)g_object_get_data + ( + G_OBJECT(boxRefinementFramePtr), + "entry_boxRefinement_centreY" + ); + GtkWidget* centreZ = + (GtkWidget*)g_object_get_data + ( + G_OBJECT(boxRefinementFramePtr), + "entry_boxRefinement_centreZ" + ); + GtkWidget* lengthX = + (GtkWidget*)g_object_get_data + ( + G_OBJECT(boxRefinementFramePtr), + "entry_boxRefinement_lengthX" + ); + GtkWidget* lengthY = + (GtkWidget*)g_object_get_data + ( + G_OBJECT(boxRefinementFramePtr), + "entry_boxRefinement_lengthY" + ); + GtkWidget* lengthZ = + (GtkWidget*)g_object_get_data + ( + G_OBJECT(boxRefinementFramePtr), + "entry_boxRefinement_lengthZ" + ); + + //- create all necessary settings + const word boxName = gtk_entry_get_text(GTK_ENTRY(name)); + gtk_entry_set_text(GTK_ENTRY(name), ""); + const scalar boxCellSize = + help::textToScalar(gtk_entry_get_text(GTK_ENTRY(cellSize))); + gtk_entry_set_text(GTK_ENTRY(cellSize), ""); + point centre; + centre.x() = help::textToScalar(gtk_entry_get_text(GTK_ENTRY(centreX))); + gtk_entry_set_text(GTK_ENTRY(centreX), ""); + centre.y() = help::textToScalar(gtk_entry_get_text(GTK_ENTRY(centreY))); + gtk_entry_set_text(GTK_ENTRY(centreY), ""); + centre.z() = help::textToScalar(gtk_entry_get_text(GTK_ENTRY(centreZ))); + gtk_entry_set_text(GTK_ENTRY(centreZ), ""); + const scalar boxLengthX = + help::textToScalar(gtk_entry_get_text(GTK_ENTRY(lengthX))); + gtk_entry_set_text(GTK_ENTRY(lengthX), ""); + const scalar boxLengthY = + help::textToScalar(gtk_entry_get_text(GTK_ENTRY(lengthY))); + gtk_entry_set_text(GTK_ENTRY(lengthY), ""); + const scalar boxLengthZ = + help::textToScalar(gtk_entry_get_text(GTK_ENTRY(lengthZ))); + gtk_entry_set_text(GTK_ENTRY(lengthZ), ""); + + boxRefinement box + ( + boxName, + boxCellSize, + centre, + boxLengthX, + boxLengthY, + boxLengthZ + ); + + guiPtr->addObjectRefinement(box); + + updateBoxRefinements(boxRefinementFramePtr); } static void removeBoxRefinement ( - GtkWidget* button, - GtkWidget* boxRefinementFramePtr + GtkWidget* button, + GtkWidget* boxRefinementFramePtr ) { - GtkWidget* createdBoxes = - (GtkWidget*)g_object_get_data - ( - G_OBJECT(boxRefinementFramePtr), - "comboboxentry_boxRefinement_createdBoxes" - ); - - const word boxName = - gtk_entry_get_text - ( - GTK_ENTRY - ( - GTK_COMBO(createdBoxes)->entry - ) - ); + GtkWidget* createdBoxes = + (GtkWidget*)g_object_get_data + ( + G_OBJECT(boxRefinementFramePtr), + "comboboxentry_boxRefinement_createdBoxes" + ); + + const word boxName = + gtk_entry_get_text + ( + GTK_ENTRY + ( + GTK_COMBO(createdBoxes)->entry + ) + ); - guiPtr->removeObjectRefinement(boxName); + guiPtr->removeObjectRefinement(boxName); - updateBoxRefinements(boxRefinementFramePtr); + updateBoxRefinements(boxRefinementFramePtr); } } void meshGenGTK::createBoxRefinementWindowPage() { - guiPtr = &meshGui_; - - boxRefinementFramePtr_ = gtk_frame_new(NULL); + guiPtr = &meshGui_; + + boxRefinementFramePtr_ = gtk_frame_new(NULL); // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - //- create a table - GtkWidget* table1 = gtk_table_new(5, 11, FALSE); - gtk_widget_show(table1); - gtk_container_add - ( - GTK_CONTAINER(boxRefinementFramePtr_), - table1 - ); + //- create a table + GtkWidget* table1 = gtk_table_new(5, 11, FALSE); + gtk_widget_show(table1); + gtk_container_add + ( + GTK_CONTAINER(boxRefinementFramePtr_), + table1 + ); // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - //- create a label for box name - GtkWidget* label_boxName = gtk_label_new("Box name"); - gtk_widget_show(label_boxName); - gtk_table_attach(GTK_TABLE(table1), label_boxName, 0, 1, 0, 1, + //- create a label for box name + GtkWidget* label_boxName = gtk_label_new("Box name"); + gtk_widget_show(label_boxName); + gtk_table_attach(GTK_TABLE(table1), label_boxName, 0, 1, 0, 1, (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0); - gtk_misc_set_alignment(GTK_MISC(label_boxName), 0, 0.5); - + gtk_misc_set_alignment(GTK_MISC(label_boxName), 0, 0.5); + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - //- create an entry for box name - GtkWidget* entry_boxName = gtk_entry_new(); - gtk_widget_show(entry_boxName); - - gtk_table_attach(GTK_TABLE(table1), entry_boxName, 1, 4, 0, 1, - (GtkAttachOptions)(GTK_FILL), + //- create an entry for box name + GtkWidget* entry_boxName = gtk_entry_new(); + gtk_widget_show(entry_boxName); + + gtk_table_attach(GTK_TABLE(table1), entry_boxName, 1, 4, 0, 1, + (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0); - + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - //- create a label for desired cell size - GtkWidget* label_boxRefinement_cellSize = gtk_label_new("Cell size [m]"); - gtk_widget_show(label_boxRefinement_cellSize); - gtk_table_attach(GTK_TABLE(table1), label_boxRefinement_cellSize, - 0, 1, 1, 2, - (GtkAttachOptions)(GTK_FILL), + //- create a label for desired cell size + GtkWidget* label_boxRefinement_cellSize = gtk_label_new("Cell size [m]"); + gtk_widget_show(label_boxRefinement_cellSize); + gtk_table_attach(GTK_TABLE(table1), label_boxRefinement_cellSize, + 0, 1, 1, 2, + (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0); - gtk_misc_set_alignment(GTK_MISC(label_boxRefinement_cellSize), 0, 0.5); - + gtk_misc_set_alignment(GTK_MISC(label_boxRefinement_cellSize), 0, 0.5); + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - //- create a label for desired cell size - GtkWidget* entry_boxRefinement_cellSize = gtk_entry_new(); - gtk_widget_show(entry_boxRefinement_cellSize); - gtk_table_attach(GTK_TABLE(table1), entry_boxRefinement_cellSize, - 1, 4, 1, 2, - (GtkAttachOptions)(GTK_FILL), + //- create a label for desired cell size + GtkWidget* entry_boxRefinement_cellSize = gtk_entry_new(); + gtk_widget_show(entry_boxRefinement_cellSize); + gtk_table_attach(GTK_TABLE(table1), entry_boxRefinement_cellSize, + 1, 4, 1, 2, + (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0); - + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - //- create labels for axes - GtkWidget* label_axes = gtk_label_new("X"); - gtk_widget_show(label_axes); - gtk_table_attach(GTK_TABLE(table1), label_axes, - 1, 2, 2, 3, - (GtkAttachOptions)(GTK_FILL), + //- create labels for axes + GtkWidget* label_axes = gtk_label_new("X"); + gtk_widget_show(label_axes); + gtk_table_attach(GTK_TABLE(table1), label_axes, + 1, 2, 2, 3, + (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0); - gtk_misc_set_alignment(GTK_MISC(label_axes), 0, 0.5); - - label_axes = gtk_label_new("Y"); - gtk_widget_show(label_axes); - gtk_table_attach(GTK_TABLE(table1), label_axes, - 2, 3, 2, 3, - (GtkAttachOptions)(GTK_FILL), + gtk_misc_set_alignment(GTK_MISC(label_axes), 0, 0.5); + + label_axes = gtk_label_new("Y"); + gtk_widget_show(label_axes); + gtk_table_attach(GTK_TABLE(table1), label_axes, + 2, 3, 2, 3, + (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0); - gtk_misc_set_alignment(GTK_MISC(label_axes), 0, 0.5); - - label_axes = gtk_label_new("Z"); - gtk_widget_show(label_axes); - gtk_table_attach(GTK_TABLE(table1), label_axes, - 3, 4, 2, 3, - (GtkAttachOptions)(GTK_FILL), + gtk_misc_set_alignment(GTK_MISC(label_axes), 0, 0.5); + + label_axes = gtk_label_new("Z"); + gtk_widget_show(label_axes); + gtk_table_attach(GTK_TABLE(table1), label_axes, + 3, 4, 2, 3, + (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0); - gtk_misc_set_alignment(GTK_MISC(label_axes), 0, 0.5); - + gtk_misc_set_alignment(GTK_MISC(label_axes), 0, 0.5); + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - //- label for box centre - GtkWidget* label_boxRefinement_centre = gtk_label_new("Centre"); - gtk_widget_show(label_boxRefinement_centre); - gtk_table_attach(GTK_TABLE(table1), label_boxRefinement_centre, - 0, 1, 3, 4, - (GtkAttachOptions)(GTK_FILL), + //- label for box centre + GtkWidget* label_boxRefinement_centre = gtk_label_new("Centre"); + gtk_widget_show(label_boxRefinement_centre); + gtk_table_attach(GTK_TABLE(table1), label_boxRefinement_centre, + 0, 1, 3, 4, + (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0); - gtk_misc_set_alignment(GTK_MISC(label_boxRefinement_centre), 0, 0.5); + gtk_misc_set_alignment(GTK_MISC(label_boxRefinement_centre), 0, 0.5); // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - //- entries for box centre - GtkWidget* entry_boxRefinement_centreX = gtk_entry_new(); - gtk_widget_show(entry_boxRefinement_centreX); - gtk_table_attach(GTK_TABLE(table1), entry_boxRefinement_centreX, - 1, 2, 3, 4, - (GtkAttachOptions)(GTK_FILL), + //- entries for box centre + GtkWidget* entry_boxRefinement_centreX = gtk_entry_new(); + gtk_widget_show(entry_boxRefinement_centreX); + gtk_table_attach(GTK_TABLE(table1), entry_boxRefinement_centreX, + 1, 2, 3, 4, + (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0); - - GtkWidget* entry_boxRefinement_centreY = gtk_entry_new(); - gtk_widget_show(entry_boxRefinement_centreY); - gtk_table_attach(GTK_TABLE(table1), entry_boxRefinement_centreY, - 2, 3, 3, 4, - (GtkAttachOptions)(GTK_FILL), + + GtkWidget* entry_boxRefinement_centreY = gtk_entry_new(); + gtk_widget_show(entry_boxRefinement_centreY); + gtk_table_attach(GTK_TABLE(table1), entry_boxRefinement_centreY, + 2, 3, 3, 4, + (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0); - - GtkWidget* entry_boxRefinement_centreZ = gtk_entry_new(); - gtk_widget_show(entry_boxRefinement_centreZ); - gtk_table_attach(GTK_TABLE(table1), entry_boxRefinement_centreZ, - 3, 4, 3, 4, - (GtkAttachOptions)(GTK_FILL), + + GtkWidget* entry_boxRefinement_centreZ = gtk_entry_new(); + gtk_widget_show(entry_boxRefinement_centreZ); + gtk_table_attach(GTK_TABLE(table1), entry_boxRefinement_centreZ, + 3, 4, 3, 4, + (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0); - + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - //- label for side lengths - GtkWidget* label_boxRefinement_lengths = gtk_label_new("Side lengths"); - gtk_widget_show(label_boxRefinement_lengths); - gtk_table_attach(GTK_TABLE(table1), label_boxRefinement_lengths, - 0, 1, 4, 5, - (GtkAttachOptions)(GTK_FILL), + //- label for side lengths + GtkWidget* label_boxRefinement_lengths = gtk_label_new("Side lengths"); + gtk_widget_show(label_boxRefinement_lengths); + gtk_table_attach(GTK_TABLE(table1), label_boxRefinement_lengths, + 0, 1, 4, 5, + (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0); - gtk_misc_set_alignment(GTK_MISC(label_boxRefinement_lengths), 0, 0.5); + gtk_misc_set_alignment(GTK_MISC(label_boxRefinement_lengths), 0, 0.5); // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - //- entries for side lengths - GtkWidget* entry_boxRefinement_lengthX = gtk_entry_new(); - gtk_widget_show(entry_boxRefinement_lengthX); - gtk_table_attach(GTK_TABLE(table1), entry_boxRefinement_lengthX, - 1, 2, 4, 5, - (GtkAttachOptions)(GTK_FILL), + //- entries for side lengths + GtkWidget* entry_boxRefinement_lengthX = gtk_entry_new(); + gtk_widget_show(entry_boxRefinement_lengthX); + gtk_table_attach(GTK_TABLE(table1), entry_boxRefinement_lengthX, + 1, 2, 4, 5, + (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0); - - GtkWidget* entry_boxRefinement_lengthY = gtk_entry_new(); - gtk_widget_show(entry_boxRefinement_lengthY); - gtk_table_attach(GTK_TABLE(table1), entry_boxRefinement_lengthY, - 2, 3, 4, 5, - (GtkAttachOptions)(GTK_FILL), + + GtkWidget* entry_boxRefinement_lengthY = gtk_entry_new(); + gtk_widget_show(entry_boxRefinement_lengthY); + gtk_table_attach(GTK_TABLE(table1), entry_boxRefinement_lengthY, + 2, 3, 4, 5, + (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0); - - GtkWidget* entry_boxRefinement_lengthZ = gtk_entry_new(); - gtk_widget_show(entry_boxRefinement_lengthZ); - gtk_table_attach(GTK_TABLE(table1), entry_boxRefinement_lengthZ, - 3, 4, 4, 5, - (GtkAttachOptions)(GTK_FILL), + + GtkWidget* entry_boxRefinement_lengthZ = gtk_entry_new(); + gtk_widget_show(entry_boxRefinement_lengthZ); + gtk_table_attach(GTK_TABLE(table1), entry_boxRefinement_lengthZ, + 3, 4, 4, 5, + (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0); - + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - //- set the button for adding boxes - GtkWidget* button1 = gtk_button_new(); - gtk_widget_show(button1); - gtk_table_attach - ( - GTK_TABLE(table1), - button1, - 4, 5, 0, 5, - (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 5 - ); - - g_signal_connect - ( - G_OBJECT(button1), - "clicked", - G_CALLBACK(addBoxRefinement), - boxRefinementFramePtr_ - ); + //- set the button for adding boxes + GtkWidget* button1 = gtk_button_new(); + gtk_widget_show(button1); + gtk_table_attach + ( + GTK_TABLE(table1), + button1, + 4, 5, 0, 5, + (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 5 + ); + + g_signal_connect + ( + G_OBJECT(button1), + "clicked", + G_CALLBACK(addBoxRefinement), + boxRefinementFramePtr_ + ); - GtkWidget* alignment1 = gtk_alignment_new(0.5, 0.5, 0, 0); - gtk_widget_show(alignment1); - gtk_container_add(GTK_CONTAINER(button1), alignment1); - - GtkWidget* hbox1 = gtk_hbox_new(FALSE, 2); - gtk_widget_show(hbox1); - gtk_container_add(GTK_CONTAINER(alignment1), hbox1); - - GtkWidget* image1 = - gtk_image_new_from_stock("gtk-add", GTK_ICON_SIZE_BUTTON); - gtk_widget_show(image1); - gtk_box_pack_start(GTK_BOX(hbox1), image1, FALSE, FALSE, 0); - - GtkWidget* label3 = gtk_label_new_with_mnemonic("Add"); - gtk_widget_show(label3); - gtk_box_pack_start(GTK_BOX(hbox1), label3, FALSE, FALSE, 0); - + GtkWidget* alignment1 = gtk_alignment_new(0.5, 0.5, 0, 0); + gtk_widget_show(alignment1); + gtk_container_add(GTK_CONTAINER(button1), alignment1); + + GtkWidget* hbox1 = gtk_hbox_new(FALSE, 2); + gtk_widget_show(hbox1); + gtk_container_add(GTK_CONTAINER(alignment1), hbox1); + + GtkWidget* image1 = + gtk_image_new_from_stock("gtk-add", GTK_ICON_SIZE_BUTTON); + gtk_widget_show(image1); + gtk_box_pack_start(GTK_BOX(hbox1), image1, FALSE, FALSE, 0); + + GtkWidget* label3 = gtk_label_new_with_mnemonic("Add"); + gtk_widget_show(label3); + gtk_box_pack_start(GTK_BOX(hbox1), label3, FALSE, FALSE, 0); + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - //- horizontal separator - GtkWidget* hseparator0 = gtk_hseparator_new(); - gtk_widget_show(hseparator0); - gtk_table_attach(GTK_TABLE(table1), hseparator0, 0, 5, 5, 6, + //- horizontal separator + GtkWidget* hseparator0 = gtk_hseparator_new(); + gtk_widget_show(hseparator0); + gtk_table_attach(GTK_TABLE(table1), hseparator0, 0, 5, 5, 6, (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(GTK_EXPAND | GTK_SHRINK | GTK_FILL), - 0, 0); + 0, 0); // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - //- label for existing box objects - GtkWidget* label_boxRefinement_existing = gtk_label_new("Existing boxes"); - gtk_widget_show(label_boxRefinement_existing); - gtk_table_attach(GTK_TABLE(table1), label_boxRefinement_existing, - 0, 1, 6, 7, - (GtkAttachOptions)(GTK_FILL), + //- label for existing box objects + GtkWidget* label_boxRefinement_existing = gtk_label_new("Existing boxes"); + gtk_widget_show(label_boxRefinement_existing); + gtk_table_attach(GTK_TABLE(table1), label_boxRefinement_existing, + 0, 1, 6, 7, + (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0); - + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - //- combobox for existing box objects - GtkWidget* comboboxentry_boxRefinement_createdBoxes = - gtk_combo_new(); - gtk_widget_show(comboboxentry_boxRefinement_createdBoxes); - gtk_table_attach(GTK_TABLE(table1),comboboxentry_boxRefinement_createdBoxes, - 1, 2, 6, 7, - (GtkAttachOptions)(GTK_FILL), + //- combobox for existing box objects + GtkWidget* comboboxentry_boxRefinement_createdBoxes = + gtk_combo_new(); + gtk_widget_show(comboboxentry_boxRefinement_createdBoxes); + gtk_table_attach(GTK_TABLE(table1),comboboxentry_boxRefinement_createdBoxes, + 1, 2, 6, 7, + (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0); - - gtk_editable_set_editable - ( - GTK_EDITABLE - ( - GTK_COMBO(comboboxentry_boxRefinement_createdBoxes)->entry - ), - 0 - ); - - + + gtk_editable_set_editable + ( + GTK_EDITABLE + ( + GTK_COMBO(comboboxentry_boxRefinement_createdBoxes)->entry + ), + 0 + ); + + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - //- create a label for selected cell size - GtkWidget* label_boxRefinement_selectedCellSize = - gtk_label_new("Cell size [m]"); - gtk_widget_show(label_boxRefinement_selectedCellSize); - gtk_table_attach(GTK_TABLE(table1), label_boxRefinement_selectedCellSize, - 0, 1, 7, 8, - (GtkAttachOptions)(GTK_FILL), + //- create a label for selected cell size + GtkWidget* label_boxRefinement_selectedCellSize = + gtk_label_new("Cell size [m]"); + gtk_widget_show(label_boxRefinement_selectedCellSize); + gtk_table_attach(GTK_TABLE(table1), label_boxRefinement_selectedCellSize, + 0, 1, 7, 8, + (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0); - gtk_misc_set_alignment - ( - GTK_MISC(label_boxRefinement_selectedCellSize), 0, 0.5 - ); - + gtk_misc_set_alignment + ( + GTK_MISC(label_boxRefinement_selectedCellSize), 0, 0.5 + ); + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - //- create a label for selected cell size - GtkWidget* entry_boxRefinement_selectedCellSize = gtk_entry_new(); - gtk_widget_show(entry_boxRefinement_selectedCellSize); - gtk_table_attach(GTK_TABLE(table1), entry_boxRefinement_selectedCellSize, - 1, 4, 7, 8, - (GtkAttachOptions)(GTK_FILL), + //- create a label for selected cell size + GtkWidget* entry_boxRefinement_selectedCellSize = gtk_entry_new(); + gtk_widget_show(entry_boxRefinement_selectedCellSize); + gtk_table_attach(GTK_TABLE(table1), entry_boxRefinement_selectedCellSize, + 1, 4, 7, 8, + (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0); - + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - //- create labels for axes - label_axes = gtk_label_new("X"); - gtk_widget_show(label_axes); - gtk_table_attach(GTK_TABLE(table1), label_axes, - 1, 2, 8, 9, - (GtkAttachOptions)(GTK_FILL), + //- create labels for axes + label_axes = gtk_label_new("X"); + gtk_widget_show(label_axes); + gtk_table_attach(GTK_TABLE(table1), label_axes, + 1, 2, 8, 9, + (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0); - gtk_misc_set_alignment(GTK_MISC(label_axes), 0, 0.5); - - label_axes = gtk_label_new("Y"); - gtk_widget_show(label_axes); - gtk_table_attach(GTK_TABLE(table1), label_axes, - 2, 3, 8, 9, - (GtkAttachOptions)(GTK_FILL), + gtk_misc_set_alignment(GTK_MISC(label_axes), 0, 0.5); + + label_axes = gtk_label_new("Y"); + gtk_widget_show(label_axes); + gtk_table_attach(GTK_TABLE(table1), label_axes, + 2, 3, 8, 9, + (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0); - gtk_misc_set_alignment(GTK_MISC(label_axes), 0, 0.5); - - label_axes = gtk_label_new("Z"); - gtk_widget_show(label_axes); - gtk_table_attach(GTK_TABLE(table1), label_axes, - 3, 4, 8, 9, - (GtkAttachOptions)(GTK_FILL), + gtk_misc_set_alignment(GTK_MISC(label_axes), 0, 0.5); + + label_axes = gtk_label_new("Z"); + gtk_widget_show(label_axes); + gtk_table_attach(GTK_TABLE(table1), label_axes, + 3, 4, 8, 9, + (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0); - gtk_misc_set_alignment(GTK_MISC(label_axes), 0, 0.5); - + gtk_misc_set_alignment(GTK_MISC(label_axes), 0, 0.5); + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - //- label for box centre - GtkWidget* label_boxRefinement_selectedCentre = gtk_label_new("Centre"); - gtk_widget_show(label_boxRefinement_selectedCentre); - gtk_table_attach(GTK_TABLE(table1), label_boxRefinement_selectedCentre, - 0, 1, 9, 10, - (GtkAttachOptions)(GTK_FILL), + //- label for box centre + GtkWidget* label_boxRefinement_selectedCentre = gtk_label_new("Centre"); + gtk_widget_show(label_boxRefinement_selectedCentre); + gtk_table_attach(GTK_TABLE(table1), label_boxRefinement_selectedCentre, + 0, 1, 9, 10, + (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0); - gtk_misc_set_alignment(GTK_MISC(label_boxRefinement_selectedCentre), 0, 0.5); + gtk_misc_set_alignment(GTK_MISC(label_boxRefinement_selectedCentre), 0, 0.5); // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - //- entries for selected box centre - GtkWidget* entry_boxRefinement_selectedCentreX = gtk_entry_new(); - gtk_widget_show(entry_boxRefinement_selectedCentreX); - gtk_table_attach(GTK_TABLE(table1), entry_boxRefinement_selectedCentreX, - 1, 2, 9, 10, - (GtkAttachOptions)(GTK_FILL), + //- entries for selected box centre + GtkWidget* entry_boxRefinement_selectedCentreX = gtk_entry_new(); + gtk_widget_show(entry_boxRefinement_selectedCentreX); + gtk_table_attach(GTK_TABLE(table1), entry_boxRefinement_selectedCentreX, + 1, 2, 9, 10, + (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0); - - GtkWidget* entry_boxRefinement_selectedCentreY = gtk_entry_new(); - gtk_widget_show(entry_boxRefinement_selectedCentreY); - gtk_table_attach(GTK_TABLE(table1), entry_boxRefinement_selectedCentreY, - 2, 3, 9, 10, - (GtkAttachOptions)(GTK_FILL), + + GtkWidget* entry_boxRefinement_selectedCentreY = gtk_entry_new(); + gtk_widget_show(entry_boxRefinement_selectedCentreY); + gtk_table_attach(GTK_TABLE(table1), entry_boxRefinement_selectedCentreY, + 2, 3, 9, 10, + (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0); - - GtkWidget* entry_boxRefinement_selectedCentreZ = gtk_entry_new(); - gtk_widget_show(entry_boxRefinement_selectedCentreZ); - gtk_table_attach(GTK_TABLE(table1), entry_boxRefinement_selectedCentreZ, - 3, 4, 9, 10, - (GtkAttachOptions)(GTK_FILL), + + GtkWidget* entry_boxRefinement_selectedCentreZ = gtk_entry_new(); + gtk_widget_show(entry_boxRefinement_selectedCentreZ); + gtk_table_attach(GTK_TABLE(table1), entry_boxRefinement_selectedCentreZ, + 3, 4, 9, 10, + (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0); - + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - //- label for selected side lengths - GtkWidget* label_boxRefinement_selectedLengths = - gtk_label_new("Side lengths"); - gtk_widget_show(label_boxRefinement_selectedLengths); - gtk_table_attach(GTK_TABLE(table1), label_boxRefinement_selectedLengths, - 0, 1, 10, 11, - (GtkAttachOptions)(GTK_FILL), + //- label for selected side lengths + GtkWidget* label_boxRefinement_selectedLengths = + gtk_label_new("Side lengths"); + gtk_widget_show(label_boxRefinement_selectedLengths); + gtk_table_attach(GTK_TABLE(table1), label_boxRefinement_selectedLengths, + 0, 1, 10, 11, + (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0); - gtk_misc_set_alignment - ( - GTK_MISC(label_boxRefinement_selectedLengths), 0, 0.5 - ); + gtk_misc_set_alignment + ( + GTK_MISC(label_boxRefinement_selectedLengths), 0, 0.5 + ); // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - //- entries for side lengths - GtkWidget* entry_boxRefinement_selectedLengthX = gtk_entry_new(); - gtk_widget_show(entry_boxRefinement_selectedLengthX); - gtk_table_attach(GTK_TABLE(table1), entry_boxRefinement_selectedLengthX, - 1, 2, 10, 11, - (GtkAttachOptions)(GTK_FILL), + //- entries for side lengths + GtkWidget* entry_boxRefinement_selectedLengthX = gtk_entry_new(); + gtk_widget_show(entry_boxRefinement_selectedLengthX); + gtk_table_attach(GTK_TABLE(table1), entry_boxRefinement_selectedLengthX, + 1, 2, 10, 11, + (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0); - - GtkWidget* entry_boxRefinement_selectedLengthY = gtk_entry_new(); - gtk_widget_show(entry_boxRefinement_selectedLengthY); - gtk_table_attach(GTK_TABLE(table1), entry_boxRefinement_selectedLengthY, - 2, 3, 10, 11, - (GtkAttachOptions)(GTK_FILL), + + GtkWidget* entry_boxRefinement_selectedLengthY = gtk_entry_new(); + gtk_widget_show(entry_boxRefinement_selectedLengthY); + gtk_table_attach(GTK_TABLE(table1), entry_boxRefinement_selectedLengthY, + 2, 3, 10, 11, + (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0); - - GtkWidget* entry_boxRefinement_selectedLengthZ = gtk_entry_new(); - gtk_widget_show(entry_boxRefinement_selectedLengthZ); - gtk_table_attach(GTK_TABLE(table1), entry_boxRefinement_selectedLengthZ, - 3, 4, 10, 11, - (GtkAttachOptions)(GTK_FILL), + + GtkWidget* entry_boxRefinement_selectedLengthZ = gtk_entry_new(); + gtk_widget_show(entry_boxRefinement_selectedLengthZ); + gtk_table_attach(GTK_TABLE(table1), entry_boxRefinement_selectedLengthZ, + 3, 4, 10, 11, + (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0); - + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - //- set the button for removing patches - GtkWidget* button2 = gtk_button_new(); - gtk_widget_show(button2); - gtk_table_attach - ( - GTK_TABLE(table1), - button2, - 4, 5, 6, 11, - (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 5 - ); - - g_signal_connect - ( - G_OBJECT(button2), - "clicked", - G_CALLBACK(removeBoxRefinement), - boxRefinementFramePtr_ - ); - - GtkWidget* alignment2 = gtk_alignment_new(0.5, 0.5, 0, 0); - gtk_widget_show(alignment2); - gtk_container_add(GTK_CONTAINER(button2), alignment2); - - GtkWidget* hbox2 = gtk_hbox_new(FALSE, 2); - gtk_widget_show(hbox2); - gtk_container_add(GTK_CONTAINER(alignment2), hbox2); - - GtkWidget* image2 = - gtk_image_new_from_stock("gtk-remove", GTK_ICON_SIZE_BUTTON); - gtk_widget_show(image2); - gtk_box_pack_start(GTK_BOX (hbox2), image2, FALSE, FALSE, 0); - - GtkWidget* label5 = gtk_label_new_with_mnemonic("Remove"); - gtk_widget_show(label5); - gtk_box_pack_start(GTK_BOX (hbox2), label5, FALSE, FALSE, 0); - + //- set the button for removing patches + GtkWidget* button2 = gtk_button_new(); + gtk_widget_show(button2); + gtk_table_attach + ( + GTK_TABLE(table1), + button2, + 4, 5, 6, 11, + (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 5 + ); + + g_signal_connect + ( + G_OBJECT(button2), + "clicked", + G_CALLBACK(removeBoxRefinement), + boxRefinementFramePtr_ + ); + + GtkWidget* alignment2 = gtk_alignment_new(0.5, 0.5, 0, 0); + gtk_widget_show(alignment2); + gtk_container_add(GTK_CONTAINER(button2), alignment2); + + GtkWidget* hbox2 = gtk_hbox_new(FALSE, 2); + gtk_widget_show(hbox2); + gtk_container_add(GTK_CONTAINER(alignment2), hbox2); + + GtkWidget* image2 = + gtk_image_new_from_stock("gtk-remove", GTK_ICON_SIZE_BUTTON); + gtk_widget_show(image2); + gtk_box_pack_start(GTK_BOX (hbox2), image2, FALSE, FALSE, 0); + + GtkWidget* label5 = gtk_label_new_with_mnemonic("Remove"); + gtk_widget_show(label5); + gtk_box_pack_start(GTK_BOX (hbox2), label5, FALSE, FALSE, 0); + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - /* Store pointers to all widgets, for use by lookup_widget(). */ - GLADE_HOOKUP_OBJECT_NO_REF - ( - boxRefinementFramePtr_, - boxRefinementFramePtr_, - "boxRefinementFramePtr_"); - GLADE_HOOKUP_OBJECT - ( - boxRefinementFramePtr_, - table1, - "table1" - ); - GLADE_HOOKUP_OBJECT - ( - boxRefinementFramePtr_, - entry_boxName, - "entry_boxName" - ); - GLADE_HOOKUP_OBJECT - ( - boxRefinementFramePtr_, - entry_boxRefinement_cellSize, - "entry_boxRefinement_cellSize" - ); - GLADE_HOOKUP_OBJECT - ( - boxRefinementFramePtr_, - entry_boxRefinement_centreX, - "entry_boxRefinement_centreX" - ); - GLADE_HOOKUP_OBJECT - ( - boxRefinementFramePtr_, - entry_boxRefinement_centreY, - "entry_boxRefinement_centreY" - ); - GLADE_HOOKUP_OBJECT - ( - boxRefinementFramePtr_, - entry_boxRefinement_centreZ, - "entry_boxRefinement_centreZ" - ); - GLADE_HOOKUP_OBJECT - ( - boxRefinementFramePtr_, - entry_boxRefinement_lengthX, - "entry_boxRefinement_lengthX" - ); - GLADE_HOOKUP_OBJECT - ( - boxRefinementFramePtr_, - entry_boxRefinement_lengthY, - "entry_boxRefinement_lengthY" - ); - GLADE_HOOKUP_OBJECT - ( - boxRefinementFramePtr_, - entry_boxRefinement_lengthZ, - "entry_boxRefinement_lengthZ" - ); - GLADE_HOOKUP_OBJECT - ( - boxRefinementFramePtr_, - comboboxentry_boxRefinement_createdBoxes, - "comboboxentry_boxRefinement_createdBoxes" - ); - GLADE_HOOKUP_OBJECT - ( - boxRefinementFramePtr_, - entry_boxRefinement_selectedCellSize, - "entry_boxRefinement_selectedCellSize" - ); - GLADE_HOOKUP_OBJECT - ( - boxRefinementFramePtr_, - entry_boxRefinement_selectedCentreX, - "entry_boxRefinement_selectedCentreX" - ); - GLADE_HOOKUP_OBJECT - ( - boxRefinementFramePtr_, - entry_boxRefinement_selectedCentreY, - "entry_boxRefinement_selectedCentreY" - ); - GLADE_HOOKUP_OBJECT - ( - boxRefinementFramePtr_, - entry_boxRefinement_selectedCentreZ, - "entry_boxRefinement_selectedCentreZ" - ); - GLADE_HOOKUP_OBJECT - ( - boxRefinementFramePtr_, - entry_boxRefinement_selectedLengthX, - "entry_boxRefinement_selectedLengthX" - ); - GLADE_HOOKUP_OBJECT - ( - boxRefinementFramePtr_, - entry_boxRefinement_selectedLengthY, - "entry_boxRefinement_selectedLengthY" - ); - GLADE_HOOKUP_OBJECT - ( - boxRefinementFramePtr_, - entry_boxRefinement_selectedLengthZ, - "entry_boxRefinement_selectedLengthZ" - ); - - updateBoxRefinements(boxRefinementFramePtr_); - - g_signal_connect - ( - G_OBJECT - ( - GTK_ENTRY - ( - GTK_COMBO(comboboxentry_boxRefinement_createdBoxes)->entry - ) - ), - "changed", - G_CALLBACK(showDataForBoxRefinement), - boxRefinementFramePtr_ - ); - - g_signal_connect - ( - G_OBJECT(entry_boxRefinement_selectedCellSize), - "changed", - G_CALLBACK(resetValuesForSelectedBox), - boxRefinementFramePtr_ - ); - - g_signal_connect - ( - G_OBJECT(entry_boxRefinement_selectedCentreX), - "changed", - G_CALLBACK(resetValuesForSelectedBox), - boxRefinementFramePtr_ - ); - - g_signal_connect - ( - G_OBJECT(entry_boxRefinement_selectedCentreY), - "changed", - G_CALLBACK(resetValuesForSelectedBox), - boxRefinementFramePtr_ - ); - - g_signal_connect - ( - G_OBJECT(entry_boxRefinement_selectedCentreZ), - "changed", - G_CALLBACK(resetValuesForSelectedBox), - boxRefinementFramePtr_ - ); - - g_signal_connect - ( - G_OBJECT(entry_boxRefinement_selectedLengthX), - "changed", - G_CALLBACK(resetValuesForSelectedBox), - boxRefinementFramePtr_ - ); - - g_signal_connect - ( - G_OBJECT(entry_boxRefinement_selectedLengthY), - "changed", - G_CALLBACK(resetValuesForSelectedBox), - boxRefinementFramePtr_ - ); - - g_signal_connect - ( - G_OBJECT(entry_boxRefinement_selectedLengthZ), - "changed", - G_CALLBACK(resetValuesForSelectedBox), - boxRefinementFramePtr_ - ); - - gtk_widget_show(boxRefinementFramePtr_); + /* Store pointers to all widgets, for use by lookup_widget(). */ + GLADE_HOOKUP_OBJECT_NO_REF + ( + boxRefinementFramePtr_, + boxRefinementFramePtr_, + "boxRefinementFramePtr_"); + GLADE_HOOKUP_OBJECT + ( + boxRefinementFramePtr_, + table1, + "table1" + ); + GLADE_HOOKUP_OBJECT + ( + boxRefinementFramePtr_, + entry_boxName, + "entry_boxName" + ); + GLADE_HOOKUP_OBJECT + ( + boxRefinementFramePtr_, + entry_boxRefinement_cellSize, + "entry_boxRefinement_cellSize" + ); + GLADE_HOOKUP_OBJECT + ( + boxRefinementFramePtr_, + entry_boxRefinement_centreX, + "entry_boxRefinement_centreX" + ); + GLADE_HOOKUP_OBJECT + ( + boxRefinementFramePtr_, + entry_boxRefinement_centreY, + "entry_boxRefinement_centreY" + ); + GLADE_HOOKUP_OBJECT + ( + boxRefinementFramePtr_, + entry_boxRefinement_centreZ, + "entry_boxRefinement_centreZ" + ); + GLADE_HOOKUP_OBJECT + ( + boxRefinementFramePtr_, + entry_boxRefinement_lengthX, + "entry_boxRefinement_lengthX" + ); + GLADE_HOOKUP_OBJECT + ( + boxRefinementFramePtr_, + entry_boxRefinement_lengthY, + "entry_boxRefinement_lengthY" + ); + GLADE_HOOKUP_OBJECT + ( + boxRefinementFramePtr_, + entry_boxRefinement_lengthZ, + "entry_boxRefinement_lengthZ" + ); + GLADE_HOOKUP_OBJECT + ( + boxRefinementFramePtr_, + comboboxentry_boxRefinement_createdBoxes, + "comboboxentry_boxRefinement_createdBoxes" + ); + GLADE_HOOKUP_OBJECT + ( + boxRefinementFramePtr_, + entry_boxRefinement_selectedCellSize, + "entry_boxRefinement_selectedCellSize" + ); + GLADE_HOOKUP_OBJECT + ( + boxRefinementFramePtr_, + entry_boxRefinement_selectedCentreX, + "entry_boxRefinement_selectedCentreX" + ); + GLADE_HOOKUP_OBJECT + ( + boxRefinementFramePtr_, + entry_boxRefinement_selectedCentreY, + "entry_boxRefinement_selectedCentreY" + ); + GLADE_HOOKUP_OBJECT + ( + boxRefinementFramePtr_, + entry_boxRefinement_selectedCentreZ, + "entry_boxRefinement_selectedCentreZ" + ); + GLADE_HOOKUP_OBJECT + ( + boxRefinementFramePtr_, + entry_boxRefinement_selectedLengthX, + "entry_boxRefinement_selectedLengthX" + ); + GLADE_HOOKUP_OBJECT + ( + boxRefinementFramePtr_, + entry_boxRefinement_selectedLengthY, + "entry_boxRefinement_selectedLengthY" + ); + GLADE_HOOKUP_OBJECT + ( + boxRefinementFramePtr_, + entry_boxRefinement_selectedLengthZ, + "entry_boxRefinement_selectedLengthZ" + ); + + updateBoxRefinements(boxRefinementFramePtr_); + + g_signal_connect + ( + G_OBJECT + ( + GTK_ENTRY + ( + GTK_COMBO(comboboxentry_boxRefinement_createdBoxes)->entry + ) + ), + "changed", + G_CALLBACK(showDataForBoxRefinement), + boxRefinementFramePtr_ + ); + + g_signal_connect + ( + G_OBJECT(entry_boxRefinement_selectedCellSize), + "changed", + G_CALLBACK(resetValuesForSelectedBox), + boxRefinementFramePtr_ + ); + + g_signal_connect + ( + G_OBJECT(entry_boxRefinement_selectedCentreX), + "changed", + G_CALLBACK(resetValuesForSelectedBox), + boxRefinementFramePtr_ + ); + + g_signal_connect + ( + G_OBJECT(entry_boxRefinement_selectedCentreY), + "changed", + G_CALLBACK(resetValuesForSelectedBox), + boxRefinementFramePtr_ + ); + + g_signal_connect + ( + G_OBJECT(entry_boxRefinement_selectedCentreZ), + "changed", + G_CALLBACK(resetValuesForSelectedBox), + boxRefinementFramePtr_ + ); + + g_signal_connect + ( + G_OBJECT(entry_boxRefinement_selectedLengthX), + "changed", + G_CALLBACK(resetValuesForSelectedBox), + boxRefinementFramePtr_ + ); + + g_signal_connect + ( + G_OBJECT(entry_boxRefinement_selectedLengthY), + "changed", + G_CALLBACK(resetValuesForSelectedBox), + boxRefinementFramePtr_ + ); + + g_signal_connect + ( + G_OBJECT(entry_boxRefinement_selectedLengthZ), + "changed", + G_CALLBACK(resetValuesForSelectedBox), + boxRefinementFramePtr_ + ); + + gtk_widget_show(boxRefinementFramePtr_); } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/GUI/meshGenGTK/meshGenGTKConeRefinement.C b/GUI/meshGenGTK/meshGenGTKConeRefinement.C index 43b978e8..791b5121 100644 --- a/GUI/meshGenGTK/meshGenGTKConeRefinement.C +++ b/GUI/meshGenGTK/meshGenGTKConeRefinement.C @@ -43,1198 +43,1198 @@ extern "C" static void showDataForConeRefinement ( - GtkWidget* widget, - GtkWidget* coneRefinementFramePtr + GtkWidget* widget, + GtkWidget* coneRefinementFramePtr ) { - GtkWidget* comboboxentry_coneRefinement_createdCones = - (GtkWidget*)g_object_get_data - ( - G_OBJECT(coneRefinementFramePtr), - "comboboxentry_coneRefinement_createdCones" - ); - GtkWidget* entry_coneRefinement_selectedCellSize = - (GtkWidget*)g_object_get_data - ( - G_OBJECT(coneRefinementFramePtr), - "entry_coneRefinement_selectedCellSize" - ); - GtkWidget* entry_coneRefinement_selectedP0X = - (GtkWidget*)g_object_get_data - ( - G_OBJECT(coneRefinementFramePtr), - "entry_coneRefinement_selectedP0X" - ); - GtkWidget* entry_coneRefinement_selectedP0Y = - (GtkWidget*)g_object_get_data - ( - G_OBJECT(coneRefinementFramePtr), - "entry_coneRefinement_selectedP0Y" - ); - GtkWidget* entry_coneRefinement_selectedP0Z = - (GtkWidget*)g_object_get_data - ( - G_OBJECT(coneRefinementFramePtr), - "entry_coneRefinement_selectedP0Z" - ); - GtkWidget* entry_coneRefinement_selectedRadius0 = - (GtkWidget*)g_object_get_data - ( - G_OBJECT(coneRefinementFramePtr), - "entry_coneRefinement_selectedRadius0" - ); - GtkWidget* entry_coneRefinement_selectedP1X = - (GtkWidget*)g_object_get_data - ( - G_OBJECT(coneRefinementFramePtr), - "entry_coneRefinement_selectedP1X" - ); - GtkWidget* entry_coneRefinement_selectedP1Y = - (GtkWidget*)g_object_get_data - ( - G_OBJECT(coneRefinementFramePtr), - "entry_coneRefinement_selectedP1Y" - ); - GtkWidget* entry_coneRefinement_selectedP1Z = - (GtkWidget*)g_object_get_data - ( - G_OBJECT(coneRefinementFramePtr), - "entry_coneRefinement_selectedP1Z" - ); - GtkWidget* entry_coneRefinement_selectedRadius1 = - (GtkWidget*)g_object_get_data - ( - G_OBJECT(coneRefinementFramePtr), - "entry_coneRefinement_selectedRadius1" - ); - - //- find the object in the dictionary - const word coneName = - gtk_entry_get_text - ( - GTK_ENTRY - ( - GTK_COMBO(comboboxentry_coneRefinement_createdCones)->entry - ) - ); - - const PtrList<entry> refs = guiPtr->objectRefinements(); - - forAll(refs, refI) - if( refs[refI].keyword() == coneName ) - { - const dictionary dict = refs[refI].dict(); - - gtk_entry_set_text - ( - GTK_ENTRY(entry_coneRefinement_selectedCellSize), - help::scalarToText - ( - scalar(readScalar(dict.lookup("cellSize"))) - ).c_str() - ); - const vector p0(dict.lookup("p0")); - gtk_entry_set_text - ( - GTK_ENTRY(entry_coneRefinement_selectedP0X), - help::scalarToText(p0.x()).c_str() - ); - gtk_entry_set_text - ( - GTK_ENTRY(entry_coneRefinement_selectedP0Y), - help::scalarToText(p0.y()).c_str() - ); - gtk_entry_set_text - ( - GTK_ENTRY(entry_coneRefinement_selectedP0Z), - help::scalarToText(p0.z()).c_str() - ); - const scalar r0(readScalar(dict.lookup("radius0"))); - gtk_entry_set_text - ( - GTK_ENTRY(entry_coneRefinement_selectedRadius0), - help::scalarToText(r0).c_str() - ); - - const vector p1(dict.lookup("p1")); - gtk_entry_set_text - ( - GTK_ENTRY(entry_coneRefinement_selectedP1X), - help::scalarToText(p1.x()).c_str() - ); - gtk_entry_set_text - ( - GTK_ENTRY(entry_coneRefinement_selectedP1Y), - help::scalarToText(p1.y()).c_str() - ); - gtk_entry_set_text - ( - GTK_ENTRY(entry_coneRefinement_selectedP1Z), - help::scalarToText(p1.z()).c_str() - ); - const scalar r1(readScalar(dict.lookup("radius1"))); - gtk_entry_set_text - ( - GTK_ENTRY(entry_coneRefinement_selectedRadius1), - help::scalarToText(r1).c_str() - ); - - return; - } - - gtk_entry_set_text(GTK_ENTRY(entry_coneRefinement_selectedCellSize), ""); - gtk_entry_set_text(GTK_ENTRY(entry_coneRefinement_selectedP0X), ""); - gtk_entry_set_text(GTK_ENTRY(entry_coneRefinement_selectedP0Y), ""); - gtk_entry_set_text(GTK_ENTRY(entry_coneRefinement_selectedP0Z), ""); - gtk_entry_set_text(GTK_ENTRY(entry_coneRefinement_selectedRadius0), ""); - gtk_entry_set_text(GTK_ENTRY(entry_coneRefinement_selectedP1X), ""); - gtk_entry_set_text(GTK_ENTRY(entry_coneRefinement_selectedP1Y), ""); - gtk_entry_set_text(GTK_ENTRY(entry_coneRefinement_selectedP1Z), ""); - gtk_entry_set_text(GTK_ENTRY(entry_coneRefinement_selectedRadius1), ""); + GtkWidget* comboboxentry_coneRefinement_createdCones = + (GtkWidget*)g_object_get_data + ( + G_OBJECT(coneRefinementFramePtr), + "comboboxentry_coneRefinement_createdCones" + ); + GtkWidget* entry_coneRefinement_selectedCellSize = + (GtkWidget*)g_object_get_data + ( + G_OBJECT(coneRefinementFramePtr), + "entry_coneRefinement_selectedCellSize" + ); + GtkWidget* entry_coneRefinement_selectedP0X = + (GtkWidget*)g_object_get_data + ( + G_OBJECT(coneRefinementFramePtr), + "entry_coneRefinement_selectedP0X" + ); + GtkWidget* entry_coneRefinement_selectedP0Y = + (GtkWidget*)g_object_get_data + ( + G_OBJECT(coneRefinementFramePtr), + "entry_coneRefinement_selectedP0Y" + ); + GtkWidget* entry_coneRefinement_selectedP0Z = + (GtkWidget*)g_object_get_data + ( + G_OBJECT(coneRefinementFramePtr), + "entry_coneRefinement_selectedP0Z" + ); + GtkWidget* entry_coneRefinement_selectedRadius0 = + (GtkWidget*)g_object_get_data + ( + G_OBJECT(coneRefinementFramePtr), + "entry_coneRefinement_selectedRadius0" + ); + GtkWidget* entry_coneRefinement_selectedP1X = + (GtkWidget*)g_object_get_data + ( + G_OBJECT(coneRefinementFramePtr), + "entry_coneRefinement_selectedP1X" + ); + GtkWidget* entry_coneRefinement_selectedP1Y = + (GtkWidget*)g_object_get_data + ( + G_OBJECT(coneRefinementFramePtr), + "entry_coneRefinement_selectedP1Y" + ); + GtkWidget* entry_coneRefinement_selectedP1Z = + (GtkWidget*)g_object_get_data + ( + G_OBJECT(coneRefinementFramePtr), + "entry_coneRefinement_selectedP1Z" + ); + GtkWidget* entry_coneRefinement_selectedRadius1 = + (GtkWidget*)g_object_get_data + ( + G_OBJECT(coneRefinementFramePtr), + "entry_coneRefinement_selectedRadius1" + ); + + //- find the object in the dictionary + const word coneName = + gtk_entry_get_text + ( + GTK_ENTRY + ( + GTK_COMBO(comboboxentry_coneRefinement_createdCones)->entry + ) + ); + + const PtrList<entry> refs = guiPtr->objectRefinements(); + + forAll(refs, refI) + if( refs[refI].keyword() == coneName ) + { + const dictionary dict = refs[refI].dict(); + + gtk_entry_set_text + ( + GTK_ENTRY(entry_coneRefinement_selectedCellSize), + help::scalarToText + ( + scalar(readScalar(dict.lookup("cellSize"))) + ).c_str() + ); + const vector p0(dict.lookup("p0")); + gtk_entry_set_text + ( + GTK_ENTRY(entry_coneRefinement_selectedP0X), + help::scalarToText(p0.x()).c_str() + ); + gtk_entry_set_text + ( + GTK_ENTRY(entry_coneRefinement_selectedP0Y), + help::scalarToText(p0.y()).c_str() + ); + gtk_entry_set_text + ( + GTK_ENTRY(entry_coneRefinement_selectedP0Z), + help::scalarToText(p0.z()).c_str() + ); + const scalar r0(readScalar(dict.lookup("radius0"))); + gtk_entry_set_text + ( + GTK_ENTRY(entry_coneRefinement_selectedRadius0), + help::scalarToText(r0).c_str() + ); + + const vector p1(dict.lookup("p1")); + gtk_entry_set_text + ( + GTK_ENTRY(entry_coneRefinement_selectedP1X), + help::scalarToText(p1.x()).c_str() + ); + gtk_entry_set_text + ( + GTK_ENTRY(entry_coneRefinement_selectedP1Y), + help::scalarToText(p1.y()).c_str() + ); + gtk_entry_set_text + ( + GTK_ENTRY(entry_coneRefinement_selectedP1Z), + help::scalarToText(p1.z()).c_str() + ); + const scalar r1(readScalar(dict.lookup("radius1"))); + gtk_entry_set_text + ( + GTK_ENTRY(entry_coneRefinement_selectedRadius1), + help::scalarToText(r1).c_str() + ); + + return; + } + + gtk_entry_set_text(GTK_ENTRY(entry_coneRefinement_selectedCellSize), ""); + gtk_entry_set_text(GTK_ENTRY(entry_coneRefinement_selectedP0X), ""); + gtk_entry_set_text(GTK_ENTRY(entry_coneRefinement_selectedP0Y), ""); + gtk_entry_set_text(GTK_ENTRY(entry_coneRefinement_selectedP0Z), ""); + gtk_entry_set_text(GTK_ENTRY(entry_coneRefinement_selectedRadius0), ""); + gtk_entry_set_text(GTK_ENTRY(entry_coneRefinement_selectedP1X), ""); + gtk_entry_set_text(GTK_ENTRY(entry_coneRefinement_selectedP1Y), ""); + gtk_entry_set_text(GTK_ENTRY(entry_coneRefinement_selectedP1Z), ""); + gtk_entry_set_text(GTK_ENTRY(entry_coneRefinement_selectedRadius1), ""); } static void resetValuesForSelectedCone ( - GtkWidget* widget, - GtkWidget* coneRefinementFramePtr + GtkWidget* widget, + GtkWidget* coneRefinementFramePtr ) { - GtkWidget* comboboxentry_coneRefinement_createdCones = - (GtkWidget*)g_object_get_data - ( - G_OBJECT(coneRefinementFramePtr), - "comboboxentry_coneRefinement_createdCones" - ); - GtkWidget* entry_coneRefinement_selectedCellSize = - (GtkWidget*)g_object_get_data - ( - G_OBJECT(coneRefinementFramePtr), - "entry_coneRefinement_selectedCellSize" - ); - GtkWidget* entry_coneRefinement_selectedP0X = - (GtkWidget*)g_object_get_data - ( - G_OBJECT(coneRefinementFramePtr), - "entry_coneRefinement_selectedP0X" - ); - GtkWidget* entry_coneRefinement_selectedP0Y = - (GtkWidget*)g_object_get_data - ( - G_OBJECT(coneRefinementFramePtr), - "entry_coneRefinement_selectedP0Y" - ); - GtkWidget* entry_coneRefinement_selectedP0Z = - (GtkWidget*)g_object_get_data - ( - G_OBJECT(coneRefinementFramePtr), - "entry_coneRefinement_selectedP0Z" - ); - GtkWidget* entry_coneRefinement_selectedRadius0 = - (GtkWidget*)g_object_get_data - ( - G_OBJECT(coneRefinementFramePtr), - "entry_coneRefinement_selectedRadius0" - ); - GtkWidget* entry_coneRefinement_selectedP1X = - (GtkWidget*)g_object_get_data - ( - G_OBJECT(coneRefinementFramePtr), - "entry_coneRefinement_selectedP1X" - ); - GtkWidget* entry_coneRefinement_selectedP1Y = - (GtkWidget*)g_object_get_data - ( - G_OBJECT(coneRefinementFramePtr), - "entry_coneRefinement_selectedP1Y" - ); - GtkWidget* entry_coneRefinement_selectedP1Z = - (GtkWidget*)g_object_get_data - ( - G_OBJECT(coneRefinementFramePtr), - "entry_coneRefinement_selectedP1Z" - ); - GtkWidget* entry_coneRefinement_selectedRadius1 = - (GtkWidget*)g_object_get_data - ( - G_OBJECT(coneRefinementFramePtr), - "entry_coneRefinement_selectedRadius1" - ); - - const word name = - gtk_entry_get_text - ( - GTK_ENTRY - ( - GTK_COMBO - ( - comboboxentry_coneRefinement_createdCones - )->entry - ) - ); - - if( name == "" ) - return; - - const PtrList<entry> refs = guiPtr->objectRefinements(); - dictionary dict; - forAll(refs, refI) - if( refs[refI].keyword() == name ) - dict = refs[refI].dict(); - guiPtr->removeObjectRefinement(name); - if( widget == entry_coneRefinement_selectedCellSize ) - { - const word size = - gtk_entry_get_text(GTK_ENTRY(entry_coneRefinement_selectedCellSize)); - dict.remove("cellSize"); - dict.add("cellSize", help::textToScalar(size)); - } - else if( widget == entry_coneRefinement_selectedP0X ) - { - point p0(dict.lookup("p0")); - const word c = - gtk_entry_get_text(GTK_ENTRY(entry_coneRefinement_selectedP0X)); - dict.remove("p0"); - p0.x() = help::textToScalar(c); - dict.add("p0", p0); - } - else if( widget == entry_coneRefinement_selectedP0Y ) - { - point p0(dict.lookup("p0")); - const word c = - gtk_entry_get_text(GTK_ENTRY(entry_coneRefinement_selectedP0Y)); - dict.remove("p0"); - p0.y() = help::textToScalar(c); - dict.add("p0", p0); - } - else if( widget == entry_coneRefinement_selectedP0Z ) - { - point p0(dict.lookup("p0")); - const word c = - gtk_entry_get_text(GTK_ENTRY(entry_coneRefinement_selectedP0Z)); - dict.remove("p0"); - p0.z() = help::textToScalar(c); - dict.add("p0", p0); - } - else if( widget == entry_coneRefinement_selectedRadius0 ) - { - scalar r0(readScalar(dict.lookup("radius0"))); - const word c = - gtk_entry_get_text - ( - GTK_ENTRY(entry_coneRefinement_selectedRadius0) - ); - dict.remove("radius0"); - r0 = help::textToScalar(c); - dict.add("radius0", r0); - } - else if( widget == entry_coneRefinement_selectedP1X ) - { - const word l = - gtk_entry_get_text(GTK_ENTRY(entry_coneRefinement_selectedP1X)); - point p1(dict.lookup("p1")); - dict.remove("p1"); - p1.x() = help::textToScalar(l); - dict.add("p1", p1); - } - else if( widget == entry_coneRefinement_selectedP1Y ) - { - const word l = - gtk_entry_get_text(GTK_ENTRY(entry_coneRefinement_selectedP1Y)); - point p1(dict.lookup("p1")); - dict.remove("p1"); - p1.y() = help::textToScalar(l); - dict.add("p1", p1); - } - else if( widget == entry_coneRefinement_selectedP1Z ) - { - const word l = - gtk_entry_get_text(GTK_ENTRY(entry_coneRefinement_selectedP1Z)); - point p1(dict.lookup("p1")); - dict.remove("p1"); - p1.z() = help::textToScalar(l); - dict.add("p1", p1); - } - else if( widget == entry_coneRefinement_selectedRadius1 ) - { - scalar r1(readScalar(dict.lookup("radius1"))); - const word c = - gtk_entry_get_text - ( - GTK_ENTRY(entry_coneRefinement_selectedRadius1) - ); - dict.remove("radius1"); - r1 = help::textToScalar(c); - dict.add("radius1", r1); - } - - coneRefinement cr(name, dict); - guiPtr->addObjectRefinement(cr); + GtkWidget* comboboxentry_coneRefinement_createdCones = + (GtkWidget*)g_object_get_data + ( + G_OBJECT(coneRefinementFramePtr), + "comboboxentry_coneRefinement_createdCones" + ); + GtkWidget* entry_coneRefinement_selectedCellSize = + (GtkWidget*)g_object_get_data + ( + G_OBJECT(coneRefinementFramePtr), + "entry_coneRefinement_selectedCellSize" + ); + GtkWidget* entry_coneRefinement_selectedP0X = + (GtkWidget*)g_object_get_data + ( + G_OBJECT(coneRefinementFramePtr), + "entry_coneRefinement_selectedP0X" + ); + GtkWidget* entry_coneRefinement_selectedP0Y = + (GtkWidget*)g_object_get_data + ( + G_OBJECT(coneRefinementFramePtr), + "entry_coneRefinement_selectedP0Y" + ); + GtkWidget* entry_coneRefinement_selectedP0Z = + (GtkWidget*)g_object_get_data + ( + G_OBJECT(coneRefinementFramePtr), + "entry_coneRefinement_selectedP0Z" + ); + GtkWidget* entry_coneRefinement_selectedRadius0 = + (GtkWidget*)g_object_get_data + ( + G_OBJECT(coneRefinementFramePtr), + "entry_coneRefinement_selectedRadius0" + ); + GtkWidget* entry_coneRefinement_selectedP1X = + (GtkWidget*)g_object_get_data + ( + G_OBJECT(coneRefinementFramePtr), + "entry_coneRefinement_selectedP1X" + ); + GtkWidget* entry_coneRefinement_selectedP1Y = + (GtkWidget*)g_object_get_data + ( + G_OBJECT(coneRefinementFramePtr), + "entry_coneRefinement_selectedP1Y" + ); + GtkWidget* entry_coneRefinement_selectedP1Z = + (GtkWidget*)g_object_get_data + ( + G_OBJECT(coneRefinementFramePtr), + "entry_coneRefinement_selectedP1Z" + ); + GtkWidget* entry_coneRefinement_selectedRadius1 = + (GtkWidget*)g_object_get_data + ( + G_OBJECT(coneRefinementFramePtr), + "entry_coneRefinement_selectedRadius1" + ); + + const word name = + gtk_entry_get_text + ( + GTK_ENTRY + ( + GTK_COMBO + ( + comboboxentry_coneRefinement_createdCones + )->entry + ) + ); + + if( name == "" ) + return; + + const PtrList<entry> refs = guiPtr->objectRefinements(); + dictionary dict; + forAll(refs, refI) + if( refs[refI].keyword() == name ) + dict = refs[refI].dict(); + guiPtr->removeObjectRefinement(name); + if( widget == entry_coneRefinement_selectedCellSize ) + { + const word size = + gtk_entry_get_text(GTK_ENTRY(entry_coneRefinement_selectedCellSize)); + dict.remove("cellSize"); + dict.add("cellSize", help::textToScalar(size)); + } + else if( widget == entry_coneRefinement_selectedP0X ) + { + point p0(dict.lookup("p0")); + const word c = + gtk_entry_get_text(GTK_ENTRY(entry_coneRefinement_selectedP0X)); + dict.remove("p0"); + p0.x() = help::textToScalar(c); + dict.add("p0", p0); + } + else if( widget == entry_coneRefinement_selectedP0Y ) + { + point p0(dict.lookup("p0")); + const word c = + gtk_entry_get_text(GTK_ENTRY(entry_coneRefinement_selectedP0Y)); + dict.remove("p0"); + p0.y() = help::textToScalar(c); + dict.add("p0", p0); + } + else if( widget == entry_coneRefinement_selectedP0Z ) + { + point p0(dict.lookup("p0")); + const word c = + gtk_entry_get_text(GTK_ENTRY(entry_coneRefinement_selectedP0Z)); + dict.remove("p0"); + p0.z() = help::textToScalar(c); + dict.add("p0", p0); + } + else if( widget == entry_coneRefinement_selectedRadius0 ) + { + scalar r0(readScalar(dict.lookup("radius0"))); + const word c = + gtk_entry_get_text + ( + GTK_ENTRY(entry_coneRefinement_selectedRadius0) + ); + dict.remove("radius0"); + r0 = help::textToScalar(c); + dict.add("radius0", r0); + } + else if( widget == entry_coneRefinement_selectedP1X ) + { + const word l = + gtk_entry_get_text(GTK_ENTRY(entry_coneRefinement_selectedP1X)); + point p1(dict.lookup("p1")); + dict.remove("p1"); + p1.x() = help::textToScalar(l); + dict.add("p1", p1); + } + else if( widget == entry_coneRefinement_selectedP1Y ) + { + const word l = + gtk_entry_get_text(GTK_ENTRY(entry_coneRefinement_selectedP1Y)); + point p1(dict.lookup("p1")); + dict.remove("p1"); + p1.y() = help::textToScalar(l); + dict.add("p1", p1); + } + else if( widget == entry_coneRefinement_selectedP1Z ) + { + const word l = + gtk_entry_get_text(GTK_ENTRY(entry_coneRefinement_selectedP1Z)); + point p1(dict.lookup("p1")); + dict.remove("p1"); + p1.z() = help::textToScalar(l); + dict.add("p1", p1); + } + else if( widget == entry_coneRefinement_selectedRadius1 ) + { + scalar r1(readScalar(dict.lookup("radius1"))); + const word c = + gtk_entry_get_text + ( + GTK_ENTRY(entry_coneRefinement_selectedRadius1) + ); + dict.remove("radius1"); + r1 = help::textToScalar(c); + dict.add("radius1", r1); + } + + coneRefinement cr(name, dict); + guiPtr->addObjectRefinement(cr); } static void updateConeRefinements(GtkWidget* coneRefinementFramePtr) { - GtkWidget* comboboxentry_coneRefinement_createdCones = - (GtkWidget*)g_object_get_data - ( - G_OBJECT(coneRefinementFramePtr), - "comboboxentry_coneRefinement_createdCones" - ); - - const PtrList<entry> refs = guiPtr->objectRefinements(); - label nCones(0); - GList* createdCones = 0; - forAll(refs, refI) - { - const word& key = refs[refI].keyword(); - const dictionary& dict = refs[refI].dict(); - const word type(dict.lookup("type")); - - if( type == "cone" ) - { - ++nCones; - coneRefinement cone(key, dict); - createdCones = - g_list_append - ( - createdCones, - const_cast<char*>(cone.name().c_str()) - ); - } - } - - gtk_combo_set_popdown_strings - ( - GTK_COMBO - ( - comboboxentry_coneRefinement_createdCones - ), createdCones - ); - - if( nCones == 0 ) - { - gtk_entry_set_text - ( - GTK_ENTRY - ( - GTK_COMBO(comboboxentry_coneRefinement_createdCones)->entry - ), - "" - ); - } - - g_list_free(createdCones); - - showDataForConeRefinement(NULL, coneRefinementFramePtr); + GtkWidget* comboboxentry_coneRefinement_createdCones = + (GtkWidget*)g_object_get_data + ( + G_OBJECT(coneRefinementFramePtr), + "comboboxentry_coneRefinement_createdCones" + ); + + const PtrList<entry> refs = guiPtr->objectRefinements(); + label nCones(0); + GList* createdCones = 0; + forAll(refs, refI) + { + const word& key = refs[refI].keyword(); + const dictionary& dict = refs[refI].dict(); + const word type(dict.lookup("type")); + + if( type == "cone" ) + { + ++nCones; + coneRefinement cone(key, dict); + createdCones = + g_list_append + ( + createdCones, + const_cast<char*>(cone.name().c_str()) + ); + } + } + + gtk_combo_set_popdown_strings + ( + GTK_COMBO + ( + comboboxentry_coneRefinement_createdCones + ), createdCones + ); + + if( nCones == 0 ) + { + gtk_entry_set_text + ( + GTK_ENTRY + ( + GTK_COMBO(comboboxentry_coneRefinement_createdCones)->entry + ), + "" + ); + } + + g_list_free(createdCones); + + showDataForConeRefinement(NULL, coneRefinementFramePtr); } static void addConeRefinement ( - GtkWidget* button, - GtkWidget* coneRefinementFramePtr + GtkWidget* button, + GtkWidget* coneRefinementFramePtr ) { - GtkWidget* name = - (GtkWidget*)g_object_get_data - ( - G_OBJECT(coneRefinementFramePtr), - "entry_coneName" - ); - GtkWidget* cellSize = - (GtkWidget*)g_object_get_data - ( - G_OBJECT(coneRefinementFramePtr), - "entry_coneRefinement_cellSize" - ); - GtkWidget* p0X = - (GtkWidget*)g_object_get_data - ( - G_OBJECT(coneRefinementFramePtr), - "entry_coneRefinement_p0X" - ); - GtkWidget* p0Y = - (GtkWidget*)g_object_get_data - ( - G_OBJECT(coneRefinementFramePtr), - "entry_coneRefinement_p0Y" - ); - GtkWidget* p0Z = - (GtkWidget*)g_object_get_data - ( - G_OBJECT(coneRefinementFramePtr), - "entry_coneRefinement_p0Z" - ); - GtkWidget* r0 = - (GtkWidget*)g_object_get_data - ( - G_OBJECT(coneRefinementFramePtr), - "entry_coneRefinement_radius0" - ); - GtkWidget* p1X = - (GtkWidget*)g_object_get_data - ( - G_OBJECT(coneRefinementFramePtr), - "entry_coneRefinement_p1X" - ); - GtkWidget* p1Y = - (GtkWidget*)g_object_get_data - ( - G_OBJECT(coneRefinementFramePtr), - "entry_coneRefinement_p1Y" - ); - GtkWidget* p1Z = - (GtkWidget*)g_object_get_data - ( - G_OBJECT(coneRefinementFramePtr), - "entry_coneRefinement_p1Z" - ); - GtkWidget* r1 = - (GtkWidget*)g_object_get_data - ( - G_OBJECT(coneRefinementFramePtr), - "entry_coneRefinement_radius1" - ); - - //- create all necessary settings - const word coneName = gtk_entry_get_text(GTK_ENTRY(name)); - gtk_entry_set_text(GTK_ENTRY(name), ""); - const scalar coneCellSize = - help::textToScalar(gtk_entry_get_text(GTK_ENTRY(cellSize))); - gtk_entry_set_text(GTK_ENTRY(cellSize), ""); - point p0, p1; - scalar radius0, radius1; - p0.x() = help::textToScalar(gtk_entry_get_text(GTK_ENTRY(p0X))); - gtk_entry_set_text(GTK_ENTRY(p0X), ""); - p0.y() = help::textToScalar(gtk_entry_get_text(GTK_ENTRY(p0Y))); - gtk_entry_set_text(GTK_ENTRY(p0Y), ""); - p0.z() = help::textToScalar(gtk_entry_get_text(GTK_ENTRY(p0Z))); - gtk_entry_set_text(GTK_ENTRY(p0Z), ""); - radius0 = help::textToScalar(gtk_entry_get_text(GTK_ENTRY(r0))); - gtk_entry_set_text(GTK_ENTRY(r0), ""); - p1.x() = help::textToScalar(gtk_entry_get_text(GTK_ENTRY(p1X))); - gtk_entry_set_text(GTK_ENTRY(p1X), ""); - p1.y() = help::textToScalar(gtk_entry_get_text(GTK_ENTRY(p1Y))); - gtk_entry_set_text(GTK_ENTRY(p1Y), ""); - p1.z() = help::textToScalar(gtk_entry_get_text(GTK_ENTRY(p1Z))); - gtk_entry_set_text(GTK_ENTRY(p1Z), ""); - radius1 = help::textToScalar(gtk_entry_get_text(GTK_ENTRY(r1))); - gtk_entry_set_text(GTK_ENTRY(r1), ""); - - coneRefinement cone - ( - coneName, - coneCellSize, - p0, - radius0, - p1, - radius1 - ); - - guiPtr->addObjectRefinement(cone); - - updateConeRefinements(coneRefinementFramePtr); + GtkWidget* name = + (GtkWidget*)g_object_get_data + ( + G_OBJECT(coneRefinementFramePtr), + "entry_coneName" + ); + GtkWidget* cellSize = + (GtkWidget*)g_object_get_data + ( + G_OBJECT(coneRefinementFramePtr), + "entry_coneRefinement_cellSize" + ); + GtkWidget* p0X = + (GtkWidget*)g_object_get_data + ( + G_OBJECT(coneRefinementFramePtr), + "entry_coneRefinement_p0X" + ); + GtkWidget* p0Y = + (GtkWidget*)g_object_get_data + ( + G_OBJECT(coneRefinementFramePtr), + "entry_coneRefinement_p0Y" + ); + GtkWidget* p0Z = + (GtkWidget*)g_object_get_data + ( + G_OBJECT(coneRefinementFramePtr), + "entry_coneRefinement_p0Z" + ); + GtkWidget* r0 = + (GtkWidget*)g_object_get_data + ( + G_OBJECT(coneRefinementFramePtr), + "entry_coneRefinement_radius0" + ); + GtkWidget* p1X = + (GtkWidget*)g_object_get_data + ( + G_OBJECT(coneRefinementFramePtr), + "entry_coneRefinement_p1X" + ); + GtkWidget* p1Y = + (GtkWidget*)g_object_get_data + ( + G_OBJECT(coneRefinementFramePtr), + "entry_coneRefinement_p1Y" + ); + GtkWidget* p1Z = + (GtkWidget*)g_object_get_data + ( + G_OBJECT(coneRefinementFramePtr), + "entry_coneRefinement_p1Z" + ); + GtkWidget* r1 = + (GtkWidget*)g_object_get_data + ( + G_OBJECT(coneRefinementFramePtr), + "entry_coneRefinement_radius1" + ); + + //- create all necessary settings + const word coneName = gtk_entry_get_text(GTK_ENTRY(name)); + gtk_entry_set_text(GTK_ENTRY(name), ""); + const scalar coneCellSize = + help::textToScalar(gtk_entry_get_text(GTK_ENTRY(cellSize))); + gtk_entry_set_text(GTK_ENTRY(cellSize), ""); + point p0, p1; + scalar radius0, radius1; + p0.x() = help::textToScalar(gtk_entry_get_text(GTK_ENTRY(p0X))); + gtk_entry_set_text(GTK_ENTRY(p0X), ""); + p0.y() = help::textToScalar(gtk_entry_get_text(GTK_ENTRY(p0Y))); + gtk_entry_set_text(GTK_ENTRY(p0Y), ""); + p0.z() = help::textToScalar(gtk_entry_get_text(GTK_ENTRY(p0Z))); + gtk_entry_set_text(GTK_ENTRY(p0Z), ""); + radius0 = help::textToScalar(gtk_entry_get_text(GTK_ENTRY(r0))); + gtk_entry_set_text(GTK_ENTRY(r0), ""); + p1.x() = help::textToScalar(gtk_entry_get_text(GTK_ENTRY(p1X))); + gtk_entry_set_text(GTK_ENTRY(p1X), ""); + p1.y() = help::textToScalar(gtk_entry_get_text(GTK_ENTRY(p1Y))); + gtk_entry_set_text(GTK_ENTRY(p1Y), ""); + p1.z() = help::textToScalar(gtk_entry_get_text(GTK_ENTRY(p1Z))); + gtk_entry_set_text(GTK_ENTRY(p1Z), ""); + radius1 = help::textToScalar(gtk_entry_get_text(GTK_ENTRY(r1))); + gtk_entry_set_text(GTK_ENTRY(r1), ""); + + coneRefinement cone + ( + coneName, + coneCellSize, + p0, + radius0, + p1, + radius1 + ); + + guiPtr->addObjectRefinement(cone); + + updateConeRefinements(coneRefinementFramePtr); } static void removeConeRefinement ( - GtkWidget* button, - GtkWidget* coneRefinementFramePtr + GtkWidget* button, + GtkWidget* coneRefinementFramePtr ) { - GtkWidget* createdCones = - (GtkWidget*)g_object_get_data - ( - G_OBJECT(coneRefinementFramePtr), - "comboboxentry_coneRefinement_createdCones" - ); - - const word coneName = - gtk_entry_get_text - ( - GTK_ENTRY - ( - GTK_COMBO(createdCones)->entry - ) - ); + GtkWidget* createdCones = + (GtkWidget*)g_object_get_data + ( + G_OBJECT(coneRefinementFramePtr), + "comboboxentry_coneRefinement_createdCones" + ); + + const word coneName = + gtk_entry_get_text + ( + GTK_ENTRY + ( + GTK_COMBO(createdCones)->entry + ) + ); - guiPtr->removeObjectRefinement(coneName); + guiPtr->removeObjectRefinement(coneName); - updateConeRefinements(coneRefinementFramePtr); + updateConeRefinements(coneRefinementFramePtr); } } void meshGenGTK::createConeRefinementWindowPage() { - guiPtr = &meshGui_; - - coneRefinementFramePtr_ = gtk_frame_new(NULL); + guiPtr = &meshGui_; + + coneRefinementFramePtr_ = gtk_frame_new(NULL); // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - //- create a table - GtkWidget* table1 = gtk_table_new(5, 15, FALSE); - gtk_widget_show(table1); - gtk_container_add - ( - GTK_CONTAINER(coneRefinementFramePtr_), - table1 - ); + //- create a table + GtkWidget* table1 = gtk_table_new(5, 15, FALSE); + gtk_widget_show(table1); + gtk_container_add + ( + GTK_CONTAINER(coneRefinementFramePtr_), + table1 + ); // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - //- create a label for cone name - GtkWidget* label_coneName = gtk_label_new("Cone name"); - gtk_widget_show(label_coneName); - gtk_table_attach(GTK_TABLE(table1), label_coneName, 0, 1, 0, 1, + //- create a label for cone name + GtkWidget* label_coneName = gtk_label_new("Cone name"); + gtk_widget_show(label_coneName); + gtk_table_attach(GTK_TABLE(table1), label_coneName, 0, 1, 0, 1, (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0); - gtk_misc_set_alignment(GTK_MISC(label_coneName), 0, 0.5); - + gtk_misc_set_alignment(GTK_MISC(label_coneName), 0, 0.5); + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - //- create an entry for cone name - GtkWidget* entry_coneName = gtk_entry_new(); - gtk_widget_show(entry_coneName); - - gtk_table_attach(GTK_TABLE(table1), entry_coneName, 1, 4, 0, 1, - (GtkAttachOptions)(GTK_FILL), + //- create an entry for cone name + GtkWidget* entry_coneName = gtk_entry_new(); + gtk_widget_show(entry_coneName); + + gtk_table_attach(GTK_TABLE(table1), entry_coneName, 1, 4, 0, 1, + (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0); - + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - //- create a label for desired cell size - GtkWidget* label_coneRefinement_cellSize = gtk_label_new("Cell size [m]"); - gtk_widget_show(label_coneRefinement_cellSize); - gtk_table_attach(GTK_TABLE(table1), label_coneRefinement_cellSize, - 0, 1, 1, 2, - (GtkAttachOptions)(GTK_FILL), + //- create a label for desired cell size + GtkWidget* label_coneRefinement_cellSize = gtk_label_new("Cell size [m]"); + gtk_widget_show(label_coneRefinement_cellSize); + gtk_table_attach(GTK_TABLE(table1), label_coneRefinement_cellSize, + 0, 1, 1, 2, + (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0); - gtk_misc_set_alignment(GTK_MISC(label_coneRefinement_cellSize), 0, 0.5); - + gtk_misc_set_alignment(GTK_MISC(label_coneRefinement_cellSize), 0, 0.5); + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - //- create a label for desired cell size - GtkWidget* entry_coneRefinement_cellSize = gtk_entry_new(); - gtk_widget_show(entry_coneRefinement_cellSize); - gtk_table_attach(GTK_TABLE(table1), entry_coneRefinement_cellSize, - 1, 4, 1, 2, - (GtkAttachOptions)(GTK_FILL), + //- create a label for desired cell size + GtkWidget* entry_coneRefinement_cellSize = gtk_entry_new(); + gtk_widget_show(entry_coneRefinement_cellSize); + gtk_table_attach(GTK_TABLE(table1), entry_coneRefinement_cellSize, + 1, 4, 1, 2, + (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0); - + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - //- create labels for axes - GtkWidget* label_axes = gtk_label_new("X"); - gtk_widget_show(label_axes); - gtk_table_attach(GTK_TABLE(table1), label_axes, - 1, 2, 2, 3, - (GtkAttachOptions)(GTK_FILL), + //- create labels for axes + GtkWidget* label_axes = gtk_label_new("X"); + gtk_widget_show(label_axes); + gtk_table_attach(GTK_TABLE(table1), label_axes, + 1, 2, 2, 3, + (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0); - gtk_misc_set_alignment(GTK_MISC(label_axes), 0, 0.5); - - label_axes = gtk_label_new("Y"); - gtk_widget_show(label_axes); - gtk_table_attach(GTK_TABLE(table1), label_axes, - 2, 3, 2, 3, - (GtkAttachOptions)(GTK_FILL), + gtk_misc_set_alignment(GTK_MISC(label_axes), 0, 0.5); + + label_axes = gtk_label_new("Y"); + gtk_widget_show(label_axes); + gtk_table_attach(GTK_TABLE(table1), label_axes, + 2, 3, 2, 3, + (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0); - gtk_misc_set_alignment(GTK_MISC(label_axes), 0, 0.5); - - label_axes = gtk_label_new("Z"); - gtk_widget_show(label_axes); - gtk_table_attach(GTK_TABLE(table1), label_axes, - 3, 4, 2, 3, - (GtkAttachOptions)(GTK_FILL), + gtk_misc_set_alignment(GTK_MISC(label_axes), 0, 0.5); + + label_axes = gtk_label_new("Z"); + gtk_widget_show(label_axes); + gtk_table_attach(GTK_TABLE(table1), label_axes, + 3, 4, 2, 3, + (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0); - gtk_misc_set_alignment(GTK_MISC(label_axes), 0, 0.5); - + gtk_misc_set_alignment(GTK_MISC(label_axes), 0, 0.5); + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - //- label for p0 - GtkWidget* label_coneRefinement_p0 = gtk_label_new("Starting point"); - gtk_widget_show(label_coneRefinement_p0); - gtk_table_attach(GTK_TABLE(table1), label_coneRefinement_p0, - 0, 1, 3, 4, - (GtkAttachOptions)(GTK_FILL), + //- label for p0 + GtkWidget* label_coneRefinement_p0 = gtk_label_new("Starting point"); + gtk_widget_show(label_coneRefinement_p0); + gtk_table_attach(GTK_TABLE(table1), label_coneRefinement_p0, + 0, 1, 3, 4, + (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0); - gtk_misc_set_alignment(GTK_MISC(label_coneRefinement_p0), 0, 0.5); + gtk_misc_set_alignment(GTK_MISC(label_coneRefinement_p0), 0, 0.5); // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - //- entries for p0 - GtkWidget* entry_coneRefinement_p0X = gtk_entry_new(); - gtk_widget_show(entry_coneRefinement_p0X); - gtk_table_attach(GTK_TABLE(table1), entry_coneRefinement_p0X, - 1, 2, 3, 4, - (GtkAttachOptions)(GTK_FILL), + //- entries for p0 + GtkWidget* entry_coneRefinement_p0X = gtk_entry_new(); + gtk_widget_show(entry_coneRefinement_p0X); + gtk_table_attach(GTK_TABLE(table1), entry_coneRefinement_p0X, + 1, 2, 3, 4, + (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0); - - GtkWidget* entry_coneRefinement_p0Y = gtk_entry_new(); - gtk_widget_show(entry_coneRefinement_p0Y); - gtk_table_attach(GTK_TABLE(table1), entry_coneRefinement_p0Y, - 2, 3, 3, 4, - (GtkAttachOptions)(GTK_FILL), + + GtkWidget* entry_coneRefinement_p0Y = gtk_entry_new(); + gtk_widget_show(entry_coneRefinement_p0Y); + gtk_table_attach(GTK_TABLE(table1), entry_coneRefinement_p0Y, + 2, 3, 3, 4, + (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0); - - GtkWidget* entry_coneRefinement_p0Z = gtk_entry_new(); - gtk_widget_show(entry_coneRefinement_p0Z); - gtk_table_attach(GTK_TABLE(table1), entry_coneRefinement_p0Z, - 3, 4, 3, 4, - (GtkAttachOptions)(GTK_FILL), + + GtkWidget* entry_coneRefinement_p0Z = gtk_entry_new(); + gtk_widget_show(entry_coneRefinement_p0Z); + gtk_table_attach(GTK_TABLE(table1), entry_coneRefinement_p0Z, + 3, 4, 3, 4, + (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0); - + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - //- label for p1 - GtkWidget* label_coneRefinement_p1 = gtk_label_new("End point"); - gtk_widget_show(label_coneRefinement_p1); - gtk_table_attach(GTK_TABLE(table1), label_coneRefinement_p1, - 0, 1, 4, 5, - (GtkAttachOptions)(GTK_FILL), + //- label for p1 + GtkWidget* label_coneRefinement_p1 = gtk_label_new("End point"); + gtk_widget_show(label_coneRefinement_p1); + gtk_table_attach(GTK_TABLE(table1), label_coneRefinement_p1, + 0, 1, 4, 5, + (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0); - gtk_misc_set_alignment(GTK_MISC(label_coneRefinement_p1), 0, 0.5); + gtk_misc_set_alignment(GTK_MISC(label_coneRefinement_p1), 0, 0.5); // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - //- entries for p1 - GtkWidget* entry_coneRefinement_p1X = gtk_entry_new(); - gtk_widget_show(entry_coneRefinement_p1X); - gtk_table_attach(GTK_TABLE(table1), entry_coneRefinement_p1X, - 1, 2, 4, 5, - (GtkAttachOptions)(GTK_FILL), + //- entries for p1 + GtkWidget* entry_coneRefinement_p1X = gtk_entry_new(); + gtk_widget_show(entry_coneRefinement_p1X); + gtk_table_attach(GTK_TABLE(table1), entry_coneRefinement_p1X, + 1, 2, 4, 5, + (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0); - - GtkWidget* entry_coneRefinement_p1Y = gtk_entry_new(); - gtk_widget_show(entry_coneRefinement_p1Y); - gtk_table_attach(GTK_TABLE(table1), entry_coneRefinement_p1Y, - 2, 3, 4, 5, - (GtkAttachOptions)(GTK_FILL), + + GtkWidget* entry_coneRefinement_p1Y = gtk_entry_new(); + gtk_widget_show(entry_coneRefinement_p1Y); + gtk_table_attach(GTK_TABLE(table1), entry_coneRefinement_p1Y, + 2, 3, 4, 5, + (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0); - - GtkWidget* entry_coneRefinement_p1Z = gtk_entry_new(); - gtk_widget_show(entry_coneRefinement_p1Z); - gtk_table_attach(GTK_TABLE(table1), entry_coneRefinement_p1Z, - 3, 4, 4, 5, - (GtkAttachOptions)(GTK_FILL), + + GtkWidget* entry_coneRefinement_p1Z = gtk_entry_new(); + gtk_widget_show(entry_coneRefinement_p1Z); + gtk_table_attach(GTK_TABLE(table1), entry_coneRefinement_p1Z, + 3, 4, 4, 5, + (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0); // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - //- label for radius0 - GtkWidget* label_coneRefinement_radius0 = - gtk_label_new("Starting radius [m]"); - gtk_widget_show(label_coneRefinement_radius0); - gtk_table_attach(GTK_TABLE(table1), label_coneRefinement_radius0, - 0, 1, 5, 6, - (GtkAttachOptions)(GTK_FILL), + //- label for radius0 + GtkWidget* label_coneRefinement_radius0 = + gtk_label_new("Starting radius [m]"); + gtk_widget_show(label_coneRefinement_radius0); + gtk_table_attach(GTK_TABLE(table1), label_coneRefinement_radius0, + 0, 1, 5, 6, + (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0); - gtk_misc_set_alignment(GTK_MISC(label_coneRefinement_radius0), 0, 0.5); + gtk_misc_set_alignment(GTK_MISC(label_coneRefinement_radius0), 0, 0.5); // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - //- entry for radius0 - GtkWidget* entry_coneRefinement_radius0 = gtk_entry_new(); - gtk_widget_show(entry_coneRefinement_radius0); - gtk_table_attach(GTK_TABLE(table1), entry_coneRefinement_radius0, - 1, 4, 5, 6, - (GtkAttachOptions)(GTK_FILL), + //- entry for radius0 + GtkWidget* entry_coneRefinement_radius0 = gtk_entry_new(); + gtk_widget_show(entry_coneRefinement_radius0); + gtk_table_attach(GTK_TABLE(table1), entry_coneRefinement_radius0, + 1, 4, 5, 6, + (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0); - + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - //- label for radius1 - GtkWidget* label_coneRefinement_radius1 = gtk_label_new("End radius [m]"); - gtk_widget_show(label_coneRefinement_radius1); - gtk_table_attach(GTK_TABLE(table1), label_coneRefinement_radius1, - 0, 1, 6, 7, - (GtkAttachOptions)(GTK_FILL), + //- label for radius1 + GtkWidget* label_coneRefinement_radius1 = gtk_label_new("End radius [m]"); + gtk_widget_show(label_coneRefinement_radius1); + gtk_table_attach(GTK_TABLE(table1), label_coneRefinement_radius1, + 0, 1, 6, 7, + (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0); - gtk_misc_set_alignment(GTK_MISC(label_coneRefinement_radius1), 0, 0.5); + gtk_misc_set_alignment(GTK_MISC(label_coneRefinement_radius1), 0, 0.5); // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - //- entry for radius1 - GtkWidget* entry_coneRefinement_radius1 = gtk_entry_new(); - gtk_widget_show(entry_coneRefinement_radius1); - gtk_table_attach(GTK_TABLE(table1), entry_coneRefinement_radius1, - 1, 4, 6, 7, - (GtkAttachOptions)(GTK_FILL), + //- entry for radius1 + GtkWidget* entry_coneRefinement_radius1 = gtk_entry_new(); + gtk_widget_show(entry_coneRefinement_radius1); + gtk_table_attach(GTK_TABLE(table1), entry_coneRefinement_radius1, + 1, 4, 6, 7, + (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0); - + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - //- set the button for adding cones - GtkWidget* button1 = gtk_button_new(); - gtk_widget_show(button1); - gtk_table_attach - ( - GTK_TABLE(table1), - button1, - 4, 5, 0, 7, - (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 5 - ); - - g_signal_connect - ( - G_OBJECT(button1), - "clicked", - G_CALLBACK(addConeRefinement), - coneRefinementFramePtr_ - ); + //- set the button for adding cones + GtkWidget* button1 = gtk_button_new(); + gtk_widget_show(button1); + gtk_table_attach + ( + GTK_TABLE(table1), + button1, + 4, 5, 0, 7, + (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 5 + ); + + g_signal_connect + ( + G_OBJECT(button1), + "clicked", + G_CALLBACK(addConeRefinement), + coneRefinementFramePtr_ + ); - GtkWidget* alignment1 = gtk_alignment_new(0.5, 0.5, 0, 0); - gtk_widget_show(alignment1); - gtk_container_add(GTK_CONTAINER(button1), alignment1); - - GtkWidget* hbox1 = gtk_hbox_new(FALSE, 2); - gtk_widget_show(hbox1); - gtk_container_add(GTK_CONTAINER(alignment1), hbox1); - - GtkWidget* image1 = - gtk_image_new_from_stock("gtk-add", GTK_ICON_SIZE_BUTTON); - gtk_widget_show(image1); - gtk_box_pack_start(GTK_BOX(hbox1), image1, FALSE, FALSE, 0); - - GtkWidget* label3 = gtk_label_new_with_mnemonic("Add"); - gtk_widget_show(label3); - gtk_box_pack_start(GTK_BOX(hbox1), label3, FALSE, FALSE, 0); - + GtkWidget* alignment1 = gtk_alignment_new(0.5, 0.5, 0, 0); + gtk_widget_show(alignment1); + gtk_container_add(GTK_CONTAINER(button1), alignment1); + + GtkWidget* hbox1 = gtk_hbox_new(FALSE, 2); + gtk_widget_show(hbox1); + gtk_container_add(GTK_CONTAINER(alignment1), hbox1); + + GtkWidget* image1 = + gtk_image_new_from_stock("gtk-add", GTK_ICON_SIZE_BUTTON); + gtk_widget_show(image1); + gtk_box_pack_start(GTK_BOX(hbox1), image1, FALSE, FALSE, 0); + + GtkWidget* label3 = gtk_label_new_with_mnemonic("Add"); + gtk_widget_show(label3); + gtk_box_pack_start(GTK_BOX(hbox1), label3, FALSE, FALSE, 0); + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - //- horizontal separator - GtkWidget* hseparator0 = gtk_hseparator_new(); - gtk_widget_show(hseparator0); - gtk_table_attach(GTK_TABLE(table1), hseparator0, 0, 5, 7, 8, + //- horizontal separator + GtkWidget* hseparator0 = gtk_hseparator_new(); + gtk_widget_show(hseparator0); + gtk_table_attach(GTK_TABLE(table1), hseparator0, 0, 5, 7, 8, (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(GTK_EXPAND | GTK_SHRINK | GTK_FILL), - 0, 0); + 0, 0); // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - //- label for existing cone objects - GtkWidget* label_coneRefinement_existing = gtk_label_new("Existing cones"); - gtk_widget_show(label_coneRefinement_existing); - gtk_table_attach(GTK_TABLE(table1), label_coneRefinement_existing, - 0, 1, 8, 9, - (GtkAttachOptions)(GTK_FILL), + //- label for existing cone objects + GtkWidget* label_coneRefinement_existing = gtk_label_new("Existing cones"); + gtk_widget_show(label_coneRefinement_existing); + gtk_table_attach(GTK_TABLE(table1), label_coneRefinement_existing, + 0, 1, 8, 9, + (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0); - + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - //- combobox for existing cone objects - GtkWidget* comboboxentry_coneRefinement_createdCones = - gtk_combo_new(); - gtk_widget_show(comboboxentry_coneRefinement_createdCones); - gtk_table_attach - ( - GTK_TABLE(table1),comboboxentry_coneRefinement_createdCones, - 1, 2, 8, 9, - (GtkAttachOptions)(GTK_FILL), - (GtkAttachOptions)(0), 0, 0 - ); - - gtk_editable_set_editable - ( - GTK_EDITABLE - ( - GTK_COMBO(comboboxentry_coneRefinement_createdCones)->entry - ), - 0 - ); - - + //- combobox for existing cone objects + GtkWidget* comboboxentry_coneRefinement_createdCones = + gtk_combo_new(); + gtk_widget_show(comboboxentry_coneRefinement_createdCones); + gtk_table_attach + ( + GTK_TABLE(table1),comboboxentry_coneRefinement_createdCones, + 1, 2, 8, 9, + (GtkAttachOptions)(GTK_FILL), + (GtkAttachOptions)(0), 0, 0 + ); + + gtk_editable_set_editable + ( + GTK_EDITABLE + ( + GTK_COMBO(comboboxentry_coneRefinement_createdCones)->entry + ), + 0 + ); + + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - //- create a label for selected cell size - GtkWidget* label_coneRefinement_selectedCellSize = - gtk_label_new("Cell size [m]"); - gtk_widget_show(label_coneRefinement_selectedCellSize); - gtk_table_attach(GTK_TABLE(table1), label_coneRefinement_selectedCellSize, - 0, 1, 9, 10, - (GtkAttachOptions)(GTK_FILL), + //- create a label for selected cell size + GtkWidget* label_coneRefinement_selectedCellSize = + gtk_label_new("Cell size [m]"); + gtk_widget_show(label_coneRefinement_selectedCellSize); + gtk_table_attach(GTK_TABLE(table1), label_coneRefinement_selectedCellSize, + 0, 1, 9, 10, + (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0); - gtk_misc_set_alignment - ( - GTK_MISC(label_coneRefinement_selectedCellSize), 0, 0.5 - ); - + gtk_misc_set_alignment + ( + GTK_MISC(label_coneRefinement_selectedCellSize), 0, 0.5 + ); + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - //- create a label for selected cell size - GtkWidget* entry_coneRefinement_selectedCellSize = gtk_entry_new(); - gtk_widget_show(entry_coneRefinement_selectedCellSize); - gtk_table_attach(GTK_TABLE(table1), entry_coneRefinement_selectedCellSize, - 1, 4, 9, 10, - (GtkAttachOptions)(GTK_FILL), + //- create a label for selected cell size + GtkWidget* entry_coneRefinement_selectedCellSize = gtk_entry_new(); + gtk_widget_show(entry_coneRefinement_selectedCellSize); + gtk_table_attach(GTK_TABLE(table1), entry_coneRefinement_selectedCellSize, + 1, 4, 9, 10, + (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0); - + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - //- create labels for axes - label_axes = gtk_label_new("X"); - gtk_widget_show(label_axes); - gtk_table_attach(GTK_TABLE(table1), label_axes, - 1, 2, 10, 11, - (GtkAttachOptions)(GTK_FILL), + //- create labels for axes + label_axes = gtk_label_new("X"); + gtk_widget_show(label_axes); + gtk_table_attach(GTK_TABLE(table1), label_axes, + 1, 2, 10, 11, + (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0); - gtk_misc_set_alignment(GTK_MISC(label_axes), 0, 0.5); - - label_axes = gtk_label_new("Y"); - gtk_widget_show(label_axes); - gtk_table_attach(GTK_TABLE(table1), label_axes, - 2, 3, 10, 11, - (GtkAttachOptions)(GTK_FILL), + gtk_misc_set_alignment(GTK_MISC(label_axes), 0, 0.5); + + label_axes = gtk_label_new("Y"); + gtk_widget_show(label_axes); + gtk_table_attach(GTK_TABLE(table1), label_axes, + 2, 3, 10, 11, + (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0); - gtk_misc_set_alignment(GTK_MISC(label_axes), 0, 0.5); - - label_axes = gtk_label_new("Z"); - gtk_widget_show(label_axes); - gtk_table_attach(GTK_TABLE(table1), label_axes, - 3, 4, 10, 11, - (GtkAttachOptions)(GTK_FILL), + gtk_misc_set_alignment(GTK_MISC(label_axes), 0, 0.5); + + label_axes = gtk_label_new("Z"); + gtk_widget_show(label_axes); + gtk_table_attach(GTK_TABLE(table1), label_axes, + 3, 4, 10, 11, + (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0); - gtk_misc_set_alignment(GTK_MISC(label_axes), 0, 0.5); - + gtk_misc_set_alignment(GTK_MISC(label_axes), 0, 0.5); + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - //- label for p0 - GtkWidget* label_coneRefinement_selectedP0 = - gtk_label_new("Starting point"); - gtk_widget_show(label_coneRefinement_selectedP0); - gtk_table_attach(GTK_TABLE(table1), label_coneRefinement_selectedP0, - 0, 1, 11, 12, - (GtkAttachOptions)(GTK_FILL), + //- label for p0 + GtkWidget* label_coneRefinement_selectedP0 = + gtk_label_new("Starting point"); + gtk_widget_show(label_coneRefinement_selectedP0); + gtk_table_attach(GTK_TABLE(table1), label_coneRefinement_selectedP0, + 0, 1, 11, 12, + (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0); - gtk_misc_set_alignment(GTK_MISC(label_coneRefinement_selectedP0), 0, 0.5); + gtk_misc_set_alignment(GTK_MISC(label_coneRefinement_selectedP0), 0, 0.5); // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - //- entries for selected p0 - GtkWidget* entry_coneRefinement_selectedP0X = gtk_entry_new(); - gtk_widget_show(entry_coneRefinement_selectedP0X); - gtk_table_attach(GTK_TABLE(table1), entry_coneRefinement_selectedP0X, - 1, 2, 11, 12, - (GtkAttachOptions)(GTK_FILL), + //- entries for selected p0 + GtkWidget* entry_coneRefinement_selectedP0X = gtk_entry_new(); + gtk_widget_show(entry_coneRefinement_selectedP0X); + gtk_table_attach(GTK_TABLE(table1), entry_coneRefinement_selectedP0X, + 1, 2, 11, 12, + (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0); - - GtkWidget* entry_coneRefinement_selectedP0Y = gtk_entry_new(); - gtk_widget_show(entry_coneRefinement_selectedP0Y); - gtk_table_attach(GTK_TABLE(table1), entry_coneRefinement_selectedP0Y, - 2, 3, 11, 12, - (GtkAttachOptions)(GTK_FILL), + + GtkWidget* entry_coneRefinement_selectedP0Y = gtk_entry_new(); + gtk_widget_show(entry_coneRefinement_selectedP0Y); + gtk_table_attach(GTK_TABLE(table1), entry_coneRefinement_selectedP0Y, + 2, 3, 11, 12, + (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0); - - GtkWidget* entry_coneRefinement_selectedP0Z = gtk_entry_new(); - gtk_widget_show(entry_coneRefinement_selectedP0Z); - gtk_table_attach(GTK_TABLE(table1), entry_coneRefinement_selectedP0Z, - 3, 4, 11, 12, - (GtkAttachOptions)(GTK_FILL), + + GtkWidget* entry_coneRefinement_selectedP0Z = gtk_entry_new(); + gtk_widget_show(entry_coneRefinement_selectedP0Z); + gtk_table_attach(GTK_TABLE(table1), entry_coneRefinement_selectedP0Z, + 3, 4, 11, 12, + (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0); - + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - //- label for selected p1 - GtkWidget* label_coneRefinement_selectedP1 = - gtk_label_new("End point"); - gtk_widget_show(label_coneRefinement_selectedP1); - gtk_table_attach(GTK_TABLE(table1), label_coneRefinement_selectedP1, - 0, 1, 12, 13, - (GtkAttachOptions)(GTK_FILL), + //- label for selected p1 + GtkWidget* label_coneRefinement_selectedP1 = + gtk_label_new("End point"); + gtk_widget_show(label_coneRefinement_selectedP1); + gtk_table_attach(GTK_TABLE(table1), label_coneRefinement_selectedP1, + 0, 1, 12, 13, + (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0); - gtk_misc_set_alignment - ( - GTK_MISC(label_coneRefinement_selectedP1), 0, 0.5 - ); + gtk_misc_set_alignment + ( + GTK_MISC(label_coneRefinement_selectedP1), 0, 0.5 + ); // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - //- entries for p1 - GtkWidget* entry_coneRefinement_selectedP1X = gtk_entry_new(); - gtk_widget_show(entry_coneRefinement_selectedP1X); - gtk_table_attach(GTK_TABLE(table1), entry_coneRefinement_selectedP1X, - 1, 2, 12, 13, - (GtkAttachOptions)(GTK_FILL), + //- entries for p1 + GtkWidget* entry_coneRefinement_selectedP1X = gtk_entry_new(); + gtk_widget_show(entry_coneRefinement_selectedP1X); + gtk_table_attach(GTK_TABLE(table1), entry_coneRefinement_selectedP1X, + 1, 2, 12, 13, + (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0); - - GtkWidget* entry_coneRefinement_selectedP1Y = gtk_entry_new(); - gtk_widget_show(entry_coneRefinement_selectedP1Y); - gtk_table_attach(GTK_TABLE(table1), entry_coneRefinement_selectedP1Y, - 2, 3, 12, 13, - (GtkAttachOptions)(GTK_FILL), + + GtkWidget* entry_coneRefinement_selectedP1Y = gtk_entry_new(); + gtk_widget_show(entry_coneRefinement_selectedP1Y); + gtk_table_attach(GTK_TABLE(table1), entry_coneRefinement_selectedP1Y, + 2, 3, 12, 13, + (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0); - - GtkWidget* entry_coneRefinement_selectedP1Z = gtk_entry_new(); - gtk_widget_show(entry_coneRefinement_selectedP1Z); - gtk_table_attach(GTK_TABLE(table1), entry_coneRefinement_selectedP1Z, - 3, 4, 12, 13, - (GtkAttachOptions)(GTK_FILL), + + GtkWidget* entry_coneRefinement_selectedP1Z = gtk_entry_new(); + gtk_widget_show(entry_coneRefinement_selectedP1Z); + gtk_table_attach(GTK_TABLE(table1), entry_coneRefinement_selectedP1Z, + 3, 4, 12, 13, + (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0); - + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - //- label for selected radius0 - GtkWidget* label_coneRefinement_selectedRadius0 = - gtk_label_new("Starting radius [m]"); - gtk_widget_show(label_coneRefinement_selectedRadius0); - gtk_table_attach(GTK_TABLE(table1), label_coneRefinement_selectedRadius0, - 0, 1, 13, 14, - (GtkAttachOptions)(GTK_FILL), + //- label for selected radius0 + GtkWidget* label_coneRefinement_selectedRadius0 = + gtk_label_new("Starting radius [m]"); + gtk_widget_show(label_coneRefinement_selectedRadius0); + gtk_table_attach(GTK_TABLE(table1), label_coneRefinement_selectedRadius0, + 0, 1, 13, 14, + (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0); - gtk_misc_set_alignment - ( - GTK_MISC(label_coneRefinement_selectedRadius0), 0, 0.5 - ); + gtk_misc_set_alignment + ( + GTK_MISC(label_coneRefinement_selectedRadius0), 0, 0.5 + ); // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - //- entry for selected radius0 - GtkWidget* entry_coneRefinement_selectedRadius0 = gtk_entry_new(); - gtk_widget_show(entry_coneRefinement_selectedRadius0); - gtk_table_attach(GTK_TABLE(table1), entry_coneRefinement_selectedRadius0, - 1, 4, 13, 14, - (GtkAttachOptions)(GTK_FILL), + //- entry for selected radius0 + GtkWidget* entry_coneRefinement_selectedRadius0 = gtk_entry_new(); + gtk_widget_show(entry_coneRefinement_selectedRadius0); + gtk_table_attach(GTK_TABLE(table1), entry_coneRefinement_selectedRadius0, + 1, 4, 13, 14, + (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0); - + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - //- label for radius1 - GtkWidget* label_coneRefinement_selectedRadius1 = - gtk_label_new("End radius [m]"); - gtk_widget_show(label_coneRefinement_selectedRadius1); - gtk_table_attach(GTK_TABLE(table1), label_coneRefinement_selectedRadius1, - 0, 1, 14, 15, - (GtkAttachOptions)(GTK_FILL), + //- label for radius1 + GtkWidget* label_coneRefinement_selectedRadius1 = + gtk_label_new("End radius [m]"); + gtk_widget_show(label_coneRefinement_selectedRadius1); + gtk_table_attach(GTK_TABLE(table1), label_coneRefinement_selectedRadius1, + 0, 1, 14, 15, + (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0); - gtk_misc_set_alignment - ( - GTK_MISC(label_coneRefinement_selectedRadius1), 0, 0.5 - ); + gtk_misc_set_alignment + ( + GTK_MISC(label_coneRefinement_selectedRadius1), 0, 0.5 + ); // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - //- entry for radius1 - GtkWidget* entry_coneRefinement_selectedRadius1 = gtk_entry_new(); - gtk_widget_show(entry_coneRefinement_selectedRadius1); - gtk_table_attach(GTK_TABLE(table1), entry_coneRefinement_selectedRadius1, - 1, 4, 14, 15, - (GtkAttachOptions)(GTK_FILL), + //- entry for radius1 + GtkWidget* entry_coneRefinement_selectedRadius1 = gtk_entry_new(); + gtk_widget_show(entry_coneRefinement_selectedRadius1); + gtk_table_attach(GTK_TABLE(table1), entry_coneRefinement_selectedRadius1, + 1, 4, 14, 15, + (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0); - + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - //- set the button for removing patches - GtkWidget* button2 = gtk_button_new(); - gtk_widget_show(button2); - gtk_table_attach - ( - GTK_TABLE(table1), - button2, - 4, 5, 8, 15, - (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 5 - ); - - g_signal_connect - ( - G_OBJECT(button2), - "clicked", - G_CALLBACK(removeConeRefinement), - coneRefinementFramePtr_ - ); - - GtkWidget* alignment2 = gtk_alignment_new(0.5, 0.5, 0, 0); - gtk_widget_show(alignment2); - gtk_container_add(GTK_CONTAINER(button2), alignment2); - - GtkWidget* hbox2 = gtk_hbox_new(FALSE, 2); - gtk_widget_show(hbox2); - gtk_container_add(GTK_CONTAINER(alignment2), hbox2); - - GtkWidget* image2 = - gtk_image_new_from_stock("gtk-remove", GTK_ICON_SIZE_BUTTON); - gtk_widget_show(image2); - gtk_box_pack_start(GTK_BOX (hbox2), image2, FALSE, FALSE, 0); - - GtkWidget* label5 = gtk_label_new_with_mnemonic("Remove"); - gtk_widget_show(label5); - gtk_box_pack_start(GTK_BOX (hbox2), label5, FALSE, FALSE, 0); - + //- set the button for removing patches + GtkWidget* button2 = gtk_button_new(); + gtk_widget_show(button2); + gtk_table_attach + ( + GTK_TABLE(table1), + button2, + 4, 5, 8, 15, + (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 5 + ); + + g_signal_connect + ( + G_OBJECT(button2), + "clicked", + G_CALLBACK(removeConeRefinement), + coneRefinementFramePtr_ + ); + + GtkWidget* alignment2 = gtk_alignment_new(0.5, 0.5, 0, 0); + gtk_widget_show(alignment2); + gtk_container_add(GTK_CONTAINER(button2), alignment2); + + GtkWidget* hbox2 = gtk_hbox_new(FALSE, 2); + gtk_widget_show(hbox2); + gtk_container_add(GTK_CONTAINER(alignment2), hbox2); + + GtkWidget* image2 = + gtk_image_new_from_stock("gtk-remove", GTK_ICON_SIZE_BUTTON); + gtk_widget_show(image2); + gtk_box_pack_start(GTK_BOX (hbox2), image2, FALSE, FALSE, 0); + + GtkWidget* label5 = gtk_label_new_with_mnemonic("Remove"); + gtk_widget_show(label5); + gtk_box_pack_start(GTK_BOX (hbox2), label5, FALSE, FALSE, 0); + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - /* Store pointers to all widgets, for use by lookup_widget(). */ - GLADE_HOOKUP_OBJECT_NO_REF - ( - coneRefinementFramePtr_, - coneRefinementFramePtr_, - "coneRefinementFramePtr_"); - GLADE_HOOKUP_OBJECT - ( - coneRefinementFramePtr_, - table1, - "table1" - ); - GLADE_HOOKUP_OBJECT - ( - coneRefinementFramePtr_, - entry_coneName, - "entry_coneName" - ); - GLADE_HOOKUP_OBJECT - ( - coneRefinementFramePtr_, - entry_coneRefinement_cellSize, - "entry_coneRefinement_cellSize" - ); - GLADE_HOOKUP_OBJECT - ( - coneRefinementFramePtr_, - entry_coneRefinement_p0X, - "entry_coneRefinement_p0X" - ); - GLADE_HOOKUP_OBJECT - ( - coneRefinementFramePtr_, - entry_coneRefinement_p0Y, - "entry_coneRefinement_p0Y" - ); - GLADE_HOOKUP_OBJECT - ( - coneRefinementFramePtr_, - entry_coneRefinement_radius0, - "entry_coneRefinement_radius0" - ); - GLADE_HOOKUP_OBJECT - ( - coneRefinementFramePtr_, - entry_coneRefinement_radius1, - "entry_coneRefinement_radius1" - ); - GLADE_HOOKUP_OBJECT - ( - coneRefinementFramePtr_, - entry_coneRefinement_p0Z, - "entry_coneRefinement_p0Z" - ); - GLADE_HOOKUP_OBJECT - ( - coneRefinementFramePtr_, - entry_coneRefinement_p1X, - "entry_coneRefinement_p1X" - ); - GLADE_HOOKUP_OBJECT - ( - coneRefinementFramePtr_, - entry_coneRefinement_p1Y, - "entry_coneRefinement_p1Y" - ); - GLADE_HOOKUP_OBJECT - ( - coneRefinementFramePtr_, - entry_coneRefinement_p1Z, - "entry_coneRefinement_p1Z" - ); - GLADE_HOOKUP_OBJECT - ( - coneRefinementFramePtr_, - comboboxentry_coneRefinement_createdCones, - "comboboxentry_coneRefinement_createdCones" - ); - GLADE_HOOKUP_OBJECT - ( - coneRefinementFramePtr_, - entry_coneRefinement_selectedCellSize, - "entry_coneRefinement_selectedCellSize" - ); - GLADE_HOOKUP_OBJECT - ( - coneRefinementFramePtr_, - entry_coneRefinement_selectedP0X, - "entry_coneRefinement_selectedP0X" - ); - GLADE_HOOKUP_OBJECT - ( - coneRefinementFramePtr_, - entry_coneRefinement_selectedP0Y, - "entry_coneRefinement_selectedP0Y" - ); - GLADE_HOOKUP_OBJECT - ( - coneRefinementFramePtr_, - entry_coneRefinement_selectedP0Z, - "entry_coneRefinement_selectedP0Z" - ); - GLADE_HOOKUP_OBJECT - ( - coneRefinementFramePtr_, - entry_coneRefinement_selectedRadius0, - "entry_coneRefinement_selectedRadius0" - ); - GLADE_HOOKUP_OBJECT - ( - coneRefinementFramePtr_, - entry_coneRefinement_selectedP1X, - "entry_coneRefinement_selectedP1X" - ); - GLADE_HOOKUP_OBJECT - ( - coneRefinementFramePtr_, - entry_coneRefinement_selectedP1Y, - "entry_coneRefinement_selectedP1Y" - ); - GLADE_HOOKUP_OBJECT - ( - coneRefinementFramePtr_, - entry_coneRefinement_selectedP1Z, - "entry_coneRefinement_selectedP1Z" - ); - GLADE_HOOKUP_OBJECT - ( - coneRefinementFramePtr_, - entry_coneRefinement_selectedRadius1, - "entry_coneRefinement_selectedRadius1" - ); - - updateConeRefinements(coneRefinementFramePtr_); - - g_signal_connect - ( - G_OBJECT - ( - GTK_ENTRY - ( - GTK_COMBO(comboboxentry_coneRefinement_createdCones)->entry - ) - ), - "changed", - G_CALLBACK(showDataForConeRefinement), - coneRefinementFramePtr_ - ); - - g_signal_connect - ( - G_OBJECT(entry_coneRefinement_selectedCellSize), - "changed", - G_CALLBACK(resetValuesForSelectedCone), - coneRefinementFramePtr_ - ); - - g_signal_connect - ( - G_OBJECT(entry_coneRefinement_selectedP0X), - "changed", - G_CALLBACK(resetValuesForSelectedCone), - coneRefinementFramePtr_ - ); - - g_signal_connect - ( - G_OBJECT(entry_coneRefinement_selectedP0Y), - "changed", - G_CALLBACK(resetValuesForSelectedCone), - coneRefinementFramePtr_ - ); - - g_signal_connect - ( - G_OBJECT(entry_coneRefinement_selectedP0Z), - "changed", - G_CALLBACK(resetValuesForSelectedCone), - coneRefinementFramePtr_ - ); - - g_signal_connect - ( - G_OBJECT(entry_coneRefinement_selectedP1X), - "changed", - G_CALLBACK(resetValuesForSelectedCone), - coneRefinementFramePtr_ - ); - - g_signal_connect - ( - G_OBJECT(entry_coneRefinement_selectedP1Y), - "changed", - G_CALLBACK(resetValuesForSelectedCone), - coneRefinementFramePtr_ - ); - - g_signal_connect - ( - G_OBJECT(entry_coneRefinement_selectedP1Z), - "changed", - G_CALLBACK(resetValuesForSelectedCone), - coneRefinementFramePtr_ - ); - - gtk_widget_show(coneRefinementFramePtr_); + /* Store pointers to all widgets, for use by lookup_widget(). */ + GLADE_HOOKUP_OBJECT_NO_REF + ( + coneRefinementFramePtr_, + coneRefinementFramePtr_, + "coneRefinementFramePtr_"); + GLADE_HOOKUP_OBJECT + ( + coneRefinementFramePtr_, + table1, + "table1" + ); + GLADE_HOOKUP_OBJECT + ( + coneRefinementFramePtr_, + entry_coneName, + "entry_coneName" + ); + GLADE_HOOKUP_OBJECT + ( + coneRefinementFramePtr_, + entry_coneRefinement_cellSize, + "entry_coneRefinement_cellSize" + ); + GLADE_HOOKUP_OBJECT + ( + coneRefinementFramePtr_, + entry_coneRefinement_p0X, + "entry_coneRefinement_p0X" + ); + GLADE_HOOKUP_OBJECT + ( + coneRefinementFramePtr_, + entry_coneRefinement_p0Y, + "entry_coneRefinement_p0Y" + ); + GLADE_HOOKUP_OBJECT + ( + coneRefinementFramePtr_, + entry_coneRefinement_radius0, + "entry_coneRefinement_radius0" + ); + GLADE_HOOKUP_OBJECT + ( + coneRefinementFramePtr_, + entry_coneRefinement_radius1, + "entry_coneRefinement_radius1" + ); + GLADE_HOOKUP_OBJECT + ( + coneRefinementFramePtr_, + entry_coneRefinement_p0Z, + "entry_coneRefinement_p0Z" + ); + GLADE_HOOKUP_OBJECT + ( + coneRefinementFramePtr_, + entry_coneRefinement_p1X, + "entry_coneRefinement_p1X" + ); + GLADE_HOOKUP_OBJECT + ( + coneRefinementFramePtr_, + entry_coneRefinement_p1Y, + "entry_coneRefinement_p1Y" + ); + GLADE_HOOKUP_OBJECT + ( + coneRefinementFramePtr_, + entry_coneRefinement_p1Z, + "entry_coneRefinement_p1Z" + ); + GLADE_HOOKUP_OBJECT + ( + coneRefinementFramePtr_, + comboboxentry_coneRefinement_createdCones, + "comboboxentry_coneRefinement_createdCones" + ); + GLADE_HOOKUP_OBJECT + ( + coneRefinementFramePtr_, + entry_coneRefinement_selectedCellSize, + "entry_coneRefinement_selectedCellSize" + ); + GLADE_HOOKUP_OBJECT + ( + coneRefinementFramePtr_, + entry_coneRefinement_selectedP0X, + "entry_coneRefinement_selectedP0X" + ); + GLADE_HOOKUP_OBJECT + ( + coneRefinementFramePtr_, + entry_coneRefinement_selectedP0Y, + "entry_coneRefinement_selectedP0Y" + ); + GLADE_HOOKUP_OBJECT + ( + coneRefinementFramePtr_, + entry_coneRefinement_selectedP0Z, + "entry_coneRefinement_selectedP0Z" + ); + GLADE_HOOKUP_OBJECT + ( + coneRefinementFramePtr_, + entry_coneRefinement_selectedRadius0, + "entry_coneRefinement_selectedRadius0" + ); + GLADE_HOOKUP_OBJECT + ( + coneRefinementFramePtr_, + entry_coneRefinement_selectedP1X, + "entry_coneRefinement_selectedP1X" + ); + GLADE_HOOKUP_OBJECT + ( + coneRefinementFramePtr_, + entry_coneRefinement_selectedP1Y, + "entry_coneRefinement_selectedP1Y" + ); + GLADE_HOOKUP_OBJECT + ( + coneRefinementFramePtr_, + entry_coneRefinement_selectedP1Z, + "entry_coneRefinement_selectedP1Z" + ); + GLADE_HOOKUP_OBJECT + ( + coneRefinementFramePtr_, + entry_coneRefinement_selectedRadius1, + "entry_coneRefinement_selectedRadius1" + ); + + updateConeRefinements(coneRefinementFramePtr_); + + g_signal_connect + ( + G_OBJECT + ( + GTK_ENTRY + ( + GTK_COMBO(comboboxentry_coneRefinement_createdCones)->entry + ) + ), + "changed", + G_CALLBACK(showDataForConeRefinement), + coneRefinementFramePtr_ + ); + + g_signal_connect + ( + G_OBJECT(entry_coneRefinement_selectedCellSize), + "changed", + G_CALLBACK(resetValuesForSelectedCone), + coneRefinementFramePtr_ + ); + + g_signal_connect + ( + G_OBJECT(entry_coneRefinement_selectedP0X), + "changed", + G_CALLBACK(resetValuesForSelectedCone), + coneRefinementFramePtr_ + ); + + g_signal_connect + ( + G_OBJECT(entry_coneRefinement_selectedP0Y), + "changed", + G_CALLBACK(resetValuesForSelectedCone), + coneRefinementFramePtr_ + ); + + g_signal_connect + ( + G_OBJECT(entry_coneRefinement_selectedP0Z), + "changed", + G_CALLBACK(resetValuesForSelectedCone), + coneRefinementFramePtr_ + ); + + g_signal_connect + ( + G_OBJECT(entry_coneRefinement_selectedP1X), + "changed", + G_CALLBACK(resetValuesForSelectedCone), + coneRefinementFramePtr_ + ); + + g_signal_connect + ( + G_OBJECT(entry_coneRefinement_selectedP1Y), + "changed", + G_CALLBACK(resetValuesForSelectedCone), + coneRefinementFramePtr_ + ); + + g_signal_connect + ( + G_OBJECT(entry_coneRefinement_selectedP1Z), + "changed", + G_CALLBACK(resetValuesForSelectedCone), + coneRefinementFramePtr_ + ); + + gtk_widget_show(coneRefinementFramePtr_); } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/GUI/meshGenGTK/meshGenGTKGeneralPage.C b/GUI/meshGenGTK/meshGenGTKGeneralPage.C index 42be44f8..80469144 100644 --- a/GUI/meshGenGTK/meshGenGTKGeneralPage.C +++ b/GUI/meshGenGTK/meshGenGTKGeneralPage.C @@ -34,136 +34,136 @@ Description namespace Foam { - + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // callback functions - + extern "C" { - + static void useButtonCallback(GtkWidget* widget, gpointer data) { - if( (gchar*)data == "UseBndSize" ) - { - if( guiPtr->boundaryCellSizeEntryExist() ) - { - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), 0); - guiPtr->removeBoundaryCellSize(); - } - else - { - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), 1); - guiPtr->setBoundaryCellSize - ( - guiPtr->maxCellSize() - ); - } - } - else if( (gchar*)data == "UseAutoRef" ) - { - if( guiPtr->minCellSizeEntryExist() ) - { - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), 0); - guiPtr->removeMinCellSize(); - } - else - { - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), 1); - guiPtr->setMinCellSize(guiPtr->maxCellSize()); - } - } - else if( (gchar*)data == "UseKeepCellsIntersectingBoundary" ) - { - if( guiPtr->keepCellsIntersectingBoundaryEntryExist() ) - { - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), 0); - guiPtr->removeKeepCellsIntersectingBoundary(); - - if( guiPtr->checkForGluedMeshEntryExist() ) - { - GtkWidget* checkButtonGluedMesh = - (GtkWidget*)g_object_get_data - ( - G_OBJECT(widget), - "checkbutton_checkForGluedMesh" - ); - - gtk_toggle_button_set_active - ( - GTK_TOGGLE_BUTTON(checkButtonGluedMesh), - 0 - ); - guiPtr->removeCheckForGluedMesh(); - } - } - else - { - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), 1); - guiPtr->setKeepCellsIntersectingBoundary(); - } - } - else if( (gchar*)(data) == "UseCheckForGluedMesh" ) - { - if( !guiPtr->keepCellsIntersectingBoundary() ) - { - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), 0); - return; - } - - if( guiPtr->checkForGluedMeshEntryExist() ) - { - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), 0); - guiPtr->removeCheckForGluedMesh(); - } - else - { - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), 1); - guiPtr->setCheckForGluedMesh(); - } - } + if( (gchar*)data == "UseBndSize" ) + { + if( guiPtr->boundaryCellSizeEntryExist() ) + { + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), 0); + guiPtr->removeBoundaryCellSize(); + } + else + { + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), 1); + guiPtr->setBoundaryCellSize + ( + guiPtr->maxCellSize() + ); + } + } + else if( (gchar*)data == "UseAutoRef" ) + { + if( guiPtr->minCellSizeEntryExist() ) + { + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), 0); + guiPtr->removeMinCellSize(); + } + else + { + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), 1); + guiPtr->setMinCellSize(guiPtr->maxCellSize()); + } + } + else if( (gchar*)data == "UseKeepCellsIntersectingBoundary" ) + { + if( guiPtr->keepCellsIntersectingBoundaryEntryExist() ) + { + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), 0); + guiPtr->removeKeepCellsIntersectingBoundary(); + + if( guiPtr->checkForGluedMeshEntryExist() ) + { + GtkWidget* checkButtonGluedMesh = + (GtkWidget*)g_object_get_data + ( + G_OBJECT(widget), + "checkbutton_checkForGluedMesh" + ); + + gtk_toggle_button_set_active + ( + GTK_TOGGLE_BUTTON(checkButtonGluedMesh), + 0 + ); + guiPtr->removeCheckForGluedMesh(); + } + } + else + { + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), 1); + guiPtr->setKeepCellsIntersectingBoundary(); + } + } + else if( (gchar*)(data) == "UseCheckForGluedMesh" ) + { + if( !guiPtr->keepCellsIntersectingBoundary() ) + { + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), 0); + return; + } + + if( guiPtr->checkForGluedMeshEntryExist() ) + { + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), 0); + guiPtr->removeCheckForGluedMesh(); + } + else + { + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), 1); + guiPtr->setCheckForGluedMesh(); + } + } } static void enterSurfaceFile(GtkWidget* widget, GtkEntry* entry) { - const fileName file = gtk_entry_get_text(entry); - guiPtr->setSurfaceFileName(file); + const fileName file = gtk_entry_get_text(entry); + guiPtr->setSurfaceFileName(file); } static void enterMaxCellSize(GtkWidget* widget, GtkEntry* entry) { - const word s = gtk_entry_get_text(GTK_ENTRY(widget)); - const scalar size = help::textToScalar(s); - guiPtr->setMaxCellSize(size); + const word s = gtk_entry_get_text(GTK_ENTRY(widget)); + const scalar size = help::textToScalar(s); + guiPtr->setMaxCellSize(size); } static void enterBndCellSize(GtkWidget* widget, GtkEntry* entry) { - if( !guiPtr->boundaryCellSizeEntryExist() ) - return; - const word s = gtk_entry_get_text(GTK_ENTRY(widget)); - const scalar size = help::textToScalar(s); - guiPtr->setBoundaryCellSize(size); + if( !guiPtr->boundaryCellSizeEntryExist() ) + return; + const word s = gtk_entry_get_text(GTK_ENTRY(widget)); + const scalar size = help::textToScalar(s); + guiPtr->setBoundaryCellSize(size); } static void enterMinCellSize(GtkWidget* widget, GtkEntry* entry) { - if( !guiPtr->minCellSizeEntryExist() ) - return; - const word s = gtk_entry_get_text(GTK_ENTRY(widget)); - const scalar size = help::textToScalar(s); - guiPtr->setMinCellSize(size); + if( !guiPtr->minCellSizeEntryExist() ) + return; + const word s = gtk_entry_get_text(GTK_ENTRY(widget)); + const scalar size = help::textToScalar(s); + guiPtr->setMinCellSize(size); } static void editableEntry(GtkWidget *checkbutton, GtkWidget *entry) { - gtk_editable_set_editable - ( - GTK_EDITABLE(entry), - GTK_TOGGLE_BUTTON(checkbutton)->active - ); - - if( !GTK_TOGGLE_BUTTON(checkbutton)->active ) - gtk_entry_set_text(GTK_ENTRY(entry), ""); + gtk_editable_set_editable + ( + GTK_EDITABLE(entry), + GTK_TOGGLE_BUTTON(checkbutton)->active + ); + + if( !GTK_TOGGLE_BUTTON(checkbutton)->active ) + gtk_entry_set_text(GTK_ENTRY(entry), ""); } } @@ -172,384 +172,384 @@ static void editableEntry(GtkWidget *checkbutton, GtkWidget *entry) void meshGenGTK::createGeneralPage() { - guiPtr = &meshGui_; - - //- create a window for a general page - generalPageFramePtr_ = gtk_frame_new(NULL); - - GtkWidget* table1 = gtk_table_new (11, 5, FALSE); - gtk_widget_show(table1); - gtk_container_add(GTK_CONTAINER(generalPageFramePtr_), table1); + guiPtr = &meshGui_; + + //- create a window for a general page + generalPageFramePtr_ = gtk_frame_new(NULL); + + GtkWidget* table1 = gtk_table_new (11, 5, FALSE); + gtk_widget_show(table1); + gtk_container_add(GTK_CONTAINER(generalPageFramePtr_), table1); // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - //- set the surface file - GtkWidget* label_surfaceFile = gtk_label_new("Surface file"); - gtk_widget_show(label_surfaceFile); - gtk_table_attach(GTK_TABLE(table1), label_surfaceFile, 1, 2, 0, 1, + //- set the surface file + GtkWidget* label_surfaceFile = gtk_label_new("Surface file"); + gtk_widget_show(label_surfaceFile); + gtk_table_attach(GTK_TABLE(table1), label_surfaceFile, 1, 2, 0, 1, (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0); - gtk_misc_set_alignment(GTK_MISC (label_surfaceFile), 0, 0.5); + gtk_misc_set_alignment(GTK_MISC (label_surfaceFile), 0, 0.5); - GtkWidget* label_Space = gtk_label_new(""); - gtk_widget_show(label_Space); - gtk_table_attach(GTK_TABLE(table1), label_Space, 2, 3, 0, 1, + GtkWidget* label_Space = gtk_label_new(""); + gtk_widget_show(label_Space); + gtk_table_attach(GTK_TABLE(table1), label_Space, 2, 3, 0, 1, (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0); - gtk_widget_set_size_request(label_Space, 10, -1); - gtk_misc_set_alignment(GTK_MISC(label_Space), 0, 0.5); - - //- create entry box for the surface file - GtkWidget* entry_surfaceFile = gtk_entry_new(); - gtk_widget_show(entry_surfaceFile); - gtk_table_attach(GTK_TABLE(table1), entry_surfaceFile, 3, 4, 0, 1, + gtk_widget_set_size_request(label_Space, 10, -1); + gtk_misc_set_alignment(GTK_MISC(label_Space), 0, 0.5); + + //- create entry box for the surface file + GtkWidget* entry_surfaceFile = gtk_entry_new(); + gtk_widget_show(entry_surfaceFile); + gtk_table_attach(GTK_TABLE(table1), entry_surfaceFile, 3, 4, 0, 1, (GtkAttachOptions)(GTK_EXPAND | GTK_FILL), (GtkAttachOptions)(0), 0, 0); - - gtk_entry_set_text - ( - GTK_ENTRY(entry_surfaceFile), - meshGui_.surfaceFileName().c_str() - ); - - gtk_editable_set_editable - ( - GTK_EDITABLE(entry_surfaceFile), - 1 - ); - - g_signal_connect(G_OBJECT(entry_surfaceFile), "changed", - G_CALLBACK(enterSurfaceFile), - (gpointer)entry_surfaceFile); + + gtk_entry_set_text + ( + GTK_ENTRY(entry_surfaceFile), + meshGui_.surfaceFileName().c_str() + ); + + gtk_editable_set_editable + ( + GTK_EDITABLE(entry_surfaceFile), + 1 + ); + + g_signal_connect(G_OBJECT(entry_surfaceFile), "changed", + G_CALLBACK(enterSurfaceFile), + (gpointer)entry_surfaceFile); -/* GtkWidget* image1 = - gtk_image_new_from_stock("gtk-open", GTK_ICON_SIZE_BUTTON); - gtk_widget_show(image1); - gtk_table_attach(GTK_TABLE (table1), image1, 4, 5, 0, 1, +/* GtkWidget* image1 = + gtk_image_new_from_stock("gtk-open", GTK_ICON_SIZE_BUTTON); + gtk_widget_show(image1); + gtk_table_attach(GTK_TABLE (table1), image1, 4, 5, 0, 1, (GtkAttachOptions)(GTK_EXPAND | GTK_FILL), (GtkAttachOptions)(GTK_FILL), 0, 0); */ // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - //- box for maxCellSize - GtkWidget* label_maxCellSize = gtk_label_new("Max cell size [m]"); - gtk_widget_show(label_maxCellSize); - gtk_table_attach(GTK_TABLE(table1), label_maxCellSize, 1, 2, 1, 2, + //- box for maxCellSize + GtkWidget* label_maxCellSize = gtk_label_new("Max cell size [m]"); + gtk_widget_show(label_maxCellSize); + gtk_table_attach(GTK_TABLE(table1), label_maxCellSize, 1, 2, 1, 2, (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0); - gtk_misc_set_alignment(GTK_MISC(label_maxCellSize), 0, 0.5); + gtk_misc_set_alignment(GTK_MISC(label_maxCellSize), 0, 0.5); - //- entry for maxCellSize - GtkWidget* entry_maxCellSize = gtk_entry_new(); - gtk_widget_show(entry_maxCellSize); - gtk_table_attach(GTK_TABLE(table1), entry_maxCellSize, 3, 5, 1, 2, + //- entry for maxCellSize + GtkWidget* entry_maxCellSize = gtk_entry_new(); + gtk_widget_show(entry_maxCellSize); + gtk_table_attach(GTK_TABLE(table1), entry_maxCellSize, 3, 5, 1, 2, (GtkAttachOptions)(GTK_EXPAND | GTK_FILL), (GtkAttachOptions)(0), 0, 0); - - gtk_entry_set_text - ( - GTK_ENTRY(entry_maxCellSize), - help::scalarToText(meshGui_.maxCellSize()).c_str() - ); - - g_signal_connect - ( - G_OBJECT(entry_maxCellSize), "changed", - G_CALLBACK(enterMaxCellSize), - (gpointer)entry_maxCellSize - ); - + + gtk_entry_set_text + ( + GTK_ENTRY(entry_maxCellSize), + help::scalarToText(meshGui_.maxCellSize()).c_str() + ); + + g_signal_connect + ( + G_OBJECT(entry_maxCellSize), "changed", + G_CALLBACK(enterMaxCellSize), + (gpointer)entry_maxCellSize + ); + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - //- horizontal separator - GtkWidget* hseparator0 = gtk_hseparator_new(); - gtk_widget_show(hseparator0); - gtk_table_attach(GTK_TABLE(table1), hseparator0, 0, 5, 2, 3, + //- horizontal separator + GtkWidget* hseparator0 = gtk_hseparator_new(); + gtk_widget_show(hseparator0); + gtk_table_attach(GTK_TABLE(table1), hseparator0, 0, 5, 2, 3, (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(GTK_EXPAND | GTK_SHRINK | GTK_FILL), - 0, 0); - + 0, 0); + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // //- boundary cell size - //- checkbutton for boundaryCellSize - GtkWidget* checkbutton_boundaryCellSize = - gtk_check_button_new_with_mnemonic - ( - "Use different size for boundary cells" - ); - gtk_widget_show(checkbutton_boundaryCellSize); - gtk_table_attach(GTK_TABLE(table1), - checkbutton_boundaryCellSize, 0, 5, 3, 4, + //- checkbutton for boundaryCellSize + GtkWidget* checkbutton_boundaryCellSize = + gtk_check_button_new_with_mnemonic + ( + "Use different size for boundary cells" + ); + gtk_widget_show(checkbutton_boundaryCellSize); + gtk_table_attach(GTK_TABLE(table1), + checkbutton_boundaryCellSize, 0, 5, 3, 4, (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 1, 0); - - //- add callbacks for the button - if( meshGui_.boundaryCellSizeEntryExist() ) - { - gtk_toggle_button_set_active - ( - GTK_TOGGLE_BUTTON(checkbutton_boundaryCellSize), - 1 - ); - } - else - { - gtk_toggle_button_set_active - ( - GTK_TOGGLE_BUTTON(checkbutton_boundaryCellSize), - 0 - ); - } - - g_signal_connect - ( - gpointer(checkbutton_boundaryCellSize), - "clicked", - G_CALLBACK(useButtonCallback), - (gpointer)"UseBndSize" - ); + + //- add callbacks for the button + if( meshGui_.boundaryCellSizeEntryExist() ) + { + gtk_toggle_button_set_active + ( + GTK_TOGGLE_BUTTON(checkbutton_boundaryCellSize), + 1 + ); + } + else + { + gtk_toggle_button_set_active + ( + GTK_TOGGLE_BUTTON(checkbutton_boundaryCellSize), + 0 + ); + } + + g_signal_connect + ( + gpointer(checkbutton_boundaryCellSize), + "clicked", + G_CALLBACK(useButtonCallback), + (gpointer)"UseBndSize" + ); -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - //- create a box for boundary cell size - GtkWidget* label_boundaryCellSize = gtk_label_new("Boundary cell size [m]"); - gtk_widget_show(label_boundaryCellSize); - gtk_table_attach(GTK_TABLE(table1), label_boundaryCellSize, 1, 2, 4, 5, +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + //- create a box for boundary cell size + GtkWidget* label_boundaryCellSize = gtk_label_new("Boundary cell size [m]"); + gtk_widget_show(label_boundaryCellSize); + gtk_table_attach(GTK_TABLE(table1), label_boundaryCellSize, 1, 2, 4, 5, (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0); - gtk_misc_set_alignment(GTK_MISC(label_boundaryCellSize), 0, 0.5); - - GtkWidget* entry_boundaryCellSize = gtk_entry_new(); - gtk_widget_show(entry_boundaryCellSize); - gtk_table_attach(GTK_TABLE (table1), entry_boundaryCellSize, 3, 5, 4, 5, + gtk_misc_set_alignment(GTK_MISC(label_boundaryCellSize), 0, 0.5); + + GtkWidget* entry_boundaryCellSize = gtk_entry_new(); + gtk_widget_show(entry_boundaryCellSize); + gtk_table_attach(GTK_TABLE (table1), entry_boundaryCellSize, 3, 5, 4, 5, (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), (GtkAttachOptions) (0), 1, 0); - gtk_entry_set_invisible_char (GTK_ENTRY (entry_boundaryCellSize), 9679); - - gtk_entry_set_visibility - ( - GTK_ENTRY(entry_boundaryCellSize), - meshGui_.boundaryCellSizeEntryExist() - ); - - if( meshGui_.boundaryCellSizeEntryExist() ) - { - gtk_entry_set_text - ( - GTK_ENTRY(entry_boundaryCellSize), - help::scalarToText(meshGui_.boundaryCellSize()).c_str() - ); - } - else - { - gtk_editable_set_editable(GTK_EDITABLE(entry_boundaryCellSize), 0); - } - - g_signal_connect - ( - G_OBJECT(checkbutton_boundaryCellSize), - "toggled", - G_CALLBACK(editableEntry), - (gpointer)entry_boundaryCellSize - ); - - g_signal_connect - ( - G_OBJECT(entry_boundaryCellSize), - "changed", - G_CALLBACK(enterBndCellSize), - (gpointer)entry_boundaryCellSize - ); - + gtk_entry_set_invisible_char (GTK_ENTRY (entry_boundaryCellSize), 9679); + + gtk_entry_set_visibility + ( + GTK_ENTRY(entry_boundaryCellSize), + meshGui_.boundaryCellSizeEntryExist() + ); + + if( meshGui_.boundaryCellSizeEntryExist() ) + { + gtk_entry_set_text + ( + GTK_ENTRY(entry_boundaryCellSize), + help::scalarToText(meshGui_.boundaryCellSize()).c_str() + ); + } + else + { + gtk_editable_set_editable(GTK_EDITABLE(entry_boundaryCellSize), 0); + } + + g_signal_connect + ( + G_OBJECT(checkbutton_boundaryCellSize), + "toggled", + G_CALLBACK(editableEntry), + (gpointer)entry_boundaryCellSize + ); + + g_signal_connect + ( + G_OBJECT(entry_boundaryCellSize), + "changed", + G_CALLBACK(enterBndCellSize), + (gpointer)entry_boundaryCellSize + ); + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - //- horizontal separator - GtkWidget* hseparator1 = gtk_hseparator_new(); - gtk_widget_show(hseparator1); - gtk_table_attach(GTK_TABLE(table1), hseparator1, 0, 5, 5, 6, + //- horizontal separator + GtkWidget* hseparator1 = gtk_hseparator_new(); + gtk_widget_show(hseparator1); + gtk_table_attach(GTK_TABLE(table1), hseparator1, 0, 5, 5, 6, (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(GTK_EXPAND | GTK_SHRINK | GTK_FILL), - 0, 0); - + 0, 0); + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - //- create a box for automatic refinement - - //- checkbox for automatic refinement - GtkWidget* checkbutton_automaticRefinement = - gtk_check_button_new_with_mnemonic("Use automatic refinement"); - gtk_widget_show(checkbutton_automaticRefinement); - gtk_table_attach(GTK_TABLE(table1), checkbutton_automaticRefinement, - 0, 5, 6, 7, + //- create a box for automatic refinement + + //- checkbox for automatic refinement + GtkWidget* checkbutton_automaticRefinement = + gtk_check_button_new_with_mnemonic("Use automatic refinement"); + gtk_widget_show(checkbutton_automaticRefinement); + gtk_table_attach(GTK_TABLE(table1), checkbutton_automaticRefinement, + 0, 5, 6, 7, (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0); - - if( meshGui_.minCellSizeEntryExist() ) - { - gtk_toggle_button_set_active - ( - GTK_TOGGLE_BUTTON(checkbutton_automaticRefinement), 1 - ); - } - else - { - gtk_toggle_button_set_active - ( - GTK_TOGGLE_BUTTON(checkbutton_automaticRefinement), 0 - ); - } - - g_signal_connect - ( - gpointer(checkbutton_automaticRefinement), - "clicked", - G_CALLBACK(useButtonCallback), - (gpointer)"UseAutoRef" - ); - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - //- create a box for min cell size - GtkWidget* label_minCellSize = gtk_label_new("Min cell size [m]"); - gtk_widget_show(label_minCellSize); - gtk_table_attach(GTK_TABLE(table1), label_minCellSize, 1, 2, 7, 8, + + if( meshGui_.minCellSizeEntryExist() ) + { + gtk_toggle_button_set_active + ( + GTK_TOGGLE_BUTTON(checkbutton_automaticRefinement), 1 + ); + } + else + { + gtk_toggle_button_set_active + ( + GTK_TOGGLE_BUTTON(checkbutton_automaticRefinement), 0 + ); + } + + g_signal_connect + ( + gpointer(checkbutton_automaticRefinement), + "clicked", + G_CALLBACK(useButtonCallback), + (gpointer)"UseAutoRef" + ); + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + //- create a box for min cell size + GtkWidget* label_minCellSize = gtk_label_new("Min cell size [m]"); + gtk_widget_show(label_minCellSize); + gtk_table_attach(GTK_TABLE(table1), label_minCellSize, 1, 2, 7, 8, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0), 0, 0); - gtk_misc_set_alignment (GTK_MISC (label_minCellSize), 0, 0.5); - - GtkWidget* entry_minCellSize = gtk_entry_new(); - gtk_widget_show(entry_minCellSize); - gtk_table_attach(GTK_TABLE (table1), entry_minCellSize, 3, 5, 7, 8, + gtk_misc_set_alignment (GTK_MISC (label_minCellSize), 0, 0.5); + + GtkWidget* entry_minCellSize = gtk_entry_new(); + gtk_widget_show(entry_minCellSize); + gtk_table_attach(GTK_TABLE (table1), entry_minCellSize, 3, 5, 7, 8, (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), (GtkAttachOptions) (0), 1, 0); - - if( meshGui_.minCellSizeEntryExist() ) - { - gtk_entry_set_text - ( - GTK_ENTRY(entry_minCellSize), - help::scalarToText(meshGui_.minCellSize()).c_str() - ); - } - else - { - gtk_editable_set_editable(GTK_EDITABLE(entry_minCellSize), 0); - } - - g_signal_connect - ( - G_OBJECT(checkbutton_automaticRefinement), - "toggled", - G_CALLBACK(editableEntry), - (gpointer)entry_minCellSize - ); - - g_signal_connect - ( - G_OBJECT(entry_minCellSize), - "changed", - G_CALLBACK(enterMinCellSize), - (gpointer)entry_minCellSize - ); - + + if( meshGui_.minCellSizeEntryExist() ) + { + gtk_entry_set_text + ( + GTK_ENTRY(entry_minCellSize), + help::scalarToText(meshGui_.minCellSize()).c_str() + ); + } + else + { + gtk_editable_set_editable(GTK_EDITABLE(entry_minCellSize), 0); + } + + g_signal_connect + ( + G_OBJECT(checkbutton_automaticRefinement), + "toggled", + G_CALLBACK(editableEntry), + (gpointer)entry_minCellSize + ); + + g_signal_connect + ( + G_OBJECT(entry_minCellSize), + "changed", + G_CALLBACK(enterMinCellSize), + (gpointer)entry_minCellSize + ); + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - //- horizontal separator - GtkWidget* hseparator2 = gtk_hseparator_new(); - gtk_widget_show(hseparator2); - gtk_table_attach(GTK_TABLE(table1), hseparator2, 0, 5, 8, 9, + //- horizontal separator + GtkWidget* hseparator2 = gtk_hseparator_new(); + gtk_widget_show(hseparator2); + gtk_table_attach(GTK_TABLE(table1), hseparator2, 0, 5, 8, 9, (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(GTK_EXPAND | GTK_SHRINK | GTK_FILL), - 0, 0); - + 0, 0); + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - //- activate keepCellsIntersectingBoundary option - GtkWidget* checkbutton_keepCellsIntersectingBoundary = - gtk_check_button_new_with_mnemonic - ( - "Keep octree boxes intersecting the boundary" - ); - gtk_widget_show(checkbutton_keepCellsIntersectingBoundary); - gtk_table_attach(GTK_TABLE(table1), - checkbutton_keepCellsIntersectingBoundary, - 0, 5, 9, 10, + //- activate keepCellsIntersectingBoundary option + GtkWidget* checkbutton_keepCellsIntersectingBoundary = + gtk_check_button_new_with_mnemonic + ( + "Keep octree boxes intersecting the boundary" + ); + gtk_widget_show(checkbutton_keepCellsIntersectingBoundary); + gtk_table_attach(GTK_TABLE(table1), + checkbutton_keepCellsIntersectingBoundary, + 0, 5, 9, 10, (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0); - - if( meshGui_.keepCellsIntersectingBoundaryEntryExist() ) - { - gtk_toggle_button_set_active - ( - GTK_TOGGLE_BUTTON(checkbutton_keepCellsIntersectingBoundary) - ,1 - ); - } - else - { - gtk_toggle_button_set_active - ( - GTK_TOGGLE_BUTTON(checkbutton_keepCellsIntersectingBoundary) - ,0 - ); - } - - g_signal_connect - ( - gpointer(checkbutton_keepCellsIntersectingBoundary), - "clicked", - G_CALLBACK(useButtonCallback), - (gpointer)"UseKeepCellsIntersectingBoundary" - ); - + + if( meshGui_.keepCellsIntersectingBoundaryEntryExist() ) + { + gtk_toggle_button_set_active + ( + GTK_TOGGLE_BUTTON(checkbutton_keepCellsIntersectingBoundary) + ,1 + ); + } + else + { + gtk_toggle_button_set_active + ( + GTK_TOGGLE_BUTTON(checkbutton_keepCellsIntersectingBoundary) + ,0 + ); + } + + g_signal_connect + ( + gpointer(checkbutton_keepCellsIntersectingBoundary), + "clicked", + G_CALLBACK(useButtonCallback), + (gpointer)"UseKeepCellsIntersectingBoundary" + ); + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - //- activate checkForGluedMesh - GtkWidget* checkbutton_checkForGluedMesh = - gtk_check_button_new_with_mnemonic("Remove invalid mesh connections"); - gtk_widget_show(checkbutton_checkForGluedMesh); - gtk_table_attach(GTK_TABLE(table1), checkbutton_checkForGluedMesh, - 0, 5, 10, 11, + //- activate checkForGluedMesh + GtkWidget* checkbutton_checkForGluedMesh = + gtk_check_button_new_with_mnemonic("Remove invalid mesh connections"); + gtk_widget_show(checkbutton_checkForGluedMesh); + gtk_table_attach(GTK_TABLE(table1), checkbutton_checkForGluedMesh, + 0, 5, 10, 11, (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0); - - if( !meshGui_.keepCellsIntersectingBoundary() ) - meshGui_.removeCheckForGluedMesh(); - - if( meshGui_.checkForGluedMesh() ) - { - gtk_toggle_button_set_active - ( - GTK_TOGGLE_BUTTON(checkbutton_checkForGluedMesh), - 1 - ); - } - else - { - gtk_toggle_button_set_active - ( - GTK_TOGGLE_BUTTON(checkbutton_checkForGluedMesh), - 0 - ); - } - - g_signal_connect - ( - gpointer(checkbutton_checkForGluedMesh), - "clicked", - G_CALLBACK(useButtonCallback), - (gpointer)"UseCheckForGluedMesh" - ); - + + if( !meshGui_.keepCellsIntersectingBoundary() ) + meshGui_.removeCheckForGluedMesh(); + + if( meshGui_.checkForGluedMesh() ) + { + gtk_toggle_button_set_active + ( + GTK_TOGGLE_BUTTON(checkbutton_checkForGluedMesh), + 1 + ); + } + else + { + gtk_toggle_button_set_active + ( + GTK_TOGGLE_BUTTON(checkbutton_checkForGluedMesh), + 0 + ); + } + + g_signal_connect + ( + gpointer(checkbutton_checkForGluedMesh), + "clicked", + G_CALLBACK(useButtonCallback), + (gpointer)"UseCheckForGluedMesh" + ); + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - /* Store pointers to all widgets, for use by lookup_widget(). */ - GLADE_HOOKUP_OBJECT_NO_REF - ( - generalPageFramePtr_, - generalPageFramePtr_, - "window_generalPage_" - ); - GLADE_HOOKUP_OBJECT - ( - checkbutton_keepCellsIntersectingBoundary, - checkbutton_checkForGluedMesh, - "checkbutton_checkForGluedMesh" - ); - - gtk_widget_show(generalPageFramePtr_); + /* Store pointers to all widgets, for use by lookup_widget(). */ + GLADE_HOOKUP_OBJECT_NO_REF + ( + generalPageFramePtr_, + generalPageFramePtr_, + "window_generalPage_" + ); + GLADE_HOOKUP_OBJECT + ( + checkbutton_keepCellsIntersectingBoundary, + checkbutton_checkForGluedMesh, + "checkbutton_checkForGluedMesh" + ); + + gtk_widget_show(generalPageFramePtr_); } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/GUI/meshGenGTK/meshGenGTKKeepCellsIntersectingPatches.C b/GUI/meshGenGTK/meshGenGTKKeepCellsIntersectingPatches.C index d14adbc4..10e6c479 100644 --- a/GUI/meshGenGTK/meshGenGTKKeepCellsIntersectingPatches.C +++ b/GUI/meshGenGTK/meshGenGTKKeepCellsIntersectingPatches.C @@ -37,374 +37,374 @@ namespace Foam // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // //- callback functions - + extern "C" { static void updateKeepCellsIntersectingPatches ( - GtkWidget* keepCellsIntersectingPatchesFramePtr + GtkWidget* keepCellsIntersectingPatchesFramePtr ) { - GtkWidget* comboboxentry_keepCellsIntersectingPatches_availablePatches = - (GtkWidget*)g_object_get_data - ( - G_OBJECT(keepCellsIntersectingPatchesFramePtr), - "comboboxentry_keepCellsIntersectingPatches_availablePatches" - ); - GtkWidget* comboboxentry_keepCellsIntersectingPatches_selectedPatches = - (GtkWidget*)g_object_get_data - ( - G_OBJECT(keepCellsIntersectingPatchesFramePtr), - "comboboxentry_keepCellsIntersectingPatches_selectedPatches" - ); - //- update available patches - wordList alreadyUsed = guiPtr->keepCellsIntersectingPatches(); - wordHashSet usedNames; - forAll(alreadyUsed, nameI) - usedNames.insert(alreadyUsed[nameI]); - - GList* avPatches = 0; - label nAvailable(0); - const triSurface& surf = guiPtr->surface(); - forAll(surf.patches(), patchI) - { - if( usedNames.found(surf.patches()[patchI].name()) ) - continue; - const char* name = surf.patches()[patchI].name().c_str(); - avPatches = g_list_append(avPatches, const_cast<char*>(name)); - ++nAvailable; - } - - gtk_combo_set_popdown_strings - ( - GTK_COMBO - ( - comboboxentry_keepCellsIntersectingPatches_availablePatches - ), avPatches - ); - - if( nAvailable == 0 ) - { - gtk_entry_set_text - ( - GTK_ENTRY - ( - GTK_COMBO - ( - comboboxentry_keepCellsIntersectingPatches_availablePatches - )->entry - ), "" - ); - } - - //- update used patches - GList* selPatches = 0; - forAll(alreadyUsed, patchI) - { - const char* name = alreadyUsed[patchI].c_str(); - selPatches = g_list_append(selPatches, const_cast<char*>(name)); - } - - gtk_combo_set_popdown_strings - ( - GTK_COMBO - ( - comboboxentry_keepCellsIntersectingPatches_selectedPatches - ), selPatches - ); - - if( alreadyUsed.size() == 0 ) - { - gtk_entry_set_text - ( - GTK_ENTRY - ( - GTK_COMBO - ( - comboboxentry_keepCellsIntersectingPatches_selectedPatches - )->entry - ), "" - ); - } - - g_list_free(avPatches); - g_list_free(selPatches); + GtkWidget* comboboxentry_keepCellsIntersectingPatches_availablePatches = + (GtkWidget*)g_object_get_data + ( + G_OBJECT(keepCellsIntersectingPatchesFramePtr), + "comboboxentry_keepCellsIntersectingPatches_availablePatches" + ); + GtkWidget* comboboxentry_keepCellsIntersectingPatches_selectedPatches = + (GtkWidget*)g_object_get_data + ( + G_OBJECT(keepCellsIntersectingPatchesFramePtr), + "comboboxentry_keepCellsIntersectingPatches_selectedPatches" + ); + //- update available patches + wordList alreadyUsed = guiPtr->keepCellsIntersectingPatches(); + wordHashSet usedNames; + forAll(alreadyUsed, nameI) + usedNames.insert(alreadyUsed[nameI]); + + GList* avPatches = 0; + label nAvailable(0); + const triSurface& surf = guiPtr->surface(); + forAll(surf.patches(), patchI) + { + if( usedNames.found(surf.patches()[patchI].name()) ) + continue; + const char* name = surf.patches()[patchI].name().c_str(); + avPatches = g_list_append(avPatches, const_cast<char*>(name)); + ++nAvailable; + } + + gtk_combo_set_popdown_strings + ( + GTK_COMBO + ( + comboboxentry_keepCellsIntersectingPatches_availablePatches + ), avPatches + ); + + if( nAvailable == 0 ) + { + gtk_entry_set_text + ( + GTK_ENTRY + ( + GTK_COMBO + ( + comboboxentry_keepCellsIntersectingPatches_availablePatches + )->entry + ), "" + ); + } + + //- update used patches + GList* selPatches = 0; + forAll(alreadyUsed, patchI) + { + const char* name = alreadyUsed[patchI].c_str(); + selPatches = g_list_append(selPatches, const_cast<char*>(name)); + } + + gtk_combo_set_popdown_strings + ( + GTK_COMBO + ( + comboboxentry_keepCellsIntersectingPatches_selectedPatches + ), selPatches + ); + + if( alreadyUsed.size() == 0 ) + { + gtk_entry_set_text + ( + GTK_ENTRY + ( + GTK_COMBO + ( + comboboxentry_keepCellsIntersectingPatches_selectedPatches + )->entry + ), "" + ); + } + + g_list_free(avPatches); + g_list_free(selPatches); } - + static void addKeepCellsIntersectingPatches ( - GtkWidget* widget, - GtkWidget* keepCellsIntersectingPatchesFramePtr + GtkWidget* widget, + GtkWidget* keepCellsIntersectingPatchesFramePtr ) { - GtkWidget* comboboxentry_keepCellsIntersectingPatches_availablePatches = - (GtkWidget*)g_object_get_data - ( - G_OBJECT(keepCellsIntersectingPatchesFramePtr), - "comboboxentry_keepCellsIntersectingPatches_availablePatches" - ); - const word name = - gtk_entry_get_text - ( - GTK_ENTRY - ( - GTK_COMBO - ( - comboboxentry_keepCellsIntersectingPatches_availablePatches - )->entry - ) - ); - - if( name == "" ) - return; - - guiPtr->addKeepCellsIntersectingPatches(name); - - updateKeepCellsIntersectingPatches(keepCellsIntersectingPatchesFramePtr); + GtkWidget* comboboxentry_keepCellsIntersectingPatches_availablePatches = + (GtkWidget*)g_object_get_data + ( + G_OBJECT(keepCellsIntersectingPatchesFramePtr), + "comboboxentry_keepCellsIntersectingPatches_availablePatches" + ); + const word name = + gtk_entry_get_text + ( + GTK_ENTRY + ( + GTK_COMBO + ( + comboboxentry_keepCellsIntersectingPatches_availablePatches + )->entry + ) + ); + + if( name == "" ) + return; + + guiPtr->addKeepCellsIntersectingPatches(name); + + updateKeepCellsIntersectingPatches(keepCellsIntersectingPatchesFramePtr); } static void removeKeepCellsIntersectingPatches ( - GtkWidget* widget, - GtkWidget* keepCellsIntersectingPatchesFramePtr + GtkWidget* widget, + GtkWidget* keepCellsIntersectingPatchesFramePtr ) { - GtkWidget* comboboxentry_keepCellsIntersectingPatches_selectedPatches = - (GtkWidget*)g_object_get_data - ( - G_OBJECT(keepCellsIntersectingPatchesFramePtr), - "comboboxentry_keepCellsIntersectingPatches_selectedPatches" - ); - const word name = - gtk_entry_get_text - ( - GTK_ENTRY - ( - GTK_COMBO - ( - comboboxentry_keepCellsIntersectingPatches_selectedPatches - )->entry - ) - ); - - if( name == "" ) - return; - - guiPtr->removeKeepCellsIntersectingPatches(name); - - updateKeepCellsIntersectingPatches(keepCellsIntersectingPatchesFramePtr); + GtkWidget* comboboxentry_keepCellsIntersectingPatches_selectedPatches = + (GtkWidget*)g_object_get_data + ( + G_OBJECT(keepCellsIntersectingPatchesFramePtr), + "comboboxentry_keepCellsIntersectingPatches_selectedPatches" + ); + const word name = + gtk_entry_get_text + ( + GTK_ENTRY + ( + GTK_COMBO + ( + comboboxentry_keepCellsIntersectingPatches_selectedPatches + )->entry + ) + ); + + if( name == "" ) + return; + + guiPtr->removeKeepCellsIntersectingPatches(name); + + updateKeepCellsIntersectingPatches(keepCellsIntersectingPatchesFramePtr); } } void meshGenGTK::createKeepCellsIntersectingPatchesWindowPage() { - guiPtr = &meshGui_; - - keepCellsIntersectingPatchesFramePtr_ = gtk_frame_new(NULL); + guiPtr = &meshGui_; + + keepCellsIntersectingPatchesFramePtr_ = gtk_frame_new(NULL); // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - //- create a table - GtkWidget* table1 = gtk_table_new(2, 3, FALSE); - gtk_widget_show(table1); - gtk_container_add - ( - GTK_CONTAINER(keepCellsIntersectingPatchesFramePtr_), - table1 - ); + //- create a table + GtkWidget* table1 = gtk_table_new(2, 3, FALSE); + gtk_widget_show(table1); + gtk_container_add + ( + GTK_CONTAINER(keepCellsIntersectingPatchesFramePtr_), + table1 + ); // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - //- set label for available patches - GtkWidget* label_keepCellsIntersectingPatches_availablePatches = - gtk_label_new("Available patches"); - gtk_widget_show(label_keepCellsIntersectingPatches_availablePatches); - gtk_table_attach - ( - GTK_TABLE(table1), - label_keepCellsIntersectingPatches_availablePatches, - 0, 1, 0, 1, - (GtkAttachOptions)(GTK_FILL), - (GtkAttachOptions) (0), 0, 0 - ); - gtk_misc_set_alignment - ( - GTK_MISC(label_keepCellsIntersectingPatches_availablePatches), - 0, - 0.5 - ); - + //- set label for available patches + GtkWidget* label_keepCellsIntersectingPatches_availablePatches = + gtk_label_new("Available patches"); + gtk_widget_show(label_keepCellsIntersectingPatches_availablePatches); + gtk_table_attach + ( + GTK_TABLE(table1), + label_keepCellsIntersectingPatches_availablePatches, + 0, 1, 0, 1, + (GtkAttachOptions)(GTK_FILL), + (GtkAttachOptions) (0), 0, 0 + ); + gtk_misc_set_alignment + ( + GTK_MISC(label_keepCellsIntersectingPatches_availablePatches), + 0, + 0.5 + ); + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - //- create the combo box for available patches - GtkWidget* comboboxentry_keepCellsIntersectingPatches_availablePatches = - gtk_combo_new(); - gtk_widget_show - ( - comboboxentry_keepCellsIntersectingPatches_availablePatches - ); - gtk_table_attach - ( - GTK_TABLE(table1), - comboboxentry_keepCellsIntersectingPatches_availablePatches, - 1, 2, 0, 1, - (GtkAttachOptions)(GTK_EXPAND | GTK_FILL), - (GtkAttachOptions)(GTK_FILL), 0, 0 - ); - - gtk_editable_set_editable - ( - GTK_EDITABLE - ( - GTK_COMBO - ( - comboboxentry_keepCellsIntersectingPatches_availablePatches - )->entry - ), - 0 - ); - + //- create the combo box for available patches + GtkWidget* comboboxentry_keepCellsIntersectingPatches_availablePatches = + gtk_combo_new(); + gtk_widget_show + ( + comboboxentry_keepCellsIntersectingPatches_availablePatches + ); + gtk_table_attach + ( + GTK_TABLE(table1), + comboboxentry_keepCellsIntersectingPatches_availablePatches, + 1, 2, 0, 1, + (GtkAttachOptions)(GTK_EXPAND | GTK_FILL), + (GtkAttachOptions)(GTK_FILL), 0, 0 + ); + + gtk_editable_set_editable + ( + GTK_EDITABLE + ( + GTK_COMBO + ( + comboboxentry_keepCellsIntersectingPatches_availablePatches + )->entry + ), + 0 + ); + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - //- set the button for adding patches - GtkWidget* button1 = gtk_button_new(); - gtk_widget_show(button1); - gtk_table_attach - ( - GTK_TABLE(table1), - button1, - 2, 3, 0, 1, - (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0 - ); - - g_signal_connect - ( - G_OBJECT(button1), - "clicked", - G_CALLBACK(addKeepCellsIntersectingPatches), - keepCellsIntersectingPatchesFramePtr_ - ); + //- set the button for adding patches + GtkWidget* button1 = gtk_button_new(); + gtk_widget_show(button1); + gtk_table_attach + ( + GTK_TABLE(table1), + button1, + 2, 3, 0, 1, + (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0 + ); + + g_signal_connect + ( + G_OBJECT(button1), + "clicked", + G_CALLBACK(addKeepCellsIntersectingPatches), + keepCellsIntersectingPatchesFramePtr_ + ); - GtkWidget* alignment1 = gtk_alignment_new(0.5, 0.5, 0, 0); - gtk_widget_show(alignment1); - gtk_container_add(GTK_CONTAINER(button1), alignment1); - - GtkWidget* hbox1 = gtk_hbox_new(FALSE, 2); - gtk_widget_show(hbox1); - gtk_container_add(GTK_CONTAINER(alignment1), hbox1); - - GtkWidget* image1 = - gtk_image_new_from_stock("gtk-add", GTK_ICON_SIZE_BUTTON); - gtk_widget_show(image1); - gtk_box_pack_start(GTK_BOX(hbox1), image1, FALSE, FALSE, 0); - - GtkWidget* label3 = gtk_label_new_with_mnemonic("Add"); - gtk_widget_show(label3); - gtk_box_pack_start(GTK_BOX(hbox1), label3, FALSE, FALSE, 0); - + GtkWidget* alignment1 = gtk_alignment_new(0.5, 0.5, 0, 0); + gtk_widget_show(alignment1); + gtk_container_add(GTK_CONTAINER(button1), alignment1); + + GtkWidget* hbox1 = gtk_hbox_new(FALSE, 2); + gtk_widget_show(hbox1); + gtk_container_add(GTK_CONTAINER(alignment1), hbox1); + + GtkWidget* image1 = + gtk_image_new_from_stock("gtk-add", GTK_ICON_SIZE_BUTTON); + gtk_widget_show(image1); + gtk_box_pack_start(GTK_BOX(hbox1), image1, FALSE, FALSE, 0); + + GtkWidget* label3 = gtk_label_new_with_mnemonic("Add"); + gtk_widget_show(label3); + gtk_box_pack_start(GTK_BOX(hbox1), label3, FALSE, FALSE, 0); + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - //- set label for selected patches - GtkWidget* label_keepCellsIntersectingPatches_selectedPatches = - gtk_label_new("Selected patches"); - gtk_widget_show(label_keepCellsIntersectingPatches_selectedPatches); - gtk_table_attach - ( - GTK_TABLE(table1), - label_keepCellsIntersectingPatches_selectedPatches, - 0, 1, 1, 2, - (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0 - ); - gtk_misc_set_alignment - ( - GTK_MISC(label_keepCellsIntersectingPatches_selectedPatches), - 0, - 0.5 - ); - + //- set label for selected patches + GtkWidget* label_keepCellsIntersectingPatches_selectedPatches = + gtk_label_new("Selected patches"); + gtk_widget_show(label_keepCellsIntersectingPatches_selectedPatches); + gtk_table_attach + ( + GTK_TABLE(table1), + label_keepCellsIntersectingPatches_selectedPatches, + 0, 1, 1, 2, + (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0 + ); + gtk_misc_set_alignment + ( + GTK_MISC(label_keepCellsIntersectingPatches_selectedPatches), + 0, + 0.5 + ); + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - //- create the combo box for selected patches - GtkWidget* comboboxentry_keepCellsIntersectingPatches_selectedPatches = - gtk_combo_new(); - gtk_widget_show(comboboxentry_keepCellsIntersectingPatches_selectedPatches); - gtk_table_attach - ( - GTK_TABLE(table1), - comboboxentry_keepCellsIntersectingPatches_selectedPatches, - 1, 2, 1, 2, - (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (GTK_FILL), 0, 0 - ); - - gtk_editable_set_editable - ( - GTK_EDITABLE - ( - GTK_COMBO - ( - comboboxentry_keepCellsIntersectingPatches_selectedPatches - )->entry - ), - 0 - ); - + //- create the combo box for selected patches + GtkWidget* comboboxentry_keepCellsIntersectingPatches_selectedPatches = + gtk_combo_new(); + gtk_widget_show(comboboxentry_keepCellsIntersectingPatches_selectedPatches); + gtk_table_attach + ( + GTK_TABLE(table1), + comboboxentry_keepCellsIntersectingPatches_selectedPatches, + 1, 2, 1, 2, + (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (GTK_FILL), 0, 0 + ); + + gtk_editable_set_editable + ( + GTK_EDITABLE + ( + GTK_COMBO + ( + comboboxentry_keepCellsIntersectingPatches_selectedPatches + )->entry + ), + 0 + ); + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - //- set the button for removing patches - GtkWidget* button2 = gtk_button_new(); - gtk_widget_show(button2); - gtk_table_attach - ( - GTK_TABLE(table1), - button2, - 2, 3, 1, 2, - (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0 - ); - - g_signal_connect - ( - G_OBJECT(button2), - "clicked", - G_CALLBACK(removeKeepCellsIntersectingPatches), - keepCellsIntersectingPatchesFramePtr_ - ); - - GtkWidget* alignment2 = gtk_alignment_new(0.5, 0.5, 0, 0); - gtk_widget_show(alignment2); - gtk_container_add(GTK_CONTAINER(button2), alignment2); - - GtkWidget* hbox2 = gtk_hbox_new(FALSE, 2); - gtk_widget_show(hbox2); - gtk_container_add(GTK_CONTAINER(alignment2), hbox2); - - GtkWidget* image2 = - gtk_image_new_from_stock("gtk-remove", GTK_ICON_SIZE_BUTTON); - gtk_widget_show(image2); - gtk_box_pack_start(GTK_BOX (hbox2), image2, FALSE, FALSE, 0); - - GtkWidget* label5 = gtk_label_new_with_mnemonic("Remove"); - gtk_widget_show(label5); - gtk_box_pack_start(GTK_BOX (hbox2), label5, FALSE, FALSE, 0); - + //- set the button for removing patches + GtkWidget* button2 = gtk_button_new(); + gtk_widget_show(button2); + gtk_table_attach + ( + GTK_TABLE(table1), + button2, + 2, 3, 1, 2, + (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0 + ); + + g_signal_connect + ( + G_OBJECT(button2), + "clicked", + G_CALLBACK(removeKeepCellsIntersectingPatches), + keepCellsIntersectingPatchesFramePtr_ + ); + + GtkWidget* alignment2 = gtk_alignment_new(0.5, 0.5, 0, 0); + gtk_widget_show(alignment2); + gtk_container_add(GTK_CONTAINER(button2), alignment2); + + GtkWidget* hbox2 = gtk_hbox_new(FALSE, 2); + gtk_widget_show(hbox2); + gtk_container_add(GTK_CONTAINER(alignment2), hbox2); + + GtkWidget* image2 = + gtk_image_new_from_stock("gtk-remove", GTK_ICON_SIZE_BUTTON); + gtk_widget_show(image2); + gtk_box_pack_start(GTK_BOX (hbox2), image2, FALSE, FALSE, 0); + + GtkWidget* label5 = gtk_label_new_with_mnemonic("Remove"); + gtk_widget_show(label5); + gtk_box_pack_start(GTK_BOX (hbox2), label5, FALSE, FALSE, 0); + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - /* Store pointers to all widgets, for use by lookup_widget(). */ - GLADE_HOOKUP_OBJECT_NO_REF - ( - keepCellsIntersectingPatchesFramePtr_, - keepCellsIntersectingPatchesFramePtr_, - "Cell intersecting patches frame" - ); - GLADE_HOOKUP_OBJECT - ( - keepCellsIntersectingPatchesFramePtr_, - comboboxentry_keepCellsIntersectingPatches_availablePatches, - "comboboxentry_keepCellsIntersectingPatches_availablePatches" - ); - GLADE_HOOKUP_OBJECT - ( - keepCellsIntersectingPatchesFramePtr_, - comboboxentry_keepCellsIntersectingPatches_selectedPatches, - "comboboxentry_keepCellsIntersectingPatches_selectedPatches" - ); - - updateKeepCellsIntersectingPatches(keepCellsIntersectingPatchesFramePtr_); - - gtk_widget_show(keepCellsIntersectingPatchesFramePtr_); + /* Store pointers to all widgets, for use by lookup_widget(). */ + GLADE_HOOKUP_OBJECT_NO_REF + ( + keepCellsIntersectingPatchesFramePtr_, + keepCellsIntersectingPatchesFramePtr_, + "Cell intersecting patches frame" + ); + GLADE_HOOKUP_OBJECT + ( + keepCellsIntersectingPatchesFramePtr_, + comboboxentry_keepCellsIntersectingPatches_availablePatches, + "comboboxentry_keepCellsIntersectingPatches_availablePatches" + ); + GLADE_HOOKUP_OBJECT + ( + keepCellsIntersectingPatchesFramePtr_, + comboboxentry_keepCellsIntersectingPatches_selectedPatches, + "comboboxentry_keepCellsIntersectingPatches_selectedPatches" + ); + + updateKeepCellsIntersectingPatches(keepCellsIntersectingPatchesFramePtr_); + + gtk_widget_show(keepCellsIntersectingPatchesFramePtr_); } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/GUI/meshGenGTK/meshGenGTKLineRefinement.C b/GUI/meshGenGTK/meshGenGTKLineRefinement.C index ee07cc2e..e6c42ff6 100644 --- a/GUI/meshGenGTK/meshGenGTKLineRefinement.C +++ b/GUI/meshGenGTK/meshGenGTKLineRefinement.C @@ -43,1008 +43,1008 @@ extern "C" static void showDataForLineRefinement ( - GtkWidget* widget, - GtkWidget* lineRefinementFramePtr + GtkWidget* widget, + GtkWidget* lineRefinementFramePtr ) { - GtkWidget* comboboxentry_lineRefinement_createdLines = - (GtkWidget*)g_object_get_data - ( - G_OBJECT(lineRefinementFramePtr), - "comboboxentry_lineRefinement_createdLines" - ); - GtkWidget* entry_lineRefinement_selectedCellSize = - (GtkWidget*)g_object_get_data - ( - G_OBJECT(lineRefinementFramePtr), - "entry_lineRefinement_selectedCellSize" - ); - GtkWidget* entry_lineRefinement_selectedP0X = - (GtkWidget*)g_object_get_data - ( - G_OBJECT(lineRefinementFramePtr), - "entry_lineRefinement_selectedP0X" - ); - GtkWidget* entry_lineRefinement_selectedP0Y = - (GtkWidget*)g_object_get_data - ( - G_OBJECT(lineRefinementFramePtr), - "entry_lineRefinement_selectedP0Y" - ); - GtkWidget* entry_lineRefinement_selectedP0Z = - (GtkWidget*)g_object_get_data - ( - G_OBJECT(lineRefinementFramePtr), - "entry_lineRefinement_selectedP0Z" - ); - GtkWidget* entry_lineRefinement_selectedP1X = - (GtkWidget*)g_object_get_data - ( - G_OBJECT(lineRefinementFramePtr), - "entry_lineRefinement_selectedP1X" - ); - GtkWidget* entry_lineRefinement_selectedP1Y = - (GtkWidget*)g_object_get_data - ( - G_OBJECT(lineRefinementFramePtr), - "entry_lineRefinement_selectedP1Y" - ); - GtkWidget* entry_lineRefinement_selectedP1Z = - (GtkWidget*)g_object_get_data - ( - G_OBJECT(lineRefinementFramePtr), - "entry_lineRefinement_selectedP1Z" - ); - - //- find the object in the dictionary - const word lineName = - gtk_entry_get_text - ( - GTK_ENTRY - ( - GTK_COMBO(comboboxentry_lineRefinement_createdLines)->entry - ) - ); - - const PtrList<entry> refs = guiPtr->objectRefinements(); - - forAll(refs, refI) - if( refs[refI].keyword() == lineName ) - { - const dictionary dict = refs[refI].dict(); - - gtk_entry_set_text - ( - GTK_ENTRY(entry_lineRefinement_selectedCellSize), - help::scalarToText - ( - scalar(readScalar(dict.lookup("cellSize"))) - ).c_str() - ); - const vector p0(dict.lookup("p0")); - gtk_entry_set_text - ( - GTK_ENTRY(entry_lineRefinement_selectedP0X), - help::scalarToText(p0.x()).c_str() - ); - gtk_entry_set_text - ( - GTK_ENTRY(entry_lineRefinement_selectedP0Y), - help::scalarToText(p0.y()).c_str() - ); - gtk_entry_set_text - ( - GTK_ENTRY(entry_lineRefinement_selectedP0Z), - help::scalarToText(p0.z()).c_str() - ); - - const vector p1(dict.lookup("p1")); - gtk_entry_set_text - ( - GTK_ENTRY(entry_lineRefinement_selectedP1X), - help::scalarToText(p1.x()).c_str() - ); - gtk_entry_set_text - ( - GTK_ENTRY(entry_lineRefinement_selectedP1Y), - help::scalarToText(p1.y()).c_str() - ); - gtk_entry_set_text - ( - GTK_ENTRY(entry_lineRefinement_selectedP1Z), - help::scalarToText(p1.z()).c_str() - ); - - return; - } - - gtk_entry_set_text(GTK_ENTRY(entry_lineRefinement_selectedCellSize), ""); - gtk_entry_set_text(GTK_ENTRY(entry_lineRefinement_selectedP0X), ""); - gtk_entry_set_text(GTK_ENTRY(entry_lineRefinement_selectedP0Y), ""); - gtk_entry_set_text(GTK_ENTRY(entry_lineRefinement_selectedP0Z), ""); - gtk_entry_set_text(GTK_ENTRY(entry_lineRefinement_selectedP1X), ""); - gtk_entry_set_text(GTK_ENTRY(entry_lineRefinement_selectedP1Y), ""); - gtk_entry_set_text(GTK_ENTRY(entry_lineRefinement_selectedP1Z), ""); + GtkWidget* comboboxentry_lineRefinement_createdLines = + (GtkWidget*)g_object_get_data + ( + G_OBJECT(lineRefinementFramePtr), + "comboboxentry_lineRefinement_createdLines" + ); + GtkWidget* entry_lineRefinement_selectedCellSize = + (GtkWidget*)g_object_get_data + ( + G_OBJECT(lineRefinementFramePtr), + "entry_lineRefinement_selectedCellSize" + ); + GtkWidget* entry_lineRefinement_selectedP0X = + (GtkWidget*)g_object_get_data + ( + G_OBJECT(lineRefinementFramePtr), + "entry_lineRefinement_selectedP0X" + ); + GtkWidget* entry_lineRefinement_selectedP0Y = + (GtkWidget*)g_object_get_data + ( + G_OBJECT(lineRefinementFramePtr), + "entry_lineRefinement_selectedP0Y" + ); + GtkWidget* entry_lineRefinement_selectedP0Z = + (GtkWidget*)g_object_get_data + ( + G_OBJECT(lineRefinementFramePtr), + "entry_lineRefinement_selectedP0Z" + ); + GtkWidget* entry_lineRefinement_selectedP1X = + (GtkWidget*)g_object_get_data + ( + G_OBJECT(lineRefinementFramePtr), + "entry_lineRefinement_selectedP1X" + ); + GtkWidget* entry_lineRefinement_selectedP1Y = + (GtkWidget*)g_object_get_data + ( + G_OBJECT(lineRefinementFramePtr), + "entry_lineRefinement_selectedP1Y" + ); + GtkWidget* entry_lineRefinement_selectedP1Z = + (GtkWidget*)g_object_get_data + ( + G_OBJECT(lineRefinementFramePtr), + "entry_lineRefinement_selectedP1Z" + ); + + //- find the object in the dictionary + const word lineName = + gtk_entry_get_text + ( + GTK_ENTRY + ( + GTK_COMBO(comboboxentry_lineRefinement_createdLines)->entry + ) + ); + + const PtrList<entry> refs = guiPtr->objectRefinements(); + + forAll(refs, refI) + if( refs[refI].keyword() == lineName ) + { + const dictionary dict = refs[refI].dict(); + + gtk_entry_set_text + ( + GTK_ENTRY(entry_lineRefinement_selectedCellSize), + help::scalarToText + ( + scalar(readScalar(dict.lookup("cellSize"))) + ).c_str() + ); + const vector p0(dict.lookup("p0")); + gtk_entry_set_text + ( + GTK_ENTRY(entry_lineRefinement_selectedP0X), + help::scalarToText(p0.x()).c_str() + ); + gtk_entry_set_text + ( + GTK_ENTRY(entry_lineRefinement_selectedP0Y), + help::scalarToText(p0.y()).c_str() + ); + gtk_entry_set_text + ( + GTK_ENTRY(entry_lineRefinement_selectedP0Z), + help::scalarToText(p0.z()).c_str() + ); + + const vector p1(dict.lookup("p1")); + gtk_entry_set_text + ( + GTK_ENTRY(entry_lineRefinement_selectedP1X), + help::scalarToText(p1.x()).c_str() + ); + gtk_entry_set_text + ( + GTK_ENTRY(entry_lineRefinement_selectedP1Y), + help::scalarToText(p1.y()).c_str() + ); + gtk_entry_set_text + ( + GTK_ENTRY(entry_lineRefinement_selectedP1Z), + help::scalarToText(p1.z()).c_str() + ); + + return; + } + + gtk_entry_set_text(GTK_ENTRY(entry_lineRefinement_selectedCellSize), ""); + gtk_entry_set_text(GTK_ENTRY(entry_lineRefinement_selectedP0X), ""); + gtk_entry_set_text(GTK_ENTRY(entry_lineRefinement_selectedP0Y), ""); + gtk_entry_set_text(GTK_ENTRY(entry_lineRefinement_selectedP0Z), ""); + gtk_entry_set_text(GTK_ENTRY(entry_lineRefinement_selectedP1X), ""); + gtk_entry_set_text(GTK_ENTRY(entry_lineRefinement_selectedP1Y), ""); + gtk_entry_set_text(GTK_ENTRY(entry_lineRefinement_selectedP1Z), ""); } static void resetValuesForSelectedLine ( - GtkWidget* widget, - GtkWidget* lineRefinementFramePtr + GtkWidget* widget, + GtkWidget* lineRefinementFramePtr ) { - GtkWidget* comboboxentry_lineRefinement_createdLines = - (GtkWidget*)g_object_get_data - ( - G_OBJECT(lineRefinementFramePtr), - "comboboxentry_lineRefinement_createdLines" - ); - GtkWidget* entry_lineRefinement_selectedCellSize = - (GtkWidget*)g_object_get_data - ( - G_OBJECT(lineRefinementFramePtr), - "entry_lineRefinement_selectedCellSize" - ); - GtkWidget* entry_lineRefinement_selectedP0X = - (GtkWidget*)g_object_get_data - ( - G_OBJECT(lineRefinementFramePtr), - "entry_lineRefinement_selectedP0X" - ); - GtkWidget* entry_lineRefinement_selectedP0Y = - (GtkWidget*)g_object_get_data - ( - G_OBJECT(lineRefinementFramePtr), - "entry_lineRefinement_selectedP0Y" - ); - GtkWidget* entry_lineRefinement_selectedP0Z = - (GtkWidget*)g_object_get_data - ( - G_OBJECT(lineRefinementFramePtr), - "entry_lineRefinement_selectedP0Z" - ); - GtkWidget* entry_lineRefinement_selectedP1X = - (GtkWidget*)g_object_get_data - ( - G_OBJECT(lineRefinementFramePtr), - "entry_lineRefinement_selectedP1X" - ); - GtkWidget* entry_lineRefinement_selectedP1Y = - (GtkWidget*)g_object_get_data - ( - G_OBJECT(lineRefinementFramePtr), - "entry_lineRefinement_selectedP1Y" - ); - GtkWidget* entry_lineRefinement_selectedP1Z = - (GtkWidget*)g_object_get_data - ( - G_OBJECT(lineRefinementFramePtr), - "entry_lineRefinement_selectedP1Z" - ); - - const word name = - gtk_entry_get_text - ( - GTK_ENTRY - ( - GTK_COMBO - ( - comboboxentry_lineRefinement_createdLines - )->entry - ) - ); - - if( name == "" ) - return; - - const PtrList<entry> refs = guiPtr->objectRefinements(); - dictionary dict; - forAll(refs, refI) - if( refs[refI].keyword() == name ) - dict = refs[refI].dict(); - guiPtr->removeObjectRefinement(name); - if( widget == entry_lineRefinement_selectedCellSize ) - { - const word size = - gtk_entry_get_text(GTK_ENTRY(entry_lineRefinement_selectedCellSize)); - dict.remove("cellSize"); - dict.add("cellSize", help::textToScalar(size)); - } - else if( widget == entry_lineRefinement_selectedP0X ) - { - point p0(dict.lookup("p0")); - const word c = - gtk_entry_get_text(GTK_ENTRY(entry_lineRefinement_selectedP0X)); - dict.remove("p0"); - p0.x() = help::textToScalar(c); - dict.add("p0", p0); - } - else if( widget == entry_lineRefinement_selectedP0Y ) - { - point p0(dict.lookup("p0")); - const word c = - gtk_entry_get_text(GTK_ENTRY(entry_lineRefinement_selectedP0Y)); - dict.remove("p0"); - p0.y() = help::textToScalar(c); - dict.add("p0", p0); - } - else if( widget == entry_lineRefinement_selectedP0Z ) - { - point p0(dict.lookup("p0")); - const word c = - gtk_entry_get_text(GTK_ENTRY(entry_lineRefinement_selectedP0Z)); - dict.remove("p0"); - p0.z() = help::textToScalar(c); - dict.add("p0", p0); - } - else if( widget == entry_lineRefinement_selectedP1X ) - { - const word l = - gtk_entry_get_text(GTK_ENTRY(entry_lineRefinement_selectedP1X)); - point p1(dict.lookup("p1")); - dict.remove("p1"); - p1.x() = help::textToScalar(l); - dict.add("p1", p1); - } - else if( widget == entry_lineRefinement_selectedP1Y ) - { - const word l = - gtk_entry_get_text(GTK_ENTRY(entry_lineRefinement_selectedP1Y)); - point p1(dict.lookup("p1")); - dict.remove("p1"); - p1.y() = help::textToScalar(l); - dict.add("p1", p1); - } - else if( widget == entry_lineRefinement_selectedP1Z ) - { - const word l = - gtk_entry_get_text(GTK_ENTRY(entry_lineRefinement_selectedP1Z)); - point p1(dict.lookup("p1")); - dict.remove("p1"); - p1.z() = help::textToScalar(l); - dict.add("p1", p1); - } - - lineRefinement br(name, dict); - guiPtr->addObjectRefinement(br); + GtkWidget* comboboxentry_lineRefinement_createdLines = + (GtkWidget*)g_object_get_data + ( + G_OBJECT(lineRefinementFramePtr), + "comboboxentry_lineRefinement_createdLines" + ); + GtkWidget* entry_lineRefinement_selectedCellSize = + (GtkWidget*)g_object_get_data + ( + G_OBJECT(lineRefinementFramePtr), + "entry_lineRefinement_selectedCellSize" + ); + GtkWidget* entry_lineRefinement_selectedP0X = + (GtkWidget*)g_object_get_data + ( + G_OBJECT(lineRefinementFramePtr), + "entry_lineRefinement_selectedP0X" + ); + GtkWidget* entry_lineRefinement_selectedP0Y = + (GtkWidget*)g_object_get_data + ( + G_OBJECT(lineRefinementFramePtr), + "entry_lineRefinement_selectedP0Y" + ); + GtkWidget* entry_lineRefinement_selectedP0Z = + (GtkWidget*)g_object_get_data + ( + G_OBJECT(lineRefinementFramePtr), + "entry_lineRefinement_selectedP0Z" + ); + GtkWidget* entry_lineRefinement_selectedP1X = + (GtkWidget*)g_object_get_data + ( + G_OBJECT(lineRefinementFramePtr), + "entry_lineRefinement_selectedP1X" + ); + GtkWidget* entry_lineRefinement_selectedP1Y = + (GtkWidget*)g_object_get_data + ( + G_OBJECT(lineRefinementFramePtr), + "entry_lineRefinement_selectedP1Y" + ); + GtkWidget* entry_lineRefinement_selectedP1Z = + (GtkWidget*)g_object_get_data + ( + G_OBJECT(lineRefinementFramePtr), + "entry_lineRefinement_selectedP1Z" + ); + + const word name = + gtk_entry_get_text + ( + GTK_ENTRY + ( + GTK_COMBO + ( + comboboxentry_lineRefinement_createdLines + )->entry + ) + ); + + if( name == "" ) + return; + + const PtrList<entry> refs = guiPtr->objectRefinements(); + dictionary dict; + forAll(refs, refI) + if( refs[refI].keyword() == name ) + dict = refs[refI].dict(); + guiPtr->removeObjectRefinement(name); + if( widget == entry_lineRefinement_selectedCellSize ) + { + const word size = + gtk_entry_get_text(GTK_ENTRY(entry_lineRefinement_selectedCellSize)); + dict.remove("cellSize"); + dict.add("cellSize", help::textToScalar(size)); + } + else if( widget == entry_lineRefinement_selectedP0X ) + { + point p0(dict.lookup("p0")); + const word c = + gtk_entry_get_text(GTK_ENTRY(entry_lineRefinement_selectedP0X)); + dict.remove("p0"); + p0.x() = help::textToScalar(c); + dict.add("p0", p0); + } + else if( widget == entry_lineRefinement_selectedP0Y ) + { + point p0(dict.lookup("p0")); + const word c = + gtk_entry_get_text(GTK_ENTRY(entry_lineRefinement_selectedP0Y)); + dict.remove("p0"); + p0.y() = help::textToScalar(c); + dict.add("p0", p0); + } + else if( widget == entry_lineRefinement_selectedP0Z ) + { + point p0(dict.lookup("p0")); + const word c = + gtk_entry_get_text(GTK_ENTRY(entry_lineRefinement_selectedP0Z)); + dict.remove("p0"); + p0.z() = help::textToScalar(c); + dict.add("p0", p0); + } + else if( widget == entry_lineRefinement_selectedP1X ) + { + const word l = + gtk_entry_get_text(GTK_ENTRY(entry_lineRefinement_selectedP1X)); + point p1(dict.lookup("p1")); + dict.remove("p1"); + p1.x() = help::textToScalar(l); + dict.add("p1", p1); + } + else if( widget == entry_lineRefinement_selectedP1Y ) + { + const word l = + gtk_entry_get_text(GTK_ENTRY(entry_lineRefinement_selectedP1Y)); + point p1(dict.lookup("p1")); + dict.remove("p1"); + p1.y() = help::textToScalar(l); + dict.add("p1", p1); + } + else if( widget == entry_lineRefinement_selectedP1Z ) + { + const word l = + gtk_entry_get_text(GTK_ENTRY(entry_lineRefinement_selectedP1Z)); + point p1(dict.lookup("p1")); + dict.remove("p1"); + p1.z() = help::textToScalar(l); + dict.add("p1", p1); + } + + lineRefinement br(name, dict); + guiPtr->addObjectRefinement(br); } static void updateLineRefinements(GtkWidget* lineRefinementFramePtr) { - GtkWidget* comboboxentry_lineRefinement_createdLines = - (GtkWidget*)g_object_get_data - ( - G_OBJECT(lineRefinementFramePtr), - "comboboxentry_lineRefinement_createdLines" - ); - - const PtrList<entry> refs = guiPtr->objectRefinements(); - label nLines(0); - GList* createdLines = 0; - forAll(refs, refI) - { - const word& key = refs[refI].keyword(); - const dictionary& dict = refs[refI].dict(); - const word type(dict.lookup("type")); - - if( type == "line" ) - { - ++nLines; - lineRefinement line(key, dict); - createdLines = - g_list_append - ( - createdLines, - const_cast<char*>(line.name().c_str()) - ); - } - } - - gtk_combo_set_popdown_strings - ( - GTK_COMBO - ( - comboboxentry_lineRefinement_createdLines - ), createdLines - ); - - if( nLines == 0 ) - { - gtk_entry_set_text - ( - GTK_ENTRY - ( - GTK_COMBO(comboboxentry_lineRefinement_createdLines)->entry - ), - "" - ); - } - - g_list_free(createdLines); - - showDataForLineRefinement(NULL, lineRefinementFramePtr); + GtkWidget* comboboxentry_lineRefinement_createdLines = + (GtkWidget*)g_object_get_data + ( + G_OBJECT(lineRefinementFramePtr), + "comboboxentry_lineRefinement_createdLines" + ); + + const PtrList<entry> refs = guiPtr->objectRefinements(); + label nLines(0); + GList* createdLines = 0; + forAll(refs, refI) + { + const word& key = refs[refI].keyword(); + const dictionary& dict = refs[refI].dict(); + const word type(dict.lookup("type")); + + if( type == "line" ) + { + ++nLines; + lineRefinement line(key, dict); + createdLines = + g_list_append + ( + createdLines, + const_cast<char*>(line.name().c_str()) + ); + } + } + + gtk_combo_set_popdown_strings + ( + GTK_COMBO + ( + comboboxentry_lineRefinement_createdLines + ), createdLines + ); + + if( nLines == 0 ) + { + gtk_entry_set_text + ( + GTK_ENTRY + ( + GTK_COMBO(comboboxentry_lineRefinement_createdLines)->entry + ), + "" + ); + } + + g_list_free(createdLines); + + showDataForLineRefinement(NULL, lineRefinementFramePtr); } static void addLineRefinement ( - GtkWidget* button, - GtkWidget* lineRefinementFramePtr + GtkWidget* button, + GtkWidget* lineRefinementFramePtr ) { - GtkWidget* name = - (GtkWidget*)g_object_get_data - ( - G_OBJECT(lineRefinementFramePtr), - "entry_lineName" - ); - GtkWidget* cellSize = - (GtkWidget*)g_object_get_data - ( - G_OBJECT(lineRefinementFramePtr), - "entry_lineRefinement_cellSize" - ); - GtkWidget* p0X = - (GtkWidget*)g_object_get_data - ( - G_OBJECT(lineRefinementFramePtr), - "entry_lineRefinement_p0X" - ); - GtkWidget* p0Y = - (GtkWidget*)g_object_get_data - ( - G_OBJECT(lineRefinementFramePtr), - "entry_lineRefinement_p0Y" - ); - GtkWidget* p0Z = - (GtkWidget*)g_object_get_data - ( - G_OBJECT(lineRefinementFramePtr), - "entry_lineRefinement_p0Z" - ); - GtkWidget* p1X = - (GtkWidget*)g_object_get_data - ( - G_OBJECT(lineRefinementFramePtr), - "entry_lineRefinement_p1X" - ); - GtkWidget* p1Y = - (GtkWidget*)g_object_get_data - ( - G_OBJECT(lineRefinementFramePtr), - "entry_lineRefinement_p1Y" - ); - GtkWidget* p1Z = - (GtkWidget*)g_object_get_data - ( - G_OBJECT(lineRefinementFramePtr), - "entry_lineRefinement_p1Z" - ); - - //- create all necessary settings - const word lineName = gtk_entry_get_text(GTK_ENTRY(name)); - gtk_entry_set_text(GTK_ENTRY(name), ""); - const scalar lineCellSize = - help::textToScalar(gtk_entry_get_text(GTK_ENTRY(cellSize))); - gtk_entry_set_text(GTK_ENTRY(cellSize), ""); - point p0, p1; - p0.x() = help::textToScalar(gtk_entry_get_text(GTK_ENTRY(p0X))); - gtk_entry_set_text(GTK_ENTRY(p0X), ""); - p0.y() = help::textToScalar(gtk_entry_get_text(GTK_ENTRY(p0Y))); - gtk_entry_set_text(GTK_ENTRY(p0Y), ""); - p0.z() = help::textToScalar(gtk_entry_get_text(GTK_ENTRY(p0Z))); - gtk_entry_set_text(GTK_ENTRY(p0Z), ""); - p1.x() = help::textToScalar(gtk_entry_get_text(GTK_ENTRY(p1X))); - gtk_entry_set_text(GTK_ENTRY(p1X), ""); - p1.y() = help::textToScalar(gtk_entry_get_text(GTK_ENTRY(p1Y))); - gtk_entry_set_text(GTK_ENTRY(p1Y), ""); - p1.z() = help::textToScalar(gtk_entry_get_text(GTK_ENTRY(p1Z))); - gtk_entry_set_text(GTK_ENTRY(p1Z), ""); - - lineRefinement line - ( - lineName, - lineCellSize, - p0, - p1 - ); - - guiPtr->addObjectRefinement(line); - - updateLineRefinements(lineRefinementFramePtr); + GtkWidget* name = + (GtkWidget*)g_object_get_data + ( + G_OBJECT(lineRefinementFramePtr), + "entry_lineName" + ); + GtkWidget* cellSize = + (GtkWidget*)g_object_get_data + ( + G_OBJECT(lineRefinementFramePtr), + "entry_lineRefinement_cellSize" + ); + GtkWidget* p0X = + (GtkWidget*)g_object_get_data + ( + G_OBJECT(lineRefinementFramePtr), + "entry_lineRefinement_p0X" + ); + GtkWidget* p0Y = + (GtkWidget*)g_object_get_data + ( + G_OBJECT(lineRefinementFramePtr), + "entry_lineRefinement_p0Y" + ); + GtkWidget* p0Z = + (GtkWidget*)g_object_get_data + ( + G_OBJECT(lineRefinementFramePtr), + "entry_lineRefinement_p0Z" + ); + GtkWidget* p1X = + (GtkWidget*)g_object_get_data + ( + G_OBJECT(lineRefinementFramePtr), + "entry_lineRefinement_p1X" + ); + GtkWidget* p1Y = + (GtkWidget*)g_object_get_data + ( + G_OBJECT(lineRefinementFramePtr), + "entry_lineRefinement_p1Y" + ); + GtkWidget* p1Z = + (GtkWidget*)g_object_get_data + ( + G_OBJECT(lineRefinementFramePtr), + "entry_lineRefinement_p1Z" + ); + + //- create all necessary settings + const word lineName = gtk_entry_get_text(GTK_ENTRY(name)); + gtk_entry_set_text(GTK_ENTRY(name), ""); + const scalar lineCellSize = + help::textToScalar(gtk_entry_get_text(GTK_ENTRY(cellSize))); + gtk_entry_set_text(GTK_ENTRY(cellSize), ""); + point p0, p1; + p0.x() = help::textToScalar(gtk_entry_get_text(GTK_ENTRY(p0X))); + gtk_entry_set_text(GTK_ENTRY(p0X), ""); + p0.y() = help::textToScalar(gtk_entry_get_text(GTK_ENTRY(p0Y))); + gtk_entry_set_text(GTK_ENTRY(p0Y), ""); + p0.z() = help::textToScalar(gtk_entry_get_text(GTK_ENTRY(p0Z))); + gtk_entry_set_text(GTK_ENTRY(p0Z), ""); + p1.x() = help::textToScalar(gtk_entry_get_text(GTK_ENTRY(p1X))); + gtk_entry_set_text(GTK_ENTRY(p1X), ""); + p1.y() = help::textToScalar(gtk_entry_get_text(GTK_ENTRY(p1Y))); + gtk_entry_set_text(GTK_ENTRY(p1Y), ""); + p1.z() = help::textToScalar(gtk_entry_get_text(GTK_ENTRY(p1Z))); + gtk_entry_set_text(GTK_ENTRY(p1Z), ""); + + lineRefinement line + ( + lineName, + lineCellSize, + p0, + p1 + ); + + guiPtr->addObjectRefinement(line); + + updateLineRefinements(lineRefinementFramePtr); } static void removeLineRefinement ( - GtkWidget* button, - GtkWidget* lineRefinementFramePtr + GtkWidget* button, + GtkWidget* lineRefinementFramePtr ) { - GtkWidget* createdLines = - (GtkWidget*)g_object_get_data - ( - G_OBJECT(lineRefinementFramePtr), - "comboboxentry_lineRefinement_createdLines" - ); - - const word lineName = - gtk_entry_get_text - ( - GTK_ENTRY - ( - GTK_COMBO(createdLines)->entry - ) - ); + GtkWidget* createdLines = + (GtkWidget*)g_object_get_data + ( + G_OBJECT(lineRefinementFramePtr), + "comboboxentry_lineRefinement_createdLines" + ); + + const word lineName = + gtk_entry_get_text + ( + GTK_ENTRY + ( + GTK_COMBO(createdLines)->entry + ) + ); - guiPtr->removeObjectRefinement(lineName); + guiPtr->removeObjectRefinement(lineName); - updateLineRefinements(lineRefinementFramePtr); + updateLineRefinements(lineRefinementFramePtr); } } void meshGenGTK::createLineRefinementWindowPage() { - guiPtr = &meshGui_; - - lineRefinementFramePtr_ = gtk_frame_new(NULL); + guiPtr = &meshGui_; + + lineRefinementFramePtr_ = gtk_frame_new(NULL); // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - //- create a table - GtkWidget* table1 = gtk_table_new(5, 11, FALSE); - gtk_widget_show(table1); - gtk_container_add - ( - GTK_CONTAINER(lineRefinementFramePtr_), - table1 - ); + //- create a table + GtkWidget* table1 = gtk_table_new(5, 11, FALSE); + gtk_widget_show(table1); + gtk_container_add + ( + GTK_CONTAINER(lineRefinementFramePtr_), + table1 + ); // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - //- create a label for box name - GtkWidget* label_lineName = gtk_label_new("Line name"); - gtk_widget_show(label_lineName); - gtk_table_attach(GTK_TABLE(table1), label_lineName, 0, 1, 0, 1, + //- create a label for box name + GtkWidget* label_lineName = gtk_label_new("Line name"); + gtk_widget_show(label_lineName); + gtk_table_attach(GTK_TABLE(table1), label_lineName, 0, 1, 0, 1, (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0); - gtk_misc_set_alignment(GTK_MISC(label_lineName), 0, 0.5); - + gtk_misc_set_alignment(GTK_MISC(label_lineName), 0, 0.5); + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - //- create an entry for box name - GtkWidget* entry_lineName = gtk_entry_new(); - gtk_widget_show(entry_lineName); - - gtk_table_attach(GTK_TABLE(table1), entry_lineName, 1, 4, 0, 1, - (GtkAttachOptions)(GTK_FILL), + //- create an entry for box name + GtkWidget* entry_lineName = gtk_entry_new(); + gtk_widget_show(entry_lineName); + + gtk_table_attach(GTK_TABLE(table1), entry_lineName, 1, 4, 0, 1, + (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0); - + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - //- create a label for desired cell size - GtkWidget* label_lineRefinement_cellSize = gtk_label_new("Cell size [m]"); - gtk_widget_show(label_lineRefinement_cellSize); - gtk_table_attach(GTK_TABLE(table1), label_lineRefinement_cellSize, - 0, 1, 1, 2, - (GtkAttachOptions)(GTK_FILL), + //- create a label for desired cell size + GtkWidget* label_lineRefinement_cellSize = gtk_label_new("Cell size [m]"); + gtk_widget_show(label_lineRefinement_cellSize); + gtk_table_attach(GTK_TABLE(table1), label_lineRefinement_cellSize, + 0, 1, 1, 2, + (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0); - gtk_misc_set_alignment(GTK_MISC(label_lineRefinement_cellSize), 0, 0.5); - + gtk_misc_set_alignment(GTK_MISC(label_lineRefinement_cellSize), 0, 0.5); + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - //- create a label for desired cell size - GtkWidget* entry_lineRefinement_cellSize = gtk_entry_new(); - gtk_widget_show(entry_lineRefinement_cellSize); - gtk_table_attach(GTK_TABLE(table1), entry_lineRefinement_cellSize, - 1, 4, 1, 2, - (GtkAttachOptions)(GTK_FILL), + //- create a label for desired cell size + GtkWidget* entry_lineRefinement_cellSize = gtk_entry_new(); + gtk_widget_show(entry_lineRefinement_cellSize); + gtk_table_attach(GTK_TABLE(table1), entry_lineRefinement_cellSize, + 1, 4, 1, 2, + (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0); - + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - //- create labels for axes - GtkWidget* label_axes = gtk_label_new("X"); - gtk_widget_show(label_axes); - gtk_table_attach(GTK_TABLE(table1), label_axes, - 1, 2, 2, 3, - (GtkAttachOptions)(GTK_FILL), + //- create labels for axes + GtkWidget* label_axes = gtk_label_new("X"); + gtk_widget_show(label_axes); + gtk_table_attach(GTK_TABLE(table1), label_axes, + 1, 2, 2, 3, + (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0); - gtk_misc_set_alignment(GTK_MISC(label_axes), 0, 0.5); - - label_axes = gtk_label_new("Y"); - gtk_widget_show(label_axes); - gtk_table_attach(GTK_TABLE(table1), label_axes, - 2, 3, 2, 3, - (GtkAttachOptions)(GTK_FILL), + gtk_misc_set_alignment(GTK_MISC(label_axes), 0, 0.5); + + label_axes = gtk_label_new("Y"); + gtk_widget_show(label_axes); + gtk_table_attach(GTK_TABLE(table1), label_axes, + 2, 3, 2, 3, + (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0); - gtk_misc_set_alignment(GTK_MISC(label_axes), 0, 0.5); - - label_axes = gtk_label_new("Z"); - gtk_widget_show(label_axes); - gtk_table_attach(GTK_TABLE(table1), label_axes, - 3, 4, 2, 3, - (GtkAttachOptions)(GTK_FILL), + gtk_misc_set_alignment(GTK_MISC(label_axes), 0, 0.5); + + label_axes = gtk_label_new("Z"); + gtk_widget_show(label_axes); + gtk_table_attach(GTK_TABLE(table1), label_axes, + 3, 4, 2, 3, + (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0); - gtk_misc_set_alignment(GTK_MISC(label_axes), 0, 0.5); - + gtk_misc_set_alignment(GTK_MISC(label_axes), 0, 0.5); + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - //- label for p0 - GtkWidget* label_lineRefinement_p0 = gtk_label_new("Starting point"); - gtk_widget_show(label_lineRefinement_p0); - gtk_table_attach(GTK_TABLE(table1), label_lineRefinement_p0, - 0, 1, 3, 4, - (GtkAttachOptions)(GTK_FILL), + //- label for p0 + GtkWidget* label_lineRefinement_p0 = gtk_label_new("Starting point"); + gtk_widget_show(label_lineRefinement_p0); + gtk_table_attach(GTK_TABLE(table1), label_lineRefinement_p0, + 0, 1, 3, 4, + (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0); - gtk_misc_set_alignment(GTK_MISC(label_lineRefinement_p0), 0, 0.5); + gtk_misc_set_alignment(GTK_MISC(label_lineRefinement_p0), 0, 0.5); // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - //- entries for p0 - GtkWidget* entry_lineRefinement_p0X = gtk_entry_new(); - gtk_widget_show(entry_lineRefinement_p0X); - gtk_table_attach(GTK_TABLE(table1), entry_lineRefinement_p0X, - 1, 2, 3, 4, - (GtkAttachOptions)(GTK_FILL), + //- entries for p0 + GtkWidget* entry_lineRefinement_p0X = gtk_entry_new(); + gtk_widget_show(entry_lineRefinement_p0X); + gtk_table_attach(GTK_TABLE(table1), entry_lineRefinement_p0X, + 1, 2, 3, 4, + (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0); - - GtkWidget* entry_lineRefinement_p0Y = gtk_entry_new(); - gtk_widget_show(entry_lineRefinement_p0Y); - gtk_table_attach(GTK_TABLE(table1), entry_lineRefinement_p0Y, - 2, 3, 3, 4, - (GtkAttachOptions)(GTK_FILL), + + GtkWidget* entry_lineRefinement_p0Y = gtk_entry_new(); + gtk_widget_show(entry_lineRefinement_p0Y); + gtk_table_attach(GTK_TABLE(table1), entry_lineRefinement_p0Y, + 2, 3, 3, 4, + (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0); - - GtkWidget* entry_lineRefinement_p0Z = gtk_entry_new(); - gtk_widget_show(entry_lineRefinement_p0Z); - gtk_table_attach(GTK_TABLE(table1), entry_lineRefinement_p0Z, - 3, 4, 3, 4, - (GtkAttachOptions)(GTK_FILL), + + GtkWidget* entry_lineRefinement_p0Z = gtk_entry_new(); + gtk_widget_show(entry_lineRefinement_p0Z); + gtk_table_attach(GTK_TABLE(table1), entry_lineRefinement_p0Z, + 3, 4, 3, 4, + (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0); - + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - //- label for p1 - GtkWidget* label_lineRefinement_p1 = gtk_label_new("End point"); - gtk_widget_show(label_lineRefinement_p1); - gtk_table_attach(GTK_TABLE(table1), label_lineRefinement_p1, - 0, 1, 4, 5, - (GtkAttachOptions)(GTK_FILL), + //- label for p1 + GtkWidget* label_lineRefinement_p1 = gtk_label_new("End point"); + gtk_widget_show(label_lineRefinement_p1); + gtk_table_attach(GTK_TABLE(table1), label_lineRefinement_p1, + 0, 1, 4, 5, + (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0); - gtk_misc_set_alignment(GTK_MISC(label_lineRefinement_p1), 0, 0.5); + gtk_misc_set_alignment(GTK_MISC(label_lineRefinement_p1), 0, 0.5); // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - //- entries for p1 - GtkWidget* entry_lineRefinement_p1X = gtk_entry_new(); - gtk_widget_show(entry_lineRefinement_p1X); - gtk_table_attach(GTK_TABLE(table1), entry_lineRefinement_p1X, - 1, 2, 4, 5, - (GtkAttachOptions)(GTK_FILL), + //- entries for p1 + GtkWidget* entry_lineRefinement_p1X = gtk_entry_new(); + gtk_widget_show(entry_lineRefinement_p1X); + gtk_table_attach(GTK_TABLE(table1), entry_lineRefinement_p1X, + 1, 2, 4, 5, + (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0); - - GtkWidget* entry_lineRefinement_p1Y = gtk_entry_new(); - gtk_widget_show(entry_lineRefinement_p1Y); - gtk_table_attach(GTK_TABLE(table1), entry_lineRefinement_p1Y, - 2, 3, 4, 5, - (GtkAttachOptions)(GTK_FILL), + + GtkWidget* entry_lineRefinement_p1Y = gtk_entry_new(); + gtk_widget_show(entry_lineRefinement_p1Y); + gtk_table_attach(GTK_TABLE(table1), entry_lineRefinement_p1Y, + 2, 3, 4, 5, + (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0); - - GtkWidget* entry_lineRefinement_p1Z = gtk_entry_new(); - gtk_widget_show(entry_lineRefinement_p1Z); - gtk_table_attach(GTK_TABLE(table1), entry_lineRefinement_p1Z, - 3, 4, 4, 5, - (GtkAttachOptions)(GTK_FILL), + + GtkWidget* entry_lineRefinement_p1Z = gtk_entry_new(); + gtk_widget_show(entry_lineRefinement_p1Z); + gtk_table_attach(GTK_TABLE(table1), entry_lineRefinement_p1Z, + 3, 4, 4, 5, + (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0); - + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - //- set the button for adding lines - GtkWidget* button1 = gtk_button_new(); - gtk_widget_show(button1); - gtk_table_attach - ( - GTK_TABLE(table1), - button1, - 4, 5, 0, 5, - (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 5 - ); - - g_signal_connect - ( - G_OBJECT(button1), - "clicked", - G_CALLBACK(addLineRefinement), - lineRefinementFramePtr_ - ); + //- set the button for adding lines + GtkWidget* button1 = gtk_button_new(); + gtk_widget_show(button1); + gtk_table_attach + ( + GTK_TABLE(table1), + button1, + 4, 5, 0, 5, + (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 5 + ); + + g_signal_connect + ( + G_OBJECT(button1), + "clicked", + G_CALLBACK(addLineRefinement), + lineRefinementFramePtr_ + ); - GtkWidget* alignment1 = gtk_alignment_new(0.5, 0.5, 0, 0); - gtk_widget_show(alignment1); - gtk_container_add(GTK_CONTAINER(button1), alignment1); - - GtkWidget* hbox1 = gtk_hbox_new(FALSE, 2); - gtk_widget_show(hbox1); - gtk_container_add(GTK_CONTAINER(alignment1), hbox1); - - GtkWidget* image1 = - gtk_image_new_from_stock("gtk-add", GTK_ICON_SIZE_BUTTON); - gtk_widget_show(image1); - gtk_box_pack_start(GTK_BOX(hbox1), image1, FALSE, FALSE, 0); - - GtkWidget* label3 = gtk_label_new_with_mnemonic("Add"); - gtk_widget_show(label3); - gtk_box_pack_start(GTK_BOX(hbox1), label3, FALSE, FALSE, 0); - + GtkWidget* alignment1 = gtk_alignment_new(0.5, 0.5, 0, 0); + gtk_widget_show(alignment1); + gtk_container_add(GTK_CONTAINER(button1), alignment1); + + GtkWidget* hbox1 = gtk_hbox_new(FALSE, 2); + gtk_widget_show(hbox1); + gtk_container_add(GTK_CONTAINER(alignment1), hbox1); + + GtkWidget* image1 = + gtk_image_new_from_stock("gtk-add", GTK_ICON_SIZE_BUTTON); + gtk_widget_show(image1); + gtk_box_pack_start(GTK_BOX(hbox1), image1, FALSE, FALSE, 0); + + GtkWidget* label3 = gtk_label_new_with_mnemonic("Add"); + gtk_widget_show(label3); + gtk_box_pack_start(GTK_BOX(hbox1), label3, FALSE, FALSE, 0); + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - //- horizontal separator - GtkWidget* hseparator0 = gtk_hseparator_new(); - gtk_widget_show(hseparator0); - gtk_table_attach(GTK_TABLE(table1), hseparator0, 0, 5, 5, 6, + //- horizontal separator + GtkWidget* hseparator0 = gtk_hseparator_new(); + gtk_widget_show(hseparator0); + gtk_table_attach(GTK_TABLE(table1), hseparator0, 0, 5, 5, 6, (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(GTK_EXPAND | GTK_SHRINK | GTK_FILL), - 0, 0); + 0, 0); // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - //- label for existing line objects - GtkWidget* label_lineRefinement_existing = gtk_label_new("Existing lines"); - gtk_widget_show(label_lineRefinement_existing); - gtk_table_attach(GTK_TABLE(table1), label_lineRefinement_existing, - 0, 1, 6, 7, - (GtkAttachOptions)(GTK_FILL), + //- label for existing line objects + GtkWidget* label_lineRefinement_existing = gtk_label_new("Existing lines"); + gtk_widget_show(label_lineRefinement_existing); + gtk_table_attach(GTK_TABLE(table1), label_lineRefinement_existing, + 0, 1, 6, 7, + (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0); - + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - //- combobox for existing box objects - GtkWidget* comboboxentry_lineRefinement_createdLines = - gtk_combo_new(); - gtk_widget_show(comboboxentry_lineRefinement_createdLines); - gtk_table_attach - ( - GTK_TABLE(table1),comboboxentry_lineRefinement_createdLines, - 1, 2, 6, 7, - (GtkAttachOptions)(GTK_FILL), - (GtkAttachOptions)(0), 0, 0 - ); - - gtk_editable_set_editable - ( - GTK_EDITABLE - ( - GTK_COMBO(comboboxentry_lineRefinement_createdLines)->entry - ), - 0 - ); - - + //- combobox for existing box objects + GtkWidget* comboboxentry_lineRefinement_createdLines = + gtk_combo_new(); + gtk_widget_show(comboboxentry_lineRefinement_createdLines); + gtk_table_attach + ( + GTK_TABLE(table1),comboboxentry_lineRefinement_createdLines, + 1, 2, 6, 7, + (GtkAttachOptions)(GTK_FILL), + (GtkAttachOptions)(0), 0, 0 + ); + + gtk_editable_set_editable + ( + GTK_EDITABLE + ( + GTK_COMBO(comboboxentry_lineRefinement_createdLines)->entry + ), + 0 + ); + + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - //- create a label for selected cell size - GtkWidget* label_lineRefinement_selectedCellSize = - gtk_label_new("Cell size [m]"); - gtk_widget_show(label_lineRefinement_selectedCellSize); - gtk_table_attach(GTK_TABLE(table1), label_lineRefinement_selectedCellSize, - 0, 1, 7, 8, - (GtkAttachOptions)(GTK_FILL), + //- create a label for selected cell size + GtkWidget* label_lineRefinement_selectedCellSize = + gtk_label_new("Cell size [m]"); + gtk_widget_show(label_lineRefinement_selectedCellSize); + gtk_table_attach(GTK_TABLE(table1), label_lineRefinement_selectedCellSize, + 0, 1, 7, 8, + (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0); - gtk_misc_set_alignment - ( - GTK_MISC(label_lineRefinement_selectedCellSize), 0, 0.5 - ); - + gtk_misc_set_alignment + ( + GTK_MISC(label_lineRefinement_selectedCellSize), 0, 0.5 + ); + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - //- create a label for selected cell size - GtkWidget* entry_lineRefinement_selectedCellSize = gtk_entry_new(); - gtk_widget_show(entry_lineRefinement_selectedCellSize); - gtk_table_attach(GTK_TABLE(table1), entry_lineRefinement_selectedCellSize, - 1, 4, 7, 8, - (GtkAttachOptions)(GTK_FILL), + //- create a label for selected cell size + GtkWidget* entry_lineRefinement_selectedCellSize = gtk_entry_new(); + gtk_widget_show(entry_lineRefinement_selectedCellSize); + gtk_table_attach(GTK_TABLE(table1), entry_lineRefinement_selectedCellSize, + 1, 4, 7, 8, + (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0); - + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - //- create labels for axes - label_axes = gtk_label_new("X"); - gtk_widget_show(label_axes); - gtk_table_attach(GTK_TABLE(table1), label_axes, - 1, 2, 8, 9, - (GtkAttachOptions)(GTK_FILL), + //- create labels for axes + label_axes = gtk_label_new("X"); + gtk_widget_show(label_axes); + gtk_table_attach(GTK_TABLE(table1), label_axes, + 1, 2, 8, 9, + (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0); - gtk_misc_set_alignment(GTK_MISC(label_axes), 0, 0.5); - - label_axes = gtk_label_new("Y"); - gtk_widget_show(label_axes); - gtk_table_attach(GTK_TABLE(table1), label_axes, - 2, 3, 8, 9, - (GtkAttachOptions)(GTK_FILL), + gtk_misc_set_alignment(GTK_MISC(label_axes), 0, 0.5); + + label_axes = gtk_label_new("Y"); + gtk_widget_show(label_axes); + gtk_table_attach(GTK_TABLE(table1), label_axes, + 2, 3, 8, 9, + (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0); - gtk_misc_set_alignment(GTK_MISC(label_axes), 0, 0.5); - - label_axes = gtk_label_new("Z"); - gtk_widget_show(label_axes); - gtk_table_attach(GTK_TABLE(table1), label_axes, - 3, 4, 8, 9, - (GtkAttachOptions)(GTK_FILL), + gtk_misc_set_alignment(GTK_MISC(label_axes), 0, 0.5); + + label_axes = gtk_label_new("Z"); + gtk_widget_show(label_axes); + gtk_table_attach(GTK_TABLE(table1), label_axes, + 3, 4, 8, 9, + (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0); - gtk_misc_set_alignment(GTK_MISC(label_axes), 0, 0.5); - + gtk_misc_set_alignment(GTK_MISC(label_axes), 0, 0.5); + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - //- label for p0 - GtkWidget* label_lineRefinement_selectedP0 = - gtk_label_new("Starting point"); - gtk_widget_show(label_lineRefinement_selectedP0); - gtk_table_attach(GTK_TABLE(table1), label_lineRefinement_selectedP0, - 0, 1, 9, 10, - (GtkAttachOptions)(GTK_FILL), + //- label for p0 + GtkWidget* label_lineRefinement_selectedP0 = + gtk_label_new("Starting point"); + gtk_widget_show(label_lineRefinement_selectedP0); + gtk_table_attach(GTK_TABLE(table1), label_lineRefinement_selectedP0, + 0, 1, 9, 10, + (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0); - gtk_misc_set_alignment(GTK_MISC(label_lineRefinement_selectedP0), 0, 0.5); + gtk_misc_set_alignment(GTK_MISC(label_lineRefinement_selectedP0), 0, 0.5); // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - //- entries for selected p0 - GtkWidget* entry_lineRefinement_selectedP0X = gtk_entry_new(); - gtk_widget_show(entry_lineRefinement_selectedP0X); - gtk_table_attach(GTK_TABLE(table1), entry_lineRefinement_selectedP0X, - 1, 2, 9, 10, - (GtkAttachOptions)(GTK_FILL), + //- entries for selected p0 + GtkWidget* entry_lineRefinement_selectedP0X = gtk_entry_new(); + gtk_widget_show(entry_lineRefinement_selectedP0X); + gtk_table_attach(GTK_TABLE(table1), entry_lineRefinement_selectedP0X, + 1, 2, 9, 10, + (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0); - - GtkWidget* entry_lineRefinement_selectedP0Y = gtk_entry_new(); - gtk_widget_show(entry_lineRefinement_selectedP0Y); - gtk_table_attach(GTK_TABLE(table1), entry_lineRefinement_selectedP0Y, - 2, 3, 9, 10, - (GtkAttachOptions)(GTK_FILL), + + GtkWidget* entry_lineRefinement_selectedP0Y = gtk_entry_new(); + gtk_widget_show(entry_lineRefinement_selectedP0Y); + gtk_table_attach(GTK_TABLE(table1), entry_lineRefinement_selectedP0Y, + 2, 3, 9, 10, + (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0); - - GtkWidget* entry_lineRefinement_selectedP0Z = gtk_entry_new(); - gtk_widget_show(entry_lineRefinement_selectedP0Z); - gtk_table_attach(GTK_TABLE(table1), entry_lineRefinement_selectedP0Z, - 3, 4, 9, 10, - (GtkAttachOptions)(GTK_FILL), + + GtkWidget* entry_lineRefinement_selectedP0Z = gtk_entry_new(); + gtk_widget_show(entry_lineRefinement_selectedP0Z); + gtk_table_attach(GTK_TABLE(table1), entry_lineRefinement_selectedP0Z, + 3, 4, 9, 10, + (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0); - + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - //- label for selected p1 - GtkWidget* label_lineRefinement_selectedP1 = - gtk_label_new("End point"); - gtk_widget_show(label_lineRefinement_selectedP1); - gtk_table_attach(GTK_TABLE(table1), label_lineRefinement_selectedP1, - 0, 1, 10, 11, - (GtkAttachOptions)(GTK_FILL), + //- label for selected p1 + GtkWidget* label_lineRefinement_selectedP1 = + gtk_label_new("End point"); + gtk_widget_show(label_lineRefinement_selectedP1); + gtk_table_attach(GTK_TABLE(table1), label_lineRefinement_selectedP1, + 0, 1, 10, 11, + (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0); - gtk_misc_set_alignment - ( - GTK_MISC(label_lineRefinement_selectedP1), 0, 0.5 - ); + gtk_misc_set_alignment + ( + GTK_MISC(label_lineRefinement_selectedP1), 0, 0.5 + ); // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - //- entries for p1 - GtkWidget* entry_lineRefinement_selectedP1X = gtk_entry_new(); - gtk_widget_show(entry_lineRefinement_selectedP1X); - gtk_table_attach(GTK_TABLE(table1), entry_lineRefinement_selectedP1X, - 1, 2, 10, 11, - (GtkAttachOptions)(GTK_FILL), + //- entries for p1 + GtkWidget* entry_lineRefinement_selectedP1X = gtk_entry_new(); + gtk_widget_show(entry_lineRefinement_selectedP1X); + gtk_table_attach(GTK_TABLE(table1), entry_lineRefinement_selectedP1X, + 1, 2, 10, 11, + (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0); - - GtkWidget* entry_lineRefinement_selectedP1Y = gtk_entry_new(); - gtk_widget_show(entry_lineRefinement_selectedP1Y); - gtk_table_attach(GTK_TABLE(table1), entry_lineRefinement_selectedP1Y, - 2, 3, 10, 11, - (GtkAttachOptions)(GTK_FILL), + + GtkWidget* entry_lineRefinement_selectedP1Y = gtk_entry_new(); + gtk_widget_show(entry_lineRefinement_selectedP1Y); + gtk_table_attach(GTK_TABLE(table1), entry_lineRefinement_selectedP1Y, + 2, 3, 10, 11, + (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0); - - GtkWidget* entry_lineRefinement_selectedP1Z = gtk_entry_new(); - gtk_widget_show(entry_lineRefinement_selectedP1Z); - gtk_table_attach(GTK_TABLE(table1), entry_lineRefinement_selectedP1Z, - 3, 4, 10, 11, - (GtkAttachOptions)(GTK_FILL), + + GtkWidget* entry_lineRefinement_selectedP1Z = gtk_entry_new(); + gtk_widget_show(entry_lineRefinement_selectedP1Z); + gtk_table_attach(GTK_TABLE(table1), entry_lineRefinement_selectedP1Z, + 3, 4, 10, 11, + (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0); - + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - //- set the button for removing patches - GtkWidget* button2 = gtk_button_new(); - gtk_widget_show(button2); - gtk_table_attach - ( - GTK_TABLE(table1), - button2, - 4, 5, 6, 11, - (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 5 - ); - - g_signal_connect - ( - G_OBJECT(button2), - "clicked", - G_CALLBACK(removeLineRefinement), - lineRefinementFramePtr_ - ); - - GtkWidget* alignment2 = gtk_alignment_new(0.5, 0.5, 0, 0); - gtk_widget_show(alignment2); - gtk_container_add(GTK_CONTAINER(button2), alignment2); - - GtkWidget* hbox2 = gtk_hbox_new(FALSE, 2); - gtk_widget_show(hbox2); - gtk_container_add(GTK_CONTAINER(alignment2), hbox2); - - GtkWidget* image2 = - gtk_image_new_from_stock("gtk-remove", GTK_ICON_SIZE_BUTTON); - gtk_widget_show(image2); - gtk_box_pack_start(GTK_BOX (hbox2), image2, FALSE, FALSE, 0); - - GtkWidget* label5 = gtk_label_new_with_mnemonic("Remove"); - gtk_widget_show(label5); - gtk_box_pack_start(GTK_BOX (hbox2), label5, FALSE, FALSE, 0); - + //- set the button for removing patches + GtkWidget* button2 = gtk_button_new(); + gtk_widget_show(button2); + gtk_table_attach + ( + GTK_TABLE(table1), + button2, + 4, 5, 6, 11, + (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 5 + ); + + g_signal_connect + ( + G_OBJECT(button2), + "clicked", + G_CALLBACK(removeLineRefinement), + lineRefinementFramePtr_ + ); + + GtkWidget* alignment2 = gtk_alignment_new(0.5, 0.5, 0, 0); + gtk_widget_show(alignment2); + gtk_container_add(GTK_CONTAINER(button2), alignment2); + + GtkWidget* hbox2 = gtk_hbox_new(FALSE, 2); + gtk_widget_show(hbox2); + gtk_container_add(GTK_CONTAINER(alignment2), hbox2); + + GtkWidget* image2 = + gtk_image_new_from_stock("gtk-remove", GTK_ICON_SIZE_BUTTON); + gtk_widget_show(image2); + gtk_box_pack_start(GTK_BOX (hbox2), image2, FALSE, FALSE, 0); + + GtkWidget* label5 = gtk_label_new_with_mnemonic("Remove"); + gtk_widget_show(label5); + gtk_box_pack_start(GTK_BOX (hbox2), label5, FALSE, FALSE, 0); + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - /* Store pointers to all widgets, for use by lookup_widget(). */ - GLADE_HOOKUP_OBJECT_NO_REF - ( - lineRefinementFramePtr_, - lineRefinementFramePtr_, - "lineRefinementFramePtr_"); - GLADE_HOOKUP_OBJECT - ( - lineRefinementFramePtr_, - table1, - "table1" - ); - GLADE_HOOKUP_OBJECT - ( - lineRefinementFramePtr_, - entry_lineName, - "entry_lineName" - ); - GLADE_HOOKUP_OBJECT - ( - lineRefinementFramePtr_, - entry_lineRefinement_cellSize, - "entry_lineRefinement_cellSize" - ); - GLADE_HOOKUP_OBJECT - ( - lineRefinementFramePtr_, - entry_lineRefinement_p0X, - "entry_lineRefinement_p0X" - ); - GLADE_HOOKUP_OBJECT - ( - lineRefinementFramePtr_, - entry_lineRefinement_p0Y, - "entry_lineRefinement_p0Y" - ); - GLADE_HOOKUP_OBJECT - ( - lineRefinementFramePtr_, - entry_lineRefinement_p0Z, - "entry_lineRefinement_p0Z" - ); - GLADE_HOOKUP_OBJECT - ( - lineRefinementFramePtr_, - entry_lineRefinement_p1X, - "entry_lineRefinement_p1X" - ); - GLADE_HOOKUP_OBJECT - ( - lineRefinementFramePtr_, - entry_lineRefinement_p1Y, - "entry_lineRefinement_p1Y" - ); - GLADE_HOOKUP_OBJECT - ( - lineRefinementFramePtr_, - entry_lineRefinement_p1Z, - "entry_lineRefinement_p1Z" - ); - GLADE_HOOKUP_OBJECT - ( - lineRefinementFramePtr_, - comboboxentry_lineRefinement_createdLines, - "comboboxentry_lineRefinement_createdLines" - ); - GLADE_HOOKUP_OBJECT - ( - lineRefinementFramePtr_, - entry_lineRefinement_selectedCellSize, - "entry_lineRefinement_selectedCellSize" - ); - GLADE_HOOKUP_OBJECT - ( - lineRefinementFramePtr_, - entry_lineRefinement_selectedP0X, - "entry_lineRefinement_selectedP0X" - ); - GLADE_HOOKUP_OBJECT - ( - lineRefinementFramePtr_, - entry_lineRefinement_selectedP0Y, - "entry_lineRefinement_selectedP0Y" - ); - GLADE_HOOKUP_OBJECT - ( - lineRefinementFramePtr_, - entry_lineRefinement_selectedP0Z, - "entry_lineRefinement_selectedP0Z" - ); - GLADE_HOOKUP_OBJECT - ( - lineRefinementFramePtr_, - entry_lineRefinement_selectedP1X, - "entry_lineRefinement_selectedP1X" - ); - GLADE_HOOKUP_OBJECT - ( - lineRefinementFramePtr_, - entry_lineRefinement_selectedP1Y, - "entry_lineRefinement_selectedP1Y" - ); - GLADE_HOOKUP_OBJECT - ( - lineRefinementFramePtr_, - entry_lineRefinement_selectedP1Z, - "entry_lineRefinement_selectedP1Z" - ); - - updateLineRefinements(lineRefinementFramePtr_); - - g_signal_connect - ( - G_OBJECT - ( - GTK_ENTRY - ( - GTK_COMBO(comboboxentry_lineRefinement_createdLines)->entry - ) - ), - "changed", - G_CALLBACK(showDataForLineRefinement), - lineRefinementFramePtr_ - ); - - g_signal_connect - ( - G_OBJECT(entry_lineRefinement_selectedCellSize), - "changed", - G_CALLBACK(resetValuesForSelectedLine), - lineRefinementFramePtr_ - ); - - g_signal_connect - ( - G_OBJECT(entry_lineRefinement_selectedP0X), - "changed", - G_CALLBACK(resetValuesForSelectedLine), - lineRefinementFramePtr_ - ); - - g_signal_connect - ( - G_OBJECT(entry_lineRefinement_selectedP0Y), - "changed", - G_CALLBACK(resetValuesForSelectedLine), - lineRefinementFramePtr_ - ); - - g_signal_connect - ( - G_OBJECT(entry_lineRefinement_selectedP0Z), - "changed", - G_CALLBACK(resetValuesForSelectedLine), - lineRefinementFramePtr_ - ); - - g_signal_connect - ( - G_OBJECT(entry_lineRefinement_selectedP1X), - "changed", - G_CALLBACK(resetValuesForSelectedLine), - lineRefinementFramePtr_ - ); - - g_signal_connect - ( - G_OBJECT(entry_lineRefinement_selectedP1Y), - "changed", - G_CALLBACK(resetValuesForSelectedLine), - lineRefinementFramePtr_ - ); - - g_signal_connect - ( - G_OBJECT(entry_lineRefinement_selectedP1Z), - "changed", - G_CALLBACK(resetValuesForSelectedLine), - lineRefinementFramePtr_ - ); - - gtk_widget_show(lineRefinementFramePtr_); + /* Store pointers to all widgets, for use by lookup_widget(). */ + GLADE_HOOKUP_OBJECT_NO_REF + ( + lineRefinementFramePtr_, + lineRefinementFramePtr_, + "lineRefinementFramePtr_"); + GLADE_HOOKUP_OBJECT + ( + lineRefinementFramePtr_, + table1, + "table1" + ); + GLADE_HOOKUP_OBJECT + ( + lineRefinementFramePtr_, + entry_lineName, + "entry_lineName" + ); + GLADE_HOOKUP_OBJECT + ( + lineRefinementFramePtr_, + entry_lineRefinement_cellSize, + "entry_lineRefinement_cellSize" + ); + GLADE_HOOKUP_OBJECT + ( + lineRefinementFramePtr_, + entry_lineRefinement_p0X, + "entry_lineRefinement_p0X" + ); + GLADE_HOOKUP_OBJECT + ( + lineRefinementFramePtr_, + entry_lineRefinement_p0Y, + "entry_lineRefinement_p0Y" + ); + GLADE_HOOKUP_OBJECT + ( + lineRefinementFramePtr_, + entry_lineRefinement_p0Z, + "entry_lineRefinement_p0Z" + ); + GLADE_HOOKUP_OBJECT + ( + lineRefinementFramePtr_, + entry_lineRefinement_p1X, + "entry_lineRefinement_p1X" + ); + GLADE_HOOKUP_OBJECT + ( + lineRefinementFramePtr_, + entry_lineRefinement_p1Y, + "entry_lineRefinement_p1Y" + ); + GLADE_HOOKUP_OBJECT + ( + lineRefinementFramePtr_, + entry_lineRefinement_p1Z, + "entry_lineRefinement_p1Z" + ); + GLADE_HOOKUP_OBJECT + ( + lineRefinementFramePtr_, + comboboxentry_lineRefinement_createdLines, + "comboboxentry_lineRefinement_createdLines" + ); + GLADE_HOOKUP_OBJECT + ( + lineRefinementFramePtr_, + entry_lineRefinement_selectedCellSize, + "entry_lineRefinement_selectedCellSize" + ); + GLADE_HOOKUP_OBJECT + ( + lineRefinementFramePtr_, + entry_lineRefinement_selectedP0X, + "entry_lineRefinement_selectedP0X" + ); + GLADE_HOOKUP_OBJECT + ( + lineRefinementFramePtr_, + entry_lineRefinement_selectedP0Y, + "entry_lineRefinement_selectedP0Y" + ); + GLADE_HOOKUP_OBJECT + ( + lineRefinementFramePtr_, + entry_lineRefinement_selectedP0Z, + "entry_lineRefinement_selectedP0Z" + ); + GLADE_HOOKUP_OBJECT + ( + lineRefinementFramePtr_, + entry_lineRefinement_selectedP1X, + "entry_lineRefinement_selectedP1X" + ); + GLADE_HOOKUP_OBJECT + ( + lineRefinementFramePtr_, + entry_lineRefinement_selectedP1Y, + "entry_lineRefinement_selectedP1Y" + ); + GLADE_HOOKUP_OBJECT + ( + lineRefinementFramePtr_, + entry_lineRefinement_selectedP1Z, + "entry_lineRefinement_selectedP1Z" + ); + + updateLineRefinements(lineRefinementFramePtr_); + + g_signal_connect + ( + G_OBJECT + ( + GTK_ENTRY + ( + GTK_COMBO(comboboxentry_lineRefinement_createdLines)->entry + ) + ), + "changed", + G_CALLBACK(showDataForLineRefinement), + lineRefinementFramePtr_ + ); + + g_signal_connect + ( + G_OBJECT(entry_lineRefinement_selectedCellSize), + "changed", + G_CALLBACK(resetValuesForSelectedLine), + lineRefinementFramePtr_ + ); + + g_signal_connect + ( + G_OBJECT(entry_lineRefinement_selectedP0X), + "changed", + G_CALLBACK(resetValuesForSelectedLine), + lineRefinementFramePtr_ + ); + + g_signal_connect + ( + G_OBJECT(entry_lineRefinement_selectedP0Y), + "changed", + G_CALLBACK(resetValuesForSelectedLine), + lineRefinementFramePtr_ + ); + + g_signal_connect + ( + G_OBJECT(entry_lineRefinement_selectedP0Z), + "changed", + G_CALLBACK(resetValuesForSelectedLine), + lineRefinementFramePtr_ + ); + + g_signal_connect + ( + G_OBJECT(entry_lineRefinement_selectedP1X), + "changed", + G_CALLBACK(resetValuesForSelectedLine), + lineRefinementFramePtr_ + ); + + g_signal_connect + ( + G_OBJECT(entry_lineRefinement_selectedP1Y), + "changed", + G_CALLBACK(resetValuesForSelectedLine), + lineRefinementFramePtr_ + ); + + g_signal_connect + ( + G_OBJECT(entry_lineRefinement_selectedP1Z), + "changed", + G_CALLBACK(resetValuesForSelectedLine), + lineRefinementFramePtr_ + ); + + gtk_widget_show(lineRefinementFramePtr_); } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/GUI/meshGenGTK/meshGenGTKLocalRefinement.C b/GUI/meshGenGTK/meshGenGTKLocalRefinement.C index 2d835069..b9cf1f5d 100644 --- a/GUI/meshGenGTK/meshGenGTKLocalRefinement.C +++ b/GUI/meshGenGTK/meshGenGTKLocalRefinement.C @@ -36,272 +36,272 @@ Description namespace Foam { - + extern "C" { - + static void updateSizeForSelectedPatch ( - GtkWidget* widget, - GtkWidget* entry_localRefinement_selectedCellSize + GtkWidget* widget, + GtkWidget* entry_localRefinement_selectedCellSize ) { - //- display the size for a patch selected in combo box - const word name = - gtk_entry_get_text - ( - GTK_ENTRY - ( - widget - ) - ); - - if( name == "" ) - { - gtk_entry_set_text - ( - GTK_ENTRY(entry_localRefinement_selectedCellSize), - "" - ); - } + //- display the size for a patch selected in combo box + const word name = + gtk_entry_get_text + ( + GTK_ENTRY + ( + widget + ) + ); + + if( name == "" ) + { + gtk_entry_set_text + ( + GTK_ENTRY(entry_localRefinement_selectedCellSize), + "" + ); + } - patchRefinementList refPatches = guiPtr->patchCellSize(); - forAll(refPatches, patchI) - if( refPatches[patchI].patchName() == name ) - { - const word s = help::scalarToText(refPatches[patchI].cellSize()); - gtk_entry_set_text - ( - GTK_ENTRY(entry_localRefinement_selectedCellSize), - s.c_str() - ); - } + patchRefinementList refPatches = guiPtr->patchCellSize(); + forAll(refPatches, patchI) + if( refPatches[patchI].patchName() == name ) + { + const word s = help::scalarToText(refPatches[patchI].cellSize()); + gtk_entry_set_text + ( + GTK_ENTRY(entry_localRefinement_selectedCellSize), + s.c_str() + ); + } } static void resetSizeForSelectedPatch ( - GtkWidget* widget, - GtkWidget* comboboxentry_localRefinement_selectedPatches + GtkWidget* widget, + GtkWidget* comboboxentry_localRefinement_selectedPatches ) { - const word name = - gtk_entry_get_text - ( - GTK_ENTRY - ( - GTK_COMBO - ( - comboboxentry_localRefinement_selectedPatches - )->entry - ) - ); - - if( name == "" ) - return; - - guiPtr->removePatchCellSize(name); - - const word text = - gtk_entry_get_text - ( - GTK_ENTRY - ( - widget - ) - ); - const scalar size = help::textToScalar(text); + const word name = + gtk_entry_get_text + ( + GTK_ENTRY + ( + GTK_COMBO + ( + comboboxentry_localRefinement_selectedPatches + )->entry + ) + ); + + if( name == "" ) + return; + + guiPtr->removePatchCellSize(name); + + const word text = + gtk_entry_get_text + ( + GTK_ENTRY + ( + widget + ) + ); + const scalar size = help::textToScalar(text); - patchRefinement pr(name, Foam::min(size, guiPtr->maxCellSize())); + patchRefinement pr(name, Foam::min(size, guiPtr->maxCellSize())); - guiPtr->addPatchCellSize(pr); + guiPtr->addPatchCellSize(pr); } - + static void updateLocalRefinementPatches(GtkWidget* localRefinementFramePtr) { - GtkWidget* comboboxentry_localRefinement_availablePatches = - (GtkWidget*)g_object_get_data - ( - G_OBJECT(localRefinementFramePtr), - "comboboxentry_localRefinement_availablePatches" - ); - GtkWidget* comboboxentry_localRefinement_selectedPatches = - (GtkWidget*)g_object_get_data - ( - G_OBJECT(localRefinementFramePtr), - "comboboxentry_localRefinement_selectedPatches" - ); - //- update available patches - patchRefinementList alreadyUsed = guiPtr->patchCellSize(); + GtkWidget* comboboxentry_localRefinement_availablePatches = + (GtkWidget*)g_object_get_data + ( + G_OBJECT(localRefinementFramePtr), + "comboboxentry_localRefinement_availablePatches" + ); + GtkWidget* comboboxentry_localRefinement_selectedPatches = + (GtkWidget*)g_object_get_data + ( + G_OBJECT(localRefinementFramePtr), + "comboboxentry_localRefinement_selectedPatches" + ); + //- update available patches + patchRefinementList alreadyUsed = guiPtr->patchCellSize(); - wordHashSet usedNames; - forAll(alreadyUsed, nameI) - usedNames.insert(alreadyUsed[nameI].patchName()); + wordHashSet usedNames; + forAll(alreadyUsed, nameI) + usedNames.insert(alreadyUsed[nameI].patchName()); - GList* avPatches = 0; - label nAvailable(0); - const triSurface& surf = guiPtr->surface(); - forAll(surf.patches(), patchI) - { - if( usedNames.found(surf.patches()[patchI].name()) ) - continue; - const char* name = surf.patches()[patchI].name().c_str(); - avPatches = g_list_append(avPatches, const_cast<char*>(name)); - ++nAvailable; - } + GList* avPatches = 0; + label nAvailable(0); + const triSurface& surf = guiPtr->surface(); + forAll(surf.patches(), patchI) + { + if( usedNames.found(surf.patches()[patchI].name()) ) + continue; + const char* name = surf.patches()[patchI].name().c_str(); + avPatches = g_list_append(avPatches, const_cast<char*>(name)); + ++nAvailable; + } - gtk_combo_set_popdown_strings - ( - GTK_COMBO - ( - comboboxentry_localRefinement_availablePatches - ), avPatches - ); - - if( nAvailable == 0 ) - { - gtk_entry_set_text - ( - GTK_ENTRY - ( - GTK_COMBO - ( - comboboxentry_localRefinement_availablePatches - )->entry - ), "" - ); - } - - //- update used patches - GList* selPatches = 0; - forAll(alreadyUsed, patchI) - { - const char* name = alreadyUsed[patchI].patchName().c_str(); - selPatches = g_list_append(selPatches, const_cast<char*>(name)); - } - - gtk_combo_set_popdown_strings - ( - GTK_COMBO - ( - comboboxentry_localRefinement_selectedPatches - ), selPatches - ); - - if( alreadyUsed.size() == 0 ) - { - gtk_entry_set_text - ( - GTK_ENTRY - ( - GTK_COMBO - ( - comboboxentry_localRefinement_selectedPatches - )->entry - ), "" - ); - } + gtk_combo_set_popdown_strings + ( + GTK_COMBO + ( + comboboxentry_localRefinement_availablePatches + ), avPatches + ); + + if( nAvailable == 0 ) + { + gtk_entry_set_text + ( + GTK_ENTRY + ( + GTK_COMBO + ( + comboboxentry_localRefinement_availablePatches + )->entry + ), "" + ); + } + + //- update used patches + GList* selPatches = 0; + forAll(alreadyUsed, patchI) + { + const char* name = alreadyUsed[patchI].patchName().c_str(); + selPatches = g_list_append(selPatches, const_cast<char*>(name)); + } + + gtk_combo_set_popdown_strings + ( + GTK_COMBO + ( + comboboxentry_localRefinement_selectedPatches + ), selPatches + ); + + if( alreadyUsed.size() == 0 ) + { + gtk_entry_set_text + ( + GTK_ENTRY + ( + GTK_COMBO + ( + comboboxentry_localRefinement_selectedPatches + )->entry + ), "" + ); + } - g_list_free(avPatches); - g_list_free(selPatches); - - GtkWidget* entry_localRefinement_selectedCellSize = - (GtkWidget*)g_object_get_data - ( - G_OBJECT(localRefinementFramePtr), - "entry_localRefinement_selectedCellSize" - ); - - updateSizeForSelectedPatch - ( - GTK_COMBO - ( - comboboxentry_localRefinement_selectedPatches - )->entry, - entry_localRefinement_selectedCellSize - ); + g_list_free(avPatches); + g_list_free(selPatches); + + GtkWidget* entry_localRefinement_selectedCellSize = + (GtkWidget*)g_object_get_data + ( + G_OBJECT(localRefinementFramePtr), + "entry_localRefinement_selectedCellSize" + ); + + updateSizeForSelectedPatch + ( + GTK_COMBO + ( + comboboxentry_localRefinement_selectedPatches + )->entry, + entry_localRefinement_selectedCellSize + ); } - + static void addPatchCellSize ( - GtkWidget* widget, - GtkWidget* localRefinementFramePtr + GtkWidget* widget, + GtkWidget* localRefinementFramePtr ) { - GtkWidget* comboboxentry_localRefinement_availablePatches = - (GtkWidget*)g_object_get_data - ( - G_OBJECT(localRefinementFramePtr), - "comboboxentry_localRefinement_availablePatches" - ); - GtkWidget* entry_localRefinement_cellSize = - (GtkWidget*)g_object_get_data - ( - G_OBJECT(localRefinementFramePtr), - "entry_localRefinement_cellSize" - ); - - const word name = - gtk_entry_get_text - ( - GTK_ENTRY - ( - GTK_COMBO - ( - comboboxentry_localRefinement_availablePatches - )->entry - ) - ); - - if( name == "" ) - return; - - const word text = - gtk_entry_get_text - ( - GTK_ENTRY - ( - entry_localRefinement_cellSize - ) - ); - const scalar size = help::textToScalar(text); + GtkWidget* comboboxentry_localRefinement_availablePatches = + (GtkWidget*)g_object_get_data + ( + G_OBJECT(localRefinementFramePtr), + "comboboxentry_localRefinement_availablePatches" + ); + GtkWidget* entry_localRefinement_cellSize = + (GtkWidget*)g_object_get_data + ( + G_OBJECT(localRefinementFramePtr), + "entry_localRefinement_cellSize" + ); + + const word name = + gtk_entry_get_text + ( + GTK_ENTRY + ( + GTK_COMBO + ( + comboboxentry_localRefinement_availablePatches + )->entry + ) + ); + + if( name == "" ) + return; + + const word text = + gtk_entry_get_text + ( + GTK_ENTRY + ( + entry_localRefinement_cellSize + ) + ); + const scalar size = help::textToScalar(text); - patchRefinement pr(name, Foam::min(size, guiPtr->maxCellSize())); + patchRefinement pr(name, Foam::min(size, guiPtr->maxCellSize())); - guiPtr->addPatchCellSize(pr); + guiPtr->addPatchCellSize(pr); - updateLocalRefinementPatches(localRefinementFramePtr); + updateLocalRefinementPatches(localRefinementFramePtr); } static void removePatchRefinement ( - GtkWidget* widget, - GtkWidget* localRefinementFramePtr + GtkWidget* widget, + GtkWidget* localRefinementFramePtr ) { - GtkWidget* comboboxentry_localRefinement_selectedPatches = - (GtkWidget*)g_object_get_data - ( - G_OBJECT(localRefinementFramePtr), - "comboboxentry_localRefinement_selectedPatches" - ); - const word name = - gtk_entry_get_text - ( - GTK_ENTRY - ( - GTK_COMBO - ( - comboboxentry_localRefinement_selectedPatches - )->entry - ) - ); - - if( name == "" ) - return; - - guiPtr->removePatchCellSize(name); - - updateLocalRefinementPatches(localRefinementFramePtr); + GtkWidget* comboboxentry_localRefinement_selectedPatches = + (GtkWidget*)g_object_get_data + ( + G_OBJECT(localRefinementFramePtr), + "comboboxentry_localRefinement_selectedPatches" + ); + const word name = + gtk_entry_get_text + ( + GTK_ENTRY + ( + GTK_COMBO + ( + comboboxentry_localRefinement_selectedPatches + )->entry + ) + ); + + if( name == "" ) + return; + + guiPtr->removePatchCellSize(name); + + updateLocalRefinementPatches(localRefinementFramePtr); } } @@ -310,278 +310,278 @@ static void removePatchRefinement void meshGenGTK::createLocalRefinementWindowPage() { - guiPtr = &meshGui_; - - localRefinementFramePtr_ = gtk_frame_new(NULL); + guiPtr = &meshGui_; + + localRefinementFramePtr_ = gtk_frame_new(NULL); // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - //- create a table - GtkWidget* table1 = gtk_table_new(2, 4, FALSE); - gtk_widget_show(table1); - gtk_container_add - ( - GTK_CONTAINER(localRefinementFramePtr_), - table1 - ); + //- create a table + GtkWidget* table1 = gtk_table_new(2, 4, FALSE); + gtk_widget_show(table1); + gtk_container_add + ( + GTK_CONTAINER(localRefinementFramePtr_), + table1 + ); // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - //- set label for available patches - GtkWidget* label_localRefinement_availablePatches = - gtk_label_new("Available patches"); - gtk_widget_show(label_localRefinement_availablePatches); - gtk_table_attach - ( - GTK_TABLE(table1), - label_localRefinement_availablePatches, - 0, 1, 0, 1, - (GtkAttachOptions)(GTK_FILL), - (GtkAttachOptions) (0), 0, 0 - ); - gtk_misc_set_alignment - ( - GTK_MISC(label_localRefinement_availablePatches), - 0, - 0.5 - ); - + //- set label for available patches + GtkWidget* label_localRefinement_availablePatches = + gtk_label_new("Available patches"); + gtk_widget_show(label_localRefinement_availablePatches); + gtk_table_attach + ( + GTK_TABLE(table1), + label_localRefinement_availablePatches, + 0, 1, 0, 1, + (GtkAttachOptions)(GTK_FILL), + (GtkAttachOptions) (0), 0, 0 + ); + gtk_misc_set_alignment + ( + GTK_MISC(label_localRefinement_availablePatches), + 0, + 0.5 + ); + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - //- create the combo box for available patches - GtkWidget* comboboxentry_localRefinement_availablePatches = - gtk_combo_new(); - gtk_widget_show - ( - comboboxentry_localRefinement_availablePatches - ); - gtk_table_attach - ( - GTK_TABLE(table1), - comboboxentry_localRefinement_availablePatches, - 1, 2, 0, 1, - (GtkAttachOptions)(GTK_EXPAND | GTK_FILL), - (GtkAttachOptions)(GTK_FILL), 0, 0 - ); - - gtk_editable_set_editable - ( - GTK_EDITABLE - ( - GTK_COMBO - ( - comboboxentry_localRefinement_availablePatches - )->entry - ), - 0 - ); - + //- create the combo box for available patches + GtkWidget* comboboxentry_localRefinement_availablePatches = + gtk_combo_new(); + gtk_widget_show + ( + comboboxentry_localRefinement_availablePatches + ); + gtk_table_attach + ( + GTK_TABLE(table1), + comboboxentry_localRefinement_availablePatches, + 1, 2, 0, 1, + (GtkAttachOptions)(GTK_EXPAND | GTK_FILL), + (GtkAttachOptions)(GTK_FILL), 0, 0 + ); + + gtk_editable_set_editable + ( + GTK_EDITABLE + ( + GTK_COMBO + ( + comboboxentry_localRefinement_availablePatches + )->entry + ), + 0 + ); + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - //- entry for cell size - GtkWidget* entry_localRefinement_cellSize = gtk_entry_new(); - gtk_widget_show(entry_localRefinement_cellSize); - - gtk_table_attach - ( - GTK_TABLE(table1), - entry_localRefinement_cellSize, - 2, 3, 0, 1, - (GtkAttachOptions)(GTK_EXPAND | GTK_FILL), - (GtkAttachOptions)(GTK_FILL), 0, 0 - ); - + //- entry for cell size + GtkWidget* entry_localRefinement_cellSize = gtk_entry_new(); + gtk_widget_show(entry_localRefinement_cellSize); + + gtk_table_attach + ( + GTK_TABLE(table1), + entry_localRefinement_cellSize, + 2, 3, 0, 1, + (GtkAttachOptions)(GTK_EXPAND | GTK_FILL), + (GtkAttachOptions)(GTK_FILL), 0, 0 + ); + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - //- set the button for adding patches - GtkWidget* button1 = gtk_button_new(); - gtk_widget_show(button1); - gtk_table_attach - ( - GTK_TABLE(table1), - button1, - 3, 4, 0, 1, - (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0 - ); - - g_signal_connect - ( - G_OBJECT(button1), - "clicked", - G_CALLBACK(addPatchCellSize), - localRefinementFramePtr_ - ); + //- set the button for adding patches + GtkWidget* button1 = gtk_button_new(); + gtk_widget_show(button1); + gtk_table_attach + ( + GTK_TABLE(table1), + button1, + 3, 4, 0, 1, + (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0 + ); + + g_signal_connect + ( + G_OBJECT(button1), + "clicked", + G_CALLBACK(addPatchCellSize), + localRefinementFramePtr_ + ); - GtkWidget* alignment1 = gtk_alignment_new(0.5, 0.5, 0, 0); - gtk_widget_show(alignment1); - gtk_container_add(GTK_CONTAINER(button1), alignment1); - - GtkWidget* hbox1 = gtk_hbox_new(FALSE, 2); - gtk_widget_show(hbox1); - gtk_container_add(GTK_CONTAINER(alignment1), hbox1); - - GtkWidget* image1 = - gtk_image_new_from_stock("gtk-add", GTK_ICON_SIZE_BUTTON); - gtk_widget_show(image1); - gtk_box_pack_start(GTK_BOX(hbox1), image1, FALSE, FALSE, 0); - - GtkWidget* label3 = gtk_label_new_with_mnemonic("Add"); - gtk_widget_show(label3); - gtk_box_pack_start(GTK_BOX(hbox1), label3, FALSE, FALSE, 0); + GtkWidget* alignment1 = gtk_alignment_new(0.5, 0.5, 0, 0); + gtk_widget_show(alignment1); + gtk_container_add(GTK_CONTAINER(button1), alignment1); + + GtkWidget* hbox1 = gtk_hbox_new(FALSE, 2); + gtk_widget_show(hbox1); + gtk_container_add(GTK_CONTAINER(alignment1), hbox1); + + GtkWidget* image1 = + gtk_image_new_from_stock("gtk-add", GTK_ICON_SIZE_BUTTON); + gtk_widget_show(image1); + gtk_box_pack_start(GTK_BOX(hbox1), image1, FALSE, FALSE, 0); + + GtkWidget* label3 = gtk_label_new_with_mnemonic("Add"); + gtk_widget_show(label3); + gtk_box_pack_start(GTK_BOX(hbox1), label3, FALSE, FALSE, 0); // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - //- set label for selected patches - GtkWidget* label_localRefinement_selectedPatches = - gtk_label_new("Selected patches"); - gtk_widget_show(label_localRefinement_selectedPatches); - gtk_table_attach - ( - GTK_TABLE(table1), - label_localRefinement_selectedPatches, - 0, 1, 1, 2, - (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0 - ); - gtk_misc_set_alignment - ( - GTK_MISC(label_localRefinement_selectedPatches), - 0, - 0.5 - ); - + //- set label for selected patches + GtkWidget* label_localRefinement_selectedPatches = + gtk_label_new("Selected patches"); + gtk_widget_show(label_localRefinement_selectedPatches); + gtk_table_attach + ( + GTK_TABLE(table1), + label_localRefinement_selectedPatches, + 0, 1, 1, 2, + (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0 + ); + gtk_misc_set_alignment + ( + GTK_MISC(label_localRefinement_selectedPatches), + 0, + 0.5 + ); + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - //- entry for selected cell size - GtkWidget* entry_localRefinement_selectedCellSize = gtk_entry_new(); - gtk_widget_show(entry_localRefinement_selectedCellSize); - - gtk_table_attach - ( - GTK_TABLE(table1), - entry_localRefinement_selectedCellSize, - 2, 3, 1, 2, - (GtkAttachOptions)(GTK_EXPAND | GTK_FILL), - (GtkAttachOptions)(GTK_FILL), 0, 0 - ); - + //- entry for selected cell size + GtkWidget* entry_localRefinement_selectedCellSize = gtk_entry_new(); + gtk_widget_show(entry_localRefinement_selectedCellSize); + + gtk_table_attach + ( + GTK_TABLE(table1), + entry_localRefinement_selectedCellSize, + 2, 3, 1, 2, + (GtkAttachOptions)(GTK_EXPAND | GTK_FILL), + (GtkAttachOptions)(GTK_FILL), 0, 0 + ); + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - //- create the combo box for selected patches - GtkWidget* comboboxentry_localRefinement_selectedPatches = gtk_combo_new(); - gtk_widget_show(comboboxentry_localRefinement_selectedPatches); + //- create the combo box for selected patches + GtkWidget* comboboxentry_localRefinement_selectedPatches = gtk_combo_new(); + gtk_widget_show(comboboxentry_localRefinement_selectedPatches); - gtk_table_attach - ( - GTK_TABLE(table1), - comboboxentry_localRefinement_selectedPatches, - 1, 2, 1, 2, - (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (GTK_FILL), 0, 0 - ); - - gtk_editable_set_editable - ( - GTK_EDITABLE - ( - GTK_COMBO - ( - comboboxentry_localRefinement_selectedPatches - )->entry - ), - 0 - ); - - //- change the displayed value to match the selected patch - g_signal_connect - ( - G_OBJECT - ( - GTK_ENTRY - ( - GTK_COMBO - ( - comboboxentry_localRefinement_selectedPatches - )->entry - ) - ), - "changed", - G_CALLBACK(updateSizeForSelectedPatch), - entry_localRefinement_selectedCellSize - ); - - //- change the selected size in case the user decides it - g_signal_connect - ( - G_OBJECT(entry_localRefinement_selectedCellSize), - "changed", - G_CALLBACK(resetSizeForSelectedPatch), - comboboxentry_localRefinement_selectedPatches - ); - + gtk_table_attach + ( + GTK_TABLE(table1), + comboboxentry_localRefinement_selectedPatches, + 1, 2, 1, 2, + (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (GTK_FILL), 0, 0 + ); + + gtk_editable_set_editable + ( + GTK_EDITABLE + ( + GTK_COMBO + ( + comboboxentry_localRefinement_selectedPatches + )->entry + ), + 0 + ); + + //- change the displayed value to match the selected patch + g_signal_connect + ( + G_OBJECT + ( + GTK_ENTRY + ( + GTK_COMBO + ( + comboboxentry_localRefinement_selectedPatches + )->entry + ) + ), + "changed", + G_CALLBACK(updateSizeForSelectedPatch), + entry_localRefinement_selectedCellSize + ); + + //- change the selected size in case the user decides it + g_signal_connect + ( + G_OBJECT(entry_localRefinement_selectedCellSize), + "changed", + G_CALLBACK(resetSizeForSelectedPatch), + comboboxentry_localRefinement_selectedPatches + ); + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - //- set the button for removing patches - GtkWidget* button2 = gtk_button_new(); - gtk_widget_show(button2); - gtk_table_attach - ( - GTK_TABLE(table1), - button2, - 3, 4, 1, 2, - (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0 - ); - - g_signal_connect - ( - G_OBJECT(button2), - "clicked", - G_CALLBACK(removePatchRefinement), - localRefinementFramePtr_ - ); - - GtkWidget* alignment2 = gtk_alignment_new(0.5, 0.5, 0, 0); - gtk_widget_show(alignment2); - gtk_container_add(GTK_CONTAINER(button2), alignment2); - - GtkWidget* hbox2 = gtk_hbox_new(FALSE, 2); - gtk_widget_show(hbox2); - gtk_container_add(GTK_CONTAINER(alignment2), hbox2); - - GtkWidget* image2 = - gtk_image_new_from_stock("gtk-remove", GTK_ICON_SIZE_BUTTON); - gtk_widget_show(image2); - gtk_box_pack_start(GTK_BOX (hbox2), image2, FALSE, FALSE, 0); - - GtkWidget* label5 = gtk_label_new_with_mnemonic("Remove"); - gtk_widget_show(label5); - gtk_box_pack_start(GTK_BOX (hbox2), label5, FALSE, FALSE, 0); - + //- set the button for removing patches + GtkWidget* button2 = gtk_button_new(); + gtk_widget_show(button2); + gtk_table_attach + ( + GTK_TABLE(table1), + button2, + 3, 4, 1, 2, + (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0 + ); + + g_signal_connect + ( + G_OBJECT(button2), + "clicked", + G_CALLBACK(removePatchRefinement), + localRefinementFramePtr_ + ); + + GtkWidget* alignment2 = gtk_alignment_new(0.5, 0.5, 0, 0); + gtk_widget_show(alignment2); + gtk_container_add(GTK_CONTAINER(button2), alignment2); + + GtkWidget* hbox2 = gtk_hbox_new(FALSE, 2); + gtk_widget_show(hbox2); + gtk_container_add(GTK_CONTAINER(alignment2), hbox2); + + GtkWidget* image2 = + gtk_image_new_from_stock("gtk-remove", GTK_ICON_SIZE_BUTTON); + gtk_widget_show(image2); + gtk_box_pack_start(GTK_BOX (hbox2), image2, FALSE, FALSE, 0); + + GtkWidget* label5 = gtk_label_new_with_mnemonic("Remove"); + gtk_widget_show(label5); + gtk_box_pack_start(GTK_BOX (hbox2), label5, FALSE, FALSE, 0); + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - /* Store pointers to all widgets, for use by lookup_widget(). */ - GLADE_HOOKUP_OBJECT_NO_REF - ( - localRefinementFramePtr_, - localRefinementFramePtr_, - "Local refinement frame" - ); - GLADE_HOOKUP_OBJECT - ( - localRefinementFramePtr_, - comboboxentry_localRefinement_availablePatches, - "comboboxentry_localRefinement_availablePatches" - ); - GLADE_HOOKUP_OBJECT - ( - localRefinementFramePtr_, - entry_localRefinement_cellSize, - "entry_localRefinement_cellSize" - ); - GLADE_HOOKUP_OBJECT - ( - localRefinementFramePtr_, - comboboxentry_localRefinement_selectedPatches, - "comboboxentry_localRefinement_selectedPatches" - ); - GLADE_HOOKUP_OBJECT - ( - localRefinementFramePtr_, - entry_localRefinement_selectedCellSize, - "entry_localRefinement_selectedCellSize" - ); - - updateLocalRefinementPatches(localRefinementFramePtr_); - - gtk_widget_show(localRefinementFramePtr_); + /* Store pointers to all widgets, for use by lookup_widget(). */ + GLADE_HOOKUP_OBJECT_NO_REF + ( + localRefinementFramePtr_, + localRefinementFramePtr_, + "Local refinement frame" + ); + GLADE_HOOKUP_OBJECT + ( + localRefinementFramePtr_, + comboboxentry_localRefinement_availablePatches, + "comboboxentry_localRefinement_availablePatches" + ); + GLADE_HOOKUP_OBJECT + ( + localRefinementFramePtr_, + entry_localRefinement_cellSize, + "entry_localRefinement_cellSize" + ); + GLADE_HOOKUP_OBJECT + ( + localRefinementFramePtr_, + comboboxentry_localRefinement_selectedPatches, + "comboboxentry_localRefinement_selectedPatches" + ); + GLADE_HOOKUP_OBJECT + ( + localRefinementFramePtr_, + entry_localRefinement_selectedCellSize, + "entry_localRefinement_selectedCellSize" + ); + + updateLocalRefinementPatches(localRefinementFramePtr_); + + gtk_widget_show(localRefinementFramePtr_); } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/GUI/meshGenGTK/meshGenGTKLocalSettingsMainWindow.C b/GUI/meshGenGTK/meshGenGTKLocalSettingsMainWindow.C index 139d4bc9..46849359 100644 --- a/GUI/meshGenGTK/meshGenGTKLocalSettingsMainWindow.C +++ b/GUI/meshGenGTK/meshGenGTKLocalSettingsMainWindow.C @@ -37,88 +37,88 @@ namespace Foam void meshGenGTK::createLocalSettingsMainWindowPage() { - //- create pages within this page - createLocalRefinementWindowPage(); - createKeepCellsIntersectingPatchesWindowPage(); - createBndLayersWindowPage(); - - localSettingsMainFramePtr_ = gtk_frame_new(NULL); - - GtkWidget* notebook1 = gtk_notebook_new (); - - gtk_container_add(GTK_CONTAINER(localSettingsMainFramePtr_), notebook1); - - //- add page for local refinement - GtkWidget* label_localRefinement = gtk_label_new("Local refinement"); - gtk_widget_show(label_localRefinement); - - gtk_notebook_append_page - ( - GTK_NOTEBOOK(notebook1), - localRefinementFramePtr_, - label_localRefinement - ); - - //- add page for keepCellsIntersectingPatches - GtkWidget* label_keepBoxesIntersectingPatches = - gtk_label_new("Keep octree boxes intersecting patches"); - gtk_widget_show(label_keepBoxesIntersectingPatches); - - gtk_notebook_append_page - ( - GTK_NOTEBOOK(notebook1), - keepCellsIntersectingPatchesFramePtr_, - label_keepBoxesIntersectingPatches - ); - - //- add page for bnd layers - GtkWidget* label_bndLayers = - gtk_label_new("Boundary layer for patches"); - gtk_widget_show(label_bndLayers); - - gtk_notebook_append_page - ( - GTK_NOTEBOOK(notebook1), - bndLayersFramePtr_, - label_bndLayers - ); - - //- show the notebook - gtk_widget_show(notebook1); - - /* Store pointers to all widgets, for use by lookup_widget(). */ - GLADE_HOOKUP_OBJECT_NO_REF - ( - localSettingsMainFramePtr_, - localSettingsMainFramePtr_, - "localSettingsMainFramePtr_" - ); - GLADE_HOOKUP_OBJECT - ( - localSettingsMainFramePtr_, - notebook1, - "notebook1" - ); - GLADE_HOOKUP_OBJECT - ( - localSettingsMainFramePtr_, - label_localRefinement, - "label_localRefinement" - ); - GLADE_HOOKUP_OBJECT - ( - localSettingsMainFramePtr_, - label_keepBoxesIntersectingPatches, - "label_keepBoxesIntersectingPatches" - ); - GLADE_HOOKUP_OBJECT - ( - localSettingsMainFramePtr_, - label_bndLayers, - "label_bndLayers" - ); - - gtk_widget_show(localSettingsMainFramePtr_); + //- create pages within this page + createLocalRefinementWindowPage(); + createKeepCellsIntersectingPatchesWindowPage(); + createBndLayersWindowPage(); + + localSettingsMainFramePtr_ = gtk_frame_new(NULL); + + GtkWidget* notebook1 = gtk_notebook_new (); + + gtk_container_add(GTK_CONTAINER(localSettingsMainFramePtr_), notebook1); + + //- add page for local refinement + GtkWidget* label_localRefinement = gtk_label_new("Local refinement"); + gtk_widget_show(label_localRefinement); + + gtk_notebook_append_page + ( + GTK_NOTEBOOK(notebook1), + localRefinementFramePtr_, + label_localRefinement + ); + + //- add page for keepCellsIntersectingPatches + GtkWidget* label_keepBoxesIntersectingPatches = + gtk_label_new("Keep octree boxes intersecting patches"); + gtk_widget_show(label_keepBoxesIntersectingPatches); + + gtk_notebook_append_page + ( + GTK_NOTEBOOK(notebook1), + keepCellsIntersectingPatchesFramePtr_, + label_keepBoxesIntersectingPatches + ); + + //- add page for bnd layers + GtkWidget* label_bndLayers = + gtk_label_new("Boundary layer for patches"); + gtk_widget_show(label_bndLayers); + + gtk_notebook_append_page + ( + GTK_NOTEBOOK(notebook1), + bndLayersFramePtr_, + label_bndLayers + ); + + //- show the notebook + gtk_widget_show(notebook1); + + /* Store pointers to all widgets, for use by lookup_widget(). */ + GLADE_HOOKUP_OBJECT_NO_REF + ( + localSettingsMainFramePtr_, + localSettingsMainFramePtr_, + "localSettingsMainFramePtr_" + ); + GLADE_HOOKUP_OBJECT + ( + localSettingsMainFramePtr_, + notebook1, + "notebook1" + ); + GLADE_HOOKUP_OBJECT + ( + localSettingsMainFramePtr_, + label_localRefinement, + "label_localRefinement" + ); + GLADE_HOOKUP_OBJECT + ( + localSettingsMainFramePtr_, + label_keepBoxesIntersectingPatches, + "label_keepBoxesIntersectingPatches" + ); + GLADE_HOOKUP_OBJECT + ( + localSettingsMainFramePtr_, + label_bndLayers, + "label_bndLayers" + ); + + gtk_widget_show(localSettingsMainFramePtr_); } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/GUI/meshGenGTK/meshGenGTKMainWindow.C b/GUI/meshGenGTK/meshGenGTKMainWindow.C index e1b6aec7..057dbcbf 100644 --- a/GUI/meshGenGTK/meshGenGTKMainWindow.C +++ b/GUI/meshGenGTK/meshGenGTKMainWindow.C @@ -34,150 +34,150 @@ namespace Foam { // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - + // Callback functions go here void saveMeshDictCallback(void* data) { - guiPtr->writeDict(); + guiPtr->writeDict(); } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // void meshGenGTK::createMainWindowPage() { - guiPtr = &meshGui_; - - //- create the main window - GtkWidget* mainWindowPtr_ = gtk_window_new(GTK_WINDOW_TOPLEVEL); - gtk_window_set_title(GTK_WINDOW (mainWindowPtr_), "Mesh generation GUI"); - g_signal_connect - ( - G_OBJECT(mainWindowPtr_), - "destroy", - G_CALLBACK(gtk_main_quit), - NULL - ); - - GtkWidget* vbox1 = gtk_vbox_new(FALSE, 0); - gtk_widget_show(vbox1); - gtk_container_add(GTK_CONTAINER (mainWindowPtr_), vbox1); - - //- create a toolbar (for reading and saving meshDict) - GtkWidget* toolbar1 = gtk_toolbar_new(); - gtk_widget_show(toolbar1); - gtk_box_pack_start(GTK_BOX(vbox1), toolbar1, FALSE, FALSE, 0); - gtk_toolbar_set_style(GTK_TOOLBAR(toolbar1), GTK_TOOLBAR_ICONS); - //GtkIconSize tmp_toolbar_icon_size = - //gtk_toolbar_get_icon_size(GTK_TOOLBAR(toolbar1)); - - GtkWidget* toolitem1 = (GtkWidget*)gtk_tool_item_new(); - gtk_widget_show(toolitem1); - gtk_container_add(GTK_CONTAINER(toolbar1), toolitem1); - - GtkWidget* button_mainWindow_save = - gtk_button_new_with_mnemonic("Save meshDict"); - gtk_widget_show(button_mainWindow_save); - gtk_container_add(GTK_CONTAINER(toolitem1), button_mainWindow_save); - - g_signal_connect - ( - G_OBJECT(button_mainWindow_save), - "clicked", - G_CALLBACK(saveMeshDictCallback), - static_cast<void*>(&meshGui_) - ); - - //- create exit button - GtkWidget* toolitem2 = (GtkWidget*)gtk_tool_item_new(); - gtk_widget_show(toolitem2); - gtk_container_add(GTK_CONTAINER(toolbar1), toolitem2); - - GtkWidget* button_mainWindow_exit = gtk_button_new_with_mnemonic("Exit"); - gtk_widget_show(button_mainWindow_exit); - gtk_container_add(GTK_CONTAINER(toolitem2), button_mainWindow_exit); - - g_signal_connect - ( - G_OBJECT(button_mainWindow_exit), - "clicked", - G_CALLBACK(gtk_main_quit), - NULL - ); - - //- create a notebook which allows the user to switch between - //- the local and global settings - GtkWidget* notebook1 = gtk_notebook_new(); - - gtk_box_pack_start(GTK_BOX(vbox1), notebook1, TRUE, TRUE, 0); - - //- append the page for general settings - GtkWidget* label_generalSettings = gtk_label_new("General settings"); - gtk_widget_show(label_generalSettings); - - gtk_notebook_append_page - ( - GTK_NOTEBOOK(notebook1), - generalPageFramePtr_, - label_generalSettings - ); - - //- add local settings - GtkWidget* label_localSettings = gtk_label_new("Local settings"); - gtk_widget_show(label_localSettings); - - gtk_notebook_append_page - ( - GTK_NOTEBOOK(notebook1), - localSettingsMainFramePtr_, - label_localSettings - ); - - //- add object refinements - GtkWidget* label_objectRefinements = gtk_label_new("Object refinements"); - gtk_widget_show(label_objectRefinements); - - gtk_notebook_append_page - ( - GTK_NOTEBOOK(notebook1), - objectRefinementMainFramePtr_, - label_objectRefinements - ); - - //- add patch renaming - GtkWidget* label_renameBoundary = gtk_label_new("Rename boundary patches"); - gtk_widget_show(label_renameBoundary); - - gtk_notebook_append_page - ( - GTK_NOTEBOOK(notebook1), - renameBoundaryFramePtr_, - label_renameBoundary - ); - - gtk_widget_show(notebook1); - - /* Store pointers to all widgets, for use by lookup_widget(). */ - GLADE_HOOKUP_OBJECT_NO_REF - ( - mainWindowPtr_, - mainWindowPtr_, - "Mesh generation GUI" - ); - - GLADE_HOOKUP_OBJECT - ( - mainWindowPtr_, - button_mainWindow_save, - "button_mainWindow_save" - ); - GLADE_HOOKUP_OBJECT - ( - mainWindowPtr_, - button_mainWindow_exit, - "button_mainWindow_exit" - ); - - gtk_widget_show(mainWindowPtr_); + guiPtr = &meshGui_; + + //- create the main window + GtkWidget* mainWindowPtr_ = gtk_window_new(GTK_WINDOW_TOPLEVEL); + gtk_window_set_title(GTK_WINDOW (mainWindowPtr_), "Mesh generation GUI"); + g_signal_connect + ( + G_OBJECT(mainWindowPtr_), + "destroy", + G_CALLBACK(gtk_main_quit), + NULL + ); + + GtkWidget* vbox1 = gtk_vbox_new(FALSE, 0); + gtk_widget_show(vbox1); + gtk_container_add(GTK_CONTAINER (mainWindowPtr_), vbox1); + + //- create a toolbar (for reading and saving meshDict) + GtkWidget* toolbar1 = gtk_toolbar_new(); + gtk_widget_show(toolbar1); + gtk_box_pack_start(GTK_BOX(vbox1), toolbar1, FALSE, FALSE, 0); + gtk_toolbar_set_style(GTK_TOOLBAR(toolbar1), GTK_TOOLBAR_ICONS); + //GtkIconSize tmp_toolbar_icon_size = + //gtk_toolbar_get_icon_size(GTK_TOOLBAR(toolbar1)); + + GtkWidget* toolitem1 = (GtkWidget*)gtk_tool_item_new(); + gtk_widget_show(toolitem1); + gtk_container_add(GTK_CONTAINER(toolbar1), toolitem1); + + GtkWidget* button_mainWindow_save = + gtk_button_new_with_mnemonic("Save meshDict"); + gtk_widget_show(button_mainWindow_save); + gtk_container_add(GTK_CONTAINER(toolitem1), button_mainWindow_save); + + g_signal_connect + ( + G_OBJECT(button_mainWindow_save), + "clicked", + G_CALLBACK(saveMeshDictCallback), + static_cast<void*>(&meshGui_) + ); + + //- create exit button + GtkWidget* toolitem2 = (GtkWidget*)gtk_tool_item_new(); + gtk_widget_show(toolitem2); + gtk_container_add(GTK_CONTAINER(toolbar1), toolitem2); + + GtkWidget* button_mainWindow_exit = gtk_button_new_with_mnemonic("Exit"); + gtk_widget_show(button_mainWindow_exit); + gtk_container_add(GTK_CONTAINER(toolitem2), button_mainWindow_exit); + + g_signal_connect + ( + G_OBJECT(button_mainWindow_exit), + "clicked", + G_CALLBACK(gtk_main_quit), + NULL + ); + + //- create a notebook which allows the user to switch between + //- the local and global settings + GtkWidget* notebook1 = gtk_notebook_new(); + + gtk_box_pack_start(GTK_BOX(vbox1), notebook1, TRUE, TRUE, 0); + + //- append the page for general settings + GtkWidget* label_generalSettings = gtk_label_new("General settings"); + gtk_widget_show(label_generalSettings); + + gtk_notebook_append_page + ( + GTK_NOTEBOOK(notebook1), + generalPageFramePtr_, + label_generalSettings + ); + + //- add local settings + GtkWidget* label_localSettings = gtk_label_new("Local settings"); + gtk_widget_show(label_localSettings); + + gtk_notebook_append_page + ( + GTK_NOTEBOOK(notebook1), + localSettingsMainFramePtr_, + label_localSettings + ); + + //- add object refinements + GtkWidget* label_objectRefinements = gtk_label_new("Object refinements"); + gtk_widget_show(label_objectRefinements); + + gtk_notebook_append_page + ( + GTK_NOTEBOOK(notebook1), + objectRefinementMainFramePtr_, + label_objectRefinements + ); + + //- add patch renaming + GtkWidget* label_renameBoundary = gtk_label_new("Rename boundary patches"); + gtk_widget_show(label_renameBoundary); + + gtk_notebook_append_page + ( + GTK_NOTEBOOK(notebook1), + renameBoundaryFramePtr_, + label_renameBoundary + ); + + gtk_widget_show(notebook1); + + /* Store pointers to all widgets, for use by lookup_widget(). */ + GLADE_HOOKUP_OBJECT_NO_REF + ( + mainWindowPtr_, + mainWindowPtr_, + "Mesh generation GUI" + ); + + GLADE_HOOKUP_OBJECT + ( + mainWindowPtr_, + button_mainWindow_save, + "button_mainWindow_save" + ); + GLADE_HOOKUP_OBJECT + ( + mainWindowPtr_, + button_mainWindow_exit, + "button_mainWindow_exit" + ); + + gtk_widget_show(mainWindowPtr_); } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/GUI/meshGenGTK/meshGenGTKObjectRefinementMainWindow.C b/GUI/meshGenGTK/meshGenGTKObjectRefinementMainWindow.C index fca11f9b..c24e3855 100644 --- a/GUI/meshGenGTK/meshGenGTKObjectRefinementMainWindow.C +++ b/GUI/meshGenGTK/meshGenGTKObjectRefinementMainWindow.C @@ -37,80 +37,80 @@ namespace Foam void meshGenGTK::createObjectRefinementMainWindowPage() { - //- create pages within this page - createBoxRefinementWindowPage(); - createLineRefinementWindowPage(); - createConeRefinementWindowPage(); - createSphereRefinementWindowPage(); - - objectRefinementMainFramePtr_ = gtk_frame_new(NULL); - - GtkWidget* notebook1 = gtk_notebook_new (); + //- create pages within this page + createBoxRefinementWindowPage(); + createLineRefinementWindowPage(); + createConeRefinementWindowPage(); + createSphereRefinementWindowPage(); + + objectRefinementMainFramePtr_ = gtk_frame_new(NULL); + + GtkWidget* notebook1 = gtk_notebook_new (); - gtk_container_add(GTK_CONTAINER(objectRefinementMainFramePtr_), notebook1); - - //- add page for box refinement - GtkWidget* label_boxRefinement = gtk_label_new("Box refinement"); - gtk_widget_show(label_boxRefinement); - - gtk_notebook_append_page - ( - GTK_NOTEBOOK(notebook1), - boxRefinementFramePtr_, - label_boxRefinement - ); - - //- add page for line refinement - GtkWidget* label_lineRefinement = gtk_label_new("Line refinement"); - gtk_widget_show(label_lineRefinement); - - gtk_notebook_append_page - ( - GTK_NOTEBOOK(notebook1), - lineRefinementFramePtr_, - label_lineRefinement - ); - - //- add page for cone refinement - GtkWidget* label_coneRefinement = gtk_label_new("Cone refinement"); - gtk_widget_show(label_coneRefinement); - - gtk_notebook_append_page - ( - GTK_NOTEBOOK(notebook1), - coneRefinementFramePtr_, - label_coneRefinement - ); - - //- add page for sphere refinement - GtkWidget* label_sphereRefinement = gtk_label_new("Sphere refinement"); - gtk_widget_show(label_sphereRefinement); - - gtk_notebook_append_page - ( - GTK_NOTEBOOK(notebook1), - sphereRefinementFramePtr_, - label_sphereRefinement - ); - - //- show the notebook - gtk_widget_show(notebook1); - - /* Store pointers to all widgets, for use by lookup_widget(). */ - GLADE_HOOKUP_OBJECT_NO_REF - ( - objectRefinementMainFramePtr_, - objectRefinementMainFramePtr_, - "objectRefinementMainFramePtr_" - ); - GLADE_HOOKUP_OBJECT - ( - objectRefinementMainFramePtr_, - notebook1, - "notebook1" - ); + gtk_container_add(GTK_CONTAINER(objectRefinementMainFramePtr_), notebook1); + + //- add page for box refinement + GtkWidget* label_boxRefinement = gtk_label_new("Box refinement"); + gtk_widget_show(label_boxRefinement); + + gtk_notebook_append_page + ( + GTK_NOTEBOOK(notebook1), + boxRefinementFramePtr_, + label_boxRefinement + ); + + //- add page for line refinement + GtkWidget* label_lineRefinement = gtk_label_new("Line refinement"); + gtk_widget_show(label_lineRefinement); + + gtk_notebook_append_page + ( + GTK_NOTEBOOK(notebook1), + lineRefinementFramePtr_, + label_lineRefinement + ); + + //- add page for cone refinement + GtkWidget* label_coneRefinement = gtk_label_new("Cone refinement"); + gtk_widget_show(label_coneRefinement); + + gtk_notebook_append_page + ( + GTK_NOTEBOOK(notebook1), + coneRefinementFramePtr_, + label_coneRefinement + ); + + //- add page for sphere refinement + GtkWidget* label_sphereRefinement = gtk_label_new("Sphere refinement"); + gtk_widget_show(label_sphereRefinement); + + gtk_notebook_append_page + ( + GTK_NOTEBOOK(notebook1), + sphereRefinementFramePtr_, + label_sphereRefinement + ); + + //- show the notebook + gtk_widget_show(notebook1); + + /* Store pointers to all widgets, for use by lookup_widget(). */ + GLADE_HOOKUP_OBJECT_NO_REF + ( + objectRefinementMainFramePtr_, + objectRefinementMainFramePtr_, + "objectRefinementMainFramePtr_" + ); + GLADE_HOOKUP_OBJECT + ( + objectRefinementMainFramePtr_, + notebook1, + "notebook1" + ); - gtk_widget_show(objectRefinementMainFramePtr_); + gtk_widget_show(objectRefinementMainFramePtr_); } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/GUI/meshGenGTK/meshGenGTKRenameBoundary.C b/GUI/meshGenGTK/meshGenGTKRenameBoundary.C index d48a0430..23efe172 100644 --- a/GUI/meshGenGTK/meshGenGTKRenameBoundary.C +++ b/GUI/meshGenGTK/meshGenGTKRenameBoundary.C @@ -35,726 +35,726 @@ Description namespace Foam { - + extern "C" { static void resetNewPatchNamesForSelectedPatch ( - GtkWidget* widget, - GtkWidget* renameBoundaryFramePtr + GtkWidget* widget, + GtkWidget* renameBoundaryFramePtr ) { - GtkWidget* comboboxentry_renameBoundary_selectedPatches = - (GtkWidget*)g_object_get_data - ( - G_OBJECT(renameBoundaryFramePtr), - "comboboxentry_renameBoundary_selectedPatches" - ); - GtkWidget* entry_renameBoundary_selectedPatchName = - (GtkWidget*)g_object_get_data - ( - G_OBJECT(renameBoundaryFramePtr), - "entry_renameBoundary_selectedPatchName" - ); - GtkWidget* entry_renameBoundary_selectedPatchType = - (GtkWidget*)g_object_get_data - ( - G_OBJECT(renameBoundaryFramePtr), - "entry_renameBoundary_selectedPatchType" - ); - - const word name = - gtk_entry_get_text - ( - GTK_ENTRY - ( - GTK_COMBO(comboboxentry_renameBoundary_selectedPatches)->entry - ) - ); - - const PtrList<entry> newPatchNames = guiPtr->newPatchNames(); - forAll(newPatchNames, nameI) - if( newPatchNames[nameI].keyword() == name ) - { - const dictionary dict = newPatchNames[nameI].dict(); - - dictionary newDict; - if( widget == entry_renameBoundary_selectedPatchName ) - { - const word newName = - gtk_entry_get_text - ( - GTK_ENTRY(entry_renameBoundary_selectedPatchName) - ); - word type("patch"); - if( dict.found("type") ) - { - type = word(dict.lookup("type")); - } - newDict.add("newName", newName); - newDict.add("type", type); - } - else - { - const word newName(dict.lookup("newName")); - const word type = - gtk_entry_get_text - ( - GTK_ENTRY(entry_renameBoundary_selectedPatchType) - ); - newDict.add("newName", newName); - newDict.add("type", type); - } - - guiPtr->removePatchName(name); - guiPtr->addNewPatchName(name, newDict); - } + GtkWidget* comboboxentry_renameBoundary_selectedPatches = + (GtkWidget*)g_object_get_data + ( + G_OBJECT(renameBoundaryFramePtr), + "comboboxentry_renameBoundary_selectedPatches" + ); + GtkWidget* entry_renameBoundary_selectedPatchName = + (GtkWidget*)g_object_get_data + ( + G_OBJECT(renameBoundaryFramePtr), + "entry_renameBoundary_selectedPatchName" + ); + GtkWidget* entry_renameBoundary_selectedPatchType = + (GtkWidget*)g_object_get_data + ( + G_OBJECT(renameBoundaryFramePtr), + "entry_renameBoundary_selectedPatchType" + ); + + const word name = + gtk_entry_get_text + ( + GTK_ENTRY + ( + GTK_COMBO(comboboxentry_renameBoundary_selectedPatches)->entry + ) + ); + + const PtrList<entry> newPatchNames = guiPtr->newPatchNames(); + forAll(newPatchNames, nameI) + if( newPatchNames[nameI].keyword() == name ) + { + const dictionary dict = newPatchNames[nameI].dict(); + + dictionary newDict; + if( widget == entry_renameBoundary_selectedPatchName ) + { + const word newName = + gtk_entry_get_text + ( + GTK_ENTRY(entry_renameBoundary_selectedPatchName) + ); + word type("patch"); + if( dict.found("type") ) + { + type = word(dict.lookup("type")); + } + newDict.add("newName", newName); + newDict.add("type", type); + } + else + { + const word newName(dict.lookup("newName")); + const word type = + gtk_entry_get_text + ( + GTK_ENTRY(entry_renameBoundary_selectedPatchType) + ); + newDict.add("newName", newName); + newDict.add("type", type); + } + + guiPtr->removePatchName(name); + guiPtr->addNewPatchName(name, newDict); + } } static void updateNewPatchNamesForSelectedPatch ( - GtkWidget* widget, - GtkWidget* renameBoundaryFramePtr + GtkWidget* widget, + GtkWidget* renameBoundaryFramePtr ) { - GtkWidget* comboboxentry_renameBoundary_selectedPatches = - (GtkWidget*)g_object_get_data - ( - G_OBJECT(renameBoundaryFramePtr), - "comboboxentry_renameBoundary_selectedPatches" - ); - GtkWidget* entry_renameBoundary_selectedPatchName = - (GtkWidget*)g_object_get_data - ( - G_OBJECT(renameBoundaryFramePtr), - "entry_renameBoundary_selectedPatchName" - ); - GtkWidget* entry_renameBoundary_selectedPatchType = - (GtkWidget*)g_object_get_data - ( - G_OBJECT(renameBoundaryFramePtr), - "entry_renameBoundary_selectedPatchType" - ); - - const word name = - gtk_entry_get_text - ( - GTK_ENTRY - ( - GTK_COMBO(comboboxentry_renameBoundary_selectedPatches)->entry - ) - ); - - if( name == "" ) - { - gtk_entry_set_text - ( - GTK_ENTRY(entry_renameBoundary_selectedPatchName), "" - ); - - gtk_entry_set_text - ( - GTK_ENTRY(entry_renameBoundary_selectedPatchType), "" - ); - - return; - } - - const PtrList<entry> newPatchNames = guiPtr->newPatchNames(); - forAll(newPatchNames, nameI) - if( newPatchNames[nameI].keyword() == name ) - { - const dictionary dict = newPatchNames[nameI].dict(); - - const word newName(dict.lookup("newName")); - word type("patch"); - if( dict.found("type") ) - { - type = word(dict.lookup("type")); - } - - gtk_entry_set_text - ( - GTK_ENTRY(entry_renameBoundary_selectedPatchName), - newName.c_str() - ); - - gtk_entry_set_text - ( - GTK_ENTRY(entry_renameBoundary_selectedPatchType), - type.c_str() - ); - } + GtkWidget* comboboxentry_renameBoundary_selectedPatches = + (GtkWidget*)g_object_get_data + ( + G_OBJECT(renameBoundaryFramePtr), + "comboboxentry_renameBoundary_selectedPatches" + ); + GtkWidget* entry_renameBoundary_selectedPatchName = + (GtkWidget*)g_object_get_data + ( + G_OBJECT(renameBoundaryFramePtr), + "entry_renameBoundary_selectedPatchName" + ); + GtkWidget* entry_renameBoundary_selectedPatchType = + (GtkWidget*)g_object_get_data + ( + G_OBJECT(renameBoundaryFramePtr), + "entry_renameBoundary_selectedPatchType" + ); + + const word name = + gtk_entry_get_text + ( + GTK_ENTRY + ( + GTK_COMBO(comboboxentry_renameBoundary_selectedPatches)->entry + ) + ); + + if( name == "" ) + { + gtk_entry_set_text + ( + GTK_ENTRY(entry_renameBoundary_selectedPatchName), "" + ); + + gtk_entry_set_text + ( + GTK_ENTRY(entry_renameBoundary_selectedPatchType), "" + ); + + return; + } + + const PtrList<entry> newPatchNames = guiPtr->newPatchNames(); + forAll(newPatchNames, nameI) + if( newPatchNames[nameI].keyword() == name ) + { + const dictionary dict = newPatchNames[nameI].dict(); + + const word newName(dict.lookup("newName")); + word type("patch"); + if( dict.found("type") ) + { + type = word(dict.lookup("type")); + } + + gtk_entry_set_text + ( + GTK_ENTRY(entry_renameBoundary_selectedPatchName), + newName.c_str() + ); + + gtk_entry_set_text + ( + GTK_ENTRY(entry_renameBoundary_selectedPatchType), + type.c_str() + ); + } } - + static void updateNewPatchNames ( - GtkWidget* renameBoundaryFramePtr + GtkWidget* renameBoundaryFramePtr ) { - GtkWidget* comboboxentry_renameBoundary_availablePatches = - (GtkWidget*)g_object_get_data - ( - G_OBJECT(renameBoundaryFramePtr), - "comboboxentry_renameBoundary_availablePatches" - ); - GtkWidget* comboboxentry_renameBoundary_selectedPatches = - (GtkWidget*)g_object_get_data - ( - G_OBJECT(renameBoundaryFramePtr), - "comboboxentry_renameBoundary_selectedPatches" - ); - - if( guiPtr->newPatchNamesEntryExist() ) - { - wordHashSet selectedPatches; - PtrList<entry> newPatchNames = guiPtr->newPatchNames(); - forAll(newPatchNames, pI) - selectedPatches.insert(newPatchNames[pI].keyword()); - - label nAvailable(0); - GList* avPatches = 0; - const triSurface& surf = guiPtr->surface(); - forAll(surf.patches(), patchI) - { - if( selectedPatches.found(surf.patches()[patchI].name()) ) - continue; - - ++nAvailable; - const char* name = surf.patches()[patchI].name().c_str(); - avPatches = g_list_append(avPatches, const_cast<char*>(name)); - } - - if( nAvailable == 0 ) - gtk_entry_set_text - ( - GTK_ENTRY - ( - GTK_COMBO - ( - comboboxentry_renameBoundary_availablePatches - )->entry - ), - "" - ); - - gtk_combo_set_popdown_strings - ( - GTK_COMBO - ( - comboboxentry_renameBoundary_availablePatches - ), avPatches - ); - - g_list_free(avPatches); - - GList* selPatches = 0; - forAll(newPatchNames, nameI) - { - const char* name = newPatchNames[nameI].keyword().c_str(); - selPatches = g_list_append(selPatches, const_cast<char*>(name)); - } - - gtk_combo_set_popdown_strings - ( - GTK_COMBO - ( - comboboxentry_renameBoundary_selectedPatches - ), selPatches - ); - - g_list_free(selPatches); - - if( nAvailable == newPatchNames.size() ) - { - gtk_entry_set_text - ( - GTK_ENTRY - ( - GTK_COMBO - ( - comboboxentry_renameBoundary_selectedPatches - )->entry - ), - "" - ); - } - } - else - { - GList* avPatches = 0; - - const triSurface& surf = guiPtr->surface(); - forAll(surf.patches(), patchI) - { - const char* name = surf.patches()[patchI].name().c_str(); - avPatches = g_list_append(avPatches, const_cast<char*>(name)); - } - - gtk_combo_set_popdown_strings - ( - GTK_COMBO - ( - comboboxentry_renameBoundary_availablePatches - ), avPatches - ); - - g_list_free(avPatches); - - gtk_combo_set_popdown_strings - ( - GTK_COMBO - ( - comboboxentry_renameBoundary_selectedPatches - ), avPatches - ); - - gtk_entry_set_text - ( - GTK_ENTRY - ( - GTK_COMBO(comboboxentry_renameBoundary_selectedPatches)->entry - ), - "" - ); - } - - updateNewPatchNamesForSelectedPatch(NULL, renameBoundaryFramePtr); + GtkWidget* comboboxentry_renameBoundary_availablePatches = + (GtkWidget*)g_object_get_data + ( + G_OBJECT(renameBoundaryFramePtr), + "comboboxentry_renameBoundary_availablePatches" + ); + GtkWidget* comboboxentry_renameBoundary_selectedPatches = + (GtkWidget*)g_object_get_data + ( + G_OBJECT(renameBoundaryFramePtr), + "comboboxentry_renameBoundary_selectedPatches" + ); + + if( guiPtr->newPatchNamesEntryExist() ) + { + wordHashSet selectedPatches; + PtrList<entry> newPatchNames = guiPtr->newPatchNames(); + forAll(newPatchNames, pI) + selectedPatches.insert(newPatchNames[pI].keyword()); + + label nAvailable(0); + GList* avPatches = 0; + const triSurface& surf = guiPtr->surface(); + forAll(surf.patches(), patchI) + { + if( selectedPatches.found(surf.patches()[patchI].name()) ) + continue; + + ++nAvailable; + const char* name = surf.patches()[patchI].name().c_str(); + avPatches = g_list_append(avPatches, const_cast<char*>(name)); + } + + if( nAvailable == 0 ) + gtk_entry_set_text + ( + GTK_ENTRY + ( + GTK_COMBO + ( + comboboxentry_renameBoundary_availablePatches + )->entry + ), + "" + ); + + gtk_combo_set_popdown_strings + ( + GTK_COMBO + ( + comboboxentry_renameBoundary_availablePatches + ), avPatches + ); + + g_list_free(avPatches); + + GList* selPatches = 0; + forAll(newPatchNames, nameI) + { + const char* name = newPatchNames[nameI].keyword().c_str(); + selPatches = g_list_append(selPatches, const_cast<char*>(name)); + } + + gtk_combo_set_popdown_strings + ( + GTK_COMBO + ( + comboboxentry_renameBoundary_selectedPatches + ), selPatches + ); + + g_list_free(selPatches); + + if( nAvailable == newPatchNames.size() ) + { + gtk_entry_set_text + ( + GTK_ENTRY + ( + GTK_COMBO + ( + comboboxentry_renameBoundary_selectedPatches + )->entry + ), + "" + ); + } + } + else + { + GList* avPatches = 0; + + const triSurface& surf = guiPtr->surface(); + forAll(surf.patches(), patchI) + { + const char* name = surf.patches()[patchI].name().c_str(); + avPatches = g_list_append(avPatches, const_cast<char*>(name)); + } + + gtk_combo_set_popdown_strings + ( + GTK_COMBO + ( + comboboxentry_renameBoundary_availablePatches + ), avPatches + ); + + g_list_free(avPatches); + + gtk_combo_set_popdown_strings + ( + GTK_COMBO + ( + comboboxentry_renameBoundary_selectedPatches + ), avPatches + ); + + gtk_entry_set_text + ( + GTK_ENTRY + ( + GTK_COMBO(comboboxentry_renameBoundary_selectedPatches)->entry + ), + "" + ); + } + + updateNewPatchNamesForSelectedPatch(NULL, renameBoundaryFramePtr); } static void setDefaultValues(GtkWidget* renameBoundaryFramePtr) { - GtkWidget* checkbutton_renameBoundary_defaultPatchName = - (GtkWidget*)g_object_get_data - ( - G_OBJECT(renameBoundaryFramePtr), - "checkbutton_renameBoundary_defaultPatchName" - ); - GtkWidget* entry_renameBoundary_defaultPatchName = - (GtkWidget*)g_object_get_data - ( - G_OBJECT(renameBoundaryFramePtr), - "entry_renameBoundary_defaultPatchName" - ); - GtkWidget* checkbutton_renameBoundary_defaultPatchType = - (GtkWidget*)g_object_get_data - ( - G_OBJECT(renameBoundaryFramePtr), - "checkbutton_renameBoundary_defaultPatchType" - ); - GtkWidget* entry_renameBoundary_defaultPatchType = - (GtkWidget*)g_object_get_data - ( - G_OBJECT(renameBoundaryFramePtr), - "entry_renameBoundary_defaultPatchType" - ); - - if( guiPtr->defaultPatchNameEntryExist() ) - { - gtk_toggle_button_set_active - ( - GTK_TOGGLE_BUTTON(checkbutton_renameBoundary_defaultPatchName), - 1 - ); - - gtk_editable_set_editable - ( - GTK_EDITABLE(entry_renameBoundary_defaultPatchName), 1 - ); - gtk_entry_set_text - ( - GTK_ENTRY(entry_renameBoundary_defaultPatchName), - guiPtr->defaultPatchName().c_str() - ); - } - else - { - gtk_toggle_button_set_active - ( - GTK_TOGGLE_BUTTON(checkbutton_renameBoundary_defaultPatchName), - 0 - ); - - gtk_editable_set_editable - ( - GTK_EDITABLE(entry_renameBoundary_defaultPatchName), 0 - ); - gtk_entry_set_text - ( - GTK_ENTRY(entry_renameBoundary_defaultPatchName), - "" - ); - } - - if( guiPtr->defaultPatchTypeEntryExist() ) - { - gtk_toggle_button_set_active - ( - GTK_TOGGLE_BUTTON(checkbutton_renameBoundary_defaultPatchType), - 1 - ); - - gtk_editable_set_editable - ( - GTK_EDITABLE(entry_renameBoundary_defaultPatchType), 1 - ); - - gtk_entry_set_text - ( - GTK_ENTRY(entry_renameBoundary_defaultPatchType), - guiPtr->defaultPatchType().c_str() - ); - } - else - { - gtk_toggle_button_set_active - ( - GTK_TOGGLE_BUTTON(checkbutton_renameBoundary_defaultPatchType), - 0 - ); - - gtk_editable_set_editable - ( - GTK_EDITABLE(entry_renameBoundary_defaultPatchType), 0 - ); - - gtk_entry_set_text - ( - GTK_ENTRY(entry_renameBoundary_defaultPatchType), - "" - ); - } + GtkWidget* checkbutton_renameBoundary_defaultPatchName = + (GtkWidget*)g_object_get_data + ( + G_OBJECT(renameBoundaryFramePtr), + "checkbutton_renameBoundary_defaultPatchName" + ); + GtkWidget* entry_renameBoundary_defaultPatchName = + (GtkWidget*)g_object_get_data + ( + G_OBJECT(renameBoundaryFramePtr), + "entry_renameBoundary_defaultPatchName" + ); + GtkWidget* checkbutton_renameBoundary_defaultPatchType = + (GtkWidget*)g_object_get_data + ( + G_OBJECT(renameBoundaryFramePtr), + "checkbutton_renameBoundary_defaultPatchType" + ); + GtkWidget* entry_renameBoundary_defaultPatchType = + (GtkWidget*)g_object_get_data + ( + G_OBJECT(renameBoundaryFramePtr), + "entry_renameBoundary_defaultPatchType" + ); + + if( guiPtr->defaultPatchNameEntryExist() ) + { + gtk_toggle_button_set_active + ( + GTK_TOGGLE_BUTTON(checkbutton_renameBoundary_defaultPatchName), + 1 + ); + + gtk_editable_set_editable + ( + GTK_EDITABLE(entry_renameBoundary_defaultPatchName), 1 + ); + gtk_entry_set_text + ( + GTK_ENTRY(entry_renameBoundary_defaultPatchName), + guiPtr->defaultPatchName().c_str() + ); + } + else + { + gtk_toggle_button_set_active + ( + GTK_TOGGLE_BUTTON(checkbutton_renameBoundary_defaultPatchName), + 0 + ); + + gtk_editable_set_editable + ( + GTK_EDITABLE(entry_renameBoundary_defaultPatchName), 0 + ); + gtk_entry_set_text + ( + GTK_ENTRY(entry_renameBoundary_defaultPatchName), + "" + ); + } + + if( guiPtr->defaultPatchTypeEntryExist() ) + { + gtk_toggle_button_set_active + ( + GTK_TOGGLE_BUTTON(checkbutton_renameBoundary_defaultPatchType), + 1 + ); + + gtk_editable_set_editable + ( + GTK_EDITABLE(entry_renameBoundary_defaultPatchType), 1 + ); + + gtk_entry_set_text + ( + GTK_ENTRY(entry_renameBoundary_defaultPatchType), + guiPtr->defaultPatchType().c_str() + ); + } + else + { + gtk_toggle_button_set_active + ( + GTK_TOGGLE_BUTTON(checkbutton_renameBoundary_defaultPatchType), + 0 + ); + + gtk_editable_set_editable + ( + GTK_EDITABLE(entry_renameBoundary_defaultPatchType), 0 + ); + + gtk_entry_set_text + ( + GTK_ENTRY(entry_renameBoundary_defaultPatchType), + "" + ); + } } static void useDefaultPatchName ( - GtkWidget* widget, - GtkWidget* renameBoundaryFramePtr + GtkWidget* widget, + GtkWidget* renameBoundaryFramePtr ) { - GtkWidget* checkbutton_renameBoundary_defaultPatchName = - (GtkWidget*)g_object_get_data - ( - G_OBJECT(renameBoundaryFramePtr), - "checkbutton_renameBoundary_defaultPatchName" - ); - GtkWidget* entry_renameBoundary_defaultPatchName = - (GtkWidget*)g_object_get_data - ( - G_OBJECT(renameBoundaryFramePtr), - "entry_renameBoundary_defaultPatchName" - ); - - if( guiPtr->defaultPatchNameEntryExist() ) - { - gtk_toggle_button_set_active - ( - GTK_TOGGLE_BUTTON(checkbutton_renameBoundary_defaultPatchName), 0 - ); - gtk_editable_set_editable - ( - GTK_EDITABLE(entry_renameBoundary_defaultPatchName), 0 - ); - gtk_entry_set_text - ( - GTK_ENTRY(entry_renameBoundary_defaultPatchName), "" - ); - guiPtr->removeDefaultPatchName(); - } - else - { - gtk_toggle_button_set_active - ( - GTK_TOGGLE_BUTTON(checkbutton_renameBoundary_defaultPatchName), 1 - ); - gtk_editable_set_editable - ( - GTK_EDITABLE(entry_renameBoundary_defaultPatchName), 1 - ); - gtk_entry_set_text - ( - GTK_ENTRY(entry_renameBoundary_defaultPatchName), "defaultFaces" - ); - guiPtr->setDefaultPatchName("defaultFaces"); - } + GtkWidget* checkbutton_renameBoundary_defaultPatchName = + (GtkWidget*)g_object_get_data + ( + G_OBJECT(renameBoundaryFramePtr), + "checkbutton_renameBoundary_defaultPatchName" + ); + GtkWidget* entry_renameBoundary_defaultPatchName = + (GtkWidget*)g_object_get_data + ( + G_OBJECT(renameBoundaryFramePtr), + "entry_renameBoundary_defaultPatchName" + ); + + if( guiPtr->defaultPatchNameEntryExist() ) + { + gtk_toggle_button_set_active + ( + GTK_TOGGLE_BUTTON(checkbutton_renameBoundary_defaultPatchName), 0 + ); + gtk_editable_set_editable + ( + GTK_EDITABLE(entry_renameBoundary_defaultPatchName), 0 + ); + gtk_entry_set_text + ( + GTK_ENTRY(entry_renameBoundary_defaultPatchName), "" + ); + guiPtr->removeDefaultPatchName(); + } + else + { + gtk_toggle_button_set_active + ( + GTK_TOGGLE_BUTTON(checkbutton_renameBoundary_defaultPatchName), 1 + ); + gtk_editable_set_editable + ( + GTK_EDITABLE(entry_renameBoundary_defaultPatchName), 1 + ); + gtk_entry_set_text + ( + GTK_ENTRY(entry_renameBoundary_defaultPatchName), "defaultFaces" + ); + guiPtr->setDefaultPatchName("defaultFaces"); + } } static void setDefaultPatchName ( - GtkWidget* widget, - GtkWidget* renameBoundaryFramePtr + GtkWidget* widget, + GtkWidget* renameBoundaryFramePtr ) { - GtkWidget* checkbutton_renameBoundary_defaultPatchName = - (GtkWidget*)g_object_get_data - ( - G_OBJECT(renameBoundaryFramePtr), - "checkbutton_renameBoundary_defaultPatchName" - ); - GtkWidget* entry_renameBoundary_defaultPatchName = - (GtkWidget*)g_object_get_data - ( - G_OBJECT(renameBoundaryFramePtr), - "entry_renameBoundary_defaultPatchName" - ); - - if( - gtk_toggle_button_get_active - ( - GTK_TOGGLE_BUTTON(checkbutton_renameBoundary_defaultPatchName) - ) - ) - { - const word name = - gtk_entry_get_text - ( - GTK_ENTRY(entry_renameBoundary_defaultPatchName) - ); - - guiPtr->setDefaultPatchName(name); - } + GtkWidget* checkbutton_renameBoundary_defaultPatchName = + (GtkWidget*)g_object_get_data + ( + G_OBJECT(renameBoundaryFramePtr), + "checkbutton_renameBoundary_defaultPatchName" + ); + GtkWidget* entry_renameBoundary_defaultPatchName = + (GtkWidget*)g_object_get_data + ( + G_OBJECT(renameBoundaryFramePtr), + "entry_renameBoundary_defaultPatchName" + ); + + if( + gtk_toggle_button_get_active + ( + GTK_TOGGLE_BUTTON(checkbutton_renameBoundary_defaultPatchName) + ) + ) + { + const word name = + gtk_entry_get_text + ( + GTK_ENTRY(entry_renameBoundary_defaultPatchName) + ); + + guiPtr->setDefaultPatchName(name); + } } static void useDefaultPatchType ( - GtkWidget* widget, - GtkWidget* renameBoundaryFramePtr + GtkWidget* widget, + GtkWidget* renameBoundaryFramePtr ) { - GtkWidget* checkbutton_renameBoundary_defaultPatchType = - (GtkWidget*)g_object_get_data - ( - G_OBJECT(renameBoundaryFramePtr), - "checkbutton_renameBoundary_defaultPatchType" - ); - GtkWidget* entry_renameBoundary_defaultPatchType = - (GtkWidget*)g_object_get_data - ( - G_OBJECT(renameBoundaryFramePtr), - "entry_renameBoundary_defaultPatchType" - ); - - if( guiPtr->defaultPatchTypeEntryExist() ) - { - gtk_toggle_button_set_active - ( - GTK_TOGGLE_BUTTON(checkbutton_renameBoundary_defaultPatchType), 0 - ); - gtk_editable_set_editable - ( - GTK_EDITABLE(entry_renameBoundary_defaultPatchType), 0 - ); - gtk_entry_set_text - ( - GTK_ENTRY(entry_renameBoundary_defaultPatchType), "" - ); - guiPtr->removeDefaultPatchType(); - } - else - { - gtk_toggle_button_set_active - ( - GTK_TOGGLE_BUTTON(checkbutton_renameBoundary_defaultPatchType), 1 - ); - gtk_editable_set_editable - ( - GTK_EDITABLE(entry_renameBoundary_defaultPatchType), 1 - ); - gtk_entry_set_text - ( - GTK_ENTRY(entry_renameBoundary_defaultPatchType), "patch" - ); - guiPtr->setDefaultPatchType("patch"); - } + GtkWidget* checkbutton_renameBoundary_defaultPatchType = + (GtkWidget*)g_object_get_data + ( + G_OBJECT(renameBoundaryFramePtr), + "checkbutton_renameBoundary_defaultPatchType" + ); + GtkWidget* entry_renameBoundary_defaultPatchType = + (GtkWidget*)g_object_get_data + ( + G_OBJECT(renameBoundaryFramePtr), + "entry_renameBoundary_defaultPatchType" + ); + + if( guiPtr->defaultPatchTypeEntryExist() ) + { + gtk_toggle_button_set_active + ( + GTK_TOGGLE_BUTTON(checkbutton_renameBoundary_defaultPatchType), 0 + ); + gtk_editable_set_editable + ( + GTK_EDITABLE(entry_renameBoundary_defaultPatchType), 0 + ); + gtk_entry_set_text + ( + GTK_ENTRY(entry_renameBoundary_defaultPatchType), "" + ); + guiPtr->removeDefaultPatchType(); + } + else + { + gtk_toggle_button_set_active + ( + GTK_TOGGLE_BUTTON(checkbutton_renameBoundary_defaultPatchType), 1 + ); + gtk_editable_set_editable + ( + GTK_EDITABLE(entry_renameBoundary_defaultPatchType), 1 + ); + gtk_entry_set_text + ( + GTK_ENTRY(entry_renameBoundary_defaultPatchType), "patch" + ); + guiPtr->setDefaultPatchType("patch"); + } } static void setDefaultPatchType ( - GtkWidget* widget, - GtkWidget* renameBoundaryFramePtr + GtkWidget* widget, + GtkWidget* renameBoundaryFramePtr ) { - GtkWidget* checkbutton_renameBoundary_defaultPatchType = - (GtkWidget*)g_object_get_data - ( - G_OBJECT(renameBoundaryFramePtr), - "checkbutton_renameBoundary_defaultPatchType" - ); - GtkWidget* entry_renameBoundary_defaultPatchType = - (GtkWidget*)g_object_get_data - ( - G_OBJECT(renameBoundaryFramePtr), - "entry_renameBoundary_defaultPatchType" - ); - - if( - gtk_toggle_button_get_active - ( - GTK_TOGGLE_BUTTON(checkbutton_renameBoundary_defaultPatchType) - ) - ) - { - const word pType = - gtk_entry_get_text - ( - GTK_ENTRY(entry_renameBoundary_defaultPatchType) - ); - - guiPtr->setDefaultPatchType(pType); - } + GtkWidget* checkbutton_renameBoundary_defaultPatchType = + (GtkWidget*)g_object_get_data + ( + G_OBJECT(renameBoundaryFramePtr), + "checkbutton_renameBoundary_defaultPatchType" + ); + GtkWidget* entry_renameBoundary_defaultPatchType = + (GtkWidget*)g_object_get_data + ( + G_OBJECT(renameBoundaryFramePtr), + "entry_renameBoundary_defaultPatchType" + ); + + if( + gtk_toggle_button_get_active + ( + GTK_TOGGLE_BUTTON(checkbutton_renameBoundary_defaultPatchType) + ) + ) + { + const word pType = + gtk_entry_get_text + ( + GTK_ENTRY(entry_renameBoundary_defaultPatchType) + ); + + guiPtr->setDefaultPatchType(pType); + } } static void useNewPatchType ( - GtkWidget* widget, - GtkWidget* renameBoundaryFramePtr + GtkWidget* widget, + GtkWidget* renameBoundaryFramePtr ) { - GtkWidget* entry_renameBoundary_newPatchType = - (GtkWidget*)g_object_get_data - ( - G_OBJECT(renameBoundaryFramePtr), - "entry_renameBoundary_newPatchType" - ); - - Info << "Here " << gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)) << endl; - if( gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)) ) - { - gtk_editable_set_editable - ( - GTK_EDITABLE(entry_renameBoundary_newPatchType), 1 - ); - } - else - { - gtk_entry_set_text - ( - GTK_ENTRY(entry_renameBoundary_newPatchType), "" - ); - gtk_editable_set_editable - ( - GTK_EDITABLE(entry_renameBoundary_newPatchType), 0 - ); - } + GtkWidget* entry_renameBoundary_newPatchType = + (GtkWidget*)g_object_get_data + ( + G_OBJECT(renameBoundaryFramePtr), + "entry_renameBoundary_newPatchType" + ); + + Info << "Here " << gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)) << endl; + if( gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)) ) + { + gtk_editable_set_editable + ( + GTK_EDITABLE(entry_renameBoundary_newPatchType), 1 + ); + } + else + { + gtk_entry_set_text + ( + GTK_ENTRY(entry_renameBoundary_newPatchType), "" + ); + gtk_editable_set_editable + ( + GTK_EDITABLE(entry_renameBoundary_newPatchType), 0 + ); + } } static void addNewPatchName ( - GtkWidget* widget, - GtkWidget* renameBoundaryFramePtr + GtkWidget* widget, + GtkWidget* renameBoundaryFramePtr ) { - GtkWidget* comboboxentry_renameBoundary_availablePatches = - (GtkWidget*)g_object_get_data - ( - G_OBJECT(renameBoundaryFramePtr), - "comboboxentry_renameBoundary_availablePatches" - ); - GtkWidget* entry_renameBoundary_newPatchName = - (GtkWidget*)g_object_get_data - ( - G_OBJECT(renameBoundaryFramePtr), - "entry_renameBoundary_newPatchName" - ); - GtkWidget* checkbutton_renameBoundary_newPatchType = - (GtkWidget*)g_object_get_data - ( - G_OBJECT(renameBoundaryFramePtr), - "checkbutton_renameBoundary_newPatchType" - ); - GtkWidget* entry_renameBoundary_newPatchType = - (GtkWidget*)g_object_get_data - ( - G_OBJECT(renameBoundaryFramePtr), - "entry_renameBoundary_newPatchType" - ); - - const word name = - gtk_entry_get_text - ( - GTK_ENTRY - ( - GTK_COMBO - ( - comboboxentry_renameBoundary_availablePatches - )->entry - ) - ); - - if( name == "" ) - return; + GtkWidget* comboboxentry_renameBoundary_availablePatches = + (GtkWidget*)g_object_get_data + ( + G_OBJECT(renameBoundaryFramePtr), + "comboboxentry_renameBoundary_availablePatches" + ); + GtkWidget* entry_renameBoundary_newPatchName = + (GtkWidget*)g_object_get_data + ( + G_OBJECT(renameBoundaryFramePtr), + "entry_renameBoundary_newPatchName" + ); + GtkWidget* checkbutton_renameBoundary_newPatchType = + (GtkWidget*)g_object_get_data + ( + G_OBJECT(renameBoundaryFramePtr), + "checkbutton_renameBoundary_newPatchType" + ); + GtkWidget* entry_renameBoundary_newPatchType = + (GtkWidget*)g_object_get_data + ( + G_OBJECT(renameBoundaryFramePtr), + "entry_renameBoundary_newPatchType" + ); + + const word name = + gtk_entry_get_text + ( + GTK_ENTRY + ( + GTK_COMBO + ( + comboboxentry_renameBoundary_availablePatches + )->entry + ) + ); + + if( name == "" ) + return; - const word newName = - gtk_entry_get_text - ( - GTK_ENTRY(entry_renameBoundary_newPatchName) - ); - gtk_entry_set_text(GTK_ENTRY(entry_renameBoundary_newPatchName), ""); - - word newType("patch"); - if( - gtk_toggle_button_get_active - ( - GTK_TOGGLE_BUTTON(checkbutton_renameBoundary_newPatchType) - ) - ) - { - newType = - gtk_entry_get_text - ( - GTK_ENTRY(entry_renameBoundary_newPatchType) - ); - - gtk_toggle_button_set_active - ( - GTK_TOGGLE_BUTTON(checkbutton_renameBoundary_newPatchType), 0 - ); - gtk_entry_set_text - ( - GTK_ENTRY(entry_renameBoundary_newPatchType), "" - ); - } - - dictionary dict; - dict.add("newName", newName); - dict.add("type", newType); - guiPtr->addNewPatchName(name, dict); - - updateNewPatchNames(renameBoundaryFramePtr); + const word newName = + gtk_entry_get_text + ( + GTK_ENTRY(entry_renameBoundary_newPatchName) + ); + gtk_entry_set_text(GTK_ENTRY(entry_renameBoundary_newPatchName), ""); + + word newType("patch"); + if( + gtk_toggle_button_get_active + ( + GTK_TOGGLE_BUTTON(checkbutton_renameBoundary_newPatchType) + ) + ) + { + newType = + gtk_entry_get_text + ( + GTK_ENTRY(entry_renameBoundary_newPatchType) + ); + + gtk_toggle_button_set_active + ( + GTK_TOGGLE_BUTTON(checkbutton_renameBoundary_newPatchType), 0 + ); + gtk_entry_set_text + ( + GTK_ENTRY(entry_renameBoundary_newPatchType), "" + ); + } + + dictionary dict; + dict.add("newName", newName); + dict.add("type", newType); + guiPtr->addNewPatchName(name, dict); + + updateNewPatchNames(renameBoundaryFramePtr); } static void removeNewPatchName ( - GtkWidget* widget, - GtkWidget* renameBoundaryFramePtr + GtkWidget* widget, + GtkWidget* renameBoundaryFramePtr ) { - GtkWidget* comboboxentry_renameBoundary_selectedPatches = - (GtkWidget*)g_object_get_data - ( - G_OBJECT(renameBoundaryFramePtr), - "comboboxentry_renameBoundary_selectedPatches" - ); - - const word name = - gtk_entry_get_text - ( - GTK_ENTRY - ( - GTK_COMBO - ( - comboboxentry_renameBoundary_selectedPatches - )->entry - ) - ); - - if( name == "" ) - return; - - guiPtr->removePatchName(name); - - updateNewPatchNames(renameBoundaryFramePtr); + GtkWidget* comboboxentry_renameBoundary_selectedPatches = + (GtkWidget*)g_object_get_data + ( + G_OBJECT(renameBoundaryFramePtr), + "comboboxentry_renameBoundary_selectedPatches" + ); + + const word name = + gtk_entry_get_text + ( + GTK_ENTRY + ( + GTK_COMBO + ( + comboboxentry_renameBoundary_selectedPatches + )->entry + ) + ); + + if( name == "" ) + return; + + guiPtr->removePatchName(name); + + updateNewPatchNames(renameBoundaryFramePtr); } } @@ -763,469 +763,469 @@ static void removeNewPatchName void meshGenGTK::createRenameBoundaryMainWindowPage() { - guiPtr = &meshGui_; - - renameBoundaryFramePtr_ = gtk_frame_new(NULL); + guiPtr = &meshGui_; + + renameBoundaryFramePtr_ = gtk_frame_new(NULL); // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - //- create a table - GtkWidget* table1 = gtk_table_new(3, 10, FALSE); - gtk_widget_show(table1); - gtk_container_add - ( - GTK_CONTAINER(renameBoundaryFramePtr_), - table1 - ); - + //- create a table + GtkWidget* table1 = gtk_table_new(3, 10, FALSE); + gtk_widget_show(table1); + gtk_container_add + ( + GTK_CONTAINER(renameBoundaryFramePtr_), + table1 + ); + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - //- create a check button for default patch name - GtkWidget* checkbutton_renameBoundary_defaultPatchName = - gtk_check_button_new_with_mnemonic - ( - "Default patch name" - ); - gtk_widget_show(checkbutton_renameBoundary_defaultPatchName); - - gtk_table_attach(GTK_TABLE(table1), - checkbutton_renameBoundary_defaultPatchName, 0, 1, 0, 1, + //- create a check button for default patch name + GtkWidget* checkbutton_renameBoundary_defaultPatchName = + gtk_check_button_new_with_mnemonic + ( + "Default patch name" + ); + gtk_widget_show(checkbutton_renameBoundary_defaultPatchName); + + gtk_table_attach(GTK_TABLE(table1), + checkbutton_renameBoundary_defaultPatchName, 0, 1, 0, 1, (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0); // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - //- create the entry for default patch name - GtkWidget* entry_renameBoundary_defaultPatchName = gtk_entry_new(); - gtk_widget_show(entry_renameBoundary_defaultPatchName); - - gtk_table_attach(GTK_TABLE(table1), - entry_renameBoundary_defaultPatchName, 1, 2, 0, 1, + //- create the entry for default patch name + GtkWidget* entry_renameBoundary_defaultPatchName = gtk_entry_new(); + gtk_widget_show(entry_renameBoundary_defaultPatchName); + + gtk_table_attach(GTK_TABLE(table1), + entry_renameBoundary_defaultPatchName, 1, 2, 0, 1, (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0); // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - //- create a check button for default patch type - GtkWidget* checkbutton_renameBoundary_defaultPatchType = - gtk_check_button_new_with_mnemonic - ( - "Default patch type" - ); - gtk_widget_show(checkbutton_renameBoundary_defaultPatchType); - - gtk_table_attach(GTK_TABLE(table1), - checkbutton_renameBoundary_defaultPatchType, 0, 1, 1, 2, + //- create a check button for default patch type + GtkWidget* checkbutton_renameBoundary_defaultPatchType = + gtk_check_button_new_with_mnemonic + ( + "Default patch type" + ); + gtk_widget_show(checkbutton_renameBoundary_defaultPatchType); + + gtk_table_attach(GTK_TABLE(table1), + checkbutton_renameBoundary_defaultPatchType, 0, 1, 1, 2, (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0); // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - //- create the entry for default patch type - GtkWidget* entry_renameBoundary_defaultPatchType = gtk_entry_new(); - gtk_widget_show(entry_renameBoundary_defaultPatchType); - - gtk_table_attach(GTK_TABLE(table1), - entry_renameBoundary_defaultPatchType, 1, 2, 1, 2, + //- create the entry for default patch type + GtkWidget* entry_renameBoundary_defaultPatchType = gtk_entry_new(); + gtk_widget_show(entry_renameBoundary_defaultPatchType); + + gtk_table_attach(GTK_TABLE(table1), + entry_renameBoundary_defaultPatchType, 1, 2, 1, 2, (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0); // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - //- add a horizontal separator - GtkWidget* hseparator = gtk_hseparator_new(); - gtk_widget_show(hseparator); - gtk_table_attach(GTK_TABLE(table1), hseparator, 0, 3, 2, 3, + //- add a horizontal separator + GtkWidget* hseparator = gtk_hseparator_new(); + gtk_widget_show(hseparator); + gtk_table_attach(GTK_TABLE(table1), hseparator, 0, 3, 2, 3, (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(GTK_EXPAND | GTK_SHRINK | GTK_FILL), - 0, 0); - + 0, 0); + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - //- add a label for available patches - GtkWidget* label_renameBoundary_availablePatches = - gtk_label_new("Available patches"); - gtk_widget_show(label_renameBoundary_availablePatches); - - gtk_table_attach(GTK_TABLE(table1), - label_renameBoundary_availablePatches, 0, 1, 3, 4, + //- add a label for available patches + GtkWidget* label_renameBoundary_availablePatches = + gtk_label_new("Available patches"); + gtk_widget_show(label_renameBoundary_availablePatches); + + gtk_table_attach(GTK_TABLE(table1), + label_renameBoundary_availablePatches, 0, 1, 3, 4, (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0); // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - //- add a combo box for available patches - GtkWidget* comboboxentry_renameBoundary_availablePatches = - gtk_combo_new(); - gtk_widget_show(comboboxentry_renameBoundary_availablePatches); - - gtk_table_attach(GTK_TABLE(table1), - comboboxentry_renameBoundary_availablePatches, 1, 2, 3, 4, + //- add a combo box for available patches + GtkWidget* comboboxentry_renameBoundary_availablePatches = + gtk_combo_new(); + gtk_widget_show(comboboxentry_renameBoundary_availablePatches); + + gtk_table_attach(GTK_TABLE(table1), + comboboxentry_renameBoundary_availablePatches, 1, 2, 3, 4, (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0); - - gtk_editable_set_editable - ( - GTK_EDITABLE - ( - GTK_COMBO - ( - comboboxentry_renameBoundary_availablePatches - )->entry - ), - 0 - ); - + + gtk_editable_set_editable + ( + GTK_EDITABLE + ( + GTK_COMBO + ( + comboboxentry_renameBoundary_availablePatches + )->entry + ), + 0 + ); + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - //- add a label for new patch name - GtkWidget* label_renameBoundary_newPatchName = - gtk_label_new("New name"); - gtk_widget_show(label_renameBoundary_newPatchName); - - gtk_table_attach(GTK_TABLE(table1), - label_renameBoundary_newPatchName, 0, 1, 4, 5, + //- add a label for new patch name + GtkWidget* label_renameBoundary_newPatchName = + gtk_label_new("New name"); + gtk_widget_show(label_renameBoundary_newPatchName); + + gtk_table_attach(GTK_TABLE(table1), + label_renameBoundary_newPatchName, 0, 1, 4, 5, (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0); - + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - //- add the entry for new patch name - GtkWidget* entry_renameBoundary_newPatchName = gtk_entry_new(); - gtk_widget_show(entry_renameBoundary_newPatchName); - - gtk_table_attach(GTK_TABLE(table1), - entry_renameBoundary_newPatchName, 1, 2, 4, 5, + //- add the entry for new patch name + GtkWidget* entry_renameBoundary_newPatchName = gtk_entry_new(); + gtk_widget_show(entry_renameBoundary_newPatchName); + + gtk_table_attach(GTK_TABLE(table1), + entry_renameBoundary_newPatchName, 1, 2, 4, 5, (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0); - + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - //- add a check button for new patch type - GtkWidget* checkbutton_renameBoundary_newPatchType = - gtk_check_button_new_with_mnemonic - ( - "New type" - ); - gtk_widget_show(checkbutton_renameBoundary_newPatchType); - - gtk_table_attach(GTK_TABLE(table1), - checkbutton_renameBoundary_newPatchType, 0, 1, 5, 6, + //- add a check button for new patch type + GtkWidget* checkbutton_renameBoundary_newPatchType = + gtk_check_button_new_with_mnemonic + ( + "New type" + ); + gtk_widget_show(checkbutton_renameBoundary_newPatchType); + + gtk_table_attach(GTK_TABLE(table1), + checkbutton_renameBoundary_newPatchType, 0, 1, 5, 6, (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0); // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - //- add the entry for new patch type - GtkWidget* entry_renameBoundary_newPatchType = gtk_entry_new(); - gtk_widget_show(entry_renameBoundary_newPatchType); - - gtk_table_attach(GTK_TABLE(table1), - entry_renameBoundary_newPatchType, 1, 2, 5, 6, + //- add the entry for new patch type + GtkWidget* entry_renameBoundary_newPatchType = gtk_entry_new(); + gtk_widget_show(entry_renameBoundary_newPatchType); + + gtk_table_attach(GTK_TABLE(table1), + entry_renameBoundary_newPatchType, 1, 2, 5, 6, (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0); - + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - //- set the button for adding new patch names - GtkWidget* button1 = gtk_button_new(); - gtk_widget_show(button1); - gtk_table_attach - ( - GTK_TABLE(table1), - button1, - 2, 3, 3, 6, - (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 3 - ); + //- set the button for adding new patch names + GtkWidget* button1 = gtk_button_new(); + gtk_widget_show(button1); + gtk_table_attach + ( + GTK_TABLE(table1), + button1, + 2, 3, 3, 6, + (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 3 + ); - GtkWidget* alignment1 = gtk_alignment_new(0.5, 0.5, 0, 0); - gtk_widget_show(alignment1); - gtk_container_add(GTK_CONTAINER(button1), alignment1); - - GtkWidget* hbox1 = gtk_hbox_new(FALSE, 2); - gtk_widget_show(hbox1); - gtk_container_add(GTK_CONTAINER(alignment1), hbox1); - - GtkWidget* image1 = - gtk_image_new_from_stock("gtk-add", GTK_ICON_SIZE_BUTTON); - gtk_widget_show(image1); - gtk_box_pack_start(GTK_BOX(hbox1), image1, FALSE, FALSE, 0); - - GtkWidget* label3 = gtk_label_new_with_mnemonic("Add"); - gtk_widget_show(label3); - gtk_box_pack_start(GTK_BOX(hbox1), label3, FALSE, FALSE, 0); - + GtkWidget* alignment1 = gtk_alignment_new(0.5, 0.5, 0, 0); + gtk_widget_show(alignment1); + gtk_container_add(GTK_CONTAINER(button1), alignment1); + + GtkWidget* hbox1 = gtk_hbox_new(FALSE, 2); + gtk_widget_show(hbox1); + gtk_container_add(GTK_CONTAINER(alignment1), hbox1); + + GtkWidget* image1 = + gtk_image_new_from_stock("gtk-add", GTK_ICON_SIZE_BUTTON); + gtk_widget_show(image1); + gtk_box_pack_start(GTK_BOX(hbox1), image1, FALSE, FALSE, 0); + + GtkWidget* label3 = gtk_label_new_with_mnemonic("Add"); + gtk_widget_show(label3); + gtk_box_pack_start(GTK_BOX(hbox1), label3, FALSE, FALSE, 0); + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - //- add a horizontal separator - hseparator = gtk_hseparator_new(); - gtk_widget_show(hseparator); - gtk_table_attach(GTK_TABLE(table1), hseparator, 0, 3, 6, 7, + //- add a horizontal separator + hseparator = gtk_hseparator_new(); + gtk_widget_show(hseparator); + gtk_table_attach(GTK_TABLE(table1), hseparator, 0, 3, 6, 7, (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(GTK_EXPAND | GTK_SHRINK | GTK_FILL), - 0, 0); + 0, 0); // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - //- add a label for selected patches - GtkWidget* label_renameBoundary_selectedPatches = - gtk_label_new("Selected patches"); - gtk_widget_show(label_renameBoundary_selectedPatches); - - gtk_table_attach(GTK_TABLE(table1), - label_renameBoundary_selectedPatches, 0, 1, 7, 8, + //- add a label for selected patches + GtkWidget* label_renameBoundary_selectedPatches = + gtk_label_new("Selected patches"); + gtk_widget_show(label_renameBoundary_selectedPatches); + + gtk_table_attach(GTK_TABLE(table1), + label_renameBoundary_selectedPatches, 0, 1, 7, 8, (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0); - + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - //- add a combo box for selected patches - GtkWidget* comboboxentry_renameBoundary_selectedPatches = - gtk_combo_new(); - gtk_widget_show(comboboxentry_renameBoundary_selectedPatches); - - gtk_table_attach(GTK_TABLE(table1), - comboboxentry_renameBoundary_selectedPatches, 1, 2, 7, 8, + //- add a combo box for selected patches + GtkWidget* comboboxentry_renameBoundary_selectedPatches = + gtk_combo_new(); + gtk_widget_show(comboboxentry_renameBoundary_selectedPatches); + + gtk_table_attach(GTK_TABLE(table1), + comboboxentry_renameBoundary_selectedPatches, 1, 2, 7, 8, (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0); - - gtk_editable_set_editable - ( - GTK_EDITABLE - ( - GTK_COMBO - ( - comboboxentry_renameBoundary_selectedPatches - )->entry - ), - 0 - ); - + + gtk_editable_set_editable + ( + GTK_EDITABLE + ( + GTK_COMBO + ( + comboboxentry_renameBoundary_selectedPatches + )->entry + ), + 0 + ); + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - //- add a label for new patch name - GtkWidget* label_renameBoundary_selectedPatchName = - gtk_label_new("New name"); - gtk_widget_show(label_renameBoundary_selectedPatchName); - - gtk_table_attach(GTK_TABLE(table1), - label_renameBoundary_selectedPatchName, 0, 1, 8, 9, + //- add a label for new patch name + GtkWidget* label_renameBoundary_selectedPatchName = + gtk_label_new("New name"); + gtk_widget_show(label_renameBoundary_selectedPatchName); + + gtk_table_attach(GTK_TABLE(table1), + label_renameBoundary_selectedPatchName, 0, 1, 8, 9, (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0); - + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - //- add the entry for selected patch name - GtkWidget* entry_renameBoundary_selectedPatchName = gtk_entry_new(); - gtk_widget_show(entry_renameBoundary_selectedPatchName); - - gtk_table_attach(GTK_TABLE(table1), - entry_renameBoundary_selectedPatchName, 1, 2, 8, 9, + //- add the entry for selected patch name + GtkWidget* entry_renameBoundary_selectedPatchName = gtk_entry_new(); + gtk_widget_show(entry_renameBoundary_selectedPatchName); + + gtk_table_attach(GTK_TABLE(table1), + entry_renameBoundary_selectedPatchName, 1, 2, 8, 9, (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0); - + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - //- add a label for selected patch type - GtkWidget* label_renameBoundary_selectedPatchType = - gtk_label_new - ( - "New type" - ); - gtk_widget_show(label_renameBoundary_selectedPatchType); - - gtk_table_attach(GTK_TABLE(table1), - label_renameBoundary_selectedPatchType, 0, 1, 9, 10, + //- add a label for selected patch type + GtkWidget* label_renameBoundary_selectedPatchType = + gtk_label_new + ( + "New type" + ); + gtk_widget_show(label_renameBoundary_selectedPatchType); + + gtk_table_attach(GTK_TABLE(table1), + label_renameBoundary_selectedPatchType, 0, 1, 9, 10, (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0); // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - //- add the entry for selected patch type - GtkWidget* entry_renameBoundary_selectedPatchType = gtk_entry_new(); - gtk_widget_show(entry_renameBoundary_selectedPatchType); - - gtk_table_attach(GTK_TABLE(table1), - entry_renameBoundary_selectedPatchType, 1, 2, 9, 10, + //- add the entry for selected patch type + GtkWidget* entry_renameBoundary_selectedPatchType = gtk_entry_new(); + gtk_widget_show(entry_renameBoundary_selectedPatchType); + + gtk_table_attach(GTK_TABLE(table1), + entry_renameBoundary_selectedPatchType, 1, 2, 9, 10, (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0); // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - //- set the button for removing new patch names - GtkWidget* button2 = gtk_button_new(); - gtk_widget_show(button2); - gtk_table_attach - ( - GTK_TABLE(table1), - button2, - 2, 3, 7, 10, - (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 5 - ); - - GtkWidget* alignment2 = gtk_alignment_new(0.5, 0.5, 0, 0); - gtk_widget_show(alignment2); - gtk_container_add(GTK_CONTAINER(button2), alignment2); - - GtkWidget* hbox2 = gtk_hbox_new(FALSE, 2); - gtk_widget_show(hbox2); - gtk_container_add(GTK_CONTAINER(alignment2), hbox2); - - GtkWidget* image2 = - gtk_image_new_from_stock("gtk-remove", GTK_ICON_SIZE_BUTTON); - gtk_widget_show(image2); - gtk_box_pack_start(GTK_BOX (hbox2), image2, FALSE, FALSE, 0); - - GtkWidget* label5 = gtk_label_new_with_mnemonic("Remove"); - gtk_widget_show(label5); - gtk_box_pack_start(GTK_BOX (hbox2), label5, FALSE, FALSE, 0); - + //- set the button for removing new patch names + GtkWidget* button2 = gtk_button_new(); + gtk_widget_show(button2); + gtk_table_attach + ( + GTK_TABLE(table1), + button2, + 2, 3, 7, 10, + (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 5 + ); + + GtkWidget* alignment2 = gtk_alignment_new(0.5, 0.5, 0, 0); + gtk_widget_show(alignment2); + gtk_container_add(GTK_CONTAINER(button2), alignment2); + + GtkWidget* hbox2 = gtk_hbox_new(FALSE, 2); + gtk_widget_show(hbox2); + gtk_container_add(GTK_CONTAINER(alignment2), hbox2); + + GtkWidget* image2 = + gtk_image_new_from_stock("gtk-remove", GTK_ICON_SIZE_BUTTON); + gtk_widget_show(image2); + gtk_box_pack_start(GTK_BOX (hbox2), image2, FALSE, FALSE, 0); + + GtkWidget* label5 = gtk_label_new_with_mnemonic("Remove"); + gtk_widget_show(label5); + gtk_box_pack_start(GTK_BOX (hbox2), label5, FALSE, FALSE, 0); + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - GLADE_HOOKUP_OBJECT_NO_REF - ( - renameBoundaryFramePtr_, - renameBoundaryFramePtr_, - "renameBoundaryFramePtr_" - ); - GLADE_HOOKUP_OBJECT - ( - renameBoundaryFramePtr_, - checkbutton_renameBoundary_defaultPatchName, - "checkbutton_renameBoundary_defaultPatchName" - ); - GLADE_HOOKUP_OBJECT - ( - renameBoundaryFramePtr_, - entry_renameBoundary_defaultPatchName, - "entry_renameBoundary_defaultPatchName" - ); - GLADE_HOOKUP_OBJECT - ( - renameBoundaryFramePtr_, - checkbutton_renameBoundary_defaultPatchType, - "checkbutton_renameBoundary_defaultPatchType" - ); - GLADE_HOOKUP_OBJECT - ( - renameBoundaryFramePtr_, - entry_renameBoundary_defaultPatchType, - "entry_renameBoundary_defaultPatchType" - ); - GLADE_HOOKUP_OBJECT - ( - renameBoundaryFramePtr_, - comboboxentry_renameBoundary_availablePatches, - "comboboxentry_renameBoundary_availablePatches" - ); - GLADE_HOOKUP_OBJECT - ( - renameBoundaryFramePtr_, - entry_renameBoundary_newPatchName, - "entry_renameBoundary_newPatchName" - ); - GLADE_HOOKUP_OBJECT - ( - renameBoundaryFramePtr_, - checkbutton_renameBoundary_newPatchType, - "checkbutton_renameBoundary_newPatchType" - ); - GLADE_HOOKUP_OBJECT - ( - renameBoundaryFramePtr_, - entry_renameBoundary_newPatchType, - "entry_renameBoundary_newPatchType" - ); - GLADE_HOOKUP_OBJECT - ( - renameBoundaryFramePtr_, - comboboxentry_renameBoundary_selectedPatches, - "comboboxentry_renameBoundary_selectedPatches" - ); - GLADE_HOOKUP_OBJECT - ( - renameBoundaryFramePtr_, - entry_renameBoundary_selectedPatchName, - "entry_renameBoundary_selectedPatchName" - ); - GLADE_HOOKUP_OBJECT - ( - renameBoundaryFramePtr_, - entry_renameBoundary_selectedPatchType, - "entry_renameBoundary_selectedPatchType" - ); - + GLADE_HOOKUP_OBJECT_NO_REF + ( + renameBoundaryFramePtr_, + renameBoundaryFramePtr_, + "renameBoundaryFramePtr_" + ); + GLADE_HOOKUP_OBJECT + ( + renameBoundaryFramePtr_, + checkbutton_renameBoundary_defaultPatchName, + "checkbutton_renameBoundary_defaultPatchName" + ); + GLADE_HOOKUP_OBJECT + ( + renameBoundaryFramePtr_, + entry_renameBoundary_defaultPatchName, + "entry_renameBoundary_defaultPatchName" + ); + GLADE_HOOKUP_OBJECT + ( + renameBoundaryFramePtr_, + checkbutton_renameBoundary_defaultPatchType, + "checkbutton_renameBoundary_defaultPatchType" + ); + GLADE_HOOKUP_OBJECT + ( + renameBoundaryFramePtr_, + entry_renameBoundary_defaultPatchType, + "entry_renameBoundary_defaultPatchType" + ); + GLADE_HOOKUP_OBJECT + ( + renameBoundaryFramePtr_, + comboboxentry_renameBoundary_availablePatches, + "comboboxentry_renameBoundary_availablePatches" + ); + GLADE_HOOKUP_OBJECT + ( + renameBoundaryFramePtr_, + entry_renameBoundary_newPatchName, + "entry_renameBoundary_newPatchName" + ); + GLADE_HOOKUP_OBJECT + ( + renameBoundaryFramePtr_, + checkbutton_renameBoundary_newPatchType, + "checkbutton_renameBoundary_newPatchType" + ); + GLADE_HOOKUP_OBJECT + ( + renameBoundaryFramePtr_, + entry_renameBoundary_newPatchType, + "entry_renameBoundary_newPatchType" + ); + GLADE_HOOKUP_OBJECT + ( + renameBoundaryFramePtr_, + comboboxentry_renameBoundary_selectedPatches, + "comboboxentry_renameBoundary_selectedPatches" + ); + GLADE_HOOKUP_OBJECT + ( + renameBoundaryFramePtr_, + entry_renameBoundary_selectedPatchName, + "entry_renameBoundary_selectedPatchName" + ); + GLADE_HOOKUP_OBJECT + ( + renameBoundaryFramePtr_, + entry_renameBoundary_selectedPatchType, + "entry_renameBoundary_selectedPatchType" + ); + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - - setDefaultValues(renameBoundaryFramePtr_); - updateNewPatchNames(renameBoundaryFramePtr_); - - g_signal_connect - ( - G_OBJECT - ( - GTK_ENTRY - ( - GTK_COMBO(comboboxentry_renameBoundary_selectedPatches)->entry - ) - ), - "changed", - G_CALLBACK(updateNewPatchNamesForSelectedPatch), - renameBoundaryFramePtr_ - ); - - g_signal_connect - ( - G_OBJECT(checkbutton_renameBoundary_defaultPatchName), - "clicked", - G_CALLBACK(useDefaultPatchName), - renameBoundaryFramePtr_ - ); + + setDefaultValues(renameBoundaryFramePtr_); + updateNewPatchNames(renameBoundaryFramePtr_); + + g_signal_connect + ( + G_OBJECT + ( + GTK_ENTRY + ( + GTK_COMBO(comboboxentry_renameBoundary_selectedPatches)->entry + ) + ), + "changed", + G_CALLBACK(updateNewPatchNamesForSelectedPatch), + renameBoundaryFramePtr_ + ); + + g_signal_connect + ( + G_OBJECT(checkbutton_renameBoundary_defaultPatchName), + "clicked", + G_CALLBACK(useDefaultPatchName), + renameBoundaryFramePtr_ + ); - g_signal_connect - ( - G_OBJECT(entry_renameBoundary_defaultPatchName), - "changed", - G_CALLBACK(setDefaultPatchName), - renameBoundaryFramePtr_ - ); + g_signal_connect + ( + G_OBJECT(entry_renameBoundary_defaultPatchName), + "changed", + G_CALLBACK(setDefaultPatchName), + renameBoundaryFramePtr_ + ); - g_signal_connect - ( - G_OBJECT(checkbutton_renameBoundary_defaultPatchType), - "clicked", - G_CALLBACK(useDefaultPatchType), - renameBoundaryFramePtr_ - ); - - g_signal_connect - ( - G_OBJECT(entry_renameBoundary_defaultPatchType), - "changed", - G_CALLBACK(setDefaultPatchType), - renameBoundaryFramePtr_ - ); - - g_signal_connect - ( - G_OBJECT(checkbutton_renameBoundary_newPatchType), - "clicked", - G_CALLBACK(useNewPatchType), - renameBoundaryFramePtr_ - ); - - g_signal_connect - ( - G_OBJECT(entry_renameBoundary_selectedPatchName), - "changed", - G_CALLBACK(resetNewPatchNamesForSelectedPatch), - renameBoundaryFramePtr_ - ); - - g_signal_connect - ( - G_OBJECT(entry_renameBoundary_selectedPatchType), - "changed", - G_CALLBACK(resetNewPatchNamesForSelectedPatch), - renameBoundaryFramePtr_ - ); - - g_signal_connect - ( - G_OBJECT(button1), - "clicked", - G_CALLBACK(addNewPatchName), - renameBoundaryFramePtr_ - ); - - g_signal_connect - ( - G_OBJECT(button2), - "clicked", - G_CALLBACK(removeNewPatchName), - renameBoundaryFramePtr_ - ); - - gtk_widget_show(renameBoundaryFramePtr_); + g_signal_connect + ( + G_OBJECT(checkbutton_renameBoundary_defaultPatchType), + "clicked", + G_CALLBACK(useDefaultPatchType), + renameBoundaryFramePtr_ + ); + + g_signal_connect + ( + G_OBJECT(entry_renameBoundary_defaultPatchType), + "changed", + G_CALLBACK(setDefaultPatchType), + renameBoundaryFramePtr_ + ); + + g_signal_connect + ( + G_OBJECT(checkbutton_renameBoundary_newPatchType), + "clicked", + G_CALLBACK(useNewPatchType), + renameBoundaryFramePtr_ + ); + + g_signal_connect + ( + G_OBJECT(entry_renameBoundary_selectedPatchName), + "changed", + G_CALLBACK(resetNewPatchNamesForSelectedPatch), + renameBoundaryFramePtr_ + ); + + g_signal_connect + ( + G_OBJECT(entry_renameBoundary_selectedPatchType), + "changed", + G_CALLBACK(resetNewPatchNamesForSelectedPatch), + renameBoundaryFramePtr_ + ); + + g_signal_connect + ( + G_OBJECT(button1), + "clicked", + G_CALLBACK(addNewPatchName), + renameBoundaryFramePtr_ + ); + + g_signal_connect + ( + G_OBJECT(button2), + "clicked", + G_CALLBACK(removeNewPatchName), + renameBoundaryFramePtr_ + ); + + gtk_widget_show(renameBoundaryFramePtr_); } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/GUI/meshGenGTK/meshGenGTKSphereRefinement.C b/GUI/meshGenGTK/meshGenGTKSphereRefinement.C index ec69c6fc..8fb36518 100644 --- a/GUI/meshGenGTK/meshGenGTKSphereRefinement.C +++ b/GUI/meshGenGTK/meshGenGTKSphereRefinement.C @@ -43,871 +43,871 @@ extern "C" static void showDataForSphereRefinement ( - GtkWidget* widget, - GtkWidget* sphereRefinementFramePtr + GtkWidget* widget, + GtkWidget* sphereRefinementFramePtr ) { - GtkWidget* comboboxentry_sphereRefinement_createdSpheres = - (GtkWidget*)g_object_get_data - ( - G_OBJECT(sphereRefinementFramePtr), - "comboboxentry_sphereRefinement_createdSpheres" - ); - GtkWidget* entry_sphereRefinement_selectedCellSize = - (GtkWidget*)g_object_get_data - ( - G_OBJECT(sphereRefinementFramePtr), - "entry_sphereRefinement_selectedCellSize" - ); - GtkWidget* entry_sphereRefinement_selectedCentreX = - (GtkWidget*)g_object_get_data - ( - G_OBJECT(sphereRefinementFramePtr), - "entry_sphereRefinement_selectedCentreX" - ); - GtkWidget* entry_sphereRefinement_selectedCentreY = - (GtkWidget*)g_object_get_data - ( - G_OBJECT(sphereRefinementFramePtr), - "entry_sphereRefinement_selectedCentreY" - ); - GtkWidget* entry_sphereRefinement_selectedCentreZ = - (GtkWidget*)g_object_get_data - ( - G_OBJECT(sphereRefinementFramePtr), - "entry_sphereRefinement_selectedCentreZ" - ); - GtkWidget* entry_sphereRefinement_selectedRadius = - (GtkWidget*)g_object_get_data - ( - G_OBJECT(sphereRefinementFramePtr), - "entry_sphereRefinement_selectedRadius" - ); - - //- find the object in the dictionary - const word sphereName = - gtk_entry_get_text - ( - GTK_ENTRY - ( - GTK_COMBO(comboboxentry_sphereRefinement_createdSpheres)->entry - ) - ); - - const PtrList<entry> refs = guiPtr->objectRefinements(); - - forAll(refs, refI) - if( refs[refI].keyword() == sphereName ) - { - const dictionary dict = refs[refI].dict(); - - gtk_entry_set_text - ( - GTK_ENTRY(entry_sphereRefinement_selectedCellSize), - help::scalarToText - ( - scalar(readScalar(dict.lookup("cellSize"))) - ).c_str() - ); - const vector centre(dict.lookup("centre")); - gtk_entry_set_text - ( - GTK_ENTRY(entry_sphereRefinement_selectedCentreX), - help::scalarToText(centre.x()).c_str() - ); - gtk_entry_set_text - ( - GTK_ENTRY(entry_sphereRefinement_selectedCentreY), - help::scalarToText(centre.y()).c_str() - ); - gtk_entry_set_text - ( - GTK_ENTRY(entry_sphereRefinement_selectedCentreZ), - help::scalarToText(centre.z()).c_str() - ); - - const scalar radius(readScalar(dict.lookup("radius"))); - gtk_entry_set_text - ( - GTK_ENTRY(entry_sphereRefinement_selectedRadius), - help::scalarToText(radius).c_str() - ); - - return; - } - - gtk_entry_set_text(GTK_ENTRY(entry_sphereRefinement_selectedCellSize), ""); - gtk_entry_set_text(GTK_ENTRY(entry_sphereRefinement_selectedCentreX), ""); - gtk_entry_set_text(GTK_ENTRY(entry_sphereRefinement_selectedCentreY), ""); - gtk_entry_set_text(GTK_ENTRY(entry_sphereRefinement_selectedCentreZ), ""); - gtk_entry_set_text(GTK_ENTRY(entry_sphereRefinement_selectedRadius), ""); + GtkWidget* comboboxentry_sphereRefinement_createdSpheres = + (GtkWidget*)g_object_get_data + ( + G_OBJECT(sphereRefinementFramePtr), + "comboboxentry_sphereRefinement_createdSpheres" + ); + GtkWidget* entry_sphereRefinement_selectedCellSize = + (GtkWidget*)g_object_get_data + ( + G_OBJECT(sphereRefinementFramePtr), + "entry_sphereRefinement_selectedCellSize" + ); + GtkWidget* entry_sphereRefinement_selectedCentreX = + (GtkWidget*)g_object_get_data + ( + G_OBJECT(sphereRefinementFramePtr), + "entry_sphereRefinement_selectedCentreX" + ); + GtkWidget* entry_sphereRefinement_selectedCentreY = + (GtkWidget*)g_object_get_data + ( + G_OBJECT(sphereRefinementFramePtr), + "entry_sphereRefinement_selectedCentreY" + ); + GtkWidget* entry_sphereRefinement_selectedCentreZ = + (GtkWidget*)g_object_get_data + ( + G_OBJECT(sphereRefinementFramePtr), + "entry_sphereRefinement_selectedCentreZ" + ); + GtkWidget* entry_sphereRefinement_selectedRadius = + (GtkWidget*)g_object_get_data + ( + G_OBJECT(sphereRefinementFramePtr), + "entry_sphereRefinement_selectedRadius" + ); + + //- find the object in the dictionary + const word sphereName = + gtk_entry_get_text + ( + GTK_ENTRY + ( + GTK_COMBO(comboboxentry_sphereRefinement_createdSpheres)->entry + ) + ); + + const PtrList<entry> refs = guiPtr->objectRefinements(); + + forAll(refs, refI) + if( refs[refI].keyword() == sphereName ) + { + const dictionary dict = refs[refI].dict(); + + gtk_entry_set_text + ( + GTK_ENTRY(entry_sphereRefinement_selectedCellSize), + help::scalarToText + ( + scalar(readScalar(dict.lookup("cellSize"))) + ).c_str() + ); + const vector centre(dict.lookup("centre")); + gtk_entry_set_text + ( + GTK_ENTRY(entry_sphereRefinement_selectedCentreX), + help::scalarToText(centre.x()).c_str() + ); + gtk_entry_set_text + ( + GTK_ENTRY(entry_sphereRefinement_selectedCentreY), + help::scalarToText(centre.y()).c_str() + ); + gtk_entry_set_text + ( + GTK_ENTRY(entry_sphereRefinement_selectedCentreZ), + help::scalarToText(centre.z()).c_str() + ); + + const scalar radius(readScalar(dict.lookup("radius"))); + gtk_entry_set_text + ( + GTK_ENTRY(entry_sphereRefinement_selectedRadius), + help::scalarToText(radius).c_str() + ); + + return; + } + + gtk_entry_set_text(GTK_ENTRY(entry_sphereRefinement_selectedCellSize), ""); + gtk_entry_set_text(GTK_ENTRY(entry_sphereRefinement_selectedCentreX), ""); + gtk_entry_set_text(GTK_ENTRY(entry_sphereRefinement_selectedCentreY), ""); + gtk_entry_set_text(GTK_ENTRY(entry_sphereRefinement_selectedCentreZ), ""); + gtk_entry_set_text(GTK_ENTRY(entry_sphereRefinement_selectedRadius), ""); } static void resetValuesForSelectedLine ( - GtkWidget* widget, - GtkWidget* sphereRefinementFramePtr + GtkWidget* widget, + GtkWidget* sphereRefinementFramePtr ) { - GtkWidget* comboboxentry_sphereRefinement_createdSpheres = - (GtkWidget*)g_object_get_data - ( - G_OBJECT(sphereRefinementFramePtr), - "comboboxentry_sphereRefinement_createdSpheres" - ); - GtkWidget* entry_sphereRefinement_selectedCellSize = - (GtkWidget*)g_object_get_data - ( - G_OBJECT(sphereRefinementFramePtr), - "entry_sphereRefinement_selectedCellSize" - ); - GtkWidget* entry_sphereRefinement_selectedCentreX = - (GtkWidget*)g_object_get_data - ( - G_OBJECT(sphereRefinementFramePtr), - "entry_sphereRefinement_selectedCentreX" - ); - GtkWidget* entry_sphereRefinement_selectedCentreY = - (GtkWidget*)g_object_get_data - ( - G_OBJECT(sphereRefinementFramePtr), - "entry_sphereRefinement_selectedCentreY" - ); - GtkWidget* entry_sphereRefinement_selectedCentreZ = - (GtkWidget*)g_object_get_data - ( - G_OBJECT(sphereRefinementFramePtr), - "entry_sphereRefinement_selectedCentreZ" - ); - GtkWidget* entry_sphereRefinement_selectedRadius = - (GtkWidget*)g_object_get_data - ( - G_OBJECT(sphereRefinementFramePtr), - "entry_sphereRefinement_selectedRadius" - ); - - const word name = - gtk_entry_get_text - ( - GTK_ENTRY - ( - GTK_COMBO - ( - comboboxentry_sphereRefinement_createdSpheres - )->entry - ) - ); - - if( name == "" ) - return; - - const PtrList<entry> refs = guiPtr->objectRefinements(); - dictionary dict; - forAll(refs, refI) - if( refs[refI].keyword() == name ) - dict = refs[refI].dict(); - guiPtr->removeObjectRefinement(name); - if( widget == entry_sphereRefinement_selectedCellSize ) - { - const word size = - gtk_entry_get_text(GTK_ENTRY(entry_sphereRefinement_selectedCellSize)); - dict.remove("cellSize"); - dict.add("cellSize", help::textToScalar(size)); - } - else if( widget == entry_sphereRefinement_selectedCentreX ) - { - point centre(dict.lookup("centre")); - const word c = - gtk_entry_get_text(GTK_ENTRY(entry_sphereRefinement_selectedCentreX)); - dict.remove("centre"); - centre.x() = help::textToScalar(c); - dict.add("centre", centre); - } - else if( widget == entry_sphereRefinement_selectedCentreY ) - { - point centre(dict.lookup("centre")); - const word c = - gtk_entry_get_text(GTK_ENTRY(entry_sphereRefinement_selectedCentreY)); - dict.remove("centre"); - centre.y() = help::textToScalar(c); - dict.add("centre", centre); - } - else if( widget == entry_sphereRefinement_selectedCentreZ ) - { - point centre(dict.lookup("centre")); - const word c = - gtk_entry_get_text(GTK_ENTRY(entry_sphereRefinement_selectedCentreZ)); - dict.remove("centre"); - centre.z() = help::textToScalar(c); - dict.add("centre", centre); - } - else if( widget == entry_sphereRefinement_selectedRadius ) - { - const word l = - gtk_entry_get_text(GTK_ENTRY(entry_sphereRefinement_selectedRadius)); - dict.remove("radius"); - scalar radius = help::textToScalar(l); - dict.add("radius", radius); - } - - sphereRefinement sr(name, dict); - guiPtr->addObjectRefinement(sr); + GtkWidget* comboboxentry_sphereRefinement_createdSpheres = + (GtkWidget*)g_object_get_data + ( + G_OBJECT(sphereRefinementFramePtr), + "comboboxentry_sphereRefinement_createdSpheres" + ); + GtkWidget* entry_sphereRefinement_selectedCellSize = + (GtkWidget*)g_object_get_data + ( + G_OBJECT(sphereRefinementFramePtr), + "entry_sphereRefinement_selectedCellSize" + ); + GtkWidget* entry_sphereRefinement_selectedCentreX = + (GtkWidget*)g_object_get_data + ( + G_OBJECT(sphereRefinementFramePtr), + "entry_sphereRefinement_selectedCentreX" + ); + GtkWidget* entry_sphereRefinement_selectedCentreY = + (GtkWidget*)g_object_get_data + ( + G_OBJECT(sphereRefinementFramePtr), + "entry_sphereRefinement_selectedCentreY" + ); + GtkWidget* entry_sphereRefinement_selectedCentreZ = + (GtkWidget*)g_object_get_data + ( + G_OBJECT(sphereRefinementFramePtr), + "entry_sphereRefinement_selectedCentreZ" + ); + GtkWidget* entry_sphereRefinement_selectedRadius = + (GtkWidget*)g_object_get_data + ( + G_OBJECT(sphereRefinementFramePtr), + "entry_sphereRefinement_selectedRadius" + ); + + const word name = + gtk_entry_get_text + ( + GTK_ENTRY + ( + GTK_COMBO + ( + comboboxentry_sphereRefinement_createdSpheres + )->entry + ) + ); + + if( name == "" ) + return; + + const PtrList<entry> refs = guiPtr->objectRefinements(); + dictionary dict; + forAll(refs, refI) + if( refs[refI].keyword() == name ) + dict = refs[refI].dict(); + guiPtr->removeObjectRefinement(name); + if( widget == entry_sphereRefinement_selectedCellSize ) + { + const word size = + gtk_entry_get_text(GTK_ENTRY(entry_sphereRefinement_selectedCellSize)); + dict.remove("cellSize"); + dict.add("cellSize", help::textToScalar(size)); + } + else if( widget == entry_sphereRefinement_selectedCentreX ) + { + point centre(dict.lookup("centre")); + const word c = + gtk_entry_get_text(GTK_ENTRY(entry_sphereRefinement_selectedCentreX)); + dict.remove("centre"); + centre.x() = help::textToScalar(c); + dict.add("centre", centre); + } + else if( widget == entry_sphereRefinement_selectedCentreY ) + { + point centre(dict.lookup("centre")); + const word c = + gtk_entry_get_text(GTK_ENTRY(entry_sphereRefinement_selectedCentreY)); + dict.remove("centre"); + centre.y() = help::textToScalar(c); + dict.add("centre", centre); + } + else if( widget == entry_sphereRefinement_selectedCentreZ ) + { + point centre(dict.lookup("centre")); + const word c = + gtk_entry_get_text(GTK_ENTRY(entry_sphereRefinement_selectedCentreZ)); + dict.remove("centre"); + centre.z() = help::textToScalar(c); + dict.add("centre", centre); + } + else if( widget == entry_sphereRefinement_selectedRadius ) + { + const word l = + gtk_entry_get_text(GTK_ENTRY(entry_sphereRefinement_selectedRadius)); + dict.remove("radius"); + scalar radius = help::textToScalar(l); + dict.add("radius", radius); + } + + sphereRefinement sr(name, dict); + guiPtr->addObjectRefinement(sr); } static void updateSphereRefinements(GtkWidget* sphereRefinementFramePtr) { - GtkWidget* comboboxentry_sphereRefinement_createdSpheres = - (GtkWidget*)g_object_get_data - ( - G_OBJECT(sphereRefinementFramePtr), - "comboboxentry_sphereRefinement_createdSpheres" - ); - - const PtrList<entry> refs = guiPtr->objectRefinements(); - label nSpheres(0); - GList* createdSpheres = 0; - forAll(refs, refI) - { - const word& key = refs[refI].keyword(); - const dictionary& dict = refs[refI].dict(); - const word type(dict.lookup("type")); - - if( type == "sphere" ) - { - ++nSpheres; - sphereRefinement sphere(key, dict); - createdSpheres = - g_list_append - ( - createdSpheres, - const_cast<char*>(sphere.name().c_str()) - ); - } - } - - gtk_combo_set_popdown_strings - ( - GTK_COMBO - ( - comboboxentry_sphereRefinement_createdSpheres - ), createdSpheres - ); - - if( nSpheres == 0 ) - { - gtk_entry_set_text - ( - GTK_ENTRY - ( - GTK_COMBO(comboboxentry_sphereRefinement_createdSpheres)->entry - ), - "" - ); - } - - g_list_free(createdSpheres); - - showDataForSphereRefinement(NULL, sphereRefinementFramePtr); + GtkWidget* comboboxentry_sphereRefinement_createdSpheres = + (GtkWidget*)g_object_get_data + ( + G_OBJECT(sphereRefinementFramePtr), + "comboboxentry_sphereRefinement_createdSpheres" + ); + + const PtrList<entry> refs = guiPtr->objectRefinements(); + label nSpheres(0); + GList* createdSpheres = 0; + forAll(refs, refI) + { + const word& key = refs[refI].keyword(); + const dictionary& dict = refs[refI].dict(); + const word type(dict.lookup("type")); + + if( type == "sphere" ) + { + ++nSpheres; + sphereRefinement sphere(key, dict); + createdSpheres = + g_list_append + ( + createdSpheres, + const_cast<char*>(sphere.name().c_str()) + ); + } + } + + gtk_combo_set_popdown_strings + ( + GTK_COMBO + ( + comboboxentry_sphereRefinement_createdSpheres + ), createdSpheres + ); + + if( nSpheres == 0 ) + { + gtk_entry_set_text + ( + GTK_ENTRY + ( + GTK_COMBO(comboboxentry_sphereRefinement_createdSpheres)->entry + ), + "" + ); + } + + g_list_free(createdSpheres); + + showDataForSphereRefinement(NULL, sphereRefinementFramePtr); } static void addSphereRefinement ( - GtkWidget* button, - GtkWidget* sphereRefinementFramePtr + GtkWidget* button, + GtkWidget* sphereRefinementFramePtr ) { - GtkWidget* name = - (GtkWidget*)g_object_get_data - ( - G_OBJECT(sphereRefinementFramePtr), - "entry_sphereName" - ); - GtkWidget* cellSize = - (GtkWidget*)g_object_get_data - ( - G_OBJECT(sphereRefinementFramePtr), - "entry_sphereRefinement_cellSize" - ); - GtkWidget* centreX = - (GtkWidget*)g_object_get_data - ( - G_OBJECT(sphereRefinementFramePtr), - "entry_sphereRefinement_centreX" - ); - GtkWidget* centreY = - (GtkWidget*)g_object_get_data - ( - G_OBJECT(sphereRefinementFramePtr), - "entry_sphereRefinement_centreY" - ); - GtkWidget* centreZ = - (GtkWidget*)g_object_get_data - ( - G_OBJECT(sphereRefinementFramePtr), - "entry_sphereRefinement_centreZ" - ); - GtkWidget* radius = - (GtkWidget*)g_object_get_data - ( - G_OBJECT(sphereRefinementFramePtr), - "entry_sphereRefinement_radius" - ); - - //- create all necessary settings - const word sphereName = gtk_entry_get_text(GTK_ENTRY(name)); - gtk_entry_set_text(GTK_ENTRY(name), ""); - const scalar sphereCellSize = - help::textToScalar(gtk_entry_get_text(GTK_ENTRY(cellSize))); - gtk_entry_set_text(GTK_ENTRY(cellSize), ""); - point centre, p1; - centre.x() = help::textToScalar(gtk_entry_get_text(GTK_ENTRY(centreX))); - gtk_entry_set_text(GTK_ENTRY(centreX), ""); - centre.y() = help::textToScalar(gtk_entry_get_text(GTK_ENTRY(centreY))); - gtk_entry_set_text(GTK_ENTRY(centreY), ""); - centre.z() = help::textToScalar(gtk_entry_get_text(GTK_ENTRY(centreZ))); - gtk_entry_set_text(GTK_ENTRY(centreZ), ""); - const scalar selectedRadius = - help::textToScalar(gtk_entry_get_text(GTK_ENTRY(radius))); - gtk_entry_set_text(GTK_ENTRY(radius), ""); - - sphereRefinement sphere - ( - sphereName, - sphereCellSize, - centre, - selectedRadius - ); - - guiPtr->addObjectRefinement(sphere); - - updateSphereRefinements(sphereRefinementFramePtr); + GtkWidget* name = + (GtkWidget*)g_object_get_data + ( + G_OBJECT(sphereRefinementFramePtr), + "entry_sphereName" + ); + GtkWidget* cellSize = + (GtkWidget*)g_object_get_data + ( + G_OBJECT(sphereRefinementFramePtr), + "entry_sphereRefinement_cellSize" + ); + GtkWidget* centreX = + (GtkWidget*)g_object_get_data + ( + G_OBJECT(sphereRefinementFramePtr), + "entry_sphereRefinement_centreX" + ); + GtkWidget* centreY = + (GtkWidget*)g_object_get_data + ( + G_OBJECT(sphereRefinementFramePtr), + "entry_sphereRefinement_centreY" + ); + GtkWidget* centreZ = + (GtkWidget*)g_object_get_data + ( + G_OBJECT(sphereRefinementFramePtr), + "entry_sphereRefinement_centreZ" + ); + GtkWidget* radius = + (GtkWidget*)g_object_get_data + ( + G_OBJECT(sphereRefinementFramePtr), + "entry_sphereRefinement_radius" + ); + + //- create all necessary settings + const word sphereName = gtk_entry_get_text(GTK_ENTRY(name)); + gtk_entry_set_text(GTK_ENTRY(name), ""); + const scalar sphereCellSize = + help::textToScalar(gtk_entry_get_text(GTK_ENTRY(cellSize))); + gtk_entry_set_text(GTK_ENTRY(cellSize), ""); + point centre, p1; + centre.x() = help::textToScalar(gtk_entry_get_text(GTK_ENTRY(centreX))); + gtk_entry_set_text(GTK_ENTRY(centreX), ""); + centre.y() = help::textToScalar(gtk_entry_get_text(GTK_ENTRY(centreY))); + gtk_entry_set_text(GTK_ENTRY(centreY), ""); + centre.z() = help::textToScalar(gtk_entry_get_text(GTK_ENTRY(centreZ))); + gtk_entry_set_text(GTK_ENTRY(centreZ), ""); + const scalar selectedRadius = + help::textToScalar(gtk_entry_get_text(GTK_ENTRY(radius))); + gtk_entry_set_text(GTK_ENTRY(radius), ""); + + sphereRefinement sphere + ( + sphereName, + sphereCellSize, + centre, + selectedRadius + ); + + guiPtr->addObjectRefinement(sphere); + + updateSphereRefinements(sphereRefinementFramePtr); } static void removeSphereRefinement ( - GtkWidget* button, - GtkWidget* sphereRefinementFramePtr + GtkWidget* button, + GtkWidget* sphereRefinementFramePtr ) { - GtkWidget* createdSpheres = - (GtkWidget*)g_object_get_data - ( - G_OBJECT(sphereRefinementFramePtr), - "comboboxentry_sphereRefinement_createdSpheres" - ); - - const word sphereName = - gtk_entry_get_text - ( - GTK_ENTRY - ( - GTK_COMBO(createdSpheres)->entry - ) - ); + GtkWidget* createdSpheres = + (GtkWidget*)g_object_get_data + ( + G_OBJECT(sphereRefinementFramePtr), + "comboboxentry_sphereRefinement_createdSpheres" + ); + + const word sphereName = + gtk_entry_get_text + ( + GTK_ENTRY + ( + GTK_COMBO(createdSpheres)->entry + ) + ); - guiPtr->removeObjectRefinement(sphereName); + guiPtr->removeObjectRefinement(sphereName); - updateSphereRefinements(sphereRefinementFramePtr); + updateSphereRefinements(sphereRefinementFramePtr); } } void meshGenGTK::createSphereRefinementWindowPage() { - guiPtr = &meshGui_; - - sphereRefinementFramePtr_ = gtk_frame_new(NULL); + guiPtr = &meshGui_; + + sphereRefinementFramePtr_ = gtk_frame_new(NULL); // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - //- create a table - GtkWidget* table1 = gtk_table_new(5, 11, FALSE); - gtk_widget_show(table1); - gtk_container_add - ( - GTK_CONTAINER(sphereRefinementFramePtr_), - table1 - ); + //- create a table + GtkWidget* table1 = gtk_table_new(5, 11, FALSE); + gtk_widget_show(table1); + gtk_container_add + ( + GTK_CONTAINER(sphereRefinementFramePtr_), + table1 + ); // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - //- create a label for sphere name - GtkWidget* label_sphereName = gtk_label_new("Sphere name"); - gtk_widget_show(label_sphereName); - gtk_table_attach(GTK_TABLE(table1), label_sphereName, 0, 1, 0, 1, + //- create a label for sphere name + GtkWidget* label_sphereName = gtk_label_new("Sphere name"); + gtk_widget_show(label_sphereName); + gtk_table_attach(GTK_TABLE(table1), label_sphereName, 0, 1, 0, 1, (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0); - gtk_misc_set_alignment(GTK_MISC(label_sphereName), 0, 0.5); - + gtk_misc_set_alignment(GTK_MISC(label_sphereName), 0, 0.5); + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - //- create an entry for box name - GtkWidget* entry_sphereName = gtk_entry_new(); - gtk_widget_show(entry_sphereName); - - gtk_table_attach(GTK_TABLE(table1), entry_sphereName, 1, 4, 0, 1, - (GtkAttachOptions)(GTK_FILL), + //- create an entry for box name + GtkWidget* entry_sphereName = gtk_entry_new(); + gtk_widget_show(entry_sphereName); + + gtk_table_attach(GTK_TABLE(table1), entry_sphereName, 1, 4, 0, 1, + (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0); - + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - //- create a label for desired cell size - GtkWidget* label_sphereRefinement_cellSize = gtk_label_new("Cell size [m]"); - gtk_widget_show(label_sphereRefinement_cellSize); - gtk_table_attach(GTK_TABLE(table1), label_sphereRefinement_cellSize, - 0, 1, 1, 2, - (GtkAttachOptions)(GTK_FILL), + //- create a label for desired cell size + GtkWidget* label_sphereRefinement_cellSize = gtk_label_new("Cell size [m]"); + gtk_widget_show(label_sphereRefinement_cellSize); + gtk_table_attach(GTK_TABLE(table1), label_sphereRefinement_cellSize, + 0, 1, 1, 2, + (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0); - gtk_misc_set_alignment(GTK_MISC(label_sphereRefinement_cellSize), 0, 0.5); - + gtk_misc_set_alignment(GTK_MISC(label_sphereRefinement_cellSize), 0, 0.5); + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - //- create a label for desired cell size - GtkWidget* entry_sphereRefinement_cellSize = gtk_entry_new(); - gtk_widget_show(entry_sphereRefinement_cellSize); - gtk_table_attach(GTK_TABLE(table1), entry_sphereRefinement_cellSize, - 1, 4, 1, 2, - (GtkAttachOptions)(GTK_FILL), + //- create a label for desired cell size + GtkWidget* entry_sphereRefinement_cellSize = gtk_entry_new(); + gtk_widget_show(entry_sphereRefinement_cellSize); + gtk_table_attach(GTK_TABLE(table1), entry_sphereRefinement_cellSize, + 1, 4, 1, 2, + (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0); - + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - //- create labels for axes - GtkWidget* label_axes = gtk_label_new("X"); - gtk_widget_show(label_axes); - gtk_table_attach(GTK_TABLE(table1), label_axes, - 1, 2, 2, 3, - (GtkAttachOptions)(GTK_FILL), + //- create labels for axes + GtkWidget* label_axes = gtk_label_new("X"); + gtk_widget_show(label_axes); + gtk_table_attach(GTK_TABLE(table1), label_axes, + 1, 2, 2, 3, + (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0); - gtk_misc_set_alignment(GTK_MISC(label_axes), 0, 0.5); - - label_axes = gtk_label_new("Y"); - gtk_widget_show(label_axes); - gtk_table_attach(GTK_TABLE(table1), label_axes, - 2, 3, 2, 3, - (GtkAttachOptions)(GTK_FILL), + gtk_misc_set_alignment(GTK_MISC(label_axes), 0, 0.5); + + label_axes = gtk_label_new("Y"); + gtk_widget_show(label_axes); + gtk_table_attach(GTK_TABLE(table1), label_axes, + 2, 3, 2, 3, + (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0); - gtk_misc_set_alignment(GTK_MISC(label_axes), 0, 0.5); - - label_axes = gtk_label_new("Z"); - gtk_widget_show(label_axes); - gtk_table_attach(GTK_TABLE(table1), label_axes, - 3, 4, 2, 3, - (GtkAttachOptions)(GTK_FILL), + gtk_misc_set_alignment(GTK_MISC(label_axes), 0, 0.5); + + label_axes = gtk_label_new("Z"); + gtk_widget_show(label_axes); + gtk_table_attach(GTK_TABLE(table1), label_axes, + 3, 4, 2, 3, + (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0); - gtk_misc_set_alignment(GTK_MISC(label_axes), 0, 0.5); - + gtk_misc_set_alignment(GTK_MISC(label_axes), 0, 0.5); + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - //- label for centre - GtkWidget* label_sphereRefinement_centre = gtk_label_new("Centre"); - gtk_widget_show(label_sphereRefinement_centre); - gtk_table_attach(GTK_TABLE(table1), label_sphereRefinement_centre, - 0, 1, 3, 4, - (GtkAttachOptions)(GTK_FILL), + //- label for centre + GtkWidget* label_sphereRefinement_centre = gtk_label_new("Centre"); + gtk_widget_show(label_sphereRefinement_centre); + gtk_table_attach(GTK_TABLE(table1), label_sphereRefinement_centre, + 0, 1, 3, 4, + (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0); - gtk_misc_set_alignment(GTK_MISC(label_sphereRefinement_centre), 0, 0.5); + gtk_misc_set_alignment(GTK_MISC(label_sphereRefinement_centre), 0, 0.5); // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - //- entries for centre - GtkWidget* entry_sphereRefinement_centreX = gtk_entry_new(); - gtk_widget_show(entry_sphereRefinement_centreX); - gtk_table_attach(GTK_TABLE(table1), entry_sphereRefinement_centreX, - 1, 2, 3, 4, - (GtkAttachOptions)(GTK_FILL), + //- entries for centre + GtkWidget* entry_sphereRefinement_centreX = gtk_entry_new(); + gtk_widget_show(entry_sphereRefinement_centreX); + gtk_table_attach(GTK_TABLE(table1), entry_sphereRefinement_centreX, + 1, 2, 3, 4, + (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0); - - GtkWidget* entry_sphereRefinement_centreY = gtk_entry_new(); - gtk_widget_show(entry_sphereRefinement_centreY); - gtk_table_attach(GTK_TABLE(table1), entry_sphereRefinement_centreY, - 2, 3, 3, 4, - (GtkAttachOptions)(GTK_FILL), + + GtkWidget* entry_sphereRefinement_centreY = gtk_entry_new(); + gtk_widget_show(entry_sphereRefinement_centreY); + gtk_table_attach(GTK_TABLE(table1), entry_sphereRefinement_centreY, + 2, 3, 3, 4, + (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0); - - GtkWidget* entry_sphereRefinement_centreZ = gtk_entry_new(); - gtk_widget_show(entry_sphereRefinement_centreZ); - gtk_table_attach(GTK_TABLE(table1), entry_sphereRefinement_centreZ, - 3, 4, 3, 4, - (GtkAttachOptions)(GTK_FILL), + + GtkWidget* entry_sphereRefinement_centreZ = gtk_entry_new(); + gtk_widget_show(entry_sphereRefinement_centreZ); + gtk_table_attach(GTK_TABLE(table1), entry_sphereRefinement_centreZ, + 3, 4, 3, 4, + (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0); - + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - //- label for radius - GtkWidget* label_sphereRefinement_p1 = gtk_label_new("Radius [m]"); - gtk_widget_show(label_sphereRefinement_p1); - gtk_table_attach(GTK_TABLE(table1), label_sphereRefinement_p1, - 0, 1, 4, 5, - (GtkAttachOptions)(GTK_FILL), + //- label for radius + GtkWidget* label_sphereRefinement_p1 = gtk_label_new("Radius [m]"); + gtk_widget_show(label_sphereRefinement_p1); + gtk_table_attach(GTK_TABLE(table1), label_sphereRefinement_p1, + 0, 1, 4, 5, + (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0); - gtk_misc_set_alignment(GTK_MISC(label_sphereRefinement_p1), 0, 0.5); + gtk_misc_set_alignment(GTK_MISC(label_sphereRefinement_p1), 0, 0.5); // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - //- entry for radius - GtkWidget* entry_sphereRefinement_radius = gtk_entry_new(); - gtk_widget_show(entry_sphereRefinement_radius); - gtk_table_attach(GTK_TABLE(table1), entry_sphereRefinement_radius, - 1, 4, 4, 5, - (GtkAttachOptions)(GTK_FILL), + //- entry for radius + GtkWidget* entry_sphereRefinement_radius = gtk_entry_new(); + gtk_widget_show(entry_sphereRefinement_radius); + gtk_table_attach(GTK_TABLE(table1), entry_sphereRefinement_radius, + 1, 4, 4, 5, + (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0); - + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - //- set the button for adding lines - GtkWidget* button1 = gtk_button_new(); - gtk_widget_show(button1); - gtk_table_attach - ( - GTK_TABLE(table1), - button1, - 4, 5, 0, 5, - (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 5 - ); - - g_signal_connect - ( - G_OBJECT(button1), - "clicked", - G_CALLBACK(addSphereRefinement), - sphereRefinementFramePtr_ - ); + //- set the button for adding lines + GtkWidget* button1 = gtk_button_new(); + gtk_widget_show(button1); + gtk_table_attach + ( + GTK_TABLE(table1), + button1, + 4, 5, 0, 5, + (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 5 + ); + + g_signal_connect + ( + G_OBJECT(button1), + "clicked", + G_CALLBACK(addSphereRefinement), + sphereRefinementFramePtr_ + ); - GtkWidget* alignment1 = gtk_alignment_new(0.5, 0.5, 0, 0); - gtk_widget_show(alignment1); - gtk_container_add(GTK_CONTAINER(button1), alignment1); - - GtkWidget* hbox1 = gtk_hbox_new(FALSE, 2); - gtk_widget_show(hbox1); - gtk_container_add(GTK_CONTAINER(alignment1), hbox1); - - GtkWidget* image1 = - gtk_image_new_from_stock("gtk-add", GTK_ICON_SIZE_BUTTON); - gtk_widget_show(image1); - gtk_box_pack_start(GTK_BOX(hbox1), image1, FALSE, FALSE, 0); - - GtkWidget* label3 = gtk_label_new_with_mnemonic("Add"); - gtk_widget_show(label3); - gtk_box_pack_start(GTK_BOX(hbox1), label3, FALSE, FALSE, 0); - + GtkWidget* alignment1 = gtk_alignment_new(0.5, 0.5, 0, 0); + gtk_widget_show(alignment1); + gtk_container_add(GTK_CONTAINER(button1), alignment1); + + GtkWidget* hbox1 = gtk_hbox_new(FALSE, 2); + gtk_widget_show(hbox1); + gtk_container_add(GTK_CONTAINER(alignment1), hbox1); + + GtkWidget* image1 = + gtk_image_new_from_stock("gtk-add", GTK_ICON_SIZE_BUTTON); + gtk_widget_show(image1); + gtk_box_pack_start(GTK_BOX(hbox1), image1, FALSE, FALSE, 0); + + GtkWidget* label3 = gtk_label_new_with_mnemonic("Add"); + gtk_widget_show(label3); + gtk_box_pack_start(GTK_BOX(hbox1), label3, FALSE, FALSE, 0); + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - //- horizontal separator - GtkWidget* hseparator0 = gtk_hseparator_new(); - gtk_widget_show(hseparator0); - gtk_table_attach(GTK_TABLE(table1), hseparator0, 0, 5, 5, 6, + //- horizontal separator + GtkWidget* hseparator0 = gtk_hseparator_new(); + gtk_widget_show(hseparator0); + gtk_table_attach(GTK_TABLE(table1), hseparator0, 0, 5, 5, 6, (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(GTK_EXPAND | GTK_SHRINK | GTK_FILL), - 0, 0); + 0, 0); // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - //- label for existing line objects - GtkWidget* label_sphereRefinement_existing = - gtk_label_new("Existing spheres"); - gtk_widget_show(label_sphereRefinement_existing); - gtk_table_attach(GTK_TABLE(table1), label_sphereRefinement_existing, - 0, 1, 6, 7, - (GtkAttachOptions)(GTK_FILL), + //- label for existing line objects + GtkWidget* label_sphereRefinement_existing = + gtk_label_new("Existing spheres"); + gtk_widget_show(label_sphereRefinement_existing); + gtk_table_attach(GTK_TABLE(table1), label_sphereRefinement_existing, + 0, 1, 6, 7, + (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0); - + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - //- combobox for existing box objects - GtkWidget* comboboxentry_sphereRefinement_createdSpheres = - gtk_combo_new(); - gtk_widget_show(comboboxentry_sphereRefinement_createdSpheres); - gtk_table_attach - ( - GTK_TABLE(table1),comboboxentry_sphereRefinement_createdSpheres, - 1, 2, 6, 7, - (GtkAttachOptions)(GTK_FILL), - (GtkAttachOptions)(0), 0, 0 - ); - - gtk_editable_set_editable - ( - GTK_EDITABLE - ( - GTK_COMBO(comboboxentry_sphereRefinement_createdSpheres)->entry - ), - 0 - ); - - + //- combobox for existing box objects + GtkWidget* comboboxentry_sphereRefinement_createdSpheres = + gtk_combo_new(); + gtk_widget_show(comboboxentry_sphereRefinement_createdSpheres); + gtk_table_attach + ( + GTK_TABLE(table1),comboboxentry_sphereRefinement_createdSpheres, + 1, 2, 6, 7, + (GtkAttachOptions)(GTK_FILL), + (GtkAttachOptions)(0), 0, 0 + ); + + gtk_editable_set_editable + ( + GTK_EDITABLE + ( + GTK_COMBO(comboboxentry_sphereRefinement_createdSpheres)->entry + ), + 0 + ); + + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - //- create a label for selected cell size - GtkWidget* label_sphereRefinement_selectedCellSize = - gtk_label_new("Cell size [m]"); - gtk_widget_show(label_sphereRefinement_selectedCellSize); - gtk_table_attach(GTK_TABLE(table1), label_sphereRefinement_selectedCellSize, - 0, 1, 7, 8, - (GtkAttachOptions)(GTK_FILL), + //- create a label for selected cell size + GtkWidget* label_sphereRefinement_selectedCellSize = + gtk_label_new("Cell size [m]"); + gtk_widget_show(label_sphereRefinement_selectedCellSize); + gtk_table_attach(GTK_TABLE(table1), label_sphereRefinement_selectedCellSize, + 0, 1, 7, 8, + (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0); - gtk_misc_set_alignment - ( - GTK_MISC(label_sphereRefinement_selectedCellSize), 0, 0.5 - ); - + gtk_misc_set_alignment + ( + GTK_MISC(label_sphereRefinement_selectedCellSize), 0, 0.5 + ); + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - //- create a label for selected cell size - GtkWidget* entry_sphereRefinement_selectedCellSize = gtk_entry_new(); - gtk_widget_show(entry_sphereRefinement_selectedCellSize); - gtk_table_attach(GTK_TABLE(table1), entry_sphereRefinement_selectedCellSize, - 1, 4, 7, 8, - (GtkAttachOptions)(GTK_FILL), + //- create a label for selected cell size + GtkWidget* entry_sphereRefinement_selectedCellSize = gtk_entry_new(); + gtk_widget_show(entry_sphereRefinement_selectedCellSize); + gtk_table_attach(GTK_TABLE(table1), entry_sphereRefinement_selectedCellSize, + 1, 4, 7, 8, + (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0); - + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - //- create labels for axes - label_axes = gtk_label_new("X"); - gtk_widget_show(label_axes); - gtk_table_attach(GTK_TABLE(table1), label_axes, - 1, 2, 8, 9, - (GtkAttachOptions)(GTK_FILL), + //- create labels for axes + label_axes = gtk_label_new("X"); + gtk_widget_show(label_axes); + gtk_table_attach(GTK_TABLE(table1), label_axes, + 1, 2, 8, 9, + (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0); - gtk_misc_set_alignment(GTK_MISC(label_axes), 0, 0.5); - - label_axes = gtk_label_new("Y"); - gtk_widget_show(label_axes); - gtk_table_attach(GTK_TABLE(table1), label_axes, - 2, 3, 8, 9, - (GtkAttachOptions)(GTK_FILL), + gtk_misc_set_alignment(GTK_MISC(label_axes), 0, 0.5); + + label_axes = gtk_label_new("Y"); + gtk_widget_show(label_axes); + gtk_table_attach(GTK_TABLE(table1), label_axes, + 2, 3, 8, 9, + (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0); - gtk_misc_set_alignment(GTK_MISC(label_axes), 0, 0.5); - - label_axes = gtk_label_new("Z"); - gtk_widget_show(label_axes); - gtk_table_attach(GTK_TABLE(table1), label_axes, - 3, 4, 8, 9, - (GtkAttachOptions)(GTK_FILL), + gtk_misc_set_alignment(GTK_MISC(label_axes), 0, 0.5); + + label_axes = gtk_label_new("Z"); + gtk_widget_show(label_axes); + gtk_table_attach(GTK_TABLE(table1), label_axes, + 3, 4, 8, 9, + (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0); - gtk_misc_set_alignment(GTK_MISC(label_axes), 0, 0.5); - + gtk_misc_set_alignment(GTK_MISC(label_axes), 0, 0.5); + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - //- label for centre - GtkWidget* label_sphereRefinement_selectedCentre = - gtk_label_new("Centre"); - gtk_widget_show(label_sphereRefinement_selectedCentre); - gtk_table_attach(GTK_TABLE(table1), label_sphereRefinement_selectedCentre, - 0, 1, 9, 10, - (GtkAttachOptions)(GTK_FILL), + //- label for centre + GtkWidget* label_sphereRefinement_selectedCentre = + gtk_label_new("Centre"); + gtk_widget_show(label_sphereRefinement_selectedCentre); + gtk_table_attach(GTK_TABLE(table1), label_sphereRefinement_selectedCentre, + 0, 1, 9, 10, + (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0); - gtk_misc_set_alignment(GTK_MISC(label_sphereRefinement_selectedCentre), 0, 0.5); + gtk_misc_set_alignment(GTK_MISC(label_sphereRefinement_selectedCentre), 0, 0.5); // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - //- entries for selected centre - GtkWidget* entry_sphereRefinement_selectedCentreX = gtk_entry_new(); - gtk_widget_show(entry_sphereRefinement_selectedCentreX); - gtk_table_attach(GTK_TABLE(table1), entry_sphereRefinement_selectedCentreX, - 1, 2, 9, 10, - (GtkAttachOptions)(GTK_FILL), + //- entries for selected centre + GtkWidget* entry_sphereRefinement_selectedCentreX = gtk_entry_new(); + gtk_widget_show(entry_sphereRefinement_selectedCentreX); + gtk_table_attach(GTK_TABLE(table1), entry_sphereRefinement_selectedCentreX, + 1, 2, 9, 10, + (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0); - - GtkWidget* entry_sphereRefinement_selectedCentreY = gtk_entry_new(); - gtk_widget_show(entry_sphereRefinement_selectedCentreY); - gtk_table_attach(GTK_TABLE(table1), entry_sphereRefinement_selectedCentreY, - 2, 3, 9, 10, - (GtkAttachOptions)(GTK_FILL), + + GtkWidget* entry_sphereRefinement_selectedCentreY = gtk_entry_new(); + gtk_widget_show(entry_sphereRefinement_selectedCentreY); + gtk_table_attach(GTK_TABLE(table1), entry_sphereRefinement_selectedCentreY, + 2, 3, 9, 10, + (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0); - - GtkWidget* entry_sphereRefinement_selectedCentreZ = gtk_entry_new(); - gtk_widget_show(entry_sphereRefinement_selectedCentreZ); - gtk_table_attach(GTK_TABLE(table1), entry_sphereRefinement_selectedCentreZ, - 3, 4, 9, 10, - (GtkAttachOptions)(GTK_FILL), + + GtkWidget* entry_sphereRefinement_selectedCentreZ = gtk_entry_new(); + gtk_widget_show(entry_sphereRefinement_selectedCentreZ); + gtk_table_attach(GTK_TABLE(table1), entry_sphereRefinement_selectedCentreZ, + 3, 4, 9, 10, + (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0); - + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - //- label for selected radius - GtkWidget* label_sphereRefinement_selectedRadius = - gtk_label_new("Radius [m]"); - gtk_widget_show(label_sphereRefinement_selectedRadius); - gtk_table_attach(GTK_TABLE(table1), label_sphereRefinement_selectedRadius, - 0, 1, 10, 11, - (GtkAttachOptions)(GTK_FILL), + //- label for selected radius + GtkWidget* label_sphereRefinement_selectedRadius = + gtk_label_new("Radius [m]"); + gtk_widget_show(label_sphereRefinement_selectedRadius); + gtk_table_attach(GTK_TABLE(table1), label_sphereRefinement_selectedRadius, + 0, 1, 10, 11, + (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0); - gtk_misc_set_alignment - ( - GTK_MISC(label_sphereRefinement_selectedRadius), 0, 0.5 - ); + gtk_misc_set_alignment + ( + GTK_MISC(label_sphereRefinement_selectedRadius), 0, 0.5 + ); // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - //- entries for radius - GtkWidget* entry_sphereRefinement_selectedRadius = gtk_entry_new(); - gtk_widget_show(entry_sphereRefinement_selectedRadius); - gtk_table_attach(GTK_TABLE(table1), entry_sphereRefinement_selectedRadius, - 1, 4, 10, 11, - (GtkAttachOptions)(GTK_FILL), + //- entries for radius + GtkWidget* entry_sphereRefinement_selectedRadius = gtk_entry_new(); + gtk_widget_show(entry_sphereRefinement_selectedRadius); + gtk_table_attach(GTK_TABLE(table1), entry_sphereRefinement_selectedRadius, + 1, 4, 10, 11, + (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0); - + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - //- set the button for removing patches - GtkWidget* button2 = gtk_button_new(); - gtk_widget_show(button2); - gtk_table_attach - ( - GTK_TABLE(table1), - button2, - 4, 5, 6, 11, - (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 5 - ); - - g_signal_connect - ( - G_OBJECT(button2), - "clicked", - G_CALLBACK(removeSphereRefinement), - sphereRefinementFramePtr_ - ); - - GtkWidget* alignment2 = gtk_alignment_new(0.5, 0.5, 0, 0); - gtk_widget_show(alignment2); - gtk_container_add(GTK_CONTAINER(button2), alignment2); - - GtkWidget* hbox2 = gtk_hbox_new(FALSE, 2); - gtk_widget_show(hbox2); - gtk_container_add(GTK_CONTAINER(alignment2), hbox2); - - GtkWidget* image2 = - gtk_image_new_from_stock("gtk-remove", GTK_ICON_SIZE_BUTTON); - gtk_widget_show(image2); - gtk_box_pack_start(GTK_BOX (hbox2), image2, FALSE, FALSE, 0); - - GtkWidget* label5 = gtk_label_new_with_mnemonic("Remove"); - gtk_widget_show(label5); - gtk_box_pack_start(GTK_BOX (hbox2), label5, FALSE, FALSE, 0); - + //- set the button for removing patches + GtkWidget* button2 = gtk_button_new(); + gtk_widget_show(button2); + gtk_table_attach + ( + GTK_TABLE(table1), + button2, + 4, 5, 6, 11, + (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 5 + ); + + g_signal_connect + ( + G_OBJECT(button2), + "clicked", + G_CALLBACK(removeSphereRefinement), + sphereRefinementFramePtr_ + ); + + GtkWidget* alignment2 = gtk_alignment_new(0.5, 0.5, 0, 0); + gtk_widget_show(alignment2); + gtk_container_add(GTK_CONTAINER(button2), alignment2); + + GtkWidget* hbox2 = gtk_hbox_new(FALSE, 2); + gtk_widget_show(hbox2); + gtk_container_add(GTK_CONTAINER(alignment2), hbox2); + + GtkWidget* image2 = + gtk_image_new_from_stock("gtk-remove", GTK_ICON_SIZE_BUTTON); + gtk_widget_show(image2); + gtk_box_pack_start(GTK_BOX (hbox2), image2, FALSE, FALSE, 0); + + GtkWidget* label5 = gtk_label_new_with_mnemonic("Remove"); + gtk_widget_show(label5); + gtk_box_pack_start(GTK_BOX (hbox2), label5, FALSE, FALSE, 0); + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - /* Store pointers to all widgets, for use by lookup_widget(). */ - GLADE_HOOKUP_OBJECT_NO_REF - ( - sphereRefinementFramePtr_, - sphereRefinementFramePtr_, - "sphereRefinementFramePtr_"); - GLADE_HOOKUP_OBJECT - ( - sphereRefinementFramePtr_, - table1, - "table1" - ); - GLADE_HOOKUP_OBJECT - ( - sphereRefinementFramePtr_, - entry_sphereName, - "entry_sphereName" - ); - GLADE_HOOKUP_OBJECT - ( - sphereRefinementFramePtr_, - entry_sphereRefinement_cellSize, - "entry_sphereRefinement_cellSize" - ); - GLADE_HOOKUP_OBJECT - ( - sphereRefinementFramePtr_, - entry_sphereRefinement_centreX, - "entry_sphereRefinement_centreX" - ); - GLADE_HOOKUP_OBJECT - ( - sphereRefinementFramePtr_, - entry_sphereRefinement_centreY, - "entry_sphereRefinement_centreY" - ); - GLADE_HOOKUP_OBJECT - ( - sphereRefinementFramePtr_, - entry_sphereRefinement_centreZ, - "entry_sphereRefinement_centreZ" - ); - GLADE_HOOKUP_OBJECT - ( - sphereRefinementFramePtr_, - entry_sphereRefinement_radius, - "entry_sphereRefinement_radius" - ); - GLADE_HOOKUP_OBJECT - ( - sphereRefinementFramePtr_, - comboboxentry_sphereRefinement_createdSpheres, - "comboboxentry_sphereRefinement_createdSpheres" - ); - GLADE_HOOKUP_OBJECT - ( - sphereRefinementFramePtr_, - entry_sphereRefinement_selectedCellSize, - "entry_sphereRefinement_selectedCellSize" - ); - GLADE_HOOKUP_OBJECT - ( - sphereRefinementFramePtr_, - entry_sphereRefinement_selectedCentreX, - "entry_sphereRefinement_selectedCentreX" - ); - GLADE_HOOKUP_OBJECT - ( - sphereRefinementFramePtr_, - entry_sphereRefinement_selectedCentreY, - "entry_sphereRefinement_selectedCentreY" - ); - GLADE_HOOKUP_OBJECT - ( - sphereRefinementFramePtr_, - entry_sphereRefinement_selectedCentreZ, - "entry_sphereRefinement_selectedCentreZ" - ); - GLADE_HOOKUP_OBJECT - ( - sphereRefinementFramePtr_, - entry_sphereRefinement_selectedRadius, - "entry_sphereRefinement_selectedRadius" - ); - - updateSphereRefinements(sphereRefinementFramePtr_); - - g_signal_connect - ( - G_OBJECT - ( - GTK_ENTRY - ( - GTK_COMBO(comboboxentry_sphereRefinement_createdSpheres)->entry - ) - ), - "changed", - G_CALLBACK(showDataForSphereRefinement), - sphereRefinementFramePtr_ - ); - - g_signal_connect - ( - G_OBJECT(entry_sphereRefinement_selectedCellSize), - "changed", - G_CALLBACK(resetValuesForSelectedLine), - sphereRefinementFramePtr_ - ); - - g_signal_connect - ( - G_OBJECT(entry_sphereRefinement_selectedCentreX), - "changed", - G_CALLBACK(resetValuesForSelectedLine), - sphereRefinementFramePtr_ - ); - - g_signal_connect - ( - G_OBJECT(entry_sphereRefinement_selectedCentreY), - "changed", - G_CALLBACK(resetValuesForSelectedLine), - sphereRefinementFramePtr_ - ); - - g_signal_connect - ( - G_OBJECT(entry_sphereRefinement_selectedCentreZ), - "changed", - G_CALLBACK(resetValuesForSelectedLine), - sphereRefinementFramePtr_ - ); - - g_signal_connect - ( - G_OBJECT(entry_sphereRefinement_selectedRadius), - "changed", - G_CALLBACK(resetValuesForSelectedLine), - sphereRefinementFramePtr_ - ); - - gtk_widget_show(sphereRefinementFramePtr_); + /* Store pointers to all widgets, for use by lookup_widget(). */ + GLADE_HOOKUP_OBJECT_NO_REF + ( + sphereRefinementFramePtr_, + sphereRefinementFramePtr_, + "sphereRefinementFramePtr_"); + GLADE_HOOKUP_OBJECT + ( + sphereRefinementFramePtr_, + table1, + "table1" + ); + GLADE_HOOKUP_OBJECT + ( + sphereRefinementFramePtr_, + entry_sphereName, + "entry_sphereName" + ); + GLADE_HOOKUP_OBJECT + ( + sphereRefinementFramePtr_, + entry_sphereRefinement_cellSize, + "entry_sphereRefinement_cellSize" + ); + GLADE_HOOKUP_OBJECT + ( + sphereRefinementFramePtr_, + entry_sphereRefinement_centreX, + "entry_sphereRefinement_centreX" + ); + GLADE_HOOKUP_OBJECT + ( + sphereRefinementFramePtr_, + entry_sphereRefinement_centreY, + "entry_sphereRefinement_centreY" + ); + GLADE_HOOKUP_OBJECT + ( + sphereRefinementFramePtr_, + entry_sphereRefinement_centreZ, + "entry_sphereRefinement_centreZ" + ); + GLADE_HOOKUP_OBJECT + ( + sphereRefinementFramePtr_, + entry_sphereRefinement_radius, + "entry_sphereRefinement_radius" + ); + GLADE_HOOKUP_OBJECT + ( + sphereRefinementFramePtr_, + comboboxentry_sphereRefinement_createdSpheres, + "comboboxentry_sphereRefinement_createdSpheres" + ); + GLADE_HOOKUP_OBJECT + ( + sphereRefinementFramePtr_, + entry_sphereRefinement_selectedCellSize, + "entry_sphereRefinement_selectedCellSize" + ); + GLADE_HOOKUP_OBJECT + ( + sphereRefinementFramePtr_, + entry_sphereRefinement_selectedCentreX, + "entry_sphereRefinement_selectedCentreX" + ); + GLADE_HOOKUP_OBJECT + ( + sphereRefinementFramePtr_, + entry_sphereRefinement_selectedCentreY, + "entry_sphereRefinement_selectedCentreY" + ); + GLADE_HOOKUP_OBJECT + ( + sphereRefinementFramePtr_, + entry_sphereRefinement_selectedCentreZ, + "entry_sphereRefinement_selectedCentreZ" + ); + GLADE_HOOKUP_OBJECT + ( + sphereRefinementFramePtr_, + entry_sphereRefinement_selectedRadius, + "entry_sphereRefinement_selectedRadius" + ); + + updateSphereRefinements(sphereRefinementFramePtr_); + + g_signal_connect + ( + G_OBJECT + ( + GTK_ENTRY + ( + GTK_COMBO(comboboxentry_sphereRefinement_createdSpheres)->entry + ) + ), + "changed", + G_CALLBACK(showDataForSphereRefinement), + sphereRefinementFramePtr_ + ); + + g_signal_connect + ( + G_OBJECT(entry_sphereRefinement_selectedCellSize), + "changed", + G_CALLBACK(resetValuesForSelectedLine), + sphereRefinementFramePtr_ + ); + + g_signal_connect + ( + G_OBJECT(entry_sphereRefinement_selectedCentreX), + "changed", + G_CALLBACK(resetValuesForSelectedLine), + sphereRefinementFramePtr_ + ); + + g_signal_connect + ( + G_OBJECT(entry_sphereRefinement_selectedCentreY), + "changed", + G_CALLBACK(resetValuesForSelectedLine), + sphereRefinementFramePtr_ + ); + + g_signal_connect + ( + G_OBJECT(entry_sphereRefinement_selectedCentreZ), + "changed", + G_CALLBACK(resetValuesForSelectedLine), + sphereRefinementFramePtr_ + ); + + g_signal_connect + ( + G_OBJECT(entry_sphereRefinement_selectedRadius), + "changed", + G_CALLBACK(resetValuesForSelectedLine), + sphereRefinementFramePtr_ + ); + + gtk_widget_show(sphereRefinementFramePtr_); } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/GUI/meshGenGUI/meshGenGUI.C b/GUI/meshGenGUI/meshGenGUI.C index ec4a697e..4530ed2b 100644 --- a/GUI/meshGenGUI/meshGenGUI.C +++ b/GUI/meshGenGUI/meshGenGUI.C @@ -40,15 +40,15 @@ namespace Foam void meshGenGUI::createSurface(const fileName& name) const { - surfacePtr_ = new triSurface(name); + surfacePtr_ = new triSurface(name); } const triSurface& meshGenGUI::surface() const { - if( !surfacePtr_ ) - createSurface(surfaceFileName()); - - return *surfacePtr_; + if( !surfacePtr_ ) + createSurface(surfaceFileName()); + + return *surfacePtr_; } // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // @@ -59,9 +59,9 @@ meshGenGUI::meshGenGUI const objectRegistry& reg ) : - meshDict_ - ( - IOobject + meshDict_ + ( + IOobject ( "meshDict", reg.time().system(), @@ -70,9 +70,9 @@ meshGenGUI::meshGenGUI IOobject::AUTO_WRITE ) ), - surfacePtr_(NULL) + surfacePtr_(NULL) { - Info << meshDict_ << endl; + Info << meshDict_ << endl; } // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // diff --git a/GUI/meshGenGUI/meshGenGUI.H b/GUI/meshGenGUI/meshGenGUI.H index 4c6e8b10..7d4b1005 100644 --- a/GUI/meshGenGUI/meshGenGUI.H +++ b/GUI/meshGenGUI/meshGenGUI.H @@ -45,7 +45,7 @@ SourceFiles namespace Foam { - + class triSurface; /*---------------------------------------------------------------------------*\ @@ -58,13 +58,13 @@ class meshGenGUI //- IOdictionary containing information about cell sizes, etc.. IOdictionary meshDict_; - - //- pointer to the triangulated surface - mutable triSurface* surfacePtr_; - - // Private member functions - //- create surface from fileName - void createSurface(const fileName&) const; + + //- pointer to the triangulated surface + mutable triSurface* surfacePtr_; + + // Private member functions + //- create surface from fileName + void createSurface(const fileName&) const; //- Disallow default bitwise copy construct meshGenGUI(const meshGenGUI&); @@ -85,100 +85,100 @@ public: // Member Functions - //- return surface - const triSurface& surface() const; - - // General meshDict settings - - //- set and get surface file name - void setSurfaceFileName(const fileName&); - fileName surfaceFileName() const; - - //- set and get max cell size - void setMaxCellSize(const scalar s); - scalar maxCellSize() const; - - //- set and get boundary cell size - bool boundaryCellSizeEntryExist() const; - void removeBoundaryCellSize(); - void setBoundaryCellSize(const scalar s); - scalar boundaryCellSize() const; - - //- set and get cell size for automatic refinement - bool minCellSizeEntryExist() const; - void removeMinCellSize(); - void setMinCellSize(const scalar s); - scalar minCellSize() const; - - //- set and get if boundary cells should be used - bool keepCellsIntersectingBoundaryEntryExist() const; - void setKeepCellsIntersectingBoundary(); - void removeKeepCellsIntersectingBoundary(); - bool keepCellsIntersectingBoundary() const; - - //- set and get the check for glued mesh should be used - bool checkForGluedMeshEntryExist() const; - void setCheckForGluedMesh(); - void removeCheckForGluedMesh(); - bool checkForGluedMesh() const; - - // Settings for patch-wise refinement - //- set and get patch refinement - bool patchCellSizeEntryExist() const; - void addPatchCellSize(const patchRefinement&); - void removePatchCellSize(const word&); - List<patchRefinement> patchCellSize() const; - - // Settings for keep cells intersecting patches - //- set end get keep cells intersecting patches - bool keepCellsIntersectingPatchesEntryExist() const; - void addKeepCellsIntersectingPatches(const word&); - void removeKeepCellsIntersectingPatches(const word&); - wordList keepCellsIntersectingPatches() const; - - // Settings for patch-wise boundary layers - //- set and get patches for which the layers should be created - bool bndLayersEntryExist() const; - void addBndLayersPatches(const word&); - void removeBndLayersPatches(const word&); - wordList keepBndLayersPatches() const; - - // Settings for subset-wise refinement - //- set and get functions for face-subset refinement - void setSubsetFileName(const fileName&); - fileName subsetFileName() const; - bool subsetCellSizeEntryExist() const; - void addSubsetCellSize(const patchRefinement&); - void removeSubsetCellSize(const word&); - List<patchRefinement> subsetCellSize() const; - - // object refinement - //- general object refinement stuff - bool objectRefinementEntryExist() const; - PtrList<entry> objectRefinements() const; - void addObjectRefinement(const objectRefinement&); - void removeObjectRefinement(const word& name); - - // rename boundaries - bool renameBoundaryEntryExist() const; - bool defaultPatchNameEntryExist() const; - word defaultPatchName() const; - void setDefaultPatchName(const word&); - void removeDefaultPatchName(); - bool defaultPatchTypeEntryExist() const; - word defaultPatchType() const; - void setDefaultPatchType(const word&); - void removeDefaultPatchType(); - bool newPatchNamesEntryExist() const; - PtrList<entry> newPatchNames() const; - void addNewPatchName(const word&, const dictionary&); - void removePatchName(const word&); - - // write the dictionary + //- return surface + const triSurface& surface() const; + + // General meshDict settings + + //- set and get surface file name + void setSurfaceFileName(const fileName&); + fileName surfaceFileName() const; + + //- set and get max cell size + void setMaxCellSize(const scalar s); + scalar maxCellSize() const; + + //- set and get boundary cell size + bool boundaryCellSizeEntryExist() const; + void removeBoundaryCellSize(); + void setBoundaryCellSize(const scalar s); + scalar boundaryCellSize() const; + + //- set and get cell size for automatic refinement + bool minCellSizeEntryExist() const; + void removeMinCellSize(); + void setMinCellSize(const scalar s); + scalar minCellSize() const; + + //- set and get if boundary cells should be used + bool keepCellsIntersectingBoundaryEntryExist() const; + void setKeepCellsIntersectingBoundary(); + void removeKeepCellsIntersectingBoundary(); + bool keepCellsIntersectingBoundary() const; + + //- set and get the check for glued mesh should be used + bool checkForGluedMeshEntryExist() const; + void setCheckForGluedMesh(); + void removeCheckForGluedMesh(); + bool checkForGluedMesh() const; + + // Settings for patch-wise refinement + //- set and get patch refinement + bool patchCellSizeEntryExist() const; + void addPatchCellSize(const patchRefinement&); + void removePatchCellSize(const word&); + List<patchRefinement> patchCellSize() const; + + // Settings for keep cells intersecting patches + //- set end get keep cells intersecting patches + bool keepCellsIntersectingPatchesEntryExist() const; + void addKeepCellsIntersectingPatches(const word&); + void removeKeepCellsIntersectingPatches(const word&); + wordList keepCellsIntersectingPatches() const; + + // Settings for patch-wise boundary layers + //- set and get patches for which the layers should be created + bool bndLayersEntryExist() const; + void addBndLayersPatches(const word&); + void removeBndLayersPatches(const word&); + wordList keepBndLayersPatches() const; + + // Settings for subset-wise refinement + //- set and get functions for face-subset refinement + void setSubsetFileName(const fileName&); + fileName subsetFileName() const; + bool subsetCellSizeEntryExist() const; + void addSubsetCellSize(const patchRefinement&); + void removeSubsetCellSize(const word&); + List<patchRefinement> subsetCellSize() const; + + // object refinement + //- general object refinement stuff + bool objectRefinementEntryExist() const; + PtrList<entry> objectRefinements() const; + void addObjectRefinement(const objectRefinement&); + void removeObjectRefinement(const word& name); + + // rename boundaries + bool renameBoundaryEntryExist() const; + bool defaultPatchNameEntryExist() const; + word defaultPatchName() const; + void setDefaultPatchName(const word&); + void removeDefaultPatchName(); + bool defaultPatchTypeEntryExist() const; + word defaultPatchType() const; + void setDefaultPatchType(const word&); + void removeDefaultPatchType(); + bool newPatchNamesEntryExist() const; + PtrList<entry> newPatchNames() const; + void addNewPatchName(const word&, const dictionary&); + void removePatchName(const word&); + + // write the dictionary void writeDict() const - { - meshDict_.regIOobject::write(); - } + { + meshDict_.regIOobject::write(); + } }; diff --git a/GUI/meshGenGUI/meshGenGUIBndLayers.C b/GUI/meshGenGUI/meshGenGUIBndLayers.C index 01f407e2..1ebb03a8 100644 --- a/GUI/meshGenGUI/meshGenGUIBndLayers.C +++ b/GUI/meshGenGUI/meshGenGUIBndLayers.C @@ -37,62 +37,62 @@ namespace Foam bool meshGenGUI::bndLayersEntryExist() const { - return meshDict_.found("boundaryLayers"); + return meshDict_.found("boundaryLayers"); } void meshGenGUI::addBndLayersPatches(const word& pName) { - if( bndLayersEntryExist() ) - { - wordList pList(meshDict_.lookup("boundaryLayers")); - - const label size = pList.size(); - pList.setSize(size + 1); - pList[size] = pName; - - meshDict_.remove("boundaryLayers"); - meshDict_.add("boundaryLayers", pList); - } - else - { - wordList pList(1); - pList[0] = pName; - - meshDict_.add("boundaryLayers", pList); - } + if( bndLayersEntryExist() ) + { + wordList pList(meshDict_.lookup("boundaryLayers")); + + const label size = pList.size(); + pList.setSize(size + 1); + pList[size] = pName; + + meshDict_.remove("boundaryLayers"); + meshDict_.add("boundaryLayers", pList); + } + else + { + wordList pList(1); + pList[0] = pName; + + meshDict_.add("boundaryLayers", pList); + } } void meshGenGUI::removeBndLayersPatches(const word& pName) { - if( bndLayersEntryExist() ) - { - wordList pList(meshDict_.lookup("boundaryLayers")); - - label pos(-1); - forAll(pList, elI) - if( pList[elI] == pName ) - { - pos = elI; - break; - } - - pList[pos] = pList[pList.size() - 1]; - pList.setSize(pList.size() - 1); - - meshDict_.remove("boundaryLayers"); - - if( pList.size() != 0 ) - meshDict_.add("boundaryLayers", pList); - } + if( bndLayersEntryExist() ) + { + wordList pList(meshDict_.lookup("boundaryLayers")); + + label pos(-1); + forAll(pList, elI) + if( pList[elI] == pName ) + { + pos = elI; + break; + } + + pList[pos] = pList[pList.size() - 1]; + pList.setSize(pList.size() - 1); + + meshDict_.remove("boundaryLayers"); + + if( pList.size() != 0 ) + meshDict_.add("boundaryLayers", pList); + } } wordList meshGenGUI::keepBndLayersPatches() const { - if( !bndLayersEntryExist() ) - return wordList(); - - wordList pNames(meshDict_.lookup("boundaryLayers")); - return pNames; + if( !bndLayersEntryExist() ) + return wordList(); + + wordList pNames(meshDict_.lookup("boundaryLayers")); + return pNames; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/GUI/meshGenGUI/meshGenGUIGeneral.C b/GUI/meshGenGUI/meshGenGUIGeneral.C index 2f7f517e..b35bf017 100644 --- a/GUI/meshGenGUI/meshGenGUIGeneral.C +++ b/GUI/meshGenGUI/meshGenGUIGeneral.C @@ -37,136 +37,136 @@ namespace Foam void meshGenGUI::setSurfaceFileName(const fileName& fName) { - if( meshDict_.found("surfaceFile") ) - meshDict_.remove("surfaceFile"); - - meshDict_.add("surfaceFile", fName); + if( meshDict_.found("surfaceFile") ) + meshDict_.remove("surfaceFile"); + + meshDict_.add("surfaceFile", fName); } fileName meshGenGUI::surfaceFileName() const { - if( !meshDict_.found("surfaceFile") ) - { - fileName f(""); - const_cast<IOdictionary&>(meshDict_).add("surfaceFile", f); - } - - return meshDict_.lookup("surfaceFile"); + if( !meshDict_.found("surfaceFile") ) + { + fileName f(""); + const_cast<IOdictionary&>(meshDict_).add("surfaceFile", f); + } + + return meshDict_.lookup("surfaceFile"); } void meshGenGUI::setMaxCellSize(const scalar s) { - if( meshDict_.found("maxCellSize") ) - meshDict_.remove("maxCellSize"); - - meshDict_.add("maxCellSize", s); + if( meshDict_.found("maxCellSize") ) + meshDict_.remove("maxCellSize"); + + meshDict_.add("maxCellSize", s); } scalar meshGenGUI::maxCellSize() const { - if( !meshDict_.found("maxCellSize") ) - const_cast<IOdictionary&>(meshDict_).add("maxCellSize", 1.0); - - return readScalar(meshDict_.lookup("maxCellSize")); + if( !meshDict_.found("maxCellSize") ) + const_cast<IOdictionary&>(meshDict_).add("maxCellSize", 1.0); + + return readScalar(meshDict_.lookup("maxCellSize")); } - + bool meshGenGUI::boundaryCellSizeEntryExist() const { - word w("boundaryCellSize"); - return meshDict_.found(w); + word w("boundaryCellSize"); + return meshDict_.found(w); } void meshGenGUI::removeBoundaryCellSize() { - meshDict_.remove("boundaryCellSize"); + meshDict_.remove("boundaryCellSize"); } void meshGenGUI::setBoundaryCellSize(const scalar s) { - if( boundaryCellSizeEntryExist() ) - meshDict_.remove("boundaryCellSize"); - - meshDict_.add("boundaryCellSize", s); + if( boundaryCellSizeEntryExist() ) + meshDict_.remove("boundaryCellSize"); + + meshDict_.add("boundaryCellSize", s); } scalar meshGenGUI::boundaryCellSize() const { - return readScalar(meshDict_.lookup("boundaryCellSize")); + return readScalar(meshDict_.lookup("boundaryCellSize")); } - + bool meshGenGUI::minCellSizeEntryExist() const { - return meshDict_.found("minCellSize"); + return meshDict_.found("minCellSize"); } void meshGenGUI::removeMinCellSize() { - if( minCellSizeEntryExist() ) - meshDict_.remove("minCellSize"); + if( minCellSizeEntryExist() ) + meshDict_.remove("minCellSize"); } void meshGenGUI::setMinCellSize(const scalar s) { - removeMinCellSize(); - - meshDict_.add("minCellSize", s); + removeMinCellSize(); + + meshDict_.add("minCellSize", s); } scalar meshGenGUI::minCellSize() const { - return readScalar(meshDict_.lookup("minCellSize")); + return readScalar(meshDict_.lookup("minCellSize")); } - + bool meshGenGUI::keepCellsIntersectingBoundaryEntryExist() const { - return meshDict_.found("keepCellsIntersectingBoundary"); + return meshDict_.found("keepCellsIntersectingBoundary"); } void meshGenGUI::setKeepCellsIntersectingBoundary() { - removeKeepCellsIntersectingBoundary(); - - meshDict_.add("keepCellsIntersectingBoundary", 1); + removeKeepCellsIntersectingBoundary(); + + meshDict_.add("keepCellsIntersectingBoundary", 1); } void meshGenGUI::removeKeepCellsIntersectingBoundary() { - if( keepCellsIntersectingBoundaryEntryExist() ) - meshDict_.remove("keepCellsIntersectingBoundary"); + if( keepCellsIntersectingBoundaryEntryExist() ) + meshDict_.remove("keepCellsIntersectingBoundary"); } bool meshGenGUI::keepCellsIntersectingBoundary() const { - if( !keepCellsIntersectingBoundaryEntryExist() ) - return false; - - return meshDict_.lookup("keepCellsIntersectingBoundary"); + if( !keepCellsIntersectingBoundaryEntryExist() ) + return false; + + return meshDict_.lookup("keepCellsIntersectingBoundary"); } - + bool meshGenGUI::checkForGluedMeshEntryExist() const { - return meshDict_.found("checkForGluedMesh"); + return meshDict_.found("checkForGluedMesh"); } void meshGenGUI::setCheckForGluedMesh() { - removeCheckForGluedMesh(); - - meshDict_.add("checkForGluedMesh", 1); + removeCheckForGluedMesh(); + + meshDict_.add("checkForGluedMesh", 1); } void meshGenGUI::removeCheckForGluedMesh() { - if( checkForGluedMeshEntryExist() ) - meshDict_.remove("checkForGluedMesh"); + if( checkForGluedMeshEntryExist() ) + meshDict_.remove("checkForGluedMesh"); } bool meshGenGUI::checkForGluedMesh() const { - if( !checkForGluedMeshEntryExist() ) - return false; - - return readBool(meshDict_.lookup("checkForGluedMesh")); + if( !checkForGluedMeshEntryExist() ) + return false; + + return readBool(meshDict_.lookup("checkForGluedMesh")); } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/GUI/meshGenGUI/meshGenGUIKeepCellsIntersectingPatches.C b/GUI/meshGenGUI/meshGenGUIKeepCellsIntersectingPatches.C index 881a125b..6379bf7d 100644 --- a/GUI/meshGenGUI/meshGenGUIKeepCellsIntersectingPatches.C +++ b/GUI/meshGenGUI/meshGenGUIKeepCellsIntersectingPatches.C @@ -37,62 +37,62 @@ namespace Foam bool meshGenGUI::keepCellsIntersectingPatchesEntryExist() const { - return meshDict_.found("keepCellsIntersectingPatches"); + return meshDict_.found("keepCellsIntersectingPatches"); } void meshGenGUI::addKeepCellsIntersectingPatches(const word& pName) { - if( keepCellsIntersectingPatchesEntryExist() ) - { - wordList pList(meshDict_.lookup("keepCellsIntersectingPatches")); - - const label size = pList.size(); - pList.setSize(size + 1); - pList[size] = pName; - - meshDict_.remove("keepCellsIntersectingPatches"); - meshDict_.add("keepCellsIntersectingPatches", pList); - } - else - { - wordList pList(1); - pList[0] = pName; - - meshDict_.add("keepCellsIntersectingPatches", pList); - } + if( keepCellsIntersectingPatchesEntryExist() ) + { + wordList pList(meshDict_.lookup("keepCellsIntersectingPatches")); + + const label size = pList.size(); + pList.setSize(size + 1); + pList[size] = pName; + + meshDict_.remove("keepCellsIntersectingPatches"); + meshDict_.add("keepCellsIntersectingPatches", pList); + } + else + { + wordList pList(1); + pList[0] = pName; + + meshDict_.add("keepCellsIntersectingPatches", pList); + } } void meshGenGUI::removeKeepCellsIntersectingPatches(const word& pName) { - if( keepCellsIntersectingPatchesEntryExist() ) - { - wordList pList(meshDict_.lookup("keepCellsIntersectingPatches")); - - label pos(-1); - forAll(pList, elI) - if( pList[elI] == pName ) - { - pos = elI; - break; - } - - pList[pos] = pList[pList.size() - 1]; - pList.setSize(pList.size() - 1); - - meshDict_.remove("keepCellsIntersectingPatches"); - - if( pList.size() != 0 ) - meshDict_.add("keepCellsIntersectingPatches", pList); - } + if( keepCellsIntersectingPatchesEntryExist() ) + { + wordList pList(meshDict_.lookup("keepCellsIntersectingPatches")); + + label pos(-1); + forAll(pList, elI) + if( pList[elI] == pName ) + { + pos = elI; + break; + } + + pList[pos] = pList[pList.size() - 1]; + pList.setSize(pList.size() - 1); + + meshDict_.remove("keepCellsIntersectingPatches"); + + if( pList.size() != 0 ) + meshDict_.add("keepCellsIntersectingPatches", pList); + } } wordList meshGenGUI::keepCellsIntersectingPatches() const { - if( !keepCellsIntersectingPatchesEntryExist() ) - return wordList(); - - wordList pNames(meshDict_.lookup("keepCellsIntersectingPatches")); - return pNames; + if( !keepCellsIntersectingPatchesEntryExist() ) + return wordList(); + + wordList pNames(meshDict_.lookup("keepCellsIntersectingPatches")); + return pNames; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/GUI/meshGenGUI/meshGenGUIObjectRefinement.C b/GUI/meshGenGUI/meshGenGUIObjectRefinement.C index 1815faa6..7c8fa601 100644 --- a/GUI/meshGenGUI/meshGenGUIObjectRefinement.C +++ b/GUI/meshGenGUI/meshGenGUIObjectRefinement.C @@ -35,89 +35,89 @@ namespace Foam { // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - + bool meshGenGUI::objectRefinementEntryExist() const { - return meshDict_.found("objectRefinements"); + return meshDict_.found("objectRefinements"); } PtrList<entry> meshGenGUI::objectRefinements() const { - if( !objectRefinementEntryExist() ) - { - return PtrList<entry>(); - } - - // Read polyPatchList - Istream& is = meshDict_.lookup("objectRefinements"); - - PtrList<entry> objectEntries(is); + if( !objectRefinementEntryExist() ) + { + return PtrList<entry>(); + } + + // Read polyPatchList + Istream& is = meshDict_.lookup("objectRefinements"); + + PtrList<entry> objectEntries(is); return objectEntries; } void meshGenGUI::addObjectRefinement(const objectRefinement& object) { - if( objectRefinementEntryExist() ) - { - PtrList<entry> objectEntries(meshDict_.lookup("objectRefinements")); - const label s = objectEntries.size(); - - objectEntries.setSize(s+1); - objectEntries.set - ( - s, - new dictionaryEntry(object.name(), object.dict()) - ); - - meshDict_.remove("objectRefinements"); - meshDict_.add("objectRefinements", objectEntries); - } - else - { - PtrList<entry> objectEntries(1); - objectEntries.set - ( - 0, - new dictionaryEntry - ( - object.name(), - object.dict() - ) - ); - - meshDict_.add("objectRefinements", objectEntries); - } + if( objectRefinementEntryExist() ) + { + PtrList<entry> objectEntries(meshDict_.lookup("objectRefinements")); + const label s = objectEntries.size(); + + objectEntries.setSize(s+1); + objectEntries.set + ( + s, + new dictionaryEntry(object.name(), object.dict()) + ); + + meshDict_.remove("objectRefinements"); + meshDict_.add("objectRefinements", objectEntries); + } + else + { + PtrList<entry> objectEntries(1); + objectEntries.set + ( + 0, + new dictionaryEntry + ( + object.name(), + object.dict() + ) + ); + + meshDict_.add("objectRefinements", objectEntries); + } } void meshGenGUI::removeObjectRefinement(const word& name) { - if( !objectRefinementEntryExist() ) - return; - - PtrList<entry> objectEntries(meshDict_.lookup("objectRefinements")); - meshDict_.remove("objectRefinements"); - - if( objectEntries.size() == 1 ) - return; - - PtrList<entry> refs(objectEntries.size()-1); - label counter(0); - forAll(objectEntries, i) - if( objectEntries[i].keyword() != name ) - { - refs.set - ( - counter++, - new dictionaryEntry - ( - objectEntries[i].keyword(), - objectEntries[i].dict() - ) - ); - } - - meshDict_.add("objectRefinements", refs); + if( !objectRefinementEntryExist() ) + return; + + PtrList<entry> objectEntries(meshDict_.lookup("objectRefinements")); + meshDict_.remove("objectRefinements"); + + if( objectEntries.size() == 1 ) + return; + + PtrList<entry> refs(objectEntries.size()-1); + label counter(0); + forAll(objectEntries, i) + if( objectEntries[i].keyword() != name ) + { + refs.set + ( + counter++, + new dictionaryEntry + ( + objectEntries[i].keyword(), + objectEntries[i].dict() + ) + ); + } + + meshDict_.add("objectRefinements", refs); } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/GUI/meshGenGUI/meshGenGUIPatchRefinement.C b/GUI/meshGenGUI/meshGenGUIPatchRefinement.C index 24a51cb2..a4e52bc4 100644 --- a/GUI/meshGenGUI/meshGenGUIPatchRefinement.C +++ b/GUI/meshGenGUI/meshGenGUIPatchRefinement.C @@ -37,60 +37,60 @@ namespace Foam bool meshGenGUI::patchCellSizeEntryExist() const { - return meshDict_.found("patchCellSize"); + return meshDict_.found("patchCellSize"); } void meshGenGUI::addPatchCellSize(const patchRefinement& pr) { - if( patchCellSizeEntryExist() ) - { - List<patchRefinement> prList(meshDict_.lookup("patchCellSize")); - - const label size = prList.size(); - prList.setSize(size + 1); - prList[size] = pr; - - meshDict_.remove("patchCellSize"); - meshDict_.add("patchCellSize", prList); - } - else - { - List<patchRefinement> prList(1); - prList[0] = pr; - - meshDict_.add("patchCellSize", prList); - } + if( patchCellSizeEntryExist() ) + { + List<patchRefinement> prList(meshDict_.lookup("patchCellSize")); + + const label size = prList.size(); + prList.setSize(size + 1); + prList[size] = pr; + + meshDict_.remove("patchCellSize"); + meshDict_.add("patchCellSize", prList); + } + else + { + List<patchRefinement> prList(1); + prList[0] = pr; + + meshDict_.add("patchCellSize", prList); + } } void meshGenGUI::removePatchCellSize(const word& patchName) { - if( patchCellSizeEntryExist() ) - { - List<patchRefinement> prList(meshDict_.lookup("patchCellSize")); - - label pos(-1); - forAll(prList, elI) - if( prList[elI].patchName() == patchName ) - { - pos = elI; - break; - } - - prList[pos] = prList[prList.size() - 1]; - prList.setSize(prList.size() - 1); - - meshDict_.remove("patchCellSize"); - meshDict_.add("patchCellSize", prList); - } + if( patchCellSizeEntryExist() ) + { + List<patchRefinement> prList(meshDict_.lookup("patchCellSize")); + + label pos(-1); + forAll(prList, elI) + if( prList[elI].patchName() == patchName ) + { + pos = elI; + break; + } + + prList[pos] = prList[prList.size() - 1]; + prList.setSize(prList.size() - 1); + + meshDict_.remove("patchCellSize"); + meshDict_.add("patchCellSize", prList); + } } List<patchRefinement> meshGenGUI::patchCellSize() const { - if( !patchCellSizeEntryExist() ) - return List<patchRefinement>(); - - List<patchRefinement> pr(meshDict_.lookup("patchCellSize")); - return pr; + if( !patchCellSizeEntryExist() ) + return List<patchRefinement>(); + + List<patchRefinement> pr(meshDict_.lookup("patchCellSize")); + return pr; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/GUI/meshGenGUI/meshGenGUIRenameBoundary.C b/GUI/meshGenGUI/meshGenGUIRenameBoundary.C index 0e76c61a..572e95d6 100644 --- a/GUI/meshGenGUI/meshGenGUIRenameBoundary.C +++ b/GUI/meshGenGUI/meshGenGUIRenameBoundary.C @@ -38,228 +38,228 @@ namespace Foam bool meshGenGUI::renameBoundaryEntryExist() const { - if( meshDict_.found("renameBoundary") ) - return true; - - return false; + if( meshDict_.found("renameBoundary") ) + return true; + + return false; } bool meshGenGUI::defaultPatchNameEntryExist() const { - if( renameBoundaryEntryExist() ) - { - const dictionary& dict = meshDict_.subDict("renameBoundary"); - - if( dict.found("defaultName") ) - return true; - } - - return false; + if( renameBoundaryEntryExist() ) + { + const dictionary& dict = meshDict_.subDict("renameBoundary"); + + if( dict.found("defaultName") ) + return true; + } + + return false; } word meshGenGUI::defaultPatchName() const { - if( defaultPatchNameEntryExist() ) - { - const dictionary& dict = meshDict_.subDict("renameBoundary"); - const word name(dict.lookup("defaultName")); - return name; - } - - return word(); + if( defaultPatchNameEntryExist() ) + { + const dictionary& dict = meshDict_.subDict("renameBoundary"); + const word name(dict.lookup("defaultName")); + return name; + } + + return word(); } void meshGenGUI::setDefaultPatchName(const word& name) { - if( renameBoundaryEntryExist() ) - { - dictionary dict = meshDict_.subDict("renameBoundary"); - meshDict_.remove("renameBoundary"); - - if( dict.found("defaultName") ) - dict.remove("defaultName"); - - dict.add("defaultName", name); - meshDict_.add("renameBoundary", dict); - } - else - { - dictionary dict; - dict.add("defaultName", name); - meshDict_.add("renameBoundary", dict); - } + if( renameBoundaryEntryExist() ) + { + dictionary dict = meshDict_.subDict("renameBoundary"); + meshDict_.remove("renameBoundary"); + + if( dict.found("defaultName") ) + dict.remove("defaultName"); + + dict.add("defaultName", name); + meshDict_.add("renameBoundary", dict); + } + else + { + dictionary dict; + dict.add("defaultName", name); + meshDict_.add("renameBoundary", dict); + } } void meshGenGUI::removeDefaultPatchName() { - if( renameBoundaryEntryExist() ) - { - dictionary dict = meshDict_.subDict("renameBoundary"); - meshDict_.remove("renameBoundary"); - - dict.remove("defaultName"); - - if( dict.toc().size() != 0 ) - meshDict_.add("renameBoundary", dict); - } + if( renameBoundaryEntryExist() ) + { + dictionary dict = meshDict_.subDict("renameBoundary"); + meshDict_.remove("renameBoundary"); + + dict.remove("defaultName"); + + if( dict.toc().size() != 0 ) + meshDict_.add("renameBoundary", dict); + } } bool meshGenGUI::defaultPatchTypeEntryExist() const { - if( renameBoundaryEntryExist() ) - { - const dictionary& dict = meshDict_.subDict("renameBoundary"); - - if( dict.found("defaultType") ) - return true; - } - - return false; + if( renameBoundaryEntryExist() ) + { + const dictionary& dict = meshDict_.subDict("renameBoundary"); + + if( dict.found("defaultType") ) + return true; + } + + return false; } word meshGenGUI::defaultPatchType() const { - if( defaultPatchNameEntryExist() ) - { - const dictionary& dict = meshDict_.subDict("renameBoundary"); - const word type(dict.lookup("defaultType")); - return type; - } - - return word(); + if( defaultPatchNameEntryExist() ) + { + const dictionary& dict = meshDict_.subDict("renameBoundary"); + const word type(dict.lookup("defaultType")); + return type; + } + + return word(); } void meshGenGUI::setDefaultPatchType(const word& type) { - if( renameBoundaryEntryExist() ) - { - dictionary dict = meshDict_.subDict("renameBoundary"); - meshDict_.remove("renameBoundary"); - - if( dict.found("defaultType") ) - dict.remove("defaultType"); - - dict.add("defaultType", type); - meshDict_.add("renameBoundary", dict); - } - else - { - dictionary dict; - dict.add("defaultType", type); - meshDict_.add("renameBoundary", dict); - } + if( renameBoundaryEntryExist() ) + { + dictionary dict = meshDict_.subDict("renameBoundary"); + meshDict_.remove("renameBoundary"); + + if( dict.found("defaultType") ) + dict.remove("defaultType"); + + dict.add("defaultType", type); + meshDict_.add("renameBoundary", dict); + } + else + { + dictionary dict; + dict.add("defaultType", type); + meshDict_.add("renameBoundary", dict); + } } void meshGenGUI::removeDefaultPatchType() { - if( renameBoundaryEntryExist() ) - { - dictionary dict = meshDict_.subDict("renameBoundary"); - meshDict_.remove("renameBoundary"); - - dict.remove("defaultType"); - - if( dict.toc().size() != 0 ) - meshDict_.add("renameBoundary", dict); - } + if( renameBoundaryEntryExist() ) + { + dictionary dict = meshDict_.subDict("renameBoundary"); + meshDict_.remove("renameBoundary"); + + dict.remove("defaultType"); + + if( dict.toc().size() != 0 ) + meshDict_.add("renameBoundary", dict); + } } bool meshGenGUI::newPatchNamesEntryExist() const { - if( renameBoundaryEntryExist() ) - { - const dictionary& dict = meshDict_.subDict("renameBoundary"); - - if( dict.found("newPatchNames") ) - return true; - } - - return false; + if( renameBoundaryEntryExist() ) + { + const dictionary& dict = meshDict_.subDict("renameBoundary"); + + if( dict.found("newPatchNames") ) + return true; + } + + return false; } PtrList<entry> meshGenGUI::newPatchNames() const { - if( newPatchNamesEntryExist() ) - { - const dictionary& dict = meshDict_.subDict("renameBoundary"); - Istream& is = dict.lookup("newPatchNames"); + if( newPatchNamesEntryExist() ) + { + const dictionary& dict = meshDict_.subDict("renameBoundary"); + Istream& is = dict.lookup("newPatchNames"); - PtrList<entry> patchEntries(is); - return patchEntries; - } - - return PtrList<entry>(); + PtrList<entry> patchEntries(is); + return patchEntries; + } + + return PtrList<entry>(); } void meshGenGUI::addNewPatchName(const word& name, const dictionary& pDict) { - if( renameBoundaryEntryExist() ) - { - dictionary& dict = - const_cast<dictionary&>(meshDict_.subDict("renameBoundary")); - - if( dict.found("newPatchNames") ) - { - Istream& is = dict.lookup("newPatchNames"); - PtrList<entry> entries(is); - - const label s = entries.size(); - entries.setSize(s+1); - entries.set(s, new dictionaryEntry(name, pDict)); - - dict.remove("newPatchNames"); - dict.add("newPatchNames", entries); - } - else - { - PtrList<entry> entries(1); - entries.set(0, new dictionaryEntry(name, pDict)); - dict.add("newPatchNames", entries); - } - } - else - { - PtrList<entry> entries(1); - entries.set(0, new dictionaryEntry(name, pDict)); - dictionary dict; - dict.add("newPatchNames", entries); - meshDict_.add("renameBoundary", dict); - } + if( renameBoundaryEntryExist() ) + { + dictionary& dict = + const_cast<dictionary&>(meshDict_.subDict("renameBoundary")); + + if( dict.found("newPatchNames") ) + { + Istream& is = dict.lookup("newPatchNames"); + PtrList<entry> entries(is); + + const label s = entries.size(); + entries.setSize(s+1); + entries.set(s, new dictionaryEntry(name, pDict)); + + dict.remove("newPatchNames"); + dict.add("newPatchNames", entries); + } + else + { + PtrList<entry> entries(1); + entries.set(0, new dictionaryEntry(name, pDict)); + dict.add("newPatchNames", entries); + } + } + else + { + PtrList<entry> entries(1); + entries.set(0, new dictionaryEntry(name, pDict)); + dictionary dict; + dict.add("newPatchNames", entries); + meshDict_.add("renameBoundary", dict); + } } void meshGenGUI::removePatchName(const word& name) { - if( newPatchNamesEntryExist() ) - { - dictionary& dict = - const_cast<dictionary&>(meshDict_.subDict("renameBoundary")); - - Istream& is = dict.lookup("newPatchNames"); - PtrList<entry> entries(is); - - PtrList<entry> newEntries(entries.size()-1); - label counter(0); - - forAll(entries, i) - { - if( entries[i].keyword() == name ) - continue; - - newEntries.set - ( - counter++, - new dictionaryEntry(entries[i].keyword(), entries[i].dict()) - ); - } - - dict.remove("newPatchNames"); - - if( newEntries.size() != 0 ) - dict.add("newPatchNames", newEntries); - - if( dict.toc().size() == 0 ) - meshDict_.remove("renameBoundary"); - } + if( newPatchNamesEntryExist() ) + { + dictionary& dict = + const_cast<dictionary&>(meshDict_.subDict("renameBoundary")); + + Istream& is = dict.lookup("newPatchNames"); + PtrList<entry> entries(is); + + PtrList<entry> newEntries(entries.size()-1); + label counter(0); + + forAll(entries, i) + { + if( entries[i].keyword() == name ) + continue; + + newEntries.set + ( + counter++, + new dictionaryEntry(entries[i].keyword(), entries[i].dict()) + ); + } + + dict.remove("newPatchNames"); + + if( newEntries.size() != 0 ) + dict.add("newPatchNames", newEntries); + + if( dict.toc().size() == 0 ) + meshDict_.remove("renameBoundary"); + } } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/GUI/meshGenQt/meshGenQt.C b/GUI/meshGenQt/meshGenQt.C index a3f56d7d..b6f304c5 100755 --- a/GUI/meshGenQt/meshGenQt.C +++ b/GUI/meshGenQt/meshGenQt.C @@ -48,16 +48,16 @@ meshGenQt::meshGenQt label argc, char* argv[], const objectRegistry& reg ) : - QMainWindow(), - meshGui_(reg), - saveButtonPtr_(NULL), - quitButtonPtr_(NULL), - tabWidgetPtr_(NULL), - tabGeneralSettingsPtr_(NULL), - tabRefinementPtr_(NULL), - tabPatchRenamePtr_(NULL) + QMainWindow(), + meshGui_(reg), + saveButtonPtr_(NULL), + quitButtonPtr_(NULL), + tabWidgetPtr_(NULL), + tabGeneralSettingsPtr_(NULL), + tabRefinementPtr_(NULL), + tabPatchRenamePtr_(NULL) { - createMainWindow(); + createMainWindow(); } // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // @@ -70,40 +70,40 @@ meshGenQt::~meshGenQt() void meshGenQt::createMainWindow() { - QWidget* widget = new QWidget(this); - widget->setGeometry(QRect(0, 0, 600, 480)); - - //- create and add save button - saveButtonPtr_ = new QPushButton(QString("Save meshDict"), widget); - saveButtonPtr_->setGeometry(QRect(11, 11, 150, 24)); - connect - ( - saveButtonPtr_, - SIGNAL(clicked()), - this, - SLOT(saveMeshDictCallback()) - ); - - //- create and add quit button - quitButtonPtr_ = new QPushButton(QString("Quit"), widget); - quitButtonPtr_->setGeometry(QRect(160, 11, 180, 24)); - connect(quitButtonPtr_, SIGNAL(clicked()), qApp, SLOT(quit())); - - //- create the table + QWidget* widget = new QWidget(this); + widget->setGeometry(QRect(0, 0, 600, 480)); + + //- create and add save button + saveButtonPtr_ = new QPushButton(QString("Save meshDict"), widget); + saveButtonPtr_->setGeometry(QRect(11, 11, 150, 24)); + connect + ( + saveButtonPtr_, + SIGNAL(clicked()), + this, + SLOT(saveMeshDictCallback()) + ); + + //- create and add quit button + quitButtonPtr_ = new QPushButton(QString("Quit"), widget); + quitButtonPtr_->setGeometry(QRect(160, 11, 180, 24)); + connect(quitButtonPtr_, SIGNAL(clicked()), qApp, SLOT(quit())); + + //- create the table tabWidgetPtr_ = new QTabWidget(widget); - tabWidgetPtr_->setGeometry(QRect(9, 41, 580, 406)); - - tabGeneralSettingsPtr_ = new meshGenQtGeneralSettings(widget, meshGui_); - tabWidgetPtr_->addTab(tabGeneralSettingsPtr_, "General settings"); - - QWidget* tab1 = new QWidget(); - tabWidgetPtr_->addTab(tab1, "Refinement"); - - //- set the front page - this->setCentralWidget(widget); - - //- resize to the desired size - QSize size(600, 480); + tabWidgetPtr_->setGeometry(QRect(9, 41, 580, 406)); + + tabGeneralSettingsPtr_ = new meshGenQtGeneralSettings(widget, meshGui_); + tabWidgetPtr_->addTab(tabGeneralSettingsPtr_, "General settings"); + + QWidget* tab1 = new QWidget(); + tabWidgetPtr_->addTab(tab1, "Refinement"); + + //- set the front page + this->setCentralWidget(widget); + + //- resize to the desired size + QSize size(600, 480); size = size.expandedTo(this->minimumSizeHint()); this->resize(size); } diff --git a/GUI/meshGenQt/meshGenQt.H b/GUI/meshGenQt/meshGenQt.H index 95bf8a3b..2e496755 100755 --- a/GUI/meshGenQt/meshGenQt.H +++ b/GUI/meshGenQt/meshGenQt.H @@ -62,39 +62,39 @@ class meshGenQtGeneralSettings; class meshGenQt : - public QMainWindow + public QMainWindow { - Q_OBJECT - - // Private data - - //- mesh generation dictionary - meshGenGUI meshGui_; - - //- main window data - QPushButton* saveButtonPtr_; - QPushButton* quitButtonPtr_; - QTabWidget* tabWidgetPtr_; - meshGenQtGeneralSettings* tabGeneralSettingsPtr_; - QWidget* tabRefinementPtr_; - QWidget* tabPatchRenamePtr_; - + Q_OBJECT + + // Private data + + //- mesh generation dictionary + meshGenGUI meshGui_; + + //- main window data + QPushButton* saveButtonPtr_; + QPushButton* quitButtonPtr_; + QTabWidget* tabWidgetPtr_; + meshGenQtGeneralSettings* tabGeneralSettingsPtr_; + QWidget* tabRefinementPtr_; + QWidget* tabPatchRenamePtr_; + private slots: - - // Private callback functions + + // Private callback functions - //- save meshDict file - void saveMeshDictCallback() - { - meshGui_.writeDict(); - } + //- save meshDict file + void saveMeshDictCallback() + { + meshGui_.writeDict(); + } private: - - // Private member functions - - //- create main window - void createMainWindow(); + + // Private member functions + + //- create main window + void createMainWindow(); //- Disallow default bitwise copy construct meshGenQt(const meshGenQt&); diff --git a/GUI/meshGenQt/meshGenQtGeneralSettings.C b/GUI/meshGenQt/meshGenQtGeneralSettings.C index cb32df50..6320da31 100755 --- a/GUI/meshGenQt/meshGenQtGeneralSettings.C +++ b/GUI/meshGenQt/meshGenQtGeneralSettings.C @@ -47,19 +47,19 @@ meshGenQtGeneralSettings::meshGenQtGeneralSettings ::QWidget* parent, meshGenGUI& meshGui ) : - QWidget(parent), - meshGui_(meshGui), - openButtonPtr_(NULL), - surfaceFileEditPtr_(NULL), - maxCellSizeEditPtr_(NULL), - bndCellSizeCheckPtr_(NULL), - bndCellSizeEditPtr_(NULL), - autoRefineCheckPtr_(NULL), - autoRefineCellSizeEditPtr_(NULL), - keepBndCellsCheckPtr_(NULL), - gluedMeshCheckPtr_(NULL) + QWidget(parent), + meshGui_(meshGui), + openButtonPtr_(NULL), + surfaceFileEditPtr_(NULL), + maxCellSizeEditPtr_(NULL), + bndCellSizeCheckPtr_(NULL), + bndCellSizeEditPtr_(NULL), + autoRefineCheckPtr_(NULL), + autoRefineCellSizeEditPtr_(NULL), + keepBndCellsCheckPtr_(NULL), + gluedMeshCheckPtr_(NULL) { - createWindow(); + createWindow(); } // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // @@ -72,84 +72,84 @@ meshGenQtGeneralSettings::~meshGenQtGeneralSettings() void meshGenQtGeneralSettings::createWindow() { - QGridLayout* gridLayout = new QGridLayout(this); + QGridLayout* gridLayout = new QGridLayout(this); gridLayout->setSpacing(6); gridLayout->setMargin(11); - //- set surface file name + //- set surface file name QLabel* surfaceLabel = new QLabel(QString("Surface file name"), this); gridLayout->addWidget(surfaceLabel, 0, 0); surfaceFileEditPtr_ = new QLineEdit(this); - surfaceFileEditPtr_->setText(meshGui_.surfaceFileName()); + surfaceFileEditPtr_->setText(meshGui_.surfaceFileName()); gridLayout->addWidget(surfaceFileEditPtr_, 0, 1); openButtonPtr_ = new QPushButton(QString("Open"), this); - connect(openButtonPtr_, SIGNAL(clicked()), this, SLOT(openSurfaceFile())); + connect(openButtonPtr_, SIGNAL(clicked()), this, SLOT(openSurfaceFile())); gridLayout->addWidget(openButtonPtr_, 0, 3); - //- set max cell size + //- set max cell size QLabel* maxCellSize = new QLabel(QString("Max cell size [m]"), this); gridLayout->addWidget(maxCellSize, 1, 0); maxCellSizeEditPtr_ = new QLineEdit(this); - maxCellSizeEditPtr_->setText(help::scalarToText(meshGui_.maxCellSize())); + maxCellSizeEditPtr_->setText(help::scalarToText(meshGui_.maxCellSize())); gridLayout->addWidget(maxCellSizeEditPtr_, 1, 1); - - connect - ( - maxCellSizeEditPtr_, - SIGNAL(textChanged(const QString&)), - this, - SLOT(setMaxCellSize(const QString&)) - ); - - QFrame* line1 = new QFrame(this); + + connect + ( + maxCellSizeEditPtr_, + SIGNAL(textChanged(const QString&)), + this, + SLOT(setMaxCellSize(const QString&)) + ); + + QFrame* line1 = new QFrame(this); //line1->setObjectName(QString::fromUtf8("line1")); line1->setFrameShape(QFrame::HLine); line1->setFrameShadow(QFrame::Sunken); gridLayout->addMultiCellWidget(line1, 2, 2, 0, 3); - //- bnd cell size settings + //- bnd cell size settings bndCellSizeCheckPtr_ = - new QCheckBox(QString("Use different boundary cell size"), this); + new QCheckBox(QString("Use different boundary cell size"), this); gridLayout->addMultiCellWidget(bndCellSizeCheckPtr_, 3, 3, 0, 2); bndCellSizeEditPtr_ = new QLineEdit(this); - - if( meshGui_.boundaryCellSizeEntryExist() ) - { - bndCellSizeCheckPtr_->setChecked(true); - bndCellSizeEditPtr_->setText - ( - help::scalarToText(meshGui_.boundaryCellSize()) - ); - } - else - { - bndCellSizeEditPtr_->setReadOnly(true); - } - - connect - ( - bndCellSizeCheckPtr_, - SIGNAL(clicked()), - this, - SLOT(activateBndCellSize()) - ); - - connect - ( - bndCellSizeEditPtr_, - SIGNAL(textChanged(const QString&)), - this, - SLOT(setBndCellSize(const QString&)) - ); - + + if( meshGui_.boundaryCellSizeEntryExist() ) + { + bndCellSizeCheckPtr_->setChecked(true); + bndCellSizeEditPtr_->setText + ( + help::scalarToText(meshGui_.boundaryCellSize()) + ); + } + else + { + bndCellSizeEditPtr_->setReadOnly(true); + } + + connect + ( + bndCellSizeCheckPtr_, + SIGNAL(clicked()), + this, + SLOT(activateBndCellSize()) + ); + + connect + ( + bndCellSizeEditPtr_, + SIGNAL(textChanged(const QString&)), + this, + SLOT(setBndCellSize(const QString&)) + ); + gridLayout->addWidget(bndCellSizeEditPtr_, 4, 1); QLabel* bndCellSize = new QLabel(QString("Bnd cell size [m]"), this); @@ -162,96 +162,96 @@ void meshGenQtGeneralSettings::createWindow() gridLayout->addMultiCellWidget(line2, 5, 5, 0, 3); - //- auto refinement settings + //- auto refinement settings autoRefineCheckPtr_ = new QCheckBox("Use automatic refinement", this); - - connect - ( - autoRefineCheckPtr_, - SIGNAL(clicked()), - this, - SLOT(activateMinCellSize()) - ); + + connect + ( + autoRefineCheckPtr_, + SIGNAL(clicked()), + this, + SLOT(activateMinCellSize()) + ); gridLayout->addMultiCellWidget(autoRefineCheckPtr_, 6, 6, 0, 2); QLabel* minCellSize = new QLabel(QString("Min cell size [m]"), this); gridLayout->addWidget(minCellSize, 7, 0); - - autoRefineCellSizeEditPtr_ = new QLineEdit(this); - gridLayout->addWidget(autoRefineCellSizeEditPtr_, 7, 1); - - if( meshGui_.minCellSizeEntryExist() ) - { - autoRefineCheckPtr_->setChecked(true); - autoRefineCellSizeEditPtr_->setText - ( - help::scalarToText(meshGui_.minCellSize()) - ); - } - else - { - autoRefineCellSizeEditPtr_->setReadOnly(true); - } - - connect - ( - autoRefineCellSizeEditPtr_, - SIGNAL(textChanged(const QString&)), - this, - SLOT(setMinCellSize(const QString&)) - ); - - QFrame* line3 = new QFrame(this); + + autoRefineCellSizeEditPtr_ = new QLineEdit(this); + gridLayout->addWidget(autoRefineCellSizeEditPtr_, 7, 1); + + if( meshGui_.minCellSizeEntryExist() ) + { + autoRefineCheckPtr_->setChecked(true); + autoRefineCellSizeEditPtr_->setText + ( + help::scalarToText(meshGui_.minCellSize()) + ); + } + else + { + autoRefineCellSizeEditPtr_->setReadOnly(true); + } + + connect + ( + autoRefineCellSizeEditPtr_, + SIGNAL(textChanged(const QString&)), + this, + SLOT(setMinCellSize(const QString&)) + ); + + QFrame* line3 = new QFrame(this); line3->setFrameShape(QFrame::HLine); line3->setFrameShadow(QFrame::Sunken); gridLayout->addMultiCellWidget(line3, 8, 8, 0, 3); - //- keep boundary intersected cells + //- keep boundary intersected cells keepBndCellsCheckPtr_ = - new QCheckBox(QString("Keep cell intersecting boundary"), this); - - if( meshGui_.keepCellsIntersectingBoundaryEntryExist() ) - { - keepBndCellsCheckPtr_->setChecked(true); - } - else - { - keepBndCellsCheckPtr_->setChecked(false); - } - - connect - ( - keepBndCellsCheckPtr_, - SIGNAL(clicked()), - this, - SLOT(activateKeepCellsIntersectingBoundary()) - ); - + new QCheckBox(QString("Keep cell intersecting boundary"), this); + + if( meshGui_.keepCellsIntersectingBoundaryEntryExist() ) + { + keepBndCellsCheckPtr_->setChecked(true); + } + else + { + keepBndCellsCheckPtr_->setChecked(false); + } + + connect + ( + keepBndCellsCheckPtr_, + SIGNAL(clicked()), + this, + SLOT(activateKeepCellsIntersectingBoundary()) + ); + gridLayout->addMultiCellWidget(keepBndCellsCheckPtr_, 9, 9, 0, 2); - //- remove glued mesh + //- remove glued mesh gluedMeshCheckPtr_ = - new QCheckBox(QString("Remove glued mesh parts"), this); - - if( meshGui_.checkForGluedMeshEntryExist() ) - { - gluedMeshCheckPtr_->setChecked(true); - } - else - { - gluedMeshCheckPtr_->setChecked(false); - } - - connect - ( - gluedMeshCheckPtr_, - SIGNAL(clicked()), - this, - SLOT(activateCheckForGluedMesh()) - ); - + new QCheckBox(QString("Remove glued mesh parts"), this); + + if( meshGui_.checkForGluedMeshEntryExist() ) + { + gluedMeshCheckPtr_->setChecked(true); + } + else + { + gluedMeshCheckPtr_->setChecked(false); + } + + connect + ( + gluedMeshCheckPtr_, + SIGNAL(clicked()), + this, + SLOT(activateCheckForGluedMesh()) + ); + gridLayout->addMultiCellWidget(gluedMeshCheckPtr_, 10, 10, 0, 2); } @@ -260,117 +260,117 @@ void meshGenQtGeneralSettings::createWindow() void meshGenQtGeneralSettings::openSurfaceFile() { - QString fn = - QFileDialog::getOpenFileName - ( - QString::null, - "Surface files (*.ftr *.stl)", - this - ); - - if( !fn.isEmpty() ) + QString fn = + QFileDialog::getOpenFileName + ( + QString::null, + "Surface files (*.ftr *.stl)", + this + ); + + if( !fn.isEmpty() ) { - surfaceFileEditPtr_->setText(fn); - fileName fName(fn.ascii()); - meshGui_.setSurfaceFileName(fName); - } + surfaceFileEditPtr_->setText(fn); + fileName fName(fn.ascii()); + meshGui_.setSurfaceFileName(fName); + } } void meshGenQtGeneralSettings::setMaxCellSize(const QString& s) { - const word sn(s.ascii()); - - const scalar size = help::textToScalar(sn); - meshGui_.setMaxCellSize(size); + const word sn(s.ascii()); + + const scalar size = help::textToScalar(sn); + meshGui_.setMaxCellSize(size); } void meshGenQtGeneralSettings::activateBndCellSize() { - if( bndCellSizeCheckPtr_->isChecked() ) - { - bndCellSizeEditPtr_->setReadOnly(false); - } - else - { - bndCellSizeEditPtr_->setText(QString("")); - bndCellSizeEditPtr_->setReadOnly(true); - meshGui_.removeBoundaryCellSize(); - } + if( bndCellSizeCheckPtr_->isChecked() ) + { + bndCellSizeEditPtr_->setReadOnly(false); + } + else + { + bndCellSizeEditPtr_->setText(QString("")); + bndCellSizeEditPtr_->setReadOnly(true); + meshGui_.removeBoundaryCellSize(); + } } void meshGenQtGeneralSettings::setBndCellSize(const QString& s) { - if( bndCellSizeCheckPtr_->isChecked() ) - { - const word sn(s.ascii()); - - const scalar size = help::textToScalar(sn); - meshGui_.setBoundaryCellSize(size); - } + if( bndCellSizeCheckPtr_->isChecked() ) + { + const word sn(s.ascii()); + + const scalar size = help::textToScalar(sn); + meshGui_.setBoundaryCellSize(size); + } } void meshGenQtGeneralSettings::activateMinCellSize() { - if( autoRefineCheckPtr_->isChecked() ) - { - autoRefineCellSizeEditPtr_->setReadOnly(false); - } - else - { - autoRefineCellSizeEditPtr_->setText(QString("")); - autoRefineCellSizeEditPtr_->setReadOnly(true); - meshGui_.removeMinCellSize(); - } + if( autoRefineCheckPtr_->isChecked() ) + { + autoRefineCellSizeEditPtr_->setReadOnly(false); + } + else + { + autoRefineCellSizeEditPtr_->setText(QString("")); + autoRefineCellSizeEditPtr_->setReadOnly(true); + meshGui_.removeMinCellSize(); + } } void meshGenQtGeneralSettings::setMinCellSize(const QString& s) { - if( bndCellSizeCheckPtr_->isChecked() ) - { - const word sn(s.ascii()); - - const scalar size = help::textToScalar(sn); - meshGui_.setMinCellSize(size); - } + if( bndCellSizeCheckPtr_->isChecked() ) + { + const word sn(s.ascii()); + + const scalar size = help::textToScalar(sn); + meshGui_.setMinCellSize(size); + } } void meshGenQtGeneralSettings::activateKeepCellsIntersectingBoundary() { - if( keepBndCellsCheckPtr_->isChecked() ) - { - meshGui_.setKeepCellsIntersectingBoundary(); - } - else - { - meshGui_.removeKeepCellsIntersectingBoundary(); - - if( gluedMeshCheckPtr_->isChecked() ) - { - gluedMeshCheckPtr_->setChecked(false); - meshGui_.removeCheckForGluedMesh(); - } - } + if( keepBndCellsCheckPtr_->isChecked() ) + { + meshGui_.setKeepCellsIntersectingBoundary(); + } + else + { + meshGui_.removeKeepCellsIntersectingBoundary(); + + if( gluedMeshCheckPtr_->isChecked() ) + { + gluedMeshCheckPtr_->setChecked(false); + meshGui_.removeCheckForGluedMesh(); + } + } } - + void meshGenQtGeneralSettings::activateCheckForGluedMesh() { - if( keepBndCellsCheckPtr_->isChecked() ) - { - meshGui_.setCheckForGluedMesh(); - - if( gluedMeshCheckPtr_->isChecked() ) - { - meshGui_.setCheckForGluedMesh(); - } - else - { - meshGui_.removeCheckForGluedMesh(); - } - } - else - { - meshGui_.removeCheckForGluedMesh(); - } + if( keepBndCellsCheckPtr_->isChecked() ) + { + meshGui_.setCheckForGluedMesh(); + + if( gluedMeshCheckPtr_->isChecked() ) + { + meshGui_.setCheckForGluedMesh(); + } + else + { + meshGui_.removeCheckForGluedMesh(); + } + } + else + { + meshGui_.removeCheckForGluedMesh(); + } } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/GUI/meshGenQt/meshGenQtGeneralSettings.H b/GUI/meshGenQt/meshGenQtGeneralSettings.H index 149df8ce..cea1a849 100755 --- a/GUI/meshGenQt/meshGenQtGeneralSettings.H +++ b/GUI/meshGenQt/meshGenQtGeneralSettings.H @@ -59,63 +59,63 @@ namespace Foam class meshGenQtGeneralSettings : - public QWidget + public QWidget { - Q_OBJECT - - // Private data - - //- mesh generation dictionary - meshGenGUI& meshGui_; - - //- main window data - QPushButton* openButtonPtr_; - QLineEdit* surfaceFileEditPtr_; - QLineEdit* maxCellSizeEditPtr_; - - QCheckBox* bndCellSizeCheckPtr_; - QLineEdit* bndCellSizeEditPtr_; - - QCheckBox* autoRefineCheckPtr_; - QLineEdit* autoRefineCellSizeEditPtr_; - - QCheckBox* keepBndCellsCheckPtr_; - QCheckBox* gluedMeshCheckPtr_; - + Q_OBJECT + + // Private data + + //- mesh generation dictionary + meshGenGUI& meshGui_; + + //- main window data + QPushButton* openButtonPtr_; + QLineEdit* surfaceFileEditPtr_; + QLineEdit* maxCellSizeEditPtr_; + + QCheckBox* bndCellSizeCheckPtr_; + QLineEdit* bndCellSizeEditPtr_; + + QCheckBox* autoRefineCheckPtr_; + QLineEdit* autoRefineCellSizeEditPtr_; + + QCheckBox* keepBndCellsCheckPtr_; + QCheckBox* gluedMeshCheckPtr_; + private slots: - - // Private callback functions + + // Private callback functions - //- open surface file - void openSurfaceFile(); - - //- set max cell size - void setMaxCellSize(const QString&); + //- open surface file + void openSurfaceFile(); + + //- set max cell size + void setMaxCellSize(const QString&); - //- set activity of bndCellSize - void activateBndCellSize(); + //- set activity of bndCellSize + void activateBndCellSize(); - //- set bndCellSize - void setBndCellSize(const QString&); + //- set bndCellSize + void setBndCellSize(const QString&); - //- set activity of auto refinement - void activateMinCellSize(); + //- set activity of auto refinement + void activateMinCellSize(); - //- set min size in auto refinement - void setMinCellSize(const QString&); + //- set min size in auto refinement + void setMinCellSize(const QString&); - //- set activity of keepCellsIntersectingBoundary - void activateKeepCellsIntersectingBoundary(); - - //- set activity of glued mesh check - void activateCheckForGluedMesh(); - + //- set activity of keepCellsIntersectingBoundary + void activateKeepCellsIntersectingBoundary(); + + //- set activity of glued mesh check + void activateCheckForGluedMesh(); + private: - - // Private member functions - - //- create window - void createWindow(); + + // Private member functions + + //- create window + void createWindow(); //- Disallow default bitwise copy construct meshGenQtGeneralSettings(const meshGenQtGeneralSettings&); diff --git a/executables/cartesianMesh/cartesianMesh.C b/executables/cartesianMesh/cartesianMesh.C index c01d5d6b..682ba237 100644 --- a/executables/cartesianMesh/cartesianMesh.C +++ b/executables/cartesianMesh/cartesianMesh.C @@ -50,7 +50,7 @@ int main(int argc, char *argv[]) Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s\n" << "ClockTime = " << runTime.elapsedClockTime() << " s" << endl; - + omg.writeMesh(); Info << "End\n" << endl; diff --git a/executables/dualMesh/dualMesh.C b/executables/dualMesh/dualMesh.C index 3f021c34..62a5b1a1 100644 --- a/executables/dualMesh/dualMesh.C +++ b/executables/dualMesh/dualMesh.C @@ -27,8 +27,8 @@ Application Description - creates an octree and generates its dual. - - dual is used as mesh template which is the treated to conform to - - the geometry surface + - dual is used as mesh template which is the treated to conform to + - the geometry surface \*---------------------------------------------------------------------------*/ @@ -48,10 +48,10 @@ int main(int argc, char *argv[]) # include "createTime.H" dualMeshGenerator omg(runTime); - + Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s\n" << "ClockTime = " << runTime.elapsedClockTime() << endl; - + omg.writeMesh(); Info << "End\n" << endl; diff --git a/executables/hexMesh/hexMesh.C b/executables/hexMesh/hexMesh.C index d88ca70b..2ddc0fa9 100644 --- a/executables/hexMesh/hexMesh.C +++ b/executables/hexMesh/hexMesh.C @@ -50,7 +50,7 @@ int main(int argc, char *argv[]) Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s\n" << "ClockTime = " << runTime.elapsedClockTime() << " s" << endl; - + omg.writeMesh(); Info << "End\n" << endl; diff --git a/executables/pMesh/pMesh.C b/executables/pMesh/pMesh.C index ea48e0d9..3edc8d88 100644 --- a/executables/pMesh/pMesh.C +++ b/executables/pMesh/pMesh.C @@ -49,7 +49,7 @@ int main(int argc, char *argv[]) Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s\n" << "ClockTime = " << runTime.elapsedClockTime() << endl; - + omg.writeMesh(); Info << "End\n" << endl; diff --git a/executables/tetMesh/tetMesh.C b/executables/tetMesh/tetMesh.C index e84f6b33..391d814f 100644 --- a/executables/tetMesh/tetMesh.C +++ b/executables/tetMesh/tetMesh.C @@ -49,7 +49,7 @@ int main(int argc, char *argv[]) Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s\n" << "ClockTime = " << runTime.elapsedClockTime() << endl; - + omg.writeMesh(); Info << "End\n" << endl; diff --git a/meshLibrary/cartesianMesh/cartesianMeshExtractor/cartesianMeshExtractor.C b/meshLibrary/cartesianMesh/cartesianMeshExtractor/cartesianMeshExtractor.C index 5c7e3461..075620b6 100644 --- a/meshLibrary/cartesianMesh/cartesianMeshExtractor/cartesianMeshExtractor.C +++ b/meshLibrary/cartesianMesh/cartesianMeshExtractor/cartesianMeshExtractor.C @@ -40,7 +40,7 @@ namespace Foam void cartesianMeshExtractor::clearOut() { - deleteDemandDrivenData(leafCellLabelPtr_); + deleteDemandDrivenData(leafCellLabelPtr_); } // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // @@ -49,14 +49,14 @@ void cartesianMeshExtractor::clearOut() cartesianMeshExtractor::cartesianMeshExtractor ( meshOctree& octree, - const IOdictionary& meshDict, - polyMeshGen& mesh + const IOdictionary& meshDict, + polyMeshGen& mesh ) : octreeCheck_(octree, meshDict, false), - mesh_(mesh), - decomposeSplitHexes_(false), - leafCellLabelPtr_(new labelList(octree.numberOfLeaves(), -1)) + mesh_(mesh), + decomposeSplitHexes_(false), + leafCellLabelPtr_(new labelList(octree.numberOfLeaves(), -1)) { } @@ -64,36 +64,36 @@ cartesianMeshExtractor::cartesianMeshExtractor cartesianMeshExtractor::~cartesianMeshExtractor() { - clearOut(); + clearOut(); } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // void cartesianMeshExtractor::decomposeSplitHexes() { - decomposeSplitHexes_ = true; + decomposeSplitHexes_ = true; } void cartesianMeshExtractor::createMesh() { - Info << "Extracting polyMesh" << endl; - - //- create points and pointLeaves addressing + Info << "Extracting polyMesh" << endl; + + //- create points and pointLeaves addressing createPointsAndAddressing(); - //- create the mesh + //- create the mesh createPolyMesh(); //- decompose split-hex cells into tetrahedra and pyramids decomposeSplitHexesIntoTetsAndPyramids(); - - //- remove unused vertices - polyMeshGenModifier(mesh_).removeUnusedVertices(); - - Info << "Mesh has :" << nl - << mesh_.points().size() << " vertices " << nl - << mesh_.faces().size() << " faces" << nl - << mesh_.cells().size() << " cells" << endl; + + //- remove unused vertices + polyMeshGenModifier(mesh_).removeUnusedVertices(); + + Info << "Mesh has :" << nl + << mesh_.points().size() << " vertices " << nl + << mesh_.faces().size() << " faces" << nl + << mesh_.cells().size() << " cells" << endl; if( Pstream::parRun() ) { @@ -113,7 +113,7 @@ void cartesianMeshExtractor::createMesh() << " This can be reolved by reducing the maxCellSize by a fraction." << "i.e. 2.49999 instead of 2.5." << exit(FatalError); } - + Info << "Finished extracting polyMesh" << endl; } diff --git a/meshLibrary/cartesianMesh/cartesianMeshExtractor/cartesianMeshExtractor.H b/meshLibrary/cartesianMesh/cartesianMeshExtractor/cartesianMeshExtractor.H index d44bdd6a..8459f38e 100644 --- a/meshLibrary/cartesianMesh/cartesianMeshExtractor/cartesianMeshExtractor.H +++ b/meshLibrary/cartesianMesh/cartesianMeshExtractor/cartesianMeshExtractor.H @@ -43,7 +43,7 @@ SourceFiles namespace Foam { - + class IOdictionary; /*---------------------------------------------------------------------------*\ @@ -55,28 +55,28 @@ class cartesianMeshExtractor // Private data //- reference to the octree addressing meshOctreeAddressing octreeCheck_; - - //- reference to the mesh - polyMeshGen& mesh_; - - //- decompose split hex cells - bool decomposeSplitHexes_; - - //- cell label for a given leaf - labelList* leafCellLabelPtr_; + + //- reference to the mesh + polyMeshGen& mesh_; + + //- decompose split hex cells + bool decomposeSplitHexes_; + + //- cell label for a given leaf + labelList* leafCellLabelPtr_; // Private member functions - //- delete all freestore data - void clearOut(); + //- delete all freestore data + void clearOut(); //- create vertices and pointLeaves addressing void createPointsAndAddressing(); //- create mesh data void createPolyMesh(); - - //- decompose split hexes into pyramids and tets - void decomposeSplitHexesIntoTetsAndPyramids(); + + //- decompose split hexes into pyramids and tets + void decomposeSplitHexesIntoTetsAndPyramids(); // Private copy constructor //- Disallow default bitwise copy construct @@ -93,8 +93,8 @@ public: cartesianMeshExtractor ( meshOctree& octree, - const IOdictionary& meshDict, - polyMeshGen& mesh + const IOdictionary& meshDict, + polyMeshGen& mesh ); // Destructor @@ -104,11 +104,11 @@ public: // Member Functions - //- decompose split hexes into standard cells - void decomposeSplitHexes(); - - //- create the mesh with the above options - void createMesh(); + //- decompose split hexes into standard cells + void decomposeSplitHexes(); + + //- create the mesh with the above options + void createMesh(); }; diff --git a/meshLibrary/cartesianMesh/cartesianMeshExtractor/cartesianMeshExtractorDecomposeSplitHexes.C b/meshLibrary/cartesianMesh/cartesianMeshExtractor/cartesianMeshExtractorDecomposeSplitHexes.C index 097ad7da..7ba87efa 100644 --- a/meshLibrary/cartesianMesh/cartesianMeshExtractor/cartesianMeshExtractorDecomposeSplitHexes.C +++ b/meshLibrary/cartesianMesh/cartesianMeshExtractor/cartesianMeshExtractorDecomposeSplitHexes.C @@ -43,11 +43,11 @@ namespace Foam void cartesianMeshExtractor::decomposeSplitHexesIntoTetsAndPyramids() { - if( !decomposeSplitHexes_ ) return; + if( !decomposeSplitHexes_ ) return; - Info << "Decomposing split-hex cells" << endl; - - const faceListPMG& faces = mesh_.faces(); + Info << "Decomposing split-hex cells" << endl; + + const faceListPMG& faces = mesh_.faces(); //- decompose faces which have more than 4 vertices boolList decompose(faces.size(), false); @@ -100,8 +100,8 @@ void cartesianMeshExtractor::decomposeSplitHexesIntoTetsAndPyramids() decomposeCells dc(mesh_); dc.decomposeMesh(decompose); } - - Info << "Finished decomposing split-hex cells" << endl; + + Info << "Finished decomposing split-hex cells" << endl; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/meshLibrary/cartesianMesh/cartesianMeshExtractor/cartesianMeshExtractorPointsAndAddressing.C b/meshLibrary/cartesianMesh/cartesianMeshExtractor/cartesianMeshExtractorPointsAndAddressing.C index c76d282a..a9fa1f34 100644 --- a/meshLibrary/cartesianMesh/cartesianMeshExtractor/cartesianMeshExtractorPointsAndAddressing.C +++ b/meshLibrary/cartesianMesh/cartesianMeshExtractor/cartesianMeshExtractorPointsAndAddressing.C @@ -42,10 +42,10 @@ void cartesianMeshExtractor::createPointsAndAddressing() Info << "Creating octree vertices" << endl; //- set the size of the point field - pointFieldPMG& points = mesh_.points(); - points.setSize(octreeCheck_.numberOfNodes()); - - //- store vertices into the pointField + pointFieldPMG& points = mesh_.points(); + points.setSize(octreeCheck_.numberOfNodes()); + + //- store vertices into the pointField const pointField& octreePoints = octreeCheck_.octreePoints(); forAll(points, pointI) diff --git a/meshLibrary/cartesianMesh/cartesianMeshExtractor/cartesianMeshExtractorPolyMesh.C b/meshLibrary/cartesianMesh/cartesianMeshExtractor/cartesianMeshExtractorPolyMesh.C index 79c2192b..9616fb91 100644 --- a/meshLibrary/cartesianMesh/cartesianMeshExtractor/cartesianMeshExtractorPolyMesh.C +++ b/meshLibrary/cartesianMesh/cartesianMeshExtractor/cartesianMeshExtractorPolyMesh.C @@ -52,13 +52,13 @@ namespace Foam void cartesianMeshExtractor::createPolyMesh() { Info << "Creating polyMesh from octree" << endl; - - const meshOctree& octree = octreeCheck_.octree(); - + + const meshOctree& octree = octreeCheck_.octree(); + //- give labels to cubes which will be used as mesh cells - const List<direction>& cType = octreeCheck_.boxType(); - - labelList& leafCellLabel = *leafCellLabelPtr_; + const List<direction>& cType = octreeCheck_.boxType(); + + labelList& leafCellLabel = *leafCellLabelPtr_; label nCells(0); forAll(cType, leafI) { @@ -74,12 +74,12 @@ void cartesianMeshExtractor::createPolyMesh() } } - //- access to mesh data - polyMeshGenModifier meshModifier(mesh_); - faceListPMG& faces = meshModifier.facesAccess(); - cellListPMG& cells = meshModifier.cellsAccess(); - - //- start creating octree mesh + //- access to mesh data + polyMeshGenModifier meshModifier(mesh_); + faceListPMG& faces = meshModifier.facesAccess(); + cellListPMG& cells = meshModifier.cellsAccess(); + + //- start creating octree mesh cells.setSize(nCells); List<direction> nFacesInCell(nCells, direction(0)); label nFaces(0); @@ -321,7 +321,7 @@ void cartesianMeshExtractor::createPolyMesh() vectorField closedness(cells.size(), vector::zero); const labelList& owner = mesh_.owner(); - const labelList& neighbour = mesh_.neighbour(); + const labelList& neighbour = mesh_.neighbour(); forAll(owner, faceI) if( owner[faceI] == -1 ) { @@ -353,7 +353,7 @@ void cartesianMeshExtractor::createPolyMesh() # endif - meshModifier.reorderBoundaryFaces(); + meshModifier.reorderBoundaryFaces(); Info << "Finished creating polyMesh" << endl; } diff --git a/meshLibrary/cartesianMesh/cartesianMeshGenerator/cartesianMeshGenerator.C b/meshLibrary/cartesianMesh/cartesianMeshGenerator/cartesianMeshGenerator.C index 151e4aec..3da72559 100644 --- a/meshLibrary/cartesianMesh/cartesianMeshGenerator/cartesianMeshGenerator.C +++ b/meshLibrary/cartesianMesh/cartesianMeshGenerator/cartesianMeshGenerator.C @@ -65,39 +65,39 @@ namespace Foam void cartesianMeshGenerator::createCartesianMesh() { - //- create polyMesh from octree boxes - cartesianMeshExtractor cme(*octreePtr_, meshDict_, mesh_); - + //- create polyMesh from octree boxes + cartesianMeshExtractor cme(*octreePtr_, meshDict_, mesh_); + if( meshDict_.found("decomposePolyhedraIntoTetsAndPyrs") ) { if( readBool(meshDict_.lookup("decomposePolyhedraIntoTetsAndPyrs")) ) cme.decomposeSplitHexes(); } - cme.createMesh(); - - # ifdef DEBUG - mesh_.write(); - # ifdef DEBUGfpma - writeMeshFPMA(mesh_, "cartesianMesh"); - # else - writeMeshEnsight(mesh_, "cartesianMesh"); - # endif - //::exit(EXIT_FAILURE); - # endif + cme.createMesh(); + + # ifdef DEBUG + mesh_.write(); + # ifdef DEBUGfpma + writeMeshFPMA(mesh_, "cartesianMesh"); + # else + writeMeshEnsight(mesh_, "cartesianMesh"); + # endif + //::exit(EXIT_FAILURE); + # endif } - + void cartesianMeshGenerator::surfacePreparation() { - //- removes unnecessary cells and morph the boundary + //- removes unnecessary cells and morph the boundary //- such that there is only one boundary face per cell - //- It also checks topology of cells after morphing is performed -/* do - { - surfaceMorpherCells* cmPtr = new surfaceMorpherCells(mesh_); - cmPtr->morphMesh(); - deleteDemandDrivenData(cmPtr); - } while( topologicalCleaner(mesh_).cleanTopology() ); + //- It also checks topology of cells after morphing is performed +/* do + { + surfaceMorpherCells* cmPtr = new surfaceMorpherCells(mesh_); + cmPtr->morphMesh(); + deleteDemandDrivenData(cmPtr); + } while( topologicalCleaner(mesh_).cleanTopology() ); */ bool changed; @@ -114,24 +114,24 @@ void cartesianMeshGenerator::surfacePreparation() if( checkCellConnectionsOverFaces(mesh_).checkCellGroups() ) changed = true; - } while( changed ); + } while( changed ); checkBoundaryFacesSharingTwoEdges(mesh_).improveTopology(); - # ifdef DEBUG - mesh_.write(); - # ifdef DEBUGfpma - writeMeshFPMA(mesh_, "afterTopoCleaning"); - # else - writeMeshEnsight(mesh_, "afterTopoCleaning"); - # endif - //::exit(EXIT_FAILURE); - # endif + # ifdef DEBUG + mesh_.write(); + # ifdef DEBUGfpma + writeMeshFPMA(mesh_, "afterTopoCleaning"); + # else + writeMeshEnsight(mesh_, "afterTopoCleaning"); + # endif + //::exit(EXIT_FAILURE); + # endif } - + void cartesianMeshGenerator::mapMeshToSurface() { - //- calculate mesh surface + //- calculate mesh surface meshSurfaceEngine* msePtr = new meshSurfaceEngine(mesh_); //- pre-map mesh surface @@ -139,79 +139,79 @@ void cartesianMeshGenerator::mapMeshToSurface() mapper.preMapVertices(); # ifdef DEBUG - # ifdef DEBUGfpma + # ifdef DEBUGfpma writeMeshFPMA(mesh_, "preMappedMesh"); # else - writeMeshEnsight(mesh_, "preMappedMesh"); - # endif - mesh_.write(); - //::exit(EXIT_FAILURE); - # endif - - //- map mesh surface on the geometry surface - mapper.mapVerticesOntoSurface(); - - # ifdef DEBUG - # ifdef DEBUGfpma - writeMeshFPMA(mesh_, "afterMapping"); - # else - writeMeshEnsight(mesh_, "afterMapping"); - # endif - mesh_.write(); - //::exit(EXIT_FAILURE); - # endif - - //- untangle surface faces - meshSurfaceOptimizer(*msePtr, *octreePtr_).preOptimizeSurface(); - - # ifdef DEBUG - # ifdef DEBUGfpma - writeMeshFPMA(mesh_, "afterSurfaceSmoothing"); - # else - writeMeshEnsight(mesh_, "afterSurfaceSmoothing"); - # endif - mesh_.write(); - //::exit(EXIT_FAILURE); - # endif + writeMeshEnsight(mesh_, "preMappedMesh"); + # endif + mesh_.write(); + //::exit(EXIT_FAILURE); + # endif + + //- map mesh surface on the geometry surface + mapper.mapVerticesOntoSurface(); + + # ifdef DEBUG + # ifdef DEBUGfpma + writeMeshFPMA(mesh_, "afterMapping"); + # else + writeMeshEnsight(mesh_, "afterMapping"); + # endif + mesh_.write(); + //::exit(EXIT_FAILURE); + # endif + + //- untangle surface faces + meshSurfaceOptimizer(*msePtr, *octreePtr_).preOptimizeSurface(); + + # ifdef DEBUG + # ifdef DEBUGfpma + writeMeshFPMA(mesh_, "afterSurfaceSmoothing"); + # else + writeMeshEnsight(mesh_, "afterSurfaceSmoothing"); + # endif + mesh_.write(); + //::exit(EXIT_FAILURE); + # endif deleteDemandDrivenData(msePtr); } void cartesianMeshGenerator::mapEdgesAndCorners() { - meshSurfaceEdgeExtractorNonTopo(mesh_, *octreePtr_); - - # ifdef DEBUG - mesh_.write(); - //meshOptimizer(*octreePtr_, mesh_).preOptimize(); - # ifdef DEBUGfpma - writeMeshFPMA(mesh_, "withEdges"); - # else - writeMeshEnsight(mesh_, "withEdges"); - #endif - //::exit(EXIT_FAILURE); - # endif + meshSurfaceEdgeExtractorNonTopo(mesh_, *octreePtr_); + + # ifdef DEBUG + mesh_.write(); + //meshOptimizer(*octreePtr_, mesh_).preOptimize(); + # ifdef DEBUGfpma + writeMeshFPMA(mesh_, "withEdges"); + # else + writeMeshEnsight(mesh_, "withEdges"); + #endif + //::exit(EXIT_FAILURE); + # endif } void cartesianMeshGenerator::optimiseMeshSurface() { - meshSurfaceEngine mse(mesh_); - meshSurfaceOptimizer(mse, *octreePtr_).optimizeSurface(); - - # ifdef DEBUG - mesh_.write(); - # ifdef DEBUGfpma - writeMeshFPMA(mesh_, "optSurfaceWithEdges"); - # else - writeMeshEnsight(mesh_, "optSurfaceWithEdges"); - #endif - //::exit(EXIT_FAILURE); - # endif + meshSurfaceEngine mse(mesh_); + meshSurfaceOptimizer(mse, *octreePtr_).optimizeSurface(); + + # ifdef DEBUG + mesh_.write(); + # ifdef DEBUGfpma + writeMeshFPMA(mesh_, "optSurfaceWithEdges"); + # else + writeMeshEnsight(mesh_, "optSurfaceWithEdges"); + #endif + //::exit(EXIT_FAILURE); + # endif } - + void cartesianMeshGenerator::generateBoudaryLayers() { - boundaryLayers bl(mesh_); + boundaryLayers bl(mesh_); if( meshDict_.found("boundaryLayers") ) { @@ -224,37 +224,37 @@ void cartesianMeshGenerator::generateBoudaryLayers() { //bl.createOTopologyLayers(); bl.addLayerForAllPatches(); - } + } - # ifdef DEBUG + # ifdef DEBUG # ifdef DEBUGfpma writeMeshFPMA(mesh_, "meshWithBndLayer"); # else - writeMeshEnsight(mesh_, "meshWithBndLayer"); + writeMeshEnsight(mesh_, "meshWithBndLayer"); + # endif + mesh_.write(); + //::exit(EXIT_FAILURE); # endif - mesh_.write(); - //::exit(EXIT_FAILURE); - # endif } - + void cartesianMeshGenerator::optimiseFinalMesh() { - //- final optimisation - meshOptimizer optimizer(mesh_); + //- final optimisation + meshOptimizer optimizer(mesh_); optimizer.optimizeSurface(*octreePtr_); deleteDemandDrivenData(octreePtr_); optimizer.optimizeMeshFV(); - - # ifdef DEBUG - # ifdef DEBUGfpma - writeMeshFPMA(mesh_,"optimisedMesh"); - # else - writeMeshEnsight(mesh_, "optimisedMesh"); - #endif - # endif + + # ifdef DEBUG + # ifdef DEBUGfpma + writeMeshFPMA(mesh_,"optimisedMesh"); + # else + writeMeshEnsight(mesh_, "optimisedMesh"); + #endif + # endif } void cartesianMeshGenerator::replaceBoundaries() @@ -262,44 +262,44 @@ void cartesianMeshGenerator::replaceBoundaries() renameBoundaryPatches rbp(mesh_, meshDict_); # ifdef DEBUG - # ifdef DEBUGfpma - writeMeshFPMA(mesh_,"renamedPatchesMesh"); - # else - writeMeshEnsight(mesh_, "renamedPatchesMesh"); - #endif - # endif + # ifdef DEBUGfpma + writeMeshFPMA(mesh_,"renamedPatchesMesh"); + # else + writeMeshEnsight(mesh_, "renamedPatchesMesh"); + #endif + # endif } void cartesianMeshGenerator::renumberMesh() { - polyMeshGenModifier(mesh_).renumberMesh(); - - # ifdef DEBUG - # ifdef DEBUGfpma - writeMeshFPMA(mesh_,"renumberedMesh"); - # else - writeMeshEnsight(mesh_, "renumberedMesh"); - #endif - # endif + polyMeshGenModifier(mesh_).renumberMesh(); + + # ifdef DEBUG + # ifdef DEBUGfpma + writeMeshFPMA(mesh_,"renumberedMesh"); + # else + writeMeshEnsight(mesh_, "renumberedMesh"); + #endif + # endif } - + void cartesianMeshGenerator::generateMesh() { - createCartesianMesh(); - - surfacePreparation(); - - mapMeshToSurface(); - - mapEdgesAndCorners(); - - optimiseMeshSurface(); - - generateBoudaryLayers(); - - optimiseFinalMesh(); - - renumberMesh(); + createCartesianMesh(); + + surfacePreparation(); + + mapMeshToSurface(); + + mapEdgesAndCorners(); + + optimiseMeshSurface(); + + generateBoudaryLayers(); + + optimiseFinalMesh(); + + renumberMesh(); replaceBoundaries(); } @@ -323,7 +323,7 @@ cartesianMeshGenerator::cartesianMeshGenerator(const Time& time) ) ), octreePtr_(NULL), - mesh_(time) + mesh_(time) { if( true ) { @@ -332,21 +332,21 @@ cartesianMeshGenerator::cartesianMeshGenerator(const Time& time) fileName surfaceFile = meshDict_.lookup("surfaceFile"); if( Pstream::parRun() ) - surfaceFile = ".."/surfaceFile; + surfaceFile = ".."/surfaceFile; surfacePtr_ = new triSurf(db_.path()/surfaceFile); - - if( meshDict_.found("subsetFileName") ) - { - fileName subsetFileName = meshDict_.lookup("subsetFileName"); + + if( meshDict_.found("subsetFileName") ) + { + fileName subsetFileName = meshDict_.lookup("subsetFileName"); if( Pstream::parRun() ) - subsetFileName = ".."/subsetFileName; - surfacePtr_->readFaceSubsets(db_.path()/subsetFileName); - } + subsetFileName = ".."/subsetFileName; + surfacePtr_->readFaceSubsets(db_.path()/subsetFileName); + } octreePtr_ = new meshOctree(*surfacePtr_); - - meshOctreeCreator(*octreePtr_, meshDict_).createOctreeBoxes(); + + meshOctreeCreator(*octreePtr_, meshDict_).createOctreeBoxes(); generateMesh(); } @@ -372,7 +372,7 @@ cartesianMeshGenerator::cartesianMeshGenerator ) ), octreePtr_(NULL), - mesh_(time) + mesh_(time) { fileName surfaceFile = meshDict_.lookup("surfaceFile"); @@ -395,8 +395,8 @@ cartesianMeshGenerator::~cartesianMeshGenerator() // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // void cartesianMeshGenerator::writeMesh() const -{ - mesh_.write(); +{ + mesh_.write(); } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/meshLibrary/cartesianMesh/cartesianMeshGenerator/cartesianMeshGenerator.H b/meshLibrary/cartesianMesh/cartesianMeshGenerator/cartesianMeshGenerator.H index b3088125..702c68a9 100644 --- a/meshLibrary/cartesianMesh/cartesianMeshGenerator/cartesianMeshGenerator.H +++ b/meshLibrary/cartesianMesh/cartesianMeshGenerator/cartesianMeshGenerator.H @@ -68,38 +68,38 @@ class cartesianMeshGenerator //- pointer to the octree meshOctree* octreePtr_; - - //- mesh - polyMeshGen mesh_; + + //- mesh + polyMeshGen mesh_; // Private member functions - //- create cartesian mesh - void createCartesianMesh(); - - //- prepare mesh surface - void surfacePreparation(); - - //- map mesh to the surface and untangle surface - void mapMeshToSurface(); - - //- capture edges and corners - void mapEdgesAndCorners(); - - //- optimise surface mesh - void optimiseMeshSurface(); - - //- add boundary layers - void generateBoudaryLayers(); - - //- mesh optimisation - void optimiseFinalMesh(); + //- create cartesian mesh + void createCartesianMesh(); + + //- prepare mesh surface + void surfacePreparation(); + + //- map mesh to the surface and untangle surface + void mapMeshToSurface(); + + //- capture edges and corners + void mapEdgesAndCorners(); + + //- optimise surface mesh + void optimiseMeshSurface(); + + //- add boundary layers + void generateBoudaryLayers(); + + //- mesh optimisation + void optimiseFinalMesh(); //- replace boundaries void replaceBoundaries(); - - //- renumber the mesh - void renumberMesh(); - + + //- renumber the mesh + void renumberMesh(); + //- generate mesh void generateMesh(); diff --git a/meshLibrary/dualMesh/dualMeshExtractor/dualMeshExtractor.C b/meshLibrary/dualMesh/dualMeshExtractor/dualMeshExtractor.C index 7ae358c9..5cdd7b2a 100644 --- a/meshLibrary/dualMesh/dualMeshExtractor/dualMeshExtractor.C +++ b/meshLibrary/dualMesh/dualMeshExtractor/dualMeshExtractor.C @@ -39,18 +39,18 @@ namespace Foam // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // const direction dualMeshExtractor::faceFlip_[6][4] = - { - {0, 4, 6, 2}, - {5, 1, 3, 7}, - {0, 2, 3, 1}, - {4, 5, 7, 6}, - {2, 6, 7, 3}, - {0, 1, 5, 4} - }; - + { + {0, 4, 6, 2}, + {5, 1, 3, 7}, + {0, 2, 3, 1}, + {4, 5, 7, 6}, + {2, 6, 7, 3}, + {0, 1, 5, 4} + }; + void dualMeshExtractor::clearOut() { - deleteDemandDrivenData(centreNodeLabelPtr_); + deleteDemandDrivenData(centreNodeLabelPtr_); } // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // @@ -59,13 +59,13 @@ void dualMeshExtractor::clearOut() dualMeshExtractor::dualMeshExtractor ( const meshOctree& octree, - const IOdictionary& dict, - polyMeshGen& mesh + const IOdictionary& dict, + polyMeshGen& mesh ) : octreeAddressing_(octree, dict, true), - mesh_(mesh), - centreNodeLabelPtr_(NULL) + mesh_(mesh), + centreNodeLabelPtr_(NULL) { } @@ -73,33 +73,33 @@ dualMeshExtractor::dualMeshExtractor dualMeshExtractor::~dualMeshExtractor() { - clearOut(); + clearOut(); } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // void dualMeshExtractor::createMesh() { - Info << "Extracting polyMesh" << endl; - + Info << "Extracting polyMesh" << endl; + createPoints(); createPolyMesh(); - - polyMeshGenModifier(mesh_).removeUnusedVertices(); - polyMeshGenModifier(mesh_).reorderBoundaryFaces(); - - Info << "Mesh has :" << nl - << mesh_.points().size() << " vertices " << nl - << mesh_.faces().size() << " faces" << nl - << mesh_.cells().size() << " cells" << endl; - - # ifdef DEBUGDual - Info << "Points start at address " << long(&mesh_.points()) << endl; - Info << "Faces start at address " << long(&mesh_.faces()) << endl; - Info << "Cells start at address " << long(&mesh_.cells()) << endl; - # endif - + + polyMeshGenModifier(mesh_).removeUnusedVertices(); + polyMeshGenModifier(mesh_).reorderBoundaryFaces(); + + Info << "Mesh has :" << nl + << mesh_.points().size() << " vertices " << nl + << mesh_.faces().size() << " faces" << nl + << mesh_.cells().size() << " cells" << endl; + + # ifdef DEBUGDual + Info << "Points start at address " << long(&mesh_.points()) << endl; + Info << "Faces start at address " << long(&mesh_.faces()) << endl; + Info << "Cells start at address " << long(&mesh_.cells()) << endl; + # endif + Info << "Finished extracting polyMesh" << endl; } diff --git a/meshLibrary/dualMesh/dualMeshExtractor/dualMeshExtractor.H b/meshLibrary/dualMesh/dualMeshExtractor/dualMeshExtractor.H index 5e7a08bc..fb64ec5f 100644 --- a/meshLibrary/dualMesh/dualMeshExtractor/dualMeshExtractor.H +++ b/meshLibrary/dualMesh/dualMeshExtractor/dualMeshExtractor.H @@ -56,82 +56,82 @@ class meshOctree; class dualMeshExtractor { // Private data - //- helper for cell creation - static const direction faceFlip_[6][4]; + //- helper for cell creation + static const direction faceFlip_[6][4]; //- reference to the octree meshOctreeAddressing octreeAddressing_; - - //- reference to the mesh - polyMeshGen& mesh_; - - //- centre node labels - labelListPMG* centreNodeLabelPtr_; + + //- reference to the mesh + polyMeshGen& mesh_; + + //- centre node labels + labelListPMG* centreNodeLabelPtr_; // Private member functions - //- delete freestore data - void clearOut(); - + //- delete freestore data + void clearOut(); + //- create vertices and pointLeaves addressing void createPoints(); //- create mesh data void createPolyMesh(); - - // Nested classes - class decomposeCreatedPoly - { - // Private data - const faceList& cellFaces_; - - const Map<direction>& nodeLevel_; - - boolListList splitFaceNode_; - - //- list of edges over which a face has been split - DynList<edge> splitEdge_; - - //- list containing information if a face - //- is a product of splitting - DynList<bool> splitFace_; - - //- a list of decomposed faces - DynList<face> decomposedFaces_; - - //- helper data - labelListList dfe_; - labelListList def_; - DynList<edge> de_; - boolList se_; - - // Private member functions - //- decompose non-planar faces into triangles - void decomposeFaces(); - - //- calculate helper data - void calculateHelperAddressing(); - - //- find additional splitting edges - void selectAdditionalSplitEdges(); - - //- distribute new faces into cells - void selectFacesForCell(List<faceList>& cFaces); - - //- create missing faces to topologically close new cells - void createMissingFaces(List<faceList>& cFaces); - - public: - - decomposeCreatedPoly - ( - const faceList& cf, - const Map<direction>& nl - ); - - ~decomposeCreatedPoly(); - - void decomposeCell(List<faceList>& decCells); - }; + + // Nested classes + class decomposeCreatedPoly + { + // Private data + const faceList& cellFaces_; + + const Map<direction>& nodeLevel_; + + boolListList splitFaceNode_; + + //- list of edges over which a face has been split + DynList<edge> splitEdge_; + + //- list containing information if a face + //- is a product of splitting + DynList<bool> splitFace_; + + //- a list of decomposed faces + DynList<face> decomposedFaces_; + + //- helper data + labelListList dfe_; + labelListList def_; + DynList<edge> de_; + boolList se_; + + // Private member functions + //- decompose non-planar faces into triangles + void decomposeFaces(); + + //- calculate helper data + void calculateHelperAddressing(); + + //- find additional splitting edges + void selectAdditionalSplitEdges(); + + //- distribute new faces into cells + void selectFacesForCell(List<faceList>& cFaces); + + //- create missing faces to topologically close new cells + void createMissingFaces(List<faceList>& cFaces); + + public: + + decomposeCreatedPoly + ( + const faceList& cf, + const Map<direction>& nl + ); + + ~decomposeCreatedPoly(); + + void decomposeCell(List<faceList>& decCells); + }; // Private copy constructor //- Disallow default bitwise copy construct @@ -148,8 +148,8 @@ public: dualMeshExtractor ( const meshOctree& octree, - const IOdictionary& dict, - polyMeshGen& mesh + const IOdictionary& dict, + polyMeshGen& mesh ); // Destructor @@ -159,7 +159,7 @@ public: // Member Functions - void createMesh(); + void createMesh(); }; diff --git a/meshLibrary/dualMesh/dualMeshExtractor/dualMeshExtractorDecompose.C b/meshLibrary/dualMesh/dualMeshExtractor/dualMeshExtractorDecompose.C index 020a407b..374f2b05 100644 --- a/meshLibrary/dualMesh/dualMeshExtractor/dualMeshExtractorDecompose.C +++ b/meshLibrary/dualMesh/dualMeshExtractor/dualMeshExtractorDecompose.C @@ -36,544 +36,544 @@ Description namespace Foam { - + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // void dualMeshExtractor::decomposeCreatedPoly::decomposeFaces() { - //- check if face needs to be decomposed - forAll(cellFaces_, cfI) - { - const face& f = cellFaces_[cfI]; - - if( f.size() == 3 ) - { - decomposedFaces_.append(f); - splitFace_.append(false); - } - else - { - List<direction> nodeLevel(4); - forAll(f, pI) - nodeLevel[pI] = nodeLevel_.find(f[pI])(); - - # ifdef DEBUGDual - forAll(nodeLevel, nI) - Info << "level for node " << f[nI] << " is " - << label(nodeLevel[nI]) << endl; - # endif - - direction minLevel(nodeLevel[0]); - forAll(nodeLevel, nI) - if( minLevel > nodeLevel[nI] ) - minLevel = nodeLevel[nI]; - - //- find positions of min level nodes - DynList<direction> posMin(4); - forAll(nodeLevel, nI) - if( nodeLevel[nI] == minLevel ) - posMin.append(nI); - - switch( posMin.size() ) - { - case 4: - { - //- store face - decomposedFaces_.append(f); - splitFace_.append(false); - } break; - case 3: - { - # ifdef DEBUGDual - Info << "2. Decomposing " << f << endl; - # endif - //- decompose face into 2 triangles - direction posHigh(0); - forAll(nodeLevel, nI) - if( nodeLevel[nI] != minLevel ) - { - posHigh = nI; - break; - } - - splitEdge_.append - ( - edge(f[posHigh], f[(posHigh+2)%4]) - ); - splitFaceNode_[cfI][posHigh] = true; - splitFaceNode_[cfI][(posHigh+2)%4] = true; - - face tri(3); - tri[0] = f[posHigh]; - tri[1] = f[f.fcIndex(posHigh)]; - tri[2] = f[(posHigh+2)%4]; - # ifdef DEBUGDual - Info << "2. tri " << tri << endl; - # endif - decomposedFaces_.append(tri); - splitFace_.append(true); - - tri[0] = f[posHigh]; - tri[1] = f[(posHigh+2)%4]; - tri[2] = f[f.rcIndex(posHigh)]; - # ifdef DEBUGDual - Info << "2. tri " << tri << endl; - # endif - decomposedFaces_.append(tri); - splitFace_.append(true); - } break; - case 2: - { - if( - (f.fcIndex(posMin[0]) == posMin[1]) - || (f.rcIndex(posMin[0]) == posMin[1]) - ) - { - decomposedFaces_.append(f); - splitFace_.append(false); - } - else - { - # ifdef DEBUGDual - Info << "3. Decomposing " << f << endl; - # endif - face tri(3); - direction pm = posMin[0]; - - splitEdge_.append - ( - edge(f[f.fcIndex(pm)], f[f.rcIndex(pm)]) - ); - splitFaceNode_[cfI][f.fcIndex(pm)] = true; - splitFaceNode_[cfI][f.rcIndex(pm)] = true; - - tri[0] = f[pm]; - tri[1] = f[f.fcIndex(pm)]; - tri[2] = f[f.rcIndex(pm)]; - # ifdef DEBUGDual - Info << "3. tri " << tri << endl; - # endif - decomposedFaces_.append(tri); - splitFace_.append(true); - - pm = posMin[1]; - tri[0] = f[pm]; - tri[1] = f[f.fcIndex(pm)]; - tri[2] = f[f.rcIndex(pm)]; - # ifdef DEBUGDual - Info << "3. tri " << tri << endl; - # endif - decomposedFaces_.append(tri); - splitFace_.append(true); - } - } break; - case 1: - { - # ifdef DEBUGDual - Info << "4. Decomposing " << f << endl; - # endif - //- decompose face into 2 triangles - const direction pm = posMin[0]; - - splitEdge_.append - ( - edge(f[f.fcIndex(pm)], f[f.rcIndex(pm)]) - ); - splitFaceNode_[cfI][f.fcIndex(pm)] = true; - splitFaceNode_[cfI][f.rcIndex(pm)] = true; - - face tri(3); - tri[0] = f[pm]; - tri[1] = f[f.fcIndex(pm)]; - tri[2] = f[f.rcIndex(pm)]; - # ifdef DEBUGDual - Info << "4. tri " << tri << endl; - # endif - decomposedFaces_.append(tri); - splitFace_.append(true); - - tri[0] = f[f.fcIndex(pm)]; - tri[1] = f[(pm+2)%4]; - tri[2] = f[f.rcIndex(pm)]; - # ifdef DEBUGDual - Info << "4. tri " << tri << endl; - # endif - decomposedFaces_.append(tri); - splitFace_.append(true); - } break; - }; - } - } + //- check if face needs to be decomposed + forAll(cellFaces_, cfI) + { + const face& f = cellFaces_[cfI]; + + if( f.size() == 3 ) + { + decomposedFaces_.append(f); + splitFace_.append(false); + } + else + { + List<direction> nodeLevel(4); + forAll(f, pI) + nodeLevel[pI] = nodeLevel_.find(f[pI])(); + + # ifdef DEBUGDual + forAll(nodeLevel, nI) + Info << "level for node " << f[nI] << " is " + << label(nodeLevel[nI]) << endl; + # endif + + direction minLevel(nodeLevel[0]); + forAll(nodeLevel, nI) + if( minLevel > nodeLevel[nI] ) + minLevel = nodeLevel[nI]; + + //- find positions of min level nodes + DynList<direction> posMin(4); + forAll(nodeLevel, nI) + if( nodeLevel[nI] == minLevel ) + posMin.append(nI); + + switch( posMin.size() ) + { + case 4: + { + //- store face + decomposedFaces_.append(f); + splitFace_.append(false); + } break; + case 3: + { + # ifdef DEBUGDual + Info << "2. Decomposing " << f << endl; + # endif + //- decompose face into 2 triangles + direction posHigh(0); + forAll(nodeLevel, nI) + if( nodeLevel[nI] != minLevel ) + { + posHigh = nI; + break; + } + + splitEdge_.append + ( + edge(f[posHigh], f[(posHigh+2)%4]) + ); + splitFaceNode_[cfI][posHigh] = true; + splitFaceNode_[cfI][(posHigh+2)%4] = true; + + face tri(3); + tri[0] = f[posHigh]; + tri[1] = f[f.fcIndex(posHigh)]; + tri[2] = f[(posHigh+2)%4]; + # ifdef DEBUGDual + Info << "2. tri " << tri << endl; + # endif + decomposedFaces_.append(tri); + splitFace_.append(true); + + tri[0] = f[posHigh]; + tri[1] = f[(posHigh+2)%4]; + tri[2] = f[f.rcIndex(posHigh)]; + # ifdef DEBUGDual + Info << "2. tri " << tri << endl; + # endif + decomposedFaces_.append(tri); + splitFace_.append(true); + } break; + case 2: + { + if( + (f.fcIndex(posMin[0]) == posMin[1]) + || (f.rcIndex(posMin[0]) == posMin[1]) + ) + { + decomposedFaces_.append(f); + splitFace_.append(false); + } + else + { + # ifdef DEBUGDual + Info << "3. Decomposing " << f << endl; + # endif + face tri(3); + direction pm = posMin[0]; + + splitEdge_.append + ( + edge(f[f.fcIndex(pm)], f[f.rcIndex(pm)]) + ); + splitFaceNode_[cfI][f.fcIndex(pm)] = true; + splitFaceNode_[cfI][f.rcIndex(pm)] = true; + + tri[0] = f[pm]; + tri[1] = f[f.fcIndex(pm)]; + tri[2] = f[f.rcIndex(pm)]; + # ifdef DEBUGDual + Info << "3. tri " << tri << endl; + # endif + decomposedFaces_.append(tri); + splitFace_.append(true); + + pm = posMin[1]; + tri[0] = f[pm]; + tri[1] = f[f.fcIndex(pm)]; + tri[2] = f[f.rcIndex(pm)]; + # ifdef DEBUGDual + Info << "3. tri " << tri << endl; + # endif + decomposedFaces_.append(tri); + splitFace_.append(true); + } + } break; + case 1: + { + # ifdef DEBUGDual + Info << "4. Decomposing " << f << endl; + # endif + //- decompose face into 2 triangles + const direction pm = posMin[0]; + + splitEdge_.append + ( + edge(f[f.fcIndex(pm)], f[f.rcIndex(pm)]) + ); + splitFaceNode_[cfI][f.fcIndex(pm)] = true; + splitFaceNode_[cfI][f.rcIndex(pm)] = true; + + face tri(3); + tri[0] = f[pm]; + tri[1] = f[f.fcIndex(pm)]; + tri[2] = f[f.rcIndex(pm)]; + # ifdef DEBUGDual + Info << "4. tri " << tri << endl; + # endif + decomposedFaces_.append(tri); + splitFace_.append(true); + + tri[0] = f[f.fcIndex(pm)]; + tri[1] = f[(pm+2)%4]; + tri[2] = f[f.rcIndex(pm)]; + # ifdef DEBUGDual + Info << "4. tri " << tri << endl; + # endif + decomposedFaces_.append(tri); + splitFace_.append(true); + } break; + }; + } + } } void dualMeshExtractor::decomposeCreatedPoly::calculateHelperAddressing() { - dfe_.setSize(decomposedFaces_.size()); - forAll(decomposedFaces_, faceI) - { - dfe_[faceI].setSize(decomposedFaces_[faceI].size()); - dfe_[faceI] = -1; - } - - direction edgeI(0); - forAll(decomposedFaces_, faceI) - { - const edgeList edg = decomposedFaces_[faceI].edges(); - forAll(edg, eI) - { - const label pos = de_.containsAtPosition(edg[eI]); - - if( pos == -1 ) - { - de_.append(edg[eI]); - dfe_[faceI][eI] = edgeI; - def_[edgeI][0] = faceI; - ++edgeI; - } - else - { - dfe_[faceI][eI] = pos; - def_[pos][1] = faceI; - } - } - } - - se_.setSize(edgeI); - se_ = false; - - forAll(de_, eI) - if( splitEdge_.contains(de_[eI]) ) - se_[eI] = true; - - # ifdef DEBUGDual - Info << "de_ " << de_ << endl; - Info << "def_ " << def_ << endl; - Info << "dfe_ " << dfe_ << endl; - Info << "se " << se_ << endl; - # endif + dfe_.setSize(decomposedFaces_.size()); + forAll(decomposedFaces_, faceI) + { + dfe_[faceI].setSize(decomposedFaces_[faceI].size()); + dfe_[faceI] = -1; + } + + direction edgeI(0); + forAll(decomposedFaces_, faceI) + { + const edgeList edg = decomposedFaces_[faceI].edges(); + forAll(edg, eI) + { + const label pos = de_.containsAtPosition(edg[eI]); + + if( pos == -1 ) + { + de_.append(edg[eI]); + dfe_[faceI][eI] = edgeI; + def_[edgeI][0] = faceI; + ++edgeI; + } + else + { + dfe_[faceI][eI] = pos; + def_[pos][1] = faceI; + } + } + } + + se_.setSize(edgeI); + se_ = false; + + forAll(de_, eI) + if( splitEdge_.contains(de_[eI]) ) + se_[eI] = true; + + # ifdef DEBUGDual + Info << "de_ " << de_ << endl; + Info << "def_ " << def_ << endl; + Info << "dfe_ " << dfe_ << endl; + Info << "se " << se_ << endl; + # endif } void dualMeshExtractor::decomposeCreatedPoly::selectAdditionalSplitEdges() { - DynList<label> splitNode(8); - forAll(splitEdge_, eI) - { - splitNode.appendIfNotIn(splitEdge_[eI].start()); - splitNode.appendIfNotIn(splitEdge_[eI].end()); - } - - forAll(se_, eI) - { - if( se_[eI] ) - continue; - - const edgeList edges0 = decomposedFaces_[def_[eI][0]].edges(); - const edgeList edges1 = decomposedFaces_[def_[eI][1]].edges(); - - const edge& e = de_[eI]; - - # ifdef DEBUGDual - Info << "Checking edge " << eI << " with nodes " << e << endl; - # endif - - forAll(e, vI) - { - if( !splitNode.contains(e[vI]) ) - continue; - - DynList<edge> connectedEdges(2); - forAll(edges0, eJ) - if( (edges0[eJ] != e) && (edges0[eJ].otherVertex(e[vI]) != -1) ) - { - connectedEdges.append(edges0[eJ]); - break; - } - - forAll(edges1, eJ) - if( (edges1[eJ] != e) && (edges1[eJ].otherVertex(e[vI]) != -1) ) - { - connectedEdges.append(edges1[eJ]); - break; - } - - # ifdef DEBUGDual - Info << "Connected edges " << connectedEdges << endl; - # endif - - forAll(cellFaces_, cfI) - { - const face& f = cellFaces_[cfI]; - const edgeList fEdges = f.edges(); - - label e0(-1), e1(-1), cv(-1); - forAll(fEdges, feI) - { - if( fEdges[feI] == connectedEdges[0] ) - { - e0 = feI; - } - else if( fEdges[feI] == connectedEdges[1] ) - { - e1 = feI; - } - - if( f[feI] == e[vI] ) - cv = feI; - } - - # ifdef DEBUGDual - Info << "e0 " << e0 << endl; - Info << "e1 " << e1 << endl; - Info << "cv " << cv << endl; - # endif - - if( (e0 != -1) && (e1 != -1) && splitFaceNode_[cfI][cv] ) - { - se_[eI] = true; - break; - } - } - } - } + DynList<label> splitNode(8); + forAll(splitEdge_, eI) + { + splitNode.appendIfNotIn(splitEdge_[eI].start()); + splitNode.appendIfNotIn(splitEdge_[eI].end()); + } + + forAll(se_, eI) + { + if( se_[eI] ) + continue; + + const edgeList edges0 = decomposedFaces_[def_[eI][0]].edges(); + const edgeList edges1 = decomposedFaces_[def_[eI][1]].edges(); + + const edge& e = de_[eI]; + + # ifdef DEBUGDual + Info << "Checking edge " << eI << " with nodes " << e << endl; + # endif + + forAll(e, vI) + { + if( !splitNode.contains(e[vI]) ) + continue; + + DynList<edge> connectedEdges(2); + forAll(edges0, eJ) + if( (edges0[eJ] != e) && (edges0[eJ].otherVertex(e[vI]) != -1) ) + { + connectedEdges.append(edges0[eJ]); + break; + } + + forAll(edges1, eJ) + if( (edges1[eJ] != e) && (edges1[eJ].otherVertex(e[vI]) != -1) ) + { + connectedEdges.append(edges1[eJ]); + break; + } + + # ifdef DEBUGDual + Info << "Connected edges " << connectedEdges << endl; + # endif + + forAll(cellFaces_, cfI) + { + const face& f = cellFaces_[cfI]; + const edgeList fEdges = f.edges(); + + label e0(-1), e1(-1), cv(-1); + forAll(fEdges, feI) + { + if( fEdges[feI] == connectedEdges[0] ) + { + e0 = feI; + } + else if( fEdges[feI] == connectedEdges[1] ) + { + e1 = feI; + } + + if( f[feI] == e[vI] ) + cv = feI; + } + + # ifdef DEBUGDual + Info << "e0 " << e0 << endl; + Info << "e1 " << e1 << endl; + Info << "cv " << cv << endl; + # endif + + if( (e0 != -1) && (e1 != -1) && splitFaceNode_[cfI][cv] ) + { + se_[eI] = true; + break; + } + } + } + } } void dualMeshExtractor::decomposeCreatedPoly::selectFacesForCell ( - List<faceList>& cFaces + List<faceList>& cFaces ) { - if( splitEdge_.size() == 0 ) - { - //- cell has not been split - cFaces.setSize(1); - cFaces[0] = cellFaces_; - } - else - { - direction cellI(0); - - cFaces.setSize(5); - boolList storedFace(decomposedFaces_.size(), false); - - forAll(storedFace, faceI) - { - if( storedFace[faceI] ) - continue; - - DynList<label> front; - front.append(faceI); - - # ifdef DEBUGDual - Info << "Starting front with face " << faceI << endl; - # endif - - cFaces.newElmt(cellI).setSize(5); - direction cfI(0); - - do - { - DynList<label> newFront; - - forAll(front, fI) - { - const label fLabel = front[fI]; - if( storedFace[fLabel] ) - continue; - cFaces[cellI].newElmt(cfI++) = decomposedFaces_[fLabel]; - storedFace[fLabel] = true; - - # ifdef DEBUGDual - Info << "Storing face " << decomposedFaces_[fLabel] - << " into cell " << label(cellI) << endl; - # endif - - forAll(dfe_[fLabel], eI) - { - const label eLabel = dfe_[fLabel][eI]; - if( !se_[eLabel] ) - { - if( !storedFace[def_[eLabel][1]] ) - { - newFront.append(def_[eLabel][1]); - # ifdef DEBUGDual - Info << "Adding face " << def_[eLabel][1] - << " into the front" << endl; - # endif - } - else if( !storedFace[def_[eLabel][0]] ) - { - newFront.append(def_[eLabel][0]); - # ifdef DEBUGDual - Info << "Adding face " << def_[eLabel][0] - << " into the front" << endl; - # endif - } - } - } - } - - front = newFront; - } while( front.size() ); - - cFaces[cellI].setSize(cfI); - ++cellI; - } - - cFaces.setSize(cellI); - # ifdef DEBUGDual - Info << "Decomposed faces " << decomposedFaces_ << endl; - Info << "Cell faces " << cFaces << endl; - forAll(storedFace, fI) - if( !storedFace[fI] ) - FatalErrorIn - ( - "void dualMeshExtractor::decomposeCreatedPoly::" - "selectFacesForCell(List<faceList>&)" - ) << "Face " << fI << " is not stored!" << abort(FatalError); - # endif - - if( cellI < 2 ) - { - //selectFacesForCellComplex(cFaces); - - if( cFaces.size() < 2 ) - FatalErrorIn - ( - "void dualMeshExtractor::decomposeCreatedPoly::" - "selectFacesForCell(List<faceList>&)" - ) << "Cell is not decomposed, but should be!" - << abort(FatalError); - } - } + if( splitEdge_.size() == 0 ) + { + //- cell has not been split + cFaces.setSize(1); + cFaces[0] = cellFaces_; + } + else + { + direction cellI(0); + + cFaces.setSize(5); + boolList storedFace(decomposedFaces_.size(), false); + + forAll(storedFace, faceI) + { + if( storedFace[faceI] ) + continue; + + DynList<label> front; + front.append(faceI); + + # ifdef DEBUGDual + Info << "Starting front with face " << faceI << endl; + # endif + + cFaces.newElmt(cellI).setSize(5); + direction cfI(0); + + do + { + DynList<label> newFront; + + forAll(front, fI) + { + const label fLabel = front[fI]; + if( storedFace[fLabel] ) + continue; + cFaces[cellI].newElmt(cfI++) = decomposedFaces_[fLabel]; + storedFace[fLabel] = true; + + # ifdef DEBUGDual + Info << "Storing face " << decomposedFaces_[fLabel] + << " into cell " << label(cellI) << endl; + # endif + + forAll(dfe_[fLabel], eI) + { + const label eLabel = dfe_[fLabel][eI]; + if( !se_[eLabel] ) + { + if( !storedFace[def_[eLabel][1]] ) + { + newFront.append(def_[eLabel][1]); + # ifdef DEBUGDual + Info << "Adding face " << def_[eLabel][1] + << " into the front" << endl; + # endif + } + else if( !storedFace[def_[eLabel][0]] ) + { + newFront.append(def_[eLabel][0]); + # ifdef DEBUGDual + Info << "Adding face " << def_[eLabel][0] + << " into the front" << endl; + # endif + } + } + } + } + + front = newFront; + } while( front.size() ); + + cFaces[cellI].setSize(cfI); + ++cellI; + } + + cFaces.setSize(cellI); + # ifdef DEBUGDual + Info << "Decomposed faces " << decomposedFaces_ << endl; + Info << "Cell faces " << cFaces << endl; + forAll(storedFace, fI) + if( !storedFace[fI] ) + FatalErrorIn + ( + "void dualMeshExtractor::decomposeCreatedPoly::" + "selectFacesForCell(List<faceList>&)" + ) << "Face " << fI << " is not stored!" << abort(FatalError); + # endif + + if( cellI < 2 ) + { + //selectFacesForCellComplex(cFaces); + + if( cFaces.size() < 2 ) + FatalErrorIn + ( + "void dualMeshExtractor::decomposeCreatedPoly::" + "selectFacesForCell(List<faceList>&)" + ) << "Cell is not decomposed, but should be!" + << abort(FatalError); + } + } } void dualMeshExtractor::decomposeCreatedPoly::createMissingFaces ( - List<faceList>& cFaces + List<faceList>& cFaces ) { - if( splitEdge_.size() == 0 ) - return; - - //- missing faces will be created from open edges shared by two - //- adjacent cells - # ifdef DEBUGDual - Info << "Creating missing faces for cells " << cFaces << endl; - # endif - List<direction> nFacesInCell(cFaces.size()); - forAll(cFaces, cI) - nFacesInCell[cI] = cFaces[cI].size(); - List<DynList<edge> > openEdges(cFaces.size()); - - forAll(cFaces, cI) - { - help::findOpenEdges(cFaces[cI], openEdges[cI]); - } - - # ifdef DEBUGDual - Info << "Open edges are " << openEdges << endl; - # endif - - forAll(openEdges, cellI) - { - const DynList<edge>& oe = openEdges[cellI]; - for(direction cellJ=(cellI+1);cellJ<openEdges.size();++cellJ) - { - const DynList<edge>& oes = openEdges[cellJ]; - - DynList<edge> commonEdges(4); - forAll(oes, eI) - if( oe.contains(oes[eI]) ) - commonEdges.append(oes[eI]); - - # ifdef DEBUGDual - Info << "Common edges are " << commonEdges << endl; - # endif + if( splitEdge_.size() == 0 ) + return; + + //- missing faces will be created from open edges shared by two + //- adjacent cells + # ifdef DEBUGDual + Info << "Creating missing faces for cells " << cFaces << endl; + # endif + List<direction> nFacesInCell(cFaces.size()); + forAll(cFaces, cI) + nFacesInCell[cI] = cFaces[cI].size(); + List<DynList<edge> > openEdges(cFaces.size()); + + forAll(cFaces, cI) + { + help::findOpenEdges(cFaces[cI], openEdges[cI]); + } + + # ifdef DEBUGDual + Info << "Open edges are " << openEdges << endl; + # endif + + forAll(openEdges, cellI) + { + const DynList<edge>& oe = openEdges[cellI]; + for(direction cellJ=(cellI+1);cellJ<openEdges.size();++cellJ) + { + const DynList<edge>& oes = openEdges[cellJ]; + + DynList<edge> commonEdges(4); + forAll(oes, eI) + if( oe.contains(oes[eI]) ) + commonEdges.append(oes[eI]); + + # ifdef DEBUGDual + Info << "Common edges are " << commonEdges << endl; + # endif - if( commonEdges.size() > 1 ) - { - //- zip open chains - help::zipOpenChain(commonEdges); - - //- create a face - face newBf(help::sortEdgeChain(commonEdges)); - # ifdef DEBUGDual - Info << "Created face for cells " << label(cellI) << " and " - << label(cellJ) << " is " << newBf << endl; - # endif - - //- store face into new cells - cFaces[cellI].newElmt(nFacesInCell[cellI]++) = newBf; - cFaces[cellJ].newElmt(nFacesInCell[cellJ]++) = - newBf.reverseFace(); - } - } - } - - forAll(cFaces, cI) - { - cFaces[cI].setSize(nFacesInCell[cI]); - help::findOpenEdges(cFaces[cI], openEdges[cI]); - } - - # ifdef DEBUGDual - Info << "Open edges making internal cell are " << openEdges << endl; - # endif - faceList midCell(4); - direction fI(0); - - forAll(openEdges, cI) - if( openEdges[cI].size() > 1 ) - { - //- zip open chain - help::zipOpenChain(openEdges[cI]); - - //- create new face - face f(help::sortEdgeChain(openEdges[cI])); - midCell[fI++] = f; - cFaces[cI].newElmt(nFacesInCell[cI]++) = f.reverseFace(); - # ifdef DEBUGDual - Info << "1. Adding face of internal cell " << f << endl; - # endif - } - - if( fI > 3 ) - { - midCell.setSize(fI); - - cFaces.setSize(nFacesInCell.size()+1); - cFaces[nFacesInCell.size()] = midCell; - } + if( commonEdges.size() > 1 ) + { + //- zip open chains + help::zipOpenChain(commonEdges); + + //- create a face + face newBf(help::sortEdgeChain(commonEdges)); + # ifdef DEBUGDual + Info << "Created face for cells " << label(cellI) << " and " + << label(cellJ) << " is " << newBf << endl; + # endif + + //- store face into new cells + cFaces[cellI].newElmt(nFacesInCell[cellI]++) = newBf; + cFaces[cellJ].newElmt(nFacesInCell[cellJ]++) = + newBf.reverseFace(); + } + } + } + + forAll(cFaces, cI) + { + cFaces[cI].setSize(nFacesInCell[cI]); + help::findOpenEdges(cFaces[cI], openEdges[cI]); + } + + # ifdef DEBUGDual + Info << "Open edges making internal cell are " << openEdges << endl; + # endif + faceList midCell(4); + direction fI(0); + + forAll(openEdges, cI) + if( openEdges[cI].size() > 1 ) + { + //- zip open chain + help::zipOpenChain(openEdges[cI]); + + //- create new face + face f(help::sortEdgeChain(openEdges[cI])); + midCell[fI++] = f; + cFaces[cI].newElmt(nFacesInCell[cI]++) = f.reverseFace(); + # ifdef DEBUGDual + Info << "1. Adding face of internal cell " << f << endl; + # endif + } + + if( fI > 3 ) + { + midCell.setSize(fI); + + cFaces.setSize(nFacesInCell.size()+1); + cFaces[nFacesInCell.size()] = midCell; + } - forAll(nFacesInCell, cI) - cFaces[cI].setSize(nFacesInCell[cI]); + forAll(nFacesInCell, cI) + cFaces[cI].setSize(nFacesInCell[cI]); } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // dualMeshExtractor::decomposeCreatedPoly::decomposeCreatedPoly ( - const faceList& cf, - const Map<direction>& nl + const faceList& cf, + const Map<direction>& nl ) : - cellFaces_(cf), - nodeLevel_(nl), - splitFaceNode_(cf.size()), - splitEdge_(6), - splitFace_(2*cf.size()), - decomposedFaces_(2*cf.size()), - dfe_(12), - def_(24, labelList(2)), - de_(24), - se_(24) + cellFaces_(cf), + nodeLevel_(nl), + splitFaceNode_(cf.size()), + splitEdge_(6), + splitFace_(2*cf.size()), + decomposedFaces_(2*cf.size()), + dfe_(12), + def_(24, labelList(2)), + de_(24), + se_(24) { - forAll(cf, fI) - { - splitFaceNode_[fI].setSize(cf[fI].size()); - splitFaceNode_[fI] = true; - } + forAll(cf, fI) + { + splitFaceNode_[fI].setSize(cf[fI].size()); + splitFaceNode_[fI] = true; + } } - + dualMeshExtractor::decomposeCreatedPoly::~decomposeCreatedPoly() {} @@ -581,77 +581,77 @@ dualMeshExtractor::decomposeCreatedPoly::~decomposeCreatedPoly() void dualMeshExtractor::decomposeCreatedPoly::decomposeCell ( - List<faceList>& decCells + List<faceList>& decCells ) { - //decCells.setSize(1); - //decCells[0] = cellFaces_; - - # ifdef DEBUGDual - Info << nl << "Starting decomposing cell " << cellFaces_ << endl; - # endif - - decomposeFaces(); - - if( splitEdge_.size() == 0 ) - { - decCells.setSize(1); - decCells[0] = cellFaces_; - return; - } - - calculateHelperAddressing(); - - selectAdditionalSplitEdges(); - - selectFacesForCell(decCells); - - createMissingFaces(decCells); - - # ifdef DEBUGClosedness - //- check for topological closedness - forAll(decCells, cI) - { - const faceList& cf = decCells[cI]; - - DynList<edge> cEdges(12); - DynList<direction> nAppearances(12); - - forAll(cf, fI) - { - const edgeList edges = cf[fI].edges(); - - forAll(edges, eI) - { - const label pos = cEdges.containsAtPosition(edges[eI]); - - if( pos == -1 ) - { - cEdges.append(edges[eI]); - nAppearances.append(1); - } - else - { - nAppearances[pos]++; - } - } - } - - forAll(nAppearances, eI) - if( nAppearances[eI] != 2 ) - { - Info << "Original cell is " << cellFaces_ << endl; - Info << "cell faces are " << decCells << endl; - Info << "Edges for cell " << cI << " are " - << cEdges << endl; - FatalErrorIn - ( - "void dualMeshExtractor::decomposeCreatedPoly::" - "createMissingFaces(List<faceList>&)" - ) << "Edge " << eI << " is open!!" << abort(FatalError); - } - } - # endif + //decCells.setSize(1); + //decCells[0] = cellFaces_; + + # ifdef DEBUGDual + Info << nl << "Starting decomposing cell " << cellFaces_ << endl; + # endif + + decomposeFaces(); + + if( splitEdge_.size() == 0 ) + { + decCells.setSize(1); + decCells[0] = cellFaces_; + return; + } + + calculateHelperAddressing(); + + selectAdditionalSplitEdges(); + + selectFacesForCell(decCells); + + createMissingFaces(decCells); + + # ifdef DEBUGClosedness + //- check for topological closedness + forAll(decCells, cI) + { + const faceList& cf = decCells[cI]; + + DynList<edge> cEdges(12); + DynList<direction> nAppearances(12); + + forAll(cf, fI) + { + const edgeList edges = cf[fI].edges(); + + forAll(edges, eI) + { + const label pos = cEdges.containsAtPosition(edges[eI]); + + if( pos == -1 ) + { + cEdges.append(edges[eI]); + nAppearances.append(1); + } + else + { + nAppearances[pos]++; + } + } + } + + forAll(nAppearances, eI) + if( nAppearances[eI] != 2 ) + { + Info << "Original cell is " << cellFaces_ << endl; + Info << "cell faces are " << decCells << endl; + Info << "Edges for cell " << cI << " are " + << cEdges << endl; + FatalErrorIn + ( + "void dualMeshExtractor::decomposeCreatedPoly::" + "createMissingFaces(List<faceList>&)" + ) << "Edge " << eI << " is open!!" << abort(FatalError); + } + } + # endif } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/meshLibrary/dualMesh/dualMeshExtractor/dualMeshExtractorPolyMesh.C b/meshLibrary/dualMesh/dualMeshExtractor/dualMeshExtractorPolyMesh.C index aa619262..b5f97a76 100644 --- a/meshLibrary/dualMesh/dualMeshExtractor/dualMeshExtractorPolyMesh.C +++ b/meshLibrary/dualMesh/dualMeshExtractor/dualMeshExtractorPolyMesh.C @@ -43,120 +43,120 @@ namespace Foam void dualMeshExtractor::createPoints() { - clearOut(); - - const List<direction>& boxType = octreeAddressing_.boxType(); - const meshOctree& octree = octreeAddressing_.octree(); - centreNodeLabelPtr_ = new labelListPMG(boxType.size(), -1); - labelListPMG& centreNode = *centreNodeLabelPtr_; - - const boundBox& rootBox = octree.rootBox(); - label nPoints(0); - - forAll(centreNode, boxI) - if( boxType[boxI] & meshOctreeAddressing::MESHCELL ) - centreNode[boxI] = nPoints++; - - pointFieldPMG& points = mesh_.points(); - points.setSize(nPoints); - - forAll(centreNode, boxI) - if( centreNode[boxI] != -1 ) - { - points[centreNode[boxI]] = - octree.returnLeaf(boxI).centre(rootBox); - } - + clearOut(); + + const List<direction>& boxType = octreeAddressing_.boxType(); + const meshOctree& octree = octreeAddressing_.octree(); + centreNodeLabelPtr_ = new labelListPMG(boxType.size(), -1); + labelListPMG& centreNode = *centreNodeLabelPtr_; + + const boundBox& rootBox = octree.rootBox(); + label nPoints(0); + + forAll(centreNode, boxI) + if( boxType[boxI] & meshOctreeAddressing::MESHCELL ) + centreNode[boxI] = nPoints++; + + pointFieldPMG& points = mesh_.points(); + points.setSize(nPoints); + + forAll(centreNode, boxI) + if( centreNode[boxI] != -1 ) + { + points[centreNode[boxI]] = + octree.returnLeaf(boxI).centre(rootBox); + } + } void dualMeshExtractor::createPolyMesh() { Info << "Creating polyMesh from octree" << endl; - - const meshOctree& octree = octreeAddressing_.octree(); - const labelListPMG& centreNode = *centreNodeLabelPtr_; - const FRWGraph<label, 8>& nodeLeaves = octreeAddressing_.nodeLeaves(); - - polyMeshGenModifierAddCellByCell meshModifier(mesh_); - - forAll(nodeLeaves, nodeI) - { - bool create(true); - - forAllRow(nodeLeaves, nodeI, nlI) - { - const label leafI = nodeLeaves(nodeI, nlI); - - if( (leafI == -1) || (centreNode[leafI] == -1) ) - { - create = false; - break; - } - } - - if( !create ) - continue; - - Map<direction> nodeLevel; - forAllRow(nodeLeaves, nodeI, nlI) - nodeLevel.insert - ( - centreNode[nodeLeaves(nodeI, nlI)], - octree.returnLeaf(nodeLeaves(nodeI, nlI)).level() - ); - - faceList cFaces(12); - direction fI(0); - - for(label i=0;i<6;++i) - { - DynList<label> f(4); - - for(label j=0;j<4;++j) - { - f.appendIfNotIn - ( - centreNode[nodeLeaves(nodeI, faceFlip_[i][j])] - ); - } - - if( f.size() == 4 ) - { - cFaces.newElmt(fI++) = face(f); - } - else if( f.size() == 3 ) - { - f.shrink(); - cFaces.newElmt(fI++) = face(f); - } - } - - cFaces.setSize(fI); - - # ifdef DEBUGDual - Info << "pLeaves " << pLeaves << endl; - forAll(pLeaves, plI) - Info << "Centre " << plI << " is " - << centreNode[pLeaves[plI]] << endl; - Info << "Cell faces are " << cFaces << nl << endl; - forAll(cFaces, cfI) - Info << "Face " << cfI << " normal is " - << cFaces[cfI].normal(mesh_.points()) << endl; - # endif - - List<faceList> tmpF; - decomposeCreatedPoly dcp(cFaces, nodeLevel); - dcp.decomposeCell(tmpF); - forAll(tmpF, cI) - { - # ifdef DEBUGDual - Info << cI << ". Cell " << cellI << " has faces " - << tmpF[cI] << endl; - # endif - - meshModifier.addCell(tmpF[cI]); - } - } + + const meshOctree& octree = octreeAddressing_.octree(); + const labelListPMG& centreNode = *centreNodeLabelPtr_; + const FRWGraph<label, 8>& nodeLeaves = octreeAddressing_.nodeLeaves(); + + polyMeshGenModifierAddCellByCell meshModifier(mesh_); + + forAll(nodeLeaves, nodeI) + { + bool create(true); + + forAllRow(nodeLeaves, nodeI, nlI) + { + const label leafI = nodeLeaves(nodeI, nlI); + + if( (leafI == -1) || (centreNode[leafI] == -1) ) + { + create = false; + break; + } + } + + if( !create ) + continue; + + Map<direction> nodeLevel; + forAllRow(nodeLeaves, nodeI, nlI) + nodeLevel.insert + ( + centreNode[nodeLeaves(nodeI, nlI)], + octree.returnLeaf(nodeLeaves(nodeI, nlI)).level() + ); + + faceList cFaces(12); + direction fI(0); + + for(label i=0;i<6;++i) + { + DynList<label> f(4); + + for(label j=0;j<4;++j) + { + f.appendIfNotIn + ( + centreNode[nodeLeaves(nodeI, faceFlip_[i][j])] + ); + } + + if( f.size() == 4 ) + { + cFaces.newElmt(fI++) = face(f); + } + else if( f.size() == 3 ) + { + f.shrink(); + cFaces.newElmt(fI++) = face(f); + } + } + + cFaces.setSize(fI); + + # ifdef DEBUGDual + Info << "pLeaves " << pLeaves << endl; + forAll(pLeaves, plI) + Info << "Centre " << plI << " is " + << centreNode[pLeaves[plI]] << endl; + Info << "Cell faces are " << cFaces << nl << endl; + forAll(cFaces, cfI) + Info << "Face " << cfI << " normal is " + << cFaces[cfI].normal(mesh_.points()) << endl; + # endif + + List<faceList> tmpF; + decomposeCreatedPoly dcp(cFaces, nodeLevel); + dcp.decomposeCell(tmpF); + forAll(tmpF, cI) + { + # ifdef DEBUGDual + Info << cI << ". Cell " << cellI << " has faces " + << tmpF[cI] << endl; + # endif + + meshModifier.addCell(tmpF[cI]); + } + } Info << "Finished creating polyMesh" << endl; } diff --git a/meshLibrary/dualMesh/dualMeshGenerator/dualMeshGenerator.C b/meshLibrary/dualMesh/dualMeshGenerator/dualMeshGenerator.C index 693d8124..389f496c 100644 --- a/meshLibrary/dualMesh/dualMeshGenerator/dualMeshGenerator.C +++ b/meshLibrary/dualMesh/dualMeshGenerator/dualMeshGenerator.C @@ -61,135 +61,135 @@ namespace Foam void dualMeshGenerator::generateDualMesh() { - //- create polyMesh from octree boxes - dualMeshExtractor dme(*octreePtr_, meshDict_, mesh_); - dme.createMesh(); - - # ifdef DEBUG - mesh_.write(); - # ifdef DEBUGfpma - writeMeshFPMA(mesh_, "dualMesh"); - # else - writeMeshEnsight(mesh_, "dualMesh"); - # endif - //::exit(EXIT_FAILURE); - # endif + //- create polyMesh from octree boxes + dualMeshExtractor dme(*octreePtr_, meshDict_, mesh_); + dme.createMesh(); + + # ifdef DEBUG + mesh_.write(); + # ifdef DEBUGfpma + writeMeshFPMA(mesh_, "dualMesh"); + # else + writeMeshEnsight(mesh_, "dualMesh"); + # endif + //::exit(EXIT_FAILURE); + # endif } void dualMeshGenerator::surfacePreparation() { - //- removes unnecessary cells and morph the boundary + //- removes unnecessary cells and morph the boundary //- such that there is only one boundary face per cell - //- It also checks topology of cells after morphing is performed - do - { - surfaceMorpherCells* cmPtr = new surfaceMorpherCells(mesh_); - cmPtr->morphMesh(); - deleteDemandDrivenData(cmPtr); - } while( topologicalCleaner(mesh_).cleanTopology() ); - - # ifdef DEBUG - mesh_.write(); - # ifdef DEBUGfpma - writeMeshFPMA(mesh_, "afterTopoCleaning"); - # else - writeMeshEnsight(mesh_, "afterTopoCleaning"); - # endif - //::exit(EXIT_FAILURE); - # endif + //- It also checks topology of cells after morphing is performed + do + { + surfaceMorpherCells* cmPtr = new surfaceMorpherCells(mesh_); + cmPtr->morphMesh(); + deleteDemandDrivenData(cmPtr); + } while( topologicalCleaner(mesh_).cleanTopology() ); + + # ifdef DEBUG + mesh_.write(); + # ifdef DEBUGfpma + writeMeshFPMA(mesh_, "afterTopoCleaning"); + # else + writeMeshEnsight(mesh_, "afterTopoCleaning"); + # endif + //::exit(EXIT_FAILURE); + # endif } - + void dualMeshGenerator::mapMeshToSurface() { - //- calculate mesh surface + //- calculate mesh surface meshSurfaceEngine* msePtr = new meshSurfaceEngine(mesh_); - //- map mesh surface on the geometry surface - meshSurfaceMapper(*msePtr, *octreePtr_).mapVerticesOntoSurface(); + //- map mesh surface on the geometry surface + meshSurfaceMapper(*msePtr, *octreePtr_).mapVerticesOntoSurface(); - # ifdef DEBUG - # ifdef DEBUGfpma - writeMeshFPMA(mesh_, "afterMapping"); - # else - writeMeshEnsight(mesh_, "afterMapping"); - # endif - mesh_.write(); - //::exit(EXIT_FAILURE); - # endif - - //- untangle surface faces - meshSurfaceOptimizer(*msePtr, *octreePtr_).preOptimizeSurface(); - - # ifdef DEBUG - //meshOptimizer(*octreePtr_, mesh_).preOptimize(); - # ifdef DEBUGfpma - writeMeshFPMA(mesh_, "afterSurfaceSmoothing"); - # else - writeMeshEnsight(mesh_, "afterSurfaceSmoothing"); - # endif - mesh_.write(); - //::exit(EXIT_FAILURE); - # endif - + # ifdef DEBUG + # ifdef DEBUGfpma + writeMeshFPMA(mesh_, "afterMapping"); + # else + writeMeshEnsight(mesh_, "afterMapping"); + # endif + mesh_.write(); + //::exit(EXIT_FAILURE); + # endif + + //- untangle surface faces + meshSurfaceOptimizer(*msePtr, *octreePtr_).preOptimizeSurface(); + + # ifdef DEBUG + //meshOptimizer(*octreePtr_, mesh_).preOptimize(); + # ifdef DEBUGfpma + writeMeshFPMA(mesh_, "afterSurfaceSmoothing"); + # else + writeMeshEnsight(mesh_, "afterSurfaceSmoothing"); + # endif + mesh_.write(); + //::exit(EXIT_FAILURE); + # endif + deleteDemandDrivenData(msePtr); - //- extract edges and corners - meshSurfaceEdgeExtractorNonTopo(mesh_, *octreePtr_); - - # ifdef DEBUG - mesh_.write(); - # ifdef DEBUGfpma - writeMeshFPMA(mesh_, "withEdges"); - # else - writeMeshEnsight(mesh_, "withEdges"); - #endif - //::exit(EXIT_FAILURE); - # endif + //- extract edges and corners + meshSurfaceEdgeExtractorNonTopo(mesh_, *octreePtr_); + + # ifdef DEBUG + mesh_.write(); + # ifdef DEBUGfpma + writeMeshFPMA(mesh_, "withEdges"); + # else + writeMeshEnsight(mesh_, "withEdges"); + #endif + //::exit(EXIT_FAILURE); + # endif } void dualMeshGenerator::optimiseMeshSurface() { - meshSurfaceEngine mse(mesh_); - meshSurfaceOptimizer(mse, *octreePtr_).optimizeSurface(); - - # ifdef DEBUG - mesh_.write(); - # ifdef DEBUGfpma - writeMeshFPMA(mesh_, "optSurfaceWithEdges"); - # else - writeMeshEnsight(mesh_, "optSurfaceWithEdges"); - #endif - //::exit(EXIT_FAILURE); - # endif + meshSurfaceEngine mse(mesh_); + meshSurfaceOptimizer(mse, *octreePtr_).optimizeSurface(); + + # ifdef DEBUG + mesh_.write(); + # ifdef DEBUGfpma + writeMeshFPMA(mesh_, "optSurfaceWithEdges"); + # else + writeMeshEnsight(mesh_, "optSurfaceWithEdges"); + #endif + //::exit(EXIT_FAILURE); + # endif } void dualMeshGenerator::checkConcaveEdges() { - //- optimize surface to get rid of nearby vertices - meshSurfaceEngine* msePtr = new meshSurfaceEngine(mesh_); - meshSurfaceOptimizer(*msePtr, *octreePtr_).optimizeSurface(); - deleteDemandDrivenData(msePtr); - - //- repair mesh near concave edges - dualUnfoldConcaveCells(mesh_, *octreePtr_).unfoldInvalidCells(); - - # ifdef DEBUG - mesh_.write(); - //meshOptimizer(*octreePtr_, mesh_).preOptimize(); - # ifdef DEBUGfpma - writeMeshFPMA(mesh_, "correctedEdges"); - # else - writeMeshEnsight(mesh_, "correctedEdges"); - #endif - //::exit(EXIT_FAILURE); - # endif + //- optimize surface to get rid of nearby vertices + meshSurfaceEngine* msePtr = new meshSurfaceEngine(mesh_); + meshSurfaceOptimizer(*msePtr, *octreePtr_).optimizeSurface(); + deleteDemandDrivenData(msePtr); + + //- repair mesh near concave edges + dualUnfoldConcaveCells(mesh_, *octreePtr_).unfoldInvalidCells(); + + # ifdef DEBUG + mesh_.write(); + //meshOptimizer(*octreePtr_, mesh_).preOptimize(); + # ifdef DEBUGfpma + writeMeshFPMA(mesh_, "correctedEdges"); + # else + writeMeshEnsight(mesh_, "correctedEdges"); + #endif + //::exit(EXIT_FAILURE); + # endif } - + void dualMeshGenerator::generateBoudaryLayers() { - boundaryLayers bl(mesh_); + boundaryLayers bl(mesh_); - if( meshDict_.found("boundaryLayers") ) + if( meshDict_.found("boundaryLayers") ) { wordList createLayers(meshDict_.lookup("boundaryLayers")); @@ -200,37 +200,37 @@ void dualMeshGenerator::generateBoudaryLayers() { //bl.createOTopologyLayers(); bl.addLayerForAllPatches(); - } - - # ifdef DEBUG - # ifdef DEBUGfpma - writeMeshFPMA(mesh_, "meshWithBndLayer"); - # else - writeMeshEnsight(mesh_, "meshWithBndLayer"); - # endif - mesh_.write(); - //::exit(EXIT_FAILURE); - # endif + } + + # ifdef DEBUG + # ifdef DEBUGfpma + writeMeshFPMA(mesh_, "meshWithBndLayer"); + # else + writeMeshEnsight(mesh_, "meshWithBndLayer"); + # endif + mesh_.write(); + //::exit(EXIT_FAILURE); + # endif } - + void dualMeshGenerator::optimiseFinalMesh() { - //- final optimisation - meshOptimizer optimizer(mesh_); + //- final optimisation + meshOptimizer optimizer(mesh_); optimizer.optimizeSurface(*octreePtr_); deleteDemandDrivenData(octreePtr_); optimizer.optimizeMeshFV(); - - # ifdef DEBUG - # ifdef DEBUGfpma - writeMeshFPMA(mesh_,"optimisedMesh"); - # else - writeMeshEnsight(mesh_, "optimisedMesh"); - #endif - # endif + + # ifdef DEBUG + # ifdef DEBUGfpma + writeMeshFPMA(mesh_,"optimisedMesh"); + # else + writeMeshEnsight(mesh_, "optimisedMesh"); + #endif + # endif } void dualMeshGenerator::replaceBoundaries() @@ -238,44 +238,44 @@ void dualMeshGenerator::replaceBoundaries() renameBoundaryPatches rbp(mesh_, meshDict_); # ifdef DEBUG - # ifdef DEBUGfpma - writeMeshFPMA(mesh_,"renamedPatchesMesh"); - # else - writeMeshEnsight(mesh_, "renamedPatchesMesh"); - #endif - # endif + # ifdef DEBUGfpma + writeMeshFPMA(mesh_,"renamedPatchesMesh"); + # else + writeMeshEnsight(mesh_, "renamedPatchesMesh"); + #endif + # endif } void dualMeshGenerator::renumberMesh() { - polyMeshGenModifier(mesh_).renumberMesh(); - - # ifdef DEBUG - # ifdef DEBUGfpma - writeMeshFPMA(mesh_,"renumberedMesh"); - # else - writeMeshEnsight(mesh_, "renumberedMesh"); - #endif - # endif + polyMeshGenModifier(mesh_).renumberMesh(); + + # ifdef DEBUG + # ifdef DEBUGfpma + writeMeshFPMA(mesh_,"renumberedMesh"); + # else + writeMeshEnsight(mesh_, "renumberedMesh"); + #endif + # endif } void dualMeshGenerator::generateMesh() { - generateDualMesh(); - - surfacePreparation(); - - mapMeshToSurface(); - - optimiseMeshSurface(); - - checkConcaveEdges(); - - generateBoudaryLayers(); - - optimiseFinalMesh(); - - renumberMesh(); + generateDualMesh(); + + surfacePreparation(); + + mapMeshToSurface(); + + optimiseMeshSurface(); + + checkConcaveEdges(); + + generateBoudaryLayers(); + + optimiseFinalMesh(); + + renumberMesh(); replaceBoundaries(); } @@ -302,7 +302,7 @@ dualMeshGenerator::dualMeshGenerator ) ), octreePtr_(NULL), - mesh_(runTime) + mesh_(runTime) { if( true ) checkMeshDict cmd(meshDict_); @@ -310,16 +310,16 @@ dualMeshGenerator::dualMeshGenerator const fileName surfaceFile = meshDict_.lookup("surfaceFile"); surfacePtr_ = new triSurf(runTime_.path()/surfaceFile); - - if( meshDict_.found("subsetFileName") ) - { - const fileName subsetFileName = meshDict_.lookup("subsetFileName"); - surfacePtr_->readFaceSubsets(runTime_.path()/subsetFileName); - } + + if( meshDict_.found("subsetFileName") ) + { + const fileName subsetFileName = meshDict_.lookup("subsetFileName"); + surfacePtr_->readFaceSubsets(runTime_.path()/subsetFileName); + } octreePtr_ = new meshOctree(*surfacePtr_); - - meshOctreeCreator(*octreePtr_, meshDict_).createOctreeBoxes(); + + meshOctreeCreator(*octreePtr_, meshDict_).createOctreeBoxes(); generateMesh(); } @@ -345,15 +345,15 @@ dualMeshGenerator::dualMeshGenerator ) ), octreePtr_(NULL), - mesh_(time) + mesh_(time) { fileName surfaceFile = meshDict_.lookup("surfaceFile"); surfacePtr_ = new triSurface(db_.path()/surfaceFile); octreePtr_ = new meshOctree(*surfacePtr_); - - meshOctreeCreator(*octreePtr_, meshDict_).createOctreeBoxes(); + + meshOctreeCreator(*octreePtr_, meshDict_).createOctreeBoxes(); generateMesh(); } @@ -371,12 +371,12 @@ dualMeshGenerator::~dualMeshGenerator() void dualMeshGenerator::writeMesh() const { - # ifdef DEBUG - mesh_.addressingData().checkCellsZipUp(true); - mesh_.addressingData().checkCellVolumes(true); - # endif - - mesh_.write(); + # ifdef DEBUG + mesh_.addressingData().checkCellsZipUp(true); + mesh_.addressingData().checkCellVolumes(true); + # endif + + mesh_.write(); } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/meshLibrary/dualMesh/dualMeshGenerator/dualMeshGenerator.H b/meshLibrary/dualMesh/dualMeshGenerator/dualMeshGenerator.H index 81ea1abb..cc6dfeec 100644 --- a/meshLibrary/dualMesh/dualMeshGenerator/dualMeshGenerator.H +++ b/meshLibrary/dualMesh/dualMeshGenerator/dualMeshGenerator.H @@ -68,38 +68,38 @@ class dualMeshGenerator //- pointer to the octree meshOctree* octreePtr_; - - //- mesh - polyMeshGen mesh_; + + //- mesh + polyMeshGen mesh_; // Private member functions - //- generate dual mesh - void generateDualMesh(); - - //- prepare mesh surface - void surfacePreparation(); - - //- map mesh to the surface and untangle surface - void mapMeshToSurface(); - - //- optimise surface of the mesh - void optimiseMeshSurface(); - - //- change mesh topology near concave edges - void checkConcaveEdges(); - - //- add boundary layers - void generateBoudaryLayers(); - - //- mesh optimisation - void optimiseFinalMesh(); + //- generate dual mesh + void generateDualMesh(); + + //- prepare mesh surface + void surfacePreparation(); + + //- map mesh to the surface and untangle surface + void mapMeshToSurface(); + + //- optimise surface of the mesh + void optimiseMeshSurface(); + + //- change mesh topology near concave edges + void checkConcaveEdges(); + + //- add boundary layers + void generateBoudaryLayers(); + + //- mesh optimisation + void optimiseFinalMesh(); //- replace boundaries void replaceBoundaries(); - - //- renumber the mesh - void renumberMesh(); - + + //- renumber the mesh + void renumberMesh(); + //- generate mesh void generateMesh(); diff --git a/meshLibrary/dualMesh/dualUnfoldConcaveCells/dualUnfoldConcaveCells.C b/meshLibrary/dualMesh/dualUnfoldConcaveCells/dualUnfoldConcaveCells.C index a0d788d8..24b1e885 100644 --- a/meshLibrary/dualMesh/dualUnfoldConcaveCells/dualUnfoldConcaveCells.C +++ b/meshLibrary/dualMesh/dualUnfoldConcaveCells/dualUnfoldConcaveCells.C @@ -43,27 +43,27 @@ Description namespace Foam { - + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - + void dualUnfoldConcaveCells::replaceBoundary() { - const PtrList<writePatch>& boundaries = mesh_.boundaries(); - wordList patchNames(boundaries.size()); - forAll(boundaries, patchI) - patchNames[patchI] = boundaries[patchI].patchName(); - - polyMeshGenModifier meshModifier(mesh_); - meshModifier.replaceBoundary - ( - patchNames, - newBoundaryFaces_, - newBoundaryOwners_, - newBoundaryPatches_ - ); - - newBoundaryFaces_.setSize(0); - newBoundaryOwners_.setSize(0); + const PtrList<writePatch>& boundaries = mesh_.boundaries(); + wordList patchNames(boundaries.size()); + forAll(boundaries, patchI) + patchNames[patchI] = boundaries[patchI].patchName(); + + polyMeshGenModifier meshModifier(mesh_); + meshModifier.replaceBoundary + ( + patchNames, + newBoundaryFaces_, + newBoundaryOwners_, + newBoundaryPatches_ + ); + + newBoundaryFaces_.setSize(0); + newBoundaryOwners_.setSize(0); } // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // @@ -71,19 +71,19 @@ void dualUnfoldConcaveCells::replaceBoundary() // Construct from polyMeshGen dualUnfoldConcaveCells::dualUnfoldConcaveCells ( - polyMeshGen& mesh, - const meshOctree& octree + polyMeshGen& mesh, + const meshOctree& octree ) : - mesh_(mesh), - octree_(octree), - typeOfCell_(mesh.cells().size(), INTERNALCELL), - typeOfVertex_(mesh.points().size(), NONE), - newBoundaryFaces_(), - newBoundaryOwners_(), - newBoundaryPatches_() + mesh_(mesh), + octree_(octree), + typeOfCell_(mesh.cells().size(), INTERNALCELL), + typeOfVertex_(mesh.points().size(), NONE), + newBoundaryFaces_(), + newBoundaryOwners_(), + newBoundaryPatches_() { - mesh_.clearAddressingData(); + mesh_.clearAddressingData(); } // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // @@ -96,45 +96,45 @@ dualUnfoldConcaveCells::~dualUnfoldConcaveCells() void dualUnfoldConcaveCells::unfoldInvalidCells() { - const meshSurfaceEngine* msePtr = new meshSurfaceEngine(mesh_); - - if( findConcaveEdges(*msePtr) ) - { - markVertexTypes(*msePtr); - - storeAndMergeBoundaryFaces(*msePtr); - - createNeighbouringBoundaryFaces(*msePtr); - - storeRemainingBoundaryFaces(*msePtr); - - removeConcaveVerticesFromIntFaces(*msePtr); - - deleteDemandDrivenData(msePtr); - - replaceBoundary(); - - checkAndRepairBoundary(); - - polyMeshGenModifier(mesh_).removeUnusedVertices(); - - # ifdef DEBUGEdges - mesh_.addressingData().checkMesh(true); - mesh_.write(); - ::exit(EXIT_FAILURE); - # endif - - correctEdgesBetweenPatches correctEdges(mesh_); + const meshSurfaceEngine* msePtr = new meshSurfaceEngine(mesh_); + + if( findConcaveEdges(*msePtr) ) + { + markVertexTypes(*msePtr); + + storeAndMergeBoundaryFaces(*msePtr); + + createNeighbouringBoundaryFaces(*msePtr); + + storeRemainingBoundaryFaces(*msePtr); + + removeConcaveVerticesFromIntFaces(*msePtr); + + deleteDemandDrivenData(msePtr); + + replaceBoundary(); + + checkAndRepairBoundary(); + + polyMeshGenModifier(mesh_).removeUnusedVertices(); + + # ifdef DEBUGEdges + mesh_.addressingData().checkMesh(true); + mesh_.write(); + ::exit(EXIT_FAILURE); + # endif + + correctEdgesBetweenPatches correctEdges(mesh_); meshSurfaceMapper(*msePtr, octree_).mapCornersAndEdges(); - - # ifdef DEBUGEdges - mesh_.addressingData().checkMesh(); - # endif - } - else - { - deleteDemandDrivenData(msePtr); - } + + # ifdef DEBUGEdges + mesh_.addressingData().checkMesh(); + # endif + } + else + { + deleteDemandDrivenData(msePtr); + } } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/meshLibrary/dualMesh/dualUnfoldConcaveCells/dualUnfoldConcaveCells.H b/meshLibrary/dualMesh/dualUnfoldConcaveCells/dualUnfoldConcaveCells.H index 10bc57db..e8eb0cad 100644 --- a/meshLibrary/dualMesh/dualUnfoldConcaveCells/dualUnfoldConcaveCells.H +++ b/meshLibrary/dualMesh/dualUnfoldConcaveCells/dualUnfoldConcaveCells.H @@ -27,8 +27,8 @@ Class Description Checks for concave cells near surface edges. Removes vertices and merges - faces in order to untangle the mesh - + faces in order to untangle the mesh + SourceFiles dualUnfoldConcaveCells.C @@ -44,7 +44,7 @@ SourceFiles namespace Foam { - + class meshSurfaceEngine; class meshOctree; @@ -55,72 +55,72 @@ class meshOctree; class dualUnfoldConcaveCells { // Private data - //- reference to the mesh - polyMeshGen& mesh_; - - //- reference to the octree - const meshOctree& octree_; - - //- list containing classification of cell type - List<direction> typeOfCell_; - - //- list containing classification of vertex type - List<direction> typeOfVertex_; - - //- new boundary faces and owner cells - VRWGraph newBoundaryFaces_; - labelListPMG newBoundaryOwners_; - labelListPMG newBoundaryPatches_; + //- reference to the mesh + polyMeshGen& mesh_; + + //- reference to the octree + const meshOctree& octree_; + + //- list containing classification of cell type + List<direction> typeOfCell_; + + //- list containing classification of vertex type + List<direction> typeOfVertex_; + + //- new boundary faces and owner cells + VRWGraph newBoundaryFaces_; + labelListPMG newBoundaryOwners_; + labelListPMG newBoundaryPatches_; // Private member functions - //- find edges to remove - bool findConcaveEdges(const meshSurfaceEngine& mse); - - //- mark vertices according to their type - void markVertexTypes(const meshSurfaceEngine& mse); - - //- merge boundary faces of the given cell - label mergeBoundaryFacesOfCell(const label cellI); - - //- merge boundary faces of concave cells - void storeAndMergeBoundaryFaces(const meshSurfaceEngine& mse); - - //- create boundary faces for cells next to concave ones - void createNeighbouringBoundaryFaces(const meshSurfaceEngine& mse); - - //- store remaining boundary faces which have not been altered - void storeRemainingBoundaryFaces(const meshSurfaceEngine& mse); - - //- remove concave vertices from internal faces - void removeConcaveVerticesFromIntFaces(const meshSurfaceEngine& mse); - - //- replace mesh boundary with the newly created boundary faces - void replaceBoundary(); - - //- perform a check to determine if all vertices have been removed - //- correctly, and that all treated cells are topologically closed - void checkAndRepairBoundary(); - - // Enumerations - - enum vertexType_ - { - NONE = 0, - CONCAVE = 1, - EDGE = 2, - CORNER = 4, - MOVED = 8, - REMOVE = 16 - }; - - enum cellType_ - { - INTERNALCELL = 0, - BOUNDARYCELL = 1, - CONCAVECELL = 2, - TREATEDCELL = 4, - MERGEDCELL = 8 - }; + //- find edges to remove + bool findConcaveEdges(const meshSurfaceEngine& mse); + + //- mark vertices according to their type + void markVertexTypes(const meshSurfaceEngine& mse); + + //- merge boundary faces of the given cell + label mergeBoundaryFacesOfCell(const label cellI); + + //- merge boundary faces of concave cells + void storeAndMergeBoundaryFaces(const meshSurfaceEngine& mse); + + //- create boundary faces for cells next to concave ones + void createNeighbouringBoundaryFaces(const meshSurfaceEngine& mse); + + //- store remaining boundary faces which have not been altered + void storeRemainingBoundaryFaces(const meshSurfaceEngine& mse); + + //- remove concave vertices from internal faces + void removeConcaveVerticesFromIntFaces(const meshSurfaceEngine& mse); + + //- replace mesh boundary with the newly created boundary faces + void replaceBoundary(); + + //- perform a check to determine if all vertices have been removed + //- correctly, and that all treated cells are topologically closed + void checkAndRepairBoundary(); + + // Enumerations + + enum vertexType_ + { + NONE = 0, + CONCAVE = 1, + EDGE = 2, + CORNER = 4, + MOVED = 8, + REMOVE = 16 + }; + + enum cellType_ + { + INTERNALCELL = 0, + BOUNDARYCELL = 1, + CONCAVECELL = 2, + TREATEDCELL = 4, + MERGEDCELL = 8 + }; //- Disallow default bitwise copy construct dualUnfoldConcaveCells(const dualUnfoldConcaveCells&); @@ -134,8 +134,8 @@ public: //- Construct from polyMeshGen dualUnfoldConcaveCells ( - polyMeshGen& mesh, - const meshOctree& octree + polyMeshGen& mesh, + const meshOctree& octree ); // Destructor @@ -143,8 +143,8 @@ public: ~dualUnfoldConcaveCells(); // Member Functions - //- clean topologically problematic cells - void unfoldInvalidCells(); + //- clean topologically problematic cells + void unfoldInvalidCells(); }; diff --git a/meshLibrary/dualMesh/dualUnfoldConcaveCells/dualUnfoldConcaveCellsMergeFaces.C b/meshLibrary/dualMesh/dualUnfoldConcaveCells/dualUnfoldConcaveCellsMergeFaces.C index ffcda4a5..aab40d84 100644 --- a/meshLibrary/dualMesh/dualUnfoldConcaveCells/dualUnfoldConcaveCellsMergeFaces.C +++ b/meshLibrary/dualMesh/dualUnfoldConcaveCells/dualUnfoldConcaveCellsMergeFaces.C @@ -50,262 +50,262 @@ namespace Foam bool dualUnfoldConcaveCells::findConcaveEdges(const meshSurfaceEngine& mse) { - const pointFieldPMG& points = mesh_.points(); - const faceList::subList& bFaces = mse.boundaryFaces(); - const edgeList& edges = mse.edges(); - const VRWGraph& edgeFaces = mse.edgeFaces(); - const labelList& faceOwner = mse.faceOwners(); - const labelList& facePatch = mse.boundaryFacePatches(); - - //- mark all boundary cells - forAll(faceOwner, bfI) - typeOfCell_[faceOwner[bfI]] |= BOUNDARYCELL; - - //- find concave cells - bool foundConcave(false); - forAll(edgeFaces, edgeI) - { - const label fOwn = edgeFaces(edgeI, 0); - const label fNei = edgeFaces(edgeI, 1); - - if( - (faceOwner[fOwn] == faceOwner[fNei]) && - (facePatch[fOwn] != facePatch[fNei]) - ) - { - if( !help::isSharedEdgeConvex(points, bFaces[fOwn], bFaces[fNei]) ) - { - foundConcave = true; - - const edge& e = edges[edgeI]; - typeOfVertex_[e.start()] |= CONCAVE; - typeOfVertex_[e.end()] |= CONCAVE; - - typeOfCell_[faceOwner[fOwn]] |= CONCAVECELL; - } - } - } - - # ifdef DEBUGEdges - cellSet badCells - ( - IOobject - ( - "concaveCells", - mesh_.returnRegistry().time().constant(), - "polyMesh/sets", - mesh_.returnRegistry() - ) - ); - - forAll(typeOfCell_, cI) - if( typeOfCell_[cI] & CONCAVECELL ) - badCells.insert(cI); - - badCells.write(); - //::exit(1); - # endif - - return foundConcave; + const pointFieldPMG& points = mesh_.points(); + const faceList::subList& bFaces = mse.boundaryFaces(); + const edgeList& edges = mse.edges(); + const VRWGraph& edgeFaces = mse.edgeFaces(); + const labelList& faceOwner = mse.faceOwners(); + const labelList& facePatch = mse.boundaryFacePatches(); + + //- mark all boundary cells + forAll(faceOwner, bfI) + typeOfCell_[faceOwner[bfI]] |= BOUNDARYCELL; + + //- find concave cells + bool foundConcave(false); + forAll(edgeFaces, edgeI) + { + const label fOwn = edgeFaces(edgeI, 0); + const label fNei = edgeFaces(edgeI, 1); + + if( + (faceOwner[fOwn] == faceOwner[fNei]) && + (facePatch[fOwn] != facePatch[fNei]) + ) + { + if( !help::isSharedEdgeConvex(points, bFaces[fOwn], bFaces[fNei]) ) + { + foundConcave = true; + + const edge& e = edges[edgeI]; + typeOfVertex_[e.start()] |= CONCAVE; + typeOfVertex_[e.end()] |= CONCAVE; + + typeOfCell_[faceOwner[fOwn]] |= CONCAVECELL; + } + } + } + + # ifdef DEBUGEdges + cellSet badCells + ( + IOobject + ( + "concaveCells", + mesh_.returnRegistry().time().constant(), + "polyMesh/sets", + mesh_.returnRegistry() + ) + ); + + forAll(typeOfCell_, cI) + if( typeOfCell_[cI] & CONCAVECELL ) + badCells.insert(cI); + + badCells.write(); + //::exit(1); + # endif + + return foundConcave; } void dualUnfoldConcaveCells::markVertexTypes(const meshSurfaceEngine& mse) -{ - const labelList& bPoints = mse.boundaryPoints(); - const VRWGraph& pointFaces = mse.pointFaces(); - const labelList& facePatch = mse.boundaryFacePatches(); - - forAll(pointFaces, bpI) - { - DynList<label> patches(5); - forAllRow(pointFaces, bpI, pfI) - patches.appendIfNotIn(facePatch[pointFaces(bpI, pfI)]); - - if( patches.size() > 2 ) - { - typeOfVertex_[bPoints[bpI]] |= CORNER; - } - else if( patches.size() == 2 ) - { - typeOfVertex_[bPoints[bpI]] |= EDGE; - } - } +{ + const labelList& bPoints = mse.boundaryPoints(); + const VRWGraph& pointFaces = mse.pointFaces(); + const labelList& facePatch = mse.boundaryFacePatches(); + + forAll(pointFaces, bpI) + { + DynList<label> patches(5); + forAllRow(pointFaces, bpI, pfI) + patches.appendIfNotIn(facePatch[pointFaces(bpI, pfI)]); + + if( patches.size() > 2 ) + { + typeOfVertex_[bPoints[bpI]] |= CORNER; + } + else if( patches.size() == 2 ) + { + typeOfVertex_[bPoints[bpI]] |= EDGE; + } + } } label dualUnfoldConcaveCells::mergeBoundaryFacesOfCell(const label cellI) { - if( typeOfCell_[cellI] & MERGEDCELL ) - { - FatalErrorIn - ( - "label dualUnfoldConcaveCells::" - "mergeBoundaryFacesOfCell(const label cellI)" - ) << "Cell " << cellI << " has already been merged!" - << abort(FatalError); - } - else - { - typeOfCell_[cellI] |= MERGEDCELL; - } - - const pointFieldPMG& points = mesh_.points(); - const faceListPMG& faces = mesh_.faces(); - const cell& c = mesh_.cells()[cellI]; - - DynList<face> bFaces(5); - DynList<label> facePatch(5); - - //- find boundary faces and corresponding patches - forAll(c, fI) - { - const label fPatch = mesh_.faceIsInPatch(c[fI]); - - if( fPatch != -1 ) - { - bFaces.append(faces[c[fI]]); - facePatch.append(fPatch); - } - } - - # ifdef DEBUGEdges - Info << "Boundary faces for cell " << cellI << " are " << bFaces << endl; - Info << "Patches for boundary faces are " << facePatch << endl; - # endif - - //- merge all boundary faces into one face - //- this assumes that there was originally only one - //- boundary face per cell. This is the cases after running - //- surface morpher and topological cleaner - boolList isFaceMerged(bFaces.size(), false); - face mf(bFaces[0]); - isFaceMerged[0] = true; - bool merged; - do - { - merged = false; - for(label i=1;i<bFaces.size();++i) - if( - !isFaceMerged[i] && - help::shareAnEdge(mf, bFaces[i]) - ) - { - merged = true; - isFaceMerged[i] = true; - mf = help::mergeTwoFaces(mf, bFaces[i]); - } - } while( merged ); - - # ifdef DEBUGEdges - Info << "Merged face for cell is " << mf << endl; - # endif - - DynList<label> shrinkedFace(mf.size()); - forAll(mf, pI) - if( !(typeOfVertex_[mf[pI]] & EDGE) ) - { - shrinkedFace.append(mf[pI]); - } - else - { - # ifdef DEBUGEdges - Info << "Marking vertex " << mf[pI] << " for removal!" << endl; - # endif - - typeOfVertex_[mf[pI]] |= REMOVE; - } - - shrinkedFace.shrink(); - - //- face will be stored into a patch corresponding - //- to the largest face - label fPatch(facePatch[0]); - scalar size(0.0); - forAll(bFaces, bfI) - { - # ifdef DEBUGEdges - Info << "Sizes of bundary face " << bfI << " is " - << bFaces[bfI].mag(points) << endl; - # endif - - if( bFaces[bfI].mag(points) > size ) - { - fPatch = facePatch[bfI]; - size = bFaces[bfI].mag(points); - } - } - - //- store shrinked face - # ifdef DEBUGEdges - Info << "Storing face " << shrinkedFace << " in patch" - << fPatch << endl; - #endif - - newBoundaryFaces_.appendList(face(shrinkedFace)); - newBoundaryOwners_.append(cellI); - newBoundaryPatches_.append(fPatch); - - return fPatch; + if( typeOfCell_[cellI] & MERGEDCELL ) + { + FatalErrorIn + ( + "label dualUnfoldConcaveCells::" + "mergeBoundaryFacesOfCell(const label cellI)" + ) << "Cell " << cellI << " has already been merged!" + << abort(FatalError); + } + else + { + typeOfCell_[cellI] |= MERGEDCELL; + } + + const pointFieldPMG& points = mesh_.points(); + const faceListPMG& faces = mesh_.faces(); + const cell& c = mesh_.cells()[cellI]; + + DynList<face> bFaces(5); + DynList<label> facePatch(5); + + //- find boundary faces and corresponding patches + forAll(c, fI) + { + const label fPatch = mesh_.faceIsInPatch(c[fI]); + + if( fPatch != -1 ) + { + bFaces.append(faces[c[fI]]); + facePatch.append(fPatch); + } + } + + # ifdef DEBUGEdges + Info << "Boundary faces for cell " << cellI << " are " << bFaces << endl; + Info << "Patches for boundary faces are " << facePatch << endl; + # endif + + //- merge all boundary faces into one face + //- this assumes that there was originally only one + //- boundary face per cell. This is the cases after running + //- surface morpher and topological cleaner + boolList isFaceMerged(bFaces.size(), false); + face mf(bFaces[0]); + isFaceMerged[0] = true; + bool merged; + do + { + merged = false; + for(label i=1;i<bFaces.size();++i) + if( + !isFaceMerged[i] && + help::shareAnEdge(mf, bFaces[i]) + ) + { + merged = true; + isFaceMerged[i] = true; + mf = help::mergeTwoFaces(mf, bFaces[i]); + } + } while( merged ); + + # ifdef DEBUGEdges + Info << "Merged face for cell is " << mf << endl; + # endif + + DynList<label> shrinkedFace(mf.size()); + forAll(mf, pI) + if( !(typeOfVertex_[mf[pI]] & EDGE) ) + { + shrinkedFace.append(mf[pI]); + } + else + { + # ifdef DEBUGEdges + Info << "Marking vertex " << mf[pI] << " for removal!" << endl; + # endif + + typeOfVertex_[mf[pI]] |= REMOVE; + } + + shrinkedFace.shrink(); + + //- face will be stored into a patch corresponding + //- to the largest face + label fPatch(facePatch[0]); + scalar size(0.0); + forAll(bFaces, bfI) + { + # ifdef DEBUGEdges + Info << "Sizes of bundary face " << bfI << " is " + << bFaces[bfI].mag(points) << endl; + # endif + + if( bFaces[bfI].mag(points) > size ) + { + fPatch = facePatch[bfI]; + size = bFaces[bfI].mag(points); + } + } + + //- store shrinked face + # ifdef DEBUGEdges + Info << "Storing face " << shrinkedFace << " in patch" + << fPatch << endl; + #endif + + newBoundaryFaces_.appendList(face(shrinkedFace)); + newBoundaryOwners_.append(cellI); + newBoundaryPatches_.append(fPatch); + + return fPatch; } void dualUnfoldConcaveCells::storeAndMergeBoundaryFaces ( - const meshSurfaceEngine& mse + const meshSurfaceEngine& mse ) { - bool addSelected; - do - { - addSelected = false; - - //- merge boundary faces for concave cells - forAll(typeOfCell_, cellI) - if( (typeOfCell_[cellI] & CONCAVECELL) && - !(typeOfCell_[cellI] & TREATEDCELL) - ) - { - # ifdef DEBUGEdges - Info << "Merging faces of concave cell " << cellI << endl; - # endif - - mergeBoundaryFacesOfCell(cellI); - - //- set flag that the cell has been treated - typeOfCell_[cellI] |= TREATEDCELL; - } - - const VRWGraph& edgeFaces = mse.edgeFaces(); - const edgeList& edges = mse.edges(); - const labelList& faceOwner = mse.faceOwners(); - const labelList& facePatch = mse.boundaryFacePatches(); - forAll(edgeFaces, edgeI) - { - const label fOwn = edgeFaces(edgeI, 0); - const label fNei = edgeFaces(edgeI, 1); - - if( - (faceOwner[fOwn] == faceOwner[fNei]) && - (facePatch[fOwn] != facePatch[fNei]) - ) - { - const edge& e = edges[edgeI]; - if( - (typeOfVertex_[e[0]] & REMOVE) && - (typeOfVertex_[e[1]] & REMOVE) && - !(typeOfCell_[faceOwner[fOwn]] & CONCAVECELL) - ) - { - typeOfCell_[faceOwner[fOwn]] |= CONCAVECELL; - addSelected = true; - - # ifdef DEBUGEdges - Info << "Cell " << faceOwner[fOwn] << " is also concave" - << endl; - # endif - } - } - } - } - while( addSelected ); + bool addSelected; + do + { + addSelected = false; + + //- merge boundary faces for concave cells + forAll(typeOfCell_, cellI) + if( (typeOfCell_[cellI] & CONCAVECELL) && + !(typeOfCell_[cellI] & TREATEDCELL) + ) + { + # ifdef DEBUGEdges + Info << "Merging faces of concave cell " << cellI << endl; + # endif + + mergeBoundaryFacesOfCell(cellI); + + //- set flag that the cell has been treated + typeOfCell_[cellI] |= TREATEDCELL; + } + + const VRWGraph& edgeFaces = mse.edgeFaces(); + const edgeList& edges = mse.edges(); + const labelList& faceOwner = mse.faceOwners(); + const labelList& facePatch = mse.boundaryFacePatches(); + forAll(edgeFaces, edgeI) + { + const label fOwn = edgeFaces(edgeI, 0); + const label fNei = edgeFaces(edgeI, 1); + + if( + (faceOwner[fOwn] == faceOwner[fNei]) && + (facePatch[fOwn] != facePatch[fNei]) + ) + { + const edge& e = edges[edgeI]; + if( + (typeOfVertex_[e[0]] & REMOVE) && + (typeOfVertex_[e[1]] & REMOVE) && + !(typeOfCell_[faceOwner[fOwn]] & CONCAVECELL) + ) + { + typeOfCell_[faceOwner[fOwn]] |= CONCAVECELL; + addSelected = true; + + # ifdef DEBUGEdges + Info << "Cell " << faceOwner[fOwn] << " is also concave" + << endl; + # endif + } + } + } + } + while( addSelected ); } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/meshLibrary/dualMesh/dualUnfoldConcaveCells/dualUnfoldConcaveCellsMergeFacesConsistency.C b/meshLibrary/dualMesh/dualUnfoldConcaveCells/dualUnfoldConcaveCellsMergeFacesConsistency.C index 3aad4c25..39d39296 100644 --- a/meshLibrary/dualMesh/dualUnfoldConcaveCells/dualUnfoldConcaveCellsMergeFacesConsistency.C +++ b/meshLibrary/dualMesh/dualUnfoldConcaveCells/dualUnfoldConcaveCellsMergeFacesConsistency.C @@ -50,355 +50,355 @@ namespace Foam void dualUnfoldConcaveCells::createNeighbouringBoundaryFaces ( - const meshSurfaceEngine& mse + const meshSurfaceEngine& mse ) { - const labelList& bPoints = mse.boundaryPoints(); - const VRWGraph& pointFaces = mse.pointFaces(); - const labelList& faceOwner = mse.faceOwners(); - const labelList& bp = mse.bp(); - - //- find the patch for merged faces which belong to the given cell - //- this here assumes that the original cell before edge extraction - //- has only one boundary face!! This is the case if surface preparation - //- is applied before edge extraction - labelListPMG newPatchForCell(mesh_.cells().size(), -1); - forAll(newBoundaryFaces_, faceI) - { - if( newPatchForCell[newBoundaryOwners_[faceI]] == -1 ) - { - newPatchForCell[newBoundaryOwners_[faceI]] = - newBoundaryPatches_[faceI]; - } - else - { - FatalErrorIn - ( - "void dualUnfoldConcaveCells::" - "createNeighbouringBoundaryFaces(const meshSurfaceEngine&)" - ) << "Cell " << newBoundaryOwners_[faceI] - << " has more than one " - << " boundary face! Cannot proceed!" << abort(FatalError); - } - } + const labelList& bPoints = mse.boundaryPoints(); + const VRWGraph& pointFaces = mse.pointFaces(); + const labelList& faceOwner = mse.faceOwners(); + const labelList& bp = mse.bp(); + + //- find the patch for merged faces which belong to the given cell + //- this here assumes that the original cell before edge extraction + //- has only one boundary face!! This is the case if surface preparation + //- is applied before edge extraction + labelListPMG newPatchForCell(mesh_.cells().size(), -1); + forAll(newBoundaryFaces_, faceI) + { + if( newPatchForCell[newBoundaryOwners_[faceI]] == -1 ) + { + newPatchForCell[newBoundaryOwners_[faceI]] = + newBoundaryPatches_[faceI]; + } + else + { + FatalErrorIn + ( + "void dualUnfoldConcaveCells::" + "createNeighbouringBoundaryFaces(const meshSurfaceEngine&)" + ) << "Cell " << newBoundaryOwners_[faceI] + << " has more than one " + << " boundary face! Cannot proceed!" << abort(FatalError); + } + } - //- create a list of possible candidates to store - labelListPMG front; - forAll(bPoints, bpI) - if( typeOfVertex_[bPoints[bpI]] & REMOVE ) - { - front.append(bpI); - } - - # ifdef DEBUGEdges - Info << "Front points " << front << endl; - # endif - - //- start creating new boundary faces - const cellListPMG& cells = mesh_.cells(); - const faceListPMG& faces = mesh_.faces(); - - while( front.size() != 0 ) - { - labelListPMG newFront; - - forAll(front, fpI) - { - const label fLabel = front[fpI]; - - label cellI(-1), patchOfTreated(-1); - forAllRow(pointFaces, fLabel, pfI) - { - const label pfLabel = pointFaces(fLabel, pfI); - - if( - typeOfCell_[faceOwner[pfLabel]] == - BOUNDARYCELL - ) - { - cellI = faceOwner[pfLabel]; + //- create a list of possible candidates to store + labelListPMG front; + forAll(bPoints, bpI) + if( typeOfVertex_[bPoints[bpI]] & REMOVE ) + { + front.append(bpI); + } + + # ifdef DEBUGEdges + Info << "Front points " << front << endl; + # endif + + //- start creating new boundary faces + const cellListPMG& cells = mesh_.cells(); + const faceListPMG& faces = mesh_.faces(); + + while( front.size() != 0 ) + { + labelListPMG newFront; + + forAll(front, fpI) + { + const label fLabel = front[fpI]; + + label cellI(-1), patchOfTreated(-1); + forAllRow(pointFaces, fLabel, pfI) + { + const label pfLabel = pointFaces(fLabel, pfI); + + if( + typeOfCell_[faceOwner[pfLabel]] == + BOUNDARYCELL + ) + { + cellI = faceOwner[pfLabel]; - } - else if( newPatchForCell[faceOwner[pfLabel]] != -1 ) - { - patchOfTreated = newPatchForCell[faceOwner[pfLabel]]; - } - } - - if( cellI == -1 ) - continue; - - typeOfCell_[cellI] |= TREATEDCELL; - - # ifdef DEBUGEdges - Info << "Checking cell " << cellI << endl; - Info << "Patch of treated " << patchOfTreated << endl; - Info << "Front point " << bPoints[front[fpI]] << endl; - # endif - - //- find boundary faces for the given cell - DynList<face> bFaces(5); - DynList<label> facePatch(5); - forAll(cells[cellI], fI) - { - const label patch = mesh_.faceIsInPatch(cells[cellI][fI]); - if( patch != -1 ) - { - bFaces.append(faces[cells[cellI][fI]]); - facePatch.append(patch); - } - } - - # ifdef DEBUGEdges - Info << "Boundary faces " << bFaces << endl; - Info << "Face patches " << facePatch << endl; - # endif - - //- check if faces have to be merged - bool merge(false); - forAll(bFaces, bfI) - { - const face& f = bFaces[bfI]; - direction nPointsInFace(0); - - # ifdef DEBUGEdges - DynList<label> removePoint(2); - # endif - - forAll(f, pI) - if( !(typeOfVertex_[f[pI]] & REMOVE) ) - { - ++nPointsInFace; - } - # ifdef DEBUGEdges - else - { - removePoint.append(f[pI]); - } - # endif - - # ifdef DEBUGEdges - Info << "Vertices removed from boundary face " << bfI - << " are " << removePoint << endl; - # endif - - if( nPointsInFace < 3 ) - { - merge = true; - break; - } - } - - if( (patchOfTreated == -1) || !facePatch.contains(patchOfTreated) ) - merge = true; - - if( merge ) - { - # ifdef DEBUGEdges - Info << "Merging boundary faces of cell" << endl; - # endif - //- merge boundary faces of the given cell - newPatchForCell[cellI] = mergeBoundaryFacesOfCell(cellI); - - forAll(bFaces, bfI) - { - const face& f = bFaces[bfI]; - forAll(f, pI) - if( typeOfVertex_[f[pI]] & REMOVE ) - newFront.append(bp[f[pI]]); - } - } - else - { - # ifdef DEBUGEdges - Info << "Changing boundary faces" << endl; - # endif - - //- change boundary faces - face triF(3); - forAll(bFaces, bfI) - if( facePatch[bfI] != patchOfTreated ) - { - const face& bf = bFaces[bfI]; - //- remove edge vertex from face not it the same patch - //- as already treated cell - face newBf(bf.size() - 1); - label rpos(-1), pJ(0); - forAll(bf, pI) - if( typeOfVertex_[bf[pI]] & REMOVE ) - { - rpos = pI; - } - else - { - newBf.newElmt(pJ++) = bf[pI]; - } - - //- store shrinked boundary face - newBf.setSize(pJ); - newBoundaryFaces_.appendList(newBf); - newBoundaryOwners_.append(cellI); - newBoundaryPatches_.append(facePatch[bfI]); - - if( rpos != -1 ) - { - triF[0] = bf.prevLabel(rpos); - triF[1] = bf[rpos]; - triF[2] = bf.nextLabel(rpos); - - # ifdef DEBUGEdges - Info << "triF " << triF << endl; - # endif - } - } - - forAll(bFaces, bfI) - if( facePatch[bfI] == patchOfTreated ) - { - //- merge face with triF and store it - const face mf = help::mergeTwoFaces(bFaces[bfI], triF); - - # ifdef DEBUGEdges - Info << "Merged face " << mf << endl; - # endif - - face shrinkedFace(mf.size() -1); - direction i(0); - forAll(mf, pI) - if( !(typeOfVertex_[mf[pI]] & REMOVE) ) - shrinkedFace[i++] = mf[pI]; - - # ifdef DEBUGEdges - Info << "Storing face " << shrinkedFace << " into patch" - << patchOfTreated << endl; - # endif - - newBoundaryFaces_.appendList(shrinkedFace); - newBoundaryOwners_.append(cellI); - newBoundaryPatches_.append(patchOfTreated); - } - } - } - - front = newFront; - } + } + else if( newPatchForCell[faceOwner[pfLabel]] != -1 ) + { + patchOfTreated = newPatchForCell[faceOwner[pfLabel]]; + } + } + + if( cellI == -1 ) + continue; + + typeOfCell_[cellI] |= TREATEDCELL; + + # ifdef DEBUGEdges + Info << "Checking cell " << cellI << endl; + Info << "Patch of treated " << patchOfTreated << endl; + Info << "Front point " << bPoints[front[fpI]] << endl; + # endif + + //- find boundary faces for the given cell + DynList<face> bFaces(5); + DynList<label> facePatch(5); + forAll(cells[cellI], fI) + { + const label patch = mesh_.faceIsInPatch(cells[cellI][fI]); + if( patch != -1 ) + { + bFaces.append(faces[cells[cellI][fI]]); + facePatch.append(patch); + } + } + + # ifdef DEBUGEdges + Info << "Boundary faces " << bFaces << endl; + Info << "Face patches " << facePatch << endl; + # endif + + //- check if faces have to be merged + bool merge(false); + forAll(bFaces, bfI) + { + const face& f = bFaces[bfI]; + direction nPointsInFace(0); + + # ifdef DEBUGEdges + DynList<label> removePoint(2); + # endif + + forAll(f, pI) + if( !(typeOfVertex_[f[pI]] & REMOVE) ) + { + ++nPointsInFace; + } + # ifdef DEBUGEdges + else + { + removePoint.append(f[pI]); + } + # endif + + # ifdef DEBUGEdges + Info << "Vertices removed from boundary face " << bfI + << " are " << removePoint << endl; + # endif + + if( nPointsInFace < 3 ) + { + merge = true; + break; + } + } + + if( (patchOfTreated == -1) || !facePatch.contains(patchOfTreated) ) + merge = true; + + if( merge ) + { + # ifdef DEBUGEdges + Info << "Merging boundary faces of cell" << endl; + # endif + //- merge boundary faces of the given cell + newPatchForCell[cellI] = mergeBoundaryFacesOfCell(cellI); + + forAll(bFaces, bfI) + { + const face& f = bFaces[bfI]; + forAll(f, pI) + if( typeOfVertex_[f[pI]] & REMOVE ) + newFront.append(bp[f[pI]]); + } + } + else + { + # ifdef DEBUGEdges + Info << "Changing boundary faces" << endl; + # endif + + //- change boundary faces + face triF(3); + forAll(bFaces, bfI) + if( facePatch[bfI] != patchOfTreated ) + { + const face& bf = bFaces[bfI]; + //- remove edge vertex from face not it the same patch + //- as already treated cell + face newBf(bf.size() - 1); + label rpos(-1), pJ(0); + forAll(bf, pI) + if( typeOfVertex_[bf[pI]] & REMOVE ) + { + rpos = pI; + } + else + { + newBf.newElmt(pJ++) = bf[pI]; + } + + //- store shrinked boundary face + newBf.setSize(pJ); + newBoundaryFaces_.appendList(newBf); + newBoundaryOwners_.append(cellI); + newBoundaryPatches_.append(facePatch[bfI]); + + if( rpos != -1 ) + { + triF[0] = bf.prevLabel(rpos); + triF[1] = bf[rpos]; + triF[2] = bf.nextLabel(rpos); + + # ifdef DEBUGEdges + Info << "triF " << triF << endl; + # endif + } + } + + forAll(bFaces, bfI) + if( facePatch[bfI] == patchOfTreated ) + { + //- merge face with triF and store it + const face mf = help::mergeTwoFaces(bFaces[bfI], triF); + + # ifdef DEBUGEdges + Info << "Merged face " << mf << endl; + # endif + + face shrinkedFace(mf.size() -1); + direction i(0); + forAll(mf, pI) + if( !(typeOfVertex_[mf[pI]] & REMOVE) ) + shrinkedFace[i++] = mf[pI]; + + # ifdef DEBUGEdges + Info << "Storing face " << shrinkedFace << " into patch" + << patchOfTreated << endl; + # endif + + newBoundaryFaces_.appendList(shrinkedFace); + newBoundaryOwners_.append(cellI); + newBoundaryPatches_.append(patchOfTreated); + } + } + } + + front = newFront; + } } void dualUnfoldConcaveCells::storeRemainingBoundaryFaces ( - const meshSurfaceEngine& mse + const meshSurfaceEngine& mse ) { - const faceList::subList& bFaces = mse.boundaryFaces(); - const labelList& faceOwner = mse.faceOwners(); - const labelList& facePatch = mse.boundaryFacePatches(); - - forAll(bFaces, bfI) - if( !(typeOfCell_[faceOwner[bfI]] & TREATEDCELL) ) - { - newBoundaryFaces_.appendList(bFaces[bfI]); - newBoundaryOwners_.append(faceOwner[bfI]); - newBoundaryPatches_.append(facePatch[bfI]); - } + const faceList::subList& bFaces = mse.boundaryFaces(); + const labelList& faceOwner = mse.faceOwners(); + const labelList& facePatch = mse.boundaryFacePatches(); + + forAll(bFaces, bfI) + if( !(typeOfCell_[faceOwner[bfI]] & TREATEDCELL) ) + { + newBoundaryFaces_.appendList(bFaces[bfI]); + newBoundaryOwners_.append(faceOwner[bfI]); + newBoundaryPatches_.append(facePatch[bfI]); + } } void dualUnfoldConcaveCells::removeConcaveVerticesFromIntFaces ( - const meshSurfaceEngine& mse + const meshSurfaceEngine& mse ) { - const label nIntFaces = mesh_.nInternalFaces(); - polyMeshGenModifier meshModifier(mesh_); - faceListPMG& faces = meshModifier.facesAccess(); + const label nIntFaces = mesh_.nInternalFaces(); + polyMeshGenModifier meshModifier(mesh_); + faceListPMG& faces = meshModifier.facesAccess(); - const VRWGraph& pointFaces = mesh_.addressingData().pointFaces(); - forAll(pointFaces, pI) - if( (typeOfVertex_[pI] & REMOVE) ) - { - # ifdef DEBUGEdges - Info << "Removing vertex " << pI << " from internal faces" << endl; - # endif - - forAllRow(pointFaces, pI, pfI) - { - const label pointFaceI = pointFaces(pI, pfI); - if( pointFaceI < nIntFaces ) - { - const face& f = faces[pointFaceI]; - - DynList<label> newF(f.size()-1); - forAll(f, pJ) - if( f[pJ] != pI ) - newF.append(f[pJ]); - - if( newF.size() > 2 ) - { - # ifdef DEBUGEdges - Info << "Internal face " << f << " is shrinked to" - << newF << endl; - # endif - newF.shrink(); - faces[pointFaceI] = face(newF); - } - } - } - } - - mesh_.clearAddressingData(); + const VRWGraph& pointFaces = mesh_.addressingData().pointFaces(); + forAll(pointFaces, pI) + if( (typeOfVertex_[pI] & REMOVE) ) + { + # ifdef DEBUGEdges + Info << "Removing vertex " << pI << " from internal faces" << endl; + # endif + + forAllRow(pointFaces, pI, pfI) + { + const label pointFaceI = pointFaces(pI, pfI); + if( pointFaceI < nIntFaces ) + { + const face& f = faces[pointFaceI]; + + DynList<label> newF(f.size()-1); + forAll(f, pJ) + if( f[pJ] != pI ) + newF.append(f[pJ]); + + if( newF.size() > 2 ) + { + # ifdef DEBUGEdges + Info << "Internal face " << f << " is shrinked to" + << newF << endl; + # endif + newF.shrink(); + faces[pointFaceI] = face(newF); + } + } + } + } + + mesh_.clearAddressingData(); } void dualUnfoldConcaveCells::checkAndRepairBoundary() { - const faceListPMG& faces = mesh_.faces(); - const labelList& owner = mesh_.owner(); - - const PtrList<writePatch>& boundaries = mesh_.boundaries(); - - newBoundaryFaces_.setSize(boundaries.size()); - newBoundaryOwners_.setSize(boundaries.size()); - - boolList touchedOwner(mesh_.cells().size(), false); - - bool changed(false); - - forAll(boundaries, patchI) - { - const label start = boundaries[patchI].patchStart(); - const label end = start + boundaries[patchI].patchSize(); - - for(label faceI=start;faceI<end;++faceI) - { - const face& f = faces[faceI]; - const label own = owner[faceI]; - - bool merge(false); - - forAll(f, pI) - if( typeOfVertex_[f[pI]] & REMOVE ) - { - merge = true; - break; - } - - if( merge && (typeOfCell_[own] & TREATEDCELL) ) - { - changed = true; - if( touchedOwner[own] ) continue; - - touchedOwner[own] = true; - mergeBoundaryFacesOfCell(own); - } - else - { - newBoundaryFaces_.appendList(f); - newBoundaryOwners_.append(own); - newBoundaryPatches_.append(patchI); - } - } - } - - if( changed ) - replaceBoundary(); + const faceListPMG& faces = mesh_.faces(); + const labelList& owner = mesh_.owner(); + + const PtrList<writePatch>& boundaries = mesh_.boundaries(); + + newBoundaryFaces_.setSize(boundaries.size()); + newBoundaryOwners_.setSize(boundaries.size()); + + boolList touchedOwner(mesh_.cells().size(), false); + + bool changed(false); + + forAll(boundaries, patchI) + { + const label start = boundaries[patchI].patchStart(); + const label end = start + boundaries[patchI].patchSize(); + + for(label faceI=start;faceI<end;++faceI) + { + const face& f = faces[faceI]; + const label own = owner[faceI]; + + bool merge(false); + + forAll(f, pI) + if( typeOfVertex_[f[pI]] & REMOVE ) + { + merge = true; + break; + } + + if( merge && (typeOfCell_[own] & TREATEDCELL) ) + { + changed = true; + if( touchedOwner[own] ) continue; + + touchedOwner[own] = true; + mergeBoundaryFacesOfCell(own); + } + else + { + newBoundaryFaces_.appendList(f); + newBoundaryOwners_.append(own); + newBoundaryPatches_.append(patchI); + } + } + } + + if( changed ) + replaceBoundary(); } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/meshLibrary/hexMesh/hexMeshExtractor/hexMeshExtractor.C b/meshLibrary/hexMesh/hexMeshExtractor/hexMeshExtractor.C index 08f3cc7e..d149e39f 100644 --- a/meshLibrary/hexMesh/hexMeshExtractor/hexMeshExtractor.C +++ b/meshLibrary/hexMesh/hexMeshExtractor/hexMeshExtractor.C @@ -37,10 +37,10 @@ namespace Foam { // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - + void hexMeshExtractor::clearOut() { - deleteDemandDrivenData(centreNodeLabelPtr_); + deleteDemandDrivenData(centreNodeLabelPtr_); deleteDemandDrivenData(subVerticesPtr_); } @@ -76,19 +76,19 @@ void hexMeshExtractor::createMesh() Info << "Extracting hex mesh" << endl; classifyOctreePoints(); - + createPoints(); createHexMesh(); - + polyMeshGenModifier(mesh_).removeUnusedVertices(); polyMeshGenModifier(mesh_).reorderBoundaryFaces(); - + Info << "Mesh has :" << nl - << mesh_.points().size() << " vertices " << nl - << mesh_.faces().size() << " faces" << nl - << mesh_.cells().size() << " cells" << endl; - + << mesh_.points().size() << " vertices " << nl + << mesh_.faces().size() << " faces" << nl + << mesh_.cells().size() << " cells" << endl; + Info << "Finished extracting hex template" << endl; } diff --git a/meshLibrary/hexMesh/hexMeshExtractor/hexMeshExtractor.H b/meshLibrary/hexMesh/hexMeshExtractor/hexMeshExtractor.H index f8401bf0..0f8fe8d8 100644 --- a/meshLibrary/hexMesh/hexMeshExtractor/hexMeshExtractor.H +++ b/meshLibrary/hexMesh/hexMeshExtractor/hexMeshExtractor.H @@ -56,10 +56,10 @@ class hexMeshExtractor // Private data //- octree and addressing meshOctreeAddressing octreeAddressing_; - + //- reference to the mesh polyMeshGen& mesh_; - + //- centre node labels labelListPMG* centreNodeLabelPtr_; @@ -75,7 +75,7 @@ class hexMeshExtractor //- classify octree points (CORNER, EDGECENTRE, FACECENTRE) void classifyOctreePoints(); - + //- create mesh points and pointLeaves addressing void createPoints(); @@ -101,7 +101,7 @@ class hexMeshExtractor //- const reference to the octree const meshOctree& octree_; - + //- centre node labels const labelListPMG& centreNodeLabel_; @@ -203,7 +203,7 @@ public: // Member Functions - void createMesh(); + void createMesh(); }; diff --git a/meshLibrary/hexMesh/hexMeshGenerator/hexMeshGenerator.C b/meshLibrary/hexMesh/hexMeshGenerator/hexMeshGenerator.C index 71fac098..edb803e8 100644 --- a/meshLibrary/hexMesh/hexMeshGenerator/hexMeshGenerator.C +++ b/meshLibrary/hexMesh/hexMeshGenerator/hexMeshGenerator.C @@ -106,7 +106,7 @@ void hexMeshGenerator::surfacePreparation() if( checkCellConnectionsOverFaces(mesh_).checkCellGroups() ) changed = true; - } while( changed ); + } while( changed ); # ifdef DEBUG mesh_.write(); @@ -118,7 +118,7 @@ void hexMeshGenerator::surfacePreparation() //::exit(EXIT_FAILURE); # endif } - + void hexMeshGenerator::mapMeshToSurface() { //- calculate mesh surface @@ -152,12 +152,12 @@ void hexMeshGenerator::mapMeshToSurface() mesh_.write(); //::exit(EXIT_FAILURE); # endif - + deleteDemandDrivenData(msePtr); //- extract edges and corners meshSurfaceEdgeExtractorFUN(mesh_, *octreePtr_); - + # ifdef DEBUG mesh_.write(); # ifdef DEBUGflma @@ -173,7 +173,7 @@ void hexMeshGenerator::optimiseMeshSurface() { meshSurfaceEngine mse(mesh_); meshSurfaceOptimizer(mse, *octreePtr_).optimizeSurface(); - + # ifdef DEBUG mesh_.write(); # ifdef DEBUGflma @@ -183,7 +183,7 @@ void hexMeshGenerator::optimiseMeshSurface() #endif # endif } - + void hexMeshGenerator::generateBoundaryLayers() { boundaryLayers bl(mesh_); @@ -210,7 +210,7 @@ void hexMeshGenerator::generateBoundaryLayers() mesh_.write(); # endif } - + void hexMeshGenerator::optimiseFinalMesh() { //- final optimisation @@ -221,7 +221,7 @@ void hexMeshGenerator::optimiseFinalMesh() deleteDemandDrivenData(octreePtr_); optimizer.optimizeMeshFV(); - + # ifdef DEBUG # ifdef DEBUGflma writeMeshFLMA(mesh_,"optimisedMesh"); @@ -247,7 +247,7 @@ void hexMeshGenerator::replaceBoundaries() void hexMeshGenerator::renumberMesh() { polyMeshGenModifier(mesh_).renumberMesh(); - + # ifdef DEBUG # ifdef DEBUGflma writeMeshFLMA(mesh_,"renumberedMesh"); @@ -311,13 +311,13 @@ hexMeshGenerator::hexMeshGenerator const fileName surfaceFile = meshDict_.lookup("surfaceFile"); surfacePtr_ = new triSurf(runTime_.path()/surfaceFile); - + if( meshDict_.found("subsetFileName") ) { const fileName subsetFileName = meshDict_.lookup("subsetFileName"); surfacePtr_->readFaceSubsets(runTime_.path()/subsetFileName); } - + generateOctree(); generateMesh(); @@ -344,7 +344,7 @@ hexMeshGenerator::hexMeshGenerator ) ), octreePtr_(NULL), - mesh_(time) + mesh_(time) { fileName surfaceFile = meshDict_.lookup("surfaceFile"); diff --git a/meshLibrary/hexMesh/hexMeshGenerator/hexMeshGenerator.H b/meshLibrary/hexMesh/hexMeshGenerator/hexMeshGenerator.H index 29f680be..9217f134 100644 --- a/meshLibrary/hexMesh/hexMeshGenerator/hexMeshGenerator.H +++ b/meshLibrary/hexMesh/hexMeshGenerator/hexMeshGenerator.H @@ -68,38 +68,38 @@ class hexMeshGenerator //- pointer to the octree meshOctree* octreePtr_; - - //- mesh - polyMeshGen mesh_; + + //- mesh + polyMeshGen mesh_; // Private member functions //- generate octree based on user's refinement settings void generateOctree(); - //- generate dual mesh - void generateDualMesh(); - - //- prepare mesh surface - void surfacePreparation(); - - //- map mesh to the surface and untangle surface - void mapMeshToSurface(); - - //- optimise surface of the mesh - void optimiseMeshSurface(); - - //- add boundary layers - void generateBoundaryLayers(); - - //- mesh optimisation - void optimiseFinalMesh(); + //- generate dual mesh + void generateDualMesh(); + + //- prepare mesh surface + void surfacePreparation(); + + //- map mesh to the surface and untangle surface + void mapMeshToSurface(); + + //- optimise surface of the mesh + void optimiseMeshSurface(); + + //- add boundary layers + void generateBoundaryLayers(); + + //- mesh optimisation + void optimiseFinalMesh(); //- replace boundaries void replaceBoundaries(); - - //- renumber the mesh - void renumberMesh(); - + + //- renumber the mesh + void renumberMesh(); + //- generate mesh void generateMesh(); diff --git a/meshLibrary/utilities/boundaryLayers/boundaryLayerCells.C b/meshLibrary/utilities/boundaryLayers/boundaryLayerCells.C index 9071bdbe..fb6750f9 100644 --- a/meshLibrary/utilities/boundaryLayers/boundaryLayerCells.C +++ b/meshLibrary/utilities/boundaryLayers/boundaryLayerCells.C @@ -53,26 +53,26 @@ namespace Foam void boundaryLayers::createLayerCells(const labelList& patchLabels) { - Info << "Starting creating layer cells" << endl; + Info << "Starting creating layer cells" << endl; const meshSurfaceEngine& mse = surfaceEngine(); - const faceList::subList& bFaces = mse.boundaryFaces(); - const VRWGraph& faceEdges = mse.faceEdges(); - const VRWGraph& edgeFaces = mse.edgeFaces(); - const labelList& boundaryFacePatches = mse.boundaryFacePatches(); - const labelList& faceOwners = mse.faceOwners(); - - boolList treatPatches(mesh_.boundaries().size(), false); - forAll(patchLabels, patchI) - { - const label pLabel = patchLabels[patchI]; - forAll(treatPatchesWithPatch_[pLabel], i) - treatPatches[treatPatchesWithPatch_[pLabel][i]] = true; - } - - //- create new faces at parallel boundaries - const Map<label>* otherProcPatchPtr(NULL); - const Map<label>* otherFaceProcPtr(NULL); + const faceList::subList& bFaces = mse.boundaryFaces(); + const VRWGraph& faceEdges = mse.faceEdges(); + const VRWGraph& edgeFaces = mse.edgeFaces(); + const labelList& boundaryFacePatches = mse.boundaryFacePatches(); + const labelList& faceOwners = mse.faceOwners(); + + boolList treatPatches(mesh_.boundaries().size(), false); + forAll(patchLabels, patchI) + { + const label pLabel = patchLabels[patchI]; + forAll(treatPatchesWithPatch_[pLabel], i) + treatPatches[treatPatchesWithPatch_[pLabel][i]] = true; + } + + //- create new faces at parallel boundaries + const Map<label>* otherProcPatchPtr(NULL); + const Map<label>* otherFaceProcPtr(NULL); if( Pstream::parRun() ) { @@ -81,58 +81,58 @@ void boundaryLayers::createLayerCells(const labelList& patchLabels) otherProcPatchPtr = &mse.otherEdgeFacePatch(); otherFaceProcPtr = &mse.otherEdgeFaceAtProc(); } - - //- create lists for new boundary faces - VRWGraph newBoundaryFaces; - labelListPMG newBoundaryOwners; - labelListPMG newBoundaryPatches; + + //- create lists for new boundary faces + VRWGraph newBoundaryFaces; + labelListPMG newBoundaryOwners; + labelListPMG newBoundaryPatches; //- create storage for new cells - VRWGraphList cellsToAdd; - - //- create layer cells and store boundary faces - const label nOldCells = mesh_.cells().size(); - forAll(bFaces, bfI) - if( treatPatches[boundaryFacePatches[bfI]] ) - { - const face& f = bFaces[bfI]; - const label pKey = patchKey_[boundaryFacePatches[bfI]]; - - DynList<DynList<label> > cellFaces; - + VRWGraphList cellsToAdd; + + //- create layer cells and store boundary faces + const label nOldCells = mesh_.cells().size(); + forAll(bFaces, bfI) + if( treatPatches[boundaryFacePatches[bfI]] ) + { + const face& f = bFaces[bfI]; + const label pKey = patchKey_[boundaryFacePatches[bfI]]; + + DynList<DynList<label> > cellFaces; + DynList<label> newF; - //- store boundary face + //- store boundary face newF.clear(); newF.append(f[0]); for(label pI=f.size()-1;pI>0;--pI) newF.append(f[pI]); - cellFaces.append(newF); - - //- create parallel face - newF.clear(); - forAll(f, pI) - newF.append(findNewNodeLabel(f[pI], pKey)); - - cellFaces.append(newF); - - newBoundaryFaces.appendList(newF); - newBoundaryOwners.append(cellsToAdd.size() + nOldCells); - newBoundaryPatches.append(boundaryFacePatches[bfI]); - - //- create quad faces - newF.setSize(4); - forAll(f, pI) - { - newF[0] = f[pI]; - newF[1] = f.nextLabel(pI); - newF[2] = findNewNodeLabel(newF[1], pKey); - newF[3] = findNewNodeLabel(f[pI], pKey); - - cellFaces.append(newF); - - //- check if the face is at the boundary + cellFaces.append(newF); + + //- create parallel face + newF.clear(); + forAll(f, pI) + newF.append(findNewNodeLabel(f[pI], pKey)); + + cellFaces.append(newF); + + newBoundaryFaces.appendList(newF); + newBoundaryOwners.append(cellsToAdd.size() + nOldCells); + newBoundaryPatches.append(boundaryFacePatches[bfI]); + + //- create quad faces + newF.setSize(4); + forAll(f, pI) + { + newF[0] = f[pI]; + newF[1] = f.nextLabel(pI); + newF[2] = findNewNodeLabel(newF[1], pKey); + newF[3] = findNewNodeLabel(f[pI], pKey); + + cellFaces.append(newF); + + //- check if the face is at the boundary //- of the treated partitions - const label edgeI = faceEdges(bfI, pI); + const label edgeI = faceEdges(bfI, pI); if( edgeFaces.sizeOfRow(edgeI) == 2 ) { label neiFace = edgeFaces(edgeI, 0); @@ -146,228 +146,228 @@ void boundaryLayers::createLayerCells(const labelList& patchLabels) newBoundaryPatches.append(boundaryFacePatches[neiFace]); } } - else if( edgeFaces.sizeOfRow(edgeI) == 1 ) + else if( edgeFaces.sizeOfRow(edgeI) == 1 ) { const Map<label>& otherProcPatch = *otherProcPatchPtr; if( !treatPatches[otherProcPatch[edgeI]] ) { - //- face is a new boundary face + //- face is a new boundary face newBoundaryFaces.appendList(newF); newBoundaryOwners.append(cellsToAdd.size() + nOldCells); newBoundaryPatches.append(otherProcPatch[edgeI]); } } - } - - # ifdef DEBUGLayer - Info << "Adding cell " << cellFaces << endl; - # endif - + } + + # ifdef DEBUGLayer + Info << "Adding cell " << cellFaces << endl; + # endif + cellsToAdd.appendGraph(cellFaces); - } - else - { - # ifdef DEBUGLayer - Info << "Storing original boundary face " - << bfI << " into patch " << boundaryFacePatches[bfI] << endl; - # endif - - newBoundaryFaces.appendList(bFaces[bfI]); - newBoundaryOwners.append(faceOwners[bfI]); - newBoundaryPatches.append(boundaryFacePatches[bfI]); - } - - //- data for parallel execution - boolList procPoint; - LongList<DynList<label, 4> > pointProcFaces; - LongList<labelPair> faceAtPatches; - if( Pstream::parRun() ) - { - procPoint.setSize(nPoints_); - procPoint = false; - + } + else + { + # ifdef DEBUGLayer + Info << "Storing original boundary face " + << bfI << " into patch " << boundaryFacePatches[bfI] << endl; + # endif + + newBoundaryFaces.appendList(bFaces[bfI]); + newBoundaryOwners.append(faceOwners[bfI]); + newBoundaryPatches.append(boundaryFacePatches[bfI]); + } + + //- data for parallel execution + boolList procPoint; + LongList<DynList<label, 4> > pointProcFaces; + LongList<labelPair> faceAtPatches; + if( Pstream::parRun() ) + { + procPoint.setSize(nPoints_); + procPoint = false; + const Map<label>& globalToLocal = mse.globalToLocalBndPointAddressing(); - const labelList& bPoints = mse.boundaryPoints(); - + const labelList& bPoints = mse.boundaryPoints(); + for ( Map<label>::const_iterator iter=globalToLocal.begin(); iter!=globalToLocal.end(); ++iter ) - { + { const label bpI = iter(); procPoint[bPoints[bpI]] = true; - } - } - - //- create cells at edges - const edgeList& edges = mse.edges(); - forAll(edgeFaces, edgeI) - { - //- do not consider edges with no faces attached to it - if( edgeFaces.sizeOfRow(edgeI) == 0 ) - continue; - - //- cells are generated at the processor with the lowest label - if( - (edgeFaces.sizeOfRow(edgeI) == 1) && - (otherFaceProcPtr->operator[](edgeI) < Pstream::myProcNo()) - ) - continue; - - //- check if the edge is a feature edge - const label patchI = boundaryFacePatches[edgeFaces(edgeI, 0)]; - - label patchJ; - if( otherProcPatchPtr && otherProcPatchPtr->found(edgeI) ) - { - patchJ = otherProcPatchPtr->operator[](edgeI); - } - else - { - patchJ = boundaryFacePatches[edgeFaces(edgeI, 1)]; - } - - if( patchI == patchJ ) - continue; - - //- check if the faces attached to the edge have different keys - const label pKeyI = patchKey_[patchI]; - const label pKeyJ = patchKey_[patchJ]; - - if( pKeyI == pKeyJ ) - continue; - - const edge& e = edges[edgeI]; - if( otherVrts_.find(e.start()) == otherVrts_.end() ) - continue; - if( otherVrts_.find(e.end()) == otherVrts_.end() ) - continue; - - DynList<DynList<label, 4>, 6> cellFaces; - createNewCellFromEdge(e, pKeyI, pKeyJ, cellFaces); - - //- store boundary faces - newBoundaryFaces.appendList(cellFaces[1]); - newBoundaryOwners.append(nOldCells+cellsToAdd.size()); - newBoundaryPatches.append(patchJ); - - newBoundaryFaces.appendList(cellFaces[3]); - newBoundaryOwners.append(nOldCells+cellsToAdd.size()); - newBoundaryPatches.append(patchI); - - if( Pstream::parRun() ) - { - if( procPoint[e.start()] ) - { - pointProcFaces.append(cellFaces[5]); - faceAtPatches.append(labelPair(patchI, patchJ)); - } - if( procPoint[e.end()] ) - { - pointProcFaces.append(cellFaces[4]); - faceAtPatches.append(labelPair(patchI, patchJ)); - } - } - - //- append cell to the queue - cellsToAdd.appendGraph(cellFaces); - } - - //- create cells for corner nodes - const VRWGraph& pointFaces = mse.pointFaces(); - const labelList& bp = mse.bp(); - - std::map<label, DynList<label, 3> > nodePatches; - labelHashSet parPoint; - if( Pstream::parRun() ) - { - const labelList& bPoints = mse.boundaryPoints(); - const VRWGraph& pProcs = mse.bpAtProcs(); - const labelList& globalPointLabel = mse.globalBoundaryPointLabel(); - const Map<label>& globalToLocal = mse.globalToLocalBndPointAddressing(); - - std::map<label, labelListPMG> facesToSend; - std::map<label, DynList<face, 8> > parPointFaces; - std::map<label, DynList<label, 3> > parPointPatches; - for - ( - std::map< - label, std::map<std::pair<label, label>, label> - >::const_iterator iter=otherVrts_.begin(); - iter!=otherVrts_.end(); - ++iter - ) - { - if( iter->second.size() == 2 ) - continue; - - const label bpI = bp[iter->first]; - - if( pProcs.sizeOfRow(bpI) != 0 ) - { - parPoint.insert(iter->first); - - //- point is at a parallel boundary - label pMin = pProcs(bpI, 0); - forAllRow(pProcs, bpI, i) - { - const label prI = pProcs(bpI, i); - - if( facesToSend.find(prI) == facesToSend.end() ) - facesToSend.insert(std::make_pair(prI, labelListPMG())); - - if( prI < pMin ) - pMin = prI; - } - - if( Pstream::myProcNo() == pMin ) - { - DynList<face, 8> pFaces(3); - DynList<label, 3> pPatches(3); - forAllRow(pointFaces, bpI, fI) - { - const label bfI = pointFaces(bpI, fI); - pPatches.append(boundaryFacePatches[bfI]); + } + } + + //- create cells at edges + const edgeList& edges = mse.edges(); + forAll(edgeFaces, edgeI) + { + //- do not consider edges with no faces attached to it + if( edgeFaces.sizeOfRow(edgeI) == 0 ) + continue; + + //- cells are generated at the processor with the lowest label + if( + (edgeFaces.sizeOfRow(edgeI) == 1) && + (otherFaceProcPtr->operator[](edgeI) < Pstream::myProcNo()) + ) + continue; + + //- check if the edge is a feature edge + const label patchI = boundaryFacePatches[edgeFaces(edgeI, 0)]; + + label patchJ; + if( otherProcPatchPtr && otherProcPatchPtr->found(edgeI) ) + { + patchJ = otherProcPatchPtr->operator[](edgeI); + } + else + { + patchJ = boundaryFacePatches[edgeFaces(edgeI, 1)]; + } + + if( patchI == patchJ ) + continue; + + //- check if the faces attached to the edge have different keys + const label pKeyI = patchKey_[patchI]; + const label pKeyJ = patchKey_[patchJ]; + + if( pKeyI == pKeyJ ) + continue; + + const edge& e = edges[edgeI]; + if( otherVrts_.find(e.start()) == otherVrts_.end() ) + continue; + if( otherVrts_.find(e.end()) == otherVrts_.end() ) + continue; + + DynList<DynList<label, 4>, 6> cellFaces; + createNewCellFromEdge(e, pKeyI, pKeyJ, cellFaces); + + //- store boundary faces + newBoundaryFaces.appendList(cellFaces[1]); + newBoundaryOwners.append(nOldCells+cellsToAdd.size()); + newBoundaryPatches.append(patchJ); + + newBoundaryFaces.appendList(cellFaces[3]); + newBoundaryOwners.append(nOldCells+cellsToAdd.size()); + newBoundaryPatches.append(patchI); + + if( Pstream::parRun() ) + { + if( procPoint[e.start()] ) + { + pointProcFaces.append(cellFaces[5]); + faceAtPatches.append(labelPair(patchI, patchJ)); + } + if( procPoint[e.end()] ) + { + pointProcFaces.append(cellFaces[4]); + faceAtPatches.append(labelPair(patchI, patchJ)); + } + } + + //- append cell to the queue + cellsToAdd.appendGraph(cellFaces); + } + + //- create cells for corner nodes + const VRWGraph& pointFaces = mse.pointFaces(); + const labelList& bp = mse.bp(); + + std::map<label, DynList<label, 3> > nodePatches; + labelHashSet parPoint; + if( Pstream::parRun() ) + { + const labelList& bPoints = mse.boundaryPoints(); + const VRWGraph& pProcs = mse.bpAtProcs(); + const labelList& globalPointLabel = mse.globalBoundaryPointLabel(); + const Map<label>& globalToLocal = mse.globalToLocalBndPointAddressing(); + + std::map<label, labelListPMG> facesToSend; + std::map<label, DynList<face, 8> > parPointFaces; + std::map<label, DynList<label, 3> > parPointPatches; + for + ( + std::map< + label, std::map<std::pair<label, label>, label> + >::const_iterator iter=otherVrts_.begin(); + iter!=otherVrts_.end(); + ++iter + ) + { + if( iter->second.size() == 2 ) + continue; + + const label bpI = bp[iter->first]; + + if( pProcs.sizeOfRow(bpI) != 0 ) + { + parPoint.insert(iter->first); + + //- point is at a parallel boundary + label pMin = pProcs(bpI, 0); + forAllRow(pProcs, bpI, i) + { + const label prI = pProcs(bpI, i); + + if( facesToSend.find(prI) == facesToSend.end() ) + facesToSend.insert(std::make_pair(prI, labelListPMG())); + + if( prI < pMin ) + pMin = prI; + } + + if( Pstream::myProcNo() == pMin ) + { + DynList<face, 8> pFaces(3); + DynList<label, 3> pPatches(3); + forAllRow(pointFaces, bpI, fI) + { + const label bfI = pointFaces(bpI, fI); + pPatches.append(boundaryFacePatches[bfI]); face bf; bf.setSize(bFaces[bfI].size()); - forAll(bf, pI) - bf[pI] = globalPointLabel[bp[bf[pI]]]; - pFaces.append(bf); - } - parPointFaces.insert(std::make_pair(bpI, pFaces)); - parPointPatches.insert(std::make_pair(bpI, pPatches)); - continue; - } - - labelListPMG& stp = facesToSend[pMin]; - - //- send the data to the processor with the lowest label - //- data is flatenned as follows - //- 1. the number of faces and global point label - //- 2. number of points in the face - //- 3. patch label - //- 4. global labels of face points - stp.append(globalPointLabel[bpI]); - stp.append(pointFaces.sizeOfRow(bpI)); - forAllRow(pointFaces, bpI, fI) - { - const label bfI = pointFaces(bpI, fI); - const face& bf = bFaces[bfI]; - stp.append(bf.size()); - stp.append(boundaryFacePatches[bfI]); - forAll(bf, pI) - stp.append(globalPointLabel[bf[pI]]); - } - } - } - - //- exchange data with other processors + forAll(bf, pI) + bf[pI] = globalPointLabel[bp[bf[pI]]]; + pFaces.append(bf); + } + parPointFaces.insert(std::make_pair(bpI, pFaces)); + parPointPatches.insert(std::make_pair(bpI, pPatches)); + continue; + } + + labelListPMG& stp = facesToSend[pMin]; + + //- send the data to the processor with the lowest label + //- data is flatenned as follows + //- 1. the number of faces and global point label + //- 2. number of points in the face + //- 3. patch label + //- 4. global labels of face points + stp.append(globalPointLabel[bpI]); + stp.append(pointFaces.sizeOfRow(bpI)); + forAllRow(pointFaces, bpI, fI) + { + const label bfI = pointFaces(bpI, fI); + const face& bf = bFaces[bfI]; + stp.append(bf.size()); + stp.append(boundaryFacePatches[bfI]); + forAll(bf, pI) + stp.append(globalPointLabel[bf[pI]]); + } + } + } + + //- exchange data with other processors labelListPMG receivedData; help::exchangeMap(facesToSend, receivedData); - + label counter(0); while( counter < receivedData.size() ) { @@ -382,259 +382,259 @@ void boundaryLayers::createLayerCells(const labelList& patchLabels) parPointFaces[bpI].append(f); } } - - //- sort faces sharing corners at the parallel boundaries - for - ( - std::map<label, DynList<face, 8> >::iterator iter=parPointFaces.begin(); - iter!=parPointFaces.end(); - ++iter - ) - { - DynList<face, 8>& pFaces = iter->second; - DynList<label, 3>& fPatches = parPointPatches[iter->first]; - const label gpI = globalPointLabel[iter->first]; - - for(label i=0;i<pFaces.size();++i) - { - const face& bf = pFaces[i]; - const edge e = bf.faceEdge(bf.which(gpI)); - - for(label j=i+1;j<pFaces.size();++j) - { - const face& obf = pFaces[j]; - if( - (obf.which(e.start()) >= 0) && - (obf.which(e.end()) >= 0) - ) - { - face add; - add.transfer(pFaces[i+1]); - pFaces[i+1].transfer(pFaces[j]); - pFaces[j].transfer(add); - const label pAdd = fPatches[i+1]; - fPatches[i+1] = fPatches[j]; - fPatches[j] = pAdd; - break; - } - } - } - - DynList<label, 3> patchIDs(fPatches.size()); - forAll(fPatches, fpI) - patchIDs.appendIfNotIn(fPatches[fpI]); - - nodePatches.insert(std::make_pair(bPoints[iter->first], patchIDs)); - } - } - - //- sort out vertices at one processor - for - ( - std::map< - label, std::map<std::pair<label, label>, label> - >::const_iterator iter=otherVrts_.begin(); - iter!=otherVrts_.end(); - ++iter - ) - { - if( iter->second.size() == 2 ) - continue; - - if( parPoint.found(iter->first) ) - continue; - - const label bpI = bp[iter->first]; - - //- ensure correct orientation - labelList pFaces(pointFaces.sizeOfRow(bpI)); - forAll(pFaces, fI) - pFaces[fI] = pointFaces(bpI, fI); - - for(label i=0;i<pFaces.size();++i) - { - const face& bf = bFaces[pFaces[i]]; - const edge e = bf.faceEdge(bf.which(iter->first)); - - for(label j=i+1;j<pFaces.size();++j) - { - const face& obf = bFaces[pFaces[j]]; - if( - (obf.which(e.start()) >= 0) && - (obf.which(e.end()) >= 0) - ) - { - const label add = pFaces[i+1]; - pFaces[i+1] = pFaces[j]; - pFaces[j] = add; - break; - } - } - } - - DynList<label, 3> patchIDs; - forAll(pFaces, patchI) - { - patchIDs.appendIfNotIn(boundaryFacePatches[pFaces[patchI]]); - } - - nodePatches.insert(std::make_pair(iter->first, patchIDs)); - } - - //- create layer cells for corner nodes - for - ( - std::map<label, DynList<label, 3> >::iterator iter=nodePatches.begin(); - iter!=nodePatches.end(); - ++iter - ) - { - const DynList<label, 3>& patchIDs = iter->second; - DynList<label, 3> pKeys; - forAll(patchIDs, patchI) - { - pKeys.appendIfNotIn(patchKey_[patchIDs[patchI]]); - } - - if( pKeys.size() != 3 ) - continue; - - DynList<DynList<label, 4>, 6> cellFaces; - createNewCellFromNode(iter->first, pKeys, cellFaces); - - //- store boundary faces - newBoundaryFaces.appendList(cellFaces[1]); - newBoundaryOwners.append(nOldCells+cellsToAdd.size()); - newBoundaryPatches.append(patchIDs[0]); - - newBoundaryFaces.appendList(cellFaces[3]); - newBoundaryOwners.append(nOldCells+cellsToAdd.size()); - newBoundaryPatches.append(patchIDs[1]); - - newBoundaryFaces.appendList(cellFaces[5]); - newBoundaryOwners.append(nOldCells+cellsToAdd.size()); - newBoundaryPatches.append(patchIDs[2]); - - if( Pstream::parRun() ) - { - if( procPoint[iter->first] ) - { - pointProcFaces.append(cellFaces[0]); - faceAtPatches.append(labelPair(patchIDs[1], patchIDs[2])); - - pointProcFaces.append(cellFaces[2]); - faceAtPatches.append(labelPair(patchIDs[0], patchIDs[2])); - - pointProcFaces.append(cellFaces[4]); - faceAtPatches.append(labelPair(patchIDs[0], patchIDs[1])); - } - } - - # ifdef DEBUGLayer - Info << "Adding corner cell " << cellFaces << endl; - # endif - - //- append cell to the queue - cellsToAdd.appendGraph(cellFaces); - } - - if( Pstream::parRun() ) - { - //- create faces at parallel boundaries created from - //- points at parallel boundaries - createNewFacesFromPointsParallel - ( - pointProcFaces, - faceAtPatches - ); - } - + + //- sort faces sharing corners at the parallel boundaries + for + ( + std::map<label, DynList<face, 8> >::iterator iter=parPointFaces.begin(); + iter!=parPointFaces.end(); + ++iter + ) + { + DynList<face, 8>& pFaces = iter->second; + DynList<label, 3>& fPatches = parPointPatches[iter->first]; + const label gpI = globalPointLabel[iter->first]; + + for(label i=0;i<pFaces.size();++i) + { + const face& bf = pFaces[i]; + const edge e = bf.faceEdge(bf.which(gpI)); + + for(label j=i+1;j<pFaces.size();++j) + { + const face& obf = pFaces[j]; + if( + (obf.which(e.start()) >= 0) && + (obf.which(e.end()) >= 0) + ) + { + face add; + add.transfer(pFaces[i+1]); + pFaces[i+1].transfer(pFaces[j]); + pFaces[j].transfer(add); + const label pAdd = fPatches[i+1]; + fPatches[i+1] = fPatches[j]; + fPatches[j] = pAdd; + break; + } + } + } + + DynList<label, 3> patchIDs(fPatches.size()); + forAll(fPatches, fpI) + patchIDs.appendIfNotIn(fPatches[fpI]); + + nodePatches.insert(std::make_pair(bPoints[iter->first], patchIDs)); + } + } + + //- sort out vertices at one processor + for + ( + std::map< + label, std::map<std::pair<label, label>, label> + >::const_iterator iter=otherVrts_.begin(); + iter!=otherVrts_.end(); + ++iter + ) + { + if( iter->second.size() == 2 ) + continue; + + if( parPoint.found(iter->first) ) + continue; + + const label bpI = bp[iter->first]; + + //- ensure correct orientation + labelList pFaces(pointFaces.sizeOfRow(bpI)); + forAll(pFaces, fI) + pFaces[fI] = pointFaces(bpI, fI); + + for(label i=0;i<pFaces.size();++i) + { + const face& bf = bFaces[pFaces[i]]; + const edge e = bf.faceEdge(bf.which(iter->first)); + + for(label j=i+1;j<pFaces.size();++j) + { + const face& obf = bFaces[pFaces[j]]; + if( + (obf.which(e.start()) >= 0) && + (obf.which(e.end()) >= 0) + ) + { + const label add = pFaces[i+1]; + pFaces[i+1] = pFaces[j]; + pFaces[j] = add; + break; + } + } + } + + DynList<label, 3> patchIDs; + forAll(pFaces, patchI) + { + patchIDs.appendIfNotIn(boundaryFacePatches[pFaces[patchI]]); + } + + nodePatches.insert(std::make_pair(iter->first, patchIDs)); + } + + //- create layer cells for corner nodes + for + ( + std::map<label, DynList<label, 3> >::iterator iter=nodePatches.begin(); + iter!=nodePatches.end(); + ++iter + ) + { + const DynList<label, 3>& patchIDs = iter->second; + DynList<label, 3> pKeys; + forAll(patchIDs, patchI) + { + pKeys.appendIfNotIn(patchKey_[patchIDs[patchI]]); + } + + if( pKeys.size() != 3 ) + continue; + + DynList<DynList<label, 4>, 6> cellFaces; + createNewCellFromNode(iter->first, pKeys, cellFaces); + + //- store boundary faces + newBoundaryFaces.appendList(cellFaces[1]); + newBoundaryOwners.append(nOldCells+cellsToAdd.size()); + newBoundaryPatches.append(patchIDs[0]); + + newBoundaryFaces.appendList(cellFaces[3]); + newBoundaryOwners.append(nOldCells+cellsToAdd.size()); + newBoundaryPatches.append(patchIDs[1]); + + newBoundaryFaces.appendList(cellFaces[5]); + newBoundaryOwners.append(nOldCells+cellsToAdd.size()); + newBoundaryPatches.append(patchIDs[2]); + + if( Pstream::parRun() ) + { + if( procPoint[iter->first] ) + { + pointProcFaces.append(cellFaces[0]); + faceAtPatches.append(labelPair(patchIDs[1], patchIDs[2])); + + pointProcFaces.append(cellFaces[2]); + faceAtPatches.append(labelPair(patchIDs[0], patchIDs[2])); + + pointProcFaces.append(cellFaces[4]); + faceAtPatches.append(labelPair(patchIDs[0], patchIDs[1])); + } + } + + # ifdef DEBUGLayer + Info << "Adding corner cell " << cellFaces << endl; + # endif + + //- append cell to the queue + cellsToAdd.appendGraph(cellFaces); + } + + if( Pstream::parRun() ) + { + //- create faces at parallel boundaries created from + //- points at parallel boundaries + createNewFacesFromPointsParallel + ( + pointProcFaces, + faceAtPatches + ); + } + //- create mesh modifier - polyMeshGenModifier meshModifier(mesh_); - + polyMeshGenModifier meshModifier(mesh_); + meshModifier.addCells(cellsToAdd); cellsToAdd.clear(); - meshModifier.reorderBoundaryFaces(); - meshModifier.replaceBoundary - ( - patchNames_, - newBoundaryFaces, - newBoundaryOwners, - newBoundaryPatches - ); + meshModifier.reorderBoundaryFaces(); + meshModifier.replaceBoundary + ( + patchNames_, + newBoundaryFaces, + newBoundaryOwners, + newBoundaryPatches + ); //- delete meshSurfaceEngine this->clearOut(); - # ifdef DEBUGLayer - mesh_.addressingData().checkMesh(true); - # endif + # ifdef DEBUGLayer + mesh_.addressingData().checkMesh(true); + # endif - Info << "Finished creating layer cells" << endl; + Info << "Finished creating layer cells" << endl; } void boundaryLayers::createNewFacesFromPointsParallel ( - const LongList<DynList<label, 4> >& faceCandidates, - const LongList<labelPair>& candidatePatches + const LongList<DynList<label, 4> >& faceCandidates, + const LongList<labelPair>& candidatePatches ) { - const meshSurfaceEngine& mse = this->surfaceEngine(); - const labelList& bPoints = mse.boundaryPoints(); - const labelList& bp = mse.bp(); - const VRWGraph& bpAtProcs = mse.bpAtProcs(); - const labelList& globalPointLabel = mse.globalBoundaryPointLabel(); - const Map<label>& globalToLocal = mse.globalToLocalBndPointAddressing(); - - labelList otherFaceProc(faceCandidates.size(), -1); - //- some faces may appear more than once - //- such faces are ordinary internal faces - VRWGraph pointFaceCandidates(nPoints_); - forAll(faceCandidates, fI) - { - forAll(faceCandidates[fI], pI) - pointFaceCandidates.append(faceCandidates[fI][pI], fI); - } - - boolList duplicateFace(faceCandidates.size(), false); - List<labelledPair> pointOfOrigin(faceCandidates.size()); - std::map<labelledPair, label> pointOfOriginToFaceLabel; - forAll(faceCandidates, fI) - { - const DynList<label, 4>& f = faceCandidates[fI]; - - const label pointI = f[0]; - - const labelledPair lp - ( - globalPointLabel[bp[pointI]], - Pair<label> + const meshSurfaceEngine& mse = this->surfaceEngine(); + const labelList& bPoints = mse.boundaryPoints(); + const labelList& bp = mse.bp(); + const VRWGraph& bpAtProcs = mse.bpAtProcs(); + const labelList& globalPointLabel = mse.globalBoundaryPointLabel(); + const Map<label>& globalToLocal = mse.globalToLocalBndPointAddressing(); + + labelList otherFaceProc(faceCandidates.size(), -1); + //- some faces may appear more than once + //- such faces are ordinary internal faces + VRWGraph pointFaceCandidates(nPoints_); + forAll(faceCandidates, fI) + { + forAll(faceCandidates[fI], pI) + pointFaceCandidates.append(faceCandidates[fI][pI], fI); + } + + boolList duplicateFace(faceCandidates.size(), false); + List<labelledPair> pointOfOrigin(faceCandidates.size()); + std::map<labelledPair, label> pointOfOriginToFaceLabel; + forAll(faceCandidates, fI) + { + const DynList<label, 4>& f = faceCandidates[fI]; + + const label pointI = f[0]; + + const labelledPair lp + ( + globalPointLabel[bp[pointI]], + Pair<label> ( patchKey_[candidatePatches[fI][0]], patchKey_[candidatePatches[fI][1]] ) - ); - - if( - pointOfOriginToFaceLabel.find(lp) != pointOfOriginToFaceLabel.end() - ) - { - duplicateFace[fI] = true; - pointOfOrigin[fI] = lp; - duplicateFace[pointOfOriginToFaceLabel[lp]] = true; - continue; - } - - pointOfOrigin[fI] = lp; - - pointOfOriginToFaceLabel.insert(std::make_pair(lp, fI)); - } - - //- find the processor patch for each processor boundary face - //- the key of the algorithm is the point from which the face was created - //- by sending the point label and the associated patches, it will be - //- possible to find the other processor containing that face - std::map<label, LongList<labelledPair> > exchangeData; + ); + + if( + pointOfOriginToFaceLabel.find(lp) != pointOfOriginToFaceLabel.end() + ) + { + duplicateFace[fI] = true; + pointOfOrigin[fI] = lp; + duplicateFace[pointOfOriginToFaceLabel[lp]] = true; + continue; + } + + pointOfOrigin[fI] = lp; + + pointOfOriginToFaceLabel.insert(std::make_pair(lp, fI)); + } + + //- find the processor patch for each processor boundary face + //- the key of the algorithm is the point from which the face was created + //- by sending the point label and the associated patches, it will be + //- possible to find the other processor containing that face + std::map<label, LongList<labelledPair> > exchangeData; const DynList<label>& neiProcs = mse.bpNeiProcs(); forAll(neiProcs, procI) { @@ -650,108 +650,108 @@ void boundaryLayers::createNewFacesFromPointsParallel ); } - forAll(faceCandidates, fI) - { - if( duplicateFace[fI] ) - continue; - - const label bpI = bp[faceCandidates[fI][0]]; - - forAllRow(bpAtProcs, bpI, procI) - { - const label neiProcNo = bpAtProcs(bpI, procI); - if( neiProcNo == Pstream::myProcNo() ) - continue; - - LongList<labelledPair>& dataToSend = exchangeData[neiProcNo]; - dataToSend.append(pointOfOrigin[fI]); - } - } - - //- exchange the data with other processors + forAll(faceCandidates, fI) + { + if( duplicateFace[fI] ) + continue; + + const label bpI = bp[faceCandidates[fI][0]]; + + forAllRow(bpAtProcs, bpI, procI) + { + const label neiProcNo = bpAtProcs(bpI, procI); + if( neiProcNo == Pstream::myProcNo() ) + continue; + + LongList<labelledPair>& dataToSend = exchangeData[neiProcNo]; + dataToSend.append(pointOfOrigin[fI]); + } + } + + //- exchange the data with other processors std::map<label, List<labelledPair> > receivedMap; help::exchangeMap(exchangeData, receivedMap); exchangeData.clear(); - for - ( - std::map<label, List<labelledPair> >::const_iterator - iter=receivedMap.begin(); - iter!=receivedMap.end(); - ++iter - ) - { - const List<labelledPair>& receivedData = iter->second; - - forAll(receivedData, i) - { - const labelledPair& lpp = receivedData[i]; - const label gpI = lpp.pairLabel(); - const label pointI = bPoints[globalToLocal[gpI]]; - const labelPair& lp = lpp.pair(); - - forAllRow(pointFaceCandidates, pointI, i) - { - const label fI = pointFaceCandidates(pointI, i); - const DynList<label, 4>& f = faceCandidates[fI]; - + for + ( + std::map<label, List<labelledPair> >::const_iterator + iter=receivedMap.begin(); + iter!=receivedMap.end(); + ++iter + ) + { + const List<labelledPair>& receivedData = iter->second; + + forAll(receivedData, i) + { + const labelledPair& lpp = receivedData[i]; + const label gpI = lpp.pairLabel(); + const label pointI = bPoints[globalToLocal[gpI]]; + const labelPair& lp = lpp.pair(); + + forAllRow(pointFaceCandidates, pointI, i) + { + const label fI = pointFaceCandidates(pointI, i); + const DynList<label, 4>& f = faceCandidates[fI]; + Pair<label> pk ( patchKey_[candidatePatches[fI][0]], patchKey_[candidatePatches[fI][1]] ); - if( - (f[0] == pointI) && ((pk == lp) || (pk.reversePair() == lp)) - ) - { - //- found the processor containing other face - otherFaceProc[pointOfOriginToFaceLabel[lpp]] = iter->first; - } - } - } - } + if( + (f[0] == pointI) && ((pk == lp) || (pk.reversePair() == lp)) + ) + { + //- found the processor containing other face + otherFaceProc[pointOfOriginToFaceLabel[lpp]] = iter->first; + } + } + } + } receivedMap.clear(); - - //- sort the points in ascending order - //- this ensures the correct order of faces at the processor boundaries - sort(pointOfOrigin); - - Map<label> otherProcToProcPatch; + + //- sort the points in ascending order + //- this ensures the correct order of faces at the processor boundaries + sort(pointOfOrigin); + + Map<label> otherProcToProcPatch; forAll(mesh_.procBoundaries(), patchI) { const writeProcessorPatch& wp = mesh_.procBoundaries()[patchI]; otherProcToProcPatch.insert(wp.neiProcNo(), patchI); } - - //- store processor faces - VRWGraph newProcFaces; - labelListPMG newProc; - - forAll(pointOfOrigin, i) - { - const label fI = pointOfOriginToFaceLabel[pointOfOrigin[i]]; - - if( duplicateFace[fI] || (otherFaceProc[fI] == -1) ) - continue; - - if( !otherProcToProcPatch.found(otherFaceProc[fI]) ) - { - otherProcToProcPatch.insert - ( - otherFaceProc[fI], - polyMeshGenModifier(mesh_).addProcessorPatch - ( - otherFaceProc[fI] - ) - ); + + //- store processor faces + VRWGraph newProcFaces; + labelListPMG newProc; + + forAll(pointOfOrigin, i) + { + const label fI = pointOfOriginToFaceLabel[pointOfOrigin[i]]; + + if( duplicateFace[fI] || (otherFaceProc[fI] == -1) ) + continue; + + if( !otherProcToProcPatch.found(otherFaceProc[fI]) ) + { + otherProcToProcPatch.insert + ( + otherFaceProc[fI], + polyMeshGenModifier(mesh_).addProcessorPatch + ( + otherFaceProc[fI] + ) + ); } - - newProcFaces.appendList(faceCandidates[fI]); - newProc.append(otherProcToProcPatch[otherFaceProc[fI]]); - } + + newProcFaces.appendList(faceCandidates[fI]); + newProc.append(otherProcToProcPatch[otherFaceProc[fI]]); + } - polyMeshGenModifier(mesh_).addProcessorFaces(newProcFaces, newProc); + polyMeshGenModifier(mesh_).addProcessorFaces(newProcFaces, newProc); } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/meshLibrary/utilities/boundaryLayers/boundaryLayers.C b/meshLibrary/utilities/boundaryLayers/boundaryLayers.C index 2154ee90..6c363c98 100644 --- a/meshLibrary/utilities/boundaryLayers/boundaryLayers.C +++ b/meshLibrary/utilities/boundaryLayers/boundaryLayers.C @@ -44,7 +44,7 @@ Description namespace Foam { - + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // const meshSurfaceEngine& boundaryLayers::surfaceEngine() const @@ -57,58 +57,58 @@ const meshSurfaceEngine& boundaryLayers::surfaceEngine() const void boundaryLayers::findPatchesToBeTreatedTogether() { - forAll(treatPatchesWithPatch_, patchI) - treatPatchesWithPatch_[patchI].append(patchI); - - const meshSurfaceEngine& mse = surfaceEngine(); - - const VRWGraph& pPatches = mse.pointPatches(); - const pointFieldPMG& points = mesh_.points(); - const faceList::subList& bFaces = mse.boundaryFaces(); + forAll(treatPatchesWithPatch_, patchI) + treatPatchesWithPatch_[patchI].append(patchI); + + const meshSurfaceEngine& mse = surfaceEngine(); + + const VRWGraph& pPatches = mse.pointPatches(); + const pointFieldPMG& points = mesh_.points(); + const faceList::subList& bFaces = mse.boundaryFaces(); const edgeList& edges = mse.edges(); - const VRWGraph& eFaces = mse.edgeFaces(); - const labelList& boundaryFacePatches = mse.boundaryFacePatches(); - - //- patches must be treated together if there exist a corner where - //- more than three patches meet + const VRWGraph& eFaces = mse.edgeFaces(); + const labelList& boundaryFacePatches = mse.boundaryFacePatches(); + + //- patches must be treated together if there exist a corner where + //- more than three patches meet meshSurfacePartitioner mPart(mse); const labelHashSet& corners = mPart.corners(); - forAllConstIter(labelHashSet, corners, it) + forAllConstIter(labelHashSet, corners, it) { const label bpI = it.key(); - if( mPart.numberOfFeatureEdgesAtPoint(bpI) != 3 ) - { + if( mPart.numberOfFeatureEdgesAtPoint(bpI) != 3 ) + { labelHashSet commonPatches; DynList<label> allPatches; - forAllRow(pPatches, bpI, patchI) - { + forAllRow(pPatches, bpI, patchI) + { const DynList<label>& tpwp = treatPatchesWithPatch_[pPatches(bpI, patchI)]; - forAll(tpwp, pJ) + forAll(tpwp, pJ) { if( commonPatches.found(tpwp[pJ]) ) continue; commonPatches.insert(tpwp[pJ]); - allPatches.append(tpwp[pJ]); + allPatches.append(tpwp[pJ]); } - } - - forAllRow(pPatches, bpI, patchI) - treatPatchesWithPatch_[pPatches(bpI, patchI)] = allPatches; - - # ifdef DEBUGLayer - Info << "Corner " << bpI << " is shared by patches " - << pPatches[bpI] << endl; - Info << "All patches " << allPatches << endl; - # endif - } + } + + forAllRow(pPatches, bpI, patchI) + treatPatchesWithPatch_[pPatches(bpI, patchI)] = allPatches; + + # ifdef DEBUGLayer + Info << "Corner " << bpI << " is shared by patches " + << pPatches[bpI] << endl; + Info << "All patches " << allPatches << endl; + # endif + } } - - //- patches must be treated together for concave geometries + + //- patches must be treated together for concave geometries //- edgeClassification map counts the number of convex and concave edges //- for a given patch. The first counts convex edges and the second counts //- concave ones. If the number of concave edges is of the considerable @@ -118,8 +118,8 @@ void boundaryLayers::findPatchesToBeTreatedTogether() std::map<std::pair<label, label>, Pair<label> > edgeClassification; labelListPMG procEdges; - forAll(eFaces, eI) - { + forAll(eFaces, eI) + { if( eFaces.sizeOfRow(eI) != 2 ) { procEdges.append(eI); @@ -131,10 +131,10 @@ void boundaryLayers::findPatchesToBeTreatedTogether() if( invertedVertices.found(e[0]) || invertedVertices.found(e[1]) ) continue; - const label patch0 = boundaryFacePatches[eFaces(eI, 0)]; - const label patch1 = boundaryFacePatches[eFaces(eI, 1)]; - if( patch0 != patch1 ) - { + const label patch0 = boundaryFacePatches[eFaces(eI, 0)]; + const label patch1 = boundaryFacePatches[eFaces(eI, 1)]; + if( patch0 != patch1 ) + { std::pair<label, label> pp ( Foam::min(patch0, patch1), @@ -146,18 +146,18 @@ void boundaryLayers::findPatchesToBeTreatedTogether() std::make_pair(pp, Pair<label>(0, 0)) ); - const face& f1 = bFaces[eFaces(eI, 0)]; - const face& f2 = bFaces[eFaces(eI, 1)]; - if( !help::isSharedEdgeConvex(points, f1, f2) ) - { + const face& f1 = bFaces[eFaces(eI, 0)]; + const face& f2 = bFaces[eFaces(eI, 1)]; + if( !help::isSharedEdgeConvex(points, f1, f2) ) + { ++edgeClassification[pp].second(); - } + } else { ++edgeClassification[pp].first(); } - } - } + } + } if( Pstream::parRun() ) { @@ -411,8 +411,8 @@ void boundaryLayers::findPatchesToBeTreatedTogether() treatPatchesWithPatch_[patchJ].append(*iter); } } - - # ifdef DEBUGLayer + + # ifdef DEBUGLayer for(it=edgeClassification.begin();it!=edgeClassification.end();++it) { const std::pair<label, label>& edgePair = it->first; @@ -421,46 +421,46 @@ void boundaryLayers::findPatchesToBeTreatedTogether() << edgePair.second << " is " << nConvexAndConcave << endl; } - Info << "Patch names " << patchNames_ << endl; - Info << "Treat patches with patch " << treatPatchesWithPatch_ << endl; - # endif + Info << "Patch names " << patchNames_ << endl; + Info << "Treat patches with patch " << treatPatchesWithPatch_ << endl; + # endif } void boundaryLayers::addLayerForPatch(const label patchLabel) { - if( treatedPatch_[patchLabel] ) + if( treatedPatch_[patchLabel] ) return; - - const PtrList<writePatch>& boundaries = mesh_.boundaries(); - - if( returnReduce(boundaries[patchLabel].patchSize(), sumOp<label>()) == 0 ) + + const PtrList<writePatch>& boundaries = mesh_.boundaries(); + + if( returnReduce(boundaries[patchLabel].patchSize(), sumOp<label>()) == 0 ) return; - - boolList treatPatches(boundaries.size(), false); - if( patchWiseLayers_ ) - { - forAll(treatPatchesWithPatch_[patchLabel], pI) - treatPatches[treatPatchesWithPatch_[patchLabel][pI]] = true; - } - else - { - forAll(treatedPatch_, patchI) - if( !treatedPatch_[patchI] ) - treatPatches[patchI] = true; - } - - newLabelForVertex_.setSize(nPoints_); - newLabelForVertex_ = -1; - otherVrts_.clear(); - patchKey_.clear(); - - createNewVertices(treatPatches); - - createNewFacesAndCells(treatPatches); - - forAll(treatPatches, patchI) - if( treatPatches[patchI] ) - treatedPatch_[patchI] = true; + + boolList treatPatches(boundaries.size(), false); + if( patchWiseLayers_ ) + { + forAll(treatPatchesWithPatch_[patchLabel], pI) + treatPatches[treatPatchesWithPatch_[patchLabel][pI]] = true; + } + else + { + forAll(treatedPatch_, patchI) + if( !treatedPatch_[patchI] ) + treatPatches[patchI] = true; + } + + newLabelForVertex_.setSize(nPoints_); + newLabelForVertex_ = -1; + otherVrts_.clear(); + patchKey_.clear(); + + createNewVertices(treatPatches); + + createNewFacesAndCells(treatPatches); + + forAll(treatPatches, patchI) + if( treatPatches[patchI] ) + treatedPatch_[patchI] = true; } // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // @@ -471,29 +471,29 @@ boundaryLayers::boundaryLayers polyMeshGen& mesh ) : - mesh_(mesh), + mesh_(mesh), msePtr_(NULL), - patchWiseLayers_(true), + patchWiseLayers_(true), terminateLayersAtConcaveEdges_(false), - patchNames_(), - treatedPatch_(), - treatPatchesWithPatch_(), - newLabelForVertex_(), - otherVrts_(), - patchKey_(), - nPoints_(mesh.points().size()) + patchNames_(), + treatedPatch_(), + treatPatchesWithPatch_(), + newLabelForVertex_(), + otherVrts_(), + patchKey_(), + nPoints_(mesh.points().size()) { - const PtrList<writePatch>& boundaries = mesh_.boundaries(); - patchNames_.setSize(boundaries.size()); - forAll(boundaries, patchI) - patchNames_[patchI] = boundaries[patchI].patchName(); - - treatedPatch_.setSize(boundaries.size()); - treatedPatch_ = false; - - treatPatchesWithPatch_.setSize(boundaries.size()); - - findPatchesToBeTreatedTogether(); + const PtrList<writePatch>& boundaries = mesh_.boundaries(); + patchNames_.setSize(boundaries.size()); + forAll(boundaries, patchI) + patchNames_[patchI] = boundaries[patchI].patchName(); + + treatedPatch_.setSize(boundaries.size()); + treatedPatch_ = false; + + treatPatchesWithPatch_.setSize(boundaries.size()); + + findPatchesToBeTreatedTogether(); } // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // @@ -510,47 +510,47 @@ boundaryLayers::~boundaryLayers() void boundaryLayers::addLayerForPatch(const word& patchName) { - const PtrList<writePatch>& boundaries = mesh_.boundaries(); - - forAll(boundaries, patchI) - if( boundaries[patchI].patchName() == patchName ) - addLayerForPatch(patchI); + const PtrList<writePatch>& boundaries = mesh_.boundaries(); + + forAll(boundaries, patchI) + if( boundaries[patchI].patchName() == patchName ) + addLayerForPatch(patchI); } - + void boundaryLayers::createOTopologyLayers() { - patchWiseLayers_ = false; + patchWiseLayers_ = false; } void boundaryLayers::terminateLayersAtConcaveEdges() { terminateLayersAtConcaveEdges_ = true; } - + void boundaryLayers::addLayerForAllPatches() { - const PtrList<writePatch>& boundaries = mesh_.boundaries(); - - if( !patchWiseLayers_ ) - { - forAll(boundaries, patchI) - addLayerForPatch(patchI); - } - else - { - newLabelForVertex_.setSize(nPoints_); - newLabelForVertex_ = -1; - otherVrts_.clear(); - patchKey_.clear(); - - labelList treatedPatches(boundaries.size()); - forAll(treatedPatches, i) - treatedPatches[i] = i; - - createNewVertices(treatedPatches); + const PtrList<writePatch>& boundaries = mesh_.boundaries(); + + if( !patchWiseLayers_ ) + { + forAll(boundaries, patchI) + addLayerForPatch(patchI); + } + else + { + newLabelForVertex_.setSize(nPoints_); + newLabelForVertex_ = -1; + otherVrts_.clear(); + patchKey_.clear(); + + labelList treatedPatches(boundaries.size()); + forAll(treatedPatches, i) + treatedPatches[i] = i; - createLayerCells(treatedPatches); - } + createNewVertices(treatedPatches); + + createLayerCells(treatedPatches); + } } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/meshLibrary/utilities/boundaryLayers/boundaryLayers.H b/meshLibrary/utilities/boundaryLayers/boundaryLayers.H index dc98f2c1..d02566be 100644 --- a/meshLibrary/utilities/boundaryLayers/boundaryLayers.H +++ b/meshLibrary/utilities/boundaryLayers/boundaryLayers.H @@ -49,7 +49,7 @@ SourceFiles namespace Foam { - + // Forward declarations class meshSurfaceEngine; @@ -59,81 +59,81 @@ class meshSurfaceEngine; class boundaryLayers { - //- Reference to the mesh - polyMeshGen& mesh_; + //- Reference to the mesh + polyMeshGen& mesh_; //- pointer to mesh surface engine mutable meshSurfaceEngine* msePtr_; - - //- shall I create patch-wise layers (true) - //- O-topology layer (false) - bool patchWiseLayers_; + + //- shall I create patch-wise layers (true) + //- O-topology layer (false) + bool patchWiseLayers_; //- shall the layers be terminated at concave edges (true) bool terminateLayersAtConcaveEdges_; - - //- patch names - wordList patchNames_; - - //- helper which contains information if a boundary layer - //- has already been extruded for a given patch - boolList treatedPatch_; - - //- extrude patches with patch - List<DynList<label> > treatPatchesWithPatch_; - - //- label of a new node (helper) - labelListPMG newLabelForVertex_; - - //- map storing labels of new vertices created at node - //- and corner vertices - std::map<label, std::map<std::pair<label, label>, label> > otherVrts_; - - //- a key assigned to each patch. It is needed to search in otherVrts_ - labelList patchKey_; - - //- number of vertices in the mesh - label nPoints_; - - // Private member functions + + //- patch names + wordList patchNames_; + + //- helper which contains information if a boundary layer + //- has already been extruded for a given patch + boolList treatedPatch_; + + //- extrude patches with patch + List<DynList<label> > treatPatchesWithPatch_; + + //- label of a new node (helper) + labelListPMG newLabelForVertex_; + + //- map storing labels of new vertices created at node + //- and corner vertices + std::map<label, std::map<std::pair<label, label>, label> > otherVrts_; + + //- a key assigned to each patch. It is needed to search in otherVrts_ + labelList patchKey_; + + //- number of vertices in the mesh + label nPoints_; + + // Private member functions //- Return reference to meshSurfaceEngine const meshSurfaceEngine& surfaceEngine() const; - //- find if any other patches need to be treated together - //- with the given one - void findPatchesToBeTreatedTogether(); - - //- find vertices of the selected patches - void findPatchVertices - ( - const boolList& treatPatches, - List<direction>& patchVertex - ) const; + //- find if any other patches need to be treated together + //- with the given one + void findPatchesToBeTreatedTogether(); + + //- find vertices of the selected patches + void findPatchVertices + ( + const boolList& treatPatches, + List<direction>& patchVertex + ) const; //- check and correct the topology of boundary faces where //- the layers terminate void checkTopologyOfBoundaryFaces(const labelList& patchLabels); - - //- create new vertex - point createNewVertex - ( - const label bpI, - const boolList& treatPatches, - const List<direction>& pVertices - ) const; - - //- create new vertices for the selected patches - void createNewVertices - ( - const boolList& treatPatches - ); - - //- create new vertices such that layers for selected patches - //- are generated in a single run - void createNewVertices - ( - const labelList& patchLabels - ); + + //- create new vertex + point createNewVertex + ( + const label bpI, + const boolList& treatPatches, + const List<direction>& pVertices + ) const; + + //- create new vertices for the selected patches + void createNewVertices + ( + const boolList& treatPatches + ); + + //- create new vertices such that layers for selected patches + //- are generated in a single run + void createNewVertices + ( + const labelList& patchLabels + ); //- creates new vertices for vertices at parallel boundaries void createNewPartitionVerticesParallel @@ -151,60 +151,60 @@ class boundaryLayers const List<direction>& pVertices, const boolList& treatPatches ); - - //- create a layer of cells - void createNewFacesAndCells - ( - const boolList& treatPatches - ); + + //- create a layer of cells + void createNewFacesAndCells + ( + const boolList& treatPatches + ); + + //- create new faces at parallel boundaries + //- faces are extruded from edges + void createNewFacesParallel + ( + const boolList& treatPatches + ); //- create new faces at parallel boundaries - //- faces are extruded from edges - void createNewFacesParallel - ( - const boolList& treatPatches - ); - - //- create new faces at parallel boundaries - //- faces are created from points at parallel boundaries - //- the function takes a reference to the faces which are the candidates - //- to create faces at parallel boundaries - void createNewFacesFromPointsParallel - ( - const LongList<DynList<label, 4> >& faceCandidates, - const LongList<labelPair>& candidatePatches - ); - - //- create layer cells in one go - //- this is much faster than layer by layer - void createLayerCells(const labelList& patchLabels); - - //- helper function finding a new face label for multiply extruded nodes - inline label findNewNodeLabel - ( - const label pointI, - const label pKey - ) const; - - //- creating hex cells near feature edges - inline void createNewCellFromEdge - ( - const edge& e, - const label pKeyI, - const label pKeyJ, - DynList<DynList<label, 4>, 6>& cellFaces - ) const; - - //- creating hex cells near corners - inline void createNewCellFromNode - ( - const label pointI, - const DynList<label, 3>& pKeys, - DynList<DynList<label, 4>, 6>& cellFaces - ) const; - - //- create a bnd layer for a given patch - void addLayerForPatch(const label patchLabel); + //- faces are created from points at parallel boundaries + //- the function takes a reference to the faces which are the candidates + //- to create faces at parallel boundaries + void createNewFacesFromPointsParallel + ( + const LongList<DynList<label, 4> >& faceCandidates, + const LongList<labelPair>& candidatePatches + ); + + //- create layer cells in one go + //- this is much faster than layer by layer + void createLayerCells(const labelList& patchLabels); + + //- helper function finding a new face label for multiply extruded nodes + inline label findNewNodeLabel + ( + const label pointI, + const label pKey + ) const; + + //- creating hex cells near feature edges + inline void createNewCellFromEdge + ( + const edge& e, + const label pKeyI, + const label pKeyJ, + DynList<DynList<label, 4>, 6>& cellFaces + ) const; + + //- creating hex cells near corners + inline void createNewCellFromNode + ( + const label pointI, + const DynList<label, 3>& pKeys, + DynList<DynList<label, 4>, 6>& cellFaces + ) const; + + //- create a bnd layer for a given patch + void addLayerForPatch(const label patchLabel); //- delete meshSurfaceEngine inline void clearOut() @@ -221,33 +221,33 @@ class boundaryLayers CORNERNODE = 4, PARALLELBOUNDARY = 8 }; - - public: - - // Constructors - - //- Construct from mesh reference - boundaryLayers(polyMeshGen& mesh); - - // Destructor - ~boundaryLayers(); - - // Public member functions - //- adds layer for a given patch - void addLayerForPatch(const word& patchName); - - //- create O-topology layers (used as flag) - void createOTopologyLayers(); + + public: + + // Constructors + + //- Construct from mesh reference + boundaryLayers(polyMeshGen& mesh); + + // Destructor + ~boundaryLayers(); + + // Public member functions + //- adds layer for a given patch + void addLayerForPatch(const word& patchName); + + //- create O-topology layers (used as flag) + void createOTopologyLayers(); //- terminate boundary layers at concave edges (used as a flag) void terminateLayersAtConcaveEdges(); - - //- add layers for all patches - void addLayerForAllPatches(); - - //- add wrapper layer - //- this function is intended for usage before surface recovery - void addWrapperLayer(); + + //- add layers for all patches + void addLayerForAllPatches(); + + //- add wrapper layer + //- this function is intended for usage before surface recovery + void addWrapperLayer(); }; diff --git a/meshLibrary/utilities/boundaryLayers/boundaryLayersCreateVertices.C b/meshLibrary/utilities/boundaryLayers/boundaryLayersCreateVertices.C index 89b48fb1..347532c4 100644 --- a/meshLibrary/utilities/boundaryLayers/boundaryLayersCreateVertices.C +++ b/meshLibrary/utilities/boundaryLayers/boundaryLayersCreateVertices.C @@ -49,15 +49,15 @@ namespace Foam void boundaryLayers::findPatchVertices ( - const boolList& treatPatches, - List<direction>& pVertices + const boolList& treatPatches, + List<direction>& pVertices ) const { const meshSurfaceEngine& mse = surfaceEngine(); const VRWGraph& pPatches = mse.pointPatches(); pVertices.setSize(pPatches.size()); - pVertices = NONE; + pVertices = NONE; # pragma omp parallel for if( pPatches.size() > 1000 ) \ schedule(dynamic, Foam::max(10, pPatches.size()/(2*omp_get_num_threads()))) @@ -100,252 +100,252 @@ void boundaryLayers::findPatchVertices point boundaryLayers::createNewVertex ( - const label bpI, - const boolList& treatPatches, - const List<direction>& patchVertex + const label bpI, + const boolList& treatPatches, + const List<direction>& patchVertex ) const { - const meshSurfaceEngine& mse = surfaceEngine(); - const labelList& bPoints = mse.boundaryPoints(); - const faceList::subList& bFaces = mse.boundaryFaces(); - const vectorField& pNormals = mse.pointNormals(); - const VRWGraph& pFaces = mse.pointFaces(); + const meshSurfaceEngine& mse = surfaceEngine(); + const labelList& bPoints = mse.boundaryPoints(); + const faceList::subList& bFaces = mse.boundaryFaces(); + const vectorField& pNormals = mse.pointNormals(); + const VRWGraph& pFaces = mse.pointFaces(); const VRWGraph& pPatches = mse.pointPatches(); - const labelList& boundaryFacePatches = mse.boundaryFacePatches(); - const VRWGraph& pointPoints = mse.pointPoints(); - - const pointFieldPMG& points = mesh_.points(); - - # ifdef DEBUGLayer - Info << "Creating new vertex for boundary vertex " << bpI << endl; - Info << "Global vertex label " << bPoints[bpI] << endl; - # endif - - vector normal(vector::zero); - scalar dist(VGREAT); - const point& p = points[bPoints[bpI]]; - if( patchVertex[bpI] & EDGENODE ) - { - # ifdef DEBUGLayer - Info << "Vertex is on the border" << endl; - # endif - - DynList<label> otherPatches(2); - forAllRow(pPatches, bpI, patchI) - if( !treatPatches[pPatches(bpI, patchI)] ) - otherPatches.appendIfNotIn - ( - pPatches(bpI, patchI) - ); - - if( otherPatches.size() == 1 ) - { - //- vertex is on an edge - # ifdef DEBUGLayer - Info << "Vertex is on an edge" << endl; - # endif - vector v(vector::zero); - - forAllRow(pFaces, bpI, pfI) - { - const face& f = bFaces[pFaces(bpI, pfI)]; - const label patchLabel = - boundaryFacePatches[pFaces(bpI, pfI)]; - - if( treatPatches[patchLabel] ) - { - normal += f.normal(points); - } - else - { - v += f.normal(points); - } - } + const labelList& boundaryFacePatches = mse.boundaryFacePatches(); + const VRWGraph& pointPoints = mse.pointPoints(); + + const pointFieldPMG& points = mesh_.points(); + + # ifdef DEBUGLayer + Info << "Creating new vertex for boundary vertex " << bpI << endl; + Info << "Global vertex label " << bPoints[bpI] << endl; + # endif + + vector normal(vector::zero); + scalar dist(VGREAT); + const point& p = points[bPoints[bpI]]; + if( patchVertex[bpI] & EDGENODE ) + { + # ifdef DEBUGLayer + Info << "Vertex is on the border" << endl; + # endif + + DynList<label> otherPatches(2); + forAllRow(pPatches, bpI, patchI) + if( !treatPatches[pPatches(bpI, patchI)] ) + otherPatches.appendIfNotIn + ( + pPatches(bpI, patchI) + ); + + if( otherPatches.size() == 1 ) + { + //- vertex is on an edge + # ifdef DEBUGLayer + Info << "Vertex is on an edge" << endl; + # endif + vector v(vector::zero); + + forAllRow(pFaces, bpI, pfI) + { + const face& f = bFaces[pFaces(bpI, pfI)]; + const label patchLabel = + boundaryFacePatches[pFaces(bpI, pfI)]; + + if( treatPatches[patchLabel] ) + { + normal += f.normal(points); + } + else + { + v += f.normal(points); + } + } - const scalar magV = mag(v); - if( magV > VSMALL ) - v /= magV; - - normal -= (normal & v) * v; - - const scalar magN = mag(normal); - if( magN > VSMALL ) - normal /= magN; - - forAllRow(pointPoints, bpI, ppI) - { - if( patchVertex[pointPoints(bpI, ppI)] ) - continue; + const scalar magV = mag(v); + if( magV > VSMALL ) + v /= magV; + + normal -= (normal & v) * v; + + const scalar magN = mag(normal); + if( magN > VSMALL ) + normal /= magN; + + forAllRow(pointPoints, bpI, ppI) + { + if( patchVertex[pointPoints(bpI, ppI)] ) + continue; - vector vec = points[bPoints[pointPoints(bpI, ppI)]] - p; - const scalar prod = 0.5 * mag(vec & normal); - - if( prod < dist ) - dist = prod; - } - } - else if( otherPatches.size() == 2 ) - { - # ifdef DEBUGLayer - Info << "Vertex is a corner" << endl; - # endif - - label otherVertex(-1); - forAllRow(pointPoints, bpI, ppI) - { - const label bpJ = pointPoints(bpI, ppI); - - bool found(true); - forAll(otherPatches, opI) - if( !pPatches.contains(bpJ, otherPatches[opI]) ) - { - found = false; - break; - } - - if( found ) - { - otherVertex = bpJ; - break; - } - } - - if( otherVertex == -1 ) - { - FatalErrorIn - ( - "void boundaryLayers::createNewVertices" - "(" - "const boolList& treatPatches," - "labelList& newLabelForVertex" - ")" - ) << "Cannot find moving vertex!" << exit(FatalError); - } - - //- normal vector is co-linear with that edge - normal = p - points[bPoints[otherVertex]]; - dist = 0.5 * mag(normal); - - if( mag(dist) > VSMALL ) - normal /= 2.0 * dist; - } - else - { - FatalErrorIn - ( - "void boundaryLayers::createNewVertices" - "(" - "const boolList& treatPatches," - "labelList& newLabelForVertex" - ") const" - ) << "There are more than 3 patches meeting at this vertex!" - << pPatches[bpI] << abort(FatalError); - } - - //- limit distances - forAllRow(pFaces, bpI, pfI) - { - const label faceLabel = pFaces(bpI, pfI); - if( otherPatches.contains(boundaryFacePatches[faceLabel]) ) - { - const face& f = bFaces[faceLabel]; - const label pos = f.which(bPoints[bpI]); - - if( pos != -1 ) - { - const point& ep1 = points[f.prevLabel(pos)]; - const point& ep2 = points[f.nextLabel(pos)]; - - const scalar dst = - help::distanceOfPointFromTheEdge(ep1, ep2, p); - - if( dst < dist ) - dist = 0.9 * dst; - } - else - { - FatalErrorIn - ( - "void boundaryLayers::createNewVertices" - "(" - "const boolList& treatPatches," - "labelList& newLabelForVertex" - ") const" - ) << "Face does not contains this vertex!" - << abort(FatalError); - } - } - } - } - else - { - normal = pNormals[bpI]; - - forAllRow(pointPoints, bpI, ppI) - { - const scalar d = - 0.5 * mag - ( - points[bPoints[pointPoints(bpI, ppI)]] - - p - ); - - if( d < dist ) - dist = d; - } - } - - //- create new vertex - # ifdef DEBUGLayer - Info << "Normal for vertex " << bpI << " is " << normal << endl; - Info << "Distance is " << dist << endl; - # endif - - return p - dist * normal; + vector vec = points[bPoints[pointPoints(bpI, ppI)]] - p; + const scalar prod = 0.5 * mag(vec & normal); + + if( prod < dist ) + dist = prod; + } + } + else if( otherPatches.size() == 2 ) + { + # ifdef DEBUGLayer + Info << "Vertex is a corner" << endl; + # endif + + label otherVertex(-1); + forAllRow(pointPoints, bpI, ppI) + { + const label bpJ = pointPoints(bpI, ppI); + + bool found(true); + forAll(otherPatches, opI) + if( !pPatches.contains(bpJ, otherPatches[opI]) ) + { + found = false; + break; + } + + if( found ) + { + otherVertex = bpJ; + break; + } + } + + if( otherVertex == -1 ) + { + FatalErrorIn + ( + "void boundaryLayers::createNewVertices" + "(" + "const boolList& treatPatches," + "labelList& newLabelForVertex" + ")" + ) << "Cannot find moving vertex!" << exit(FatalError); + } + + //- normal vector is co-linear with that edge + normal = p - points[bPoints[otherVertex]]; + dist = 0.5 * mag(normal); + + if( mag(dist) > VSMALL ) + normal /= 2.0 * dist; + } + else + { + FatalErrorIn + ( + "void boundaryLayers::createNewVertices" + "(" + "const boolList& treatPatches," + "labelList& newLabelForVertex" + ") const" + ) << "There are more than 3 patches meeting at this vertex!" + << pPatches[bpI] << abort(FatalError); + } + + //- limit distances + forAllRow(pFaces, bpI, pfI) + { + const label faceLabel = pFaces(bpI, pfI); + if( otherPatches.contains(boundaryFacePatches[faceLabel]) ) + { + const face& f = bFaces[faceLabel]; + const label pos = f.which(bPoints[bpI]); + + if( pos != -1 ) + { + const point& ep1 = points[f.prevLabel(pos)]; + const point& ep2 = points[f.nextLabel(pos)]; + + const scalar dst = + help::distanceOfPointFromTheEdge(ep1, ep2, p); + + if( dst < dist ) + dist = 0.9 * dst; + } + else + { + FatalErrorIn + ( + "void boundaryLayers::createNewVertices" + "(" + "const boolList& treatPatches," + "labelList& newLabelForVertex" + ") const" + ) << "Face does not contains this vertex!" + << abort(FatalError); + } + } + } + } + else + { + normal = pNormals[bpI]; + + forAllRow(pointPoints, bpI, ppI) + { + const scalar d = + 0.5 * mag + ( + points[bPoints[pointPoints(bpI, ppI)]] - + p + ); + + if( d < dist ) + dist = d; + } + } + + //- create new vertex + # ifdef DEBUGLayer + Info << "Normal for vertex " << bpI << " is " << normal << endl; + Info << "Distance is " << dist << endl; + # endif + + return p - dist * normal; } - + void boundaryLayers::createNewVertices(const boolList& treatPatches) { - Info << "Creating vertices for layer cells" << endl; + Info << "Creating vertices for layer cells" << endl; - List<direction> patchVertex; - findPatchVertices(treatPatches, patchVertex); - + List<direction> patchVertex; + findPatchVertices(treatPatches, patchVertex); + const meshSurfaceEngine& mse = surfaceEngine(); - const labelList& bPoints = mse.boundaryPoints(); - - //- the following is needed for parallel runs - //- it is ugly, but must stay for now :( - if( Pstream::parRun() ) - { - mse.pointNormals(); - mse.pointPatches(); + const labelList& bPoints = mse.boundaryPoints(); + + //- the following is needed for parallel runs + //- it is ugly, but must stay for now :( + if( Pstream::parRun() ) + { + mse.pointNormals(); + mse.pointPatches(); mse.pointPoints(); - } - - pointFieldPMG& points = mesh_.points(); - - label nExtrudedVertices(0); - forAll(patchVertex, bpI) - if( patchVertex[bpI] ) - ++nExtrudedVertices; - - points.setSize(points.size() + nExtrudedVertices); - + } + + pointFieldPMG& points = mesh_.points(); + + label nExtrudedVertices(0); + forAll(patchVertex, bpI) + if( patchVertex[bpI] ) + ++nExtrudedVertices; + + points.setSize(points.size() + nExtrudedVertices); + labelListPMG procPoints; - forAll(bPoints, bpI) - if( patchVertex[bpI] ) - { + forAll(bPoints, bpI) + if( patchVertex[bpI] ) + { if( patchVertex[bpI] & PARALLELBOUNDARY ) { procPoints.append(bpI); continue; } - points[nPoints_] = createNewVertex(bpI, treatPatches, patchVertex); - newLabelForVertex_[bPoints[bpI]] = nPoints_; - ++nPoints_; - } + points[nPoints_] = createNewVertex(bpI, treatPatches, patchVertex); + newLabelForVertex_[bPoints[bpI]] = nPoints_; + ++nPoints_; + } if( Pstream::parRun() ) { @@ -365,113 +365,113 @@ void boundaryLayers::createNewVertices(const boolList& treatPatches) } //- swap coordinates of new and old points - forAll(bPoints, bpI) - { - const label pLabel = newLabelForVertex_[bPoints[bpI]]; - if( pLabel != -1 ) - { + forAll(bPoints, bpI) + { + const label pLabel = newLabelForVertex_[bPoints[bpI]]; + if( pLabel != -1 ) + { const point p = points[pLabel]; - points[pLabel] = points[bPoints[bpI]]; + points[pLabel] = points[bPoints[bpI]]; points[bPoints[bpI]] = p; - } - } + } + } - if( nPoints_ != points.size() ) - FatalErrorIn - ( - "void boundaryLayers::createNewVertices(" - "const meshSurfaceEngine& mse," - "const boolList& treatPatches," - "labelList& newLabelForVertex)" - ) << "Number of vertices " << nPoints_ - << " does not match the list size " - << abort(FatalError); - - Info << "Finished creating layer vertices" << endl; + if( nPoints_ != points.size() ) + FatalErrorIn + ( + "void boundaryLayers::createNewVertices(" + "const meshSurfaceEngine& mse," + "const boolList& treatPatches," + "labelList& newLabelForVertex)" + ) << "Number of vertices " << nPoints_ + << " does not match the list size " + << abort(FatalError); + + Info << "Finished creating layer vertices" << endl; } void boundaryLayers::createNewVertices(const labelList& patchLabels) { - otherVrts_.clear(); - - patchKey_.setSize(mesh_.boundaries().size()); - patchKey_ = -1; - - const meshSurfaceEngine& mse = surfaceEngine(); + otherVrts_.clear(); + + patchKey_.setSize(mesh_.boundaries().size()); + patchKey_ = -1; + + const meshSurfaceEngine& mse = surfaceEngine(); const VRWGraph& pPatches = mse.pointPatches(); - const labelList& bPoints = mse.boundaryPoints(); + const labelList& bPoints = mse.boundaryPoints(); const label nBndPts = bPoints.size(); //- the following is needed for parallel runs - //- it is ugly, but must stay for now :( - mse.boundaryFaces(); - mse.pointNormals(); - mse.pointFaces(); - mse.boundaryFacePatches(); - mse.pointPoints(); - - pointFieldPMG& points = mesh_.points(); + //- it is ugly, but must stay for now :( + mse.boundaryFaces(); + mse.pointNormals(); + mse.pointFaces(); + mse.boundaryFacePatches(); + mse.pointPoints(); + + pointFieldPMG& points = mesh_.points(); boolList treatPatches(mesh_.boundaries().size()); List<direction> patchVertex(nBndPts); - - //- generate new layer vertices for each patch - forAll(patchLabels, patchI) - { - const label pLabel = patchLabels[patchI]; - treatPatches = false; - - bool treat(true); - forAll(treatPatchesWithPatch_[pLabel], pI) - { - const label otherPatch = treatPatchesWithPatch_[pLabel][pI]; - treatPatches[otherPatch] = true; - - if( patchKey_[otherPatch] == -1 ) - { - patchKey_[otherPatch] = patchI; - } - else - { - treat = false; - } - } - - if( !treat ) - continue; - - const label pKey = patchKey_[pLabel]; - - //- classify vertices belonging to this patch - findPatchVertices(treatPatches, patchVertex); - - //- go throught the vertices and create the new ones - labelListPMG procPoints; + + //- generate new layer vertices for each patch + forAll(patchLabels, patchI) + { + const label pLabel = patchLabels[patchI]; + treatPatches = false; + + bool treat(true); + forAll(treatPatchesWithPatch_[pLabel], pI) + { + const label otherPatch = treatPatchesWithPatch_[pLabel][pI]; + treatPatches[otherPatch] = true; + + if( patchKey_[otherPatch] == -1 ) + { + patchKey_[otherPatch] = patchI; + } + else + { + treat = false; + } + } + + if( !treat ) + continue; + + const label pKey = patchKey_[pLabel]; + + //- classify vertices belonging to this patch + findPatchVertices(treatPatches, patchVertex); + + //- go throught the vertices and create the new ones + labelListPMG procPoints; # pragma omp parallel for if( nBndPts > 100 ) \ schedule(dynamic, Foam::max(10, nBndPts/(2*omp_get_num_threads()))) for(label bpI=0;bpI<nBndPts;++bpI) - { - if( !patchVertex[bpI] ) - continue; - - //- skip vertices at parallel boundaries - if( patchVertex[bpI] & PARALLELBOUNDARY ) - { + { + if( !patchVertex[bpI] ) + continue; + + //- skip vertices at parallel boundaries + if( patchVertex[bpI] & PARALLELBOUNDARY ) + { # pragma omp critical(appendProcPoints) procPoints.append(bpI); - continue; - } - - const label pointI = bPoints[bpI]; + continue; + } + + const label pointI = bPoints[bpI]; label nPoints; # pragma omp critical(incrementNumPoints) nPoints = nPoints_++; - - //- create new point - const point p = createNewVertex(bpI, treatPatches, patchVertex); - - if( patchVertex[bpI] & EDGENODE ) - { + + //- create new point + const point p = createNewVertex(bpI, treatPatches, patchVertex); + + if( patchVertex[bpI] & EDGENODE ) + { # pragma omp critical(adjustMap) { if( otherVrts_.find(pointI) == otherVrts_.end() ) @@ -484,145 +484,145 @@ void boundaryLayers::createNewVertices(const labelList& patchLabels) std::pair<label, label> pr(pKey, pKey); otherVrts_[pointI].insert(std::make_pair(pr, nPoints)); } - } - else - { - //- this the only new point for a given vertex - newLabelForVertex_[pointI] = nPoints; - } - - //- store the point + } + else + { + //- this the only new point for a given vertex + newLabelForVertex_[pointI] = nPoints; + } + + //- store the point # pragma omp critical(addVertex) { points.newElmt(nPoints) = p; } - } - - if( Pstream::parRun() ) - { - points.setSize(nPoints_+procPoints.size()); - - createNewPartitionVerticesParallel - ( - procPoints, - patchVertex, - treatPatches - ); - - createNewEdgeVerticesParallel - ( - procPoints, - patchVertex, - treatPatches - ); - } - } - - //- create missing vertices for edge and corner vertices - //- they should be stored in the otherNodes map - forAll(bPoints, bpI) - { - const label pointI = bPoints[bpI]; - - if( otherVrts_.find(pointI) == otherVrts_.end() ) - continue; - - const point& p = points[pointI]; - - std::map<std::pair<label, label>, label>& m = otherVrts_[pointI]; - DynList<label> usedPatches(3); - DynList<label> newNodeLabel(3); - DynList<vector> newPatchPenetrationVector(3); - forAllRow(pPatches, bpI, patchI) - { - const label pKey = patchKey_[pPatches(bpI, patchI)]; - const std::pair<label, label> pr(pKey, pKey); - const std::map<std::pair<label, label>, label>::const_iterator it = - m.find(pr); - if( (it != m.end()) && !usedPatches.contains(pKey) ) - { - usedPatches.append(pKey); - newNodeLabel.append(it->second); - newPatchPenetrationVector.append(points[it->second] - p); - } - } - - if( newNodeLabel.size() == 1 ) - { - //- only one patch is treated - newLabelForVertex_[pointI] = newNodeLabel[0]; - otherVrts_.erase(pointI); - } - else if( newNodeLabel.size() == 2 ) - { - //- point is located at an extrusion edge - //- create the new position for the existing point - point newP(p); - newP += newPatchPenetrationVector[0]; - newP += newPatchPenetrationVector[1]; - - points.append(newP); - newLabelForVertex_[pointI] = nPoints_; - ++nPoints_; - } - else if( newNodeLabel.size() == 3 ) - { - //- point is located at an extrusion corner - //- create 3 points and the new position for the existing point - point newP(p); - for(label i=0;i<3;++i) - { - newP += newPatchPenetrationVector[i]; - for(label j=i+1;j<3;++j) - { - const point np = - p + newPatchPenetrationVector[i] + - newPatchPenetrationVector[j]; - - points.append(np); - m.insert - ( - std::make_pair - ( - std::make_pair(usedPatches[i], usedPatches[j]), + } + + if( Pstream::parRun() ) + { + points.setSize(nPoints_+procPoints.size()); + + createNewPartitionVerticesParallel + ( + procPoints, + patchVertex, + treatPatches + ); + + createNewEdgeVerticesParallel + ( + procPoints, + patchVertex, + treatPatches + ); + } + } + + //- create missing vertices for edge and corner vertices + //- they should be stored in the otherNodes map + forAll(bPoints, bpI) + { + const label pointI = bPoints[bpI]; + + if( otherVrts_.find(pointI) == otherVrts_.end() ) + continue; + + const point& p = points[pointI]; + + std::map<std::pair<label, label>, label>& m = otherVrts_[pointI]; + DynList<label> usedPatches(3); + DynList<label> newNodeLabel(3); + DynList<vector> newPatchPenetrationVector(3); + forAllRow(pPatches, bpI, patchI) + { + const label pKey = patchKey_[pPatches(bpI, patchI)]; + const std::pair<label, label> pr(pKey, pKey); + const std::map<std::pair<label, label>, label>::const_iterator it = + m.find(pr); + if( (it != m.end()) && !usedPatches.contains(pKey) ) + { + usedPatches.append(pKey); + newNodeLabel.append(it->second); + newPatchPenetrationVector.append(points[it->second] - p); + } + } + + if( newNodeLabel.size() == 1 ) + { + //- only one patch is treated + newLabelForVertex_[pointI] = newNodeLabel[0]; + otherVrts_.erase(pointI); + } + else if( newNodeLabel.size() == 2 ) + { + //- point is located at an extrusion edge + //- create the new position for the existing point + point newP(p); + newP += newPatchPenetrationVector[0]; + newP += newPatchPenetrationVector[1]; + + points.append(newP); + newLabelForVertex_[pointI] = nPoints_; + ++nPoints_; + } + else if( newNodeLabel.size() == 3 ) + { + //- point is located at an extrusion corner + //- create 3 points and the new position for the existing point + point newP(p); + for(label i=0;i<3;++i) + { + newP += newPatchPenetrationVector[i]; + for(label j=i+1;j<3;++j) + { + const point np = + p + newPatchPenetrationVector[i] + + newPatchPenetrationVector[j]; + + points.append(np); + m.insert + ( + std::make_pair + ( + std::make_pair(usedPatches[i], usedPatches[j]), nPoints_ - ) - ); - ++nPoints_; - } - } - - //- create new position for the existing point - points.append(newP); - newLabelForVertex_[pointI] = nPoints_; - ++nPoints_; - } - else - { - FatalErrorIn - ( - "void boundaryLayers::createNewVertices(" - "const labelList& patchLabels, labelListPMG& newLabelForVertex," - "std::map<label, std::map<std::pair<label, label>, label> >&)" - ) << "Boundary node " << bpI << " is not at an edge!" - << abort(FatalError); - } - } - - //- swap coordinates of new and old points + ) + ); + ++nPoints_; + } + } + + //- create new position for the existing point + points.append(newP); + newLabelForVertex_[pointI] = nPoints_; + ++nPoints_; + } + else + { + FatalErrorIn + ( + "void boundaryLayers::createNewVertices(" + "const labelList& patchLabels, labelListPMG& newLabelForVertex," + "std::map<label, std::map<std::pair<label, label>, label> >&)" + ) << "Boundary node " << bpI << " is not at an edge!" + << abort(FatalError); + } + } + + //- swap coordinates of new and old points # pragma omp parallel for if( bPoints.size() > 1000 ) \ schedule(dynamic, 100) - forAll(bPoints, bpI) - { - const label pLabel = newLabelForVertex_[bPoints[bpI]]; + forAll(bPoints, bpI) + { + const label pLabel = newLabelForVertex_[bPoints[bpI]]; - if( pLabel != -1 ) - { + if( pLabel != -1 ) + { const point p = points[pLabel]; - points[pLabel] = points[bPoints[bpI]]; + points[pLabel] = points[bPoints[bpI]]; points[bPoints[bpI]] = p; - } - } + } + } } void boundaryLayers::createNewPartitionVerticesParallel @@ -778,17 +778,17 @@ void boundaryLayers::createNewEdgeVerticesParallel scalarField dist(edgePoints.size(), VGREAT); vectorField normal(edgePoints.size(), vector::zero); vectorField v(edgePoints.size(), vector::zero); - - label pKey(-1); - if( patchKey_.size() ) - { - forAll(treatPatches, patchI) - if( treatPatches[patchI] ) - { - pKey = patchKey_[patchI]; - break; - } - } + + label pKey(-1); + if( patchKey_.size() ) + { + forAll(treatPatches, patchI) + if( treatPatches[patchI] ) + { + pKey = patchKey_[patchI]; + break; + } + } forAll(edgePoints, epI) { @@ -996,7 +996,7 @@ void boundaryLayers::createNewEdgeVerticesParallel } } } - + //- exchange distances with other processors std::map<label, LongList<labelledScalar> > exchangeDistances; forAll(neiProcs, procI) @@ -1039,25 +1039,25 @@ void boundaryLayers::createNewEdgeVerticesParallel const point& p = points[bPoints[bpI]]; points[nPoints_] = p - normal[epI] * dist[epI]; - - if( pKey == -1 ) - { - //- extrusion for one patch in a single go - newLabelForVertex_[bPoints[bpI]] = nPoints_; - } - else - { - const label pointI = bPoints[bpI]; - - if( otherVrts_.find(pointI) == otherVrts_.end() ) - { - std::map<std::pair<label, label>, label> m; - otherVrts_.insert(std::make_pair(pointI, m)); - } - - std::pair<label, label> pr(pKey, pKey); - otherVrts_[pointI].insert(std::make_pair(pr, nPoints_)); - } + + if( pKey == -1 ) + { + //- extrusion for one patch in a single go + newLabelForVertex_[bPoints[bpI]] = nPoints_; + } + else + { + const label pointI = bPoints[bpI]; + + if( otherVrts_.find(pointI) == otherVrts_.end() ) + { + std::map<std::pair<label, label>, label> m; + otherVrts_.insert(std::make_pair(pointI, m)); + } + + std::pair<label, label> pr(pKey, pKey); + otherVrts_[pointI].insert(std::make_pair(pr, nPoints_)); + } ++nPoints_; } } diff --git a/meshLibrary/utilities/boundaryLayers/boundaryLayersFacesAndCells.C b/meshLibrary/utilities/boundaryLayers/boundaryLayersFacesAndCells.C index 312abe0b..6cf85315 100644 --- a/meshLibrary/utilities/boundaryLayers/boundaryLayersFacesAndCells.C +++ b/meshLibrary/utilities/boundaryLayers/boundaryLayersFacesAndCells.C @@ -47,14 +47,14 @@ namespace Foam void boundaryLayers::createNewFacesAndCells(const boolList& treatPatches) { - Info << "Starting creating layer cells" << endl; + Info << "Starting creating layer cells" << endl; const meshSurfaceEngine& mse = surfaceEngine(); - const faceList::subList& bFaces = mse.boundaryFaces(); - const VRWGraph& faceEdges = mse.faceEdges(); - const VRWGraph& edgeFaces = mse.edgeFaces(); - const labelList& boundaryFacePatches = mse.boundaryFacePatches(); - const labelList& faceOwners = mse.faceOwners(); + const faceList::subList& bFaces = mse.boundaryFaces(); + const VRWGraph& faceEdges = mse.faceEdges(); + const VRWGraph& edgeFaces = mse.edgeFaces(); + const labelList& boundaryFacePatches = mse.boundaryFacePatches(); + const labelList& faceOwners = mse.faceOwners(); //- this is used for parallel runs const Map<label>* otherProcPatchPtr(NULL); @@ -65,52 +65,52 @@ void boundaryLayers::createNewFacesAndCells(const boolList& treatPatches) otherProcPatchPtr = &mse.otherEdgeFacePatch(); } - - //- create lists for new boundary faces - VRWGraph newBoundaryFaces; - labelListPMG newBoundaryOwners; - labelListPMG newBoundaryPatches; + + //- create lists for new boundary faces + VRWGraph newBoundaryFaces; + labelListPMG newBoundaryOwners; + labelListPMG newBoundaryPatches; //- create storage for new cells - VRWGraphList cellsToAdd; - - //- create layer cells and store boundary faces - const label nOldCells = mesh_.cells().size(); - forAll(bFaces, bfI) - if( treatPatches[boundaryFacePatches[bfI]] ) - { - const face& f = bFaces[bfI]; - - faceList cellFaces(f.size() + 2); - - direction fI(0); - //- store boundary face - cellFaces[fI++] = f.reverseFace(); - - //- create parallel face - face newF(f.size()); - forAll(f, pI) - newF[pI] = newLabelForVertex_[f[pI]]; - cellFaces[fI++] = newF; - - newBoundaryFaces.appendList(newF); - newBoundaryOwners.append(cellsToAdd.size() + nOldCells); - newBoundaryPatches.append(boundaryFacePatches[bfI]); - - //- create quad faces - newF.setSize(4); - forAll(f, pI) - { - newF[0] = f[pI]; - newF[1] = f.nextLabel(pI); - newF[2] = newLabelForVertex_[f.nextLabel(pI)]; - newF[3] = newLabelForVertex_[f[pI]]; - - cellFaces[fI++] = newF; - - //- check if the face is at the boundary + VRWGraphList cellsToAdd; + + //- create layer cells and store boundary faces + const label nOldCells = mesh_.cells().size(); + forAll(bFaces, bfI) + if( treatPatches[boundaryFacePatches[bfI]] ) + { + const face& f = bFaces[bfI]; + + faceList cellFaces(f.size() + 2); + + direction fI(0); + //- store boundary face + cellFaces[fI++] = f.reverseFace(); + + //- create parallel face + face newF(f.size()); + forAll(f, pI) + newF[pI] = newLabelForVertex_[f[pI]]; + cellFaces[fI++] = newF; + + newBoundaryFaces.appendList(newF); + newBoundaryOwners.append(cellsToAdd.size() + nOldCells); + newBoundaryPatches.append(boundaryFacePatches[bfI]); + + //- create quad faces + newF.setSize(4); + forAll(f, pI) + { + newF[0] = f[pI]; + newF[1] = f.nextLabel(pI); + newF[2] = newLabelForVertex_[f.nextLabel(pI)]; + newF[3] = newLabelForVertex_[f[pI]]; + + cellFaces[fI++] = newF; + + //- check if the face is at the boundary //- of the treated partitions - const label edgeI = faceEdges(bfI, pI); + const label edgeI = faceEdges(bfI, pI); if( edgeFaces.sizeOfRow(edgeI) == 2 ) { label neiFace = edgeFaces(edgeI, 0); @@ -134,49 +134,49 @@ void boundaryLayers::createNewFacesAndCells(const boolList& treatPatches) newBoundaryPatches.append(otherProcPatch[edgeI]); } } - } - + } + cellsToAdd.appendGraph(cellFaces); - } - else - { - # ifdef DEBUGLayer - Info << "Storing original boundary face " - << bfI << " into patch " << boundaryFacePatches[bfI] << endl; - # endif + } + else + { + # ifdef DEBUGLayer + Info << "Storing original boundary face " + << bfI << " into patch " << boundaryFacePatches[bfI] << endl; + # endif - newBoundaryFaces.appendList(bFaces[bfI]); - newBoundaryOwners.append(faceOwners[bfI]); - newBoundaryPatches.append(boundaryFacePatches[bfI]); - } + newBoundaryFaces.appendList(bFaces[bfI]); + newBoundaryOwners.append(faceOwners[bfI]); + newBoundaryPatches.append(boundaryFacePatches[bfI]); + } //- create mesh modifier - polyMeshGenModifier meshModifier(mesh_); - + polyMeshGenModifier meshModifier(mesh_); + meshModifier.addCells(cellsToAdd); cellsToAdd.clear(); - meshModifier.reorderBoundaryFaces(); - meshModifier.replaceBoundary - ( - patchNames_, - newBoundaryFaces, - newBoundaryOwners, - newBoundaryPatches - ); + meshModifier.reorderBoundaryFaces(); + meshModifier.replaceBoundary + ( + patchNames_, + newBoundaryFaces, + newBoundaryOwners, + newBoundaryPatches + ); //- delete meshSurfaceEngine this->clearOut(); - # ifdef DEBUGLayer - mesh_.addressingData().checkMesh(true); - # endif - - Info << "Finished creating layer cells" << endl; + # ifdef DEBUGLayer + mesh_.addressingData().checkMesh(true); + # endif + + Info << "Finished creating layer cells" << endl; } void boundaryLayers::createNewFacesParallel ( - const boolList& treatPatches + const boolList& treatPatches ) { const meshSurfaceEngine& mse = surfaceEngine(); @@ -246,14 +246,14 @@ void boundaryLayers::createNewFacesParallel if( !otherProcToProcPatch.found(otherFaceProc[beI]) ) { - otherProcToProcPatch.insert - ( - otherFaceProc[beI], - polyMeshGenModifier(mesh_).addProcessorPatch - ( - otherFaceProc[beI] - ) - ); + otherProcToProcPatch.insert + ( + otherFaceProc[beI], + polyMeshGenModifier(mesh_).addProcessorPatch + ( + otherFaceProc[beI] + ) + ); } } @@ -264,9 +264,9 @@ void boundaryLayers::createNewFacesParallel forAll(treatedEdgeLabels, geI) { const label beI = globalToLocal[treatedEdgeLabels[geI]]; - - if( edgeFaces.sizeOfRow(beI) == 0 ) - continue; + + if( edgeFaces.sizeOfRow(beI) == 0 ) + continue; const label bfI = edgeFaces(beI, 0); const label pos = faceEdges.containsAtPosition(bfI, beI); @@ -276,45 +276,45 @@ void boundaryLayers::createNewFacesParallel { newF[0] = e.start(); newF[1] = e.end(); - if( patchKey_.size() != 0 ) - { - newF[2] = - findNewNodeLabel(e.end(), patchKey_[otherProcPatch[beI]]); - newF[3] = - findNewNodeLabel(e.start(), patchKey_[otherProcPatch[beI]]); - } - else - { - newF[2] = newLabelForVertex_[e.end()]; - newF[3] = newLabelForVertex_[e.start()]; - } + if( patchKey_.size() != 0 ) + { + newF[2] = + findNewNodeLabel(e.end(), patchKey_[otherProcPatch[beI]]); + newF[3] = + findNewNodeLabel(e.start(), patchKey_[otherProcPatch[beI]]); + } + else + { + newF[2] = newLabelForVertex_[e.end()]; + newF[3] = newLabelForVertex_[e.start()]; + } } else { newF[0] = e.end(); - if( patchKey_.size() != 0 ) - { - newF[1] = - findNewNodeLabel + if( patchKey_.size() != 0 ) + { + newF[1] = + findNewNodeLabel ( e.end(), patchKey_[boundaryFacePatches[bfI]] ); - newF[2] = - findNewNodeLabel - ( - e.start(), - patchKey_[boundaryFacePatches[bfI]] - ); - } - else - { - newF[1] = newLabelForVertex_[e.end()]; - newF[2] = newLabelForVertex_[e.start()]; - } + newF[2] = + findNewNodeLabel + ( + e.start(), + patchKey_[boundaryFacePatches[bfI]] + ); + } + else + { + newF[1] = newLabelForVertex_[e.end()]; + newF[2] = newLabelForVertex_[e.start()]; + } newF[3] = e.start(); } - + newProcFaces.appendList(newF); faceProcPatch.append(otherProcToProcPatch[otherFaceProc[beI]]); } diff --git a/meshLibrary/utilities/boundaryLayers/boundaryLayersI.H b/meshLibrary/utilities/boundaryLayers/boundaryLayersI.H index 53942156..c5f53909 100644 --- a/meshLibrary/utilities/boundaryLayers/boundaryLayersI.H +++ b/meshLibrary/utilities/boundaryLayers/boundaryLayersI.H @@ -37,267 +37,267 @@ namespace Foam label boundaryLayers::findNewNodeLabel ( - const label pointI, - const label pKey + const label pointI, + const label pKey ) const { - if( otherVrts_.find(pointI) != otherVrts_.end() ) - { - const std::map - < - label, std::map<std::pair<label, label>, label> - >::const_iterator it = otherVrts_.find(pointI); - const std::map<std::pair<label, label>, label>& m = it->second; + if( otherVrts_.find(pointI) != otherVrts_.end() ) + { + const std::map + < + label, std::map<std::pair<label, label>, label> + >::const_iterator it = otherVrts_.find(pointI); + const std::map<std::pair<label, label>, label>& m = it->second; - std::map<std::pair<label, label>, label>::const_iterator mit; - if( m.size() == 2 ) - { - for(mit=m.begin();mit!=m.end();++mit) - { - if( mit->first.first != pKey ) - return mit->second; - } - } - else - { - for(mit=m.begin();mit!=m.end();++mit) - { - if( mit->first.first == pKey ) - continue; - if( mit->first.second == pKey ) - continue; - if( mit->first.first == mit->first.second ) - continue; - - return mit->second; - } - } - } + std::map<std::pair<label, label>, label>::const_iterator mit; + if( m.size() == 2 ) + { + for(mit=m.begin();mit!=m.end();++mit) + { + if( mit->first.first != pKey ) + return mit->second; + } + } + else + { + for(mit=m.begin();mit!=m.end();++mit) + { + if( mit->first.first == pKey ) + continue; + if( mit->first.second == pKey ) + continue; + if( mit->first.first == mit->first.second ) + continue; + + return mit->second; + } + } + } - return newLabelForVertex_[pointI]; + return newLabelForVertex_[pointI]; } inline void boundaryLayers::createNewCellFromEdge ( - const edge& e, - const label pKeyI, - const label pKeyJ, - DynList<DynList<label, 4>, 6>& cellFaces + const edge& e, + const label pKeyI, + const label pKeyJ, + DynList<DynList<label, 4>, 6>& cellFaces ) const { - const std::map<std::pair<label, label>, label>& ms = - otherVrts_.find(e.start())->second; - const std::map<std::pair<label, label>, label>& me = - otherVrts_.find(e.end())->second; - - # ifdef DEBUGLayer - Info << "Creating cell for edge " << edgeI << " with nodes " << e << endl; - Info << "pKeyI " << pKeyI << endl; - Info << "pKeyJ " << pKeyJ << endl; - std::map<std::pair<label, label>, label>::const_iterator iter; - for(iter=ms.begin();iter!=ms.end();++iter) - Info << "1. Pair (" << iter->first.first << ", " - << iter->first.second << ") has value " << iter->second << endl; - for(iter=me.begin();iter!=me.end();++iter) - Info << "2. Pair (" << iter->first.first << ", " - << iter->first.second << ") has value " << iter->second << endl; - # endif - - label p0s(-1), p1s(-1), ns(-1), p0e(-1), p1e(-1), ne(-1); - - if( ms.size() == 2 ) - { - p0s = ms.find(std::pair<label, label>(pKeyI, pKeyI))->second; - p1s = ms.find(std::pair<label, label>(pKeyJ, pKeyJ))->second; - ns = newLabelForVertex_[e.start()]; - } - else - { - std::map<std::pair<label, label>, label>::const_iterator it; - for(it=ms.begin();it!=ms.end();++it) - { - if( - (it->first.first != pKeyJ) && (it->first.second != pKeyJ) - && (it->first.first != it->first.second) - ) - { - p0s = it->second; - } - else if( - (it->first.first != pKeyI) && (it->first.second != pKeyI) - && (it->first.first != it->first.second) - ) - { - p1s = it->second; - } - else if( - (it->first.first == it->first.second) && - (it->first.first != pKeyI) && (it->first.first != pKeyJ) - ) - { - ns = it->second; - } - } - } - if( me.size() == 2 ) - { - p0e = me.find(std::pair<label, label>(pKeyI, pKeyI))->second; - p1e = me.find(std::pair<label, label>(pKeyJ, pKeyJ))->second; - ne = newLabelForVertex_[e.end()]; - } - else - { - std::map<std::pair<label, label>, label>::const_iterator it; - for(it=me.begin();it!=me.end();++it) - { - if( - (it->first.first != pKeyJ) && (it->first.second != pKeyJ) - && (it->first.first != it->first.second) - ) - { - p0e = it->second; - } - else if( - (it->first.first != pKeyI) && (it->first.second != pKeyI) - && (it->first.first != it->first.second) - ) - { - p1e = it->second; - } - else if( - (it->first.first == it->first.second) && - (it->first.first != pKeyI) && (it->first.first != pKeyJ) - ) - { - ne = it->second; - } - } - } - - cellFaces.setSize(6); - DynList<label, 4> f; + const std::map<std::pair<label, label>, label>& ms = + otherVrts_.find(e.start())->second; + const std::map<std::pair<label, label>, label>& me = + otherVrts_.find(e.end())->second; + + # ifdef DEBUGLayer + Info << "Creating cell for edge " << edgeI << " with nodes " << e << endl; + Info << "pKeyI " << pKeyI << endl; + Info << "pKeyJ " << pKeyJ << endl; + std::map<std::pair<label, label>, label>::const_iterator iter; + for(iter=ms.begin();iter!=ms.end();++iter) + Info << "1. Pair (" << iter->first.first << ", " + << iter->first.second << ") has value " << iter->second << endl; + for(iter=me.begin();iter!=me.end();++iter) + Info << "2. Pair (" << iter->first.first << ", " + << iter->first.second << ") has value " << iter->second << endl; + # endif + + label p0s(-1), p1s(-1), ns(-1), p0e(-1), p1e(-1), ne(-1); + + if( ms.size() == 2 ) + { + p0s = ms.find(std::pair<label, label>(pKeyI, pKeyI))->second; + p1s = ms.find(std::pair<label, label>(pKeyJ, pKeyJ))->second; + ns = newLabelForVertex_[e.start()]; + } + else + { + std::map<std::pair<label, label>, label>::const_iterator it; + for(it=ms.begin();it!=ms.end();++it) + { + if( + (it->first.first != pKeyJ) && (it->first.second != pKeyJ) + && (it->first.first != it->first.second) + ) + { + p0s = it->second; + } + else if( + (it->first.first != pKeyI) && (it->first.second != pKeyI) + && (it->first.first != it->first.second) + ) + { + p1s = it->second; + } + else if( + (it->first.first == it->first.second) && + (it->first.first != pKeyI) && (it->first.first != pKeyJ) + ) + { + ns = it->second; + } + } + } + if( me.size() == 2 ) + { + p0e = me.find(std::pair<label, label>(pKeyI, pKeyI))->second; + p1e = me.find(std::pair<label, label>(pKeyJ, pKeyJ))->second; + ne = newLabelForVertex_[e.end()]; + } + else + { + std::map<std::pair<label, label>, label>::const_iterator it; + for(it=me.begin();it!=me.end();++it) + { + if( + (it->first.first != pKeyJ) && (it->first.second != pKeyJ) + && (it->first.first != it->first.second) + ) + { + p0e = it->second; + } + else if( + (it->first.first != pKeyI) && (it->first.second != pKeyI) + && (it->first.first != it->first.second) + ) + { + p1e = it->second; + } + else if( + (it->first.first == it->first.second) && + (it->first.first != pKeyI) && (it->first.first != pKeyJ) + ) + { + ne = it->second; + } + } + } + + cellFaces.setSize(6); + DynList<label, 4> f; f.setSize(4); - //- F0 - f[0] = e.end(); - f[1] = e.start(); - f[2] = p1s; - f[3] = p1e; - cellFaces[0] = f; - //- F1 - f[0] = p0e; - f[1] = ne; - f[2] = ns; - f[3] = p0s; - cellFaces[1] = f; - //- F2 - f[0] = e.start(); - f[1] = e.end(); - f[2] = p0e; - f[3] = p0s; - cellFaces[2] = f; - //- F3 - f[0] = p1s; - f[1] = ns; - f[2] = ne; - f[3] = p1e; - cellFaces[3] = f; - //- F4 - f[0] = e.end(); - f[1] = p1e; - f[2] = ne; - f[3] = p0e; - cellFaces[4] = f; - //- F5 - f[0] = e.start(); - f[1] = p0s; - f[2] = ns; - f[3] = p1s; - cellFaces[5] = f; + //- F0 + f[0] = e.end(); + f[1] = e.start(); + f[2] = p1s; + f[3] = p1e; + cellFaces[0] = f; + //- F1 + f[0] = p0e; + f[1] = ne; + f[2] = ns; + f[3] = p0s; + cellFaces[1] = f; + //- F2 + f[0] = e.start(); + f[1] = e.end(); + f[2] = p0e; + f[3] = p0s; + cellFaces[2] = f; + //- F3 + f[0] = p1s; + f[1] = ns; + f[2] = ne; + f[3] = p1e; + cellFaces[3] = f; + //- F4 + f[0] = e.end(); + f[1] = p1e; + f[2] = ne; + f[3] = p0e; + cellFaces[4] = f; + //- F5 + f[0] = e.start(); + f[1] = p0s; + f[2] = ns; + f[3] = p1s; + cellFaces[5] = f; } inline void boundaryLayers::createNewCellFromNode ( - const label pointI, - const DynList<label, 3>& pKeys, - DynList<DynList<label, 4>, 6>& cellFaces + const label pointI, + const DynList<label, 3>& pKeys, + DynList<DynList<label, 4>, 6>& cellFaces ) const { - const std::map<std::pair<label, label>, label>& m = - otherVrts_.find(pointI)->second; - - //- create labels before creating cells - const label n = newLabelForVertex_[pointI]; - const label p00 = - m.find(std::pair<label, label>(pKeys[0], pKeys[0]))->second; - const label p11 = - m.find(std::pair<label, label>(pKeys[1], pKeys[1]))->second; - const label p22 = - m.find(std::pair<label, label>(pKeys[2], pKeys[2]))->second; + const std::map<std::pair<label, label>, label>& m = + otherVrts_.find(pointI)->second; + + //- create labels before creating cells + const label n = newLabelForVertex_[pointI]; + const label p00 = + m.find(std::pair<label, label>(pKeys[0], pKeys[0]))->second; + const label p11 = + m.find(std::pair<label, label>(pKeys[1], pKeys[1]))->second; + const label p22 = + m.find(std::pair<label, label>(pKeys[2], pKeys[2]))->second; - std::pair<label, label> pr; - pr.first = pKeys[0]; - pr.second = pKeys[1]; - if( m.find(pr) == m.end() ) - { - pr.first = pKeys[1]; - pr.second = pKeys[0]; - } - const label p01 = m.find(pr)->second; - - pr.first = pKeys[0]; - pr.second = pKeys[2]; - if( m.find(pr) == m.end() ) - { - pr.first = pKeys[2]; - pr.second = pKeys[0]; - } - const label p02 = m.find(pr)->second; - - pr.first = pKeys[1]; - pr.second = pKeys[2]; - if( m.find(pr) == m.end() ) - { - pr.first = pKeys[2]; - pr.second = pKeys[1]; - } - const label p12 = m.find(pr)->second; - - //- create the cell and append it - cellFaces.setSize(6); - forAll(cellFaces, fI) + std::pair<label, label> pr; + pr.first = pKeys[0]; + pr.second = pKeys[1]; + if( m.find(pr) == m.end() ) + { + pr.first = pKeys[1]; + pr.second = pKeys[0]; + } + const label p01 = m.find(pr)->second; + + pr.first = pKeys[0]; + pr.second = pKeys[2]; + if( m.find(pr) == m.end() ) + { + pr.first = pKeys[2]; + pr.second = pKeys[0]; + } + const label p02 = m.find(pr)->second; + + pr.first = pKeys[1]; + pr.second = pKeys[2]; + if( m.find(pr) == m.end() ) + { + pr.first = pKeys[2]; + pr.second = pKeys[1]; + } + const label p12 = m.find(pr)->second; + + //- create the cell and append it + cellFaces.setSize(6); + forAll(cellFaces, fI) cellFaces[fI].setSize(4); - //- F0 - cellFaces[0][0] = pointI; - cellFaces[0][1] = p02; - cellFaces[0][2] = p00; - cellFaces[0][3] = p01; - //- F1 - cellFaces[1][0] = p12; - cellFaces[1][1] = p11; - cellFaces[1][2] = n; - cellFaces[1][3] = p22; + //- F0 + cellFaces[0][0] = pointI; + cellFaces[0][1] = p02; + cellFaces[0][2] = p00; + cellFaces[0][3] = p01; + //- F1 + cellFaces[1][0] = p12; + cellFaces[1][1] = p11; + cellFaces[1][2] = n; + cellFaces[1][3] = p22; - //- F2 - cellFaces[2][0] = pointI; - cellFaces[2][1] = p01; - cellFaces[2][2] = p11; - cellFaces[2][3] = p12; - //- F3 - cellFaces[3][0] = p02; - cellFaces[3][1] = p22; - cellFaces[3][2] = n; - cellFaces[3][3] = p00; - //- F4 - cellFaces[4][0] = pointI; - cellFaces[4][1] = p12; - cellFaces[4][2] = p22; - cellFaces[4][3] = p02; - //- F5 - cellFaces[5][0] = p01; - cellFaces[5][1] = p00; - cellFaces[5][2] = n; - cellFaces[5][3] = p11; + //- F2 + cellFaces[2][0] = pointI; + cellFaces[2][1] = p01; + cellFaces[2][2] = p11; + cellFaces[2][3] = p12; + //- F3 + cellFaces[3][0] = p02; + cellFaces[3][1] = p22; + cellFaces[3][2] = n; + cellFaces[3][3] = p00; + //- F4 + cellFaces[4][0] = pointI; + cellFaces[4][1] = p12; + cellFaces[4][2] = p22; + cellFaces[4][3] = p02; + //- F5 + cellFaces[5][0] = p01; + cellFaces[5][1] = p00; + cellFaces[5][2] = n; + cellFaces[5][3] = p11; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/meshLibrary/utilities/boundaryLayers/boundaryLayersWrapperLayer.C b/meshLibrary/utilities/boundaryLayers/boundaryLayersWrapperLayer.C index 61c381e1..c8d7bef7 100644 --- a/meshLibrary/utilities/boundaryLayers/boundaryLayersWrapperLayer.C +++ b/meshLibrary/utilities/boundaryLayers/boundaryLayersWrapperLayer.C @@ -34,36 +34,36 @@ Description namespace Foam { - + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // void boundaryLayers::addWrapperLayer() { - createOTopologyLayers(); - - if( treatedPatch_[0] ) return; + createOTopologyLayers(); + + if( treatedPatch_[0] ) return; - const meshSurfaceEngine& mse = surfaceEngine(); - - const labelList& bPoints = mse.boundaryPoints(); - - boolList treatPatches(mesh_.boundaries().size(), true); - - labelListPMG newLabelForVertex(nPoints_, -1); + const meshSurfaceEngine& mse = surfaceEngine(); + + const labelList& bPoints = mse.boundaryPoints(); + + boolList treatPatches(mesh_.boundaries().size(), true); + + labelListPMG newLabelForVertex(nPoints_, -1); - pointFieldPMG& points = mesh_.points(); - points.setSize(points.size() + bPoints.size()); - forAll(bPoints, bpI) - { - points[nPoints_] = points[bPoints[bpI]]; - newLabelForVertex[bPoints[bpI]] = nPoints_++; - } - - createNewFacesAndCells(treatPatches); - - forAll(treatPatches, patchI) - if( treatPatches[patchI] ) - treatedPatch_[patchI] = true; + pointFieldPMG& points = mesh_.points(); + points.setSize(points.size() + bPoints.size()); + forAll(bPoints, bpI) + { + points[nPoints_] = points[bPoints[bpI]]; + newLabelForVertex[bPoints[bpI]] = nPoints_++; + } + + createNewFacesAndCells(treatPatches); + + forAll(treatPatches, patchI) + if( treatPatches[patchI] ) + treatedPatch_[patchI] = true; //- delete surface engine clearOut(); diff --git a/meshLibrary/utilities/boundaryLayers/extrudeLayer.H b/meshLibrary/utilities/boundaryLayers/extrudeLayer.H index e048610b..8404a96e 100644 --- a/meshLibrary/utilities/boundaryLayers/extrudeLayer.H +++ b/meshLibrary/utilities/boundaryLayers/extrudeLayer.H @@ -78,8 +78,8 @@ class extrudeLayer //- original point label labelListPMG origPointLabel_; - - // Private member functions + + // Private member functions //- duplicate faces which will be extruded void createDuplicateFrontFaces(const LongList<labelPair>&); @@ -184,11 +184,11 @@ class extrudeLayer //- Disallow bitwise assignment void operator=(const extrudeLayer&); - + public: - + // Constructors - + //- Construct from mesh, extrusion faces, thickness and number of layers extrudeLayer ( @@ -196,11 +196,11 @@ class extrudeLayer const LongList<labelPair>& extrusionFront, const scalar thickness = -1.0 ); - - // Destructor + + // Destructor ~extrudeLayer(); - - // Public member functions + + // Public member functions }; // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/meshLibrary/utilities/checkMeshDict/checkMeshDict.C b/meshLibrary/utilities/checkMeshDict/checkMeshDict.C index d9948590..30258b80 100644 --- a/meshLibrary/utilities/checkMeshDict/checkMeshDict.C +++ b/meshLibrary/utilities/checkMeshDict/checkMeshDict.C @@ -35,7 +35,7 @@ Description namespace Foam { - + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // void checkMeshDict::checkPatchCellSize() diff --git a/meshLibrary/utilities/checkMeshDict/checkMeshDict.H b/meshLibrary/utilities/checkMeshDict/checkMeshDict.H index da6a2295..2d868086 100644 --- a/meshLibrary/utilities/checkMeshDict/checkMeshDict.H +++ b/meshLibrary/utilities/checkMeshDict/checkMeshDict.H @@ -49,10 +49,10 @@ namespace Foam class checkMeshDict { - //- Reference to the mesh + //- Reference to the mesh const IOdictionary& meshDict_; - - // Private member functions + + // Private member functions //- check patchCellSize entry void checkPatchCellSize(); @@ -73,18 +73,18 @@ class checkMeshDict //- perform all checks void checkEntries(); - - public: - - // Constructors - - //- Construct from IOdictionary - checkMeshDict(const IOdictionary& meshDict); - - // Destructor - ~checkMeshDict(); - - // Public member functions + + public: + + // Constructors + + //- Construct from IOdictionary + checkMeshDict(const IOdictionary& meshDict); + + // Destructor + ~checkMeshDict(); + + // Public member functions }; diff --git a/meshLibrary/utilities/containers/DynList/DynList.H b/meshLibrary/utilities/containers/DynList/DynList.H index 4adf574d..9e673e4c 100644 --- a/meshLibrary/utilities/containers/DynList/DynList.H +++ b/meshLibrary/utilities/containers/DynList/DynList.H @@ -145,21 +145,21 @@ public: //- Append an element at the end of the list inline void append(const T& e); - - //- Append an element at the end of the list if it is not yet - //- present in the list (takes linear time) - inline void appendIfNotIn(const T& e); - - //- check if the element is in the list (takes linear time) - inline bool contains(const T& e) const; - inline label containsAtPosition(const T& e) const; + + //- Append an element at the end of the list if it is not yet + //- present in the list (takes linear time) + inline void appendIfNotIn(const T& e); + + //- check if the element is in the list (takes linear time) + inline bool contains(const T& e) const; + inline label containsAtPosition(const T& e) const; //- Return and remove the top element inline T removeLastElement(); - inline T removeElement(const label i); - - //- return a refence to the element. Resize the list if necessary - inline T& newElmt(const label); + inline T removeElement(const label i); + + //- return a refence to the element. Resize the list if necessary + inline T& newElmt(const label); //- Return non-const access to an element, //- resizing the list if necessary diff --git a/meshLibrary/utilities/containers/DynList/DynListI.H b/meshLibrary/utilities/containers/DynList/DynListI.H index 79f70250..0799f0fd 100644 --- a/meshLibrary/utilities/containers/DynList/DynListI.H +++ b/meshLibrary/utilities/containers/DynList/DynListI.H @@ -40,7 +40,7 @@ inline void Foam::DynList<T, staticSize>::allocateSize(const label s) delete [] data; UList<T>::reset(newData, s); - //this->UList<T>::operator=(UList<T>(newData, s)); + //this->UList<T>::operator=(UList<T>(newData, s)); } else if( (s > staticSize) && (s < UList<T>::size()) ) { @@ -53,7 +53,7 @@ inline void Foam::DynList<T, staticSize>::allocateSize(const label s) delete [] data; UList<T>::reset(newData, s); - //this->UList<T>::operator=(UList<T>(newData, s)); + //this->UList<T>::operator=(UList<T>(newData, s)); } else if( (s <= staticSize) && (UList<T>::size() > staticSize) ) { @@ -65,7 +65,7 @@ inline void Foam::DynList<T, staticSize>::allocateSize(const label s) delete [] data; UList<T>::reset(staticData_, staticSize); - //this->UList<T>::operator=(UList<T>(staticData_, staticSize)); + //this->UList<T>::operator=(UList<T>(staticData_, staticSize)); } } @@ -75,11 +75,11 @@ inline void Foam::DynList<T, staticSize>::checkIndex(const label i) const if( (i < 0) || (i >= nextFree_) ) { FatalErrorIn - ( - "void Foam::DynList<T, label, Offset>::" - "checkIndex(const label i) const" - ) << "Index " << i << " is not in range " << 0 - << " and " << nextFree_ << abort(FatalError); + ( + "void Foam::DynList<T, label, Offset>::" + "checkIndex(const label i) const" + ) << "Index " << i << " is not in range " << 0 + << " and " << nextFree_ << abort(FatalError); } } @@ -200,32 +200,32 @@ inline void Foam::DynList<T, staticSize>::append(const T& e) template<class T, Foam::label staticSize> inline void Foam::DynList<T, staticSize>::appendIfNotIn(const T& e) { - if( !contains(e) ) - append(e); + if( !contains(e) ) + append(e); } template<class T, Foam::label staticSize> inline bool Foam::DynList<T, staticSize>::contains(const T& e) const { - for(label i=0;i<nextFree_;++i) + for(label i=0;i<nextFree_;++i) { - if( UList<T>::operator[](i) == e ) - return true; + if( UList<T>::operator[](i) == e ) + return true; } - - return false; + + return false; } template<class T, Foam::label staticSize> inline Foam::label Foam::DynList<T, staticSize>::containsAtPosition(const T& e) const { - for(label i=0;i<nextFree_;++i) + for(label i=0;i<nextFree_;++i) { - if( UList<T>::operator[](i) == e ) - return i; + if( UList<T>::operator[](i) == e ) + return i; } - - return -1; + + return -1; } template<class T, Foam::label staticSize> @@ -246,16 +246,16 @@ inline T Foam::DynList<T, staticSize>::removeLastElement() template<class T, Foam::label staticSize> inline T Foam::DynList<T, staticSize>::removeElement(const label i) { - if( nextFree_ == 0 ) + if( nextFree_ == 0 ) { FatalErrorIn ( "void Foam::DynList<T, staticSize>::remove()" ) << "List is empty" << abort(FatalError); } - + T el = this->operator[](i); - this->operator[](i) = this->operator[](nextFree_-1); + this->operator[](i) = this->operator[](nextFree_-1); --nextFree_; return el; @@ -264,7 +264,7 @@ inline T Foam::DynList<T, staticSize>::removeElement(const label i) template<class T, Foam::label staticSize> inline T& Foam::DynList<T, staticSize>::newElmt(const label i) { - return this->operator()(i); + return this->operator()(i); } // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // diff --git a/meshLibrary/utilities/containers/FRWGraph/FRWGraph.C b/meshLibrary/utilities/containers/FRWGraph/FRWGraph.C index 55e6496a..885dd04f 100644 --- a/meshLibrary/utilities/containers/FRWGraph/FRWGraph.C +++ b/meshLibrary/utilities/containers/FRWGraph/FRWGraph.C @@ -35,15 +35,15 @@ Foam::Ostream& Foam::operator<< const Foam::FRWGraph<T, width>& DL ) { - os << DL.size() << "(" << endl; - for(register label i=0;i<DL.size();++i) - { - os << width << "("; - for(label j=0;j<width;++j) - os << DL(i, j) << " " << endl; - os << ")" << endl; - } - os << ")"; + os << DL.size() << "(" << endl; + for(register label i=0;i<DL.size();++i) + { + os << width << "("; + for(label j=0;j<width;++j) + os << DL(i, j) << " " << endl; + os << ")" << endl; + } + os << ")"; return os; } @@ -55,15 +55,15 @@ Foam::Istream& Foam::operator>> Foam::FRWGraph<T, width>& DL ) { - label size; - T e; - is >> size; - DL.setSize(size); - for(IndexType i=0;i<size;++i) - { - is >> e; - DL[i] = e; - } + label size; + T e; + is >> size; + DL.setSize(size); + for(IndexType i=0;i<size;++i) + { + is >> e; + DL[i] = e; + } return is; } diff --git a/meshLibrary/utilities/containers/FRWGraph/FRWGraph.H b/meshLibrary/utilities/containers/FRWGraph/FRWGraph.H index 5c95f0d8..c28b5fda 100644 --- a/meshLibrary/utilities/containers/FRWGraph/FRWGraph.H +++ b/meshLibrary/utilities/containers/FRWGraph/FRWGraph.H @@ -27,7 +27,7 @@ Class Description This class is an implementation of a graph with the fixed row width. - The implementation is memory efficient. + The implementation is memory efficient. SourceFiles FRWGraphI.H diff --git a/meshLibrary/utilities/containers/FRWGraph/FRWGraphI.H b/meshLibrary/utilities/containers/FRWGraph/FRWGraphI.H index 6998098c..e62011a3 100644 --- a/meshLibrary/utilities/containers/FRWGraph/FRWGraphI.H +++ b/meshLibrary/utilities/containers/FRWGraph/FRWGraphI.H @@ -27,25 +27,25 @@ License template<class T, Foam::label width> void Foam::FRWGraph<T, width>::checkIndex(const label i, const label j) const { - if( (i < 0) || (i >= nRows_) ) - { - FatalErrorIn - ( - "void Foam::FRWGraph<T,width>::" - "checkIndex(const label i, const label j) const" - ) << "Row index " << Foam::label(i) - << " is not in range " << Foam::label(0) - << " and " << nRows_ << abort(FatalError); - } - - if( (j < 0) || (j >= width) ) - FatalErrorIn - ( - "void Foam::FRWGraph<T,width>::" - "checkIndex(label const i) const" - ) << "Column index " << Foam::label(j) - << " is not in range " << Foam::label(0) - << " and " << width << abort(FatalError); + if( (i < 0) || (i >= nRows_) ) + { + FatalErrorIn + ( + "void Foam::FRWGraph<T,width>::" + "checkIndex(const label i, const label j) const" + ) << "Row index " << Foam::label(i) + << " is not in range " << Foam::label(0) + << " and " << nRows_ << abort(FatalError); + } + + if( (j < 0) || (j >= width) ) + FatalErrorIn + ( + "void Foam::FRWGraph<T,width>::" + "checkIndex(label const i) const" + ) << "Column index " << Foam::label(j) + << " is not in range " << Foam::label(0) + << " and " << width << abort(FatalError); } // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // @@ -54,8 +54,8 @@ void Foam::FRWGraph<T, width>::checkIndex(const label i, const label j) const template<class T, Foam::label width> inline Foam::FRWGraph<T,width>::FRWGraph() : - data_(), - nRows_(0) + data_(), + nRows_(0) { } @@ -66,8 +66,8 @@ inline Foam::FRWGraph<T,width>::FRWGraph const label s ) : - data_(s * width), - nRows_(s) + data_(s * width), + nRows_(s) { } @@ -77,22 +77,22 @@ template<class T, Foam::label width> inline Foam::FRWGraph<T,width>::FRWGraph ( const label s, - const T& t + const T& t ) : - data_(s * width, t), - nRows_(s) + data_(s * width, t), + nRows_(s) { } template<class T, Foam::label width> inline Foam::FRWGraph<T,width>::FRWGraph ( - const FRWGraph<T,width>& ol + const FRWGraph<T,width>& ol ) : - data_(ol.data_), - nRows_(ol.nRows_) + data_(ol.data_), + nRows_(ol.nRows_) { } @@ -113,111 +113,111 @@ inline Foam::label Foam::FRWGraph<T,width>::size() const template<class T, Foam::label width> inline Foam::label Foam::FRWGraph<T,width>::sizeOfRow(const label rowI) const { - return width; + return width; } template<class T, Foam::label width> inline void Foam::FRWGraph<T,width>::setSize(const label i) { - data_.setSize(i * width); - nRows_ = i; + data_.setSize(i * width); + nRows_ = i; } template<class T, Foam::label width> inline void Foam::FRWGraph<T,width>::clear() { data_.clear(); - nRows_ = 0; + nRows_ = 0; } template<class T, Foam::label width> inline void Foam::FRWGraph<T,width>::appendFixedList ( - const FixedList<T, width>& l + const FixedList<T, width>& l ) { - forAll(l, elI) - data_.append(l[elI]); - ++nRows_; + forAll(l, elI) + data_.append(l[elI]); + ++nRows_; } template<class T, Foam::label width> inline void Foam::FRWGraph<T,width>::setRow ( - const label rowI, - const FixedList<T, width>& l + const label rowI, + const FixedList<T, width>& l ) { - const label start = rowI * width; - forAll(l, elI) - data_[start+elI] = l[elI]; + const label start = rowI * width; + forAll(l, elI) + data_[start+elI] = l[elI]; } template<class T, Foam::label width> inline bool Foam::FRWGraph<T,width>::contains ( - const label rowI, + const label rowI, const T& e ) const { - const label start = rowI * width; - for(register label i=0;i<width;++i) - if( data_[start+i] == e ) - return true; - - return false; + const label start = rowI * width; + for(register label i=0;i<width;++i) + if( data_[start+i] == e ) + return true; + + return false; } template<class T, Foam::label width> inline Foam::label Foam::FRWGraph<T,width>::containsAtPosition ( - const label rowI, + const label rowI, const T& e ) const { - const label start = rowI * width; - for(register label i=0;i<width;++i) - if( data_[start+i] == e ) - return i; - - return -1; + const label start = rowI * width; + for(register label i=0;i<width;++i) + if( data_[start+i] == e ) + return i; + + return -1; } // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // template<class T, Foam::label width> inline const T& Foam::FRWGraph<T,width>::operator() ( - const label i, - const label j + const label i, + const label j ) const { - #ifdef FULLDEBUG - checkIndex(i, j); - #endif - - return data_[i * width + j]; + #ifdef FULLDEBUG + checkIndex(i, j); + #endif + + return data_[i * width + j]; } template<class T, Foam::label width> inline T& Foam::FRWGraph<T,width>::operator() ( - const label i, const label j + const label i, const label j ) { - #ifdef FULLDEBUG - checkIndex(i, j); - #endif - - return data_[i * width + j]; + #ifdef FULLDEBUG + checkIndex(i, j); + #endif + + return data_[i * width + j]; } template<class T, Foam::label width> inline void Foam::FRWGraph<T,width>::operator= ( - const FRWGraph<T, width>& l + const FRWGraph<T, width>& l ) { - data_ = l.data_; + data_ = l.data_; } diff --git a/meshLibrary/utilities/containers/Graphs/cellIOGraph.C b/meshLibrary/utilities/containers/Graphs/cellIOGraph.C index 80e752c2..fa717f9f 100644 --- a/meshLibrary/utilities/containers/Graphs/cellIOGraph.C +++ b/meshLibrary/utilities/containers/Graphs/cellIOGraph.C @@ -39,14 +39,14 @@ namespace Foam cellIOGraph::cellIOGraph(const IOobject& io) : regIOobject(io), - VRWGraph() + VRWGraph() { } cellIOGraph::cellIOGraph ( - const IOobject& io, - const label size + const IOobject& io, + const label size ) : regIOobject(io), @@ -55,8 +55,8 @@ cellIOGraph::cellIOGraph cellIOGraph::cellIOGraph ( - const IOobject& io, - const VRWGraph& g + const IOobject& io, + const VRWGraph& g ) : regIOobject(io), @@ -66,7 +66,7 @@ cellIOGraph::cellIOGraph void cellIOGraph::operator=(const cellIOGraph& rhs) { - VRWGraph::operator=(rhs); + VRWGraph::operator=(rhs); } void cellIOGraph::operator=(const VRWGraph& rhs) diff --git a/meshLibrary/utilities/containers/Graphs/cellIOGraph.H b/meshLibrary/utilities/containers/Graphs/cellIOGraph.H index d708de38..956f83c5 100644 --- a/meshLibrary/utilities/containers/Graphs/cellIOGraph.H +++ b/meshLibrary/utilities/containers/Graphs/cellIOGraph.H @@ -57,7 +57,7 @@ class cellIOGraph public: //- Runtime type information - TypeName("cellIOGraph"); + TypeName("cellIOGraph"); // Constructors @@ -78,7 +78,7 @@ public: // Member operators - void operator=(const cellIOGraph&); + void operator=(const cellIOGraph&); void operator=(const VRWGraph&); }; diff --git a/meshLibrary/utilities/containers/Graphs/faceIOGraph.C b/meshLibrary/utilities/containers/Graphs/faceIOGraph.C index 96ac4340..dff99ce1 100644 --- a/meshLibrary/utilities/containers/Graphs/faceIOGraph.C +++ b/meshLibrary/utilities/containers/Graphs/faceIOGraph.C @@ -39,14 +39,14 @@ namespace Foam faceIOGraph::faceIOGraph(const IOobject& io) : regIOobject(io), - VRWGraph() + VRWGraph() { } faceIOGraph::faceIOGraph ( - const IOobject& io, - const label size + const IOobject& io, + const label size ) : regIOobject(io), @@ -55,8 +55,8 @@ faceIOGraph::faceIOGraph faceIOGraph::faceIOGraph ( - const IOobject& io, - const VRWGraph& g + const IOobject& io, + const VRWGraph& g ) : regIOobject(io), @@ -66,7 +66,7 @@ faceIOGraph::faceIOGraph void faceIOGraph::operator=(const faceIOGraph& rhs) { - VRWGraph::operator=(rhs); + VRWGraph::operator=(rhs); } void faceIOGraph::operator=(const VRWGraph& rhs) diff --git a/meshLibrary/utilities/containers/Graphs/faceIOGraph.H b/meshLibrary/utilities/containers/Graphs/faceIOGraph.H index 1dbbf0ed..4aad77a5 100644 --- a/meshLibrary/utilities/containers/Graphs/faceIOGraph.H +++ b/meshLibrary/utilities/containers/Graphs/faceIOGraph.H @@ -57,7 +57,7 @@ class faceIOGraph public: //- Runtime type information - TypeName("faceIOGraph"); + TypeName("faceIOGraph"); // Constructors @@ -78,7 +78,7 @@ public: // Member operators - void operator=(const faceIOGraph&); + void operator=(const faceIOGraph&); void operator=(const VRWGraph&); }; diff --git a/meshLibrary/utilities/containers/IODynList/IODynList.C b/meshLibrary/utilities/containers/IODynList/IODynList.C index e2e12920..e9aaf451 100644 --- a/meshLibrary/utilities/containers/IODynList/IODynList.C +++ b/meshLibrary/utilities/containers/IODynList/IODynList.C @@ -41,7 +41,7 @@ template<class T, class IndexType> IODynList<T, IndexType>::IODynList(const IOobject& io) : regIOobject(io), - DynList<T, IndexType>() + DynList<T, IndexType>() { if ( @@ -58,8 +58,8 @@ IODynList<T, IndexType>::IODynList(const IOobject& io) template<class T, class IndexType> IODynList<T, IndexType>::IODynList ( - const IOobject& io, - const IndexType size + const IOobject& io, + const IndexType size ) : regIOobject(io), @@ -70,8 +70,8 @@ IODynList<T, IndexType>::IODynList template<class T, class IndexType> IODynList<T, IndexType>::IODynList ( - const IOobject& io, - const DynList<T, IndexType>& list + const IOobject& io, + const DynList<T, IndexType>& list ) : regIOobject(io), @@ -82,15 +82,15 @@ IODynList<T, IndexType>::IODynList readStream(typeName) >> *this; close(); } - - DynList<T, IndexType>::operator=(list); + + DynList<T, IndexType>::operator=(list); } template<class T, class IndexType> void IODynList<T, IndexType>::operator= ( - const IODynList<T, IndexType>& rhs + const IODynList<T, IndexType>& rhs ) { DynList<T, IndexType>::operator=(rhs); @@ -100,7 +100,7 @@ void IODynList<T, IndexType>::operator= template<class T, class IndexType> void IODynList<T, IndexType>::operator= ( - const DynList<T, IndexType>& rhs + const DynList<T, IndexType>& rhs ) { DynList<T, IndexType>::operator=(rhs); diff --git a/meshLibrary/utilities/containers/IOLongList/IOLongList.C b/meshLibrary/utilities/containers/IOLongList/IOLongList.C index bd278523..53192b08 100644 --- a/meshLibrary/utilities/containers/IOLongList/IOLongList.C +++ b/meshLibrary/utilities/containers/IOLongList/IOLongList.C @@ -41,7 +41,7 @@ template<class T, label Offset> IOLongList<T, Offset>::IOLongList(const IOobject& io) : regIOobject(io), - LongList<T, Offset>() + LongList<T, Offset>() { if ( @@ -58,8 +58,8 @@ IOLongList<T, Offset>::IOLongList(const IOobject& io) template<class T, label Offset> IOLongList<T, Offset>::IOLongList ( - const IOobject& io, - const label size + const IOobject& io, + const label size ) : regIOobject(io), @@ -70,8 +70,8 @@ IOLongList<T, Offset>::IOLongList template<class T, label Offset> IOLongList<T, Offset>::IOLongList ( - const IOobject& io, - const LongList<T, Offset>& list + const IOobject& io, + const LongList<T, Offset>& list ) : regIOobject(io), @@ -82,15 +82,15 @@ IOLongList<T, Offset>::IOLongList readStream(typeName) >> *this; close(); } - - LongList<T, Offset>::operator=(list); + + LongList<T, Offset>::operator=(list); } template<class T, label Offset> void IOLongList<T, Offset>::operator= ( - const IOLongList<T, Offset>& rhs + const IOLongList<T, Offset>& rhs ) { LongList<T, Offset>::operator=(rhs); @@ -100,7 +100,7 @@ void IOLongList<T, Offset>::operator= template<class T, label Offset> void IOLongList<T, Offset>::operator= ( - const LongList<T, Offset>& rhs + const LongList<T, Offset>& rhs ) { LongList<T, Offset>::operator=(rhs); diff --git a/meshLibrary/utilities/containers/IOLongList/IOLongListInstances.C b/meshLibrary/utilities/containers/IOLongList/IOLongListInstances.C index c99007ef..e5444a5e 100644 --- a/meshLibrary/utilities/containers/IOLongList/IOLongListInstances.C +++ b/meshLibrary/utilities/containers/IOLongList/IOLongListInstances.C @@ -35,15 +35,15 @@ Description namespace Foam { defineCompoundTypeName(IOLongList<label>, labelIOListPMG); - defineCompoundTypeName(IOLongList<point>, pointIOFieldPMG); - //defineCompoundTypeName(IOLongList<face>, faceIOListPMG); - //defineCompoundTypeName(IOLongList<cell>, cellIOListPMG); + defineCompoundTypeName(IOLongList<point>, pointIOFieldPMG); + //defineCompoundTypeName(IOLongList<face>, faceIOListPMG); + //defineCompoundTypeName(IOLongList<cell>, cellIOListPMG); //addCompoundToRunTimeSelectionTable(IOLongList<label>, labelIOLongList); defineTemplateTypeNameAndDebugWithName(labelIOListPMG, "labelList", 0); - defineTemplateTypeNameAndDebugWithName(pointIOFieldPMG, "vectorField", 0); - //defineTemplateTypeNameAndDebugWithName(faceIOListPMG, "faceList", 0); - //defineTemplateTypeNameAndDebugWithName(cellIOListPMG, "cellList", 0); + defineTemplateTypeNameAndDebugWithName(pointIOFieldPMG, "vectorField", 0); + //defineTemplateTypeNameAndDebugWithName(faceIOListPMG, "faceList", 0); + //defineTemplateTypeNameAndDebugWithName(cellIOListPMG, "cellList", 0); } // ************************************************************************* // diff --git a/meshLibrary/utilities/containers/IOLongList/IOLongListInstances.H b/meshLibrary/utilities/containers/IOLongList/IOLongListInstances.H index bc7f2695..68a4cd35 100644 --- a/meshLibrary/utilities/containers/IOLongList/IOLongListInstances.H +++ b/meshLibrary/utilities/containers/IOLongList/IOLongListInstances.H @@ -44,8 +44,8 @@ namespace Foam { typedef IOLongList<point> pointIOFieldPMG; typedef IOLongList<face> faceIOListPMG; - typedef IOLongList<cell> cellIOListPMG; - typedef IOLongList<label> labelIOListPMG; + typedef IOLongList<cell> cellIOListPMG; + typedef IOLongList<label> labelIOListPMG; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/meshLibrary/utilities/containers/Lists/cellListPMG.H b/meshLibrary/utilities/containers/Lists/cellListPMG.H index d7e62ef3..9263ea26 100644 --- a/meshLibrary/utilities/containers/Lists/cellListPMG.H +++ b/meshLibrary/utilities/containers/Lists/cellListPMG.H @@ -27,7 +27,7 @@ Class Description This is a container with additional size to prevent re-allocation - every time it is resized + every time it is resized SourceFiles @@ -49,51 +49,51 @@ namespace Foam // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // class cellListPMG - : public cellList + : public cellList { - // Private data - //- number of used elements - label nElmts_; - - // Disallow bitwise assignment - void operator=(const cellListPMG&); - - cellListPMG(const cellListPMG&); - - // Disallow transfer from cellList - void transfer(cellList&); - + // Private data + //- number of used elements + label nElmts_; + + // Disallow bitwise assignment + void operator=(const cellListPMG&); + + cellListPMG(const cellListPMG&); + + // Disallow transfer from cellList + void transfer(cellList&); + public: - - // Constructors - //- null construct - inline cellListPMG(); - - // Destructor - inline ~cellListPMG(); - - // Member functions - //- return the number of used elements - inline label size() const; - - //- set the number of used elements - inline void setSize(const label nElmts); - - //- set the size to zero - inline void clear(); - - //- add a cell at the end of the list - inline void append(const cell&); - - //- return an element with bound checking - inline cell& newElmt(const label); - - // Member operators - inline void operator=(const cellList&); - - friend inline Ostream& operator<<(Ostream&, const cellListPMG&); - - friend inline Istream& operator>>(Istream&, cellListPMG&); + + // Constructors + //- null construct + inline cellListPMG(); + + // Destructor + inline ~cellListPMG(); + + // Member functions + //- return the number of used elements + inline label size() const; + + //- set the number of used elements + inline void setSize(const label nElmts); + + //- set the size to zero + inline void clear(); + + //- add a cell at the end of the list + inline void append(const cell&); + + //- return an element with bound checking + inline cell& newElmt(const label); + + // Member operators + inline void operator=(const cellList&); + + friend inline Ostream& operator<<(Ostream&, const cellListPMG&); + + friend inline Istream& operator>>(Istream&, cellListPMG&); }; // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/meshLibrary/utilities/containers/Lists/cellListPMGI.H b/meshLibrary/utilities/containers/Lists/cellListPMGI.H index 31e71675..f014116e 100644 --- a/meshLibrary/utilities/containers/Lists/cellListPMGI.H +++ b/meshLibrary/utilities/containers/Lists/cellListPMGI.H @@ -40,8 +40,8 @@ namespace Foam inline cellListPMG::cellListPMG() : - cellList(), - nElmts_(0) + cellList(), + nElmts_(0) { } @@ -53,76 +53,76 @@ inline cellListPMG::~cellListPMG() } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - + inline label cellListPMG::size() const { - return nElmts_; + return nElmts_; } inline void cellListPMG::setSize(const label nElmts) { - if( nElmts >= cellList::size() ) - { - if( cellList::size() != 0 ) - { - Info << "Resizing cells!" << endl; - cellList copy(label(1.5*nElmts)); - for(label i=0;i<nElmts_;++i) - copy[i].transfer(this->operator[](i)); - - cellList::transfer(copy); - } - else - { - cellList::setSize(label(1.5*nElmts)); - } - } - - nElmts_ = nElmts; + if( nElmts >= cellList::size() ) + { + if( cellList::size() != 0 ) + { + Info << "Resizing cells!" << endl; + cellList copy(label(1.5*nElmts)); + for(label i=0;i<nElmts_;++i) + copy[i].transfer(this->operator[](i)); + + cellList::transfer(copy); + } + else + { + cellList::setSize(label(1.5*nElmts)); + } + } + + nElmts_ = nElmts; } inline void cellListPMG::clear() { - nElmts_ = 0; + nElmts_ = 0; } inline void cellListPMG::append(const cell& c) { - const label i = nElmts_; - setSize(i+1); - this->operator[](i) = c; + const label i = nElmts_; + setSize(i+1); + this->operator[](i) = c; } inline cell& cellListPMG::newElmt(const label cI) { - setSize(cI+1); - return this->operator[](cI); + setSize(cI+1); + return this->operator[](cI); } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // inline void cellListPMG::operator=(const cellList& cls) { - setSize(cls.size()); - forAll(cls, cI) - this->operator[](cI) = cls[cI]; + setSize(cls.size()); + forAll(cls, cI) + this->operator[](cI) = cls[cI]; } - + inline Ostream& operator<<(Ostream& os, const cellListPMG& cls) { - SubList<cell> c(cls, cls.nElmts_, 0); - - os << c; - return os; + SubList<cell> c(cls, cls.nElmts_, 0); + + os << c; + return os; } inline Istream& operator>>(Istream& is, cellListPMG& cls) { - cellList& cells = static_cast<cellList&>(cls); - is >> cells; - cls.nElmts_ = cells.size(); - - return is; + cellList& cells = static_cast<cellList&>(cls); + is >> cells; + cls.nElmts_ = cells.size(); + + return is; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/meshLibrary/utilities/containers/Lists/faceListPMG.C b/meshLibrary/utilities/containers/Lists/faceListPMG.C index 762fb463..32770208 100644 --- a/meshLibrary/utilities/containers/Lists/faceListPMG.C +++ b/meshLibrary/utilities/containers/Lists/faceListPMG.C @@ -35,14 +35,14 @@ Description namespace Foam { //defineCompoundTypeName(IODynListHP<label>, labelIOListPMG); - //defineCompoundTypeName(IODynListHP<point>, pointIOFieldPMG); - //defineCompoundTypeName(IODynListHP<face>, faceIOListPMG); - //defineCompoundTypeName(IODynListHP<cell>, cellIOListPMG); + //defineCompoundTypeName(IODynListHP<point>, pointIOFieldPMG); + //defineCompoundTypeName(IODynListHP<face>, faceIOListPMG); + //defineCompoundTypeName(IODynListHP<cell>, cellIOListPMG); //addCompoundToRunTimeSelectionTable(IODynListHP<label>, labelIODynListHP); defineTemplateTypeNameAndDebugWithName(faceListPMG, "faceList", 0); - //defineTemplateTypeNameAndDebugWithName(faceIOListPMG, "faceList", 0); - //defineTemplateTypeNameAndDebugWithName(cellIOListPMG, "cellList", 0); + //defineTemplateTypeNameAndDebugWithName(faceIOListPMG, "faceList", 0); + //defineTemplateTypeNameAndDebugWithName(cellIOListPMG, "cellList", 0); } // ************************************************************************* // diff --git a/meshLibrary/utilities/containers/Lists/faceListPMG.H b/meshLibrary/utilities/containers/Lists/faceListPMG.H index 67afcc28..d2596333 100644 --- a/meshLibrary/utilities/containers/Lists/faceListPMG.H +++ b/meshLibrary/utilities/containers/Lists/faceListPMG.H @@ -27,7 +27,7 @@ Class Description This is a container with additional size to prevent re-allocation - every time it is resized + every time it is resized SourceFiles @@ -50,63 +50,63 @@ namespace Foam // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // class faceListPMG -: public regIOobject, - public faceList +: public regIOobject, + public faceList { - // Private data - //- number of used elements - label nElmts_; - - // Disallow bitwise assignment - void operator=(const faceListPMG&); - - faceListPMG(const faceListPMG&); - - // Disallow transfer from faceList - void transfer(faceList&); - + // Private data + //- number of used elements + label nElmts_; + + // Disallow bitwise assignment + void operator=(const faceListPMG&); + + faceListPMG(const faceListPMG&); + + // Disallow transfer from faceList + void transfer(faceList&); + public: - - TypeName("List"); - - // Constructors - //- construct from IOobject - inline faceListPMG(const IOobject&); - - //- construct from IOobject and size - inline faceListPMG(const IOobject&, const label); - - //- construct from IOobject and faceList - inline faceListPMG(const IOobject&, const faceList&); - - // Destructor - inline ~faceListPMG(); - - // Member functions - //- return the number of used elements - inline label size() const; - - //- set the number of used elements - inline void setSize(const label nElmts); - - //- set the size to zero - inline void clear(); - - //- add a face at the end of the list - inline void append(const face&); - - //- return an element with bound checking - inline face& newElmt(const label); - - //- read/write the list onto disk - inline bool writeData(Ostream&) const; - - // Member operators - inline void operator=(const faceList&); - - friend inline Ostream& operator<<(Ostream&, const faceListPMG&); - - friend inline Istream& operator>>(Istream&, faceListPMG&); + + TypeName("List"); + + // Constructors + //- construct from IOobject + inline faceListPMG(const IOobject&); + + //- construct from IOobject and size + inline faceListPMG(const IOobject&, const label); + + //- construct from IOobject and faceList + inline faceListPMG(const IOobject&, const faceList&); + + // Destructor + inline ~faceListPMG(); + + // Member functions + //- return the number of used elements + inline label size() const; + + //- set the number of used elements + inline void setSize(const label nElmts); + + //- set the size to zero + inline void clear(); + + //- add a face at the end of the list + inline void append(const face&); + + //- return an element with bound checking + inline face& newElmt(const label); + + //- read/write the list onto disk + inline bool writeData(Ostream&) const; + + // Member operators + inline void operator=(const faceList&); + + friend inline Ostream& operator<<(Ostream&, const faceListPMG&); + + friend inline Istream& operator>>(Istream&, faceListPMG&); }; // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/meshLibrary/utilities/containers/Lists/faceListPMGI.H b/meshLibrary/utilities/containers/Lists/faceListPMGI.H index 2d8c5f76..f688795f 100644 --- a/meshLibrary/utilities/containers/Lists/faceListPMGI.H +++ b/meshLibrary/utilities/containers/Lists/faceListPMGI.H @@ -40,25 +40,25 @@ namespace Foam inline faceListPMG::faceListPMG(const IOobject& io) : - regIOobject(io), - faceList(readStream(typeName)), - nElmts_(faceList::size()) + regIOobject(io), + faceList(readStream(typeName)), + nElmts_(faceList::size()) { } inline faceListPMG::faceListPMG(const IOobject& io, const label s) : - regIOobject(io), - faceList(s), - nElmts_(s) + regIOobject(io), + faceList(s), + nElmts_(s) { } inline faceListPMG::faceListPMG(const IOobject& io, const faceList& fcs) : - regIOobject(io), - faceList(fcs), - nElmts_(fcs.size()) + regIOobject(io), + faceList(fcs), + nElmts_(fcs.size()) { } @@ -70,81 +70,81 @@ inline faceListPMG::~faceListPMG() } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - + inline label faceListPMG::size() const { - return nElmts_; + return nElmts_; } inline void faceListPMG::setSize(const label nElmts) { - if( nElmts >= faceList::size() ) - { - if( faceList::size() != 0 ) - { - Info << "Resizing faces!" << endl; - faceList copy(label(1.5*nElmts)); - for(label i=0;i<nElmts_;++i) - copy[i].transfer(this->operator[](i)); - - faceList::transfer(copy); - } - else - { - faceList::setSize(label(1.5*nElmts)); - } - } - - nElmts_ = nElmts; + if( nElmts >= faceList::size() ) + { + if( faceList::size() != 0 ) + { + Info << "Resizing faces!" << endl; + faceList copy(label(1.5*nElmts)); + for(label i=0;i<nElmts_;++i) + copy[i].transfer(this->operator[](i)); + + faceList::transfer(copy); + } + else + { + faceList::setSize(label(1.5*nElmts)); + } + } + + nElmts_ = nElmts; } inline void faceListPMG::clear() { - nElmts_ = 0; + nElmts_ = 0; } inline void faceListPMG::append(const face& f) { - const label i = nElmts_; - setSize(i+1); - this->operator[](i) = f; + const label i = nElmts_; + setSize(i+1); + this->operator[](i) = f; } inline face& faceListPMG::newElmt(const label fI) { - setSize(fI+1); - return this->operator[](fI); + setSize(fI+1); + return this->operator[](fI); } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // inline bool faceListPMG::writeData(Ostream& os) const { - return (os << *this).good(); + return (os << *this).good(); } inline void faceListPMG::operator=(const faceList& fcs) { - setSize(fcs.size()); - forAll(fcs, fI) - this->operator[](fI) = fcs[fI]; + setSize(fcs.size()); + forAll(fcs, fI) + this->operator[](fI) = fcs[fI]; } - + inline Ostream& operator<<(Ostream& os, const faceListPMG& fcs) { - SubList<face> f(fcs, fcs.nElmts_, 0); - - os << f; - return os; + SubList<face> f(fcs, fcs.nElmts_, 0); + + os << f; + return os; } inline Istream& operator>>(Istream& is, faceListPMG& fcs) { - faceList& faces = static_cast<faceList&>(fcs); - is >> faces; - fcs.nElmts_ = faces.size(); - - return is; + faceList& faces = static_cast<faceList&>(fcs); + is >> faces; + fcs.nElmts_ = faces.size(); + + return is; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/meshLibrary/utilities/containers/Lists/pointFieldPMG.C b/meshLibrary/utilities/containers/Lists/pointFieldPMG.C index 968078c2..9fb37ef1 100644 --- a/meshLibrary/utilities/containers/Lists/pointFieldPMG.C +++ b/meshLibrary/utilities/containers/Lists/pointFieldPMG.C @@ -35,12 +35,12 @@ Description namespace Foam { //defineCompoundTypeName(IODynListHP<label>, labelIOListPMG); - //defineCompoundTypeName(IODynListHP<point>, pointIOFieldPMG); - //defineCompoundTypeName(IODynListHP<face>, faceIOListPMG); - //defineCompoundTypeName(IODynListHP<cell>, cellIOListPMG); + //defineCompoundTypeName(IODynListHP<point>, pointIOFieldPMG); + //defineCompoundTypeName(IODynListHP<face>, faceIOListPMG); + //defineCompoundTypeName(IODynListHP<cell>, cellIOListPMG); //addCompoundToRunTimeSelectionTable(IODynListHP<label>, labelIODynListHP); - defineTemplateTypeNameAndDebugWithName(pointFieldPMG, "vectorField", 0); + defineTemplateTypeNameAndDebugWithName(pointFieldPMG, "vectorField", 0); } // ************************************************************************* // diff --git a/meshLibrary/utilities/containers/Lists/pointFieldPMG.H b/meshLibrary/utilities/containers/Lists/pointFieldPMG.H index 34a02092..84e55efa 100644 --- a/meshLibrary/utilities/containers/Lists/pointFieldPMG.H +++ b/meshLibrary/utilities/containers/Lists/pointFieldPMG.H @@ -27,7 +27,7 @@ Class Description This is a container with additional size to prevent re-allocation - every time it is resized + every time it is resized SourceFiles @@ -50,63 +50,63 @@ namespace Foam // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // class pointFieldPMG -: public regIOobject, - public pointField +: public regIOobject, + public pointField { - // Private data - //- number of used elements - label nElmts_; - - // Disallow bitwise assignment - void operator=(const pointFieldPMG&); - - pointFieldPMG(const pointFieldPMG&); - - // Disallow transfer from pointField - void transfer(pointField&); - + // Private data + //- number of used elements + label nElmts_; + + // Disallow bitwise assignment + void operator=(const pointFieldPMG&); + + pointFieldPMG(const pointFieldPMG&); + + // Disallow transfer from pointField + void transfer(pointField&); + public: - - TypeName("Field"); - - // Constructors - //- construct from IOobject - inline pointFieldPMG(const IOobject&); - - //- construct from IOobject and size - inline pointFieldPMG(const IOobject&, const label); - - //- construct from IOobject and pointField - inline pointFieldPMG(const IOobject&, const pointField&); - - // Destructor - inline ~pointFieldPMG(); - - // Member functions - //- return the number of used elements - inline label size() const; - - //- set the number of used elements - inline void setSize(const label nElmts); - - //- set the size to zero - inline void clear(); - - //- add a point at the end of the list - inline void append(const point&); - - //- return an element with bound checking - inline point& newElmt(const label); - - //- read/write the list onto disk - inline bool writeData(Ostream&) const; - - // Member operators - inline void operator=(const pointField&); - - friend inline Ostream& operator<<(Ostream&, const pointFieldPMG&); - - friend inline Istream& operator>>(Istream&, pointFieldPMG&); + + TypeName("Field"); + + // Constructors + //- construct from IOobject + inline pointFieldPMG(const IOobject&); + + //- construct from IOobject and size + inline pointFieldPMG(const IOobject&, const label); + + //- construct from IOobject and pointField + inline pointFieldPMG(const IOobject&, const pointField&); + + // Destructor + inline ~pointFieldPMG(); + + // Member functions + //- return the number of used elements + inline label size() const; + + //- set the number of used elements + inline void setSize(const label nElmts); + + //- set the size to zero + inline void clear(); + + //- add a point at the end of the list + inline void append(const point&); + + //- return an element with bound checking + inline point& newElmt(const label); + + //- read/write the list onto disk + inline bool writeData(Ostream&) const; + + // Member operators + inline void operator=(const pointField&); + + friend inline Ostream& operator<<(Ostream&, const pointFieldPMG&); + + friend inline Istream& operator>>(Istream&, pointFieldPMG&); }; // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/meshLibrary/utilities/containers/Lists/pointFieldPMGI.H b/meshLibrary/utilities/containers/Lists/pointFieldPMGI.H index 5f7c9667..d58e8cfc 100644 --- a/meshLibrary/utilities/containers/Lists/pointFieldPMGI.H +++ b/meshLibrary/utilities/containers/Lists/pointFieldPMGI.H @@ -40,26 +40,26 @@ namespace Foam inline pointFieldPMG::pointFieldPMG(const IOobject& io) : - regIOobject(io), - pointField(readStream(typeName)), - nElmts_(pointField::size()) + regIOobject(io), + pointField(readStream(typeName)), + nElmts_(pointField::size()) { - close(); + close(); } inline pointFieldPMG::pointFieldPMG(const IOobject& io, const label s) : - regIOobject(io), - pointField(s), - nElmts_(s) + regIOobject(io), + pointField(s), + nElmts_(s) { } inline pointFieldPMG::pointFieldPMG(const IOobject& io, const pointField& pts) : - regIOobject(io), - pointField(pts), - nElmts_(pts.size()) + regIOobject(io), + pointField(pts), + nElmts_(pts.size()) { } @@ -71,70 +71,70 @@ inline pointFieldPMG::~pointFieldPMG() } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - + inline label pointFieldPMG::size() const { - return nElmts_; + return nElmts_; } inline void pointFieldPMG::setSize(const label nElmts) { - if( nElmts >= pointField::size() ) - { - Info << "Resizing points!" << endl; - pointField::setSize(label(1.5*nElmts)+1); - } + if( nElmts >= pointField::size() ) + { + Info << "Resizing points!" << endl; + pointField::setSize(label(1.5*nElmts)+1); + } - nElmts_ = nElmts; + nElmts_ = nElmts; } inline void pointFieldPMG::clear() { - nElmts_ = 0; + nElmts_ = 0; } inline void pointFieldPMG::append(const point& p) { - const label i = nElmts_; - setSize(i+1); - this->operator[](i) = p; + const label i = nElmts_; + setSize(i+1); + this->operator[](i) = p; } inline point& pointFieldPMG::newElmt(const label pI) { - setSize(pI+1); - return this->operator[](pI); + setSize(pI+1); + return this->operator[](pI); } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // inline bool pointFieldPMG::writeData(Ostream& os) const { - return (os << *this).good(); + return (os << *this).good(); } inline void pointFieldPMG::operator=(const pointField& pts) { - setSize(pts.size()); - forAll(pts, pI) - this->operator[](pI) = pts[pI]; + setSize(pts.size()); + forAll(pts, pI) + this->operator[](pI) = pts[pI]; } - + inline Ostream& operator<<(Ostream& os, const pointFieldPMG& pts) { - SubList<point> p(pts, pts.nElmts_, 0); - - os << p; - return os; + SubList<point> p(pts, pts.nElmts_, 0); + + os << p; + return os; } inline Istream& operator>>(Istream& is, pointFieldPMG& pts) { - pointField& points = static_cast<pointField&>(pts); - is >> points; - pts.nElmts_ = points.size(); - - return is; + pointField& points = static_cast<pointField&>(pts); + is >> points; + pts.nElmts_ = points.size(); + + return is; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/meshLibrary/utilities/containers/LongList/LongList.C b/meshLibrary/utilities/containers/LongList/LongList.C index 40b37762..31e48775 100644 --- a/meshLibrary/utilities/containers/LongList/LongList.C +++ b/meshLibrary/utilities/containers/LongList/LongList.C @@ -31,14 +31,14 @@ License #include "Time.H" // * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * // - + template<class T, Foam::label Offset> void Foam::LongList<T, Offset>::writeEntry(Ostream& os) const { - if + if ( size() && - token::compound::isCompound + token::compound::isCompound ( "LongList<" + word(pTraits<T>::typeName) + '>' ) @@ -53,11 +53,11 @@ void Foam::LongList<T, Offset>::writeEntry(Ostream& os) const template<class T, Foam::label Offset> void Foam::LongList<T, Offset>::writeEntry ( - const word& keyword, - Ostream& os + const word& keyword, + Ostream& os ) const { - os.writeKeyword(keyword); + os.writeKeyword(keyword); writeEntry(os); os << token::END_STATEMENT << endl; } @@ -126,10 +126,10 @@ Foam::Ostream& Foam::operator<< } } } - - // Check state of IOstream + + // Check state of IOstream os.check("Ostream& operator<<(Ostream&, const LongList&)"); - + return os; } diff --git a/meshLibrary/utilities/containers/LongList/LongList.H b/meshLibrary/utilities/containers/LongList/LongList.H index 30e89ffa..c8d4387e 100644 --- a/meshLibrary/utilities/containers/LongList/LongList.H +++ b/meshLibrary/utilities/containers/LongList/LongList.H @@ -29,8 +29,8 @@ Description A dynamic list is a 1-D vector of objects of type T which resizes itself as necessary to accept the new objects. Internal storage is a 2-D graph with a fixed size of the chunks used to store the data. - This way the data does not get copied every time array is resized, but - only the pointers to the chunks of data. + This way the data does not get copied every time array is resized, but + only the pointers to the chunks of data. SourceFiles LongListI.H @@ -76,41 +76,41 @@ template<class T, label Offset = 19> class LongList { // Private data - //- number of allocated elements - label N_; - - //- number of elements in the list - label nextFree_; + //- number of allocated elements + label N_; + + //- number of elements in the list + label nextFree_; //- number of used blocks of data - label numBlocks_; + label numBlocks_; //- maximum number of blocks that can be allocated //- without reallocating the list containing pointers //- to the chunks of data label numAllocatedBlocks_; - - //- size of blocks is calculated by powers of 2 - //- and therefore the access can be done using shift and mask - label shift_; - label mask_; + + //- size of blocks is calculated by powers of 2 + //- and therefore the access can be done using shift and mask + label shift_; + label mask_; - //- array of pointers to the blocks of data, each of the size WIDTH - T** dataPtr_; - - // Private member functions - //- check index - void checkIndex(label const i) const; - - //- initialize width and mask - void initializeParameters(); + //- array of pointers to the blocks of data, each of the size WIDTH + T** dataPtr_; + + // Private member functions + //- check index + void checkIndex(label const i) const; + + //- initialize width and mask + void initializeParameters(); //- Allocate memory for the list void allocateSize(const label); - - //- delete all elements - void clearOut(); - + + //- delete all elements + void clearOut(); + public: // Constructors @@ -121,15 +121,15 @@ public: //- Construct given size explicit inline LongList(const label size); - //- Construct to given size and initialize - explicit inline LongList(const label size, const T& t); + //- Construct to given size and initialize + explicit inline LongList(const label size, const T& t); //- Copy contructor - inline LongList(const LongList<T, Offset>&); + inline LongList(const LongList<T, Offset>&); - // Destructor + // Destructor - inline ~LongList(); + inline ~LongList(); // Member Functions @@ -154,52 +154,52 @@ public: //- Shrink the list to the number of elements used inline LongList<T, Offset>& shrink(); - - //- transfer the list from another one without allocating it - inline void transfer(LongList<T, Offset>&); + + //- transfer the list from another one without allocating it + inline void transfer(LongList<T, Offset>&); // Member Operators //- Append an element at the end of the list inline void append(const T& e); - - //- Append an element at the end of the list if it is not yet - //- present in the list (takes linear time) - inline void appendIfNotIn(const T& e); - - //- check if the element is in the list (takes linear time) - inline bool contains(const T& e) const; - inline label containsAtPosition(const T& e) const; + + //- Append an element at the end of the list if it is not yet + //- present in the list (takes linear time) + inline void appendIfNotIn(const T& e); + + //- check if the element is in the list (takes linear time) + inline bool contains(const T& e) const; + inline label containsAtPosition(const T& e) const; //- Return and remove the element inline T remove(const label i); inline T removeLastElement(); - - //- get and set operators - inline const T& operator[](const label i) const; - inline T& operator[](const label i); + + //- get and set operators + inline const T& operator[](const label i) const; + inline T& operator[](const label i); //- Return non-const access to an element, // resizing the list if necessary inline T& operator()(const label); - - //- return a non-const access to an element, - // resize the list if necessary - inline T& newElmt(const label); + + //- return a non-const access to an element, + // resize the list if necessary + inline T& newElmt(const label); //- Assignment of all entries to the given value inline void operator=(const T&); - - //- Assignment operator - inline void operator=(const LongList<T, Offset>&); + + //- Assignment operator + inline void operator=(const LongList<T, Offset>&); // IOstream operators //- Read from stream and append to the current content void appendFromStream(Istream&); - //- Write as a dictionary entry. + //- Write as a dictionary entry. void writeEntry(Ostream& os) const; //- Write as a dictionary entry with keyword. diff --git a/meshLibrary/utilities/containers/LongList/LongListI.H b/meshLibrary/utilities/containers/LongList/LongListI.H index 76c5dcf2..b71f9c10 100644 --- a/meshLibrary/utilities/containers/LongList/LongListI.H +++ b/meshLibrary/utilities/containers/LongList/LongListI.H @@ -29,53 +29,53 @@ License template<class T, Foam::label Offset> void Foam::LongList<T, Offset>::checkIndex(const label i) const { - if( (i < 0) || (i >= nextFree_) ) - { - FatalErrorIn - ( - "void Foam::LongList<T, label, Offset>::" - "checkIndex(const label i) const" - ) << "Index " << Foam::label(i) << " is not in range " << Foam::label(0) - << " and " << Foam::label(nextFree_) << abort(FatalError); - } + if( (i < 0) || (i >= nextFree_) ) + { + FatalErrorIn + ( + "void Foam::LongList<T, label, Offset>::" + "checkIndex(const label i) const" + ) << "Index " << Foam::label(i) << " is not in range " << Foam::label(0) + << " and " << Foam::label(nextFree_) << abort(FatalError); + } } template<class T, Foam::label Offset> void Foam::LongList<T, Offset>::initializeParameters() { - unsigned int t = sizeof(T); - label it(0); + unsigned int t = sizeof(T); + label it(0); - while( t > 1 ) - { - t >>= 1; - ++it; - } + while( t > 1 ) + { + t >>= 1; + ++it; + } - shift_ = Foam::max(10, Offset - it); + shift_ = Foam::max(10, Offset - it); mask_ = 1<<shift_; - mask_ -= 1; + mask_ -= 1; } template<class T, Foam::label Offset> inline void Foam::LongList<T, Offset>::allocateSize(const label s) { - if( s == 0 ) - { - clearOut(); - return; - } + if( s == 0 ) + { + clearOut(); + return; + } - const label numblock1 = ((s-1)>>shift_) + 1; + const label numblock1 = ((s-1)>>shift_) + 1; const label blockSize = 1<<shift_; - if( numblock1 < numBlocks_ ) - { - for(register label i=numblock1;i<numBlocks_;++i) - delete [] dataPtr_[i]; - } - else if( numblock1 > numBlocks_ ) - { + if( numblock1 < numBlocks_ ) + { + for(register label i=numblock1;i<numBlocks_;++i) + delete [] dataPtr_[i]; + } + else if( numblock1 > numBlocks_ ) + { if( numblock1 >= numAllocatedBlocks_ ) { do @@ -92,30 +92,30 @@ inline void Foam::LongList<T, Offset>::allocateSize(const label s) dataPtr_ = dataptr1; } - for(register label i=numBlocks_;i<numblock1;++i) - dataPtr_[i] = new T[blockSize]; - } - - numBlocks_ = numblock1; - N_ = numBlocks_ * blockSize; + for(register label i=numBlocks_;i<numblock1;++i) + dataPtr_[i] = new T[blockSize]; + } + + numBlocks_ = numblock1; + N_ = numBlocks_ * blockSize; } template<class T, Foam::label Offset> void Foam::LongList<T, Offset>::clearOut() { - for(register label i=0;i<numBlocks_;++i) - delete [] dataPtr_[i]; - - if( dataPtr_ ) - { - delete [] dataPtr_; - dataPtr_ = NULL; - } - - N_ = 0; - numBlocks_ = 0; + for(register label i=0;i<numBlocks_;++i) + delete [] dataPtr_[i]; + + if( dataPtr_ ) + { + delete [] dataPtr_; + dataPtr_ = NULL; + } + + N_ = 0; + numBlocks_ = 0; numAllocatedBlocks_ = 0; - nextFree_ = 0; + nextFree_ = 0; } // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // @@ -124,31 +124,31 @@ void Foam::LongList<T, Offset>::clearOut() template<class T, Foam::label Offset> inline Foam::LongList<T, Offset>::LongList() : - N_(0), - nextFree_(0), - numBlocks_(0), + N_(0), + nextFree_(0), + numBlocks_(0), numAllocatedBlocks_(0), - shift_(), - mask_(), - dataPtr_(NULL) + shift_(), + mask_(), + dataPtr_(NULL) { - initializeParameters(); + initializeParameters(); } //- Construct given size template<class T, Foam::label Offset> inline Foam::LongList<T, Offset>::LongList(const label s) : - N_(0), - nextFree_(0), - numBlocks_(0), + N_(0), + nextFree_(0), + numBlocks_(0), numAllocatedBlocks_(0), - shift_(), - mask_(), - dataPtr_(NULL) + shift_(), + mask_(), + dataPtr_(NULL) { - initializeParameters(); - setSize(s); + initializeParameters(); + setSize(s); } @@ -156,37 +156,37 @@ inline Foam::LongList<T, Offset>::LongList(const label s) template<class T, Foam::label Offset> inline Foam::LongList<T, Offset>::LongList(const label s, const T& t) : - N_(0), - nextFree_(0), - numBlocks_(0), + N_(0), + nextFree_(0), + numBlocks_(0), numAllocatedBlocks_(0), - shift_(), - mask_(), - dataPtr_(NULL) + shift_(), + mask_(), + dataPtr_(NULL) { - initializeParameters(); - setSize(s); - *this = t; + initializeParameters(); + setSize(s); + *this = t; } template<class T, Foam::label Offset> inline Foam::LongList<T, Offset>::LongList(const LongList<T, Offset>& ol) : - N_(0), - nextFree_(0), - numBlocks_(0), + N_(0), + nextFree_(0), + numBlocks_(0), numAllocatedBlocks_(0), - shift_(ol.shift_), - mask_(ol.mask_), - dataPtr_(NULL) + shift_(ol.shift_), + mask_(ol.mask_), + dataPtr_(NULL) { - *this = ol; + *this = ol; } template<class T, Foam::label Offset> inline Foam::LongList<T, Offset>::~LongList() { - clearOut(); + clearOut(); } // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // @@ -214,8 +214,8 @@ inline Foam::label Foam::LongList<T, Offset>::byteSize() const template<class T, Foam::label Offset> inline void Foam::LongList<T, Offset>::setSize(const label i) { - allocateSize(i); - nextFree_ = i; + allocateSize(i); + nextFree_ = i; } template<class T, Foam::label Offset> @@ -236,19 +236,19 @@ Foam::LongList<T, Offset>::shrink() template<class T, Foam::label Offset> inline void Foam::LongList<T, Offset>::transfer(LongList<T, Offset>& ol) { - clearOut(); - dataPtr_ = ol.dataPtr_; - N_ = ol.N_; - nextFree_ = ol.nextFree_; - numBlocks_ = ol.numBlocks_; + clearOut(); + dataPtr_ = ol.dataPtr_; + N_ = ol.N_; + nextFree_ = ol.nextFree_; + numBlocks_ = ol.numBlocks_; numAllocatedBlocks_ = ol.numAllocatedBlocks_; - shift_ = ol.shift_; - mask_ = ol.mask_; - - ol.dataPtr_ = NULL; - ol.N_ = 0; - ol.nextFree_ = 0; - ol.numBlocks_ = 0; + shift_ = ol.shift_; + mask_ = ol.mask_; + + ol.dataPtr_ = NULL; + ol.N_ = 0; + ol.nextFree_ = 0; + ol.numBlocks_ = 0; ol.numAllocatedBlocks_ = 0; } @@ -256,29 +256,29 @@ inline void Foam::LongList<T, Offset>::transfer(LongList<T, Offset>& ol) template<class T, Foam::label Offset> inline void Foam::LongList<T, Offset>::append(const T& e) { - if( nextFree_ >= N_ ) + if( nextFree_ >= N_ ) { - allocateSize(nextFree_+1); + allocateSize(nextFree_+1); } - - operator[](nextFree_++) = e; + + operator[](nextFree_++) = e; } template<class T, Foam::label Offset> inline void Foam::LongList<T, Offset>::appendIfNotIn(const T& e) { - if( !contains(e) ) - append(e); + if( !contains(e) ) + append(e); } template<class T, Foam::label Offset> inline bool Foam::LongList<T, Offset>::contains(const T& e) const { - for(register label i=0;i<nextFree_;++i) - if( (*this)[i] == e ) - return true; - - return false; + for(register label i=0;i<nextFree_;++i) + if( (*this)[i] == e ) + return true; + + return false; } template<class T, Foam::label Offset> @@ -287,11 +287,11 @@ inline Foam::label Foam::LongList<T, Offset>::containsAtPosition const T& e ) const { - for(register label i=0;i<nextFree_;++i) - if( (*this)[i] == e ) - return i; - - return -1; + for(register label i=0;i<nextFree_;++i) + if( (*this)[i] == e ) + return i; + + return -1; } template<class T, Foam::label Offset> @@ -304,9 +304,9 @@ inline T Foam::LongList<T, Offset>::remove(const label i) "void Foam::LongList<T, Offset>::remove()" ) << "List is empty" << abort(FatalError); } - + T el = operator[](i); - operator[](i) = operator[](nextFree_-1); + operator[](i) = operator[](nextFree_-1); --nextFree_; return el; } @@ -333,28 +333,28 @@ inline T Foam::LongList<T, Offset>::removeLastElement() template<class T, Foam::label Offset> inline const T& Foam::LongList<T, Offset>::operator[](const label i) const { - #ifdef FULLDEBUG - checkIndex(i); - #endif - - return dataPtr_[i>>shift_][i&mask_]; + #ifdef FULLDEBUG + checkIndex(i); + #endif + + return dataPtr_[i>>shift_][i&mask_]; } template<class T, Foam::label Offset> inline T& Foam::LongList<T, Offset>::operator[](const label i) { - #ifdef FULLDEBUG - checkIndex(i); - #endif - - return dataPtr_[i>>shift_][i&mask_]; + #ifdef FULLDEBUG + checkIndex(i); + #endif + + return dataPtr_[i>>shift_][i&mask_]; } template<class T, Foam::label Offset> inline T& Foam::LongList<T, Offset>::operator()(const label i) { if( i >= nextFree_ ) - setSize(i+1); + setSize(i+1); return operator[](i); } @@ -363,22 +363,22 @@ inline T& Foam::LongList<T, Offset>::operator()(const label i) template<class T, Foam::label Offset> inline T& Foam::LongList<T, Offset>::newElmt(const label i) { - return operator()(i); + return operator()(i); } template<class T, Foam::label Offset> inline void Foam::LongList<T, Offset>::operator=(const T& t) { for(register label i=0;i<nextFree_;++i) - operator[](i) = t; + operator[](i) = t; } template<class T, Foam::label Offset> inline void Foam::LongList<T, Offset>::operator=(const LongList<T, Offset>& l) { - setSize(l.size()); - for(register label i=0;i<l.nextFree_;++i) - operator[](i) = l[i]; + setSize(l.size()); + for(register label i=0;i<l.nextFree_;++i) + operator[](i) = l[i]; } diff --git a/meshLibrary/utilities/containers/VRWGraph/VRWGraph.C b/meshLibrary/utilities/containers/VRWGraph/VRWGraph.C index b8da9352..8be1384d 100644 --- a/meshLibrary/utilities/containers/VRWGraph/VRWGraph.C +++ b/meshLibrary/utilities/containers/VRWGraph/VRWGraph.C @@ -36,22 +36,22 @@ Foam::Ostream& Foam::operator<< const Foam::VRWGraph& DL ) { - os << DL.size() << nl << token::BEGIN_LIST; - - for(register label i=0;i<DL.size();++i) - { - os << nl << DL.sizeOfRow(i) << token::BEGIN_LIST; - for(label j=0;j<DL.sizeOfRow(i);++j) - { - if( j > 0 ) os << token::SPACE; - - os << DL(i, j); - } - - os << token::END_LIST; - } - - os << nl << token::END_LIST; + os << DL.size() << nl << token::BEGIN_LIST; + + for(register label i=0;i<DL.size();++i) + { + os << nl << DL.sizeOfRow(i) << token::BEGIN_LIST; + for(label j=0;j<DL.sizeOfRow(i);++j) + { + if( j > 0 ) os << token::SPACE; + + os << DL(i, j); + } + + os << token::END_LIST; + } + + os << nl << token::END_LIST; return os; } @@ -63,15 +63,15 @@ Foam::Istream& Foam::operator>> Foam::VRWGraph<T, width>& DL ) { - label size; - T e; - is >> size; - DL.setSize(size); - for(IndexType i=0;i<size;++i) - { - is >> e; - DL[i] = e; - } + label size; + T e; + is >> size; + DL.setSize(size); + for(IndexType i=0;i<size;++i) + { + is >> e; + DL[i] = e; + } return is; } @@ -79,31 +79,31 @@ Foam::Istream& Foam::operator>> void Foam::VRWGraph::optimizeMemoryUsage() { - labelListPMG newPosForNode(data_.size()); - label pos(0), nElements; - nElements = data_.size(); - for(label elI=0;elI<nElements;++elI) - if( data_[elI] != FREEENTRY ) - { - newPosForNode[elI] = pos++; - } - else - { - newPosForNode[elI] = -1; - } - - //- create new data - for(label elI=0;elI<nElements;++elI) - if( (newPosForNode[elI] != -1) && (newPosForNode[elI] < elI) ) - data_[newPosForNode[elI]] = data_[elI]; - - data_.setSize(pos); - - //- renumber rows - nElements = rows_.size(); - for(label rowI=0;rowI<nElements;++rowI) - if( rows_[rowI].start() != INVALIDROW ) - rows_[rowI].start() = newPosForNode[rows_[rowI].start()]; + labelListPMG newPosForNode(data_.size()); + label pos(0), nElements; + nElements = data_.size(); + for(label elI=0;elI<nElements;++elI) + if( data_[elI] != FREEENTRY ) + { + newPosForNode[elI] = pos++; + } + else + { + newPosForNode[elI] = -1; + } + + //- create new data + for(label elI=0;elI<nElements;++elI) + if( (newPosForNode[elI] != -1) && (newPosForNode[elI] < elI) ) + data_[newPosForNode[elI]] = data_[elI]; + + data_.setSize(pos); + + //- renumber rows + nElements = rows_.size(); + for(label rowI=0;rowI<nElements;++rowI) + if( rows_[rowI].start() != INVALIDROW ) + rows_[rowI].start() = newPosForNode[rows_[rowI].start()]; } // ************************************************************************* // diff --git a/meshLibrary/utilities/containers/VRWGraph/VRWGraph.H b/meshLibrary/utilities/containers/VRWGraph/VRWGraph.H index 506cc9c2..efdb2436 100644 --- a/meshLibrary/utilities/containers/VRWGraph/VRWGraph.H +++ b/meshLibrary/utilities/containers/VRWGraph/VRWGraph.H @@ -27,7 +27,7 @@ Class Description This class is an implementation of a graph with variable column width. - The imoplementation is memory efficient. + The imoplementation is memory efficient. SourceFiles VRWGraphI.H @@ -48,49 +48,49 @@ SourceFiles namespace Foam { - + class VRWGraphModifier; - + class rowElement { - // Private data - label start_; - label size_; - - public: - - inline rowElement() - : - start_(), - size_() - {} - - inline rowElement(const label i, const label j) - : - start_(i), - size_(j) - {} - - inline ~rowElement() - {} - - inline label start() const - { - return start_; - } - inline label& start() - { - return start_; - } - - inline label size() const - { - return size_; - } - inline label& size() - { - return size_; - } + // Private data + label start_; + label size_; + + public: + + inline rowElement() + : + start_(), + size_() + {} + + inline rowElement(const label i, const label j) + : + start_(i), + size_(j) + {} + + inline ~rowElement() + {} + + inline label start() const + { + return start_; + } + inline label& start() + { + return start_; + } + + inline label size() const + { + return size_; + } + inline label& size() + { + return size_; + } }; /*---------------------------------------------------------------------------*\ @@ -100,30 +100,30 @@ class rowElement class VRWGraph { // Private data - //- list containing the data - labelListPMG data_; - - //- number of rows - LongList<rowElement> rows_; - - // Private member functions - //- check index - inline void checkIndex(const label i, const label j) const; - - // Enumerators - enum typeOfEntries - { - NONE = 0, - INVALIDROW=-10, - FREEENTRY=-11, - FREESTART=-12 - }; - + //- list containing the data + labelListPMG data_; + + //- number of rows + LongList<rowElement> rows_; + + // Private member functions + //- check index + inline void checkIndex(const label i, const label j) const; + + // Enumerators + enum typeOfEntries + { + NONE = 0, + INVALIDROW=-10, + FREEENTRY=-11, + FREESTART=-12 + }; + public: - - // Friend classes + + // Friend classes - friend class VRWGraphSMPModifier; + friend class VRWGraphSMPModifier; // Constructors @@ -135,25 +135,25 @@ public: //- Construct given number of rows and row size explicit inline VRWGraph - ( - const label nRows, - const label nColumnsInRow + ( + const label nRows, + const label nColumnsInRow ); - //- Construct to given number of rows, row size and initialize - explicit inline VRWGraph - ( - const label nRows, - const label nColumnsInRow, - const label t - ); + //- Construct to given number of rows, row size and initialize + explicit inline VRWGraph + ( + const label nRows, + const label nColumnsInRow, + const label t + ); //- Copy contructor - inline VRWGraph(const VRWGraph&); + inline VRWGraph(const VRWGraph&); - // Destructor + // Destructor - inline ~VRWGraph(); + inline ~VRWGraph(); // Member Functions @@ -161,18 +161,18 @@ public: //- Returns the number of rows inline label size() const; - - //- Returns the number of elements in the given row - inline label sizeOfRow(const label rowI) const; + + //- Returns the number of elements in the given row + inline label sizeOfRow(const label rowI) const; // Edit //- Reset the number of rows inline void setSize(const label); - - //- Reset the number of rows. The second argument specifies - //- the reserved column width - inline void setSizeAndColumnWidth + + //- Reset the number of rows. The second argument specifies + //- the reserved column width + inline void setSizeAndColumnWidth ( const label newNumRows, const label rcWidth @@ -181,9 +181,9 @@ public: //- Set the number of rows and the size of each row template<class ListType> inline void setSizeAndRowSize(const ListType&); - - //- Reset the size of the given row - inline void setRowSize(const label rowI, const label newSize); + + //- Reset the size of the given row + inline void setRowSize(const label rowI, const label newSize); //- Clear the graph inline void clear(); @@ -191,18 +191,18 @@ public: // Member Operators //- Append a list as a row at the end of the graph - template<class ListType> + template<class ListType> inline void appendList(const ListType& l); - - //- Append an element to the given row - inline void append(const label rowI, const label); - - //- Append an element to the given row if it does not exist there - inline void appendIfNotIn(const label rowI, const label); - - //- Set row with the list - template<class ListType> - inline void setRow(const label rowI, const ListType& l); + + //- Append an element to the given row + inline void append(const label rowI, const label); + + //- Append an element to the given row if it does not exist there + inline void appendIfNotIn(const label rowI, const label); + + //- Set row with the list + template<class ListType> + inline void setRow(const label rowI, const ListType& l); //- merge graphs with the identical number of rows //- into a single one. Use for SMP parallelisation @@ -228,24 +228,24 @@ public: ); inline void reverseAddressing(const VRWGraph& origGraph); - - //- optimize memory usage - // this should be used once the graph will not be resized any more - void optimizeMemoryUsage(); - - //- check if the element is in the given row (takes linear time) - inline bool contains(const label rowI, const label e) const; - inline label containsAtPosition(const label rowI, const label e) const; - - //- get and set operators - inline label operator()(const label i, const label j) const; - inline label& operator()(const label i, const label j); - - inline constRow operator[](const label i) const; - inline row operator[](const label i); - - //- Assignment operator - inline void operator=(const VRWGraph&); + + //- optimize memory usage + // this should be used once the graph will not be resized any more + void optimizeMemoryUsage(); + + //- check if the element is in the given row (takes linear time) + inline bool contains(const label rowI, const label e) const; + inline label containsAtPosition(const label rowI, const label e) const; + + //- get and set operators + inline label operator()(const label i, const label j) const; + inline label& operator()(const label i, const label j); + + inline constRow operator[](const label i) const; + inline row operator[](const label i); + + //- Assignment operator + inline void operator=(const VRWGraph&); // IOstream operators @@ -274,7 +274,7 @@ public: // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // #define forAllRow(graph, rowI, index) \ - for(Foam::label index=0;index<(graph).sizeOfRow(rowI);++index) + for(Foam::label index=0;index<(graph).sizeOfRow(rowI);++index) // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/meshLibrary/utilities/containers/VRWGraph/VRWGraphI.H b/meshLibrary/utilities/containers/VRWGraph/VRWGraphI.H index 9bfc9ec2..9a25c9b5 100644 --- a/meshLibrary/utilities/containers/VRWGraph/VRWGraphI.H +++ b/meshLibrary/utilities/containers/VRWGraph/VRWGraphI.H @@ -26,25 +26,25 @@ License inline void Foam::VRWGraph::checkIndex(const label i, const label j) const { - if( (i < 0) || (i >= rows_.size()) ) - { - FatalErrorIn - ( - "void Foam::VRWGraph<T,width>::" - "checkIndex(const label i, const label j) const" - ) << "Row index " << Foam::label(i) - << " is not in range " << Foam::label(0) - << " and " << rows_.size() << abort(FatalError); - } - - if( (j < 0) || (j >= rows_[i].size()) ) - FatalErrorIn - ( - "void Foam::VRWGraph<T,width>::" - "checkIndex(label const i) const" - ) << "Column index " << Foam::label(j) - << " is not in range " << Foam::label(0) - << " and " << rows_[i].size() << abort(FatalError); + if( (i < 0) || (i >= rows_.size()) ) + { + FatalErrorIn + ( + "void Foam::VRWGraph<T,width>::" + "checkIndex(const label i, const label j) const" + ) << "Row index " << Foam::label(i) + << " is not in range " << Foam::label(0) + << " and " << rows_.size() << abort(FatalError); + } + + if( (j < 0) || (j >= rows_[i].size()) ) + FatalErrorIn + ( + "void Foam::VRWGraph<T,width>::" + "checkIndex(label const i) const" + ) << "Column index " << Foam::label(j) + << " is not in range " << Foam::label(0) + << " and " << rows_[i].size() << abort(FatalError); } // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // @@ -52,8 +52,8 @@ inline void Foam::VRWGraph::checkIndex(const label i, const label j) const //- Construct null inline Foam::VRWGraph::VRWGraph() : - data_(), - rows_() + data_(), + rows_() { } @@ -63,14 +63,14 @@ inline Foam::VRWGraph::VRWGraph const label size ) : - data_(), - rows_(size) + data_(), + rows_(size) { - for(label rowI=0;rowI<size;++rowI) - { - rows_[rowI].start() = INVALIDROW; - rows_[rowI].size() = NONE; - } + for(label rowI=0;rowI<size;++rowI) + { + rows_[rowI].start() = INVALIDROW; + rows_[rowI].size() = NONE; + } } inline Foam::VRWGraph::VRWGraph @@ -80,39 +80,39 @@ inline Foam::VRWGraph::VRWGraph ) : data_(nRows * nColumnsInRow), - rows_(nRows) + rows_(nRows) { for(label rowI=0;rowI<nRows;++rowI) - { - rows_[rowI].start() = rowI*nColumnsInRow; - rows_[rowI].size() = nColumnsInRow; - } + { + rows_[rowI].start() = rowI*nColumnsInRow; + rows_[rowI].size() = nColumnsInRow; + } } inline Foam::VRWGraph::VRWGraph ( const label nRows, - const label nColumnsInRow, - const label t + const label nColumnsInRow, + const label t ) : - data_(nRows * nColumnsInRow, t), - rows_(nRows) + data_(nRows * nColumnsInRow, t), + rows_(nRows) { - for(label rowI=0;rowI<nRows;++rowI) - { - rows_[rowI].start() = rowI*nColumnsInRow; - rows_[rowI].size() = nColumnsInRow; - } + for(label rowI=0;rowI<nRows;++rowI) + { + rows_[rowI].start() = rowI*nColumnsInRow; + rows_[rowI].size() = nColumnsInRow; + } } inline Foam::VRWGraph::VRWGraph ( - const VRWGraph& ol + const VRWGraph& ol ) : - data_(ol.data_), - rows_(ol.rows_) + data_(ol.data_), + rows_(ol.rows_) { } @@ -130,52 +130,52 @@ inline Foam::label Foam::VRWGraph::size() const inline Foam::label Foam::VRWGraph::sizeOfRow(const label rowI) const { - return rows_[rowI].size(); + return rows_[rowI].size(); } inline void Foam::VRWGraph::setSize(const label size) { - if( size > rows_.size() ) - { - rowElement rowInfo(INVALIDROW, NONE); - - for(label i=rows_.size();i<size;++i) - rows_.append(rowInfo); - } - else - { - rows_.setSize(size); - } + if( size > rows_.size() ) + { + rowElement rowInfo(INVALIDROW, NONE); + + for(label i=rows_.size();i<size;++i) + rows_.append(rowInfo); + } + else + { + rows_.setSize(size); + } } void Foam::VRWGraph::setSizeAndColumnWidth ( - const label newNumRows, - const label rcWidth + const label newNumRows, + const label rcWidth ) { - if( rows_.size() != 0 ) - FatalErrorIn - ( - "void Foam::VRWGraph::setSizeAndColumnWidth" - "(const label size, const label rcWidth)" - ) << "This function should be used for empty graphs, only!" - << exit(FatalError); - - data_.setSize(newNumRows * rcWidth); - data_ = FREEENTRY; - - rows_.setSize(newNumRows); - label start(0); - - for(label i=0;i<newNumRows;++i) - { - rows_[i].start() = start; - rows_[i].size() = 0; - data_[start] = FREESTART; - - start += rcWidth; - } + if( rows_.size() != 0 ) + FatalErrorIn + ( + "void Foam::VRWGraph::setSizeAndColumnWidth" + "(const label size, const label rcWidth)" + ) << "This function should be used for empty graphs, only!" + << exit(FatalError); + + data_.setSize(newNumRows * rcWidth); + data_ = FREEENTRY; + + rows_.setSize(newNumRows); + label start(0); + + for(label i=0;i<newNumRows;++i) + { + rows_[i].start() = start; + rows_[i].size() = 0; + data_[start] = FREESTART; + + start += rcWidth; + } } template<class ListType> @@ -207,88 +207,88 @@ inline void Foam::VRWGraph::setSizeAndRowSize(const ListType& l) inline void Foam::VRWGraph::setRowSize(const label rowI, const label newSize) { - # ifdef FULLDEBUG - if( (rowI < 0) || (rowI >= rows_.size()) ) - FatalErrorIn - ( - "void Foam::VRWGraph<T,width>::" - "checkIndex(const label rowI, const label size) const" - ) << "Row index " << Foam::label(rowI) - << " is not in range " << Foam::label(0) - << " and " << rows_.size() << abort(FatalError); - # endif - - const label start = rows_[rowI].start(); - if( start == INVALIDROW ) - { - if( newSize > 0 ) - { - rows_[rowI].start() = data_.size(); - for(label i=0;i<newSize;++i) - data_.append(NONE); - rows_[rowI].size() = newSize; - } - } - else if( newSize > rows_[rowI].size() ) - { - //- check if there is some unused space after the last element - bool foundUnused(true); - - for(label i=rows_[rowI].size();i<newSize;++i) - { - const label j = start + i; - if( - (j >= data_.size()) || - (data_[j] != FREEENTRY) || - (data_[j] == FREESTART) - ) - { - foundUnused = false; - break; - } - } - - if( foundUnused ) - { - //- row can be extended without copying - for(label i=rows_[rowI].size();i<newSize;++i) - data_[start+i] = NONE; - } - else - { - //- row is copied at the end of the data list - rows_[rowI].start() = data_.size(); - for(label i=0;i<rows_[rowI].size();++i) - { - data_.append(data_[start+i]); - data_[start+i] = FREEENTRY; - } - for(label i=rows_[rowI].size();i<newSize;++i) - data_.append(NONE); - } - - rows_[rowI].size() = newSize; - } - else if( newSize < rows_[rowI].size() ) - { - for(label i=newSize;i<rows_[rowI].size();++i) - data_[start+i] = FREEENTRY; - rows_[rowI].size() = newSize; - if( newSize == 0 ) - rows_[rowI].start() = INVALIDROW; - } + # ifdef FULLDEBUG + if( (rowI < 0) || (rowI >= rows_.size()) ) + FatalErrorIn + ( + "void Foam::VRWGraph<T,width>::" + "checkIndex(const label rowI, const label size) const" + ) << "Row index " << Foam::label(rowI) + << " is not in range " << Foam::label(0) + << " and " << rows_.size() << abort(FatalError); + # endif + + const label start = rows_[rowI].start(); + if( start == INVALIDROW ) + { + if( newSize > 0 ) + { + rows_[rowI].start() = data_.size(); + for(label i=0;i<newSize;++i) + data_.append(NONE); + rows_[rowI].size() = newSize; + } + } + else if( newSize > rows_[rowI].size() ) + { + //- check if there is some unused space after the last element + bool foundUnused(true); + + for(label i=rows_[rowI].size();i<newSize;++i) + { + const label j = start + i; + if( + (j >= data_.size()) || + (data_[j] != FREEENTRY) || + (data_[j] == FREESTART) + ) + { + foundUnused = false; + break; + } + } + + if( foundUnused ) + { + //- row can be extended without copying + for(label i=rows_[rowI].size();i<newSize;++i) + data_[start+i] = NONE; + } + else + { + //- row is copied at the end of the data list + rows_[rowI].start() = data_.size(); + for(label i=0;i<rows_[rowI].size();++i) + { + data_.append(data_[start+i]); + data_[start+i] = FREEENTRY; + } + for(label i=rows_[rowI].size();i<newSize;++i) + data_.append(NONE); + } + + rows_[rowI].size() = newSize; + } + else if( newSize < rows_[rowI].size() ) + { + for(label i=newSize;i<rows_[rowI].size();++i) + data_[start+i] = FREEENTRY; + rows_[rowI].size() = newSize; + if( newSize == 0 ) + rows_[rowI].start() = INVALIDROW; + } } inline void Foam::VRWGraph::clear() { data_.setSize(0); - rows_.setSize(0); + rows_.setSize(0); } template<class ListType> inline void Foam::VRWGraph::appendList ( - const ListType& l + const ListType& l ) { if( l.size() == 0 ) @@ -297,16 +297,16 @@ inline void Foam::VRWGraph::appendList return; } - rowElement rowInfo(data_.size(), l.size()); - const label size = l.size(); - for(label elI=0;elI<size;++elI) - data_.append(l[elI]); - rows_.append(rowInfo); + rowElement rowInfo(data_.size(), l.size()); + const label size = l.size(); + for(label elI=0;elI<size;++elI) + data_.append(l[elI]); + rows_.append(rowInfo); } inline void Foam::VRWGraph::append(const label rowI, const label el) { - rowElement& re = rows_[rowI]; + rowElement& re = rows_[rowI]; if( re.start() == INVALIDROW ) { @@ -315,11 +315,11 @@ inline void Foam::VRWGraph::append(const label rowI, const label el) data_.append(el); } else - { + { const label oldStart = re.start(); const label oldSize = re.size(); ++re.size(); - + if( oldStart + oldSize < data_.size() ) { if( @@ -349,22 +349,22 @@ inline void Foam::VRWGraph::append(const label rowI, const label el) inline void Foam::VRWGraph::appendIfNotIn(const label rowI, const label el) { - if( !contains(rowI, el) ) - append(rowI, el); + if( !contains(rowI, el) ) + append(rowI, el); } template<class ListType> inline void Foam::VRWGraph::setRow ( - const label rowI, - const ListType& l + const label rowI, + const ListType& l ) { - this->setRowSize(rowI, l.size()); - const label start = rows_[rowI].start(); - const label size = l.size(); - for(label elI=0;elI<size;++elI) - data_[start+elI] = l[elI]; + this->setRowSize(rowI, l.size()); + const label start = rows_[rowI].start(); + const label size = l.size(); + for(label elI=0;elI<size;++elI) + data_[start+elI] = l[elI]; } inline void Foam::VRWGraph::mergeGraphs(const List<VRWGraph>& graphParts) @@ -513,85 +513,85 @@ inline void Foam::VRWGraph::reverseAddressing(const VRWGraph& origGraph) inline bool Foam::VRWGraph::contains ( - const label rowI, + const label rowI, const label e ) const { - const label start = rows_[rowI].start(); - if( start == INVALIDROW ) - return false; - const label size = rows_[rowI].size(); - - for(register label i=0;i<size;++i) - if( data_[start+i] == e ) - return true; - - return false; + const label start = rows_[rowI].start(); + if( start == INVALIDROW ) + return false; + const label size = rows_[rowI].size(); + + for(register label i=0;i<size;++i) + if( data_[start+i] == e ) + return true; + + return false; } inline Foam::label Foam::VRWGraph::containsAtPosition ( - const label rowI, + const label rowI, const label e ) const { - const label start = rows_[rowI].start(); - if( start == INVALIDROW ) - return -1; - - const label size = rows_[rowI].size(); - for(register label i=0;i<size;++i) - if( data_[start+i] == e ) - return i; - - return -1; + const label start = rows_[rowI].start(); + if( start == INVALIDROW ) + return -1; + + const label size = rows_[rowI].size(); + for(register label i=0;i<size;++i) + if( data_[start+i] == e ) + return i; + + return -1; } // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // inline Foam::label Foam::VRWGraph::operator() ( - const label i, - const label j + const label i, + const label j ) const { - #ifdef FULLDEBUG - checkIndex(i, j); - #endif - - return data_[rows_[i].start() + j]; + #ifdef FULLDEBUG + checkIndex(i, j); + #endif + + return data_[rows_[i].start() + j]; } inline Foam::label& Foam::VRWGraph::operator() ( - const label i, const label j + const label i, const label j ) { - #ifdef FULLDEBUG - checkIndex(i, j); - #endif - - return data_[rows_[i].start() + j]; + #ifdef FULLDEBUG + checkIndex(i, j); + #endif + + return data_[rows_[i].start() + j]; } inline Foam::constRow Foam::VRWGraph::operator[](const label i) const { - return constRow(*this, i); + return constRow(*this, i); } inline Foam::row Foam::VRWGraph::operator[](const label i) { - return row(*this, i); + return row(*this, i); } inline void Foam::VRWGraph::operator= ( - const VRWGraph& l + const VRWGraph& l ) { - data_ = l.data_; - rows_ = l.rows_; + data_ = l.data_; + rows_ = l.rows_; } diff --git a/meshLibrary/utilities/containers/VRWGraph/VRWGraphSMPModifier.C b/meshLibrary/utilities/containers/VRWGraph/VRWGraphSMPModifier.C index 199a8a15..183a69f9 100644 --- a/meshLibrary/utilities/containers/VRWGraph/VRWGraphSMPModifier.C +++ b/meshLibrary/utilities/containers/VRWGraph/VRWGraphSMPModifier.C @@ -33,7 +33,7 @@ License namespace Foam { - + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // VRWGraphSMPModifier::VRWGraphSMPModifier(VRWGraph& graph) @@ -43,12 +43,12 @@ VRWGraphSMPModifier::VRWGraphSMPModifier(VRWGraph& graph) VRWGraphSMPModifier::~VRWGraphSMPModifier() {} - + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // void VRWGraphSMPModifier::mergeGraphs(const List<VRWGraph>& graphParts) { - const label nGraphs = graphParts.size(); + const label nGraphs = graphParts.size(); const label nRows = graphParts[0].size(); forAll(graphParts, i) { @@ -196,7 +196,7 @@ void VRWGraphSMPModifier::reverseAddressing(const VRWGraph& origGraph) { const LongList<labelPair>& data = dataForOtherThreads[i][threadI]; - + forAll(data, j) { const label entryI = data[j].first(); @@ -222,7 +222,7 @@ void VRWGraphSMPModifier::reverseAddressing(const VRWGraph& origGraph) { const LongList<labelPair>& data = dataForOtherThreads[i][threadI]; - + forAll(data, j) { const label entryI = data[j].first(); @@ -238,7 +238,7 @@ void VRWGraphSMPModifier::optimizeMemoryUsage() if( graph_.size() < 1000 ) nThreads = 1; - DynList<label> nRows, nEntries; + DynList<label> nRows, nEntries; nRows.setSize(nThreads); nEntries.setSize(nThreads); @@ -314,7 +314,7 @@ void VRWGraphSMPModifier::optimizeMemoryUsage() void VRWGraphSMPModifier::operator=(const VRWGraph& og) { - graph_.data_.setSize(og.data_.size()); + graph_.data_.setSize(og.data_.size()); graph_.rows_.setSize(og.rows_.size()); # pragma omp parallel diff --git a/meshLibrary/utilities/containers/VRWGraph/VRWGraphSMPModifier.H b/meshLibrary/utilities/containers/VRWGraph/VRWGraphSMPModifier.H index cf7d60e9..69672008 100644 --- a/meshLibrary/utilities/containers/VRWGraph/VRWGraphSMPModifier.H +++ b/meshLibrary/utilities/containers/VRWGraph/VRWGraphSMPModifier.H @@ -27,8 +27,8 @@ Class Description This class is a modifier for VRWGraph which allows for multi-threaded - execution of most time-consuimg functions - + execution of most time-consuimg functions + SourceFiles VRWGraphSMPModifier.H VRWGraphSMPModifier.C @@ -65,7 +65,7 @@ class VRWGraphSMPModifier //- Disallow bitwise assignment void operator=(const VRWGraphSMPModifier&); - + public: // Constructor @@ -102,7 +102,7 @@ public: template<class ListType> void reverseAddressing(const ListType&, const VRWGraph&); - + //- optimize memory usage // this should be used once the graph will not be resized any more void optimizeMemoryUsage(); diff --git a/meshLibrary/utilities/containers/VRWGraph/VRWGraphSMPModifierTemplates.C b/meshLibrary/utilities/containers/VRWGraph/VRWGraphSMPModifierTemplates.C index 78fe0aeb..12d4ea03 100644 --- a/meshLibrary/utilities/containers/VRWGraph/VRWGraphSMPModifierTemplates.C +++ b/meshLibrary/utilities/containers/VRWGraph/VRWGraphSMPModifierTemplates.C @@ -39,7 +39,7 @@ namespace Foam template<class ListType> void VRWGraphSMPModifier::setSizeAndRowSize(const ListType& s) { - graph_.rows_.setSize(s.size()); + graph_.rows_.setSize(s.size()); label nThreads = 3 * omp_get_num_procs(); if( s.size() < 1000 ) @@ -193,7 +193,7 @@ void VRWGraphSMPModifier::reverseAddressing(const GraphType& origGraph) { const LongList<labelPair>& data = dataForOtherThreads[i][threadI]; - + forAll(data, j) { const label entryI = data[j].first(); @@ -219,7 +219,7 @@ void VRWGraphSMPModifier::reverseAddressing(const GraphType& origGraph) { const LongList<labelPair>& data = dataForOtherThreads[i][threadI]; - + forAll(data, j) { const label entryI = data[j].first(); @@ -342,7 +342,7 @@ void VRWGraphSMPModifier::reverseAddressing { const LongList<labelPair>& data = dataForOtherThreads[i][threadI]; - + forAll(data, j) { const label entryI = data[j].first(); @@ -368,7 +368,7 @@ void VRWGraphSMPModifier::reverseAddressing { const LongList<labelPair>& data = dataForOtherThreads[i][threadI]; - + forAll(data, j) { const label entryI = data[j].first(); @@ -489,7 +489,7 @@ void VRWGraphSMPModifier::reverseAddressing { const LongList<labelPair>& data = dataForOtherThreads[i][threadI]; - + forAll(data, j) { const label entryI = data[j].first(); @@ -515,7 +515,7 @@ void VRWGraphSMPModifier::reverseAddressing { const LongList<labelPair>& data = dataForOtherThreads[i][threadI]; - + forAll(data, j) { const label entryI = data[j].first(); diff --git a/meshLibrary/utilities/containers/VRWGraphList/VRWGraphList.C b/meshLibrary/utilities/containers/VRWGraphList/VRWGraphList.C index 0f1f8fd1..5359463d 100644 --- a/meshLibrary/utilities/containers/VRWGraphList/VRWGraphList.C +++ b/meshLibrary/utilities/containers/VRWGraphList/VRWGraphList.C @@ -36,14 +36,14 @@ Foam::Ostream& Foam::operator<< const Foam::VRWGraphList& DL ) { - os << DL.size() << nl << token::BEGIN_LIST; - - for(register label i=0;i<DL.size();++i) - { - os << nl << DL[i]; - } - - os << nl << token::END_LIST; + os << DL.size() << nl << token::BEGIN_LIST; + + for(register label i=0;i<DL.size();++i) + { + os << nl << DL[i]; + } + + os << nl << token::END_LIST; return os; } @@ -55,15 +55,15 @@ Foam::Istream& Foam::operator>> Foam::VRWGraphList<T, width>& DL ) { - label size; - T e; - is >> size; - DL.setSize(size); - for(IndexType i=0;i<size;++i) - { - is >> e; - DL[i] = e; - } + label size; + T e; + is >> size; + DL.setSize(size); + for(IndexType i=0;i<size;++i) + { + is >> e; + DL[i] = e; + } return is; } diff --git a/meshLibrary/utilities/containers/VRWGraphList/VRWGraphList.H b/meshLibrary/utilities/containers/VRWGraphList/VRWGraphList.H index 96660cf9..fbe21b45 100644 --- a/meshLibrary/utilities/containers/VRWGraphList/VRWGraphList.H +++ b/meshLibrary/utilities/containers/VRWGraphList/VRWGraphList.H @@ -27,7 +27,7 @@ Class Description This class is an implementation of a list of graphs - with variable column width. The implementation is memory efficient. + with variable column width. The implementation is memory efficient. SourceFiles VRWGraphListI.H @@ -52,23 +52,23 @@ namespace Foam class VRWGraphList { - + // Private data - //- graph containing the data - VRWGraph data_; - - //- number of rows - LongList<rowElement> rows_; - - // Private member functions - //- check index - inline void checkIndex - ( - const label i, - const label j, - const label k - ) const; - + //- graph containing the data + VRWGraph data_; + + //- number of rows + LongList<rowElement> rows_; + + // Private member functions + //- check index + inline void checkIndex + ( + const label i, + const label j, + const label k + ) const; + public: // Constructors @@ -77,11 +77,11 @@ public: inline VRWGraphList(); //- Copy contructor - inline VRWGraphList(const VRWGraphList&); + inline VRWGraphList(const VRWGraphList&); - // Destructor + // Destructor - inline ~VRWGraphList(); + inline ~VRWGraphList(); // Member Functions @@ -89,12 +89,12 @@ public: //- Returns the number of graphs inline label size() const; - - //- Returns the number of rows in the graph at that position - inline label sizeOfGraph(const label posI) const; - - //- Return the number of element in the row at the given position - inline label sizeOfRow(const label posI, const label rowI) const; + + //- Returns the number of rows in the graph at that position + inline label sizeOfGraph(const label posI) const; + + //- Return the number of element in the row at the given position + inline label sizeOfRow(const label posI, const label rowI) const; //- Clear the graph inline void clear(); @@ -102,23 +102,23 @@ public: // Member Operators //- Append a graph at the end of the graphList - template<class GraphType> + template<class GraphType> inline void appendGraph(const GraphType& l); - - //- get and set operators - inline label operator() - ( - const label i, - const label j, - const label k - ) const; - - inline label& operator()(const label i, const label j, const label k); - - inline const subGraph<const VRWGraph> operator[](const label i) const; - - //- Assignment operator - inline void operator=(const VRWGraphList&); + + //- get and set operators + inline label operator() + ( + const label i, + const label j, + const label k + ) const; + + inline label& operator()(const label i, const label j, const label k); + + inline const subGraph<const VRWGraph> operator[](const label i) const; + + //- Assignment operator + inline void operator=(const VRWGraphList&); // IOstream operators diff --git a/meshLibrary/utilities/containers/VRWGraphList/VRWGraphListI.H b/meshLibrary/utilities/containers/VRWGraphList/VRWGraphListI.H index 78afff17..c8d1daab 100644 --- a/meshLibrary/utilities/containers/VRWGraphList/VRWGraphListI.H +++ b/meshLibrary/utilities/containers/VRWGraphList/VRWGraphListI.H @@ -26,45 +26,45 @@ License namespace Foam { - + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // inline void Foam::VRWGraphList::checkIndex ( - const label i, - const label j, - const label k + const label i, + const label j, + const label k ) const { - if( (i < 0) || (i >= rows_.size()) ) - { - FatalErrorIn - ( - "void Foam::VRWGraphList<T,width>::" - "checkIndex(const label i, const label j, const label k) const" - ) << "Position index " << Foam::label(i) - << " is not in range " << Foam::label(0) - << " and " << rows_.size() << abort(FatalError); - } - - if( (j < 0) || (j >= rows_[i].size()) ) - FatalErrorIn - ( - "void Foam::VRWGraphList<T,width>::" - "checkIndex(label const i, const label j, const label k) const" - ) << "Row index " << Foam::label(j) - << " is not in range " << Foam::label(0) - << " and " << rows_[i].size() << abort(FatalError); - - if( (k < 0) || (k >= data_.sizeOfRow(rows_[i].start()+j)) ) - FatalErrorIn - ( - "void Foam::VRWGraphList<T,width>::" - "checkIndex(label const i, const label j, const label k) const" - ) << "Data index " << Foam::label(k) - << " is not in range " << Foam::label(0) - << " and " << data_.sizeOfRow(rows_[i].start()+j) - << abort(FatalError); + if( (i < 0) || (i >= rows_.size()) ) + { + FatalErrorIn + ( + "void Foam::VRWGraphList<T,width>::" + "checkIndex(const label i, const label j, const label k) const" + ) << "Position index " << Foam::label(i) + << " is not in range " << Foam::label(0) + << " and " << rows_.size() << abort(FatalError); + } + + if( (j < 0) || (j >= rows_[i].size()) ) + FatalErrorIn + ( + "void Foam::VRWGraphList<T,width>::" + "checkIndex(label const i, const label j, const label k) const" + ) << "Row index " << Foam::label(j) + << " is not in range " << Foam::label(0) + << " and " << rows_[i].size() << abort(FatalError); + + if( (k < 0) || (k >= data_.sizeOfRow(rows_[i].start()+j)) ) + FatalErrorIn + ( + "void Foam::VRWGraphList<T,width>::" + "checkIndex(label const i, const label j, const label k) const" + ) << "Data index " << Foam::label(k) + << " is not in range " << Foam::label(0) + << " and " << data_.sizeOfRow(rows_[i].start()+j) + << abort(FatalError); } // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // @@ -72,18 +72,18 @@ inline void Foam::VRWGraphList::checkIndex //- Construct null inline Foam::VRWGraphList::VRWGraphList() : - data_(), - rows_() + data_(), + rows_() { } inline Foam::VRWGraphList::VRWGraphList ( - const VRWGraphList& ol + const VRWGraphList& ol ) : - data_(ol.data_), - rows_(ol.rows_) + data_(ol.data_), + rows_(ol.rows_) { } @@ -101,79 +101,79 @@ inline Foam::label Foam::VRWGraphList::size() const inline Foam::label Foam::VRWGraphList::sizeOfGraph(const label posI) const { - return rows_[posI].size(); + return rows_[posI].size(); } inline Foam::label Foam::VRWGraphList::sizeOfRow ( - const label posI, - const label rowI + const label posI, + const label rowI ) const { - return data_.sizeOfRow(rows_[posI].start()+rowI); + return data_.sizeOfRow(rows_[posI].start()+rowI); } inline void Foam::VRWGraphList::clear() { data_.setSize(0); - rows_.setSize(0); + rows_.setSize(0); } template<class GraphType> inline void Foam::VRWGraphList::appendGraph ( - const GraphType& l + const GraphType& l ) { - rowElement re(data_.size(), l.size()); - - for(label i=0;i<l.size();++i) - data_.appendList(l[i]); - - rows_.append(re); + rowElement re(data_.size(), l.size()); + + for(label i=0;i<l.size();++i) + data_.appendList(l[i]); + + rows_.append(re); } // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // inline Foam::label Foam::VRWGraphList::operator() ( - const label i, - const label j, - const label k + const label i, + const label j, + const label k ) const { - #ifdef FULLDEBUG - checkIndex(i, j, k); - #endif - - return data_(rows_[i].start() + j, k); + #ifdef FULLDEBUG + checkIndex(i, j, k); + #endif + + return data_(rows_[i].start() + j, k); } inline Foam::label& Foam::VRWGraphList::operator() ( - const label i, const label j, const label k + const label i, const label j, const label k ) { - #ifdef FULLDEBUG - checkIndex(i, j, k); - #endif - - return data_(rows_[i].start() + j, k); + #ifdef FULLDEBUG + checkIndex(i, j, k); + #endif + + return data_(rows_[i].start() + j, k); } inline const Foam::subGraph<const VRWGraph> Foam::VRWGraphList::operator[] ( - const label i + const label i ) const { - return Foam::subGraph<const VRWGraph>(data_, i, rows_[i].size()); + return Foam::subGraph<const VRWGraph>(data_, i, rows_[i].size()); } inline void Foam::VRWGraphList::operator=(const VRWGraphList& l) { - data_ = l.data_; - rows_ = l.rows_; + data_ = l.data_; + rows_ = l.rows_; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/meshLibrary/utilities/containers/graphRow/graphRow.H b/meshLibrary/utilities/containers/graphRow/graphRow.H index 64e771c7..150b3aac 100644 --- a/meshLibrary/utilities/containers/graphRow/graphRow.H +++ b/meshLibrary/utilities/containers/graphRow/graphRow.H @@ -44,7 +44,7 @@ SourceFiles namespace Foam { - + class VRWGraph; template<class graphType> class graphRow; @@ -59,16 +59,16 @@ template<class graphType> class graphRow { // Private data - //- reference to the graph - graphType& data_; - - //- row number - const label rowI_; - - // Private member functions - //- check index - inline void checkIndex(const label i) const; - + //- reference to the graph + graphType& data_; + + //- row number + const label rowI_; + + // Private member functions + //- check index + inline void checkIndex(const label i) const; + public: // Constructors @@ -77,52 +77,52 @@ public: inline graphRow(graphType&, const label); //- Copy contructor - inline graphRow(const graphRow<graphType>&); + inline graphRow(const graphRow<graphType>&); - // Destructor + // Destructor - inline ~graphRow(); + inline ~graphRow(); // Member Functions - //- Returns the number of rows - inline label size() const; + //- Returns the number of rows + inline label size() const; - //- Reset the number of rows - inline void setSize(const label size); + //- Reset the number of rows + inline void setSize(const label size); - //- Clear the graph - inline void clear(); + //- Clear the graph + inline void clear(); // Member Operators - - //- Append an element to the given row - inline void append(const label); - - //- Append an element to the given row if it does not exist there - inline void appendIfNotIn(const label); - - //- check if the element is in the given row (takes linear time) - inline bool contains(const label e) const; - inline label containsAtPosition(const label e) const; - - //- set and get operators - inline label operator[](const label) const; - inline label& operator[](const label); - - //- Assignment operator - inline void operator=(const graphRow<graphType>&); - template<class listType> - inline void operator=(const listType&); + + //- Append an element to the given row + inline void append(const label); + + //- Append an element to the given row if it does not exist there + inline void appendIfNotIn(const label); + + //- check if the element is in the given row (takes linear time) + inline bool contains(const label e) const; + inline label containsAtPosition(const label e) const; + + //- set and get operators + inline label operator[](const label) const; + inline label& operator[](const label); + + //- Assignment operator + inline void operator=(const graphRow<graphType>&); + template<class listType> + inline void operator=(const listType&); // IOstream operators // Write graphRow to Ostream. friend Ostream& operator<< <graphType> - ( - Ostream&, - const graphRow<graphType>& - ); + ( + Ostream&, + const graphRow<graphType>& + ); //- Read from Istream, discarding contents of existing graphRow. /* friend Istream& operator>> <T, width> diff --git a/meshLibrary/utilities/containers/graphRow/graphRowI.H b/meshLibrary/utilities/containers/graphRow/graphRowI.H index ce43d9d6..9e037ed7 100644 --- a/meshLibrary/utilities/containers/graphRow/graphRowI.H +++ b/meshLibrary/utilities/containers/graphRow/graphRowI.H @@ -30,16 +30,16 @@ namespace Foam template<class graphType> inline void Foam::graphRow<graphType>::checkIndex(const label i) const { - if( (i < 0) || (i >=data_.sizeOfRow(rowI_)) ) - { - FatalErrorIn - ( - "void Foam::graphRow<graphType>::" - "checkIndex(const label i) const" - ) << "Row index " << rowI_ - << " is not in range " << Foam::label(0) - << " and " << data_.sizeOfRow(rowI_) << abort(FatalError); - } + if( (i < 0) || (i >=data_.sizeOfRow(rowI_)) ) + { + FatalErrorIn + ( + "void Foam::graphRow<graphType>::" + "checkIndex(const label i) const" + ) << "Row index " << rowI_ + << " is not in range " << Foam::label(0) + << " and " << data_.sizeOfRow(rowI_) << abort(FatalError); + } } // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // @@ -47,19 +47,19 @@ inline void Foam::graphRow<graphType>::checkIndex(const label i) const template<class graphType> inline Foam::graphRow<graphType>::graphRow(graphType& g, const label i) : - data_(g), - rowI_(i) + data_(g), + rowI_(i) { } template<class graphType> inline Foam::graphRow<graphType>::graphRow ( - const graphRow<graphType>& ol + const graphRow<graphType>& ol ) : - data_(ol.data_), - rowI_(ol.rowI_) + data_(ol.data_), + rowI_(ol.rowI_) { } @@ -80,31 +80,31 @@ inline Foam::label Foam::graphRow<graphType>::size() const template<class graphType> inline void Foam::graphRow<graphType>::setSize(const label s) { - data_.setRowSize(rowI_, s); + data_.setRowSize(rowI_, s); } template<class graphType> inline void Foam::graphRow<graphType>::clear() { - data_.setRowSize(rowI_, 0); + data_.setRowSize(rowI_, 0); } template<class graphType> inline void Foam::graphRow<graphType>::append(const label el) { - data_.append(rowI_, el); + data_.append(rowI_, el); } template<class graphType> inline void Foam::graphRow<graphType>::appendIfNotIn(const label el) { - data_.appendIfNotIn(rowI_, el); + data_.appendIfNotIn(rowI_, el); } template<class graphType> inline bool Foam::graphRow<graphType>::contains(const label e) const { - return data_.contains(rowI_, e); + return data_.contains(rowI_, e); } template<class graphType> @@ -113,7 +113,7 @@ inline Foam::label Foam::graphRow<graphType>::containsAtPosition const label e ) const { - return data_.containsAtPosition(rowI_, e); + return data_.containsAtPosition(rowI_, e); } // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // @@ -121,48 +121,48 @@ inline Foam::label Foam::graphRow<graphType>::containsAtPosition template<class graphType> inline Foam::label Foam::graphRow<graphType>::operator[](const label i) const { - return data_(rowI_, i); + return data_(rowI_, i); } template<class graphType> inline Foam::label& Foam::graphRow<graphType>::operator[](const label i) { - return data_(rowI_, i); + return data_(rowI_, i); } template<class graphType> inline void Foam::graphRow<graphType>::operator= ( - const graphRow<graphType>& l + const graphRow<graphType>& l ) { - data_.setRowSize(rowI_, l.size()); - for(label i=0;i<l.size();++i) - data_(rowI_, i) = l[i]; + data_.setRowSize(rowI_, l.size()); + for(label i=0;i<l.size();++i) + data_(rowI_, i) = l[i]; } template<class graphType> template<class listType> inline void Foam::graphRow<graphType>::operator=(const listType& l) { - data_.setRowSize(rowI_, l.size()); - for(label i=0;i<l.size();++i) - data_(rowI_, i) = l[i]; + data_.setRowSize(rowI_, l.size()); + for(label i=0;i<l.size();++i) + data_(rowI_, i) = l[i]; } template<class graphType> inline Foam::Ostream& operator<< ( - Foam::Ostream& os, - const Foam::graphRow<graphType>& r + Foam::Ostream& os, + const Foam::graphRow<graphType>& r ) { - os << r.size() << "("; - for(Foam::label i=0;i<r.size();++i) - os << r[i] << " "; - os << ")"; - - return os; + os << r.size() << "("; + for(Foam::label i=0;i<r.size();++i) + os << r[i] << " "; + os << ")"; + + return os; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/meshLibrary/utilities/containers/subGraph/subGraph.H b/meshLibrary/utilities/containers/subGraph/subGraph.H index 5e825864..254b5257 100644 --- a/meshLibrary/utilities/containers/subGraph/subGraph.H +++ b/meshLibrary/utilities/containers/subGraph/subGraph.H @@ -58,19 +58,19 @@ template<class graphType> class subGraph { // Private data - //- reference to the graph - graphType& data_; - - //- starts at row - const label start_; - - //- number of rows in the subGraph - const label size_; - - // Private member functions - //- check index - inline void checkIndex(const label i) const; - + //- reference to the graph + graphType& data_; + + //- starts at row + const label start_; + + //- number of rows in the subGraph + const label size_; + + // Private member functions + //- check index + inline void checkIndex(const label i) const; + public: // Constructors @@ -79,46 +79,46 @@ public: inline subGraph(graphType&, const label, const label); //- Copy contructor - inline subGraph(const subGraph<graphType>&); + inline subGraph(const subGraph<graphType>&); - // Destructor + // Destructor - inline ~subGraph(); + inline ~subGraph(); // Member Functions - //- Returns the number of rows - inline label size() const; + //- Returns the number of rows + inline label size() const; - //- Returns the size of a given row - inline label sizeOfRow(const label rowI) const; + //- Returns the size of a given row + inline label sizeOfRow(const label rowI) const; // Member Operators - - //- Append an element to the given row - inline void append(const label rowI, const label); - - //- Append an element to the given row if it does not exist there - inline void appendIfNotIn(const label rowI, const label); - - //- check if the element is in the given row (takes linear time) - inline bool contains(const label rowI, const label e) const; - inline label containsAtPosition(const label rowI, const label e) const; - - //- set and get operators - inline label operator()(const label i, const label j) const; - inline label& operator()(const label i, const label j); - inline const graphRow<const graphType> operator[](const label) const; - inline graphRow<graphType> operator[](const label); + + //- Append an element to the given row + inline void append(const label rowI, const label); + + //- Append an element to the given row if it does not exist there + inline void appendIfNotIn(const label rowI, const label); + + //- check if the element is in the given row (takes linear time) + inline bool contains(const label rowI, const label e) const; + inline label containsAtPosition(const label rowI, const label e) const; + + //- set and get operators + inline label operator()(const label i, const label j) const; + inline label& operator()(const label i, const label j); + inline const graphRow<const graphType> operator[](const label) const; + inline graphRow<graphType> operator[](const label); // IOstream operators // Write subGraph to Ostream. friend Ostream& operator<< <graphType> - ( - Ostream&, - const subGraph<graphType>& - ); + ( + Ostream&, + const subGraph<graphType>& + ); }; // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/meshLibrary/utilities/containers/subGraph/subGraphI.H b/meshLibrary/utilities/containers/subGraph/subGraphI.H index cc18f877..877f0954 100644 --- a/meshLibrary/utilities/containers/subGraph/subGraphI.H +++ b/meshLibrary/utilities/containers/subGraph/subGraphI.H @@ -30,16 +30,16 @@ namespace Foam template<class graphType> inline void Foam::subGraph<graphType>::checkIndex(const label i) const { - if( (i < 0) || (i >= size_) ) - { - FatalErrorIn - ( - "void Foam::subGraph<graphType>::" - "checkIndex(const label i) const" - ) << "Row index " << i - << " is not in range " << Foam::label(0) - << " and " << size_ << abort(FatalError); - } + if( (i < 0) || (i >= size_) ) + { + FatalErrorIn + ( + "void Foam::subGraph<graphType>::" + "checkIndex(const label i) const" + ) << "Row index " << i + << " is not in range " << Foam::label(0) + << " and " << size_ << abort(FatalError); + } } // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // @@ -47,26 +47,26 @@ inline void Foam::subGraph<graphType>::checkIndex(const label i) const template<class graphType> inline Foam::subGraph<graphType>::subGraph ( - graphType& g, - const label start, - const label size + graphType& g, + const label start, + const label size ) : - data_(g), - start_(start), - size_(size) + data_(g), + start_(start), + size_(size) { } template<class graphType> inline Foam::subGraph<graphType>::subGraph ( - const subGraph<graphType>& ol + const subGraph<graphType>& ol ) : - data_(ol.data_), - start_(ol.start_), - size_(ol.size_) + data_(ol.data_), + start_(ol.start_), + size_(ol.size_) { } @@ -87,43 +87,43 @@ inline Foam::label Foam::subGraph<graphType>::size() const template<class graphType> inline Foam::label Foam::subGraph<graphType>::sizeOfRow(const label rowI) const { - return data_.sizeOfRow(start_+rowI); + return data_.sizeOfRow(start_+rowI); } template<class graphType> inline void Foam::subGraph<graphType>::append(const label rowI, const label el) { - data_.append(start_+rowI, el); + data_.append(start_+rowI, el); } template<class graphType> inline void Foam::subGraph<graphType>::appendIfNotIn ( - const label rowI, - const label el + const label rowI, + const label el ) { - data_.appendIfNotIn(start_+rowI, el); + data_.appendIfNotIn(start_+rowI, el); } template<class graphType> inline bool Foam::subGraph<graphType>::contains ( - const label rowI, - const label e + const label rowI, + const label e ) const { - return data_.contains(start_+rowI, e); + return data_.contains(start_+rowI, e); } template<class graphType> inline Foam::label Foam::subGraph<graphType>::containsAtPosition ( - const label rowI, + const label rowI, const label e ) const { - return data_.containsAtPosition(start_+rowI, e); + return data_.containsAtPosition(start_+rowI, e); } // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // @@ -131,25 +131,25 @@ inline Foam::label Foam::subGraph<graphType>::containsAtPosition template<class graphType> inline Foam::label Foam::subGraph<graphType>::operator() ( - const label i, - const label j + const label i, + const label j ) const { - # ifdef FULLDEBUG - checkIndex(i); - # endif - - return data_(start_+i, j); + # ifdef FULLDEBUG + checkIndex(i); + # endif + + return data_(start_+i, j); } template<class graphType> inline Foam::label& Foam::subGraph<graphType>::operator() ( - const label i, - const label j + const label i, + const label j ) { - return data_(start_+i, j); + return data_(start_+i, j); } @@ -157,43 +157,43 @@ template<class graphType> inline const Foam::graphRow<const graphType> Foam::subGraph<graphType>::operator[] ( - const label i + const label i ) const { - return data_[start_+i]; + return data_[start_+i]; } template<class graphType> inline Foam::graphRow<graphType> Foam::subGraph<graphType>::operator[](const label i) { - return data_[start_+i]; + return data_[start_+i]; } template<class graphType> inline Foam::Ostream& operator<< ( - Foam::Ostream& os, - const Foam::subGraph<graphType>& sg + Foam::Ostream& os, + const Foam::subGraph<graphType>& sg ) { - os << sg.size() << "\n" << "("; - for(Foam::label i=0;i<sg.size();++i) - { - os << "\n" << sg.sizeOfRow(i) << "("; - for(Foam::label j=0;j<sg.sizeOfRow(i);++j) - { - if( j > 0 ) os << " "; - - os << sg(i, j); - } - - os << ")"; - } - - os << "\n" << ")"; - - return os; + os << sg.size() << "\n" << "("; + for(Foam::label i=0;i<sg.size();++i) + { + os << "\n" << sg.sizeOfRow(i) << "("; + for(Foam::label j=0;j<sg.sizeOfRow(i);++j) + { + if( j > 0 ) os << " "; + + os << sg(i, j); + } + + os << ")"; + } + + os << "\n" << ")"; + + return os; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/meshLibrary/utilities/dataConversion/foamToEnsight/ensightMesh.C b/meshLibrary/utilities/dataConversion/foamToEnsight/ensightMesh.C index 860cc81b..a33f4d28 100644 --- a/meshLibrary/utilities/dataConversion/foamToEnsight/ensightMesh.C +++ b/meshLibrary/utilities/dataConversion/foamToEnsight/ensightMesh.C @@ -69,38 +69,38 @@ void ensightMesh::writePolys OFstream& ensightGeometryFile ) const { - ensightGeometryFile << "nfaced" << nl << setw(10) << cellFaces.size() << nl; - - forAll(cellFaces, cI) - { - ensightGeometryFile << setw(10) << cellFaces[cI].size() << nl; - } - - forAll(cellFaces, cI) - { - const labelList& cf = cellFaces[cI]; - - forAll(cf, faceI) - { - ensightGeometryFile << setw(10) << faces[cf[faceI]].size() << nl; - } - } - - forAll(cellFaces, cI) - { - const labelList& cf = cellFaces[cI]; + ensightGeometryFile << "nfaced" << nl << setw(10) << cellFaces.size() << nl; + + forAll(cellFaces, cI) + { + ensightGeometryFile << setw(10) << cellFaces[cI].size() << nl; + } + + forAll(cellFaces, cI) + { + const labelList& cf = cellFaces[cI]; + + forAll(cf, faceI) + { + ensightGeometryFile << setw(10) << faces[cf[faceI]].size() << nl; + } + } + + forAll(cellFaces, cI) + { + const labelList& cf = cellFaces[cI]; - forAll(cf, faceI) - { - const face& f = faces[cf[faceI]]; - - forAll(f, pointI) - { - ensightGeometryFile << setw(10) << f[pointI] + 1; - } - ensightGeometryFile << nl; - } - } + forAll(cf, faceI) + { + const face& f = faces[cf[faceI]]; + + forAll(f, pointI) + { + ensightGeometryFile << setw(10) << f[pointI] + 1; + } + ensightGeometryFile << nl; + } + } } void Foam::ensightMesh::writeFaces @@ -111,14 +111,14 @@ void Foam::ensightMesh::writeFaces { if (patchFaces.size()) { - ensightGeometryFile - << "nsided" << nl << setw(10) << patchFaces.size() << nl; + ensightGeometryFile + << "nsided" << nl << setw(10) << patchFaces.size() << nl; - forAll(patchFaces, i) - { - ensightGeometryFile - << setw(10) << patchFaces[i].size() << nl; - } + forAll(patchFaces, i) + { + ensightGeometryFile + << setw(10) << patchFaces[i].size() << nl; + } forAll(patchFaces, i) { @@ -135,41 +135,41 @@ void Foam::ensightMesh::writeFaces void Foam::ensightMesh::writePatches ( - Foam::OFstream& ensightGeometryFile + Foam::OFstream& ensightGeometryFile ) const { - const faceListPMG& faces = mesh_.faces(); - const PtrList<writePatch>& boundaries = mesh_.boundaries(); - + const faceListPMG& faces = mesh_.faces(); + const PtrList<writePatch>& boundaries = mesh_.boundaries(); + forAll(boundaries, patchI) { - ensightGeometryFile - << "part" << nl - << setw(10) << patchI + 2 << nl - << boundaries[patchI].patchName() << nl - << "coordinates" << nl - << setw(10) << mesh_.points().size() - << endl; - - for (direction d=0; d<vector::nComponents; d++) - { - writePoints - ( - mesh_.points().component(d), - ensightGeometryFile - ); - } - - faceList patchFaces(boundaries[patchI].patchSize()); - const label start = boundaries[patchI].patchStart(); - forAll(patchFaces, faceI) - patchFaces[faceI] = faces[start+faceI]; - - writeFaces - ( - patchFaces, - ensightGeometryFile - ); + ensightGeometryFile + << "part" << nl + << setw(10) << patchI + 2 << nl + << boundaries[patchI].patchName() << nl + << "coordinates" << nl + << setw(10) << mesh_.points().size() + << endl; + + for (direction d=0; d<vector::nComponents; d++) + { + writePoints + ( + mesh_.points().component(d), + ensightGeometryFile + ); + } + + faceList patchFaces(boundaries[patchI].patchSize()); + const label start = boundaries[patchI].patchStart(); + forAll(patchFaces, faceI) + patchFaces[faceI] = faces[start+faceI]; + + writeFaces + ( + patchFaces, + ensightGeometryFile + ); } } @@ -183,41 +183,41 @@ void ensightMesh::write const cellListPMG& cellFaces = mesh_.cells(); const faceListPMG& faces = mesh_.faces(); - // Set Format - ensightGeometryFile.setf - ( - ios_base::scientific, - ios_base::floatfield - ); - ensightGeometryFile.precision(5); - - ensightGeometryFile - << "FOAM Geometry File " << nl << nl - << "node id assign" << nl - << "element id assign" << nl; - - ensightGeometryFile - << "part" << nl - << setw(10) << 1 << nl - << "FOAM cells" << nl - << "coordinates" << nl - << setw(10) << points.size() - << endl; - - for (direction d=0; d<vector::nComponents; d++) - { + // Set Format + ensightGeometryFile.setf + ( + ios_base::scientific, + ios_base::floatfield + ); + ensightGeometryFile.precision(5); + + ensightGeometryFile + << "FOAM Geometry File " << nl << nl + << "node id assign" << nl + << "element id assign" << nl; + + ensightGeometryFile + << "part" << nl + << setw(10) << 1 << nl + << "FOAM cells" << nl + << "coordinates" << nl + << setw(10) << points.size() + << endl; + + for (direction d=0; d<vector::nComponents; d++) + { scalarField comp = points.component(d)(); - writePoints(comp, ensightGeometryFile); - } + writePoints(comp, ensightGeometryFile); + } - writePolys - ( - cellFaces, - faces, - ensightGeometryFile - ); + writePolys + ( + cellFaces, + faces, + ensightGeometryFile + ); - writePatches(ensightGeometryFile); + writePatches(ensightGeometryFile); } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/meshLibrary/utilities/dataConversion/foamToEnsight/ensightMesh.H b/meshLibrary/utilities/dataConversion/foamToEnsight/ensightMesh.H index bc080e04..5aec297f 100644 --- a/meshLibrary/utilities/dataConversion/foamToEnsight/ensightMesh.H +++ b/meshLibrary/utilities/dataConversion/foamToEnsight/ensightMesh.H @@ -72,17 +72,17 @@ class ensightMesh const faceListPMG& faces, OFstream& ensightGeometryFile ) const; - - void writeFaces - ( - const faceList& patchFaces, - OFstream& ensightGeometryFile - ) const; - - void writePatches - ( - OFstream& ensightGeometryFile - ) const; + + void writeFaces + ( + const faceList& patchFaces, + OFstream& ensightGeometryFile + ) const; + + void writePatches + ( + OFstream& ensightGeometryFile + ) const; public: diff --git a/meshLibrary/utilities/dataConversion/foamToEnsight/writeMeshEnsight.C b/meshLibrary/utilities/dataConversion/foamToEnsight/writeMeshEnsight.C index a6400cde..c4110c10 100644 --- a/meshLibrary/utilities/dataConversion/foamToEnsight/writeMeshEnsight.C +++ b/meshLibrary/utilities/dataConversion/foamToEnsight/writeMeshEnsight.C @@ -44,51 +44,51 @@ namespace Foam void writeMeshEnsight(const polyMeshGen& mesh, const word& fName) { - const Time& time = mesh.returnTime(); - + const Time& time = mesh.returnTime(); + const word postProcDir = "EnSight"+fName; - const word prepend = fName + '.'; - Info << "Writting mesh into " << postProcDir << endl; + const word prepend = fName + '.'; + Info << "Writting mesh into " << postProcDir << endl; fileName postProcPath = time.path()/postProcDir; - if( Foam::isDir(postProcPath) ) - { - Foam::rmDir(postProcPath); - } + if( Foam::isDir(postProcPath) ) + { + Foam::rmDir(postProcPath); + } - Foam::mkDir(postProcPath); + Foam::mkDir(postProcPath); - // Open the Case file - fileName ensightCaseFileName = prepend + "case"; + // Open the Case file + fileName ensightCaseFileName = prepend + "case"; -/* OFstream ensightCaseFile - ( - postProcPath/ensightCaseFileName, - IOstream::ASCII, - IOstream::currentVersion, - IOstream::UNCOMPRESSED - ); +/* OFstream ensightCaseFile + ( + postProcPath/ensightCaseFileName, + IOstream::ASCII, + IOstream::currentVersion, + IOstream::UNCOMPRESSED + ); */ - OFstream ensightCaseFile(postProcPath/ensightCaseFileName); + OFstream ensightCaseFile(postProcPath/ensightCaseFileName); - Info<< nl << "Case file is " << ensightCaseFileName << endl; + Info<< nl << "Case file is " << ensightCaseFileName << endl; -/* OFstream ensightGeometryFile - ( - postProcPath/prepend+"000.mesh", - IOstream::ASCII, - IOstream::currentVersion, - IOstream::UNCOMPRESSED - ); +/* OFstream ensightGeometryFile + ( + postProcPath/prepend+"000.mesh", + IOstream::ASCII, + IOstream::currentVersion, + IOstream::UNCOMPRESSED + ); */ - OFstream ensightGeometryFile(postProcPath/prepend+"000.mesh"); - + OFstream ensightGeometryFile(postProcPath/prepend+"000.mesh"); + // Construct the EnSight mesh ensightMesh eMesh(mesh); - eMesh.write(ensightGeometryFile); + eMesh.write(ensightGeometryFile); - //- write the case file + //- write the case file ensightCaseFile << "FORMAT" << nl; ensightCaseFile << "type: ensight gold" << nl << nl; @@ -101,7 +101,7 @@ void writeMeshEnsight(const polyMeshGen& mesh, const word& fName) << "model: 1 " << (geomCaseFileName + ".mesh").c_str() << nl; } - + ensightCaseFile << nl << "TIME" << nl << "time set: " << 1 << nl << "number of steps: " << 1 << nl diff --git a/meshLibrary/utilities/dataConversion/foamToFLMA/flmaMesh.C b/meshLibrary/utilities/dataConversion/foamToFLMA/flmaMesh.C index 024b23e9..f7a0cb91 100644 --- a/meshLibrary/utilities/dataConversion/foamToFLMA/flmaMesh.C +++ b/meshLibrary/utilities/dataConversion/foamToFLMA/flmaMesh.C @@ -129,20 +129,20 @@ void Foam::flmaMesh::writePoints Foam::OFstream& flmaGeometryFile ) const { - flmaGeometryFile << (mesh_.points().size()+additionalPoints_.size()) << nl; - const pointFieldPMG& points = mesh_.points(); - forAll(points, pointI) - { - const point& p = points[pointI]; - flmaGeometryFile << p.x() << ' ' << p.y() << ' ' << p.z() << ' '; - } + flmaGeometryFile << (mesh_.points().size()+additionalPoints_.size()) << nl; + const pointFieldPMG& points = mesh_.points(); + forAll(points, pointI) + { + const point& p = points[pointI]; + flmaGeometryFile << p.x() << ' ' << p.y() << ' ' << p.z() << ' '; + } forAll(additionalPoints_, pointI) { const point& p = additionalPoints_[pointI]; flmaGeometryFile << p.x() << ' ' << p.y() << ' ' << p.z() << ' '; - } - - flmaGeometryFile << nl; + } + + flmaGeometryFile << nl; } void flmaMesh::writeCells @@ -152,13 +152,13 @@ void flmaMesh::writeCells { const labelList& owner = mesh_.owner(); const faceListPMG& faces = mesh_.faces(); - const cellListPMG& cells = mesh_.cells(); - tetMatcher tet; + const cellListPMG& cells = mesh_.cells(); + tetMatcher tet; pyrMatcher pyr; hexMatcher hex; prismMatcher prism; - flmaGeometryFile << cells.size() << nl; + flmaGeometryFile << cells.size() << nl; forAll(cells, cellI) { @@ -210,11 +210,11 @@ void Foam::flmaMesh::writeCellTypes void Foam::flmaMesh::writeSelections ( - Foam::OFstream& flmaGeometryFile + Foam::OFstream& flmaGeometryFile ) const { //- write patches as face selections - const PtrList<writePatch>& patches = mesh_.boundaries(); + const PtrList<writePatch>& patches = mesh_.boundaries(); const faceListPMG& faces = mesh_.faces(); const labelList& owner = mesh_.owner(); const cellListPMG& cells = mesh_.cells(); @@ -238,7 +238,7 @@ void Foam::flmaMesh::writeSelections nSubsets += indices.size(); Info << "Mesh has " << indices.size() << " cell subsets" << endl; - flmaGeometryFile << nSubsets << nl; + flmaGeometryFile << nSubsets << nl; //- write patches as face selections forAll(patches, patchI) @@ -439,13 +439,13 @@ void flmaMesh::write OFstream& flmaGeometryFile ) const { - writePoints(flmaGeometryFile); + writePoints(flmaGeometryFile); - writeCells(flmaGeometryFile); + writeCells(flmaGeometryFile); writeCellTypes(flmaGeometryFile); - writeSelections(flmaGeometryFile); + writeSelections(flmaGeometryFile); } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/meshLibrary/utilities/dataConversion/foamToFLMA/flmaMesh.H b/meshLibrary/utilities/dataConversion/foamToFLMA/flmaMesh.H index 85db08c4..6d6a119b 100644 --- a/meshLibrary/utilities/dataConversion/foamToFLMA/flmaMesh.H +++ b/meshLibrary/utilities/dataConversion/foamToFLMA/flmaMesh.H @@ -83,21 +83,21 @@ class flmaMesh ( OFstream& flmaGeometryFile ) const; - - void writeCellTypes - ( - OFstream& flmaGeometryFile - ) const; + + void writeCellTypes + ( + OFstream& flmaGeometryFile + ) const; void writeCells ( OFstream& flmaGeometryFile ) const; - - void writeSelections - ( - OFstream& flmaGeometryFile - ) const; + + void writeSelections + ( + OFstream& flmaGeometryFile + ) const; public: diff --git a/meshLibrary/utilities/dataConversion/foamToFLMA/writeMeshFLMA.C b/meshLibrary/utilities/dataConversion/foamToFLMA/writeMeshFLMA.C index 5ec66cdf..946cb87e 100644 --- a/meshLibrary/utilities/dataConversion/foamToFLMA/writeMeshFLMA.C +++ b/meshLibrary/utilities/dataConversion/foamToFLMA/writeMeshFLMA.C @@ -44,27 +44,27 @@ namespace Foam void writeMeshFLMA(const polyMeshGen& mesh, const word& fName) { - const Time& time = mesh.returnTime(); - + const Time& time = mesh.returnTime(); + const word postProcDir = "FLMA"; fileName postProcPath = time.path()/postProcDir; - if( !Foam::isDir(postProcPath) ) - { - mkDir(postProcPath); - } + if( !Foam::isDir(postProcPath) ) + { + mkDir(postProcPath); + } - // Open the flma file - const fileName flmaFileName = fName + ".flma"; - - Info << "Writting mesh into " << flmaFileName << endl; + // Open the flma file + const fileName flmaFileName = fName + ".flma"; + + Info << "Writting mesh into " << flmaFileName << endl; - OFstream flmaGeometryFile(postProcPath/flmaFileName); - + OFstream flmaGeometryFile(postProcPath/flmaFileName); + // Construct the flma mesh flmaMesh Mesh(mesh); - Mesh.write(flmaGeometryFile); + Mesh.write(flmaGeometryFile); } } diff --git a/meshLibrary/utilities/dataConversion/foamToFLMA/writeMeshFLMA.H b/meshLibrary/utilities/dataConversion/foamToFLMA/writeMeshFLMA.H index 3b8cd2a9..36041141 100644 --- a/meshLibrary/utilities/dataConversion/foamToFLMA/writeMeshFLMA.H +++ b/meshLibrary/utilities/dataConversion/foamToFLMA/writeMeshFLMA.H @@ -26,7 +26,7 @@ Class writeMeshFLMA Description - Write mesh into flma format + Write mesh into flma format SourceFiles writeMeshFLMA.C diff --git a/meshLibrary/utilities/dataConversion/foamToFPMA/fpmaMesh.C b/meshLibrary/utilities/dataConversion/foamToFPMA/fpmaMesh.C index 9d4b58bc..a1f2282b 100644 --- a/meshLibrary/utilities/dataConversion/foamToFPMA/fpmaMesh.C +++ b/meshLibrary/utilities/dataConversion/foamToFPMA/fpmaMesh.C @@ -51,52 +51,52 @@ Foam::fpmaMesh::~fpmaMesh() void Foam::fpmaMesh::writePoints(Foam::OFstream& fpmaGeometryFile) const { - fpmaGeometryFile << mesh_.points().size() << nl; - const pointFieldPMG& points = mesh_.points(); - forAll(points, pointI) - { - const point& p = points[pointI]; - fpmaGeometryFile << p.x() << ' ' << p.y() << ' ' << p.z() << ' '; - } - - fpmaGeometryFile << nl; + fpmaGeometryFile << mesh_.points().size() << nl; + const pointFieldPMG& points = mesh_.points(); + forAll(points, pointI) + { + const point& p = points[pointI]; + fpmaGeometryFile << p.x() << ' ' << p.y() << ' ' << p.z() << ' '; + } + + fpmaGeometryFile << nl; } void fpmaMesh::writeCells(OFstream& fpmaGeometryFile) const { - const cellListPMG& cells = mesh_.cells(); - - fpmaGeometryFile << cells.size() << nl; - forAll(cells, cellI) - { - const cell& c = cells[cellI]; - - fpmaGeometryFile << c.size(); - forAll(c, fI) - fpmaGeometryFile << ' ' << c[fI]; - fpmaGeometryFile << nl; - } + const cellListPMG& cells = mesh_.cells(); + + fpmaGeometryFile << cells.size() << nl; + forAll(cells, cellI) + { + const cell& c = cells[cellI]; + + fpmaGeometryFile << c.size(); + forAll(c, fI) + fpmaGeometryFile << ' ' << c[fI]; + fpmaGeometryFile << nl; + } } void Foam::fpmaMesh::writeFaces(OFstream& fpmaGeometryFile) const { - const faceListPMG& faces = mesh_.faces(); - fpmaGeometryFile << faces.size() << nl; - forAll(faces, faceI) - { - const face& f = faces[faceI]; - - fpmaGeometryFile << f.size(); - forAllReverse(f, pI) - fpmaGeometryFile << ' ' << f[pI]; - fpmaGeometryFile << nl; - } + const faceListPMG& faces = mesh_.faces(); + fpmaGeometryFile << faces.size() << nl; + forAll(faces, faceI) + { + const face& f = faces[faceI]; + + fpmaGeometryFile << f.size(); + forAllReverse(f, pI) + fpmaGeometryFile << ' ' << f[pI]; + fpmaGeometryFile << nl; + } } void Foam::fpmaMesh::writeSubsets(Foam::OFstream& fpmaGeometryFile) const { //- write patches as face selections - const PtrList<writePatch>& patches = mesh_.boundaries(); + const PtrList<writePatch>& patches = mesh_.boundaries(); label nSubsets(0); @@ -112,7 +112,7 @@ void Foam::fpmaMesh::writeSubsets(Foam::OFstream& fpmaGeometryFile) const nSubsets += indices.size(); Info << "Mesh has " << indices.size() << " cell subsets" << endl; - fpmaGeometryFile << nSubsets << nl; + fpmaGeometryFile << nSubsets << nl; //- write patches as face selections forAll(patches, patchI) @@ -177,13 +177,13 @@ void Foam::fpmaMesh::writeSubsets(Foam::OFstream& fpmaGeometryFile) const void fpmaMesh::write(OFstream& fpmaGeometryFile) const { - writePoints(fpmaGeometryFile); - - writeFaces(fpmaGeometryFile); + writePoints(fpmaGeometryFile); + + writeFaces(fpmaGeometryFile); - writeCells(fpmaGeometryFile); + writeCells(fpmaGeometryFile); - writeSubsets(fpmaGeometryFile); + writeSubsets(fpmaGeometryFile); } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/meshLibrary/utilities/dataConversion/foamToFPMA/fpmaMesh.H b/meshLibrary/utilities/dataConversion/foamToFPMA/fpmaMesh.H index 517dd7a0..01845e6f 100644 --- a/meshLibrary/utilities/dataConversion/foamToFPMA/fpmaMesh.H +++ b/meshLibrary/utilities/dataConversion/foamToFPMA/fpmaMesh.H @@ -61,12 +61,12 @@ class fpmaMesh void operator=(const fpmaMesh&); void writePoints(OFstream& fpmaGeometryFile) const; - - void writeFaces(OFstream& fpmaGeometryFile) const; + + void writeFaces(OFstream& fpmaGeometryFile) const; void writeCells(OFstream& fpmaGeometryFile) const; - - void writeSubsets(OFstream& fpmaGeometryFile) const; + + void writeSubsets(OFstream& fpmaGeometryFile) const; public: diff --git a/meshLibrary/utilities/dataConversion/foamToFPMA/writeMeshFPMA.C b/meshLibrary/utilities/dataConversion/foamToFPMA/writeMeshFPMA.C index 92c8cd73..c6add14b 100644 --- a/meshLibrary/utilities/dataConversion/foamToFPMA/writeMeshFPMA.C +++ b/meshLibrary/utilities/dataConversion/foamToFPMA/writeMeshFPMA.C @@ -46,36 +46,36 @@ namespace Foam void writeMeshFPMA(const polyMeshGen& mesh, const word& fName) { - const Time& time = mesh.returnTime(); - + const Time& time = mesh.returnTime(); + const word postProcDir = "FPMA"; fileName postProcPath = time.path()/postProcDir; - if( !Foam::isDir(postProcPath) ) - { - mkDir(postProcPath); - } - - // Open the Case file - const fileName fpmaFileName = fName + ".fpma"; - - Info << "Writting mesh into " << fpmaFileName << endl; - -/* OFstream fpmaGeometryFile - ( - postProcPath/fpmaFileName, - IOstream::ASCII, - IOstream::currentVersion, - IOstream::UNCOMPRESSED - ); + if( !Foam::isDir(postProcPath) ) + { + mkDir(postProcPath); + } + + // Open the Case file + const fileName fpmaFileName = fName + ".fpma"; + + Info << "Writting mesh into " << fpmaFileName << endl; + +/* OFstream fpmaGeometryFile + ( + postProcPath/fpmaFileName, + IOstream::ASCII, + IOstream::currentVersion, + IOstream::UNCOMPRESSED + ); */ - OFstream fpmaGeometryFile(postProcPath/fpmaFileName); - + OFstream fpmaGeometryFile(postProcPath/fpmaFileName); + // Construct the EnSight mesh fpmaMesh Mesh(mesh); - Mesh.write(fpmaGeometryFile); + Mesh.write(fpmaGeometryFile); } void createFIRESelections(polyMeshGen& mesh) diff --git a/meshLibrary/utilities/dataConversion/foamToFPMA/writeMeshFPMA.H b/meshLibrary/utilities/dataConversion/foamToFPMA/writeMeshFPMA.H index f22ed000..4681bdea 100644 --- a/meshLibrary/utilities/dataConversion/foamToFPMA/writeMeshFPMA.H +++ b/meshLibrary/utilities/dataConversion/foamToFPMA/writeMeshFPMA.H @@ -26,7 +26,7 @@ Class writeMeshFPMA Description - Write mesh into fpma format + Write mesh into fpma format SourceFiles writeMeshFPMA.C diff --git a/meshLibrary/utilities/dataConversion/octreeToEnsight/octreeMesh.C b/meshLibrary/utilities/dataConversion/octreeToEnsight/octreeMesh.C index 230ae7d3..324b9f7c 100644 --- a/meshLibrary/utilities/dataConversion/octreeToEnsight/octreeMesh.C +++ b/meshLibrary/utilities/dataConversion/octreeToEnsight/octreeMesh.C @@ -38,32 +38,32 @@ namespace Foam // Construct from meshOctree Foam::octreeMesh::octreeMesh(const meshOctree& octree) : - points_(3*octree.numberOfLeaves()), - boxes_(octree.numberOfLeaves()), - useBox_(octree.numberOfLeaves(), true), + points_(3*octree.numberOfLeaves()), + boxes_(octree.numberOfLeaves()), + useBox_(octree.numberOfLeaves(), true), octree_(octree) { - createPointsAndCells(); + createPointsAndCells(); } // Construct from meshOctree and cube type Foam::octreeMesh::octreeMesh ( - const meshOctree& octree, - const direction cubeType + const meshOctree& octree, + const direction cubeType ) : - points_(3*octree.numberOfLeaves()), - boxes_(octree.numberOfLeaves()), - useBox_(octree.numberOfLeaves(), false), + points_(3*octree.numberOfLeaves()), + boxes_(octree.numberOfLeaves()), + useBox_(octree.numberOfLeaves(), false), octree_(octree) { - label i, nLeaves = octree.numberOfLeaves(); - for(i=0;i<nLeaves;++i) - if( octree_.returnLeaf(i).cubeType() & cubeType ) - useBox_[i] = true; - - createPointsAndCells(); + label i, nLeaves = octree.numberOfLeaves(); + for(i=0;i<nLeaves;++i) + if( octree_.returnLeaf(i).cubeType() & cubeType ) + useBox_[i] = true; + + createPointsAndCells(); } @@ -77,78 +77,78 @@ Foam::octreeMesh::~octreeMesh() void octreeMesh::createPointsAndCells() { - label boxI, nLeaves = octree_.numberOfLeaves(); - - const cellModel& hex = *cellModeller::lookup("hex"); - const boundBox& rootBox = octree_.rootBox(); - Info << "Root box for writting octree " << rootBox << endl; - - label pointI(0), boxJ(0); - - for(boxI=0;boxI<nLeaves;++boxI) - if( useBox_[boxI] ) - { - labelList cv(8); - - const meshOctreeCubeBasic& c = octree_.returnLeaf(boxI); - FixedList<point, 8> vrt; - c.vertices(rootBox, vrt); - - forAll(vrt, vI) - { - points_.newElmt(pointI) = vrt[vI]; - switch( vI ) - { - case 0: - { - cv[4] = pointI; - break; - } - case 1: - { - cv[5] = pointI; - break; - } - case 2: - { - cv[0] = pointI; - break; - } - case 3: - { - cv[1] = pointI; - break; - } - case 4: - { - cv[7] = pointI; - break; - } - case 5: - { - cv[6] = pointI; - break; - } - case 6: - { - cv[3] = pointI; - break; - } - case 7: - { - cv[2] = pointI; - break; - } - }; - - ++pointI; - } - - boxes_[boxJ++] = cellShape(hex, cv); - } - - points_.setSize(pointI); - boxes_.setSize(boxJ); + label boxI, nLeaves = octree_.numberOfLeaves(); + + const cellModel& hex = *cellModeller::lookup("hex"); + const boundBox& rootBox = octree_.rootBox(); + Info << "Root box for writting octree " << rootBox << endl; + + label pointI(0), boxJ(0); + + for(boxI=0;boxI<nLeaves;++boxI) + if( useBox_[boxI] ) + { + labelList cv(8); + + const meshOctreeCubeBasic& c = octree_.returnLeaf(boxI); + FixedList<point, 8> vrt; + c.vertices(rootBox, vrt); + + forAll(vrt, vI) + { + points_.newElmt(pointI) = vrt[vI]; + switch( vI ) + { + case 0: + { + cv[4] = pointI; + break; + } + case 1: + { + cv[5] = pointI; + break; + } + case 2: + { + cv[0] = pointI; + break; + } + case 3: + { + cv[1] = pointI; + break; + } + case 4: + { + cv[7] = pointI; + break; + } + case 5: + { + cv[6] = pointI; + break; + } + case 6: + { + cv[3] = pointI; + break; + } + case 7: + { + cv[2] = pointI; + break; + } + }; + + ++pointI; + } + + boxes_[boxJ++] = cellShape(hex, cv); + } + + points_.setSize(pointI); + boxes_.setSize(boxJ); } void Foam::octreeMesh::writePoints @@ -168,17 +168,17 @@ void Foam::octreeMesh::writeBoxes OFstream& ensightGeometryFile ) const { - ensightGeometryFile << "hexa8" << nl << setw(10) << boxes_.size() << nl; - - forAll(boxes_, boxI) - { - const cellShape& box = boxes_[boxI]; - - forAll(box, pI) - ensightGeometryFile << setw(10) << box[pI] + 1; - + ensightGeometryFile << "hexa8" << nl << setw(10) << boxes_.size() << nl; + + forAll(boxes_, boxI) + { + const cellShape& box = boxes_[boxI]; + + forAll(box, pI) + ensightGeometryFile << setw(10) << box[pI] + 1; + ensightGeometryFile << nl; - } + } } @@ -187,36 +187,36 @@ void octreeMesh::write OFstream& ensightGeometryFile ) const { - // Set Format - ensightGeometryFile.setf - ( - ios_base::scientific, - ios_base::floatfield - ); - ensightGeometryFile.precision(5); - - ensightGeometryFile - << "FOAM Geometry File " << nl << nl - << "node id assign" << nl - << "element id assign" << nl; - - ensightGeometryFile - << "part" << nl - << setw(10) << 1 << nl - << "FOAM cells" << nl - << "coordinates" << nl - << setw(10) << points_.size() - << endl; - - for (direction d=0; d<vector::nComponents; d++) - { - writePoints(points_.component(d)(), ensightGeometryFile); - } - - writeBoxes - ( - ensightGeometryFile - ); + // Set Format + ensightGeometryFile.setf + ( + ios_base::scientific, + ios_base::floatfield + ); + ensightGeometryFile.precision(5); + + ensightGeometryFile + << "FOAM Geometry File " << nl << nl + << "node id assign" << nl + << "element id assign" << nl; + + ensightGeometryFile + << "part" << nl + << setw(10) << 1 << nl + << "FOAM cells" << nl + << "coordinates" << nl + << setw(10) << points_.size() + << endl; + + for (direction d=0; d<vector::nComponents; d++) + { + writePoints(points_.component(d)(), ensightGeometryFile); + } + + writeBoxes + ( + ensightGeometryFile + ); } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/meshLibrary/utilities/dataConversion/octreeToEnsight/octreeMesh.H b/meshLibrary/utilities/dataConversion/octreeToEnsight/octreeMesh.H index f9ce6a9d..c506b0cf 100644 --- a/meshLibrary/utilities/dataConversion/octreeToEnsight/octreeMesh.H +++ b/meshLibrary/utilities/dataConversion/octreeToEnsight/octreeMesh.H @@ -52,12 +52,12 @@ namespace Foam class octreeMesh { // Private data - //- points - pointField points_; + //- points + pointField points_; - cellShapeList boxes_; - - boolList useBox_; + cellShapeList boxes_; + + boolList useBox_; // Private Member Functions @@ -77,8 +77,8 @@ class octreeMesh ( OFstream& ensightGeometryFile ) const; - - void createPointsAndCells(); + + void createPointsAndCells(); public: // Public data @@ -90,8 +90,8 @@ public: //- Construct from meshOctree octreeMesh(const meshOctree& octree); - //- Construct from meshOctree and cube type - octreeMesh(const meshOctree& octree, const direction cubeType); + //- Construct from meshOctree and cube type + octreeMesh(const meshOctree& octree, const direction cubeType); // Destructor diff --git a/meshLibrary/utilities/dataConversion/octreeToEnsight/writeOctreeEnsight.C b/meshLibrary/utilities/dataConversion/octreeToEnsight/writeOctreeEnsight.C index 54055f4a..b3d144e2 100644 --- a/meshLibrary/utilities/dataConversion/octreeToEnsight/writeOctreeEnsight.C +++ b/meshLibrary/utilities/dataConversion/octreeToEnsight/writeOctreeEnsight.C @@ -46,58 +46,58 @@ namespace Foam void writeOctreeEnsight(const meshOctree& octree, const word& fName) { const word postProcDir = "EnSight"+fName; - const word prepend = fName + '.'; - Serr << "Writting mesh into " << postProcDir << endl; + const word prepend = fName + '.'; + Serr << "Writting mesh into " << postProcDir << endl; fileName postProcPath; - if( Pstream::parRun() ) - { - std::ostringstream ss; - ss << Pstream::myProcNo(); - postProcPath = "processor"+ss.str()/postProcDir; - } - else - { - postProcPath = postProcDir; - } - - if( Foam::isDir(postProcPath) ) - { - rmDir(postProcPath); - } - - mkDir(postProcPath); - - // Open the Case file - fileName ensightCaseFileName = prepend + "case"; - -/* OFstream ensightCaseFile - ( - postProcPath/ensightCaseFileName, - IOstream::ASCII, - IOstream::currentVersion, - IOstream::UNCOMPRESSED - ); + if( Pstream::parRun() ) + { + std::ostringstream ss; + ss << Pstream::myProcNo(); + postProcPath = "processor"+ss.str()/postProcDir; + } + else + { + postProcPath = postProcDir; + } + + if( Foam::isDir(postProcPath) ) + { + rmDir(postProcPath); + } + + mkDir(postProcPath); + + // Open the Case file + fileName ensightCaseFileName = prepend + "case"; + +/* OFstream ensightCaseFile + ( + postProcPath/ensightCaseFileName, + IOstream::ASCII, + IOstream::currentVersion, + IOstream::UNCOMPRESSED + ); */ - OFstream ensightCaseFile(postProcPath/ensightCaseFileName); - - Serr<< nl << "Case file is " << ensightCaseFileName << endl; - -/* OFstream ensightGeometryFile - ( - postProcPath/prepend+"000.mesh", - IOstream::ASCII, - IOstream::currentVersion, - IOstream::UNCOMPRESSED - ); + OFstream ensightCaseFile(postProcPath/ensightCaseFileName); + + Serr<< nl << "Case file is " << ensightCaseFileName << endl; + +/* OFstream ensightGeometryFile + ( + postProcPath/prepend+"000.mesh", + IOstream::ASCII, + IOstream::currentVersion, + IOstream::UNCOMPRESSED + ); */ - OFstream ensightGeometryFile(postProcPath/prepend+"000.mesh"); - + OFstream ensightGeometryFile(postProcPath/prepend+"000.mesh"); + // Construct the EnSight mesh octreeMesh eMesh(octree); - eMesh.write(ensightGeometryFile); + eMesh.write(ensightGeometryFile); - //- write the case file + //- write the case file ensightCaseFile << "FORMAT" << nl; ensightCaseFile << "type: ensight gold" << nl << nl; @@ -108,7 +108,7 @@ void writeOctreeEnsight(const meshOctree& octree, const word& fName) << "GEOMETRY" << nl << "model: 1 " << (geomCaseFileName + ".mesh").c_str() << nl; - + ensightCaseFile << nl << "TIME" << nl << "time set: " << 1 << nl << "number of steps: " << 1 << nl @@ -123,56 +123,56 @@ void writeOctreeEnsight(const meshOctree& octree, const word& fName) void writeOctreeEnsight ( - const meshOctree& octree, - const word& fName, - const direction cubeType + const meshOctree& octree, + const word& fName, + const direction cubeType ) { - //const Time& time = mesh.returnRegistry().time(); - + //const Time& time = mesh.returnRegistry().time(); + const word postProcDir = "EnSight"+fName; - const word prepend = fName + '.'; - Info << "Writting mesh into " << postProcDir << endl; + const word prepend = fName + '.'; + Info << "Writting mesh into " << postProcDir << endl; fileName postProcPath = postProcDir; - if( Foam::isDir(postProcPath)) - { - rmDir(postProcPath); - } - - mkDir(postProcPath); - - // Open the Case file - fileName ensightCaseFileName = prepend + "case"; - -/* OFstream ensightCaseFile - ( - postProcPath/ensightCaseFileName, - IOstream::ASCII, - IOstream::currentVersion, - IOstream::UNCOMPRESSED - ); -*/ - OFstream ensightCaseFile(postProcPath/ensightCaseFileName); - - Info<< nl << "Case file is " << ensightCaseFileName << endl; - -/* OFstream ensightGeometryFile - ( - postProcPath/prepend+"000.mesh", - IOstream::ASCII, - IOstream::currentVersion, - IOstream::UNCOMPRESSED - ); + if( Foam::isDir(postProcPath)) + { + rmDir(postProcPath); + } + + mkDir(postProcPath); + + // Open the Case file + fileName ensightCaseFileName = prepend + "case"; + +/* OFstream ensightCaseFile + ( + postProcPath/ensightCaseFileName, + IOstream::ASCII, + IOstream::currentVersion, + IOstream::UNCOMPRESSED + ); +*/ + OFstream ensightCaseFile(postProcPath/ensightCaseFileName); + + Info<< nl << "Case file is " << ensightCaseFileName << endl; + +/* OFstream ensightGeometryFile + ( + postProcPath/prepend+"000.mesh", + IOstream::ASCII, + IOstream::currentVersion, + IOstream::UNCOMPRESSED + ); */ - OFstream ensightGeometryFile(postProcPath/prepend+"000.mesh"); - + OFstream ensightGeometryFile(postProcPath/prepend+"000.mesh"); + // Construct the EnSight mesh octreeMesh eMesh(octree, cubeType); - eMesh.write(ensightGeometryFile); + eMesh.write(ensightGeometryFile); - //- write the case file + //- write the case file ensightCaseFile << "FORMAT" << nl; ensightCaseFile << "type: ensight gold" << nl << nl; @@ -185,7 +185,7 @@ void writeOctreeEnsight << "model: 1 " << (geomCaseFileName + ".mesh").c_str() << nl; } - + ensightCaseFile << nl << "TIME" << nl << "time set: " << 1 << nl << "number of steps: " << 1 << nl diff --git a/meshLibrary/utilities/dataConversion/octreeToEnsight/writeOctreeEnsight.H b/meshLibrary/utilities/dataConversion/octreeToEnsight/writeOctreeEnsight.H index 432e3b21..eecebcc4 100644 --- a/meshLibrary/utilities/dataConversion/octreeToEnsight/writeOctreeEnsight.H +++ b/meshLibrary/utilities/dataConversion/octreeToEnsight/writeOctreeEnsight.H @@ -47,15 +47,15 @@ class meshOctree; void writeOctreeEnsight ( - const meshOctree& octree, - const word& fName + const meshOctree& octree, + const word& fName ); void writeOctreeEnsight ( - const meshOctree& octree, - const word& fName, - const direction cubeType + const meshOctree& octree, + const word& fName, + const direction cubeType ); // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/meshLibrary/utilities/dataConversion/octreeToFPMA/octreeMeshFPMA.C b/meshLibrary/utilities/dataConversion/octreeToFPMA/octreeMeshFPMA.C index 19c9efde..46b6953d 100644 --- a/meshLibrary/utilities/dataConversion/octreeToFPMA/octreeMeshFPMA.C +++ b/meshLibrary/utilities/dataConversion/octreeToFPMA/octreeMeshFPMA.C @@ -41,7 +41,7 @@ Foam::octreeMeshFPMA::octreeMeshFPMA const dictionary& dict ) : - addressing_(octree, dict, false) + addressing_(octree, dict, false) { addressing_.boxType(); for(label leafI=0;leafI<octree.numberOfLeaves();++leafI) @@ -62,15 +62,15 @@ void Foam::octreeMeshFPMA::writePoints ) const { const pointField& points = addressing_.octreePoints(); - fpmaGeometryFile << points.size() << nl; - - forAll(points, pointI) - { - const point& p = points[pointI]; - fpmaGeometryFile << p.x() << ' ' << p.y() << ' ' << p.z() << ' '; - } - - fpmaGeometryFile << nl; + fpmaGeometryFile << points.size() << nl; + + forAll(points, pointI) + { + const point& p = points[pointI]; + fpmaGeometryFile << p.x() << ' ' << p.y() << ' ' << p.z() << ' '; + } + + fpmaGeometryFile << nl; } void octreeMeshFPMA::writeCells @@ -78,16 +78,16 @@ void octreeMeshFPMA::writeCells OFstream& fpmaGeometryFile ) const { - const VRWGraph& cells = addressing_.leafFaces(); - - fpmaGeometryFile << cells.size() << nl; - forAll(cells, cellI) - { - fpmaGeometryFile << cells.sizeOfRow(cellI); - forAllRow(cells, cellI, fI) - fpmaGeometryFile << ' ' << cells(cellI, fI); - fpmaGeometryFile << nl; - } + const VRWGraph& cells = addressing_.leafFaces(); + + fpmaGeometryFile << cells.size() << nl; + forAll(cells, cellI) + { + fpmaGeometryFile << cells.sizeOfRow(cellI); + forAllRow(cells, cellI, fI) + fpmaGeometryFile << ' ' << cells(cellI, fI); + fpmaGeometryFile << nl; + } } void Foam::octreeMeshFPMA::writeFaces @@ -95,25 +95,25 @@ void Foam::octreeMeshFPMA::writeFaces OFstream& fpmaGeometryFile ) const { - const VRWGraph& faces = addressing_.octreeFaces(); - fpmaGeometryFile << faces.size() << nl; - forAll(faces, faceI) - { - const constRow f = faces[faceI]; - - fpmaGeometryFile << f.size(); - forAllReverse(f, pI) - fpmaGeometryFile << ' ' << f[pI]; - fpmaGeometryFile << nl; - } + const VRWGraph& faces = addressing_.octreeFaces(); + fpmaGeometryFile << faces.size() << nl; + forAll(faces, faceI) + { + const constRow f = faces[faceI]; + + fpmaGeometryFile << f.size(); + forAllReverse(f, pI) + fpmaGeometryFile << ' ' << f[pI]; + fpmaGeometryFile << nl; + } } void Foam::octreeMeshFPMA::writeSelections ( - Foam::OFstream& fpmaGeometryFile + Foam::OFstream& fpmaGeometryFile ) const { - fpmaGeometryFile << 4 << nl; + fpmaGeometryFile << 4 << nl; //- create outside selection fpmaGeometryFile << "Outside" << nl << 2 << nl; labelListPMG selBoxes; @@ -176,13 +176,13 @@ void octreeMeshFPMA::write OFstream& fpmaGeometryFile ) const { - writePoints(fpmaGeometryFile); - - writeFaces(fpmaGeometryFile); + writePoints(fpmaGeometryFile); + + writeFaces(fpmaGeometryFile); - writeCells(fpmaGeometryFile); + writeCells(fpmaGeometryFile); - writeSelections(fpmaGeometryFile); + writeSelections(fpmaGeometryFile); } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/meshLibrary/utilities/dataConversion/octreeToFPMA/octreeMeshFPMA.H b/meshLibrary/utilities/dataConversion/octreeToFPMA/octreeMeshFPMA.H index 93b22b71..c6cef57c 100644 --- a/meshLibrary/utilities/dataConversion/octreeToFPMA/octreeMeshFPMA.H +++ b/meshLibrary/utilities/dataConversion/octreeToFPMA/octreeMeshFPMA.H @@ -52,7 +52,7 @@ namespace Foam class octreeMeshFPMA { // Private data - //- octree addressing + //- octree addressing meshOctreeAddressing addressing_; // Private Member Functions @@ -67,21 +67,21 @@ class octreeMeshFPMA ( OFstream& fpmaGeometryFile ) const; - - void writeFaces - ( - OFstream& fpmaGeometryFile - ) const; + + void writeFaces + ( + OFstream& fpmaGeometryFile + ) const; void writeCells ( OFstream& fpmaGeometryFile ) const; - - void writeSelections - ( - OFstream& fpmaGeometryFile - ) const; + + void writeSelections + ( + OFstream& fpmaGeometryFile + ) const; public: diff --git a/meshLibrary/utilities/dataConversion/octreeToFPMA/writeOctreeFPMA.C b/meshLibrary/utilities/dataConversion/octreeToFPMA/writeOctreeFPMA.C index 154200fd..cb17c3e9 100644 --- a/meshLibrary/utilities/dataConversion/octreeToFPMA/writeOctreeFPMA.C +++ b/meshLibrary/utilities/dataConversion/octreeToFPMA/writeOctreeFPMA.C @@ -48,36 +48,36 @@ void writeOctreeFPMA(const meshOctree& octree, const word& fName) const word postProcDir = "FPMA"; const word prepend = fName + '.'; - Serr << "Writting mesh into " << postProcDir << endl; + Serr << "Writting mesh into " << postProcDir << endl; fileName postProcPath; - if( Pstream::parRun() ) - { - std::ostringstream ss; - ss << Pstream::myProcNo(); - postProcPath = "processor"+ss.str()/postProcDir; - } - else - { - postProcPath = postProcDir; - } - - if( !Foam::isDir(postProcPath) ) - { - mkDir(postProcPath); - } - - // Open the Case file - const fileName fpmaFileName = fName + ".fpma"; - - Info << "Writting octree into " << fpmaFileName << endl; - - OFstream fpmaGeometryFile(postProcPath/fpmaFileName); - + if( Pstream::parRun() ) + { + std::ostringstream ss; + ss << Pstream::myProcNo(); + postProcPath = "processor"+ss.str()/postProcDir; + } + else + { + postProcPath = postProcDir; + } + + if( !Foam::isDir(postProcPath) ) + { + mkDir(postProcPath); + } + + // Open the Case file + const fileName fpmaFileName = fName + ".fpma"; + + Info << "Writting octree into " << fpmaFileName << endl; + + OFstream fpmaGeometryFile(postProcPath/fpmaFileName); + // Construct the octree mesh dictionary dict; octreeMeshFPMA Mesh(octree, dict); - Mesh.write(fpmaGeometryFile); + Mesh.write(fpmaGeometryFile); } } diff --git a/meshLibrary/utilities/dataConversion/octreeToFPMA/writeOctreeFPMA.H b/meshLibrary/utilities/dataConversion/octreeToFPMA/writeOctreeFPMA.H index 1f42f828..c9bebbf8 100644 --- a/meshLibrary/utilities/dataConversion/octreeToFPMA/writeOctreeFPMA.H +++ b/meshLibrary/utilities/dataConversion/octreeToFPMA/writeOctreeFPMA.H @@ -47,8 +47,8 @@ class meshOctree; void writeOctreeFPMA ( - const meshOctree& octree, - const word& fName + const meshOctree& octree, + const word& fName ); // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/meshLibrary/utilities/dataConversion/simplexToFLMA/simplexMesh.C b/meshLibrary/utilities/dataConversion/simplexToFLMA/simplexMesh.C index 81f2af94..a9f4e7f1 100644 --- a/meshLibrary/utilities/dataConversion/simplexToFLMA/simplexMesh.C +++ b/meshLibrary/utilities/dataConversion/simplexToFLMA/simplexMesh.C @@ -34,22 +34,22 @@ namespace Foam void Foam::simplexMesh::writePoints(Foam::OFstream& flmaGeometryFile) const { - flmaGeometryFile << mesh_.pts().size() << nl; - const DynList<point, 128>& points = mesh_.pts(); - forAll(points, pointI) - { - const point& p = points[pointI]; - flmaGeometryFile << p.x() << ' ' << p.y() << ' ' << p.z() << ' '; - } - - flmaGeometryFile << nl; + flmaGeometryFile << mesh_.pts().size() << nl; + const DynList<point, 128>& points = mesh_.pts(); + forAll(points, pointI) + { + const point& p = points[pointI]; + flmaGeometryFile << p.x() << ' ' << p.y() << ' ' << p.z() << ' '; + } + + flmaGeometryFile << nl; } void simplexMesh::writeCells(OFstream& flmaGeometryFile) const { const DynList<partTet, 128>& tets = mesh_.tets(); - flmaGeometryFile << tets.size() << nl; + flmaGeometryFile << tets.size() << nl; forAll(tets, tetI) { @@ -72,7 +72,7 @@ void Foam::simplexMesh::writeCellTypes(OFstream& flmaGeometryFile) const void Foam::simplexMesh::writeSelections(Foam::OFstream& flmaGeometryFile) const { - flmaGeometryFile << 0; + flmaGeometryFile << 0; } // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // @@ -97,13 +97,13 @@ void simplexMesh::write OFstream& flmaGeometryFile ) const { - writePoints(flmaGeometryFile); + writePoints(flmaGeometryFile); - writeCells(flmaGeometryFile); + writeCells(flmaGeometryFile); writeCellTypes(flmaGeometryFile); - writeSelections(flmaGeometryFile); + writeSelections(flmaGeometryFile); } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/meshLibrary/utilities/dataConversion/simplexToFLMA/simplexMesh.H b/meshLibrary/utilities/dataConversion/simplexToFLMA/simplexMesh.H index 4341a75d..bb139a53 100644 --- a/meshLibrary/utilities/dataConversion/simplexToFLMA/simplexMesh.H +++ b/meshLibrary/utilities/dataConversion/simplexToFLMA/simplexMesh.H @@ -67,21 +67,21 @@ class simplexMesh ( OFstream& flmaGeometryFile ) const; - - void writeCellTypes - ( - OFstream& flmaGeometryFile - ) const; + + void writeCellTypes + ( + OFstream& flmaGeometryFile + ) const; void writeCells ( OFstream& flmaGeometryFile ) const; - - void writeSelections - ( - OFstream& flmaGeometryFile - ) const; + + void writeSelections + ( + OFstream& flmaGeometryFile + ) const; public: diff --git a/meshLibrary/utilities/dataConversion/simplexToFLMA/writeSimplexFLMA.C b/meshLibrary/utilities/dataConversion/simplexToFLMA/writeSimplexFLMA.C index 8c72c657..a40afcf1 100644 --- a/meshLibrary/utilities/dataConversion/simplexToFLMA/writeSimplexFLMA.C +++ b/meshLibrary/utilities/dataConversion/simplexToFLMA/writeSimplexFLMA.C @@ -48,21 +48,21 @@ void writeSimplexFLMA(const partTetMeshSimplex& simplex, const word& fName) fileName postProcPath = postProcDir; - if( !Foam::isDir(postProcPath) ) - { - mkDir(postProcPath); - } - - // Open the flma file - const fileName flmaFileName = fName + ".flma"; - - Info << "Writting mesh into " << flmaFileName << endl; - - OFstream flmaGeometryFile(postProcPath/flmaFileName); - + if( !Foam::isDir(postProcPath) ) + { + mkDir(postProcPath); + } + + // Open the flma file + const fileName flmaFileName = fName + ".flma"; + + Info << "Writting mesh into " << flmaFileName << endl; + + OFstream flmaGeometryFile(postProcPath/flmaFileName); + // Construct the flma mesh simplexMesh Mesh(simplex); - Mesh.write(flmaGeometryFile); + Mesh.write(flmaGeometryFile); } } diff --git a/meshLibrary/utilities/dataConversion/simplexToFLMA/writeSimplexFLMA.H b/meshLibrary/utilities/dataConversion/simplexToFLMA/writeSimplexFLMA.H index 2413ad47..8edf976f 100644 --- a/meshLibrary/utilities/dataConversion/simplexToFLMA/writeSimplexFLMA.H +++ b/meshLibrary/utilities/dataConversion/simplexToFLMA/writeSimplexFLMA.H @@ -26,7 +26,7 @@ Class writeSimplexFLMA Description - Write a partTetMeshSimplex into flma format + Write a partTetMeshSimplex into flma format SourceFiles writeSimplexFLMA.C diff --git a/meshLibrary/utilities/decomposeCells/decomposeCells.H b/meshLibrary/utilities/decomposeCells/decomposeCells.H index d63d1a46..96e1da7a 100644 --- a/meshLibrary/utilities/decomposeCells/decomposeCells.H +++ b/meshLibrary/utilities/decomposeCells/decomposeCells.H @@ -50,17 +50,17 @@ namespace Foam class decomposeCells { // private data - //- reference to the mesh - polyMeshGen& mesh_; - - //- new boundary faces - wordList patchNames_; - VRWGraph newBoundaryFaces_; - labelListPMG newBoundaryPatches_; - - VRWGraphList facesOfNewCells_; - - // Private member functions + //- reference to the mesh + polyMeshGen& mesh_; + + //- new boundary faces + wordList patchNames_; + VRWGraph newBoundaryFaces_; + labelListPMG newBoundaryPatches_; + + VRWGraphList facesOfNewCells_; + + // Private member functions //- check if the valid pyramids are generated from the split cells //- this check splits faces which could @@ -68,33 +68,33 @@ class decomposeCells void checkFaceConnections(const boolList& decomposeCell); //- create addressing needed to decompose the cell - void findAddressingForCell - ( - const label cellI, - DynList<label, 32>& vrt, - DynList<edge, 64>& edges, - DynList<DynList<label, 8> >& faceEdges, - DynList<DynList<label, 2>, 64>& edgeFaces - ) const; - + void findAddressingForCell + ( + const label cellI, + DynList<label, 32>& vrt, + DynList<edge, 64>& edges, + DynList<DynList<label, 8> >& faceEdges, + DynList<DynList<label, 2>, 64>& edgeFaces + ) const; + //- find the apex of the pyramids - label findTopVertex - ( - const label cellI, - const DynList<label, 32>& vrt, - const DynList<edge, 64>& edges, - const DynList<DynList<label, 2>, 64>& edgeFaces - ); - - void decomposeCellIntoPyramids(const label cellI); - - void createPointsAndCellFaces(const boolList& decomposeCell); - - void storeBoundaryFaces(const boolList& decomposeCell); - - void removeDecomposedCells(const boolList& decomposeCell); - - void addNewCells(); + label findTopVertex + ( + const label cellI, + const DynList<label, 32>& vrt, + const DynList<edge, 64>& edges, + const DynList<DynList<label, 2>, 64>& edgeFaces + ); + + void decomposeCellIntoPyramids(const label cellI); + + void createPointsAndCellFaces(const boolList& decomposeCell); + + void storeBoundaryFaces(const boolList& decomposeCell); + + void removeDecomposedCells(const boolList& decomposeCell); + + void addNewCells(); //- disallows bitwise construct void operator=(const decomposeCells&); @@ -105,17 +105,17 @@ class decomposeCells public: // Constructors - //- construct from polyMeshGen and a list containing patches - //- for each point - decomposeCells(polyMeshGen& mesh); + //- construct from polyMeshGen and a list containing patches + //- for each point + decomposeCells(polyMeshGen& mesh); //- Destructor ~decomposeCells(); // Member functions - //- perform decomposition of selected cell into pyramids - void decomposeMesh(const boolList&); + //- perform decomposition of selected cell into pyramids + void decomposeMesh(const boolList&); }; diff --git a/meshLibrary/utilities/decomposeCells/decomposeCellsDecomposition.C b/meshLibrary/utilities/decomposeCells/decomposeCellsDecomposition.C index 45cd9281..55762b90 100644 --- a/meshLibrary/utilities/decomposeCells/decomposeCellsDecomposition.C +++ b/meshLibrary/utilities/decomposeCells/decomposeCellsDecomposition.C @@ -254,7 +254,7 @@ void decomposeCells::addNewCells() newBoundaryPatches_ ); - polyMeshGenModifier(mesh_).removeUnusedVertices(); + polyMeshGenModifier(mesh_).removeUnusedVertices(); } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *// diff --git a/meshLibrary/utilities/decomposeCells/decomposeCellsPyramids.C b/meshLibrary/utilities/decomposeCells/decomposeCellsPyramids.C index 12dffedf..7813e9a6 100644 --- a/meshLibrary/utilities/decomposeCells/decomposeCellsPyramids.C +++ b/meshLibrary/utilities/decomposeCells/decomposeCellsPyramids.C @@ -36,18 +36,18 @@ Description namespace Foam { - + void decomposeCells::findAddressingForCell ( - const label cellI, - DynList<label, 32>& vrt, - DynList<edge, 64>& edges, - DynList<DynList<label, 8> >& faceEdges, - DynList<DynList<label, 2>, 64>& edgeFaces + const label cellI, + DynList<label, 32>& vrt, + DynList<edge, 64>& edges, + DynList<DynList<label, 8> >& faceEdges, + DynList<DynList<label, 2>, 64>& edgeFaces ) const { - const cell& c = mesh_.cells()[cellI]; - const faceListPMG& faces = mesh_.faces(); + const cell& c = mesh_.cells()[cellI]; + const faceListPMG& faces = mesh_.faces(); forAll(faceEdges, feI) { faceEdges[feI].setSize(faces[c[feI]].size()); @@ -56,7 +56,7 @@ void decomposeCells::findAddressingForCell forAll(c, fI) { - const face& f = faces[c[fI]]; + const face& f = faces[c[fI]]; const edgeList edg = faces[c[fI]].edges(); forAll(edg, eI) @@ -104,32 +104,32 @@ void decomposeCells::findAddressingForCell Info << "Edges " << edges << endl; Info << "faceEdges " << faceEdges << endl; Info << "edgeFaces " << edgeFaces << endl; - mesh_.write(); + mesh_.write(); FatalErrorIn ( "faceListList pMesh::decomposeCellIntoPyramids()" ) << "Cell " << cellI << " is not topologically closed!" << abort(FatalError); - } + } } label decomposeCells::findTopVertex ( - const label cellI, - const DynList<label, 32>& vrt, - const DynList<edge, 64>& edges, - const DynList<DynList<label, 2>, 64>& edgeFaces + const label cellI, + const DynList<label, 32>& vrt, + const DynList<edge, 64>& edges, + const DynList<DynList<label, 2>, 64>& edgeFaces ) { - const cell& c = mesh_.cells()[cellI]; - const faceListPMG& faces = mesh_.faces(); - - pointFieldPMG& pointsAccess = mesh_.points(); + const cell& c = mesh_.cells()[cellI]; + const faceListPMG& faces = mesh_.faces(); + + pointFieldPMG& pointsAccess = mesh_.points(); - //- there is no vertex in 3 or more patches - //- find boundary faces - label topVertex(-1); - + //- there is no vertex in 3 or more patches + //- find boundary faces + label topVertex(-1); + const labelList cp = c.labels(faces); point p(vector::zero); forAll(cp, cpI) @@ -143,39 +143,39 @@ label decomposeCells::findTopVertex Info << "Top vertex is " << topVertex << endl; # endif - return topVertex; + return topVertex; } void decomposeCells::decomposeCellIntoPyramids(const label cellI) { - const cellListPMG& cells = mesh_.cells(); - const faceListPMG& faces = mesh_.faces(); - const labelList& owner = mesh_.owner(); + const cellListPMG& cells = mesh_.cells(); + const faceListPMG& faces = mesh_.faces(); + const labelList& owner = mesh_.owner(); - const cell& c = cells[cellI]; - + const cell& c = cells[cellI]; + # ifdef DEBUGDecompose Info << "Starting decomposing cell " << cellI << endl; Info << "Cell consists of faces " << c << endl; - forAll(c, fI) - Info << "Face " << c[fI] << " is " << faces[c[fI]] << endl; + forAll(c, fI) + Info << "Face " << c[fI] << " is " << faces[c[fI]] << endl; # endif //- calculate edges, faceEdges and edgeFaces addressing - DynList<label, 32> vrt; + DynList<label, 32> vrt; DynList<edge, 64> edges; DynList<DynList<label, 8> > faceEdges; faceEdges.setSize(c.size()); DynList<DynList<label, 2>, 64> edgeFaces; - findAddressingForCell(cellI, vrt, edges, faceEdges, edgeFaces); + findAddressingForCell(cellI, vrt, edges, faceEdges, edgeFaces); // find a vertex which will be the top of the pyramids //- if there exist a corner vertex which is in 3 or more patches then //- it is selected as the top vertex label topVertex = findTopVertex(cellI, vrt, edges, edgeFaces); - + //- start generating pyramids - forAll(c, fI) + forAll(c, fI) { # ifdef DEBUGDecompose Info << "Face " << faces[c[fI]] << " is a base face" << endl; @@ -214,7 +214,7 @@ void decomposeCells::decomposeCellIntoPyramids(const label cellI) rf[1] = triFaces[tfI][2]; rf[2] = triFaces[tfI][1]; cellFaces[cfI++] = rf; - } + } } # ifdef DEBUGDecompose diff --git a/meshLibrary/utilities/faceDecomposition/decomposeFaces.C b/meshLibrary/utilities/faceDecomposition/decomposeFaces.C index e58693ae..d52e388e 100644 --- a/meshLibrary/utilities/faceDecomposition/decomposeFaces.C +++ b/meshLibrary/utilities/faceDecomposition/decomposeFaces.C @@ -309,7 +309,7 @@ void decomposeFaces::decomposeMeshFaces(const boolList& decomposeFace) c.setSize(newC.size()); forAll(newC, fJ) c[fJ] = newC[fJ]; - } + } meshModifier.clearAll(); diff --git a/meshLibrary/utilities/faceDecomposition/decomposeFaces.H b/meshLibrary/utilities/faceDecomposition/decomposeFaces.H index cac7194d..3a250022 100644 --- a/meshLibrary/utilities/faceDecomposition/decomposeFaces.H +++ b/meshLibrary/utilities/faceDecomposition/decomposeFaces.H @@ -49,11 +49,11 @@ namespace Foam class decomposeFaces { // private data - //- reference to the mesh - polyMeshGen& mesh_; - - //- number of points - VRWGraph newFacesForFace_; + //- reference to the mesh + polyMeshGen& mesh_; + + //- number of points + VRWGraph newFacesForFace_; //- disallows bitwise construct void operator=(const decomposeFaces&); @@ -72,11 +72,11 @@ public: ~decomposeFaces(); // Member functions - //- decompose selected faces into triangles using midnode subdivision - void decomposeMeshFaces(const boolList& decomposeFace); + //- decompose selected faces into triangles using midnode subdivision + void decomposeMeshFaces(const boolList& decomposeFace); - //- decompose internal faces containing concave nodes - void decomposeConcaveInternalFaces(const boolList& concaveVertex); + //- decompose internal faces containing concave nodes + void decomposeConcaveInternalFaces(const boolList& concaveVertex); }; diff --git a/meshLibrary/utilities/faceDecomposition/faceDecomposition.C b/meshLibrary/utilities/faceDecomposition/faceDecomposition.C index 83e4928a..282eec88 100644 --- a/meshLibrary/utilities/faceDecomposition/faceDecomposition.C +++ b/meshLibrary/utilities/faceDecomposition/faceDecomposition.C @@ -70,13 +70,13 @@ label faceDecomposition::concaveVertex() const } label vrtIndex = edges[eI].commonVertex(edges[next]); - /* + /* if( pointTriIndex_[vrtIndex] && pointTriIndex_[vrtIndex]->size() > 1 ) - */ - concaveVrt = vrtIndex; + */ + concaveVrt = vrtIndex; } } @@ -87,12 +87,12 @@ label faceDecomposition::concaveVertex() const //- Constructor faceDecomposition::faceDecomposition ( - const face& f, - const pointField& pts + const face& f, + const pointField& pts ) : - f_(f), - points_(pts) + f_(f), + points_(pts) { } @@ -113,7 +113,7 @@ bool faceDecomposition::isFaceConvex() const bool faceDecomposition::isFacePlanar(const scalar tol) const { - vector nref = f_.normal(points_); + vector nref = f_.normal(points_); nref /= mag(nref); forAll(f_, pI) @@ -138,7 +138,7 @@ bool faceDecomposition::isFacePlanar() const tol *= 0.05; - return isFacePlanar(tol); + return isFacePlanar(tol); } faceList faceDecomposition::decomposeFace() const @@ -267,13 +267,13 @@ faceList faceDecomposition::decomposeFaceIntoTriangles(const label cv) const Info << "face " << faceNo << " " << f_ << " is decomposed into " << fcs << endl; # endif - - return fcs; + + return fcs; } - - faceList fcs(1, f_); - - return fcs; + + faceList fcs(1, f_); + + return fcs; } faceList faceDecomposition::decomposeFaceIntoTriangles() const diff --git a/meshLibrary/utilities/faceDecomposition/faceDecomposition.H b/meshLibrary/utilities/faceDecomposition/faceDecomposition.H index ff8db7b1..37fc546d 100644 --- a/meshLibrary/utilities/faceDecomposition/faceDecomposition.H +++ b/meshLibrary/utilities/faceDecomposition/faceDecomposition.H @@ -49,18 +49,18 @@ namespace Foam class faceDecomposition { // private data - const face& f_; - - const pointField& points_; + const face& f_; + + const pointField& points_; // private member functions - //- find concave vertex and return its position - //- in the face - label concaveVertex() const; - - //- decomposes the face into triangle starting from - //- the given vertex - faceList decomposeFaceIntoTriangles(const label cv) const; + //- find concave vertex and return its position + //- in the face + label concaveVertex() const; + + //- decomposes the face into triangle starting from + //- the given vertex + faceList decomposeFaceIntoTriangles(const label cv) const; //- disallows bitwise construct void operator=(const faceDecomposition&); @@ -75,27 +75,27 @@ public: //- construct components faceDecomposition ( - const face&, - const pointField& + const face&, + const pointField& ); //- Destructor ~faceDecomposition(); // Member functions - //- check if the face is convex - bool isFaceConvex() const; - - //- check if the face is planar - bool isFacePlanar() const; - bool isFacePlanar(const scalar tol) const; - - //- decompose face into triangles - faceList decomposeFaceIntoTriangles() const; - - //- decompose face into the minimal number - //- of convex faces - faceList decomposeFace() const; + //- check if the face is convex + bool isFaceConvex() const; + + //- check if the face is planar + bool isFacePlanar() const; + bool isFacePlanar(const scalar tol) const; + + //- decompose face into triangles + faceList decomposeFaceIntoTriangles() const; + + //- decompose face into the minimal number + //- of convex faces + faceList decomposeFace() const; }; diff --git a/meshLibrary/utilities/helperClasses/createFacesFromChain/createFacesFromChain.C b/meshLibrary/utilities/helperClasses/createFacesFromChain/createFacesFromChain.C index e8dbe61c..67fac636 100644 --- a/meshLibrary/utilities/helperClasses/createFacesFromChain/createFacesFromChain.C +++ b/meshLibrary/utilities/helperClasses/createFacesFromChain/createFacesFromChain.C @@ -42,193 +42,193 @@ namespace Foam void createFacesFromChain::findPointsBelongingToTheFace ( - const label currPos, - boolList& includePoints, - boolList& endPoints + const label currPos, + boolList& includePoints, + boolList& endPoints ) const { - includePoints.setSize(chainPoints_.size()); - endPoints.setSize(chainPoints_.size()); - endPoints = false; - includePoints = false; - - const label currRegion = regionsForPointAtPosition_[currPos][0]; - if( regionsForPointAtPosition_[currPos].size() != 1 ) - { - FatalErrorIn - ( - "void createFacesFromChain::createFacesFromChain::" - "findVerticesBelongingToTheFace" - ) << "Trying to create a face from an invalid point!" - << abort(FatalError); - } - - # ifdef DEBUGCutter - Info << "Finding vertices belonging to the face from chain " - << chainPoints_ << endl; - # endif - - forAll(chainPoints_, pI) - { - const label pos = (pI+currPos) % chainPoints_.size(); - - if( regionsForPointAtPosition_[pos].contains(currRegion) ) - includePoints[pos] = true; - - if( regionsForPointAtPosition_[pos].size() > 1 ) - { - endPoints[pos] = true; - break; - } - else if( !includePoints[pos] ) - { - FatalErrorIn - ( - "void createFacesFromChain::findVerticesBelongingToTheFace()" - ) << "Cannot create boundary face" - << abort(FatalError); - } - } - - forAllReverse(chainPoints_, pI) - { - const label pos = (pI+currPos) % chainPoints_.size(); - if( includePoints[pos] ) break; - - if( regionsForPointAtPosition_[pos].contains(currRegion) ) - includePoints[pos] = true; - - if( regionsForPointAtPosition_[pos].size() > 1 ) - { - endPoints[pos] = true; - break; - } - else if( !includePoints[pos] ) - { - FatalErrorIn - ( - "void createFacesFromChain::createFacesFromChain::" - "findVerticesBelongingToTheFace" - ) << "Cannot create boundary face" - << abort(FatalError); - } - } - - # ifdef DEBUGCutter - Info << "Include points " << includePoints << endl; - Info << "End points " << endPoints << endl; - # endif + includePoints.setSize(chainPoints_.size()); + endPoints.setSize(chainPoints_.size()); + endPoints = false; + includePoints = false; + + const label currRegion = regionsForPointAtPosition_[currPos][0]; + if( regionsForPointAtPosition_[currPos].size() != 1 ) + { + FatalErrorIn + ( + "void createFacesFromChain::createFacesFromChain::" + "findVerticesBelongingToTheFace" + ) << "Trying to create a face from an invalid point!" + << abort(FatalError); + } + + # ifdef DEBUGCutter + Info << "Finding vertices belonging to the face from chain " + << chainPoints_ << endl; + # endif + + forAll(chainPoints_, pI) + { + const label pos = (pI+currPos) % chainPoints_.size(); + + if( regionsForPointAtPosition_[pos].contains(currRegion) ) + includePoints[pos] = true; + + if( regionsForPointAtPosition_[pos].size() > 1 ) + { + endPoints[pos] = true; + break; + } + else if( !includePoints[pos] ) + { + FatalErrorIn + ( + "void createFacesFromChain::findVerticesBelongingToTheFace()" + ) << "Cannot create boundary face" + << abort(FatalError); + } + } + + forAllReverse(chainPoints_, pI) + { + const label pos = (pI+currPos) % chainPoints_.size(); + if( includePoints[pos] ) break; + + if( regionsForPointAtPosition_[pos].contains(currRegion) ) + includePoints[pos] = true; + + if( regionsForPointAtPosition_[pos].size() > 1 ) + { + endPoints[pos] = true; + break; + } + else if( !includePoints[pos] ) + { + FatalErrorIn + ( + "void createFacesFromChain::createFacesFromChain::" + "findVerticesBelongingToTheFace" + ) << "Cannot create boundary face" + << abort(FatalError); + } + } + + # ifdef DEBUGCutter + Info << "Include points " << includePoints << endl; + Info << "End points " << endPoints << endl; + # endif } void createFacesFromChain::shrinkTheChain ( - const label currPos, - const boolList& includePoints, - const boolList& endPoints + const label currPos, + const boolList& includePoints, + const boolList& endPoints ) { - const label currRegion = regionsForPointAtPosition_[currPos][0]; - if( regionsForPointAtPosition_[currPos].size() != 1 ) - { - FatalErrorIn - ( - "void createFacesFromChain::createFacesFromChain::" - "findVerticesBelongingToTheFace" - ) << "Trying to create a face from an invalid point!" - << abort(FatalError); - } - - # ifdef DEBUGCutter - Info << "Shrinking chain " << chainPoints_ << endl; - # endif - - labelList shrinkedChain(chainPoints_.size()); - List<DynList<label> > shrinkedRegions(chainPoints_.size()); - - direction pI(0); - - forAll(chainPoints_, vI) - if( !includePoints[vI] ) - { - shrinkedChain[pI] = chainPoints_[vI]; - shrinkedRegions[pI] = regionsForPointAtPosition_[vI]; - ++pI; - } - else if( endPoints[vI] ) - { - shrinkedChain[pI] = chainPoints_[vI]; - forAll(regionsForPointAtPosition_[vI], regI) - if( regionsForPointAtPosition_[vI][regI] != currRegion ) - shrinkedRegions[pI].append - ( - regionsForPointAtPosition_[vI][regI] - ); - ++pI; - } - - //- set sizes - shrinkedChain.setSize(pI); - shrinkedRegions.setSize(pI); - - //- store the shrinked lists - chainPoints_ = shrinkedChain; - regionsForPointAtPosition_ = shrinkedRegions; - - # ifdef DEBUGCutter - Info << "Shrinked chain " << chainPoints_ << endl; - Info << "Shrinked regions " << regionsForPointAtPosition_ << endl; - # endif + const label currRegion = regionsForPointAtPosition_[currPos][0]; + if( regionsForPointAtPosition_[currPos].size() != 1 ) + { + FatalErrorIn + ( + "void createFacesFromChain::createFacesFromChain::" + "findVerticesBelongingToTheFace" + ) << "Trying to create a face from an invalid point!" + << abort(FatalError); + } + + # ifdef DEBUGCutter + Info << "Shrinking chain " << chainPoints_ << endl; + # endif + + labelList shrinkedChain(chainPoints_.size()); + List<DynList<label> > shrinkedRegions(chainPoints_.size()); + + direction pI(0); + + forAll(chainPoints_, vI) + if( !includePoints[vI] ) + { + shrinkedChain[pI] = chainPoints_[vI]; + shrinkedRegions[pI] = regionsForPointAtPosition_[vI]; + ++pI; + } + else if( endPoints[vI] ) + { + shrinkedChain[pI] = chainPoints_[vI]; + forAll(regionsForPointAtPosition_[vI], regI) + if( regionsForPointAtPosition_[vI][regI] != currRegion ) + shrinkedRegions[pI].append + ( + regionsForPointAtPosition_[vI][regI] + ); + ++pI; + } + + //- set sizes + shrinkedChain.setSize(pI); + shrinkedRegions.setSize(pI); + + //- store the shrinked lists + chainPoints_ = shrinkedChain; + regionsForPointAtPosition_ = shrinkedRegions; + + # ifdef DEBUGCutter + Info << "Shrinked chain " << chainPoints_ << endl; + Info << "Shrinked regions " << regionsForPointAtPosition_ << endl; + # endif } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *// createFacesFromChain::createFacesFromChain ( - const labelList& chVertices, - const VRWGraph& pointRegions + const labelList& chVertices, + const VRWGraph& pointRegions ) : - chainPoints_(chVertices), - regionsForPointAtPosition_(chVertices.size()), - createdFaces_(), - faceRegions_() + chainPoints_(chVertices), + regionsForPointAtPosition_(chVertices.size()), + createdFaces_(), + faceRegions_() { - forAll(chVertices, vI) - { - const constRow row = pointRegions[chVertices[vI]]; - regionsForPointAtPosition_[vI].clear(); - forAll(row, rI) - regionsForPointAtPosition_[vI].append(row[rI]); - } - - # ifdef DEBUGCutter - Info << "Making boundary faces for chain " << chainPoints_ << endl; - Info << "Regions for chain points " << regionsForPointAtPosition_ << endl; - # endif + forAll(chVertices, vI) + { + const constRow row = pointRegions[chVertices[vI]]; + regionsForPointAtPosition_[vI].clear(); + forAll(row, rI) + regionsForPointAtPosition_[vI].append(row[rI]); + } + + # ifdef DEBUGCutter + Info << "Making boundary faces for chain " << chainPoints_ << endl; + Info << "Regions for chain points " << regionsForPointAtPosition_ << endl; + # endif } createFacesFromChain::createFacesFromChain ( - const labelList& chVertices, - const List<DynList<label> >& pointRegions + const labelList& chVertices, + const List<DynList<label> >& pointRegions ) : - chainPoints_(chVertices), - regionsForPointAtPosition_(chVertices.size()), - createdFaces_(), - faceRegions_() + chainPoints_(chVertices), + regionsForPointAtPosition_(chVertices.size()), + createdFaces_(), + faceRegions_() { - forAll(chVertices, vI) - { - regionsForPointAtPosition_[vI] = pointRegions[chVertices[vI]]; - } - - # ifdef DEBUGCutter - Info << "Making boundary faces for chain " << chainPoints_ << endl; - Info << "Regions for chain points " << regionsForPointAtPosition_ << endl; - # endif + forAll(chVertices, vI) + { + regionsForPointAtPosition_[vI] = pointRegions[chVertices[vI]]; + } + + # ifdef DEBUGCutter + Info << "Making boundary faces for chain " << chainPoints_ << endl; + Info << "Regions for chain points " << regionsForPointAtPosition_ << endl; + # endif } - + createFacesFromChain::~createFacesFromChain() { } @@ -238,205 +238,205 @@ createFacesFromChain::~createFacesFromChain() void createFacesFromChain::createFacesWithoutACorner() { - bool found; - do - { - found = false; - - boolList includePoints, endPoints; - - //- this function removes nodes from the chainPoints_ and creates - //- new faces. In order to create a valid face, it is important that - //- that a chain of vertices belonging to a given patch is singly - //- connected. Non-singly connected chains are not treated until they - //- become singly connected after elimination of other chains - - /* - boolList usedPoint(chainPoints_.size(), false); - Map<label> numOfChains; - forAll(chainPoints_, pI) - if( !usedPoint[pI] && (regionsForPointAtPosition_[pI].size() == 1) ) - { - findPointsBelongingToTheFace(pI, includePoints, endPoints); - - forAll(includePoints, ipI) - if( includePoints[ipI] ) - usedPoint[ipI] = true; - - if( !numOfChains.found(regionsForPointAtPosition_[pI][0]) ) - { - numOfChains.insert - ( - regionsForPointAtPosition_[pI][0], - 1 - ); - } - else - { - numOfChains[regionsForPointAtPosition_[pI][0]]++; - } - } - */ - - //- start creating faces and eliminating nodes from the chain for - //- singly connected topologies - forAll(chainPoints_, pI) - if( - (regionsForPointAtPosition_[pI].size() == 1) - //&& (numOfChains[regionsForPointAtPosition_[pI][0]] == 1) - ) - { - findPointsBelongingToTheFace(pI, includePoints, endPoints); - - //- create a new face - face f(chainPoints_.size()); - direction vrtI(0); - - forAll(includePoints, incI) - if( includePoints[incI] ) - f[vrtI++] = chainPoints_[incI]; - - DynList<label> facePatches(3); - forAll(endPoints, epI) - if( endPoints[epI] ) - { - const DynList<label>& pr = - regionsForPointAtPosition_[epI]; - - forAll(pr, i) - facePatches.appendIfNotIn(pr[i]); - } - - //- face must contain an additional corner point if the number - //- of associated patches is greater than 2. Skip creating the - //- face is this is the case - if( facePatches.size() > 2 ) - continue; - - found = true; - - if( vrtI > 2 ) - { - f.setSize(vrtI); - createdFaces_.append(f); - faceRegions_.append(regionsForPointAtPosition_[pI][0]); - - # ifdef DEBUGCutter - Info << "Created face " << f << endl; - # endif - } + bool found; + do + { + found = false; + + boolList includePoints, endPoints; + + //- this function removes nodes from the chainPoints_ and creates + //- new faces. In order to create a valid face, it is important that + //- that a chain of vertices belonging to a given patch is singly + //- connected. Non-singly connected chains are not treated until they + //- become singly connected after elimination of other chains + + /* + boolList usedPoint(chainPoints_.size(), false); + Map<label> numOfChains; + forAll(chainPoints_, pI) + if( !usedPoint[pI] && (regionsForPointAtPosition_[pI].size() == 1) ) + { + findPointsBelongingToTheFace(pI, includePoints, endPoints); + + forAll(includePoints, ipI) + if( includePoints[ipI] ) + usedPoint[ipI] = true; + + if( !numOfChains.found(regionsForPointAtPosition_[pI][0]) ) + { + numOfChains.insert + ( + regionsForPointAtPosition_[pI][0], + 1 + ); + } + else + { + numOfChains[regionsForPointAtPosition_[pI][0]]++; + } + } + */ + + //- start creating faces and eliminating nodes from the chain for + //- singly connected topologies + forAll(chainPoints_, pI) + if( + (regionsForPointAtPosition_[pI].size() == 1) + //&& (numOfChains[regionsForPointAtPosition_[pI][0]] == 1) + ) + { + findPointsBelongingToTheFace(pI, includePoints, endPoints); + + //- create a new face + face f(chainPoints_.size()); + direction vrtI(0); + + forAll(includePoints, incI) + if( includePoints[incI] ) + f[vrtI++] = chainPoints_[incI]; + + DynList<label> facePatches(3); + forAll(endPoints, epI) + if( endPoints[epI] ) + { + const DynList<label>& pr = + regionsForPointAtPosition_[epI]; + + forAll(pr, i) + facePatches.appendIfNotIn(pr[i]); + } + + //- face must contain an additional corner point if the number + //- of associated patches is greater than 2. Skip creating the + //- face is this is the case + if( facePatches.size() > 2 ) + continue; + + found = true; + + if( vrtI > 2 ) + { + f.setSize(vrtI); + createdFaces_.append(f); + faceRegions_.append(regionsForPointAtPosition_[pI][0]); + + # ifdef DEBUGCutter + Info << "Created face " << f << endl; + # endif + } - //- shrink the chainPoints_ - shrinkTheChain(pI, includePoints, endPoints); - - break; - } - } while( found ); + //- shrink the chainPoints_ + shrinkTheChain(pI, includePoints, endPoints); + + break; + } + } while( found ); } - + void createFacesFromChain::createFacesWithACorner ( - const label cornerLabel + const label cornerLabel ) { - label start(-1), facePatch(-1); - forAll(chainPoints_, cpI) - if( regionsForPointAtPosition_[cpI].size() == 2 ) - { - start = cpI; - - DynList<label> commonPatches(2); - const DynList<label>& np = - regionsForPointAtPosition_[chainPoints_.fcIndex(cpI)]; - - forAll(np, npI) - if( regionsForPointAtPosition_[cpI].contains(np[npI]) ) - commonPatches.append(np[npI]); - - if( commonPatches.size() == 1 ) - { - facePatch = commonPatches[0]; - } - else - { - FatalErrorIn - ( - "void createFacesFromChain::createFacesFromChain::" - "createFacesWithACorner(const label cornerLabel)" - ) << "Cannot determine face patch" << abort(FatalError); - } - - break; - } - - //- start creating faces with a corner - face f(5); - direction vI(0); - f[vI++] = chainPoints_[start]; - - for(label cpI=1;cpI<chainPoints_.size();++cpI) - { - const label pos = (cpI + start) % chainPoints_.size(); - - if( regionsForPointAtPosition_[pos].size() == 1 ) - { - f.newElmt(vI++) = chainPoints_[pos]; - } - else if( regionsForPointAtPosition_[pos].size() == 2 ) - { - //- store old face - f.newElmt(vI++) = chainPoints_[pos]; - f.newElmt(vI++) = cornerLabel; - f.setSize(vI); - vI = 0; - createdFaces_.append(f); - faceRegions_.append(facePatch); - - //- start creting new face - f[vI++] = chainPoints_[pos]; - const label ppos = - regionsForPointAtPosition_[pos].containsAtPosition(facePatch); - if( ppos == 0 ) - { - facePatch = regionsForPointAtPosition_[pos][1]; - } - else - { - facePatch = regionsForPointAtPosition_[pos][0]; - } - } - else - { - FatalErrorIn - ( - "void createFacesFromChain::createFacesFromChain::" - "createFacesWithACorner(const label cornerLabel)" - ) << "Found chain vertex in more than 2 patches!!" - << abort(FatalError); - } - } - - //- add the start position into the last face - f.newElmt(vI++) = chainPoints_[start]; - f.newElmt(vI++) = cornerLabel; - f.setSize(vI); - createdFaces_.append(f); - faceRegions_.append(facePatch); + label start(-1), facePatch(-1); + forAll(chainPoints_, cpI) + if( regionsForPointAtPosition_[cpI].size() == 2 ) + { + start = cpI; + + DynList<label> commonPatches(2); + const DynList<label>& np = + regionsForPointAtPosition_[chainPoints_.fcIndex(cpI)]; + + forAll(np, npI) + if( regionsForPointAtPosition_[cpI].contains(np[npI]) ) + commonPatches.append(np[npI]); + + if( commonPatches.size() == 1 ) + { + facePatch = commonPatches[0]; + } + else + { + FatalErrorIn + ( + "void createFacesFromChain::createFacesFromChain::" + "createFacesWithACorner(const label cornerLabel)" + ) << "Cannot determine face patch" << abort(FatalError); + } + + break; + } + + //- start creating faces with a corner + face f(5); + direction vI(0); + f[vI++] = chainPoints_[start]; + + for(label cpI=1;cpI<chainPoints_.size();++cpI) + { + const label pos = (cpI + start) % chainPoints_.size(); + + if( regionsForPointAtPosition_[pos].size() == 1 ) + { + f.newElmt(vI++) = chainPoints_[pos]; + } + else if( regionsForPointAtPosition_[pos].size() == 2 ) + { + //- store old face + f.newElmt(vI++) = chainPoints_[pos]; + f.newElmt(vI++) = cornerLabel; + f.setSize(vI); + vI = 0; + createdFaces_.append(f); + faceRegions_.append(facePatch); + + //- start creting new face + f[vI++] = chainPoints_[pos]; + const label ppos = + regionsForPointAtPosition_[pos].containsAtPosition(facePatch); + if( ppos == 0 ) + { + facePatch = regionsForPointAtPosition_[pos][1]; + } + else + { + facePatch = regionsForPointAtPosition_[pos][0]; + } + } + else + { + FatalErrorIn + ( + "void createFacesFromChain::createFacesFromChain::" + "createFacesWithACorner(const label cornerLabel)" + ) << "Found chain vertex in more than 2 patches!!" + << abort(FatalError); + } + } + + //- add the start position into the last face + f.newElmt(vI++) = chainPoints_[start]; + f.newElmt(vI++) = cornerLabel; + f.setSize(vI); + createdFaces_.append(f); + faceRegions_.append(facePatch); } const DynList<face>& createFacesFromChain::createdFaces() const { - return createdFaces_; + return createdFaces_; } const DynList<label>& createFacesFromChain::faceRegion()const { - return faceRegions_; + return faceRegions_; } const labelList& createFacesFromChain::unresolvedPoints() const { - return chainPoints_; + return chainPoints_; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *// diff --git a/meshLibrary/utilities/helperClasses/createFacesFromChain/createFacesFromChain.H b/meshLibrary/utilities/helperClasses/createFacesFromChain/createFacesFromChain.H index 4390acf7..052c11db 100644 --- a/meshLibrary/utilities/helperClasses/createFacesFromChain/createFacesFromChain.H +++ b/meshLibrary/utilities/helperClasses/createFacesFromChain/createFacesFromChain.H @@ -43,7 +43,7 @@ SourceFiles namespace Foam { - + class VRWGraph; /*---------------------------------------------------------------------------*\ @@ -52,58 +52,58 @@ class VRWGraph; class createFacesFromChain { - // Members - labelList chainPoints_; - - List<DynList<label> > regionsForPointAtPosition_; - - DynList<face> createdFaces_; - DynList<label> faceRegions_; - - // Private member functions - void findPointsBelongingToTheFace - ( - const label currPos, - boolList& includePoints, - boolList& endPoints - ) const; - - void shrinkTheChain - ( - const label currPos, - const boolList& includePoints, - const boolList& endPoints - ); - - public: - - createFacesFromChain - ( - const labelList& chPoints, - const VRWGraph& pointRegions - ); - - createFacesFromChain - ( - const labelList& chPoints, - const List<DynList<label> >& pointRegions - ); - - ~createFacesFromChain(); - - // Member functions - //- create faces which do not require an additional corner - void createFacesWithoutACorner(); - - //- create faces with a corner - void createFacesWithACorner(const label); - - //- return created faces and the corresponding patches - const DynList<face>& createdFaces() const; - const DynList<label>& faceRegion() const; - - //- a list of points which have not yet been resolved - const labelList& unresolvedPoints() const; + // Members + labelList chainPoints_; + + List<DynList<label> > regionsForPointAtPosition_; + + DynList<face> createdFaces_; + DynList<label> faceRegions_; + + // Private member functions + void findPointsBelongingToTheFace + ( + const label currPos, + boolList& includePoints, + boolList& endPoints + ) const; + + void shrinkTheChain + ( + const label currPos, + const boolList& includePoints, + const boolList& endPoints + ); + + public: + + createFacesFromChain + ( + const labelList& chPoints, + const VRWGraph& pointRegions + ); + + createFacesFromChain + ( + const labelList& chPoints, + const List<DynList<label> >& pointRegions + ); + + ~createFacesFromChain(); + + // Member functions + //- create faces which do not require an additional corner + void createFacesWithoutACorner(); + + //- create faces with a corner + void createFacesWithACorner(const label); + + //- return created faces and the corresponding patches + const DynList<face>& createdFaces() const; + const DynList<label>& faceRegion() const; + + //- a list of points which have not yet been resolved + const labelList& unresolvedPoints() const; }; // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/meshLibrary/utilities/helperClasses/inSphereTest/inSphereTest.H b/meshLibrary/utilities/helperClasses/inSphereTest/inSphereTest.H index 6c2cdd42..3ab772a0 100644 --- a/meshLibrary/utilities/helperClasses/inSphereTest/inSphereTest.H +++ b/meshLibrary/utilities/helperClasses/inSphereTest/inSphereTest.H @@ -27,7 +27,7 @@ Class Description Calculates if a point is inside a tetrahedron sphere or not. Uses adaptive- - precision arithmetic by J. R. Schewchuk + precision arithmetic by J. R. Schewchuk SourceFiles inSphereTest.C diff --git a/meshLibrary/utilities/helperClasses/matrices/matrix2D.H b/meshLibrary/utilities/helperClasses/matrices/matrix2D.H index c37b39b4..05e2173f 100644 --- a/meshLibrary/utilities/helperClasses/matrices/matrix2D.H +++ b/meshLibrary/utilities/helperClasses/matrices/matrix2D.H @@ -42,7 +42,7 @@ SourceFiles namespace Foam { - + /*---------------------------------------------------------------------------*\ Class matrix2D Declaration \*---------------------------------------------------------------------------*/ @@ -52,42 +52,42 @@ class matrix2D { // Private members mutable scalar det_; - mutable bool calculatedDet_; - + mutable bool calculatedDet_; + // Private member functions - //- calculate matrix determinant - inline void calculateDeterminant() const; - + //- calculate matrix determinant + inline void calculateDeterminant() const; + public: - // Constructors - //- Null constructor - explicit inline matrix2D(); + // Constructors + //- Null constructor + explicit inline matrix2D(); - //- Copy constructor - inline matrix2D(const matrix2D&); + //- Copy constructor + inline matrix2D(const matrix2D&); - // Destructor - inline ~matrix2D(); + // Destructor + inline ~matrix2D(); - // Member functions - //- return matrix determinant - inline scalar determinant() const; + // Member functions + //- return matrix determinant + inline scalar determinant() const; - //- return inverse matrix - inline matrix2D inverse() const; + //- return inverse matrix + inline matrix2D inverse() const; - //- find the solution of the system with the given rhs - inline FixedList<scalar, 2> solve - ( - const FixedList<scalar, 2>& source - ) const; + //- find the solution of the system with the given rhs + inline FixedList<scalar, 2> solve + ( + const FixedList<scalar, 2>& source + ) const; - //- return the first component of the solution vector - inline scalar solveFirst(const FixedList<scalar, 2>& source) const; - - //- return the second component of the solution vector - inline scalar solveSecond(const FixedList<scalar, 2>& source) const; + //- return the first component of the solution vector + inline scalar solveFirst(const FixedList<scalar, 2>& source) const; + + //- return the second component of the solution vector + inline scalar solveSecond(const FixedList<scalar, 2>& source) const; }; // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/meshLibrary/utilities/helperClasses/matrices/matrix2DI.H b/meshLibrary/utilities/helperClasses/matrices/matrix2DI.H index 29bfb1fa..03174aac 100644 --- a/meshLibrary/utilities/helperClasses/matrices/matrix2DI.H +++ b/meshLibrary/utilities/helperClasses/matrices/matrix2DI.H @@ -35,34 +35,34 @@ Description namespace Foam { - + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - + inline void matrix2D::calculateDeterminant() const { - if( calculatedDet_ ) - return; - - const FixedList<FixedList<scalar, 2>, 2>& mat = *this; - det_ = mat[0][0] * mat[1][1] - mat[0][1] * mat[1][0]; - - calculatedDet_ = true; + if( calculatedDet_ ) + return; + + const FixedList<FixedList<scalar, 2>, 2>& mat = *this; + det_ = mat[0][0] * mat[1][1] - mat[0][1] * mat[1][0]; + + calculatedDet_ = true; } - + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - + inline matrix2D::matrix2D() : - det_(), - calculatedDet_(false) + det_(), + calculatedDet_(false) { } inline matrix2D::matrix2D(const matrix2D& m) : - FixedList<FixedList<scalar, 2>, 2>(m), - det_(), - calculatedDet_(false) + FixedList<FixedList<scalar, 2>, 2>(m), + det_(), + calculatedDet_(false) { } @@ -73,60 +73,60 @@ inline matrix2D::~matrix2D() inline scalar matrix2D::determinant() const { - calculateDeterminant(); - - return det_; + calculateDeterminant(); + + return det_; } inline matrix2D matrix2D::inverse() const { - calculateDeterminant(); - const FixedList<FixedList<scalar, 2>, 2>& mat = *this; - matrix2D imat; - imat[0][0] = mat[1][1] / det_; - imat[0][1] = -1.0 * mat[0][1] / det_; - imat[1][0] = -1.0 * mat[1][0] / det_; - imat[1][1] = mat[0][0] / det_; - - return matrix2D(imat); + calculateDeterminant(); + const FixedList<FixedList<scalar, 2>, 2>& mat = *this; + matrix2D imat; + imat[0][0] = mat[1][1] / det_; + imat[0][1] = -1.0 * mat[0][1] / det_; + imat[1][0] = -1.0 * mat[1][0] / det_; + imat[1][1] = mat[0][0] / det_; + + return matrix2D(imat); } inline FixedList<scalar, 2> matrix2D::solve ( - const FixedList<scalar, 2>& source + const FixedList<scalar, 2>& source ) const { - FixedList<scalar, 2> result; - result[0] = solveFirst(source); - result[1] = solveSecond(source); - - return result; + FixedList<scalar, 2> result; + result[0] = solveFirst(source); + result[1] = solveSecond(source); + + return result; } inline scalar matrix2D::solveFirst(const FixedList<scalar, 2>& source) const { - calculateDeterminant(); - - const FixedList<FixedList<scalar, 2>, 2>& mat = *this; - - return - ( - mat[1][1] * source[0] - - mat[0][1] * source[1] - ) / det_; + calculateDeterminant(); + + const FixedList<FixedList<scalar, 2>, 2>& mat = *this; + + return + ( + mat[1][1] * source[0] - + mat[0][1] * source[1] + ) / det_; } - + inline scalar matrix2D::solveSecond(const FixedList<scalar, 2>& source) const { - calculateDeterminant(); - - const FixedList<FixedList<scalar, 2>, 2>& mat = *this; - - return - ( - -1.0 * mat[1][0] * source[0] + - mat[0][0] * source[1] - ) / det_; + calculateDeterminant(); + + const FixedList<FixedList<scalar, 2>, 2>& mat = *this; + + return + ( + -1.0 * mat[1][0] * source[0] + + mat[0][0] * source[1] + ) / det_; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/meshLibrary/utilities/helperClasses/matrices/matrix3D.H b/meshLibrary/utilities/helperClasses/matrices/matrix3D.H index 6e4e1b89..8cfc103e 100644 --- a/meshLibrary/utilities/helperClasses/matrices/matrix3D.H +++ b/meshLibrary/utilities/helperClasses/matrices/matrix3D.H @@ -43,7 +43,7 @@ SourceFiles namespace Foam { - + /*---------------------------------------------------------------------------*\ Class matrix3D Declaration \*---------------------------------------------------------------------------*/ @@ -53,45 +53,45 @@ class matrix3D { // Private members mutable scalar det_; - mutable bool calculatedDet_; - + mutable bool calculatedDet_; + // Private member functions - //- calculate matrix determinant - inline void calculateDeterminant() const; + //- calculate matrix determinant + inline void calculateDeterminant() const; public: - // Constructors - //- Null constructor - explicit inline matrix3D(); - - //- Copy constructor - inline matrix3D(const matrix3D&); - - // Destructor - inline ~matrix3D(); - - // Member functions - //- return matrix determinant - inline scalar determinant() const; - - //- return inverse matrix - inline matrix3D inverse() const; - - //- find the solution of the system with the given rhs - inline FixedList<scalar, 3> solve - ( - const FixedList<scalar, 3>& source - ) const; - - //- return the first component of the solution vector - inline scalar solveFirst(const FixedList<scalar, 3>& source) const; - - //- return the second component of the solution vector - inline scalar solveSecond(const FixedList<scalar, 3>& source) const; - - //- return the third component of the solution vector - inline scalar solveThird(const FixedList<scalar, 3>& source) const; + // Constructors + //- Null constructor + explicit inline matrix3D(); + + //- Copy constructor + inline matrix3D(const matrix3D&); + + // Destructor + inline ~matrix3D(); + + // Member functions + //- return matrix determinant + inline scalar determinant() const; + + //- return inverse matrix + inline matrix3D inverse() const; + + //- find the solution of the system with the given rhs + inline FixedList<scalar, 3> solve + ( + const FixedList<scalar, 3>& source + ) const; + + //- return the first component of the solution vector + inline scalar solveFirst(const FixedList<scalar, 3>& source) const; + + //- return the second component of the solution vector + inline scalar solveSecond(const FixedList<scalar, 3>& source) const; + + //- return the third component of the solution vector + inline scalar solveThird(const FixedList<scalar, 3>& source) const; }; // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/meshLibrary/utilities/helperClasses/matrices/matrix3DI.H b/meshLibrary/utilities/helperClasses/matrices/matrix3DI.H index 9fb39a96..3574e1f4 100644 --- a/meshLibrary/utilities/helperClasses/matrices/matrix3DI.H +++ b/meshLibrary/utilities/helperClasses/matrices/matrix3DI.H @@ -35,36 +35,36 @@ Description namespace Foam { - + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - + inline void matrix3D::calculateDeterminant() const { - if( calculatedDet_ ) - return; - - const FixedList<FixedList<scalar, 3>, 3>& mat = *this; - det_ = - mat[0][0] * (mat[1][1] * mat[2][2] - mat[1][2] * mat[2][1]) - - mat[0][1] * (mat[1][0] * mat[2][2] - mat[1][2] * mat[2][0]) + - mat[0][2] * (mat[1][0] * mat[2][1] - mat[1][1] * mat[2][0]); - calculatedDet_ = true; + if( calculatedDet_ ) + return; + + const FixedList<FixedList<scalar, 3>, 3>& mat = *this; + det_ = + mat[0][0] * (mat[1][1] * mat[2][2] - mat[1][2] * mat[2][1]) - + mat[0][1] * (mat[1][0] * mat[2][2] - mat[1][2] * mat[2][0]) + + mat[0][2] * (mat[1][0] * mat[2][1] - mat[1][1] * mat[2][0]); + calculatedDet_ = true; } - + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - + inline matrix3D::matrix3D() : - det_(), - calculatedDet_(false) + det_(), + calculatedDet_(false) { } inline matrix3D::matrix3D(const matrix3D& m) : - FixedList<FixedList<scalar, 3>, 3>(m), - det_(), - calculatedDet_(false) + FixedList<FixedList<scalar, 3>, 3>(m), + det_(), + calculatedDet_(false) { } @@ -75,82 +75,82 @@ inline matrix3D::~matrix3D() inline scalar matrix3D::determinant() const { - calculateDeterminant(); - - return det_; + calculateDeterminant(); + + return det_; } inline matrix3D matrix3D::inverse() const { - calculateDeterminant(); - const FixedList<FixedList<scalar, 3>, 3>& mat = *this; - matrix3D imat; - imat[0][0] = (mat[1][1] * mat[2][2] - mat[1][2] * mat[2][1]) / det_; - imat[0][1] = (mat[0][2] * mat[2][1] - mat[0][1] * mat[2][2]) / det_; - imat[0][2] = (mat[0][1] * mat[1][2] - mat[0][2] * mat[1][1]) / det_; - imat[1][0] = (mat[1][2] * mat[2][0] - mat[1][0] * mat[2][2]) / det_; - imat[1][1] = (mat[0][0] * mat[2][2] - mat[0][2] * mat[2][0]) / det_; - imat[1][2] = (mat[0][2] * mat[1][0] - mat[0][0] * mat[1][2]) / det_; - imat[2][0] = (mat[1][0] * mat[2][1] - mat[1][1] * mat[2][0]) / det_; - imat[2][1] = (mat[0][1] * mat[2][0] - mat[0][0] * mat[2][1]) / det_; - imat[2][2] = (mat[0][0] * mat[1][1] - mat[0][1] * mat[1][0]) / det_; - - return imat; + calculateDeterminant(); + const FixedList<FixedList<scalar, 3>, 3>& mat = *this; + matrix3D imat; + imat[0][0] = (mat[1][1] * mat[2][2] - mat[1][2] * mat[2][1]) / det_; + imat[0][1] = (mat[0][2] * mat[2][1] - mat[0][1] * mat[2][2]) / det_; + imat[0][2] = (mat[0][1] * mat[1][2] - mat[0][2] * mat[1][1]) / det_; + imat[1][0] = (mat[1][2] * mat[2][0] - mat[1][0] * mat[2][2]) / det_; + imat[1][1] = (mat[0][0] * mat[2][2] - mat[0][2] * mat[2][0]) / det_; + imat[1][2] = (mat[0][2] * mat[1][0] - mat[0][0] * mat[1][2]) / det_; + imat[2][0] = (mat[1][0] * mat[2][1] - mat[1][1] * mat[2][0]) / det_; + imat[2][1] = (mat[0][1] * mat[2][0] - mat[0][0] * mat[2][1]) / det_; + imat[2][2] = (mat[0][0] * mat[1][1] - mat[0][1] * mat[1][0]) / det_; + + return imat; } inline FixedList<scalar, 3> matrix3D::solve ( - const FixedList<scalar, 3>& source + const FixedList<scalar, 3>& source ) const { - FixedList<scalar, 3> result; - result[0] = solveFirst(source); - result[1] = solveSecond(source); - result[2] = solveThird(source); - - return result; + FixedList<scalar, 3> result; + result[0] = solveFirst(source); + result[1] = solveSecond(source); + result[2] = solveThird(source); + + return result; } inline scalar matrix3D::solveFirst(const FixedList<scalar, 3>& source) const { - calculateDeterminant(); - - const FixedList<FixedList<scalar, 3>, 3>& mat = *this; - - return - ( - (mat[1][1] * mat[2][2] - mat[1][2] * mat[2][1]) * source[0] + - (mat[0][2] * mat[2][1] - mat[0][1] * mat[2][2]) * source[1] + - (mat[0][1] * mat[1][2] - mat[0][2] * mat[1][1]) * source[2] - ) / det_; + calculateDeterminant(); + + const FixedList<FixedList<scalar, 3>, 3>& mat = *this; + + return + ( + (mat[1][1] * mat[2][2] - mat[1][2] * mat[2][1]) * source[0] + + (mat[0][2] * mat[2][1] - mat[0][1] * mat[2][2]) * source[1] + + (mat[0][1] * mat[1][2] - mat[0][2] * mat[1][1]) * source[2] + ) / det_; } - + inline scalar matrix3D::solveSecond(const FixedList<scalar, 3>& source) const { - calculateDeterminant(); - - const FixedList<FixedList<scalar, 3>, 3>& mat = *this; - - return - ( - (mat[1][2] * mat[2][0] - mat[1][0] * mat[2][2]) * source[0] + - (mat[0][0] * mat[2][2] - mat[0][2] * mat[2][0]) * source[1] + - (mat[0][2] * mat[1][0] - mat[0][0] * mat[1][2]) * source[2] - ) / det_; + calculateDeterminant(); + + const FixedList<FixedList<scalar, 3>, 3>& mat = *this; + + return + ( + (mat[1][2] * mat[2][0] - mat[1][0] * mat[2][2]) * source[0] + + (mat[0][0] * mat[2][2] - mat[0][2] * mat[2][0]) * source[1] + + (mat[0][2] * mat[1][0] - mat[0][0] * mat[1][2]) * source[2] + ) / det_; } - + inline scalar matrix3D::solveThird(const FixedList<scalar, 3>& source) const { - calculateDeterminant(); - - const FixedList<FixedList<scalar, 3>, 3>& mat = *this; - - return - ( - (mat[1][0] * mat[2][1] - mat[1][1] * mat[2][0]) * source[0] + - (mat[0][1] * mat[2][0] - mat[0][0] * mat[2][1]) * source[1] + - (mat[0][0] * mat[1][1] - mat[0][1] * mat[1][0]) * source[2] - ) / det_; + calculateDeterminant(); + + const FixedList<FixedList<scalar, 3>, 3>& mat = *this; + + return + ( + (mat[1][0] * mat[2][1] - mat[1][1] * mat[2][0]) * source[0] + + (mat[0][1] * mat[2][0] - mat[0][0] * mat[2][1]) * source[1] + + (mat[0][0] * mat[1][1] - mat[0][1] * mat[1][0]) * source[2] + ) / det_; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/meshLibrary/utilities/helperClasses/parallelHelpers/labelledPair/labelledPair.H b/meshLibrary/utilities/helperClasses/parallelHelpers/labelledPair/labelledPair.H index 09dc8944..4b225887 100644 --- a/meshLibrary/utilities/helperClasses/parallelHelpers/labelledPair/labelledPair.H +++ b/meshLibrary/utilities/helperClasses/parallelHelpers/labelledPair/labelledPair.H @@ -110,9 +110,9 @@ class labelledPair { if( pLabel_ != lpp.pLabel_ ) return false; - - if( (pair_ != lpp.pair_) && (pair_.reversePair() != lpp.pair_) ) - return false; + + if( (pair_ != lpp.pair_) && (pair_.reversePair() != lpp.pair_) ) + return false; return true; } @@ -124,32 +124,32 @@ class labelledPair { return !this->operator==(lcc); } - - inline bool operator<(const labelledPair& lpp) const - { - if( pLabel_ < lpp.pLabel_ ) - { - return true; - } - else if( pLabel_ > lpp.pLabel_ ) - { - return false; - } - - if( - (pair_.first() + pair_.second()) < - (lpp.pair().first() + lpp.pair().second()) - ) - return true; - - if( - Foam::min(pair_.first(), pair_.second()) < - Foam::min(lpp.pair().first(), lpp.pair().second()) - ) - return true; - - return false; - } + + inline bool operator<(const labelledPair& lpp) const + { + if( pLabel_ < lpp.pLabel_ ) + { + return true; + } + else if( pLabel_ > lpp.pLabel_ ) + { + return false; + } + + if( + (pair_.first() + pair_.second()) < + (lpp.pair().first() + lpp.pair().second()) + ) + return true; + + if( + Foam::min(pair_.first(), pair_.second()) < + Foam::min(lpp.pair().first(), lpp.pair().second()) + ) + return true; + + return false; + } // Friend operators friend Ostream& operator<< diff --git a/meshLibrary/utilities/helperClasses/parallelHelpers/labelledPoint/labelledPoint.H b/meshLibrary/utilities/helperClasses/parallelHelpers/labelledPoint/labelledPoint.H index 15610c54..a075f0e5 100644 --- a/meshLibrary/utilities/helperClasses/parallelHelpers/labelledPoint/labelledPoint.H +++ b/meshLibrary/utilities/helperClasses/parallelHelpers/labelledPoint/labelledPoint.H @@ -85,22 +85,22 @@ class labelledPoint { return pLabel_; } - - inline label& pointLabel() - { - return pLabel_; - } + + inline label& pointLabel() + { + return pLabel_; + } //- return point coordinates inline const point& coordinates() const { return coords_; } - - inline point& coordinates() - { - return coords_; - } + + inline point& coordinates() + { + return coords_; + } // Member operators diff --git a/meshLibrary/utilities/helperClasses/parallelHelpers/labelledPointScalar/labelledPointScalar.H b/meshLibrary/utilities/helperClasses/parallelHelpers/labelledPointScalar/labelledPointScalar.H index f051bb9b..fdf253e3 100644 --- a/meshLibrary/utilities/helperClasses/parallelHelpers/labelledPointScalar/labelledPointScalar.H +++ b/meshLibrary/utilities/helperClasses/parallelHelpers/labelledPointScalar/labelledPointScalar.H @@ -90,22 +90,22 @@ class labelledPointScalar { return pLabel_; } - - inline label& pointLabel() - { - return pLabel_; - } + + inline label& pointLabel() + { + return pLabel_; + } //- return point coordinates inline const point& coordinates() const { return coords_; } - - inline point& coordinates() - { - return coords_; - } + + inline point& coordinates() + { + return coords_; + } //- return scalar value inline const scalar& scalarValue() const diff --git a/meshLibrary/utilities/helperClasses/sortEdgesIntoChains/sortEdgesIntoChains.C b/meshLibrary/utilities/helperClasses/sortEdgesIntoChains/sortEdgesIntoChains.C index 4880d4b1..e5094947 100644 --- a/meshLibrary/utilities/helperClasses/sortEdgesIntoChains/sortEdgesIntoChains.C +++ b/meshLibrary/utilities/helperClasses/sortEdgesIntoChains/sortEdgesIntoChains.C @@ -41,222 +41,222 @@ namespace Foam void sortEdgesIntoChains::createNodeLabels() { - label nPoints(0); - forAll(bEdges_, eI) - { - const edge& e = bEdges_[eI]; - if( !newNodeLabel_.found(e.start()) ) - newNodeLabel_.insert(e.start(), nPoints++); - if( !newNodeLabel_.found(e.end()) ) - newNodeLabel_.insert(e.end(), nPoints++); - } - - edgesAtPoint_.setSize(nPoints, DynList<label>(2)); - forAll(bEdges_, eI) - { - const edge& e = bEdges_[eI]; - label l = newNodeLabel_[e.start()]; - edgesAtPoint_[l].append(eI); - - l = newNodeLabel_[e.end()]; - edgesAtPoint_[l].append(eI); - } - - forAll(edgesAtPoint_, pI) - if( edgesAtPoint_[pI].size() % 2 ) - openEdges_ = true; + label nPoints(0); + forAll(bEdges_, eI) + { + const edge& e = bEdges_[eI]; + if( !newNodeLabel_.found(e.start()) ) + newNodeLabel_.insert(e.start(), nPoints++); + if( !newNodeLabel_.found(e.end()) ) + newNodeLabel_.insert(e.end(), nPoints++); + } + + edgesAtPoint_.setSize(nPoints, DynList<label>(2)); + forAll(bEdges_, eI) + { + const edge& e = bEdges_[eI]; + label l = newNodeLabel_[e.start()]; + edgesAtPoint_[l].append(eI); + + l = newNodeLabel_[e.end()]; + edgesAtPoint_[l].append(eI); + } + + forAll(edgesAtPoint_, pI) + if( edgesAtPoint_[pI].size() % 2 ) + openEdges_ = true; } - + bool sortEdgesIntoChains::findPointsBelongingToTheChain ( - const label currPos, - boolList& chainEdges + const label currPos, + boolList& chainEdges ) const { - # ifdef DEBUGSort - Info << "Finding point belonging to a chain" << endl; - # endif - - chainEdges.setSize(bEdges_.size()); - chainEdges = false; - - if( edgesAtPoint_[currPos].size() != 2 ) - return false; - - const label commonVrt = - bEdges_[edgesAtPoint_[currPos][0]].commonVertex - ( - bEdges_[edgesAtPoint_[currPos][1]] - ); - label prevVrt = bEdges_[edgesAtPoint_[currPos][0]].otherVertex(commonVrt); - label nextVrt = bEdges_[edgesAtPoint_[currPos][1]].otherVertex(commonVrt); - forAll(edgesAtPoint_[currPos], posI) - chainEdges[edgesAtPoint_[currPos][posI]] = true; - - # ifdef DEBUGSort - Info << "commonVrt " << commonVrt << endl; - Info << "prevVrt " << prevVrt << endl; - Info << "nextVrt " << nextVrt << endl; - # endif - - bool found; - do - { - found = false; - - const DynList<label>& vEdges = edgesAtPoint_[newNodeLabel_[prevVrt]]; - if( vEdges.size() == 2 ) - { - forAll(vEdges, eI) - if( !chainEdges[vEdges[eI]] ) - { - found = true; - chainEdges[vEdges[eI]] = true; - prevVrt = bEdges_[vEdges[eI]].otherVertex(prevVrt); - } - } - } while( found ); - - do - { - found = false; - - const DynList<label>& vEdges = edgesAtPoint_[newNodeLabel_[nextVrt]]; - if( vEdges.size() == 2 ) - { - forAll(vEdges, eI) - if( !chainEdges[vEdges[eI]] ) - { - found = true; - chainEdges[vEdges[eI]] = true; - nextVrt = bEdges_[vEdges[eI]].otherVertex(nextVrt); - } - } - } while( found ); - - if( - (edgesAtPoint_[newNodeLabel_[nextVrt]].size() != 2) && - (edgesAtPoint_[newNodeLabel_[prevVrt]].size() != 2) && - (prevVrt != nextVrt) - ) - { - chainEdges = false; - return false; - } - - # ifdef DEBUGSort - Info << "Chain edges " << chainEdges << endl; - # endif - - return true; + # ifdef DEBUGSort + Info << "Finding point belonging to a chain" << endl; + # endif + + chainEdges.setSize(bEdges_.size()); + chainEdges = false; + + if( edgesAtPoint_[currPos].size() != 2 ) + return false; + + const label commonVrt = + bEdges_[edgesAtPoint_[currPos][0]].commonVertex + ( + bEdges_[edgesAtPoint_[currPos][1]] + ); + label prevVrt = bEdges_[edgesAtPoint_[currPos][0]].otherVertex(commonVrt); + label nextVrt = bEdges_[edgesAtPoint_[currPos][1]].otherVertex(commonVrt); + forAll(edgesAtPoint_[currPos], posI) + chainEdges[edgesAtPoint_[currPos][posI]] = true; + + # ifdef DEBUGSort + Info << "commonVrt " << commonVrt << endl; + Info << "prevVrt " << prevVrt << endl; + Info << "nextVrt " << nextVrt << endl; + # endif + + bool found; + do + { + found = false; + + const DynList<label>& vEdges = edgesAtPoint_[newNodeLabel_[prevVrt]]; + if( vEdges.size() == 2 ) + { + forAll(vEdges, eI) + if( !chainEdges[vEdges[eI]] ) + { + found = true; + chainEdges[vEdges[eI]] = true; + prevVrt = bEdges_[vEdges[eI]].otherVertex(prevVrt); + } + } + } while( found ); + + do + { + found = false; + + const DynList<label>& vEdges = edgesAtPoint_[newNodeLabel_[nextVrt]]; + if( vEdges.size() == 2 ) + { + forAll(vEdges, eI) + if( !chainEdges[vEdges[eI]] ) + { + found = true; + chainEdges[vEdges[eI]] = true; + nextVrt = bEdges_[vEdges[eI]].otherVertex(nextVrt); + } + } + } while( found ); + + if( + (edgesAtPoint_[newNodeLabel_[nextVrt]].size() != 2) && + (edgesAtPoint_[newNodeLabel_[prevVrt]].size() != 2) && + (prevVrt != nextVrt) + ) + { + chainEdges = false; + return false; + } + + # ifdef DEBUGSort + Info << "Chain edges " << chainEdges << endl; + # endif + + return true; } void sortEdgesIntoChains::shrinkEdges(const boolList& chainEdges) { - forAll(chainEdges, eI) - if( chainEdges[eI] ) - { - const edge& e = bEdges_[eI]; - edgesAtPoint_[newNodeLabel_[e.start()]].removeElement - ( - edgesAtPoint_[newNodeLabel_[e.start()]].containsAtPosition(eI) - ); - - edgesAtPoint_[newNodeLabel_[e.end()]].removeElement - ( - edgesAtPoint_[newNodeLabel_[e.end()]].containsAtPosition(eI) - ); - } + forAll(chainEdges, eI) + if( chainEdges[eI] ) + { + const edge& e = bEdges_[eI]; + edgesAtPoint_[newNodeLabel_[e.start()]].removeElement + ( + edgesAtPoint_[newNodeLabel_[e.start()]].containsAtPosition(eI) + ); + + edgesAtPoint_[newNodeLabel_[e.end()]].removeElement + ( + edgesAtPoint_[newNodeLabel_[e.end()]].containsAtPosition(eI) + ); + } } void sortEdgesIntoChains::createChainFromEdges(const boolList& chainEdges) { - direction i(0); - forAll(chainEdges, eI) - if( chainEdges[eI] ) - ++i; - - labelList chainPoints(i); - i = 0; - - forAll(chainEdges, eI) - if( chainEdges[eI] ) - { - chainPoints[i++] = bEdges_[eI].start(); - chainPoints[i++] = bEdges_[eI].end(); - - # ifdef DEBUGSort - Info << "Init chainPoints " << chainPoints << endl; - # endif - - bool found; - do - { - # ifdef DEBUGSort - Info << "Iteration " << label(i-1) << endl; - # endif - - found = false; - const DynList<label>& pEdges = - edgesAtPoint_[newNodeLabel_[chainPoints[i-1]]]; - - forAll(pEdges, peI) - if( chainEdges[pEdges[peI]] ) - { - const label otherPoint = - bEdges_[pEdges[peI]].otherVertex(chainPoints[i-1]); - - # ifdef DEBUGSort - Info << "Other point " << otherPoint << endl; - # endif - if( otherPoint == -1 ) - continue; - if( chainPoints[i-2] == otherPoint ) - continue; - if( chainPoints[0] == otherPoint ) - continue; - - found = true; - chainPoints[i++] = otherPoint; - } - } while( found ); - - createdChains_.append(chainPoints); - - break; - } + direction i(0); + forAll(chainEdges, eI) + if( chainEdges[eI] ) + ++i; + + labelList chainPoints(i); + i = 0; + + forAll(chainEdges, eI) + if( chainEdges[eI] ) + { + chainPoints[i++] = bEdges_[eI].start(); + chainPoints[i++] = bEdges_[eI].end(); + + # ifdef DEBUGSort + Info << "Init chainPoints " << chainPoints << endl; + # endif + + bool found; + do + { + # ifdef DEBUGSort + Info << "Iteration " << label(i-1) << endl; + # endif + + found = false; + const DynList<label>& pEdges = + edgesAtPoint_[newNodeLabel_[chainPoints[i-1]]]; + + forAll(pEdges, peI) + if( chainEdges[pEdges[peI]] ) + { + const label otherPoint = + bEdges_[pEdges[peI]].otherVertex(chainPoints[i-1]); + + # ifdef DEBUGSort + Info << "Other point " << otherPoint << endl; + # endif + if( otherPoint == -1 ) + continue; + if( chainPoints[i-2] == otherPoint ) + continue; + if( chainPoints[0] == otherPoint ) + continue; + + found = true; + chainPoints[i++] = otherPoint; + } + } while( found ); + + createdChains_.append(chainPoints); + + break; + } } void sortEdgesIntoChains::sortEdges() { - createNodeLabels(); - - if( !openEdges_ ) - { - boolList chainEdges(bEdges_.size()); - forAll(edgesAtPoint_, pI) - if( findPointsBelongingToTheChain(pI, chainEdges) ) - { - createChainFromEdges(chainEdges); - - shrinkEdges(chainEdges); - } - } + createNodeLabels(); + + if( !openEdges_ ) + { + boolList chainEdges(bEdges_.size()); + forAll(edgesAtPoint_, pI) + if( findPointsBelongingToTheChain(pI, chainEdges) ) + { + createChainFromEdges(chainEdges); + + shrinkEdges(chainEdges); + } + } } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *// sortEdgesIntoChains::sortEdgesIntoChains(const DynList<edge>& bEdges) : - bEdges_(bEdges), - openEdges_(false), - newNodeLabel_(), - edgesAtPoint_(), - createdChains_() + bEdges_(bEdges), + openEdges_(false), + newNodeLabel_(), + edgesAtPoint_(), + createdChains_() { - sortEdges(); + sortEdges(); } - + sortEdgesIntoChains::~sortEdgesIntoChains() { } @@ -265,7 +265,7 @@ sortEdgesIntoChains::~sortEdgesIntoChains() // Member functions const DynList<labelList>& sortEdgesIntoChains::sortedChains() const { - return createdChains_; + return createdChains_; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *// diff --git a/meshLibrary/utilities/helperClasses/sortEdgesIntoChains/sortEdgesIntoChains.H b/meshLibrary/utilities/helperClasses/sortEdgesIntoChains/sortEdgesIntoChains.H index cfc646e2..61b1eedc 100644 --- a/meshLibrary/utilities/helperClasses/sortEdgesIntoChains/sortEdgesIntoChains.H +++ b/meshLibrary/utilities/helperClasses/sortEdgesIntoChains/sortEdgesIntoChains.H @@ -51,45 +51,45 @@ namespace Foam class sortEdgesIntoChains { - // Members - const DynList<edge>& bEdges_; - - bool openEdges_; - - Map<label> newNodeLabel_; - - List<DynList<label> > edgesAtPoint_; - - DynList<labelList> createdChains_; - - // Private member functions - void createNodeLabels(); - - bool findPointsBelongingToTheChain - ( - const label currPos, - boolList& chainEdges - ) const; - - void shrinkEdges(const boolList& chainEdges); - - void createChainFromEdges(const boolList& chainEdges); - - void sortEdges(); - - public: - - sortEdgesIntoChains - ( - const DynList<edge>& bEdges - ); - - ~sortEdgesIntoChains(); - - // Member functions - - //- a list of points which have not yet been resolved - const DynList<labelList>& sortedChains() const; + // Members + const DynList<edge>& bEdges_; + + bool openEdges_; + + Map<label> newNodeLabel_; + + List<DynList<label> > edgesAtPoint_; + + DynList<labelList> createdChains_; + + // Private member functions + void createNodeLabels(); + + bool findPointsBelongingToTheChain + ( + const label currPos, + boolList& chainEdges + ) const; + + void shrinkEdges(const boolList& chainEdges); + + void createChainFromEdges(const boolList& chainEdges); + + void sortEdges(); + + public: + + sortEdgesIntoChains + ( + const DynList<edge>& bEdges + ); + + ~sortEdgesIntoChains(); + + // Member functions + + //- a list of points which have not yet been resolved + const DynList<labelList>& sortedChains() const; }; // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/meshLibrary/utilities/helperFunctions/helperFunctionsPar.C b/meshLibrary/utilities/helperFunctions/helperFunctionsPar.C index 0d894432..a0c9da36 100644 --- a/meshLibrary/utilities/helperFunctions/helperFunctionsPar.C +++ b/meshLibrary/utilities/helperFunctions/helperFunctionsPar.C @@ -437,7 +437,7 @@ void reverseAddressingSMP if( it != data.end() ) { const DynList<labelPair, 64>& entries = it->second; - + forAll(entries, j) ++nAppearances[entries[j].first()]; } @@ -464,7 +464,7 @@ void reverseAddressingSMP if( it != data.end() ) { const DynList<labelPair, 64>& entries = it->second; - + forAll(entries, j) { const label entryI = entries[j].first(); @@ -502,7 +502,7 @@ void reverseAddressingSMP if( it != data.end() ) { const DynList<labelPair, 64>& entries = it->second; - + forAll(entries, j) { const label entryI = entries[j].first(); diff --git a/meshLibrary/utilities/helperFunctions/helperFunctionsStringConversion.C b/meshLibrary/utilities/helperFunctions/helperFunctionsStringConversion.C index acd0c9dd..774142a1 100644 --- a/meshLibrary/utilities/helperFunctions/helperFunctionsStringConversion.C +++ b/meshLibrary/utilities/helperFunctions/helperFunctionsStringConversion.C @@ -45,12 +45,12 @@ namespace help scalar textToScalar(const word& w) { - std::stringstream ss; - ss << w; - - double s; - ss >> s; - return s; + std::stringstream ss; + ss << w; + + double s; + ss >> s; + return s; } //- convert the text to label @@ -61,18 +61,18 @@ label textToLabel(const word& w) word scalarToText(const scalar s) { - std::ostringstream ss; - ss << s; - - return ss.str(); + std::ostringstream ss; + ss << s; + + return ss.str(); } word labelToText(const label l) { std::ostringstream ss; - ss << l; - - return ss.str(); + ss << l; + + return ss.str(); } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *// diff --git a/meshLibrary/utilities/helperFunctions/helperFunctionsTopologyManipulationI.H b/meshLibrary/utilities/helperFunctions/helperFunctionsTopologyManipulationI.H index d523e606..272dd47e 100644 --- a/meshLibrary/utilities/helperFunctions/helperFunctionsTopologyManipulationI.H +++ b/meshLibrary/utilities/helperFunctions/helperFunctionsTopologyManipulationI.H @@ -70,78 +70,78 @@ inline face mergeTwoFaces(const face& f1, const face& f2) inline edgeList modifyFacesToShareOneEdge(face& f1, face& f2) { - const edgeList edg1 = f1.edges(); - const edgeList edg2 = f2.edges(); - - boolList she1(f1.size(), false); - boolList she2(f2.size(), false); - - edgeList sharedEdges(edg1); - label nSharedEdges(0); - - forAll(edg1, eI) - forAll(edg2, eJ) - if( edg1[eI] == edg2[eJ] ) - { - sharedEdges.newElmt(nSharedEdges++) = edg1[eI]; - - she1[eI] = true; - she2[eJ] = true; - break; - } - - face newF(f1); - label i(0); - forAll(f1, pI) - if( !(she1[pI] && she1[(pI-1+f1.size())%f1.size()]) ) - newF[i++] = f1[pI]; - - newF.setSize(i); - f1 = newF; - - newF = f2; - i = 0; - forAll(f2, pI) - if( !(she2[pI] && she2[(pI-1+f2.size())%f2.size()]) ) + const edgeList edg1 = f1.edges(); + const edgeList edg2 = f2.edges(); + + boolList she1(f1.size(), false); + boolList she2(f2.size(), false); + + edgeList sharedEdges(edg1); + label nSharedEdges(0); + + forAll(edg1, eI) + forAll(edg2, eJ) + if( edg1[eI] == edg2[eJ] ) + { + sharedEdges.newElmt(nSharedEdges++) = edg1[eI]; + + she1[eI] = true; + she2[eJ] = true; + break; + } + + face newF(f1); + label i(0); + forAll(f1, pI) + if( !(she1[pI] && she1[(pI-1+f1.size())%f1.size()]) ) + newF[i++] = f1[pI]; + + newF.setSize(i); + f1 = newF; + + newF = f2; + i = 0; + forAll(f2, pI) + if( !(she2[pI] && she2[(pI-1+f2.size())%f2.size()]) ) newF[i++] = f2[pI]; - - newF.setSize(i); - f2 = newF; + + newF.setSize(i); + f2 = newF; - sharedEdges.setSize(nSharedEdges); - return sharedEdges; + sharedEdges.setSize(nSharedEdges); + return sharedEdges; } inline face createFaceFromRemovedPart(const face& fOrig, const face& fCut) { - if( fCut.size() == 0 ) - return fOrig; - - const edgeList eOrig = fOrig.edges(); - const edgeList eCut = fCut.edges(); - - boolList usedEdge(eOrig.size(), false); - - forAll(eOrig, eI) - forAll(eCut, eJ) - if( eOrig[eI] == eCut[eJ] ) - { - usedEdge[eI] = true; - break; - } - - face f(fOrig); - direction i(0); - - forAll(fOrig, pI) - if( !(usedEdge[pI] && usedEdge[(pI-1+fOrig.size())%fOrig.size()]) ) - { - f[i++] = fOrig[pI]; - } - - f.setSize(i); - - return f; + if( fCut.size() == 0 ) + return fOrig; + + const edgeList eOrig = fOrig.edges(); + const edgeList eCut = fCut.edges(); + + boolList usedEdge(eOrig.size(), false); + + forAll(eOrig, eI) + forAll(eCut, eJ) + if( eOrig[eI] == eCut[eJ] ) + { + usedEdge[eI] = true; + break; + } + + face f(fOrig); + direction i(0); + + forAll(fOrig, pI) + if( !(usedEdge[pI] && usedEdge[(pI-1+fOrig.size())%fOrig.size()]) ) + { + f[i++] = fOrig[pI]; + } + + f.setSize(i); + + return f; } inline face removeEdgesFromFace @@ -150,70 +150,70 @@ inline face removeEdgesFromFace const DynList<edge>& removeEdges ) { - boolList foundEdge(fOrig.size(), false); - - forAll(removeEdges, reI) - forAll(fOrig, eI) - if( removeEdges[reI] == fOrig.faceEdge(eI) ) - { - foundEdge[eI] = true; - break; - } - - face newF(fOrig.size()); - label i(0); - - forAll(fOrig, pI) - if( !(foundEdge[pI] && foundEdge[fOrig.rcIndex(pI)]) ) - newF[i++] = fOrig[pI]; - - newF.setSize(i); - - return newF; + boolList foundEdge(fOrig.size(), false); + + forAll(removeEdges, reI) + forAll(fOrig, eI) + if( removeEdges[reI] == fOrig.faceEdge(eI) ) + { + foundEdge[eI] = true; + break; + } + + face newF(fOrig.size()); + label i(0); + + forAll(fOrig, pI) + if( !(foundEdge[pI] && foundEdge[fOrig.rcIndex(pI)]) ) + newF[i++] = fOrig[pI]; + + newF.setSize(i); + + return newF; } inline void findOpenEdges(const faceList& cellFaces, DynList<edge>& openEdges) { - DynList<edge> cellEdges(12); - DynList<label> nAppearances(12); - - forAll(cellFaces, fI) - { - const edgeList edges = cellFaces[fI].edges(); - - forAll(edges, eI) - { - const label pos = cellEdges.containsAtPosition(edges[eI]); - - if( pos == -1 ) - { - cellEdges.append(edges[eI]); - nAppearances.append(1); - } - else - { - nAppearances[pos]++; - } - } - } - - openEdges.setSize(12); - openEdges.clear(); - - forAll(nAppearances, eI) - if( nAppearances[eI] == 1 ) - { - openEdges.append(cellEdges[eI]); - } - else if( nAppearances[eI] > 2 ) - { - FatalErrorIn - ( - "void findOpenEdges(const faceList& cellFaces," - "DynList<edge>& openEdges)" - ) << "More than two faces in " << cellFaces - << " share edge " << cellEdges[eI] << abort(FatalError); - } + DynList<edge> cellEdges(12); + DynList<label> nAppearances(12); + + forAll(cellFaces, fI) + { + const edgeList edges = cellFaces[fI].edges(); + + forAll(edges, eI) + { + const label pos = cellEdges.containsAtPosition(edges[eI]); + + if( pos == -1 ) + { + cellEdges.append(edges[eI]); + nAppearances.append(1); + } + else + { + nAppearances[pos]++; + } + } + } + + openEdges.setSize(12); + openEdges.clear(); + + forAll(nAppearances, eI) + if( nAppearances[eI] == 1 ) + { + openEdges.append(cellEdges[eI]); + } + else if( nAppearances[eI] > 2 ) + { + FatalErrorIn + ( + "void findOpenEdges(const faceList& cellFaces," + "DynList<edge>& openEdges)" + ) << "More than two faces in " << cellFaces + << " share edge " << cellEdges[eI] << abort(FatalError); + } } inline bool shareAnEdge(const face& f1, const face& f2) @@ -244,13 +244,13 @@ inline edge sharedEdge(const face& f1, const face& f2) inline label positionOfEdgeInFace(const edge& e, const face& f) { - const edgeList edges = f.edges(); - - forAll(edges, eI) - if( edges[eI] == e ) - return eI; - - return -1; + const edgeList edges = f.edges(); + + forAll(edges, eI) + if( edges[eI] == e ) + return eI; + + return -1; } inline label sharedVertex(const face& f1, const face& f2) @@ -304,143 +304,143 @@ inline label sharedVertex(const faceList& fcs) inline bool areElementsInChain(const boolList& sel) { - boolList selInChain(sel.size(), false); - - forAll(sel, eI) + boolList selInChain(sel.size(), false); + + forAll(sel, eI) { - if( sel[eI] ) - { - selInChain[eI] = true; - bool found; - do - { - found = false; - forAll(selInChain, eJ) - if( - !selInChain[eJ] && sel[eJ] && - ( - selInChain[sel.fcIndex(eJ)] || - selInChain[sel.rcIndex(eJ)] - ) - ) - { - found = true; - selInChain[eJ] = true; - } - } while( found ); - - break; - } + if( sel[eI] ) + { + selInChain[eI] = true; + bool found; + do + { + found = false; + forAll(selInChain, eJ) + if( + !selInChain[eJ] && sel[eJ] && + ( + selInChain[sel.fcIndex(eJ)] || + selInChain[sel.rcIndex(eJ)] + ) + ) + { + found = true; + selInChain[eJ] = true; + } + } while( found ); + + break; + } } - - forAll(sel, eI) + + forAll(sel, eI) { - if( sel[eI] && !selInChain[eI] ) - return false; + if( sel[eI] && !selInChain[eI] ) + return false; } - - return true; + + return true; } inline void zipOpenChain(DynList<edge>& bEdges) { - //- close the chain if open - DynList<label> chainVertices(5); - List<label> nAppearances(5); - forAll(bEdges, eI) - { - const edge& e = bEdges[eI]; - forAll(e, pI) - { - const label pos = chainVertices.containsAtPosition(e[pI]); - - if( pos == -1 ) - { - nAppearances[chainVertices.size()] = 1; - chainVertices.append(e[pI]); - } - else - { - ++nAppearances[pos]; - } - } - } - - bool closed(true); - DynList<label> openVertices(2); - forAll(chainVertices, pI) - if( nAppearances[pI] == 1 ) - { - closed = false; - openVertices.append(chainVertices[pI]); - } - - if( !closed && (openVertices.size() == 2) ) - { - forAll(bEdges, eI) - if( bEdges[eI].end() == openVertices[0] ) - { - bEdges.append(edge(openVertices[0], openVertices[1])); - break; - } - else if( bEdges[eI].end() == openVertices[1] ) - { - bEdges.append(edge(openVertices[1], openVertices[0])); - break; - } - } - else if( !closed ) - { - FatalErrorIn - ( - "void dualMeshExtractor::decomposeCreatedPoly::" + //- close the chain if open + DynList<label> chainVertices(5); + List<label> nAppearances(5); + forAll(bEdges, eI) + { + const edge& e = bEdges[eI]; + forAll(e, pI) + { + const label pos = chainVertices.containsAtPosition(e[pI]); + + if( pos == -1 ) + { + nAppearances[chainVertices.size()] = 1; + chainVertices.append(e[pI]); + } + else + { + ++nAppearances[pos]; + } + } + } + + bool closed(true); + DynList<label> openVertices(2); + forAll(chainVertices, pI) + if( nAppearances[pI] == 1 ) + { + closed = false; + openVertices.append(chainVertices[pI]); + } + + if( !closed && (openVertices.size() == 2) ) + { + forAll(bEdges, eI) + if( bEdges[eI].end() == openVertices[0] ) + { + bEdges.append(edge(openVertices[0], openVertices[1])); + break; + } + else if( bEdges[eI].end() == openVertices[1] ) + { + bEdges.append(edge(openVertices[1], openVertices[0])); + break; + } + } + else if( !closed ) + { + FatalErrorIn + ( + "void dualMeshExtractor::decomposeCreatedPoly::" "createMissingFaces(List<faceList>& cFaces)" - ) << "Chain has " << openVertices << " open vertices" - << abort(FatalError); - } + ) << "Chain has " << openVertices << " open vertices" + << abort(FatalError); + } } inline labelList sortEdgeChain(const DynList<edge>& bEdges) { - boolList sorted(bEdges.size(), false); - - DynList<edge> sortedEdges; - sortedEdges.append(bEdges[0]); - sorted[0] = true; - direction i(0); - - bool finished; - do - { - finished = true; - - forAll(bEdges, eI) - if( !sorted[eI] ) - { - if( sortedEdges[i].end() == bEdges[eI].start() ) - { - sorted[eI] = true; - finished = false; - sortedEdges.append(bEdges[eI]); - ++i; - } - else if( sortedEdges[i].end() == bEdges[eI].end() ) - { - FatalErrorIn - ( - "labelList sortEdgeChain(" - "const DynList<edge>& bEdges)" - ) << "Chain is not oriented correctly!" - << abort(FatalError); - } - } - } while( !finished ); - - labelList sortPoints(bEdges.size()); - forAll(sortedEdges, eI) - sortPoints[eI] = sortedEdges[eI].start(); - - return sortPoints; + boolList sorted(bEdges.size(), false); + + DynList<edge> sortedEdges; + sortedEdges.append(bEdges[0]); + sorted[0] = true; + direction i(0); + + bool finished; + do + { + finished = true; + + forAll(bEdges, eI) + if( !sorted[eI] ) + { + if( sortedEdges[i].end() == bEdges[eI].start() ) + { + sorted[eI] = true; + finished = false; + sortedEdges.append(bEdges[eI]); + ++i; + } + else if( sortedEdges[i].end() == bEdges[eI].end() ) + { + FatalErrorIn + ( + "labelList sortEdgeChain(" + "const DynList<edge>& bEdges)" + ) << "Chain is not oriented correctly!" + << abort(FatalError); + } + } + } while( !finished ); + + labelList sortPoints(bEdges.size()); + forAll(sortedEdges, eI) + sortPoints[eI] = sortedEdges[eI].start(); + + return sortPoints; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *// diff --git a/meshLibrary/utilities/meshes/partTetMesh/partTetMesh.C b/meshLibrary/utilities/meshes/partTetMesh/partTetMesh.C index 34f195b5..0f94556f 100644 --- a/meshLibrary/utilities/meshes/partTetMesh/partTetMesh.C +++ b/meshLibrary/utilities/meshes/partTetMesh/partTetMesh.C @@ -47,89 +47,89 @@ namespace Foam partTetMesh::partTetMesh(polyMeshGen& mesh) : - origMesh_(mesh), - points_(), - tets_(), - nodeLabelInOrigMesh_(), - smoothVertex_(), - pointTets_(), + origMesh_(mesh), + points_(), + tets_(), + nodeLabelInOrigMesh_(), + smoothVertex_(), + pointTets_(), internalPointsOrderPtr_(NULL), boundaryPointsOrderPtr_(NULL), pAtProcsPtr_(NULL), globalToLocalPointAddressingPtr_(NULL), neiProcsPtr_(NULL), - pAtParallelBoundariesPtr_(NULL), + pAtParallelBoundariesPtr_(NULL), pAtBufferLayersPtr_(NULL) { - List<direction> useCell(mesh.cells().size(), direction(1)); - - createPointsAndTets(useCell); + List<direction> useCell(mesh.cells().size(), direction(1)); + + createPointsAndTets(useCell); } partTetMesh::partTetMesh ( - polyMeshGen& mesh, - labelHashSet& badFaces, - const direction additionalLayers + polyMeshGen& mesh, + labelHashSet& badFaces, + const direction additionalLayers ) : - origMesh_(mesh), - points_(), - tets_(), - nodeLabelInOrigMesh_(), - smoothVertex_(), - pointTets_(), + origMesh_(mesh), + points_(), + tets_(), + nodeLabelInOrigMesh_(), + smoothVertex_(), + pointTets_(), internalPointsOrderPtr_(NULL), boundaryPointsOrderPtr_(NULL), globalPointLabelPtr_(NULL), pAtProcsPtr_(NULL), globalToLocalPointAddressingPtr_(NULL), neiProcsPtr_(NULL), - pAtParallelBoundariesPtr_(NULL), + pAtParallelBoundariesPtr_(NULL), pAtBufferLayersPtr_(NULL) { - const faceListPMG& faces = mesh.faces(); - const cellListPMG& cells = mesh.cells(); - const VRWGraph& pointCells = mesh.addressingData().pointCells(); - - List<direction> useCell(cells.size(), direction(0)); - - //- select cells containing at least one vertex of the bad faces - forAll(faces, faceI) - if( badFaces.found(faceI) ) - { - const face& f = faces[faceI]; - - forAll(f, pI) - { - forAllRow(pointCells, f[pI], pcI) - useCell[pointCells(f[pI], pcI)] = 1; - } - } - - //- add additional layer of cells - for(label layerI=1;layerI<(additionalLayers+1);++layerI) - { - forAll(useCell, cI) - if( useCell[cI] == layerI ) - { - const cell& c = cells[cI]; - - forAll(c, fI) - { - const face& f = faces[c[fI]]; - - forAll(f, pI) - { - forAllRow(pointCells, f[pI], pcI) - { - const label cLabel = pointCells(f[pI], pcI); - if( !useCell[cLabel] ) - useCell[cLabel] = layerI + 1; - } - } - } - } + const faceListPMG& faces = mesh.faces(); + const cellListPMG& cells = mesh.cells(); + const VRWGraph& pointCells = mesh.addressingData().pointCells(); + + List<direction> useCell(cells.size(), direction(0)); + + //- select cells containing at least one vertex of the bad faces + forAll(faces, faceI) + if( badFaces.found(faceI) ) + { + const face& f = faces[faceI]; + + forAll(f, pI) + { + forAllRow(pointCells, f[pI], pcI) + useCell[pointCells(f[pI], pcI)] = 1; + } + } + + //- add additional layer of cells + for(label layerI=1;layerI<(additionalLayers+1);++layerI) + { + forAll(useCell, cI) + if( useCell[cI] == layerI ) + { + const cell& c = cells[cI]; + + forAll(c, fI) + { + const face& f = faces[c[fI]]; + + forAll(f, pI) + { + forAllRow(pointCells, f[pI], pcI) + { + const label cLabel = pointCells(f[pI], pcI); + if( !useCell[cLabel] ) + useCell[cLabel] = layerI + 1; + } + } + } + } if( Pstream::parRun() ) { @@ -183,9 +183,9 @@ partTetMesh::partTetMesh } } } - } - - createPointsAndTets(useCell); + } + + createPointsAndTets(useCell); } partTetMesh::~partTetMesh() @@ -196,7 +196,7 @@ partTetMesh::~partTetMesh() deleteDemandDrivenData(pAtProcsPtr_); deleteDemandDrivenData(globalToLocalPointAddressingPtr_); deleteDemandDrivenData(neiProcsPtr_); - deleteDemandDrivenData(pAtParallelBoundariesPtr_); + deleteDemandDrivenData(pAtParallelBoundariesPtr_); deleteDemandDrivenData(pAtBufferLayersPtr_); } @@ -383,30 +383,30 @@ void partTetMesh::updateVerticesSMP(const List<LongList<labelledPoint> >& np) void partTetMesh::updateOrigMesh(boolList* changedFacePtr) { - pointFieldPMG& pts = origMesh_.points(); + pointFieldPMG& pts = origMesh_.points(); - boolList changedNode(pts.size(), false); + boolList changedNode(pts.size(), false); # pragma omp parallel for if( pts.size() > 1000 ) \ schedule(guided, 10) - forAll(nodeLabelInOrigMesh_, pI) - if( nodeLabelInOrigMesh_[pI] != -1 ) - { - changedNode[nodeLabelInOrigMesh_[pI]] = true; - pts[nodeLabelInOrigMesh_[pI]] = points_[pI]; - } - - if( changedFacePtr ) - { - boolList& chF = *changedFacePtr; - chF = false; - + forAll(nodeLabelInOrigMesh_, pI) + if( nodeLabelInOrigMesh_[pI] != -1 ) + { + changedNode[nodeLabelInOrigMesh_[pI]] = true; + pts[nodeLabelInOrigMesh_[pI]] = points_[pI]; + } + + if( changedFacePtr ) + { + boolList& chF = *changedFacePtr; + chF = false; + const cellListPMG& cells = origMesh_.cells(); const VRWGraph& pointCells = origMesh_.addressingData().pointCells(); # pragma omp parallel for if( pointCells.size() > 100 ) \ schedule(dynamic, 20) - forAll(pointCells, pointI) + forAll(pointCells, pointI) { if( changedNode[pointI] ) { @@ -460,64 +460,64 @@ void partTetMesh::updateOrigMesh(boolList* changedFacePtr) forAll(receivedData, i) chF[start+receivedData[i]] = true; } - + //- update geometry information - const_cast<polyMeshGenAddressing&> - ( - origMesh_.addressingData() - ).updateGeometry(chF); - } - else - { - const_cast<polyMeshGenAddressing&> - ( - origMesh_.addressingData() - ).clearGeom(); - } + const_cast<polyMeshGenAddressing&> + ( + origMesh_.addressingData() + ).updateGeometry(chF); + } + else + { + const_cast<polyMeshGenAddressing&> + ( + origMesh_.addressingData() + ).clearGeom(); + } } void partTetMesh::createPolyMesh(polyMeshGen& pmg) const { - polyMeshGenModifier meshModifier(pmg); - - pointFieldPMG& pAccess = meshModifier.pointsAccess(); - pAccess.setSize(points_.size()); - forAll(points_, pI) - pAccess[pI] = points_[pI]; - - VRWGraphList cellFaces; - - forAll(tets_, tetI) - { - const partTet& tet = tets_[tetI]; - - FixedList<FixedList<label, 3>, 4> tetFaces; + polyMeshGenModifier meshModifier(pmg); + + pointFieldPMG& pAccess = meshModifier.pointsAccess(); + pAccess.setSize(points_.size()); + forAll(points_, pI) + pAccess[pI] = points_[pI]; + + VRWGraphList cellFaces; + + forAll(tets_, tetI) + { + const partTet& tet = tets_[tetI]; + + FixedList<FixedList<label, 3>, 4> tetFaces; - //- face 0 - tetFaces[0][0] = tet[0]; - tetFaces[0][1] = tet[2]; - tetFaces[0][2] = tet[1]; - - //- face 1 - tetFaces[1][0] = tet[0]; - tetFaces[1][1] = tet[1]; - tetFaces[1][2] = tet[3]; - - //- face 2 - tetFaces[2][0] = tet[0]; - tetFaces[2][1] = tet[3]; - tetFaces[2][2] = tet[2]; - - //- face 3 - tetFaces[3][0] = tet[1]; - tetFaces[3][1] = tet[2]; - tetFaces[3][2] = tet[3]; + //- face 0 + tetFaces[0][0] = tet[0]; + tetFaces[0][1] = tet[2]; + tetFaces[0][2] = tet[1]; + + //- face 1 + tetFaces[1][0] = tet[0]; + tetFaces[1][1] = tet[1]; + tetFaces[1][2] = tet[3]; + + //- face 2 + tetFaces[2][0] = tet[0]; + tetFaces[2][1] = tet[3]; + tetFaces[2][2] = tet[2]; + + //- face 3 + tetFaces[3][0] = tet[1]; + tetFaces[3][1] = tet[2]; + tetFaces[3][2] = tet[3]; cellFaces.appendGraph(tetFaces); - } - - meshModifier.addCells(cellFaces); - meshModifier.reorderBoundaryFaces(); + } + + meshModifier.addCells(cellFaces); + meshModifier.reorderBoundaryFaces(); //- store points into subsets const label bndPointID = pmg.addPointSubset("boundaryPoints"); diff --git a/meshLibrary/utilities/meshes/partTetMesh/partTetMesh.H b/meshLibrary/utilities/meshes/partTetMesh/partTetMesh.H index 656ec946..4a5dc59b 100644 --- a/meshLibrary/utilities/meshes/partTetMesh/partTetMesh.H +++ b/meshLibrary/utilities/meshes/partTetMesh/partTetMesh.H @@ -60,24 +60,24 @@ class VRWGraph; class partTetMesh { - // Private data + // Private data //- reference to the original mesh - polyMeshGen& origMesh_; - + polyMeshGen& origMesh_; + //- points in the tet mesh - LongList<point> points_; - + LongList<point> points_; + //- tetrahedra making the mesh - LongList<partTet> tets_; - + LongList<partTet> tets_; + //- label of node in the polyMeshGen - labelListPMG nodeLabelInOrigMesh_; - + labelListPMG nodeLabelInOrigMesh_; + //- shall a node be used for smoothing or not - LongList<direction> smoothVertex_; - - //- addressing data - VRWGraph pointTets_; + LongList<direction> smoothVertex_; + + //- addressing data + VRWGraph pointTets_; //- internal point ordering for parallel runs mutable VRWGraph* internalPointsOrderPtr_; @@ -97,17 +97,17 @@ class partTetMesh //- processors which should communicate with the current one mutable DynList<label>* neiProcsPtr_; - - //- labels of points at parallel boundaries - mutable labelListPMG* pAtParallelBoundariesPtr_; + + //- labels of points at parallel boundaries + mutable labelListPMG* pAtParallelBoundariesPtr_; //- labels of points serving as buffer layers on other processors mutable labelListPMG* pAtBufferLayersPtr_; - - // Private member functions - - //- create points and tets - void createPointsAndTets(const List<direction>&); + + // Private member functions + + //- create points and tets + void createPointsAndTets(const List<direction>&); //- create parallel addressing void createParallelAddressing @@ -125,21 +125,21 @@ class partTetMesh //- create order of boundary points for parallel execution void createBOUNDARYPointsOrdering() const; - + public: - - // Constructors - //- construct from polyMeshGen - partTetMesh(polyMeshGen& mesh); - - //- construct from polyMeshGen, bad faces and the number - //- of additional layers - partTetMesh - ( - polyMeshGen& mesh, - labelHashSet& badFaces, - const direction additionalLayers = 0 - ); + + // Constructors + //- construct from polyMeshGen + partTetMesh(polyMeshGen& mesh); + + //- construct from polyMeshGen, bad faces and the number + //- of additional layers + partTetMesh + ( + polyMeshGen& mesh, + labelHashSet& badFaces, + const direction additionalLayers = 0 + ); // Enumerators @@ -153,35 +153,35 @@ public: BOUNDARY = 16 }; - // Destructor - ~partTetMesh(); - - // Member functions - //- access to points, tets and other data + // Destructor + ~partTetMesh(); + + // Member functions + //- access to points, tets and other data inline const LongList<point>& points() const { return points_; } - - inline const LongList<partTet>& tets() const - { - return tets_; - } - - inline const VRWGraph& pointTets() const - { - return pointTets_; - } - - inline const LongList<direction>& smoothVertex() const - { - return smoothVertex_; - } - - inline const labelListPMG& nodeLabelInOrigMesh() const - { - return nodeLabelInOrigMesh_; - } + + inline const LongList<partTet>& tets() const + { + return tets_; + } + + inline const VRWGraph& pointTets() const + { + return pointTets_; + } + + inline const LongList<direction>& smoothVertex() const + { + return smoothVertex_; + } + + inline const labelListPMG& nodeLabelInOrigMesh() const + { + return nodeLabelInOrigMesh_; + } // Access to point ordering for Gauss-Seidel type of iteration //- return vertex ordering which can be executed in parallel @@ -225,23 +225,23 @@ public: return *neiProcsPtr_; } - - inline const labelListPMG& pointsAtProcessorBoundaries() const - { - if( !Pstream::parRun() ) - FatalError << "This is a serial run" << abort(FatalError); - - return *pAtParallelBoundariesPtr_; - } + + inline const labelListPMG& pointsAtProcessorBoundaries() const + { + if( !Pstream::parRun() ) + FatalError << "This is a serial run" << abort(FatalError); + + return *pAtParallelBoundariesPtr_; + } inline const labelListPMG& bufferLayerPoints() const { if( !Pstream::parRun() ) - FatalError << "This is a serial run" << abort(FatalError); + FatalError << "This is a serial run" << abort(FatalError); return *pAtBufferLayersPtr_; } - + // Modifiers //- move the vertex to a new position @@ -252,10 +252,10 @@ public: void updateVerticesSMP(const List<LongList<labelledPoint> >&); //- updates the vertices of the original polyMeshGen - void updateOrigMesh(boolList* changedFacePtr = NULL); - + void updateOrigMesh(boolList* changedFacePtr = NULL); + //- creates polyMeshGen from this partTetMesh - void createPolyMesh(polyMeshGen& pmg) const; + void createPolyMesh(polyMeshGen& pmg) const; }; // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/meshLibrary/utilities/meshes/partTetMesh/partTetMeshAddressing.C b/meshLibrary/utilities/meshes/partTetMesh/partTetMeshAddressing.C index 99b93537..3370f276 100644 --- a/meshLibrary/utilities/meshes/partTetMesh/partTetMeshAddressing.C +++ b/meshLibrary/utilities/meshes/partTetMesh/partTetMeshAddressing.C @@ -39,16 +39,16 @@ Description namespace Foam { - + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - + void partTetMesh::createPointsAndTets(const List<direction>& useCell) { - const pointFieldPMG& points = origMesh_.points(); - const faceListPMG& faces = origMesh_.faces(); - const cellListPMG& cells = origMesh_.cells(); - const labelList& owner = origMesh_.owner(); - const labelList& neighbour = origMesh_.neighbour(); + const pointFieldPMG& points = origMesh_.points(); + const faceListPMG& faces = origMesh_.faces(); + const cellListPMG& cells = origMesh_.cells(); + const labelList& owner = origMesh_.owner(); + const labelList& neighbour = origMesh_.neighbour(); const PtrList<writePatch>& boundaries = origMesh_.boundaries(); const PtrList<writeProcessorPatch>& procBoundaries = origMesh_.procBoundaries(); @@ -110,14 +110,14 @@ void partTetMesh::createPointsAndTets(const List<direction>& useCell) forAll(receivedData, faceI) ++usedFace[start+receivedData[faceI]]; } - - const vectorField& faceCentres = origMesh_.addressingData().faceCentres(); - const vectorField& cellCentres = origMesh_.addressingData().cellCentres(); - - labelListPMG nodeLabelForPoint(points.size(), -1); - labelListPMG nodeLabelForFace(faces.size(), -1); - labelListPMG nodeLabelForCell(cells.size(), -1); - + + const vectorField& faceCentres = origMesh_.addressingData().faceCentres(); + const vectorField& cellCentres = origMesh_.addressingData().cellCentres(); + + labelListPMG nodeLabelForPoint(points.size(), -1); + labelListPMG nodeLabelForFace(faces.size(), -1); + labelListPMG nodeLabelForCell(cells.size(), -1); + points_.clear(); smoothVertex_.clear(); @@ -237,10 +237,10 @@ void partTetMesh::createPointsAndTets(const List<direction>& useCell) //- create tets tetMatcher tet; - forAll(useCell, cI) - if( useCell[cI] ) - { - const cell& c = cells[cI]; + forAll(useCell, cI) + if( useCell[cI] ) + { + const cell& c = cells[cI]; if( tet.matchShape(false, faces, owner, cI, cells[cI]) ) { @@ -260,110 +260,110 @@ void partTetMesh::createPointsAndTets(const List<direction>& useCell) continue; } - - nodeLabelForCell[cI] = points_.size(); - const label centreLabel = points_.size(); + + nodeLabelForCell[cI] = points_.size(); + const label centreLabel = points_.size(); points_.append(cellCentres[cI]); smoothVertex_.append(CELLCENTRE); - - forAll(c, fI) - { - const face& f = faces[c[fI]]; - - if( owner[c[fI]] == cI ) - { - if( f.size() == 3 ) - { - partTet tet - ( - nodeLabelForPoint[f[0]], - nodeLabelForPoint[f[2]], - nodeLabelForPoint[f[1]], - centreLabel - ); - - # ifdef DEBUGSmooth - Info << "1.1 Tet " << tets_.size() << " is " - << tet << endl; - # endif - - tets_.append(tet); - } - else - { - forAll(f, pI) - { - partTet tet - ( - nodeLabelForPoint[f[pI]], - nodeLabelForPoint[f.prevLabel(pI)], - nodeLabelForFace[c[fI]], - centreLabel - ); - - # ifdef DEBUGSmooth - Info << "1.2 Tet " << tets_.size() << " is " - << tet << endl; - # endif - - tets_.append(tet); - } - } - } - else - { - if( f.size() == 3 ) - { - partTet tet - ( - nodeLabelForPoint[f[0]], - nodeLabelForPoint[f[1]], - nodeLabelForPoint[f[2]], - centreLabel - ); - - # ifdef DEBUGSmooth - Info << "2.1 Tet " << tets_.size() << " is " - << tet << endl; - # endif - - tets_.append(tet); - } - else - { - forAll(f, pI) - { - partTet tet - ( - nodeLabelForPoint[f[pI]], - nodeLabelForPoint[f.nextLabel(pI)], - nodeLabelForFace[c[fI]], - centreLabel - ); - - # ifdef DEBUGSmooth - Info << "2.2 Tet " << tets_.size() << " is " - << tet << endl; - # endif - - tets_.append(tet); - } - } - } - } - } - - //- create node labels in origMesh_ - nodeLabelInOrigMesh_.setSize(points_.size()); - nodeLabelInOrigMesh_ = -1; - forAll(nodeLabelForPoint, pI) - if( nodeLabelForPoint[pI] != -1 ) - { - nodeLabelInOrigMesh_[nodeLabelForPoint[pI]] = pI; - } - - //- create pointTets_ - pointTets_.reverseAddressing(points_.size(), tets_); + + forAll(c, fI) + { + const face& f = faces[c[fI]]; + + if( owner[c[fI]] == cI ) + { + if( f.size() == 3 ) + { + partTet tet + ( + nodeLabelForPoint[f[0]], + nodeLabelForPoint[f[2]], + nodeLabelForPoint[f[1]], + centreLabel + ); + + # ifdef DEBUGSmooth + Info << "1.1 Tet " << tets_.size() << " is " + << tet << endl; + # endif + + tets_.append(tet); + } + else + { + forAll(f, pI) + { + partTet tet + ( + nodeLabelForPoint[f[pI]], + nodeLabelForPoint[f.prevLabel(pI)], + nodeLabelForFace[c[fI]], + centreLabel + ); + + # ifdef DEBUGSmooth + Info << "1.2 Tet " << tets_.size() << " is " + << tet << endl; + # endif + + tets_.append(tet); + } + } + } + else + { + if( f.size() == 3 ) + { + partTet tet + ( + nodeLabelForPoint[f[0]], + nodeLabelForPoint[f[1]], + nodeLabelForPoint[f[2]], + centreLabel + ); + + # ifdef DEBUGSmooth + Info << "2.1 Tet " << tets_.size() << " is " + << tet << endl; + # endif + + tets_.append(tet); + } + else + { + forAll(f, pI) + { + partTet tet + ( + nodeLabelForPoint[f[pI]], + nodeLabelForPoint[f.nextLabel(pI)], + nodeLabelForFace[c[fI]], + centreLabel + ); + + # ifdef DEBUGSmooth + Info << "2.2 Tet " << tets_.size() << " is " + << tet << endl; + # endif + + tets_.append(tet); + } + } + } + } + } + + //- create node labels in origMesh_ + nodeLabelInOrigMesh_.setSize(points_.size()); + nodeLabelInOrigMesh_ = -1; + forAll(nodeLabelForPoint, pI) + if( nodeLabelForPoint[pI] != -1 ) + { + nodeLabelInOrigMesh_[nodeLabelForPoint[pI]] = pI; + } + + //- create pointTets_ + pointTets_.reverseAddressing(points_.size(), tets_); //- create addressing for parallel runs if( Pstream::parRun() ) @@ -377,19 +377,19 @@ void partTetMesh::createPointsAndTets(const List<direction>& useCell) createBufferLayers(); } - - # ifdef DEBUGSmooth - forAll(nodeLabelInOrigMesh_, pI) - if( - (nodeLabelInOrigMesh_[pI] != -1) && - (mag(points_[pI] - points[nodeLabelInOrigMesh_[pI]]) > SMALL) - ) - FatalErrorIn - ( - "void partTetMesh::createPointsAndTets" - "(const boolList& useCell)" - ) << "Node " << pI << " is dislocated" << abort(FatalError); - # endif + + # ifdef DEBUGSmooth + forAll(nodeLabelInOrigMesh_, pI) + if( + (nodeLabelInOrigMesh_[pI] != -1) && + (mag(points_[pI] - points[nodeLabelInOrigMesh_[pI]]) > SMALL) + ) + FatalErrorIn + ( + "void partTetMesh::createPointsAndTets" + "(const boolList& useCell)" + ) << "Node " << pI << " is dislocated" << abort(FatalError); + # endif } void partTetMesh::createSMOOTHPointsOrdering() const diff --git a/meshLibrary/utilities/meshes/partTetMesh/partTetMeshParallelAddressing.C b/meshLibrary/utilities/meshes/partTetMesh/partTetMeshParallelAddressing.C index c4d9c1e6..6454d85f 100644 --- a/meshLibrary/utilities/meshes/partTetMesh/partTetMeshParallelAddressing.C +++ b/meshLibrary/utilities/meshes/partTetMesh/partTetMeshParallelAddressing.C @@ -41,7 +41,7 @@ Description namespace Foam { - + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // void partTetMesh::createParallelAddressing @@ -75,10 +75,10 @@ void partTetMesh::createParallelAddressing globalToLocal.clear(); //- allocate storage for points at parallel boundaries - if( !pAtParallelBoundariesPtr_ ) - pAtParallelBoundariesPtr_ = new labelListPMG(); - labelListPMG& pAtParallelBoundaries = *pAtParallelBoundariesPtr_; - pAtParallelBoundaries.clear(); + if( !pAtParallelBoundariesPtr_ ) + pAtParallelBoundariesPtr_ = new labelListPMG(); + labelListPMG& pAtParallelBoundaries = *pAtParallelBoundariesPtr_; + pAtParallelBoundaries.clear(); //- create point-processors addressing std::map<label, labelListPMG> exchangeData; @@ -232,13 +232,13 @@ void partTetMesh::createParallelAddressing //- create global to local mapping forAll(globalTetPointLabel, pI) - { + { if( pProcs.sizeOfRow(pI) != 0 ) - { - pAtParallelBoundaries.append(pI); + { + pAtParallelBoundaries.append(pI); globalToLocal.insert(globalTetPointLabel[pI], pI); - } - } + } + } //- mark vertices at parallel boundaries forAll(smoothVertex_, pI) diff --git a/meshLibrary/utilities/meshes/partTetMesh/partTetMeshSimplex.C b/meshLibrary/utilities/meshes/partTetMesh/partTetMeshSimplex.C index f0446181..d07b1a7b 100644 --- a/meshLibrary/utilities/meshes/partTetMesh/partTetMeshSimplex.C +++ b/meshLibrary/utilities/meshes/partTetMesh/partTetMeshSimplex.C @@ -70,66 +70,66 @@ partTetMeshSimplex::partTetMeshSimplex } # ifdef DEBUGSmooth - Info << "Tet " << tetI << " is " << tet << endl; - # endif - - const label pos = tet.whichPosition(pI); - switch( pos ) - { - case 0: - { - tets_[tetI] = - partTet - ( - addr[tet.b()], - addr[tet.d()], - addr[tet.c()], - addr[tet.a()] - ); - } break; - case 1: - { - tets_[tetI] = - partTet - ( - addr[tet.a()], - addr[tet.c()], - addr[tet.d()], - addr[tet.b()] - ); - } break; - case 2: - { - tets_[tetI] = - partTet - ( - addr[tet.a()], - addr[tet.d()], - addr[tet.b()], - addr[tet.c()] - ); - } break; - case 3: - { - tets_[tetI] = - partTet - ( - addr[tet.a()], - addr[tet.b()], - addr[tet.c()], - addr[tet.d()] - ); - } break; - default: - { - FatalErrorIn - ( - "partTetMeshSimplex::partTetMeshSimplex(" + Info << "Tet " << tetI << " is " << tet << endl; + # endif + + const label pos = tet.whichPosition(pI); + switch( pos ) + { + case 0: + { + tets_[tetI] = + partTet + ( + addr[tet.b()], + addr[tet.d()], + addr[tet.c()], + addr[tet.a()] + ); + } break; + case 1: + { + tets_[tetI] = + partTet + ( + addr[tet.a()], + addr[tet.c()], + addr[tet.d()], + addr[tet.b()] + ); + } break; + case 2: + { + tets_[tetI] = + partTet + ( + addr[tet.a()], + addr[tet.d()], + addr[tet.b()], + addr[tet.c()] + ); + } break; + case 3: + { + tets_[tetI] = + partTet + ( + addr[tet.a()], + addr[tet.b()], + addr[tet.c()], + addr[tet.d()] + ); + } break; + default: + { + FatalErrorIn + ( + "partTetMeshSimplex::partTetMeshSimplex(" "(const partTetMesh& tm, const label pI)" - ) << "Point " << pI << " is not present in tet" << tet - << abort(FatalError); - } - } + ) << "Point " << pI << " is not present in tet" << tet + << abort(FatalError); + } + } } } @@ -163,63 +163,63 @@ partTetMeshSimplex::partTetMeshSimplex if( tet[i].pointLabel() == gpI ) pos = i; } - - switch( pos ) - { - case 0: - { - tets_[tetI] = - partTet - ( - addr[tet[1].pointLabel()], - addr[tet[3].pointLabel()], - addr[tet[2].pointLabel()], - addr[tet[0].pointLabel()] - ); - } break; - case 1: - { - tets_[tetI] = - partTet - ( - addr[tet[0].pointLabel()], - addr[tet[2].pointLabel()], - addr[tet[3].pointLabel()], - addr[tet[1].pointLabel()] - ); - } break; - case 2: - { - tets_[tetI] = - partTet - ( - addr[tet[0].pointLabel()], - addr[tet[3].pointLabel()], - addr[tet[1].pointLabel()], - addr[tet[2].pointLabel()] - ); - } break; - case 3: - { - tets_[tetI] = - partTet - ( - addr[tet[0].pointLabel()], - addr[tet[1].pointLabel()], - addr[tet[2].pointLabel()], - addr[tet[3].pointLabel()] - ); - } break; - default: - { - FatalErrorIn - ( - "partTetMeshSimplex::partTetMeshSimplex(" + + switch( pos ) + { + case 0: + { + tets_[tetI] = + partTet + ( + addr[tet[1].pointLabel()], + addr[tet[3].pointLabel()], + addr[tet[2].pointLabel()], + addr[tet[0].pointLabel()] + ); + } break; + case 1: + { + tets_[tetI] = + partTet + ( + addr[tet[0].pointLabel()], + addr[tet[2].pointLabel()], + addr[tet[3].pointLabel()], + addr[tet[1].pointLabel()] + ); + } break; + case 2: + { + tets_[tetI] = + partTet + ( + addr[tet[0].pointLabel()], + addr[tet[3].pointLabel()], + addr[tet[1].pointLabel()], + addr[tet[2].pointLabel()] + ); + } break; + case 3: + { + tets_[tetI] = + partTet + ( + addr[tet[0].pointLabel()], + addr[tet[1].pointLabel()], + addr[tet[2].pointLabel()], + addr[tet[3].pointLabel()] + ); + } break; + default: + { + FatalErrorIn + ( + "partTetMeshSimplex::partTetMeshSimplex(" "(const partTetMesh& tm, const label pI)" - ) << "Point " << gpI << " is not present in tet" << tet - << abort(FatalError); - } - } + ) << "Point " << gpI << " is not present in tet" << tet + << abort(FatalError); + } + } } } diff --git a/meshLibrary/utilities/meshes/polyMeshGen/polyMeshGen.C b/meshLibrary/utilities/meshes/polyMeshGen/polyMeshGen.C index 1b7b4ef2..003796cb 100644 --- a/meshLibrary/utilities/meshes/polyMeshGen/polyMeshGen.C +++ b/meshLibrary/utilities/meshes/polyMeshGen/polyMeshGen.C @@ -31,7 +31,7 @@ Description namespace Foam { - + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // polyMeshGen::polyMeshGen(const Time& t) @@ -77,7 +77,7 @@ polyMeshGen::polyMeshGen ) { } - + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // Destructor polyMeshGen::~polyMeshGen() diff --git a/meshLibrary/utilities/meshes/polyMeshGen/polyMeshGen.H b/meshLibrary/utilities/meshes/polyMeshGen/polyMeshGen.H index ca0e3933..0a9c9ef1 100644 --- a/meshLibrary/utilities/meshes/polyMeshGen/polyMeshGen.H +++ b/meshLibrary/utilities/meshes/polyMeshGen/polyMeshGen.H @@ -50,29 +50,29 @@ class polyMeshGen public: // Constructors - //- Null constructor - polyMeshGen(const Time& t); - - //- Construct from components without the boundary - polyMeshGen - ( - const Time& t, - const pointField& points, - const faceList& faces, - const cellList& cells - ); - - //- Construct from components with the boundary - polyMeshGen - ( - const Time& t, - const pointField& points, - const faceList& faces, - const cellList& cells, - const wordList& patchNames, - const labelList& patchStart, - const labelList& nFacesInPatch - ); + //- Null constructor + polyMeshGen(const Time& t); + + //- Construct from components without the boundary + polyMeshGen + ( + const Time& t, + const pointField& points, + const faceList& faces, + const cellList& cells + ); + + //- Construct from components with the boundary + polyMeshGen + ( + const Time& t, + const pointField& points, + const faceList& faces, + const cellList& cells, + const wordList& patchNames, + const labelList& patchStart, + const labelList& nFacesInPatch + ); // Destructor diff --git a/meshLibrary/utilities/meshes/polyMeshGen/polyMeshGenFaces.C b/meshLibrary/utilities/meshes/polyMeshGen/polyMeshGenFaces.C index 4f53cc86..936a9ac2 100644 --- a/meshLibrary/utilities/meshes/polyMeshGen/polyMeshGenFaces.C +++ b/meshLibrary/utilities/meshes/polyMeshGen/polyMeshGenFaces.C @@ -40,94 +40,94 @@ namespace Foam void polyMeshGenFaces::clearOut() const { - deleteDemandDrivenData(ownerPtr_); - deleteDemandDrivenData(neighbourPtr_); + deleteDemandDrivenData(ownerPtr_); + deleteDemandDrivenData(neighbourPtr_); } - + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // Constructors //- Null constructor polyMeshGenFaces::polyMeshGenFaces(const Time& runTime) : - polyMeshGenPoints(runTime), - faces_ - ( - IOobject - ( - "faces", - runTime.constant(), - "polyMesh", - runTime - ), - 0 - ), + polyMeshGenPoints(runTime), + faces_ + ( + IOobject + ( + "faces", + runTime.constant(), + "polyMesh", + runTime + ), + 0 + ), procBoundaries_(), - boundaries_(), + boundaries_(), faceSubsets_(), - nIntFaces_(0), - ownerPtr_(NULL), - neighbourPtr_(NULL) + nIntFaces_(0), + ownerPtr_(NULL), + neighbourPtr_(NULL) { } //- Construct from components without the boundary polyMeshGenFaces::polyMeshGenFaces ( - const Time& runTime, - const pointField& points, - const faceList& faces + const Time& runTime, + const pointField& points, + const faceList& faces ) : - polyMeshGenPoints(runTime, points), - faces_ - ( - IOobject - ( - "faces", - runTime.constant(), - "polyMesh", - runTime - ), - faces - ), + polyMeshGenPoints(runTime, points), + faces_ + ( + IOobject + ( + "faces", + runTime.constant(), + "polyMesh", + runTime + ), + faces + ), procBoundaries_(), - boundaries_(), + boundaries_(), faceSubsets_(), - nIntFaces_(0), - ownerPtr_(NULL), - neighbourPtr_(NULL) + nIntFaces_(0), + ownerPtr_(NULL), + neighbourPtr_(NULL) { } //- Construct from components with the boundary polyMeshGenFaces::polyMeshGenFaces ( - const Time& runTime, - const pointField& points, - const faceList& faces, - const wordList& patchNames, - const labelList& patchStart, - const labelList& nFacesInPatch + const Time& runTime, + const pointField& points, + const faceList& faces, + const wordList& patchNames, + const labelList& patchStart, + const labelList& nFacesInPatch ) : - polyMeshGenPoints(runTime, points), - faces_ - ( - IOobject - ( - "faces", - runTime.constant(), - "polyMesh", - runTime - ), - faces - ), + polyMeshGenPoints(runTime, points), + faces_ + ( + IOobject + ( + "faces", + runTime.constant(), + "polyMesh", + runTime + ), + faces + ), procBoundaries_(), - boundaries_(), + boundaries_(), faceSubsets_(), - nIntFaces_(0), - ownerPtr_(NULL), - neighbourPtr_(NULL) + nIntFaces_(0), + ownerPtr_(NULL), + neighbourPtr_(NULL) { if( Pstream::parRun() ) FatalErrorIn @@ -141,28 +141,28 @@ polyMeshGenFaces::polyMeshGenFaces "const labelList& nFacesInPatch)" ) << "Cannot do this in parallel!" << exit(FatalError); - boundaries_.setSize(patchNames.size()); - forAll(patchNames, patchI) - { - boundaries_.set - ( - patchI, - new writePatch - ( - patchNames[patchI], - "patch", - nFacesInPatch[patchI], - patchStart[patchI] - ) - ); - } + boundaries_.setSize(patchNames.size()); + forAll(patchNames, patchI) + { + boundaries_.set + ( + patchI, + new writePatch + ( + patchNames[patchI], + "patch", + nFacesInPatch[patchI], + patchStart[patchI] + ) + ); + } } - + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // Destructor polyMeshGenFaces::~polyMeshGenFaces() { - clearOut(); + clearOut(); } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -183,10 +183,10 @@ label polyMeshGenFaces::faceIsInProcPatch(const label faceLabel) const return -1; forAllReverse(procBoundaries_, patchI) - if( faceLabel >= procBoundaries_[patchI].patchStart() ) - return patchI; + if( faceLabel >= procBoundaries_[patchI].patchStart() ) + return patchI; - return -1; + return -1; } label polyMeshGenFaces::faceIsInPatch(const label faceLabel) const @@ -195,11 +195,11 @@ label polyMeshGenFaces::faceIsInPatch(const label faceLabel) const if( faceLabel >= (boundaries_[i].patchStart()+boundaries_[i].patchSize()) ) return -1; - forAllReverse(boundaries_, patchI) - if( faceLabel >= boundaries_[patchI].patchStart() ) - return patchI; + forAllReverse(boundaries_, patchI) + if( faceLabel >= boundaries_[patchI].patchStart() ) + return patchI; - return -1; + return -1; } label polyMeshGenFaces::addFaceSubset(const word& setName) @@ -270,62 +270,62 @@ void polyMeshGenFaces::read() polyMeshGenPoints::read(); faceIOList fcs - ( - IOobject - ( - "faces", - runTime_.constant(), - "polyMesh", - runTime_, - IOobject::MUST_READ - ) - ); - faces_ = fcs; - - deleteDemandDrivenData(ownerPtr_); - deleteDemandDrivenData(neighbourPtr_); - - ownerPtr_ = - new labelIOList - ( - IOobject - ( - "owner", - runTime_.constant(), - "polyMesh", - runTime_, - IOobject::MUST_READ - ) - ); - - neighbourPtr_ = - new labelIOList - ( - IOobject - ( - "neighbour", - runTime_.constant(), - "polyMesh", - runTime_, - IOobject::MUST_READ - ) - ); + ( + IOobject + ( + "faces", + runTime_.constant(), + "polyMesh", + runTime_, + IOobject::MUST_READ + ) + ); + faces_ = fcs; + + deleteDemandDrivenData(ownerPtr_); + deleteDemandDrivenData(neighbourPtr_); + + ownerPtr_ = + new labelIOList + ( + IOobject + ( + "owner", + runTime_.constant(), + "polyMesh", + runTime_, + IOobject::MUST_READ + ) + ); + + neighbourPtr_ = + new labelIOList + ( + IOobject + ( + "neighbour", + runTime_.constant(), + "polyMesh", + runTime_, + IOobject::MUST_READ + ) + ); if( neighbourPtr_->size() != ownerPtr_->size() ) neighbourPtr_->setSize(ownerPtr_->size(), -1); - //- read boundary information - IOPtrList<writePatchBase> patches - ( - IOobject - ( - "boundary", - runTime_.constant(), - "polyMesh", - runTime_, - IOobject::MUST_READ - ) - ); + //- read boundary information + IOPtrList<writePatchBase> patches + ( + IOobject + ( + "boundary", + runTime_.constant(), + "polyMesh", + runTime_, + IOobject::MUST_READ + ) + ); label i(0); forAll(patches, patchI) @@ -333,23 +333,23 @@ void polyMeshGenFaces::read() ++i; procBoundaries_.setSize(i); - boundaries_.setSize(patches.size()-i); - + boundaries_.setSize(patches.size()-i); + i=0; - forAll(patches, patchI) + forAll(patches, patchI) if( patches[patchI].type() != "processor" ) { - boundaries_.set - ( - i, - new writePatch - ( - patches[patchI].patchName(), - patches[patchI].patchType(), - patches[patchI].patchSize(), - patches[patchI].patchStart() - ) - ); + boundaries_.set + ( + i, + new writePatch + ( + patches[patchI].patchName(), + patches[patchI].patchType(), + patches[patchI].patchSize(), + patches[patchI].patchStart() + ) + ); ++i; } @@ -368,7 +368,7 @@ void polyMeshGenFaces::read() ); } - nIntFaces_ = boundaries_[0].patchStart(); + nIntFaces_ = boundaries_[0].patchStart(); //- read face subsets IOobjectList allSets @@ -396,14 +396,14 @@ void polyMeshGenFaces::write() const polyMeshGenPoints::write(); faces_.write(); - - if( !ownerPtr_ || !neighbourPtr_ ) - calculateOwnersAndNeighbours(); - ownerPtr_->write(); - neighbourPtr_->write(); - + + if( !ownerPtr_ || !neighbourPtr_ ) + calculateOwnersAndNeighbours(); + ownerPtr_->write(); + neighbourPtr_->write(); + //- write boundary data - PtrList<writePatchBase> ptchs + PtrList<writePatchBase> ptchs ( procBoundaries_.size() + boundaries_.size() ); @@ -417,7 +417,7 @@ void polyMeshGenFaces::write() const dict.add("type", boundaries_[patchI].patchType()); dict.add("nFaces", boundaries_[patchI].patchSize()); dict.add("startFace", boundaries_[patchI].patchStart()); - ptchs.set + ptchs.set ( i++, writePatchBase::New @@ -441,22 +441,22 @@ void polyMeshGenFaces::write() const ) ); } - + IOPtrList<writePatchBase> patches - ( - IOobject - ( - "boundary", - runTime_.constant(), - "polyMesh", - runTime_, - IOobject::NO_READ, - IOobject::AUTO_WRITE - ), - ptchs - ); + ( + IOobject + ( + "boundary", + runTime_.constant(), + "polyMesh", + runTime_, + IOobject::NO_READ, + IOobject::AUTO_WRITE + ), + ptchs + ); - patches.write(); + patches.write(); //- write face subsets std::map<label, meshSubset>::const_iterator setIt; diff --git a/meshLibrary/utilities/meshes/polyMeshGen/polyMeshGenFaces.H b/meshLibrary/utilities/meshes/polyMeshGen/polyMeshGenFaces.H index caccdc47..9fdf2ee8 100644 --- a/meshLibrary/utilities/meshes/polyMeshGen/polyMeshGenFaces.H +++ b/meshLibrary/utilities/meshes/polyMeshGen/polyMeshGenFaces.H @@ -55,94 +55,94 @@ class polyMeshGenFaces protected: // Protected data - //- list of faces - faceListPMG faces_; + //- list of faces + faceListPMG faces_; //- inter-processor boundaries. These faces are located after the other //- boundary faces in the list of faces. The processor //- boundaries are internal faces in the end. PtrList<writeProcessorPatch> procBoundaries_; - - //- boundary data - PtrList<writePatch> boundaries_; + + //- boundary data + PtrList<writePatch> boundaries_; //- face subsets std::map<label, meshSubset> faceSubsets_; - - // Addressing data - //- number of internal faces, owner and neighbour - mutable label nIntFaces_; - mutable labelIOList* ownerPtr_; - mutable labelIOList* neighbourPtr_; - - // Private member functions + + // Addressing data + //- number of internal faces, owner and neighbour + mutable label nIntFaces_; + mutable labelIOList* ownerPtr_; + mutable labelIOList* neighbourPtr_; + + // Private member functions //- calculate owner and neighbour addressing virtual void calculateOwnersAndNeighbours() const = 0; - - //- clear all pointer data - void clearOut() const; - - // Disallow bitwise assignment - void operator=(const polyMeshGenFaces&); - - polyMeshGenFaces(const polyMeshGenFaces&); + + //- clear all pointer data + void clearOut() const; + + // Disallow bitwise assignment + void operator=(const polyMeshGenFaces&); + + polyMeshGenFaces(const polyMeshGenFaces&); public: - - friend class polyMeshGenModifier; - - // Constructors - //- Null constructor - polyMeshGenFaces(const Time&); - - //- Construct from components without the boundary - polyMeshGenFaces - ( - const Time&, - const pointField& points, - const faceList& faces - ); - - //- Construct from components with the boundary - polyMeshGenFaces - ( - const Time&, - const pointField& points, - const faceList& faces, - const wordList& patchNames, - const labelList& patchStart, - const labelList& nFacesInPatch - ); - - // Destructor - virtual ~polyMeshGenFaces(); - - // Member functions - - //- access to faces - inline const faceListPMG& faces() const; - - //- return number of internal faces - inline label nInternalFaces() const; - - //- owner and neighbour cells for faces - inline const labelList& owner() const; - inline const labelList& neighbour() const; - + + friend class polyMeshGenModifier; + + // Constructors + //- Null constructor + polyMeshGenFaces(const Time&); + + //- Construct from components without the boundary + polyMeshGenFaces + ( + const Time&, + const pointField& points, + const faceList& faces + ); + + //- Construct from components with the boundary + polyMeshGenFaces + ( + const Time&, + const pointField& points, + const faceList& faces, + const wordList& patchNames, + const labelList& patchStart, + const labelList& nFacesInPatch + ); + + // Destructor + virtual ~polyMeshGenFaces(); + + // Member functions + + //- access to faces + inline const faceListPMG& faces() const; + + //- return number of internal faces + inline label nInternalFaces() const; + + //- owner and neighbour cells for faces + inline const labelList& owner() const; + inline const labelList& neighbour() const; + // Boundary data //- inter-processor boundaries inline const PtrList<writeProcessorPatch>& procBoundaries() const; //- return processor patch label for the given face label - label faceIsInProcPatch(const label faceLabel) const; + label faceIsInProcPatch(const label faceLabel) const; + + //- ordinary boundaries + inline const PtrList<writePatch>& boundaries() const; - //- ordinary boundaries - inline const PtrList<writePatch>& boundaries() const; - - //- return patch label for the given face label - label faceIsInPatch(const label faceLabel) const; + //- return patch label for the given face label + label faceIsInPatch(const label faceLabel) const; // Subsets @@ -159,12 +159,12 @@ public: template<class ListType> inline void updateFaceSubsets(const ListType&); inline void updateFaceSubsets(const VRWGraph&); - - // Read mesh - void read(); - - // Write mesh - void write() const; + + // Read mesh + void read(); + + // Write mesh + void write() const; }; // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/meshLibrary/utilities/meshes/polyMeshGen/polyMeshGenFacesI.H b/meshLibrary/utilities/meshes/polyMeshGen/polyMeshGenFacesI.H index a71dc4ca..149f4f54 100644 --- a/meshLibrary/utilities/meshes/polyMeshGen/polyMeshGenFacesI.H +++ b/meshLibrary/utilities/meshes/polyMeshGen/polyMeshGenFacesI.H @@ -36,34 +36,34 @@ namespace Foam { // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - + inline const faceListPMG& polyMeshGenFaces::faces() const { - return faces_; + return faces_; } - + inline label polyMeshGenFaces::nInternalFaces() const { - if( !(ownerPtr_ && neighbourPtr_) ) - calculateOwnersAndNeighbours(); + if( !(ownerPtr_ && neighbourPtr_) ) + calculateOwnersAndNeighbours(); - return nIntFaces_; + return nIntFaces_; } inline const labelList& polyMeshGenFaces::owner() const { - if( !ownerPtr_ ) - calculateOwnersAndNeighbours(); - - return *ownerPtr_; + if( !ownerPtr_ ) + calculateOwnersAndNeighbours(); + + return *ownerPtr_; } inline const labelList& polyMeshGenFaces::neighbour() const { - if( !neighbourPtr_ ) - calculateOwnersAndNeighbours(); - - return *neighbourPtr_; + if( !neighbourPtr_ ) + calculateOwnersAndNeighbours(); + + return *neighbourPtr_; } inline const PtrList<writeProcessorPatch>& @@ -74,7 +74,7 @@ polyMeshGenFaces::procBoundaries() const inline const PtrList<writePatch>& polyMeshGenFaces::boundaries() const { - return boundaries_; + return boundaries_; } inline void polyMeshGenFaces::addFaceToSubset diff --git a/meshLibrary/utilities/meshes/polyMeshGen/polyMeshGenPoints.C b/meshLibrary/utilities/meshes/polyMeshGen/polyMeshGenPoints.C index 2c6801f3..f79b39ea 100644 --- a/meshLibrary/utilities/meshes/polyMeshGen/polyMeshGenPoints.C +++ b/meshLibrary/utilities/meshes/polyMeshGen/polyMeshGenPoints.C @@ -39,18 +39,18 @@ namespace Foam //- Null constructor polyMeshGenPoints::polyMeshGenPoints(const Time& runTime) : - runTime_(runTime), - points_ - ( - IOobject - ( - "points", - runTime.constant(), - "polyMesh", - runTime - ), - 0 - ), + runTime_(runTime), + points_ + ( + IOobject + ( + "points", + runTime.constant(), + "polyMesh", + runTime + ), + 0 + ), pointSubsets_() { } @@ -58,26 +58,26 @@ polyMeshGenPoints::polyMeshGenPoints(const Time& runTime) //- Construct from time and points polyMeshGenPoints::polyMeshGenPoints ( - const Time& runTime, - const pointField& points + const Time& runTime, + const pointField& points ) : - runTime_(runTime), - points_ - ( - IOobject - ( - "points", - runTime.constant(), - "polyMesh", - runTime - ), - points - ), + runTime_(runTime), + points_ + ( + IOobject + ( + "points", + runTime.constant(), + "polyMesh", + runTime + ), + points + ), pointSubsets_() { } - + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // Destructor polyMeshGenPoints::~polyMeshGenPoints() @@ -147,18 +147,18 @@ label polyMeshGenPoints::pointSubsetIndex(const word& subsetName) const void polyMeshGenPoints::read() { - pointIOField pts - ( - IOobject - ( - "points", - runTime_.constant(), - "polyMesh", - runTime_, - IOobject::MUST_READ - ) - ); - points_ = pts; + pointIOField pts + ( + IOobject + ( + "points", + runTime_.constant(), + "polyMesh", + runTime_, + IOobject::MUST_READ + ) + ); + points_ = pts; //- read point subsets IOobjectList allSets diff --git a/meshLibrary/utilities/meshes/polyMeshGen/polyMeshGenPoints.H b/meshLibrary/utilities/meshes/polyMeshGen/polyMeshGenPoints.H index 5ac98b6e..43fa9ea5 100644 --- a/meshLibrary/utilities/meshes/polyMeshGen/polyMeshGenPoints.H +++ b/meshLibrary/utilities/meshes/polyMeshGen/polyMeshGenPoints.H @@ -55,44 +55,44 @@ class polyMeshGenPoints protected: // Protected data - //- reference to the Time registry - const Time& runTime_; + //- reference to the Time registry + const Time& runTime_; - //- list of vertices - pointFieldPMG points_; + //- list of vertices + pointFieldPMG points_; //- map of point subsets std::map<label, meshSubset> pointSubsets_; - - // Disallow bitwise assignment - void operator=(const polyMeshGenPoints&); - - polyMeshGenPoints(const polyMeshGenPoints&); + + // Disallow bitwise assignment + void operator=(const polyMeshGenPoints&); + + polyMeshGenPoints(const polyMeshGenPoints&); public: - - friend class polyMeshGenModifier; - - // Constructors - //- Null constructor - polyMeshGenPoints(const Time&); - - //- Construct from components without the boundary - polyMeshGenPoints - ( - const Time&, - const pointField& points - ); - - // Destructor - ~polyMeshGenPoints(); - - // Member functions - //- access to Time - inline const Time& returnTime() const; - - //- access to points - inline const pointFieldPMG& points() const; + + friend class polyMeshGenModifier; + + // Constructors + //- Null constructor + polyMeshGenPoints(const Time&); + + //- Construct from components without the boundary + polyMeshGenPoints + ( + const Time&, + const pointField& points + ); + + // Destructor + ~polyMeshGenPoints(); + + // Member functions + //- access to Time + inline const Time& returnTime() const; + + //- access to points + inline const pointFieldPMG& points() const; //- non-const access to points inline pointFieldPMG& points(); @@ -113,12 +113,12 @@ public: inline void pointsInSubset(const label, ListType&) const; template<class ListType> inline void updatePointSubsets(const ListType&); - - // Read mesh - void read(); - - // Write mesh - void write() const; + + // Read mesh + void read(); + + // Write mesh + void write() const; }; // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/meshLibrary/utilities/meshes/polyMeshGen/polyMeshGenPointsI.H b/meshLibrary/utilities/meshes/polyMeshGen/polyMeshGenPointsI.H index 04931dda..bf3f04a7 100644 --- a/meshLibrary/utilities/meshes/polyMeshGen/polyMeshGenPointsI.H +++ b/meshLibrary/utilities/meshes/polyMeshGen/polyMeshGenPointsI.H @@ -39,19 +39,19 @@ namespace Foam inline const Time& polyMeshGenPoints::returnTime() const { - return runTime_; + return runTime_; } - + inline const pointFieldPMG& polyMeshGenPoints::points() const { - return points_; + return points_; } inline pointFieldPMG& polyMeshGenPoints::points() { return points_; } - + inline void polyMeshGenPoints::appendVertex(const point& p) { points_.append(p); diff --git a/meshLibrary/utilities/meshes/polyMeshGen/writePatch/writePatch.C b/meshLibrary/utilities/meshes/polyMeshGen/writePatch/writePatch.C index 2789aa3a..1035cbed 100644 --- a/meshLibrary/utilities/meshes/polyMeshGen/writePatch/writePatch.C +++ b/meshLibrary/utilities/meshes/polyMeshGen/writePatch/writePatch.C @@ -66,7 +66,7 @@ dictionary writePatch::dict() const { dictionary dict; - dict.add("type", type_); + dict.add("type", type_); dict.add("nFaces", nFaces_); dict.add("startFace", startFace_); @@ -97,12 +97,12 @@ Ostream& writePatch::operator<<(Ostream& os) const Istream& writePatch::operator>>(Istream& is) { - token t; - is >> name_ >> t; - is >> t >> type_ >> t; - is >> t >> nFaces_ >> t; - is >> t >> startFace_ >> t; - is >> t; + token t; + is >> name_ >> t; + is >> t >> type_ >> t; + is >> t >> nFaces_ >> t; + is >> t >> startFace_ >> t; + is >> t; return is; } diff --git a/meshLibrary/utilities/meshes/polyMeshGen/writePatch/writePatch.H b/meshLibrary/utilities/meshes/polyMeshGen/writePatch/writePatch.H index 1b5bd53a..fd5fce60 100644 --- a/meshLibrary/utilities/meshes/polyMeshGen/writePatch/writePatch.H +++ b/meshLibrary/utilities/meshes/polyMeshGen/writePatch/writePatch.H @@ -71,29 +71,29 @@ public: virtual autoPtr<writePatchBase> clone() const { return autoPtr<writePatchBase> - ( - new writePatch - ( - patchName(), + ( + new writePatch + ( + patchName(), patchType(), patchSize(), patchStart() - ) - ); + ) + ); } virtual autoPtr<writePatchBase> clone(const writePatch& wp) const { return autoPtr<writePatchBase> - ( - new writePatch - ( - wp.patchName(), + ( + new writePatch + ( + wp.patchName(), wp.patchType(), wp.patchSize(), wp.patchStart() - ) - ); + ) + ); } //- Return as dictionary of entries diff --git a/meshLibrary/utilities/meshes/polyMeshGen/writePatch/writePatchBase.C b/meshLibrary/utilities/meshes/polyMeshGen/writePatch/writePatchBase.C index a53cb27a..64956851 100644 --- a/meshLibrary/utilities/meshes/polyMeshGen/writePatch/writePatchBase.C +++ b/meshLibrary/utilities/meshes/polyMeshGen/writePatch/writePatchBase.C @@ -40,9 +40,9 @@ namespace Foam defineTemplateTypeNameAndDebugWithName ( - IOPtrList<writePatchBase>, - "polyBoundaryMesh", - 0 + IOPtrList<writePatchBase>, + "polyBoundaryMesh", + 0 ); defineTypeNameAndDebug(writePatchBase, 0); diff --git a/meshLibrary/utilities/meshes/polyMeshGen/writePatch/writePatchBase.H b/meshLibrary/utilities/meshes/polyMeshGen/writePatch/writePatchBase.H index 5fa92e72..76ee6f96 100644 --- a/meshLibrary/utilities/meshes/polyMeshGen/writePatch/writePatchBase.H +++ b/meshLibrary/utilities/meshes/polyMeshGen/writePatch/writePatchBase.H @@ -134,11 +134,11 @@ public: { return name_; } - - inline word& patchName() - { - return name_; - } + + inline word& patchName() + { + return name_; + } inline const word& patchType() const { diff --git a/meshLibrary/utilities/meshes/polyMeshGen/writePatch/writeProcessorPatch.C b/meshLibrary/utilities/meshes/polyMeshGen/writePatch/writeProcessorPatch.C index d9271201..b9163d9c 100644 --- a/meshLibrary/utilities/meshes/polyMeshGen/writePatch/writeProcessorPatch.C +++ b/meshLibrary/utilities/meshes/polyMeshGen/writePatch/writeProcessorPatch.C @@ -76,12 +76,12 @@ dictionary writeProcessorPatch::dict() const { dictionary dict; - dict.add("type", type_); + dict.add("type", type_); dict.add("nFaces", nFaces_); dict.add("startFace", startFace_); - dict.add("myProcNo", myProcNo_); - dict.add("neighbProcNo", neighbProcNo_); + dict.add("myProcNo", myProcNo_); + dict.add("neighbProcNo", neighbProcNo_); return dict; } @@ -112,14 +112,14 @@ Ostream& writeProcessorPatch::operator<<(Ostream& os) const Istream& writeProcessorPatch::operator>>(Istream& is) { - token t; - is >> name_ >> t; - is >> t >> type_ >> t; - is >> t >> nFaces_ >> t; - is >> t >> startFace_ >> t; + token t; + is >> name_ >> t; + is >> t >> type_ >> t; + is >> t >> nFaces_ >> t; + is >> t >> startFace_ >> t; is >> t >> myProcNo_ >> t; is >> t >> neighbProcNo_ >> t; - is >> t; + is >> t; return is; } diff --git a/meshLibrary/utilities/meshes/polyMeshGen/writePatch/writeProcessorPatch.H b/meshLibrary/utilities/meshes/polyMeshGen/writePatch/writeProcessorPatch.H index cc0924be..0a726a7b 100644 --- a/meshLibrary/utilities/meshes/polyMeshGen/writePatch/writeProcessorPatch.H +++ b/meshLibrary/utilities/meshes/polyMeshGen/writePatch/writeProcessorPatch.H @@ -77,36 +77,36 @@ public: virtual autoPtr<writePatchBase> clone() const { return autoPtr<writePatchBase> - ( - new writeProcessorPatch - ( - patchName(), + ( + new writeProcessorPatch + ( + patchName(), patchType(), patchSize(), patchStart(), myProcNo_, neighbProcNo_ - ) - ); + ) + ); } virtual autoPtr<writePatchBase> clone - ( - const writeProcessorPatch& pp - ) const + ( + const writeProcessorPatch& pp + ) const { return autoPtr<writePatchBase> - ( - new writeProcessorPatch - ( - pp.patchName(), + ( + new writeProcessorPatch + ( + pp.patchName(), pp.patchType(), pp.patchSize(), pp.patchStart(), pp.myProcNo_, pp.neighbProcNo_ - ) - ); + ) + ); } // Member functions diff --git a/meshLibrary/utilities/meshes/polyMeshGenAddressing/polyMeshGenAddressing.H b/meshLibrary/utilities/meshes/polyMeshGenAddressing/polyMeshGenAddressing.H index 8e95e0e6..2d4eb013 100644 --- a/meshLibrary/utilities/meshes/polyMeshGenAddressing/polyMeshGenAddressing.H +++ b/meshLibrary/utilities/meshes/polyMeshGenAddressing/polyMeshGenAddressing.H @@ -70,63 +70,63 @@ namespace Foam class polyMeshGenAddressing { - // Mesh data + // Mesh data //- reference to the mesh const polyMeshGenCells& mesh_; - // Shapes + // Shapes - //- Edges - mutable edgeList* edgesPtr_; + //- Edges + mutable edgeList* edgesPtr_; - // Connectivity + // Connectivity - //- Cell-cells - mutable VRWGraph* ccPtr_; + //- Cell-cells + mutable VRWGraph* ccPtr_; - //- Edge-cells - mutable VRWGraph* ecPtr_; + //- Edge-cells + mutable VRWGraph* ecPtr_; - //- Point-cells - mutable VRWGraph* pcPtr_; + //- Point-cells + mutable VRWGraph* pcPtr_; - //- Edge-faces - mutable VRWGraph* efPtr_; + //- Edge-faces + mutable VRWGraph* efPtr_; - //- Point-faces - mutable VRWGraph* pfPtr_; + //- Point-faces + mutable VRWGraph* pfPtr_; - //- Cell-edges - mutable VRWGraph* cePtr_; + //- Cell-edges + mutable VRWGraph* cePtr_; - //- Face-edges - mutable VRWGraph* fePtr_; + //- Face-edges + mutable VRWGraph* fePtr_; - //- Point-edges - mutable VRWGraph* pePtr_; + //- Point-edges + mutable VRWGraph* pePtr_; - //- Point-points - mutable VRWGraph* ppPtr_; + //- Point-points + mutable VRWGraph* ppPtr_; - //- Cell-points - mutable VRWGraph* cpPtr_; + //- Cell-points + mutable VRWGraph* cpPtr_; - // Geometric data + // Geometric data - //- Cell centres - mutable vectorField* cellCentresPtr_; + //- Cell centres + mutable vectorField* cellCentresPtr_; - //- Face centres - mutable vectorField* faceCentresPtr_; + //- Face centres + mutable vectorField* faceCentresPtr_; - //- Cell volumes - mutable scalarField* cellVolumesPtr_; + //- Cell volumes + mutable scalarField* cellVolumesPtr_; - //- Face areas - mutable vectorField* faceAreasPtr_; + //- Face areas + mutable vectorField* faceAreasPtr_; // Parallel demand driven data @@ -249,7 +249,7 @@ class polyMeshGenAddressing //- Calculate edge vectors void calcEdgeVectors() const; - // Disallow bitwise construct + // Disallow bitwise construct //- Default constructor polyMeshGenAddressing(); diff --git a/meshLibrary/utilities/meshes/polyMeshGenAddressing/polyMeshGenAddressingCellCells.C b/meshLibrary/utilities/meshes/polyMeshGenAddressing/polyMeshGenAddressingCellCells.C index c2210e9a..94724fea 100644 --- a/meshLibrary/utilities/meshes/polyMeshGenAddressing/polyMeshGenAddressingCellCells.C +++ b/meshLibrary/utilities/meshes/polyMeshGenAddressing/polyMeshGenAddressingCellCells.C @@ -46,7 +46,7 @@ void polyMeshGenAddressing::calcCellCells() const } else { - const cellListPMG& cells = mesh_.cells(); + const cellListPMG& cells = mesh_.cells(); const labelList& own = mesh_.owner(); const labelList& nei = mesh_.neighbour(); diff --git a/meshLibrary/utilities/meshes/polyMeshGenAddressing/polyMeshGenAddressingCellPoints.C b/meshLibrary/utilities/meshes/polyMeshGenAddressing/polyMeshGenAddressingCellPoints.C index 5d1c69d4..163d9ace 100644 --- a/meshLibrary/utilities/meshes/polyMeshGenAddressing/polyMeshGenAddressingCellPoints.C +++ b/meshLibrary/utilities/meshes/polyMeshGenAddressing/polyMeshGenAddressingCellPoints.C @@ -47,7 +47,7 @@ void polyMeshGenAddressing::calcCellPoints() const else { const cellListPMG& cells = mesh_.cells(); - const faceListPMG& faces = mesh_.faces(); + const faceListPMG& faces = mesh_.faces(); //- create the storage cpPtr_ = new VRWGraph(cells.size()); diff --git a/meshLibrary/utilities/meshes/polyMeshGenAddressing/polyMeshGenAddressingCentresAndAreas.C b/meshLibrary/utilities/meshes/polyMeshGenAddressing/polyMeshGenAddressingCentresAndAreas.C index 7561931e..2270a7ea 100644 --- a/meshLibrary/utilities/meshes/polyMeshGenAddressing/polyMeshGenAddressingCentresAndAreas.C +++ b/meshLibrary/utilities/meshes/polyMeshGenAddressing/polyMeshGenAddressingCentresAndAreas.C @@ -48,9 +48,9 @@ void polyMeshGenAddressing::calcFaceCentresAndAreas() const << "Face centres or face areas already calculated" << abort(FatalError); } - - const pointFieldPMG& points = mesh_.points(); - const faceListPMG& faces = mesh_.faces(); + + const pointFieldPMG& points = mesh_.points(); + const faceListPMG& faces = mesh_.faces(); faceCentresPtr_ = new vectorField(faces.size()); vectorField& fCtrs = *faceCentresPtr_; diff --git a/meshLibrary/utilities/meshes/polyMeshGenAddressing/polyMeshGenAddressingCentresAndVols.C b/meshLibrary/utilities/meshes/polyMeshGenAddressing/polyMeshGenAddressingCentresAndVols.C index 49af006a..3e6f22d5 100644 --- a/meshLibrary/utilities/meshes/polyMeshGenAddressing/polyMeshGenAddressingCentresAndVols.C +++ b/meshLibrary/utilities/meshes/polyMeshGenAddressing/polyMeshGenAddressingCentresAndVols.C @@ -50,8 +50,8 @@ void polyMeshGenAddressing::calcCellCentresAndVols() const << "Cell centres or cell volumes already calculated" << abort(FatalError); } - - const cellListPMG& cells = mesh_.cells(); + + const cellListPMG& cells = mesh_.cells(); // set the accumulated cell centre to zero vector cellCentresPtr_ = new vectorField(cells.size()); @@ -75,7 +75,7 @@ void polyMeshGenAddressing::makeCellCentresAndVols { const labelList& own = mesh_.owner(); const cellListPMG& cells = mesh_.cells(); - const label nCells = cells.size(); + const label nCells = cells.size(); # pragma omp parallel for if( nCells > 1000 ) for(label cellI=0;cellI<nCells;++cellI) diff --git a/meshLibrary/utilities/meshes/polyMeshGenAddressing/polyMeshGenAddressingPointFaces.C b/meshLibrary/utilities/meshes/polyMeshGenAddressing/polyMeshGenAddressingPointFaces.C index 9d2f4741..27b54242 100644 --- a/meshLibrary/utilities/meshes/polyMeshGenAddressing/polyMeshGenAddressingPointFaces.C +++ b/meshLibrary/utilities/meshes/polyMeshGenAddressing/polyMeshGenAddressingPointFaces.C @@ -45,7 +45,7 @@ void polyMeshGenAddressing::calcPointFaces() const else { const faceListPMG& faces = mesh_.faces(); - const label nPoints = mesh_.points().size(); + const label nPoints = mesh_.points().size(); //- create the addressing pfPtr_ = new VRWGraph(); diff --git a/meshLibrary/utilities/meshes/polyMeshGenAddressing/polyMeshGenAddressingPointPoints.C b/meshLibrary/utilities/meshes/polyMeshGenAddressing/polyMeshGenAddressingPointPoints.C index dead65b4..9dc106b4 100644 --- a/meshLibrary/utilities/meshes/polyMeshGenAddressing/polyMeshGenAddressingPointPoints.C +++ b/meshLibrary/utilities/meshes/polyMeshGenAddressing/polyMeshGenAddressingPointPoints.C @@ -50,8 +50,8 @@ void polyMeshGenAddressing::calcPointPoints() const VRWGraph& pp = *ppPtr_; const faceListPMG& faces = mesh_.faces(); - const VRWGraph& pointFaces = this->pointFaces(); - + const VRWGraph& pointFaces = this->pointFaces(); + labelList nPoints(pointFaces.size()); const label nThreads = 3 * omp_get_num_procs(); diff --git a/meshLibrary/utilities/meshes/polyMeshGenAddressing/polyMeshGenAddressingUpdateGeometry.C b/meshLibrary/utilities/meshes/polyMeshGenAddressing/polyMeshGenAddressingUpdateGeometry.C index 7b4f17ff..ff7000ab 100644 --- a/meshLibrary/utilities/meshes/polyMeshGenAddressing/polyMeshGenAddressingUpdateGeometry.C +++ b/meshLibrary/utilities/meshes/polyMeshGenAddressing/polyMeshGenAddressingUpdateGeometry.C @@ -38,157 +38,157 @@ namespace Foam void polyMeshGenAddressing::updateGeometry ( - const boolList& changedFace + const boolList& changedFace ) { - const pointFieldPMG& p = mesh_.points(); - const faceListPMG& faces = mesh_.faces(); - - //- update face centres and face areas - if( faceCentresPtr_ && faceAreasPtr_ ) - { - vectorField& fCtrs = *faceCentresPtr_; - vectorField& fAreas = *faceAreasPtr_; - + const pointFieldPMG& p = mesh_.points(); + const faceListPMG& faces = mesh_.faces(); + + //- update face centres and face areas + if( faceCentresPtr_ && faceAreasPtr_ ) + { + vectorField& fCtrs = *faceCentresPtr_; + vectorField& fAreas = *faceAreasPtr_; + # pragma omp parallel for if( faces.size() > 100 ) \ schedule(dynamic, 10) - forAll(faces, faceI) - if( changedFace[faceI] ) - { - const face& f = faces[faceI]; - const label nPoints = f.size(); - - // If the face is a triangle, do a direct calculation for - // efficiency and to avoid round-off error-related problems - if (nPoints == 3) - { - fCtrs[faceI] = (1.0/3.0)*(p[f[0]] + p[f[1]] + p[f[2]]); - fAreas[faceI] = - 0.5*((p[f[1]] - p[f[0]])^(p[f[2]] - p[f[0]])); - } - else - { - vector sumN = vector::zero; - scalar sumA = 0.0; - vector sumAc = vector::zero; - - point fCentre = p[f[0]]; - for(label pI=1;pI<nPoints;++pI) - { - fCentre += p[f[pI]]; - } - - fCentre /= nPoints; - - for(label pI=0;pI<nPoints;++pI) - { - const point& nextPoint = p[f.nextLabel(pI)]; - - vector c = p[f[pI]] + nextPoint + fCentre; - vector n = (nextPoint - p[f[pI]])^(fCentre - p[f[pI]]); - scalar a = mag(n); - - sumN += n; - sumA += a; - sumAc += a*c; - } - - fCtrs[faceI] = (1.0/3.0)*sumAc/(sumA + VSMALL); - fAreas[faceI] = 0.5*sumN; - } - } - } - - //- update cell centres and cell volumes - if( cellCentresPtr_ && cellVolumesPtr_ && faceCentresPtr_ && faceAreasPtr_ ) - { - const vectorField& fCtrs = *faceCentresPtr_; - const vectorField& fAreas = *faceAreasPtr_; - vectorField& cellCtrs = *cellCentresPtr_; - scalarField& cellVols = *cellVolumesPtr_; - - const labelList& own = mesh_.owner(); - const cellListPMG& cells = mesh_.cells(); - + forAll(faces, faceI) + if( changedFace[faceI] ) + { + const face& f = faces[faceI]; + const label nPoints = f.size(); + + // If the face is a triangle, do a direct calculation for + // efficiency and to avoid round-off error-related problems + if (nPoints == 3) + { + fCtrs[faceI] = (1.0/3.0)*(p[f[0]] + p[f[1]] + p[f[2]]); + fAreas[faceI] = + 0.5*((p[f[1]] - p[f[0]])^(p[f[2]] - p[f[0]])); + } + else + { + vector sumN = vector::zero; + scalar sumA = 0.0; + vector sumAc = vector::zero; + + point fCentre = p[f[0]]; + for(label pI=1;pI<nPoints;++pI) + { + fCentre += p[f[pI]]; + } + + fCentre /= nPoints; + + for(label pI=0;pI<nPoints;++pI) + { + const point& nextPoint = p[f.nextLabel(pI)]; + + vector c = p[f[pI]] + nextPoint + fCentre; + vector n = (nextPoint - p[f[pI]])^(fCentre - p[f[pI]]); + scalar a = mag(n); + + sumN += n; + sumA += a; + sumAc += a*c; + } + + fCtrs[faceI] = (1.0/3.0)*sumAc/(sumA + VSMALL); + fAreas[faceI] = 0.5*sumN; + } + } + } + + //- update cell centres and cell volumes + if( cellCentresPtr_ && cellVolumesPtr_ && faceCentresPtr_ && faceAreasPtr_ ) + { + const vectorField& fCtrs = *faceCentresPtr_; + const vectorField& fAreas = *faceAreasPtr_; + vectorField& cellCtrs = *cellCentresPtr_; + scalarField& cellVols = *cellVolumesPtr_; + + const labelList& own = mesh_.owner(); + const cellListPMG& cells = mesh_.cells(); + # pragma omp parallel for if( cells.size() > 100 ) \ schedule(dynamic, 10) - forAll(cells, cellI) - { - const cell& c = cells[cellI]; - - bool update(false); - forAll(c, fI) - if( changedFace[c[fI]] ) - { - update = true; - break; - } - - if( update ) - { - cellCtrs[cellI] = vector::zero; - cellVols[cellI] = 0.0; - - //- estimate position of cell centre - vector cEst(vector::zero); - forAll(c, fI) - cEst += fCtrs[c[fI]]; - cEst /= c.size(); - - forAll(c, fI) - if( own[c[fI]] == cellI ) - { - // Calculate 3*face-pyramid volume - const scalar pyr3Vol = - max - ( - fAreas[c[fI]] & - ( - fCtrs[c[fI]] - - cEst - ), - VSMALL - ); - - // Calculate face-pyramid centre - const vector pc = - (3.0/4.0)*fCtrs[c[fI]] + (1.0/4.0)*cEst; - - // Accumulate volume-weighted face-pyramid centre - cellCtrs[cellI] += pyr3Vol*pc; - - // Accumulate face-pyramid volume - cellVols[cellI] += pyr3Vol; - } - else - { - // Calculate 3*face-pyramid volume - const scalar pyr3Vol = - max - ( - fAreas[c[fI]] & - ( - cEst - fCtrs[c[fI]] - ), - VSMALL - ); - - // Calculate face-pyramid centre - const vector pc = - (3.0/4.0)*fCtrs[c[fI]] + (1.0/4.0)*cEst; - - // Accumulate volume-weighted face-pyramid centre - cellCtrs[cellI] += pyr3Vol*pc; - - // Accumulate face-pyramid volume - cellVols[cellI] += pyr3Vol; - } - - cellCtrs[cellI] /= cellVols[cellI]; - cellVols[cellI] /= 3.0; - } - } - } + forAll(cells, cellI) + { + const cell& c = cells[cellI]; + + bool update(false); + forAll(c, fI) + if( changedFace[c[fI]] ) + { + update = true; + break; + } + + if( update ) + { + cellCtrs[cellI] = vector::zero; + cellVols[cellI] = 0.0; + + //- estimate position of cell centre + vector cEst(vector::zero); + forAll(c, fI) + cEst += fCtrs[c[fI]]; + cEst /= c.size(); + + forAll(c, fI) + if( own[c[fI]] == cellI ) + { + // Calculate 3*face-pyramid volume + const scalar pyr3Vol = + max + ( + fAreas[c[fI]] & + ( + fCtrs[c[fI]] - + cEst + ), + VSMALL + ); + + // Calculate face-pyramid centre + const vector pc = + (3.0/4.0)*fCtrs[c[fI]] + (1.0/4.0)*cEst; + + // Accumulate volume-weighted face-pyramid centre + cellCtrs[cellI] += pyr3Vol*pc; + + // Accumulate face-pyramid volume + cellVols[cellI] += pyr3Vol; + } + else + { + // Calculate 3*face-pyramid volume + const scalar pyr3Vol = + max + ( + fAreas[c[fI]] & + ( + cEst - fCtrs[c[fI]] + ), + VSMALL + ); + + // Calculate face-pyramid centre + const vector pc = + (3.0/4.0)*fCtrs[c[fI]] + (1.0/4.0)*cEst; + + // Accumulate volume-weighted face-pyramid centre + cellCtrs[cellI] += pyr3Vol*pc; + + // Accumulate face-pyramid volume + cellVols[cellI] += pyr3Vol; + } + + cellCtrs[cellI] /= cellVols[cellI]; + cellVols[cellI] /= 3.0; + } + } + } } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/meshLibrary/utilities/meshes/polyMeshGenChecks/polyMeshGenChecksGeometry.C b/meshLibrary/utilities/meshes/polyMeshGenChecks/polyMeshGenChecksGeometry.C index 792ece61..20b67a11 100644 --- a/meshLibrary/utilities/meshes/polyMeshGenChecks/polyMeshGenChecksGeometry.C +++ b/meshLibrary/utilities/meshes/polyMeshGenChecks/polyMeshGenChecksGeometry.C @@ -119,7 +119,7 @@ bool checkClosedCells { // Check that all cells labels are valid const cellListPMG& cells = mesh.cells(); - const label nFaces = mesh.faces().size(); + const label nFaces = mesh.faces().size(); label nErrorClosed = 0; @@ -175,9 +175,9 @@ bool checkClosedCells sumClosed[own[faceI]] += areas[faceI]; sumMagClosed[own[faceI]] += mag(areas[faceI]); - if( nei[faceI] == -1 ) - continue; - + if( nei[faceI] == -1 ) + continue; + // Subtract from neighbour sumClosed[nei[faceI]] -= areas[faceI]; sumMagClosed[nei[faceI]] += mag(areas[faceI]); @@ -619,7 +619,7 @@ bool checkFaceDotProduct const labelList& own = mesh.owner(); const labelList& nei = mesh.neighbour(); - const label nInternalFaces = mesh.nInternalFaces(); + const label nInternalFaces = mesh.nInternalFaces(); // Severe nonorthogonality threshold const scalar severeNonorthogonalityThreshold = @@ -868,15 +868,15 @@ bool checkFacePyramids # pragma omp parallel for schedule(guided) reduction(+ : nErrorPyrs) forAll(faces, faceI) { - if( changedFacePtr && !(*changedFacePtr)[faceI] ) - continue; - + if( changedFacePtr && !(*changedFacePtr)[faceI] ) + continue; + // Create the owner pyramid - it will have negative volume const scalar pyrVol = pyramidPointFaceRef - ( - faces[faceI], - ctrs[owner[faceI]] - ).mag(points); + ( + faces[faceI], + ctrs[owner[faceI]] + ).mag(points); bool badFace(false); @@ -1026,7 +1026,7 @@ bool checkFaceSkewness //- larger than the face area vector const labelList& own = mesh.owner(); const labelList& nei = mesh.neighbour(); - const label nInternalFaces = mesh.nInternalFaces(); + const label nInternalFaces = mesh.nInternalFaces(); const vectorField& centres = mesh.addressingData().cellCentres(); const vectorField& fCentres = mesh.addressingData().faceCentres(); @@ -1264,7 +1264,7 @@ bool checkFaceUniformity const labelList& owner = mesh.owner(); const labelList& neighbour = mesh.neighbour(); - const label nInternalFaces = mesh.nInternalFaces(); + const label nInternalFaces = mesh.nInternalFaces(); scalar maxUniformity = 0.0; scalar minUniformity = VGREAT; @@ -1568,7 +1568,7 @@ bool checkFaceFlatness const bool report, const scalar warnFlatness, labelHashSet* setPtr, - const boolList* changedFacePtr + const boolList* changedFacePtr ) { if( warnFlatness < 0 || warnFlatness > 1 ) diff --git a/meshLibrary/utilities/meshes/polyMeshGenChecks/polyMeshGenChecksTopology.C b/meshLibrary/utilities/meshes/polyMeshGenChecks/polyMeshGenChecksTopology.C index c2767cfe..02623e58 100644 --- a/meshLibrary/utilities/meshes/polyMeshGenChecks/polyMeshGenChecksTopology.C +++ b/meshLibrary/utilities/meshes/polyMeshGenChecks/polyMeshGenChecksTopology.C @@ -176,7 +176,7 @@ bool checkUpperTriangular forAllRow(cc, cellI, nbrI) { - const label neiI = cc(cellI, nbrI); + const label neiI = cc(cellI, nbrI); if( (neiI > cellI) && !usedNbr[nbrI] && (neiI < minNei) ) { nextNei = nbrI; @@ -373,7 +373,7 @@ bool checkFaceVertices const faceListPMG& faces = mesh.faces(); label nErrorFaces = 0; - const label nPoints = mesh.points().size(); + const label nPoints = mesh.points().size(); forAll(faces, fI) { diff --git a/meshLibrary/utilities/meshes/polyMeshGenModifier/polyMeshGenModifierAddCellByCell.C b/meshLibrary/utilities/meshes/polyMeshGenModifier/polyMeshGenModifierAddCellByCell.C index 5821a78f..c04b7c00 100644 --- a/meshLibrary/utilities/meshes/polyMeshGenModifier/polyMeshGenModifierAddCellByCell.C +++ b/meshLibrary/utilities/meshes/polyMeshGenModifier/polyMeshGenModifierAddCellByCell.C @@ -36,82 +36,82 @@ namespace Foam polyMeshGenModifierAddCellByCell::polyMeshGenModifierAddCellByCell ( - polyMeshGen& mesh + polyMeshGen& mesh ) : - polyMeshGenModifier(mesh), - nFaces_(mesh.faces().size()), - newFaces_(nFaces_), - nCells_(mesh.cells().size()), - newCells_(nCells_) + polyMeshGenModifier(mesh), + nFaces_(mesh.faces().size()), + newFaces_(nFaces_), + nCells_(mesh.cells().size()), + newCells_(nCells_) { this->pointFaces(); - faceListPMG& faces = this->facesAccess(); - forAll(faces, faceI) - newFaces_[faceI].transfer(faces[faceI]); - - cellListPMG& cells = this->cellsAccess(); - forAll(cells, cellI) - newCells_[cellI].transfer(cells[cellI]); + faceListPMG& faces = this->facesAccess(); + forAll(faces, faceI) + newFaces_[faceI].transfer(faces[faceI]); + + cellListPMG& cells = this->cellsAccess(); + forAll(cells, cellI) + newCells_[cellI].transfer(cells[cellI]); }; - + // Destructor polyMeshGenModifierAddCellByCell::~polyMeshGenModifierAddCellByCell() { - faceListPMG& faces = this->facesAccess(); - faces.setSize(nFaces_); - forAll(faces, faceI) - faces[faceI].transfer(newFaces_[faceI]); - - cellListPMG& cells = this->cellsAccess(); - cells.setSize(newCells_.size()); - forAll(cells, cellI) - cells[cellI].transfer(newCells_[cellI]); + faceListPMG& faces = this->facesAccess(); + faces.setSize(nFaces_); + forAll(faces, faceI) + faces[faceI].transfer(newFaces_[faceI]); + + cellListPMG& cells = this->cellsAccess(); + cells.setSize(newCells_.size()); + forAll(cells, cellI) + cells[cellI].transfer(newCells_[cellI]); } - + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // void polyMeshGenModifierAddCellByCell::addCell(const faceList& cellFaces) { - cell c(cellFaces.size()); - - VRWGraph& pointFaces = this->pointFaces(); - - forAll(cellFaces, faceI) - { - const face& f = cellFaces[faceI]; - - const label pointI = f[0]; - - label fLabel(-1); - forAllRow(pointFaces, pointI, pfI) - { - const label faceI = pointFaces(pointI, pfI); - - if( newFaces_[faceI] == f ) - { - fLabel = faceI; - break; - } - } - - if( fLabel == -1 ) - { - newFaces_.append(f); - c[faceI] = nFaces_; - forAll(f, pI) - pointFaces.append(f[pI], nFaces_); - - ++nFaces_; - } - else - { - c[faceI] = fLabel; - } - } - - newCells_.append(c); - ++nCells_; + cell c(cellFaces.size()); + + VRWGraph& pointFaces = this->pointFaces(); + + forAll(cellFaces, faceI) + { + const face& f = cellFaces[faceI]; + + const label pointI = f[0]; + + label fLabel(-1); + forAllRow(pointFaces, pointI, pfI) + { + const label faceI = pointFaces(pointI, pfI); + + if( newFaces_[faceI] == f ) + { + fLabel = faceI; + break; + } + } + + if( fLabel == -1 ) + { + newFaces_.append(f); + c[faceI] = nFaces_; + forAll(f, pI) + pointFaces.append(f[pI], nFaces_); + + ++nFaces_; + } + else + { + c[faceI] = fLabel; + } + } + + newCells_.append(c); + ++nCells_; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/meshLibrary/utilities/meshes/polyMeshGenModifier/polyMeshGenModifierAddCellByCell.H b/meshLibrary/utilities/meshes/polyMeshGenModifier/polyMeshGenModifierAddCellByCell.H index fd5bd9e4..d173e468 100644 --- a/meshLibrary/utilities/meshes/polyMeshGenModifier/polyMeshGenModifierAddCellByCell.H +++ b/meshLibrary/utilities/meshes/polyMeshGenModifier/polyMeshGenModifierAddCellByCell.H @@ -48,27 +48,27 @@ namespace Foam class polyMeshGenModifierAddCellByCell : public polyMeshGenModifier { - // Private data - //- number of faces - label nFaces_; - LongList<face> newFaces_; - - //- number of cells - label nCells_; - LongList<cell> newCells_; + // Private data + //- number of faces + label nFaces_; + LongList<face> newFaces_; + + //- number of cells + label nCells_; + LongList<cell> newCells_; public: - // Constructors - //- Construct from the reference to the mesh - polyMeshGenModifierAddCellByCell(polyMeshGen& mesh); - - // Destructor - ~polyMeshGenModifierAddCellByCell(); - - // Member functions - //- add a single cell (vertices must be added); - void addCell(const faceList& cell); + // Constructors + //- Construct from the reference to the mesh + polyMeshGenModifierAddCellByCell(polyMeshGen& mesh); + + // Destructor + ~polyMeshGenModifierAddCellByCell(); + + // Member functions + //- add a single cell (vertices must be added); + void addCell(const faceList& cell); }; // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/meshLibrary/utilities/meshes/polyMeshGenModifier/polyMeshGenModifierRemoveCells.C b/meshLibrary/utilities/meshes/polyMeshGenModifier/polyMeshGenModifierRemoveCells.C index 19bfe2e9..4ca25f74 100644 --- a/meshLibrary/utilities/meshes/polyMeshGenModifier/polyMeshGenModifierRemoveCells.C +++ b/meshLibrary/utilities/meshes/polyMeshGenModifier/polyMeshGenModifierRemoveCells.C @@ -42,71 +42,71 @@ void polyMeshGenModifier::removeCells const bool removeProcFaces ) { - Info << "Removing selected cells from the mesh" << endl; + Info << "Removing selected cells from the mesh" << endl; - //mesh_.clearOut(); + //mesh_.clearOut(); - faceListPMG& faces = mesh_.faces_; - cellListPMG& cells = mesh_.cells_; + faceListPMG& faces = mesh_.faces_; + cellListPMG& cells = mesh_.cells_; - if( removeCell.size() != cells.size() ) - { - Info << "Size of cells " << cells.size() << endl; - Info << "Size of list for removal " << removeCell.size() << endl; - FatalErrorIn - ( - "void polyMeshGenModifier::removeCells(const boolList& removeCell)" - ) << "Incorrect number of entries in removeCell list!" - << abort(FatalError); - } + if( removeCell.size() != cells.size() ) + { + Info << "Size of cells " << cells.size() << endl; + Info << "Size of list for removal " << removeCell.size() << endl; + FatalErrorIn + ( + "void polyMeshGenModifier::removeCells(const boolList& removeCell)" + ) << "Incorrect number of entries in removeCell list!" + << abort(FatalError); + } - //- flip internal faces which will become boundary ones - const labelList& owner = mesh_.owner(); - const labelList& neighbour = mesh_.neighbour(); + //- flip internal faces which will become boundary ones + const labelList& owner = mesh_.owner(); + const labelList& neighbour = mesh_.neighbour(); # pragma omp parallel for schedule(dynamic, 40) - forAll(faces, faceI) - { - if( neighbour[faceI] == -1 ) + forAll(faces, faceI) + { + if( neighbour[faceI] == -1 ) { faceI = faces.size(); - continue; + continue; } - if( removeCell[owner[faceI]] && !removeCell[neighbour[faceI]] ) - faces[faceI] = faces[faceI].reverseFace(); - } + if( removeCell[owner[faceI]] && !removeCell[neighbour[faceI]] ) + faces[faceI] = faces[faceI].reverseFace(); + } - mesh_.clearOut(); + mesh_.clearOut(); - //- remove unwanted cells - label nCells(0); - labelListPMG newCellLabel(cells.size(), -1); - forAll(newCellLabel, cellI) - if( !removeCell[cellI] ) - newCellLabel[cellI] = nCells++; + //- remove unwanted cells + label nCells(0); + labelListPMG newCellLabel(cells.size(), -1); + forAll(newCellLabel, cellI) + if( !removeCell[cellI] ) + newCellLabel[cellI] = nCells++; - forAll(cells, cellI) - if( (newCellLabel[cellI] != -1) && (newCellLabel[cellI] < cellI) ) - { - cells[newCellLabel[cellI]].transfer(cells[cellI]); - } + forAll(cells, cellI) + if( (newCellLabel[cellI] != -1) && (newCellLabel[cellI] < cellI) ) + { + cells[newCellLabel[cellI]].transfer(cells[cellI]); + } - cells.setSize(nCells); + cells.setSize(nCells); //- update cell subsets in the mesh mesh_.updateCellSubsets(newCellLabel); reduce(nCells, sumOp<label>()); - Info << "New cells size " << nCells << endl; + Info << "New cells size " << nCells << endl; - //- reorder positions of boundary faces + //- reorder positions of boundary faces //- this outs the newly-created bnd faces at the end of the list - this->reorderBoundaryFaces(); + this->reorderBoundaryFaces(); mesh_.clearOut(); - //- remove unused faces - boolList removeFace(faces.size(), true); + //- remove unused faces + boolList removeFace(faces.size(), true); # pragma omp parallel if( cells.size() > 1000 ) { @@ -130,9 +130,9 @@ void polyMeshGenModifier::removeCells } } - mesh_.clearOut(); + mesh_.clearOut(); - this->removeFaces(removeFace); + this->removeFaces(removeFace); Info << "Finished removing selected cells from the mesh" << endl; } diff --git a/meshLibrary/utilities/meshes/polyMeshGenModifier/polyMeshGenModifierRemoveFaces.C b/meshLibrary/utilities/meshes/polyMeshGenModifier/polyMeshGenModifierRemoveFaces.C index b1550138..6dc1f162 100644 --- a/meshLibrary/utilities/meshes/polyMeshGenModifier/polyMeshGenModifierRemoveFaces.C +++ b/meshLibrary/utilities/meshes/polyMeshGenModifier/polyMeshGenModifierRemoveFaces.C @@ -38,57 +38,57 @@ namespace Foam void polyMeshGenModifier::removeFaces(const boolList& removeFace) { - //mesh_.clearOut(); + //mesh_.clearOut(); Info << "Removing faces" << endl; - faceListPMG& faces = mesh_.faces_; - cellListPMG& cells = mesh_.cells_; + faceListPMG& faces = mesh_.faces_; + cellListPMG& cells = mesh_.cells_; - label nFaces(0); - labelListPMG newFaceLabel(faces.size(), -1); + label nFaces(0); + labelListPMG newFaceLabel(faces.size(), -1); - //- copy internal faces + //- copy internal faces const label nInternalFaces = mesh_.nInternalFaces(); for(label faceI=0;faceI<nInternalFaces;++faceI) if( !removeFace[faceI] ) - { - if( nFaces < faceI ) - faces[nFaces].transfer(faces[faceI]); + { + if( nFaces < faceI ) + faces[nFaces].transfer(faces[faceI]); newFaceLabel[faceI] = nFaces; - ++nFaces; + ++nFaces; } - //- copy boundary faces - PtrList<writePatch>& boundaries = mesh_.boundaries_; - labelList patchStart(boundaries.size()); - labelList nFacesInPatch(boundaries.size()); - label npI(0); - forAll(boundaries, patchI) - { - const label oldStart = boundaries[patchI].patchStart(); - const label oldNumFacesInPatch = boundaries[patchI].patchSize(); - - patchStart[npI] = nFaces; - nFacesInPatch[npI] = 0; - - for(label faceI=0;faceI<oldNumFacesInPatch;++faceI) - if( !removeFace[oldStart+faceI] ) - { - ++nFacesInPatch[npI]; - if( nFaces < (oldStart+faceI) ) - faces[nFaces].transfer(faces[oldStart+faceI]); - newFaceLabel[oldStart+faceI] = nFaces++; - } + //- copy boundary faces + PtrList<writePatch>& boundaries = mesh_.boundaries_; + labelList patchStart(boundaries.size()); + labelList nFacesInPatch(boundaries.size()); + label npI(0); + forAll(boundaries, patchI) + { + const label oldStart = boundaries[patchI].patchStart(); + const label oldNumFacesInPatch = boundaries[patchI].patchSize(); + + patchStart[npI] = nFaces; + nFacesInPatch[npI] = 0; + + for(label faceI=0;faceI<oldNumFacesInPatch;++faceI) + if( !removeFace[oldStart+faceI] ) + { + ++nFacesInPatch[npI]; + if( nFaces < (oldStart+faceI) ) + faces[nFaces].transfer(faces[oldStart+faceI]); + newFaceLabel[oldStart+faceI] = nFaces++; + } ++npI; - } + } - forAll(boundaries, patchI) - { - boundaries[patchI].patchStart() = patchStart[patchI]; - boundaries[patchI].patchSize() = nFacesInPatch[patchI]; - } + forAll(boundaries, patchI) + { + boundaries[patchI].patchStart() = patchStart[patchI]; + boundaries[patchI].patchSize() = nFacesInPatch[patchI]; + } if( Pstream::parRun() ) { @@ -124,11 +124,11 @@ void polyMeshGenModifier::removeFaces(const boolList& removeFace) removeProcFace[faceI] = true; OPstream toOtherProc - ( + ( Pstream::blocking, - procBoundaries[patchI].neiProcNo(), - removeProcFace.byteSize() - ); + procBoundaries[patchI].neiProcNo(), + removeProcFace.byteSize() + ); toOtherProc << removeProcFace; } @@ -217,7 +217,7 @@ void polyMeshGenModifier::removeFaces(const boolList& removeFace) //- update face subsets in the mesh mesh_.updateFaceSubsets(newFaceLabel); - //- change cells + //- change cells # pragma omp parallel for if( cells.size() > 1000 ) schedule(dynamic, 40) forAll(cells, cellI) { @@ -235,7 +235,7 @@ void polyMeshGenModifier::removeFaces(const boolList& removeFace) c[fI] = newC[fI]; } - mesh_.clearOut(); + mesh_.clearOut(); Info << "Finished removing faces" << endl; } @@ -340,7 +340,7 @@ void polyMeshGenModifier::removeDuplicateFaces() c[fI] = newC[fI]; } - mesh_.clearOut(); + mesh_.clearOut(); } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/meshLibrary/utilities/meshes/polyMeshGenModifier/polyMeshGenModifierRemoveUnusedVertices.C b/meshLibrary/utilities/meshes/polyMeshGenModifier/polyMeshGenModifierRemoveUnusedVertices.C index a35feae5..783d1d29 100644 --- a/meshLibrary/utilities/meshes/polyMeshGenModifier/polyMeshGenModifierRemoveUnusedVertices.C +++ b/meshLibrary/utilities/meshes/polyMeshGenModifier/polyMeshGenModifierRemoveUnusedVertices.C @@ -74,7 +74,7 @@ void polyMeshGenModifier::removeUnusedVertices() mesh_.updatePointSubsets(newLabel); - mesh_.clearOut(); + mesh_.clearOut(); this->clearOut(); } diff --git a/meshLibrary/utilities/meshes/polyMeshGenModifier/polyMeshGenModifierRenumberMesh.C b/meshLibrary/utilities/meshes/polyMeshGenModifier/polyMeshGenModifierRenumberMesh.C index 6e11f655..60a88a3f 100644 --- a/meshLibrary/utilities/meshes/polyMeshGenModifier/polyMeshGenModifierRenumberMesh.C +++ b/meshLibrary/utilities/meshes/polyMeshGenModifier/polyMeshGenModifierRenumberMesh.C @@ -243,7 +243,7 @@ void polyMeshGenModifier::renumberMesh() } } - faceListPMG& oldFaces = this->facesAccess(); + faceListPMG& oldFaces = this->facesAccess(); faceList newFaces(oldFaces.size()); forAll(newFaces, faceI) @@ -280,7 +280,7 @@ void polyMeshGenModifier::renumberMesh() this->clearOut(); mesh_.clearOut(); - Info << "Finished renumbering the mesh" << endl; + Info << "Finished renumbering the mesh" << endl; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/meshLibrary/utilities/meshes/polyMeshGenModifier/polyMeshGenModifierReorderBoundaryFaces.C b/meshLibrary/utilities/meshes/polyMeshGenModifier/polyMeshGenModifierReorderBoundaryFaces.C index 70e441e7..ff21bdfd 100644 --- a/meshLibrary/utilities/meshes/polyMeshGenModifier/polyMeshGenModifierReorderBoundaryFaces.C +++ b/meshLibrary/utilities/meshes/polyMeshGenModifier/polyMeshGenModifierReorderBoundaryFaces.C @@ -295,8 +295,8 @@ void polyMeshGenModifier::reorderProcBoundaryFaces() cell& c = cells[cellI]; forAll(c, fI) - if( newFaceLabel[c[fI]] != -1 ) - c[fI] = newFaceLabel[c[fI]]; + if( newFaceLabel[c[fI]] != -1 ) + c[fI] = newFaceLabel[c[fI]]; } //- update face subsets diff --git a/meshLibrary/utilities/meshes/polyMeshGenModifier/polyMeshGenModifierZipUpCells.C b/meshLibrary/utilities/meshes/polyMeshGenModifier/polyMeshGenModifierZipUpCells.C index f9ee23ab..4878e314 100644 --- a/meshLibrary/utilities/meshes/polyMeshGenModifier/polyMeshGenModifierZipUpCells.C +++ b/meshLibrary/utilities/meshes/polyMeshGenModifier/polyMeshGenModifierZipUpCells.C @@ -42,14 +42,14 @@ namespace Foam void polyMeshGenModifier::zipUpCells() { - this->clearOut(); - + this->clearOut(); + Info<< "Zipping up topologically open cells" << endl; - - const pointFieldPMG& points = mesh_.points(); - const cellListPMG& cells = mesh_.cells(); - - faceListPMG& faces = mesh_.faces_; + + const pointFieldPMG& points = mesh_.points(); + const cellListPMG& cells = mesh_.cells(); + + faceListPMG& faces = mesh_.faces_; // Algorithm: // Take the original mesh and visit all cells. For every cell @@ -78,34 +78,34 @@ void polyMeshGenModifier::zipUpCells() do { nChangedFacesInMesh = 0; - + //- calculate pointFaces addressing # ifdef DEBUG_ZIPUP Info << "Starting pointFaces addressing " << endl; # endif - List<direction> nUsage(points.size(), direction(0)); - forAll(faces, fI) - { - const face& f = faces[fI]; - forAll(f, pI) - ++nUsage[f[pI]]; - } - - VRWGraph pFaces(points.size()); - forAll(nUsage, pI) - pFaces.setRowSize(pI, nUsage[pI]); - - nUsage = 0; - - forAll(faces, fI) - { - const face& f = faces[fI]; - forAll(f, pI) - pFaces(f[pI], nUsage[f[pI]]++) = fI; - } - - nUsage.clear(); + List<direction> nUsage(points.size(), direction(0)); + forAll(faces, fI) + { + const face& f = faces[fI]; + forAll(f, pI) + ++nUsage[f[pI]]; + } + + VRWGraph pFaces(points.size()); + forAll(nUsage, pI) + pFaces.setRowSize(pI, nUsage[pI]); + + nUsage = 0; + + forAll(faces, fI) + { + const face& f = faces[fI]; + forAll(f, pI) + pFaces(f[pI], nUsage[f[pI]]++) = fI; + } + + nUsage.clear(); # ifdef DEBUG_ZIPUP Info << "Starting zipping cells " << endl; @@ -551,21 +551,21 @@ void polyMeshGenModifier::zipUpCells() // In order to avoid edge-to-edge comparison, get faces using // point-face addressing in two goes. - const label start = testEdge.start(); - const label end = testEdge.end(); - - labelList facesSharingEdge - ( - pFaces.sizeOfRow(start) + - pFaces.sizeOfRow(end) - ); + const label start = testEdge.start(); + const label end = testEdge.end(); + + labelList facesSharingEdge + ( + pFaces.sizeOfRow(start) + + pFaces.sizeOfRow(end) + ); label nfse = 0; - - forAllRow(pFaces, start, pfI) - facesSharingEdge[nfse++] = pFaces(start, pfI); - - forAllRow(pFaces, end, pfI) - facesSharingEdge[nfse++] = pFaces(end, pfI); + + forAllRow(pFaces, start, pfI) + facesSharingEdge[nfse++] = pFaces(start, pfI); + + forAllRow(pFaces, end, pfI) + facesSharingEdge[nfse++] = pFaces(end, pfI); forAll(facesSharingEdge, faceI) { @@ -709,13 +709,13 @@ void polyMeshGenModifier::zipUpCells() nNewFacePoints++; } } - - forAll(newFace, pI) - pFaces.appendIfNotIn - ( - newFace[pI], - currentFaceIndex - ); + + forAll(newFace, pI) + pFaces.appendIfNotIn + ( + newFace[pI], + currentFaceIndex + ); # ifdef DEBUG_ZIPUP Info<< "oldFace: " diff --git a/meshLibrary/utilities/meshes/primitives/meshSubsets/meshSubset.H b/meshLibrary/utilities/meshes/primitives/meshSubsets/meshSubset.H index fc17c509..0ae4c738 100644 --- a/meshLibrary/utilities/meshes/primitives/meshSubsets/meshSubset.H +++ b/meshLibrary/utilities/meshes/primitives/meshSubsets/meshSubset.H @@ -54,7 +54,7 @@ class VRWGraph; class meshSubset { - // Private data + // Private data //- name of the given subset word name_; @@ -89,8 +89,8 @@ public: const ListType& elements ); - // Destructor - ~meshSubset(); + // Destructor + ~meshSubset(); // Member Functions @@ -124,14 +124,14 @@ public: //- update subset after modification //- this modifier is used in case when elements are decomposed inline void updateSubset(const VRWGraph&); - - // Searches - //- find if the element exists in the subset - inline bool contains(const label) const; + + // Searches + //- find if the element exists in the subset + inline bool contains(const label) const; // IOstream operators - friend Ostream& operator<<(Ostream&, const meshSubset&); + friend Ostream& operator<<(Ostream&, const meshSubset&); }; // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/meshLibrary/utilities/meshes/primitives/partTet/partTet.H b/meshLibrary/utilities/meshes/primitives/partTet/partTet.H index ae57a545..c9879a62 100644 --- a/meshLibrary/utilities/meshes/primitives/partTet/partTet.H +++ b/meshLibrary/utilities/meshes/primitives/partTet/partTet.H @@ -55,15 +55,15 @@ class Ostream; class partTet { protected: - - // Protected data + + // Protected data label data_[4]; public: // Constructors - //- Null construct - inline partTet(); + //- Null construct + inline partTet(); //- Construct from point labels inline partTet @@ -74,8 +74,8 @@ public: const label d ); - // Destructor - ~partTet(); + // Destructor + ~partTet(); // Member Functions @@ -92,54 +92,54 @@ public: inline label d() const; inline label size() const; - - // Searches - //- find position of the node in the partTet - inline label whichPosition(const label) const; + + // Searches + //- find position of the node in the partTet + inline label whichPosition(const label) const; // Properties //- Return face normal - template<class PointField> + template<class PointField> inline vector Sa(const PointField&) const; - template<class PointField> + template<class PointField> inline vector Sb(const PointField&) const; - template<class PointField> + template<class PointField> inline vector Sc(const PointField&) const; - template<class PointField> + template<class PointField> inline vector Sd(const PointField&) const; //- Return volume - template<class PointField> + template<class PointField> inline scalar mag(const PointField&) const; - - //- Return circum-centre - template<class PointField> - inline point crcmCentre(const PointField&) const; - - template<class PointField> - inline scalar crcmRadius(const PointField&) const; - - //- Return centroid of the tetrahedron - template<class PointField> - inline point centroid(const PointField&) const; - - //- Return edges - edgeList edges() const; - - // Member operators - - inline label operator[](const label) const; - - inline void operator=(const partTet&); + + //- Return circum-centre + template<class PointField> + inline point crcmCentre(const PointField&) const; + + template<class PointField> + inline scalar crcmRadius(const PointField&) const; + + //- Return centroid of the tetrahedron + template<class PointField> + inline point centroid(const PointField&) const; + + //- Return edges + edgeList edges() const; + + // Member operators + + inline label operator[](const label) const; + + inline void operator=(const partTet&); // IOstream operators - friend Ostream& operator<<(Ostream&, const partTet&); + friend Ostream& operator<<(Ostream&, const partTet&); }; diff --git a/meshLibrary/utilities/meshes/primitives/partTet/partTetI.H b/meshLibrary/utilities/meshes/primitives/partTet/partTetI.H index 38ebaf3f..19ae4548 100644 --- a/meshLibrary/utilities/meshes/primitives/partTet/partTetI.H +++ b/meshLibrary/utilities/meshes/primitives/partTet/partTetI.H @@ -40,7 +40,7 @@ namespace Foam inline partTet::partTet() { } - + inline partTet::partTet ( const label a, @@ -49,10 +49,10 @@ inline partTet::partTet const label d ) { - data_[0] = a; - data_[1] = b; - data_[2] = c; - data_[3] = d; + data_[0] = a; + data_[1] = b; + data_[2] = c; + data_[3] = d; } inline partTet::~partTet() @@ -88,145 +88,145 @@ inline label partTet::size() const inline label partTet::whichPosition(const label pointI) const { - for(label i=0;i<4;++i) - if( data_[i] == pointI ) - return i; - - return -1; + for(label i=0;i<4;++i) + if( data_[i] == pointI ) + return i; + + return -1; } template<class PointField> inline vector partTet::Sa(const PointField& points) const { - triangle<point, point> tria - ( - points[data_[1]], - points[data_[2]], - points[data_[3]] - ); - - return tria.normal(); + triangle<point, point> tria + ( + points[data_[1]], + points[data_[2]], + points[data_[3]] + ); + + return tria.normal(); //return triangle<point, point>(b_, c_, d_).normal(); } template<class PointField> inline vector partTet::Sb(const PointField& points) const { - triangle<point, point> tria - ( - points[data_[0]], - points[data_[3]], - points[data_[2]] - ); - - return tria.normal(); + triangle<point, point> tria + ( + points[data_[0]], + points[data_[3]], + points[data_[2]] + ); + + return tria.normal(); //return triangle<point, point>(a_, d_, c_).normal(); } template<class PointField> inline vector partTet::Sc(const PointField& points) const { - triangle<point, point> tria - ( - points[data_[0]], - points[data_[1]], - points[data_[3]] - ); - - return tria.normal(); + triangle<point, point> tria + ( + points[data_[0]], + points[data_[1]], + points[data_[3]] + ); + + return tria.normal(); //return triangle<point, point>(a_, b_, d_).normal(); } template<class PointField> inline vector partTet::Sd(const PointField& points) const { - triangle<point, point> tria - ( - points[data_[0]], - points[data_[2]], - points[data_[1]] - ); - - return tria.normal(); + triangle<point, point> tria + ( + points[data_[0]], + points[data_[2]], + points[data_[1]] + ); + + return tria.normal(); //return triangle<point, point>(a_, c_, b_).normal(); } template<class PointField> inline scalar partTet::mag(const PointField& points) const { - tetrahedron<point, point> tet - ( - points[data_[0]], - points[data_[1]], - points[data_[2]], - points[data_[3]] - ); - - return tet.mag(); + tetrahedron<point, point> tet + ( + points[data_[0]], + points[data_[1]], + points[data_[2]], + points[data_[3]] + ); + + return tet.mag(); //return (1.0/6.0)*(((b_ - a_) ^ (c_ - a_)) & (d_ - a_)); } template<class PointField> inline point partTet::crcmCentre(const PointField& points) const { - tetrahedron<point, point> tet - ( - points[data_[0]], - points[data_[1]], - points[data_[2]], - points[data_[3]] - ); - - return tet.circumCentre(); + tetrahedron<point, point> tet + ( + points[data_[0]], + points[data_[1]], + points[data_[2]], + points[data_[3]] + ); + + return tet.circumCentre(); } template<class PointField> inline scalar partTet::crcmRadius(const PointField& points) const { - tetrahedron<point, point> tet - ( - points[data_[0]], - points[data_[1]], - points[data_[2]], - points[data_[3]] - ); - - return tet.circumRadius(); + tetrahedron<point, point> tet + ( + points[data_[0]], + points[data_[1]], + points[data_[2]], + points[data_[3]] + ); + + return tet.circumRadius(); } template<class PointField> inline point partTet::centroid(const PointField& points) const { - point p = points[data_[0]]; - for(label i=1;i<4;++i) - p += points[data_[i]]; - - p /= 4; - return p; + point p = points[data_[0]]; + for(label i=1;i<4;++i) + p += points[data_[i]]; + + p /= 4; + return p; } inline edgeList partTet::edges() const { - edgeList edges(6); - edges[0] = edge(data_[0], data_[1]); - edges[1] = edge(data_[0], data_[2]); - edges[2] = edge(data_[0], data_[3]); + edgeList edges(6); + edges[0] = edge(data_[0], data_[1]); + edges[1] = edge(data_[0], data_[2]); + edges[2] = edge(data_[0], data_[3]); edges[3] = edge(data_[3], data_[1]); edges[4] = edge(data_[1], data_[2]); edges[5] = edge(data_[3], data_[2]); - return edges; + return edges; } inline label partTet::operator[](const label i) const { - return data_[i]; + return data_[i]; } inline void partTet::operator=(const partTet& tet) { - for(label i=0;i<4;++i) - data_[i] = tet.data_[i]; + for(label i=0;i<4;++i) + data_[i] = tet.data_[i]; } // * * * * * * * * * * * * * * * Ostream Operator * * * * * * * * * * * * * // diff --git a/meshLibrary/utilities/meshes/triSurf/triSurf.C b/meshLibrary/utilities/meshes/triSurf/triSurf.C index 8c5fabba..a12729db 100644 --- a/meshLibrary/utilities/meshes/triSurf/triSurf.C +++ b/meshLibrary/utilities/meshes/triSurf/triSurf.C @@ -36,90 +36,90 @@ Description namespace Foam { - + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // void triSurf::calculateFaceGroups() const { - nFaceGroups_ = 0; - - faceGroupPtr_ = new labelListPMG(triSurface::size(), -1); - labelListPMG& faceGroup = *faceGroupPtr_; - - const labelListList& faceEdges = this->faceEdges(); - const labelListList& edgeFaces = this->edgeFaces(); - - labelListPMG front; - - forAll(faceGroup, fI) - { - if( faceGroup[fI] != -1 ) - continue; - - front.clear(); - front.append(fI); - faceGroup[fI] = nFaceGroups_; - - while( front.size() != 0 ) - { - const label fLabel = front.removeLastElement(); - - const labelList& fEdges = faceEdges[fLabel]; - forAll(fEdges, feI) - { - const label eI = fEdges[feI]; - - if( edgeFaces[eI].size() != 2 ) - continue; - - label nei = edgeFaces[eI][0]; - if( nei == fLabel ) - nei = edgeFaces[eI][1]; - - if( faceGroup[nei] == -1 ) - { - faceGroup[nei] = nFaceGroups_; - front.append(nei); - } - } - } - - ++nFaceGroups_; - } + nFaceGroups_ = 0; + + faceGroupPtr_ = new labelListPMG(triSurface::size(), -1); + labelListPMG& faceGroup = *faceGroupPtr_; + + const labelListList& faceEdges = this->faceEdges(); + const labelListList& edgeFaces = this->edgeFaces(); + + labelListPMG front; + + forAll(faceGroup, fI) + { + if( faceGroup[fI] != -1 ) + continue; + + front.clear(); + front.append(fI); + faceGroup[fI] = nFaceGroups_; + + while( front.size() != 0 ) + { + const label fLabel = front.removeLastElement(); + + const labelList& fEdges = faceEdges[fLabel]; + forAll(fEdges, feI) + { + const label eI = fEdges[feI]; + + if( edgeFaces[eI].size() != 2 ) + continue; + + label nei = edgeFaces[eI][0]; + if( nei == fLabel ) + nei = edgeFaces[eI][1]; + + if( faceGroup[nei] == -1 ) + { + faceGroup[nei] = nFaceGroups_; + front.append(nei); + } + } + } + + ++nFaceGroups_; + } } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // triSurf::triSurf(const fileName& name) : - triSurface(name), - triSubsets_(), - nFaceGroups_(-1), - faceGroupPtr_(NULL) + triSurface(name), + triSubsets_(), + nFaceGroups_(-1), + faceGroupPtr_(NULL) { } triSurf::triSurf ( - const List<labelledTri>& triangles, - const geometricSurfacePatchList& patches, - const pointField& points, - std::map<word, labelListPMG>& faceSubsets + const List<labelledTri>& triangles, + const geometricSurfacePatchList& patches, + const pointField& points, + std::map<word, labelListPMG>& faceSubsets ) : - triSurface(triangles, patches, points), - triSubsets_(), - nFaceGroups_(-1), - faceGroupPtr_(NULL) + triSurface(triangles, patches, points), + triSubsets_(), + nFaceGroups_(-1), + faceGroupPtr_(NULL) { - std::map<word, labelListPMG>::const_iterator iter; - for(iter=faceSubsets.begin();iter!=faceSubsets.end();++iter) - { - triSubsets_.insert - ( - std::pair<word, labelListPMG>(iter->first, iter->second) - ); - } + std::map<word, labelListPMG>::const_iterator iter; + for(iter=faceSubsets.begin();iter!=faceSubsets.end();++iter) + { + triSubsets_.insert + ( + std::pair<word, labelListPMG>(iter->first, iter->second) + ); + } } // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // @@ -127,47 +127,47 @@ triSurf::triSurf triSurf::~triSurf() { } - + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // void triSurf::readFaceSubsets(const fileName& fName) { - IFstream file(fName); - - //- read the number of subsets - label nSubsets; - file >> nSubsets; - - // read subsets - for(label subsetI=0;subsetI<nSubsets;++subsetI) - { - word name; - file >> name; - labelListPMG set; - file >> set; - - this->addFacetsToSubset(name, set); - } + IFstream file(fName); + + //- read the number of subsets + label nSubsets; + file >> nSubsets; + + // read subsets + for(label subsetI=0;subsetI<nSubsets;++subsetI) + { + word name; + file >> name; + labelListPMG set; + file >> set; + + this->addFacetsToSubset(name, set); + } } void triSurf::writeFaceSubsets(const fileName& fName) const { - OFstream file(fName); - - label nSubsets(0); - - //- find the number of subsets - std::map<word, labelListPMG>::const_iterator iter; - for(iter = triSubsets_.begin();iter != triSubsets_.end();++iter) - ++nSubsets; - file << nSubsets << nl; - - //- write subsets - for(iter = triSubsets_.begin();iter != triSubsets_.end();++iter) - { - file << iter->first << nl; - file << iter->second << nl; - } + OFstream file(fName); + + label nSubsets(0); + + //- find the number of subsets + std::map<word, labelListPMG>::const_iterator iter; + for(iter = triSubsets_.begin();iter != triSubsets_.end();++iter) + ++nSubsets; + file << nSubsets << nl; + + //- write subsets + for(iter = triSubsets_.begin();iter != triSubsets_.end();++iter) + { + file << iter->first << nl; + file << iter->second << nl; + } } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/meshLibrary/utilities/meshes/triSurf/triSurf.H b/meshLibrary/utilities/meshes/triSurf/triSurf.H index 4b2ff732..242a73a4 100644 --- a/meshLibrary/utilities/meshes/triSurf/triSurf.H +++ b/meshLibrary/utilities/meshes/triSurf/triSurf.H @@ -27,8 +27,8 @@ Class Description A class for triangulated surface used in the meshing process. - It is derived from triSurface with some additional subsets. - Subsets are vert useful for local mesh refinement. + It is derived from triSurface with some additional subsets. + Subsets are vert useful for local mesh refinement. SourceFiles triSurf.C diff --git a/meshLibrary/utilities/octrees/meshOctree/meshOctreeAddressing/meshOctreeAddressing.C b/meshLibrary/utilities/octrees/meshOctree/meshOctreeAddressing/meshOctreeAddressing.C index cca03d53..a32c6114 100644 --- a/meshLibrary/utilities/octrees/meshOctree/meshOctreeAddressing/meshOctreeAddressing.C +++ b/meshLibrary/utilities/octrees/meshOctree/meshOctreeAddressing/meshOctreeAddressing.C @@ -51,12 +51,12 @@ void meshOctreeAddressing::clearOut() void meshOctreeAddressing::clearNodeAddressing() { - nNodes_ = 0; + nNodes_ = 0; deleteDemandDrivenData(octreePointsPtr_); - deleteDemandDrivenData(nodeLabelsPtr_); - deleteDemandDrivenData(nodeLeavesPtr_); + deleteDemandDrivenData(nodeLabelsPtr_); + deleteDemandDrivenData(nodeLeavesPtr_); - deleteDemandDrivenData(nodeTypePtr_); + deleteDemandDrivenData(nodeTypePtr_); } void meshOctreeAddressing::clearBoxTypes() @@ -104,18 +104,18 @@ meshOctreeAddressing::meshOctreeAddressing ( const meshOctree& mo, const dictionary& dict, - bool useDATABoxes + bool useDATABoxes ) : - octree_(mo), - meshDict_(dict), - useDATABoxes_(useDATABoxes), - nNodes_(0), + octree_(mo), + meshDict_(dict), + useDATABoxes_(useDATABoxes), + nNodes_(0), octreePointsPtr_(NULL), - nodeLabelsPtr_(NULL), - nodeLeavesPtr_(NULL), - boxTypePtr_(NULL), - nodeTypePtr_(NULL), + nodeLabelsPtr_(NULL), + nodeLeavesPtr_(NULL), + boxTypePtr_(NULL), + nodeTypePtr_(NULL), octreeFacesPtr_(NULL), octreeFacesOwnersPtr_(NULL), octreeFacesNeighboursPtr_(NULL), @@ -160,15 +160,15 @@ meshOctreeAddressing::meshOctreeAddressing om.addLayerFromNeighbouringProcessors(); } - //- check for glued regions - checkGluedRegions(); + //- check for glued regions + checkGluedRegions(); } // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // meshOctreeAddressing::~meshOctreeAddressing() { - clearOut(); + clearOut(); } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -381,103 +381,103 @@ void meshOctreeAddressing::edgeIntersections void meshOctreeAddressing::cubesAroundEdge ( - const label leafI, - const direction eI, - FixedList<label, 4>& edgeCubes + const label leafI, + const direction eI, + FixedList<label, 4>& edgeCubes ) const { - const VRWGraph& nl = this->nodeLabels(); - const label nodeI = nl(leafI, meshOctreeCubeCoordinates::edgeNodes_[eI][0]); - const FRWGraph<label, 8>& pLeaves = this->nodeLeaves(); - - switch( eI ) - { - case 0: case 1: case 2: case 3: - { - edgeCubes[0] = pLeaves(nodeI, 1); - edgeCubes[1] = pLeaves(nodeI, 3); - edgeCubes[2] = pLeaves(nodeI, 5); - edgeCubes[3] = pLeaves(nodeI, 7); - } break; - case 4: case 5: case 6: case 7: - { - edgeCubes[0] = pLeaves(nodeI, 2); - edgeCubes[1] = pLeaves(nodeI, 3); - edgeCubes[2] = pLeaves(nodeI, 6); - edgeCubes[3] = pLeaves(nodeI, 7); - } break; - case 8: case 9: case 10: case 11: - { - edgeCubes[0] = pLeaves(nodeI, 4); - edgeCubes[1] = pLeaves(nodeI, 5); - edgeCubes[2] = pLeaves(nodeI, 6); - edgeCubes[3] = pLeaves(nodeI, 7); - } break; - default: - { - FatalErrorIn - ( - "void tetMeshExtractorOctree::cubesAroundEdge(const label," - "const direction, FixedList<label, 4>&)" - ) << "Invalid edge specified!!" << abort(FatalError); - } break; - }; + const VRWGraph& nl = this->nodeLabels(); + const label nodeI = nl(leafI, meshOctreeCubeCoordinates::edgeNodes_[eI][0]); + const FRWGraph<label, 8>& pLeaves = this->nodeLeaves(); + + switch( eI ) + { + case 0: case 1: case 2: case 3: + { + edgeCubes[0] = pLeaves(nodeI, 1); + edgeCubes[1] = pLeaves(nodeI, 3); + edgeCubes[2] = pLeaves(nodeI, 5); + edgeCubes[3] = pLeaves(nodeI, 7); + } break; + case 4: case 5: case 6: case 7: + { + edgeCubes[0] = pLeaves(nodeI, 2); + edgeCubes[1] = pLeaves(nodeI, 3); + edgeCubes[2] = pLeaves(nodeI, 6); + edgeCubes[3] = pLeaves(nodeI, 7); + } break; + case 8: case 9: case 10: case 11: + { + edgeCubes[0] = pLeaves(nodeI, 4); + edgeCubes[1] = pLeaves(nodeI, 5); + edgeCubes[2] = pLeaves(nodeI, 6); + edgeCubes[3] = pLeaves(nodeI, 7); + } break; + default: + { + FatalErrorIn + ( + "void tetMeshExtractorOctree::cubesAroundEdge(const label," + "const direction, FixedList<label, 4>&)" + ) << "Invalid edge specified!!" << abort(FatalError); + } break; + }; } label meshOctreeAddressing::findEdgeCentre ( - const label leafI, - const direction eI + const label leafI, + const direction eI ) const { - const meshOctreeCubeBasic& oc = octree_.returnLeaf(leafI); - const VRWGraph& nl = this->nodeLabels(); - const label nodeI = nl(leafI, meshOctreeCubeCoordinates::edgeNodes_[eI][0]); - const FRWGraph<label, 8>& pLeaves = this->nodeLeaves(); - - const direction level = oc.level(); - - label fI(-1); - switch( eI ) - { - case 0: case 1: case 2: case 3: - { - fI = 1; - } break; - case 4: case 5: case 6: case 7: - { - fI = 3; - } break; - case 8: case 9: case 10: case 11: - { - fI = 5; - } break; - default: - { - FatalErrorIn - ( - "label meshOctreeAddressing::findEdgeCentre" + const meshOctreeCubeBasic& oc = octree_.returnLeaf(leafI); + const VRWGraph& nl = this->nodeLabels(); + const label nodeI = nl(leafI, meshOctreeCubeCoordinates::edgeNodes_[eI][0]); + const FRWGraph<label, 8>& pLeaves = this->nodeLeaves(); + + const direction level = oc.level(); + + label fI(-1); + switch( eI ) + { + case 0: case 1: case 2: case 3: + { + fI = 1; + } break; + case 4: case 5: case 6: case 7: + { + fI = 3; + } break; + case 8: case 9: case 10: case 11: + { + fI = 5; + } break; + default: + { + FatalErrorIn + ( + "label meshOctreeAddressing::findEdgeCentre" "(const label leafI, const direction eI) const" - ) << "Invalid edge specified!!" << abort(FatalError); - } break; - }; + ) << "Invalid edge specified!!" << abort(FatalError); + } break; + }; - for(label i=0;i<4;++i) - { + for(label i=0;i<4;++i) + { const label fNode = meshOctreeCubeCoordinates::faceNodes_[fI][i]; - if( pLeaves(nodeI, fNode) < 0 ) - continue; + if( pLeaves(nodeI, fNode) < 0 ) + continue; - const label leafJ = pLeaves(nodeI, fNode); - if( octree_.returnLeaf(leafJ).level() > level ) + const label leafJ = pLeaves(nodeI, fNode); + if( octree_.returnLeaf(leafJ).level() > level ) { const label shift = (i+2)%4; - return nl(leafJ, meshOctreeCubeCoordinates::faceNodes_[fI][shift]); + return nl(leafJ, meshOctreeCubeCoordinates::faceNodes_[fI][shift]); } - } + } - return -1; + return -1; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/meshLibrary/utilities/octrees/meshOctree/meshOctreeAddressing/meshOctreeAddressing.H b/meshLibrary/utilities/octrees/meshOctree/meshOctreeAddressing/meshOctreeAddressing.H index 02f08be8..09e9b2df 100644 --- a/meshLibrary/utilities/octrees/meshOctree/meshOctreeAddressing/meshOctreeAddressing.H +++ b/meshLibrary/utilities/octrees/meshOctree/meshOctreeAddressing/meshOctreeAddressing.H @@ -27,7 +27,7 @@ Class Description Automatic octree for mesh generation. This class checks if the current - octree resolution is enough to resolve all surface features + octree resolution is enough to resolve all surface features SourceFiles meshOctreeAddressing.C @@ -61,32 +61,32 @@ class IOdictionary; class meshOctreeAddressing { // Private data - //- reference to the octree - const meshOctree& octree_; - - //- reference to the dictionary - const dictionary& meshDict_; - - //- use DATA boxes - bool useDATABoxes_; - - //- number of created octree nodes - mutable label nNodes_; + //- reference to the octree + const meshOctree& octree_; + + //- reference to the dictionary + const dictionary& meshDict_; + + //- use DATA boxes + bool useDATABoxes_; + + //- number of created octree nodes + mutable label nNodes_; //- coordinates of octree nodes mutable pointField* octreePointsPtr_; - - //- node labels - mutable VRWGraph* nodeLabelsPtr_; + + //- node labels + mutable VRWGraph* nodeLabelsPtr_; //- node leaves - mutable FRWGraph<label, 8>* nodeLeavesPtr_; + mutable FRWGraph<label, 8>* nodeLeavesPtr_; - //- identify which boxes should be used as mesh cells - mutable List<direction>* boxTypePtr_; + //- identify which boxes should be used as mesh cells + mutable List<direction>* boxTypePtr_; //- identify created nodes as OUTERNODE or INNERNODE - mutable List<direction>* nodeTypePtr_; + mutable List<direction>* nodeTypePtr_; // Additional addressing useful for some algorithms //- faces of the octree @@ -147,22 +147,22 @@ class meshOctreeAddressing //- leaf at procs mutable VRWGraph* leafAtProcsPtr_; - - // Private member functions + + // Private member functions //- calculate octreePointsPtr_ void createOctreePoints() const; - //- calculate nodeLabelsPtr_ - void createNodeLabels() const; - - //- calculate nodeLeavesPtr_ - void createNodeLeaves() const; - - //- assemble boxTypePtr_ list - void findUsedBoxes() const; - - //- calculate nodeTypePtr_ - void calculateNodeType() const; + //- calculate nodeLabelsPtr_ + void createNodeLabels() const; + + //- calculate nodeLeavesPtr_ + void createNodeLeaves() const; + + //- assemble boxTypePtr_ list + void findUsedBoxes() const; + + //- calculate nodeTypePtr_ + void calculateNodeType() const; //- calculate faces void createOctreeFaces() const; @@ -187,17 +187,17 @@ class meshOctreeAddressing //- calculate edge-faces void calculateEdgeFaces() const; - - //- Clear allocated data - void clearOut(); + + //- Clear allocated data + void clearOut(); void clearBoxTypes(); void clearNodeAddressing(); void clearOctreeFaces(); void clearAddressing(); void clearParallelAddressing(); - - //- check if distinct parts are glued together - void checkGluedRegions(); + + //- check if distinct parts are glued together + void checkGluedRegions(); // Private member functions for parallel runs @@ -218,29 +218,29 @@ public: //- Construct from surface and dictionary meshOctreeAddressing - ( - const meshOctree& mo, - const dictionary& dict, - bool useDATABoxes = false - ); + ( + const meshOctree& mo, + const dictionary& dict, + bool useDATABoxes = false + ); // Destructor ~meshOctreeAddressing(); - // Enumerators - - enum octreeCubeTypes - { - NONE = 0, - MESHCELL = 1, - BOUNDARY = 2, - SPLITHEX = 4, - INNERNODE = 8, - OUTERNODE = 16, - BOUNDARYNODE = 32 - }; - + // Enumerators + + enum octreeCubeTypes + { + NONE = 0, + MESHCELL = 1, + BOUNDARY = 2, + SPLITHEX = 4, + INNERNODE = 8, + OUTERNODE = 16, + BOUNDARYNODE = 32 + }; + // Member Functions //- check if there exist any non-signly connected edges and vertices @@ -248,26 +248,26 @@ public: //- for the cartesian template void checkAndFixIrregularConnections(); - //- return number of octree nodes - inline label numberOfNodes() const; + //- return number of octree nodes + inline label numberOfNodes() const; //- return coordinates of octree vertices inline const pointField& octreePoints() const; - //- return nodeLabels - inline const VRWGraph& nodeLabels() const; + //- return nodeLabels + inline const VRWGraph& nodeLabels() const; - //- return nodeLeaves - inline const FRWGraph<label, 8>& nodeLeaves() const; - - //- return which octree boxes are used for mesh creation - inline const List<direction>& boxType() const; + //- return nodeLeaves + inline const FRWGraph<label, 8>& nodeLeaves() const; + + //- return which octree boxes are used for mesh creation + inline const List<direction>& boxType() const; //- return type of node (INNERNODE,or OUTERNODE) inline const List<direction>& nodeType() const; - - //- set box type - inline void setBoxType(const label boxI, const direction type); + + //- set box type + inline void setBoxType(const label boxI, const direction type); //- return octree faces, created for MESHCELL boxes inline const VRWGraph& octreeFaces() const; @@ -315,20 +315,20 @@ public: //- return edge-faces addressing inline const VRWGraph& edgeFaces() const; - - //- return const reference to meshOctree - inline const meshOctree& octree() const; - - //- find cubes around an edge (cubes must be at the same level) - void cubesAroundEdge - ( - const label leafI, - const direction eI, - FixedList<label, 4>& edgeCubes - ) const; - - //- find edge centre if it exists - label findEdgeCentre(const label leafI, const direction eI) const; + + //- return const reference to meshOctree + inline const meshOctree& octree() const; + + //- find cubes around an edge (cubes must be at the same level) + void cubesAroundEdge + ( + const label leafI, + const direction eI, + FixedList<label, 4>& edgeCubes + ) const; + + //- find edge centre if it exists + label findEdgeCentre(const label leafI, const direction eI) const; // Access to data needed for parallel execution diff --git a/meshLibrary/utilities/octrees/meshOctree/meshOctreeAddressing/meshOctreeAddressingCreation.C b/meshLibrary/utilities/octrees/meshOctree/meshOctreeAddressing/meshOctreeAddressingCreation.C index b0c7da50..bb8f75de 100644 --- a/meshLibrary/utilities/octrees/meshOctree/meshOctreeAddressing/meshOctreeAddressingCreation.C +++ b/meshLibrary/utilities/octrees/meshOctree/meshOctreeAddressing/meshOctreeAddressingCreation.C @@ -67,17 +67,17 @@ void meshOctreeAddressing::createOctreePoints() const forAllRow(nodeLabels, cubeI, pI) { forAllRow(nodeLabels, cubeI, nI) - octreePoints[nodeLabels(cubeI, nI)] = vertices[nI]; + octreePoints[nodeLabels(cubeI, nI)] = vertices[nI]; } } } void meshOctreeAddressing::createNodeLabels() const { - const List<direction>& boxType = this->boxType(); + const List<direction>& boxType = this->boxType(); - nodeLabelsPtr_ = new VRWGraph(octree_.numberOfLeaves()); - VRWGraph& nodeLabels = *nodeLabelsPtr_; + nodeLabelsPtr_ = new VRWGraph(octree_.numberOfLeaves()); + VRWGraph& nodeLabels = *nodeLabelsPtr_; //- allocate storage for node labels forAll(nodeLabels, leafI) @@ -232,11 +232,11 @@ void meshOctreeAddressing::createNodeLabels() const void meshOctreeAddressing::createNodeLeaves() const { const List<direction>& boxType = this->boxType(); - const VRWGraph& nodeLabels = this->nodeLabels(); + const VRWGraph& nodeLabels = this->nodeLabels(); - //- allocate nodeLeavesPtr_ - nodeLeavesPtr_ = new FRWGraph<label, 8>(nNodes_); - FRWGraph<label, 8>& nodeLeaves = *nodeLeavesPtr_; + //- allocate nodeLeavesPtr_ + nodeLeavesPtr_ = new FRWGraph<label, 8>(nNodes_); + FRWGraph<label, 8>& nodeLeaves = *nodeLeavesPtr_; boolList storedNode(nNodes_, false); # pragma omp parallel for schedule(dynamic, 100) @@ -270,20 +270,20 @@ void meshOctreeAddressing::createNodeLeaves() const void meshOctreeAddressing::findUsedBoxes() const { - boxTypePtr_ = new List<direction>(octree_.numberOfLeaves(), NONE); - List<direction>& boxType = *boxTypePtr_; + boxTypePtr_ = new List<direction>(octree_.numberOfLeaves(), NONE); + List<direction>& boxType = *boxTypePtr_; # pragma omp parallel for schedule(dynamic, 40) forAll(boxType, leafI) - { - const meshOctreeCubeBasic& leaf = octree_.returnLeaf(leafI); + { + const meshOctreeCubeBasic& leaf = octree_.returnLeaf(leafI); - if( - !octree_.hasContainedTriangles(leafI) && - (leaf.cubeType() & meshOctreeCubeBasic::INSIDE) - ) - boxType[leafI] |= MESHCELL; - } + if( + !octree_.hasContainedTriangles(leafI) && + (leaf.cubeType() & meshOctreeCubeBasic::INSIDE) + ) + boxType[leafI] |= MESHCELL; + } if( meshDict_.found("nonManifoldMeshing") ) { @@ -304,14 +304,14 @@ void meshOctreeAddressing::findUsedBoxes() const } } - if( useDATABoxes_ ) - { - Info << "Using DATA boxes" << endl; + if( useDATABoxes_ ) + { + Info << "Using DATA boxes" << endl; forAll(boxType, leafI) { - if( octree_.hasContainedTriangles(leafI) ) - boxType[leafI] |= MESHCELL; + if( octree_.hasContainedTriangles(leafI) ) + boxType[leafI] |= MESHCELL; } //- do not use boxes intersecting given patches @@ -365,13 +365,13 @@ void meshOctreeAddressing::findUsedBoxes() const } } } - } - else if( meshDict_.found("keepCellsIntersectingPatches") ) - { - const wordHashSet patchesToKeep - ( - meshDict_.lookup("keepCellsIntersectingPatches") - ); + } + else if( meshDict_.found("keepCellsIntersectingPatches") ) + { + const wordHashSet patchesToKeep + ( + meshDict_.lookup("keepCellsIntersectingPatches") + ); const triSurf& ts = octree_.surface(); boolList keepFacets(ts.size(), false); @@ -415,34 +415,34 @@ void meshOctreeAddressing::findUsedBoxes() const } } } - } + } - //- set BOUNDARY flag to boxes which do not have a MESHCELL flag - DynList<label> neighs; - # pragma omp parallel for if( boxType.size() > 1000 ) \ + //- set BOUNDARY flag to boxes which do not have a MESHCELL flag + DynList<label> neighs; + # pragma omp parallel for if( boxType.size() > 1000 ) \ private(neighs) schedule(dynamic, 20) - forAll(boxType, leafI) - { - if( boxType[leafI] & MESHCELL ) - { - for(label i=0;i<6;++i) - { - neighs.clear(); - octree_.findNeighboursInDirection(leafI, i, neighs); - - forAll(neighs, neiI) - { - const label neiLabel = neighs[neiI]; + forAll(boxType, leafI) + { + if( boxType[leafI] & MESHCELL ) + { + for(label i=0;i<6;++i) + { + neighs.clear(); + octree_.findNeighboursInDirection(leafI, i, neighs); + + forAll(neighs, neiI) + { + const label neiLabel = neighs[neiI]; if( neiLabel < 0 ) continue; - if( !(boxType[neiLabel] & MESHCELL) ) - boxType[neiLabel] = BOUNDARY; - } - } - } - } + if( !(boxType[neiLabel] & MESHCELL) ) + boxType[neiLabel] = BOUNDARY; + } + } + } + } if( Pstream::parRun() ) { @@ -492,41 +492,41 @@ void meshOctreeAddressing::findUsedBoxes() const void meshOctreeAddressing::calculateNodeType() const { - const FRWGraph<label, 8>& nodeLeaves = this->nodeLeaves(); + const FRWGraph<label, 8>& nodeLeaves = this->nodeLeaves(); - nodeTypePtr_ = new List<direction>(nNodes_, NONE); - List<direction>& nodeType = *nodeTypePtr_; + nodeTypePtr_ = new List<direction>(nNodes_, NONE); + List<direction>& nodeType = *nodeTypePtr_; - # pragma omp parallel for schedule(static, 1) - forAll(nodeLeaves, nodeI) - { - forAllRow(nodeLeaves, nodeI, nlI) - { - const label leafI = nodeLeaves(nodeI, nlI); + # pragma omp parallel for schedule(static, 1) + forAll(nodeLeaves, nodeI) + { + forAllRow(nodeLeaves, nodeI, nlI) + { + const label leafI = nodeLeaves(nodeI, nlI); - if( leafI == -1 ) - continue; + if( leafI == -1 ) + continue; - const meshOctreeCubeBasic& oc = octree_.returnLeaf(leafI); + const meshOctreeCubeBasic& oc = octree_.returnLeaf(leafI); - if( + if( (oc.cubeType() & meshOctreeCubeBasic::OUTSIDE) || (oc.cubeType() & meshOctreeCubeBasic::UNKNOWN) ) - { - nodeType[nodeI] |= OUTERNODE; - break; - } - else if( - !octree_.hasContainedTriangles(leafI) && - (oc.cubeType() & meshOctreeCubeBasic::INSIDE) - ) - { - nodeType[nodeI] |= INNERNODE; - break; - } - } - } + { + nodeType[nodeI] |= OUTERNODE; + break; + } + else if( + !octree_.hasContainedTriangles(leafI) && + (oc.cubeType() & meshOctreeCubeBasic::INSIDE) + ) + { + nodeType[nodeI] |= INNERNODE; + break; + } + } + } } void meshOctreeAddressing::createOctreeFaces() const @@ -537,252 +537,252 @@ void meshOctreeAddressing::createOctreeFaces() const const VRWGraph& nodeLabels = this->nodeLabels(); const List<direction>& boxType = this->boxType(); - this->nodeLeaves(); - - label nFaces(0); - labelList rowSizes, chunkSizes; - - # pragma omp parallel - { - //- faces are created and stored into helper arrays, and each thread - //- allocates its own graph for storing faces. The faces are generated - //- by dividing the octree leaves into chunks, and distributing these - //- chunks over the threads. There are four chunks per each thread to - //- improve load balancing. The number of faces generated in each chunk - //- is stored and later in used to store the faces into the octree faces - //- graph in the correct order - VRWGraph helperFaces; - labelListPMG helperOwner, helperNeighbour; - - const label nChunks = 4 * omp_get_num_threads(); - const label chunkSize = boxType.size() / nChunks + 1; - - # pragma omp master - { - chunkSizes.setSize(nChunks); - chunkSizes = 0; - } - - # pragma omp barrier - - for - ( - label chunkI=omp_get_thread_num(); - chunkI<nChunks; - chunkI+=omp_get_num_threads() - ) - { - const label start = chunkSize * chunkI; - const label end = Foam::min(start+chunkSize, boxType.size()); - - const label nBefore = helperFaces.size(); - - for(label leafI=start;leafI<end;++leafI) - { - const meshOctreeCubeBasic& oc = octree_.returnLeaf(leafI); - - if( boxType[leafI] & MESHCELL ) - { - FixedList<label, 12> edgeCentreLabel; - for(label i=0;i<12;++i) - edgeCentreLabel[i] = findEdgeCentre(leafI, i); - - for(label fI=0;fI<6;++fI) - { - DynList<label> neighbours; - octree_.findNeighboursInDirection - ( - leafI, - fI, - neighbours - ); - - if( neighbours.size() != 1 ) - continue; - - const label nei = neighbours[0]; - - //- stop if the neighbour is on other processor - if( nei == meshOctreeCubeBasic::OTHERPROC ) - continue; - - //- create face - DynList<label, 8> f; - for(label pI=0;pI<4;++pI) - { - const label nI = - meshOctreeCubeCoordinates::faceNodes_[fI][pI]; - const label feI = - meshOctreeCubeCoordinates::faceEdges_[fI][pI]; - - f.append(nodeLabels(leafI, nI)); - - if( edgeCentreLabel[feI] != -1 ) - f.append(edgeCentreLabel[feI]); - } - - if( nei < 0 ) - { - //- face is at the boundary of the octree - helperFaces.appendList(f); - helperOwner.append(leafI); - helperNeighbour.append(-1); - } - else if( boxType[nei] & MESHCELL ) - { - //- face is an internal face - if( nei > leafI ) - { - helperFaces.appendList(f); - helperOwner.append(leafI); - helperNeighbour.append(nei); - } - else if - ( - octree_.returnLeaf(nei).level() < oc.level() - ) - { - //- append a reversed face - label i(1); - for(label j=f.size()-1;j>i;--j) - { - const label add = f[j]; - f[j] = f[i]; - f[i] = add; - ++i; - } - - helperFaces.appendList(f); - helperOwner.append(nei); - helperNeighbour.append(leafI); - } - } - else if( boxType[nei] & BOUNDARY ) - { - //- face is at the boundary of the mesh cells - helperFaces.appendList(f); - helperOwner.append(leafI); - helperNeighbour.append(nei); - } - } - } - else if( boxType[leafI] & BOUNDARY ) - { - for(label fI=0;fI<6;++fI) - { - DynList<label> neighbours; - octree_.findNeighboursInDirection - ( - leafI, - fI, - neighbours - ); - - if( neighbours.size() != 1 ) - continue; - const label nei = neighbours[0]; - if( nei < 0 ) - continue; - if( - (boxType[nei] & MESHCELL) && - (octree_.returnLeaf(nei).level() < oc.level()) - ) - { - //- add a boundary face - const label* fNodes = - meshOctreeCubeCoordinates::faceNodes_[fI]; - face cf(4); - for(label i=0;i<4;++i) - { - cf[i] = nodeLabels(leafI, fNodes[i]); - } - - helperFaces.appendList(cf.reverseFace()); - helperOwner.append(nei); - helperNeighbour.append(leafI); - } - } - } - } - - //- store the size of this chunk - chunkSizes[chunkI] = helperFaces.size() - nBefore; - } - - //- set the sizes of faces graph - # pragma omp critical - nFaces += helperFaces.size(); - - # pragma omp barrier - - # pragma omp master - { - rowSizes.setSize(nFaces); - octreeFacesPtr_->setSize(nFaces); - octreeFacesOwnersPtr_->setSize(nFaces); - octreeFacesNeighboursPtr_->setSize(nFaces); - } - - # pragma omp barrier - - //- set the size of face graph rows and copy owners and neighbours - for - ( - label chunkI=omp_get_thread_num(); - chunkI<nChunks; - chunkI+=omp_get_num_threads() - ) - { - label start(0), localStart(0); - for(label i=0;i<chunkI;++i) - start += chunkSizes[i]; - for(label i=omp_get_thread_num();i<chunkI;i+=omp_get_num_threads()) - localStart += chunkSizes[i]; - - for(label faceI=0;faceI<chunkSizes[chunkI];++faceI) - { - octreeFacesOwnersPtr_->operator[](start) = - helperOwner[localStart]; - octreeFacesNeighboursPtr_->operator[](start) = - helperNeighbour[localStart]; - rowSizes[start++] = helperFaces.sizeOfRow(localStart++); - } - } - - # pragma omp barrier - - //- set the size of octree faces - # pragma omp master - VRWGraphSMPModifier(*octreeFacesPtr_).setSizeAndRowSize(rowSizes); - - # pragma omp barrier - - //- copy the data into octree faces - for - ( - label chunkI=omp_get_thread_num(); - chunkI<nChunks; - chunkI+=omp_get_num_threads() - ) - { - label start(0), localStart(0); - - for(label i=0;i<chunkI;++i) - start += chunkSizes[i]; - for(label i=omp_get_thread_num();i<chunkI;i+=omp_get_num_threads()) - localStart += chunkSizes[i]; - - for(label faceI=0;faceI<chunkSizes[chunkI];++faceI) - { - for(label i=0;i<helperFaces.sizeOfRow(localStart);++i) - octreeFacesPtr_->operator()(start, i) = - helperFaces(localStart, i); - - ++start; - ++localStart; - } - } - } + this->nodeLeaves(); + + label nFaces(0); + labelList rowSizes, chunkSizes; + + # pragma omp parallel + { + //- faces are created and stored into helper arrays, and each thread + //- allocates its own graph for storing faces. The faces are generated + //- by dividing the octree leaves into chunks, and distributing these + //- chunks over the threads. There are four chunks per each thread to + //- improve load balancing. The number of faces generated in each chunk + //- is stored and later in used to store the faces into the octree faces + //- graph in the correct order + VRWGraph helperFaces; + labelListPMG helperOwner, helperNeighbour; + + const label nChunks = 4 * omp_get_num_threads(); + const label chunkSize = boxType.size() / nChunks + 1; + + # pragma omp master + { + chunkSizes.setSize(nChunks); + chunkSizes = 0; + } + + # pragma omp barrier + + for + ( + label chunkI=omp_get_thread_num(); + chunkI<nChunks; + chunkI+=omp_get_num_threads() + ) + { + const label start = chunkSize * chunkI; + const label end = Foam::min(start+chunkSize, boxType.size()); + + const label nBefore = helperFaces.size(); + + for(label leafI=start;leafI<end;++leafI) + { + const meshOctreeCubeBasic& oc = octree_.returnLeaf(leafI); + + if( boxType[leafI] & MESHCELL ) + { + FixedList<label, 12> edgeCentreLabel; + for(label i=0;i<12;++i) + edgeCentreLabel[i] = findEdgeCentre(leafI, i); + + for(label fI=0;fI<6;++fI) + { + DynList<label> neighbours; + octree_.findNeighboursInDirection + ( + leafI, + fI, + neighbours + ); + + if( neighbours.size() != 1 ) + continue; + + const label nei = neighbours[0]; + + //- stop if the neighbour is on other processor + if( nei == meshOctreeCubeBasic::OTHERPROC ) + continue; + + //- create face + DynList<label, 8> f; + for(label pI=0;pI<4;++pI) + { + const label nI = + meshOctreeCubeCoordinates::faceNodes_[fI][pI]; + const label feI = + meshOctreeCubeCoordinates::faceEdges_[fI][pI]; + + f.append(nodeLabels(leafI, nI)); + + if( edgeCentreLabel[feI] != -1 ) + f.append(edgeCentreLabel[feI]); + } + + if( nei < 0 ) + { + //- face is at the boundary of the octree + helperFaces.appendList(f); + helperOwner.append(leafI); + helperNeighbour.append(-1); + } + else if( boxType[nei] & MESHCELL ) + { + //- face is an internal face + if( nei > leafI ) + { + helperFaces.appendList(f); + helperOwner.append(leafI); + helperNeighbour.append(nei); + } + else if + ( + octree_.returnLeaf(nei).level() < oc.level() + ) + { + //- append a reversed face + label i(1); + for(label j=f.size()-1;j>i;--j) + { + const label add = f[j]; + f[j] = f[i]; + f[i] = add; + ++i; + } + + helperFaces.appendList(f); + helperOwner.append(nei); + helperNeighbour.append(leafI); + } + } + else if( boxType[nei] & BOUNDARY ) + { + //- face is at the boundary of the mesh cells + helperFaces.appendList(f); + helperOwner.append(leafI); + helperNeighbour.append(nei); + } + } + } + else if( boxType[leafI] & BOUNDARY ) + { + for(label fI=0;fI<6;++fI) + { + DynList<label> neighbours; + octree_.findNeighboursInDirection + ( + leafI, + fI, + neighbours + ); + + if( neighbours.size() != 1 ) + continue; + const label nei = neighbours[0]; + if( nei < 0 ) + continue; + if( + (boxType[nei] & MESHCELL) && + (octree_.returnLeaf(nei).level() < oc.level()) + ) + { + //- add a boundary face + const label* fNodes = + meshOctreeCubeCoordinates::faceNodes_[fI]; + face cf(4); + for(label i=0;i<4;++i) + { + cf[i] = nodeLabels(leafI, fNodes[i]); + } + + helperFaces.appendList(cf.reverseFace()); + helperOwner.append(nei); + helperNeighbour.append(leafI); + } + } + } + } + + //- store the size of this chunk + chunkSizes[chunkI] = helperFaces.size() - nBefore; + } + + //- set the sizes of faces graph + # pragma omp critical + nFaces += helperFaces.size(); + + # pragma omp barrier + + # pragma omp master + { + rowSizes.setSize(nFaces); + octreeFacesPtr_->setSize(nFaces); + octreeFacesOwnersPtr_->setSize(nFaces); + octreeFacesNeighboursPtr_->setSize(nFaces); + } + + # pragma omp barrier + + //- set the size of face graph rows and copy owners and neighbours + for + ( + label chunkI=omp_get_thread_num(); + chunkI<nChunks; + chunkI+=omp_get_num_threads() + ) + { + label start(0), localStart(0); + for(label i=0;i<chunkI;++i) + start += chunkSizes[i]; + for(label i=omp_get_thread_num();i<chunkI;i+=omp_get_num_threads()) + localStart += chunkSizes[i]; + + for(label faceI=0;faceI<chunkSizes[chunkI];++faceI) + { + octreeFacesOwnersPtr_->operator[](start) = + helperOwner[localStart]; + octreeFacesNeighboursPtr_->operator[](start) = + helperNeighbour[localStart]; + rowSizes[start++] = helperFaces.sizeOfRow(localStart++); + } + } + + # pragma omp barrier + + //- set the size of octree faces + # pragma omp master + VRWGraphSMPModifier(*octreeFacesPtr_).setSizeAndRowSize(rowSizes); + + # pragma omp barrier + + //- copy the data into octree faces + for + ( + label chunkI=omp_get_thread_num(); + chunkI<nChunks; + chunkI+=omp_get_num_threads() + ) + { + label start(0), localStart(0); + + for(label i=0;i<chunkI;++i) + start += chunkSizes[i]; + for(label i=omp_get_thread_num();i<chunkI;i+=omp_get_num_threads()) + localStart += chunkSizes[i]; + + for(label faceI=0;faceI<chunkSizes[chunkI];++faceI) + { + for(label i=0;i<helperFaces.sizeOfRow(localStart);++i) + octreeFacesPtr_->operator()(start, i) = + helperFaces(localStart, i); + + ++start; + ++localStart; + } + } + } # ifdef DEBUGVrt List<vector> sum(octree_.numberOfLeaves(), vector::zero); diff --git a/meshLibrary/utilities/octrees/meshOctree/meshOctreeAddressing/meshOctreeAddressingGluedMesh.C b/meshLibrary/utilities/octrees/meshOctree/meshOctreeAddressing/meshOctreeAddressingGluedMesh.C index ac62e38e..bf11865b 100644 --- a/meshLibrary/utilities/octrees/meshOctree/meshOctreeAddressing/meshOctreeAddressingGluedMesh.C +++ b/meshLibrary/utilities/octrees/meshOctree/meshOctreeAddressing/meshOctreeAddressingGluedMesh.C @@ -42,97 +42,97 @@ namespace Foam void meshOctreeAddressing::checkGluedRegions() { - if( !useDATABoxes_ ) - return; - - if( meshDict_.found("checkForGluedMesh") ) - { - if( !readBool(meshDict_.lookup("checkForGluedMesh")) ) - return; - } - else - { - return; - } - - Info << "Removing glued regions" << endl; - const List<direction>& boxType = this->boxType(); - const VRWGraph& nodeLabels = this->nodeLabels(); - const List<direction>& nodeType = this->nodeType(); + if( !useDATABoxes_ ) + return; + + if( meshDict_.found("checkForGluedMesh") ) + { + if( !readBool(meshDict_.lookup("checkForGluedMesh")) ) + return; + } + else + { + return; + } + + Info << "Removing glued regions" << endl; + const List<direction>& boxType = this->boxType(); + const VRWGraph& nodeLabels = this->nodeLabels(); + const List<direction>& nodeType = this->nodeType(); const VRWGraph& edgeLeaves = this->edgeLeaves(); const VRWGraph& leafEdges = this->leafEdges(); const FRWGraph<label, 8>& nodeLeaves = this->nodeLeaves(); const LongList<edge>& edges = this->octreeEdges(); - - DynList<label> neighbours(4); + + DynList<label> neighbours(4); labelListPMG removeBox; - forAll(boxType, leafI) + forAll(boxType, leafI) { - if( - octree_.hasContainedTriangles(leafI) && - (boxType[leafI] & MESHCELL) - ) - { - //- mark the initial INNERNODE + if( + octree_.hasContainedTriangles(leafI) && + (boxType[leafI] & MESHCELL) + ) + { + //- mark the initial INNERNODE labelHashSet innerNodes; - forAllRow(nodeLabels, leafI, nodeI) - if( nodeType[nodeLabels(leafI, nodeI)] & INNERNODE ) - { - innerNodes.insert(nodeLabels(leafI, nodeI)); - break; - } - - //- mark all INNERNODEs for which it is possible to walk along - //- cubes edges without crossing any boundary - bool finished; - do - { - finished = true; - - forAllRow(leafEdges, leafI, leI) - { + forAllRow(nodeLabels, leafI, nodeI) + if( nodeType[nodeLabels(leafI, nodeI)] & INNERNODE ) + { + innerNodes.insert(nodeLabels(leafI, nodeI)); + break; + } + + //- mark all INNERNODEs for which it is possible to walk along + //- cubes edges without crossing any boundary + bool finished; + do + { + finished = true; + + forAllRow(leafEdges, leafI, leI) + { const label edgeI = leafEdges(leafI, leI); const edge& edg = edges[edgeI]; - const label s = edg[0]; - const label e = edg[1]; - - if( - (nodeType[s] & INNERNODE) && (nodeType[e] & INNERNODE) - && (innerNodes.found(s) ^ innerNodes.found(e)) - ) - { - bool foundInside(false); - forAllRow(edgeLeaves, edgeI, elI) - { + const label s = edg[0]; + const label e = edg[1]; + + if( + (nodeType[s] & INNERNODE) && (nodeType[e] & INNERNODE) + && (innerNodes.found(s) ^ innerNodes.found(e)) + ) + { + bool foundInside(false); + forAllRow(edgeLeaves, edgeI, elI) + { const label ecLabel = edgeLeaves(edgeI, elI); - if( ecLabel < 0 ) - continue; - if( octree_.hasContainedTriangles(ecLabel) ) - continue; - if( - !( - octree_.returnLeaf(ecLabel).cubeType() & - meshOctreeCubeBasic::INSIDE - ) - ) - continue; - - foundInside = true; - break; - } - - if( foundInside ) - { - innerNodes.insert(s); - innerNodes.insert(e); - finished = false; - } - } - } - - } while( !finished ); - + if( ecLabel < 0 ) + continue; + if( octree_.hasContainedTriangles(ecLabel) ) + continue; + if( + !( + octree_.returnLeaf(ecLabel).cubeType() & + meshOctreeCubeBasic::INSIDE + ) + ) + continue; + + foundInside = true; + break; + } + + if( foundInside ) + { + innerNodes.insert(s); + innerNodes.insert(e); + finished = false; + } + } + } + + } while( !finished ); + labelHashSet permissibleNeighbours; forAllConstIter(labelHashSet, innerNodes, it) { @@ -140,7 +140,7 @@ void meshOctreeAddressing::checkGluedRegions() forAllRow(nodeLeaves, nodeI, nlI) permissibleNeighbours.insert(nodeLeaves(nodeI, nlI)); } - + if( permissibleNeighbours.size() ) { for(label i=0;i<6;++i) @@ -167,7 +167,7 @@ void meshOctreeAddressing::checkGluedRegions() { removeBox.append(leafI); } - } + } } forAll(removeBox, i) @@ -199,7 +199,7 @@ void meshOctreeAddressing::checkGluedRegions() } } - Info << "Finished removing glued regions" << endl; + Info << "Finished removing glued regions" << endl; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/meshLibrary/utilities/octrees/meshOctree/meshOctreeAddressing/meshOctreeAddressingI.H b/meshLibrary/utilities/octrees/meshOctree/meshOctreeAddressing/meshOctreeAddressingI.H index 5f22cb96..661ac16d 100644 --- a/meshLibrary/utilities/octrees/meshOctree/meshOctreeAddressing/meshOctreeAddressingI.H +++ b/meshLibrary/utilities/octrees/meshOctree/meshOctreeAddressing/meshOctreeAddressingI.H @@ -39,7 +39,7 @@ inline label meshOctreeAddressing::numberOfNodes() const if( !nodeLabelsPtr_ ) createNodeLabels(); - return nNodes_; + return nNodes_; } inline const pointField& meshOctreeAddressing::octreePoints() const @@ -49,55 +49,55 @@ inline const pointField& meshOctreeAddressing::octreePoints() const return *octreePointsPtr_; } - + inline const VRWGraph& meshOctreeAddressing::nodeLabels() const { - if( !nodeLabelsPtr_ ) - createNodeLabels(); - - return *nodeLabelsPtr_; + if( !nodeLabelsPtr_ ) + createNodeLabels(); + + return *nodeLabelsPtr_; } inline const FRWGraph<label, 8>& meshOctreeAddressing::nodeLeaves() const { - if( !nodeLeavesPtr_ ) - createNodeLeaves(); - - return *nodeLeavesPtr_; + if( !nodeLeavesPtr_ ) + createNodeLeaves(); + + return *nodeLeavesPtr_; } - + inline const List<direction>& meshOctreeAddressing::boxType() const { - if( !boxTypePtr_ ) - findUsedBoxes(); - - return *boxTypePtr_; + if( !boxTypePtr_ ) + findUsedBoxes(); + + return *boxTypePtr_; } inline void meshOctreeAddressing::setBoxType ( - const label boxI, - const direction type + const label boxI, + const direction type ) { - if( boxTypePtr_ ) - { - List<direction>& boxType = *boxTypePtr_; - boxType[boxI] |= type; - } + if( boxTypePtr_ ) + { + List<direction>& boxType = *boxTypePtr_; + boxType[boxI] |= type; + } } inline const meshOctree& meshOctreeAddressing::octree() const { - return octree_; + return octree_; } inline const List<direction>& meshOctreeAddressing::nodeType() const { - if( !nodeTypePtr_ ) - calculateNodeType(); - - return *nodeTypePtr_; + if( !nodeTypePtr_ ) + calculateNodeType(); + + return *nodeTypePtr_; } inline const VRWGraph& meshOctreeAddressing::octreeFaces() const diff --git a/meshLibrary/utilities/octrees/meshOctree/meshOctreeAddressing/meshOctreeAddressingIrregularConnections.C b/meshLibrary/utilities/octrees/meshOctree/meshOctreeAddressing/meshOctreeAddressingIrregularConnections.C index 10c97207..3f92cc07 100644 --- a/meshLibrary/utilities/octrees/meshOctree/meshOctreeAddressing/meshOctreeAddressingIrregularConnections.C +++ b/meshLibrary/utilities/octrees/meshOctree/meshOctreeAddressing/meshOctreeAddressingIrregularConnections.C @@ -230,7 +230,7 @@ void meshOctreeAddressing::checkAndFixIrregularConnections() clearOctreeFaces(); clearAddressing(); - Info << "Finished checking the surface of the selected boxes" << endl; + Info << "Finished checking the surface of the selected boxes" << endl; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/meshLibrary/utilities/octrees/meshOctree/meshOctreeAutomaticRefinement/meshOctreeAutomaticRefinement.C b/meshLibrary/utilities/octrees/meshOctree/meshOctreeAutomaticRefinement/meshOctreeAutomaticRefinement.C index 84af6f54..24342de1 100644 --- a/meshLibrary/utilities/octrees/meshOctree/meshOctreeAutomaticRefinement/meshOctreeAutomaticRefinement.C +++ b/meshLibrary/utilities/octrees/meshOctree/meshOctreeAutomaticRefinement/meshOctreeAutomaticRefinement.C @@ -40,7 +40,7 @@ Description namespace Foam { - + void meshOctreeAutomaticRefinement::createOctreeAddressing() const { octreeAddressingPtr_ = @@ -55,7 +55,7 @@ const return *octreeAddressingPtr_; } - + void meshOctreeAutomaticRefinement::createSurfacePartitioner() const { partitionerPtr_ = new triSurfacePartitioner(octree_.surface()); @@ -68,7 +68,7 @@ const triSurfacePartitioner& meshOctreeAutomaticRefinement::partitioner() const return *partitionerPtr_; } - + void meshOctreeAutomaticRefinement::createCurvatureEstimator() const { curvaturePtr_ = new triSurfaceCurvatureEstimator(octree_.surface()); @@ -102,7 +102,7 @@ void meshOctreeAutomaticRefinement::setMaxRefLevel() do { finished = false; - + const scalar lSize = size / pow(2, maxRefLevel_); if( lSize < cs ) diff --git a/meshLibrary/utilities/octrees/meshOctree/meshOctreeAutomaticRefinement/meshOctreeAutomaticRefinement.H b/meshLibrary/utilities/octrees/meshOctree/meshOctreeAutomaticRefinement/meshOctreeAutomaticRefinement.H index 080d3711..6bc4b583 100644 --- a/meshLibrary/utilities/octrees/meshOctree/meshOctreeAutomaticRefinement/meshOctreeAutomaticRefinement.H +++ b/meshLibrary/utilities/octrees/meshOctree/meshOctreeAutomaticRefinement/meshOctreeAutomaticRefinement.H @@ -27,7 +27,7 @@ Class Description Automatic octree for mesh generation. This class checks if the current - octree resolution is enough to resolve all surface features + octree resolution is enough to resolve all surface features SourceFiles meshOctreeAutomaticRefinement.C @@ -87,7 +87,7 @@ class meshOctreeAutomaticRefinement //- curvature estimator pointer mutable triSurfaceCurvatureEstimator* curvaturePtr_; - //- calculate curvaturePtr_ + //- calculate curvaturePtr_ void createCurvatureEstimator() const; const triSurfaceCurvatureEstimator& curvature() const; @@ -151,7 +151,7 @@ public: // Destructor ~meshOctreeAutomaticRefinement(); - + // Member Functions //- activate hex refinement void activateHexRefinement(); diff --git a/meshLibrary/utilities/octrees/meshOctree/meshOctreeAutomaticRefinement/meshOctreeAutomaticRefinementRef.C b/meshLibrary/utilities/octrees/meshOctree/meshOctreeAutomaticRefinement/meshOctreeAutomaticRefinementRef.C index 0f759c10..b931c4a2 100644 --- a/meshLibrary/utilities/octrees/meshOctree/meshOctreeAutomaticRefinement/meshOctreeAutomaticRefinementRef.C +++ b/meshLibrary/utilities/octrees/meshOctree/meshOctreeAutomaticRefinement/meshOctreeAutomaticRefinementRef.C @@ -145,7 +145,7 @@ bool meshOctreeAutomaticRefinement::refineBasedOnContainedCorners forAll(corners, cornerI) { const label cLabel = - octree_.findLeafContainingVertex(points[corners[cornerI]]); + octree_.findLeafContainingVertex(points[corners[cornerI]]); if( cLabel < 0 ) continue; @@ -444,12 +444,12 @@ bool meshOctreeAutomaticRefinement::refineBasedOnProximityTests } reduce(nMarked, sumOp<label>()); - Info << nMarked << " boxed marked by proximity criteria" << endl; + Info << nMarked << " boxed marked by proximity criteria" << endl; if( nMarked != 0 ) return true; - return false; + return false; } void meshOctreeAutomaticRefinement::refineSelectedBoxes diff --git a/meshLibrary/utilities/octrees/meshOctree/meshOctreeFindNearestSurfacePoint.C b/meshLibrary/utilities/octrees/meshOctree/meshOctreeFindNearestSurfacePoint.C index 5d312ce8..2115ec0c 100644 --- a/meshLibrary/utilities/octrees/meshOctree/meshOctreeFindNearestSurfacePoint.C +++ b/meshLibrary/utilities/octrees/meshOctree/meshOctreeFindNearestSurfacePoint.C @@ -64,7 +64,7 @@ void meshOctree::findNearestSurfacePoint //- find nearest surface vertex to the point p bool found; - label iterationI(0); + label iterationI(0); DynList<const meshOctreeCube*, 256> neighbours; do @@ -133,7 +133,7 @@ void meshOctree::findNearestSurfacePointInRegion //- find nearest surface vertex to the point p bool found; - label iterationI(0); + label iterationI(0); DynList<const meshOctreeCube*, 256> neighbours; do diff --git a/meshLibrary/utilities/octrees/meshOctree/meshOctreeI.H b/meshLibrary/utilities/octrees/meshOctree/meshOctreeI.H index 33d0ef3c..7c998ccc 100644 --- a/meshLibrary/utilities/octrees/meshOctree/meshOctreeI.H +++ b/meshLibrary/utilities/octrees/meshOctree/meshOctreeI.H @@ -54,7 +54,7 @@ inline label meshOctree::numberOfLeaves() const inline const meshOctreeCubeBasic& meshOctree::returnLeaf ( - const label leafI + const label leafI ) const { return *leaves_[leafI]; @@ -171,21 +171,21 @@ inline void meshOctree::findNeighboursOverEdge inline void meshOctree::findNeighboursInDirection ( - const label leafI, - const label dir, - DynList<label>& neiLeaves + const label leafI, + const label dir, + DynList<label>& neiLeaves ) const { - findNeighboursInDirection(leaves_[leafI]->coordinates(), dir, neiLeaves); + findNeighboursInDirection(leaves_[leafI]->coordinates(), dir, neiLeaves); } inline void meshOctree::findNeighboursForLeaf ( - const label leafI, - DynList<label>& neighbourLeaves + const label leafI, + DynList<label>& neighbourLeaves ) const { - findNeighboursForLeaf(leaves_[leafI]->coordinates(), neighbourLeaves); + findNeighboursForLeaf(leaves_[leafI]->coordinates(), neighbourLeaves); } inline void meshOctree::findAllLeafNeighbours diff --git a/meshLibrary/utilities/octrees/meshOctree/meshOctreeModifier/meshOctreeModifier.C b/meshLibrary/utilities/octrees/meshOctree/meshOctreeModifier/meshOctreeModifier.C index b9f77935..af17ab5f 100644 --- a/meshLibrary/utilities/octrees/meshOctree/meshOctreeModifier/meshOctreeModifier.C +++ b/meshLibrary/utilities/octrees/meshOctree/meshOctreeModifier/meshOctreeModifier.C @@ -45,7 +45,7 @@ meshOctreeModifier::meshOctreeModifier meshOctree& octree ) : - octree_(octree) + octree_(octree) {} // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // diff --git a/meshLibrary/utilities/octrees/meshOctree/meshOctreeModifier/meshOctreeModifierParallelRefinement.C b/meshLibrary/utilities/octrees/meshOctree/meshOctreeModifier/meshOctreeModifierParallelRefinement.C index a9f2cf71..56c712d0 100644 --- a/meshLibrary/utilities/octrees/meshOctree/meshOctreeModifier/meshOctreeModifierParallelRefinement.C +++ b/meshLibrary/utilities/octrees/meshOctree/meshOctreeModifier/meshOctreeModifierParallelRefinement.C @@ -71,7 +71,7 @@ void meshOctreeModifier::refineTreeForCoordinates meshOctreeCube* nei(octree_.initialCubePtr_); - for(label i=(l-1);i>=0;--i) + for(label i=(l-1);i>=0;--i) { const label levelLimiter = (1 << i); @@ -344,7 +344,7 @@ void meshOctreeModifier::addLayerFromNeighbouringProcessors() } # endif - Info << "Finished adding an additional layer of octree cubes" << endl; + Info << "Finished adding an additional layer of octree cubes" << endl; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/meshLibrary/utilities/octrees/meshOctree/meshOctreeNeighbourSearches.C b/meshLibrary/utilities/octrees/meshOctree/meshOctreeNeighbourSearches.C index b3b65be7..08965205 100644 --- a/meshLibrary/utilities/octrees/meshOctree/meshOctreeNeighbourSearches.C +++ b/meshLibrary/utilities/octrees/meshOctree/meshOctreeNeighbourSearches.C @@ -362,7 +362,7 @@ void meshOctree::findLeavesForCubeVertex for(label i=0;i<8;++i) { - positions[i] = cc + vrtLeavesPos_[vrtI][i]; + positions[i] = cc + vrtLeavesPos_[vrtI][i]; } forAll(positions, posI) diff --git a/meshLibrary/utilities/octrees/meshOctree/refinementControls/objectRefinement/boxRefinement.C b/meshLibrary/utilities/octrees/meshOctree/refinementControls/objectRefinement/boxRefinement.C index b36fd8af..a6dbf222 100644 --- a/meshLibrary/utilities/octrees/meshOctree/refinementControls/objectRefinement/boxRefinement.C +++ b/meshLibrary/utilities/octrees/meshOctree/refinementControls/objectRefinement/boxRefinement.C @@ -41,39 +41,39 @@ addToRunTimeSelectionTable(objectRefinement, boxRefinement, dictionary); boxRefinement::boxRefinement() : objectRefinement(), - centre_(), - lengthX_(-1.0), - lengthY_(-1.0), - lengthZ_(-1.0) - //angleX_(0.0), - //angleY_(0.0), - //angleZ_(0.0) + centre_(), + lengthX_(-1.0), + lengthY_(-1.0), + lengthZ_(-1.0) + //angleX_(0.0), + //angleY_(0.0), + //angleZ_(0.0) {} boxRefinement::boxRefinement ( - const word& name, + const word& name, const scalar cellSize, - const point& centre, - const scalar lengthX, - const scalar lengthY, - const scalar lengthZ - //const scalar angleX, - //const scalar angleY, - //const scalar angleZ + const point& centre, + const scalar lengthX, + const scalar lengthY, + const scalar lengthZ + //const scalar angleX, + //const scalar angleY, + //const scalar angleZ ) : objectRefinement(), - centre_(centre), - lengthX_(lengthX), - lengthY_(lengthY), - lengthZ_(lengthZ) - //angleX_(angleX), - //angleY_(angleY), - //angleZ_(angleZ) + centre_(centre), + lengthX_(lengthX), + lengthY_(lengthY), + lengthZ_(lengthZ) + //angleX_(angleX), + //angleY_(angleY), + //angleZ_(angleZ) { - setName(name); - setCellSize(cellSize); + setName(name); + setCellSize(cellSize); } boxRefinement::boxRefinement @@ -84,63 +84,63 @@ boxRefinement::boxRefinement : objectRefinement(name, dict) { - this->operator=(dict); + this->operator=(dict); } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // bool boxRefinement::intersectsObject(const boundBox& bb) const { - vector v(0.5*lengthX_, 0.5*lengthY_, 0.5*lengthZ_); - boundBox box(centre_ - v, centre_ + v); - - if( box.overlaps(bb) ) - return true; - - return false; + vector v(0.5*lengthX_, 0.5*lengthY_, 0.5*lengthZ_); + boundBox box(centre_ - v, centre_ + v); + + if( box.overlaps(bb) ) + return true; + + return false; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // dictionary boxRefinement::dict(bool ignoreType) const { - dictionary dict; + dictionary dict; - dict.add("cellSize", cellSize()); - dict.add("type", type()); + dict.add("cellSize", cellSize()); + dict.add("type", type()); dict.add("centre", centre_); dict.add("lengthX", lengthX_); - dict.add("lengthY", lengthY_); - dict.add("lengthZ", lengthZ_); - - //dict.add("angleX", angleX_); - //dict.add("angleY", angleY_); - //dict.add("angleZ", angleZ_); + dict.add("lengthY", lengthY_); + dict.add("lengthZ", lengthZ_); + + //dict.add("angleX", angleX_); + //dict.add("angleY", angleY_); + //dict.add("angleZ", angleZ_); return dict; } void boxRefinement::write(Ostream& os) const { - os << " type: " << type() + os << " type: " << type() << " centre: " << centre_ << " lengthX: " << lengthX_ - << " lengthY: " << lengthY_ - << " lengthZ: " << lengthZ_; - //<< " angleX: " << angleX_ - //<< " angleY: " << angleY_ - //<< " angleZ: " << angleZ_; + << " lengthY: " << lengthY_ + << " lengthZ: " << lengthZ_; + //<< " angleX: " << angleX_ + //<< " angleY: " << angleY_ + //<< " angleZ: " << angleZ_; } void boxRefinement::writeDict(Ostream& os, bool subDict) const { - if( subDict ) + if( subDict ) { os << indent << token::BEGIN_BLOCK << incrIndent << nl; } - - os.writeKeyword("cellSize") << cellSize() << token::END_STATEMENT << nl; + + os.writeKeyword("cellSize") << cellSize() << token::END_STATEMENT << nl; // only write type for derived types if( type() != typeName_() ) @@ -150,11 +150,11 @@ void boxRefinement::writeDict(Ostream& os, bool subDict) const os.writeKeyword("centre") << centre_ << token::END_STATEMENT << nl; os.writeKeyword("lengthX") << lengthX_ << token::END_STATEMENT << nl; - os.writeKeyword("lengthY") << lengthY_ << token::END_STATEMENT << nl; - os.writeKeyword("lengthZ") << lengthZ_ << token::END_STATEMENT << nl; - //os.writeKeyword("angleX") << angleX_ << token::END_STATEMENT << nl; - //os.writeKeyword("angleY") << angleY_ << token::END_STATEMENT << nl; - //os.writeKeyword("angleZ") << angleZ_ << token::END_STATEMENT << nl; + os.writeKeyword("lengthY") << lengthY_ << token::END_STATEMENT << nl; + os.writeKeyword("lengthZ") << lengthZ_ << token::END_STATEMENT << nl; + //os.writeKeyword("angleX") << angleX_ << token::END_STATEMENT << nl; + //os.writeKeyword("angleY") << angleY_ << token::END_STATEMENT << nl; + //os.writeKeyword("angleZ") << angleZ_ << token::END_STATEMENT << nl; if( subDict ) { @@ -179,10 +179,10 @@ void boxRefinement::operator=(const dictionary& d) } else { - FatalErrorIn - ( - "void boxRefinement::operator=(const dictionary& d)" - ) << "Entry centre is not sopecified!" << exit(FatalError); + FatalErrorIn + ( + "void boxRefinement::operator=(const dictionary& d)" + ) << "Entry centre is not sopecified!" << exit(FatalError); centre_ = vector::zero; } @@ -193,42 +193,42 @@ void boxRefinement::operator=(const dictionary& d) } else { - FatalErrorIn - ( - "void boxRefinement::operator=(const dictionary& d)" - ) << "Entry lengthX is not sopecified!" << exit(FatalError); + FatalErrorIn + ( + "void boxRefinement::operator=(const dictionary& d)" + ) << "Entry lengthX is not sopecified!" << exit(FatalError); lengthX_ = -1.0; } - - // specify lengthY + + // specify lengthY if( dict.found("lengthY") ) { lengthY_ = readScalar(dict.lookup("lengthY")); } else { - FatalErrorIn - ( - "void boxRefinement::operator=(const dictionary& d)" - ) << "Entry lengthY is not sopecified!" << exit(FatalError); + FatalErrorIn + ( + "void boxRefinement::operator=(const dictionary& d)" + ) << "Entry lengthY is not sopecified!" << exit(FatalError); lengthY_ = -1.0; } - - // specify lengthZ + + // specify lengthZ if( dict.found("lengthZ") ) { lengthZ_ = readScalar(dict.lookup("lengthZ")); } else { - FatalErrorIn - ( - "void boxRefinement::operator=(const dictionary& d)" - ) << "Entry lengthZ is not sopecified!" << exit(FatalError); + FatalErrorIn + ( + "void boxRefinement::operator=(const dictionary& d)" + ) << "Entry lengthZ is not sopecified!" << exit(FatalError); lengthZ_ = -1.0; } - - // specify angleX + + // specify angleX /* if( dict.found("angleX") ) { angleX_ = readScalar(dict.lookup("angleX")); @@ -237,8 +237,8 @@ void boxRefinement::operator=(const dictionary& d) { angleX_ = -1.0; } - - // specify angleY + + // specify angleY if( dict.found("angleY") ) { angleY_ = readScalar(dict.lookup("angleY")); @@ -247,8 +247,8 @@ void boxRefinement::operator=(const dictionary& d) { angleY_ = -1.0; } - - // specify angleX + + // specify angleX if( dict.found("angleZ") ) { angleZ_ = readScalar(dict.lookup("angleZ")); @@ -264,14 +264,14 @@ void boxRefinement::operator=(const dictionary& d) Ostream& boxRefinement::operator<<(Ostream& os) const { - os << "name " << name() << nl; - os << "cell size " << cellSize() << nl; - write(os); - return os; + os << "name " << name() << nl; + os << "cell size " << cellSize() << nl; + write(os); + return os; } - + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - + } // End namespace Foam // ************************************************************************* // diff --git a/meshLibrary/utilities/octrees/meshOctree/refinementControls/objectRefinement/boxRefinement.H b/meshLibrary/utilities/octrees/meshOctree/refinementControls/objectRefinement/boxRefinement.H index a47944f4..df95717e 100644 --- a/meshLibrary/utilities/octrees/meshOctree/refinementControls/objectRefinement/boxRefinement.H +++ b/meshLibrary/utilities/octrees/meshOctree/refinementControls/objectRefinement/boxRefinement.H @@ -53,19 +53,19 @@ class boxRefinement : public objectRefinement { - // Private data - //- centre of the box - point centre_; - - //- length of box sides - scalar lengthX_; - scalar lengthY_; - scalar lengthZ_; - - //- angles to the global coordinate system - //scalar angleX_; - //scalar angleY_; - //scalar angleZ_; + // Private data + //- centre of the box + point centre_; + + //- length of box sides + scalar lengthX_; + scalar lengthY_; + scalar lengthZ_; + + //- angles to the global coordinate system + //scalar angleX_; + //scalar angleY_; + //scalar angleZ_; public: @@ -84,46 +84,46 @@ public: const word& name, const scalar cellSize, const point& centre, - const scalar lengthX, - const scalar lengthY, - const scalar lengthZ - //const scalar angleX = 0., - //const scalar angleY = 0., - //const scalar angleZ = 0. + const scalar lengthX, + const scalar lengthY, + const scalar lengthZ + //const scalar angleX = 0., + //const scalar angleY = 0., + //const scalar angleZ = 0. ); //- Construct from dictionary boxRefinement(const word& name, const dictionary& dict); - - //- Construct and return a clone + + //- Construct and return a clone virtual autoPtr<objectRefinement> clone - ( - const boxRefinement& sr - ) const + ( + const boxRefinement& sr + ) const { return autoPtr<objectRefinement> - ( - new boxRefinement - ( - sr.name(), - sr.cellSize(), - sr.centre_, - sr.lengthX_, - sr.lengthY_, - sr.lengthZ_ - //sr.angleX_, - //sr.angleY_, - //sr.angleZ_ - ) - ); + ( + new boxRefinement + ( + sr.name(), + sr.cellSize(), + sr.centre_, + sr.lengthX_, + sr.lengthY_, + sr.lengthZ_ + //sr.angleX_, + //sr.angleY_, + //sr.angleZ_ + ) + ); } - - // Member Functions - - //- check if a boundBox intersects or is inside the object - bool intersectsObject(const boundBox&) const; - - //- Return as dictionary of entries + + // Member Functions + + //- check if a boundBox intersects or is inside the object + bool intersectsObject(const boundBox&) const; + + //- Return as dictionary of entries dictionary dict(bool ignoreType = false) const; // Write @@ -133,15 +133,15 @@ public: //- Write dictionary void writeDict(Ostream&, bool subDict = true) const; - - // Member Operators + + // Member Operators //- assign from dictionary void operator=(const dictionary&); // IOstream Operators - Ostream& operator<<(Ostream&) const; + Ostream& operator<<(Ostream&) const; }; diff --git a/meshLibrary/utilities/octrees/meshOctree/refinementControls/objectRefinement/coneRefinement.C b/meshLibrary/utilities/octrees/meshOctree/refinementControls/objectRefinement/coneRefinement.C index d54cdeaa..0a290fea 100644 --- a/meshLibrary/utilities/octrees/meshOctree/refinementControls/objectRefinement/coneRefinement.C +++ b/meshLibrary/utilities/octrees/meshOctree/refinementControls/objectRefinement/coneRefinement.C @@ -41,30 +41,30 @@ addToRunTimeSelectionTable(objectRefinement, coneRefinement, dictionary); coneRefinement::coneRefinement() : objectRefinement(), - p0_(), - r0_(-1.0), - p1_(), - r1_(-1.0) + p0_(), + r0_(-1.0), + p1_(), + r1_(-1.0) {} coneRefinement::coneRefinement ( - const word& name, + const word& name, const scalar cellSize, - const point& p0, - const scalar radius0, - const point& p1, - const scalar radius1 + const point& p0, + const scalar radius0, + const point& p1, + const scalar radius1 ) : objectRefinement(), - p0_(p0), - r0_(radius0), - p1_(p1), - r1_(radius1) + p0_(p0), + r0_(radius0), + p1_(p1), + r1_(radius1) { - setName(name); - setCellSize(cellSize); + setName(name); + setCellSize(cellSize); } coneRefinement::coneRefinement @@ -75,68 +75,68 @@ coneRefinement::coneRefinement : objectRefinement(name, dict) { - this->operator=(dict); + this->operator=(dict); } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // bool coneRefinement::intersectsObject(const boundBox& bb) const { - //- check if the centre is inside the cone - const point c = (bb.max() + bb.min()) / 2.0; - - const vector v = p1_ - p0_; - const scalar d = magSqr(v); - - if( d < VSMALL ) - return false; - - const scalar t = ((c - p0_) & v) / d; - if( (t > 1.0) || (t < 0.0) ) - return false; - - const scalar r = r0_ + (r1_ - r0_) * t; - - if( mag(p0_ + t * v - c) < r ) - return true; - - return false; + //- check if the centre is inside the cone + const point c = (bb.max() + bb.min()) / 2.0; + + const vector v = p1_ - p0_; + const scalar d = magSqr(v); + + if( d < VSMALL ) + return false; + + const scalar t = ((c - p0_) & v) / d; + if( (t > 1.0) || (t < 0.0) ) + return false; + + const scalar r = r0_ + (r1_ - r0_) * t; + + if( mag(p0_ + t * v - c) < r ) + return true; + + return false; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // dictionary coneRefinement::dict(bool ignoreType) const { - dictionary dict; + dictionary dict; - dict.add("cellSize", cellSize()); - dict.add("type", type()); + dict.add("cellSize", cellSize()); + dict.add("type", type()); dict.add("p0", p0_); dict.add("radius0", r0_); - dict.add("p1", p1_); - dict.add("radius1", r1_); + dict.add("p1", p1_); + dict.add("radius1", r1_); return dict; } void coneRefinement::write(Ostream& os) const { - os << " type: " << type() + os << " type: " << type() << " p0: " << p0_ << " radius0: " << r0_ - << " p1: " << p1_ - << " radius1: " << r1_; + << " p1: " << p1_ + << " radius1: " << r1_; } void coneRefinement::writeDict(Ostream& os, bool subDict) const { - if( subDict ) + if( subDict ) { os << indent << token::BEGIN_BLOCK << incrIndent << nl; } - - os.writeKeyword("cellSize") << cellSize() << token::END_STATEMENT << nl; + + os.writeKeyword("cellSize") << cellSize() << token::END_STATEMENT << nl; // only write type for derived types if( type() != typeName_() ) @@ -146,9 +146,9 @@ void coneRefinement::writeDict(Ostream& os, bool subDict) const os.writeKeyword("p0") << p0_ << token::END_STATEMENT << nl; os.writeKeyword("radius0") << r0_ << token::END_STATEMENT << nl; - os.writeKeyword("p1") << p1_ << token::END_STATEMENT << nl; + os.writeKeyword("p1") << p1_ << token::END_STATEMENT << nl; os.writeKeyword("radius1") << r1_ << token::END_STATEMENT << nl; - + if( subDict ) { os << decrIndent << indent << token::END_BLOCK << endl; @@ -172,10 +172,10 @@ void coneRefinement::operator=(const dictionary& d) } else { - FatalErrorIn - ( - "void coneRefinement::operator=(const dictionary& d)" - ) << "Entry p0 is not specified!" << exit(FatalError); + FatalErrorIn + ( + "void coneRefinement::operator=(const dictionary& d)" + ) << "Entry p0 is not specified!" << exit(FatalError); p0_ = vector::zero; } @@ -186,24 +186,24 @@ void coneRefinement::operator=(const dictionary& d) } else { - FatalErrorIn - ( - "void coneRefinement::operator=(const dictionary& d)" - ) << "Entry radius0 is not specified!" << exit(FatalError); + FatalErrorIn + ( + "void coneRefinement::operator=(const dictionary& d)" + ) << "Entry radius0 is not specified!" << exit(FatalError); r0_ = -1.0; } - - // unspecified centre is (0 0 0) + + // unspecified centre is (0 0 0) if( dict.found("p1") ) { dict.lookup("p1") >> p1_; } else { - FatalErrorIn - ( - "void coneRefinement::operator=(const dictionary& d)" - ) << "Entry p1 is not specified!" << exit(FatalError); + FatalErrorIn + ( + "void coneRefinement::operator=(const dictionary& d)" + ) << "Entry p1 is not specified!" << exit(FatalError); p1_ = vector::zero; } @@ -214,10 +214,10 @@ void coneRefinement::operator=(const dictionary& d) } else { - FatalErrorIn - ( - "void coneRefinement::operator=(const dictionary& d)" - ) << "Entry radius1 is not specified!" << exit(FatalError); + FatalErrorIn + ( + "void coneRefinement::operator=(const dictionary& d)" + ) << "Entry radius1 is not specified!" << exit(FatalError); r1_ = -1.0; } } @@ -226,14 +226,14 @@ void coneRefinement::operator=(const dictionary& d) Ostream& coneRefinement::operator<<(Ostream& os) const { - os << "name " << name() << nl; - os << "cell size " << cellSize() << nl; - write(os); - return os; + os << "name " << name() << nl; + os << "cell size " << cellSize() << nl; + write(os); + return os; } - + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - + } // End namespace Foam // ************************************************************************* // diff --git a/meshLibrary/utilities/octrees/meshOctree/refinementControls/objectRefinement/coneRefinement.H b/meshLibrary/utilities/octrees/meshOctree/refinementControls/objectRefinement/coneRefinement.H index 82e57455..d586c2db 100644 --- a/meshLibrary/utilities/octrees/meshOctree/refinementControls/objectRefinement/coneRefinement.H +++ b/meshLibrary/utilities/octrees/meshOctree/refinementControls/objectRefinement/coneRefinement.H @@ -53,14 +53,14 @@ class coneRefinement : public objectRefinement { - // Private data - //- start point and the radius - point p0_; - scalar r0_; - - //- end point and the radius - point p1_; - scalar r1_; + // Private data + //- start point and the radius + point p0_; + scalar r0_; + + //- end point and the radius + point p1_; + scalar r1_; public: @@ -80,39 +80,39 @@ public: const scalar cellSize, const point& p0, const scalar radius0, - const point& p1, - const scalar radius1 + const point& p1, + const scalar radius1 ); //- Construct from dictionary coneRefinement(const word& name, const dictionary& dict); - - //- Construct and return a clone + + //- Construct and return a clone virtual autoPtr<objectRefinement> clone - ( - const coneRefinement& sr - ) const + ( + const coneRefinement& sr + ) const { return autoPtr<objectRefinement> - ( - new coneRefinement - ( - sr.name(), - sr.cellSize(), - sr.p0_, - sr.r0_, - sr.p1_, - sr.r1_ - ) - ); + ( + new coneRefinement + ( + sr.name(), + sr.cellSize(), + sr.p0_, + sr.r0_, + sr.p1_, + sr.r1_ + ) + ); } - - // Member Functions - - //- check if a boundBox intersects or is inside the object - bool intersectsObject(const boundBox&) const; - - //- Return as dictionary of entries + + // Member Functions + + //- check if a boundBox intersects or is inside the object + bool intersectsObject(const boundBox&) const; + + //- Return as dictionary of entries dictionary dict(bool ignoreType = false) const; // Write @@ -122,15 +122,15 @@ public: //- Write dictionary void writeDict(Ostream&, bool subDict = true) const; - - // Member Operators + + // Member Operators //- assign from dictionary void operator=(const dictionary&); // IOstream Operators - Ostream& operator<<(Ostream&) const; + Ostream& operator<<(Ostream&) const; }; diff --git a/meshLibrary/utilities/octrees/meshOctree/refinementControls/objectRefinement/lineRefinement.C b/meshLibrary/utilities/octrees/meshOctree/refinementControls/objectRefinement/lineRefinement.C index fac4c5e9..da720901 100644 --- a/meshLibrary/utilities/octrees/meshOctree/refinementControls/objectRefinement/lineRefinement.C +++ b/meshLibrary/utilities/octrees/meshOctree/refinementControls/objectRefinement/lineRefinement.C @@ -41,24 +41,24 @@ addToRunTimeSelectionTable(objectRefinement, lineRefinement, dictionary); lineRefinement::lineRefinement() : objectRefinement(), - p0_(), - p1_() + p0_(), + p1_() {} lineRefinement::lineRefinement ( - const word& name, + const word& name, const scalar cellSize, - const point& p0, - const point& p1 + const point& p0, + const point& p1 ) : objectRefinement(), - p0_(p0), - p1_(p1) + p0_(p0), + p1_(p1) { - setName(name); - setCellSize(cellSize); + setName(name); + setCellSize(cellSize); } lineRefinement::lineRefinement @@ -69,7 +69,7 @@ lineRefinement::lineRefinement : objectRefinement(name, dict) { - this->operator=(dict); + this->operator=(dict); } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -77,8 +77,8 @@ lineRefinement::lineRefinement bool lineRefinement::intersectsObject(const boundBox& bb) const { //- check if the cube contains start point or end point - const scalar l = bb.max().x() - bb.min().x(); - + const scalar l = bb.max().x() - bb.min().x(); + const point min = bb.min() - l * vector(SMALL, SMALL, SMALL); const point max = bb.max() + l * vector(SMALL, SMALL, SMALL); @@ -207,10 +207,10 @@ bool lineRefinement::intersectsObject(const boundBox& bb) const dictionary lineRefinement::dict(bool ignoreType) const { - dictionary dict; + dictionary dict; - dict.add("cellSize", cellSize()); - dict.add("type", type()); + dict.add("cellSize", cellSize()); + dict.add("type", type()); dict.add("p0", p0_); dict.add("p1", p1_); @@ -220,19 +220,19 @@ dictionary lineRefinement::dict(bool ignoreType) const void lineRefinement::write(Ostream& os) const { - os << " type: " << type() + os << " type: " << type() << " p0: " << p0_ << " p1: " << p1_; } void lineRefinement::writeDict(Ostream& os, bool subDict) const { - if( subDict ) + if( subDict ) { os << indent << token::BEGIN_BLOCK << incrIndent << nl; } - - os.writeKeyword("cellSize") << cellSize() << token::END_STATEMENT << nl; + + os.writeKeyword("cellSize") << cellSize() << token::END_STATEMENT << nl; // only write type for derived types if( type() != typeName_() ) @@ -266,10 +266,10 @@ void lineRefinement::operator=(const dictionary& d) } else { - FatalErrorIn - ( - "void lineRefinement::operator=(const dictionary& d)" - ) << "Entry p0 is not specified!" << exit(FatalError); + FatalErrorIn + ( + "void lineRefinement::operator=(const dictionary& d)" + ) << "Entry p0 is not specified!" << exit(FatalError); p0_ = vector::zero; } @@ -280,10 +280,10 @@ void lineRefinement::operator=(const dictionary& d) } else { - FatalErrorIn - ( - "void lineRefinement::operator=(const dictionary& d)" - ) << "Entry p1 is not specified!" << exit(FatalError); + FatalErrorIn + ( + "void lineRefinement::operator=(const dictionary& d)" + ) << "Entry p1 is not specified!" << exit(FatalError); p1_ = vector::zero; } } @@ -292,14 +292,14 @@ void lineRefinement::operator=(const dictionary& d) Ostream& lineRefinement::operator<<(Ostream& os) const { - os << "name " << name() << nl; - os << "cell size " << cellSize() << nl; - write(os); - return os; + os << "name " << name() << nl; + os << "cell size " << cellSize() << nl; + write(os); + return os; } - + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - + } // End namespace Foam // ************************************************************************* // diff --git a/meshLibrary/utilities/octrees/meshOctree/refinementControls/objectRefinement/lineRefinement.H b/meshLibrary/utilities/octrees/meshOctree/refinementControls/objectRefinement/lineRefinement.H index c8761a0e..83898b3a 100644 --- a/meshLibrary/utilities/octrees/meshOctree/refinementControls/objectRefinement/lineRefinement.H +++ b/meshLibrary/utilities/octrees/meshOctree/refinementControls/objectRefinement/lineRefinement.H @@ -53,12 +53,12 @@ class lineRefinement : public objectRefinement { - // Private data - //- start point of the line - point p0_; - - //- end point of the line - point p1_; + // Private data + //- start point of the line + point p0_; + + //- end point of the line + point p1_; public: @@ -82,31 +82,31 @@ public: //- Construct from dictionary lineRefinement(const word& name, const dictionary& dict); - - //- Construct and return a clone + + //- Construct and return a clone virtual autoPtr<objectRefinement> clone - ( - const lineRefinement& sr - ) const + ( + const lineRefinement& sr + ) const { return autoPtr<objectRefinement> - ( - new lineRefinement - ( - sr.name(), - sr.cellSize(), - sr.p0_, - sr.p1_ - ) - ); + ( + new lineRefinement + ( + sr.name(), + sr.cellSize(), + sr.p0_, + sr.p1_ + ) + ); } - - // Member Functions - - //- check if the line intersects the box - bool intersectsObject(const boundBox&) const; - - //- Return as dictionary of entries + + // Member Functions + + //- check if the line intersects the box + bool intersectsObject(const boundBox&) const; + + //- Return as dictionary of entries dictionary dict(bool ignoreType = false) const; // Write @@ -116,15 +116,15 @@ public: //- Write dictionary void writeDict(Ostream&, bool subDict = true) const; - - // Member Operators + + // Member Operators //- assign from dictionary void operator=(const dictionary&); // IOstream Operators - Ostream& operator<<(Ostream&) const; + Ostream& operator<<(Ostream&) const; }; diff --git a/meshLibrary/utilities/octrees/meshOctree/refinementControls/objectRefinement/newObjectRefinement.C b/meshLibrary/utilities/octrees/meshOctree/refinementControls/objectRefinement/newObjectRefinement.C index 6032fc23..22ca72df 100644 --- a/meshLibrary/utilities/octrees/meshOctree/refinementControls/objectRefinement/newObjectRefinement.C +++ b/meshLibrary/utilities/octrees/meshOctree/refinementControls/objectRefinement/newObjectRefinement.C @@ -52,7 +52,7 @@ autoPtr<Foam::objectRefinement> Foam::objectRefinement::New word refType(typeName_()); if( dict.found("type") ) { - dict.lookup("type") >> refType; + dict.lookup("type") >> refType; } dictionaryConstructorTable::iterator cstrIter = diff --git a/meshLibrary/utilities/octrees/meshOctree/refinementControls/objectRefinement/objectRefinement.C b/meshLibrary/utilities/octrees/meshOctree/refinementControls/objectRefinement/objectRefinement.C index 5ec770cd..e2cc02d1 100644 --- a/meshLibrary/utilities/octrees/meshOctree/refinementControls/objectRefinement/objectRefinement.C +++ b/meshLibrary/utilities/octrees/meshOctree/refinementControls/objectRefinement/objectRefinement.C @@ -32,7 +32,7 @@ License namespace Foam { - + defineTypeNameAndDebug(objectRefinement, 0); defineRunTimeSelectionTable(objectRefinement, dictionary); @@ -41,7 +41,7 @@ defineRunTimeSelectionTable(objectRefinement, dictionary); objectRefinement::objectRefinement() : name_(), - cellSize_() + cellSize_() {} @@ -52,7 +52,7 @@ objectRefinement::objectRefinement ) : name_(name), - cellSize_(readScalar(dict.lookup("cellSize"))) + cellSize_(readScalar(dict.lookup("cellSize"))) { } @@ -161,9 +161,9 @@ void coordinateSystem::operator=(const dictionary& rhs) Ostream& operator<<(Ostream& os, const objectRefinement& obr) { - os << obr.name() << nl; - obr.writeDict(os, true); - return os; + os << obr.name() << nl; + obr.writeDict(os, true); + return os; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/meshLibrary/utilities/octrees/meshOctree/refinementControls/objectRefinement/objectRefinementList.H b/meshLibrary/utilities/octrees/meshOctree/refinementControls/objectRefinement/objectRefinementList.H index 79ac07a7..4121cc2f 100644 --- a/meshLibrary/utilities/octrees/meshOctree/refinementControls/objectRefinement/objectRefinementList.H +++ b/meshLibrary/utilities/octrees/meshOctree/refinementControls/objectRefinement/objectRefinementList.H @@ -26,7 +26,7 @@ Class objectRefinementList Description - A list of object refinements + A list of object refinements SourceFiles diff --git a/meshLibrary/utilities/octrees/meshOctree/refinementControls/objectRefinement/sphereRefinement.C b/meshLibrary/utilities/octrees/meshOctree/refinementControls/objectRefinement/sphereRefinement.C index 0d362ada..b708fca0 100644 --- a/meshLibrary/utilities/octrees/meshOctree/refinementControls/objectRefinement/sphereRefinement.C +++ b/meshLibrary/utilities/octrees/meshOctree/refinementControls/objectRefinement/sphereRefinement.C @@ -41,24 +41,24 @@ addToRunTimeSelectionTable(objectRefinement, sphereRefinement, dictionary); sphereRefinement::sphereRefinement() : objectRefinement(), - centre_(), - radius_(-1.0) + centre_(), + radius_(-1.0) {} sphereRefinement::sphereRefinement ( - const word& name, + const word& name, const scalar cellSize, - const point& centre, - const scalar radius + const point& centre, + const scalar radius ) : objectRefinement(), - centre_(centre), - radius_(radius) + centre_(centre), + radius_(radius) { - setName(name); - setCellSize(cellSize); + setName(name); + setCellSize(cellSize); } sphereRefinement::sphereRefinement @@ -69,7 +69,7 @@ sphereRefinement::sphereRefinement : objectRefinement(name, dict) { - this->operator=(dict); + this->operator=(dict); } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -79,19 +79,19 @@ bool sphereRefinement::intersectsObject(const boundBox& bb) const const point& c = (bb.max() + bb.min()) / 2.0; if( magSqr(c - centre_) < sqr(radius_) ) - return true; - - return false; + return true; + + return false; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // dictionary sphereRefinement::dict(bool ignoreType) const { - dictionary dict; + dictionary dict; - dict.add("cellSize", cellSize()); - dict.add("type", type()); + dict.add("cellSize", cellSize()); + dict.add("type", type()); dict.add("centre", centre_); dict.add("radius", radius_); @@ -101,19 +101,19 @@ dictionary sphereRefinement::dict(bool ignoreType) const void sphereRefinement::write(Ostream& os) const { - os << " type: " << type() + os << " type: " << type() << " centre: " << centre_ << " radius: " << radius_; } void sphereRefinement::writeDict(Ostream& os, bool subDict) const { - if( subDict ) + if( subDict ) { os << indent << token::BEGIN_BLOCK << incrIndent << nl; } - - os.writeKeyword("cellSize") << cellSize() << token::END_STATEMENT << nl; + + os.writeKeyword("cellSize") << cellSize() << token::END_STATEMENT << nl; // only write type for derived types if( type() != typeName_() ) @@ -147,10 +147,10 @@ void sphereRefinement::operator=(const dictionary& d) } else { - FatalErrorIn - ( - "void sphereRefinement::operator=(const dictionary& d)" - ) << "Entry centre is not specified!" << exit(FatalError); + FatalErrorIn + ( + "void sphereRefinement::operator=(const dictionary& d)" + ) << "Entry centre is not specified!" << exit(FatalError); centre_ = vector::zero; } @@ -161,10 +161,10 @@ void sphereRefinement::operator=(const dictionary& d) } else { - FatalErrorIn - ( - "void sphereRefinement::operator=(const dictionary& d)" - ) << "Entry radius is not specified!" << exit(FatalError); + FatalErrorIn + ( + "void sphereRefinement::operator=(const dictionary& d)" + ) << "Entry radius is not specified!" << exit(FatalError); radius_ = -1.0; } } @@ -173,14 +173,14 @@ void sphereRefinement::operator=(const dictionary& d) Ostream& sphereRefinement::operator<<(Ostream& os) const { - os << "name " << name() << nl; - os << "cell size " << cellSize() << nl; - write(os); - return os; + os << "name " << name() << nl; + os << "cell size " << cellSize() << nl; + write(os); + return os; } - + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - + } // End namespace Foam // ************************************************************************* // diff --git a/meshLibrary/utilities/octrees/meshOctree/refinementControls/objectRefinement/sphereRefinement.H b/meshLibrary/utilities/octrees/meshOctree/refinementControls/objectRefinement/sphereRefinement.H index 1e1b0bcf..8e939e8f 100644 --- a/meshLibrary/utilities/octrees/meshOctree/refinementControls/objectRefinement/sphereRefinement.H +++ b/meshLibrary/utilities/octrees/meshOctree/refinementControls/objectRefinement/sphereRefinement.H @@ -53,12 +53,12 @@ class sphereRefinement : public objectRefinement { - // Private data - //- centre of the sphere - point centre_; - - //- radius of the sphere - scalar radius_; + // Private data + //- centre of the sphere + point centre_; + + //- radius of the sphere + scalar radius_; public: @@ -82,31 +82,31 @@ public: //- Construct from dictionary sphereRefinement(const word& name, const dictionary& dict); - - //- Construct and return a clone + + //- Construct and return a clone virtual autoPtr<objectRefinement> clone - ( - const sphereRefinement& sr - ) const + ( + const sphereRefinement& sr + ) const { return autoPtr<objectRefinement> - ( - new sphereRefinement - ( - sr.name(), - sr.cellSize(), - sr.centre_, - sr.radius_ - ) - ); + ( + new sphereRefinement + ( + sr.name(), + sr.cellSize(), + sr.centre_, + sr.radius_ + ) + ); } - - // Member Functions - - //- check if a boundBox intersects or is inside the object - bool intersectsObject(const boundBox&) const; - - //- Return as dictionary of entries + + // Member Functions + + //- check if a boundBox intersects or is inside the object + bool intersectsObject(const boundBox&) const; + + //- Return as dictionary of entries dictionary dict(bool ignoreType = false) const; // Write @@ -116,15 +116,15 @@ public: //- Write dictionary void writeDict(Ostream&, bool subDict = true) const; - - // Member Operators + + // Member Operators //- assign from dictionary void operator=(const dictionary&); // IOstream Operators - Ostream& operator<<(Ostream&) const; + Ostream& operator<<(Ostream&) const; }; diff --git a/meshLibrary/utilities/octrees/meshOctree/refinementControls/patchRefinement/patchRefinement.C b/meshLibrary/utilities/octrees/meshOctree/refinementControls/patchRefinement/patchRefinement.C index e4e56a80..871e1d18 100644 --- a/meshLibrary/utilities/octrees/meshOctree/refinementControls/patchRefinement/patchRefinement.C +++ b/meshLibrary/utilities/octrees/meshOctree/refinementControls/patchRefinement/patchRefinement.C @@ -98,8 +98,8 @@ scalar patchRefinement::cellSize() const void patchRefinement::operator=(const patchRefinement& pr) { - patchName_ = pr.patchName_; - cellSize_ = pr.cellSize_; + patchName_ = pr.patchName_; + cellSize_ = pr.cellSize_; } Istream& operator>>(Istream& is, patchRefinement& pr) diff --git a/meshLibrary/utilities/octrees/meshOctree/refinementControls/patchRefinement/patchRefinement.H b/meshLibrary/utilities/octrees/meshOctree/refinementControls/patchRefinement/patchRefinement.H index c9ca3fc7..0bea8d54 100644 --- a/meshLibrary/utilities/octrees/meshOctree/refinementControls/patchRefinement/patchRefinement.H +++ b/meshLibrary/utilities/octrees/meshOctree/refinementControls/patchRefinement/patchRefinement.H @@ -27,7 +27,7 @@ Class Description A class used for octree refinement. Refinement of boxes intersected - by a given patch to the prescribed size. + by a given patch to the prescribed size. SourceFiles patchRefinement.C @@ -88,7 +88,7 @@ public: // Operators - void operator=(const patchRefinement&); + void operator=(const patchRefinement&); friend Istream& operator>>(Istream&, patchRefinement&); friend Ostream& operator<<(Ostream&, const patchRefinement&); friend bool operator==(const patchRefinement&, const patchRefinement&); diff --git a/meshLibrary/utilities/octrees/meshOctree/refinementControls/patchRefinement/patchRefinementList.H b/meshLibrary/utilities/octrees/meshOctree/refinementControls/patchRefinement/patchRefinementList.H index 5f929fb6..93284518 100644 --- a/meshLibrary/utilities/octrees/meshOctree/refinementControls/patchRefinement/patchRefinementList.H +++ b/meshLibrary/utilities/octrees/meshOctree/refinementControls/patchRefinement/patchRefinementList.H @@ -26,7 +26,7 @@ Class patchRefinementList Description - A list of patch refinements + A list of patch refinements SourceFiles diff --git a/meshLibrary/utilities/octrees/surfaceIntersectionsOctree/surfaceIntersectionsOctree.C b/meshLibrary/utilities/octrees/surfaceIntersectionsOctree/surfaceIntersectionsOctree.C index 174b42f9..67fc7158 100644 --- a/meshLibrary/utilities/octrees/surfaceIntersectionsOctree/surfaceIntersectionsOctree.C +++ b/meshLibrary/utilities/octrees/surfaceIntersectionsOctree/surfaceIntersectionsOctree.C @@ -101,7 +101,7 @@ surfaceIntersectionsOctree::surfaceIntersectionsOctree if( oc.containedElements().size() > 0 ) { - oc.setCubeType(surfaceIntersectionsOctreeCube::DATA); + oc.setCubeType(surfaceIntersectionsOctreeCube::DATA); } else { @@ -160,7 +160,7 @@ surfaceIntersectionsOctreeCube* surfaceIntersectionsOctree::findLeafContainingVe # endif surfaceIntersectionsOctreeCube* oc = - const_cast<surfaceIntersectionsOctreeCube*>(&initialCube_); + const_cast<surfaceIntersectionsOctreeCube*>(&initialCube_); if( !oc->isVertexInside(p) ) { diff --git a/meshLibrary/utilities/octrees/surfaceIntersectionsOctree/surfaceIntersectionsOctreeCube/surfaceIntersectionsOctreeCube.H b/meshLibrary/utilities/octrees/surfaceIntersectionsOctree/surfaceIntersectionsOctreeCube/surfaceIntersectionsOctreeCube.H index 1686d84e..2b2a61cf 100644 --- a/meshLibrary/utilities/octrees/surfaceIntersectionsOctree/surfaceIntersectionsOctreeCube/surfaceIntersectionsOctreeCube.H +++ b/meshLibrary/utilities/octrees/surfaceIntersectionsOctree/surfaceIntersectionsOctreeCube/surfaceIntersectionsOctreeCube.H @@ -76,7 +76,7 @@ class surfaceIntersectionsOctreeCube //- is the cube outside, data or outside of the domain direction cubeType_; - //- returns cube's edges + //- returns cube's edges List< List<point> > edges() const; //- Disallow default bitwise copy construct @@ -95,7 +95,7 @@ public: ~surfaceIntersectionsOctreeCube(); - // Enumerators + // Enumerators enum cubeTypes { OUTSIDE = 0, @@ -109,16 +109,16 @@ public: //- is cube a leaf inline bool isLeaf() const; - - //- return and set cube type - direction cubeType() const - { - return cubeType_; - }; - void setCubeType(const direction t) - { - cubeType_ = t; - } + + //- return and set cube type + direction cubeType() const + { + return cubeType_; + }; + void setCubeType(const direction t) + { + cubeType_ = t; + } //- vertices FixedList<point, 8> vertices() const; diff --git a/meshLibrary/utilities/smoothers/geometry/meshOptimizer/meshOptimizer.C b/meshLibrary/utilities/smoothers/geometry/meshOptimizer/meshOptimizer.C index b7589f18..a3e29108 100644 --- a/meshLibrary/utilities/smoothers/geometry/meshOptimizer/meshOptimizer.C +++ b/meshLibrary/utilities/smoothers/geometry/meshOptimizer/meshOptimizer.C @@ -39,20 +39,20 @@ Description namespace Foam { - + // * * * * * * * * Private member functions * * * * * * * * * * * * * * * * * // - + const meshSurfaceEngine& meshOptimizer::meshSurface() const { - if( !msePtr_ ) - msePtr_ = new meshSurfaceEngine(mesh_); - - return *msePtr_; + if( !msePtr_ ) + msePtr_ = new meshSurfaceEngine(mesh_); + + return *msePtr_; } void meshOptimizer::clearSurface() { - deleteDemandDrivenData(msePtr_); + deleteDemandDrivenData(msePtr_); } label meshOptimizer::findBadFaces @@ -138,15 +138,15 @@ label meshOptimizer::findLowQualityFaces // Construct from mesh meshOptimizer::meshOptimizer(polyMeshGen& mesh) : - mesh_(mesh), + mesh_(mesh), vertexLocation_(mesh.points().size(), INSIDE), - msePtr_(NULL) + msePtr_(NULL) { - const meshSurfaceEngine& mse = meshSurface(); - const labelList& bPoints = mse.boundaryPoints(); - + const meshSurfaceEngine& mse = meshSurface(); + const labelList& bPoints = mse.boundaryPoints(); + //- mark boundary vertices - forAll(bPoints, bpI) + forAll(bPoints, bpI) vertexLocation_[bPoints[bpI]] = BOUNDARY; //- mark edge vertices @@ -173,7 +173,7 @@ meshOptimizer::meshOptimizer(polyMeshGen& mesh) meshOptimizer::~meshOptimizer() { - clearSurface(); + clearSurface(); } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/meshLibrary/utilities/smoothers/geometry/meshOptimizer/meshOptimizer.H b/meshLibrary/utilities/smoothers/geometry/meshOptimizer/meshOptimizer.H index d899bf7e..68cbb656 100644 --- a/meshLibrary/utilities/smoothers/geometry/meshOptimizer/meshOptimizer.H +++ b/meshLibrary/utilities/smoothers/geometry/meshOptimizer/meshOptimizer.H @@ -63,18 +63,18 @@ class meshOptimizer { // Private data //- reference to the mesh - polyMeshGen& mesh_; - - //- location of vertex (internal, boundary, edge, corner) + polyMeshGen& mesh_; + + //- location of vertex (internal, boundary, edge, corner) List<direction> vertexLocation_; - - //- mesh surface - mutable meshSurfaceEngine* msePtr_; + + //- mesh surface + mutable meshSurfaceEngine* msePtr_; // Private member functions - //- return mesh surface - const meshSurfaceEngine& meshSurface() const; - void clearSurface(); + //- return mesh surface + const meshSurfaceEngine& meshSurface() const; + void clearSurface(); //- find problematic faces label findBadFaces(labelHashSet&, const boolList&) const; @@ -123,7 +123,7 @@ class meshOptimizer //- Disallow default bitwise assignment void operator=(const laplaceSmoother&); - + public: // Constructor @@ -176,16 +176,16 @@ class meshOptimizer //- Disallow default bitwise assignment void operator=(const meshOptimizer&); - - // enumerators - enum vertexType_ - { - INSIDE = 1, - BOUNDARY = 2, - EDGE = 4, - CORNER = 8, + + // enumerators + enum vertexType_ + { + INSIDE = 1, + BOUNDARY = 2, + EDGE = 4, + CORNER = 8, PARALLELBOUNDARY = 16 - }; + }; public: @@ -203,15 +203,15 @@ public: //- smooth surface vertices void optimizeSurface(const meshOctree&); - //- performs mesh untangling based on detected negative normals - void untangleMeshFV(); + //- performs mesh untangling based on detected negative normals + void untangleMeshFV(); //- performs mesh optimisation for faces with high non-orthogonality //- and skewness void optimizeLowQualityFaces(); - //- final optimisation - void optimizeMeshFV(); + //- final optimisation + void optimizeMeshFV(); }; diff --git a/meshLibrary/utilities/smoothers/geometry/meshOptimizer/meshOptimizerOptimizePoint.C b/meshLibrary/utilities/smoothers/geometry/meshOptimizer/meshOptimizerOptimizePoint.C index 0c12907c..fee47de0 100644 --- a/meshLibrary/utilities/smoothers/geometry/meshOptimizer/meshOptimizerOptimizePoint.C +++ b/meshLibrary/utilities/smoothers/geometry/meshOptimizer/meshOptimizerOptimizePoint.C @@ -92,7 +92,7 @@ void meshOptimizer::laplaceSmoother::laplacianSurface const label nIterations ) { - const VRWGraph& pPoints = mesh_.addressingData().pointPoints(); + const VRWGraph& pPoints = mesh_.addressingData().pointPoints(); pointFieldPMG& points = mesh_.points(); for(label iterationI=0;iterationI<nIterations;++iterationI) @@ -122,7 +122,7 @@ void meshOptimizer::laplaceSmoother::laplacianSurface newP += points[pLabel]; ++counter; } - + if( counter != 0 ) { newP /= counter; diff --git a/meshLibrary/utilities/smoothers/geometry/meshOptimizer/meshOptimizerOptimizePointParallel.C b/meshLibrary/utilities/smoothers/geometry/meshOptimizer/meshOptimizerOptimizePointParallel.C index 3dcef4d6..58ead361 100644 --- a/meshLibrary/utilities/smoothers/geometry/meshOptimizer/meshOptimizerOptimizePointParallel.C +++ b/meshLibrary/utilities/smoothers/geometry/meshOptimizer/meshOptimizerOptimizePointParallel.C @@ -67,42 +67,42 @@ void meshOptimizer::laplaceSmoother::laplacianParallel const Map<label>& globalToLocal = addressing.globalToLocalPointAddressing(); //- create storage for the data - std::map<label, labelledPoint> localData; + std::map<label, labelledPoint> localData; //- create data which shall be exchanged with other processors std::map<label, LongList<refLabelledPoint> > exchangeData; forAll(procPoints, pI) { - const label pointI = procPoints[pI]; - - localData.insert(std::make_pair(pointI, labelledPoint(0,vector::zero))); - labelledPoint& lpd = localData[pointI]; - + const label pointI = procPoints[pI]; + + localData.insert(std::make_pair(pointI, labelledPoint(0,vector::zero))); + labelledPoint& lpd = localData[pointI]; + forAllRow(pPoints, pointI, ppI) { const label nei = pPoints(pointI, ppI); if( smoothOnlySurfaceNodes && (vertexLocation_[nei] & INSIDE) ) continue; - - if( pointAtProcs.sizeOfRow(nei) != 0 ) - { - label pMin(Pstream::nProcs()); - forAllRow(pointAtProcs, nei, procI) - { - const label procJ = pointAtProcs(nei, procI); - if( (procJ < pMin) && pointAtProcs.contains(pointI, procJ) ) - pMin = procJ; - } - - if( pMin != Pstream::myProcNo() ) - continue; - } - - ++lpd.pointLabel(); - lpd.coordinates() += points[nei]; + + if( pointAtProcs.sizeOfRow(nei) != 0 ) + { + label pMin(Pstream::nProcs()); + forAllRow(pointAtProcs, nei, procI) + { + const label procJ = pointAtProcs(nei, procI); + if( (procJ < pMin) && pointAtProcs.contains(pointI, procJ) ) + pMin = procJ; + } + + if( pMin != Pstream::myProcNo() ) + continue; + } + + ++lpd.pointLabel(); + lpd.coordinates() += points[nei]; } - + forAllRow(pointAtProcs, pointI, procI) { const label neiProc = pointAtProcs(pointI, procI); @@ -118,8 +118,8 @@ void meshOptimizer::laplaceSmoother::laplacianParallel } //- add data to the list which will be sent to other processor - LongList<refLabelledPoint>& dts = exchangeData[neiProc]; - dts.append(refLabelledPoint(globalPointLabel[pointI], lpd)); + LongList<refLabelledPoint>& dts = exchangeData[neiProc]; + dts.append(refLabelledPoint(globalPointLabel[pointI], lpd)); } } @@ -152,32 +152,32 @@ void meshOptimizer::laplaceSmoother::laplacianParallel points[pointI] = newP; } } - - # ifdef DEBUGSmooth - //- check - std::map<label, LongList<labelledPoint> > check; - forAll(procPoints, pI) - { - const label pointI = procPoints[pI]; - - forAllRow(pointAtProcs, pointI, i) - { - const label procI = pointAtProcs(pointI, i); - if( procI == Pstream::myProcNo() ) - continue; - if( check.find(procI) == check.end() ) - { - check.insert(std::make_pair(procI, LongList<labelledPoint>())); - } - - LongList<labelledPoint>& data = check[procI]; - data.append(labelledPoint(globalPointLabel[pointI],points[pointI])); - } - } - + + # ifdef DEBUGSmooth + //- check + std::map<label, LongList<labelledPoint> > check; + forAll(procPoints, pI) + { + const label pointI = procPoints[pI]; + + forAllRow(pointAtProcs, pointI, i) + { + const label procI = pointAtProcs(pointI, i); + if( procI == Pstream::myProcNo() ) + continue; + if( check.find(procI) == check.end() ) + { + check.insert(std::make_pair(procI, LongList<labelledPoint>())); + } + + LongList<labelledPoint>& data = check[procI]; + data.append(labelledPoint(globalPointLabel[pointI],points[pointI])); + } + } + LongList<labelledPoint> data; help::exchangeMap(check, data); - + forAll(data, i) { const label pointI = globalToLocal[data[i].pointLabel()]; @@ -186,7 +186,7 @@ void meshOptimizer::laplaceSmoother::laplacianParallel Pout << "Crap " << globalPointLabel[pointI] << " coordinates " << points[pointI] << " point there " << data[i] << endl; } - # endif + # endif } void meshOptimizer::laplaceSmoother::laplacianPCParallel @@ -211,25 +211,25 @@ void meshOptimizer::laplaceSmoother::laplacianPCParallel const Map<label>& globalToLocal = addressing.globalToLocalPointAddressing(); //- create storage for the data - std::map<label, labelledPoint> localData; + std::map<label, labelledPoint> localData; //- create data which shall be exchanged with other processors std::map<label, LongList<refLabelledPoint> > exchangeData; forAll(procPoints, pI) { - const label pointI = procPoints[pI]; - - localData.insert(std::make_pair(pointI, labelledPoint(0,vector::zero))); - labelledPoint& lpd = localData[pointI]; - + const label pointI = procPoints[pI]; + + localData.insert(std::make_pair(pointI, labelledPoint(0,vector::zero))); + labelledPoint& lpd = localData[pointI]; + forAllRow(pCells, pointI, pcI) { const label cellI = pCells(pointI, pcI); - - ++lpd.pointLabel(); - lpd.coordinates() += centres[cellI]; + + ++lpd.pointLabel(); + lpd.coordinates() += centres[cellI]; } - + forAllRow(pointAtProcs, pointI, procI) { const label neiProc = pointAtProcs(pointI, procI); @@ -245,8 +245,8 @@ void meshOptimizer::laplaceSmoother::laplacianPCParallel } //- add data to the list which will be sent to other processor - LongList<refLabelledPoint>& dts = exchangeData[neiProc]; - dts.append(refLabelledPoint(globalPointLabel[pointI], lpd)); + LongList<refLabelledPoint>& dts = exchangeData[neiProc]; + dts.append(refLabelledPoint(globalPointLabel[pointI], lpd)); } } @@ -279,32 +279,32 @@ void meshOptimizer::laplaceSmoother::laplacianPCParallel points[pointI] = newP; } } - - # ifdef DEBUGSmooth - //- check - std::map<label, LongList<labelledPoint> > check; - forAll(procPoints, pI) - { - const label pointI = procPoints[pI]; - - forAllRow(pointAtProcs, pointI, i) - { - const label procI = pointAtProcs(pointI, i); - if( procI == Pstream::myProcNo() ) - continue; - if( check.find(procI) == check.end() ) - { - check.insert(std::make_pair(procI, LongList<labelledPoint>())); - } - - LongList<labelledPoint>& data = check[procI]; - data.append(labelledPoint(globalPointLabel[pointI],points[pointI])); - } - } - + + # ifdef DEBUGSmooth + //- check + std::map<label, LongList<labelledPoint> > check; + forAll(procPoints, pI) + { + const label pointI = procPoints[pI]; + + forAllRow(pointAtProcs, pointI, i) + { + const label procI = pointAtProcs(pointI, i); + if( procI == Pstream::myProcNo() ) + continue; + if( check.find(procI) == check.end() ) + { + check.insert(std::make_pair(procI, LongList<labelledPoint>())); + } + + LongList<labelledPoint>& data = check[procI]; + data.append(labelledPoint(globalPointLabel[pointI],points[pointI])); + } + } + LongList<labelledPoint> data; help::exchangeMap(check, data); - + forAll(data, i) { const label pointI = globalToLocal[data[i].pointLabel()]; @@ -313,7 +313,7 @@ void meshOptimizer::laplaceSmoother::laplacianPCParallel Pout << "Crap " << globalPointLabel[pointI] << " coordinates " << points[pointI] << " point there " << data[i] << endl; } - # endif + # endif } void meshOptimizer::laplaceSmoother::laplacianWPCParallel @@ -339,15 +339,15 @@ void meshOptimizer::laplaceSmoother::laplacianWPCParallel const Map<label>& globalToLocal = addressing.globalToLocalPointAddressing(); //- create storage for the data - std::map<label, labelledPointScalar> localData; + std::map<label, labelledPointScalar> localData; //- create data which shall be exchanged with other processors std::map<label, LongList<labelledPointScalar> > exchangeData; forAll(procPoints, pI) { - const label pointI = procPoints[pI]; - - localData.insert + const label pointI = procPoints[pI]; + + localData.insert ( std::make_pair ( @@ -355,17 +355,17 @@ void meshOptimizer::laplaceSmoother::laplacianWPCParallel labelledPointScalar(globalPointLabel[pointI], vector::zero, 0.) ) ); - labelledPointScalar& lps = localData[pointI]; - + labelledPointScalar& lps = localData[pointI]; + forAllRow(pCells, pointI, pcI) { const label cellI = pCells(pointI, pcI); - - const scalar w = Foam::max(volumes[cellI], VSMALL); - lps.coordinates() += w * centres[cellI]; + + const scalar w = Foam::max(volumes[cellI], VSMALL); + lps.coordinates() += w * centres[cellI]; lps.scalarValue() += w; } - + forAllRow(pointAtProcs, pointI, procI) { const label neiProc = pointAtProcs(pointI, procI); @@ -381,8 +381,8 @@ void meshOptimizer::laplaceSmoother::laplacianWPCParallel } //- add data to the list which will be sent to other processor - LongList<labelledPointScalar>& dts = exchangeData[neiProc]; - dts.append(lps); + LongList<labelledPointScalar>& dts = exchangeData[neiProc]; + dts.append(lps); } } @@ -415,32 +415,32 @@ void meshOptimizer::laplaceSmoother::laplacianWPCParallel points[pointI] = newP; } } - - # ifdef DEBUGSmooth - //- check - std::map<label, LongList<labelledPoint> > check; - forAll(procPoints, pI) - { - const label pointI = procPoints[pI]; - - forAllRow(pointAtProcs, pointI, i) - { - const label procI = pointAtProcs(pointI, i); - if( procI == Pstream::myProcNo() ) - continue; - if( check.find(procI) == check.end() ) - { - check.insert(std::make_pair(procI, LongList<labelledPoint>())); - } - - LongList<labelledPoint>& data = check[procI]; - data.append(labelledPoint(globalPointLabel[pointI],points[pointI])); - } - } - + + # ifdef DEBUGSmooth + //- check + std::map<label, LongList<labelledPoint> > check; + forAll(procPoints, pI) + { + const label pointI = procPoints[pI]; + + forAllRow(pointAtProcs, pointI, i) + { + const label procI = pointAtProcs(pointI, i); + if( procI == Pstream::myProcNo() ) + continue; + if( check.find(procI) == check.end() ) + { + check.insert(std::make_pair(procI, LongList<labelledPoint>())); + } + + LongList<labelledPoint>& data = check[procI]; + data.append(labelledPoint(globalPointLabel[pointI],points[pointI])); + } + } + LongList<labelledPoint> data; help::exchangeMap(check, data); - + forAll(data, i) { const label pointI = globalToLocal[data[i].pointLabel()]; @@ -449,7 +449,7 @@ void meshOptimizer::laplaceSmoother::laplacianWPCParallel Pout << "Crap " << globalPointLabel[pointI] << " coordinates " << points[pointI] << " point there " << data[i] << endl; } - # endif + # endif } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/meshLibrary/utilities/smoothers/geometry/meshOptimizer/meshOptimizerOptimizeSurface.C b/meshLibrary/utilities/smoothers/geometry/meshOptimizer/meshOptimizerOptimizeSurface.C index bd4b563d..da5f1635 100644 --- a/meshLibrary/utilities/smoothers/geometry/meshOptimizer/meshOptimizerOptimizeSurface.C +++ b/meshLibrary/utilities/smoothers/geometry/meshOptimizer/meshOptimizerOptimizeSurface.C @@ -45,15 +45,15 @@ namespace Foam void meshOptimizer::optimizeSurface(const meshOctree& octree) { Info << "Optimizing positions of surface nodes" << endl; - - meshSurfaceEngine& mse = const_cast<meshSurfaceEngine&>(meshSurface()); - meshSurfaceOptimizer surfaceOptimizer(mse, octree); + + meshSurfaceEngine& mse = const_cast<meshSurfaceEngine&>(meshSurface()); + meshSurfaceOptimizer surfaceOptimizer(mse, octree); - surfaceOptimizer.optimizeSurface(); + surfaceOptimizer.optimizeSurface(); meshSurfaceMapper(mse, octree).mapVerticesOntoSurfacePatches(); - - clearSurface(); + + clearSurface(); Info << "Finished optimizing positions of surface nodes" << endl; } diff --git a/meshLibrary/utilities/smoothers/geometry/meshOptimizer/optimizeMeshFV.C b/meshLibrary/utilities/smoothers/geometry/meshOptimizer/optimizeMeshFV.C index d564e5e9..42ef6e15 100644 --- a/meshLibrary/utilities/smoothers/geometry/meshOptimizer/optimizeMeshFV.C +++ b/meshLibrary/utilities/smoothers/geometry/meshOptimizer/optimizeMeshFV.C @@ -55,20 +55,20 @@ namespace Foam void meshOptimizer::untangleMeshFV() { - Info << "Starting untangling the mesh" << endl; - - # ifdef DEBUGSmooth - partTetMesh tm(mesh_); - forAll(tm.tets(), tetI) - if( tm.tets()[tetI].mag(tm.points()) < 0.0 ) - Info << "Tet " << tetI << " is inverted!" << endl; - polyMeshGen tetPolyMesh(mesh_.returnTime()); - tm.createPolyMesh(tetPolyMesh); + Info << "Starting untangling the mesh" << endl; + + # ifdef DEBUGSmooth + partTetMesh tm(mesh_); + forAll(tm.tets(), tetI) + if( tm.tets()[tetI].mag(tm.points()) < 0.0 ) + Info << "Tet " << tetI << " is inverted!" << endl; + polyMeshGen tetPolyMesh(mesh_.returnTime()); + tm.createPolyMesh(tetPolyMesh); polyMeshGenModifier(tetPolyMesh).removeUnusedVertices(); - forAll(tm.smoothVertex(), pI) - if( !tm.smoothVertex()[pI] ) - Info << "Point " << pI << " cannot be moved!" << endl; - //writeMeshEnsight(tetPolyMesh, "tetMesh"); + forAll(tm.smoothVertex(), pI) + if( !tm.smoothVertex()[pI] ) + Info << "Point " << pI << " cannot be moved!" << endl; + //writeMeshEnsight(tetPolyMesh, "tetMesh"); writeMeshFLMA(tetPolyMesh, "tetMesh"); const VRWGraph& pTets = tm.pointTets(); @@ -83,59 +83,59 @@ void meshOptimizer::untangleMeshFV() word name("simplex"+help::scalarToText(pointI)); writeSimplexFLMA(simplex, name); } - - boolList boundaryVertex(tetPolyMesh.points().size(), false); - const labelList& neighbour = tetPolyMesh.neighbour(); - forAll(neighbour, faceI) - if( neighbour[faceI] == -1 ) - { - const face& f = tetPolyMesh.faces()[faceI]; - - forAll(f, pI) - boundaryVertex[f[pI]] = true; - } - - forAll(boundaryVertex, pI) - { - if( boundaryVertex[pI] && tm.smoothVertex()[pI] ) - FatalErrorIn - ( - "void meshOptimizer::untangleMeshFV()" - ) << "Boundary vertex should not be moved!" << abort(FatalError); - } - # endif - - label nBadFaces, nGlobalIter(0), nIter; + + boolList boundaryVertex(tetPolyMesh.points().size(), false); + const labelList& neighbour = tetPolyMesh.neighbour(); + forAll(neighbour, faceI) + if( neighbour[faceI] == -1 ) + { + const face& f = tetPolyMesh.faces()[faceI]; + + forAll(f, pI) + boundaryVertex[f[pI]] = true; + } + + forAll(boundaryVertex, pI) + { + if( boundaryVertex[pI] && tm.smoothVertex()[pI] ) + FatalErrorIn + ( + "void meshOptimizer::untangleMeshFV()" + ) << "Boundary vertex should not be moved!" << abort(FatalError); + } + # endif + + label nBadFaces, nGlobalIter(0), nIter; const label maxNumGlobalIterations(10); - - const faceListPMG& faces = mesh_.faces(); - boolList changedFace(faces.size(), true); + + const faceListPMG& faces = mesh_.faces(); + boolList changedFace(faces.size(), true); labelHashSet badFaces; - - do - { - nIter = 0; + + do + { + nIter = 0; label minNumBadFaces(10 * faces.size()), minIter(-1); - do - { - nBadFaces = findBadFaces(badFaces, changedFace); + do + { + nBadFaces = findBadFaces(badFaces, changedFace); Info << "Iteration " << nIter << ". Number of bad faces is " << nBadFaces << endl; - //- perform optimisation - if( nBadFaces == 0 ) - break; + //- perform optimisation + if( nBadFaces == 0 ) + break; if( nBadFaces < minNumBadFaces ) { minNumBadFaces = nBadFaces; minIter = nIter; } - - partTetMesh tetMesh(mesh_, badFaces, (nGlobalIter / 5) + 1); + + partTetMesh tetMesh(mesh_, badFaces, (nGlobalIter / 5) + 1); tetMeshOptimisation tmo(tetMesh); @@ -145,28 +145,28 @@ void meshOptimizer::untangleMeshFV() tmo.optimiseUsingVolumeOptimizer(); - tetMesh.updateOrigMesh(&changedFace); - - } while( (nIter < minIter+5) && (++nIter < 50) ); + tetMesh.updateOrigMesh(&changedFace); + + } while( (nIter < minIter+5) && (++nIter < 50) ); - if( (nBadFaces == 0) || (++nGlobalIter >= maxNumGlobalIterations) ) - break; + if( (nBadFaces == 0) || (++nGlobalIter >= maxNumGlobalIterations) ) + break; // move boundary vertices nIter = 0; - do - { - nBadFaces = findBadFaces(badFaces, changedFace); + do + { + nBadFaces = findBadFaces(badFaces, changedFace); Info << "Iteration " << nIter << ". Number of bad faces is " << nBadFaces << endl; - //- perform optimisation - if( nBadFaces == 0 ) - break; - - partTetMesh tetMesh(mesh_, badFaces, 0); + //- perform optimisation + if( nBadFaces == 0 ) + break; + + partTetMesh tetMesh(mesh_, badFaces, 0); tetMeshOptimisation tmo(tetMesh); if( nGlobalIter < 2 ) @@ -185,22 +185,22 @@ void meshOptimizer::untangleMeshFV() tmo.optimiseBoundaryVolumeOptimizer(false); } - tetMesh.updateOrigMesh(&changedFace); + tetMesh.updateOrigMesh(&changedFace); - } while( ++nIter < 2 ); - } - while( nBadFaces ); - - Info << "Finished untangling the mesh" << endl; + } while( ++nIter < 2 ); + } + while( nBadFaces ); + + Info << "Finished untangling the mesh" << endl; } void meshOptimizer::optimizeLowQualityFaces() { label nBadFaces, nIter(0); - - const faceListPMG& faces = mesh_.faces(); - boolList changedFace(faces.size(), true); - + + const faceListPMG& faces = mesh_.faces(); + boolList changedFace(faces.size(), true); + label minNumBadFaces(10 * faces.size()), minIter(-1); do { @@ -238,7 +238,7 @@ void meshOptimizer::optimizeLowQualityFaces() } while( (nIter < minIter+2) && (++nIter < 10) ); } - + void meshOptimizer::optimizeMeshFV() { Info << "Starting smoothing the mesh" << endl; @@ -246,8 +246,8 @@ void meshOptimizer::optimizeMeshFV() laplaceSmoother lps(mesh_, vertexLocation_); lps.optimizeLaplacianPC(2); lps.optimizeLaplacianWPC(3); - - untangleMeshFV(); + + untangleMeshFV(); Info << "Finished smoothing the mesh" << endl; } diff --git a/meshLibrary/utilities/smoothers/geometry/meshOptimizer/tetMeshOptimisation/advancedSmoothers/knuppMetric/knuppMetric.C b/meshLibrary/utilities/smoothers/geometry/meshOptimizer/tetMeshOptimisation/advancedSmoothers/knuppMetric/knuppMetric.C index 609816e2..8c6f384d 100644 --- a/meshLibrary/utilities/smoothers/geometry/meshOptimizer/tetMeshOptimisation/advancedSmoothers/knuppMetric/knuppMetric.C +++ b/meshLibrary/utilities/smoothers/geometry/meshOptimizer/tetMeshOptimisation/advancedSmoothers/knuppMetric/knuppMetric.C @@ -80,9 +80,9 @@ void knuppMetric::evaluateGradients(vector& grad, tensor& gradGrad) const gradGrad += gfx * gfx; } } - + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - + knuppMetric::knuppMetric(partTetMeshSimplex& simplex) : simplexSmoother(simplex), @@ -93,15 +93,15 @@ knuppMetric::knuppMetric(partTetMeshSimplex& simplex) { forAll(tets_, tetI) { - const partTet& pt = tets_[tetI]; - const triangle<point, point> tri - ( - points_[pt.a()], - points_[pt.b()], - points_[pt.c()] - ); + const partTet& pt = tets_[tetI]; + const triangle<point, point> tri + ( + points_[pt.a()], + points_[pt.b()], + points_[pt.c()] + ); - const vector n = tri.normal(); + const vector n = tri.normal(); const scalar d = mag(n); if( d > VSMALL ) @@ -113,7 +113,7 @@ knuppMetric::knuppMetric(partTetMeshSimplex& simplex) beta_ = 0.01 * bb_.mag(); } - + knuppMetric::~knuppMetric() { @@ -190,7 +190,7 @@ void knuppMetric::optimizeNodePosition(const scalar tolObsolete) # ifdef DEBUGSmooth Info << "Second grad " << gradGradF << endl; - Info << "inv(gradGradF, determinant) " << inv(gradGradF, determinant) << endl; + Info << "inv(gradGradF, determinant) " << inv(gradGradF, determinant) << endl; Info << "Gradient " << gradF << endl; Info << "Determinant " << determinant << endl; Info << "Displacement " << disp << endl; @@ -198,25 +198,25 @@ void knuppMetric::optimizeNodePosition(const scalar tolObsolete) # endif - scalar relax(0.8); - label nLoops(0); - while( func > lastFunc ) - { - p_ = pOrig - relax * disp; - relax *= 0.5; - func = evaluateMetric(); - - if( func < lastFunc ) - continue; - - //- it seems that this direction is wrong - if( ++nLoops == 5 ) - { - p_ = pOrig; - disp = vector::zero; - func = 0.0; - } - } + scalar relax(0.8); + label nLoops(0); + while( func > lastFunc ) + { + p_ = pOrig - relax * disp; + relax *= 0.5; + func = evaluateMetric(); + + if( func < lastFunc ) + continue; + + //- it seems that this direction is wrong + if( ++nLoops == 5 ) + { + p_ = pOrig; + disp = vector::zero; + func = 0.0; + } + } lastFunc = func; } diff --git a/meshLibrary/utilities/smoothers/geometry/meshOptimizer/tetMeshOptimisation/advancedSmoothers/knuppMetric/knuppMetric.H b/meshLibrary/utilities/smoothers/geometry/meshOptimizer/tetMeshOptimisation/advancedSmoothers/knuppMetric/knuppMetric.H index f87f20a5..7075d94d 100644 --- a/meshLibrary/utilities/smoothers/geometry/meshOptimizer/tetMeshOptimisation/advancedSmoothers/knuppMetric/knuppMetric.H +++ b/meshLibrary/utilities/smoothers/geometry/meshOptimizer/tetMeshOptimisation/advancedSmoothers/knuppMetric/knuppMetric.H @@ -27,7 +27,7 @@ Class Description Mesh smoothing using Knupp's metric. The metric is non-zero for inverted - tets only + tets only SourceFiles knuppMetric.C @@ -57,8 +57,8 @@ class knuppMetric public simplexSmoother { // Private data - //- free vertex - point& p_; + //- free vertex + point& p_; //- normals of triangles forming the outer hull DynList<vector, 64> normals_; @@ -79,15 +79,15 @@ class knuppMetric public: - knuppMetric(partTetMeshSimplex& simplex); + knuppMetric(partTetMeshSimplex& simplex); - // Destructor - ~knuppMetric(); + // Destructor + ~knuppMetric(); - // Member functions - //- find the best position such that all tets making a simplex - //- have a positive volume - void optimizeNodePosition(const scalar tol = 0.001); + // Member functions + //- find the best position such that all tets making a simplex + //- have a positive volume + void optimizeNodePosition(const scalar tol = 0.001); }; // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/meshLibrary/utilities/smoothers/geometry/meshOptimizer/tetMeshOptimisation/advancedSmoothers/meshUntangler/meshUntangler.C b/meshLibrary/utilities/smoothers/geometry/meshOptimizer/tetMeshOptimisation/advancedSmoothers/meshUntangler/meshUntangler.C index 9fe49807..09d67568 100644 --- a/meshLibrary/utilities/smoothers/geometry/meshOptimizer/tetMeshOptimisation/advancedSmoothers/meshUntangler/meshUntangler.C +++ b/meshLibrary/utilities/smoothers/geometry/meshOptimizer/tetMeshOptimisation/advancedSmoothers/meshUntangler/meshUntangler.C @@ -41,15 +41,15 @@ Description namespace Foam { - + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // meshUntangler::meshUntangler ( - partTetMeshSimplex& simplex + partTetMeshSimplex& simplex ) : - simplexSmoother(simplex) + simplexSmoother(simplex) { } @@ -60,47 +60,47 @@ meshUntangler::~meshUntangler() void meshUntangler::optimizeNodePosition(const scalar tol) { - # ifdef DEBUGSmooth - Info << "Untangling point " << pointI_ << endl; - # endif - - cutRegion cr(bb_); - - forAll(tets_, tetI) - { - const partTet& tet = tets_[tetI]; - vector n - ( - (points_[tet.b()] - points_[tet.a()]) ^ - (points_[tet.c()] - points_[tet.a()]) - ); - - if( mag(n) < VSMALL ) continue; - - plane pl(points_[tet.a()], n); - - # ifdef DEBUGSmooth - Info << "tet.a() " << tet.a() << endl; - Info << "Cutting plane ref point " << pl.refPoint() << endl; - Info << "Cutting plane normal " << pl.normal() << endl; - # endif - - cr.planeCut(pl); - } - - if( cr.points().size() ) - { - point p(vector::zero); - - const DynList<point, 64>& pts = cr.points(); - forAll(pts, pI) - p += pts[pI]; - - p /= pts.size(); - - # ifdef DEBUGSmooth - Info << "Corners of the feasible region " << pts << endl; - # endif + # ifdef DEBUGSmooth + Info << "Untangling point " << pointI_ << endl; + # endif + + cutRegion cr(bb_); + + forAll(tets_, tetI) + { + const partTet& tet = tets_[tetI]; + vector n + ( + (points_[tet.b()] - points_[tet.a()]) ^ + (points_[tet.c()] - points_[tet.a()]) + ); + + if( mag(n) < VSMALL ) continue; + + plane pl(points_[tet.a()], n); + + # ifdef DEBUGSmooth + Info << "tet.a() " << tet.a() << endl; + Info << "Cutting plane ref point " << pl.refPoint() << endl; + Info << "Cutting plane normal " << pl.normal() << endl; + # endif + + cr.planeCut(pl); + } + + if( cr.points().size() ) + { + point p(vector::zero); + + const DynList<point, 64>& pts = cr.points(); + forAll(pts, pI) + p += pts[pI]; + + p /= pts.size(); + + # ifdef DEBUGSmooth + Info << "Corners of the feasible region " << pts << endl; + # endif for(direction i=0;i<vector::nComponents;++i) { @@ -108,9 +108,9 @@ void meshUntangler::optimizeNodePosition(const scalar tol) if( (val != val) || ((val - val) != (val - val)) ) return; } - + points_[pointI_] = p; - } + } } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/meshLibrary/utilities/smoothers/geometry/meshOptimizer/tetMeshOptimisation/advancedSmoothers/meshUntangler/meshUntangler.H b/meshLibrary/utilities/smoothers/geometry/meshOptimizer/tetMeshOptimisation/advancedSmoothers/meshUntangler/meshUntangler.H index 55f65151..28080b67 100644 --- a/meshLibrary/utilities/smoothers/geometry/meshOptimizer/tetMeshOptimisation/advancedSmoothers/meshUntangler/meshUntangler.H +++ b/meshLibrary/utilities/smoothers/geometry/meshOptimizer/tetMeshOptimisation/advancedSmoothers/meshUntangler/meshUntangler.H @@ -27,7 +27,7 @@ Class Description Mesh smoothing without any topological changes. The vertex is put - into the centre of the convex feasible region. + into the centre of the convex feasible region. SourceFiles meshUntangler.C @@ -52,93 +52,93 @@ class partTetMeshSimplex; /*---------------------------------------------------------------------------*\ Class meshUntangler Declaration \*---------------------------------------------------------------------------*/ - + class meshUntangler : public simplexSmoother { - // Private nested classes - - class cutRegion - { - // Private data - DynList<point, 64>* pointsPtr_; - DynList<edge, 128>* edgesPtr_; - DynList<DynList<label, 8>, 64>* facesPtr_; - - //- helper data - DynList<point, 64>* cPtsPtr_; - DynList<edge, 128>* cEdgesPtr_; - DynList<DynList<label, 8>, 64>* cFacesPtr_; - - DynList<label, 64> newVertexLabel_; - DynList<scalar, 64> vertexDistance_; - DynList<direction, 64> vertexTypes_; - DynList<label, 128> newEdgeLabel_; - label origNumVertices_; - - scalar tol_; - bool valid_; - - // Private member functions - bool findNewVertices(const plane& plane); - void findNewEdges(); - void findNewFaces(); - - //- tie break to resolve problems due to truncation - //- errors - void tieBreak(const DynList<label, 8>& f); - - //- remove coincident vertices to improve tie breaking - void removeCoincidentVertices(); - - void createInitialConfiguration(const boundBox&); - - // Enumerations - enum vTypes - { - NONE = 0, - KEEP = 1, - INPLANE = 2, - USED = 4 - }; - - public: - - // Constructor - //- Construct from boundBox - cutRegion(const boundBox&); - - // Destructor - ~cutRegion(); - - // Member functions - //- return the vertices of the feasible region - inline const DynList<point, 64>& points() const - { - return *pointsPtr_; - } - - //- cut the region woth the plane - void planeCut(const plane& plane); - - //- export the feasible region as polyMeshGen - void createPolyMeshFromRegion(polyMeshGen&) const; - }; - - public: - + // Private nested classes + + class cutRegion + { + // Private data + DynList<point, 64>* pointsPtr_; + DynList<edge, 128>* edgesPtr_; + DynList<DynList<label, 8>, 64>* facesPtr_; + + //- helper data + DynList<point, 64>* cPtsPtr_; + DynList<edge, 128>* cEdgesPtr_; + DynList<DynList<label, 8>, 64>* cFacesPtr_; + + DynList<label, 64> newVertexLabel_; + DynList<scalar, 64> vertexDistance_; + DynList<direction, 64> vertexTypes_; + DynList<label, 128> newEdgeLabel_; + label origNumVertices_; + + scalar tol_; + bool valid_; + + // Private member functions + bool findNewVertices(const plane& plane); + void findNewEdges(); + void findNewFaces(); + + //- tie break to resolve problems due to truncation + //- errors + void tieBreak(const DynList<label, 8>& f); + + //- remove coincident vertices to improve tie breaking + void removeCoincidentVertices(); + + void createInitialConfiguration(const boundBox&); + + // Enumerations + enum vTypes + { + NONE = 0, + KEEP = 1, + INPLANE = 2, + USED = 4 + }; + + public: + + // Constructor + //- Construct from boundBox + cutRegion(const boundBox&); + + // Destructor + ~cutRegion(); + + // Member functions + //- return the vertices of the feasible region + inline const DynList<point, 64>& points() const + { + return *pointsPtr_; + } + + //- cut the region woth the plane + void planeCut(const plane& plane); + + //- export the feasible region as polyMeshGen + void createPolyMeshFromRegion(polyMeshGen&) const; + }; + + public: + // Constructor //- Construct from partTetMeshSimplex meshUntangler(partTetMeshSimplex& simplex); - - // Destructor - ~meshUntangler(); - - // Member functions - //- improve the position the the node by putting it + + // Destructor + ~meshUntangler(); + + // Member functions + //- improve the position the the node by putting it //- into the feasible region - void optimizeNodePosition(const scalar tol = 0.001); + void optimizeNodePosition(const scalar tol = 0.001); }; diff --git a/meshLibrary/utilities/smoothers/geometry/meshOptimizer/tetMeshOptimisation/advancedSmoothers/meshUntangler/meshUntanglerCutRegion.C b/meshLibrary/utilities/smoothers/geometry/meshOptimizer/tetMeshOptimisation/advancedSmoothers/meshUntangler/meshUntanglerCutRegion.C index 78b7fd7f..04bfd1ba 100644 --- a/meshLibrary/utilities/smoothers/geometry/meshOptimizer/tetMeshOptimisation/advancedSmoothers/meshUntangler/meshUntanglerCutRegion.C +++ b/meshLibrary/utilities/smoothers/geometry/meshOptimizer/tetMeshOptimisation/advancedSmoothers/meshUntangler/meshUntanglerCutRegion.C @@ -45,247 +45,247 @@ Description namespace Foam { - + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - + void meshUntangler::cutRegion::createInitialConfiguration ( - const boundBox& bb + const boundBox& bb ) -{ - pointsPtr_ = new DynList<point, 64>(); - DynList<point, 64>& bVertices = *pointsPtr_; - edgesPtr_ = new DynList<edge, 128>(); - DynList<edge, 128>& bEdges = *edgesPtr_; - facesPtr_ = new DynList<DynList<label, 8>, 64>(); - DynList<DynList<label, 8>, 64>& bFaces = *facesPtr_; - - //- set vertices - const point c = (bb.max() + bb.min()) / 2.0; - const point vec = (bb.max() - bb.min()) / 2.0; - bVertices.append - ( - point(c.x() - vec.x(), c.y() - vec.y(), c.z() - vec.z()) - ); - bVertices.append - ( - point(c.x() + vec.x(), c.y() - vec.y(), c.z() - vec.z()) - ); - bVertices.append - ( - point(c.x() + vec.x(), c.y() + vec.y(), c.z() - vec.z()) - ); - bVertices.append - ( - point(c.x() - vec.x(), c.y() + vec.y(), c.z() - vec.z()) - ); - bVertices.append - ( - point(c.x() - vec.x(), c.y() - vec.y(), c.z() + vec.z()) - ); - bVertices.append - ( - point(c.x() + vec.x(), c.y() - vec.y(), c.z() + vec.z()) - ); - bVertices.append - ( - point(c.x() + vec.x(), c.y() + vec.y(), c.z() + vec.z()) - ); - bVertices.append - ( - point(c.x() - vec.x(), c.y() + vec.y(), c.z() + vec.z()) - ); - - //- set edges +{ + pointsPtr_ = new DynList<point, 64>(); + DynList<point, 64>& bVertices = *pointsPtr_; + edgesPtr_ = new DynList<edge, 128>(); + DynList<edge, 128>& bEdges = *edgesPtr_; + facesPtr_ = new DynList<DynList<label, 8>, 64>(); + DynList<DynList<label, 8>, 64>& bFaces = *facesPtr_; + + //- set vertices + const point c = (bb.max() + bb.min()) / 2.0; + const point vec = (bb.max() - bb.min()) / 2.0; + bVertices.append + ( + point(c.x() - vec.x(), c.y() - vec.y(), c.z() - vec.z()) + ); + bVertices.append + ( + point(c.x() + vec.x(), c.y() - vec.y(), c.z() - vec.z()) + ); + bVertices.append + ( + point(c.x() + vec.x(), c.y() + vec.y(), c.z() - vec.z()) + ); + bVertices.append + ( + point(c.x() - vec.x(), c.y() + vec.y(), c.z() - vec.z()) + ); + bVertices.append + ( + point(c.x() - vec.x(), c.y() - vec.y(), c.z() + vec.z()) + ); + bVertices.append + ( + point(c.x() + vec.x(), c.y() - vec.y(), c.z() + vec.z()) + ); + bVertices.append + ( + point(c.x() + vec.x(), c.y() + vec.y(), c.z() + vec.z()) + ); + bVertices.append + ( + point(c.x() - vec.x(), c.y() + vec.y(), c.z() + vec.z()) + ); + + //- set edges - //- edges in x direction - bEdges.append(edge(0, 1)); - bEdges.append(edge(3, 2)); - bEdges.append(edge(7, 6)); - bEdges.append(edge(4, 5)); - - //- edges in y direction - bEdges.append(edge(1, 2)); - bEdges.append(edge(0, 3)); - bEdges.append(edge(4, 7)); - bEdges.append(edge(5, 6)); - - //- edges in z direction - bEdges.append(edge(0, 4)); - bEdges.append(edge(1, 5)); - bEdges.append(edge(2, 6)); - bEdges.append(edge(3, 7)); - - //- set faces - DynList<label, 8> f; - f.setSize(4); + //- edges in x direction + bEdges.append(edge(0, 1)); + bEdges.append(edge(3, 2)); + bEdges.append(edge(7, 6)); + bEdges.append(edge(4, 5)); + + //- edges in y direction + bEdges.append(edge(1, 2)); + bEdges.append(edge(0, 3)); + bEdges.append(edge(4, 7)); + bEdges.append(edge(5, 6)); + + //- edges in z direction + bEdges.append(edge(0, 4)); + bEdges.append(edge(1, 5)); + bEdges.append(edge(2, 6)); + bEdges.append(edge(3, 7)); + + //- set faces + DynList<label, 8> f; + f.setSize(4); - //- faces in x direction - f[0] = 5; - f[1] = 11; - f[2] = 6; - f[3] = 8; - bFaces.append(f); - f[0] = 4; - f[1] = 10; - f[2] = 7; - f[3] = 9; - bFaces.append(f); - //- faces in y direction - f[0] = 0; - f[1] = 8; - f[2] = 3; - f[3] = 9; - bFaces.append(f); - f[0] = 1; - f[1] = 11; - f[2] = 2; - f[3] = 10; - bFaces.append(f); - //- faces in z direction - f[0] = 0; - f[1] = 4; - f[2] = 1; - f[3] = 5; - bFaces.append(f); - f[0] = 3; - f[1] = 7; - f[2] = 2; - f[3] = 6; - bFaces.append(f); - - # ifdef DEBUGSmooth - Info << "Original vertices " << *pointsPtr_ << endl; - Info << "Original edges " << *edgesPtr_ << endl; - Info << "Original faces " << *facesPtr_ << endl; - # endif + //- faces in x direction + f[0] = 5; + f[1] = 11; + f[2] = 6; + f[3] = 8; + bFaces.append(f); + f[0] = 4; + f[1] = 10; + f[2] = 7; + f[3] = 9; + bFaces.append(f); + //- faces in y direction + f[0] = 0; + f[1] = 8; + f[2] = 3; + f[3] = 9; + bFaces.append(f); + f[0] = 1; + f[1] = 11; + f[2] = 2; + f[3] = 10; + bFaces.append(f); + //- faces in z direction + f[0] = 0; + f[1] = 4; + f[2] = 1; + f[3] = 5; + bFaces.append(f); + f[0] = 3; + f[1] = 7; + f[2] = 2; + f[3] = 6; + bFaces.append(f); + + # ifdef DEBUGSmooth + Info << "Original vertices " << *pointsPtr_ << endl; + Info << "Original edges " << *edgesPtr_ << endl; + Info << "Original faces " << *facesPtr_ << endl; + # endif } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - + meshUntangler::cutRegion::cutRegion(const boundBox& bb) : - pointsPtr_(NULL), - edgesPtr_(NULL), - facesPtr_(NULL), - cPtsPtr_(NULL), - cEdgesPtr_(NULL), - cFacesPtr_(NULL), - newVertexLabel_(), - vertexDistance_(), - vertexTypes_(), - newEdgeLabel_(), - origNumVertices_(), - tol_(SMALL * bb.mag()), - valid_(true) + pointsPtr_(NULL), + edgesPtr_(NULL), + facesPtr_(NULL), + cPtsPtr_(NULL), + cEdgesPtr_(NULL), + cFacesPtr_(NULL), + newVertexLabel_(), + vertexDistance_(), + vertexTypes_(), + newEdgeLabel_(), + origNumVertices_(), + tol_(SMALL * bb.mag()), + valid_(true) { - createInitialConfiguration(bb); + createInitialConfiguration(bb); } meshUntangler::cutRegion::~cutRegion() { - deleteDemandDrivenData(pointsPtr_); - deleteDemandDrivenData(edgesPtr_); - deleteDemandDrivenData(facesPtr_); - deleteDemandDrivenData(cPtsPtr_); - deleteDemandDrivenData(cEdgesPtr_); - deleteDemandDrivenData(cFacesPtr_); + deleteDemandDrivenData(pointsPtr_); + deleteDemandDrivenData(edgesPtr_); + deleteDemandDrivenData(facesPtr_); + deleteDemandDrivenData(cPtsPtr_); + deleteDemandDrivenData(cEdgesPtr_); + deleteDemandDrivenData(cFacesPtr_); } - + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // void meshUntangler::cutRegion::planeCut(const plane& plane) { - if( !valid_ ) - return; + if( !valid_ ) + return; - # ifdef DEBUGSmooth - if( cFacesPtr_ || cPtsPtr_ || cEdgesPtr_ ) - { - FatalErrorIn - ( - "void meshUntangler::" - "cutRegion::planeCut(const plane& plane)" - ) << "Pointers should not be allocated!" << abort(FatalError); - } - - Foam::Time runTime - ( - Foam::Time::controlDictName, - "../.", - "testSmoothing" - ); - - objectRegistry oR(runTime); + # ifdef DEBUGSmooth + if( cFacesPtr_ || cPtsPtr_ || cEdgesPtr_ ) + { + FatalErrorIn + ( + "void meshUntangler::" + "cutRegion::planeCut(const plane& plane)" + ) << "Pointers should not be allocated!" << abort(FatalError); + } + + Foam::Time runTime + ( + Foam::Time::controlDictName, + "../.", + "testSmoothing" + ); + + objectRegistry oR(runTime); - polyMeshGen pmg - ( - oR - ); - this->createPolyMeshFromRegion(pmg); - writeMeshEnsight(pmg, "feasibleRegion"); - # endif - - if( findNewVertices(plane) ) - { - findNewEdges(); - - findNewFaces(); - - if( !valid_ ) return; + polyMeshGen pmg + ( + oR + ); + this->createPolyMeshFromRegion(pmg); + writeMeshEnsight(pmg, "feasibleRegion"); + # endif + + if( findNewVertices(plane) ) + { + findNewEdges(); + + findNewFaces(); + + if( !valid_ ) return; - deleteDemandDrivenData(pointsPtr_); - pointsPtr_ = cPtsPtr_; - cPtsPtr_ = NULL; + deleteDemandDrivenData(pointsPtr_); + pointsPtr_ = cPtsPtr_; + cPtsPtr_ = NULL; - deleteDemandDrivenData(edgesPtr_); - edgesPtr_ = cEdgesPtr_; - cEdgesPtr_ = NULL; + deleteDemandDrivenData(edgesPtr_); + edgesPtr_ = cEdgesPtr_; + cEdgesPtr_ = NULL; - deleteDemandDrivenData(facesPtr_); - facesPtr_ = cFacesPtr_; - cFacesPtr_ = NULL; - } + deleteDemandDrivenData(facesPtr_); + facesPtr_ = cFacesPtr_; + cFacesPtr_ = NULL; + } } void meshUntangler::cutRegion::createPolyMeshFromRegion ( - polyMeshGen& mesh + polyMeshGen& mesh ) const { - polyMeshGenModifier meshModifier(mesh); - pointFieldPMG& points = meshModifier.pointsAccess(); - points.setSize(pointsPtr_->size()); - forAll(points, pI) - points[pI] = (*pointsPtr_)[pI]; - - faceListPMG& faces = meshModifier.facesAccess(); - cellListPMG& cells = meshModifier.cellsAccess(); - cells.setSize(1); - cells[0].setSize(facesPtr_->size()); - faces.setSize(facesPtr_->size()); - - const DynList<edge, 128>& edges = *edgesPtr_; - const DynList<DynList<label, 8>, 64>& fcs = *facesPtr_; - forAll(faces, fI) - { - DynList<edge> fEdges; - const DynList<label, 8>& f = fcs[fI]; - forAll(f, eI) - fEdges.append(edges[f[eI]]); - - Info << "Edges forming face " << fI << " are " << fEdges << endl; - labelListList sf = sortEdgesIntoChains(fEdges).sortedChains(); - if( sf.size() != 1 ) - FatalErrorIn - ( - "void meshOptimizer::meshUntangler::" - "cutRegion::createPolyMeshFromRegion(polyMesgGen&)" - ) << "More than one face created!" << abort(FatalError); - - faces[fI] = face(sf[0]); - cells[0][fI] = fI; - } + polyMeshGenModifier meshModifier(mesh); + pointFieldPMG& points = meshModifier.pointsAccess(); + points.setSize(pointsPtr_->size()); + forAll(points, pI) + points[pI] = (*pointsPtr_)[pI]; + + faceListPMG& faces = meshModifier.facesAccess(); + cellListPMG& cells = meshModifier.cellsAccess(); + cells.setSize(1); + cells[0].setSize(facesPtr_->size()); + faces.setSize(facesPtr_->size()); + + const DynList<edge, 128>& edges = *edgesPtr_; + const DynList<DynList<label, 8>, 64>& fcs = *facesPtr_; + forAll(faces, fI) + { + DynList<edge> fEdges; + const DynList<label, 8>& f = fcs[fI]; + forAll(f, eI) + fEdges.append(edges[f[eI]]); + + Info << "Edges forming face " << fI << " are " << fEdges << endl; + labelListList sf = sortEdgesIntoChains(fEdges).sortedChains(); + if( sf.size() != 1 ) + FatalErrorIn + ( + "void meshOptimizer::meshUntangler::" + "cutRegion::createPolyMeshFromRegion(polyMesgGen&)" + ) << "More than one face created!" << abort(FatalError); + + faces[fI] = face(sf[0]); + cells[0][fI] = fI; + } } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/meshLibrary/utilities/smoothers/geometry/meshOptimizer/tetMeshOptimisation/advancedSmoothers/meshUntangler/meshUntanglerCutRegionEdges.C b/meshLibrary/utilities/smoothers/geometry/meshOptimizer/tetMeshOptimisation/advancedSmoothers/meshUntangler/meshUntanglerCutRegionEdges.C index bc2e6d0d..ed2c915a 100644 --- a/meshLibrary/utilities/smoothers/geometry/meshOptimizer/tetMeshOptimisation/advancedSmoothers/meshUntangler/meshUntanglerCutRegionEdges.C +++ b/meshLibrary/utilities/smoothers/geometry/meshOptimizer/tetMeshOptimisation/advancedSmoothers/meshUntangler/meshUntanglerCutRegionEdges.C @@ -35,81 +35,81 @@ Description namespace Foam { - + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // void meshUntangler::cutRegion::findNewEdges() { - #ifdef DEBUGSmooth - Info << "Creating new edgesPtr_" << endl; - #endif - - cEdgesPtr_ = new DynList<edge, 128>(); - DynList<edge, 128>& cEdges = *cEdgesPtr_; - - const DynList<point, 64>& pts = *pointsPtr_; - const DynList<edge, 128>& edges = *edgesPtr_; - - newEdgeLabel_.setSize(edges.size()); - newEdgeLabel_ = -1; + #ifdef DEBUGSmooth + Info << "Creating new edgesPtr_" << endl; + #endif + + cEdgesPtr_ = new DynList<edge, 128>(); + DynList<edge, 128>& cEdges = *cEdgesPtr_; + + const DynList<point, 64>& pts = *pointsPtr_; + const DynList<edge, 128>& edges = *edgesPtr_; + + newEdgeLabel_.setSize(edges.size()); + newEdgeLabel_ = -1; - forAll(edges, eI) - { - const edge& e = edges[eI]; - const label start = e.start(); - const label end = e.end(); - const label newStartLabel = newVertexLabel_[start]; - const label newEndLabel = newVertexLabel_[end]; - - if( (newStartLabel != -1) && (newEndLabel != -1) ) - { - newEdgeLabel_[eI] = cEdges.size(); - cEdges.append(edge(newStartLabel, newEndLabel)); - } - else if( (newEndLabel != -1) && (vertexTypes_[end] & KEEP) ) - { - //- start edge vertex is not visible, but the other one is - newEdgeLabel_[eI] = cEdges.size(); - cEdges.append(edge(newEndLabel, cPtsPtr_->size())); - - const scalar t = - -vertexDistance_[start] / - (vertexDistance_[end] - vertexDistance_[start]); - - const point newP = (1.0 - t) * pts[start] + t * pts[end]; - cPtsPtr_->append(newP); - } - else if( (newStartLabel != -1) && (vertexTypes_[start] & KEEP) ) - { - //- end edge vertex is not visible, but the other one is - newEdgeLabel_[eI] = cEdges.size(); - cEdges.append(edge(newStartLabel, cPtsPtr_->size())); - - const scalar t = - -vertexDistance_[end] / - (vertexDistance_[start] - vertexDistance_[end]); - - const point newP = (1.0 - t) * pts[end] + t * pts[start]; - cPtsPtr_->append(newP); - } - - # ifdef DEBUGSmooth - if( newEdgeLabel_[eI] != -1 ) - { - Info << nl << "Edge " << eI << "consisting of " << e - << " has been replaced with edge " << newEdgeLabel_[eI] << " " - << cEdges[newEdgeLabel_[eI]] << endl; - } - else - { - Info << "Edge " << e << " has been deleted!" << endl; - } - # endif - } - - #ifdef DEBUGSmooth - Info << "Found " << cEdges.size() << " new edges" << endl; - #endif + forAll(edges, eI) + { + const edge& e = edges[eI]; + const label start = e.start(); + const label end = e.end(); + const label newStartLabel = newVertexLabel_[start]; + const label newEndLabel = newVertexLabel_[end]; + + if( (newStartLabel != -1) && (newEndLabel != -1) ) + { + newEdgeLabel_[eI] = cEdges.size(); + cEdges.append(edge(newStartLabel, newEndLabel)); + } + else if( (newEndLabel != -1) && (vertexTypes_[end] & KEEP) ) + { + //- start edge vertex is not visible, but the other one is + newEdgeLabel_[eI] = cEdges.size(); + cEdges.append(edge(newEndLabel, cPtsPtr_->size())); + + const scalar t = + -vertexDistance_[start] / + (vertexDistance_[end] - vertexDistance_[start]); + + const point newP = (1.0 - t) * pts[start] + t * pts[end]; + cPtsPtr_->append(newP); + } + else if( (newStartLabel != -1) && (vertexTypes_[start] & KEEP) ) + { + //- end edge vertex is not visible, but the other one is + newEdgeLabel_[eI] = cEdges.size(); + cEdges.append(edge(newStartLabel, cPtsPtr_->size())); + + const scalar t = + -vertexDistance_[end] / + (vertexDistance_[start] - vertexDistance_[end]); + + const point newP = (1.0 - t) * pts[end] + t * pts[start]; + cPtsPtr_->append(newP); + } + + # ifdef DEBUGSmooth + if( newEdgeLabel_[eI] != -1 ) + { + Info << nl << "Edge " << eI << "consisting of " << e + << " has been replaced with edge " << newEdgeLabel_[eI] << " " + << cEdges[newEdgeLabel_[eI]] << endl; + } + else + { + Info << "Edge " << e << " has been deleted!" << endl; + } + # endif + } + + #ifdef DEBUGSmooth + Info << "Found " << cEdges.size() << " new edges" << endl; + #endif } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/meshLibrary/utilities/smoothers/geometry/meshOptimizer/tetMeshOptimisation/advancedSmoothers/meshUntangler/meshUntanglerCutRegionFaces.C b/meshLibrary/utilities/smoothers/geometry/meshOptimizer/tetMeshOptimisation/advancedSmoothers/meshUntangler/meshUntanglerCutRegionFaces.C index 6f511a46..871d9a05 100644 --- a/meshLibrary/utilities/smoothers/geometry/meshOptimizer/tetMeshOptimisation/advancedSmoothers/meshUntangler/meshUntanglerCutRegionFaces.C +++ b/meshLibrary/utilities/smoothers/geometry/meshOptimizer/tetMeshOptimisation/advancedSmoothers/meshUntangler/meshUntanglerCutRegionFaces.C @@ -39,178 +39,178 @@ Description namespace Foam { - + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // void meshUntangler::cutRegion::findNewFaces() { - #ifdef DEBUGSmooth - Info << "Finding new faces " << endl; - #endif - - bool finished; - do - { - finished = true; - - const DynList<DynList<label, 8>, 64>& fcs = *facesPtr_; - DynList<edge, 128>& cEdges = *cEdgesPtr_; - - cFacesPtr_ = new DynList<DynList<label, 8>, 64>(); - DynList<DynList<label, 8>, 64>& cFaces = *cFacesPtr_; - - DynList<label, 8> faceInPlane; - - DynList<label, 64> pointUsage; - pointUsage.setSize(cPtsPtr_->size()); - - forAll(fcs, fI) - { - const DynList<label, 8>& f = fcs[fI]; - - # ifdef DEBUGSmooth - Info << "Creating new face from face " << fI - << " consisting of edges " << f << endl; - # endif - - pointUsage = 0; - - DynList<label, 8> newFace(f.size()+1); - - forAll(f, eI) - { - # ifdef DEBUGSmooth - const DynList<edge>& edges = *edgesPtr_; - Info << "Vertex types for face edge " << eI << " are " - << label(vertexTypes_[edges[f[eI]].start()]) << " and " - << label(vertexTypes_[edges[f[eI]].end()]) << endl; - # endif - - const label edgeLabel = newEdgeLabel_[f[eI]]; - - if( edgeLabel != -1 ) - { - # ifdef DEBUGSmooth - Info << "Orig edge " << eI << " " << edges[f[eI]] - << " is replaced with " << cEdges[edgeLabel] << endl; - # endif - - const edge& e = cEdges[edgeLabel]; - ++pointUsage[e[0]]; - ++pointUsage[e[1]]; - newFace.append(edgeLabel); - } - } - - if( newFace.size() > 1 ) - { - DynList<label, 4> newEdge(2); - forAll(pointUsage, pI) - if( pointUsage[pI] == 1 ) - newEdge.append(pI); + #ifdef DEBUGSmooth + Info << "Finding new faces " << endl; + #endif + + bool finished; + do + { + finished = true; + + const DynList<DynList<label, 8>, 64>& fcs = *facesPtr_; + DynList<edge, 128>& cEdges = *cEdgesPtr_; + + cFacesPtr_ = new DynList<DynList<label, 8>, 64>(); + DynList<DynList<label, 8>, 64>& cFaces = *cFacesPtr_; + + DynList<label, 8> faceInPlane; + + DynList<label, 64> pointUsage; + pointUsage.setSize(cPtsPtr_->size()); + + forAll(fcs, fI) + { + const DynList<label, 8>& f = fcs[fI]; + + # ifdef DEBUGSmooth + Info << "Creating new face from face " << fI + << " consisting of edges " << f << endl; + # endif + + pointUsage = 0; + + DynList<label, 8> newFace(f.size()+1); + + forAll(f, eI) + { + # ifdef DEBUGSmooth + const DynList<edge>& edges = *edgesPtr_; + Info << "Vertex types for face edge " << eI << " are " + << label(vertexTypes_[edges[f[eI]].start()]) << " and " + << label(vertexTypes_[edges[f[eI]].end()]) << endl; + # endif + + const label edgeLabel = newEdgeLabel_[f[eI]]; + + if( edgeLabel != -1 ) + { + # ifdef DEBUGSmooth + Info << "Orig edge " << eI << " " << edges[f[eI]] + << " is replaced with " << cEdges[edgeLabel] << endl; + # endif + + const edge& e = cEdges[edgeLabel]; + ++pointUsage[e[0]]; + ++pointUsage[e[1]]; + newFace.append(edgeLabel); + } + } + + if( newFace.size() > 1 ) + { + DynList<label, 4> newEdge(2); + forAll(pointUsage, pI) + if( pointUsage[pI] == 1 ) + newEdge.append(pI); - if( newEdge.size() == 2 ) - { - # ifdef DEBUGSmooth - Info << "Storing new edge " << newEdge << endl; - # endif - - newFace.append(cEdges.size()); - cEdges.append(edge(newEdge[0], newEdge[1])); - } - else if( newEdge.size() > 2 ) - { - # ifdef DEBUGSmooth - Info << "New edge " << newEdge << endl; - # endif - - tieBreak(f); - if( !valid_ ) return; - finished = false; - break; - - FatalErrorIn - ( - "void meshUntangler::cutRegion::findNewFaces()" - ) << "Edge has more than two nodes!" - << abort(FatalError); - } - - cFaces.append(newFace); - } - } - - if( !finished ) continue; - - //- find edges which form the faceInPlane - DynList<label, 128> edgeUsage; - edgeUsage.setSize(cEdges.size()); - edgeUsage = 0; - forAll(cFaces, fI) - { - const DynList<label, 8>& f = cFaces[fI]; - - forAll(f, eI) - ++edgeUsage[f[eI]]; - } - - forAll(edgeUsage, eI) - if( edgeUsage[eI] == 1 ) - faceInPlane.append(eI); - - if( faceInPlane.size() > 2 ) - { - # ifdef DEBUGSmooth - Info << "Adding face in plane " << faceInPlane << endl; - Info << "Face in plane consists of edges " << endl; - forAll(faceInPlane, eI) - Info << "Edge " << eI << " is " - << cEdges[faceInPlane[eI]] << endl; - # endif - - cFaces.append(faceInPlane); - } - - # ifdef DEBUGSmooth - Info << "cEdges " << cEdges << endl; - Info << "Number of faces before cutting " << fcs.size() << endl; - Info << "Found " << cFaces.size() << " new faces" << endl; - forAll(fcs, fI) - { - Info << "Old face " << fI << " contains edges " << fcs[fI] << endl; - } - - forAll(cFaces, fI) - { - Info << "New face " << fI << " contains edges " << cFaces[fI] << endl; - } - - //- test if the region is closed - List<DynList<label, 4> > eFaces(cEdges.size()); - forAll(cFaces, fI) - { - const DynList<label, 8>& f = cFaces[fI]; - forAll(f, eI) - eFaces[f[eI]].append(fI); - } - - if( eFaces.size() > 5 ) - forAll(eFaces, fI) - if( eFaces[fI].size() != 2 ) - { - Info << "eFaces " << eFaces << endl; - Info << "cEdges " << cEdges << endl; - Info << "cFaces " << cFaces << endl; - - FatalErrorIn - ( - "void meshOptimizer::meshUntangler::" - "cutRegion::findNewFaces()" - ) << "Cell is not topologically closed!" << abort(FatalError); - } - # endif - - } while( !finished ); + if( newEdge.size() == 2 ) + { + # ifdef DEBUGSmooth + Info << "Storing new edge " << newEdge << endl; + # endif + + newFace.append(cEdges.size()); + cEdges.append(edge(newEdge[0], newEdge[1])); + } + else if( newEdge.size() > 2 ) + { + # ifdef DEBUGSmooth + Info << "New edge " << newEdge << endl; + # endif + + tieBreak(f); + if( !valid_ ) return; + finished = false; + break; + + FatalErrorIn + ( + "void meshUntangler::cutRegion::findNewFaces()" + ) << "Edge has more than two nodes!" + << abort(FatalError); + } + + cFaces.append(newFace); + } + } + + if( !finished ) continue; + + //- find edges which form the faceInPlane + DynList<label, 128> edgeUsage; + edgeUsage.setSize(cEdges.size()); + edgeUsage = 0; + forAll(cFaces, fI) + { + const DynList<label, 8>& f = cFaces[fI]; + + forAll(f, eI) + ++edgeUsage[f[eI]]; + } + + forAll(edgeUsage, eI) + if( edgeUsage[eI] == 1 ) + faceInPlane.append(eI); + + if( faceInPlane.size() > 2 ) + { + # ifdef DEBUGSmooth + Info << "Adding face in plane " << faceInPlane << endl; + Info << "Face in plane consists of edges " << endl; + forAll(faceInPlane, eI) + Info << "Edge " << eI << " is " + << cEdges[faceInPlane[eI]] << endl; + # endif + + cFaces.append(faceInPlane); + } + + # ifdef DEBUGSmooth + Info << "cEdges " << cEdges << endl; + Info << "Number of faces before cutting " << fcs.size() << endl; + Info << "Found " << cFaces.size() << " new faces" << endl; + forAll(fcs, fI) + { + Info << "Old face " << fI << " contains edges " << fcs[fI] << endl; + } + + forAll(cFaces, fI) + { + Info << "New face " << fI << " contains edges " << cFaces[fI] << endl; + } + + //- test if the region is closed + List<DynList<label, 4> > eFaces(cEdges.size()); + forAll(cFaces, fI) + { + const DynList<label, 8>& f = cFaces[fI]; + forAll(f, eI) + eFaces[f[eI]].append(fI); + } + + if( eFaces.size() > 5 ) + forAll(eFaces, fI) + if( eFaces[fI].size() != 2 ) + { + Info << "eFaces " << eFaces << endl; + Info << "cEdges " << cEdges << endl; + Info << "cFaces " << cFaces << endl; + + FatalErrorIn + ( + "void meshOptimizer::meshUntangler::" + "cutRegion::findNewFaces()" + ) << "Cell is not topologically closed!" << abort(FatalError); + } + # endif + + } while( !finished ); } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/meshLibrary/utilities/smoothers/geometry/meshOptimizer/tetMeshOptimisation/advancedSmoothers/meshUntangler/meshUntanglerCutRegionPoints.C b/meshLibrary/utilities/smoothers/geometry/meshOptimizer/tetMeshOptimisation/advancedSmoothers/meshUntangler/meshUntanglerCutRegionPoints.C index b1a08b8d..4c4a9366 100644 --- a/meshLibrary/utilities/smoothers/geometry/meshOptimizer/tetMeshOptimisation/advancedSmoothers/meshUntangler/meshUntanglerCutRegionPoints.C +++ b/meshLibrary/utilities/smoothers/geometry/meshOptimizer/tetMeshOptimisation/advancedSmoothers/meshUntangler/meshUntanglerCutRegionPoints.C @@ -45,150 +45,150 @@ Description namespace Foam { - + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - + bool meshUntangler::cutRegion::findNewVertices ( - const plane& plane + const plane& plane ) { - #ifdef DEBUGSmooth - Info << "Finding new vertices" << endl; - #endif - - const DynList<point, 64>& points = *pointsPtr_; - - newVertexLabel_.setSize(points.size()); - newVertexLabel_ = -1; - - vertexDistance_.setSize(points.size()); - - vertexTypes_.setSize(points.size()); - vertexTypes_ = direction(NONE); - - origNumVertices_ = 0; - - cPtsPtr_ = new DynList<point, 64>(); - - const point& rp = plane.refPoint(); - const vector& n = plane.normal(); - forAll(points, pI) - { - const point& p = points[pI]; - vertexDistance_[pI] = ((p - rp) & n); - - if( vertexDistance_[pI] > tol_ ) - { - cPtsPtr_->append(p); - newVertexLabel_[pI] = origNumVertices_++; - vertexTypes_[pI] |= KEEP; - } - else if( vertexDistance_[pI] >= -tol_ ) - { - cPtsPtr_->append(p); - newVertexLabel_[pI] = origNumVertices_++; - vertexTypes_[pI] |= INPLANE; - vertexDistance_[pI] = 0.0; - } - } - - #ifdef DEBUGSmooth - Info << "tolerance " << tol_ << endl; - Info << "New number of vertices is " << origNumVertices_ << endl; - forAll(points, pI) - Info << "Original vertex " << pI << " is " << points[pI] - << ". Vertex distance from plane is " << vertexDistance_[pI] - << " and its new label is " << newVertexLabel_[pI] << endl; - #endif - - if( origNumVertices_ < points.size() ) - { - return true; - } - else - { - deleteDemandDrivenData(cPtsPtr_); - - return false; - } + #ifdef DEBUGSmooth + Info << "Finding new vertices" << endl; + #endif + + const DynList<point, 64>& points = *pointsPtr_; + + newVertexLabel_.setSize(points.size()); + newVertexLabel_ = -1; + + vertexDistance_.setSize(points.size()); + + vertexTypes_.setSize(points.size()); + vertexTypes_ = direction(NONE); + + origNumVertices_ = 0; + + cPtsPtr_ = new DynList<point, 64>(); + + const point& rp = plane.refPoint(); + const vector& n = plane.normal(); + forAll(points, pI) + { + const point& p = points[pI]; + vertexDistance_[pI] = ((p - rp) & n); + + if( vertexDistance_[pI] > tol_ ) + { + cPtsPtr_->append(p); + newVertexLabel_[pI] = origNumVertices_++; + vertexTypes_[pI] |= KEEP; + } + else if( vertexDistance_[pI] >= -tol_ ) + { + cPtsPtr_->append(p); + newVertexLabel_[pI] = origNumVertices_++; + vertexTypes_[pI] |= INPLANE; + vertexDistance_[pI] = 0.0; + } + } + + #ifdef DEBUGSmooth + Info << "tolerance " << tol_ << endl; + Info << "New number of vertices is " << origNumVertices_ << endl; + forAll(points, pI) + Info << "Original vertex " << pI << " is " << points[pI] + << ". Vertex distance from plane is " << vertexDistance_[pI] + << " and its new label is " << newVertexLabel_[pI] << endl; + #endif + + if( origNumVertices_ < points.size() ) + { + return true; + } + else + { + deleteDemandDrivenData(cPtsPtr_); + + return false; + } } void meshUntangler::cutRegion::removeCoincidentVertices() { - const DynList<point, 64>& points = *pointsPtr_; - DynList<edge, 128>& edges = *edgesPtr_; - DynList<label, 64> newLabelForPoint; - newLabelForPoint.setSize(points.size()); - newLabelForPoint = -1; - - bool found(false); - forAll(points, pI) - { - if( newLabelForPoint[pI] != -1 ) continue; - for(label pJ=pI+1;pJ<points.size();++pJ) - if( mag(points[pJ] - points[pI]) < tol_ ) - { - # ifdef DEBUGSmooth - Info << "Vertices " << pI << " and " << pJ - << " are too close" << endl; - # endif - - newLabelForPoint[pJ] = pI; - found = true; - } - } - - if( !found ) - return; - - forAll(edges, eI) - { - edge& e = edges[eI]; - if( newLabelForPoint[e.start()] != -1 ) - e.start() = newLabelForPoint[e.start()]; - if( newLabelForPoint[e.end()] != -1 ) - e.end() = newLabelForPoint[e.end()]; - } - - //- remove edges which contain the same vertex - newEdgeLabel_ = -1; - label edgeLabel(0); - - cEdgesPtr_ = new DynList<edge, 128>(); - forAll(edges, eI) - if( edges[eI].start() != edges[eI].end() ) - { - cEdgesPtr_->append(edges[eI]); - newEdgeLabel_[eI] = edgeLabel++; - } - - deleteDemandDrivenData(edgesPtr_); - edgesPtr_ = cEdgesPtr_; - cEdgesPtr_ = NULL; - - //- renumber faces - const DynList<DynList<label, 8>, 64>& faces = *facesPtr_; - cFacesPtr_ = new DynList<DynList<label, 8>, 64>(); - forAll(faces, fI) - { - const DynList<label, 8>& f = faces[fI]; - - DynList<label, 8> nf(f.size()); - - forAll(f, eI) - if( newEdgeLabel_[f[eI]] != -1 ) - nf.append(newEdgeLabel_[f[eI]]); - - if( nf.size() > 2 ) - { - cFacesPtr_->append(nf); - } - } - - deleteDemandDrivenData(facesPtr_); - facesPtr_ = cFacesPtr_; - cFacesPtr_ = NULL; + const DynList<point, 64>& points = *pointsPtr_; + DynList<edge, 128>& edges = *edgesPtr_; + DynList<label, 64> newLabelForPoint; + newLabelForPoint.setSize(points.size()); + newLabelForPoint = -1; + + bool found(false); + forAll(points, pI) + { + if( newLabelForPoint[pI] != -1 ) continue; + for(label pJ=pI+1;pJ<points.size();++pJ) + if( mag(points[pJ] - points[pI]) < tol_ ) + { + # ifdef DEBUGSmooth + Info << "Vertices " << pI << " and " << pJ + << " are too close" << endl; + # endif + + newLabelForPoint[pJ] = pI; + found = true; + } + } + + if( !found ) + return; + + forAll(edges, eI) + { + edge& e = edges[eI]; + if( newLabelForPoint[e.start()] != -1 ) + e.start() = newLabelForPoint[e.start()]; + if( newLabelForPoint[e.end()] != -1 ) + e.end() = newLabelForPoint[e.end()]; + } + + //- remove edges which contain the same vertex + newEdgeLabel_ = -1; + label edgeLabel(0); + + cEdgesPtr_ = new DynList<edge, 128>(); + forAll(edges, eI) + if( edges[eI].start() != edges[eI].end() ) + { + cEdgesPtr_->append(edges[eI]); + newEdgeLabel_[eI] = edgeLabel++; + } + + deleteDemandDrivenData(edgesPtr_); + edgesPtr_ = cEdgesPtr_; + cEdgesPtr_ = NULL; + + //- renumber faces + const DynList<DynList<label, 8>, 64>& faces = *facesPtr_; + cFacesPtr_ = new DynList<DynList<label, 8>, 64>(); + forAll(faces, fI) + { + const DynList<label, 8>& f = faces[fI]; + + DynList<label, 8> nf(f.size()); + + forAll(f, eI) + if( newEdgeLabel_[f[eI]] != -1 ) + nf.append(newEdgeLabel_[f[eI]]); + + if( nf.size() > 2 ) + { + cFacesPtr_->append(nf); + } + } + + deleteDemandDrivenData(facesPtr_); + facesPtr_ = cFacesPtr_; + cFacesPtr_ = NULL; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/meshLibrary/utilities/smoothers/geometry/meshOptimizer/tetMeshOptimisation/advancedSmoothers/meshUntangler/meshUntanglerCutRegionTieBreak.C b/meshLibrary/utilities/smoothers/geometry/meshOptimizer/tetMeshOptimisation/advancedSmoothers/meshUntangler/meshUntanglerCutRegionTieBreak.C index 7ff9e46a..725b23ec 100644 --- a/meshLibrary/utilities/smoothers/geometry/meshOptimizer/tetMeshOptimisation/advancedSmoothers/meshUntangler/meshUntanglerCutRegionTieBreak.C +++ b/meshLibrary/utilities/smoothers/geometry/meshOptimizer/tetMeshOptimisation/advancedSmoothers/meshUntangler/meshUntanglerCutRegionTieBreak.C @@ -36,158 +36,158 @@ Description namespace Foam { - + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // void meshUntangler::cutRegion::tieBreak(const DynList<label, 8>& f) { - // There must be only one, singly connected region which is cut off - // from the feasible region. This may not be the case if one operates in the - // range of computer tolerances. In order to resolve the tie it is necessary - // to find a single region which will be cut off from the feasible region. - // This will be done by finding the node with the most negative distance, - // and then start marking vertices connected to that vertex via an edge. - - # ifdef DEBUGSmooth - Info << "Starting tie break" << endl; - # endif - - //- delete pointer data - deleteDemandDrivenData(cPtsPtr_); - deleteDemandDrivenData(cEdgesPtr_); - deleteDemandDrivenData(cFacesPtr_); - - //- remove coincident vertices - //removeCoincidentVertices(); - - const DynList<edge, 128>& edges = *edgesPtr_; + // There must be only one, singly connected region which is cut off + // from the feasible region. This may not be the case if one operates in the + // range of computer tolerances. In order to resolve the tie it is necessary + // to find a single region which will be cut off from the feasible region. + // This will be done by finding the node with the most negative distance, + // and then start marking vertices connected to that vertex via an edge. + + # ifdef DEBUGSmooth + Info << "Starting tie break" << endl; + # endif + + //- delete pointer data + deleteDemandDrivenData(cPtsPtr_); + deleteDemandDrivenData(cEdgesPtr_); + deleteDemandDrivenData(cFacesPtr_); + + //- remove coincident vertices + //removeCoincidentVertices(); + + const DynList<edge, 128>& edges = *edgesPtr_; - DynList<edge> faceEdges(f.size()); - forAll(f, eI) - faceEdges.append(edges[f[eI]]); - - labelListList fvertices = sortEdgesIntoChains(faceEdges).sortedChains(); - if( fvertices.size() != 1 ) - { - valid_ = false; - return; - - Info << "Face vertices " << fvertices << endl; - FatalErrorIn - ( - "void meshUntangler::cutRegion::tieBreak(const face& f)" - ) << "Number of created faces is not 1 but " - << fvertices.size() << abort(FatalError); - } - - const labelList& fv = fvertices[0]; - - DynList<label, 64> vertexRegion; - vertexRegion.setSize(fv.size()); - vertexRegion = 0; - - label region(1); - forAll(fv, vI) - if( !vertexTypes_[fv[vI]] && !vertexRegion[vI] ) - { - vertexRegion[vI] = region; - - label fcI = fv.fcIndex(vI); - label rcI = fv.rcIndex(vI); - bool found; - do - { - found = false; - if( !vertexTypes_[fv[fcI]] ) - { - vertexRegion[fcI] = region; - fcI = fv.fcIndex(fcI); - found = true; - } - - if( !vertexTypes_[fv[rcI]] ) - { - vertexRegion[rcI] = region; - rcI = fv.rcIndex(rcI); - found = true; - } - } while( found ); - - ++region; - } - - # ifdef DEBUGSmooth - Info << "Tolerance " << tol_ << endl; - Info << "Number of regions " << region-1 << endl; - Info << "Vertex regions " << vertexRegion << endl; - # endif - - if( region > 2 ) - { - //- there are more than two regions which need to be cut off - # ifdef DEBUGSmooth - forAll(fv, vI) - Info << "Distance for vertex " << fv[vI] << " is " - << vertexDistance_[fv[vI]] << endl; - # endif - - //- there should be only one cut-off region - //- there this region will be determined by the most negative - //- distance from plane - scalar minDist(VGREAT); - label minRegion(-1); - forAll(fv, vI) - if( vertexRegion[vI] && (vertexDistance_[fv[vI]] < minDist) ) - { - minDist = vertexDistance_[fv[vI]]; - minRegion = vertexRegion[vI]; - } - - forAll(vertexRegion, vI) - if( vertexRegion[vI] && (vertexRegion[vI] != minRegion) ) - { - vertexTypes_[fv[vI]] |= INPLANE; - } - } - else - { - forAll(fv, vI) - if( - (vertexTypes_[fv[vI]] & INPLANE) && - !vertexRegion[fv.rcIndex(vI)] && - !vertexRegion[fv.fcIndex(vI)] - ) - { - vertexTypes_[fv[vI]] ^= INPLANE; - vertexTypes_[fv[vI]] |= KEEP; - - # ifdef DEBUGSmooth - Info << "Node " << vI << " was INPLANE" << endl; - Info << "New type " << label(vertexTypes_[fv[vI]]) << endl; - # endif - } - } - - # ifdef DEBUGSmooth - forAll(fv, vI) - Info << "Vertex type for vertex " << fv[vI] << " is " - << label(vertexTypes_[fv[vI]]) << endl; - # endif - - //- create new points - const DynList<point, 64>& points = *pointsPtr_; - cPtsPtr_ = new DynList<point, 64>(); - newVertexLabel_ = -1; - origNumVertices_ = 0; - forAll(points, pI) - if( vertexTypes_[pI] ) - { - cPtsPtr_->append(points[pI]); - newVertexLabel_[pI] = origNumVertices_++; - } - - //- find new edges and continue creating faces - findNewEdges(); + DynList<edge> faceEdges(f.size()); + forAll(f, eI) + faceEdges.append(edges[f[eI]]); + + labelListList fvertices = sortEdgesIntoChains(faceEdges).sortedChains(); + if( fvertices.size() != 1 ) + { + valid_ = false; + return; + + Info << "Face vertices " << fvertices << endl; + FatalErrorIn + ( + "void meshUntangler::cutRegion::tieBreak(const face& f)" + ) << "Number of created faces is not 1 but " + << fvertices.size() << abort(FatalError); + } + + const labelList& fv = fvertices[0]; + + DynList<label, 64> vertexRegion; + vertexRegion.setSize(fv.size()); + vertexRegion = 0; + + label region(1); + forAll(fv, vI) + if( !vertexTypes_[fv[vI]] && !vertexRegion[vI] ) + { + vertexRegion[vI] = region; + + label fcI = fv.fcIndex(vI); + label rcI = fv.rcIndex(vI); + bool found; + do + { + found = false; + if( !vertexTypes_[fv[fcI]] ) + { + vertexRegion[fcI] = region; + fcI = fv.fcIndex(fcI); + found = true; + } + + if( !vertexTypes_[fv[rcI]] ) + { + vertexRegion[rcI] = region; + rcI = fv.rcIndex(rcI); + found = true; + } + } while( found ); + + ++region; + } + + # ifdef DEBUGSmooth + Info << "Tolerance " << tol_ << endl; + Info << "Number of regions " << region-1 << endl; + Info << "Vertex regions " << vertexRegion << endl; + # endif + + if( region > 2 ) + { + //- there are more than two regions which need to be cut off + # ifdef DEBUGSmooth + forAll(fv, vI) + Info << "Distance for vertex " << fv[vI] << " is " + << vertexDistance_[fv[vI]] << endl; + # endif + + //- there should be only one cut-off region + //- there this region will be determined by the most negative + //- distance from plane + scalar minDist(VGREAT); + label minRegion(-1); + forAll(fv, vI) + if( vertexRegion[vI] && (vertexDistance_[fv[vI]] < minDist) ) + { + minDist = vertexDistance_[fv[vI]]; + minRegion = vertexRegion[vI]; + } + + forAll(vertexRegion, vI) + if( vertexRegion[vI] && (vertexRegion[vI] != minRegion) ) + { + vertexTypes_[fv[vI]] |= INPLANE; + } + } + else + { + forAll(fv, vI) + if( + (vertexTypes_[fv[vI]] & INPLANE) && + !vertexRegion[fv.rcIndex(vI)] && + !vertexRegion[fv.fcIndex(vI)] + ) + { + vertexTypes_[fv[vI]] ^= INPLANE; + vertexTypes_[fv[vI]] |= KEEP; + + # ifdef DEBUGSmooth + Info << "Node " << vI << " was INPLANE" << endl; + Info << "New type " << label(vertexTypes_[fv[vI]]) << endl; + # endif + } + } + + # ifdef DEBUGSmooth + forAll(fv, vI) + Info << "Vertex type for vertex " << fv[vI] << " is " + << label(vertexTypes_[fv[vI]]) << endl; + # endif + + //- create new points + const DynList<point, 64>& points = *pointsPtr_; + cPtsPtr_ = new DynList<point, 64>(); + newVertexLabel_ = -1; + origNumVertices_ = 0; + forAll(points, pI) + if( vertexTypes_[pI] ) + { + cPtsPtr_->append(points[pI]); + newVertexLabel_[pI] = origNumVertices_++; + } + + //- find new edges and continue creating faces + findNewEdges(); } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/meshLibrary/utilities/smoothers/geometry/meshOptimizer/tetMeshOptimisation/advancedSmoothers/simplexSmoother/simplexSmoother.H b/meshLibrary/utilities/smoothers/geometry/meshOptimizer/tetMeshOptimisation/advancedSmoothers/simplexSmoother/simplexSmoother.H index 3f83381c..fa32b260 100644 --- a/meshLibrary/utilities/smoothers/geometry/meshOptimizer/tetMeshOptimisation/advancedSmoothers/simplexSmoother/simplexSmoother.H +++ b/meshLibrary/utilities/smoothers/geometry/meshOptimizer/tetMeshOptimisation/advancedSmoothers/simplexSmoother/simplexSmoother.H @@ -27,7 +27,7 @@ Class Description Mesh smoothing without any topological changes. The vertex is put into - location which minimises the objective function. + location which minimises the objective function. SourceFiles simplexSmoother.C @@ -53,25 +53,25 @@ class partTetMeshSimplex; /*---------------------------------------------------------------------------*\ Class simplexSmoother Declaration \*---------------------------------------------------------------------------*/ - + //- class for volume optimizer class simplexSmoother { protected: - + // Protected data - //- mesh points - DynList<point, 128>& points_; - - //- list tets around the given vertex - const DynList<partTet, 128>& tets_; - - //- label of the point - const label pointI_; - - //- bound box - boundBox bb_; - + //- mesh points + DynList<point, 128>& points_; + + //- list tets around the given vertex + const DynList<partTet, 128>& tets_; + + //- label of the point + const label pointI_; + + //- bound box + boundBox bb_; + private: // Private member functions @@ -80,19 +80,19 @@ private: //- Disallow default bitwise assignment void operator=(const simplexSmoother&); - - public: - - // Constructor + + public: + + // Constructor //- construct from partTetMeshSimplex simplexSmoother(partTetMeshSimplex& simplex); - - // Destructor - virtual ~simplexSmoother(); - - // Member functions - //- improve the position of the centre node - virtual void optimizeNodePosition(const scalar tol = 0.001) = 0; + + // Destructor + virtual ~simplexSmoother(); + + // Member functions + //- improve the position of the centre node + virtual void optimizeNodePosition(const scalar tol = 0.001) = 0; }; diff --git a/meshLibrary/utilities/smoothers/geometry/meshOptimizer/tetMeshOptimisation/advancedSmoothers/volumeOptimizer/volumeOptimizer.C b/meshLibrary/utilities/smoothers/geometry/meshOptimizer/tetMeshOptimisation/advancedSmoothers/volumeOptimizer/volumeOptimizer.C index 380af374..5737bbeb 100644 --- a/meshLibrary/utilities/smoothers/geometry/meshOptimizer/tetMeshOptimisation/advancedSmoothers/volumeOptimizer/volumeOptimizer.C +++ b/meshLibrary/utilities/smoothers/geometry/meshOptimizer/tetMeshOptimisation/advancedSmoothers/volumeOptimizer/volumeOptimizer.C @@ -49,7 +49,7 @@ volumeOptimizer::volumeOptimizer(partTetMeshSimplex& simplex) volumeOptimizer::~volumeOptimizer() { } - + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // Member functions @@ -60,7 +60,7 @@ void volumeOptimizer::optimizeNodePosition(const scalar tol) point& p = points_[pointI_]; if( !bb_.contains(p) ) - p = 0.5 * (bb_.max() + bb_.min()); + p = 0.5 * (bb_.max() + bb_.min()); const scalar scale = 1.0 / bb_.mag(); forAll(points_, pI) @@ -70,7 +70,7 @@ void volumeOptimizer::optimizeNodePosition(const scalar tol) Info << nl << "Smoothing point " << pointI_ << " with coordinates " << p << endl; scalar Vmina(VGREAT); forAll(tets_, tetI) - Vmina = Foam::min(Vmina, tets_[tetI].mag(points_)); + Vmina = Foam::min(Vmina, tets_[tetI].mag(points_)); Info << "Vmin before " << Vmina << endl; # endif @@ -78,26 +78,26 @@ void volumeOptimizer::optimizeNodePosition(const scalar tol) vector disp(vector::zero); tensor gradGradF; point pOrig; - + scalar funcBefore, funcAfter(evaluateFunc()); bool finished; do { - finished = false; - pOrig = p; - funcBefore = funcAfter; + finished = false; + pOrig = p; + funcBefore = funcAfter; - evaluateGradientsExact(gradF, gradGradF); + evaluateGradientsExact(gradF, gradGradF); - const scalar determinant = Foam::det(gradGradF); - if( determinant > SMALL ) - { - disp = (inv(gradGradF, determinant) & gradF); + const scalar determinant = Foam::det(gradGradF); + if( determinant > SMALL ) + { + disp = (inv(gradGradF, determinant) & gradF); - p -= disp; + p -= disp; - funcAfter = evaluateFunc(); + funcAfter = evaluateFunc(); # ifdef DEBUGSmooth Info << nl << "gradF " << gradF << endl; @@ -111,28 +111,28 @@ void volumeOptimizer::optimizeNodePosition(const scalar tol) scalar relax(0.8); label nLoops(0); - while( funcAfter > funcBefore ) - { - p = pOrig - relax * disp; - relax *= 0.5; - funcAfter = evaluateFunc(); - - if( funcAfter < funcBefore ) - continue; - - if( ++nLoops == 5 ) - { - //- it seems that this direction is wrong, stop the loop - p = pOrig; - disp = vector::zero; - finished = true; - funcAfter = funcBefore; - } - } - + while( funcAfter > funcBefore ) + { + p = pOrig - relax * disp; + relax *= 0.5; + funcAfter = evaluateFunc(); + + if( funcAfter < funcBefore ) + continue; + + if( ++nLoops == 5 ) + { + //- it seems that this direction is wrong, stop the loop + p = pOrig; + disp = vector::zero; + finished = true; + funcAfter = funcBefore; + } + } + if( mag(funcBefore - funcAfter) / funcBefore < tol ) finished = true; - } + } else { //- move in random direction @@ -163,18 +163,18 @@ void volumeOptimizer::optimizeNodePosition(const scalar tol) p += disp; funcAfter = evaluateFunc(); } - } while( (++iter < 10) && !finished ); + } while( (++iter < 10) && !finished ); - # ifdef DEBUGSmooth - scalar Vmin(VGREAT); - forAll(tets_, tetI) + # ifdef DEBUGSmooth + scalar Vmin(VGREAT); + forAll(tets_, tetI) Vmin = Foam::min(Vmin, tets_[tetI].mag(points_)); - - Info << nl << "New coordinates for point " + + Info << nl << "New coordinates for point " << pointI_ << " are " << p << endl; - Info << "Num iterations " << iter << " gradient " << gradF << endl; - Info << "Vmin " << Vmin << endl; - # endif + Info << "Num iterations " << iter << " gradient " << gradF << endl; + Info << "Vmin " << Vmin << endl; + # endif //- scale back to the original size forAll(points_, pI) diff --git a/meshLibrary/utilities/smoothers/geometry/meshOptimizer/tetMeshOptimisation/advancedSmoothers/volumeOptimizer/volumeOptimizer.H b/meshLibrary/utilities/smoothers/geometry/meshOptimizer/tetMeshOptimisation/advancedSmoothers/volumeOptimizer/volumeOptimizer.H index 5fcfbcf1..2bc317df 100644 --- a/meshLibrary/utilities/smoothers/geometry/meshOptimizer/tetMeshOptimisation/advancedSmoothers/volumeOptimizer/volumeOptimizer.H +++ b/meshLibrary/utilities/smoothers/geometry/meshOptimizer/tetMeshOptimisation/advancedSmoothers/volumeOptimizer/volumeOptimizer.H @@ -27,7 +27,7 @@ Class Description Mesh smoothing without any topological changes. The vertex is put into - location which minimises the objective function. + location which minimises the objective function. SourceFiles volumeOptimizer.C @@ -50,34 +50,34 @@ class partTetMeshSimplex; /*---------------------------------------------------------------------------*\ Class volumeOptimizer Declaration \*---------------------------------------------------------------------------*/ - + //- class for volume optimizer class volumeOptimizer : public simplexSmoother { - // Private member functions - //- evaluate functional - scalar evaluateFunc() const; - - //- find appropriate value of K - scalar evaluateStabilisationFactor() const; - - //- evaluate gradients of the functional - void evaluateGradientsExact(vector&, tensor&) const; - - public: - - // Constructor + // Private member functions + //- evaluate functional + scalar evaluateFunc() const; + + //- find appropriate value of K + scalar evaluateStabilisationFactor() const; + + //- evaluate gradients of the functional + void evaluateGradientsExact(vector&, tensor&) const; + + public: + + // Constructor //- construct from partTetMeshSimplex volumeOptimizer(partTetMeshSimplex& simplex); - - // Destructor - ~volumeOptimizer(); - - // Member functions - //- find the best position for the node - void optimizeNodePosition(const scalar tol = 0.001); + + // Destructor + ~volumeOptimizer(); + + // Member functions + //- find the best position for the node + void optimizeNodePosition(const scalar tol = 0.001); }; diff --git a/meshLibrary/utilities/smoothers/geometry/meshOptimizer/tetMeshOptimisation/advancedSmoothers/volumeOptimizer/volumeOptimizerEvaluateGradients.C b/meshLibrary/utilities/smoothers/geometry/meshOptimizer/tetMeshOptimisation/advancedSmoothers/volumeOptimizer/volumeOptimizerEvaluateGradients.C index 77c73ac7..cc12c9a6 100644 --- a/meshLibrary/utilities/smoothers/geometry/meshOptimizer/tetMeshOptimisation/advancedSmoothers/volumeOptimizer/volumeOptimizerEvaluateGradients.C +++ b/meshLibrary/utilities/smoothers/geometry/meshOptimizer/tetMeshOptimisation/advancedSmoothers/volumeOptimizer/volumeOptimizerEvaluateGradients.C @@ -43,152 +43,152 @@ scalar volumeOptimizer::evaluateFunc() const { const scalar K = evaluateStabilisationFactor(); - scalar func(0.0); - - forAll(tets_, tetI) - { - const partTet& pt = tets_[tetI]; - const tetrahedron<point, point> tet - ( - points_[pt.a()], - points_[pt.b()], - points_[pt.c()], - points_[pt.d()] - ); - - const scalar LSqrTri - ( - magSqr(tet.d() - tet.a()) + - magSqr(tet.d() - tet.b()) + - magSqr(tet.d() - tet.c()) - ); - - const scalar Vtri = tet.mag(); + scalar func(0.0); + + forAll(tets_, tetI) + { + const partTet& pt = tets_[tetI]; + const tetrahedron<point, point> tet + ( + points_[pt.a()], + points_[pt.b()], + points_[pt.c()], + points_[pt.d()] + ); + + const scalar LSqrTri + ( + magSqr(tet.d() - tet.a()) + + magSqr(tet.d() - tet.b()) + + magSqr(tet.d() - tet.c()) + ); + + const scalar Vtri = tet.mag(); const scalar Vstab = 0.5 * (Vtri + mag(Vtri)) + K; - - func += LSqrTri / pow(Vstab, 2./3.); - } - - return func; + + func += LSqrTri / pow(Vstab, 2./3.); + } + + return func; } scalar volumeOptimizer::evaluateStabilisationFactor() const { - scalar K = 0.0; - - scalar Vmin(VGREAT), LSqMax(0.0); - - forAll(tets_, tetI) - { - const partTet& pt = tets_[tetI]; - const tetrahedron<point, point> tet - ( - points_[pt.a()], - points_[pt.b()], - points_[pt.c()], - points_[pt.d()] - ); - - const scalar Vtri = tet.mag(); + scalar K = 0.0; + + scalar Vmin(VGREAT), LSqMax(0.0); + + forAll(tets_, tetI) + { + const partTet& pt = tets_[tetI]; + const tetrahedron<point, point> tet + ( + points_[pt.a()], + points_[pt.b()], + points_[pt.c()], + points_[pt.d()] + ); + + const scalar Vtri = tet.mag(); Vmin = Foam::min(Vmin, Vtri); const scalar LSqrTri - ( - magSqr(tet.d() - tet.a()) + - magSqr(tet.d() - tet.b()) + - magSqr(tet.d() - tet.c()) - ); + ( + magSqr(tet.d() - tet.a()) + + magSqr(tet.d() - tet.b()) + + magSqr(tet.d() - tet.c()) + ); LSqMax = Foam::max(LSqMax, LSqrTri); - } - - if( Vmin < SMALL * LSqMax ) + } + + if( Vmin < SMALL * LSqMax ) K = SMALL * LSqMax; - - return K; + + return K; } void volumeOptimizer::evaluateGradientsExact ( - vector& gradF, - tensor& gradGradF + vector& gradF, + tensor& gradGradF ) const { - gradF = vector::zero; - gradGradF = tensor::zero; + gradF = vector::zero; + gradGradF = tensor::zero; const scalar K = evaluateStabilisationFactor(); - - tensor gradGradLsq(tensor::zero); - gradGradLsq.xx() = 6.0; - gradGradLsq.yy() = 6.0; - gradGradLsq.zz() = 6.0; - - const point& p = points_[pointI_]; - - forAll(tets_, tetI) - { - const partTet& pt = tets_[tetI]; - const tetrahedron<point, point> tet - ( - points_[pt.a()], - points_[pt.b()], - points_[pt.c()], - points_[pt.d()] - ); - - const vector B - ( - (1.0/6.0) * - ( - (tet.b() - tet.a()) ^ - (tet.c() - tet.a()) - ) - ); - - //- add this trihedron to the metric - const scalar LSqrTri - ( - magSqr(tet.d() - tet.a()) + - magSqr(tet.d() - tet.b()) + - magSqr(tet.d() - tet.c()) - ); - - const scalar Vtri = tet.mag(); - - //- evaluate gradients - const scalar Vstab = 0.5 * (Vtri + mag(Vtri)) + K; - - if( Vstab < VSMALL ) - { - Info << "Tet " << tet << endl; - Info << "B " << B << endl; - Info << "Vtri " << Vtri << endl; - IOstream::defaultPrecision(20); - Info << "Vstab " << Vstab << endl; - - FatalErrorIn - ( - "void nodeDisplacementVolumeOptimizer()" - ) << "I cannot continue " << exit(FatalError); - } - - const vector gradLsq = 2. * (3. * p - tet.a() - tet.b() - tet.c()); - const vector gradVstab = 0.5 * (B + Foam::sign(Vtri) * B); - - //- calculate the gradients - const scalar Vs = pow(Vstab, 2./3.) + VSMALL; + + tensor gradGradLsq(tensor::zero); + gradGradLsq.xx() = 6.0; + gradGradLsq.yy() = 6.0; + gradGradLsq.zz() = 6.0; + + const point& p = points_[pointI_]; + + forAll(tets_, tetI) + { + const partTet& pt = tets_[tetI]; + const tetrahedron<point, point> tet + ( + points_[pt.a()], + points_[pt.b()], + points_[pt.c()], + points_[pt.d()] + ); + + const vector B + ( + (1.0/6.0) * + ( + (tet.b() - tet.a()) ^ + (tet.c() - tet.a()) + ) + ); + + //- add this trihedron to the metric + const scalar LSqrTri + ( + magSqr(tet.d() - tet.a()) + + magSqr(tet.d() - tet.b()) + + magSqr(tet.d() - tet.c()) + ); + + const scalar Vtri = tet.mag(); + + //- evaluate gradients + const scalar Vstab = 0.5 * (Vtri + mag(Vtri)) + K; + + if( Vstab < VSMALL ) + { + Info << "Tet " << tet << endl; + Info << "B " << B << endl; + Info << "Vtri " << Vtri << endl; + IOstream::defaultPrecision(20); + Info << "Vstab " << Vstab << endl; + + FatalErrorIn + ( + "void nodeDisplacementVolumeOptimizer()" + ) << "I cannot continue " << exit(FatalError); + } + + const vector gradLsq = 2. * (3. * p - tet.a() - tet.b() - tet.c()); + const vector gradVstab = 0.5 * (B + Foam::sign(Vtri) * B); + + //- calculate the gradients + const scalar Vs = pow(Vstab, 2./3.) + VSMALL; const scalar Vs53 = Vs * Vstab + VSMALL; - gradF += (gradLsq / Vs) - (2./3. * LSqrTri * gradVstab / Vs53); - - //- calculate the second gradient - gradGradF += - 10./9. * LSqrTri * (gradVstab * gradVstab) / (Vstab * Vs53 + VSMALL) - - 2./3. * twoSymm(gradLsq * gradVstab) / Vs53 - + gradGradLsq / Vs; - } + gradF += (gradLsq / Vs) - (2./3. * LSqrTri * gradVstab / Vs53); + + //- calculate the second gradient + gradGradF += + 10./9. * LSqrTri * (gradVstab * gradVstab) / (Vstab * Vs53 + VSMALL) + - 2./3. * twoSymm(gradLsq * gradVstab) / Vs53 + + gradGradLsq / Vs; + } } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/meshLibrary/utilities/smoothers/geometry/meshOptimizer/tetMeshOptimisation/tetMeshOptimisation.H b/meshLibrary/utilities/smoothers/geometry/meshOptimizer/tetMeshOptimisation/tetMeshOptimisation.H index 5edc32da..17933c11 100644 --- a/meshLibrary/utilities/smoothers/geometry/meshOptimizer/tetMeshOptimisation/tetMeshOptimisation.H +++ b/meshLibrary/utilities/smoothers/geometry/meshOptimizer/tetMeshOptimisation/tetMeshOptimisation.H @@ -61,7 +61,7 @@ class tetMeshOptimisation { // Private data //- reference to the tet mesh - partTetMesh& tetMesh_; + partTetMesh& tetMesh_; // Private member functions needed for parallel runs //- make sure that all processors have the same points diff --git a/meshLibrary/utilities/smoothers/geometry/meshOptimizer/tetMeshOptimisation/tetMeshOptimisationParallel.C b/meshLibrary/utilities/smoothers/geometry/meshOptimizer/tetMeshOptimisation/tetMeshOptimisationParallel.C index 2a70ed3e..04f48cd5 100644 --- a/meshLibrary/utilities/smoothers/geometry/meshOptimizer/tetMeshOptimisation/tetMeshOptimisationParallel.C +++ b/meshLibrary/utilities/smoothers/geometry/meshOptimizer/tetMeshOptimisation/tetMeshOptimisationParallel.C @@ -50,8 +50,8 @@ void tetMeshOptimisation::unifyNegativePoints(boolList& negativeNode) const const labelListPMG& globalPointLabel = tetMesh_.globalPointLabel(); const VRWGraph& pProcs = tetMesh_.pointAtProcs(); const Map<label>& globalToLocal = tetMesh_.globalToLocalPointAddressing(); - const labelListPMG& pAtParallelBoundaries = - tetMesh_.pointsAtProcessorBoundaries(); + const labelListPMG& pAtParallelBoundaries = + tetMesh_.pointsAtProcessorBoundaries(); std::map<label, labelListPMG> selectedNegativeNodes; forAll(neiProcs, procI) @@ -97,8 +97,8 @@ void tetMeshOptimisation::exchangeData const labelListPMG& globalPointLabel = tetMesh_.globalPointLabel(); const VRWGraph& pProcs = tetMesh_.pointAtProcs(); const Map<label>& globalToLocal = tetMesh_.globalToLocalPointAddressing(); - const labelListPMG& pAtParallelBoundaries = - tetMesh_.pointsAtProcessorBoundaries(); + const labelListPMG& pAtParallelBoundaries = + tetMesh_.pointsAtProcessorBoundaries(); const LongList<point>& points = tetMesh_.points(); const LongList<direction>& smoothVertex = tetMesh_.smoothVertex(); @@ -112,21 +112,21 @@ void tetMeshOptimisation::exchangeData std::make_pair(neiProcs[procI], LongList<parPartTet>()) ); - //- create storage in the m map + //- create storage in the m map m.clear(); - forAll(pAtParallelBoundaries, i) - { - const label pI = pAtParallelBoundaries[i]; - if( !(smoothVertex[pI] & partTetMesh::SMOOTH) ) - continue; + forAll(pAtParallelBoundaries, i) + { + const label pI = pAtParallelBoundaries[i]; + if( !(smoothVertex[pI] & partTetMesh::SMOOTH) ) + continue; if( negativeNodePtr && !(*negativeNodePtr)[pI] ) continue; - - m.insert(std::make_pair(pI, DynList<parPartTet>(12))); - } - - //- store local data into the maps - forAll(tets, tetI) + + m.insert(std::make_pair(pI, DynList<parPartTet>(12))); + } + + //- store local data into the maps + forAll(tets, tetI) { const partTet& tet = tets[tetI]; @@ -284,8 +284,8 @@ void tetMeshOptimisation::unifyCoordinatesParallel std::map<label, labelledPoint> parallelBndPoints; forAll(pAtParallelBoundaries, i) { - const label pI = pAtParallelBoundaries[i]; - + const label pI = pAtParallelBoundaries[i]; + if( !(smoothVertex[pI] & partTetMesh::PARALLELBOUNDARY) ) continue; diff --git a/meshLibrary/utilities/smoothers/geometry/meshSurfaceOptimizer/advancedSurfaceSmoothers/surfaceOptimizer/surfaceOptimizer.C b/meshLibrary/utilities/smoothers/geometry/meshSurfaceOptimizer/advancedSurfaceSmoothers/surfaceOptimizer/surfaceOptimizer.C index f04e3b78..145034ba 100644 --- a/meshLibrary/utilities/smoothers/geometry/meshSurfaceOptimizer/advancedSurfaceSmoothers/surfaceOptimizer/surfaceOptimizer.C +++ b/meshLibrary/utilities/smoothers/geometry/meshSurfaceOptimizer/advancedSurfaceSmoothers/surfaceOptimizer/surfaceOptimizer.C @@ -58,46 +58,46 @@ surfaceOptimizer::~surfaceOptimizer() point surfaceOptimizer::optimizePoint(const scalar tol) { - scalar avgEdge(0.0); - forAll(trias_, triI) - avgEdge += - mag(pts_[trias_[triI][1]] - pts_[trias_[triI][0]]); - avgEdge /= trias_.size(); - - avgEdge *= tol; - - tensor gradGradLt(tensor::zero); - gradGradLt.xx() = 4.0; - gradGradLt.yy() = 4.0; - - point newPoint(vector::zero); - - vector disp; - disp.z() = 0.0; - direction nIterations(0); - do - { - //- find the minimum area - scalar Amin(SMALL); - forAll(trias_, triI) - { - const point& p0 = pts_[trias_[triI][0]]; - const point& p1 = pts_[trias_[triI][1]]; - const point& p2 = pts_[trias_[triI][2]]; - - const scalar Atri = - 0.5 * - ( - (p1.y() - p2.y()) * p0.x() + - (p2.x() - p1.x()) * p0.y() + - (p1.x() * p2.y() - p2.x() * p1.y()) - ); - - if( Atri < Amin ) - Amin = Atri; - } - - //- K is greater than zero in case the stabilisation is needed + scalar avgEdge(0.0); + forAll(trias_, triI) + avgEdge += + mag(pts_[trias_[triI][1]] - pts_[trias_[triI][0]]); + avgEdge /= trias_.size(); + + avgEdge *= tol; + + tensor gradGradLt(tensor::zero); + gradGradLt.xx() = 4.0; + gradGradLt.yy() = 4.0; + + point newPoint(vector::zero); + + vector disp; + disp.z() = 0.0; + direction nIterations(0); + do + { + //- find the minimum area + scalar Amin(SMALL); + forAll(trias_, triI) + { + const point& p0 = pts_[trias_[triI][0]]; + const point& p1 = pts_[trias_[triI][1]]; + const point& p2 = pts_[trias_[triI][2]]; + + const scalar Atri = + 0.5 * + ( + (p1.y() - p2.y()) * p0.x() + + (p2.x() - p1.x()) * p0.y() + + (p1.x() * p2.y() - p2.x() * p1.y()) + ); + + if( Atri < Amin ) + Amin = Atri; + } + + //- K is greater than zero in case the stabilisation is needed scalar K = 0.0; if( Amin < SMALL ) { @@ -105,112 +105,112 @@ point surfaceOptimizer::optimizePoint(const scalar tol) if( sqrt(sqr(Amin) + 4.0 * sqr(K)) < (1.0 + SMALL) * mag(Amin) ) K = max(sqrt(SMALL) * mag(Amin), K); } - //const scalar K = sqrt(SMALL * (SMALL - Amin)); - - # ifdef DEBUGSmooth - Info << "Point " << bpI << " K = " << K << endl; - # endif - - //- start assembling the system - vector gradF(vector::zero); - tensor gradGradF(tensor::zero); - forAll(trias_, triI) - { - const point& p0 = pts_[trias_[triI][0]]; - const point& p1 = pts_[trias_[triI][1]]; - const point& p2 = pts_[trias_[triI][2]]; - - if( magSqr(p1 - p2) < VSMALL ) continue; - - const scalar LSqrTri - ( - magSqr(p0 - p1) + - magSqr(p1 - p2) + - magSqr(p2 - p0) - ); - - const scalar Atri = - 0.5 * - ( - (p1.y() - p2.y()) * p0.x() + - (p2.x() - p1.x()) * p0.y() + - (p1.x() * p2.y() - p2.x() * p1.y()) - ); - - const scalar stab = sqrt(sqr(Atri) + K); - const scalar Astab = 0.5 * (Atri + stab); - const vector B((p1.y() - p2.y()), (p2.x() - p1.x()), 0.0); - const vector gradAstab = 0.5 * (B + (Atri * B) / stab); - const tensor gradGradAstab = - 0.5 * - ( - (B * B) / stab - - (B * B) * sqr(Atri) / pow(stab, 3) - ); - - const vector gradLt(4 * p0 - 2.0 * p1 - 2.0 * p2); - - //- calculate the gradient - gradF += (gradLt * Astab - LSqrTri * gradAstab) / sqr(Astab); - - //- calculate the second gradient - gradGradF += - gradGradLt / Astab - - 2.0 * symm(gradLt * gradAstab) / sqr(Astab) - - LSqrTri * gradGradAstab / sqr(Astab) + - 2.0 * LSqrTri * (gradAstab * gradAstab) / pow(Astab, 3); - } - - if( mag(gradGradF.xx()) < VSMALL ) gradGradF.xx() = VSMALL; - if( mag(gradGradF.yy()) < VSMALL ) gradGradF.yy() = VSMALL; - - matrix2D mat; - mat[0][0] = gradGradF.xx(); - mat[0][1] = gradGradF.xy(); - mat[1][0] = gradGradF.yx(); - mat[1][1] = gradGradF.yy(); - FixedList<scalar, 2> source; - source[0] = gradF.x(); - source[1] = gradF.y(); - - const scalar det = mat.determinant(); - - if( mag(det) < VSMALL ) - { - disp = vector::zero; - } - else - { - disp.x() = mat.solveFirst(source); - disp.y() = mat.solveSecond(source); - - if( mag(disp) > 0.7 * avgEdge ) - { - vector dir = disp / mag(disp); - - disp = dir * 0.7 * avgEdge; - } - } - - # ifdef DEBUGSmooth - Info << "Second gradient " << gradGradF << endl; - Info << "Gradient " << gradF << endl; - Info << "Displacement " << disp << endl; - # endif - - newPoint -= disp; - pts_[trias_[0][0]] = newPoint; - - #ifdef DEBUGSmooth - Info << "New coordinates " << newPoint << endl; - # endif - - } while( (++nIterations < 100) && (mag(disp) > avgEdge) ); - - //- do not move the vertex if the process has not converged - if( nIterations >= 100 ) - newPoint = vector::zero; - + //const scalar K = sqrt(SMALL * (SMALL - Amin)); + + # ifdef DEBUGSmooth + Info << "Point " << bpI << " K = " << K << endl; + # endif + + //- start assembling the system + vector gradF(vector::zero); + tensor gradGradF(tensor::zero); + forAll(trias_, triI) + { + const point& p0 = pts_[trias_[triI][0]]; + const point& p1 = pts_[trias_[triI][1]]; + const point& p2 = pts_[trias_[triI][2]]; + + if( magSqr(p1 - p2) < VSMALL ) continue; + + const scalar LSqrTri + ( + magSqr(p0 - p1) + + magSqr(p1 - p2) + + magSqr(p2 - p0) + ); + + const scalar Atri = + 0.5 * + ( + (p1.y() - p2.y()) * p0.x() + + (p2.x() - p1.x()) * p0.y() + + (p1.x() * p2.y() - p2.x() * p1.y()) + ); + + const scalar stab = sqrt(sqr(Atri) + K); + const scalar Astab = 0.5 * (Atri + stab); + const vector B((p1.y() - p2.y()), (p2.x() - p1.x()), 0.0); + const vector gradAstab = 0.5 * (B + (Atri * B) / stab); + const tensor gradGradAstab = + 0.5 * + ( + (B * B) / stab - + (B * B) * sqr(Atri) / pow(stab, 3) + ); + + const vector gradLt(4 * p0 - 2.0 * p1 - 2.0 * p2); + + //- calculate the gradient + gradF += (gradLt * Astab - LSqrTri * gradAstab) / sqr(Astab); + + //- calculate the second gradient + gradGradF += + gradGradLt / Astab - + 2.0 * symm(gradLt * gradAstab) / sqr(Astab) - + LSqrTri * gradGradAstab / sqr(Astab) + + 2.0 * LSqrTri * (gradAstab * gradAstab) / pow(Astab, 3); + } + + if( mag(gradGradF.xx()) < VSMALL ) gradGradF.xx() = VSMALL; + if( mag(gradGradF.yy()) < VSMALL ) gradGradF.yy() = VSMALL; + + matrix2D mat; + mat[0][0] = gradGradF.xx(); + mat[0][1] = gradGradF.xy(); + mat[1][0] = gradGradF.yx(); + mat[1][1] = gradGradF.yy(); + FixedList<scalar, 2> source; + source[0] = gradF.x(); + source[1] = gradF.y(); + + const scalar det = mat.determinant(); + + if( mag(det) < VSMALL ) + { + disp = vector::zero; + } + else + { + disp.x() = mat.solveFirst(source); + disp.y() = mat.solveSecond(source); + + if( mag(disp) > 0.7 * avgEdge ) + { + vector dir = disp / mag(disp); + + disp = dir * 0.7 * avgEdge; + } + } + + # ifdef DEBUGSmooth + Info << "Second gradient " << gradGradF << endl; + Info << "Gradient " << gradF << endl; + Info << "Displacement " << disp << endl; + # endif + + newPoint -= disp; + pts_[trias_[0][0]] = newPoint; + + #ifdef DEBUGSmooth + Info << "New coordinates " << newPoint << endl; + # endif + + } while( (++nIterations < 100) && (mag(disp) > avgEdge) ); + + //- do not move the vertex if the process has not converged + if( nIterations >= 100 ) + newPoint = vector::zero; + return newPoint; } diff --git a/meshLibrary/utilities/smoothers/geometry/meshSurfaceOptimizer/advancedSurfaceSmoothers/surfaceOptimizer/surfaceOptimizer.H b/meshLibrary/utilities/smoothers/geometry/meshSurfaceOptimizer/advancedSurfaceSmoothers/surfaceOptimizer/surfaceOptimizer.H index c13f5a6e..67efc852 100644 --- a/meshLibrary/utilities/smoothers/geometry/meshSurfaceOptimizer/advancedSurfaceSmoothers/surfaceOptimizer/surfaceOptimizer.H +++ b/meshLibrary/utilities/smoothers/geometry/meshSurfaceOptimizer/advancedSurfaceSmoothers/surfaceOptimizer/surfaceOptimizer.H @@ -52,7 +52,7 @@ namespace Foam class surfaceOptimizer { // Private data - //- reference to the simplex points + //- reference to the simplex points DynList<point>& pts_; //- reference to the triangles forming a simplex @@ -71,7 +71,7 @@ public: //- Construct from transformed points and triangles forming a simplex surfaceOptimizer ( - DynList<point>& pts, + DynList<point>& pts, const DynList<triFace>& trias ); @@ -81,9 +81,9 @@ public: ~surfaceOptimizer(); // Member Functions - - //- optimizes position of a central point in the simplex - point optimizePoint(const scalar tol = 0.1); + + //- optimizes position of a central point in the simplex + point optimizePoint(const scalar tol = 0.1); }; diff --git a/meshLibrary/utilities/smoothers/geometry/meshSurfaceOptimizer/meshSurfaceOptimizer.C b/meshLibrary/utilities/smoothers/geometry/meshSurfaceOptimizer/meshSurfaceOptimizer.C index 9f47e44b..4936d40a 100644 --- a/meshLibrary/utilities/smoothers/geometry/meshSurfaceOptimizer/meshSurfaceOptimizer.C +++ b/meshLibrary/utilities/smoothers/geometry/meshSurfaceOptimizer/meshSurfaceOptimizer.C @@ -39,7 +39,7 @@ Description namespace Foam { - + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // void meshSurfaceOptimizer::classifySurfaceVertices() @@ -50,7 +50,7 @@ void meshSurfaceOptimizer::classifySurfaceVertices() //- set all vertices to partition vertexType_ = PARTITION; - + //- set corners forAllConstIter(labelHashSet, corners, it) vertexType_[it.key()] = CORNER; @@ -79,25 +79,25 @@ void meshSurfaceOptimizer::classifySurfaceVertices() // Construct from mesh surface and octree meshSurfaceOptimizer::meshSurfaceOptimizer ( - meshSurfaceEngine& surface, + meshSurfaceEngine& surface, const meshOctree& octree ) : - surfaceEngine_(surface), + surfaceEngine_(surface), meshOctree_(octree), - vertexType_(surface.boundaryPoints().size()), - trianglesPtr_(NULL), - pointTrianglesPtr_(NULL) + vertexType_(surface.boundaryPoints().size()), + trianglesPtr_(NULL), + pointTrianglesPtr_(NULL) { - classifySurfaceVertices(); + classifySurfaceVertices(); } // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // meshSurfaceOptimizer::~meshSurfaceOptimizer() { - deleteDemandDrivenData(trianglesPtr_); - deleteDemandDrivenData(pointTrianglesPtr_); + deleteDemandDrivenData(trianglesPtr_); + deleteDemandDrivenData(pointTrianglesPtr_); } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/meshLibrary/utilities/smoothers/geometry/meshSurfaceOptimizer/meshSurfaceOptimizer.H b/meshLibrary/utilities/smoothers/geometry/meshSurfaceOptimizer/meshSurfaceOptimizer.H index 23d044c5..87209d9e 100644 --- a/meshLibrary/utilities/smoothers/geometry/meshSurfaceOptimizer/meshSurfaceOptimizer.H +++ b/meshLibrary/utilities/smoothers/geometry/meshSurfaceOptimizer/meshSurfaceOptimizer.H @@ -62,41 +62,41 @@ class plane; class meshSurfaceOptimizer { // Private data - //- reference to the mesh surface - meshSurfaceEngine& surfaceEngine_; - + //- reference to the mesh surface + meshSurfaceEngine& surfaceEngine_; + //- reference to the octree const meshOctree& meshOctree_; - - //- type of surface vertex - List<direction> vertexType_; - - //- form trihedra - mutable LongList<triFace>* trianglesPtr_; - mutable VRWGraph* pointTrianglesPtr_; + + //- type of surface vertex + List<direction> vertexType_; + + //- form trihedra + mutable LongList<triFace>* trianglesPtr_; + mutable VRWGraph* pointTrianglesPtr_; // Private member functions - //- classify surface vertices as PARTITION, EDGE, CORNER - void classifySurfaceVertices(); - - //- calculate surface triangulation - void calculateTrianglesAndAddressing() const; - inline const LongList<triFace>& triangles() const; - inline const VRWGraph& pointTriangles() const; - - //- find vertices which are inverted - label findInvertedVertices(boolList& smoothVertex) const; - - //- transform into a 2D space in plane - inline bool transformIntoPlane - ( - const label bpI, - const plane& pl, - vector& vecX, - vector& vecY, - DynList<point>& pts, - DynList<triFace>& trias - ) const; + //- classify surface vertices as PARTITION, EDGE, CORNER + void classifySurfaceVertices(); + + //- calculate surface triangulation + void calculateTrianglesAndAddressing() const; + inline const LongList<triFace>& triangles() const; + inline const VRWGraph& pointTriangles() const; + + //- find vertices which are inverted + label findInvertedVertices(boolList& smoothVertex) const; + + //- transform into a 2D space in plane + inline bool transformIntoPlane + ( + const label bpI, + const plane& pl, + vector& vecX, + vector& vecY, + DynList<point>& pts, + DynList<triFace>& trias + ) const; //- transform into a 2D space in plane for parallel boundaries inline bool transformIntoPlaneParallel @@ -105,10 +105,10 @@ class meshSurfaceOptimizer const plane& pl, const std::map<label, DynList<parTriFace> >& m, vector& vecX, - vector& vecY, - DynList<point>& pts, - DynList<triFace>& trias - ) const; + vector& vecY, + DynList<point>& pts, + DynList<triFace>& trias + ) const; //- new position of a node after laplacian smoothing //- the position is the average of neighbouring vertex positions @@ -150,7 +150,7 @@ class meshSurfaceOptimizer const label bpI, const bool transformIntoPlane = true ) const; - + //- smooth the node using the laplacian smoother //- new position is the average of the neighbouring vertices void nodeDisplacementLaplacian @@ -167,16 +167,16 @@ class meshSurfaceOptimizer const label bpI, const bool transformIntoPlane = true ) const; - - //- smooth the node using surface optimizer - void nodeDisplacementSurfaceOptimizer - ( - const label bpI, - const scalar tol = 1.0 - ); - - //- smooth edge node - void edgeNodeDisplacement(const label bpI) const; + + //- smooth the node using surface optimizer + void nodeDisplacementSurfaceOptimizer + ( + const label bpI, + const scalar tol = 1.0 + ); + + //- smooth edge node + void edgeNodeDisplacement(const label bpI) const; // Functions needed for parallel runs @@ -219,15 +219,15 @@ class meshSurfaceOptimizer //- Disallow default bitwise assignment void operator=(const meshSurfaceOptimizer&); - - // Enumerators - enum vertexTypes - { - PARTITION = 1, - EDGE = 2, - CORNER = 4, + + // Enumerators + enum vertexTypes + { + PARTITION = 1, + EDGE = 2, + CORNER = 4, PROCBND = 8 - }; + }; public: @@ -236,8 +236,8 @@ public: //- Construct from mesh surface and octree meshSurfaceOptimizer ( - meshSurfaceEngine& surface, - const meshOctree& octree + meshSurfaceEngine& surface, + const meshOctree& octree ); @@ -246,11 +246,11 @@ public: ~meshSurfaceOptimizer(); // Member Functions - //- optimisation before the edges and corners are created - void preOptimizeSurface(); + //- optimisation before the edges and corners are created + void preOptimizeSurface(); - //- optimize boundary nodes after boundary regions are created - void optimizeSurface(const label nIterations = 5); + //- optimize boundary nodes after boundary regions are created + void optimizeSurface(const label nIterations = 5); }; diff --git a/meshLibrary/utilities/smoothers/geometry/meshSurfaceOptimizer/meshSurfaceOptimizerCalculateTrianglesAndAddressing.C b/meshLibrary/utilities/smoothers/geometry/meshSurfaceOptimizer/meshSurfaceOptimizerCalculateTrianglesAndAddressing.C index 96a94164..6b57c9bb 100644 --- a/meshLibrary/utilities/smoothers/geometry/meshSurfaceOptimizer/meshSurfaceOptimizerCalculateTrianglesAndAddressing.C +++ b/meshLibrary/utilities/smoothers/geometry/meshSurfaceOptimizer/meshSurfaceOptimizerCalculateTrianglesAndAddressing.C @@ -41,42 +41,42 @@ namespace Foam void meshSurfaceOptimizer::calculateTrianglesAndAddressing() const { - if( trianglesPtr_ || pointTrianglesPtr_ ) - FatalErrorIn - ( - "void meshSurfaceOptimizer::calculateTrianglesAndAddressing() const" - ) << "Addressing is already calculated!" << abort(FatalError); - - const faceList::subList& bFaces = surfaceEngine_.boundaryFaces(); - const labelList& bp = surfaceEngine_.bp(); - - triFace triangle; //- helper - - pointTrianglesPtr_ = new VRWGraph(surfaceEngine_.boundaryPoints().size()); - VRWGraph& pointTriangles = *pointTrianglesPtr_; - - trianglesPtr_ = new LongList<triFace>(); - LongList<triFace>& triangles = *trianglesPtr_; - - //- start creating triangles - forAll(bFaces, bfI) - { - const face& bf = bFaces[bfI]; - - forAll(bf, pI) - { + if( trianglesPtr_ || pointTrianglesPtr_ ) + FatalErrorIn + ( + "void meshSurfaceOptimizer::calculateTrianglesAndAddressing() const" + ) << "Addressing is already calculated!" << abort(FatalError); + + const faceList::subList& bFaces = surfaceEngine_.boundaryFaces(); + const labelList& bp = surfaceEngine_.bp(); + + triFace triangle; //- helper + + pointTrianglesPtr_ = new VRWGraph(surfaceEngine_.boundaryPoints().size()); + VRWGraph& pointTriangles = *pointTrianglesPtr_; + + trianglesPtr_ = new LongList<triFace>(); + LongList<triFace>& triangles = *trianglesPtr_; + + //- start creating triangles + forAll(bFaces, bfI) + { + const face& bf = bFaces[bfI]; + + forAll(bf, pI) + { const label nTrias = bf.size() - 2; - triangle[0] = bp[bf[pI]]; + triangle[0] = bp[bf[pI]]; for(label i=0;i<nTrias;++i) { triangle[1] = bp[bf[(pI+i+1)%bf.size()]]; triangle[2] = bp[bf[(pI+i+2)%bf.size()]]; - + triangles.append(triangle); } - } - } + } + } //- create point-triangles addressing labelList nTriaAtPoint(pointTriangles.size(), 0); diff --git a/meshLibrary/utilities/smoothers/geometry/meshSurfaceOptimizer/meshSurfaceOptimizerI.H b/meshLibrary/utilities/smoothers/geometry/meshSurfaceOptimizer/meshSurfaceOptimizerI.H index fe9fba11..014cf987 100644 --- a/meshLibrary/utilities/smoothers/geometry/meshSurfaceOptimizer/meshSurfaceOptimizerI.H +++ b/meshLibrary/utilities/smoothers/geometry/meshSurfaceOptimizer/meshSurfaceOptimizerI.H @@ -43,131 +43,131 @@ namespace Foam const LongList<triFace>& meshSurfaceOptimizer::triangles() const { - if( !trianglesPtr_ ) - calculateTrianglesAndAddressing(); - - return *trianglesPtr_; + if( !trianglesPtr_ ) + calculateTrianglesAndAddressing(); + + return *trianglesPtr_; } const VRWGraph& meshSurfaceOptimizer::pointTriangles() const { - if( !pointTrianglesPtr_ ) - calculateTrianglesAndAddressing(); - - return *pointTrianglesPtr_; + if( !pointTrianglesPtr_ ) + calculateTrianglesAndAddressing(); + + return *pointTrianglesPtr_; } inline bool meshSurfaceOptimizer::transformIntoPlane ( - const label bpI, - const plane& pl, - vector& vecX, - vector& vecY, - DynList<point>& pts, - DynList<triFace>& trias + const label bpI, + const plane& pl, + vector& vecX, + vector& vecY, + DynList<point>& pts, + DynList<triFace>& trias ) const { - # ifdef DEBUGSmooth - Info << "Transforming boundary node " << bpI << endl; - # endif - - const pointFieldPMG& points = surfaceEngine_.points(); - const labelList& bPoints = surfaceEngine_.boundaryPoints(); - const VRWGraph& pPoints = surfaceEngine_.pointPoints(); - const LongList<triFace>& triangles = this->triangles(); - const constRow pTriangles = pointTriangles()[bpI]; - - # ifdef DEBUGSmooth - Info << "Triangles containing this node are " << pTriangles << endl; - # endif - - //- create vecX and vecY - const point& p = points[bPoints[bpI]]; - pts.setSize(0); - bool found(false); - forAllRow(pPoints, bpI, pI) - { - const point sp = pl.nearestPoint(points[bPoints[pPoints(bpI, pI)]]); - const scalar d = mag(sp - p); - if( d > VSMALL ) - { - vecX = sp - p; - vecX /= d; - vecY = pl.normal() ^ vecX; - vecY /= mag(vecY); - found = true; - break; - } - } - - if( !found ) - return false; - - # ifdef DEBUGSmooth - Info << "VecX " << vecX << endl; - Info << "vecY " << vecY << endl; - # endif - - //- transform the vertices - label counter(0); - Map<label> pointMapping; - trias.setSize(pTriangles.size()); - forAll(pTriangles, triI) - { - const triFace& tri = triangles[pTriangles[triI]]; - - forAll(tri, pI) - { - Map<label>::iterator fnd = pointMapping.find(tri[pI]); - if( fnd != pointMapping.end() ) - { - trias[triI][pI] = fnd(); - } - else - { - point pt - ( - ((points[bPoints[tri[pI]]] - p) & vecX), - ((points[bPoints[tri[pI]]] - p) & vecY), - 0.0 - ); + # ifdef DEBUGSmooth + Info << "Transforming boundary node " << bpI << endl; + # endif + + const pointFieldPMG& points = surfaceEngine_.points(); + const labelList& bPoints = surfaceEngine_.boundaryPoints(); + const VRWGraph& pPoints = surfaceEngine_.pointPoints(); + const LongList<triFace>& triangles = this->triangles(); + const constRow pTriangles = pointTriangles()[bpI]; + + # ifdef DEBUGSmooth + Info << "Triangles containing this node are " << pTriangles << endl; + # endif + + //- create vecX and vecY + const point& p = points[bPoints[bpI]]; + pts.setSize(0); + bool found(false); + forAllRow(pPoints, bpI, pI) + { + const point sp = pl.nearestPoint(points[bPoints[pPoints(bpI, pI)]]); + const scalar d = mag(sp - p); + if( d > VSMALL ) + { + vecX = sp - p; + vecX /= d; + vecY = pl.normal() ^ vecX; + vecY /= mag(vecY); + found = true; + break; + } + } + + if( !found ) + return false; + + # ifdef DEBUGSmooth + Info << "VecX " << vecX << endl; + Info << "vecY " << vecY << endl; + # endif + + //- transform the vertices + label counter(0); + Map<label> pointMapping; + trias.setSize(pTriangles.size()); + forAll(pTriangles, triI) + { + const triFace& tri = triangles[pTriangles[triI]]; + + forAll(tri, pI) + { + Map<label>::iterator fnd = pointMapping.find(tri[pI]); + if( fnd != pointMapping.end() ) + { + trias[triI][pI] = fnd(); + } + else + { + point pt + ( + ((points[bPoints[tri[pI]]] - p) & vecX), + ((points[bPoints[tri[pI]]] - p) & vecY), + 0.0 + ); - pts.append(pt); - trias[triI][pI] = counter; - pointMapping.insert(tri[pI], counter); - ++counter; - } - } - } - - # ifdef DEBUGSmooth - Info << "Original triangles " << endl; - forAll(pTriangles, triI) - Info << "Tri " << triI << " is " << triangles[pTriangles[triI]] << endl; - Info << "Transformed triangles are " << trias << endl; - Info << "Transformed vertices " << pts << endl; - # endif - - return found; + pts.append(pt); + trias[triI][pI] = counter; + pointMapping.insert(tri[pI], counter); + ++counter; + } + } + } + + # ifdef DEBUGSmooth + Info << "Original triangles " << endl; + forAll(pTriangles, triI) + Info << "Tri " << triI << " is " << triangles[pTriangles[triI]] << endl; + Info << "Transformed triangles are " << trias << endl; + Info << "Transformed vertices " << pts << endl; + # endif + + return found; } inline bool meshSurfaceOptimizer::transformIntoPlaneParallel ( - const label bpI, - const plane& pl, + const label bpI, + const plane& pl, const std::map<label, DynList<parTriFace> >& m, - vector& vecX, - vector& vecY, - DynList<point>& pts, - DynList<triFace>& trias + vector& vecX, + vector& vecY, + DynList<point>& pts, + DynList<triFace>& trias ) const { - # ifdef DEBUGSmooth - Info << "Transforming boundary node " << bpI << endl; - # endif - - const pointFieldPMG& points = surfaceEngine_.points(); - const labelList& bPoints = surfaceEngine_.boundaryPoints(); + # ifdef DEBUGSmooth + Info << "Transforming boundary node " << bpI << endl; + # endif + + const pointFieldPMG& points = surfaceEngine_.points(); + const labelList& bPoints = surfaceEngine_.boundaryPoints(); const labelList& globalPointLabel = surfaceEngine_.globalBoundaryPointLabel(); @@ -176,16 +176,16 @@ inline bool meshSurfaceOptimizer::transformIntoPlaneParallel pIter = m.find(globalPointLabel[bpI]); const DynList<parTriFace>& pFcs = pIter->second; - # ifdef DEBUGSmooth + # ifdef DEBUGSmooth if( globalPointLabel[bpI] != pFcs[0].globalLabelOfPoint(0) ) FatalError << "Wrong points supplied!" << abort(FatalError); - Info << "Triangles containing this node are " << pFcs << endl; - # endif - - //- create vecX and vecY - const point& p = points[bPoints[bpI]]; - pts.setSize(0); - bool found(false); + Info << "Triangles containing this node are " << pFcs << endl; + # endif + + //- create vecX and vecY + const point& p = points[bPoints[bpI]]; + pts.setSize(0); + bool found(false); forAll(pFcs, tI) { @@ -201,19 +201,19 @@ inline bool meshSurfaceOptimizer::transformIntoPlaneParallel break; } } - - if( !found ) - return false; - - # ifdef DEBUGSmooth - Info << "VecX " << vecX << endl; - Info << "vecY " << vecY << endl; - # endif - - //- transform the vertices - label counter(0); - Map<label> pointMapping; - trias.setSize(pFcs.size()); + + if( !found ) + return false; + + # ifdef DEBUGSmooth + Info << "VecX " << vecX << endl; + Info << "vecY " << vecY << endl; + # endif + + //- transform the vertices + label counter(0); + Map<label> pointMapping; + trias.setSize(pFcs.size()); //- tranfer triangle from other proc first forAll(pFcs, triI) @@ -221,16 +221,16 @@ inline bool meshSurfaceOptimizer::transformIntoPlaneParallel const parTriFace& tri = pFcs[triI]; for(label pI=0;pI<3;++pI) - { - Map<label>::iterator fnd = + { + Map<label>::iterator fnd = pointMapping.find(tri.globalLabelOfPoint(pI)); - if( fnd != pointMapping.end() ) - { - trias[triI][pI] = fnd(); - } - else - { + if( fnd != pointMapping.end() ) + { + trias[triI][pI] = fnd(); + } + else + { point tp; if( pI == 0 ) { @@ -245,22 +245,22 @@ inline bool meshSurfaceOptimizer::transformIntoPlaneParallel tp = tri.trianglePoints().c(); } - point pt - ( - ((tp - p) & vecX), - ((tp - p) & vecY), - 0.0 - ); + point pt + ( + ((tp - p) & vecX), + ((tp - p) & vecY), + 0.0 + ); - pts.append(pt); - trias[triI][pI] = counter; - pointMapping.insert(tri.globalLabelOfPoint(pI), counter); - ++counter; - } - } + pts.append(pt); + trias[triI][pI] = counter; + pointMapping.insert(tri.globalLabelOfPoint(pI), counter); + ++counter; + } + } } - - return found; + + return found; } inline point meshSurfaceOptimizer::newPositionLaplacian @@ -271,16 +271,16 @@ inline point meshSurfaceOptimizer::newPositionLaplacian { const VRWGraph& pPoints = surfaceEngine_.pointPoints(); const pointFieldPMG& points = surfaceEngine_.points(); - const labelList& bPoints = surfaceEngine_.boundaryPoints(); + const labelList& bPoints = surfaceEngine_.boundaryPoints(); vector newP(vector::zero); if( transformIntoPlane ) { const vector& pNormal = surfaceEngine_.pointNormals()[bpI]; - + if( magSqr(pNormal) < VSMALL ) return points[bPoints[bpI]]; - + plane pl(points[bPoints[bpI]], pNormal); DynList<point> projectedPoints; @@ -314,7 +314,7 @@ inline point meshSurfaceOptimizer::newPositionLaplacianFC const VRWGraph& pointFaces = surfaceEngine_.pointFaces(); const pointFieldPMG& points = surfaceEngine_.points(); const vectorField& faceCentres = surfaceEngine_.faceCentres(); - const labelList& bPoints = surfaceEngine_.boundaryPoints(); + const labelList& bPoints = surfaceEngine_.boundaryPoints(); vector newP(vector::zero); @@ -359,7 +359,7 @@ inline point meshSurfaceOptimizer::newPositionLaplacianWFC const pointFieldPMG& points = surfaceEngine_.points(); const vectorField& faceAreas = surfaceEngine_.faceNormals(); const vectorField& faceCentres = surfaceEngine_.faceCentres(); - const labelList& bPoints = surfaceEngine_.boundaryPoints(); + const labelList& bPoints = surfaceEngine_.boundaryPoints(); vector newP(vector::zero); @@ -414,40 +414,40 @@ inline point meshSurfaceOptimizer::newPositionSurfaceOptimizer ) const { const pointFieldPMG& points = surfaceEngine_.points(); - const labelList& bPoints = surfaceEngine_.boundaryPoints(); - - # ifdef DEBUGSmooth - Info << "Smoothing boundary node " << bpI << endl; - Info << "Node label in the mesh is " << bPoints[bpI] << endl; - Info << "Point coordinates " << points[bPoints[bpI]] << endl; - # endif - - //- project vertices onto the plane - const vector& pNormal = surfaceEngine_.pointNormals()[bpI]; - if( magSqr(pNormal) < VSMALL ) - return points[bPoints[bpI]]; - - const plane pl(points[bPoints[bpI]], pNormal); - - DynList<point> pts; - DynList<triFace> trias; - vector vecX, vecY; + const labelList& bPoints = surfaceEngine_.boundaryPoints(); + + # ifdef DEBUGSmooth + Info << "Smoothing boundary node " << bpI << endl; + Info << "Node label in the mesh is " << bPoints[bpI] << endl; + Info << "Point coordinates " << points[bPoints[bpI]] << endl; + # endif + + //- project vertices onto the plane + const vector& pNormal = surfaceEngine_.pointNormals()[bpI]; + if( magSqr(pNormal) < VSMALL ) + return points[bPoints[bpI]]; + + const plane pl(points[bPoints[bpI]], pNormal); + + DynList<point> pts; + DynList<triFace> trias; + vector vecX, vecY; bool success = this->transformIntoPlane(bpI, pl, vecX, vecY, pts, trias); - if( !success ) - { - Warning << "Cannot transform in plane" << endl; - return points[bPoints[bpI]]; - } + if( !success ) + { + Warning << "Cannot transform in plane" << endl; + return points[bPoints[bpI]]; + } surfaceOptimizer so(pts, trias); const point newPoint = so.optimizePoint(tol); - const point newP - ( - points[bPoints[bpI]] + - vecX * newPoint.x() + - vecY * newPoint.y() - ); + const point newP + ( + points[bPoints[bpI]] + + vecX * newPoint.x() + + vecY * newPoint.y() + ); return newP; } @@ -459,36 +459,36 @@ inline point meshSurfaceOptimizer::newEdgePositionLaplacian ) const { const VRWGraph& pPoints = surfaceEngine_.pointPoints(); - const labelList& bPoints = surfaceEngine_.boundaryPoints(); - const VRWGraph& pFaces = surfaceEngine_.pointFaces(); - const labelList& facePatch = surfaceEngine_.boundaryFacePatches(); - const pointFieldPMG& points = surfaceEngine_.points(); - - DynList<label> edgePoints(2); - forAllRow(pPoints, bpI, neiI) - if( - (vertexType_[pPoints(bpI, neiI)] & EDGE) || - (vertexType_[pPoints(bpI, neiI)] & CORNER) - ) - edgePoints.append(bPoints[pPoints(bpI, neiI)]); + const labelList& bPoints = surfaceEngine_.boundaryPoints(); + const VRWGraph& pFaces = surfaceEngine_.pointFaces(); + const labelList& facePatch = surfaceEngine_.boundaryFacePatches(); + const pointFieldPMG& points = surfaceEngine_.points(); + + DynList<label> edgePoints(2); + forAllRow(pPoints, bpI, neiI) + if( + (vertexType_[pPoints(bpI, neiI)] & EDGE) || + (vertexType_[pPoints(bpI, neiI)] & CORNER) + ) + edgePoints.append(bPoints[pPoints(bpI, neiI)]); if( edgePoints.size() < 2 ) return points[bPoints[bpI]]; - - DynList<label> pointPatches(2); - forAllRow(pFaces, bpI, pfI) - pointPatches.appendIfNotIn(facePatch[pFaces(bpI, pfI)]); - - # ifdef DEBUGSearch - Info << "Edge points " << edgePoints << endl; - Info << "pointPatches " << pointPatches << endl; - # endif - - vector pos(vector::zero); - forAll(edgePoints, epI) - pos += points[edgePoints[epI]]; - - pos /= edgePoints.size(); + + DynList<label> pointPatches(2); + forAllRow(pFaces, bpI, pfI) + pointPatches.appendIfNotIn(facePatch[pFaces(bpI, pfI)]); + + # ifdef DEBUGSearch + Info << "Edge points " << edgePoints << endl; + Info << "pointPatches " << pointPatches << endl; + # endif + + vector pos(vector::zero); + forAll(edgePoints, epI) + pos += points[edgePoints[epI]]; + + pos /= edgePoints.size(); return pos; } diff --git a/meshLibrary/utilities/smoothers/geometry/meshSurfaceOptimizer/meshSurfaceOptimizerOptimizePoint.C b/meshLibrary/utilities/smoothers/geometry/meshSurfaceOptimizer/meshSurfaceOptimizerOptimizePoint.C index 0db4c17f..0e5924e7 100644 --- a/meshLibrary/utilities/smoothers/geometry/meshSurfaceOptimizer/meshSurfaceOptimizerOptimizePoint.C +++ b/meshLibrary/utilities/smoothers/geometry/meshSurfaceOptimizer/meshSurfaceOptimizerOptimizePoint.C @@ -51,7 +51,7 @@ void meshSurfaceOptimizer::nodeDisplacementLaplacian { const point newP = newPositionLaplacian(bpI, transformIntoPlane); - meshSurfaceEngineModifier surfaceModifier(surfaceEngine_); + meshSurfaceEngineModifier surfaceModifier(surfaceEngine_); surfaceModifier.moveBoundaryVertex(bpI, newP); } @@ -63,62 +63,62 @@ void meshSurfaceOptimizer::nodeDisplacementLaplacianFC { const point newP = newPositionLaplacianFC(bpI, transformIntoPlane); - meshSurfaceEngineModifier surfaceModifier(surfaceEngine_); + meshSurfaceEngineModifier surfaceModifier(surfaceEngine_); surfaceModifier.moveBoundaryVertex(bpI, newP); } void meshSurfaceOptimizer::nodeDisplacementSurfaceOptimizer ( - const label bpI, - const scalar tol + const label bpI, + const scalar tol ) { - const pointFieldPMG& points = surfaceEngine_.points(); - const labelList& bPoints = surfaceEngine_.boundaryPoints(); - - # ifdef DEBUGSmooth - Info << "Smoothing boundary node " << bpI << endl; - Info << "Node label in the mesh is " << bPoints[bpI] << endl; - Info << "Point coordinates " << points[bPoints[bpI]] << endl; - # endif - - //- project vertices onto the plane - const vector& pNormal = surfaceEngine_.pointNormals()[bpI]; - if( magSqr(pNormal) < VSMALL ) - return; - - const plane pl(points[bPoints[bpI]], pNormal); - - DynList<point> pts; - DynList<triFace> trias; - vector vecX, vecY; - if( !transformIntoPlane(bpI, pl, vecX, vecY, pts, trias) ) - { - Warning << "Cannot transform in plane" << endl; - return; - } + const pointFieldPMG& points = surfaceEngine_.points(); + const labelList& bPoints = surfaceEngine_.boundaryPoints(); + + # ifdef DEBUGSmooth + Info << "Smoothing boundary node " << bpI << endl; + Info << "Node label in the mesh is " << bPoints[bpI] << endl; + Info << "Point coordinates " << points[bPoints[bpI]] << endl; + # endif + + //- project vertices onto the plane + const vector& pNormal = surfaceEngine_.pointNormals()[bpI]; + if( magSqr(pNormal) < VSMALL ) + return; + + const plane pl(points[bPoints[bpI]], pNormal); + + DynList<point> pts; + DynList<triFace> trias; + vector vecX, vecY; + if( !transformIntoPlane(bpI, pl, vecX, vecY, pts, trias) ) + { + Warning << "Cannot transform in plane" << endl; + return; + } surfaceOptimizer so(pts, trias); point newPoint = so.optimizePoint(tol); - const point newP - ( - points[bPoints[bpI]] + - vecX * newPoint.x() + - vecY * newPoint.y() - ); - - meshSurfaceEngineModifier sm(surfaceEngine_); - sm.moveBoundaryVertex(bpI, newP); + const point newP + ( + points[bPoints[bpI]] + + vecX * newPoint.x() + + vecY * newPoint.y() + ); + + meshSurfaceEngineModifier sm(surfaceEngine_); + sm.moveBoundaryVertex(bpI, newP); } void meshSurfaceOptimizer::edgeNodeDisplacement(const label bpI) const { const pointFieldPMG& points = surfaceEngine_.points(); - const labelList& bPoints = surfaceEngine_.boundaryPoints(); + const labelList& bPoints = surfaceEngine_.boundaryPoints(); - const point pos = newEdgePositionLaplacian(bpI); - const point newP = 0.5 * (pos + points[bPoints[bpI]]); + const point pos = newEdgePositionLaplacian(bpI); + const point newP = 0.5 * (pos + points[bPoints[bpI]]); # ifdef DEBUGSearch Info << "New position for point is " << newP << endl; diff --git a/meshLibrary/utilities/smoothers/geometry/meshSurfaceOptimizer/meshSurfaceOptimizerOptimizePointParallel.C b/meshLibrary/utilities/smoothers/geometry/meshSurfaceOptimizer/meshSurfaceOptimizerOptimizePointParallel.C index 7b52a433..f6fe3a43 100644 --- a/meshLibrary/utilities/smoothers/geometry/meshSurfaceOptimizer/meshSurfaceOptimizerOptimizePointParallel.C +++ b/meshLibrary/utilities/smoothers/geometry/meshSurfaceOptimizer/meshSurfaceOptimizerOptimizePointParallel.C @@ -55,22 +55,22 @@ void meshSurfaceOptimizer::nodeDisplacementLaplacianParallel //- update vertex normals meshSurfaceEngineModifier(surfaceEngine_).updateVertexNormals(); - - //- create storage for data - std::map<label, labelledPoint> localData; - + + //- create storage for data + std::map<label, labelledPoint> localData; + //- exchange data with other processors std::map<label, LongList<refLabelledPoint> > exchangeData; const pointField& points = surfaceEngine_.points(); const labelList& bPoints = surfaceEngine_.boundaryPoints(); - const VRWGraph& pPoints = surfaceEngine_.pointPoints(); + const VRWGraph& pPoints = surfaceEngine_.pointPoints(); const vectorField& pNormals = surfaceEngine_.pointNormals(); const labelList& globalPointLabel = surfaceEngine_.globalBoundaryPointLabel(); - const VRWGraph& bpAtProcs = surfaceEngine_.bpAtProcs(); - const Map<label>& globalToLocal = - surfaceEngine_.globalToLocalBndPointAddressing(); + const VRWGraph& bpAtProcs = surfaceEngine_.bpAtProcs(); + const Map<label>& globalToLocal = + surfaceEngine_.globalToLocalBndPointAddressing(); //- perform smoothing forAll(nodesToSmooth, pI) @@ -83,33 +83,33 @@ void meshSurfaceOptimizer::nodeDisplacementLaplacianParallel const plane pl(points[bPoints[bpI]], pNormals[bpI]); //- project points onto the plane - localData.insert(std::make_pair(bpI, labelledPoint(0, vector::zero))); - labelledPoint& lpd = localData[bpI]; - - forAllRow(pPoints, bpI, ppI) - { - const label nei = pPoints(bpI, ppI); - - if( bpAtProcs.sizeOfRow(nei) != 0 ) - { - label pMin(Pstream::nProcs()); - forAllRow(bpAtProcs, nei, procI) - { - const label procJ = bpAtProcs(nei, procI); - if( (procJ < pMin) && bpAtProcs.contains(bpI, procJ) ) - pMin = procJ; - } - - if( pMin != Pstream::myProcNo() ) - continue; - } - - const point& p = points[bPoints[nei]]; - ++lpd.pointLabel(); - lpd.coordinates() += transformIntoPlane?pl.nearestPoint(p):p; + localData.insert(std::make_pair(bpI, labelledPoint(0, vector::zero))); + labelledPoint& lpd = localData[bpI]; + + forAllRow(pPoints, bpI, ppI) + { + const label nei = pPoints(bpI, ppI); + + if( bpAtProcs.sizeOfRow(nei) != 0 ) + { + label pMin(Pstream::nProcs()); + forAllRow(bpAtProcs, nei, procI) + { + const label procJ = bpAtProcs(nei, procI); + if( (procJ < pMin) && bpAtProcs.contains(bpI, procJ) ) + pMin = procJ; + } + + if( pMin != Pstream::myProcNo() ) + continue; + } + + const point& p = points[bPoints[nei]]; + ++lpd.pointLabel(); + lpd.coordinates() += transformIntoPlane?pl.nearestPoint(p):p; } - - forAllRow(bpAtProcs, bpI, procI) + + forAllRow(bpAtProcs, bpI, procI) { const label neiProc = bpAtProcs(bpI, procI); if( neiProc == Pstream::myProcNo() ) @@ -124,12 +124,12 @@ void meshSurfaceOptimizer::nodeDisplacementLaplacianParallel } //- add data to the list which will be sent to other processor - LongList<refLabelledPoint>& dts = exchangeData[neiProc]; - dts.append(refLabelledPoint(globalPointLabel[bpI], lpd)); + LongList<refLabelledPoint>& dts = exchangeData[neiProc]; + dts.append(refLabelledPoint(globalPointLabel[bpI], lpd)); } - } - - //- exchange data with other processors + } + + //- exchange data with other processors LongList<refLabelledPoint> receivedData; help::exchangeMap(exchangeData, receivedData); @@ -144,16 +144,16 @@ void meshSurfaceOptimizer::nodeDisplacementLaplacianParallel lpd.coordinates() += lp.lPoint().coordinates(); } - forAll(nodesToSmooth, pI) - { - const label bpI = nodesToSmooth[pI]; - - if( localData.find(bpI) == localData.end() ) - continue; - + forAll(nodesToSmooth, pI) + { + const label bpI = nodesToSmooth[pI]; + + if( localData.find(bpI) == localData.end() ) + continue; + //- create new point position const labelledPoint& lp = localData[bpI]; - const point newP = lp.coordinates() / lp.pointLabel(); + const point newP = lp.coordinates() / lp.pointLabel(); meshSurfaceEngineModifier surfaceModifier(surfaceEngine_); surfaceModifier.moveBoundaryVertex @@ -178,24 +178,24 @@ void meshSurfaceOptimizer::nodeDisplacementLaplacianFCParallel //- update vertex normals meshSurfaceEngineModifier(surfaceEngine_).updateVertexNormals(); - - //- create storage for data - std::map<label, labelledPoint> localData; - + + //- create storage for data + std::map<label, labelledPoint> localData; + //- exchange data with other processors std::map<label, LongList<refLabelledPoint> > exchangeData; const pointField& points = surfaceEngine_.points(); const labelList& bPoints = surfaceEngine_.boundaryPoints(); - const VRWGraph& pFaces = surfaceEngine_.pointFaces(); + const VRWGraph& pFaces = surfaceEngine_.pointFaces(); const vectorField& faceCentres = surfaceEngine_.faceCentres(); const vectorField& pNormals = surfaceEngine_.pointNormals(); const labelList& globalPointLabel = surfaceEngine_.globalBoundaryPointLabel(); - const VRWGraph& bpAtProcs = surfaceEngine_.bpAtProcs(); - const Map<label>& globalToLocal = - surfaceEngine_.globalToLocalBndPointAddressing(); + const VRWGraph& bpAtProcs = surfaceEngine_.bpAtProcs(); + const Map<label>& globalToLocal = + surfaceEngine_.globalToLocalBndPointAddressing(); //- perform smoothing forAll(nodesToSmooth, pI) @@ -208,17 +208,17 @@ void meshSurfaceOptimizer::nodeDisplacementLaplacianFCParallel const plane pl(points[bPoints[bpI]], pNormals[bpI]); //- project points onto the plane - localData.insert(std::make_pair(bpI, labelledPoint(0, vector::zero))); - labelledPoint& lpd = localData[bpI]; - - forAllRow(pFaces, bpI, pfI) - { - const point& p = faceCentres[pFaces(bpI, pfI)]; - ++lpd.pointLabel(); - lpd.coordinates() += transformIntoPlane?pl.nearestPoint(p):p; + localData.insert(std::make_pair(bpI, labelledPoint(0, vector::zero))); + labelledPoint& lpd = localData[bpI]; + + forAllRow(pFaces, bpI, pfI) + { + const point& p = faceCentres[pFaces(bpI, pfI)]; + ++lpd.pointLabel(); + lpd.coordinates() += transformIntoPlane?pl.nearestPoint(p):p; } - - forAllRow(bpAtProcs, bpI, procI) + + forAllRow(bpAtProcs, bpI, procI) { const label neiProc = bpAtProcs(bpI, procI); if( neiProc == Pstream::myProcNo() ) @@ -233,12 +233,12 @@ void meshSurfaceOptimizer::nodeDisplacementLaplacianFCParallel } //- add data to the list which will be sent to other processor - LongList<refLabelledPoint>& dts = exchangeData[neiProc]; - dts.append(refLabelledPoint(globalPointLabel[bpI], lpd)); + LongList<refLabelledPoint>& dts = exchangeData[neiProc]; + dts.append(refLabelledPoint(globalPointLabel[bpI], lpd)); } - } - - //- exchange data with other processors + } + + //- exchange data with other processors LongList<refLabelledPoint> receivedData; help::exchangeMap(exchangeData, receivedData); @@ -253,16 +253,16 @@ void meshSurfaceOptimizer::nodeDisplacementLaplacianFCParallel lpd.coordinates() += lp.lPoint().coordinates(); } - forAll(nodesToSmooth, pI) - { - const label bpI = nodesToSmooth[pI]; - - if( localData.find(bpI) == localData.end() ) - continue; - + forAll(nodesToSmooth, pI) + { + const label bpI = nodesToSmooth[pI]; + + if( localData.find(bpI) == localData.end() ) + continue; + //- create new point position const labelledPoint& lp = localData[bpI]; - const point newP = lp.coordinates() / lp.pointLabel(); + const point newP = lp.coordinates() / lp.pointLabel(); meshSurfaceEngineModifier surfaceModifier(surfaceEngine_); surfaceModifier.moveBoundaryVertex diff --git a/meshLibrary/utilities/smoothers/geometry/meshSurfaceOptimizer/meshSurfaceOptimizerOptimizeSurface.C b/meshLibrary/utilities/smoothers/geometry/meshSurfaceOptimizer/meshSurfaceOptimizerOptimizeSurface.C index ca21f736..c22942f8 100644 --- a/meshLibrary/utilities/smoothers/geometry/meshSurfaceOptimizer/meshSurfaceOptimizerOptimizeSurface.C +++ b/meshLibrary/utilities/smoothers/geometry/meshSurfaceOptimizer/meshSurfaceOptimizerOptimizeSurface.C @@ -50,20 +50,20 @@ namespace Foam label meshSurfaceOptimizer::findInvertedVertices ( - boolList& smoothVertex + boolList& smoothVertex ) const { - const labelList& bPoints = surfaceEngine_.boundaryPoints(); - const VRWGraph& pPoints = surfaceEngine_.pointPoints(); - + const labelList& bPoints = surfaceEngine_.boundaryPoints(); + const VRWGraph& pPoints = surfaceEngine_.pointPoints(); + if( smoothVertex.size() != bPoints.size() ) { smoothVertex.setSize(bPoints.size()); smoothVertex = true; } - label nInvertedTria(0); - + label nInvertedTria(0); + //- check the vertices at the surface //- mark the ones where the mesh is tangled meshSurfaceCheckInvertedVertices vrtCheck(surfaceEngine_, &smoothVertex); @@ -78,22 +78,22 @@ label meshSurfaceOptimizer::findInvertedVertices smoothVertex[bpI] = true; } } - + if( Pstream::parRun() ) reduce(nInvertedTria, sumOp<label>()); - Info << "Number of inverted boundary faces is " << nInvertedTria << endl; + Info << "Number of inverted boundary faces is " << nInvertedTria << endl; if( nInvertedTria == 0 ) return 0; - - //- add additional layers around inverted points - for(label i=0;i<2;++i) - { - boolList originallySelected = smoothVertex; - forAll(smoothVertex, bpI) - if( originallySelected[bpI] ) - forAllRow(pPoints, bpI, ppI) - smoothVertex[pPoints(bpI, ppI)] = true; + + //- add additional layers around inverted points + for(label i=0;i<2;++i) + { + boolList originallySelected = smoothVertex; + forAll(smoothVertex, bpI) + if( originallySelected[bpI] ) + forAllRow(pPoints, bpI, ppI) + smoothVertex[pPoints(bpI, ppI)] = true; if( Pstream::parRun() ) { @@ -141,51 +141,51 @@ label meshSurfaceOptimizer::findInvertedVertices smoothVertex[bpI] = true; } } - } - - return nInvertedTria; + } + + return nInvertedTria; } void meshSurfaceOptimizer::preOptimizeSurface() { Info << "Optimizing positions of surface nodes" << endl; - const labelList& bPoints = surfaceEngine_.boundaryPoints(); + const labelList& bPoints = surfaceEngine_.boundaryPoints(); surfaceEngine_.pointFaces(); surfaceEngine_.faceCentres(); surfaceEngine_.pointPoints(); surfaceEngine_.boundaryFacePatches(); surfaceEngine_.pointNormals(); - this->triangles(); - this->pointTriangles(); - - boolList smoothVertex; - - meshSurfaceEngineModifier surfaceModifier(surfaceEngine_); + this->triangles(); + this->pointTriangles(); + + boolList smoothVertex; + + meshSurfaceEngineModifier surfaceModifier(surfaceEngine_); meshSurfaceMapper mapper(surfaceEngine_, meshOctree_); - - bool remapVertex(true); - label nInvertedTria; - label nGlobalIter(0); + + bool remapVertex(true); + label nInvertedTria; + label nGlobalIter(0); labelListPMG procBndNodes, movedPoints; - - do - { - label nIter(0); - - do - { - nInvertedTria = findInvertedVertices(smoothVertex); + + do + { + label nIter(0); + + do + { + nInvertedTria = findInvertedVertices(smoothVertex); - if( nInvertedTria == 0 ) break; - + if( nInvertedTria == 0 ) break; + procBndNodes.clear(); movedPoints.clear(); - forAll(bPoints, bpI) + forAll(bPoints, bpI) { - if( smoothVertex[bpI] && (vertexType_[bpI] & PARTITION) ) - { + if( smoothVertex[bpI] && (vertexType_[bpI] & PARTITION) ) + { movedPoints.append(bpI); if( vertexType_[bpI] & PROCBND ) @@ -262,18 +262,18 @@ void meshSurfaceOptimizer::preOptimizeSurface() if( remapVertex ) mapper.mapVerticesOntoSurface(movedPoints); - - } while( nInvertedTria && (++nIter < 20) ); - - if( nInvertedTria ) - { - Info << "Smoothing remaining inverted vertices " << endl; + + } while( nInvertedTria && (++nIter < 20) ); + + if( nInvertedTria ) + { + Info << "Smoothing remaining inverted vertices " << endl; movedPoints.clear(); procBndNodes.clear(); - forAll(smoothVertex, bpI) - if( smoothVertex[bpI] ) - { + forAll(smoothVertex, bpI) + if( smoothVertex[bpI] ) + { movedPoints.append(bpI); if( vertexType_[bpI] & PROCBND ) @@ -282,8 +282,8 @@ void meshSurfaceOptimizer::preOptimizeSurface() continue; } - nodeDisplacementLaplacianFC(bpI, false); - } + nodeDisplacementLaplacianFC(bpI, false); + } if( Pstream::parRun() ) { @@ -292,19 +292,19 @@ void meshSurfaceOptimizer::preOptimizeSurface() if( remapVertex ) mapper.mapVerticesOntoSurface(movedPoints); - - if( nGlobalIter > 3 ) - remapVertex = false; - } - - } while( nInvertedTria && (++nGlobalIter < 10) ); + + if( nGlobalIter > 3 ) + remapVertex = false; + } + + } while( nInvertedTria && (++nGlobalIter < 10) ); Info << "Finished optimizing positions of surface nodes" << endl; } void meshSurfaceOptimizer::optimizeSurface(const label nIterations) { - const labelList& bPoints = surfaceEngine_.boundaryPoints(); + const labelList& bPoints = surfaceEngine_.boundaryPoints(); //- needed for parallel execution surfaceEngine_.pointFaces(); @@ -326,12 +326,12 @@ void meshSurfaceOptimizer::optimizeSurface(const label nIterations) } meshSurfaceMapper mapper(surfaceEngine_, meshOctree_); - - //- optimize edge vertices - Info << "Optimizing edges. Iteration:" << flush; - for(label i=0;i<nIterations;++i) - { - Info << "." << flush; + + //- optimize edge vertices + Info << "Optimizing edges. Iteration:" << flush; + for(label i=0;i<nIterations;++i) + { + Info << "." << flush; meshSurfaceEngineModifier bMod(surfaceEngine_); # pragma omp parallel if( edgePoints.size() > 1000 ) @@ -366,16 +366,16 @@ void meshSurfaceOptimizer::optimizeSurface(const label nIterations) } mapper.mapEdgeNodes(edgePoints); - } - Info << endl; - - //- optimize nodes of surface vertices which are not on surface edges - Info << "Optimizing surface vertices. Iteration:"; - for(label i=0;i<nIterations;++i) - { + } + Info << endl; + + //- optimize nodes of surface vertices which are not on surface edges + Info << "Optimizing surface vertices. Iteration:"; + for(label i=0;i<nIterations;++i) + { procBndNodes.clear(); - Info << "." << flush; + Info << "." << flush; meshSurfaceEngineModifier bMod(surfaceEngine_); # pragma omp parallel if( vertexType_.size() > 100 ) @@ -414,7 +414,7 @@ void meshSurfaceOptimizer::optimizeSurface(const label nIterations) { nodeDisplacementLaplacianFCParallel(procBndNodes,true); } - } + } Info << endl; } diff --git a/meshLibrary/utilities/smoothers/topology/checkBoundaryFacesSharingTwoEdges/checkBoundaryFacesSharingTwoEdges.H b/meshLibrary/utilities/smoothers/topology/checkBoundaryFacesSharingTwoEdges/checkBoundaryFacesSharingTwoEdges.H index 7a925f1b..76d5f8a7 100644 --- a/meshLibrary/utilities/smoothers/topology/checkBoundaryFacesSharingTwoEdges/checkBoundaryFacesSharingTwoEdges.H +++ b/meshLibrary/utilities/smoothers/topology/checkBoundaryFacesSharingTwoEdges/checkBoundaryFacesSharingTwoEdges.H @@ -59,7 +59,7 @@ class checkBoundaryFacesSharingTwoEdges { // Private data //- Reference to polyMeshGen - polyMeshGen& mesh_; + polyMeshGen& mesh_; //- pointer to meshSurfaceEngine mutable meshSurfaceEngine* meshSurfacePtr_; @@ -118,7 +118,7 @@ public: // Member Functions //- find boundary points connected to two boundary faces, only - void findPoints(labelHashSet& badPoints); + void findPoints(labelHashSet& badPoints); //- find boundary points connected to two boundary faces //- remove points if possible, decompose boundary faces otherwise diff --git a/meshLibrary/utilities/smoothers/topology/checkCellConnectionsOverFaces/checkCellConnectionsOverFaces.C b/meshLibrary/utilities/smoothers/topology/checkCellConnectionsOverFaces/checkCellConnectionsOverFaces.C index 4ed98b2e..9587c866 100644 --- a/meshLibrary/utilities/smoothers/topology/checkCellConnectionsOverFaces/checkCellConnectionsOverFaces.C +++ b/meshLibrary/utilities/smoothers/topology/checkCellConnectionsOverFaces/checkCellConnectionsOverFaces.C @@ -523,7 +523,7 @@ class groupingOp void checkCellConnectionsOverFaces::findCellGroups() { - Info << "Checking cell connections" << endl; + Info << "Checking cell connections" << endl; //mesh_.write(); //returnReduce(1, sumOp<label>()); @@ -532,11 +532,11 @@ void checkCellConnectionsOverFaces::findCellGroups() const cellListPMG& cells = mesh_.cells(); const labelList& owner = mesh_.owner(); const labelList& neighbour = mesh_.neighbour(); - - labelListPMG front, communicationFaces; + + labelListPMG front, communicationFaces; label chunkI(0), nChunks, chunkSize; VRWGraph neighbouringGroups; - + # pragma omp parallel if( cells.size() > 1000 ) \ private(front, communicationFaces) { @@ -829,8 +829,8 @@ void checkCellConnectionsOverFaces::findCellGroups() nGroups_ = Foam::max(globalGroupLabel_) + 1; reduce(nGroups_, maxOp<label>()); - - Info << "Finished checking cell connections" << endl; + + Info << "Finished checking cell connections" << endl; } // * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * * * * * // diff --git a/meshLibrary/utilities/smoothers/topology/checkCellConnectionsOverFaces/checkCellConnectionsOverFaces.H b/meshLibrary/utilities/smoothers/topology/checkCellConnectionsOverFaces/checkCellConnectionsOverFaces.H index 13300e74..73911deb 100644 --- a/meshLibrary/utilities/smoothers/topology/checkCellConnectionsOverFaces/checkCellConnectionsOverFaces.H +++ b/meshLibrary/utilities/smoothers/topology/checkCellConnectionsOverFaces/checkCellConnectionsOverFaces.H @@ -51,12 +51,12 @@ class checkCellConnectionsOverFaces { // Private data //- Reference to polyMeshGen - polyMeshGen& mesh_; - + polyMeshGen& mesh_; + //- each cell is assigned a group //- cells which can be visited over face neighbours are assigned //- to the same group - labelList cellGroup_; + labelList cellGroup_; //- global group label (needed for parallel execution) labelList globalGroupLabel_; @@ -65,8 +65,8 @@ class checkCellConnectionsOverFaces label nGroups_; // Private member functions - //- decompose marked cells - void findCellGroups(); + //- decompose marked cells + void findCellGroups(); //- Disallow default bitwise copy construct checkCellConnectionsOverFaces(const checkCellConnectionsOverFaces&); @@ -88,7 +88,7 @@ public: // Member Functions //- check if all cells are connected as a single domain //- return true if the mesh has been changed - bool checkCellGroups(); + bool checkCellGroups(); }; // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/meshLibrary/utilities/smoothers/topology/checkIrregularSurfaceConnections/checkIrregularSurfaceConnections.H b/meshLibrary/utilities/smoothers/topology/checkIrregularSurfaceConnections/checkIrregularSurfaceConnections.H index b3c3fb86..a4d019c2 100644 --- a/meshLibrary/utilities/smoothers/topology/checkIrregularSurfaceConnections/checkIrregularSurfaceConnections.H +++ b/meshLibrary/utilities/smoothers/topology/checkIrregularSurfaceConnections/checkIrregularSurfaceConnections.H @@ -54,7 +54,7 @@ class checkIrregularSurfaceConnections { // Private data //- Reference to polyMeshGen - polyMeshGen& mesh_; + polyMeshGen& mesh_; //- pointer to meshSurfaceEngine mutable meshSurfaceEngine* meshSurfacePtr_; @@ -75,9 +75,9 @@ class checkIrregularSurfaceConnections deleteDemandDrivenData(meshSurfacePtr_); } - //- check if there exist vertices with more than one groups of cells + //- check if there exist vertices with more than one groups of cells //- attached to it - bool checkAndFixCellGroupsAtBndVertices + bool checkAndFixCellGroupsAtBndVertices ( labelHashSet& badVertices, const bool removeConnections = false @@ -122,7 +122,7 @@ public: // Member Functions //- find vertices where the surface is not valid - void checkIrregularVertices(labelHashSet& badVertices); + void checkIrregularVertices(labelHashSet& badVertices); //- find invalid connections and fix them on the fly bool checkAndFixIrregularConnections(); diff --git a/meshLibrary/utilities/smoothers/topology/checkIrregularSurfaceConnections/checkIrregularSurfaceConnectionsFunctions.C b/meshLibrary/utilities/smoothers/topology/checkIrregularSurfaceConnections/checkIrregularSurfaceConnectionsFunctions.C index 94fa6dcd..a4dba8fd 100644 --- a/meshLibrary/utilities/smoothers/topology/checkIrregularSurfaceConnections/checkIrregularSurfaceConnectionsFunctions.C +++ b/meshLibrary/utilities/smoothers/topology/checkIrregularSurfaceConnections/checkIrregularSurfaceConnectionsFunctions.C @@ -93,7 +93,7 @@ bool checkIrregularSurfaceConnections::checkAndFixCellGroupsAtBndVertices { const label cellI = pointCells(pointI, cI); - if( cellGroup.found(cellI) ) + if( cellGroup.found(cellI) ) continue; cellGroup.insert(cellI, nGroup); @@ -471,14 +471,14 @@ bool checkIrregularSurfaceConnections::checkEdgeFaceConnections labelHashSet badEdges; - forAll(edgeFaces, edgeI) - if( edgeFaces.sizeOfRow(edgeI) > 2 ) - { + forAll(edgeFaces, edgeI) + if( edgeFaces.sizeOfRow(edgeI) > 2 ) + { badVertices.insert(edges[edgeI].start()); badVertices.insert(edges[edgeI].end()); badEdges.insert(edgeI); - } + } if( Pstream::parRun() ) { diff --git a/meshLibrary/utilities/smoothers/topology/checkNonMappableCellConnections/checkNonMappableCellConnections.H b/meshLibrary/utilities/smoothers/topology/checkNonMappableCellConnections/checkNonMappableCellConnections.H index 5f3f7b1f..6852f3ab 100644 --- a/meshLibrary/utilities/smoothers/topology/checkNonMappableCellConnections/checkNonMappableCellConnections.H +++ b/meshLibrary/utilities/smoothers/topology/checkNonMappableCellConnections/checkNonMappableCellConnections.H @@ -56,7 +56,7 @@ class checkNonMappableCellConnections { // Private data //- Reference to polyMeshGen - polyMeshGen& mesh_; + polyMeshGen& mesh_; //- type of cell labelList cellType_; @@ -95,7 +95,7 @@ public: // Member Functions //- find problematic cells - void findCells(labelHashSet& badCells); + void findCells(labelHashSet& badCells); //- find and remove problematic cells bool removeCells(); diff --git a/meshLibrary/utilities/smoothers/topology/topologicalCleaner/topologicalCleaner.H b/meshLibrary/utilities/smoothers/topology/topologicalCleaner/topologicalCleaner.H index b9cd9eb4..caa2bfb3 100644 --- a/meshLibrary/utilities/smoothers/topology/topologicalCleaner/topologicalCleaner.H +++ b/meshLibrary/utilities/smoothers/topology/topologicalCleaner/topologicalCleaner.H @@ -52,25 +52,25 @@ namespace Foam class topologicalCleaner { // Private data - polyMeshGen& mesh_; - - bool changed_; - - boolList decomposeCell_; + polyMeshGen& mesh_; + + bool changed_; + + boolList decomposeCell_; // Private member functions - + //- check and fix incorrectly connected faces void checkNonConsecutiveBoundaryVertices(); - - //- check and fix non-mappable faces - void checkNonMappableFaces(); - - //- check and fix non-mappable cells - void checkNonMappableCells(); - - //- decompose marked cells - void decomposeCells(); + + //- check and fix non-mappable faces + void checkNonMappableFaces(); + + //- check and fix non-mappable cells + void checkNonMappableCells(); + + //- decompose marked cells + void decomposeCells(); //- Disallow default bitwise copy construct topologicalCleaner(const topologicalCleaner&); @@ -92,17 +92,17 @@ public: // Member Functions - //- clean topologically problematic cells - bool cleanTopology(); + //- clean topologically problematic cells + bool cleanTopology(); - //- check and fix vertices where two or more groups of cells meet - void checkInvalidConnectionsForVerticesCells + //- check and fix vertices where two or more groups of cells meet + void checkInvalidConnectionsForVerticesCells ( labelHashSet* irregularNodes = NULL ); - - //- check and fix vertices where two or more groups of faces meet - void checkInvalidConnectionsForVerticesFaces + + //- check and fix vertices where two or more groups of faces meet + void checkInvalidConnectionsForVerticesFaces ( labelHashSet* irregularNodes = NULL ); diff --git a/meshLibrary/utilities/smoothers/topology/topologicalCleaner/topologyCleanerNonMappableCells.C b/meshLibrary/utilities/smoothers/topology/topologicalCleaner/topologyCleanerNonMappableCells.C index 536a87c8..683caa56 100644 --- a/meshLibrary/utilities/smoothers/topology/topologicalCleaner/topologyCleanerNonMappableCells.C +++ b/meshLibrary/utilities/smoothers/topology/topologicalCleaner/topologyCleanerNonMappableCells.C @@ -42,12 +42,12 @@ namespace Foam void topologicalCleaner::checkNonMappableCells() { - Info << "Checking for non-mappable cells" << endl; - //- decompose cells with more than one boundary face - const labelList& owner = mesh_.owner(); - - List<direction> nBoundaryFaces(mesh_.cells().size(), direction(0)); - const PtrList<writePatch>& boundaries = mesh_.boundaries(); + Info << "Checking for non-mappable cells" << endl; + //- decompose cells with more than one boundary face + const labelList& owner = mesh_.owner(); + + List<direction> nBoundaryFaces(mesh_.cells().size(), direction(0)); + const PtrList<writePatch>& boundaries = mesh_.boundaries(); forAll(boundaries, patchI) { const label start = boundaries[patchI].patchStart(); @@ -58,86 +58,86 @@ void topologicalCleaner::checkNonMappableCells() ++nBoundaryFaces[owner[faceI]]; } } - - label nBadCells(0); - forAll(nBoundaryFaces, cI) - if( nBoundaryFaces[cI] > 1 ) - { - ++nBadCells; - decomposeCell_[cI] = true; - } - + + label nBadCells(0); + forAll(nBoundaryFaces, cI) + if( nBoundaryFaces[cI] > 1 ) + { + ++nBadCells; + decomposeCell_[cI] = true; + } + if( Pstream::parRun() ) reduce(nBadCells, sumOp<label>()); - - if( nBadCells != 0 ) - changed_ = true; - - Info << "Found " << nBadCells << " non-mappable cells" << endl; - Info << "Finished checking for non-mappable cells" << endl; + + if( nBadCells != 0 ) + changed_ = true; + + Info << "Found " << nBadCells << " non-mappable cells" << endl; + Info << "Finished checking for non-mappable cells" << endl; } void topologicalCleaner::checkNonMappableFaces() { - Info << "Checking for non-mappable faces" << endl; - - const faceListPMG& faces = mesh_.faces(); - const labelList& owner = mesh_.owner(); - const labelList& neighbour = mesh_.neighbour(); - - //- find boundary vertices - boolList boundaryVertex(mesh_.points().size(), false); + Info << "Checking for non-mappable faces" << endl; + + const faceListPMG& faces = mesh_.faces(); + const labelList& owner = mesh_.owner(); + const labelList& neighbour = mesh_.neighbour(); + + //- find boundary vertices + boolList boundaryVertex(mesh_.points().size(), false); const PtrList<writePatch>& boundaries = mesh_.boundaries(); - forAll(boundaries, patchI) + forAll(boundaries, patchI) { const label start = boundaries[patchI].patchStart(); const label end = start + boundaries[patchI].patchSize(); - for(label faceI=start;faceI<end;++faceI) - { - const face& f = faces[faceI]; - forAll(f, pI) - boundaryVertex[f[pI]] = true; - } - } + for(label faceI=start;faceI<end;++faceI) + { + const face& f = faces[faceI]; + forAll(f, pI) + boundaryVertex[f[pI]] = true; + } + } + + boolList decomposeFace(faces.size(), false); + + //- internal faces which have more than two vertices at the boundary + //- cannot always be mapped at the boundary and form a valid cell + //- The second case of interest are faces which have two vertices at the + //- boundary but are not connected over an edge + const label nIntFaces = mesh_.nInternalFaces(); - boolList decomposeFace(faces.size(), false); - - //- internal faces which have more than two vertices at the boundary - //- cannot always be mapped at the boundary and form a valid cell - //- The second case of interest are faces which have two vertices at the - //- boundary but are not connected over an edge - const label nIntFaces = mesh_.nInternalFaces(); - - //bool changed(false); - - label nBadFaces(0); - for(label faceI=0;faceI<nIntFaces;++faceI) - { - const face& f = faces[faceI]; - - DynList<label> bPos(f.size()); - forAll(f, pI) - if( boundaryVertex[f[pI]] ) - bPos.append(pI); - - if( - (bPos.size() > 2) || - ( - (bPos.size() == 2) && - ( - (bPos[1] != (bPos[0] + 1)) && - !((bPos[0] == 0) && (bPos[1] == (f.size() - 1))) - ) - ) - ) - { - ++nBadFaces; - decomposeFace[faceI] = true; - decomposeCell_[owner[faceI]] = true; - decomposeCell_[neighbour[faceI]] = true; - } - } + //bool changed(false); + + label nBadFaces(0); + for(label faceI=0;faceI<nIntFaces;++faceI) + { + const face& f = faces[faceI]; + + DynList<label> bPos(f.size()); + forAll(f, pI) + if( boundaryVertex[f[pI]] ) + bPos.append(pI); + + if( + (bPos.size() > 2) || + ( + (bPos.size() == 2) && + ( + (bPos[1] != (bPos[0] + 1)) && + !((bPos[0] == 0) && (bPos[1] == (f.size() - 1))) + ) + ) + ) + { + ++nBadFaces; + decomposeFace[faceI] = true; + decomposeCell_[owner[faceI]] = true; + decomposeCell_[neighbour[faceI]] = true; + } + } if( Pstream::parRun() ) { @@ -155,7 +155,7 @@ void topologicalCleaner::checkNonMappableFaces() for(label faceI=start;faceI<end;++faceI) { const face& f = faces[faceI]; - + DynList<label> bPos(f.size()); forAll(f, pI) if( boundaryVertex[f[pI]] ) @@ -181,11 +181,11 @@ void topologicalCleaner::checkNonMappableFaces() //- send information about decomposed faces to other processor OPstream toOtherProc - ( + ( Pstream::blocking, - procBoundaries[patchI].neiProcNo(), - decProcFace.byteSize() - ); + procBoundaries[patchI].neiProcNo(), + decProcFace.byteSize() + ); toOtherProc << decProcFace; } @@ -210,16 +210,16 @@ void topologicalCleaner::checkNonMappableFaces() reduce(nBadFaces, sumOp<label>()); } - - Info << "Found " << nBadFaces << " non-mappable faces" << endl; - - if( nBadFaces != 0 ) - { - changed_ = true; - decomposeFaces(mesh_).decomposeMeshFaces(decomposeFace); - } - - Info << "Finished checking non-mappable faces" << endl; + + Info << "Found " << nBadFaces << " non-mappable faces" << endl; + + if( nBadFaces != 0 ) + { + changed_ = true; + decomposeFaces(mesh_).decomposeMeshFaces(decomposeFace); + } + + Info << "Finished checking non-mappable faces" << endl; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/meshLibrary/utilities/surfaceTools/boundaryFacesGenerator/boundaryFacesGenerator.C b/meshLibrary/utilities/surfaceTools/boundaryFacesGenerator/boundaryFacesGenerator.C index cbe61977..c98aca21 100644 --- a/meshLibrary/utilities/surfaceTools/boundaryFacesGenerator/boundaryFacesGenerator.C +++ b/meshLibrary/utilities/surfaceTools/boundaryFacesGenerator/boundaryFacesGenerator.C @@ -35,105 +35,105 @@ Description namespace Foam { - + // * * * * * * * * * * * * * Private member functions * * * * * * * * * * * // - + void boundaryFacesGenerator::createBoundaryFaces() { - //- set sizes of boundary cells - polyMeshGenModifier meshModifier(mesh_); - cellListPMG& cells = meshModifier.cellsAccess(); - forAll(boundaryCell_, cellI) - if( boundaryCell_[cellI] ) - cells[cellI].setSize(nFacesInCell_[cellI]); - - //- create boundary faces - forAll(boundaryCell_, cellI) - if( boundaryCell_[cellI] ) - createBoundaryFacesForCell(cellI); + //- set sizes of boundary cells + polyMeshGenModifier meshModifier(mesh_); + cellListPMG& cells = meshModifier.cellsAccess(); + forAll(boundaryCell_, cellI) + if( boundaryCell_[cellI] ) + cells[cellI].setSize(nFacesInCell_[cellI]); + + //- create boundary faces + forAll(boundaryCell_, cellI) + if( boundaryCell_[cellI] ) + createBoundaryFacesForCell(cellI); } void boundaryFacesGenerator::storeBoundaryFaces() { - wordList patchNames; - if( hasFacesInDefaultPatch_ ) - { - patchNames.setSize(surface_.patches().size() + 1); - patchNames[surface_.patches().size()] = "defaultFaces"; - } - else - { - patchNames.setSize(surface_.patches().size()); - } - - forAll(surface_.patches(), patchI) - patchNames[patchI] = surface_.patches()[patchI].name(); - - polyMeshGenModifier(mesh_).replaceBoundary - ( - patchNames, - boundaryFaces_, - boundaryOwners_, - boundaryPatches_ - ); - polyMeshGenModifier(mesh_).removeUnusedVertices(); + wordList patchNames; + if( hasFacesInDefaultPatch_ ) + { + patchNames.setSize(surface_.patches().size() + 1); + patchNames[surface_.patches().size()] = "defaultFaces"; + } + else + { + patchNames.setSize(surface_.patches().size()); + } + + forAll(surface_.patches(), patchI) + patchNames[patchI] = surface_.patches()[patchI].name(); + + polyMeshGenModifier(mesh_).replaceBoundary + ( + patchNames, + boundaryFaces_, + boundaryOwners_, + boundaryPatches_ + ); + polyMeshGenModifier(mesh_).removeUnusedVertices(); } void boundaryFacesGenerator::createSurfaceCornersAndPatches() { - const labelListList& pointFaces = surface_.pointFaces(); - forAll(pointFaces, pI) - { - const labelList& pFaces = pointFaces[pI]; - - DynList<label> patches(5); - forAll(pFaces, pfI) - patches.appendIfNotIn(surface_[pFaces[pfI]].region()); - - //- corners are points in at least three regions - if( patches.size() > 2 ) - { - surfaceCorners_.append(pI); - cornersPatches_.append(patches); - } - } - - Info << "The surface has " << surfaceCorners_.size() << " corners" << endl; + const labelListList& pointFaces = surface_.pointFaces(); + forAll(pointFaces, pI) + { + const labelList& pFaces = pointFaces[pI]; + + DynList<label> patches(5); + forAll(pFaces, pfI) + patches.appendIfNotIn(surface_[pFaces[pfI]].region()); + + //- corners are points in at least three regions + if( patches.size() > 2 ) + { + surfaceCorners_.append(pI); + cornersPatches_.append(patches); + } + } + + Info << "The surface has " << surfaceCorners_.size() << " corners" << endl; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - + boundaryFacesGenerator::boundaryFacesGenerator ( - polyMeshGen& mesh, - List<direction>& nFacesInCell, - label& nPoints, - const label nIntFaces, - const boolList& boundaryCell, - VRWGraph& pointPatches, - const triSurface& surface + polyMeshGen& mesh, + List<direction>& nFacesInCell, + label& nPoints, + const label nIntFaces, + const boolList& boundaryCell, + VRWGraph& pointPatches, + const triSurface& surface ) : - surface_(surface), - mesh_(mesh), - nFacesInCell_(nFacesInCell), - boundaryCell_(boundaryCell), - pointRegions_(pointPatches), - nPoints_(nPoints), - nIntFaces_(nIntFaces), - boundaryFaces_(), - boundaryOwners_(), - boundaryPatches_(), - hasFacesInDefaultPatch_(false), - defaultPatchID_(surface.patches().size()), - surfaceCorners_(surface.patches().size()), - cornersPatches_(surface.patches().size()) + surface_(surface), + mesh_(mesh), + nFacesInCell_(nFacesInCell), + boundaryCell_(boundaryCell), + pointRegions_(pointPatches), + nPoints_(nPoints), + nIntFaces_(nIntFaces), + boundaryFaces_(), + boundaryOwners_(), + boundaryPatches_(), + hasFacesInDefaultPatch_(false), + defaultPatchID_(surface.patches().size()), + surfaceCorners_(surface.patches().size()), + cornersPatches_(surface.patches().size()) { - createSurfaceCornersAndPatches(); - + createSurfaceCornersAndPatches(); + createBoundaryFaces(); - - storeBoundaryFaces(); + + storeBoundaryFaces(); boundaryOutwardOrientation boo(mesh); } diff --git a/meshLibrary/utilities/surfaceTools/boundaryFacesGenerator/boundaryFacesGenerator.H b/meshLibrary/utilities/surfaceTools/boundaryFacesGenerator/boundaryFacesGenerator.H index 1012ed85..35bcf20d 100644 --- a/meshLibrary/utilities/surfaceTools/boundaryFacesGenerator/boundaryFacesGenerator.H +++ b/meshLibrary/utilities/surfaceTools/boundaryFacesGenerator/boundaryFacesGenerator.H @@ -51,69 +51,69 @@ namespace Foam class boundaryFacesGenerator { // private data - //- triangulated surface - const triSurface& surface_; + //- triangulated surface + const triSurface& surface_; //- mesh data - polyMeshGen& mesh_; - - //- helpers + polyMeshGen& mesh_; + + //- helpers List<direction>& nFacesInCell_; const boolList& boundaryCell_; - VRWGraph& pointRegions_; - - label& nPoints_; + VRWGraph& pointRegions_; + + label& nPoints_; const label nIntFaces_; - //- boundary faces - VRWGraph boundaryFaces_; - labelListPMG boundaryOwners_; - labelListPMG boundaryPatches_; - bool hasFacesInDefaultPatch_; - label defaultPatchID_; - - //- surface corners - DynList<label> surfaceCorners_; - DynList< DynList<label> > cornersPatches_; + //- boundary faces + VRWGraph boundaryFaces_; + labelListPMG boundaryOwners_; + labelListPMG boundaryPatches_; + bool hasFacesInDefaultPatch_; + label defaultPatchID_; + + //- surface corners + DynList<label> surfaceCorners_; + DynList< DynList<label> > cornersPatches_; // private member functions - //- find patches for the given vertex + //- find patches for the given vertex labelList patchesForPoint(const label) const; - //- find patches for a given cell - void determineCellPatches(const label, DynList<label>&); - - //- find boundary chains for the given cell - void createBoundaryChainsForCell(const label, labelListList&); - - void createFacesForChain - ( - const labelList& chainVertices, - const DynList<label>& patches, - List<DynList<face> >& facesForChain - ); - void createFacesForChainWithCorner - ( - const label cornerLabel, - const labelList& bChain, - const DynList<label>& patches, - List<DynList<face> >& facesForChain - ); - void createFacesForChainWithoutCorners - ( - const labelList& bChain, - const DynList<label>& patches, - List<DynList<face> >& facesForChain - ); - void createBoundaryFacesForCell(const label); + //- find patches for a given cell + void determineCellPatches(const label, DynList<label>&); + + //- find boundary chains for the given cell + void createBoundaryChainsForCell(const label, labelListList&); + + void createFacesForChain + ( + const labelList& chainVertices, + const DynList<label>& patches, + List<DynList<face> >& facesForChain + ); + void createFacesForChainWithCorner + ( + const label cornerLabel, + const labelList& bChain, + const DynList<label>& patches, + List<DynList<face> >& facesForChain + ); + void createFacesForChainWithoutCorners + ( + const labelList& bChain, + const DynList<label>& patches, + List<DynList<face> >& facesForChain + ); + void createBoundaryFacesForCell(const label); void createBoundaryFaces(); - - //- store boundary faces into the mesh - void storeBoundaryFaces(); - - //- find surface corners - void createSurfaceCornersAndPatches(); + + //- store boundary faces into the mesh + void storeBoundaryFaces(); + + //- find surface corners + void createSurfaceCornersAndPatches(); //- disallows bitwise construct void operator=(const boundaryFacesGenerator&); @@ -128,12 +128,12 @@ public: //- construct components boundaryFacesGenerator ( - polyMeshGen& mesh, - List<direction>& nFacesInCell, - label& nPoints, - const label nIntFaces, - const boolList& boundaryCell, - VRWGraph& pointPatches, + polyMeshGen& mesh, + List<direction>& nFacesInCell, + label& nPoints, + const label nIntFaces, + const boolList& boundaryCell, + VRWGraph& pointPatches, const triSurface& surface ); diff --git a/meshLibrary/utilities/surfaceTools/boundaryFacesGenerator/boundaryFacesGeneratorCreateBoundaryFaces.C b/meshLibrary/utilities/surfaceTools/boundaryFacesGenerator/boundaryFacesGeneratorCreateBoundaryFaces.C index 3f191995..c537314b 100644 --- a/meshLibrary/utilities/surfaceTools/boundaryFacesGenerator/boundaryFacesGeneratorCreateBoundaryFaces.C +++ b/meshLibrary/utilities/surfaceTools/boundaryFacesGenerator/boundaryFacesGeneratorCreateBoundaryFaces.C @@ -40,201 +40,201 @@ namespace Foam labelList boundaryFacesGenerator::patchesForPoint(const label vI) const { - labelList pcs(pointRegions_.sizeOfRow(vI)); - - forAll(pcs, pI) - pcs[pI] = pointRegions_(vI, pI); - - return pcs; + labelList pcs(pointRegions_.sizeOfRow(vI)); + + forAll(pcs, pI) + pcs[pI] = pointRegions_(vI, pI); + + return pcs; } void boundaryFacesGenerator::determineCellPatches ( - const label cellI, - DynList<label>& patches + const label cellI, + DynList<label>& patches ) { - const cellListPMG& polyCells_ = mesh_.cells(); - const faceListPMG& polyFaces_ = mesh_.faces(); - const cell& c = polyCells_[cellI]; + const cellListPMG& polyCells_ = mesh_.cells(); + const faceListPMG& polyFaces_ = mesh_.faces(); + const cell& c = polyCells_[cellI]; - # ifdef DEBUGCutter - Info << "Cell faces are " << c << endl; - forAll(c, fI) - Info << "Face " << c[fI] << " is " - << polyFaces_[c[fI]] << endl; - # endif - - const labelList cellPoints = c.labels(polyFaces_); - - # ifdef DEBUGCutter - Info << "Cell points are " << cellPoints << endl; - # endif + # ifdef DEBUGCutter + Info << "Cell faces are " << c << endl; + forAll(c, fI) + Info << "Face " << c[fI] << " is " + << polyFaces_[c[fI]] << endl; + # endif + + const labelList cellPoints = c.labels(polyFaces_); + + # ifdef DEBUGCutter + Info << "Cell points are " << cellPoints << endl; + # endif - //- find which boundary regions intersect the polyhedron - //- this can be determined by monitoring patch labels - //- of cell points - patches.clear(); - - forAll(cellPoints, cpI) - { - const labelList pp = patchesForPoint(cellPoints[cpI]); - forAll(pp, ppI) - patches.appendIfNotIn(pp[ppI]); - } - - # ifdef DEBUGCutter - Info << "Patches for cell " << cellI << " are " << patches << endl; - # endif + //- find which boundary regions intersect the polyhedron + //- this can be determined by monitoring patch labels + //- of cell points + patches.clear(); + + forAll(cellPoints, cpI) + { + const labelList pp = patchesForPoint(cellPoints[cpI]); + forAll(pp, ppI) + patches.appendIfNotIn(pp[ppI]); + } + + # ifdef DEBUGCutter + Info << "Patches for cell " << cellI << " are " << patches << endl; + # endif } void boundaryFacesGenerator::createBoundaryChainsForCell ( - const label cellI, - labelListList& boundaryChains + const label cellI, + labelListList& boundaryChains ) { - const faceListPMG& polyFaces_ = mesh_.faces(); - const cell& c = mesh_.cells()[cellI]; - //- find edges which appear once - //- these edges are on the boundary - const edgeList cellEdges = c.edges(polyFaces_); - - labelList nAppearances(cellEdges.size(), 0); - forAll(c, fI) - { - const face& f = polyFaces_[c[fI]]; - - const edgeList fe = f.edges(); + const faceListPMG& polyFaces_ = mesh_.faces(); + const cell& c = mesh_.cells()[cellI]; + //- find edges which appear once + //- these edges are on the boundary + const edgeList cellEdges = c.edges(polyFaces_); + + labelList nAppearances(cellEdges.size(), 0); + forAll(c, fI) + { + const face& f = polyFaces_[c[fI]]; + + const edgeList fe = f.edges(); - forAll(fe, eI) - forAll(cellEdges, i) - if( fe[eI] == cellEdges[i] ) - { - ++nAppearances[i]; - break; - } - } + forAll(fe, eI) + forAll(cellEdges, i) + if( fe[eI] == cellEdges[i] ) + { + ++nAppearances[i]; + break; + } + } - //- create a list of boundary edges - DynList<edge> boundaryEdges(10); + //- create a list of boundary edges + DynList<edge> boundaryEdges(10); - forAll(nAppearances, aI) - if( nAppearances[aI] == 1 ) - { - boundaryEdges.append(cellEdges[aI]); - } - else if( nAppearances[aI] > 2 ) - { - const cellListPMG& polyCells_ = mesh_.cells(); - forAll(polyCells_[cellI], fI) - Info << "Face " << polyCells_[cellI][fI] << " is " - << polyFaces_[polyCells_[cellI][fI]] << endl; - FatalErrorIn - ( - "void createBoundaryFaces()" - ) << "Cell " << cellI << " is not topologically closed!" - << abort(FatalError); - } + forAll(nAppearances, aI) + if( nAppearances[aI] == 1 ) + { + boundaryEdges.append(cellEdges[aI]); + } + else if( nAppearances[aI] > 2 ) + { + const cellListPMG& polyCells_ = mesh_.cells(); + forAll(polyCells_[cellI], fI) + Info << "Face " << polyCells_[cellI][fI] << " is " + << polyFaces_[polyCells_[cellI][fI]] << endl; + FatalErrorIn + ( + "void createBoundaryFaces()" + ) << "Cell " << cellI << " is not topologically closed!" + << abort(FatalError); + } - //- sort edges into chains - boundaryChains = sortEdgesIntoChains(boundaryEdges).sortedChains(); + //- sort edges into chains + boundaryChains = sortEdgesIntoChains(boundaryEdges).sortedChains(); - # ifdef DEBUGCutter - Info << "boundaryChains " << boundaryChains << endl; - # endif + # ifdef DEBUGCutter + Info << "boundaryChains " << boundaryChains << endl; + # endif } void boundaryFacesGenerator::createBoundaryFacesForCell(const label cellI) { - //- check if there are any faces in the current cell - if( nFacesInCell_[cellI] == 0 ) - FatalErrorIn - ( - "void boundaryFacesGenerator::createBoundaryFacesForCell" - "(const label)" - ) << "Cell " << cellI << " has no faces!!" - << nl << "This generally means that there is not enough cells " - << "in that region. It can be remedied by refining " - << "the mesh there." << exit(FatalError); - - //- determine cell patches - DynList<label> patches(5); - determineCellPatches(cellI, patches); - - # ifdef DEBUGCutter - Info << "Cell patches " << patches << endl; - # endif - - //- create boundary chains for cell - labelListList boundaryChains; - createBoundaryChainsForCell(cellI, boundaryChains); - - //- create storage for faces created from the boundary chain - //- this list contains faces created from the chain - //- with respect to the boundary patch they belong to - //- first list : faces for each chain - //- second list: faces with respect to the patch - //- third list : there can be more than one face per patch - List< List< DynList<face> > > facePoints - ( - boundaryChains.size() - ); - - forAll(facePoints, chI) - { - facePoints[chI].setSize(patches.size()+1); - } - - //- create faces for the given chains - forAll(boundaryChains, bcI) - createFacesForChain - ( - boundaryChains[bcI], - patches, - facePoints[bcI] - ); - - # ifdef DEBUGCutter - Info << "facePoints " << facePoints << endl; - # endif - - //- store faces into the list - forAll(facePoints, chI) - { - const List< DynList<face> >& chfcs = facePoints[chI]; - - forAll(chfcs, patchI) - { - const DynList<face>& patchFaces = chfcs[patchI]; - - if( patchI < patches.size() ) - { - forAll(patchFaces, pfI) - { - boundaryFaces_.appendList(patchFaces[pfI]); - boundaryOwners_.append(cellI); - boundaryPatches_.append(patches[patchI]); - } - } - else - { - # ifdef DEBUGCutter - Info << "Faces " << patchFaces - << " are in default patch" << endl; - # endif - //- faces in default patch - forAll(patchFaces, pfI) - { - hasFacesInDefaultPatch_ = true; - boundaryFaces_.appendList(patchFaces[pfI]); - boundaryOwners_.append(cellI); - boundaryPatches_.append(defaultPatchID_); - } - } - } - } + //- check if there are any faces in the current cell + if( nFacesInCell_[cellI] == 0 ) + FatalErrorIn + ( + "void boundaryFacesGenerator::createBoundaryFacesForCell" + "(const label)" + ) << "Cell " << cellI << " has no faces!!" + << nl << "This generally means that there is not enough cells " + << "in that region. It can be remedied by refining " + << "the mesh there." << exit(FatalError); + + //- determine cell patches + DynList<label> patches(5); + determineCellPatches(cellI, patches); + + # ifdef DEBUGCutter + Info << "Cell patches " << patches << endl; + # endif + + //- create boundary chains for cell + labelListList boundaryChains; + createBoundaryChainsForCell(cellI, boundaryChains); + + //- create storage for faces created from the boundary chain + //- this list contains faces created from the chain + //- with respect to the boundary patch they belong to + //- first list : faces for each chain + //- second list: faces with respect to the patch + //- third list : there can be more than one face per patch + List< List< DynList<face> > > facePoints + ( + boundaryChains.size() + ); + + forAll(facePoints, chI) + { + facePoints[chI].setSize(patches.size()+1); + } + + //- create faces for the given chains + forAll(boundaryChains, bcI) + createFacesForChain + ( + boundaryChains[bcI], + patches, + facePoints[bcI] + ); + + # ifdef DEBUGCutter + Info << "facePoints " << facePoints << endl; + # endif + + //- store faces into the list + forAll(facePoints, chI) + { + const List< DynList<face> >& chfcs = facePoints[chI]; + + forAll(chfcs, patchI) + { + const DynList<face>& patchFaces = chfcs[patchI]; + + if( patchI < patches.size() ) + { + forAll(patchFaces, pfI) + { + boundaryFaces_.appendList(patchFaces[pfI]); + boundaryOwners_.append(cellI); + boundaryPatches_.append(patches[patchI]); + } + } + else + { + # ifdef DEBUGCutter + Info << "Faces " << patchFaces + << " are in default patch" << endl; + # endif + //- faces in default patch + forAll(patchFaces, pfI) + { + hasFacesInDefaultPatch_ = true; + boundaryFaces_.appendList(patchFaces[pfI]); + boundaryOwners_.append(cellI); + boundaryPatches_.append(defaultPatchID_); + } + } + } + } } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *// diff --git a/meshLibrary/utilities/surfaceTools/boundaryFacesGenerator/boundaryFacesGeneratorFacesForChain.C b/meshLibrary/utilities/surfaceTools/boundaryFacesGenerator/boundaryFacesGeneratorFacesForChain.C index bcaaacb6..20819099 100644 --- a/meshLibrary/utilities/surfaceTools/boundaryFacesGenerator/boundaryFacesGeneratorFacesForChain.C +++ b/meshLibrary/utilities/surfaceTools/boundaryFacesGenerator/boundaryFacesGeneratorFacesForChain.C @@ -35,157 +35,157 @@ Description namespace Foam { - + // * * * * * * * * * * * * * Private member functions * * * * * * * * * * * // void boundaryFacesGenerator::createFacesForChain ( - const labelList& chainVertices, - const DynList<label>& patches, - List< DynList<face> >& facesForChain + const labelList& chainVertices, + const DynList<label>& patches, + List< DynList<face> >& facesForChain ) { - createFacesFromChain cffc(chainVertices, pointRegions_); - - //- create faces which do not need an additional corner first - cffc.createFacesWithoutACorner(); - - if( cffc.unresolvedPoints().size() == 0 ) - { - //- store created faces and return - const DynList<face>& createdFaces = cffc.createdFaces(); - const DynList<label>& faceRegion = cffc.faceRegion(); - - forAll(createdFaces, fI) - { - const label pos = patches.containsAtPosition(faceRegion[fI]); - const face& f = createdFaces[fI]; - # ifdef DEBUGCutter - Info << "Storing face " << f << " at position " << pos << endl; - # endif - facesForChain[pos].append(f); - } - - return; - } - else if( cffc.unresolvedPoints().size() < 3 ) - { - FatalErrorIn - ( - "void boundaryFacesGenerator::createFacesForChain" - "(" - "const labelList& chainVertices," - "const DynList<label>& patches," - "List< DynList<face> >& facesForChain" - ")" - ) << "I am not sure if this should ever happen!" << exit(FatalError); - } - - const labelList& unresolvedPoints = cffc.unresolvedPoints(); - DynList<label> chainPatches(5); - forAll(unresolvedPoints, upI) - { - const labelList pp = patchesForPoint(unresolvedPoints[upI]); - - forAll(pp, ppI) - chainPatches.appendIfNotIn(pp[ppI]); - } - - if( chainPatches.size() < 3 ) - { - //- expected three or more patches - //- this will be resolved by storing the face into a default patch - facesForChain[patches.size()].append(face(chainVertices)); - } - else - { - //- find the cornerLabel - DynList<label> cornersCandidates; - - forAll(cornersPatches_, cornerI) - { - const DynList<label>& cPatches = cornersPatches_[cornerI]; - - bool allFound(true); - forAll(cPatches, cpI) - { - bool found = chainPatches.contains(cPatches[cpI]); - - if( !found ) - { - allFound = false; - break; - } - } - - if( allFound ) - cornersCandidates.append(surfaceCorners_[cornerI]); - } - - if( cornersCandidates.size() != 0 ) - { - label cornerLabel(-1); - - if( cornersCandidates.size() == 1 ) - { - cornerLabel = cornersCandidates[0]; - } - else - { - //- find nearest corner - point c(vector::zero); - forAll(chainVertices, cvI) - c += mesh_.points()[chainVertices[cvI]]; - c /= chainVertices.size(); - - scalar dist(VGREAT); - forAll(cornersCandidates, cornerI) - if( - mag - ( - surface_.localPoints()[cornersCandidates[cornerI]] - - c - ) < dist - ) - { - dist = - mag - ( - surface_.localPoints()[cornersCandidates[cornerI]] - - c - ); - cornerLabel = cornersCandidates[cornerI]; - } - } - - //- create faces including the corner - //- create faces with a corner vertex - cffc.createFacesWithACorner(nPoints_); - - //- add new mesh vertex - polyMeshGenModifier modifier(mesh_); - modifier.pointsAccess().newElmt(nPoints_++) = - surface_.localPoints()[cornerLabel]; - - const DynList<face>& createdFaces = cffc.createdFaces(); - const DynList<label>& faceRegion = cffc.faceRegion(); - forAll(createdFaces, fI) - { - const label pos = patches.containsAtPosition(faceRegion[fI]); - const face& f = createdFaces[fI]; - # ifdef DEBUGCutter - Info << "Storing face " << f << " at position " << pos << endl; - # endif - facesForChain[pos].append(f); - } - } - else - { - //- this is a tricky combination - //- store the face into the default patch - facesForChain[patches.size()].append(face(chainVertices)); - } - } + createFacesFromChain cffc(chainVertices, pointRegions_); + + //- create faces which do not need an additional corner first + cffc.createFacesWithoutACorner(); + + if( cffc.unresolvedPoints().size() == 0 ) + { + //- store created faces and return + const DynList<face>& createdFaces = cffc.createdFaces(); + const DynList<label>& faceRegion = cffc.faceRegion(); + + forAll(createdFaces, fI) + { + const label pos = patches.containsAtPosition(faceRegion[fI]); + const face& f = createdFaces[fI]; + # ifdef DEBUGCutter + Info << "Storing face " << f << " at position " << pos << endl; + # endif + facesForChain[pos].append(f); + } + + return; + } + else if( cffc.unresolvedPoints().size() < 3 ) + { + FatalErrorIn + ( + "void boundaryFacesGenerator::createFacesForChain" + "(" + "const labelList& chainVertices," + "const DynList<label>& patches," + "List< DynList<face> >& facesForChain" + ")" + ) << "I am not sure if this should ever happen!" << exit(FatalError); + } + + const labelList& unresolvedPoints = cffc.unresolvedPoints(); + DynList<label> chainPatches(5); + forAll(unresolvedPoints, upI) + { + const labelList pp = patchesForPoint(unresolvedPoints[upI]); + + forAll(pp, ppI) + chainPatches.appendIfNotIn(pp[ppI]); + } + + if( chainPatches.size() < 3 ) + { + //- expected three or more patches + //- this will be resolved by storing the face into a default patch + facesForChain[patches.size()].append(face(chainVertices)); + } + else + { + //- find the cornerLabel + DynList<label> cornersCandidates; + + forAll(cornersPatches_, cornerI) + { + const DynList<label>& cPatches = cornersPatches_[cornerI]; + + bool allFound(true); + forAll(cPatches, cpI) + { + bool found = chainPatches.contains(cPatches[cpI]); + + if( !found ) + { + allFound = false; + break; + } + } + + if( allFound ) + cornersCandidates.append(surfaceCorners_[cornerI]); + } + + if( cornersCandidates.size() != 0 ) + { + label cornerLabel(-1); + + if( cornersCandidates.size() == 1 ) + { + cornerLabel = cornersCandidates[0]; + } + else + { + //- find nearest corner + point c(vector::zero); + forAll(chainVertices, cvI) + c += mesh_.points()[chainVertices[cvI]]; + c /= chainVertices.size(); + + scalar dist(VGREAT); + forAll(cornersCandidates, cornerI) + if( + mag + ( + surface_.localPoints()[cornersCandidates[cornerI]] - + c + ) < dist + ) + { + dist = + mag + ( + surface_.localPoints()[cornersCandidates[cornerI]] - + c + ); + cornerLabel = cornersCandidates[cornerI]; + } + } + + //- create faces including the corner + //- create faces with a corner vertex + cffc.createFacesWithACorner(nPoints_); + + //- add new mesh vertex + polyMeshGenModifier modifier(mesh_); + modifier.pointsAccess().newElmt(nPoints_++) = + surface_.localPoints()[cornerLabel]; + + const DynList<face>& createdFaces = cffc.createdFaces(); + const DynList<label>& faceRegion = cffc.faceRegion(); + forAll(createdFaces, fI) + { + const label pos = patches.containsAtPosition(faceRegion[fI]); + const face& f = createdFaces[fI]; + # ifdef DEBUGCutter + Info << "Storing face " << f << " at position " << pos << endl; + # endif + facesForChain[pos].append(f); + } + } + else + { + //- this is a tricky combination + //- store the face into the default patch + facesForChain[patches.size()].append(face(chainVertices)); + } + } } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *// diff --git a/meshLibrary/utilities/surfaceTools/boundaryOutwardOrientation/boundaryOutwardOrientation.C b/meshLibrary/utilities/surfaceTools/boundaryOutwardOrientation/boundaryOutwardOrientation.C index 62fdd542..72ac690b 100644 --- a/meshLibrary/utilities/surfaceTools/boundaryOutwardOrientation/boundaryOutwardOrientation.C +++ b/meshLibrary/utilities/surfaceTools/boundaryOutwardOrientation/boundaryOutwardOrientation.C @@ -41,25 +41,25 @@ namespace Foam void boundaryOutwardOrientation::checkBoundaryOrientation() { - polyMeshGenModifier meshModifier_(mesh_); - faceListPMG& faces_ = meshModifier_.facesAccess(); - const cellListPMG& cells_ = mesh_.cells(); - const labelList& owner_ = mesh_.owner(); - const labelList& neighbour_ = mesh_.neighbour(); - - if( mesh_.boundaries().size() == 0 ) - { - WarningIn - ( - "void boundaryOutwardOrientation::checkBoundaryOrientation()" - ) << "Boundary data is not yet calculated!! Cannot proceed!" - << endl; - - return; - } - - const label nIntFaces_ = mesh_.nInternalFaces(); - + polyMeshGenModifier meshModifier_(mesh_); + faceListPMG& faces_ = meshModifier_.facesAccess(); + const cellListPMG& cells_ = mesh_.cells(); + const labelList& owner_ = mesh_.owner(); + const labelList& neighbour_ = mesh_.neighbour(); + + if( mesh_.boundaries().size() == 0 ) + { + WarningIn + ( + "void boundaryOutwardOrientation::checkBoundaryOrientation()" + ) << "Boundary data is not yet calculated!! Cannot proceed!" + << endl; + + return; + } + + const label nIntFaces_ = mesh_.nInternalFaces(); + for(register label faceI=nIntFaces_;faceI<faces_.size();faceI++) { const cell& c = cells_[owner_[faceI]]; @@ -92,11 +92,11 @@ void boundaryOutwardOrientation::checkBoundaryOrientation() if( e.start() != -1 ) { edge eOther(-1, -1); - const edgeList newBfEdges = newBf.edges(); - forAll(newBfEdges, eJ) - if( newBfEdges[eJ] == e ) - eOther = newBfEdges[eJ]; - + const edgeList newBfEdges = newBf.edges(); + forAll(newBfEdges, eJ) + if( newBfEdges[eJ] == e ) + eOther = newBfEdges[eJ]; + if( ( (owner_[c[fI]] == owner_[faceI] ) && @@ -124,12 +124,12 @@ void boundaryOutwardOrientation::checkBoundaryOrientation() boundaryOutwardOrientation::boundaryOutwardOrientation ( - polyMeshGen& mesh + polyMeshGen& mesh ) : - mesh_(mesh) + mesh_(mesh) { - checkBoundaryOrientation(); + checkBoundaryOrientation(); } boundaryOutwardOrientation::~boundaryOutwardOrientation() diff --git a/meshLibrary/utilities/surfaceTools/boundaryOutwardOrientation/boundaryOutwardOrientation.H b/meshLibrary/utilities/surfaceTools/boundaryOutwardOrientation/boundaryOutwardOrientation.H index 6eef8876..39fe19d3 100644 --- a/meshLibrary/utilities/surfaceTools/boundaryOutwardOrientation/boundaryOutwardOrientation.H +++ b/meshLibrary/utilities/surfaceTools/boundaryOutwardOrientation/boundaryOutwardOrientation.H @@ -50,11 +50,11 @@ namespace Foam class boundaryOutwardOrientation { // Private data - //- refenrence to the mesh - polyMeshGen& mesh_; - - //- orientate boundary - void checkBoundaryOrientation(); + //- refenrence to the mesh + polyMeshGen& mesh_; + + //- orientate boundary + void checkBoundaryOrientation(); //- Disallow default bitwise copy construct boundaryOutwardOrientation(const boundaryOutwardOrientation&); diff --git a/meshLibrary/utilities/surfaceTools/correctEdgesBetweenPatches/correctEdgesBetweenPatches.C b/meshLibrary/utilities/surfaceTools/correctEdgesBetweenPatches/correctEdgesBetweenPatches.C index 4f5c1334..9e576ede 100644 --- a/meshLibrary/utilities/surfaceTools/correctEdgesBetweenPatches/correctEdgesBetweenPatches.C +++ b/meshLibrary/utilities/surfaceTools/correctEdgesBetweenPatches/correctEdgesBetweenPatches.C @@ -37,7 +37,7 @@ Description namespace Foam { - + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // const meshSurfaceEngine& correctEdgesBetweenPatches::meshSurface() const @@ -58,13 +58,13 @@ void correctEdgesBetweenPatches::replaceBoundary() { clearMeshSurface(); - polyMeshGenModifier(mesh_).replaceBoundary - ( - patchNames_, - newBoundaryFaces_, - newBoundaryOwners_, - newBoundaryPatches_ - ); + polyMeshGenModifier(mesh_).replaceBoundary + ( + patchNames_, + newBoundaryFaces_, + newBoundaryOwners_, + newBoundaryPatches_ + ); } void correctEdgesBetweenPatches::decomposeCorrectedCells() @@ -83,21 +83,21 @@ void correctEdgesBetweenPatches::decomposeCorrectedCells() // Construct from mesh, octree, regions for boundary vertices correctEdgesBetweenPatches::correctEdgesBetweenPatches ( - polyMeshGen& mesh + polyMeshGen& mesh ) : - mesh_(mesh), - msePtr_(NULL), - patchNames_(mesh.boundaries().size()), - newBoundaryFaces_(), - newBoundaryOwners_(), - newBoundaryPatches_(), - decomposeCell_(mesh_.cells().size(), false), - decompose_(false) + mesh_(mesh), + msePtr_(NULL), + patchNames_(mesh.boundaries().size()), + newBoundaryFaces_(), + newBoundaryOwners_(), + newBoundaryPatches_(), + decomposeCell_(mesh_.cells().size(), false), + decompose_(false) { - const PtrList<writePatch>& boundaries = mesh_.boundaries(); - forAll(boundaries, patchI) - patchNames_[patchI] = boundaries[patchI].patchName(); + const PtrList<writePatch>& boundaries = mesh_.boundaries(); + forAll(boundaries, patchI) + patchNames_[patchI] = boundaries[patchI].patchName(); checkFacePatches(); @@ -112,7 +112,7 @@ correctEdgesBetweenPatches::correctEdgesBetweenPatches correctEdgesBetweenPatches::~correctEdgesBetweenPatches() { - deleteDemandDrivenData(msePtr_); + deleteDemandDrivenData(msePtr_); } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/meshLibrary/utilities/surfaceTools/correctEdgesBetweenPatches/correctEdgesBetweenPatches.H b/meshLibrary/utilities/surfaceTools/correctEdgesBetweenPatches/correctEdgesBetweenPatches.H index 4c735c31..57d9e99a 100644 --- a/meshLibrary/utilities/surfaceTools/correctEdgesBetweenPatches/correctEdgesBetweenPatches.H +++ b/meshLibrary/utilities/surfaceTools/correctEdgesBetweenPatches/correctEdgesBetweenPatches.H @@ -27,7 +27,7 @@ Class Description Changes mesh surface until every boundary face shares only one edge with - the faces in other boundary patch + the faces in other boundary patch SourceFiles correctEdgesBetweenPatches.C @@ -57,21 +57,21 @@ class meshSurfaceEngine; class correctEdgesBetweenPatches { // Private data - //- mesh - polyMeshGen& mesh_; - - //- pointer to surface engine - mutable const meshSurfaceEngine* msePtr_; - - //- boundary data - wordList patchNames_; - VRWGraph newBoundaryFaces_; - labelListPMG newBoundaryOwners_; - labelListPMG newBoundaryPatches_; - - //- holds data which cells have to be decomposed - boolList decomposeCell_; - bool decompose_; + //- mesh + polyMeshGen& mesh_; + + //- pointer to surface engine + mutable const meshSurfaceEngine* msePtr_; + + //- boundary data + wordList patchNames_; + VRWGraph newBoundaryFaces_; + labelListPMG newBoundaryOwners_; + labelListPMG newBoundaryPatches_; + + //- holds data which cells have to be decomposed + boolList decomposeCell_; + bool decompose_; // Private member functions @@ -81,11 +81,11 @@ class correctEdgesBetweenPatches //- delete mesh surface void clearMeshSurface(); - //- replace boundary - void replaceBoundary(); - - //- decompose corrected cells - void decomposeCorrectedCells(); + //- replace boundary + void replaceBoundary(); + + //- decompose corrected cells + void decomposeCorrectedCells(); //- minimise the number of edges which should be constrained //- to the feature edges @@ -95,9 +95,9 @@ class correctEdgesBetweenPatches //- over vertices and internal faces which have more than one feature //- edge at the boundary void decomposeProblematicFaces(); - - //- perform decompose remaining faces having more than one feature edge - void patchCorrection(); + + //- perform decompose remaining faces having more than one feature edge + void patchCorrection(); //- Disallow default bitwise copy construct correctEdgesBetweenPatches(const correctEdgesBetweenPatches&); diff --git a/meshLibrary/utilities/surfaceTools/decomposeCellsNearConcaveEdges/decomposeCellsNearConcaveEdges.C b/meshLibrary/utilities/surfaceTools/decomposeCellsNearConcaveEdges/decomposeCellsNearConcaveEdges.C index 13e59b3b..4a9a6e29 100644 --- a/meshLibrary/utilities/surfaceTools/decomposeCellsNearConcaveEdges/decomposeCellsNearConcaveEdges.C +++ b/meshLibrary/utilities/surfaceTools/decomposeCellsNearConcaveEdges/decomposeCellsNearConcaveEdges.C @@ -35,7 +35,7 @@ Description namespace Foam { - + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // @@ -43,15 +43,15 @@ namespace Foam // Construct from mesh, octree, regions for boundary vertices decomposeCellsNearConcaveEdges::decomposeCellsNearConcaveEdges ( - polyMeshGen& mesh + polyMeshGen& mesh ) : - mesh_(mesh), - decomposeCell_(mesh_.cells().size(), false) -{ - findConcaveFacesAndCells(); - - decomposeConcaveCells(); + mesh_(mesh), + decomposeCell_(mesh_.cells().size(), false) +{ + findConcaveFacesAndCells(); + + decomposeConcaveCells(); } // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // diff --git a/meshLibrary/utilities/surfaceTools/decomposeCellsNearConcaveEdges/decomposeCellsNearConcaveEdges.H b/meshLibrary/utilities/surfaceTools/decomposeCellsNearConcaveEdges/decomposeCellsNearConcaveEdges.H index 152527a1..93228081 100644 --- a/meshLibrary/utilities/surfaceTools/decomposeCellsNearConcaveEdges/decomposeCellsNearConcaveEdges.H +++ b/meshLibrary/utilities/surfaceTools/decomposeCellsNearConcaveEdges/decomposeCellsNearConcaveEdges.H @@ -51,19 +51,19 @@ namespace Foam class decomposeCellsNearConcaveEdges { // Private data - //- mesh - polyMeshGen& mesh_; - - //- holds data which cells have to be decomposed - boolList decomposeCell_; + //- mesh + polyMeshGen& mesh_; + + //- holds data which cells have to be decomposed + boolList decomposeCell_; // Private member functions - //- find problematic cells which need to be decomposed - void findConcaveFacesAndCells(); - - //- perform patch correction - void decomposeConcaveCells(); + //- find problematic cells which need to be decomposed + void findConcaveFacesAndCells(); + + //- perform patch correction + void decomposeConcaveCells(); //- Disallow default bitwise copy construct decomposeCellsNearConcaveEdges(const decomposeCellsNearConcaveEdges&); diff --git a/meshLibrary/utilities/surfaceTools/decomposeCellsNearConcaveEdges/decomposeCellsNearConcaveEdgesDecompose.C b/meshLibrary/utilities/surfaceTools/decomposeCellsNearConcaveEdges/decomposeCellsNearConcaveEdgesDecompose.C index f15942b3..10183f8f 100644 --- a/meshLibrary/utilities/surfaceTools/decomposeCellsNearConcaveEdges/decomposeCellsNearConcaveEdgesDecompose.C +++ b/meshLibrary/utilities/surfaceTools/decomposeCellsNearConcaveEdges/decomposeCellsNearConcaveEdgesDecompose.C @@ -43,85 +43,85 @@ Description namespace Foam { - + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // void decomposeCellsNearConcaveEdges::findConcaveFacesAndCells() { - meshSurfaceEngine mse(mesh_); - const faceList::subList& bFaces = mse.boundaryFaces(); - const labelList& facePatch = mse.boundaryFacePatches(); - const VRWGraph& edgeFaces = mse.edgeFaces(); - const edgeList& edges = mse.edges(); - const pointFieldPMG& points = mesh_.points(); - - boolList concaveVertex(points.size(), false); - forAll(edgeFaces, eI) - { - const label bfI = edgeFaces[eI][0]; - const label bfJ = edgeFaces[eI][1]; - - const face& f0 = bFaces[bfI]; - const face& f1 = bFaces[bfJ]; - - if( - (facePatch[bfI] != facePatch[bfJ]) && - !help::isSharedEdgeConvex(points, f0, f1) - ) - { - const edge& e = edges[eI]; - concaveVertex[e[0]] = true; - concaveVertex[e[1]] = true; - } - } - - //- decompose concave internal faces - decomposeFaces(mesh_).decomposeConcaveInternalFaces(concaveVertex); - - //- find which cells need to be decomposed - # ifdef DEBUGDec - const label id = mesh_.addCellSubset("decomposeCells"); - # endif + meshSurfaceEngine mse(mesh_); + const faceList::subList& bFaces = mse.boundaryFaces(); + const labelList& facePatch = mse.boundaryFacePatches(); + const VRWGraph& edgeFaces = mse.edgeFaces(); + const edgeList& edges = mse.edges(); + const pointFieldPMG& points = mesh_.points(); - const faceListPMG& faces = mesh_.faces(); - const labelList& owner = mesh_.owner(); - const labelList& neighbour = mesh_.neighbour(); - const label nIntFaces = mesh_.nInternalFaces(); - for(label faceI=0;faceI<nIntFaces;++faceI) - { - const face& f = faces[faceI]; - - forAll(f, pI) + boolList concaveVertex(points.size(), false); + forAll(edgeFaces, eI) + { + const label bfI = edgeFaces[eI][0]; + const label bfJ = edgeFaces[eI][1]; + + const face& f0 = bFaces[bfI]; + const face& f1 = bFaces[bfJ]; + + if( + (facePatch[bfI] != facePatch[bfJ]) && + !help::isSharedEdgeConvex(points, f0, f1) + ) + { + const edge& e = edges[eI]; + concaveVertex[e[0]] = true; + concaveVertex[e[1]] = true; + } + } + + //- decompose concave internal faces + decomposeFaces(mesh_).decomposeConcaveInternalFaces(concaveVertex); + + //- find which cells need to be decomposed + # ifdef DEBUGDec + const label id = mesh_.addCellSubset("decomposeCells"); + # endif + + const faceListPMG& faces = mesh_.faces(); + const labelList& owner = mesh_.owner(); + const labelList& neighbour = mesh_.neighbour(); + const label nIntFaces = mesh_.nInternalFaces(); + for(label faceI=0;faceI<nIntFaces;++faceI) + { + const face& f = faces[faceI]; + + forAll(f, pI) { if( f[pI] >= concaveVertex.size() ) continue; - if( concaveVertex[f[pI]] ) - { - decomposeCell_[owner[faceI]] = true; - decomposeCell_[neighbour[faceI]] = true; - - # ifdef DEBUGDec - mesh_.addCellToSubset(id, owner[faceI]); - mesh_.addCellToSubset(id, neighbour[faceI]); - # endif - - break; - } + if( concaveVertex[f[pI]] ) + { + decomposeCell_[owner[faceI]] = true; + decomposeCell_[neighbour[faceI]] = true; + + # ifdef DEBUGDec + mesh_.addCellToSubset(id, owner[faceI]); + mesh_.addCellToSubset(id, neighbour[faceI]); + # endif + + break; + } } - } - - # ifdef DEBUGDec + } + + # ifdef DEBUGDec Info << "Writting mesh" << endl; - mesh_.write(); - ::exit(1); - # endif -} + mesh_.write(); + ::exit(1); + # endif +} void decomposeCellsNearConcaveEdges::decomposeConcaveCells() { - decomposeCells dc(mesh_); - dc.decomposeMesh(decomposeCell_); + decomposeCells dc(mesh_); + dc.decomposeMesh(decomposeCell_); } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/meshLibrary/utilities/surfaceTools/meshSurfaceCheckInvertedVertices/meshSurfaceCheckInvertedVertices.C b/meshLibrary/utilities/surfaceTools/meshSurfaceCheckInvertedVertices/meshSurfaceCheckInvertedVertices.C index 8dd753d0..d1d218d4 100644 --- a/meshLibrary/utilities/surfaceTools/meshSurfaceCheckInvertedVertices/meshSurfaceCheckInvertedVertices.C +++ b/meshLibrary/utilities/surfaceTools/meshSurfaceCheckInvertedVertices/meshSurfaceCheckInvertedVertices.C @@ -225,7 +225,7 @@ meshSurfaceCheckInvertedVertices::meshSurfaceCheckInvertedVertices activePointsPtr_(activePointsPtr), invertedVertices_() { - checkVertices(); + checkVertices(); } meshSurfaceCheckInvertedVertices::meshSurfaceCheckInvertedVertices @@ -238,7 +238,7 @@ meshSurfaceCheckInvertedVertices::meshSurfaceCheckInvertedVertices activePointsPtr_(NULL), invertedVertices_() { - checkVertices(); + checkVertices(); } // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // diff --git a/meshLibrary/utilities/surfaceTools/meshSurfaceCutter/meshSurfaceCutter.C b/meshLibrary/utilities/surfaceTools/meshSurfaceCutter/meshSurfaceCutter.C index c0e52feb..2758cb5a 100644 --- a/meshLibrary/utilities/surfaceTools/meshSurfaceCutter/meshSurfaceCutter.C +++ b/meshLibrary/utilities/surfaceTools/meshSurfaceCutter/meshSurfaceCutter.C @@ -36,25 +36,25 @@ namespace Foam { // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - + meshSurfaceCutter::meshSurfaceCutter ( - polyMeshGen& mesh, - const triSurface& surface + polyMeshGen& mesh, + const triSurface& surface ) : - surface_(surface), - mesh_(mesh), - nIntFaces_(0), - nPoints_(mesh.points().size()), - nFacesInCell_(mesh.cells().size(), direction(0)), - problematicTopology_(mesh.cells().size(), false), - boundaryCell_(mesh.cells().size(), false), - edgePointPtr_(NULL), - newPointsPtr_(NULL), - newPointLabelPtr_(NULL), - facesFromFacePtr_(NULL), - pointTriIndex_() + surface_(surface), + mesh_(mesh), + nIntFaces_(0), + nPoints_(mesh.points().size()), + nFacesInCell_(mesh.cells().size(), direction(0)), + problematicTopology_(mesh.cells().size(), false), + boundaryCell_(mesh.cells().size(), false), + edgePointPtr_(NULL), + newPointsPtr_(NULL), + newPointLabelPtr_(NULL), + facesFromFacePtr_(NULL), + pointTriIndex_() { # ifdef DEBUGCutter @@ -71,7 +71,7 @@ meshSurfaceCutter::meshSurfaceCutter Info << "Checking for cell consisting of two or more closed parts" << endl; # endif //checkCellTopology(); - + # ifdef DEBUGCutter Info << "Checking directions of face normals" << endl; # endif diff --git a/meshLibrary/utilities/surfaceTools/meshSurfaceCutter/meshSurfaceCutter.H b/meshLibrary/utilities/surfaceTools/meshSurfaceCutter/meshSurfaceCutter.H index 36459880..777dd59c 100644 --- a/meshLibrary/utilities/surfaceTools/meshSurfaceCutter/meshSurfaceCutter.H +++ b/meshLibrary/utilities/surfaceTools/meshSurfaceCutter/meshSurfaceCutter.H @@ -51,33 +51,33 @@ namespace Foam class meshSurfaceCutter { // private data - //- triangulated surface - const triSurface& surface_; + //- triangulated surface + const triSurface& surface_; //- mesh data - polyMeshGen& mesh_; - - //- helpers - label nIntFaces_; + polyMeshGen& mesh_; + + //- helpers + label nIntFaces_; label nPoints_; List<direction> nFacesInCell_; boolList problematicTopology_; boolList boundaryCell_; - - edgeList* edgePointPtr_; - DynList<point>* newPointsPtr_; - labelList* newPointLabelPtr_; + + edgeList* edgePointPtr_; + DynList<point>* newPointsPtr_; + labelList* newPointLabelPtr_; faceListList* facesFromFacePtr_; List< DynList<label> > pointTriIndex_; // private member functions - //- return patches for the given point + //- return patches for the given point labelList patchesForPoint(const label) const; - - //- find internal points and intersections with the surface - void findInternalPointsAndIntersections(); + + //- find internal points and intersections with the surface + void findInternalPointsAndIntersections(); - //- find vertices on boundary edges + //- find vertices on boundary edges void findBoundaryEdgePoints ( const label, @@ -86,17 +86,17 @@ class meshSurfaceCutter const boolList& ); - //- cuts the face + //- cuts the face bool faceCutter ( const label ); - - void createInternalMeshPointsAndFaces(); - - void createBoundaryFaces(); - //void checkCellTopology(); - //void checkFaceDirections(); + + void createInternalMeshPointsAndFaces(); + + void createBoundaryFaces(); + //void checkCellTopology(); + //void checkFaceDirections(); //- disallows bitwise construct void operator=(const meshSurfaceCutter&); @@ -111,7 +111,7 @@ public: //- construct components meshSurfaceCutter ( - polyMeshGen& mesh, + polyMeshGen& mesh, const triSurface& surface ); diff --git a/meshLibrary/utilities/surfaceTools/meshSurfaceCutter/meshSurfaceCutterBoundaryFaces.C b/meshLibrary/utilities/surfaceTools/meshSurfaceCutter/meshSurfaceCutterBoundaryFaces.C index 092f2b11..54b004b6 100644 --- a/meshLibrary/utilities/surfaceTools/meshSurfaceCutter/meshSurfaceCutterBoundaryFaces.C +++ b/meshLibrary/utilities/surfaceTools/meshSurfaceCutter/meshSurfaceCutterBoundaryFaces.C @@ -47,7 +47,7 @@ labelList meshSurfaceCutter::patchesForPoint(const label vI) const const DynList<label>& tria = pointTriIndex_[vI]; short i(0); - forAll(tria, tI) + forAll(tria, tI) pcs[i++] = fcs[tria[tI]].region(); return pcs; @@ -60,24 +60,24 @@ labelList meshSurfaceCutter::patchesForPoint(const label vI) const void meshSurfaceCutter::createBoundaryFaces() { - VRWGraph pointPatches(nPoints_); - forAll(pointPatches, pI) - { - const labelList pp = patchesForPoint(pI); - forAll(pp, ppI) - pointPatches.append(pI, pp[ppI]); - } - - boundaryFacesGenerator - ( - mesh_, - nFacesInCell_, - nPoints_, - nIntFaces_, - boundaryCell_, - pointPatches, - surface_ - ); + VRWGraph pointPatches(nPoints_); + forAll(pointPatches, pI) + { + const labelList pp = patchesForPoint(pI); + forAll(pp, ppI) + pointPatches.append(pI, pp[ppI]); + } + + boundaryFacesGenerator + ( + mesh_, + nFacesInCell_, + nPoints_, + nIntFaces_, + boundaryCell_, + pointPatches, + surface_ + ); } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *// diff --git a/meshLibrary/utilities/surfaceTools/meshSurfaceCutter/meshSurfaceCutterCreateEdges.C b/meshLibrary/utilities/surfaceTools/meshSurfaceCutter/meshSurfaceCutterCreateEdges.C index 5db4cd54..9121324d 100644 --- a/meshLibrary/utilities/surfaceTools/meshSurfaceCutter/meshSurfaceCutterCreateEdges.C +++ b/meshLibrary/utilities/surfaceTools/meshSurfaceCutter/meshSurfaceCutterCreateEdges.C @@ -41,9 +41,9 @@ void meshSurfaceCutter::createEdges labelListList& faceEdges ) const { - const pointFieldPMG& points = mesh_.points(); - const faceListPMG& faces = mesh_.faces(); - + const pointFieldPMG& points = mesh_.points(); + const faceListPMG& faces = mesh_.faces(); + //- set sizes of lists faceEdges.setSize(faces.size()); //- create point faces addressing diff --git a/meshLibrary/utilities/surfaceTools/meshSurfaceCutter/meshSurfaceCutterEdgePoints.C b/meshLibrary/utilities/surfaceTools/meshSurfaceCutter/meshSurfaceCutterEdgePoints.C index 4cb8daa5..d6389ea2 100644 --- a/meshLibrary/utilities/surfaceTools/meshSurfaceCutter/meshSurfaceCutterEdgePoints.C +++ b/meshLibrary/utilities/surfaceTools/meshSurfaceCutter/meshSurfaceCutterEdgePoints.C @@ -47,16 +47,16 @@ void meshSurfaceCutter::findBoundaryEdgePoints const boolList& inwardPoint ) { - DynList<point>& newPoints = *newPointsPtr_; - - const faceListPMG& faces = mesh_.faces(); - const pointFieldPMG& meshPoints = mesh_.points(); - + DynList<point>& newPoints = *newPointsPtr_; + + const faceListPMG& faces = mesh_.faces(); + const pointFieldPMG& meshPoints = mesh_.points(); + # ifdef DEBUGCutter Info << "Creating edge points for face " << faceI << endl; - Info << "Face consists of vertices " << faces[faceI] << endl; - const pointField fvrt = faces[faceI].points(meshPoints); - Info << "Vertices " << fvrt << endl; + Info << "Face consists of vertices " << faces[faceI] << endl; + const pointField fvrt = faces[faceI].points(meshPoints); + Info << "Vertices " << fvrt << endl; # endif label inward(-1); @@ -77,9 +77,9 @@ void meshSurfaceCutter::findBoundaryEdgePoints vector normal = f.normal(meshPoints); normal /= mag(normal); - #ifdef DEBUGCutter - Info << "Face normal " << normal << endl; - # endif + #ifdef DEBUGCutter + Info << "Face normal " << normal << endl; + # endif const pointField& points = surface_.points(); const List<labelledTri>& faces = surface_.localFaces(); @@ -148,8 +148,8 @@ void meshSurfaceCutter::findBoundaryEdgePoints # ifdef DEBUGCutter Info << "SEarch tri " << searchTri << " " << faces[searchTri] << endl; - Info << "Vertices in the triangle " - << faces[searchTri].points(points) << endl; + Info << "Vertices in the triangle " + << faces[searchTri].points(points) << endl; Info << "intersected edges " << intersectedEdges << endl; Info << "Intersections " << edgePoints << endl; Info << "intersected vertices " @@ -236,13 +236,13 @@ void meshSurfaceCutter::findBoundaryEdgePoints FatalErrorIn ( "void meshSurfaceCutter::" - "findBoundaryEdgePoints()" + "findBoundaryEdgePoints()" ) << " Cannot close face " << faceI << " because your data is higly degenerate" << ". Please smooth your triangulated" << " surface and try again!" << abort(FatalError); - + const scalar d0 = mag ( @@ -275,8 +275,8 @@ void meshSurfaceCutter::findBoundaryEdgePoints << newPoints[newF[npI]] << endl; FatalErrorIn ( - "void meshSurfaceCutter::" - "findBoundaryEdgePoints()" + "void meshSurfaceCutter::" + "findBoundaryEdgePoints()" ) << "Cannot find the vertex on the edge!!" << " Cannot close face " << faceI << abort(FatalError); @@ -372,8 +372,8 @@ void meshSurfaceCutter::findBoundaryEdgePoints << intersectedNeighbours << endl; FatalErrorIn ( - "void meshSurfaceCutter::" - "findBoundaryEdgePoints()" + "void meshSurfaceCutter::" + "findBoundaryEdgePoints()" ) << "Cannot find the vertex on the edge!!" << " Cannot close face " << faceI << abort(FatalError); diff --git a/meshLibrary/utilities/surfaceTools/meshSurfaceCutter/meshSurfaceCutterFaceCutter.C b/meshLibrary/utilities/surfaceTools/meshSurfaceCutter/meshSurfaceCutterFaceCutter.C index ceb917aa..b9b4ee62 100644 --- a/meshLibrary/utilities/surfaceTools/meshSurfaceCutter/meshSurfaceCutterFaceCutter.C +++ b/meshLibrary/utilities/surfaceTools/meshSurfaceCutter/meshSurfaceCutterFaceCutter.C @@ -53,17 +53,17 @@ bool meshSurfaceCutter::faceCutter Info << "Point " << f[pI] << " " << mesh_.points()[f[pI]] << endl; # endif - const edgeList& edges = mesh_.addressingData().edges(); + const edgeList& edges = mesh_.addressingData().edges(); const VRWGraph& faceEdges = mesh_.addressingData().faceEdges(); - labelList fEdges(faceEdges.sizeOfRow(faceI)); - forAllRow(faceEdges, faceI, eI) - fEdges[eI] = faceEdges(faceI, eI); - - const labelList& newPointLabels = *newPointLabelPtr_; - const edgeList& edgePoint = *edgePointPtr_; + labelList fEdges(faceEdges.sizeOfRow(faceI)); + forAllRow(faceEdges, faceI, eI) + fEdges[eI] = faceEdges(faceI, eI); + + const labelList& newPointLabels = *newPointLabelPtr_; + const edgeList& edgePoint = *edgePointPtr_; # ifdef DEBUG_meshSurfaceCutter - const DynList<point>& newPoints = *newPointsPtr_; + const DynList<point>& newPoints = *newPointsPtr_; forAll(f, pI) Info << "Original edge " << pI << " " << edges[fEdges[pI]] << endl; # endif diff --git a/meshLibrary/utilities/surfaceTools/meshSurfaceCutter/meshSurfaceCutterFaceDirections.C b/meshLibrary/utilities/surfaceTools/meshSurfaceCutter/meshSurfaceCutterFaceDirections.C index 88b39835..50d60d6f 100644 --- a/meshLibrary/utilities/surfaceTools/meshSurfaceCutter/meshSurfaceCutterFaceDirections.C +++ b/meshLibrary/utilities/surfaceTools/meshSurfaceCutter/meshSurfaceCutterFaceDirections.C @@ -41,51 +41,51 @@ void meshSurfaceCutter::checkFaceDirections() labelList own(polyFaces_.size(),-1); labelList nei(nIntFaces_,-1); - help::calculateOwnersAndNeighbours - ( - polyFaces_, - polyCells_, - own, - nei - ); + help::calculateOwnersAndNeighbours + ( + polyFaces_, + polyCells_, + own, + nei + ); //- check if the boundary face normals point outside for(register label faceI=patchStart_[0];faceI < polyFaces_.size();faceI++) { - const cell& c = polyCells_[own[faceI]]; - - const edgeList fEdges = polyFaces_[faceI].edges(); - - forAll(c, fI) - if( faceI != c[fI] ) - { - const edgeList nEdges = polyFaces_[c[fI]].edges(); - - forAll(fEdges, eI) - { - bool found(false); - - forAll(nEdges, eJ) - if( fEdges[eI] == nEdges[eJ] ) - { - if( - ( - (own[c[fI]] == own[faceI]) && - (fEdges[eI].start() == nEdges[eJ].start()) - ) || - ( - (nei[c[fI]] == own[faceI]) && - (fEdges[eI].start() == nEdges[eJ].end()) - ) - ) - polyFaces_[faceI] = - polyFaces_[faceI].reverseFace(); - } - - if( found ) - break; - } - } + const cell& c = polyCells_[own[faceI]]; + + const edgeList fEdges = polyFaces_[faceI].edges(); + + forAll(c, fI) + if( faceI != c[fI] ) + { + const edgeList nEdges = polyFaces_[c[fI]].edges(); + + forAll(fEdges, eI) + { + bool found(false); + + forAll(nEdges, eJ) + if( fEdges[eI] == nEdges[eJ] ) + { + if( + ( + (own[c[fI]] == own[faceI]) && + (fEdges[eI].start() == nEdges[eJ].start()) + ) || + ( + (nei[c[fI]] == own[faceI]) && + (fEdges[eI].start() == nEdges[eJ].end()) + ) + ) + polyFaces_[faceI] = + polyFaces_[faceI].reverseFace(); + } + + if( found ) + break; + } + } } } diff --git a/meshLibrary/utilities/surfaceTools/meshSurfaceCutter/meshSurfaceCutterInternalFaces.C b/meshLibrary/utilities/surfaceTools/meshSurfaceCutter/meshSurfaceCutterInternalFaces.C index f1f34ead..b3121d0d 100644 --- a/meshLibrary/utilities/surfaceTools/meshSurfaceCutter/meshSurfaceCutterInternalFaces.C +++ b/meshLibrary/utilities/surfaceTools/meshSurfaceCutter/meshSurfaceCutterInternalFaces.C @@ -42,35 +42,35 @@ Description namespace Foam { - + void meshSurfaceCutter::findInternalPointsAndIntersections() { - //- create poly edges - const polyMeshGenAddressing& addressingData = mesh_.addressingData(); - const edgeList& edges = addressingData.edges(); - const VRWGraph& faceEdges = addressingData.faceEdges(); + //- create poly edges + const polyMeshGenAddressing& addressingData = mesh_.addressingData(); + const edgeList& edges = addressingData.edges(); + const VRWGraph& faceEdges = addressingData.faceEdges(); # ifdef DEBUGCutter Info << "Edges " << edges << endl; Info << "faceEdges " << faceEdges << endl; # endif - //- create the octree - surfaceIntersectionsOctree so(surface_, 100, 10); - - const pointFieldPMG& points = mesh_.points(); - - if( !newPointsPtr_ ) - newPointsPtr_ = new DynList<point>(); - DynList<point>& newPoints = *newPointsPtr_; - newPoints.setSize(points.size()); - - if( !newPointLabelPtr_ ) - newPointLabelPtr_ = new labelList(); + //- create the octree + surfaceIntersectionsOctree so(surface_, 100, 10); + + const pointFieldPMG& points = mesh_.points(); + + if( !newPointsPtr_ ) + newPointsPtr_ = new DynList<point>(); + DynList<point>& newPoints = *newPointsPtr_; + newPoints.setSize(points.size()); + + if( !newPointLabelPtr_ ) + newPointLabelPtr_ = new labelList(); labelList& newPointLabels = *newPointLabelPtr_; - newPointLabels.setSize(points.size()); - newPointLabels = -1; - + newPointLabels.setSize(points.size()); + newPointLabels = -1; + const label np = points.size(); nPoints_ = 0; Serr << "Creating internal vertices:"; @@ -116,12 +116,12 @@ void meshSurfaceCutter::findInternalPointsAndIntersections() pointTriIndex_.setSize(points.size()); - if( !edgePointPtr_ ) - edgePointPtr_ = new edgeList(); + if( !edgePointPtr_ ) + edgePointPtr_ = new edgeList(); edgeList& edgePoint = *edgePointPtr_; - edgePoint.setSize(edges.size()); - edgePoint = edge(-1, -1); - //Info << "Number of edges is " << edges.size() << endl; + edgePoint.setSize(edges.size()); + edgePoint = edge(-1, -1); + //Info << "Number of edges is " << edges.size() << endl; index = 0; @@ -141,14 +141,14 @@ void meshSurfaceCutter::findInternalPointsAndIntersections() { edgePoint[eI].start() = nPoints_; edgePoint[eI].end() = -1; - - # ifdef DEBUGCutter - Info << nl << "1. Points for edge " << eI - << " are " << edges[eI] << endl; - Info << "Start vertex " << points[e.start()] << endl; - Info << "End vertex " << points[e.end()] << endl; - Info << "Intersection " << ss.rawPoint() << endl; - # endif + + # ifdef DEBUGCutter + Info << nl << "1. Points for edge " << eI + << " are " << edges[eI] << endl; + Info << "Start vertex " << points[e.start()] << endl; + Info << "End vertex " << points[e.end()] << endl; + Info << "Intersection " << ss.rawPoint() << endl; + # endif newPoints.append(ss.rawPoint()); pointTriIndex_.newElmt(nPoints_).append(ss.index()); @@ -180,14 +180,14 @@ void meshSurfaceCutter::findInternalPointsAndIntersections() { edgePoint[eI].start() = -1; edgePoint[eI].end() = nPoints_; - - # ifdef DEBUGCutter - Info << nl << "2. Points for edge " << eI - << " are " << edges[eI] << endl; - Info << "Start vertex " << points[e.start()] << endl; - Info << "End vertex " << points[e.end()] << endl; - Info << "Intersection " << ss.rawPoint() << endl; - # endif + + # ifdef DEBUGCutter + Info << nl << "2. Points for edge " << eI + << " are " << edges[eI] << endl; + Info << "Start vertex " << points[e.start()] << endl; + Info << "End vertex " << points[e.end()] << endl; + Info << "Intersection " << ss.rawPoint() << endl; + # endif newPoints.append(ss.rawPoint()); pointTriIndex_.newElmt(nPoints_).append(ss.index()); @@ -224,14 +224,14 @@ void meshSurfaceCutter::findInternalPointsAndIntersections() edgePoint[eI].start() = nPoints_; newPoints.append(ss.rawPoint()); - # ifdef DEBUGCutter - Info << nl << "3. Points for edge " << eI - << " are " << edges[eI] << endl; - Info << "Start vertex " << points[e.start()] << endl; - Info << "End vertex " << points[e.end()] << endl; - Info << "Intersection1 " << ss.rawPoint() << endl; - Info << "Intersection2 " << ss1.rawPoint() << endl; - # endif + # ifdef DEBUGCutter + Info << nl << "3. Points for edge " << eI + << " are " << edges[eI] << endl; + Info << "Start vertex " << points[e.start()] << endl; + Info << "End vertex " << points[e.end()] << endl; + Info << "Intersection1 " << ss.rawPoint() << endl; + Info << "Intersection2 " << ss1.rawPoint() << endl; + # endif pointTriIndex_.newElmt(nPoints_).append(ss.index()); nPoints_++; @@ -243,8 +243,8 @@ void meshSurfaceCutter::findInternalPointsAndIntersections() } else if( ss.hit() || ss1.hit() ) { - Info << "ss " << ss << endl; - Info << "ss1 " << ss1 << endl; + Info << "ss " << ss << endl; + Info << "ss1 " << ss1 << endl; FatalErrorIn ( "void meshSurfaceCutter::createInternalMeshPointsAndFaces()" @@ -304,16 +304,16 @@ void meshSurfaceCutter::findInternalPointsAndIntersections() Info << "edgePoint["<<eI<<"] are "<< edgePoint[eI] << endl; } # endif - + } void meshSurfaceCutter::createInternalMeshPointsAndFaces() { - findInternalPointsAndIntersections(); + findInternalPointsAndIntersections(); const labelList owner = mesh_.owner(); const labelList neighbour = mesh_.neighbour(); - const faceListPMG& faces = mesh_.faces(); + const faceListPMG& faces = mesh_.faces(); //- Finally, create new internal faces Serr << "Creating internal faces:"; @@ -341,7 +341,7 @@ void meshSurfaceCutter::createInternalMeshPointsAndFaces() # ifdef DEBUGCutter Info << "Cutting face " << faceI << " for cell " << owner[faceI] << " and cell " << neighbour[faceI] << endl; - Info << "Original face " << faces[faceI] << endl; + Info << "Original face " << faces[faceI] << endl; # endif //- create a mesh face from a face of a Voronoi polyhedron @@ -350,11 +350,11 @@ void meshSurfaceCutter::createInternalMeshPointsAndFaces() boundaryCell_[owner[faceI]] = true; boundaryCell_[neighbour[faceI]] = true; } - - # ifdef DEBUGCutter - Info << "New faces for face are " << facesFromFace_[faceI] << endl; - # endif - + + # ifdef DEBUGCutter + Info << "New faces for face are " << facesFromFace_[faceI] << endl; + # endif + if( index++ >= neighbour.size() / 10 ) { Serr << "."; @@ -373,12 +373,12 @@ void meshSurfaceCutter::createInternalMeshPointsAndFaces() { nFacesInCell_[cI] = 0; } - + nIntFaces_ = 0; - - polyMeshGenModifier meshModifier(mesh_); - cellListPMG& newCells = meshModifier.cellsAccess(); - faceListPMG& newFaces = meshModifier.facesAccess(); + + polyMeshGenModifier meshModifier(mesh_); + cellListPMG& newCells = meshModifier.cellsAccess(); + faceListPMG& newFaces = meshModifier.facesAccess(); forAll(facesFromFace_, faceI) { @@ -395,13 +395,13 @@ void meshSurfaceCutter::createInternalMeshPointsAndFaces() //- that the owner and/or neighbour cells consist of two parts if( facesFromFace_[faceI].size() > 1 ) { - # ifdef DEBUCutter + # ifdef DEBUCutter Info << "face " << faceI << " " << faces[faceI] << nl << "owner " << owner[faceI] << nl << "neighbour " << neighbour[faceI] << nl << " is decomposed into " << facesFromFace_[faceI] << endl; - # endif + # endif problematicTopology_[owner[faceI]] = true; problematicTopology_[neighbour[faceI]] = true; } @@ -415,14 +415,14 @@ void meshSurfaceCutter::createInternalMeshPointsAndFaces() << " and " << neighbour[faceI] << endl; # endif if( f.size() > 2 ) - { - //- store cut internal faces - const label own = owner[faceI]; - const label nei = neighbour[faceI]; - newCells[own][nFacesInCell_[own]++] = nIntFaces_; - newCells[nei][nFacesInCell_[nei]++] = nIntFaces_; - newFaces.newElmt(nIntFaces_++) = f; - } + { + //- store cut internal faces + const label own = owner[faceI]; + const label nei = neighbour[faceI]; + newCells[own][nFacesInCell_[own]++] = nIntFaces_; + newCells[nei][nFacesInCell_[nei]++] = nIntFaces_; + newFaces.newElmt(nIntFaces_++) = f; + } } } diff --git a/meshLibrary/utilities/surfaceTools/meshSurfaceEdgeExtractor/meshSurfaceEdgeCreateBoundaryFaces.C b/meshLibrary/utilities/surfaceTools/meshSurfaceEdgeExtractor/meshSurfaceEdgeCreateBoundaryFaces.C index 05ba3ca0..42268c5e 100644 --- a/meshLibrary/utilities/surfaceTools/meshSurfaceEdgeExtractor/meshSurfaceEdgeCreateBoundaryFaces.C +++ b/meshLibrary/utilities/surfaceTools/meshSurfaceEdgeExtractor/meshSurfaceEdgeCreateBoundaryFaces.C @@ -43,16 +43,16 @@ namespace Foam void meshSurfaceEdgeExtractor::createBoundaryFaces() { - boundaryFacesGenerator bfg - ( - mesh_, - nFacesInCell_, - nPoints_, - mesh_.boundaries()[0].patchStart(), - boundaryCell_, - pointRegions_, - meshOctree_.surface() - ); + boundaryFacesGenerator bfg + ( + mesh_, + nFacesInCell_, + nPoints_, + mesh_.boundaries()[0].patchStart(), + boundaryCell_, + pointRegions_, + meshOctree_.surface() + ); } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/meshLibrary/utilities/surfaceTools/meshSurfaceEdgeExtractor/meshSurfaceEdgeCreateEdgeVertices.C b/meshLibrary/utilities/surfaceTools/meshSurfaceEdgeExtractor/meshSurfaceEdgeCreateEdgeVertices.C index bb8b7eff..33c36d5d 100644 --- a/meshLibrary/utilities/surfaceTools/meshSurfaceEdgeExtractor/meshSurfaceEdgeCreateEdgeVertices.C +++ b/meshLibrary/utilities/surfaceTools/meshSurfaceEdgeExtractor/meshSurfaceEdgeCreateEdgeVertices.C @@ -43,112 +43,112 @@ namespace Foam void meshSurfaceEdgeExtractor::createEdgeVertices() { - pointFieldPMG& points = mesh_.points(); - const faceListPMG& faces = mesh_.faces(); - - const edgeList& edges = mesh_.addressingData().edges(); - const VRWGraph& faceEdges = mesh_.addressingData().faceEdges(); - - Map<label> newEdgePoint; - - const label nIntFaces = mesh_.nInternalFaces(); - const label nFaces = faces.size(); - - nPoints_ = points.size(); - - for(label faceI=nIntFaces;faceI<nFaces;++faceI) - { - const face& f = faces[faceI]; - - forAll(f, pI) - { - const label edgeI = faceEdges(faceI, pI); - - if( newEdgePoint.found(edgeI) ) continue; - - const label s = f[pI]; - const label e = f.nextLabel(pI); - - if( !pointRegions_.sizeOfRow(s) || !pointRegions_.sizeOfRow(e) ) - { - Warning << "Boundary vertices " << s << " and " << e - << " are not mapped to the boundary!" << endl; - - continue; - } - - if( pointRegions_(s, 0) != pointRegions_(e, 0) ) - { - point newP; + pointFieldPMG& points = mesh_.points(); + const faceListPMG& faces = mesh_.faces(); + + const edgeList& edges = mesh_.addressingData().edges(); + const VRWGraph& faceEdges = mesh_.addressingData().faceEdges(); + + Map<label> newEdgePoint; + + const label nIntFaces = mesh_.nInternalFaces(); + const label nFaces = faces.size(); + + nPoints_ = points.size(); + + for(label faceI=nIntFaces;faceI<nFaces;++faceI) + { + const face& f = faces[faceI]; + + forAll(f, pI) + { + const label edgeI = faceEdges(faceI, pI); + + if( newEdgePoint.found(edgeI) ) continue; + + const label s = f[pI]; + const label e = f.nextLabel(pI); + + if( !pointRegions_.sizeOfRow(s) || !pointRegions_.sizeOfRow(e) ) + { + Warning << "Boundary vertices " << s << " and " << e + << " are not mapped to the boundary!" << endl; + + continue; + } + + if( pointRegions_(s, 0) != pointRegions_(e, 0) ) + { + point newP; scalar distSq; - - FixedList<point, 2> edgePoints; - FixedList<label, 2> patches; - - edgePoints[0] = points[s]; - edgePoints[1] = points[e]; - patches[0] = pointRegions_(s, 0); - patches[1] = pointRegions_(e, 0); - - const bool found = - meshOctree_.findNearestVertexToTheEdge - ( - edgePoints, - patches, - newP, + + FixedList<point, 2> edgePoints; + FixedList<label, 2> patches; + + edgePoints[0] = points[s]; + edgePoints[1] = points[e]; + patches[0] = pointRegions_(s, 0); + patches[1] = pointRegions_(e, 0); + + const bool found = + meshOctree_.findNearestVertexToTheEdge + ( + edgePoints, + patches, + newP, distSq - ); - - if( found ) - { - points.append(newP); - } - else - { - points.append - ( - edges[faceEdges(faceI, pI)].centre(points) - ); - } - - pointRegions_.appendList(patches); - - newEdgePoint.insert(edgeI, nPoints_); - ++nPoints_; - } - } - } - - points.setSize(nPoints_); - - //- create new faces - DynList<label> newF(20); - forAll(faces, faceI) - { - const face& f = faces[faceI]; - - newF.clear(); - - forAll(f, eI) - { - newF.append(f[eI]); - if( newEdgePoint.found(faceEdges(faceI, eI)) ) - newF.append(newEdgePoint[faceEdges(faceI, eI)]); - } - - if( newF.size() > f.size() ) - { - //- face must be changed - face& mf = const_cast<face&>(f); - mf.setSize(newF.size()); - forAll(mf, pI) - mf[pI] = newF[pI]; - } - } - - mesh_.clearAddressingData(); - - Info << "Finished creating mesh edges" << endl; + ); + + if( found ) + { + points.append(newP); + } + else + { + points.append + ( + edges[faceEdges(faceI, pI)].centre(points) + ); + } + + pointRegions_.appendList(patches); + + newEdgePoint.insert(edgeI, nPoints_); + ++nPoints_; + } + } + } + + points.setSize(nPoints_); + + //- create new faces + DynList<label> newF(20); + forAll(faces, faceI) + { + const face& f = faces[faceI]; + + newF.clear(); + + forAll(f, eI) + { + newF.append(f[eI]); + if( newEdgePoint.found(faceEdges(faceI, eI)) ) + newF.append(newEdgePoint[faceEdges(faceI, eI)]); + } + + if( newF.size() > f.size() ) + { + //- face must be changed + face& mf = const_cast<face&>(f); + mf.setSize(newF.size()); + forAll(mf, pI) + mf[pI] = newF[pI]; + } + } + + mesh_.clearAddressingData(); + + Info << "Finished creating mesh edges" << endl; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/meshLibrary/utilities/surfaceTools/meshSurfaceEdgeExtractor/meshSurfaceEdgeExtractor.C b/meshLibrary/utilities/surfaceTools/meshSurfaceEdgeExtractor/meshSurfaceEdgeExtractor.C index b9a5c932..e3da7828 100644 --- a/meshLibrary/utilities/surfaceTools/meshSurfaceEdgeExtractor/meshSurfaceEdgeExtractor.C +++ b/meshLibrary/utilities/surfaceTools/meshSurfaceEdgeExtractor/meshSurfaceEdgeExtractor.C @@ -41,27 +41,27 @@ namespace Foam // Construct from mesh, octree, regions for boundary vertices meshSurfaceEdgeExtractor::meshSurfaceEdgeExtractor ( - polyMeshGen& mesh, - const meshOctree& octree, - const labelList& pointRegion + polyMeshGen& mesh, + const meshOctree& octree, + const labelList& pointRegion ) : - mesh_(mesh), - nPoints_(mesh.points().size()), - boundaryCell_(mesh.cells().size(), false), - nFacesInCell_(mesh.cells().size(), direction(0)), + mesh_(mesh), + nPoints_(mesh.points().size()), + boundaryCell_(mesh.cells().size(), false), + nFacesInCell_(mesh.cells().size(), direction(0)), meshOctree_(octree), pointRegions_(pointRegion.size()) -{ - forAll(pointRegion, pointI) - if( pointRegion[pointI] != -1 ) - pointRegions_.append(pointI, pointRegion[pointI]); - - createEdgeVertices(); - - removeOldBoundaryFaces(); - - createBoundaryFaces(); +{ + forAll(pointRegion, pointI) + if( pointRegion[pointI] != -1 ) + pointRegions_.append(pointI, pointRegion[pointI]); + + createEdgeVertices(); + + removeOldBoundaryFaces(); + + createBoundaryFaces(); } // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // @@ -74,35 +74,35 @@ meshSurfaceEdgeExtractor::~meshSurfaceEdgeExtractor() void meshSurfaceEdgeExtractor::removeOldBoundaryFaces() { - const labelList neighbour_ = mesh_.neighbour(); - polyMeshGenModifier meshModifier_(mesh_); - cellListPMG& cells_ = meshModifier_.cellsAccess(); - - forAll(cells_, cellI) - { - const cell& c = cells_[cellI]; - - cell newC(c); - - forAll(c, fI) - if( neighbour_[c[fI]] != -1 ) - { - boundaryCell_[cellI] = true; - newC[nFacesInCell_[cellI]++] = c[fI]; - } - - if( nFacesInCell_[cellI] < c.size() ) - { - newC.setSize(nFacesInCell_[cellI]); - - cells_[cellI] = newC; - }; - } - - PtrList<writePatch>& boundaries = meshModifier_.boundariesAccess(); - boundaries.setSize(1); - boundaries[0].patchSize() = 0; - meshModifier_.facesAccess().setSize(boundaries[0].patchStart()); + const labelList neighbour_ = mesh_.neighbour(); + polyMeshGenModifier meshModifier_(mesh_); + cellListPMG& cells_ = meshModifier_.cellsAccess(); + + forAll(cells_, cellI) + { + const cell& c = cells_[cellI]; + + cell newC(c); + + forAll(c, fI) + if( neighbour_[c[fI]] != -1 ) + { + boundaryCell_[cellI] = true; + newC[nFacesInCell_[cellI]++] = c[fI]; + } + + if( nFacesInCell_[cellI] < c.size() ) + { + newC.setSize(nFacesInCell_[cellI]); + + cells_[cellI] = newC; + }; + } + + PtrList<writePatch>& boundaries = meshModifier_.boundariesAccess(); + boundaries.setSize(1); + boundaries[0].patchSize() = 0; + meshModifier_.facesAccess().setSize(boundaries[0].patchStart()); } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/meshLibrary/utilities/surfaceTools/meshSurfaceEdgeExtractor/meshSurfaceEdgeExtractor.H b/meshLibrary/utilities/surfaceTools/meshSurfaceEdgeExtractor/meshSurfaceEdgeExtractor.H index 8ba457ea..23e378d3 100644 --- a/meshLibrary/utilities/surfaceTools/meshSurfaceEdgeExtractor/meshSurfaceEdgeExtractor.H +++ b/meshLibrary/utilities/surfaceTools/meshSurfaceEdgeExtractor/meshSurfaceEdgeExtractor.H @@ -55,14 +55,14 @@ class meshSurfaceEngine; class meshSurfaceEdgeExtractor { // Private data - //- mesh - polyMeshGen& mesh_; - - label nPoints_; - - boolList boundaryCell_; - - List<direction> nFacesInCell_; + //- mesh + polyMeshGen& mesh_; + + label nPoints_; + + boolList boundaryCell_; + + List<direction> nFacesInCell_; //- reference to the octree const meshOctree& meshOctree_; @@ -71,14 +71,14 @@ class meshSurfaceEdgeExtractor VRWGraph pointRegions_; // Private member functions - //- remove old boundary faces - void removeOldBoundaryFaces(); - + //- remove old boundary faces + void removeOldBoundaryFaces(); + //- create vertices on surface edges void createEdgeVertices(); - - //- create new boundary faces - void createBoundaryFaces(); + + //- create new boundary faces + void createBoundaryFaces(); //- Disallow default bitwise copy construct meshSurfaceEdgeExtractor(const meshSurfaceEdgeExtractor&); @@ -93,9 +93,9 @@ public: //- Construct from mesh data meshSurfaceEdgeExtractor ( - polyMeshGen& mesh, + polyMeshGen& mesh, const meshOctree& octree, - const labelList& pointRegion + const labelList& pointRegion ); // Destructor diff --git a/meshLibrary/utilities/surfaceTools/meshSurfaceEdgeExtractorNonTopo/meshSurfaceEdgeExtractorNonTopo.C b/meshLibrary/utilities/surfaceTools/meshSurfaceEdgeExtractorNonTopo/meshSurfaceEdgeExtractorNonTopo.C index 8cfa3503..89845f3b 100644 --- a/meshLibrary/utilities/surfaceTools/meshSurfaceEdgeExtractorNonTopo/meshSurfaceEdgeExtractorNonTopo.C +++ b/meshLibrary/utilities/surfaceTools/meshSurfaceEdgeExtractorNonTopo/meshSurfaceEdgeExtractorNonTopo.C @@ -43,18 +43,18 @@ namespace Foam // Construct from mesh, octree, regions for boundary vertices meshSurfaceEdgeExtractorNonTopo::meshSurfaceEdgeExtractorNonTopo ( - polyMeshGen& mesh, - const meshOctree& octree + polyMeshGen& mesh, + const meshOctree& octree ) : - mesh_(mesh), - meshOctree_(octree) -{ - distributeBoundaryFaces(); + mesh_(mesh), + meshOctree_(octree) +{ + distributeBoundaryFaces(); correctEdgesBetweenPatches featureEdges(mesh); - - remapBoundaryPoints(); + + remapBoundaryPoints(); } // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // diff --git a/meshLibrary/utilities/surfaceTools/meshSurfaceEdgeExtractorNonTopo/meshSurfaceEdgeExtractorNonTopo.H b/meshLibrary/utilities/surfaceTools/meshSurfaceEdgeExtractorNonTopo/meshSurfaceEdgeExtractorNonTopo.H index e6ffae5d..4e117436 100644 --- a/meshLibrary/utilities/surfaceTools/meshSurfaceEdgeExtractorNonTopo/meshSurfaceEdgeExtractorNonTopo.H +++ b/meshLibrary/utilities/surfaceTools/meshSurfaceEdgeExtractorNonTopo/meshSurfaceEdgeExtractorNonTopo.H @@ -55,19 +55,19 @@ class meshSurfaceEngine; class meshSurfaceEdgeExtractorNonTopo { // Private data - //- mesh - polyMeshGen& mesh_; - - //- octree - const meshOctree& meshOctree_; + //- mesh + polyMeshGen& mesh_; + + //- octree + const meshOctree& meshOctree_; // Private member functions - - //- distribute boundary faces into patches - void distributeBoundaryFaces(); - - //- re-map points after edges have been extracted - void remapBoundaryPoints(); + + //- distribute boundary faces into patches + void distributeBoundaryFaces(); + + //- re-map points after edges have been extracted + void remapBoundaryPoints(); //- Disallow default bitwise copy construct meshSurfaceEdgeExtractorNonTopo(const meshSurfaceEdgeExtractorNonTopo&); @@ -82,7 +82,7 @@ public: //- Construct from mesh data meshSurfaceEdgeExtractorNonTopo ( - polyMeshGen& mesh, + polyMeshGen& mesh, const meshOctree& octree ); diff --git a/meshLibrary/utilities/surfaceTools/meshSurfaceEdgeExtractorNonTopo/meshSurfaceEdgeExtractorNonTopoDistributeFaces.C b/meshLibrary/utilities/surfaceTools/meshSurfaceEdgeExtractorNonTopo/meshSurfaceEdgeExtractorNonTopoDistributeFaces.C index 849b9c5c..1cfba1e6 100644 --- a/meshLibrary/utilities/surfaceTools/meshSurfaceEdgeExtractorNonTopo/meshSurfaceEdgeExtractorNonTopoDistributeFaces.C +++ b/meshLibrary/utilities/surfaceTools/meshSurfaceEdgeExtractorNonTopo/meshSurfaceEdgeExtractorNonTopoDistributeFaces.C @@ -47,24 +47,24 @@ namespace Foam void meshSurfaceEdgeExtractorNonTopo::distributeBoundaryFaces() { - meshSurfaceEngine mse(mesh_); - - const faceList::subList& bFaces = mse.boundaryFaces(); - const labelList& faceOwner = mse.faceOwners(); - const pointFieldPMG& points = mse.points(); - - //- set size of patchNames, newBoundaryFaces_ and newBoundaryOwners_ - const triSurface& surface = meshOctree_.surface(); - const label nPatches = surface.patches().size(); - - wordList patchNames(nPatches); - VRWGraph newBoundaryFaces; - labelListPMG newBoundaryOwners(bFaces.size()); - labelListPMG newBoundaryPatches(bFaces.size()); - - //- set patchNames - forAll(surface.patches(), patchI) - patchNames[patchI] = surface.patches()[patchI].name(); + meshSurfaceEngine mse(mesh_); + + const faceList::subList& bFaces = mse.boundaryFaces(); + const labelList& faceOwner = mse.faceOwners(); + const pointFieldPMG& points = mse.points(); + + //- set size of patchNames, newBoundaryFaces_ and newBoundaryOwners_ + const triSurface& surface = meshOctree_.surface(); + const label nPatches = surface.patches().size(); + + wordList patchNames(nPatches); + VRWGraph newBoundaryFaces; + labelListPMG newBoundaryOwners(bFaces.size()); + labelListPMG newBoundaryPatches(bFaces.size()); + + //- set patchNames + forAll(surface.patches(), patchI) + patchNames[patchI] = surface.patches()[patchI].name(); //- append boundary faces forAll(bFaces, bfI) @@ -72,42 +72,42 @@ void meshSurfaceEdgeExtractorNonTopo::distributeBoundaryFaces() newBoundaryFaces.appendList(bFaces[bfI]); newBoundaryOwners[bfI] = faceOwner[bfI]; } - - //- find the region for face by finding the patch nearest - //- to the face centre + + //- find the region for face by finding the patch nearest + //- to the face centre # pragma omp parallel for if( bFaces.size() > 100 ) schedule(guided) - forAll(bFaces, bfI) - { - const point c = bFaces[bfI].centre(points); + forAll(bFaces, bfI) + { + const point c = bFaces[bfI].centre(points); label facePatch; point p; scalar distSq; - - meshOctree_.findNearestSurfacePoint(p, distSq, facePatch, c); - - if( (facePatch > -1) && (facePatch < nPatches) ) - { - newBoundaryPatches[bfI] = facePatch; - } - else - { - FatalErrorIn - ( - "void meshSurfaceEdgeExtractorNonTopo::" - "distributeBoundaryFaces()" - ) << "Cannot distribute a face " << bFaces[bfI] << " into any " - << "surface patch!. Exiting.." << exit(FatalError); - } - } - - polyMeshGenModifier(mesh_).replaceBoundary - ( - patchNames, - newBoundaryFaces, - newBoundaryOwners, - newBoundaryPatches - ); + + meshOctree_.findNearestSurfacePoint(p, distSq, facePatch, c); + + if( (facePatch > -1) && (facePatch < nPatches) ) + { + newBoundaryPatches[bfI] = facePatch; + } + else + { + FatalErrorIn + ( + "void meshSurfaceEdgeExtractorNonTopo::" + "distributeBoundaryFaces()" + ) << "Cannot distribute a face " << bFaces[bfI] << " into any " + << "surface patch!. Exiting.." << exit(FatalError); + } + } + + polyMeshGenModifier(mesh_).replaceBoundary + ( + patchNames, + newBoundaryFaces, + newBoundaryOwners, + newBoundaryPatches + ); } void meshSurfaceEdgeExtractorNonTopo::remapBoundaryPoints() diff --git a/meshLibrary/utilities/surfaceTools/meshSurfaceEngine/meshSurfaceEngine.C b/meshLibrary/utilities/surfaceTools/meshSurfaceEngine/meshSurfaceEngine.C index 1e3cd6e8..01afde37 100644 --- a/meshLibrary/utilities/surfaceTools/meshSurfaceEngine/meshSurfaceEngine.C +++ b/meshLibrary/utilities/surfaceTools/meshSurfaceEngine/meshSurfaceEngine.C @@ -43,10 +43,10 @@ namespace Foam // Construct from surface. Holds reference! meshSurfaceEngine::meshSurfaceEngine(polyMeshGen& mesh) : - mesh_(mesh), + mesh_(mesh), boundaryPointsPtr_(NULL), boundaryFacesPtr_(NULL), - boundaryFacePatchPtr_(NULL), + boundaryFacePatchPtr_(NULL), boundaryFaceOwnersPtr_(NULL), pointFacesPtr_(NULL), pointInFacePtr_(NULL), @@ -56,10 +56,10 @@ meshSurfaceEngine::meshSurfaceEngine(polyMeshGen& mesh) edgesPtr_(NULL), bpEdgesPtr_(NULL), edgeFacesPtr_(NULL), - faceEdgesPtr_(NULL), - faceFacesPtr_(NULL), + faceEdgesPtr_(NULL), + faceFacesPtr_(NULL), pointNormalsPtr_(NULL), - faceNormalsPtr_(NULL), + faceNormalsPtr_(NULL), faceCentresPtr_(NULL), globalBoundaryPointLabelPtr_(NULL), @@ -75,7 +75,7 @@ meshSurfaceEngine::meshSurfaceEngine(polyMeshGen& mesh) globalBoundaryFaceLabelPtr_(NULL) { calculateBoundaryFaces(); - calculateBoundaryNodes(); + calculateBoundaryNodes(); } // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // @@ -110,7 +110,7 @@ const cellListPMG& meshSurfaceEngine::cells() const const labelList& meshSurfaceEngine::bp() const { if( !bppPtr_ ) - { + { # ifdef FULLDEBUG if( omp_in_parallel() ) FatalErrorIn @@ -121,8 +121,8 @@ const labelList& meshSurfaceEngine::bp() const # endif calculateBoundaryFaces(); - calculateBoundaryNodes(); - } + calculateBoundaryNodes(); + } return *bppPtr_; } @@ -130,7 +130,7 @@ const labelList& meshSurfaceEngine::bp() const const labelList& meshSurfaceEngine::boundaryPoints() const { if( !boundaryPointsPtr_ ) - { + { # ifdef FULLDEBUG if( omp_in_parallel() ) FatalErrorIn @@ -140,8 +140,8 @@ const labelList& meshSurfaceEngine::boundaryPoints() const << " This is not thread safe" << exit(FatalError); # endif - calculateBoundaryNodes(); - } + calculateBoundaryNodes(); + } return *boundaryPointsPtr_; } @@ -149,7 +149,7 @@ const labelList& meshSurfaceEngine::boundaryPoints() const const faceList::subList& meshSurfaceEngine::boundaryFaces() const { if( !boundaryFacesPtr_ ) - { + { # ifdef FULLDEBUG if( omp_in_parallel() ) FatalErrorIn @@ -161,14 +161,14 @@ const faceList::subList& meshSurfaceEngine::boundaryFaces() const # endif calculateBoundaryFaces(); - } + } return *boundaryFacesPtr_; } const labelList& meshSurfaceEngine::boundaryFacePatches() const { - if( !boundaryFacePatchPtr_ ) + if( !boundaryFacePatchPtr_ ) { # ifdef FULLDEBUG if( omp_in_parallel() ) @@ -180,16 +180,16 @@ const labelList& meshSurfaceEngine::boundaryFacePatches() const << " This is not thread safe" << exit(FatalError); # endif - calculateBoundaryFacePatches(); + calculateBoundaryFacePatches(); } - - return *boundaryFacePatchPtr_; + + return *boundaryFacePatchPtr_; } const labelList& meshSurfaceEngine::faceOwners() const { if( !boundaryFaceOwnersPtr_ ) - { + { # ifdef FULLDEBUG if( omp_in_parallel() ) FatalErrorIn @@ -199,8 +199,8 @@ const labelList& meshSurfaceEngine::faceOwners() const << " This is not thread safe" << exit(FatalError); # endif - calculateBoundaryOwners(); - } + calculateBoundaryOwners(); + } return *boundaryFaceOwnersPtr_; } @@ -302,7 +302,7 @@ const vectorField& meshSurfaceEngine::pointNormals() const const vectorField& meshSurfaceEngine::faceNormals() const { - if( !faceNormalsPtr_ ) + if( !faceNormalsPtr_ ) { # ifdef FULLDEBUG if( omp_in_parallel() ) @@ -313,10 +313,10 @@ const vectorField& meshSurfaceEngine::faceNormals() const << " This is not thread safe" << exit(FatalError); # endif - calculateFaceNormals(); + calculateFaceNormals(); } - - return *faceNormalsPtr_; + + return *faceNormalsPtr_; } const vectorField& meshSurfaceEngine::faceCentres() const @@ -653,7 +653,7 @@ void meshSurfaceEngine::clearOut() { deleteDemandDrivenData(boundaryPointsPtr_); deleteDemandDrivenData(boundaryFacesPtr_); - deleteDemandDrivenData(boundaryFacePatchPtr_); + deleteDemandDrivenData(boundaryFacePatchPtr_); deleteDemandDrivenData(boundaryFaceOwnersPtr_); deleteDemandDrivenData(pointFacesPtr_); deleteDemandDrivenData(pointInFacePtr_); @@ -661,13 +661,13 @@ void meshSurfaceEngine::clearOut() deleteDemandDrivenData(bppPtr_); deleteDemandDrivenData(pointPointsPtr_); deleteDemandDrivenData(pointNormalsPtr_); - deleteDemandDrivenData(faceNormalsPtr_); + deleteDemandDrivenData(faceNormalsPtr_); deleteDemandDrivenData(faceCentresPtr_); deleteDemandDrivenData(edgesPtr_); deleteDemandDrivenData(bpEdgesPtr_); deleteDemandDrivenData(edgeFacesPtr_); - deleteDemandDrivenData(faceEdgesPtr_); - deleteDemandDrivenData(faceFacesPtr_); + deleteDemandDrivenData(faceEdgesPtr_); + deleteDemandDrivenData(faceFacesPtr_); deleteDemandDrivenData(globalBoundaryPointLabelPtr_); deleteDemandDrivenData(globalBoundaryPointToLocalPtr_); diff --git a/meshLibrary/utilities/surfaceTools/meshSurfaceEngine/meshSurfaceEngine.H b/meshLibrary/utilities/surfaceTools/meshSurfaceEngine/meshSurfaceEngine.H index 497bb6de..579ff728 100644 --- a/meshLibrary/utilities/surfaceTools/meshSurfaceEngine/meshSurfaceEngine.H +++ b/meshLibrary/utilities/surfaceTools/meshSurfaceEngine/meshSurfaceEngine.H @@ -57,16 +57,16 @@ class meshSurfaceEngine { // Private data //- mesh - polyMeshGen& mesh_; + polyMeshGen& mesh_; //- boundary points mutable labelList* boundaryPointsPtr_; //- boundary faces mutable faceList::subList* boundaryFacesPtr_; - - //- patches boundary faces are in - mutable labelList* boundaryFacePatchPtr_; + + //- patches boundary faces are in + mutable labelList* boundaryFacePatchPtr_; //- face owners mutable labelList* boundaryFaceOwnersPtr_; @@ -92,18 +92,18 @@ class meshSurfaceEngine //- edge faces addressing mutable VRWGraph* edgeFacesPtr_; - - //- face edges addressing - mutable VRWGraph* faceEdgesPtr_; - - //- face-faces addressing - mutable VRWGraph* faceFacesPtr_; + + //- face edges addressing + mutable VRWGraph* faceEdgesPtr_; + + //- face-faces addressing + mutable VRWGraph* faceFacesPtr_; //- point normals mutable vectorField* pointNormalsPtr_; - - //- face normals - mutable vectorField* faceNormalsPtr_; + + //- face normals + mutable vectorField* faceNormalsPtr_; //- face centres mutable vectorField* faceCentresPtr_; @@ -145,10 +145,10 @@ class meshSurfaceEngine //- calculate boundary nodes, faces and addressing void calculateBoundaryFaces() const; - void calculateBoundaryOwners() const; - void calculateBoundaryNodes() const; - - void calculateBoundaryFacePatches() const; + void calculateBoundaryOwners() const; + void calculateBoundaryNodes() const; + + void calculateBoundaryFacePatches() const; void calculatePointFaces() const; @@ -157,15 +157,15 @@ class meshSurfaceEngine void calculatePointPoints() const; void calculatePointNormals() const; - void calculateFaceNormals() const; + void calculateFaceNormals() const; void calculateFaceCentres() const; void updatePointNormalsAtProcBoundaries() const; void calculateEdgesAndAddressing() const; void calculateFaceEdgesAddressing() const; - void calculateEdgeFacesAddressing() const; - void calculateFaceFacesAddressing() const; + void calculateEdgeFacesAddressing() const; + void calculateFaceFacesAddressing() const; // Private member functions for parallel runs @@ -186,8 +186,8 @@ class meshSurfaceEngine public: - friend class meshSurfaceEngineModifier; - + friend class meshSurfaceEngineModifier; + // Constructors //- Construct from mesh @@ -206,9 +206,9 @@ public: const labelList& boundaryPoints() const; const faceList::subList& boundaryFaces() const; - - //- patch label for each boundary face - const labelList& boundaryFacePatches() const; + + //- patch label for each boundary face + const labelList& boundaryFacePatches() const; const labelList& faceOwners() const; @@ -220,8 +220,8 @@ public: const VRWGraph& pointPoints() const; const vectorField& pointNormals() const; - - const vectorField& faceNormals() const; + + const vectorField& faceNormals() const; const vectorField& faceCentres() const; @@ -232,10 +232,10 @@ public: const VRWGraph& boundaryPointEdges() const; const VRWGraph& edgeFaces() const; - - const VRWGraph& faceEdges() const; - - const VRWGraph& faceFaces() const; + + const VRWGraph& faceEdges() const; + + const VRWGraph& faceFaces() const; // Functions for parallel runs //- global boundary point label diff --git a/meshLibrary/utilities/surfaceTools/meshSurfaceEngine/meshSurfaceEngineCalculateBoundaryNodesAndFaces.C b/meshLibrary/utilities/surfaceTools/meshSurfaceEngine/meshSurfaceEngineCalculateBoundaryNodesAndFaces.C index 96088476..ffd6aafb 100644 --- a/meshLibrary/utilities/surfaceTools/meshSurfaceEngine/meshSurfaceEngineCalculateBoundaryNodesAndFaces.C +++ b/meshLibrary/utilities/surfaceTools/meshSurfaceEngine/meshSurfaceEngineCalculateBoundaryNodesAndFaces.C @@ -48,34 +48,34 @@ namespace Foam void meshSurfaceEngine::calculateBoundaryFaces() const { - if( mesh_.boundaries().size() != 0 ) - { - const faceListPMG& faces = mesh_.faces(); - const PtrList<writePatch>& boundaries = mesh_.boundaries(); + if( mesh_.boundaries().size() != 0 ) + { + const faceListPMG& faces = mesh_.faces(); + const PtrList<writePatch>& boundaries = mesh_.boundaries(); label nBoundaryFaces(0); forAll(boundaries, patchI) nBoundaryFaces += boundaries[patchI].patchSize(); - boundaryFacesPtr_ = - new faceList::subList - ( - faces, - nBoundaryFaces, - boundaries[0].patchStart() - ); + boundaryFacesPtr_ = + new faceList::subList + ( + faces, + nBoundaryFaces, + boundaries[0].patchStart() + ); reduce(nBoundaryFaces, sumOp<label>()); Info << "Found " << nBoundaryFaces << " boundary faces " << endl; - } - else - { - FatalErrorIn - ( - "void meshSurfaceEngine::calculateBoundaryFaces() const" - ) << "Boundary faces are not at the end of the face list!" - << exit(FatalError); - } + } + else + { + FatalErrorIn + ( + "void meshSurfaceEngine::calculateBoundaryFaces() const" + ) << "Boundary faces are not at the end of the face list!" + << exit(FatalError); + } } void meshSurfaceEngine::calculateBoundaryOwners() const @@ -85,7 +85,7 @@ void meshSurfaceEngine::calculateBoundaryOwners() const const faceList::subList& boundaryFaces = this->boundaryFaces(); if( !boundaryFaceOwnersPtr_ ) - boundaryFaceOwnersPtr_ = new labelList(boundaryFaces.size()); + boundaryFaceOwnersPtr_ = new labelList(boundaryFaces.size()); labelList& owners = *boundaryFaceOwnersPtr_; @@ -93,7 +93,7 @@ void meshSurfaceEngine::calculateBoundaryOwners() const # pragma omp parallel for schedule(static, 1) forAll(boundaryFaces, fI) - owners[fI] = owner[start+fI]; + owners[fI] = owner[start+fI]; } void meshSurfaceEngine::calculateBoundaryNodes() const @@ -662,15 +662,15 @@ void meshSurfaceEngine::calculatePointNormals() const forAllRow(pFaces, pI, pfI) normal += fNormals[pFaces(pI, pfI)]; - const scalar d = mag(normal); - if( d > VSMALL ) - { - normal /= d; - } - else - { - normal = vector::zero; - } + const scalar d = mag(normal); + if( d > VSMALL ) + { + normal /= d; + } + else + { + normal = vector::zero; + } (*pointNormalsPtr_)[pI] = normal; } @@ -680,19 +680,19 @@ void meshSurfaceEngine::calculatePointNormals() const void meshSurfaceEngine::calculateFaceNormals() const { - const faceList::subList& bFaces = this->boundaryFaces(); - const pointFieldPMG& points = mesh_.points(); + const faceList::subList& bFaces = this->boundaryFaces(); + const pointFieldPMG& points = mesh_.points(); - faceNormalsPtr_ = new vectorField(bFaces.size()); + faceNormalsPtr_ = new vectorField(bFaces.size()); const label size = bFaces.size(); - # pragma omp parallel for if( size > 1000 ) + # pragma omp parallel for if( size > 1000 ) for(label bfI=0;bfI<size;++bfI) - { - const face& bf = bFaces[bfI]; + { + const face& bf = bFaces[bfI]; - faceNormalsPtr_->operator[](bfI) = bf.normal(points); - } + faceNormalsPtr_->operator[](bfI) = bf.normal(points); + } } void meshSurfaceEngine::calculateFaceCentres() const @@ -700,12 +700,12 @@ void meshSurfaceEngine::calculateFaceCentres() const const faceList::subList& bFaces = this->boundaryFaces(); const pointFieldPMG& points = mesh_.points(); - faceCentresPtr_ = new vectorField(bFaces.size()); + faceCentresPtr_ = new vectorField(bFaces.size()); const label size = bFaces.size(); - # pragma omp parallel for if( size > 1000 ) + # pragma omp parallel for if( size > 1000 ) for(label bfI=0;bfI<size;++bfI) - faceCentresPtr_->operator[](bfI) = bFaces[bfI].centre(points); + faceCentresPtr_->operator[](bfI) = bFaces[bfI].centre(points); } void meshSurfaceEngine::updatePointNormalsAtProcBoundaries() const @@ -923,11 +923,11 @@ void meshSurfaceEngine::calculateEdgesAndAddressing() const } OPstream toOtherProc - ( + ( Pstream::blocking, - procBoundaries[patchI].neiProcNo(), - dts.byteSize() - ); + procBoundaries[patchI].neiProcNo(), + dts.byteSize() + ); toOtherProc << dts; } @@ -988,7 +988,7 @@ void meshSurfaceEngine::calculateFaceEdgesAddressing() const const VRWGraph& pointFaces = this->pointFaces(); faceEdgesPtr_ = new VRWGraph(bFaces.size()); - VRWGraph& faceEdges = *faceEdgesPtr_; + VRWGraph& faceEdges = *faceEdgesPtr_; labelList nfe(bFaces.size()); @@ -1034,7 +1034,7 @@ void meshSurfaceEngine::calculateFaceEdgesAddressing() const void meshSurfaceEngine::calculateEdgeFacesAddressing() const { const faceList::subList& bFaces = this->boundaryFaces(); - const VRWGraph& pointFaces = this->pointFaces(); + const VRWGraph& pointFaces = this->pointFaces(); const edgeList& edges = this->edges(); const labelList& bp = this->bp(); @@ -1111,19 +1111,19 @@ void meshSurfaceEngine::calculateEdgeFacesAddressing() const void meshSurfaceEngine::calculateFaceFacesAddressing() const { - const VRWGraph& edgeFaces = this->edgeFaces(); + const VRWGraph& edgeFaces = this->edgeFaces(); - const faceList::subList& bFaces = boundaryFaces(); - faceFacesPtr_ = new VRWGraph(bFaces.size()); - VRWGraph& faceFaces = *faceFacesPtr_; + const faceList::subList& bFaces = boundaryFaces(); + faceFacesPtr_ = new VRWGraph(bFaces.size()); + VRWGraph& faceFaces = *faceFacesPtr_; - forAll(bFaces, bfI) - faceFaces.setRowSize(bfI, bFaces[bfI].size()); + forAll(bFaces, bfI) + faceFaces.setRowSize(bfI, bFaces[bfI].size()); - labelList nAppearances(bFaces.size(), 0); + labelList nAppearances(bFaces.size(), 0); - forAll(edgeFaces, efI) - { + forAll(edgeFaces, efI) + { if( edgeFaces.sizeOfRow(efI) == 2 ) { const label f0 = edgeFaces(efI, 0); @@ -1137,17 +1137,17 @@ void meshSurfaceEngine::calculateFaceFacesAddressing() const const label f0 = edgeFaces(efI, 0); faceFaces(f0, nAppearances[f0]++) = -1; } - else if( Pstream::parRun() && (edgeFaces.sizeOfRow(efI) != 0 ) ) - { - FatalErrorIn - ( - "void meshSurfaceEngine::calculateFaceFacesAddressing() const" - ) << "The surface of the mesh is invalid!" - << " The number of faces containing edge " << efI - << " is " << edgeFaces.sizeOfRow(efI) + else if( Pstream::parRun() && (edgeFaces.sizeOfRow(efI) != 0 ) ) + { + FatalErrorIn + ( + "void meshSurfaceEngine::calculateFaceFacesAddressing() const" + ) << "The surface of the mesh is invalid!" + << " The number of faces containing edge " << efI + << " is " << edgeFaces.sizeOfRow(efI) << " Cannot continue" << exit(FatalError); - } - } + } + } } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/meshLibrary/utilities/surfaceTools/meshSurfaceEngine/meshSurfaceEngineModifier.C b/meshLibrary/utilities/surfaceTools/meshSurfaceEngine/meshSurfaceEngineModifier.C index b8f1fb2e..f3539ef1 100644 --- a/meshLibrary/utilities/surfaceTools/meshSurfaceEngine/meshSurfaceEngineModifier.C +++ b/meshLibrary/utilities/surfaceTools/meshSurfaceEngine/meshSurfaceEngineModifier.C @@ -45,19 +45,19 @@ namespace Foam // Construct from meshSurfaceEngine. Holds reference! meshSurfaceEngineModifier::meshSurfaceEngineModifier ( - meshSurfaceEngine& surfaceEngine + meshSurfaceEngine& surfaceEngine ) : - surfaceEngine_(surfaceEngine) + surfaceEngine_(surfaceEngine) { } meshSurfaceEngineModifier::meshSurfaceEngineModifier ( - const meshSurfaceEngine& surfaceEngine + const meshSurfaceEngine& surfaceEngine ) : - surfaceEngine_(const_cast<meshSurfaceEngine&>(surfaceEngine)) + surfaceEngine_(const_cast<meshSurfaceEngine&>(surfaceEngine)) { } @@ -71,11 +71,11 @@ meshSurfaceEngineModifier::~meshSurfaceEngineModifier() void meshSurfaceEngineModifier::moveBoundaryVertexNoUpdate ( - const label bpI, - const point& newP + const label bpI, + const point& newP ) { - surfaceEngine_.mesh_.points()[surfaceEngine_.boundaryPoints()[bpI]] = newP; + surfaceEngine_.mesh_.points()[surfaceEngine_.boundaryPoints()[bpI]] = newP; } void meshSurfaceEngineModifier::moveBoundaryVertex @@ -86,13 +86,13 @@ void meshSurfaceEngineModifier::moveBoundaryVertex { const labelList& bPoints = surfaceEngine_.boundaryPoints(); pointFieldPMG& points = surfaceEngine_.mesh_.points(); - points[bPoints[bpI]] = newP; + points[bPoints[bpI]] = newP; if( surfaceEngine_.faceCentresPtr_ ) { vectorField& faceCentres = *surfaceEngine_.faceCentresPtr_; const VRWGraph& pFaces = surfaceEngine_.pointFaces(); - const faceList::subList& bFaces = surfaceEngine_.boundaryFaces(); + const faceList::subList& bFaces = surfaceEngine_.boundaryFaces(); forAllRow(pFaces, bpI, pfI) { @@ -106,7 +106,7 @@ void meshSurfaceEngineModifier::moveBoundaryVertex { vectorField& faceNormals = *surfaceEngine_.faceNormalsPtr_; const VRWGraph& pFaces = surfaceEngine_.pointFaces(); - const faceList::subList& bFaces = surfaceEngine_.boundaryFaces(); + const faceList::subList& bFaces = surfaceEngine_.boundaryFaces(); forAllRow(pFaces, bpI, pfI) { @@ -117,49 +117,49 @@ void meshSurfaceEngineModifier::moveBoundaryVertex } if( surfaceEngine_.pointNormalsPtr_ ) - { + { const vectorField& faceNormals = *surfaceEngine_.faceNormalsPtr_; - const VRWGraph& pFaces = surfaceEngine_.pointFaces(); - const VRWGraph& pPoints = surfaceEngine_.pointPoints(); - - vectorField& pn = *surfaceEngine_.pointNormalsPtr_; - vector n(vector::zero); - forAllRow(pFaces, bpI, pfI) - n += faceNormals[pFaces(bpI, pfI)]; - - const scalar l = mag(n); - if( l > VSMALL ) - { - n /= l; - } - else - { - n = vector::zero; - } - - pn[bpI] = n; - - //- change normal of vertices connected to bpI - forAllRow(pPoints, bpI, ppI) - { - const label bpJ = pPoints(bpI, ppI); - n = vector::zero; - forAllRow(pFaces, bpJ, pfI) - n += faceNormals[pFaces(bpJ, pfI)]; - - const scalar d = mag(n); - if( d > VSMALL ) - { - n /= d; - } - else - { - n = vector::zero; - } - - pn[bpJ] = n; - } - } + const VRWGraph& pFaces = surfaceEngine_.pointFaces(); + const VRWGraph& pPoints = surfaceEngine_.pointPoints(); + + vectorField& pn = *surfaceEngine_.pointNormalsPtr_; + vector n(vector::zero); + forAllRow(pFaces, bpI, pfI) + n += faceNormals[pFaces(bpI, pfI)]; + + const scalar l = mag(n); + if( l > VSMALL ) + { + n /= l; + } + else + { + n = vector::zero; + } + + pn[bpI] = n; + + //- change normal of vertices connected to bpI + forAllRow(pPoints, bpI, ppI) + { + const label bpJ = pPoints(bpI, ppI); + n = vector::zero; + forAllRow(pFaces, bpJ, pfI) + n += faceNormals[pFaces(bpJ, pfI)]; + + const scalar d = mag(n); + if( d > VSMALL ) + { + n /= d; + } + else + { + n = vector::zero; + } + + pn[bpJ] = n; + } + } } void meshSurfaceEngineModifier::syncVerticesAtParallelBoundaries() @@ -253,7 +253,7 @@ void meshSurfaceEngineModifier::updateGeometry if( surfaceEngine_.faceCentresPtr_ ) { vectorField& faceCentres = *surfaceEngine_.faceCentresPtr_; - + size = updateFaces.size(); # pragma omp parallel for if( size > 1000 ) schedule(dynamic, 100) for(label bfI=0;bfI<size;++bfI) @@ -277,11 +277,11 @@ void meshSurfaceEngineModifier::updateGeometry } if( surfaceEngine_.pointNormalsPtr_ ) - { + { const vectorField& faceNormals = surfaceEngine_.faceNormals(); - const VRWGraph& pFaces = surfaceEngine_.pointFaces(); - - vectorField& pn = *surfaceEngine_.pointNormalsPtr_; + const VRWGraph& pFaces = surfaceEngine_.pointFaces(); + + vectorField& pn = *surfaceEngine_.pointNormalsPtr_; size = updateBndNodes.size(); # pragma omp parallel for if( size > 1000 ) schedule(dynamic, 100) for(label i=0;i<size;++i) @@ -291,7 +291,7 @@ void meshSurfaceEngineModifier::updateGeometry vector n(vector::zero); forAllRow(pFaces, bpI, pfI) n += faceNormals[pFaces(bpI, pfI)]; - + const scalar l = mag(n); if( l > VSMALL ) { @@ -301,10 +301,10 @@ void meshSurfaceEngineModifier::updateGeometry { n = vector::zero; } - + pn[bpI] = n; } - } + } } void meshSurfaceEngineModifier::updateGeometry() diff --git a/meshLibrary/utilities/surfaceTools/meshSurfaceEngine/meshSurfaceEngineModifier.H b/meshLibrary/utilities/surfaceTools/meshSurfaceEngine/meshSurfaceEngineModifier.H index 14adb707..74d13d57 100644 --- a/meshLibrary/utilities/surfaceTools/meshSurfaceEngine/meshSurfaceEngineModifier.H +++ b/meshLibrary/utilities/surfaceTools/meshSurfaceEngine/meshSurfaceEngineModifier.H @@ -44,14 +44,14 @@ namespace Foam { /*---------------------------------------------------------------------------*\ - Class meshSurfaceEngineModifier Declaration + Class meshSurfaceEngineModifier Declaration \*---------------------------------------------------------------------------*/ class meshSurfaceEngineModifier { // Private data //- reference to the meshSurfaceEngine - meshSurfaceEngine& surfaceEngine_; + meshSurfaceEngine& surfaceEngine_; //- Disallow default bitwise copy construct meshSurfaceEngineModifier(const meshSurfaceEngineModifier&); @@ -60,26 +60,26 @@ class meshSurfaceEngineModifier void operator=(const meshSurfaceEngineModifier&); public: - + // Constructors //- Construct from reference to meshSurfaceEngine meshSurfaceEngineModifier(meshSurfaceEngine& surfaceEngine); - //- Construct from const reference to meshSurfaceEngine - meshSurfaceEngineModifier(const meshSurfaceEngine& surfaceEngine); + //- Construct from const reference to meshSurfaceEngine + meshSurfaceEngineModifier(const meshSurfaceEngine& surfaceEngine); // Destructor ~meshSurfaceEngineModifier(); // Member Functions - - //- relocate the selected boundary vertex - void moveBoundaryVertexNoUpdate(const label bpI, const point& newP); - + + //- relocate the selected boundary vertex + void moveBoundaryVertexNoUpdate(const label bpI, const point& newP); + //- relocate the selected boundary vertex and update geometry data - void moveBoundaryVertex(const label bpI, const point& newP); + void moveBoundaryVertex(const label bpI, const point& newP); //- update normals of boundary vertices at processor boundaries inline void updateVertexNormals() diff --git a/meshLibrary/utilities/surfaceTools/meshSurfaceEngine/meshSurfaceEngineParallelAddressing.C b/meshLibrary/utilities/surfaceTools/meshSurfaceEngine/meshSurfaceEngineParallelAddressing.C index 2d773de4..3aa9973d 100644 --- a/meshLibrary/utilities/surfaceTools/meshSurfaceEngine/meshSurfaceEngineParallelAddressing.C +++ b/meshLibrary/utilities/surfaceTools/meshSurfaceEngine/meshSurfaceEngineParallelAddressing.C @@ -134,11 +134,11 @@ void meshSurfaceEngine::calcGlobalBoundaryPointLabels() const } OPstream toOtherProc - ( + ( Pstream::blocking, - procBoundaries[patchI].neiProcNo(), - dts.byteSize() - ); + procBoundaries[patchI].neiProcNo(), + dts.byteSize() + ); toOtherProc << dts; } @@ -249,11 +249,11 @@ void meshSurfaceEngine::calcGlobalBoundaryPointLabels() const } OPstream toOtherProc - ( + ( Pstream::blocking, - procBoundaries[patchI].neiProcNo(), - dts.byteSize() - ); + procBoundaries[patchI].neiProcNo(), + dts.byteSize() + ); toOtherProc << dts; } @@ -288,11 +288,11 @@ void meshSurfaceEngine::calcGlobalBoundaryPointLabels() const "void meshSurfaceEngine::" "calcGlobalBoundaryPointLabels() const" ) << "Point labels in proc boundary " - << procBoundaries[patchI].patchName() - << " face " << f << " pI = " << pI - << nl << " label " << globalPointLabel[bp[f[pI]]] - << nl << " other global label " << globalLabel - << " do not match!" << abort(FatalError); + << procBoundaries[patchI].patchName() + << " face " << f << " pI = " << pI + << nl << " label " << globalPointLabel[bp[f[pI]]] + << nl << " other global label " << globalLabel + << " do not match!" << abort(FatalError); } } } @@ -441,11 +441,11 @@ void meshSurfaceEngine::calcGlobalBoundaryEdgeLabels() const } OPstream toOtherProc - ( + ( Pstream::blocking, - procBoundaries[patchI].neiProcNo(), - dts.byteSize() - ); + procBoundaries[patchI].neiProcNo(), + dts.byteSize() + ); toOtherProc << dts; } @@ -571,11 +571,11 @@ void meshSurfaceEngine::calcGlobalBoundaryEdgeLabels() const } OPstream toOtherProc - ( + ( Pstream::blocking, - procBoundaries[patchI].neiProcNo(), - dts.byteSize() - ); + procBoundaries[patchI].neiProcNo(), + dts.byteSize() + ); toOtherProc << dts; } diff --git a/meshLibrary/utilities/surfaceTools/meshSurfaceMapper/meshSurfaceMapperCornersAndEdges.C b/meshLibrary/utilities/surfaceTools/meshSurfaceMapper/meshSurfaceMapperCornersAndEdges.C index 811104e5..0e66b9e0 100644 --- a/meshLibrary/utilities/surfaceTools/meshSurfaceMapper/meshSurfaceMapperCornersAndEdges.C +++ b/meshLibrary/utilities/surfaceTools/meshSurfaceMapper/meshSurfaceMapperCornersAndEdges.C @@ -44,7 +44,7 @@ Description namespace Foam { - + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // void meshSurfaceMapper::findMappingDistance diff --git a/meshLibrary/utilities/surfaceTools/meshSurfaceMapper/meshSurfaceMapperMapVertices.C b/meshLibrary/utilities/surfaceTools/meshSurfaceMapper/meshSurfaceMapperMapVertices.C index 1f620c3a..089124ac 100644 --- a/meshLibrary/utilities/surfaceTools/meshSurfaceMapper/meshSurfaceMapperMapVertices.C +++ b/meshLibrary/utilities/surfaceTools/meshSurfaceMapper/meshSurfaceMapperMapVertices.C @@ -208,14 +208,14 @@ void meshSurfaceMapper::mapVerticesOntoSurface() void meshSurfaceMapper::mapVerticesOntoSurface(const labelListPMG& nodesToMap) { - const labelList& boundaryPoints = surfaceEngine_.boundaryPoints(); + const labelList& boundaryPoints = surfaceEngine_.boundaryPoints(); const pointFieldPMG& points = surfaceEngine_.points(); const VRWGraph* bpAtProcsPtr(NULL); if( Pstream::parRun() ) bpAtProcsPtr = &surfaceEngine_.bpAtProcs(); - - meshSurfaceEngineModifier surfaceModifier(surfaceEngine_); + + meshSurfaceEngineModifier surfaceModifier(surfaceEngine_); LongList<parMapperHelper> parallelBndNodes; const label size = nodesToMap.size(); @@ -225,10 +225,10 @@ void meshSurfaceMapper::mapVerticesOntoSurface(const labelListPMG& nodesToMap) { const label bpI = nodesToMap[i]; - # ifdef DEBUGMapping + # ifdef DEBUGMapping Info << nl << "Mapping vertex " << bpI << " with coordinates " << points[boundaryPoints[bpI]] << endl; - # endif + # endif label patch; point mapPoint; @@ -242,7 +242,7 @@ void meshSurfaceMapper::mapVerticesOntoSurface(const labelListPMG& nodesToMap) points[boundaryPoints[bpI]] ); - surfaceModifier.moveBoundaryVertexNoUpdate(bpI, mapPoint); + surfaceModifier.moveBoundaryVertexNoUpdate(bpI, mapPoint); if( bpAtProcsPtr && bpAtProcsPtr->sizeOfRow(bpI) ) { @@ -258,10 +258,10 @@ void meshSurfaceMapper::mapVerticesOntoSurface(const labelListPMG& nodesToMap) ) ); } - - # ifdef DEBUGMapping + + # ifdef DEBUGMapping Info << "Mapped point " << points[boundaryPoints[bpI]] << endl; - # endif + # endif } surfaceModifier.updateGeometry(nodesToMap); @@ -317,8 +317,8 @@ void meshSurfaceMapper::mapVerticesOntoSurfacePatches const VRWGraph* bpAtProcsPtr(NULL); if( Pstream::parRun() ) bpAtProcsPtr = &surfaceEngine_.bpAtProcs(); - - meshSurfaceEngineModifier surfaceModifier(surfaceEngine_); + + meshSurfaceEngineModifier surfaceModifier(surfaceEngine_); LongList<parMapperHelper> parallelBndNodes; const label size = nodesToMap.size(); @@ -359,9 +359,9 @@ void meshSurfaceMapper::mapVerticesOntoSurfacePatches ); } - # ifdef DEBUGMapping + # ifdef DEBUGMapping Info << "Mapped point " << points[boundaryPoints[bpI]] << endl; - # endif + # endif } surfaceModifier.updateGeometry(nodesToMap); diff --git a/meshLibrary/utilities/surfaceTools/meshSurfacePartitioner/meshSurfacePartitioner.C b/meshLibrary/utilities/surfaceTools/meshSurfacePartitioner/meshSurfacePartitioner.C index 84292b93..80e75ad4 100644 --- a/meshLibrary/utilities/surfaceTools/meshSurfacePartitioner/meshSurfacePartitioner.C +++ b/meshLibrary/utilities/surfaceTools/meshSurfacePartitioner/meshSurfacePartitioner.C @@ -38,7 +38,7 @@ namespace Foam // Construct from meshSurfaceEngine. Holds reference! meshSurfacePartitioner::meshSurfacePartitioner ( - const meshSurfaceEngine& meshSurface + const meshSurfaceEngine& meshSurface ) : meshSurface_(meshSurface), diff --git a/meshLibrary/utilities/surfaceTools/meshSurfacePartitioner/meshSurfacePartitioner.H b/meshLibrary/utilities/surfaceTools/meshSurfacePartitioner/meshSurfacePartitioner.H index 01ee1108..ffd1fdba 100644 --- a/meshLibrary/utilities/surfaceTools/meshSurfacePartitioner/meshSurfacePartitioner.H +++ b/meshLibrary/utilities/surfaceTools/meshSurfacePartitioner/meshSurfacePartitioner.H @@ -52,7 +52,7 @@ class meshSurfacePartitioner { // Private data //- reference to mesh surface engine - const meshSurfaceEngine& meshSurface_; + const meshSurfaceEngine& meshSurface_; //- labels of corner nodes labelHashSet corners_; @@ -77,7 +77,7 @@ class meshSurfacePartitioner void operator=(const meshSurfacePartitioner&); public: - + // Constructors //- Construct from mesh diff --git a/meshLibrary/utilities/surfaceTools/renameBoundaryPatches/renameBoundaryPatches.C b/meshLibrary/utilities/surfaceTools/renameBoundaryPatches/renameBoundaryPatches.C index 1f1aa91b..f4d7f5d5 100644 --- a/meshLibrary/utilities/surfaceTools/renameBoundaryPatches/renameBoundaryPatches.C +++ b/meshLibrary/utilities/surfaceTools/renameBoundaryPatches/renameBoundaryPatches.C @@ -38,29 +38,29 @@ Description namespace Foam { - + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - + void renameBoundaryPatches::calculateNewBoundary() { Info << "Renaming boundary patches" << endl; - const dictionary& dict = meshDict_.subDict("renameBoundary"); - - std::map<word, label> patchToLabel; - forAll(mesh_.boundaries(), patchI) + const dictionary& dict = meshDict_.subDict("renameBoundary"); + + std::map<word, label> patchToLabel; + forAll(mesh_.boundaries(), patchI) { - patchToLabel.insert - ( - std::pair<word, label> - ( - mesh_.boundaries()[patchI].patchName(), - patchI - ) - ); + patchToLabel.insert + ( + std::pair<word, label> + ( + mesh_.boundaries()[patchI].patchName(), + patchI + ) + ); } - labelList patchToNew(mesh_.boundaries().size(), -1); + labelList patchToNew(mesh_.boundaries().size(), -1); wordList newPatchNames(patchToNew.size()); wordList newPatchTypes(patchToNew.size()); @@ -122,11 +122,11 @@ void renameBoundaryPatches::calculateNewBoundary() } word defaultName(""); - if( dict.found("defaultName") ) - defaultName = word(dict.lookup("defaultName")); - word defaultType("patch"); - if( dict.found("defaultType") ) - defaultType = word(dict.lookup("defaultType")); + if( dict.found("defaultName") ) + defaultName = word(dict.lookup("defaultName")); + word defaultType("patch"); + if( dict.found("defaultType") ) + defaultType = word(dict.lookup("defaultType")); if( dict.found("defaultName") ) { @@ -135,19 +135,19 @@ void renameBoundaryPatches::calculateNewBoundary() newPatchTypes[newPatchI] = defaultType; ++newPatchI; } - else - { - forAll(patchToNew, patchI) - { - if( patchToNew[patchI] != -1 ) - continue; - - patchToNew[patchI] = newPatchI; - newPatchNames[newPatchI] = mesh_.boundaries()[patchI].patchName(); - newPatchTypes[newPatchI] = mesh_.boundaries()[patchI].patchType(); - ++newPatchI; - } - } + else + { + forAll(patchToNew, patchI) + { + if( patchToNew[patchI] != -1 ) + continue; + + patchToNew[patchI] = newPatchI; + newPatchNames[newPatchI] = mesh_.boundaries()[patchI].patchName(); + newPatchTypes[newPatchI] = mesh_.boundaries()[patchI].patchType(); + ++newPatchI; + } + } if( newPatchI == 0 ) return; @@ -212,14 +212,14 @@ void renameBoundaryPatches::calculateNewBoundary() renameBoundaryPatches::renameBoundaryPatches ( polyMeshGen& mesh, - const IOdictionary& meshDict + const IOdictionary& meshDict ) : - mesh_(mesh), - meshDict_(meshDict) + mesh_(mesh), + meshDict_(meshDict) { - if( meshDict.found("renameBoundary") ) - calculateNewBoundary(); + if( meshDict.found("renameBoundary") ) + calculateNewBoundary(); } // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // diff --git a/meshLibrary/utilities/surfaceTools/renameBoundaryPatches/renameBoundaryPatches.H b/meshLibrary/utilities/surfaceTools/renameBoundaryPatches/renameBoundaryPatches.H index 26fec838..606ce853 100644 --- a/meshLibrary/utilities/surfaceTools/renameBoundaryPatches/renameBoundaryPatches.H +++ b/meshLibrary/utilities/surfaceTools/renameBoundaryPatches/renameBoundaryPatches.H @@ -54,14 +54,14 @@ class renameBoundaryPatches { // Private data //- mesh - polyMeshGen& mesh_; - - //- dictionary containing relevant information - const IOdictionary& meshDict_; + polyMeshGen& mesh_; + + //- dictionary containing relevant information + const IOdictionary& meshDict_; // Private member functions - //- calculate new boundary and replace the existing one - void calculateNewBoundary(); + //- calculate new boundary and replace the existing one + void calculateNewBoundary(); //- Disallow default bitwise copy construct renameBoundaryPatches(const renameBoundaryPatches&); @@ -76,8 +76,8 @@ public: //- Construct from mesh and IOdictionary renameBoundaryPatches ( - polyMeshGen& mesh, - const IOdictionary& meshDict + polyMeshGen& mesh, + const IOdictionary& meshDict ); // Destructor diff --git a/meshLibrary/utilities/surfaceTools/surfaceMorpherCells/surfaceMorpherCells.C b/meshLibrary/utilities/surfaceTools/surfaceMorpherCells/surfaceMorpherCells.C index 53cbc326..f0a4ac22 100644 --- a/meshLibrary/utilities/surfaceTools/surfaceMorpherCells/surfaceMorpherCells.C +++ b/meshLibrary/utilities/surfaceTools/surfaceMorpherCells/surfaceMorpherCells.C @@ -46,32 +46,32 @@ namespace Foam void surfaceMorpherCells::replaceMeshBoundary() { - wordList patchNames(1); - patchNames[0] = "defaultFaces"; - - polyMeshGenModifier(mesh_).replaceBoundary - ( - patchNames, - newBoundaryFaces_, - newBoundaryOwners_, - newBoundaryPatches_ - ); + wordList patchNames(1); + patchNames[0] = "defaultFaces"; + + polyMeshGenModifier(mesh_).replaceBoundary + ( + patchNames, + newBoundaryFaces_, + newBoundaryOwners_, + newBoundaryPatches_ + ); } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // surfaceMorpherCells::surfaceMorpherCells ( - polyMeshGen& mesh + polyMeshGen& mesh ) : - mesh_(mesh), + mesh_(mesh), nIntFaces_(0), boundaryVertex_(mesh.points().size()), - cellFlags_(mesh.cells().size()), - newBoundaryFaces_(), - newBoundaryOwners_(), - newBoundaryPatches_() + cellFlags_(mesh.cells().size()), + newBoundaryFaces_(), + newBoundaryOwners_(), + newBoundaryPatches_() { } @@ -82,102 +82,102 @@ surfaceMorpherCells::~surfaceMorpherCells() void surfaceMorpherCells::morphMesh() { - //- perform surface morphing - bool changed; - - # ifdef DEBUGMorph - label iter(0); - # endif - + //- perform surface morphing + bool changed; + + # ifdef DEBUGMorph + label iter(0); + # endif + do { - changed = false; - # ifdef DEBUGMorph - Info << "Iteration " << ++iter << endl; - # endif - - findBoundaryVertices(); - - findBoundaryCells(); - - if( removeCellsWithAllVerticesAtTheBoundary() ) - { - changed = true; - continue; - } + changed = false; + # ifdef DEBUGMorph + Info << "Iteration " << ++iter << endl; + # endif + + findBoundaryVertices(); + + findBoundaryCells(); + + if( removeCellsWithAllVerticesAtTheBoundary() ) + { + changed = true; + continue; + } if( morphInternalFaces() ) - { - changed = true; - continue; - } - - if( morphBoundaryFaces() ) - { - changed = true; - continue; - } - - # ifdef DEBUGMorph - mesh_.write(); - mesh_.addressingData().checkMesh(true); - fileName name("morphedMesh"); - std::ostringstream ss; - ss << iter; - name += ss.str(); - Info << "name " << name << endl; - writeMeshEnsight(mesh_, name); - ++iter; - - const cellListPMG& cells = mesh_.cells(); - const faceListPMG& faces = mesh_.faces(); - forAll(cells, cellI) - { - const cell& c = cells[cellI]; - - const edgeList edges = c.edges(faces); - List<direction> nAppearances(edges.size(), direction(0)); - - forAll(c, fI) - { - const edgeList fEdges = faces[c[fI]].edges(); - - forAll(fEdges, eI) - forAll(edges, eJ) - if( fEdges[eI] == edges[eJ] ) - { - ++nAppearances[eJ]; - break; - } - } - - bool closed(true); - forAll(nAppearances, eI) - if( nAppearances[eI] != 2 ) - { - closed = false; - Info << "Edge " << edges[eI] << " appears " - << label(nAppearances[eI]) << " times in cell " - << cellI << endl; - } - - if( !closed ) - { - Info << "Cell " << cellI << " consists of faces " << c << endl; - forAll(c, fI) - Info << "Face " << c[fI] << " is " << faces[c[fI]] << endl; - FatalErrorIn - ( - "void surfaceMorpherCells::morphMesh()" - ) << "Cell " << cellI << " is not topologically closed" - << abort(FatalError); - } - } - # endif + { + changed = true; + continue; + } + + if( morphBoundaryFaces() ) + { + changed = true; + continue; + } + + # ifdef DEBUGMorph + mesh_.write(); + mesh_.addressingData().checkMesh(true); + fileName name("morphedMesh"); + std::ostringstream ss; + ss << iter; + name += ss.str(); + Info << "name " << name << endl; + writeMeshEnsight(mesh_, name); + ++iter; + + const cellListPMG& cells = mesh_.cells(); + const faceListPMG& faces = mesh_.faces(); + forAll(cells, cellI) + { + const cell& c = cells[cellI]; + + const edgeList edges = c.edges(faces); + List<direction> nAppearances(edges.size(), direction(0)); + + forAll(c, fI) + { + const edgeList fEdges = faces[c[fI]].edges(); + + forAll(fEdges, eI) + forAll(edges, eJ) + if( fEdges[eI] == edges[eJ] ) + { + ++nAppearances[eJ]; + break; + } + } + + bool closed(true); + forAll(nAppearances, eI) + if( nAppearances[eI] != 2 ) + { + closed = false; + Info << "Edge " << edges[eI] << " appears " + << label(nAppearances[eI]) << " times in cell " + << cellI << endl; + } + + if( !closed ) + { + Info << "Cell " << cellI << " consists of faces " << c << endl; + forAll(c, fI) + Info << "Face " << c[fI] << " is " << faces[c[fI]] << endl; + FatalErrorIn + ( + "void surfaceMorpherCells::morphMesh()" + ) << "Cell " << cellI << " is not topologically closed" + << abort(FatalError); + } + } + # endif } while( changed ); - polyMeshGenModifier(mesh_).removeUnusedVertices(); + polyMeshGenModifier(mesh_).removeUnusedVertices(); } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/meshLibrary/utilities/surfaceTools/surfaceMorpherCells/surfaceMorpherCells.H b/meshLibrary/utilities/surfaceTools/surfaceMorpherCells/surfaceMorpherCells.H index 3f515063..78e09c34 100644 --- a/meshLibrary/utilities/surfaceTools/surfaceMorpherCells/surfaceMorpherCells.H +++ b/meshLibrary/utilities/surfaceTools/surfaceMorpherCells/surfaceMorpherCells.H @@ -27,7 +27,7 @@ Class Description Changes the boundary of the mesh template, such that each boundary cell - has only one boundary face. + has only one boundary face. SourceFiles surfaceMorpherCells.C @@ -53,49 +53,49 @@ namespace Foam class surfaceMorpherCells { // Private data - //- mesh modifier - polyMeshGen& mesh_; + //- mesh modifier + polyMeshGen& mesh_; - //- number of internal faces + //- number of internal faces label nIntFaces_; - - //- true for vertices which are at the boundary + + //- true for vertices which are at the boundary boolList boundaryVertex_; - - //- true for cells which are at the boundary - List<direction> cellFlags_; - - //- new boundary faces and owner cells - VRWGraph newBoundaryFaces_; - labelListPMG newBoundaryOwners_; - labelListPMG newBoundaryPatches_; - - // Private enumerators - enum cellTypes - { - NONE = 0, - BOUNDARY = 1, - CHANGED = 2 - }; + + //- true for cells which are at the boundary + List<direction> cellFlags_; + + //- new boundary faces and owner cells + VRWGraph newBoundaryFaces_; + labelListPMG newBoundaryOwners_; + labelListPMG newBoundaryPatches_; + + // Private enumerators + enum cellTypes + { + NONE = 0, + BOUNDARY = 1, + CHANGED = 2 + }; // Private member functions //- find surface vertices void findBoundaryVertices(); - - //- find boundary cells - void findBoundaryCells(); - - //- remove cells with all vertices at the boundary - bool removeCellsWithAllVerticesAtTheBoundary(); - - //- morph boundary faces + + //- find boundary cells + void findBoundaryCells(); + + //- remove cells with all vertices at the boundary + bool removeCellsWithAllVerticesAtTheBoundary(); + + //- morph boundary faces bool morphBoundaryFaces(); - + //- morph internal faces - bool morphInternalFaces(); - - //- replace the boundary of the mesh with the newly created one - void replaceMeshBoundary(); + bool morphInternalFaces(); + + //- replace the boundary of the mesh with the newly created one + void replaceMeshBoundary(); //- Disallow default bitwise copy construct surfaceMorpherCells(const surfaceMorpherCells&); diff --git a/meshLibrary/utilities/surfaceTools/surfaceMorpherCells/surfaceMorpherCellsCreateBoundaryFaces.C b/meshLibrary/utilities/surfaceTools/surfaceMorpherCells/surfaceMorpherCellsCreateBoundaryFaces.C index 04aecc4b..4bae0b23 100644 --- a/meshLibrary/utilities/surfaceTools/surfaceMorpherCells/surfaceMorpherCellsCreateBoundaryFaces.C +++ b/meshLibrary/utilities/surfaceTools/surfaceMorpherCells/surfaceMorpherCellsCreateBoundaryFaces.C @@ -46,211 +46,211 @@ namespace Foam bool surfaceMorpherCells::removeCellsWithAllVerticesAtTheBoundary() { - boolList removeCells(cellFlags_.size(), false); - - const faceListPMG& faces = mesh_.faces(); - const cellListPMG& cells = mesh_.cells(); - - bool changed(false); - - label nRemoved(0); - forAll(cellFlags_, cellI) - if( cellFlags_[cellI] & BOUNDARY ) - { - const cell& c = cells[cellI]; - //- remove cells which have all their vertices at the boundary - bool allBoundary(true); - - const labelList labels = c.labels(faces); - - forAll(labels, lI) - if( !boundaryVertex_[labels[lI]] ) - { - allBoundary = false; - break; - } - - if( allBoundary ) - { - ++nRemoved; - changed = true; - removeCells[cellI] = true; - } - - //- remove cells which are not topologically closed - DynList<edge> edges(24); - DynList<direction> nAppearances(24); - - forAll(c, fI) - { - const face& f = faces[c[fI]]; - forAll(f, eI) - { - const label pos = edges.containsAtPosition(f.faceEdge(eI)); - - if( pos == -1 ) - { - edges.append(f.faceEdge(eI)); - nAppearances.append(1); - } - else - { - ++nAppearances[pos]; - } - } - } - - forAll(nAppearances, eI) - if( nAppearances[eI] != 2 ) - { - ++nRemoved; - changed = true; - removeCells[cellI] = true; - } + boolList removeCells(cellFlags_.size(), false); + + const faceListPMG& faces = mesh_.faces(); + const cellListPMG& cells = mesh_.cells(); + + bool changed(false); + + label nRemoved(0); + forAll(cellFlags_, cellI) + if( cellFlags_[cellI] & BOUNDARY ) + { + const cell& c = cells[cellI]; + //- remove cells which have all their vertices at the boundary + bool allBoundary(true); + + const labelList labels = c.labels(faces); + + forAll(labels, lI) + if( !boundaryVertex_[labels[lI]] ) + { + allBoundary = false; + break; + } + + if( allBoundary ) + { + ++nRemoved; + changed = true; + removeCells[cellI] = true; + } + + //- remove cells which are not topologically closed + DynList<edge> edges(24); + DynList<direction> nAppearances(24); + + forAll(c, fI) + { + const face& f = faces[c[fI]]; + forAll(f, eI) + { + const label pos = edges.containsAtPosition(f.faceEdge(eI)); + + if( pos == -1 ) + { + edges.append(f.faceEdge(eI)); + nAppearances.append(1); + } + else + { + ++nAppearances[pos]; + } + } + } + + forAll(nAppearances, eI) + if( nAppearances[eI] != 2 ) + { + ++nRemoved; + changed = true; + removeCells[cellI] = true; + } - } + } if( Pstream::parRun() ) reduce(nRemoved, sumOp<label>()); if( nRemoved != 0 ) - { - Info << "Removing " << nRemoved - << " cells which cannot be morphed" << endl; - polyMeshGenModifier(mesh_).removeCells(removeCells); - } + { + Info << "Removing " << nRemoved + << " cells which cannot be morphed" << endl; + polyMeshGenModifier(mesh_).removeCells(removeCells); + } if( Pstream::parRun() ) { reduce(changed, maxOp<bool>()); } - - return changed; + + return changed; } bool surfaceMorpherCells::morphBoundaryFaces() { Info << "Morphing boundary faces" << endl; - - newBoundaryFaces_.setSize(0); - newBoundaryOwners_.setSize(0); - newBoundaryPatches_.setSize(0); - - const faceListPMG& faces = mesh_.faces(); - const cellListPMG& cells = mesh_.cells(); - - bool changed(false); - - forAll(cells, cellI) - if( cellFlags_[cellI] & BOUNDARY ) - { - const cell& c = cells[cellI]; - - DynList<label> bFaces(c.size()); - - forAll(c, fI) - if( mesh_.faceIsInPatch(c[fI]) != -1 ) - bFaces.append(c[fI]); - - # ifdef DEBUGMorph - Info << "Boundary faces in cell " << cellI - << " are " << bFaces << endl; - forAll(bFaces, bfI) - Info << "Face " << bFaces[bfI] << " is " - << faces[bFaces[bfI]] << endl; - # endif - - boolList mergedFaces(bFaces.size(), false); - - face mf = faces[bFaces[0]]; - mergedFaces[0] = true; - - bool finished; - do - { - finished = true; - for(label i=1;i<bFaces.size();++i) - { - if( mergedFaces[i] ) continue; - - const face& bf = faces[bFaces[i]]; - const edgeList bEdges = bf.edges(); - const edgeList mEdges = mf.edges(); - - direction nSharedEdges(0); - forAll(bEdges, eI) - forAll(mEdges, eJ) - if( bEdges[eI] == mEdges[eJ] ) - ++nSharedEdges; - - direction nSharedPoints(0); - forAll(bf, pI) - forAll(mf, pJ) - if( bf[pI] == mf[pJ] ) - ++nSharedPoints; - - if( - nSharedEdges && - ((nSharedEdges + 1) == nSharedPoints) - ) - { - mf = help::mergeTwoFaces(mf, bf); - mergedFaces[i] = true; - changed = true; - finished = false; + + newBoundaryFaces_.setSize(0); + newBoundaryOwners_.setSize(0); + newBoundaryPatches_.setSize(0); + + const faceListPMG& faces = mesh_.faces(); + const cellListPMG& cells = mesh_.cells(); + + bool changed(false); + + forAll(cells, cellI) + if( cellFlags_[cellI] & BOUNDARY ) + { + const cell& c = cells[cellI]; + + DynList<label> bFaces(c.size()); + + forAll(c, fI) + if( mesh_.faceIsInPatch(c[fI]) != -1 ) + bFaces.append(c[fI]); + + # ifdef DEBUGMorph + Info << "Boundary faces in cell " << cellI + << " are " << bFaces << endl; + forAll(bFaces, bfI) + Info << "Face " << bFaces[bfI] << " is " + << faces[bFaces[bfI]] << endl; + # endif + + boolList mergedFaces(bFaces.size(), false); + + face mf = faces[bFaces[0]]; + mergedFaces[0] = true; + + bool finished; + do + { + finished = true; + for(label i=1;i<bFaces.size();++i) + { + if( mergedFaces[i] ) continue; + + const face& bf = faces[bFaces[i]]; + const edgeList bEdges = bf.edges(); + const edgeList mEdges = mf.edges(); + + direction nSharedEdges(0); + forAll(bEdges, eI) + forAll(mEdges, eJ) + if( bEdges[eI] == mEdges[eJ] ) + ++nSharedEdges; + + direction nSharedPoints(0); + forAll(bf, pI) + forAll(mf, pJ) + if( bf[pI] == mf[pJ] ) + ++nSharedPoints; + + if( + nSharedEdges && + ((nSharedEdges + 1) == nSharedPoints) + ) + { + mf = help::mergeTwoFaces(mf, bf); + mergedFaces[i] = true; + changed = true; + finished = false; - //- set CHANGED flag - cellFlags_[cellI] |= CHANGED; - } - } - } while( !finished ); - - newBoundaryFaces_.appendList(mf); - newBoundaryOwners_.append(cellI); - newBoundaryPatches_.append(0); - - # ifdef DEBUGMorph - Info << "Adding merged face " << mf << endl; - # endif - - for(label i=1;i<bFaces.size();++i) - if( !mergedFaces[i] ) - { - newBoundaryFaces_.appendList(faces[bFaces[i]]); - newBoundaryOwners_.append(cellI); - newBoundaryPatches_.append(0); - - # ifdef DEBUGMorph - Info << "Adding untouched boundary face " - << faces[bFaces[i]] << endl; - # endif - } - } + //- set CHANGED flag + cellFlags_[cellI] |= CHANGED; + } + } + } while( !finished ); + + newBoundaryFaces_.appendList(mf); + newBoundaryOwners_.append(cellI); + newBoundaryPatches_.append(0); + + # ifdef DEBUGMorph + Info << "Adding merged face " << mf << endl; + # endif + + for(label i=1;i<bFaces.size();++i) + if( !mergedFaces[i] ) + { + newBoundaryFaces_.appendList(faces[bFaces[i]]); + newBoundaryOwners_.append(cellI); + newBoundaryPatches_.append(0); + + # ifdef DEBUGMorph + Info << "Adding untouched boundary face " + << faces[bFaces[i]] << endl; + # endif + } + } if( Pstream::parRun() ) { reduce(changed, maxOp<bool>()); } - - if( changed ) - { - replaceMeshBoundary(); - } - - # ifdef DEBUGMorph - labelHashSet zipCells; - mesh_.addressingData().checkCellsZipUp(true, &zipCells); - if( zipCells.size() ) - { - Info << "Cells " << zipCells << " are not zipped!!" << endl; - ::exit(EXIT_FAILURE); - } - mesh_.clearAddressingData(); - # endif + + if( changed ) + { + replaceMeshBoundary(); + } + + # ifdef DEBUGMorph + labelHashSet zipCells; + mesh_.addressingData().checkCellsZipUp(true, &zipCells); + if( zipCells.size() ) + { + Info << "Cells " << zipCells << " are not zipped!!" << endl; + ::exit(EXIT_FAILURE); + } + mesh_.clearAddressingData(); + # endif Info << "Finished morphing boundary faces" << endl; - - return changed; + + return changed; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/meshLibrary/utilities/surfaceTools/surfaceMorpherCells/surfaceMorpherCellsMorphInternalFaces.C b/meshLibrary/utilities/surfaceTools/surfaceMorpherCells/surfaceMorpherCellsMorphInternalFaces.C index 7df58c02..2c229b03 100644 --- a/meshLibrary/utilities/surfaceTools/surfaceMorpherCells/surfaceMorpherCellsMorphInternalFaces.C +++ b/meshLibrary/utilities/surfaceTools/surfaceMorpherCells/surfaceMorpherCellsMorphInternalFaces.C @@ -577,7 +577,7 @@ bool surfaceMorpherCells::morphInternalFaces() labelHashSet zipCells; mesh_.addressingData().checkCellsZipUp(true, &zipCells); if( zipCells.size() ) - { + { Serr << Pstream::myProcNo() << "Open cells appeared!" << endl; //mesh_.write(); //writeMeshEnsight(mesh_, "openMeshAfterInternalMorph"); diff --git a/meshLibrary/utilities/surfaceTools/triangulateNonPlanarBoundaryFaces/triangulateNonPlanarBoundaryFaces.C b/meshLibrary/utilities/surfaceTools/triangulateNonPlanarBoundaryFaces/triangulateNonPlanarBoundaryFaces.C index 98dbda50..80407df8 100644 --- a/meshLibrary/utilities/surfaceTools/triangulateNonPlanarBoundaryFaces/triangulateNonPlanarBoundaryFaces.C +++ b/meshLibrary/utilities/surfaceTools/triangulateNonPlanarBoundaryFaces/triangulateNonPlanarBoundaryFaces.C @@ -42,50 +42,50 @@ namespace Foam void triangulateNonPlanarBoundaryFaces::findBoundaryCellsToDecompose() { - const pointFieldPMG& points = mesh_.points(); - const labelList& owner = mesh_.owner(); - const faceListPMG& faces = mesh_.faces(); - - const PtrList<writePatch>& boundaries = mesh_.boundaries(); - - label nDecompose(0); - - forAll(boundaries, patchI) - { - const label start = boundaries[patchI].patchStart(); - const label end = start + boundaries[patchI].patchSize(); - - for(label faceI=start;faceI<end;++faceI) - { - const face& f = faces[faceI]; - - forAll(f, pI) - pointPatches_[f[pI]].appendIfNotIn(patchI); - - //- do not waste time on triangles - if( f.size() < 4 ) continue; - - if( !faceDecomposition(f, points).isFacePlanar() ) - { - ++nDecompose; - decomposeCell_[owner[faceI]] = true; - } - } - } - - Info << "Found " << nDecompose << " non-planar boundary faces" << endl; + const pointFieldPMG& points = mesh_.points(); + const labelList& owner = mesh_.owner(); + const faceListPMG& faces = mesh_.faces(); + + const PtrList<writePatch>& boundaries = mesh_.boundaries(); + + label nDecompose(0); + + forAll(boundaries, patchI) + { + const label start = boundaries[patchI].patchStart(); + const label end = start + boundaries[patchI].patchSize(); + + for(label faceI=start;faceI<end;++faceI) + { + const face& f = faces[faceI]; + + forAll(f, pI) + pointPatches_[f[pI]].appendIfNotIn(patchI); + + //- do not waste time on triangles + if( f.size() < 4 ) continue; + + if( !faceDecomposition(f, points).isFacePlanar() ) + { + ++nDecompose; + decomposeCell_[owner[faceI]] = true; + } + } + } + + Info << "Found " << nDecompose << " non-planar boundary faces" << endl; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // triangulateNonPlanarBoundaryFaces::triangulateNonPlanarBoundaryFaces ( - polyMeshGen& mesh + polyMeshGen& mesh ) : - mesh_(mesh), + mesh_(mesh), decomposeCell_(mesh.cells().size(), false), - pointPatches_(mesh.points().size()) + pointPatches_(mesh.points().size()) { } @@ -98,13 +98,13 @@ void triangulateNonPlanarBoundaryFaces::decomposeMesh() { FatalError << "Not implemented" << exit(FatalError); - Info << "Decomposing non-planar boundary faces" << endl; - findBoundaryCellsToDecompose(); - - decomposeCells decomposeNonPlanarCells(mesh_); - decomposeNonPlanarCells.decomposeMesh(decomposeCell_); - - Info << "Finished decomposing non-planar boundary faces" << endl; + Info << "Decomposing non-planar boundary faces" << endl; + findBoundaryCellsToDecompose(); + + decomposeCells decomposeNonPlanarCells(mesh_); + decomposeNonPlanarCells.decomposeMesh(decomposeCell_); + + Info << "Finished decomposing non-planar boundary faces" << endl; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/meshLibrary/utilities/surfaceTools/triangulateNonPlanarBoundaryFaces/triangulateNonPlanarBoundaryFaces.H b/meshLibrary/utilities/surfaceTools/triangulateNonPlanarBoundaryFaces/triangulateNonPlanarBoundaryFaces.H index e04d1940..53707cd6 100644 --- a/meshLibrary/utilities/surfaceTools/triangulateNonPlanarBoundaryFaces/triangulateNonPlanarBoundaryFaces.H +++ b/meshLibrary/utilities/surfaceTools/triangulateNonPlanarBoundaryFaces/triangulateNonPlanarBoundaryFaces.H @@ -51,12 +51,12 @@ namespace Foam class triangulateNonPlanarBoundaryFaces { // Private data - //- mesh modifier - polyMeshGen& mesh_; + //- mesh modifier + polyMeshGen& mesh_; boolList decomposeCell_; - - VRWGraph pointPatches_; + + VRWGraph pointPatches_; // Private member functions //- find surface vertices diff --git a/meshLibrary/utilities/tetrahedra/delaunayTessellation.tgz b/meshLibrary/utilities/tetrahedra/delaunayTessellation.tgz index ce4b7f35e0ae31ab9dede81c4050b7cd860374ab..3fed52b68d2b4d764b35a5210d80e995fd9df0ce 100644 GIT binary patch delta 1065 zcmZ3zk@3f7#tAYk3JMAe8)bu;!Hmg;%&}m`=JU*%j9}JeOV$nu;}C1BC`fgr^TGo* ze*`E0T~t{62_!H%j4czaWb*;G0;n!S4t=oD<U|ftFk^E&$2>+^kaCsSb<>4q1fzu> zX4n;g1okYpTn?fqTXN}u)lN?1vVbt=bNNFU@43D~7|*yHAdGaLRS<>{Z!3f`gEtJq zcn=lXT*{XRb<Y!isQ%jm@4$*SpAuw-czW|W5fP}W$D%*Ll9TU<-GDH*ir)n@Hcyt& zhblTOsR<UE{8sWJn6Y`klmJ9-^95-KC`(Y*0b=~*AcbpSWs@}(d%%p%+Y~1;L0FzD zYar?;e^U*C2zjdsLxtkioghMs)F(rPHk)bAhOj1I(t>)wR@;LM6nZvyK;-0;+WlZn zlOuI@K^P*s&@fEV{V5Jov#>Kf>k!A}H%mhvusJ5XfrKXK>1lF<7%zF>fT+oH^wPn6 z;kjqQd=CAE5YtxaPk}J(4ZcDcriS(qMk$Q3)ew>%Cd(V8LZn)apoxgj*bE}#YMcvU zY&K4UFvLvSA&hw@mm!QIQ%K-X4ltX<0dfWiPkv&y7$V(aZlwVdxmhe(T_qp;cAn3T z1Fk}nJLP9FF`BKM^4&o$xi+WMDH5b+@)PrQU|pLhTc|>UaPv;fFbHe1fVBifQq!6V zDx_nx1S~Z9q75Y0Cdb)!fkigIw1q0#{Kn1*s$AYd4=g#^&tW5&vB~j23z#v<4H~hb zZqT^i%;b>?jsG04Mu-8M-+9l1h)wSF%Li-R{L^m-lQ78fAUv%!Pft4G8i+Z0cc24U z#pFMMO%O(XkRya~FvtWEQs09hPT$-T909fFZip;|HTidFGek>$m^y^9JnSfhksE#h J!qAJT1pou+7A61y delta 705 zcmeydnQ`?-#tAZvoEsH_nHf1JmovvQa&ErCoXN<@IoXx9gOPLcMb=h+&PeBl2W<Wb zPX4>7u=W$@<ZQM~kTSLckTM?*eMZj7^&F~<oSRp0%wrVcREb?TU06miTIgYhT><Bw z#g@xCCnt01Fmg_w%w@sIIr%)7KO^U4CGKyGoRejE8W=ezFW_0l$T``Mx0R7|@^#)Y zM$XBGe65U}n|JZ$fvnIG04Y@ye8<SSSwe`JnUQm|yr>9B#$4<NBj;pe@f(bslldj? zGIDPIAfXSEP?pkU<eVHJb&-*Cv#PWJBO~W#OBn|cRV(WN^6Ei_YmA(eXDjwFa&FdE zn#9D&x%r^V8j#jPwGc+m%_r4_L7WHbPK=zJ)ifr9wC>fM4HApd2Dz3?$Ag8_<__oN z7@dAb&dKj}b}@2JUaRZR$T>;xry%FT&hV^59FyNH4SB%knC!+mSwLTtmGdR<8_vlt z`su8k!gJ4ZPTr=!kdbq8w80cc&dHw*zA|!7eq(6Q$T?Zx2t*bcWioP3zHgMu$T``= z7!(;-jLjH1C-a%)f<oLRiIH>iQ<HW^&dCL)ml-)HyPMr*<eaQwK8cBwbMhhc#f+Sj zGcBwbIVUf-P+;VoeA;3iBj@H?OI46pmRW@{GICC`kznN9EMvn2@|KeA5=PF+r)+x| zIVVTibun^oeqjfa*!<4k2qdrKsK>}TIm~e*Bj;vrr~fP<m$-w1D$N}fZkxqCGeM!) z?A-{mfWvnd6C>y3W&Zh$oSP*Bb}(^qa!xDF)00lP#yR;(kORo2!A*>ulh*}1f_xur y0&=x}2q-@GheUvkkPedt*=rNt%*Z+UaJV`n=j3<cM;SRMZ;v>@$T_(>vK9cApw37D diff --git a/meshLibrary/utilities/tetrahedra/tetCreatorOctree/tetCreatorOctree.C b/meshLibrary/utilities/tetrahedra/tetCreatorOctree/tetCreatorOctree.C index f4ac52af..28ed10dd 100644 --- a/meshLibrary/utilities/tetrahedra/tetCreatorOctree/tetCreatorOctree.C +++ b/meshLibrary/utilities/tetrahedra/tetCreatorOctree/tetCreatorOctree.C @@ -36,116 +36,116 @@ Description namespace Foam { - + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - + const meshOctreeCubeCoordinates tetCreatorOctree::edgeCoordinates_[12][4]= - { - { //- edge 0 - meshOctreeCubeCoordinates(0, 0, 1, 0), - meshOctreeCubeCoordinates(0, -1, 1, 0), - meshOctreeCubeCoordinates(0, -1, 0, 0), - meshOctreeCubeCoordinates(0, 0, 0, 0) - }, - { //- edge 1 - meshOctreeCubeCoordinates(0, 0, 0, 0), - meshOctreeCubeCoordinates(0, -1, 0, 0), - meshOctreeCubeCoordinates(0, -1, -1, 0), - meshOctreeCubeCoordinates(0, 0, -1, 0) - }, - { //- edge 2 - meshOctreeCubeCoordinates(0, 1, 0, 0), - meshOctreeCubeCoordinates(0, 0, 0, 0), - meshOctreeCubeCoordinates(0, 0, -1, 0), - meshOctreeCubeCoordinates(0, 1, -1, 0) - }, - { //- edge 3 - meshOctreeCubeCoordinates(0, 1, 1, 0), - meshOctreeCubeCoordinates(0, 0, 1, 0), - meshOctreeCubeCoordinates(0, 0, 0, 0), - meshOctreeCubeCoordinates(0, 1, 0, 0) - }, - { //- edge 4 - meshOctreeCubeCoordinates(0, 0, 0, 0), - meshOctreeCubeCoordinates(0, 0, 1, 0), - meshOctreeCubeCoordinates(1, 0, 1, 0), - meshOctreeCubeCoordinates(1, 0, 0, 0) - }, - { //- edge 5 - meshOctreeCubeCoordinates(0, 0, -1, 0), - meshOctreeCubeCoordinates(0, 0, 0, 0), - meshOctreeCubeCoordinates(1, 0, 0, 0), - meshOctreeCubeCoordinates(1, 0, -1, 0) - }, - { //- edge 6 - meshOctreeCubeCoordinates(-1, 0, -1, 0), - meshOctreeCubeCoordinates(-1, 0, 0, 0), - meshOctreeCubeCoordinates(0, 0, 0, 0), - meshOctreeCubeCoordinates(0, 0, -1, 0) - }, - { //- edge 7 - meshOctreeCubeCoordinates(-1, 0, 0, 0), - meshOctreeCubeCoordinates(-1, 0, 1, 0), - meshOctreeCubeCoordinates(0, 0, 1, 0), - meshOctreeCubeCoordinates(0, 0, 0, 0) - }, - { //- edge 8 - meshOctreeCubeCoordinates(-1, 0, 0, 0), - meshOctreeCubeCoordinates(-1, -1, 0, 0), - meshOctreeCubeCoordinates(0, -1, 0, 0), - meshOctreeCubeCoordinates(0, 0, 0, 0) - }, - { //- edge 9 - meshOctreeCubeCoordinates(0, 0, 0, 0), - meshOctreeCubeCoordinates(0, -1, 0, 0), - meshOctreeCubeCoordinates(1, -1, 0, 0), - meshOctreeCubeCoordinates(1, 0, 0, 0) - }, - { //- edge 10 - meshOctreeCubeCoordinates(0, 1, 0, 0), - meshOctreeCubeCoordinates(0, 0, 0, 0), - meshOctreeCubeCoordinates(1, 0, 0, 0), - meshOctreeCubeCoordinates(1, 1, 0, 0) - }, - { //- edge 11 - meshOctreeCubeCoordinates(-1, 1, 0, 0), - meshOctreeCubeCoordinates(-1, 0, 0, 0), - meshOctreeCubeCoordinates(0, 0, 0, 0), - meshOctreeCubeCoordinates(0, 1, 0, 0) - } - }; - + { + { //- edge 0 + meshOctreeCubeCoordinates(0, 0, 1, 0), + meshOctreeCubeCoordinates(0, -1, 1, 0), + meshOctreeCubeCoordinates(0, -1, 0, 0), + meshOctreeCubeCoordinates(0, 0, 0, 0) + }, + { //- edge 1 + meshOctreeCubeCoordinates(0, 0, 0, 0), + meshOctreeCubeCoordinates(0, -1, 0, 0), + meshOctreeCubeCoordinates(0, -1, -1, 0), + meshOctreeCubeCoordinates(0, 0, -1, 0) + }, + { //- edge 2 + meshOctreeCubeCoordinates(0, 1, 0, 0), + meshOctreeCubeCoordinates(0, 0, 0, 0), + meshOctreeCubeCoordinates(0, 0, -1, 0), + meshOctreeCubeCoordinates(0, 1, -1, 0) + }, + { //- edge 3 + meshOctreeCubeCoordinates(0, 1, 1, 0), + meshOctreeCubeCoordinates(0, 0, 1, 0), + meshOctreeCubeCoordinates(0, 0, 0, 0), + meshOctreeCubeCoordinates(0, 1, 0, 0) + }, + { //- edge 4 + meshOctreeCubeCoordinates(0, 0, 0, 0), + meshOctreeCubeCoordinates(0, 0, 1, 0), + meshOctreeCubeCoordinates(1, 0, 1, 0), + meshOctreeCubeCoordinates(1, 0, 0, 0) + }, + { //- edge 5 + meshOctreeCubeCoordinates(0, 0, -1, 0), + meshOctreeCubeCoordinates(0, 0, 0, 0), + meshOctreeCubeCoordinates(1, 0, 0, 0), + meshOctreeCubeCoordinates(1, 0, -1, 0) + }, + { //- edge 6 + meshOctreeCubeCoordinates(-1, 0, -1, 0), + meshOctreeCubeCoordinates(-1, 0, 0, 0), + meshOctreeCubeCoordinates(0, 0, 0, 0), + meshOctreeCubeCoordinates(0, 0, -1, 0) + }, + { //- edge 7 + meshOctreeCubeCoordinates(-1, 0, 0, 0), + meshOctreeCubeCoordinates(-1, 0, 1, 0), + meshOctreeCubeCoordinates(0, 0, 1, 0), + meshOctreeCubeCoordinates(0, 0, 0, 0) + }, + { //- edge 8 + meshOctreeCubeCoordinates(-1, 0, 0, 0), + meshOctreeCubeCoordinates(-1, -1, 0, 0), + meshOctreeCubeCoordinates(0, -1, 0, 0), + meshOctreeCubeCoordinates(0, 0, 0, 0) + }, + { //- edge 9 + meshOctreeCubeCoordinates(0, 0, 0, 0), + meshOctreeCubeCoordinates(0, -1, 0, 0), + meshOctreeCubeCoordinates(1, -1, 0, 0), + meshOctreeCubeCoordinates(1, 0, 0, 0) + }, + { //- edge 10 + meshOctreeCubeCoordinates(0, 1, 0, 0), + meshOctreeCubeCoordinates(0, 0, 0, 0), + meshOctreeCubeCoordinates(1, 0, 0, 0), + meshOctreeCubeCoordinates(1, 1, 0, 0) + }, + { //- edge 11 + meshOctreeCubeCoordinates(-1, 1, 0, 0), + meshOctreeCubeCoordinates(-1, 0, 0, 0), + meshOctreeCubeCoordinates(0, 0, 0, 0), + meshOctreeCubeCoordinates(0, 1, 0, 0) + } + }; + const label tetCreatorOctree::faceCentreHelper_[3][4] = - { - {3, 5, 2, 4}, - {5, 1, 4, 0}, - {1, 3, 0, 2} - }; + { + {3, 5, 2, 4}, + {5, 1, 4, 0}, + {1, 3, 0, 2} + }; void tetCreatorOctree::createTets() { - createPointsAndAddressing(); - - createTetsFromFacesWithCentreNode(); - - createTetsAroundSplitEdges(); - - createTetsAroundEdges(); - - createTetsFromSplitFaces(); - - clearOut(); - sortedLeaves_.setSize(0); - - created_ = true; + createPointsAndAddressing(); + + createTetsFromFacesWithCentreNode(); + + createTetsAroundSplitEdges(); + + createTetsAroundEdges(); + + createTetsFromSplitFaces(); + + clearOut(); + sortedLeaves_.setSize(0); + + created_ = true; } void tetCreatorOctree::clearOut() { - sortedLeaves_.clear(); - deleteDemandDrivenData(subNodeLabelsPtr_); - deleteDemandDrivenData(cubeLabelPtr_); - deleteDemandDrivenData(faceCentreLabelPtr_); + sortedLeaves_.clear(); + deleteDemandDrivenData(subNodeLabelsPtr_); + deleteDemandDrivenData(cubeLabelPtr_); + deleteDemandDrivenData(faceCentreLabelPtr_); } // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // @@ -154,28 +154,28 @@ void tetCreatorOctree::clearOut() tetCreatorOctree::tetCreatorOctree ( const meshOctree& octree, - const IOdictionary& meshDict + const IOdictionary& meshDict ) : octreeCheck_(octree, meshDict, true), - tetPoints_(), - tets_(), - sortedLeaves_(), - subNodeLabelsPtr_(NULL), - cubeLabelPtr_(NULL), - faceCentreLabelPtr_(NULL), - created_(false) + tetPoints_(), + tets_(), + sortedLeaves_(), + subNodeLabelsPtr_(NULL), + cubeLabelPtr_(NULL), + faceCentreLabelPtr_(NULL), + created_(false) { - createTets(); - - clearOut(); + createTets(); + + clearOut(); } // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // tetCreatorOctree::~tetCreatorOctree() { - clearOut(); + clearOut(); } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/meshLibrary/utilities/tetrahedra/tetCreatorOctree/tetCreatorOctree.H b/meshLibrary/utilities/tetrahedra/tetCreatorOctree/tetCreatorOctree.H index d5c1b4f4..4364fd2f 100644 --- a/meshLibrary/utilities/tetrahedra/tetCreatorOctree/tetCreatorOctree.H +++ b/meshLibrary/utilities/tetrahedra/tetCreatorOctree/tetCreatorOctree.H @@ -55,69 +55,69 @@ namespace Foam class tetCreatorOctree { // Private data - //- helper for searching coordinates of cubes around an edge - static const meshOctreeCubeCoordinates edgeCoordinates_[12][4]; - - //- helper for finding face centres of cubes sharing an edge - static const label faceCentreHelper_[3][4]; - + //- helper for searching coordinates of cubes around an edge + static const meshOctreeCubeCoordinates edgeCoordinates_[12][4]; + + //- helper for finding face centres of cubes sharing an edge + static const label faceCentreHelper_[3][4]; + //- reference to the octree meshOctreeAddressing octreeCheck_; - - //- points of the tetrahedrisation - LongList<point> tetPoints_; - - //- tetrahedra - LongList<partTet> tets_; - - //- octree leaves sorted according to their level - List<labelListPMG> sortedLeaves_; - - //- node labels of vertices created inside split-hex boxes - VRWGraph* subNodeLabelsPtr_; - - //- cube centre label - labelList* cubeLabelPtr_; - - //- cube face label - VRWGraph* faceCentreLabelPtr_; - - //- are tets created or not - bool created_; - + + //- points of the tetrahedrisation + LongList<point> tetPoints_; + + //- tetrahedra + LongList<partTet> tets_; + + //- octree leaves sorted according to their level + List<labelListPMG> sortedLeaves_; + + //- node labels of vertices created inside split-hex boxes + VRWGraph* subNodeLabelsPtr_; + + //- cube centre label + labelList* cubeLabelPtr_; + + //- cube face label + VRWGraph* faceCentreLabelPtr_; + + //- are tets created or not + bool created_; + // Private member functions - //- deletes all pointer data - void clearOut(); - - //- find elements which will be used as mesh cells - void selectElements(); - - // Private member functions for creating tetrahedra - //- create tetPoints_ and necessary addressing - void createPointsAndAddressing(); - - //- create faceCentreLabelPtr_ - void createFaceCentreLabels(); - - //- create tetrahedra from faces, owner and neighbour - void createTetsAroundEdges(); - - //- create tetrahedra from split faces - void createTetsFromSplitFaces(); - - //- create tetrahedra from faces which share at least one edge - //- with a refined cube - void createTetsFromFacesWithCentreNode(); - - //- create tetrahedra from faces with split edges - void createTetsAroundSplitEdges(); - - //- helper funtion which checks validity of a created tet and appends - //- it if valid - inline void checkAndAppendTet(const partTet); - - //- function containing the workflow - void createTets(); + //- deletes all pointer data + void clearOut(); + + //- find elements which will be used as mesh cells + void selectElements(); + + // Private member functions for creating tetrahedra + //- create tetPoints_ and necessary addressing + void createPointsAndAddressing(); + + //- create faceCentreLabelPtr_ + void createFaceCentreLabels(); + + //- create tetrahedra from faces, owner and neighbour + void createTetsAroundEdges(); + + //- create tetrahedra from split faces + void createTetsFromSplitFaces(); + + //- create tetrahedra from faces which share at least one edge + //- with a refined cube + void createTetsFromFacesWithCentreNode(); + + //- create tetrahedra from faces with split edges + void createTetsAroundSplitEdges(); + + //- helper funtion which checks validity of a created tet and appends + //- it if valid + inline void checkAndAppendTet(const partTet); + + //- function containing the workflow + void createTets(); // Private copy constructor //- Disallow default bitwise copy construct @@ -134,7 +134,7 @@ public: tetCreatorOctree ( const meshOctree& octree, - const IOdictionary& meshDict + const IOdictionary& meshDict ); // Destructor @@ -143,27 +143,27 @@ public: // Member Functions - const LongList<point>& tetPoints() const - { - if( !created_ ) - FatalErrorIn - ( - "const LongList<point>& tetPoints() const" - ) << "Tets are not created!" << exit(FatalError); - - return tetPoints_; - } - - const LongList<partTet>& tets() const - { - if( !created_ ) - FatalErrorIn - ( - "const LongList<point>& tets() const" - ) << "Tets are not created!" << exit(FatalError); - - return tets_; - } + const LongList<point>& tetPoints() const + { + if( !created_ ) + FatalErrorIn + ( + "const LongList<point>& tetPoints() const" + ) << "Tets are not created!" << exit(FatalError); + + return tetPoints_; + } + + const LongList<partTet>& tets() const + { + if( !created_ ) + FatalErrorIn + ( + "const LongList<point>& tets() const" + ) << "Tets are not created!" << exit(FatalError); + + return tets_; + } }; diff --git a/meshLibrary/utilities/tetrahedra/tetCreatorOctree/tetCreatorOctreeFromFacesWithCentreNode.C b/meshLibrary/utilities/tetrahedra/tetCreatorOctree/tetCreatorOctreeFromFacesWithCentreNode.C index 2abf7d8c..a10259dd 100644 --- a/meshLibrary/utilities/tetrahedra/tetCreatorOctree/tetCreatorOctreeFromFacesWithCentreNode.C +++ b/meshLibrary/utilities/tetrahedra/tetCreatorOctree/tetCreatorOctreeFromFacesWithCentreNode.C @@ -35,43 +35,43 @@ Description namespace Foam { - + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // void tetCreatorOctree::createTetsFromFacesWithCentreNode() { - Info << "Creating tets from faces with centre node" << endl; + Info << "Creating tets from faces with centre node" << endl; + + const labelList& cubeLabel = *cubeLabelPtr_; + const VRWGraph& nodeLabels = octreeCheck_.nodeLabels(); + const VRWGraph& subNodeLabels = *subNodeLabelsPtr_; + const FRWGraph<label, 8>& pointLeaves = octreeCheck_.nodeLeaves(); - const labelList& cubeLabel = *cubeLabelPtr_; - const VRWGraph& nodeLabels = octreeCheck_.nodeLabels(); - const VRWGraph& subNodeLabels = *subNodeLabelsPtr_; - const FRWGraph<label, 8>& pointLeaves = octreeCheck_.nodeLeaves(); - - if( !faceCentreLabelPtr_ ) - faceCentreLabelPtr_ = new VRWGraph(cubeLabel.size()); - VRWGraph& faceCentreLabel = *faceCentreLabelPtr_; - - //- start creating tets - forAll(pointLeaves, pointI) - { - label pl[8]; - bool create(true); - - for(label plI=0;plI<8;++plI) - { - pl[plI] = pointLeaves(pointI, plI); - if( pl[plI] == -1 ) - { - create = false; - break; - } - } - - if( !create ) - continue; - - //- create 6 tets for each possible combination - //- there are 12 possible combinations + if( !faceCentreLabelPtr_ ) + faceCentreLabelPtr_ = new VRWGraph(cubeLabel.size()); + VRWGraph& faceCentreLabel = *faceCentreLabelPtr_; + + //- start creating tets + forAll(pointLeaves, pointI) + { + label pl[8]; + bool create(true); + + for(label plI=0;plI<8;++plI) + { + pl[plI] = pointLeaves(pointI, plI); + if( pl[plI] == -1 ) + { + create = false; + break; + } + } + + if( !create ) + continue; + + //- create 6 tets for each possible combination + //- there are 12 possible combinations for(label fI=0;fI<6;++fI) { const label* fEdges = meshOctreeCubeCoordinates::faceEdges_[fI]; @@ -196,7 +196,7 @@ void tetCreatorOctree::createTetsFromFacesWithCentreNode() } } } - } + } } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/meshLibrary/utilities/tetrahedra/tetCreatorOctree/tetCreatorOctreeI.H b/meshLibrary/utilities/tetrahedra/tetCreatorOctree/tetCreatorOctreeI.H index 16c428b7..cc843727 100644 --- a/meshLibrary/utilities/tetrahedra/tetCreatorOctree/tetCreatorOctreeI.H +++ b/meshLibrary/utilities/tetrahedra/tetCreatorOctree/tetCreatorOctreeI.H @@ -33,23 +33,23 @@ namespace Foam inline void tetCreatorOctree::checkAndAppendTet(const partTet pt) { - bool valid(true); - for(label n=0;n<4;++n) - if( pt[n] < 0 ) - { - valid = false; - break; - } - - if( valid ) - { + bool valid(true); + for(label n=0;n<4;++n) + if( pt[n] < 0 ) + { + valid = false; + break; + } + + if( valid ) + { tets_.append(pt); # ifdef DEBUGTets Info << "Added tet " << (tets_.size()-1) << " is " << tets_[tets_.size()-1] << endl; # endif - } + } } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/meshLibrary/utilities/tetrahedra/tetCreatorOctree/tetCreatorOctreePointsAndAddressing.C b/meshLibrary/utilities/tetrahedra/tetCreatorOctree/tetCreatorOctreePointsAndAddressing.C index a3d4f31a..506fe19f 100644 --- a/meshLibrary/utilities/tetrahedra/tetCreatorOctree/tetCreatorOctreePointsAndAddressing.C +++ b/meshLibrary/utilities/tetrahedra/tetCreatorOctree/tetCreatorOctreePointsAndAddressing.C @@ -37,266 +37,266 @@ Description namespace Foam { - + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // void tetCreatorOctree::selectElements() { - const List<direction>& boxType = octreeCheck_.boxType(); - const meshOctree& octree = octreeCheck_.octree(); - const boundBox& rootBox = octree.rootBox(); - - //- store nodeLabels first - const VRWGraph& nodeLabels = octreeCheck_.nodeLabels(); - tetPoints_.setSize(octreeCheck_.numberOfNodes()); - - forAll(nodeLabels, leafI) - if( nodeLabels.sizeOfRow(leafI) != 0 ) - { - const meshOctreeCubeBasic& oc = octree.returnLeaf(leafI); - FixedList<point, 8> lv; - oc.vertices(rootBox, lv); - - forAll(lv, vI) - tetPoints_[nodeLabels(leafI, vI)] = lv[vI]; - } - - //- create cubeLabel list - if( !cubeLabelPtr_ ) - cubeLabelPtr_ = new labelList(); - labelList& cubeLabel = *cubeLabelPtr_; - cubeLabel.setSize(octree.numberOfLeaves()); - cubeLabel = -1; - - forAll(boxType, leafI) - if( boxType[leafI] & meshOctreeAddressing::MESHCELL ) - { - const meshOctreeCubeBasic& oc = octree.returnLeaf(leafI); - cubeLabel[leafI] = tetPoints_.size(); - tetPoints_.append(oc.centre(rootBox)); - } + const List<direction>& boxType = octreeCheck_.boxType(); + const meshOctree& octree = octreeCheck_.octree(); + const boundBox& rootBox = octree.rootBox(); + + //- store nodeLabels first + const VRWGraph& nodeLabels = octreeCheck_.nodeLabels(); + tetPoints_.setSize(octreeCheck_.numberOfNodes()); + + forAll(nodeLabels, leafI) + if( nodeLabels.sizeOfRow(leafI) != 0 ) + { + const meshOctreeCubeBasic& oc = octree.returnLeaf(leafI); + FixedList<point, 8> lv; + oc.vertices(rootBox, lv); + + forAll(lv, vI) + tetPoints_[nodeLabels(leafI, vI)] = lv[vI]; + } + + //- create cubeLabel list + if( !cubeLabelPtr_ ) + cubeLabelPtr_ = new labelList(); + labelList& cubeLabel = *cubeLabelPtr_; + cubeLabel.setSize(octree.numberOfLeaves()); + cubeLabel = -1; + + forAll(boxType, leafI) + if( boxType[leafI] & meshOctreeAddressing::MESHCELL ) + { + const meshOctreeCubeBasic& oc = octree.returnLeaf(leafI); + cubeLabel[leafI] = tetPoints_.size(); + tetPoints_.append(oc.centre(rootBox)); + } } void tetCreatorOctree::createPointsAndAddressing() { - selectElements(); - - const meshOctree& octree = octreeCheck_.octree(); - const boundBox& rootBox = octree.rootBox(); - const VRWGraph& nodeLabels = octreeCheck_.nodeLabels(); - - if( !subNodeLabelsPtr_ ) - subNodeLabelsPtr_ = new VRWGraph(octree.numberOfLeaves()); - VRWGraph& subNodeLabels = *subNodeLabelsPtr_; - - //- store nodeLabels - direction maxLevel(0); + selectElements(); + + const meshOctree& octree = octreeCheck_.octree(); + const boundBox& rootBox = octree.rootBox(); + const VRWGraph& nodeLabels = octreeCheck_.nodeLabels(); + + if( !subNodeLabelsPtr_ ) + subNodeLabelsPtr_ = new VRWGraph(octree.numberOfLeaves()); + VRWGraph& subNodeLabels = *subNodeLabelsPtr_; + + //- store nodeLabels + direction maxLevel(0); forAll(nodeLabels, leafI) if( octree.returnLeaf(leafI).level() > maxLevel ) maxLevel = octree.returnLeaf(leafI).level(); sortedLeaves_.setSize(maxLevel+1); - forAll(sortedLeaves_, levelI) - sortedLeaves_[levelI].clear(); - + forAll(sortedLeaves_, levelI) + sortedLeaves_[levelI].clear(); + forAll(nodeLabels, leafI) { const meshOctreeCubeBasic& oc = octree.returnLeaf(leafI); sortedLeaves_[oc.level()].append(leafI); } - //- create subNodeLabels - const FRWGraph<label, 8>& pointLeaves = octreeCheck_.nodeLeaves(); - - forAll(pointLeaves, pointI) - { - bool validLeaf[8]; - direction levelI(0); - for(label i=0;i<8;++i) - { - const label pointLeafI = pointLeaves(pointI, i); - - if( pointLeafI == -1 ) - { - validLeaf[i] = false; - } - else - { - validLeaf[i] = true; - for(label j=i+1;j<8;++j) - if( pointLeafI == pointLeaves(pointI, j) ) - { - validLeaf[i] = false; - validLeaf[j] = false; - } - - const direction level = - octree.returnLeaf(pointLeafI).level(); - - if( level > levelI ) - levelI = level; - } - } - - for(label plI=0;plI<8;++plI) - if( validLeaf[plI] ) - { - const label pointLeafI = pointLeaves(pointI, plI); - - const meshOctreeCubeBasic& lc = - octree.returnLeaf(pointLeafI); - - if( lc.level() < levelI ) - { - if( subNodeLabels.sizeOfRow(pointLeafI) != 8 ) - { - subNodeLabels.setRowSize(pointLeafI, 8); - forAllRow(subNodeLabels, pointLeafI, k) - subNodeLabels(pointLeafI, k) = -1; - } - - subNodeLabels(pointLeafI, (7-plI)) = tetPoints_.size(); - FixedList<point, 8> lv; - lc.vertices(rootBox, lv); - - tetPoints_.append - ( - 0.5 * (lv[7-plI] + lc.centre(rootBox)) - ); - } - } - } - - createFaceCentreLabels(); - - # ifdef DEBUGTets - forAll(nodeLabels, leafI) - { - forAllRow(nodeLabels, leafI, nlI) - if( leafI != pointLeaves(nodeLabels(leafI, nlI), (7-nlI)) ) - FatalError << "Shit" << abort(FatalError); - } - # endif + //- create subNodeLabels + const FRWGraph<label, 8>& pointLeaves = octreeCheck_.nodeLeaves(); + + forAll(pointLeaves, pointI) + { + bool validLeaf[8]; + direction levelI(0); + for(label i=0;i<8;++i) + { + const label pointLeafI = pointLeaves(pointI, i); + + if( pointLeafI == -1 ) + { + validLeaf[i] = false; + } + else + { + validLeaf[i] = true; + for(label j=i+1;j<8;++j) + if( pointLeafI == pointLeaves(pointI, j) ) + { + validLeaf[i] = false; + validLeaf[j] = false; + } + + const direction level = + octree.returnLeaf(pointLeafI).level(); + + if( level > levelI ) + levelI = level; + } + } + + for(label plI=0;plI<8;++plI) + if( validLeaf[plI] ) + { + const label pointLeafI = pointLeaves(pointI, plI); + + const meshOctreeCubeBasic& lc = + octree.returnLeaf(pointLeafI); + + if( lc.level() < levelI ) + { + if( subNodeLabels.sizeOfRow(pointLeafI) != 8 ) + { + subNodeLabels.setRowSize(pointLeafI, 8); + forAllRow(subNodeLabels, pointLeafI, k) + subNodeLabels(pointLeafI, k) = -1; + } + + subNodeLabels(pointLeafI, (7-plI)) = tetPoints_.size(); + FixedList<point, 8> lv; + lc.vertices(rootBox, lv); + + tetPoints_.append + ( + 0.5 * (lv[7-plI] + lc.centre(rootBox)) + ); + } + } + } + + createFaceCentreLabels(); + + # ifdef DEBUGTets + forAll(nodeLabels, leafI) + { + forAllRow(nodeLabels, leafI, nlI) + if( leafI != pointLeaves(nodeLabels(leafI, nlI), (7-nlI)) ) + FatalError << "Shit" << abort(FatalError); + } + # endif } void tetCreatorOctree::createFaceCentreLabels() { - Info << "Creating face centre labels " << endl; - const labelList& cubeLabel = *cubeLabelPtr_; - const VRWGraph& nodeLabels = octreeCheck_.nodeLabels(); - const FRWGraph<label, 8>& pointLeaves = octreeCheck_.nodeLeaves(); - const meshOctree& octree = octreeCheck_.octree(); + Info << "Creating face centre labels " << endl; + const labelList& cubeLabel = *cubeLabelPtr_; + const VRWGraph& nodeLabels = octreeCheck_.nodeLabels(); + const FRWGraph<label, 8>& pointLeaves = octreeCheck_.nodeLeaves(); + const meshOctree& octree = octreeCheck_.octree(); - - # ifdef DEBUGTets - Info << "Node labels " << nodeLabels << endl; - # endif - - List<direction> nodeLevel(pointLeaves.size(), direction(0)); - forAll(nodeLabels, leafI) - { - const direction level = octree.returnLeaf(leafI).level(); - - forAllRow(nodeLabels, leafI, nlI) - { - const label nLabel = nodeLabels(leafI, nlI); - # ifdef DEBUGTets - Info << "Node label[" << leafI << "][" << nlI << "] " - << nLabel << endl; - # endif - - if( nodeLevel[nLabel] < level ) - nodeLevel[nLabel] = level; - } - } - - if( !faceCentreLabelPtr_ ) - faceCentreLabelPtr_ = new VRWGraph(cubeLabel.size()); - VRWGraph& faceCentreLabel = *faceCentreLabelPtr_; - - forAll(cubeLabel, cubeI) - if( cubeLabel[cubeI] != -1 ) - { - const direction level = octree.returnLeaf(cubeI).level(); - - for(label i=0;i<6;++i) - { - if( - (faceCentreLabel.sizeOfRow(cubeI) != 0) && - (faceCentreLabel(cubeI, i) != -1) - ) - continue; + + # ifdef DEBUGTets + Info << "Node labels " << nodeLabels << endl; + # endif + + List<direction> nodeLevel(pointLeaves.size(), direction(0)); + forAll(nodeLabels, leafI) + { + const direction level = octree.returnLeaf(leafI).level(); + + forAllRow(nodeLabels, leafI, nlI) + { + const label nLabel = nodeLabels(leafI, nlI); + # ifdef DEBUGTets + Info << "Node label[" << leafI << "][" << nlI << "] " + << nLabel << endl; + # endif + + if( nodeLevel[nLabel] < level ) + nodeLevel[nLabel] = level; + } + } + + if( !faceCentreLabelPtr_ ) + faceCentreLabelPtr_ = new VRWGraph(cubeLabel.size()); + VRWGraph& faceCentreLabel = *faceCentreLabelPtr_; + + forAll(cubeLabel, cubeI) + if( cubeLabel[cubeI] != -1 ) + { + const direction level = octree.returnLeaf(cubeI).level(); + + for(label i=0;i<6;++i) + { + if( + (faceCentreLabel.sizeOfRow(cubeI) != 0) && + (faceCentreLabel(cubeI, i) != -1) + ) + continue; const FixedList<label, 4> faceNodes = meshOctreeCubeCoordinates::faceNodes_[i]; - - label highLevelNode(-1); - for(label j=0;j<4;++j) - if( nodeLevel[nodeLabels(cubeI, faceNodes[j])] > level ) - { - highLevelNode = j; - break; - } - - if( highLevelNode == -1 ) - continue; - - DynList<label> neighbours(4); - octree.findNeighboursInDirection(cubeI, i, neighbours); - - if( (neighbours.size() != 1) || (neighbours[0] == -1) ) - continue; - - if( faceCentreLabel.sizeOfRow(cubeI) == 0 ) - { - faceCentreLabel.setRowSize(cubeI, 6); - forAllRow(faceCentreLabel, cubeI, colI) - faceCentreLabel(cubeI, colI) = -1; - } - const label cNei = neighbours[0]; - if( faceCentreLabel.sizeOfRow(cNei) == 0 ) - { - faceCentreLabel.setRowSize(cNei, 6); - forAllRow(faceCentreLabel, cNei, colI) - faceCentreLabel(cNei, colI) = -1; - } - - faceCentreLabel(cubeI, i) = tetPoints_.size(); - switch( i ) - { - case 0: - { - faceCentreLabel(cNei, 1) = tetPoints_.size(); - } break; - case 1: - { - faceCentreLabel(cNei, 0) = tetPoints_.size(); - } break; - case 2: - { - faceCentreLabel(cNei, 3) = tetPoints_.size(); - } break; - case 3: - { - faceCentreLabel(cNei, 2) = tetPoints_.size(); - } break; - case 4: - { - faceCentreLabel(cNei, 5) = tetPoints_.size(); - } break; - case 5: - { - faceCentreLabel(cNei, 4) = tetPoints_.size(); - } break; - }; - - point p(vector::zero); - for(label j=0;j<4;++j) - p += tetPoints_[nodeLabels(cubeI, faceNodes[j])]; - p /= 4; - tetPoints_.append(p); - } - } + + label highLevelNode(-1); + for(label j=0;j<4;++j) + if( nodeLevel[nodeLabels(cubeI, faceNodes[j])] > level ) + { + highLevelNode = j; + break; + } + + if( highLevelNode == -1 ) + continue; + + DynList<label> neighbours(4); + octree.findNeighboursInDirection(cubeI, i, neighbours); + + if( (neighbours.size() != 1) || (neighbours[0] == -1) ) + continue; + + if( faceCentreLabel.sizeOfRow(cubeI) == 0 ) + { + faceCentreLabel.setRowSize(cubeI, 6); + forAllRow(faceCentreLabel, cubeI, colI) + faceCentreLabel(cubeI, colI) = -1; + } + const label cNei = neighbours[0]; + if( faceCentreLabel.sizeOfRow(cNei) == 0 ) + { + faceCentreLabel.setRowSize(cNei, 6); + forAllRow(faceCentreLabel, cNei, colI) + faceCentreLabel(cNei, colI) = -1; + } + + faceCentreLabel(cubeI, i) = tetPoints_.size(); + switch( i ) + { + case 0: + { + faceCentreLabel(cNei, 1) = tetPoints_.size(); + } break; + case 1: + { + faceCentreLabel(cNei, 0) = tetPoints_.size(); + } break; + case 2: + { + faceCentreLabel(cNei, 3) = tetPoints_.size(); + } break; + case 3: + { + faceCentreLabel(cNei, 2) = tetPoints_.size(); + } break; + case 4: + { + faceCentreLabel(cNei, 5) = tetPoints_.size(); + } break; + case 5: + { + faceCentreLabel(cNei, 4) = tetPoints_.size(); + } break; + }; + + point p(vector::zero); + for(label j=0;j<4;++j) + p += tetPoints_[nodeLabels(cubeI, faceNodes[j])]; + p /= 4; + tetPoints_.append(p); + } + } } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/meshLibrary/utilities/tetrahedra/tetCreatorOctree/tetCreatorOctreeTetsAroundEdges.C b/meshLibrary/utilities/tetrahedra/tetCreatorOctree/tetCreatorOctreeTetsAroundEdges.C index 1836b3f9..234d6a55 100644 --- a/meshLibrary/utilities/tetrahedra/tetCreatorOctree/tetCreatorOctreeTetsAroundEdges.C +++ b/meshLibrary/utilities/tetrahedra/tetCreatorOctree/tetCreatorOctreeTetsAroundEdges.C @@ -36,101 +36,101 @@ Description namespace Foam { - + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - + void tetCreatorOctree::createTetsAroundEdges() { - Info << "Creating tets around edges" << endl; + Info << "Creating tets around edges" << endl; - const labelList& cubeLabel = *cubeLabelPtr_; - const VRWGraph& nodeLabels = octreeCheck_.nodeLabels(); + const labelList& cubeLabel = *cubeLabelPtr_; + const VRWGraph& nodeLabels = octreeCheck_.nodeLabels(); const FRWGraph<label, 8>& pLeaves = octreeCheck_.nodeLeaves(); - const VRWGraph& subNodeLabels = *subNodeLabelsPtr_; - const VRWGraph& faceCentreLabel = *faceCentreLabelPtr_; - const meshOctree& octree = octreeCheck_.octree(); + const VRWGraph& subNodeLabels = *subNodeLabelsPtr_; + const VRWGraph& faceCentreLabel = *faceCentreLabelPtr_; + const meshOctree& octree = octreeCheck_.octree(); const FixedList<FixedList<meshOctreeCubeCoordinates, 8>, 8>& vlPos = octree.positionsOfLeavesAtNodes(); - + //- find maximum refinement level of octree leaves attached to each vertex - List<direction> nodeLevel(octreeCheck_.numberOfNodes()); + List<direction> nodeLevel(octreeCheck_.numberOfNodes()); - forAll(pLeaves, nodeI) - { + forAll(pLeaves, nodeI) + { direction level(0); - - for(label plI=0;plI<8;++plI) - { + + for(label plI=0;plI<8;++plI) + { const label leafI = pLeaves(nodeI, plI); - if( leafI < 0 ) + if( leafI < 0 ) continue; - level = Foam::max(level, octree.returnLeaf(leafI).level()); - } + level = Foam::max(level, octree.returnLeaf(leafI).level()); + } nodeLevel[nodeI] = level; - } - + } + //- start creating tets around edges which have both vertices at the same //- refinement level which is equal to the max refinement level of boxes //- incident to such edges - forAllReverse(sortedLeaves_, levelI) - { - const labelListPMG& curLevelLeaves = sortedLeaves_[levelI]; - - forAll(curLevelLeaves, leafI) - { - const label curLeaf = curLevelLeaves[leafI]; - - if( cubeLabel[curLeaf] == -1 ) - continue; + forAllReverse(sortedLeaves_, levelI) + { + const labelListPMG& curLevelLeaves = sortedLeaves_[levelI]; + + forAll(curLevelLeaves, leafI) + { + const label curLeaf = curLevelLeaves[leafI]; + + if( cubeLabel[curLeaf] == -1 ) + continue; const meshOctreeCubeCoordinates& cc = octree.returnLeaf(curLeaf).coordinates(); - - # ifdef DEBUGTets - Info << "Search cube " << curLeaf << " has coordinates " - << octree.returnLeaf(curLeaf).coordinates() << endl; - Info << "Node labels for cube are " << nodeLabels[curLeaf] << endl; - # endif + + # ifdef DEBUGTets + Info << "Search cube " << curLeaf << " has coordinates " + << octree.returnLeaf(curLeaf).coordinates() << endl; + Info << "Node labels for cube are " << nodeLabels[curLeaf] << endl; + # endif //- start checking edges - for(label eI=0;eI<12;++eI) - { + for(label eI=0;eI<12;++eI) + { const label startNode = meshOctreeCubeCoordinates::edgeNodes_[eI][0]; - const label start = nodeLabels(curLeaf, startNode); - const label end = - nodeLabels - ( - curLeaf, - meshOctreeCubeCoordinates::edgeNodes_[eI][1] - ); - - # ifdef DEBUGTets - Info << "Creating tets around edge " << eI << endl; - Info << "Edge nodes are " << start << " and " << end << endl; + const label start = nodeLabels(curLeaf, startNode); + const label end = + nodeLabels + ( + curLeaf, + meshOctreeCubeCoordinates::edgeNodes_[eI][1] + ); + + # ifdef DEBUGTets + Info << "Creating tets around edge " << eI << endl; + Info << "Edge nodes are " << start << " and " << end << endl; Info << "Coordinates start " << tetPoints_[start] << " end " << tetPoints_[end] << endl; - # endif - - bool create(true); - - if( - (nodeLevel[start] == levelI) && - (nodeLevel[end] == levelI) + # endif + + bool create(true); + + if( + (nodeLevel[start] == levelI) && + (nodeLevel[end] == levelI) ) - { + { //- edge has both vertices at the same refinement level //- as the current leaf - FixedList<label, 4> edgeCubes; + FixedList<label, 4> edgeCubes; const label fI = 2*(eI/4)+1; const label* fNodes = meshOctreeCubeCoordinates::faceNodes_[fI]; - + //- store octree leaves at this edge //- they are all adjacent to the start point for(label i=0;i<4;++i) @@ -148,48 +148,48 @@ void tetCreatorOctree::createTetsAroundEdges() << nodeLabels[edgeCubes[i]] << endl; } # endif - + DynList<label> centreNodes; - - forAll(edgeCubes, i) - { - const label cLabel = edgeCubes[i]; - - if( (cLabel == -1) || (cubeLabel[cLabel] == -1) ) - { - centreNodes.append(-1); - continue; - } - - const meshOctreeCubeCoordinates& oc = - octree.returnLeaf(cLabel).coordinates(); - - # ifdef DEBUGTets - Info << "Edge cube " << i << " is " << oc << endl; - Info << "Node labels "; - forAllRow(nodeLabels, cLabel, k) - Info << nodeLabels(cLabel, k) << " "; - Info << endl; - # endif - - if( oc.level() == levelI ) - { - if( cLabel < curLeaf ) - { - create = false; - break; - } - - # ifdef DEBUGTets - Info << "Adding centre label " << cubeLabel[cLabel] - << endl; - # endif - - centreNodes.append(cubeLabel[cLabel]); - + + forAll(edgeCubes, i) + { + const label cLabel = edgeCubes[i]; + + if( (cLabel == -1) || (cubeLabel[cLabel] == -1) ) + { + centreNodes.append(-1); + continue; + } + + const meshOctreeCubeCoordinates& oc = + octree.returnLeaf(cLabel).coordinates(); + + # ifdef DEBUGTets + Info << "Edge cube " << i << " is " << oc << endl; + Info << "Node labels "; + forAllRow(nodeLabels, cLabel, k) + Info << nodeLabels(cLabel, k) << " "; + Info << endl; + # endif + + if( oc.level() == levelI ) + { + if( cLabel < curLeaf ) + { + create = false; + break; + } + + # ifdef DEBUGTets + Info << "Adding centre label " << cubeLabel[cLabel] + << endl; + # endif + + centreNodes.append(cubeLabel[cLabel]); + //- adding face centre labels - if( faceCentreLabel.sizeOfRow(cLabel) != 0 ) - { + if( faceCentreLabel.sizeOfRow(cLabel) != 0 ) + { const label helpFace = eI/4; const label fcl = @@ -201,15 +201,15 @@ void tetCreatorOctree::createTetsAroundEdges() if( fcl != -1 ) centreNodes.append(fcl); - } - - # ifdef DEBUGTets - Info << "Centre nodes after cube " << i - << " are " << centreNodes << endl; - # endif - } - else if( oc.level() < levelI ) - { + } + + # ifdef DEBUGTets + Info << "Centre nodes after cube " << i + << " are " << centreNodes << endl; + # endif + } + else if( oc.level() < levelI ) + { # ifdef DEBUGTets Info << "Edge cube " << cLabel << endl; Info << "cc " << cc << endl; @@ -227,7 +227,7 @@ void tetCreatorOctree::createTetsAroundEdges() Info << "sc " << sc << endl; # endif - label pos(-1); + label pos(-1); for(label j=0;j<8;j++) { @@ -245,34 +245,34 @@ void tetCreatorOctree::createTetsAroundEdges() "createTetsAroundEdges()" ) << "Cannot find cube position" << abort(FatalError); - - # ifdef DEBUGTets - Info << "Pos " << pos << endl; - # endif - + + # ifdef DEBUGTets + Info << "Pos " << pos << endl; + # endif + centreNodes.append(subNodeLabels(cLabel, pos)); - - # ifdef DEBUGTets - Info << "Centre node " << i << " is " - << subNodeLabels(cLabel, pos) + + # ifdef DEBUGTets + Info << "Centre node " << i << " is " + << subNodeLabels(cLabel, pos) << " coordinates " << tetPoints_[subNodeLabels(cLabel, pos)] << endl; - # endif - } - } - - //- create tets around this edge - if( create ) - { - const label nCentres = centreNodes.size(); - - forAll(centreNodes, i) - { - if( centreNodes[i] == -1 ) - continue; - if( centreNodes[(i+1)%nCentres] == -1 ) - continue; + # endif + } + } + + //- create tets around this edge + if( create ) + { + const label nCentres = centreNodes.size(); + + forAll(centreNodes, i) + { + if( centreNodes[i] == -1 ) + continue; + if( centreNodes[(i+1)%nCentres] == -1 ) + continue; partTet tet ( @@ -281,20 +281,20 @@ void tetCreatorOctree::createTetsAroundEdges() start, end ); - - tets_.append(tet); - - # ifdef DEBUGTets - Info << "Last added tet " - << tets_.size()-1 <<" is " - << tets_[tets_.size()-1] << endl; - # endif - } - } - } - } - } - } + + tets_.append(tet); + + # ifdef DEBUGTets + Info << "Last added tet " + << tets_.size()-1 <<" is " + << tets_[tets_.size()-1] << endl; + # endif + } + } + } + } + } + } } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/meshLibrary/utilities/tetrahedra/tetCreatorOctree/tetCreatorOctreeTetsAroundSplitEdges.C b/meshLibrary/utilities/tetrahedra/tetCreatorOctree/tetCreatorOctreeTetsAroundSplitEdges.C index 74f7363a..cf806e96 100644 --- a/meshLibrary/utilities/tetrahedra/tetCreatorOctree/tetCreatorOctreeTetsAroundSplitEdges.C +++ b/meshLibrary/utilities/tetrahedra/tetCreatorOctree/tetCreatorOctreeTetsAroundSplitEdges.C @@ -36,82 +36,82 @@ Description namespace Foam { - + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - + void tetCreatorOctree::createTetsAroundSplitEdges() { - Info << "Creating tets around split edges " << endl; + Info << "Creating tets around split edges " << endl; - const labelList& cubeLabel = *cubeLabelPtr_; - const meshOctree& octree = octreeCheck_.octree(); - const VRWGraph& nodeLabels = octreeCheck_.nodeLabels(); + const labelList& cubeLabel = *cubeLabelPtr_; + const meshOctree& octree = octreeCheck_.octree(); + const VRWGraph& nodeLabels = octreeCheck_.nodeLabels(); const FRWGraph<label, 8>& pLeaves = octreeCheck_.nodeLeaves(); - const VRWGraph& subNodeLabels = *subNodeLabelsPtr_; - const VRWGraph& faceCentreLabel = *faceCentreLabelPtr_; - - # ifdef DEBUGTets - Info << "Number of octree nodes " << octreeCheck_.numberOfNodes() << endl; - # endif - + const VRWGraph& subNodeLabels = *subNodeLabelsPtr_; + const VRWGraph& faceCentreLabel = *faceCentreLabelPtr_; + + # ifdef DEBUGTets + Info << "Number of octree nodes " << octreeCheck_.numberOfNodes() << endl; + # endif + //- find maximum refinement level of octree leaves attached to each vertex - List<direction> nodeLevel(octreeCheck_.numberOfNodes()); + List<direction> nodeLevel(octreeCheck_.numberOfNodes()); - forAll(pLeaves, nodeI) - { + forAll(pLeaves, nodeI) + { direction level(0); - - for(label plI=0;plI<8;++plI) - { + + for(label plI=0;plI<8;++plI) + { const label leafI = pLeaves(nodeI, plI); - if( leafI < 0 ) + if( leafI < 0 ) continue; - level = Foam::max(level, octree.returnLeaf(leafI).level()); - } + level = Foam::max(level, octree.returnLeaf(leafI).level()); + } nodeLevel[nodeI] = level; - } - - //- start creating tets around split edges - label helpNodes[2][8]; - label faceCentres[4]; - - forAllReverse(sortedLeaves_, levelI) - { - const labelListPMG& curLevelLeaves = sortedLeaves_[levelI]; - - forAll(curLevelLeaves, leafI) - { - const label curLabel = curLevelLeaves[leafI]; - - if( cubeLabel[curLabel] == -1 ) - continue; - + } + + //- start creating tets around split edges + label helpNodes[2][8]; + label faceCentres[4]; + + forAllReverse(sortedLeaves_, levelI) + { + const labelListPMG& curLevelLeaves = sortedLeaves_[levelI]; + + forAll(curLevelLeaves, leafI) + { + const label curLabel = curLevelLeaves[leafI]; + + if( cubeLabel[curLabel] == -1 ) + continue; + //- start checking edges - for(label eI=0;eI<12;++eI) - { - const label start = - nodeLabels - ( - curLabel, - meshOctreeCubeCoordinates::edgeNodes_[eI][0] - ); - const label end = - nodeLabels - ( - curLabel, - meshOctreeCubeCoordinates::edgeNodes_[eI][1] - ); - - if( (nodeLevel[start] == levelI) && (nodeLevel[end] == levelI) ) - continue; - + for(label eI=0;eI<12;++eI) + { + const label start = + nodeLabels + ( + curLabel, + meshOctreeCubeCoordinates::edgeNodes_[eI][0] + ); + const label end = + nodeLabels + ( + curLabel, + meshOctreeCubeCoordinates::edgeNodes_[eI][1] + ); + + if( (nodeLevel[start] == levelI) && (nodeLevel[end] == levelI) ) + continue; + //- the edge has at least one vertex at different ref level - bool create(true); + bool create(true); - FixedList<label, 4> edgeCubes; + FixedList<label, 4> edgeCubes; const label fI = 2*(eI/4)+1; const label* fNodes = @@ -121,68 +121,68 @@ void tetCreatorOctree::createTetsAroundSplitEdges() //- they are all adjacent to the start point for(label i=0;i<4;++i) edgeCubes[i] = pLeaves(start, fNodes[i]); - - # ifdef DEBUGTets - Info << "Cube " << curLabel << " has nodes "; - forAllRow(nodeLabels, curLabel, i) - Info << nodeLabels(curLabel, i) << " "; - Info << endl; - Info << "Creating tets around edge " << eI << endl; - Info << "Edge nodes are " << start << " and " << end << endl; - Info << "Edge cubes " << edgeCubes << endl; - # endif - - forAll(edgeCubes, i) - { - const label cLabel = edgeCubes[i]; - - if( - (cLabel == -1) || - (cLabel < curLabel) || - (octree.returnLeaf(cLabel).level() != levelI) - ) - { - create = false; - break; - } - - # ifdef DEBUGTets - Info << "Edge cube " << i << " is " << cLabel << endl; - # endif - - for(label j=0;j<8;++j) - { - if( nodeLabels(cLabel,j) == start ) - { - if( subNodeLabels.sizeOfRow(cLabel) != 0 ) - { - helpNodes[0][i] = subNodeLabels(cLabel,j); - } - else - { - helpNodes[0][i] = -1; - } - - helpNodes[0][i+4] = cubeLabel[cLabel]; - } - - if( nodeLabels(cLabel, j) == end ) - { - if( subNodeLabels.sizeOfRow(cLabel) != 0 ) - { - helpNodes[1][i+4] = subNodeLabels(cLabel,j); - } - else - { - helpNodes[1][i+4] = -1; - } - - helpNodes[1][i] = cubeLabel[cLabel]; - } - } - - if( faceCentreLabel.sizeOfRow(cLabel) != 0 ) - { + + # ifdef DEBUGTets + Info << "Cube " << curLabel << " has nodes "; + forAllRow(nodeLabels, curLabel, i) + Info << nodeLabels(curLabel, i) << " "; + Info << endl; + Info << "Creating tets around edge " << eI << endl; + Info << "Edge nodes are " << start << " and " << end << endl; + Info << "Edge cubes " << edgeCubes << endl; + # endif + + forAll(edgeCubes, i) + { + const label cLabel = edgeCubes[i]; + + if( + (cLabel == -1) || + (cLabel < curLabel) || + (octree.returnLeaf(cLabel).level() != levelI) + ) + { + create = false; + break; + } + + # ifdef DEBUGTets + Info << "Edge cube " << i << " is " << cLabel << endl; + # endif + + for(label j=0;j<8;++j) + { + if( nodeLabels(cLabel,j) == start ) + { + if( subNodeLabels.sizeOfRow(cLabel) != 0 ) + { + helpNodes[0][i] = subNodeLabels(cLabel,j); + } + else + { + helpNodes[0][i] = -1; + } + + helpNodes[0][i+4] = cubeLabel[cLabel]; + } + + if( nodeLabels(cLabel, j) == end ) + { + if( subNodeLabels.sizeOfRow(cLabel) != 0 ) + { + helpNodes[1][i+4] = subNodeLabels(cLabel,j); + } + else + { + helpNodes[1][i+4] = -1; + } + + helpNodes[1][i] = cubeLabel[cLabel]; + } + } + + if( faceCentreLabel.sizeOfRow(cLabel) != 0 ) + { const label helpFace = eI/4; faceCentres[i] = @@ -191,199 +191,199 @@ void tetCreatorOctree::createTetsAroundSplitEdges() cLabel, faceCentreHelper_[helpFace][i] ); - } - else - { - faceCentres[i] = -1; - } - } - - if( !create ) - continue; - - # ifdef DEBUGTets - for(label n=0;n<4;++n) - { - Info << "Face centre " << n << " " - << faceCentres[n] << endl; - Info << "Hex 0 " << helpNodes[0][n] << " and " - << helpNodes[0][n+4] << endl; - Info << "Hex 1 " << helpNodes[1][n] << " and " - << helpNodes[1][n+4] << endl; - } - # endif - - if( nodeLevel[start] > levelI ) - { - for(label k=0;k<4;++k) - { - //- add 4 tets - checkAndAppendTet - ( - partTet - ( - start, - helpNodes[0][k], - helpNodes[0][(k+1)%4], - tetPoints_.size() - ) - ); - - //- 2. tet - checkAndAppendTet - ( - partTet - ( - tetPoints_.size(), - helpNodes[0][k], - helpNodes[0][(k+1)%4], - faceCentres[k] - ) - ); - - //- 3. tet - checkAndAppendTet - ( - partTet - ( - faceCentres[k], - helpNodes[0][k], - helpNodes[0][k+4], - tetPoints_.size() - ) - ); - - //- 4. tet - checkAndAppendTet - ( - partTet - ( - faceCentres[(k+3)%4], - helpNodes[0][k+4], - helpNodes[0][k], - tetPoints_.size() - ) - ); - } - } - else - { - for(label k=0;k<4;++k) - { - checkAndAppendTet - ( - partTet - ( - faceCentres[(k+3)%4], - helpNodes[0][k+4], - start, - tetPoints_.size() - ) - ); - - checkAndAppendTet - ( - partTet - ( - faceCentres[k], - start, - helpNodes[0][k+4], - tetPoints_.size() - ) - ); - } - } - - if( nodeLevel[end] > levelI ) - { - for(label k=0;k<4;++k) - { - //- add 4 tets - checkAndAppendTet - ( - partTet - ( - tetPoints_.size(), - helpNodes[1][k+4], - helpNodes[1][((k+1)%4)+4], - end - ) - ); - - // 2. tet - checkAndAppendTet - ( - partTet - ( - faceCentres[k], - helpNodes[1][k+4], - helpNodes[1][((k+1)%4)+4], - tetPoints_.size() - ) - ); - - //- 3. tet - checkAndAppendTet - ( - partTet - ( - tetPoints_.size(), - helpNodes[1][k], - faceCentres[k], - helpNodes[1][k+4] - ) - ); - - //- 4. tet - checkAndAppendTet - ( - partTet - ( - faceCentres[(k+3)%4], - helpNodes[1][k], - tetPoints_.size(), - helpNodes[1][k+4] - ) - ); - } - } - else - { - for(label k=0;k<4;++k) - { - checkAndAppendTet - ( - partTet - ( - faceCentres[(k+3)%4], - helpNodes[1][k], - tetPoints_.size(), - end - ) - ); - - checkAndAppendTet - ( - partTet - ( - helpNodes[1][k], - faceCentres[k], - tetPoints_.size(), - end - ) - ); - } - } - + } + else + { + faceCentres[i] = -1; + } + } + + if( !create ) + continue; + + # ifdef DEBUGTets + for(label n=0;n<4;++n) + { + Info << "Face centre " << n << " " + << faceCentres[n] << endl; + Info << "Hex 0 " << helpNodes[0][n] << " and " + << helpNodes[0][n+4] << endl; + Info << "Hex 1 " << helpNodes[1][n] << " and " + << helpNodes[1][n+4] << endl; + } + # endif + + if( nodeLevel[start] > levelI ) + { + for(label k=0;k<4;++k) + { + //- add 4 tets + checkAndAppendTet + ( + partTet + ( + start, + helpNodes[0][k], + helpNodes[0][(k+1)%4], + tetPoints_.size() + ) + ); + + //- 2. tet + checkAndAppendTet + ( + partTet + ( + tetPoints_.size(), + helpNodes[0][k], + helpNodes[0][(k+1)%4], + faceCentres[k] + ) + ); + + //- 3. tet + checkAndAppendTet + ( + partTet + ( + faceCentres[k], + helpNodes[0][k], + helpNodes[0][k+4], + tetPoints_.size() + ) + ); + + //- 4. tet + checkAndAppendTet + ( + partTet + ( + faceCentres[(k+3)%4], + helpNodes[0][k+4], + helpNodes[0][k], + tetPoints_.size() + ) + ); + } + } + else + { + for(label k=0;k<4;++k) + { + checkAndAppendTet + ( + partTet + ( + faceCentres[(k+3)%4], + helpNodes[0][k+4], + start, + tetPoints_.size() + ) + ); + + checkAndAppendTet + ( + partTet + ( + faceCentres[k], + start, + helpNodes[0][k+4], + tetPoints_.size() + ) + ); + } + } + + if( nodeLevel[end] > levelI ) + { + for(label k=0;k<4;++k) + { + //- add 4 tets + checkAndAppendTet + ( + partTet + ( + tetPoints_.size(), + helpNodes[1][k+4], + helpNodes[1][((k+1)%4)+4], + end + ) + ); + + // 2. tet + checkAndAppendTet + ( + partTet + ( + faceCentres[k], + helpNodes[1][k+4], + helpNodes[1][((k+1)%4)+4], + tetPoints_.size() + ) + ); + + //- 3. tet + checkAndAppendTet + ( + partTet + ( + tetPoints_.size(), + helpNodes[1][k], + faceCentres[k], + helpNodes[1][k+4] + ) + ); + + //- 4. tet + checkAndAppendTet + ( + partTet + ( + faceCentres[(k+3)%4], + helpNodes[1][k], + tetPoints_.size(), + helpNodes[1][k+4] + ) + ); + } + } + else + { + for(label k=0;k<4;++k) + { + checkAndAppendTet + ( + partTet + ( + faceCentres[(k+3)%4], + helpNodes[1][k], + tetPoints_.size(), + end + ) + ); + + checkAndAppendTet + ( + partTet + ( + helpNodes[1][k], + faceCentres[k], + tetPoints_.size(), + end + ) + ); + } + } + //- add the edge centre - tetPoints_.append(0.5 * (tetPoints_[start] + tetPoints_[end])); - } - } - } - - # ifdef DEBUGTets - Info << "Created tets " << tets_ << endl; - # endif + tetPoints_.append(0.5 * (tetPoints_[start] + tetPoints_[end])); + } + } + } + + # ifdef DEBUGTets + Info << "Created tets " << tets_ << endl; + # endif } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/meshLibrary/utilities/tetrahedra/tetCreatorOctree/tetCreatorOctreeTetsFromSplitFaces.C b/meshLibrary/utilities/tetrahedra/tetCreatorOctree/tetCreatorOctreeTetsFromSplitFaces.C index 65d41d83..db43ed66 100644 --- a/meshLibrary/utilities/tetrahedra/tetCreatorOctree/tetCreatorOctreeTetsFromSplitFaces.C +++ b/meshLibrary/utilities/tetrahedra/tetCreatorOctree/tetCreatorOctreeTetsFromSplitFaces.C @@ -35,54 +35,54 @@ Description namespace Foam { - + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // void tetCreatorOctree::createTetsFromSplitFaces() { - Info << "Creating tets from split faces" << endl; + Info << "Creating tets from split faces" << endl; + + const labelList& cubeLabel = *cubeLabelPtr_; + const VRWGraph& subNodeLabels = *subNodeLabelsPtr_; + const FRWGraph<label, 8>& pLeaves = octreeCheck_.nodeLeaves(); - const labelList& cubeLabel = *cubeLabelPtr_; - const VRWGraph& subNodeLabels = *subNodeLabelsPtr_; - const FRWGraph<label, 8>& pLeaves = octreeCheck_.nodeLeaves(); - - forAll(pLeaves, pointI) - { - for(label i=0;i<6;++i) - { + forAll(pLeaves, pointI) + { + for(label i=0;i<6;++i) + { const label* fNodes = meshOctreeCubeCoordinates::faceNodes_[i]; - const label cLabel = pLeaves(pointI, fNodes[0]); + const label cLabel = pLeaves(pointI, fNodes[0]); if( cLabel < 0 ) continue; if( cubeLabel[cLabel] < 0 ) continue; - if( - (cLabel == pLeaves(pointI, fNodes[1])) && - (cLabel == pLeaves(pointI, fNodes[2])) && - (cLabel == pLeaves(pointI, fNodes[3])) - ) - { - //- create 4 tets - for(label j=0;j<4;++j) + if( + (cLabel == pLeaves(pointI, fNodes[1])) && + (cLabel == pLeaves(pointI, fNodes[2])) && + (cLabel == pLeaves(pointI, fNodes[3])) + ) + { + //- create 4 tets + for(label j=0;j<4;++j) { - checkAndAppendTet - ( - partTet - ( - pointI, - subNodeLabels(cLabel, 7-fNodes[j]), - subNodeLabels(cLabel, 7-fNodes[(j+1)%4]), - cubeLabel[cLabel] - ) - ); + checkAndAppendTet + ( + partTet + ( + pointI, + subNodeLabels(cLabel, 7-fNodes[j]), + subNodeLabels(cLabel, 7-fNodes[(j+1)%4]), + cubeLabel[cLabel] + ) + ); } - } - } - } + } + } + } } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/meshLibrary/utilities/tetrahedra/tetPointsCreator/tetPointsCreator.C b/meshLibrary/utilities/tetrahedra/tetPointsCreator/tetPointsCreator.C index 33f87040..c6fa2f2c 100644 --- a/meshLibrary/utilities/tetrahedra/tetPointsCreator/tetPointsCreator.C +++ b/meshLibrary/utilities/tetrahedra/tetPointsCreator/tetPointsCreator.C @@ -40,14 +40,14 @@ namespace Foam // Construct from octree and mesh data tetPointsCreator::tetPointsCreator ( - tetTessellation& tessellation, + tetTessellation& tessellation, const meshOctree& octree ) : - tessellation_(tessellation), + tessellation_(tessellation), octree_(octree) { - createPoints(); + createPoints(); } // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // diff --git a/meshLibrary/utilities/tetrahedra/tetPointsCreator/tetPointsCreator.H b/meshLibrary/utilities/tetrahedra/tetPointsCreator/tetPointsCreator.H index 8029e388..96d8e31b 100644 --- a/meshLibrary/utilities/tetrahedra/tetPointsCreator/tetPointsCreator.H +++ b/meshLibrary/utilities/tetrahedra/tetPointsCreator/tetPointsCreator.H @@ -56,25 +56,25 @@ class tetTessellation; class tetPointsCreator { // Private data - //- reference to the Delaunay tessellation - tetTessellation& tessellation_; - + //- reference to the Delaunay tessellation + tetTessellation& tessellation_; + //- reference to the octree const meshOctree& octree_; // Private member functions //- create vertices and pointLeaves addressing void createPoints(); - - // Helper functions - //- checks if the point is inside the surface - bool isPointInsideSurface(const point&) const; - - //- find out if this element has been changed already - bool isElementChanged(const label elmtI, const label nElements) const; - - //- return cell size at the given location - scalar cellSizeAtLocation(const point&) const; + + // Helper functions + //- checks if the point is inside the surface + bool isPointInsideSurface(const point&) const; + + //- find out if this element has been changed already + bool isElementChanged(const label elmtI, const label nElements) const; + + //- return cell size at the given location + scalar cellSizeAtLocation(const point&) const; // Private copy constructor //- Disallow default bitwise copy construct @@ -90,7 +90,7 @@ public: //- Construct from octree and mesh data tetPointsCreator ( - tetTessellation& tessellation, + tetTessellation& tessellation, const meshOctree& octree ); diff --git a/meshLibrary/utilities/tetrahedra/tetPointsCreator/tetPointsCreatorAddPoints.C b/meshLibrary/utilities/tetrahedra/tetPointsCreator/tetPointsCreatorAddPoints.C index 3cb78a81..f1c0856b 100644 --- a/meshLibrary/utilities/tetrahedra/tetPointsCreator/tetPointsCreatorAddPoints.C +++ b/meshLibrary/utilities/tetrahedra/tetPointsCreator/tetPointsCreatorAddPoints.C @@ -37,88 +37,88 @@ Description namespace Foam { - + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // void tetPointsCreator::createPoints() { - //- create initial bunch of points from centroids of the existing tets - //- repeat this until the first internal point is found - const LongList<point>& tetPoints = tessellation_.points(); - const LongList<tessellationElement>& elmts = tessellation_.elmts(); - LongList<bool> internalPoint(tetPoints.size(), false); - - bool found; - label nIter(0); - do - { - Info << "Tessellation has " << tetPoints.size() << " points" << endl; - Info << "Number of tets " << elmts.size() << endl; - found = false; - const label nPoints = tetPoints.size(); - const label nElements = elmts.size(); - for(label elmtI=0;elmtI<nElements;++elmtI) - //forAll(elmts, elmtI) - { - if( isElementChanged(elmtI, nPoints) ) - continue; - - const tessellationElement& elmt = elmts[elmtI]; - const point p = elmt.centroid(tetPoints); - - if( isPointInsideSurface(p) ) - { - tessellation_.addCentroid(elmtI); - found = true; - } - } - } while( found && (++nIter < 7) ); - - tessellation_.checkTessellation(); + //- create initial bunch of points from centroids of the existing tets + //- repeat this until the first internal point is found + const LongList<point>& tetPoints = tessellation_.points(); + const LongList<tessellationElement>& elmts = tessellation_.elmts(); + LongList<bool> internalPoint(tetPoints.size(), false); + + bool found; + label nIter(0); + do + { + Info << "Tessellation has " << tetPoints.size() << " points" << endl; + Info << "Number of tets " << elmts.size() << endl; + found = false; + const label nPoints = tetPoints.size(); + const label nElements = elmts.size(); + for(label elmtI=0;elmtI<nElements;++elmtI) + //forAll(elmts, elmtI) + { + if( isElementChanged(elmtI, nPoints) ) + continue; + + const tessellationElement& elmt = elmts[elmtI]; + const point p = elmt.centroid(tetPoints); + + if( isPointInsideSurface(p) ) + { + tessellation_.addCentroid(elmtI); + found = true; + } + } + } while( found && (++nIter < 7) ); + + tessellation_.checkTessellation(); } bool tetPointsCreator::isPointInsideSurface(const point& p) const { - const label cLabel = octree_.findLeafContainingVertex(p); - - if( cLabel == -1 ) - return false; - - if( - (octree_.returnLeaf(cLabel).cubeType() & meshOctreeCubeBasic::INSIDE) || - (octree_.returnLeaf(cLabel).cubeType() & meshOctreeCubeBasic::DATA) - ) - return true; - - return false; + const label cLabel = octree_.findLeafContainingVertex(p); + + if( cLabel == -1 ) + return false; + + if( + (octree_.returnLeaf(cLabel).cubeType() & meshOctreeCubeBasic::INSIDE) || + (octree_.returnLeaf(cLabel).cubeType() & meshOctreeCubeBasic::DATA) + ) + return true; + + return false; } bool tetPointsCreator::isElementChanged ( - const label elmtI, - const label nElements + const label elmtI, + const label nElements ) const { - if( elmtI >= nElements ) - return true; - - const tessellationElement& elmt = tessellation_.elmts()[elmtI]; - - for(direction i=0;i<DIM;++i) - if( elmt[i] >= nElements ) - return true; - - return false; + if( elmtI >= nElements ) + return true; + + const tessellationElement& elmt = tessellation_.elmts()[elmtI]; + + for(direction i=0;i<DIM;++i) + if( elmt[i] >= nElements ) + return true; + + return false; } scalar tetPointsCreator::cellSizeAtLocation(const point& p) const { - const label cLabel = octree_.findLeafContainingVertex(p); - - if( cLabel == -1 ) - return VGREAT; - - return octree_.returnLeaf(cLabel).size(octree_.rootBox()); + const label cLabel = octree_.findLeafContainingVertex(p); + + if( cLabel == -1 ) + return VGREAT; + + return octree_.returnLeaf(cLabel).size(octree_.rootBox()); } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/meshLibrary/utilities/tetrahedra/tetTessellation/delaunayTessellation/delaunayTessellation.H b/meshLibrary/utilities/tetrahedra/tetTessellation/delaunayTessellation/delaunayTessellation.H index 8395bf7e..101899b8 100644 --- a/meshLibrary/utilities/tetrahedra/tetTessellation/delaunayTessellation/delaunayTessellation.H +++ b/meshLibrary/utilities/tetrahedra/tetTessellation/delaunayTessellation/delaunayTessellation.H @@ -53,13 +53,13 @@ public: // Constructors //- Construct from list of points - delaunayTessellation(const LongList<point>&); + delaunayTessellation(const LongList<point>&); - //- Construct from triangulated surface - delaunayTessellation(const triSurface& surf); + //- Construct from triangulated surface + delaunayTessellation(const triSurface& surf); - //- Construct from boundBox - delaunayTessellation(const boundBox& bb); + //- Construct from boundBox + delaunayTessellation(const boundBox& bb); // Destructor @@ -67,22 +67,22 @@ public: // Member functions - //- add point which is already in the list of points - bool addPoint(const label pI); + //- add point which is already in the list of points + bool addPoint(const label pI); - //- create a new point from the centroid of the given element - //- and add it into the tessellation - void addCentroid(const label elmtI); + //- create a new point from the centroid of the given element + //- and add it into the tessellation + void addCentroid(const label elmtI); - //- create a new point from the circumcentre of the given element - //- and add it into the tessellation - void addCircumCentre(const label elmtI); - - //- create a new point at the centre of the given edge of the element - //- and add it into the tessellation - void addEdgeCentre(const label elmtI, const direction eI); + //- create a new point from the circumcentre of the given element + //- and add it into the tessellation + void addCircumCentre(const label elmtI); + + //- create a new point at the centre of the given edge of the element + //- and add it into the tessellation + void addEdgeCentre(const label elmtI, const direction eI); - //- check if the tesselation obeys Delaunay properties + //- check if the tesselation obeys Delaunay properties void checkTessellation() const; }; diff --git a/meshLibrary/utilities/tetrahedra/tetTessellation/delaunayTessellation/delaunayTessellationFunctions.C b/meshLibrary/utilities/tetrahedra/tetTessellation/delaunayTessellation/delaunayTessellationFunctions.C index 081734e8..8b90b24a 100644 --- a/meshLibrary/utilities/tetrahedra/tetTessellation/delaunayTessellation/delaunayTessellationFunctions.C +++ b/meshLibrary/utilities/tetrahedra/tetTessellation/delaunayTessellation/delaunayTessellationFunctions.C @@ -39,17 +39,17 @@ namespace Foam bool delaunayTessellation::addPoint(const label pI) { - # ifdef DEBUGTessalation - Info << "Adding point " << pI - << " with coordinates " << points_[pI] << endl; - # endif - - const point& p = points_[pI]; - + # ifdef DEBUGTessalation + Info << "Adding point " << pI + << " with coordinates " << points_[pI] << endl; + # endif + + const point& p = points_[pI]; + pointOk_ = true; nElmts_ = 0; - + const label el = findInitialElement(p); treeSearch @@ -66,121 +66,121 @@ bool delaunayTessellation::addPoint(const label pI) } makeNewElements(el, pI); - - resetInfluences(el); + + resetInfluences(el); return true; } void delaunayTessellation::addCentroid(const label elmtI) { - const label pI = points_.size(); - points_.append(elmts_[elmtI].centroid(points_)); - const point& p = points_[pI]; - - do - { - pointOk_ = true; - - nElmts_ = 0; - - treeSearch(elmtI, p); - - //- skip the point if it produces invalid tessellation - if( !pointOk_ ) - { - resetInfluences(elmtI); - continue; - } - - makeNewElements(elmtI, pI); - - resetInfluences(elmtI); - } - while( !pointOk_ ); + const label pI = points_.size(); + points_.append(elmts_[elmtI].centroid(points_)); + const point& p = points_[pI]; + + do + { + pointOk_ = true; + + nElmts_ = 0; + + treeSearch(elmtI, p); + + //- skip the point if it produces invalid tessellation + if( !pointOk_ ) + { + resetInfluences(elmtI); + continue; + } + + makeNewElements(elmtI, pI); + + resetInfluences(elmtI); + } + while( !pointOk_ ); } void delaunayTessellation::addCircumCentre(const label elmtI) { - const label pI = points_.size(); - points_.append(elmts_[elmtI].crcmCentre(points_)); - const point& p = points_[pI]; - + const label pI = points_.size(); + points_.append(elmts_[elmtI].crcmCentre(points_)); + const point& p = points_[pI]; + do - { - pointOk_ = true; - - nElmts_ = 0; - - treeSearch(elmtI, p); - - //- skip the point if it produces invalid tessellation - if( !pointOk_ ) - { - resetInfluences(elmtI); - continue; - } - - makeNewElements(elmtI, pI); - - resetInfluences(elmtI); - } - while( !pointOk_ ); + { + pointOk_ = true; + + nElmts_ = 0; + + treeSearch(elmtI, p); + + //- skip the point if it produces invalid tessellation + if( !pointOk_ ) + { + resetInfluences(elmtI); + continue; + } + + makeNewElements(elmtI, pI); + + resetInfluences(elmtI); + } + while( !pointOk_ ); } void delaunayTessellation::addEdgeCentre(const label elmtI, const direction eI) { - const label pI = points_.size(); - const edge e = elmts_[elmtI].edges()[eI]; - points_.append(0.5*(points_[e[0]]+points_[e[1]])); - const point& p = points_[pI]; - + const label pI = points_.size(); + const edge e = elmts_[elmtI].edges()[eI]; + points_.append(0.5*(points_[e[0]]+points_[e[1]])); + const point& p = points_[pI]; + do - { - Info << "Adding point " << pI << endl; - pointOk_ = true; - - nElmts_ = 0; - - treeSearch(elmtI, p); - - //- skip the point if it produces invalid tessellation - if( !pointOk_ ) - { - Warning << "Adding point " << pI << " failed" << endl; - resetInfluences(elmtI); - continue; - } - - makeNewElements(elmtI, pI); - - resetInfluences(elmtI); - } - while( !pointOk_ ); + { + Info << "Adding point " << pI << endl; + pointOk_ = true; + + nElmts_ = 0; + + treeSearch(elmtI, p); + + //- skip the point if it produces invalid tessellation + if( !pointOk_ ) + { + Warning << "Adding point " << pI << " failed" << endl; + resetInfluences(elmtI); + continue; + } + + makeNewElements(elmtI, pI); + + resetInfluences(elmtI); + } + while( !pointOk_ ); } void delaunayTessellation::checkTessellation() const { forAll(elmts_, elI) { - const tessellationElement& elmt = elmts_[elI]; - - for(direction i=0;i<DIM1;++i) - if( elmt.neighbour(i) > elI ) - { - const tessellationElement& nei = elmts_[elmt.neighbour(i)]; + const tessellationElement& elmt = elmts_[elI]; + + for(direction i=0;i<DIM1;++i) + if( elmt.neighbour(i) > elI ) + { + const tessellationElement& nei = elmts_[elmt.neighbour(i)]; if( nei.influencedBy(points_, points_[elmt[i]]) > VSM ) { - Info << "Influence " - << nei.influencedBy(points_, points_[elmt[i]]) << endl; - FatalErrorIn - ( - "delaunayTessellation::checkTessalation()" - ) << "This is not a Delaunay hierarchy!!" - << abort(FatalError); + Info << "Influence " + << nei.influencedBy(points_, points_[elmt[i]]) << endl; + FatalErrorIn + ( + "delaunayTessellation::checkTessalation()" + ) << "This is not a Delaunay hierarchy!!" + << abort(FatalError); } } - } + } } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/meshLibrary/utilities/tetrahedra/tetTessellation/subdivisionTessellation/subdivisionTessellation.H b/meshLibrary/utilities/tetrahedra/tetTessellation/subdivisionTessellation/subdivisionTessellation.H index c7a7b4db..6b4aaafe 100644 --- a/meshLibrary/utilities/tetrahedra/tetTessellation/subdivisionTessellation/subdivisionTessellation.H +++ b/meshLibrary/utilities/tetrahedra/tetTessellation/subdivisionTessellation/subdivisionTessellation.H @@ -49,53 +49,53 @@ class subdivisionTessellation : public tetTessellation { // Private member functions - //- mark all tetrahedra sharing edge e (used in addEdgeCentre) + //- mark all tetrahedra sharing edge e (used in addEdgeCentre) void treeSearch(const label elmtI, const edge& e); - - //- mark tetrahedron (used in addCentroid); - void treeSearch(const label elmtI); - - //- (used in addEdgeCentre); - void makeNewElementsBisect - ( - const label elmtI, - const edge& e, - const label pI - ); - + + //- mark tetrahedron (used in addCentroid); + void treeSearch(const label elmtI); + + //- (used in addEdgeCentre); + void makeNewElementsBisect + ( + const label elmtI, + const edge& e, + const label pI + ); + public: // Constructors //- Construct from list of points - subdivisionTessellation(const LongList<point>&); + subdivisionTessellation(const LongList<point>&); - //- Construct from triangulated surface - subdivisionTessellation(const triSurface& surf); + //- Construct from triangulated surface + subdivisionTessellation(const triSurface& surf); - //- Construct from boundBox - subdivisionTessellation(const boundBox& bb); + //- Construct from boundBox + subdivisionTessellation(const boundBox& bb); // Destructor ~subdivisionTessellation(); // Member functions - //- this function is not implemented - bool addPoint(const label); + //- this function is not implemented + bool addPoint(const label); - //- create a new point from the centroid of the given element - //- and add it into the tessellation - void addCentroid(const label elmtI); + //- create a new point from the centroid of the given element + //- and add it into the tessellation + void addCentroid(const label elmtI); - //- this is not implemented - void addCircumCentre(const label); - - //- create a new point at the centre of the given edge of the element - //- and add it into the tessellation - void addEdgeCentre(const label elmtI, const direction eI); + //- this is not implemented + void addCircumCentre(const label); + + //- create a new point at the centre of the given edge of the element + //- and add it into the tessellation + void addEdgeCentre(const label elmtI, const direction eI); - //- check if all elements have positive volume + //- check if all elements have positive volume void checkTessellation() const; }; diff --git a/meshLibrary/utilities/tetrahedra/tetTessellation/subdivisionTessellation/subdivisionTessellationFunctions.C b/meshLibrary/utilities/tetrahedra/tetTessellation/subdivisionTessellation/subdivisionTessellationFunctions.C index de7b8c0a..dfce2905 100644 --- a/meshLibrary/utilities/tetrahedra/tetTessellation/subdivisionTessellation/subdivisionTessellationFunctions.C +++ b/meshLibrary/utilities/tetrahedra/tetTessellation/subdivisionTessellation/subdivisionTessellationFunctions.C @@ -42,84 +42,84 @@ namespace Foam bool subdivisionTessellation::addPoint(const label pI) { - FatalErrorIn - ( - "bool subdivisionTessellation::addPoint(const label)" - ) << "Not implemented!" << exit(FatalError); - - return false; + FatalErrorIn + ( + "bool subdivisionTessellation::addPoint(const label)" + ) << "Not implemented!" << exit(FatalError); + + return false; } void subdivisionTessellation::addCentroid(const label elmtI) { - const label pI = points_.size(); - points_.append(elmts_[elmtI].centroid(points_)); - - # ifdef DEBUGTessalation - Info << "subdivisionTessellation:: Adding centroid " << pI << endl; - # endif - - nElmts_ = 0; + const label pI = points_.size(); + points_.append(elmts_[elmtI].centroid(points_)); + + # ifdef DEBUGTessalation + Info << "subdivisionTessellation:: Adding centroid " << pI << endl; + # endif + + nElmts_ = 0; - treeSearch(elmtI); + treeSearch(elmtI); - makeNewElements(elmtI, pI); - - resetInfluences(elmtI); + makeNewElements(elmtI, pI); + + resetInfluences(elmtI); } void subdivisionTessellation::addCircumCentre(const label elmtI) { - FatalErrorIn - ( - "bool subdivisionTessellation::addPoint(const label)" - ) << "Not implemented!" << exit(FatalError); + FatalErrorIn + ( + "bool subdivisionTessellation::addPoint(const label)" + ) << "Not implemented!" << exit(FatalError); } void subdivisionTessellation::addEdgeCentre ( - const label elmtI, - const direction eI + const label elmtI, + const direction eI ) { - const label pI = points_.size(); - const edge e = elmts_[elmtI].edges()[eI]; - points_.append(0.5*(points_[e[0]]+points_[e[1]])); - - # ifdef DEBUGTessalation - Info << "subdivisionTessellation:: Adding edge centre " - << points_[pI] << endl; - # endif - - nElmts_ = 0; + const label pI = points_.size(); + const edge e = elmts_[elmtI].edges()[eI]; + points_.append(0.5*(points_[e[0]]+points_[e[1]])); + + # ifdef DEBUGTessalation + Info << "subdivisionTessellation:: Adding edge centre " + << points_[pI] << endl; + # endif + + nElmts_ = 0; - treeSearch(elmtI, e); + treeSearch(elmtI, e); - makeNewElementsBisect(elmtI, e, pI); - - resetInfluences(elmtI); + makeNewElementsBisect(elmtI, e, pI); + + resetInfluences(elmtI); } - + void subdivisionTessellation::treeSearch(const label elmtI) { - tessellationElement& elmt = elmts_[elmtI]; - - //- stop searching it the tessellationElement is marked already + tessellationElement& elmt = elmts_[elmtI]; + + //- stop searching it the tessellationElement is marked already if( elmt.influence_ & tessellationElement::GOOD ) return; - - # ifdef DEBUGTessalation - Info << "Setting GOOD at element " << elmtI << endl; - # endif - - elmt.influence_ |= tessellationElement::GOOD; - delElmts_[nElmts_++] = elmtI; - - for(direction ineigh=0;ineigh<DIM1;++ineigh) - { - const label el = elmt.neighbour(ineigh); + + # ifdef DEBUGTessalation + Info << "Setting GOOD at element " << elmtI << endl; + # endif + + elmt.influence_ |= tessellationElement::GOOD; + delElmts_[nElmts_++] = elmtI; + + for(direction ineigh=0;ineigh<DIM1;++ineigh) + { + const label el = elmt.neighbour(ineigh); if( el != -1 ) - elmts_[el].influence_ |= tessellationElement::BOUND; - } + elmts_[el].influence_ |= tessellationElement::BOUND; + } } void subdivisionTessellation::treeSearch @@ -128,27 +128,27 @@ void subdivisionTessellation::treeSearch const edge& e ) { - tessellationElement& elmt = elmts_[elmtI]; - + tessellationElement& elmt = elmts_[elmtI]; + //- stop searching if there exist an element with unknown influence if( !pointOk_ ) return; //- stop searching it the tessellationElement is marked already if( elmt.influence_ & tessellationElement::GOOD ) return; - - if( (elmt.whichPosition(e[0]) != -1) && (elmt.whichPosition(e[1]) != -1) ) - { - elmt.influence_ |= tessellationElement::GOOD; - delElmts_[nElmts_++] = elmtI; - # ifdef DEBUGTessalation - Info << "Selecting element " << elmtI << "with nodes " << elmt << endl; - # endif - } - else - { - elmt.influence_ |= tessellationElement::BOUND; - return; - } + + if( (elmt.whichPosition(e[0]) != -1) && (elmt.whichPosition(e[1]) != -1) ) + { + elmt.influence_ |= tessellationElement::GOOD; + delElmts_[nElmts_++] = elmtI; + # ifdef DEBUGTessalation + Info << "Selecting element " << elmtI << "with nodes " << elmt << endl; + # endif + } + else + { + elmt.influence_ |= tessellationElement::BOUND; + return; + } for(direction i=0;i<DIM1;++i) { @@ -168,177 +168,177 @@ void subdivisionTessellation::treeSearch void subdivisionTessellation::makeNewElementsBisect ( - const label elmtI, - const edge& e, - const label pI + const label elmtI, + const edge& e, + const label pI ) { - # ifdef DEBUGTessalation - for(label i=0;i<nElmts_;++i) - Info << "Element to delete is " << elmts_[delElmts_[i]] << endl; - # endif - - //- create new elements - DynList<tessellationElement>* newElementsPtr = - new DynList<tessellationElement>(4*nElmts_); - for(label i=0;i<nElmts_;++i) - { - const tessellationElement& elmt = elmts_[delElmts_[i]]; - - for(direction j=0;j<DIM1;++j) - { - const label nei = elmt.neighbour(j); - if( - (nei == -1) || - (elmts_[nei].influence_ & tessellationElement::BOUND) - ) - { - triFace f = elmt.face(j); - direction nFound(0); - forAll(f, pJ) - if( e.otherVertex(f[pJ]) != -1 ) - ++nFound; - if( nFound != 2 ) - { - tessellationElement nelmt(f[0], f[1], f[2], pI); - nelmt.setNeighbour(3, nei); - nelmt.influence_ = elmt.influence_; - newElementsPtr->append(nelmt); - } - } - } - } - - //- create labels of new elements and store them - labelList newLabels(newElementsPtr->size()); - forAll(newLabels, lI) - if( lI < nElmts_ ) - { - elmts_[delElmts_[lI]] = (*newElementsPtr)[lI]; - newLabels[lI] = delElmts_[lI]; - } - else - { - newLabels[lI] = elmts_.size(); - elmts_.append((*newElementsPtr)[lI]); - } - - deleteDemandDrivenData(newElementsPtr); - # ifdef DEBUGTessalation - Info << "Labels of new elements " << newLabels << endl; - # endif - //- update neighbouring information for BOUND elements - Map<label> newPointLabel; - forAll(newLabels, lI) - { - const tessellationElement& elmt = elmts_[newLabels[lI]]; - for(direction i=0;i<DIM;++i) - if( !newPointLabel.found(elmt[i]) ) - { - const label n = newPointLabel.size(); - newPointLabel.insert(elmt[i], n); - } - - const label nei = elmt.neighbour(3); - if( nei != -1 ) - { - tessellationElement& nelmt = elmts_[nei]; - for(direction i=0;i<DIM1;++i) - if( elmt.whichPosition(nelmt[i]) == -1 ) - { - nelmt.setNeighbour(i, newLabels[lI]); - break; - } - } - } - - //- create neighbours of newly created elements - List< DynList<label> > nodeElements - ( - newPointLabel.size(), - DynList<label>(6) - ); - - forAll(newLabels, lI) - { - const tessellationElement& elmt = elmts_[newLabels[lI]]; - for(direction i=0;i<DIM;++i) - nodeElements[newPointLabel[elmt[i]]].append(newLabels[lI]); - } - - # ifdef DEBUGTessalation - Info << "Node elements " << nodeElements << endl; - Info <<"New point label " << newPointLabel << endl; - # endif - - forAll(newLabels, lI) - { - tessellationElement& elmt = elmts_[newLabels[lI]]; - for(direction i=0;i<DIM;++i) - { - const label s = newPointLabel[elmt[(i+1)%3]]; - const label e = elmt[(i+2)%3]; - const DynList<label>& nel = nodeElements[s]; - forAll(nel, elI) - if( (elmts_[nel[elI]].whichPosition(e) != -1) && - (nel[elI] != newLabels[lI]) - ) - { - elmt.setNeighbour(i, nel[elI]); - break; - } - } - } - - # ifdef DEBUGTessalation - forAll(newLabels, lI) - { - const tessellationElement& elmt = elmts_[newLabels[lI]]; - Info << "New element " << newLabels[lI] << " is " << elmt << endl; - for(direction i=0;i<DIM1;++i) - { - Info << "Neighbour over face " << elmt.face(i) << " is " - << elmt.neighbour(i) << endl; - - triFace f = elmt.face(i); - if( elmt.neighbour(i) != -1 ) - { - const label nei = elmt.neighbour(i); - bool found(false); - for(direction j=0;j<DIM1;++j) - { - triFace fnei = elmts_[nei].face(j); - if( fnei == f ) - { - found = true; - if( elmts_[nei].neighbour(j) != newLabels[lI] ) - FatalError << "Wrong neighbour addressing" - << abort(FatalError); - } - } - - if( !found ) - FatalError << "Cannot find neighbour!" << abort(FatalError); - } - } - } - # endif + # ifdef DEBUGTessalation + for(label i=0;i<nElmts_;++i) + Info << "Element to delete is " << elmts_[delElmts_[i]] << endl; + # endif + + //- create new elements + DynList<tessellationElement>* newElementsPtr = + new DynList<tessellationElement>(4*nElmts_); + for(label i=0;i<nElmts_;++i) + { + const tessellationElement& elmt = elmts_[delElmts_[i]]; + + for(direction j=0;j<DIM1;++j) + { + const label nei = elmt.neighbour(j); + if( + (nei == -1) || + (elmts_[nei].influence_ & tessellationElement::BOUND) + ) + { + triFace f = elmt.face(j); + direction nFound(0); + forAll(f, pJ) + if( e.otherVertex(f[pJ]) != -1 ) + ++nFound; + if( nFound != 2 ) + { + tessellationElement nelmt(f[0], f[1], f[2], pI); + nelmt.setNeighbour(3, nei); + nelmt.influence_ = elmt.influence_; + newElementsPtr->append(nelmt); + } + } + } + } + + //- create labels of new elements and store them + labelList newLabels(newElementsPtr->size()); + forAll(newLabels, lI) + if( lI < nElmts_ ) + { + elmts_[delElmts_[lI]] = (*newElementsPtr)[lI]; + newLabels[lI] = delElmts_[lI]; + } + else + { + newLabels[lI] = elmts_.size(); + elmts_.append((*newElementsPtr)[lI]); + } + + deleteDemandDrivenData(newElementsPtr); + # ifdef DEBUGTessalation + Info << "Labels of new elements " << newLabels << endl; + # endif + //- update neighbouring information for BOUND elements + Map<label> newPointLabel; + forAll(newLabels, lI) + { + const tessellationElement& elmt = elmts_[newLabels[lI]]; + for(direction i=0;i<DIM;++i) + if( !newPointLabel.found(elmt[i]) ) + { + const label n = newPointLabel.size(); + newPointLabel.insert(elmt[i], n); + } + + const label nei = elmt.neighbour(3); + if( nei != -1 ) + { + tessellationElement& nelmt = elmts_[nei]; + for(direction i=0;i<DIM1;++i) + if( elmt.whichPosition(nelmt[i]) == -1 ) + { + nelmt.setNeighbour(i, newLabels[lI]); + break; + } + } + } + + //- create neighbours of newly created elements + List< DynList<label> > nodeElements + ( + newPointLabel.size(), + DynList<label>(6) + ); + + forAll(newLabels, lI) + { + const tessellationElement& elmt = elmts_[newLabels[lI]]; + for(direction i=0;i<DIM;++i) + nodeElements[newPointLabel[elmt[i]]].append(newLabels[lI]); + } + + # ifdef DEBUGTessalation + Info << "Node elements " << nodeElements << endl; + Info <<"New point label " << newPointLabel << endl; + # endif + + forAll(newLabels, lI) + { + tessellationElement& elmt = elmts_[newLabels[lI]]; + for(direction i=0;i<DIM;++i) + { + const label s = newPointLabel[elmt[(i+1)%3]]; + const label e = elmt[(i+2)%3]; + const DynList<label>& nel = nodeElements[s]; + forAll(nel, elI) + if( (elmts_[nel[elI]].whichPosition(e) != -1) && + (nel[elI] != newLabels[lI]) + ) + { + elmt.setNeighbour(i, nel[elI]); + break; + } + } + } + + # ifdef DEBUGTessalation + forAll(newLabels, lI) + { + const tessellationElement& elmt = elmts_[newLabels[lI]]; + Info << "New element " << newLabels[lI] << " is " << elmt << endl; + for(direction i=0;i<DIM1;++i) + { + Info << "Neighbour over face " << elmt.face(i) << " is " + << elmt.neighbour(i) << endl; + + triFace f = elmt.face(i); + if( elmt.neighbour(i) != -1 ) + { + const label nei = elmt.neighbour(i); + bool found(false); + for(direction j=0;j<DIM1;++j) + { + triFace fnei = elmts_[nei].face(j); + if( fnei == f ) + { + found = true; + if( elmts_[nei].neighbour(j) != newLabels[lI] ) + FatalError << "Wrong neighbour addressing" + << abort(FatalError); + } + } + + if( !found ) + FatalError << "Cannot find neighbour!" << abort(FatalError); + } + } + } + # endif } void subdivisionTessellation::checkTessellation() const { forAll(elmts_, elI) { - const tessellationElement& elmt = elmts_[elI]; - - if( elmt.mag(points_) < 0.0 ) - { - FatalErrorIn - ( - "subdivisionTessellation::checkTessalation()" - ) << "Element " << elI << " is inverted!" << abort(FatalError); - } - } + const tessellationElement& elmt = elmts_[elI]; + + if( elmt.mag(points_) < 0.0 ) + { + FatalErrorIn + ( + "subdivisionTessellation::checkTessalation()" + ) << "Element " << elI << " is inverted!" << abort(FatalError); + } + } } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/meshLibrary/utilities/tetrahedra/tetTessellation/tessellationElement.C b/meshLibrary/utilities/tetrahedra/tetTessellation/tessellationElement.C index cb385c16..2d2455be 100644 --- a/meshLibrary/utilities/tetrahedra/tetTessellation/tessellationElement.C +++ b/meshLibrary/utilities/tetrahedra/tetTessellation/tessellationElement.C @@ -37,20 +37,20 @@ namespace Foam tessellationElement::tessellationElement() : - partTet(), - influence_(NONE) + partTet(), + influence_(NONE) { } tessellationElement::tessellationElement ( const label a, - const label b, - const label c, - const label d + const label b, + const label c, + const label d ) : - partTet(a, b, c, d), + partTet(a, b, c, d), influence_(NONE) { for(label dir=0;dir<4;++dir) @@ -67,12 +67,12 @@ tessellationElement::~tessellationElement() scalar tessellationElement::influencedBy ( - const LongList<point>& points, - const point& r + const LongList<point>& points, + const point& r ) const { - const point crcm = crcmCentre(points); - + const point crcm = crcmCentre(points); + const scalar d = (magSqr(crcm - points[a()]) - magSqr(crcm - r)); # ifdef DEBUGtessalation @@ -89,16 +89,16 @@ scalar tessellationElement::influencedBy Ostream& operator<<(Ostream& os, const tessellationElement& elmt) { - partTet t(elmt); + partTet t(elmt); os << t; - os << " neighbours are "; + os << " neighbours are "; for(label ineigh=0;ineigh<4;++ineigh) { os << " " << elmt.neighbours_[ineigh]; } - os << endl; - + os << endl; + return os; } diff --git a/meshLibrary/utilities/tetrahedra/tetTessellation/tessellationElement.H b/meshLibrary/utilities/tetrahedra/tetTessellation/tessellationElement.H index e9c6575a..2dce0ff6 100644 --- a/meshLibrary/utilities/tetrahedra/tetTessellation/tessellationElement.H +++ b/meshLibrary/utilities/tetrahedra/tetTessellation/tessellationElement.H @@ -53,33 +53,33 @@ class tessellationElement : public partTet { // Private data - - //- neighbours of the given element - label neighbours_[4]; - + + //- neighbours of the given element + label neighbours_[4]; + public: // Constructors //- Construct null - tessellationElement(); + tessellationElement(); - //- Construct from nodes + //- Construct from nodes tessellationElement - ( - const label a, - const label b, - const label c, - const label d - ); + ( + const label a, + const label b, + const label c, + const label d + ); // Destructor ~tessellationElement(); - // Enumerations and public members + // Enumerations and public members - //- types of influence a node can have on an tessellationElement + //- types of influence a node can have on an tessellationElement enum typesOfInfluence { NONE = 0, @@ -92,17 +92,17 @@ public: direction influence_; // Member functions - //- swap node with another one - inline void setNode(const direction, const label); + //- swap node with another one + inline void setNode(const direction, const label); - //- Return index of a neighbour in the given direction + //- Return index of a neighbour in the given direction inline label neighbour(const direction) const; - - //- set neighbour in a given direction - inline void setNeighbour(const direction, const label); - - //- return face in the given direction - inline triFace face(const direction) const; + + //- set neighbour in a given direction + inline void setNeighbour(const direction, const label); + + //- return face in the given direction + inline triFace face(const direction) const; //- Return the influence the point r has on this tessellationElement. // Result is the difference between the sqr of the radius of @@ -110,15 +110,15 @@ public: // centre of the circumcircle. The result is positive if the point // is inside the circle (i.e. influences it). scalar influencedBy - ( - const LongList<point>& points, - const point& r - ) const; + ( + const LongList<point>& points, + const point& r + ) const; - // Ostream Operator + // Ostream Operator friend Ostream& operator<<(Ostream&, const tessellationElement&); - - inline void operator=(const tessellationElement&); + + inline void operator=(const tessellationElement&); }; diff --git a/meshLibrary/utilities/tetrahedra/tetTessellation/tessellationElementI.H b/meshLibrary/utilities/tetrahedra/tetTessellation/tessellationElementI.H index f21e277c..6efb0164 100644 --- a/meshLibrary/utilities/tetrahedra/tetTessellation/tessellationElementI.H +++ b/meshLibrary/utilities/tetrahedra/tetTessellation/tessellationElementI.H @@ -33,7 +33,7 @@ namespace Foam inline void tessellationElement::setNode(const direction i, const label nodeI) { - data_[i] = nodeI; + data_[i] = nodeI; } inline label tessellationElement::neighbour(const direction i) const @@ -43,49 +43,49 @@ inline label tessellationElement::neighbour(const direction i) const inline void tessellationElement::setNeighbour ( - const direction i, - const label neiI + const direction i, + const label neiI ) { - neighbours_[i] = neiI; + neighbours_[i] = neiI; } inline triFace tessellationElement::face(const direction i) const { - switch( i ) - { - case 0: - { - return triFace(data_[1], data_[3], data_[2]); - } break; - case 1: - { - return triFace(data_[0], data_[2], data_[3]); - } break; - case 2: - { - return triFace(data_[0], data_[3], data_[1]); - } break; - case 3: - { - return triFace(data_[0], data_[1], data_[2]); - } break; - }; - - return triFace(); + switch( i ) + { + case 0: + { + return triFace(data_[1], data_[3], data_[2]); + } break; + case 1: + { + return triFace(data_[0], data_[2], data_[3]); + } break; + case 2: + { + return triFace(data_[0], data_[3], data_[1]); + } break; + case 3: + { + return triFace(data_[0], data_[1], data_[2]); + } break; + }; + + return triFace(); } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // inline void tessellationElement::operator=(const tessellationElement& elmt) { - for(label i=0;i<4;++i) - { - data_[i] = elmt[i]; - neighbours_[i] = elmt.neighbour(i); - } - - influence_ = elmt.influence_; + for(label i=0;i<4;++i) + { + data_[i] = elmt[i]; + neighbours_[i] = elmt.neighbour(i); + } + + influence_ = elmt.influence_; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/meshLibrary/utilities/tetrahedra/tetTessellation/tetTessellation.C b/meshLibrary/utilities/tetrahedra/tetTessellation/tetTessellation.C index 093d3f07..67cc21d0 100644 --- a/meshLibrary/utilities/tetrahedra/tetTessellation/tetTessellation.C +++ b/meshLibrary/utilities/tetrahedra/tetTessellation/tetTessellation.C @@ -35,94 +35,94 @@ Description namespace Foam { - + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - + void tetTessellation::createInitialTets() { - boundaryPoints_[0] = points_.size(); - points_.append(min_); - boundaryPoints_[1] = points_.size(); - points_.append(point(max_.x(), min_.y(), min_.z())); - boundaryPoints_[2] = points_.size(); - points_.append(point(max_.x(), max_.y(), min_.z())); - boundaryPoints_[3] = points_.size(); - points_.append(point(min_.x(), max_.y(), min_.z())); - boundaryPoints_[4] = points_.size(); - points_.append(point(min_.x(), min_.y(), max_.z())); - boundaryPoints_[5] = points_.size(); - points_.append(point(max_.x(), min_.y(), max_.z())); - boundaryPoints_[6] = points_.size(); - points_.append(max_); - boundaryPoints_[7] = points_.size(); - points_.append(point(min_.x(), max_.y(), max_.z())); - - DynList<label> tetLabels(5); - tetLabels.append(elmts_.size()); - elmts_.append - ( - tessellationElement - ( - boundaryPoints_[0], - boundaryPoints_[4], - boundaryPoints_[1], - boundaryPoints_[3] - ) - ); - tetLabels.append(elmts_.size()); - elmts_.append - ( - tessellationElement - ( - boundaryPoints_[5], - boundaryPoints_[1], - boundaryPoints_[4], - boundaryPoints_[6] - ) - ); - tetLabels.append(elmts_.size()); - elmts_.append - ( - tessellationElement - ( - boundaryPoints_[7], - boundaryPoints_[4], - boundaryPoints_[3], - boundaryPoints_[6] - ) - ); - tetLabels.append(elmts_.size()); - elmts_.append - ( - tessellationElement - ( - boundaryPoints_[2], - boundaryPoints_[3], - boundaryPoints_[1], - boundaryPoints_[6] - ) - ); - tetLabels.append(elmts_.size()); - elmts_.append - ( - tessellationElement - ( - boundaryPoints_[3], - boundaryPoints_[4], - boundaryPoints_[1], - boundaryPoints_[6] - ) - ); - - elmts_[tetLabels[0]].setNeighbour(0, tetLabels[4]); - elmts_[tetLabels[1]].setNeighbour(0, tetLabels[4]); - elmts_[tetLabels[2]].setNeighbour(0, tetLabels[4]); - elmts_[tetLabels[3]].setNeighbour(0, tetLabels[4]); - - elmts_[tetLabels[4]].setNeighbour(0, tetLabels[1]); - elmts_[tetLabels[4]].setNeighbour(1, tetLabels[3]); - elmts_[tetLabels[4]].setNeighbour(2, tetLabels[2]); - elmts_[tetLabels[4]].setNeighbour(3, tetLabels[0]); + boundaryPoints_[0] = points_.size(); + points_.append(min_); + boundaryPoints_[1] = points_.size(); + points_.append(point(max_.x(), min_.y(), min_.z())); + boundaryPoints_[2] = points_.size(); + points_.append(point(max_.x(), max_.y(), min_.z())); + boundaryPoints_[3] = points_.size(); + points_.append(point(min_.x(), max_.y(), min_.z())); + boundaryPoints_[4] = points_.size(); + points_.append(point(min_.x(), min_.y(), max_.z())); + boundaryPoints_[5] = points_.size(); + points_.append(point(max_.x(), min_.y(), max_.z())); + boundaryPoints_[6] = points_.size(); + points_.append(max_); + boundaryPoints_[7] = points_.size(); + points_.append(point(min_.x(), max_.y(), max_.z())); + + DynList<label> tetLabels(5); + tetLabels.append(elmts_.size()); + elmts_.append + ( + tessellationElement + ( + boundaryPoints_[0], + boundaryPoints_[4], + boundaryPoints_[1], + boundaryPoints_[3] + ) + ); + tetLabels.append(elmts_.size()); + elmts_.append + ( + tessellationElement + ( + boundaryPoints_[5], + boundaryPoints_[1], + boundaryPoints_[4], + boundaryPoints_[6] + ) + ); + tetLabels.append(elmts_.size()); + elmts_.append + ( + tessellationElement + ( + boundaryPoints_[7], + boundaryPoints_[4], + boundaryPoints_[3], + boundaryPoints_[6] + ) + ); + tetLabels.append(elmts_.size()); + elmts_.append + ( + tessellationElement + ( + boundaryPoints_[2], + boundaryPoints_[3], + boundaryPoints_[1], + boundaryPoints_[6] + ) + ); + tetLabels.append(elmts_.size()); + elmts_.append + ( + tessellationElement + ( + boundaryPoints_[3], + boundaryPoints_[4], + boundaryPoints_[1], + boundaryPoints_[6] + ) + ); + + elmts_[tetLabels[0]].setNeighbour(0, tetLabels[4]); + elmts_[tetLabels[1]].setNeighbour(0, tetLabels[4]); + elmts_[tetLabels[2]].setNeighbour(0, tetLabels[4]); + elmts_[tetLabels[3]].setNeighbour(0, tetLabels[4]); + + elmts_[tetLabels[4]].setNeighbour(0, tetLabels[1]); + elmts_[tetLabels[4]].setNeighbour(1, tetLabels[3]); + elmts_[tetLabels[4]].setNeighbour(2, tetLabels[2]); + elmts_[tetLabels[4]].setNeighbour(3, tetLabels[0]); } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -169,10 +169,10 @@ tetTessellation::tetTessellation # ifdef DEBUGTessalation Info << "Elements " << elmts_ << endl; - forAll(elmts_, eI) - Info << "Volume of element " << eI - << " is " << elmts_[eI].mag(points_) << endl; - Info << "Number of points is " << points_.size() << endl; + forAll(elmts_, eI) + Info << "Volume of element " << eI + << " is " << elmts_[eI].mag(points_) << endl; + Info << "Number of points is " << points_.size() << endl; Info << "Number of tetrahedra is " << elmts_.size() << endl; # endif } @@ -194,9 +194,9 @@ tetTessellation::tetTessellation # ifdef DEBUGTessalation Info << "Elements " << elmts_ << endl; - forAll(elmts_, eI) - Info << "Volume of element " << eI - << " is " << elmts_[eI].mag(points_) << endl; + forAll(elmts_, eI) + Info << "Volume of element " << eI + << " is " << elmts_[eI].mag(points_) << endl; # endif } @@ -214,9 +214,9 @@ tetTessellation::tetTessellation(const boundBox& bb) # ifdef DEBUGTessalation Info << "Elements " << elmts_ << endl; - forAll(elmts_, eI) - Info << "Volume of element " << eI - << " is " << elmts_[eI].mag(points_) << endl; + forAll(elmts_, eI) + Info << "Volume of element " << eI + << " is " << elmts_[eI].mag(points_) << endl; # endif } diff --git a/meshLibrary/utilities/tetrahedra/tetTessellation/tetTessellation.H b/meshLibrary/utilities/tetrahedra/tetTessellation/tetTessellation.H index 43b0ef69..f7881070 100644 --- a/meshLibrary/utilities/tetrahedra/tetTessellation/tetTessellation.H +++ b/meshLibrary/utilities/tetrahedra/tetTessellation/tetTessellation.H @@ -44,7 +44,7 @@ SourceFiles namespace Foam { - + class triSurface; /*---------------------------------------------------------------------------*\ @@ -54,16 +54,16 @@ class triSurface; class tetTessellation { protected: - + // Protected data //- The points LongList<point> points_; - - //- labels of boundary tet points - //- boundary tet encompasses the whole structure and all elements of - //- interest are contained inside it. The labels of these points are - //- stored such that they can be removed from the final mesh - label boundaryPoints_[8]; + + //- labels of boundary tet points + //- boundary tet encompasses the whole structure and all elements of + //- interest are contained inside it. The labels of these points are + //- stored such that they can be removed from the final mesh + label boundaryPoints_[8]; //- The tessellationElements LongList<tessellationElement> elmts_; @@ -78,28 +78,28 @@ protected: point min_; // Protected member functions - label findInitialElement(const point&); + label findInitialElement(const point&); void treeSearch(const label elmtI, const point&); void resetInfluences(const label elmtI); void makeNewElements(const label elmtI, const label pI); - - void createInitialTets(); - + + void createInitialTets(); + public: // Constructors //- Construct from list of points - tetTessellation(const LongList<point>&); + tetTessellation(const LongList<point>&); - //- Construct from triangulated surface - tetTessellation(const triSurface& surf); + //- Construct from triangulated surface + tetTessellation(const triSurface& surf); - //- Construct from boundBox - tetTessellation(const boundBox& bb); + //- Construct from boundBox + tetTessellation(const boundBox& bb); // Destructor @@ -107,30 +107,30 @@ public: // Member functions - //- add point which is already in the list of points - virtual bool addPoint(const label pI) = 0; + //- add point which is already in the list of points + virtual bool addPoint(const label pI) = 0; - //- create a new point from the centroid of the given element - //- and add it into the tessellation - virtual void addCentroid(const label elmtI) = 0; + //- create a new point from the centroid of the given element + //- and add it into the tessellation + virtual void addCentroid(const label elmtI) = 0; - //- create a new point from the circumcentre of the given element - //- and add it into the tessellation - virtual void addCircumCentre(const label elmtI) = 0; - - //- create a new point at the centre of the given edge of the element - //- and add it into the tessellation - virtual void addEdgeCentre(const label elmtI, const direction eI) = 0; + //- create a new point from the circumcentre of the given element + //- and add it into the tessellation + virtual void addCircumCentre(const label elmtI) = 0; + + //- create a new point at the centre of the given edge of the element + //- and add it into the tessellation + virtual void addEdgeCentre(const label elmtI, const direction eI) = 0; const LongList<point>& points() const { return points_; }; - - const LongList<tessellationElement>& elmts() const - { - return elmts_; - } + + const LongList<tessellationElement>& elmts() const + { + return elmts_; + } const point& max() const { diff --git a/meshLibrary/utilities/tetrahedra/tetTessellation/tetTessellationFunctions.C b/meshLibrary/utilities/tetrahedra/tetTessellation/tetTessellationFunctions.C index 878437fc..d0879460 100644 --- a/meshLibrary/utilities/tetrahedra/tetTessellation/tetTessellationFunctions.C +++ b/meshLibrary/utilities/tetrahedra/tetTessellation/tetTessellationFunctions.C @@ -43,11 +43,11 @@ label tetTessellation::findInitialElement(const point& p) label el = elmts_.size() - 1; //- find an tessellationElement which is influenced by the point - //- this brutal force search is not to be used for big tessellations + //- this brutal force search is not to be used for big tessellations const label nEl = elmts_.size(); - for(label tI=0;tI<nEl;++tI) - if( elmts_[tI].influencedBy(points_, p) > VSM ) - return tI; + for(label tI=0;tI<nEl;++tI) + if( elmts_[tI].influencedBy(points_, p) > VSM ) + return tI; return el; } @@ -58,15 +58,15 @@ void tetTessellation::treeSearch const point& p ) { - tessellationElement& elmt = elmts_[elmtI]; - + tessellationElement& elmt = elmts_[elmtI]; + //- stop searching if there exist an element with unknown influence if( !pointOk_ ) return; //- stop searching it the tessellationElement is marked already if( elmt.influence_ & tessellationElement::GOOD ) return; - - const scalar infl = elmt.influencedBy(points_, p); + + const scalar infl = elmt.influencedBy(points_, p); if( infl > VSM ) { @@ -89,8 +89,8 @@ void tetTessellation::treeSearch { point& r = const_cast<point&>(p); Random rnd(0); - - const point crcm = elmt.crcmCentre(points_); + + const point crcm = elmt.crcmCentre(points_); point add = p - 1e-7 * @@ -127,8 +127,8 @@ void tetTessellation::treeSearch void tetTessellation::resetInfluences(const label elmtI) { - tessellationElement& elmt = elmts_[elmtI]; - + tessellationElement& elmt = elmts_[elmtI]; + if( !elmt.influence_ ) return; elmt.influence_ = tessellationElement::NONE; diff --git a/meshLibrary/utilities/tetrahedra/tetTessellation/tetTessellationNewElmts.C b/meshLibrary/utilities/tetrahedra/tetTessellation/tetTessellationNewElmts.C index 9e2739d5..c258f617 100644 --- a/meshLibrary/utilities/tetrahedra/tetTessellation/tetTessellationNewElmts.C +++ b/meshLibrary/utilities/tetrahedra/tetTessellation/tetTessellationNewElmts.C @@ -41,146 +41,146 @@ namespace Foam void tetTessellation::makeNewElements(const label elmtI, const label pI) { - # ifdef DEBUGTessalation - for(label i=0;i<nElmts_;++i) - Info << "Element to delete is " << elmts_[delElmts_[i]] << endl; - # endif - - //- create new elements - DynList<tessellationElement>* newElementsPtr = - new DynList<tessellationElement>(4*nElmts_); - for(label i=0;i<nElmts_;++i) - { - const tessellationElement& elmt = elmts_[delElmts_[i]]; - - for(direction j=0;j<DIM1;++j) - { - const label nei = elmt.neighbour(j); - if( - (nei == -1) || - (elmts_[nei].influence_ & tessellationElement::BOUND) - ) - { - triFace f = elmt.face(j); - tessellationElement nelmt(f[0], f[1], f[2], pI); - nelmt.setNeighbour(3, nei); - nelmt.influence_ = elmt.influence_; - newElementsPtr->append(nelmt); - } - } - } - - //- create labels of new elements and store them - labelList newLabels(newElementsPtr->size()); - forAll(newLabels, lI) - if( lI < nElmts_ ) - { - elmts_[delElmts_[lI]] = (*newElementsPtr)[lI]; - newLabels[lI] = delElmts_[lI]; - } - else - { - newLabels[lI] = elmts_.size(); - elmts_.append((*newElementsPtr)[lI]); - } - - deleteDemandDrivenData(newElementsPtr); - # ifdef DEBUGTessalation - Info << "Labels of new elements " << newLabels << endl; - # endif - //- update neighbouring information for BOUND elements - Map<label> newPointLabel; - forAll(newLabels, lI) - { - const tessellationElement& elmt = elmts_[newLabels[lI]]; - for(direction i=0;i<DIM;++i) - if( !newPointLabel.found(elmt[i]) ) - { - const label n = newPointLabel.size(); - newPointLabel.insert(elmt[i], n); - } - - const label nei = elmt.neighbour(3); - if( nei != -1 ) - { - tessellationElement& nelmt = elmts_[nei]; - for(direction i=0;i<DIM1;++i) - if( elmt.whichPosition(nelmt[i]) == -1 ) - { - nelmt.setNeighbour(i, newLabels[lI]); - break; - } - } - } - - //- create neighbours of newly created elements - List< DynList<label> > nodeElements - ( - newPointLabel.size(), - DynList<label>(6) - ); - - forAll(newLabels, lI) - { - const tessellationElement& elmt = elmts_[newLabels[lI]]; - for(direction i=0;i<DIM;++i) - nodeElements[newPointLabel[elmt[i]]].append(newLabels[lI]); - } - - # ifdef DEBUGTessalation - Info << "Node elements " << nodeElements << endl; - Info <<"New point label " << newPointLabel << endl; - # endif - - forAll(newLabels, lI) - { - tessellationElement& elmt = elmts_[newLabels[lI]]; - for(direction i=0;i<DIM;++i) - { - const label s = newPointLabel[elmt[(i+1)%3]]; - const label e = elmt[(i+2)%3]; - const DynList<label>& nel = nodeElements[s]; - forAll(nel, elI) - if( (elmts_[nel[elI]].whichPosition(e) != -1) && - (nel[elI] != newLabels[lI]) - ) - elmt.setNeighbour(i, nel[elI]); - } - } - - # ifdef DEBUGTessalation - forAll(newLabels, lI) - { - const tessellationElement& elmt = elmts_[newLabels[lI]]; - Info << "New element " << newLabels[lI] << " is " << elmt << endl; - for(direction i=0;i<DIM1;++i) - { - Info << "Neighbour over face " << elmt.face(i) << " is " - << elmt.neighbour(i) << endl; - - triFace f = elmt.face(i); - if( elmt.neighbour(i) != -1 ) - { - const label nei = elmt.neighbour(i); - bool found(false); - for(direction j=0;j<DIM1;++j) - { - triFace fnei = elmts_[nei].face(j); - if( fnei == f ) - { - found = true; - if( elmts_[nei].neighbour(j) != newLabels[lI] ) - FatalError << "Wrong neighbour addressing" - << abort(FatalError); - } - } - - if( !found ) - FatalError << "Cannot find neighbour!" << abort(FatalError); - } - } - } - # endif + # ifdef DEBUGTessalation + for(label i=0;i<nElmts_;++i) + Info << "Element to delete is " << elmts_[delElmts_[i]] << endl; + # endif + + //- create new elements + DynList<tessellationElement>* newElementsPtr = + new DynList<tessellationElement>(4*nElmts_); + for(label i=0;i<nElmts_;++i) + { + const tessellationElement& elmt = elmts_[delElmts_[i]]; + + for(direction j=0;j<DIM1;++j) + { + const label nei = elmt.neighbour(j); + if( + (nei == -1) || + (elmts_[nei].influence_ & tessellationElement::BOUND) + ) + { + triFace f = elmt.face(j); + tessellationElement nelmt(f[0], f[1], f[2], pI); + nelmt.setNeighbour(3, nei); + nelmt.influence_ = elmt.influence_; + newElementsPtr->append(nelmt); + } + } + } + + //- create labels of new elements and store them + labelList newLabels(newElementsPtr->size()); + forAll(newLabels, lI) + if( lI < nElmts_ ) + { + elmts_[delElmts_[lI]] = (*newElementsPtr)[lI]; + newLabels[lI] = delElmts_[lI]; + } + else + { + newLabels[lI] = elmts_.size(); + elmts_.append((*newElementsPtr)[lI]); + } + + deleteDemandDrivenData(newElementsPtr); + # ifdef DEBUGTessalation + Info << "Labels of new elements " << newLabels << endl; + # endif + //- update neighbouring information for BOUND elements + Map<label> newPointLabel; + forAll(newLabels, lI) + { + const tessellationElement& elmt = elmts_[newLabels[lI]]; + for(direction i=0;i<DIM;++i) + if( !newPointLabel.found(elmt[i]) ) + { + const label n = newPointLabel.size(); + newPointLabel.insert(elmt[i], n); + } + + const label nei = elmt.neighbour(3); + if( nei != -1 ) + { + tessellationElement& nelmt = elmts_[nei]; + for(direction i=0;i<DIM1;++i) + if( elmt.whichPosition(nelmt[i]) == -1 ) + { + nelmt.setNeighbour(i, newLabels[lI]); + break; + } + } + } + + //- create neighbours of newly created elements + List< DynList<label> > nodeElements + ( + newPointLabel.size(), + DynList<label>(6) + ); + + forAll(newLabels, lI) + { + const tessellationElement& elmt = elmts_[newLabels[lI]]; + for(direction i=0;i<DIM;++i) + nodeElements[newPointLabel[elmt[i]]].append(newLabels[lI]); + } + + # ifdef DEBUGTessalation + Info << "Node elements " << nodeElements << endl; + Info <<"New point label " << newPointLabel << endl; + # endif + + forAll(newLabels, lI) + { + tessellationElement& elmt = elmts_[newLabels[lI]]; + for(direction i=0;i<DIM;++i) + { + const label s = newPointLabel[elmt[(i+1)%3]]; + const label e = elmt[(i+2)%3]; + const DynList<label>& nel = nodeElements[s]; + forAll(nel, elI) + if( (elmts_[nel[elI]].whichPosition(e) != -1) && + (nel[elI] != newLabels[lI]) + ) + elmt.setNeighbour(i, nel[elI]); + } + } + + # ifdef DEBUGTessalation + forAll(newLabels, lI) + { + const tessellationElement& elmt = elmts_[newLabels[lI]]; + Info << "New element " << newLabels[lI] << " is " << elmt << endl; + for(direction i=0;i<DIM1;++i) + { + Info << "Neighbour over face " << elmt.face(i) << " is " + << elmt.neighbour(i) << endl; + + triFace f = elmt.face(i); + if( elmt.neighbour(i) != -1 ) + { + const label nei = elmt.neighbour(i); + bool found(false); + for(direction j=0;j<DIM1;++j) + { + triFace fnei = elmts_[nei].face(j); + if( fnei == f ) + { + found = true; + if( elmts_[nei].neighbour(j) != newLabels[lI] ) + FatalError << "Wrong neighbour addressing" + << abort(FatalError); + } + } + + if( !found ) + FatalError << "Cannot find neighbour!" << abort(FatalError); + } + } + } + # endif } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/meshLibrary/utilities/triSurfaceTools/triSurfaceCleanupDuplicates/triSurfaceCleanupDuplicates.H b/meshLibrary/utilities/triSurfaceTools/triSurfaceCleanupDuplicates/triSurfaceCleanupDuplicates.H index 748d1e8e..cf47d21a 100644 --- a/meshLibrary/utilities/triSurfaceTools/triSurfaceCleanupDuplicates/triSurfaceCleanupDuplicates.H +++ b/meshLibrary/utilities/triSurfaceTools/triSurfaceCleanupDuplicates/triSurfaceCleanupDuplicates.H @@ -27,7 +27,7 @@ Class Description Provides information regarding surface partitions on the surface - triangulation, and connectivity between various surface partitions. + triangulation, and connectivity between various surface partitions. SourceFiles triSurfaceCleanupDuplicatesDuplicates.C diff --git a/meshLibrary/utilities/triSurfaceTools/triSurfaceCurvatureEstimator/triSurfaceCurvatureEstimator.H b/meshLibrary/utilities/triSurfaceTools/triSurfaceCurvatureEstimator/triSurfaceCurvatureEstimator.H index df51895d..7f283168 100644 --- a/meshLibrary/utilities/triSurfaceTools/triSurfaceCurvatureEstimator/triSurfaceCurvatureEstimator.H +++ b/meshLibrary/utilities/triSurfaceTools/triSurfaceCurvatureEstimator/triSurfaceCurvatureEstimator.H @@ -27,7 +27,7 @@ Class Description Provides information regarding surface partitions on the surface - triangulation, and connectivity between various surface partitions. + triangulation, and connectivity between various surface partitions. SourceFiles triSurfaceCurvatureEstimator.C diff --git a/meshLibrary/utilities/triSurfaceTools/triSurfaceDetectMaterials/triSurfaceDetectMaterials.C b/meshLibrary/utilities/triSurfaceTools/triSurfaceDetectMaterials/triSurfaceDetectMaterials.C index 63612957..5897618e 100644 --- a/meshLibrary/utilities/triSurfaceTools/triSurfaceDetectMaterials/triSurfaceDetectMaterials.C +++ b/meshLibrary/utilities/triSurfaceTools/triSurfaceDetectMaterials/triSurfaceDetectMaterials.C @@ -39,7 +39,7 @@ namespace Foam triSurfaceDetectMaterials::triSurfaceDetectMaterials(const triSurf& surface) : - surf_(surface), + surf_(surface), octreePtr_(NULL), facePartition_(), nPartitions_(), @@ -117,7 +117,7 @@ void triSurfaceDetectMaterials::writeMaterials(const fileName& fName) const Info << "Partition " << partI << " is an enclosed baffle" << endl; } } - + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // } // End namespace Foam diff --git a/meshLibrary/utilities/triSurfaceTools/triSurfaceDetectMaterials/triSurfaceDetectMaterials.H b/meshLibrary/utilities/triSurfaceTools/triSurfaceDetectMaterials/triSurfaceDetectMaterials.H index dc1e3a37..813f0a82 100644 --- a/meshLibrary/utilities/triSurfaceTools/triSurfaceDetectMaterials/triSurfaceDetectMaterials.H +++ b/meshLibrary/utilities/triSurfaceTools/triSurfaceDetectMaterials/triSurfaceDetectMaterials.H @@ -27,7 +27,7 @@ Class Description Provides information regarding surface partitions on the surface - triangulation, and connectivity between various surface partitions. + triangulation, and connectivity between various surface partitions. SourceFiles triSurfaceDetectMaterials.C @@ -55,7 +55,7 @@ class meshOctree; class triSurfaceDetectMaterials { // Private data - //- reference to triSurf + //- reference to triSurf const triSurf& surf_; //- pointer to the octree @@ -78,9 +78,9 @@ class triSurfaceDetectMaterials List<direction> partitionType_; // Private member functions - //- create partitioning + //- create partitioning void createPartitions(); - + //- create the octree void createOctree(); @@ -118,7 +118,7 @@ public: // Member Functions - + //- detect surface parts belonging to different materials void detectMaterialsAndInternalWalls(); diff --git a/meshLibrary/utilities/triSurfaceTools/triSurfacePartitioner/triSurfacePartitioner.C b/meshLibrary/utilities/triSurfaceTools/triSurfacePartitioner/triSurfacePartitioner.C index 19933881..a0276155 100644 --- a/meshLibrary/utilities/triSurfaceTools/triSurfacePartitioner/triSurfacePartitioner.C +++ b/meshLibrary/utilities/triSurfaceTools/triSurfacePartitioner/triSurfacePartitioner.C @@ -45,19 +45,19 @@ namespace Foam triSurfacePartitioner::triSurfacePartitioner ( - const triSurface& surface + const triSurface& surface ) : - surface_(surface), + surface_(surface), corners_(), - cornerPatches_(), - partitionPartitions_(surface.patches().size()), + cornerPatches_(), + partitionPartitions_(surface.patches().size()), edgePartitions_(), edgePartitionEdgePartitions_(), partitionsEdgeParts_(), edgePartitionsCorners_() { - calculatePartitionAddressing(); + calculatePartitionAddressing(); } triSurfacePartitioner::~triSurfacePartitioner() @@ -67,17 +67,17 @@ triSurfacePartitioner::~triSurfacePartitioner() const labelList& triSurfacePartitioner::corners() const { - return corners_; + return corners_; } const List<DynList<label> >& triSurfacePartitioner::cornerPatches() const { - return cornerPatches_; + return cornerPatches_; } const List<labelHashSet>& triSurfacePartitioner::partitionPartitions() const { - return partitionPartitions_; + return partitionPartitions_; } const labelList& triSurfacePartitioner::edgePartitions() const @@ -144,7 +144,7 @@ void triSurfacePartitioner::cornersBetweenEdgePartitions corners.append(corn[cornerI]); } } - + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // } // End namespace Foam diff --git a/meshLibrary/utilities/triSurfaceTools/triSurfacePartitioner/triSurfacePartitioner.H b/meshLibrary/utilities/triSurfaceTools/triSurfacePartitioner/triSurfacePartitioner.H index d9f261a1..b987df5a 100644 --- a/meshLibrary/utilities/triSurfaceTools/triSurfacePartitioner/triSurfacePartitioner.H +++ b/meshLibrary/utilities/triSurfaceTools/triSurfacePartitioner/triSurfacePartitioner.H @@ -27,7 +27,7 @@ Class Description Provides information regarding surface partitions on the surface - triangulation, and connectivity between various surface partitions. + triangulation, and connectivity between various surface partitions. SourceFiles triSurfacePartitioner.C @@ -55,15 +55,15 @@ namespace Foam class triSurfacePartitioner { // Private data - //- reference to triSurface - const triSurface& surface_; - - //- corner nodes - labelList corners_; - List<DynList<label> > cornerPatches_; - - //- information which partitions share an edge with a given partition - List<labelHashSet> partitionPartitions_; + //- reference to triSurface + const triSurface& surface_; + + //- corner nodes + labelList corners_; + List<DynList<label> > cornerPatches_; + + //- information which partitions share an edge with a given partition + List<labelHashSet> partitionPartitions_; //- edge partitions labelList edgePartitions_; @@ -79,14 +79,14 @@ class triSurfacePartitioner std::map<std::pair<label, label>, labelHashSet> edgePartitionsCorners_; // Private member functions - //- calculate partitions - void calculatePartitionAddressing(); - - //- find surface corners - void calculateCornersAndAddressing(); - - //- calculate partitionPartitions_ addressing - void calculatePartitionPartitions(); + //- calculate partitions + void calculatePartitionAddressing(); + + //- find surface corners + void calculateCornersAndAddressing(); + + //- calculate partitionPartitions_ addressing + void calculatePartitionPartitions(); //- calculate edge partitions void calculateEdgePartitions(); @@ -116,14 +116,14 @@ public: // Member Functions - //- return corner nodes - const labelList& corners() const; - - //- return corner patches - const List<DynList<label> >& cornerPatches() const; + //- return corner nodes + const labelList& corners() const; + + //- return corner patches + const List<DynList<label> >& cornerPatches() const; - //- return partition-partitions addressing - const List<labelHashSet>& partitionPartitions() const; + //- return partition-partitions addressing + const List<labelHashSet>& partitionPartitions() const; //- return edge partitions. Partitions of edges which are not //- the feature edges is set to -1 diff --git a/meshLibrary/utilities/triSurfaceTools/triSurfacePartitioner/triSurfacePartitionerCreateAddressing.C b/meshLibrary/utilities/triSurfaceTools/triSurfacePartitioner/triSurfacePartitionerCreateAddressing.C index ed56edc8..7afebc4c 100644 --- a/meshLibrary/utilities/triSurfaceTools/triSurfacePartitioner/triSurfacePartitionerCreateAddressing.C +++ b/meshLibrary/utilities/triSurfaceTools/triSurfacePartitioner/triSurfacePartitionerCreateAddressing.C @@ -39,9 +39,9 @@ namespace Foam void triSurfacePartitioner::calculatePartitionAddressing() { - calculateCornersAndAddressing(); - - calculatePartitionPartitions(); + calculateCornersAndAddressing(); + + calculatePartitionPartitions(); calculateEdgePartitions(); @@ -50,10 +50,10 @@ void triSurfacePartitioner::calculatePartitionAddressing() calculateEdgePartitionsToCorners(); } - + void triSurfacePartitioner::calculateCornersAndAddressing() { - const labelListList& pointFaces = surface_.pointFaces(); + const labelListList& pointFaces = surface_.pointFaces(); const edgeList& edges = surface_.edges(); const labelListList& edgeFaces = surface_.edgeFaces(); @@ -65,7 +65,7 @@ void triSurfacePartitioner::calculateCornersAndAddressing() continue; const label sPatch = surface_[edgeFaces[eI][0]].region(); - const label ePatch = surface_[edgeFaces[eI][1]].region(); + const label ePatch = surface_[edgeFaces[eI][1]].region(); if( sPatch != ePatch ) { @@ -85,51 +85,51 @@ void triSurfacePartitioner::calculateCornersAndAddressing() ++nCorners; } - - corners_.setSize(nCorners); - cornerPatches_.setSize(nCorners); - nCorners = 0; - + + corners_.setSize(nCorners); + cornerPatches_.setSize(nCorners); + nCorners = 0; + //- store corner data DynList<label> patches(10); - forAll(pointFaces, pointI) - { + forAll(pointFaces, pointI) + { if( nEdgesAtNode[pointI] < direction(3) ) continue; - const labelList& pf = pointFaces[pointI]; - - patches.clear(); - forAll(pf, pfI) - patches.appendIfNotIn(surface_[pf[pfI]].region()); - + const labelList& pf = pointFaces[pointI]; + + patches.clear(); + forAll(pf, pfI) + patches.appendIfNotIn(surface_[pf[pfI]].region()); + corners_[nCorners] = pointI; cornerPatches_[nCorners] = patches; ++nCorners; - } + } } - + void triSurfacePartitioner::calculatePartitionPartitions() { - const labelListList& edgeFaces = surface_.edgeFaces(); - - forAll(edgeFaces, eI) - { - if( edgeFaces[eI].size() != 2 ) - { - Warning << "Surface is not a manifold!!" << endl; - continue; - } - - const label sPatch = surface_[edgeFaces[eI][0]].region(); - const label ePatch = surface_[edgeFaces[eI][1]].region(); - - if( sPatch != ePatch ) - { - partitionPartitions_[sPatch].insert(ePatch); - partitionPartitions_[ePatch].insert(sPatch); - } - } + const labelListList& edgeFaces = surface_.edgeFaces(); + + forAll(edgeFaces, eI) + { + if( edgeFaces[eI].size() != 2 ) + { + Warning << "Surface is not a manifold!!" << endl; + continue; + } + + const label sPatch = surface_[edgeFaces[eI][0]].region(); + const label ePatch = surface_[edgeFaces[eI][1]].region(); + + if( sPatch != ePatch ) + { + partitionPartitions_[sPatch].insert(ePatch); + partitionPartitions_[ePatch].insert(sPatch); + } + } } void triSurfacePartitioner::calculateEdgePartitions() diff --git a/meshLibrary/voronoiMesh/voronoiMeshExtractor/voronoiMeshExtractor.C b/meshLibrary/voronoiMesh/voronoiMeshExtractor/voronoiMeshExtractor.C index da20cc05..ec7a8873 100644 --- a/meshLibrary/voronoiMesh/voronoiMeshExtractor/voronoiMeshExtractor.C +++ b/meshLibrary/voronoiMesh/voronoiMeshExtractor/voronoiMeshExtractor.C @@ -35,15 +35,15 @@ Description namespace Foam { - + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // void voronoiMeshExtractor::clearOut() { - deleteDemandDrivenData(pointEdgesPtr_); - deleteDemandDrivenData(edgesPtr_); - deleteDemandDrivenData(edgeTetsPtr_); - deleteDemandDrivenData(boundaryEdgePtr_); + deleteDemandDrivenData(pointEdgesPtr_); + deleteDemandDrivenData(edgesPtr_); + deleteDemandDrivenData(edgeTetsPtr_); + deleteDemandDrivenData(boundaryEdgePtr_); } // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // @@ -52,16 +52,16 @@ void voronoiMeshExtractor::clearOut() voronoiMeshExtractor::voronoiMeshExtractor ( const meshOctree& octree, - const IOdictionary& meshDict, - polyMeshGen& mesh + const IOdictionary& meshDict, + polyMeshGen& mesh ) : tetCreator_(octree, meshDict), - mesh_(mesh), - pointEdgesPtr_(NULL), - edgesPtr_(NULL), - edgeTetsPtr_(NULL), - boundaryEdgePtr_(NULL) + mesh_(mesh), + pointEdgesPtr_(NULL), + edgesPtr_(NULL), + edgeTetsPtr_(NULL), + boundaryEdgePtr_(NULL) { } @@ -69,29 +69,29 @@ voronoiMeshExtractor::voronoiMeshExtractor voronoiMeshExtractor::~voronoiMeshExtractor() { - clearOut(); + clearOut(); } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // void voronoiMeshExtractor::createMesh() { - Info << "Extracting voronoi mesh" << endl; - - //- copy tet points into the mesh - createPoints(); + Info << "Extracting voronoi mesh" << endl; + + //- copy tet points into the mesh + createPoints(); - //- create the mesh + //- create the mesh createPolyMesh(); - - polyMeshGenModifier(mesh_).reorderBoundaryFaces(); - polyMeshGenModifier(mesh_).removeUnusedVertices(); - - Info << "Mesh has :" << nl - << mesh_.points().size() << " vertices " << nl - << mesh_.faces().size() << " faces" << nl - << mesh_.cells().size() << " cells" << endl; - + + polyMeshGenModifier(mesh_).reorderBoundaryFaces(); + polyMeshGenModifier(mesh_).removeUnusedVertices(); + + Info << "Mesh has :" << nl + << mesh_.points().size() << " vertices " << nl + << mesh_.faces().size() << " faces" << nl + << mesh_.cells().size() << " cells" << endl; + Info << "Finished extracting voronoi mesh" << endl; } diff --git a/meshLibrary/voronoiMesh/voronoiMeshExtractor/voronoiMeshExtractor.H b/meshLibrary/voronoiMesh/voronoiMeshExtractor/voronoiMeshExtractor.H index b76c22c1..cdce2eb9 100644 --- a/meshLibrary/voronoiMesh/voronoiMeshExtractor/voronoiMeshExtractor.H +++ b/meshLibrary/voronoiMesh/voronoiMeshExtractor/voronoiMeshExtractor.H @@ -53,41 +53,41 @@ namespace Foam class voronoiMeshExtractor { // Private data - //- create tets - tetCreatorOctree tetCreator_; - - //- reference to the mesh - polyMeshGen& mesh_; - - //- edges connected to a vertex in the tet mesh - mutable VRWGraph* pointEdgesPtr_; - - //- edges of the tetrahedrization - mutable LongList<edge>* edgesPtr_; - - //- tets around each edge - mutable VRWGraph* edgeTetsPtr_; - - //- is edge at the boundary - mutable boolList* boundaryEdgePtr_; - + //- create tets + tetCreatorOctree tetCreator_; + + //- reference to the mesh + polyMeshGen& mesh_; + + //- edges connected to a vertex in the tet mesh + mutable VRWGraph* pointEdgesPtr_; + + //- edges of the tetrahedrization + mutable LongList<edge>* edgesPtr_; + + //- tets around each edge + mutable VRWGraph* edgeTetsPtr_; + + //- is edge at the boundary + mutable boolList* boundaryEdgePtr_; + // Private member functions - //- create and return addressing - void createAddressing() const; - - const VRWGraph& pointEdges() const; - const LongList<edge>& edges() const; - const VRWGraph& edgeTets() const; - const boolList& boundaryEdge() const; - + //- create and return addressing + void createAddressing() const; + + const VRWGraph& pointEdges() const; + const LongList<edge>& edges() const; + const VRWGraph& edgeTets() const; + const boolList& boundaryEdge() const; + //- create points of the voronoi mesh void createPoints(); //- create mesh data void createPolyMesh(); - - //- delete all pointer data - void clearOut(); + + //- delete all pointer data + void clearOut(); // Private copy constructor //- Disallow default bitwise copy construct @@ -104,8 +104,8 @@ public: voronoiMeshExtractor ( const meshOctree& octree, - const IOdictionary& meshDict, - polyMeshGen& mesh + const IOdictionary& meshDict, + polyMeshGen& mesh ); // Destructor @@ -114,7 +114,7 @@ public: // Member Functions - void createMesh(); + void createMesh(); }; diff --git a/meshLibrary/voronoiMesh/voronoiMeshExtractor/voronoiMeshExtractorAddressing.C b/meshLibrary/voronoiMesh/voronoiMeshExtractor/voronoiMeshExtractorAddressing.C index 0220de53..cb16fc7f 100644 --- a/meshLibrary/voronoiMesh/voronoiMeshExtractor/voronoiMeshExtractorAddressing.C +++ b/meshLibrary/voronoiMesh/voronoiMeshExtractor/voronoiMeshExtractorAddressing.C @@ -36,184 +36,184 @@ Description namespace Foam { - + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // void voronoiMeshExtractor::createAddressing() const { - if( pointEdgesPtr_ ) - return; - pointEdgesPtr_ = new VRWGraph(tetCreator_.tetPoints().size()); - VRWGraph& pointEdges = *pointEdgesPtr_; - - if( edgeTetsPtr_ ) - return; - edgeTetsPtr_ = new VRWGraph(); - VRWGraph& edgeTets = *edgeTetsPtr_; - - if( boundaryEdgePtr_ ) - return; - boundaryEdgePtr_ = new boolList(); - boolList& boundaryEdges = *boundaryEdgePtr_; - - if( edgesPtr_ ) - return; - edgesPtr_ = new LongList<edge>(); - LongList<edge>& edges = *edgesPtr_; - - //- create edges, pointEdges and edgeTets - const LongList<partTet>& tets = tetCreator_.tets(); - forAll(tets, tetI) - { - const edgeList tetEdges = tets[tetI].edges(); - - forAll(tetEdges, eI) - { - const edge& e = tetEdges[eI]; - const label start = e.start(); - - bool store(true); - - forAllRow(pointEdges, start, peI) - { - const label edgeI = pointEdges(start, peI); - - if( edges[edgeI] == e ) - { - store = false; - - edgeTets.append(edgeI, tetI); - } - } - - if( store ) - { - pointEdges.append(start, edges.size()); - pointEdges.append(e.end(), edges.size()); - - FixedList<label, 1> helper; - helper[0] = tetI; - edgeTets.appendList(helper); - - edges.append(e); - } - } - } - - pointEdges.optimizeMemoryUsage(); - edgeTets.optimizeMemoryUsage(); - - //- sort edge-tets in circular order - boundaryEdges.setSize(edgeTets.size()); - boundaryEdges = false; - - forAll(edgeTets, edgeI) - { - labelList eTets(edgeTets.sizeOfRow(edgeI)); - forAll(eTets, etI) - eTets[etI] = edgeTets(edgeI, etI); - - labelList nFound(eTets.size(), 0); - List<FixedList<label, 2> > elNeighbours(eTets.size()); - forAll(elNeighbours, tetI) - elNeighbours[tetI] = -1; - - forAll(eTets, tetI) - { - if( nFound[tetI] == 2 ) - continue; - - const partTet& pt = tets[eTets[tetI]]; - - for(label i=tetI+1;i<eTets.size();++i) - { - const partTet& ptNei = tets[eTets[i]]; - - label nShared(0); - for(label j=0;j<4;++j) - for(label k=0;k<4;++k) - if( pt[j] == ptNei[k] ) - { - ++nShared; - break; - } - - if( nShared == 3 ) - { - elNeighbours[tetI][nFound[tetI]++] = i; - elNeighbours[i][nFound[i]++] = tetI; - } - } - } - - bool sort(true); - forAll(nFound, tetI) - if( nFound[tetI] != 2 ) - { - boundaryEdges[edgeI] = true; - sort = false; - break; - } - - if( sort ) - { - labelList sortedTets(eTets.size()); - - label currI(0), nextI(elNeighbours[0][0]), counter(0); - sortedTets[counter++] = eTets[currI]; - - do - { - sortedTets[counter++] = eTets[nextI]; - - //- find the next element - if( elNeighbours[nextI][0] == currI ) - { - currI = nextI; - nextI = elNeighbours[nextI][1]; - } - else - { - currI = nextI; - nextI = elNeighbours[nextI][0]; - } - } while( counter < eTets.size() ); - - edgeTets.setRow(edgeI, sortedTets); - } - } + if( pointEdgesPtr_ ) + return; + pointEdgesPtr_ = new VRWGraph(tetCreator_.tetPoints().size()); + VRWGraph& pointEdges = *pointEdgesPtr_; + + if( edgeTetsPtr_ ) + return; + edgeTetsPtr_ = new VRWGraph(); + VRWGraph& edgeTets = *edgeTetsPtr_; + + if( boundaryEdgePtr_ ) + return; + boundaryEdgePtr_ = new boolList(); + boolList& boundaryEdges = *boundaryEdgePtr_; + + if( edgesPtr_ ) + return; + edgesPtr_ = new LongList<edge>(); + LongList<edge>& edges = *edgesPtr_; + + //- create edges, pointEdges and edgeTets + const LongList<partTet>& tets = tetCreator_.tets(); + forAll(tets, tetI) + { + const edgeList tetEdges = tets[tetI].edges(); + + forAll(tetEdges, eI) + { + const edge& e = tetEdges[eI]; + const label start = e.start(); + + bool store(true); + + forAllRow(pointEdges, start, peI) + { + const label edgeI = pointEdges(start, peI); + + if( edges[edgeI] == e ) + { + store = false; + + edgeTets.append(edgeI, tetI); + } + } + + if( store ) + { + pointEdges.append(start, edges.size()); + pointEdges.append(e.end(), edges.size()); + + FixedList<label, 1> helper; + helper[0] = tetI; + edgeTets.appendList(helper); + + edges.append(e); + } + } + } + + pointEdges.optimizeMemoryUsage(); + edgeTets.optimizeMemoryUsage(); + + //- sort edge-tets in circular order + boundaryEdges.setSize(edgeTets.size()); + boundaryEdges = false; + + forAll(edgeTets, edgeI) + { + labelList eTets(edgeTets.sizeOfRow(edgeI)); + forAll(eTets, etI) + eTets[etI] = edgeTets(edgeI, etI); + + labelList nFound(eTets.size(), 0); + List<FixedList<label, 2> > elNeighbours(eTets.size()); + forAll(elNeighbours, tetI) + elNeighbours[tetI] = -1; + + forAll(eTets, tetI) + { + if( nFound[tetI] == 2 ) + continue; + + const partTet& pt = tets[eTets[tetI]]; + + for(label i=tetI+1;i<eTets.size();++i) + { + const partTet& ptNei = tets[eTets[i]]; + + label nShared(0); + for(label j=0;j<4;++j) + for(label k=0;k<4;++k) + if( pt[j] == ptNei[k] ) + { + ++nShared; + break; + } + + if( nShared == 3 ) + { + elNeighbours[tetI][nFound[tetI]++] = i; + elNeighbours[i][nFound[i]++] = tetI; + } + } + } + + bool sort(true); + forAll(nFound, tetI) + if( nFound[tetI] != 2 ) + { + boundaryEdges[edgeI] = true; + sort = false; + break; + } + + if( sort ) + { + labelList sortedTets(eTets.size()); + + label currI(0), nextI(elNeighbours[0][0]), counter(0); + sortedTets[counter++] = eTets[currI]; + + do + { + sortedTets[counter++] = eTets[nextI]; + + //- find the next element + if( elNeighbours[nextI][0] == currI ) + { + currI = nextI; + nextI = elNeighbours[nextI][1]; + } + else + { + currI = nextI; + nextI = elNeighbours[nextI][0]; + } + } while( counter < eTets.size() ); + + edgeTets.setRow(edgeI, sortedTets); + } + } } const VRWGraph& voronoiMeshExtractor::pointEdges() const { - if( !pointEdgesPtr_ ) - createAddressing(); - - return *pointEdgesPtr_; + if( !pointEdgesPtr_ ) + createAddressing(); + + return *pointEdgesPtr_; } const LongList<edge>& voronoiMeshExtractor::edges() const { - if( !edgesPtr_ ) - createAddressing(); - - return *edgesPtr_; + if( !edgesPtr_ ) + createAddressing(); + + return *edgesPtr_; } const VRWGraph& voronoiMeshExtractor::edgeTets() const { - if( !edgeTetsPtr_ ) - createAddressing(); - - return *edgeTetsPtr_; + if( !edgeTetsPtr_ ) + createAddressing(); + + return *edgeTetsPtr_; } const boolList& voronoiMeshExtractor::boundaryEdge() const { - if( !boundaryEdgePtr_ ) - createAddressing(); - - return *boundaryEdgePtr_; + if( !boundaryEdgePtr_ ) + createAddressing(); + + return *boundaryEdgePtr_; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/meshLibrary/voronoiMesh/voronoiMeshExtractor/voronoiMeshExtractorCreateMesh.C b/meshLibrary/voronoiMesh/voronoiMeshExtractor/voronoiMeshExtractorCreateMesh.C index 36b69cd6..5a8dbc35 100644 --- a/meshLibrary/voronoiMesh/voronoiMeshExtractor/voronoiMeshExtractorCreateMesh.C +++ b/meshLibrary/voronoiMesh/voronoiMeshExtractor/voronoiMeshExtractorCreateMesh.C @@ -38,107 +38,107 @@ Description namespace Foam { - + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // void voronoiMeshExtractor::createPoints() { - const LongList<point>& tetPoints = tetCreator_.tetPoints(); - const LongList<partTet>& tets = tetCreator_.tets(); - - pointFieldPMG& points = mesh_.points(); - points.setSize(tets.size()); - - # ifdef DEBUGVoronoi - Info << "Number of tets " << tets.size() << endl; - # endif - - forAll(tets, tetI) - { - points[tetI] = tets[tetI].centroid(tetPoints); - - # ifdef DEBUGVoronoi - Info << "Point " << tetI << " has coordinates " - << points[tetI] << endl; - Info << "Tet of origin " << tetI << " has nodes " - << tets[tetI] << endl; - # endif - } + const LongList<point>& tetPoints = tetCreator_.tetPoints(); + const LongList<partTet>& tets = tetCreator_.tets(); + + pointFieldPMG& points = mesh_.points(); + points.setSize(tets.size()); + + # ifdef DEBUGVoronoi + Info << "Number of tets " << tets.size() << endl; + # endif + + forAll(tets, tetI) + { + points[tetI] = tets[tetI].centroid(tetPoints); + + # ifdef DEBUGVoronoi + Info << "Point " << tetI << " has coordinates " + << points[tetI] << endl; + Info << "Tet of origin " << tetI << " has nodes " + << tets[tetI] << endl; + # endif + } } void voronoiMeshExtractor::createPolyMesh() { - const VRWGraph& pointEdges = this->pointEdges(); - const VRWGraph& edgeTets = this->edgeTets(); - const boolList& boundaryEdge = this->boundaryEdge(); - const LongList<edge>& edges = this->edges(); - const LongList<partTet>& tets = tetCreator_.tets(); - - polyMeshGenModifierAddCellByCell meshModifier(mesh_); - - forAll(pointEdges, pointI) - { - bool create(true); - forAllRow(pointEdges, pointI, eI) - if( boundaryEdge[pointEdges(pointI, eI)] ) - { - create = false; - break; - } - - if( !create || (pointEdges.sizeOfRow(pointI) == 0) ) - continue; - - faceList cellFaces(pointEdges.sizeOfRow(pointI)); - - forAllRow(pointEdges, pointI, faceI) - { - const label edgeI = pointEdges(pointI, faceI); - - //- check if the face orientation needs to be changed - bool flip(false); - const partTet& tet = tets[edgeTets(edgeI, 0)]; - const partTet& tet1 = tets[edgeTets(edgeI, 1)]; - tessellationElement tEl(tet[0], tet[1], tet[2], tet[3]); - for(label i=0;i<4;++i) - { - const triFace tf = tEl.face(i); - label nShared(0); - for(label j=0;j<3;++j) - if( tet1.whichPosition(tf[j]) != -1 ) - ++nShared; - - if( nShared == 3 ) - { - const edge& e = edges[edgeI]; - - const edgeList tEdges = tf.edges(); - forAll(tEdges, teI) - if( tEdges[teI] == e ) - { - if( pointI == tEdges[teI].start() ) - flip = true; - - break; - } - - break; - } - } - - face& f = cellFaces[faceI]; - f.setSize(edgeTets.sizeOfRow(edgeI)); - - //- fill the faces with the node labels - forAll(f, pI) - f[pI] = edgeTets(edgeI, pI); - - if( flip ) - f = f.reverseFace(); - } - - meshModifier.addCell(cellFaces); - } + const VRWGraph& pointEdges = this->pointEdges(); + const VRWGraph& edgeTets = this->edgeTets(); + const boolList& boundaryEdge = this->boundaryEdge(); + const LongList<edge>& edges = this->edges(); + const LongList<partTet>& tets = tetCreator_.tets(); + + polyMeshGenModifierAddCellByCell meshModifier(mesh_); + + forAll(pointEdges, pointI) + { + bool create(true); + forAllRow(pointEdges, pointI, eI) + if( boundaryEdge[pointEdges(pointI, eI)] ) + { + create = false; + break; + } + + if( !create || (pointEdges.sizeOfRow(pointI) == 0) ) + continue; + + faceList cellFaces(pointEdges.sizeOfRow(pointI)); + + forAllRow(pointEdges, pointI, faceI) + { + const label edgeI = pointEdges(pointI, faceI); + + //- check if the face orientation needs to be changed + bool flip(false); + const partTet& tet = tets[edgeTets(edgeI, 0)]; + const partTet& tet1 = tets[edgeTets(edgeI, 1)]; + tessellationElement tEl(tet[0], tet[1], tet[2], tet[3]); + for(label i=0;i<4;++i) + { + const triFace tf = tEl.face(i); + label nShared(0); + for(label j=0;j<3;++j) + if( tet1.whichPosition(tf[j]) != -1 ) + ++nShared; + + if( nShared == 3 ) + { + const edge& e = edges[edgeI]; + + const edgeList tEdges = tf.edges(); + forAll(tEdges, teI) + if( tEdges[teI] == e ) + { + if( pointI == tEdges[teI].start() ) + flip = true; + + break; + } + + break; + } + } + + face& f = cellFaces[faceI]; + f.setSize(edgeTets.sizeOfRow(edgeI)); + + //- fill the faces with the node labels + forAll(f, pI) + f[pI] = edgeTets(edgeI, pI); + + if( flip ) + f = f.reverseFace(); + } + + meshModifier.addCell(cellFaces); + } } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/testingInterfaces/testBoundaryLayer/testBoundaryLayer.C b/testingInterfaces/testBoundaryLayer/testBoundaryLayer.C index 36ca0a3c..188794ec 100644 --- a/testingInterfaces/testBoundaryLayer/testBoundaryLayer.C +++ b/testingInterfaces/testBoundaryLayer/testBoundaryLayer.C @@ -51,46 +51,46 @@ int main(int argc, char *argv[]) # include "setRootCase.H" # include "createTime.H" # include "createPolyMesh.H" - - objectRegistry registry(runTime); - -/* labelList patchStarts(mesh.boundaryMesh().size()); - labelList patchSizes(mesh.boundaryMesh().size()); - - forAll(mesh.boundaryMesh(), patchI) - { - patchStarts[patchI] = mesh.boundaryMesh()[patchI].start(); - patchSizes[patchI] = mesh.boundaryMesh()[patchI].size(); - } - - polyMeshGen pmg - ( - registry, - mesh.points(), - mesh.faces(), - mesh.cells(), - mesh.boundaryMesh().names(), - patchStarts, - patchSizes - ); + + objectRegistry registry(runTime); + +/* labelList patchStarts(mesh.boundaryMesh().size()); + labelList patchSizes(mesh.boundaryMesh().size()); + + forAll(mesh.boundaryMesh(), patchI) + { + patchStarts[patchI] = mesh.boundaryMesh()[patchI].start(); + patchSizes[patchI] = mesh.boundaryMesh()[patchI].size(); + } + + polyMeshGen pmg + ( + registry, + mesh.points(), + mesh.faces(), + mesh.cells(), + mesh.boundaryMesh().names(), + patchStarts, + patchSizes + ); */ - polyMeshGen pmg(registry); - pmg.read(); - //writeMeshEnsight(pmg, "meshWithoutBndLayers"); - - boundaryLayers bndLayers(pmg); - //bndLayers.addLayerForPatch("inlet"); - //bndLayers.addLayerForPatch("symmetryplane"); - //bndLayers.createOTopologyLayers(); - bndLayers.addLayerForAllPatches(); - - //pmg.write(); - //meshOctree* octreePtr = NULL; - //meshOptimizer(*octreePtr, pmg).preOptimize(); - - writeMeshEnsight(pmg, "meshWithBndLayers"); - //pmg.addressingData().checkMesh(true); - + polyMeshGen pmg(registry); + pmg.read(); + //writeMeshEnsight(pmg, "meshWithoutBndLayers"); + + boundaryLayers bndLayers(pmg); + //bndLayers.addLayerForPatch("inlet"); + //bndLayers.addLayerForPatch("symmetryplane"); + //bndLayers.createOTopologyLayers(); + bndLayers.addLayerForAllPatches(); + + //pmg.write(); + //meshOctree* octreePtr = NULL; + //meshOptimizer(*octreePtr, pmg).preOptimize(); + + writeMeshEnsight(pmg, "meshWithBndLayers"); + //pmg.addressingData().checkMesh(true); + Info << "End\n" << endl; return 0; } diff --git a/testingInterfaces/testCartesianMeshExtractor/testCartesianMeshExtractor.C b/testingInterfaces/testCartesianMeshExtractor/testCartesianMeshExtractor.C index bce35148..d51c3aa1 100644 --- a/testingInterfaces/testCartesianMeshExtractor/testCartesianMeshExtractor.C +++ b/testingInterfaces/testCartesianMeshExtractor/testCartesianMeshExtractor.C @@ -52,7 +52,7 @@ int main(int argc, char *argv[]) # include "setRootCase.H" # include "createTime.H" - IOdictionary meshDict + IOdictionary meshDict ( IOobject ( @@ -64,48 +64,48 @@ int main(int argc, char *argv[]) ) ); - fileName surfaceFile = meshDict.lookup("surfaceFile"); + fileName surfaceFile = meshDict.lookup("surfaceFile"); if( Pstream::parRun() ) - surfaceFile = ".."/surfaceFile; + surfaceFile = ".."/surfaceFile; triSurf surf(runTime.path()/surfaceFile); - if( meshDict.found("subsetFileName") ) - { - fileName subsetFileName = meshDict.lookup("subsetFileName"); + if( meshDict.found("subsetFileName") ) + { + fileName subsetFileName = meshDict.lookup("subsetFileName"); if( Pstream::parRun() ) - subsetFileName = ".."/subsetFileName; - surf.readFaceSubsets(runTime.path()/subsetFileName); - } + subsetFileName = ".."/subsetFileName; + surf.readFaceSubsets(runTime.path()/subsetFileName); + } - // construct the octree + // construct the octree meshOctree mo(surf); - meshOctreeCreator(mo, meshDict).createOctreeBoxes(); + meshOctreeCreator(mo, meshDict).createOctreeBoxes(); meshOctreeAutomaticRefinement(mo, meshDict, false).automaticRefinement(); - Info<< "Execution time for octree creation = " + Info<< "Execution time for octree creation = " << runTime.elapsedCpuTime() << " s\n" << endl << endl; - polyMeshGen pmg(runTime); - cartesianMeshExtractor cmg(mo, meshDict, pmg); + polyMeshGen pmg(runTime); + cartesianMeshExtractor cmg(mo, meshDict, pmg); - //cmg.decomposeSplitHexes(); - cmg.createMesh(); + //cmg.decomposeSplitHexes(); + cmg.createMesh(); pmg.write(); /* if( Pstream::parRun() ) { std::ostringstream ss; - ss << Pstream::myProcNo(); + ss << Pstream::myProcNo(); writeMeshEnsight(pmg, "cartesianMesh"+ss.str()); } else { writeMeshEnsight(pmg, "cartesianMesh"); - } + } */ Info << "End\n" << endl; return 0; diff --git a/testingInterfaces/testCellSurfaceIntersections/testCellSurfaceIntersections.C b/testingInterfaces/testCellSurfaceIntersections/testCellSurfaceIntersections.C index 95cf6c59..8f908254 100644 --- a/testingInterfaces/testCellSurfaceIntersections/testCellSurfaceIntersections.C +++ b/testingInterfaces/testCellSurfaceIntersections/testCellSurfaceIntersections.C @@ -64,23 +64,23 @@ int main(int argc, char *argv[]) ) ); - fileName surfaceFile = meshDict.lookup("surfaceFile"); + fileName surfaceFile = meshDict.lookup("surfaceFile"); if( Pstream::parRun() ) - surfaceFile = ".."/surfaceFile; + surfaceFile = ".."/surfaceFile; triSurf surf(runTime.path()/surfaceFile); - if( meshDict.found("subsetFileName") ) - { - fileName subsetFileName = meshDict.lookup("subsetFileName"); + if( meshDict.found("subsetFileName") ) + { + fileName subsetFileName = meshDict.lookup("subsetFileName"); if( Pstream::parRun() ) - subsetFileName = ".."/subsetFileName; - surf.readFaceSubsets(runTime.path()/subsetFileName); - } + subsetFileName = ".."/subsetFileName; + surf.readFaceSubsets(runTime.path()/subsetFileName); + } - // construct the octree + // construct the octree meshOctree mo(surf); - meshOctreeCreator(mo, meshDict).createOctreeBoxes(); + meshOctreeCreator(mo, meshDict).createOctreeBoxes(); polyMeshGen pmg(runTime); pmg.read(); diff --git a/testingInterfaces/testChainFromEdges/testChainFromEdges.C b/testingInterfaces/testChainFromEdges/testChainFromEdges.C index ce4f3373..17ad38a7 100644 --- a/testingInterfaces/testChainFromEdges/testChainFromEdges.C +++ b/testingInterfaces/testChainFromEdges/testChainFromEdges.C @@ -40,25 +40,25 @@ using namespace Foam; int main(int argc, char *argv[]) { - DynList<edge> bEdges; - bEdges.append(edge(33, 34)); - bEdges.append(edge(33, 12)); - bEdges.append(edge(34, 12)); - bEdges.append(edge(12, 35)); - bEdges.append(edge(40, 41)); - bEdges.append(edge(40, 12)); - bEdges.append(edge(41, 36)); - bEdges.append(edge(35, 36)); - - bEdges.append(edge(41, 50)); - bEdges.append(edge(48, 57)); - bEdges.append(edge(50, 57)); - bEdges.append(edge(41, 48)); - - sortEdgesIntoChains seic(bEdges); - - Info << "Sorted chains are " << seic.sortedChains() << endl; - + DynList<edge> bEdges; + bEdges.append(edge(33, 34)); + bEdges.append(edge(33, 12)); + bEdges.append(edge(34, 12)); + bEdges.append(edge(12, 35)); + bEdges.append(edge(40, 41)); + bEdges.append(edge(40, 12)); + bEdges.append(edge(41, 36)); + bEdges.append(edge(35, 36)); + + bEdges.append(edge(41, 50)); + bEdges.append(edge(48, 57)); + bEdges.append(edge(50, 57)); + bEdges.append(edge(41, 48)); + + sortEdgesIntoChains seic(bEdges); + + Info << "Sorted chains are " << seic.sortedChains() << endl; + Info << "End\n" << endl; return 0; } diff --git a/testingInterfaces/testConcaveCellUnfolder/testConcaveCellUnfolder.C b/testingInterfaces/testConcaveCellUnfolder/testConcaveCellUnfolder.C index 59932b86..26cdd94e 100644 --- a/testingInterfaces/testConcaveCellUnfolder/testConcaveCellUnfolder.C +++ b/testingInterfaces/testConcaveCellUnfolder/testConcaveCellUnfolder.C @@ -54,10 +54,10 @@ int main(int argc, char *argv[]) # include "setRootCase.H" # include "createTime.H" # include "createPolyMesh.H" - - objectRegistry registry(runTime); - - IOdictionary meshDict + + objectRegistry registry(runTime); + + IOdictionary meshDict ( IOobject ( @@ -68,48 +68,48 @@ int main(int argc, char *argv[]) IOobject::NO_WRITE ) ); - - const fileName surfaceFile = meshDict.lookup("surfaceFile"); + + const fileName surfaceFile = meshDict.lookup("surfaceFile"); triSurf surf(registry.path()/surfaceFile); - // construct the octree + // construct the octree meshOctree mo(surf); - meshOctreeCreator(mo, meshDict).createOctreeWithRefinedBoundary(8); - - // construct the polyMeshGen - labelList starts(mesh.boundaryMesh().names().size()); - labelList nFacesInPatch(starts.size()); - - forAll(mesh.boundaryMesh(), patchI) - { - starts[patchI] = mesh.boundaryMesh()[patchI].start(); - nFacesInPatch[patchI] = mesh.boundaryMesh()[patchI].size(); - } - - polyMeshGen pmg - ( - registry, - mesh.points(), - mesh.faces(), - mesh.cells(), - mesh.boundaryMesh().names(), - starts, - nFacesInPatch - ); - - //- optimize surface to get rid of nearby vertices - meshSurfaceEngine* msePtr = new meshSurfaceEngine(pmg); - meshSurfaceOptimizer(*msePtr, mo).optimizeSurface(); - deleteDemandDrivenData(msePtr); - - - dualUnfoldConcaveCells(pmg, mo).unfoldInvalidCells(); - - pmg.write(); - writeMeshEnsight(pmg, "correctedEdges"); - pmg.addressingData().checkMesh(true); - + meshOctreeCreator(mo, meshDict).createOctreeWithRefinedBoundary(8); + + // construct the polyMeshGen + labelList starts(mesh.boundaryMesh().names().size()); + labelList nFacesInPatch(starts.size()); + + forAll(mesh.boundaryMesh(), patchI) + { + starts[patchI] = mesh.boundaryMesh()[patchI].start(); + nFacesInPatch[patchI] = mesh.boundaryMesh()[patchI].size(); + } + + polyMeshGen pmg + ( + registry, + mesh.points(), + mesh.faces(), + mesh.cells(), + mesh.boundaryMesh().names(), + starts, + nFacesInPatch + ); + + //- optimize surface to get rid of nearby vertices + meshSurfaceEngine* msePtr = new meshSurfaceEngine(pmg); + meshSurfaceOptimizer(*msePtr, mo).optimizeSurface(); + deleteDemandDrivenData(msePtr); + + + dualUnfoldConcaveCells(pmg, mo).unfoldInvalidCells(); + + pmg.write(); + writeMeshEnsight(pmg, "correctedEdges"); + pmg.addressingData().checkMesh(true); + Info << "End\n" << endl; return 0; } diff --git a/testingInterfaces/testDelaunay/testDelaunay.C b/testingInterfaces/testDelaunay/testDelaunay.C index bdb1b4ee..ca699a01 100644 --- a/testingInterfaces/testDelaunay/testDelaunay.C +++ b/testingInterfaces/testDelaunay/testDelaunay.C @@ -42,28 +42,28 @@ using namespace Foam; int main(int argc, char *argv[]) { - Random ranGen(label(0)); - - DynListHP<point> points; - - scalar scale = 5; + Random ranGen(label(0)); + + DynListHP<point> points; + + scalar scale = 5; vector refPoint(10, -20, 0); - for(label i=0;i<16;++i) - points.append(scale*(ranGen.vector01() + refPoint)); - - cpuTime executionTime; - delaunayTessellation dt(points); - - for(label i=0;i<16;++i) - while( !dt.addPoint(i) ) - {} - - Info<< "ExecutionTime = " + for(label i=0;i<16;++i) + points.append(scale*(ranGen.vector01() + refPoint)); + + cpuTime executionTime; + delaunayTessellation dt(points); + + for(label i=0;i<16;++i) + while( !dt.addPoint(i) ) + {} + + Info<< "ExecutionTime = " << executionTime.elapsedCpuTime() - << " s\n" << endl << endl; - - dt.checkTessellation(); - + << " s\n" << endl << endl; + + dt.checkTessellation(); + Info << "End\n" << endl; return 0; } diff --git a/testingInterfaces/testDualMeshExtractor/testDualMeshExtractor.C b/testingInterfaces/testDualMeshExtractor/testDualMeshExtractor.C index 4f8fb342..005cfe82 100644 --- a/testingInterfaces/testDualMeshExtractor/testDualMeshExtractor.C +++ b/testingInterfaces/testDualMeshExtractor/testDualMeshExtractor.C @@ -52,10 +52,10 @@ int main(int argc, char *argv[]) { # include "setRootCase.H" # include "createTime.H" - - objectRegistry registry(runTime); - - IOdictionary meshDict + + objectRegistry registry(runTime); + + IOdictionary meshDict ( IOobject ( @@ -66,28 +66,28 @@ int main(int argc, char *argv[]) IOobject::NO_WRITE ) ); - - const fileName surfaceFile = meshDict.lookup("surfaceFile"); + + const fileName surfaceFile = meshDict.lookup("surfaceFile"); triSurf surf(registry.path()/surfaceFile); - // construct the octree + // construct the octree meshOctree mo(surf); - meshOctreeCreator(mo, meshDict).createOctreeBoxes(); - - polyMeshGen pmg(registry); - - dualMeshExtractor dme(mo, meshDict, pmg); - dme.createMesh(); - - meshOptimizer mOpt(pmg); - mOpt.untangleMeshFV(); - - writeMeshEnsight(pmg, "dualMesh"); - //writeMeshFPMA(pmg, "dualMesh"); - pmg.addressingData().checkMesh(true); - pmg.write(); - + meshOctreeCreator(mo, meshDict).createOctreeBoxes(); + + polyMeshGen pmg(registry); + + dualMeshExtractor dme(mo, meshDict, pmg); + dme.createMesh(); + + meshOptimizer mOpt(pmg); + mOpt.untangleMeshFV(); + + writeMeshEnsight(pmg, "dualMesh"); + //writeMeshFPMA(pmg, "dualMesh"); + pmg.addressingData().checkMesh(true); + pmg.write(); + Info << "End\n" << endl; return 0; } diff --git a/testingInterfaces/testDynListHP/testDynListHP.C b/testingInterfaces/testDynListHP/testDynListHP.C index 3597691e..13ee742d 100644 --- a/testingInterfaces/testDynListHP/testDynListHP.C +++ b/testingInterfaces/testDynListHP/testDynListHP.C @@ -46,11 +46,11 @@ using namespace Foam; int main(int argc, char *argv[]) { - + //# include "setRootCase.H" //# include "createTime.H" - - //objectRegistry registry(runTime); + + //objectRegistry registry(runTime); for(label i=0;i<2;++i) { @@ -75,29 +75,29 @@ int main(int argc, char *argv[]) } - /* - for(label i=0;i<2;i++) - { - DynListHP<point*> l1; + /* + for(label i=0;i<2;i++) + { + DynListHP<point*> l1; - labelListPMG l2(1000000, 15); - - l2.append(13); - l2.append(18); - l2.shrink(); + labelListPMG l2(1000000, 15); + + l2.append(13); + l2.append(18); + l2.shrink(); for(label i=0;i<10000000;++i) l2.append(i); - - //Info << "l2 " << l2 << endl; - - DynListHP<point> points(100000); - forAll(points, pI) - points[pI] = point(pI+1, pI+2, pI+3); - - points.append(point(1, 0, 0)); - points.append(point(15, 5, 3)); - points.append(point(2, 3, 1)); + + //Info << "l2 " << l2 << endl; + + DynListHP<point> points(100000); + forAll(points, pI) + points[pI] = point(pI+1, pI+2, pI+3); + + points.append(point(1, 0, 0)); + points.append(point(15, 5, 3)); + points.append(point(2, 3, 1)); FCWGraph<label, 8> lg(10000000); forAll(lg, i) @@ -105,10 +105,10 @@ int main(int argc, char *argv[]) FixedList<label, 8> lst(10); lg.setRow(i, lst); } - - forAll(points, pI) - l1.append(&points[pI]); - } + + forAll(points, pI) + l1.append(&points[pI]); + } if( Pstream::parRun() ) { @@ -131,7 +131,7 @@ int main(int argc, char *argv[]) Pout << "Values " << d << endl; } } - */ + */ Info << "End\n" << endl; return 0; } diff --git a/testingInterfaces/testFacesFromChain/testFacesFromChain.C b/testingInterfaces/testFacesFromChain/testFacesFromChain.C index 51622a81..dcdfe1ca 100644 --- a/testingInterfaces/testFacesFromChain/testFacesFromChain.C +++ b/testingInterfaces/testFacesFromChain/testFacesFromChain.C @@ -40,54 +40,54 @@ using namespace Foam; int main(int argc, char *argv[]) { - labelList chainPoints(10); - forAll(chainPoints, pI) - chainPoints[pI] = pI; - - List<DynList<label> > pointPatches(10); - pointPatches[0].append(1); - pointPatches[0].append(2); - - pointPatches[1].append(2); - - pointPatches[2].append(2); - pointPatches[2].append(3); - - pointPatches[3].append(3); - - pointPatches[4].append(2); - pointPatches[4].append(3); - - pointPatches[5].append(2); - - pointPatches[6].append(0); - pointPatches[6].append(2); - - pointPatches[7].append(0); + labelList chainPoints(10); + forAll(chainPoints, pI) + chainPoints[pI] = pI; + + List<DynList<label> > pointPatches(10); + pointPatches[0].append(1); + pointPatches[0].append(2); + + pointPatches[1].append(2); + + pointPatches[2].append(2); + pointPatches[2].append(3); + + pointPatches[3].append(3); + + pointPatches[4].append(2); + pointPatches[4].append(3); + + pointPatches[5].append(2); + + pointPatches[6].append(0); + pointPatches[6].append(2); + + pointPatches[7].append(0); - pointPatches[8].append(0); - pointPatches[8].append(1); - - pointPatches[9].append(1); - - boundaryFacesGenerator::createFacesFromChain cffc - ( - chainPoints, - pointPatches - ); - - cffc.createFacesWithoutACorner(); - - Info << "1. Created faces are " << cffc.createdFaces() << endl; - Info << "1. Face patches " << cffc.faceRegion() << endl; - Info << "1. Unresolved points " << cffc.unresolvedPoints() << endl; - - cffc.createFacesWithACorner(10); - - Info << "2. Created faces are " << cffc.createdFaces() << endl; - Info << "2. Face patches " << cffc.faceRegion() << endl; - Info << "2. Unresolved points " << cffc.unresolvedPoints() << endl; - + pointPatches[8].append(0); + pointPatches[8].append(1); + + pointPatches[9].append(1); + + boundaryFacesGenerator::createFacesFromChain cffc + ( + chainPoints, + pointPatches + ); + + cffc.createFacesWithoutACorner(); + + Info << "1. Created faces are " << cffc.createdFaces() << endl; + Info << "1. Face patches " << cffc.faceRegion() << endl; + Info << "1. Unresolved points " << cffc.unresolvedPoints() << endl; + + cffc.createFacesWithACorner(10); + + Info << "2. Created faces are " << cffc.createdFaces() << endl; + Info << "2. Face patches " << cffc.faceRegion() << endl; + Info << "2. Unresolved points " << cffc.unresolvedPoints() << endl; + Info << "End\n" << endl; return 0; } diff --git a/testingInterfaces/testGraph/testGraph.C b/testingInterfaces/testGraph/testGraph.C index 8fef37c8..f318cc82 100644 --- a/testingInterfaces/testGraph/testGraph.C +++ b/testingInterfaces/testGraph/testGraph.C @@ -45,7 +45,7 @@ using namespace Foam; int main(int argc, char *argv[]) { - + //# include "setRootCase.H" //# include "createTime.H" @@ -97,7 +97,7 @@ int main(int argc, char *argv[]) //Info << "Orig graph " << origGraph << endl; //Info << "Reversed graph " << reverse << endl; - + Info << "End\n" << endl; return 0; } diff --git a/testingInterfaces/testMaterialDetector/testMaterialDetector.C b/testingInterfaces/testMaterialDetector/testMaterialDetector.C index b9043521..fc4c6204 100644 --- a/testingInterfaces/testMaterialDetector/testMaterialDetector.C +++ b/testingInterfaces/testMaterialDetector/testMaterialDetector.C @@ -48,8 +48,8 @@ int main(int argc, char *argv[]) { # include "setRootCase.H" # include "createTime.H" - - IOdictionary meshDict + + IOdictionary meshDict ( IOobject ( @@ -60,13 +60,13 @@ int main(int argc, char *argv[]) IOobject::NO_WRITE ) ); - - fileName surfaceFile = meshDict.lookup("surfaceFile"); + + fileName surfaceFile = meshDict.lookup("surfaceFile"); if( Pstream::parRun() ) - surfaceFile = ".."/surfaceFile; + surfaceFile = ".."/surfaceFile; triSurf surf(runTime.path()/surfaceFile); - + triSurfaceDetectMaterials detector(surf); detector.detectMaterialsAndInternalWalls(); Info << "Found " << detector.numberOfPartitions() << " partitions" << endl; diff --git a/testingInterfaces/testParallelMesh/testParallelMesh.C b/testingInterfaces/testParallelMesh/testParallelMesh.C index 329eac95..5e49743e 100644 --- a/testingInterfaces/testParallelMesh/testParallelMesh.C +++ b/testingInterfaces/testParallelMesh/testParallelMesh.C @@ -50,10 +50,10 @@ int main(int argc, char *argv[]) { # include "setRootCase.H" # include "createTime.H" - - polyMeshGen pmg(runTime); - pmg.read(); - + + polyMeshGen pmg(runTime); + pmg.read(); + //- test number of nodes per processor face const pointFieldPMG& points = pmg.points(); const faceListPMG& faces = pmg.faces(); @@ -224,7 +224,7 @@ int main(int argc, char *argv[]) << patchI << " is not correct!" << abort(FatalError); } } - } + } /* Serr << Pstream::myProcNo() << "Global point labels " << pmg.addressingData().globalPointLabel() << endl; diff --git a/testingInterfaces/testRenumberMesh/testRenumberMesh.C b/testingInterfaces/testRenumberMesh/testRenumberMesh.C index 937983e8..5b1d0932 100644 --- a/testingInterfaces/testRenumberMesh/testRenumberMesh.C +++ b/testingInterfaces/testRenumberMesh/testRenumberMesh.C @@ -46,43 +46,43 @@ int main(int argc, char *argv[]) { # include "setRootCase.H" # include "createTime.H" - - objectRegistry registry(runTime); - - polyMeshGen pmg(registry); - pmg.read(); - - const labelList& owner = pmg.owner(); - const labelList& neighbour = pmg.neighbour(); - - label band(0); - forAll(owner, fI) - { - const label diff = neighbour[fI] - owner[fI]; - if( diff > band ) - band = diff; - } - - Info << "Band before renumbering is " << band << endl; - - polyMeshGenModifier(pmg).renumberMesh(); - - const labelList& newOwner = pmg.owner(); - const labelList& newNeighbour = pmg.neighbour(); - band = 0; - forAll(newOwner, fI) - { - const label diff = newNeighbour[fI] - newOwner[fI]; - if( diff > band ) - band = diff; - } - - Info << "Band after renumbering is " << band << endl; - - pmg.addressingData().checkMesh(true); - - //pmg.write(); - + + objectRegistry registry(runTime); + + polyMeshGen pmg(registry); + pmg.read(); + + const labelList& owner = pmg.owner(); + const labelList& neighbour = pmg.neighbour(); + + label band(0); + forAll(owner, fI) + { + const label diff = neighbour[fI] - owner[fI]; + if( diff > band ) + band = diff; + } + + Info << "Band before renumbering is " << band << endl; + + polyMeshGenModifier(pmg).renumberMesh(); + + const labelList& newOwner = pmg.owner(); + const labelList& newNeighbour = pmg.neighbour(); + band = 0; + forAll(newOwner, fI) + { + const label diff = newNeighbour[fI] - newOwner[fI]; + if( diff > band ) + band = diff; + } + + Info << "Band after renumbering is " << band << endl; + + pmg.addressingData().checkMesh(true); + + //pmg.write(); + Info << "End\n" << endl; return 0; } diff --git a/testingInterfaces/testSurfaceEdgeExtractor/testSurfaceEdgeExtractor.C b/testingInterfaces/testSurfaceEdgeExtractor/testSurfaceEdgeExtractor.C index 65f3bd60..45669e94 100644 --- a/testingInterfaces/testSurfaceEdgeExtractor/testSurfaceEdgeExtractor.C +++ b/testingInterfaces/testSurfaceEdgeExtractor/testSurfaceEdgeExtractor.C @@ -49,10 +49,10 @@ int main(int argc, char *argv[]) { # include "setRootCase.H" # include "createTime.H" - - objectRegistry registry(runTime); - - IOdictionary meshDict + + objectRegistry registry(runTime); + + IOdictionary meshDict ( IOobject ( @@ -63,40 +63,40 @@ int main(int argc, char *argv[]) IOobject::NO_WRITE ) ); - - const fileName surfaceFile = meshDict.lookup("surfaceFile"); + + const fileName surfaceFile = meshDict.lookup("surfaceFile"); triSurf surf(registry.path()/surfaceFile); - // construct the octree + // construct the octree meshOctree mo(surf); - meshOctreeCreator(mo, meshDict).createOctreeWithRefinedBoundary(8); - - // construct the polyMeshGen - polyMeshGen pmg(registry); - pmg.read(); - - // find regions for boundary vertices - meshSurfaceEngine mse(pmg); - - labelList pointRegion(pmg.points().size(), -1); - - Info << "Finding boundary regions for boundary vertices" << endl; - const labelList& bPoints = mse.boundaryPoints(); - forAll(bPoints, bpI) - { - point& p = pmg.points()[bPoints[bpI]]; - point np; - mo.findNearestSurfacePoint(np, pointRegion[bPoints[bpI]], p); - p = np; - } - - Info << "Extracting edges" << endl; - meshSurfaceEdgeExtractor(pmg, mo, pointRegion); - - writeMeshEnsight(pmg, "meshWithEdges"); - pmg.addressingData().checkMesh(true); - + meshOctreeCreator(mo, meshDict).createOctreeWithRefinedBoundary(8); + + // construct the polyMeshGen + polyMeshGen pmg(registry); + pmg.read(); + + // find regions for boundary vertices + meshSurfaceEngine mse(pmg); + + labelList pointRegion(pmg.points().size(), -1); + + Info << "Finding boundary regions for boundary vertices" << endl; + const labelList& bPoints = mse.boundaryPoints(); + forAll(bPoints, bpI) + { + point& p = pmg.points()[bPoints[bpI]]; + point np; + mo.findNearestSurfacePoint(np, pointRegion[bPoints[bpI]], p); + p = np; + } + + Info << "Extracting edges" << endl; + meshSurfaceEdgeExtractor(pmg, mo, pointRegion); + + writeMeshEnsight(pmg, "meshWithEdges"); + pmg.addressingData().checkMesh(true); + Info << "End\n" << endl; return 0; } diff --git a/testingInterfaces/testSurfaceMorpher/testSurfaceMorpher.C b/testingInterfaces/testSurfaceMorpher/testSurfaceMorpher.C index 0e01d132..e35a2d50 100644 --- a/testingInterfaces/testSurfaceMorpher/testSurfaceMorpher.C +++ b/testingInterfaces/testSurfaceMorpher/testSurfaceMorpher.C @@ -50,21 +50,21 @@ int main(int argc, char *argv[]) { # include "setRootCase.H" # include "createTime.H" - + polyMeshGen pmg(runTime); pmg.read(); - + do { surfaceMorpherCells* morpherPtr = new surfaceMorpherCells(pmg); morpherPtr->morphMesh(); deleteDemandDrivenData(morpherPtr); } while( topologicalCleaner(pmg).cleanTopology() ); - + writeMeshEnsight(pmg, "morphedMesh"); //pmg.addressingData().checkMesh(true); pmg.write(); - + Info << "End\n" << endl; return 0; } diff --git a/testingInterfaces/testSurfaceSmoothing/testSurfaceSmoothing.C b/testingInterfaces/testSurfaceSmoothing/testSurfaceSmoothing.C index 3f1c8b71..c507cae9 100644 --- a/testingInterfaces/testSurfaceSmoothing/testSurfaceSmoothing.C +++ b/testingInterfaces/testSurfaceSmoothing/testSurfaceSmoothing.C @@ -50,8 +50,8 @@ int main(int argc, char *argv[]) { # include "setRootCase.H" # include "createTime.H" - - objectRegistry registry(runTime); + + objectRegistry registry(runTime); IOdictionary meshDict ( @@ -67,24 +67,24 @@ int main(int argc, char *argv[]) fileName surfaceFile = meshDict.lookup("surfaceFile"); if( Pstream::parRun() ) - surfaceFile = ".."/surfaceFile; + surfaceFile = ".."/surfaceFile; triSurf surf(registry.path()/surfaceFile); - - if( meshDict.found("subsetFileName") ) - { - fileName subsetFileName = meshDict.lookup("subsetFileName"); + + if( meshDict.found("subsetFileName") ) + { + fileName subsetFileName = meshDict.lookup("subsetFileName"); if( Pstream::parRun() ) - subsetFileName = ".."/subsetFileName; - surf.readFaceSubsets(registry.path()/subsetFileName); - } + subsetFileName = ".."/subsetFileName; + surf.readFaceSubsets(registry.path()/subsetFileName); + } - // construct the octree + // construct the octree meshOctree moc(surf); - meshOctreeCreator(moc, meshDict).createOctreeBoxes(); + meshOctreeCreator(moc, meshDict).createOctreeBoxes(); - polyMeshGen pmg(registry); - pmg.read(); + polyMeshGen pmg(registry); + pmg.read(); // make sure that mesh contains all surface patches if( @@ -121,27 +121,27 @@ int main(int argc, char *argv[]) meshModifier.patchStartAccess() = patchStart; meshModifier.nFacesInPatchAccess() = nFacesInPatch; } - - meshSurfaceEngine ms(pmg); - meshSurfaceOptimizer mo(ms, moc); + + meshSurfaceEngine ms(pmg); + meshSurfaceOptimizer mo(ms, moc); /* - labelList pointRegion(pmg.points().size(), -1); - for(label faceI=mesh.nInternalFaces();faceI<pmg.faces().size();faceI++) - { - const face& f = pmg.faces()[faceI]; - - forAll(f, pI) - pointRegion[f[pI]] = 1; + labelList pointRegion(pmg.points().size(), -1); + for(label faceI=mesh.nInternalFaces();faceI<pmg.faces().size();faceI++) + { + const face& f = pmg.faces()[faceI]; + + forAll(f, pI) + pointRegion[f[pI]] = 1; } - mo.preOptimizeSurface(pointRegion); - */ + mo.preOptimizeSurface(pointRegion); + */ mo.optimizeSurface(); pmg.write(); - writeMeshEnsight(pmg, "smoothMesh"); - + writeMeshEnsight(pmg, "smoothMesh"); + Info << "End\n" << endl; return 0; } diff --git a/testingInterfaces/testVoronoiMeshExtractor/testVoronoiMeshExtractor.C b/testingInterfaces/testVoronoiMeshExtractor/testVoronoiMeshExtractor.C index 0a20f47e..3177823a 100644 --- a/testingInterfaces/testVoronoiMeshExtractor/testVoronoiMeshExtractor.C +++ b/testingInterfaces/testVoronoiMeshExtractor/testVoronoiMeshExtractor.C @@ -50,10 +50,10 @@ int main(int argc, char *argv[]) { # include "setRootCase.H" # include "createTime.H" - - objectRegistry registry(runTime); - - IOdictionary meshDict + + objectRegistry registry(runTime); + + IOdictionary meshDict ( IOobject ( @@ -64,27 +64,27 @@ int main(int argc, char *argv[]) IOobject::NO_WRITE ) ); - - const fileName surfaceFile = meshDict.lookup("surfaceFile"); + + const fileName surfaceFile = meshDict.lookup("surfaceFile"); triSurf surf(registry.path()/surfaceFile); - // construct the octree + // construct the octree meshOctree mo(surf); - meshOctreeCreator(mo, meshDict).createOctreeBoxes(); - - Info<< "Execution time for octree creation = " + meshOctreeCreator(mo, meshDict).createOctreeBoxes(); + + Info<< "Execution time for octree creation = " << runTime.elapsedCpuTime() << " s\n" << endl << endl; - - polyMeshGen pmg(registry); - voronoiMeshExtractor vmg(mo, meshDict, pmg); - - vmg.createMesh(); - - pmg.write(); - writeMeshEnsight(pmg, "voronoiMesh"); - + + polyMeshGen pmg(registry); + voronoiMeshExtractor vmg(mo, meshDict, pmg); + + vmg.createMesh(); + + pmg.write(); + writeMeshEnsight(pmg, "voronoiMesh"); + Info << "End\n" << endl; return 0; } diff --git a/tutorials/FanOctree/system/meshDict b/tutorials/FanOctree/system/meshDict index 24907a17..a4455d43 100755 --- a/tutorials/FanOctree/system/meshDict +++ b/tutorials/FanOctree/system/meshDict @@ -37,33 +37,33 @@ boundaryCellSize 10; patchCellSize 19 ( - // outer rim - patch0 5 - // blade seat edge - patch5 1.25 - - // shaft - patch6 10 - - // thin edges at blade ends - patch37 0.625 - patch55 0.625 - patch72 0.625 - patch89 0.625 - patch86 0.625 - patch114 0.625 - patch138 0.625 - patch157 0.625 - - // blades - patch8 5 - patch11 5 + // outer rim + patch0 5 + // blade seat edge + patch5 1.25 + + // shaft + patch6 10 + + // thin edges at blade ends + patch37 0.625 + patch55 0.625 + patch72 0.625 + patch89 0.625 + patch86 0.625 + patch114 0.625 + patch138 0.625 + patch157 0.625 + + // blades + patch8 5 + patch11 5 patch12 5 - patch16 5 - patch19 5 - patch24 5 - patch27 5 - patch30 5 + patch16 5 + patch19 5 + patch24 5 + patch27 5 + patch30 5 ); subsetFileName "Fan1.sftr"; @@ -71,15 +71,15 @@ subsetFileName "Fan1.sftr"; subsetCellSize 1 ( - _refine_1 2.5 + _refine_1 2.5 ); keepCellsIntersectingPatches 3 ( - patch0 - patch1 - patch2 + patch0 + patch1 + patch2 ); keepCellsIntersectingBoundary 1; diff --git a/tutorials/asmoOctree/system/meshDict b/tutorials/asmoOctree/system/meshDict index 01f3c633..06df937a 100755 --- a/tutorials/asmoOctree/system/meshDict +++ b/tutorials/asmoOctree/system/meshDict @@ -39,9 +39,9 @@ minCellSize 0.0125; patchCellSize 3 ( - defaultFaces0006 0.005 - defaultFaces0007 0.0025 - defaultFaces0009 0.0025 + defaultFaces0006 0.005 + defaultFaces0007 0.0025 + defaultFaces0009 0.0025 ); /* keepCellsIntersectingPatches @@ -54,5 +54,5 @@ keepCellsIntersectingPatches */ internalVertex (1.5 -0.4 0.8); - + // ************************************************************************* // diff --git a/tutorials/bunnyOctree/system/meshDict b/tutorials/bunnyOctree/system/meshDict index 1f89a2cd..9993deaa 100755 --- a/tutorials/bunnyOctree/system/meshDict +++ b/tutorials/bunnyOctree/system/meshDict @@ -39,44 +39,44 @@ objectRefinements ( ear1 { - cellSize 3.75; - type cone; - p0 (-100 1873 -320); - radius0 200; - p1 (-560 1400 0); - radius1 200; + cellSize 3.75; + type cone; + p0 (-100 1873 -320); + radius0 200; + p1 (-560 1400 0); + radius1 200; } ear2 { - cellSize 3.75; - type cone; - p0 (-650 1873 -620); - radius0 200; - p1 (-670 1300 0); - radius1 200; + cellSize 3.75; + type cone; + p0 (-650 1873 -620); + radius0 200; + p1 (-670 1300 0); + radius1 200; } tail { - cellSize 3.75; - type box; - centre (500 500 150); - lengthX 100; - lengthY 150; - lengthZ 200; + cellSize 3.75; + type box; + centre (500 500 150); + lengthX 100; + lengthY 150; + lengthZ 200; } insideTheBody { - cellSize 3.75; - type sphere; - centre (0 700 0); - radius 50; + cellSize 3.75; + type sphere; + centre (0 700 0); + radius 50; } muzzlePiercing { - cellSize 3.75; - type line; - p0 (-750 1000 450); - p1 (-750 1500 450); + cellSize 3.75; + type line; + p0 (-750 1000 450); + p1 (-750 1500 450); } ); diff --git a/tutorials/cutCubeOctree/system/meshDict b/tutorials/cutCubeOctree/system/meshDict index b5a56136..91a4b700 100755 --- a/tutorials/cutCubeOctree/system/meshDict +++ b/tutorials/cutCubeOctree/system/meshDict @@ -44,5 +44,5 @@ patch0007 0.05 ); internalVertex (0.05 0.05 0.05); - + // ************************************************************************* // diff --git a/tutorials/intakePortOctree/system/meshDict b/tutorials/intakePortOctree/system/meshDict index b54a67d8..f1f46171 100755 --- a/tutorials/intakePortOctree/system/meshDict +++ b/tutorials/intakePortOctree/system/meshDict @@ -41,14 +41,14 @@ internalVertex (20.0 -155.0 54); patchCellSize 8 ( - patch001 0.625 - patch002 0.625 - patch003 0.625 - patch004 0.625 - patch005 0.625 - patch006 0.625 - patch007 0.625 - patch008 0.625 + patch001 0.625 + patch002 0.625 + patch003 0.625 + patch004 0.625 + patch005 0.625 + patch006 0.625 + patch007 0.625 + patch008 0.625 ); - + // ************************************************************************* // diff --git a/tutorials/sBendOctree/system/meshDict b/tutorials/sBendOctree/system/meshDict index 16a02393..04c4566c 100755 --- a/tutorials/sBendOctree/system/meshDict +++ b/tutorials/sBendOctree/system/meshDict @@ -39,8 +39,8 @@ minCellSize 0.05; patchCellSize 2 ( - walls 0.025 - walls1 0.025 + walls 0.025 + walls1 0.025 ); - + // ************************************************************************* // diff --git a/tutorials/sawOctree/system/meshDict b/tutorials/sawOctree/system/meshDict index 87f3f69f..2411108b 100755 --- a/tutorials/sawOctree/system/meshDict +++ b/tutorials/sawOctree/system/meshDict @@ -41,8 +41,8 @@ internalVertex (0.0 1.0 -0.25); patchCellSize 2 ( - walls 0.05 - walls1 0.05 + walls 0.05 + walls1 0.05 ); - */ + */ // ************************************************************************* // diff --git a/tutorials/socketOctree/system/meshDict b/tutorials/socketOctree/system/meshDict index e9ec4e64..40dd95c7 100755 --- a/tutorials/socketOctree/system/meshDict +++ b/tutorials/socketOctree/system/meshDict @@ -41,9 +41,9 @@ internalVertex (0.0 1.0 -0.25); patchCellSize 2 ( - walls 0.05 - walls1 0.05 + walls 0.05 + walls1 0.05 ); */ - + // ************************************************************************* // diff --git a/utilities/FLMAToSurface/FLMAToSurface.C b/utilities/FLMAToSurface/FLMAToSurface.C index 584efa4a..cc7d6f97 100644 --- a/utilities/FLMAToSurface/FLMAToSurface.C +++ b/utilities/FLMAToSurface/FLMAToSurface.C @@ -23,7 +23,7 @@ License Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Description - Reads the AVL's surface mesh + Reads the AVL's surface mesh \*---------------------------------------------------------------------------*/ @@ -42,129 +42,129 @@ using namespace Foam; int main(int argc, char *argv[]) { - argList::noParallel(); + argList::noParallel(); argList::validArgs.clear(); argList::validArgs.append("input surface file"); argList::validArgs.append("output surface file"); - argList::validArgs.append("subset file name"); + argList::validArgs.append("subset file name"); argList args(argc, argv); fileName inFileName(args.args()[1]); fileName outFileName(args.args()[2]); - fileName subsetFileName(args.args()[3]); - - if( inFileName.ext() != "flma" ) - { - Info << "Cannot convert this mesh" << endl; - return 0; - } - - label counter; - - IFstream inFile(inFileName); - - inFile >> counter; - - //- read vertices - pointField points(counter); - for(label pointI=0;pointI<counter;++pointI) - { - point p; - inFile >> p.x(); - inFile >> p.y(); - inFile >> p.z(); - - points[pointI] = p; - } - - //- read facets - inFile >> counter; - triFaceList triangles(counter); - forAll(triangles, triI) - { - inFile >> counter; - - if( counter != 3 ) - { - Info << "Facet " << triI << " is not a triangle!!" << endl; - Warning << "Cannot convert this surface!" << endl; - return 0; - } - - for(label j=0;j<3;++j) - inFile >> triangles[triI][2-j]; - } - - triSurface ts(triangles, points); - ts.write(outFileName); - - //- read cell types - inFile >> counter; - forAll(triangles, triI) - inFile >> counter; - - //- start reading selections - std::map<word, labelListPMG> subsets; - inFile >> counter; - for(label selI=0;selI<counter;++selI) - { - //- read selection name - word selName; - inFile >> selName; - - //- read selection type - label selType; - inFile >> selType; - - //- read selection entries - label size; - inFile >> size; - labelListPMG entries(size); - for(label i=0;i<size;++i) - inFile >> entries[i]; - - //- store cell selections - if( selType == 2 ) - { - Info << "Adding subset " << selName << endl; - subsets.insert(std::pair<word, labelListPMG>(selName, entries)); - } - } - - OFstream outFile(subsetFileName); - - std::map<word, labelListPMG>::const_iterator iter; - counter = 0; - for(iter=subsets.begin();iter!=subsets.end();++iter) - ++counter; - - outFile << counter << nl; - for(iter=subsets.begin();iter!=subsets.end();++iter) - { - outFile << iter->first << nl; - outFile << iter->second << nl; - } - -/* for(iter=subsets.begin();iter!=subsets.end();++iter) - { - labelList faceMap, pointMap; - boolList useTri(triangles.size(), false); - - const word& sName = iter->first; - const labelListPMG& elmts = iter->second; - - forAll(elmts, elI) - useTri[elmts[elI]] = true; - - faceMap.setSize(elmts.size()); - pointMap.setSize(elmts.size()); - - triSurface subSurface = ts.subsetMesh(useTri, pointMap, faceMap); - - subSurface.write(sName+".stl"); - } -*/ + fileName subsetFileName(args.args()[3]); + + if( inFileName.ext() != "flma" ) + { + Info << "Cannot convert this mesh" << endl; + return 0; + } + + label counter; + + IFstream inFile(inFileName); + + inFile >> counter; + + //- read vertices + pointField points(counter); + for(label pointI=0;pointI<counter;++pointI) + { + point p; + inFile >> p.x(); + inFile >> p.y(); + inFile >> p.z(); + + points[pointI] = p; + } + + //- read facets + inFile >> counter; + triFaceList triangles(counter); + forAll(triangles, triI) + { + inFile >> counter; + + if( counter != 3 ) + { + Info << "Facet " << triI << " is not a triangle!!" << endl; + Warning << "Cannot convert this surface!" << endl; + return 0; + } + + for(label j=0;j<3;++j) + inFile >> triangles[triI][2-j]; + } + + triSurface ts(triangles, points); + ts.write(outFileName); + + //- read cell types + inFile >> counter; + forAll(triangles, triI) + inFile >> counter; + + //- start reading selections + std::map<word, labelListPMG> subsets; + inFile >> counter; + for(label selI=0;selI<counter;++selI) + { + //- read selection name + word selName; + inFile >> selName; + + //- read selection type + label selType; + inFile >> selType; + + //- read selection entries + label size; + inFile >> size; + labelListPMG entries(size); + for(label i=0;i<size;++i) + inFile >> entries[i]; + + //- store cell selections + if( selType == 2 ) + { + Info << "Adding subset " << selName << endl; + subsets.insert(std::pair<word, labelListPMG>(selName, entries)); + } + } + + OFstream outFile(subsetFileName); + + std::map<word, labelListPMG>::const_iterator iter; + counter = 0; + for(iter=subsets.begin();iter!=subsets.end();++iter) + ++counter; + + outFile << counter << nl; + for(iter=subsets.begin();iter!=subsets.end();++iter) + { + outFile << iter->first << nl; + outFile << iter->second << nl; + } + +/* for(iter=subsets.begin();iter!=subsets.end();++iter) + { + labelList faceMap, pointMap; + boolList useTri(triangles.size(), false); + + const word& sName = iter->first; + const labelListPMG& elmts = iter->second; + + forAll(elmts, elI) + useTri[elmts[elI]] = true; + + faceMap.setSize(elmts.size()); + pointMap.setSize(elmts.size()); + + triSurface subSurface = ts.subsetMesh(useTri, pointMap, faceMap); + + subSurface.write(sName+".stl"); + } +*/ Info << "End\n" << endl; return 0; } diff --git a/utilities/FPMAToMesh/FPMAToMesh.C b/utilities/FPMAToMesh/FPMAToMesh.C index 4acd3d6b..073ad9f4 100644 --- a/utilities/FPMAToMesh/FPMAToMesh.C +++ b/utilities/FPMAToMesh/FPMAToMesh.C @@ -23,7 +23,7 @@ License Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Description - Writes the mesh in fpma format readable by AVL's CfdWM + Writes the mesh in fpma format readable by AVL's CfdWM \*---------------------------------------------------------------------------*/ @@ -64,12 +64,12 @@ int main(int argc, char *argv[]) points.setSize(counter); forAll(points, pointI) { - point p; - file >> p.x(); - file >> p.y(); - file >> p.z(); - - points[pointI] = p; + point p; + file >> p.x(); + file >> p.y(); + file >> p.z(); + + points[pointI] = p; } //- read the number of faces @@ -82,14 +82,14 @@ int main(int argc, char *argv[]) forAll(faces, faceI) { file >> counter; - - face f; - f.setSize(counter); - - forAll(f, pI) - file >> f[pI]; - - faces[faceI] = f.reverseFace(); + + face f; + f.setSize(counter); + + forAll(f, pI) + file >> f[pI]; + + faces[faceI] = f.reverseFace(); } //- read the number of cells @@ -101,14 +101,14 @@ int main(int argc, char *argv[]) forAll(cells, cellI) { - file >> counter; - - cell& c = cells[cellI]; - - c.setSize(counter); - - forAll(c, fI) - file >> c[fI]; + file >> counter; + + cell& c = cells[cellI]; + + c.setSize(counter); + + forAll(c, fI) + file >> c[fI]; } //- read selections @@ -119,60 +119,60 @@ int main(int argc, char *argv[]) for(label setI=0;setI<counter;++setI) { - word sName; - file >> sName; - - label type; - file >> type; - - label nEntries; - file >> nEntries; - - switch( type ) - { - case 3: - { - //- face selection - const label id = pmg.addFaceSubset(sName); - - patchNames.setSize(patchNames.size()+1); - patchNames[patchNames.size()-1] = sName; - subsetToPatch.insert(id, patchNames.size()-1); - - Info << "Reading face selection " << sName << endl; - - for(label i=0;i<nEntries;++i) - { - label entryI; - file >> entryI; - pmg.addFaceToSubset(id, entryI); - } - } break; - case 2: - { - //- cell selection - const label id = pmg.addCellSubset(sName); - - for(label i=0;i<nEntries;++i) - { - label entryI; - file >> entryI; - pmg.addCellToSubset(id, entryI); - } - } break; - case 1: - { - //- node selection - const label id = pmg.addPointSubset(sName); - - for(label i=0;i<nEntries;++i) - { - label entryI; - file >> entryI; - pmg.addPointToSubset(id, entryI); - } - } break; - }; + word sName; + file >> sName; + + label type; + file >> type; + + label nEntries; + file >> nEntries; + + switch( type ) + { + case 3: + { + //- face selection + const label id = pmg.addFaceSubset(sName); + + patchNames.setSize(patchNames.size()+1); + patchNames[patchNames.size()-1] = sName; + subsetToPatch.insert(id, patchNames.size()-1); + + Info << "Reading face selection " << sName << endl; + + for(label i=0;i<nEntries;++i) + { + label entryI; + file >> entryI; + pmg.addFaceToSubset(id, entryI); + } + } break; + case 2: + { + //- cell selection + const label id = pmg.addCellSubset(sName); + + for(label i=0;i<nEntries;++i) + { + label entryI; + file >> entryI; + pmg.addCellToSubset(id, entryI); + } + } break; + case 1: + { + //- node selection + const label id = pmg.addPointSubset(sName); + + for(label i=0;i<nEntries;++i) + { + label entryI; + file >> entryI; + pmg.addPointToSubset(id, entryI); + } + } break; + }; } //- create patches from face selections @@ -186,26 +186,26 @@ int main(int argc, char *argv[]) forAll(faceSubsets, setI) { - labelListPMG setFaces; - pmg.facesInSubset(faceSubsets[setI], setFaces); - - forAll(setFaces, i) - { - boundaryFaces.appendList(faces[setFaces[i]]); - boundaryOwner.append(owner[setFaces[i]]); - boundaryPatches.append(subsetToPatch[faceSubsets[setI]]); - } - - pmg.removeFaceSubset(faceSubsets[setI]); + labelListPMG setFaces; + pmg.facesInSubset(faceSubsets[setI], setFaces); + + forAll(setFaces, i) + { + boundaryFaces.appendList(faces[setFaces[i]]); + boundaryOwner.append(owner[setFaces[i]]); + boundaryPatches.append(subsetToPatch[faceSubsets[setI]]); + } + + pmg.removeFaceSubset(faceSubsets[setI]); } meshModifier.reorderBoundaryFaces(); meshModifier.replaceBoundary ( - patchNames, - boundaryFaces, - boundaryOwner, - boundaryPatches + patchNames, + boundaryFaces, + boundaryOwner, + boundaryPatches ); pmg.write(); diff --git a/utilities/FPMAToMesh/Make/options b/utilities/FPMAToMesh/Make/options index d357c996..8ef7ed77 100644 --- a/utilities/FPMAToMesh/Make/options +++ b/utilities/FPMAToMesh/Make/options @@ -1,5 +1,5 @@ EXE_INC = -I../../meshLibrary/lnInclude \ - -I$(LIB_SRC)/meshTools/lnInclude + -I$(LIB_SRC)/meshTools/lnInclude EXE_LIBS = -lMeshLibrary \ - -lmeshTools + -lmeshTools diff --git a/utilities/cellSetIntersectedByPlane/cellSetIntersectedByPlane.C b/utilities/cellSetIntersectedByPlane/cellSetIntersectedByPlane.C index b5d6ff65..04e22d74 100644 --- a/utilities/cellSetIntersectedByPlane/cellSetIntersectedByPlane.C +++ b/utilities/cellSetIntersectedByPlane/cellSetIntersectedByPlane.C @@ -45,78 +45,78 @@ using namespace Foam; int main(int argc, char *argv[]) { //argList::validArgs.append("cellSet"); - + # include "setRootCase.H" # include "createTime.H" - - Info<< "Reading mesh for time = " << runTime.value() << endl; - polyMesh mesh(runTime); - - cellSet cs - ( - IOobject - ( - "c0", - runTime.timeName(), - "polyMesh/sets", - runTime, - IOobject::NO_READ - ) - ); - - vector n, origin; - Info << "Normal x coord" ; - cin >> n.x(); - Info << endl << "Normal y coord "; - cin >> n.y(); - Info << endl << "Normal z coord"; - cin >> n.z(); - - Info << "Origin x coord" ; - cin >> origin.x(); - Info << endl << "Origin y coord "; - cin >> origin.y(); - Info << endl << "Origin z coord"; - cin >> origin.z(); + + Info<< "Reading mesh for time = " << runTime.value() << endl; + polyMesh mesh(runTime); + + cellSet cs + ( + IOobject + ( + "c0", + runTime.timeName(), + "polyMesh/sets", + runTime, + IOobject::NO_READ + ) + ); + + vector n, origin; + Info << "Normal x coord" ; + cin >> n.x(); + Info << endl << "Normal y coord "; + cin >> n.y(); + Info << endl << "Normal z coord"; + cin >> n.z(); + + Info << "Origin x coord" ; + cin >> origin.x(); + Info << endl << "Origin y coord "; + cin >> origin.y(); + Info << endl << "Origin z coord"; + cin >> origin.z(); //Info<< "Reading cell set from " << setName << endl << endl; - //cellSet cs(mesh, setName); - - //- printCells contained in the cellSet - const pointField& points = mesh.points(); - const edgeList& edges = mesh.edges(); - const labelListList& edgeCells = mesh.edgeCells(); - - forAll(edges, eI) - { - const edge& e = edges[eI]; - bool visibleS, visibleE; - if( ((points[e.start()] - origin) & n) >= 0.0 ) - { - visibleS = true; - } - else - { - visibleS = false; - } - - if( ((points[e.end()] - origin) & n) >= 0.0 ) - { - visibleE = true; - } - else - { - visibleE = false; - } - - if( visibleS ^ visibleE ) - { - forAll(edgeCells[eI], ecI) - cs.insert(edgeCells[eI][ecI]); - } - } - - cs.write(); + //cellSet cs(mesh, setName); + + //- printCells contained in the cellSet + const pointField& points = mesh.points(); + const edgeList& edges = mesh.edges(); + const labelListList& edgeCells = mesh.edgeCells(); + + forAll(edges, eI) + { + const edge& e = edges[eI]; + bool visibleS, visibleE; + if( ((points[e.start()] - origin) & n) >= 0.0 ) + { + visibleS = true; + } + else + { + visibleS = false; + } + + if( ((points[e.end()] - origin) & n) >= 0.0 ) + { + visibleE = true; + } + else + { + visibleE = false; + } + + if( visibleS ^ visibleE ) + { + forAll(edgeCells[eI], ecI) + cs.insert(edgeCells[eI][ecI]); + } + } + + cs.write(); Info << "End\n" << endl; return 0; diff --git a/utilities/meshToFPMA/Make/options b/utilities/meshToFPMA/Make/options index d357c996..8ef7ed77 100644 --- a/utilities/meshToFPMA/Make/options +++ b/utilities/meshToFPMA/Make/options @@ -1,5 +1,5 @@ EXE_INC = -I../../meshLibrary/lnInclude \ - -I$(LIB_SRC)/meshTools/lnInclude + -I$(LIB_SRC)/meshTools/lnInclude EXE_LIBS = -lMeshLibrary \ - -lmeshTools + -lmeshTools diff --git a/utilities/meshToFPMA/meshToFPMA.C b/utilities/meshToFPMA/meshToFPMA.C index 583188be..9208de10 100644 --- a/utilities/meshToFPMA/meshToFPMA.C +++ b/utilities/meshToFPMA/meshToFPMA.C @@ -23,7 +23,7 @@ License Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Description - Writes the mesh in fpma format readable by AVL's CfdWM + Writes the mesh in fpma format readable by AVL's CfdWM \*---------------------------------------------------------------------------*/ @@ -41,7 +41,7 @@ int main(int argc, char *argv[]) # include "setRootCase.H" # include "createTime.H" - polyMeshGen pmg(runTime); + polyMeshGen pmg(runTime); pmg.read(); if( Pstream::parRun() ) @@ -49,9 +49,9 @@ int main(int argc, char *argv[]) polyMeshGenModifier(pmg).addBufferCells(); createFIRESelections(pmg); } - - writeMeshFPMA(pmg, "convertedMesh"); - + + writeMeshFPMA(pmg, "convertedMesh"); + Info << "End\n" << endl; return 0; } diff --git a/utilities/patchesToSubsets/patchesToSubsets.C b/utilities/patchesToSubsets/patchesToSubsets.C index cb514fa3..6c33a763 100644 --- a/utilities/patchesToSubsets/patchesToSubsets.C +++ b/utilities/patchesToSubsets/patchesToSubsets.C @@ -23,7 +23,7 @@ License Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Description - Reads the AVL's surface mesh + Reads the AVL's surface mesh \*---------------------------------------------------------------------------*/ @@ -42,18 +42,18 @@ using namespace Foam; int main(int argc, char *argv[]) { - argList::noParallel(); + argList::noParallel(); argList::validArgs.clear(); argList::validArgs.append("input surface file"); - argList::validArgs.append("output subset file"); + argList::validArgs.append("output subset file"); argList args(argc, argv); fileName inFileName(args.args()[1]); - fileName subsetFileName(args.args()[2]); - - triSurf origSurf(inFileName); - + fileName subsetFileName(args.args()[2]); + + triSurf origSurf(inFileName); + wordList patchNames(origSurf.patches().size()); forAll(origSurf.patches(), patchI) patchNames[patchI] = origSurf.patches()[patchI].name(); @@ -69,9 +69,9 @@ int main(int argc, char *argv[]) origSurf.addFacetsToSubset(patchNames[patchI], subsetFacets); } - - origSurf.writeFaceSubsets(subsetFileName); - + + origSurf.writeFaceSubsets(subsetFileName); + Info << "End\n" << endl; return 0; diff --git a/utilities/plyToSurface/Make/options b/utilities/plyToSurface/Make/options index 7e13b026..8dcbb874 100644 --- a/utilities/plyToSurface/Make/options +++ b/utilities/plyToSurface/Make/options @@ -1,5 +1,5 @@ EXE_INC = -I$(FOAM_USER_LIB)/pMesh3D/pMeshLibrary/lnInclude \ - -I$(LIB_SRC)/triSurface/lnInclude + -I$(LIB_SRC)/triSurface/lnInclude EXE_LIBS = -ltriSurface -lmeshTools -lMeshLibrary diff --git a/utilities/plyToSurface/plyToSurface.C b/utilities/plyToSurface/plyToSurface.C index b4c6ac36..ac081576 100644 --- a/utilities/plyToSurface/plyToSurface.C +++ b/utilities/plyToSurface/plyToSurface.C @@ -23,7 +23,7 @@ License Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Description - Converts STAR CD surfaces into stl or other formats + Converts STAR CD surfaces into stl or other formats \*---------------------------------------------------------------------------*/ @@ -61,56 +61,56 @@ int main(int argc, char *argv[]) } IFstream surfFile(inFileName); - - //- parse the number of vertices - token t; - do - { - surfFile >> t; - } while( !t.isLabel() ); - pointField points(t.labelToken()); - Info << "Surface has " << points.size() << " points" << endl; - - //- find the number of elements - do - { - surfFile >> t; - } while( !t.isLabel() ); + + //- parse the number of vertices + token t; + do + { + surfFile >> t; + } while( !t.isLabel() ); + pointField points(t.labelToken()); + Info << "Surface has " << points.size() << " points" << endl; + + //- find the number of elements + do + { + surfFile >> t; + } while( !t.isLabel() ); List<labelledTri> triFaces(t.labelToken()); - Info << "Surface has " << triFaces.size() << " facets" << endl; - - //- read vertices - do - { - surfFile >> t; - } while( t.isWord() && (t.wordToken() != "end_header") ); - - forAll(points, pointI) - { - point& p = points[pointI]; - - surfFile >> p.x(); - surfFile >> p.y(); - surfFile >> p.z(); - } - - //- read triangles - forAll(triFaces, triI) - { - label nPts; - surfFile >> nPts; - if( nPts != 3 ) - { - Info << "Facet " << triI << " is not a triangle!!" << endl; - Warning << "Cannot convert this surface!" << endl; - return 0; - } - - for(label i=0;i<nPts;++i) - surfFile >> triFaces[triI][i]; - - triFaces[triI].region() = 0; - } + Info << "Surface has " << triFaces.size() << " facets" << endl; + + //- read vertices + do + { + surfFile >> t; + } while( t.isWord() && (t.wordToken() != "end_header") ); + + forAll(points, pointI) + { + point& p = points[pointI]; + + surfFile >> p.x(); + surfFile >> p.y(); + surfFile >> p.z(); + } + + //- read triangles + forAll(triFaces, triI) + { + label nPts; + surfFile >> nPts; + if( nPts != 3 ) + { + Info << "Facet " << triI << " is not a triangle!!" << endl; + Warning << "Cannot convert this surface!" << endl; + return 0; + } + + for(label i=0;i<nPts;++i) + surfFile >> triFaces[triI][i]; + + triFaces[triI].region() = 0; + } triSurface surf(triFaces, points); diff --git a/utilities/preparePar/preparePar.C b/utilities/preparePar/preparePar.C index 25510e46..c228cb42 100644 --- a/utilities/preparePar/preparePar.C +++ b/utilities/preparePar/preparePar.C @@ -46,10 +46,10 @@ int main(int argc, char *argv[]) { # include "setRootCase.H" # include "createTime.H" - - objectRegistry registry(runTime); - - IOdictionary meshDict + + objectRegistry registry(runTime); + + IOdictionary meshDict ( IOobject ( @@ -60,39 +60,39 @@ int main(int argc, char *argv[]) IOobject::NO_WRITE ) ); - - IOdictionary decomposeParDict - ( - IOobject - ( - "decomposeParDict", - registry.time().system(), + + IOdictionary decomposeParDict + ( + IOobject + ( + "decomposeParDict", + registry.time().system(), registry, IOobject::MUST_READ, IOobject::NO_WRITE ) ); - - const label nProcessors - ( - readLabel(decomposeParDict.lookup("numberOfSubdomains")) - ); - - for(label procI=0;procI<nProcessors;++procI) - { - fileName file("processor"); - std::ostringstream ss; - ss << procI; - file += ss.str(); - Info << "Creating " << file << endl; - - //- create a directory for processor data - mkDir(runTime.path()/file); - - //- copy the contents of the const directory into processor* - cp(registry.path()/"constant", runTime.path()/file); - } - + + const label nProcessors + ( + readLabel(decomposeParDict.lookup("numberOfSubdomains")) + ); + + for(label procI=0;procI<nProcessors;++procI) + { + fileName file("processor"); + std::ostringstream ss; + ss << procI; + file += ss.str(); + Info << "Creating " << file << endl; + + //- create a directory for processor data + mkDir(runTime.path()/file); + + //- copy the contents of the const directory into processor* + cp(registry.path()/"constant", runTime.path()/file); + } + Info << "End\n" << endl; return 0; } diff --git a/utilities/printCellsInSet/printCellsInSet.C b/utilities/printCellsInSet/printCellsInSet.C index 951fad65..e6b9f8da 100644 --- a/utilities/printCellsInSet/printCellsInSet.C +++ b/utilities/printCellsInSet/printCellsInSet.C @@ -45,33 +45,33 @@ using namespace Foam; int main(int argc, char *argv[]) { argList::validArgs.append("cellSet"); - + # include "setRootCase.H" # include "createTime.H" - - Info<< "Reading mesh for time = " << runTime.value() << endl; - polyMesh mesh(runTime); + + Info<< "Reading mesh for time = " << runTime.value() << endl; + polyMesh mesh(runTime); word setName(args.args()[3]); Info<< "Reading cell set from " << setName << endl << endl; - cellSet cs(mesh, setName); - - //- printCells contained in the cellSet - const cellList& cells = mesh.cells(); - const faceList& faces = mesh.faces(); - - forAll(cells, cellI) - if( cs.found(cellI) ) - { - const cell& c = cells[cellI]; - Info << "Cell " << cellI << " consists of faces " << c << endl; - - forAll(c, fI) - Info << "Face " << c[fI] << " is " << faces[c[fI]] << endl; - - Info << nl << endl; - } + cellSet cs(mesh, setName); + + //- printCells contained in the cellSet + const cellList& cells = mesh.cells(); + const faceList& faces = mesh.faces(); + + forAll(cells, cellI) + if( cs.found(cellI) ) + { + const cell& c = cells[cellI]; + Info << "Cell " << cellI << " consists of faces " << c << endl; + + forAll(c, fI) + Info << "Face " << c[fI] << " is " << faces[c[fI]] << endl; + + Info << nl << endl; + } Info << "End\n" << endl; return 0; diff --git a/utilities/starSurfaceToSTL/Make/options b/utilities/starSurfaceToSTL/Make/options index 7e13b026..8dcbb874 100644 --- a/utilities/starSurfaceToSTL/Make/options +++ b/utilities/starSurfaceToSTL/Make/options @@ -1,5 +1,5 @@ EXE_INC = -I$(FOAM_USER_LIB)/pMesh3D/pMeshLibrary/lnInclude \ - -I$(LIB_SRC)/triSurface/lnInclude + -I$(LIB_SRC)/triSurface/lnInclude EXE_LIBS = -ltriSurface -lmeshTools -lMeshLibrary diff --git a/utilities/starSurfaceToSTL/starSurfaceToSTL.C b/utilities/starSurfaceToSTL/starSurfaceToSTL.C index 5f48a9fa..9c93fe01 100644 --- a/utilities/starSurfaceToSTL/starSurfaceToSTL.C +++ b/utilities/starSurfaceToSTL/starSurfaceToSTL.C @@ -23,7 +23,7 @@ License Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Description - Converts STAR CD surfaces into stl or other formats + Converts STAR CD surfaces into stl or other formats \*---------------------------------------------------------------------------*/ diff --git a/utilities/subsetToPatch/subsetToPatch.C b/utilities/subsetToPatch/subsetToPatch.C index ee2d3c7a..b789ae8e 100644 --- a/utilities/subsetToPatch/subsetToPatch.C +++ b/utilities/subsetToPatch/subsetToPatch.C @@ -23,7 +23,7 @@ License Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Description - Creates surface patches from surface subsets + Creates surface patches from surface subsets \*---------------------------------------------------------------------------*/ @@ -65,7 +65,7 @@ triSurf* makePatchFromSubset origSurf.facesInSubset(subsetNames[subsetI]); const label regionI = origSurf.patches().size() + subsetI; - + forAll(subsetFaces, fI) { newTriangles[subsetFaces[fI]].region() = regionI; @@ -106,7 +106,7 @@ triSurf* makePatchFromSubset //- copy subsets for the new surface DynList<word> existingSubsets; origSurf.existingFaceSubsets(existingSubsets); - + std::map<word, labelListPMG> newSubsets; forAll(existingSubsets, sI) newSubsets.insert @@ -121,7 +121,7 @@ triSurf* makePatchFromSubset //- delete subsets converted to patches forAll(subsetNames, subsetI) newSubsets.erase(subsetNames[subsetI]); - + triSurf* newSurfPtr = new triSurf(newTriangles, newPatches, origSurf.points(), newSubsets); @@ -142,15 +142,15 @@ int main(int argc, char *argv[]) fileName inFileName(args.args()[1]); fileName subsetFileName(args.args()[2]); word subsetName(args.args()[3]); - + triSurf* origSurfPtr = new triSurf(inFileName); origSurfPtr->readFaceSubsets(subsetFileName); - + DynList<word> subsetNames; if( !origSurfPtr->doesFaceSubsetExist(subsetName) ) { Warning << "Subset " << subsetName - << " checking subsets containing this string!" << endl; + << " checking subsets containing this string!" << endl; DynList<word> existingSubsets; origSurfPtr->existingFaceSubsets(existingSubsets); @@ -178,7 +178,7 @@ int main(int argc, char *argv[]) newSurfPtr->write(inFileName, false); newSurfPtr->writeFaceSubsets(subsetFileName); deleteDemandDrivenData(newSurfPtr); - + Info << "End\n" << endl; return 0; } diff --git a/utilities/surfaceClosedness/Make/options b/utilities/surfaceClosedness/Make/options index 7e444b99..16aa0b05 100644 --- a/utilities/surfaceClosedness/Make/options +++ b/utilities/surfaceClosedness/Make/options @@ -1,4 +1,4 @@ EXE_INC = -I$(FOAM_USER_LIB)/pMesh3D/pMeshLibrary/lnInclude \ - -I$(LIB_SRC)/triSurface/lnInclude + -I$(LIB_SRC)/triSurface/lnInclude EXE_LIBS = -ltriSurface -lmeshTools -lMeshLibrary diff --git a/utilities/surfaceClosedness/surfaceClosedness.C b/utilities/surfaceClosedness/surfaceClosedness.C index d6615d5a..5ccd4dcb 100644 --- a/utilities/surfaceClosedness/surfaceClosedness.C +++ b/utilities/surfaceClosedness/surfaceClosedness.C @@ -23,7 +23,7 @@ License Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Description - Checks if the surface is geometrically closed + Checks if the surface is geometrically closed \*---------------------------------------------------------------------------*/ diff --git a/utilities/surfaceFeatureEdges/Make/options b/utilities/surfaceFeatureEdges/Make/options index aca3590d..3ccb2d18 100644 --- a/utilities/surfaceFeatureEdges/Make/options +++ b/utilities/surfaceFeatureEdges/Make/options @@ -1,5 +1,5 @@ EXE_INC = -I../../meshLibrary/lnInclude \ - -I$(LIB_SRC)/triSurface/lnInclude \ - -I$(LIB_SRC)/meshTools/lnInclude + -I$(LIB_SRC)/triSurface/lnInclude \ + -I$(LIB_SRC)/meshTools/lnInclude EXE_LIBS = -ltriSurface -lMeshLibrary -lmeshTools diff --git a/utilities/surfaceFeatureEdges/surfaceFeatureEdges.C b/utilities/surfaceFeatureEdges/surfaceFeatureEdges.C index c3dbcc04..ae621611 100644 --- a/utilities/surfaceFeatureEdges/surfaceFeatureEdges.C +++ b/utilities/surfaceFeatureEdges/surfaceFeatureEdges.C @@ -23,7 +23,7 @@ License Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Description - Finds feature edges and corners of a triangulated surface + Finds feature edges and corners of a triangulated surface \*---------------------------------------------------------------------------*/ @@ -48,8 +48,8 @@ int main(int argc, char *argv[]) argList::validArgs.clear(); argList::validArgs.append("input surface file"); argList::validArgs.append("output surface file"); - argList::validOptions.insert("subsets", "fileName"); - argList::validOptions.insert("angle", "scalar"); + argList::validOptions.insert("subsets", "fileName"); + argList::validOptions.insert("angle", "scalar"); argList args(argc, argv); fileName inFileName(args.args()[1]); diff --git a/utilities/surfaceGenerateBoundingBox/Make/options b/utilities/surfaceGenerateBoundingBox/Make/options index aca3590d..3ccb2d18 100644 --- a/utilities/surfaceGenerateBoundingBox/Make/options +++ b/utilities/surfaceGenerateBoundingBox/Make/options @@ -1,5 +1,5 @@ EXE_INC = -I../../meshLibrary/lnInclude \ - -I$(LIB_SRC)/triSurface/lnInclude \ - -I$(LIB_SRC)/meshTools/lnInclude + -I$(LIB_SRC)/triSurface/lnInclude \ + -I$(LIB_SRC)/meshTools/lnInclude EXE_LIBS = -ltriSurface -lMeshLibrary -lmeshTools diff --git a/utilities/surfaceGenerateBoundingBox/surfaceGenerateBoundingBox.C b/utilities/surfaceGenerateBoundingBox/surfaceGenerateBoundingBox.C index 27a1a668..fca5fcfc 100644 --- a/utilities/surfaceGenerateBoundingBox/surfaceGenerateBoundingBox.C +++ b/utilities/surfaceGenerateBoundingBox/surfaceGenerateBoundingBox.C @@ -23,7 +23,7 @@ License Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Description - Finds feature edges and corners of a triangulated surface + Finds feature edges and corners of a triangulated surface \*---------------------------------------------------------------------------*/ diff --git a/utilities/surfaceOutwardOrientation/Make/options b/utilities/surfaceOutwardOrientation/Make/options index 168df83b..5899a719 100644 --- a/utilities/surfaceOutwardOrientation/Make/options +++ b/utilities/surfaceOutwardOrientation/Make/options @@ -1,5 +1,5 @@ EXE_INC = -I$(FOAM_USER_LIB)/pMesh3D/pMeshLibrary/lnInclude \ - -I$(LIB_SRC)/triSurface/lnInclude \ - -I$(LIB_SRC)/meshTools/lnInclude + -I$(LIB_SRC)/triSurface/lnInclude \ + -I$(LIB_SRC)/meshTools/lnInclude EXE_LIBS = -ltriSurface -lmeshTools $(FOAM_USER_LIBBIN)/libpMesh.so diff --git a/utilities/surfaceOutwardOrientation/surfaceOutwardOrientation.C b/utilities/surfaceOutwardOrientation/surfaceOutwardOrientation.C index f0383d8a..bb0a5ee6 100644 --- a/utilities/surfaceOutwardOrientation/surfaceOutwardOrientation.C +++ b/utilities/surfaceOutwardOrientation/surfaceOutwardOrientation.C @@ -23,7 +23,7 @@ License Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Description - Ensures outward orientation of the triangulated surface + Ensures outward orientation of the triangulated surface \*---------------------------------------------------------------------------*/ diff --git a/utilities/surfaceRefine/Make/options b/utilities/surfaceRefine/Make/options index 7e444b99..16aa0b05 100644 --- a/utilities/surfaceRefine/Make/options +++ b/utilities/surfaceRefine/Make/options @@ -1,4 +1,4 @@ EXE_INC = -I$(FOAM_USER_LIB)/pMesh3D/pMeshLibrary/lnInclude \ - -I$(LIB_SRC)/triSurface/lnInclude + -I$(LIB_SRC)/triSurface/lnInclude EXE_LIBS = -ltriSurface -lmeshTools -lMeshLibrary diff --git a/utilities/surfaceRefine/surfaceRefine.C b/utilities/surfaceRefine/surfaceRefine.C index cb6c4658..6ab9a086 100644 --- a/utilities/surfaceRefine/surfaceRefine.C +++ b/utilities/surfaceRefine/surfaceRefine.C @@ -23,7 +23,7 @@ License Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Description - Refinement of triangulated surface + Refinement of triangulated surface \*---------------------------------------------------------------------------*/ diff --git a/utilities/surfaceStitch/Make/options b/utilities/surfaceStitch/Make/options index 39f23d7a..062f6d71 100644 --- a/utilities/surfaceStitch/Make/options +++ b/utilities/surfaceStitch/Make/options @@ -1,4 +1,4 @@ EXE_INC = -I../../meshLibrary/lnInclude \ - -I$(LIB_SRC)/triSurface/lnInclude + -I$(LIB_SRC)/triSurface/lnInclude EXE_LIBS = -ltriSurface -lmeshTools -lMeshLibrary diff --git a/utilities/surfaceStitch/surfaceStitch.C b/utilities/surfaceStitch/surfaceStitch.C index b767885e..c3e52e77 100644 --- a/utilities/surfaceStitch/surfaceStitch.C +++ b/utilities/surfaceStitch/surfaceStitch.C @@ -23,7 +23,7 @@ License Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Description - Closing holes in the triangulated surface + Closing holes in the triangulated surface \*---------------------------------------------------------------------------*/ @@ -67,116 +67,116 @@ int main(int argc, char *argv[]) triSurface& surf = *ts; - const pointField& points = surf.localPoints(); + const pointField& points = surf.localPoints(); const labelListList& eFaces = surf.edgeFaces(); const edgeList& edges = surf.edges(); const labelListList& pEdges = surf.pointEdges(); - const labelListList& pFaces = surf.pointFaces(); + const labelListList& pFaces = surf.pointFaces(); - //- mark the open edges + //- mark the open edges boolList problemEdges(eFaces.size(), false); forAll(eFaces, eI) - { + { if( eFaces[eI].size() < 2 ) problemEdges[eI] = true; - } - - //- find the vertices which have exactly two open edges attached to them - //- create triangles which fit best into their surrounding - forAll(pEdges, pointI) - { - const labelList& pe = pEdges[pointI]; - - DynList<label> openEdges; - forAll(pe, peI) - { - if( problemEdges[pe[peI]] ) - openEdges.append(pe[peI]); - } - - //- skip vertices attached to more than two open edges - if( openEdges.size() != 2 ) - continue; - - //- skip vertices attached to only one triangle - if( pFaces[pointI].size() == 1 ) - continue; - - const edge& e0 = edges[openEdges[0]]; - const edge& e1 = edges[openEdges[1]]; - - const labelledTri& t0 = surf[eFaces[openEdges[0]][0]]; - const labelledTri& t1 = surf[eFaces[openEdges[1]][0]]; - - labelledTri t; - t[0] = pointI; - if( e0.start() == pointI ) - { - t[1] = e1.otherVertex(pointI); - t[2] = e0.otherVertex(pointI); - t.region() = t0.region(); - } - else if( e1.start() == pointI ) - { - t[1] = e0.otherVertex(pointI); - t[2] = e1.otherVertex(pointI); - t.region() = t1.region(); - } - else - { - continue; - FatalError << "Strange" << exit(FatalError); - } - - Info << "Creating triangle for point " << pointI << endl; - Info << "triangle is " << t << endl; - - //- check dot product between the normals - vector n0 = t0.normal(points); - n0 /= mag(n0) + VSMALL; - - vector n1 = t1.normal(points); - n1 /= mag(n1) + VSMALL; - - vector n = t.normal(points); - n /= mag(n) + VSMALL; - - //- find the maximum dot product between the normals of - //- of existing triangles and the newly generated one - scalar q = (n & n0); - q = Foam::max(q, (n & n1)); - - if( q > 0.9 ) - { - createdTriangles.append(t); - ++counter; - - forAll(openEdges, i) - problemEdges[openEdges[i]] = false; - } - } - - if( createdTriangles.size() ) - { - List<labelledTri> newTriangles = surf.localFaces(); - - label nTriangles(newTriangles.size()); - newTriangles.setSize(nTriangles+createdTriangles.size()); - forAll(createdTriangles, i) - newTriangles[nTriangles++] = createdTriangles[i]; - - triSurface* newts = - new triSurface - ( - newTriangles, - surf.patches(), - surf.points() - ); - - deleteDemandDrivenData(ts); - ts = newts; - } + } + + //- find the vertices which have exactly two open edges attached to them + //- create triangles which fit best into their surrounding + forAll(pEdges, pointI) + { + const labelList& pe = pEdges[pointI]; + + DynList<label> openEdges; + forAll(pe, peI) + { + if( problemEdges[pe[peI]] ) + openEdges.append(pe[peI]); + } + + //- skip vertices attached to more than two open edges + if( openEdges.size() != 2 ) + continue; + + //- skip vertices attached to only one triangle + if( pFaces[pointI].size() == 1 ) + continue; + + const edge& e0 = edges[openEdges[0]]; + const edge& e1 = edges[openEdges[1]]; + + const labelledTri& t0 = surf[eFaces[openEdges[0]][0]]; + const labelledTri& t1 = surf[eFaces[openEdges[1]][0]]; + + labelledTri t; + t[0] = pointI; + if( e0.start() == pointI ) + { + t[1] = e1.otherVertex(pointI); + t[2] = e0.otherVertex(pointI); + t.region() = t0.region(); + } + else if( e1.start() == pointI ) + { + t[1] = e0.otherVertex(pointI); + t[2] = e1.otherVertex(pointI); + t.region() = t1.region(); + } + else + { + continue; + FatalError << "Strange" << exit(FatalError); + } + + Info << "Creating triangle for point " << pointI << endl; + Info << "triangle is " << t << endl; + + //- check dot product between the normals + vector n0 = t0.normal(points); + n0 /= mag(n0) + VSMALL; + + vector n1 = t1.normal(points); + n1 /= mag(n1) + VSMALL; + + vector n = t.normal(points); + n /= mag(n) + VSMALL; + + //- find the maximum dot product between the normals of + //- of existing triangles and the newly generated one + scalar q = (n & n0); + q = Foam::max(q, (n & n1)); + + if( q > 0.9 ) + { + createdTriangles.append(t); + ++counter; + + forAll(openEdges, i) + problemEdges[openEdges[i]] = false; + } + } + + if( createdTriangles.size() ) + { + List<labelledTri> newTriangles = surf.localFaces(); + + label nTriangles(newTriangles.size()); + newTriangles.setSize(nTriangles+createdTriangles.size()); + forAll(createdTriangles, i) + newTriangles[nTriangles++] = createdTriangles[i]; + + triSurface* newts = + new triSurface + ( + newTriangles, + surf.patches(), + surf.points() + ); + + deleteDemandDrivenData(ts); + ts = newts; + } } while( createdTriangles.size() ); -- GitLab