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

ENH/COMP: Minor bugfixes and compilation issues

Fixed construction of vtkHierarchicalDataSet and
added vtkAMR library to list of target link libraries.
parent e7f15e73
......@@ -20,8 +20,11 @@
#include "vtkUniformGrid.h"
#include "vtkAMRBox.h"
#include "vtkAMRConnectivityFilter.h"
#include "vtkHierarchicalBoxDataSet.h"
#include "vtkXMLPHierarchicalBoxDataWriter.h"
#include "vtkMultiProcessController.h"
#include "vtkMPIController.h"
#include "vtkAssertUtils.hpp"
// Global Variables
......@@ -29,19 +32,55 @@ vtkMultiProcessController *Controller;
// Function Prototypes
vtkHierarchicalBoxDataSet* GetAMRDataSet( );
vtkUniformGrid* GetGrid( vtkAMRBox &gridBox );
vtkUniformGrid* GetGrid( double* origin,double* h,int* ndim );
void WriteAMRData( vtkHierarchicalBoxDataSet *amrdata, const char* filename );
int main( int argc, char **argv )
{
MPI_Init( &argc, &argv );
Controller = vtkMultiProcessController::GetGlobalController();
Controller = vtkMPIController::New();
Controller->Initialize( &argc, &argv );
vtkAssertUtils::assertNotNull( Controller,__FILE__,__LINE__ );
// STEP 0: Read In AMR data
std::cout << "Reading data!" << std::endl;
std::cout.flush( );
vtkHierarchicalBoxDataSet *amrData = GetAMRDataSet();
vtkAssertUtils::assertNotNull( amrData, __FILE__, __LINE__ );
vtkAssertUtils::assertEquals(
amrData->GetNumberOfLevels(),2,__FILE__,__LINE__);
vtkAssertUtils::assertEquals(
amrData->GetNumberOfDataSets(0),1,__FILE__,__LINE__);
vtkAssertUtils::assertEquals(
amrData->GetNumberOfDataSets(1),1,__FILE__,__LINE__ );
WriteAMRData( amrData, "Input" );
std::cout << "Done reading!" << std::endl;
std::cout.flush( );
Controller->Barrier( );
// STEP 1: Compute inter-block and inter-process connectivity
std::cout << "Computing inter-block & inter-process connectivity!\n";
std::cout.flush( );
vtkAMRConnectivityFilter* connectivityFilter =
vtkAMRConnectivityFilter::New( );
vtkAssertUtils::assertNotNull( connectivityFilter,__FILE__,__LINE__);
connectivityFilter->SetController( Controller );
connectivityFilter->SetAMRDataSet( amrData );
connectivityFilter->ComputeConnectivity();
std::cout << "Done computing connectivity!\n";
std::cout.flush( );
Controller->Barrier();
MPI_Finalize();
connectivityFilter->Print( std::cout );
Controller->Barrier();
// STEP 2: Data transfer
Controller->Finalize();
return 0;
}
......@@ -49,20 +88,95 @@ int main( int argc, char **argv )
// Function Prototype Implementation
//=============================================================================
void WriteAMRData( vtkHierarchicalBoxDataSet* amrdata, const char* filename )
{
vtkAssertUtils::assertNotNull(amrdata,__FILE__,__LINE__);
// vtkXMLPHierarchicalBoxDataWriter *myWriter =
// vtkXMLPHierarchicalBoxDataWriter::New( );
// myWriter->SetInput( amrdata );
// myWriter->SetFileName( filename );
// myWriter->Write();
}
//------------------------------------------------------------------------------
vtkHierarchicalBoxDataSet* GetAMRDataSet( )
{
vtkAssertUtils::assertNotNull( Controller, __FILE__, __LINE__ );
vtkHierarchicalBoxDataSet *data = vtkHierarchicalBoxDataSet::New( );
vtkAssertUtils::assertNotNull( data, __FILE__, __LINE__ );
switch( Controller->GetLocalProcessId() )
data->Initialize();
double origin[3];
double h[3];
int ndim[3];
int dim = 2;
int blockId = -1;
int level = -1;
int rank = Controller->GetLocalProcessId();
int numProcs = Controller->GetNumberOfProcesses();
switch( rank )
{
case 0:
// TODO: implement this
{
vtkAssertUtils::assertEquals( dim, 2, __FILE__, __LINE__ );
ndim[0] = 11;
ndim[1] = 10;
ndim[2] = 1;
origin[0] = 0.0;
origin[1] = 0.0;
origin[2] = 0.0;
blockId = 0;
level = 0;
h[0] = h[1] = h[2] = 0.5;
vtkAMRBox myBox(origin,dim,ndim,h,blockId,level,rank);
vtkUniformGrid *myGrid = GetGrid( origin,h,ndim );
vtkAssertUtils::assertNotNull( myGrid, __FILE__, __LINE__ );
data->SetDataSet( level,0,myBox,myGrid);
ndim[0] = 10;
ndim[1] = 7;
ndim[2] = 1;
origin[0] = 1.5;
origin[1] = 1.5;
origin[2] = 0.0;
blockId = 1;
level = 1;
h[0] = h[1] = h[2] = 0.25;
vtkAMRBox rmtBox(origin,dim,ndim,h,blockId,level,blockId%numProcs);
data->SetDataSet( level,0,rmtBox,NULL);
}
break;
case 1:
// TODO: implement this
{
vtkAssertUtils::assertEquals( dim, 2, __FILE__, __LINE__ );
ndim[0] = 10;
ndim[1] = 7;
ndim[2] = 1;
origin[0] = 1.5;
origin[1] = 1.5;
origin[2] = 0.0;
blockId = 1;
level = 1;
h[0] = h[1] = h[2] = 0.25;
vtkAMRBox myBox(origin,dim,ndim,h,blockId,level,rank);
vtkUniformGrid *myGrid = GetGrid( origin,h,ndim );
vtkAssertUtils::assertNotNull( myGrid, __FILE__, __LINE__ );
data->SetDataSet( level,0,myBox,myGrid);
ndim[0] = 11;
ndim[1] = 10;
ndim[2] = 1;
origin[0] = 0.0;
origin[1] = 0.0;
origin[2] = 0.0;
blockId = 0;
level = 0;
h[0] = h[1] = h[2] = 0.5;
vtkAMRBox rmtBox(origin,dim,ndim,h,blockId,level,blockId%numProcs);
data->SetDataSet( level,0,rmtBox,NULL);
}
break;
default:
/* Note: Code should not reach here! */
......@@ -74,8 +188,12 @@ vtkHierarchicalBoxDataSet* GetAMRDataSet( )
}
//----------------------------------------------------------------------------
vtkUniformGrid* GetGrid( vtkAMRBox &gridBox )
vtkUniformGrid* GetGrid( double *origin, double *spacing, int *ndim )
{
// TODO: implement this
return NULL;
vtkUniformGrid *grd = vtkUniformGrid::New();
grd->Initialize();
grd->SetOrigin( origin );
grd->SetSpacing( spacing );
grd->SetDimensions( ndim );
return grd;
}
......@@ -17,8 +17,7 @@ IF (VTK_USE_MPI)
SET(MPI_LIBRARIES ${MPI_LIBRARIES} "${MPI_EXTRA_LIBRARY}")
ENDIF (MPI_EXTRA_LIBRARY)
# Needed for mpich 2
ADD_DEFINITIONS("-DMPICH_IGNORE_CXX_SEEK")
ADD_DEFINITIONS("-DMPICH_IGNORE_CXX_SEEK -DASSERT_ON")
ENDIF (VTK_USE_MPI)
......
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