/*---------------------------------------------------------------------------*\ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation \\/ M anipulation | Copyright (C) 2015-2016 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. OpenFOAM is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. OpenFOAM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenFOAM. If not, see . Class Foam::meshRefinement Description Helper class which maintains intersections of (changing) mesh with (static) surfaces. Maintains - per face any intersections of the cc-cc segment with any of the surfaces SourceFiles meshRefinement.C meshRefinementBaffles.C meshRefinementGapRefine.C meshRefinementMerge.C meshRefinementProblemCells.C meshRefinementRefine.C \*---------------------------------------------------------------------------*/ #ifndef meshRefinement_H #define meshRefinement_H #include "hexRef8.H" #include "mapPolyMesh.H" #include "autoPtr.H" #include "labelPair.H" #include "indirectPrimitivePatch.H" #include "pointFieldsFwd.H" #include "Tuple2.H" #include "pointIndexHit.H" #include "wordPairHashTable.H" #include "surfaceZonesInfo.H" #include "volumeType.H" #include "DynamicField.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam { // Class forward declarations class fvMesh; class mapDistributePolyMesh; class decompositionMethod; class refinementSurfaces; class refinementFeatures; class shellSurfaces; class removeCells; class fvMeshDistribute; class removePoints; class localPointRegion; class snapParameters; /*---------------------------------------------------------------------------*\ Class meshRefinement Declaration \*---------------------------------------------------------------------------*/ class meshRefinement { public: // Public data types //- Enumeration for what to debug enum IOdebugType { IOMESH, //IOSCALARLEVELS, IOOBJINTERSECTIONS, IOFEATURESEEDS, IOATTRACTION, IOLAYERINFO }; static const NamedEnum IOdebugTypeNames; enum debugType { MESH = 1< IOoutputTypeNames; enum outputType { OUTPUTLAYERINFO = 1< IOwriteTypeNames; enum writeType { WRITEMESH = 1< faceToCoupledPatch_; //- User supplied face based data. List> userFaceData_; //- Meshed patches - are treated differently. Stored as wordList since // order changes. wordList meshedPatches_; //- FaceZone to master patch name HashTable faceZoneToMasterPatch_; //- FaceZone to slave patch name HashTable faceZoneToSlavePatch_; //- FaceZone to method to handle faces HashTable faceZoneToType_; // Private Member Functions //- Add patchfield of given type to all fields on mesh template static void addPatchFields(fvMesh&, const word& patchFieldType); //- Reorder patchfields of all fields on mesh template static void reorderPatchFields(fvMesh&, const labelList& oldToNew); //- Find out which faces have changed given cells (old mesh labels) // that were marked for refinement. static labelList getChangedFaces ( const mapPolyMesh&, const labelList& oldCellsToRefine ); //- Calculate coupled boundary end vector and refinement level void calcNeighbourData(labelList& neiLevel, pointField& neiCc) const; //- Calculate rays from cell-centre to cell-centre and corresponding // min cell refinement level void calcCellCellRays ( const pointField& neiCc, const labelList& neiLevel, const labelList& testFaces, pointField& start, pointField& end, labelList& minLevel ) const; //- Remove cells. Put exposedFaces into exposedPatchIDs. autoPtr doRemoveCells ( const labelList& cellsToRemove, const labelList& exposedFaces, const labelList& exposedPatchIDs, removeCells& cellRemover ); //- Get cells which are inside any closed surface. Note that // all closed surfaces // will have already been oriented to have keepPoint outside. labelList getInsideCells(const word&) const; //- Do all to remove inside cells autoPtr removeInsideCells ( const string& msg, const label exposedPatchI ); // Refinement candidate selection //- Mark cell for refinement (if not already marked). Return false // if refinelimit hit. Keeps running count (in nRefine) of cells // marked for refinement static bool markForRefine ( const label markValue, const label nAllowRefine, label& cellValue, label& nRefine ); //- Mark every cell with level of feature passing through it // (or -1 if not passed through). Uses tracking. void markFeatureCellLevel ( const pointField& keepPoints, labelList& maxFeatureLevel ) const; //- Calculate list of cells to refine based on intersection of // features. label markFeatureRefinement ( const pointField& keepPoints, const label nAllowRefine, labelList& refineCell, label& nRefine ) const; //- Mark cells for distance-to-feature based refinement. label markInternalDistanceToFeatureRefinement ( const label nAllowRefine, labelList& refineCell, label& nRefine ) const; //- Mark cells for refinement-shells based refinement. label markInternalRefinement ( const label nAllowRefine, labelList& refineCell, label& nRefine ) const; //- Unmark cells for refinement based on limit-shells. Return number // of limited cells. label unmarkInternalRefinement ( labelList& refineCell, label& nRefine ) const; //- Collect faces that are intersected and whose neighbours aren't // yet marked for refinement. labelList getRefineCandidateFaces ( const labelList& refineCell ) const; //- Mark cells for surface intersection based refinement. label markSurfaceRefinement ( const label nAllowRefine, const labelList& neiLevel, const pointField& neiCc, labelList& refineCell, label& nRefine ) const; //- Mark cells intersected by the surface if they are inside // close gaps label markSurfaceGapRefinement ( const scalar planarCos, const label nAllowRefine, const labelList& neiLevel, const pointField& neiCc, labelList& refineCell, label& nRefine ) const; //- Generate single ray from nearPoint in direction of nearNormal label generateRays ( const point& nearPoint, const vector& nearNormal, const FixedList& gapInfo, const volumeType& mode, const label cLevel, DynamicField& start, DynamicField& end ) const; //- Generate pairs of rays through cell centre // Each ray pair has start, end, and expected gap size label generateRays ( const bool useSurfaceNormal, const point& nearPoint, const vector& nearNormal, const FixedList& gapInfo, const volumeType& mode, const point& cc, const label cLevel, DynamicField& start, DynamicField& end, DynamicField& gapSize, DynamicField& start2, DynamicField& end2, DynamicField& gapSize2 ) const; //- Select candidate cells (cells inside a shell with gapLevel // specified) void selectGapCandidates ( const labelList& refineCell, const label nRefine, labelList& cellMap, List>& shellGapInfo, List& shellGapMode ) const; //- Merge gap information coming from shell and from surface // (surface wins) void mergeGapInfo ( const FixedList& shellGapInfo, const volumeType shellGapMode, const FixedList& surfGapInfo, const volumeType surfGapMode, FixedList& gapInfo, volumeType& gapMode ) const; //- Mark cells for non-surface intersection based gap refinement label markInternalGapRefinement ( const scalar planarCos, const bool spreadGapSize, const label nAllowRefine, labelList& refineCell, label& nRefine, labelList& numGapCells, scalarField& gapSize ) const; //- Refine cells containing small gaps label markSmallFeatureRefinement ( const scalar planarCos, const label nAllowRefine, const labelList& neiLevel, const pointField& neiCc, labelList& refineCell, label& nRefine ) const; //- Helper: count number of normals1 that are in normals2 label countMatches ( const List& normals1, const List& normals2, const scalar tol = 1e-6 ) const; //- Mark cells for surface curvature based refinement. Marks if // local curvature > curvature or if on different regions // (markDifferingRegions) label markSurfaceCurvatureRefinement ( const scalar curvature, const label nAllowRefine, const labelList& neiLevel, const pointField& neiCc, labelList& refineCell, label& nRefine ) const; //- Mark cell if local a gap topology or bool checkProximity ( const scalar planarCos, const label nAllowRefine, const label surfaceLevel, const vector& surfaceLocation, const vector& surfaceNormal, const label cellI, label& cellMaxLevel, vector& cellMaxLocation, vector& cellMaxNormal, labelList& refineCell, label& nRefine ) const; //- Mark cells for surface proximity based refinement. label markProximityRefinement ( const scalar curvature, const label nAllowRefine, const labelList& neiLevel, const pointField& neiCc, labelList& refineCell, label& nRefine ) const; // Baffle handling //- Get faces to repatch. Returns map from face to patch. Map getZoneBafflePatches ( const bool allowBoundary, const labelList& globalToMasterPatch, const labelList& globalToSlavePatch ) const; //- Calculate intersections. Return per face -1 or the global // surface region void getIntersections ( const labelList& surfacesToTest, const pointField& neiCc, const labelList& testFaces, labelList& globalRegion1, labelList& globalRegion2 ) const; //- Calculate intersections on zoned faces. Return per face -1 // or the index of the surface and the orientation w.r.t. surface void getIntersections ( const labelList& surfacesToTest, const pointField& neiCc, const labelList& testFaces, labelList& namedSurfaceIndex, PackedBoolList& posOrientation ) const; //- Determine patches for baffles void getBafflePatches ( const labelList& globalToMasterPatch, const pointField& locationsInMesh, const wordList& regionsInMesh, const labelList& neiLevel, const pointField& neiCc, labelList& ownPatch, labelList& neiPatch ) const; //- Repatches external face or creates baffle for internal face // with user specified patches (might be different for both sides). // Returns label of added face. label createBaffle ( const label faceI, const label ownPatch, const label neiPatch, polyTopoChange& meshMod ) const; // Problem cell handling //- Helper function to mark face as being on 'boundary'. Used by // markFacesOnProblemCells void markBoundaryFace ( const label faceI, boolList& isBoundaryFace, boolList& isBoundaryEdge, boolList& isBoundaryPoint ) const; void findNearest ( const labelList& meshFaces, List& nearestInfo, labelList& nearestSurface, labelList& nearestRegion, vectorField& nearestNormal ) const; Map