Skip to content
Snippets Groups Projects
Commit 00f652b1 authored by Frederik Hennig's avatar Frederik Hennig
Browse files

no-slip/free-slip combined scenario, not working yet

parent cd65d46d
No related merge requests found
...@@ -7,6 +7,10 @@ ...@@ -7,6 +7,10 @@
#include "field/all.h" #include "field/all.h"
#include "field/communication/StencilRestrictedPackInfo.h" #include "field/communication/StencilRestrictedPackInfo.h"
#include "walberla/experimental/Sweep.hpp"
#include "stencil/Directions.h"
#include <memory> #include <memory>
#include "gen/LbmAlgorithms.hpp" #include "gen/LbmAlgorithms.hpp"
...@@ -26,6 +30,7 @@ namespace BasicLbmScenarios ...@@ -26,6 +30,7 @@ namespace BasicLbmScenarios
{ {
using namespace walberla; using namespace walberla;
using namespace walberla::experimental;
using PdfField_T = field::GhostLayerField< real_t, gen::LbStencil::Q >; using PdfField_T = field::GhostLayerField< real_t, gen::LbStencil::Q >;
using ScalarField_T = field::GhostLayerField< real_t, 1 >; using ScalarField_T = field::GhostLayerField< real_t, 1 >;
...@@ -96,6 +101,16 @@ struct SimDomain ...@@ -96,6 +101,16 @@ struct SimDomain
return { gpuFields.pdfsId, gpuFields.rhoId, gpuFields.uId, force, omega }; return { gpuFields.pdfsId, gpuFields.rhoId, gpuFields.uId, force, omega };
} }
auto
freeSlipBottom() {
return sweep::BorderSweep< stencil::Direction::B, gen::bc_grid_aligned::FreeSlipBottom > { blocks, gen::bc_grid_aligned::FreeSlipBottom { gpuFields.pdfsId }, 0 };
}
auto
noSlipTop() {
return sweep::BorderSweep< stencil::Direction::T, gen::bc_grid_aligned::NoSlipTop > { blocks, gen::bc_grid_aligned::NoSlipTop { gpuFields.pdfsId }, -1 };
}
void wait() { WALBERLA_GPU_CHECK(gpuDeviceSynchronize()); } void wait() { WALBERLA_GPU_CHECK(gpuDeviceSynchronize()); }
void syncGhostLayers() void syncGhostLayers()
......
...@@ -59,14 +59,17 @@ void fullyPeriodic(Environment& env) ...@@ -59,14 +59,17 @@ void fullyPeriodic(Environment& env)
void mirroredHalfChannel(Environment& env) void mirroredHalfChannel(Environment& env)
{ {
size_t zCells { 64 }; size_t zCells { 64 };
/**
* Need one more cell in z-direction for the free-slip boundary to be on the inner layer
*/
SimDomain dom{ SimDomainBuilder{ SimDomain dom{ SimDomainBuilder{
.blocks = { 1, 1, 1 }, .cellsPerBlock = { 4, 4, zCells }, .periodic = { true, true, false } } .blocks = { 1, 1, 1 }, .cellsPerBlock = { 4, 4, zCells + 1 }, .periodic = { true, true, false } }
.build() }; .build() };
/* Hagen-Poiseuille-law in lattice units */ /* Hagen-Poiseuille-law in lattice units */
const real_t u_max{ 0.025 }; const real_t u_max{ 0.025 };
const real_t reynolds{ 10.0 }; const real_t reynolds{ 10.0 };
const real_t L_z{ 2 * zCells }; const real_t L_z{ real_c( 2 * zCells ) };
const real_t radius { L_z / 2.0 }; const real_t radius { L_z / 2.0 };
const real_t r_squared { radius * radius }; const real_t r_squared { radius * radius };
const real_t lattice_viscosity{ L_z * u_max / reynolds }; const real_t lattice_viscosity{ L_z * u_max / reynolds };
...@@ -99,9 +102,36 @@ void mirroredHalfChannel(Environment& env) ...@@ -99,9 +102,36 @@ void mirroredHalfChannel(Environment& env)
dom.fields2device(); dom.fields2device();
dom.initFromFields(force); dom.initFromFields(force);
// TODO: Get collision and boundary sweeps auto streamCollide = dom.streamCollideSweep(omega, force);
// Set up boundary sweeps on the lower and upper ghost layers auto noSlipTop = dom.noSlipTop();
// Run 10 time steps and make sure the flow stays in steady-state auto freeSlipBottom = dom.freeSlipBottom();
for (uint_t t = 0; t < 10; ++t)
{
dom.forAllBlocks([&](IBlock& b) { streamCollide(&b); });
dom.syncGhostLayers();
dom.fields2host();
dom.forAllBlocks([&](auto& block) {
const VectorField_T& velField = *block.template getData< VectorField_T >(dom.cpuFields.uId);
dom.forAllCells([&](Cell c) {
Cell globalCell{ c };
dom.blocks->transformBlockLocalToGlobalCell(globalCell, block);
Vector3< real_t > cellCenter{ dom.blocks->getCellCenter(globalCell) };
real_t expected{ velocityProfile(cellCenter[2]) };
real_t actual{ velField.get(c, 0) };
WALBERLA_CHECK_FLOAT_EQUAL(expected, actual);
});
});
dom.forAllBlocks([&](IBlock& b) {
noSlipTop(&b);
freeSlipBottom(&b);
});
}
} }
/** /**
...@@ -217,6 +247,7 @@ int main(int argc, char** argv) ...@@ -217,6 +247,7 @@ int main(int argc, char** argv)
{ {
walberla::Environment env{ argc, argv }; walberla::Environment env{ argc, argv };
BasicLbmScenarios::fullyPeriodic(env); BasicLbmScenarios::fullyPeriodic(env);
BasicLbmScenarios::mirroredHalfChannel(env);
#if !defined(LBM_SCENARIOS_GPU_BUILD) #if !defined(LBM_SCENARIOS_GPU_BUILD)
BasicLbmScenarios::freeSlipPipe(env); BasicLbmScenarios::freeSlipPipe(env);
#endif #endif
......
...@@ -6,6 +6,9 @@ set(WALBERLA_BUILD_BENCHMARKS OFF CACHE BOOL "") ...@@ -6,6 +6,9 @@ set(WALBERLA_BUILD_BENCHMARKS OFF CACHE BOOL "")
set(WALBERLA_BUILD_SHOWCASES OFF CACHE BOOL "") set(WALBERLA_BUILD_SHOWCASES OFF CACHE BOOL "")
set(WALBERLA_BUILD_TUTORIALS OFF CACHE BOOL "") set(WALBERLA_BUILD_TUTORIALS OFF CACHE BOOL "")
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED)
include(FetchContent) include(FetchContent)
FetchContent_Declare( FetchContent_Declare(
......
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