Commit 795f2b30 authored by George Zagaris's avatar George Zagaris
Browse files

BUGFIX:Remove partial overlaps from sample problem

Fixed construction of sample problem, s.t.,
high resolution cells covers the entire low
resolution cells, i.e., no partial overlap.
Furthermore, vtkXMLHierarchicalBoxWriter is
used to write the data-set.
parent b34b5547
......@@ -205,4 +205,3 @@ void vtkAMRDataTransferFilter::WriteData( vtkHierarchicalBoxDataSet* amrData,
this->Controller->Barrier();
}
......@@ -16,6 +16,7 @@
// A simple utility to demonstrate & test the parallel AMR functionality
// and inter-block data transfer.
#include <cassert>
#include <mpi.h>
#include "vtkUniformGrid.h"
......@@ -32,34 +33,45 @@
#include "vtkXMLPHierarchicalBoxDataWriter.h"
#include "vtkMultiProcessController.h"
#include "vtkMPIController.h"
#include "vtkAssertUtils.hpp"
#include "vtkAMRUtilities.h"
// Global Variables
vtkMultiProcessController *Controller;
// Function Prototypes
vtkHierarchicalBoxDataSet* GetAMRDataSet( );
vtkHierarchicalBoxDataSet* GetSerialAMRDataSet();
vtkHierarchicalBoxDataSet* GetParallelAMRDataSet();
vtkUniformGrid* GetGrid( double* origin,double* h,int* ndim );
//
// Main
//
int main( int argc, char **argv )
{
Controller = vtkMPIController::New();
Controller->Initialize( &argc, &argv );
vtkAssertUtils::assertNotNull( Controller,__FILE__,__LINE__ );
assert("pre: Controller != NULL" && (Controller != NULL ) );
// STEP 0: Read In AMR data
std::cout << "Reading data!" << std::endl;
std::cout << "Constructing Sample AMR 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),2,__FILE__,__LINE__ );
vtkHierarchicalBoxDataSet *amrData = NULL;
if( Controller->GetNumberOfProcesses( ) == 3 )
amrData = GetParallelAMRDataSet( );
else if( Controller->GetNumberOfProcesses() == 1 )
amrData = GetSerialAMRDataSet( );
else
{
std::cerr << "Can only run with 1 or 3 MPI processes!\n";
std::cerr.flush();
return( -1 );
}
assert("pre: AMRData != NULL" && (amrData != NULL) );
assert("pre: numLevels == 2" && (amrData->GetNumberOfLevels()==2) );
std::cout << "Done reading!" << std::endl;
std::cout.flush( );
......@@ -69,9 +81,7 @@ int main( int argc, char **argv )
std::cout << "Computing inter-block & inter-process connectivity!\n";
std::cout.flush( );
vtkAMRConnectivityFilter* connectivityFilter =
vtkAMRConnectivityFilter::New( );
vtkAssertUtils::assertNotNull( connectivityFilter,__FILE__,__LINE__);
vtkAMRConnectivityFilter* connectivityFilter= vtkAMRConnectivityFilter::New( );
connectivityFilter->SetController( Controller );
connectivityFilter->SetAMRDataSet( amrData );
connectivityFilter->ComputeConnectivity();
......@@ -88,22 +98,25 @@ int main( int argc, char **argv )
std::cout.flush();
vtkAMRDataTransferFilter* transferFilter = vtkAMRDataTransferFilter::New();
vtkAssertUtils::assertNotNull( transferFilter,__FILE__,__LINE__);
transferFilter->SetController( Controller );
transferFilter->SetAMRDataSet( amrData );
transferFilter->SetNumberOfGhostLayers( 2 );
transferFilter->SetRemoteConnectivity(
connectivityFilter->GetRemoteConnectivity() );
connectivityFilter->GetRemoteConnectivity() );
transferFilter->SetLocalConnectivity(
connectivityFilter->GetLocalConnectivity() );
connectivityFilter->GetLocalConnectivity() );
transferFilter->Transfer();
std::cout << "[DONE]\n";
std::cout.flush();
Controller->Barrier();
// STEP 3: CleanUp
amrData->Delete();
connectivityFilter->Delete();
transferFilter->Delete();
Controller->Finalize();
return 0;
}
......@@ -113,12 +126,10 @@ int main( int argc, char **argv )
//=============================================================================
//------------------------------------------------------------------------------
vtkHierarchicalBoxDataSet* GetAMRDataSet( )
vtkHierarchicalBoxDataSet* GetSerialAMRDataSet( )
{
vtkAssertUtils::assertNotNull( Controller, __FILE__, __LINE__ );
vtkHierarchicalBoxDataSet *data = vtkHierarchicalBoxDataSet::New( );
vtkAssertUtils::assertNotNull( data, __FILE__, __LINE__ );
data->Initialize();
double origin[3];
......@@ -127,148 +138,62 @@ vtkHierarchicalBoxDataSet* GetAMRDataSet( )
int dim = 2;
int blockId = -1;
int level = -1;
int rank = Controller->GetLocalProcessId();
int numProcs = Controller->GetNumberOfProcesses();
switch( rank )
{
case 0:
{
// BLOCK 0
vtkAssertUtils::assertEquals( dim, 2, __FILE__, __LINE__ );
ndim[0] = 25;
ndim[1] = 25;
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 rmtBox0(origin,dim,ndim,h,blockId,level,rank);
vtkUniformGrid *myGrid = GetGrid( origin,h,ndim );
vtkAssertUtils::assertNotNull( myGrid, __FILE__, __LINE__ );
data->SetDataSet( level,0,rmtBox0,myGrid);
// BLOCK 1
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 rmtBox1(origin,dim,ndim,h,blockId,level,blockId%numProcs);
data->SetDataSet( level,0,rmtBox1,NULL);
// BLOCK 2
ndim[0] = 10;
ndim[1] = 7;
ndim[2] = 1;
origin[0] = 1.0;
origin[1] = 3.0;
origin[2] = 0.0;
blockId = 2;
level = 1;
h[0] = h[1] = h[2] = 0.25;
vtkAMRBox rmtBox2(origin,dim,ndim,h,blockId,level,blockId%numProcs);
data->SetDataSet( level,1,rmtBox2,NULL);
}
break;
case 1:
{
// BLOCK 1
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 rmtBox1(origin,dim,ndim,h,blockId,level,rank);
vtkUniformGrid *myGrid = GetGrid( origin,h,ndim );
vtkAssertUtils::assertNotNull( myGrid, __FILE__, __LINE__ );
data->SetDataSet( level,0,rmtBox1,myGrid);
// BLOCK 0
ndim[0] = 25;
ndim[1] = 25;
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 rmtBox0(origin,dim,ndim,h,blockId,level,blockId%numProcs);
data->SetDataSet( level,0,rmtBox0,NULL);
// BLOCK 2
ndim[0] = 10;
ndim[1] = 7;
ndim[2] = 1;
origin[0] = 1.0;
origin[1] = 3.0;
origin[2] = 0.0;
blockId = 2;
level = 1;
h[0] = h[1] = h[2] = 0.25;
vtkAMRBox rmtBox2(origin,dim,ndim,h,blockId,level,blockId%numProcs);
data->SetDataSet( level,1,rmtBox2,NULL);
}
break;
case 2:
{
// BLOCK 2
ndim[0] = 10;
ndim[1] = 7;
ndim[2] = 1;
origin[0] = 1.0;
origin[1] = 3.0;
origin[2] = 0.0;
blockId = 2;
level = 1;
h[0] = h[1] = h[2] = 0.25;
vtkAMRBox rmtBox2(origin,dim,ndim,h,blockId,level,blockId%numProcs);
vtkUniformGrid *myGrid = GetGrid( origin,h,ndim );
vtkAssertUtils::assertNotNull( myGrid, __FILE__, __LINE__ );
data->SetDataSet( level,1,rmtBox2,NULL);
// BLOCK 0
ndim[0] = 25;
ndim[1] = 25;
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 rmtBox0(origin,dim,ndim,h,blockId,level,blockId%numProcs);
data->SetDataSet( level,0,rmtBox0,NULL);
// BLOCK 1
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 rmtBox1(origin,dim,ndim,h,blockId,level,blockId%numProcs);
data->SetDataSet( level,0,rmtBox1,NULL);
}
break;
default:
/* Note: Code should not reach here! */
return NULL;
}
int rank = 0;
// BLOCK 0
ndim[0] = 25;
ndim[1] = 25;
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;
vtkUniformGrid *grid0 = GetGrid( origin,h,ndim );
data->SetDataSet( level,blockId,grid0);
grid0->Delete();
// BLOCK 1
ndim[0] = 11;
ndim[1] = 7;
ndim[2] = 1;
origin[0] = 1.5;
origin[1] = 1.5;
origin[2] = 0.0;
blockId = 0;
level = 1;
h[0] = h[1] = h[2] = 0.25;
vtkUniformGrid *grid1 = GetGrid( origin,h,ndim );
data->SetDataSet( level,blockId,grid1);
grid1->Delete();
// BLOCK 2
ndim[0] = 11;
ndim[1] = 7;
ndim[2] = 1;
origin[0] = 1.0;
origin[1] = 3.0;
origin[2] = 0.0;
blockId = 1;
level = 1;
h[0] = h[1] = h[2] = 0.25;
vtkUniformGrid *grid2 = GetGrid( origin,h,ndim );
data->SetDataSet( level,blockId,grid2);
grid2->Delete();
vtkAMRUtilities::GenerateMetaData( data, NULL );
data->GenerateVisibilityArrays();
return( data );
}
//------------------------------------------------------------------------------
vtkHierarchicalBoxDataSet* GetParallelAMRDataSet( )
{
vtkHierarchicalBoxDataSet *data = vtkHierarchicalBoxDataSet::New( );
data->Initialize();
// TODO: imlpement this
return( data );
......@@ -290,10 +215,9 @@ vtkUniformGrid* GetGrid( double *origin, double *spacing, int *ndim )
for( int cellIdx=0; cellIdx < grd->GetNumberOfCells(); ++cellIdx )
{
vtkCell* myCell = grd->GetCell( cellIdx);
vtkAssertUtils::assertNotNull( myCell, __FILE__, __LINE__ );
assert( "post: myCell != NULL" && (myCell != NULL) );
vtkPoints *cellPoints = myCell->GetPoints();
vtkAssertUtils::assertNotNull( cellPoints, __FILE__, __LINE__ );
double xyzCenter[3];
xyzCenter[0] = 0.0;
......
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