Added ALL option for cellSource pointToCell of meshTools
This commit is contained in:
parent
ac941215d5
commit
ee7a5233e7
2 changed files with 59 additions and 9 deletions
|
@ -46,18 +46,21 @@ addToRunTimeSelectionTable(topoSetSource, pointToCell, istream);
|
||||||
Foam::topoSetSource::addToUsageTable Foam::pointToCell::usage_
|
Foam::topoSetSource::addToUsageTable Foam::pointToCell::usage_
|
||||||
(
|
(
|
||||||
pointToCell::typeName,
|
pointToCell::typeName,
|
||||||
"\n Usage: pointToCell <pointSet> any\n\n"
|
"\n Usage: pointToCell <pointSet> any|all\n\n"
|
||||||
" Select all cells with any point in the pointSet\n\n"
|
" Select cells with\n"
|
||||||
|
" -any point in the pointSet\n"
|
||||||
|
" -all points in the pointSet\n\n"
|
||||||
);
|
);
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
const char* Foam::NamedEnum<Foam::pointToCell::pointAction, 1>::names[] =
|
const char* Foam::NamedEnum<Foam::pointToCell::pointAction, 2>::names[] =
|
||||||
{
|
{
|
||||||
"any"
|
"any",
|
||||||
|
"all"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
const Foam::NamedEnum<Foam::pointToCell::pointAction, 1>
|
const Foam::NamedEnum<Foam::pointToCell::pointAction, 2>
|
||||||
Foam::pointToCell::pointActionNames_;
|
Foam::pointToCell::pointActionNames_;
|
||||||
|
|
||||||
|
|
||||||
|
@ -69,9 +72,9 @@ void Foam::pointToCell::combine(topoSet& set, const bool add) const
|
||||||
pointSet loadedSet(mesh_, setName_);
|
pointSet loadedSet(mesh_, setName_);
|
||||||
|
|
||||||
|
|
||||||
// Handle any selection
|
|
||||||
if (option_ == ANY)
|
if (option_ == ANY)
|
||||||
{
|
{
|
||||||
|
// Add cells with any point in loadedSet
|
||||||
for
|
for
|
||||||
(
|
(
|
||||||
pointSet::const_iterator iter = loadedSet.begin();
|
pointSet::const_iterator iter = loadedSet.begin();
|
||||||
|
@ -89,6 +92,53 @@ void Foam::pointToCell::combine(topoSet& set, const bool add) const
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (option_ == ALL)
|
||||||
|
{
|
||||||
|
// Add all cells whose points are all in set.
|
||||||
|
|
||||||
|
Map<label> numPoints(loadedSet.size());
|
||||||
|
|
||||||
|
forAllConstIter(pointSet, loadedSet, iter)
|
||||||
|
{
|
||||||
|
label pointI = iter.key();
|
||||||
|
|
||||||
|
const labelList& pCells = mesh_.pointCells()[pointI];
|
||||||
|
|
||||||
|
forAll(pCells, pCellI)
|
||||||
|
{
|
||||||
|
label cellI = pCells[pCellI];
|
||||||
|
|
||||||
|
Map<label>::iterator fndCell = numPoints.find(cellI);
|
||||||
|
|
||||||
|
if (fndCell == numPoints.end())
|
||||||
|
{
|
||||||
|
numPoints.insert(cellI, 1);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fndCell()++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Include cells that are referenced as many times as there are points
|
||||||
|
// in cell -> all points of cell
|
||||||
|
for
|
||||||
|
(
|
||||||
|
Map<label>::const_iterator iter = numPoints.begin();
|
||||||
|
iter != numPoints.end();
|
||||||
|
++iter
|
||||||
|
)
|
||||||
|
{
|
||||||
|
label cellI = iter.key();
|
||||||
|
|
||||||
|
if (iter() == mesh_.cellPoints()[cellI].size())
|
||||||
|
{
|
||||||
|
addOrDelete(set, cellI, add);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -55,8 +55,8 @@ public:
|
||||||
//- Enumeration defining the valid options
|
//- Enumeration defining the valid options
|
||||||
enum pointAction
|
enum pointAction
|
||||||
{
|
{
|
||||||
ANY // Cells using any point in set
|
ANY, // Cells using any point in set
|
||||||
//ALL // Possible extension: cells whose all points are in set
|
ALL // Cells whose all points are in set
|
||||||
};
|
};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -64,7 +64,7 @@ private:
|
||||||
//- Add usage string
|
//- Add usage string
|
||||||
static addToUsageTable usage_;
|
static addToUsageTable usage_;
|
||||||
|
|
||||||
static const NamedEnum<pointAction, 1> pointActionNames_;
|
static const NamedEnum<pointAction, 2> pointActionNames_;
|
||||||
|
|
||||||
//- Name of set to use
|
//- Name of set to use
|
||||||
word setName_;
|
word setName_;
|
||||||
|
|
Reference in a new issue