Skip to content
Snippets Groups Projects
Commit 05702a6a authored by Markus Holzer's avatar Markus Holzer
Browse files

added comparison between solution and approximation

parent 84cb3ddc
No related merge requests found
...@@ -84,8 +84,7 @@ void initF( const shared_ptr< StructuredBlockStorage > & blocks, const BlockData ...@@ -84,8 +84,7 @@ void initF( const shared_ptr< StructuredBlockStorage > & blocks, const BlockData
CellInterval xyz = f->xyzSize(); CellInterval xyz = f->xyzSize();
for( auto cell = xyz.begin(); cell != xyz.end(); ++cell ) for( auto cell = xyz.begin(); cell != xyz.end(); ++cell )
{ {
const Vector3< real_t > p = blocks->getBlockLocalCellCenter( *block, *cell ); f->get( *cell ) = 0.0;
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] );
} }
} }
} }
...@@ -137,6 +136,10 @@ void testPoisson() ...@@ -137,6 +136,10 @@ void testPoisson()
cuda::fieldCpy<GPUField, ScalarField_T>( blocks, gpufId, cpufId ); cuda::fieldCpy<GPUField, ScalarField_T>( blocks, gpufId, cpufId );
timeloop.run(); timeloop.run();
cuda::fieldCpy<ScalarField_T, GPUField>( blocks, cpuFieldID, gpuField ); 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);
} }
......
...@@ -12,8 +12,8 @@ with CodeGeneration() as ctx: ...@@ -12,8 +12,8 @@ with CodeGeneration() as ctx:
@ps.kernel @ps.kernel
def kernel_func(): def kernel_func():
dst[0, 0] @= ((dx**2 * (src[1, 0] + src[-1, 0])) + src[0, 0] @= ((dy**2 * (src[1, 0] + src[-1, 0])) +
(dy**2 * (src[0, 1] + src[0, -1])) - (dx**2 * (src[0, 1] + src[0, -1])) -
(rhs[0, 0] * dx**2 * dy**2)) / (2 * (dx**2 + dy**2)) (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')
...@@ -70,8 +70,7 @@ void initF( const shared_ptr< StructuredBlockStorage > & blocks, const BlockData ...@@ -70,8 +70,7 @@ void initF( const shared_ptr< StructuredBlockStorage > & blocks, const BlockData
CellInterval xyz = f->xyzSize(); CellInterval xyz = f->xyzSize();
for( auto cell = xyz.begin(); cell != xyz.end(); ++cell ) for( auto cell = xyz.begin(); cell != xyz.end(); ++cell )
{ {
const Vector3< real_t > p = blocks->getBlockLocalCellCenter( *block, *cell ); f->get( *cell ) = 0.0;
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] );
} }
} }
} }
...@@ -79,9 +78,9 @@ void initF( const shared_ptr< StructuredBlockStorage > & blocks, const BlockData ...@@ -79,9 +78,9 @@ void initF( const shared_ptr< StructuredBlockStorage > & blocks, const BlockData
void testPoisson() void testPoisson()
{ {
const uint_t xCells = uint_t(200); const uint_t xCells = uint_t(100);
const uint_t yCells = 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 ySize = real_t(1);
const real_t dx = xSize / real_c( xCells + uint_t(1) ); const real_t dx = xSize / real_c( xCells + uint_t(1) );
const real_t dy = ySize / real_c( yCells + uint_t(1) ); const real_t dy = ySize / real_c( yCells + uint_t(1) );
...@@ -116,6 +115,10 @@ void testPoisson() ...@@ -116,6 +115,10 @@ void testPoisson()
<< Sweep( pystencils::Poisson(fId, fieldID, dx, dy), "Poisson Kernel" ); << Sweep( pystencils::Poisson(fId, fieldID, dx, dy), "Poisson Kernel" );
timeloop.run(); 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);
} }
......
...@@ -11,8 +11,8 @@ with CodeGeneration() as ctx: ...@@ -11,8 +11,8 @@ with CodeGeneration() as ctx:
@ps.kernel @ps.kernel
def kernel_func(): 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])) - (dx**2 * (src[0, 1] + src[0, -1])) -
(rhs[0, 0] * dx**2 * dy**2)) / (2 * (dx**2 + dy**2)) (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)
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