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
Branches
Tags
No related merge requests found
......@@ -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);
}
......
......@@ -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')
......@@ -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);
}
......
......@@ -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)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment