Commit 0b6d0300 authored by mattijs's avatar mattijs
Browse files

ENH: cellSource postprocessing : allow all to select all cells

parent 4d604143
......@@ -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,35 +54,43 @@ const Foam::NamedEnum<Foam::fieldValues::cellSource::operationType, 7>
void Foam::fieldValues::cellSource::setCellZoneCells()
{
label zoneId = mesh().cellZones().findZoneID(sourceName_);
if (zoneId < 0)
switch (source_)
{
FatalErrorIn("cellSource::cellSource::setCellZoneCells()")
<< "Unknown cell zone name: " << sourceName_
<< ". Valid cell zones are: " << mesh().cellZones().names()
<< nl << exit(FatalError);
}
const cellZone& cZone = mesh().cellZones()[zoneId];
case stCellZone:
{
label zoneId = mesh().cellZones().findZoneID(sourceName_);
if (zoneId < 0)
{
FatalErrorIn("cellSource::cellSource::setCellZoneCells()")
<< "Unknown cell zone name: " << sourceName_
<< ". Valid cell zones are: " << mesh().cellZones().names()
<< nl << exit(FatalError);
}
cellId_ = mesh().cellZones()[zoneId];
nCells_ = returnReduce(cellId_.size(), sumOp<label>());
break;
}
cellId_.setSize(cZone.size());
case stAll:
{
cellId_ = identity(mesh().nCells());
nCells_ = returnReduce(cellId_.size(), sumOp<label>());
break;
}
label count = 0;
forAll(cZone, i)
{
label cellI = cZone[i];
cellId_[count] = cellI;
count++;
default:
{
FatalErrorIn("cellSource::setCellZoneCells()")
<< "Unknown source type. Valid source types are:"
<< sourceTypeNames_ << nl << exit(FatalError);
}
}
cellId_.setSize(count);
nCells_ = returnReduce(cellId_.size(), sumOp<label>());
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);
}
}
setCellZoneCells();
Info<< type() << " " << name_ << ":" << nl
<< " total cells = " << nCells_ << nl
......
......@@ -89,7 +89,8 @@ public:
//- Source type enumeration
enum sourceType
{
stCellZone
stCellZone,
stAll
};
//- Source type names
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment