mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: regionToCell: allow multiple regions and erosion
This commit is contained in:
@ -167,8 +167,10 @@ FoamFile
|
|||||||
// source regionToCell;
|
// source regionToCell;
|
||||||
// sourceInfo
|
// sourceInfo
|
||||||
// {
|
// {
|
||||||
// set c0; // name of cellSet giving mesh subset
|
// set c0; // optional name of cellSet giving mesh subset
|
||||||
// insidePoint (1 2 3); // point inside region to select
|
// insidePoints ((1 2 3)); // points inside region to select
|
||||||
|
// nErode 0; // optional number of layers to erode
|
||||||
|
// // selection
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// // Cells underneath plane such that volume is reached. E.g. for use
|
// // Cells underneath plane such that volume is reached. E.g. for use
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -24,12 +24,10 @@ License
|
|||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#include "regionToCell.H"
|
#include "regionToCell.H"
|
||||||
#include "polyMesh.H"
|
|
||||||
#include "regionSplit.H"
|
#include "regionSplit.H"
|
||||||
#include "globalMeshData.H"
|
#include "emptyPolyPatch.H"
|
||||||
#include "cellSet.H"
|
#include "cellSet.H"
|
||||||
#include "syncTools.H"
|
#include "syncTools.H"
|
||||||
|
|
||||||
#include "addToRunTimeSelectionTable.H"
|
#include "addToRunTimeSelectionTable.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||||
@ -49,104 +47,339 @@ addToRunTimeSelectionTable(topoSetSource, regionToCell, istream);
|
|||||||
Foam::topoSetSource::addToUsageTable Foam::regionToCell::usage_
|
Foam::topoSetSource::addToUsageTable Foam::regionToCell::usage_
|
||||||
(
|
(
|
||||||
regionToCell::typeName,
|
regionToCell::typeName,
|
||||||
"\n Usage: regionToCell subCellSet (x y z)\n\n"
|
"\n Usage: regionToCell subCellSet (pt0 .. ptn)\n\n"
|
||||||
" Select all cells in the connected region containing point.\n"
|
" Select all cells in the connected region containing"
|
||||||
" If started inside the subCellSet keeps to it;\n"
|
" points (pt0..ptn).\n"
|
||||||
" if started outside stays outside.\n"
|
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
|
void Foam::regionToCell::markRegionFaces
|
||||||
|
(
|
||||||
|
const boolList& selectedCell,
|
||||||
|
boolList& regionFace
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
// Internal faces
|
||||||
|
const labelList& faceOwner = mesh_.faceOwner();
|
||||||
|
const labelList& faceNeighbour = mesh_.faceNeighbour();
|
||||||
|
forAll(faceNeighbour, faceI)
|
||||||
|
{
|
||||||
|
if
|
||||||
|
(
|
||||||
|
selectedCell[faceOwner[faceI]]
|
||||||
|
!= selectedCell[faceNeighbour[faceI]]
|
||||||
|
)
|
||||||
|
{
|
||||||
|
regionFace[faceI] = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Swap neighbour selectedCell state
|
||||||
|
boolList nbrSelected;
|
||||||
|
syncTools::swapBoundaryCellList(mesh_, selectedCell, nbrSelected);
|
||||||
|
|
||||||
|
// Boundary faces
|
||||||
|
const polyBoundaryMesh& pbm = mesh_.boundaryMesh();
|
||||||
|
forAll(pbm, patchI)
|
||||||
|
{
|
||||||
|
const polyPatch& pp = pbm[patchI];
|
||||||
|
const labelUList& faceCells = pp.faceCells();
|
||||||
|
forAll(faceCells, i)
|
||||||
|
{
|
||||||
|
label faceI = pp.start()+i;
|
||||||
|
label bFaceI = faceI-mesh_.nInternalFaces();
|
||||||
|
if
|
||||||
|
(
|
||||||
|
selectedCell[faceCells[i]]
|
||||||
|
!= selectedCell[nbrSelected[bFaceI]]
|
||||||
|
)
|
||||||
|
{
|
||||||
|
regionFace[faceI] = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::boolList Foam::regionToCell::findRegions
|
||||||
|
(
|
||||||
|
const bool verbose,
|
||||||
|
const regionSplit& cellRegion
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
boolList keepRegion(cellRegion.nRegions(), false);
|
||||||
|
|
||||||
|
forAll(insidePoints_, i)
|
||||||
|
{
|
||||||
|
// Find the region containing the insidePoint
|
||||||
|
|
||||||
|
label cellI = mesh_.findCell(insidePoints_[i]);
|
||||||
|
|
||||||
|
label keepRegionI = -1;
|
||||||
|
label keepProcI = -1;
|
||||||
|
if (cellI != -1)
|
||||||
|
{
|
||||||
|
keepRegionI = cellRegion[cellI];
|
||||||
|
keepProcI = Pstream::myProcNo();
|
||||||
|
}
|
||||||
|
reduce(keepRegionI, maxOp<label>());
|
||||||
|
keepRegion[keepRegionI] = true;
|
||||||
|
|
||||||
|
reduce(keepProcI, maxOp<label>());
|
||||||
|
|
||||||
|
if (keepProcI == -1)
|
||||||
|
{
|
||||||
|
FatalErrorIn
|
||||||
|
(
|
||||||
|
"outsideCellSelection::findRegions"
|
||||||
|
"(const bool, const regionSplit&)"
|
||||||
|
) << "Did not find " << insidePoints_[i]
|
||||||
|
<< " in mesh." << " Mesh bounds are " << mesh_.bounds()
|
||||||
|
<< exit(FatalError);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (verbose)
|
||||||
|
{
|
||||||
|
Info<< "Found location " << insidePoints_[i]
|
||||||
|
<< " in cell " << cellI << " on processor " << keepProcI
|
||||||
|
<< " in global region " << keepRegionI
|
||||||
|
<< " out of " << cellRegion.nRegions() << " regions." << endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return keepRegion;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Foam::regionToCell::unselectOutsideRegions
|
||||||
|
(
|
||||||
|
boolList& selectedCell
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
// Determine faces on the edge of selectedCell
|
||||||
|
boolList blockedFace(mesh_.nFaces(), false);
|
||||||
|
markRegionFaces(selectedCell, blockedFace);
|
||||||
|
|
||||||
|
// Determine regions
|
||||||
|
regionSplit cellRegion(mesh_, blockedFace);
|
||||||
|
|
||||||
|
// Determine regions containing insidePoints_
|
||||||
|
boolList keepRegion(findRegions(true, cellRegion));
|
||||||
|
|
||||||
|
// Go back to bool per cell
|
||||||
|
forAll(cellRegion, cellI)
|
||||||
|
{
|
||||||
|
if (!keepRegion[cellRegion[cellI]])
|
||||||
|
{
|
||||||
|
selectedCell[cellI] = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Foam::regionToCell::shrinkRegions
|
||||||
|
(
|
||||||
|
boolList& selectedCell
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
// Select points on unselected cells and boundary
|
||||||
|
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
boolList boundaryPoint(mesh_.nPoints(), false);
|
||||||
|
|
||||||
|
const polyBoundaryMesh& pbm = mesh_.boundaryMesh();
|
||||||
|
|
||||||
|
forAll(pbm, patchI)
|
||||||
|
{
|
||||||
|
const polyPatch& pp = pbm[patchI];
|
||||||
|
|
||||||
|
if (!pp.coupled() && !isA<emptyPolyPatch>(pp))
|
||||||
|
{
|
||||||
|
forAll(pp, i)
|
||||||
|
{
|
||||||
|
const face& f = pp[i];
|
||||||
|
forAll(f, fp)
|
||||||
|
{
|
||||||
|
boundaryPoint[f[fp]] = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
forAll(selectedCell, cellI)
|
||||||
|
{
|
||||||
|
if (!selectedCell[cellI])
|
||||||
|
{
|
||||||
|
const labelList& cPoints = mesh_.cellPoints(cellI);
|
||||||
|
forAll(cPoints, i)
|
||||||
|
{
|
||||||
|
boundaryPoint[cPoints[i]] = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
syncTools::syncPointList(mesh_, boundaryPoint, orEqOp<bool>(), false);
|
||||||
|
|
||||||
|
|
||||||
|
// Select all cells using these points
|
||||||
|
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
label nChanged = 0;
|
||||||
|
forAll(boundaryPoint, pointI)
|
||||||
|
{
|
||||||
|
if (boundaryPoint[pointI])
|
||||||
|
{
|
||||||
|
const labelList& pCells = mesh_.pointCells(pointI);
|
||||||
|
forAll(pCells, i)
|
||||||
|
{
|
||||||
|
label cellI = pCells[i];
|
||||||
|
if (selectedCell[cellI])
|
||||||
|
{
|
||||||
|
selectedCell[cellI] = false;
|
||||||
|
nChanged++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Foam::regionToCell::erode
|
||||||
|
(
|
||||||
|
boolList& selectedCell
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
//Info<< "Entering shrinkRegions:" << count(selectedCell) << endl;
|
||||||
|
//generateField("selectedCell_before", selectedCell)().write();
|
||||||
|
|
||||||
|
// Now erode and see which regions get disconnected
|
||||||
|
boolList shrunkSelectedCell(selectedCell);
|
||||||
|
|
||||||
|
for (label iter = 0; iter < nErode_; iter++)
|
||||||
|
{
|
||||||
|
shrinkRegions(shrunkSelectedCell);
|
||||||
|
}
|
||||||
|
|
||||||
|
//Info<< "After shrinking:" << count(shrunkSelectedCell) << endl;
|
||||||
|
//generateField("shrunkSelectedCell", shrunkSelectedCell)().write();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Determine faces on the edge of shrunkSelectedCell
|
||||||
|
boolList blockedFace(mesh_.nFaces(), false);
|
||||||
|
markRegionFaces(shrunkSelectedCell, blockedFace);
|
||||||
|
|
||||||
|
// Find disconnected regions
|
||||||
|
regionSplit cellRegion(mesh_, blockedFace);
|
||||||
|
|
||||||
|
// Determine regions containing insidePoints
|
||||||
|
boolList keepRegion(findRegions(true, cellRegion));
|
||||||
|
|
||||||
|
|
||||||
|
// Extract cells in regions that are not to be kept.
|
||||||
|
boolList removeCell(mesh_.nCells(), false);
|
||||||
|
forAll(cellRegion, cellI)
|
||||||
|
{
|
||||||
|
if (shrunkSelectedCell[cellI] && !keepRegion[cellRegion[cellI]])
|
||||||
|
{
|
||||||
|
removeCell[cellI] = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//Info<< "removeCell before:" << count(removeCell) << endl;
|
||||||
|
//generateField("removeCell_before", removeCell)().write();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Grow removeCell
|
||||||
|
for (label iter = 0; iter < nErode_; iter++)
|
||||||
|
{
|
||||||
|
// Grow selected cell in regions that are not for keeping
|
||||||
|
boolList boundaryPoint(mesh_.nPoints(), false);
|
||||||
|
forAll(removeCell, cellI)
|
||||||
|
{
|
||||||
|
if (removeCell[cellI])
|
||||||
|
{
|
||||||
|
const labelList& cPoints = mesh_.cellPoints(cellI);
|
||||||
|
forAll(cPoints, i)
|
||||||
|
{
|
||||||
|
boundaryPoint[cPoints[i]] = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
syncTools::syncPointList(mesh_, boundaryPoint, orEqOp<bool>(), false);
|
||||||
|
|
||||||
|
// Select all cells using these points
|
||||||
|
|
||||||
|
label nChanged = 0;
|
||||||
|
forAll(boundaryPoint, pointI)
|
||||||
|
{
|
||||||
|
if (boundaryPoint[pointI])
|
||||||
|
{
|
||||||
|
const labelList& pCells = mesh_.pointCells(pointI);
|
||||||
|
forAll(pCells, i)
|
||||||
|
{
|
||||||
|
label cellI = pCells[i];
|
||||||
|
if (!removeCell[cellI])
|
||||||
|
{
|
||||||
|
removeCell[cellI] = true;
|
||||||
|
nChanged++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//Info<< "removeCell after:" << count(removeCell) << endl;
|
||||||
|
//generateField("removeCell_after", removeCell)().write();
|
||||||
|
|
||||||
|
|
||||||
|
// Unmark removeCell
|
||||||
|
forAll(removeCell, cellI)
|
||||||
|
{
|
||||||
|
if (removeCell[cellI])
|
||||||
|
{
|
||||||
|
selectedCell[cellI] = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void Foam::regionToCell::combine(topoSet& set, const bool add) const
|
void Foam::regionToCell::combine(topoSet& set, const bool add) const
|
||||||
{
|
{
|
||||||
label cellI = mesh_.findCell(insidePoint_);
|
// Note: wip. Select cells first
|
||||||
|
boolList selectedCell(mesh_.nCells(), true);
|
||||||
|
|
||||||
// Load the subset of cells
|
if (setName_.size() && setName_ != "none")
|
||||||
boolList blockedFace(mesh_.nFaces(), false);
|
|
||||||
{
|
{
|
||||||
Info<< "Loading subset " << setName_ << " to delimit search region."
|
Info<< "Loading subset " << setName_ << " to delimit search region."
|
||||||
<< endl;
|
<< endl;
|
||||||
cellSet subSet(mesh_, setName_);
|
cellSet subSet(mesh_, setName_);
|
||||||
|
|
||||||
boolList inSubset(mesh_.nCells(), false);
|
selectedCell = false;
|
||||||
forAllConstIter(cellSet, subSet, iter)
|
forAllConstIter(cellSet, subSet, iter)
|
||||||
{
|
{
|
||||||
inSubset[iter.key()] = true;
|
selectedCell[iter.key()] = true;
|
||||||
}
|
|
||||||
|
|
||||||
if (cellI != -1 && inSubset[cellI])
|
|
||||||
{
|
|
||||||
Pout<< "Point " << insidePoint_ << " is inside cellSet "
|
|
||||||
<< setName_ << endl
|
|
||||||
<< "Collecting all cells connected to " << cellI
|
|
||||||
<< " and inside cellSet " << setName_ << endl;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Pout<< "Point " << insidePoint_ << " is outside cellSet "
|
|
||||||
<< setName_ << endl
|
|
||||||
<< "Collecting all cells connected to " << cellI
|
|
||||||
<< " and outside cellSet " << setName_ << endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get coupled cell status
|
|
||||||
label nInt = mesh_.nInternalFaces();
|
|
||||||
boolList neiSet(mesh_.nFaces()-nInt, false);
|
|
||||||
for (label faceI = nInt; faceI < mesh_.nFaces(); faceI++)
|
|
||||||
{
|
|
||||||
neiSet[faceI-nInt] = inSubset[mesh_.faceOwner()[faceI]];
|
|
||||||
}
|
|
||||||
syncTools::swapBoundaryFaceList(mesh_, neiSet);
|
|
||||||
|
|
||||||
// Find faces inbetween subSet and non-subset.
|
|
||||||
for (label faceI = 0; faceI < nInt; faceI++)
|
|
||||||
{
|
|
||||||
bool ownInSet = inSubset[mesh_.faceOwner()[faceI]];
|
|
||||||
bool neiInSet = inSubset[mesh_.faceNeighbour()[faceI]];
|
|
||||||
blockedFace[faceI] = (ownInSet != neiInSet);
|
|
||||||
}
|
|
||||||
for (label faceI = nInt; faceI < mesh_.nFaces(); faceI++)
|
|
||||||
{
|
|
||||||
bool ownInSet = inSubset[mesh_.faceOwner()[faceI]];
|
|
||||||
bool neiInSet = neiSet[faceI-nInt];
|
|
||||||
blockedFace[faceI] = (ownInSet != neiInSet);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Find connected regions without crossing boundary of the cellset.
|
|
||||||
regionSplit regions(mesh_, blockedFace);
|
|
||||||
|
|
||||||
// Get the region containing the insidePoint
|
unselectOutsideRegions(selectedCell);
|
||||||
label regionI = -1;
|
|
||||||
|
|
||||||
if (cellI != -1)
|
if (nErode_ > 0)
|
||||||
{
|
{
|
||||||
// On processor that has found cell.
|
erode(selectedCell);
|
||||||
regionI = regions[cellI];
|
|
||||||
}
|
|
||||||
|
|
||||||
reduce(regionI, maxOp<label>());
|
|
||||||
|
|
||||||
if (regionI == -1)
|
|
||||||
{
|
|
||||||
WarningIn
|
|
||||||
(
|
|
||||||
"regionToCell::combine(topoSet&, const bool) const"
|
|
||||||
) << "Point " << insidePoint_
|
|
||||||
<< " is not inside the mesh." << nl
|
|
||||||
<< "Bounding box of the mesh:" << mesh_.bounds()
|
|
||||||
<< endl;
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Pick up the cells of the region
|
forAll(selectedCell, cellI)
|
||||||
const labelList regionCells(findIndices(regions, regionI));
|
|
||||||
|
|
||||||
forAll(regionCells, i)
|
|
||||||
{
|
{
|
||||||
addOrDelete(set, regionCells[i], add);
|
if (selectedCell[cellI])
|
||||||
|
{
|
||||||
|
addOrDelete(set, cellI, add);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -158,12 +391,14 @@ Foam::regionToCell::regionToCell
|
|||||||
(
|
(
|
||||||
const polyMesh& mesh,
|
const polyMesh& mesh,
|
||||||
const word& setName,
|
const word& setName,
|
||||||
const point& insidePoint
|
const pointField& insidePoints,
|
||||||
|
const label nErode
|
||||||
)
|
)
|
||||||
:
|
:
|
||||||
topoSetSource(mesh),
|
topoSetSource(mesh),
|
||||||
setName_(setName),
|
setName_(setName),
|
||||||
insidePoint_(insidePoint)
|
insidePoints_(insidePoints),
|
||||||
|
nErode_(nErode)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
@ -175,8 +410,14 @@ Foam::regionToCell::regionToCell
|
|||||||
)
|
)
|
||||||
:
|
:
|
||||||
topoSetSource(mesh),
|
topoSetSource(mesh),
|
||||||
setName_(dict.lookup("set")),
|
setName_(dict.lookupOrDefault<word>("set", "none")),
|
||||||
insidePoint_(dict.lookup("insidePoint"))
|
insidePoints_
|
||||||
|
(
|
||||||
|
dict.found("insidePoints")
|
||||||
|
? dict.lookup("insidePoints")
|
||||||
|
: dict.lookup("insidePoint")
|
||||||
|
),
|
||||||
|
nErode_(dict.lookupOrDefault("nErode", 0))
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
@ -189,7 +430,8 @@ Foam::regionToCell::regionToCell
|
|||||||
:
|
:
|
||||||
topoSetSource(mesh),
|
topoSetSource(mesh),
|
||||||
setName_(checkIs(is)),
|
setName_(checkIs(is)),
|
||||||
insidePoint_(checkIs(is))
|
insidePoints_(checkIs(is)),
|
||||||
|
nErode_(0)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
@ -209,15 +451,15 @@ void Foam::regionToCell::applyToSet
|
|||||||
{
|
{
|
||||||
if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD))
|
if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD))
|
||||||
{
|
{
|
||||||
Info<< " Adding all cells of connected region containing point "
|
Info<< " Adding all cells of connected region containing points "
|
||||||
<< insidePoint_ << " ..." << endl;
|
<< insidePoints_ << " ..." << endl;
|
||||||
|
|
||||||
combine(set, true);
|
combine(set, true);
|
||||||
}
|
}
|
||||||
else if (action == topoSetSource::DELETE)
|
else if (action == topoSetSource::DELETE)
|
||||||
{
|
{
|
||||||
Info<< " Removing all cells of connected region containing point "
|
Info<< " Removing all cells of connected region containing points "
|
||||||
<< insidePoint_ << " ..." << endl;
|
<< insidePoints_ << " ..." << endl;
|
||||||
|
|
||||||
combine(set, false);
|
combine(set, false);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -26,7 +26,20 @@ Class
|
|||||||
|
|
||||||
Description
|
Description
|
||||||
TopoSetSource. Select cells belonging to topological connected region
|
TopoSetSource. Select cells belonging to topological connected region
|
||||||
(that contains given point)
|
(that contains given points)
|
||||||
|
|
||||||
|
In dictionary input:
|
||||||
|
|
||||||
|
// optional name of cellSet delimiting search
|
||||||
|
set c0;
|
||||||
|
|
||||||
|
//- Number of cell layers to erode mesh to detect holes in the mesh
|
||||||
|
// Set to 0 if not used.
|
||||||
|
nErode 3;
|
||||||
|
|
||||||
|
// points inside region to select
|
||||||
|
insidePoints ((1 2 3));
|
||||||
|
|
||||||
|
|
||||||
SourceFiles
|
SourceFiles
|
||||||
regionToCell.C
|
regionToCell.C
|
||||||
@ -37,12 +50,15 @@ SourceFiles
|
|||||||
#define regionToCell_H
|
#define regionToCell_H
|
||||||
|
|
||||||
#include "topoSetSource.H"
|
#include "topoSetSource.H"
|
||||||
|
#include "boolList.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
namespace Foam
|
namespace Foam
|
||||||
{
|
{
|
||||||
|
|
||||||
|
class regionSplit;
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*\
|
/*---------------------------------------------------------------------------*\
|
||||||
Class regionToCell Declaration
|
Class regionToCell Declaration
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
@ -58,14 +74,38 @@ class regionToCell
|
|||||||
static addToUsageTable usage_;
|
static addToUsageTable usage_;
|
||||||
|
|
||||||
//- Name of cellSet to keep to
|
//- Name of cellSet to keep to
|
||||||
word setName_;
|
const word setName_;
|
||||||
|
|
||||||
//- Coordinate that is inside connected region
|
//- Coordinate(s) that is inside connected region
|
||||||
point insidePoint_;
|
const pointField insidePoints_;
|
||||||
|
|
||||||
|
//- Number of layers to erode
|
||||||
|
const label nErode_;
|
||||||
|
|
||||||
|
|
||||||
// Private Member Functions
|
// Private Member Functions
|
||||||
|
|
||||||
|
//- Mark faces inbetween selected and unselected elements
|
||||||
|
void markRegionFaces
|
||||||
|
(
|
||||||
|
const boolList& selectedCell,
|
||||||
|
boolList& regionFace
|
||||||
|
) const;
|
||||||
|
|
||||||
|
//- Determine for every disconnected region in the mesh whether
|
||||||
|
// it contains a locationInMesh
|
||||||
|
boolList findRegions(const bool verbose, const regionSplit&) const;
|
||||||
|
|
||||||
|
//- Unselect regions not containing a locationInMesh
|
||||||
|
void unselectOutsideRegions(boolList& selectedCell) const;
|
||||||
|
|
||||||
|
//- Unselect one layer of cells from selectedCell
|
||||||
|
void shrinkRegions(boolList& selectedCell) const;
|
||||||
|
|
||||||
|
//- Erode a given number of layers from selectedCell. Remove any
|
||||||
|
// region that gets disconnected that way.
|
||||||
|
void erode(boolList& selectedCell) const;
|
||||||
|
|
||||||
void combine(topoSet& set, const bool add) const;
|
void combine(topoSet& set, const bool add) const;
|
||||||
|
|
||||||
|
|
||||||
@ -81,7 +121,8 @@ public:
|
|||||||
(
|
(
|
||||||
const polyMesh& mesh,
|
const polyMesh& mesh,
|
||||||
const word& setName,
|
const word& setName,
|
||||||
const point& insidePoint
|
const pointField& insidePoints,
|
||||||
|
const label nErode
|
||||||
);
|
);
|
||||||
|
|
||||||
//- Construct from dictionary
|
//- Construct from dictionary
|
||||||
|
|||||||
Reference in New Issue
Block a user