Commit a3018b7a authored by George Zagaris's avatar George Zagaris
Browse files

ENH: QDV for AMR -- Load Metadata

This commit introduces the first set of
changes for Query-Driven Visualization (QDV)
of AMR datasets. The changes are as follows:

(1) The base reader implements RequestInformation()
    and defines a pure abstract method FillMetaData()
    to be implemented by concrete classes.

(2) Concrete AMR readers implement FillMetaData() which
    essentially creates a vtkHierarchicalBoxDataSet with
    the uniform grids and AMR boxes but with no data, e.g.,
    density etc.

(3) The metada is published in the output information object
    for downstream modules.
parent 895a4446
......@@ -21,8 +21,10 @@
#include "vtkDataArraySelection.h"
#include "vtkCallbackCommand.h"
#include "vtkIndent.h"
#include "vtkSmartPointer.h"
#include "vtkCompositeDataPipeline.h"
#include "vtkAMRSliceFilter.h"
//#include "vtkAMRSliceFilter.h"
#include "vtkAMRUtilities.h"
......@@ -210,8 +212,20 @@ int vtkAMRBaseReader::RequestInformation(
vtkInformationVector **inputVector,
vtkInformationVector *outputVector )
{
// std::cout << "Called RequestInformation..." << std::endl;
// std::cout.flush();
this->Superclass::RequestInformation( rqst, inputVector, outputVector );
std::cout << "FILE: " << __FILE__ << " - RequestInformation\n";
std::cout.flush();
vtkSmartPointer<vtkHierarchicalBoxDataSet> metadata =
vtkSmartPointer<vtkHierarchicalBoxDataSet>::New();
vtkInformation* info = outputVector->GetInformationObject(0);
assert( "pre: output information object is NULL" && (info != NULL) );
this->FillMetaData( metadata );
info->Set( vtkCompositeDataPipeline::COMPOSITE_DATA_META_DATA(), metadata );
this->Modified();
return 1;
}
......@@ -222,22 +236,22 @@ int vtkAMRBaseReader::RequestData(
vtkInformationVector** vtkNotUsed(inputVector),
vtkInformationVector* outputVector )
{
std::cout << "FILE: " << __FILE__ << " - RequestData\n";
std::cout.flush();
vtkInformation *outInf = outputVector->GetInformationObject( 0 );
vtkHierarchicalBoxDataSet *output =
vtkHierarchicalBoxDataSet::SafeDownCast(
outInf->Get( vtkDataObject::DATA_OBJECT() ) );
assert( "pre: output AMR dataset is NULL" && ( output != NULL ) );
// std::cout << __FILE__ << "::RequestData is called....";
if( outInf->Has(
vtkStreamingDemandDrivenPipeline::UPDATE_AMR_LEVEL() ) )
{
this->MaxLevel = outInf->Get(
vtkStreamingDemandDrivenPipeline::UPDATE_AMR_LEVEL() );
// std::cout << "\nSetting NEW max level: " << this->MaxLevel << std::endl;
}
// std::cout.flush();
// std::cout << std::endl;
this->ReadMetaData();
this->GenerateBlockMap();
......
......@@ -146,6 +146,10 @@ class VTK_AMR_EXPORT vtkAMRBaseReader :
// Returns the total number of levels. Implemented by concrete instances.
virtual int GetNumberOfLevels() = 0;
// Description:
// Loads all the AMR metadata
virtual int FillMetaData( vtkHierarchicalBoxDataSet* metadata ) = 0;
// Description:
// Loads the block according to the index w.r.t. the generated BlockMap.
virtual void GetBlock(
......
......@@ -321,6 +321,49 @@ int vtkAMREnzoReader::GetNumberOfLevels()
return( this->Internal->NumberOfLevels );
}
//-----------------------------------------------------------------------------
int vtkAMREnzoReader::FillMetaData( vtkHierarchicalBoxDataSet *metadata )
{
assert( "pre: Internal Enzo Reader is NULL" && (this->Internal != NULL) );
assert( "pre: metadata object is NULL" && (metadata != NULL) );
this->Internal->ReadMetaData();
std::vector< int > b2level;
b2level.resize( this->Internal->NumberOfLevels, 0 );
// this->Internal->Blocks includes a pseudo block -- the root as block #0
for( int i=0; i < this->Internal->NumberOfBlocks; ++i )
{
vtkEnzoReaderBlock &theBlock = this->Internal->Blocks[ i+1 ];
int level = theBlock.Level;
double blockMin[ 3 ];
double blockMax[ 3 ];
double spacings[ 3 ];
for( int j=0; j < 3; ++j )
{
blockMin[j] = theBlock.MinBounds[j];
blockMax[j] = theBlock.MaxBounds[j];
spacings[j] = (theBlock.BlockNodeDimensions[j] > 1)?
(blockMax[j]-blockMin[j]/(theBlock.BlockNodeDimensions[j]-1.0)):1.0;
}
vtkUniformGrid *ug = vtkUniformGrid::New();
ug->SetDimensions( theBlock.BlockNodeDimensions );
ug->SetOrigin( blockMin[0], blockMin[1], blockMin[2] );
ug->SetSpacing( spacings[0], spacings[1], spacings[2] );
metadata->SetDataSet( level, b2level[ level ], ug );
ug->Delete();
b2level[ level ]++;
} // END for all blocks
// NOTE: the controller here is null since each process loads its own metadata
vtkAMRUtilities::GenerateMetaData( metadata, NULL );
return( 1 );
}
//-----------------------------------------------------------------------------
void vtkAMREnzoReader::GetBlock(
int index, vtkHierarchicalBoxDataSet *hbds,
......
......@@ -96,6 +96,10 @@ class VTK_AMR_EXPORT vtkAMREnzoReader : public vtkAMRBaseReader
// See vtkAMRBaseReader::GetNumberOfLevels
int GetNumberOfLevels();
// Description:
// See vtkAMRBaseReader::FillMetaData
int FillMetaData( vtkHierarchicalBoxDataSet *metadata );
// Description:
// See vtkAMRBaseReader::GetBlock
void GetBlock(
......
......@@ -146,6 +146,49 @@ int vtkAMRFlashReader::GetNumberOfLevels()
return( this->Internal->NumberOfLevels );
}
//-----------------------------------------------------------------------------
int vtkAMRFlashReader::FillMetaData( vtkHierarchicalBoxDataSet *metadata )
{
assert( "pre: Internal Flash Reader is NULL" && (this->Internal != NULL) );
assert( "pre: metadata object is NULL" && (metadata != NULL) );
this->Internal->ReadMetaData();
std::vector< int > b2level;
b2level.resize( this->Internal->NumberOfLevels, 0 );
for( int i=0; i < this->Internal->NumberOfBlocks; ++i )
{
// Start numbering levels from 0!
int level = this->Internal->Blocks[ i ].Level-1;
double blockMin[3];
double blockMax[3];
double spacings[3];
for( int j=0; j < 3; ++j )
{
blockMin[j] = this->Internal->Blocks[i].MinBounds[j];
blockMax[j] = this->Internal->Blocks[i].MaxBounds[j];
spacings[j] = (this->Internal->BlockGridDimensions[j] > 1)?
(blockMax[j]-blockMin[j])/(this->Internal->BlockGridDimensions[j]-1.0):1.0;
}
vtkUniformGrid *ug = vtkUniformGrid::New();
ug->SetDimensions( this->Internal->BlockGridDimensions );
ug->SetOrigin( blockMin[0], blockMin[1], blockMin[2] );
ug->SetSpacing( spacings );
metadata->SetDataSet( level, b2level[level], ug );
ug->Delete();
b2level[ level ]++;
} // END for all blocks
// NOTE: The communicator here is NULL since each process loads all the
// metadata.
vtkAMRUtilities::GenerateMetaData( metadata, NULL );
return( 1 );
}
//-----------------------------------------------------------------------------
void vtkAMRFlashReader::GetBlock(
int index, vtkHierarchicalBoxDataSet *hbds,
......
......@@ -61,6 +61,10 @@ class VTK_AMR_EXPORT vtkAMRFlashReader : public vtkAMRBaseReader
// See vtkAMRBaseReader::GetNumberOfLevels
int GetNumberOfLevels();
// Description:
// See vtkAMRBaseReader::FillMetaData
int FillMetaData( vtkHierarchicalBoxDataSet *metadata );
// Description:
// See vtkAMRBaseReader::GetBlock
void GetBlock(
......
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