snappyHexMesh: Added locationsInMesh specification

In order to select to keep the cells in multiple disconnected regions it is
necessary to specify a location in each of those regions as a list of points,
e.g.

castellatedMeshControls
{
.
.
.
    locationsInMesh
    (
        (-0.18 0.003 0.05 )
        (-0.09 0.003 0.05)
        (0.09  0.003 0.05)
        (0.18  0.003 0.05)
    );
.
.
.
}

The locationInMesh control is still available for backward compatibility and to
specify a point when meshing a single region.
This commit is contained in:
Henry Weller
2021-09-27 11:43:01 +01:00
parent 98686ae760
commit b39d6b224f
11 changed files with 571 additions and 551 deletions

View File

@ -128,7 +128,7 @@ void Foam::meshRefinement::calcNeighbourData
const labelList& cellLevel = meshCutter_.cellLevel();
const pointField& cellCentres = mesh_.cellCentres();
label nBoundaryFaces = mesh_.nFaces() - mesh_.nInternalFaces();
const label nBoundaryFaces = mesh_.nFaces() - mesh_.nInternalFaces();
if (neiLevel.size() != nBoundaryFaces || neiCc.size() != nBoundaryFaces)
{
@ -149,7 +149,7 @@ void Foam::meshRefinement::calcNeighbourData
const vectorField::subField faceCentres = pp.faceCentres();
const vectorField::subField faceAreas = pp.faceAreas();
label bFacei = pp.start()-mesh_.nInternalFaces();
label bFacei = pp.start() - mesh_.nInternalFaces();
if (pp.coupled())
{
@ -170,12 +170,11 @@ void Foam::meshRefinement::calcNeighbourData
forAll(faceCells, i)
{
// Extrapolate the face centre.
vector fn = faceAreas[i];
fn /= mag(fn)+vSmall;
const vector fn = faceAreas[i]/(mag(faceAreas[i]) + vSmall);
label own = faceCells[i];
label ownLevel = cellLevel[own];
label faceLevel = meshCutter_.faceLevel(pp.start()+i);
const label own = faceCells[i];
const label ownLevel = cellLevel[own];
const label faceLevel = meshCutter_.faceLevel(pp.start() + i);
// Normal distance from face centre to cell centre
scalar d = ((faceCentres[i] - cellCentres[own]) & fn);
@ -243,8 +242,8 @@ void Foam::meshRefinement::updateIntersections(const labelList& changedFaces)
// Get boundary face centre and level. Coupled aware.
labelList neiLevel(mesh_.nFaces()-mesh_.nInternalFaces());
pointField neiCc(mesh_.nFaces()-mesh_.nInternalFaces());
labelList neiLevel(mesh_.nFaces() - mesh_.nInternalFaces());
pointField neiCc(mesh_.nFaces() - mesh_.nInternalFaces());
calcNeighbourData(neiLevel, neiCc);
// Collect segments we want to test for
@ -253,8 +252,8 @@ void Foam::meshRefinement::updateIntersections(const labelList& changedFaces)
forAll(changedFaces, i)
{
label facei = changedFaces[i];
label own = mesh_.faceOwner()[facei];
const label facei = changedFaces[i];
const label own = mesh_.faceOwner()[facei];
start[i] = cellCentres[own];
if (mesh_.isInternalFace(facei))
@ -299,8 +298,8 @@ void Foam::meshRefinement::updateIntersections(const labelList& changedFaces)
// case in general since same vectors but just to make sure.
syncTools::syncFaceList(mesh_, surfaceIndex_, maxEqOp<label>());
label nHits = countHits();
label nTotHits = returnReduce(nHits, sumOp<label>());
const label nHits = countHits();
const label nTotHits = returnReduce(nHits, sumOp<label>());
Info<< " Number of intersected edges : " << nTotHits << endl;
@ -414,7 +413,7 @@ void Foam::meshRefinement::checkData()
meshCutter_.checkRefinementLevels(1, labelList(0));
label nBnd = mesh_.nFaces()-mesh_.nInternalFaces();
label nBnd = mesh_.nFaces() - mesh_.nInternalFaces();
Pout<< "meshRefinement::checkData() : Checking synchronisation."
<< endl;
@ -546,7 +545,7 @@ void Foam::meshRefinement::checkData()
labelList::subList boundarySurface
(
surfaceIndex_,
mesh_.nFaces()-mesh_.nInternalFaces(),
mesh_.nFaces() - mesh_.nInternalFaces(),
mesh_.nInternalFaces()
);
@ -577,7 +576,7 @@ void Foam::meshRefinement::checkData()
localPointRegion::findDuplicateFaces
(
mesh_,
identity(mesh_.nFaces()-mesh_.nInternalFaces())
identity(mesh_.nFaces() - mesh_.nInternalFaces())
+ mesh_.nInternalFaces()
)
);
@ -676,13 +675,13 @@ Foam::autoPtr<Foam::mapPolyMesh> Foam::meshRefinement::splitFaces
forAll(splitFaces, i)
{
label facei = splitFaces[i];
const label facei = splitFaces[i];
const face& f = mesh_.faces()[facei];
// Split as start and end index in face
const labelPair& split = splits[i];
label nVerts = split[1]-split[0];
label nVerts = split[1] - split[0];
if (nVerts < 0)
{
nVerts += f.size();
@ -700,7 +699,7 @@ Foam::autoPtr<Foam::mapPolyMesh> Foam::meshRefinement::splitFaces
fp = f.fcIndex(fp);
}
face f1(f.size()-f0.size()+2);
face f1(f.size() - f0.size() + 2);
fp = split[1];
forAll(f1, i)
{
@ -710,7 +709,7 @@ Foam::autoPtr<Foam::mapPolyMesh> Foam::meshRefinement::splitFaces
// Determine face properties
label own = mesh_.faceOwner()[facei];
const label own = mesh_.faceOwner()[facei];
label nei = -1;
label patchi = -1;
if (facei >= mesh_.nInternalFaces())
@ -722,7 +721,7 @@ Foam::autoPtr<Foam::mapPolyMesh> Foam::meshRefinement::splitFaces
nei = mesh_.faceNeighbour()[facei];
}
label zoneI = mesh_.faceZones().whichZone(facei);
const label zoneI = mesh_.faceZones().whichZone(facei);
bool zoneFlip = false;
if (zoneI != -1)
{
@ -831,7 +830,7 @@ Foam::autoPtr<Foam::mapPolyMesh> Foam::meshRefinement::splitFaces
// {
// forAll(pp, i)
// {
// label facei = pp.start()+i;
// label facei = pp.start() + i;
//
// if (!blockedFace[facei])
// {
@ -1251,7 +1250,7 @@ Foam::label Foam::meshRefinement::countHits() const
// // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// // (does not determine master for non-coupled=fully-local regions)
//
// Map<label> coupledRegionToMaster(mesh_.nFaces()-mesh_.nInternalFaces());
// Map<label> coupledRegionToMaster(mesh_.nFaces() - mesh_.nInternalFaces());
// getCoupledRegionMaster
// (
// globalCells,
@ -1436,7 +1435,7 @@ Foam::autoPtr<Foam::mapDistributePolyMesh> Foam::meshRefinement::balance
forAll(fZone, i)
{
label facei = fZone[i];
const label facei = fZone[i];
if (blockedFace[facei])
{
if
@ -1500,7 +1499,7 @@ Foam::autoPtr<Foam::mapDistributePolyMesh> Foam::meshRefinement::balance
if (keepBaffles)
{
label nBnd = mesh_.nFaces()-mesh_.nInternalFaces();
const label nBnd = mesh_.nFaces() - mesh_.nInternalFaces();
labelList coupledFace(mesh_.nFaces(), -1);
{
@ -1863,7 +1862,7 @@ void Foam::meshRefinement::checkCoupledFaceZones(const polyMesh& mesh)
// Check that coupled faces are present on both sides.
labelList faceToZone(mesh.nFaces()-mesh.nInternalFaces(), -1);
labelList faceToZone(mesh.nFaces() - mesh.nInternalFaces(), -1);
forAll(fZones, zoneI)
{
@ -1908,7 +1907,7 @@ void Foam::meshRefinement::checkCoupledFaceZones(const polyMesh& mesh)
if (faceToZone[i] != neiFaceToZone[i])
{
FatalErrorInFunction
<< "Face " << mesh.nInternalFaces()+i
<< "Face " << mesh.nInternalFaces() + i
<< " is in zone " << faceToZone[i]
<< ", its coupled face is in zone " << neiFaceToZone[i]
<< abort(FatalError);
@ -1981,7 +1980,7 @@ Foam::label Foam::meshRefinement::addMeshedPatch
{
const polyBoundaryMesh& pbm = mesh_.boundaryMesh();
label meshedI = findIndex(meshedPatches_, name);
const label meshedI = findIndex(meshedPatches_, name);
if (meshedI != -1)
{
@ -2082,7 +2081,7 @@ void Foam::meshRefinement::selectSeparatedCoupledFaces(boolList& selected) const
{
forAll(cpp, i)
{
selected[cpp.start()+i] = true;
selected[cpp.start() + i] = true;
}
}
}
@ -2095,28 +2094,75 @@ Foam::label Foam::meshRefinement::findRegion
const polyMesh& mesh,
const labelList& cellToRegion,
const vector& perturbVec,
const point& p
const point& locationInMesh
)
{
label regionI = -1;
label celli = mesh.findCell(p);
label regioni = -1;
label celli = mesh.findCell(locationInMesh);
if (celli != -1)
{
regionI = cellToRegion[celli];
regioni = cellToRegion[celli];
}
reduce(regionI, maxOp<label>());
reduce(regioni, maxOp<label>());
if (regionI == -1)
if (regioni == -1)
{
// See if we can perturb a bit
celli = mesh.findCell(p+perturbVec);
celli = mesh.findCell(locationInMesh + perturbVec);
if (celli != -1)
{
regionI = cellToRegion[celli];
regioni = cellToRegion[celli];
}
reduce(regioni, maxOp<label>());
}
return regioni;
}
void Foam::meshRefinement::findRegions
(
const polyMesh& mesh,
labelList& cellRegion,
const vector& perturbVec,
const List<point>& locationsInMesh
)
{
// List of all cells inside any of the regions
// which have a point in the locationsInMesh list
PackedBoolList insideCells(mesh.nCells());
// For each of the locationsInMesh find the corresponding region
// and mark the cells
forAll(locationsInMesh, i)
{
// Find the region corresponding to the locationsInMesh[i]
const label regioni = findRegion
(
mesh,
cellRegion,
perturbVec,
locationsInMesh[i]
);
// Add all the cells in the region to insideCells
forAll(cellRegion, celli)
{
if (cellRegion[celli] == regioni)
{
insideCells[celli] = true;
}
}
}
// For all unmarked cells set cellRegion to -1
forAll(insideCells, celli)
{
if (!insideCells[celli])
{
cellRegion[celli] = -1;
}
reduce(regionI, maxOp<label>());
}
return regionI;
}
@ -2124,7 +2170,7 @@ Foam::autoPtr<Foam::mapPolyMesh> Foam::meshRefinement::splitMeshRegions
(
const labelList& globalToMasterPatch,
const labelList& globalToSlavePatch,
const point& keepPoint
const List<point>& locationsInMesh
)
{
// Force calculation of face decomposition (used in findCell)
@ -2138,23 +2184,14 @@ Foam::autoPtr<Foam::mapPolyMesh> Foam::meshRefinement::splitMeshRegions
regionSplit cellRegion(mesh_, blockedFace);
label regionI = findRegion
findRegions
(
mesh_,
cellRegion,
mergeDistance_*vector(1,1,1), // note:1,1,1 should really be normalised
keepPoint
mergeDistance_*vector::one,
locationsInMesh
);
if (regionI == -1)
{
FatalErrorInFunction
<< "Point " << keepPoint
<< " is not inside the mesh." << nl
<< "Bounding box of the mesh:" << mesh_.bounds()
<< exit(FatalError);
}
// Subset
// ~~~~~~
@ -2162,58 +2199,70 @@ Foam::autoPtr<Foam::mapPolyMesh> Foam::meshRefinement::splitMeshRegions
DynamicList<label> cellsToRemove(mesh_.nCells());
forAll(cellRegion, celli)
{
if (cellRegion[celli] != regionI)
if (cellRegion[celli] == -1)
{
cellsToRemove.append(celli);
}
}
cellsToRemove.shrink();
label nCellsToKeep = mesh_.nCells() - cellsToRemove.size();
reduce(nCellsToKeep, sumOp<label>());
const label nCellsToRemove = returnReduce
(
cellsToRemove.size(),
sumOp<label>()
);
Info<< "Keeping all cells in region " << regionI
<< " containing point " << keepPoint << endl
<< "Selected for keeping : "
<< nCellsToKeep
<< " cells." << endl;
// Remove cells
removeCells cellRemover(mesh_);
labelList exposedFaces(cellRemover.getExposedFaces(cellsToRemove));
labelList exposedPatch;
label nExposedFaces = returnReduce(exposedFaces.size(), sumOp<label>());
if (nExposedFaces)
if (nCellsToRemove)
{
// FatalErrorInFunction
// << "Removing non-reachable cells should only expose"
// << " boundary faces" << nl
// << "ExposedFaces:" << exposedFaces << abort(FatalError);
label nCellsToKeep = mesh_.nCells() - cellsToRemove.size();
reduce(nCellsToKeep, sumOp<label>());
// Patch for exposed faces for lack of anything sensible.
label defaultPatch = 0;
if (globalToMasterPatch.size())
Info<< "Keeping all cells in regions containing any point in "
<< locationsInMesh << endl
<< "Selected for keeping : " << nCellsToKeep << " cells." << endl;
// Remove cells
removeCells cellRemover(mesh_);
const labelList exposedFaces
(
cellRemover.getExposedFaces(cellsToRemove)
);
labelList exposedPatch;
const label nExposedFaces =
returnReduce(exposedFaces.size(), sumOp<label>());
if (nExposedFaces)
{
defaultPatch = globalToMasterPatch[0];
// Patch for exposed faces for lack of anything sensible.
label defaultPatch = 0;
if (globalToMasterPatch.size())
{
defaultPatch = globalToMasterPatch[0];
}
WarningInFunction
<< "Removing non-reachable cells exposes "
<< nExposedFaces << " internal or coupled faces." << endl
<< " These get put into patch " << defaultPatch << endl;
exposedPatch.setSize(exposedFaces.size(), defaultPatch);
}
WarningInFunction
<< "Removing non-reachable cells exposes "
<< nExposedFaces << " internal or coupled faces." << endl
<< " These get put into patch " << defaultPatch << endl;
exposedPatch.setSize(exposedFaces.size(), defaultPatch);
return doRemoveCells
(
cellsToRemove,
exposedFaces,
exposedPatch,
cellRemover
);
}
else
{
return autoPtr<mapPolyMesh>();
}
return doRemoveCells
(
cellsToRemove,
exposedFaces,
exposedPatch,
cellRemover
);
}
@ -2363,7 +2412,7 @@ void Foam::meshRefinement::updateMesh
forAll(map.faceMap(), facei)
{
label oldFacei = map.faceMap()[facei];
const label oldFacei = map.faceMap()[facei];
if (oldFacei >= 0)
{
@ -2379,7 +2428,7 @@ void Foam::meshRefinement::updateMesh
labelList newFaceData(map.faceMap().size(), -1);
forAll(newFaceData, facei)
{
label oldFacei = map.faceMap()[facei];
const label oldFacei = map.faceMap()[facei];
if (oldFacei >= 0)
{
@ -2551,7 +2600,7 @@ const
{
const labelList& cellLevel = meshCutter_.cellLevel();
labelList nCells(gMax(cellLevel)+1, 0);
labelList nCells(gMax(cellLevel) + 1, 0);
forAll(cellLevel, celli)
{
@ -2661,8 +2710,8 @@ void Foam::meshRefinement::dumpIntersections(const fileName& prefix) const
// ~~~~~~~~~~~~~~~~~~~~~~
// Get boundary face centre and level. Coupled aware.
labelList neiLevel(mesh_.nFaces()-mesh_.nInternalFaces());
pointField neiCc(mesh_.nFaces()-mesh_.nInternalFaces());
labelList neiLevel(mesh_.nFaces() - mesh_.nInternalFaces());
pointField neiCc(mesh_.nFaces() - mesh_.nInternalFaces());
calcNeighbourData(neiLevel, neiCc);
labelList intersectionFaces(intersectedFaces());
@ -2673,7 +2722,7 @@ void Foam::meshRefinement::dumpIntersections(const fileName& prefix) const
forAll(intersectionFaces, i)
{
label facei = intersectionFaces[i];
const label facei = intersectionFaces[i];
start[i] = cellCentres[mesh_.faceOwner()[facei]];
if (mesh_.isInternalFace(facei))

View File

@ -225,7 +225,7 @@ private:
// Get cells which are inside any closed surface. Note that
// all closed surfaces
// will have already been oriented to have keepPoint outside.
// will have already been oriented to have locationInMesh outside.
labelList getInsideCells(const word&) const;
// Do all to remove inside cells
@ -253,7 +253,7 @@ private:
// (or -1 if not passed through). Uses tracking.
void markFeatureCellLevel
(
const pointField& keepPoints,
const List<point>& locationsInMesh,
labelList& maxFeatureLevel
) const;
@ -261,7 +261,7 @@ private:
// features.
label markFeatureRefinement
(
const pointField& keepPoints,
const List<point>& locationsInMesh,
const label nAllowRefine,
labelList& refineCell,
@ -431,6 +431,12 @@ private:
//- Returns list with for every internal face -1 or the patch
// they should be baffled into. If removeEdgeConnectedCells is set
// removes cells based on perpendicularAngle.
//
// Gets run after createBaffles so all the unzoned surface
// intersections have already been turned into baffles. (Note:
// zoned surfaces are not baffled at this stage) Used to remove
// cells by baffling all their faces and have the splitMeshRegions
// chuck away non used regions.
labelList markFacesOnProblemCells
(
const dictionary& motionDict,
@ -503,7 +509,7 @@ private:
// marked in namedSurfaceIndex regarded as blocked.
void findCellZoneTopo
(
const point& keepPoint,
const List<point>& locationsInMesh,
const labelList& namedSurfaceIndex,
const labelList& surfaceToCellZone,
labelList& cellToZone
@ -773,7 +779,7 @@ public:
//- Calculate list of cells to refine.
labelList refineCandidates
(
const pointField& keepPoints,
const List<point>& locationsInMesh,
const scalar curvature,
const scalar planarAngle,
@ -832,7 +838,7 @@ public:
Time& runTime,
const labelList& globalToMasterPatch,
const labelList& globalToSlavePatch,
const point& keepPoint
const List<point>& locationsInMesh
);
//- Split off (with optional buffer layers) unreachable areas
@ -842,7 +848,7 @@ public:
const label nBufferLayers,
const labelList& globalToMasterPatch,
const labelList& globalToSlavePatch,
const point& keepPoint
const List<point>& locationsInMesh
);
//- Find boundary points that connect to more than one cell
@ -879,10 +885,10 @@ public:
//- Put faces/cells into zones according to surface specification.
// Returns null if no zone surfaces present. Region containing
// the keepPoint will not be put into a cellZone.
// the locationInMesh will not be put into a cellZone.
autoPtr<mapPolyMesh> zonify
(
const point& keepPoint,
const List<point>& locationsInMesh,
const bool allowFreeStandingZoneFaces
);
@ -904,15 +910,25 @@ public:
const polyMesh&,
const labelList& cellRegion,
const vector& perturbVec,
const point& p
const point& locationInMesh
);
//- Split mesh. Keep part containing point.
//- Find regions points are in and update cellRegion
// Uses optional perturbation to re-test.
static void findRegions
(
const polyMesh&,
labelList& cellRegion,
const vector& perturbVec,
const List<point>& locationsInMesh
);
//- Split mesh. Keep regions containing any point in locationsInMesh
autoPtr<mapPolyMesh> splitMeshRegions
(
const labelList& globalToMasterPatch,
const labelList& globalToSlavePatch,
const point& keepPoint
const List<point>& locationsInMesh
);
//- Split faces into two

File diff suppressed because it is too large Load Diff

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -362,7 +362,7 @@ Foam::label Foam::meshRefinement::mergePatchFacesUndo
forAll(allFaceSets, setI)
{
label oldMasterI = allFaceSets[setI][0];
const label oldMasterI = allFaceSets[setI][0];
retestFaces.insert(map().reverseFaceMap()[oldMasterI]);
}
updateMesh(map, growFaceCellFace(retestFaces));
@ -450,11 +450,11 @@ Foam::label Foam::meshRefinement::mergePatchFacesUndo
forAll(allFaceSets, setI)
{
label masterFacei = faceCombiner.masterFace()[setI];
const label masterFacei = faceCombiner.masterFace()[setI];
if (masterFacei != -1)
{
label masterCellII = mesh_.faceOwner()[masterFacei];
const label masterCellII = mesh_.faceOwner()[masterFacei];
const cell& cFaces = mesh_.cells()[masterCellII];
@ -470,7 +470,7 @@ Foam::label Foam::meshRefinement::mergePatchFacesUndo
}
mastersToRestore.shrink();
label nRestore = returnReduce
const label nRestore = returnReduce
(
mastersToRestore.size(),
sumOp<label>()
@ -634,7 +634,7 @@ Foam::autoPtr<Foam::mapPolyMesh> Foam::meshRefinement::doRemovePoints
labelHashSet retestFaces(pointRemover.savedFaceLabels().size());
forAll(pointRemover.savedFaceLabels(), i)
{
label facei = pointRemover.savedFaceLabels()[i];
const label facei = pointRemover.savedFaceLabels()[i];
if (facei >= 0)
{
retestFaces.insert(facei);
@ -653,7 +653,6 @@ Foam::autoPtr<Foam::mapPolyMesh> Foam::meshRefinement::doRemovePoints
}
// Restore faces (which contain removed points)
Foam::autoPtr<Foam::mapPolyMesh> Foam::meshRefinement::doRestorePoints
(
removePoints& pointRemover,
@ -705,7 +704,7 @@ Foam::autoPtr<Foam::mapPolyMesh> Foam::meshRefinement::doRestorePoints
labelHashSet retestFaces(2*facesToRestore.size());
forAll(facesToRestore, i)
{
label facei = map().reverseFaceMap()[facesToRestore[i]];
const label facei = map().reverseFaceMap()[facesToRestore[i]];
if (facei >= 0)
{
retestFaces.insert(facei);
@ -738,7 +737,7 @@ Foam::labelList Foam::meshRefinement::collectFaces
forAll(candidateFaces, i)
{
label facei = candidateFaces[i];
const label facei = candidateFaces[i];
if (set.found(facei))
{
@ -768,9 +767,8 @@ Foam::labelList Foam::meshRefinement::growFaceCellFace
forAllConstIter(faceSet, set, iter)
{
label facei = iter.key();
label own = mesh_.faceOwner()[facei];
const label facei = iter.key();
const label own = mesh_.faceOwner()[facei];
const cell& ownFaces = mesh_.cells()[own];
forAll(ownFaces, ownFacei)
@ -780,7 +778,7 @@ Foam::labelList Foam::meshRefinement::growFaceCellFace
if (mesh_.isInternalFace(facei))
{
label nbr = mesh_.faceNeighbour()[facei];
const label nbr = mesh_.faceNeighbour()[facei];
const cell& nbrFaces = mesh_.cells()[nbr];
forAll(nbrFaces, nbrFacei)
@ -897,7 +895,11 @@ Foam::label Foam::meshRefinement::mergeEdgesUndo
)
);
label n = returnReduce(masterErrorFaces.size(), sumOp<label>());
const label n = returnReduce
(
masterErrorFaces.size(),
sumOp<label>()
);
Info<< "Detected " << n
<< " error faces on boundaries that have been merged."

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -113,7 +113,7 @@ void Foam::meshRefinement::findNearest
}
}
label geomI = surfaces_.surfaces()[surfI];
const label geomI = surfaces_.surfaces()[surfI];
pointField localNormals;
surfaces_.geometry()[geomI].getNormal(localHits, localNormals);
@ -168,11 +168,11 @@ Foam::Map<Foam::label> Foam::meshRefinement::findEdgeConnectedProblemCells
if (eFaces.size() == 2)
{
label face0 = pp.addressing()[eFaces[0]];
label face1 = pp.addressing()[eFaces[1]];
const label face0 = pp.addressing()[eFaces[0]];
const label face1 = pp.addressing()[eFaces[1]];
label cell0 = mesh_.faceOwner()[face0];
label cell1 = mesh_.faceOwner()[face1];
const label cell0 = mesh_.faceOwner()[face0];
const label cell1 = mesh_.faceOwner()[face1];
if (cellLevel[cell0] > cellLevel[cell1])
{
@ -241,18 +241,16 @@ Foam::Map<Foam::label> Foam::meshRefinement::findEdgeConnectedProblemCells
forAll(candidateFaces, i)
{
label facei = candidateFaces[i];
const label facei = candidateFaces[i];
const vector n = mesh_.faceAreas()[facei]/mag(mesh_.faceAreas()[facei]);
vector n = mesh_.faceAreas()[facei];
n /= mag(n);
label region = surfaces_.globalRegion
const label region = surfaces_.globalRegion
(
nearestSurface[i],
nearestRegion[i]
);
scalar angle = degToRad(perpendicularAngle[region]);
const scalar angle = degToRad(perpendicularAngle[region]);
if (angle >= 0)
{
@ -280,9 +278,6 @@ Foam::Map<Foam::label> Foam::meshRefinement::findEdgeConnectedProblemCells
}
// Check if moving face to new points causes a 'collapsed' face.
// Uses new point position only for the face, not the neighbouring
// cell centres
bool Foam::meshRefinement::isCollapsedFace
(
const pointField& points,
@ -310,10 +305,10 @@ bool Foam::meshRefinement::isCollapsedFace
if (mesh_.isInternalFace(facei))
{
label nei = mesh_.faceNeighbour()[facei];
vector d = mesh_.cellCentres()[nei] - ownCc;
const label nei = mesh_.faceNeighbour()[facei];
const vector d = mesh_.cellCentres()[nei] - ownCc;
scalar dDotS = (d & s)/(mag(d)*magS + vSmall);
const scalar dDotS = (d & s)/(mag(d)*magS + vSmall);
if (dDotS < severeNonorthogonalityThreshold)
{
@ -326,13 +321,13 @@ bool Foam::meshRefinement::isCollapsedFace
}
else
{
label patchi = mesh_.boundaryMesh().whichPatch(facei);
const label patchi = mesh_.boundaryMesh().whichPatch(facei);
if (mesh_.boundaryMesh()[patchi].coupled())
{
vector d = neiCc[facei-mesh_.nInternalFaces()] - ownCc;
const vector d = neiCc[facei-mesh_.nInternalFaces()] - ownCc;
scalar dDotS = (d & s)/(mag(d)*magS + vSmall);
const scalar dDotS = (d & s)/(mag(d)*magS + vSmall);
if (dDotS < severeNonorthogonalityThreshold)
{
@ -353,7 +348,6 @@ bool Foam::meshRefinement::isCollapsedFace
}
// Check if moving cell to new points causes it to collapse.
bool Foam::meshRefinement::isCollapsedCell
(
const pointField& points,
@ -361,7 +355,7 @@ bool Foam::meshRefinement::isCollapsedCell
const label celli
) const
{
scalar vol = mesh_.cells()[celli].mag(points, mesh_.faces());
const scalar vol = mesh_.cells()[celli].mag(points, mesh_.faces());
if (vol/mesh_.cellVolumes()[celli] < volFraction)
{
@ -406,7 +400,7 @@ Foam::labelList Foam::meshRefinement::nearestPatch
nFaces = 0;
forAll(adaptPatchIDs, i)
{
label patchi = adaptPatchIDs[i];
const label patchi = adaptPatchIDs[i];
const polyPatch& pp = patches[patchi];
forAll(pp, i)
@ -462,12 +456,6 @@ Foam::labelList Foam::meshRefinement::nearestPatch
}
// Returns list with for every internal face -1 or the patch they should
// be baffled into. Gets run after createBaffles so all the unzoned surface
// intersections have already been turned into baffles. (Note: zoned surfaces
// are not baffled at this stage)
// Used to remove cells by baffling all their faces and have the
// splitMeshRegions chuck away non used regions.
Foam::labelList Foam::meshRefinement::markFacesOnProblemCells
(
const dictionary& motionDict,
@ -557,7 +545,7 @@ Foam::labelList Foam::meshRefinement::markFacesOnProblemCells
forAll(cFaces, i)
{
label facei = cFaces[i];
const label facei = cFaces[i];
if (facePatch[facei] == -1 && mesh_.isInternalFace(facei))
{
@ -731,7 +719,7 @@ Foam::labelList Foam::meshRefinement::markFacesOnProblemCells
forAll(cPoints, i)
{
label pointi = cPoints[i];
const label pointi = cPoints[i];
if (pointLevel[pointi] <= cellLevel[celli])
{
@ -794,7 +782,7 @@ Foam::labelList Foam::meshRefinement::markFacesOnProblemCells
// Block all faces of cell
forAll(cFaces, cf)
{
label facei = cFaces[cf];
const label facei = cFaces[cf];
if
(
@ -881,7 +869,7 @@ Foam::labelList Foam::meshRefinement::markFacesOnProblemCells
forAll(cFaces, cf)
{
label facei = cFaces[cf];
const label facei = cFaces[cf];
if
(

View File

@ -155,8 +155,8 @@ Foam::labelList Foam::meshRefinement::getChangedFaces
for (label facei = 0; facei < nInternalFaces; facei++)
{
label oldOwn = map.cellMap()[faceOwner[facei]];
label oldNei = map.cellMap()[faceNeighbour[facei]];
const label oldOwn = map.cellMap()[faceOwner[facei]];
const label oldNei = map.cellMap()[faceNeighbour[facei]];
if
(
@ -195,7 +195,7 @@ Foam::labelList Foam::meshRefinement::getChangedFaces
}
else
{
refinedBoundaryFace[facei-nInternalFaces] = true;
refinedBoundaryFace[facei - nInternalFaces] = true;
}
facei++;
}
@ -313,7 +313,7 @@ bool Foam::meshRefinement::markForRefine
void Foam::meshRefinement::markFeatureCellLevel
(
const pointField& keepPoints,
const List<point>& locationsInMesh,
labelList& maxFeatureLevel
) const
{
@ -324,7 +324,8 @@ void Foam::meshRefinement::markFeatureCellLevel
//
// 1. find non-manifold points on feature edges (i.e. start of feature edge
// or 'knot')
// 2. seed particle starting at keepPoint going to this non-manifold point
// 2. seed particle starting at locationInMesh going to this non-manifold
// point
// 3. track particles to their non-manifold point
//
// 4. track particles across their connected feature edges, marking all
@ -332,7 +333,8 @@ void Foam::meshRefinement::markFeatureCellLevel
// 5. do 4 until all edges have been visited.
// Find all start cells of features. Is done by tracking from keepPoint.
// Find all start cells of features.
// Is done by tracking from locationInMesh.
Cloud<trackedParticle> startPointCloud
(
mesh_,
@ -343,17 +345,17 @@ void Foam::meshRefinement::markFeatureCellLevel
// Features are identical on all processors. Number them so we know
// what to seed. Do this on only the processor that
// holds the keepPoint.
// holds the locationInMesh.
forAll(keepPoints, i)
forAll(locationsInMesh, i)
{
const point& keepPoint = keepPoints[i];
const point& locationInMesh = locationsInMesh[i];
const label celli = mesh_.cellTree().findInside(keepPoint);
const label celli = mesh_.cellTree().findInside(locationInMesh);
if (celli != -1)
{
// I am the processor that holds the keepPoint
// I am the processor that holds the locationInMesh
forAll(features_, featI)
{
@ -363,7 +365,7 @@ void Foam::meshRefinement::markFeatureCellLevel
// Find regions on edgeMesh
labelList edgeRegion;
label nRegions = featureMesh.regions(edgeRegion);
const label nRegions = featureMesh.regions(edgeRegion);
PackedBoolList regionVisited(nRegions);
@ -391,7 +393,7 @@ void Foam::meshRefinement::markFeatureCellLevel
new trackedParticle
(
mesh_,
keepPoint,
locationInMesh,
celli,
featureMesh.points()[pointi], // endpos
featureLevel, // level
@ -419,7 +421,7 @@ void Foam::meshRefinement::markFeatureCellLevel
if (regionVisited.set(edgeRegion[edgeI], 1u))
{
const edge& e = featureMesh.edges()[edgeI];
label pointi = e.start();
const label pointi = e.start();
if (debug&meshRefinement::FEATURESEEDS)
{
Pout<< "Adding particle from point:" << pointi
@ -434,7 +436,7 @@ void Foam::meshRefinement::markFeatureCellLevel
new trackedParticle
(
mesh_,
keepPoint,
locationInMesh,
celli,
featureMesh.points()[pointi], // endpos
featureLevel, // level
@ -509,8 +511,8 @@ void Foam::meshRefinement::markFeatureCellLevel
{
const trackedParticle& startTp = iter();
label featI = startTp.i();
label pointi = startTp.j();
const label featI = startTp.i();
const label pointi = startTp.j();
const edgeMesh& featureMesh = features_[featI];
const labelList& pEdges = featureMesh.pointEdges()[pointi];
@ -518,7 +520,7 @@ void Foam::meshRefinement::markFeatureCellLevel
// Now shoot particles down all pEdges.
forAll(pEdges, pEdgeI)
{
label edgeI = pEdges[pEdgeI];
const label edgeI = pEdges[pEdgeI];
if (featureEdgeVisited[featI].set(edgeI, 1u))
{
@ -567,8 +569,8 @@ void Foam::meshRefinement::markFeatureCellLevel
{
trackedParticle& tp = iter();
label featI = tp.i();
label pointi = tp.j();
const label featI = tp.i();
const label pointi = tp.j();
const edgeMesh& featureMesh = features_[featI];
const labelList& pEdges = featureMesh.pointEdges()[pointi];
@ -580,7 +582,7 @@ void Foam::meshRefinement::markFeatureCellLevel
forAll(pEdges, i)
{
label edgeI = pEdges[i];
const label edgeI = pEdges[i];
if (featureEdgeVisited[featI].set(edgeI, 1u))
{
@ -588,7 +590,7 @@ void Foam::meshRefinement::markFeatureCellLevel
// on the edge.
const edge& e = featureMesh.edges()[edgeI];
label otherPointi = e.otherVertex(pointi);
const label otherPointi = e.otherVertex(pointi);
tp.start() = tp.position();
tp.end() = featureMesh.points()[otherPointi];
@ -640,7 +642,7 @@ void Foam::meshRefinement::markFeatureCellLevel
// Calculates list of cells to refine based on intersection with feature edge.
Foam::label Foam::meshRefinement::markFeatureRefinement
(
const pointField& keepPoints,
const List<point>& locationsInMesh,
const label nAllowRefine,
labelList& refineCell,
@ -649,14 +651,14 @@ Foam::label Foam::meshRefinement::markFeatureRefinement
{
// Largest refinement level of any feature passed through
labelList maxFeatureLevel;
markFeatureCellLevel(keepPoints, maxFeatureLevel);
markFeatureCellLevel(locationsInMesh, maxFeatureLevel);
// See which cells to refine. maxFeatureLevel will hold highest level
// of any feature edge that passed through.
const labelList& cellLevel = meshCutter_.cellLevel();
label oldNRefine = nRefine;
const label oldNRefine = nRefine;
forAll(maxFeatureLevel, celli)
{
@ -741,7 +743,7 @@ Foam::label Foam::meshRefinement::markInternalDistanceToFeatureRefinement
{
if (maxLevel[testI] > testLevels[testI])
{
bool reachedLimit = !markForRefine
const bool reachedLimit = !markForRefine
(
maxLevel[testI], // mark with any positive value
nAllowRefine,
@ -777,7 +779,6 @@ Foam::label Foam::meshRefinement::markInternalDistanceToFeatureRefinement
}
// Mark cells for non-surface intersection based refinement.
Foam::label Foam::meshRefinement::markInternalRefinement
(
const label nAllowRefine,
@ -789,7 +790,7 @@ Foam::label Foam::meshRefinement::markInternalRefinement
const labelList& cellLevel = meshCutter_.cellLevel();
const pointField& cellCentres = mesh_.cellCentres();
label oldNRefine = nRefine;
const label oldNRefine = nRefine;
// Collect cells to test
pointField testCc(cellLevel.size()-nRefine);
@ -861,8 +862,6 @@ Foam::label Foam::meshRefinement::markInternalRefinement
}
// Collect faces that are intersected and whose neighbours aren't yet marked
// for refinement.
Foam::labelList Foam::meshRefinement::getRefineCandidateFaces
(
const labelList& refineCell
@ -880,7 +879,7 @@ Foam::labelList Foam::meshRefinement::getRefineCandidateFaces
if (mesh_.isInternalFace(facei))
{
label nei = mesh_.faceNeighbour()[facei];
const label nei = mesh_.faceNeighbour()[facei];
if (refineCell[own] == -1 || refineCell[nei] == -1)
{
@ -902,7 +901,6 @@ Foam::labelList Foam::meshRefinement::getRefineCandidateFaces
}
// Mark cells for surface intersection based refinement.
Foam::label Foam::meshRefinement::markSurfaceRefinement
(
const label nAllowRefine,
@ -916,7 +914,7 @@ Foam::label Foam::meshRefinement::markSurfaceRefinement
const labelList& cellLevel = meshCutter_.cellLevel();
const pointField& cellCentres = mesh_.cellCentres();
label oldNRefine = nRefine;
const label oldNRefine = nRefine;
// Use cached surfaceIndex_ to detect if any intersection. If so
// re-intersect to determine level wanted.
@ -935,9 +933,9 @@ Foam::label Foam::meshRefinement::markSurfaceRefinement
forAll(testFaces, i)
{
label facei = testFaces[i];
const label facei = testFaces[i];
label own = mesh_.faceOwner()[facei];
const label own = mesh_.faceOwner()[facei];
if (mesh_.isInternalFace(facei))
{
@ -949,7 +947,7 @@ Foam::label Foam::meshRefinement::markSurfaceRefinement
}
else
{
label bFacei = facei - mesh_.nInternalFaces();
const label bFacei = facei - mesh_.nInternalFaces();
start[i] = cellCentres[own];
end[i] = neiCc[bFacei];
@ -986,9 +984,9 @@ Foam::label Foam::meshRefinement::markSurfaceRefinement
forAll(testFaces, i)
{
label facei = testFaces[i];
const label facei = testFaces[i];
label surfI = surfaceHit[i];
const label surfI = surfaceHit[i];
if (surfI != -1)
{
@ -998,7 +996,7 @@ Foam::label Foam::meshRefinement::markSurfaceRefinement
// do the check with the surfaceMinLevel whilst intersecting the
// surfaces?
label own = mesh_.faceOwner()[facei];
const label own = mesh_.faceOwner()[facei];
if (surfaceMinLevel[i] > cellLevel[own])
{
@ -1020,7 +1018,8 @@ Foam::label Foam::meshRefinement::markSurfaceRefinement
if (mesh_.isInternalFace(facei))
{
label nei = mesh_.faceNeighbour()[facei];
const label nei = mesh_.faceNeighbour()[facei];
if (surfaceMinLevel[i] > cellLevel[nei])
{
// Neighbour needs refining
@ -1100,7 +1099,7 @@ Foam::label Foam::meshRefinement::markSurfaceCurvatureRefinement
const labelList& cellLevel = meshCutter_.cellLevel();
const pointField& cellCentres = mesh_.cellCentres();
label oldNRefine = nRefine;
const label oldNRefine = nRefine;
// 1. local test: any cell on more than one surface gets refined
// (if its current level is < max of the surface max level)
@ -1123,13 +1122,12 @@ Foam::label Foam::meshRefinement::markSurfaceCurvatureRefinement
forAll(testFaces, i)
{
label facei = testFaces[i];
label own = mesh_.faceOwner()[facei];
const label facei = testFaces[i];
const label own = mesh_.faceOwner()[facei];
if (mesh_.isInternalFace(facei))
{
label nei = mesh_.faceNeighbour()[facei];
const label nei = mesh_.faceNeighbour()[facei];
start[i] = cellCentres[own];
end[i] = cellCentres[nei];
@ -1137,7 +1135,7 @@ Foam::label Foam::meshRefinement::markSurfaceCurvatureRefinement
}
else
{
label bFacei = facei - mesh_.nInternalFaces();
const label bFacei = facei - mesh_.nInternalFaces();
start[i] = cellCentres[own];
end[i] = neiCc[bFacei];
@ -1167,6 +1165,7 @@ Foam::label Foam::meshRefinement::markSurfaceCurvatureRefinement
{
// Per segment the normals of the surfaces
List<vectorList> surfaceNormal;
// Per segment the list of levels of the surfaces
labelListList surfaceLevel;
@ -1207,8 +1206,8 @@ Foam::label Foam::meshRefinement::markSurfaceCurvatureRefinement
// Convert face-wise data to cell.
forAll(testFaces, i)
{
label facei = testFaces[i];
label own = mesh_.faceOwner()[facei];
const label facei = testFaces[i];
const label own = mesh_.faceOwner()[facei];
const vectorList& fNormals = surfaceNormal[i];
const labelList& fLevels = surfaceLevel[i];
@ -1284,7 +1283,7 @@ Foam::label Foam::meshRefinement::markSurfaceCurvatureRefinement
{
if ((normals[i] & normals[j]) < curvature)
{
label maxLevel = max(levels[i], levels[j]);
const label maxLevel = max(levels[i], levels[j]);
if (cellLevel[celli] < maxLevel)
{
@ -1329,8 +1328,8 @@ Foam::label Foam::meshRefinement::markSurfaceCurvatureRefinement
facei++
)
{
label own = mesh_.faceOwner()[facei];
label nei = mesh_.faceNeighbour()[facei];
const label own = mesh_.faceOwner()[facei];
const label nei = mesh_.faceNeighbour()[facei];
const vectorList& ownNormals = cellSurfNormals[own];
const labelList& ownLevels = cellSurfLevels[own];
@ -1513,8 +1512,8 @@ bool Foam::meshRefinement::isGap
{
//- Hits differ and angles are oppositeish and
// hits have a normal distance
vector d = point1-point0;
scalar magD = mag(d);
const vector d = point1 - point0;
const scalar magD = mag(d);
if (magD > mergeDistance())
{
@ -1570,8 +1569,8 @@ bool Foam::meshRefinement::isNormalGap
{
//- Hits differ and angles are oppositeish and
// hits have a normal distance
vector d = point1-point0;
scalar magD = mag(d);
vector d = point1 - point0;
const scalar magD = mag(d);
if (magD > mergeDistance())
{
@ -1712,7 +1711,7 @@ Foam::label Foam::meshRefinement::markProximityRefinement
const labelList& cellLevel = meshCutter_.cellLevel();
const pointField& cellCentres = mesh_.cellCentres();
label oldNRefine = nRefine;
const label oldNRefine = nRefine;
// 1. local test: any cell on more than one surface gets refined
// (if its current level is < max of the surface max level)
@ -1732,13 +1731,12 @@ Foam::label Foam::meshRefinement::markProximityRefinement
forAll(testFaces, i)
{
label facei = testFaces[i];
label own = mesh_.faceOwner()[facei];
const label facei = testFaces[i];
const label own = mesh_.faceOwner()[facei];
if (mesh_.isInternalFace(facei))
{
label nei = mesh_.faceNeighbour()[facei];
const label nei = mesh_.faceNeighbour()[facei];
start[i] = cellCentres[own];
end[i] = cellCentres[nei];
@ -1746,7 +1744,7 @@ Foam::label Foam::meshRefinement::markProximityRefinement
}
else
{
label bFacei = facei - mesh_.nInternalFaces();
const label bFacei = facei - mesh_.nInternalFaces();
start[i] = cellCentres[own];
end[i] = neiCc[bFacei];
@ -1878,8 +1876,8 @@ Foam::label Foam::meshRefinement::markProximityRefinement
for (label facei = mesh_.nInternalFaces(); facei < mesh_.nFaces(); facei++)
{
label bFacei = facei-mesh_.nInternalFaces();
label own = mesh_.faceOwner()[facei];
const label bFacei = facei-mesh_.nInternalFaces();
const label own = mesh_.faceOwner()[facei];
neiBndMaxLevel[bFacei] = cellMaxLevel[own];
neiBndMaxLocation[bFacei] = cellMaxLocation[own];
@ -1894,8 +1892,8 @@ Foam::label Foam::meshRefinement::markProximityRefinement
// Internal faces
for (label facei = 0; facei < mesh_.nInternalFaces(); facei++)
{
label own = mesh_.faceOwner()[facei];
label nei = mesh_.faceNeighbour()[facei];
const label own = mesh_.faceOwner()[facei];
const label nei = mesh_.faceNeighbour()[facei];
if (cellMaxLevel[own] != -1 && cellMaxLevel[nei] != -1)
{
@ -1964,8 +1962,8 @@ Foam::label Foam::meshRefinement::markProximityRefinement
// Boundary faces
for (label facei = mesh_.nInternalFaces(); facei < mesh_.nFaces(); facei++)
{
label own = mesh_.faceOwner()[facei];
label bFacei = facei - mesh_.nInternalFaces();
const label own = mesh_.faceOwner()[facei];
const label bFacei = facei - mesh_.nInternalFaces();
if (cellLevel[own] < cellMaxLevel[own] && neiBndMaxLevel[bFacei] != -1)
{
@ -2027,7 +2025,7 @@ Foam::label Foam::meshRefinement::markProximityRefinement
// hitting overall limit maxGlobalCells.
Foam::labelList Foam::meshRefinement::refineCandidates
(
const pointField& keepPoints,
const List<point>& locationsInMesh,
const scalar curvature,
const scalar planarAngle,
@ -2041,7 +2039,7 @@ Foam::labelList Foam::meshRefinement::refineCandidates
const label maxLocalCells
) const
{
label totNCells = mesh_.globalData().nTotalCells();
const label totNCells = mesh_.globalData().nTotalCells();
labelList cellsToRefine;
@ -2073,7 +2071,7 @@ Foam::labelList Foam::meshRefinement::refineCandidates
// << endl;
//- Disable refinement shortcut. nAllowRefine is per processor limit.
label nAllowRefine = labelMax / Pstream::nProcs();
const label nAllowRefine = labelMax / Pstream::nProcs();
// Marked for refinement (>= 0) or not (-1). Actual value is the
// index of the surface it intersects.
@ -2093,9 +2091,9 @@ Foam::labelList Foam::meshRefinement::refineCandidates
if (featureRefinement)
{
label nFeatures = markFeatureRefinement
const label nFeatures = markFeatureRefinement
(
keepPoints,
locationsInMesh,
nAllowRefine,
refineCell,
@ -2111,7 +2109,7 @@ Foam::labelList Foam::meshRefinement::refineCandidates
if (featureDistanceRefinement)
{
label nShell = markInternalDistanceToFeatureRefinement
const label nShell = markInternalDistanceToFeatureRefinement
(
nAllowRefine,
@ -2127,7 +2125,7 @@ Foam::labelList Foam::meshRefinement::refineCandidates
if (internalRefinement)
{
label nShell = markInternalRefinement
const label nShell = markInternalRefinement
(
nAllowRefine,
@ -2143,7 +2141,7 @@ Foam::labelList Foam::meshRefinement::refineCandidates
if (surfaceRefinement)
{
label nSurf = markSurfaceRefinement
const label nSurf = markSurfaceRefinement
(
nAllowRefine,
neiLevel,
@ -2166,7 +2164,7 @@ Foam::labelList Foam::meshRefinement::refineCandidates
&& (surfaces_.minLevel() != surfaces_.maxLevel())
)
{
label nCurv = markSurfaceCurvatureRefinement
const label nCurv = markSurfaceCurvatureRefinement
(
curvature,
nAllowRefine,
@ -2193,7 +2191,7 @@ Foam::labelList Foam::meshRefinement::refineCandidates
Info<< "Specified gap level : " << max(surfaces_.gapLevel())
<< ", planar angle " << planarAngle << endl;
label nGap = markProximityRefinement
const label nGap = markProximityRefinement
(
planarCos,
nAllowRefine,
@ -2266,8 +2264,6 @@ Foam::autoPtr<Foam::mapPolyMesh> Foam::meshRefinement::refine
}
// Do refinement of consistent set of cells followed by truncation and
// load balancing.
Foam::autoPtr<Foam::mapDistributePolyMesh>
Foam::meshRefinement::refineAndBalance
(
@ -2310,11 +2306,11 @@ Foam::meshRefinement::refineAndBalance
if (Pstream::nProcs() > 1)
{
scalar nIdealCells =
const scalar nIdealCells =
mesh_.globalData().nTotalCells()
/ Pstream::nProcs();
scalar unbalance = returnReduce
const scalar unbalance = returnReduce
(
mag(1.0-mesh_.nCells()/nIdealCells),
maxOp<scalar>()
@ -2414,11 +2410,11 @@ Foam::meshRefinement::balanceAndRefine
{
// First check if we need to balance at all. Precalculate number of
// cells after refinement and see what maximum difference is.
scalar nNewCells = scalar(mesh_.nCells() + 7*cellsToRefine.size());
scalar nIdealNewCells =
returnReduce(nNewCells, sumOp<scalar>())
/ Pstream::nProcs();
scalar unbalance = returnReduce
const scalar nNewCells =
scalar(mesh_.nCells() + 7*cellsToRefine.size());
const scalar nIdealNewCells =
returnReduce(nNewCells, sumOp<scalar>())/Pstream::nProcs();
const scalar unbalance = returnReduce
(
mag(1.0-nNewCells/nIdealNewCells),
maxOp<scalar>()

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -30,7 +30,6 @@ License
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
// Add a T entry
template<class T> void Foam::meshRefinement::updateList
(
const labelList& newToOld,
@ -42,11 +41,11 @@ template<class T> void Foam::meshRefinement::updateList
forAll(newElems, i)
{
label oldI = newToOld[i];
const label oldi = newToOld[i];
if (oldI >= 0)
if (oldi >= 0)
{
newElems[i] = elems[oldI];
newElems[i] = elems[oldi];
}
}
@ -96,7 +95,6 @@ T Foam::meshRefinement::gAverage
}
// Compare two lists over all boundary faces
template<class T>
void Foam::meshRefinement::testSyncBoundaryFaceList
(
@ -106,7 +104,7 @@ void Foam::meshRefinement::testSyncBoundaryFaceList
const UList<T>& syncedFaceData
) const
{
label nBFaces = mesh_.nFaces() - mesh_.nInternalFaces();
const label nBFaces = mesh_.nFaces() - mesh_.nInternalFaces();
if (faceData.size() != nBFaces || syncedFaceData.size() != nBFaces)
{
@ -132,7 +130,7 @@ void Foam::meshRefinement::testSyncBoundaryFaceList
if (mag(data - syncData) > tol)
{
label facei = pp.start()+i;
const label facei = pp.start() + i;
FatalErrorInFunction
<< msg
@ -210,8 +208,8 @@ int Foam::meshRefinement::readFlags
forAll(words, i)
{
int index = namedEnum[words[i]];
int val = 1<<index;
const int index = namedEnum[words[i]];
const int val = 1<<index;
flags |= val;
}
return flags;
@ -256,10 +254,10 @@ void Foam::meshRefinement::weightedSum
{
const edge& e = edges[edgeI];
scalar eWeight = edgeWeights[edgeI];
const scalar eWeight = edgeWeights[edgeI];
label v0 = e[0];
label v1 = e[1];
const label v0 = e[0];
const label v1 = e[1];
sum[v0] += eWeight*pointData[v1];
sum[v1] += eWeight*pointData[v0];

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2013-2018 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2013-2021 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -23,8 +23,6 @@ License
\*---------------------------------------------------------------------------*/
#include "polyMesh.H"
#include "transform.H"
#include "orientedSurface.H"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
@ -104,10 +102,6 @@ inline bool Foam::patchFaceOrientation::updateEdge
const face& f = patch.localFaces()[facei];
const edge& e = patch.edges()[edgeI];
// Pout<< "Updating edge:" << edgeI << " verts:" << e << nl
// << " start:" << patch.localPoints()[e[0]] << nl
// << " end:" << patch.localPoints()[e[1]] << endl;
patchFaceOrientation consistentInfo(faceInfo);
// Check how edge relates to face
@ -118,6 +112,7 @@ inline bool Foam::patchFaceOrientation::updateEdge
}
operator=(consistentInfo);
return true;
}
@ -147,6 +142,7 @@ inline bool Foam::patchFaceOrientation::updateEdge
}
operator=(consistentInfo);
return true;
}
@ -172,14 +168,6 @@ inline bool Foam::patchFaceOrientation::updateFace
const face& f = patch.localFaces()[facei];
const edge& e = patch.edges()[edgeI];
// Pout<< "Updating face:" << facei << nl
// << " verts:" << f << nl
// << " with edge:" << edgeI << nl
// << " start:" << patch.localPoints()[e[0]] << nl
// << " end:" << patch.localPoints()[e[1]] << endl;
// Create (flipped/unflipped) version of edgeInfo
patchFaceOrientation consistentInfo(edgeInfo);
@ -189,6 +177,7 @@ inline bool Foam::patchFaceOrientation::updateFace
}
operator=(consistentInfo);
return true;
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -44,7 +44,12 @@ Foam::refinementParameters::refinementParameters(const dictionary& dict)
)
),
nBufferLayers_(dict.lookup<label>("nCellsBetweenLevels")),
keepPoints_(pointField(1, dict.lookup("locationInMesh"))),
locationsInMesh_
(
dict.found("locationsInMesh")
? List<point>(dict.lookup("locationsInMesh"))
: List<point>(1, dict.lookup("locationInMesh"))
),
allowFreeStandingZoneFaces_(dict.lookup("allowFreeStandingZoneFaces")),
useTopologicalSnapDetection_
(
@ -56,6 +61,8 @@ Foam::refinementParameters::refinementParameters(const dictionary& dict)
dict.lookupOrDefault<Switch>("handleSnapProblems", true)
)
{
InfoInFunction << locationsInMesh_ << endl;
scalar featAngle(dict.lookup<scalar>("resolveFeatureAngle"));
if (featAngle < 0 || featAngle > 180)
@ -81,13 +88,13 @@ const
globalIndex globalCells(mesh.nCells());
// Cell label per point
labelList cellLabels(keepPoints_.size());
labelList cellLabels(locationsInMesh_.size());
forAll(keepPoints_, i)
forAll(locationsInMesh_, i)
{
const point& keepPoint = keepPoints_[i];
const point& locationInMesh = locationsInMesh_[i];
label localCelli = mesh.findCell(keepPoint);
label localCelli = mesh.findCell(locationInMesh);
label globalCelli = -1;
@ -101,7 +108,7 @@ const
if (globalCelli == -1)
{
FatalErrorInFunction
<< "Point " << keepPoint
<< "Point " << locationInMesh
<< " is not inside the mesh or on a face or edge." << nl
<< "Bounding box of the mesh:" << mesh.bounds()
<< exit(FatalError);
@ -111,7 +118,7 @@ const
label proci = globalCells.whichProcID(globalCelli);
label procCelli = globalCells.toLocal(proci, globalCelli);
Info<< "Found point " << keepPoint << " in cell " << procCelli
Info<< "Found point " << locationInMesh << " in cell " << procCelli
<< " on processor " << proci << endl;

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -36,7 +36,8 @@ SourceFiles
#define refinementParameters_H
#include "dictionary.H"
#include "pointField.H"
#include "labelList.H"
#include "point.H"
#include "Switch.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -74,7 +75,7 @@ class refinementParameters
const label nBufferLayers_;
//- Areas to keep
const pointField keepPoints_;
const List<point> locationsInMesh_;
//- FaceZone faces allowed which have owner and neighbour in same
// cellZone?
@ -141,10 +142,10 @@ public:
return nBufferLayers_;
}
//- Areas to keep
const pointField& keepPoints() const
//- Locations in to select meshed regions
const List<point>& locationsInMesh() const
{
return keepPoints_;
return locationsInMesh_;
}
//- Are zone faces allowed only in between different cell zones

View File

@ -94,7 +94,7 @@ Foam::label Foam::snappyRefineDriver::featureEdgeRefine
(
meshRefiner_.refineCandidates
(
refineParams.keepPoints(),
refineParams.locationsInMesh(),
refineParams.curvature(),
refineParams.planarAngle(),
@ -207,7 +207,7 @@ Foam::label Foam::snappyRefineDriver::surfaceOnlyRefine
(
meshRefiner_.refineCandidates
(
refineParams.keepPoints(),
refineParams.locationsInMesh(),
refineParams.curvature(),
refineParams.planarAngle(),
@ -341,7 +341,7 @@ Foam::label Foam::snappyRefineDriver::gapOnlyRefine
(
meshRefiner_.refineCandidates
(
refineParams.keepPoints(),
refineParams.locationsInMesh(),
refineParams.curvature(),
refineParams.planarAngle(),
@ -692,7 +692,7 @@ void Foam::snappyRefineDriver::removeInsideCells
nBufferLayers, // nBufferLayers
globalToMasterPatch_,
globalToSlavePatch_,
refineParams.keepPoints()[0]
refineParams.locationsInMesh()
);
if (debug&meshRefinement::MESH)
@ -753,7 +753,7 @@ Foam::label Foam::snappyRefineDriver::shellRefine
(
meshRefiner_.refineCandidates
(
refineParams.keepPoints(),
refineParams.locationsInMesh(),
refineParams.curvature(),
refineParams.planarAngle(),
@ -921,7 +921,7 @@ void Foam::snappyRefineDriver::baffleAndSplitMesh
const_cast<Time&>(mesh.time()),
globalToMasterPatch_,
globalToSlavePatch_,
refineParams.keepPoints()[0]
refineParams.locationsInMesh()
);
}
@ -956,7 +956,7 @@ void Foam::snappyRefineDriver::zonify
meshRefiner_.zonify
(
refineParams.keepPoints()[0],
refineParams.locationsInMesh(),
refineParams.allowFreeStandingZoneFaces()
);
@ -1023,7 +1023,7 @@ void Foam::snappyRefineDriver::splitAndMergeBaffles
const_cast<Time&>(mesh.time()),
globalToMasterPatch_,
globalToSlavePatch_,
refineParams.keepPoints()[0]
refineParams.locationsInMesh()
);
if (debug)
@ -1061,7 +1061,7 @@ void Foam::snappyRefineDriver::splitAndMergeBaffles
(
globalToMasterPatch_,
globalToSlavePatch_,
refineParams.keepPoints()[0]
refineParams.locationsInMesh()
);
if (debug)
@ -1197,7 +1197,7 @@ void Foam::snappyRefineDriver::doRefine
);
// Introduce baffles at surface intersections. Remove sections unreachable
// from keepPoint.
// from locationInMesh.
baffleAndSplitMesh
(
refineParams,