Commit 6e81cfce authored by George Zagaris's avatar George Zagaris
Browse files

ENH: Use global controller by default

This commit applies changes that enable
the use of the global controller
by default. Before, a NULL controller
indicated that the reader is parallel.
However, with this change, the Controller
is almost guaranteed to be non-NULL. To
determine whether the reader is running
serially or parallel, an additional helper
method was added which checks both if the
Controller is NULL and the total number of
processes associated with the controller.
Consequently, all conditional statements of
"if( this->Controller != NULL )" have been
updated to "if( this->IsParallel() )" which
implements the correct behavior.
parent 887062a9
......@@ -63,7 +63,7 @@ void vtkAMRBaseReader::Initialize()
this->FileName = NULL;
this->MaxLevel = 0;
this->LoadParticles = 1;
this->Controller = NULL;
this->Controller = vtkMultiProcessController::GetGlobalController();
this->InitialRequest = true;
this->CellDataArraySelection = vtkDataArraySelection::New();
......@@ -155,7 +155,7 @@ int vtkAMRBaseReader::GetBlockProcessId( const int blockIdx )
{
// If this is reader instance is serial, return Process 0
// as the Process ID for the corresponding block.
if( this->Controller == NULL )
if( !this->IsParallel() )
return 0;
int N = this->Controller->GetNumberOfProcesses();
......@@ -167,7 +167,7 @@ bool vtkAMRBaseReader::IsBlockMine( const int blockIdx )
{
// If this reader instance does not run in parallel, then,
// all blocks are owned by this reader.
if( this->Controller == NULL )
if( !this->IsParallel() )
return true;
int myRank = this->Controller->GetLocalProcessId();
......@@ -187,6 +187,18 @@ void vtkAMRBaseReader::InitializeArraySelections()
}
}
//------------------------------------------------------------------------------
bool vtkAMRBaseReader::IsParallel( )
{
if( this->Controller == NULL )
return false;
if( this->Controller->GetNumberOfProcesses() > 1 )
return true;
return false;
}
//------------------------------------------------------------------------------
int vtkAMRBaseReader::RequestData(
vtkInformation* vtkNotUsed(request),
......@@ -231,7 +243,7 @@ int vtkAMRBaseReader::RequestData(
// If this instance of the reader is not parallel, block until all processes
// read their blocks.
if( this->Controller != NULL )
if( this->IsParallel() )
this->Controller->Barrier();
outInf = NULL;
......
......@@ -93,6 +93,11 @@ class VTK_AMR_EXPORT vtkAMRBaseReader :
vtkAMRBaseReader();
~vtkAMRBaseReader();
// Desscription:
// Checks if this reader instance is attached to a communicator
// with more than one MPI processes.
bool IsParallel();
// Description:
// Determines if the block is owned by this process based on the
// the block index and total number of processes.
......
Markdown is supported
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