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

View File

@ -225,7 +225,7 @@ private:
// Get cells which are inside any closed surface. Note that // Get cells which are inside any closed surface. Note that
// all closed surfaces // 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; labelList getInsideCells(const word&) const;
// Do all to remove inside cells // Do all to remove inside cells
@ -253,7 +253,7 @@ private:
// (or -1 if not passed through). Uses tracking. // (or -1 if not passed through). Uses tracking.
void markFeatureCellLevel void markFeatureCellLevel
( (
const pointField& keepPoints, const List<point>& locationsInMesh,
labelList& maxFeatureLevel labelList& maxFeatureLevel
) const; ) const;
@ -261,7 +261,7 @@ private:
// features. // features.
label markFeatureRefinement label markFeatureRefinement
( (
const pointField& keepPoints, const List<point>& locationsInMesh,
const label nAllowRefine, const label nAllowRefine,
labelList& refineCell, labelList& refineCell,
@ -431,6 +431,12 @@ private:
//- Returns list with for every internal face -1 or the patch //- Returns list with for every internal face -1 or the patch
// they should be baffled into. If removeEdgeConnectedCells is set // they should be baffled into. If removeEdgeConnectedCells is set
// removes cells based on perpendicularAngle. // 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 labelList markFacesOnProblemCells
( (
const dictionary& motionDict, const dictionary& motionDict,
@ -503,7 +509,7 @@ private:
// marked in namedSurfaceIndex regarded as blocked. // marked in namedSurfaceIndex regarded as blocked.
void findCellZoneTopo void findCellZoneTopo
( (
const point& keepPoint, const List<point>& locationsInMesh,
const labelList& namedSurfaceIndex, const labelList& namedSurfaceIndex,
const labelList& surfaceToCellZone, const labelList& surfaceToCellZone,
labelList& cellToZone labelList& cellToZone
@ -773,7 +779,7 @@ public:
//- Calculate list of cells to refine. //- Calculate list of cells to refine.
labelList refineCandidates labelList refineCandidates
( (
const pointField& keepPoints, const List<point>& locationsInMesh,
const scalar curvature, const scalar curvature,
const scalar planarAngle, const scalar planarAngle,
@ -832,7 +838,7 @@ public:
Time& runTime, Time& runTime,
const labelList& globalToMasterPatch, const labelList& globalToMasterPatch,
const labelList& globalToSlavePatch, const labelList& globalToSlavePatch,
const point& keepPoint const List<point>& locationsInMesh
); );
//- Split off (with optional buffer layers) unreachable areas //- Split off (with optional buffer layers) unreachable areas
@ -842,7 +848,7 @@ public:
const label nBufferLayers, const label nBufferLayers,
const labelList& globalToMasterPatch, const labelList& globalToMasterPatch,
const labelList& globalToSlavePatch, const labelList& globalToSlavePatch,
const point& keepPoint const List<point>& locationsInMesh
); );
//- Find boundary points that connect to more than one cell //- Find boundary points that connect to more than one cell
@ -879,10 +885,10 @@ public:
//- Put faces/cells into zones according to surface specification. //- Put faces/cells into zones according to surface specification.
// Returns null if no zone surfaces present. Region containing // 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 autoPtr<mapPolyMesh> zonify
( (
const point& keepPoint, const List<point>& locationsInMesh,
const bool allowFreeStandingZoneFaces const bool allowFreeStandingZoneFaces
); );
@ -904,15 +910,25 @@ public:
const polyMesh&, const polyMesh&,
const labelList& cellRegion, const labelList& cellRegion,
const vector& perturbVec, 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 autoPtr<mapPolyMesh> splitMeshRegions
( (
const labelList& globalToMasterPatch, const labelList& globalToMasterPatch,
const labelList& globalToSlavePatch, const labelList& globalToSlavePatch,
const point& keepPoint const List<point>& locationsInMesh
); );
//- Split faces into two //- 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 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -362,7 +362,7 @@ Foam::label Foam::meshRefinement::mergePatchFacesUndo
forAll(allFaceSets, setI) forAll(allFaceSets, setI)
{ {
label oldMasterI = allFaceSets[setI][0]; const label oldMasterI = allFaceSets[setI][0];
retestFaces.insert(map().reverseFaceMap()[oldMasterI]); retestFaces.insert(map().reverseFaceMap()[oldMasterI]);
} }
updateMesh(map, growFaceCellFace(retestFaces)); updateMesh(map, growFaceCellFace(retestFaces));
@ -450,11 +450,11 @@ Foam::label Foam::meshRefinement::mergePatchFacesUndo
forAll(allFaceSets, setI) forAll(allFaceSets, setI)
{ {
label masterFacei = faceCombiner.masterFace()[setI]; const label masterFacei = faceCombiner.masterFace()[setI];
if (masterFacei != -1) if (masterFacei != -1)
{ {
label masterCellII = mesh_.faceOwner()[masterFacei]; const label masterCellII = mesh_.faceOwner()[masterFacei];
const cell& cFaces = mesh_.cells()[masterCellII]; const cell& cFaces = mesh_.cells()[masterCellII];
@ -470,7 +470,7 @@ Foam::label Foam::meshRefinement::mergePatchFacesUndo
} }
mastersToRestore.shrink(); mastersToRestore.shrink();
label nRestore = returnReduce const label nRestore = returnReduce
( (
mastersToRestore.size(), mastersToRestore.size(),
sumOp<label>() sumOp<label>()
@ -634,7 +634,7 @@ Foam::autoPtr<Foam::mapPolyMesh> Foam::meshRefinement::doRemovePoints
labelHashSet retestFaces(pointRemover.savedFaceLabels().size()); labelHashSet retestFaces(pointRemover.savedFaceLabels().size());
forAll(pointRemover.savedFaceLabels(), i) forAll(pointRemover.savedFaceLabels(), i)
{ {
label facei = pointRemover.savedFaceLabels()[i]; const label facei = pointRemover.savedFaceLabels()[i];
if (facei >= 0) if (facei >= 0)
{ {
retestFaces.insert(facei); 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 Foam::autoPtr<Foam::mapPolyMesh> Foam::meshRefinement::doRestorePoints
( (
removePoints& pointRemover, removePoints& pointRemover,
@ -705,7 +704,7 @@ Foam::autoPtr<Foam::mapPolyMesh> Foam::meshRefinement::doRestorePoints
labelHashSet retestFaces(2*facesToRestore.size()); labelHashSet retestFaces(2*facesToRestore.size());
forAll(facesToRestore, i) forAll(facesToRestore, i)
{ {
label facei = map().reverseFaceMap()[facesToRestore[i]]; const label facei = map().reverseFaceMap()[facesToRestore[i]];
if (facei >= 0) if (facei >= 0)
{ {
retestFaces.insert(facei); retestFaces.insert(facei);
@ -738,7 +737,7 @@ Foam::labelList Foam::meshRefinement::collectFaces
forAll(candidateFaces, i) forAll(candidateFaces, i)
{ {
label facei = candidateFaces[i]; const label facei = candidateFaces[i];
if (set.found(facei)) if (set.found(facei))
{ {
@ -768,9 +767,8 @@ Foam::labelList Foam::meshRefinement::growFaceCellFace
forAllConstIter(faceSet, set, iter) forAllConstIter(faceSet, set, iter)
{ {
label facei = iter.key(); const label facei = iter.key();
const label own = mesh_.faceOwner()[facei];
label own = mesh_.faceOwner()[facei];
const cell& ownFaces = mesh_.cells()[own]; const cell& ownFaces = mesh_.cells()[own];
forAll(ownFaces, ownFacei) forAll(ownFaces, ownFacei)
@ -780,7 +778,7 @@ Foam::labelList Foam::meshRefinement::growFaceCellFace
if (mesh_.isInternalFace(facei)) if (mesh_.isInternalFace(facei))
{ {
label nbr = mesh_.faceNeighbour()[facei]; const label nbr = mesh_.faceNeighbour()[facei];
const cell& nbrFaces = mesh_.cells()[nbr]; const cell& nbrFaces = mesh_.cells()[nbr];
forAll(nbrFaces, nbrFacei) 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 Info<< "Detected " << n
<< " error faces on boundaries that have been merged." << " error faces on boundaries that have been merged."

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -113,7 +113,7 @@ void Foam::meshRefinement::findNearest
} }
} }
label geomI = surfaces_.surfaces()[surfI]; const label geomI = surfaces_.surfaces()[surfI];
pointField localNormals; pointField localNormals;
surfaces_.geometry()[geomI].getNormal(localHits, localNormals); surfaces_.geometry()[geomI].getNormal(localHits, localNormals);
@ -168,11 +168,11 @@ Foam::Map<Foam::label> Foam::meshRefinement::findEdgeConnectedProblemCells
if (eFaces.size() == 2) if (eFaces.size() == 2)
{ {
label face0 = pp.addressing()[eFaces[0]]; const label face0 = pp.addressing()[eFaces[0]];
label face1 = pp.addressing()[eFaces[1]]; const label face1 = pp.addressing()[eFaces[1]];
label cell0 = mesh_.faceOwner()[face0]; const label cell0 = mesh_.faceOwner()[face0];
label cell1 = mesh_.faceOwner()[face1]; const label cell1 = mesh_.faceOwner()[face1];
if (cellLevel[cell0] > cellLevel[cell1]) if (cellLevel[cell0] > cellLevel[cell1])
{ {
@ -241,18 +241,16 @@ Foam::Map<Foam::label> Foam::meshRefinement::findEdgeConnectedProblemCells
forAll(candidateFaces, i) 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]; const label region = surfaces_.globalRegion
n /= mag(n);
label region = surfaces_.globalRegion
( (
nearestSurface[i], nearestSurface[i],
nearestRegion[i] nearestRegion[i]
); );
scalar angle = degToRad(perpendicularAngle[region]); const scalar angle = degToRad(perpendicularAngle[region]);
if (angle >= 0) 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 bool Foam::meshRefinement::isCollapsedFace
( (
const pointField& points, const pointField& points,
@ -310,10 +305,10 @@ bool Foam::meshRefinement::isCollapsedFace
if (mesh_.isInternalFace(facei)) if (mesh_.isInternalFace(facei))
{ {
label nei = mesh_.faceNeighbour()[facei]; const label nei = mesh_.faceNeighbour()[facei];
vector d = mesh_.cellCentres()[nei] - ownCc; 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) if (dDotS < severeNonorthogonalityThreshold)
{ {
@ -326,13 +321,13 @@ bool Foam::meshRefinement::isCollapsedFace
} }
else else
{ {
label patchi = mesh_.boundaryMesh().whichPatch(facei); const label patchi = mesh_.boundaryMesh().whichPatch(facei);
if (mesh_.boundaryMesh()[patchi].coupled()) 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) 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 bool Foam::meshRefinement::isCollapsedCell
( (
const pointField& points, const pointField& points,
@ -361,7 +355,7 @@ bool Foam::meshRefinement::isCollapsedCell
const label celli const label celli
) const ) 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) if (vol/mesh_.cellVolumes()[celli] < volFraction)
{ {
@ -406,7 +400,7 @@ Foam::labelList Foam::meshRefinement::nearestPatch
nFaces = 0; nFaces = 0;
forAll(adaptPatchIDs, i) forAll(adaptPatchIDs, i)
{ {
label patchi = adaptPatchIDs[i]; const label patchi = adaptPatchIDs[i];
const polyPatch& pp = patches[patchi]; const polyPatch& pp = patches[patchi];
forAll(pp, i) 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 Foam::labelList Foam::meshRefinement::markFacesOnProblemCells
( (
const dictionary& motionDict, const dictionary& motionDict,
@ -557,7 +545,7 @@ Foam::labelList Foam::meshRefinement::markFacesOnProblemCells
forAll(cFaces, i) forAll(cFaces, i)
{ {
label facei = cFaces[i]; const label facei = cFaces[i];
if (facePatch[facei] == -1 && mesh_.isInternalFace(facei)) if (facePatch[facei] == -1 && mesh_.isInternalFace(facei))
{ {
@ -731,7 +719,7 @@ Foam::labelList Foam::meshRefinement::markFacesOnProblemCells
forAll(cPoints, i) forAll(cPoints, i)
{ {
label pointi = cPoints[i]; const label pointi = cPoints[i];
if (pointLevel[pointi] <= cellLevel[celli]) if (pointLevel[pointi] <= cellLevel[celli])
{ {
@ -794,7 +782,7 @@ Foam::labelList Foam::meshRefinement::markFacesOnProblemCells
// Block all faces of cell // Block all faces of cell
forAll(cFaces, cf) forAll(cFaces, cf)
{ {
label facei = cFaces[cf]; const label facei = cFaces[cf];
if if
( (
@ -881,7 +869,7 @@ Foam::labelList Foam::meshRefinement::markFacesOnProblemCells
forAll(cFaces, cf) forAll(cFaces, cf)
{ {
label facei = cFaces[cf]; const label facei = cFaces[cf];
if if
( (

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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