Commit 5d365db1 authored by George Zagaris's avatar George Zagaris
Browse files

ENH: Single AMR box calucation at root level

Added functionality to compute a single AMR box
for the root level. This is used in ParaView to
decide whether or not a block is on a boundary
and thus must be processed for rendering.
parent 1f3ce1c3
......@@ -31,6 +31,8 @@
#include "vtkIdList.h"
#include "vtkAssertUtils.hpp"
#include <cmath>
#include <limits>
#include <vtkstd/vector>
#include <sstream>
#include <cassert>
......@@ -416,6 +418,70 @@ int vtkHierarchicalBoxDataSet::GetRefinementRatio(vtkCompositeDataIterator* iter
return info->Has(REFINEMENT_RATIO())? info->Get(REFINEMENT_RATIO()): 0;
}
//----------------------------------------------------------------------------
void vtkHierarchicalBoxDataSet::GetRootAMRBox( vtkAMRBox &root )
{
if( (this->GetNumberOfLevels() == 0) ||
(this->GetNumberOfDataSets(0) == 0) )
return;
double min[3];
double max[3];
min[0] = min[1] = min[2] = std::numeric_limits<double>::max();
max[0] = max[1] = max[2] = std::numeric_limits<double>::min();
int lo[3];
lo[0]=lo[1]=lo[2]=0;
int hi[3];
hi[0]=hi[1]=hi[2]=0;
int dimension = 0;
double spacing[3];
unsigned int dataIdx = 0;
for( ; dataIdx < this->GetNumberOfDataSets(0); ++dataIdx )
{
vtkAMRBox myBox;
this->GetMetaData( 0, dataIdx, myBox );
double boxmin[3];
double boxmax[3];
int boxdims[3];
// Note: the AMR boxes are cell dimensioned, hence,
// in order to calculate the global dimensions, we
// just need to sum the number of cells in the box.
myBox.GetNumberOfCells( boxdims );
myBox.GetMinBounds( boxmin );
myBox.GetMaxBounds( boxmax );
for( int i=0; i < myBox.GetDimensionality(); ++i )
{
if( boxmin[i] < min[i] )
min[i] = boxmin[i];
if( boxmax[i] > max[i] )
max[i] = boxmax[i];
}
dimension = myBox.GetDimensionality();
myBox.GetGridSpacing( spacing );
} // END for all data
for( int i=0; i < dimension; ++i )
hi[ i ] = round( (max[i]-min[i])/spacing[i] );
root.SetDimensionality( dimension );
root.SetDataSetOrigin( min );
root.SetGridSpacing( spacing );
root.SetDimensions( lo, hi );
root.SetLevel( 0 );
root.SetBlockId( 0 );
root.SetProcessId( -1 ); /* not owned, can be computed by any process */
}
//----------------------------------------------------------------------------
int vtkHierarchicalBoxDataSet::GetMetaData(
unsigned int level, unsigned int index, vtkAMRBox &box)
......@@ -450,7 +516,7 @@ int vtkHierarchicalBoxDataSet::GetMetaData(
}
else
{
vtkErrorMacro( "No meta-data found for requested object!\n" );
// vtkErrorMacro( "No meta-data found for requested object!\n" );
return 0;
}
}
......
......@@ -90,6 +90,11 @@ public:
virtual void SetDataSet(vtkCompositeDataIterator* iter, vtkDataObject* dataObj)
{ this->Superclass::SetDataSet(iter, dataObj); }
// Description:
// This method returns the root AMR box for the entire root level.
// The root AMR box covers the entire domain.
void GetRootAMRBox( vtkAMRBox &root );
// Description:
// Set the dataset pointer for a given node. This will resize the number of
// levels and the number of datasets in the level to fit level, id requested.
......
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