[Paraview] AMR reader
Randy Hudson
hudson at mcs.anl.gov
Tue Aug 23 13:06:37 EDT 2005
I've speeded up my amr reader by turning inside out the loop that reads the scalar variables from the dataset and loads them into the vtkHierarchicalDataSet.
Below is the current piece of RequestData() that does that work. I measured the time spent in the five code blocks indicated, and by far the most time is spent in BLOCK FIVE, ds->GenerateVisibilityArrays().
Does that sound right?
Thanks.
vtkDataObject* doOutput = info->Get(vtkCompositeDataSet::COMPOSITE_DATA_SET());
vtkHierarchicalBoxDataSet* ds = vtkHierarchicalBoxDataSet::SafeDownCast(doOutput);
int runsize = this->fvo_hb - this->fvo_lb + 1;
int* levelPerBlockId = new int[runsize];
{ // BLOCK ONE ----------------------------------------
for(int i=0; i<this->numLevels; i++) {
for(int j=0; j<this->numBlocksPerLevel[i]; j++) {
if ((this->fvo_lb <= this->blockIdsPerLevel[i][j]) && (this->blockIdsPerLevel[i][j] <= this->fvo_hb)) {
levelPerBlockId[this->blockIdsPerLevel[i][j] - this->fvo_lb] = i;
}
}
}
} // -------------------------------------------------
vtkDoubleArray*** scalars; // vtkDataArray*[k][runsize]
// TRY ALLOCATING THE MIDDLE DIMENSION HERE, RATHER THAN IN flashVtkComponents
scalars = new vtkDoubleArray**[count];
{ // BLOCK TWO ----------------------------------------
for (int k=0; k<count; k++) { // FOR ALL SELECTED SCALAR VARIABLES
scalars[k] = new vtkDoubleArray*[runsize];
// GET ARRAYS FOR ALL BLOCKS IN THIS PROCESS' RANGE
this->AddBlockrunScalars(this->fvo_lb, this->fvo_hb, indices_of_selected[k], scalars[k]);
}
} // -------------------------------------------------
{ // BLOCK THREE ----------------------------------------
for (int i=this->fvo_lb; i<=this->fvo_hb; i++) {
vtkUniformGrid* ug = vtkUniformGrid::New();
this->fvo->DefineUG(levelPerBlockId[i - this->fvo_lb], i, ug); // LEVEL IDX, BLK ID & GRID
for (int k=0; k<count; k++) { // FOR ALL SELECTED SCALAR VARIABLES
scalars[k][i - this->fvo_lb]->SetName(this->varNames[indices_of_selected[k]]);
if (this->fvo->GetDataLocation() == LocPoint) {
ug->GetPointData()->AddArray((vtkDataArray*)(scalars[k][i - this->fvo_lb]));
} else if (this->fvo->GetDataLocation() == LocCell) {
ug->GetCellData()->AddArray((vtkDataArray*)(scalars[k][i - this->fvo_lb]));
}
scalars[k][i - this->fvo_lb]->Delete();
}
ds->SetDataSet(levelPerBlockId[i - this->fvo_lb], i - this->fvo_lb, ug);
ug->Delete();
}
} // -------------------------------------------------
for (int k=0; k<count; k++) { // FOR ALL SELECTED SCALAR VARIABLES
delete [] scalars[k];
}
delete [] scalars;
#endif
{ // BLOCK FOUR ----------------------------------------
for(int i=0; i<this->numLevels; i++) {
ds->SetRefinementRatio(i, 2);
}
} // -------------------------------------------------
{ // BLOCK FIVE ----------------------------------------
ds->GenerateVisibilityArrays();
} // -------------------------------------------------
Randy.
630 252 8690.
More information about the ParaView
mailing list