Commit 5a179802 authored by Markus Holzer's avatar Markus Holzer
Browse files

Minor changes

parent f65bfb0b
Pipeline #40104 failed with stages
in 104 minutes and 55 seconds
......@@ -36,29 +36,29 @@ using namespace walberla;
namespace walberla{
void kernel_double( cuda::FieldAccessor<double> f );
void kernel_double( cuda::FieldAccessor<real_t> f );
}
GhostLayerField<double,1> * createCPUField( IBlock* const block, StructuredBlockStorage* const storage )
GhostLayerField<real_t,1> * createCPUField( IBlock* const block, StructuredBlockStorage* const storage )
{
return new GhostLayerField<double,1> (
storage->getNumberOfXCells( *block ), // number of cells in x direction
storage->getNumberOfYCells( *block ), // number of cells in y direction
storage->getNumberOfZCells( *block ), // number of cells in z direction
1, // number of ghost layers
double(1), // initial value
field::fzyx);
return new GhostLayerField<real_t,1> (
storage->getNumberOfXCells( *block ), // number of cells in x direction
storage->getNumberOfYCells( *block ), // number of cells in y direction
storage->getNumberOfZCells( *block ), // number of cells in z direction
1, // number of ghost layers
real_t(1), // initial value
field::fzyx);
}
cuda::GPUField<double> * createGPUField( IBlock* const block, StructuredBlockStorage* const storage )
cuda::GPUField<real_t> * createGPUField( IBlock* const block, StructuredBlockStorage* const storage )
{
return new cuda::GPUField<double> (
storage->getNumberOfXCells( *block ), // number of cells in x direction
storage->getNumberOfYCells( *block ), // number of cells in y direction
storage->getNumberOfZCells( *block ), // number of cells in z direction
1, // fSize
1, // number of ghost layers
field::fzyx );
return new cuda::GPUField<real_t> (
storage->getNumberOfXCells( *block ), // number of cells in x direction
storage->getNumberOfYCells( *block ), // number of cells in y direction
storage->getNumberOfZCells( *block ), // number of cells in z direction
1, // fSize
1, // number of ghost layers
field::fzyx );
}
......@@ -68,37 +68,37 @@ int main( int argc, char ** argv )
debug::enterTestMode();
shared_ptr< StructuredBlockForest > blocks = blockforest::createUniformBlockGrid (
uint_t(1), uint_t(1), uint_t(1), // number of blocks in x,y,z direction
uint_t(14), uint_t(14), uint_t(14), // how many cells per block (x,y,z)
real_c(0.5), // dx: length of one cell in physical coordinates
false, // one block per process - "false" means all blocks to one process
false, false, false ); // no periodicity
uint_t(1), uint_t(1), uint_t(1), // number of blocks in x,y,z direction
uint_t(14), uint_t(14), uint_t(14), // how many cells per block (x,y,z)
real_c(0.5), // dx: length of one cell in physical coordinates
false, // one block per process - "false" means all blocks to one process
false, false, false ); // no periodicity
BlockDataID cpuFieldID = blocks->addStructuredBlockData< GhostLayerField<double,1> > ( &createCPUField, "CPUField" );
BlockDataID cpuFieldID = blocks->addStructuredBlockData< GhostLayerField<real_t,1> > ( &createCPUField, "CPUField" );
BlockDataID gpuFieldID = blocks->addStructuredBlockData< cuda::GPUField<double> > ( &createGPUField, "GPUField" );
BlockDataID gpuFieldID = blocks->addStructuredBlockData< cuda::GPUField<real_t> > ( &createGPUField, "GPUField" );
for ( auto blockIterator = blocks->begin(); blockIterator != blocks->end(); ++blockIterator )
{
IBlock & currentBlock = *blockIterator;
// get the field stored on the current block
auto cpuField = currentBlock.getData< GhostLayerField<double,1> > ( cpuFieldID );
auto gpuField = currentBlock.getData< cuda::GPUField<double> > ( gpuFieldID );
auto cpuField = currentBlock.getData< GhostLayerField<real_t,1> > ( cpuFieldID );
auto gpuField = currentBlock.getData< cuda::GPUField<real_t> > ( gpuFieldID );
cuda::fieldCpy( *gpuField, *cpuField );
auto myKernel = cuda::make_kernel( &kernel_double );
auto indexing = cuda::FieldIndexing<double>::sliceBeforeGhostLayerXYZ( *gpuField, 1, stencil::W, true );
auto indexing = cuda::FieldIndexing<real_t>::sliceBeforeGhostLayerXYZ( *gpuField, 1, stencil::W, true );
myKernel.addFieldIndexingParam(indexing);
myKernel();
cuda::fieldCpy( *cpuField, *gpuField );
WALBERLA_ASSERT_FLOAT_EQUAL( cpuField->get(0,0,0), real_t(2) );
WALBERLA_ASSERT_FLOAT_EQUAL( cpuField->get(0,0,0), real_t(2) )
}
......@@ -108,5 +108,5 @@ int main( int argc, char ** argv )
//gui.run();
return 0;
return EXIT_SUCCESS;
}
......@@ -206,11 +206,7 @@ int main(int argc, char** argv)
real_t v2 = velField->get(cell_idx_c(cellsPerBlock[0] / 2), i + 1, cell_idx_c(cellsPerBlock[2] / 2), 0);
real_t grad = v2 - v1;
// WALBERLA_LOG_DEVEL_VAR(grad)
#ifdef WALBERLA_DOUBLE_ACCURACY
WALBERLA_CHECK_FLOAT_EQUAL_EPSILON(grad, 0.0, real_c(1e-16))
#else
WALBERLA_CHECK_FLOAT_EQUAL_EPSILON(grad, 0.0, real_c(1e-8))
#endif
WALBERLA_ASSERT_FLOAT_EQUAL(grad, 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