From f4db00045d7ea9412eabcd7e8cfd8ad0460061a8 Mon Sep 17 00:00:00 2001 From: Vuko Vukcevic Date: Thu, 2 Mar 2017 09:58:12 +0100 Subject: [PATCH 1/2] Updates to dynamicRefineFvMesh Ported protection for non-hex cells from Vanilla --- .../dynamicRefineFvMesh/dynamicRefineFvMesh.C | 146 +++++++++++++++++- .../dynamicRefineFvMesh/dynamicRefineFvMesh.H | 20 +++ .../directTopoChange/directActions/hexRef8.C | 10 ++ 3 files changed, 174 insertions(+), 2 deletions(-) diff --git a/src/dynamicMesh/dynamicFvMesh/dynamicRefineFvMesh/dynamicRefineFvMesh.C b/src/dynamicMesh/dynamicFvMesh/dynamicRefineFvMesh/dynamicRefineFvMesh.C index e7727a6f3..baac97b89 100644 --- a/src/dynamicMesh/dynamicFvMesh/dynamicRefineFvMesh/dynamicRefineFvMesh.C +++ b/src/dynamicMesh/dynamicFvMesh/dynamicRefineFvMesh/dynamicRefineFvMesh.C @@ -31,6 +31,7 @@ License #include "syncTools.H" #include "pointFields.H" #include "directTopoChange.H" +#include "cellSet.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -59,7 +60,16 @@ label dynamicRefineFvMesh::count { n++; } + + // debug also serves to get-around Clang compiler trying to optimise + // out this forAll loop under O3 optimisation + + if (debug) + { + Info<< "n=" << n << endl; + } } + return n; } @@ -860,11 +870,78 @@ void dynamicRefineFvMesh::extendMarkedCells(PackedBoolList& markedCell) const } +void Foam::dynamicRefineFvMesh::checkEightAnchorPoints +( + PackedBoolList& protectedCell, + label& nProtected +) const +{ + const labelList& cellLevel = meshCutter_.cellLevel(); + const labelList& pointLevel = meshCutter_.pointLevel(); + + labelList nAnchorPoints(nCells(), 0); + + forAll(pointLevel, pointI) + { + const labelList& pCells = pointCells(pointI); + + forAll(pCells, pCellI) + { + label cellI = pCells[pCellI]; + + if (pointLevel[pointI] <= cellLevel[cellI]) + { + // Check if cell has already 8 anchor points -> protect cell + if (nAnchorPoints[cellI] == 8) + { + if (protectedCell.set(cellI, true)) + { + nProtected++; + } + } + + if (!protectedCell[cellI]) + { + nAnchorPoints[cellI]++; + } + } + } + } + + + forAll(protectedCell, cellI) + { + if (!protectedCell[cellI] && nAnchorPoints[cellI] != 8) + { + protectedCell.set(cellI, true); + nProtected++; + } + } +} + + // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // dynamicRefineFvMesh::dynamicRefineFvMesh(const IOobject& io) : dynamicFvMesh(io), + singleMotionUpdate_ + ( + IOdictionary + ( + IOobject + ( + "dynamicMeshDict", + time().constant(), + *this, + IOobject::MUST_READ, + IOobject::NO_WRITE, + false + ) + ).subDict(typeName + "Coeffs") + .lookupOrDefault("singleMotionUpdate", true) + ), + curTimeIndex_(-1), meshCutter_(*this), dumpLevel_(false), nRefinementIterations_(0), @@ -984,12 +1061,63 @@ dynamicRefineFvMesh::dynamicRefineFvMesh(const IOobject& io) nProtected++; } } + + // Also protect any cells that are less than hex + forAll(cells(), cellI) + { + const cell& cFaces = cells()[cellI]; + + if (cFaces.size() < 6) + { + if (protectedCell_.set(cellI, 1)) + { + nProtected++; + } + } + else + { + forAll(cFaces, cFaceI) + { + if (faces()[cFaces[cFaceI]].size() < 4) + { + if (protectedCell_.set(cellI, 1)) + { + nProtected++; + } + break; + } + } + } + } + + // Check cells for 8 corner points + checkEightAnchorPoints(protectedCell_, nProtected); } if (returnReduce(nProtected, sumOp