From 05702a6a51954c56eed4961470ac4092ca09d05f Mon Sep 17 00:00:00 2001 From: markus <markus.holzer@fau.de> Date: Fri, 5 Jun 2020 12:23:44 +0200 Subject: [PATCH] added comparison between solution and approximation --- tests/cuda/codegen/CodegenPoissonGPU.cpp | 7 +++++-- tests/cuda/codegen/CudaPoisson.py | 6 +++--- tests/field/codegen/CodegenPoisson.cpp | 11 +++++++---- tests/field/codegen/Poisson.py | 4 ++-- 4 files changed, 17 insertions(+), 11 deletions(-) diff --git a/tests/cuda/codegen/CodegenPoissonGPU.cpp b/tests/cuda/codegen/CodegenPoissonGPU.cpp index 166e8793c..fd88bf1fb 100644 --- a/tests/cuda/codegen/CodegenPoissonGPU.cpp +++ b/tests/cuda/codegen/CodegenPoissonGPU.cpp @@ -84,8 +84,7 @@ void initF( const shared_ptr< StructuredBlockStorage > & blocks, const BlockData CellInterval xyz = f->xyzSize(); for( auto cell = xyz.begin(); cell != xyz.end(); ++cell ) { - const Vector3< real_t > p = blocks->getBlockLocalCellCenter( *block, *cell ); - f->get( *cell ) = real_t(4) * math::pi * math::pi * std::sin( real_t(2) * math::pi * p[0] ) * std::sinh( real_t(2) * math::pi * p[1] ); + f->get( *cell ) = 0.0; } } } @@ -137,6 +136,10 @@ void testPoisson() cuda::fieldCpy<GPUField, ScalarField_T>( blocks, gpufId, cpufId ); timeloop.run(); cuda::fieldCpy<ScalarField_T, GPUField>( blocks, cpuFieldID, gpuField ); + + auto firstBlock = blocks->begin(); + auto f = firstBlock->getData<ScalarField_T>( cpuFieldID ); + WALBERLA_CHECK_LESS(f->get(50,99,0) - std::sin( math::pi * 0.5 ) * std::sinh( math::pi * 0.99 ), 0.01); } diff --git a/tests/cuda/codegen/CudaPoisson.py b/tests/cuda/codegen/CudaPoisson.py index 011b41494..53752ee96 100644 --- a/tests/cuda/codegen/CudaPoisson.py +++ b/tests/cuda/codegen/CudaPoisson.py @@ -12,8 +12,8 @@ with CodeGeneration() as ctx: @ps.kernel def kernel_func(): - dst[0, 0] @= ((dx**2 * (src[1, 0] + src[-1, 0])) + - (dy**2 * (src[0, 1] + src[0, -1])) - + src[0, 0] @= ((dy**2 * (src[1, 0] + src[-1, 0])) + + (dx**2 * (src[0, 1] + src[0, -1])) - (rhs[0, 0] * dx**2 * dy**2)) / (2 * (dx**2 + dy**2)) - generate_sweep(ctx, 'PoissonGPU', kernel_func, field_swaps=[(src, dst)], target='gpu') + generate_sweep(ctx, 'PoissonGPU', kernel_func, target='gpu') diff --git a/tests/field/codegen/CodegenPoisson.cpp b/tests/field/codegen/CodegenPoisson.cpp index 52b93bbbd..f5137375a 100644 --- a/tests/field/codegen/CodegenPoisson.cpp +++ b/tests/field/codegen/CodegenPoisson.cpp @@ -70,8 +70,7 @@ void initF( const shared_ptr< StructuredBlockStorage > & blocks, const BlockData CellInterval xyz = f->xyzSize(); for( auto cell = xyz.begin(); cell != xyz.end(); ++cell ) { - const Vector3< real_t > p = blocks->getBlockLocalCellCenter( *block, *cell ); - f->get( *cell ) = real_t(4) * math::pi * math::pi * std::sin( real_t(2) * math::pi * p[0] ) * std::sinh( real_t(2) * math::pi * p[1] ); + f->get( *cell ) = 0.0; } } } @@ -79,9 +78,9 @@ void initF( const shared_ptr< StructuredBlockStorage > & blocks, const BlockData void testPoisson() { - const uint_t xCells = uint_t(200); + const uint_t xCells = uint_t(100); const uint_t yCells = uint_t(100); - const real_t xSize = real_t(2); + const real_t xSize = real_t(1); const real_t ySize = real_t(1); const real_t dx = xSize / real_c( xCells + uint_t(1) ); const real_t dy = ySize / real_c( yCells + uint_t(1) ); @@ -116,6 +115,10 @@ void testPoisson() << Sweep( pystencils::Poisson(fId, fieldID, dx, dy), "Poisson Kernel" ); timeloop.run(); + + auto firstBlock = blocks->begin(); + auto f = firstBlock->getData<ScalarField_T>( fieldID ); + WALBERLA_CHECK_LESS(f->get(50,99,0) - std::sin( math::pi * 0.5 ) * std::sinh( math::pi * 0.99 ), 0.01); } diff --git a/tests/field/codegen/Poisson.py b/tests/field/codegen/Poisson.py index df3e9589e..6edec0315 100644 --- a/tests/field/codegen/Poisson.py +++ b/tests/field/codegen/Poisson.py @@ -11,8 +11,8 @@ with CodeGeneration() as ctx: @ps.kernel def kernel_func(): - dst[0, 0] @= ((dy**2 * (src[1, 0] + src[-1, 0])) + + src[0, 0] @= ((dy**2 * (src[1, 0] + src[-1, 0])) + (dx**2 * (src[0, 1] + src[0, -1])) - (rhs[0, 0] * dx**2 * dy**2)) / (2 * (dx**2 + dy**2)) - generate_sweep(ctx, 'Poisson', kernel_func, field_swaps=[(src, dst)]) + generate_sweep(ctx, 'Poisson', kernel_func) -- GitLab