Skip to content
Snippets Groups Projects
Commit 48787179 authored by Jonas Plewinski's avatar Jonas Plewinski
Browse files

Add force driven Poiseuille channel flow, with generated lattice model !560

parent 0696bfb0
No related merge requests found
...@@ -2,25 +2,41 @@ ...@@ -2,25 +2,41 @@
waLBerla_link_files_to_builddir( "*.dat" ) waLBerla_link_files_to_builddir( "*.dat" )
waLBerla_link_files_to_builddir( "*.prm" ) waLBerla_link_files_to_builddir( "*.prm" )
waLBerla_add_executable( NAME PoiseuilleChannel
FILES PoiseuilleChannel.cpp
DEPENDS blockforest boundary core field lbm postprocessing stencil timeloop vtk sqlite )
waLBerla_add_executable( NAME PoiseuilleChannelForceTesting if( WALBERLA_BUILD_WITH_CODEGEN )
FILES PoiseuilleChannelForceTesting.cpp
DEPENDS blockforest core field lbm geometry timeloop )
############## waLBerla_generate_target_from_python(NAME PoiseuilleChannelForceGeneratedLBM FILE GeneratedLBM.py
# Some tests # OUT_FILES GeneratedLBM.cpp GeneratedLBM.h )
##############
waLBerla_add_executable( NAME PoiseuilleChannelForceTesting
FILES PoiseuilleChannelForceTesting.cpp
DEPENDS blockforest core field lbm geometry timeloop PoiseuilleChannelForceGeneratedLBM )
else()
waLBerla_add_executable( NAME PoiseuilleChannel
FILES PoiseuilleChannel.cpp
DEPENDS blockforest boundary core field lbm postprocessing stencil timeloop vtk sqlite )
waLBerla_add_executable( NAME PoiseuilleChannelForceTesting
FILES PoiseuilleChannelForceTesting.cpp
DEPENDS blockforest core field lbm geometry timeloop )
##############
# Some tests #
##############
waLBerla_execute_test( NO_MODULE_LABEL NAME PoiseuilleChannelTestParallelPlatesNoCheckRelease COMMAND $<TARGET_FILE:PoiseuilleChannel> ${CMAKE_CURRENT_SOURCE_DIR}/TestParallelPlatesNoCheck.dat --trt --linear-exp PROCESSES 4 CONFIGURATIONS Release RelWithDbgInfo DEPENDS_ON_TARGETS PoiseuilleChannel )
waLBerla_execute_test( NO_MODULE_LABEL NAME PoiseuilleChannelTestPipeNoCheckRelease COMMAND $<TARGET_FILE:PoiseuilleChannel> ${CMAKE_CURRENT_SOURCE_DIR}/TestPipeNoCheck.dat --trt --linear-exp PROCESSES 4 CONFIGURATIONS Release RelWithDbgInfo DEPENDS_ON_TARGETS PoiseuilleChannel )
waLBerla_execute_test( NO_MODULE_LABEL NAME PoiseuilleChannelTestParallelPlatesNoCheckDebug COMMAND $<TARGET_FILE:PoiseuilleChannel> ${CMAKE_CURRENT_SOURCE_DIR}/TestParallelPlatesNoCheck.dat --trt --linear-exp PROCESSES 4 LABELS longrun CONFIGURATIONS Debug DebugOptimized DEPENDS_ON_TARGETS PoiseuilleChannel )
waLBerla_execute_test( NO_MODULE_LABEL NAME PoiseuilleChannelTestPipeNoCheckDebug COMMAND $<TARGET_FILE:PoiseuilleChannel> ${CMAKE_CURRENT_SOURCE_DIR}/TestPipeNoCheck.dat --trt --linear-exp PROCESSES 4 LABELS longrun CONFIGURATIONS Debug DebugOptimized DEPENDS_ON_TARGETS PoiseuilleChannel )
waLBerla_execute_test( NO_MODULE_LABEL NAME PoiseuilleChannelTestParallelPlates0 COMMAND $<TARGET_FILE:PoiseuilleChannel> ${CMAKE_CURRENT_SOURCE_DIR}/TestParallelPlates0.dat --trt --linear-exp LABELS longrun CONFIGURATIONS Release RelWithDbgInfo DEPENDS_ON_TARGETS PoiseuilleChannel )
waLBerla_execute_test( NO_MODULE_LABEL NAME PoiseuilleChannelTestParallelPlates2 COMMAND $<TARGET_FILE:PoiseuilleChannel> ${CMAKE_CURRENT_SOURCE_DIR}/TestParallelPlates2.dat --trt --linear-exp LABELS longrun verylongrun PROCESSES 4 CONFIGURATIONS Release RelWithDbgInfo DEPENDS_ON_TARGETS PoiseuilleChannel )
waLBerla_execute_test( NO_MODULE_LABEL NAME PoiseuilleChannelTestPipe0 COMMAND $<TARGET_FILE:PoiseuilleChannel> ${CMAKE_CURRENT_SOURCE_DIR}/TestPipe0.dat --trt --linear-exp LABELS longrun CONFIGURATIONS Release RelWithDbgInfo DEPENDS_ON_TARGETS PoiseuilleChannel )
waLBerla_execute_test( NO_MODULE_LABEL NAME PoiseuilleChannelTestPipe2 COMMAND $<TARGET_FILE:PoiseuilleChannel> ${CMAKE_CURRENT_SOURCE_DIR}/TestPipe2.dat --trt --linear-exp LABELS longrun verylongrun PROCESSES 4 CONFIGURATIONS Release RelWithDbgInfo DEPENDS_ON_TARGETS PoiseuilleChannel )
endif()
waLBerla_execute_test( NO_MODULE_LABEL NAME PoiseuilleChannelTestParallelPlatesNoCheckRelease COMMAND $<TARGET_FILE:PoiseuilleChannel> ${CMAKE_CURRENT_SOURCE_DIR}/TestParallelPlatesNoCheck.dat --trt --linear-exp PROCESSES 4 CONFIGURATIONS Release RelWithDbgInfo DEPENDS_ON_TARGETS PoiseuilleChannel )
waLBerla_execute_test( NO_MODULE_LABEL NAME PoiseuilleChannelTestPipeNoCheckRelease COMMAND $<TARGET_FILE:PoiseuilleChannel> ${CMAKE_CURRENT_SOURCE_DIR}/TestPipeNoCheck.dat --trt --linear-exp PROCESSES 4 CONFIGURATIONS Release RelWithDbgInfo DEPENDS_ON_TARGETS PoiseuilleChannel )
waLBerla_execute_test( NO_MODULE_LABEL NAME PoiseuilleChannelTestParallelPlatesNoCheckDebug COMMAND $<TARGET_FILE:PoiseuilleChannel> ${CMAKE_CURRENT_SOURCE_DIR}/TestParallelPlatesNoCheck.dat --trt --linear-exp PROCESSES 4 LABELS longrun CONFIGURATIONS Debug DebugOptimized DEPENDS_ON_TARGETS PoiseuilleChannel )
waLBerla_execute_test( NO_MODULE_LABEL NAME PoiseuilleChannelTestPipeNoCheckDebug COMMAND $<TARGET_FILE:PoiseuilleChannel> ${CMAKE_CURRENT_SOURCE_DIR}/TestPipeNoCheck.dat --trt --linear-exp PROCESSES 4 LABELS longrun CONFIGURATIONS Debug DebugOptimized DEPENDS_ON_TARGETS PoiseuilleChannel )
waLBerla_execute_test( NO_MODULE_LABEL NAME PoiseuilleChannelTestParallelPlates0 COMMAND $<TARGET_FILE:PoiseuilleChannel> ${CMAKE_CURRENT_SOURCE_DIR}/TestParallelPlates0.dat --trt --linear-exp LABELS longrun CONFIGURATIONS Release RelWithDbgInfo DEPENDS_ON_TARGETS PoiseuilleChannel )
waLBerla_execute_test( NO_MODULE_LABEL NAME PoiseuilleChannelTestParallelPlates2 COMMAND $<TARGET_FILE:PoiseuilleChannel> ${CMAKE_CURRENT_SOURCE_DIR}/TestParallelPlates2.dat --trt --linear-exp LABELS longrun verylongrun PROCESSES 4 CONFIGURATIONS Release RelWithDbgInfo DEPENDS_ON_TARGETS PoiseuilleChannel )
waLBerla_execute_test( NO_MODULE_LABEL NAME PoiseuilleChannelTestPipe0 COMMAND $<TARGET_FILE:PoiseuilleChannel> ${CMAKE_CURRENT_SOURCE_DIR}/TestPipe0.dat --trt --linear-exp LABELS longrun CONFIGURATIONS Release RelWithDbgInfo DEPENDS_ON_TARGETS PoiseuilleChannel )
waLBerla_execute_test( NO_MODULE_LABEL NAME PoiseuilleChannelTestPipe2 COMMAND $<TARGET_FILE:PoiseuilleChannel> ${CMAKE_CURRENT_SOURCE_DIR}/TestPipe2.dat --trt --linear-exp LABELS longrun verylongrun PROCESSES 4 CONFIGURATIONS Release RelWithDbgInfo DEPENDS_ON_TARGETS PoiseuilleChannel )
import sympy as sp
from lbmpy.creationfunctions import LBMConfig, LBMOptimisation, create_lb_collision_rule
from lbmpy.enums import ForceModel, Method, Stencil
from lbmpy.stencils import LBStencil
from pystencils_walberla import CodeGeneration
from lbmpy_walberla import generate_lattice_model
generatedMethod = 'TRT'
# general parameters
stencil = LBStencil(Stencil.D2Q9)
force = sp.symbols('force_:2')
layout = 'fzyx' #'zyxf'
if generatedMethod == 'SRT':
omega = sp.Symbol('omega')
# method definition
lbm_config = LBMConfig(stencil=stencil,
method=Method.SRT,
relaxation_rate=omega,
compressible=True,
force=force,
force_model=ForceModel.GUO,
zero_centered=False,
streaming_pattern='pull') # free surface implementation only works with pull pattern
elif generatedMethod == 'TRT':
omega_e = sp.Symbol('omega_e')
omega_o = sp.Symbol('omega_o')
# method definition
lbm_config = LBMConfig(stencil=stencil,
method=Method.TRT,
relaxation_rates=[omega_e, omega_o],
compressible=True,
force=force,
force_model=ForceModel.GUO,
zero_centered=False,
streaming_pattern='pull') # free surface implementation only works with pull pattern
# optimizations to be used by the code generator
lbm_opt = LBMOptimisation(cse_global=True,
field_layout=layout)
collision_rule = create_lb_collision_rule(lbm_config=lbm_config,
lbm_optimisation=lbm_opt)
with CodeGeneration() as ctx:
generate_lattice_model(ctx, "GeneratedLBM", collision_rule, field_layout=layout)
...@@ -29,11 +29,15 @@ ...@@ -29,11 +29,15 @@
#include "lbm/all.h" #include "lbm/all.h"
#include "timeloop/all.h" #include "timeloop/all.h"
#ifdef WALBERLA_BUILD_WITH_CODEGEN
#include "GeneratedLBM.h"
#endif
namespace walberla { namespace walberla {
//const uint_t FieldGhostLayers( 1 ); //const uint_t FieldGhostLayers( 1 );
#define CODEGEN
//#define USE_SRT //#define USE_SRT
#define USE_TRT #define USE_TRT
...@@ -42,19 +46,25 @@ namespace walberla { ...@@ -42,19 +46,25 @@ namespace walberla {
//#define USE_SimpleConstant //#define USE_SimpleConstant
//#define USE_GuoField //#define USE_GuoField
#if defined(USE_GuoConstant) #ifdef CODEGEN
using ForceModel_T = lbm::force_model::GuoConstant; #else
#elif defined(USE_SimpleConstant) #if defined(USE_GuoConstant)
using ForceModel_T = lbm::force_model::SimpleConstant; using ForceModel_T = lbm::force_model::GuoConstant;
#elif defined(USE_SimpleConstant)
using ForceModel_T = lbm::force_model::SimpleConstant;
#endif
#endif #endif
//using Vec3Field_T = field::GhostLayerField<Vector3<real_t>, 1>; //using Vec3Field_T = field::GhostLayerField<Vector3<real_t>, 1>;
//using ForceModel_T = lbm::force_model::GuoField<Vec3Field_T>; //using ForceModel_T = lbm::force_model::GuoField<Vec3Field_T>;
#if defined(USE_SRT) #ifdef CODEGEN
using CollisionModel_T = lbm::collision_model::SRT; using LatticeModel_T = lbm::GeneratedLBM;
using LatticeModel_T = lbm::D2Q9<CollisionModel_T , true, ForceModel_T>; #else
#elif defined(USE_TRT) #ifdef USE_SRT
using CollisionModel_T = lbm::collision_model::TRT; using CollisionModel_T = lbm::collision_model::SRT;
#elif defined(USE_TRT)
using CollisionModel_T = lbm::collision_model::TRT;
#endif
using LatticeModel_T = lbm::D2Q9<CollisionModel_T , true, ForceModel_T>; using LatticeModel_T = lbm::D2Q9<CollisionModel_T , true, ForceModel_T>;
#endif #endif
...@@ -67,7 +77,6 @@ using flag_t = walberla::uint8_t; ...@@ -67,7 +77,6 @@ using flag_t = walberla::uint8_t;
using FlagField_T = FlagField<flag_t>; using FlagField_T = FlagField<flag_t>;
int main( int argc, char ** argv ) int main( int argc, char ** argv )
{ {
walberla::Environment walberlaEnv( argc, argv ); walberla::Environment walberlaEnv( argc, argv );
...@@ -82,27 +91,38 @@ int main( int argc, char ** argv ) ...@@ -82,27 +91,38 @@ int main( int argc, char ** argv )
const uint_t timesteps = parameters.getParameter< uint_t > ( "timesteps", uint_c( 10 ) ); const uint_t timesteps = parameters.getParameter< uint_t > ( "timesteps", uint_c( 10 ) );
const double remainingTimeLoggerFrequency = parameters.getParameter< double >( "remainingTimeLoggerFrequency", 3.0 ); // in seconds const double remainingTimeLoggerFrequency = parameters.getParameter< double >( "remainingTimeLoggerFrequency", 3.0 ); // in seconds
const Vector3<real_t> bodyForce(real_t(1e-6), real_t(0), real_t(0)); const Vector3<real_t> bodyForce(real_t(1e-5), real_t(0), real_t(0));
// create fields // create fields
//> BlockDataID forceFieldID = field::addToStorage< Vec3Field_T >( blocks, "force field", Vector3<real_t>(real_t(0)), field::zyxf, FieldGhostLayers ); //> BlockDataID forceFieldID = field::addToStorage< Vec3Field_T >( blocks, "force field", Vector3<real_t>(real_t(0)), field::zyxf, FieldGhostLayers );
#ifdef CODEGEN
#if defined(USE_SRT) #ifdef USE_SRT
LatticeModel_T latticeModel = LatticeModel_T(CollisionModel_T(omega),ForceModel_T(bodyForce)); LatticeModel_T latticeModel = LatticeModel_T (bodyForce[0], bodyForce[1], omega);
#elif defined(USE_TRT) #elif defined(USE_TRT)
real_t lambda_e = lbm::collision_model::TRT::lambda_e( omega ); real_t lambda_e = lbm::collision_model::TRT::lambda_e( omega );
real_t lambda_d = lbm::collision_model::TRT::lambda_d( omega, lbm::collision_model::TRT::threeSixteenth ); real_t lambda_d = lbm::collision_model::TRT::lambda_d( omega, lbm::collision_model::TRT::threeSixteenth );
std::cout << " lambda_e = " << lambda_e << " | lambda_d = " << lambda_d << std::endl; std::cout << " lambda_e = " << lambda_e << " | lambda_d = " << lambda_d << std::endl;
LatticeModel_T latticeModel = LatticeModel_T latticeModel = LatticeModel_T (bodyForce[0], bodyForce[1], lambda_e, lambda_d);
LatticeModel_T(CollisionModel_T(lambda_e, lambda_d), ForceModel_T(bodyForce)); #endif
auto viscosity = lbm::collision_model::viscosityFromOmega(omega); #else
std::cout << " omega = " << omega << " | viscosity = " << viscosity << std::endl; #if defined(USE_SRT)
#elif defined(USE_MRT) LatticeModel_T latticeModel = LatticeModel_T(CollisionModel_T(omega),ForceModel_T(bodyForce));
LatticeModel_T latticeModel = LatticeModel_T(CollisionModel_T(omega, omega, omega, omega, omega, omega), #elif defined(USE_TRT)
ForceModel_T(bodyForce)); real_t lambda_e = lbm::collision_model::TRT::lambda_e( omega );
real_t lambda_d = lbm::collision_model::TRT::lambda_d( omega, lbm::collision_model::TRT::threeSixteenth );
std::cout << " lambda_e = " << lambda_e << " | lambda_d = " << lambda_d << std::endl;
LatticeModel_T latticeModel =
LatticeModel_T(CollisionModel_T(lambda_e, lambda_d), ForceModel_T(bodyForce));
auto viscosity = lbm::collision_model::viscosityFromOmega(omega);
std::cout << " omega = " << omega << " | viscosity = " << viscosity << std::endl;
#elif defined(USE_MRT)
LatticeModel_T latticeModel = LatticeModel_T(CollisionModel_T(omega, omega, omega, omega, omega, omega),
ForceModel_T(bodyForce));
#endif
#endif #endif
//> LatticeModel_T latticeModel = LatticeModel_T( lbm::collision_model::SRT( omega ), ForceModel_T( forceFieldID )); //> LatticeModel_T latticeModel = LatticeModel_T( lbm::collision_model::SRT( omega ), ForceModel_T( forceFieldID ));
BlockDataID pdfFieldId = lbm::addPdfFieldToStorage( blocks, "pdf field", latticeModel, initialVelocity, real_t(1) ); BlockDataID pdfFieldId = lbm::addPdfFieldToStorage( blocks, "pdf field", latticeModel, initialVelocity, real_t(1), field::fzyx );
//> BlockDataID pdfFieldId = lbm::addPdfFieldToStorage( blocks, "pdf field (zyxf)", latticeModel, initialVelocity, real_t(1), FieldGhostLayers, field::zyxf ); //> BlockDataID pdfFieldId = lbm::addPdfFieldToStorage( blocks, "pdf field (zyxf)", latticeModel, initialVelocity, real_t(1), FieldGhostLayers, field::zyxf );
BlockDataID flagFieldId = field::addFlagFieldToStorage< FlagField_T >( blocks, "flag field" ); BlockDataID flagFieldId = field::addFlagFieldToStorage< FlagField_T >( blocks, "flag field" );
...@@ -132,7 +152,13 @@ int main( int argc, char ** argv ) ...@@ -132,7 +152,13 @@ int main( int argc, char ** argv )
// add LBM sweep and communication to time loop // add LBM sweep and communication to time loop
timeloop.add() << BeforeFunction( communication, "communication" ) timeloop.add() << BeforeFunction( communication, "communication" )
<< Sweep( BHFactory::BoundaryHandling::getBlockSweep( boundaryHandlingId ), "boundary handling" ); << Sweep( BHFactory::BoundaryHandling::getBlockSweep( boundaryHandlingId ), "boundary handling" );
timeloop.add() << Sweep( makeSharedSweep( lbm::makeCellwiseSweep< LatticeModel_T, FlagField_T >( pdfFieldId, flagFieldId, fluidFlagUID ) ), "LB stream & collide" ); #ifdef CODEGEN
auto lbmSweep = LatticeModel_T::Sweep(pdfFieldId);
timeloop.add() << Sweep( lbmSweep, "LB Sweep" );
#else
auto lbmSweep = lbm::makeCellwiseSweep< LatticeModel_T, FlagField_T >( pdfFieldId, flagFieldId, fluidFlagUID );
timeloop.add() << Sweep( makeSharedSweep( lbmSweep ), "LB stream & collide" );
#endif
// LBM stability check // LBM stability check
timeloop.addFuncAfterTimeStep( makeSharedFunctor( field::makeStabilityChecker< PdfField_T, FlagField_T >( walberlaEnv.config(), blocks, pdfFieldId, timeloop.addFuncAfterTimeStep( makeSharedFunctor( field::makeStabilityChecker< PdfField_T, FlagField_T >( walberlaEnv.config(), blocks, pdfFieldId,
......
...@@ -3,8 +3,8 @@ Parameters ...@@ -3,8 +3,8 @@ Parameters
{ {
omega 1.8; omega 1.8;
initialVelocity < 0.0, 0, 0 >; initialVelocity < 0.0, 0, 0 >;
//timesteps 10000; timesteps 10000;
timesteps 1; //timesteps 1;
remainingTimeLoggerFrequency 3; // in seconds remainingTimeLoggerFrequency 3; // in seconds
} }
...@@ -12,10 +12,10 @@ Parameters ...@@ -12,10 +12,10 @@ Parameters
DomainSetup DomainSetup
{ {
blocks < 1, 1, 1 >; blocks < 1, 1, 1 >;
//cellsPerBlock < 300, 80, 1 >; cellsPerBlock < 300, 80, 1 >;
//periodic < 1, 0, 1 >; periodic < 1, 0, 1 >;
cellsPerBlock < 2, 2, 1 >; //cellsPerBlock < 2, 2, 1 >;
periodic < 1, 1, 1 >; //periodic < 1, 1, 1 >;
} }
StabilityChecker StabilityChecker
...@@ -27,7 +27,7 @@ StabilityChecker ...@@ -27,7 +27,7 @@ StabilityChecker
Boundaries Boundaries
{ {
// Border { direction S,N; walldistance -1; NoSlip {} } Border { direction S,N; walldistance -1; NoSlip {} }
} }
......
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