Commit 3932b848 authored by George Zagaris's avatar George Zagaris
Browse files

COMP: Fix compiler warnings

Fix compiler warnings due to unused variables and comparissons between
signed/unsigned.

Change-Id: I664733c0b4f41ed9034c63b0f5b93492bb7fb616
parent a0f7debe
......@@ -228,28 +228,29 @@ int vtkAMRBaseParticlesReader::RequestData(
// STEP 2: Read blocks
mbds->SetNumberOfBlocks( this->NumberOfBlocks );
for( unsigned int blkidx=0; blkidx < this->NumberOfBlocks; ++blkidx )
unsigned int blkidx=0;
for( ;blkidx < static_cast<unsigned int>(this->NumberOfBlocks); ++blkidx )
{
if( this->IsBlockMine( blkidx ) )
{
vtkPolyData *particles = this->ReadParticles( blkidx );
assert( "particles dataset should not be NULL!" &&
(particles != NULL) );
mbds->SetBlock( blkidx, particles );
particles->Delete();
}
else
{
mbds->SetBlock( blkidx, NULL );
}
if( this->IsBlockMine( blkidx ) )
{
vtkPolyData *particles = this->ReadParticles( blkidx );
assert( "particles dataset should not be NULL!" &&
(particles != NULL) );
mbds->SetBlock( blkidx, particles );
particles->Delete();
}
else
{
mbds->SetBlock( blkidx, NULL );
}
} // END for all blocks
// STEP 3: Synchronize
if( this->IsParallel( ) )
{
this->Controller->Barrier();
}
return 1;
}
......
......@@ -403,7 +403,7 @@ vtkUniformGrid* vtkAMRBaseReader::GetAMRBlock( const int blockIdx )
//------------------------------------------------------------------------------
void vtkAMRBaseReader::LoadPointData(
const int blockIdx, vtkUniformGrid *block )
const int vtkNotUsed(blockIdx), vtkUniformGrid* vtkNotUsed(block) )
{
// TODO: implement this
//vtkErrorMacro( "Node-centered AMR data are not currently supported" );
......
......@@ -54,11 +54,11 @@ vtkAMRCutPlane::vtkAMRCutPlane()
this->initialRequest = true;
for( int i=0; i < 3; ++i )
{
this->Center[i] = 0.0;
this->Normal[i] = 0.0;
this->Center[i] = 0.0;
this->Normal[i] = 0.0;
}
this->Controller = vtkMultiProcessController::GetGlobalController();
this->plane = NULL;
this->Plane = NULL;
this->UseNativeCutter = 1;
this->contourValues = vtkContourValues::New();
}
......@@ -73,9 +73,9 @@ vtkAMRCutPlane::~vtkAMRCutPlane()
this->contourValues->Delete();
this->contourValues = NULL;
if( this->plane != NULL )
this->plane->Delete();
this->plane = NULL;
if( this->Plane != NULL )
this->Plane->Delete();
this->Plane = NULL;
}
//------------------------------------------------------------------------------
......@@ -108,12 +108,12 @@ int vtkAMRCutPlane::FillOutputPortInformation(
//------------------------------------------------------------------------------
int vtkAMRCutPlane::RequestInformation(
vtkInformation* vtkNotUsed(rqst), vtkInformationVector** inputVector,
vtkInformationVector* outputVector )
vtkInformationVector* vtkNotUsed(outputVector) )
{
this->blocksToLoad.clear();
if( this->plane != NULL )
this->plane->Delete();
if( this->Plane != NULL )
this->Plane->Delete();
vtkInformation *input = inputVector[0]->GetInformationObject(0);
assert( "pre: input information object is NULL" && (input != NULL) );
......@@ -125,10 +125,10 @@ int vtkAMRCutPlane::RequestInformation(
input->Get(
vtkCompositeDataPipeline::COMPOSITE_DATA_META_DATA() ) );
this->plane = this->GetCutPlane( metadata );
assert( "Cut plane is NULL" && (this->plane != NULL) );
this->Plane = this->GetCutPlane( metadata );
assert( "Cut plane is NULL" && (this->Plane != NULL) );
this->ComputeAMRBlocksToLoad( this->plane, metadata );
this->ComputeAMRBlocksToLoad( this->Plane, metadata );
}
this->Modified();
......@@ -138,7 +138,7 @@ int vtkAMRCutPlane::RequestInformation(
//------------------------------------------------------------------------------
int vtkAMRCutPlane::RequestUpdateExtent(
vtkInformation* vtkNotUsed(rqst), vtkInformationVector** inputVector,
vtkInformationVector* outputVector)
vtkInformationVector* vtkNotUsed(outputVector) )
{
vtkInformation *inInfo = inputVector[0]->GetInformationObject(0);
assert( "pre: inInfo is NULL" && (inInfo != NULL) );
......@@ -190,7 +190,7 @@ int vtkAMRCutPlane::RequestData(
{
vtkCutter *myCutter = vtkCutter::New();
myCutter->SetInput( grid );
myCutter->SetCutFunction( this->plane );
myCutter->SetCutFunction( this->Plane );
myCutter->Update();
mbds->SetBlock( blockIdx, myCutter->GetOutput( ) );
++blockIdx;
......@@ -230,7 +230,7 @@ int vtkAMRCutPlane::RequestData(
// vtkIdType ptIdx = 0;
// for( ; ptIdx < grid->GetNumberOfPoints(); ++ptIdx )
// {
// double val = this->plane->EvaluateFunction( grid->GetPoint(ptIdx) );
// double val = this->Plane->EvaluateFunction( grid->GetPoint(ptIdx) );
// cutScalars->SetComponent( ptIdx, 0, val );
// } // END for all cells
// grid->GetPointData()->AddArray( cutScalars );
......@@ -249,7 +249,6 @@ void vtkAMRCutPlane::CutAMRBlock(
vtkPolyData *mesh = vtkPolyData::New();
vtkPoints *meshPts = vtkPoints::New();
vtkCellArray *verts = vtkCellArray::New();
vtkCellArray *cells = vtkCellArray::New();
......@@ -331,12 +330,13 @@ void vtkAMRCutPlane::ComputeAMRBlocksToLoad(
double bounds[6];
int NumLevels = m->GetNumberOfLevels();
int maxLevelToLoad =
(this->LevelOfResolution < m->GetNumberOfLevels() )?
this->LevelOfResolution : m->GetNumberOfLevels();
(this->LevelOfResolution < NumLevels )?
this->LevelOfResolution : NumLevels;
unsigned int level = 0;
for( ; level <= maxLevelToLoad; ++level )
for( ; level <= static_cast<unsigned int>(maxLevelToLoad); ++level )
{
unsigned int dataIdx = 0;
for( ; dataIdx < m->GetNumberOfDataSets( level ); ++dataIdx )
......@@ -385,12 +385,12 @@ bool vtkAMRCutPlane::PlaneIntersectsAMRBox( double bounds[6] )
{
// Store A,B,C,D from the plane equation
double plane[4];
plane[0] = this->plane->GetNormal()[0];
plane[1] = this->plane->GetNormal()[1];
plane[2] = this->plane->GetNormal()[2];
plane[3] = this->plane->GetNormal()[0]*this->plane->GetOrigin()[0] +
this->plane->GetNormal()[1]*this->plane->GetOrigin()[1] +
this->plane->GetNormal()[2]*this->plane->GetOrigin()[2];
plane[0] = this->Plane->GetNormal()[0];
plane[1] = this->Plane->GetNormal()[1];
plane[2] = this->Plane->GetNormal()[2];
plane[3] = this->Plane->GetNormal()[0]*this->Plane->GetOrigin()[0] +
this->Plane->GetNormal()[1]*this->Plane->GetOrigin()[1] +
this->Plane->GetNormal()[2]*this->Plane->GetOrigin()[2];
return( this->PlaneIntersectsAMRBox( plane,bounds) );
}
......
......@@ -142,7 +142,7 @@ class VTK_AMR_EXPORT vtkAMRCutPlane : public vtkMultiBlockDataSetAlgorithm
bool initialRequest;
bool UseNativeCutter;
vtkMultiProcessController *Controller;
vtkPlane *plane;
vtkPlane *Plane;
vtkContourValues *contourValues;
// BTX
......
......@@ -182,7 +182,7 @@ int vtkAMRFlashParticlesReader::GetTotalNumberOfParticles()
//------------------------------------------------------------------------------
vtkPolyData* vtkAMRFlashParticlesReader::GetParticles(
const char *file, const int blkidx )
const char *file, const int vtkNotUsed(blkidx) )
{
hid_t dataIdx = H5Dopen( this->Internal->FileIndex, file );
if( dataIdx < 0 )
......
......@@ -161,7 +161,7 @@ int vtkAMRFlashReader::FillMetaData( )
{
// Start numbering levels from 0!
int level = this->Internal->Blocks[ i ].Level-1;
int id = b2level[level];
// int id = b2level[level];
int internalIdx = i;
double blockMin[3];
......
......@@ -14,6 +14,14 @@
=========================================================================*/
#include "vtkAMRGaussianPulseSource.h"
#include "vtkObjectFactory.h"
#include "vtkOverlappingAMR.h"
#include "vtkUniformGrid.h"
#include "vtkCellData.h"
#include "vtkDoubleArray.h"
#include "vtkAMRUtilities.h"
#include "vtkInformation.h"
#include "vtkInformationVector.h"
#include "vtkCell.h"
#include <cassert>
......@@ -23,7 +31,7 @@ vtkStandardNewMacro(vtkAMRGaussianPulseSource);
vtkAMRGaussianPulseSource::vtkAMRGaussianPulseSource()
{
this->SetNumberOfInputPorts(0);
this->SetNumberOfOutputPorts(1);
this->RootSpacing[0] =
this->RootSpacing[1] =
this->RootSpacing[2] = 0.5;
......@@ -36,7 +44,7 @@ vtkAMRGaussianPulseSource::vtkAMRGaussianPulseSource()
this->PulseWidth[1] =
this->PulseWidth[2] = 0.5;
this->NumberOfLevels = 3;
this->NumberOfLevels = 1;
this->Dimension = 3;
this->RefinmentRatio = 2;
this->PulseAmplitude = 0.0001;
......@@ -54,12 +62,150 @@ void vtkAMRGaussianPulseSource::PrintSelf(ostream& os, vtkIndent indent)
this->Superclass::PrintSelf( os, indent );
}
//------------------------------------------------------------------------------
void vtkAMRGaussianPulseSource::ComputeCellCenter(
vtkUniformGrid *grid, vtkIdType cellIdx, double centroid[3] )
{
assert("pre: input grid instance is NULL" && (grid != NULL));
assert("pre: cell index is out-of-bounds!" &&
(cellIdx >= 0) && (cellIdx < grid->GetNumberOfCells()));
vtkCell *myCell = grid->GetCell( cellIdx );
assert( "ERROR: Cell is NULL" && (myCell != NULL) );
double pcenter[3];
double *weights = new double[ myCell->GetNumberOfPoints() ];
int subId = myCell->GetParametricCenter( pcenter );
myCell->EvaluateLocation( subId, pcenter, centroid, weights );
delete [] weights;
}
//------------------------------------------------------------------------------
void vtkAMRGaussianPulseSource::GeneratePulseField(vtkUniformGrid* grid)
{
assert("pre: grid is NULL!" && (grid != NULL));
assert("pre: grid is empty!" && (grid->GetNumberOfCells() >= 1) );
vtkDoubleArray *centroidArray = vtkDoubleArray::New();
centroidArray->SetName("Centroid");
centroidArray->SetNumberOfComponents( 3 );
centroidArray->SetNumberOfTuples( grid->GetNumberOfCells() );
vtkDoubleArray *pulseField = vtkDoubleArray::New();
pulseField->SetName( "Gaussian-Pulse" );
pulseField->SetNumberOfComponents( 1 );
pulseField->SetNumberOfTuples( grid->GetNumberOfCells() );
double centroid[3];
vtkIdType cellIdx = 0;
for(; cellIdx < grid->GetNumberOfCells(); ++cellIdx )
{
this->ComputeCellCenter(grid,cellIdx,centroid);
centroidArray->SetComponent(cellIdx,0,centroid[0]);
centroidArray->SetComponent(cellIdx,1,centroid[1]);
centroidArray->SetComponent(cellIdx,2,centroid[2]);
double pulse = this->ComputePulseAt(centroid);
pulseField->SetComponent(cellIdx,0,pulse);
} // END for all cells
grid->GetCellData()->AddArray( centroidArray );
centroidArray->Delete();
grid->GetCellData()->AddArray( pulseField );
pulseField->Delete();
}
//------------------------------------------------------------------------------
vtkUniformGrid* vtkAMRGaussianPulseSource::GetGrid(
double origin[3], double h[3], int ndim[3] )
{
vtkUniformGrid *grid = vtkUniformGrid::New();
grid->Initialize();
grid->SetOrigin( origin );
grid->SetSpacing( h );
grid->SetDimensions( ndim );
this->GeneratePulseField( grid );
return( grid );
}
//------------------------------------------------------------------------------
vtkUniformGrid* vtkAMRGaussianPulseSource::GetRootAMR()
{
double origin[3];
double h[3];
int ndim[3];
vtkUniformGrid *grid = NULL;
origin[0] = origin[1] = origin[2] = 0.0;
h[0] = h[1] = h[2] = 1.0;
switch( this->Dimension )
{
case 2:
origin[0] = origin[1] = -5.0;
ndim[0] = ndim[1] = 10;
ndim[2] = 1;
break;
case 3:
origin[0] = origin[1] = origin[2] = -5.0;
ndim[0] = ndim[1] = ndim[2] = 10;
break;
default:
vtkErrorMacro( "ERROR: Invalid grid dimension!\n" );
assert("ERROR: code should not reach here!" && false);
}
grid = this->GetGrid( origin, h, ndim );
assert("ERROR: cannot create root AMR grid!" && (grid != NULL) );
return( grid );
}
//------------------------------------------------------------------------------
void vtkAMRGaussianPulseSource::Generate2DDataSet( vtkOverlappingAMR *amr )
{
assert("pre: input amr dataset is NULL" && (amr != NULL));
vtkUniformGrid *root = this->GetRootAMR();
amr->SetNumberOfLevels( this->NumberOfLevels );
amr->SetDataSet(0,0, root);
root->Delete();
}
//------------------------------------------------------------------------------
void vtkAMRGaussianPulseSource::Generate3DDataSet( vtkOverlappingAMR *amr )
{
assert("pre: input amr dataset is NULL" && (amr != NULL));
vtkUniformGrid *root = this->GetRootAMR();
amr->SetNumberOfLevels( this->NumberOfLevels );
amr->SetDataSet(0,0, root);
root->Delete();
}
//------------------------------------------------------------------------------
int vtkAMRGaussianPulseSource::RequestData(
vtkInformation *request,
vtkInformationVector **inputVector,
vtkInformation * vtkNotUsed(request),
vtkInformationVector **vtkNotUsed(inputVector),
vtkInformationVector *outputVector )
{
vtkInformation *info = outputVector->GetInformationObject(0);
vtkOverlappingAMR *output =
vtkOverlappingAMR::SafeDownCast(info->Get(vtkDataObject::DATA_OBJECT()));
assert("pre: output should not be NULL!" && (output != NULL) );
switch( this->Dimension )
{
case 2:
this->Generate2DDataSet( output );
break;
case 3:
this->Generate3DDataSet( output );
break;
default:
vtkErrorMacro("Dimensions must be either 2 or 3!");
}
vtkAMRUtilities::GenerateMetaData( output, NULL );
return 1;
}
......@@ -23,6 +23,11 @@
#include <cmath> // For std::exp
class vtkOverlappingAMR;
class vtkUniformGrid;
class vtkInformation;
class vtkInformationVector;
class VTK_AMR_EXPORT vtkAMRGaussianPulseSource :
public vtkOverlappingAMRAlgorithm
{
......@@ -84,6 +89,33 @@ class VTK_AMR_EXPORT vtkAMRGaussianPulseSource :
// Computes the gaussian pulse at the given location based on the user
// supplied parameters for pulse width and origin.
double ComputePulseAt(const double x, const double y, const double z);
double ComputePulseAt( double pt[3] )
{return( this->ComputePulseAt(pt[0],pt[1],pt[2]) );}
// Description:
// Given the cell index w.r.t. to a uniform grid, this method computes the
// cartesian coordinates of the centroid of the cell.
void ComputeCellCenter(vtkUniformGrid *grid,
vtkIdType cellIdx,
double centroid[3] );
// Description:
// Generates a pulse field for the given uniform grid
void GeneratePulseField(vtkUniformGrid *grid);
// Description:
// Constructs a uniform grid path with the given origin/spacing and node
// dimensions.
vtkUniformGrid* GetGrid( double origin[3], double h[3], int ndim[3] );
// Description:
// Construct the root uniform grid AMR.
vtkUniformGrid* GetRootAMR();
// Description:
// Generate 2-D or 3-D DataSet
void Generate2DDataSet(vtkOverlappingAMR* amr);
void Generate3DDataSet(vtkOverlappingAMR* amr);
double RootSpacing[3];
double PulseOrigin[3];
......@@ -102,7 +134,7 @@ class VTK_AMR_EXPORT vtkAMRGaussianPulseSource :
// INLINE METHODS
//==============================================================================
inline double vtkAMRGaussianPulseSource::ComputePulseAt(
const double x, const double y, const double z)
const double x, const double y, const double vtkNotUsed(z))
{
double pulse = 0.0;
......
......@@ -139,7 +139,7 @@ int vtkAMRResampleFilter::RequestUpdateExtent(
int vtkAMRResampleFilter::RequestInformation(
vtkInformation* vtkNotUsed(rqst),
vtkInformationVector** inputVector,
vtkInformationVector* outputVector )
vtkInformationVector* vtkNotUsed(outputVector) )
{
assert( "pre: inputVector is NULL" && (inputVector != NULL) );
......@@ -408,7 +408,6 @@ void vtkAMRResampleFilter::SearchForDonorGridAtLevel(
vtkTimerLog::MarkStartEvent( oss.str().c_str() );
unsigned int dataIdx = 0;
for(donorGridId = 0; donorGridId < amrds->GetNumberOfDataSets(level); ++donorGridId )
{
donorCellIdx = -1;
......@@ -443,9 +442,10 @@ int vtkAMRResampleFilter::ProbeGridPointInAMR(
vtkUniformGrid *currentGrid = NULL;
int currentCellIdx = -1;
int donorCellIdx = -1;
unsigned int currentLevel = 0;;
unsigned int currentLevel = 0;
bool hadDonorGrid = false;
unsigned int donorGridId, currentGridId;
unsigned int donorGridId = 0;
unsigned int currentGridId = 0;
// STEP 0: Check the previously cached donor-grid
if( donorGrid != NULL )
......@@ -768,11 +768,6 @@ void vtkAMRResampleFilter::TransferToGridNodes(
for(pIdx = 0; pIdx < g->GetNumberOfPoints(); ++pIdx )
{
g->GetPoint( pIdx, qPoint );
if (pIdx == 50580)
{
int oops;
oops = 1;
}
donorCellIdx =
this->ProbeGridPointInAMRGraph(qPoint,donorGrid,
donorLevel, donorGridId,
......@@ -1062,8 +1057,7 @@ void vtkAMRResampleFilter::AdjustNumberOfSamplesInRegion(
}
else
{
int oops;
oops =1;
assert("ERROR: code should not reach here!" && false );
}
}
}
......
......@@ -100,7 +100,7 @@ bool vtkAMRSliceFilter::IsAMRData2D( vtkOverlappingAMR *input )
//------------------------------------------------------------------------------
void vtkAMRSliceFilter::InitializeOffSet(
vtkOverlappingAMR *inp, double *minBounds, double *maxBounds )
vtkOverlappingAMR* vtkNotUsed(inp), double *minBounds, double *maxBounds )
{
if( !this->initialRequest )
{
......@@ -318,7 +318,7 @@ void vtkAMRSliceFilter::ComputeAMRBlocksToLoad(
(this->EnablePrefetching==1)? this->MaxResolution+1 : this->MaxResolution;
unsigned int level=0;
for( ; level <= maxLevelToLoad; ++level )
for( ; level <= static_cast<unsigned int>(maxLevelToLoad); ++level )
{
unsigned int dataIdx = 0;
for( ; dataIdx < metadata->GetNumberOfDataSets( level ); ++dataIdx )
......@@ -373,12 +373,13 @@ void vtkAMRSliceFilter::GetAMRSliceInPlane(
// Storage for the AMR box bounds
double bounds[6];
int NumLevels = inp->GetNumberOfLevels();
int maxLevel =
(this->MaxResolution < inp->GetNumberOfLevels() )?
this->MaxResolution+1 : inp->GetNumberOfLevels();
(this->MaxResolution < NumLevels )?
this->MaxResolution+1 : NumLevels;
unsigned int level=0;
for( ; level < maxLevel; ++level )
for( ; level < static_cast<unsigned int>(maxLevel); ++level )
{
unsigned int dataIdx=0;
for( ; dataIdx < inp->GetNumberOfDataSets(level); ++dataIdx )
......@@ -598,7 +599,7 @@ int vtkAMRSliceFilter::RequestInformation(
//------------------------------------------------------------------------------
int vtkAMRSliceFilter::RequestUpdateExtent(
vtkInformation*, vtkInformationVector **inputVector,
vtkInformationVector *outputVector )
vtkInformationVector* vtkNotUsed(outputVector) )
{
if( this->ForwardUpstream == 1 )
......
......@@ -96,7 +96,7 @@ void vtkExtentRCBPartitioner::GetExtent( const int idx, int ext[6] )
}
//------------------------------------------------------------------------------
void vtkExtentRCBPartitioner::AddExtent( const int idx, int ext[6] )
void vtkExtentRCBPartitioner::AddExtent( const int vtkNotUsed(idx), int ext[6] )
{
for( int i=0; i < 6; ++i )
this->pextents.push_back( ext[ i ] );
......
......@@ -64,6 +64,10 @@ void AttachPulseToGrid( vtkUniformGrid *grid );
//
int main( int argc, char **argv )
{
// Fix compiler warning for unused variables
static_cast<void>(argc);
static_cast<void>(argv);
// STEP 0: Initialize gaussian pulse parameters
SetPulse();
......@@ -129,7 +133,6 @@ vtkHierarchicalBoxDataSet* GetAMRDataSet()
int ndim[3];
int blockId = -1;
int level = -1;
int rank = 0;
// Root Block -- Block 0,0
ndim[0] = 6; ndim[1] = 5; ndim[2] = 1;
......
......@@ -78,6 +78,10 @@ void WriteAMRData( vtkHierarchicalBoxDataSet *amrData, std::string prefix );
//
int main( int argc, char **argv )
{
// Fix compiler warning for unused variables
static_cast<void>(argc);
static_cast<void>(argv);
// STEP 0: Initialize gaussian pulse parameters
SetPulse();
......@@ -129,7 +133,6 @@ vtkHierarchicalBoxDataSet* GetAMRDataSet()
int ndim[3];
int blockId = -1;
int level = -1;
int rank = 0;
// Root Block -- Block 0
ndim[0] = 6; ndim[1] = ndim[2] = 5;
......
......@@ -809,7 +809,6 @@ vtkIdType vtkImageData::FindCell(double x[3], vtkCell *vtkNotUsed(cell),
}
}
vtkIdType cellIdx = this->ComputeCellId( idx );
if (weights)
{
// Shift parametric coordinates for XZ/YZ planes
......
......@@ -43,7 +43,7 @@ class VTK_FILTERING_EXPORT vtkNonOverlappingAMR : public vtkUniformGridAMR
{this->Superclass::ShallowCopy(src);}
virtual void DeepCopy(vtkDataObject *src)
{this->Superclass::DeepCopy(src);}
virtual void CopyStructure(vtkNonOverlappingAMR* input)