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

ENH: Removing old reference code

Change-Id: I12bc6b24bc926b5d974a6a1cb480b472ed44b3a4
parent 6d966d36
Old code saved here for reference
\ No newline at end of file
/*=========================================================================
Program: Visualization Toolkit
Module: vtkAMRConnectivityFilter.cxx
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
#include "vtkAMRConnectivityFilter.h"
#include "vtkObjectFactory.h"
#include "vtkAMRBox.h"
#include "vtkMultiProcessController.h"
#include "vtkAMRInterBlockConnectivity.h"
#include "vtkHierarchicalBoxDataSet.h"
#include <cassert>
//
// Standard methods
//
vtkStandardNewMacro( vtkAMRConnectivityFilter );
vtkAMRConnectivityFilter::vtkAMRConnectivityFilter()
{
this->AMRDataSet = NULL;
this->RemoteConnectivity = NULL;
this->LocalConnectivity = NULL;
this->Controller = NULL;
}
//-----------------------------------------------------------------------------
vtkAMRConnectivityFilter::~vtkAMRConnectivityFilter()
{
this->AMRDataSet = NULL;
this->RemoteConnectivity = NULL;
this->LocalConnectivity = NULL;
this->Controller = NULL;
}
//-----------------------------------------------------------------------------
void vtkAMRConnectivityFilter::PrintSelf( std::ostream &os, vtkIndent indent )
{
if( this->RemoteConnectivity != NULL )
{
os << "Remote Connectivity:\n";
this->RemoteConnectivity->PrintSelf( os, indent );
os << "\n\n";
}
if( this->LocalConnectivity != NULL )
{
os << "Local Connectivity:\n";
this->LocalConnectivity->PrintSelf( os, indent );
}
}
//-----------------------------------------------------------------------------
void vtkAMRConnectivityFilter::ComputeConnectivity( )
{
if( this->AMRDataSet == NULL )
{
vtkErrorMacro( "Cannot compute AMR connectivity on a NULL data-set!" );
}
this->RemoteConnectivity = vtkAMRInterBlockConnectivity::New( );
this->LocalConnectivity = vtkAMRInterBlockConnectivity::New( );
unsigned int level = 0;
for( ;level < this->AMRDataSet->GetNumberOfLevels(); ++level )
{
unsigned int dataIdx = 0;
for( ;dataIdx < this->AMRDataSet->GetNumberOfDataSets(level); ++dataIdx )
{
vtkAMRBox myBox;
this->AMRDataSet->GetMetaData( level, dataIdx, myBox );
assert( "post: metadata level mismatch" &&
(myBox.GetLevel()==level) );
assert( "post: metadata idx mismatch" &&
(myBox.GetBlockId()==dataIdx) );
myBox.WriteBox();
this->ComputeBlockConnectivity( myBox );
} // END for all blocks at this level
} // END for all levels
}
//-----------------------------------------------------------------------------
void vtkAMRConnectivityFilter::ComputeBlockConnectivity( vtkAMRBox &myBox)
{
assert( "pre: Input AMR dataset is NULL" && (this->AMRDataSet != NULL) );
int myRank = 0;
if( this->Controller != NULL )
myRank = this->Controller->GetLocalProcessId();
unsigned int level = 0;
for( ; level < this->AMRDataSet->GetNumberOfLevels(); ++level )
{
unsigned int idx = 0;
for( ; idx < this->AMRDataSet->GetNumberOfDataSets( level ); ++idx )
{
vtkAMRBox box;
this->AMRDataSet->GetMetaData( level, idx, box );
// If the blocks are not at the same level or are at the
// same level but, have a different block ID, the check for
// collision.
if( (box.GetLevel() != myBox.GetLevel()) ||
(box.GetBlockId() != myBox.GetBlockId() ) )
{
if( vtkAMRBox::Collides(box,myBox) )
{
// the boxes collide
if( box.GetProcessId() == myRank )
{
// Add to local connectivity
this->LocalConnectivity->InsertConnection(
myBox.GetBlockId(),myBox.GetLevel(),
box.GetBlockId(),box.GetLevel(),
myRank );
}
else
{
// Add to remote connectivity
this->RemoteConnectivity->InsertConnection(
myBox.GetBlockId(),myBox.GetLevel(),
box.GetBlockId(),box.GetLevel(),
box.GetProcessId() );
}
} // END if the boxes collide
} // END if different block
} // END for all blocks at this level
} // END for all levels
}
/*=========================================================================
Program: Visualization Toolkit
Module: vtkAMRConnectivityFilter.h
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
// .NAME vtkAMRConnectivityFilter -- Computes remote & local connectivities.
//
// .SECTION Description
// A concrete instance of vtkHierarchicalBoxDataSet algorithm that implements
// functionality for computing the remote & local connectivities.
#ifndef VTKAMRCONNECTIVITYFILTER_H_
#define VTKAMRCONNECTIVITYFILTER_H_
#include "vtkHierarchicalBoxDataSetAlgorithm.h"
class vtkHierarchicalBoxDataSet;
class vtkAMRInterBlockConnectivity;
class vtkAMRBox;
class vtkMultiProcessController;
class VTK_AMR_EXPORT vtkAMRConnectivityFilter :
public vtkHierarchicalBoxDataSetAlgorithm
{
public:
static vtkAMRConnectivityFilter* New();
vtkTypeMacro(vtkAMRConnectivityFilter,vtkHierarchicalBoxDataSetAlgorithm);
void PrintSelf( std::ostream &os, vtkIndent indent );
// Inline setters & getters
vtkSetMacro( AMRDataSet, vtkHierarchicalBoxDataSet* );
vtkSetMacro( Controller, vtkMultiProcessController* );
vtkGetMacro( RemoteConnectivity, vtkAMRInterBlockConnectivity* );
vtkGetMacro( LocalConnectivity, vtkAMRInterBlockConnectivity* );
// Description:
// Computes the remote & local connectivities
void ComputeConnectivity( );
protected:
vtkAMRConnectivityFilter();
virtual ~vtkAMRConnectivityFilter();
// Description:
// Computes the inter-block connectivity of the given block.
void ComputeBlockConnectivity( vtkAMRBox &box );
vtkMultiProcessController* Controller;
vtkHierarchicalBoxDataSet* AMRDataSet;
vtkAMRInterBlockConnectivity* RemoteConnectivity;
vtkAMRInterBlockConnectivity* LocalConnectivity;
private:
vtkAMRConnectivityFilter(const vtkAMRConnectivityFilter&); // Not implemented
vtkAMRConnectivityFilter& operator=(const vtkAMRConnectivityFilter&); // Not implemented
};
#endif /* VTKAMRCONNECTIVITYFILTER_H_ */
/*=========================================================================
Program: Visualization Toolkit
Module: vtkAMRContourFilter.cxx
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
#include "vtkAMRContourFilter.h"
#include "vtkObjectFactory.h"
#include "vtkHierarchicalBoxDataSet.h"
#include "vtkInformation.h"
#include "vtkInformationVector.h"
//
// Standard methods
//
vtkStandardNewMacro( vtkAMRContourFilter );
vtkAMRContourFilter::vtkAMRContourFilter()
{
this->SetNumberOfOutputPorts( 1 );
}
//------------------------------------------------------------------------------
vtkAMRContourFilter::~vtkAMRContourFilter()
{
}
//------------------------------------------------------------------------------
void vtkAMRContourFilter::PrintSelf( std::ostream& os, vtkIndent indent )
{
this->Superclass::PrintSelf( os, indent );
}
//------------------------------------------------------------------------------
int vtkAMRContourFilter::FillInputPortInformation(
int vtkNotUsed(port), vtkInformation *info )
{
info->Set(
vtkAlgorithm::INPUT_REQUIRED_DATA_TYPE(), "vtkHierarchicalBoxDataSet");
return 1;
}
//------------------------------------------------------------------------------
int vtkAMRContourFilter::FillOutputPortInformation(
int vtkNotUsed(port), vtkInformation *info )
{
info->Set(vtkDataObject::DATA_TYPE_NAME(), "vtkMultiBlockDataSet");
return 1;
}
//------------------------------------------------------------------------------
int vtkAMRContourFilter::RequestData( vtkInformation *request,
vtkInformationVector **inputVector, vtkInformationVector *outputVector)
{
// TODO: implement this
return( 1 );
}
/*=========================================================================
Program: Visualization Toolkit
Module: vtkAMRContourFilter.h
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
// .NAME vtkAMRContourFilter.h -- Contour for 2D and 3D AMR datasets.
//
// .SECTION Description
// This filter is a concrete instance of vktMultiBlockDataSetAlgorithm which
// accepts as input an AMR dataset, represented as a vtkHierarchicalBoxDataSet,
// and generates a corresponding multiblock dataset of polydata to represent the
// contours.
//
// .SECTION See Also
// vtkHierarchicalBoxDataSet
#ifndef VTKAMRCONTOURFILTER_H_
#define VTKAMRCONTOURFILTER_H_
#include "vtkMultiBlockDataSetAlgorithm.h"
class vtkInformation;
class vtkInformationVector;
class VTK_AMR_EXPORT vtkAMRContourFilter : public vtkMultiBlockDataSetAlgorithm
{
public:
static vtkAMRContourFilter *New();
vtkTypeMacro(vtkAMRContourFilter,vtkMultiBlockDataSetAlgorithm);
void PrintSelf(std::ostream& os, vtkIndent indent);
protected:
vtkAMRContourFilter();
virtual ~vtkAMRContourFilter();
virtual int RequestData(
vtkInformation*,vtkInformationVector**,vtkInformationVector*);
virtual int FillInputPortInformation(int port, vtkInformation *info);
virtual int FillOutputPortInformation(int port, vtkInformation *info);
private:
vtkAMRContourFilter(const vtkAMRContourFilter&); // Not implemented
void operator=(const vtkAMRContourFilter&); // Not implemented
};
#endif /* VTKAMRCONTOURFILTER_H_ */
This diff is collapsed.
/*=========================================================================
Program: Visualization Toolkit
Module: vtkAMRDualMeshExtractor.h
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
// .NAME vtkAMRDualMeshExtractor.h -- Extracts the dual mesh from an AMR dataset
//
// .SECTION Description
// This is a concrete instance of a vtkMultiBlockDataSetAlgorithm which accepts
// as input an AMR dataset, represented in a vtkHierarchicalBoxDataSet instance,
// and outputs the dual-mesh of each block given in corresponding instance of
// vtkMultiBlockDataSet.
//
// .SECTION See Also
// vtkMultiBlockDataSetAlgorithm, vtkUniformGrid
#ifndef VTKAMRDUALMESHEXTRACTOR_H_
#define VTKAMRDUALMESHEXTRACTOR_H_
#include "vtkMultiBlockDataSetAlgorithm.h"
// Forward declarations
class vtkInformation;
class vtkInformationVector;
class vtkUniformGrid;
class vtkHierarchicalBoxDataSet;
class vtkMultiBlockDataSet;
class vtkUnstructuredGrid;
class vtkMultiProcessController;
class vtkIdList;
class VTK_AMR_EXPORT vtkAMRDualMeshExtractor :
public vtkMultiBlockDataSetAlgorithm
{
public:
static vtkAMRDualMeshExtractor *New();
vtkTypeMacro(vtkAMRDualMeshExtractor,vtkMultiBlockDataSetAlgorithm);
void PrintSelf( std::ostream& oss, vtkIndent indent);
// Description:
// Set & Get macro for the multi-process controller.
// The controller is set to NULL by default in which
// case the algorithm will operate serially.
vtkSetMacro(Controller,vtkMultiProcessController*);
vtkGetMacro(Controller,vtkMultiProcessController*);
// Description:
// Sets the number of ghost layers to use when stitching the duals at
// the inter-level boundaries. Default is 1.
vtkSetMacro(NumberOfGhostLayers,int);
vtkGetMacro(NumberOfGhostLayers,int);
// Description:
// This method writes multiblock data. Note, this method is mostly used
// for debugging purposes.
void WriteMultiBlockData( vtkMultiBlockDataSet *mbds, const char *prefix );
protected:
vtkAMRDualMeshExtractor();
virtual ~vtkAMRDualMeshExtractor();
// Description:
// This method exchanges ghost information among the AMR
// grids and returns a new instance of the input AMR dataset
// that consists the ghost information.
vtkHierarchicalBoxDataSet* ExchangeGhostInformation(
vtkHierarchicalBoxDataSet *inputAMR );
// Description:
// This method checks if the dual node for the cell corresponding
// to cellIdx, w.r.t. the uniform grid ug, should be processed, i.e.,
// form a cell using the adjacent dual cell nodes. There are two conditions
// that are checked to determine whether or not the cell can be processed:
// 1.If the cell is visible it is processed.
// 2.If the cell is not visible, but has ownership of one or more of its
// points, then it is processed.
bool ProcessCellDual(
vtkUniformGrid *ug, const int cellIdx,
const int cellijk[3], const int celldims[3] );
// Description:
// This methnod computes the cell point ids for a given ijk point.
// It Returns true if a valid cell can be formed from the given point
// else false. The following conditions indicate whether or not a valid cell
// can be formed from the given node:
// 1. If the point is on a max boundary w.r.t. to the given dimensions, then
// a cell cannot be formed and the method returns immediately.
// 2. If the formed cell, consists of dual cell nodes which all correspond
// to cells that are not visible, then the cell is rejected.
bool GetCellIds(
vtkUniformGrid *ug,
int ijk[3], int dims[3],
vtkIdList *pntIdList, int numNodesPerCell );
// Description:
// This method computes the center of the given cell.
void ComputeCellCenter(vtkUniformGrid *ug, int cellIdx, double center[3]);
// Description:
// This method extracts the dual mesh for each dataset at each level
// from the given AMR data-set into a multiblock dataset. Each block
// in the output vtkMultiBlockDataSet corresponds to a level in the
// vtkHierarchicalBoxDataSet and consists of vtkMultiPieceDataSet which
// in turn contains the dual mesh of each dataset in the corresponding
// level. The dual grids are represented as vtkUnstructuredGrid instances.
void ExtractDualMesh(
vtkHierarchicalBoxDataSet *amrds, vtkMultiBlockDataSet* mbds );
// Description:
// This method computes the dual mesh for the given uniform grid.
vtkUnstructuredGrid* GetDualMesh( vtkUniformGrid *ug );
// Description:
// This method fixes the gaps at the inter-level regions
void FixGaps( vtkHierarchicalBoxDataSet *amrds,vtkMultiBlockDataSet *dual );
// Description:
// This method process the dual mesh at the current level.
void ProcessDual(
const unsigned int currentLevel, vtkUnstructuredGrid *dualMesh,
vtkHierarchicalBoxDataSet *amrData );
// Standard pipeline routines
virtual int RequestData(
vtkInformation*,vtkInformationVector**,vtkInformationVector*);
virtual int FillInputPortInformation(int port, vtkInformation *info);
virtual int FillOutputPortInformation(int port, vtkInformation *info);
vtkMultiProcessController *Controller;
int NumberOfGhostLayers;
private:
vtkAMRDualMeshExtractor(const vtkAMRDualMeshExtractor&);// Not implemented
void operator=(const vtkAMRDualMeshExtractor&);// Not implemented
};
#endif /* VTKAMRDUALMESHEXTRACTOR_H_ */
/*=========================================================================
Program: Visualization Toolkit
Module: vtkAMRGhostCellExtruder.cxx
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
#include "vtkAMRGhostCellExtruder.h"
#include "vtkObjectFactory.h"
#include "vtkHierarchicalBoxDataSet.h"
#include "vtkAMRBox.h"
#include "vtkCellData.h"
#include "vtkPointData.h"
#include "vtkIntArray.h"
#include "vtkUniformGrid.h"
#include "vtkIndent.h"
#include "vtkMultiProcessController.h"
#include "vtkInformation.h"
#include "vtkInformationVector.h"
#include <cassert>
vtkStandardNewMacro(vtkAMRGhostCellExtruder);
vtkAMRGhostCellExtruder::vtkAMRGhostCellExtruder()
{
this->Controller = NULL;
this->NumberOfGhostLayers = 1;
this->SetNumberOfOutputPorts( 1 );
}
//------------------------------------------------------------------------------
vtkAMRGhostCellExtruder::~vtkAMRGhostCellExtruder()
{
}
//------------------------------------------------------------------------------
void vtkAMRGhostCellExtruder::PrintSelf( std::ostream &os, vtkIndent indent )
{
this->Superclass::PrintSelf( os, indent );
}
//------------------------------------------------------------------------------
int vtkAMRGhostCellExtruder::FillInputPortInformation(
int vtkNotUsed(port), vtkInformation *info )
{
info->Set(
vtkAlgorithm::INPUT_REQUIRED_DATA_TYPE(),"vtkHierarchicalBoxDataSet");
return 1;
}
//------------------------------------------------------------------------------
int vtkAMRGhostCellExtruder::FillOutputPortInformation(
int vtkNotUsed(port), vtkInformation *info )
{
info->Set(vtkDataObject::DATA_TYPE_NAME(),"vtkHierarchicalBoxDataSet");
return 1;
}
//------------------------------------------------------------------------------
int vtkAMRGhostCellExtruder::RequestData(
vtkInformation* vtkNotUsed(rqst), vtkInformationVector** inputVector,
vtkInformationVector* outputVector )
{
// STEP 0: Get input & output object
vtkInformation *input = inputVector[0]->GetInformationObject( 0 );
assert( "pre: input infomration is NULL" && (input != NULL) );
vtkHierarchicalBoxDataSet *inputAMR =
vtkHierarchicalBoxDataSet::SafeDownCast(
input->Get(vtkDataObject::DATA_OBJECT()));
assert( "pre: input AMR dataset is NULL" && (inputAMR != NULL) );
vtkInformation *output = outputVector->GetInformationObject(0);
vtkHierarchicalBoxDataSet *outputAMR =
vtkHierarchicalBoxDataSet::SafeDownCast(
output->Get(vtkDataObject::DATA_OBJECT() ) );
assert( "pre: output AMR dataset is NULL" && (outputAMR != NULL) );
// STEP 1: Construct output AMR dataset
this->ConstructExtrudedDataSet( inputAMR, outputAMR );
// STEP 2: Synchronize
if( this->Controller != NULL )
this->Controller->Barrier( );
return 1;
}
//------------------------------------------------------------------------------
void vtkAMRGhostCellExtruder::ConstructExtrudedDataSet(
vtkHierarchicalBoxDataSet *inAMR, vtkHierarchicalBoxDataSet *outAMR )
{
assert( "pre: input AMR dataset is NULL" && (inAMR != NULL) );
assert( "pre: output AMR dataset is NULL" && (outAMR != NULL ) );
assert( "pre: number of exrtusion layers is less that 1" &&
(this->NumberOfGhostLayers >= 1) );
vtkUniformGrid *ugPtr = NULL;
unsigned int currentLevel = 0;
for( ;currentLevel < inAMR->GetNumberOfLevels(); ++currentLevel )
{
unsigned int dataIdx = 0;
for( ;dataIdx < inAMR->GetNumberOfDataSets(currentLevel); ++dataIdx )
{