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; ...@@ -36,29 +36,29 @@ using namespace walberla;
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> ( return new GhostLayerField<real_t,1> (
storage->getNumberOfXCells( *block ), // number of cells in x direction storage->getNumberOfXCells( *block ), // number of cells in x direction
storage->getNumberOfYCells( *block ), // number of cells in y direction storage->getNumberOfYCells( *block ), // number of cells in y direction
storage->getNumberOfZCells( *block ), // number of cells in z direction storage->getNumberOfZCells( *block ), // number of cells in z direction
1, // number of ghost layers 1, // number of ghost layers
double(1), // initial value real_t(1), // initial value
field::fzyx); 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> ( return new cuda::GPUField<real_t> (
storage->getNumberOfXCells( *block ), // number of cells in x direction storage->getNumberOfXCells( *block ), // number of cells in x direction
storage->getNumberOfYCells( *block ), // number of cells in y direction storage->getNumberOfYCells( *block ), // number of cells in y direction
storage->getNumberOfZCells( *block ), // number of cells in z direction storage->getNumberOfZCells( *block ), // number of cells in z direction
1, // fSize 1, // fSize
1, // number of ghost layers 1, // number of ghost layers
field::fzyx ); field::fzyx );
} }
...@@ -68,37 +68,37 @@ int main( int argc, char ** argv ) ...@@ -68,37 +68,37 @@ int main( int argc, char ** argv )
debug::enterTestMode(); debug::enterTestMode();
shared_ptr< StructuredBlockForest > blocks = blockforest::createUniformBlockGrid ( 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(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) 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 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, // one block per process - "false" means all blocks to one process
false, false, false ); // no periodicity 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 ) for ( auto blockIterator = blocks->begin(); blockIterator != blocks->end(); ++blockIterator )
{ {
IBlock & currentBlock = *blockIterator; IBlock & currentBlock = *blockIterator;
// get the field stored on the current block // get the field stored on the current block
auto cpuField = currentBlock.getData< GhostLayerField<double,1> > ( cpuFieldID ); auto cpuField = currentBlock.getData< GhostLayerField<real_t,1> > ( cpuFieldID );
auto gpuField = currentBlock.getData< cuda::GPUField<double> > ( gpuFieldID ); auto gpuField = currentBlock.getData< cuda::GPUField<real_t> > ( gpuFieldID );
cuda::fieldCpy( *gpuField, *cpuField ); cuda::fieldCpy( *gpuField, *cpuField );
auto myKernel = cuda::make_kernel( &kernel_double ); 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.addFieldIndexingParam(indexing);
myKernel(); myKernel();
cuda::fieldCpy( *cpuField, *gpuField ); 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 ) ...@@ -108,5 +108,5 @@ int main( int argc, char ** argv )
//gui.run(); //gui.run();
return 0; return EXIT_SUCCESS;
} }
...@@ -206,11 +206,7 @@ int main(int argc, char** argv) ...@@ -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 v2 = velField->get(cell_idx_c(cellsPerBlock[0] / 2), i + 1, cell_idx_c(cellsPerBlock[2] / 2), 0);
real_t grad = v2 - v1; real_t grad = v2 - v1;
// WALBERLA_LOG_DEVEL_VAR(grad) // WALBERLA_LOG_DEVEL_VAR(grad)
#ifdef WALBERLA_DOUBLE_ACCURACY WALBERLA_ASSERT_FLOAT_EQUAL(grad, 0.0)
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
} }
} }
......
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