diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 3927d881288d90034c0fd9fc0d548cf677d6f260..4a44474058c2ce51ba80bdd8651fc7d3ba8624a5 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -28,7 +28,7 @@ stages: - mkdir $CI_PROJECT_DIR/build - cd $CI_PROJECT_DIR/build - if dpkg --compare-versions `ompi_info | head -2 | tail -1 | sed 's/[^0-9.]*\([0-9.]*\).*/\1/'` ge 1.10; then export MPIEXEC_PREFLAGS="--allow-run-as-root" ; fi - - cmake .. -DWALBERLA_BUFFER_DEBUG=$WALBERLA_BUFFER_DEBUG -DWALBERLA_BUILD_TESTS=ON -DWALBERLA_BUILD_BENCHMARKS=ON -DWALBERLA_BUILD_TUTORIALS=ON -DWALBERLA_BUILD_TOOLS=ON -DWALBERLA_BUILD_WITH_MPI=$WALBERLA_BUILD_WITH_MPI -DWALBERLA_BUILD_WITH_CUDA=$WALBERLA_BUILD_WITH_CUDA -DWALBERLA_BUILD_WITH_PYTHON=$WALBERLA_BUILD_WITH_PYTHON -DWALBERLA_BUILD_WITH_OPENMP=$WALBERLA_BUILD_WITH_OPENMP -DCMAKE_BUILD_TYPE=$CMAKE_BUILD_TYPE -DMPIEXEC_PREFLAGS=$MPIEXEC_PREFLAGS -DWALBERLA_DOUBLE_ACCURACY=$WALBERLA_DOUBLE_ACCURACY -DWARNING_ERROR=ON + - cmake .. -DWALBERLA_BUFFER_DEBUG=$WALBERLA_BUFFER_DEBUG -DWALBERLA_BUILD_TESTS=ON -DWALBERLA_BUILD_BENCHMARKS=ON -DWALBERLA_BUILD_TUTORIALS=ON -DWALBERLA_BUILD_TOOLS=ON -DWALBERLA_BUILD_WITH_MPI=$WALBERLA_BUILD_WITH_MPI -DWALBERLA_BUILD_WITH_CUDA=$WALBERLA_BUILD_WITH_CUDA -DWALBERLA_BUILD_WITH_PYTHON=$WALBERLA_BUILD_WITH_PYTHON -DWALBERLA_BUILD_WITH_OPENMP=$WALBERLA_BUILD_WITH_OPENMP -DCMAKE_BUILD_TYPE=$CMAKE_BUILD_TYPE -DMPIEXEC_PREFLAGS=$MPIEXEC_PREFLAGS -DWALBERLA_DOUBLE_ACCURACY=$WALBERLA_DOUBLE_ACCURACY -DWARNING_ERROR=ON -DWALBERLA_BUILD_WITH_METIS=$WALBERLA_BUILD_WITH_METIS -DWALBERLA_BUILD_WITH_PARMETIS=$WALBERLA_BUILD_WITH_PARMETIS - cmake . -LAH - make -j $NUM_BUILD_CORES -l $NUM_CORES - ctest -LE $CTEST_EXCLUDE_LABELS -C $CMAKE_BUILD_TYPE --output-on-failure -j $NUM_CORES @@ -45,17 +45,21 @@ stages: CMAKE_BUILD_TYPE: "Release" WALBERLA_BUFFER_DEBUG: "OFF" WALBERLA_DOUBLE_ACCURACY: "ON" + WALBERLA_BUILD_WITH_METIS: "OFF" + WALBERLA_BUILD_WITH_PARMETIS: "OFF" .build_mpionly_template: &build_mpionly_definition <<: *build_definition variables: - CTEST_EXCLUDE_LABELS: "longrun" - WALBERLA_BUILD_WITH_MPI: "ON" - WALBERLA_BUILD_WITH_OPENMP: "OFF" - CMAKE_BUILD_TYPE: "Release" - WALBERLA_BUFFER_DEBUG: "OFF" - WALBERLA_DOUBLE_ACCURACY: "ON" + CTEST_EXCLUDE_LABELS: "longrun" + WALBERLA_BUILD_WITH_MPI: "ON" + WALBERLA_BUILD_WITH_OPENMP: "OFF" + CMAKE_BUILD_TYPE: "Release" + WALBERLA_BUFFER_DEBUG: "OFF" + WALBERLA_DOUBLE_ACCURACY: "ON" + WALBERLA_BUILD_WITH_METIS: "OFF" + WALBERLA_BUILD_WITH_PARMETIS: "OFF" .build_hybrid_template: &build_hybrid_definition @@ -69,6 +73,8 @@ stages: CMAKE_BUILD_TYPE: "Release" WALBERLA_BUFFER_DEBUG: "OFF" WALBERLA_DOUBLE_ACCURACY: "ON" + WALBERLA_BUILD_WITH_METIS: "ON" + WALBERLA_BUILD_WITH_PARMETIS: "ON" .build_serial_dbg_template: &build_serial_dbg_definition <<: *build_definition @@ -79,17 +85,21 @@ stages: CMAKE_BUILD_TYPE: "DebugOptimized" WALBERLA_BUFFER_DEBUG: "OFF" WALBERLA_DOUBLE_ACCURACY: "ON" + WALBERLA_BUILD_WITH_METIS: "OFF" + WALBERLA_BUILD_WITH_PARMETIS: "OFF" .build_mpionly_dbg_template: &build_mpionly_dbg_definition <<: *build_definition variables: - CTEST_EXCLUDE_LABELS: "longrun" - WALBERLA_BUILD_WITH_MPI: "ON" - WALBERLA_BUILD_WITH_OPENMP: "OFF" - CMAKE_BUILD_TYPE: "DebugOptimized" - WALBERLA_BUFFER_DEBUG: "OFF" - WALBERLA_DOUBLE_ACCURACY: "ON" + CTEST_EXCLUDE_LABELS: "longrun" + WALBERLA_BUILD_WITH_MPI: "ON" + WALBERLA_BUILD_WITH_OPENMP: "OFF" + CMAKE_BUILD_TYPE: "DebugOptimized" + WALBERLA_BUFFER_DEBUG: "OFF" + WALBERLA_DOUBLE_ACCURACY: "ON" + WALBERLA_BUILD_WITH_METIS: "OFF" + WALBERLA_BUILD_WITH_PARMETIS: "OFF" .build_hybrid_dbg_template: &build_hybrid_dbg_definition @@ -103,6 +113,8 @@ stages: CMAKE_BUILD_TYPE: "DebugOptimized" WALBERLA_BUFFER_DEBUG: "OFF" WALBERLA_DOUBLE_ACCURACY: "ON" + WALBERLA_BUILD_WITH_METIS: "ON" + WALBERLA_BUILD_WITH_PARMETIS: "ON" .build_hybrid_dbg_sp_template: &build_hybrid_dbg_sp_definition <<: *build_definition @@ -115,6 +127,8 @@ stages: CMAKE_BUILD_TYPE: "DebugOptimized" WALBERLA_BUFFER_DEBUG: "OFF" WALBERLA_DOUBLE_ACCURACY: "OFF" + WALBERLA_BUILD_WITH_METIS: "OFF" + WALBERLA_BUILD_WITH_PARMETIS: "OFF" ############################################################################### @@ -125,67 +139,6 @@ stages: -intel_15_serial: - <<: *build_serial_definition - image: i10git.cs.fau.de:5005/walberla/buildenvs/intel:15 - only: - - triggers - tags: - - docker - - intel - -intel_15_mpionly: - <<: *build_mpionly_definition - image: i10git.cs.fau.de:5005/walberla/buildenvs/intel:15 - only: - - triggers - tags: - - docker - - intel - -intel_15_hybrid: - <<: *build_hybrid_definition - image: i10git.cs.fau.de:5005/walberla/buildenvs/intel:15 - only: - - triggers - tags: - - docker - - intel - -intel_15_serial_dbg: - <<: *build_serial_dbg_definition - image: i10git.cs.fau.de:5005/walberla/buildenvs/intel:15 - only: - - triggers - tags: - - docker - - intel - -intel_15_mpionly_dbg: - <<: *build_mpionly_dbg_definition - image: i10git.cs.fau.de:5005/walberla/buildenvs/intel:15 - only: - - triggers - tags: - - docker - - intel - -intel_15_hybrid_dbg: - <<: *build_hybrid_dbg_definition - image: i10git.cs.fau.de:5005/walberla/buildenvs/intel:15 - tags: - - docker - - intel - -intel_15_hybrid_dbg_sp: - <<: *build_hybrid_dbg_sp_definition - image: i10git.cs.fau.de:5005/walberla/buildenvs/intel:15 - only: - - triggers - tags: - - docker - - intel - intel_16_serial: <<: *build_serial_definition image: i10git.cs.fau.de:5005/walberla/buildenvs/intel:16 @@ -239,8 +192,6 @@ intel_16_mpionly_dbg: intel_16_hybrid_dbg: <<: *build_hybrid_dbg_definition image: i10git.cs.fau.de:5005/walberla/buildenvs/intel:16 - only: - - triggers tags: - cuda - docker @@ -309,172 +260,6 @@ intel_17_hybrid_dbg_sp: - docker - intel -gcc_4.7_serial: - <<: *build_serial_definition - image: i10git.cs.fau.de:5005/walberla/buildenvs/gcc:4.7 - only: - - triggers - tags: - - docker - -gcc_4.7_mpionly: - <<: *build_mpionly_definition - image: i10git.cs.fau.de:5005/walberla/buildenvs/gcc:4.7 - only: - - triggers - tags: - - docker - -gcc_4.7_hybrid: - <<: *build_hybrid_definition - image: i10git.cs.fau.de:5005/walberla/buildenvs/gcc:4.7 - only: - - triggers - tags: - - docker - -gcc_4.7_serial_dbg: - <<: *build_serial_dbg_definition - image: i10git.cs.fau.de:5005/walberla/buildenvs/gcc:4.7 - only: - - triggers - tags: - - docker - -gcc_4.7_mpionly_dbg: - <<: *build_mpionly_dbg_definition - image: i10git.cs.fau.de:5005/walberla/buildenvs/gcc:4.7 - only: - - triggers - tags: - - docker - -gcc_4.7_hybrid_dbg: - <<: *build_hybrid_dbg_definition - image: i10git.cs.fau.de:5005/walberla/buildenvs/gcc:4.7 - tags: - - docker - -gcc_4.7_hybrid_dbg_sp: - <<: *build_hybrid_dbg_sp_definition - image: i10git.cs.fau.de:5005/walberla/buildenvs/gcc:4.7 - only: - - triggers - tags: - - docker - -gcc_4.8_serial: - <<: *build_serial_definition - image: i10git.cs.fau.de:5005/walberla/buildenvs/gcc:4.8 - only: - - triggers - tags: - - docker - -gcc_4.8_mpionly: - <<: *build_mpionly_definition - image: i10git.cs.fau.de:5005/walberla/buildenvs/gcc:4.8 - only: - - triggers - tags: - - docker - -gcc_4.8_hybrid: - <<: *build_hybrid_definition - image: i10git.cs.fau.de:5005/walberla/buildenvs/gcc:4.8 - only: - - triggers - tags: - - docker - -gcc_4.8_serial_dbg: - <<: *build_serial_dbg_definition - image: i10git.cs.fau.de:5005/walberla/buildenvs/gcc:4.8 - only: - - triggers - tags: - - docker - -gcc_4.8_mpionly_dbg: - <<: *build_mpionly_dbg_definition - image: i10git.cs.fau.de:5005/walberla/buildenvs/gcc:4.8 - only: - - triggers - tags: - - docker - -gcc_4.8_hybrid_dbg: - <<: *build_hybrid_dbg_definition - image: i10git.cs.fau.de:5005/walberla/buildenvs/gcc:4.8 - only: - - triggers - tags: - - docker - -gcc_4.8_hybrid_dbg_sp: - <<: *build_hybrid_dbg_sp_definition - image: i10git.cs.fau.de:5005/walberla/buildenvs/gcc:4.8 - only: - - triggers - tags: - - docker - -gcc_4.9_serial: - <<: *build_serial_definition - image: i10git.cs.fau.de:5005/walberla/buildenvs/gcc:4.9 - only: - - triggers - tags: - - docker - -gcc_4.9_mpionly: - <<: *build_mpionly_definition - image: i10git.cs.fau.de:5005/walberla/buildenvs/gcc:4.9 - only: - - triggers - tags: - - docker - -gcc_4.9_hybrid: - <<: *build_hybrid_definition - image: i10git.cs.fau.de:5005/walberla/buildenvs/gcc:4.9 - only: - - triggers - tags: - - docker - -gcc_4.9_serial_dbg: - <<: *build_serial_dbg_definition - image: i10git.cs.fau.de:5005/walberla/buildenvs/gcc:4.9 - only: - - triggers - tags: - - docker - -gcc_4.9_mpionly_dbg: - <<: *build_mpionly_dbg_definition - image: i10git.cs.fau.de:5005/walberla/buildenvs/gcc:4.9 - only: - - triggers - tags: - - docker - -gcc_4.9_hybrid_dbg: - <<: *build_hybrid_dbg_definition - image: i10git.cs.fau.de:5005/walberla/buildenvs/gcc:4.9 - only: - - triggers - tags: - - docker - -gcc_4.9_hybrid_dbg_sp: - <<: *build_hybrid_dbg_sp_definition - image: i10git.cs.fau.de:5005/walberla/buildenvs/gcc:4.9 - only: - - triggers - tags: - - docker - gcc_5_serial: <<: *build_serial_definition image: i10git.cs.fau.de:5005/walberla/buildenvs/gcc:5 @@ -519,8 +304,6 @@ gcc_5_mpionly_dbg: gcc_5_hybrid_dbg: <<: *build_hybrid_dbg_definition image: i10git.cs.fau.de:5005/walberla/buildenvs/gcc:5 - only: - - triggers tags: - cuda - docker @@ -636,72 +419,6 @@ gcc_7_hybrid_dbg_sp: tags: - docker -clang_3.4_serial: - <<: *build_serial_definition - image: i10git.cs.fau.de:5005/walberla/buildenvs/clang:3.4 - only: - - triggers - tags: - - docker - -clang_3.4_mpionly: - <<: *build_mpionly_definition - image: i10git.cs.fau.de:5005/walberla/buildenvs/clang:3.4 - only: - - triggers - tags: - - docker - -clang_3.4_serial_dbg: - <<: *build_serial_dbg_definition - image: i10git.cs.fau.de:5005/walberla/buildenvs/clang:3.4 - only: - - triggers - tags: - - docker - -clang_3.4_mpionly_dbg: - <<: *build_mpionly_dbg_definition - image: i10git.cs.fau.de:5005/walberla/buildenvs/clang:3.4 - tags: - - docker - -clang_3.5_serial: - <<: *build_serial_definition - image: i10git.cs.fau.de:5005/walberla/buildenvs/clang:3.5 - only: - - triggers - tags: - - cuda - - docker - -clang_3.5_mpionly: - <<: *build_mpionly_definition - image: i10git.cs.fau.de:5005/walberla/buildenvs/clang:3.5 - only: - - triggers - tags: - - cuda - - docker - -clang_3.5_serial_dbg: - <<: *build_serial_dbg_definition - image: i10git.cs.fau.de:5005/walberla/buildenvs/clang:3.5 - only: - - triggers - tags: - - cuda - - docker - -clang_3.5_mpionly_dbg: - <<: *build_mpionly_dbg_definition - image: i10git.cs.fau.de:5005/walberla/buildenvs/clang:3.5 - only: - - triggers - tags: - - cuda - - docker - clang_3.6_serial: <<: *build_serial_definition image: i10git.cs.fau.de:5005/walberla/buildenvs/clang:3.6 @@ -732,8 +449,6 @@ clang_3.6_serial_dbg: clang_3.6_mpionly_dbg: <<: *build_mpionly_dbg_definition image: i10git.cs.fau.de:5005/walberla/buildenvs/clang:3.6 - only: - - triggers tags: - cuda - docker @@ -1097,88 +812,6 @@ coverage: - ctest -LE $CTEST_EXCLUDE_LABELS -C $BUILD_CONFIGURATION --output-on-failure -j 4 -msvc-12_Hybrid_Dbg: - <<: *win_build_definition - variables: - CMAKE_GENERATOR: "Visual Studio 12 2013 Win64" - BUILD_CONFIGURATION: "DebugOptimized" - CTEST_EXCLUDE_LABELS: "longrun" - WALBERLA_BUILD_WITH_MPI: "ON" - WALBERLA_BUILD_WITH_OPENMP: "ON" - WALBERLA_DOUBLE_ACCURACY: "ON" - -msvc-12_Hybrid_SP_Dbg: - <<: *win_build_definition - variables: - CMAKE_GENERATOR: "Visual Studio 12 2013 Win64" - BUILD_CONFIGURATION: "DebugOptimized" - CTEST_EXCLUDE_LABELS: "longrun" - WALBERLA_BUILD_WITH_MPI: "ON" - WALBERLA_BUILD_WITH_OPENMP: "ON" - WALBERLA_DOUBLE_ACCURACY: "OFF" - only: - - triggers - -msvc-12_Hybrid: - <<: *win_build_definition - variables: - CMAKE_GENERATOR: "Visual Studio 12 2013 Win64" - BUILD_CONFIGURATION: "Release" - CTEST_EXCLUDE_LABELS: "longrun" - WALBERLA_BUILD_WITH_MPI: "ON" - WALBERLA_BUILD_WITH_OPENMP: "ON" - WALBERLA_DOUBLE_ACCURACY: "ON" - only: - - triggers - -msvc-12_Serial_Dbg: - <<: *win_build_definition - variables: - CMAKE_GENERATOR: "Visual Studio 12 2013 Win64" - BUILD_CONFIGURATION: "DebugOptimized" - CTEST_EXCLUDE_LABELS: "longrun" - WALBERLA_BUILD_WITH_MPI: "OFF" - WALBERLA_BUILD_WITH_OPENMP: "OFF" - WALBERLA_DOUBLE_ACCURACY: "ON" - only: - - triggers - -msvc-12_Serial: - <<: *win_build_definition - variables: - CMAKE_GENERATOR: "Visual Studio 12 2013 Win64" - BUILD_CONFIGURATION: "Release" - CTEST_EXCLUDE_LABELS: "longrun" - WALBERLA_BUILD_WITH_MPI: "OFF" - WALBERLA_BUILD_WITH_OPENMP: "OFF" - WALBERLA_DOUBLE_ACCURACY: "ON" - only: - - triggers - -msvc-12_MpiOnly_Dbg: - <<: *win_build_definition - variables: - CMAKE_GENERATOR: "Visual Studio 12 2013 Win64" - BUILD_CONFIGURATION: "DebugOptimized" - CTEST_EXCLUDE_LABELS: "longrun" - WALBERLA_BUILD_WITH_MPI: "ON" - WALBERLA_BUILD_WITH_OPENMP: "OFF" - WALBERLA_DOUBLE_ACCURACY: "ON" - only: - - triggers - -msvc-12_MpiOnly: - <<: *win_build_definition - variables: - CMAKE_GENERATOR: "Visual Studio 12 2013 Win64" - BUILD_CONFIGURATION: "Release" - CTEST_EXCLUDE_LABELS: "longrun" - WALBERLA_BUILD_WITH_MPI: "ON" - WALBERLA_BUILD_WITH_OPENMP: "OFF" - WALBERLA_DOUBLE_ACCURACY: "ON" - only: - - triggers - msvc-14_Hybrid_Dbg: <<: *win_build_definition variables: @@ -1188,8 +821,6 @@ msvc-14_Hybrid_Dbg: WALBERLA_BUILD_WITH_MPI: "ON" WALBERLA_BUILD_WITH_OPENMP: "ON" WALBERLA_DOUBLE_ACCURACY: "ON" - only: - - triggers msvc-14_Hybrid_SP_Dbg: <<: *win_build_definition @@ -1348,14 +979,10 @@ msvc-14.1_MpiOnly: .conda-deploy: &conda_deploy_definition stage: deploy before_script: - - conda update -y conda - - conda update -y python - conda install -y conda-build anaconda-client - anaconda login --username $CONDA_DEPLOY_USER --password $CONDA_DEPLOY_PASSWORD --hostname $CI_JOB_ID - conda config --set anaconda_upload yes - conda config --add channels lssfau - - conda -V - - conda build -V after_script: - anaconda logout dependencies: [] @@ -1364,41 +991,21 @@ msvc-14.1_MpiOnly: - master@walberla/walberla - tags@walberla/walberla -conda-py36-win-withoutLbm: +conda-py36-win: <<: *conda_deploy_definition tags: - win script: - - conda build --python=3.6 --user=lssfau utilities\\conda\\withoutLbm + - conda build --python=3.6 --user=lssfau utilities\\conda\\walberla -conda-py35-win-withoutLbm: +conda-py35-win: <<: *conda_deploy_definition tags: - win script: - - conda build --python=3.5 --user=lssfau utilities\\conda\\withoutLbm + - conda build --python=3.5 --user=lssfau utilities\\conda\\walberla -conda-py36-linux-withoutLbm: - <<: *conda_deploy_definition - tags: - - docker - image: continuumio/miniconda3 - script: - - apt-get update - - apt-get install -y build-essential - - conda build --python=3.6 --user=lssfau utilities/conda/withoutLbm - -conda-py35-linux-withoutLbm: - <<: *conda_deploy_definition - tags: - - docker - image: continuumio/miniconda3 - script: - - apt-get update - - apt-get install -y build-essential - - conda build --python=3.5 --user=lssfau utilities/conda/withoutLbm - -conda-py36-linux-withLbm: +conda-py36-linux: <<: *conda_deploy_definition tags: - docker @@ -1406,9 +1013,9 @@ conda-py36-linux-withLbm: script: - apt-get update - apt-get install -y build-essential - - conda build --python=3.6 --user=lssfau utilities/conda/withLbm + - conda build --python=3.6 --user=lssfau utilities/conda/walberla -conda-py35-linux-withLbm: +conda-py35-linux: <<: *conda_deploy_definition tags: - docker @@ -1416,4 +1023,4 @@ conda-py35-linux-withLbm: script: - apt-get update - apt-get install -y build-essential - - conda build --python=3.5 --user=lssfau utilities/conda/withLbm + - conda build --python=3.5 --user=lssfau utilities/conda/walberla diff --git a/CMakeLists.txt b/CMakeLists.txt index 583c5bb4edf29cddf5dccf17645c7b5f729fc54b..6ad1c28c18ca6f2b44b4f436bc654ab63d25b2c8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -25,7 +25,7 @@ ## ############################################################################################################################ -CMAKE_MINIMUM_REQUIRED (VERSION 2.8) +CMAKE_MINIMUM_REQUIRED (VERSION 3.1) PROJECT ( walberla ) @@ -36,11 +36,7 @@ include ( waLBerlaFunctions ) set_version( 4 0 ) -if( CMAKE_VERSION VERSION_LESS 2.8.3 ) - include( CMakeParseArgumentsCompat ) -else() - include( CMakeParseArguments ) -endif() +include( CMakeParseArguments ) # Enable CTest enable_testing() @@ -166,6 +162,10 @@ if( CMAKE_CXX_COMPILER MATCHES "icpc" OR CMAKE_CXX_COMPILER_ARG1 MATCHES "icpc" SET(CMAKE_LINKER "${XILD}") ENDIF(XILD) MARK_AS_ADVANCED(XILD) + if( CMAKE_VERSION VERSION_LESS 3.6.0 ) + set( CMAKE_CXX14_STANDARD_COMPILE_OPTION "-std=c++14" ) + add_flag ( CMAKE_CXX_FLAGS ${CMAKE_CXX14_STANDARD_COMPILE_OPTION} ) + endif() else() option ( WALBERLA_CXX_COMPILER_IS_INTEL "Use Intel compiler" OFF ) endif() @@ -204,7 +204,7 @@ endif() mark_as_advanced ( WALBERLA_CXX_COMPILER_IS_NEC ) # Check for Clang compiler -if( CMAKE_CXX_COMPILER MATCHES "clang" OR CMAKE_CXX_COMPILER_ARG1 MATCHES "clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang" ) +if( CMAKE_CXX_COMPILER MATCHES "clang" OR CMAKE_CXX_COMPILER_ARG1 MATCHES "clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang" ) option ( WALBERLA_CXX_COMPILER_IS_CLANG "Use clang compiler" ON ) else() option ( WALBERLA_CXX_COMPILER_IS_CLANG "Use clang compiler" OFF ) @@ -270,30 +270,19 @@ if ( WALBERLA_PROFILE_USE ) endif() endif() +set( CMAKE_CXX_STANDARD 14 ) +set( CMAKE_CXX_STANDARD_REQUIRED ON ) +set( CMAKE_CXX_EXTENSIONS OFF ) + # common flags for intel and g++ if( WALBERLA_CXX_COMPILER_IS_GNU OR WALBERLA_CXX_COMPILER_IS_INTEL ) - if( CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.7 ) - add_flag ( CMAKE_CXX_FLAGS "-std=c++0x" ) - else() - add_flag ( CMAKE_CXX_FLAGS "-std=c++11" ) - endif() - #add_flag ( CMAKE_C_FLAGS "-std=c99" ) add_flag ( CMAKE_CXX_FLAGS "-Wall -Wconversion -Wshadow" ) endif() -# C++11 language features for IBM compiler -if( WALBERLA_CXX_COMPILER_IS_IBM ) - add_flag ( CMAKE_CXX_FLAGS "-qlanglvl=autotypededuction -qlanglvl=decltype -qlanglvl=static_assert -qlanglvl=rightanglebracket -qlanglvl=c99longlong" ) -endif() - -# C++11 language features for Cray compiler -if( WALBERLA_CXX_COMPILER_IS_CRAY ) - add_flag ( CMAKE_CXX_FLAGS "-hstd=c++11" ) -endif() - -# C++11 language features for NEC compiler +# C++ language features for NEC compiler if( WALBERLA_CXX_COMPILER_IS_NEC ) - add_flag ( CMAKE_CXX_FLAGS "-Kcpp11 -Krtti -Kexceptions -size_t64 -Kgcc" ) + set( CMAKE_CXX14_STANDARD_COMPILE_OPTION "-Kcpp14" ) + add_flag ( CMAKE_CXX_FLAGS "${CMAKE_CXX14_STANDARD_COMPILE_OPTION} -Krtti -Kexceptions -size_t64 -Kgcc" ) add_flag ( CMAKE_CXX_FLAGS "-D__BIG_ENDIAN -D__BYTE_ORDER=__BIG_ENDIAN" ) add_flag ( CMAKE_CXX_FLAGS "-Tnoauto,used" ) add_flag ( CMAKE_EXE_LINKER_FLAGS "-Wl,-h,muldefs" ) @@ -384,7 +373,7 @@ endif ( ) if ( WALBERLA_CXX_COMPILER_IS_CLANG ) - add_flag ( CMAKE_CXX_FLAGS "-Wall -Wconversion -Wshadow -Wno-c++11-extensions -std=c++11 -Qunused-arguments" ) + add_flag ( CMAKE_CXX_FLAGS "-Wall -Wconversion -Wshadow -Wno-c++11-extensions -Qunused-arguments" ) add_flag ( CMAKE_CXX_FLAGS "-D'_LIBCPP_EXTERN_TEMPLATE(...)='") endif ( ) @@ -449,6 +438,70 @@ endif() +############################################################################################################################ +## +## Find optional C++ libraries +## +############################################################################################################################ + +try_compile( WALBERLA_USE_STD_FILESYSTEM "${CMAKE_CURRENT_BINARY_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}/cmake/TestStdFilesystem.cpp" + COMPILE_DEFINITIONS -DWALBERLA_USE_STD_FILESYSTEM ${CMAKE_CXX14_STANDARD_COMPILE_OPTION} ) +if( WALBERLA_USE_STD_FILESYSTEM ) + message( STATUS "Found std::filesystem") +else() + try_compile( WALBERLA_USE_STD_EXPERIMENTAL_FILESYSTEM "${CMAKE_CURRENT_BINARY_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}/cmake/TestStdFilesystem.cpp" + COMPILE_DEFINITIONS -DWALBERLA_USE_STD_EXPERIMENTAL_FILESYSTEM ${CMAKE_CXX14_STANDARD_COMPILE_OPTION} ) + if( WALBERLA_USE_STD_EXPERIMENTAL_FILESYSTEM ) + message( STATUS "Found std::experimental::filesystem") + endif() + if( NOT WALBERLA_CXX_COMPILER_IS_MSVC AND NOT WALBERLA_USE_STD_EXPERIMENTAL_FILESYSTEM ) + unset( WALBERLA_USE_STD_EXPERIMENTAL_FILESYSTEM CACHE ) + try_compile( WALBERLA_USE_STD_EXPERIMENTAL_FILESYSTEM "${CMAKE_CURRENT_BINARY_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}/cmake/TestStdFilesystem.cpp" + COMPILE_DEFINITIONS -DWALBERLA_USE_STD_EXPERIMENTAL_FILESYSTEM ${CMAKE_CXX14_STANDARD_COMPILE_OPTION} + LINK_LIBRARIES stdc++fs ) + if( WALBERLA_USE_STD_EXPERIMENTAL_FILESYSTEM ) + message( STATUS "Found std::experimental::filesystem in libstdc++fs") + list ( APPEND SERVICE_LIBS -lstdc++fs ) + endif() + endif() + if( NOT WALBERLA_CXX_COMPILER_IS_MSVC AND NOT WALBERLA_USE_STD_EXPERIMENTAL_FILESYSTEM ) + unset( WALBERLA_USE_STD_EXPERIMENTAL_FILESYSTEM CACHE ) + try_compile( WALBERLA_USE_STD_EXPERIMENTAL_FILESYSTEM "${CMAKE_CURRENT_BINARY_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}/cmake/TestStdFilesystem.cpp" + COMPILE_DEFINITIONS -DWALBERLA_USE_STD_EXPERIMENTAL_FILESYSTEM ${CMAKE_CXX14_STANDARD_COMPILE_OPTION} + LINK_LIBRARIES c++experimental ) + if( WALBERLA_USE_STD_EXPERIMENTAL_FILESYSTEM ) + message( STATUS "Found std::experimental::filesystem in libc++experimental") + list ( APPEND SERVICE_LIBS -lc++experimental ) + endif() + endif() +endif() + +try_compile( WALBERLA_USE_STD_ANY "${CMAKE_CURRENT_BINARY_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}/cmake/TestStdAny.cpp" + COMPILE_DEFINITIONS -DWALBERLA_USE_STD_ANY ${CMAKE_CXX14_STANDARD_COMPILE_OPTION} ) +if( WALBERLA_USE_STD_ANY ) + message( STATUS "Found std::any") +else() + try_compile( WALBERLA_USE_STD_EXPERIMENTAL_ANY "${CMAKE_CURRENT_BINARY_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}/cmake/TestStdAny.cpp" + COMPILE_DEFINITIONS -DWALBERLA_USE_STD_EXPERIMENTAL_ANY ${CMAKE_CXX14_STANDARD_COMPILE_OPTION} ) + if( WALBERLA_USE_STD_EXPERIMENTAL_ANY ) + message( STATUS "Found std::experimental::any") + endif() +endif() + +try_compile( WALBERLA_USE_STD_OPTIONAL "${CMAKE_CURRENT_BINARY_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}/cmake/TestStdOptional.cpp" + COMPILE_DEFINITIONS -DWALBERLA_USE_STD_OPTIONAL ${CMAKE_CXX14_STANDARD_COMPILE_OPTION} ) +if( WALBERLA_USE_STD_OPTIONAL ) + message( STATUS "Found std::optional") +else() + try_compile( WALBERLA_USE_STD_EXPERIMENTAL_OPTIONAL "${CMAKE_CURRENT_BINARY_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}/cmake/TestStdOptional.cpp" + COMPILE_DEFINITIONS -DWALBERLA_USE_STD_EXPERIMENTAL_OPTIONAL ${CMAKE_CXX14_STANDARD_COMPILE_OPTION} ) + if( WALBERLA_USE_STD_EXPERIMENTAL_OPTIONAL ) + message( STATUS "Found std::experimental::optional") + endif() +endif() + + + ############################################################################################################################ ## ## Visual Studio Setup @@ -587,24 +640,12 @@ endif() ############################################################################################################################# set ( waLBerla_REQUIRED_MIN_BOOST_VERSION "1.48") -option ( WALBERLA_BUILD_WITH_BOOST_THREAD "Build with boost thread library support" ON ) -# There have been problems with the IBM compiler and boost thread, so WALBERLA_BUILD_WITH_BOOST_THREAD is disabled by default for this compiler -if( WALBERLA_CXX_COMPILER_IS_IBM ) - set ( WALBERLA_BUILD_WITH_BOOST_THREAD OFF CACHE BOOL "Build with boost thread library support" FORCE ) +if ( NOT WALBERLA_USE_STD_FILESYSTEM AND NOT WALBERLA_USE_STD_EXPERIMENTAL_FILESYSTEM ) + list ( APPEND waLBerla_REQUIRED_BOOST_COMPONENTS filesystem system ) +else() + list ( APPEND waLBerla_OPTIONAL_BOOST_COMPONENTS system ) endif() -if ( WALBERLA_BUILD_WITH_BOOST_THREAD ) - list ( APPEND waLBerla_REQUIRED_BOOST_COMPONENTS chrono filesystem system thread ) -else () - list ( APPEND waLBerla_REQUIRED_BOOST_COMPONENTS chrono filesystem system ) -endif () - -if (( WALBERLA_CXX_COMPILER_IS_IBM ) OR - ( WALBERLA_CXX_COMPILER_IS_GNU AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.9 ) OR - ( WALBERLA_CXX_COMPILER_IS_CLANG AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.5 ) ) - list ( APPEND waLBerla_REQUIRED_BOOST_COMPONENTS regex) - endif() - if ( WALBERLA_BUILD_WITH_PYTHON AND WALBERLA_CXX_COMPILER_IS_MSVC ) list( APPEND waLBerla_REQUIRED_BOOST_COMPONENTS python3 ) endif() @@ -630,14 +671,14 @@ if ( NOT BOOST_ROOT ) endforeach ( ) endif ( ) -find_package ( Boost ${waLBerla_REQUIRED_MIN_BOOST_VERSION} COMPONENTS ${waLBerla_REQUIRED_BOOST_COMPONENTS} QUIET ) +find_package ( Boost ${waLBerla_REQUIRED_MIN_BOOST_VERSION} COMPONENTS ${waLBerla_REQUIRED_BOOST_COMPONENTS} OPTIONAL_COMPONENTS ${waLBerla_OPTIONAL_BOOST_COMPONENTS} QUIET ) if( NOT Boost_FOUND ) message ( WARNING "The specified configuration of the BOOST libraries was not found on your system! Now trying some other configuration..." ) foreach ( Boost_USE_STATIC_LIBS ON OFF ) foreach ( Boost_USE_MULTITHREADED ON OFF ) - find_package ( Boost ${waLBerla_REQUIRED_MIN_BOOST_VERSION} COMPONENTS ${waLBerla_REQUIRED_BOOST_COMPONENTS} QUIET ) + find_package ( Boost ${waLBerla_REQUIRED_MIN_BOOST_VERSION} COMPONENTS ${waLBerla_REQUIRED_BOOST_COMPONENTS} OPTIONAL_COMPONENTS ${waLBerla_OPTIONAL_BOOST_COMPONENTS} QUIET ) if ( Boost_FOUND ) set ( Boost_USE_STATIC_LIBS ${Boost_USE_STATIC_LIBS} CACHE BOOL "Use boost static libraries" FORCE ) set ( Boost_USE_MULTITHREADED ${Boost_USE_MULTITHREADED} CACHE BOOL "Use boost multithreaded libraries" FORCE ) @@ -660,8 +701,10 @@ if ( Boost_FOUND ) else() include_directories ( SYSTEM ${Boost_INCLUDE_DIRS} ) endif() - link_directories ( ${Boost_LIBRARY_DIRS} ) - list ( APPEND SERVICE_LIBS ${Boost_LIBRARIES} ) + if( waLBerla_REQUIRED_BOOST_COMPONENTS ) + link_directories ( ${Boost_LIBRARY_DIRS} ) + list ( APPEND SERVICE_LIBS ${Boost_LIBRARIES} ) + endif() add_definitions ( -DBOOST_ALL_NO_LIB ) # Disable Boost auto-linking (CMAKE does that for us...) #fix for static lib usage: http://stackoverflow.com/questions/11812463/boost-python-link-errors-under-windows-msvc10 @@ -678,7 +721,7 @@ if ( Boost_FOUND ) else( Boost_FOUND ) # Search again, this time with the REQUIRED option. This will give a CMAKE error and a detailed error message for the user - find_package ( Boost ${waLBerla_REQUIRED_MIN_BOOST_VERSION} REQUIRED ${waLBerla_REQUIRED_BOOST_COMPONENTS} ) + find_package ( Boost ${waLBerla_REQUIRED_MIN_BOOST_VERSION} REQUIRED ${waLBerla_REQUIRED_BOOST_COMPONENTS} OPTIONAL_COMPONENTS ${waLBerla_OPTIONAL_BOOST_COMPONENTS} ) endif( Boost_FOUND ) @@ -712,11 +755,11 @@ endif() ############################################################################################################################ ## -## PThread is required in Linux environments by boost::thread +## PThread is required in Linux environments by std::thread ## ############################################################################################################################ -if ( NOT WIN32 AND WALBERLA_BUILD_WITH_BOOST_THREAD ) +if ( NOT WIN32 ) add_flag( CMAKE_CXX_FLAGS "-pthread" ) endif() diff --git a/README.md b/README.md index b1659f2a9fb7d49f161c823f773a07637a86fe8c..e9f71cd44cc73ec4f0dde812b8630c70d6e3af40 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ is documented in [Sphinx](http://walberla.net/sphinx/index.html). ## Getting started -The minimum requirements are a C++11-compliant compiler (e.g. GCC or Clang), +The minimum requirements are a C++14-compliant compiler (e.g. GCC or Clang), the [Boost](http://www.boost.org) library and the [CMake](http://www.cmake.org) build system. Furthermore, you need an MPI library (like [Open MPI](http://www.open-mpi.org)) if you want to make use of parallel diff --git a/apps/benchmarks/ForcesOnSphereNearPlaneInShearFlow/ForcesOnSphereNearPlaneInShearFlow.cpp b/apps/benchmarks/ForcesOnSphereNearPlaneInShearFlow/ForcesOnSphereNearPlaneInShearFlow.cpp index e10ef4cb98df3a2f6995966817ac09755f718833..62cd5258d085e029eedce2f53940177244d7d187 100644 --- a/apps/benchmarks/ForcesOnSphereNearPlaneInShearFlow/ForcesOnSphereNearPlaneInShearFlow.cpp +++ b/apps/benchmarks/ForcesOnSphereNearPlaneInShearFlow/ForcesOnSphereNearPlaneInShearFlow.cpp @@ -576,7 +576,7 @@ int main( int argc, char **argv ) // set up synchronization procedure const real_t overlap = real_t( 1.5 ) * dx; - boost::function<void(void)> syncCall = boost::bind( pe::syncShadowOwners<BodyTypeTuple>, boost::ref(blocks->getBlockForest()), bodyStorageID, static_cast<WcTimingTree*>(NULL), overlap, false ); + std::function<void(void)> syncCall = boost::bind( pe::syncShadowOwners<BodyTypeTuple>, boost::ref(blocks->getBlockForest()), bodyStorageID, static_cast<WcTimingTree*>(NULL), overlap, false ); // create pe bodies @@ -635,7 +635,7 @@ int main( int argc, char **argv ) /////////////// // setup of the LBM communication for synchronizing the pdf field between neighboring blocks - boost::function< void () > commFunction; + std::function< void () > commFunction; blockforest::communication::UniformBufferedScheme< Stencil_T > scheme( blocks ); scheme.addPackInfo( make_shared< lbm::PdfFieldPackInfo< LatticeModel_T > >( pdfFieldID ) ); commFunction = scheme; diff --git a/apps/benchmarks/MeshDistance/MeshDistanceBenchmark.cpp b/apps/benchmarks/MeshDistance/MeshDistanceBenchmark.cpp index 64e9001fc18fec9d08296c9136015eeb9ad29568..0e95853463bb92a51bff94e4606427416dc7d994 100644 --- a/apps/benchmarks/MeshDistance/MeshDistanceBenchmark.cpp +++ b/apps/benchmarks/MeshDistance/MeshDistanceBenchmark.cpp @@ -34,7 +34,7 @@ #include "mesh/distance_octree/DistanceOctree.h" #include "mesh/MeshIO.h" -#include <boost/random.hpp> +#include <random> #include <algorithm> #include <vector> @@ -64,7 +64,7 @@ void runBenchmark( const std::string & meshFile, const uint_t numPoints, const u timer.end(); WALBERLA_LOG_INFO( "Mesh preparation took " << timer.last() << "s" ); - boost::random::mt19937 rng; + std::mt19937 rng; std::vector< typename MeshType::Point > points( numPoints ); for(auto it = points.begin(); it != points.end(); ++it) diff --git a/apps/benchmarks/MotionSingleHeavySphere/MotionSingleHeavySphere.cpp b/apps/benchmarks/MotionSingleHeavySphere/MotionSingleHeavySphere.cpp index 90e2b3479e6147974feccb5fda9ffa55e997ab4d..1bc5f2ff98de09c36cb45c76fad1ffec52d4e6f7 100644 --- a/apps/benchmarks/MotionSingleHeavySphere/MotionSingleHeavySphere.cpp +++ b/apps/benchmarks/MotionSingleHeavySphere/MotionSingleHeavySphere.cpp @@ -809,7 +809,7 @@ int main( int argc, char **argv ) // set up synchronization procedure const real_t overlap = real_t( 1.5 ) * dx; - boost::function<void(void)> syncCall; + std::function<void(void)> syncCall; if( XBlocks <= uint_t(4) ) syncCall = boost::bind( pe::syncNextNeighbors<BodyTypeTuple>, boost::ref(blocks->getBlockForest()), bodyStorageID, static_cast<WcTimingTree*>(NULL), overlap, false ); else @@ -831,7 +831,7 @@ int main( int argc, char **argv ) else if( int(Galileo) == 250 ) { // add random perturbance for chaotic regime - walberla::math::seedRandomGenerator( boost::mt19937::result_type(std::time(0)) ); + walberla::math::seedRandomGenerator( std::mt19937::result_type(std::time(0)) ); xParticle = real_c( xlength ) * real_t(0.5) + walberla::math::realRandom( real_t(-0.5), real_t(0.5) ); yParticle = real_c( ylength ) * real_t(0.5) + walberla::math::realRandom( real_t(-0.5), real_t(0.5) ); @@ -944,12 +944,12 @@ int main( int argc, char **argv ) WALBERLA_LOG_INFO_ON_ROOT("Basefolder for simulation results: " << basefolder); // create base directory if it does not yet exist - boost::filesystem::path tpath( basefolder ); - if( !boost::filesystem::exists( tpath ) ) - boost::filesystem::create_directory( tpath ); + filesystem::path tpath( basefolder ); + if( !filesystem::exists( tpath ) ) + filesystem::create_directory( tpath ); // setup of the LBM communication for synchronizing the pdf field between neighboring blocks - boost::function< void () > commFunction; + std::function< void () > commFunction; blockforest::communication::UniformBufferedScheme< Stencil_T > scheme( blocks ); scheme.addPackInfo( make_shared< lbm::PdfFieldPackInfo< LatticeModel_T > >( pdfFieldID ) ); @@ -1241,7 +1241,7 @@ int main( int argc, char **argv ) timeloop.addFuncAfterTimeStep( MovingSpherePropertyEvaluator( &timeloop, blocks, bodyStorageID, basefolder, uInfty, Galileo, GalileoSim, gravity, viscosity, diameter, densityRatio, numLBMSubCycles ), "Evaluate sphere"); // advance pe rigid body simulation - timeloop.addFuncAfterTimeStep( pe_coupling::TimeStep( blocks, bodyStorageID, cr, syncCall, real_c(numLBMSubCycles), numPeSubCycles ), "pe Time Step" ); + timeloop.addFuncAfterTimeStep( pe_coupling::TimeStep( blocks->getBlockForestPointer(), bodyStorageID, cr, syncCall, real_c(numLBMSubCycles), numPeSubCycles ), "pe Time Step" ); // vtk output auto pdfFieldVTK = vtk::createVTKOutput_BlockData( blocks, "fluid_field", writeFrequency, FieldGhostLayers, false, basefolder ); @@ -1255,9 +1255,9 @@ int main( int argc, char **argv ) pdfFieldVTK->addBeforeFunction(VTKInfoLogger( &timeloop, blocks, bodyStorageID, basefolder, uInfty )); // create folder for log_vtk files to not pollute the basefolder - boost::filesystem::path tpath2( basefolder+"/log_vtk" ); - if( !boost::filesystem::exists( tpath2 ) ) - boost::filesystem::create_directory( tpath2 ); + filesystem::path tpath2( basefolder+"/log_vtk" ); + if( !filesystem::exists( tpath2 ) ) + filesystem::create_directory( tpath2 ); field::FlagFieldCellFilter< FlagField_T > fluidFilter( flagFieldID ); diff --git a/apps/benchmarks/SchaeferTurek/SchaeferTurek.cpp b/apps/benchmarks/SchaeferTurek/SchaeferTurek.cpp index 695cc61f63a56b412975a7cc9c912dc39fe016af..ed907fc37b06df8e3e54691bebc52bc7ea7c495f 100644 --- a/apps/benchmarks/SchaeferTurek/SchaeferTurek.cpp +++ b/apps/benchmarks/SchaeferTurek/SchaeferTurek.cpp @@ -1285,7 +1285,7 @@ public: markEmptyBlocks_( markEmptyBlocks ), state_( state ) {} - void operator()( std::vector< std::pair< const PhantomBlock *, boost::any > > & blockData, const PhantomBlockForest & ) + void operator()( std::vector< std::pair< const PhantomBlock *, walberla::any > > & blockData, const PhantomBlockForest & ) { for( auto it = blockData.begin(); it != blockData.end(); ++it ) { @@ -1309,7 +1309,7 @@ struct Pseudo2DPhantomWeightPackUnpack buffer << block.getData< Pseudo2DPhantomWeight >().weight(); } - void operator()( mpi::RecvBuffer & buffer, const PhantomBlock &, boost::any & data ) + void operator()( mpi::RecvBuffer & buffer, const PhantomBlock &, walberla::any & data ) { Pseudo2DPhantomWeight::weight_t w; buffer >> w; diff --git a/apps/benchmarks/UniformGrid/UniformGrid.cpp b/apps/benchmarks/UniformGrid/UniformGrid.cpp index 15c75b3f84f5524b1b61cc32e5d913de9073721f..396faa8300a9e4a54b47c7f909bf40a929e6a7f6 100644 --- a/apps/benchmarks/UniformGrid/UniformGrid.cpp +++ b/apps/benchmarks/UniformGrid/UniformGrid.cpp @@ -495,7 +495,7 @@ struct AddLB { // setup of the LB communication for synchronizing the pdf field between neighboring blocks - boost::function< void () > commFunction; + std::function< void () > commFunction; if( directComm ) { if( fullComm ) @@ -599,7 +599,7 @@ struct AddLB< LatticeModel_T, typename boost::enable_if_c< boost::mpl::or_< { // setup of the LB communication for synchronizing the pdf field between neighboring blocks - boost::function< void () > commFunction; + std::function< void () > commFunction; if( directComm ) { diff --git a/apps/showcases/BidisperseFluidizedBed/BidisperseFluidizedBedDPM.cpp b/apps/showcases/BidisperseFluidizedBed/BidisperseFluidizedBedDPM.cpp index 1d65e398765707869220e565cd283dde393a8dc5..de0512d8dd7e24c7ae85cf706293d63e28b2a368 100644 --- a/apps/showcases/BidisperseFluidizedBed/BidisperseFluidizedBedDPM.cpp +++ b/apps/showcases/BidisperseFluidizedBed/BidisperseFluidizedBedDPM.cpp @@ -740,9 +740,9 @@ int main( int argc, char **argv ) { if( !funcTest ) { // create base directory if it does not yet exist - boost::filesystem::path tpath( vtkBaseFolder ); - if( !boost::filesystem::exists( tpath ) ) - boost::filesystem::create_directory( tpath ); + filesystem::path tpath( vtkBaseFolder ); + if( !filesystem::exists( tpath ) ) + filesystem::create_directory( tpath ); } @@ -1093,7 +1093,7 @@ int main( int argc, char **argv ) { ///////////////////////////////// // drag correlation function - boost::function<Vector3<real_t> ( const Vector3<real_t>&, const Vector3<real_t> &, real_t, real_t, real_t, real_t)> dragCorrelationFunction; + std::function<Vector3<real_t> ( const Vector3<real_t>&, const Vector3<real_t> &, real_t, real_t, real_t, real_t)> dragCorrelationFunction; if( dragCorr == DragCorrelation::ErgunWenYu ) { dragCorrelationFunction = pe_coupling::discrete_particle_methods::dragForceErgunWenYu; @@ -1124,7 +1124,7 @@ int main( int argc, char **argv ) { } // lift correlation function - boost::function<Vector3<real_t> ( const Vector3<real_t> &, const Vector3<real_t> &, const Vector3<real_t> &, real_t, real_t, real_t )> liftCorrelationFunction; + std::function<Vector3<real_t> ( const Vector3<real_t> &, const Vector3<real_t> &, const Vector3<real_t> &, real_t, real_t, real_t )> liftCorrelationFunction; if( liftCorr == LiftCorrelation::NoLift ) { liftCorrelationFunction = pe_coupling::discrete_particle_methods::noLiftForce; @@ -1139,7 +1139,7 @@ int main( int argc, char **argv ) { } // added mass correlation function - boost::function<Vector3<real_t> ( const Vector3<real_t> &, const Vector3<real_t> &, real_t, real_t )> addedMassCorrelationFunction; + std::function<Vector3<real_t> ( const Vector3<real_t> &, const Vector3<real_t> &, real_t, real_t )> addedMassCorrelationFunction; if( addedMassCorr == AddedMassCorrelation::NoAM ) { addedMassCorrelationFunction = pe_coupling::discrete_particle_methods::noAddedMassForce; @@ -1154,7 +1154,7 @@ int main( int argc, char **argv ) { } // set up effective viscosity calculation - boost::function<real_t ( real_t, real_t)> effectiveViscosityFunction; + std::function<real_t ( real_t, real_t)> effectiveViscosityFunction; if( effVisc == EffectiveViscosity::None ) { effectiveViscosityFunction = pe_coupling::discrete_particle_methods::calculateUnchangedEffectiveViscosity; @@ -1186,7 +1186,7 @@ int main( int argc, char **argv ) { (*bodyVelocityTimeDerivativeEvaluator)(); // function used to evaluate the interaction force between fluid and particles - boost::function<void(void)> dragAndPressureForceEvaluationFunction; + std::function<void(void)> dragAndPressureForceEvaluationFunction; if( dpm == DPMethod::GNS ) { if (interpol == Interpolation::INearestNeighbor) { if (dist == Distribution::DNearestNeighbor) { @@ -1251,7 +1251,7 @@ int main( int argc, char **argv ) { // function to evaluate the lift force contribution - boost::function<void(void)> liftForceEvaluationFunction; + std::function<void(void)> liftForceEvaluationFunction; if( interpol == Interpolation::INearestNeighbor ) { if( dist == Distribution::DNearestNeighbor ) @@ -1311,7 +1311,7 @@ int main( int argc, char **argv ) { } // function to evaluate the added mass contribution - boost::function<void(void)> addedMassEvaluationFunction; + std::function<void(void)> addedMassEvaluationFunction; if( interpol == Interpolation::INearestNeighbor ) { if( dist == Distribution::DNearestNeighbor ) @@ -1371,7 +1371,7 @@ int main( int argc, char **argv ) { } // function to evaluate lubrication forces - boost::function<void(void)> lubricationEvaluationFunction; + std::function<void(void)> lubricationEvaluationFunction; if( lubricationCutOffDistance > real_t(0) ) { typedef pe_coupling::discrete_particle_methods::LubricationForceEvaluator LE_T; @@ -1568,7 +1568,7 @@ int main( int argc, char **argv ) { timeloop.add() << Sweep( DummySweep(), "Dummy Sweep ") << AfterFunction( BodiesQuantityEvaluator(&timeloop, blocks, bodyStorageID, vtkBaseFolder+"/quantityLogging.txt", numSpheres, real_t(numSpheres) * particleMass ), "Body Quantity Evaluator") << AfterFunction( ForceOnBodiesAdder( blocks, bodyStorageID, Vector3<real_t>(0,0,- gravitationalAcc * ( densityRatio - real_t(1) ) ) ), "Gravitational and Buoyancy Force Add" ) - << AfterFunction( pe_coupling::discrete_particle_methods::SubgridTimeStep( blocks, bodyStorageID, *cr, syncCall, lubricationEvaluationFunction, dtInteractionSubCycle, peSubSteps ), "Pe Time Step" ); + << AfterFunction( pe_coupling::TimeStep( blocks, bodyStorageID, *cr, syncCall, dtInteractionSubCycle, peSubSteps, lubricationEvaluationFunction ), "Pe Time Step" ); // update solid volume fraction field timeloop.add() << Sweep( pe_coupling::discrete_particle_methods::SolidVolumeFractionFieldEvaluator<FlagField_T, field::KernelDistributor> ( blocks, svfFieldID, bodyStorageID, flagFieldID, Fluid_Flag ), "Solid Volume Fraction Field Evaluation" ) diff --git a/apps/tools/povrayFileCompressor/main.cpp b/apps/tools/povrayFileCompressor/main.cpp index 86f1f9ee41b95a0a4eff496f6f53484eca7e71c3..4d56bc779ec523376c8aedab6ed0ef0867d95c25 100644 --- a/apps/tools/povrayFileCompressor/main.cpp +++ b/apps/tools/povrayFileCompressor/main.cpp @@ -21,17 +21,16 @@ #include "geometry/mesh/TriangleMesh.h" #include "geometry/mesh/TriangleMeshIO.h" #include "core/Regex.h" +#include "core/Filesystem.h" #include <fstream> #include <iomanip> #include <iostream> -#define BOOST_FILESYSTEM_NO_DEPRECATED -#include <boost/filesystem.hpp> #include <boost/algorithm/string.hpp> -namespace fs = boost::filesystem; +namespace filesystem = walberla::filesystem; bool verbose; bool quiet; @@ -90,29 +89,29 @@ int main(int argc, char** argv) if( quiet && verbose ) PRINT_ERR( "PovrayFileCompressor can't be quiet (-q) and verbose (-v) at the same time\n" ) - fs::path inPath(argv[argc-2]); - if( !fs::exists(inPath) || !fs::is_directory(inPath) ) + filesystem::path inPath(argv[argc-2]); + if( !filesystem::exists(inPath) || !filesystem::is_directory(inPath) ) PRINT_ERR( "Path " << inPath << " does not exist or is not a directory!\n" ); - fs::path outPath(argv[argc-1]); - if( !fs::exists(outPath) ) - fs::create_directories(outPath); + filesystem::path outPath(argv[argc-1]); + if( !filesystem::exists(outPath) ) + filesystem::create_directories(outPath); PRINT_DEF( "Input Path: " << inPath << "\nOutput Path: " << outPath << "\n" ) - std::vector< std::vector<fs::path> > infiles; + std::vector< std::vector<filesystem::path> > infiles; PRINT_DEF( "Collecting files to compress ..." ) - for(auto pit = fs::directory_iterator(inPath); pit != fs::directory_iterator(); ++pit) + for(auto pit = filesystem::directory_iterator(inPath); pit != filesystem::directory_iterator(); ++pit) { - if( !fs::is_directory( pit->status() ) ) + if( !filesystem::is_directory( pit->status() ) ) continue; PRINT_VER( "\nCollecting files to compress in: " << pit->path()) - std::vector<fs::path> pfiles; - for(auto tit = fs::directory_iterator(pit->path()); tit != fs::directory_iterator(); ++tit) + std::vector<filesystem::path> pfiles; + for(auto tit = filesystem::directory_iterator(pit->path()); tit != filesystem::directory_iterator(); ++tit) { static const walberla::regex extensionExpression("\\.dat"); if( walberla::regex_match( tit->path().extension().string(), extensionExpression ) ) @@ -140,14 +139,14 @@ int main(int argc, char** argv) { PRINT_VER( "Compress timestep " << t << "\n" ) PRINT_VER( "Merge Splitted Meshes: \n" ) - PRINT_VER( "Merge Mesh: " << fs::absolute(infiles[0][t]).string().c_str() << "\n" ) - std::ifstream is( fs::absolute(infiles[0][t]).string().c_str() ); + PRINT_VER( "Merge Mesh: " << filesystem::absolute(infiles[0][t]).string().c_str() << "\n" ) + std::ifstream is( filesystem::absolute(infiles[0][t]).string().c_str() ); walberla::geometry::readMeshPov(is, mesh, true); is.close(); for( size_t p = 1u; p < processes; ++p ){ - PRINT_VER( "Merge Mesh: " << fs::absolute(infiles[p][t]).string().c_str() << "\n" ) - std::ifstream tis( fs::absolute(infiles[p][t]).string().c_str() ); + PRINT_VER( "Merge Mesh: " << filesystem::absolute(infiles[p][t]).string().c_str() << "\n" ) + std::ifstream tis( filesystem::absolute(infiles[p][t]).string().c_str() ); walberla::geometry::readMeshPov(tis, mesh, false); tis.close(); } @@ -172,7 +171,7 @@ int main(int argc, char** argv) } } - fs::path oPath = fs::absolute(outPath) / infiles[0][t].filename(); + filesystem::path oPath = filesystem::absolute(outPath) / infiles[0][t].filename(); PRINT_VER( "Write New Mesh File: " << (oPath.string().c_str()) << "\n" ) std::ofstream os( oPath.string().c_str() ); walberla::geometry::writeMeshPov( os, mesh, 0u, n ); diff --git a/apps/tutorials/pe/02_ConfinedGasExtended.cpp b/apps/tutorials/pe/02_ConfinedGasExtended.cpp index c58d14c2f13d7ce22f84bd83386ae5791ffc26b8..b1ac3e4a380c915c1883213706edead118920b9a 100644 --- a/apps/tutorials/pe/02_ConfinedGasExtended.cpp +++ b/apps/tutorials/pe/02_ConfinedGasExtended.cpp @@ -147,7 +147,7 @@ int main( int argc, char ** argv ) cr.setGlobalLinearAcceleration( Vec3(0,0,0) ); WALBERLA_LOG_INFO_ON_ROOT("*** SYNCCALL ***"); - boost::function<void(void)> syncCall; + std::function<void(void)> syncCall; if (!syncShadowOwners) { syncCall = boost::bind( pe::syncNextNeighbors<BodyTuple>, boost::ref(*forest), storageID, &tt, real_c(0.0), false ); @@ -157,7 +157,7 @@ int main( int argc, char ** argv ) } //! [Bind Sync Call] - boost::function<void(void)> syncCallWithoutTT; + std::function<void(void)> syncCallWithoutTT; if (!syncShadowOwners) { syncCallWithoutTT = boost::bind( pe::syncNextNeighbors<BodyTuple>, boost::ref(*forest), storageID, static_cast<WcTimingTree*>(NULL), real_c(0.0), false ); diff --git a/cmake/CMakeParseArgumentsCompat.cmake b/cmake/CMakeParseArgumentsCompat.cmake deleted file mode 100644 index 2f54a2336b81558ce7803a4ec6e6d78a94f6dc1c..0000000000000000000000000000000000000000 --- a/cmake/CMakeParseArgumentsCompat.cmake +++ /dev/null @@ -1,138 +0,0 @@ -# CMAKE_PARSE_ARGUMENTS(<prefix> <options> <one_value_keywords> <multi_value_keywords> args...) -# -# CMAKE_PARSE_ARGUMENTS() is intended to be used in macros or functions for -# parsing the arguments given to that macro or function. -# It processes the arguments and defines a set of variables which hold the -# values of the respective options. -# -# The <options> argument contains all options for the respective macro, -# i.e. keywords which can be used when calling the macro without any value -# following, like e.g. the OPTIONAL keyword of the install() command. -# -# The <one_value_keywords> argument contains all keywords for this macro -# which are followed by one value, like e.g. DESTINATION keyword of the -# install() command. -# -# The <multi_value_keywords> argument contains all keywords for this macro -# which can be followed by more than one value, like e.g. the TARGETS or -# FILES keywords of the install() command. -# -# When done, CMAKE_PARSE_ARGUMENTS() will have defined for each of the -# keywords listed in <options>, <one_value_keywords> and -# <multi_value_keywords> a variable composed of the given <prefix> -# followed by "_" and the name of the respective keyword. -# These variables will then hold the respective value from the argument list. -# For the <options> keywords this will be TRUE or FALSE. -# -# All remaining arguments are collected in a variable -# <prefix>_UNPARSED_ARGUMENTS, this can be checked afterwards to see whether -# your macro was called with unrecognized parameters. -# -# As an example here a my_install() macro, which takes similar arguments as the -# real install() command: -# -# function(MY_INSTALL) -# set(options OPTIONAL FAST) -# set(oneValueArgs DESTINATION RENAME) -# set(multiValueArgs TARGETS CONFIGURATIONS) -# cmake_parse_arguments(MY_INSTALL "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN} ) -# ... -# -# Assume my_install() has been called like this: -# my_install(TARGETS foo bar DESTINATION bin OPTIONAL blub) -# -# After the cmake_parse_arguments() call the macro will have set the following -# variables: -# MY_INSTALL_OPTIONAL = TRUE -# MY_INSTALL_FAST = FALSE (this option was not used when calling my_install() -# MY_INSTALL_DESTINATION = "bin" -# MY_INSTALL_RENAME = "" (was not used) -# MY_INSTALL_TARGETS = "foo;bar" -# MY_INSTALL_CONFIGURATIONS = "" (was not used) -# MY_INSTALL_UNPARSED_ARGUMENTS = "blub" (no value expected after "OPTIONAL" -# -# You can the continue and process these variables. -# -# Keywords terminate lists of values, e.g. if directly after a one_value_keyword -# another recognized keyword follows, this is interpreted as the beginning of -# the new option. -# E.g. my_install(TARGETS foo DESTINATION OPTIONAL) would result in -# MY_INSTALL_DESTINATION set to "OPTIONAL", but MY_INSTALL_DESTINATION would -# be empty and MY_INSTALL_OPTIONAL would be set to TRUE therefor. - -#============================================================================= -# Copyright 2010 Alexander Neundorf <neundorf@kde.org> -# -# Distributed under the OSI-approved BSD License (the "License"); -# see accompanying file Copyright.txt for details. -# -# This software is distributed WITHOUT ANY WARRANTY; without even the -# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -# See the License for more information. -#============================================================================= -# (To distribute this file outside of CMake, substitute the full -# License text for the above reference.) - - -if(__CMAKE_PARSE_ARGUMENTS_INCLUDED) - return() -endif() -set(__CMAKE_PARSE_ARGUMENTS_INCLUDED TRUE) - - -function(CMAKE_PARSE_ARGUMENTS prefix _optionNames _singleArgNames _multiArgNames) - # first set all result variables to empty/FALSE - foreach(arg_name ${_singleArgNames} ${_multiArgNames}) - set(${prefix}_${arg_name}) - endforeach(arg_name) - - foreach(option ${_optionNames}) - set(${prefix}_${option} FALSE) - endforeach(option) - - set(${prefix}_UNPARSED_ARGUMENTS) - - set(insideValues FALSE) - set(currentArgName) - - # now iterate over all arguments and fill the result variables - foreach(currentArg ${ARGN}) - list(FIND _optionNames "${currentArg}" optionIndex) # ... then this marks the end of the arguments belonging to this keyword - list(FIND _singleArgNames "${currentArg}" singleArgIndex) # ... then this marks the end of the arguments belonging to this keyword - list(FIND _multiArgNames "${currentArg}" multiArgIndex) # ... then this marks the end of the arguments belonging to this keyword - - if(${optionIndex} EQUAL -1 AND ${singleArgIndex} EQUAL -1 AND ${multiArgIndex} EQUAL -1) - if(insideValues) - if(insideValues STREQUAL "SINGLE") - set(${prefix}_${currentArgName} ${currentArg}) - set(insideValues FALSE) - elseif(insideValues STREQUAL "MULTI") - list(APPEND ${prefix}_${currentArgName} ${currentArg}) - endif() - else(insideValues) - list(APPEND ${prefix}_UNPARSED_ARGUMENTS ${currentArg}) - endif(insideValues) - else() - if(NOT ${optionIndex} EQUAL -1) - set(${prefix}_${currentArg} TRUE) - set(insideValues FALSE) - elseif(NOT ${singleArgIndex} EQUAL -1) - set(currentArgName ${currentArg}) - set(${prefix}_${currentArgName}) - set(insideValues "SINGLE") - elseif(NOT ${multiArgIndex} EQUAL -1) - set(currentArgName ${currentArg}) - set(${prefix}_${currentArgName}) - set(insideValues "MULTI") - endif() - endif() - - endforeach(currentArg) - - # propagate the result variables to the caller: - foreach(arg_name ${_singleArgNames} ${_multiArgNames} ${_optionNames}) - set(${prefix}_${arg_name} ${${prefix}_${arg_name}} PARENT_SCOPE) - endforeach(arg_name) - set(${prefix}_UNPARSED_ARGUMENTS ${${prefix}_UNPARSED_ARGUMENTS} PARENT_SCOPE) - -endfunction(CMAKE_PARSE_ARGUMENTS _options _singleArgs _multiArgs) diff --git a/cmake/TestStdAny.cpp b/cmake/TestStdAny.cpp new file mode 100644 index 0000000000000000000000000000000000000000..6b7e22269737d293cab1daba5d4030c186b5fcd8 --- /dev/null +++ b/cmake/TestStdAny.cpp @@ -0,0 +1,16 @@ +#include <iostream> +#if defined(WALBERLA_USE_STD_ANY) +#include <any> +#elif defined(WALBERLA_USE_STD_EXPERIMENTAL_ANY) +#include <experimental/any> +#endif + +int main() { +#if defined(WALBERLA_USE_STD_ANY) + auto a = std::any(42); +#elif defined(WALBERLA_USE_STD_EXPERIMENTAL_ANY) + auto a = std::experimental::any(42); +#endif + std::cout << std::experimental::any_cast<int>(a) << std::endl; + return 0; +} diff --git a/cmake/TestStdFilesystem.cpp b/cmake/TestStdFilesystem.cpp new file mode 100644 index 0000000000000000000000000000000000000000..1caf5057db6c1253635b8810e2a7792bd56d249f --- /dev/null +++ b/cmake/TestStdFilesystem.cpp @@ -0,0 +1,16 @@ +#include <iostream> +#if defined(WALBERLA_USE_STD_FILESYSTEM) +#include <filesystem> +#elif defined(WALBERLA_USE_STD_EXPERIMENTAL_FILESYSTEM) +#include <experimental/filesystem> +#endif + +int main() { +#if defined(WALBERLA_USE_STD_FILESYSTEM) + std::filesystem::path p("/tmp/test.txt"); +#elif defined(WALBERLA_USE_STD_EXPERIMENTAL_FILESYSTEM) + std::experimental::filesystem::path p("/tmp/test.txt"); +#endif + std::cout << p.extension().string() << std::endl; + return 0; +} diff --git a/cmake/TestStdOptional.cpp b/cmake/TestStdOptional.cpp new file mode 100644 index 0000000000000000000000000000000000000000..fc3a148c128e534eb37fc635c697d1e88961a6db --- /dev/null +++ b/cmake/TestStdOptional.cpp @@ -0,0 +1,19 @@ +#include <iostream> +#if defined(WALBERLA_USE_STD_OPTIONAL) +#include <optional> +#elif defined(WALBERLA_USE_STD_EXPERIMENTAL_OPTIONAL) +#include <experimental/optional> +#endif + +int main() { +#if defined(WALBERLA_USE_STD_OPTIONAL) + auto a = std::optional<int>(); + auto b = std::optional<int>(42); +#elif defined(WALBERLA_USE_STD_EXPERIMENTAL_OPTIONAL) + auto a = std::experimental::optional<int>(); + auto b = std::experimental::optional<int>(42); +#endif + if (b) + std::cout << a.value_or(b.value()) << std::endl; + return 0; +} diff --git a/cmake/waLBerlaFunctions.cmake b/cmake/waLBerlaFunctions.cmake index 727f5d02288f2c7f33e22648a63d46be4f449a02..d4b9a01f587732b6dbe8dce3e55092a3913c2125 100644 --- a/cmake/waLBerlaFunctions.cmake +++ b/cmake/waLBerlaFunctions.cmake @@ -111,6 +111,8 @@ function ( waLBerla_add_module ) waLBerla_register_dependency ( ${moduleName} ${ARG_DEPENDS} ) + set_property( TARGET ${moduleName} PROPERTY CXX_STANDARD 14 ) + # This property is needed for visual studio to group modules together if( WALBERLA_GROUP_PROJECTS ) set_property( TARGET ${moduleLibraryName} PROPERTY FOLDER "SRC" ) @@ -228,6 +230,7 @@ function ( waLBerla_add_executable ) target_link_modules ( ${ARG_NAME} ${ARG_DEPENDS} ) target_link_libraries( ${ARG_NAME} ${SERVICE_LIBS} ) + set_property( TARGET ${ARG_NAME} PROPERTY CXX_STANDARD 14 ) if( WALBERLA_GROUP_PROJECTS ) if( NOT ARG_GROUP ) diff --git a/python/waLBerla/core_extension.py b/python/waLBerla/core_extension.py index 8720e3faf254636785a8461811630b9dc3edd306..e25e06d1b531e2119a7bffd10907ca69718c2802 100644 --- a/python/waLBerla/core_extension.py +++ b/python/waLBerla/core_extension.py @@ -58,13 +58,16 @@ def sliceToCellInterval( s ): def cellIntervalToSlice(cellInterval, collapseExtentOne=True): + if not hasattr(collapseExtentOne, '__len__'): + collapseExtentOne = (collapseExtentOne, collapseExtentOne, collapseExtentOne) + slices = [] - for i in range(3): - if collapseExtentOne and cellInterval.min[i] == cellInterval.max[i]: + for i, collapseInfo in enumerate(collapseExtentOne): + if collapseInfo and cellInterval.min[i] == cellInterval.max[i]: slices.append( cellInterval.min[i] ) else: slices.append( slice(cellInterval.min[i], cellInterval.max[i]+1,None ) ) - return slices + return tuple(slices) diff --git a/python/waLBerla/cuda_extension.py b/python/waLBerla/cuda_extension.py index be218d11649f0157981df62469728f9c3c3c53cf..e61612b45627b85d00d690152b740900f874a522 100644 --- a/python/waLBerla/cuda_extension.py +++ b/python/waLBerla/cuda_extension.py @@ -1,14 +1,25 @@ from pycuda.gpuarray import GPUArray import numpy as np +from .field_extension import normalizeGhostlayerInfo -def toGpuArray(f): + +def toGpuArray(f, withGhostLayers=True): """Converts a waLBerla GPUField to a pycuda GPUArray""" if not f: return None dtype = np.dtype(f.dtypeStr) strides = [dtype.itemsize*a for a in f.strides] - return GPUArray(f.sizeWithGhostLayers, dtype, gpudata=f.ptr, strides=strides) + res = GPUArray(f.sizeWithGhostLayers, dtype, gpudata=f.ptr, strides=strides) + if withGhostLayers is True: + return res + ghostLayers = normalizeGhostlayerInfo(f, withGhostLayers) + glCutoff = [ f.nrOfGhostLayers - gl for gl in ghostLayers ] + res = res[ glCutoff[0]:-glCutoff[0] if glCutoff[0] > 0 else None, + glCutoff[1]:-glCutoff[1] if glCutoff[1] > 0 else None, + glCutoff[2]:-glCutoff[2] if glCutoff[2] > 0 else None, + : ] + return res def extend(cppCudaModule): cppCudaModule.toGpuArray = toGpuArray diff --git a/python/waLBerla/field_extension.py b/python/waLBerla/field_extension.py index 7856c4ed97d42ebb3a5eef5fa2f077645d677617..aa1be40cbe8f5ecfcc555470700016010ff59662 100644 --- a/python/waLBerla/field_extension.py +++ b/python/waLBerla/field_extension.py @@ -7,6 +7,25 @@ except ImportError: # ----------------------------- Python functions to extend the C++ field module --------------------------------- +def normalizeGhostlayerInfo( field, withGhostLayers): + """Takes one ghost layer parameter and returns an integer: + True -> all ghost layers, False->no ghost layers""" + + def normalizeComponent(gl): + if gl == False: + return 0 + if gl == True: + return field.nrOfGhostLayers + if gl > field.nrOfGhostLayers: + raise ValueError("Field only has %d ghost layers (requested %d)" % ( field.nrOfGhostLayers, gl ) ) + return gl + + if hasattr( withGhostLayers, "__len__") and len(withGhostLayers) == 3: + ghostLayers = [ normalizeComponent(gl) for gl in withGhostLayers ] + else: + ghostLayers = [ normalizeComponent(withGhostLayers) ] * 3 + return ghostLayers + def npArrayFromWaLBerlaField(field, withGhostLayers=False): """ Creates a numpy array view on the waLBerla field data @field: the waLBerla field @@ -19,24 +38,9 @@ def npArrayFromWaLBerlaField(field, withGhostLayers=False): if not field: return None - - def normalizeGhostlayerInfo( field, gl ): - """Takes one ghost layer parameter and returns an integer: - True -> all ghost layers, False->no ghost layers""" - if gl == False: - return 0 - if gl == True: - return field.nrOfGhostLayers - if gl > field.nrOfGhostLayers: - raise ValueError("Field only has %d ghost layers (requested %d)" % ( field.nrOfGhostLayers, gl ) ) - return gl - - if hasattr( withGhostLayers, "__len__") and len(withGhostLayers) == 3: - ghostLayers = [ normalizeGhostlayerInfo(field, gl) for gl in withGhostLayers ] - else: - ghostLayers = [ normalizeGhostlayerInfo(field, withGhostLayers) ] * 3 - - + + ghostLayers = normalizeGhostlayerInfo(field, withGhostLayers) + if not hasattr(field, 'buffer'): # Field adaptor -> create field with adapted values field = field.copyToField() @@ -75,15 +79,17 @@ def copyArrayToField(dstField, srcArray, slice=[slice(None,None,None) ]*3, withG def extend(cppFieldModule): - def gatherGenerator(blocks, blockDataName, sliceObj, allGather=False): + def gatherField(blocks, blockDataName, sliceObj, allGather=False): field = cppFieldModule.gather(blocks, blockDataName, sliceObj, targetRank=-1 if allGather else 0) if field is not None: field = npArrayFromWaLBerlaField(field) field.flags.writeable = False - yield field + return field + else: + return None cppFieldModule.toArray = npArrayFromWaLBerlaField cppFieldModule.adaptorToArray = arrayFromWaLBerlaAdaptor cppFieldModule.copyArrayToField = copyArrayToField - cppFieldModule.gatherGenerator = gatherGenerator + cppFieldModule.gatherField = gatherField diff --git a/src/blockforest/Block.cpp b/src/blockforest/Block.cpp index d4d081c33fc20c485e5ae817c65ccfceaffbfc47..d13ba9de7b7057dda04927ad9bb9240d98637f2b 100644 --- a/src/blockforest/Block.cpp +++ b/src/blockforest/Block.cpp @@ -97,7 +97,7 @@ Block::Block( BlockForest & forest, const PhantomBlock & phantom ) : Block::Block( BlockForest & forest, const BlockID & id, const AABB & aabb, const uint_t level, mpi::RecvBuffer & buffer, - const boost::function< uint_t ( const uint_t ) > & processMapping ) : + const std::function< uint_t ( const uint_t ) > & processMapping ) : IBlock( forest, aabb, id.getID() ), diff --git a/src/blockforest/Block.h b/src/blockforest/Block.h index 5f1a089ffa34149547d9da5105f4305c78328eff..39d958b7e8ecad45bd56d7113f1eebb8412fb41f 100644 --- a/src/blockforest/Block.h +++ b/src/blockforest/Block.h @@ -77,7 +77,7 @@ public: const std::vector< BlockReconstruction::NeighborhoodReconstructionBlock > & neighbors ); Block( BlockForest & forest, const PhantomBlock & phantom ); Block( BlockForest & forest, const BlockID & id, const AABB & aabb, const uint_t level, mpi::RecvBuffer & buffer, - const boost::function< uint_t ( const uint_t ) > & processMapping = boost::function< uint_t ( const uint_t ) >() ); + const std::function< uint_t ( const uint_t ) > & processMapping = std::function< uint_t ( const uint_t ) >() ); virtual ~Block() {} diff --git a/src/blockforest/BlockDataHandling.h b/src/blockforest/BlockDataHandling.h index a9e612e84560bdf5593ef00d979c13d8af5bf5b0..c947b3e032de0a01bf727a30e86d81ff23c035f5 100644 --- a/src/blockforest/BlockDataHandling.h +++ b/src/blockforest/BlockDataHandling.h @@ -214,7 +214,7 @@ public: template< typename T > BlockDataHandlingAdder & operator<<( const domain_decomposition::BlockDataCreator<T> & bdc ) { - auto downcast = boost::dynamic_pointer_cast< blockforest::BlockDataHandling<T> >( bdc.dataHandling_ ); + auto downcast = dynamic_pointer_cast< blockforest::BlockDataHandling<T> >( bdc.dataHandling_ ); if( downcast ) { dataHandling_.add( make_shared< blockforest::internal::BlockDataHandlingHelper<T> >( downcast ), bdc.requiredSelectors_, diff --git a/src/blockforest/BlockForest.cpp b/src/blockforest/BlockForest.cpp index 8d99f0abe7b0c015b35e0d855221979471619b64..e6c19cbc1fe9341bc297f73606a926549659355a 100644 --- a/src/blockforest/BlockForest.cpp +++ b/src/blockforest/BlockForest.cpp @@ -2277,7 +2277,7 @@ void BlockForest::update( PhantomBlockForest & phantomForest ) auto blockDataHandlingWrapper = dataItem->getDataHandling( block, targetState[0] ); if( blockDataHandlingWrapper ) { - auto downcastBlockDataHandlingWrapper = boost::dynamic_pointer_cast< blockforest::internal::BlockDataHandlingWrapper >( blockDataHandlingWrapper ); + auto downcastBlockDataHandlingWrapper = dynamic_pointer_cast< blockforest::internal::BlockDataHandlingWrapper >( blockDataHandlingWrapper ); if( !downcastBlockDataHandlingWrapper ) { WALBERLA_ABORT( "Dynamic data structure refresh failed!\n" @@ -2305,7 +2305,7 @@ void BlockForest::update( PhantomBlockForest & phantomForest ) auto blockDataHandlingWrapper = dataItem->getDataHandling( block, targetState[c] ); if( blockDataHandlingWrapper ) { - auto downcastBlockDataHandlingWrapper = boost::dynamic_pointer_cast< blockforest::internal::BlockDataHandlingWrapper >( blockDataHandlingWrapper ); + auto downcastBlockDataHandlingWrapper = dynamic_pointer_cast< blockforest::internal::BlockDataHandlingWrapper >( blockDataHandlingWrapper ); if( !downcastBlockDataHandlingWrapper ) { WALBERLA_ABORT( "Dynamic data structure refresh failed!\n" @@ -2651,7 +2651,7 @@ void BlockForest::update( PhantomBlockForest & phantomForest ) auto blockDataHandlingWrapper = dataItem->getDataHandling( block ); if( blockDataHandlingWrapper ) { - auto downcastBlockDataHandlingWrapper = boost::dynamic_pointer_cast< blockforest::internal::BlockDataHandlingWrapper >( blockDataHandlingWrapper ); + auto downcastBlockDataHandlingWrapper = dynamic_pointer_cast< blockforest::internal::BlockDataHandlingWrapper >( blockDataHandlingWrapper ); if( !downcastBlockDataHandlingWrapper ) { WALBERLA_ABORT( "Dynamic data structure refresh failed!\n" @@ -2671,7 +2671,7 @@ void BlockForest::update( PhantomBlockForest & phantomForest ) auto blockDataHandlingWrapper = dataItem->getDataHandling( block, buffers[0].first ); if( blockDataHandlingWrapper ) { - auto downcastBlockDataHandlingWrapper = boost::dynamic_pointer_cast< blockforest::internal::BlockDataHandlingWrapper >( blockDataHandlingWrapper ); + auto downcastBlockDataHandlingWrapper = dynamic_pointer_cast< blockforest::internal::BlockDataHandlingWrapper >( blockDataHandlingWrapper ); if( !downcastBlockDataHandlingWrapper ) { WALBERLA_ABORT( "Dynamic data structure refresh failed!\n" @@ -2699,7 +2699,7 @@ void BlockForest::update( PhantomBlockForest & phantomForest ) auto blockDataHandlingWrapper = dataItem->getDataHandling( block ); if( blockDataHandlingWrapper ) { - auto downcastBlockDataHandlingWrapper = boost::dynamic_pointer_cast< blockforest::internal::BlockDataHandlingWrapper >( blockDataHandlingWrapper ); + auto downcastBlockDataHandlingWrapper = dynamic_pointer_cast< blockforest::internal::BlockDataHandlingWrapper >( blockDataHandlingWrapper ); if( !downcastBlockDataHandlingWrapper ) { WALBERLA_ABORT( "Dynamic data structure refresh failed!\n" @@ -2720,7 +2720,7 @@ void BlockForest::update( PhantomBlockForest & phantomForest ) auto blockDataHandlingWrapper = dataItem->getDataHandling( block, buffers[c].first ); if( blockDataHandlingWrapper ) { - auto downcastBlockDataHandlingWrapper = boost::dynamic_pointer_cast< blockforest::internal::BlockDataHandlingWrapper >( blockDataHandlingWrapper ); + auto downcastBlockDataHandlingWrapper = dynamic_pointer_cast< blockforest::internal::BlockDataHandlingWrapper >( blockDataHandlingWrapper ); if( !downcastBlockDataHandlingWrapper ) { WALBERLA_ABORT( "Dynamic data structure refresh failed!\n" diff --git a/src/blockforest/BlockForest.h b/src/blockforest/BlockForest.h index 011dbf371076aaa42d6aa49f7acf83acbcad2546..42d1081e1feb7d6af47aba14e398966cdf055066 100644 --- a/src/blockforest/BlockForest.h +++ b/src/blockforest/BlockForest.h @@ -49,16 +49,16 @@ class BlockForest : public BlockStorage { public: - typedef boost::function< void ( std::vector< std::pair< const Block *, uint_t > > & minTargetLevels, + typedef std::function< void ( std::vector< std::pair< const Block *, uint_t > > & minTargetLevels, std::vector< const Block * > & blocksAlreadyMarkedForRefinement, const BlockForest & forest ) > RefreshMinTargetLevelDeterminationFunction; - typedef boost::function< void ( BlockForest & forest, const PhantomBlockForest & phantomForest ) > RefreshCallbackFunction; + typedef std::function< void ( BlockForest & forest, const PhantomBlockForest & phantomForest ) > RefreshCallbackFunction; - typedef boost::function< void ( std::vector<uint_t> & sendTo, std::vector<uint_t> & recvFrom ) > SnapshotCreationFunction; - typedef boost::function< uint_t ( const uint_t ) > SnapshotRestorenFunction; - typedef boost::function< void () > SnapshotRestoreCallbackFunction; + typedef std::function< void ( std::vector<uint_t> & sendTo, std::vector<uint_t> & recvFrom ) > SnapshotCreationFunction; + typedef std::function< uint_t ( const uint_t ) > SnapshotRestorenFunction; + typedef std::function< void () > SnapshotRestoreCallbackFunction; enum FileIOMode { MPI_PARALLEL, MASTER_SLAVE, SERIALIZED_DISTRIBUTED }; @@ -87,7 +87,7 @@ public: class RefreshCallbackWrappper { public: - typedef boost::function< void () > Functor_T; + typedef std::function< void () > Functor_T; RefreshCallbackWrappper( const Functor_T & functor ) : functor_( functor ) {} void operator()( BlockForest &, const PhantomBlockForest & ) { functor_(); } private: @@ -354,7 +354,7 @@ public: const Set<SUID> & incompatibleSelectors = Set<SUID>::emptySet() ); template< typename T > - inline BlockDataID addBlockData( boost::function< T* ( IBlock* const block ) > function, + inline BlockDataID addBlockData( std::function< T* ( IBlock* const block ) > function, const std::string & identifier = std::string(), const Set<SUID> & requiredSelectors = Set<SUID>::emptySet(), const Set<SUID> & incompatibleSelectors = Set<SUID>::emptySet() ) @@ -452,7 +452,7 @@ public: void setRefreshPhantomBlockDataPackFunction( const PhantomBlockForest::PhantomBlockDataPackFunction & f ) { refreshPhantomBlockDataPackFunction_ = f; } void setRefreshPhantomBlockDataUnpackFunction( const PhantomBlockForest::PhantomBlockDataUnpackFunction & f ) { refreshPhantomBlockDataUnpackFunction_ = f; } - inline bool loadBalancingFunctionRegistered() const { return !refreshPhantomBlockMigrationPreparationFunction_.empty(); } + inline bool loadBalancingFunctionRegistered() const { return static_cast<bool>(refreshPhantomBlockMigrationPreparationFunction_); } /// get number of "setRefreshPhantomBlockMigrationPreparationFunction" calls inline uint_t phantomBlockMigrationIterations() const { return phantomBlockMigrationIterations_; } @@ -856,7 +856,7 @@ inline BlockDataID BlockForest::addBlockData( const shared_ptr< T > & dataHandli { //static_assert( boost::is_base_of< BlockDataHandling<typename T::value_type>, T >::value ); - auto downcast = boost::dynamic_pointer_cast< blockforest::BlockDataHandling<typename T::value_type> >( dataHandling ); + auto downcast = dynamic_pointer_cast< blockforest::BlockDataHandling<typename T::value_type> >( dataHandling ); if( downcast ) { @@ -880,7 +880,7 @@ template< typename T > inline BlockDataID BlockForest::loadBlockData( const std::string & file, const shared_ptr< T > & dataHandling, const std::string & identifier, const Set<SUID> & requiredSelectors, const Set<SUID> & incompatibleSelectors ) { - auto downcast = boost::dynamic_pointer_cast< blockforest::BlockDataHandling<typename T::value_type> >( dataHandling ); + auto downcast = dynamic_pointer_cast< blockforest::BlockDataHandling<typename T::value_type> >( dataHandling ); if( downcast ) { diff --git a/src/blockforest/BlockID.h b/src/blockforest/BlockID.h index b9691c74490ac52663b07f65816002fc2c48354d..dddb36d96c9659d9e7e8d6460c5bfd939726fe78 100644 --- a/src/blockforest/BlockID.h +++ b/src/blockforest/BlockID.h @@ -93,8 +93,8 @@ private: static const uint_t SHIFT = UINT_BITS - 3; - BOOST_STATIC_ASSERT( UINT_BITS > 31 ); - BOOST_STATIC_ASSERT( !(UINT_BITS & (UINT_BITS - 1)) ); // power of two + WALBERLA_STATIC_ASSERT( UINT_BITS > 31 ); + WALBERLA_STATIC_ASSERT( !(UINT_BITS & (UINT_BITS - 1)) ); // power of two }; // class BlockID diff --git a/src/blockforest/GlobalLoadBalancing.h b/src/blockforest/GlobalLoadBalancing.h index 23f79d7b5d3618d50e9d8d9e0cf2f4a4d1c2e137..521af77de0c6c1fa8b186286e04e427110cf03e0 100644 --- a/src/blockforest/GlobalLoadBalancing.h +++ b/src/blockforest/GlobalLoadBalancing.h @@ -32,7 +32,7 @@ #include "core/load_balancing/MetisWrapper.h" #include "core/math/KahanSummation.h" -#include <boost/function.hpp> +#include <functional> #include <algorithm> #include <list> @@ -55,7 +55,7 @@ public: class MetisConfiguration { public: - typedef boost::function< memory_t ( const BLOCK* const, const BLOCK* const ) > CommunicationFunction; + typedef std::function< memory_t ( const BLOCK* const, const BLOCK* const ) > CommunicationFunction; MetisConfiguration( const bool _includeMetis = false, const bool _forceMetis = false, CommunicationFunction _communicationFunction = 0, const real_t _maxUbvec = real_c(1.5), const uint_t _iterations = uint_c(10) ) : @@ -801,7 +801,7 @@ uint_t GlobalLoadBalancing::metis( const std::vector< BLOCK* >& blocks, const me for( uint_t j = 0; j != block->getNeighborhoodSize(); ++j ) { adjncy.push_back( numeric_cast<int64_t>( block->getNeighbor(j)->getIndex() ) ); - adjwgt.push_back( metisConfig.communicationFunction().empty() ? 1 : + adjwgt.push_back( !metisConfig.communicationFunction() ? 1 : ( numeric_cast<int64_t>( static_cast< memory_t >(0.5) + metisConfig.communicationFunction()( block, block->getNeighbor(j) ) ) ) ); } diff --git a/src/blockforest/PhantomBlock.h b/src/blockforest/PhantomBlock.h index a209e1a17b4a87e79351360c2e314ece047b342e..7f42061abc56b1332af0be31cd1fdfbeda83beb3 100644 --- a/src/blockforest/PhantomBlock.h +++ b/src/blockforest/PhantomBlock.h @@ -28,11 +28,10 @@ #include "core/debug/Debug.h" #include "core/math/AABB.h" #include "core/uid/SUID.h" +#include "core/Any.h" #include <vector> -#include <boost/any.hpp> - namespace walberla { @@ -86,7 +85,7 @@ public: void addData( const T & data ) { data_ = data; } template< typename T > - T getData() const { return boost::any_cast<T>( data_ ); } + T getData() const { return walberla::any_cast<T>( data_ ); } bool hasData() const { return !(data_.empty()); } @@ -143,7 +142,7 @@ private: uint_t level_; // set by the user/application via callback - boost::any data_; + walberla::any data_; std::vector< NeighborBlock* > neighborhoodSection_[26]; // the 26 neighborhood sections (can be restored from 'neighborhood_') std::vector< NeighborBlock > neighborhood_; // all neighbor blocks diff --git a/src/blockforest/PhantomBlockForest.cpp b/src/blockforest/PhantomBlockForest.cpp index 4dce58b48c010129ca81ea30e0b5724e607c9c25..196ba5529e2b24b8825ea8a5903d9191cc83814f 100644 --- a/src/blockforest/PhantomBlockForest.cpp +++ b/src/blockforest/PhantomBlockForest.cpp @@ -256,13 +256,13 @@ void PhantomBlockForest::assignBlockData( const PhantomBlockDataAssignmentFuncti { if( function ) { - std::vector< std::pair< const PhantomBlock *, boost::any > > blockData; + std::vector< std::pair< const PhantomBlock *, walberla::any > > blockData; for( auto it = blocks_.begin(); it != blocks_.end(); ++it ) { auto & block = it->second; WALBERLA_ASSERT_NOT_NULLPTR( block.get() ); - blockData.push_back( std::make_pair( block.get(), boost::any() ) ); + blockData.push_back( std::make_pair( block.get(), walberla::any() ) ); } function( blockData, *this ); @@ -405,7 +405,7 @@ void PhantomBlockForest::migrate( const PhantomBlockDataPackFunction & packBlock if( packBlockData ) { - WALBERLA_ASSERT( unpackBlockData ); + WALBERLA_ASSERT( static_cast<bool>(unpackBlockData) ); packBlockData( buffer, *pBlock ); } @@ -483,8 +483,8 @@ void PhantomBlockForest::migrate( const PhantomBlockDataPackFunction & packBlock if( unpackBlockData ) { - WALBERLA_ASSERT( packBlockData ); - boost::any data; + WALBERLA_ASSERT( static_cast<bool>(packBlockData) ); + walberla::any data; unpackBlockData( buffer, *phantom, data ); phantom->addData( data ); } diff --git a/src/blockforest/PhantomBlockForest.h b/src/blockforest/PhantomBlockForest.h index 5e263158d666d839302d33beda6fcdcf90d1f2b1..1c7285167da9295ab15394133195f812406e1626 100644 --- a/src/blockforest/PhantomBlockForest.h +++ b/src/blockforest/PhantomBlockForest.h @@ -42,23 +42,23 @@ class PhantomBlockForest { public: - typedef boost::function< Set<SUID> ( const std::vector< std::pair< BlockID, Set<SUID> > > & source, const BlockID & destintation ) > + typedef std::function< Set<SUID> ( const std::vector< std::pair< BlockID, Set<SUID> > > & source, const BlockID & destintation ) > BlockStateDeterminationFunction; - typedef boost::function< void ( std::vector< std::pair< const PhantomBlock *, boost::any > > & blockData, + typedef std::function< void ( std::vector< std::pair< const PhantomBlock *, walberla::any > > & blockData, const PhantomBlockForest & phantomForest ) > PhantomBlockDataAssignmentFunction; /// \param iteration execution counter of this callback /// \return should the callback rerun after phantom block migration? - typedef boost::function< bool ( std::vector< std::pair< const PhantomBlock *, uint_t > > & targetProcess, + typedef std::function< bool ( std::vector< std::pair< const PhantomBlock *, uint_t > > & targetProcess, std::set< uint_t > & processesToRecvFrom, const PhantomBlockForest & phantomForest, const uint_t iteration ) > MigrationPreparationFunction; // = load balancing - typedef boost::function< void ( mpi::SendBuffer & buffer, const PhantomBlock & block ) > PhantomBlockDataPackFunction; - typedef boost::function< void ( mpi::RecvBuffer & buffer, const PhantomBlock & block, boost::any & data ) > PhantomBlockDataUnpackFunction; + typedef std::function< void ( mpi::SendBuffer & buffer, const PhantomBlock & block ) > PhantomBlockDataPackFunction; + typedef std::function< void ( mpi::RecvBuffer & buffer, const PhantomBlock & block, walberla::any & data ) > PhantomBlockDataUnpackFunction; diff --git a/src/blockforest/SetupBlockForest.h b/src/blockforest/SetupBlockForest.h index 01a1379a319bc3c948708eb8481fa0aaab56d794..dbea75a0058945ccb631e6b9689a9ec4324338ac 100644 --- a/src/blockforest/SetupBlockForest.h +++ b/src/blockforest/SetupBlockForest.h @@ -31,7 +31,7 @@ #include "core/math/AABB.h" #include "core/uid/SUID.h" -#include <boost/function.hpp> +#include <functional> #include <set> #include <string> #include <vector> @@ -45,7 +45,7 @@ class SetupBlockForest : private NonCopyable { public: - typedef boost::function< uint_t ( SetupBlockForest & forest, const uint_t numberOfProcesses, const memory_t perProcessMemoryLimit ) > + typedef std::function< uint_t ( SetupBlockForest & forest, const uint_t numberOfProcesses, const memory_t perProcessMemoryLimit ) > TargetProcessAssignmentFunction; // returns number of processes (may be lower than numberOfProcesses) @@ -72,14 +72,14 @@ public: // Do not use a vector of bool's! Due to the implementation of this vector in the standard library, parallel access to a // vector of bool's - even on different elements - is not thread-safe! - typedef boost::function< void ( std::vector<uint8_t>& excludeBlock, const RootBlockAABB& aabb ) > RootBlockExclusionFunction; + typedef std::function< void ( std::vector<uint8_t>& excludeBlock, const RootBlockAABB& aabb ) > RootBlockExclusionFunction; - typedef boost::function< void ( SetupBlockForest& forest ) > RefinementSelectionFunction; - typedef boost::function< void ( SetupBlockForest& forest ) > WorkloadMemorySUIDAssignmentFunction; + typedef std::function< void ( SetupBlockForest& forest ) > RefinementSelectionFunction; + typedef std::function< void ( SetupBlockForest& forest ) > WorkloadMemorySUIDAssignmentFunction; typedef std::vector< std::pair< const SetupBlock*, const SetupBlock* > > CommunicationPairs; typedef std::vector< real_t > CommunicationWeights; - typedef boost::function< void ( const CommunicationPairs &, CommunicationWeights & ) > CommunicationWeightFunction; + typedef std::function< void ( const CommunicationPairs &, CommunicationWeights & ) > CommunicationWeightFunction; inline static void NullCommunicationWeightFunction( const CommunicationPairs &, CommunicationWeights & ) { diff --git a/src/blockforest/StructuredBlockForest.h b/src/blockforest/StructuredBlockForest.h index 19de504b62ee54e2aa91bdd9c739cbe0899b362f..82f4e810d1444d18ebbb1f47e9cd19a42d2ab2c2 100644 --- a/src/blockforest/StructuredBlockForest.h +++ b/src/blockforest/StructuredBlockForest.h @@ -138,7 +138,7 @@ public: { return blockForest_->addBlockData( dataHandling, identifier, requiredSelectors, incompatibleSelectors ); } template< typename T > - inline BlockDataID addBlockData( boost::function< T* ( IBlock* const block ) > function, + inline BlockDataID addBlockData( std::function< T* ( IBlock* const block ) > function, const std::string& identifier = std::string(), const Set<SUID>& requiredSelectors = Set<SUID>::emptySet(), const Set<SUID>& incompatibleSelectors = Set<SUID>::emptySet() ) diff --git a/src/blockforest/Types.h b/src/blockforest/Types.h index 0624414b23b529e47b23e6c56a941afa0b816eb7..76ab3911327cb28608cb6c89b2a8e964a6791803 100644 --- a/src/blockforest/Types.h +++ b/src/blockforest/Types.h @@ -23,7 +23,6 @@ #include "core/DataTypes.h" -#include <boost/static_assert.hpp> #include <limits> @@ -37,8 +36,8 @@ namespace blockforest { typedef real_t workload_t; typedef real_t memory_t; -BOOST_STATIC_ASSERT( sizeof( workload_t ) == 4 || sizeof( workload_t ) == 8 ); -BOOST_STATIC_ASSERT( sizeof( memory_t ) == 4 || sizeof( memory_t ) == 8 ); +WALBERLA_STATIC_ASSERT( sizeof( workload_t ) == 4 || sizeof( workload_t ) == 8 ); +WALBERLA_STATIC_ASSERT( sizeof( memory_t ) == 4 || sizeof( memory_t ) == 8 ); template< typename T > inline workload_t workload_c( T t ) { return numeric_cast< workload_t >(t); } ///< cast to type workload_t using "workload_c(x)" template< typename T > inline memory_t memory_c ( T t ) { return numeric_cast< memory_t >(t); } ///< cast to type memory_t using "memory_c(x)" diff --git a/src/blockforest/communication/NonUniformBufferedScheme.h b/src/blockforest/communication/NonUniformBufferedScheme.h index 12d059fc6b2914f4e57c3399a8fe79007731f405..e2eca543d736d543748d115ee645f91b12323e01 100644 --- a/src/blockforest/communication/NonUniformBufferedScheme.h +++ b/src/blockforest/communication/NonUniformBufferedScheme.h @@ -37,7 +37,7 @@ #include "core/uid/SUID.h" #include <boost/bind.hpp> -#include <boost/function.hpp> +#include <functional> #include <map> #include <set> @@ -60,8 +60,8 @@ public: typedef mpi::RecvBuffer RecvBuffer; typedef shared_ptr< blockforest::communication::NonUniformPackInfo > PackInfo; - typedef boost::function<void ()> VoidFunction; - typedef boost::function<void ( SendBuffer & buffer )> SendBufferFunction; + typedef std::function<void ()> VoidFunction; + typedef std::function<void ( SendBuffer & buffer )> SendBufferFunction; //**Construction & Destruction*************************************************************************************** /*! \name Construction & Destruction */ @@ -110,7 +110,7 @@ public: //@{ void startCommunication() { startCommunicateEqualLevel(); startCommunicateCoarseToFine(); startCommunicateFineToCoarse(); } - boost::function<void()> getStartCommunicateFunctor() { return boost::bind( &NonUniformBufferedScheme::startCommunication, this ); } + std::function<void()> getStartCommunicateFunctor() { return boost::bind( &NonUniformBufferedScheme::startCommunication, this ); } inline void startCommunicateEqualLevel(); inline void startCommunicateCoarseToFine(); @@ -121,7 +121,7 @@ public: inline void startCommunicateFineToCoarse( const uint_t fineLevel ); void wait() { waitCommunicateEqualLevel(); waitCommunicateCoarseToFine(); waitCommunicateFineToCoarse(); } - boost::function<void() > getWaitFunctor() { return boost::bind( &NonUniformBufferedScheme::wait, this ); } + std::function<void() > getWaitFunctor() { return boost::bind( &NonUniformBufferedScheme::wait, this ); } inline void waitCommunicateEqualLevel(); inline void waitCommunicateCoarseToFine(); diff --git a/src/blockforest/communication/UniformBufferedScheme.h b/src/blockforest/communication/UniformBufferedScheme.h index 5fc500e20c7fb6aa710b2dd87d047c4777762a05..393301f6c78039790a97c6f752798e344c1c07a0 100644 --- a/src/blockforest/communication/UniformBufferedScheme.h +++ b/src/blockforest/communication/UniformBufferedScheme.h @@ -39,7 +39,7 @@ #include "core/uid/SUID.h" #include <boost/bind.hpp> -#include <boost/function.hpp> +#include <functional> #include <map> #include <vector> @@ -89,8 +89,8 @@ public: typedef shared_ptr< walberla::communication::UniformPackInfo > PackInfo; - typedef boost::function<void ()> VoidFunction; - typedef boost::function<void ( SendBuffer & buffer )> SendBufferFunction; + typedef std::function<void ()> VoidFunction; + typedef std::function<void ( SendBuffer & buffer )> SendBufferFunction; typedef walberla::communication::UniformPackInfo CommunicationItemInfo; @@ -161,8 +161,8 @@ public: void startCommunication(); void wait(); - boost::function<void()> getStartCommunicateFunctor(); - boost::function<void()> getWaitFunctor(); + std::function<void()> getStartCommunicateFunctor(); + std::function<void()> getWaitFunctor(); //@} //******************************************************************************************************************* @@ -537,13 +537,13 @@ void UniformBufferedScheme<Stencil>::localBufferUnpacking( const uint_t index, c } template< typename Stencil > -boost::function<void()> UniformBufferedScheme<Stencil>::getStartCommunicateFunctor() +std::function<void()> UniformBufferedScheme<Stencil>::getStartCommunicateFunctor() { return boost::bind( &UniformBufferedScheme::startCommunication, this ); } template< typename Stencil > -boost::function<void()> UniformBufferedScheme<Stencil>::getWaitFunctor() +std::function<void()> UniformBufferedScheme<Stencil>::getWaitFunctor() { return boost::bind( &UniformBufferedScheme::wait, this ); } diff --git a/src/blockforest/communication/UniformDirectScheme.h b/src/blockforest/communication/UniformDirectScheme.h index 4c2e0a4de906279f784d1dd2144d9c3deb17f65d..16d6e9fdda939275ba60ce3ef22aa98b5db9f143 100644 --- a/src/blockforest/communication/UniformDirectScheme.h +++ b/src/blockforest/communication/UniformDirectScheme.h @@ -112,8 +112,8 @@ public: void startCommunication(); void wait(); - boost::function<void()> getStartCommunicateFunctor() { return boost::bind( &UniformDirectScheme::startCommunication, this ); } - boost::function<void()> getWaitFunctor() { return boost::bind( &UniformDirectScheme::wait, this ); } + std::function<void()> getStartCommunicateFunctor() { return boost::bind( &UniformDirectScheme::startCommunication, this ); } + std::function<void()> getWaitFunctor() { return boost::bind( &UniformDirectScheme::wait, this ); } //@} //******************************************************************************************************************* diff --git a/src/blockforest/loadbalancing/DynamicCurve.h b/src/blockforest/loadbalancing/DynamicCurve.h index 14a08f559643ee7d90afca52fb5d3e698cbc770a..d9767ecf055e8b1106bbcd2746381c5be4b89db1 100644 --- a/src/blockforest/loadbalancing/DynamicCurve.h +++ b/src/blockforest/loadbalancing/DynamicCurve.h @@ -114,6 +114,9 @@ public: const PhantomBlockForest & phantomForest, const uint_t iteration ) const; + void setMaxBlocksPerProcess(const int maxBlocks) {maxBlocksPerProcess_ = maxBlocks;} + int getMaxBlocksPerProcess() const {return maxBlocksPerProcess_;} + private: void allGatherWeighted( std::vector< std::pair< const PhantomBlock *, uint_t > > & targetProcess, @@ -191,6 +194,8 @@ private: /// /// This allows to use the same algorithm for levelwise balancing as well as for balancing without levels. bool levelwise_; + + int maxBlocksPerProcess_ = std::numeric_limits<int>::max(); //!< limits the maximum number of blocks per process }; @@ -785,9 +790,11 @@ void DynamicCurveBalance< PhantomData_T >::balanceWeighted( const std::vector< s { const long double pWeight = totalWeight / numeric_cast< long double >( processes - p ); long double weight( 0 ); + int numBlocks( 0 ); while( c < blocks.size() && std::abs( pWeight - weight - numeric_cast< long double >( allBlocks[ uint_c( blocks[c].first ) ][ blocks[c].second ].second ) ) <= - std::abs( pWeight - weight ) ) + std::abs( pWeight - weight ) && + numBlocks < maxBlocksPerProcess_ ) { targets[ uint_c( blocks[c].first ) ][ blocks[c].second ] = pid_c(p); sender[p].insert( blocks[c].first ); @@ -795,6 +802,7 @@ void DynamicCurveBalance< PhantomData_T >::balanceWeighted( const std::vector< s weight += addedWeight; totalWeight -= addedWeight; ++c; + ++numBlocks; } } while( c < blocks.size() ) diff --git a/src/blockforest/loadbalancing/DynamicParMetis.h b/src/blockforest/loadbalancing/DynamicParMetis.h index 1fa7667ee3aa4932015291edccd2fbd87c336d0b..927ca25698c5257a667674535d9838191634c1a6 100644 --- a/src/blockforest/loadbalancing/DynamicParMetis.h +++ b/src/blockforest/loadbalancing/DynamicParMetis.h @@ -119,7 +119,7 @@ struct DynamicParMetisBlockInfoPackUnpack block.getData< DynamicParMetisBlockInfo >().toBuffer( buffer ); } - void operator()( mpi::RecvBuffer & buffer, const PhantomBlock &, boost::any & data ) + void operator()( mpi::RecvBuffer & buffer, const PhantomBlock &, walberla::any & data ) { data = DynamicParMetisBlockInfo( buffer ); } diff --git a/src/blockforest/loadbalancing/PODPhantomData.h b/src/blockforest/loadbalancing/PODPhantomData.h index ccf514a1f6ec3af8192d70cd48f58e07af1e5561..2be8c77cecf13525222529e9dfbc2d31dfd35cea 100644 --- a/src/blockforest/loadbalancing/PODPhantomData.h +++ b/src/blockforest/loadbalancing/PODPhantomData.h @@ -53,7 +53,7 @@ struct PODPhantomWeightPackUnpack buffer << block.getData< PODPhantomWeight<T> >().weight(); } - void operator()( mpi::RecvBuffer & buffer, const PhantomBlock &, boost::any & data ) + void operator()( mpi::RecvBuffer & buffer, const PhantomBlock &, walberla::any & data ) { typename PODPhantomWeight<T>::weight_t w; buffer >> w; diff --git a/src/blockforest/loadbalancing/StaticParMetis.h b/src/blockforest/loadbalancing/StaticParMetis.h index 85012654d1d170899034d09a50e529e2d78218e9..0e77baf45b72be5a6f6991fed3c8cc49891f94f9 100644 --- a/src/blockforest/loadbalancing/StaticParMetis.h +++ b/src/blockforest/loadbalancing/StaticParMetis.h @@ -41,7 +41,7 @@ public: enum WeightsToUse { PARMETIS_NO_WEIGHTS = 0, PARMETIS_EDGE_WEIGHTS = 1, PARMETIS_VERTEX_WEIGHTS = 2, PARMETIS_BOTH_WEIGHTS = 3 }; typedef std::pair< const SetupBlock *, const SetupBlock * > BlockPair; - typedef boost::function<void (const std::vector< BlockPair > & edges, std::vector< int64_t > & weights ) > CommWeightFunction; + typedef std::function<void (const std::vector< BlockPair > & edges, std::vector< int64_t > & weights ) > CommWeightFunction; StaticLevelwiseParMetis( const Algorithm algorithm = PARMETIS_PART_GEOM_KWAY ) : algorithm_( algorithm ), weightsToUse_( PARMETIS_VERTEX_WEIGHTS ) {} diff --git a/src/blockforest/python/Exports.cpp b/src/blockforest/python/Exports.cpp index 096a9f4a4d83381c1ad3caacdbb09aba05a11f41..66fd6c3d9d4fbf44a61253fe820f5918ca7783a4 100644 --- a/src/blockforest/python/Exports.cpp +++ b/src/blockforest/python/Exports.cpp @@ -87,7 +87,7 @@ object python_createUniformBlockGrid(tuple args, dict kw) *it != "dx" && *it != "oneBlockPerProcess" ) { - PyErr_SetString( PyExc_ValueError, (std::string("Unknown Parameter") + (*it) ).c_str() ); + PyErr_SetString( PyExc_ValueError, (std::string("Unknown Parameter: ") + (*it) ).c_str() ); throw boost::python::error_already_set(); } } diff --git a/src/core/Abort.h b/src/core/Abort.h index 3fa01308bd24c40baa1283691cee7bdb3c380afd..8c52f6783d8539613492498be0bd66ae7858b1a6 100644 --- a/src/core/Abort.h +++ b/src/core/Abort.h @@ -23,7 +23,7 @@ #include "core/singleton/Singleton.h" -#include <boost/function.hpp> +#include <functional> #include <cstdlib> #include <sstream> #include <stdexcept> @@ -40,7 +40,7 @@ class Abort : public singleton::Singleton<Abort> public: - typedef boost::function<void ( const std::string & message, const std::string & callerPath, const int line, bool withDebugInfo )> AbortFunction; + typedef std::function<void ( const std::string & message, const std::string & callerPath, const int line, bool withDebugInfo )> AbortFunction; void resetAbortFunction( const AbortFunction & function = AbortFunction() ) { abortFunction_ = function; } diff --git a/src/pe/amr/weight_assignment/WeightAssignmentFunctor.cpp b/src/core/Any.h similarity index 65% rename from src/pe/amr/weight_assignment/WeightAssignmentFunctor.cpp rename to src/core/Any.h index 806c3538ae46599c61a713eae9b60ac010035ad6..2799c1e8525fc4176e6dc7b98c3e791716c43f13 100644 --- a/src/pe/amr/weight_assignment/WeightAssignmentFunctor.cpp +++ b/src/core/Any.h @@ -13,19 +13,36 @@ // You should have received a copy of the GNU General Public License along // with waLBerla (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. // -//! \file WeightAssignmentFunctor.cpp -//! \author Sebastian Eibl <sebastian.eibl@fau.de> +//! \file Any.h +//! \ingroup core +//! \author Michael Kuron <mkuron@icp.uni-stuttgart.de> // //====================================================================================================================== -#include "WeightAssignmentFunctor.h" +#pragma once + + +#if defined(WALBERLA_USE_STD_ANY) +#include <any> +#elif defined(WALBERLA_USE_STD_EXPERIMENTAL_ANY) +#include <experimental/any> +#else +#include <boost/any.hpp> +#endif + + namespace walberla { -namespace pe { -namespace amr { -const double WeightAssignmentFunctor::baseWeight = real_t(10.0); +#if defined(WALBERLA_USE_STD_ANY) +using std::any; +using std::any_cast; +#elif defined(WALBERLA_USE_STD_EXPERIMENTAL_ANY) +using std::experimental::any; +using std::experimental::any_cast; +#else +using boost::any; +using boost::any_cast; +#endif } -} -} diff --git a/src/core/DataTypes.h b/src/core/DataTypes.h index 765636c0626c6bd62bde1a57d94f86c0ed8f0bba..b0442f52466f8fcbe13ef68656a9b99ad449cbb2 100644 --- a/src/core/DataTypes.h +++ b/src/core/DataTypes.h @@ -23,13 +23,10 @@ #include "waLBerlaDefinitions.h" -#include <boost/cstdint.hpp> -#include <boost/make_shared.hpp> +#include <cstdint> #include <boost/numeric/conversion/cast.hpp> -#include <boost/shared_ptr.hpp> -#include <boost/weak_ptr.hpp> -#include <boost/static_assert.hpp> -#include "boost/type_traits/integral_constant.hpp" +#include <memory> +#include <type_traits> #include <boost/units/detail/utility.hpp> #include <cmath> @@ -39,17 +36,19 @@ namespace walberla { +#define WALBERLA_STATIC_ASSERT(x) static_assert(x, "Assertion failed") -template <typename> struct never_true : boost::false_type {}; + +template <typename> struct never_true : std::false_type {}; // shared ptr -using boost::shared_ptr; -using boost::weak_ptr; -using boost::make_shared; -using boost::dynamic_pointer_cast; +using std::shared_ptr; +using std::weak_ptr; +using std::make_shared; +using std::dynamic_pointer_cast; // functions, use this when "function" namespace is no longer needed //using std::function; @@ -69,10 +68,10 @@ inline S numeric_cast( T t ) { // fixed size signed integral types -typedef boost::int8_t int8_t; ///< 8 bit signed integer -typedef boost::int16_t int16_t; ///< 16 bit signed integer -typedef boost::int32_t int32_t; ///< 32 bit signed integer -typedef boost::int64_t int64_t; ///< 64 bit signed integer +typedef std::int8_t int8_t; ///< 8 bit signed integer +typedef std::int16_t int16_t; ///< 16 bit signed integer +typedef std::int32_t int32_t; ///< 32 bit signed integer +typedef std::int64_t int64_t; ///< 64 bit signed integer template< typename T > inline int8_t int8_c( T t ) { return numeric_cast< int8_t >(t); } ///< cast to type int8_t using "int8_c(x)" template< typename T > inline int16_t int16_c( T t ) { return numeric_cast< int16_t >(t); } ///< cast to type int16_t using "int16_c(x)" @@ -83,10 +82,10 @@ template< typename T > inline int64_t int64_c( T t ) { return numeric_cast< int6 // fixed size unsigned integral types -typedef boost::uint8_t uint8_t; ///< 8 bit unsigned integer -typedef boost::uint16_t uint16_t; ///< 16 bit unsigned integer -typedef boost::uint32_t uint32_t; ///< 32 bit unsigned integer -typedef boost::uint64_t uint64_t; ///< 64 bit unsigned integer +typedef std::uint8_t uint8_t; ///< 8 bit unsigned integer +typedef std::uint16_t uint16_t; ///< 16 bit unsigned integer +typedef std::uint32_t uint32_t; ///< 32 bit unsigned integer +typedef std::uint64_t uint64_t; ///< 64 bit unsigned integer typedef uint8_t byte_t; typedef uint64_t id_t; //sid datatype for pe @@ -156,7 +155,7 @@ static const uint_t UINT_BITS_LD = int_ld< std::numeric_limits< uint_t >::digits typedef int cell_idx_t; //typedef int64_t cell_idx_t; -BOOST_STATIC_ASSERT( std::numeric_limits<cell_idx_t>::is_specialized && +WALBERLA_STATIC_ASSERT( std::numeric_limits<cell_idx_t>::is_specialized && std::numeric_limits<cell_idx_t>::is_integer && std::numeric_limits<cell_idx_t>::is_signed ); diff --git a/src/core/Filesystem.h b/src/core/Filesystem.h new file mode 100644 index 0000000000000000000000000000000000000000..c7bdf2e1246e875854fe19eb681d35928baf7667 --- /dev/null +++ b/src/core/Filesystem.h @@ -0,0 +1,47 @@ +//====================================================================================================================== +// +// This file is part of waLBerla. waLBerla is free software: you can +// redistribute it and/or modify it under the terms of the GNU General Public +// License as published by the Free Software Foundation, either version 3 of +// the License, or (at your option) any later version. +// +// waLBerla is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License along +// with waLBerla (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file Filesystem.h +//! \ingroup core +//! \author Michael Kuron <mkuron@icp.uni-stuttgart.de> +// +//====================================================================================================================== + +#pragma once + + +#if defined(WALBERLA_USE_STD_FILESYSTEM) +#include <filesystem> +#elif defined(WALBERLA_USE_STD_EXPERIMENTAL_FILESYSTEM) +#include <experimental/filesystem> +#else +#include <boost/filesystem.hpp> +#endif + + + +namespace walberla { +namespace filesystem { + +#if defined(WALBERLA_USE_STD_FILESYSTEM) +using namespace std::filesystem; +#elif defined(WALBERLA_USE_STD_EXPERIMENTAL_FILESYSTEM) +using namespace std::experimental::filesystem; +#else +using namespace boost::filesystem; +#endif + +} +} diff --git a/src/core/Optional.h b/src/core/Optional.h new file mode 100644 index 0000000000000000000000000000000000000000..ad23d1666a07716c717591f4b188291869a74626 --- /dev/null +++ b/src/core/Optional.h @@ -0,0 +1,48 @@ +//====================================================================================================================== +// +// This file is part of waLBerla. waLBerla is free software: you can +// redistribute it and/or modify it under the terms of the GNU General Public +// License as published by the Free Software Foundation, either version 3 of +// the License, or (at your option) OPTIONAL later version. +// +// waLBerla is distributed in the hope that it will be useful, but WITHOUT +// OPTIONAL WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License along +// with waLBerla (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file Optional.h +//! \ingroup core +//! \author Michael Kuron <mkuron@icp.uni-stuttgart.de> +// +//====================================================================================================================== + +#pragma once + + +#if defined(WALBERLA_USE_STD_OPTIONAL) +#include <optional> +#elif defined(WALBERLA_USE_STD_EXPERIMENTAL_OPTIONAL) +#include <experimental/optional> +#else +#include <boost/optional.hpp> +#endif + + + +namespace walberla { + +#if defined(WALBERLA_USE_STD_OPTIONAL) +using std::optional; +using std::nullopt; +#elif defined(WALBERLA_USE_STD_EXPERIMENTAL_OPTIONAL) +using std::experimental::optional; +using std::experimental::nullopt; +#else +using boost::optional; +const boost::none_t nullopt = boost::none; +#endif + +} diff --git a/src/core/Regex.h b/src/core/Regex.h index 85eeba2be889b3e4d7968d9a62acfff4f67ea2d3..03d45ba7812fb44b5e6e2cf97666c1f4c313df9e 100644 --- a/src/core/Regex.h +++ b/src/core/Regex.h @@ -22,43 +22,15 @@ #pragma once -#if ( defined WALBERLA_CXX_COMPILER_IS_IBM ) -#include <boost/regex.hpp> -#elif ( defined WALBERLA_CXX_COMPILER_IS_CLANG ) && ( ( __clang_major__ == 3 ) && ( __clang_minor__ <= 4 ) ) -#include <boost/regex.hpp> -#elif ( defined WALBERLA_CXX_COMPILER_IS_GNU ) && ( ( __GNUC__ == 4 ) && ( __GNUC_MINOR__ <= 8 ) ) -#include <boost/regex.hpp> -#else #include <regex> -#endif namespace walberla { -#if ( defined WALBERLA_CXX_COMPILER_IS_IBM ) -using boost::regex; -using boost::regex_match; -using boost::regex_error; -using boost::regex_search; -using boost::regex_replace; -#elif ( defined WALBERLA_CXX_COMPILER_IS_CLANG ) && ( ( __clang_major__ == 3 ) && ( __clang_minor__ <= 4 ) ) -using boost::regex; -using boost::regex_match; -using boost::regex_error; -using boost::regex_search; -using boost::regex_replace; -#elif ( defined WALBERLA_CXX_COMPILER_IS_GNU ) && ( ( __GNUC__ == 4 ) && ( __GNUC_MINOR__ <= 8 ) ) -using boost::regex; -using boost::regex_match; -using boost::regex_error; -using boost::regex_search; -using boost::regex_replace; -#else using std::regex; using std::regex_match; using std::regex_error; using std::regex_search; using std::regex_replace; -#endif } \ No newline at end of file diff --git a/src/core/cell/CellInterval.h b/src/core/cell/CellInterval.h index 1f4737337e942f340001c4363e613485624cf2e8..10dfb0d9b1bbc375aeac80e08118b61af8c8cfd4 100644 --- a/src/core/cell/CellInterval.h +++ b/src/core/cell/CellInterval.h @@ -29,7 +29,6 @@ #include "core/mpi/RecvBuffer.h" #include "core/mpi/SendBuffer.h" -#include <boost/static_assert.hpp> #include <algorithm> #include <iterator> diff --git a/src/core/config/Config.cpp b/src/core/config/Config.cpp index 8660f50522529a23e278096380f1beb25b442390..48277f3bc6336d225909ff0172e98da0a76233bf 100644 --- a/src/core/config/Config.cpp +++ b/src/core/config/Config.cpp @@ -262,7 +262,7 @@ void Config::parseFromFile( const char* filename, Block& block, unsigned int lev } else { removeTrailingWhiteSpaces( value ); - std::string file( (boost::filesystem::path( getDirectory( filename ) ) / value).string() ); + std::string file( (filesystem::path( getDirectory( filename ) ) / value).string() ); parseFromFile( file.c_str(), block, level+1 ); } } @@ -395,7 +395,7 @@ void Config::extractBlock( const char* filename, std::stringstream& input, Block } else { removeTrailingWhiteSpaces( value ); - std::string file( (boost::filesystem::path( getDirectory( filename ) ) / value).string() ); + std::string file( (filesystem::path( getDirectory( filename ) ) / value).string() ); parseFromFile( file.c_str(), block, level+1 ); } } diff --git a/src/core/config/Config.h b/src/core/config/Config.h index 1d2a286a4701aeecb8dd535699015f08526692a8..87dfc0b499fa33758fb0496d5d222ef4c5dc06bf 100644 --- a/src/core/config/Config.h +++ b/src/core/config/Config.h @@ -37,11 +37,7 @@ // boost includes #include <boost/algorithm/string/predicate.hpp> -#include <boost/filesystem/path.hpp> - -#ifndef BOOST_FILESYSTEM_VERSION -#define BOOST_FILESYSTEM_VERSION 1 -#endif +#include "core/Filesystem.h" @@ -687,13 +683,8 @@ inline void Config::convertToLowerCase( std::string& s ) */ inline std::string Config::getDirectory( const std::string& path ) { - boost::filesystem::path p( path ); -# if BOOST_FILESYSTEM_VERSION>2 - return p.branch_path().string(); -# else -# warning BOOST FILESYSTEM VERSION IS RATHER OLD! PLEASE USE BOOST VERSION 1.46 OR HIGHER + filesystem::path p( path ); return p.parent_path().string(); -# endif } //********************************************************************************************************************** @@ -707,12 +698,8 @@ inline std::string Config::getDirectory( const std::string& path ) */ inline std::string Config::getFilename( const std::string& path ) { - boost::filesystem::path p( path ); -# if BOOST_FILESYSTEM_VERSION>2 - return p.leaf().string(); -# else - return p.filename(); -# endif + filesystem::path p( path ); + return p.filename().string(); } //********************************************************************************************************************** diff --git a/src/core/debug/CheckFunctions.h b/src/core/debug/CheckFunctions.h index 54efea20b30ba2abc04105df96729d00d900eb53..4e64bbf358954947fd4fdcd01cf9808d93ed77c4 100644 --- a/src/core/debug/CheckFunctions.h +++ b/src/core/debug/CheckFunctions.h @@ -28,8 +28,6 @@ #include "core/math/Utility.h" #include "core/VectorTrait.h" -//#include <boost/math/special_functions/next.hpp> -#include <boost/static_assert.hpp> #include <boost/type_traits/is_arithmetic.hpp> #include <boost/type_traits/is_floating_point.hpp> #include <boost/type_traits/has_left_shift.hpp> diff --git a/src/core/debug/CheckFunctions.impl.h b/src/core/debug/CheckFunctions.impl.h index fb67dd269fcd357eb986bd7e32b283e23c82ccae..fac44221d516a0a8be73690787eecff21a672e88 100644 --- a/src/core/debug/CheckFunctions.impl.h +++ b/src/core/debug/CheckFunctions.impl.h @@ -20,6 +20,7 @@ //====================================================================================================================== +#include <boost/type_traits/integral_constant.hpp> /// \cond internal diff --git a/src/core/debug/Debug.h b/src/core/debug/Debug.h index 8bca728a3a9af53e395ec413a069095409bd56e3..3ea4bcd054c16039fb2adedfaf4e8043ed38ff5c 100644 --- a/src/core/debug/Debug.h +++ b/src/core/debug/Debug.h @@ -25,7 +25,7 @@ #ifndef NDEBUG # include "CheckFunctions.h" -# include <boost/function.hpp> +# include <functional> # include <boost/bind.hpp> # include <string> #endif @@ -255,12 +255,12 @@ void myAssert(const char * const file, const int line); class ConditionalExec { public: - ConditionalExec( bool cond, const boost::function<void (void)> & function ) : cond_(cond), function_(function) { } + ConditionalExec( bool cond, const std::function<void (void)> & function ) : cond_(cond), function_(function) { } ~ConditionalExec() { if(cond_) function_(); } operator bool() const { return cond_; } private: bool cond_; - boost::function<void (void)> function_; + std::function<void (void)> function_; }; /// \endcond diff --git a/src/core/logging/Logging.cpp b/src/core/logging/Logging.cpp index ea8bde365749b10c36bdd9ac669d81927fb9411f..60fc970bc461b770558d9dd674ef5e0060ca639d 100644 --- a/src/core/logging/Logging.cpp +++ b/src/core/logging/Logging.cpp @@ -21,8 +21,7 @@ #include "Logging.h" -#include <boost/filesystem/operations.hpp> -#include <boost/filesystem/path.hpp> +#include "core/Filesystem.h" #include <ctime> @@ -105,9 +104,9 @@ void Logging::includeLoggingToFile( const std::string & file, bool append ) std::ostringstream filename; if( file.empty() ) { - boost::filesystem::path logDir( "logging" ); - if( !boost::filesystem::exists( logDir ) ) - boost::filesystem::create_directory( logDir ); + filesystem::path logDir( "logging" ); + if( !filesystem::exists( logDir ) ) + filesystem::create_directory( logDir ); if( numberOfProcesses_ == 1 ) filename << "logging/logfile.txt"; @@ -120,7 +119,7 @@ void Logging::includeLoggingToFile( const std::string & file, bool append ) filename << file; else { - boost::filesystem::path filePath( file ); + filesystem::path filePath( file ); const std::string stem = filePath.stem().string(); const std::string extension = filePath.extension().string(); const std::string modifiedFilename = stem + std::string("_") + rank.str() + extension; diff --git a/src/core/logging/Logging.h b/src/core/logging/Logging.h index 0f7a88319dfa29625b18ee6faa59a3179538a7bf..603b944142e3dd564bd57ffaa7b2e03b5dc1e84a 100644 --- a/src/core/logging/Logging.h +++ b/src/core/logging/Logging.h @@ -31,7 +31,7 @@ #include "core/Regex.h" #include <boost/algorithm/string/replace.hpp> -#include <boost/function.hpp> +#include <functional> #include <cmath> #include <fstream> diff --git a/src/core/math/DistributedSample.cpp b/src/core/math/DistributedSample.cpp index 8d7a531b55545d059b600e25ceb9c8f10704cf93..509af72af40ccd817e29f183e0d1b8925574a414 100644 --- a/src/core/math/DistributedSample.cpp +++ b/src/core/math/DistributedSample.cpp @@ -26,7 +26,6 @@ #include <boost/algorithm/string/replace.hpp> #include <boost/lexical_cast.hpp> -#include <boost/math/special_functions/pow.hpp> @@ -64,7 +63,10 @@ void DistributedSample::mpiAllGather() variance_ = real_t(0); for( auto it = data_.begin(); it != data_.end(); ++it ) - variance_ += boost::math::pow<2>( *it - mean_ ); + { + real_t val = *it - mean_; + variance_ += val*val; + } WALBERLA_MPI_SECTION() { @@ -120,7 +122,10 @@ void DistributedSample::mpiGather( int rank ) variance_ = real_t(0); for( auto it = data_.begin(); it != data_.end(); ++it ) - variance_ += boost::math::pow<2>( *it - mean_ ); + { + real_t val = *it - mean_; + variance_ += val*val; + } WALBERLA_MPI_SECTION() { diff --git a/src/core/math/FPClassify.h b/src/core/math/FPClassify.h index 2c87b8e2b37597f02c5e824f8ac650d6b16e70da..abd8aee27c2d15ea1b13558fda974c5866d46eb8 100644 --- a/src/core/math/FPClassify.h +++ b/src/core/math/FPClassify.h @@ -22,7 +22,7 @@ #pragma once -#include <boost/math/special_functions/fpclassify.hpp> +#include <cmath> namespace walberla { @@ -39,7 +39,7 @@ namespace math { template<typename T> inline bool isnan(T x) { - return (boost::math::isnan)(x); + return (std::isnan)(x); } @@ -53,7 +53,7 @@ inline bool isnan(T x) template<typename T> inline bool isinf(T x) { - return (boost::math::isinf)(x); + return (std::isinf)(x); } @@ -67,7 +67,7 @@ inline bool isinf(T x) template<typename T> bool finite(T x) { - return (boost::math::isfinite)(x); + return (std::isfinite)(x); } diff --git a/src/core/math/GenericAABB.h b/src/core/math/GenericAABB.h index 99e1ac6478d2fef22a3cafc4e9d29eaaa68c5d60..aa8e15ac57be558db072a0aef155bde677c97d52 100644 --- a/src/core/math/GenericAABB.h +++ b/src/core/math/GenericAABB.h @@ -30,7 +30,7 @@ #include <boost/array.hpp> #include <boost/type_traits/is_floating_point.hpp> -#include <boost/random/uniform_real_distribution.hpp> +#include <random> namespace walberla { diff --git a/src/core/math/GenericAABB.impl.h b/src/core/math/GenericAABB.impl.h index e5db1a23cd68e35012b3720c76213e118697963f..5709d770e51cf1f03ff81f3c9e322032b35325d6 100644 --- a/src/core/math/GenericAABB.impl.h +++ b/src/core/math/GenericAABB.impl.h @@ -1717,7 +1717,7 @@ void GenericAABB< T >::intersect( const GenericAABB & other ) * The point is in ( [ xMin(), xMax() ), [ yMin(), yMax() ), [ zMin(), zMax() ) ) * * \pre !empty() - * \param engine An Uniform Random Number Generator (e.g. boost::random::mt19937) + * \param engine An Uniform Random Number Generator (e.g. std::mt19937) * \returns Random point within *this */ template< typename T > @@ -1725,9 +1725,9 @@ template< typename Engine > typename GenericAABB< T >::vector_type GenericAABB< T >::randomPoint( Engine & engine ) const { WALBERLA_ASSERT( !empty() ); - boost::random::uniform_real_distribution< T > randX( xMin(), xMax() ); - boost::random::uniform_real_distribution< T > randY( yMin(), yMax() ); - boost::random::uniform_real_distribution< T > randZ( zMin(), zMax() ); + std::uniform_real_distribution< T > randX( xMin(), xMax() ); + std::uniform_real_distribution< T > randY( yMin(), yMax() ); + std::uniform_real_distribution< T > randZ( zMin(), zMax() ); return vector_type( randX( engine ), randY( engine ), randZ( engine ) ); } diff --git a/src/core/math/Matrix2.h b/src/core/math/Matrix2.h index db66c6e2cc45be63c6798537dd8e1d6f6db04d56..87b41821e01dc77efd2e2daffc82382ada132980 100644 --- a/src/core/math/Matrix2.h +++ b/src/core/math/Matrix2.h @@ -28,7 +28,6 @@ #include "core/mpi/RecvBuffer.h" #include "core/mpi/SendBuffer.h" -#include <boost/static_assert.hpp> #include <algorithm> #include <cmath> #include <iostream> @@ -725,9 +724,9 @@ inline const Matrix2<Type> Matrix2<Type>::getTranspose() const template< typename Type > inline Matrix2<Type>& Matrix2<Type>::invert() { - BOOST_STATIC_ASSERT( !std::numeric_limits<Type>::is_integer ); + WALBERLA_STATIC_ASSERT( !std::numeric_limits<Type>::is_integer ); - BOOST_STATIC_ASSERT( !std::numeric_limits<Type>::is_integer ); + WALBERLA_STATIC_ASSERT( !std::numeric_limits<Type>::is_integer ); Type det = getDeterminant(); @@ -754,9 +753,9 @@ inline Matrix2<Type>& Matrix2<Type>::invert() template< typename Type > inline const Matrix2<Type> Matrix2<Type>::getInverse() const { - BOOST_STATIC_ASSERT( !std::numeric_limits<Type>::is_integer ); + WALBERLA_STATIC_ASSERT( !std::numeric_limits<Type>::is_integer ); - BOOST_STATIC_ASSERT( !std::numeric_limits<Type>::is_integer ); + WALBERLA_STATIC_ASSERT( !std::numeric_limits<Type>::is_integer ); Type det = getDeterminant(); @@ -898,7 +897,7 @@ inline bool isnan( const Matrix2<Type>& m ) template< typename Type > inline const Matrix2<Type> abs( const Matrix2<Type>& m ) { - BOOST_STATIC_ASSERT( std::numeric_limits<Type>::is_integer ); + WALBERLA_STATIC_ASSERT( std::numeric_limits<Type>::is_integer ); return Matrix2<Type>( std::abs(m[0]), std::abs(m[1]), std::abs(m[2]), std::abs(m[3]) ); } @@ -919,7 +918,7 @@ inline const Matrix2<Type> abs( const Matrix2<Type>& m ) template< typename Type > inline const Matrix2<Type> fabs( const Matrix2<Type>& m ) { - BOOST_STATIC_ASSERT( !std::numeric_limits<Type>::is_integer ); + WALBERLA_STATIC_ASSERT( !std::numeric_limits<Type>::is_integer ); return Matrix2<Type>( std::fabs(m[0]), std::fabs(m[1]), std::fabs(m[2]), std::fabs(m[3]) ); } diff --git a/src/core/math/Matrix3.h b/src/core/math/Matrix3.h index 8706833ae539070102d9258ece6c8faecf1016e1..27a29b9450d6c9d95630440b7ffc346d6e0fa630 100644 --- a/src/core/math/Matrix3.h +++ b/src/core/math/Matrix3.h @@ -32,7 +32,6 @@ #include "core/mpi/RecvBuffer.h" #include "core/mpi/SendBuffer.h" -#include <boost/static_assert.hpp> #include <boost/type_traits/is_arithmetic.hpp> #include <boost/utility/enable_if.hpp> @@ -370,9 +369,9 @@ template< typename Type > template< typename Axis, typename Angle > Matrix3<Type>::Matrix3( Vector3<Axis> axis, Angle angle ) { - BOOST_STATIC_ASSERT( !std::numeric_limits<Type>::is_integer ); - BOOST_STATIC_ASSERT( !std::numeric_limits<Axis>::is_integer ); - BOOST_STATIC_ASSERT( !std::numeric_limits<Angle>::is_integer ); + WALBERLA_STATIC_ASSERT( !std::numeric_limits<Type>::is_integer ); + WALBERLA_STATIC_ASSERT( !std::numeric_limits<Axis>::is_integer ); + WALBERLA_STATIC_ASSERT( !std::numeric_limits<Angle>::is_integer ); const Angle sina( std::sin(angle) ); const Angle cosa( std::cos(angle) ); @@ -1007,9 +1006,9 @@ inline const Matrix3<Type> Matrix3<Type>::getTranspose() const template< typename Type > inline Matrix3<Type>& Matrix3<Type>::invert() { - BOOST_STATIC_ASSERT( !std::numeric_limits<Type>::is_integer ); + WALBERLA_STATIC_ASSERT( !std::numeric_limits<Type>::is_integer ); - BOOST_STATIC_ASSERT( !std::numeric_limits<Type>::is_integer ); + WALBERLA_STATIC_ASSERT( !std::numeric_limits<Type>::is_integer ); Type det = v_[0] * ( ( v_[4] * v_[8] ) - ( v_[7] * v_[5] ) ) + v_[1] * ( ( v_[5] * v_[6] ) - ( v_[8] * v_[3] ) ) + @@ -1046,7 +1045,7 @@ inline Matrix3<Type>& Matrix3<Type>::invert() template< typename Type > inline const Matrix3<Type> Matrix3<Type>::getInverse() const { - BOOST_STATIC_ASSERT( !std::numeric_limits<Type>::is_integer ); + WALBERLA_STATIC_ASSERT( !std::numeric_limits<Type>::is_integer ); Type det = v_[0] * ( ( v_[4] * v_[8] ) - ( v_[7] * v_[5] ) ) + v_[1] * ( ( v_[5] * v_[6] ) - ( v_[8] * v_[3] ) ) + @@ -1101,8 +1100,8 @@ template< typename Type > template< typename Other > inline const Matrix3<HIGH> Matrix3<Type>::rotate( const Matrix3<Other>& m ) const { - BOOST_STATIC_ASSERT( !std::numeric_limits<Type>::is_integer ); - BOOST_STATIC_ASSERT( !std::numeric_limits<Other>::is_integer ); + WALBERLA_STATIC_ASSERT( !std::numeric_limits<Type>::is_integer ); + WALBERLA_STATIC_ASSERT( !std::numeric_limits<Other>::is_integer ); //--Multiplication in two steps (number of FLOP = 90, 1 additional temporary matrix)------------ @@ -1160,8 +1159,8 @@ template< typename Type > template< typename Other > inline const Matrix3<HIGH> Matrix3<Type>::diagRotate( const Matrix3<Other>& m ) const { - BOOST_STATIC_ASSERT( !std::numeric_limits<Type>::is_integer ); - BOOST_STATIC_ASSERT( !std::numeric_limits<Other>::is_integer ); + WALBERLA_STATIC_ASSERT( !std::numeric_limits<Type>::is_integer ); + WALBERLA_STATIC_ASSERT( !std::numeric_limits<Other>::is_integer ); // Precalculating tmp = m * R(-1) const Matrix3<HIGH> tmp( m.v_[0]*v_[0], m.v_[0]*v_[3], m.v_[0]*v_[6], @@ -1249,7 +1248,7 @@ inline bool Matrix3<Type>::isZero() const template< typename Type > inline const Matrix3<Type> Matrix3<Type>::getCholesky() const { - BOOST_STATIC_ASSERT( !std::numeric_limits<Type>::is_integer ); + WALBERLA_STATIC_ASSERT( !std::numeric_limits<Type>::is_integer ); Matrix3 tmp( Type(0) ); @@ -1292,8 +1291,8 @@ template< typename Type > template< typename Other > inline const Vector3<HIGH> Matrix3<Type>::solve( const Vector3<Other> &rhs ) const { - BOOST_STATIC_ASSERT( !std::numeric_limits<Type>::is_integer ); - BOOST_STATIC_ASSERT( !std::numeric_limits<Other>::is_integer ); + WALBERLA_STATIC_ASSERT( !std::numeric_limits<Type>::is_integer ); + WALBERLA_STATIC_ASSERT( !std::numeric_limits<Other>::is_integer ); Vector3<HIGH> tmp1, tmp2; HIGH sum; @@ -1355,7 +1354,7 @@ inline Type Matrix3<Type>::trace() const template< typename Type > inline const Vector3<Type> Matrix3<Type>::getEulerAnglesXYZ() const { - BOOST_STATIC_ASSERT( !std::numeric_limits<Type>::is_integer ); + WALBERLA_STATIC_ASSERT( !std::numeric_limits<Type>::is_integer ); const Type cy( std::sqrt( v_[0]*v_[0] + v_[3]*v_[3] ) ); @@ -1382,7 +1381,7 @@ inline const Vector3<Type> Matrix3<Type>::getEulerAnglesXYZ() const template< typename Type > const Vector3<Type> Matrix3<Type>::getEulerAngles( EulerRotation order ) const { - BOOST_STATIC_ASSERT( !std::numeric_limits<Type>::is_integer ); + WALBERLA_STATIC_ASSERT( !std::numeric_limits<Type>::is_integer ); static const uint_t eulSafe[4] = { 0, 1, 2, 0 }; static const uint_t eulNext[4] = { 1, 2, 0, 1 }; @@ -1612,6 +1611,23 @@ inline const Matrix3<Type> skewSymCrossProduct( const Vector3<Type>& vec, const //************************************************************************************************* +//************************************************************************************************* +/*!\brief Dyadic product of two vectors (\f$ M = u \otimes v \f$). + * + * \param vec1 The first vector argument. + * \param vec2 The second vector argument. + * \return The matrix \f$ u \otimes v \f$. + */ +template< typename Type > +inline const Matrix3<Type> dyadicProduct( const Vector3<Type>& vec1, const Vector3<Type>& vec2 ) +{ + return Matrix3<Type>( vec1[0] * vec2[0], vec1[0] * vec2[1], vec1[0] * vec2[2], + vec1[1] * vec2[0], vec1[1] * vec2[1], vec1[1] * vec2[2], + vec1[2] * vec2[0], vec1[2] * vec2[1], vec1[2] * vec2[2]); +} +//************************************************************************************************* + + //********************************************************************************************************************** /*!\fn std::ostream& operator<<( std::ostream& os, const Matrix3<Type>& m ) // \brief Global output operator for 3x3 matrices. @@ -1663,7 +1679,7 @@ inline bool isnan( const Matrix3<Type>& m ) template< typename Type > inline const Matrix3<Type> abs( const Matrix3<Type>& m ) { - BOOST_STATIC_ASSERT( std::numeric_limits<Type>::is_integer ); + WALBERLA_STATIC_ASSERT( std::numeric_limits<Type>::is_integer ); return Matrix3<Type>( std::abs(m[0]), std::abs(m[1]), std::abs(m[2]), std::abs(m[3]), std::abs(m[4]), std::abs(m[5]), std::abs(m[6]), std::abs(m[7]), std::abs(m[8]) ); @@ -1685,7 +1701,7 @@ inline const Matrix3<Type> abs( const Matrix3<Type>& m ) template< typename Type > inline const Matrix3<Type> fabs( const Matrix3<Type>& m ) { - BOOST_STATIC_ASSERT( !std::numeric_limits<Type>::is_integer ); + WALBERLA_STATIC_ASSERT( !std::numeric_limits<Type>::is_integer ); return Matrix3<Type>( std::fabs(m[0]), std::fabs(m[1]), std::fabs(m[2]), std::fabs(m[3]), std::fabs(m[4]), std::fabs(m[5]), std::fabs(m[6]), std::fabs(m[7]), std::fabs(m[8]) ); diff --git a/src/core/math/PhysicalCheck.cpp b/src/core/math/PhysicalCheck.cpp index 43c8e5030a5e0266f12701acab71fd9d11fd7255..321890603a9e7d0306858a94e489dad95b02cf4d 100644 --- a/src/core/math/PhysicalCheck.cpp +++ b/src/core/math/PhysicalCheck.cpp @@ -231,7 +231,7 @@ namespace math { constraints_.push_back( *i ); } - void PhysicalCheck::completeConfig( const boost::shared_ptr<Config>& config ) + void PhysicalCheck::completeConfig( const shared_ptr<Config>& config ) { auto globalBlock = config->getWritableGlobalBlock(); diff --git a/src/core/math/PhysicalCheck.h b/src/core/math/PhysicalCheck.h index d3ae91ee9848425fef6ecc063e3a3c254ebcf897..857b292f404f96b2bec8fed07ed036963afefea4 100644 --- a/src/core/math/PhysicalCheck.h +++ b/src/core/math/PhysicalCheck.h @@ -94,7 +94,7 @@ namespace math { void addEquations ( const std::vector<std::string>& equations ); void addUnitParameterRelations ( const std::map< std::string, std::string >& unitParameterRelations ); void addConstraints ( const std::vector<std::string>& constraints ); - void completeConfig ( const boost::shared_ptr<Config>& config ); + void completeConfig ( const shared_ptr<Config>& config ); //@} //**************************************************************************************************************** diff --git a/src/core/math/Quaternion.h b/src/core/math/Quaternion.h index a20309bfd857aa85a8739bf834e9de7b7a424040..ccf6836d1f16a204b3ba179d1acfefdf1a0d1878 100644 --- a/src/core/math/Quaternion.h +++ b/src/core/math/Quaternion.h @@ -661,7 +661,7 @@ inline void Quaternion<Type>::swap( Quaternion& q ) /* throw() */ template< typename Type > inline const Vector3<Type> Quaternion<Type>::getEulerAnglesXYZ() const { - BOOST_STATIC_ASSERT(!std::numeric_limits<Type>::is_integer); + WALBERLA_STATIC_ASSERT(!std::numeric_limits<Type>::is_integer); Vector3<Type> eulerAngles; diff --git a/src/core/math/Random.cpp b/src/core/math/Random.cpp index 0236e1012abe4745d3527bc4542d5581476331ae..72707f208e5053cba44daed005e2685f86333e8b 100644 --- a/src/core/math/Random.cpp +++ b/src/core/math/Random.cpp @@ -29,9 +29,9 @@ namespace math { namespace internal { -static boost::mt19937 generator; // static boost::random::mt19937_64 generator; +static std::mt19937 generator; // static std::mt19937_64 generator; -boost::mt19937 & getGenerator() // boost::random::mt19937_64 +std::mt19937 & getGenerator() // std::mt19937_64 { return generator; } @@ -40,7 +40,7 @@ boost::mt19937 & getGenerator() // boost::random::mt19937_64 -void seedRandomGenerator( const boost::mt19937::result_type & seed ) +void seedRandomGenerator( const std::mt19937::result_type & seed ) { #ifdef _OPENMP #pragma omp critical (random) diff --git a/src/core/math/Random.h b/src/core/math/Random.h index 77476461533158952bdb8d5c328cd9a07b1f3854..ec61aa51d65b76f3a10c243086d08a48eb166590 100644 --- a/src/core/math/Random.h +++ b/src/core/math/Random.h @@ -24,9 +24,7 @@ #include "core/DataTypes.h" #include "core/debug/Debug.h" -#include <boost/random/mersenne_twister.hpp> -#include <boost/random/uniform_int.hpp> // #include <boost/random/uniform_int_distribution.hpp> -#include <boost/random/uniform_real.hpp> // #include <boost/random/uniform_real_distribution.hpp> +#include <random> #include <limits> @@ -36,12 +34,12 @@ namespace math { namespace internal { -boost::mt19937 & getGenerator(); // boost::random::mt19937_64 +std::mt19937 & getGenerator(); // std::mt19937_64 } -void seedRandomGenerator( const boost::mt19937::result_type & seed ); // boost::random::mt19937_64 +void seedRandomGenerator( const std::mt19937::result_type & seed ); // std::mt19937_64 @@ -51,13 +49,13 @@ void seedRandomGenerator( const boost::mt19937::result_type & seed ); // boost:: */ //********************************************************************************************************************** template< typename INT > -INT intRandom( const INT min = std::numeric_limits<INT>::min(), const INT max = std::numeric_limits<INT>::max(), - boost::mt19937 & generator = internal::getGenerator() ) +INT intRandom( const INT min, const INT max, std::mt19937 & generator ) { static_assert_int_t< INT >(); + static_assert(sizeof(INT) > sizeof(char), "cannot use char"); WALBERLA_ASSERT_LESS_EQUAL( min, max ); - boost::uniform_int< INT > distribution( min, max ); // boost::random::uniform_int_distribution< INT > distribution; + std::uniform_int_distribution< INT > distribution( min, max ); INT value; #ifdef _OPENMP @@ -68,19 +66,89 @@ INT intRandom( const INT min = std::numeric_limits<INT>::min(), const INT max = return value; } +template<> +inline char intRandom<char>( const char min, const char max, std::mt19937 & generator ) +{ + static_assert_int_t< char >(); + WALBERLA_ASSERT_LESS_EQUAL( min, max ); + + std::uniform_int_distribution< int16_t > distribution( min, max ); + + char value; +#ifdef _OPENMP + #pragma omp critical (random) +#endif + { value = static_cast<char>( distribution( generator ) ); } + + return value; +} + +template<> +inline unsigned char intRandom<unsigned char>( const unsigned char min, const unsigned char max, std::mt19937 & generator ) +{ + static_assert_int_t< unsigned char >(); + WALBERLA_ASSERT_LESS_EQUAL( min, max ); + + std::uniform_int_distribution< int16_t > distribution( min, max ); + + unsigned char value; +#ifdef _OPENMP + #pragma omp critical (random) +#endif + { value = static_cast<unsigned char>( distribution( generator ) ); } + + return value; +} + +template<> +inline signed char intRandom<signed char>( const signed char min, const signed char max, std::mt19937 & generator ) +{ + static_assert_int_t< signed char >(); + WALBERLA_ASSERT_LESS_EQUAL( min, max ); + + std::uniform_int_distribution< int16_t > distribution( min, max ); + + signed char value; +#ifdef _OPENMP + #pragma omp critical (random) +#endif + { value = static_cast<signed char>( distribution( generator ) ); } + + return value; +} + + +template< typename INT > +INT intRandom( const INT min ) +{ + return intRandom( min, std::numeric_limits<INT>::max(), internal::getGenerator() ); +} + +template< typename INT > +INT intRandom( const INT min, const INT max ) +{ + return intRandom( min, max, internal::getGenerator() ); +} + +template< typename INT > +INT intRandom() +{ + return intRandom( std::numeric_limits<INT>::min(), std::numeric_limits<INT>::max() ); +} + template< typename INT > class IntRandom { public: - IntRandom( const boost::mt19937::result_type & seed = boost::mt19937::result_type() ) { generator_.seed( seed ); } + IntRandom( const std::mt19937::result_type & seed = std::mt19937::result_type() ) { generator_.seed( seed ); } INT operator()( const INT min = std::numeric_limits<INT>::min(), const INT max = std::numeric_limits<INT>::max() ) { return intRandom( min, max, generator_ ); } private: - boost::mt19937 generator_; + std::mt19937 generator_; }; @@ -91,12 +159,12 @@ private: */ //********************************************************************************************************************** template< typename REAL > -REAL realRandom( const REAL min = REAL(0), const REAL max = REAL(1), boost::mt19937 & generator = internal::getGenerator() ) +REAL realRandom( const REAL min = REAL(0), const REAL max = REAL(1), std::mt19937 & generator = internal::getGenerator() ) { static_assert( std::numeric_limits<REAL>::is_specialized && !std::numeric_limits<REAL>::is_integer, "Floating point type required/expected!" ); WALBERLA_ASSERT_LESS( min, max ); - boost::uniform_real< REAL > distribution( min, max ); // boost::uniform_real_distribution< REAL > distribution( min, max ); + std::uniform_real_distribution< REAL > distribution( min, max ); REAL value; #ifdef _OPENMP @@ -113,13 +181,13 @@ template< typename REAL > class RealRandom { public: - RealRandom( const boost::mt19937::result_type & seed = boost::mt19937::result_type() ) { generator_.seed( seed ); } + RealRandom( const std::mt19937::result_type & seed = std::mt19937::result_type() ) { generator_.seed( seed ); } REAL operator()( const REAL min = REAL(0), const REAL max = REAL(1) ) { return realRandom( min, max, generator_ ); } private: - boost::mt19937 generator_; + std::mt19937 generator_; }; @@ -133,10 +201,10 @@ inline bool boolRandom() { ///< Randomly returns 'true' or 'false' class BoolRandom { public: - BoolRandom( const boost::mt19937::result_type & seed = boost::mt19937::result_type() ) { generator_.seed( seed ); } + BoolRandom( const std::mt19937::result_type & seed = std::mt19937::result_type() ) { generator_.seed( seed ); } bool operator()() { return boolRandom(); } private: - boost::mt19937 generator_; + std::mt19937 generator_; }; diff --git a/src/core/math/Sample.cpp b/src/core/math/Sample.cpp index 6db1ad17abb7600aeec1bcf9fbd6fb792712bcea..eabe897cd81c45ba07445f168e87841eecea99fa 100644 --- a/src/core/math/Sample.cpp +++ b/src/core/math/Sample.cpp @@ -26,7 +26,6 @@ #include <boost/algorithm/string/replace.hpp> #include <boost/lexical_cast.hpp> -#include <boost/math/special_functions/pow.hpp> #include <functional> #include <iterator> @@ -128,7 +127,10 @@ real_t Sample::variance( real_t theMean ) const KahanAccumulator< real_t > acc; for(auto it = begin(); it != end(); ++it) - acc += boost::math::pow<2>(*it - theMean); + { + real_t val = *it - theMean; + acc += val*val; + } return acc.get() / real_c(size()); } diff --git a/src/core/math/Utility.h b/src/core/math/Utility.h index f53d2c47c86d94b38592513bc6083e3eef5e14bb..198cd4c73dd9e311e3f8fa2766d2a827f9eb0dd2 100644 --- a/src/core/math/Utility.h +++ b/src/core/math/Utility.h @@ -26,7 +26,6 @@ #include "core/DataTypes.h" #include <boost/math/constants/constants.hpp> -#include <boost/static_assert.hpp> #include <cmath> #include <cstddef> #include <limits> @@ -100,7 +99,7 @@ inline real_t round( real_t a ); template< typename T > inline const T sign( T a ) { - BOOST_STATIC_ASSERT( std::numeric_limits<T>::is_signed ); + WALBERLA_STATIC_ASSERT( std::numeric_limits<T>::is_signed ); return ( a < T(0) )?( T(-1) ):( T(1) ); } //********************************************************************************************************************** diff --git a/src/core/math/Vector2.h b/src/core/math/Vector2.h index 247f2a026a83e68365ff58be1864b0713b30c59d..1ad6f9cab05d9eda80a0684d736e5921ba26b5d0 100644 --- a/src/core/math/Vector2.h +++ b/src/core/math/Vector2.h @@ -38,7 +38,6 @@ #include "core/mpi/SendBuffer.h" #include <boost/functional/hash.hpp> -#include <boost/static_assert.hpp> #include <boost/type_traits/is_floating_point.hpp> #include <boost/type_traits/is_fundamental.hpp> #include <boost/type_traits/is_same.hpp> diff --git a/src/core/math/Vector3.h b/src/core/math/Vector3.h index 132397d94bdae63e3dc451b4287016b76386006d..239311ca550020f3e79ec43e914d7980202d7af7 100644 --- a/src/core/math/Vector3.h +++ b/src/core/math/Vector3.h @@ -39,7 +39,6 @@ #include "core/debug/CheckFunctions.h" #include <boost/functional/hash.hpp> -#include <boost/static_assert.hpp> #include <boost/type_traits.hpp> #include <boost/type_traits/is_floating_point.hpp> #include <boost/type_traits/is_fundamental.hpp> diff --git a/src/core/math/equation_system/Equation.cpp b/src/core/math/equation_system/Equation.cpp index 6c355b86fdc800e2d1513979fc2be8280a602258..53bef41aa50ae3e29425ab947390380e891cf372 100644 --- a/src/core/math/equation_system/Equation.cpp +++ b/src/core/math/equation_system/Equation.cpp @@ -23,7 +23,8 @@ #include "Operator.h" #include "Variable.h" -#include <boost/math/special_functions/fpclassify.hpp> +#include <cmath> +#include <algorithm> namespace walberla { @@ -128,10 +129,10 @@ namespace math { double left = root_->left_->compute(); double right = root_->right_->compute(); - if ( boost::math::isnan(left) && boost::math::isnan(right) ){ + if ( std::isnan(left) && std::isnan(right) ){ //WALBERLA_LOG_WARNING( "WARNING: Both values are NAN -> return true" ); return true; - } else if ( boost::math::isinf(left) && boost::math::isinf(right) ){ + } else if ( std::isinf(left) && std::isinf(right) ){ //WALBERLA_LOG_WARNING( "WARNING: Both values are INF -> return true" ); return true; } diff --git a/src/core/math/equation_system/EquationSystem.h b/src/core/math/equation_system/EquationSystem.h index 5ba6d2db2f24c0c7c0fe09aae48fe8236d071025..56a15bf8096b58fbd26dc007d7fb6522c4232166 100644 --- a/src/core/math/equation_system/EquationSystem.h +++ b/src/core/math/equation_system/EquationSystem.h @@ -121,7 +121,7 @@ namespace math { }; - typedef boost::shared_ptr< EquationSystem > EquationSystemPtr; + typedef shared_ptr< EquationSystem > EquationSystemPtr; } // namespace math } // namespace walberla diff --git a/src/core/math/equation_system/FwdEquation.h b/src/core/math/equation_system/FwdEquation.h index 587eceb7960558b5d69f4e300c74edbbb363c5a9..37787456b7eb1daa3ab131cb30112bd9804e483e 100644 --- a/src/core/math/equation_system/FwdEquation.h +++ b/src/core/math/equation_system/FwdEquation.h @@ -21,7 +21,7 @@ #pragma once -#include <boost/shared_ptr.hpp> +#include <memory> namespace walberla { @@ -41,13 +41,13 @@ namespace math { }; class Node; - typedef boost::shared_ptr<Node> NodePtr; + typedef std::shared_ptr<Node> NodePtr; ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // EQUATION ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////// class Equation; - typedef boost::shared_ptr< Equation > EquationPtr; + typedef std::shared_ptr< Equation > EquationPtr; } // namespace math } // namespace walberla diff --git a/src/core/math/equation_system/FwdOperator.h b/src/core/math/equation_system/FwdOperator.h index 1b54a2dbeddc74a879d102edd7787626842a4e82..2df1ae9abda4bed416e52223400111758ea4e4fa 100644 --- a/src/core/math/equation_system/FwdOperator.h +++ b/src/core/math/equation_system/FwdOperator.h @@ -21,7 +21,6 @@ #pragma once -#include <boost/shared_ptr.hpp> #include <map> diff --git a/src/core/math/equation_system/FwdVariable.h b/src/core/math/equation_system/FwdVariable.h index cbd8c86f709fa590016071e4cad036558d947af8..76715f973efe5b97d47fe7762abc8747f14e760b 100644 --- a/src/core/math/equation_system/FwdVariable.h +++ b/src/core/math/equation_system/FwdVariable.h @@ -21,7 +21,7 @@ #pragma once -#include <boost/shared_ptr.hpp> +#include <memory> #include <map> #include <string> @@ -33,7 +33,7 @@ namespace math { class Var; - typedef boost::shared_ptr<Var> VarPtr; + typedef std::shared_ptr<Var> VarPtr; typedef std::map<std::string, VarPtr> VarMap; typedef std::map<std::string, VarPtr>::const_iterator VarMapIt; diff --git a/src/core/math/equation_system/Variable.cpp b/src/core/math/equation_system/Variable.cpp index 12295cb9c6e909735b6c8207ec61b4d83ad6f930..04d9b7517c75fc3428aad650d4963dd872f2c92b 100644 --- a/src/core/math/equation_system/Variable.cpp +++ b/src/core/math/equation_system/Variable.cpp @@ -21,7 +21,7 @@ #include "Variable.h" -#include <boost/math/special_functions/fpclassify.hpp> +#include <cmath> #include <sstream> @@ -36,7 +36,7 @@ namespace math { void Var::setValue( const double value ){ value_ = value; - valid_ = !boost::math::isnan( value ); + valid_ = !std::isnan( value ); } bool Var::operator==( const Var& var) const { diff --git a/src/core/mpi/BufferDataTypeExtensions.h b/src/core/mpi/BufferDataTypeExtensions.h index 47d22bacac8bbdd0659dedc8792762289ce1e60a..b05128c4a193aebd46f9f31fec2ed89dc41c30ec 100644 --- a/src/core/mpi/BufferDataTypeExtensions.h +++ b/src/core/mpi/BufferDataTypeExtensions.h @@ -27,10 +27,10 @@ #include "SendBuffer.h" #include "core/Conversion.h" #include "core/DataTypes.h" +#include "core/Optional.h" #include <boost/array.hpp> #include <boost/integer.hpp> -#include <boost/optional.hpp> #include <boost/uuid/uuid.hpp> #include <deque> @@ -465,18 +465,18 @@ struct BufferSizeTrait< std::multimap<K,T,C,A> > { static const bool constantSiz // --------------------------------------------------------------------------------------------------------------------- -// ------------------------------------- Boost optional Support -------------------------------------------------------- +// ------------------------------------------- optional Support -------------------------------------------------------- // --------------------------------------------------------------------------------------------------------------------- template< typename T, // Element type of SendBuffer typename G, // Growth policy of SendBuffer typename OT> // Optional type -GenericSendBuffer<T,G>& operator<<( GenericSendBuffer<T,G> & buf, const boost::optional<OT> & o ) +GenericSendBuffer<T,G>& operator<<( GenericSendBuffer<T,G> & buf, const walberla::optional<OT> & o ) { buf.addDebugMarker( "op" ); bool hasContent = true; - if (o == boost::none) + if (o == walberla::nullopt) hasContent = false; buf << hasContent; @@ -489,7 +489,7 @@ GenericSendBuffer<T,G>& operator<<( GenericSendBuffer<T,G> & buf, const boost::o template< typename T, // Element type of RecvBuffer typename OT> // Optional type -GenericRecvBuffer<T>& operator>>( GenericRecvBuffer<T> & buf, boost::optional<OT> & o ) +GenericRecvBuffer<T>& operator>>( GenericRecvBuffer<T> & buf, walberla::optional<OT> & o ) { buf.readDebugMarker( "op" ); @@ -509,7 +509,7 @@ GenericRecvBuffer<T>& operator>>( GenericRecvBuffer<T> & buf, boost::optional<OT } else { - o = boost::none; + o = walberla::nullopt; } return buf; diff --git a/src/core/mpi/OpenMPBufferSystem.cpp b/src/core/mpi/OpenMPBufferSystem.cpp index afdc66b1af087e43b9195f59d47e571cee161a0d..54471ccf415c82cd2403d0a4db3c122de9ced943 100644 --- a/src/core/mpi/OpenMPBufferSystem.cpp +++ b/src/core/mpi/OpenMPBufferSystem.cpp @@ -47,14 +47,14 @@ OpenMPBufferSystem::OpenMPBufferSystem( const MPI_Comm & communicator, int tag, } -void OpenMPBufferSystem::addReceivingFunction( MPIRank rank, boost::function<void ( RecvBuffer & buf ) > recvFunction ) +void OpenMPBufferSystem::addReceivingFunction( MPIRank rank, std::function<void ( RecvBuffer & buf ) > recvFunction ) { dirty_ = true; recvFunctions_[rank] = recvFunction; } -void OpenMPBufferSystem::addSendingFunction ( MPIRank rank, boost::function<void ( SendBuffer & buf ) > sendFunction ) +void OpenMPBufferSystem::addSendingFunction ( MPIRank rank, std::function<void ( SendBuffer & buf ) > sendFunction ) { dirty_ = true; sendRanks_.push_back( rank ); diff --git a/src/core/mpi/OpenMPBufferSystem.h b/src/core/mpi/OpenMPBufferSystem.h index f38f471608cdf00f36a3c7d062149c14500b7eee..9fd31e2b2146b23fef31a8b1ae768621cadeb738 100644 --- a/src/core/mpi/OpenMPBufferSystem.h +++ b/src/core/mpi/OpenMPBufferSystem.h @@ -23,7 +23,7 @@ #include "BufferSystem.h" -#include <boost/function.hpp> +#include <functional> #include <map> @@ -60,8 +60,8 @@ public: bool isSizeCommunicatedInNextStep() const { return bs_.isSizeCommunicatedInNextStep(); } - void addReceivingFunction( MPIRank rank, boost::function<void ( RecvBuffer & buf ) > recvFunction ); - void addSendingFunction ( MPIRank rank, boost::function<void ( SendBuffer & buf ) > sendFunction ); + void addReceivingFunction( MPIRank rank, std::function<void ( RecvBuffer & buf ) > recvFunction ); + void addSendingFunction ( MPIRank rank, std::function<void ( SendBuffer & buf ) > sendFunction ); void clearReceivingFunctions() { dirty_ = true; recvFunctions_.clear(); } void clearSendingFunctions() { dirty_ = true; sendFunctions_.clear(); sendRanks_.clear(); } @@ -86,11 +86,11 @@ private: bool sizeChangesEverytime_; - std::map<MPIRank, boost::function<void ( RecvBuffer & )> > recvFunctions_; + std::map<MPIRank, std::function<void ( RecvBuffer & )> > recvFunctions_; std::vector<MPIRank> sendRanks_; - std::vector< boost::function<void ( SendBuffer & )> > sendFunctions_; + std::vector< std::function<void ( SendBuffer & )> > sendFunctions_; void startCommunicationOpenMP(); void startCommunicationSerial(); diff --git a/src/core/mpi/RecvBuffer.h b/src/core/mpi/RecvBuffer.h index 5015f9bf52c8373cf70c0eb72286027cd5498971..3caa764b7bfc9a2559d78204cc10bc2e8c33c6fb 100644 --- a/src/core/mpi/RecvBuffer.h +++ b/src/core/mpi/RecvBuffer.h @@ -554,10 +554,10 @@ template< typename T > // Element type template< typename V > // Type of the built-in data value inline void GenericRecvBuffer<T>::peek( V& value ) const { - BOOST_STATIC_ASSERT( boost::is_arithmetic<V>::value ); + WALBERLA_STATIC_ASSERT( boost::is_arithmetic<V>::value ); - BOOST_STATIC_ASSERT( sizeof(V) > sizeof(T) ); - BOOST_STATIC_ASSERT( sizeof(V) % sizeof(T) == 0); + WALBERLA_STATIC_ASSERT( sizeof(V) > sizeof(T) ); + WALBERLA_STATIC_ASSERT( sizeof(V) % sizeof(T) == 0); // Checking the validity of the read operation WALBERLA_ASSERT_LESS_EQUAL( cur_ + BUFFER_DEBUG_OVERHEAD + sizeof(V)/sizeof(T), end_); diff --git a/src/core/singleton/Singleton.h b/src/core/singleton/Singleton.h index bb3e6ba8eb691e84df4a3334a2696f25e67a70ef..441a730c7e8dfae097317fda450101a71d1f1401 100644 --- a/src/core/singleton/Singleton.h +++ b/src/core/singleton/Singleton.h @@ -27,9 +27,7 @@ #include "core/DataTypes.h" #include "core/NonCopyable.h" -#ifdef WALBERLA_BUILD_WITH_BOOST_THREAD -#include <boost/thread/mutex.hpp> -#endif +#include <mutex> /// \cond internal @@ -41,14 +39,11 @@ namespace singleton { #ifdef WALBERLA_CXX_COMPILER_IS_GNU #pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunknown-pragmas" -#pragma GCC diagnostic ignored "-Wpragmas" #pragma GCC diagnostic ignored "-Wunused-local-typedefs" #endif #ifdef WALBERLA_CXX_COMPILER_IS_CLANG #pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wunknown-pragmas" #pragma clang diagnostic ignored "-Wunused-local-typedefs" #endif @@ -495,9 +490,7 @@ public: //@{ static const shared_ptr<T>& instance() { -#ifdef WALBERLA_BUILD_WITH_BOOST_THREAD - boost::mutex::scoped_lock lock( instanceMutex_ ); -#endif + std::lock_guard<std::mutex> lock( instanceMutex_ ); static shared_ptr<T> object( new T() ); isInstantiated_ = true; return object; @@ -520,9 +513,7 @@ private: shared_ptr<D7> dependency7_; //!< Handle to the seventh lifetime dependency. shared_ptr<D8> dependency8_; //!< Handle to the eighth lifetime dependency. -#ifdef WALBERLA_BUILD_WITH_BOOST_THREAD - static boost::mutex instanceMutex_; //!< Synchronization mutex for access to the singleton. -#endif + static std::mutex instanceMutex_; //!< Synchronization mutex for access to the singleton. static bool isInstantiated_; //@} @@ -592,9 +583,7 @@ public: //@{ static const shared_ptr<T>& instance() { -#ifdef WALBERLA_BUILD_WITH_BOOST_THREAD - boost::mutex::scoped_lock lock( instanceMutex_ ); -#endif + std::lock_guard<std::mutex> lock( instanceMutex_ ); static shared_ptr<T> object( new T() ); isInstantiated_ = true; return object; @@ -616,9 +605,7 @@ private: shared_ptr<D6> dependency6_; //!< Handle to the sixth lifetime dependency. shared_ptr<D7> dependency7_; //!< Handle to the seventh lifetime dependency. -#ifdef WALBERLA_BUILD_WITH_BOOST_THREAD - static boost::mutex instanceMutex_; //!< Synchronization mutex for access to the singleton. -#endif + static std::mutex instanceMutex_; //!< Synchronization mutex for access to the singleton. static bool isInstantiated_; //@} @@ -686,9 +673,7 @@ public: //@{ static const shared_ptr<T>& instance() { -#ifdef WALBERLA_BUILD_WITH_BOOST_THREAD - boost::mutex::scoped_lock lock( instanceMutex_ ); -#endif + std::lock_guard<std::mutex> lock( instanceMutex_ ); static shared_ptr<T> object( new T() ); isInstantiated_ = true; return object; @@ -709,9 +694,7 @@ private: shared_ptr<D5> dependency5_; //!< Handle to the fifth lifetime dependency. shared_ptr<D6> dependency6_; //!< Handle to the sixth lifetime dependency. -#ifdef WALBERLA_BUILD_WITH_BOOST_THREAD - static boost::mutex instanceMutex_; //!< Synchronization mutex for access to the singleton. -#endif + static std::mutex instanceMutex_; //!< Synchronization mutex for access to the singleton. static bool isInstantiated_; //@} @@ -776,9 +759,7 @@ public: //@{ static const shared_ptr<T>& instance() { -#ifdef WALBERLA_BUILD_WITH_BOOST_THREAD - boost::mutex::scoped_lock lock( instanceMutex_ ); -#endif + std::lock_guard<std::mutex> lock( instanceMutex_ ); static shared_ptr<T> object( new T() ); isInstantiated_ = true; return object; @@ -798,9 +779,7 @@ private: shared_ptr<D4> dependency4_; //!< Handle to the fourth lifetime dependency. shared_ptr<D5> dependency5_; //!< Handle to the fifth lifetime dependency. -#ifdef WALBERLA_BUILD_WITH_BOOST_THREAD - static boost::mutex instanceMutex_; //!< Synchronization mutex for access to the singleton. -#endif + static std::mutex instanceMutex_; //!< Synchronization mutex for access to the singleton. static bool isInstantiated_; //@} @@ -862,9 +841,7 @@ public: //@{ static const shared_ptr<T>& instance() { -#ifdef WALBERLA_BUILD_WITH_BOOST_THREAD - boost::mutex::scoped_lock lock( instanceMutex_ ); -#endif + std::lock_guard<std::mutex> lock( instanceMutex_ ); static shared_ptr<T> object( new T() ); isInstantiated_ = true; return object; @@ -883,9 +860,7 @@ private: shared_ptr<D3> dependency3_; //!< Handle to the third lifetime dependency. shared_ptr<D4> dependency4_; //!< Handle to the fourth lifetime dependency. -#ifdef WALBERLA_BUILD_WITH_BOOST_THREAD - static boost::mutex instanceMutex_; //!< Synchronization mutex for access to the singleton. -#endif + static std::mutex instanceMutex_; //!< Synchronization mutex for access to the singleton. static bool isInstantiated_; //@} @@ -944,9 +919,7 @@ public: //@{ static const shared_ptr<T>& instance() { -#ifdef WALBERLA_BUILD_WITH_BOOST_THREAD - boost::mutex::scoped_lock lock( instanceMutex_ ); -#endif + std::lock_guard<std::mutex> lock( instanceMutex_ ); static shared_ptr<T> object( new T() ); isInstantiated_ = true; return object; @@ -964,9 +937,7 @@ private: shared_ptr<D2> dependency2_; //!< Handle to the second lifetime dependency. shared_ptr<D3> dependency3_; //!< Handle to the third lifetime dependency. -#ifdef WALBERLA_BUILD_WITH_BOOST_THREAD - static boost::mutex instanceMutex_; //!< Synchronization mutex for access to the singleton. -#endif + static std::mutex instanceMutex_; //!< Synchronization mutex for access to the singleton. static bool isInstantiated_; //@} @@ -1022,9 +993,7 @@ public: //@{ static const shared_ptr<T>& instance() { -#ifdef WALBERLA_BUILD_WITH_BOOST_THREAD - boost::mutex::scoped_lock lock( instanceMutex_ ); -#endif + std::lock_guard<std::mutex> lock( instanceMutex_ ); static shared_ptr<T> object( new T() ); isInstantiated_ = true; return object; @@ -1041,9 +1010,7 @@ private: shared_ptr<D1> dependency1_; //!< Handle to the first lifetime dependency. shared_ptr<D2> dependency2_; //!< Handle to the second lifetime dependency. -#ifdef WALBERLA_BUILD_WITH_BOOST_THREAD - static boost::mutex instanceMutex_; //!< Synchronization mutex for access to the singleton. -#endif + static std::mutex instanceMutex_; //!< Synchronization mutex for access to the singleton. static bool isInstantiated_; //@} @@ -1096,9 +1063,7 @@ public: //@{ static const shared_ptr<T>& instance() { -#ifdef WALBERLA_BUILD_WITH_BOOST_THREAD - boost::mutex::scoped_lock lock( instanceMutex_ ); -#endif + std::lock_guard<std::mutex> lock( instanceMutex_ ); static shared_ptr<T> object( new T() ); isInstantiated_ = true; return object; @@ -1114,9 +1079,7 @@ private: //@{ shared_ptr<D1> dependency1_; //!< Handle to the lifetime dependency. -#ifdef WALBERLA_BUILD_WITH_BOOST_THREAD - static boost::mutex instanceMutex_; //!< Synchronization mutex for access to the singleton. -#endif + static std::mutex instanceMutex_; //!< Synchronization mutex for access to the singleton. static bool isInstantiated_; //@} @@ -1165,9 +1128,7 @@ public: //@{ static const shared_ptr<T>& instance() { -#ifdef WALBERLA_BUILD_WITH_BOOST_THREAD - boost::mutex::scoped_lock lock( instanceMutex_ ); -#endif + std::lock_guard<std::mutex> lock( instanceMutex_ ); static shared_ptr<T> object( new T() ); isInstantiated_ = true; return object; @@ -1181,9 +1142,7 @@ private: //**Member variables**************************************************************************** /*!\name Member variables */ //@{ -#ifdef WALBERLA_BUILD_WITH_BOOST_THREAD - static boost::mutex instanceMutex_; //!< Synchronization mutex for access to the singleton. -#endif + static std::mutex instanceMutex_; //!< Synchronization mutex for access to the singleton. static bool isInstantiated_; //@} @@ -1199,82 +1158,56 @@ private: // //====================================================================================================================== -#ifdef WALBERLA_BUILD_WITH_BOOST_THREAD template< typename T, typename A, typename B, typename C, typename D, typename E, typename F, typename G, typename H > -boost::mutex Singleton<T,A,B,C,D,E,F,G,H>::instanceMutex_; -#endif +std::mutex Singleton<T,A,B,C,D,E,F,G,H>::instanceMutex_; template< typename T, typename A, typename B, typename C, typename D, typename E, typename F, typename G, typename H > bool Singleton<T,A,B,C,D,E,F,G,H>::isInstantiated_ = false; - -#ifdef WALBERLA_BUILD_WITH_BOOST_THREAD template< typename T, typename A, typename B, typename C, typename D, typename E, typename F, typename G > -boost::mutex Singleton<T,A,B,C,D,E,F,G,NullType>::instanceMutex_; -#endif +std::mutex Singleton<T,A,B,C,D,E,F,G,NullType>::instanceMutex_; template< typename T, typename A, typename B, typename C, typename D, typename E, typename F, typename G > bool Singleton<T,A,B,C,D,E,F,G,NullType>::isInstantiated_ = false; - -#ifdef WALBERLA_BUILD_WITH_BOOST_THREAD template< typename T, typename A, typename B, typename C, typename D, typename E, typename F > -boost::mutex Singleton<T,A,B,C,D,E,F,NullType,NullType>::instanceMutex_; -#endif +std::mutex Singleton<T,A,B,C,D,E,F,NullType,NullType>::instanceMutex_; template< typename T, typename A, typename B, typename C, typename D, typename E, typename F > bool Singleton<T,A,B,C,D,E,F,NullType,NullType>::isInstantiated_ = false; - -#ifdef WALBERLA_BUILD_WITH_BOOST_THREAD template< typename T, typename A, typename B, typename C, typename D, typename E > -boost::mutex Singleton<T,A,B,C,D,E,NullType,NullType,NullType>::instanceMutex_; -#endif +std::mutex Singleton<T,A,B,C,D,E,NullType,NullType,NullType>::instanceMutex_; template< typename T, typename A, typename B, typename C, typename D, typename E > bool Singleton<T,A,B,C,D,E,NullType,NullType,NullType>::isInstantiated_ = false; - -#ifdef WALBERLA_BUILD_WITH_BOOST_THREAD template< typename T, typename A, typename B, typename C, typename D > -boost::mutex Singleton<T,A,B,C,D,NullType,NullType,NullType,NullType>::instanceMutex_; -#endif +std::mutex Singleton<T,A,B,C,D,NullType,NullType,NullType,NullType>::instanceMutex_; template< typename T, typename A, typename B, typename C, typename D > bool Singleton<T,A,B,C,D,NullType,NullType,NullType,NullType>::isInstantiated_ = false; - -#ifdef WALBERLA_BUILD_WITH_BOOST_THREAD template< typename T, typename A, typename B, typename C > -boost::mutex Singleton<T,A,B,C,NullType,NullType,NullType,NullType,NullType>::instanceMutex_; -#endif +std::mutex Singleton<T,A,B,C,NullType,NullType,NullType,NullType,NullType>::instanceMutex_; template< typename T, typename A, typename B, typename C > bool Singleton<T,A,B,C,NullType,NullType,NullType,NullType,NullType>::isInstantiated_ = false; - -#ifdef WALBERLA_BUILD_WITH_BOOST_THREAD template< typename T, typename A, typename B > -boost::mutex Singleton<T,A,B,NullType,NullType,NullType,NullType,NullType,NullType>::instanceMutex_; -#endif +std::mutex Singleton<T,A,B,NullType,NullType,NullType,NullType,NullType,NullType>::instanceMutex_; template< typename T, typename A, typename B > bool Singleton<T,A,B,NullType,NullType,NullType,NullType,NullType,NullType>::isInstantiated_ = false; - -#ifdef WALBERLA_BUILD_WITH_BOOST_THREAD template< typename T, typename A > -boost::mutex Singleton<T,A,NullType,NullType,NullType,NullType,NullType,NullType,NullType>::instanceMutex_; -#endif +std::mutex Singleton<T,A,NullType,NullType,NullType,NullType,NullType,NullType,NullType>::instanceMutex_; template< typename T, typename A > bool Singleton<T,A,NullType,NullType,NullType,NullType,NullType,NullType,NullType>::isInstantiated_ = false; - -#ifdef WALBERLA_BUILD_WITH_BOOST_THREAD template< typename T > -boost::mutex Singleton<T,NullType,NullType,NullType,NullType,NullType,NullType,NullType,NullType>::instanceMutex_; -#endif +std::mutex Singleton<T,NullType,NullType,NullType,NullType,NullType,NullType,NullType,NullType>::instanceMutex_; template< typename T > bool Singleton<T,NullType,NullType,NullType,NullType,NullType,NullType,NullType,NullType>::isInstantiated_ = false; diff --git a/src/core/timing/Time.h b/src/core/timing/Time.h index 87a962f0ed6e85dabf2eb8dbb12dd49e16c7e6e6..f6112885951e14185e2bdddd3215bde85c495b67 100644 --- a/src/core/timing/Time.h +++ b/src/core/timing/Time.h @@ -31,7 +31,7 @@ #include <sstream> #include <string> -#include <boost/chrono/chrono.hpp> +#include <chrono> #if defined(_MSC_VER) # ifndef NOMINMAX @@ -75,18 +75,7 @@ inline double getCpuTime(); */ inline double getWcTime() { -#ifdef WIN32 - LARGE_INTEGER perfCounter, perfFrequency; - QueryPerformanceCounter( &perfCounter ); - QueryPerformanceFrequency( &perfFrequency ); - return static_cast<double>(perfCounter.QuadPart) / static_cast<double>(perfFrequency.QuadPart); -#elif defined __bg__ // boost::chrono seems broken on BG/Q - struct timeval tp; - gettimeofday( &tp, NULL ); - return ( static_cast<double>( tp.tv_sec ) + static_cast<double>( tp.tv_usec )/1E6 ); -#else - return static_cast<double>(boost::chrono::duration_cast<boost::chrono::nanoseconds>(boost::chrono::high_resolution_clock::now().time_since_epoch()).count()) * 1e-9; -#endif + return static_cast<double>(std::chrono::duration_cast<std::chrono::nanoseconds>(std::chrono::high_resolution_clock::now().time_since_epoch()).count()) * 1e-9; } //********************************************************************************************************************** diff --git a/src/core/uid/UID.h b/src/core/uid/UID.h index 3f4cb7f975be744d46917625d0a92c6286eba924..7739f7a39fe5139d27f9dd6614111d98d3e2c731 100644 --- a/src/core/uid/UID.h +++ b/src/core/uid/UID.h @@ -34,9 +34,8 @@ #include <sstream> #include <string> -#ifdef WALBERLA_BUILD_WITH_BOOST_THREAD -#include <boost/thread.hpp> -#endif +#include <mutex> +#include <shared_mutex> namespace walberla { @@ -69,8 +68,7 @@ namespace uid { * translates the numerical UID representations into a bit mask. For further information see the documentation of the * two member functions "toIndex()" and "toBitMask()" of this class. * -* If 'WALBERLA_BUILD_WITH_BOOST_THREAD' is defined, the class UID is thread safe and follows -* a multiple-readers / single-writer pattern. +* The class UID is thread safe and follows a multiple-readers / single-writer pattern. */ //********************************************************************************************************************** @@ -129,10 +127,8 @@ private: static std::map< uint_type, std::string >& uidToString() { static std::map< uint_type, std::string > map; return map; } static std::map< std::string, uint_type >& stringToUid() { static std::map< std::string, uint_type > map; return map; } -#ifdef WALBERLA_BUILD_WITH_BOOST_THREAD - static boost::shared_mutex& uidToStringMutex() { static boost::shared_mutex mutex; return mutex; } - static boost::shared_mutex& stringToUidMutex() { static boost::shared_mutex mutex; return mutex; } -#endif + static std::shared_timed_mutex& uidToStringMutex() { static std::shared_timed_mutex mutex; return mutex; } + static std::shared_timed_mutex& stringToUidMutex() { static std::shared_timed_mutex mutex; return mutex; } uint_type uid_; @@ -197,9 +193,7 @@ inline UID<T>::UID( const std::string& identifier, const bool newUid, const bool template< typename T > void UID<T>::init( const std::string& identifier, const bool newUid, const bool appendUIDtoIdentifier ) { -#ifdef WALBERLA_BUILD_WITH_BOOST_THREAD - boost::unique_lock< boost::shared_mutex > stringToUid_lock( stringToUidMutex() ); -#endif + std::unique_lock< std::shared_timed_mutex > stringToUid_lock( stringToUidMutex() ); WALBERLA_ASSERT( !identifier.empty() ); @@ -211,9 +205,7 @@ void UID<T>::init( const std::string& identifier, const bool newUid, const bool WALBERLA_ASSERT( stringToUid().find( idString ) == stringToUid().end() ); // 'idString' must not exist -#ifdef WALBERLA_BUILD_WITH_BOOST_THREAD - boost::unique_lock< boost::shared_mutex > uidToString_lock( uidToStringMutex() ); -#endif + std::unique_lock< std::shared_timed_mutex > uidToString_lock( uidToStringMutex() ); uidToString()[ uid_ ] = idString; stringToUid()[ idString ] = uid_; @@ -226,9 +218,7 @@ void UID<T>::init( const std::string& identifier, const bool newUid, const bool uid_ = T::generateUID(); -#ifdef WALBERLA_BUILD_WITH_BOOST_THREAD - boost::unique_lock< boost::shared_mutex > uidToString_lock( uidToStringMutex() ); -#endif + std::unique_lock< std::shared_timed_mutex > uidToString_lock( uidToStringMutex() ); uidToString()[ uid_ ] = identifier; stringToUid()[ identifier ] = uid_; } @@ -256,10 +246,7 @@ UID<T>::UID( const bool createAnonymousUID ) : uid_( 0 ) { #endif } else { - -#ifdef WALBERLA_BUILD_WITH_BOOST_THREAD - boost::unique_lock< boost::shared_mutex > stringToUid_lock( stringToUidMutex() ); -#endif + std::unique_lock< std::shared_timed_mutex > stringToUid_lock( stringToUidMutex() ); uid_ = T::generateUID(); @@ -267,9 +254,7 @@ UID<T>::UID( const bool createAnonymousUID ) : uid_( 0 ) { WALBERLA_ASSERT( stringToUid().find( identifier ) == stringToUid().end() ); // 'identifier' must not exist -#ifdef WALBERLA_BUILD_WITH_BOOST_THREAD - boost::unique_lock< boost::shared_mutex > uidToString_lock( uidToStringMutex() ); -#endif + std::unique_lock< std::shared_timed_mutex > uidToString_lock( uidToStringMutex() ); uidToString()[ uid_ ] = identifier; stringToUid()[ identifier ] = uid_; @@ -304,10 +289,7 @@ inline UID<T>::UID( const uint_type uid ) : uid_( uid ) //********************************************************************************************************************** template< typename T > UID<T> UID<T>::getOrConstruct( const std::string& identifier ) { - -#ifdef WALBERLA_BUILD_WITH_BOOST_THREAD - boost::unique_lock< boost::shared_mutex > stringToUid_lock( stringToUidMutex() ); -#endif + std::unique_lock< std::shared_timed_mutex > stringToUid_lock( stringToUidMutex() ); WALBERLA_ASSERT( !identifier.empty() ); @@ -317,9 +299,7 @@ UID<T> UID<T>::getOrConstruct( const std::string& identifier ) { uint_type uid = T::generateUID(); -#ifdef WALBERLA_BUILD_WITH_BOOST_THREAD - boost::unique_lock< boost::shared_mutex > uidToString_lock( uidToStringMutex() ); -#endif + std::unique_lock< std::shared_timed_mutex > uidToString_lock( uidToStringMutex() ); uidToString()[ uid ] = identifier; stringToUid()[ identifier ] = uid; @@ -340,10 +320,7 @@ UID<T> UID<T>::getOrConstruct( const std::string& identifier ) { //********************************************************************************************************************** template< typename T > inline UID<T> UID<T>::get( const std::string& identifier ) { - -#ifdef WALBERLA_BUILD_WITH_BOOST_THREAD - boost::shared_lock< boost::shared_mutex > lock( stringToUidMutex() ); -#endif + std::shared_lock< std::shared_timed_mutex > lock( stringToUidMutex() ); WALBERLA_ASSERT( stringToUid().find( identifier ) != stringToUid().end() ); // 'identifier' must exist @@ -354,10 +331,7 @@ inline UID<T> UID<T>::get( const std::string& identifier ) { template< typename T > inline const std::string& UID<T>::getIdentifier() const { - -#ifdef WALBERLA_BUILD_WITH_BOOST_THREAD - boost::shared_lock< boost::shared_mutex > lock( uidToStringMutex() ); -#endif + std::shared_lock< std::shared_timed_mutex > lock( uidToStringMutex() ); WALBERLA_ASSERT( valid_ ); WALBERLA_ASSERT( uidToString().find( uid_ ) != uidToString().end() ); diff --git a/src/core/uid/UIDGenerators.h b/src/core/uid/UIDGenerators.h index 96dc6443eba50168b2acba8adf9b1c613cc03101..d9c254d93986340ed079761a2951119e1d7d29c4 100644 --- a/src/core/uid/UIDGenerators.h +++ b/src/core/uid/UIDGenerators.h @@ -24,8 +24,7 @@ #include "core/debug/Debug.h" -#include <boost/cstdint.hpp> -#include <boost/static_assert.hpp> +#include <cstdint> #include <limits> @@ -106,7 +105,7 @@ public: static const char* getType() { static const char* const type = "index generator"; return type; } - BOOST_STATIC_ASSERT( std::numeric_limits<UINT>::is_specialized && std::numeric_limits<UINT>::is_integer && + WALBERLA_STATIC_ASSERT( std::numeric_limits<UINT>::is_specialized && std::numeric_limits<UINT>::is_integer && !std::numeric_limits<UINT>::is_signed ); }; @@ -142,7 +141,7 @@ public: static const char* getType() { static const char* const type = "standard generator"; return type; } - BOOST_STATIC_ASSERT( std::numeric_limits<UINT>::is_specialized && std::numeric_limits<UINT>::is_integer && + WALBERLA_STATIC_ASSERT( std::numeric_limits<UINT>::is_specialized && std::numeric_limits<UINT>::is_integer && !std::numeric_limits<UINT>::is_signed ); }; @@ -242,7 +241,7 @@ public: static const char* getType() { static const char* const type = "bit generator"; return type; } - BOOST_STATIC_ASSERT( std::numeric_limits<UINT>::is_specialized && std::numeric_limits<UINT>::is_integer && + WALBERLA_STATIC_ASSERT( std::numeric_limits<UINT>::is_specialized && std::numeric_limits<UINT>::is_integer && !std::numeric_limits<UINT>::is_signed ); }; @@ -281,7 +280,7 @@ public: static const char* getType() { static const char* const type = "singleton generator"; return type; } - BOOST_STATIC_ASSERT( std::numeric_limits<UINT>::is_specialized && std::numeric_limits<UINT>::is_integer && + WALBERLA_STATIC_ASSERT( std::numeric_limits<UINT>::is_specialized && std::numeric_limits<UINT>::is_integer && !std::numeric_limits<UINT>::is_signed ); }; diff --git a/src/cuda/FieldCopy.h b/src/cuda/FieldCopy.h index 87af5060d139cefd2ef529ab4c51878bc5f72816..07fd04c808032fccd21c3f00f98600294b124a9b 100644 --- a/src/cuda/FieldCopy.h +++ b/src/cuda/FieldCopy.h @@ -49,7 +49,7 @@ namespace cuda { } template<typename DstType, typename SrcType> - boost::function<void()> fieldCpyFunctor( const shared_ptr< StructuredBlockStorage > & blocks, + std::function<void()> fieldCpyFunctor( const shared_ptr< StructuredBlockStorage > & blocks, BlockDataID dstID, ConstBlockDataID srcID ) { return boost::bind( fieldCpy<DstType,SrcType>, blocks, dstID, srcID ); @@ -66,7 +66,7 @@ namespace cuda { } template<typename DstType, typename SrcType> - boost::function<void(IBlock*)> fieldCpyFunctor( BlockDataID dstID, ConstBlockDataID srcID ) + std::function<void(IBlock*)> fieldCpyFunctor( BlockDataID dstID, ConstBlockDataID srcID ) { return boost::bind( fieldCpySweepFunction<DstType,SrcType>, dstID, srcID, _1 ); } diff --git a/src/cuda/GPUCopy.cpp b/src/cuda/GPUCopy.cpp index 3c1c8f12649ab4f2de483e4b6a3ebf6877790910..834150fdcb921064392fb99d6690752b6eaaee3c 100644 --- a/src/cuda/GPUCopy.cpp +++ b/src/cuda/GPUCopy.cpp @@ -26,6 +26,8 @@ #include "GPUCopy.h" #include "ErrorChecking.h" +#include <cstring> + namespace walberla { namespace cuda { @@ -56,7 +58,7 @@ void copyDevToDevFZYX( const cudaPitchedPtr& dst, const cudaPitchedPtr& src, WALBERLA_ASSERT( fIntervalSize == 1 || ( Nz == dstAllocSizeZ && Nz == srcAllocSizeZ ) ); cudaMemcpy3DParms p; - memset( &p, 0, sizeof(p) ); + std::memset( &p, 0, sizeof(p) ); p.srcPos = make_cudaPos( srcX * typeSize, srcY, srcCoordF * srcAllocSizeZ + srcZ ); p.srcPtr = make_cudaPitchedPtr( src.ptr, src.pitch, src.xsize, src.ysize ); @@ -115,7 +117,7 @@ void copyDevToDevZYXF( const cudaPitchedPtr& dst, const cudaPitchedPtr& src, auto copyFunctor = [&](uint_t dstCoordZ, uint_t srcCoordZ, uint_t zIntervalSize) { cudaMemcpy3DParms p; - memset( &p, 0, sizeof(p) ); + std::memset( &p, 0, sizeof(p) ); p.srcPos = make_cudaPos( srcF * typeSize, srcX, srcCoordZ * srcAllocSizeY + srcY ); p.srcPtr = make_cudaPitchedPtr( src.ptr, src.pitch, src.xsize, src.ysize ); @@ -174,7 +176,7 @@ void copyHostToDevFZYX( const cudaPitchedPtr& dst, unsigned char* src, auto copyFunctor = [&](uint_t dstCoordF, uint_t srcCoordF, uint_t fIntervalSize) { cudaMemcpy3DParms p; - memset( &p, 0, sizeof(p) ); + std::memset( &p, 0, sizeof(p) ); p.srcPos = make_cudaPos( srcX * typeSize, srcY, srcCoordF * srcAllocSizeZ + srcZ ); p.srcPtr = make_cudaPitchedPtr( src, Nx * typeSize, Nx * typeSize, Ny ); @@ -233,7 +235,7 @@ void copyHostToDevZYXF( const cudaPitchedPtr& dst, unsigned char* src, auto copyFunctor = [&](uint_t dstCoordZ, uint_t srcCoordZ, uint_t zIntervalSize) { cudaMemcpy3DParms p; - memset( &p, 0, sizeof(p) ); + std::memset( &p, 0, sizeof(p) ); p.srcPos = make_cudaPos( srcF * typeSize, srcX, srcCoordZ * srcAllocSizeY + srcY ); p.srcPtr = make_cudaPitchedPtr( src, Nf * typeSize, Nf * typeSize, Nx ); @@ -293,7 +295,7 @@ void copyDevToHostFZYX( unsigned char* dst, const cudaPitchedPtr& src, auto copyFunctor = [&](uint_t dstCoordF, uint_t srcCoordF, uint_t fIntervalSize) { cudaMemcpy3DParms p; - memset( &p, 0, sizeof(p) ); + std::memset( &p, 0, sizeof(p) ); p.srcPos = make_cudaPos( srcX * typeSize, srcY, srcCoordF * srcAllocSizeZ + srcZ ); p.srcPtr = make_cudaPitchedPtr( src.ptr, src.pitch, src.xsize, src.ysize ); @@ -353,7 +355,7 @@ void copyDevToHostZYXF( unsigned char* dst, const cudaPitchedPtr& src, auto copyFunctor = [&](uint_t dstCoordZ, uint_t srcCoordZ, uint_t zIntervalSize) { cudaMemcpy3DParms p; - memset( &p, 0, sizeof(p) ); + std::memset( &p, 0, sizeof(p) ); p.srcPos = make_cudaPos( srcF * typeSize, srcX, srcCoordZ * srcAllocSizeY + srcY ); p.srcPtr = make_cudaPitchedPtr( src.ptr, src.pitch, src.xsize, src.ysize ); diff --git a/src/domain_decomposition/BlockDataHandling.h b/src/domain_decomposition/BlockDataHandling.h index c9e74212e1132d8f6f1f1546ba93e4102d23b7cb..4bd96dae090d6c09d5c43498d61343600803312b 100644 --- a/src/domain_decomposition/BlockDataHandling.h +++ b/src/domain_decomposition/BlockDataHandling.h @@ -82,7 +82,7 @@ class BlockDataHandlingFunctionAdaptor : public BlockDataHandling<T> { public: - typedef boost::function< T* ( IBlock * const block ) > Function; + typedef std::function< T* ( IBlock * const block ) > Function; BlockDataHandlingFunctionAdaptor( const Function & function ) : function_( function ) {} @@ -130,7 +130,7 @@ struct BlockDataCreator requiredSelectors_( requiredSelectors ), incompatibleSelectors_( incompatibleSelectors ) {} - BlockDataCreator( const boost::function< T* ( IBlock * const block ) > & function, + BlockDataCreator( const std::function< T* ( IBlock * const block ) > & function, const std::string & identifier = std::string(), const Set<SUID> & requiredSelectors = Set<SUID>::emptySet(), const Set<SUID> & incompatibleSelectors = Set<SUID>::emptySet() ) : diff --git a/src/domain_decomposition/BlockStorage.h b/src/domain_decomposition/BlockStorage.h index 4d3292e21e0d6a8e7f87ae2c42c3271ade5fed79..fb778309aae9853272eef2c8402d3d553d6a2e7a 100644 --- a/src/domain_decomposition/BlockStorage.h +++ b/src/domain_decomposition/BlockStorage.h @@ -34,7 +34,7 @@ #include "core/uid/GlobalState.h" #include "core/uid/SUID.h" -#include <boost/function.hpp> +#include <functional> //#include <boost/type_traits/is_base_of.hpp> #include <string> #include <vector> @@ -472,7 +472,7 @@ public: const Set<SUID> & incompatibleSelectors = Set<SUID>::emptySet() ); template< typename T > - inline BlockDataID addBlockData( boost::function< T* ( IBlock* const block ) > function, + inline BlockDataID addBlockData( std::function< T* ( IBlock* const block ) > function, const std::string & identifier = std::string(), const Set<SUID> & requiredSelectors = Set<SUID>::emptySet(), const Set<SUID> & incompatibleSelectors = Set<SUID>::emptySet() ); @@ -676,7 +676,7 @@ inline BlockDataID BlockStorage::addBlockData( const shared_ptr< T > & dataHandl */ //********************************************************************************************************************** template< typename T > -inline BlockDataID BlockStorage::addBlockData( boost::function< T* ( IBlock* const block ) > function, const std::string & identifier, +inline BlockDataID BlockStorage::addBlockData( std::function< T* ( IBlock* const block ) > function, const std::string & identifier, const Set<SUID> & requiredSelectors, const Set<SUID> & incompatibleSelectors ) { internal::SelectableBlockDataHandlingWrapper dataHandling( diff --git a/src/domain_decomposition/IBlock.h b/src/domain_decomposition/IBlock.h index e9b4ec6fb0dcf070e469cee35b52a223423ca627..215f8a51d27d714b41192ecaec0d273e721f560d 100644 --- a/src/domain_decomposition/IBlock.h +++ b/src/domain_decomposition/IBlock.h @@ -30,7 +30,6 @@ #include "core/math/AABB.h" #include "core/uid/SUID.h" -#include <boost/cast.hpp> #include <typeinfo> #include <vector> diff --git a/src/domain_decomposition/MakeBlockDataInitFunction.h b/src/domain_decomposition/MakeBlockDataInitFunction.h index 2f82ea473cba060f1994e3df0520e6496cc08b3f..466f944c110341acdde00a786e45fa39d3764e05 100644 --- a/src/domain_decomposition/MakeBlockDataInitFunction.h +++ b/src/domain_decomposition/MakeBlockDataInitFunction.h @@ -24,7 +24,7 @@ #include "IBlock.h" #include <boost/bind.hpp> -#include <boost/function.hpp> +#include <functional> namespace walberla { @@ -91,61 +91,61 @@ namespace internal template<class T> -boost::function< T* ( const IBlock* const block ) > +std::function< T* ( const IBlock* const block ) > makeBlockDataInitFunction() { return boost::bind( internal::newFunc<T>, _1); } template<class T, class P1> -boost::function< T* ( const IBlock* const block ) > +std::function< T* ( const IBlock* const block ) > makeBlockDataInitFunction(const P1 & p1) { return boost::bind( internal::newFunc<T,P1>, _1,p1); } template<class T, class P1, class P2> -boost::function< T* ( const IBlock* const block ) > +std::function< T* ( const IBlock* const block ) > makeBlockDataInitFunction(const P1 & p1, const P2 & p2) { return boost::bind( internal::newFunc<T,P1,P2>, _1,p1,p2); } template<class T, class P1, class P2, class P3> -boost::function< T* ( const IBlock* const block ) > +std::function< T* ( const IBlock* const block ) > makeBlockDataInitFunction(const P1 & p1, const P2 & p2, const P3 & p3) { return boost::bind( internal::newFunc<T,P1,P2,P3>, _1,p1,p2,p3); } template<class T, class P1, class P2, class P3, class P4> -boost::function< T* ( const IBlock* const block ) > +std::function< T* ( const IBlock* const block ) > makeBlockDataInitFunction(const P1 & p1, const P2 & p2, const P3 & p3, const P4 & p4) { return boost::bind( internal::newFunc<T,P1,P2,P3,P4>, _1,p1,p2,p3,p4); } template<class T, class P1, class P2, class P3, class P4, class P5> -boost::function< T* ( const IBlock* const block ) > +std::function< T* ( const IBlock* const block ) > makeBlockDataInitFunction(const P1 & p1, const P2 & p2, const P3 & p3, const P4 & p4, const P5 & p5) { return boost::bind( internal::newFunc<T,P1,P2,P3,P4,P5>, _1,p1,p2,p3,p4,p5); } template<class T, class P1, class P2, class P3, class P4, class P5, class P6> -boost::function< T* ( const IBlock* const block ) > +std::function< T* ( const IBlock* const block ) > makeBlockDataInitFunction(const P1 & p1, const P2 & p2, const P3 & p3, const P4 & p4, const P5 & p5, const P6 & p6) { return boost::bind( internal::newFunc<T,P1,P2,P3,P4,P5,P6>, _1,p1,p2,p3,p4,p5,p6); } template<class T, class P1, class P2, class P3, class P4, class P5, class P6, class P7> -boost::function< T* ( const IBlock* const block ) > +std::function< T* ( const IBlock* const block ) > makeBlockDataInitFunction(const P1 & p1, const P2 & p2, const P3 & p3, const P4 & p4, const P5 & p5, const P6 & p6, const P7 & p7) { return boost::bind( internal::newFunc<T,P1,P2,P3,P4,P5,P6,P7>, _1,p1,p2,p3,p4,p5,p6,p7); } template<class T, class P1, class P2, class P3, class P4, class P5, class P6, class P7, class P8> -boost::function< T* ( const IBlock* const block ) > +std::function< T* ( const IBlock* const block ) > makeBlockDataInitFunction(const P1 & p1, const P2 & p2, const P3 & p3, const P4 & p4, const P5 & p5, const P6 & p6, const P7 & p7, const P8 & p8) { return boost::bind( internal::newFunc<T,P1,P2,P3,P4,P5,P6,P7,P8>, _1,p1,p2,p3,p4,p5,p6,p7,p8); } template<class T, class P1, class P2, class P3, class P4, class P5, class P6, class P7, class P8, class P9> -boost::function< T* ( const IBlock* const block ) > +std::function< T* ( const IBlock* const block ) > makeBlockDataInitFunction(const P1 & p1, const P2 & p2, const P3 & p3, const P4 & p4, const P5 & p5, const P6 & p6, const P7 & p7, const P8 & p8, const P9 & p9) { return boost::bind( internal::newFunc<T,P1,P2,P3,P4,P5,P6,P7,P8,P9>, _1,p1,p2,p3,p4,p5,p6,p7,p8,p9); } diff --git a/src/domain_decomposition/StructuredBlockStorage.h b/src/domain_decomposition/StructuredBlockStorage.h index 8fbd4fb04abfcd0c1aba0dea8229abafea802635..4315429d285f3189e82d367f75d0a2f48bd895c8 100644 --- a/src/domain_decomposition/StructuredBlockStorage.h +++ b/src/domain_decomposition/StructuredBlockStorage.h @@ -43,14 +43,14 @@ template< typename T > struct StructuredBlockDataCreator { StructuredBlockDataCreator( - const boost::function< T * ( IBlock * const block, StructuredBlockStorage * const storage ) > & function, + const std::function< T * ( IBlock * const block, StructuredBlockStorage * const storage ) > & function, const std::string & identifier = std::string(), const Set<SUID> & requiredSelectors = Set<SUID>::emptySet(), const Set<SUID> & incompatibleSelectors = Set<SUID>::emptySet() ) : function_( function ), identifier_( identifier ), requiredSelectors_( requiredSelectors ), incompatibleSelectors_( incompatibleSelectors ) {} - boost::function< T * ( IBlock * const block, StructuredBlockStorage * const storage ) > function_; + std::function< T * ( IBlock * const block, StructuredBlockStorage * const storage ) > function_; std::string identifier_; Set<SUID> requiredSelectors_; @@ -243,7 +243,7 @@ public: { return blockStorage_->addBlockData( dataHandling, identifier, requiredSelectors, incompatibleSelectors ); } template< typename T > - inline BlockDataID addBlockData( boost::function< T* ( IBlock* const block ) > function, + inline BlockDataID addBlockData( std::function< T* ( IBlock* const block ) > function, const std::string& identifier = std::string(), const Set<SUID>& requiredSelectors = Set<SUID>::emptySet(), const Set<SUID>& incompatibleSelectors = Set<SUID>::emptySet() ) @@ -413,7 +413,7 @@ public: { return StructuredBlockDataAdder( *this, identifier ); } template< typename T > - inline BlockDataID addStructuredBlockData( boost::function< T* ( IBlock* const block, StructuredBlockStorage* const storage ) > function, + inline BlockDataID addStructuredBlockData( std::function< T* ( IBlock* const block, StructuredBlockStorage* const storage ) > function, const std::string& identifier = std::string(), const Set<SUID>& requiredSelectors = Set<SUID>::emptySet(), const Set<SUID>& incompatibleSelectors = Set<SUID>::emptySet() ); @@ -1072,7 +1072,7 @@ inline void StructuredBlockStorage::transformBlockLocalToGlobalCellInterval( Cel //********************************************************************************************************************** template< typename T > inline BlockDataID StructuredBlockStorage::addStructuredBlockData( - boost::function< T* ( IBlock* const block, StructuredBlockStorage* const storage ) > function, + std::function< T* ( IBlock* const block, StructuredBlockStorage* const storage ) > function, const std::string& identifier, const Set<SUID>& requiredSelectors, const Set<SUID>& incompatibleSelectors ) { internal::SelectableBlockDataHandlingWrapper dataHandling( diff --git a/src/fft/Fft.cpp b/src/fft/Fft.cpp index f54423ee7044b8f6b668c31bee2e7816646719fd..bbae269ea245a124fe5ca0b8208d5bd408db6bb4 100644 --- a/src/fft/Fft.cpp +++ b/src/fft/Fft.cpp @@ -7,7 +7,7 @@ namespace fft { template <typename Field_T> FourierTransform<Field_T>::FourierTransform( shared_ptr< StructuredBlockForest > & blocks, BlockDataID fieldId, - boost::function<real_t(uint_t,uint_t,uint_t)> greens ) + std::function<real_t(uint_t,uint_t,uint_t)> greens ) : blocks_(blocks), fieldId_(fieldId), greens_() { #ifdef WALBERLA_USE_PFFT diff --git a/src/fft/Fft.h b/src/fft/Fft.h index 0f4c29f469d95e6a464af99b9925caa0194bb861..481c96bb86843ef632034bd4e301dfb6596a9d92 100644 --- a/src/fft/Fft.h +++ b/src/fft/Fft.h @@ -22,7 +22,7 @@ class FourierTransform { public: FourierTransform( shared_ptr< StructuredBlockForest > & blocks, BlockDataID fieldId, - boost::function<real_t(uint_t,uint_t,uint_t)> greens = boost::function<real_t(uint_t,uint_t,uint_t)>() ); + std::function<real_t(uint_t,uint_t,uint_t)> greens = std::function<real_t(uint_t,uint_t,uint_t)>() ); void operator() (); private: diff --git a/src/field/AccuracyEvaluation.h b/src/field/AccuracyEvaluation.h index a043dc0958f1664ff4cc35bab891152107dadd7f..4f6e40176bd85bf9db91aba8318ac6311f37bdf7 100644 --- a/src/field/AccuracyEvaluation.h +++ b/src/field/AccuracyEvaluation.h @@ -133,7 +133,7 @@ inline real_t accuracyEvaluationAbsError( const Vector3<real_t> & error ) { retu //********************************************************************************************************************** template< typename Field_T, - typename SolutionFunction_T = boost::function< typename Field_T::value_type ( const Vector3< real_t > & ) >, + typename SolutionFunction_T = std::function< typename Field_T::value_type ( const Vector3< real_t > & ) >, typename Filter_T = DefaultEvaluationFilter > class AccuracyEvaluation { diff --git a/src/field/AccuracyEvaluationLinePlot.h b/src/field/AccuracyEvaluationLinePlot.h index 217a2c55a4e77044913ba85b2889d97593fb4f32..d2c1fcbe66019004261c61fa9d9ffc06d33376ea 100644 --- a/src/field/AccuracyEvaluationLinePlot.h +++ b/src/field/AccuracyEvaluationLinePlot.h @@ -191,7 +191,7 @@ inline void accuracyEvaluationLinePlotIO( std::ofstream & file, const std::vecto //********************************************************************************************************************** template< typename Field_T, - typename SolutionFunction_T = boost::function< typename Field_T::value_type ( const Vector3< real_t > & ) >, + typename SolutionFunction_T = std::function< typename Field_T::value_type ( const Vector3< real_t > & ) >, typename Filter_T = DefaultEvaluationFilter > class AccuracyEvaluationLinePlot { diff --git a/src/field/AddToStorage.h b/src/field/AddToStorage.h index 5136dab5ab7a4261ff381ad2eb660f77fd91f0c8..7895d3b555663386540c135f755af734eca76435 100644 --- a/src/field/AddToStorage.h +++ b/src/field/AddToStorage.h @@ -64,8 +64,8 @@ BlockDataID addFlagFieldToStorage( const shared_ptr< BlockStorage_T > & blocks, const std::string & identifier, const uint_t nrOfGhostLayers = uint_t(1), const bool alwaysInitialize = false, - const boost::function< void ( FlagField_T * field, IBlock * const block ) > & initFunction = - boost::function< void ( FlagField_T * field, IBlock * const block ) >(), + const std::function< void ( FlagField_T * field, IBlock * const block ) > & initFunction = + std::function< void ( FlagField_T * field, IBlock * const block ) >(), const Set<SUID> & requiredSelectors = Set<SUID>::emptySet(), const Set<SUID> & incompatibleSelectors = Set<SUID>::emptySet() ) { @@ -91,7 +91,7 @@ BlockDataID addFlagFieldToStorage( const shared_ptr< BlockStorage_T > & blocks, const Set<SUID> & requiredSelectors, const Set<SUID> & incompatibleSelectors = Set<SUID>::emptySet() ) { return addFlagFieldToStorage< FlagField_T >( blocks, identifier, nrOfGhostLayers, alwaysInitialize, - boost::function< void ( FlagField_T * field, IBlock * const block ) >(), + std::function< void ( FlagField_T * field, IBlock * const block ) >(), requiredSelectors, incompatibleSelectors ); } @@ -108,9 +108,9 @@ struct AddToStorage { static BlockDataID add( const shared_ptr< BlockStorage_T > & blocks, const std::string & identifier, const typename GhostLayerField_T::value_type & initValue, const Layout layout, const uint_t nrOfGhostLayers, - const bool /*alwaysInitialize*/, const boost::function< void ( GhostLayerField_T * field, IBlock * const block ) > & initFunction, + const bool /*alwaysInitialize*/, const std::function< void ( GhostLayerField_T * field, IBlock * const block ) > & initFunction, const Set<SUID> & requiredSelectors, const Set<SUID> & incompatibleSelectors, - const boost::function< Vector3< uint_t > ( const shared_ptr< StructuredBlockStorage > &, IBlock * const ) > calculateSize = defaultSize ) + const std::function< Vector3< uint_t > ( const shared_ptr< StructuredBlockStorage > &, IBlock * const ) > calculateSize = defaultSize ) { auto dataHandling = walberla::make_shared< field::AlwaysInitializeBlockDataHandling< GhostLayerField_T > >( blocks, nrOfGhostLayers, initValue, layout, calculateSize ); dataHandling->addInitializationFunction( initFunction ); @@ -125,9 +125,9 @@ struct AddToStorage< GhostLayerField_T, BlockStorage_T, { static BlockDataID add( const shared_ptr< BlockStorage_T > & blocks, const std::string & identifier, const typename GhostLayerField_T::value_type & initValue, const Layout layout, const uint_t nrOfGhostLayers, - const bool alwaysInitialize, const boost::function< void ( GhostLayerField_T * field, IBlock * const block ) > & initFunction, + const bool alwaysInitialize, const std::function< void ( GhostLayerField_T * field, IBlock * const block ) > & initFunction, const Set<SUID> & requiredSelectors, const Set<SUID> & incompatibleSelectors, - const boost::function< Vector3< uint_t > ( const shared_ptr< StructuredBlockStorage > &, IBlock * const ) > calculateSize = defaultSize ) + const std::function< Vector3< uint_t > ( const shared_ptr< StructuredBlockStorage > &, IBlock * const ) > calculateSize = defaultSize ) { if( alwaysInitialize ) { @@ -153,8 +153,8 @@ BlockDataID addToStorage( const shared_ptr< BlockStorage_T > & blocks, const Layout layout = zyxf, const uint_t nrOfGhostLayers = uint_t(1), const bool alwaysInitialize = false, - const boost::function< void ( GhostLayerField_T * field, IBlock * const block ) > & initFunction = - boost::function< void ( GhostLayerField_T * field, IBlock * const block ) >(), + const std::function< void ( GhostLayerField_T * field, IBlock * const block ) > & initFunction = + std::function< void ( GhostLayerField_T * field, IBlock * const block ) >(), const Set<SUID> & requiredSelectors = Set<SUID>::emptySet(), const Set<SUID> & incompatibleSelectors = Set<SUID>::emptySet() ) { @@ -174,7 +174,7 @@ BlockDataID addToStorage( const shared_ptr< BlockStorage_T > & blocks, const Set<SUID> & requiredSelectors, const Set<SUID> & incompatibleSelectors = Set<SUID>::emptySet() ) { return addToStorage< GhostLayerField_T >( blocks, identifier, initValue, layout, nrOfGhostLayers, alwaysInitialize, - boost::function< void ( GhostLayerField_T * field, IBlock * const block ) >(), + std::function< void ( GhostLayerField_T * field, IBlock * const block ) >(), requiredSelectors, incompatibleSelectors ); } @@ -183,13 +183,13 @@ BlockDataID addToStorage( const shared_ptr< BlockStorage_T > & blocks, template< typename GhostLayerField_T, typename BlockStorage_T > BlockDataID addToStorage( const shared_ptr< BlockStorage_T > & blocks, const std::string & identifier, - const boost::function< Vector3< uint_t > ( const shared_ptr< StructuredBlockStorage > &, IBlock * const ) > calculateSize, + const std::function< Vector3< uint_t > ( const shared_ptr< StructuredBlockStorage > &, IBlock * const ) > calculateSize, const typename GhostLayerField_T::value_type & initValue = typename GhostLayerField_T::value_type(), const Layout layout = zyxf, const uint_t nrOfGhostLayers = uint_t(1), const bool alwaysInitialize = false, - const boost::function< void ( GhostLayerField_T * field, IBlock * const block ) > & initFunction = - boost::function< void ( GhostLayerField_T * field, IBlock * const block ) >(), + const std::function< void ( GhostLayerField_T * field, IBlock * const block ) > & initFunction = + std::function< void ( GhostLayerField_T * field, IBlock * const block ) >(), const Set<SUID> & requiredSelectors = Set<SUID>::emptySet(), const Set<SUID> & incompatibleSelectors = Set<SUID>::emptySet() ) { @@ -203,7 +203,7 @@ BlockDataID addToStorage( const shared_ptr< BlockStorage_T > & blocks, template< typename GhostLayerField_T, typename BlockStorage_T > BlockDataID addToStorage( const shared_ptr< BlockStorage_T > & blocks, const std::string & identifier, - const boost::function< Vector3< uint_t > ( const shared_ptr< StructuredBlockStorage > &, IBlock * const ) > calculateSize, + const std::function< Vector3< uint_t > ( const shared_ptr< StructuredBlockStorage > &, IBlock * const ) > calculateSize, const typename GhostLayerField_T::value_type & initValue, const Layout layout, const uint_t nrOfGhostLayers, @@ -211,7 +211,7 @@ BlockDataID addToStorage( const shared_ptr< BlockStorage_T > & blocks, const Set<SUID> & requiredSelectors, const Set<SUID> & incompatibleSelectors = Set<SUID>::emptySet() ) { return addToStorage< GhostLayerField_T >( blocks, identifier, initValue, layout, nrOfGhostLayers, alwaysInitialize, - boost::function< void ( GhostLayerField_T * field, IBlock * const block ) >(), + std::function< void ( GhostLayerField_T * field, IBlock * const block ) >(), requiredSelectors, incompatibleSelectors, calculateSize ); } @@ -274,8 +274,8 @@ struct Creator : public domain_decomposition::BlockDataCreator< GhostLayerField_ const Layout layout = zyxf, const uint_t nrOfGhostLayers = uint_t(1), const bool /*alwaysInitialize*/ = false, - const boost::function< void ( GhostLayerField_T * field, IBlock * const block ) > & initFunction = - boost::function< void ( GhostLayerField_T * field, IBlock * const block ) >() ) : + const std::function< void ( GhostLayerField_T * field, IBlock * const block ) > & initFunction = + std::function< void ( GhostLayerField_T * field, IBlock * const block ) >() ) : domain_decomposition::BlockDataCreator< GhostLayerField_T >( shared_ptr< field::DefaultBlockDataHandling< GhostLayerField_T > >(), identifier, requiredSelectors, incompatibleSelectors ) { @@ -313,8 +313,8 @@ struct Creator< GhostLayerField_T, const Layout layout = zyxf, const uint_t nrOfGhostLayers = uint_t(1), const bool alwaysInitialize = false, - const boost::function< void ( GhostLayerField_T * field, IBlock * const block ) > & initFunction = - boost::function< void ( GhostLayerField_T * field, IBlock * const block ) >() ) : + const std::function< void ( GhostLayerField_T * field, IBlock * const block ) > & initFunction = + std::function< void ( GhostLayerField_T * field, IBlock * const block ) >() ) : domain_decomposition::BlockDataCreator< GhostLayerField_T >( shared_ptr< field::DefaultBlockDataHandling< GhostLayerField_T > >(), identifier, requiredSelectors, incompatibleSelectors ) { @@ -358,8 +358,8 @@ struct Creator< FlagField<T> > : public domain_decomposition::BlockDataCreator< const Set<SUID> & incompatibleSelectors, const uint_t nrOfGhostLayers = uint_t(1), const bool alwaysInitialize = false, - const boost::function< void ( FlagField<T> * field, IBlock * const block ) > & initFunction = - boost::function< void ( FlagField<T> * field, IBlock * const block ) >() ) : + const std::function< void ( FlagField<T> * field, IBlock * const block ) > & initFunction = + std::function< void ( FlagField<T> * field, IBlock * const block ) >() ) : domain_decomposition::BlockDataCreator< FlagField<T> >( shared_ptr< field::DefaultBlockDataHandling< FlagField<T> > >(), identifier, requiredSelectors, incompatibleSelectors ) { diff --git a/src/field/Field.h b/src/field/Field.h index b6e517ec3d1f774c2c372757a2423ced83e84ec5..913655771e2eec0c8937b3e96ce3511093ec3f34 100644 --- a/src/field/Field.h +++ b/src/field/Field.h @@ -36,8 +36,7 @@ #include "iterators/FieldIterator.h" #include "iterators/FieldPointer.h" -#include <boost/function.hpp> -#include <boost/static_assert.hpp> +#include <functional> #include <memory> #include <vector> @@ -278,7 +277,7 @@ namespace field { //** Monitoring ************************************************************************************************* /*! \name Monitoring */ //@{ - typedef boost::function< void ( cell_idx_t x, cell_idx_t y, + typedef std::function< void ( cell_idx_t x, cell_idx_t y, cell_idx_t z, cell_idx_t f, const T & value) > MonitorFunction; void addMonitoringFunction( const MonitorFunction & func ); diff --git a/src/field/FlagField.h b/src/field/FlagField.h index 4472323ae4e149c11bf3537a603f7b3a35804817..2785dd199fac3964a2ae835c3bf7c15299ff213a 100644 --- a/src/field/FlagField.h +++ b/src/field/FlagField.h @@ -32,7 +32,6 @@ #include "core/math/Uint.h" #include <boost/array.hpp> -#include <boost/static_assert.hpp> #include <boost/type_traits/is_same.hpp> #include <iostream> diff --git a/src/field/VolumetricFlowRateEvaluation.h b/src/field/VolumetricFlowRateEvaluation.h index 26bf6ec8134993a24d14ef16a97b0af2b603c9f3..1763ea0eb78585bb8588cb581869d027488f5680 100644 --- a/src/field/VolumetricFlowRateEvaluation.h +++ b/src/field/VolumetricFlowRateEvaluation.h @@ -47,8 +47,8 @@ namespace field { namespace internal { -typedef boost::function< real_t () > FlowRateSolution_T; -typedef boost::function< Vector3< real_t > ( const Vector3< real_t > & ) > FlowRateVelocitySolution_T; +typedef std::function< real_t () > FlowRateSolution_T; +typedef std::function< Vector3< real_t > ( const Vector3< real_t > & ) > FlowRateVelocitySolution_T; const std::string volumetricFlowRateEvaluationFilename("flowrate.dat"); const real_t volumetricFlowRateEvaluationNormalization( real_t(1) ); @@ -205,7 +205,7 @@ public: real_t solution() const { - if( solution_.empty() ) + if( !solution_ ) return real_t(0); auto blocks = blocks_.lock(); @@ -305,7 +305,7 @@ void VolumetricFlowRateEvaluation< VelocityField_T, Filter_T >::operator()() if( axis_[0] ) { const auto factor = normalizationFactor_ * normalizedDy * normalizedDz; - if( velocitySolution_.empty() ) + if( !velocitySolution_ ) { WALBERLA_FOR_ALL_CELLS_XYZ_OMP( field, omp parallel for schedule(static) reduction(+:_flowRate), @@ -338,7 +338,7 @@ void VolumetricFlowRateEvaluation< VelocityField_T, Filter_T >::operator()() else if( axis_[1] ) { const auto factor = normalizationFactor_ * normalizedDx * normalizedDz; - if( velocitySolution_.empty() ) + if( !velocitySolution_ ) { WALBERLA_FOR_ALL_CELLS_XYZ_OMP( field, omp parallel for schedule(static) reduction(+:_flowRate), @@ -371,7 +371,7 @@ void VolumetricFlowRateEvaluation< VelocityField_T, Filter_T >::operator()() else { const auto factor = normalizationFactor_ * normalizedDx * normalizedDy; - if( velocitySolution_.empty() ) + if( !velocitySolution_ ) { WALBERLA_FOR_ALL_CELLS_XYZ_OMP( field, omp parallel for schedule(static) reduction(+:_flowRate), @@ -420,16 +420,16 @@ void VolumetricFlowRateEvaluation< VelocityField_T, Filter_T >::operator()() file << "# volumetric flow rate evaluation of data '" << id << "'\n" << "# step [1], flow rate (simulation) [2], flow rate (\"discrete\" solution) [3], flow rate (exact solution) [4]" ", rel. error (base = \"discrete\" solution) [5], rel. error (base = exact solution) [6]" << std::endl; - if( velocitySolution_.empty() ) + if( !velocitySolution_ ) file << "ATTENTION: \"discrete\" solution values not available and thus not valid!" << std::endl; - if( solution_.empty() ) + if( !solution_ ) file << "ATTENTION: exact solution values not available and thus not valid!" << std::endl; file.close(); } if( log ) { - if( !velocitySolution_.empty() && !solution_.empty() ) + if( velocitySolution_ && solution_ ) { WALBERLA_LOG_INFO( "Evaluation of the volumetric flow rate [data = '" << id << "']:" << "\n- exact solution: " << _solution << @@ -439,18 +439,18 @@ void VolumetricFlowRateEvaluation< VelocityField_T, Filter_T >::operator()() "\n + " << ( std::abs( ( flowRate_ - velocitySolutionFlowRate_ ) / velocitySolutionFlowRate_ ) ) << " (base = \"discrete\" solution)" << "\n + " << ( std::abs( ( flowRate_ - _solution ) / _solution ) ) << " (base = exact solution)" ); } - else if( !velocitySolution_.empty() ) + else if( velocitySolution_ ) { - WALBERLA_ASSERT( solution_.empty() ); + WALBERLA_ASSERT( !solution_ ); WALBERLA_LOG_INFO( "Evaluation of the volumetric flow rate [data = '" << id << "']:" << "\n- \"discrete\" solution: " << velocitySolutionFlowRate_ << " (using reference velocities evaluated at cell centers)" << "\n- simulation: " << flowRate_ << " (using computed velocities evaluated at cell centers)" << "\n- rel. error (of the simulation): " << ( std::abs( flowRate_ - velocitySolutionFlowRate_ ) / velocitySolutionFlowRate_ ) ); } - else if( !solution_.empty() ) + else if( solution_ ) { - WALBERLA_ASSERT( velocitySolution_.empty() ); + WALBERLA_ASSERT( !velocitySolution_ ); WALBERLA_LOG_INFO( "Evaluation of the volumetric flow rate [data = '" << id << "']:" << "\n- exact solution: " << _solution << "\n- simulation: " << flowRate_ << @@ -459,7 +459,7 @@ void VolumetricFlowRateEvaluation< VelocityField_T, Filter_T >::operator()() } else { - WALBERLA_ASSERT( solution_.empty() && velocitySolution_.empty() ); + WALBERLA_ASSERT( !solution_ && !velocitySolution_ ); WALBERLA_LOG_INFO( "Evaluation of the volumetric flow rate [data = '" << id << "']: " << flowRate_ ); } } @@ -467,7 +467,7 @@ void VolumetricFlowRateEvaluation< VelocityField_T, Filter_T >::operator()() if( plot ) { std::ofstream file( filename_.c_str(), std::ofstream::out | std::ofstream::app ); - file << ( executionCounter_ - uint_t(1) ) << " " << flowRate_ << " " << velocitySolutionFlowRate_ << " " << solution_ << " " + file << ( executionCounter_ - uint_t(1) ) << " " << flowRate_ << " " << velocitySolutionFlowRate_ << " " << _solution << " " << ( isIdentical( velocitySolutionFlowRate_, real_t(0) ) ? real_t(0) : std::abs( ( flowRate_ - velocitySolutionFlowRate_ ) / velocitySolutionFlowRate_ ) ) << " " << ( isIdentical( _solution, real_t(0) ) ? real_t(0) : std::abs( ( flowRate_ - _solution ) / _solution ) ) << std::endl; file.close(); diff --git a/src/field/allocation/FieldAllocator.h b/src/field/allocation/FieldAllocator.h index 78d149fc3ade6b3c26dcb8c08edbf8c100b27d3e..5be0ecf4b0dbd2b5e292d446dd13d62aae9aca23 100644 --- a/src/field/allocation/FieldAllocator.h +++ b/src/field/allocation/FieldAllocator.h @@ -26,7 +26,6 @@ #include "core/debug/Debug.h" #include "field/CMakeDefs.h" -#include <boost/static_assert.hpp> #include <map> #include <new> @@ -289,8 +288,8 @@ namespace field { aligned_free(values); } - BOOST_STATIC_ASSERT_MSG(alignment > 0, "Use StdFieldAlloc"); - BOOST_STATIC_ASSERT_MSG(!(alignment & (alignment - 1)) , "Alignment has to be power of 2"); + static_assert(alignment > 0, "Use StdFieldAlloc"); + static_assert(!(alignment & (alignment - 1)) , "Alignment has to be power of 2"); private: /// Nr of elements per allocated pointer has to be stored to call the destructor on each element diff --git a/src/field/blockforest/BlockDataHandling.h b/src/field/blockforest/BlockDataHandling.h index 3e73314c69633274a2647fecb2f5a848bfffa638..3d6d92a622287bd11d341e14d1e62a707aec464f 100644 --- a/src/field/blockforest/BlockDataHandling.h +++ b/src/field/blockforest/BlockDataHandling.h @@ -40,7 +40,7 @@ class BlockDataHandling : public blockforest::BlockDataHandling< Field_T > public: typedef typename Field_T::value_type Value_T; - typedef boost::function< void ( Field_T * field, IBlock * const block ) > InitializationFunction_T; + typedef std::function< void ( Field_T * field, IBlock * const block ) > InitializationFunction_T; virtual ~BlockDataHandling() {} @@ -395,18 +395,18 @@ public: typedef typename GhostLayerField_T::value_type Value_T; DefaultBlockDataHandling( const weak_ptr< StructuredBlockStorage > & blocks, - const boost::function< Vector3< uint_t > ( const shared_ptr< StructuredBlockStorage > &, IBlock * const ) > calculateSize = internal::defaultSize ) : + const std::function< Vector3< uint_t > ( const shared_ptr< StructuredBlockStorage > &, IBlock * const ) > calculateSize = internal::defaultSize ) : blocks_( blocks ), nrOfGhostLayers_( uint_t(1) ), initValue_(), layout_( zyxf ), calculateSize_( calculateSize ) {} DefaultBlockDataHandling( const weak_ptr< StructuredBlockStorage > & blocks, const uint_t nrOfGhostLayers, - const boost::function< Vector3< uint_t > ( const shared_ptr< StructuredBlockStorage > &, IBlock * const ) > calculateSize = internal::defaultSize ) : + const std::function< Vector3< uint_t > ( const shared_ptr< StructuredBlockStorage > &, IBlock * const ) > calculateSize = internal::defaultSize ) : blocks_( blocks ), nrOfGhostLayers_( nrOfGhostLayers ), initValue_(), layout_( zyxf ), calculateSize_( calculateSize ) {} DefaultBlockDataHandling( const weak_ptr< StructuredBlockStorage > & blocks, const uint_t nrOfGhostLayers, const Value_T & initValue, const Layout layout = zyxf, - const boost::function< Vector3< uint_t > ( const shared_ptr< StructuredBlockStorage > &, IBlock * const ) > calculateSize = internal::defaultSize ) : + const std::function< Vector3< uint_t > ( const shared_ptr< StructuredBlockStorage > &, IBlock * const ) > calculateSize = internal::defaultSize ) : blocks_( blocks ), nrOfGhostLayers_( nrOfGhostLayers ), initValue_( initValue ), layout_( layout ), calculateSize_( calculateSize ) { static_assert( !boost::is_same< GhostLayerField_T, FlagField< Value_T > >::value, @@ -440,7 +440,7 @@ private: uint_t nrOfGhostLayers_; Value_T initValue_; Layout layout_; - const boost::function< Vector3< uint_t > ( const shared_ptr< StructuredBlockStorage > &, IBlock * const ) > calculateSize_; + const std::function< Vector3< uint_t > ( const shared_ptr< StructuredBlockStorage > &, IBlock * const ) > calculateSize_; }; // class DefaultBlockDataHandling @@ -455,21 +455,21 @@ class AlwaysInitializeBlockDataHandling : public blockforest::AlwaysInitializeBl public: typedef typename GhostLayerField_T::value_type Value_T; - typedef boost::function< void ( GhostLayerField_T * field, IBlock * const block ) > InitializationFunction_T; + typedef std::function< void ( GhostLayerField_T * field, IBlock * const block ) > InitializationFunction_T; AlwaysInitializeBlockDataHandling( const weak_ptr< StructuredBlockStorage > & blocks, - const boost::function< Vector3< uint_t > ( const shared_ptr< StructuredBlockStorage > &, IBlock * const ) > calculateSize = internal::defaultSize ) : + const std::function< Vector3< uint_t > ( const shared_ptr< StructuredBlockStorage > &, IBlock * const ) > calculateSize = internal::defaultSize ) : blocks_( blocks ), nrOfGhostLayers_( uint_t(1) ), initValue_(), layout_( zyxf ), calculateSize_( calculateSize ) {} AlwaysInitializeBlockDataHandling( const weak_ptr< StructuredBlockStorage > & blocks, const uint_t nrOfGhostLayers, - const boost::function< Vector3< uint_t > ( const shared_ptr< StructuredBlockStorage > &, IBlock * const ) > calculateSize = internal::defaultSize ) : + const std::function< Vector3< uint_t > ( const shared_ptr< StructuredBlockStorage > &, IBlock * const ) > calculateSize = internal::defaultSize ) : blocks_( blocks ), nrOfGhostLayers_( nrOfGhostLayers ), initValue_(), layout_( zyxf ), calculateSize_( calculateSize ) {} AlwaysInitializeBlockDataHandling( const weak_ptr< StructuredBlockStorage > & blocks, const uint_t nrOfGhostLayers, const Value_T & initValue, const Layout layout, - const boost::function< Vector3< uint_t > ( const shared_ptr< StructuredBlockStorage > &, IBlock * const ) > calculateSize = internal::defaultSize ) : + const std::function< Vector3< uint_t > ( const shared_ptr< StructuredBlockStorage > &, IBlock * const ) > calculateSize = internal::defaultSize ) : blocks_( blocks ), nrOfGhostLayers_( nrOfGhostLayers ), initValue_( initValue ), layout_( layout ), calculateSize_( calculateSize ) { static_assert( !boost::is_same< GhostLayerField_T, FlagField< Value_T > >::value, @@ -498,7 +498,7 @@ private: uint_t nrOfGhostLayers_; Value_T initValue_; Layout layout_; - const boost::function< Vector3< uint_t > ( const shared_ptr< StructuredBlockStorage > &, IBlock * const ) > calculateSize_; + const std::function< Vector3< uint_t > ( const shared_ptr< StructuredBlockStorage > &, IBlock * const ) > calculateSize_; InitializationFunction_T initFunction_; diff --git a/src/field/python/FieldExport.impl.h b/src/field/python/FieldExport.impl.h index 058379e656756d133bec1b45255bbc76cc36c9ea..ecbbbae8ca9d72cd0b9c1db0352159297853a5c7 100644 --- a/src/field/python/FieldExport.impl.h +++ b/src/field/python/FieldExport.impl.h @@ -34,6 +34,7 @@ #include "field/AddToStorage.h" #include "field/python/GatherExport.h" #include "field/vtk/VTKWriter.h" +#include "field/vtk/FlagFieldMapping.h" #include "python_coupling/helper/MplHelpers.h" #include "python_coupling/helper/BoostPythonHelpers.h" @@ -749,8 +750,8 @@ namespace internal { .add_property("allocSize", &field_allocSize < Field_T > ) .add_property("strides", &field_strides < Field_T > ) .add_property("offsets", &field_offsets < Field_T > ) - .def("clone", &Field_T::clone , return_value_policy<manage_new_object>()) - .def("cloneUninitialized", &Field_T::cloneUninitialized , return_value_policy<manage_new_object>()) + .def("clone", &Field_T::clone , return_value_policy<manage_new_object>()) + .def("cloneUninitialized", &Field_T::cloneUninitialized, return_value_policy<manage_new_object>()) .def("swapDataPointers", &field_swapDataPointers< Field_T > ) .def("__getitem__", &field_getCellXYZ < Field_T > ) .def("__setitem__", &field_setCellXYZ < Field_T > ) @@ -1087,6 +1088,150 @@ namespace internal { return exporter.getCreatedWriter(); } } + + //=================================================================================================================== + // + // createFlagFieldVTKWriter + // + //=================================================================================================================== + + class CreateFlagFieldVTKWriterExporter + { + public: + CreateFlagFieldVTKWriterExporter( const shared_ptr<StructuredBlockStorage> & blocks, + ConstBlockDataID fieldId, const std::string & vtkName, + boost::python::dict flagMapping) + : blocks_( blocks ), fieldId_(fieldId), vtkName_( vtkName ), flagMapping_( flagMapping ) + {} + + template< typename FieldType> + void operator() ( python_coupling::NonCopyableWrap<FieldType> ) + { + using namespace boost::python; + + IBlock * firstBlock = & ( * blocks_->begin() ); + if( firstBlock->isDataClassOrSubclassOf<FieldType>(fieldId_) ) + { + typedef typename FieldType::flag_t flag_t; + typedef field::FlagFieldMapping<FieldType, flag_t> FFMapping; + auto uncastedWriter = shared_ptr<FFMapping >( new FFMapping(fieldId_, vtkName_)); + writer_ = uncastedWriter; + auto keys = flagMapping_.keys(); + + for( int i=0; i < len(keys); ++i ) { + uncastedWriter->addMapping(FlagUID(extract<std::string>(keys[i])), + extract<flag_t>(flagMapping_[keys[i]]) ); + } + } + + } + + shared_ptr< vtk::BlockCellDataWriterInterface > getCreatedWriter() { + return writer_; + } + + private: + shared_ptr< vtk::BlockCellDataWriterInterface > writer_; + shared_ptr< StructuredBlockStorage > blocks_; + ConstBlockDataID fieldId_; + std::string vtkName_; + boost::python::dict flagMapping_; + }; + + + template<typename FieldTypes> + inline shared_ptr<vtk::BlockCellDataWriterInterface> createFlagFieldVTKWriter(const shared_ptr<StructuredBlockStorage> & blocks, + const std::string & name, + boost::python::dict flagMapping, + const std::string & nameInVtkOutput = "" ) + { + std::string vtkName = nameInVtkOutput; + if( vtkName.size() == 0) + vtkName = name; + + if ( blocks->begin() == blocks->end() ) + return shared_ptr<vtk::BlockCellDataWriterInterface>(); + auto fieldID = python_coupling::blockDataIDFromString( *blocks, name ); + + CreateFlagFieldVTKWriterExporter exporter(blocks, fieldID, vtkName, flagMapping); + python_coupling::for_each_noncopyable_type< FieldTypes > ( boost::ref(exporter) ); + if ( ! exporter.getCreatedWriter() ) { + PyErr_SetString( PyExc_ValueError, "Failed to create writer"); + throw boost::python::error_already_set(); + } + else { + return exporter.getCreatedWriter(); + } + } + + + //=================================================================================================================== + // + // createBinarizationFieldWriter + // + //=================================================================================================================== + + class CreateBinarizationVTKWriterExporter + { + public: + CreateBinarizationVTKWriterExporter( const shared_ptr<StructuredBlockStorage> & blocks, + ConstBlockDataID fieldId, const std::string & vtkName, uint_t mask ) + : blocks_( blocks ), fieldId_(fieldId), vtkName_( vtkName ), mask_(mask) + {} + + template< typename FieldType> + void operator() ( python_coupling::NonCopyableWrap<FieldType> ) + { + using namespace boost::python; + + IBlock * firstBlock = & ( * blocks_->begin() ); + if( firstBlock->isDataClassOrSubclassOf<FieldType>(fieldId_) ) + { + typedef field::BinarizationFieldWriter<FieldType> Writer; + writer_ = shared_ptr<Writer>( new Writer(fieldId_, vtkName_, + static_cast<typename FieldType::value_type>(mask_) )); + } + } + + shared_ptr< vtk::BlockCellDataWriterInterface > getCreatedWriter() { + return writer_; + } + + private: + shared_ptr< vtk::BlockCellDataWriterInterface > writer_; + shared_ptr< StructuredBlockStorage > blocks_; + ConstBlockDataID fieldId_; + std::string vtkName_; + uint_t mask_; + }; + + + template<typename FieldTypes> + inline shared_ptr<vtk::BlockCellDataWriterInterface> createBinarizationVTKWriter(const shared_ptr<StructuredBlockStorage> & blocks, + const std::string & name, + uint_t mask, + const std::string & nameInVtkOutput = "" ) + { + std::string vtkName = nameInVtkOutput; + if( vtkName.size() == 0) + vtkName = name; + + if ( blocks->begin() == blocks->end() ) + return shared_ptr<vtk::BlockCellDataWriterInterface>(); + auto fieldID = python_coupling::blockDataIDFromString( *blocks, name ); + + CreateBinarizationVTKWriterExporter exporter(blocks, fieldID, vtkName, mask); + python_coupling::for_each_noncopyable_type< FieldTypes > ( boost::ref(exporter) ); + if ( ! exporter.getCreatedWriter() ) { + PyErr_SetString( PyExc_ValueError, "Failed to create writer"); + throw boost::python::error_already_set(); + } + else { + return exporter.getCreatedWriter(); + } + } + + } // namespace internal @@ -1127,6 +1272,26 @@ void exportFields() ( arg("ghostLayers") = uint_t(1) ) ) ); def( "createVTKWriter", &internal::createVTKWriter<FieldTypes>, ( arg("blocks"), arg("name"), arg("vtkName")="" )); + + + typedef boost::mpl::vector< + FlagField<uint8_t>, + FlagField<uint16_t>, + FlagField<uint32_t>, + FlagField<uint64_t> > FlagFields; + + def( "createFlagFieldVTKWriter", &internal::createFlagFieldVTKWriter<FlagFields>, + ( arg("blocks"), arg("name"), arg("flagMapping"), arg("vtkName")="" )); + + + typedef boost::mpl::vector< + Field<uint8_t,1 >, + Field<uint16_t, 1>, + Field<uint32_t, 1>, + Field<uint64_t, 1> > UintFields; + + def( "createBinarizationVTKWriter", &internal::createBinarizationVTKWriter<UintFields>, + ( arg("blocks"), arg("name"), arg("mask"), arg("vtkName")="" )); } diff --git a/src/field/python/GatherExport.impl.h b/src/field/python/GatherExport.impl.h index d297d8a63c2e8d84f1a2aa6dbce933b6d4d92c17..42f66565c21de0d708f2f00f3f916cf770e84ce1 100644 --- a/src/field/python/GatherExport.impl.h +++ b/src/field/python/GatherExport.impl.h @@ -76,7 +76,7 @@ namespace internal { IBlock * firstBlock = & ( * blocks->begin() ); python_coupling::Dispatcher<FieldTypes, Exporter_gatherToObject > dispatcher( firstBlock ); auto func = dispatcher( fieldID ); - if ( func.empty() ) + if ( !func ) { PyErr_SetString( PyExc_RuntimeError, "This function cannot handle this type of block data."); throw error_already_set(); diff --git a/src/field/vtk/FlagFieldMapping.h b/src/field/vtk/FlagFieldMapping.h index dbda66b788df794395312e0b71b4fb4deac322fe..8b25ce58e6dea759214898243d717ce5ab97fde8 100644 --- a/src/field/vtk/FlagFieldMapping.h +++ b/src/field/vtk/FlagFieldMapping.h @@ -30,7 +30,6 @@ namespace walberla { namespace field { - template< typename FlagField_T, typename T > class FlagFieldMapping : public vtk::BlockCellDataWriter<T,1> { @@ -84,6 +83,38 @@ protected: }; // FlagFieldMapping +template<typename FieldType, typename TargetType=uint8_t> +class BinarizationFieldWriter : public vtk::BlockCellDataWriter<TargetType,1> +{ + typedef typename FieldType::value_type SrcType; + +public: + BinarizationFieldWriter( const ConstBlockDataID fieldID, const std::string& id, SrcType mask) : + vtk::BlockCellDataWriter<TargetType,1>( id ), fieldID_( fieldID ), field_( NULL ), mask_( mask ) {} + +protected: + + void configure() { + WALBERLA_ASSERT_NOT_NULLPTR( this->block_ ); + field_ = this->block_->template getData< FieldType >( fieldID_ ); + } + + TargetType evaluate( const cell_idx_t x, const cell_idx_t y, const cell_idx_t z, const cell_idx_t /*f*/ ) + { + WALBERLA_ASSERT_NOT_NULLPTR( field_ ); + if (field_->get(x,y,z) & mask_) { + return TargetType(1); + } else { + return TargetType(0); + } + } + const ConstBlockDataID fieldID_; + const FieldType* field_; + + SrcType mask_; +}; // BinaryFieldWriter + + } // namespace field } // namespace walberla diff --git a/src/field/vtk/VTKWriter.h b/src/field/vtk/VTKWriter.h index fabb4d71454356a3ec213b64a3f30f19e93c33c7..c83033fe81a06a54c7a0874ceb8581fc07b6f353 100644 --- a/src/field/vtk/VTKWriter.h +++ b/src/field/vtk/VTKWriter.h @@ -169,7 +169,7 @@ inline vtk::VTKOutput::Write createVTKOutput ( const ConstBlockDataID & fieldId auto vtkOutput = vtk::createVTKOutput_BlockData( blocks, identifier, writeFrequency, ghostLayers, forcePVTU, baseFolder, executionFolder, continuousNumbering, binary, littleEndian, useMPIIO, initialExecutionCount ); - vtkOutput->addCellDataWriter( boost::make_shared< VTKWriter< Field_T,OutputType > >( fieldId, identifier ) ); + vtkOutput->addCellDataWriter( make_shared< VTKWriter< Field_T,OutputType > >( fieldId, identifier ) ); return writeFiles( vtkOutput, true, simultaneousIOOperations, requiredStates, incompatibleStates ); } @@ -222,7 +222,7 @@ inline vtk::VTKOutput::Write createScalingVTKOutput( const ConstBlockDataID & fi auto vtkOutput = vtk::createVTKOutput_BlockData( blocks, identifier, writeFrequency, ghostLayers, forcePVTU, baseFolder, executionFolder, continuousNumbering, binary, littleEndian, useMPIIO, initialExecutionCount ); - auto writer = boost::make_shared< VTKWriter< Field_T,OutputType > >( fieldId, identifier ); + auto writer = make_shared< VTKWriter< Field_T,OutputType > >( fieldId, identifier ); vtkOutput->addCellDataWriter( vtk::makeBlockCellDataWriterScalingAdapter(identifier, writer, factor) ); return writeFiles( vtkOutput, true, simultaneousIOOperations, requiredStates, incompatibleStates ); diff --git a/src/gather/CurveGatherPackInfo.h b/src/gather/CurveGatherPackInfo.h index ff545e15f54e24101f61401a230f66c4a83342a3..f23b18ae6abc04845bedef1fb39e748250fd5243 100644 --- a/src/gather/CurveGatherPackInfo.h +++ b/src/gather/CurveGatherPackInfo.h @@ -28,7 +28,7 @@ #include "domain_decomposition/StructuredBlockStorage.h" #include "field/interpolators/TrilinearInterpolatorFwd.h" -#include <boost/function.hpp> +#include <functional> #include <functional> #include <map> #include <vector> @@ -52,7 +52,7 @@ class CurveGatherPackInfo : public GatherPackInfo { public: typedef Vector3<real_t> RealVec3; - typedef boost::function<RealVec3 (real_t t) > CurveCallback; + typedef std::function<RealVec3 (real_t t) > CurveCallback; //**Construction & Destruction************************************************************************* diff --git a/src/gather/CurveGatherPackInfo.impl.h b/src/gather/CurveGatherPackInfo.impl.h index c18ff74d511b67b5dbd38c315d405388ab7c9b2f..0039b2a05cb1f3c16adb1ab427bb8ae925fc9923 100644 --- a/src/gather/CurveGatherPackInfo.impl.h +++ b/src/gather/CurveGatherPackInfo.impl.h @@ -20,7 +20,6 @@ // //====================================================================================================================== -#include "boost/lambda/bind.hpp" #include "core/debug/Debug.h" #include "core/logging/Logging.h" #include "core/math/Parser.h" diff --git a/src/gather/FileGatherScheme.cpp b/src/gather/FileGatherScheme.cpp index b19f8d93c3c529d7a88a61a8c1e81ea5a4477a19..0aa2e40d7121db5eacbda388a5f55afcabe434c9 100644 --- a/src/gather/FileGatherScheme.cpp +++ b/src/gather/FileGatherScheme.cpp @@ -27,7 +27,7 @@ #include "core/mpi/RecvBuffer.h" #include "core/mpi/SendBuffer.h" -#include <boost/filesystem.hpp> +#include "core/Filesystem.h" #include <boost/lexical_cast.hpp> @@ -56,7 +56,7 @@ FileGatherScheme::~FileGatherScheme() void FileGatherScheme::deleteTemporaryFiles() { - using namespace boost::filesystem; + using namespace filesystem; using std::string; for(int rank=0; rank < MPIManager::instance()->numProcesses(); ++rank) @@ -108,7 +108,7 @@ void FileGatherScheme::writeToFile() void FileGatherScheme::collectFromFiles() { - using namespace boost::filesystem; + using namespace filesystem; using namespace std; if ( fileStream_.is_open() ) diff --git a/src/gui/Gui.h b/src/gui/Gui.h index f2b520d76ca34410c8de3ea9ace617fa1680b18f..b66ddc3be5b4c722b3f5455f717e46955c5655b2 100644 --- a/src/gui/Gui.h +++ b/src/gui/Gui.h @@ -25,7 +25,7 @@ #include "blockforest/StructuredBlockForest.h" #include "timeloop/ITimeloop.h" -#include <boost/function.hpp> +#include <functional> #include <vector> @@ -52,7 +52,7 @@ namespace gui { void registerPropertyTree( const shared_ptr<PropertyTree> propertyTree ); - typedef boost::function< DisplayAdaptor * ( const IBlock &, ConstBlockDataID ) > DisplayAdaptorCreatorFunc; + typedef std::function< DisplayAdaptor * ( const IBlock &, ConstBlockDataID ) > DisplayAdaptorCreatorFunc; void registerDisplayAdaptorCreator( const DisplayAdaptorCreatorFunc & creatorFunc ); static void breakpoint( const std::string & comment, const std::string & file, int line ); diff --git a/src/lbm/boundary/VelocityBoundary.h b/src/lbm/boundary/VelocityBoundary.h index 383cd41bb2d4832dbd51276a56cadc1610ab7730..8b470021b3575e755894f49397ff9cc0ddb945c3 100644 --- a/src/lbm/boundary/VelocityBoundary.h +++ b/src/lbm/boundary/VelocityBoundary.h @@ -112,7 +112,7 @@ public: inline void treatDirection( const cell_idx_t x, const cell_idx_t y, const cell_idx_t z, const stencil::Direction dir, const cell_idx_t nx, const cell_idx_t ny, const cell_idx_t nz, const flag_t mask ); - inline const std::vector<real_t> & getValue( const cell_idx_t x, cell_idx_t y, cell_idx_t z ) const { return vel_->get(x,y,z); } + inline const std::vector<real_t> & getValue( const cell_idx_t x, cell_idx_t y, cell_idx_t z ) const { return *(vel_->get(x,y,z)); } private: diff --git a/src/lbm/python/ExportBasic.impl.h b/src/lbm/python/ExportBasic.impl.h index 4727cb5f38cd106b094c849c7c384e7c82164f01..afae7a5a105fc0e4067d694eaa74e19b5817bb51 100644 --- a/src/lbm/python/ExportBasic.impl.h +++ b/src/lbm/python/ExportBasic.impl.h @@ -388,7 +388,7 @@ namespace internal SweepWrapper() {} - SweepWrapper( const boost::function<void(IBlock*) > & sweepToWrap ) + SweepWrapper( const std::function<void(IBlock*) > & sweepToWrap ) : sweepToWrap_( sweepToWrap ) {} void operator() ( IBlock * block ) @@ -397,7 +397,7 @@ namespace internal sweepToWrap_( block ); } protected: - boost::function<void(IBlock*) > sweepToWrap_; + std::function<void(IBlock*) > sweepToWrap_; }; diff --git a/src/lbm/refinement/BoundarySetup.h b/src/lbm/refinement/BoundarySetup.h index 07b963f0da2fcb36d12bf619924f85747bfd72fa..4271b9984e3e74476bae1e4b7ab0f20af61dcc24 100644 --- a/src/lbm/refinement/BoundarySetup.h +++ b/src/lbm/refinement/BoundarySetup.h @@ -74,16 +74,16 @@ inline shared_ptr< BoundaryConfiguration > defaultBoundaryConfiguration( const C //********************************************************************************************************************** template< typename BoundaryHandling_T, bool ForceBoundary > void consistentlySetBoundary( StructuredBlockStorage & blocks, Block & block, const BlockDataID & boundaryHandlingId, const FlagUID & flag, - const boost::function< bool ( const Vector3< real_t > & ) > & isBoundary, - const boost::function< shared_ptr< BoundaryConfiguration > ( const Cell &, const Vector3< real_t > & ) > & parameter = internal::defaultBoundaryConfiguration ); + const std::function< bool ( const Vector3< real_t > & ) > & isBoundary, + const std::function< shared_ptr< BoundaryConfiguration > ( const Cell &, const Vector3< real_t > & ) > & parameter = internal::defaultBoundaryConfiguration ); /// For documentation see function "template< typename BoundaryHandling_T, bool ForceBoundary > void consistentlySetBoundary(...)" template< typename BoundaryHandling_T > void consistentlySetBoundary( StructuredBlockStorage & blocks, Block & block, const BlockDataID & boundaryHandlingId, const FlagUID & flag, - const boost::function< bool ( const Vector3< real_t > & ) > & isBoundary, - const boost::function< shared_ptr< BoundaryConfiguration > ( const Cell &, const Vector3< real_t > & ) > & parameter = internal::defaultBoundaryConfiguration ) + const std::function< bool ( const Vector3< real_t > & ) > & isBoundary, + const std::function< shared_ptr< BoundaryConfiguration > ( const Cell &, const Vector3< real_t > & ) > & parameter = internal::defaultBoundaryConfiguration ) { consistentlySetBoundary< BoundaryHandling_T, false >( blocks, block, boundaryHandlingId, flag, isBoundary, parameter ); } @@ -93,8 +93,8 @@ void consistentlySetBoundary( StructuredBlockStorage & blocks, Block & block, co /// For documentation see function "template< typename BoundaryHandling_T, bool ForceBoundary > void consistentlySetBoundary(...)" template< typename BoundaryHandling_T > void consistentlyForceBoundary( StructuredBlockStorage & blocks, Block & block, const BlockDataID & boundaryHandlingId, const FlagUID & flag, - const boost::function< bool ( const Vector3< real_t > & ) > & isBoundary, - const boost::function< shared_ptr< BoundaryConfiguration > ( const Cell &, const Vector3< real_t > & ) > & parameter = internal::defaultBoundaryConfiguration ) + const std::function< bool ( const Vector3< real_t > & ) > & isBoundary, + const std::function< shared_ptr< BoundaryConfiguration > ( const Cell &, const Vector3< real_t > & ) > & parameter = internal::defaultBoundaryConfiguration ) { consistentlySetBoundary< BoundaryHandling_T, true >( blocks, block, boundaryHandlingId, flag, isBoundary, parameter ); } @@ -103,8 +103,8 @@ void consistentlyForceBoundary( StructuredBlockStorage & blocks, Block & block, template< typename BoundaryHandling_T, bool ForceBoundary > void consistentlySetBoundary( StructuredBlockStorage & blocks, Block & block, const BlockDataID & boundaryHandlingId, const FlagUID & flag, - const boost::function< bool ( const Vector3< real_t > & ) > & isBoundary, - const boost::function< shared_ptr< BoundaryConfiguration > ( const Cell &, const Vector3< real_t > & ) > & parameter ) + const std::function< bool ( const Vector3< real_t > & ) > & isBoundary, + const std::function< shared_ptr< BoundaryConfiguration > ( const Cell &, const Vector3< real_t > & ) > & parameter ) { const uint_t level = blocks.getLevel(block); diff --git a/src/lbm/refinement/RefinementFunctorWrapper.h b/src/lbm/refinement/RefinementFunctorWrapper.h index 92261857469ffe0297b4f9462daf978fe792cae9..9ea0b99e15baa1ebdd6653256cbaf6e6dfd3b87e 100644 --- a/src/lbm/refinement/RefinementFunctorWrapper.h +++ b/src/lbm/refinement/RefinementFunctorWrapper.h @@ -23,7 +23,7 @@ #include "domain_decomposition/BlockStorage.h" -#include <boost/function.hpp> +#include <functional> namespace walberla { namespace lbm { @@ -31,7 +31,7 @@ namespace refinement { class FunctorWrapper { public: - FunctorWrapper( const boost::function<void()> & fct) + FunctorWrapper( const std::function<void()> & fct) : fct_(fct) { } @@ -40,12 +40,12 @@ public: } private: - boost::function<void(void)> fct_; + std::function<void(void)> fct_; }; class SweepAsFunctorWrapper { public: - SweepAsFunctorWrapper( const boost::function<void(IBlock * )> & fct, + SweepAsFunctorWrapper( const std::function<void(IBlock * )> & fct, const shared_ptr <StructuredBlockStorage> & blockStorage ) : fct_(fct), blockStorage_(blockStorage) { } @@ -58,7 +58,7 @@ public: } private: - boost::function<void(IBlock * )> fct_; + std::function<void(IBlock * )> fct_; shared_ptr <StructuredBlockStorage> blockStorage_; }; diff --git a/src/lbm/refinement/TimeStep.h b/src/lbm/refinement/TimeStep.h index f006d0494aa0af888821c671c6491aa86cff49dc..1be6a470d5402e21600831870524e80c563f6716 100644 --- a/src/lbm/refinement/TimeStep.h +++ b/src/lbm/refinement/TimeStep.h @@ -55,8 +55,8 @@ public: typedef typename NeighborsStencil<LatticeModel_T>::type CommunicationStencil_T; - typedef boost::function< void ( const uint_t, const uint_t ) > VoidFunction; // parameters: level, execution count - typedef boost::function< void ( IBlock *, const uint_t, const uint_t ) > BlockFunction; // parameters: block, level, execution count + typedef std::function< void ( const uint_t, const uint_t ) > VoidFunction; // parameters: level, execution count + typedef std::function< void ( IBlock *, const uint_t, const uint_t ) > BlockFunction; // parameters: block, level, execution count private: diff --git a/src/lbm/srt/SplitPureSweep.impl.h b/src/lbm/srt/SplitPureSweep.impl.h index 975e06eb7ebc65af827fbb196d168bbd29381da9..d545a9d1269be9cbd48833d610a37f12b91f8e3c 100644 --- a/src/lbm/srt/SplitPureSweep.impl.h +++ b/src/lbm/srt/SplitPureSweep.impl.h @@ -133,11 +133,11 @@ void SplitPureSweep< LatticeModel_T, typename boost::enable_if< boost::mpl::and_ #endif // temporaries, calculated by the first innermost loop - real_t * WALBERLA_RESTRICT velX = new real_t[ xSize ]; - real_t * WALBERLA_RESTRICT velY = new real_t[ xSize ]; - real_t * WALBERLA_RESTRICT velZ = new real_t[ xSize ]; + real_t * WALBERLA_RESTRICT velX = new real_t[ uint_c( xSize ) ]; + real_t * WALBERLA_RESTRICT velY = new real_t[ uint_c( xSize ) ]; + real_t * WALBERLA_RESTRICT velZ = new real_t[ uint_c( xSize ) ]; - real_t * WALBERLA_RESTRICT dir_indep_trm = new real_t[ xSize ]; + real_t * WALBERLA_RESTRICT dir_indep_trm = new real_t[ uint_c( xSize ) ]; if( src->layout() == field::fzyx && dst->layout() == field::fzyx ) { @@ -489,11 +489,11 @@ void SplitPureSweep< LatticeModel_T, typename boost::enable_if< boost::mpl::and_ #endif // temporaries, calculated by the first innermost loop - real_t * WALBERLA_RESTRICT velX = new real_t[ xSize ]; - real_t * WALBERLA_RESTRICT velY = new real_t[ xSize ]; - real_t * WALBERLA_RESTRICT velZ = new real_t[ xSize ]; + real_t * WALBERLA_RESTRICT velX = new real_t[ uint_c( xSize ) ]; + real_t * WALBERLA_RESTRICT velY = new real_t[ uint_c( xSize ) ]; + real_t * WALBERLA_RESTRICT velZ = new real_t[ uint_c( xSize ) ]; - real_t * WALBERLA_RESTRICT dir_indep_trm = new real_t[ xSize ]; + real_t * WALBERLA_RESTRICT dir_indep_trm = new real_t[ uint_c( xSize ) ]; if( src->layout() == field::fzyx ) { @@ -833,13 +833,13 @@ void SplitPureSweep< LatticeModel_T, typename boost::enable_if< boost::mpl::and_ #endif // temporaries, calculated by the first innermost loop - real_t * WALBERLA_RESTRICT velX = new real_t[ xSize ]; - real_t * WALBERLA_RESTRICT velY = new real_t[ xSize ]; - real_t * WALBERLA_RESTRICT velZ = new real_t[ xSize ]; + real_t * WALBERLA_RESTRICT velX = new real_t[ uint_c( xSize ) ]; + real_t * WALBERLA_RESTRICT velY = new real_t[ uint_c( xSize ) ]; + real_t * WALBERLA_RESTRICT velZ = new real_t[ uint_c( xSize ) ]; - real_t * WALBERLA_RESTRICT rho = new real_t[ xSize ]; + real_t * WALBERLA_RESTRICT rho = new real_t[ uint_c( xSize ) ]; - real_t * WALBERLA_RESTRICT dir_indep_trm = new real_t[ xSize ]; + real_t * WALBERLA_RESTRICT dir_indep_trm = new real_t[ uint_c( xSize ) ]; if( src->layout() == field::fzyx && dst->layout() == field::fzyx ) { @@ -1191,13 +1191,13 @@ void SplitPureSweep< LatticeModel_T, typename boost::enable_if< boost::mpl::and_ #endif // temporaries, calculated by the first innermost loop - real_t * WALBERLA_RESTRICT velX = new real_t[ xSize ]; - real_t * WALBERLA_RESTRICT velY = new real_t[ xSize ]; - real_t * WALBERLA_RESTRICT velZ = new real_t[ xSize ]; + real_t * WALBERLA_RESTRICT velX = new real_t[ uint_c( xSize ) ]; + real_t * WALBERLA_RESTRICT velY = new real_t[ uint_c( xSize ) ]; + real_t * WALBERLA_RESTRICT velZ = new real_t[ uint_c( xSize ) ]; - real_t * WALBERLA_RESTRICT rho = new real_t[ xSize ]; + real_t * WALBERLA_RESTRICT rho = new real_t[ uint_c( xSize ) ]; - real_t * WALBERLA_RESTRICT dir_indep_trm = new real_t[ xSize ]; + real_t * WALBERLA_RESTRICT dir_indep_trm = new real_t[ uint_c( xSize ) ]; if( src->layout() == field::fzyx ) { diff --git a/src/lbm/srt/SplitSweep.impl.h b/src/lbm/srt/SplitSweep.impl.h index 30d16a68f9ba9fb765f4f908bb0f1ba36edb666e..fca8be64fe097069ea8f8892177e27d0cb0691e8 100644 --- a/src/lbm/srt/SplitSweep.impl.h +++ b/src/lbm/srt/SplitSweep.impl.h @@ -127,13 +127,13 @@ void SplitSweep< LatticeModel_T, FlagField_T, typename boost::enable_if< boost:: #endif // temporaries, calculated by the first innermost loop - real_t * WALBERLA_RESTRICT velX = new real_t[ xSize ]; - real_t * WALBERLA_RESTRICT velY = new real_t[ xSize ]; - real_t * WALBERLA_RESTRICT velZ = new real_t[ xSize ]; + real_t * WALBERLA_RESTRICT velX = new real_t[ uint_c(xSize) ]; + real_t * WALBERLA_RESTRICT velY = new real_t[ uint_c(xSize) ]; + real_t * WALBERLA_RESTRICT velZ = new real_t[ uint_c(xSize) ]; - real_t * WALBERLA_RESTRICT dir_indep_trm = new real_t[ xSize ]; + real_t * WALBERLA_RESTRICT dir_indep_trm = new real_t[ uint_c(xSize) ]; - bool * WALBERLA_RESTRICT perform_lbm = new bool[ xSize ]; + bool * WALBERLA_RESTRICT perform_lbm = new bool[ uint_c(xSize) ]; if( src->layout() == field::fzyx && dst->layout() == field::fzyx ) { @@ -553,13 +553,13 @@ void SplitSweep< LatticeModel_T, FlagField_T, typename boost::enable_if< boost:: #endif // temporaries, calculated by the first innermost loop - real_t * WALBERLA_RESTRICT velX = new real_t[ xSize ]; - real_t * WALBERLA_RESTRICT velY = new real_t[ xSize ]; - real_t * WALBERLA_RESTRICT velZ = new real_t[ xSize ]; + real_t * WALBERLA_RESTRICT velX = new real_t[ uint_c(xSize) ]; + real_t * WALBERLA_RESTRICT velY = new real_t[ uint_c(xSize) ]; + real_t * WALBERLA_RESTRICT velZ = new real_t[ uint_c(xSize) ]; - real_t * WALBERLA_RESTRICT dir_indep_trm = new real_t[ xSize ]; + real_t * WALBERLA_RESTRICT dir_indep_trm = new real_t[ uint_c(xSize) ]; - bool * WALBERLA_RESTRICT perform_lbm = new bool[ xSize ]; + bool * WALBERLA_RESTRICT perform_lbm = new bool[ uint_c(xSize) ]; if( src->layout() == field::fzyx ) { @@ -967,15 +967,15 @@ void SplitSweep< LatticeModel_T, FlagField_T, typename boost::enable_if< boost:: #endif // temporaries, calculated by the first innermost loop - real_t * WALBERLA_RESTRICT velX = new real_t[ xSize ]; - real_t * WALBERLA_RESTRICT velY = new real_t[ xSize ]; - real_t * WALBERLA_RESTRICT velZ = new real_t[ xSize ]; + real_t * WALBERLA_RESTRICT velX = new real_t[ uint_c(xSize) ]; + real_t * WALBERLA_RESTRICT velY = new real_t[ uint_c(xSize) ]; + real_t * WALBERLA_RESTRICT velZ = new real_t[ uint_c(xSize) ]; - real_t * WALBERLA_RESTRICT rho = new real_t[ xSize ]; + real_t * WALBERLA_RESTRICT rho = new real_t[ uint_c(xSize) ]; - real_t * WALBERLA_RESTRICT dir_indep_trm = new real_t[ xSize ]; + real_t * WALBERLA_RESTRICT dir_indep_trm = new real_t[ uint_c(xSize) ]; - bool * WALBERLA_RESTRICT perform_lbm = new bool[ xSize ]; + bool * WALBERLA_RESTRICT perform_lbm = new bool[ uint_c(xSize) ]; if( src->layout() == field::fzyx && dst->layout() == field::fzyx ) { @@ -1398,15 +1398,15 @@ void SplitSweep< LatticeModel_T, FlagField_T, typename boost::enable_if< boost:: #endif // temporaries, calculated by the first innermost loop - real_t * WALBERLA_RESTRICT velX = new real_t[ xSize ]; - real_t * WALBERLA_RESTRICT velY = new real_t[ xSize ]; - real_t * WALBERLA_RESTRICT velZ = new real_t[ xSize ]; + real_t * WALBERLA_RESTRICT velX = new real_t[ uint_c(xSize) ]; + real_t * WALBERLA_RESTRICT velY = new real_t[ uint_c(xSize) ]; + real_t * WALBERLA_RESTRICT velZ = new real_t[ uint_c(xSize) ]; - real_t * WALBERLA_RESTRICT rho = new real_t[ xSize ]; + real_t * WALBERLA_RESTRICT rho = new real_t[ uint_c(xSize) ]; - real_t * WALBERLA_RESTRICT dir_indep_trm = new real_t[ xSize ]; + real_t * WALBERLA_RESTRICT dir_indep_trm = new real_t[ uint_c(xSize) ]; - bool * WALBERLA_RESTRICT perform_lbm = new bool[ xSize ]; + bool * WALBERLA_RESTRICT perform_lbm = new bool[ uint_c(xSize) ]; if( src->layout() == field::fzyx ) { diff --git a/src/lbm/srt/bluegeneq/SplitPureSweep.impl.h b/src/lbm/srt/bluegeneq/SplitPureSweep.impl.h index 501bf1ed06b070f68caaa8a2fd158e98a86d2e51..865e3dfa7dd579c1518094c9214b8139418841e9 100644 --- a/src/lbm/srt/bluegeneq/SplitPureSweep.impl.h +++ b/src/lbm/srt/bluegeneq/SplitPureSweep.impl.h @@ -145,11 +145,11 @@ void SplitPureSweep< LatticeModel_T, typename boost::enable_if_c< ice_and< boost #endif // temporaries, calculated by the first innermost loop - real_t* velX = new real_t[ xSize ]; - real_t* velY = new real_t[ xSize ]; - real_t* velZ = new real_t[ xSize ]; + real_t* velX = new real_t[ uint_c(xSize) ]; + real_t* velY = new real_t[ uint_c(xSize) ]; + real_t* velZ = new real_t[ uint_c(xSize) ]; - real_t* dir_indep_trm = new real_t[ xSize ]; + real_t* dir_indep_trm = new real_t[ uint_c(xSize) ]; if( src->layout() == field::fzyx && dst->layout() == field::fzyx ) { @@ -634,11 +634,11 @@ void SplitPureSweep< LatticeModel_T, typename boost::enable_if_c< ice_and< boost #endif // temporaries, calculated by the first innermost loop - real_t* velX = new real_t[ xSize ]; - real_t* velY = new real_t[ xSize ]; - real_t* velZ = new real_t[ xSize ]; + real_t* velX = new real_t[ uint_c(xSize) ]; + real_t* velY = new real_t[ uint_c(xSize) ]; + real_t* velZ = new real_t[ uint_c(xSize) ]; - real_t* dir_indep_trm = new real_t[ xSize ]; + real_t* dir_indep_trm = new real_t[ uint_c(xSize) ]; if( src->layout() == field::fzyx ) { @@ -1038,13 +1038,13 @@ void SplitPureSweep< LatticeModel_T, typename boost::enable_if_c< ice_and< boost #endif // temporaries, calculated by the first innermost loop - real_t* velX = new real_t[ xSize ]; - real_t* velY = new real_t[ xSize ]; - real_t* velZ = new real_t[ xSize ]; + real_t* velX = new real_t[ uint_c(xSize) ]; + real_t* velY = new real_t[ uint_c(xSize) ]; + real_t* velZ = new real_t[ uint_c(xSize) ]; - real_t* rho = new real_t[ xSize ]; + real_t* rho = new real_t[ uint_c(xSize) ]; - real_t* dir_indep_trm = new real_t[ xSize ]; + real_t* dir_indep_trm = new real_t[ uint_c(xSize) ]; if( src->layout() == field::fzyx && dst->layout() == field::fzyx ) { @@ -1529,13 +1529,13 @@ void SplitPureSweep< LatticeModel_T, typename boost::enable_if_c< ice_and< boost #endif // temporaries, calculated by the first innermost loop - real_t* velX = new real_t[ xSize ]; - real_t* velY = new real_t[ xSize ]; - real_t* velZ = new real_t[ xSize ]; + real_t* velX = new real_t[ uint_c(xSize) ]; + real_t* velY = new real_t[ uint_c(xSize) ]; + real_t* velZ = new real_t[ uint_c(xSize) ]; - real_t* rho = new real_t[ xSize ]; + real_t* rho = new real_t[ uint_c(xSize) ]; - real_t* dir_indep_trm = new real_t[ xSize ]; + real_t* dir_indep_trm = new real_t[ uint_c(xSize) ]; if( src->layout() == field::fzyx ) { diff --git a/src/lbm/trt/SplitPureSweep.impl.h b/src/lbm/trt/SplitPureSweep.impl.h index 90f742b7b0c916194aae6e0358daabe93c59ac41..0c60f11b440c230bff7c211b24e51e59700bdbda 100644 --- a/src/lbm/trt/SplitPureSweep.impl.h +++ b/src/lbm/trt/SplitPureSweep.impl.h @@ -140,11 +140,11 @@ void SplitPureSweep< LatticeModel_T, typename boost::enable_if< boost::mpl::and_ #endif // temporaries, calculated by the first innermost loop - real_t * WALBERLA_RESTRICT velX = new real_t[ xSize ]; - real_t * WALBERLA_RESTRICT velY = new real_t[ xSize ]; - real_t * WALBERLA_RESTRICT velZ = new real_t[ xSize ]; + real_t * WALBERLA_RESTRICT velX = new real_t[ uint_c( xSize ) ]; + real_t * WALBERLA_RESTRICT velY = new real_t[ uint_c( xSize ) ]; + real_t * WALBERLA_RESTRICT velZ = new real_t[ uint_c( xSize ) ]; - real_t * WALBERLA_RESTRICT feq_common = new real_t[ xSize ]; + real_t * WALBERLA_RESTRICT feq_common = new real_t[ uint_c( xSize ) ]; if( src->layout() == field::fzyx && dst->layout() == field::fzyx ) { @@ -543,11 +543,11 @@ void SplitPureSweep< LatticeModel_T, typename boost::enable_if< boost::mpl::and_ #endif // temporaries, calculated by the first innermost loop - real_t * WALBERLA_RESTRICT velX = new real_t[ xSize ]; - real_t * WALBERLA_RESTRICT velY = new real_t[ xSize ]; - real_t * WALBERLA_RESTRICT velZ = new real_t[ xSize ]; + real_t * WALBERLA_RESTRICT velX = new real_t[ uint_c( xSize ) ]; + real_t * WALBERLA_RESTRICT velY = new real_t[ uint_c( xSize ) ]; + real_t * WALBERLA_RESTRICT velZ = new real_t[ uint_c( xSize ) ]; - real_t * WALBERLA_RESTRICT feq_common = new real_t[ xSize ]; + real_t * WALBERLA_RESTRICT feq_common = new real_t[ uint_c( xSize ) ]; if( src->layout() == field::fzyx ) { @@ -936,16 +936,16 @@ void SplitPureSweep< LatticeModel_T, typename boost::enable_if< boost::mpl::and_ #endif // temporaries, calculated by the first innermost loop - real_t * WALBERLA_RESTRICT velX = new real_t[ xSize ]; - real_t * WALBERLA_RESTRICT velY = new real_t[ xSize ]; - real_t * WALBERLA_RESTRICT velZ = new real_t[ xSize ]; + real_t * WALBERLA_RESTRICT velX = new real_t[ uint_c( xSize ) ]; + real_t * WALBERLA_RESTRICT velY = new real_t[ uint_c( xSize ) ]; + real_t * WALBERLA_RESTRICT velZ = new real_t[ uint_c( xSize ) ]; - real_t * WALBERLA_RESTRICT t1x2 = new real_t[ xSize ]; - real_t * WALBERLA_RESTRICT t2x2 = new real_t[ xSize ]; - real_t * WALBERLA_RESTRICT fac1 = new real_t[ xSize ]; - real_t * WALBERLA_RESTRICT fac2 = new real_t[ xSize ]; + real_t * WALBERLA_RESTRICT t1x2 = new real_t[ uint_c( xSize ) ]; + real_t * WALBERLA_RESTRICT t2x2 = new real_t[ uint_c( xSize ) ]; + real_t * WALBERLA_RESTRICT fac1 = new real_t[ uint_c( xSize ) ]; + real_t * WALBERLA_RESTRICT fac2 = new real_t[ uint_c( xSize ) ]; - real_t * WALBERLA_RESTRICT feq_common = new real_t[ xSize ]; + real_t * WALBERLA_RESTRICT feq_common = new real_t[ uint_c( xSize ) ]; if( src->layout() == field::fzyx && dst->layout() == field::fzyx ) { @@ -1358,16 +1358,16 @@ void SplitPureSweep< LatticeModel_T, typename boost::enable_if< boost::mpl::and_ #endif // temporaries, calculated by the first innermost loop - real_t * WALBERLA_RESTRICT velX = new real_t[ xSize ]; - real_t * WALBERLA_RESTRICT velY = new real_t[ xSize ]; - real_t * WALBERLA_RESTRICT velZ = new real_t[ xSize ]; + real_t * WALBERLA_RESTRICT velX = new real_t[ uint_c( xSize ) ]; + real_t * WALBERLA_RESTRICT velY = new real_t[ uint_c( xSize ) ]; + real_t * WALBERLA_RESTRICT velZ = new real_t[ uint_c( xSize ) ]; - real_t * WALBERLA_RESTRICT t1x2 = new real_t[ xSize ]; - real_t * WALBERLA_RESTRICT t2x2 = new real_t[ xSize ]; - real_t * WALBERLA_RESTRICT fac1 = new real_t[ xSize ]; - real_t * WALBERLA_RESTRICT fac2 = new real_t[ xSize ]; + real_t * WALBERLA_RESTRICT t1x2 = new real_t[ uint_c( xSize ) ]; + real_t * WALBERLA_RESTRICT t2x2 = new real_t[ uint_c( xSize ) ]; + real_t * WALBERLA_RESTRICT fac1 = new real_t[ uint_c( xSize ) ]; + real_t * WALBERLA_RESTRICT fac2 = new real_t[ uint_c( xSize ) ]; - real_t * WALBERLA_RESTRICT feq_common = new real_t[ xSize ]; + real_t * WALBERLA_RESTRICT feq_common = new real_t[ uint_c( xSize ) ]; if( src->layout() == field::fzyx ) { diff --git a/src/lbm/trt/SplitSweep.impl.h b/src/lbm/trt/SplitSweep.impl.h index f33ef64ab34d7110ddb12b648b1c02c897cfbe25..fed687b167e9f1f89e20d7e64d63ce3941732cf4 100644 --- a/src/lbm/trt/SplitSweep.impl.h +++ b/src/lbm/trt/SplitSweep.impl.h @@ -134,13 +134,13 @@ void SplitSweep< LatticeModel_T, FlagField_T, typename boost::enable_if< boost:: #endif // temporaries, calculated by the first innermost loop - real_t * WALBERLA_RESTRICT velX = new real_t[ xSize ]; - real_t * WALBERLA_RESTRICT velY = new real_t[ xSize ]; - real_t * WALBERLA_RESTRICT velZ = new real_t[ xSize ]; + real_t * WALBERLA_RESTRICT velX = new real_t[ uint_c(xSize) ]; + real_t * WALBERLA_RESTRICT velY = new real_t[ uint_c(xSize) ]; + real_t * WALBERLA_RESTRICT velZ = new real_t[ uint_c(xSize) ]; - real_t * WALBERLA_RESTRICT feq_common = new real_t[ xSize ]; + real_t * WALBERLA_RESTRICT feq_common = new real_t[ uint_c(xSize) ]; - bool * WALBERLA_RESTRICT perform_lbm = new bool[ xSize ]; + bool * WALBERLA_RESTRICT perform_lbm = new bool[ uint_c(xSize) ]; if( src->layout() == field::fzyx && dst->layout() == field::fzyx ) { @@ -611,13 +611,13 @@ void SplitSweep< LatticeModel_T, FlagField_T, typename boost::enable_if< boost:: #endif // temporaries, calculated by the first innermost loop - real_t * WALBERLA_RESTRICT velX = new real_t[ xSize ]; - real_t * WALBERLA_RESTRICT velY = new real_t[ xSize ]; - real_t * WALBERLA_RESTRICT velZ = new real_t[ xSize ]; + real_t * WALBERLA_RESTRICT velX = new real_t[ uint_c(xSize) ]; + real_t * WALBERLA_RESTRICT velY = new real_t[ uint_c(xSize) ]; + real_t * WALBERLA_RESTRICT velZ = new real_t[ uint_c(xSize) ]; - real_t * WALBERLA_RESTRICT feq_common = new real_t[ xSize ]; + real_t * WALBERLA_RESTRICT feq_common = new real_t[ uint_c(xSize) ]; - bool * WALBERLA_RESTRICT perform_lbm = new bool[ xSize ]; + bool * WALBERLA_RESTRICT perform_lbm = new bool[ uint_c(xSize) ]; if( src->layout() == field::fzyx ) { @@ -1074,18 +1074,18 @@ void SplitSweep< LatticeModel_T, FlagField_T, typename boost::enable_if< boost:: #endif // temporaries, calculated by the first innermost loop - real_t * WALBERLA_RESTRICT velX = new real_t[ xSize ]; - real_t * WALBERLA_RESTRICT velY = new real_t[ xSize ]; - real_t * WALBERLA_RESTRICT velZ = new real_t[ xSize ]; + real_t * WALBERLA_RESTRICT velX = new real_t[ uint_c(xSize) ]; + real_t * WALBERLA_RESTRICT velY = new real_t[ uint_c(xSize) ]; + real_t * WALBERLA_RESTRICT velZ = new real_t[ uint_c(xSize) ]; - real_t * WALBERLA_RESTRICT t1x2 = new real_t[ xSize ]; - real_t * WALBERLA_RESTRICT t2x2 = new real_t[ xSize ]; - real_t * WALBERLA_RESTRICT fac1 = new real_t[ xSize ]; - real_t * WALBERLA_RESTRICT fac2 = new real_t[ xSize ]; + real_t * WALBERLA_RESTRICT t1x2 = new real_t[ uint_c(xSize) ]; + real_t * WALBERLA_RESTRICT t2x2 = new real_t[ uint_c(xSize) ]; + real_t * WALBERLA_RESTRICT fac1 = new real_t[ uint_c(xSize) ]; + real_t * WALBERLA_RESTRICT fac2 = new real_t[ uint_c(xSize) ]; - real_t * WALBERLA_RESTRICT feq_common = new real_t[ xSize ]; + real_t * WALBERLA_RESTRICT feq_common = new real_t[ uint_c(xSize) ]; - bool * WALBERLA_RESTRICT perform_lbm = new bool[ xSize ]; + bool * WALBERLA_RESTRICT perform_lbm = new bool[ uint_c(xSize) ]; if( src->layout() == field::fzyx && dst->layout() == field::fzyx ) { @@ -1570,18 +1570,18 @@ void SplitSweep< LatticeModel_T, FlagField_T, typename boost::enable_if< boost:: #endif // temporaries, calculated by the first innermost loop - real_t * WALBERLA_RESTRICT velX = new real_t[ xSize ]; - real_t * WALBERLA_RESTRICT velY = new real_t[ xSize ]; - real_t * WALBERLA_RESTRICT velZ = new real_t[ xSize ]; + real_t * WALBERLA_RESTRICT velX = new real_t[ uint_c(xSize) ]; + real_t * WALBERLA_RESTRICT velY = new real_t[ uint_c(xSize) ]; + real_t * WALBERLA_RESTRICT velZ = new real_t[ uint_c(xSize) ]; - real_t * WALBERLA_RESTRICT t1x2 = new real_t[ xSize ]; - real_t * WALBERLA_RESTRICT t2x2 = new real_t[ xSize ]; - real_t * WALBERLA_RESTRICT fac1 = new real_t[ xSize ]; - real_t * WALBERLA_RESTRICT fac2 = new real_t[ xSize ]; + real_t * WALBERLA_RESTRICT t1x2 = new real_t[ uint_c(xSize) ]; + real_t * WALBERLA_RESTRICT t2x2 = new real_t[ uint_c(xSize) ]; + real_t * WALBERLA_RESTRICT fac1 = new real_t[ uint_c(xSize) ]; + real_t * WALBERLA_RESTRICT fac2 = new real_t[ uint_c(xSize) ]; - real_t * WALBERLA_RESTRICT feq_common = new real_t[ xSize ]; + real_t * WALBERLA_RESTRICT feq_common = new real_t[ uint_c(xSize) ]; - bool * WALBERLA_RESTRICT perform_lbm = new bool[ xSize ]; + bool * WALBERLA_RESTRICT perform_lbm = new bool[ uint_c(xSize) ]; if( src->layout() == field::fzyx ) { diff --git a/src/lbm/trt/bluegeneq/SplitPureSweep.impl.h b/src/lbm/trt/bluegeneq/SplitPureSweep.impl.h index 985667314552ca883d1115df4e4a45526c06f921..ca3821096a692da7bc61322f53e4b68a910e825a 100644 --- a/src/lbm/trt/bluegeneq/SplitPureSweep.impl.h +++ b/src/lbm/trt/bluegeneq/SplitPureSweep.impl.h @@ -151,11 +151,11 @@ void SplitPureSweep< LatticeModel_T, typename boost::enable_if_c< ice_and< boost #endif // temporaries, calculated by the first innermost loop - real_t* velX = new real_t[ xSize ]; - real_t* velY = new real_t[ xSize ]; - real_t* velZ = new real_t[ xSize ]; + real_t* velX = new real_t[ uint_c(xSize) ]; + real_t* velY = new real_t[ uint_c(xSize) ]; + real_t* velZ = new real_t[ uint_c(xSize) ]; - real_t* feq_common = new real_t[ xSize ]; + real_t* feq_common = new real_t[ uint_c(xSize) ]; if( src->layout() == field::fzyx && dst->layout() == field::fzyx ) { @@ -687,11 +687,11 @@ void SplitPureSweep< LatticeModel_T, typename boost::enable_if_c< ice_and< boost #endif // temporaries, calculated by the first innermost loop - real_t* velX = new real_t[ xSize ]; - real_t* velY = new real_t[ xSize ]; - real_t* velZ = new real_t[ xSize ]; + real_t* velX = new real_t[ uint_c(xSize) ]; + real_t* velY = new real_t[ uint_c(xSize) ]; + real_t* velZ = new real_t[ uint_c(xSize) ]; - real_t* feq_common = new real_t[ xSize ]; + real_t* feq_common = new real_t[ uint_c(xSize) ]; if( src->layout() == field::fzyx ) { @@ -1140,16 +1140,16 @@ void SplitPureSweep< LatticeModel_T, typename boost::enable_if_c< ice_and< boost #endif // temporaries, calculated by the first innermost loop - real_t* velX = new real_t[ xSize ]; - real_t* velY = new real_t[ xSize ]; - real_t* velZ = new real_t[ xSize ]; + real_t* velX = new real_t[ uint_c(xSize) ]; + real_t* velY = new real_t[ uint_c(xSize) ]; + real_t* velZ = new real_t[ uint_c(xSize) ]; - real_t* t1x2 = new real_t[ xSize ]; - real_t* t2x2 = new real_t[ xSize ]; - real_t* fac1 = new real_t[ xSize ]; - real_t* fac2 = new real_t[ xSize ]; + real_t* t1x2 = new real_t[ uint_c(xSize) ]; + real_t* t2x2 = new real_t[ uint_c(xSize) ]; + real_t* fac1 = new real_t[ uint_c(xSize) ]; + real_t* fac2 = new real_t[ uint_c(xSize) ]; - real_t* feq_common = new real_t[ xSize ]; + real_t* feq_common = new real_t[ uint_c(xSize) ]; if( src->layout() == field::fzyx && dst->layout() == field::fzyx ) { @@ -1699,16 +1699,16 @@ void SplitPureSweep< LatticeModel_T, typename boost::enable_if_c< ice_and< boost #endif // temporaries, calculated by the first innermost loop - real_t* velX = new real_t[ xSize ]; - real_t* velY = new real_t[ xSize ]; - real_t* velZ = new real_t[ xSize ]; + real_t* velX = new real_t[ uint_c(xSize) ]; + real_t* velY = new real_t[ uint_c(xSize) ]; + real_t* velZ = new real_t[ uint_c(xSize) ]; - real_t* t1x2 = new real_t[ xSize ]; - real_t* t2x2 = new real_t[ xSize ]; - real_t* fac1 = new real_t[ xSize ]; - real_t* fac2 = new real_t[ xSize ]; + real_t* t1x2 = new real_t[ uint_c(xSize) ]; + real_t* t2x2 = new real_t[ uint_c(xSize) ]; + real_t* fac1 = new real_t[ uint_c(xSize) ]; + real_t* fac2 = new real_t[ uint_c(xSize) ]; - real_t* feq_common = new real_t[ xSize ]; + real_t* feq_common = new real_t[ uint_c(xSize) ]; if( src->layout() == field::fzyx ) { diff --git a/src/mesh/MeshIO.h b/src/mesh/MeshIO.h index 493276526791bae35fae634563c112ccc7b7374c..119fdddff7538133b1855c17f170379536de7656 100644 --- a/src/mesh/MeshIO.h +++ b/src/mesh/MeshIO.h @@ -28,7 +28,7 @@ #include <fstream> #include <string> -#include <boost/filesystem.hpp> +#include "core/Filesystem.h" #ifdef _MSC_VER # pragma warning(push) @@ -57,10 +57,10 @@ namespace mesh { template< typename MeshType > void readAndBroadcast( const std::string & filename, MeshType & mesh ) { - if( !boost::filesystem::exists( filename ) ) + if( !filesystem::exists( filename ) ) WALBERLA_ABORT( "The mesh file \"" << filename << "\" does not exist!" ); - std::string extension = boost::filesystem::extension( filename ); + std::string extension = filesystem::path( filename ).extension().string(); std::string str; diff --git a/src/mesh/boundary/BoundarySetup.h b/src/mesh/boundary/BoundarySetup.h index 26254df4ec3cfeaa65a7f9c1937f777854960f98..08840ed0ae24502e7248d9831351b955d15f0d30 100644 --- a/src/mesh/boundary/BoundarySetup.h +++ b/src/mesh/boundary/BoundarySetup.h @@ -34,7 +34,7 @@ #include "stencil/D3Q27.h" -#include <boost/function.hpp> +#include <functional> #include <queue> @@ -46,7 +46,7 @@ class BoundarySetup public: typedef field::GhostLayerField< uint8_t, uint_t(1) > VoxelizationField; - typedef boost::function< real_t ( const Vector3< real_t > &) > DistanceFunction; + typedef std::function< real_t ( const Vector3< real_t > &) > DistanceFunction; enum Location { INSIDE, OUTSIDE }; diff --git a/src/mesh/pe/vtk/CommonDataSources.h b/src/mesh/pe/vtk/CommonDataSources.h index 3449740a315722ea6b031d704c1fbd29cc9d9c0b..d2454c15cd6a59e836e6f97dba550b0d6696281e 100644 --- a/src/mesh/pe/vtk/CommonDataSources.h +++ b/src/mesh/pe/vtk/CommonDataSources.h @@ -38,6 +38,115 @@ namespace walberla { namespace mesh { namespace pe { +template< typename MeshType, typename Tesselation, typename OutputType = uint64_t > +class SIDVertexDataSource : public PeVTKMeshWriter<MeshType, Tesselation>::template VertexDataSource< OutputType > +{ +public: + typedef typename PeVTKMeshWriter<MeshType, Tesselation>::template VertexDataSource< OutputType > Base; + typedef typename Base::Vertices Vertices; + typedef typename Base::value_type value_type; + typedef typename Base::BodyPointerVPropManager BodyPointerVPropManager; + + SIDVertexDataSource( const std::string & _name = "sid" ) + : Base( _name ) { } + + virtual uint_t numComponents() { return uint_t(1); } + + virtual void getData( const MeshType & /*mesh*/, const Vertices & vertices, std::vector<value_type> & data, const BodyPointerVPropManager & bodyPointer ) + { + data.reserve( vertices.size() ); + + for( auto it = vertices.begin(); it != vertices.end(); ++it ) + { + const auto & v = bodyPointer[*it]->getSystemID(); + data.push_back( numeric_cast<OutputType>( v ) ); + } + } +}; + + +template< typename MeshType, typename Tesselation, typename OutputType = uint64_t > +class SIDFaceDataSource : public PeVTKMeshWriter<MeshType, Tesselation>::template FaceDataSource< OutputType > +{ +public: + typedef typename PeVTKMeshWriter<MeshType, Tesselation>::template FaceDataSource< OutputType > Base; + typedef typename Base::Faces Faces; + typedef typename Base::value_type value_type; + typedef typename Base::BodyPointerFPropManager BodyPointerFPropManager; + + SIDFaceDataSource( const std::string & _name = "sid" ) + : Base( _name ) { } + + virtual uint_t numComponents() { return uint_t(1); } + + virtual void getData( const MeshType & /*mesh*/, const Faces & faces, std::vector<value_type> & data, const BodyPointerFPropManager & bodyPointer ) + { + data.reserve( faces.size() ); + + for( auto it = faces.begin(); it != faces.end(); ++it ) + { + const auto & v = bodyPointer[*it]->getSystemID(); + + data.push_back( numeric_cast<OutputType>( v ) ); + } + } +}; + +template< typename MeshType, typename Tesselation, typename OutputType = uint64_t > +class UIDVertexDataSource : public PeVTKMeshWriter<MeshType, Tesselation>::template VertexDataSource< OutputType > +{ +public: + typedef typename PeVTKMeshWriter<MeshType, Tesselation>::template VertexDataSource< OutputType > Base; + typedef typename Base::Vertices Vertices; + typedef typename Base::value_type value_type; + typedef typename Base::BodyPointerVPropManager BodyPointerVPropManager; + + UIDVertexDataSource( const std::string & _name = "uid" ) + : Base( _name ) { } + + virtual uint_t numComponents() { return uint_t(1); } + + virtual void getData( const MeshType & /*mesh*/, const Vertices & vertices, std::vector<value_type> & data, const BodyPointerVPropManager & bodyPointer ) + { + data.reserve( vertices.size() ); + + for( auto it = vertices.begin(); it != vertices.end(); ++it ) + { + const auto & v = bodyPointer[*it]->getID(); + data.push_back( numeric_cast<OutputType>( v ) ); + } + } +}; + + +template< typename MeshType, typename Tesselation, typename OutputType = uint64_t > +class UIDFaceDataSource : public PeVTKMeshWriter<MeshType, Tesselation>::template FaceDataSource< OutputType > +{ +public: + typedef typename PeVTKMeshWriter<MeshType, Tesselation>::template FaceDataSource< OutputType > Base; + typedef typename Base::Faces Faces; + typedef typename Base::value_type value_type; + typedef typename Base::BodyPointerFPropManager BodyPointerFPropManager; + + UIDFaceDataSource( const std::string & _name = "uid" ) + : Base( _name ) { } + + virtual uint_t numComponents() { return uint_t(1); } + + virtual void getData( const MeshType & /*mesh*/, const Faces & faces, std::vector<value_type> & data, const BodyPointerFPropManager & bodyPointer ) + { + data.reserve( faces.size() ); + + for( auto it = faces.begin(); it != faces.end(); ++it ) + { + const auto & v = bodyPointer[*it]->getID(); + + data.push_back( numeric_cast<OutputType>( v ) ); + } + } +}; + + template< typename MeshType, typename Tesselation, typename OutputType = real_t > class LinearVelocityVertexDataSource : public PeVTKMeshWriter<MeshType, Tesselation>::template VertexDataSource< OutputType > { @@ -190,4 +299,4 @@ public: } // namespace pe } // namespace mesh -} // namespace walberla \ No newline at end of file +} // namespace walberla diff --git a/src/mesh/python/Exports.impl.h b/src/mesh/python/Exports.impl.h index 5b76ff0819c1dd9f79f7d28671b9ad415e76f3b4..d47cd2f7da53984c33cf93b8df31fb8e832f110c 100644 --- a/src/mesh/python/Exports.impl.h +++ b/src/mesh/python/Exports.impl.h @@ -151,7 +151,6 @@ void exportModuleToPython() ; - } diff --git a/src/mesh/vtk/VTKMeshWriter.h b/src/mesh/vtk/VTKMeshWriter.h index f01a65bebfe5bf0fa30df0e15ae1a4fc788aa243..cf01acf7e4c5451faa2459703a845228f9a9a8e0 100644 --- a/src/mesh/vtk/VTKMeshWriter.h +++ b/src/mesh/vtk/VTKMeshWriter.h @@ -29,7 +29,7 @@ #include "vtk/Base64Writer.h" #include "vtk/UtilityFunctions.h" -#include <boost/filesystem.hpp> +#include "core/Filesystem.h" #include <iostream> #include <vector> @@ -42,7 +42,7 @@ namespace mesh { template< typename MeshType > class VTKMeshWriter { public: - typedef boost::function<bool ( const MeshType &, const typename MeshType::FaceHandle & )> FaceFilterFunction; + typedef std::function<bool ( const MeshType &, const typename MeshType::FaceHandle & )> FaceFilterFunction; typedef std::vector< typename MeshType::FaceHandle > Faces; typedef std::vector< typename MeshType::VertexHandle > Vertices; @@ -90,15 +90,17 @@ public: inline void addDataSource( const shared_ptr< VertexDataSource<double> > & dataSource ) { doubleVertexDataSources_.push_back( dataSource ); } inline void addDataSource( const shared_ptr< VertexDataSource<int32_t> > & dataSource ) { int32VertexDataSources_.push_back( dataSource ); } inline void addDataSource( const shared_ptr< VertexDataSource<uint8_t> > & dataSource ) { uint8VertexDataSources_.push_back( dataSource ); } + inline void addDataSource( const shared_ptr< VertexDataSource<uint64_t> > & dataSource ) { uint64VertexDataSources_.push_back( dataSource ); } inline void addDataSource( const shared_ptr< FaceDataSource<float> > & dataSource ) { floatFaceDataSources_.push_back( dataSource ); } inline void addDataSource( const shared_ptr< FaceDataSource<double> > & dataSource ) { doubleFaceDataSources_.push_back( dataSource ); } inline void addDataSource( const shared_ptr< FaceDataSource<int32_t> > & dataSource ) { int32FaceDataSources_.push_back( dataSource ); } inline void addDataSource( const shared_ptr< FaceDataSource<uint8_t> > & dataSource ) { uint8FaceDataSources_.push_back( dataSource ); } + inline void addDataSource( const shared_ptr< FaceDataSource<uint64_t> > & dataSource ) { uint64FaceDataSources_.push_back( dataSource ); } inline void setFaceFilter ( const FaceFilterFunction & f ) { faceFilter_ = f; } inline void clearFaceFilter() { faceFilter_ = FaceFilterFunction(); } - inline bool isFaceFilterSet() const { return !faceFilter_.empty(); } + inline bool isFaceFilterSet() const { return static_cast<bool>(faceFilter_); } void incrementTimeStep() { ++timestep_; } bool isWriteScheduled() const { return timestep_ % writeFrequency_ == 0; } @@ -127,15 +129,17 @@ protected: FaceFilterFunction faceFilter_; - std::vector< shared_ptr< VertexDataSource<float > > > floatVertexDataSources_; - std::vector< shared_ptr< VertexDataSource<double > > > doubleVertexDataSources_; - std::vector< shared_ptr< VertexDataSource<int32_t> > > int32VertexDataSources_; - std::vector< shared_ptr< VertexDataSource<uint8_t> > > uint8VertexDataSources_; - - std::vector< shared_ptr< FaceDataSource<float > > > floatFaceDataSources_; - std::vector< shared_ptr< FaceDataSource<double > > > doubleFaceDataSources_; - std::vector< shared_ptr< FaceDataSource<int32_t> > > int32FaceDataSources_; - std::vector< shared_ptr< FaceDataSource<uint8_t> > > uint8FaceDataSources_; + std::vector< shared_ptr< VertexDataSource<float > > > floatVertexDataSources_; + std::vector< shared_ptr< VertexDataSource<double > > > doubleVertexDataSources_; + std::vector< shared_ptr< VertexDataSource<int32_t> > > int32VertexDataSources_; + std::vector< shared_ptr< VertexDataSource<uint8_t> > > uint8VertexDataSources_; + std::vector< shared_ptr< VertexDataSource<uint64_t> > > uint64VertexDataSources_; + + std::vector< shared_ptr< FaceDataSource<float > > > floatFaceDataSources_; + std::vector< shared_ptr< FaceDataSource<double > > > doubleFaceDataSources_; + std::vector< shared_ptr< FaceDataSource<int32_t> > > int32FaceDataSources_; + std::vector< shared_ptr< FaceDataSource<uint8_t> > > uint8FaceDataSources_; + std::vector< shared_ptr< FaceDataSource<uint64_t> > > uint64FaceDataSources_; }; @@ -194,15 +198,15 @@ VTKMeshWriter<MeshType>::VTKMeshWriter( const shared_ptr<const MeshType> & mesh, { std::ostringstream folder; folder << baseFolder_ << '/' << identifier_; - if( boost::filesystem::exists( folder.str() ) ) - boost::filesystem::remove_all( folder.str() ); + if( filesystem::exists( folder.str() ) ) + filesystem::remove_all( folder.str() ); std::ostringstream pvdFile; pvdFile << baseFolder_ << '/' << identifier_ << ".pvd"; - if( boost::filesystem::exists( pvdFile.str() ) ) - boost::filesystem::remove( pvdFile.str() ); + if( filesystem::exists( pvdFile.str() ) ) + filesystem::remove( pvdFile.str() ); - boost::filesystem::create_directories( folder.str() ); + filesystem::create_directories( folder.str() ); } WALBERLA_MPI_BARRIER(); } @@ -303,19 +307,21 @@ void VTKMeshWriter<MeshType>::writePiece( std::ostream & os ) const os << " <CellData>\n"; - writeFaceData( floatFaceDataSources_ , faces, os, b64 ); - writeFaceData( doubleFaceDataSources_, faces, os, b64 ); - writeFaceData( int32FaceDataSources_ , faces, os, b64 ); - writeFaceData( uint8FaceDataSources_ , faces, os, b64 ); + writeFaceData( floatFaceDataSources_ , faces, os, b64 ); + writeFaceData( doubleFaceDataSources_, faces, os, b64 ); + writeFaceData( int32FaceDataSources_ , faces, os, b64 ); + writeFaceData( uint8FaceDataSources_ , faces, os, b64 ); + writeFaceData( uint64FaceDataSources_ , faces, os, b64 ); os << " </CellData>\n"; os << " <PointData>\n"; - writeVertexData( floatVertexDataSources_ , vertices, os, b64 ); - writeVertexData( doubleVertexDataSources_, vertices, os, b64 ); - writeVertexData( int32VertexDataSources_ , vertices, os, b64 ); - writeVertexData( uint8VertexDataSources_ , vertices, os, b64 ); + writeVertexData( floatVertexDataSources_ , vertices, os, b64 ); + writeVertexData( doubleVertexDataSources_, vertices, os, b64 ); + writeVertexData( int32VertexDataSources_ , vertices, os, b64 ); + writeVertexData( uint8VertexDataSources_ , vertices, os, b64 ); + writeVertexData( uint64VertexDataSources_ , vertices, os, b64 ); os << " </PointData>\n"; @@ -376,4 +382,4 @@ void VTKMeshWriter<MeshType>::operator()() } // namespace mesh -} // namespace walberla \ No newline at end of file +} // namespace walberla diff --git a/src/pde/iterations/CGFixedStencilIteration.h b/src/pde/iterations/CGFixedStencilIteration.h index b7c5ac85fbfa17ec775841822f5d8fcf14fc7531..145fa37c80515a9745265d9b12a652abbf733d19 100644 --- a/src/pde/iterations/CGFixedStencilIteration.h +++ b/src/pde/iterations/CGFixedStencilIteration.h @@ -31,7 +31,7 @@ #include "field/GhostLayerField.h" #include "field/iterators/IteratorMacros.h" -#include <boost/function.hpp> +#include <functional> @@ -50,7 +50,7 @@ public: CGFixedStencilIteration( BlockStorage & blocks, const BlockDataID & uId, const BlockDataID & rId, const BlockDataID & dId, const BlockDataID & zId, const BlockDataID & fId, const std::vector< real_t > & weights, - const uint_t iterations, const boost::function< void () > & synchronizeD, + const uint_t iterations, const std::function< void () > & synchronizeD, const real_t residualNormThreshold = real_t(0), const Set<SUID> & requiredSelectors = Set<SUID>::emptySet(), const Set<SUID> & incompatibleSelectors = Set<SUID>::emptySet() ); @@ -88,7 +88,7 @@ protected: uint_t iterations_; real_t residualNormThreshold_; - boost::function< void () > synchronizeD_; + std::function< void () > synchronizeD_; Set<SUID> requiredSelectors_; Set<SUID> incompatibleSelectors_; @@ -100,7 +100,7 @@ template< typename Stencil_T > CGFixedStencilIteration< Stencil_T >::CGFixedStencilIteration( BlockStorage & blocks, const BlockDataID & uId, const BlockDataID & rId, const BlockDataID & dId, const BlockDataID & zId, const BlockDataID & fId, const std::vector< real_t > & weights, - const uint_t iterations, const boost::function< void () > & synchronizeD, + const uint_t iterations, const std::function< void () > & synchronizeD, const real_t residualNormThreshold, const Set<SUID> & requiredSelectors, const Set<SUID> & incompatibleSelectors ) : blocks_( blocks ), uId_( uId ), rId_( rId ), dId_( dId ), zId_( zId ), fId_( fId ), diff --git a/src/pde/iterations/CGIteration.h b/src/pde/iterations/CGIteration.h index 2a0afaf23bb81526e8f4468fa3a7bbc6c015a387..d3339759bb7b2998a22eb6e281704ef583a98715 100644 --- a/src/pde/iterations/CGIteration.h +++ b/src/pde/iterations/CGIteration.h @@ -31,7 +31,7 @@ #include "field/GhostLayerField.h" #include "field/iterators/IteratorMacros.h" -#include <boost/function.hpp> +#include <functional> @@ -51,7 +51,7 @@ public: CGIteration( BlockStorage & blocks, const BlockDataID & uId, const BlockDataID & rId, const BlockDataID & dId, const BlockDataID & zId, const BlockDataID & fId, const BlockDataID & stencilId, - const uint_t iterations, const boost::function< void () > & synchronizeD, + const uint_t iterations, const std::function< void () > & synchronizeD, const real_t residualNormThreshold = real_t(0), const Set<SUID> & requiredSelectors = Set<SUID>::emptySet(), const Set<SUID> & incompatibleSelectors = Set<SUID>::emptySet() ); @@ -88,7 +88,7 @@ protected: uint_t iterations_; real_t residualNormThreshold_; - boost::function< void () > synchronizeD_; + std::function< void () > synchronizeD_; Set<SUID> requiredSelectors_; Set<SUID> incompatibleSelectors_; @@ -100,7 +100,7 @@ template< typename Stencil_T > CGIteration< Stencil_T >::CGIteration( BlockStorage & blocks, const BlockDataID & uId, const BlockDataID & rId, const BlockDataID & dId, const BlockDataID & zId, const BlockDataID & fId, const BlockDataID & stencilId, - const uint_t iterations, const boost::function< void () > & synchronizeD, + const uint_t iterations, const std::function< void () > & synchronizeD, const real_t residualNormThreshold, const Set<SUID> & requiredSelectors, const Set<SUID> & incompatibleSelectors ) : blocks_( blocks ), uId_( uId ), rId_( rId ), dId_( dId ), zId_( zId ), fId_( fId ), stencilId_( stencilId ), diff --git a/src/pde/iterations/JacobiIteration.cpp b/src/pde/iterations/JacobiIteration.cpp index f3044457e4c1672a3263c349db2de980b4c1a553..f088ebe3110c14891d7e6620e62319e117ebdf1d 100644 --- a/src/pde/iterations/JacobiIteration.cpp +++ b/src/pde/iterations/JacobiIteration.cpp @@ -37,7 +37,7 @@ void JacobiIteration::operator()() uint_t i( uint_t(0) ); while( i < iterations_ ) { - if( !boundary_.empty() ) + if( boundary_ ) boundary_(); communication_(); @@ -48,7 +48,7 @@ void JacobiIteration::operator()() { if( (i % residualCheckFrequency_) == uint_t(0) ) { - if( !boundary_.empty() ) + if( boundary_ ) boundary_(); const real_t residualNorm = residualNorm_(); WALBERLA_CHECK( math::finite(residualNorm), "Non-finite residual norm detected during the Jacobi iteration, " diff --git a/src/pde/iterations/JacobiIteration.h b/src/pde/iterations/JacobiIteration.h index 3f30bcd85b21039576eefa1e3660744b13de4845..3002e7ff33c13c7dfcd5da50238828809e74c45c 100644 --- a/src/pde/iterations/JacobiIteration.h +++ b/src/pde/iterations/JacobiIteration.h @@ -25,7 +25,7 @@ #include "core/uid/SUID.h" #include "domain_decomposition/BlockStorage.h" -#include <boost/function.hpp> +#include <functional> @@ -39,9 +39,9 @@ class JacobiIteration public: JacobiIteration( BlockStorage & blocks, const uint_t iterations, - const boost::function< void () > & communication, - const boost::function< void ( IBlock * ) > & jacobi, - const boost::function< real_t () > & residualNorm, + const std::function< void () > & communication, + const std::function< void ( IBlock * ) > & jacobi, + const std::function< real_t () > & residualNorm, const real_t residualNormThreshold = real_t(0), const uint_t residualCheckFrequency = uint_t(1), const Set<SUID> & requiredSelectors = Set<SUID>::emptySet(), const Set<SUID> & incompatibleSelectors = Set<SUID>::emptySet() ) : @@ -51,7 +51,7 @@ public: requiredSelectors_( requiredSelectors ), incompatibleSelectors_( incompatibleSelectors ) {} - void addBoundaryHandling( const boost::function< void () > & boundary ) { boundary_ = boundary; } + void addBoundaryHandling( const std::function< void () > & boundary ) { boundary_ = boundary; } void operator()(); @@ -63,10 +63,10 @@ protected: real_t residualNormThreshold_; uint_t residualCheckFrequency_; - boost::function< void () > boundary_; - boost::function< void () > communication_; - boost::function< void ( IBlock * ) > jacobi_; - boost::function< real_t () > residualNorm_; + std::function< void () > boundary_; + std::function< void () > communication_; + std::function< void ( IBlock * ) > jacobi_; + std::function< real_t () > residualNorm_; Set<SUID> requiredSelectors_; Set<SUID> incompatibleSelectors_; diff --git a/src/pde/iterations/RBGSIteration.cpp b/src/pde/iterations/RBGSIteration.cpp index 7994b633128a3eeec52ceea4abc12870db0f66bc..18c503db781cf4e73f21731c558dc052796c72ee 100644 --- a/src/pde/iterations/RBGSIteration.cpp +++ b/src/pde/iterations/RBGSIteration.cpp @@ -40,14 +40,14 @@ void RBGSIteration::operator()() uint_t i( uint_t(0) ); while( i < iterations_ ) { - if( !boundary_.empty() ) + if( boundary_ ) boundary_(); communication_(); for( auto block = blocks_.begin( requiredSelectors_, incompatibleSelectors_ ); block != blocks_.end(); ++block ) redUpdate_( block.get() ); - if( !boundary_.empty() ) + if( boundary_ ) boundary_(); communication_(); @@ -58,7 +58,7 @@ void RBGSIteration::operator()() { if( (i % residualCheckFrequency_) == uint_t(0) ) { - if( !boundary_.empty() ) + if( boundary_ ) boundary_(); const real_t residualNorm = residualNorm_(); WALBERLA_CHECK( math::finite(residualNorm), "Non-finite residual norm detected during the red-black Gauss-Seidel iteration, " diff --git a/src/pde/iterations/RBGSIteration.h b/src/pde/iterations/RBGSIteration.h index aaae718913b99ca1006d37b1ac0f224e5b7dcaac..9f4ee04e7e9f3aa7f4584263e6d6603716d14b32 100644 --- a/src/pde/iterations/RBGSIteration.h +++ b/src/pde/iterations/RBGSIteration.h @@ -25,7 +25,7 @@ #include "core/uid/SUID.h" #include "domain_decomposition/BlockStorage.h" -#include <boost/function.hpp> +#include <functional> @@ -39,10 +39,10 @@ class RBGSIteration public: RBGSIteration( BlockStorage & blocks, const uint_t iterations, - const boost::function< void () > & communication, - const boost::function< void ( IBlock * ) > & redUpdate, - const boost::function< void ( IBlock * ) > & blackUpdate, - const boost::function< real_t () > & residualNorm, + const std::function< void () > & communication, + const std::function< void ( IBlock * ) > & redUpdate, + const std::function< void ( IBlock * ) > & blackUpdate, + const std::function< real_t () > & residualNorm, const real_t residualNormThreshold = real_t(0), const uint_t residualCheckFrequency = uint_t(1), const Set<SUID> & requiredSelectors = Set<SUID>::emptySet(), const Set<SUID> & incompatibleSelectors = Set<SUID>::emptySet() ) : @@ -53,7 +53,7 @@ public: requiredSelectors_( requiredSelectors ), incompatibleSelectors_( incompatibleSelectors ) {} - void addBoundaryHandling( const boost::function< void () > & boundary ) { boundary_ = boundary; } + void addBoundaryHandling( const std::function< void () > & boundary ) { boundary_ = boundary; } void operator()(); @@ -71,11 +71,11 @@ protected: uint_t iterationsPerformed_; bool thresholdReached_; - boost::function< void () > boundary_; - boost::function< void () > communication_; - boost::function< void ( IBlock * ) > redUpdate_; - boost::function< void ( IBlock * ) > blackUpdate_; - boost::function< real_t () > residualNorm_; + std::function< void () > boundary_; + std::function< void () > communication_; + std::function< void ( IBlock * ) > redUpdate_; + std::function< void ( IBlock * ) > blackUpdate_; + std::function< real_t () > residualNorm_; Set<SUID> requiredSelectors_; Set<SUID> incompatibleSelectors_; diff --git a/src/pde/iterations/VCycles.h b/src/pde/iterations/VCycles.h index 161af67115994d5a5ea20275198e04de7e97491c..eca2b908fc5420cb24b1889e0bba71c2c2cbe86d 100644 --- a/src/pde/iterations/VCycles.h +++ b/src/pde/iterations/VCycles.h @@ -33,7 +33,7 @@ #include "pde/sweeps/RBGSFixedStencil.h" #include "pde/sweeps/RBGS.h" -#include <boost/function.hpp> +#include <functional> #include <vector> @@ -54,7 +54,7 @@ public: const Weight_T weights, const uint_t iterations, const uint_t numLvl, const uint_t preSmoothingIters, const uint_t postSmoothingIters, - const uint_t coarseIters, const boost::function< real_t () > & residualNorm, + const uint_t coarseIters, const std::function< real_t () > & residualNorm, const real_t residualNormThreshold = real_t(0), const uint_t residualCheckFrequency = uint_t(1), const Set<SUID> & requiredSelectors = Set<SUID>::emptySet(), const Set<SUID> & incompatibleSelectors = Set<SUID>::emptySet() ); @@ -63,7 +63,7 @@ public: const BlockDataID & stencilFieldId, const uint_t iterations, const uint_t numLvl, const uint_t preSmoothingIters, const uint_t postSmoothingIters, - const uint_t coarseIters, const boost::function< real_t () > & residualNorm, + const uint_t coarseIters, const std::function< real_t () > & residualNorm, const real_t residualNormThreshold = real_t(0), const uint_t residualCheckFrequency = uint_t(1), const Set<SUID> & requiredSelectors = Set<SUID>::emptySet(), const Set<SUID> & incompatibleSelectors = Set<SUID>::emptySet() ); @@ -94,7 +94,7 @@ protected: uint_t iterationsPerformed_; bool thresholdReached_; - boost::function< real_t() > residualNorm_; + std::function< real_t() > residualNorm_; std::vector<real_t> convergenceRate_; std::vector<BlockDataID> uId_; @@ -105,9 +105,9 @@ protected: std::vector< shared_ptr<pde::RBGSFixedStencil< Stencil_T > > > RBGSFixedSweeps_; std::vector< shared_ptr<pde::RBGS< Stencil_T > > > RBGSSweeps_; - std::vector< boost::function< void() > > RBGSIteration_; - boost::function< void() > CGIteration_; - std::vector<boost::function< void(IBlock *) > > computeResidual_, restrict_, zeroize_, prolongateAndCorrect_; + std::vector< std::function< void() > > RBGSIteration_; + std::function< void() > CGIteration_; + std::vector<std::function< void(IBlock *) > > computeResidual_, restrict_, zeroize_, prolongateAndCorrect_; std::vector< blockforest::communication::UniformBufferedScheme< Stencil_T > > communication_; diff --git a/src/pde/iterations/VCycles.impl.h b/src/pde/iterations/VCycles.impl.h index 8ad0833d4f9c4f1173f32a9dd4a2d011b6c8fa07..a35cf35779f8dd3396a6792a4fedeaad7e7957e3 100644 --- a/src/pde/iterations/VCycles.impl.h +++ b/src/pde/iterations/VCycles.impl.h @@ -44,7 +44,7 @@ VCycles< Stencil_T >::VCycles( shared_ptr< StructuredBlockForest > blocks, const const Weight_T weights, const uint_t iterations, const uint_t numLvl, const uint_t preSmoothingIters, const uint_t postSmoothingIters, - const uint_t coarseIters, const boost::function< real_t () > & residualNorm, + const uint_t coarseIters, const std::function< real_t () > & residualNorm, const real_t residualNormThreshold, const uint_t residualCheckFrequency, const Set<SUID> & requiredSelectors, const Set<SUID> & incompatibleSelectors ) : @@ -150,7 +150,7 @@ VCycles< Stencil_T >::VCycles( shared_ptr< StructuredBlockForest > blocks, const const BlockDataID & stencilFieldId, const uint_t iterations, const uint_t numLvl, const uint_t preSmoothingIters, const uint_t postSmoothingIters, - const uint_t coarseIters, const boost::function< real_t () > & residualNorm, + const uint_t coarseIters, const std::function< real_t () > & residualNorm, const real_t residualNormThreshold, const uint_t residualCheckFrequency, const Set<SUID> & requiredSelectors, const Set<SUID> & incompatibleSelectors ) : diff --git a/src/pde/sweeps/RBGS.h b/src/pde/sweeps/RBGS.h index 98f9849190bb1f88d6fab4eb2e912c8be2cc2389..1f3404341379aea84ab26e4d514a8a5f9cc9ff58 100644 --- a/src/pde/sweeps/RBGS.h +++ b/src/pde/sweeps/RBGS.h @@ -51,12 +51,12 @@ public: void update( IBlock * const block, const bool rb ); - boost::function< void ( IBlock * const ) > getRedSweep() + std::function< void ( IBlock * const ) > getRedSweep() { return boost::bind( &RBGS::update, this, _1, true ); } - boost::function< void ( IBlock * const ) > getBlackSweep() + std::function< void ( IBlock * const ) > getBlackSweep() { return boost::bind( &RBGS::update, this, _1, false ); } diff --git a/src/pde/sweeps/RBGSFixedStencil.h b/src/pde/sweeps/RBGSFixedStencil.h index cd4715fda9efc16bffe66e9cd97b2b3c39840594..76df0005548e9df4126d30e017ce10bb1d75f750 100644 --- a/src/pde/sweeps/RBGSFixedStencil.h +++ b/src/pde/sweeps/RBGSFixedStencil.h @@ -50,12 +50,12 @@ public: void update( IBlock * const block, const bool rb ); - boost::function< void ( IBlock * const ) > getRedSweep() + std::function< void ( IBlock * const ) > getRedSweep() { return boost::bind( &RBGSFixedStencil::update, this, _1, true ); } - boost::function< void ( IBlock * const ) > getBlackSweep() + std::function< void ( IBlock * const ) > getBlackSweep() { return boost::bind( &RBGSFixedStencil::update, this, _1, false ); } diff --git a/src/pde/sweeps/SOR.h b/src/pde/sweeps/SOR.h index 9ce89069cef49c9ea003513a6cd311d0242dff18..90be98268340223cd6e22d750c7db6bee9d5105b 100644 --- a/src/pde/sweeps/SOR.h +++ b/src/pde/sweeps/SOR.h @@ -51,12 +51,12 @@ public: void update( IBlock * const block, const bool rb ); - boost::function< void ( IBlock * const ) > getRedSweep() + std::function< void ( IBlock * const ) > getRedSweep() { return boost::bind( &SOR::update, this, _1, true ); } - boost::function< void ( IBlock * const ) > getBlackSweep() + std::function< void ( IBlock * const ) > getBlackSweep() { return boost::bind( &SOR::update, this, _1, false ); } diff --git a/src/pde/sweeps/SORFixedStencil.h b/src/pde/sweeps/SORFixedStencil.h index 2e9a54a9128f7316a5ca228637a7ce4c399c7bf8..51535e0378b9ccaa5bcf1181442ed5ff7bdba5ec 100644 --- a/src/pde/sweeps/SORFixedStencil.h +++ b/src/pde/sweeps/SORFixedStencil.h @@ -50,12 +50,12 @@ public: void update( IBlock * const block, const bool rb ); - boost::function< void ( IBlock * const ) > getRedSweep() + std::function< void ( IBlock * const ) > getRedSweep() { return boost::bind( &SORFixedStencil::update, this, _1, true ); } - boost::function< void ( IBlock * const ) > getBlackSweep() + std::function< void ( IBlock * const ) > getBlackSweep() { return boost::bind( &SORFixedStencil::update, this, _1, false ); } diff --git a/src/pe/Materials.cpp b/src/pe/Materials.cpp index ef789831e16d8bf53daf7aa1415ab622d8d04efa..b66e115f041b49c74f9fdfc9356f37d16062e2b6 100644 --- a/src/pe/Materials.cpp +++ b/src/pe/Materials.cpp @@ -311,5 +311,21 @@ std::vector<MaterialID> Material::findPrefix( const std::string& prefix ) } //************************************************************************************************* +std::string Material::toString( const MaterialID& v ) +{ + std::stringstream ss; + ss << "Material " << Material::getName(v) << "\n" + << " density = " << Material::getDensity(v) << "\n" + << " cor = " << Material::getRestitution(v) << "\n" + << " csf = " << Material::getStaticFriction(v) << "\n" + << " cdf = " << Material::getDynamicFriction(v) << "\n" + << " poisson = " << Material::getPoissonRatio(v) << "\n" + << " young = " << Material::getYoungModulus(v) << "\n" + << " stiffness = " << Material::getStiffness(v) << "\n" + << " dampingN = " << Material::getDampingN(v) << "\n" + << " dampingT = " << Material::getDampingT(v); + return ss.str(); +} + } // namespace pe } // namespace walberla diff --git a/src/pe/Materials.h b/src/pe/Materials.h index 229999cc9982f05365945145ad06993367567da7..87278ef355bc6c6f50c8256b404218a96aa98d7a 100644 --- a/src/pe/Materials.h +++ b/src/pe/Materials.h @@ -15,7 +15,6 @@ // //! \file Materials.h //! \author Klaus Iglberger -//! \author Sebastian Eibl <sebastian.eibl@fau.de> //! \brief Header file for materials // //====================================================================================================================== @@ -27,6 +26,7 @@ // Includes //************************************************************************************************* +#include <iostream> #include <string> #include <vector> #include <pe/Types.h> @@ -151,6 +151,7 @@ public: static inline real_t getDampingT( MaterialID material ); static inline real_t getDampingT( MaterialID material1, MaterialID material2 ); static inline Materials getMaterials() { return materials_; } + static std::string toString( const MaterialID& v ); //@} //********************************************************************************************** diff --git a/src/pe/amr/weight_assignment/MetisAssignmentFunctor.h b/src/pe/amr/weight_assignment/MetisAssignmentFunctor.h index 3b03af49e8dfcf5b48772351c7afac2678f7204f..bed28616694dbdbff30914cba828d0ed22c6d6fe 100644 --- a/src/pe/amr/weight_assignment/MetisAssignmentFunctor.h +++ b/src/pe/amr/weight_assignment/MetisAssignmentFunctor.h @@ -38,7 +38,7 @@ public: MetisAssignmentFunctor( const shared_ptr<InfoCollection>& ic ) : ic_( ic ) {} - void operator()( std::vector< std::pair< const PhantomBlock *, boost::any > > & blockData, const PhantomBlockForest & ) + void operator()( std::vector< std::pair< const PhantomBlock *, walberla::any > > & blockData, const PhantomBlockForest & ) { for( auto it = blockData.begin(); it != blockData.end(); ++it ) { diff --git a/src/pe/amr/weight_assignment/WeightAssignmentFunctor.h b/src/pe/amr/weight_assignment/WeightAssignmentFunctor.h index 3a6b5d9b2ad34969bbdcfcd0e021ff42bcd33f60..1632bc596e1c3b01fc9d090e5fd29ca6c1f18ad0 100644 --- a/src/pe/amr/weight_assignment/WeightAssignmentFunctor.h +++ b/src/pe/amr/weight_assignment/WeightAssignmentFunctor.h @@ -35,12 +35,9 @@ public: typedef walberla::blockforest::PODPhantomWeight<double> PhantomBlockWeight; typedef walberla::blockforest::PODPhantomWeightPackUnpack<double> PhantomBlockWeightPackUnpackFunctor; - ///Base weight due to allocated data structures. A weight of zero for blocks is dangerous as empty blocks might accumulate on one process! - static const double baseWeight; - - WeightAssignmentFunctor( shared_ptr<InfoCollection>& ic ) : ic_(ic) {} + WeightAssignmentFunctor( shared_ptr<InfoCollection>& ic, const real_t baseWeight = real_t(10.0) ) : ic_(ic), baseWeight_(baseWeight) {} - void operator()( std::vector< std::pair< const PhantomBlock *, boost::any > > & blockData, const PhantomBlockForest & ) + void operator()( std::vector< std::pair< const PhantomBlock *, walberla::any > > & blockData, const PhantomBlockForest & ) { for( auto it = blockData.begin(); it != blockData.end(); ++it ) { @@ -52,7 +49,7 @@ public: { auto infoIt = ic_->find( block->getId()/*.getFatherId()*/ ); WALBERLA_ASSERT_UNEQUAL( infoIt, ic_->end() ); - it->second = PhantomBlockWeight( double_c(infoIt->second.numberOfLocalBodies) + baseWeight ); + it->second = PhantomBlockWeight( double_c(infoIt->second.numberOfLocalBodies) + baseWeight_ ); continue; } @@ -60,7 +57,7 @@ public: { auto infoIt = ic_->find( block->getId() ); WALBERLA_ASSERT_UNEQUAL( infoIt, ic_->end() ); - it->second = PhantomBlockWeight( double_c(infoIt->second.numberOfLocalBodies) + baseWeight ); + it->second = PhantomBlockWeight( double_c(infoIt->second.numberOfLocalBodies) + baseWeight_ ); continue; } @@ -74,14 +71,20 @@ public: WALBERLA_ASSERT_UNEQUAL( childIt, ic_->end() ); weight += double_c(childIt->second.numberOfLocalBodies); } - it->second = PhantomBlockWeight( weight + baseWeight ); + it->second = PhantomBlockWeight( weight + baseWeight_ ); continue; } } } + inline void setBaseWeight( const double weight) { baseWeight_ = weight;} + inline double getBaseWeight() const { return baseWeight_; } + private: shared_ptr<InfoCollection> ic_; + + ///Base weight due to allocated data structures. A weight of zero for blocks is dangerous as empty blocks might accumulate on one process! + double baseWeight_ = real_t(10.0); }; } diff --git a/src/pe/ccd/HashGrids.cpp b/src/pe/ccd/HashGrids.cpp index e126e554d56db11e2325c9d5ea8e7860c55ce2c4..31d4c96cc8a84206298eab9ea2738a978aa3e5e3 100644 --- a/src/pe/ccd/HashGrids.cpp +++ b/src/pe/ccd/HashGrids.cpp @@ -770,23 +770,12 @@ void HashGrids::reloadBodies() } //************************************************************************************************* -//**Implementation of ICCD interface ******************************************************** + //************************************************************************************************* -/*!\brief Contact generation between colliding rigid bodies. - * - * \return Vector of possible contacts. - * - * This function generates all contacts between all registered rigid bodies. The contacts are - * added to the contact container which can be retrieved via getPossibleContacts(). +/*!\brief Updates all hash grids and reassigns bodies. */ -PossibleContacts& HashGrids::generatePossibleContacts( WcTimingTree* tt ) +void HashGrids::update(WcTimingTree* tt) { - if (tt != NULL) tt->start("CCD"); - - contacts_.clear(); - - WALBERLA_LOG_DETAIL( " Finding the contacts via the hierarchical hash grids algorithm..."); - // ----- UPDATE PHASE ----- // if (tt != NULL) tt->start("AddNewBodies"); @@ -921,6 +910,26 @@ PossibleContacts& HashGrids::generatePossibleContacts( WcTimingTree* tt ) } } if (tt != NULL) tt->stop("Update"); +} + +//**Implementation of ICCD interface ******************************************************** +//************************************************************************************************* +/*!\brief Contact generation between colliding rigid bodies. + * + * \return Vector of possible contacts. + * + * This function generates all contacts between all registered rigid bodies. The contacts are + * added to the contact container which can be retrieved via getPossibleContacts(). + */ +PossibleContacts& HashGrids::generatePossibleContacts( WcTimingTree* tt ) +{ + if (tt != NULL) tt->start("CCD"); + + contacts_.clear(); + + WALBERLA_LOG_DETAIL( " Finding the contacts via the hierarchical hash grids algorithm..."); + + update(tt); if (tt != NULL) tt->start("Detection"); // ----- DETECTION STEP ----- // diff --git a/src/pe/ccd/HashGrids.h b/src/pe/ccd/HashGrids.h index 18871eff3a1e0c7ac376b14b52f22706a667b7fb..b1ab8198be32c6ea707e58011b048b9e66a0304d 100644 --- a/src/pe/ccd/HashGrids.h +++ b/src/pe/ccd/HashGrids.h @@ -276,6 +276,7 @@ public: //@} //********************************************************************************************** + void update(WcTimingTree* tt); //**Implementation of ICCD interface ******************************************************** virtual PossibleContacts& generatePossibleContacts( WcTimingTree* tt = NULL ); diff --git a/src/pe/cr/HCSITS.impl.h b/src/pe/cr/HCSITS.impl.h index a67882dc306140900bc9c02cb840fce0019b5ae9..457cd4c299c88731b6e35058e59706a34774ea59 100644 --- a/src/pe/cr/HCSITS.impl.h +++ b/src/pe/cr/HCSITS.impl.h @@ -1810,6 +1810,13 @@ inline void HardContactSemiImplicitTimesteppingSolvers::integratePositions( Body { v = v * (edge * getSpeedLimitFactor() / dt / speed ); } + + const real_t maxPhi = real_t(2) * math::PI * getSpeedLimitFactor(); + const real_t phi = w.length() * dt; + if (phi > maxPhi) + { + w = w / phi * maxPhi; + } } // Calculating the translational displacement @@ -1820,6 +1827,7 @@ inline void HardContactSemiImplicitTimesteppingSolvers::integratePositions( Body // Calculating the new orientation const Quat dq( phi, phi.length() ); + WALBERLA_ASSERT(!math::isnan(dq), "dq: " << dq << " phi: " << phi << " w: " << w << " dt: " << dt << " angVel: " << body->getAngularVel()); body->setOrientation( dq * body->getQuaternion() ); // Storing the velocities back in the body properties diff --git a/src/pe/rigidbody/BodyStorage.h b/src/pe/rigidbody/BodyStorage.h index fb34a55908f6a721914f9fcde6fb8e4953f73589..0ab0ef40b58ab71e2712d2de3132e2ad388baa66 100644 --- a/src/pe/rigidbody/BodyStorage.h +++ b/src/pe/rigidbody/BodyStorage.h @@ -37,7 +37,7 @@ #include <pe/rigidbody/RigidBody.h> #include <pe/Types.h> -#include <boost/function.hpp> +#include <functional> namespace walberla { namespace pe { @@ -133,12 +133,12 @@ public: //**Callbacks************************************************************************ /*!\name Callbacks */ //@{ - inline void registerAddCallback ( const std::string name, const boost::function<void (BodyID)>& func ); - inline void deregisterAddCallback ( const std::string name ); + inline void registerAddCallback ( const std::string& name, const std::function<void (BodyID)>& func ); + inline void deregisterAddCallback ( const std::string& name ); inline void clearAddCallbacks ( ); - inline void registerRemoveCallback ( const std::string name, const boost::function<void (BodyID)>& func ); - inline void deregisterRemoveCallback ( const std::string name ); + inline void registerRemoveCallback ( const std::string& name, const std::function<void (BodyID)>& func ); + inline void deregisterRemoveCallback ( const std::string& name ); inline void clearRemoveCallbacks ( ); //@} //********************************************************************************************** @@ -150,8 +150,8 @@ private: Bodies bodies_; //!< The rigid bodies contained in the simulation world. std::map<id_t, SizeType> bodyIDs_; //!< The association of system IDs to rigid bodies. - std::map< std::string, boost::function<void (BodyID)> > addCallbacks_; - std::map< std::string, boost::function<void (BodyID)> > removeCallbacks_; + std::map< std::string, std::function<void (BodyID)> > addCallbacks_; + std::map< std::string, std::function<void (BodyID)> > removeCallbacks_; //@} //********************************************************************************************** }; @@ -713,13 +713,13 @@ inline void BodyStorage::clear() } //************************************************************************************************* -inline void BodyStorage::registerAddCallback ( const std::string name, const boost::function<void (BodyID)>& func ) +inline void BodyStorage::registerAddCallback ( const std::string& name, const std::function<void (BodyID)>& func ) { WALBERLA_ASSERT_EQUAL(addCallbacks_.find(name), addCallbacks_.end(), "Callback '" << name << "' already exists!"); addCallbacks_.insert( std::make_pair(name, func) ); } -inline void BodyStorage::deregisterAddCallback ( const std::string name ) +inline void BodyStorage::deregisterAddCallback ( const std::string& name ) { auto res = addCallbacks_.find( name ); if (res != addCallbacks_.end() ) @@ -733,13 +733,13 @@ inline void BodyStorage::clearAddCallbacks ( ) addCallbacks_.clear(); } -inline void BodyStorage::registerRemoveCallback ( const std::string name, const boost::function<void (BodyID)>& func ) +inline void BodyStorage::registerRemoveCallback ( const std::string& name, const std::function<void (BodyID)>& func ) { WALBERLA_ASSERT_EQUAL(removeCallbacks_.find(name), removeCallbacks_.end(), "Callback '" << name << "' already exists!"); removeCallbacks_.insert( std::make_pair(name, func) ); } -inline void BodyStorage::deregisterRemoveCallback ( const std::string name ) +inline void BodyStorage::deregisterRemoveCallback ( const std::string& name ) { auto res = removeCallbacks_.find( name ); if (res != removeCallbacks_.end() ) diff --git a/src/pe/rigidbody/Capsule.h b/src/pe/rigidbody/Capsule.h index 55070d0224f835f8870f1be99e3eb432f936a6e0..ce6bb8cbe513160efd30f723cfb952eedefdcc00 100644 --- a/src/pe/rigidbody/Capsule.h +++ b/src/pe/rigidbody/Capsule.h @@ -89,6 +89,7 @@ public: //@{ inline real_t getRadius() const; inline real_t getLength() const; + inline real_t getVolume() const; //@} //********************************************************************************************** @@ -194,6 +195,18 @@ inline real_t Capsule::getLength() const //************************************************************************************************* +//************************************************************************************************* +/*!\brief Returns the volume of the capsule. + * + * \return The volume of the capsule. + */ +inline real_t Capsule::getVolume() const +{ + return Capsule::calcVolume( getRadius(), getLength() ); +} +//************************************************************************************************* + + //================================================================================================= diff --git a/src/pe/rigidbody/Sphere.cpp b/src/pe/rigidbody/Sphere.cpp index f4314e9bad63289046a92b42b073bc15d75a60bc..2d45389cb0ddfef29b3f48b41f9f0de44f689135 100644 --- a/src/pe/rigidbody/Sphere.cpp +++ b/src/pe/rigidbody/Sphere.cpp @@ -90,7 +90,7 @@ Sphere::Sphere( id_t const typeId, id_t sid, id_t uid, const Vec3& gpos, const V } else { auto mass = calcMass( radius, Material::getDensity( material ) ); - setMassAndInertia( mass, calcInertia( radius, mass ) ); + setMassAndInertia( mass, calcInertia( mass, radius ) ); } setCommunicating( communicating ); setFinite( true ); diff --git a/src/pe/utility/CreateWorld.cpp b/src/pe/utility/CreateWorld.cpp index f5e3feb0233536baaf005d0645755539e2da94ad..3ede915c665701c38248f1a3e25d2b55552fca81 100644 --- a/src/pe/utility/CreateWorld.cpp +++ b/src/pe/utility/CreateWorld.cpp @@ -30,17 +30,37 @@ #include <core/logging/Logging.h> #include <core/math/AABB.h> +#include <memory> + namespace walberla { namespace pe { -shared_ptr<BlockForest> createBlockForest(const math::AABB simulationDomain, - Vector3<uint_t> blocks, - const Vector3<bool> isPeriodic, - const uint_t numberOfProcesses) +class FixedRefinementLevelSelector +{ +public: + FixedRefinementLevelSelector( const uint_t level ) : level_(level) {} + void operator()( SetupBlockForest& forest ) + { + for( auto block = forest.begin(); block != forest.end(); ++block ) + { + if( block->getLevel() < level_ ) + block->setMarker( true ); + } + } +private: + uint_t level_; +}; + +std::unique_ptr<SetupBlockForest> createSetupBlockForest(const math::AABB simulationDomain, + Vector3<uint_t> blocks, + const Vector3<bool> isPeriodic, + const uint_t numberOfProcesses, + const uint_t initialRefinementLevel) { WALBERLA_MPI_SECTION() { - MPIManager::instance()->useWorldComm(); + if (!MPIManager::instance()->rankValid()) + MPIManager::instance()->useWorldComm(); } if (isPeriodic[0] && blocks[0]<2) @@ -59,46 +79,41 @@ shared_ptr<BlockForest> createBlockForest(const math::AABB simulationDomain, blocks[2] = 2; } - SetupBlockForest sforest; - sforest.addWorkloadMemorySUIDAssignmentFunction( blockforest::uniformWorkloadAndMemoryAssignment ); - sforest.init( simulationDomain, blocks[0], blocks[1], blocks[2], isPeriodic[0], isPeriodic[1], isPeriodic[2] ); + auto sforest = std::unique_ptr<SetupBlockForest>( new SetupBlockForest() ); + sforest->addWorkloadMemorySUIDAssignmentFunction( blockforest::uniformWorkloadAndMemoryAssignment ); + sforest->addRefinementSelectionFunction( FixedRefinementLevelSelector(initialRefinementLevel) ); + sforest->init( simulationDomain, blocks[0], blocks[1], blocks[2], isPeriodic[0], isPeriodic[1], isPeriodic[2] ); - WALBERLA_LOG_INFO_ON_ROOT( "Balancing for " << numberOfProcesses << " processes..."); + WALBERLA_LOG_INFO_ON_ROOT( "Balancing " << sforest->getNumberOfBlocks() << " blocks for " << numberOfProcesses << " processes..."); - sforest.balanceLoad( blockforest::StaticLevelwiseCurveBalance(true), numberOfProcesses, real_t(0), memory_t(0), false, true ); - return shared_ptr< BlockForest >( new BlockForest( uint_c( MPIManager::instance()->rank() ), sforest, false ) ); + sforest->balanceLoad( blockforest::StaticLevelwiseCurveBalance(true), numberOfProcesses, real_t(0), memory_t(0), false, true ); + return sforest; } shared_ptr<BlockForest> createBlockForest(const math::AABB simulationDomain, Vector3<uint_t> blocks, const Vector3<bool> isPeriodic, - const bool setupRun, - const std::string sbffile, - const uint_t numberOfProcesses) + const uint_t numberOfProcesses, + const uint_t initialRefinementLevel) { WALBERLA_MPI_SECTION() { - MPIManager::instance()->useWorldComm(); - } - - if (isPeriodic[0] && blocks[0]<2) - { - WALBERLA_LOG_WARNING_ON_ROOT( "To few blocks in periodic x direction (" << blocks[0] << ")! Setting to 2..." ); - blocks[0] = 2; - } - if (isPeriodic[1] && blocks[1]<2) - { - WALBERLA_LOG_WARNING_ON_ROOT( "To few blocks in periodic y direction (" << blocks[1] << ")! Setting to 2..." ); - blocks[1] = 2; - } - if (isPeriodic[2] && blocks[2]<2) - { - WALBERLA_LOG_WARNING_ON_ROOT( "To few blocks in periodic z direction (" << blocks[2] << ")! Setting to 2..." ); - blocks[2] = 2; + if (!MPIManager::instance()->rankValid()) + MPIManager::instance()->useWorldComm(); } - WALBERLA_LOG_INFO_ON_ROOT( "Setup file specified: Using " << sbffile ); + std::unique_ptr<SetupBlockForest> sforest( createSetupBlockForest( simulationDomain, blocks, isPeriodic, numberOfProcesses, initialRefinementLevel )); + return shared_ptr< BlockForest >( new BlockForest( uint_c( MPIManager::instance()->rank() ), *sforest, false ) ); +} +shared_ptr<BlockForest> createBlockForest(const math::AABB simulationDomain, + Vector3<uint_t> blocks, + const Vector3<bool> isPeriodic, + const bool setupRun, + const std::string sbffile, + const uint_t numberOfProcesses, + const uint_t initialRefinementLevel) +{ if (setupRun) { WALBERLA_LOG_INFO_ON_ROOT("Setup run. For production run specify 'setupRun = false'"); @@ -110,16 +125,8 @@ shared_ptr<BlockForest> createBlockForest(const math::AABB simulationDomain, { WALBERLA_LOG_INFO_ON_ROOT( "Creating the block structure ..." ); - SetupBlockForest sforest; - - sforest.addWorkloadMemorySUIDAssignmentFunction( blockforest::uniformWorkloadAndMemoryAssignment ); - - sforest.init( simulationDomain, blocks[0], blocks[1], blocks[2], isPeriodic[0], isPeriodic[1], isPeriodic[2] ); - - // calculate process distribution - sforest.balanceLoad( blockforest::StaticLevelwiseCurveBalance(true), numberOfProcesses, real_t(0), memory_t(0), false, true ); - - sforest.saveToFile( sbffile.c_str() ); + std::unique_ptr<SetupBlockForest> sforest( createSetupBlockForest(simulationDomain, blocks, isPeriodic, numberOfProcesses, initialRefinementLevel) ); + sforest->saveToFile( sbffile.c_str() ); WALBERLA_LOG_INFO_ON_ROOT( "SetupBlockForest successfully saved to file!" ); } @@ -127,15 +134,20 @@ shared_ptr<BlockForest> createBlockForest(const math::AABB simulationDomain, return shared_ptr<BlockForest>(); } + WALBERLA_MPI_SECTION() + { + if (!MPIManager::instance()->rankValid()) + MPIManager::instance()->useWorldComm(); + } + WALBERLA_LOG_INFO_ON_ROOT( "Production Run!" ); WALBERLA_LOG_INFO_ON_ROOT( "Creating the block structure: loading from file \'" << sbffile << "\' ..." ); - return shared_ptr< BlockForest >( new BlockForest( uint_c( MPIManager::instance()->rank() ), sbffile.c_str(), true, false ) ); } + shared_ptr<BlockForest> createBlockForestFromConfig(const Config::BlockHandle& mainConf) { - bool setupRun = mainConf.getParameter< bool >( "setupRun", true ); Vec3 simulationCorner = mainConf.getParameter<Vec3>("simulationCorner", Vec3(0, 0, 0)); Vec3 simulationSize = mainConf.getParameter<Vec3>("simulationDomain", Vec3(10, 10, 10)); @@ -144,19 +156,18 @@ shared_ptr<BlockForest> createBlockForestFromConfig(const Config::BlockHandle& m Vector3<bool> isPeriodic = mainConf.getParameter<Vector3<bool>>("isPeriodic", Vector3<bool>(true, true, true)); uint_t numberOfProcesses = mainConf.getParameter<uint_t>( "numberOfProcesses", setupRun ? blocks[0] * blocks[1] * blocks[2] : uint_c(mpi::MPIManager::instance()->numProcesses()) ); + uint_t initialRefinementLevel = mainConf.getParameter<uint_t>( "initialRefinementLevel", uint_t(0) ); if( !mainConf.isDefined( "sbfFile" ) ) { WALBERLA_LOG_INFO_ON_ROOT( "No setup file specified: Creation without setup file!" ); - - return createBlockForest( simulationDomain, blocks, isPeriodic, numberOfProcesses); + return createBlockForest(simulationDomain, blocks, isPeriodic, numberOfProcesses, initialRefinementLevel); } // sbf file given -> try to load or save domain decomposition std::string sbffile = mainConf.getParameter< std::string >( "sbfFile" ); WALBERLA_LOG_INFO_ON_ROOT( "Setup file specified: Using " << sbffile ); - - return createBlockForest(simulationDomain, blocks, isPeriodic, setupRun, sbffile, numberOfProcesses); + return createBlockForest(simulationDomain, blocks, isPeriodic, setupRun, sbffile, numberOfProcesses, initialRefinementLevel); } } // namespace pe diff --git a/src/pe/utility/CreateWorld.h b/src/pe/utility/CreateWorld.h index 1594b8172e8b286eca664d5b6350b110d1a02965..3d66078348bb8d9d2c358a35d7086d32810d0083 100644 --- a/src/pe/utility/CreateWorld.h +++ b/src/pe/utility/CreateWorld.h @@ -34,13 +34,15 @@ namespace pe { shared_ptr<BlockForest> createBlockForest(const math::AABB simulationDomain, Vector3<uint_t> blocks, const Vector3<bool> isPeriodic, - const uint_t numberOfProcesses = uint_c(mpi::MPIManager::instance()->numProcesses())); + const uint_t numberOfProcesses = uint_c(mpi::MPIManager::instance()->numProcesses()), + const uint_t initialRefinementLevel = uint_t(0)); shared_ptr<BlockForest> createBlockForest(const math::AABB simulationDomain, Vector3<uint_t> blocks, const Vector3<bool> isPeriodic, const bool setupRun, const std::string sbffile, - const uint_t numberOfProcesses = uint_c(mpi::MPIManager::instance()->numProcesses())); + const uint_t numberOfProcesses = uint_c(mpi::MPIManager::instance()->numProcesses()), + const uint_t initialRefinementLevel = uint_t(0)); shared_ptr<BlockForest> createBlockForestFromConfig(const Config::BlockHandle& mainConf); } // namespace pe diff --git a/src/pe/vtk/EllipsoidVtkOutput.cpp b/src/pe/vtk/EllipsoidVtkOutput.cpp new file mode 100644 index 0000000000000000000000000000000000000000..4ec85db3819595a1300a9999295d44ab91182b8d --- /dev/null +++ b/src/pe/vtk/EllipsoidVtkOutput.cpp @@ -0,0 +1,93 @@ +//====================================================================================================================== +// +// This file is part of waLBerla. waLBerla is free software: you can +// redistribute it and/or modify it under the terms of the GNU General Public +// License as published by the Free Software Foundation, either version 3 of +// the License, or (at your option) any later version. +// +// waLBerla is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License along +// with waLBerla (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file EllipsoidVtkOutput.cpp +//! \author Christoph Rettinger <christoph.rettinger@fau.de> +// +//====================================================================================================================== + +#include "core/DataTypes.h" +#include "EllipsoidVtkOutput.h" +#include "pe/rigidbody/BodyStorage.h" + +#include "core/selectable/IsSetSelected.h" +#include "core/uid/GlobalState.h" + + +namespace walberla { +namespace pe { + +std::vector< EllipsoidVtkOutput::Attributes > EllipsoidVtkOutput::getAttributes() const +{ + std::vector< Attributes > attributes; + attributes.push_back( Attributes( vtk::typeToString< float >(), "mass", uint_c(1) ) ); + attributes.push_back( Attributes( vtk::typeToString< float >(), "tensorGlyph", uint_c(6) ) ); + attributes.push_back( Attributes( vtk::typeToString< float >(), "velocity", uint_c(3) ) ); + attributes.push_back( Attributes( vtk::typeToString< int >(), "rank", uint_c(1) ) ); + attributes.push_back( Attributes( vtk::typeToString< id_t >(), "id", uint_c(1) ) ); + attributes.push_back( Attributes( vtk::typeToString< id_t >(), "uid", uint_c(1) ) ); + + return attributes; +} + +void EllipsoidVtkOutput::configure() +{ + bodies_.clear(); + tensorGlyphs_.clear(); + + for( auto blockIt = blockStorage_.begin(); blockIt != blockStorage_.end(); ++blockIt ) + { + + const Storage& bs = *(blockIt->getData<const Storage>( storageID_ )); + + for( auto it = bs[0].begin(); it != bs[0].end(); ++it ) + { + if (it->getTypeID() == Ellipsoid::getStaticTypeID()) + { + auto ellipsoid = static_cast<ConstEllipsoidID> (*it); + bodies_.push_back(ellipsoid); + + // compute tensor glyph for visualization with ParaView (tensorGlyph) + Mat3 rotMat = ellipsoid->getRotation(); + Vector3<real_t> directionVectorX(rotMat[0], rotMat[3], rotMat[6]); + Vector3<real_t> directionVectorY(rotMat[1], rotMat[4], rotMat[7]); + Vector3<real_t> directionVectorZ(rotMat[2], rotMat[5], rotMat[8]); + Vector3<real_t> semiAxes = ellipsoid->getSemiAxes(); + Mat3 axa = math::dyadicProduct(directionVectorX, directionVectorX); + Mat3 bxb = math::dyadicProduct(directionVectorY, directionVectorY); + Mat3 cxc = math::dyadicProduct(directionVectorZ, directionVectorZ); + Mat3 tensor = axa * semiAxes[0] + bxb * semiAxes[1] + cxc * semiAxes[2]; + // use symmetry to only write 6 of the 9 elements: XX YY ZZ XY YZ XZ + tensorGlyphs_.push_back({{tensor(0,0), tensor(1,1), tensor(2,2), + tensor(0,1), tensor(1,2), tensor(0,2)}}); + } + } + } +} + +std::vector< math::Vector3< real_t > > EllipsoidVtkOutput::getPoints() +{ + std::vector< math::Vector3< real_t > > result( bodies_.size() ); + auto resultIt = result.begin(); + for( auto it = bodies_.begin(); it != bodies_.end(); ++it, ++resultIt ) + { + *resultIt = (*it)->getPosition(); + } + return result; +} + +} // namespace pe +} // namespace walberla + diff --git a/src/pe/vtk/EllipsoidVtkOutput.h b/src/pe/vtk/EllipsoidVtkOutput.h new file mode 100644 index 0000000000000000000000000000000000000000..e12f91879e6aaf0d2eb3d74f04b5d5ab3103feea --- /dev/null +++ b/src/pe/vtk/EllipsoidVtkOutput.h @@ -0,0 +1,129 @@ +//====================================================================================================================== +// +// This file is part of waLBerla. waLBerla is free software: you can +// redistribute it and/or modify it under the terms of the GNU General Public +// License as published by the Free Software Foundation, either version 3 of +// the License, or (at your option) any later version. +// +// waLBerla is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License along +// with waLBerla (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file EllipsoidVtkOutput.h +//! \author Christoph Rettinger <christoph.rettinger@fau.de> +// +//====================================================================================================================== + +#pragma once + +#include "pe/rigidbody/RigidBody.h" +#include "pe/rigidbody/Ellipsoid.h" + +#include "core/DataTypes.h" +#include "core/Set.h" +#include "core/uid/SUID.h" + +#include "domain_decomposition/BlockStorage.h" + +#include "vtk/Base64Writer.h" +#include "vtk/PointDataSource.h" +#include "vtk/UtilityFunctions.h" + +#include <vector> +#include <array> + +namespace walberla { +namespace pe { + +class EllipsoidVtkOutput : public vtk::PointDataSource +{ +public: + EllipsoidVtkOutput( ConstBlockDataID storageID, const BlockStorage & blockStorage) + : storageID_( storageID ) + , blockStorage_( blockStorage ) { } + + std::vector< Attributes > getAttributes() const; + + void configure(); + + std::vector< Vector3< real_t > > getPoints(); + + inline void push( std::ostream& os , const uint_t /*data*/, const uint_t point, const uint_t component ); + inline void push( vtk::Base64Writer& b64, const uint_t /*data*/, const uint_t point, const uint_t component ); + +private: + + ConstBlockDataID storageID_; + const BlockStorage & blockStorage_; + std::vector< ConstEllipsoidID > bodies_; + std::vector< std::array<real_t,6> > tensorGlyphs_; +}; + + +void EllipsoidVtkOutput::push( std::ostream& os, const uint_t data, const uint_t point, const uint_t component ) +{ + WALBERLA_ASSERT_LESS( point, bodies_.size() ); + WALBERLA_ASSERT_LESS( component, 6u ); + + switch( data ) + { + case 0: + vtk::toStream( os, numeric_cast< float >(bodies_.at( point )->getMass()) ); + break; + case 1: + vtk::toStream( os, numeric_cast< float >(tensorGlyphs_.at(point)[component]) ); + break; + case 2: + vtk::toStream( os, numeric_cast< float >(bodies_.at( point )->getLinearVel()[component]) ); + break; + case 3: + vtk::toStream( os, numeric_cast< int >(bodies_.at( point )->MPITrait.getOwner().rank_) ); + break; + case 4: + vtk::toStream( os, numeric_cast< id_t >(bodies_.at( point )->getTopSuperBody()->getSystemID()) ); + break; + case 5: + vtk::toStream( os, numeric_cast< id_t >(bodies_.at( point )->getTopSuperBody()->getID()) ); + break; + } + +} + + + +void EllipsoidVtkOutput::push( vtk::Base64Writer& b64, const uint_t data, const uint_t point, const uint_t component ) +{ + WALBERLA_ASSERT_LESS( point, bodies_.size() ); + WALBERLA_ASSERT_LESS( component, 6u ); + + switch( data ) + { + case 0: + b64 << numeric_cast< float >(bodies_.at( point )->getMass()); + break; + case 1: + b64 << numeric_cast< float >(tensorGlyphs_.at(point)[component]); + break; + case 2: + b64 << numeric_cast< float >(bodies_.at( point )->getLinearVel()[component]); + break; + case 3: + b64 << numeric_cast< int >(bodies_.at( point )->MPITrait.getOwner().rank_); + break; + case 4: + b64 << numeric_cast< id_t >(bodies_.at( point )->getTopSuperBody()->getSystemID()); + break; + case 5: + b64 << numeric_cast< id_t >(bodies_.at( point )->getTopSuperBody()->getID()); + break; + } +} + + +} // namespace pe +} // namespace walberla + diff --git a/src/pe_coupling/discrete_particle_methods/evaluators/AddedMassForceEvaluator.h b/src/pe_coupling/discrete_particle_methods/evaluators/AddedMassForceEvaluator.h index 5950cfc3fc1f8dc59119ad24072f8609f218d762..a318686d8865509b3597d3361852c51c42c1ffcc 100644 --- a/src/pe_coupling/discrete_particle_methods/evaluators/AddedMassForceEvaluator.h +++ b/src/pe_coupling/discrete_particle_methods/evaluators/AddedMassForceEvaluator.h @@ -45,7 +45,7 @@ #include "stencil/Directions.h" -#include <boost/function.hpp> +#include <functional> namespace walberla { namespace pe_coupling { @@ -78,9 +78,9 @@ public: const BlockDataID & forceFieldID, const BlockDataID & bodyStorageID, const BlockDataID & flagFieldID, const Set< FlagUID > & domainFlags, const BlockDataID & velocityTimeDerivativeFieldID, - const boost::function<Vector3<real_t> ( const Vector3<real_t> &, const Vector3<real_t> &, real_t, real_t )> & addedMassForceCorrelationFunction, + const std::function<Vector3<real_t> ( const Vector3<real_t> &, const Vector3<real_t> &, real_t, real_t )> & addedMassForceCorrelationFunction, const shared_ptr< BodyVelocityTimeDerivativeEvaluator > & bodyVelocityTimeDerivativeEvaluator, - const boost::function<bool(pe::BodyID)> & dpmBodySelectorFct = selectRegularBodies ) + const std::function<bool(pe::BodyID)> & dpmBodySelectorFct = selectRegularBodies ) : blockStorage_( blockStorage ), bodyStorageID_( bodyStorageID ), addedMassForceCorrelationFunction_( addedMassForceCorrelationFunction ), bodyVelocityTimeDerivativeEvaluator_( bodyVelocityTimeDerivativeEvaluator ), @@ -97,11 +97,11 @@ private: shared_ptr<StructuredBlockStorage> blockStorage_; const BlockDataID bodyStorageID_; - boost::function<Vector3<real_t> ( const Vector3<real_t> &, const Vector3<real_t> &, real_t, real_t )> addedMassForceCorrelationFunction_; + std::function<Vector3<real_t> ( const Vector3<real_t> &, const Vector3<real_t> &, real_t, real_t )> addedMassForceCorrelationFunction_; shared_ptr< BodyVelocityTimeDerivativeEvaluator > bodyVelocityTimeDerivativeEvaluator_; - boost::function<bool(pe::BodyID)> dpmBodySelectorFct_; + std::function<bool(pe::BodyID)> dpmBodySelectorFct_; BlockDataID velocityTimeDerivativeFieldInterpolatorID_; BlockDataID forceDistributorID_; diff --git a/src/pe_coupling/discrete_particle_methods/evaluators/BodyVelocityTimeDerivativeEvaluator.h b/src/pe_coupling/discrete_particle_methods/evaluators/BodyVelocityTimeDerivativeEvaluator.h index 95d64064089c8a89081774b59a7f0f90b3856ecc..229be174ef1951b0e2601a65717457683c8d1467 100644 --- a/src/pe_coupling/discrete_particle_methods/evaluators/BodyVelocityTimeDerivativeEvaluator.h +++ b/src/pe_coupling/discrete_particle_methods/evaluators/BodyVelocityTimeDerivativeEvaluator.h @@ -27,7 +27,7 @@ #include "pe_coupling/utility/BodySelectorFunctions.h" -#include <boost/function.hpp> +#include <functional> #include <map> namespace walberla { @@ -50,7 +50,7 @@ public: BodyVelocityTimeDerivativeEvaluator( const shared_ptr<StructuredBlockStorage> & blockStorage, const BlockDataID & bodyStorageID, const real_t & deltaT = real_t(1), - const boost::function<bool(pe::BodyID)> & dpmBodySelectorFct = selectRegularBodies ) + const std::function<bool(pe::BodyID)> & dpmBodySelectorFct = selectRegularBodies ) : blockStorage_( blockStorage ), bodyStorageID_( bodyStorageID ), deltaTinv_( real_t(1) / deltaT ), dpmBodySelectorFct_( dpmBodySelectorFct) { } @@ -88,7 +88,7 @@ private: const BlockDataID bodyStorageID_; std::map< walberla::id_t, Vector3< real_t > > bodyVelocityMap_; real_t deltaTinv_; - boost::function<bool(pe::BodyID)> dpmBodySelectorFct_; + std::function<bool(pe::BodyID)> dpmBodySelectorFct_; }; diff --git a/src/pe_coupling/discrete_particle_methods/evaluators/EffectiveViscosityFieldEvaluator.h b/src/pe_coupling/discrete_particle_methods/evaluators/EffectiveViscosityFieldEvaluator.h index c052b6059bad2ac9a54ce5bee15a8f8ae6c10033..fc10c9b975cf8e5845432f62d439b354fefb6f3f 100644 --- a/src/pe_coupling/discrete_particle_methods/evaluators/EffectiveViscosityFieldEvaluator.h +++ b/src/pe_coupling/discrete_particle_methods/evaluators/EffectiveViscosityFieldEvaluator.h @@ -66,7 +66,7 @@ public: EffectiveViscosityFieldEvaluator( const BlockDataID & omegaFieldID, const ConstBlockDataID & solidVolumeFractionFieldID, const real_t & fluidViscosity, - const boost::function<real_t (real_t, real_t)> & effectiveViscosityFunc ) + const std::function<real_t (real_t, real_t)> & effectiveViscosityFunc ) : omegaFieldID_( omegaFieldID ), solidVolumeFractionFieldID_( solidVolumeFractionFieldID ), fluidViscosity_( fluidViscosity ), effectiveViscosityFunc_( effectiveViscosityFunc ) { @@ -97,7 +97,7 @@ private: const BlockDataID omegaFieldID_; const ConstBlockDataID solidVolumeFractionFieldID_; real_t fluidViscosity_; - boost::function<real_t (real_t, real_t)> effectiveViscosityFunc_; + std::function<real_t (real_t, real_t)> effectiveViscosityFunc_; }; diff --git a/src/pe_coupling/discrete_particle_methods/evaluators/InteractionForceEvaluator.h b/src/pe_coupling/discrete_particle_methods/evaluators/InteractionForceEvaluator.h index d3a6dc098cb536ba85794543c69086095b074566..33a2e7d76fa567bd754214a4ccba52280c31299e 100644 --- a/src/pe_coupling/discrete_particle_methods/evaluators/InteractionForceEvaluator.h +++ b/src/pe_coupling/discrete_particle_methods/evaluators/InteractionForceEvaluator.h @@ -45,7 +45,7 @@ #include "stencil/Directions.h" -#include <boost/function.hpp> +#include <functional> #include <vector> @@ -88,9 +88,9 @@ public: const BlockDataID & forceFieldID, const BlockDataID & bodyStorageID, const BlockDataID & flagFieldID, const Set< FlagUID > & domainFlags, const BlockDataID & velocityFieldID, const BlockDataID & solidVolumeFractionFieldID, const BlockDataID & pressureGradientFieldID, - const boost::function<Vector3<real_t> ( const Vector3<real_t> &, const Vector3<real_t> &, real_t, real_t, real_t, real_t )> & dragForceCorrelationFunction, + const std::function<Vector3<real_t> ( const Vector3<real_t> &, const Vector3<real_t> &, real_t, real_t, real_t, real_t )> & dragForceCorrelationFunction, real_t fluidDynamicViscosity, - const boost::function<bool(pe::BodyID)> & dpmBodySelectorFct = selectRegularBodies ) + const std::function<bool(pe::BodyID)> & dpmBodySelectorFct = selectRegularBodies ) : blockStorage_( blockStorage ), bodyStorageID_( bodyStorageID ), dragForceCorrelationFunction_( dragForceCorrelationFunction ), fluidDynamicViscosity_( fluidDynamicViscosity ), dpmBodySelectorFct_( dpmBodySelectorFct) @@ -109,11 +109,11 @@ private: const BlockDataID bodyStorageID_; const BlockDataID pdfFieldID_; - boost::function<Vector3<real_t> ( const Vector3<real_t> &, const Vector3<real_t> &, real_t, real_t, real_t, real_t )> dragForceCorrelationFunction_; + std::function<Vector3<real_t> ( const Vector3<real_t> &, const Vector3<real_t> &, real_t, real_t, real_t, real_t )> dragForceCorrelationFunction_; real_t fluidDynamicViscosity_; - boost::function<bool(pe::BodyID)> dpmBodySelectorFct_; + std::function<bool(pe::BodyID)> dpmBodySelectorFct_; BlockDataID velocityFieldInterpolatorID_; BlockDataID solidVolumeFractionFieldInterpolatorID_; diff --git a/src/pe_coupling/discrete_particle_methods/evaluators/LiftForceEvaluator.h b/src/pe_coupling/discrete_particle_methods/evaluators/LiftForceEvaluator.h index 97dee854dc7d68d66e165dd5849de0a8b04af2cd..d04ca701ca8788abc87b424b4b9b3a3328109819 100644 --- a/src/pe_coupling/discrete_particle_methods/evaluators/LiftForceEvaluator.h +++ b/src/pe_coupling/discrete_particle_methods/evaluators/LiftForceEvaluator.h @@ -38,7 +38,7 @@ #include "pe_coupling/geometry/SphereEquivalentDiameter.h" #include "pe_coupling/utility/BodySelectorFunctions.h" -#include <boost/function.hpp> +#include <functional> #include <cmath> @@ -72,9 +72,9 @@ public: LiftForceEvaluator( const shared_ptr<StructuredBlockStorage> & blockStorage, const BlockDataID & forceFieldID, const BlockDataID & bodyStorageID, const BlockDataID & flagFieldID, const Set< FlagUID > & domainFlags, const BlockDataID & velocityFieldID, const BlockDataID & velocityCurlFieldID, - const boost::function<Vector3<real_t> ( const Vector3<real_t> &, const Vector3<real_t> &, const Vector3<real_t> &, real_t, real_t, real_t )> & liftForceCorrelationFunction, + const std::function<Vector3<real_t> ( const Vector3<real_t> &, const Vector3<real_t> &, const Vector3<real_t> &, real_t, real_t, real_t )> & liftForceCorrelationFunction, real_t fluidDynamicViscosity, - const boost::function<bool(pe::BodyID)> & dpmBodySelectorFct = selectRegularBodies ) + const std::function<bool(pe::BodyID)> & dpmBodySelectorFct = selectRegularBodies ) : blockStorage_( blockStorage ), bodyStorageID_( bodyStorageID ), liftForceCorrelationFunction_( liftForceCorrelationFunction ), fluidDynamicViscosity_( fluidDynamicViscosity ), dpmBodySelectorFct_( dpmBodySelectorFct) { @@ -90,11 +90,11 @@ private: shared_ptr<StructuredBlockStorage> blockStorage_; BlockDataID bodyStorageID_; - boost::function<Vector3<real_t> ( const Vector3<real_t> &, const Vector3<real_t> &, const Vector3<real_t> &, real_t, real_t, real_t )> liftForceCorrelationFunction_; + std::function<Vector3<real_t> ( const Vector3<real_t> &, const Vector3<real_t> &, const Vector3<real_t> &, real_t, real_t, real_t )> liftForceCorrelationFunction_; real_t fluidDynamicViscosity_; - boost::function<bool(pe::BodyID)> dpmBodySelectorFct_; + std::function<bool(pe::BodyID)> dpmBodySelectorFct_; BlockDataID velocityFieldInterpolatorID_; BlockDataID velocityCurlFieldInterpolatorID_; diff --git a/src/pe_coupling/discrete_particle_methods/evaluators/LubricationForceEvaluator.h b/src/pe_coupling/discrete_particle_methods/evaluators/LubricationForceEvaluator.h index b13966987d80c04f855e51db082e9f8852d3d9e8..e99d3e88f63befc5ef49a932eb395af4cad82a76 100644 --- a/src/pe_coupling/discrete_particle_methods/evaluators/LubricationForceEvaluator.h +++ b/src/pe_coupling/discrete_particle_methods/evaluators/LubricationForceEvaluator.h @@ -54,24 +54,26 @@ public: LubricationForceEvaluator ( const shared_ptr<StructuredBlockStorage> & blockStorage, const shared_ptr<pe::BodyStorage> & globalBodyStorage, const BlockDataID & bodyStorageID, - real_t dynamicViscosity, real_t cutOffDistance = real_t(2) / real_t(3) ) + real_t dynamicViscosity, + real_t cutOffDistance = real_t(2) / real_t(3), real_t minimalGapSize = real_t(1e-5) ) : blockStorage_ ( blockStorage ) , globalBodyStorage_( globalBodyStorage ) , bodyStorageID_( bodyStorageID ) , dynamicViscosity_( dynamicViscosity ) , cutOffDistance_( cutOffDistance ) + , minimalGapSize_( minimalGapSize ) { } - void operator()( ); + void operator()(); private: // helper functions - void treatLubricationSphrSphr ( real_t nu_Lattice, real_t cutOff, real_t minimalGap, const pe::SphereID sphereI, const pe::SphereID sphereJ, const math::AABB & blockAABB ); - void treatLubricationSphrPlane( real_t nu_Lattice, real_t cutOff, real_t minimalGap, const pe::SphereID sphereI, const pe::ConstPlaneID planeJ ); + void treatLubricationSphrSphr ( const pe::SphereID sphereI, const pe::SphereID sphereJ, const math::AABB & blockAABB ); + void treatLubricationSphrPlane( const pe::SphereID sphereI, const pe::ConstPlaneID planeJ ); - pe::Vec3 compLubricationSphrSphr ( real_t nu_Lattice, real_t gap, real_t cutOff, const pe::SphereID sphereI, const pe::SphereID sphereJ ) const; - pe::Vec3 compLubricationSphrPlane( real_t nu_Lattice, real_t gap, real_t cutOff, const pe::SphereID sphereI, const pe::ConstPlaneID planeJ) const; + pe::Vec3 compLubricationSphrSphr ( real_t gap, const pe::SphereID sphereI, const pe::SphereID sphereJ ) const; + pe::Vec3 compLubricationSphrPlane( real_t gap, const pe::SphereID sphereI, const pe::ConstPlaneID planeJ ) const; // member variables shared_ptr<StructuredBlockStorage> blockStorage_; @@ -81,24 +83,17 @@ private: real_t dynamicViscosity_; real_t cutOffDistance_; + real_t minimalGapSize_; }; // class LubricationForceEvaluator -void LubricationForceEvaluator::operator ()( ) +void LubricationForceEvaluator::operator ()() { WALBERLA_LOG_PROGRESS( "Calculating Lubrication Force" ); - // cut off distance for lubrication force - const real_t cutOff = cutOffDistance_; - for (auto blockIt = blockStorage_->begin(); blockIt != blockStorage_->end(); ++blockIt) { - // minimal gap used to limit the lubrication force - const real_t minimalGap = real_t(1e-5) * blockStorage_->dx( blockStorage_->getLevel( *blockIt ) ); - - real_t nu_L = dynamicViscosity_; - // loop over all rigid bodies for( auto body1It = pe::BodyIterator::begin( *blockIt, bodyStorageID_ ); body1It != pe::BodyIterator::end(); ++body1It ) { @@ -115,7 +110,7 @@ void LubricationForceEvaluator::operator ()( ) if ( body2It->getTypeID() == pe::Sphere::getStaticTypeID() ) { pe::SphereID sphereJ = static_cast<pe::SphereID>( *body2It ); - treatLubricationSphrSphr( nu_L, cutOff, minimalGap, sphereI, sphereJ, blockIt->getAABB() ); + treatLubricationSphrSphr( sphereI, sphereJ, blockIt->getAABB() ); } } } @@ -134,12 +129,12 @@ void LubricationForceEvaluator::operator ()( ) { // sphere-plane lubrication pe::PlaneID planeJ = static_cast<pe::PlaneID>( *body2It ); - treatLubricationSphrPlane( nu_L, cutOff, minimalGap, sphereI, planeJ ); + treatLubricationSphrPlane( sphereI, planeJ ); } else if ( body2It->getTypeID() == pe::Sphere::getStaticTypeID() ) { // sphere-sphere lubrication pe::SphereID sphereJ = static_cast<pe::SphereID>( *body2It ); - treatLubricationSphrSphr( nu_L, cutOff, minimalGap, sphereI, sphereJ, blockIt->getAABB() ); + treatLubricationSphrSphr( sphereI, sphereJ, blockIt->getAABB() ); } } } @@ -147,24 +142,23 @@ void LubricationForceEvaluator::operator ()( ) } } -void LubricationForceEvaluator::treatLubricationSphrSphr( real_t nu_Lattice, real_t cutOff, real_t minimalGap, - const pe::SphereID sphereI, const pe::SphereID sphereJ, const math::AABB & blockAABB ) +void LubricationForceEvaluator::treatLubricationSphrSphr( const pe::SphereID sphereI, const pe::SphereID sphereJ, const math::AABB & blockAABB ) { WALBERLA_ASSERT_UNEQUAL( sphereI->getSystemID(), sphereJ->getSystemID() ); real_t gap = pe::getSurfaceDistance( sphereI, sphereJ ); - if ( gap > cutOff || gap < real_t(0) ) + if ( gap > cutOffDistance_ || gap < real_t(0) ) { - WALBERLA_LOG_DETAIL("gap " << gap << " larger than cutOff - continue"); + WALBERLA_LOG_DETAIL("gap " << gap << " larger than cutOff " << cutOffDistance_ << " - ignoring pair"); return; } - if ( gap < minimalGap ) + if ( gap < minimalGapSize_ ) { - WALBERLA_LOG_DETAIL("gap " << gap << " smaller than minimal gap " << minimalGap << " - using minimal gap"); - gap = minimalGap; + WALBERLA_LOG_DETAIL("gap " << gap << " smaller than minimal gap " << minimalGapSize_ << " - using minimal gap"); + gap = minimalGapSize_; } const pe::Vec3 &posSphereI = sphereI->getPosition(); @@ -172,13 +166,13 @@ void LubricationForceEvaluator::treatLubricationSphrSphr( real_t nu_Lattice, rea pe::Vec3 fLub(0); // compute (global) coordinate between spheres' centers of gravity - pe::Vec3 midPoint( (posSphereI + posSphereJ ) * real_c(0.5) ); + pe::Vec3 midPoint( (posSphereI + posSphereJ ) * real_t(0.5) ); // Let process on which midPoint lies do the lubrication correction // or the local process of sphereI if sphereJ is global if ( blockAABB.contains(midPoint) || sphereJ->isGlobal() ) { - fLub = compLubricationSphrSphr(nu_Lattice, gap, cutOff, sphereI, sphereJ); + fLub = compLubricationSphrSphr(gap, sphereI, sphereJ); sphereI->addForce( fLub); sphereJ->addForce(-fLub); @@ -188,25 +182,24 @@ void LubricationForceEvaluator::treatLubricationSphrSphr( real_t nu_Lattice, rea } -void LubricationForceEvaluator::treatLubricationSphrPlane( real_t nu_Lattice, real_t cutOff, real_t minimalGap, - const pe::SphereID sphereI, const pe::ConstPlaneID planeJ ) +void LubricationForceEvaluator::treatLubricationSphrPlane( const pe::SphereID sphereI, const pe::ConstPlaneID planeJ ) { real_t gap = pe::getSurfaceDistance( sphereI, planeJ ); - if ( gap > cutOff || gap < real_t(0) ) + if ( gap > cutOffDistance_ || gap < real_t(0) ) { - WALBERLA_LOG_DETAIL("gap " << gap << " larger than cutOff - continue"); + WALBERLA_LOG_DETAIL("gap " << gap << " larger than cutOff " << cutOffDistance_ << " - ignoring pair"); return; } - if ( gap < minimalGap ) + if ( gap < minimalGapSize_ ) { - WALBERLA_LOG_DETAIL("gap " << gap << " smaller than minimal gap " << minimalGap << " - using minimal gap"); - gap = minimalGap; + WALBERLA_LOG_DETAIL("gap " << gap << " smaller than minimal gap " << minimalGapSize_ << " - using minimal gap"); + gap = minimalGapSize_; } - pe::Vec3 fLub = compLubricationSphrPlane( nu_Lattice, gap, cutOff, sphereI, planeJ); + pe::Vec3 fLub = compLubricationSphrPlane( gap, sphereI, planeJ); WALBERLA_LOG_DETAIL( "Lubrication force on sphere " << sphereI->getID() << " to plane with id " << planeJ->getID() << " is:" << fLub << std::endl ); sphereI->addForce( fLub ); @@ -214,8 +207,7 @@ void LubricationForceEvaluator::treatLubricationSphrPlane( real_t nu_Lattice, re } -pe::Vec3 LubricationForceEvaluator::compLubricationSphrSphr( real_t nu_Lattice, real_t gap, real_t cutOff, - const pe::SphereID sphereI, const pe::SphereID sphereJ) const +pe::Vec3 LubricationForceEvaluator::compLubricationSphrSphr( real_t gap, const pe::SphereID sphereI, const pe::SphereID sphereJ) const { const pe::Vec3 &posSphereI = sphereI->getPosition(); const pe::Vec3 &posSphereJ = sphereJ->getPosition(); @@ -233,9 +225,9 @@ pe::Vec3 LubricationForceEvaluator::compLubricationSphrSphr( real_t nu_Lattice, real_t d = real_t(2) * diameterSphereI * diameterSphereJ / ( diameterSphereI + diameterSphereJ ); real_t h = gap; real_t r = d + h; - real_t a_sq = ( real_t(3) * nu_Lattice * walberla::math::PI * d / real_t(2) ) * ( d / ( real_t(4) * h ) + ( real_t(18) / real_t(40) ) * std::log( d / ( real_t(2) * h ) ) + - ( real_t(9)/real_t(84) ) * ( h / d ) * std::log( d/( real_t(2)*h ) ) ); - real_t a_sh = ( nu_Lattice * walberla::math::PI * d / real_t(2) ) * std::log( d / ( real_t(2) * h ) ) * ( d + h ) * ( d + h ) / real_t(4); + real_t a_sq = ( real_t(3) * dynamicViscosity_ * walberla::math::PI * d / real_t(2) ) * ( d / ( real_t(4) * h ) + ( real_t(18) / real_t(40) ) * std::log( d / ( real_t(2) * h ) ) + + ( real_t(9)/real_t(84) ) * ( h / d ) * std::log( d/( real_t(2)*h ) ) ); + real_t a_sh = ( dynamicViscosity_ * walberla::math::PI * d / real_t(2) ) * std::log( d / ( real_t(2) * h ) ) * ( d + h ) * ( d + h ) / real_t(4); pe::Vec3 fLub( - a_sq * length * rIJ - a_sh * ( real_t(2) / r ) * ( real_t(2) / r ) * ( velDiff - length * rIJ ) ); WALBERLA_LOG_DETAIL_SECTION() @@ -252,11 +244,11 @@ pe::Vec3 LubricationForceEvaluator::compLubricationSphrSphr( real_t nu_Lattice, ss << "pos: " << posSphereJ << "\n\n"; real_t distance = gap + diameterSphereI * real_t(0.5) + diameterSphereJ * real_t(0.5); - ss << "distance: " << distance << "\n"; - ss << "nu: " << nu_Lattice << "\n"; + ss << "distance: " << distance << "\n"; + ss << "viscosity: " << dynamicViscosity_ << "\n"; ss << "gap: " << gap << "\n"; - ss << "cutOff: " << cutOff << "\n"; + ss << "cutOff: " << cutOffDistance_ << "\n"; ss << "velDiff " << velDiff << "\n"; ss << "rIJ " << rIJ << "\n\n"; @@ -268,8 +260,7 @@ pe::Vec3 LubricationForceEvaluator::compLubricationSphrSphr( real_t nu_Lattice, return fLub; } -pe::Vec3 LubricationForceEvaluator::compLubricationSphrPlane( real_t nu_Lattice, real_t gap, real_t cutOff, - const pe::SphereID sphereI, const pe::ConstPlaneID planeJ) const +pe::Vec3 LubricationForceEvaluator::compLubricationSphrPlane( real_t gap, const pe::SphereID sphereI, const pe::ConstPlaneID planeJ) const { const pe::Vec3 &posSphereI( sphereI->getPosition() ); real_t radiusSphereI = sphereI->getRadius(); @@ -283,9 +274,9 @@ pe::Vec3 LubricationForceEvaluator::compLubricationSphrPlane( real_t nu_Lattice, real_t d = real_t(4) * radiusSphereI; real_t h = gap; real_t r = d + h; - real_t a_sq = ( real_t(3) * nu_Lattice * walberla::math::PI * d / real_t(2) ) * ( d / ( real_t(4) * h ) + ( real_t(18) / real_t(40) ) * std::log( d / ( real_t(2) * h ) ) + - ( real_t(9)/real_t(84) ) * ( h / d ) * std::log( d/( real_t(2)*h ) ) ); - real_t a_sh = ( nu_Lattice * walberla::math::PI * d / real_t(2) ) * std::log( d / ( real_t(2) * h ) ) * ( d + h ) * ( d + h ) / real_t(4); + real_t a_sq = ( real_t(3) * dynamicViscosity_ * walberla::math::PI * d / real_t(2) ) * ( d / ( real_t(4) * h ) + ( real_t(18) / real_t(40) ) * std::log( d / ( real_t(2) * h ) ) + + ( real_t(9)/real_t(84) ) * ( h / d ) * std::log( d/( real_t(2)*h ) ) ); + real_t a_sh = ( dynamicViscosity_ * walberla::math::PI * d / real_t(2) ) * std::log( d / ( real_t(2) * h ) ) * ( d + h ) * ( d + h ) / real_t(4); pe::Vec3 fLub( - a_sq * length * rIJ - a_sh * ( real_t(2) / r ) * ( real_t(2) / r ) * ( v1 - length * rIJ ) ); WALBERLA_LOG_DETAIL_SECTION() { @@ -296,11 +287,11 @@ pe::Vec3 LubricationForceEvaluator::compLubricationSphrPlane( real_t nu_Lattice, ss << "pos: " << posSphereI << "\n\n"; real_t distance = gap + radiusSphereI; - ss << "distance: " << distance << "\n"; - ss << "nu: " << nu_Lattice << "\n"; + ss << "distance: " << distance << "\n"; + ss << "viscosity: " << dynamicViscosity_ << "\n"; ss << "gap: " << gap << "\n"; - ss << "cutOff: " << cutOff << "\n"; + ss << "cutOff: " << cutOffDistance_ << "\n"; ss << "velDiff " << sphereI->getLinearVel() << "\n"; ss << "rIJ " << -rIJ << "\n\n"; diff --git a/src/pe_coupling/discrete_particle_methods/evaluators/SolidVolumeFractionFieldEvaluator.h b/src/pe_coupling/discrete_particle_methods/evaluators/SolidVolumeFractionFieldEvaluator.h index eb0bbafb4b3b8ff7d74da6ea51661698a92a821d..1c83df74afc0eba7d192454f350932307f27bef4 100644 --- a/src/pe_coupling/discrete_particle_methods/evaluators/SolidVolumeFractionFieldEvaluator.h +++ b/src/pe_coupling/discrete_particle_methods/evaluators/SolidVolumeFractionFieldEvaluator.h @@ -32,7 +32,7 @@ #include "pe_coupling/utility/BodySelectorFunctions.h" -#include <boost/function.hpp> +#include <functional> namespace walberla { namespace pe_coupling { @@ -68,7 +68,7 @@ public: SolidVolumeFractionFieldEvaluator( const shared_ptr<StructuredBlockStorage> & blockStorage, const BlockDataID & solidVolumeFractionFieldID, const BlockDataID & bodyStorageID, const BlockDataID & flagFieldID, const Set< FlagUID > & domainFlags, - const boost::function<bool(pe::BodyID)> & dpmBodySelectorFct = selectRegularBodies ) + const std::function<bool(pe::BodyID)> & dpmBodySelectorFct = selectRegularBodies ) : blockStorage_( blockStorage ), solidVolumeFractionFieldID_( solidVolumeFractionFieldID ), bodyStorageID_( bodyStorageID ), dpmBodySelectorFct_( dpmBodySelectorFct) { @@ -104,7 +104,7 @@ private: BlockDataID solidVolumeFractionFieldID_; BlockDataID bodyStorageID_; - boost::function<bool(pe::BodyID)> dpmBodySelectorFct_; + std::function<bool(pe::BodyID)> dpmBodySelectorFct_; BlockDataID scalarDistributorID_; }; diff --git a/src/pe_coupling/discrete_particle_methods/utility/BodyVelocityInitializer.h b/src/pe_coupling/discrete_particle_methods/utility/BodyVelocityInitializer.h index 3ad78d1ad3f1929342c05c101b516dbe1a00b403..75ebeef5b370820e5f306b06c0f954c45b7dd16e 100644 --- a/src/pe_coupling/discrete_particle_methods/utility/BodyVelocityInitializer.h +++ b/src/pe_coupling/discrete_particle_methods/utility/BodyVelocityInitializer.h @@ -36,7 +36,7 @@ #include "pe_coupling/utility/BodySelectorFunctions.h" -#include <boost/function.hpp> +#include <functional> #include <cmath> @@ -66,7 +66,7 @@ public: BodyVelocityInitializer( const shared_ptr<StructuredBlockStorage> & blockStorage, const BlockDataID & bodyStorageID, const BlockDataID & flagFieldID, const Set< FlagUID > & domainFlags, const BlockDataID & velocityFieldID, - const boost::function<bool(pe::BodyID)> & dpmBodySelectorFct = selectRegularBodies ) + const std::function<bool(pe::BodyID)> & dpmBodySelectorFct = selectRegularBodies ) : blockStorage_( blockStorage ), bodyStorageID_( bodyStorageID ), dpmBodySelectorFct_( dpmBodySelectorFct) { @@ -105,7 +105,7 @@ private: shared_ptr<StructuredBlockStorage> blockStorage_; BlockDataID bodyStorageID_; BlockDataID velocityFieldInterpolatorID_; - boost::function<bool(pe::BodyID)> dpmBodySelectorFct_; + std::function<bool(pe::BodyID)> dpmBodySelectorFct_; }; diff --git a/src/pe_coupling/discrete_particle_methods/utility/SubgridTimeStep.h b/src/pe_coupling/discrete_particle_methods/utility/SubgridTimeStep.h deleted file mode 100644 index 130a4829fa5a6bd87960c937f7fa12621cddc525..0000000000000000000000000000000000000000 --- a/src/pe_coupling/discrete_particle_methods/utility/SubgridTimeStep.h +++ /dev/null @@ -1,164 +0,0 @@ -//====================================================================================================================== -// -// This file is part of waLBerla. waLBerla is free software: you can -// redistribute it and/or modify it under the terms of the GNU General Public -// License as published by the Free Software Foundation, either version 3 of -// the License, or (at your option) any later version. -// -// waLBerla is distributed in the hope that it will be useful, but WITHOUT -// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -// for more details. -// -// You should have received a copy of the GNU General Public License along -// with waLBerla (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. -// -//! \file SubgridTimeStep.h -//! \ingroup pe_coupling -//! \author Christoph Rettinger <christoph.rettinger@fau.de> -// -//====================================================================================================================== - -#pragma once - -#include "core/debug/Debug.h" -#include "core/timing/TimingTree.h" - -#include "domain_decomposition/BlockStorage.h" - -#include "field/GhostLayerField.h" - -#include "pe/cr/ICR.h" -#include "pe/rigidbody/BodyIterators.h" -#include "pe/synchronization/SyncForces.h" - -#include <boost/function.hpp> - -#include <map> - -/*!\brief Carries out the the PE time steps, including sub iteration functionality. - * - * This class is similar to src/pe_coupling/utility/TimeStep. - * - * It executes 'intermediateSteps' PE steps within one timestep of size 'timeStepSize'. - * - * These PE sub iterations require, that the current external (e.g. hydrodynamic, gravitational,..) forces and torques - * acting on each particle remains unchanged. Thus, a map is set up internally that stores and re-sets these forces - * and torques in each PE sub iteration - * . - * Additionally, a function 'forceEvaluationFunc' can be given that allows to evaluate different forces before the PE - * step is carried out. An example are particle-particle lubrication forces that have to be updated in each sub iteration. - * - */ -namespace walberla { -namespace pe_coupling { -namespace discrete_particle_methods { - -class SubgridTimeStep -{ -public: - - typedef field::GhostLayerField< Vector3<real_t>, 1 > ForceField_T; - - explicit SubgridTimeStep( const shared_ptr<StructuredBlockStorage> & blockStorage, - const BlockDataID & bodyStorageID, - pe::cr::ICR & collisionResponse, - const boost::function<void (void)> & synchronizeFunc, - const boost::function<void ()> & forceEvaluationFunc, - const real_t timeStepSize = real_t(1), const uint_t intermediateSteps = uint_t(1) ) - : timeStepSize_( timeStepSize ) - , intermediateSteps_( ( intermediateSteps == 0 ) ? uint_t(1) : intermediateSteps ) - , blockStorage_( blockStorage ) - , bodyStorageID_(bodyStorageID) - , collisionResponse_(collisionResponse) - , synchronizeFunc_(synchronizeFunc) - , forceEvaluationFunc_(forceEvaluationFunc) - {} - - void operator()() - { - if( intermediateSteps_ == 1 ) - { - forceEvaluationFunc_(); - - collisionResponse_.timestep( timeStepSize_ ); - synchronizeFunc_(); - } - else - { - // sum up all forces from shadow copies on local body (owner) - pe::reduceForces(blockStorage_->getBlockStorage(), bodyStorageID_); - // send total forces to shadow owners - pe::distributeForces(blockStorage_->getBlockStorage(), bodyStorageID_); - - // store force/torques. Those should only contain external forces (gravity, buoyancy,..) - // generate map from all known bodies (process local) to total forces - std::map< walberla::id_t, std::vector< real_t > > forceMap; - for (auto blockIt = blockStorage_->begin(); blockIt != blockStorage_->end(); ++blockIt) - { - for( auto bodyIt = pe::BodyIterator::begin(*blockIt, bodyStorageID_); bodyIt != pe::BodyIterator::end(); ++bodyIt ) - { - auto & f = forceMap[ bodyIt->getSystemID() ]; - - const auto & force = bodyIt->getForce(); - f.push_back( force[0] ); - f.push_back( force[1] ); - f.push_back( force[2] ); - - const auto & torque = bodyIt->getTorque(); - f.push_back( torque[0] ); - f.push_back( torque[1] ); - f.push_back( torque[2] ); - - if ( bodyIt->isRemote() ) - { - bodyIt->resetForceAndTorque(); - } - } - } - - // perform pe sub time steps - const real_t subTimeStepSize = timeStepSize_ / real_c( intermediateSteps_ ); - for( uint_t i = 0; i != intermediateSteps_; ++i ) - { - // evaluate forces (e.g. lubrication forces) - forceEvaluationFunc_(); - - // in the first set forces on local bodies are already set by force synchronization - if( i != 0 ) { - for (auto blockIt = blockStorage_->begin(); blockIt != blockStorage_->end(); ++blockIt) - { - for( auto body = pe::LocalBodyIterator::begin(*blockIt, bodyStorageID_); body != pe::LocalBodyIterator::end(); ++body ) - { - const auto & f = forceMap[ body->getSystemID() ]; - body->addForce ( f[0], f[1], f[2] ); - body->addTorque( f[3], f[4], f[5] ); - } - } - } - - collisionResponse_.timestep( subTimeStepSize ); - synchronizeFunc_(); - } - } - } - -protected: - - const real_t timeStepSize_; - - const uint_t intermediateSteps_; - - shared_ptr<StructuredBlockStorage> blockStorage_; - const BlockDataID & bodyStorageID_; - - pe::cr::ICR & collisionResponse_; - boost::function<void (void)> synchronizeFunc_; - boost::function<void ()> forceEvaluationFunc_; - -}; - - -} // namespace discrete_particle_methods -} // namespace pe_coupling -} // namespace walberla diff --git a/src/pe_coupling/discrete_particle_methods/utility/all.h b/src/pe_coupling/discrete_particle_methods/utility/all.h index 6c471171429b3dd2887e13ab4933fcfecc0839f1..31cb9cf9f5c37d6912cebf4b14edd8d63ed473a4 100644 --- a/src/pe_coupling/discrete_particle_methods/utility/all.h +++ b/src/pe_coupling/discrete_particle_methods/utility/all.h @@ -28,5 +28,4 @@ #include "CombinedReductionFieldCommunication.h" #include "ExternalForceToForceFieldAdder.h" #include "ForceFieldResetter.h" -#include "SubgridTimeStep.h" #include "FieldDataSwapper.h" diff --git a/src/pe_coupling/mapping/BodyMapping.h b/src/pe_coupling/mapping/BodyMapping.h index 042c8dd23acc30d445dbba791fc68d86a5970d05..4af2e9d3195ebaddc0ce3a6a08108c2c4d28d10d 100644 --- a/src/pe_coupling/mapping/BodyMapping.h +++ b/src/pe_coupling/mapping/BodyMapping.h @@ -35,7 +35,7 @@ #include "pe_coupling/utility/BodySelectorFunctions.h" -#include <boost/function.hpp> +#include <functional> namespace walberla { namespace pe_coupling { @@ -99,7 +99,7 @@ template< typename BoundaryHandling_T > void mapBodies( StructuredBlockStorage & blockStorage, const BlockDataID & boundaryHandlingID, const BlockDataID & bodyStorageID, pe::BodyStorage & globalBodyStorage, const FlagUID & obstacle, - const boost::function<bool(pe::BodyID)> & mappingBodySelectorFct = selectAllBodies ) + const std::function<bool(pe::BodyID)> & mappingBodySelectorFct = selectAllBodies ) { for( auto blockIt = blockStorage.begin(); blockIt != blockStorage.end(); ++blockIt ) { diff --git a/src/pe_coupling/momentum_exchange_method/BodyMapping.h b/src/pe_coupling/momentum_exchange_method/BodyMapping.h index 3b4b7ff57736c629eaaa377086162d88a7e47f21..7651386b613b476a00d5070c1550884930a003f9 100644 --- a/src/pe_coupling/momentum_exchange_method/BodyMapping.h +++ b/src/pe_coupling/momentum_exchange_method/BodyMapping.h @@ -35,7 +35,7 @@ #include "pe_coupling/mapping/BodyBBMapping.h" #include "pe_coupling/utility/BodySelectorFunctions.h" -#include <boost/function.hpp> +#include <functional> namespace walberla { namespace pe_coupling { @@ -70,7 +70,7 @@ public: const shared_ptr<pe::BodyStorage> & globalBodyStorage, const BlockDataID & bodyFieldID, const FlagUID & obstacle, const FlagUID & formerObstacle, - const boost::function<bool(pe::BodyID)> & mappingBodySelectorFct = selectRegularBodies ) + const std::function<bool(pe::BodyID)> & mappingBodySelectorFct = selectRegularBodies ) : blockStorage_( blockStorage ), boundaryHandlingID_( boundaryHandlingID ), bodyStorageID_(bodyStorageID), globalBodyStorage_( globalBodyStorage ), bodyFieldID_( bodyFieldID ), obstacle_( obstacle ), formerObstacle_( formerObstacle ), mappingBodySelectorFct_( mappingBodySelectorFct ) @@ -192,7 +192,7 @@ private: const FlagUID obstacle_; const FlagUID formerObstacle_; - boost::function<bool(pe::BodyID)> mappingBodySelectorFct_; + std::function<bool(pe::BodyID)> mappingBodySelectorFct_; }; // class BodyMapping @@ -267,7 +267,7 @@ template< typename BoundaryHandling_T > void mapMovingBodies( StructuredBlockStorage & blockStorage, const BlockDataID & boundaryHandlingID, const BlockDataID & bodyStorageID, pe::BodyStorage & globalBodyStorage, const BlockDataID & bodyFieldID, const FlagUID & obstacle, - const boost::function<bool(pe::BodyID)> & mappingBodySelectorFct = selectAllBodies ) + const std::function<bool(pe::BodyID)> & mappingBodySelectorFct = selectAllBodies ) { for( auto blockIt = blockStorage.begin(); blockIt != blockStorage.end(); ++blockIt ) { diff --git a/src/pe_coupling/momentum_exchange_method/restoration/PDFReconstruction.h b/src/pe_coupling/momentum_exchange_method/restoration/PDFReconstruction.h index ef8289da08ffc29712a8cb4ec7cfcfc559605a5c..d21808bb3cc8bae4084ea24bff84b6051dd30253 100644 --- a/src/pe_coupling/momentum_exchange_method/restoration/PDFReconstruction.h +++ b/src/pe_coupling/momentum_exchange_method/restoration/PDFReconstruction.h @@ -33,7 +33,7 @@ #include "field/iterators/IteratorMacros.h" #include "Reconstructor.h" -#include <boost/function.hpp> +#include <functional> namespace walberla { namespace pe_coupling { @@ -71,7 +71,7 @@ public: const BlockDataID & bodyFieldID, const Reconstructer_T & reconstructor, const FlagUID & formerObstacle, const FlagUID & fluid, - const boost::function<bool(pe::BodyID)> & movingBodySelectorFct = selectRegularBodies, + const std::function<bool(pe::BodyID)> & movingBodySelectorFct = selectRegularBodies, const bool optimizeForSmallObstacleFraction = false ) : blockStorage_( blockStorage ), boundaryHandlingID_( boundaryHandlingID ), bodyStorageID_(bodyStorageID), globalBodyStorage_( globalBodyStorage ), bodyFieldID_( bodyFieldID ), @@ -127,7 +127,7 @@ private: const FlagUID formerObstacle_; const FlagUID fluid_; - boost::function<bool(pe::BodyID)> movingBodySelectorFct_; + std::function<bool(pe::BodyID)> movingBodySelectorFct_; const bool optimizeForSmallObstacleFraction_; diff --git a/src/pe_coupling/momentum_exchange_method/restoration/Reconstructor.h b/src/pe_coupling/momentum_exchange_method/restoration/Reconstructor.h index 7f9ce1017f6cc13c703ee18711c792b1d07f8c85..b8fb7affbfc2bb720b7eb0930419d221ad5343c2 100644 --- a/src/pe_coupling/momentum_exchange_method/restoration/Reconstructor.h +++ b/src/pe_coupling/momentum_exchange_method/restoration/Reconstructor.h @@ -120,6 +120,8 @@ void EquilibriumReconstructor< LatticeModel_T, BoundaryHandling_T > real_t cx, cy, cz; blockStorage_->getBlockLocalCellCenter( *block, Cell(x,y,z), cx, cy, cz ); + + WALBERLA_ASSERT_NOT_NULLPTR( (*bodyField)(x,y,z) ); const auto velocity = (*bodyField)(x,y,z)->velFromWF(cx,cy,cz); pdfField->setToEquilibrium( x, y, z, Vector3< real_t >( velocity[0], velocity[1], velocity[2] ), averageDensity ); diff --git a/src/pe_coupling/partially_saturated_cells_method/BodyAndVolumeFractionMapping.h b/src/pe_coupling/partially_saturated_cells_method/BodyAndVolumeFractionMapping.h index 3a6ef85a07db100e4f487548c518a0f0d02d63d9..9f28d42e6bd41f2226766c3e6b88bb8ad0b350ec 100644 --- a/src/pe_coupling/partially_saturated_cells_method/BodyAndVolumeFractionMapping.h +++ b/src/pe_coupling/partially_saturated_cells_method/BodyAndVolumeFractionMapping.h @@ -34,7 +34,7 @@ #include "pe_coupling/mapping/BodyBBMapping.h" #include "pe_coupling/utility/BodySelectorFunctions.h" -#include <boost/function.hpp> +#include <functional> namespace walberla { namespace pe_coupling { @@ -108,7 +108,7 @@ public: const shared_ptr<pe::BodyStorage> & globalBodyStorage, const BlockDataID & bodyStorageID, const BlockDataID & bodyAndVolumeFractionFieldID, - const boost::function<bool(pe::BodyID)> & mappingBodySelectorFct = selectRegularBodies, + const std::function<bool(pe::BodyID)> & mappingBodySelectorFct = selectRegularBodies, const real_t velocityUpdatingEpsilon = real_t(0), const real_t positionUpdatingEpsilon = real_t(0), const uint_t superSamplingDepth = uint_t(4) ) @@ -141,7 +141,7 @@ private: const BlockDataID bodyStorageID_; const BlockDataID bodyAndVolumeFractionFieldID_; - boost::function<bool(pe::BodyID)> mappingBodySelectorFct_; + std::function<bool(pe::BodyID)> mappingBodySelectorFct_; shared_ptr<BodyAndVolumeFractionField_T> updatedBodyAndVolumeFractionField_; std::map< walberla::id_t, Vector3< real_t > > lastUpdatedPositionMap_; diff --git a/src/pe_coupling/utility/LubricationCorrection.h b/src/pe_coupling/utility/LubricationCorrection.h index e101ea2bcbf7a2d750ea1d24254c700c998b4e24..c318c66c6e42b3a3bdb3cafc50854b8f82c60569 100644 --- a/src/pe_coupling/utility/LubricationCorrection.h +++ b/src/pe_coupling/utility/LubricationCorrection.h @@ -43,24 +43,26 @@ public: // constructor LubricationCorrection ( const shared_ptr<StructuredBlockStorage> & blockStorage, const shared_ptr<pe::BodyStorage> & globalBodyStorage, - const BlockDataID & bodyStorageID, real_t dynamicViscosity, real_t cutOffDistance = real_t(2) / real_t(3) ) + const BlockDataID & bodyStorageID, real_t dynamicViscosity, + real_t cutOffDistance = real_t(2) / real_t(3), real_t minimalGapSize = real_t(1e-5) ) : blockStorage_ ( blockStorage ) , globalBodyStorage_( globalBodyStorage ) , bodyStorageID_( bodyStorageID ) , dynamicViscosity_( dynamicViscosity ) , cutOffDistance_( cutOffDistance ) + , minimalGapSize_( minimalGapSize ) { } - void operator()( ); + void operator()(); private: // helper functions - void treatLubricationSphrSphr ( real_t nu_Lattice, real_t cutOff, real_t minimalGap, const pe::SphereID sphereI, const pe::SphereID sphereJ, const math::AABB & blockAABB ); - void treatLubricationSphrPlane( real_t nu_Lattice, real_t cutOff, real_t minimalGap, const pe::SphereID sphereI, const pe::ConstPlaneID planeJ ); + void treatLubricationSphrSphr ( const pe::SphereID sphereI, const pe::SphereID sphereJ, const math::AABB & blockAABB ); + void treatLubricationSphrPlane( const pe::SphereID sphereI, const pe::ConstPlaneID planeJ ); - pe::Vec3 compLubricationSphrSphr ( real_t nu_Lattice, real_t gap, real_t cutOff, const pe::SphereID sphereI, const pe::SphereID sphereJ ) const; - pe::Vec3 compLubricationSphrPlane( real_t nu_Lattice, real_t gap, real_t cutOff, const pe::SphereID sphereI, const pe::ConstPlaneID planeJ) const; + pe::Vec3 compLubricationSphrSphr ( real_t gap, const pe::SphereID sphereI, const pe::SphereID sphereJ ) const; + pe::Vec3 compLubricationSphrPlane( real_t gap, const pe::SphereID sphereI, const pe::ConstPlaneID planeJ ) const; // member variables shared_ptr<StructuredBlockStorage> blockStorage_; @@ -70,24 +72,17 @@ private: real_t dynamicViscosity_; real_t cutOffDistance_; + real_t minimalGapSize_; }; // class LubricationCorrection -void LubricationCorrection::operator ()( ) +void LubricationCorrection::operator ()() { WALBERLA_LOG_PROGRESS( "Calculating Lubrication Force" ); - // cut off distance for lubrication force - const real_t cutOff = cutOffDistance_; - for (auto blockIt = blockStorage_->begin(); blockIt != blockStorage_->end(); ++blockIt) { - // minimal gap used to limit the lubrication force - const real_t minimalGap = real_t(1e-5) * blockStorage_->dx( blockStorage_->getLevel( *blockIt ) ); - - real_t nu_L = dynamicViscosity_; - // loop over all rigid bodies for( auto body1It = pe::BodyIterator::begin( *blockIt, bodyStorageID_ ); body1It != pe::BodyIterator::end(); ++body1It ) { @@ -104,7 +99,7 @@ void LubricationCorrection::operator ()( ) if ( body2It->getTypeID() == pe::Sphere::getStaticTypeID() ) { pe::SphereID sphereJ = static_cast<pe::SphereID>( *body2It ); - treatLubricationSphrSphr( nu_L, cutOff, minimalGap, sphereI, sphereJ, blockIt->getAABB() ); + treatLubricationSphrSphr( sphereI, sphereJ, blockIt->getAABB() ); } } } @@ -123,12 +118,12 @@ void LubricationCorrection::operator ()( ) { // sphere-plane lubrication pe::PlaneID planeJ = static_cast<pe::PlaneID>( *body2It ); - treatLubricationSphrPlane( nu_L, cutOff, minimalGap, sphereI, planeJ ); + treatLubricationSphrPlane( sphereI, planeJ ); } else if ( body2It->getTypeID() == pe::Sphere::getStaticTypeID() ) { // sphere-sphere lubrication pe::SphereID sphereJ = static_cast<pe::SphereID>( *body2It ); - treatLubricationSphrSphr( nu_L, cutOff, minimalGap, sphereI, sphereJ, blockIt->getAABB() ); + treatLubricationSphrSphr( sphereI, sphereJ, blockIt->getAABB() ); } } } @@ -143,24 +138,23 @@ void LubricationCorrection::operator ()( ) // Helper Functions // ////////////////////// -void LubricationCorrection::treatLubricationSphrSphr( real_t nu_Lattice, real_t cutOff, real_t minimalGap, - const pe::SphereID sphereI, const pe::SphereID sphereJ, const math::AABB & blockAABB ) +void LubricationCorrection::treatLubricationSphrSphr( const pe::SphereID sphereI, const pe::SphereID sphereJ, const math::AABB & blockAABB ) { WALBERLA_ASSERT_UNEQUAL( sphereI->getSystemID(), sphereJ->getSystemID() ); real_t gap = pe::getSurfaceDistance( sphereI, sphereJ ); - if ( gap > cutOff || gap < real_t(0) ) + if ( gap > cutOffDistance_ || gap < real_t(0) ) { - WALBERLA_LOG_DETAIL("gap " << gap << " larger than cutOff - continue"); + WALBERLA_LOG_DETAIL("gap " << gap << " larger than cutOff " << cutOffDistance_ << " - ignoring pair"); return; } - if ( gap < minimalGap ) + if ( gap < minimalGapSize_ ) { - WALBERLA_LOG_DETAIL("gap " << gap << " smaller than minimal gap " << minimalGap << " - using minimal gap"); - gap = minimalGap; + WALBERLA_LOG_DETAIL("gap " << gap << " smaller than minimal gap " << minimalGapSize_ << " - using minimal gap"); + gap = minimalGapSize_; } const pe::Vec3 &posSphereI = sphereI->getPosition(); @@ -174,7 +168,7 @@ void LubricationCorrection::treatLubricationSphrSphr( real_t nu_Lattice, real_t // or the local process of sphereI if sphereJ is global if ( blockAABB.contains(midPoint) || sphereJ->isGlobal() ) { - fLub = compLubricationSphrSphr(nu_Lattice, gap, cutOff, sphereI, sphereJ); + fLub = compLubricationSphrSphr(gap, sphereI, sphereJ); sphereI->addForce( fLub); sphereJ->addForce(-fLub); @@ -184,25 +178,24 @@ void LubricationCorrection::treatLubricationSphrSphr( real_t nu_Lattice, real_t } -void LubricationCorrection::treatLubricationSphrPlane( real_t nu_Lattice, real_t cutOff, real_t minimalGap, - const pe::SphereID sphereI, const pe::ConstPlaneID planeJ ) +void LubricationCorrection::treatLubricationSphrPlane( const pe::SphereID sphereI, const pe::ConstPlaneID planeJ ) { real_t gap = pe::getSurfaceDistance( sphereI, planeJ ); - if ( gap > cutOff || gap < real_t(0) ) + if ( gap > cutOffDistance_ || gap < real_t(0) ) { - WALBERLA_LOG_DETAIL("gap " << gap << " larger than cutOff - continue"); + WALBERLA_LOG_DETAIL("gap " << gap << " larger than cutOff " << cutOffDistance_ << " - ignoring pair"); return; } - if ( gap < minimalGap ) + if ( gap < minimalGapSize_ ) { - WALBERLA_LOG_DETAIL("gap " << gap << " smaller than minimal gap " << minimalGap << " - using minimal gap"); - gap = minimalGap; + WALBERLA_LOG_DETAIL("gap " << gap << " smaller than minimal gap " << minimalGapSize_ << " - using minimal gap"); + gap = minimalGapSize_; } - pe::Vec3 fLub = compLubricationSphrPlane( nu_Lattice, gap, cutOff, sphereI, planeJ); + pe::Vec3 fLub = compLubricationSphrPlane( gap, sphereI, planeJ); WALBERLA_LOG_DETAIL( "Lubrication force on sphere " << sphereI->getID() << " to plane with id " << planeJ->getID() << " is:" << fLub << std::endl ); sphereI->addForce( fLub ); @@ -222,8 +215,7 @@ void LubricationCorrection::treatLubricationSphrPlane( real_t nu_Lattice, real_t * and qualitatively by considering direction of force for example setup. */ //***************************************************************************************************************************************** -pe::Vec3 LubricationCorrection::compLubricationSphrSphr( real_t nu_Lattice, real_t gap, real_t cutOff, - const pe::SphereID sphereI, const pe::SphereID sphereJ) const +pe::Vec3 LubricationCorrection::compLubricationSphrSphr( real_t gap, const pe::SphereID sphereI, const pe::SphereID sphereJ) const { const pe::Vec3 &posSphereI = sphereI->getPosition(); const pe::Vec3 &posSphereJ = sphereJ->getPosition(); @@ -241,7 +233,7 @@ pe::Vec3 LubricationCorrection::compLubricationSphrSphr( real_t nu_Lattice, real real_t radiiSQR = ( radiusSphereI * radiusSphereJ ) * ( radiusSphereI * radiusSphereJ ); real_t radiiSumSQR = ( radiusSphereI + radiusSphereJ ) * ( radiusSphereI + radiusSphereJ ); - pe::Vec3 fLub = ( -real_t(6) * nu_Lattice * walberla::math::PI * radiiSQR / radiiSumSQR * ( real_t(1) / gap - real_t(1) / cutOff) * length * rIJ); + pe::Vec3 fLub = ( -real_t(6) * dynamicViscosity_ * walberla::math::PI * radiiSQR / radiiSumSQR * ( real_t(1) / gap - real_t(1) / cutOffDistance_) * length * rIJ); WALBERLA_LOG_DETAIL_SECTION() { @@ -257,11 +249,11 @@ pe::Vec3 LubricationCorrection::compLubricationSphrSphr( real_t nu_Lattice, real ss << "pos: " << posSphereJ << "\n\n"; real_t distance = gap + radiusSphereI + radiusSphereJ; - ss << "distance: " << distance << "\n"; - ss << "nu: " << nu_Lattice << "\n"; + ss << "distance: " << distance << "\n"; + ss << "viscosity: " << dynamicViscosity_ << "\n"; ss << "gap: " << gap << "\n"; - ss << "cutOff: " << cutOff << "\n"; + ss << "cutOff: " << cutOffDistance_ << "\n"; ss << "velDiff " << velDiff << "\n"; ss << "rIJ " << rIJ << "\n\n"; @@ -287,8 +279,7 @@ pe::Vec3 LubricationCorrection::compLubricationSphrSphr( real_t nu_Lattice, real * and qualitatively by considering direction of force for example setup. */ //***************************************************************************************************************************************** -pe::Vec3 LubricationCorrection::compLubricationSphrPlane( real_t nu_Lattice, real_t gap, real_t cutOff, - const pe::SphereID sphereI, const pe::ConstPlaneID planeJ) const +pe::Vec3 LubricationCorrection::compLubricationSphrPlane( real_t gap, const pe::SphereID sphereI, const pe::ConstPlaneID planeJ) const { const pe::Vec3 &posSphereI( sphereI->getPosition() ); real_t radiusSphereI = sphereI->getRadius(); @@ -300,7 +291,7 @@ pe::Vec3 LubricationCorrection::compLubricationSphrPlane( real_t nu_Lattice, rea real_t radiiSQR = radiusSphereI * radiusSphereI; - pe::Vec3 fLub( -real_t(6) * nu_Lattice * walberla::math::PI * radiiSQR * (real_t(1) / gap - real_t(1) / cutOff) * length * rIJ); + pe::Vec3 fLub( -real_t(6) * dynamicViscosity_ * walberla::math::PI * radiiSQR * (real_t(1) / gap - real_t(1) / cutOffDistance_) * length * rIJ); WALBERLA_LOG_DETAIL_SECTION() { std::stringstream ss; @@ -310,11 +301,11 @@ pe::Vec3 LubricationCorrection::compLubricationSphrPlane( real_t nu_Lattice, rea ss << "pos: " << posSphereI << "\n\n"; real_t distance = gap + radiusSphereI; - ss << "distance: " << distance << "\n"; - ss << "nu: " << nu_Lattice << "\n"; + ss << "distance: " << distance << "\n"; + ss << "viscosity: " << dynamicViscosity_ << "\n"; ss << "gap: " << gap << "\n"; - ss << "cutOff: " << cutOff << "\n"; + ss << "cutOff: " << cutOffDistance_ << "\n"; ss << "velDiff " << sphereI->getLinearVel() << "\n"; ss << "rIJ " << -rIJ << "\n\n"; diff --git a/src/pe_coupling/utility/TimeStep.h b/src/pe_coupling/utility/TimeStep.h index b69e87ffc83191d3fe8319a82fba48bd7233487e..2e7bbaa539056d3421b3db039ab5d3f898e4cd79 100644 --- a/src/pe_coupling/utility/TimeStep.h +++ b/src/pe_coupling/utility/TimeStep.h @@ -32,7 +32,7 @@ #include "pe/rigidbody/BodyIterators.h" #include "pe/synchronization/SyncForces.h" -#include <boost/function.hpp> +#include <functional> #include <map> @@ -40,6 +40,18 @@ namespace walberla { namespace pe_coupling { +/*!\brief Carries out the the PE time steps, including sub iteration functionality. + * + * It executes 'numberOfSubIterations' PE steps within one timestep of size 'timeStepSize'. + * + * These PE sub iterations require, that the current external (e.g. hydrodynamic, gravitational,..) forces and torques + * acting on each particle remains unchanged. Thus, a map is set up internally that stores and re-sets these forces + * and torques in each PE sub iteration + * . + * Additionally, a function 'forceEvaluationFunc' can be given that allows to evaluate different forces before the PE + * step is carried out. An example are particle-particle lubrication forces that have to be updated in each sub iteration. + * + */ class TimeStep { public: @@ -47,14 +59,17 @@ public: explicit TimeStep( const shared_ptr<BlockStorage> & blockStorage, const BlockDataID & bodyStorageID, pe::cr::ICR & collisionResponse, - const boost::function<void (void)> & synchronizeFunc, - const real_t timeStep = real_t(1), const uint_t intermediateSteps = uint_c(1) ) - : timeStep_( timeStep ) - , intermediateSteps_( ( intermediateSteps == 0 ) ? uint_c(1) : intermediateSteps ) + const std::function<void (void)> & synchronizeFunc, + const real_t timeStepSize = real_t(1), + const uint_t numberOfSubIterations = uint_t(1), + const std::function<void (void)> & forceEvaluationFunc = [](){}) + : timeStepSize_( timeStepSize ) + , numberOfSubIterations_( ( numberOfSubIterations == 0 ) ? uint_t(1) : numberOfSubIterations ) , blockStorage_( blockStorage ) - , bodyStorageID_(bodyStorageID) - , collisionResponse_(collisionResponse) - , synchronizeFunc_(synchronizeFunc) + , bodyStorageID_( bodyStorageID ) + , collisionResponse_( collisionResponse ) + , synchronizeFunc_( synchronizeFunc ) + , forceEvaluationFunc_( forceEvaluationFunc ) {} void operator()( IBlock * block ) @@ -65,10 +80,12 @@ public: void operator()() { - if( intermediateSteps_ == 1 ) + if( numberOfSubIterations_ == 1 ) { - collisionResponse_.timestep( timeStep_ ); - synchronizeFunc_( ); + forceEvaluationFunc_(); + + collisionResponse_.timestep( timeStepSize_ ); + synchronizeFunc_(); } else { @@ -82,14 +99,14 @@ public: // send total forces/torques to shadow owners pe::distributeForces( *blockStorage_, bodyStorageID_ ); - // generate map from all known bodies (process local) to total forces + // generate map from all known bodies (process local) to total forces/torques std::map< walberla::id_t, std::vector< real_t > > forceMap; for( auto blockIt = blockStorage_->begin(); blockIt != blockStorage_->end(); ++blockIt ) { // iterate over local and remote bodies and store force/torque in map // Remote bodies are required since during the then following collision response time steps, - // bodies can change owner ship (i.e. a now remote body could become a local body ). - // Since only the owning process re-sets the force/torque later, remote body values have to be stores as well. + // bodies can change ownership (i.e. a now remote body could become a local body ). + // Since only the owning process re-sets the force/torque later, remote body values have to be stored as well. for( auto bodyIt = pe::BodyIterator::begin(*blockIt, bodyStorageID_); bodyIt != pe::BodyIterator::end(); ++bodyIt ) { auto & f = forceMap[ bodyIt->getSystemID() ]; @@ -118,10 +135,11 @@ public: } // perform pe time steps - const real_t subTimestep = timeStep_ / real_c( intermediateSteps_ ); - for( uint_t i = 0; i != intermediateSteps_; ++i ) + const real_t subTimeStepSize = timeStepSize_ / real_c( numberOfSubIterations_ ); + for( uint_t i = 0; i != numberOfSubIterations_; ++i ) { - // in the first set forces on local bodies are already set by force synchronization + + // in the first iteration, forces on local bodies are already set by force synchronization if( i != 0 ) { for( auto blockIt = blockStorage_->begin(); blockIt != blockStorage_->end(); ++blockIt ) @@ -137,23 +155,26 @@ public: } } - collisionResponse_.timestep( subTimestep ); - synchronizeFunc_( ); + // evaluate forces (e.g. lubrication forces) + forceEvaluationFunc_(); + + collisionResponse_.timestep( subTimeStepSize ); + synchronizeFunc_(); } } } protected: - const real_t timeStep_; - - const uint_t intermediateSteps_; + const real_t timeStepSize_; + const uint_t numberOfSubIterations_; shared_ptr<BlockStorage> blockStorage_; const BlockDataID & bodyStorageID_; pe::cr::ICR & collisionResponse_; - boost::function<void (void)> synchronizeFunc_; + std::function<void (void)> synchronizeFunc_; + std::function<void (void)> forceEvaluationFunc_; }; // class TimeStep diff --git a/src/python_coupling/DictWrapper.impl.h b/src/python_coupling/DictWrapper.impl.h index 57e7f55348865367bb0ae12a550a76e8d1cbf0d2..400eb2e7f09e4855cd2d1ffdb630b2dfb6ac6448 100644 --- a/src/python_coupling/DictWrapper.impl.h +++ b/src/python_coupling/DictWrapper.impl.h @@ -102,7 +102,7 @@ inline bool DictWrapper::has<DictWrapper >( const std::string & name ) //=================================================================================================================== // -// Getting boost::functions +// Getting std::functions // //=================================================================================================================== @@ -111,13 +111,13 @@ inline void runPythonObject( boost::python::object obj ) { obj(); } template<> -inline boost::function<void()> DictWrapper::get( const std::string & name ) { +inline std::function<void()> DictWrapper::get( const std::string & name ) { boost::python::object obj ( d_[name] ); return boost::bind( &runPythonObject, obj ); } template<> -inline bool DictWrapper::has<boost::function<void()> >( const std::string & name ) +inline bool DictWrapper::has<std::function<void()> >( const std::string & name ) { if(! d_.has_key(name) ) return false; diff --git a/src/python_coupling/Manager.h b/src/python_coupling/Manager.h index 5acfb0daadcd7d5444cdf757bb62bc8cb6e94236..b6294b6fb0a6f218585b1e75bcc9d1bf5ba262ed 100644 --- a/src/python_coupling/Manager.h +++ b/src/python_coupling/Manager.h @@ -71,8 +71,8 @@ namespace python_coupling { public: WALBERLA_BEFRIEND_SINGLETON; - typedef boost::function<void()> ExporterFunction; - typedef boost::function< boost::python::object ( IBlock&, BlockDataID ) > BlockDataToObjectFunction; + typedef std::function<void()> ExporterFunction; + typedef std::function< boost::python::object ( IBlock&, BlockDataID ) > BlockDataToObjectFunction; ~Manager(); diff --git a/src/python_coupling/PythonCallback.cpp b/src/python_coupling/PythonCallback.cpp index 5573970b16bac2a30d89b2fe675baa70ec02626e..c469b10dfc877aeee8a83af26dbe153032cdc181 100644 --- a/src/python_coupling/PythonCallback.cpp +++ b/src/python_coupling/PythonCallback.cpp @@ -29,9 +29,13 @@ #include "core/Abort.h" #include "core/logging/Logging.h" #include "helper/ExceptionHandling.h" +#include "core/Filesystem.h" - -#include <boost/filesystem.hpp> +#if defined(__GLIBCXX__) && __GLIBCXX__ <= 20160609 +#define CURRENT_PATH_WORKAROUND +#include <unistd.h> +#include <errno.h> +#endif namespace walberla { namespace python_coupling { @@ -52,16 +56,38 @@ namespace python_coupling { code << "'" << *argStrIt << "',"; code << "] \n"; + filesystem::path path ( fileOrModuleName ); +#ifdef CURRENT_PATH_WORKAROUND + // workaround for double free in filesystem::current_path in libstdc++ 5.4 and lower + size_t cwd_size = 16; + char * cwd_buf = (char*) std::malloc(cwd_size * sizeof(char)); - boost::filesystem::path path ( fileOrModuleName ); - path = boost::filesystem::absolute( path ); + while( getcwd( cwd_buf, cwd_size ) == NULL ) + { + if (errno == ERANGE) + { + cwd_size *= 2; + cwd_buf = (char*) std::realloc( cwd_buf, cwd_size * sizeof(char) ); + } + else + { + python_coupling::terminateOnPythonException( std::string("Could not determine working directory") ); + } + } + + std::string cwd(cwd_buf); + std::free(cwd_buf); +#else + filesystem::path cwd = filesystem::current_path(); +#endif + path = filesystem::absolute( path, cwd ); if ( path.extension() == ".py" ) { moduleName = path.stem().string(); if ( ! path.parent_path().empty() ) { - std::string p = boost::filesystem::canonical(path.parent_path()).string(); + std::string p = filesystem::canonical(path.parent_path(), cwd).string(); code << "sys.path.append( r'" << p << "')" << "\n"; } } diff --git a/src/python_coupling/basic_exports/BasicExports.cpp b/src/python_coupling/basic_exports/BasicExports.cpp index 837122b5a4012502f8833584308557621bd11944..a3e4a8f31cbeb1715515319c2b6ff0e37bbe1e42 100644 --- a/src/python_coupling/basic_exports/BasicExports.cpp +++ b/src/python_coupling/basic_exports/BasicExports.cpp @@ -41,6 +41,7 @@ #include "python_coupling/helper/BlockStorageExportHelpers.h" #include "stencil/Directions.h" +#include <boost/version.hpp> using namespace boost::python; @@ -111,6 +112,47 @@ struct NumpyFloatConversion }; +#if BOOST_VERSION < 106300 +// taken from https://github.com/boostorg/python/commit/97e4b34a15978ca9d7c296da2de89b78bba4e0d5 +template <class T> +struct exportSharedPtr +{ + exportSharedPtr() + { + converter::registry::insert( &convertible, &construct, boost::python::type_id<std::shared_ptr<T> >() +#ifndef BOOST_PYTHON_NO_PY_SIGNATURES + , &converter::expected_from_python_type_direct<T>::get_pytype +#endif + ); + } + +private: + static void* convertible( PyObject* p ) + { + if ( p == Py_None ) + return p; + + return converter::get_lvalue_from_python( p, converter::registered<T>::converters ); + } + + static void construct( PyObject* source, converter::rvalue_from_python_stage1_data* data ) + { + void* const storage = ( (converter::rvalue_from_python_storage< std::shared_ptr<T> >*) data )->storage.bytes; + // Deal with the "None" case. + if ( data->convertible == source ) + new (storage) std::shared_ptr<T>(); + else + { + std::shared_ptr<void> hold_convertible_ref_count( (void*)0, converter::shared_ptr_deleter( handle<>( borrowed( source ) ) ) ); + // use aliasing constructor + new (storage) std::shared_ptr<T>( hold_convertible_ref_count, static_cast<T*>(data->convertible) ); + } + + data->convertible = storage; + } +}; +#endif + //====================================================================================================================== // // Helper Functions @@ -609,6 +651,10 @@ void exportTiming() .def( self_ns::str(self) ) ; +#if BOOST_VERSION < 106300 + exportSharedPtr<WcTimingTree>(); +#endif + } @@ -996,6 +1042,10 @@ void exportStructuredBlockStorage() .add_property( "periodic", &SbS_periodic ) ; + +#if BOOST_VERSION < 106300 + exportSharedPtr<StructuredBlockStorage>(); +#endif } //====================================================================================================================== @@ -1013,6 +1063,11 @@ void exportCommunication() using communication::UniformMPIDatatypeInfo; class_< UniformMPIDatatypeInfo, shared_ptr<UniformMPIDatatypeInfo>, boost::noncopyable> ( "UniformMPIDatatypeInfo", no_init ); + +#if BOOST_VERSION < 106300 + exportSharedPtr<UniformPackInfo>(); + exportSharedPtr<UniformMPIDatatypeInfo>(); +#endif } //====================================================================================================================== diff --git a/src/python_coupling/helper/MplHelpers.h b/src/python_coupling/helper/MplHelpers.h index ff5969f75dbc2ab7a7778749fed990be7f85432c..640f45637b09d10dc54904250749830dea43fbc8 100644 --- a/src/python_coupling/helper/MplHelpers.h +++ b/src/python_coupling/helper/MplHelpers.h @@ -61,7 +61,7 @@ struct NonCopyableWrap {}; #define FunctionExporterClass( functionName, functionSignature ) \ struct Exporter_##functionName \ { \ - typedef boost::function< functionSignature > FunctionType;\ + typedef std::function< functionSignature > FunctionType;\ Exporter_##functionName( const IBlock * block, ConstBlockDataID id )\ : block_( block ), blockDataID_( id )\ {}\ diff --git a/src/timeloop/PerformanceMeter.cpp b/src/timeloop/PerformanceMeter.cpp index 1f4f5c13dce935e034d3e34f69fc1d58b4cd489c..7af5f847d18ba2ae2bc51049fbe8706a3d30a0a7 100644 --- a/src/timeloop/PerformanceMeter.cpp +++ b/src/timeloop/PerformanceMeter.cpp @@ -51,7 +51,7 @@ namespace timeloop { timeloop.addFuncBeforeTimeStep( perfMeter.getBeforeFunction() ); \endcode *******************************************************************************************************************/ - boost::function<void () > PerformanceMeter::getBeforeFunction() + std::function<void () > PerformanceMeter::getBeforeFunction() { return boost::bind ( &PerformanceMeter::timingStart, this ); } @@ -64,7 +64,7 @@ namespace timeloop { timeloop.addFuncAfterTimeStep ( perfMeter.getAfterFunction() ); \endcode *******************************************************************************************************************/ - boost::function<void () > PerformanceMeter::getAfterFunction() + std::function<void () > PerformanceMeter::getAfterFunction() { return boost::bind ( &PerformanceMeter::timingEnd, this ); } diff --git a/src/timeloop/PerformanceMeter.h b/src/timeloop/PerformanceMeter.h index d08a3fb1b79fd79f5ade7ce5d78b489fa89db84d..732121789149a1553e927fe2eb5d24e8ffa07846 100644 --- a/src/timeloop/PerformanceMeter.h +++ b/src/timeloop/PerformanceMeter.h @@ -24,7 +24,7 @@ #include "domain_decomposition/StructuredBlockStorage.h" #include <boost/bind.hpp> -#include <boost/function.hpp> +#include <functional> #include <iostream> #include <map> @@ -72,7 +72,7 @@ namespace timeloop { class PerformanceMeter { public: - typedef boost::function< uint_t(const IBlock &) > CountFunction; + typedef std::function< uint_t(const IBlock &) > CountFunction; PerformanceMeter( StructuredBlockStorage & blockStorage ); @@ -86,8 +86,8 @@ namespace timeloop { void timingStart(); void timingEnd(); - boost::function<void () > getBeforeFunction(); - boost::function<void () > getAfterFunction(); + std::function<void () > getBeforeFunction(); + std::function<void () > getAfterFunction(); void clear(); //@} diff --git a/src/timeloop/SelectableFunctionCreators.h b/src/timeloop/SelectableFunctionCreators.h index f00d5a3a0f298c901665b05115335d0c5c562e26..b6762e469e37afc1f3c093c76af35c822731ec82 100644 --- a/src/timeloop/SelectableFunctionCreators.h +++ b/src/timeloop/SelectableFunctionCreators.h @@ -26,7 +26,7 @@ #include "domain_decomposition/BlockStorage.h" #include <boost/bind.hpp> -#include <boost/function.hpp> +#include <functional> #include <string> @@ -38,7 +38,7 @@ namespace timeloop { template < typename FuncType > struct FuncCreator { - FuncCreator( boost::function< FuncType > fct, + FuncCreator( std::function< FuncType > fct, const std::string& identifier = std::string(), const Set<SUID>& requiredSelectors = Set<SUID>::emptySet(), const Set<SUID>& incompatibleSelectors = Set<SUID>::emptySet() ) @@ -46,7 +46,7 @@ namespace timeloop { requiredSelectors_( requiredSelectors ), incompatibleSelectors_( incompatibleSelectors ) {} - boost::function< FuncType > function_; + std::function< FuncType > function_; std::string identifier_; Set<SUID> requiredSelectors_; Set<SUID> incompatibleSelectors_; @@ -58,7 +58,7 @@ namespace timeloop { { SelectableFunction() {} - SelectableFunction ( boost::function< FuncType > fct, + SelectableFunction ( std::function< FuncType > fct, const std::string& identifier = std::string(), const Set<SUID>& requiredSelectors = Set<SUID>::emptySet(), const Set<SUID>& incompatibleSelectors = Set<SUID>::emptySet() ) @@ -72,14 +72,14 @@ namespace timeloop { return *this; } - selectable::SetSelectableObject< boost::function<FuncType>, SUID > selectableFunc_; + selectable::SetSelectableObject< std::function<FuncType>, SUID > selectableFunc_; }; struct BeforeFunction : public SelectableFunction< void () > { BeforeFunction() {} - BeforeFunction(boost::function< void () > fct, + BeforeFunction(std::function< void () > fct, const std::string& id = std::string(), const Set<SUID>& req = Set<SUID>::emptySet(), const Set<SUID>& incomp = Set<SUID>::emptySet()) @@ -97,7 +97,7 @@ namespace timeloop { struct AfterFunction : public SelectableFunction< void () > { AfterFunction() {} - AfterFunction(boost::function< void () > fct, + AfterFunction(std::function< void () > fct, const std::string& id = std::string(), const Set<SUID>& req = Set<SUID>::emptySet(), const Set<SUID>& incomp = Set<SUID>::emptySet()) @@ -115,14 +115,14 @@ namespace timeloop { template< typename T > struct SweepOnBlock { - SweepOnBlock( boost::function< T* ( IBlock* const block ) > function, + SweepOnBlock( std::function< T* ( IBlock* const block ) > function, const std::string& identifier = std::string(), const Set<SUID>& required = Set<SUID>::emptySet(), const Set<SUID>& incompatible = Set<SUID>::emptySet() ) : function_( function ), identifier_( identifier ), requiredSelectors_( required ), incompatibleSelectors_( incompatible ) {} - boost::function< T* ( IBlock* const block ) > function_; + std::function< T* ( IBlock* const block ) > function_; std::string identifier_; Set<SUID> requiredSelectors_; diff --git a/src/timeloop/SweepTimeloop.h b/src/timeloop/SweepTimeloop.h index 33daeb7b52df4b542ebb4488d89ea42dc01bc96f..a9b4d6d2ad88692a1c86e674e82a1c2f80cd897d 100644 --- a/src/timeloop/SweepTimeloop.h +++ b/src/timeloop/SweepTimeloop.h @@ -26,7 +26,7 @@ #include "Timeloop.h" #include "domain_decomposition/StructuredBlockStorage.h" -#include <boost/function.hpp> +#include <functional> #include <map> diff --git a/src/timeloop/Timeloop.h b/src/timeloop/Timeloop.h index 3733f166800dccf7da34a197d6a4d832167af8f9..35d59fbcbb29aa703604a70119c7e642405c3bac 100644 --- a/src/timeloop/Timeloop.h +++ b/src/timeloop/Timeloop.h @@ -30,13 +30,13 @@ #include "core/timing/TimingPool.h" #include "core/uid/SUID.h" -#include <boost/function.hpp> +#include <functional> namespace walberla { namespace timeloop { -typedef boost::function<void ()> VoidFctNoArguments; +typedef std::function<void ()> VoidFctNoArguments; //******************************************************************************************************************* diff --git a/src/vtk/ChainedFilter.h b/src/vtk/ChainedFilter.h index 43411c80d7779832cda4389369f7ba916939ec7d..573fff5c160854ac95cc72880f3b2c192c8e82c6 100644 --- a/src/vtk/ChainedFilter.h +++ b/src/vtk/ChainedFilter.h @@ -25,7 +25,7 @@ #include "core/cell/CellSet.h" #include "domain_decomposition/StructuredBlockStorage.h" -#include <boost/function.hpp> +#include <functional> namespace walberla { @@ -37,7 +37,7 @@ class ChainedFilter { public: - typedef boost::function< void ( CellSet& filteredCells, const IBlock& block, const StructuredBlockStorage& storage, const uint_t ghostLayers ) > CellFilter; + typedef std::function< void ( CellSet& filteredCells, const IBlock& block, const StructuredBlockStorage& storage, const uint_t ghostLayers ) > CellFilter; void addFilter( const CellFilter& filter ) { filters_.push_back( filter ); } diff --git a/src/vtk/Initialization.h b/src/vtk/Initialization.h index 6970130315c2f96d7c7c26e025667e00f20e6937..b08caac6a49eb3f7a0e2f024a32cc6f62d1b2505 100644 --- a/src/vtk/Initialization.h +++ b/src/vtk/Initialization.h @@ -26,7 +26,7 @@ #include "core/config/Config.h" #include "domain_decomposition/StructuredBlockStorage.h" -#include <boost/function.hpp> +#include <functional> #include <string> @@ -37,7 +37,7 @@ namespace vtk { // For documentation see the documentation of function "initializeVTKOutput" in Initialization.cpp -typedef boost::function< void () > OutputFunction; +typedef std::function< void () > OutputFunction; struct SelectableOutputFunction { @@ -76,7 +76,7 @@ void initializeVTKOutput( std::map< std::string, SelectableOutputFunction > & ou const std::map< std::string, VTKOutput::CellFilter > & filters, const std::map< std::string, VTKOutput::BeforeFunction > & beforeFunctions ); -typedef boost::function< void ( std::vector< shared_ptr< BlockCellDataWriterInterface > > & writers, +typedef std::function< void ( std::vector< shared_ptr< BlockCellDataWriterInterface > > & writers, std::map< std::string, VTKOutput::CellFilter > & filters, std::map< std::string, VTKOutput::BeforeFunction > & beforeFunctions ) > RegisterVTKOutputFunction; diff --git a/src/vtk/VTKOutput.cpp b/src/vtk/VTKOutput.cpp index b9a5e0f7d4e7b6a3d0105ff5a107c8609fb95a33..7e660ac3157ab190a038781ea2f9ee8840a7f251 100644 --- a/src/vtk/VTKOutput.cpp +++ b/src/vtk/VTKOutput.cpp @@ -138,20 +138,20 @@ void VTKOutput::init( const std::string & identifier ) WALBERLA_ROOT_SECTION() { - boost::filesystem::path path( baseFolder_ + "/" + identifier_ ); - if( boost::filesystem::exists( path ) && executionCounter_ == 0 ) - boost::filesystem::remove_all( path ); + filesystem::path path( baseFolder_ + "/" + identifier_ ); + if( filesystem::exists( path ) && executionCounter_ == 0 ) + filesystem::remove_all( path ); - boost::filesystem::path pvd( baseFolder_ + "/" + identifier_ + ".pvd" ); - if( boost::filesystem::exists( pvd ) && executionCounter_ == 0 ) + filesystem::path pvd( baseFolder_ + "/" + identifier_ + ".pvd" ); + if( filesystem::exists( pvd ) && executionCounter_ == 0 ) std::remove( pvd.string().c_str() ); - boost::filesystem::path basePath( baseFolder_ ); - if( !boost::filesystem::exists( basePath ) ) - boost::filesystem::create_directories( basePath ); + filesystem::path basePath( baseFolder_ ); + if( !filesystem::exists( basePath ) ) + filesystem::create_directories( basePath ); - if ( !boost::filesystem::exists( path ) ) - boost::filesystem::create_directories( path ); + if ( !filesystem::exists( path ) ) + filesystem::create_directories( path ); } WALBERLA_MPI_WORLD_BARRIER(); @@ -181,9 +181,9 @@ void VTKOutput::forceWrite( uint_t number, const bool immediatelyWriteCollectors { if( !useMPIIO_ ) { - boost::filesystem::path tpath( path.str() ); - if( !boost::filesystem::exists( tpath ) ) - boost::filesystem::create_directory( tpath ); + filesystem::path tpath( path.str() ); + if( !filesystem::exists( tpath ) ) + filesystem::create_directory( tpath ); } } WALBERLA_MPI_WORLD_BARRIER(); @@ -1730,7 +1730,7 @@ void VTKOutput::writePVTI( const uint_t collector ) const ofs << " </PCellData>\n"; - std::vector< boost::filesystem::path > files; + std::vector< filesystem::path > files; getFilenames( files, collector ); for( auto file = files.begin(); file != files.end(); ++file ) @@ -1780,7 +1780,7 @@ void VTKOutput::writePVTI_sampled( const uint_t collector ) const ofs << " </PCellData>\n"; - std::vector< boost::filesystem::path > files; + std::vector< filesystem::path > files; getFilenames( files, collector ); for( auto file = files.begin(); file != files.end(); ++file ) @@ -1928,7 +1928,7 @@ void VTKOutput::writePVTU( const uint_t collector ) const ofs << " </PCellData>\n"; - std::vector< boost::filesystem::path > files; + std::vector< filesystem::path > files; getFilenames( files, collector ); for( auto file = files.begin(); file != files.end(); ++file ) @@ -1980,17 +1980,17 @@ bool VTKOutput::writeCombinedVTU( std::string localPart, const uint_t collector -void VTKOutput::getFilenames( std::vector< boost::filesystem::path >& files, const uint_t collector ) const +void VTKOutput::getFilenames( std::vector< filesystem::path >& files, const uint_t collector ) const { std::ostringstream path; path << baseFolder_ << "/" << identifier_ << "/" << executionFolder_ << "_" << collector; - boost::filesystem::path directory( path.str() ); + filesystem::path directory( path.str() ); - WALBERLA_ASSERT( boost::filesystem::exists( directory ) ); + WALBERLA_ASSERT( filesystem::exists( directory ) ); - for( boost::filesystem::directory_iterator file( directory ); file != boost::filesystem::directory_iterator(); ++file ) + for( filesystem::directory_iterator file( directory ); file != filesystem::directory_iterator(); ++file ) { - WALBERLA_ASSERT( boost::filesystem::is_regular_file( file->path() ) && !boost::filesystem::is_directory( file->path() ) ); + WALBERLA_ASSERT( filesystem::is_regular_file( file->path() ) && !filesystem::is_directory( file->path() ) ); files.push_back( file->path() ); } } diff --git a/src/vtk/VTKOutput.h b/src/vtk/VTKOutput.h index 71cec90a9f124875c962ee19cc135851ea1f773e..9b5945630446d443c88bfd5adda6b0bf77b3fc76 100644 --- a/src/vtk/VTKOutput.h +++ b/src/vtk/VTKOutput.h @@ -33,9 +33,8 @@ #include "domain_decomposition/StructuredBlockStorage.h" -#include <boost/filesystem/operations.hpp> -#include <boost/filesystem/path.hpp> -#include <boost/function.hpp> +#include "core/Filesystem.h" +#include <functional> #include <boost/tuple/tuple.hpp> #include <fstream> @@ -144,8 +143,8 @@ public: const bool continuousNumbering, const bool binary, const bool littleEndian, const bool useMPIIO, const uint_t initialExecutionCount ); - typedef boost::function< void () > BeforeFunction; - typedef boost::function< void ( CellSet& filteredCells, const IBlock& block, + typedef std::function< void () > BeforeFunction; + typedef std::function< void ( CellSet& filteredCells, const IBlock& block, const StructuredBlockStorage& storage, const uint_t ghostLayers ) > CellFilter; ~VTKOutput(); @@ -271,7 +270,7 @@ private: bool writeCombinedVTI_sampled( std::string localPart, const uint_t collector ) const; bool writeCombinedVTU(std::string localPart, const uint_t collector) const; - void getFilenames( std::vector< boost::filesystem::path >& blocks, const uint_t collector ) const; + void getFilenames( std::vector< filesystem::path >& blocks, const uint_t collector ) const; void writePPointData( std::ofstream& ofs ) const; void writePCellData( std::ofstream& ofs ) const; diff --git a/src/vtk/python/Exports.cpp b/src/vtk/python/Exports.cpp index 94c0906b1c008518db0fa980d5d27d92f8ee22f0..86fe6e26f3ec502e9ec7288e3254b053c0084527 100644 --- a/src/vtk/python/Exports.cpp +++ b/src/vtk/python/Exports.cpp @@ -40,9 +40,10 @@ namespace internal { shared_ptr<VTKOutput> VTKOutput_create(const shared_ptr<StructuredBlockStorage> & sbs, const std::string & identifier, const std::string & baseFolder, const std::string & executionFolder, - const bool binary, const bool littleEndian, const bool useMPIIO ) + const bool binary, const bool littleEndian, const bool useMPIIO, + uint_t ghostLayers=0) { - return createVTKOutput_BlockData(*sbs, identifier, 1, 0, false, baseFolder, executionFolder, + return createVTKOutput_BlockData(*sbs, identifier, 1, ghostLayers, false, baseFolder, executionFolder, true, binary, littleEndian, useMPIIO, 0); } @@ -72,15 +73,18 @@ void exportModuleToPython() ; def("makeOutput", internal::VTKOutput_create, (arg("blocks"), arg("name"), arg("baseFolder")=".", - arg("executionFolder")="vtk", arg("binary")=true, arg("littleEndian")=true, arg("useMPIIO")=true)); + arg("executionFolder")="vtk", arg("binary")=true, + arg("littleEndian")=true, arg("useMPIIO")=true, + arg("ghostLayers")=0)); class_<VTKOutput, shared_ptr<VTKOutput>, boost::noncopyable > ("VTKOutput", no_init) - .def( "addCellDataWriter", &VTKOutput::addCellDataWriter ) - .def( "write" , &internal::VTKOutput_write ) + .def( "addCellDataWriter" , &VTKOutput::addCellDataWriter ) + .def( "write" , &internal::VTKOutput_write ) + .def( "__call__" , &internal::VTKOutput_write ) .def( "addAABBInclusionFilter", &VTKOutput::addAABBInclusionFilter ) .def( "addAABBExclusionFilter", &VTKOutput::addAABBExclusionFilter ) - .def( "setSamplingResolution", p_setSamplingResolution1 ) - .def( "setSamplingResolution", p_setSamplingResolution2 ) + .def( "setSamplingResolution" , p_setSamplingResolution1 ) + .def( "setSamplingResolution" , p_setSamplingResolution2 ) ; } diff --git a/src/waLBerlaDefinitions.in.h b/src/waLBerlaDefinitions.in.h index 15a6df25970d702d06b0aae11c774f2b8e811e2f..26b6627685ab451ae693fb32f8af4dfe0080d8aa 100644 --- a/src/waLBerlaDefinitions.in.h +++ b/src/waLBerlaDefinitions.in.h @@ -23,7 +23,6 @@ #cmakedefine WALBERLA_BUILD_WITH_METIS #cmakedefine WALBERLA_BUILD_WITH_PARMETIS -#cmakedefine WALBERLA_BUILD_WITH_BOOST_THREAD #cmakedefine WALBERLA_BUILD_WITH_PYTHON #cmakedefine WALBERLA_BUILD_WITH_FFT @@ -43,6 +42,13 @@ #cmakedefine WALBERLA_CXX_COMPILER_IS_MSVC #cmakedefine WALBERLA_CXX_COMPILER_IS_CLANG +#cmakedefine WALBERLA_USE_STD_EXPERIMENTAL_FILESYSTEM +#cmakedefine WALBERLA_USE_STD_FILESYSTEM +#cmakedefine WALBERLA_USE_STD_EXPERIMENTAL_ANY +#cmakedefine WALBERLA_USE_STD_ANY +#cmakedefine WALBERLA_USE_STD_EXPERIMENTAL_OPTIONAL +#cmakedefine WALBERLA_USE_STD_OPTIONAL + // SIMD #cmakedefine WALBERLA_SIMD_FORCE_SCALAR diff --git a/tests/blockforest/BlockDataIOTest.cpp b/tests/blockforest/BlockDataIOTest.cpp index 6a550599a27983226082edef5c75c8a2495ed803..291b3322a6e1b1324bf74f2ce27cbaed5ec0423e 100644 --- a/tests/blockforest/BlockDataIOTest.cpp +++ b/tests/blockforest/BlockDataIOTest.cpp @@ -91,7 +91,7 @@ int main( int argc, char* argv[] ) auto dataHandling = make_shared< field::DefaultBlockDataHandling< FieldType > >( sbf, uint_t(3), 0.0, field::zyxf ); auto originalFieldId = sbf->addBlockData( dataHandling, "OriginalField", None, Empty ); - math::seedRandomGenerator( numeric_cast<boost::mt19937::result_type>( MPIManager::instance()->rank() ) ); + math::seedRandomGenerator( numeric_cast<std::mt19937::result_type>( MPIManager::instance()->rank() ) ); for( auto it = sbf->begin( None, Empty ); it != sbf->end(); ++it ) { diff --git a/tests/blockforest/StructuredBlockForestTest.cpp b/tests/blockforest/StructuredBlockForestTest.cpp index 84032f8091a58b8c749ec008f2e4fc535ce5af2c..fc9ce847cd0c55800623d99128fd6585109fea03 100644 --- a/tests/blockforest/StructuredBlockForestTest.cpp +++ b/tests/blockforest/StructuredBlockForestTest.cpp @@ -25,7 +25,7 @@ #include "core/debug/TestSubsystem.h" #include "core/mpi/Environment.h" -#include <boost/random/mersenne_twister.hpp> +#include <random> namespace walberla { namespace blockforest { @@ -418,7 +418,7 @@ static void test() { bb = *( block->getData< CellInterval >( bid ) ); WALBERLA_CHECK_EQUAL( bb, CellInterval(Cell(150,180,210),Cell(199,239,279)) ); - boost::random::mt19937 eng( 23 ); + std::mt19937 eng( 23 ); for( int i = 0; i < 23; ++i ) { const Vector3<real_t> globalPoint = forest.getDomain().getScaled( real_t(1.25) ).randomPoint( eng ); diff --git a/tests/core/CMakeLists.txt b/tests/core/CMakeLists.txt index f81f11461e80d525317c9d909b4ecad08372fd0e..6885cf97661fa507cc240a45207b63a62aec4a43 100644 --- a/tests/core/CMakeLists.txt +++ b/tests/core/CMakeLists.txt @@ -106,10 +106,8 @@ waLBerla_execute_test( NAME EquationSolverTest ) waLBerla_compile_test( FILES mpi/BufferTest.cpp ) waLBerla_execute_test( NAME BufferTest ) -if( WALBERLA_BUILD_WITH_BOOST_THREAD ) - waLBerla_compile_test( FILES mpi/BufferSystemTest.cpp ) - waLBerla_execute_test( NAME BufferSystemTest PROCESSES 4 ) -endif() +waLBerla_compile_test( FILES mpi/BufferSystemTest.cpp ) +waLBerla_execute_test( NAME BufferSystemTest PROCESSES 4 ) waLBerla_compile_test( FILES mpi/BroadcastTest.cpp ) waLBerla_execute_test( NAME BroadcastTest1 COMMAND $<TARGET_FILE:BroadcastTest> ) diff --git a/tests/core/cell/CellIntervalTest.cpp b/tests/core/cell/CellIntervalTest.cpp index bf4f42da5769136b24323e1f3c99eb429bdf2d78..5ce0c57f26552353f4fa117c679c59cb15b687ca 100644 --- a/tests/core/cell/CellIntervalTest.cpp +++ b/tests/core/cell/CellIntervalTest.cpp @@ -23,19 +23,20 @@ #include "core/cell/CellInterval.h" #include "core/debug/TestSubsystem.h" -#include <boost/random/mersenne_twister.hpp> -#include <boost/random/uniform_int.hpp> +#include <random> #include <iostream> #include <iterator> using namespace walberla; +typedef std::mersenne_twister_engine< walberla::uint32_t, 32, 351, 175, 19, 0xccab8ee7, 11, 0xffffffff, 7, 0x31b6ab00, 15, 0xffe50000, 17, 0xa37d3c92 > mt11213b; + CellInterval makeRandomInterval(uint_t maxSize) { - static boost::mt11213b rng; - boost::uniform_int<cell_idx_t> dist( std::numeric_limits<cell_idx_t>::min(), std::numeric_limits<cell_idx_t>::max() - cell_idx_c( maxSize ) ); - boost::uniform_int<uint_t> dist2( uint_t(0), maxSize ); + static mt11213b rng; + std::uniform_int_distribution<cell_idx_t> dist( std::numeric_limits<cell_idx_t>::min(), std::numeric_limits<cell_idx_t>::max() - cell_idx_c( maxSize ) ); + std::uniform_int_distribution<uint_t> dist2( uint_t(0), maxSize ); cell_idx_t xMin = dist(rng); cell_idx_t yMin = dist(rng); @@ -50,10 +51,10 @@ CellInterval makeRandomInterval(uint_t maxSize) CellInterval makeRandomEmptyInterval(uint_t maxSize) { - static boost::mt11213b rng; - boost::uniform_int<cell_idx_t> dist( std::numeric_limits<cell_idx_t>::min() + cell_idx_c( maxSize ), std::numeric_limits<cell_idx_t>::max() - cell_idx_c( maxSize ) ); - boost::uniform_int<uint_t> dist2( uint_t(1), maxSize ); - boost::uniform_int<uint_t> dist3( uint_t(0), uint_t(1) ); + static mt11213b rng; + std::uniform_int_distribution<cell_idx_t> dist( std::numeric_limits<cell_idx_t>::min() + cell_idx_c( maxSize ), std::numeric_limits<cell_idx_t>::max() - cell_idx_c( maxSize ) ); + std::uniform_int_distribution<uint_t> dist2( uint_t(1), maxSize ); + std::uniform_int_distribution<uint_t> dist3( uint_t(0), uint_t(1) ); cell_idx_t xMin = dist(rng); cell_idx_t yMin = dist(rng); @@ -81,8 +82,8 @@ CellInterval makeRandomEmptyInterval(uint_t maxSize) Cell makeRandomCell() { - static boost::mt11213b rng; - boost::uniform_int<cell_idx_t> dist( std::numeric_limits<cell_idx_t>::min(), std::numeric_limits<cell_idx_t>::max() ); + static mt11213b rng; + std::uniform_int_distribution<cell_idx_t> dist( std::numeric_limits<cell_idx_t>::min(), std::numeric_limits<cell_idx_t>::max() ); return Cell( dist(rng), dist(rng), dist(rng) ); } diff --git a/tests/core/cell/CellTest.cpp b/tests/core/cell/CellTest.cpp index 1cdc574744a3dd8da3924483bd50fa925b69b8de..55c6097baf07567577a250c018714b3fd977baff 100644 --- a/tests/core/cell/CellTest.cpp +++ b/tests/core/cell/CellTest.cpp @@ -23,8 +23,7 @@ #include "core/cell/Cell.h" #include "core/debug/TestSubsystem.h" -#include <boost/random/mersenne_twister.hpp> -#include <boost/random/uniform_int.hpp> +#include <random> using namespace walberla; @@ -135,8 +134,9 @@ int main( int /*argc*/, char** /*argv*/ ) { debug::enterTestMode(); - boost::mt11213b rng; - boost::uniform_int<cell_idx_t> dist( std::numeric_limits<cell_idx_t>::min(), std::numeric_limits<cell_idx_t>::max() ); + typedef std::mersenne_twister_engine< walberla::uint32_t, 32, 351, 175, 19, 0xccab8ee7, 11, 0xffffffff, 7, 0x31b6ab00, 15, 0xffe50000, 17, 0xa37d3c92 > mt11213b; + mt11213b rng; + std::uniform_int_distribution<cell_idx_t> dist( std::numeric_limits<cell_idx_t>::min(), std::numeric_limits<cell_idx_t>::max() ); for(int i = 0; i < 100000; ++i) { diff --git a/tests/core/load_balancing/MetisTest.cpp b/tests/core/load_balancing/MetisTest.cpp index a69cffb9957c29a37a128add41b0e983646e2e74..a460077c21653d9e628c12f868e330012a7d861f 100644 --- a/tests/core/load_balancing/MetisTest.cpp +++ b/tests/core/load_balancing/MetisTest.cpp @@ -40,7 +40,6 @@ #include "vtk/BlockCellDataWriter.h" #include <boost/lexical_cast.hpp> -#include <boost/random.hpp> int main( int argc, char * argv[] ) { diff --git a/tests/core/load_balancing/ParMetisTest.cpp b/tests/core/load_balancing/ParMetisTest.cpp index ce43ce97b828f197c65e0dacb986d07105616fee..0b9643961ab083a4da5a4fc886c5060eb9bc4116 100644 --- a/tests/core/load_balancing/ParMetisTest.cpp +++ b/tests/core/load_balancing/ParMetisTest.cpp @@ -42,7 +42,6 @@ #include "vtk/BlockCellDataWriter.h" #include <boost/lexical_cast.hpp> -#include <boost/random.hpp> int main( int argc, char * argv[] ) { @@ -131,7 +130,7 @@ int main( int argc, char * argv[] ) int64_t numflag = 0; int64_t nparts = int64_c( partitions ); std::vector< double > tpwgts( partitions, 1.0 / numeric_cast<double>( partitions ) ); - std::vector< double > ubvec( ncon, 1.05 ); + std::vector< double > ubvec( numeric_cast<size_t>(ncon), 1.05 ); int64_t options[] = {0,0,0}; int64_t edgecut; std::vector< int64_t > part( fieldSize[0] * fieldSize[1] ); diff --git a/tests/core/math/GenericAABBTest.cpp b/tests/core/math/GenericAABBTest.cpp index 6a5d4ce9ac814ddcf60a238a6d56e7c0494e2259..9194c0ba802093334f89a50532ec45a36b27879b 100644 --- a/tests/core/math/GenericAABBTest.cpp +++ b/tests/core/math/GenericAABBTest.cpp @@ -27,8 +27,7 @@ #include "stencil/D3CornerStencil.h" -#include <boost/random/mersenne_twister.hpp> -#include <boost/random/uniform_real.hpp> +#include <random> using namespace walberla; @@ -112,7 +111,7 @@ void testNonEmptyAABB( const GenericAABB< T > & aabb ) WALBERLA_CHECK_FLOAT_EQUAL( tmpAABB.volume(), T(0) ); WALBERLA_CHECK_IDENTICAL( tmpAABB.volume(), aabb.intersectionVolume( intersectingBox ) ); - boost::random::mt19937 urng; + std::mt19937 urng; for( int i = 0; i < 100; ++i ) { auto p = aabb.randomPoint( urng ); @@ -530,9 +529,10 @@ void testConstructors( const T x0, const T y0, const T z0, const T x1, const T y template< typename T > void randomTest() { - boost::mt11213b rng; + typedef std::mersenne_twister_engine< walberla::uint32_t, 32, 351, 175, 19, 0xccab8ee7, 11, 0xffffffff, 7, 0x31b6ab00, 15, 0xffe50000, 17, 0xa37d3c92 > mt11213b; + mt11213b rng; - boost::uniform_real<T> dist( -T(10), T(10) ); + std::uniform_real_distribution<T> dist( -T(10), T(10) ); for( int i = 0; i < 1000; ++i ) { @@ -600,7 +600,7 @@ void testAABBDistancesRandom( const GenericAABB< T > & baseAABB ) { static const uint_t NUM_BOXES = 100; static const uint_t NUM_POINTS = 1000; - boost::random::mt19937 rng; + std::mt19937 rng; for( uint_t i = 0; i < NUM_BOXES; ++i ) { diff --git a/tests/core/math/PlaneTest.cpp b/tests/core/math/PlaneTest.cpp index b74f2c30fea85eae761c062afad06f544634f1d5..73e7d56c73808062b320609666219077e374398c 100644 --- a/tests/core/math/PlaneTest.cpp +++ b/tests/core/math/PlaneTest.cpp @@ -25,9 +25,7 @@ #include "core/math/Vector3.h" #include "core/mpi/Environment.h" -#include <boost/random/mersenne_twister.hpp> -#include <boost/random/normal_distribution.hpp> -#include <boost/random/variate_generator.hpp> +#include <random> #include <cmath> #include <vector> @@ -39,9 +37,9 @@ template < typename scalar_t > struct RandomPointGenerator { typedef walberla::Vector3<scalar_t> vector_t; - typedef boost::mt11213b RandomNumberEngine; - typedef boost::normal_distribution<scalar_t> NormalDistribution; - typedef boost::variate_generator< RandomNumberEngine, NormalDistribution > Generator; + typedef std::mersenne_twister_engine< walberla::uint32_t, 32, 351, 175, 19, 0xccab8ee7, 11, 0xffffffff, 7, 0x31b6ab00, 15, 0xffe50000, 17, 0xa37d3c92 > mt11213b; + typedef mt11213b RandomNumberEngine; + typedef std::normal_distribution<scalar_t> NormalDistribution; RandomPointGenerator( const vector_t & mu, const vector_t & sigma ) { @@ -49,17 +47,19 @@ struct RandomPointGenerator { RandomNumberEngine rne; rne.seed( numeric_cast< RandomNumberEngine::result_type >( i * 642573 ) ); - normalDistributions.push_back( Generator( rne, NormalDistribution( mu[i], sigma[i] ) ) ); + engines.push_back( rne ); + normalDistributions.push_back( NormalDistribution( mu[i], sigma[i] ) ); } } vector_t operator()() { - return vector_t( normalDistributions[0](), normalDistributions[1](), normalDistributions[2]() ); + return vector_t( normalDistributions[0](engines[0]), normalDistributions[1](engines[1]), normalDistributions[2](engines[2]) ); } private: - std::vector< Generator > normalDistributions; + std::vector< RandomNumberEngine > engines; + std::vector< NormalDistribution > normalDistributions; }; void testIOStream( const Plane & p ) @@ -135,20 +135,22 @@ int main(int argc, char * argv[]) Vec3Real p1 = rpg(); Vec3Real p2 = rpg(); - if( (p0 - p1).sqrLength() < 1e-6 || (p0 - p2).sqrLength() < 1e-6 || (p2 - p1).sqrLength() < 1e-6 ) + real_t angle = std::acos( (p1-p0) * (p2-p0) / std::sqrt( (p1-p0).sqrLength() * (p2-p0).sqrLength() ) ); + + if( (p0 - p1).sqrLength() < 1e-6 || (p0 - p2).sqrLength() < 1e-6 || (p2 - p1).sqrLength() < 1e-6 || angle < math::PI / real_t(180) ) { --i; continue; } - Plane plane( p0, (p0 - p1) % (p0 - p2) ); + Plane plane( p0, (p0 - p1).getNormalized() % (p0 - p2).getNormalized() ); - WALBERLA_CHECK ( realIsEqual( plane.signedDistance( p0 ), real_t(0) ) ); - WALBERLA_CHECK ( realIsEqual( plane.distance ( p0 ), real_t(0) ) ); - WALBERLA_CHECK ( realIsEqual( plane.signedDistance( p1 ), real_t(0) ) ); - WALBERLA_CHECK ( realIsEqual( plane.distance ( p1 ), real_t(0) ) ); - WALBERLA_CHECK ( realIsEqual( plane.signedDistance( p2 ), real_t(0) ) ); - WALBERLA_CHECK ( realIsEqual( plane.distance ( p2 ), real_t(0) ) ); + WALBERLA_CHECK_FLOAT_EQUAL( plane.signedDistance( p0 ), real_t(0) ); + WALBERLA_CHECK_FLOAT_EQUAL( plane.distance ( p0 ), real_t(0) ); + WALBERLA_CHECK_FLOAT_EQUAL( plane.signedDistance( p1 ), real_t(0) ); + WALBERLA_CHECK_FLOAT_EQUAL( plane.distance ( p1 ), real_t(0) ); + WALBERLA_CHECK_FLOAT_EQUAL( plane.signedDistance( p2 ), real_t(0) ); + WALBERLA_CHECK_FLOAT_EQUAL( plane.distance ( p2 ), real_t(0) ); WALBERLA_CHECK_GREATER_EQUAL( plane.distance( p0 ), real_t(0) ); WALBERLA_CHECK_GREATER_EQUAL( plane.distance( p1 ), real_t(0) ); WALBERLA_CHECK_GREATER_EQUAL( plane.distance( p2 ), real_t(0) ); diff --git a/tests/core/math/PrimesTest.cpp b/tests/core/math/PrimesTest.cpp index 9e8a776a05e536d62cf04797fc5d5d4753bb08a7..141a9704ba2670a11bba4e8d3e342232b2d49c0f 100644 --- a/tests/core/math/PrimesTest.cpp +++ b/tests/core/math/PrimesTest.cpp @@ -27,8 +27,7 @@ #include "core/math/Primes.h" #include "core/mpi/MPIManager.h" -#include <boost/random/mersenne_twister.hpp> -#include <boost/random/uniform_int.hpp> +#include <random> #include <algorithm> #include <numeric> @@ -85,8 +84,9 @@ int main(int argc, char * argv[]) runTests( n ); } - boost::mt11213b rng; - boost::uniform_int<uint_t> dist( 100, 10000 ); + typedef std::mersenne_twister_engine< walberla::uint32_t, 32, 351, 175, 19, 0xccab8ee7, 11, 0xffffffff, 7, 0x31b6ab00, 15, 0xffe50000, 17, 0xa37d3c92 > mt11213b; + mt11213b rng; + std::uniform_int_distribution<uint_t> dist( 100, 10000 ); for(int i = 0; i < 100; ++i) { const uint_t n = dist(rng); diff --git a/tests/core/mpi/BufferSystemTest.cpp b/tests/core/mpi/BufferSystemTest.cpp index 9aa4d0f83d9afd22c4296d04909898666fc67e0c..a6104a87ed537e76b3ce273f3aaf443d838b97e5 100644 --- a/tests/core/mpi/BufferSystemTest.cpp +++ b/tests/core/mpi/BufferSystemTest.cpp @@ -26,22 +26,22 @@ #include "core/mpi/BufferSystem.h" #include "core/mpi/Environment.h" -#include <boost/random/mersenne_twister.hpp> -#include <boost/random/uniform_int.hpp> -#include <boost/random/variate_generator.hpp> -#include <boost/thread/thread.hpp> +#include <random> #include <cmath> #include <iostream> #include <set> +#include <thread> +#include <chrono> using namespace walberla; using mpi::BufferSystem; +using namespace std::literals::chrono_literals; -typedef boost::mt19937 base_generator_type; +typedef std::mt19937 base_generator_type; /** * Utility function for sleeping a random time @@ -58,11 +58,10 @@ void randomSleep( int maxTimeInMs = 20 ) unsigned int seed = static_cast<unsigned int>(std::time(0)) + static_cast<unsigned int>(rank*1000) + counter; generator.seed(seed); - boost::uniform_int<> uni_dist(0,maxTimeInMs); - boost::variate_generator<base_generator_type&, boost::uniform_int<> > uni(generator, uni_dist); + std::uniform_int_distribution<> uni_dist(0,maxTimeInMs); - int sleepTime = uni(); - boost::this_thread::sleep( boost::posix_time::milliseconds( sleepTime ) ); + int sleepTime = uni_dist(generator); + std::this_thread::sleep_for( sleepTime * 1ms ); } diff --git a/tests/core/mpi/BufferTest.cpp b/tests/core/mpi/BufferTest.cpp index 4d1819dcda3c99f99697ae45a6173cf50c918730..c34a1ef8e89d2a138031ba1dde8092be69e7f40a 100644 --- a/tests/core/mpi/BufferTest.cpp +++ b/tests/core/mpi/BufferTest.cpp @@ -36,8 +36,7 @@ #include "core/mpi/RecvBuffer.h" #include "core/mpi/SendBuffer.h" -#include <boost/random/mersenne_twister.hpp> -#include <boost/random/uniform_int.hpp> // #include <boost/random/uniform_int_distribution.hpp> +#include <random> #include <cstring> #include <iostream> @@ -48,9 +47,9 @@ using namespace mpi; template<typename T> void initIntegerContainer( T & container ) { - static boost::mt19937 rng; - boost::uniform_int<typename T::value_type> dist; - boost::uniform_int<size_t> size_dist(10,1000); + static std::mt19937 rng; + std::uniform_int_distribution<typename T::value_type> dist; + std::uniform_int_distribution<size_t> size_dist(10,1000); size_t size = size_dist(rng); container.clear(); @@ -61,9 +60,9 @@ void initIntegerContainer( T & container ) template<typename T> void initIntegerAssocContainer( T & container ) { - static boost::mt19937 rng; - boost::uniform_int<typename T::value_type> dist; - boost::uniform_int<size_t> size_dist(10,1000); + static std::mt19937 rng; + std::uniform_int_distribution<typename T::value_type> dist; + std::uniform_int_distribution<size_t> size_dist(10,1000); size_t size = size_dist(rng); container.clear(); @@ -74,9 +73,9 @@ void initIntegerAssocContainer( T & container ) void initVecBool( std::vector<bool> & vecBool ) { - static boost::mt19937 rng; - boost::uniform_int<walberla::uint32_t> dist; - boost::uniform_int<size_t> size_dist(10,1000); + static std::mt19937 rng; + std::uniform_int_distribution<walberla::uint32_t> dist; + std::uniform_int_distribution<size_t> size_dist(10,1000); size_t size = size_dist(rng); vecBool.clear(); @@ -88,10 +87,10 @@ void initVecBool( std::vector<bool> & vecBool ) template<typename T> void initIntegerMap( T & container ) { - static boost::mt19937 rng; - boost::uniform_int<typename T::mapped_type> mapped_dist; - boost::uniform_int<typename T::key_type> key_dist; - boost::uniform_int<size_t> size_dist(10,1000); + static std::mt19937 rng; + std::uniform_int_distribution<typename T::mapped_type> mapped_dist; + std::uniform_int_distribution<typename T::key_type> key_dist; + std::uniform_int_distribution<size_t> size_dist(10,1000); size_t size = size_dist(rng); container.clear(); @@ -103,9 +102,9 @@ void initIntegerMap( T & container ) template<typename T> void initCellContainer( T & container ) { - static boost::mt19937 rng; - boost::uniform_int<cell_idx_t> dist; - boost::uniform_int<size_t> size_dist(10,1000); + static std::mt19937 rng; + std::uniform_int_distribution<cell_idx_t> dist; + std::uniform_int_distribution<size_t> size_dist(10,1000); size_t size = size_dist(rng); container.clear(); @@ -116,8 +115,8 @@ void initCellContainer( T & container ) template<typename T, std::size_t N> void initBoostArray( boost::array< T, N > & array ) { - static boost::mt19937 rng; - boost::uniform_int<T> dist; + static std::mt19937 rng; + std::uniform_int_distribution<T> dist; for( auto it = array.begin(); it != array.end(); ++it ) *it = dist( rng ); @@ -264,7 +263,7 @@ void bufferTestUInt8() { std::string stdString("Hello World!"), stdStringEmpty; - boost::optional<int> optional0, optional1, optional2, optional3; + walberla::optional<int> optional0, optional1, optional2, optional3; optional2 = 23; optional3 = 42; @@ -278,7 +277,7 @@ void bufferTestUInt8() std::string recvStdString, recvStdStringEmpty; - boost::optional<int> recvOptional0, recvOptional1, recvOptional2, recvOptional3; + walberla::optional<int> recvOptional0, recvOptional1, recvOptional2, recvOptional3; recvOptional0 = 123; recvOptional1 = 123; diff --git a/tests/core/mpi/MPITextFileTest.cpp b/tests/core/mpi/MPITextFileTest.cpp index a1551d8bde94a902052e39d9385e3604a88318d1..1500d730f0fdbada5b765286d26b27e5727fa438 100644 --- a/tests/core/mpi/MPITextFileTest.cpp +++ b/tests/core/mpi/MPITextFileTest.cpp @@ -27,7 +27,7 @@ #include "core/mpi/MPIManager.h" #include "core/mpi/MPITextFile.h" -#include <boost/filesystem.hpp> +#include "core/Filesystem.h" #include <vector> #include <sstream> @@ -61,8 +61,8 @@ void testSameSizeFile( const std::string & filename, const size_t chunkSize ) WALBERLA_MPI_BARRIER(); WALBERLA_ROOT_SECTION() { - if( boost::filesystem::exists( filename ) ) - boost::filesystem::remove( filename ); + if( filesystem::exists( filename ) ) + filesystem::remove( filename ); } WALBERLA_MPI_BARRIER(); } @@ -98,8 +98,8 @@ void testDifferentSizeFile( const std::string & filename, const size_t minChunkS WALBERLA_MPI_BARRIER(); WALBERLA_ROOT_SECTION() { - if( boost::filesystem::exists( filename ) ) - boost::filesystem::remove( filename ); + if( filesystem::exists( filename ) ) + filesystem::remove( filename ); } WALBERLA_MPI_BARRIER(); } diff --git a/tests/core/timing/TimingTreeTest.cpp b/tests/core/timing/TimingTreeTest.cpp index 9d5c539d522657cb51f48bebb3a1737cc44eea8b..862620f326fc8b0eeadcfb55c3b64c6221fd13be 100644 --- a/tests/core/timing/TimingTreeTest.cpp +++ b/tests/core/timing/TimingTreeTest.cpp @@ -25,9 +25,6 @@ #include "core/timing/StaticPolicy.h" #include "core/timing/TimingTree.h" -#include <boost/date_time/posix_time/posix_time.hpp> -#include <boost/thread/thread.hpp> - #include <iostream> using namespace walberla; @@ -41,8 +38,6 @@ int main( int argc, char ** argv ) { debug::enterTestMode(); -#ifdef WALBERLA_BUILD_WITH_BOOST_THREAD - mpi::Environment mpiEnv(argc, argv); WALBERLA_UNUSED( mpiEnv ); @@ -123,7 +118,6 @@ int main( int argc, char ** argv ) // std::cout << tt2; // std::cout << tt3; } -#endif return 0; } diff --git a/tests/cuda/communication/GPUPackInfoCommunicationTest.cpp b/tests/cuda/communication/GPUPackInfoCommunicationTest.cpp index f3f19d085012b02e8947d2d5100a7c2e3ad1dfb6..8d0d66c8ea643d86778064fc7f0ae6001e1e31d5 100644 --- a/tests/cuda/communication/GPUPackInfoCommunicationTest.cpp +++ b/tests/cuda/communication/GPUPackInfoCommunicationTest.cpp @@ -131,7 +131,7 @@ int main( int argc, char ** argv ) BlockDataID asyncGPUFieldId = blocks->addStructuredBlockData< GPUFieldType >( &createGPUField, "asyncGPUField" ); - math::seedRandomGenerator( numeric_cast<boost::mt19937::result_type>( MPIManager::instance()->rank() ) ); + math::seedRandomGenerator( numeric_cast<std::mt19937::result_type>( MPIManager::instance()->rank() ) ); // Initialize CPU field with random values initFields( blocks, sourceFieldId ); @@ -149,11 +149,11 @@ int main( int argc, char ** argv ) // Setup communication schemes for synchronous GPUPackInfo CommSchemeType syncCommScheme(blocks); - syncCommScheme.addPackInfo( boost::make_shared< GPUPackInfoType >( syncGPUFieldId ) ); + syncCommScheme.addPackInfo( make_shared< GPUPackInfoType >( syncGPUFieldId ) ); // Setup communication scheme for asynchronous GPUPackInfo, which uses CUDA streams CommSchemeType asyncCommScheme(blocks); - asyncCommScheme.addPackInfo( boost::make_shared< GPUPackInfoType >( asyncGPUFieldId, streams ) ); + asyncCommScheme.addPackInfo( make_shared< GPUPackInfoType >( asyncGPUFieldId, streams ) ); // Perform one communication step for each scheme syncCommScheme(); diff --git a/tests/field/AccuracyEvaluationTest.cpp b/tests/field/AccuracyEvaluationTest.cpp index 8fedfe317944aa0b710ac8ab6bd0e6526a5119b5..c7656509fbdf86324d345f76bc027c6f90d2050f 100644 --- a/tests/field/AccuracyEvaluationTest.cpp +++ b/tests/field/AccuracyEvaluationTest.cpp @@ -67,8 +67,8 @@ int main( int argc, char* argv[] ) real_t(1), // dx uint_t( 2), uint_t( 1), uint_t( 2) ); // number of processes - //math::seedRandomGenerator( numeric_cast<boost::mt19937::result_type>( std::time(0) ) ); - math::seedRandomGenerator( numeric_cast<boost::mt19937::result_type>( MPIManager::instance()->rank() ) ); + //math::seedRandomGenerator( numeric_cast<std::mt19937::result_type>( std::time(0) ) ); + math::seedRandomGenerator( numeric_cast<std::mt19937::result_type>( MPIManager::instance()->rank() ) ); auto sId = field::addToStorage< ScalarField_T >( blocks, "scalar field" ); auto vId = field::addToStorage< VectorField_T >( blocks, "vector field" ); diff --git a/tests/field/FieldFileIOTest.cpp b/tests/field/FieldFileIOTest.cpp index 2e33e0dceb77076eafafe99a6353527fc63c01cd..6e7a95a2dec44fb408c17e1039df77867e8fdb0b 100644 --- a/tests/field/FieldFileIOTest.cpp +++ b/tests/field/FieldFileIOTest.cpp @@ -114,7 +114,7 @@ int main( int argc, char* argv[] ) auto originalFieldId = field::addToStorage< FieldType >( sbf, "OriginalField" ); auto readFieldId = field::addToStorage< FieldType >( sbf, "ReadField" ); - math::seedRandomGenerator( numeric_cast<boost::mt19937::result_type>( MPIManager::instance()->rank() ) ); + math::seedRandomGenerator( numeric_cast<std::mt19937::result_type>( MPIManager::instance()->rank() ) ); for( auto it = sbf->begin(); it != sbf->end(); ++it ) { diff --git a/tests/field/FieldMPIDatatypesTest.cpp b/tests/field/FieldMPIDatatypesTest.cpp index f5411aeb535c30152ccbeb346d6c3e371b1f82e6..3328c1bd72c222d404c589041a9866fd2a8e33f3 100644 --- a/tests/field/FieldMPIDatatypesTest.cpp +++ b/tests/field/FieldMPIDatatypesTest.cpp @@ -33,9 +33,7 @@ #include "stencil/D3Q27.h" -#include <boost/random/mersenne_twister.hpp> -#include <boost/random/uniform_int_distribution.hpp> -#include <boost/random/uniform_real_distribution.hpp> +#include <random> namespace mpi_datatypes_test { @@ -51,7 +49,7 @@ public: template< typename T, uint_t fSize > void operator()( Field< T, fSize > & field ) { - boost::random::uniform_real_distribution< T > distribution; + std::uniform_real_distribution< T > distribution; for( auto it = field.begin(); it != field.end(); ++it ) { @@ -62,7 +60,7 @@ public: template< typename T, uint_t fSize > void operator()( GhostLayerField< T, fSize > & field ) { - boost::random::uniform_real_distribution< T > distribution; + std::uniform_real_distribution< T > distribution; for( auto it = field.beginWithGhostLayer(); it != field.end(); ++it ) { @@ -71,7 +69,7 @@ public: } private: - boost::random::mt19937 generator_; + std::mt19937 generator_; }; diff --git a/tests/field/FieldTiming.cpp b/tests/field/FieldTiming.cpp index 86fdb06f5e664abb5f4789c638639ccdd985bf4e..5e8fd340756e899de7c9c0c6ca2e725682c60bb8 100644 --- a/tests/field/FieldTiming.cpp +++ b/tests/field/FieldTiming.cpp @@ -196,7 +196,7 @@ double initFieldRandom(DoubleField & field) return sum; } -typedef boost::function<double (const DoubleField & field)> Func; +typedef std::function<double (const DoubleField & field)> Func; void timeFunction( WcTimer & timer, Func f, const DoubleField & field, double sum, double epsilon, int nrExecutions=30 ) { for(int i=0 ; i < nrExecutions; ++i) diff --git a/tests/geometry/RandomPointGenerator.h b/tests/geometry/RandomPointGenerator.h index 8275946f4f2b355f07200963ee5a98b878130e80..097f610c487a1bac04a0141057ac9fedb379d8e8 100644 --- a/tests/geometry/RandomPointGenerator.h +++ b/tests/geometry/RandomPointGenerator.h @@ -23,9 +23,7 @@ #include "core/math/Vector3.h" -#include <boost/random/mersenne_twister.hpp> -#include <boost/random/normal_distribution.hpp> -#include <boost/random/variate_generator.hpp> +#include <random> #include <vector> @@ -33,21 +31,25 @@ template < typename scalar_t > struct RandomPointGenerator { typedef walberla::Vector3<scalar_t> vector_t; - typedef boost::mt11213b RandomNumberEngine; - typedef boost::normal_distribution<scalar_t> NormalDistribution; - typedef boost::variate_generator< RandomNumberEngine, NormalDistribution > Generator; + typedef std::mersenne_twister_engine< walberla::uint32_t, 32, 351, 175, 19, 0xccab8ee7, 11, 0xffffffff, 7, 0x31b6ab00, 15, 0xffe50000, 17, 0xa37d3c92 > mt11213b; + typedef mt11213b RandomNumberEngine; + typedef std::normal_distribution<scalar_t> NormalDistribution; RandomPointGenerator( const vector_t & mu, const vector_t & sigma ) { for( walberla::uint_t i = 0; i < 3; ++i ) - normalDistributions.push_back( Generator( RandomNumberEngine(), NormalDistribution( mu[i], sigma[i] ) ) ); + { + engines.push_back( RandomNumberEngine() ); + normalDistributions.push_back( NormalDistribution( mu[i], sigma[i] ) ); + } } vector_t operator()() { - return vector_t( normalDistributions[0](), normalDistributions[1](), normalDistributions[2]() ); + return vector_t( normalDistributions[0](engines[0]), normalDistributions[1](engines[1]), normalDistributions[2](engines[2]) ); } private: - std::vector< Generator > normalDistributions; + std::vector< RandomNumberEngine > engines; + std::vector< NormalDistribution > normalDistributions; }; diff --git a/tests/geometry/VoxelFileTest.cpp b/tests/geometry/VoxelFileTest.cpp index 3918b08dec89c888e5dc760e3c5f5c51245f4221..3d6d18fa1654edfacffe3637801e0f4274576557 100644 --- a/tests/geometry/VoxelFileTest.cpp +++ b/tests/geometry/VoxelFileTest.cpp @@ -52,10 +52,9 @@ #include "core/logging/Logging.h" #include "core/mpi/MPIManager.h" -#include <boost/filesystem.hpp> +#include "core/Filesystem.h" #include <boost/foreach.hpp> -#include <boost/random/mersenne_twister.hpp> -#include <boost/random/uniform_int.hpp> +#include <random> #ifdef _MSC_VER # pragma warning(push) @@ -69,15 +68,17 @@ # pragma warning(pop) #endif //_MSC_VER +typedef std::mersenne_twister_engine< walberla::uint32_t, 32, 351, 175, 19, 0xccab8ee7, 11, 0xffffffff, 7, 0x31b6ab00, 15, 0xffe50000, 17, 0xa37d3c92 > mt11213b; + /// randomize the memory underlying the vector up the maximal size (== capacity) template<typename T> void randomizeVector( std::vector<T> & v ) { - //boost::random::mt11213b rng; - boost::mt11213b rng; - //boost::random::uniform_int_distribution<T> dist( std::numeric_limits<T>::min(), std::numeric_limits<T>::max() ); - boost::uniform_int<T> dist( std::numeric_limits<T>::min(), std::numeric_limits<T>::max() ); + static_assert(sizeof(T) > sizeof(char), "cannot use char"); + + mt11213b rng; + std::uniform_int_distribution<T> dist( std::numeric_limits<T>::min(), std::numeric_limits<T>::max() ); size_t oldSize = v.size(); v.resize( v.capacity() ); @@ -86,18 +87,64 @@ void randomizeVector( std::vector<T> & v ) v.resize(oldSize); } +template<> +void randomizeVector( std::vector<unsigned char> & v ) +{ + mt11213b rng; + std::uniform_int_distribution<walberla::int16_t> dist( std::numeric_limits<unsigned char>::min(), std::numeric_limits<unsigned char>::max() ); + + size_t oldSize = v.size(); + v.resize( v.capacity() ); + for(typename std::vector<unsigned char>::iterator it = v.begin(); it != v.end(); ++it) + *it = static_cast<unsigned char>( dist(rng) ); + v.resize(oldSize); +} + +template<> +void randomizeVector( std::vector<char> & v ) +{ + mt11213b rng; + std::uniform_int_distribution<int16_t> dist( std::numeric_limits<char>::min(), std::numeric_limits<char>::max() ); + + size_t oldSize = v.size(); + v.resize( v.capacity() ); + for(typename std::vector<char>::iterator it = v.begin(); it != v.end(); ++it) + *it = static_cast<char>( dist(rng) ); + v.resize(oldSize); +} + template<typename T> void makeRandomMultiArray( boost::multi_array<T, 3> & ma) { - //boost::random::mt11213b rng; - boost::mt11213b rng; - //boost::random::uniform_int_distribution<T> dist( std::numeric_limits<T>::min(), std::numeric_limits<T>::max() ); - boost::uniform_int<T> dist( std::numeric_limits<T>::min(), std::numeric_limits<T>::max() ); + static_assert(sizeof(T) > sizeof(char), "cannot use char"); + + mt11213b rng; + std::uniform_int_distribution<T> dist( std::numeric_limits<T>::min(), std::numeric_limits<T>::max() ); for(T* it = ma.data(); it != ma.data() + ma.num_elements(); ++it) *it = dist(rng); } +template<> +void makeRandomMultiArray( boost::multi_array<unsigned char, 3> & ma) +{ + mt11213b rng; + std::uniform_int_distribution<walberla::int16_t> dist( std::numeric_limits<unsigned char>::min(), std::numeric_limits<unsigned char>::max() ); + + for(unsigned char* it = ma.data(); it != ma.data() + ma.num_elements(); ++it) + *it = static_cast<unsigned char>( dist(rng) ); +} + +template<> +void makeRandomMultiArray( boost::multi_array<char, 3> & ma) +{ + mt11213b rng; + std::uniform_int_distribution<int16_t> dist( std::numeric_limits<char>::min(), std::numeric_limits<char>::max() ); + + for(char* it = ma.data(); it != ma.data() + ma.num_elements(); ++it) + *it = static_cast<char>( dist(rng) ); +} + template<typename T> void runTests(const std::string & filename, size_t xSize, size_t ySize, size_t zSize); @@ -162,14 +209,12 @@ void runTests(const std::string & filename, size_t xSize, size_t ySize, size_t z using namespace walberla; using geometry::VoxelFileReader; - namespace fs = boost::filesystem; - WALBERLA_LOG_INFO( "Running Test with size " << xSize << "x" << ySize << "x" << zSize << " T = " << typeid(T).name() ); - fs::path path(filename); + filesystem::path path(filename); - if( fs::exists( path ) ) - fs::remove( path ); + if( filesystem::exists( path ) ) + filesystem::remove( path ); CellInterval aabb(0, 0, 0, cell_idx_c(xSize - 1), cell_idx_c(ySize - 1), cell_idx_c(zSize - 1)); uint_t numCells = aabb.numCells(); @@ -202,8 +247,8 @@ void runTests(const std::string & filename, size_t xSize, size_t ySize, size_t z data.clear(); - WALBERLA_CHECK( fs::exists( path ) ); - WALBERLA_CHECK( fs::is_regular_file( path ) ); + WALBERLA_CHECK( filesystem::exists( path ) ); + WALBERLA_CHECK( filesystem::is_regular_file( path ) ); geometryFile.open(filename); WALBERLA_CHECK( geometryFile.isOpen() ); @@ -349,8 +394,8 @@ void runTests(const std::string & filename, size_t xSize, size_t ySize, size_t z geometryFile.close(); WALBERLA_CHECK( !geometryFile.isOpen() ); - if( fs::exists( path ) ) - fs::remove( path ); + if( filesystem::exists( path ) ) + filesystem::remove( path ); geometryFile.create(filename, xSize, ySize, zSize); @@ -418,8 +463,8 @@ void runTests(const std::string & filename, size_t xSize, size_t ySize, size_t z } WALBERLA_CHECK( runtimeErrorThrown ); geometryFile.close(); - if( fs::exists( fs::path(filename + "0") ) ) - fs::remove( fs::path(filename + "0") ); + if( filesystem::exists( filesystem::path(filename + "0") ) ) + filesystem::remove( filesystem::path(filename + "0") ); if(xSize > 0) { @@ -440,12 +485,12 @@ void runTests(const std::string & filename, size_t xSize, size_t ySize, size_t z } WALBERLA_CHECK( runtimeErrorThrown ); geometryFile.close(); - if( fs::exists( fs::path(filename + "1") ) ) - fs::remove( fs::path(filename + "1") ); + if( filesystem::exists( filesystem::path(filename + "1") ) ) + filesystem::remove( filesystem::path(filename + "1") ); } - if( fs::exists( path ) ) - fs::remove( path ); + if( filesystem::exists( path ) ) + filesystem::remove( path ); } diff --git a/tests/lbm/Poiseuille.cpp b/tests/lbm/Poiseuille.cpp index c1bd59992ee499f2283141d7a3bd27d3a4f3a99a..5e56138fe75b24a278d201d9af3a15226e76582b 100644 --- a/tests/lbm/Poiseuille.cpp +++ b/tests/lbm/Poiseuille.cpp @@ -118,7 +118,7 @@ public: lastMeanError_( 0 ), lastMaxError_( 0 ) { if ( filename.size() > 0 ) - graphWriter_ = boost::make_shared<gather::GnuPlotGraphWriter>( filename ); + graphWriter_ = make_shared<gather::GnuPlotGraphWriter>( filename ); } virtual ~PoiseuilleVelocityDataProcessor() {} diff --git a/tests/lbm/boundary/SimpleDiffusionDirichlet.cpp b/tests/lbm/boundary/SimpleDiffusionDirichlet.cpp index 4515cc13c0dec9b3147fff7d60cfa1629bb76dc6..d28603a3feb1553d8d321d7b2ab216bc3ef14960 100644 --- a/tests/lbm/boundary/SimpleDiffusionDirichlet.cpp +++ b/tests/lbm/boundary/SimpleDiffusionDirichlet.cpp @@ -75,6 +75,7 @@ #include <boost/lexical_cast.hpp> #include <stdexcept> +#include <array> #include "gather/GnuPlotGraphWriter.h" #include "field/vtk/FlagFieldCellFilter.h" @@ -240,6 +241,7 @@ public: piInv_(real_t(1)/math::PI), valid_(uint_c(std::ceil(omega*omega*omega*real_t(10)))), time_( time ), + expArray(), timestep_( uint_t(0u) ), E_max_(maxValue-minValue), E_mean_(maxValue-minValue) @@ -265,7 +267,7 @@ private: const uint_t valid_; const uint_t time_; - real_t expArray[1000]; + std::array<real_t,1000> expArray; uint_t timestep_; real_t E_max_; diff --git a/tests/lbm/geometry/IntersectionRatioTest.cpp b/tests/lbm/geometry/IntersectionRatioTest.cpp index d0296018434b61f6d15df32f88df83d729927bc3..ae7a4a159f2f60f62220b0b691cd9db0826add58 100644 --- a/tests/lbm/geometry/IntersectionRatioTest.cpp +++ b/tests/lbm/geometry/IntersectionRatioTest.cpp @@ -26,7 +26,7 @@ #include "geometry/bodies/Sphere.h" #include "geometry/bodies/AABBBody.h" -#include <boost/random/mersenne_twister.hpp> +#include <random> namespace walberla { @@ -77,7 +77,7 @@ void testAABB() static const math::Vector3<real_t> UNIT( real_t( 1 ), real_t( 1 ), real_t( 1 ) ); static const real_t EPSILON = real_t(1e-4); - boost::random::mt19937 randomEngine; + std::mt19937 randomEngine; std::vector<math::AABB> testAABBs; testAABBs.push_back( math::AABB( -UNIT, UNIT ) ); diff --git a/tests/mesh/MeshAABBIntersectionTest.cpp b/tests/mesh/MeshAABBIntersectionTest.cpp index f950e7609647dbec0a6dc690c5230f58b2a6cdea..fc4711134edbc3068b2011262fa0128330cc4ed6 100644 --- a/tests/mesh/MeshAABBIntersectionTest.cpp +++ b/tests/mesh/MeshAABBIntersectionTest.cpp @@ -29,7 +29,7 @@ #include "mesh/DistanceComputations.h" #include "mesh/TriangleMeshes.h" -#include <boost/random.hpp> +#include <random> #include <boost/lexical_cast.hpp> #include <vector> @@ -53,7 +53,7 @@ void runTests( const uint_t numAABBs ) WALBERLA_CHECK( isIntersecting( triDist, meshAABB, real_t(0) ) ); - boost::random::mt19937 rng( uint32_t(42) ); + std::mt19937 rng( uint32_t(42) ); for(uint_t i = 0; i < numAABBs; ++i) { diff --git a/tests/mesh/MeshAABBSelectionTest.cpp b/tests/mesh/MeshAABBSelectionTest.cpp index 7a95cb4ea38b676e6b0aaf381d6ff7c7b16cbb55..37d421bfe5656e1ec59efe9b8d6e36463f3aa32b 100644 --- a/tests/mesh/MeshAABBSelectionTest.cpp +++ b/tests/mesh/MeshAABBSelectionTest.cpp @@ -31,7 +31,7 @@ #include "mesh/MeshIO.h" #include "mesh/MeshOperations.h" -#include <boost/random.hpp> +#include <random> #include <boost/lexical_cast.hpp> #include <algorithm> @@ -61,7 +61,7 @@ int main( int argc, char * argv[] ) auto aabb = computeAABB( *mesh ); - boost::random::mt19937 rng; + std::mt19937 rng; for( uint_t i = 0; i < numBoxes; ++i ) { diff --git a/tests/mesh/MeshContainmentOctreeTest.cpp b/tests/mesh/MeshContainmentOctreeTest.cpp index 8858790eb3a7e2bacda2ba1372bb87149dc64e74..4e922e17a8e5f6a4a54f49437fccc32037052b91 100644 --- a/tests/mesh/MeshContainmentOctreeTest.cpp +++ b/tests/mesh/MeshContainmentOctreeTest.cpp @@ -35,7 +35,7 @@ #include "mesh/vtk/VTKMeshWriter.h" #include "mesh/vtk/CommonDataSources.h" -#include <boost/random.hpp> +#include <random> #include <vector> #include <string> @@ -104,7 +104,7 @@ int main( int argc, char * argv[] ) if( writeVtk ) containmentOctree.writeVTKOutput( "containment_octree" ); - boost::random::mt19937 rng; + std::mt19937 rng; for( int i = 0; i < 10000; ++i ) { diff --git a/tests/mesh/MeshDistanceCompareTest.cpp b/tests/mesh/MeshDistanceCompareTest.cpp index ee89527ec5fd70ad6804516af4a4f955f765b850..4067a28e853b3e24ca8f6b84bff7883e013e635e 100644 --- a/tests/mesh/MeshDistanceCompareTest.cpp +++ b/tests/mesh/MeshDistanceCompareTest.cpp @@ -32,7 +32,7 @@ #include "mesh/DistanceComputations.h" #include "mesh/MeshIO.h" -#include <boost/random.hpp> +#include <random> #include <vector> #include <string> @@ -54,7 +54,7 @@ void testAABBDistance( const Vector3<real_t> & translationVector = Vector3<real_ TriangleDistance<MeshType> triDist( mesh ); - boost::random::mt19937 rng; + std::mt19937 rng; for( int i = 0; i < 10000; ++i ) { diff --git a/tests/mesh/MeshDistanceOctreeTest.cpp b/tests/mesh/MeshDistanceOctreeTest.cpp index 24601416f276671a9b405e605034e2ac146bff36..3d849c3f6b71909f9f30dd60a748ba03d26e4c25 100644 --- a/tests/mesh/MeshDistanceOctreeTest.cpp +++ b/tests/mesh/MeshDistanceOctreeTest.cpp @@ -32,7 +32,7 @@ #include "mesh/distance_octree/DistanceOctree.h" #include "mesh/MeshIO.h" -#include <boost/random.hpp> +#include <random> #include <vector> #include <string> @@ -55,7 +55,7 @@ void test( const std::string & meshFile ) //distanceOctree.writeVTKOutput( "distance_octree" ); - boost::random::mt19937 rng; + std::mt19937 rng; for( int i = 0; i < 1000; ++i ) { diff --git a/tests/mesh/MeshDistancePlausibilityTest.cpp b/tests/mesh/MeshDistancePlausibilityTest.cpp index 69b76016696ab8af49ea07c3160feedee153d7d7..5ca33efc11439636d2df20583682947407f18580 100644 --- a/tests/mesh/MeshDistancePlausibilityTest.cpp +++ b/tests/mesh/MeshDistancePlausibilityTest.cpp @@ -45,7 +45,6 @@ #include "stencil/D3Q27.h" #include <boost/lexical_cast.hpp> -#include <boost/random.hpp> #include <vector> #include <string> @@ -207,8 +206,8 @@ int main( int argc, char * argv[] ) auto vtkOutput = vtk::createVTKOutput_BlockData( blocks, "plausibility test" ); - vtkOutput->addCellDataWriter( boost::make_shared< field::VTKWriter< DistanceField, float > >( distanceFieldId , "distance field" ) ); - vtkOutput->addCellDataWriter( boost::make_shared< field::VTKWriter< ErrorMarkerField > >( errorMarkerFieldId, "error marker" ) ); + vtkOutput->addCellDataWriter( make_shared< field::VTKWriter< DistanceField, float > >( distanceFieldId , "distance field" ) ); + vtkOutput->addCellDataWriter( make_shared< field::VTKWriter< ErrorMarkerField > >( errorMarkerFieldId, "error marker" ) ); writeFiles( vtkOutput, true )(); } diff --git a/tests/mesh/MeshVTKTest.cpp b/tests/mesh/MeshVTKTest.cpp index 211bffd112c110e3f96ff3f72d2e04c868ff0f8e..ac6ecd3074bed19b2f724fe53c778b84be18584f 100644 --- a/tests/mesh/MeshVTKTest.cpp +++ b/tests/mesh/MeshVTKTest.cpp @@ -30,8 +30,6 @@ #include "mesh/vtk/CommonDataSources.h" #include "mesh/vtk/CommonFilters.h" -#include <boost/random.hpp> - #include <vector> #include <string> diff --git a/tests/mesh/PeVTKMeshWriterTest.cpp b/tests/mesh/PeVTKMeshWriterTest.cpp index 4c0f683dc4aded284648b6f1a13ae00be345434f..a765f30c4290e09240027168fd90591314c48eb4 100644 --- a/tests/mesh/PeVTKMeshWriterTest.cpp +++ b/tests/mesh/PeVTKMeshWriterTest.cpp @@ -38,10 +38,11 @@ #include <core/logging/Logging.h> #include <core/timing/TimingTree.h> #include <core/waLBerlaBuildInfo.h> +#include <core/math/Utility.h> #include <postprocessing/sqlite/SQLite.h> #include <vtk/VTKOutput.h> -#include <boost/random.hpp> +#include <random> using namespace walberla; using namespace walberla::pe; @@ -86,15 +87,16 @@ std::vector<Vector3<real_t>> generatePointCloudDodecahedron() template< typename RNG > std::vector<Vector3<real_t>> generatPointCloudOnSphere( const real_t radius, const uint_t numPoints, RNG & rng ) { - boost::uniform_on_sphere<real_t> distribution(3); + std::uniform_real_distribution<real_t> distribution; std::vector<Vector3<real_t>> pointCloud( numPoints ); for( auto & p : pointCloud ) { - auto v = distribution(rng); - p[0] = v[0] * radius; - p[1] = v[1] * radius; - p[2] = v[2] * radius; + real_t theta = 2 * math::PI * distribution(rng); + real_t phi = std::acos( real_t(1.0) - real_t(2.0) * distribution(rng) ); + p[0] = std::sin(phi) * std::cos(theta) * radius; + p[1] = std::sin(phi) * std::sin(theta) * radius; + p[2] = std::cos(phi) * radius; } return pointCloud; @@ -140,7 +142,7 @@ int main( int argc, char ** argv ) cr.setRelaxationParameter( real_t(0.7) ); cr.setGlobalLinearAcceleration( Vec3(0,0,5) ); - boost::function<void(void)> syncCall = boost::bind( pe::syncNextNeighbors<BodyTuple>, boost::ref(*forest), storageID, static_cast<WcTimingTree*>(NULL), real_c(0.0), false ); + std::function<void(void)> syncCall = boost::bind( pe::syncNextNeighbors<BodyTuple>, boost::ref(*forest), storageID, static_cast<WcTimingTree*>(NULL), real_c(0.0), false ); typedef mesh::FloatPolyMesh OutputMeshType; typedef mesh::pe::DefaultTesselation<OutputMeshType> TesselationType; @@ -177,7 +179,7 @@ int main( int argc, char ** argv ) //for( auto & p: pointCloud) // p = p.getNormalized() * radius; - boost::random::mt19937 rng(42); + std::mt19937 rng(42); for (auto blkIt = forest->begin(); blkIt != forest->end(); ++blkIt) { IBlock & currentBlock = *blkIt; diff --git a/tests/mesh/QHullTest.cpp b/tests/mesh/QHullTest.cpp index 1183325e0b73041efdec3031e76f80c7f1d5b1e1..c755a46ec3fa3bb9e93f4fa3a1497e6c03c3c630 100644 --- a/tests/mesh/QHullTest.cpp +++ b/tests/mesh/QHullTest.cpp @@ -23,6 +23,7 @@ #include "core/logging/Logging.h" #include "core/mpi/Environment.h" #include "core/timing/Timer.h" +#include "core/math/Utility.h" #include "mesh/TriangleMeshes.h" #include "mesh/QHull.h" @@ -32,7 +33,7 @@ #include "vtk/VTKOutput.h" #include "vtk/PointDataSource.h" -#include <boost/random.hpp> +#include <random> #include <vector> #include <string> @@ -190,7 +191,7 @@ std::vector<Vector3<real_t>> generatePointCloudDodecahedron() std::vector<Vector3<real_t>> generatePointCloudInAABB( const math::AABB & aabb, const uint_t numPoints ) { - boost::random::mt19937 rng(42); + std::mt19937 rng(42); std::vector<Vector3<real_t>> pointCloud( numPoints ); for( auto & p : pointCloud ) @@ -202,16 +203,17 @@ std::vector<Vector3<real_t>> generatePointCloudInAABB( const math::AABB & aabb, std::vector<Vector3<real_t>> generatPointCloudOnSphere( const real_t radius, const uint_t numPoints ) { - boost::random::mt19937 rng(42); - boost::uniform_on_sphere<real_t> distribution(3); + std::mt19937 rng(42); + std::uniform_real_distribution<real_t> distribution; std::vector<Vector3<real_t>> pointCloud( numPoints ); for( auto & p : pointCloud ) { - auto v = distribution(rng); - p[0] = v[0] * radius; - p[1] = v[1] * radius; - p[2] = v[2] * radius; + real_t theta = 2 * math::PI * distribution(rng); + real_t phi = std::acos( real_t(1.0) - real_t(2.0) * distribution(rng) ); + p[0] = std::sin(phi) * std::cos(theta) * radius; + p[1] = std::sin(phi) * std::sin(theta) * radius; + p[2] = std::cos(phi) * radius; } return pointCloud; diff --git a/tests/pe/CMakeLists.txt b/tests/pe/CMakeLists.txt index 8268c9a158e44a5d9f090b8c1164e463ce4e4a66..64a077d081657246870a0bbac6583cc58bb8acb0 100644 --- a/tests/pe/CMakeLists.txt +++ b/tests/pe/CMakeLists.txt @@ -25,6 +25,9 @@ waLBerla_execute_test( NAME PE_COLLISION ) waLBerla_compile_test( NAME PE_COLLISIONTOBIASGJK FILES CollisionTobiasGJK.cpp DEPENDS core ) waLBerla_execute_test( NAME PE_COLLISIONTOBIASGJK ) +waLBerla_compile_test( NAME PE_CREATEWORLD FILES CreateWorld.cpp DEPENDS core ) +waLBerla_execute_test( NAME PE_CREATEWORLD ) + waLBerla_compile_test( NAME PE_DELETEBODY FILES DeleteBody.cpp DEPENDS core blockforest ) waLBerla_execute_test( NAME PE_DELETEBODY_NN COMMAND $<TARGET_FILE:PE_DELETEBODY> ) waLBerla_execute_test( NAME PE_DELETEBODY_SO COMMAND $<TARGET_FILE:PE_DELETEBODY> --syncShadowOwners ) @@ -118,3 +121,6 @@ waLBerla_execute_test( NAME PE_STATICTYPEIDS ) waLBerla_compile_test( NAME PE_UNION FILES Union.cpp DEPENDS core ) waLBerla_execute_test( NAME PE_UNION ) + +waLBerla_compile_test( NAME PE_VOLUMEINERTIA FILES VolumeInertia.cpp DEPENDS core ) +waLBerla_execute_test( NAME PE_VOLUMEINERTIA CONFIGURATIONS Release RelWithDbgInfo) diff --git a/tests/pe/CreateWorld.cpp b/tests/pe/CreateWorld.cpp new file mode 100644 index 0000000000000000000000000000000000000000..6a79b5bfb59fc72618a145147c6a180c746d7d01 --- /dev/null +++ b/tests/pe/CreateWorld.cpp @@ -0,0 +1,58 @@ +//====================================================================================================================== +// +// This file is part of waLBerla. waLBerla is free software: you can +// redistribute it and/or modify it under the terms of the GNU General Public +// License as published by the Free Software Foundation, either version 3 of +// the License, or (at your option) any later version. +// +// waLBerla is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License along +// with waLBerla (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file HCSITS.cpp +//! \brief checks equality of hash grids and simple ccd +//! \author Sebastian Eibl <sebastian.eibl@fau.de> +// +//====================================================================================================================== + +#include "pe/basic.h" +#include "pe/utility/CreateWorld.h" + +#include "blockforest/all.h" +#include "core/all.h" +#include "domain_decomposition/all.h" + +#include "core/debug/TestSubsystem.h" + +using namespace walberla; +using namespace walberla::pe; + +typedef boost::tuple<Sphere, Plane> BodyTuple ; + +int main( int argc, char** argv ) +{ + walberla::debug::enterTestMode(); + Environment env(argc, argv); + WALBERLA_UNUSED(env); + + // create blocks + auto forest = createBlockForest( + math::AABB(0,0,0,10,10,10), + Vector3<uint_t>(1,1,1), + Vector3<bool>(false, false, false), + 1, + 1); + + WALBERLA_CHECK_EQUAL( forest->size(), 8); + for (auto blockIt = forest->begin(); blockIt != forest->end(); ++blockIt) + { + blockforest::Block& currentBlock = *(dynamic_cast<blockforest::Block*>(&(*blockIt))); + WALBERLA_CHECK_EQUAL( currentBlock.getLevel(), 1); + } + + return EXIT_SUCCESS; +} diff --git a/tests/pe/DeleteBody.cpp b/tests/pe/DeleteBody.cpp index 9b0d149bc327ed2bdfc6c9f79e6eeacfb5c8a0ba..64f03d42a807a89b5cce96903acf13ee7fe5220d 100644 --- a/tests/pe/DeleteBody.cpp +++ b/tests/pe/DeleteBody.cpp @@ -80,7 +80,7 @@ int main( int argc, char** argv ) } WALBERLA_CHECK_UNEQUAL(firstStorage, secondStorage); - boost::function<void(void)> syncCall; + std::function<void(void)> syncCall; if (!syncShadowOwners) { syncCall = boost::bind( pe::syncNextNeighbors<BodyTuple>, boost::ref(forest->getBlockForest()), storageID, static_cast<WcTimingTree*>(NULL), real_c(0.0), false ); diff --git a/tests/pe/ShadowCopy.cpp b/tests/pe/ShadowCopy.cpp index d0d3c119fd47b8c7f3a2ccef15a08f86ab935870..cbd4958e34ede91c698393f37f42633925f15abc 100644 --- a/tests/pe/ShadowCopy.cpp +++ b/tests/pe/ShadowCopy.cpp @@ -62,7 +62,7 @@ int main( int argc, char** argv ) // logging::Logging::instance()->includeLoggingToFile("ShadowCopy"); bool syncShadowOwners = false; - boost::function<void(void)> syncCall; + std::function<void(void)> syncCall; if (!syncShadowOwners) { syncCall = boost::bind( pe::syncNextNeighbors<BodyTuple>, boost::ref(forest->getBlockForest()), storageID, static_cast<WcTimingTree*>(NULL), real_c(0.0), false ); diff --git a/tests/pe/SyncEquivalence.cpp b/tests/pe/SyncEquivalence.cpp index 9d5cb83b52bfeb5e2c9a977e8a9f191215dc9827..c311e1d6728ebd00a11b86451b0a8b208ef94d33 100644 --- a/tests/pe/SyncEquivalence.cpp +++ b/tests/pe/SyncEquivalence.cpp @@ -95,9 +95,9 @@ void createSimulation(math::AABB& simulationDomain, real_t vMax, SimInfo& info) { - boost::mt19937 generator; + std::mt19937 generator; generator.seed(1337); - //math::seedRandomGenerator( 1337 ); //static_cast<boost::mt19937::result_type>(1337 * mpi::MPIManager::instance()->worldRank()) ); + //math::seedRandomGenerator( 1337 ); //static_cast<std::mt19937::result_type>(1337 * mpi::MPIManager::instance()->worldRank()) ); info.globalBodyStorage = make_shared<BodyStorage>(); diff --git a/tests/pe/VolumeInertia.cpp b/tests/pe/VolumeInertia.cpp new file mode 100644 index 0000000000000000000000000000000000000000..becd6ddd37b8fbd8380d4bf20def053a6b40b1c4 --- /dev/null +++ b/tests/pe/VolumeInertia.cpp @@ -0,0 +1,133 @@ +//====================================================================================================================== +// +// This file is part of waLBerla. waLBerla is free software: you can +// redistribute it and/or modify it under the terms of the GNU General Public +// License as published by the Free Software Foundation, either version 3 of +// the License, or (at your option) any later version. +// +// waLBerla is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License along +// with waLBerla (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file VolumeInertia.cpp +//! \author Sebastian Eibl <sebastian.eibl@fau.de> +// +//====================================================================================================================== + +#include <core/debug/TestSubsystem.h> +#include <core/grid_generator/SCIterator.h> +#include <pe/Materials.h> +#include <pe/rigidbody/Box.h> +#include <pe/rigidbody/Capsule.h> +#include <pe/rigidbody/Ellipsoid.h> +#include <pe/rigidbody/Sphere.h> + +using namespace walberla; +using namespace walberla::pe; + +template< typename ContainmentT > +void calcNumeric( const ContainmentT & body, const AABB & aabb, const real_t spacing, real_t& outVolume, Vec3& outCOM, Mat3& outInertia ) +{ + Vector3<real_t> pointOfReference = aabb.min() + Vector3<real_t>( real_t(0.5) * spacing ); + + uint_t volume = 0; + math::KahanAccumulator<real_t> centroid[3]; + math::KahanAccumulator<real_t> intertiaTensor[6]; + uint_t numPoints = 0; + + for(grid_generator::SCIterator it( aabb, pointOfReference, spacing ); it != grid_generator::SCIterator(); ++it) + { + if(body.containsPoint( *it )) + { + //volume + ++volume; + + //center of mass + centroid[0] += (*it)[0]; + centroid[1] += (*it)[1]; + centroid[2] += (*it)[2]; + + //inertia tensor + const Vector3<real_t> p = *it; + const real_t & x = p[0]; + const real_t & y = p[1]; + const real_t & z = p[2]; + + intertiaTensor[0] += y*y + z*z; + intertiaTensor[1] += -x*y; + intertiaTensor[2] += -x*z; + intertiaTensor[3] += x*x + z*z; + intertiaTensor[4] += -y*z; + intertiaTensor[5] += x*x + y*y; + ++numPoints; + } + } + + auto dV = (spacing * spacing * spacing); + auto dm = dV * Material::getDensity( body.getMaterial() ); + outVolume = real_c(volume) * dV; + outCOM = Vec3( centroid[0].get(), centroid[1].get(), centroid[2].get() ) / real_c(numPoints); + outInertia = Mat3( intertiaTensor[0].get(), intertiaTensor[1].get(), intertiaTensor[2].get(), + intertiaTensor[1].get(), intertiaTensor[3].get(), intertiaTensor[4].get(), + intertiaTensor[2].get(), intertiaTensor[4].get(), intertiaTensor[5].get() ) * dm; +} + +int main( int argc, char ** argv ) +{ + walberla::debug::enterTestMode(); + + walberla::MPIManager::instance()->initializeMPI( &argc, &argv ); + + MaterialID material = createMaterial( "dummy", + real_t( 3900 ), + 0, + 0, + 0, + real_t( 0.23 ), + real_t( 3.6e11 ), + real_t( 8.65e6 ), + real_t( 1.1e1 ), + 0 ); + + real_t volume; + Vec3 COM; + Mat3 inertia; + + Sphere sp(0, 0, Vec3(0,0,0), Vec3(0,0,0), Quat(), real_t(2.34), material, false, true, false); + calcNumeric(sp, sp.getAABB(), real_t(0.01), volume, COM, inertia); + WALBERLA_CHECK( walberla::debug::check_functions_detail::check_float_equal_eps(sp.getVolume(), volume, real_t(10e-4)) ); + WALBERLA_CHECK( walberla::debug::check_functions_detail::check_float_equal_eps(Sphere::calcVolume( real_t(2.34) ), volume, real_t(10e-4)) ); + WALBERLA_CHECK( walberla::debug::check_functions_detail::check_float_equal_eps(sp.getInertia(), inertia, real_t(10)) ); + WALBERLA_CHECK( walberla::debug::check_functions_detail::check_float_equal_eps(sp.getMass(), volume * Material::getDensity(material), real_t(10e-4)) ); + WALBERLA_CHECK( walberla::debug::check_functions_detail::check_float_equal_eps(COM, Vec3(0), real_t(10e-4)) ); + + Box bx(0, 0, Vec3(0,0,0), Vec3(0,0,0), Quat(), Vec3(real_t(1.5), real_t(2.5), real_t(3.5)), material, false, true, false); + calcNumeric(bx, bx.getAABB(), real_t(0.01), volume, COM, inertia); + WALBERLA_CHECK( walberla::debug::check_functions_detail::check_float_equal_eps(bx.getVolume(), volume, real_t(10e-4)) ); + WALBERLA_CHECK( walberla::debug::check_functions_detail::check_float_equal_eps(Box::calcVolume( Vec3(real_t(1.5), real_t(2.5), real_t(3.5)) ), volume, real_t(10e-4)) ); + WALBERLA_CHECK( walberla::debug::check_functions_detail::check_float_equal_eps(bx.getInertia(), inertia, real_t(10)) ); + WALBERLA_CHECK( walberla::debug::check_functions_detail::check_float_equal_eps(bx.getMass(), volume * Material::getDensity(material), real_t(10e-4)) ); + WALBERLA_CHECK( walberla::debug::check_functions_detail::check_float_equal_eps(COM, Vec3(0), real_t(10e-4)) ); + + Ellipsoid el(0, 0, Vec3(0,0,0), Vec3(0,0,0), Quat(), Vec3(real_t(1.5), real_t(2.5), real_t(3.5)), material, false, true, false); + calcNumeric(el, el.getAABB(), real_t(0.01), volume, COM, inertia); + WALBERLA_CHECK( walberla::debug::check_functions_detail::check_float_equal_eps(el.getVolume(), volume, real_t(10e-4)) ); + WALBERLA_CHECK( walberla::debug::check_functions_detail::check_float_equal_eps(Ellipsoid::calcVolume( Vec3(real_t(1.5), real_t(2.5), real_t(3.5)) ), volume, real_t(10e-4)) ); + WALBERLA_CHECK( walberla::debug::check_functions_detail::check_float_equal_eps(el.getInertia(), inertia, real_t(10)) ); + WALBERLA_CHECK( walberla::debug::check_functions_detail::check_float_equal_eps(el.getMass(), volume * Material::getDensity(material), real_t(10e-4)) ); + WALBERLA_CHECK( walberla::debug::check_functions_detail::check_float_equal_eps(COM, Vec3(0), real_t(10e-4)) ); + + Capsule cp(0, 0, Vec3(0,0,0), Vec3(0,0,0), Quat(), real_t(1.5), real_t(2.5), material, false, true, false); + calcNumeric(cp, cp.getAABB(), real_t(0.01), volume, COM, inertia); + WALBERLA_CHECK( walberla::debug::check_functions_detail::check_float_equal_eps(cp.getVolume(), volume, real_t(10e-4)) ); + WALBERLA_CHECK( walberla::debug::check_functions_detail::check_float_equal_eps(Capsule::calcVolume( real_t(1.5), real_t(2.5) ), volume, real_t(10e-4)) ); + WALBERLA_CHECK( walberla::debug::check_functions_detail::check_float_equal_eps(cp.getInertia(), inertia, real_t(10)) ); + WALBERLA_CHECK( walberla::debug::check_functions_detail::check_float_equal_eps(cp.getMass(), volume * Material::getDensity(material), real_t(10e-4)) ); + WALBERLA_CHECK( walberla::debug::check_functions_detail::check_float_equal_eps(COM, Vec3(0), real_t(10e-4)) ); + + return EXIT_SUCCESS; +} diff --git a/tests/pe_coupling/discrete_particle_methods/HinderedSettlingDynamicsDPM.cpp b/tests/pe_coupling/discrete_particle_methods/HinderedSettlingDynamicsDPM.cpp index 8786074ddbe78cea3ca1a560f4f6b8ff2d03fda6..d9fd267079e1b78d322a80ff1e7afdd1aabc3755 100644 --- a/tests/pe_coupling/discrete_particle_methods/HinderedSettlingDynamicsDPM.cpp +++ b/tests/pe_coupling/discrete_particle_methods/HinderedSettlingDynamicsDPM.cpp @@ -337,7 +337,7 @@ public: QuantityEvaluator( SweepTimeloop* timeloop, StructuredBlockStorage & blocks, const BlockDataID & bodyStorageID, const BlockDataID & forceFieldID, const BlockDataID & pdfFieldID, const std::string & fileName, bool fileIO, const uint_t & numSpheres, const real_t & velExpected, - const boost::function<Vector3<real_t> ()> & evaluateMeanFluidVelocity ) : + const std::function<Vector3<real_t> ()> & evaluateMeanFluidVelocity ) : timeloop_( timeloop ), blocks_( blocks ), bodyStorageID_( bodyStorageID ), forceFieldID_( forceFieldID ), pdfFieldID_( pdfFieldID ), fileName_( fileName ), fileIO_( fileIO ), numSpheres_( numSpheres ), velExpected_( velExpected ), evaluateMeanFluidVelocity_( evaluateMeanFluidVelocity ) @@ -484,7 +484,7 @@ private: const uint_t numSpheres_; const real_t velExpected_; - boost::function<Vector3<real_t> ()> evaluateMeanFluidVelocity_; + std::function<Vector3<real_t> ()> evaluateMeanFluidVelocity_; }; @@ -703,9 +703,9 @@ int main( int argc, char **argv ) if( fileIO ) { // create base directory if it does not yet exist - boost::filesystem::path tpath( baseFolder ); - if( !boost::filesystem::exists( tpath ) ) - boost::filesystem::create_directory( tpath ); + filesystem::path tpath( baseFolder ); + if( !filesystem::exists( tpath ) ) + filesystem::create_directory( tpath ); } /////////////////////////////// @@ -1044,7 +1044,7 @@ int main( int argc, char **argv ) ///////////////////////////////// // drag correlation function - boost::function<Vector3<real_t> ( const Vector3<real_t>&, const Vector3<real_t> &, real_t, real_t, real_t, real_t)> dragCorrelationFunction; + std::function<Vector3<real_t> ( const Vector3<real_t>&, const Vector3<real_t> &, real_t, real_t, real_t, real_t)> dragCorrelationFunction; if( dragCorr == DragCorrelation::ErgunWenYu ) { dragCorrelationFunction = pe_coupling::discrete_particle_methods::dragForceErgunWenYu; @@ -1075,7 +1075,7 @@ int main( int argc, char **argv ) } // lift correlation function - boost::function<Vector3<real_t> ( const Vector3<real_t> &, const Vector3<real_t> &, const Vector3<real_t> &, real_t, real_t, real_t )> liftCorrelationFunction; + std::function<Vector3<real_t> ( const Vector3<real_t> &, const Vector3<real_t> &, const Vector3<real_t> &, real_t, real_t, real_t )> liftCorrelationFunction; if( liftCorr == LiftCorrelation::NoLift ) { liftCorrelationFunction = pe_coupling::discrete_particle_methods::noLiftForce; @@ -1090,7 +1090,7 @@ int main( int argc, char **argv ) } // added mass correlation function - boost::function<Vector3<real_t> ( const Vector3<real_t> &, const Vector3<real_t> &, real_t, real_t )> addedMassCorrelationFunction; + std::function<Vector3<real_t> ( const Vector3<real_t> &, const Vector3<real_t> &, real_t, real_t )> addedMassCorrelationFunction; if( addedMassCorr == AddedMassCorrelation::NoAM ) { addedMassCorrelationFunction = pe_coupling::discrete_particle_methods::noAddedMassForce; @@ -1105,7 +1105,7 @@ int main( int argc, char **argv ) } // set up effective viscosity calculation - boost::function<real_t ( real_t, real_t)> effectiveViscosityFunction; + std::function<real_t ( real_t, real_t)> effectiveViscosityFunction; if( effVisc == EffectiveViscosity::None ) { effectiveViscosityFunction = pe_coupling::discrete_particle_methods::calculateUnchangedEffectiveViscosity; @@ -1137,7 +1137,7 @@ int main( int argc, char **argv ) (*bodyVelocityTimeDerivativeEvaluator)(); // function used to evaluate the interaction force between fluid and particles - boost::function<void(void)> dragAndPressureForceEvaluationFunction; + std::function<void(void)> dragAndPressureForceEvaluationFunction; if( dpm == DPMethod::GNS ) { if (interpol == Interpolation::INearestNeighbor) { if (dist == Distribution::DNearestNeighbor) { @@ -1202,7 +1202,7 @@ int main( int argc, char **argv ) // function to evaluate the lift force contribution - boost::function<void(void)> liftForceEvaluationFunction; + std::function<void(void)> liftForceEvaluationFunction; if( interpol == Interpolation::INearestNeighbor ) { if( dist == Distribution::DNearestNeighbor ) @@ -1262,7 +1262,7 @@ int main( int argc, char **argv ) } // function to evaluate the added mass contribution - boost::function<void(void)> addedMassEvaluationFunction; + std::function<void(void)> addedMassEvaluationFunction; if( interpol == Interpolation::INearestNeighbor ) { if( dist == Distribution::DNearestNeighbor ) @@ -1322,7 +1322,7 @@ int main( int argc, char **argv ) } // function to evaluate lubrication forces - boost::function<void(void)> lubricationEvaluationFunction; + std::function<void(void)> lubricationEvaluationFunction; if( lubricationCutOffDistance > real_t(0) ) { if( useLubricationCorrection ) @@ -1343,7 +1343,7 @@ int main( int argc, char **argv ) // function to evaluate the mean fluid velocity - boost::function<Vector3<real_t> ()> evaluateMeanFluidVelocity = boost::bind(getGNSMeanFluidVelocity, blocks, pdfFieldID, svfFieldID, domainVolume); + std::function<Vector3<real_t> ()> evaluateMeanFluidVelocity = boost::bind(getGNSMeanFluidVelocity, blocks, pdfFieldID, svfFieldID, domainVolume); ////////////////////////////// @@ -1643,7 +1643,7 @@ int main( int argc, char **argv ) << AfterFunction( pe_coupling::ForceOnBodiesAdder( blocks, bodyStorageID, Vector3<real_t>(0,0,- gravity * densityRatio * diameter * diameter * diameter * math::PI / real_t(6) ) ), "Gravitational Force Add" ) << AfterFunction( pe_coupling::ForceOnBodiesAdder( blocks, bodyStorageID, Vector3<real_t>(0,0,gravity * real_t(1) * diameter * diameter * diameter * math::PI / real_t(6) ) ), "Buoyancy Force (due to gravity) Add" ) << AfterFunction( pe_coupling::ForceOnBodiesAdder( blocks, bodyStorageID, Vector3<real_t>(0,0,extForce[2] * real_t(1) * diameter * diameter * diameter * math::PI / real_t(6) ) ), "Buoyancy Force (due to external fluid force) Add" ) - << AfterFunction( pe_coupling::discrete_particle_methods::SubgridTimeStep( blocks, bodyStorageID, *cr, syncCall, lubricationEvaluationFunction, dtInteractionSubCycle, peSubSteps ), "Pe Time Step" ); + << AfterFunction( pe_coupling::TimeStep( blocks, bodyStorageID, *cr, syncCall, dtInteractionSubCycle, peSubSteps, lubricationEvaluationFunction ), "Pe Time Step" ); timeloop.add() << Sweep( DummySweep(), "Dummy Sweep ") << AfterFunction( SharedFunctor<CollisionPropertiesEvaluator>( collisionPropertiesEvaluator ), "Collision properties evaluator"); diff --git a/tests/pe_coupling/discrete_particle_methods/SphereWallCollisionBehaviorDPM.cpp b/tests/pe_coupling/discrete_particle_methods/SphereWallCollisionBehaviorDPM.cpp index 8b4616f72d3d8b3cebae47ebd4894ee6ab26dc08..5ec32af40e6dc4dae10443bdb2f31f1bd01c791f 100644 --- a/tests/pe_coupling/discrete_particle_methods/SphereWallCollisionBehaviorDPM.cpp +++ b/tests/pe_coupling/discrete_particle_methods/SphereWallCollisionBehaviorDPM.cpp @@ -595,9 +595,9 @@ int main( int argc, char **argv ) if( fileIO ) { // create base directory if it does not yet exist - boost::filesystem::path tpath( baseFolder ); - if( !boost::filesystem::exists( tpath ) ) - boost::filesystem::create_directory( tpath ); + filesystem::path tpath( baseFolder ); + if( !filesystem::exists( tpath ) ) + filesystem::create_directory( tpath ); } /////////////////////////////// @@ -840,7 +840,7 @@ int main( int argc, char **argv ) ///////////////////////////////// // drag correlation function - boost::function<Vector3<real_t> ( const Vector3<real_t>&, const Vector3<real_t> &, real_t, real_t, real_t, real_t)> dragCorrelationFunction; + std::function<Vector3<real_t> ( const Vector3<real_t>&, const Vector3<real_t> &, real_t, real_t, real_t, real_t)> dragCorrelationFunction; if( dragCorr == DragCorrelation::ErgunWenYu ) { dragCorrelationFunction = pe_coupling::discrete_particle_methods::dragForceErgunWenYu; @@ -871,7 +871,7 @@ int main( int argc, char **argv ) } // lift correlation function - boost::function<Vector3<real_t> ( const Vector3<real_t> &, const Vector3<real_t> &, const Vector3<real_t> &, real_t, real_t, real_t )> liftCorrelationFunction; + std::function<Vector3<real_t> ( const Vector3<real_t> &, const Vector3<real_t> &, const Vector3<real_t> &, real_t, real_t, real_t )> liftCorrelationFunction; if( liftCorr == LiftCorrelation::NoLift ) { liftCorrelationFunction = pe_coupling::discrete_particle_methods::noLiftForce; @@ -886,7 +886,7 @@ int main( int argc, char **argv ) } // added mass correlation function - boost::function<Vector3<real_t> ( const Vector3<real_t> &, const Vector3<real_t> &, real_t, real_t )> addedMassCorrelationFunction; + std::function<Vector3<real_t> ( const Vector3<real_t> &, const Vector3<real_t> &, real_t, real_t )> addedMassCorrelationFunction; if( addedMassCorr == AddedMassCorrelation::NoAM ) { addedMassCorrelationFunction = pe_coupling::discrete_particle_methods::noAddedMassForce; @@ -901,7 +901,7 @@ int main( int argc, char **argv ) } // set up effective viscosity calculation - boost::function<real_t ( real_t, real_t)> effectiveViscosityFunction; + std::function<real_t ( real_t, real_t)> effectiveViscosityFunction; if( effVisc == EffectiveViscosity::None ) { effectiveViscosityFunction = pe_coupling::discrete_particle_methods::calculateUnchangedEffectiveViscosity; @@ -933,7 +933,7 @@ int main( int argc, char **argv ) (*bodyVelocityTimeDerivativeEvaluator)(); // function used to evaluate the interaction force between fluid and particles - boost::function<void(void)> dragAndPressureForceEvaluationFunction; + std::function<void(void)> dragAndPressureForceEvaluationFunction; if( dpm == DPMethod::GNS ) { if (interpol == Interpolation::INearestNeighbor) { if (dist == Distribution::DNearestNeighbor) { @@ -998,7 +998,7 @@ int main( int argc, char **argv ) // function to evaluate the lift force contribution - boost::function<void(void)> liftForceEvaluationFunction; + std::function<void(void)> liftForceEvaluationFunction; if( interpol == Interpolation::INearestNeighbor ) { if( dist == Distribution::DNearestNeighbor ) @@ -1059,7 +1059,7 @@ int main( int argc, char **argv ) // function to evaluate the added mass contribution - boost::function<void(void)> addedMassEvaluationFunction; + std::function<void(void)> addedMassEvaluationFunction; if( interpol == Interpolation::INearestNeighbor ) { if( dist == Distribution::DNearestNeighbor ) @@ -1119,7 +1119,7 @@ int main( int argc, char **argv ) } // function to evaluate lubrication forces - boost::function<void(void)> lubricationEvaluationFunction; + std::function<void(void)> lubricationEvaluationFunction; if( lubricationCutOffDistance > real_t(0) ) { if( useLubricationCorrection ) @@ -1234,7 +1234,7 @@ int main( int argc, char **argv ) << AfterFunction( dragAndPressureForceEvaluationFunction, "Fluid-Particle Interaction Force Evaluation" ) << AfterFunction( dragForceComm, "Drag Force Field Communication" ) << AfterFunction( pe_coupling::ForceOnBodiesAdder( blocks, bodyStorageID, -gravitationalForce ), "Gravitational and buoyancy force" ) - << AfterFunction( pe_coupling::discrete_particle_methods::SubgridTimeStep( blocks, bodyStorageID, *cr, syncCall, lubricationEvaluationFunction, dtInteractionSubCycle, peSubSteps ), "Pe Time Step" ) + << AfterFunction( pe_coupling::TimeStep( blocks, bodyStorageID, *cr, syncCall, dtInteractionSubCycle, peSubSteps, lubricationEvaluationFunction ), "Pe Time Step" ) << AfterFunction( SharedFunctor<CollisionPropertiesEvaluator>( collisionPropertiesEvaluator ), "Collision properties evaluator"); if( dist == Distribution::DNearestNeighbor ) diff --git a/tests/pe_coupling/momentum_exchange_method/BodyAtBlockBoarderCheck.cpp b/tests/pe_coupling/momentum_exchange_method/BodyAtBlockBoarderCheck.cpp index e47a1d4cbe0d44769c633b29bb900a9f2d0a4c6c..4133741c77ebb5f7bf427b77ad096f0ab0c2ea33 100644 --- a/tests/pe_coupling/momentum_exchange_method/BodyAtBlockBoarderCheck.cpp +++ b/tests/pe_coupling/momentum_exchange_method/BodyAtBlockBoarderCheck.cpp @@ -281,7 +281,7 @@ int main( int argc, char **argv ) // connect to pe const real_t overlap = real_c( 1.5 ) * dx; - boost::function<void(void)> syncCall = boost::bind( pe::syncShadowOwners<BodyTypeTuple>, boost::ref(blocks->getBlockForest()), bodyStorageID, static_cast<WcTimingTree*>(NULL), overlap, false ); + std::function<void(void)> syncCall = boost::bind( pe::syncShadowOwners<BodyTypeTuple>, boost::ref(blocks->getBlockForest()), bodyStorageID, static_cast<WcTimingTree*>(NULL), overlap, false ); auto sphereMaterialID = pe::createMaterial( "sphereMat", real_c(1) , real_c(0.3), real_c(0.2), real_c(0.2), real_c(0.24), real_c(200), real_c(200), real_c(0), real_c(0) ); // create two spheres: one which overlaps with a block boundary and one inside the block diff --git a/tests/pe_coupling/momentum_exchange_method/DragForceSphereMEM.cpp b/tests/pe_coupling/momentum_exchange_method/DragForceSphereMEM.cpp index 1e4bf71b5d9d87f25d6822e22372d4c690285918..c1d3d69a0964a5d187d79d9304497c00d4bf4ce6 100644 --- a/tests/pe_coupling/momentum_exchange_method/DragForceSphereMEM.cpp +++ b/tests/pe_coupling/momentum_exchange_method/DragForceSphereMEM.cpp @@ -516,7 +516,7 @@ int main( int argc, char **argv ) SweepTimeloop timeloop( blocks->getBlockStorage(), timesteps ); // setup of the LBM communication for synchronizing the pdf field between neighboring blocks - boost::function< void () > commFunction; + std::function< void () > commFunction; blockforest::communication::UniformBufferedScheme< stencil::D3Q27 > scheme( blocks ); scheme.addPackInfo( make_shared< field::communication::PackInfo< PdfField_T > >( pdfFieldID ) ); diff --git a/tests/pe_coupling/momentum_exchange_method/GlobalBodyAsBoundaryMEMStaticRefinement.cpp b/tests/pe_coupling/momentum_exchange_method/GlobalBodyAsBoundaryMEMStaticRefinement.cpp index e833f9a7134c8d7cdcaee07ac7711f928b4bc502..27626a2e5d93b95e14850edf93265aebfd06bca5 100644 --- a/tests/pe_coupling/momentum_exchange_method/GlobalBodyAsBoundaryMEMStaticRefinement.cpp +++ b/tests/pe_coupling/momentum_exchange_method/GlobalBodyAsBoundaryMEMStaticRefinement.cpp @@ -391,7 +391,7 @@ int main( int argc, char **argv ) /////////////// // setup of the LBM communication for synchronizing the pdf field between neighboring blocks - boost::function< void () > commFunction; + std::function< void () > commFunction; blockforest::communication::UniformBufferedScheme< Stencil_T > scheme( blocks ); scheme.addPackInfo( make_shared< lbm::PdfFieldPackInfo< LatticeModel_T > >( pdfFieldID ) ); commFunction = scheme; diff --git a/tests/pe_coupling/momentum_exchange_method/LubricationCorrectionMEM.cpp b/tests/pe_coupling/momentum_exchange_method/LubricationCorrectionMEM.cpp index 2569114b661f0143c030adc415601dbb42638450..d0d021395ac9fdebda1baca45cb0bc78b13449ae 100644 --- a/tests/pe_coupling/momentum_exchange_method/LubricationCorrectionMEM.cpp +++ b/tests/pe_coupling/momentum_exchange_method/LubricationCorrectionMEM.cpp @@ -789,7 +789,7 @@ int main( int argc, char **argv ) // set up synchronization procedure const real_t overlap = real_c( 1.5 ) * dx; - boost::function<void(void)> syncCall = boost::bind( pe::syncShadowOwners<BodyTypeTuple>, boost::ref(blocks->getBlockForest()), bodyStorageID, static_cast<WcTimingTree*>(NULL), overlap, false ); + std::function<void(void)> syncCall = boost::bind( pe::syncShadowOwners<BodyTypeTuple>, boost::ref(blocks->getBlockForest()), bodyStorageID, static_cast<WcTimingTree*>(NULL), overlap, false ); // create the material const auto myMat = pe::createMaterial( "myMat", real_c(1.4), real_t(0), real_t(1), real_t(1), real_t(0), real_t(1), real_t(1), real_t(0), real_t(0) ); @@ -940,7 +940,7 @@ int main( int argc, char **argv ) << Sweep( pe_coupling::PDFReconstruction< LatticeModel_T, BoundaryHandling_T, Reconstructor_T >( blocks, boundaryHandlingID, bodyStorageID, globalBodyStorage, bodyFieldID, reconstructor, FormerMO_Flag, Fluid_Flag ), "PDF Restore" ); // setup of the LBM communication for synchronizing the pdf field between neighboring blocks - boost::function< void () > commFunction; + std::function< void () > commFunction; if( fullPDFSync ) { blockforest::communication::UniformBufferedScheme< stencil::D3Q27 > scheme( blocks ); diff --git a/tests/pe_coupling/momentum_exchange_method/PeriodicParticleChannelMEM.cpp b/tests/pe_coupling/momentum_exchange_method/PeriodicParticleChannelMEM.cpp index 15d44380b97143cfaeb25476b5b4a9652578daa3..ef64aa7a87b345e84e5bd1390f18b008667064a7 100644 --- a/tests/pe_coupling/momentum_exchange_method/PeriodicParticleChannelMEM.cpp +++ b/tests/pe_coupling/momentum_exchange_method/PeriodicParticleChannelMEM.cpp @@ -413,7 +413,7 @@ int main( int argc, char **argv ) // set up synchronization procedure const real_t overlap = real_c( 1.5 ) * dx; - boost::function<void(void)> syncCall = boost::bind( pe::syncShadowOwners<BodyTypeTuple>, boost::ref(blocks->getBlockForest()), bodyStorageID, static_cast<WcTimingTree*>(NULL), overlap, false ); + std::function<void(void)> syncCall = boost::bind( pe::syncShadowOwners<BodyTypeTuple>, boost::ref(blocks->getBlockForest()), bodyStorageID, static_cast<WcTimingTree*>(NULL), overlap, false ); // create pe bodies const auto material = pe::createMaterial( "granular", real_c(1.2), real_c(0.25), real_c(0.4), real_c(0.4), real_c(0.35), real_c(1.39e11), real_c(5.18e7), real_c(1.07e2), real_c(1.07e2) ); @@ -524,7 +524,7 @@ int main( int argc, char **argv ) reconstructor, FormerMO_Flag, Fluid_Flag ), "PDF Restore" ); // setup of the LBM communication for synchronizing the pdf field between neighboring blocks - boost::function< void () > commFunction; + std::function< void () > commFunction; if( fullPDFSync ) { blockforest::communication::UniformBufferedScheme< stencil::D3Q27 > scheme( blocks ); diff --git a/tests/pe_coupling/momentum_exchange_method/SegreSilberbergMEM.cpp b/tests/pe_coupling/momentum_exchange_method/SegreSilberbergMEM.cpp index 6cfeb3dea5941f075fd70d3305529ebb096e0956..6ccc9f5c7d5156ba058991860ccb271ecbcbfe91 100644 --- a/tests/pe_coupling/momentum_exchange_method/SegreSilberbergMEM.cpp +++ b/tests/pe_coupling/momentum_exchange_method/SegreSilberbergMEM.cpp @@ -546,7 +546,7 @@ int main( int argc, char **argv ) // set up synchronization procedure const real_t overlap = real_t( 1.5 ) * dx; - boost::function<void(void)> syncCall; + std::function<void(void)> syncCall; if (!syncShadowOwners) { syncCall = boost::bind( pe::syncNextNeighbors<BodyTypeTuple>, boost::ref(blocks->getBlockForest()), bodyStorageID, static_cast<WcTimingTree*>(NULL), overlap, false ); @@ -623,7 +623,7 @@ int main( int argc, char **argv ) /////////////// // setup of the LBM communication for synchronizing the pdf field between neighboring blocks - boost::function< void () > commFunction; + std::function< void () > commFunction; blockforest::communication::UniformBufferedScheme< Stencil_T > scheme( blocks ); scheme.addPackInfo( make_shared< lbm::PdfFieldPackInfo< LatticeModel_T > >( pdfFieldID ) ); commFunction = scheme; @@ -670,9 +670,9 @@ int main( int argc, char **argv ) } shared_ptr<pe_coupling::BodiesForceTorqueContainer> bodiesFTContainer1 = make_shared<pe_coupling::BodiesForceTorqueContainer>(blocks, bodyStorageID); - boost::function<void(void)> storeForceTorqueInCont1 = boost::bind(&pe_coupling::BodiesForceTorqueContainer::store, bodiesFTContainer1); + std::function<void(void)> storeForceTorqueInCont1 = boost::bind(&pe_coupling::BodiesForceTorqueContainer::store, bodiesFTContainer1); shared_ptr<pe_coupling::BodiesForceTorqueContainer> bodiesFTContainer2 = make_shared<pe_coupling::BodiesForceTorqueContainer>(blocks, bodyStorageID); - boost::function<void(void)> setForceTorqueOnBodiesFromCont2 = boost::bind(&pe_coupling::BodiesForceTorqueContainer::setOnBodies, bodiesFTContainer2); + std::function<void(void)> setForceTorqueOnBodiesFromCont2 = boost::bind(&pe_coupling::BodiesForceTorqueContainer::setOnBodies, bodiesFTContainer2); bodiesFTContainer2->store(); diff --git a/tests/pe_coupling/momentum_exchange_method/SettlingSphereMEM.cpp b/tests/pe_coupling/momentum_exchange_method/SettlingSphereMEM.cpp index 0dfd102a5a61d08575b626f706b98f08b1451396..6674cde01316e65119f1738ef249945b0614fca2 100644 --- a/tests/pe_coupling/momentum_exchange_method/SettlingSphereMEM.cpp +++ b/tests/pe_coupling/momentum_exchange_method/SettlingSphereMEM.cpp @@ -312,9 +312,9 @@ int main( int argc, char **argv ) if( fileIO ) { // create base directory if it does not yet exist - boost::filesystem::path tpath( baseFolder ); - if( !boost::filesystem::exists( tpath ) ) - boost::filesystem::create_directory( tpath ); + filesystem::path tpath( baseFolder ); + if( !filesystem::exists( tpath ) ) + filesystem::create_directory( tpath ); } ////////////////////////////////////// @@ -457,7 +457,7 @@ int main( int argc, char **argv ) // set up synchronization procedure const real_t overlap = real_t( 1.5 ) * dx; - boost::function<void(void)> syncCall = boost::bind( pe::syncShadowOwners<BodyTypeTuple>, boost::ref(blocks->getBlockForest()), bodyStorageID, static_cast<WcTimingTree*>(NULL), overlap, false ); + std::function<void(void)> syncCall = boost::bind( pe::syncShadowOwners<BodyTypeTuple>, boost::ref(blocks->getBlockForest()), bodyStorageID, static_cast<WcTimingTree*>(NULL), overlap, false ); // create pe bodies @@ -509,7 +509,7 @@ int main( int argc, char **argv ) /////////////// // setup of the LBM communication for synchronizing the pdf field between neighboring blocks - boost::function< void () > commFunction; + std::function< void () > commFunction; blockforest::communication::UniformBufferedScheme< Stencil_T > scheme( blocks ); scheme.addPackInfo( make_shared< lbm::PdfFieldPackInfo< LatticeModel_T > >( pdfFieldID ) ); commFunction = scheme; @@ -530,11 +530,11 @@ int main( int argc, char **argv ) ( blocks, boundaryHandlingID, bodyStorageID, globalBodyStorage, bodyFieldID, reconstructor, FormerMO_Flag, Fluid_Flag ), "PDF Restore" ); shared_ptr<pe_coupling::BodiesForceTorqueContainer> bodiesFTContainer1 = make_shared<pe_coupling::BodiesForceTorqueContainer>(blocks, bodyStorageID); - boost::function<void(void)> storeForceTorqueInCont1 = boost::bind(&pe_coupling::BodiesForceTorqueContainer::store, bodiesFTContainer1); + std::function<void(void)> storeForceTorqueInCont1 = boost::bind(&pe_coupling::BodiesForceTorqueContainer::store, bodiesFTContainer1); shared_ptr<pe_coupling::BodiesForceTorqueContainer> bodiesFTContainer2 = make_shared<pe_coupling::BodiesForceTorqueContainer>(blocks, bodyStorageID); - boost::function<void(void)> setForceTorqueOnBodiesFromCont2 = boost::bind(&pe_coupling::BodiesForceTorqueContainer::setOnBodies, bodiesFTContainer2); + std::function<void(void)> setForceTorqueOnBodiesFromCont2 = boost::bind(&pe_coupling::BodiesForceTorqueContainer::setOnBodies, bodiesFTContainer2); shared_ptr<pe_coupling::ForceTorqueOnBodiesScaler> forceScaler = make_shared<pe_coupling::ForceTorqueOnBodiesScaler>(blocks, bodyStorageID, real_t(1)); - boost::function<void(void)> setForceScalingFactorToHalf = boost::bind(&pe_coupling::ForceTorqueOnBodiesScaler::resetScalingFactor,forceScaler,real_t(0.5)); + std::function<void(void)> setForceScalingFactorToHalf = boost::bind(&pe_coupling::ForceTorqueOnBodiesScaler::resetScalingFactor,forceScaler,real_t(0.5)); if( averageForceTorqueOverTwoTimSteps ) { bodiesFTContainer2->store(); diff --git a/tests/pe_coupling/momentum_exchange_method/SettlingSphereMEMDynamicRefinement.cpp b/tests/pe_coupling/momentum_exchange_method/SettlingSphereMEMDynamicRefinement.cpp index 75b9ff72e24c4792a8bce5a4bbf3128d564b908d..44b17eb70ee97b509d096e0b09133d97bc40efc8 100644 --- a/tests/pe_coupling/momentum_exchange_method/SettlingSphereMEMDynamicRefinement.cpp +++ b/tests/pe_coupling/momentum_exchange_method/SettlingSphereMEMDynamicRefinement.cpp @@ -516,9 +516,9 @@ int main( int argc, char **argv ) if( fileIO ) { // create base directory if it does not yet exist - boost::filesystem::path tpath( baseFolder ); - if( !boost::filesystem::exists( tpath ) ) - boost::filesystem::create_directory( tpath ); + filesystem::path tpath( baseFolder ); + if( !filesystem::exists( tpath ) ) + filesystem::create_directory( tpath ); } ////////////////////////////////////// @@ -677,7 +677,7 @@ int main( int argc, char **argv ) // set up synchronization procedure const real_t overlap = real_t( 1.5 ) * dx; - boost::function<void(void)> syncCall = boost::bind( pe::syncShadowOwners<BodyTypeTuple>, boost::ref(blocks->getBlockForest()), bodyStorageID, static_cast<WcTimingTree*>(NULL), overlap, false ); + std::function<void(void)> syncCall = boost::bind( pe::syncShadowOwners<BodyTypeTuple>, boost::ref(blocks->getBlockForest()), bodyStorageID, static_cast<WcTimingTree*>(NULL), overlap, false ); // create pe bodies @@ -728,12 +728,12 @@ int main( int argc, char **argv ) // force averaging functionality shared_ptr<pe_coupling::BodiesForceTorqueContainer> bodiesFTContainer1 = make_shared<pe_coupling::BodiesForceTorqueContainer>(blocks, bodyStorageID); - boost::function<void(void)> storeForceTorqueInCont1 = boost::bind(&pe_coupling::BodiesForceTorqueContainer::store, bodiesFTContainer1); + std::function<void(void)> storeForceTorqueInCont1 = boost::bind(&pe_coupling::BodiesForceTorqueContainer::store, bodiesFTContainer1); shared_ptr<pe_coupling::BodiesForceTorqueContainer> bodiesFTContainer2 = make_shared<pe_coupling::BodiesForceTorqueContainer>(blocks, bodyStorageID); - boost::function<void(void)> setForceTorqueOnBodiesFromCont2 = boost::bind(&pe_coupling::BodiesForceTorqueContainer::setOnBodies, bodiesFTContainer2); + std::function<void(void)> setForceTorqueOnBodiesFromCont2 = boost::bind(&pe_coupling::BodiesForceTorqueContainer::setOnBodies, bodiesFTContainer2); shared_ptr<pe_coupling::ForceTorqueOnBodiesScaler> forceScaler = make_shared<pe_coupling::ForceTorqueOnBodiesScaler>(blocks, bodyStorageID, real_t(0.5)); - boost::function<void(void)> setForceScalingFactorToOne = boost::bind(&pe_coupling::ForceTorqueOnBodiesScaler::resetScalingFactor,forceScaler,real_t(1)); - boost::function<void(void)> setForceScalingFactorToHalf = boost::bind(&pe_coupling::ForceTorqueOnBodiesScaler::resetScalingFactor,forceScaler,real_t(0.5)); + std::function<void(void)> setForceScalingFactorToOne = boost::bind(&pe_coupling::ForceTorqueOnBodiesScaler::resetScalingFactor,forceScaler,real_t(1)); + std::function<void(void)> setForceScalingFactorToHalf = boost::bind(&pe_coupling::ForceTorqueOnBodiesScaler::resetScalingFactor,forceScaler,real_t(0.5)); if( averageForceTorqueOverTwoTimSteps ) { bodiesFTContainer2->store(); @@ -746,7 +746,7 @@ int main( int argc, char **argv ) /////////////// // setup of the LBM communication for synchronizing the pdf field between neighboring blocks - boost::function< void () > commFunction; + std::function< void () > commFunction; blockforest::communication::UniformBufferedScheme< Stencil_T > scheme( blocks ); scheme.addPackInfo( make_shared< lbm::PdfFieldPackInfo< LatticeModel_T > >( pdfFieldID ) ); commFunction = scheme; diff --git a/tests/pe_coupling/momentum_exchange_method/SettlingSphereMEMStaticRefinement.cpp b/tests/pe_coupling/momentum_exchange_method/SettlingSphereMEMStaticRefinement.cpp index d93c8731e1272efdb81d71f6509a9de44121080a..391ab7b8947bd32cc518760d4fc726c96ceae4c6 100644 --- a/tests/pe_coupling/momentum_exchange_method/SettlingSphereMEMStaticRefinement.cpp +++ b/tests/pe_coupling/momentum_exchange_method/SettlingSphereMEMStaticRefinement.cpp @@ -405,9 +405,9 @@ int main( int argc, char **argv ) if( fileIO ) { // create base directory if it does not yet exist - boost::filesystem::path tpath( baseFolder ); - if( !boost::filesystem::exists( tpath ) ) - boost::filesystem::create_directory( tpath ); + filesystem::path tpath( baseFolder ); + if( !filesystem::exists( tpath ) ) + filesystem::create_directory( tpath ); } ////////////////////////////////////// @@ -544,7 +544,7 @@ int main( int argc, char **argv ) // set up synchronization procedure const real_t overlap = real_t( 1.5 ) * dx; - boost::function<void(void)> syncCall = boost::bind( pe::syncShadowOwners<BodyTypeTuple>, boost::ref(blocks->getBlockForest()), bodyStorageID, static_cast<WcTimingTree*>(NULL), overlap, false ); + std::function<void(void)> syncCall = boost::bind( pe::syncShadowOwners<BodyTypeTuple>, boost::ref(blocks->getBlockForest()), bodyStorageID, static_cast<WcTimingTree*>(NULL), overlap, false ); // create pe bodies @@ -595,11 +595,11 @@ int main( int argc, char **argv ) // force averaging functionality shared_ptr<pe_coupling::BodiesForceTorqueContainer> bodiesFTContainer1 = make_shared<pe_coupling::BodiesForceTorqueContainer>(blocks, bodyStorageID); - boost::function<void(void)> storeForceTorqueInCont1 = boost::bind(&pe_coupling::BodiesForceTorqueContainer::store, bodiesFTContainer1); + std::function<void(void)> storeForceTorqueInCont1 = boost::bind(&pe_coupling::BodiesForceTorqueContainer::store, bodiesFTContainer1); shared_ptr<pe_coupling::BodiesForceTorqueContainer> bodiesFTContainer2 = make_shared<pe_coupling::BodiesForceTorqueContainer>(blocks, bodyStorageID); - boost::function<void(void)> setForceTorqueOnBodiesFromCont2 = boost::bind(&pe_coupling::BodiesForceTorqueContainer::setOnBodies, bodiesFTContainer2); + std::function<void(void)> setForceTorqueOnBodiesFromCont2 = boost::bind(&pe_coupling::BodiesForceTorqueContainer::setOnBodies, bodiesFTContainer2); shared_ptr<pe_coupling::ForceTorqueOnBodiesScaler> forceScaler = make_shared<pe_coupling::ForceTorqueOnBodiesScaler>(blocks, bodyStorageID, real_t(1)); - boost::function<void(void)> setForceScalingFactorToHalf = boost::bind(&pe_coupling::ForceTorqueOnBodiesScaler::resetScalingFactor,forceScaler,real_t(0.5)); + std::function<void(void)> setForceScalingFactorToHalf = boost::bind(&pe_coupling::ForceTorqueOnBodiesScaler::resetScalingFactor,forceScaler,real_t(0.5)); if( averageForceTorqueOverTwoTimSteps ) { bodiesFTContainer2->store(); @@ -610,7 +610,7 @@ int main( int argc, char **argv ) /////////////// // setup of the LBM communication for synchronizing the pdf field between neighboring blocks - boost::function< void () > commFunction; + std::function< void () > commFunction; blockforest::communication::UniformBufferedScheme< Stencil_T > scheme( blocks ); scheme.addPackInfo( make_shared< lbm::PdfFieldPackInfo< LatticeModel_T > >( pdfFieldID ) ); commFunction = scheme; diff --git a/tests/pe_coupling/momentum_exchange_method/SquirmerTest.cpp b/tests/pe_coupling/momentum_exchange_method/SquirmerTest.cpp index 00ce16ed011c41a33eb4a42b8b8a2cb706dc94a7..82fd1093713a0421ace63341e6a65225b41f2534 100644 --- a/tests/pe_coupling/momentum_exchange_method/SquirmerTest.cpp +++ b/tests/pe_coupling/momentum_exchange_method/SquirmerTest.cpp @@ -289,7 +289,7 @@ int main(int argc, char **argv) { return EXIT_FAILURE; } - boost::function<void(void)> syncCall = boost::bind(pe::syncShadowOwners<BodyTypeTuple>, + std::function<void(void)> syncCall = boost::bind(pe::syncShadowOwners<BodyTypeTuple>, boost::ref(blocks->getBlockForest()), bodyStorageID, static_cast<WcTimingTree *>(NULL), overlap, false); @@ -358,7 +358,7 @@ int main(int argc, char **argv) { "PDF Restore"); // setup of the LBM communication for synchronizing the pdf field between neighboring blocks - boost::function<void()> commFunction; + std::function<void()> commFunction; blockforest::communication::UniformBufferedScheme<stencil::D3Q27> scheme(blocks); scheme.addPackInfo(make_shared<field::communication::PackInfo<PdfField_T> >(pdfFieldID)); diff --git a/tests/pe_coupling/momentum_exchange_method/TaylorCouetteFlowMEM.cpp b/tests/pe_coupling/momentum_exchange_method/TaylorCouetteFlowMEM.cpp index 1b8d4677ec81ff4777f62a811fe0a2ee44a13c20..e6d43a5d0039a43d1aee67b9723f95d971e0b4de 100644 --- a/tests/pe_coupling/momentum_exchange_method/TaylorCouetteFlowMEM.cpp +++ b/tests/pe_coupling/momentum_exchange_method/TaylorCouetteFlowMEM.cpp @@ -303,7 +303,7 @@ int main( int argc, char **argv ) // set up synchronization procedure const real_t overlap = real_t( 1.5 ) * dx; - boost::function<void(void)> syncCall = boost::bind( pe::syncShadowOwners<BodyTypeTuple>, boost::ref(blocks->getBlockForest()), bodyStorageID, static_cast<WcTimingTree*>(NULL), overlap, false ); + std::function<void(void)> syncCall = boost::bind( pe::syncShadowOwners<BodyTypeTuple>, boost::ref(blocks->getBlockForest()), bodyStorageID, static_cast<WcTimingTree*>(NULL), overlap, false ); // create pe bodies const auto material = pe::createMaterial( "granular", real_t(1.2), real_t(0.25), real_t(0.4), real_t(0.4), real_t(0.35), real_t(1.39e11), real_t(5.18e7), real_t(1.07e2), real_t(1.07e2) ); @@ -348,7 +348,7 @@ int main( int argc, char **argv ) SweepTimeloop timeloop( blocks->getBlockStorage(), timesteps ); // setup of the LBM communication for synchronizing the pdf field between neighboring blocks - boost::function< void () > commFunction; + std::function< void () > commFunction; blockforest::communication::UniformBufferedScheme< Stencil_T > scheme( blocks ); scheme.addPackInfo( make_shared< lbm::PdfFieldPackInfo< LatticeModel_T > >( pdfFieldID ) ); commFunction = scheme; diff --git a/tests/pe_coupling/momentum_exchange_method/TorqueSphereMEM.cpp b/tests/pe_coupling/momentum_exchange_method/TorqueSphereMEM.cpp index 85cc5083ed638f8dd62b4802507f7333c8d56dbc..2ff3f3c98e779a184d5c5e51e1407df41814814f 100644 --- a/tests/pe_coupling/momentum_exchange_method/TorqueSphereMEM.cpp +++ b/tests/pe_coupling/momentum_exchange_method/TorqueSphereMEM.cpp @@ -466,7 +466,7 @@ int main( int argc, char **argv ) SweepTimeloop timeloop( blocks->getBlockStorage(), timesteps ); // setup of the LBM communication for synchronizing the pdf field between neighboring blocks - boost::function< void () > commFunction; + std::function< void () > commFunction; blockforest::communication::UniformBufferedScheme< stencil::D3Q27 > scheme( blocks ); scheme.addPackInfo( make_shared< field::communication::PackInfo< PdfField_T > >( pdfFieldID ) ); diff --git a/tests/pe_coupling/partially_saturated_cells_method/DragForceSpherePSM.cpp b/tests/pe_coupling/partially_saturated_cells_method/DragForceSpherePSM.cpp index 79e3c2f4901866bc7a1dd3e9304fc0629981da8a..1547b5baa773303c0002aa8779127d5cecc4e711 100644 --- a/tests/pe_coupling/partially_saturated_cells_method/DragForceSpherePSM.cpp +++ b/tests/pe_coupling/partially_saturated_cells_method/DragForceSpherePSM.cpp @@ -455,7 +455,7 @@ int main( int argc, char **argv ) SweepTimeloop timeloop( blocks->getBlockStorage(), timesteps ); // setup of the LBM communication for synchronizing the pdf field between neighboring blocks - boost::function< void () > commFunction; + std::function< void () > commFunction; blockforest::communication::UniformBufferedScheme< Stencil_T > scheme( blocks ); scheme.addPackInfo( make_shared< field::communication::PackInfo< PdfField_T > >( pdfFieldID ) ); diff --git a/tests/pe_coupling/partially_saturated_cells_method/SegreSilberbergPSM.cpp b/tests/pe_coupling/partially_saturated_cells_method/SegreSilberbergPSM.cpp index 563828ee360da2151c6e5ee36e27d30e9b337a56..7e0ad3250d28b0cb1f219bbae034dfdc77e817e2 100644 --- a/tests/pe_coupling/partially_saturated_cells_method/SegreSilberbergPSM.cpp +++ b/tests/pe_coupling/partially_saturated_cells_method/SegreSilberbergPSM.cpp @@ -502,7 +502,7 @@ int main( int argc, char **argv ) // set up synchronization procedure const real_t overlap = real_c( 1.5 ) * dx; - boost::function<void(void)> syncCall = boost::bind( pe::syncShadowOwners<BodyTypeTuple>, boost::ref(blocks->getBlockForest()), bodyStorageID, static_cast<WcTimingTree*>(NULL), overlap, false ); + std::function<void(void)> syncCall = boost::bind( pe::syncShadowOwners<BodyTypeTuple>, boost::ref(blocks->getBlockForest()), bodyStorageID, static_cast<WcTimingTree*>(NULL), overlap, false ); // create pe bodies @@ -568,7 +568,7 @@ int main( int argc, char **argv ) /////////////// // setup of the LBM communication for synchronizing the pdf field between neighboring blocks - boost::function< void () > commFunction; + std::function< void () > commFunction; blockforest::communication::UniformBufferedScheme< Stencil_T > scheme( blocks ); scheme.addPackInfo( make_shared< lbm::PdfFieldPackInfo< LatticeModel_T > >( pdfFieldID ) ); commFunction = scheme; diff --git a/tests/pe_coupling/partially_saturated_cells_method/TorqueSpherePSM.cpp b/tests/pe_coupling/partially_saturated_cells_method/TorqueSpherePSM.cpp index 31921f2f02306b36cd19480d3b3d043504072583..f91b5566e82396466744845bae224e5028e769a6 100644 --- a/tests/pe_coupling/partially_saturated_cells_method/TorqueSpherePSM.cpp +++ b/tests/pe_coupling/partially_saturated_cells_method/TorqueSpherePSM.cpp @@ -402,7 +402,7 @@ int main( int argc, char **argv ) SweepTimeloop timeloop( blocks->getBlockStorage(), timesteps ); // setup of the LBM communication for synchronizing the pdf field between neighboring blocks - boost::function< void () > commFunction; + std::function< void () > commFunction; blockforest::communication::UniformBufferedScheme< stencil::D3Q27 > scheme( blocks ); scheme.addPackInfo( make_shared< field::communication::PackInfo< PdfField_T > >( pdfFieldID ) );