Commit 0870c5f2 authored by David Partyka's avatar David Partyka
Browse files

Revert "ENH: Berger & Collela AMR improvemets"

This reverts commit f80b2ab7.
parent 4e583c78
This diff is collapsed.
......@@ -25,20 +25,18 @@
// vtkAMRBox is used in vtkHierarchicalBoxDataSet to compute cell visibilty.
//
// .SECTION See Also
// vtkHierarachicalBoxDataSet, vtkAMRUtilities
// vtkHierarachicalBoxDataSet, vtkAMRBoxUtilities.hxx
#ifndef __vtkAMRBox_h
#define __vtkAMRBox_h
#include "vtkObject.h"
#include "vtkType.h" //For utility functions.
#include "vtkType.h" //For utility functions.
#include <vtkstd/vector> // STL Header
class VTK_FILTERING_EXPORT vtkAMRBox
{
public:
// Description:
// Construct the empty box.
vtkAMRBox(int dim=3);
......@@ -50,7 +48,7 @@ public:
int ihi,int jhi,int khi);
// Description:
// Construct a specific 2D box in the XY plane.
// Construct a specific 2D box.
vtkAMRBox(
int ilo,int jlo,
int ihi,int jhi);
......@@ -65,7 +63,6 @@ public:
vtkAMRBox(int dim, const int dims[6]);
vtkAMRBox(const int dims[6]);
// Description:
// Copy construct this box from another.
vtkAMRBox(const vtkAMRBox &other);
......@@ -74,73 +71,16 @@ public:
// Copy the other box to this box.
vtkAMRBox &operator=(const vtkAMRBox &other);
// Description:
// Determines if two AMR boxes collide.
static bool Collides( vtkAMRBox &b1, vtkAMRBox &b2 );
// Description:
// Set the box to null;
void Invalidate();
// Description:
// Returns the number of ghost layes that have been extruded along
// each dimension.
void GetNumberOfGhosts( int *ng );
// Description:
// Get the minimum coordinates of this box instance.
double GetMinX() const;
double GetMinY() const;
double GetMinZ() const;
void GetMinBounds( double min[3] ) const;
// Description:
// Get the maximum coordinates of this box instance.
double GetMaxX() const;
double GetMaxY() const;
double GetMaxZ() const;
void GetMaxBounds( double max[3] ) const;
// Description:
// Get/Set the spatial dimension of the box. Only 2 and 3
// are valid.
int GetDimensionality() const { return this->Dimension; }
void SetDimensionality(int dim);
// Description:
// Sets the Grid topology description of this AMR box instance.
int GetGridDescription() const { return this->GridDescription; };
void SetGridDescription( const int desc );
// Description:
// Get/Set the process ID of the process that owns the box.
int GetProcessId() const { return this->ProcessId; }
void SetProcessId( const int pid );
// Description:
// Get/Set the Block ID of the AMR grid corresponding to this AMR box.
int GetBlockId() const { return this->BlockId; }
void SetBlockId( const int blockIdx );
// Description:
// Get/Set the Block level of the AMR grid corresponding to this AMR box.
int GetLevel() const { return this->BlockLevel; }
void SetLevel( const int level );
// Description:
// Returns the real extent of this AMR Box instance.
void GetRealExtent( int realExtent[6] ) const;
// Description:
// Sets the real extent of this AMR box instance.
void SetRealExtent( int realExtent[6] );
void SetRealExtent( int minijk[3], int maxijk[3] );
// Description:
// Checks if the point is inside this AMRBox instance.
// x,y,z the world point
bool HasPoint( const double x, const double y, const double z );
// Description:
// Set the dimensions of the box. ilo,jlo,klo,ihi,jhi,khi
void SetDimensions(
......@@ -227,17 +167,8 @@ public:
// Description:
// Test if this box is empty/valid.
// The box is empty iff all the hibounds are
// equal to the low bounds, i.e.,
// LoCorner[ i ] == HiCorner[ i ] for all i.
bool Empty() const;
// Description:
// Check to see if the AMR box instance is invalid.
// An AMR box is invalid iff HiCorner[ i ] < LoCorner[ i ]
// for any i.
bool IsInvalid() const;
// Description:
// Test if this box has the same dimensions as another.
bool operator==(const vtkAMRBox &other);
......@@ -263,57 +194,10 @@ public:
// Coarsen the box.
void Coarsen(int r);
// Description:
// Returns the linear index of the given cell structured coordinates
int GetCellLinearIndex( const int i, const int j, const int k );
// Description:
// Checks to see if the node corresponding to the given
// i-j-k coordinates is a ghost node.
bool IsGhostNode( const int i, const int j, const int k );
// Description:
// Gets the real coordinates of the point within the virtual
// AMR box at the given ijk coordinates.
// ijk -- the computational coordinate of the point in query (in)
// pnt -- the physical (real) coordinate of the point (out)
void GetPoint( const int ijk[3], double pnt[3] ) const;
void GetPoint( const int i, const int j, const int k, double pnt[3] ) const;
// Description:
// Send the box to a stream. "(ilo,jlo,jhi),(ihi,jhi,khi)"
ostream &Print(ostream &os) const;
// Description:
// Serializes this object instance into a byte-stream.
// buffer -- user-supplied pointer where the serialized object is stored.
// bytesize -- number of bytes, i.e., the size of the buffer.
// NOTE: buffer is allocated internally by this method.
// Pre-conditions:
// buffer == NULL
// Post-conditions:
// buffer != NULL
// bytesize != 0
void Serialize( unsigned char*& buffer, vtkIdType &bytesize );
// Description:
// Deserializes this object instance from the given byte-stream.
// Pre-conditions:
// buffer != NULL
// bytesize != 0
void Deserialize( unsigned char* buffer, const vtkIdType &bytesize );
// Description:
// Returns the number of bytes allocated by this instance. In addition,
// this number of bytes corresponds to the buffer size required to serialize
// any vtkAMRBox instance.
static vtkIdType GetBytesize(){return (17*sizeof(int)+6*sizeof(double)); };
// Description:
// Writes the AMR box in a VTK file.
// Note: This method is used for debugging purposes.
void WriteBox();
//BTX
// @deprecated Replaced by Contains() as of VTK 5.4.
// Do not use! See Contains().
......@@ -324,7 +208,6 @@ public:
//ETX
public:
// Description:
// These are public for backward compatibility only. If your
// code uses these, it will break in the future when this class
......@@ -333,47 +216,10 @@ public:
int LoCorner[3]; // lo corner cell id.
int HiCorner[3]; // hi corner cell id.
protected:
// Description:
// Initializes this box instance.
void Initialize( );
private:
int Dimension; // 2 or 3
int BlockId; // The ID of the corresponding block
int ProcessId; // The process ID that owns this block
int BlockLevel; // The level of this AMR box instance
int NG[6]; // Number of ghosts along each dimension
double X0[3]; // Dataset origin (not box origin)
double DX[3]; // grid spacing
int RealExtent[6]; // Extent of the all the real nodes, i.e., not the ghosts
int GridDescription; // Defines whether the box is on the XY,YZ planes.
// Description:
// This method builds the AMR box with the given dimensions.
// Note: the dimension of the AMR box is automatically detected
// within this method.
void BuildAMRBox(
const int ilo, const int jlo, const int klo,
const int ihi, const int jhi, const int khi );
// Description:
// Determines the dimension of the AMR box given the
// box indices. Note, the AMR box can be on an arbitrary
// axis-aligned plane, i.e., XZ or YZ.
// int DetectDimension(
// const int ilo, const int jlo, const int klo,
// const int ihi, const int jhi, const int khi );
// Description:
// A simple method to write a box with the given min/max
// coordindates for debugging.
void WriteBox(
const double x, const double y, const double z,
const double X, const double Y, const double Z );
int Dimension; // 2 or 3.
double X0[3]; // Dataset origin (not box origin). low corner cell's, low corner node.
double DX[3]; // grid spacing.
};
// NOTE 2008-11-10
......
This diff is collapsed.
......@@ -41,9 +41,6 @@
#define __vtkHierarchicalBoxDataSet_h
#include "vtkCompositeDataSet.h"
#include <vtkstd/vector> // For STL vector
#include <vtkstd/map> // For STL map
#include <vtkstd/utility> // For STL pair
class vtkAMRBox;
class vtkInformationIdTypeKey;
......@@ -51,21 +48,13 @@ class vtkInformationIntegerKey;
class vtkInformationIntegerVectorKey;
class vtkUniformGrid;
typedef vtkstd::vector<vtkAMRBox> vtkAMRBoxList;
class VTK_FILTERING_EXPORT vtkHierarchicalBoxDataSet: public vtkCompositeDataSet
class VTK_FILTERING_EXPORT vtkHierarchicalBoxDataSet : public vtkCompositeDataSet
{
public:
static vtkHierarchicalBoxDataSet *New();
vtkTypeMacro(vtkHierarchicalBoxDataSet,vtkCompositeDataSet);
void PrintSelf(ostream& os, vtkIndent indent);
// Descrition:
// Set & Get the AMR dataset origin
// The origin is essentially the minimum of all the grids.
void SetOrigin( const double origin[3] );
void GetOrigin( double origin[3] );
// Description:
// Return a new iterator (the iterator has to be deleted by user).
virtual vtkCompositeDataIterator* NewIterator();
......@@ -101,37 +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:
// This method returns the global AMR box, covering the entire
// domain, with the prescribed spacing.
void GetGlobalAMRBoxWithSpacing( vtkAMRBox &box, double h[3] );
// 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.
void SetDataSet(unsigned int level, unsigned int id,
int LoCorner[3], int HiCorner[3], vtkUniformGrid* dataSet);
// Description:
// Set the dataset pointer for a given node without any metadata. This will
// resize the number of levels and the number of datasets accordingly.
void SetDataSet(unsigned int level, unsigned int id, vtkUniformGrid* dataSet);
// Description:
// Appends the dataset to the given level. This will resize the
// number of levels and the number of datasets accordingly.
void AppendDataSet(unsigned int level, vtkUniformGrid* dataSet );
// Description:
// Sets the meta-data object at a given node. This will resize the number
// of levels and number of datasets acoordingly.
void SetMetaData(unsigned int level, unsigned int id, const vtkAMRBox &box );
//BTX
// Description:
// Set the dataset pointer for a given node. This will resize the number of
......@@ -149,7 +112,6 @@ public:
vtkUniformGrid* GetDataSet(unsigned int level,
unsigned int id,
vtkAMRBox& box);
vtkUniformGrid* GetDataSet(unsigned int level,unsigned int id );
// Description:
// Returns the AMR box for the location pointer by the iterator.
......@@ -169,27 +131,12 @@ public:
int HasLevelMetaData(unsigned int level)
{ return this->HasChildMetaData(level); }
// Description:
// Sets the composite index of the data at the given (level,index) pair.
void SetCompositeIndex(
const unsigned int level, const unsigned int index, const int idx );
// Description:
// Retrieves the composite index associated with the data at the given
// (level,index) pair.
int GetCompositeIndex( const unsigned int level, const unsigned int index );
// Description:
// Get meta-data associated with a dataset. This may allocate a new
// vtkInformation object if none is already present. Use HasMetaData to
// avoid unnecessary allocations.
vtkInformation* GetMetaData(unsigned int level, unsigned int index);
// Description:
// Get the AMR box meta-data associated with a given dataset.
// Returns 1 iff GetMetaData() was successful, else 0.
int GetMetaData(unsigned int level, unsigned int index, vtkAMRBox &box);
// Description:
// Returns if meta-data exists for a given dataset under a given level.
int HasMetaData(unsigned int level, unsigned int index);
......@@ -220,12 +167,6 @@ public:
static vtkInformationIntegerKey* BOX_DIMENSIONALITY();
static vtkInformationIntegerKey* REFINEMENT_RATIO();
static vtkInformationIdTypeKey* NUMBER_OF_BLANKED_POINTS();
static vtkInformationDoubleVectorKey* BOX_ORIGIN();
static vtkInformationDoubleVectorKey* SPACING();
static vtkInformationIntegerKey* RANK();
static vtkInformationIntegerKey* BLOCK_ID();
static vtkInformationIntegerVectorKey* REAL_EXTENT();
static vtkInformationIntegerKey* GEOMETRIC_DESCRIPTION();
//BTX
// Description:
......@@ -259,43 +200,14 @@ public:
{ return this->Superclass::HasMetaData(iter); }
// Description:
// Given the level and dataset index, returns the flat index in pre-order
// traversal.
// Given the level and dataset index, returns the flat index provided level
// and dataset index are valid.
unsigned int GetFlatIndex(unsigned int level, unsigned int index);
// Description:
// Given the composite Idx (as set by SetCompositeIdx) this method returns the
// corresponding level and dataset index within the level.
void GetLevelAndIndex(
const unsigned int compositeIdx, unsigned int &level, unsigned int &idx );
// Description:
// Removes all AMR data stored in this instance of the vtkHierarchicalBoxDataSet
void Clear();
// Description:
// Returns the total number of blocks
int GetTotalNumberOfBlocks();
// Description:
// In-line Set & Get
vtkSetMacro( PadCellVisibility, bool );
vtkGetMacro( PadCellVisibility, bool );
protected:
vtkHierarchicalBoxDataSet();
~vtkHierarchicalBoxDataSet();
// Description:
// Gets the list of higher res boxes from this level at the level, l+1
void GetHigherResolutionCoarsenedBoxes(
vtkAMRBoxList &blist, const unsigned int l );
// Description:
// Blanks the grids at level, l, Given the list of high-res boxes at level
// l+1 coarsened to level l.
void BlankGridsAtLevel( vtkAMRBoxList &blist, const unsigned int l );
// Description:
// Compute the range of the scalars and cache it into ScalarRange
// only if the cache became invalid (ScalarRangeComputeTime).
......@@ -306,19 +218,7 @@ protected:
// Time at which scalar range is computed
vtkTimeStamp ScalarRangeComputeTime;
bool PadCellVisibility;
// Global Origin
double origin[3];
// Mapping of composite indices to the (level,id) pair.
vtkstd::map< int, vtkstd::pair<unsigned int,unsigned int> >
CompositeIndex2LevelIdPair;
private:
vtkHierarchicalBoxDataSet(const vtkHierarchicalBoxDataSet&); // Not implemented.
void operator=(const vtkHierarchicalBoxDataSet&); // Not implemented.
};
......
......@@ -29,10 +29,8 @@
#include "vtkPointData.h"
#include "vtkPoints.h"
#include "vtkStructuredVisibilityConstraint.h"
#include "vtkStructuredData.h"
#include "vtkVertex.h"
#include "vtkVoxel.h"
#include "vtkIntArray.h"
vtkStandardNewMacro(vtkUniformGrid);
......@@ -170,12 +168,6 @@ int vtkUniformGrid::Initialize(const vtkAMRBox *def, int nGhosts)
return this->Initialize(def, nGhosts,nGhosts,nGhosts);
}
//----------------------------------------------------------------------------
int vtkUniformGrid::GetGridDescription()
{
return( this->GetDataDescription() );
}
//----------------------------------------------------------------------------
vtkEmptyCell* vtkUniformGrid::GetEmptyCell()
{
......@@ -233,12 +225,12 @@ vtkCell *vtkUniformGrid::GetCell(vtkIdType cellId)
}
// see whether the cell is blanked
// if ( (this->PointVisibility->IsConstrained() ||
// this->CellVisibility->IsConstrained())
// && !this->IsCellVisible(cellId) )
// {
// return this->GetEmptyCell();
// }
if ( (this->PointVisibility->IsConstrained() ||
this->CellVisibility->IsConstrained())
&& !this->IsCellVisible(cellId) )
{
return this->GetEmptyCell();
}
switch (this->GetDataDescription())
{
......@@ -785,15 +777,6 @@ void vtkUniformGrid::BlankPoint(vtkIdType ptId)
this->PointVisibility->Blank(ptId);
}
//----------------------------------------------------------------------------
void vtkUniformGrid::BlankPoint( const int i, const int j, const int k )
{
int ijk[3];
ijk[0] = i; ijk[1] = j; ijk[2] = k;
int idx = vtkStructuredData::ComputePointId(this->Dimensions, ijk );
this->BlankPoint( idx );
}
//----------------------------------------------------------------------------
// Turn on a particular data point.
void vtkUniformGrid::UnBlankPoint(vtkIdType ptId)
......@@ -802,15 +785,6 @@ void vtkUniformGrid::UnBlankPoint(vtkIdType ptId)
this->PointVisibility->UnBlank(ptId);
}
//----------------------------------------------------------------------------
void vtkUniformGrid::UnBlankPoint( const int i, const int j, const int k )
{
int ijk[3];
ijk[0] = i; ijk[1] = j; ijk[2] = k;
int idx = vtkStructuredData::ComputePointId(this->Dimensions, ijk );
this->UnBlankPoint( idx );
}
//----------------------------------------------------------------------------
void vtkUniformGrid::SetPointVisibilityArray(vtkUnsignedCharArray *ptVis)
{
......@@ -827,91 +801,18 @@ vtkUnsignedCharArray* vtkUniformGrid::GetPointVisibilityArray()
// Turn off a particular data cell.
void vtkUniformGrid::BlankCell(vtkIdType cellId)
{
int dims[3];
this->GetDimensions( dims );;
dims[0]--;dims[1]--;dims[2]--;
dims[0] = ( dims[0] < 1 )? 1 : dims[0];
dims[1] = ( dims[1] < 1 )? 1 : dims[1];
dims[2] = ( dims[2] < 1 )? 1 : dims[2];
this->CellVisibility->Initialize( dims );
this->CellVisibility->Initialize(this->GetDimensions());
this->CellVisibility->Blank(cellId);
}
//----------------------------------------------------------------------------
void vtkUniformGrid::BlankCell( const int i, const int j, const int k )
{
int ijk[3];
ijk[0] = i; ijk[1] = j; ijk[2] = k;
int idx = vtkStructuredData::ComputeCellId(this->Dimensions, ijk );
assert( "cell id in range:" &&
( (idx >= 0) && (idx < this->GetNumberOfCells() ) ) );
this->BlankCell( idx );
}
//----------------------------------------------------------------------------
// Turn on a particular data cell.
void vtkUniformGrid::UnBlankCell(vtkIdType cellId)
{
int dims[3];
this->GetDimensions( dims );
dims[0]--;dims[1]--;dims[2]--;
dims[0] = ( dims[0] < 1 )? 1 : dims[0];
dims[1] = ( dims[1] < 1 )? 1 : dims[1];
dims[2] = ( dims[2] < 1 )? 1 : dims[2];
this->CellVisibility->Initialize( dims );
this->CellVisibility->Initialize(this->GetDimensions());
this->CellVisibility->UnBlank(cellId);
}
//----------------------------------------------------------------------------
void vtkUniformGrid::UnBlankCell( const int i, const int j, const int k )
{
int ijk[3];
ijk[0] = i; ijk[1] = j; ijk[2] = k;
int idx = vtkStructuredData::ComputeCellId(this->Dimensions, ijk );
assert( "cell id in range:" &&
( (idx >= 0) && (idx < this->GetNumberOfCells() ) ) );
this->UnBlankCell( idx );
}
//----------------------------------------------------------------------------
void vtkUniformGrid::AttachCellVisibilityToCellData( )
{
vtkIntArray *cellIblank = NULL;
cellIblank = vtkIntArray::New( );
cellIblank->SetName( "CellIBLANK" );
cellIblank->SetNumberOfTuples( this->GetNumberOfCells() );
cellIblank->SetNumberOfComponents( 1 );
for( int i=0; i < this->GetNumberOfCells(); ++i )
{
if( this->IsCellVisible( i ) )
cellIblank->SetValue( i, 1 );
else
cellIblank->SetValue( i, 0 );
}
this->CellData->AddArray( cellIblank );
}
//----------------------------------------------------------------------------
void vtkUniformGrid::AttachPointVisibilityToPointData( )
{
vtkIntArray *pointIblank = NULL;
pointIblank = vtkIntArray::New( );
pointIblank->SetName( "PointIBLANK" );
pointIblank->SetNumberOfTuples( this->GetNumberOfPoints() );
pointIblank->SetNumberOfComponents( 1 );
for( int i=0; i < this->GetNumberOfPoints(); ++i )
{
if( this->IsPointVisible( i ) )
pointIblank->SetValue( i, 1 );
else
pointIblank->SetValue( i, 0 );
}
this->PointData->AddArray( pointIblank );
}
//----------------------------------------------------------------------------
void vtkUniformGrid::SetCellVisibilityArray(vtkUnsignedCharArray *cellVis)
{
......@@ -935,98 +836,97 @@ unsigned char vtkUniformGrid::IsPointVisible(vtkIdType pointId)
unsigned char vtkUniformGrid::IsCellVisible(vtkIdType cellId)
{
return( this->CellVisibility->IsVisible( cellId ) );
// if ( !this->CellVisibility->IsVisible(cellId) )
// {
// return 0;
// }
//
// int iMin, iMax, jMin, jMax, kMin, kMax;
// int *dims = this->GetDimensions();
//
// iMin = iMax = jMin = jMax = kMin = kMax = 0;
//
// switch (this->GetDataDescription())
// {
// case VTK_EMPTY:
// return 0;
//
// case VTK_SINGLE_POINT: // cellId can only be = 0
// break;
//
// case VTK_X_LINE:
// iMin = cellId;
// iMax = cellId + 1;
// break;
//