ENH: cellSource postprocessing : allow all to select all cells

This commit is contained in:
mattijs
2010-06-01 17:23:47 +01:00
parent 4d60414377
commit 0b6d0300c9
2 changed files with 39 additions and 46 deletions

View File

@ -32,14 +32,11 @@ License
defineTypeNameAndDebug(Foam::fieldValues::cellSource, 0);
template<>
const char* Foam::NamedEnum<Foam::fieldValues::cellSource::sourceType, 1>::
names[] =
{
"cellZone"
};
const char* NamedEnum<fieldValues::cellSource::sourceType, 2>::
names[] = {"cellZone", "all"};
const Foam::NamedEnum<Foam::fieldValues::cellSource::sourceType, 1>
Foam::fieldValues::cellSource::sourceTypeNames_;
const NamedEnum<fieldValues::cellSource::sourceType, 2>
fieldValues::cellSource::sourceTypeNames_;
template<>
const char* Foam::NamedEnum<Foam::fieldValues::cellSource::operationType, 7>::
@ -57,6 +54,10 @@ const Foam::NamedEnum<Foam::fieldValues::cellSource::operationType, 7>
void Foam::fieldValues::cellSource::setCellZoneCells()
{
switch (source_)
{
case stCellZone:
{
label zoneId = mesh().cellZones().findZoneID(sourceName_);
if (zoneId < 0)
@ -67,25 +68,29 @@ void Foam::fieldValues::cellSource::setCellZoneCells()
<< nl << exit(FatalError);
}
const cellZone& cZone = mesh().cellZones()[zoneId];
cellId_.setSize(cZone.size());
label count = 0;
forAll(cZone, i)
{
label cellI = cZone[i];
cellId_[count] = cellI;
count++;
cellId_ = mesh().cellZones()[zoneId];
nCells_ = returnReduce(cellId_.size(), sumOp<label>());
break;
}
cellId_.setSize(count);
case stAll:
{
cellId_ = identity(mesh().nCells());
nCells_ = returnReduce(cellId_.size(), sumOp<label>());
break;
}
default:
{
FatalErrorIn("cellSource::setCellZoneCells()")
<< "Unknown source type. Valid source types are:"
<< sourceTypeNames_ << nl << exit(FatalError);
}
}
if (debug)
{
Pout<< "Original cell zone size = " << cZone.size()
<< ", new size = " << count << endl;
Pout<< "Selected source size = " << cellId_.size() << endl;
}
}
@ -94,20 +99,7 @@ void Foam::fieldValues::cellSource::setCellZoneCells()
void Foam::fieldValues::cellSource::initialise(const dictionary& dict)
{
switch (source_)
{
case stCellZone:
{
setCellZoneCells();
break;
}
default:
{
FatalErrorIn("cellSource::initialise()")
<< "Unknown source type. Valid source types are:"
<< sourceTypeNames_ << nl << exit(FatalError);
}
}
Info<< type() << " " << name_ << ":" << nl
<< " total cells = " << nCells_ << nl

View File

@ -89,7 +89,8 @@ public:
//- Source type enumeration
enum sourceType
{
stCellZone
stCellZone,
stAll
};
//- Source type names