diff --git a/.clang-format b/.clang-format index 1bdc80ff8929a640ee9753cb3249805508b9259b..dcd3860f6268d6f47ebf528641f36a8b31eef848 100644 --- a/.clang-format +++ b/.clang-format @@ -4,7 +4,7 @@ Language: Cpp AccessModifierOffset: -4 AlignAfterOpenBracket: Align AlignConsecutiveMacros: false -AlignConsecutiveAssignments: true +AlignConsecutiveAssignments: false AlignConsecutiveDeclarations: false AlignEscapedNewlines: Right AlignOperands: true @@ -14,7 +14,7 @@ AllowAllConstructorInitializersOnNextLine: true AllowAllParametersOfDeclarationOnNextLine: true AllowShortBlocksOnASingleLine: Never AllowShortCaseLabelsOnASingleLine: false -AllowShortFunctionsOnASingleLine: All +AllowShortFunctionsOnASingleLine: None AllowShortLambdasOnASingleLine: All AllowShortIfStatementsOnASingleLine: Never AllowShortLoopsOnASingleLine: false diff --git a/.cmake-format.yaml b/.cmake-format.yaml new file mode 100644 index 0000000000000000000000000000000000000000..d11c25002bb06b3db16ca63853faa096aac70c91 --- /dev/null +++ b/.cmake-format.yaml @@ -0,0 +1,76 @@ +parse: + additional_commands: + foo: + flags: + - BAR + - BAZ + kwargs: + HEADERS: '*' + SOURCES: '*' + DEPENDS: '*' + override_spec: {} + _help_vartags: + vartags: [] + proptags: [] + +format: + disable: false + line_width: 120 + tab_size: 4 + use_tabchars: false + fractional_tab_policy: use-space + max_subgroups_hwrap: 2 + max_pargs_hwrap: 6 + max_rows_cmdline: 2 + separate_ctrl_name_with_space: false + separate_fn_name_with_space: false + dangle_parens: false + dangle_align: prefix + min_prefix_chars: 4 + max_prefix_chars: 10 + max_lines_hwrap: 2 + line_ending: unix + command_case: canonical + keyword_case: unchanged + always_wrap: [] + enable_sort: true + autosort: false + require_valid_layout: false + layout_passes: {} + +markup: + bullet_char: '*' + enum_char: . + first_comment_is_literal: false + literal_comment_pattern: null + fence_pattern: ^\s*([`~]{3}[`~]*)(.*)$ + ruler_pattern: ^\s*[^\w\s]{3}.*[^\w\s]{3}$ + explicit_trailing_pattern: '#<' + hashruler_min_length: 10 + canonicalize_hashrulers: true + enable_markup: true + +lint: + disabled_codes: [] + function_pattern: '[0-9a-z_]+' + macro_pattern: '[0-9A-Z_]+' + global_var_pattern: '[A-Z][0-9A-Z_]+' + internal_var_pattern: _[A-Z][0-9A-Z_]+ + local_var_pattern: '[a-z][a-z0-9_]+' + private_var_pattern: _[0-9a-z_]+ + public_var_pattern: '[A-Z][0-9A-Z_]+' + argument_var_pattern: '[a-z][a-z0-9_]+' + keyword_pattern: '[A-Z][0-9A-Z_]+' + max_conditionals_custom_parser: 2 + min_statement_spacing: 1 + max_statement_spacing: 2 + max_returns: 6 + max_branches: 12 + max_arguments: 5 + max_localvars: 15 + max_statements: 50 + +encode: + emit_byteorder_mark: false + input_encoding: utf-8 + output_encoding: utf-8 \ No newline at end of file diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 132a776c71be1cf5d759bbaca801fc35c447d877..2854c1f6784fd5a87a8dbc1031d01b06b16e4325 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -11,10 +11,5 @@ "streetsidesoftware.code-spell-checker" ], "runArgs": ["--gpus","all"], - "image": "git.rz.tu-bs.de:4567/irmb/virtualfluids/ubuntu20_04:1.2", - "containerEnv": {"HOME": "/workspaces/"}, - "mounts": [ - "source=/mnt/d/output,target=/${containerWorkspaceFolder}/output,type=bind", - "source=${localEnv:HOME}/STLs,target=${containerWorkspaceFolder}/stl,type=bind" - ] -} \ No newline at end of file + "image": "git.rz.tu-bs.de:4567/irmb/virtualfluids/ubuntu20_04:1.2" +} diff --git a/.gitignore b/.gitignore index d0f28e28d47ced2a00b55d184571088371ce273a..578d3f91a2de6cac430328063dc90e85611961e1 100644 --- a/.gitignore +++ b/.gitignore @@ -19,6 +19,13 @@ __pycache__/ # simulation results output/ +logs/ + +# Input files +stl/ + +# Scripts +scripts/ # scripts scripts/ diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index dedfc6898999f20f60a42ebc80b3cdf0522a8331..2c6c35332b372379891de0c1ecc14640b48cbca8 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,7 +1,7 @@ ############################################################################### ## VirtualFluids CI Pipeline ## ############################################################################### -image: irmb/virtualfluids-python-deps-ubuntu20.04:latest +image: git.rz.tu-bs.de:4567/irmb/virtualfluids/ubuntu20_04:1.3 stages: - build @@ -20,8 +20,6 @@ stages: .gnu_build_template: stage: build - image: irmb/virtualfluids-deps-ubuntu20.04 - tags: - gpu - linux @@ -51,7 +49,7 @@ stages: - cd $CI_PROJECT_DIR/$BUILD_FOLDER - rm -r -f ./* - cmake .. -LAH - --preset=all_make_ccache + --preset=all_make -DBUILD_WARNINGS_AS_ERRORS=ON -DCMAKE_CUDA_ARCHITECTURES=60 - make -j4 @@ -121,8 +119,6 @@ msvc_16: gcc_9_python: stage: build_python - image: irmb/virtualfluids-python-deps-ubuntu20.04:latest - needs: ["gcc_9"] cache: @@ -149,8 +145,6 @@ gcc_9_python: build_singularity_image: stage: container_upload - image: irmb/virtualfluids-python-deps-ubuntu20.04:latest - needs: - gcc_9_python @@ -171,8 +165,6 @@ build_singularity_image: gcc_9_unit_tests: stage: test - image: irmb/virtualfluids-deps-ubuntu20.04:latest - needs: ["gcc_9"] before_script: @@ -203,8 +195,6 @@ msvc_16_unit_tests: gcc_9_python_bindings_test: stage: test - image: irmb/virtualfluids-python-deps-ubuntu20.04:latest - needs: ["gcc_9_python"] before_script: @@ -220,8 +210,6 @@ gcc_9_python_bindings_test: gcc_9_python_slurm_test: stage: test - image: irmb/virtualfluids-python-deps-ubuntu20.04:latest - needs: ["gcc_9_python"] rules: @@ -281,8 +269,6 @@ nvidia_test: gpu_numerical_tests: stage: benchmark - image: irmb/virtualfluids-deps-ubuntu20.04 - when: manual needs: [] @@ -301,7 +287,7 @@ gpu_numerical_tests: - cd $CI_PROJECT_DIR/build - rm -r -f ./* - cmake .. - --preset=gpu_numerical_tests_ccache_make + --preset=gpu_numerical_tests_make -DCMAKE_CUDA_ARCHITECTURES=60 -DPATH_NUMERICAL_TESTS=/tmp/test_data/numerical_tests_gpu - make -j4 @@ -328,8 +314,6 @@ gpu_numerical_tests: clang_build_analyzer_clang_10: stage: analyze - image: irmb/virtualfluids-deps-ubuntu20.04 - only: ["schedules"] needs: [] @@ -362,8 +346,6 @@ clang_build_analyzer_clang_10: include_what_you_use_clang_10: stage: analyze - image: irmb/virtualfluids-deps-ubuntu20.04 - only: ["schedules"] needs: [] @@ -391,24 +373,28 @@ include_what_you_use_clang_10: - make ############################################################################### +.analyze_template: + + rules: # dont create MR pipeline, run always on irmb/develop and manual in all other cases + - if: $CI_PIPELINE_SOURCE == "merge_request_event" + when: never + - if: '$CI_PROJECT_NAMESPACE == "irmb" && $CI_COMMIT_BRANCH == "develop"' + when: always + - when: manual + allow_failure: true + cppcheck: stage: analyze - image: irmb/virtualfluids-deps-ubuntu20.04 - - only: - - develop@irmb/VirtualFluids_dev + extends: .analyze_template needs: [] before_script: - - export DEBIAN_FRONTEND=noninteractive - - apt-get update - - apt-get install -y cppcheck + - cppcheck --version script: - cd $CI_PROJECT_DIR - - cppcheck --version - cppcheck src --enable=all --xml 2> cppcheck.xml artifacts: @@ -422,10 +408,7 @@ cppcheck: lizard: stage: analyze - image: irmb/virtualfluids-python-deps-ubuntu20.04:latest - - only: - - develop@irmb/VirtualFluids_dev + extends: .analyze_template needs: [] @@ -450,17 +433,11 @@ lizard: gcov_gcc_9: stage: analyze - image: irmb/virtualfluids-python-deps-ubuntu20.04:latest - - only: - - develop@irmb/VirtualFluids_dev + extends: .analyze_template needs: [] before_script: - - export DEBIAN_FRONTEND=noninteractive - - apt-get update - - pip3 install gcovr - gcovr --version script: @@ -496,10 +473,7 @@ gcov_gcc_9: clang-tidy: stage: analyze - image: irmb/virtualfluids-python-deps-ubuntu20.04:latest - - only: - - develop@irmb/VirtualFluids_dev + extends: .analyze_template needs: [] @@ -512,7 +486,6 @@ clang-tidy: - mkdir -p $CI_PROJECT_DIR/build - cd $CI_PROJECT_DIR/build - cmake .. - -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DBUILD_VF_CPU=ON -DBUILD_VF_GPU=OFF - python3 ../utilities/filterCompileCommands.py compile_commands.json @@ -555,7 +528,7 @@ pages: .deploy_template: stage: deploy - image: irmb/virtualfluids-python-deps-ubuntu20.04:latest + before_script: - 'command -v ssh-agent >/dev/null || ( apt-get update -y && apt-get install openssh-client -y )' @@ -618,8 +591,6 @@ vf_wheel_to_jupyterhub: sonar-scanner: stage: deploy - image: irmb/virtualfluids-python-deps-ubuntu20.04:latest - tags: - linux diff --git a/AUTHORS.md b/AUTHORS.md index 00a5410811196462d6f808036be7feb5e74a102d..554a5f1614a41f8bf7528e24b13d0a8569cb210d 100644 --- a/AUTHORS.md +++ b/AUTHORS.md @@ -1,25 +1,28 @@ # AUTHORS VF has been developed essentially over the last fifteen years by various researchers at IRMB including (in alphabetical order): + +Damilola Adekanye, M.Sc. Dr. Benjamin Ahrenholz -M. Sc. Hussein Alihussein +Dr. Hussein Alihussein Dr. Sebastian Bindick -B. Sc. Aileen Brendel +Aileen Brendel, B.Sc. J.Prof. Dr. Martin Geier Dr. Sebastian Geller Dr. Ehsan Goraki Fard Dr. Jan Hegewald Dr. Christian Janßen -M. Sc. Konstantin Kutscher -M. Sc. Stephan Lenz +Prof. Dr.-Ing. habil. Manfred Krafczyk +Dr. Konstantin Kutscher +Dr. Stephan Lenz Dr. Jan Linxweiler -B. Sc. Lennard Lux -B. Sc. Sven Marcus -M. Sc. Sören Peters +Lennard Lux, B.Sc. +Sören Peters, M.Sc. +Sven Marcus, M.Sc. Dr. Hesameddin Safari Dr. Martin Schönherr Dipl.-Ing. Maik Stiebler Dr. Sören Textor (aka Freudiger) PD Dr. Jonas Tölke Dr. Sonja Uphoff -B. Sc. Anna Wellmann \ No newline at end of file +Anna Wellmann, M.Sc. diff --git a/CMake/3rd/vtk.cmake b/CMake/3rd/vtk.cmake index 83cf22e8849298d2b42909664cacd5fd9044903e..7bba91a5a25da622ef752d670845754a6349815c 100644 --- a/CMake/3rd/vtk.cmake +++ b/CMake/3rd/vtk.cmake @@ -3,9 +3,8 @@ # VTK_DIR needs to bet set to the VTK build directory in the config file. ######################################################################### find_package(VTK REQUIRED) - vf_get_library_name(library_name) +vf_get_library_name(library_name) - include(${VTK_USE_FILE}) - target_include_directories(${library_name} PRIVATE ${VTK_INCLUDE_DIRS}) +target_include_directories(${library_name} PRIVATE ${VTK_INCLUDE_DIRS}) - target_link_libraries(${library_name} PRIVATE ${VTK_LIBRARIES}) +target_link_libraries(${library_name} PRIVATE ${VTK_LIBRARIES}) diff --git a/CMake/Cache.cmake b/CMake/Cache.cmake new file mode 100644 index 0000000000000000000000000000000000000000..5cd6b500bb9d38afa095fc0eb1087b228ee48ab2 --- /dev/null +++ b/CMake/Cache.cmake @@ -0,0 +1,31 @@ +option(ENABLE_CACHE "Enable cache if available" ON) +if(NOT ENABLE_CACHE) + return() +endif() + +set(CACHE_OPTION + "ccache" + CACHE STRING "Compiler cache to be used") +set(CACHE_OPTION_VALUES "ccache" "sccache") +set_property(CACHE CACHE_OPTION PROPERTY STRINGS ${CACHE_OPTION_VALUES}) +list( + FIND + CACHE_OPTION_VALUES + ${CACHE_OPTION} + CACHE_OPTION_INDEX) + +if(${CACHE_OPTION_INDEX} EQUAL -1) + message( + STATUS + "Using custom compiler cache system: '${CACHE_OPTION}', explicitly supported entries are ${CACHE_OPTION_VALUES}") +endif() + +find_program(CACHE_BINARY ${CACHE_OPTION}) +if(CACHE_BINARY) + message(STATUS "${CACHE_OPTION} found and enabled") + set(CMAKE_CXX_COMPILER_LAUNCHER ${CACHE_BINARY}) + set(CMAKE_CUDA_COMPILER_LAUNCHER ${CACHE_BINARY}) + set(CMAKE_C_COMPILER_LAUNCHER ${CACHE_BINARY}) +else() + message(STATUS "${CACHE_OPTION} is enabled but was not found. Not using it") +endif() diff --git a/CMake/CompilerWarnings.cmake b/CMake/CompilerWarnings.cmake new file mode 100644 index 0000000000000000000000000000000000000000..eafc2f7a85068ab66d9e113848e94c4a2569bdff --- /dev/null +++ b/CMake/CompilerWarnings.cmake @@ -0,0 +1,77 @@ +# from here: +# +# https://github.com/lefticus/cppbestpractices/blob/master/02-Use_the_Tools_Available.md + +function(set_project_warnings project_name) + + set(MSVC_WARNINGS + /W4 # Baseline reasonable warnings + /w14242 # 'identifier': conversion from 'type1' to 'type1', possible loss of data + /w14254 # 'operator': conversion from 'type1:field_bits' to 'type2:field_bits', possible loss of data + /w14263 # 'function': member function does not override any base class virtual member function + /w14265 # 'classname': class has virtual functions, but destructor is not virtual instances of this class may not + # be destructed correctly + /w14287 # 'operator': unsigned/negative constant mismatch + /we4289 # nonstandard extension used: 'variable': loop control variable declared in the for-loop is used outside + # the for-loop scope + /w14296 # 'operator': expression is always 'boolean_value' + /w14311 # 'variable': pointer truncation from 'type1' to 'type2' + /w14545 # expression before comma evaluates to a function which is missing an argument list + /w14546 # function call before comma missing argument list + /w14547 # 'operator': operator before comma has no effect; expected operator with side-effect + /w14549 # 'operator': operator before comma has no effect; did you intend 'operator'? + /w14555 # expression has no effect; expected expression with side- effect + /w14619 # pragma warning: there is no warning number 'number' + /w14640 # Enable warning on thread un-safe static member initialization + /w14826 # Conversion from 'type1' to 'type_2' is sign-extended. This may cause unexpected runtime behavior. + /w14905 # wide string literal cast to 'LPSTR' + /w14906 # string literal cast to 'LPWSTR' + /w14928 # illegal copy-initialization; more than one user-defined conversion has been implicitly applied + /permissive- # standards conformance mode for MSVC compiler. + ) + + set(CLANG_WARNINGS + -Wall + -Wextra # reasonable and standard + -Wshadow # warn the user if a variable declaration shadows one from a parent context + -Wnon-virtual-dtor # warn the user if a class with virtual functions has a non-virtual destructor. This helps + # catch hard to track down memory errors + -Wold-style-cast # warn for c-style casts + -Wcast-align # warn for potential performance problem casts + -Wunused # warn on anything being unused + -Woverloaded-virtual # warn if you overload (not override) a virtual function + -Wpedantic # warn if non-standard C++ is used + -Wconversion # warn on type conversions that may lose data + -Wsign-conversion # warn on sign conversions + -Wnull-dereference # warn if a null dereference is detected + -Wdouble-promotion # warn if float is implicit promoted to double + -Wformat=2 # warn on security issues around functions that format output (ie printf) + ) + + if(BUILD_WARNINGS_AS_ERRORS) + set(CLANG_WARNINGS ${CLANG_WARNINGS} -Werror) + set(MSVC_WARNINGS ${MSVC_WARNINGS} /WX) + endif() + + set(GCC_WARNINGS + ${CLANG_WARNINGS} + -Wmisleading-indentation # warn if indentation implies blocks where blocks do not exist + -Wduplicated-cond # warn if if / else chain has duplicated conditions + -Wduplicated-branches # warn if if / else branches have duplicated code + -Wlogical-op # warn about logical operations being used where bitwise were probably wanted + -Wuseless-cast # warn if you perform a cast to the same type + ) + + if(MSVC) + set(PROJECT_WARNINGS ${MSVC_WARNINGS}) + elseif(CMAKE_CXX_COMPILER_ID MATCHES ".*Clang") + set(PROJECT_WARNINGS ${CLANG_WARNINGS}) + elseif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") + set(PROJECT_WARNINGS ${GCC_WARNINGS}) + else() + message(AUTHOR_WARNING "No compiler warnings set for '${CMAKE_CXX_COMPILER_ID}' compiler.") + endif() + + target_compile_options(${project_name} INTERFACE ${PROJECT_WARNINGS}) + +endfunction() diff --git a/CMake/Sanitizers.cmake b/CMake/Sanitizers.cmake new file mode 100644 index 0000000000000000000000000000000000000000..6f16207fefbc2f9ca72f065950b242a4333d442e --- /dev/null +++ b/CMake/Sanitizers.cmake @@ -0,0 +1,60 @@ +function(enable_sanitizers project_name) + + if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID MATCHES ".*Clang") + + set(SANITIZERS "") + + option(ENABLE_SANITIZER_ADDRESS "Enable address sanitizer" FALSE) + if(ENABLE_SANITIZER_ADDRESS) + list(APPEND SANITIZERS "address") + endif() + + option(ENABLE_SANITIZER_LEAK "Enable leak sanitizer" FALSE) + if(ENABLE_SANITIZER_LEAK) + list(APPEND SANITIZERS "leak") + endif() + + option(ENABLE_SANITIZER_UNDEFINED_BEHAVIOR "Enable undefined behavior sanitizer" FALSE) + if(ENABLE_SANITIZER_UNDEFINED_BEHAVIOR) + list(APPEND SANITIZERS "undefined") + endif() + + option(ENABLE_SANITIZER_THREAD "Enable thread sanitizer" FALSE) + if(ENABLE_SANITIZER_THREAD) + if("address" IN_LIST SANITIZERS OR "leak" IN_LIST SANITIZERS) + message(WARNING "Thread sanitizer does not work with Address and Leak sanitizer enabled") + else() + list(APPEND SANITIZERS "thread") + endif() + endif() + + option(ENABLE_SANITIZER_MEMORY "Enable memory sanitizer" FALSE) + if(ENABLE_SANITIZER_MEMORY AND CMAKE_CXX_COMPILER_ID MATCHES ".*Clang") + if("address" IN_LIST SANITIZERS + OR "thread" IN_LIST SANITIZERS + OR "leak" IN_LIST SANITIZERS) + message(WARNING "Memory sanitizer does not work with Address, Thread and Leak sanitizer enabled") + else() + list(APPEND SANITIZERS "memory") + endif() + endif() + + list( + JOIN + SANITIZERS + "," + LIST_OF_SANITIZERS) + + endif() + + if(LIST_OF_SANITIZERS) + if(NOT + "${LIST_OF_SANITIZERS}" + STREQUAL + "") + target_compile_options(${project_name} INTERFACE -fsanitize=${LIST_OF_SANITIZERS}) + target_link_options(${project_name} INTERFACE -fsanitize=${LIST_OF_SANITIZERS}) + endif() + endif() + +endfunction() diff --git a/CMake/VirtualFluidsMacros.cmake b/CMake/VirtualFluidsMacros.cmake index 2c2bc1d650e5e2c402f34a1a2547b9fa6f5e063b..fbe0d9404e6c923bfb866e7d8dea7844b51ae17a 100644 --- a/CMake/VirtualFluidsMacros.cmake +++ b/CMake/VirtualFluidsMacros.cmake @@ -21,6 +21,7 @@ endfunction() include(${VF_CMAKE_DIR}/CMakeSetCompilerFlags.cmake) include(${VF_CMAKE_DIR}/FileUtilities.cmake) include(${VF_CMAKE_DIR}/3rd.cmake) +include(${VF_CMAKE_DIR}/Sanitizers.cmake) ############################################################################################################### # Reset the compiler and linker flags @@ -152,6 +153,9 @@ function(vf_add_library) ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib" PDB_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin") + # sanitizers + enable_sanitizers(${library_name}) + # link time optimization if(BUILD_VF_LTO) if(NOT ${ARG_BUILDTYPE} MATCHES binary) diff --git a/CMake/cmake_config_files/GITLAB-RUNNER03.config.cmake b/CMake/cmake_config_files/GITLAB-RUNNER03.config.cmake new file mode 100644 index 0000000000000000000000000000000000000000..edaf7669b171518c8aa6b2ec9786147a6ffc48f5 --- /dev/null +++ b/CMake/cmake_config_files/GITLAB-RUNNER03.config.cmake @@ -0,0 +1,10 @@ +################################################################################# +# VirtualFluids MACHINE FILE +# Responsible: Soeren Peters +# OS: Windows 10 +################################################################################# + + +#SET(PATH_NUMERICAL_TESTS "E:/temp/numericalTests/") +#LIST(APPEND VF_COMPILER_DEFINITION "PATH_NUMERICAL_TESTS=${PATH_NUMERICAL_TESTS}") +SET(CMAKE_CUDA_ARCHITECTURES 61) \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index c83a82b1475e2a00d79100ec3900dc0cda047aa9..d7aae3233d1f17e804e29ba3090d7a3bc9ca8a3f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,13 +6,13 @@ # |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ # ################################################################################# -# required cmake versions -# CMAKE 3.13: target_link_options -# CMAKE 3.15: CMAKE_MSVC_RUNTIME_LIBRARY -################################################################################# cmake_minimum_required(VERSION 3.15..3.20 FATAL_ERROR) -project(VirtualFluids CXX) +project(VirtualFluids + VERSION 1.0.0 + DESCRIPTION "CFD code based on the Lattice Boltzmann Method" + HOMEPAGE_URL "https://www.tu-braunschweig.de/irmb/forschung/virtualfluids" + LANGUAGES CXX) if(NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE Release) @@ -22,6 +22,8 @@ message(STATUS "CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}") set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) +set(CMAKE_EXPORT_COMPILE_COMMANDS ON) + set_property(GLOBAL PROPERTY USE_FOLDERS ON) set_property(GLOBAL PROPERTY PREDEFINED_TARGETS_FOLDER ".cmake") set(libraryFolder "libs") @@ -34,6 +36,11 @@ set (VF_THIRD_DIR ${CMAKE_CURRENT_SOURCE_DIR}/3rdParty) set (VF_SRC_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src) set (VF_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}) +if (${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR}) + message(FATAL_ERROR "In-source builds are prohibited. " + "Create a new directory and build there.") +endif () + ################################################################################# # OPTIONS ################################################################################# @@ -41,10 +48,10 @@ option(BUILD_VF_CPU "Build VirtualFluids cpu variant" OFF) option(BUILD_VF_GPU "Build VirtualFluids gpu variant" OFF) option(BUILD_USE_OPENMP "Build VirtualFluids with openmp" ON) - +option(BUILD_USE_BOOST "Build VirtualFluids with boost" OFF) +option(BUILD_USE_MPI "include MPI library support" ON) # vf gpu -option(BUILD_VF_GPU "Build VirtualFluids GPU" ON ) option(BUILD_VF_GKS "Build VirtualFluids GKS" OFF ) option(BUILD_VF_TRAFFIC "Build VirtualFluids Traffic" OFF) option(BUILD_JSONCPP "Builds json cpp " OFF) @@ -76,6 +83,15 @@ option(BUILD_VF_DOUBLE_ACCURACY "Use double accuracy" OFF) ################################################################################# # MACROS ################################################################################# +add_library(project_warnings INTERFACE) + +# standard compiler warnings - Link this 'library' to use the warnings specified in CompilerWarnings.cmake +include(${VF_CMAKE_DIR}/CompilerWarnings.cmake) +set_project_warnings(project_warnings) + +# enable cache system +include(${VF_CMAKE_DIR}/Cache.cmake) + include(CMakePrintHelpers) include(${VF_CMAKE_DIR}/VirtualFluidsMacros.cmake) @@ -83,7 +99,8 @@ IF( BUILD_VF_DOUBLE_ACCURACY ) list(APPEND VF_COMPILER_DEFINITION VF_DOUBLE_ACCURACY) ENDIF() -if(BUILD_VF_GPU) +# set gpu features +if(BUILD_VF_GPU OR BUILD_VF_GKS) include(CheckLanguage) check_language(CUDA) @@ -119,12 +136,28 @@ if(BUILD_VF_GPU) message(STATUS "CMAKE_CUDA_FLAGS: ${CMAKE_CUDA_FLAGS}") message(STATUS "CUDA Architecture: ${CMAKE_CUDA_ARCHITECTURES}") + set(CMAKE_CUDA_ARCHITECTURES "${CMAKE_CUDA_ARCHITECTURES}" CACHE STRING "Cuda Architecture (compute capabilitiy)") endif() ################################################################################# # COMMON LIBRARIES ################################################################################# +include(FetchContent) + +set(spdlog_version "v1.9.1") +set(spdlog_url "https://github.com/gabime/spdlog") +message(STATUS "Fetching spdlog: ${spdlog_version}") +FetchContent_Declare( + spdlog + GIT_REPOSITORY ${spdlog_url} + GIT_TAG ${spdlog_version} +) + +FetchContent_MakeAvailable(spdlog) +target_compile_options(spdlog PRIVATE "-fPIC") +groupTarget(spdlog ${thirdFolder}) + if(BUILD_VF_UNIT_TESTS) add_subdirectory(${VF_THIRD_DIR}/googletest) include(GoogleTest) @@ -135,10 +168,29 @@ if(BUILD_USE_OPENMP) find_package(OpenMP REQUIRED) endif() -find_package(MPI REQUIRED) +if(BUILD_USE_MPI) + find_package(MPI REQUIRED) + if(BUILD_VF_CPU) + list(APPEND VF_COMPILER_DEFINITION VF_MPI) + endif() +endif() +# boost +IF(BUILD_USE_BOOST) + list(APPEND VF_COMPILER_DEFINITION BUILD_USE_BOOST) + set(Boost_USE_STATIC_LIBS ON) + set(Boost_USE_MULTITHREADED ON) + set(Boost_USE_STATIC_RUNTIME ON) + + # minimum boost version: 1.60 + # no packages specfied - only headeronly libraries + find_package(Boost 1.60 REQUIRED) +ENDIF() + +add_subdirectory(src/logger) add_subdirectory(src/basics) +add_subdirectory(src/mpi) add_subdirectory(src/lbm) @@ -148,6 +200,12 @@ add_subdirectory(src/lbm) if (BUILD_VF_CPU) include (cpu.cmake) endif() -if(BUILD_VF_GPU) +if(BUILD_VF_GPU OR BUILD_VF_GKS) + add_subdirectory(src/cuda) include (gpu.cmake) -endif() \ No newline at end of file +endif() + +if (BUILD_VF_PYTHON_BINDINGS) + add_subdirectory(${VF_THIRD_DIR}/pybind11/pybind11-2.6.0) + add_subdirectory(pythonbindings) +endif() diff --git a/CMakePresets.json b/CMakePresets.json index 663142f01b4076bc66295549a11fb4e3b6701ce0..0f360fd303cdcad923b01d56df5c6d48ad62ca2c 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -2,7 +2,7 @@ "version": 2, "cmakeMinimumRequired": { "major": 3, - "minor": 19, + "minor": 20, "patch": 0 }, "configurePresets": [ @@ -20,16 +20,6 @@ "hidden": true, "generator": "Unix Makefiles" }, - { - "name": "default_ccache_make", - "inherits": "default_make", - "hidden": true, - "cacheVariables": { - "CMAKE_CXX_COMPILER_LAUNCHER": "ccache", - "CMAKE_CUDA_COMPILER_LAUNCHER": "ccache", - "CMAKE_C_COMPILER_LAUNCHER": "ccache" - } - }, { "name": "default_msvc", "inherits": "default", @@ -87,14 +77,6 @@ ], "displayName": "cpu make configuration" }, - { - "name": "cpu_make_ccache", - "inherits": [ - "default_ccache_make", - "default_cpu" - ], - "displayName": "cpu ccache make configuration" - }, { "name": "cpu_msvc", "inherits": [ @@ -111,14 +93,6 @@ ], "displayName": "gpu make configuration" }, - { - "name": "gpu_make_ccache", - "inherits": [ - "default_ccache_make", - "default_gpu" - ], - "displayName": "gpu ccache make configuration" - }, { "name": "gpu_msvc", "inherits": [ @@ -135,14 +109,6 @@ ], "displayName": "all make configuration" }, - { - "name": "all_make_ccache", - "inherits": [ - "default_ccache_make", - "default_all" - ], - "displayName": "all ccache make configuration" - }, { "name": "all_msvc", "inherits": [ @@ -159,14 +125,6 @@ ], "displayName": "gpu numerical tests make configuration" }, - { - "name": "gpu_numerical_tests_ccache_make", - "inherits": [ - "default_ccache_make", - "default_gpu_numerical_tests" - ], - "displayName": "gpu numerical tests ccache make configuration" - }, { "name": "gpu_numerical_tests_msvc", "inherits": [ diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index a0693d564438ece97e0e9bebc7262bf189a337d4..ebd21c1a26e184136b41d35d1091ba519e885f62 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -15,7 +15,7 @@ To contribute use a merge request as follows: - Run the tests. - Write or adapt tests as needed. - Add or change the documentation as needed. -- Push your branch to your fork on gitea, the remote `origin`. +- Push your branch to your fork on gitlab, the remote `origin`. - From your fork open a merge request in the correct branch. Target the project's `develop` or `open_source` branch - … - If we requests further changes just push them to your branch. The MR will be updated automatically. diff --git a/Containers/dockerfiles/Ubuntu20_04.Dockerfile b/Containers/dockerfiles/Ubuntu20_04.Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..93ff4f896b6ce1518661bb343ed2bfd94ebbbf89 --- /dev/null +++ b/Containers/dockerfiles/Ubuntu20_04.Dockerfile @@ -0,0 +1,48 @@ +# VirtualFluids BuildDependencies: +# Ubuntu 20.04 +# general tools: wget, unzip, git +# CMake 3.22.3 +# ccache +# gcc 9.3 (default) +# gdb +# openmpi 4.0.3 +# openmp +# cuda 11.3.1 as base image +# freeGLUT +# cppcheck +# clang 10.0 (default) +# python pip3 with modules: setuptools, wheels, scikit-build, pyvista, numpy, ansible, gcovr + +FROM nvidia/cuda:11.3.1-devel-ubuntu20.04 + +ENV DEBIAN_FRONTEND=noninteractive +RUN apt-get update && \ + apt-get install -y \ + wget unzip git \ + build-essential gdb \ + ccache \ + ninja-build \ + openmpi-bin=4.0.3-0ubuntu1 \ + libomp-dev \ + clang \ + clang-format \ + clang-tidy \ + clang-tools \ + llvm-dev \ + libclang-dev \ + python3-pip \ + freeglut3-dev \ + cppcheck \ + && mkdir -p /usr/local/cmake/ && cd /usr/local/cmake/ \ + && version=3.22 && build=3 \ + && wget https://cmake.org/files/v$version/cmake-$version.$build-linux-x86_64.tar.gz \ + && tar -xzvf cmake-$version.$build-linux-x86_64.tar.gz \ + && ln -s /usr/local/cmake/cmake-$version.$build-linux-x86_64/bin/* /usr/local/bin/ \ + && pip3 install \ + setuptools \ + wheel \ + scikit-build \ + pyvista \ + numpy \ + ansible \ + 'jinja2<3.1' gcovr==5.0 diff --git a/Python/SlurmTests/poiseuille/settings.py b/Python/SlurmTests/poiseuille/settings.py index f75c2b1d7133323880dd5520de0a96cb8fa87860..4b4a1e4e9cc7f6118a60c22a40c70b027e3ac4e2 100644 --- a/Python/SlurmTests/poiseuille/settings.py +++ b/Python/SlurmTests/poiseuille/settings.py @@ -1,7 +1,7 @@ import os from acousticscaling import OneDirectionalAcousticScaling -from pyfluids.kernel import LBMKernel, KernelType -from pyfluids.parameters import RuntimeParameters, GridParameters, PhysicalParameters +from pyfluids.cpu.kernel import LBMKernel, KernelType +from pyfluids.cpu.parameters import RuntimeParameters, GridParameters, PhysicalParameters grid_params = GridParameters() diff --git a/Python/SlurmTests/poiseuille/simulation_runner.py b/Python/SlurmTests/poiseuille/simulation_runner.py index 0b75de40b6a8f11ccd76f97f2ed9d709dc5362dd..03fb24be7ea1a6468ae25ec3aa40ab59962ef91e 100644 --- a/Python/SlurmTests/poiseuille/simulation_runner.py +++ b/Python/SlurmTests/poiseuille/simulation_runner.py @@ -2,7 +2,7 @@ import os from SlurmTests.poiseuille.settings import Scaling from poiseuille.simulation import run_simulation -from pyfluids.writer import Writer, OutputFormat +from pyfluids.cpu.writer import Writer, OutputFormat scale_level = int(os.environ["PYFLUIDS_SCALE_LEVEL"]) diff --git a/Python/acousticscaling.py b/Python/acousticscaling.py index 50b81db064251fa269f29bf72a561567ddedafbc..a664b8e924d648b680562b9aef11bee87b3562b1 100644 --- a/Python/acousticscaling.py +++ b/Python/acousticscaling.py @@ -1,5 +1,5 @@ -from pyfluids.kernel import LBMKernel -from pyfluids.parameters import GridParameters, PhysicalParameters, RuntimeParameters +from pyfluids.cpu.kernel import LBMKernel +from pyfluids.cpu.parameters import GridParameters, PhysicalParameters, RuntimeParameters class OneDirectionalAcousticScaling: @@ -13,10 +13,10 @@ class OneDirectionalAcousticScaling: self._runtime_params = runtime_parameters self._kernel = kernel - def configuration_for_scale_level(self, level: int = 1) -> (GridParameters, + def configuration_for_scale_level(self, level: int = 1) -> tuple[GridParameters, PhysicalParameters, RuntimeParameters, - LBMKernel): + LBMKernel]: if level < 0: raise ValueError("level must be >= 0") diff --git a/src/gpu/GridGenerator/geometries/Point/Point.cpp b/Python/actuator_line/__init__.py similarity index 100% rename from src/gpu/GridGenerator/geometries/Point/Point.cpp rename to Python/actuator_line/__init__.py diff --git a/Python/actuator_line/actuator_line.py b/Python/actuator_line/actuator_line.py new file mode 100644 index 0000000000000000000000000000000000000000..cd0e06149a52430cbdc811106b505bc6049e2221 --- /dev/null +++ b/Python/actuator_line/actuator_line.py @@ -0,0 +1,111 @@ +#%% +import numpy as np +from pathlib import Path +from mpi4py import MPI +from pyfluids import basics, gpu, logger +#%% +reference_diameter = 126 + +length = np.array([29,6,6])*reference_diameter +viscosity = 1.56e-5 +velocity = 9 +mach = 0.1 +nodes_per_diameter = 32 + +sim_name = "ActuatorLine" +config_file = Path(__file__).parent/Path("config.txt") +output_path = Path(__file__).parent/Path("output") +output_path.mkdir(exist_ok=True) +timeStepOut = 500 +t_end = 50 + +#%% +logger.Logger.initialize_logger() +basics.logger.Logger.add_stdout() +basics.logger.Logger.set_debug_level(basics.logger.Level.INFO_LOW) +basics.logger.Logger.time_stamp(basics.logger.TimeStamp.ENABLE) +basics.logger.Logger.enable_printed_rank_numbers(True) +#%% +grid_builder = gpu.MultipleGridBuilder.make_shared() +dx = reference_diameter/nodes_per_diameter + +grid_builder.add_coarse_grid(0.0, 0.0, 0.0, *length, dx) +grid_builder.set_periodic_boundary_condition(False, False, False) +grid_builder.build_grids(basics.LbmOrGks.LBM, False) +# %% +comm = gpu.Communicator.get_instance() +#%% +config = basics.ConfigurationFile() +config.load(str(config_file)) +#%% +para = gpu.Parameter(config, comm.get_number_of_process(), comm.get_pid()) + +dt = dx * mach / (np.sqrt(3) * velocity) +velocity_lb = velocity * dt / dx # LB units +viscosity_lb = viscosity * dt / (dx * dx) # LB units + +#%% +para.set_devices([0]) +para.set_output_prefix(sim_name) +para.set_output_path(str(output_path)) +para.set_f_name(para.get_output_path() + "/" + para.get_output_prefix()) +para.set_print_files(True) +para.set_max_level(1) +#%% +para.set_velocity(velocity_lb) +para.set_viscosity(viscosity_lb) +para.set_velocity_ratio(dx/dt) +para.set_main_kernel("TurbulentViscosityCumulantK17CompChim") +para.set_use_AMD(True) +para.set_SGS_constant(0.083) + +def init_func(coord_x, coord_y, coord_z): + return [0.0, velocity_lb, 0.0, 0.0] + +para.set_initial_condition(init_func) +para.set_t_out(timeStepOut) +para.set_t_end(int(t_end/dt)) +para.set_is_body_force(True) + +#%% +grid_builder.set_velocity_boundary_condition(gpu.SideType.MX, velocity_lb, 0.0, 0.0) + +grid_builder.set_velocity_boundary_condition(gpu.SideType.MY, velocity_lb, 0.0, 0.0) +grid_builder.set_velocity_boundary_condition(gpu.SideType.PY, velocity_lb, 0.0, 0.0) + +grid_builder.set_velocity_boundary_condition(gpu.SideType.MZ, velocity_lb, 0.0, 0.0) +grid_builder.set_velocity_boundary_condition(gpu.SideType.PZ, velocity_lb, 0.0, 0.0) + +grid_builder.set_pressure_boundary_condition(gpu.SideType.PX, 0.0) + +#%% +cuda_memory_manager = gpu.CudaMemoryManager.make(para) +grid_generator = gpu.GridProvider.make_grid_generator(grid_builder, para, cuda_memory_manager) +#%% +turb_pos = np.array([3,3,3])*reference_diameter +epsilon = 5 +density = 1.225 +level = 0 +n_blades = 3 +n_blade_nodes = 32 +alm = gpu.ActuatorLine(n_blades, density, n_blade_nodes, epsilon, *turb_pos, reference_diameter, level, dt, dx) +para.add_actuator(alm) +#%% +point_probe = gpu.probes.PointProbe("pointProbe", str(output_path), 100, 500, 100) +point_probe.add_probe_points_from_list(np.array([1,2,5])*reference_diameter, np.array([3,3,3])*reference_diameter, np.array([3,3,3])*reference_diameter) +point_probe.add_post_processing_variable(gpu.probes.PostProcessingVariable.Means) + +para.add_probe(point_probe) + +plane_probe = gpu.probes.PlaneProbe("planeProbe", str(output_path), 100, 500, 100) +plane_probe.set_probe_plane(5*reference_diameter, 0, 0, dx, length[1], length[2]) +para.add_probe(plane_probe) +#%% +sim = gpu.Simulation(comm) +kernel_factory = gpu.KernelFactory.get_instance() +sim.set_factories(kernel_factory, gpu.PreProcessorFactory.get_instance()) +sim.init(para, grid_generator, gpu.FileWriter(), cuda_memory_manager) +#%% +sim.run() +sim.free() +MPI.Finalize() \ No newline at end of file diff --git a/Python/actuator_line/config.txt b/Python/actuator_line/config.txt new file mode 100644 index 0000000000000000000000000000000000000000..e4c778c4cc048f54c0a32310e6bf4a7343a263fa --- /dev/null +++ b/Python/actuator_line/config.txt @@ -0,0 +1,2 @@ +Path = . +GridPath = . diff --git a/src/gpu/GridGenerator/geometries/Point/Point.h b/Python/boundary_layer/__init__.py similarity index 100% rename from src/gpu/GridGenerator/geometries/Point/Point.h rename to Python/boundary_layer/__init__.py diff --git a/Python/boundary_layer/boundary_layer.py b/Python/boundary_layer/boundary_layer.py new file mode 100644 index 0000000000000000000000000000000000000000..cf941a9418e5c3ec5d94864f119de20401601622 --- /dev/null +++ b/Python/boundary_layer/boundary_layer.py @@ -0,0 +1,108 @@ +#%% +import numpy as np +from pathlib import Path +from mpi4py import MPI +from pyfluids import basics, gpu, logger +#%% +reference_diameter = 126 + +length = np.array([30,8,8])*reference_diameter +viscosity = 1.56e-5 +velocity = 9 +mach = 0.1 +nodes_per_diameter = 32 + +sim_name = "BoundaryLayer" +config_file = Path(__file__).parent/Path("config.txt") +output_path = Path(__file__).parent/Path("output") +output_path.mkdir(exist_ok=True) +timeStepOut = 500 +t_end = 50 + +#%% +logger.Logger.initialize_logger() +basics.logger.Logger.add_stdout() +basics.logger.Logger.set_debug_level(basics.logger.Level.INFO_LOW) +basics.logger.Logger.time_stamp(basics.logger.TimeStamp.ENABLE) +basics.logger.Logger.enable_printed_rank_numbers(True) +#%% +grid_builder = gpu.MultipleGridBuilder.make_shared() +dx = reference_diameter/nodes_per_diameter + +grid_builder.add_coarse_grid(0.0, 0.0, 0.0, *length, dx) +grid_builder.set_periodic_boundary_condition(False, False, False) +grid_builder.build_grids(basics.LbmOrGks.LBM, False) +# %% +comm = gpu.Communicator.get_instance() +#%% +config = basics.ConfigurationFile() +config.load(str(config_file)) +#%% +para = gpu.Parameter(config, comm.get_number_of_process(), comm.get_pid()) + +dt = dx * mach / (np.sqrt(3) * velocity) +velocity_lb = velocity * dt / dx # LB units +viscosity_lb = viscosity * dt / (dx * dx) # LB units + +#%% +para.set_devices([0]) +para.set_output_prefix(sim_name) +para.set_output_path(str(output_path)) +para.set_f_name(para.get_output_path() + "/" + para.get_output_prefix()) +para.set_print_files(True) +para.set_max_level(1) +#%% +para.set_velocity(velocity_lb) +para.set_viscosity(viscosity_lb) +para.set_velocity_ratio(dx/dt) +para.set_main_kernel("CumulantK17CompChim") + +def init_func(coord_x, coord_y, coord_z): + return [0.0, velocity_lb, 0.0, 0.0] + +para.set_initial_condition(init_func) +para.set_t_out(timeStepOut) +para.set_t_end(int(t_end/dt)) +para.set_is_body_force(True) + +#%% +grid_builder.set_velocity_boundary_condition(gpu.SideType.MX, velocity_lb, 0.0, 0.0) +grid_builder.set_velocity_boundary_condition(gpu.SideType.PX, velocity_lb, 0.0, 0.0) + +grid_builder.set_velocity_boundary_condition(gpu.SideType.MY, velocity_lb, 0.0, 0.0) +grid_builder.set_velocity_boundary_condition(gpu.SideType.PY, velocity_lb, 0.0, 0.0) + +grid_builder.set_velocity_boundary_condition(gpu.SideType.MZ, velocity_lb, 0.0, 0.0) +grid_builder.set_velocity_boundary_condition(gpu.SideType.PZ, velocity_lb, 0.0, 0.0) + +#%% +cuda_memory_manager = gpu.CudaMemoryManager.make(para) +grid_generator = gpu.GridProvider.make_grid_generator(grid_builder, para, cuda_memory_manager) +#%% +turb_pos = np.array([3,3,3])*reference_diameter +epsilon = 5 +density = 1.225 +level = 0 +n_blades = 3 +n_blade_nodes = 32 +alm = gpu.ActuatorLine(n_blades, density, n_blade_nodes, epsilon, *turb_pos, reference_diameter, level, dt, dx) +para.add_actuator(alm) +#%% +point_probe = gpu.probes.PointProbe("pointProbe", str(output_path), 100, 500, 100) +point_probe.add_probe_points_from_list(np.array([1,2,5])*reference_diameter, np.array([3,3,3])*reference_diameter, np.array([3,3,3])*reference_diameter) +point_probe.add_post_processing_variable(gpu.probes.PostProcessingVariable.Means) + +para.add_probe(point_probe) + +plane_probe = gpu.probes.PlaneProbe("planeProbe", str(output_path), 100, 500, 100) +plane_probe.set_probe_plane(5*reference_diameter, 0, 0, dx, length[1], length[2]) +para.add_probe(plane_probe) +#%% +sim = gpu.Simulation(comm) +kernel_factory = gpu.KernelFactory.get_instance() +sim.set_factories(kernel_factory, gpu.PreProcessorFactory.get_instance()) +sim.init(para, grid_generator, gpu.FileWriter(), cuda_memory_manager) +#%% +sim.run() +sim.free() +MPI.Finalize() \ No newline at end of file diff --git a/Python/boundary_layer/config.txt b/Python/boundary_layer/config.txt new file mode 100644 index 0000000000000000000000000000000000000000..e4c778c4cc048f54c0a32310e6bf4a7343a263fa --- /dev/null +++ b/Python/boundary_layer/config.txt @@ -0,0 +1,2 @@ +Path = . +GridPath = . diff --git a/Python/cubeflow/simulation.py b/Python/cubeflow/simulation.py index c8c145fdc27b5eab6a6e2df95d94f27999b6e258..9e77e8d747c072188d8d81150afa8e2ccb76a792 100644 --- a/Python/cubeflow/simulation.py +++ b/Python/cubeflow/simulation.py @@ -1,9 +1,9 @@ -from pyfluids import Simulation -from pyfluids.boundaryconditions import NoSlipBoundaryCondition, VelocityBoundaryCondition, DensityBoundaryCondition -from pyfluids.geometry import GbCuboid3D -from pyfluids.kernel import LBMKernel, KernelType -from pyfluids.parameters import PhysicalParameters, RuntimeParameters, GridParameters -from pyfluids.writer import Writer, OutputFormat +from pyfluids.cpu import Simulation +from pyfluids.cpu.boundaryconditions import NoSlipBoundaryCondition, VelocityBoundaryCondition, DensityBoundaryCondition +from pyfluids.cpu.geometry import GbCuboid3D +from pyfluids.cpu.kernel import LBMKernel, KernelType +from pyfluids.cpu.parameters import PhysicalParameters, RuntimeParameters, GridParameters +from pyfluids.cpu.writer import Writer, OutputFormat from pymuparser import Parser import os diff --git a/Python/liddrivencavity/simulation.py b/Python/liddrivencavity/simulation.py index f5e5921a3a163c8f5d2421c833ccc993eb5430c0..155fad2f6f8aade0368c8a7006b88f7985f8822c 100644 --- a/Python/liddrivencavity/simulation.py +++ b/Python/liddrivencavity/simulation.py @@ -1,9 +1,9 @@ -from pyfluids import Simulation -from pyfluids.boundaryconditions import NoSlipBoundaryCondition, VelocityBoundaryCondition -from pyfluids.geometry import GbCuboid3D -from pyfluids.kernel import LBMKernel, KernelType -from pyfluids.parameters import GridParameters, PhysicalParameters, RuntimeParameters -from pyfluids.writer import Writer, OutputFormat +from pyfluids.cpu import Simulation +from pyfluids.cpu.boundaryconditions import NoSlipBoundaryCondition, VelocityBoundaryCondition +from pyfluids.cpu.geometry import GbCuboid3D +from pyfluids.cpu.kernel import LBMKernel, KernelType +from pyfluids.cpu.parameters import GridParameters, PhysicalParameters, RuntimeParameters +from pyfluids.cpu.writer import Writer, OutputFormat from pymuparser import Parser runtime_params = RuntimeParameters() diff --git a/Python/poiseuille/poiseuille_hpc.py b/Python/poiseuille/poiseuille_hpc.py index b9bf67531f3b760bacc1912dc39b57d8b594253c..f5f5a1387c9fe234abae0c6f979cc7d5b283d1a4 100644 --- a/Python/poiseuille/poiseuille_hpc.py +++ b/Python/poiseuille/poiseuille_hpc.py @@ -1,5 +1,5 @@ from poiseuille.simulation import run_simulation -from pyfluids.parameters import * +from pyfluids.cpu.parameters import * grid_parameters = GridParameters() grid_parameters.number_of_nodes_per_direction = [64, 64, 512] diff --git a/Python/poiseuille/simulation.py b/Python/poiseuille/simulation.py index 31ceb1ab9ef90fa4fd606bde4f47c45b8f7d7567..d107801fa84cfe16d1d7e91d31dc3ff4b8671f02 100644 --- a/Python/poiseuille/simulation.py +++ b/Python/poiseuille/simulation.py @@ -1,9 +1,9 @@ -from pyfluids import Simulation -from pyfluids.boundaryconditions import NoSlipBoundaryCondition -from pyfluids.geometry import GbCuboid3D, State -from pyfluids.kernel import LBMKernel, KernelType -from pyfluids.parameters import RuntimeParameters, GridParameters, PhysicalParameters -from pyfluids.writer import Writer, OutputFormat +from pyfluids.cpu import Simulation +from pyfluids.cpu.boundaryconditions import NoSlipBoundaryCondition +from pyfluids.cpu.geometry import GbCuboid3D, State +from pyfluids.cpu.kernel import LBMKernel, KernelType +from pyfluids.cpu.parameters import RuntimeParameters, GridParameters, PhysicalParameters +from pyfluids.cpu.writer import Writer, OutputFormat default_grid_params = GridParameters() default_grid_params.node_distance = 10 / 32 diff --git a/Python/poiseuille/test_poiseuille_l2.py b/Python/poiseuille/test_poiseuille_l2.py index 39c8b6dffe05e3c352e7fd340857e43d8d5a3dc8..93aa2600d5260dea7e72f3aa98db7334fe5285c6 100644 --- a/Python/poiseuille/test_poiseuille_l2.py +++ b/Python/poiseuille/test_poiseuille_l2.py @@ -5,8 +5,8 @@ import unittest import matplotlib.pyplot as plt import numpy as np import pyvista as pv -from pyfluids.kernel import LBMKernel, KernelType -from pyfluids.parameters import GridParameters, PhysicalParameters, RuntimeParameters +from pyfluids.cpu.kernel import LBMKernel, KernelType +from pyfluids.cpu.parameters import GridParameters, PhysicalParameters, RuntimeParameters from scipy import stats from errors import normalized_l2_error diff --git a/Python/tests/test_acousticscaling.py b/Python/tests/test_acousticscaling.py index 2da5314529f9559f9ac316f2d1bb3f1a9d0e1211..6413123a80db8c5882fcf1dbe6f72a1f5438736c 100644 --- a/Python/tests/test_acousticscaling.py +++ b/Python/tests/test_acousticscaling.py @@ -1,8 +1,8 @@ import unittest from typing import List -from pyfluids.kernel import LBMKernel, KernelType -from pyfluids.parameters import GridParameters, PhysicalParameters, RuntimeParameters +from pyfluids.cpu.kernel import LBMKernel, KernelType +from pyfluids.cpu.parameters import GridParameters, PhysicalParameters, RuntimeParameters from acousticscaling import OneDirectionalAcousticScaling diff --git a/Python/tests/test_boundaryconditions.py b/Python/tests/test_boundaryconditions.py index 5a7d61f36337398fc5621540951f15b72262b17b..e004ddfa21c78ea3d63a89f5dbc3bd7438a18ff1 100644 --- a/Python/tests/test_boundaryconditions.py +++ b/Python/tests/test_boundaryconditions.py @@ -1,5 +1,5 @@ import unittest -from pyfluids.boundaryconditions import * +from pyfluids.cpu.boundaryconditions import * class BoundaryConditionsTest(unittest.TestCase): diff --git a/Python/tests/test_geometry.py b/Python/tests/test_geometry.py index 5e953f58b4b24393ae3a8f2994184c9c7f27eca3..5bb89eb245b6055653b78fde381da050d402b0cc 100644 --- a/Python/tests/test_geometry.py +++ b/Python/tests/test_geometry.py @@ -1,6 +1,6 @@ import unittest -from pyfluids.geometry import * +from pyfluids.cpu.geometry import * class TestGeometry(unittest.TestCase): diff --git a/Python/tests/test_kernel.py b/Python/tests/test_kernel.py index b1016f15308a77c9025787e061355819cbca3874..8f58a1c869f9e292856268d43245a75f1dcfe213 100644 --- a/Python/tests/test_kernel.py +++ b/Python/tests/test_kernel.py @@ -1,6 +1,6 @@ import unittest -from pyfluids.kernel import LBMKernel, KernelType +from pyfluids.cpu.kernel import LBMKernel, KernelType class TestLBMKernel(unittest.TestCase): diff --git a/README.md b/README.md index b9d60ed3d1955f2fe0728ca92d8ec7f6b8846a06..e762a1fafb43cb0657a25c17ee7f9df770d4f600 100644 --- a/README.md +++ b/README.md @@ -3,32 +3,32 @@ VirtualFluids (VF) is a research code developed at the Institute for Computational Modeling in Civil Engineering (iRMB). The code is a Computational Fluid Dynamics (CFD) solver based on the Lattice Boltzmann Method (LBM) for turbulent, thermal, multiphase and multicomponent flow problems as well as for multi-field problems such as Fluid-Structure-interaction including distributed pre- and postprocessing capabilities for simulations with more than 100 billion degrees of freedom. ## Getting Start -### Suported Platforms -VirtualFluids has been used on a variety of platforms: +VirtualFluids is mainly supported on these two platforms: - Linux - - Mac OS X - Windows - - Cygwin + +VirtualFluids can also be build and used in a Docker image. An ubuntu development environment is located in the [container registry](https://git.rz.tu-bs.de/irmb/virtualfluids/container_registry). +An extensive guide about the usage and development in VirtualFluids with docker can be found [here](https://git.rz.tu-bs.de/irmb/virtualfluids/-/wikis/Getting-Start-with-the-development-of-VirtualFluids). + + +The following is a brief explanation of how to use it without Docker: ### Software Requirements - + - [CMake](https://cmake.org/) (minimum version 3.15) - C++ compiler with C++14 support - - [Paraview](https://www.paraview.org/) (most recent version) + - [Paraview](https://www.paraview.org/) for visualizations (most recent version) -with usage of the GPU: + +with usage of the GPU: - CUDA [developer.nvidia.com/cuda-zone](https://developer.nvidia.com/cuda-zone): * Minimum CUDA Version 9.0 * Minimum Compute Capability 3.0, because of maximal number of Blocks in x direction * Recommended Compute Capability 6.0, because of atomics for double precision floating point data (GKS only) - -### Contributing -To contribute to VirtualFluids please follow these [instructions](CONTRIBUTING.md). ### Build VirtualFluids ```shell -$ mkdir build -$ cd build +$ mkdir build && cd build ``` Pass the relevant [options](#options) to cmake. E.g. for the CPU part: @@ -41,11 +41,11 @@ Alternatively enable the options via the cmake-gui. ### <a id="options"></a> Options - BUILD_VF_CPU - Build VirtualFluids CPU variant -- BUILD_VF_GPU +- BUILD_VF_GPU - Build VirtualFluids GPU variant - BUILD_VF_UNIT_TESTS - Build VirtualFluids unit tests -- VF_DOUBLE_ACCURACY +- VF_DOUBLE_ACCURACY - GPU change between Double and Single Precision ### Result Files @@ -55,14 +55,15 @@ The CPU part generates a set of multiple output directories in the prescribed ou A GPU computation generates a the time series of output files directly in the output path. In Paraview these time series can be read directly. - +## Contributing +To contribute to VirtualFluids please follow these [instructions](CONTRIBUTING.md). ## Documentation The doxygen generated documentation can be found [here](https://irmb.gitlab-pages.rz.tu-bs.de/VirtualFluids_dev). ## Known Issues -If you notice any problems on your platform, please report an [issue](https://git.rz.tu-bs.de/irmb/virtualfluids/-/issues/new). +If you notice any problems on your platform, please report an [issue](https://git.rz.tu-bs.de/irmb/virtualfluids/-/issues/new). ## Authors diff --git a/apps/cpu/AcousticPulse/ap.cpp b/apps/cpu/AcousticPulse/ap.cpp index 3ce1b39e558f3dadc0cd024e05180103d87b2f21..77ddfbf626e25b8c5d17d438255e37b4977dbddd 100644 --- a/apps/cpu/AcousticPulse/ap.cpp +++ b/apps/cpu/AcousticPulse/ap.cpp @@ -10,7 +10,7 @@ void run() { try { - SPtr<Communicator> comm = MPICommunicator::getInstance(); + SPtr<vf::mpi::Communicator> comm = vf::mpi::MPICommunicator::getInstance(); int myid = comm->getProcessID(); int numOfThreads = 4; diff --git a/apps/cpu/BeadPack/beadpack.cpp b/apps/cpu/BeadPack/beadpack.cpp index 09980876882a1ceb2b555256ddf891cd00f08384..d683fc445359e6e2d19a7d6f72c59158d6bf7f98 100644 --- a/apps/cpu/BeadPack/beadpack.cpp +++ b/apps/cpu/BeadPack/beadpack.cpp @@ -23,7 +23,7 @@ void sbonepd(const char *configname) throw exceptionText; } - CommunicatorPtr comm = MPICommunicator::getInstance(); + CommunicatorPtr comm = vf::mpi::MPICommunicator::getInstance(); int myid = comm->getProcessID(); if (machine == "BOMBADIL") @@ -73,8 +73,8 @@ void sbonepd(const char *configname) LBMReal rho_LB = 0.0; //nueWasser = 1e-6 m^2/s double nu_real = 1e-6; - LBMReal dt = 5e-8; // s (frei gewählt) - //dx - frei gewählt + LBMReal dt = 5e-8; // s (frei gew�hlt) + //dx - frei gew�hlt // LBMReal nu_LB = nu_real / (dx*dx / dt); diff --git a/apps/cpu/BoxBenchmark/bb.cpp b/apps/cpu/BoxBenchmark/bb.cpp index 719df7738df87e2b310aa03332fb2a3ef8f2ffe6..7d5c0ec2f4fdf4627b87a32727925f62a3bc89e9 100644 --- a/apps/cpu/BoxBenchmark/bb.cpp +++ b/apps/cpu/BoxBenchmark/bb.cpp @@ -37,7 +37,7 @@ void run(string configname) //UbLog::reportingLevel() = UbLog::logLevelFromString("DEBUG3"); - SPtr<Communicator> comm = MPICommunicator::getInstance(); + SPtr<vf::mpi::Communicator> comm = vf::mpi::MPICommunicator::getInstance(); int myid = comm->getProcessID(); if (logToFile) diff --git a/apps/cpu/CheckpointConverter/cpc.cpp b/apps/cpu/CheckpointConverter/cpc.cpp index c26e7df4c682e1c5214d15644c57d52ac7d8413a..4eb526cc75be39153f61cbc4d599a21bcc5394b4 100644 --- a/apps/cpu/CheckpointConverter/cpc.cpp +++ b/apps/cpu/CheckpointConverter/cpc.cpp @@ -17,7 +17,7 @@ void run(string configname) int step = config.getValue<int>("step"); int numberOfProcesses = config.getValue<int>("numberOfProcesses"); - SPtr<Communicator> comm = MPICommunicator::getInstance(); + SPtr<vf::mpi::Communicator> comm = vf::mpi::MPICommunicator::getInstance(); int myid = comm->getProcessID(); SPtr<Grid3D> grid(new Grid3D(comm)); diff --git a/apps/cpu/ConvectionOfVortex/cov.cpp b/apps/cpu/ConvectionOfVortex/cov.cpp index 2782060b9d68f2673e840ec4b882b0a66544c564..4e1f592b896c21da5bc6bc59f3b2bfb584650374 100644 --- a/apps/cpu/ConvectionOfVortex/cov.cpp +++ b/apps/cpu/ConvectionOfVortex/cov.cpp @@ -10,7 +10,7 @@ void run() { try { - SPtr<Communicator> comm = MPICommunicator::getInstance(); + SPtr<vf::mpi::Communicator> comm = vf::mpi::MPICommunicator::getInstance(); int myid = comm->getProcessID(); int numOfThreads = 4; diff --git a/apps/cpu/CouetteFlow/cflow.cpp b/apps/cpu/CouetteFlow/cflow.cpp index e37bafade742c42601fdeb66cfa45ca516097ff3..276fbe125b5b3cd0271542f7e9d8ab9f9abca518 100644 --- a/apps/cpu/CouetteFlow/cflow.cpp +++ b/apps/cpu/CouetteFlow/cflow.cpp @@ -37,7 +37,7 @@ void bflow(string configname) // double Re = config.getValue<double>("Re"); // double Bn = config.getValue<double>("Bn"); - SPtr<Communicator> comm = MPICommunicator::getInstance(); + SPtr<vf::mpi::Communicator> comm = vf::mpi::MPICommunicator::getInstance(); int myid = comm->getProcessID(); if (logToFile) diff --git a/apps/cpu/DHIT/dhit.cpp b/apps/cpu/DHIT/dhit.cpp index 957c823ef664e4dd19df45fa322e93a8c8164bb7..850a531a9ac490ed195ad17ce298ca5cf027151a 100644 --- a/apps/cpu/DHIT/dhit.cpp +++ b/apps/cpu/DHIT/dhit.cpp @@ -29,7 +29,7 @@ void run(string configname) double lambda = config.getDouble("lambda"); double initTime = config.getDouble("initTime"); - SPtr<Communicator> comm = MPICommunicator::getInstance(); + SPtr<vf::mpi::Communicator> comm = vf::mpi::MPICommunicator::getInstance(); int myid = comm->getProcessID(); if (logToFile) diff --git a/apps/cpu/DLR-F16-Porous/f16.cpp b/apps/cpu/DLR-F16-Porous/f16.cpp index 9197aca45bbfed9be817fbcb83db4973e4a58f87..7ddd135b2996c794e2802e235fdedc2a3013cdf3 100644 --- a/apps/cpu/DLR-F16-Porous/f16.cpp +++ b/apps/cpu/DLR-F16-Porous/f16.cpp @@ -95,7 +95,7 @@ void run(string configname) - SPtr<Communicator> comm = MPICommunicator::getInstance(); + SPtr<vf::mpi::Communicator> comm = vf::mpi::MPICommunicator::getInstance(); int myid = comm->getProcessID(); if (logToFile) diff --git a/apps/cpu/DLR-F16-Solid/f16.cpp b/apps/cpu/DLR-F16-Solid/f16.cpp index d88b650b143793b67388f920bd2e23c380af0e5a..328da5dc54b5a2db751eb71ad1ce8810cb471470 100644 --- a/apps/cpu/DLR-F16-Solid/f16.cpp +++ b/apps/cpu/DLR-F16-Solid/f16.cpp @@ -47,7 +47,7 @@ void run(string configname) double timeAvStart = config.getValue<double>("timeAvStart"); double timeAvStop = config.getValue<double>("timeAvStop"); - SPtr<Communicator> comm = MPICommunicator::getInstance(); + SPtr<vf::mpi::Communicator> comm = vf::mpi::MPICommunicator::getInstance(); int myid = comm->getProcessID(); if (logToFile) diff --git a/apps/cpu/DLR-F16/f16.cpp b/apps/cpu/DLR-F16/f16.cpp index 523a9c7c09795627d43de8b119597e52caf4d5b0..2bbc1b8ed63be110d4b6ccc98cdcdb88337d4760 100644 --- a/apps/cpu/DLR-F16/f16.cpp +++ b/apps/cpu/DLR-F16/f16.cpp @@ -13,7 +13,7 @@ double rangeRandom1() void setBC(SPtr<Grid3D> grid, string pathGeo, string fngFileWhole, string zigZagTape, vector<double> boundingBox, double uLB, double rhoLB, double blockLength, SPtr<BCProcessor> bcProcessor) { - SPtr<Communicator> comm = MPICommunicator::getInstance(); + SPtr<vf::mpi::Communicator> comm = vf::mpi::MPICommunicator::getInstance(); int myid = comm->getProcessID(); std::vector<std::vector<SPtr<Block3D>> > blockVector; @@ -205,7 +205,7 @@ void run(string configname) int chunk = config.getValue<int>("chunk"); - SPtr<Communicator> comm = MPICommunicator::getInstance(); + SPtr<vf::mpi::Communicator> comm = vf::mpi::MPICommunicator::getInstance(); int myid = comm->getProcessID(); if (logToFile) diff --git a/apps/cpu/FlowAroundCylinder/cylinder.cpp b/apps/cpu/FlowAroundCylinder/cylinder.cpp index 81bfd5ff3658d41e29ab6f56590119de7db3fe82..2f470d17dbac3600b2c42acede2bba9e6c45f872 100644 --- a/apps/cpu/FlowAroundCylinder/cylinder.cpp +++ b/apps/cpu/FlowAroundCylinder/cylinder.cpp @@ -33,7 +33,7 @@ void run(string configname) vector<int> blockNx = config.getVector<int>("blockNx"); double dx = config.getValue<double>("dx"); - SPtr<Communicator> comm = MPICommunicator::getInstance(); + SPtr<vf::mpi::Communicator> comm = vf::mpi::MPICommunicator::getInstance(); int myid = comm->getProcessID(); if (logToFile) diff --git a/apps/cpu/FlowAroundCylinder/cylinder.cpp.old b/apps/cpu/FlowAroundCylinder/cylinder.cpp.old index 7293ab62fcbe0e43511df29b995aa82c2be37ca5..f251ee63514c67cca6df0e998cc196d3cc5a9ec8 100644 --- a/apps/cpu/FlowAroundCylinder/cylinder.cpp.old +++ b/apps/cpu/FlowAroundCylinder/cylinder.cpp.old @@ -15,7 +15,7 @@ void run(const char *cstr) int numOfThreads = 1; double availMem = 0; - CommunicatorPtr comm = MPICommunicator::getInstance(); + CommunicatorPtr comm = vf::mpi::MPICommunicator::getInstance(); int myid = comm->getProcessID(); if(machine == "BOMBADIL") @@ -385,7 +385,7 @@ void run2(const char *cstr) int numOfThreads = 1; double availMem = 0; - CommunicatorPtr comm = MPICommunicator::getInstance(); + CommunicatorPtr comm = vf::mpi::MPICommunicator::getInstance(); int myid = comm->getProcessID(); if(machine == "BOMBADIL") diff --git a/apps/cpu/Hagen_Poiseuille_flow/pflow.cpp b/apps/cpu/Hagen_Poiseuille_flow/pflow.cpp index 05f6c625be6ffe4cd56a673eb44a62e6c59d5ce0..074e8c3aa9b338fa00db0718862d20c7e99f5e55 100644 --- a/apps/cpu/Hagen_Poiseuille_flow/pflow.cpp +++ b/apps/cpu/Hagen_Poiseuille_flow/pflow.cpp @@ -29,7 +29,7 @@ using namespace std; // double deltax = config.getDouble("deltax"); // // -// SPtr<Communicator> comm = MPICommunicator::getInstance(); +// SPtr<vf::mpi::Communicator> comm = vf::mpi::MPICommunicator::getInstance(); // int myid = comm->getProcessID(); // // if (logToFile) @@ -322,7 +322,7 @@ void pflowdp(string configname) double cpStepStart = config.getValue<double>("cpStepStart"); bool newStart = config.getValue<bool>("newStart"); - SPtr<Communicator> comm = MPICommunicator::getInstance(); + SPtr<vf::mpi::Communicator> comm = vf::mpi::MPICommunicator::getInstance(); int myid = comm->getProcessID(); LBMReal rhoLB = 0.0; diff --git a/apps/cpu/Hagen_Poiseuille_flow2/pflow2.cpp b/apps/cpu/Hagen_Poiseuille_flow2/pflow2.cpp index 5bcf21ed9596ce6d8d6bce9974b98627c007168d..40bf20ecabe23637b6271edd6ac6c4fd951f4760 100644 --- a/apps/cpu/Hagen_Poiseuille_flow2/pflow2.cpp +++ b/apps/cpu/Hagen_Poiseuille_flow2/pflow2.cpp @@ -29,7 +29,7 @@ void pflowdp(string configname) double deltax = config.getValue<double>("deltax"); - SPtr<Communicator> comm = MPICommunicator::getInstance(); + SPtr<vf::mpi::Communicator> comm = vf::mpi::MPICommunicator::getInstance(); int myid = comm->getProcessID(); LBMReal rhoLB = 0.0; diff --git a/apps/cpu/HerschelBulkleyModel/hbflow.cpp b/apps/cpu/HerschelBulkleyModel/hbflow.cpp index 976635bdea0823f6e4cdef208f06d98499e0eabf..8483883aca772693758b9f52fcee53c54b84a1d5 100644 --- a/apps/cpu/HerschelBulkleyModel/hbflow.cpp +++ b/apps/cpu/HerschelBulkleyModel/hbflow.cpp @@ -38,7 +38,7 @@ void bflow(string configname) // double Bn = config.getValue<double>("Bn"); double scaleFactor = config.getValue<double>("scaleFactor"); - SPtr<Communicator> comm = MPICommunicator::getInstance(); + SPtr<vf::mpi::Communicator> comm = vf::mpi::MPICommunicator::getInstance(); int myid = comm->getProcessID(); if (logToFile) diff --git a/apps/cpu/HerschelBulkleySphere/hbsphere.cpp b/apps/cpu/HerschelBulkleySphere/hbsphere.cpp index eff2c2c628995b34f00650d310275d186d38f2fc..d86424869d5598adb2dfa61c1da2f6590bd79401 100644 --- a/apps/cpu/HerschelBulkleySphere/hbsphere.cpp +++ b/apps/cpu/HerschelBulkleySphere/hbsphere.cpp @@ -35,7 +35,7 @@ void bflow(string configname) double Bn = config.getValue<double>("Bn"); vector<double> sphereCenter = config.getVector<double>("sphereCenter"); - SPtr<Communicator> comm = MPICommunicator::getInstance(); + SPtr<vf::mpi::Communicator> comm = vf::mpi::MPICommunicator::getInstance(); int myid = comm->getProcessID(); if (logToFile) diff --git a/apps/cpu/InterfaceTest/itest.cpp b/apps/cpu/InterfaceTest/itest.cpp index 104305be9e8f0fde44bb8d5f129fb3a55786b70a..face949bd7d68c8d4fe94d7e32dc728b7818f42f 100644 --- a/apps/cpu/InterfaceTest/itest.cpp +++ b/apps/cpu/InterfaceTest/itest.cpp @@ -11,7 +11,7 @@ void run() { try { - SPtr<Communicator> comm = MPICommunicator::getInstance(); + SPtr<vf::mpi::Communicator> comm = vf::mpi::MPICommunicator::getInstance(); int myid = comm->getProcessID(); int numOfThreads = 4; diff --git a/apps/cpu/JetBreakup/JetBreakup.cpp b/apps/cpu/JetBreakup/JetBreakup.cpp index d6cff6366a00a65983ee67075f99d8ca2c9e1ff9..eb7d705537e4307e4ca1066ac9d06dafb72449f4 100644 --- a/apps/cpu/JetBreakup/JetBreakup.cpp +++ b/apps/cpu/JetBreakup/JetBreakup.cpp @@ -51,7 +51,7 @@ void run(string configname) double beta = 12 * sigma / interfaceThickness; double kappa = 1.5 * interfaceThickness * sigma; - CommunicatorPtr comm = MPICommunicator::getInstance(); + CommunicatorPtr comm = vf::mpi::MPICommunicator::getInstance(); int myid = comm->getProcessID(); if (logToFile) diff --git a/apps/cpu/LaminarTubeFlow/ltf.cpp b/apps/cpu/LaminarTubeFlow/ltf.cpp index c2c3866fc11b404acb3c571450f86d8ce07a4b2f..c8951903084ccacf208718f25948206b1c98c1ab 100644 --- a/apps/cpu/LaminarTubeFlow/ltf.cpp +++ b/apps/cpu/LaminarTubeFlow/ltf.cpp @@ -31,7 +31,7 @@ void run(string configname) double cpStep = config.getValue<double>("cpStep"); bool newStart = config.getValue<bool>("newStart"); - SPtr<Communicator> comm = MPICommunicator::getInstance(); + SPtr<vf::mpi::Communicator> comm = vf::mpi::MPICommunicator::getInstance(); int myid = comm->getProcessID(); if (logToFile) @@ -49,6 +49,8 @@ void run(string configname) stringstream logFilename; logFilename << pathname + "/logfile" + UbSystem::toString(UbSystem::getTimeStamp()) + ".txt"; UbLog::output_policy::setStream(logFilename.str()); + + vf::logging::Logger::changeLogPath(pathname); } } @@ -143,12 +145,12 @@ void run(string configname) if (myid == 0) { - UBLOG(logINFO, "uLb = " << uLB); - UBLOG(logINFO, "rho = " << rhoLB); - UBLOG(logINFO, "nuLb = " << nuLB); - UBLOG(logINFO, "Re = " << Re); - UBLOG(logINFO, "dx = " << dx); - UBLOG(logINFO, "Preprocess - start"); + VF_LOG_INFO("uLb = {}", uLB); + VF_LOG_INFO("rho = {}", rhoLB); + VF_LOG_INFO("nuLb = {}", nuLB); + VF_LOG_INFO("Re = {}", Re); + VF_LOG_INFO("dx = {}", dx); + VF_LOG_INFO("Preprocess - start"); } grid->setDeltaX(dx); @@ -232,19 +234,19 @@ void run(string configname) if (myid == 0) { - UBLOG(logINFO, "Number of blocks = " << numberOfBlocks); - UBLOG(logINFO, "Number of nodes = " << numberOfNodes); + VF_LOG_INFO("Number of blocks = {}", numberOfBlocks); + VF_LOG_INFO("Number of nodes = {}", numberOfNodes); int minInitLevel = grid->getCoarsestInitializedLevel(); int maxInitLevel = grid->getFinestInitializedLevel(); for (int level = minInitLevel; level <= maxInitLevel; level++) { int nobl = grid->getNumberOfBlocks(level); - UBLOG(logINFO, "Number of blocks for level " << level << " = " << nobl); - UBLOG(logINFO, "Number of nodes for level " << level << " = " << nobl*numberOfNodesPerBlock); + VF_LOG_INFO("Number of blocks for level {} = {}", level, nobl); + VF_LOG_INFO("Number of nodes for level {} = {}", level, nobl*numberOfNodesPerBlock); } - UBLOG(logINFO, "Necessary memory = " << needMemAll << " bytes"); - UBLOG(logINFO, "Necessary memory per process = " << needMem << " bytes"); - UBLOG(logINFO, "Available memory per process = " << availMem << " bytes"); + VF_LOG_INFO("Necessary memory = {} bytes", needMemAll); + VF_LOG_INFO("Necessary memory per process = {} bytes", needMem); + VF_LOG_INFO("Available memory per process = {} bytes", availMem); } SetKernelBlockVisitor kernelVisitor(kernel, nuLB, availMem, needMem); @@ -275,27 +277,27 @@ void run(string configname) ppgeo.reset(); } - if (myid == 0) UBLOG(logINFO, "Preprocess - end"); + if (myid == 0) VF_LOG_INFO("Preprocess - end"); } else { if (myid == 0) { - UBLOG(logINFO, "Parameters:"); - UBLOG(logINFO, "uLb = " << uLB); - UBLOG(logINFO, "rho = " << rhoLB); - UBLOG(logINFO, "nuLb = " << nuLB); - UBLOG(logINFO, "Re = " << Re); - UBLOG(logINFO, "dx = " << dx); - UBLOG(logINFO, "number of levels = " << refineLevel + 1); - UBLOG(logINFO, "numOfThreads = " << numOfThreads); - UBLOG(logINFO, "path = " << pathname); + VF_LOG_INFO("Parameters:"); + VF_LOG_INFO("uLb = {}", uLB); + VF_LOG_INFO("rho = {}", rhoLB); + VF_LOG_INFO("nuLb = {}", nuLB); + VF_LOG_INFO("Re = {}", Re); + VF_LOG_INFO("dx = {}", dx); + VF_LOG_INFO("number of levels = {}", refineLevel + 1); + VF_LOG_INFO("numOfThreads = {}", numOfThreads); + VF_LOG_INFO("path = {}", pathname); } migCoProcessor->restart((int)restartStep); grid->setTimeStep(restartStep); - if (myid == 0) UBLOG(logINFO, "Restart - end"); + if (myid == 0) VF_LOG_INFO("Restart - end"); } OneDistributionSetConnectorsBlockVisitor setConnsVisitor(comm); @@ -324,10 +326,9 @@ void run(string configname) calculator->addCoProcessor(migCoProcessor); calculator->addCoProcessor(timeDepBC); - if (myid == 0) UBLOG(logINFO, "Simulation-start"); + if (myid == 0) VF_LOG_INFO("Simulation-start"); calculator->calculate(); - if (myid == 0) - UBLOG(logINFO, "Simulation-end"); + if (myid == 0) VF_LOG_INFO("Simulation-end"); } catch (std::exception& e) { @@ -343,19 +344,23 @@ void run(string configname) } } -int main(int /*argc*/, char* argv[]) + + +int main(int argc, char *argv[]) { - if (argv != NULL) - { - if (argv[1] != NULL) - { - run(string(argv[1])); - } - else - { - cout << "Configuration file is missing!" << endl; - } - } + try { + vf::logging::Logger::initalizeLogger(); -} + VF_LOG_INFO("Starting VirtualFluids..."); + if (argc > 1) + run(std::string(argv[1])); + else + VF_LOG_CRITICAL("Configuration file is missing!"); + + VF_LOG_INFO("VirtualFluids is finished."); + + } catch (const spdlog::spdlog_ex &ex) { + std::cout << "Log initialization failed: " << ex.what() << std::endl; + } +} diff --git a/apps/cpu/LaminarTubeFlowConv/ltf.cpp b/apps/cpu/LaminarTubeFlowConv/ltf.cpp index 6c20cdea96b775b9ae3314daa628c26774c30788..53cd7c1ac7900118f47e483f867d22de2e3e7974 100644 --- a/apps/cpu/LaminarTubeFlowConv/ltf.cpp +++ b/apps/cpu/LaminarTubeFlowConv/ltf.cpp @@ -30,7 +30,7 @@ void run(int tn) int numOfThreads = 1; double availMem = 0; - CommunicatorPtr comm = MPICommunicator::getInstance(); + CommunicatorPtr comm = vf::mpi::MPICommunicator::getInstance(); int myid = comm->getProcessID(); if(machine == "BOMBADIL") diff --git a/apps/cpu/LidDrivenCavity/LidDrivenCavity.cpp b/apps/cpu/LidDrivenCavity/LidDrivenCavity.cpp index 104d487b905c03901ffa3ecc24f2f34b44cffe5e..1819ee0f6fe00191f28ddfcab8cce93466047289 100644 --- a/apps/cpu/LidDrivenCavity/LidDrivenCavity.cpp +++ b/apps/cpu/LidDrivenCavity/LidDrivenCavity.cpp @@ -80,7 +80,7 @@ int main(int /*argc*/, char* /*argv*/[]) double g_maxX3 = 0.5; // NullCommunicator is a place-holder for interprocess communication - SPtr<Communicator> comm = NullCommunicator::getInstance(); + SPtr<vf::mpi::Communicator> comm = NullCommunicator::getInstance(); // new grid object SPtr<Grid3D> grid(new Grid3D(comm)); // set grid spacing diff --git a/apps/cpu/Multiphase/Multiphase (Droplet Test).cpp.backup b/apps/cpu/Multiphase/Multiphase (Droplet Test).cpp.backup index 389b754f848e8886140113310572686a9efd908b..533fb619c2bb82783b99110894079594b5ddba47 100644 --- a/apps/cpu/Multiphase/Multiphase (Droplet Test).cpp.backup +++ b/apps/cpu/Multiphase/Multiphase (Droplet Test).cpp.backup @@ -51,7 +51,7 @@ void run(string configname) double beta = 12*sigma/interfaceThickness; double kappa = 1.5*interfaceThickness*sigma; - CommunicatorPtr comm = MPICommunicator::getInstance(); + CommunicatorPtr comm = vf::mpi::MPICommunicator::getInstance(); int myid = comm->getProcessID(); if (logToFile) diff --git a/apps/cpu/Multiphase/Multiphase (Jet breakup on Phoenix).cpp.backup b/apps/cpu/Multiphase/Multiphase (Jet breakup on Phoenix).cpp.backup index 1adc07f8b293327e9bf814d82ebcca8b8aa91d44..954d4b539411adb36ea47724ab612fcd8d70be87 100644 --- a/apps/cpu/Multiphase/Multiphase (Jet breakup on Phoenix).cpp.backup +++ b/apps/cpu/Multiphase/Multiphase (Jet breakup on Phoenix).cpp.backup @@ -51,7 +51,7 @@ void run(string configname) double beta = 12*sigma/interfaceThickness; double kappa = 1.5*interfaceThickness*sigma; - CommunicatorPtr comm = MPICommunicator::getInstance(); + CommunicatorPtr comm = vf::mpi::MPICommunicator::getInstance(); int myid = comm->getProcessID(); if (logToFile) diff --git a/apps/cpu/Multiphase/Multiphase.cpp b/apps/cpu/Multiphase/Multiphase.cpp index 77bcfd0c00a4f2d6050de7dfb58a2c923b5d2ce4..9fd7110f25bddb2f23ef550bbb9a7c0754fab9d8 100644 --- a/apps/cpu/Multiphase/Multiphase.cpp +++ b/apps/cpu/Multiphase/Multiphase.cpp @@ -52,7 +52,7 @@ void run(string configname) double beta = 12 * sigma / interfaceThickness; double kappa = 1.5 * interfaceThickness * sigma; - SPtr<Communicator> comm = MPICommunicator::getInstance(); + SPtr<vf::mpi::Communicator> comm = vf::mpi::MPICommunicator::getInstance(); int myid = comm->getProcessID(); if (myid == 0) diff --git a/apps/cpu/Multiphase/backup/Multiphase (Droplet Test).cpp b/apps/cpu/Multiphase/backup/Multiphase (Droplet Test).cpp index 18989d3601729dcc663f707bc21e3a7f91a57dfd..3362f66d5b07d1b94fd6c2623af58011ae425905 100644 --- a/apps/cpu/Multiphase/backup/Multiphase (Droplet Test).cpp +++ b/apps/cpu/Multiphase/backup/Multiphase (Droplet Test).cpp @@ -51,7 +51,7 @@ void run(string configname) double beta = 12*sigma/interfaceThickness; double kappa = 1.5*interfaceThickness*sigma; - CommunicatorPtr comm = MPICommunicator::getInstance(); + CommunicatorPtr comm = vf::mpi::MPICommunicator::getInstance(); int myid = comm->getProcessID(); if (logToFile) diff --git a/apps/cpu/Multiphase/backup/Multiphase (Final before automation).cpp b/apps/cpu/Multiphase/backup/Multiphase (Final before automation).cpp index b6160314eb87c785443602a4c5eb35ca16ebc02b..5ed66edace35c61fa3244c445fa479db13ccec8f 100644 --- a/apps/cpu/Multiphase/backup/Multiphase (Final before automation).cpp +++ b/apps/cpu/Multiphase/backup/Multiphase (Final before automation).cpp @@ -67,7 +67,7 @@ void run(string configname) double beta = 12*sigma/interfaceThickness; double kappa = 1.5*interfaceThickness*sigma; - CommunicatorPtr comm = MPICommunicator::getInstance(); + CommunicatorPtr comm = vf::mpi::MPICommunicator::getInstance(); int myid = comm->getProcessID(); if (logToFile) diff --git a/apps/cpu/Multiphase/backup/Multiphase (Flow Focusing).cpp b/apps/cpu/Multiphase/backup/Multiphase (Flow Focusing).cpp index 11e064e30a210485aabd40c40ee925e3acf56922..a6355a2aa56e0bd85d919250e750427df7662284 100644 --- a/apps/cpu/Multiphase/backup/Multiphase (Flow Focusing).cpp +++ b/apps/cpu/Multiphase/backup/Multiphase (Flow Focusing).cpp @@ -51,7 +51,7 @@ void run(string configname) double beta = 12*sigma/interfaceThickness; double kappa = 1.5*interfaceThickness*sigma; - CommunicatorPtr comm = MPICommunicator::getInstance(); + CommunicatorPtr comm = vf::mpi::MPICommunicator::getInstance(); int myid = comm->getProcessID(); if (logToFile) diff --git a/apps/cpu/Multiphase/backup/Multiphase (Jet breakup on Phoenix).cpp b/apps/cpu/Multiphase/backup/Multiphase (Jet breakup on Phoenix).cpp index 1adc07f8b293327e9bf814d82ebcca8b8aa91d44..954d4b539411adb36ea47724ab612fcd8d70be87 100644 --- a/apps/cpu/Multiphase/backup/Multiphase (Jet breakup on Phoenix).cpp +++ b/apps/cpu/Multiphase/backup/Multiphase (Jet breakup on Phoenix).cpp @@ -51,7 +51,7 @@ void run(string configname) double beta = 12*sigma/interfaceThickness; double kappa = 1.5*interfaceThickness*sigma; - CommunicatorPtr comm = MPICommunicator::getInstance(); + CommunicatorPtr comm = vf::mpi::MPICommunicator::getInstance(); int myid = comm->getProcessID(); if (logToFile) diff --git a/apps/cpu/Multiphase/backup/Multiphase (T-Junction).cpp b/apps/cpu/Multiphase/backup/Multiphase (T-Junction).cpp index 2f3e94e7acf42de01826e0aac1daff2689d04acb..1af6f9a19754035d1e4cc1466d80fa0d77de52c7 100644 --- a/apps/cpu/Multiphase/backup/Multiphase (T-Junction).cpp +++ b/apps/cpu/Multiphase/backup/Multiphase (T-Junction).cpp @@ -51,7 +51,7 @@ void run(string configname) double beta = 12*sigma/interfaceThickness; double kappa = 1.5*interfaceThickness*sigma; - CommunicatorPtr comm = MPICommunicator::getInstance(); + CommunicatorPtr comm = vf::mpi::MPICommunicator::getInstance(); int myid = comm->getProcessID(); if (logToFile) diff --git a/apps/cpu/Multiphase/backup/Multiphase (Thermal).cpp b/apps/cpu/Multiphase/backup/Multiphase (Thermal).cpp index a61d7b7541f05e66eab79f0e5bf1f4e91325632f..51ba4463a32740f8b2e07391d1ab174ccb9e7095 100644 --- a/apps/cpu/Multiphase/backup/Multiphase (Thermal).cpp +++ b/apps/cpu/Multiphase/backup/Multiphase (Thermal).cpp @@ -51,7 +51,7 @@ void run(string configname) double beta = 12*sigma/interfaceThickness; double kappa = 1.5*interfaceThickness*sigma; - CommunicatorPtr comm = MPICommunicator::getInstance(); + CommunicatorPtr comm = vf::mpi::MPICommunicator::getInstance(); int myid = comm->getProcessID(); if (logToFile) diff --git a/apps/cpu/Multiphase/backup/Multiphase (Tube).cpp b/apps/cpu/Multiphase/backup/Multiphase (Tube).cpp index 7febd0cf18d80039af1fc284612789321b21e6b6..7e6dfd24a1ba90420891de57a7ba399d5c860e7d 100644 --- a/apps/cpu/Multiphase/backup/Multiphase (Tube).cpp +++ b/apps/cpu/Multiphase/backup/Multiphase (Tube).cpp @@ -42,7 +42,7 @@ void run(string configname) double beta = 12*sigma/interfaceThickness; double kappa = 1.5*interfaceThickness*sigma; - CommunicatorPtr comm = MPICommunicator::getInstance(); + CommunicatorPtr comm = vf::mpi::MPICommunicator::getInstance(); int myid = comm->getProcessID(); if (logToFile) diff --git a/apps/cpu/Multiphase/backup/Multiphase.cpp b/apps/cpu/Multiphase/backup/Multiphase.cpp index df4c311d8de62ce79aa337af19561b510b859d79..8b09c15f4f5eb829ca37fce160bbb86ebb92f19d 100644 --- a/apps/cpu/Multiphase/backup/Multiphase.cpp +++ b/apps/cpu/Multiphase/backup/Multiphase.cpp @@ -78,7 +78,7 @@ void run(string configname) double beta = 12*sigma/interfaceThickness; double kappa = 1.5*interfaceThickness*sigma; - CommunicatorPtr comm = MPICommunicator::getInstance(); + CommunicatorPtr comm = vf::mpi::MPICommunicator::getInstance(); int myid = comm->getProcessID(); if (logToFile) diff --git a/apps/cpu/MultiphaseDropletTest/droplet.cpp b/apps/cpu/MultiphaseDropletTest/droplet.cpp index 829ad38628665cbe006e7f9b88cb63b8ea362472..fe27ecce81cd97215600b54d613e7123cb80f261 100644 --- a/apps/cpu/MultiphaseDropletTest/droplet.cpp +++ b/apps/cpu/MultiphaseDropletTest/droplet.cpp @@ -45,7 +45,7 @@ void run(string configname) double beta = 12 * sigma / interfaceThickness; double kappa = 1.5 * interfaceThickness * sigma; - SPtr<Communicator> comm = MPICommunicator::getInstance(); + SPtr<vf::mpi::Communicator> comm = vf::mpi::MPICommunicator::getInstance(); int myid = comm->getProcessID(); if (myid == 0) diff --git a/apps/cpu/OrganPipe/OrganPipe.cpp b/apps/cpu/OrganPipe/OrganPipe.cpp index 8ad094bc9cc8db392eac1f7926365a9dca2586c6..ad6ec5a1d0892b60f699b74ee4101a9f4ad047e3 100644 --- a/apps/cpu/OrganPipe/OrganPipe.cpp +++ b/apps/cpu/OrganPipe/OrganPipe.cpp @@ -8,7 +8,7 @@ void run(string configname) { try { - SPtr<Communicator> comm = MPICommunicator::getInstance(); + SPtr<vf::mpi::Communicator> comm = vf::mpi::MPICommunicator::getInstance(); int myid = comm->getProcessID(); if (myid == 0) UBLOG(logINFO, "Testcase organ pipe"); diff --git a/apps/cpu/PlateWithPorousInlay/plate.cpp b/apps/cpu/PlateWithPorousInlay/plate.cpp index 60531c9ae960eec48264d3876395a5edc69bc499..315bacfa954640c8963ef46c3a7c840280a69e06 100644 --- a/apps/cpu/PlateWithPorousInlay/plate.cpp +++ b/apps/cpu/PlateWithPorousInlay/plate.cpp @@ -52,7 +52,7 @@ void run(const char *cstr) stringstream logFilename; double availMem = 0; - CommunicatorPtr comm = MPICommunicator::getInstance(); + CommunicatorPtr comm = vf::mpi::MPICommunicator::getInstance(); int myid = comm->getProcessID(); string machine = string(cstr); @@ -118,9 +118,9 @@ void run(const char *cstr) ///////////////Knotenabmessungen: int nx[3], blocknx[3]; - nx[0] = 90;//240;//120;//60;//86;//43;//65;//50; //länge + nx[0] = 90;//240;//120;//60;//86;//43;//65;//50; //l�nge nx[1] = 2;//2;//6;///1;//5;// //breite - nx[2] = 30;//64;//32;//18;//5;//15;//15; //höhe gebiet + nx[2] = 30;//64;//32;//18;//5;//15;//15; //h�he gebiet blocknx[0] = 16;//10;//6; blocknx[1] = 16;//10;//6; blocknx[2] = 16;//10;//6; @@ -128,11 +128,11 @@ void run(const char *cstr) int baseLevel = 0; int refineLevel = 5; - double H = 600.0; // Kanalhöhe [mm] + double H = 600.0; // Kanalh�he [mm] double cdx = H / (double)(nx[2] * blocknx[2]); double fdx = cdx / double(1 << refineLevel); - //double h = 200.0; // gewünschte Plattenhöhe in Gitterpunkten + //double h = 200.0; // gew�nschte Plattenh�he in Gitterpunkten //double fdx = plate->getLengthX3()/h; //double cdx = fdx*double(1<<refineLevel); @@ -147,7 +147,7 @@ void run(const char *cstr) // Re = 1000000 // V = 16.05 # m / s // p = 994.7 #hPa(manuell abgelesen von MUB) - // T = 21.78 #°C + // T = 21.78 #�C // Luftfeuchte = 50.5 # % ////////////////////////////////////////////////////////////////////////// // Simulation Parametr @@ -155,7 +155,7 @@ void run(const char *cstr) double Re = 1e6; // 1133333.3333333335; double rhoLB = 0.0; double uLB = 0.1; - double lReal = 1000; //Plattenlänge in mm + double lReal = 1000; //Plattenl�nge in mm double nuLB = (uLB*(lReal / cdx)) / Re; int sizeSP = 4; diff --git a/apps/cpu/PoiseuilleFlow/pf1.cpp b/apps/cpu/PoiseuilleFlow/pf1.cpp index 3880e9583dd07bdad7fcd11272f0a372155ef654..4e4d87ecc797db7545b2dae84e1f76220a02cc33 100644 --- a/apps/cpu/PoiseuilleFlow/pf1.cpp +++ b/apps/cpu/PoiseuilleFlow/pf1.cpp @@ -7,7 +7,7 @@ using namespace std; //pipe flow with forcing void pf1() { - SPtr<Communicator> comm = MPICommunicator::getInstance(); + SPtr<vf::mpi::Communicator> comm = vf::mpi::MPICommunicator::getInstance(); int myid = comm->getProcessID(); //parameters diff --git a/apps/cpu/PoiseuilleFlow/pf2.cpp b/apps/cpu/PoiseuilleFlow/pf2.cpp index addb56c279c8fbddd51b6c03ac514014c9c33423..f312bc37dacc3caadd9935f450cdcf808c945b4f 100644 --- a/apps/cpu/PoiseuilleFlow/pf2.cpp +++ b/apps/cpu/PoiseuilleFlow/pf2.cpp @@ -6,7 +6,7 @@ ////pipe flow with pressure drop //void pf2() //{ -// SPtr<Communicator> comm = MPICommunicator::getInstance(); +// SPtr<vf::mpi::Communicator> comm = vf::mpi::MPICommunicator::getInstance(); // int myid = comm->getProcessID(); // // //parameters diff --git a/apps/cpu/PoiseuilleFlow/pf3.cpp b/apps/cpu/PoiseuilleFlow/pf3.cpp index a2bcd1edcf49cd0245853feed5e16e102932ca95..a2eca67d593fd9e21641e99bd3910e4c775f00a9 100644 --- a/apps/cpu/PoiseuilleFlow/pf3.cpp +++ b/apps/cpu/PoiseuilleFlow/pf3.cpp @@ -6,7 +6,7 @@ ////two plates flow with forcing //void pf3() //{ -// SPtr<Communicator> comm = MPICommunicator::getInstance(); +// SPtr<vf::mpi::Communicator> comm = vf::mpi::MPICommunicator::getInstance(); // int myid = comm->getProcessID(); // // //parameters diff --git a/apps/cpu/PoiseuilleFlow/pf4.cpp b/apps/cpu/PoiseuilleFlow/pf4.cpp index 28e81e76a6f2ad1e47b6589a826ca5139a265547..9b249f94e19fd6c53b6410702406c498c101ed42 100644 --- a/apps/cpu/PoiseuilleFlow/pf4.cpp +++ b/apps/cpu/PoiseuilleFlow/pf4.cpp @@ -6,7 +6,7 @@ ////two plates flow with pressure drop //void pf4() //{ -// SPtr<Communicator> comm = MPICommunicator::getInstance(); +// SPtr<vf::mpi::Communicator> comm = vf::mpi::MPICommunicator::getInstance(); // int myid = comm->getProcessID(); // // //parameters diff --git a/apps/cpu/Thermoplast/thermoplast.cpp b/apps/cpu/Thermoplast/thermoplast.cpp index dc77db67a844004fe2ecc63a15df125c03ad1903..b004543254e4788ffa6a7314536b1811c217700b 100644 --- a/apps/cpu/Thermoplast/thermoplast.cpp +++ b/apps/cpu/Thermoplast/thermoplast.cpp @@ -52,7 +52,7 @@ vector<double> peMaxOffset; string pathOut;// = "d:/temp/thermoplastCluster"; string pathGeo;// = "d:/Projects/ThermoPlast/Geometrie"; -void addNozzle(SPtr<Grid3D> grid, SPtr<Communicator> comm, SPtr<BCAdapter> noSlipBCAdapter/*, InteractorsHelper& intHelper*/) +void addNozzle(SPtr<Grid3D> grid, SPtr<vf::mpi::Communicator> comm, SPtr<BCAdapter> noSlipBCAdapter/*, InteractorsHelper& intHelper*/) { int myid = comm->getProcessID(); if (myid==0) UBLOG(logINFO, "Add nozzles:start"); @@ -126,7 +126,7 @@ void addNozzle(SPtr<Grid3D> grid, SPtr<Communicator> comm, SPtr<BCAdapter> noSli if (myid==0) UBLOG(logINFO, "Add nozzles:end"); } -std::shared_ptr<DemCoProcessor> makePeCoProcessor(SPtr<Grid3D> grid, SPtr<Communicator> comm, const SPtr<UbScheduler> peScheduler, const std::shared_ptr<LBMUnitConverter> lbmUnitConverter, int maxpeIterations) +std::shared_ptr<DemCoProcessor> makePeCoProcessor(SPtr<Grid3D> grid, SPtr<vf::mpi::Communicator> comm, const SPtr<UbScheduler> peScheduler, const std::shared_ptr<LBMUnitConverter> lbmUnitConverter, int maxpeIterations) { double peRelaxtion = 0.7; //int maxpeIterations = 10000; @@ -194,7 +194,7 @@ void createSpheres(double radius, Vector3D origin, int maxX2, int maxX3, double void thermoplast(string configname) { - SPtr<Communicator> comm = MPICommunicator::getInstance(); + SPtr<vf::mpi::Communicator> comm = vf::mpi::MPICommunicator::getInstance(); int myid = comm->getProcessID(); vf::basics::ConfigurationFile config; diff --git a/apps/cpu/ViskomatXL/viskomat.cpp b/apps/cpu/ViskomatXL/viskomat.cpp index 12eea28c32990f38393bc3d3478cd0833c30c5ef..be7d3e850b633f7f40b24eaffd024487447d0c12 100644 --- a/apps/cpu/ViskomatXL/viskomat.cpp +++ b/apps/cpu/ViskomatXL/viskomat.cpp @@ -41,7 +41,7 @@ void bflow(string configname) //outputPath = outputPath + "/rheometerBingham_" + config.getValue<string>("resolution") + "_" + config.getValue<string>("OmegaLB"); - SPtr<Communicator> comm = MPICommunicator::getInstance(); + SPtr<vf::mpi::Communicator> comm = vf::mpi::MPICommunicator::getInstance(); int myid = comm->getProcessID(); if (logToFile) diff --git a/apps/cpu/Wing/wing.cpp b/apps/cpu/Wing/wing.cpp index 34f75cebaa8f23c913e2bf19130299e307a707f2..ff6cbcfcab3b60669aea19ca6a56077034f0e7dc 100644 --- a/apps/cpu/Wing/wing.cpp +++ b/apps/cpu/Wing/wing.cpp @@ -30,7 +30,7 @@ void setup(const char *cstr1, const char *cstr2) int refineLevel = UbSystem::stringTo<int>(cf.getValue("refineLevel")); int blocknx = UbSystem::stringTo<int>(cf.getValue("blocknx")); - CommunicatorPtr comm = MPICommunicator::getInstance(); + CommunicatorPtr comm = vf::mpi::MPICommunicator::getInstance(); int myid = comm->getProcessID(); if(machine == "Bombadil") int dumy=0; diff --git a/apps/cpu/aperm/aperm.cpp b/apps/cpu/aperm/aperm.cpp index 0172975c677e0072d3ead6ab13127cca98ca7161..ecff1a453276444b706e31729012dea10597ac61 100644 --- a/apps/cpu/aperm/aperm.cpp +++ b/apps/cpu/aperm/aperm.cpp @@ -59,7 +59,7 @@ void run(string configname) double cpStepStart = config.getDouble("cpStepStart"); bool newStart = config.getValue<bool>("newStart"); - SPtr<Communicator> comm = MPICommunicator::getInstance(); + SPtr<vf::mpi::Communicator> comm = vf::mpi::MPICommunicator::getInstance(); int myid = comm->getProcessID(); if (logToFile) diff --git a/apps/cpu/aperm/aperm.cpp.old b/apps/cpu/aperm/aperm.cpp.old index 87f05527469d44c5ea565108e515bea2a6b50a29..54dfe45fd86ff791d3965632a21acac0a3284aea 100644 --- a/apps/cpu/aperm/aperm.cpp.old +++ b/apps/cpu/aperm/aperm.cpp.old @@ -58,7 +58,7 @@ void run(string configname) bool yDir = config.getBool("yDir"); bool zDir = config.getBool("zDir"); - CommunicatorPtr comm = MPICommunicator::getInstance(); + CommunicatorPtr comm = vf::mpi::MPICommunicator::getInstance(); int myid = comm->getProcessID(); if (logToFile) diff --git a/apps/cpu/aperm/aperm.cpp.old2 b/apps/cpu/aperm/aperm.cpp.old2 index fd2b40d89a9479ba50843028a3d61e9422e759b7..bd49f895a277a34608393a7cb53c0b6466526a95 100644 --- a/apps/cpu/aperm/aperm.cpp.old2 +++ b/apps/cpu/aperm/aperm.cpp.old2 @@ -55,7 +55,7 @@ void run(string configname) bool yDir = config.getBool("yDir"); bool zDir = config.getBool("zDir"); - CommunicatorPtr comm = MPICommunicator::getInstance(); + CommunicatorPtr comm = vf::mpi::MPICommunicator::getInstance(); int myid = comm->getProcessID(); if (logToFile) diff --git a/apps/cpu/bChannelA/bChannelA.cpp b/apps/cpu/bChannelA/bChannelA.cpp index 75e263bbe125871598fdd1cbd38749e41132a224..d50e87437b5fa17353b0f8adb298ec91ecc9d964 100644 --- a/apps/cpu/bChannelA/bChannelA.cpp +++ b/apps/cpu/bChannelA/bChannelA.cpp @@ -111,7 +111,7 @@ void run(string configname) vector<double> nupsStep = config.getVector<double>("nupsStep"); vector<double> boundingBox = config.getVector<double>("boundingBox"); - SPtr<Communicator> comm = MPICommunicator::getInstance(); + SPtr<vf::mpi::Communicator> comm = vf::mpi::MPICommunicator::getInstance(); int myid = comm->getProcessID(); if (logToFile) diff --git a/apps/cpu/bChannelVA/bChannelVA.cpp b/apps/cpu/bChannelVA/bChannelVA.cpp index dce429bd17250e90d3cd2ac753e77f720a184c70..6cfe5dac2557f167864495599074cd3c94da6517 100644 --- a/apps/cpu/bChannelVA/bChannelVA.cpp +++ b/apps/cpu/bChannelVA/bChannelVA.cpp @@ -13,7 +13,7 @@ int main(int argc, char* argv[]) try { //Sleep(20000); - SPtr<Communicator> comm = MPICommunicator::getInstance(); + SPtr<vf::mpi::Communicator> comm = vf::mpi::MPICommunicator::getInstance(); int myid = comm->getProcessID(); //Pheonix diff --git a/apps/cpu/bKanal/HLRNb/bKanal.cpp b/apps/cpu/bKanal/HLRNb/bKanal.cpp index d7028dba969d01b409a3fc84b4fc3b83556da69a..0c5c46a0cb78354563425685c8346ff81258ccd2 100644 --- a/apps/cpu/bKanal/HLRNb/bKanal.cpp +++ b/apps/cpu/bKanal/HLRNb/bKanal.cpp @@ -27,7 +27,7 @@ void run(const char *cstr) UbLog::reportingLevel() = logINFO; - CommunicatorPtr comm = MPICommunicator::getInstance(); + CommunicatorPtr comm = vf::mpi::MPICommunicator::getInstance(); int myid = comm->getProcessID(); @@ -77,9 +77,9 @@ void run(const char *cstr) int H=200;//200;//392; - // nx[0] =8;//ok mit 8// (int)(3.0*(double)H/8.0/8.0);//2;// (int)(0.3*(double)H/6.0/4.0);//das "/4" hier ist wegen der verfeinerung da! //länge + // nx[0] =8;//ok mit 8// (int)(3.0*(double)H/8.0/8.0);//2;// (int)(0.3*(double)H/6.0/4.0);//das "/4" hier ist wegen der verfeinerung da! //l�nge // nx[1] =8;//ok mit 8// (int)(2.0*(double)H/8.0/8.0);//2;// (int)(0.2*(double)H/6.0/4.0);// //breite - nx[2] = (int)(2.0*(double)H/5.0/8.0);// //höhe gebiet + nx[2] = (int)(2.0*(double)H/5.0/8.0);// //h�he gebiet //(3/2/2)-ratio: nx[1]=nx[2]; @@ -289,7 +289,7 @@ void run(const char *cstr) // , originX1+geoLength[0]+geoOverlap, originX2+geoOverlap+geoLength[1], kanalhoeheSI*0.25)); //RefineCrossAndInsideGbObjectBlockVisitor refineVisitorminl3(wallsX1X2minRefl3, 0,refineLevel-3); //grid->accept(refineVisitorminl3); - /////würfel unten version + /////w�rfel unten version // GbCuboid3DPtr wallsX1X2minRef2(new GbCuboid3D( originX1-3.0*geoOverlap , originX2-3.0*geoOverlap , originX3-3.0*geoOverlap // , originX1+geoLength[0]+geoOverlap, originX2+geoOverlap+geoLength[1], kanalhoeheSI*0.2)); //RefineCrossAndInsideGbObjectBlockVisitor refineVisitormin2(wallsX1X2minRef2, 0,refineLevel-2); @@ -308,7 +308,7 @@ void run(const char *cstr) - /////würfel anfang version + /////w�rfel anfang version // GbCuboid3DPtr wallsX1X2minRef2(new GbCuboid3D( originX1-3.0*geoOverlap , originX2-3.0*geoOverlap , originX3-3.0*geoOverlap // , originX1+geoLength[0]+geoOverlap, originX2+geoOverlap+geoLength[1], kanalhoeheSI*0.56)); //RefineCrossAndInsideGbObjectBlockVisitor refineVisitormin2(wallsX1X2minRef2, 0,refineLevel-2); @@ -389,10 +389,10 @@ void run(const char *cstr) ///interactoren //int bbOption1 = 0; //0=simple Bounce Back, 1=quadr. BB //D3Q27BoundaryConditionAdapterPtr bcObst(new D3Q27NoSlipBCAdapter(bbOption1)); - ///////würfel unten version ende + ///////w�rfel unten version ende //////////////////////////////////////////////////////////////////////////////// ////////PM grid - //Temporär: + //Tempor�r: //double H=1.0; vector<D3Q27InteractorPtr> D3Q27InteractorPtrarray; diff --git a/apps/cpu/bKanal/bKanal.cpp b/apps/cpu/bKanal/bKanal.cpp index b6ee71f79963d0c2e6336cbe2455babba6b3cea2..94af8f6aa46ddf5f398747805836ba95ce1dbbaf 100644 --- a/apps/cpu/bKanal/bKanal.cpp +++ b/apps/cpu/bKanal/bKanal.cpp @@ -24,7 +24,7 @@ void run(const char *cstr) UbLog::reportingLevel() = logINFO; - CommunicatorPtr comm = MPICommunicator::getInstance(); + CommunicatorPtr comm = vf::mpi::MPICommunicator::getInstance(); int myid = comm->getProcessID(); string machine = string(cstr); @@ -81,9 +81,9 @@ void run(const char *cstr) int H=200;//200;//392; - // nx[0] =8;//ok mit 8// (int)(3.0*(double)H/8.0/8.0);//2;// (int)(0.3*(double)H/6.0/4.0);//das "/4" hier ist wegen der verfeinerung da! //länge + // nx[0] =8;//ok mit 8// (int)(3.0*(double)H/8.0/8.0);//2;// (int)(0.3*(double)H/6.0/4.0);//das "/4" hier ist wegen der verfeinerung da! //l�nge // nx[1] =8;//ok mit 8// (int)(2.0*(double)H/8.0/8.0);//2;// (int)(0.2*(double)H/6.0/4.0);// //breite - nx[2] = (int)(2.0*(double)H/5.0/8.0);// //höhe gebiet + nx[2] = (int)(2.0*(double)H/5.0/8.0);// //h�he gebiet //(3/2/2)-ratio: nx[1]=nx[2]; @@ -267,10 +267,10 @@ void run(const char *cstr) ///interactoren //int bbOption1 = 0; //0=simple Bounce Back, 1=quadr. BB //D3Q27BoundaryConditionAdapterPtr bcObst(new D3Q27NoSlipBCAdapter(bbOption1)); - ///////würfel unten version ende + ///////w�rfel unten version ende //////////////////////////////////////////////////////////////////////////////// ////////PM grid - //Temporär: + //Tempor�r: //double H=1.0; vector<D3Q27InteractorPtr> D3Q27InteractorPtrarray; diff --git a/apps/cpu/bKanal/sKanal/bKanal.cpp b/apps/cpu/bKanal/sKanal/bKanal.cpp index cabea74871a6da507b1c9c9ddf23820a936bdb10..6a9d3c2c697b04c176bc9c11aa38f7f719e07785 100644 --- a/apps/cpu/bKanal/sKanal/bKanal.cpp +++ b/apps/cpu/bKanal/sKanal/bKanal.cpp @@ -27,7 +27,7 @@ void run(const char *cstr) UbLog::reportingLevel() = logINFO; - CommunicatorPtr comm = MPICommunicator::getInstance(); + CommunicatorPtr comm = vf::mpi::MPICommunicator::getInstance(); int myid = comm->getProcessID(); if(machine == "PIPPINNEU") @@ -89,9 +89,9 @@ void run(const char *cstr) int H=200;//200;//392; - // nx[0] =8;//ok mit 8// (int)(3.0*(double)H/8.0/8.0);//2;// (int)(0.3*(double)H/6.0/4.0);//das "/4" hier ist wegen der verfeinerung da! //länge + // nx[0] =8;//ok mit 8// (int)(3.0*(double)H/8.0/8.0);//2;// (int)(0.3*(double)H/6.0/4.0);//das "/4" hier ist wegen der verfeinerung da! //l�nge // nx[1] =8;//ok mit 8// (int)(2.0*(double)H/8.0/8.0);//2;// (int)(0.2*(double)H/6.0/4.0);// //breite - nx[2] = (int)(2.0*(double)H/5.0/8.0);// //höhe gebiet + nx[2] = (int)(2.0*(double)H/5.0/8.0);// //h�he gebiet //(3/2/2)-ratio: nx[1]=nx[2]; @@ -300,7 +300,7 @@ void run(const char *cstr) // , originX1+geoLength[0]+geoOverlap, originX2+geoOverlap+geoLength[1], kanalhoeheSI*0.25)); //RefineCrossAndInsideGbObjectBlockVisitor refineVisitorminl3(wallsX1X2minRefl3, 0,refineLevel-3); //grid->accept(refineVisitorminl3); - /////würfel unten version + /////w�rfel unten version // GbCuboid3DPtr wallsX1X2minRef2(new GbCuboid3D( originX1-3.0*geoOverlap , originX2-3.0*geoOverlap , originX3-3.0*geoOverlap // , originX1+geoLength[0]+geoOverlap, originX2+geoOverlap+geoLength[1], kanalhoeheSI*0.2)); //RefineCrossAndInsideGbObjectBlockVisitor refineVisitormin2(wallsX1X2minRef2, 0,refineLevel-2); @@ -319,7 +319,7 @@ void run(const char *cstr) - /////würfel anfang version + /////w�rfel anfang version // GbCuboid3DPtr wallsX1X2minRef2(new GbCuboid3D( originX1-3.0*geoOverlap , originX2-3.0*geoOverlap , originX3-3.0*geoOverlap // , originX1+geoLength[0]+geoOverlap, originX2+geoOverlap+geoLength[1], kanalhoeheSI*0.56)); //RefineCrossAndInsideGbObjectBlockVisitor refineVisitormin2(wallsX1X2minRef2, 0,refineLevel-2); @@ -400,10 +400,10 @@ void run(const char *cstr) ///interactoren //int bbOption1 = 0; //0=simple Bounce Back, 1=quadr. BB //D3Q27BoundaryConditionAdapterPtr bcObst(new D3Q27NoSlipBCAdapter(bbOption1)); - ///////würfel unten version ende + ///////w�rfel unten version ende //////////////////////////////////////////////////////////////////////////////// ////////PM grid - //Temporär: + //Tempor�r: //double H=1.0; vector<D3Q27InteractorPtr> D3Q27InteractorPtrarray; diff --git a/apps/cpu/bKanal2/bKanal2.cpp b/apps/cpu/bKanal2/bKanal2.cpp index 87181a20e7c8542456c220d80e76a214c9b0c779..10e6f988085244e2028f28fca4129bc354c49699 100644 --- a/apps/cpu/bKanal2/bKanal2.cpp +++ b/apps/cpu/bKanal2/bKanal2.cpp @@ -24,7 +24,7 @@ void run(const char *cstr) UbLog::reportingLevel() = logINFO; - CommunicatorPtr comm = MPICommunicator::getInstance(); + CommunicatorPtr comm = vf::mpi::MPICommunicator::getInstance(); int myid = comm->getProcessID(); string machine = string(cstr); @@ -222,10 +222,10 @@ void run(const char *cstr) ///interactoren //int bbOption1 = 0; //0=simple Bounce Back, 1=quadr. BB //D3Q27BoundaryConditionAdapterPtr bcObst(new D3Q27NoSlipBCAdapter(bbOption1)); - ///////würfel unten version ende + ///////w�rfel unten version ende //////////////////////////////////////////////////////////////////////////////// ////////PM grid - //Temporär: + //Tempor�r: //double H=1.0; vector<D3Q27InteractorPtr> D3Q27InteractorPtrarray; diff --git a/apps/cpu/bKanalAv/bKanal.cpp b/apps/cpu/bKanalAv/bKanal.cpp index 067aabbddc7284603bf3d8dfa2c6bf4a5eca99a8..71ca1ed0464afd67adf8db473ccdbf9487b8acda 100644 --- a/apps/cpu/bKanalAv/bKanal.cpp +++ b/apps/cpu/bKanalAv/bKanal.cpp @@ -27,7 +27,7 @@ void run(const char *cstr) UbLog::reportingLevel() = logINFO; - CommunicatorPtr comm = MPICommunicator::getInstance(); + CommunicatorPtr comm = vf::mpi::MPICommunicator::getInstance(); int myid = comm->getProcessID(); @@ -77,9 +77,9 @@ void run(const char *cstr) int H=200;//200;//392; - // nx[0] =8;//ok mit 8// (int)(3.0*(double)H/8.0/8.0);//2;// (int)(0.3*(double)H/6.0/4.0);//das "/4" hier ist wegen der verfeinerung da! //länge + // nx[0] =8;//ok mit 8// (int)(3.0*(double)H/8.0/8.0);//2;// (int)(0.3*(double)H/6.0/4.0);//das "/4" hier ist wegen der verfeinerung da! //l�nge // nx[1] =8;//ok mit 8// (int)(2.0*(double)H/8.0/8.0);//2;// (int)(0.2*(double)H/6.0/4.0);// //breite - nx[2] = (int)(2.0*(double)H/5.0/8.0);// //höhe gebiet + nx[2] = (int)(2.0*(double)H/5.0/8.0);// //h�he gebiet //(3/2/2)-ratio: nx[1]=nx[2]; @@ -289,7 +289,7 @@ void run(const char *cstr) // , originX1+geoLength[0]+geoOverlap, originX2+geoOverlap+geoLength[1], kanalhoeheSI*0.25)); //RefineCrossAndInsideGbObjectBlockVisitor refineVisitorminl3(wallsX1X2minRefl3, 0,refineLevel-3); //grid->accept(refineVisitorminl3); - /////würfel unten version + /////w�rfel unten version // GbCuboid3DPtr wallsX1X2minRef2(new GbCuboid3D( originX1-3.0*geoOverlap , originX2-3.0*geoOverlap , originX3-3.0*geoOverlap // , originX1+geoLength[0]+geoOverlap, originX2+geoOverlap+geoLength[1], kanalhoeheSI*0.2)); //RefineCrossAndInsideGbObjectBlockVisitor refineVisitormin2(wallsX1X2minRef2, 0,refineLevel-2); @@ -308,7 +308,7 @@ void run(const char *cstr) - /////würfel anfang version + /////w�rfel anfang version // GbCuboid3DPtr wallsX1X2minRef2(new GbCuboid3D( originX1-3.0*geoOverlap , originX2-3.0*geoOverlap , originX3-3.0*geoOverlap // , originX1+geoLength[0]+geoOverlap, originX2+geoOverlap+geoLength[1], kanalhoeheSI*0.56)); //RefineCrossAndInsideGbObjectBlockVisitor refineVisitormin2(wallsX1X2minRef2, 0,refineLevel-2); @@ -389,10 +389,10 @@ void run(const char *cstr) ///interactoren //int bbOption1 = 0; //0=simple Bounce Back, 1=quadr. BB //D3Q27BoundaryConditionAdapterPtr bcObst(new D3Q27NoSlipBCAdapter(bbOption1)); - ///////würfel unten version ende + ///////w�rfel unten version ende //////////////////////////////////////////////////////////////////////////////// ////////PM grid - //Temporär: + //Tempor�r: //double H=1.0; //vector<D3Q27InteractorPtr> D3Q27InteractorPtrarray; diff --git a/apps/cpu/band/band.cpp b/apps/cpu/band/band.cpp index ed3103ef6b5ab8854b4b2244f01f08776a069b9a..370e50341662d21f25407cec428b1c20ee543a37 100644 --- a/apps/cpu/band/band.cpp +++ b/apps/cpu/band/band.cpp @@ -20,7 +20,7 @@ void run(const char *cstr) //UbLog::reportingLevel() = logDEBUG5; - CommunicatorPtr comm = MPICommunicator::getInstance(); + CommunicatorPtr comm = vf::mpi::MPICommunicator::getInstance(); int myid = comm->getProcessID(); string machine = string(cstr); @@ -80,9 +80,9 @@ void run(const char *cstr) ///////////////Knotenabmessungen: int nx[3], blocknx[3]; - nx[0] = 10;//240;//120;//60;//86;//43;//65;//50; //länge + nx[0] = 10;//240;//120;//60;//86;//43;//65;//50; //l�nge nx[1] = 1;//2;//6;///1;//5;// //breite - nx[2] = 2;//64;//32;//18;//5;//15;//15; //höhe gebiet + nx[2] = 2;//64;//32;//18;//5;//15;//15; //h�he gebiet blocknx[0] = 10;//10;//6; blocknx[1] = 10;//10;//6; blocknx[2] = 10;//10;//6; @@ -90,12 +90,12 @@ void run(const char *cstr) int baseLevel = 0; int refineLevel = 0; - double H = 0.6; // Kanalhöhe [mm] + double H = 0.6; // Kanalh�he [mm] //double cdx = H/blocknx[2]; double cdx = 0.0390625; double fdx = cdx/double(1<<refineLevel); - //double h = 200.0; // gewünschte Plattenhöhe in Gitterpunkten + //double h = 200.0; // gew�nschte Plattenh�he in Gitterpunkten //double fdx = plate->getLengthX3()/h; //double cdx = fdx*double(1<<refineLevel); @@ -107,7 +107,7 @@ void run(const char *cstr) double Re = 680; double rhoLB = 0.0; double uLB = 0.1; - double lReal = 0.6; //Zackenhöhe in mm + double lReal = 0.6; //Zackenh�he in mm double nuLB = (uLB*(lReal/cdx))/Re; Grid3DPtr grid(new Grid3D(comm)); diff --git a/apps/cpu/bbone/bbone.cpp b/apps/cpu/bbone/bbone.cpp index 30a2b28c32e78f65b4c79d185b302e83e38e8579..3eb6c827c6157c4dc6810ffaab402e3e51337c93 100644 --- a/apps/cpu/bbone/bbone.cpp +++ b/apps/cpu/bbone/bbone.cpp @@ -33,7 +33,7 @@ void sbonepd(string configname) bool logToFile = config.getBool("logToFile"); double deltaT = config.getDouble("deltaT"); - CommunicatorPtr comm = MPICommunicator::getInstance(); + CommunicatorPtr comm = vf::mpi::MPICommunicator::getInstance(); int myid = comm->getProcessID(); if (logToFile) @@ -70,8 +70,8 @@ void sbonepd(string configname) LBMReal rho_LB = 0.0; //nueWasser = 1e-6 m^2/s double nu_real = 1e-6; - LBMReal dt = deltaT; //1e-5; // s (frei gewählt) - //dx - frei gewählt + LBMReal dt = deltaT; //1e-5; // s (frei gew�hlt) + //dx - frei gew�hlt // LBMReal nu_LB = nu_real / (dx*dx / dt); diff --git a/apps/cpu/block_test/block_test_incompressible.hpp b/apps/cpu/block_test/block_test_incompressible.hpp index d7c1c49f4ca01f2899e1d721afdf9d6b47e870cd..2ce506c93f4611a3069140703e712dbcca7fe661 100644 --- a/apps/cpu/block_test/block_test_incompressible.hpp +++ b/apps/cpu/block_test/block_test_incompressible.hpp @@ -29,7 +29,7 @@ void block_test_incompressible(const char *cstr1, const char *cstr2) int numOfThreads = UbSystem::stringTo<int>(cf.getValue("numOfThreads")); double availMem = 0; - CommunicatorPtr comm = MPICommunicator::getInstance(); + CommunicatorPtr comm = vf::mpi::MPICommunicator::getInstance(); int myid = comm->getProcessID(); if(machine == "BOMBADIL") diff --git a/apps/cpu/bond_benchmark/bonb_b_chanel.cpp b/apps/cpu/bond_benchmark/bonb_b_chanel.cpp index 3753ebea683a520dfd34fd2a78f392f169442214..b5e63c50d5a9ba91abb872319a7e68de9df28b97 100644 --- a/apps/cpu/bond_benchmark/bonb_b_chanel.cpp +++ b/apps/cpu/bond_benchmark/bonb_b_chanel.cpp @@ -29,7 +29,7 @@ void chanel(const char *cstr) string comm_type = cf.getValue("comm"); if(comm_type == "MPI") - comm = MPICommunicator::getInstance(); + comm = vf::mpi::MPICommunicator::getInstance(); else if(comm_type == "BOND") comm = BondCommunicator::getInstance(); diff --git a/apps/cpu/bond_benchmark/bond_b.cpp b/apps/cpu/bond_benchmark/bond_b.cpp index ba3221aa058aad9d9b0fb807bbbde05c21bc3bc0..6d607811a21f4dc111f6b003bf9343c60973207c 100644 --- a/apps/cpu/bond_benchmark/bond_b.cpp +++ b/apps/cpu/bond_benchmark/bond_b.cpp @@ -35,7 +35,7 @@ void periodic(const char *cstr1, const char *cstr2) string comm_type = cf.getValue("comm"); if(comm_type == "MPI") - comm = MPICommunicator::getInstance(); + comm = vf::mpi::MPICommunicator::getInstance(); else if(comm_type == "BOND") comm = BondCommunicator::getInstance(); diff --git a/apps/cpu/bond_test/bond_test.cpp b/apps/cpu/bond_test/bond_test.cpp index 06e9d7710b7067d289292df29a615763f9b0b5fa..b7091184ff789dd6ac56e8c085853e5a45c088a0 100644 --- a/apps/cpu/bond_test/bond_test.cpp +++ b/apps/cpu/bond_test/bond_test.cpp @@ -153,7 +153,7 @@ void simulation(const char *cstr) CommunicatorPtr comm; string comm_type = cf.getValue("comm"); if(comm_type == "MPI") - comm = MPICommunicator::getInstance(); + comm = vf::mpi::MPICommunicator::getInstance(); else if(comm_type == "BOND") comm = BondCommunicator::getInstance(); diff --git a/apps/cpu/bone/bone.cpp b/apps/cpu/bone/bone.cpp index 9ad9321d601fff1caf126b776f9697fdd22876f1..849241ba26fc515ca2ee4ac3bd127742c0c693e5 100644 --- a/apps/cpu/bone/bone.cpp +++ b/apps/cpu/bone/bone.cpp @@ -18,7 +18,7 @@ void run(const char *cstr1, const char *cstr2) stringstream logFilename; double availMem = 0; - CommunicatorPtr comm = MPICommunicator::getInstance(); + CommunicatorPtr comm = vf::mpi::MPICommunicator::getInstance(); int myid = comm->getProcessID(); string machine = string(cstr1); @@ -102,9 +102,9 @@ void run(const char *cstr1, const char *cstr2) /////////////////Knotenabmessungen: //int nx[3], blocknx[3]; - //nx[0] = 90;//240;//120;//60;//86;//43;//65;//50; //länge + //nx[0] = 90;//240;//120;//60;//86;//43;//65;//50; //l�nge //nx[1] = 2;//2;//6;///1;//5;// //breite - //nx[2] = 30;//64;//32;//18;//5;//15;//15; //höhe gebiet + //nx[2] = 30;//64;//32;//18;//5;//15;//15; //h�he gebiet //blocknx[0] = 16;//10;//6; //blocknx[1] = 16;//10;//6; //blocknx[2] = 16;//10;//6; @@ -112,11 +112,11 @@ void run(const char *cstr1, const char *cstr2) //int baseLevel = 0; //int refineLevel = 4; - //double H = 600.0; // Kanalhöhe [mm] + //double H = 600.0; // Kanalh�he [mm] //double cdx = H/(double)(nx[2]*blocknx[2]); //double fdx = cdx/double(1<<refineLevel); - ////double h = 200.0; // gewünschte Plattenhöhe in Gitterpunkten + ////double h = 200.0; // gew�nschte Plattenh�he in Gitterpunkten ////double fdx = plate->getLengthX3()/h; ////double cdx = fdx*double(1<<refineLevel); @@ -128,7 +128,7 @@ void run(const char *cstr1, const char *cstr2) //double Re = 1133333.3333333335; //double rhoLB = 0.0; //double uLB = 0.1; - //double lReal = 1000; //Plattenlänge in mm + //double lReal = 1000; //Plattenl�nge in mm //double nuLB = (uLB*(lReal/cdx))/Re; //int sizeSP=4; diff --git a/apps/cpu/f16Test/f16test.cpp b/apps/cpu/f16Test/f16test.cpp index 58921f91e5fa294fb117a2842626e28d12ade8d4..a73949c8cef45cfa1b576070cb004041f2ac7a0f 100644 --- a/apps/cpu/f16Test/f16test.cpp +++ b/apps/cpu/f16Test/f16test.cpp @@ -42,7 +42,7 @@ void run(string configname) double refineDistance = config.getDouble("refineDistance"); vector<double> nupsStep = config.getVector<double>("nupsStep"); - SPtr<Communicator> comm = MPICommunicator::getInstance(); + SPtr<vf::mpi::Communicator> comm = vf::mpi::MPICommunicator::getInstance(); int myid = comm->getProcessID(); if (logToFile) diff --git a/apps/cpu/insitu_demo/insitu_demo.cpp b/apps/cpu/insitu_demo/insitu_demo.cpp index 0e58965c47809e9f35403fc7f330ec0135588bbd..42a1c6b4c636801bbaa50a1027751cd88301edfb 100644 --- a/apps/cpu/insitu_demo/insitu_demo.cpp +++ b/apps/cpu/insitu_demo/insitu_demo.cpp @@ -15,7 +15,7 @@ void chanel(const char *cstr1) double availMem = 0; //CommunicatorPtr comm = FETOLCommunicator::getInstance(); - CommunicatorPtr comm = MPICommunicator::getInstance(); + CommunicatorPtr comm = vf::mpi::MPICommunicator::getInstance(); int myid = comm->getProcessID(); int mybundle = comm->getBundleID(); diff --git a/apps/cpu/levels/levels.cpp b/apps/cpu/levels/levels.cpp index 7173a4ba562a95fc93e267c5498957fc4a539da6..0fe328df129ea3f64a135f74f51e425c8d33bd52 100644 --- a/apps/cpu/levels/levels.cpp +++ b/apps/cpu/levels/levels.cpp @@ -14,7 +14,7 @@ void run(string configname) string machine = QUOTEME(CAB_MACHINE); - SPtr<Communicator> comm = MPICommunicator::getInstance(); + SPtr<vf::mpi::Communicator> comm = vf::mpi::MPICommunicator::getInstance(); int myid = comm->getProcessID(); int mybundle = comm->getBundleID(); diff --git a/apps/cpu/micropart/micropartTestQs3.hpp b/apps/cpu/micropart/micropartTestQs3.hpp index 11fe1c802e128e5cd36349694de084f7623125f0..14e9a84412a51548b91f668369029afd057241c5 100644 --- a/apps/cpu/micropart/micropartTestQs3.hpp +++ b/apps/cpu/micropart/micropartTestQs3.hpp @@ -9,7 +9,7 @@ void micropartTestQs3(const char *cstr) { try { - CommunicatorPtr comm = MPICommunicator::getInstance(); + CommunicatorPtr comm = vf::mpi::MPICommunicator::getInstance(); int myid = comm->getProcessID(); int numprocs = comm->getNumberOfProcesses(); @@ -436,7 +436,7 @@ void micropartTestQs3(const char *cstr) // if(myid == 0) // { - // //Abstände "q" als Linien rausschreiben + // //Abst�nde "q" als Linien rausschreiben // std::vector< UbTupleFloat3 > nodes; // std::vector< UbTupleInt2 > lines; // geoInt->addQsLineSet(nodes, lines); diff --git a/apps/cpu/mirror/mirror.cpp b/apps/cpu/mirror/mirror.cpp index e4a2f33027bb3b0be3eafb6b0746a14f642107ee..68902fdb7d0dcb74d3eb59d884a0619c8bb0cf6b 100644 --- a/apps/cpu/mirror/mirror.cpp +++ b/apps/cpu/mirror/mirror.cpp @@ -49,7 +49,7 @@ void run(string configname) string VRES1100_Spiegel_fein = config.getValue<string>("VRES1100_Spiegel_fein"); - SPtr<Communicator> comm = MPICommunicator::getInstance(); + SPtr<vf::mpi::Communicator> comm = vf::mpi::MPICommunicator::getInstance(); int myid = comm->getProcessID(); if (logToFile) diff --git a/apps/cpu/mpi_benchmark/mpib.cpp b/apps/cpu/mpi_benchmark/mpib.cpp index 05a251bb2f0632a8cff7b1d0cb42603c5be0438e..6c13de98b743ad251bb1000dafc609660ca4ba46 100644 --- a/apps/cpu/mpi_benchmark/mpib.cpp +++ b/apps/cpu/mpi_benchmark/mpib.cpp @@ -8,7 +8,7 @@ using namespace std; void run(string configname) { - SPtr<Communicator> comm = MPICommunicator::getInstance(); + SPtr<vf::mpi::Communicator> comm = vf::mpi::MPICommunicator::getInstance(); int myid = comm->getProcessID(); // Get the name of the processor diff --git a/apps/cpu/pChannel/pChannel.cpp b/apps/cpu/pChannel/pChannel.cpp index f036c22b6a7f3016a25d20640026db10eb5cb6bf..c2b32108037389ddd18351ff7092cd3d680492ea 100644 --- a/apps/cpu/pChannel/pChannel.cpp +++ b/apps/cpu/pChannel/pChannel.cpp @@ -206,7 +206,7 @@ void run(string configname) vector<double> nupsStep = config.getVector<double>("nupsStep"); vector<double> boundingBox = config.getVector<double>("boundingBox"); - SPtr<Communicator> comm = MPICommunicator::getInstance(); + SPtr<vf::mpi::Communicator> comm = vf::mpi::MPICommunicator::getInstance(); int myid = comm->getProcessID(); if (logToFile) diff --git a/apps/cpu/pChannel/pChannel.cpp.hlrn b/apps/cpu/pChannel/pChannel.cpp.hlrn index a0592ec5b0871b37e3d7f21e0f85cc91ebf561d2..f25a0c4c2e62d6b2b97ff338d567ef911bdc9d14 100644 --- a/apps/cpu/pChannel/pChannel.cpp.hlrn +++ b/apps/cpu/pChannel/pChannel.cpp.hlrn @@ -52,7 +52,7 @@ void run(string configname) double timeLineTsStop = config.getDouble("timeLineTsStop"); - CommunicatorPtr comm = MPICommunicator::getInstance(); + CommunicatorPtr comm = vf::mpi::MPICommunicator::getInstance(); int myid = comm->getProcessID(); if (logToFile) diff --git a/apps/cpu/pDisk/pdisk.cpp b/apps/cpu/pDisk/pdisk.cpp index f24b6b0c185e7ddb45bef85caefb550828e2e998..f19e04ff81222e7eb448c1f0236669fb824fad23 100644 --- a/apps/cpu/pDisk/pdisk.cpp +++ b/apps/cpu/pDisk/pdisk.cpp @@ -39,7 +39,7 @@ void run(string configname) //UbLog::reportingLevel() = logDEBUG5; - CommunicatorPtr comm = MPICommunicator::getInstance(); + CommunicatorPtr comm = vf::mpi::MPICommunicator::getInstance(); int myid = comm->getProcessID(); diff --git a/apps/cpu/perm/perm.cpp b/apps/cpu/perm/perm.cpp index 21b4bc47abfd650e52c9b235d28fdcdf52b229f2..7fae63025a198a09af2a30da3776f940441dbcc2 100644 --- a/apps/cpu/perm/perm.cpp +++ b/apps/cpu/perm/perm.cpp @@ -44,7 +44,7 @@ void perm(string configname) double deltax = config.getValue<double>("deltax"); bool writeSampleToFile = config.getValue<bool>("writeSampleToFile"); - SPtr<Communicator> comm = MPICommunicator::getInstance(); + SPtr<vf::mpi::Communicator> comm = vf::mpi::MPICommunicator::getInstance(); int myid = comm->getProcessID(); if (logToFile) diff --git a/apps/cpu/perm/perm.cpp_s b/apps/cpu/perm/perm.cpp_s index 3d6c8457f02a8e9063d1e8fd2758e284e769f1de..21db434d5290ee948665f45af8ae1c93a84d9336 100644 --- a/apps/cpu/perm/perm.cpp_s +++ b/apps/cpu/perm/perm.cpp_s @@ -23,7 +23,7 @@ void perm(const char *configname) throw exceptionText; } - CommunicatorPtr comm = MPICommunicator::getInstance(); + CommunicatorPtr comm = vf::mpi::MPICommunicator::getInstance(); int myid = comm->getProcessID(); if (machine == "BOMBADIL") diff --git a/apps/cpu/plate/plate.cpp b/apps/cpu/plate/plate.cpp index 7322f5fc89e6c2729e5cf07b9e69894594b1c3d3..28db0262fa649ea93f8b44cf69821557ad53961e 100644 --- a/apps/cpu/plate/plate.cpp +++ b/apps/cpu/plate/plate.cpp @@ -25,7 +25,7 @@ void run(const char *cstr, double endTime) //UbLog::reportingLevel() = logDEBUG5; - CommunicatorPtr comm = MPICommunicator::getInstance(); + CommunicatorPtr comm = vf::mpi::MPICommunicator::getInstance(); int myid = comm->getProcessID(); string machine = string(cstr); @@ -106,9 +106,9 @@ void run(const char *cstr, double endTime) //int H=200;//200;//392; ///////////////Knotenabmessungen: - nx[0] = 50;//240;//120;//60;//86;//43;//65;//50; //länge + nx[0] = 50;//240;//120;//60;//86;//43;//65;//50; //l�nge nx[1] = 1;//2;//6;///1;//5;// //breite - nx[2] = 16;//64;//32;//18;//5;//15;//15; //höhe gebiet + nx[2] = 16;//64;//32;//18;//5;//15;//15; //h�he gebiet blocknx[0] = 25;//10;//6; blocknx[1] = 25;//10;//6; blocknx[2] = 25;//10;//6; @@ -117,9 +117,9 @@ void run(const char *cstr, double endTime) refineLevel = 4; ///////////////Weltabmessungen: - double kanalhoeheSI = 60.0/100.0;//60.0/100.0;//cm, Kanalhöhe - double kanalbreiteSI = kanalhoeheSI*((double)nx[1])/((double)nx[2]);//=kanalhöhe*nx1/nx2//1.65/100.0;//13.2/100.0;////40.0/100.0; //cm, Kanalbreite //13.2 zeilbreite - double kanallaengeSI = kanalhoeheSI*((double)nx[0])/((double)nx[2]);//80.0/100.0;//cm, Kanallänge, ist nicht angegeben + double kanalhoeheSI = 60.0/100.0;//60.0/100.0;//cm, Kanalh�he + double kanalbreiteSI = kanalhoeheSI*((double)nx[1])/((double)nx[2]);//=kanalh�he*nx1/nx2//1.65/100.0;//13.2/100.0;////40.0/100.0; //cm, Kanalbreite //13.2 zeilbreite + double kanallaengeSI = kanalhoeheSI*((double)nx[0])/((double)nx[2]);//80.0/100.0;//cm, Kanall�nge, ist nicht angegeben // double refinewidth1=kanalhoeheSI/10.0; @@ -156,7 +156,7 @@ void run(const char *cstr, double endTime) double hReal = 0.0105;//<-m 1.05;//Plattendicke in cm(! cm nicht m !) double uReal = 15;//m/s //Re*nueReal/hReal; - double lReal = 1; //m Plattenlänge + double lReal = 1; //m Plattenl�nge //##Machzahl: //#Ma = uReal/csReal diff --git a/apps/cpu/plate2/plate2.cpp b/apps/cpu/plate2/plate2.cpp index 8fe2cd3dbbd7f9183927e5e09dd1d20ffc6769ea..a908abf5b3652dcdd24c44202950f4962351c735 100644 --- a/apps/cpu/plate2/plate2.cpp +++ b/apps/cpu/plate2/plate2.cpp @@ -18,7 +18,7 @@ void run(const char *cstr1, const char *cstr2) stringstream logFilename; double availMem = 0; - CommunicatorPtr comm = MPICommunicator::getInstance(); + CommunicatorPtr comm = vf::mpi::MPICommunicator::getInstance(); int myid = comm->getProcessID(); string machine = string(cstr1); @@ -85,9 +85,9 @@ void run(const char *cstr1, const char *cstr2) ///////////////Knotenabmessungen: int nx[3], blocknx[3]; - nx[0] = 90;//240;//120;//60;//86;//43;//65;//50; //länge + nx[0] = 90;//240;//120;//60;//86;//43;//65;//50; //l�nge nx[1] = 2;//2;//6;///1;//5;// //breite - nx[2] = 30;//64;//32;//18;//5;//15;//15; //höhe gebiet + nx[2] = 30;//64;//32;//18;//5;//15;//15; //h�he gebiet blocknx[0] = 16;//10;//6; blocknx[1] = 16;//10;//6; blocknx[2] = 16;//10;//6; @@ -95,11 +95,11 @@ void run(const char *cstr1, const char *cstr2) int baseLevel = 0; int refineLevel = 4; - double H = 600.0; // Kanalhöhe [mm] + double H = 600.0; // Kanalh�he [mm] double cdx = H/(double)(nx[2]*blocknx[2]); double fdx = cdx/double(1<<refineLevel); - //double h = 200.0; // gewünschte Plattenhöhe in Gitterpunkten + //double h = 200.0; // gew�nschte Plattenh�he in Gitterpunkten //double fdx = plate->getLengthX3()/h; //double cdx = fdx*double(1<<refineLevel); @@ -111,7 +111,7 @@ void run(const char *cstr1, const char *cstr2) double Re = 1133333.3333333335; double rhoLB = 0.0; double uLB = 0.1; - double lReal = 1000; //Plattenlänge in mm + double lReal = 1000; //Plattenl�nge in mm double nuLB = (uLB*(lReal/cdx))/Re; int sizeSP=4; diff --git a/apps/cpu/poiseuille_example/poiseuille.cpp b/apps/cpu/poiseuille_example/poiseuille.cpp index db9ac4ffb0218e0d0202ea773427d948609aeac5..d5de62d10edb0ddcfb7790febe494f937317f6e9 100644 --- a/apps/cpu/poiseuille_example/poiseuille.cpp +++ b/apps/cpu/poiseuille_example/poiseuille.cpp @@ -25,7 +25,7 @@ int main() const auto lbmUnitConverter = std::make_shared<LBMUnitConverter>(); const auto writer = WbWriterVtkXmlBinary::getInstance(); - const auto communicator = MPICommunicator::getInstance(); + const auto communicator = vf::mpi::MPICommunicator::getInstance(); const auto kernel = std::make_shared<CompressibleCumulant4thOrderViscosityLBMKernel>(); kernel->setBCProcessor(std::make_shared<BCProcessor>()); kernel->setForcingX1(1e-6 * lbmUnitConverter->getFactorForceWToLb()); diff --git a/apps/cpu/porplate2/porplate.cpp b/apps/cpu/porplate2/porplate.cpp index 109f0b3f75396dcf2d3d410f22fb5da76016344d..2414e07732b18cac8a8c7c61b276f007c16826ef 100644 --- a/apps/cpu/porplate2/porplate.cpp +++ b/apps/cpu/porplate2/porplate.cpp @@ -316,7 +316,7 @@ void run(const char *cstr, bool firststart) stringstream logFilename; double availMem = 0; - CommunicatorPtr comm = MPICommunicator::getInstance(); + CommunicatorPtr comm = vf::mpi::MPICommunicator::getInstance(); int myid = comm->getProcessID(); string machine = string(cstr); @@ -384,9 +384,9 @@ void run(const char *cstr, bool firststart) ///////////////Knotenabmessungen: int nx[3], blocknx[3]; - nx[0] = 90;//240;//120;//60;//86;//43;//65;//50; //länge + nx[0] = 90;//240;//120;//60;//86;//43;//65;//50; //l�nge nx[1] = 2;//2;//6;///1;//5;// //breite - nx[2] = 30;//64;//32;//18;//5;//15;//15; //höhe gebiet + nx[2] = 30;//64;//32;//18;//5;//15;//15; //h�he gebiet blocknx[0] = 16;//10;//6; blocknx[1] = 16;//10;//6; blocknx[2] = 16;//10;//6; @@ -394,11 +394,11 @@ void run(const char *cstr, bool firststart) int baseLevel = 0; int refineLevel = 5; - double H = 600.0; // Kanalhöhe [mm] + double H = 600.0; // Kanalh�he [mm] double cdx = H / (double)(nx[2] * blocknx[2]); double fdx = cdx / double(1 << refineLevel); - //double h = 200.0; // gewünschte Plattenhöhe in Gitterpunkten + //double h = 200.0; // gew�nschte Plattenh�he in Gitterpunkten //double fdx = plate->getLengthX3()/h; //double cdx = fdx*double(1<<refineLevel); @@ -413,7 +413,7 @@ void run(const char *cstr, bool firststart) // Re = 1000000 // V = 16.05 # m / s // p = 994.7 #hPa(manuell abgelesen von MUB) - // T = 21.78 #°C + // T = 21.78 #�C // Luftfeuchte = 50.5 # % ////////////////////////////////////////////////////////////////////////// // Simulation Parametr @@ -421,7 +421,7 @@ void run(const char *cstr, bool firststart) double Re = 1e6; // 1133333.3333333335; double rhoLB = 0.0; double uLB = 0.1; - double lReal = 1000; //Plattenlänge in mm + double lReal = 1000; //Plattenl�nge in mm double nuLB = (uLB*(lReal / cdx)) / Re; int sizeSP = 4; diff --git a/apps/cpu/rheometer/rheometer.cpp b/apps/cpu/rheometer/rheometer.cpp index 3c7907d3b1bc13547d64abd2180657d20b250704..c972d8fec3da4c6d4191948c7fcaafc9f061d13b 100644 --- a/apps/cpu/rheometer/rheometer.cpp +++ b/apps/cpu/rheometer/rheometer.cpp @@ -40,7 +40,7 @@ void bflow(string configname) //outputPath = outputPath + "/rheometerBingham_" + config.getValue<string>("resolution") + "_" + config.getValue<string>("OmegaLB"); - SPtr<Communicator> comm = MPICommunicator::getInstance(); + SPtr<vf::mpi::Communicator> comm = vf::mpi::MPICommunicator::getInstance(); int myid = comm->getProcessID(); if (logToFile) diff --git a/apps/cpu/sbone/sbone.cpp b/apps/cpu/sbone/sbone.cpp index 845994925ff18b01189898ad59ebdaab9d851f65..321396da68d290946c16b36955cc1be98c10cf84 100644 --- a/apps/cpu/sbone/sbone.cpp +++ b/apps/cpu/sbone/sbone.cpp @@ -23,7 +23,7 @@ void sbonepd(const char *configname) throw exceptionText; } - CommunicatorPtr comm = MPICommunicator::getInstance(); + CommunicatorPtr comm = vf::mpi::MPICommunicator::getInstance(); int myid = comm->getProcessID(); if(machine == "BOMBADIL") @@ -71,8 +71,8 @@ void sbonepd(const char *configname) LBMReal rho_LB = 0.0; //nueWasser = 1e-6 m^2/s double nu_real = 1e-6; - LBMReal dt = 5e-8; // s (frei gewählt) - //dx - frei gewählt + LBMReal dt = 5e-8; // s (frei gew�hlt) + //dx - frei gew�hlt // LBMReal nu_LB = nu_real/(dx*dx/dt); diff --git a/apps/cpu/screw/screw.cpp b/apps/cpu/screw/screw.cpp index 099ae784987b4c829a00018e712df690b0660c38..c1eea3f960cf6b4b64757843d08d126e4fac14b9 100644 --- a/apps/cpu/screw/screw.cpp +++ b/apps/cpu/screw/screw.cpp @@ -29,7 +29,7 @@ int main(int argc, char* argv[]) int restartStep = config.getValue<int>("restartStep"); - SPtr<Communicator> comm = MPICommunicator::getInstance(); + SPtr<vf::mpi::Communicator> comm = vf::mpi::MPICommunicator::getInstance(); int myid = comm->getProcessID(); SPtr<LBMUnitConverter> conv = SPtr<LBMUnitConverter>(new LBMUnitConverter()); diff --git a/apps/cpu/sphere/sphere.cpp b/apps/cpu/sphere/sphere.cpp index 3b725f98cf62b5c987cbbde9f0698b5d9bc337c1..5ab9a2a70f59273c326d7757faf13e4e338c6614 100644 --- a/apps/cpu/sphere/sphere.cpp +++ b/apps/cpu/sphere/sphere.cpp @@ -9,7 +9,7 @@ void run(string configname) { try { - SPtr<Communicator> comm = MPICommunicator::getInstance(); + SPtr<vf::mpi::Communicator> comm = vf::mpi::MPICommunicator::getInstance(); int myid = comm->getProcessID(); diff --git a/apps/cpu/stick/stick.cpp b/apps/cpu/stick/stick.cpp index 058b767fcae53286428dad0858b42158b1113ae0..62efec8098241d440a2b2292ca5018fea915fe4e 100644 --- a/apps/cpu/stick/stick.cpp +++ b/apps/cpu/stick/stick.cpp @@ -19,7 +19,7 @@ void main() int numOfThreads = 4; double availMem = 10e9; - CommunicatorPtr comm = MPICommunicator::getInstance(); + CommunicatorPtr comm = vf::mpi::MPICommunicator::getInstance(); int myid = comm->getProcessID(); double dx = 1; diff --git a/apps/cpu/teperm/teperm.cpp b/apps/cpu/teperm/teperm.cpp index 51638fa26e5675e69bf9e6ce23950f6cf9a47ec6..aecdb3745f3da37c03b07eb7b103374a99df4302 100644 --- a/apps/cpu/teperm/teperm.cpp +++ b/apps/cpu/teperm/teperm.cpp @@ -63,7 +63,7 @@ void run(string configname) int chunk = config.getValue<int>("chunk"); - SPtr<Communicator> comm = MPICommunicator::getInstance(); + SPtr<vf::mpi::Communicator> comm = vf::mpi::MPICommunicator::getInstance(); int myid = comm->getProcessID(); if (logToFile) diff --git a/apps/cpu/town/town.cpp b/apps/cpu/town/town.cpp index 8f9b97857625939606874b1d539a01e8b54bb52e..ccaf90f8d277df9e16a5e3592eafa649e142d235 100644 --- a/apps/cpu/town/town.cpp +++ b/apps/cpu/town/town.cpp @@ -18,7 +18,7 @@ void run(const char *cstr1, const char *cstr2) stringstream logFilename; double availMem = 0; - CommunicatorPtr comm = MPICommunicator::getInstance(); + CommunicatorPtr comm = vf::mpi::MPICommunicator::getInstance(); int myid = comm->getProcessID(); string machine = string(cstr1); diff --git a/apps/gpu/GKS/Flame7cm/CMakeLists.txt b/apps/gpu/GKS/Flame7cm/CMakeLists.txt index c3f57dcdd8c9ea9e8ba891d72c039f5acdfc9cf9..75ca5fa4b4e9c51724d32a3733559b9489ce7943 100644 --- a/apps/gpu/GKS/Flame7cm/CMakeLists.txt +++ b/apps/gpu/GKS/Flame7cm/CMakeLists.txt @@ -1,6 +1,5 @@ -PROJECT(Flame7cm) +PROJECT(Flame7cm LANGUAGES CUDA CXX) -vf_add_library(BUILDTYPE binary PRIVATE_LINK basics GridGenerator GksMeshAdapter GksVtkAdapter GksGpu FILES Flame7cm.cpp ) +vf_add_library(BUILDTYPE binary PRIVATE_LINK basics GridGenerator GksMeshAdapter GksVtkAdapter GksGpu MPI::MPI_CXX FILES Flame7cm.cpp ) -include (${VF_CMAKE_DIR}/3rd/cuda.cmake) -include (${VF_CMAKE_DIR}/3rd/mpi.cmake) +set_source_files_properties(Flame7cm.cpp PROPERTIES LANGUAGE CUDA) diff --git a/apps/gpu/GKS/Flame7cm/Flame7cm.cpp b/apps/gpu/GKS/Flame7cm/Flame7cm.cpp index e0b736dfe5fb1be1a038bfb4ea6ad88b570f5951..4323ce5ae3bf8486a2203adec470e0d1fdc05a70 100644 --- a/apps/gpu/GKS/Flame7cm/Flame7cm.cpp +++ b/apps/gpu/GKS/Flame7cm/Flame7cm.cpp @@ -152,11 +152,10 @@ void thermalCavity( std::string path, std::string simulationName, uint _gpuIndex //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - auto gridFactory = GridFactory::make(); - gridFactory->setGridStrategy(Device::CPU); - gridFactory->setTriangularMeshDiscretizationMethod(TriangularMeshDiscretizationMethod::POINT_IN_OBJECT); + // auto gridFactory = GridFactory::make(); + // gridFactory->setTriangularMeshDiscretizationMethod(TriangularMeshDiscretizationMethod::POINT_IN_OBJECT); - auto gridBuilder = MultipleGridBuilder::makeShared(gridFactory); + auto gridBuilder = MultipleGridBuilder::makeShared(); //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -476,14 +475,14 @@ int main( int argc, char* argv[]) { thermalCavity( path, simulationName, gpuIndex, nx, useTempLimiter, restartIter ); } - catch (const std::exception& e) - { - *logging::out << logging::Logger::LOGGER_ERROR << e.what() << "\n"; - } catch (const std::bad_alloc& e) { *logging::out << logging::Logger::LOGGER_ERROR << "Bad Alloc:" << e.what() << "\n"; } + catch (const std::exception& e) + { + *logging::out << logging::Logger::LOGGER_ERROR << e.what() << "\n"; + } catch (...) { *logging::out << logging::Logger::LOGGER_ERROR << "Unknown exception!\n"; diff --git a/apps/gpu/LBM/ActuatorLine/ActuatorLine.cpp b/apps/gpu/LBM/ActuatorLine/ActuatorLine.cpp new file mode 100644 index 0000000000000000000000000000000000000000..6be64950710c53b3c7931180a9beb1368a615fe3 --- /dev/null +++ b/apps/gpu/LBM/ActuatorLine/ActuatorLine.cpp @@ -0,0 +1,252 @@ + +#define _USE_MATH_DEFINES +#include <math.h> +#include <string> +#include <sstream> +#include <iostream> +#include <stdexcept> +#include <fstream> +#include <exception> +#include <memory> + +////////////////////////////////////////////////////////////////////////// + +#include "Core/DataTypes.h" +#include "PointerDefinitions.h" + +#include "Core/StringUtilities/StringUtil.h" + +#include "Core/VectorTypes.h" + +#include <basics/config/ConfigurationFile.h> + +#include <logger/Logger.h> + + +////////////////////////////////////////////////////////////////////////// + +#include "GridGenerator/grid/GridBuilder/LevelGridBuilder.h" +#include "GridGenerator/grid/GridBuilder/MultipleGridBuilder.h" +#include "GridGenerator/grid/BoundaryConditions/Side.h" +#include "GridGenerator/grid/GridFactory.h" + +#include "GridGenerator/io/SimulationFileWriter/SimulationFileWriter.h" +#include "GridGenerator/io/GridVTKWriter/GridVTKWriter.h" +#include "GridGenerator/io/STLReaderWriter/STLReader.h" +#include "GridGenerator/io/STLReaderWriter/STLWriter.h" + +////////////////////////////////////////////////////////////////////////// + +#include "VirtualFluids_GPU/LBM/Simulation.h" +#include "VirtualFluids_GPU/Communication/Communicator.h" +#include "VirtualFluids_GPU/DataStructureInitializer/GridReaderGenerator/GridGenerator.h" +#include "VirtualFluids_GPU/DataStructureInitializer/GridProvider.h" +#include "VirtualFluids_GPU/DataStructureInitializer/GridReaderFiles/GridReader.h" +#include "VirtualFluids_GPU/Parameter/Parameter.h" +#include "VirtualFluids_GPU/Output/FileWriter.h" +#include "VirtualFluids_GPU/PreCollisionInteractor/ActuatorLine.h" +#include "VirtualFluids_GPU/PreCollisionInteractor/Probes/PointProbe.h" +#include "VirtualFluids_GPU/PreCollisionInteractor/Probes/PlaneProbe.h" + +#include "VirtualFluids_GPU/Kernel/Utilities/KernelFactory/KernelFactoryImp.h" +#include "VirtualFluids_GPU/PreProcessor/PreProcessorFactory/PreProcessorFactoryImp.h" + +#include "VirtualFluids_GPU/GPU/CudaMemoryManager.h" + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// +// U s e r s e t t i n g s +// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +LbmOrGks lbmOrGks = LBM; + +const real reference_diameter = 126.0; // diameter in m + +const real L_x = 10*reference_diameter; +const real L_y = 6*reference_diameter; +const real L_z = 6*reference_diameter; + +const real viscosity = 1.56e-5; + +const real velocity = 9.0; + +const real mach = 0.1; + +const uint nodes_per_diameter = 16; + +std::string path("."); + +std::string simulationName("ActuatorLine"); + +const float tOut = 100; +const float tEnd = 280; // total time of simulation in s +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +void multipleLevel(const std::string& configPath) +{ + + logging::Logger::addStream(&std::cout); + logging::Logger::setDebugLevel(logging::Logger::Level::INFO_LOW); + logging::Logger::timeStamp(logging::Logger::ENABLE); + logging::Logger::enablePrintedRankNumbers(logging::Logger::ENABLE); + + auto gridFactory = GridFactory::make(); + gridFactory->setTriangularMeshDiscretizationMethod(TriangularMeshDiscretizationMethod::POINT_IN_OBJECT); + auto gridBuilder = MultipleGridBuilder::makeShared(gridFactory); + + //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + const real dx = reference_diameter/real(nodes_per_diameter); + + gridBuilder->addCoarseGrid(0.0, 0.0, 0.0, + L_x, L_y, L_z, dx); + + gridBuilder->setPeriodicBoundaryCondition(false, false, false); + + gridBuilder->buildGrids(lbmOrGks, false); // buildGrids() has to be called before setting the BCs!!!! + + //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + vf::gpu::Communicator& communicator = vf::gpu::Communicator::getInstance(); + + vf::basics::ConfigurationFile config; + config.load(configPath); + ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////^ + SPtr<Parameter> para = std::make_shared<Parameter>(config, communicator.getNummberOfProcess(), communicator.getPID()); + + //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + const real dt = dx * mach / (sqrt(3) * velocity); + + const real velocityLB = velocity * dt / dx; // LB units + + const real viscosityLB = viscosity * dt / (dx * dx); // LB units + + VF_LOG_INFO("velocity [dx/dt] = {}", velocityLB); + VF_LOG_INFO("viscosity [10^8 dx^2/dt] = {}", viscosityLB*1e8); + + //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + para->setDevices(std::vector<uint>{(uint)0}); + + para->setOutputPrefix( simulationName ); + + para->setFName(para->getOutputPath() + "/" + para->getOutputPrefix()); + + para->setPrintFiles(true); + + para->setMaxLevel(1); + + + para->setVelocity(velocityLB); + para->setViscosity(viscosityLB); + para->setVelocityRatio( dx / dt ); + para->setViscosityRatio( dx*dx/dt ); + para->setMainKernel("CumulantK17CompChim"); + + para->setInitialCondition([&](real coordX, real coordY, real coordZ, real &rho, real &vx, real &vy, real &vz) { + rho = (real)0.0; + vx = velocityLB; + vy = (real)0.0; + vz = (real)0.0; + }); + + para->setTOut( uint(tOut/dt) ); + para->setTEnd( uint(tEnd/dt) ); + + para->setIsBodyForce( true ); + + + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + gridBuilder->setVelocityBoundaryCondition(SideType::MX, velocityLB, 0.0, 0.0); + + gridBuilder->setVelocityBoundaryCondition(SideType::MY, velocityLB, 0.0, 0.0); + gridBuilder->setVelocityBoundaryCondition(SideType::PY, velocityLB, 0.0, 0.0); + gridBuilder->setVelocityBoundaryCondition(SideType::MZ, velocityLB, 0.0, 0.0); + gridBuilder->setVelocityBoundaryCondition(SideType::PZ, velocityLB, 0.0, 0.0); + gridBuilder->setPressureBoundaryCondition(SideType::PX, 0.0); + + //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + SPtr<CudaMemoryManager> cudaMemoryManager = CudaMemoryManager::make(para); + + SPtr<GridProvider> gridGenerator = GridProvider::makeGridGenerator(gridBuilder, para, cudaMemoryManager); + + real turbPos[3] = {3*reference_diameter, 3*reference_diameter, 3*reference_diameter}; + real epsilon = 5.f; // width of gaussian smearing + real density = 1.225f; + int level = 0; + uint nBlades = 3; + uint nBladeNodes = 32; + + SPtr<ActuatorLine> actuator_line =SPtr<ActuatorLine>( new ActuatorLine(nBlades, density, nBladeNodes, epsilon, turbPos[0], turbPos[1], turbPos[2], reference_diameter, level, dt, dx) ); + para->addActuator( actuator_line ); + + SPtr<PointProbe> pointProbe = SPtr<PointProbe>( new PointProbe("pointProbe", para->getOutputPath(), 100, 1, 500, 100) ); + std::vector<real> probeCoordsX = {reference_diameter,2*reference_diameter,5*reference_diameter}; + std::vector<real> probeCoordsY = {3*reference_diameter,3*reference_diameter,3*reference_diameter}; + std::vector<real> probeCoordsZ = {3*reference_diameter,3*reference_diameter,3*reference_diameter}; + pointProbe->addProbePointsFromList(probeCoordsX, probeCoordsY, probeCoordsZ); + // pointProbe->addProbePointsFromXNormalPlane(2*D, 0.0, 0.0, L_y, L_z, (uint)L_y/dx, (uint)L_z/dx); + pointProbe->addPostProcessingVariable(PostProcessingVariable::Means); + pointProbe->addPostProcessingVariable(PostProcessingVariable::Variances); + para->addProbe( pointProbe ); + + SPtr<PlaneProbe> planeProbe = SPtr<PlaneProbe>( new PlaneProbe("planeProbe", para->getOutputPath(), 100, 500, 100) ); + planeProbe->setProbePlane(5*reference_diameter, 0, 0, dx, L_y, L_z); + planeProbe->addPostProcessingVariable(PostProcessingVariable::Means); + para->addProbe( planeProbe ); + + + + + Simulation sim(communicator); + SPtr<FileWriter> fileWriter = SPtr<FileWriter>(new FileWriter()); + SPtr<KernelFactoryImp> kernelFactory = KernelFactoryImp::getInstance(); + SPtr<PreProcessorFactoryImp> preProcessorFactory = PreProcessorFactoryImp::getInstance(); + sim.setFactories(kernelFactory, preProcessorFactory); + sim.init(para, gridGenerator, fileWriter, cudaMemoryManager); + sim.run(); + sim.free(); +} + +int main( int argc, char* argv[]) +{ + if ( argv != NULL ) + { + try + { + vf::logging::Logger::initalizeLogger(); + + if( argc > 1){ path = argv[1]; } + + multipleLevel(path + "/configActuatorLine.txt"); + } + catch (const spdlog::spdlog_ex &ex) { + std::cout << "Log initialization failed: " << ex.what() << std::endl; + } + + catch (const std::bad_alloc& e) + { + VF_LOG_CRITICAL("Bad Alloc: {}", e.what()); + } + catch (const std::exception& e) + { + VF_LOG_CRITICAL("exception: {}", e.what()); + } + catch (...) + { + VF_LOG_CRITICAL("Unknown exception!"); + } + } + return 0; +} diff --git a/apps/gpu/LBM/ActuatorLine/CMakeLists.txt b/apps/gpu/LBM/ActuatorLine/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..e0ff4e06e83a957be6966a7322ff06a0d068d18a --- /dev/null +++ b/apps/gpu/LBM/ActuatorLine/CMakeLists.txt @@ -0,0 +1,7 @@ +PROJECT(ActuatorLine LANGUAGES CUDA CXX) + +vf_add_library(BUILDTYPE binary PRIVATE_LINK basics VirtualFluids_GPU GridGenerator MPI::MPI_CXX FILES ActuatorLine.cpp) + +set_source_files_properties(ActuatorLine.cpp PROPERTIES LANGUAGE CUDA) + +set_target_properties(ActuatorLine PROPERTIES CUDA_SEPARABLE_COMPILATION ON) diff --git a/apps/gpu/LBM/ActuatorLine/configActuatorLine.txt b/apps/gpu/LBM/ActuatorLine/configActuatorLine.txt new file mode 100644 index 0000000000000000000000000000000000000000..233994f0d32a48190d84f7044500e24b06b926a9 --- /dev/null +++ b/apps/gpu/LBM/ActuatorLine/configActuatorLine.txt @@ -0,0 +1,8 @@ +################################################## +#informations for Writing +################################################## +Path = . +################################################## +#informations for reading +################################################## +GridPath=. diff --git a/apps/gpu/LBM/BoundaryLayer/BoundaryLayer.cpp b/apps/gpu/LBM/BoundaryLayer/BoundaryLayer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..c440bd14cf46ca8dae8013b5c0a480109924f7c4 --- /dev/null +++ b/apps/gpu/LBM/BoundaryLayer/BoundaryLayer.cpp @@ -0,0 +1,270 @@ + +#define _USE_MATH_DEFINES +#include <math.h> +#include <string> +#include <sstream> +#include <iostream> +#include <stdexcept> +#include <fstream> +#include <exception> +#include <memory> + +////////////////////////////////////////////////////////////////////////// + +#include "Core/DataTypes.h" +#include "PointerDefinitions.h" + +#include "Core/StringUtilities/StringUtil.h" + +#include "Core/VectorTypes.h" + +#include <basics/config/ConfigurationFile.h> + +#include <logger/Logger.h> + + +////////////////////////////////////////////////////////////////////////// + +#include "GridGenerator/grid/GridBuilder/LevelGridBuilder.h" +#include "GridGenerator/grid/GridBuilder/MultipleGridBuilder.h" +#include "GridGenerator/grid/BoundaryConditions/Side.h" +#include "GridGenerator/grid/GridFactory.h" + +#include "GridGenerator/io/SimulationFileWriter/SimulationFileWriter.h" +#include "GridGenerator/io/GridVTKWriter/GridVTKWriter.h" +#include "GridGenerator/io/STLReaderWriter/STLReader.h" +#include "GridGenerator/io/STLReaderWriter/STLWriter.h" + +////////////////////////////////////////////////////////////////////////// + +#include "VirtualFluids_GPU/LBM/Simulation.h" +#include "VirtualFluids_GPU/Communication/Communicator.h" +#include "VirtualFluids_GPU/DataStructureInitializer/GridReaderGenerator/GridGenerator.h" +#include "VirtualFluids_GPU/DataStructureInitializer/GridProvider.h" +#include "VirtualFluids_GPU/DataStructureInitializer/GridReaderFiles/GridReader.h" +#include "VirtualFluids_GPU/Parameter/Parameter.h" +#include "VirtualFluids_GPU/Output/FileWriter.h" +#include "VirtualFluids_GPU/PreCollisionInteractor/ActuatorLine.h" +#include "VirtualFluids_GPU/PreCollisionInteractor/Probes/PointProbe.h" +#include "VirtualFluids_GPU/PreCollisionInteractor/Probes/PlaneProbe.h" +#include "VirtualFluids_GPU/PreCollisionInteractor/Probes/PlanarAverageProbe.h" +#include "VirtualFluids_GPU/PreCollisionInteractor/Probes/WallModelProbe.h" + +#include "VirtualFluids_GPU/Kernel/Utilities/KernelFactory/KernelFactoryImp.h" +#include "VirtualFluids_GPU/PreProcessor/PreProcessorFactory/PreProcessorFactoryImp.h" + +#include "VirtualFluids_GPU/GPU/CudaMemoryManager.h" + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +std::string path("."); + +std::string simulationName("BoundayLayer"); + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + +void multipleLevel(const std::string& configPath) +{ + + logging::Logger::addStream(&std::cout); + logging::Logger::setDebugLevel(logging::Logger::Level::INFO_LOW); + logging::Logger::timeStamp(logging::Logger::ENABLE); + logging::Logger::enablePrintedRankNumbers(logging::Logger::ENABLE); + + auto gridFactory = GridFactory::make(); + auto gridBuilder = MultipleGridBuilder::makeShared(gridFactory); + + //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + vf::gpu::Communicator& communicator = vf::gpu::Communicator::getInstance(); + + vf::basics::ConfigurationFile config; + config.load(configPath); + ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////^ + SPtr<Parameter> para = std::make_shared<Parameter>(config, communicator.getNummberOfProcess(), communicator.getPID()); + + //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // + // U s e r s e t t i n g s + // + //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + LbmOrGks lbmOrGks = LBM; + + const real H = 1000.0; // boundary layer height in m + + const real L_x = 6*H; + const real L_y = 4*H; + const real L_z = 1*H; + + const real z0 = 0.1; // roughness length in m + const real u_star = 0.4; //friction velocity in m/s + const real kappa = 0.4; // von Karman constant + + const real viscosity = 1.56e-5; + + const real velocity = 0.5*u_star/kappa*log(L_z/z0); //0.5 times max mean velocity at the top in m/s + + const real mach = config.contains("Ma")? config.getValue<real>("Ma"): 0.1; + + const uint nodes_per_H = config.contains("nz")? config.getValue<uint>("nz"): 64; + + // all in s + const float tStartOut = config.getValue<real>("tStartOut"); + const float tOut = config.getValue<real>("tOut"); + const float tEnd = config.getValue<real>("tEnd"); // total time of simulation + + const float tStartAveraging = config.getValue<real>("tStartAveraging"); + const float tStartTmpAveraging = config.getValue<real>("tStartTmpAveraging"); + const float tAveraging = config.getValue<real>("tAveraging"); + const float tStartOutProbe = config.getValue<real>("tStartOutProbe"); + const float tOutProbe = config.getValue<real>("tOutProbe"); + + + const real dx = L_z/real(nodes_per_H); + + const real dt = dx * mach / (sqrt(3) * velocity); + + const real velocityLB = velocity * dt / dx; // LB units + + const real viscosityLB = viscosity * dt / (dx * dx); // LB units + + const real pressureGradient = u_star * u_star / H ; + const real pressureGradientLB = pressureGradient * (dt*dt)/dx; // LB units + + VF_LOG_INFO("velocity [dx/dt] = {}", velocityLB); + VF_LOG_INFO("dt = {}", dt); + VF_LOG_INFO("dx = {}", dx); + VF_LOG_INFO("viscosity [10^8 dx^2/dt] = {}", viscosityLB*1e8); + VF_LOG_INFO("u* /(dx/dt) = {}", u_star*dt/dx); + VF_LOG_INFO("dpdx = {}", pressureGradient); + VF_LOG_INFO("dpdx /(dx/dt^2) = {}", pressureGradientLB); + + //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + para->setOutputPrefix( simulationName ); + + para->setFName(para->getOutputPath() + "/" + para->getOutputPrefix()); + + para->setPrintFiles(true); + + para->setForcing(pressureGradientLB, 0, 0); + para->setVelocity(velocityLB); + para->setViscosity(viscosityLB); + para->setVelocityRatio( dx / dt ); + para->setViscosityRatio( dx*dx/dt ); + para->setDensityRatio( 1.0 ); + + if(para->getUseAMD()) + para->setMainKernel("TurbulentViscosityCumulantK17CompChim"); + else + para->setMainKernel("CumulantK17CompChim"); + + para->setIsBodyForce( config.getValue<bool>("bodyForce") ); + + para->setTStartOut(uint(tStartOut/dt) ); + para->setTOut( uint(tOut/dt) ); + para->setTEnd( uint(tEnd/dt) ); + + // para->setTOut( 100 ); + // para->setTEnd( 100000 ); + + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + gridBuilder->addCoarseGrid(0.0, 0.0, 0.0, + L_x, L_y, L_z, dx); + // gridBuilder->setNumberOfLayers(0,0); + // gridBuilder->addGrid( new Cuboid( 300., 300., 300., 1000. , 1000., 600.), 1 ); + + gridBuilder->setPeriodicBoundaryCondition(true, true, false); + + gridBuilder->buildGrids(lbmOrGks, false); // buildGrids() has to be called before setting the BCs!!!! + + uint samplingOffset = 2; + // gridBuilder->setVelocityBoundaryCondition(SideType::MZ, 0.0, 0.0, 0.0); + gridBuilder->setStressBoundaryCondition(SideType::MZ, + 0.0, 0.0, 1.0, // wall normals + samplingOffset, z0/dx); // wall model settinng + para->setHasWallModelMonitor(true); + + + // gridBuilder->setVelocityBoundaryCondition(SideType::PZ, 0.0, 0.0, 0.0); + gridBuilder->setSlipBoundaryCondition(SideType::PZ, 0.0, 0.0, 0.0); + + real cPi = 3.1415926535897932384626433832795; + para->setInitialCondition([&](real coordX, real coordY, real coordZ, real &rho, real &vx, real &vy, real &vz) { + rho = (real)0.0; + vx = (u_star/0.4 * log(coordZ/z0) + 2.0*sin(cPi*16.0f*coordX/L_x)*sin(cPi*8.0f*coordZ/H)/(pow(coordZ/H,c2o1)+c1o1)) * dt / dx; + vy = 2.0*sin(cPi*16.0f*coordX/L_x)*sin(cPi*8.0f*coordZ/H)/(pow(coordZ/H,c2o1)+c1o1) * dt / dx; + vz = 8.0*u_star/0.4*(sin(cPi*8.0*coordY/H)*sin(cPi*8.0*coordZ/H)+sin(cPi*8.0*coordX/L_x))/(pow(L_z/2.0-coordZ, c2o1)+c1o1) * dt / dx; + }); + //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + SPtr<CudaMemoryManager> cudaMemoryManager = CudaMemoryManager::make(para); + + SPtr<GridProvider> gridGenerator = GridProvider::makeGridGenerator(gridBuilder, para, cudaMemoryManager); + + SPtr<PlanarAverageProbe> planarAverageProbe = SPtr<PlanarAverageProbe>( new PlanarAverageProbe("planeProbe", para->getOutputPath(), tStartAveraging/dt, tStartTmpAveraging/dt, tAveraging/dt , tStartOutProbe/dt, tOutProbe/dt, 'z') ); + planarAverageProbe->addAllAvailableStatistics(); + planarAverageProbe->setFileNameToNOut(); + para->addProbe( planarAverageProbe ); + + para->setHasWallModelMonitor(true); + SPtr<WallModelProbe> wallModelProbe = SPtr<WallModelProbe>( new WallModelProbe("wallModelProbe", para->getOutputPath(), tStartAveraging/dt, tStartTmpAveraging/dt, tAveraging/dt/4.0 , tStartOutProbe/dt, tOutProbe/dt) ); + wallModelProbe->addAllAvailableStatistics(); + wallModelProbe->setFileNameToNOut(); + wallModelProbe->setForceOutputToStress(true); + if(para->getIsBodyForce()) + wallModelProbe->setEvaluatePressureGradient(true); + para->addProbe( wallModelProbe ); + + Simulation sim(communicator); + SPtr<FileWriter> fileWriter = SPtr<FileWriter>(new FileWriter()); + SPtr<KernelFactoryImp> kernelFactory = KernelFactoryImp::getInstance(); + SPtr<PreProcessorFactoryImp> preProcessorFactory = PreProcessorFactoryImp::getInstance(); + sim.setFactories(kernelFactory, preProcessorFactory); + sim.init(para, gridGenerator, fileWriter, cudaMemoryManager); + sim.run(); + sim.free(); +} + +int main( int argc, char* argv[]) +{ + if ( argv != NULL ) + { + try + { + vf::logging::Logger::initalizeLogger(); + + if( argc > 1){ path = argv[1]; } + + multipleLevel(path + "/configBoundaryLayer.txt"); + } + catch (const spdlog::spdlog_ex &ex) { + std::cout << "Log initialization failed: " << ex.what() << std::endl; + } + + catch (const std::bad_alloc& e) + { + VF_LOG_CRITICAL("Bad Alloc: {}", e.what()); + } + catch (const std::exception& e) + { + VF_LOG_CRITICAL("exception: {}", e.what()); + } + catch (...) + { + VF_LOG_CRITICAL("Unknown exception!"); + } + } + return 0; +} diff --git a/apps/gpu/LBM/BoundaryLayer/CMakeLists.txt b/apps/gpu/LBM/BoundaryLayer/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..801b634803943d48abda690935df0867eb3418d2 --- /dev/null +++ b/apps/gpu/LBM/BoundaryLayer/CMakeLists.txt @@ -0,0 +1,7 @@ +PROJECT(BoundaryLayer LANGUAGES CUDA CXX) + +vf_add_library(BUILDTYPE binary PRIVATE_LINK basics VirtualFluids_GPU GridGenerator MPI::MPI_CXX FILES BoundaryLayer.cpp) + +set_source_files_properties(BoundaryLayer.cpp PROPERTIES LANGUAGE CUDA) + +set_target_properties(BoundaryLayer PROPERTIES CUDA_SEPARABLE_COMPILATION ON) diff --git a/apps/gpu/LBM/BoundaryLayer/configBoundaryLayer.txt b/apps/gpu/LBM/BoundaryLayer/configBoundaryLayer.txt new file mode 100644 index 0000000000000000000000000000000000000000..a489f0ab89738a193b16fee41c212a5943f6525d --- /dev/null +++ b/apps/gpu/LBM/BoundaryLayer/configBoundaryLayer.txt @@ -0,0 +1,30 @@ +################################################## +#informations for Writing +################################################## +Path = . +################################################## +#informations for reading +################################################## +GridPath = . +################################################## +Devices = 1 +################################################## +tStartOut = 0 +tOut = 100000 +tEnd = 300000 +################################################## +tStartAveraging = 0 +tStartTmpAveraging = 100000 +tAveraging = 200 +tStartOutProbe = 0 +tOutProbe = 1000 +################################################## +Ma = 0.1 +nz = 96 + +bodyForce = true +UseAMD = true +SGSconstant = 0.2 +QuadricLimiterP = 100000.0 +QuadricLimiterM = 100000.0 +QuadricLimiterD = 100000.0 diff --git a/apps/gpu/LBM/DrivenCavity/DrivenCavity.cpp b/apps/gpu/LBM/DrivenCavity/DrivenCavity.cpp index 710d5c87fcf05cbe27747f50d8685b9f3467fe17..9f31c9358620331dd45dd1ff1a32f29b677a6d13 100644 --- a/apps/gpu/LBM/DrivenCavity/DrivenCavity.cpp +++ b/apps/gpu/LBM/DrivenCavity/DrivenCavity.cpp @@ -10,21 +10,19 @@ #include <memory> #include <filesystem> -#include "mpi.h" - ////////////////////////////////////////////////////////////////////////// #include "Core/DataTypes.h" #include "PointerDefinitions.h" -#include "Core/LbmOrGks.h" #include "Core/StringUtilities/StringUtil.h" #include "Core/VectorTypes.h" -#include "Core/Logger/Logger.h" #include <basics/config/ConfigurationFile.h> +#include <logger/Logger.h> + ////////////////////////////////////////////////////////////////////////// #include "GridGenerator/grid/GridBuilder/LevelGridBuilder.h" @@ -97,6 +95,8 @@ const real dt = (real)1.0e-3; //0.5e-3; const uint nx = 64; +std::string path("D:/out/DrivenCavity/new"); + std::string simulationName("DrivenCavityChim"); const uint timeStepOut = 10000; @@ -114,9 +114,7 @@ void multipleLevel(const std::string& configPath) logging::Logger::enablePrintedRankNumbers(logging::Logger::ENABLE); auto gridFactory = GridFactory::make(); - gridFactory->setGridStrategy(Device::CPU); gridFactory->setTriangularMeshDiscretizationMethod(TriangularMeshDiscretizationMethod::POINT_IN_OBJECT); - auto gridBuilder = MultipleGridBuilder::makeShared(gridFactory); //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -125,8 +123,18 @@ void multipleLevel(const std::string& configPath) real dx = L / real(nx); - gridBuilder->addCoarseGrid(-0.5 * L, -0.5 * L, -0.5 * L, - 0.5 * L, 0.5 * L, 0.5 * L, dx); + //gridBuilder->addCoarseGrid(-0.5 * L, -0.5 * L, -0.5 * L, + // 0.5 * L, 0.5 * L, 0.5 * L, dx); + + gridBuilder->addCoarseGrid(-2.0 * dx, -0.5 * L, -0.5 * L, + 2.0 * dx, 0.5 * L, 0.5 * L, dx); + + auto refBox = new Cuboid(-0.1 * L, -0.1 * L, -0.1 * L, + 0.1 * L, 0.1 * L, 0.1 * L); + + gridBuilder->addGrid(refBox, 1); + + gridBuilder->setNumberOfLayers(0, 0); gridBuilder->setPeriodicBoundaryCondition(false, false, false); @@ -145,12 +153,12 @@ void multipleLevel(const std::string& configPath) { //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - vf::gpu::Communicator* comm = vf::gpu::Communicator::getInstanz(); + vf::gpu::Communicator& communicator = vf::gpu::Communicator::getInstance(); vf::basics::ConfigurationFile config; config.load(configPath); - SPtr<Parameter> para = std::make_shared<Parameter>(config, comm->getNummberOfProcess(), comm->getPID()); + SPtr<Parameter> para = std::make_shared<Parameter>(config, communicator.getNummberOfProcess(), communicator.getPID()); //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -161,20 +169,22 @@ void multipleLevel(const std::string& configPath) const real viscosityLB = nx * velocityLB / Re; // LB units - *logging::out << logging::Logger::INFO_HIGH << "velocity [dx/dt] = " << velocityLB << " \n"; - *logging::out << logging::Logger::INFO_HIGH << "viscosity [dx^2/dt] = " << viscosityLB << "\n"; + VF_LOG_INFO("velocity [dx/dt] = {}", velocityLB); + VF_LOG_INFO("viscosity [dx^2/dt] = {}", viscosityLB); //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// para->setDevices(std::vector<uint>{(uint)0}); + para->setOutputPath( path ); + para->setOutputPrefix( simulationName ); para->setFName(para->getOutputPath() + "/" + para->getOutputPrefix()); para->setPrintFiles(true); - para->setMaxLevel(1); + para->setMaxLevel(2); para->setVelocity(velocityLB); para->setViscosity(viscosityLB); @@ -204,11 +214,15 @@ void multipleLevel(const std::string& configPath) //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + gridBuilder->writeGridsToVtk(path + "/grid/"); + + //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + SPtr<CudaMemoryManager> cudaMemoryManager = CudaMemoryManager::make(para); SPtr<GridProvider> gridGenerator = GridProvider::makeGridGenerator(gridBuilder, para, cudaMemoryManager); - Simulation sim; + Simulation sim(communicator); SPtr<FileWriter> fileWriter = SPtr<FileWriter>(new FileWriter()); SPtr<KernelFactoryImp> kernelFactory = KernelFactoryImp::getInstance(); SPtr<PreProcessorFactoryImp> preProcessorFactory = PreProcessorFactoryImp::getInstance(); @@ -336,29 +350,31 @@ void multipleLevel(const std::string& configPath) int main( int argc, char* argv[]) { - MPI_Init(&argc, &argv); - try { + vf::logging::Logger::initalizeLogger(); + // assuming that the config files is stored parallel to this file. std::filesystem::path filePath = __FILE__; filePath.replace_filename("configDrivenCavity.txt"); - multipleLevel(filePath.string()); - } + multipleLevel(filePath.string()); + } + catch (const spdlog::spdlog_ex &ex) { + std::cout << "Log initialization failed: " << ex.what() << std::endl; + } catch (const std::bad_alloc& e) { - *logging::out << logging::Logger::LOGGER_ERROR << "Bad Alloc:" << e.what() << "\n"; + VF_LOG_CRITICAL("Bad Alloc: {}", e.what()); } catch (const std::exception& e) { - *logging::out << logging::Logger::LOGGER_ERROR << e.what() << "\n"; + VF_LOG_CRITICAL("exception: {}", e.what()); } catch (...) { - *logging::out << logging::Logger::LOGGER_ERROR << "Unknown exception!\n"; + VF_LOG_CRITICAL("Unknown exception!"); } - MPI_Finalize(); return 0; } diff --git a/apps/gpu/LBM/WTG_RUB/WTG_RUB.cpp b/apps/gpu/LBM/WTG_RUB/WTG_RUB.cpp index 2539bcd5f15be627f35f30ac04f43e5c3da28937..62abfd7fc286baf68d0051b5b6b58f89e35a3cc3 100644 --- a/apps/gpu/LBM/WTG_RUB/WTG_RUB.cpp +++ b/apps/gpu/LBM/WTG_RUB/WTG_RUB.cpp @@ -54,6 +54,7 @@ #include "VirtualFluids_GPU/GPU/CudaMemoryManager.h" +#include <logger/Logger.h> //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -67,7 +68,7 @@ LbmOrGks lbmOrGks = LBM; -const real L = 1.0; +// const real L = 1.0; const real velocity = 1.0; @@ -82,7 +83,8 @@ std::string simulationName(""); // 1: original setup of Lennard Lux (6 level, 4.0 cm -> 1.25 mm) // 2: setup 1 of MSch (4 level, 1.0 cm -> 1.25 mm) // 3: setup 2 of MSch (5 level, 1.6 cm -> 1.0 mm) -int setupDomain = 3; +// 4: setup 3 of MSch (small/test) (3 level, 4.0 cm -> 1.0 cm) +int setupDomain = 4; // std::string path("D:/out/WTG_RUB"); // Mollok // std::string inputPath("D:/out/WTG_RUB/input/"); @@ -90,7 +92,7 @@ int setupDomain = 3; std::string path("/workspaces/VirtualFluids_dev/output/WTG_RUB_Results/"); // Aragorn std::string inputPath("/workspaces/VirtualFluids_dev/stl/WTG_RUB/"); -const uint timeStepStartOut = 0; +// const uint timeStepStartOut = 0; const uint timeStepOut = 10000; const uint timeStepEnd = 100000; @@ -113,9 +115,7 @@ void multipleLevel(const std::string& configPath) logging::Logger::enablePrintedRankNumbers(logging::Logger::ENABLE); auto gridFactory = GridFactory::make(); - gridFactory->setGridStrategy(Device::CPU); gridFactory->setTriangularMeshDiscretizationMethod(TriangularMeshDiscretizationMethod::POINT_IN_OBJECT); - auto gridBuilder = MultipleGridBuilder::makeShared(gridFactory); //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -130,15 +130,19 @@ void multipleLevel(const std::string& configPath) maxLevel = 5; viscosityLB = (real)3.75e-06; // LB units } else if (setupDomain == 2) { - dx = (real)1; + dx = (real)1; maxLevel = 3; viscosityLB = (real)1.5e-05; // LB units } else if (setupDomain == 3) { dx = (real)1.6; maxLevel = 4; viscosityLB = (real)9.375e-06; // LB units + } else if (setupDomain == 4) { + dx = (real)4.0; + maxLevel = 2; + viscosityLB = (real)3.75e-06; // LB units } - + real x_min = 0.0; real x_max = 1250.0; real y_min = 0.0; @@ -160,18 +164,18 @@ void multipleLevel(const std::string& configPath) // MeasurePoints [MP01-15: lvl maxLevel],[MP16-41: lvl 1]; disable when reducing numberOfLevels --> dx might be too // large if MP01-15 are used with low resolution dx, MPs might be placed in solid City-geometry - bool useMP = true; + bool useMP = false;//true; bool measureVeloProfilesOnly = false; // Two Components: true->DiffOn, false->DiffOff - bool diffOnOff = false; + // bool diffOnOff = false; // Resetting diff or flow field, e.g. after restart, do not reset diff/flow at start of measureRun ;-) - bool reset_diff = true; - bool reset_flow = true; + // bool reset_diff = false; + bool reset_flow = false; //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - gridBuilder->addCoarseGrid(x_min, y_min, z_min, + gridBuilder->addCoarseGrid(x_min, y_min, z_min, x_max, y_max, z_max, dx); gridBuilder->setNumberOfLayers(0, 0); @@ -194,12 +198,12 @@ void multipleLevel(const std::string& configPath) //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - vf::gpu::Communicator* comm = vf::gpu::Communicator::getInstanz(); + vf::gpu::Communicator& communicator = vf::gpu::Communicator::getInstance(); vf::basics::ConfigurationFile config; config.load(configPath); - SPtr<Parameter> para = std::make_shared<Parameter>(config, comm->getNummberOfProcess(), comm->getPID()); + SPtr<Parameter> para = std::make_shared<Parameter>(config, communicator.getNummberOfProcess(), communicator.getPID()); //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// const real velocityLB = (real)0.0844; // LB units @@ -330,7 +334,7 @@ void multipleLevel(const std::string& configPath) SPtr<GridProvider> gridGenerator = GridProvider::makeGridGenerator(gridBuilder, para, cudaMemoryManager); - Simulation sim; + Simulation sim (communicator); SPtr<FileWriter> fileWriter = SPtr<FileWriter>(new FileWriter()); SPtr<KernelFactoryImp> kernelFactory = KernelFactoryImp::getInstance(); SPtr<PreProcessorFactoryImp> preProcessorFactory = PreProcessorFactoryImp::getInstance(); @@ -476,7 +480,7 @@ void addFineGrids(SPtr<MultipleGridBuilder> gridBuilder, uint &maxLevel, real &r } } } - } + } else if (setupDomain == 3) { ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////*/ // creates Cuboids (FG1 to FG2, lvl 1 to lvl 2) and add STLs (FG3 to FG4, lvl 3 to lvl 4) depending on maxLevel @@ -490,19 +494,19 @@ void addFineGrids(SPtr<MultipleGridBuilder> gridBuilder, uint &maxLevel, real &r // FG4 -> dx = 1.0 mm; lvl 4 // //// FineGrid Level 1 ->dx = 8.0 mm; lvl 1 - //auto FG1 = new Cuboid(-20, -20, -5 + z_offset, 800, 200, 75 + z_offset); + // auto FG1 = new Cuboid(-20, -20, -5 + z_offset, 800, 200, 75 + z_offset); // FineGrid Level 1 -> dx = 8.0 mm; lvl 1 auto FG1_1 = new Cuboid(-20, -20, -5 + z_offset, 780, 200, 30 + z_offset); - auto FG1_2 = new Cuboid(500, -20, 5 + z_offset, 720, 210, 75 + z_offset); - auto FG1 = new Conglomerate(); + auto FG1_2 = new Cuboid(500, -20, 5 + z_offset, 720, 210, 75 + z_offset); + auto FG1 = new Conglomerate(); FG1->add(FG1_1); FG1->add(FG1_2); // FineGrid Level 2 -> dx = 4.0 mm; lvl 2 auto FG2_1 = new Cuboid(-20, -20, -5 + z_offset, 760, 200, 10 + z_offset); - auto FG2_2 = new Cuboid(520, -20, 5 + z_offset, 700, 210, 50 + z_offset); - auto FG2 = new Conglomerate(); + auto FG2_2 = new Cuboid(520, -20, 5 + z_offset, 700, 210, 50 + z_offset); + auto FG2 = new Conglomerate(); FG2->add(FG2_1); FG2->add(FG2_2); @@ -534,6 +538,34 @@ void addFineGrids(SPtr<MultipleGridBuilder> gridBuilder, uint &maxLevel, real &r } } } + else if (setupDomain == 4) { + ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////*/ + // creates Cuboids (FG1 to FG2, lvl 1 to lvl 2) depending on + // maxLevel and rotationOfCity; also adds FineGrids(FGs) to gridbuilder + + // GridList(CG = coarse grid, fg = fine grid) + // CG -> dx = 4 cm; lvl 0 + // FG1 -> dx = 2 cm; lvl 1 + // FG2 -> dx = 1 cm; lvl 2 + // + // FineGrid Level 1 ->dx = 2 cm; lvl 1 + auto FG1 = new Cuboid(-20, -20, -5 + z_offset, 800, 200, 75 + z_offset); + + // FineGrid Level 2 -> dx = 1 cm; lvl 2 + auto FG2_1 = new Cuboid(-20, -20, -5 + z_offset, 760, 200, 10 + z_offset); + auto FG2_2 = new Cuboid(500, -20, 5 + z_offset, 680, 210, 50 + z_offset); + auto FG2 = new Conglomerate(); + FG2->add(FG2_1); + FG2->add(FG2_2); + + // Adding FineGrids 1 to 2 depending on maxLevel + if (maxLevel >= 1) { + gridBuilder->addGrid(FG1, 1); + if (maxLevel >= 2) { + gridBuilder->addGrid(FG2, 2); + } + } + } @@ -724,31 +756,31 @@ std::string chooseVariation() int main( int argc, char* argv[]) { - MPI_Init(&argc, &argv); - if ( argv != NULL ) + try { - try - { - // assuming that the config files is stored parallel to this file. - std::filesystem::path filePath = __FILE__; - filePath.replace_filename("configDrivenCavity.txt"); + vf::logging::Logger::initalizeLogger(); - multipleLevel(filePath.string()); - } - catch (const std::bad_alloc& e) - { - *logging::out << logging::Logger::LOGGER_ERROR << "Bad Alloc:" << e.what() << "\n"; - } - catch (const std::exception& e) - { - *logging::out << logging::Logger::LOGGER_ERROR << e.what() << "\n"; - } - catch (...) - { - *logging::out << logging::Logger::LOGGER_ERROR << "Unknown exception!\n"; - } + // assuming that the config files is stored parallel to this file. + std::filesystem::path filePath = __FILE__; + filePath.replace_filename("configDrivenCavity.txt"); + + multipleLevel(filePath.string()); + } + catch (const spdlog::spdlog_ex &ex) { + std::cout << "Log initialization failed: " << ex.what() << std::endl; + } + catch (const std::bad_alloc& e) + { + VF_LOG_CRITICAL("Bad Alloc: {}", e.what()); + } + catch (const std::exception& e) + { + VF_LOG_CRITICAL("exception: {}", e.what()); + } + catch (...) + { + VF_LOG_CRITICAL("Unknown exception!"); } - MPI_Finalize(); return 0; } diff --git a/cpu.cmake b/cpu.cmake index 397d54c3a142e2237804609754b5b18d7e069f70..a6220ec1ffb9641b824ee26b8be8497ea340173f 100644 --- a/cpu.cmake +++ b/cpu.cmake @@ -23,7 +23,6 @@ #ENDIF() SET(USE_METIS ON CACHE BOOL "include METIS library support") -SET(USE_MPI ON CACHE BOOL "include MPI library support") SET(USE_VTK OFF CACHE BOOL "include VTK library support") SET(USE_CATALYST OFF CACHE BOOL "include Paraview Catalyst support") @@ -50,9 +49,6 @@ ENDIF() IF(${USE_METIS}) list(APPEND VF_COMPILER_DEFINITION VF_METIS) ENDIF() -IF(${USE_MPI}) - list(APPEND VF_COMPILER_DEFINITION VF_MPI) -ENDIF() IF(${USE_VTK}) list(APPEND VF_COMPILER_DEFINITION VF_VTK) ENDIF() @@ -84,9 +80,7 @@ add_subdirectory(${VF_THIRD_DIR}/MuParser) add_subdirectory(src/cpu/VirtualFluidsCore) if(BUILD_VF_PYTHON_BINDINGS) - add_subdirectory(${VF_THIRD_DIR}/pybind11/pybind11-2.6.0) add_subdirectory(src/cpu/simulationconfig) - add_subdirectory(src/cpu/pythonbindings) endif() set (APPS_ROOT_CPU "${VF_ROOT_DIR}/apps/cpu/") diff --git a/gpu.cmake b/gpu.cmake index af4bdca383f1314820adeaf0c6738feeb7c004f4..ad9d844278c1df76dde8c212ea7472f07cd6d471 100644 --- a/gpu.cmake +++ b/gpu.cmake @@ -1,11 +1,3 @@ - - -if(BUILD_NUMERIC_TESTS) - set(CMAKE_CXX_STANDARD 17) -endif() - -############################################################# - IF( BUILD_VF_GKS ) # only use this with device of CC larger than 6.0 set(CMAKE_CUDA_FLAGS "-Xptxas=\"-v\"" CACHE STRING "" FORCE) @@ -44,10 +36,12 @@ IF (BUILD_VF_GPU) #add_subdirectory(apps/gpu/LBM/gridGeneratorTest) #add_subdirectory(apps/gpu/LBM/TGV_3D) #add_subdirectory(apps/gpu/LBM/TGV_3D_MultiGPU) - add_subdirectory(apps/gpu/LBM/SphereScaling) + #add_subdirectory(apps/gpu/LBM/SphereScaling) #add_subdirectory(apps/gpu/LBM/DrivenCavityMultiGPU) #add_subdirectory(apps/gpu/LBM/MusselOyster) #add_subdirectory(apps/gpu/LBM/Poiseuille) + #add_subdirectory(apps/gpu/LBM/ActuatorLine) + add_subdirectory(apps/gpu/LBM/BoundaryLayer) ELSE() MESSAGE( STATUS "exclude Virtual Fluids GPU." ) ENDIF() @@ -141,4 +135,4 @@ endif() if(BUILD_VF_TRAFFIC) add_subdirectory(src/gpu/Traffic) add_subdirectory(apps/gpu/LBM/TrafficTest) -endif() \ No newline at end of file +endif() diff --git a/pythonbindings/CMakeLists.txt b/pythonbindings/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..5a84adef027fdfa2953e016693bb64570e48c1ef --- /dev/null +++ b/pythonbindings/CMakeLists.txt @@ -0,0 +1,24 @@ +project(VirtualFluidsPython LANGUAGES CUDA CXX) +IF(BUILD_VF_GPU) + pybind11_add_module(pyfluids src/VirtualFluidsModulesGPU.cpp) + set_source_files_properties(src/VirtualFluidsModulesGPU.cpp PROPERTIES LANGUAGE CUDA) + + target_link_libraries(pyfluids PRIVATE GridGenerator VirtualFluids_GPU basics lbmCuda logger) + target_include_directories(pyfluids PRIVATE ${VF_THIRD_DIR}/cuda_samples/) + +ENDIF() +IF(BUILD_VF_CPU) + pybind11_add_module(pyfluids src/VirtualFluidsModulesCPU.cpp) + pybind11_add_module(pymuparser src/muParser.cpp) + + # TODO: Move this to MuParser CMakeLists.txt + set_target_properties(muparser PROPERTIES POSITION_INDEPENDENT_CODE ON) + + target_compile_definitions(pyfluids PRIVATE VF_METIS VF_MPI) + target_compile_definitions(pymuparser PRIVATE VF_METIS VF_MPI) + + target_link_libraries(pyfluids PRIVATE simulationconfig VirtualFluidsCore muparser basics) + target_link_libraries(pymuparser PRIVATE muparser) +ENDIF() +target_include_directories(pyfluids PRIVATE ${CMAKE_SOURCE_DIR}/src/) +target_include_directories(pyfluids PRIVATE ${CMAKE_BINARY_DIR}) \ No newline at end of file diff --git a/pythonbindings/src/VirtualFluidsModulesCPU.cpp b/pythonbindings/src/VirtualFluidsModulesCPU.cpp new file mode 100644 index 0000000000000000000000000000000000000000..2fba3da494f568f7d0d0a117a579a45c9c1b9245 --- /dev/null +++ b/pythonbindings/src/VirtualFluidsModulesCPU.cpp @@ -0,0 +1,12 @@ +#include <pybind11/pybind11.h> +#include "cpu/cpu.cpp" + +namespace py_bindings +{ + namespace py = pybind11; + + PYBIND11_MODULE(pyfluids, m) + { + cpu::makeModule(m); + } +} \ No newline at end of file diff --git a/pythonbindings/src/VirtualFluidsModulesGPU.cpp b/pythonbindings/src/VirtualFluidsModulesGPU.cpp new file mode 100644 index 0000000000000000000000000000000000000000..b96971caf381faada76ee676cf60469492d055c2 --- /dev/null +++ b/pythonbindings/src/VirtualFluidsModulesGPU.cpp @@ -0,0 +1,19 @@ +#include <pybind11/pybind11.h> +#include "basics/basics.cpp" +#include "lbm/lbm.cpp" +#include "gpu/gpu.cpp" +#include "logger/logger.cpp" + +namespace py_bindings +{ + namespace py = pybind11; + + PYBIND11_MODULE(pyfluids, m) + { + basics::makeModule(m); + gpu::makeModule(m); + lbm::makeModule(m); + logging::makeModule(m); + py::add_ostream_redirect(m, "ostream_redirect"); + } +} \ No newline at end of file diff --git a/pythonbindings/src/basics/basics.cpp b/pythonbindings/src/basics/basics.cpp new file mode 100644 index 0000000000000000000000000000000000000000..381e345d78226b25ec3a77a14340d2ef1171c8c9 --- /dev/null +++ b/pythonbindings/src/basics/basics.cpp @@ -0,0 +1,20 @@ +#include <pybind11/pybind11.h> +#include "submodules/logger.cpp" +#include "submodules/configuration_file.cpp" +#include "submodules/lbm_or_gks.cpp" + +namespace basics +{ + namespace py = pybind11; + + py::module makeModule(py::module_ &parentModule) + { + py::module basicsModule = parentModule.def_submodule("basics"); + + logger::makeModule(basicsModule); + configuration::makeModule(basicsModule); + lbmOrGks::makeModule(basicsModule); + + return basicsModule; + } +} \ No newline at end of file diff --git a/pythonbindings/src/basics/submodules/configuration_file.cpp b/pythonbindings/src/basics/submodules/configuration_file.cpp new file mode 100644 index 0000000000000000000000000000000000000000..f5a2f87135a17f5eda34a7467d95f9db6b1c21d1 --- /dev/null +++ b/pythonbindings/src/basics/submodules/configuration_file.cpp @@ -0,0 +1,14 @@ +#include <pybind11/pybind11.h> +#include <basics/config/ConfigurationFile.h> + +namespace configuration +{ + namespace py = pybind11; + + void makeModule(py::module_ &parentModule) + { + py::class_<vf::basics::ConfigurationFile>(parentModule, "ConfigurationFile") + .def(py::init<>()) + .def("load", &vf::basics::ConfigurationFile::load); + } +} \ No newline at end of file diff --git a/pythonbindings/src/basics/submodules/lbm_or_gks.cpp b/pythonbindings/src/basics/submodules/lbm_or_gks.cpp new file mode 100644 index 0000000000000000000000000000000000000000..ed1deeca62fc57b7f44499b306e9f99b7f990604 --- /dev/null +++ b/pythonbindings/src/basics/submodules/lbm_or_gks.cpp @@ -0,0 +1,14 @@ +#include <pybind11/pybind11.h> +#include "basics/Core/LbmOrGks.h" + +namespace lbmOrGks +{ + namespace py = pybind11; + + void makeModule(py::module_ &parentModule) + { + py::enum_<LbmOrGks>(parentModule, "LbmOrGks") + .value("LBM", LbmOrGks::LBM) + .value("GKS", LbmOrGks::GKS); + } +} \ No newline at end of file diff --git a/pythonbindings/src/basics/submodules/logger.cpp b/pythonbindings/src/basics/submodules/logger.cpp new file mode 100644 index 0000000000000000000000000000000000000000..d46648e349b44243581e083f3561e8a13648f3b2 --- /dev/null +++ b/pythonbindings/src/basics/submodules/logger.cpp @@ -0,0 +1,36 @@ +#include <pybind11/pybind11.h> +#include <pybind11/iostream.h> +#include <basics/Core/Logger/Logger.h> +#include <basics/Core/Logger/implementations/LoggerImp.h> + +namespace logger +{ + namespace py = pybind11; + + py::module makeModule(py::module_ &parentModule) + { + py::module loggerModule = parentModule.def_submodule("logger"); + + py::class_<logging::Logger>(loggerModule, "Logger") + .def("add_stdout", [](){ + logging::Logger::addStream(&std::cout); + }) + .def("set_debug_level", &logging::Logger::setDebugLevel) + .def("time_stamp", &logging::Logger::timeStamp) + .def("enable_printed_rank_numbers", &logging::Logger::enablePrintedRankNumbers); + + loggerModule.attr("log") = logging::out; + py::enum_<logging::Logger::Level>(loggerModule, "Level") + .value("INFO_LOW", logging::Logger::Level::INFO_LOW) + .value("INFO_INTERMEDIATE", logging::Logger::Level::INFO_INTERMEDIATE) + .value("INFO_HIGH", logging::Logger::Level::INFO_HIGH) + .value("WARNING", logging::Logger::Level::WARNING) + .value("LOGGER_ERROR", logging::Logger::Level::LOGGER_ERROR); + + py::enum_<logging::Logger::TimeStamp>(loggerModule, "TimeStamp") + .value("ENABLE", logging::Logger::TimeStamp::ENABLE) + .value("DISABLE", logging::Logger::TimeStamp::DISABLE); + + return loggerModule; + } +} \ No newline at end of file diff --git a/pythonbindings/src/cpu/cpu.cpp b/pythonbindings/src/cpu/cpu.cpp new file mode 100644 index 0000000000000000000000000000000000000000..554de53b47446366693aed31d534f6145ebea8ba --- /dev/null +++ b/pythonbindings/src/cpu/cpu.cpp @@ -0,0 +1,23 @@ +#include <pybind11/pybind11.h> +#include "submodules/boundaryconditions.cpp" +#include "submodules/simulationconfig.cpp" +#include "submodules/geometry.cpp" +#include "submodules/kernel.cpp" +#include "submodules/simulationparameters.cpp" +#include "submodules/writer.cpp" + +namespace cpu +{ + namespace py = pybind11; + py::module makeModule(py::module_ &parentModule) + { + py::module cpuModule = parentModule.def_submodule("cpu"); + boundaryconditions::makeModule(cpuModule); + simulation::makeModule(cpuModule); + geometry::makeModule(cpuModule); + kernel::makeModule(cpuModule); + parameters::makeModule(cpuModule); + writer::makeModule(cpuModule); + return cpuModule; + } +} \ No newline at end of file diff --git a/pythonbindings/src/cpu/submodules/boundaryconditions.cpp b/pythonbindings/src/cpu/submodules/boundaryconditions.cpp new file mode 100644 index 0000000000000000000000000000000000000000..3bff7bc069ca20fe1c0cf3d1847b9714e0381505 --- /dev/null +++ b/pythonbindings/src/cpu/submodules/boundaryconditions.cpp @@ -0,0 +1,64 @@ +#include <pybind11/pybind11.h> +#include <pybind11/stl.h> +#include <BoundaryConditions/DensityBCAdapter.h> +#include <BoundaryConditions/NonReflectingOutflowBCAlgorithm.h> +#include <BoundaryConditions/BCAdapter.h> +#include <BoundaryConditions/NoSlipBCAdapter.h> +#include <BoundaryConditions/VelocityBCAdapter.h> +#include <BoundaryConditions/NoSlipBCAlgorithm.h> +#include <BoundaryConditions/VelocityBCAlgorithm.h> +#include <BoundaryConditions/HighViscosityNoSlipBCAlgorithm.h> + +namespace boundaryconditions +{ + namespace py = pybind11; + using namespace py::literals; + + template<class adapter, class algorithm, + class = std::enable_if_t<std::is_base_of<BCAdapter, adapter>::value>, + class = std::enable_if_t<std::is_base_of<BCAlgorithm, algorithm>::value>> + class PyBoundaryCondition : public adapter + { + public: + template<typename ...Args> + PyBoundaryCondition(Args &&... args) : adapter(std::forward<Args>(args)...) + { + this->setBcAlgorithm(std::make_shared<algorithm>()); + } + }; + + template<class adapter, class algorithm> + using bc_class = py::class_<PyBoundaryCondition<adapter, algorithm>, BCAdapter, + std::shared_ptr<PyBoundaryCondition<adapter, algorithm>>>; + + void makeModule(py::module_ &parentModule) + { + py::module_ bcModule = parentModule.def_submodule("boundaryconditions"); + + auto _ = py::class_<BCAdapter, std::shared_ptr<BCAdapter>>(bcModule, "BCAdapter"); + + bc_class<NoSlipBCAdapter, NoSlipBCAlgorithm>(bcModule, "NoSlipBoundaryCondition") + .def(py::init()); + + bc_class<NoSlipBCAdapter, HighViscosityNoSlipBCAlgorithm>(bcModule, "HighViscosityNoSlipBoundaryCondition") + .def(py::init()); + + bc_class<VelocityBCAdapter, VelocityBCAlgorithm>(bcModule, "VelocityBoundaryCondition") + .def(py::init()) + .def(py::init<bool &, bool &, bool &, mu::Parser &, double &, double &>(), + "vx1"_a, "vx2"_a, "vx3"_a, + "function"_a, "start_time"_a, "end_time"_a) + .def(py::init<bool &, bool &, bool &, mu::Parser &, mu::Parser &, mu::Parser &, double &, double &>(), + "vx1"_a, "vx2"_a, "vx3"_a, + "function_vx1"_a, "function_vx2"_a, "function_vx2"_a, + "start_time"_a, "end_time"_a) + .def(py::init<double &, double &, double &, double &, double &, double &, double &, double &, double &>(), + "vx1"_a, "vx1_start_time"_a, "vx1_end_time"_a, + "vx2"_a, "vx2_start_time"_a, "vx2_end_time"_a, + "vx3"_a, "vx3_start_time"_a, "vx3_end_time"_a); + + bc_class<DensityBCAdapter, NonReflectingOutflowBCAlgorithm>(bcModule, "NonReflectingOutflow") + .def(py::init()); + } + +} \ No newline at end of file diff --git a/pythonbindings/src/cpu/submodules/geometry.cpp b/pythonbindings/src/cpu/submodules/geometry.cpp new file mode 100644 index 0000000000000000000000000000000000000000..b7ff4dd761258d41687589d2dd89c3479093753e --- /dev/null +++ b/pythonbindings/src/cpu/submodules/geometry.cpp @@ -0,0 +1,84 @@ +#include <pybind11/pybind11.h> +#include <geometry3d/GbPoint3D.h> +#include <geometry3d/GbObject3D.h> +#include <geometry3d/GbCuboid3D.h> +#include <geometry3d/GbLine3D.h> +#include <Interactors/Interactor3D.h> + + +namespace geometry +{ + namespace py = pybind11; + + template<class GeoObject> + using py_geometry = py::class_<GeoObject, GbObject3D, std::shared_ptr<GeoObject>>; + + std::string GbPoint3D_repr_(const GbPoint3D &instance) + { + std::ostringstream stream; + stream << "<GbPoint3D" + << " x1: " << instance.getX1Coordinate() + << " x2: " << instance.getX2Coordinate() + << " x3: " << instance.getX3Coordinate() << ">"; + + return stream.str(); + } + + void makeModule(py::module_ &parentModule) + { + py::module geometry = parentModule.def_submodule("geometry"); + + py::class_<GbObject3D, std::shared_ptr<GbObject3D>>(geometry, "GbObject3D"); + + py_geometry<GbPoint3D>(geometry, "GbPoint3D") + .def(py::init()) + .def(py::init<double &, double &, double &>()) + .def(py::init<GbPoint3D *>()) + .def_property("x1", &GbPoint3D::getX1Coordinate, &GbPoint3D::setX1) + .def_property("x2", &GbPoint3D::getX2Coordinate, &GbPoint3D::setX2) + .def_property("x3", &GbPoint3D::getX3Coordinate, &GbPoint3D::setX3) + .def("get_distance", &GbPoint3D::getDistance) + .def("__repr__", &GbPoint3D_repr_); + + py_geometry<GbCuboid3D>(geometry, "GbCuboid3D") + .def(py::init()) + .def(py::init<double &, double &, double &, double &, double &, double &>()) + .def(py::init<GbPoint3D *, GbPoint3D *>()) + .def(py::init<GbCuboid3D *>()) + .def_property("point1", &GbCuboid3D::getPoint1, &GbCuboid3D::setPoint1) + .def_property("point2", &GbCuboid3D::getPoint2, &GbCuboid3D::setPoint2) + .def("__repr__", [&](GbCuboid3D &instance) + { + std::ostringstream stream; + stream << "<GbCuboid3D" << std::endl + << "point1: " << GbPoint3D_repr_(instance.getPoint1()) << std::endl + << "point2: " << GbPoint3D_repr_(instance.getPoint2()) << ">"; + return stream.str(); + }); + + py_geometry<GbLine3D>(geometry, "GbLine3D") + .def(py::init()) + .def(py::init<GbPoint3D *, GbPoint3D *>()) + .def(py::init<GbLine3D>()) + .def_property("point1", &GbLine3D::getPoint1, &GbLine3D::setPoint1) + .def_property("point2", &GbLine3D::getPoint2, &GbLine3D::setPoint2) + .def("__repr__", [&](GbLine3D &instance) + { + std::ostringstream stream; + stream << "<GbLine3D" << std::endl + << "point1: " << GbPoint3D_repr_(instance.getPoint1()) << std::endl + << "point2: " << GbPoint3D_repr_(instance.getPoint2()) << ">"; + return stream.str(); + }); + + + py::class_<Interactor3D, std::shared_ptr<Interactor3D>>(geometry, "State") + .def_readonly_static("SOLID", &Interactor3D::SOLID) + .def_readonly_static("INVERSESOLID", &Interactor3D::INVERSESOLID) + .def_readonly_static("TIMEDEPENDENT", &Interactor3D::TIMEDEPENDENT) + .def_readonly_static("FLUID", &Interactor3D::FLUID) + .def_readonly_static("MOVEABLE", &Interactor3D::MOVEABLE) + .def_readonly_static("CHANGENOTNECESSARY", &Interactor3D::CHANGENOTNECESSARY); + } + +} \ No newline at end of file diff --git a/pythonbindings/src/cpu/submodules/kernel.cpp b/pythonbindings/src/cpu/submodules/kernel.cpp new file mode 100644 index 0000000000000000000000000000000000000000..fb291790632cc2041410f60a14fca8d966283343 --- /dev/null +++ b/pythonbindings/src/cpu/submodules/kernel.cpp @@ -0,0 +1,45 @@ +#include <memory> +#include <pybind11/pybind11.h> +#include <simulationconfig/KernelFactory.h> +#include <simulationconfig/KernelConfigStructs.h> + +namespace kernel +{ + namespace py = pybind11; + + void makeModule(py::module_ &parentModule) + { + py::module kernelModule = parentModule.def_submodule("kernel"); + + py::enum_<KernelFactory::KernelType>(kernelModule, "KernelType") + .value("BGK", KernelFactory::BGK) + .value("CompressibleCumulantFourthOrderViscosity", + KernelFactory::COMPRESSIBLE_CUMULANT_4TH_ORDER_VISCOSITY); + + py::class_<LBMKernelConfiguration, std::shared_ptr<LBMKernelConfiguration>>(kernelModule, "LBMKernel") + .def(py::init<KernelFactory::KernelType>()) + .def_readwrite("type", &LBMKernelConfiguration::kernelType) + .def_readwrite("use_forcing", &LBMKernelConfiguration::useForcing) + .def_readwrite("forcing_in_x1", &LBMKernelConfiguration::forcingX1) + .def_readwrite("forcing_in_x2", &LBMKernelConfiguration::forcingX2) + .def_readwrite("forcing_in_x3", &LBMKernelConfiguration::forcingX3) + .def("set_forcing", [](LBMKernelConfiguration &kernelConfig, double x1, double x2, double x3) + { + kernelConfig.forcingX1 = x1; + kernelConfig.forcingX2 = x2; + kernelConfig.forcingX3 = x3; + }) + .def("__repr__", [](LBMKernelConfiguration &kernelConfig) + { + std::ostringstream stream; + stream << "<" << kernelConfig.kernelType << std::endl + << "Use forcing: " << kernelConfig.useForcing << std::endl + << "Forcing in x1: " << kernelConfig.forcingX1 << std::endl + << "Forcing in x2: " << kernelConfig.forcingX2 << std::endl + << "Forcing in x3: " << kernelConfig.forcingX3 << ">" << std::endl; + + return stream.str(); + }); + } + +} \ No newline at end of file diff --git a/pythonbindings/src/cpu/submodules/simulationconfig.cpp b/pythonbindings/src/cpu/submodules/simulationconfig.cpp new file mode 100644 index 0000000000000000000000000000000000000000..60af4e36af4dca67e9262dd9f5ee1f46d5b7bb58 --- /dev/null +++ b/pythonbindings/src/cpu/submodules/simulationconfig.cpp @@ -0,0 +1,22 @@ +#include <pybind11/pybind11.h> +#include <simulationconfig/Simulation.h> + +namespace simulation +{ + namespace py = pybind11; + + void makeModule(py::module_ &parentModule) + { + py::class_<Simulation, std::shared_ptr<Simulation>>(parentModule, "Simulation") + .def(py::init()) + .def("set_writer", &Simulation::setWriterConfiguration) + .def("set_grid_parameters", &Simulation::setGridParameters) + .def("set_physical_parameters", &Simulation::setPhysicalParameters) + .def("set_runtime_parameters", &Simulation::setRuntimeParameters) + .def("set_kernel_config", &Simulation::setKernelConfiguration) + .def("add_object", &Simulation::addObject) + .def("add_bc_adapter", &Simulation::addBCAdapter) + .def("run_simulation", &Simulation::run); + } + +} \ No newline at end of file diff --git a/pythonbindings/src/cpu/submodules/simulationparameters.cpp b/pythonbindings/src/cpu/submodules/simulationparameters.cpp new file mode 100644 index 0000000000000000000000000000000000000000..acc272f2ee412cfbafd9007b4b18610cfd0a1e9b --- /dev/null +++ b/pythonbindings/src/cpu/submodules/simulationparameters.cpp @@ -0,0 +1,59 @@ +#include <pybind11/pybind11.h> +#include <pybind11/stl.h> +#include <complex> +#include <simulationconfig/SimulationParameters.h> + +namespace parameters +{ + namespace py = pybind11; + + void makeModule(py::module_ &parentModule) + { + py::module parametersModule = parentModule.def_submodule("parameters"); + + py::class_<PhysicalParameters, std::shared_ptr<PhysicalParameters>>(parametersModule, "PhysicalParameters") + .def(py::init()) + .def_readwrite("bulk_viscosity_factor", &PhysicalParameters::bulkViscosityFactor, + "The viscosity of the fluid will be multiplied with this factor to calculate its bulk viscosity. Default is 1.0") + .def_readwrite("lattice_viscosity", &PhysicalParameters::latticeViscosity, "Lattice viscosity"); + + py::class_<GridParameters, std::shared_ptr<GridParameters>>(parametersModule, "GridParameters") + .def(py::init()) + .def_readwrite("node_distance", &GridParameters::nodeDistance) + .def_readwrite("reference_direction_index", &GridParameters::referenceDirectionIndex) + .def_readwrite("number_of_nodes_per_direction", &GridParameters::numberOfNodesPerDirection) + .def_readwrite("blocks_per_direction", &GridParameters::blocksPerDirection) + .def_readwrite("periodic_boundary_in_x1", &GridParameters::periodicBoundaryInX1) + .def_readwrite("periodic_boundary_in_x2", &GridParameters::periodicBoundaryInX2) + .def_readwrite("periodic_boundary_in_x3", &GridParameters::periodicBoundaryInX3) + .def_property_readonly("bounding_box", &GridParameters::boundingBox); + + py::class_<BoundingBox, std::shared_ptr<BoundingBox>>(parametersModule, "BoundingBox") + .def_readonly("min_x1", &BoundingBox::minX1) + .def_readonly("min_x2", &BoundingBox::minX2) + .def_readonly("min_x3", &BoundingBox::minX3) + .def_readonly("max_x1", &BoundingBox::maxX1) + .def_readonly("max_x2", &BoundingBox::maxX2) + .def_readonly("max_x3", &BoundingBox::maxX3) + .def("__repr__", [](BoundingBox &self) + { + std::ostringstream stream; + stream << "<BoundingBox" << std::endl + << "min x1: " << self.minX1 << std::endl + << "min x2: " << self.minX2 << std::endl + << "min x3: " << self.minX3 << std::endl + << "max x1: " << self.maxX1 << std::endl + << "max x2: " << self.maxX2 << std::endl + << "max x3: " << self.maxX3 << std::endl << ">"; + + return stream.str(); + }); + + py::class_<RuntimeParameters, std::shared_ptr<RuntimeParameters>>(parametersModule, "RuntimeParameters") + .def(py::init()) + .def_readwrite("number_of_timesteps", &RuntimeParameters::numberOfTimeSteps) + .def_readwrite("timestep_log_interval", &RuntimeParameters::timeStepLogInterval) + .def_readwrite("number_of_threads", &RuntimeParameters::numberOfThreads); + + } +} \ No newline at end of file diff --git a/pythonbindings/src/cpu/submodules/writer.cpp b/pythonbindings/src/cpu/submodules/writer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..d5ec527a27caf63d9a3066c51e1f675b307fe0b2 --- /dev/null +++ b/pythonbindings/src/cpu/submodules/writer.cpp @@ -0,0 +1,21 @@ +#include <pybind11/pybind11.h> +#include <simulationconfig/WriterConfiguration.h> + +namespace writer +{ + namespace py = pybind11; + + void makeModule(py::module_ &parentModule) + { + py::module writerModule = parentModule.def_submodule("writer"); + + py::enum_<OutputFormat>(writerModule, "OutputFormat") + .value("ASCII", OutputFormat::ASCII) + .value("BINARY", OutputFormat::BINARY); + + py::class_<WriterConfiguration>(writerModule, "Writer") + .def(py::init()) + .def_readwrite("output_path", &WriterConfiguration::outputPath) + .def_readwrite("output_format", &WriterConfiguration::outputFormat); + } +} \ No newline at end of file diff --git a/pythonbindings/src/gpu/gpu.cpp b/pythonbindings/src/gpu/gpu.cpp new file mode 100644 index 0000000000000000000000000000000000000000..1dd960dbb3ff9c9ef21cecb36e5df90e74360726 --- /dev/null +++ b/pythonbindings/src/gpu/gpu.cpp @@ -0,0 +1,40 @@ +#include <pybind11/pybind11.h> +#include "submodules/actuator_line.cpp" +#include "submodules/pre_collision_interactor.cpp" +#include "submodules/simulation.cpp" +#include "submodules/parameter.cpp" +#include "submodules/boundary_conditions.cpp" +#include "submodules/communicator.cpp" +#include "submodules/grid_builder.cpp" +#include "submodules/cuda_memory_manager.cpp" +#include "submodules/grid_provider.cpp" +#include "submodules/probes.cpp" +#include "submodules/kernel_factory.cpp" +#include "submodules/pre_processor_factory.cpp" +#include "submodules/file_writer.cpp" +#include "submodules/grid_generator.cpp" + +namespace gpu +{ + namespace py = pybind11; + + py::module makeModule(py::module_ &parentModule) + { + py::module gpuModule = parentModule.def_submodule("gpu"); + simulation::makeModule(gpuModule); + parameter::makeModule(gpuModule); + pre_collision_interactor::makeModule(gpuModule); + actuator_line::makeModule(gpuModule); + boundary_conditions::makeModule(gpuModule); + communicator::makeModule(gpuModule); + grid_builder::makeModule(gpuModule); + cuda_memory_manager::makeModule(gpuModule); + grid_provider::makeModule(gpuModule); + probes::makeModule(gpuModule); + kernel_factory::makeModule(gpuModule); + pre_processor_factory::makeModule(gpuModule); + file_writer::makeModule(gpuModule); + grid_generator::makeModule(gpuModule); + return gpuModule; + } +} \ No newline at end of file diff --git a/pythonbindings/src/gpu/submodules/actuator_line.cpp b/pythonbindings/src/gpu/submodules/actuator_line.cpp new file mode 100644 index 0000000000000000000000000000000000000000..3207fadbc37df38e53e00adcb9a86f0b8e82ba98 --- /dev/null +++ b/pythonbindings/src/gpu/submodules/actuator_line.cpp @@ -0,0 +1,72 @@ +#include <pybind11/pybind11.h> +#include <pybind11/stl.h> +#include <pybind11/numpy.h> +#include <gpu/VirtualFluids_GPU/PreCollisionInteractor/ActuatorLine.h> +#include <gpu/VirtualFluids_GPU/PreCollisionInteractor/PreCollisionInteractor.h> +class PyActuatorLine : public ActuatorLine +{ +public: + using ActuatorLine::ActuatorLine; // Inherit constructors + void calcBladeForces() override + { + PYBIND11_OVERRIDE_NAME(void, ActuatorLine, "calc_blade_forces", calcBladeForces,); + } +}; +namespace actuator_line +{ + namespace py = pybind11; + + void makeModule(py::module_ &parentModule) + { + using arr = py::array_t<float, py::array::c_style>; + + py::class_<ActuatorLine, PreCollisionInteractor, PyActuatorLine, std::shared_ptr<ActuatorLine>>(parentModule, "ActuatorLine", py::dynamic_attr()) + .def(py::init< const uint, + const real, + const uint, + const real, + real, real, real, + const real, + int, + const real, + const real>(), + "n_blades", + "density", + "n_blade_nodes", + "epsilon", + "turbine_pos_x", "turbine_pos_y", "turbine_pos_z", + "diameter", + "level", + "delta_t", + "delta_x") + .def_property("omega", &ActuatorLine::getOmega, &ActuatorLine::setOmega) + .def_property("azimuth", &ActuatorLine::getAzimuth, &ActuatorLine::setAzimuth) + .def_property("yaw", &ActuatorLine::getYaw, &ActuatorLine::setYaw) + .def_property_readonly("n_blades", &ActuatorLine::getNBlades) + .def_property_readonly("n_blade_nodes", &ActuatorLine::getNBladeNodes) + .def_property_readonly("n_nodes", &ActuatorLine::getNNodes) + .def_property_readonly("n_indices", &ActuatorLine::getNIndices) + .def_property_readonly("density", &ActuatorLine::getDensity) + .def_property_readonly("position_x", &ActuatorLine::getPositionX) + .def_property_readonly("position_y", &ActuatorLine::getPositionY) + .def_property_readonly("position_z", &ActuatorLine::getPositionZ) + .def_property_readonly("position", [](ActuatorLine& al){ real position[3] = {al.getPositionX(), al.getPositionY(), al.getPositionZ()}; return arr(3, position); } ) + .def("get_radii", [](ActuatorLine& al){ return arr(al.getNBladeNodes(), al.getBladeRadii()); } ) + .def("get_blade_coords_x", [](ActuatorLine& al){ return arr({al.getNBlades(), al.getNBladeNodes()}, al.getBladeCoordsX()); } ) + .def("get_blade_coords_y", [](ActuatorLine& al){ return arr({al.getNBlades(), al.getNBladeNodes()}, al.getBladeCoordsY()); } ) + .def("get_blade_coords_z", [](ActuatorLine& al){ return arr({al.getNBlades(), al.getNBladeNodes()}, al.getBladeCoordsZ()); } ) + .def("get_blade_velocities_x", [](ActuatorLine& al){ return arr({al.getNBlades(), al.getNBladeNodes()}, al.getBladeVelocitiesX()); } ) + .def("get_blade_velocities_y", [](ActuatorLine& al){ return arr({al.getNBlades(), al.getNBladeNodes()}, al.getBladeVelocitiesY()); } ) + .def("get_blade_velocities_z", [](ActuatorLine& al){ return arr({al.getNBlades(), al.getNBladeNodes()}, al.getBladeVelocitiesZ()); } ) + .def("get_blade_forces_x", [](ActuatorLine& al){ return arr({al.getNBlades(), al.getNBladeNodes()}, al.getBladeForcesX()); } ) + .def("get_blade_forces_y", [](ActuatorLine& al){ return arr({al.getNBlades(), al.getNBladeNodes()}, al.getBladeForcesY()); } ) + .def("get_blade_forces_z", [](ActuatorLine& al){ return arr({al.getNBlades(), al.getNBladeNodes()}, al.getBladeForcesZ()); } ) + .def("set_blade_coords", [](ActuatorLine& al, arr coordsX, arr coordsY, arr coordsZ){ + al.setBladeCoords(static_cast<float *>(coordsX.request().ptr), static_cast<float *>(coordsY.request().ptr), static_cast<float *>(coordsZ.request().ptr)); } ) + .def("set_blade_velocities", [](ActuatorLine& al, arr velocitiesX, arr velocitiesY, arr velocitiesZ){ + al.setBladeVelocities(static_cast<float *>(velocitiesX.request().ptr), static_cast<float *>(velocitiesY.request().ptr), static_cast<float *>(velocitiesZ.request().ptr)); } ) + .def("set_blade_forces", [](ActuatorLine& al, arr forcesX, arr forcesY, arr forcesZ){ + al.setBladeForces(static_cast<float *>(forcesX.request().ptr), static_cast<float *>(forcesY.request().ptr), static_cast<float *>(forcesZ.request().ptr)); } ) + .def("calc_blade_forces", &ActuatorLine::calcBladeForces); + } +} \ No newline at end of file diff --git a/pythonbindings/src/gpu/submodules/boundary_conditions.cpp b/pythonbindings/src/gpu/submodules/boundary_conditions.cpp new file mode 100644 index 0000000000000000000000000000000000000000..8f941a8705c225275d25291205ebdaeef8de5c9e --- /dev/null +++ b/pythonbindings/src/gpu/submodules/boundary_conditions.cpp @@ -0,0 +1,20 @@ +#include <pybind11/pybind11.h> +#include <gpu/GridGenerator/grid/BoundaryConditions/Side.h> + +namespace boundary_conditions +{ + namespace py = pybind11; + + void makeModule(py::module_ &parentModule) + { + py::enum_<SideType>(parentModule, "SideType") + .value("MX", SideType::MX) + .value("PX", SideType::PX) + .value("MY", SideType::MY) + .value("PY", SideType::PY) + .value("MZ", SideType::MZ) + .value("PZ", SideType::PZ) + .value("GEOMETRY", SideType::GEOMETRY) + .export_values(); + } +} \ No newline at end of file diff --git a/pythonbindings/src/gpu/submodules/communicator.cpp b/pythonbindings/src/gpu/submodules/communicator.cpp new file mode 100644 index 0000000000000000000000000000000000000000..edb36e2c2f774903590a16a0b406c721662827b1 --- /dev/null +++ b/pythonbindings/src/gpu/submodules/communicator.cpp @@ -0,0 +1,15 @@ +#include <pybind11/pybind11.h> +#include <gpu/VirtualFluids_GPU/Communication/Communicator.h> + +namespace communicator +{ + namespace py = pybind11; + + void makeModule(py::module_ &parentModule) + { + py::class_<vf::gpu::Communicator, std::unique_ptr<vf::gpu::Communicator, py::nodelete>>(parentModule, "Communicator") + .def("get_instance", &vf::gpu::Communicator::getInstance, py::return_value_policy::reference) + .def("get_number_of_process", &vf::gpu::Communicator::getNummberOfProcess) + .def("get_pid", &vf::gpu::Communicator::getPID); + } +} \ No newline at end of file diff --git a/pythonbindings/src/gpu/submodules/cuda_memory_manager.cpp b/pythonbindings/src/gpu/submodules/cuda_memory_manager.cpp new file mode 100644 index 0000000000000000000000000000000000000000..f337aeb306fd1836e5bc2962e85f45d593185836 --- /dev/null +++ b/pythonbindings/src/gpu/submodules/cuda_memory_manager.cpp @@ -0,0 +1,15 @@ +#include <pybind11/pybind11.h> +#include <gpu/VirtualFluids_GPU/GPU/CudaMemoryManager.h> +#include <gpu/VirtualFluids_GPU/Parameter/Parameter.h> + + +namespace cuda_memory_manager +{ + namespace py = pybind11; + + void makeModule(py::module_ &parentModule) + { + py::class_<CudaMemoryManager, std::shared_ptr<CudaMemoryManager>>(parentModule, "CudaMemoryManager") + .def("make", &CudaMemoryManager::make, py::return_value_policy::reference); + } +} \ No newline at end of file diff --git a/pythonbindings/src/gpu/submodules/file_writer.cpp b/pythonbindings/src/gpu/submodules/file_writer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..2ad90fe7381be215b2d257b5be99caf25db1e0ae --- /dev/null +++ b/pythonbindings/src/gpu/submodules/file_writer.cpp @@ -0,0 +1,17 @@ +#include <pybind11/pybind11.h> +#include <gpu/VirtualFluids_GPU/Output/FileWriter.h> +#include <gpu/VirtualFluids_GPU/Output/DataWriter.h> + + +namespace file_writer +{ + namespace py = pybind11; + + void makeModule(py::module_ &parentModule) + { + py::class_<DataWriter, std::shared_ptr<DataWriter>>(parentModule, "_DataWriter"); + + py::class_<FileWriter, DataWriter, std::shared_ptr<FileWriter>>(parentModule, "FileWriter") + .def(py::init<>()); + } +} \ No newline at end of file diff --git a/pythonbindings/src/gpu/submodules/grid_builder.cpp b/pythonbindings/src/gpu/submodules/grid_builder.cpp new file mode 100644 index 0000000000000000000000000000000000000000..09241f71cbe9cd013600c34e4d0a07e53a1bc79f --- /dev/null +++ b/pythonbindings/src/gpu/submodules/grid_builder.cpp @@ -0,0 +1,36 @@ +#include <pybind11/pybind11.h> +#include "gpu/GridGenerator/grid/GridBuilder/MultipleGridBuilder.h" +#include "gpu/GridGenerator/grid/GridBuilder/GridBuilder.h" +#include "gpu/GridGenerator/grid/GridBuilder/LevelGridBuilder.h" +#include "gpu/GridGenerator/geometries/Object.h" +#include "gpu/GridGenerator/grid/BoundaryConditions/Side.h" + +namespace grid_builder +{ + namespace py = pybind11; + + void makeModule(py::module_ &parentModule) + { + py::class_<GridBuilder, std::shared_ptr<GridBuilder>>(parentModule, "GridBuilder") + .def("get_number_of_grid_levels", &GridBuilder::getNumberOfGridLevels) + .def("get_grid", &GridBuilder::getGrid); + + py::class_<LevelGridBuilder, GridBuilder, std::shared_ptr<LevelGridBuilder>>(parentModule, "LevelGridBuilder") + .def("get_grid", py::overload_cast<int, int>(&LevelGridBuilder::getGrid)) + .def("set_slip_boundary_condition", &LevelGridBuilder::setSlipBoundaryCondition) + .def("set_velocity_boundary_condition", &LevelGridBuilder::setVelocityBoundaryCondition) + .def("set_pressure_boundary_condition", &LevelGridBuilder::setPressureBoundaryCondition) + .def("set_periodic_boundary_condition", &LevelGridBuilder::setPeriodicBoundaryCondition) + .def("set_no_slip_boundary_condition", &LevelGridBuilder::setNoSlipBoundaryCondition); + + py::class_<MultipleGridBuilder, LevelGridBuilder, std::shared_ptr<MultipleGridBuilder>>(parentModule, "MultipleGridBuilder") + .def("make_shared", &MultipleGridBuilder::makeShared, py::return_value_policy::reference) + .def("add_coarse_grid", &MultipleGridBuilder::addCoarseGrid) + .def("add_grid", py::overload_cast<Object*>(&MultipleGridBuilder::addGrid)) + .def("add_grid", py::overload_cast<Object*, uint>(&MultipleGridBuilder::addGrid)) + .def("add_geometry", py::overload_cast<Object*>(&MultipleGridBuilder::addGeometry)) + .def("add_geometry", py::overload_cast<Object*, uint>(&MultipleGridBuilder::addGeometry)) + .def("get_number_of_levels", &MultipleGridBuilder::getNumberOfLevels) + .def("build_grids", &MultipleGridBuilder::buildGrids); + } +} \ No newline at end of file diff --git a/pythonbindings/src/gpu/submodules/grid_generator.cpp b/pythonbindings/src/gpu/submodules/grid_generator.cpp new file mode 100644 index 0000000000000000000000000000000000000000..b9babe1d6b45f69d516a4cd57377eaa6c1b37149 --- /dev/null +++ b/pythonbindings/src/gpu/submodules/grid_generator.cpp @@ -0,0 +1,38 @@ +#include <pybind11/pybind11.h> +#include "gpu/GridGenerator/geometries/Object.h" +#include "gpu/GridGenerator/geometries/BoundingBox/BoundingBox.h" +#include "gpu/GridGenerator/geometries/Conglomerate/Conglomerate.h" +#include "gpu/GridGenerator/geometries/Cuboid/Cuboid.h" +#include "gpu/GridGenerator/geometries/Sphere/Sphere.h" +#include "gpu/GridGenerator/geometries/TriangularMesh/TriangularMesh.h" + +namespace grid_generator +{ + namespace py = pybind11; + py::module makeModule(py::module_ &parentModule) + { + py::module gridGeneratorModule = parentModule.def_submodule("grid_generator"); + + py::class_<BoundingBox>(gridGeneratorModule, "BoundingBox") + .def(py::init<real, real, real, real, real, real>(),"min_x","max_x","min_y","max_y","min_z","max_z"); + + py::class_<Object, std::shared_ptr<Object>>(gridGeneratorModule, "Object"); + + py::class_<Conglomerate, Object, std::shared_ptr<Conglomerate>>(gridGeneratorModule, "Conglomerate") + .def("make_shared", &Conglomerate::makeShared, py::return_value_policy::reference) + .def("add", &Conglomerate::add) + .def("subtract", &Conglomerate::subtract); + + py::class_<Cuboid, Object, std::shared_ptr<Cuboid>>(gridGeneratorModule, "Cuboid") + .def(py::init<const double&, const double&, const double&, const double&, const double&, const double&>(), + "min_x1", "min_x2", "min_x3", "max_x1", "max_x2", "max_x3"); + + py::class_<Sphere, Object, std::shared_ptr<Sphere>>(gridGeneratorModule, "Sphere") + .def("make_shared", &Sphere::makeShared, py::return_value_policy::reference); + + py::class_<TriangularMesh, Object, std::shared_ptr<TriangularMesh>>(gridGeneratorModule, "TriangularMesh") + .def("make", &TriangularMesh::make, py::return_value_policy::reference); + + return gridGeneratorModule; + } +} diff --git a/pythonbindings/src/gpu/submodules/grid_provider.cpp b/pythonbindings/src/gpu/submodules/grid_provider.cpp new file mode 100644 index 0000000000000000000000000000000000000000..5a5514dd8b14d24f4818740e115c8504bc973726 --- /dev/null +++ b/pythonbindings/src/gpu/submodules/grid_provider.cpp @@ -0,0 +1,16 @@ +#include <pybind11/pybind11.h> +#include "gpu/VirtualFluids_GPU/DataStructureInitializer/GridProvider.h" +#include <gpu/VirtualFluids_GPU/GPU/CudaMemoryManager.h> +#include <gpu/VirtualFluids_GPU/Parameter/Parameter.h> +#include "gpu/GridGenerator/grid/GridBuilder/GridBuilder.h" + +namespace grid_provider +{ + namespace py = pybind11; + + void makeModule(py::module_ &parentModule) + { + py::class_<GridProvider, std::shared_ptr<GridProvider>>(parentModule, "GridProvider") + .def("make_grid_generator", &GridProvider::makeGridGenerator, py::return_value_policy::reference); + } +} \ No newline at end of file diff --git a/pythonbindings/src/gpu/submodules/kernel_factory.cpp b/pythonbindings/src/gpu/submodules/kernel_factory.cpp new file mode 100644 index 0000000000000000000000000000000000000000..af710948aa75900ba9f4051360ec26dd8510118a --- /dev/null +++ b/pythonbindings/src/gpu/submodules/kernel_factory.cpp @@ -0,0 +1,16 @@ +#include <pybind11/pybind11.h> +#include <gpu/VirtualFluids_GPU/Kernel/Utilities/KernelFactory/KernelFactoryImp.h> +#include <gpu/VirtualFluids_GPU/Kernel/Utilities/KernelFactory/KernelFactory.h> + +namespace kernel_factory +{ + namespace py = pybind11; + + void makeModule(py::module_ &parentModule) + { + py::class_<KernelFactory, std::shared_ptr<KernelFactory>>(parentModule, "_KernelFactory"); + + py::class_<KernelFactoryImp, KernelFactory, std::shared_ptr<KernelFactoryImp>>(parentModule, "KernelFactory") + .def("get_instance", &KernelFactoryImp::getInstance, py::return_value_policy::reference); + } +} \ No newline at end of file diff --git a/pythonbindings/src/gpu/submodules/parameter.cpp b/pythonbindings/src/gpu/submodules/parameter.cpp new file mode 100644 index 0000000000000000000000000000000000000000..626693fd0ee32ce6866f67f54a71fe414f0f9c8e --- /dev/null +++ b/pythonbindings/src/gpu/submodules/parameter.cpp @@ -0,0 +1,72 @@ +#include <pybind11/pybind11.h> +#include <pybind11/functional.h> +#include <pybind11/stl.h> +#include <gpu/VirtualFluids_GPU/Parameter/Parameter.h> +#include <basics/config/ConfigurationFile.h> +#include <gpu/VirtualFluids_GPU/PreCollisionInteractor/PreCollisionInteractor.h> + +namespace parameter +{ + namespace py = pybind11; + + void makeModule(py::module_ &parentModule) + { + py::class_<Parameter, std::shared_ptr<Parameter>>(parentModule, "Parameter") + .def(py::init< + const vf::basics::ConfigurationFile&, + int, + int + >(), + "config_data", + "number_of_processes", + "my_ID") + .def("set_forcing", &Parameter::setForcing) + .def("set_diff_on", &Parameter::setDiffOn) + .def("set_comp_on", &Parameter::setCompOn) + .def("set_max_level", &Parameter::setMaxLevel) + .def("set_t_end", &Parameter::setTEnd) + .def("set_t_out", &Parameter::setTOut) + .def("set_t_start_out", &Parameter::setTStartOut) + .def("set_timestep_of_coarse_level", &Parameter::setTimestepOfCoarseLevel) + .def("set_output_path", &Parameter::setOutputPath) + .def("set_output_prefix", &Parameter::setOutputPrefix) + .def("set_f_name", &Parameter::setFName) + .def("set_print_files", &Parameter::setPrintFiles) + .def("set_temperature_init", &Parameter::setTemperatureInit) + .def("set_temperature_BC", &Parameter::setTemperatureBC) + .def("set_viscosity", &Parameter::setViscosity) + .def("set_velocity", &Parameter::setVelocity) + .def("set_viscosity_ratio", &Parameter::setViscosityRatio) + .def("set_velocity_ratio", &Parameter::setVelocityRatio) + .def("set_density_ratio", &Parameter::setDensityRatio) + .def("set_devices", &Parameter::setDevices) + .def("set_is_body_force", &Parameter::setIsBodyForce) + .def("set_main_kernel", &Parameter::setMainKernel) + .def("set_AD_kernel", &Parameter::setADKernel) + .def("set_use_AMD", &Parameter::setUseAMD) + .def("set_use_Wale", &Parameter::setUseWale) + .def("set_SGS_constant", &Parameter::setSGSConstant) + .def("set_initial_condition", [](Parameter ¶, std::function<std::vector<float>(real, real, real)> &init_func) + { + para.setInitialCondition([init_func](real coordX, real coordY, real coordZ, real& rho, real& vx, real& vy, real& vz) + { + std::vector<float> values = init_func(coordX, coordY, coordZ); + rho = values[0]; + vx = values[1]; + vy = values[2]; + vz = values[3]; + }); + }) + .def("add_actuator", &Parameter::addActuator) + .def("add_probe", &Parameter::addProbe) + .def("get_output_path", &Parameter::getOutputPath) + .def("get_output_prefix", &Parameter::getOutputPrefix) + .def("get_velocity", &Parameter::getVelocity) + .def("get_viscosity", &Parameter::getViscosity) + .def("get_velocity_ratio", &Parameter::getVelocityRatio) + .def("get_viscosity_ratio", &Parameter::getViscosityRatio) + .def("get_density_ratio", &Parameter::getDensityRatio) + .def("get_force_ratio", &Parameter::getForceRatio) + ; + } +} \ No newline at end of file diff --git a/pythonbindings/src/gpu/submodules/pre_collision_interactor.cpp b/pythonbindings/src/gpu/submodules/pre_collision_interactor.cpp new file mode 100644 index 0000000000000000000000000000000000000000..362ee1a8ce6112cfa9543f1b254e10f3e35822a1 --- /dev/null +++ b/pythonbindings/src/gpu/submodules/pre_collision_interactor.cpp @@ -0,0 +1,12 @@ +#include <pybind11/pybind11.h> +#include <gpu/VirtualFluids_GPU/PreCollisionInteractor/PreCollisionInteractor.h> + +namespace pre_collision_interactor +{ + namespace py = pybind11; + + void makeModule(py::module_ &parentModule) + { + py::class_<PreCollisionInteractor, std::shared_ptr<PreCollisionInteractor>>(parentModule, "PreCollisionInteractor"); + } +} \ No newline at end of file diff --git a/pythonbindings/src/gpu/submodules/pre_processor_factory.cpp b/pythonbindings/src/gpu/submodules/pre_processor_factory.cpp new file mode 100644 index 0000000000000000000000000000000000000000..b76ae285b413594847f6672e7f3fc0e656da3cec --- /dev/null +++ b/pythonbindings/src/gpu/submodules/pre_processor_factory.cpp @@ -0,0 +1,16 @@ +#include <pybind11/pybind11.h> +#include <gpu/VirtualFluids_GPU/PreProcessor/PreProcessorFactory/PreProcessorFactory.h> +#include <gpu/VirtualFluids_GPU/PreProcessor/PreProcessorFactory/PreProcessorFactoryImp.h> + +namespace pre_processor_factory +{ + namespace py = pybind11; + + void makeModule(py::module_ &parentModule) + { + py::class_<PreProcessorFactory, std::shared_ptr<PreProcessorFactory>>(parentModule, "_PreProcessorFactory"); + + py::class_<PreProcessorFactoryImp, PreProcessorFactory, std::shared_ptr<PreProcessorFactoryImp>>(parentModule, "PreProcessorFactory") + .def("get_instance", &PreProcessorFactoryImp::getInstance, py::return_value_policy::reference); + } +} \ No newline at end of file diff --git a/pythonbindings/src/gpu/submodules/probes.cpp b/pythonbindings/src/gpu/submodules/probes.cpp new file mode 100644 index 0000000000000000000000000000000000000000..9b751a513d23a8a17e4e9981ababc720fc7346b0 --- /dev/null +++ b/pythonbindings/src/gpu/submodules/probes.cpp @@ -0,0 +1,55 @@ +#include <pybind11/pybind11.h> +#include <pybind11/stl.h> +#include <gpu/VirtualFluids_GPU/PreCollisionInteractor/Probes/Probe.h> +#include <gpu/VirtualFluids_GPU/PreCollisionInteractor/Probes/PointProbe.h> +#include <gpu/VirtualFluids_GPU/PreCollisionInteractor/Probes/PlaneProbe.h> +#include <gpu/VirtualFluids_GPU/PreCollisionInteractor/PreCollisionInteractor.h> + +namespace probes +{ + namespace py = pybind11; + + py::module makeModule(py::module_ &parentModule) + { + py::module probeModule = parentModule.def_submodule("probes"); + + py::enum_<PostProcessingVariable>(probeModule, "PostProcessingVariable") + .value("Instantaneous", PostProcessingVariable::Instantaneous) + .value("Means", PostProcessingVariable::Means) + .value("Variances", PostProcessingVariable::Variances); + + py::class_<Probe, PreCollisionInteractor, std::shared_ptr<Probe>>(probeModule, "Probe") + .def("add_post_processing_variable", &Probe::addPostProcessingVariable); + + py::class_<PointProbe, Probe, std::shared_ptr<PointProbe>>(probeModule, "PointProbe") + .def(py::init< + const std::string, + const std::string, + uint, + uint, + uint>(), + "probe_name", + "output_path" + "t_start_avg", + "t_start_out", + "t_out") + .def("add_probe_points_from_list", &PointProbe::addProbePointsFromList) + .def("add_probe_points_from_x_normal_plane", &PointProbe::addProbePointsFromXNormalPlane); + + py::class_<PlaneProbe, Probe, std::shared_ptr<PlaneProbe>>(probeModule, "PlaneProbe") + .def(py::init< + const std::string, + const std::string, + uint, + uint, + uint>(), + "probe_name", + "output_path" + "t_start_avg", + "t_start_out", + "t_out") + .def("set_probe_plane", &PlaneProbe::setProbePlane); + + return probeModule; + } +} \ No newline at end of file diff --git a/pythonbindings/src/gpu/submodules/simulation.cpp b/pythonbindings/src/gpu/submodules/simulation.cpp new file mode 100644 index 0000000000000000000000000000000000000000..9683e8768417ad2422fb1a53ef6a428543bceffc --- /dev/null +++ b/pythonbindings/src/gpu/submodules/simulation.cpp @@ -0,0 +1,25 @@ +#include <pybind11/pybind11.h> +#include <gpu/VirtualFluids_GPU/LBM/Simulation.h> +#include <gpu/VirtualFluids_GPU/Communication/Communicator.h> +#include <gpu/VirtualFluids_GPU/Kernel/Utilities/KernelFactory/KernelFactory.h> +#include <gpu/VirtualFluids_GPU/PreProcessor/PreProcessorFactory/PreProcessorFactory.h> +#include <gpu/VirtualFluids_GPU/DataStructureInitializer/GridProvider.h> +#include <gpu/VirtualFluids_GPU/Parameter/Parameter.h> +#include <gpu/VirtualFluids_GPU/GPU/CudaMemoryManager.h> +#include <gpu/VirtualFluids_GPU/DataStructureInitializer/GridProvider.h> +#include <gpu/VirtualFluids_GPU/Output/DataWriter.h> + +namespace simulation +{ + namespace py = pybind11; + + void makeModule(py::module_ &parentModule) + { + py::class_<Simulation>(parentModule, "Simulation") + .def(py::init<vf::gpu::Communicator&>(), "communicator") + .def("set_factories", &Simulation::setFactories) + .def("init", &Simulation::init) + .def("run", &Simulation::run) + .def("free", &Simulation::free); + } +} \ No newline at end of file diff --git a/pythonbindings/src/lbm/lbm.cpp b/pythonbindings/src/lbm/lbm.cpp new file mode 100644 index 0000000000000000000000000000000000000000..441b9ff372f4e4513fee58c4a8a1cd78d38582dd --- /dev/null +++ b/pythonbindings/src/lbm/lbm.cpp @@ -0,0 +1,13 @@ +#include <pybind11/pybind11.h> + +namespace lbm +{ + namespace py = pybind11; + + py::module makeModule(py::module_ &parentModule) + { + py::module lbmModule = parentModule.def_submodule("lbm"); + + return lbmModule; + } +} \ No newline at end of file diff --git a/pythonbindings/src/logger/logger.cpp b/pythonbindings/src/logger/logger.cpp new file mode 100644 index 0000000000000000000000000000000000000000..82ad3d92760ae38c0eb62b16be726e4eeaca08ac --- /dev/null +++ b/pythonbindings/src/logger/logger.cpp @@ -0,0 +1,25 @@ +#include <pybind11/pybind11.h> +#include <logger/Logger.h> + +namespace logging +{ + namespace py = pybind11; + + py::module makeModule(py::module_ &parentModule) + { + py::module loggerModule = parentModule.def_submodule("logger"); + + py::class_<vf::logging::Logger>(loggerModule, "Logger") + .def("initialize_logger", &vf::logging::Logger::initalizeLogger) + .def("change_log_path", &vf::logging::Logger::changeLogPath); + + // use f-strings (f"text {float}") in python for compounded messages + loggerModule.def("vf_log_trace", [](std::string arg){ VF_LOG_TRACE(arg); }); + loggerModule.def("vf_log_debug", [](std::string arg){ VF_LOG_DEBUG(arg); }); + loggerModule.def("vf_log_info", [](std::string arg){ VF_LOG_INFO(arg); }); + loggerModule.def("vf_log_warning", [](std::string arg){ VF_LOG_WARNING(arg); }); + loggerModule.def("vf_log_critical", [](std::string arg){ VF_LOG_CRITICAL(arg); }); + + return loggerModule; + } +} // namespace logging diff --git a/src/cpu/pythonbindings/src/muParser.cpp b/pythonbindings/src/muParser.cpp similarity index 100% rename from src/cpu/pythonbindings/src/muParser.cpp rename to pythonbindings/src/muParser.cpp diff --git a/setup.py b/setup.py index ffe6663be9561a209945b91bb396254b703ae892..b26e1c13d09447d17f8e9fd6e2cd0d0671595bf3 100644 --- a/setup.py +++ b/setup.py @@ -6,23 +6,66 @@ import subprocess from setuptools import setup, Extension from setuptools.command.build_ext import build_ext +from setuptools.command.install import install +from setuptools.command.develop import develop from distutils.version import LooseVersion +""" +Install python wrapper of virtual fluids +Install GPU backend with option --GPU +(pass to pip via --install-option="--GPU") +""" + vf_cmake_args = [ "-DBUILD_VF_PYTHON_BINDINGS=ON", - "-DBUILD_VF_DOUBLE_ACCURACY=ON", "-DCMAKE_CXX_COMPILER_LAUNCHER=ccache", "-DCMAKE_CUDA_COMPILER_LAUNCHER=ccache", "-DCMAKE_C_COMPILER_LAUNCHER=ccache", - "-DBUILD_VF_CPU:BOOL=ON", - "-DBUILD_VF_GPU:BOOL=OFF", - "-DUSE_METIS=ON", - "-DUSE_MPI=ON", "-DBUILD_SHARED_LIBS=OFF", - "-DBUILD_VF_UNIT_TESTS:BOOL=ON", "-DBUILD_WARNINGS_AS_ERRORS=OFF" ] +vf_cpu_cmake_args = [ + "-DBUILD_VF_DOUBLE_ACCURACY=ON", + "-DBUILD_VF_CPU:BOOL=ON", + "-DBUILD_VF_UNIT_TESTS:BOOL=ON", + "-DUSE_METIS=ON", + "-DUSE_MPI=ON" +] + +vf_gpu_cmake_args = [ + "-DBUILD_VF_DOUBLE_ACCURACY=OFF", + "-DBUILD_VF_GPU:BOOL=ON", + "-DBUILD_VF_UNIT_TESTS:BOOL=OFF", +] + +GPU = False + +class CommandMixin: + user_options = [ + ('GPU', None, 'compile pyfluids with GPU backend'), + ] + + def initialize_options(self): + super().initialize_options() + self.GPU = False + + def finalize_options(self): + super().finalize_options() + + def run(self): + global GPU + GPU = GPU or self.GPU + super().run() + + +class InstallCommand(CommandMixin, install): + user_options = getattr(install, 'user_options', []) + CommandMixin.user_options + + +class DevelopCommand(CommandMixin, develop): + user_options = getattr(develop, 'user_options', []) + CommandMixin.user_options + class CMakeExtension(Extension): def __init__(self, name, sourcedir=''): @@ -30,8 +73,11 @@ class CMakeExtension(Extension): self.sourcedir = os.path.abspath(sourcedir) -class CMakeBuild(build_ext): +class CMakeBuild(CommandMixin, build_ext): + user_options = getattr(build_ext, 'user_options', []) + CommandMixin.user_options + def run(self): + super().run() try: out = subprocess.check_output(['cmake', '--version']) except OSError: @@ -68,12 +114,16 @@ class CMakeBuild(build_ext): build_args += ['--', '-j2'] cmake_args.extend(vf_cmake_args) + cmake_args.extend(vf_gpu_cmake_args if GPU else vf_cpu_cmake_args) env = os.environ.copy() env['CXXFLAGS'] = '{} -DVERSION_INFO=\\"{}\\"'.format(env.get('CXXFLAGS', ''), self.distribution.get_version()) if not os.path.exists(self.build_temp): os.makedirs(self.build_temp) + cmake_cache_file = self.build_temp+"/CMakeCache.txt" + if os.path.exists(cmake_cache_file): + os.remove(cmake_cache_file) subprocess.check_call(['cmake', ext.sourcedir] + cmake_args, cwd=self.build_temp, env=env) subprocess.check_call(['cmake', '--build', '.'] + build_args, cwd=self.build_temp) @@ -82,6 +132,6 @@ setup( name='pyfluids', version='0.0.1', ext_modules=[CMakeExtension('pyfluids')], - cmdclass=dict(build_ext=CMakeBuild), + cmdclass={"install": InstallCommand, "develop": DevelopCommand, "build_ext": CMakeBuild}, zip_safe=False, ) diff --git a/src/basics/CMakeLists.txt b/src/basics/CMakeLists.txt index 1703d6269c1cebe36005226373da85b14c5515f6..7f871424b2c6849d2c0f6e8d277b17214fa5cd9c 100644 --- a/src/basics/CMakeLists.txt +++ b/src/basics/CMakeLists.txt @@ -1,7 +1,7 @@ include(Core/buildInfo.cmake) -vf_add_library(PUBLIC_LINK MPI::MPI_CXX EXCLUDE buildInfo.in.cpp) +vf_add_library(PUBLIC_LINK logger MPI::MPI_CXX EXCLUDE buildInfo.in.cpp) vf_get_library_name (library_name) target_include_directories(${library_name} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/Core) diff --git a/src/basics/Core/ArrayTypes.h b/src/basics/Core/ArrayTypes.h index 7d5d70374b04d7ad29a6443fbcac0263fd8d0ad6..f899c92a7be4f29065b55b13fb1a1181da0eaf7e 100644 --- a/src/basics/Core/ArrayTypes.h +++ b/src/basics/Core/ArrayTypes.h @@ -1,3 +1,35 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids 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. +// +// VirtualFluids 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 VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file ArrayTypes.h +//! \ingroup Core +//! \author Konstantin Kutscher, Soeren Textor, Sebastian Geller +//======================================================================================= #ifndef ARRAYTYPES_H #define ARRAYTYPES_H diff --git a/src/basics/Core/DataTypes.h b/src/basics/Core/DataTypes.h index 49d269097b76cdf3ad350ed0cd65d72e6310d849..36fd33aaa0587382ce322c06b46bbb7cd0cdd8d0 100644 --- a/src/basics/Core/DataTypes.h +++ b/src/basics/Core/DataTypes.h @@ -1,3 +1,35 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids 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. +// +// VirtualFluids 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 VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file DataTypes.h +//! \ingroup Core +//! \author Soeren Peters +//======================================================================================= #ifndef DATATYPES_H #define DATATYPES_H diff --git a/src/basics/Core/Logger/Logger.cpp b/src/basics/Core/Logger/Logger.cpp index 6ee96cba58ad6a4c95e25792963027b2e53a4df7..1a27ef6f2a33bf46b9f488a4cf8d17705c2a64e6 100644 --- a/src/basics/Core/Logger/Logger.cpp +++ b/src/basics/Core/Logger/Logger.cpp @@ -1,5 +1,36 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids 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. +// +// VirtualFluids 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 VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file Logger.cpp +//! \ingroup Logger +//! \author Stephan Lenz +//======================================================================================= #include "Logger.h" -//#include "mpi.h" #include <iostream> #include <memory> diff --git a/src/basics/Core/Logger/Logger.h b/src/basics/Core/Logger/Logger.h index d0cd91938868283ec7d13faa7439cf22d7c00729..53cb974b8e409a8ba6eb555abac41ca99eb2bbcf 100644 --- a/src/basics/Core/Logger/Logger.h +++ b/src/basics/Core/Logger/Logger.h @@ -1,3 +1,35 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids 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. +// +// VirtualFluids 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 VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file Logger.h +//! \ingroup Logger +//! \author Stephan Lenz +//======================================================================================= #ifndef Logger_H #define Logger_H diff --git a/src/basics/Core/Logger/implementations/LoggerImp.cpp b/src/basics/Core/Logger/implementations/LoggerImp.cpp index f002fdc59ee0a92bdc1be79a74aa347f0451600d..086c0e3aa5153f017905cd8476248ea7a7434335 100644 --- a/src/basics/Core/Logger/implementations/LoggerImp.cpp +++ b/src/basics/Core/Logger/implementations/LoggerImp.cpp @@ -1,3 +1,35 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids 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. +// +// VirtualFluids 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 VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file LoggerImp.cpp +//! \ingroup Logger +//! \author Stephan Lenz +//======================================================================================= #include "LoggerImp.h" #include <chrono> diff --git a/src/basics/Core/Logger/implementations/LoggerImp.h b/src/basics/Core/Logger/implementations/LoggerImp.h index 45b64b6dc2208991ca3c1ac67ad80af0b2ea6f22..070b06a23ee59a1d387f09fc86960dd3083c4e61 100644 --- a/src/basics/Core/Logger/implementations/LoggerImp.h +++ b/src/basics/Core/Logger/implementations/LoggerImp.h @@ -1,3 +1,35 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids 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. +// +// VirtualFluids 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 VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file LoggerImp.h +//! \ingroup Logger +//! \author Stephan Lenz +//======================================================================================= #ifndef LoggerImp_H #define LoggerImp_H diff --git a/src/basics/Core/NonCreatable.h b/src/basics/Core/NonCreatable.h index b25fc808bf0607a047b46643b412b23fb71037b0..c581a19ec92b666f45109f1e3c66b9e57fb54614 100644 --- a/src/basics/Core/NonCreatable.h +++ b/src/basics/Core/NonCreatable.h @@ -1,7 +1,35 @@ -/* - * Author: S. Peters - * mail: peters@irmb.tu-bs.de - */ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids 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. +// +// VirtualFluids 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 VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file NonCreatable.h +//! \ingroup Core +//! \author Soeren Peters +//======================================================================================= #ifndef NON_CREATABLE_H #define NON_CREATABLE_H diff --git a/src/basics/Core/RealConstants.h b/src/basics/Core/RealConstants.h index 91fe0ec0ccff65680f702eab67aa0fb3c4e0172b..5cb42584e29d0e0a1a9cf1b40f50736dd13169f0 100644 --- a/src/basics/Core/RealConstants.h +++ b/src/basics/Core/RealConstants.h @@ -1,223 +1,255 @@ -// #ifndef REAL_CONSTANT_H -// #define REAL_CONSTANT_H - -// #ifdef VF_DOUBLE_ACCURACY -// #define c1o2 0.5 -// #define c3o2 1.5 -// #define c1o3 0.333333333333333 -// #define c2o3 0.666666666666667 -// #define c1o4 0.25 -// #define c3o4 0.75 -// #define c1o6 0.166666666666667 -// #define c1o7 0.142857142857143 -// #define c1o8 0.125 -// #define c1o9 0.111111111111111 -// #define c2o9 0.222222222222222 -// #define c4o9 0.444444444444444 -// #define c1o10 0.1 -// #define c1o12 0.083333333333333 -// #define c1o16 0.0625 -// #define c3o16 0.1875 -// #define c9o16 0.5625 -// #define c1o18 0.055555555555556 -// #define c1o20 0.05 -// #define c19o20 0.95 -// #define c21o20 1.05 -// #define c1o24 0.041666666666667 -// #define c1o27 0.037037037037037 -// #define c3o32 0.09375 -// #define c4o32 0.125 -// #define c1o36 0.027777777777778 -// #define c1o48 0.020833333333333 -// #define c1o64 0.015625 -// #define c3o64 0.046875 -// #define c9o64 0.140625 -// #define c27o64 0.421875 -// #define c1o66 0.015151515151515 -// #define c1o72 0.013888888888889 -// #define c1o264 0.003787878787879 -// #define c8o27 0.296296296296296 -// #define c2o27 0.074074074074074 -// #define c1o54 0.018518518518519 -// #define c1o100 0.01 -// #define c99o100 0.99 -// #define c1o126 0.007936507936508 -// #define c1o216 0.004629629629630 -// #define c5o4 1.25 -// #define c9o4 2.25 -// #define c5o2 2.5 -// #define c9o2 4.5 - -// #define c0o1 0. -// #define c1o1 1. -// #define c2o1 2. -// #define c3o1 3. -// #define c4o1 4. -// #define c5o1 5. -// #define c6o1 6. -// #define c7o1 7. -// #define c8o1 8. -// #define c9o1 9. -// #define c10o1 10. -// #define c11o1 11. -// #define c12o1 12. -// #define c13o1 13. -// #define c14o1 14. -// #define c15o1 15. -// #define c16o1 16. -// #define c17o1 17. -// #define c18o1 18. -// #define c21o1 21. -// #define c24o1 24. -// #define c25o1 25. -// #define c26o1 26. -// #define c27o1 27. -// #define c28o1 28. -// #define c29o1 29. -// #define c30o1 30. -// #define c32o1 32. -// #define c33o1 33. -// #define c34o1 34. -// #define c36o1 36. -// #define c40o1 40. -// #define c42o1 42. -// #define c46o1 46. -// #define c48o1 48. -// #define c50o1 50. -// #define c52o1 52. -// #define c54o1 54. -// #define c56o1 56. -// #define c64o1 64. -// #define c66o1 66. -// #define c68o1 68. -// #define c69o1 69. -// #define c72o1 72. -// #define c84o1 84. -// #define c88o1 88. -// #define c96o1 96. -// #define c100o1 100.0 -// #define c130o1 130.0 -// #define c152o1 152.0 -// #define c166o1 166.0 -// #define c195o1 195.0 -// #define c216o1 216.0 -// #define c264o1 264.0 -// #define c290o1 290.0 -// #define c367o1 367.0 - -// #define Op0000002 0.0000002 -// #define c10eM30 1e-30 -// #define c10eM10 1e-10 -// #define smallSingle 0.0000000002 - -// #else -// #define c1o2 0.5f -// #define c3o2 1.5f -// #define c1o3 (1.0f / 3.0f) -// #define c2o3 (2.0f / 3.0f) -// #define c1o4 0.25f -// #define c3o4 0.75f -// #define c1o6 (1.0f / 6.0f) -// #define c1o7 (1.0f / 7.0f) -// #define c1o8 0.125f -// #define c1o9 (1.0f / 9.0f) -// #define c2o9 (2.0f / 9.0f) -// #define c4o9 (4.0f / 9.0f) -// #define c1o10 0.1f -// #define c1o12 (1.0f / 12.0f) -// #define c1o16 0.0625f -// #define c3o16 0.1875f -// #define c9o16 0.5625f -// #define c1o18 (1.0f / 18.0f) -// #define c1o20 0.05f -// #define c19o20 0.95f -// #define c21o20 1.05f -// #define c1o24 (1.0f / 24.0f) -// #define c1o27 (1.0f / 27.0f) -// #define c3o32 0.09375f -// #define c4o32 0.125f -// #define c1o36 (1.0f / 36.0f) -// #define c1o48 (1.0f / 48.0f) -// #define c1o64 0.015625f -// #define c3o64 0.046875f -// #define c9o64 0.140625f -// #define c27o64 0.421875f -// #define c1o66 (1.0f / 66.0f) -// #define c1o72 (1.0f / 72.0f) -// #define c1o264 (1.0f / 264.0f) -// #define c8o27 (8.0f / 27.0f) -// #define c2o27 (2.0f / 27.0f) -// #define c1o54 (1.0f / 54.0f) -// #define c1o100 0.01f -// #define c99o100 0.99f -// #define c1o126 (1.0f / 126.0f) -// #define c1o216 (1.0f / 216.0f) -// #define c5o4 1.25f -// #define c9o4 2.25f -// #define c5o2 2.5f -// #define c9o2 4.5f - -// #define c0o1 0.f -// #define c1o1 1.f -// #define c2o1 2.f -// #define c3o1 3.f -// #define c4o1 4.f -// #define c5o1 5.f -// #define c6o1 6.f -// #define c7o1 7.f -// #define c8o1 8.f -// #define c9o1 9.f -// #define c10o1 10.f -// #define c11o1 11.f -// #define c12o1 12.f -// #define c13o1 13.f -// #define c14o1 14.f -// #define c15o1 15.f -// #define c16o1 16.f -// #define c17o1 17.f -// #define c18o1 18.f -// #define c21o1 21.f -// #define c24o1 24.f -// #define c25o1 25.f -// #define c26o1 26.f -// #define c27o1 27.f -// #define c28o1 28.f -// #define c29o1 29.f -// #define c30o1 30.f -// #define c32o1 32.f -// #define c33o1 33.f -// #define c34o1 34.f -// #define c36o1 36.f -// #define c40o1 40.f -// #define c42o1 42.f -// #define c46o1 46.f -// #define c48o1 48.f -// #define c50o1 50.f -// #define c52o1 52.f -// #define c54o1 54.f -// #define c56o1 56.f -// #define c64o1 64.f -// #define c66o1 66.f -// #define c68o1 68.f -// #define c69o1 69.f -// #define c72o1 72.f -// #define c84o1 84.f -// #define c88o1 88.f -// #define c96o1 96.f -// #define c100o1 100.0f -// #define c130o1 130.0f -// #define c152o1 152.0f -// #define c166o1 166.0f -// #define c195o1 195.0f -// #define c216o1 216.0f -// #define c264o1 264.0f -// #define c290o1 290.0f -// #define c367o1 367.0f - -// #define Op0000002 0.0000002f -// #define c10eM30 1e-30 -// #define c10eM10 1e-10 -// #define smallSingle 0.0000000002f -// #endif - -// #endif \ No newline at end of file +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids 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. +// +// VirtualFluids 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 VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file RealConstants.h +//! \ingroup Core +//! \author Martin Schoenherr +//======================================================================================= +//#ifndef REAL_CONSTANT_H +//#define REAL_CONSTANT_H +// +//#ifdef VF_DOUBLE_ACCURACY +//#define c1o2 0.5 +//#define c3o2 1.5 +//#define c1o3 0.333333333333333 +//#define c2o3 0.666666666666667 +//#define c1o4 0.25 +//#define c3o4 0.75 +//#define c1o6 0.166666666666667 +//#define c1o7 0.142857142857143 +//#define c1o8 0.125 +//#define c1o9 0.111111111111111 +//#define c2o9 0.222222222222222 +//#define c4o9 0.444444444444444 +//#define c1o10 0.1 +//#define c1o12 0.083333333333333 +//#define c1o16 0.0625 +//#define c3o16 0.1875 +//#define c9o16 0.5625 +//#define c1o18 0.055555555555556 +//#define c1o20 0.05 +//#define c19o20 0.95 +//#define c21o20 1.05 +//#define c1o24 0.041666666666667 +//#define c1o27 0.037037037037037 +//#define c3o32 0.09375 +//#define c4o32 0.125 +//#define c1o36 0.027777777777778 +//#define c1o48 0.020833333333333 +//#define c1o64 0.015625 +//#define c3o64 0.046875 +//#define c9o64 0.140625 +//#define c27o64 0.421875 +//#define c1o66 0.015151515151515 +//#define c1o72 0.013888888888889 +//#define c1o264 0.003787878787879 +//#define c8o27 0.296296296296296 +//#define c2o27 0.074074074074074 +//#define c1o54 0.018518518518519 +//#define c1o100 0.01 +//#define c99o100 0.99 +//#define c1o126 0.007936507936508 +//#define c1o216 0.004629629629630 +//#define c5o4 1.25 +//#define c9o4 2.25 +//#define c5o2 2.5 +//#define c9o2 4.5 +// +//#define c0o1 0. +//#define c1o1 1. +//#define c2o1 2. +//#define c3o1 3. +//#define c4o1 4. +//#define c5o1 5. +//#define c6o1 6. +//#define c7o1 7. +//#define c8o1 8. +//#define c9o1 9. +//#define c10o1 10. +//#define c11o1 11. +//#define c12o1 12. +//#define c13o1 13. +//#define c14o1 14. +//#define c15o1 15. +//#define c16o1 16. +//#define c17o1 17. +//#define c18o1 18. +//#define c21o1 21. +//#define c24o1 24. +//#define c25o1 25. +//#define c26o1 26. +//#define c27o1 27. +//#define c28o1 28. +//#define c29o1 29. +//#define c30o1 30. +//#define c32o1 32. +//#define c33o1 33. +//#define c34o1 34. +//#define c36o1 36. +//#define c40o1 40. +//#define c42o1 42. +//#define c46o1 46. +//#define c48o1 48. +//#define c50o1 50. +//#define c52o1 52. +//#define c54o1 54. +//#define c56o1 56. +//#define c64o1 64. +//#define c66o1 66. +//#define c68o1 68. +//#define c69o1 69. +//#define c72o1 72. +//#define c84o1 84. +//#define c88o1 88. +//#define c96o1 96. +//#define c100o1 100.0 +//#define c130o1 130.0 +//#define c152o1 152.0 +//#define c166o1 166.0 +//#define c195o1 195.0 +//#define c216o1 216.0 +//#define c264o1 264.0 +//#define c290o1 290.0 +//#define c367o1 367.0 +// +//#define Op0000002 0.0000002 +//#define c10eM30 1e-30 +//#define c10eM10 1e-10 +//#define smallSingle 0.0000000002 +// +//#else +//#define c1o2 0.5f +//#define c3o2 1.5f +//#define c1o3 (1.0f / 3.0f) +//#define c2o3 (2.0f / 3.0f) +//#define c1o4 0.25f +//#define c3o4 0.75f +//#define c1o6 (1.0f / 6.0f) +//#define c1o7 (1.0f / 7.0f) +//#define c1o8 0.125f +//#define c1o9 (1.0f / 9.0f) +//#define c2o9 (2.0f / 9.0f) +//#define c4o9 (4.0f / 9.0f) +//#define c1o10 0.1f +//#define c1o12 (1.0f / 12.0f) +//#define c1o16 0.0625f +//#define c3o16 0.1875f +//#define c9o16 0.5625f +//#define c1o18 (1.0f / 18.0f) +//#define c1o20 0.05f +//#define c19o20 0.95f +//#define c21o20 1.05f +//#define c1o24 (1.0f / 24.0f) +//#define c1o27 (1.0f / 27.0f) +//#define c3o32 0.09375f +//#define c4o32 0.125f +//#define c1o36 (1.0f / 36.0f) +//#define c1o48 (1.0f / 48.0f) +//#define c1o64 0.015625f +//#define c3o64 0.046875f +//#define c9o64 0.140625f +//#define c27o64 0.421875f +//#define c1o66 (1.0f / 66.0f) +//#define c1o72 (1.0f / 72.0f) +//#define c1o264 (1.0f / 264.0f) +//#define c8o27 (8.0f / 27.0f) +//#define c2o27 (2.0f / 27.0f) +//#define c1o54 (1.0f / 54.0f) +//#define c1o100 0.01f +//#define c99o100 0.99f +//#define c1o126 (1.0f / 126.0f) +//#define c1o216 (1.0f / 216.0f) +//#define c5o4 1.25f +//#define c9o4 2.25f +//#define c5o2 2.5f +//#define c9o2 4.5f +// +//#define c0o1 0.f +//#define c1o1 1.f +//#define c2o1 2.f +//#define c3o1 3.f +//#define c4o1 4.f +//#define c5o1 5.f +//#define c6o1 6.f +//#define c7o1 7.f +//#define c8o1 8.f +//#define c9o1 9.f +//#define c10o1 10.f +//#define c11o1 11.f +//#define c12o1 12.f +//#define c13o1 13.f +//#define c14o1 14.f +//#define c15o1 15.f +//#define c16o1 16.f +//#define c17o1 17.f +//#define c18o1 18.f +//#define c21o1 21.f +//#define c24o1 24.f +//#define c25o1 25.f +//#define c26o1 26.f +//#define c27o1 27.f +//#define c28o1 28.f +//#define c29o1 29.f +//#define c30o1 30.f +//#define c32o1 32.f +//#define c33o1 33.f +//#define c34o1 34.f +//#define c36o1 36.f +//#define c40o1 40.f +//#define c42o1 42.f +//#define c46o1 46.f +//#define c48o1 48.f +//#define c50o1 50.f +//#define c52o1 52.f +//#define c54o1 54.f +//#define c56o1 56.f +//#define c64o1 64.f +//#define c66o1 66.f +//#define c68o1 68.f +//#define c69o1 69.f +//#define c72o1 72.f +//#define c84o1 84.f +//#define c88o1 88.f +//#define c96o1 96.f +//#define c100o1 100.0f +//#define c130o1 130.0f +//#define c152o1 152.0f +//#define c166o1 166.0f +//#define c195o1 195.0f +//#define c216o1 216.0f +//#define c264o1 264.0f +//#define c290o1 290.0f +//#define c367o1 367.0f +// +//#define Op0000002 0.0000002f +//#define c10eM30 1e-30 +//#define c10eM10 1e-10 +//#define smallSingle 0.0000000002f +//#endif +// +//#endif \ No newline at end of file diff --git a/src/basics/Core/StringUtilities/StringUtil.cpp b/src/basics/Core/StringUtilities/StringUtil.cpp index 327a62346a91073834c8b710e90968a524ee2d28..d8bcae7a513d498418c62d2f39a8b7bdd450468d 100644 --- a/src/basics/Core/StringUtilities/StringUtil.cpp +++ b/src/basics/Core/StringUtilities/StringUtil.cpp @@ -1,3 +1,35 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids 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. +// +// VirtualFluids 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 VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file StringUtil.cpp +//! \ingroup StringUtilities +//! \author Konstantin Kutscher, Soeren Textor, Sebastian Geller +//======================================================================================= #include "StringUtil.h" #include <string.h> diff --git a/src/basics/Core/StringUtilities/StringUtil.h b/src/basics/Core/StringUtilities/StringUtil.h index 1927a69bc60bf2467fb09893463b3c9363191890..b1b777ad2a512ec78061f019df6e043bfb1cf37b 100644 --- a/src/basics/Core/StringUtilities/StringUtil.h +++ b/src/basics/Core/StringUtilities/StringUtil.h @@ -1,3 +1,35 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids 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. +// +// VirtualFluids 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 VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file StringUtil.h +//! \ingroup StringUtilities +//! \author Konstantin Kutscher, Soeren Textor, Sebastian Geller +//======================================================================================= #ifndef STRINGUTIL_H #define STRINGUTIL_H diff --git a/src/basics/Core/Timer/Timer.cpp b/src/basics/Core/Timer/Timer.cpp index 9ca58ed190a5ff68d9f57e8d27fda73f94958ef8..c8856f72adffe0c407ff29ee74246638ce5c8280 100644 --- a/src/basics/Core/Timer/Timer.cpp +++ b/src/basics/Core/Timer/Timer.cpp @@ -1,3 +1,35 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids 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. +// +// VirtualFluids 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 VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file Timer.cpp +//! \ingroup Timer +//! \author Stephan Lenz +//======================================================================================= #include "Timer.h" #include "TimerImp.h" diff --git a/src/basics/Core/Timer/Timer.h b/src/basics/Core/Timer/Timer.h index e8a97000fb8cc3967490e60edca1c564cc8431c7..6de04b2f3d5573ac6266bd2c35cf18cd232384dd 100644 --- a/src/basics/Core/Timer/Timer.h +++ b/src/basics/Core/Timer/Timer.h @@ -1,3 +1,35 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids 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. +// +// VirtualFluids 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 VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file Timer.h +//! \ingroup Timer +//! \author Stephan Lenz +//======================================================================================= #ifndef TIMER_H #define TIMER_H diff --git a/src/basics/Core/Timer/TimerImp.cpp b/src/basics/Core/Timer/TimerImp.cpp index 7aef3e999c0d5466fb69b08eafa32fa95370383b..76f9ac36793f2e2543abe9086f2780ee94b50eb7 100644 --- a/src/basics/Core/Timer/TimerImp.cpp +++ b/src/basics/Core/Timer/TimerImp.cpp @@ -1,3 +1,35 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids 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. +// +// VirtualFluids 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 VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file TimerImp.cpp +//! \ingroup Timer +//! \author Stephan Lenz +//======================================================================================= #include "TimerImp.h" void TimerImp::start() { this->startTime = std::chrono::high_resolution_clock::now(); } diff --git a/src/basics/Core/Timer/TimerImp.h b/src/basics/Core/Timer/TimerImp.h index bcc078db9a4f00eb23abe93a9a1e16509c948820..e180ae084cb19b939f6e7a82cae7a0db3cc1ea15 100644 --- a/src/basics/Core/Timer/TimerImp.h +++ b/src/basics/Core/Timer/TimerImp.h @@ -1,3 +1,35 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids 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. +// +// VirtualFluids 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 VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file TimerImp.h +//! \ingroup Timer +//! \author Stephan Lenz +//======================================================================================= #ifndef TIMER_IMP_H #define TIMER_IMP_H diff --git a/src/basics/Core/VectorTypes.cpp b/src/basics/Core/VectorTypes.cpp index dab2675093415ec103d1bf7ffd3666d57b0977f5..ecc986be836cb3c85d760f4db408707bfb1180b4 100644 --- a/src/basics/Core/VectorTypes.cpp +++ b/src/basics/Core/VectorTypes.cpp @@ -1,3 +1,35 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids 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. +// +// VirtualFluids 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 VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file VectorTypes.cpp +//! \ingroup Core +//! \author Soeren Peters +//======================================================================================= #include "VectorTypes.h" // Vec3 Vec3::operator+( Vec3& left, Vec3& right ){ diff --git a/src/basics/Core/VectorTypes.h b/src/basics/Core/VectorTypes.h index 226ab7c55fdafdcb9322b07e42573df4ac3d5618..2ca45b359397c712b8b8695b9a99b4c5f8c324d1 100644 --- a/src/basics/Core/VectorTypes.h +++ b/src/basics/Core/VectorTypes.h @@ -1,3 +1,35 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids 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. +// +// VirtualFluids 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 VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file VectorTypes.h +//! \ingroup Core +//! \author Soeren Peters +//======================================================================================= #ifndef VECTORTYPES_H #define VECTORTYPES_H @@ -17,6 +49,7 @@ #include "basics_export.h" #include "DataTypes.h" +#include "RealConstants.h" struct BASICS_EXPORT Vec3 { real x{ 0. }, y{ 0. }, z{ 0. }; diff --git a/src/basics/Core/buildInfo.h b/src/basics/Core/buildInfo.h index a5499518c7a13ea52d470895b702ca0aab1294e0..598d5ee742fc329c01c66a24429cd20b2cebe89e 100644 --- a/src/basics/Core/buildInfo.h +++ b/src/basics/Core/buildInfo.h @@ -1,3 +1,35 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids 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. +// +// VirtualFluids 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 VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file buildInfo.h +//! \ingroup Core +//! \author Soeren Peters +//======================================================================================= #ifndef buildInfo_H #define buildInfo_H diff --git a/src/basics/PointerDefinitions.h b/src/basics/PointerDefinitions.h index 4b8657025cc5100c6623b5172cbab3484bc2f8a1..3ce2330379e13785c5603da9dcb2966bff38978b 100644 --- a/src/basics/PointerDefinitions.h +++ b/src/basics/PointerDefinitions.h @@ -1,7 +1,35 @@ -/* - * Author: S. Peters - * mail: peters@irmb.tu-bs.de - */ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids 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. +// +// VirtualFluids 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 VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file PointerDefinitions.h +//! \ingroup Core +//! \author Soeren Peters +//======================================================================================= #ifndef SHARED_POINTER_H #define SHARED_POINTER_H diff --git a/src/basics/Singelton.h b/src/basics/Singelton.h new file mode 100644 index 0000000000000000000000000000000000000000..f0979b5dd3d89e26ebbe4b4e82d2336e1f59a07e --- /dev/null +++ b/src/basics/Singelton.h @@ -0,0 +1,58 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids 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. +// +// VirtualFluids 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 VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \author Soeren Peters +//======================================================================================= + +#ifndef BASICS_SINGELTON_H +#define BASICS_SINGELTON_H + +namespace vf::basics +{ + +template<typename T> +class Singleton +{ +public: + Singleton(const Singleton&) = delete; + Singleton & operator=(const Singleton& rhs) = delete; + +protected: + Singleton() = default; + +public: + static std::shared_ptr<Singleton> getInstance() + { + static std::shared_ptr<Singleton> s{new T}; + return s; + } +}; + +} + +#endif \ No newline at end of file diff --git a/src/basics/basics/container/CbVectorPool.h b/src/basics/basics/container/CbVectorPool.h index 0272056b51d65aacafad78cbae03971a24879a7e..f764dd9e53df7b3b0f07500a3cfa6577476819f7 100644 --- a/src/basics/basics/container/CbVectorPool.h +++ b/src/basics/basics/container/CbVectorPool.h @@ -1,9 +1,35 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ // +// This file is part of VirtualFluids. VirtualFluids 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. +// +// VirtualFluids 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 VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file CbVectorPool.h +//! \ingroup container +//! \author Soeren Freudiger, Sebastian Geller +//======================================================================================= #ifndef CBVECTORPOOL_H #define CBVECTORPOOL_H diff --git a/src/basics/basics/memory/MbSmartPtr.h b/src/basics/basics/memory/MbSmartPtr.h index 1ddced8c061708af5b04e005d7c7224900f64d3c..9c36cd97301c0fb3be3e98e612e4d05ab3fc899c 100644 --- a/src/basics/basics/memory/MbSmartPtr.h +++ b/src/basics/basics/memory/MbSmartPtr.h @@ -1,9 +1,35 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ // +// This file is part of VirtualFluids. VirtualFluids 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. +// +// VirtualFluids 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 VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file MbSmartPtr.h +//! \ingroup memory +//! \author Soeren Freudiger, Sebastian Geller +//======================================================================================= #ifndef MBSMARTPTR_H #define MBSMARTPTR_H diff --git a/src/basics/basics/memory/MbSmartPtrBase.cpp b/src/basics/basics/memory/MbSmartPtrBase.cpp index a0651b0290f6628d50442658d26912e4337d0cd6..cebff4e4d5c99a6d05865d7cb9d6f936a064efe5 100644 --- a/src/basics/basics/memory/MbSmartPtrBase.cpp +++ b/src/basics/basics/memory/MbSmartPtrBase.cpp @@ -1,3 +1,35 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids 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. +// +// VirtualFluids 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 VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file MbSmartPtrBase.cpp +//! \ingroup memory +//! \author Soeren Freudiger, Sebastian Geller +//======================================================================================= #include <basics/memory/MbSmartPtrBase.h> using namespace std; diff --git a/src/basics/basics/memory/MbSmartPtrBase.h b/src/basics/basics/memory/MbSmartPtrBase.h index 1abdcac81c1454694d846d5d4a396df2dca095da..697af8f3b01e183043dcc2f04bab670c3d42f78f 100644 --- a/src/basics/basics/memory/MbSmartPtrBase.h +++ b/src/basics/basics/memory/MbSmartPtrBase.h @@ -1,9 +1,35 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ // +// This file is part of VirtualFluids. VirtualFluids 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. +// +// VirtualFluids 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 VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file MbSmartPtrBase.h +//! \ingroup memory +//! \author Soeren Freudiger, Sebastian Geller +//======================================================================================= #ifndef MBSMARTPTRBASE_H #define MBSMARTPTRBASE_H diff --git a/src/basics/basics/parallel/PbMpi.h b/src/basics/basics/parallel/PbMpi.h index 857ff7b1058b2a773a6b759bbd3dca8105db0a68..7f73da85b4ee333a3f266ea8fc082fc5d88f1b40 100644 --- a/src/basics/basics/parallel/PbMpi.h +++ b/src/basics/basics/parallel/PbMpi.h @@ -1,9 +1,35 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ // +// This file is part of VirtualFluids. VirtualFluids 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. +// +// VirtualFluids 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 VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file PbMpi.h +//! \ingroup parallel +//! \author Soeren Freudiger, Sebastian Geller +//======================================================================================= #ifndef PbMpi_H #define PbMpi_H diff --git a/src/basics/basics/transmitter/TbTransmitter.h b/src/basics/basics/transmitter/TbTransmitter.h index 4d5e5195d9840ea54b3a4f62b0063626e60e4c5b..22fff52a1d1a9d2219b78e933d63e3e1c208897f 100644 --- a/src/basics/basics/transmitter/TbTransmitter.h +++ b/src/basics/basics/transmitter/TbTransmitter.h @@ -1,9 +1,35 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ // +// This file is part of VirtualFluids. VirtualFluids 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. +// +// VirtualFluids 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 VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file TbTransmitter.h +//! \ingroup transmitter +//! \author Soeren Freudiger, Sebastian Geller +//======================================================================================= #ifndef TBTRANSMITTER_H #define TBTRANSMITTER_H diff --git a/src/basics/basics/transmitter/TbTransmitterLocal.h b/src/basics/basics/transmitter/TbTransmitterLocal.h index f0a6c30df18a28dd61bfc25af48610d931ba270f..39a2592c19cbb23d56c880ef501a89b506b974d7 100644 --- a/src/basics/basics/transmitter/TbTransmitterLocal.h +++ b/src/basics/basics/transmitter/TbTransmitterLocal.h @@ -1,9 +1,35 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ // +// This file is part of VirtualFluids. VirtualFluids 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. +// +// VirtualFluids 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 VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file TbTransmitterLocal.h +//! \ingroup transmitter +//! \author Soeren Freudiger, Sebastian Geller +//======================================================================================= #ifndef TOTRANSMITTERLOCAL_H #define TOTRANSMITTERLOCAL_H diff --git a/src/basics/basics/transmitter/TbTransmitterMpiPool.h b/src/basics/basics/transmitter/TbTransmitterMpiPool.h index ff170e18e31f6f14beef00e245e724a259a9e753..83c0b1e396364840d4ec03a666f482791e098462 100644 --- a/src/basics/basics/transmitter/TbTransmitterMpiPool.h +++ b/src/basics/basics/transmitter/TbTransmitterMpiPool.h @@ -1,9 +1,35 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ // +// This file is part of VirtualFluids. VirtualFluids 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. +// +// VirtualFluids 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 VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file TbTransmitterMpiPool.h +//! \ingroup transmitter +//! \author Soeren Freudiger, Sebastian Geller +//======================================================================================= #ifndef TBTRANSMITTERMPIPOOL_H #define TBTRANSMITTERMPIPOOL_H diff --git a/src/basics/basics/utilities/UbException.h b/src/basics/basics/utilities/UbException.h index 9a458980688145c199bf7193000131aeb5fb5e30..5c9fef87bb65b12c1216111ddb9ca1e5eba58ab3 100644 --- a/src/basics/basics/utilities/UbException.h +++ b/src/basics/basics/utilities/UbException.h @@ -114,7 +114,7 @@ public: /*==========================================================*/ virtual void addInfo(const std::string &err_str) { - exceptionData.push_back(makeUbTuple((std::string) "-", 0, (std::string) "unknown", err_str)); + exceptionData.push_back(makeUbTuple(std::string("-"), 0, std::string("unknown"), err_str)); } /*==========================================================*/ // add exception diff --git a/src/basics/basics/utilities/UbFileInput.h b/src/basics/basics/utilities/UbFileInput.h index d3128830be296c1250617d82b4190c618a49335e..d1eac796f437a17b5519d12b096dc8b5d4263de4 100644 --- a/src/basics/basics/utilities/UbFileInput.h +++ b/src/basics/basics/utilities/UbFileInput.h @@ -1,9 +1,35 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ // +// This file is part of VirtualFluids. VirtualFluids 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. +// +// VirtualFluids 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 VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file UbFileInput.h +//! \ingroup utilities +//! \author Soeren Freudiger, Sebastian Geller +//======================================================================================= #ifndef UBFILEINPUT_H #define UBFILEINPUT_H diff --git a/src/basics/basics/utilities/UbFileInputASCII.cpp b/src/basics/basics/utilities/UbFileInputASCII.cpp index cefa577d2ad37058a56696af37decf6a461af593..f988c52f7e381b988830a4506c72e77221c177d9 100644 --- a/src/basics/basics/utilities/UbFileInputASCII.cpp +++ b/src/basics/basics/utilities/UbFileInputASCII.cpp @@ -1,6 +1,38 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids 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. +// +// VirtualFluids 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 VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file UbFileInputASCII.cpp +//! \ingroup utilities +//! \author Soeren Freudiger, Sebastian Geller +//======================================================================================= +#include <algorithm> #include <basics/utilities/UbFileInputASCII.h> #include <cstring> -#include <algorithm> using namespace std; @@ -156,10 +188,10 @@ int UbFileInputASCII::readIntegerAfterString(const string &var) " wasn't found in " + this->filename)); } while (strstr(line, var.c_str()) != line); // Ende Schleife, wenn varname ganz in zeile vorkommt - std::string temp {line}; + std::string temp{ line }; temp = temp.substr(var.size()); // zeile um "varname" kuerzen - temp.erase(std::remove(temp.begin(), temp.end(), ' '), temp.end()); // remove whitespace + temp.erase(std::remove(temp.begin(), temp.end(), ' '), temp.end()); // remove whitespace temp.erase(std::remove(temp.begin(), temp.end(), '\t'), temp.end()); // remove tabs return std::stoi(temp); @@ -184,10 +216,10 @@ double UbFileInputASCII::readDoubleAfterString(const string &var) } while (/*!strncmp(varname,line,sizeof(varname))==0*/ strstr(line, var.c_str()) != line); // Ende Schleife, wenn varname ganz in zeile vorkommt - std::string temp {line}; + std::string temp{ line }; temp = temp.substr(var.size()); // zeile um "varname" kuerzen - temp.erase(std::remove(temp.begin(), temp.end(), ' '), temp.end()); // remove whitespace + temp.erase(std::remove(temp.begin(), temp.end(), ' '), temp.end()); // remove whitespace temp.erase(std::remove(temp.begin(), temp.end(), '\t'), temp.end()); // remove tabs return std::stod(temp); @@ -212,10 +244,10 @@ string UbFileInputASCII::readStringAfterString(const string &var) //,char *value " wasn't found in " + this->filename)); } while (strstr(line, var.c_str()) != line); // Ende Schleife, wenn varname ganz in zeile vorkommt - std::string temp {line}; + std::string temp{ line }; temp = temp.substr(var.size()); // zeile um "varname" kuerzen - temp.erase(std::remove(temp.begin(), temp.end(), ' '), temp.end()); // remove whitespace + temp.erase(std::remove(temp.begin(), temp.end(), ' '), temp.end()); // remove whitespace temp.erase(std::remove(temp.begin(), temp.end(), '\t'), temp.end()); // remove tabs return temp; diff --git a/src/basics/basics/utilities/UbFileInputASCII.h b/src/basics/basics/utilities/UbFileInputASCII.h index 65cd28921ce99e04ad483cc397fd0aff076ec54c..a86955bca511f194f5936a81dd9a542026f88f67 100644 --- a/src/basics/basics/utilities/UbFileInputASCII.h +++ b/src/basics/basics/utilities/UbFileInputASCII.h @@ -1,9 +1,35 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ // +// This file is part of VirtualFluids. VirtualFluids 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. +// +// VirtualFluids 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 VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file UbFileInputASCII.h +//! \ingroup utilities +//! \author Soeren Freudiger, Sebastian Geller +//======================================================================================= #ifndef UBFILEINPUTASCII_H #define UBFILEINPUTASCII_H diff --git a/src/basics/basics/utilities/UbFileInputBinary.cpp b/src/basics/basics/utilities/UbFileInputBinary.cpp index 120b4ab860d45dac3094b46c4bbad3f03fa65b6e..b77327f6d8c195f93ba34510a3b691e6cd6c52b2 100644 --- a/src/basics/basics/utilities/UbFileInputBinary.cpp +++ b/src/basics/basics/utilities/UbFileInputBinary.cpp @@ -1,3 +1,35 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids 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. +// +// VirtualFluids 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 VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file UbFileInputBinary.cpp +//! \ingroup utilities +//! \author Soeren Freudiger, Sebastian Geller +//======================================================================================= #include <basics/utilities/UbFileInputBinary.h> #include <cstring> diff --git a/src/basics/basics/utilities/UbFileInputBinary.h b/src/basics/basics/utilities/UbFileInputBinary.h index b1e40d396c6948ef474dd23eab5e04767b6d8d2d..9e477c3a24df2c78b5696688354d5dcba747d486 100644 --- a/src/basics/basics/utilities/UbFileInputBinary.h +++ b/src/basics/basics/utilities/UbFileInputBinary.h @@ -1,9 +1,35 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ // +// This file is part of VirtualFluids. VirtualFluids 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. +// +// VirtualFluids 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 VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file UbFileInputBinary.h +//! \ingroup utilities +//! \author Soeren Freudiger, Sebastian Geller +//======================================================================================= #ifndef UBFILEINPUTBINARY_H #define UBFILEINPUTBINARY_H diff --git a/src/basics/basics/utilities/UbFileOutput.h b/src/basics/basics/utilities/UbFileOutput.h index 7e3e12d4ce2725073ed153d4cad9985664664cd1..877b96fc5c6a1d31ee7f6e724df134dd42373760 100644 --- a/src/basics/basics/utilities/UbFileOutput.h +++ b/src/basics/basics/utilities/UbFileOutput.h @@ -1,9 +1,35 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ // +// This file is part of VirtualFluids. VirtualFluids 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. +// +// VirtualFluids 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 VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file UbFileOutput.h +//! \ingroup utilities +//! \author Soeren Freudiger, Sebastian Geller +//======================================================================================= #ifndef UBFILEOUTPUT_H #define UBFILEOUTPUT_H diff --git a/src/basics/basics/utilities/UbFileOutputASCII.cpp b/src/basics/basics/utilities/UbFileOutputASCII.cpp index 68bfc8b64ad2e10c5b8a76b0bcdc98bdd7fa019d..56edaf919a9d3f058fff9f5d74e646679f5010f0 100644 --- a/src/basics/basics/utilities/UbFileOutputASCII.cpp +++ b/src/basics/basics/utilities/UbFileOutputASCII.cpp @@ -1,3 +1,35 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids 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. +// +// VirtualFluids 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 VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file UbFileOutputASCII.cpp +//! \ingroup utilities +//! \author Soeren Freudiger, Sebastian Geller +//======================================================================================= #include <basics/utilities/UbFileOutputASCII.h> #include <basics/utilities/UbInfinity.h> #include <basics/utilities/UbMath.h> diff --git a/src/basics/basics/utilities/UbFileOutputASCII.h b/src/basics/basics/utilities/UbFileOutputASCII.h index e6d763561ba6e36dbceae844e4d0423692fa6a94..24efd507a0b94266cd95e6b3113cef5bf498b076 100644 --- a/src/basics/basics/utilities/UbFileOutputASCII.h +++ b/src/basics/basics/utilities/UbFileOutputASCII.h @@ -1,9 +1,35 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ // +// This file is part of VirtualFluids. VirtualFluids 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. +// +// VirtualFluids 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 VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file UbFileOutputASCII.h +//! \ingroup utilities +//! \author Soeren Freudiger, Sebastian Geller +//======================================================================================= #ifndef UBFILEOUTPUTASCII_H #define UBFILEOUTPUTASCII_H diff --git a/src/basics/basics/utilities/UbFileOutputBinary.cpp b/src/basics/basics/utilities/UbFileOutputBinary.cpp index fa9ab7480f360e4d9a14098ffca8020f159cc76c..ce9fca58f7eddd8d0ec3cc4a7d0ecf48fb2f4691 100644 --- a/src/basics/basics/utilities/UbFileOutputBinary.cpp +++ b/src/basics/basics/utilities/UbFileOutputBinary.cpp @@ -1,3 +1,35 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids 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. +// +// VirtualFluids 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 VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file UbFileOutputBinary.cpp +//! \ingroup utilities +//! \author Soeren Freudiger, Sebastian Geller +//======================================================================================= #include <basics/utilities/UbFileOutputBinary.h> #include <basics/utilities/UbSystem.h> #include <cstring> diff --git a/src/basics/basics/utilities/UbFileOutputBinary.h b/src/basics/basics/utilities/UbFileOutputBinary.h index fb4799d1761fbc7056e5b0c6050c385e95692073..630df58b8a3ed47d9a3e8adc033db282ce5e80ef 100644 --- a/src/basics/basics/utilities/UbFileOutputBinary.h +++ b/src/basics/basics/utilities/UbFileOutputBinary.h @@ -1,9 +1,35 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ // +// This file is part of VirtualFluids. VirtualFluids 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. +// +// VirtualFluids 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 VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file UbFileOutputBinary.h +//! \ingroup utilities +//! \author Soeren Freudiger, Sebastian Geller +//======================================================================================= #ifndef UBFILEOUTPUTBINARY_H #define UBFILEOUTPUTBINARY_H diff --git a/src/basics/basics/utilities/UbNupsTimer.h b/src/basics/basics/utilities/UbNupsTimer.h index ca576fa6ce53c4bfaa48aed26463e12108745c94..1545b5b694a57d112b485cf766ce26e22f30d939 100644 --- a/src/basics/basics/utilities/UbNupsTimer.h +++ b/src/basics/basics/utilities/UbNupsTimer.h @@ -1,3 +1,35 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids 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. +// +// VirtualFluids 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 VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file UbNupsTimer.h +//! \ingroup utilities +//! \author Soeren Freudiger, Sebastian Geller +//======================================================================================= #ifndef UBNUPSTIMER_H #define UBNUPSTIMER_H diff --git a/src/basics/basics/utilities/UbRandom.h b/src/basics/basics/utilities/UbRandom.h index aed28014b0a866f9223162dc9a07237c7da4b1b0..9026f600734f971923ec5b69f42ea7caddc1ddd2 100644 --- a/src/basics/basics/utilities/UbRandom.h +++ b/src/basics/basics/utilities/UbRandom.h @@ -1,9 +1,35 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ // +// This file is part of VirtualFluids. VirtualFluids 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. +// +// VirtualFluids 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 VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file UbRandom.h +//! \ingroup utilities +//! \author Soeren Freudiger, Sebastian Geller +//======================================================================================= #ifndef UBRANDOM_H #define UBRANDOM_H diff --git a/src/basics/basics/utilities/Vector3D.cpp b/src/basics/basics/utilities/Vector3D.cpp index 6ff9dc8738f869d75e7fc9870bb5bb7468d83468..a97e8bfdcd64a717b556d7f02e4450ee56977ea0 100644 --- a/src/basics/basics/utilities/Vector3D.cpp +++ b/src/basics/basics/utilities/Vector3D.cpp @@ -26,7 +26,7 @@ // You should have received a copy of the GNU General Public License along // with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. // -//! \file UbVector3D.cpp +//! \file Vector3D.cpp //! \ingroup utilities //! \author Soeren Freudiger, Sebastian Geller //======================================================================================= diff --git a/src/basics/basics/utilities/Vector3D.h b/src/basics/basics/utilities/Vector3D.h index b278a80d732115a9b1183547e61ff1fe6e82d057..ab02dbeea18264a305564d995055744a15c1c7cb 100644 --- a/src/basics/basics/utilities/Vector3D.h +++ b/src/basics/basics/utilities/Vector3D.h @@ -26,7 +26,7 @@ // You should have received a copy of the GNU General Public License along // with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. // -//! \file UbVector3D.h +//! \file Vector3D.h //! \ingroup utilities //! \author Soeren Freudiger, Sebastian Geller //======================================================================================= diff --git a/src/basics/basics/writer/WbWriterAvsASCII.cpp b/src/basics/basics/writer/WbWriterAvsASCII.cpp index 31b922c92df182da53539e12dd4f0ad18adca5c0..3f17db89a1aa1893d156b9142991bf6ce15806c5 100644 --- a/src/basics/basics/writer/WbWriterAvsASCII.cpp +++ b/src/basics/basics/writer/WbWriterAvsASCII.cpp @@ -1,3 +1,35 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids 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. +// +// VirtualFluids 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 VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file WbWriterAvsASCII.cpp +//! \ingroup writer +//! \author Soeren Freudiger, Sebastian Geller +//======================================================================================= #include <basics/utilities/UbLogger.h> #include <basics/utilities/UbSystem.h> #include <basics/writer/WbWriterAvsASCII.h> diff --git a/src/basics/basics/writer/WbWriterAvsASCII.h b/src/basics/basics/writer/WbWriterAvsASCII.h index 493d8b1e0fa3182b9acaf4bfa3f11e436c18d678..f5a462c70f11ddd7b1e4b76ab935b9ad1f988523 100644 --- a/src/basics/basics/writer/WbWriterAvsASCII.h +++ b/src/basics/basics/writer/WbWriterAvsASCII.h @@ -1,9 +1,35 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ // +// This file is part of VirtualFluids. VirtualFluids 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. +// +// VirtualFluids 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 VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file WbWriterAvsASCII.h +//! \ingroup writer +//! \author Soeren Freudiger, Sebastian Geller +//======================================================================================= #ifndef WBWRITERAVSASCII_H #define WBWRITERAVSASCII_H diff --git a/src/basics/basics/writer/WbWriterAvsBinary.cpp b/src/basics/basics/writer/WbWriterAvsBinary.cpp index e52b2232ad701e6c61df2b552545668c9f3d9989..8ce19629448cff4ebbb33a61eaead0bca119a998 100644 --- a/src/basics/basics/writer/WbWriterAvsBinary.cpp +++ b/src/basics/basics/writer/WbWriterAvsBinary.cpp @@ -1,3 +1,35 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids 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. +// +// VirtualFluids 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 VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file WbWriterAvsBinary.cpp +//! \ingroup writer +//! \author Soeren Freudiger, Sebastian Geller +//======================================================================================= #include <basics/utilities/UbLogger.h> #include <basics/utilities/UbSystem.h> #include <basics/writer/WbWriterAvsASCII.h> diff --git a/src/basics/basics/writer/WbWriterAvsBinary.h b/src/basics/basics/writer/WbWriterAvsBinary.h index 42e50debd8b63f877fc132d652088dfaefb1271e..ef6c73cacbfdac1d8ad500022ec2e3cafe0d373e 100644 --- a/src/basics/basics/writer/WbWriterAvsBinary.h +++ b/src/basics/basics/writer/WbWriterAvsBinary.h @@ -1,9 +1,35 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ // +// This file is part of VirtualFluids. VirtualFluids 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. +// +// VirtualFluids 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 VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file WbWriterAvsBinary.h +//! \ingroup writer +//! \author Soeren Freudiger, Sebastian Geller +//======================================================================================= #ifndef WBWRITERAVSBINARY_H #define WBWRITERAVSBINARY_H diff --git a/src/basics/basics/writer/WbWriterBOBJ.cpp b/src/basics/basics/writer/WbWriterBOBJ.cpp index 4401f25b0bd2dc0a9ac8161b901a9d53683ad941..59ea865efc1a21f017a0804b40c8e6cb0089ff32 100644 --- a/src/basics/basics/writer/WbWriterBOBJ.cpp +++ b/src/basics/basics/writer/WbWriterBOBJ.cpp @@ -1,3 +1,35 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids 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. +// +// VirtualFluids 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 VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file WbWriterBOBJ.cpp +//! \ingroup writer +//! \author Soeren Freudiger, Sebastian Geller +//======================================================================================= #ifdef CAB_ZLIB #include <basics/utilities/UbLogger.h> #include <basics/writer/WbWriterBOBJ.h> diff --git a/src/basics/basics/writer/WbWriterBOBJ.h b/src/basics/basics/writer/WbWriterBOBJ.h index f5872cc3a38eed227ebcefcdcedd13a78152b060..591357ac6f861b39af617b3d4c8380de6be7dff6 100644 --- a/src/basics/basics/writer/WbWriterBOBJ.h +++ b/src/basics/basics/writer/WbWriterBOBJ.h @@ -1,3 +1,35 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids 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. +// +// VirtualFluids 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 VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file WbWriterBOBJ.h +//! \ingroup writer +//! \author Soeren Freudiger, Sebastian Geller +//======================================================================================= #ifdef CAB_ZLIB #ifndef WBWRITERBOBJ_H #define WBWRITERBOBJ_H diff --git a/src/basics/basics/writer/WbWriterSunflow.cpp b/src/basics/basics/writer/WbWriterSunflow.cpp index 6c60fe9d0e685dd49bad71a1452b3392e4bb0938..61ecc8e567aa546b6c92c0a0f662714bee0a1746 100644 --- a/src/basics/basics/writer/WbWriterSunflow.cpp +++ b/src/basics/basics/writer/WbWriterSunflow.cpp @@ -1,3 +1,35 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids 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. +// +// VirtualFluids 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 VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file WbWriterSunflow.cpp +//! \ingroup writer +//! \author Soeren Freudiger, Sebastian Geller +//======================================================================================= #include <basics/utilities/UbLogger.h> #include <basics/writer/WbWriterSunflow.h> #include <cstring> diff --git a/src/basics/basics/writer/WbWriterSunflow.h b/src/basics/basics/writer/WbWriterSunflow.h index 328f9c31014dd14977e06125a1c55c6a96898529..519a932f9088b535fb49e77770accd8364226096 100644 --- a/src/basics/basics/writer/WbWriterSunflow.h +++ b/src/basics/basics/writer/WbWriterSunflow.h @@ -1,3 +1,35 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids 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. +// +// VirtualFluids 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 VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file WbWriterSunflow.h +//! \ingroup writer +//! \author Soeren Freudiger, Sebastian Geller +//======================================================================================= #ifndef WbWriterSunflow_H #define WbWriterSunflow_H diff --git a/src/basics/basics/writer/WbWriterTecPlotASCII.cpp b/src/basics/basics/writer/WbWriterTecPlotASCII.cpp index 895853eb29ea8b364a1f914655cc4a5b0c7d093c..ec7748d35ecea52b645a6cc654d52a6bb93fc874 100644 --- a/src/basics/basics/writer/WbWriterTecPlotASCII.cpp +++ b/src/basics/basics/writer/WbWriterTecPlotASCII.cpp @@ -1,3 +1,35 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids 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. +// +// VirtualFluids 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 VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file WbWriterTechPlotASCII.cpp +//! \ingroup writer +//! \author Soeren Freudiger, Sebastian Geller +//======================================================================================= #include <basics/utilities/UbLogger.h> #include <basics/writer/WbWriterTecPlotASCII.h> diff --git a/src/basics/basics/writer/WbWriterTecPlotASCII.h b/src/basics/basics/writer/WbWriterTecPlotASCII.h index 8869b59dedea70d7ed634244d44f9be10372c23e..31cac3cc49b60d66f932530eb4f36c1b8029304d 100644 --- a/src/basics/basics/writer/WbWriterTecPlotASCII.h +++ b/src/basics/basics/writer/WbWriterTecPlotASCII.h @@ -1,3 +1,35 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids 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. +// +// VirtualFluids 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 VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file WbWriterTechPlotASCII.h +//! \ingroup writer +//! \author Soeren Freudiger, Sebastian Geller +//======================================================================================= #ifndef WBWRITERTECPLOTASCII_H #define WBWRITERTECPLOTASCII_H diff --git a/src/basics/basics/writer/WbWriterVtkASCII.cpp b/src/basics/basics/writer/WbWriterVtkASCII.cpp index 754d6d006b80249af5495f24b5fcdbd9d637fc5a..dcd94f8203b1388e974fdcc3638dc3abff10cb67 100644 --- a/src/basics/basics/writer/WbWriterVtkASCII.cpp +++ b/src/basics/basics/writer/WbWriterVtkASCII.cpp @@ -1,3 +1,35 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids 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. +// +// VirtualFluids 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 VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file WbWriterVtkASCII.cpp +//! \ingroup writer +//! \author Soeren Freudiger, Sebastian Geller +//======================================================================================= #include <basics/utilities/UbLogger.h> #include <basics/writer/WbWriterVtkASCII.h> #include <cstring> diff --git a/src/basics/basics/writer/WbWriterVtkASCII.h b/src/basics/basics/writer/WbWriterVtkASCII.h index cce49c5fdf6a8b16724006022828854383abdb51..f041a45eba07e32af59b490b11ca2c041a822339 100644 --- a/src/basics/basics/writer/WbWriterVtkASCII.h +++ b/src/basics/basics/writer/WbWriterVtkASCII.h @@ -1,9 +1,35 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ // +// This file is part of VirtualFluids. VirtualFluids 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. +// +// VirtualFluids 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 VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file WbWriterVtkASCII.h +//! \ingroup writer +//! \author Soeren Freudiger, Sebastian Geller +//======================================================================================= #ifndef WBWRITERVTKASCII_H #define WBWRITERVTKASCII_H diff --git a/src/basics/basics/writer/WbWriterVtkBinary.cpp b/src/basics/basics/writer/WbWriterVtkBinary.cpp index 2f0a203dacb1b335ede29564f3386a0cf3b8acc8..0b1507e7a5f2c9cb22128c06dd9112541c642504 100644 --- a/src/basics/basics/writer/WbWriterVtkBinary.cpp +++ b/src/basics/basics/writer/WbWriterVtkBinary.cpp @@ -1,3 +1,35 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids 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. +// +// VirtualFluids 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 VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file WbWriterVtkBinary.cpp +//! \ingroup writer +//! \author Soeren Freudiger, Sebastian Geller +//======================================================================================= #include <basics/utilities/UbLogger.h> #include <basics/writer/WbWriterVtkASCII.h> #include <basics/writer/WbWriterVtkBinary.h> diff --git a/src/basics/basics/writer/WbWriterVtkBinary.h b/src/basics/basics/writer/WbWriterVtkBinary.h index aa39a3daacb6a4bd51794cc1bc72fc5818d473c8..8d5485a58db22c60124b931a878e12acce16bd09 100644 --- a/src/basics/basics/writer/WbWriterVtkBinary.h +++ b/src/basics/basics/writer/WbWriterVtkBinary.h @@ -1,9 +1,35 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ // +// This file is part of VirtualFluids. VirtualFluids 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. +// +// VirtualFluids 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 VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file WbWriterVtkBinary.h +//! \ingroup writer +//! \author Soeren Freudiger, Sebastian Geller +//======================================================================================= #ifndef WBWRITERVTKBINARY_H #define WBWRITERVTKBINARY_H diff --git a/src/basics/basics/writer/WbWriterX3D.cpp b/src/basics/basics/writer/WbWriterX3D.cpp index 3a043252314b44728847480bef5ca535d1f7fb86..fd8ab6174b0b948718b0d7fbc8ca74d4054b2d2b 100644 --- a/src/basics/basics/writer/WbWriterX3D.cpp +++ b/src/basics/basics/writer/WbWriterX3D.cpp @@ -1,3 +1,35 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids 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. +// +// VirtualFluids 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 VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file WbWriterX3D.cpp +//! \ingroup writer +//! \author Soeren Freudiger, Sebastian Geller +//======================================================================================= #include <basics/utilities/UbLogger.h> #include <basics/writer/WbWriterX3D.h> diff --git a/src/basics/basics/writer/WbWriterX3D.h b/src/basics/basics/writer/WbWriterX3D.h index 86f0abfb5da244ba14cc7dcf225c17c3faefa394..4884d828c8f17a4c0ec270fbbe6fa42e69adb69e 100644 --- a/src/basics/basics/writer/WbWriterX3D.h +++ b/src/basics/basics/writer/WbWriterX3D.h @@ -1,3 +1,35 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids 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. +// +// VirtualFluids 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 VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file WbWriterX3D.h +//! \ingroup writer +//! \author Soeren Freudiger, Sebastian Geller +//======================================================================================= #ifndef WBWRITERX3D_H #define WBWRITERX3D_H diff --git a/src/basics/geometry3d/GbCylinder3D.cpp b/src/basics/geometry3d/GbCylinder3D.cpp index 2b90ca0fae9a7e22245961b8d713a35d72fa7df8..562eb70c85acd87b405cf0c05f646ce22a40b3de 100644 --- a/src/basics/geometry3d/GbCylinder3D.cpp +++ b/src/basics/geometry3d/GbCylinder3D.cpp @@ -1,3 +1,35 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids 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. +// +// VirtualFluids 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 VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file GbCylinder3D.cpp +//! \ingroup geometry3D +//! \author Konstantin Kutscher, Soeren Textor, Sebastian Geller +//======================================================================================= #include <basics/utilities/UbInfinity.h> #include <geometry3d/GbCylinder3D.h> #include <geometry3d/GbPoint3D.h> diff --git a/src/basics/geometry3d/GbCylinder3D.h b/src/basics/geometry3d/GbCylinder3D.h index 3740f18b11ea1f7820fe930dc91a5c264b5a600d..5bb25a8650379540679fba693a396bc1a50434b5 100644 --- a/src/basics/geometry3d/GbCylinder3D.h +++ b/src/basics/geometry3d/GbCylinder3D.h @@ -1,9 +1,35 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ // +// This file is part of VirtualFluids. VirtualFluids 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. +// +// VirtualFluids 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 VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file GbCylinder3D.h +//! \ingroup geometry3D +//! \author Konstantin Kutscher, Soeren Textor, Sebastian Geller +//======================================================================================= #ifndef GBCYLINDER3D_H #define GBCYLINDER3D_H diff --git a/src/basics/geometry3d/GbHalfSpace3D.cpp b/src/basics/geometry3d/GbHalfSpace3D.cpp index 8566d337d32ae269bb630d3f2a44f49b0cd70118..9e72e281e0bc456d32e46780d66de787547b3806 100644 --- a/src/basics/geometry3d/GbHalfSpace3D.cpp +++ b/src/basics/geometry3d/GbHalfSpace3D.cpp @@ -1,3 +1,35 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids 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. +// +// VirtualFluids 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 VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file GbHalfSpace3D.cpp +//! \ingroup geometry3D +//! \author Konstantin Kutscher, Soeren Textor, Sebastian Geller +//======================================================================================= #include <geometry3d/GbHalfSpace3D.h> using namespace std; diff --git a/src/basics/geometry3d/GbHalfSpace3D.h b/src/basics/geometry3d/GbHalfSpace3D.h index 768a01c96c831405fb6024d1bd92d1d92de38c7a..b4ac549fbf21d136c3916980d6336fa92b0b4f44 100644 --- a/src/basics/geometry3d/GbHalfSpace3D.h +++ b/src/basics/geometry3d/GbHalfSpace3D.h @@ -1,9 +1,35 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ // +// This file is part of VirtualFluids. VirtualFluids 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. +// +// VirtualFluids 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 VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file GbHalfSpace3D.h +//! \ingroup geometry3D +//! \author Konstantin Kutscher, Soeren Textor, Sebastian Geller +//======================================================================================= #ifndef GBHALFSPACE3D_H #define GBHALFSPACE3D_H diff --git a/src/basics/geometry3d/GbHalfSpaceKrischan3D.cpp b/src/basics/geometry3d/GbHalfSpaceKrischan3D.cpp index 903cffa95f56a0258989f477e07e37d7a7dcaadf..929868f764bdcdc4c420efcfb2d6b829ddcdd112 100644 --- a/src/basics/geometry3d/GbHalfSpaceKrischan3D.cpp +++ b/src/basics/geometry3d/GbHalfSpaceKrischan3D.cpp @@ -1,3 +1,35 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids 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. +// +// VirtualFluids 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 VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file GbHalfSpaceKrischan3D.cpp +//! \ingroup geometry3D +//! \author Konstantin Kutscher, Soeren Textor, Sebastian Geller +//======================================================================================= #include <geometry3d/GbHalfSpaceKrischan3D.h> using namespace std; diff --git a/src/basics/geometry3d/GbHalfSpaceKrischan3D.h b/src/basics/geometry3d/GbHalfSpaceKrischan3D.h index df01e6c7b30c5ebcc6a2bdbfd828e2523c4f927d..d62046d4a63d17e3c272c177bdb50823ce1954bb 100644 --- a/src/basics/geometry3d/GbHalfSpaceKrischan3D.h +++ b/src/basics/geometry3d/GbHalfSpaceKrischan3D.h @@ -1,9 +1,35 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ // +// This file is part of VirtualFluids. VirtualFluids 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. +// +// VirtualFluids 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 VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file GbHalfSpaceKrischan3D.h +//! \ingroup geometry3D +//! \author Konstantin Kutscher, Soeren Textor, Sebastian Geller +//======================================================================================= #ifndef GbHalfSpaceKrischan3D_H #define GbHalfSpaceKrischan3D_H diff --git a/src/basics/geometry3d/GbMeshTools3D.h b/src/basics/geometry3d/GbMeshTools3D.h index 5c260e9c65237d2bc8d1482044edc2273fc97905..2464bcc34788dadfd99e64b9a94878d22df4a54b 100644 --- a/src/basics/geometry3d/GbMeshTools3D.h +++ b/src/basics/geometry3d/GbMeshTools3D.h @@ -1,3 +1,35 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids 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. +// +// VirtualFluids 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 VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file GbMeshTools3D.h +//! \ingroup geometry3D +//! \author Konstantin Kutscher, Soeren Textor, Sebastian Geller +//======================================================================================= #ifndef GBMESHTOOLS3D_H #define GBMESHTOOLS3D_H diff --git a/src/basics/geometry3d/GbObjectGroup3D.cpp b/src/basics/geometry3d/GbObjectGroup3D.cpp index 4d765691860a9f8ac39d4476a5c28fa92dd7c423..a3a964b1dc95a9f13a122f985375873baa830f7d 100644 --- a/src/basics/geometry3d/GbObjectGroup3D.cpp +++ b/src/basics/geometry3d/GbObjectGroup3D.cpp @@ -1,3 +1,35 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids 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. +// +// VirtualFluids 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 VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file GbObjectGroup3D.cpp +//! \ingroup geometry3D +//! \author Konstantin Kutscher, Soeren Textor, Sebastian Geller +//======================================================================================= #include <geometry3d/GbLine3D.h> #include <geometry3d/GbObjectGroup3D.h> #include <geometry3d/GbPoint3D.h> diff --git a/src/basics/geometry3d/GbObjectGroup3D.h b/src/basics/geometry3d/GbObjectGroup3D.h index 51413cbe98dcdce934960ac0f2a230eeaa9798f3..6c748a12a403594e7604f580fdc30245c1c6d28c 100644 --- a/src/basics/geometry3d/GbObjectGroup3D.h +++ b/src/basics/geometry3d/GbObjectGroup3D.h @@ -1,9 +1,35 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ // +// This file is part of VirtualFluids. VirtualFluids 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. +// +// VirtualFluids 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 VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file GbObjectGroup3D.h +//! \ingroup geometry3D +//! \author Konstantin Kutscher, Soeren Textor, Sebastian Geller +//======================================================================================= #ifndef GBOBJECTGROUP3D_H #define GBOBJECTGROUP3D_H diff --git a/src/basics/geometry3d/GbQuadFaceMesh3D.cpp b/src/basics/geometry3d/GbQuadFaceMesh3D.cpp index e525d710e6bf9f6d44fcb57a41ea7579e0667dd4..1b2c2aeaabf1eacd78577cc67b678be895747e05 100644 --- a/src/basics/geometry3d/GbQuadFaceMesh3D.cpp +++ b/src/basics/geometry3d/GbQuadFaceMesh3D.cpp @@ -1,3 +1,35 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids 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. +// +// VirtualFluids 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 VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file GbQuadFaceMesh3D.cpp +//! \ingroup geometry3D +//! \author Konstantin Kutscher, Soeren Textor, Sebastian Geller +//======================================================================================= #include <geometry3d/GbQuadFaceMesh3D.h> #include <geometry3d/GbCuboid3D.h> diff --git a/src/basics/geometry3d/GbQuadFaceMesh3D.h b/src/basics/geometry3d/GbQuadFaceMesh3D.h index d4f1c1310a07b673e2aab6a7a0526ad5aa79d5bd..2671488303695158dcaa618a4ffa9c101bb5e1c3 100644 --- a/src/basics/geometry3d/GbQuadFaceMesh3D.h +++ b/src/basics/geometry3d/GbQuadFaceMesh3D.h @@ -1,9 +1,35 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ // +// This file is part of VirtualFluids. VirtualFluids 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. +// +// VirtualFluids 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 VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file GbQuadFaceMesh3D.h +//! \ingroup geometry3D +//! \author Konstantin Kutscher, Soeren Textor, Sebastian Geller +//======================================================================================= #ifndef GBQUADFACEMESH3D_H #define GBQUADFACEMESH3D_H diff --git a/src/basics/geometry3d/GbSphere3D.cpp b/src/basics/geometry3d/GbSphere3D.cpp index da8aba0cb44e6f447266335874811425e17c8ef3..2cb94c462c6e2c1b95e820fab06fe2d37325ecb1 100644 --- a/src/basics/geometry3d/GbSphere3D.cpp +++ b/src/basics/geometry3d/GbSphere3D.cpp @@ -1,3 +1,35 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids 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. +// +// VirtualFluids 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 VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file GbSphere3D.cpp +//! \ingroup geometry3D +//! \author Konstantin Kutscher, Soeren Textor, Sebastian Geller +//======================================================================================= #include <geometry3d/GbLine3D.h> #include <geometry3d/GbPoint3D.h> #include <geometry3d/GbSphere3D.h> diff --git a/src/basics/geometry3d/GbSphere3D.h b/src/basics/geometry3d/GbSphere3D.h index 738a122a185f8a10eddce64d035cea73b96e8b07..2ffef25dbfa7e0732ddd3e24b158d7046a7b11b6 100644 --- a/src/basics/geometry3d/GbSphere3D.h +++ b/src/basics/geometry3d/GbSphere3D.h @@ -1,9 +1,35 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ // +// This file is part of VirtualFluids. VirtualFluids 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. +// +// VirtualFluids 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 VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file GbSphere3D.h +//! \ingroup geometry3D +//! \author Konstantin Kutscher, Soeren Textor, Sebastian Geller +//======================================================================================= #ifndef GBSPHERE3D_H #define GBSPHERE3D_H diff --git a/src/basics/geometry3d/GbTriFaceMesh3D.cpp b/src/basics/geometry3d/GbTriFaceMesh3D.cpp index f4622a5f35e3f45d7a9b7c32919e84b8a9fb268c..7da89fc9bf0565ec7862939ffa652b3ff1880a4f 100644 --- a/src/basics/geometry3d/GbTriFaceMesh3D.cpp +++ b/src/basics/geometry3d/GbTriFaceMesh3D.cpp @@ -1,4 +1,35 @@ - +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids 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. +// +// VirtualFluids 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 VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file GbTriFaceMesh3D.cpp +//! \ingroup geometry3D +//! \author Konstantin Kutscher, Soeren Textor, Sebastian Geller +//======================================================================================= #include <geometry3d/GbTriFaceMesh3D.h> #include <basics/utilities/UbFileInputASCII.h> @@ -1111,24 +1142,24 @@ void GbTriFaceMesh3D::readMeshFromSTLFileBinary(string filename, bool removeRedu UB_THROW(UbException(UB_EXARGS, "Can not open STL file: " + filename)); } char title[80]; - int nFaces; - size_t read_values = fread(title, 80, 1, f); - read_values = fread((void *)&nFaces, 4, 1, f); + int nFaces; + size_t sizef = fread(title, 80, 1, f); + sizef = fread((void *)&nFaces, 4, 1, f); float v[12]; // normal=3, vertices=3*3 = 12 unsigned short uint16; // Every Face is 50 Bytes: Normal(3*float), Vertices(9*float), 2 Bytes Spacer for (int i = 0; i < nFaces; ++i) { for (size_t j = 0; j < 12; ++j) { - read_values = fread((void *)&v[j], sizeof(float), 1, f); + sizef = fread((void *)&v[j], sizeof(float), 1, f); } - read_values = fread((void *)&uint16, sizeof(unsigned short), 1, f); // spacer between successive faces - (void)read_values; + sizef = fread((void *)&uint16, sizeof(unsigned short), 1, f); // spacer between successive faces nodes->push_back(GbTriFaceMesh3D::Vertex(v[3], v[4], v[5])); nodes->push_back(GbTriFaceMesh3D::Vertex(v[6], v[7], v[8])); nodes->push_back(GbTriFaceMesh3D::Vertex(v[9], v[10], v[11])); triangles->push_back(GbTriFaceMesh3D::TriFace(nr, nr + 1, nr + 2)); nr += 3; } + (void)sizef; fclose(f); if (removeRedundantNodes) { diff --git a/src/basics/geometry3d/GbTriFaceMesh3D.h b/src/basics/geometry3d/GbTriFaceMesh3D.h index 7a3654cb1b939f21ebada4400698b69378b032f0..33ddbe2fdd82fb1cfd8fe96fd8b98843a6e82879 100644 --- a/src/basics/geometry3d/GbTriFaceMesh3D.h +++ b/src/basics/geometry3d/GbTriFaceMesh3D.h @@ -1,9 +1,35 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ // +// This file is part of VirtualFluids. VirtualFluids 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. +// +// VirtualFluids 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 VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file GbTriFaceMesh3D.h +//! \ingroup geometry3D +//! \author Konstantin Kutscher, Soeren Textor, Sebastian Geller +//======================================================================================= #ifndef GBTRIFACEMESH3D_H #define GBTRIFACEMESH3D_H diff --git a/src/basics/geometry3d/GbTriangularMesh3D.cpp b/src/basics/geometry3d/GbTriangularMesh3D.cpp index 94138be759437d57271e172f71be923e493c2c23..3fc0495fad3a1426a9749b43bca7348be4aa6186 100644 --- a/src/basics/geometry3d/GbTriangularMesh3D.cpp +++ b/src/basics/geometry3d/GbTriangularMesh3D.cpp @@ -1,3 +1,35 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids 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. +// +// VirtualFluids 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 VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file GbTriangularMesh3D.cpp +//! \ingroup geometry3D +//! \author Konstantin Kutscher, Soeren Textor, Sebastian Geller +//======================================================================================= #include <geometry3d/GbTriangularMesh3D.h> #include <map> diff --git a/src/basics/geometry3d/GbTriangularMesh3D.h b/src/basics/geometry3d/GbTriangularMesh3D.h index 46be833a2ccd4b6f89b4aa20b7a87a7ca028e118..61f8a4f4b7a0b9b1122bf78b74129ec5da437f86 100644 --- a/src/basics/geometry3d/GbTriangularMesh3D.h +++ b/src/basics/geometry3d/GbTriangularMesh3D.h @@ -1,9 +1,35 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ // +// This file is part of VirtualFluids. VirtualFluids 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. +// +// VirtualFluids 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 VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file GbTriangularMesh3D.h +//! \ingroup geometry3D +//! \author Konstantin Kutscher, Soeren Textor, Sebastian Geller +//======================================================================================= #ifndef GBTRIANGULARMESH_H #define GBTRIANGULARMESH_H diff --git a/src/basics/geometry3d/GbVoxelMatrix3D.cpp b/src/basics/geometry3d/GbVoxelMatrix3D.cpp index d4a047323abea561947abe662ba404dee08b519f..c88f1d13104a5312efd161143d40e835f5654571 100644 --- a/src/basics/geometry3d/GbVoxelMatrix3D.cpp +++ b/src/basics/geometry3d/GbVoxelMatrix3D.cpp @@ -1,3 +1,35 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids 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. +// +// VirtualFluids 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 VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file GbVoxelMatrix3D.cpp +//! \ingroup geometry3D +//! \author Konstantin Kutscher, Soeren Textor, Sebastian Geller +//======================================================================================= #include <geometry3d/GbVoxelMatrix3D.h> #include <basics/utilities/UbFileInputASCII.h> diff --git a/src/basics/geometry3d/GbVoxelMatrix3D.h b/src/basics/geometry3d/GbVoxelMatrix3D.h index 3f166863c8116d2b5900c575ee0baaae6acb2bdc..c71646e206777533fa0423ce5916c974a7124929 100644 --- a/src/basics/geometry3d/GbVoxelMatrix3D.h +++ b/src/basics/geometry3d/GbVoxelMatrix3D.h @@ -1,9 +1,35 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ // +// This file is part of VirtualFluids. VirtualFluids 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. +// +// VirtualFluids 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 VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file GbVoxelMatrix3D.h +//! \ingroup geometry3D +//! \author Konstantin Kutscher, Soeren Textor, Sebastian Geller +//======================================================================================= #ifndef GBVOXELMATRIX3D_H #define GBVOXELMATRIX3D_H @@ -290,8 +316,7 @@ void GbVoxelMatrix3D::readBufferedMatrixFromRawFile(std::string filename, GbVoxe CbArray3D<T> readMatrix(nodesX1, nodesX2, nodesX3); UBLOG(logINFO, " - read file to matrix"); - auto read_values = fread(readMatrix.getStartAdressOfSortedArray(0, 0, 0), sizeof(T), readMatrix.getDataVector().size(), file); - (void) read_values; + fread(readMatrix.getStartAdressOfSortedArray(0, 0, 0), sizeof(T), readMatrix.getDataVector().size(), file); fclose(file); UBLOG(logINFO, " - init values"); diff --git a/src/basics/geometry3d/KdTree/KdNode.h b/src/basics/geometry3d/KdTree/KdNode.h index eef1eb69614b9167fe9710d56f2766c1de4eab13..f60de664934a79a01f1ebcdabb83a862c55ab6b2 100644 --- a/src/basics/geometry3d/KdTree/KdNode.h +++ b/src/basics/geometry3d/KdTree/KdNode.h @@ -1,3 +1,35 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids 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. +// +// VirtualFluids 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 VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file KdNode.h +//! \ingroup KdTree +//! \author Soeren Textor, Sebastian Bindick +//======================================================================================= #ifndef KDNODE_H #define KDNODE_H diff --git a/src/basics/geometry3d/KdTree/KdRay.h b/src/basics/geometry3d/KdTree/KdRay.h index b37e30ce6666fdc8d061a4341dce810a077644f4..43bbcd4500c98a5aa8fc4ba52993f8b62d6d1021 100644 --- a/src/basics/geometry3d/KdTree/KdRay.h +++ b/src/basics/geometry3d/KdTree/KdRay.h @@ -1,3 +1,35 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids 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. +// +// VirtualFluids 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 VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file KdRay.h +//! \ingroup KdTree +//! \author Soeren Textor, Sebastian Bindick +//======================================================================================= #ifndef KDRAY_H #define KDRAY_H diff --git a/src/basics/geometry3d/KdTree/KdSplitCandidate.h b/src/basics/geometry3d/KdTree/KdSplitCandidate.h index b937a1235b732d420483f1fb8580ce396a874641..cfd2fc3bca2ca1eccae8418c11ad4c69fe892954 100644 --- a/src/basics/geometry3d/KdTree/KdSplitCandidate.h +++ b/src/basics/geometry3d/KdTree/KdSplitCandidate.h @@ -1,3 +1,35 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids 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. +// +// VirtualFluids 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 VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file KdSplitCandidate.h +//! \ingroup KdTree +//! \author Soeren Textor, Sebastian Bindick +//======================================================================================= #ifndef KDSPLITCANDIDATE_H #define KDSPLITCANDIDATE_H diff --git a/src/basics/geometry3d/KdTree/KdSplitCandidateManager.h b/src/basics/geometry3d/KdTree/KdSplitCandidateManager.h index cf32711b14a6acfc0d5fb2c1afc37aeda68e504a..d7f4bdf10f141ef6358759708ef9d4fa9d5b9e11 100644 --- a/src/basics/geometry3d/KdTree/KdSplitCandidateManager.h +++ b/src/basics/geometry3d/KdTree/KdSplitCandidateManager.h @@ -1,3 +1,35 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids 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. +// +// VirtualFluids 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 VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file KdSplitCandidateManager.h +//! \ingroup KdTree +//! \author Soeren Textor, Sebastian Bindick +//======================================================================================= #ifndef KDSPLITCANDIDATEMANAGER_H #define KDSPLITCANDIDATEMANAGER_H diff --git a/src/basics/geometry3d/KdTree/KdTree.h b/src/basics/geometry3d/KdTree/KdTree.h index 42c337f66cdddb450108e973fc0a75323512a149..b290c3c61a0591e04cc9358769ef3ce087192f30 100644 --- a/src/basics/geometry3d/KdTree/KdTree.h +++ b/src/basics/geometry3d/KdTree/KdTree.h @@ -1,3 +1,35 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids 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. +// +// VirtualFluids 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 VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file KdTree.h +//! \ingroup KdTree +//! \author Soeren Textor, Sebastian Bindick +//======================================================================================= #ifndef KDTREE_H #define KDTREE_H @@ -75,7 +107,7 @@ public: new std::vector<GbTriFaceMesh3D::TriFace>(*mesh.getTriangles())); const int maxLevel = - static_cast<int>(lround(8.0 + 1.3 * std::log((double)triFaces->size()))); // TODO: remove magic numbers + static_cast<int>(std::lround(8.0 + 1.3 * std::log((double)triFaces->size()))); // TODO: remove magic numbers rootNode = new Node<T>(T(mesh.getX1Minimum()), T(mesh.getX2Minimum()), T(mesh.getX3Minimum()), T(mesh.getX1Maximum()), diff --git a/src/basics/geometry3d/KdTree/KdUtilities.cpp b/src/basics/geometry3d/KdTree/KdUtilities.cpp index b2b56b0912297cbfb355d97a4a120f54820828ab..0dca20ad16b1f2bd89a7591ffe1264e6d1098c82 100644 --- a/src/basics/geometry3d/KdTree/KdUtilities.cpp +++ b/src/basics/geometry3d/KdTree/KdUtilities.cpp @@ -1,3 +1,35 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids 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. +// +// VirtualFluids 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 VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file KdUtilities.cpp +//! \ingroup KdTree +//! \author Soeren Textor, Sebastian Bindick +//======================================================================================= #include <geometry3d/KdTree/KdUtilities.h> namespace Kd diff --git a/src/basics/geometry3d/KdTree/KdUtilities.h b/src/basics/geometry3d/KdTree/KdUtilities.h index bf02ee4443f24782875478d4e30431fcb8910b9b..7a304102c7effd2ce1cc487427aa712b1ada2592 100644 --- a/src/basics/geometry3d/KdTree/KdUtilities.h +++ b/src/basics/geometry3d/KdTree/KdUtilities.h @@ -1,3 +1,35 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids 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. +// +// VirtualFluids 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 VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file KdUtilities.h +//! \ingroup KdTree +//! \author Soeren Textor, Sebastian Bindick +//======================================================================================= #ifndef KDUTILIES_H #define KDUTILIES_H diff --git a/src/basics/geometry3d/KdTree/intersectionhandler/KdCountLineIntersectionHandler.h b/src/basics/geometry3d/KdTree/intersectionhandler/KdCountLineIntersectionHandler.h index 0e5a9eb02569e1408dceb2a04ca8fdf97e658260..49b2754d6f3d6180e16c09b4d74d6dfde8dd4528 100644 --- a/src/basics/geometry3d/KdTree/intersectionhandler/KdCountLineIntersectionHandler.h +++ b/src/basics/geometry3d/KdTree/intersectionhandler/KdCountLineIntersectionHandler.h @@ -1,3 +1,35 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids 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. +// +// VirtualFluids 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 VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file KdCountLineIntersectionHandler.h +//! \ingroup splitalgorithms +//! \author Soeren Textor, Sebastian Bindick +//======================================================================================= #ifndef KDCOUNTLINEINTERSECTIONHANDLER_H #define KDCOUNTLINEINTERSECTIONHANDLER_H diff --git a/src/basics/geometry3d/KdTree/intersectionhandler/KdCountRayIntersectionHandler.h b/src/basics/geometry3d/KdTree/intersectionhandler/KdCountRayIntersectionHandler.h index 2fab632ff78b60cd7d6dd2f595aba3562d1f9804..7ca7ed3ee3e9eba80b7ee3cf090502c929df3fc9 100644 --- a/src/basics/geometry3d/KdTree/intersectionhandler/KdCountRayIntersectionHandler.h +++ b/src/basics/geometry3d/KdTree/intersectionhandler/KdCountRayIntersectionHandler.h @@ -1,3 +1,35 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids 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. +// +// VirtualFluids 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 VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file KdCountRayIntersectionHandler.h +//! \ingroup splitalgorithms +//! \author Soeren Textor, Sebastian Bindick +//======================================================================================= #ifndef KDCOUNTRAYINTERSECTIONHANDLER_H #define KDCOUNTRAYINTERSECTIONHANDLER_H diff --git a/src/basics/geometry3d/KdTree/intersectionhandler/KdLineIntersectionHandler.h b/src/basics/geometry3d/KdTree/intersectionhandler/KdLineIntersectionHandler.h index 61d4800d22fa6b8e204c1325f781b9fbf411c057..0895f740894341b8cf5b3d340b114eb76b88a58e 100644 --- a/src/basics/geometry3d/KdTree/intersectionhandler/KdLineIntersectionHandler.h +++ b/src/basics/geometry3d/KdTree/intersectionhandler/KdLineIntersectionHandler.h @@ -1,3 +1,35 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids 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. +// +// VirtualFluids 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 VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file KdLineIntersectionHandler.h +//! \ingroup splitalgorithms +//! \author Soeren Textor, Sebastian Bindick +//======================================================================================= #ifndef KDLINEINTERSECTIONHANDLER_H #define KDLINEINTERSECTIONHANDLER_H diff --git a/src/basics/geometry3d/KdTree/intersectionhandler/KdRayIntersectionHandler.h b/src/basics/geometry3d/KdTree/intersectionhandler/KdRayIntersectionHandler.h index 2965b0b393c5e324af0a7d3dea593f703f208db1..e38fcd5340a94200b961c27f092aec1258722c13 100644 --- a/src/basics/geometry3d/KdTree/intersectionhandler/KdRayIntersectionHandler.h +++ b/src/basics/geometry3d/KdTree/intersectionhandler/KdRayIntersectionHandler.h @@ -1,3 +1,35 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids 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. +// +// VirtualFluids 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 VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file KdRayIntersectionHandler.h +//! \ingroup splitalgorithms +//! \author Soeren Textor, Sebastian Bindick +//======================================================================================= #ifndef KDRAYINTERSECTIONHANDLER_H #define KDRAYINTERSECTIONHANDLER_H diff --git a/src/basics/geometry3d/KdTree/splitalgorithms/KdSAHSplit.cpp b/src/basics/geometry3d/KdTree/splitalgorithms/KdSAHSplit.cpp index 31cfa74d8bc32628e87a8db5e184b9df5134b3a8..b1437df34892146645692691894ace02b509871b 100644 --- a/src/basics/geometry3d/KdTree/splitalgorithms/KdSAHSplit.cpp +++ b/src/basics/geometry3d/KdTree/splitalgorithms/KdSAHSplit.cpp @@ -1,3 +1,35 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids 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. +// +// VirtualFluids 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 VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file KdSAHSplit.cpp +//! \ingroup splitalgorithms +//! \author Soeren Textor, Sebastian Bindick +//======================================================================================= //#include <geometry3d/KdTree/SAHSplit.h> // namespace Kd diff --git a/src/basics/geometry3d/KdTree/splitalgorithms/KdSAHSplit.h b/src/basics/geometry3d/KdTree/splitalgorithms/KdSAHSplit.h index c828f5f7fdc95000f64a83e964c0697649e31f97..334c911fb8fc68bf3b1c82a9757d026320edcf8e 100644 --- a/src/basics/geometry3d/KdTree/splitalgorithms/KdSAHSplit.h +++ b/src/basics/geometry3d/KdTree/splitalgorithms/KdSAHSplit.h @@ -1,3 +1,35 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids 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. +// +// VirtualFluids 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 VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file KdSAHSplit.h +//! \ingroup splitalgorithms +//! \author Soeren Textor, Sebastian Bindick +//======================================================================================= #ifndef KDSAHSPLIT_H #define KDSAHSPLIT_H diff --git a/src/basics/geometry3d/KdTree/splitalgorithms/KdSpatiallMedianSplit.h b/src/basics/geometry3d/KdTree/splitalgorithms/KdSpatiallMedianSplit.h index 518ac967ae1f26d6c67cd6946fbaf8ce1360c4bc..57a3eef3b9e2d2698b307fcac124f932b8b0b148 100644 --- a/src/basics/geometry3d/KdTree/splitalgorithms/KdSpatiallMedianSplit.h +++ b/src/basics/geometry3d/KdTree/splitalgorithms/KdSpatiallMedianSplit.h @@ -1,3 +1,35 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids 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. +// +// VirtualFluids 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 VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file KdSpacialMedianSplit.h +//! \ingroup splitalgorithms +//! \author Soeren Textor, Sebastian Bindick +//======================================================================================= #ifndef SPATIALLMEDIANSPLIT_H #define SPATIALLMEDIANSPLIT_H diff --git a/src/basics/geometry3d/KdTree/splitalgorithms/KdSplitAlgorithm.h b/src/basics/geometry3d/KdTree/splitalgorithms/KdSplitAlgorithm.h index c767a0c0d1013441610e6b1eb20501796c42c78e..b6901241e9dd36a1f687ff87a9a292ef95daa1b8 100644 --- a/src/basics/geometry3d/KdTree/splitalgorithms/KdSplitAlgorithm.h +++ b/src/basics/geometry3d/KdTree/splitalgorithms/KdSplitAlgorithm.h @@ -1,3 +1,35 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids 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. +// +// VirtualFluids 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 VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file KdSplitAlgorithm.h +//! \ingroup splitalgorithms +//! \author Soeren Textor, Sebastian Bindick +//======================================================================================= #ifndef KDSPLITALGORITHM_H #define KDSPLITALGORITHM_H diff --git a/src/cpu/DemCoupling/CreateDemObjectsCoProcessor.cpp b/src/cpu/DemCoupling/CreateDemObjectsCoProcessor.cpp index dacf8cfc870566455d1c91d94fd27e17239690e9..6f32a053afb4f6f45ae74e32b7f8665ab4fd58db 100644 --- a/src/cpu/DemCoupling/CreateDemObjectsCoProcessor.cpp +++ b/src/cpu/DemCoupling/CreateDemObjectsCoProcessor.cpp @@ -1,5 +1,5 @@ #include "CreateDemObjectsCoProcessor.h" -#include "Communicator.h" +#include <mpi/Communicator.h> #include "DemCoProcessor.h" #include "EquilibriumReconstructor.h" #include "ExtrapolationReconstructor.h" @@ -19,7 +19,7 @@ #include "muParser.h" CreateDemObjectsCoProcessor::CreateDemObjectsCoProcessor(SPtr<Grid3D> grid, SPtr<UbScheduler> s, - std::shared_ptr<Communicator> comm, + std::shared_ptr<vf::mpi::Communicator> comm, SPtr<DemCoProcessor> demCoProcessor, SPtr<PhysicsEngineMaterialAdapter> demObjectMaterial, double tolerance) diff --git a/src/cpu/DemCoupling/CreateDemObjectsCoProcessor.h b/src/cpu/DemCoupling/CreateDemObjectsCoProcessor.h index c8ecc6842ee0f77142ad05e5cb90ed71baaa5d64..7da317e67bd932f7d594c68d63ebc117b50c1e85 100644 --- a/src/cpu/DemCoupling/CreateDemObjectsCoProcessor.h +++ b/src/cpu/DemCoupling/CreateDemObjectsCoProcessor.h @@ -14,7 +14,7 @@ class Grid3D; class UbScheduler; -class Communicator; +namespace vf::mpi {class Communicator;} class DemCoProcessor; class GbObject3D; class BCAdapter; @@ -24,7 +24,7 @@ class PhysicsEngineMaterialAdapter; class CreateDemObjectsCoProcessor : public CoProcessor { public: - CreateDemObjectsCoProcessor(SPtr<Grid3D> grid, SPtr<UbScheduler> s, std::shared_ptr<Communicator> comm, + CreateDemObjectsCoProcessor(SPtr<Grid3D> grid, SPtr<UbScheduler> s, std::shared_ptr<vf::mpi::Communicator> comm, SPtr<DemCoProcessor> demCoProcessor, SPtr<PhysicsEngineMaterialAdapter> geoObjectMaterial, double tolerance = 0); void process(double step) override; @@ -36,7 +36,7 @@ public: protected: private: - SPtr<Communicator> comm; + std::shared_ptr<vf::mpi::Communicator> comm; SPtr<DemCoProcessor> demCoProcessor; std::vector<SPtr<GbObject3D>> geoObjectPrototypeVector; SPtr<PhysicsEngineMaterialAdapter> demObjectMaterial; diff --git a/src/cpu/DemCoupling/DemCoProcessor.cpp b/src/cpu/DemCoupling/DemCoProcessor.cpp index 554ffaa6c76f36ad0b5834854c88b8f14864efe8..642a942d7d96b73af898690a5737f53d2d88b1a5 100644 --- a/src/cpu/DemCoupling/DemCoProcessor.cpp +++ b/src/cpu/DemCoupling/DemCoProcessor.cpp @@ -1,7 +1,7 @@ #include "DemCoProcessor.h" #include "BCProcessor.h" -#include "Communicator.h" +#include <mpi/Communicator.h> #include "DataSet3D.h" #include "DistributionArray3D.h" #include "ForceCalculator.h" @@ -29,7 +29,7 @@ #include <array> #include <functional> -DemCoProcessor::DemCoProcessor(SPtr<Grid3D> grid, SPtr<UbScheduler> s, SPtr<Communicator> comm, +DemCoProcessor::DemCoProcessor(SPtr<Grid3D> grid, SPtr<UbScheduler> s, std::shared_ptr<vf::mpi::Communicator> comm, std::shared_ptr<ForceCalculator> forceCalculator, std::shared_ptr<PhysicsEngineSolverAdapter> physicsEngineSolver, double intermediatePeSteps) diff --git a/src/cpu/DemCoupling/DemCoProcessor.h b/src/cpu/DemCoupling/DemCoProcessor.h index 64fe2436128cb6eb5aabe118785213d1212ca296..d2946f1e93fcaedc69d44a83a68dc2079910e48f 100644 --- a/src/cpu/DemCoupling/DemCoProcessor.h +++ b/src/cpu/DemCoupling/DemCoProcessor.h @@ -31,15 +31,14 @@ class PePhysicsEngineGeometryAdapter; class UbScheduler; class Grid3D; class ForceCalculator; -class Communicator; +namespace vf::mpi {class Communicator;} class MovableObjectInteractor; -class Communicator; class BoundaryConditionsBlockVisitor; class DemCoProcessor : public CoProcessor { public: - DemCoProcessor(std::shared_ptr<Grid3D> grid, std::shared_ptr<UbScheduler> s, std::shared_ptr<Communicator> comm, + DemCoProcessor(std::shared_ptr<Grid3D> grid, std::shared_ptr<UbScheduler> s, std::shared_ptr<vf::mpi::Communicator> comm, std::shared_ptr<ForceCalculator> forceCalculator, std::shared_ptr<PhysicsEngineSolverAdapter> physicsEngineSolver, double intermediatePeSteps = 1.0); virtual ~DemCoProcessor(); @@ -74,7 +73,7 @@ private: std::shared_ptr<PePhysicsEngineGeometryAdapter> getPeGeoAdapter(unsigned long long systemId); private: - std::shared_ptr<Communicator> comm; + std::shared_ptr<vf::mpi::Communicator> comm; std::vector<std::shared_ptr<MovableObjectInteractor>> interactors; std::shared_ptr<ForceCalculator> forceCalculator; std::shared_ptr<PePhysicsEngineSolverAdapter> physicsEngineSolver; diff --git a/src/cpu/DemCoupling/PePartitioningGridVisitor.cpp b/src/cpu/DemCoupling/PePartitioningGridVisitor.cpp index 8dbe680a89e913c71ce116e1203bb5d005d4bbdd..429eaeb8be0d3a601b64199e5e86279f7d05ce8f 100644 --- a/src/cpu/DemCoupling/PePartitioningGridVisitor.cpp +++ b/src/cpu/DemCoupling/PePartitioningGridVisitor.cpp @@ -2,7 +2,7 @@ #include "PePartitioningGridVisitor.h" #include "Block3D.h" -#include "Communicator.h" +#include <mpi/Communicator.h> #include "CoordinateTransformation3D.h" #include "Grid3D.h" #include "UbLogger.h" @@ -13,7 +13,7 @@ using namespace std; -PePartitioningGridVisitor::PePartitioningGridVisitor(SPtr<Communicator> comm, std::shared_ptr<DemCoProcessor> dem) +PePartitioningGridVisitor::PePartitioningGridVisitor(std::shared_ptr<vf::mpi::Communicator> comm, std::shared_ptr<DemCoProcessor> dem) : Grid3DVisitor(), comm(comm), dem(dem) { forest = dynamicPointerCast<PePhysicsEngineSolverAdapter>(dem->getPhysicsEngineSolver())->getForest(); diff --git a/src/cpu/DemCoupling/PePartitioningGridVisitor.h b/src/cpu/DemCoupling/PePartitioningGridVisitor.h index ff97d531d7f6ccaebb8c7e3a1ab60c2c27177bf5..cad80c0f4d986c45560c6111e8943226df136d24 100644 --- a/src/cpu/DemCoupling/PePartitioningGridVisitor.h +++ b/src/cpu/DemCoupling/PePartitioningGridVisitor.h @@ -16,7 +16,7 @@ //! \brief The class implements domain decomposition with PE library //! \author Konstantin Kutscher ////////////////////////////////////////////////////////////////////////// -class Communicator; +namespace vf::mpi {class Communicator;} class Grid3D; class Block3D; class DemCoProcessor; @@ -32,7 +32,7 @@ public: //! Constructor //! \param comm - communicator - PePartitioningGridVisitor(SPtr<Communicator> comm, std::shared_ptr<DemCoProcessor> dem); + PePartitioningGridVisitor(std::shared_ptr<vf::mpi::Communicator> comm, std::shared_ptr<DemCoProcessor> dem); virtual ~PePartitioningGridVisitor(); void visit(SPtr<Grid3D> grid) override; @@ -44,7 +44,7 @@ protected: SPtr<Block3D> getBlockByMinUniform(double minX1, double minX2, double minX3, SPtr<Grid3D> grid); private: - SPtr<Communicator> comm; + std::shared_ptr<vf::mpi::Communicator> comm; std::shared_ptr<DemCoProcessor> dem; std::vector<int> ids; diff --git a/src/cpu/DemCoupling/RestartDemObjectsCoProcessor.cpp b/src/cpu/DemCoupling/RestartDemObjectsCoProcessor.cpp index 1d018376319ce7bed6eca6e4ef7f4492237699fb..ff6cbe7e5a3e394bac18016507a57308d0f1ecbf 100644 --- a/src/cpu/DemCoupling/RestartDemObjectsCoProcessor.cpp +++ b/src/cpu/DemCoupling/RestartDemObjectsCoProcessor.cpp @@ -1,6 +1,6 @@ #include "RestartDemObjectsCoProcessor.h" -#include "Communicator.h" +#include <mpi/Communicator.h> #include "CreateDemObjectsCoProcessor.h" #include "DemCoProcessor.h" #include "GbSphere3D.h" @@ -15,7 +15,7 @@ RestartDemObjectsCoProcessor::RestartDemObjectsCoProcessor() {} RestartDemObjectsCoProcessor::RestartDemObjectsCoProcessor( SPtr<Grid3D> grid, SPtr<UbScheduler> s, const std::string &path, SPtr<DemCoProcessor> demCoProcessor, - SPtr<CreateDemObjectsCoProcessor> createDemObjectsCoProcessor, double radius, SPtr<Communicator> comm) + SPtr<CreateDemObjectsCoProcessor> createDemObjectsCoProcessor, double radius, std::shared_ptr<vf::mpi::Communicator> comm) : CoProcessor(grid, s), path(path), demCoProcessor(demCoProcessor), createDemObjectsCoProcessor(createDemObjectsCoProcessor), radius(radius), comm(comm) { diff --git a/src/cpu/DemCoupling/RestartDemObjectsCoProcessor.h b/src/cpu/DemCoupling/RestartDemObjectsCoProcessor.h index 08fb70ef5821ceb3d53d8e4d1e0489519cc8f881..5123a2d6e51ece8e96d6623d573141a8c272026f 100644 --- a/src/cpu/DemCoupling/RestartDemObjectsCoProcessor.h +++ b/src/cpu/DemCoupling/RestartDemObjectsCoProcessor.h @@ -11,7 +11,7 @@ #include "CoProcessor.h" -class Communicator; +namespace vf::mpi {class Communicator;} class Grid3D; class UbScheduler; class DemCoProcessor; @@ -24,7 +24,7 @@ public: RestartDemObjectsCoProcessor(SPtr<Grid3D> grid, SPtr<UbScheduler> s, const std::string &path, SPtr<DemCoProcessor> demCoProcessor, SPtr<CreateDemObjectsCoProcessor> createDemObjectsCoProcessor, double radius, - SPtr<Communicator> comm); + std::shared_ptr<vf::mpi::Communicator> comm); ~RestartDemObjectsCoProcessor() {} void process(double step) override; void restart(double step); @@ -34,7 +34,7 @@ public: private: std::string path; double radius; - SPtr<Communicator> comm; + std::shared_ptr<vf::mpi::Communicator> comm; SPtr<DemCoProcessor> demCoProcessor; SPtr<CreateDemObjectsCoProcessor> createDemObjectsCoProcessor; }; diff --git a/src/cpu/DemCoupling/WriteDemObjectsCoProcessor.cpp b/src/cpu/DemCoupling/WriteDemObjectsCoProcessor.cpp index 03b0c278373a8eb1b74172f31cef044442cccae4..3e22c90cf266fa8593b0036d160d79080a3ad31c 100644 --- a/src/cpu/DemCoupling/WriteDemObjectsCoProcessor.cpp +++ b/src/cpu/DemCoupling/WriteDemObjectsCoProcessor.cpp @@ -3,7 +3,7 @@ #include "basics/writer/WbWriterVtkXmlASCII.h" #include "basics/writer/WbWriterVtkXmlBinary.h" -#include "Communicator.h" +#include <mpi/Communicator.h> #include "DemCoProcessor.h" #include "Grid3D.h" #include "UbScheduler.h" @@ -13,7 +13,7 @@ WriteDemObjectsCoProcessor::WriteDemObjectsCoProcessor() {} ////////////////////////////////////////////////////////////////////////// WriteDemObjectsCoProcessor::WriteDemObjectsCoProcessor(SPtr<Grid3D> grid, SPtr<UbScheduler> s, const std::string &path, WbWriter *const writer, SPtr<DemCoProcessor> demCoProcessor, - SPtr<Communicator> comm) + std::shared_ptr<vf::mpi::Communicator> comm) : CoProcessor(grid, s), path(path), writer(writer), demCoProcessor(demCoProcessor), comm(comm) { } diff --git a/src/cpu/DemCoupling/WriteDemObjectsCoProcessor.h b/src/cpu/DemCoupling/WriteDemObjectsCoProcessor.h index 6c45b86322a792bcdb165b70082d5ae08b6cc496..7fb3b045ccd439d772ef565c2013af32c75a7a2d 100644 --- a/src/cpu/DemCoupling/WriteDemObjectsCoProcessor.h +++ b/src/cpu/DemCoupling/WriteDemObjectsCoProcessor.h @@ -11,7 +11,7 @@ #include "CoProcessor.h" -class Communicator; +namespace vf::mpi {class Communicator;} class Grid3D; class UbScheduler; class DemCoProcessor; @@ -22,14 +22,14 @@ class WriteDemObjectsCoProcessor : public CoProcessor public: WriteDemObjectsCoProcessor(); WriteDemObjectsCoProcessor(SPtr<Grid3D> grid, SPtr<UbScheduler> s, const std::string &path, WbWriter *const writer, - SPtr<DemCoProcessor> demCoProcessor, SPtr<Communicator> comm); + SPtr<DemCoProcessor> demCoProcessor, std::shared_ptr<vf::mpi::Communicator> comm); ~WriteDemObjectsCoProcessor() {} void process(double step) override; private: std::string path; WbWriter *writer; - SPtr<Communicator> comm; + std::shared_ptr<vf::mpi::Communicator> comm; SPtr<DemCoProcessor> demCoProcessor; }; #endif diff --git a/src/cpu/DemCoupling/WritePeBlocksCoProcessor.cpp b/src/cpu/DemCoupling/WritePeBlocksCoProcessor.cpp index 693a23c5cf6157dbdc3f3011330926ecae79b6bf..401ea91bc7225eea7f871cbc2e92be44d1a5c9d7 100644 --- a/src/cpu/DemCoupling/WritePeBlocksCoProcessor.cpp +++ b/src/cpu/DemCoupling/WritePeBlocksCoProcessor.cpp @@ -3,13 +3,13 @@ #include "basics/writer/WbWriterVtkXmlASCII.h" #include "Block3D.h" -#include "Communicator.h" +#include <mpi/Communicator.h> #include "D3Q27System.h" #include "Grid3D.h" #include "UbScheduler.h" WritePeBlocksCoProcessor::WritePeBlocksCoProcessor(SPtr<Grid3D> grid, SPtr<UbScheduler> s, const std::string &path, - WbWriter *const writer, SPtr<Communicator> comm, + WbWriter *const writer, std::shared_ptr<vf::mpi::Communicator> comm, SPtr<walberla::blockforest::BlockForest> forest) : CoProcessor(grid, s), path(path), writer(writer), comm(comm), forest(forest) { diff --git a/src/cpu/DemCoupling/WritePeBlocksCoProcessor.h b/src/cpu/DemCoupling/WritePeBlocksCoProcessor.h index 72334abd5e55fe4b9e4700540fca185db68f44b4..ae27d50b3f0bba867db7ad8cce79f2e5d8fd5681 100644 --- a/src/cpu/DemCoupling/WritePeBlocksCoProcessor.h +++ b/src/cpu/DemCoupling/WritePeBlocksCoProcessor.h @@ -15,7 +15,7 @@ #include <pe/basic.h> -class Communicator; +namespace vf::mpi {class Communicator;} class Grid3D; class UbScheduler; class WbWriter; @@ -24,7 +24,7 @@ class WritePeBlocksCoProcessor : public CoProcessor { public: WritePeBlocksCoProcessor(SPtr<Grid3D> grid, SPtr<UbScheduler> s, const std::string &path, WbWriter *const writer, - SPtr<Communicator> comm, SPtr<walberla::blockforest::BlockForest> forest); + std::shared_ptr<vf::mpi::Communicator> comm, SPtr<walberla::blockforest::BlockForest> forest); virtual ~WritePeBlocksCoProcessor(); void process(double step) override; @@ -34,7 +34,7 @@ protected: std::string path; WbWriter *writer; - SPtr<Communicator> comm; + std::shared_ptr<vf::mpi::Communicator> comm; SPtr<walberla::blockforest::BlockForest> forest; }; diff --git a/src/cpu/DemCoupling/physicsEngineAdapter/pe/PePhysicsEngineSolverAdapter.cpp b/src/cpu/DemCoupling/physicsEngineAdapter/pe/PePhysicsEngineSolverAdapter.cpp index dd78dc143fd0aa149663ae674146198491917644..14cef406392fbfbd9862a71b0c054df85a8608ec 100644 --- a/src/cpu/DemCoupling/physicsEngineAdapter/pe/PePhysicsEngineSolverAdapter.cpp +++ b/src/cpu/DemCoupling/physicsEngineAdapter/pe/PePhysicsEngineSolverAdapter.cpp @@ -8,7 +8,7 @@ #include <pe/basic.h> #include <pe/rigidbody/UnionFactory.h> //#include "geometry/GeometricalFunctions.h" -#include "Communicator.h" +#include <mpi/Communicator.h> #include "PeAdapter.h" #include "PeLoadBalancerAdapter.h" #include "PePhysicsEngineGeometryAdapter.h" diff --git a/src/cpu/VirtualFluids.h b/src/cpu/VirtualFluids.h index f5064398a6a2953c20f844be3db5865a16620e93..ee5f07a02552bbb04e21be2b3abd5b7015f14144 100644 --- a/src/cpu/VirtualFluids.h +++ b/src/cpu/VirtualFluids.h @@ -40,9 +40,14 @@ #include <omp.h> #endif +#include <mpi/Communicator.h> +#include <mpi/MPICommunicator.h> +#include <mpi/NullCommunicator.h> + #include <basics/PointerDefinitions.h> #include <basics/config/ConfigurationFile.h> +#include <logger/Logger.h> #include <basics/container/CbArray2D.h> #include <basics/container/CbArray3D.h> @@ -135,8 +140,8 @@ #include <BoundaryConditions/SimpleSlipBCAlgorithm.h> #include <BoundaryConditions/RheologyPowellEyringModelNoSlipBCAlgorithm.h> #include <BoundaryConditions/RheologyBinghamModelVelocityBCAlgorithm.h> -#include <BoundaryConditions/MultiphaseNoSlipBCAlgorithm.h> -#include <BoundaryConditions/MultiphaseNonReflectingOutflowBCAlgorithm.h> +#include <BoundaryConditions/MultiphaseNoSlipBCAlgorithm.h> +#include <BoundaryConditions/MultiphaseNonReflectingOutflowBCAlgorithm.h> #include <BoundaryConditions/MultiphaseVelocityBCAdapter.h> #include <BoundaryConditions/MultiphaseVelocityBCAlgorithm.h> @@ -283,10 +288,7 @@ #include <geometry3d/KdTree/splitalgorithms/KdSplitAlgorithm.h> #include <Parallel/BlocksDistributor.h> -#include <Parallel/Communicator.h> -#include <Parallel/MPICommunicator.h> #include <Parallel/MetisPartitioner.h> -#include <Parallel/NullCommunicator.h> #include <Parallel/PriorityQueueDecompositor.h> #include <Parallel/SimpleGeometricPartitioner.h> #include <Parallel/ZoltanPartitioner.h> diff --git a/src/cpu/VirtualFluidsCore/CMakeLists.txt b/src/cpu/VirtualFluidsCore/CMakeLists.txt index 36ac278fb8aee484d38a09a3fd4499965875f712..a9ee657434ae6ace1fd85974d825469a9e038d68 100644 --- a/src/cpu/VirtualFluidsCore/CMakeLists.txt +++ b/src/cpu/VirtualFluidsCore/CMakeLists.txt @@ -22,11 +22,10 @@ IF(${USE_DEM_COUPLING}) ENDIF() if(BUILD_USE_OPENMP) - list(APPEND VF_LIBRARIES OpenMP::OpenMP_CXX) + list(APPEND VF_LIBRARIES OpenMP::OpenMP_CXX) endif() -vf_add_library(BUILDTYPE static PUBLIC_LINK basics muparser MPI::MPI_CXX ${VF_LIBRARIES} PRIVATE_LINK lbm) - +vf_add_library(BUILDTYPE static PUBLIC_LINK basics muparser ${VF_LIBRARIES} PRIVATE_LINK lbm mpi logger) vf_get_library_name(library_name) diff --git a/src/cpu/VirtualFluidsCore/CoProcessors/AdjustForcingCoProcessor.cpp b/src/cpu/VirtualFluidsCore/CoProcessors/AdjustForcingCoProcessor.cpp index 2174090103ddfd5c806d62cb30a8e1567403251c..d02c249a62f60cdb91fbd4af9e975d39c6c4e29d 100644 --- a/src/cpu/VirtualFluidsCore/CoProcessors/AdjustForcingCoProcessor.cpp +++ b/src/cpu/VirtualFluidsCore/CoProcessors/AdjustForcingCoProcessor.cpp @@ -6,7 +6,7 @@ #include <fstream> -#include "Communicator.h" +#include <mpi/Communicator.h> #include "Grid3D.h" #include "IntegrateValuesHelper.h" #include "UbScheduler.h" @@ -14,7 +14,7 @@ AdjustForcingCoProcessor::AdjustForcingCoProcessor(SPtr<Grid3D> grid, SPtr<UbScheduler> s, const std::string &path, SPtr<IntegrateValuesHelper> integrateValues, double vTarged, - SPtr<Communicator> comm) + std::shared_ptr<vf::mpi::Communicator> comm) : CoProcessor(grid, s), path(path), integrateValues(integrateValues), comm(comm), vx1Targed(vTarged) { diff --git a/src/cpu/VirtualFluidsCore/CoProcessors/AdjustForcingCoProcessor.h b/src/cpu/VirtualFluidsCore/CoProcessors/AdjustForcingCoProcessor.h index 93b99dadab125f87a12b1e905c3171559a5ea31f..fbf75d066e626a3cf3d44c481138a9b1007b3107 100644 --- a/src/cpu/VirtualFluidsCore/CoProcessors/AdjustForcingCoProcessor.h +++ b/src/cpu/VirtualFluidsCore/CoProcessors/AdjustForcingCoProcessor.h @@ -6,7 +6,7 @@ #include "CoProcessor.h" -class Communicator; +namespace vf::mpi {class Communicator;} class UbScheduler; class Grid3D; class IntegrateValuesHelper; @@ -21,7 +21,7 @@ class AdjustForcingCoProcessor : public CoProcessor { public: AdjustForcingCoProcessor(SPtr<Grid3D> grid, SPtr<UbScheduler> s, const std::string &path, - SPtr<IntegrateValuesHelper> integrateValues, double vTarged, SPtr<Communicator> comm); + SPtr<IntegrateValuesHelper> integrateValues, double vTarged, std::shared_ptr<vf::mpi::Communicator> comm); //!< calls collect PostprocessData void process(double step) override; @@ -30,7 +30,7 @@ protected: SPtr<IntegrateValuesHelper> integrateValues; //!< compares velocity in integrateValues with target velocity and adjusts forcing accordingly. void collectData(double step); - SPtr<Communicator> comm; + std::shared_ptr<vf::mpi::Communicator> comm; private: double vx1Targed; //!< target velocity. diff --git a/src/cpu/VirtualFluidsCore/CoProcessors/AverageValuesCoProcessor.cpp b/src/cpu/VirtualFluidsCore/CoProcessors/AverageValuesCoProcessor.cpp index 6912d4bb9c3a2034adb33c0e05722cb6d93a01c3..adce3f920ed36850ff711c10c7777a5035de027e 100644 --- a/src/cpu/VirtualFluidsCore/CoProcessors/AverageValuesCoProcessor.cpp +++ b/src/cpu/VirtualFluidsCore/CoProcessors/AverageValuesCoProcessor.cpp @@ -7,7 +7,7 @@ #include "BCArray3D.h" #include "Block3D.h" -#include "Communicator.h" +#include <mpi/Communicator.h> #include "DataSet3D.h" #include "Grid3D.h" #include "UbScheduler.h" @@ -185,7 +185,7 @@ void AverageValuesCoProcessor::collectData(double step) piece = subfolder + "/" + piece; vector<string> cellDataNames; - SPtr<Communicator> comm = Communicator::getInstance(); + std::shared_ptr<vf::mpi::Communicator> comm = vf::mpi::Communicator::getInstance(); vector<string> pieces = comm->gather(piece); if (comm->getProcessID() == comm->getRoot()) { string pname = @@ -448,7 +448,7 @@ void AverageValuesCoProcessor::calculateAverageValues(double timeStep) //////////////////////////////////////////////////////////////////////////// // void AverageValuesCoProcessor::initPlotData(double step) //{ -// SPtr<Communicator> comm = Communicator::getInstance(); +// std::shared_ptr<vf::mpi::Communicator> comm = vf::mpi::Communicator::getInstance(); // if (comm->getProcessID() == comm->getRoot()) // { // std::ofstream ostr; diff --git a/src/cpu/VirtualFluidsCore/CoProcessors/CalculateForcesCoProcessor.cpp b/src/cpu/VirtualFluidsCore/CoProcessors/CalculateForcesCoProcessor.cpp index fe347d7864710b9c3bde20d83d63a5758c3d26e8..4e75e6337a44d46586a62a74d2e592b7d0839c57 100644 --- a/src/cpu/VirtualFluidsCore/CoProcessors/CalculateForcesCoProcessor.cpp +++ b/src/cpu/VirtualFluidsCore/CoProcessors/CalculateForcesCoProcessor.cpp @@ -4,7 +4,7 @@ #include "BCArray3D.h" #include "Block3D.h" #include "BoundaryConditions.h" -#include "Communicator.h" +#include <mpi/Communicator.h> #include "D3Q27Interactor.h" #include "DataSet3D.h" #include "DistributionArray3D.h" @@ -14,7 +14,7 @@ #include "UbScheduler.h" CalculateForcesCoProcessor::CalculateForcesCoProcessor(SPtr<Grid3D> grid, SPtr<UbScheduler> s, const std::string &path, - SPtr<Communicator> comm, double v, double a) + std::shared_ptr<vf::mpi::Communicator> comm, double v, double a) : CoProcessor(grid, s), path(path), comm(comm), v(v), a(a), forceX1global(0), forceX2global(0), forceX3global(0) { if (comm->getProcessID() == comm->getRoot()) { diff --git a/src/cpu/VirtualFluidsCore/CoProcessors/CalculateForcesCoProcessor.h b/src/cpu/VirtualFluidsCore/CoProcessors/CalculateForcesCoProcessor.h index c3004cf16b3c70cb5f24526badb69f62683b0b36..aa6bfd47799ed5d426550c756eccfff706709e9e 100644 --- a/src/cpu/VirtualFluidsCore/CoProcessors/CalculateForcesCoProcessor.h +++ b/src/cpu/VirtualFluidsCore/CoProcessors/CalculateForcesCoProcessor.h @@ -16,7 +16,7 @@ #include "UbTuple.h" class ForceCalculator; -class Communicator; +namespace vf::mpi {class Communicator;} class Grid3D; class UbScheduler; class D3Q27Interactor; @@ -29,7 +29,7 @@ public: //! Constructor //! \param v - velocity of fluid in LB units //! \param a - area of object in LB units - CalculateForcesCoProcessor(SPtr<Grid3D> grid, SPtr<UbScheduler> s, const std::string &path, SPtr<Communicator> comm, + CalculateForcesCoProcessor(SPtr<Grid3D> grid, SPtr<UbScheduler> s, const std::string &path, std::shared_ptr<vf::mpi::Communicator> comm, double v, double a); ~CalculateForcesCoProcessor() override; void process(double step) override; @@ -45,7 +45,7 @@ protected: private: std::string path; - SPtr<Communicator> comm; + std::shared_ptr<vf::mpi::Communicator> comm; std::vector<SPtr<D3Q27Interactor>> interactors; double forceX1global; double forceX2global; diff --git a/src/cpu/VirtualFluidsCore/CoProcessors/CalculateTorqueCoProcessor.cpp b/src/cpu/VirtualFluidsCore/CoProcessors/CalculateTorqueCoProcessor.cpp index 9fd6e8c28aeb1bdb8120c98f0a338aa21b38cc57..770e837a0f27b1cb42db385a44382c6bee402aaf 100644 --- a/src/cpu/VirtualFluidsCore/CoProcessors/CalculateTorqueCoProcessor.cpp +++ b/src/cpu/VirtualFluidsCore/CoProcessors/CalculateTorqueCoProcessor.cpp @@ -1,7 +1,7 @@ #include "CalculateTorqueCoProcessor.h" #include "BCProcessor.h" -#include "Communicator.h" +#include <mpi/Communicator.h> #include "D3Q27Interactor.h" #include "UbScheduler.h" #include "Grid3D.h" @@ -13,7 +13,7 @@ #include "EsoTwist3D.h" #include "DistributionArray3D.h" -CalculateTorqueCoProcessor::CalculateTorqueCoProcessor( SPtr<Grid3D> grid, SPtr<UbScheduler> s, const std::string &path_, SPtr<Communicator> comm) : CoProcessor(grid, s), path(path_), comm(comm), forceX1global(0), forceX2global(0), forceX3global(0) +CalculateTorqueCoProcessor::CalculateTorqueCoProcessor( SPtr<Grid3D> grid, SPtr<UbScheduler> s, const std::string &path_, std::shared_ptr<vf::mpi::Communicator> comm) : CoProcessor(grid, s), path(path_), comm(comm), forceX1global(0), forceX2global(0), forceX3global(0) { if (comm->getProcessID() == comm->getRoot()) { diff --git a/src/cpu/VirtualFluidsCore/CoProcessors/CalculateTorqueCoProcessor.h b/src/cpu/VirtualFluidsCore/CoProcessors/CalculateTorqueCoProcessor.h index 43e1e75acaf4ab115ac9c6dc40b449cf98f97e79..b1a7f771f5dffb5146f66d2bc16399b92aaceba6 100644 --- a/src/cpu/VirtualFluidsCore/CoProcessors/CalculateTorqueCoProcessor.h +++ b/src/cpu/VirtualFluidsCore/CoProcessors/CalculateTorqueCoProcessor.h @@ -17,7 +17,7 @@ #include "D3Q27System.h" class ForceCalculator; -class Communicator; +namespace vf::mpi {class Communicator;} class Grid3D; class UbScheduler; class D3Q27Interactor; @@ -28,7 +28,7 @@ class CalculateTorqueCoProcessor: public CoProcessor { public: //! Constructor - CalculateTorqueCoProcessor(SPtr<Grid3D> grid, SPtr<UbScheduler> s, const std::string &path, SPtr<Communicator> comm); + CalculateTorqueCoProcessor(SPtr<Grid3D> grid, SPtr<UbScheduler> s, const std::string &path, std::shared_ptr<vf::mpi::Communicator> comm); virtual ~CalculateTorqueCoProcessor(); void process(double step); void addInteractor(SPtr<D3Q27Interactor> interactor); @@ -38,7 +38,7 @@ protected: UbTupleDouble3 getForces(int x1, int x2, int x3, SPtr<DistributionArray3D> distributions, SPtr<BoundaryConditions> bc); private: std::string path; - SPtr<Communicator> comm; + std::shared_ptr<vf::mpi::Communicator> comm; std::vector<SPtr<D3Q27Interactor> > interactors; double forceX1global; double forceX2global; diff --git a/src/cpu/VirtualFluidsCore/CoProcessors/DecreaseViscosityCoProcessor.cpp b/src/cpu/VirtualFluidsCore/CoProcessors/DecreaseViscosityCoProcessor.cpp index f7061e9c8f9ebc3a43171d1b075d95ba76818f60..6dae1c7049ea3c0d779b31fff2e79104e034790f 100644 --- a/src/cpu/VirtualFluidsCore/CoProcessors/DecreaseViscosityCoProcessor.cpp +++ b/src/cpu/VirtualFluidsCore/CoProcessors/DecreaseViscosityCoProcessor.cpp @@ -10,13 +10,13 @@ #include <vector> #include "Block3D.h" -#include "Communicator.h" +#include <mpi/Communicator.h> #include "Grid3D.h" #include "LBMKernel.h" #include "UbScheduler.h" DecreaseViscosityCoProcessor::DecreaseViscosityCoProcessor(SPtr<Grid3D> grid, SPtr<UbScheduler> s, mu::Parser *nueFunc, - SPtr<Communicator> comm) + std::shared_ptr<vf::mpi::Communicator> comm) : CoProcessor(grid, s), nueFunc(nueFunc), comm(comm) { diff --git a/src/cpu/VirtualFluidsCore/CoProcessors/DecreaseViscosityCoProcessor.h b/src/cpu/VirtualFluidsCore/CoProcessors/DecreaseViscosityCoProcessor.h index 75a833be7d95c0f0fbd8a171d96de9e651598693..ca413ba2d5201d3043594f4a4b4803091bb51cc8 100644 --- a/src/cpu/VirtualFluidsCore/CoProcessors/DecreaseViscosityCoProcessor.h +++ b/src/cpu/VirtualFluidsCore/CoProcessors/DecreaseViscosityCoProcessor.h @@ -11,7 +11,7 @@ class UbScheduler; class Grid3D; -class Communicator; +namespace vf::mpi {class Communicator;} //! \brief The class sets viscosity/collision factor according to a previously defined function in time. //! \details initialization in test case (example): @@ -28,7 +28,7 @@ class Communicator; class DecreaseViscosityCoProcessor : public CoProcessor { public: - DecreaseViscosityCoProcessor(SPtr<Grid3D> grid, SPtr<UbScheduler> s, mu::Parser *nueFunc, SPtr<Communicator> comm); + DecreaseViscosityCoProcessor(SPtr<Grid3D> grid, SPtr<UbScheduler> s, mu::Parser *nueFunc, std::shared_ptr<vf::mpi::Communicator> comm); ~DecreaseViscosityCoProcessor() override; //! calls collect PostprocessData. void process(double step) override; @@ -36,7 +36,7 @@ public: protected: //! resets the collision factor depending on the current timestep. void setViscosity(double step); - SPtr<Communicator> comm; + std::shared_ptr<vf::mpi::Communicator> comm; private: mutable mu::value_type timeStep; diff --git a/src/cpu/VirtualFluidsCore/CoProcessors/EmergencyExitCoProcessor.cpp b/src/cpu/VirtualFluidsCore/CoProcessors/EmergencyExitCoProcessor.cpp index 11251a33660ff72887ce984baba43b820c9a22e5..3195ea4dfc6a9be9cf49ef7e04bfe57bce6e70f2 100644 --- a/src/cpu/VirtualFluidsCore/CoProcessors/EmergencyExitCoProcessor.cpp +++ b/src/cpu/VirtualFluidsCore/CoProcessors/EmergencyExitCoProcessor.cpp @@ -1,5 +1,5 @@ #include "EmergencyExitCoProcessor.h" -#include "Communicator.h" +#include <mpi/Communicator.h> #include "Grid3D.h" #include "MPIIORestartCoProcessor.h" #include "UbLogger.h" @@ -8,7 +8,7 @@ #include <basics/utilities/UbFileOutputASCII.h> EmergencyExitCoProcessor::EmergencyExitCoProcessor(SPtr<Grid3D> grid, SPtr<UbScheduler> s, const std::string &path, - SPtr<MPIIORestartCoProcessor> rp, SPtr<Communicator> comm) + SPtr<MPIIORestartCoProcessor> rp, std::shared_ptr<vf::mpi::Communicator> comm) : CoProcessor(grid, s), path(path), rp(rp), comm(comm) { this->path = path + "/exit"; diff --git a/src/cpu/VirtualFluidsCore/CoProcessors/EmergencyExitCoProcessor.h b/src/cpu/VirtualFluidsCore/CoProcessors/EmergencyExitCoProcessor.h index 382083c07a0b1dc900ef59ae2c2d5a5967d32f72..8894420c979eb6e7879c1788010d7e5d7e807eec 100644 --- a/src/cpu/VirtualFluidsCore/CoProcessors/EmergencyExitCoProcessor.h +++ b/src/cpu/VirtualFluidsCore/CoProcessors/EmergencyExitCoProcessor.h @@ -14,7 +14,7 @@ #include "CoProcessor.h" class MPIIORestartCoProcessor; -class Communicator; +namespace vf::mpi {class Communicator;} class Grid3D; class UbScheduler; @@ -22,7 +22,7 @@ class EmergencyExitCoProcessor : public CoProcessor { public: EmergencyExitCoProcessor(SPtr<Grid3D> grid, SPtr<UbScheduler> s, const std::string &path, - SPtr<MPIIORestartCoProcessor> rp, SPtr<Communicator> comm); + SPtr<MPIIORestartCoProcessor> rp, std::shared_ptr<vf::mpi::Communicator> comm); ~EmergencyExitCoProcessor() override; void process(double step) override; @@ -35,7 +35,7 @@ protected: private: std::string path; - SPtr<Communicator> comm; + std::shared_ptr<vf::mpi::Communicator> comm; SPtr<MPIIORestartCoProcessor> rp; std::string metafile; }; diff --git a/src/cpu/VirtualFluidsCore/CoProcessors/ForceCalculator.cpp b/src/cpu/VirtualFluidsCore/CoProcessors/ForceCalculator.cpp index 7e04fd4b66a9abb108d07d7d033768f25b769299..5a514606ad8486073e7c1e3679ee7a31916553df 100644 --- a/src/cpu/VirtualFluidsCore/CoProcessors/ForceCalculator.cpp +++ b/src/cpu/VirtualFluidsCore/CoProcessors/ForceCalculator.cpp @@ -4,13 +4,13 @@ #include "BCArray3D.h" #include "Block3D.h" #include "BoundaryConditions.h" -#include "Communicator.h" +#include <mpi/Communicator.h> #include "D3Q27Interactor.h" #include "DataSet3D.h" #include "DistributionArray3D.h" #include "LBMKernel.h" -ForceCalculator::ForceCalculator(SPtr<Communicator> comm) +ForceCalculator::ForceCalculator(std::shared_ptr<vf::mpi::Communicator> comm) : comm(comm), forceX1global(0), forceX2global(0), forceX3global(0) { } diff --git a/src/cpu/VirtualFluidsCore/CoProcessors/ForceCalculator.h b/src/cpu/VirtualFluidsCore/CoProcessors/ForceCalculator.h index 432cc452263deb9206a834251e49612276c2a060..7aeb514abe426020af59a936d5f8b8c184ea496f 100644 --- a/src/cpu/VirtualFluidsCore/CoProcessors/ForceCalculator.h +++ b/src/cpu/VirtualFluidsCore/CoProcessors/ForceCalculator.h @@ -14,14 +14,14 @@ #include "Vector3D.h" class D3Q27Interactor; -class Communicator; +namespace vf::mpi {class Communicator;} class DistributionArray3D; class BoundaryConditions; class ForceCalculator { public: - ForceCalculator(std::shared_ptr<Communicator> comm); + ForceCalculator(std::shared_ptr<vf::mpi::Communicator> comm); virtual ~ForceCalculator(); void calculateForces(std::vector<std::shared_ptr<D3Q27Interactor>> interactors); @@ -34,7 +34,7 @@ public: private: void gatherGlobalForces(); - std::shared_ptr<Communicator> comm; + std::shared_ptr<vf::mpi::Communicator> comm; double forceX1global; double forceX2global; diff --git a/src/cpu/VirtualFluidsCore/CoProcessors/InSituCatalystCoProcessor.cpp b/src/cpu/VirtualFluidsCore/CoProcessors/InSituCatalystCoProcessor.cpp index 6955c55dd315a350909695d5693f60a6368f6bb0..40a8011ca871965f4b389ce32559b847021d2fe2 100644 --- a/src/cpu/VirtualFluidsCore/CoProcessors/InSituCatalystCoProcessor.cpp +++ b/src/cpu/VirtualFluidsCore/CoProcessors/InSituCatalystCoProcessor.cpp @@ -20,7 +20,7 @@ InSituCatalystCoProcessor::InSituCatalystCoProcessor() {} InSituCatalystCoProcessor::InSituCatalystCoProcessor(SPtr<Grid3D> grid, SPtr<UbScheduler> s, std::string script) : CoProcessor(grid, s) { - gridRank = Communicator::getInstance()->getProcessID(); + gridRank = vf::mpi::Communicator::getInstance()->getProcessID(); minInitLevel = this->grid->getCoarsestInitializedLevel(); maxInitLevel = this->grid->getFinestInitializedLevel(); diff --git a/src/cpu/VirtualFluidsCore/CoProcessors/InSituVTKCoProcessor.cpp b/src/cpu/VirtualFluidsCore/CoProcessors/InSituVTKCoProcessor.cpp index 8d5cec10521830ba2aec9f2c06ef2a796da6b954..73c0a2325953994c337934347e872223ba18452a 100644 --- a/src/cpu/VirtualFluidsCore/CoProcessors/InSituVTKCoProcessor.cpp +++ b/src/cpu/VirtualFluidsCore/CoProcessors/InSituVTKCoProcessor.cpp @@ -30,7 +30,7 @@ InSituVTKCoProcessor::InSituVTKCoProcessor(SPtr<Grid3D> grid, SPtr<UbScheduler> SPtr<LBMUnitConverter> conv) : CoProcessor(grid, s), conv(conv) { - gridRank = Communicator::getInstance()->getProcessID(); + gridRank = vf::mpi::Communicator::getInstance()->getProcessID(); minInitLevel = this->grid->getCoarsestInitializedLevel(); maxInitLevel = this->grid->getFinestInitializedLevel(); @@ -269,7 +269,7 @@ void InSituVTKCoProcessor::readConfigFile(const std::string &configFile) string dummy; int wRank = 0; getline(ifs, dummy); - int np = Communicator::getInstance()->getNumberOfProcesses(); + int np = vf::mpi::Communicator::getInstance()->getNumberOfProcesses(); while (ifs.good()) { getline(ifs, dummy, ';'); diff --git a/src/cpu/VirtualFluidsCore/CoProcessors/IntegrateValuesHelper.cpp b/src/cpu/VirtualFluidsCore/CoProcessors/IntegrateValuesHelper.cpp index 81f7dfc418f3ea13a706fef2820b355131e56a71..4e711bd7c03b1da262c427230dc1c357966e1681 100644 --- a/src/cpu/VirtualFluidsCore/CoProcessors/IntegrateValuesHelper.cpp +++ b/src/cpu/VirtualFluidsCore/CoProcessors/IntegrateValuesHelper.cpp @@ -10,7 +10,7 @@ #include "LBMKernel.h" ////////////////////////////////////////////////////////////////////////// -IntegrateValuesHelper::IntegrateValuesHelper(SPtr<Grid3D> grid, SPtr<Communicator> comm, double minX1, double minX2, +IntegrateValuesHelper::IntegrateValuesHelper(SPtr<Grid3D> grid, std::shared_ptr<vf::mpi::Communicator> comm, double minX1, double minX2, double minX3, double maxX1, double maxX2, double maxX3) : @@ -21,7 +21,7 @@ IntegrateValuesHelper::IntegrateValuesHelper(SPtr<Grid3D> grid, SPtr<Communicato init(-1); } ////////////////////////////////////////////////////////////////////////// -IntegrateValuesHelper::IntegrateValuesHelper(SPtr<Grid3D> grid, SPtr<Communicator> comm, double minX1, double minX2, +IntegrateValuesHelper::IntegrateValuesHelper(SPtr<Grid3D> grid, std::shared_ptr<vf::mpi::Communicator> comm, double minX1, double minX2, double minX3, double maxX1, double maxX2, double maxX3, int level) : diff --git a/src/cpu/VirtualFluidsCore/CoProcessors/IntegrateValuesHelper.h b/src/cpu/VirtualFluidsCore/CoProcessors/IntegrateValuesHelper.h index f5d846f98317d56f6c0ccf3e267a382ead1cd2a6..d6c87dcfd604bc1f1ded813b04e6ee71829c0d27 100644 --- a/src/cpu/VirtualFluidsCore/CoProcessors/IntegrateValuesHelper.h +++ b/src/cpu/VirtualFluidsCore/CoProcessors/IntegrateValuesHelper.h @@ -5,7 +5,7 @@ #include "Block3D.h" #include "CbArray2D.h" -#include "Communicator.h" +#include <mpi/Communicator.h> #include "D3Q27System.h" #include "GbCuboid3D.h" #include "Grid3D.h" @@ -36,9 +36,9 @@ public: }; public: - IntegrateValuesHelper(SPtr<Grid3D> grid, SPtr<Communicator> comm, double minX1, double minX2, double minX3, + IntegrateValuesHelper(SPtr<Grid3D> grid, std::shared_ptr<vf::mpi::Communicator> comm, double minX1, double minX2, double minX3, double maxX1, double maxX2, double maxX3); - IntegrateValuesHelper(SPtr<Grid3D> grid, SPtr<Communicator> comm, double minX1, double minX2, double minX3, + IntegrateValuesHelper(SPtr<Grid3D> grid, std::shared_ptr<vf::mpi::Communicator> comm, double minX1, double minX2, double minX3, double maxX1, double maxX2, double maxX3, int level); virtual ~IntegrateValuesHelper(); @@ -77,7 +77,7 @@ private: double sAvVx1, sAvVx2, sAvVx3, sTSx1, sTSx2, sTSx3, sTSx1x3; std::vector<CalcNodes> cnodes; GbCuboid3DPtr boundingBox; - SPtr<Communicator> comm; + std::shared_ptr<vf::mpi::Communicator> comm; CbArray2D<Node> cnodes2DMatrix; enum Values { AvVx = 0, AvVy = 1, AvVz = 2, AvVxx = 3, AvVyy = 4, AvVzz = 5, AvVxy = 6, AvVyz = 7, AvVxz = 8 }; }; diff --git a/src/cpu/VirtualFluidsCore/CoProcessors/LineTimeSeriesCoProcessor.cpp b/src/cpu/VirtualFluidsCore/CoProcessors/LineTimeSeriesCoProcessor.cpp index fe04f4f9c98f8c41a33ee298df0689e2d254c2a7..9e5fa087fccf6d1121052ece7673a406984d52c0 100644 --- a/src/cpu/VirtualFluidsCore/CoProcessors/LineTimeSeriesCoProcessor.cpp +++ b/src/cpu/VirtualFluidsCore/CoProcessors/LineTimeSeriesCoProcessor.cpp @@ -3,7 +3,7 @@ #include "WbWriterVtkXmlASCII.h" #include "Block3D.h" -#include "Communicator.h" +#include <mpi/Communicator.h> #include "CompressibleCumulantLBMKernel.h" #include "CoordinateTransformation3D.h" #include "DataSet3D.h" @@ -13,7 +13,7 @@ #include "UbScheduler.h" LineTimeSeriesCoProcessor::LineTimeSeriesCoProcessor(SPtr<Grid3D> grid, SPtr<UbScheduler> s, const std::string &path, - SPtr<GbLine3D> line, int level, SPtr<Communicator> comm) + SPtr<GbLine3D> line, int level, std::shared_ptr<vf::mpi::Communicator> comm) : CoProcessor(grid, s), path(path), length(0), ix1(0), ix2(0), ix3(0), level(level), line(line) { root = comm->isRoot(); diff --git a/src/cpu/VirtualFluidsCore/CoProcessors/LineTimeSeriesCoProcessor.h b/src/cpu/VirtualFluidsCore/CoProcessors/LineTimeSeriesCoProcessor.h index 76f933c0599c38d8c84eb4e872a307c951113d4b..16061b0b259b9118a82f7f46abbb919250b5dfea 100644 --- a/src/cpu/VirtualFluidsCore/CoProcessors/LineTimeSeriesCoProcessor.h +++ b/src/cpu/VirtualFluidsCore/CoProcessors/LineTimeSeriesCoProcessor.h @@ -9,7 +9,7 @@ #include "CoProcessor.h" #include "LBMSystem.h" -class Communicator; +namespace vf::mpi {class Communicator;} class Grid3D; class UbScheduler; class GbLine3D; @@ -27,7 +27,7 @@ public: public: LineTimeSeriesCoProcessor(SPtr<Grid3D> grid, SPtr<UbScheduler> s, const std::string &path, SPtr<GbLine3D> line, - int level, SPtr<Communicator> comm); + int level, std::shared_ptr<vf::mpi::Communicator> comm); ~LineTimeSeriesCoProcessor() override = default; void process(double step) override; diff --git a/src/cpu/VirtualFluidsCore/CoProcessors/MPIIOCoProcessor.cpp b/src/cpu/VirtualFluidsCore/CoProcessors/MPIIOCoProcessor.cpp index 481311f909457f80655b5c888a8226635472a3ce..4f8f3a4b503f9490545ed760aaacf2778dece474 100644 --- a/src/cpu/VirtualFluidsCore/CoProcessors/MPIIOCoProcessor.cpp +++ b/src/cpu/VirtualFluidsCore/CoProcessors/MPIIOCoProcessor.cpp @@ -1,6 +1,6 @@ #include "MPIIOCoProcessor.h" #include "Block3D.h" -#include "Communicator.h" +#include <mpi/Communicator.h> #include "CoordinateTransformation3D.h" #include "Grid3D.h" #include "MPIIODataStructures.h" @@ -13,7 +13,7 @@ using namespace MPIIODataStructures; MPIIOCoProcessor::MPIIOCoProcessor(SPtr<Grid3D> grid, SPtr<UbScheduler> s, const std::string &path, - SPtr<Communicator> comm) + std::shared_ptr<vf::mpi::Communicator> comm) : CoProcessor(grid, s), path(path), comm(comm) { UbSystem::makeDirectory(path + "/mpi_io_cp"); diff --git a/src/cpu/VirtualFluidsCore/CoProcessors/MPIIOCoProcessor.h b/src/cpu/VirtualFluidsCore/CoProcessors/MPIIOCoProcessor.h index 8997a39d1fc16136d06e507f493e743662e189a5..edee5255ebdb14ed23cd3f53e4738a3fd8d58186 100644 --- a/src/cpu/VirtualFluidsCore/CoProcessors/MPIIOCoProcessor.h +++ b/src/cpu/VirtualFluidsCore/CoProcessors/MPIIOCoProcessor.h @@ -8,14 +8,14 @@ class Grid3D; class UbScheduler; -class Communicator; +namespace vf::mpi {class Communicator;} //! \class MPIWriteBlocksBECoProcessor //! \brief Writes the grid each timestep into the files and reads the grip from the files before regenerating class MPIIOCoProcessor : public CoProcessor { public: - MPIIOCoProcessor(SPtr<Grid3D> grid, SPtr<UbScheduler> s, const std::string &path, SPtr<Communicator> comm); + MPIIOCoProcessor(SPtr<Grid3D> grid, SPtr<UbScheduler> s, const std::string &path, std::shared_ptr<vf::mpi::Communicator> comm); ~MPIIOCoProcessor() override; //! Each timestep writes the grid into the files @@ -37,7 +37,7 @@ public: protected: std::string path; - SPtr<Communicator> comm; + std::shared_ptr<vf::mpi::Communicator> comm; MPI_Datatype gridParamType, block3dType, dataSetParamType, boundCondType, arrayPresenceType; }; #endif // ! _MPIIOCoProcessor_H_ diff --git a/src/cpu/VirtualFluidsCore/CoProcessors/MPIIOMigrationBECoProcessor.cpp b/src/cpu/VirtualFluidsCore/CoProcessors/MPIIOMigrationBECoProcessor.cpp index 0d713212c0f19e62bc521482ecc5a937a359e7a6..b58376cebd7854a1aba1a2b69881ac445ad51082 100644 --- a/src/cpu/VirtualFluidsCore/CoProcessors/MPIIOMigrationBECoProcessor.cpp +++ b/src/cpu/VirtualFluidsCore/CoProcessors/MPIIOMigrationBECoProcessor.cpp @@ -3,7 +3,7 @@ #include "BCProcessor.h" #include "Block3D.h" #include "BoundaryConditions.h" -#include "Communicator.h" +#include <mpi/Communicator.h> #include "CoordinateTransformation3D.h" #include "D3Q27EsoTwist3DSplittedVector.h" #include "D3Q27System.h" @@ -25,7 +25,7 @@ using namespace MPIIODataStructures; #define MESSAGE_TAG 80 #define SEND_BLOCK_SIZE 100000 -MPIIOMigrationBECoProcessor::MPIIOMigrationBECoProcessor(SPtr<Grid3D> grid, SPtr<UbScheduler> s, const std::string &path, SPtr<Communicator> comm) +MPIIOMigrationBECoProcessor::MPIIOMigrationBECoProcessor(SPtr<Grid3D> grid, SPtr<UbScheduler> s, const std::string &path, std::shared_ptr<vf::mpi::Communicator> comm) : MPIIOCoProcessor(grid, s, path, comm), nue(-999.999), nuL(-999.999), nuG(-999.999), densityRatio(-999.999) { memset(&boundCondParamStr, 0, sizeof(boundCondParamStr)); diff --git a/src/cpu/VirtualFluidsCore/CoProcessors/MPIIOMigrationBECoProcessor.h b/src/cpu/VirtualFluidsCore/CoProcessors/MPIIOMigrationBECoProcessor.h index 9a89ada1ae039d10cd53b06b189e5709398911c8..7c9471246af0207d3baef1bb7e8e1726627d77b6 100644 --- a/src/cpu/VirtualFluidsCore/CoProcessors/MPIIOMigrationBECoProcessor.h +++ b/src/cpu/VirtualFluidsCore/CoProcessors/MPIIOMigrationBECoProcessor.h @@ -10,7 +10,7 @@ class Grid3D; class UbScheduler; -class Communicator; +namespace vf::mpi {class Communicator;} class BCProcessor; class LBMKernel; @@ -31,7 +31,7 @@ class MPIIOMigrationBECoProcessor : public MPIIOCoProcessor public: MPIIOMigrationBECoProcessor(SPtr<Grid3D> grid, SPtr<UbScheduler> s, const std::string &path, - SPtr<Communicator> comm); + std::shared_ptr<vf::mpi::Communicator> comm); ~MPIIOMigrationBECoProcessor() override; //! Each timestep writes the grid into the files void process(double step) override; @@ -80,7 +80,7 @@ public: protected: // std::string path; - // SPtr<Communicator> comm; + // std::shared_ptr<vf::mpi::Communicator> comm; private: // MPI_Datatype gridParamType, block3dType; diff --git a/src/cpu/VirtualFluidsCore/CoProcessors/MPIIOMigrationCoProcessor.cpp b/src/cpu/VirtualFluidsCore/CoProcessors/MPIIOMigrationCoProcessor.cpp index 87ded25803be8c71d3b201aa7907aadc54cdfc1b..daf31d6fd663574381d5d5d63263283f9681de7a 100644 --- a/src/cpu/VirtualFluidsCore/CoProcessors/MPIIOMigrationCoProcessor.cpp +++ b/src/cpu/VirtualFluidsCore/CoProcessors/MPIIOMigrationCoProcessor.cpp @@ -3,7 +3,7 @@ #include "BCProcessor.h" #include "Block3D.h" #include "BoundaryConditions.h" -#include "Communicator.h" +#include <mpi/Communicator.h> #include "CoordinateTransformation3D.h" #include "D3Q27EsoTwist3DSplittedVector.h" #include "D3Q27System.h" @@ -22,7 +22,7 @@ using namespace MPIIODataStructures; -MPIIOMigrationCoProcessor::MPIIOMigrationCoProcessor(SPtr<Grid3D> grid, SPtr<UbScheduler> s, const std::string &path, SPtr<Communicator> comm) +MPIIOMigrationCoProcessor::MPIIOMigrationCoProcessor(SPtr<Grid3D> grid, SPtr<UbScheduler> s, const std::string &path, std::shared_ptr<vf::mpi::Communicator> comm) : MPIIOCoProcessor(grid, s, path, comm) { memset(&boundCondParamStr, 0, sizeof(boundCondParamStr)); diff --git a/src/cpu/VirtualFluidsCore/CoProcessors/MPIIOMigrationCoProcessor.h b/src/cpu/VirtualFluidsCore/CoProcessors/MPIIOMigrationCoProcessor.h index ca0de8f3e7ba315bc8a870f89063ea9f38d7b59f..1293d38d4a9f9a7ff7174db3473288cc1af70c4e 100644 --- a/src/cpu/VirtualFluidsCore/CoProcessors/MPIIOMigrationCoProcessor.h +++ b/src/cpu/VirtualFluidsCore/CoProcessors/MPIIOMigrationCoProcessor.h @@ -9,7 +9,7 @@ class Grid3D; class UbScheduler; -class Communicator; +namespace vf::mpi {class Communicator;} class BCProcessor; class LBMKernel; @@ -29,7 +29,7 @@ public: PhaseField2 = 8 }; - MPIIOMigrationCoProcessor(SPtr<Grid3D> grid, SPtr<UbScheduler> s, const std::string &path, SPtr<Communicator> comm); + MPIIOMigrationCoProcessor(SPtr<Grid3D> grid, SPtr<UbScheduler> s, const std::string &path, std::shared_ptr<vf::mpi::Communicator> comm); ~MPIIOMigrationCoProcessor() override; //! Each timestep writes the grid into the files void process(double step) override; @@ -73,7 +73,7 @@ public: protected: // std::string path; - // SPtr<Communicator> comm; + // std::shared_ptr<vf::mpi::Communicator> comm; private: // MPI_Datatype gridParamType, block3dType; diff --git a/src/cpu/VirtualFluidsCore/CoProcessors/MPIIORestartCoProcessor.cpp b/src/cpu/VirtualFluidsCore/CoProcessors/MPIIORestartCoProcessor.cpp index f69514478a2a53372c1807324581ad125bc55432..2a35d2d203a242a1ddc89ab431f6772e49ceb98b 100644 --- a/src/cpu/VirtualFluidsCore/CoProcessors/MPIIORestartCoProcessor.cpp +++ b/src/cpu/VirtualFluidsCore/CoProcessors/MPIIORestartCoProcessor.cpp @@ -3,7 +3,7 @@ #include "BCProcessor.h" #include "Block3D.h" #include "BoundaryConditions.h" -#include "Communicator.h" +#include <mpi/Communicator.h> #include "CoordinateTransformation3D.h" #include "D3Q27EsoTwist3DSplittedVector.h" #include "D3Q27System.h" @@ -25,7 +25,7 @@ using namespace MPIIODataStructures; -MPIIORestartCoProcessor::MPIIORestartCoProcessor(SPtr<Grid3D> grid, SPtr<UbScheduler> s, const std::string &path, SPtr<Communicator> comm) +MPIIORestartCoProcessor::MPIIORestartCoProcessor(SPtr<Grid3D> grid, SPtr<UbScheduler> s, const std::string &path, std::shared_ptr<vf::mpi::Communicator> comm) : MPIIOCoProcessor(grid, s, path, comm) { memset(&boundCondParamStr, 0, sizeof(boundCondParamStr)); diff --git a/src/cpu/VirtualFluidsCore/CoProcessors/MPIIORestartCoProcessor.h b/src/cpu/VirtualFluidsCore/CoProcessors/MPIIORestartCoProcessor.h index 57f559769a06d9a87a968ada73fbaba712da789b..b50eafb799f601a48aa0d80f5a4a0a17bab95d0f 100644 --- a/src/cpu/VirtualFluidsCore/CoProcessors/MPIIORestartCoProcessor.h +++ b/src/cpu/VirtualFluidsCore/CoProcessors/MPIIORestartCoProcessor.h @@ -11,7 +11,7 @@ class Grid3D; class UbScheduler; -class Communicator; +namespace vf::mpi {class Communicator;} class BCProcessor; class LBMKernel; @@ -20,7 +20,7 @@ class LBMKernel; class MPIIORestartCoProcessor : public MPIIOCoProcessor { public: - MPIIORestartCoProcessor(SPtr<Grid3D> grid, SPtr<UbScheduler> s, const std::string &path, SPtr<Communicator> comm); + MPIIORestartCoProcessor(SPtr<Grid3D> grid, SPtr<UbScheduler> s, const std::string &path, std::shared_ptr<vf::mpi::Communicator> comm); ~MPIIORestartCoProcessor() override; //! Each timestep writes the grid into the files void process(double step) override; @@ -62,7 +62,7 @@ public: protected: // std::string path; - // SPtr<Communicator> comm; + // std::shared_ptr<vf::mpi::Communicator> comm; private: // MPI_Datatype gridParamType, block3dType; diff --git a/src/cpu/VirtualFluidsCore/CoProcessors/MicrophoneArrayCoProcessor.cpp b/src/cpu/VirtualFluidsCore/CoProcessors/MicrophoneArrayCoProcessor.cpp index 698528f32fc24a1d1cacc1f7fd7f61c59bd18430..53e98e9e107e0cc91fccf6e59afae18ea9a0e931 100644 --- a/src/cpu/VirtualFluidsCore/CoProcessors/MicrophoneArrayCoProcessor.cpp +++ b/src/cpu/VirtualFluidsCore/CoProcessors/MicrophoneArrayCoProcessor.cpp @@ -2,7 +2,7 @@ #include "BCArray3D.h" #include "BCProcessor.h" #include "Block3D.h" -#include "Communicator.h" +#include <mpi/Communicator.h> #include "D3Q27System.h" #include "DataSet3D.h" #include "DistributionArray3D.h" @@ -13,7 +13,7 @@ #include <sstream> MicrophoneArrayCoProcessor::MicrophoneArrayCoProcessor(SPtr<Grid3D> grid, SPtr<UbScheduler> s, const std::string &path, - SPtr<Communicator> comm) + std::shared_ptr<vf::mpi::Communicator> comm) : CoProcessor(grid, s), path(path), comm(comm) { count = 0; diff --git a/src/cpu/VirtualFluidsCore/CoProcessors/MicrophoneArrayCoProcessor.h b/src/cpu/VirtualFluidsCore/CoProcessors/MicrophoneArrayCoProcessor.h index d6185df6be205442e2cf1dc7a58710232ae80edf..a10f30440c8539677511af6f7ac40fbe257d4eaf 100644 --- a/src/cpu/VirtualFluidsCore/CoProcessors/MicrophoneArrayCoProcessor.h +++ b/src/cpu/VirtualFluidsCore/CoProcessors/MicrophoneArrayCoProcessor.h @@ -8,7 +8,7 @@ #include <string> #include <vector> -class Communicator; +namespace vf::mpi {class Communicator;} class Grid3D; class UbScheduler; class Vector3D; @@ -23,7 +23,7 @@ class MicrophoneArrayCoProcessor : public CoProcessor { public: MicrophoneArrayCoProcessor(SPtr<Grid3D> grid, SPtr<UbScheduler> s, const std::string &path, - SPtr<Communicator> comm); + std::shared_ptr<vf::mpi::Communicator> comm); ~MicrophoneArrayCoProcessor() override; //! calls collectData. @@ -38,7 +38,7 @@ protected: private: std::string path; - SPtr<Communicator> comm; + std::shared_ptr<vf::mpi::Communicator> comm; struct Mic { unsigned int id; diff --git a/src/cpu/VirtualFluidsCore/CoProcessors/NUPSCounterCoProcessor.cpp b/src/cpu/VirtualFluidsCore/CoProcessors/NUPSCounterCoProcessor.cpp index 46cbba0df4b96fddec45c7c696de51d74e9bc6eb..633ffd26f3ed77c58ac83200fdf18cb6f0385979 100644 --- a/src/cpu/VirtualFluidsCore/CoProcessors/NUPSCounterCoProcessor.cpp +++ b/src/cpu/VirtualFluidsCore/CoProcessors/NUPSCounterCoProcessor.cpp @@ -33,12 +33,12 @@ #include "NUPSCounterCoProcessor.h" -#include "Communicator.h" +#include <mpi/Communicator.h> #include "Grid3D.h" #include "UbScheduler.h" NUPSCounterCoProcessor::NUPSCounterCoProcessor(SPtr<Grid3D> grid, SPtr<UbScheduler> s, int numOfThreads, - SPtr<Communicator> comm) + std::shared_ptr<vf::mpi::Communicator> comm) : CoProcessor(grid, s), numOfThreads(numOfThreads), nup(0), nup_t(0), nupsStep(0.0), comm(comm) { if (comm->getProcessID() == comm->getRoot()) { diff --git a/src/cpu/VirtualFluidsCore/CoProcessors/NUPSCounterCoProcessor.h b/src/cpu/VirtualFluidsCore/CoProcessors/NUPSCounterCoProcessor.h index 61d2ba0b69a96959b07d5e1901da62ab7abdaa1a..ce6b16996824be9e614e131c6e05fad0d1a507fd 100644 --- a/src/cpu/VirtualFluidsCore/CoProcessors/NUPSCounterCoProcessor.h +++ b/src/cpu/VirtualFluidsCore/CoProcessors/NUPSCounterCoProcessor.h @@ -39,7 +39,7 @@ #include "CoProcessor.h" #include "basics/utilities/UbTiming.h" -class Communicator; +namespace vf::mpi {class Communicator;} class Grid3D; class UbScheduler; @@ -54,7 +54,7 @@ public: //! \param s is UbScheduler object for scheduling of observer //! \param numOfThreads is number of threads //! \param comm is Communicator object - NUPSCounterCoProcessor(SPtr<Grid3D> grid, SPtr<UbScheduler> s, int numOfThreads, SPtr<Communicator> comm); + NUPSCounterCoProcessor(SPtr<Grid3D> grid, SPtr<UbScheduler> s, int numOfThreads, std::shared_ptr<vf::mpi::Communicator> comm); ~NUPSCounterCoProcessor() override; void process(double step) override; @@ -70,7 +70,7 @@ protected: double nup; double nup_t; double nupsStep; - SPtr<Communicator> comm; + std::shared_ptr<vf::mpi::Communicator> comm; }; #endif diff --git a/src/cpu/VirtualFluidsCore/CoProcessors/PressureCoefficientCoProcessor.cpp b/src/cpu/VirtualFluidsCore/CoProcessors/PressureCoefficientCoProcessor.cpp index 1c7e47f52e721069b20a6b3c27d1e71857ef74ab..ae385117c311eabfe2c5b98c8c2c45f4cd7473cd 100644 --- a/src/cpu/VirtualFluidsCore/CoProcessors/PressureCoefficientCoProcessor.cpp +++ b/src/cpu/VirtualFluidsCore/CoProcessors/PressureCoefficientCoProcessor.cpp @@ -4,7 +4,7 @@ #include "BCArray3D.h" #include "BCProcessor.h" #include "Block3D.h" -#include "Communicator.h" +#include <mpi/Communicator.h> #include "D3Q27Interactor.h" #include "DataSet3D.h" #include "GbCuboid3D.h" @@ -14,7 +14,7 @@ PressureCoefficientCoProcessor::PressureCoefficientCoProcessor(SPtr<Grid3D> grid, SPtr<UbScheduler> s, GbCuboid3DPtr plane, const std::string &path, - SPtr<Communicator> comm) + std::shared_ptr<vf::mpi::Communicator> comm) : CoProcessor(grid, s), plane(plane), path(path), comm(comm) { maxStep = scheduler->getMaxEnd(); diff --git a/src/cpu/VirtualFluidsCore/CoProcessors/PressureCoefficientCoProcessor.h b/src/cpu/VirtualFluidsCore/CoProcessors/PressureCoefficientCoProcessor.h index f8f1d80d9c3185a13ab7ceebd579929f441c25e0..42927a7315d620e60c3af5c4285a89c18609cee7 100644 --- a/src/cpu/VirtualFluidsCore/CoProcessors/PressureCoefficientCoProcessor.h +++ b/src/cpu/VirtualFluidsCore/CoProcessors/PressureCoefficientCoProcessor.h @@ -11,7 +11,7 @@ class GbCuboid3D; class D3Q27Interactor; -class Communicator; +namespace vf::mpi {class Communicator;} class Grid3D; class UbScheduler; @@ -19,7 +19,7 @@ class PressureCoefficientCoProcessor : public CoProcessor { public: PressureCoefficientCoProcessor(SPtr<Grid3D> grid, SPtr<UbScheduler> s, SPtr<GbCuboid3D> plane, - const std::string &path, SPtr<Communicator> comm); + const std::string &path, std::shared_ptr<vf::mpi::Communicator> comm); ~PressureCoefficientCoProcessor() override; void process(double step) override; @@ -35,7 +35,7 @@ protected: private: SPtr<GbCuboid3D> plane; std::string path; - SPtr<Communicator> comm; + std::shared_ptr<vf::mpi::Communicator> comm; std::vector<SPtr<D3Q27Interactor>> interactors; int numberOfSteps; double maxStep; diff --git a/src/cpu/VirtualFluidsCore/CoProcessors/PressureDifferenceCoProcessor.cpp b/src/cpu/VirtualFluidsCore/CoProcessors/PressureDifferenceCoProcessor.cpp index e9b94dc6a225cd1b3b8a70126a242dd42e8e5b0c..74cd5a09c71b717f138090892b51b12a721f60ab 100644 --- a/src/cpu/VirtualFluidsCore/CoProcessors/PressureDifferenceCoProcessor.cpp +++ b/src/cpu/VirtualFluidsCore/CoProcessors/PressureDifferenceCoProcessor.cpp @@ -9,7 +9,7 @@ #include <fstream> -#include "Communicator.h" +#include <mpi/Communicator.h> #include "Grid3D.h" #include "IntegrateValuesHelper.h" #include "LBMUnitConverter.h" @@ -18,7 +18,7 @@ PressureDifferenceCoProcessor::PressureDifferenceCoProcessor(SPtr<Grid3D> grid, SPtr<UbScheduler> s, const std::string &path, SPtr<IntegrateValuesHelper> h1, SPtr<IntegrateValuesHelper> h2, LBMReal rhoReal, - LBMReal uReal, LBMReal uLB, SPtr<Communicator> comm) + LBMReal uReal, LBMReal uLB, std::shared_ptr<vf::mpi::Communicator> comm) : CoProcessor(grid, s), path(path), h1(h1), h2(h2), comm(comm) { diff --git a/src/cpu/VirtualFluidsCore/CoProcessors/PressureDifferenceCoProcessor.h b/src/cpu/VirtualFluidsCore/CoProcessors/PressureDifferenceCoProcessor.h index e805c250ba4132d2f90560bfb48e6f361b2e467a..6de68a977904d5cc25ee37395eff4c9e66748eb4 100644 --- a/src/cpu/VirtualFluidsCore/CoProcessors/PressureDifferenceCoProcessor.h +++ b/src/cpu/VirtualFluidsCore/CoProcessors/PressureDifferenceCoProcessor.h @@ -14,7 +14,7 @@ #include "CoProcessor.h" #include "LBMSystem.h" -class Communicator; +namespace vf::mpi {class Communicator;} class Grid3D; class UbScheduler; class LBMUnitConverter; @@ -26,7 +26,7 @@ public: PressureDifferenceCoProcessor(SPtr<Grid3D> grid, SPtr<UbScheduler> s, const std::string &path, SPtr<IntegrateValuesHelper> h1, SPtr<IntegrateValuesHelper> h2, LBMReal rhoReal, LBMReal uReal, LBMReal uLB, - /*const SPtr<LBMUnitConverter> conv,*/ SPtr<Communicator> comm); + /*const SPtr<LBMUnitConverter> conv,*/ std::shared_ptr<vf::mpi::Communicator> comm); ~PressureDifferenceCoProcessor() override; void process(double step) override; @@ -36,7 +36,7 @@ protected: std::string path; SPtr<LBMUnitConverter> conv; void collectData(double step); - SPtr<Communicator> comm; + std::shared_ptr<vf::mpi::Communicator> comm; LBMReal factor1; //= (1/3)*rhoReal*(uReal/uLB)^2 for calculation pReal = rhoLB * (1/3)*rhoReal*(uReal/uLB)^2, //rhoReal and uReal in SI LBMReal factor2; //= rhoReal*(uReal/uLB)^2 for calculation pReal = press * rhoReal*(uReal/uLB)^2, rhoReal and diff --git a/src/cpu/VirtualFluidsCore/CoProcessors/QCriterionCoProcessor.cpp b/src/cpu/VirtualFluidsCore/CoProcessors/QCriterionCoProcessor.cpp index 28652870f2f1c81dd0d9d6f4fbb014a9626af4e1..1fbdb6f7f40a9b126cfa174d8cef7d7516ff884a 100644 --- a/src/cpu/VirtualFluidsCore/CoProcessors/QCriterionCoProcessor.cpp +++ b/src/cpu/VirtualFluidsCore/CoProcessors/QCriterionCoProcessor.cpp @@ -7,11 +7,11 @@ #include "basics/writer/WbWriterVtkXmlASCII.h" #include "BCArray3D.h" -#include "Communicator.h" +#include <mpi/Communicator.h> #include "UbScheduler.h" QCriterionCoProcessor::QCriterionCoProcessor(SPtr<Grid3D> grid, const std::string &path, WbWriter *const writer, - SPtr<UbScheduler> s, SPtr<Communicator> comm) + SPtr<UbScheduler> s, std::shared_ptr<vf::mpi::Communicator> comm) : CoProcessor(grid, s), path(path), comm(comm), writer(writer) { init(); diff --git a/src/cpu/VirtualFluidsCore/CoProcessors/QCriterionCoProcessor.h b/src/cpu/VirtualFluidsCore/CoProcessors/QCriterionCoProcessor.h index 0227687526a0e0f46339d3342162a26393063872..55f0df5a2e8aaaf933babb70d6b9c5246424c34c 100644 --- a/src/cpu/VirtualFluidsCore/CoProcessors/QCriterionCoProcessor.h +++ b/src/cpu/VirtualFluidsCore/CoProcessors/QCriterionCoProcessor.h @@ -13,7 +13,7 @@ #include "LBMSystem.h" #include "UbTuple.h" -class Communicator; +namespace vf::mpi {class Communicator;} class Grid3D; class UbScheduler; class WbWriter; @@ -29,7 +29,7 @@ class QCriterionCoProcessor : public CoProcessor { public: QCriterionCoProcessor(SPtr<Grid3D> grid, const std::string &path, WbWriter *const writer, SPtr<UbScheduler> s, - SPtr<Communicator> comm); + std::shared_ptr<vf::mpi::Communicator> comm); //! Make update if timestep is write-timestep specified in SPtr<UbScheduler> s void process(double step) override; @@ -58,7 +58,7 @@ private: int gridRank; // comm-Rank des aktuellen prozesses std::string path; WbWriter *writer; - SPtr<Communicator> comm; + std::shared_ptr<vf::mpi::Communicator> comm; enum Values { xdir = 0, ydir = 1, zdir = 2 }; // labels for the different components }; diff --git a/src/cpu/VirtualFluidsCore/CoProcessors/ShearStressCoProcessor.cpp b/src/cpu/VirtualFluidsCore/CoProcessors/ShearStressCoProcessor.cpp index 3b546a702726fca63d23f72dc0b04545ad544525..3765d2a999f73c476a4f1b250daeaefde971c277 100644 --- a/src/cpu/VirtualFluidsCore/CoProcessors/ShearStressCoProcessor.cpp +++ b/src/cpu/VirtualFluidsCore/CoProcessors/ShearStressCoProcessor.cpp @@ -4,7 +4,7 @@ #include "BCArray3D.h" #include "Block3D.h" -#include "Communicator.h" +#include <mpi/Communicator.h> #include "D3Q27Interactor.h" #include "DataSet3D.h" #include "Grid3D.h" @@ -16,7 +16,7 @@ ShearStressCoProcessor::ShearStressCoProcessor(SPtr<Grid3D> grid, const std::str SPtr<UbScheduler> s, SPtr<UbScheduler> rs) : CoProcessor(grid, s), Resetscheduler(rs), path(path), writer(writer) { - SPtr<Communicator> comm = Communicator::getInstance(); + std::shared_ptr<vf::mpi::Communicator> comm = vf::mpi::Communicator::getInstance(); normals.push_back(0); normals.push_back(0); normals.push_back(1); @@ -62,7 +62,7 @@ void ShearStressCoProcessor::collectData(double step) // vector<string> cellDataNames; - // SPtr<Communicator> comm = Communicator::getInstance(); + // std::shared_ptr<vf::mpi::Communicator> comm = vf::mpi::Communicator::getInstance(); // vector<string> pieces = comm->gatherStrings(piece); // if (comm->getProcessID() == comm->getRoot()) //{ @@ -94,7 +94,7 @@ void ShearStressCoProcessor::collectData(double step) piece = subfolder + "/" + piece; vector<string> cellDataNames; - SPtr<Communicator> comm = Communicator::getInstance(); + std::shared_ptr<vf::mpi::Communicator> comm = vf::mpi::Communicator::getInstance(); vector<string> pieces = comm->gather(piece); if (comm->getProcessID() == comm->getRoot()) { string pname = diff --git a/src/cpu/VirtualFluidsCore/CoProcessors/TimeAveragedValuesCoProcessor.cpp b/src/cpu/VirtualFluidsCore/CoProcessors/TimeAveragedValuesCoProcessor.cpp index 24230ca99c605e8bbd2594236253c8ef63de1afc..7391754ee92fe216b78245c38032dbfc0594ad62 100644 --- a/src/cpu/VirtualFluidsCore/CoProcessors/TimeAveragedValuesCoProcessor.cpp +++ b/src/cpu/VirtualFluidsCore/CoProcessors/TimeAveragedValuesCoProcessor.cpp @@ -4,7 +4,7 @@ #include "LBMKernel.h" #include "Block3D.h" -#include "Communicator.h" +#include <mpi/Communicator.h> #include "DataSet3D.h" #include "Grid3D.h" #include "UbScheduler.h" @@ -16,7 +16,7 @@ TimeAveragedValuesCoProcessor::TimeAveragedValuesCoProcessor() = default; ////////////////////////////////////////////////////////////////////////// TimeAveragedValuesCoProcessor::TimeAveragedValuesCoProcessor(SPtr<Grid3D> grid, const std::string &path, WbWriter *const writer, SPtr<UbScheduler> s, - SPtr<Communicator> comm, int options) + std::shared_ptr<vf::mpi::Communicator> comm, int options) : CoProcessor(grid, s), path(path), writer(writer), comm(comm), options(options) { init(); @@ -26,7 +26,7 @@ TimeAveragedValuesCoProcessor::TimeAveragedValuesCoProcessor(SPtr<Grid3D> grid, ////////////////////////////////////////////////////////////////////////// TimeAveragedValuesCoProcessor::TimeAveragedValuesCoProcessor(SPtr<Grid3D> grid, const std::string &path, WbWriter *const writer, SPtr<UbScheduler> s, - SPtr<Communicator> comm, int options, + std::shared_ptr<vf::mpi::Communicator> comm, int options, std::vector<int> levels, std::vector<double> &levelCoords, std::vector<double> &bounds, bool timeAveraging) : CoProcessor(grid, s), path(path), writer(writer), comm(comm), options(options), levels(levels), diff --git a/src/cpu/VirtualFluidsCore/CoProcessors/TimeAveragedValuesCoProcessor.h b/src/cpu/VirtualFluidsCore/CoProcessors/TimeAveragedValuesCoProcessor.h index 70dd79f062331be762603d07576675a123f7770b..155f293a08d0ef0726193a48c9a8fb8051bd3972 100644 --- a/src/cpu/VirtualFluidsCore/CoProcessors/TimeAveragedValuesCoProcessor.h +++ b/src/cpu/VirtualFluidsCore/CoProcessors/TimeAveragedValuesCoProcessor.h @@ -9,7 +9,7 @@ #include "IntegrateValuesHelper.h" #include "LBMSystem.h" -class Communicator; +namespace vf::mpi {class Communicator;} class Grid3D; class UbScheduler; class WbWriter; @@ -41,9 +41,9 @@ public: public: TimeAveragedValuesCoProcessor(); TimeAveragedValuesCoProcessor(SPtr<Grid3D> grid, const std::string &path, WbWriter *const writer, - SPtr<UbScheduler> s, SPtr<Communicator> comm, int options); + SPtr<UbScheduler> s, std::shared_ptr<vf::mpi::Communicator> comm, int options); TimeAveragedValuesCoProcessor(SPtr<Grid3D> grid, const std::string &path, WbWriter *const writer, - SPtr<UbScheduler> s, SPtr<Communicator> comm, int options, std::vector<int> levels, + SPtr<UbScheduler> s, std::shared_ptr<vf::mpi::Communicator> comm, int options, std::vector<int> levels, std::vector<double> &levelCoords, std::vector<double> &bounds, bool timeAveraging = true); //! Make update @@ -70,7 +70,7 @@ protected: void calculateAverageValuesForPlane(std::vector<IntegrateValuesHelper::CalcNodes> &cnodes); private: - SPtr<Communicator> comm; + std::shared_ptr<vf::mpi::Communicator> comm; std::vector<UbTupleFloat3> nodes; std::vector<UbTupleUInt8> cells; std::vector<std::string> datanames; diff --git a/src/cpu/VirtualFluidsCore/CoProcessors/TimeseriesCoProcessor.cpp b/src/cpu/VirtualFluidsCore/CoProcessors/TimeseriesCoProcessor.cpp index 8103d646643bf350f65c299ee73625978c3c6f6a..d2be7f0e25ae773be89dcad02dc6b96c0651d23a 100644 --- a/src/cpu/VirtualFluidsCore/CoProcessors/TimeseriesCoProcessor.cpp +++ b/src/cpu/VirtualFluidsCore/CoProcessors/TimeseriesCoProcessor.cpp @@ -9,14 +9,14 @@ #include <fstream> -#include "Communicator.h" +#include <mpi/Communicator.h> #include "Grid3D.h" #include "IntegrateValuesHelper.h" #include "LBMUnitConverter.h" #include "UbScheduler.h" TimeseriesCoProcessor::TimeseriesCoProcessor(SPtr<Grid3D> grid, SPtr<UbScheduler> s, SPtr<IntegrateValuesHelper> h1, - const std::string &path, SPtr<Communicator> comm) + const std::string &path, std::shared_ptr<vf::mpi::Communicator> comm) : CoProcessor(grid, s), h1(h1), path(path), comm(comm) { if (comm->getProcessID() == comm->getRoot()) { diff --git a/src/cpu/VirtualFluidsCore/CoProcessors/TimeseriesCoProcessor.h b/src/cpu/VirtualFluidsCore/CoProcessors/TimeseriesCoProcessor.h index b59a68b66d4d42080824d44c339c03fffe27f269..e92e324aab1b7cbbe16d7e6652ecb3ed0dfa9ed4 100644 --- a/src/cpu/VirtualFluidsCore/CoProcessors/TimeseriesCoProcessor.h +++ b/src/cpu/VirtualFluidsCore/CoProcessors/TimeseriesCoProcessor.h @@ -13,7 +13,7 @@ #include "CoProcessor.h" -class Communicator; +namespace vf::mpi {class Communicator;} class Grid3D; class UbScheduler; class IntegrateValuesHelper; @@ -27,7 +27,7 @@ class TimeseriesCoProcessor : public CoProcessor { public: TimeseriesCoProcessor(SPtr<Grid3D> grid, SPtr<UbScheduler> s, SPtr<IntegrateValuesHelper> h1, - const std::string &path, SPtr<Communicator> comm); + const std::string &path, std::shared_ptr<vf::mpi::Communicator> comm); ~TimeseriesCoProcessor() override; //! calls collectData. @@ -38,7 +38,7 @@ protected: //! object that can compute spacial average values in 3D-subdomain. SPtr<IntegrateValuesHelper> h1; - SPtr<Communicator> comm; + std::shared_ptr<vf::mpi::Communicator> comm; private: std::string path; //! output filename, e.g. pathname + "/steps/timeseries" diff --git a/src/cpu/VirtualFluidsCore/CoProcessors/TurbulenceIntensityCoProcessor.cpp b/src/cpu/VirtualFluidsCore/CoProcessors/TurbulenceIntensityCoProcessor.cpp index b292d40bfff650a61bebc6c906ad867e7e660d83..51be3b53a9a3bc123b15e03d0925bd619fb01fa3 100644 --- a/src/cpu/VirtualFluidsCore/CoProcessors/TurbulenceIntensityCoProcessor.cpp +++ b/src/cpu/VirtualFluidsCore/CoProcessors/TurbulenceIntensityCoProcessor.cpp @@ -3,7 +3,7 @@ #include "BCArray3D.h" #include "BCProcessor.h" #include "Block3D.h" -#include "Communicator.h" +#include <mpi/Communicator.h> #include "DataSet3D.h" #include "Grid3D.h" #include "LBMKernel.h" @@ -14,7 +14,7 @@ TurbulenceIntensityCoProcessor::TurbulenceIntensityCoProcessor(SPtr<Grid3D> grid, const std::string &path, WbWriter *const writer, SPtr<UbScheduler> s, - SPtr<Communicator> comm) + std::shared_ptr<vf::mpi::Communicator> comm) : CoProcessor(grid, s), path(path), comm(comm), writer(writer) { init(); diff --git a/src/cpu/VirtualFluidsCore/CoProcessors/TurbulenceIntensityCoProcessor.h b/src/cpu/VirtualFluidsCore/CoProcessors/TurbulenceIntensityCoProcessor.h index 5c389eed8ca84c2a8ec6700af6c33bd8a492eb1c..40983604d25385420cba8da4af28faa33283aaf0 100644 --- a/src/cpu/VirtualFluidsCore/CoProcessors/TurbulenceIntensityCoProcessor.h +++ b/src/cpu/VirtualFluidsCore/CoProcessors/TurbulenceIntensityCoProcessor.h @@ -8,7 +8,7 @@ #include "CoProcessor.h" #include "UbTuple.h" -class Communicator; +namespace vf::mpi {class Communicator;} class Grid3D; class UbScheduler; class WbWriter; @@ -18,7 +18,7 @@ class TurbulenceIntensityCoProcessor : public CoProcessor { public: TurbulenceIntensityCoProcessor(SPtr<Grid3D> grid, const std::string &path, WbWriter *const writer, - SPtr<UbScheduler> s, SPtr<Communicator> comm); + SPtr<UbScheduler> s, std::shared_ptr<vf::mpi::Communicator> comm); void process(double step) override; protected: @@ -39,7 +39,7 @@ private: int gridRank; std::string path; WbWriter *writer; - SPtr<Communicator> comm; + std::shared_ptr<vf::mpi::Communicator> comm; enum Values { AvVx = 0, AvVy = 1, AvVz = 2, AvVxxyyzz = 3 }; }; #endif diff --git a/src/cpu/VirtualFluidsCore/CoProcessors/WriteBlocksCoProcessor.cpp b/src/cpu/VirtualFluidsCore/CoProcessors/WriteBlocksCoProcessor.cpp index bac7c9c346c24198b56ce8a77cf884c0a660bb1f..536d2ee133517279aa2458d06aea8edcee1dd20f 100644 --- a/src/cpu/VirtualFluidsCore/CoProcessors/WriteBlocksCoProcessor.cpp +++ b/src/cpu/VirtualFluidsCore/CoProcessors/WriteBlocksCoProcessor.cpp @@ -33,15 +33,16 @@ #include "WriteBlocksCoProcessor.h" #include "basics/writer/WbWriterVtkXmlASCII.h" +#include <logger/Logger.h> #include "Block3D.h" -#include "Communicator.h" +#include <mpi/Communicator.h> #include "D3Q27System.h" #include "Grid3D.h" #include "UbScheduler.h" WriteBlocksCoProcessor::WriteBlocksCoProcessor(SPtr<Grid3D> grid, SPtr<UbScheduler> s, const std::string &path, - WbWriter *const writer, SPtr<Communicator> comm) + WbWriter *const writer, std::shared_ptr<vf::mpi::Communicator> comm) : CoProcessor(grid, s), path(path), writer(writer), comm(comm) { } @@ -180,6 +181,6 @@ void WriteBlocksCoProcessor::collectData(double step) istep, false); } - UBLOG(logINFO, "WriteBlocksCoProcessor step: " << istep); + VF_LOG_INFO("WriteBlocksCoProcessor step: {}", istep); } } diff --git a/src/cpu/VirtualFluidsCore/CoProcessors/WriteBlocksCoProcessor.h b/src/cpu/VirtualFluidsCore/CoProcessors/WriteBlocksCoProcessor.h index b26cdeebb29fcb1a9ba5b96f010c3c4af83e4c99..837d9bbad7533d0f097c07851b352c50cccf5465 100644 --- a/src/cpu/VirtualFluidsCore/CoProcessors/WriteBlocksCoProcessor.h +++ b/src/cpu/VirtualFluidsCore/CoProcessors/WriteBlocksCoProcessor.h @@ -39,7 +39,7 @@ #include "CoProcessor.h" -class Communicator; +namespace vf::mpi {class Communicator;} class Grid3D; class UbScheduler; class WbWriter; @@ -57,7 +57,7 @@ public: //! \param writer is WbWriter object //! \param comm is Communicator object WriteBlocksCoProcessor(SPtr<Grid3D> grid, SPtr<UbScheduler> s, const std::string &path, WbWriter *const writer, - SPtr<Communicator> comm); + std::shared_ptr<vf::mpi::Communicator> comm); ~WriteBlocksCoProcessor() override; void process(double step) override; @@ -69,7 +69,7 @@ protected: std::string path; WbWriter *writer; - SPtr<Communicator> comm; + std::shared_ptr<vf::mpi::Communicator> comm; }; #endif diff --git a/src/cpu/VirtualFluidsCore/CoProcessors/WriteBoundaryConditionsCoProcessor.cpp b/src/cpu/VirtualFluidsCore/CoProcessors/WriteBoundaryConditionsCoProcessor.cpp index 117088f67aa0e832608d96480e15bde2fb5dec3b..6c927f4945f9bcf211c7f84e38fbc6d395960b7f 100644 --- a/src/cpu/VirtualFluidsCore/CoProcessors/WriteBoundaryConditionsCoProcessor.cpp +++ b/src/cpu/VirtualFluidsCore/CoProcessors/WriteBoundaryConditionsCoProcessor.cpp @@ -37,10 +37,12 @@ #include <string> #include <vector> +#include <logger/Logger.h> + #include "BCArray3D.h" #include "Block3D.h" #include "CbArray3D.h" -#include "Communicator.h" +#include <mpi/Communicator.h> #include "Grid3D.h" #include "LBMUnitConverter.h" #include "UbScheduler.h" @@ -53,7 +55,7 @@ WriteBoundaryConditionsCoProcessor::WriteBoundaryConditionsCoProcessor() = defau ////////////////////////////////////////////////////////////////////////// WriteBoundaryConditionsCoProcessor::WriteBoundaryConditionsCoProcessor(SPtr<Grid3D> grid, SPtr<UbScheduler> s, const std::string &path, WbWriter *const writer, - SPtr<Communicator> comm) + std::shared_ptr<vf::mpi::Communicator> comm) : CoProcessor(grid, s), path(path), writer(writer), comm(comm) { gridRank = comm->getProcessID(); @@ -114,7 +116,7 @@ void WriteBoundaryConditionsCoProcessor::collectData(double step) } else { WbWriterVtkXmlASCII::getInstance()->addFilesToCollection(cfilePath, filenames, istep, false); } - UBLOG(logINFO, "WriteBoundaryConditionsCoProcessor step: " << istep); + VF_LOG_INFO("WriteBoundaryConditionsCoProcessor step: {}", istep); } clearData(); diff --git a/src/cpu/VirtualFluidsCore/CoProcessors/WriteBoundaryConditionsCoProcessor.h b/src/cpu/VirtualFluidsCore/CoProcessors/WriteBoundaryConditionsCoProcessor.h index ad29abca5e90c1267d7ab1768c1b3600fbd535c7..2608a3ae8df931a5f0b347b77ad525712676aeab 100644 --- a/src/cpu/VirtualFluidsCore/CoProcessors/WriteBoundaryConditionsCoProcessor.h +++ b/src/cpu/VirtualFluidsCore/CoProcessors/WriteBoundaryConditionsCoProcessor.h @@ -41,7 +41,7 @@ #include "CoProcessor.h" #include "UbTuple.h" -class Communicator; +namespace vf::mpi {class Communicator;} class Grid3D; class UbScheduler; class WbWriter; @@ -61,7 +61,7 @@ public: //! \param writer is WbWriter object //! \param comm is Communicator object WriteBoundaryConditionsCoProcessor(SPtr<Grid3D> grid, SPtr<UbScheduler> s, const std::string &path, - WbWriter *const writer, SPtr<Communicator> comm); + WbWriter *const writer, std::shared_ptr<vf::mpi::Communicator> comm); ~WriteBoundaryConditionsCoProcessor() override = default; void process(double step) override; @@ -84,6 +84,6 @@ private: int minInitLevel; int maxInitLevel; int gridRank; - SPtr<Communicator> comm; + std::shared_ptr<vf::mpi::Communicator> comm; }; #endif diff --git a/src/cpu/VirtualFluidsCore/CoProcessors/WriteGbObjectsCoProcessor.cpp b/src/cpu/VirtualFluidsCore/CoProcessors/WriteGbObjectsCoProcessor.cpp index 3c1c36a11fcdfc000cc6251130f720baf91607a2..1935ea22396a43dad53b2cf0a5b2960319026656 100644 --- a/src/cpu/VirtualFluidsCore/CoProcessors/WriteGbObjectsCoProcessor.cpp +++ b/src/cpu/VirtualFluidsCore/CoProcessors/WriteGbObjectsCoProcessor.cpp @@ -1,5 +1,5 @@ #include "WriteGbObjectsCoProcessor.h" -#include "Communicator.h" +#include <mpi/Communicator.h> #include "GbObject3D.h" #include "UbScheduler.h" #include "WbWriterVtkXmlASCII.h" @@ -7,7 +7,7 @@ #include <vector> WriteGbObjectsCoProcessor::WriteGbObjectsCoProcessor(SPtr<Grid3D> grid, SPtr<UbScheduler> s, const std::string &path, - WbWriter *const writer, SPtr<Communicator> comm) + WbWriter *const writer, std::shared_ptr<vf::mpi::Communicator> comm) : CoProcessor(grid, s), path(path), writer(writer), comm(comm) { } diff --git a/src/cpu/VirtualFluidsCore/CoProcessors/WriteGbObjectsCoProcessor.h b/src/cpu/VirtualFluidsCore/CoProcessors/WriteGbObjectsCoProcessor.h index d1e9925b5eaec20a1319818acb67c662e595e7d3..09b9bdeb766d5c4251c18a46df888fe67ef54df8 100644 --- a/src/cpu/VirtualFluidsCore/CoProcessors/WriteGbObjectsCoProcessor.h +++ b/src/cpu/VirtualFluidsCore/CoProcessors/WriteGbObjectsCoProcessor.h @@ -7,7 +7,7 @@ #include <vector> class GbObject3D; -class Communicator; +namespace vf::mpi {class Communicator;} class Grid3D; class UbScheduler; class WbWriter; @@ -21,7 +21,7 @@ class WriteGbObjectsCoProcessor : public CoProcessor { public: WriteGbObjectsCoProcessor(SPtr<Grid3D> grid, SPtr<UbScheduler> s, const std::string &path, WbWriter *const writer, - SPtr<Communicator> comm); + std::shared_ptr<vf::mpi::Communicator> comm); ~WriteGbObjectsCoProcessor() override; //! calls collectData. void process(double step) override; @@ -35,7 +35,7 @@ private: std::vector<SPtr<GbObject3D>> objects; std::string path; WbWriter *writer; - SPtr<Communicator> comm; + std::shared_ptr<vf::mpi::Communicator> comm; }; #endif // WriteGbObjectsCoProcessor_h__ \ No newline at end of file diff --git a/src/cpu/VirtualFluidsCore/CoProcessors/WriteMQFromSelectionCoProcessor.cpp b/src/cpu/VirtualFluidsCore/CoProcessors/WriteMQFromSelectionCoProcessor.cpp index 3d892d561fe64de1b3efb3f94450e36cc6632a0d..fc70b841ff2bee64176ec711dc579649c0f1c032 100644 --- a/src/cpu/VirtualFluidsCore/CoProcessors/WriteMQFromSelectionCoProcessor.cpp +++ b/src/cpu/VirtualFluidsCore/CoProcessors/WriteMQFromSelectionCoProcessor.cpp @@ -6,7 +6,7 @@ #include "BCArray3D.h" #include "Block3D.h" -#include "Communicator.h" +#include <mpi/Communicator.h> #include "DataSet3D.h" #include "GbObject3D.h" #include "Grid3D.h" @@ -19,7 +19,7 @@ WriteMQFromSelectionCoProcessor::WriteMQFromSelectionCoProcessor() = default; WriteMQFromSelectionCoProcessor::WriteMQFromSelectionCoProcessor(SPtr<Grid3D> grid, SPtr<UbScheduler> s, SPtr<GbObject3D> gbObject, const std::string &path, WbWriter *const writer, SPtr<LBMUnitConverter> conv, - SPtr<Communicator> comm) + std::shared_ptr<vf::mpi::Communicator> comm) : CoProcessor(grid, s), gbObject(gbObject), path(path), writer(writer), conv(conv), comm(comm) { gridRank = comm->getProcessID(); @@ -80,7 +80,7 @@ void WriteMQFromSelectionCoProcessor::collectData(double step) piece = subfolder + "/" + piece; std::vector<std::string> cellDataNames; - SPtr<Communicator> comm = Communicator::getInstance(); + std::shared_ptr<vf::mpi::Communicator> comm = vf::mpi::Communicator::getInstance(); std::vector<std::string> pieces = comm->gather(piece); if (comm->getProcessID() == comm->getRoot()) { std::string pname = diff --git a/src/cpu/VirtualFluidsCore/CoProcessors/WriteMQFromSelectionCoProcessor.h b/src/cpu/VirtualFluidsCore/CoProcessors/WriteMQFromSelectionCoProcessor.h index 0e52856cb32360a706b77fdcea8935037664b542..0dc3976b14b9930a1c1713074ff2222ad52b1fc8 100644 --- a/src/cpu/VirtualFluidsCore/CoProcessors/WriteMQFromSelectionCoProcessor.h +++ b/src/cpu/VirtualFluidsCore/CoProcessors/WriteMQFromSelectionCoProcessor.h @@ -10,7 +10,7 @@ #include "LBMSystem.h" #include "UbTuple.h" -class Communicator; +namespace vf::mpi {class Communicator;} class Grid3D; class UbScheduler; class LBMUnitConverter; @@ -24,7 +24,7 @@ public: WriteMQFromSelectionCoProcessor(); WriteMQFromSelectionCoProcessor(SPtr<Grid3D> grid, SPtr<UbScheduler> s, SPtr<GbObject3D> gbObject, const std::string &path, WbWriter *const writer, SPtr<LBMUnitConverter> conv, - SPtr<Communicator> comm); + std::shared_ptr<vf::mpi::Communicator> comm); ~WriteMQFromSelectionCoProcessor() override = default; void process(double step) override; @@ -47,7 +47,7 @@ private: int minInitLevel; int maxInitLevel; int gridRank; - SPtr<Communicator> comm; + std::shared_ptr<vf::mpi::Communicator> comm; SPtr<GbObject3D> gbObject; using CalcMacrosFct = void (*)(const LBMReal *const &, LBMReal &, LBMReal &, LBMReal &, LBMReal &); diff --git a/src/cpu/VirtualFluidsCore/CoProcessors/WriteMacroscopicQuantitiesCoProcessor.cpp b/src/cpu/VirtualFluidsCore/CoProcessors/WriteMacroscopicQuantitiesCoProcessor.cpp index e98d6ac874ace46659bc2903b3c67a0f9f93fa24..4bf2b30375145fb961cb7f932afc4aa15780820b 100644 --- a/src/cpu/VirtualFluidsCore/CoProcessors/WriteMacroscopicQuantitiesCoProcessor.cpp +++ b/src/cpu/VirtualFluidsCore/CoProcessors/WriteMacroscopicQuantitiesCoProcessor.cpp @@ -39,7 +39,7 @@ #include "BCArray3D.h" #include "Block3D.h" -#include "Communicator.h" +#include <mpi/Communicator.h> #include "DataSet3D.h" #include "Grid3D.h" #include "LBMUnitConverter.h" @@ -52,7 +52,7 @@ WriteMacroscopicQuantitiesCoProcessor::WriteMacroscopicQuantitiesCoProcessor(SPt const std::string &path, WbWriter *const writer, SPtr<LBMUnitConverter> conv, - SPtr<Communicator> comm) + std::shared_ptr<vf::mpi::Communicator> comm) : CoProcessor(grid, s), path(path), writer(writer), conv(conv), comm(comm) { gridRank = comm->getProcessID(); diff --git a/src/cpu/VirtualFluidsCore/CoProcessors/WriteMacroscopicQuantitiesCoProcessor.h b/src/cpu/VirtualFluidsCore/CoProcessors/WriteMacroscopicQuantitiesCoProcessor.h index 91df3acf3dc3f584516820e45ca000365dc5d94f..7fb1844e08cf7454294b658f539b95c38eb3fa34 100644 --- a/src/cpu/VirtualFluidsCore/CoProcessors/WriteMacroscopicQuantitiesCoProcessor.h +++ b/src/cpu/VirtualFluidsCore/CoProcessors/WriteMacroscopicQuantitiesCoProcessor.h @@ -42,7 +42,7 @@ #include "LBMSystem.h" #include "UbTuple.h" -class Communicator; +namespace vf::mpi {class Communicator;} class Grid3D; class UbScheduler; class LBMUnitConverter; @@ -63,7 +63,7 @@ public: //! \param conv is LBMUnitConverter object //! \param comm is Communicator object WriteMacroscopicQuantitiesCoProcessor(SPtr<Grid3D> grid, SPtr<UbScheduler> s, const std::string &path, - WbWriter *const writer, SPtr<LBMUnitConverter> conv, SPtr<Communicator> comm); + WbWriter *const writer, SPtr<LBMUnitConverter> conv, std::shared_ptr<vf::mpi::Communicator> comm); ~WriteMacroscopicQuantitiesCoProcessor() override = default; void process(double step) override; @@ -90,7 +90,7 @@ private: int minInitLevel; int maxInitLevel; int gridRank; - SPtr<Communicator> comm; + std::shared_ptr<vf::mpi::Communicator> comm; using CalcMacrosFct = void (*)(const LBMReal *const &, LBMReal &, LBMReal &, LBMReal &, LBMReal &); CalcMacrosFct calcMacros; diff --git a/src/cpu/VirtualFluidsCore/CoProcessors/WriteMultiphaseQuantitiesCoProcessor.cpp b/src/cpu/VirtualFluidsCore/CoProcessors/WriteMultiphaseQuantitiesCoProcessor.cpp index 73034d88996a3c22d8a3aa9e86517c5cbe92ffc3..c5442930623344fb528a7764fb1f1e314c35437c 100644 --- a/src/cpu/VirtualFluidsCore/CoProcessors/WriteMultiphaseQuantitiesCoProcessor.cpp +++ b/src/cpu/VirtualFluidsCore/CoProcessors/WriteMultiphaseQuantitiesCoProcessor.cpp @@ -39,7 +39,7 @@ #include "BCArray3D.h" #include "Block3D.h" -#include "Communicator.h" +#include <mpi/Communicator.h> #include "DataSet3D.h" #include "Grid3D.h" #include "LBMUnitConverter.h" @@ -52,7 +52,7 @@ WriteMultiphaseQuantitiesCoProcessor::WriteMultiphaseQuantitiesCoProcessor(SPtr< const std::string &path, WbWriter *const writer, SPtr<LBMUnitConverter> conv, - SPtr<Communicator> comm) + std::shared_ptr<vf::mpi::Communicator> comm) : CoProcessor(grid, s), path(path), writer(writer), conv(conv), comm(comm) { gridRank = comm->getProcessID(); diff --git a/src/cpu/VirtualFluidsCore/CoProcessors/WriteMultiphaseQuantitiesCoProcessor.h b/src/cpu/VirtualFluidsCore/CoProcessors/WriteMultiphaseQuantitiesCoProcessor.h index a4504c1dfccbad377e0bad4bc1aab51989abaff4..3825f9d4df3e744aec1605524c78f0028e4380fd 100644 --- a/src/cpu/VirtualFluidsCore/CoProcessors/WriteMultiphaseQuantitiesCoProcessor.h +++ b/src/cpu/VirtualFluidsCore/CoProcessors/WriteMultiphaseQuantitiesCoProcessor.h @@ -42,7 +42,7 @@ #include "LBMSystem.h" #include "UbTuple.h" -class Communicator; +namespace vf::mpi {class Communicator;} class Grid3D; class UbScheduler; class LBMUnitConverter; @@ -63,7 +63,7 @@ public: //! \param conv is LBMUnitConverter object //! \param comm is Communicator object WriteMultiphaseQuantitiesCoProcessor(SPtr<Grid3D> grid, SPtr<UbScheduler> s, const std::string &path, - WbWriter *const writer, SPtr<LBMUnitConverter> conv, SPtr<Communicator> comm); + WbWriter *const writer, SPtr<LBMUnitConverter> conv, std::shared_ptr<vf::mpi::Communicator> comm); ~WriteMultiphaseQuantitiesCoProcessor() override = default; void process(double step) override; @@ -90,7 +90,7 @@ private: int minInitLevel; int maxInitLevel; int gridRank; - SPtr<Communicator> comm; + std::shared_ptr<vf::mpi::Communicator> comm; LBMReal gradX1_phi(const LBMReal *const &); LBMReal gradX2_phi(const LBMReal *const &); diff --git a/src/cpu/VirtualFluidsCore/CoProcessors/WriteThixotropyQuantitiesCoProcessor.cpp b/src/cpu/VirtualFluidsCore/CoProcessors/WriteThixotropyQuantitiesCoProcessor.cpp index f2edcd551b8a08ff00792a7daea4ee70d0fa17af..900c4bc95e85e57254121882e43e89fbb05b7201 100644 --- a/src/cpu/VirtualFluidsCore/CoProcessors/WriteThixotropyQuantitiesCoProcessor.cpp +++ b/src/cpu/VirtualFluidsCore/CoProcessors/WriteThixotropyQuantitiesCoProcessor.cpp @@ -52,7 +52,7 @@ WriteThixotropyQuantitiesCoProcessor::WriteThixotropyQuantitiesCoProcessor() } ////////////////////////////////////////////////////////////////////////// -WriteThixotropyQuantitiesCoProcessor::WriteThixotropyQuantitiesCoProcessor(SPtr<Grid3D> grid, SPtr<UbScheduler> s, const std::string& path, WbWriter* const writer, SPtr<LBMUnitConverter> conv, SPtr<Communicator> comm) : CoProcessor(grid, s), path(path), writer(writer), conv(conv), comm(comm) +WriteThixotropyQuantitiesCoProcessor::WriteThixotropyQuantitiesCoProcessor(SPtr<Grid3D> grid, SPtr<UbScheduler> s, const std::string& path, WbWriter* const writer, SPtr<LBMUnitConverter> conv, std::shared_ptr<vf::mpi::Communicator> comm) : CoProcessor(grid, s), path(path), writer(writer), conv(conv), comm(comm) { gridRank = comm->getProcessID(); minInitLevel = this->grid->getCoarsestInitializedLevel(); diff --git a/src/cpu/VirtualFluidsCore/CoProcessors/WriteThixotropyQuantitiesCoProcessor.h b/src/cpu/VirtualFluidsCore/CoProcessors/WriteThixotropyQuantitiesCoProcessor.h index b14e7f9f54c0e8e444a5f00804fee5cbc1ff6e21..d247c5c76bd5dc243041e53905e2189980875bd3 100644 --- a/src/cpu/VirtualFluidsCore/CoProcessors/WriteThixotropyQuantitiesCoProcessor.h +++ b/src/cpu/VirtualFluidsCore/CoProcessors/WriteThixotropyQuantitiesCoProcessor.h @@ -38,14 +38,14 @@ #include "Grid3D.h" #include "Block3D.h" #include "LBMUnitConverter.h" -#include "Communicator.h" +#include <mpi/Communicator.h> #include "WbWriter.h" class WriteThixotropyQuantitiesCoProcessor : public CoProcessor { public: WriteThixotropyQuantitiesCoProcessor(); - WriteThixotropyQuantitiesCoProcessor(SPtr<Grid3D> grid, SPtr<UbScheduler> s, const std::string& path, WbWriter* const writer, SPtr<LBMUnitConverter> conv, SPtr<Communicator> comm); + WriteThixotropyQuantitiesCoProcessor(SPtr<Grid3D> grid, SPtr<UbScheduler> s, const std::string& path, WbWriter* const writer, SPtr<LBMUnitConverter> conv, std::shared_ptr<vf::mpi::Communicator> comm); ~WriteThixotropyQuantitiesCoProcessor() = default; void process(double step) override; @@ -69,7 +69,7 @@ private: int minInitLevel; int maxInitLevel; int gridRank; - SPtr<Communicator> comm; + std::shared_ptr<vf::mpi::Communicator> comm; // double ConcentrationSum; }; #endif diff --git a/src/cpu/VirtualFluidsCore/Grid/BasicCalculator.cpp b/src/cpu/VirtualFluidsCore/Grid/BasicCalculator.cpp index d2a7baee86607f7c99a30cf59910fa831ae4a7a9..85a01cd1f85cf3efc556dd176cb748fc947e972b 100644 --- a/src/cpu/VirtualFluidsCore/Grid/BasicCalculator.cpp +++ b/src/cpu/VirtualFluidsCore/Grid/BasicCalculator.cpp @@ -324,7 +324,7 @@ void BasicCalculator::interpolation(int startLevel, int maxInitLevel) ////////////////////////////////////////////////////////////////////////// void BasicCalculator::applyPreCollisionBC(int startLevel, int maxInitLevel) { - // startLevel bis maxInitLevel + // from startLevel to maxInitLevel for (int level = startLevel; level <= maxInitLevel; level++) { int size = (int)blocks[level].size(); #ifdef _OPENMP @@ -349,7 +349,7 @@ void BasicCalculator::applyPreCollisionBC(int startLevel, int maxInitLevel) ////////////////////////////////////////////////////////////////////////// void BasicCalculator::applyPostCollisionBC(int startLevel, int maxInitLevel) { - // startLevel bis maxInitLevel + // from startLevel to maxInitLevel for (int level = startLevel; level <= maxInitLevel; level++) { int size = (int)blocks[level].size(); #ifdef _OPENMP diff --git a/src/cpu/VirtualFluidsCore/Grid/Grid3D.cpp b/src/cpu/VirtualFluidsCore/Grid/Grid3D.cpp index 1d37e4a09f5c45967a76eb7ff1abc7999788c8b9..c1036c62ac09fbb27284faa0b27825bfee3220ac 100644 --- a/src/cpu/VirtualFluidsCore/Grid/Grid3D.cpp +++ b/src/cpu/VirtualFluidsCore/Grid/Grid3D.cpp @@ -50,7 +50,7 @@ using namespace std; Grid3D::Grid3D() { levelSet.resize(Grid3DSystem::MAXLEVEL + 1); } ////////////////////////////////////////////////////////////////////////// -Grid3D::Grid3D(SPtr<Communicator> comm) +Grid3D::Grid3D(std::shared_ptr<vf::mpi::Communicator> comm) { levelSet.resize(Grid3DSystem::MAXLEVEL + 1); @@ -58,7 +58,7 @@ Grid3D::Grid3D(SPtr<Communicator> comm) rank = comm->getProcessID(); } ////////////////////////////////////////////////////////////////////////// -Grid3D::Grid3D(SPtr<Communicator> comm, int blockNx1, int blockNx2, int blockNx3, int gridNx1, int gridNx2, int gridNx3) +Grid3D::Grid3D(std::shared_ptr<vf::mpi::Communicator> comm, int blockNx1, int blockNx2, int blockNx3, int gridNx1, int gridNx2, int gridNx3) : blockNx1(blockNx1), blockNx2(blockNx2), blockNx3(blockNx2), nx1(gridNx1), nx2(gridNx2), nx3(gridNx3) @@ -2299,7 +2299,7 @@ void Grid3D::renumberBlockIDs() ////////////////////////////////////////////////////////////////////////// -void Grid3D::updateDistributedBlocks(SPtr<Communicator> comm) +void Grid3D::updateDistributedBlocks(std::shared_ptr<vf::mpi::Communicator> comm) { std::vector<int> blocks; diff --git a/src/cpu/VirtualFluidsCore/Grid/Grid3D.h b/src/cpu/VirtualFluidsCore/Grid/Grid3D.h index f3aa968316fcc74f77584ad58ae7114dcab0840c..3607a3f99d8593f3a4c73e5393b1eb1250655883 100644 --- a/src/cpu/VirtualFluidsCore/Grid/Grid3D.h +++ b/src/cpu/VirtualFluidsCore/Grid/Grid3D.h @@ -47,7 +47,7 @@ class CoordinateTransformation3D; #include <Block3DVisitor.h> #include <Grid3DVisitor.h> -class Communicator; +namespace vf::mpi {class Communicator;} class Block3D; class Interactor3D; @@ -66,8 +66,8 @@ public: public: Grid3D(); - Grid3D(SPtr<Communicator> comm); - Grid3D(SPtr<Communicator> comm, int blockNx1, int blockNx2, int blockNx3, int gridNx1, int gridNx2, int gridNx3); + Grid3D(std::shared_ptr<vf::mpi::Communicator> comm); + Grid3D(std::shared_ptr<vf::mpi::Communicator> comm, int blockNx1, int blockNx2, int blockNx3, int gridNx1, int gridNx2, int gridNx3); virtual ~Grid3D() = default; ////////////////////////////////////////////////////////////////////////// // blocks control @@ -96,7 +96,7 @@ public: BlockIDMap &getBlockIDs(); void deleteBlockIDs(); void renumberBlockIDs(); - void updateDistributedBlocks(SPtr<Communicator> comm); + void updateDistributedBlocks(std::shared_ptr<vf::mpi::Communicator> comm); SPtr<Block3D> getSuperBlock(SPtr<Block3D> block); SPtr<Block3D> getSuperBlock(int ix1, int ix2, int ix3, int level); void getSubBlocks(SPtr<Block3D> block, int levelDepth, std::vector<SPtr<Block3D>> &blocks); diff --git a/src/cpu/VirtualFluidsCore/Interactors/InteractorsHelper.cpp b/src/cpu/VirtualFluidsCore/Interactors/InteractorsHelper.cpp index d8ee6593400e8bc89dde7d2708f31595e86f1a5b..f96c7aa2f75391c667b873e8a91a758a989d9cc2 100644 --- a/src/cpu/VirtualFluidsCore/Interactors/InteractorsHelper.cpp +++ b/src/cpu/VirtualFluidsCore/Interactors/InteractorsHelper.cpp @@ -34,7 +34,7 @@ #include "InteractorsHelper.h" #include "Block3D.h" -#include "Communicator.h" +#include <mpi/Communicator.h> #include "SetBcBlocksBlockVisitor.h" #include "SetSolidBlocksBlockVisitor.h" #include <Grid3D.h> @@ -100,6 +100,6 @@ void InteractorsHelper::updateGrid() ids.push_back(block->getGlobalID()); std::vector<int> rids; - Communicator::getInstance()->allGather(ids, rids); + vf::mpi::Communicator::getInstance()->allGather(ids, rids); grid->deleteBlocks(rids); } diff --git a/src/cpu/VirtualFluidsCore/LBM/CumulantK17LBMKernel.cpp b/src/cpu/VirtualFluidsCore/LBM/CumulantK17LBMKernel.cpp index 9c52f5e0469ce5b6c6e08136f25d3c027d36bdbd..daed493b9cc1afddbd92acabcd551da0f463ea26 100644 --- a/src/cpu/VirtualFluidsCore/LBM/CumulantK17LBMKernel.cpp +++ b/src/cpu/VirtualFluidsCore/LBM/CumulantK17LBMKernel.cpp @@ -39,7 +39,6 @@ #include "Block3D.h" #include "BCArray3D.h" - #define PROOF_CORRECTNESS using namespace UbMath; diff --git a/src/cpu/VirtualFluidsCore/LBM/CumulantK17LBMKernel.h b/src/cpu/VirtualFluidsCore/LBM/CumulantK17LBMKernel.h index 3052f50e3e48925ed21a3c3af68cc2d247c88a02..aab4d669655efe5bd489feb3829da28e67aa9ecb 100644 --- a/src/cpu/VirtualFluidsCore/LBM/CumulantK17LBMKernel.h +++ b/src/cpu/VirtualFluidsCore/LBM/CumulantK17LBMKernel.h @@ -79,7 +79,7 @@ protected: }; //////////////////////////////////////////////////////////////////////////////// -//! \brief forward chimera transformation \ref forwardInverseChimeraWithK +//! \brief forward chimera transformation \ref forwardInverseChimeraWithK //! Transformation from distributions to central moments according to Eq. (6)-(14) in //! <a href="https://doi.org/10.1016/j.jcp.2017.05.040"><b>[ M. Geier et al. (2017), DOI:10.1016/j.jcp.2017.05.040 ]</b></a> //! Modified for lower round-off errors. @@ -112,7 +112,7 @@ inline void CumulantK17LBMKernel::backwardInverseChimeraWithK(LBMReal& mfa, LBMR mfb = m1; } //////////////////////////////////////////////////////////////////////////////// -//! \brief forward chimera transformation \ref forwardChimera +//! \brief forward chimera transformation \ref forwardChimera //! Transformation from distributions to central moments according to Eq. (6)-(14) in //! <a href="https://doi.org/10.1016/j.jcp.2017.05.040"><b>[ M. Geier et al. (2017), DOI:10.1016/j.jcp.2017.05.040 ]</b></a> //! for \f$ K_{abc}=0 \f$. This is to avoid unnessary floating point operations. @@ -128,7 +128,7 @@ inline void CumulantK17LBMKernel::forwardChimera(LBMReal& mfa, LBMReal& mfb, LBM mfa = m1; } //////////////////////////////////////////////////////////////////////////////// -//! \brief backward chimera transformation \ref backwardChimera +//! \brief backward chimera transformation \ref backwardChimera //! Transformation from central moments to distributions according to Eq. (57)-(65) in //! <a href="https://doi.org/10.1016/j.jcp.2017.05.040"><b>[ M. Geier et al. (2017), DOI:10.1016/j.jcp.2017.05.040 ]</b></a> //! for \f$ K_{abc}=0 \f$. This is to avoid unnessary floating point operations. diff --git a/src/cpu/VirtualFluidsCore/LBM/D3Q27System.h b/src/cpu/VirtualFluidsCore/LBM/D3Q27System.h index 04fe8a819b143db8cc935fc893faa514805060a6..bdb443ee2e40bf53a60ebf61c249a8e80aedd4b3 100644 --- a/src/cpu/VirtualFluidsCore/LBM/D3Q27System.h +++ b/src/cpu/VirtualFluidsCore/LBM/D3Q27System.h @@ -35,14 +35,13 @@ #define D3Q27SYSTEM_H #include <cmath> -#include <iostream> #include <string> +#include <iostream> #include "LBMSystem.h" #include "UbException.h" #include "UbMath.h" - //! \brief namespace for global system-functions namespace D3Q27System { @@ -148,7 +147,6 @@ static const int ET_BNW = 11; static const int ET_TSW = 12; static const int ET_BNE = 12; - ////////////////////////////////////////////////////////////////////////// // MACROSCOPIC VALUES /*=====================================================================*/ diff --git a/src/cpu/VirtualFluidsCore/LBM/LBMKernel.h b/src/cpu/VirtualFluidsCore/LBM/LBMKernel.h index 5e211f87b3c5170589838bd71f8f7c22c2d4a431..d4c477dee5fbdaa4b66b3d0d3200d4cab761dc0f 100644 --- a/src/cpu/VirtualFluidsCore/LBM/LBMKernel.h +++ b/src/cpu/VirtualFluidsCore/LBM/LBMKernel.h @@ -53,7 +53,6 @@ public: public: LBMKernel(); - virtual ~LBMKernel() = default; virtual SPtr<LBMKernel> clone() = 0; diff --git a/src/cpu/VirtualFluidsCore/Parallel/BlocksDistributor.cpp b/src/cpu/VirtualFluidsCore/Parallel/BlocksDistributor.cpp index 09f0af7ac74b79d18220de90dab10be78f580a88..eef54a8625147046c2d8f38e2207e2fe2d20e325 100644 --- a/src/cpu/VirtualFluidsCore/Parallel/BlocksDistributor.cpp +++ b/src/cpu/VirtualFluidsCore/Parallel/BlocksDistributor.cpp @@ -1,3 +1,3 @@ #include "BlocksDistributor.h" -BlocksDistributor::BlocksDistributor(SPtr<Grid3D> grid, SPtr<Communicator> comm) : grid(grid), comm(comm) {} +BlocksDistributor::BlocksDistributor(SPtr<Grid3D> grid, std::shared_ptr<vf::mpi::Communicator> comm) : grid(grid), comm(comm) {} diff --git a/src/cpu/VirtualFluidsCore/Parallel/BlocksDistributor.h b/src/cpu/VirtualFluidsCore/Parallel/BlocksDistributor.h index 7af79dc293676ae84fe2943e3316ebb4d4ddd866..85aa52d05e0dd215ac93ca4bb08cc057f84914d0 100644 --- a/src/cpu/VirtualFluidsCore/Parallel/BlocksDistributor.h +++ b/src/cpu/VirtualFluidsCore/Parallel/BlocksDistributor.h @@ -1,7 +1,7 @@ #ifndef BlocksDistributor_H #define BlocksDistributor_H -#include "Communicator.h" +#include <mpi/Communicator.h> #include "Grid3D.h" #include <PointerDefinitions.h> @@ -9,13 +9,13 @@ class BlocksDistributor { public: - BlocksDistributor(SPtr<Grid3D> grid, SPtr<Communicator> comm); + BlocksDistributor(SPtr<Grid3D> grid, std::shared_ptr<vf::mpi::Communicator> comm); ~BlocksDistributor(); protected: private: SPtr<Grid3D> grid; - SPtr<Communicator> comm; + std::shared_ptr<vf::mpi::Communicator> comm; }; #endif diff --git a/src/cpu/VirtualFluidsCore/Utilities/CheckpointConverter.cpp b/src/cpu/VirtualFluidsCore/Utilities/CheckpointConverter.cpp index 146f5eccc6823cd3d057eb8ea08e08dd2a95ef29..6e7968f37493476ac7f076b4d7aa129b56c7326f 100644 --- a/src/cpu/VirtualFluidsCore/Utilities/CheckpointConverter.cpp +++ b/src/cpu/VirtualFluidsCore/Utilities/CheckpointConverter.cpp @@ -1,7 +1,7 @@ #include "CheckpointConverter.h" #include "Block3D.h" #include "BoundaryConditions.h" -#include "Communicator.h" +#include <mpi/Communicator.h> #include "CoordinateTransformation3D.h" #include "DataSet3D.h" #include "Grid3D.h" @@ -12,7 +12,7 @@ using namespace MPIIODataStructures; -CheckpointConverter::CheckpointConverter(SPtr<Grid3D> grid, const std::string &path, SPtr<Communicator> comm) +CheckpointConverter::CheckpointConverter(SPtr<Grid3D> grid, const std::string &path, std::shared_ptr<vf::mpi::Communicator> comm) : grid(grid), path(path), comm(comm) { UbSystem::makeDirectory(path + "/mpi_io_cp"); diff --git a/src/cpu/VirtualFluidsCore/Utilities/CheckpointConverter.h b/src/cpu/VirtualFluidsCore/Utilities/CheckpointConverter.h index bad6116ccf8e1ebc32b8f7d6e12c3d36bc1b4e46..6fe24772d574a6db67428a820027971b4c7fd230 100644 --- a/src/cpu/VirtualFluidsCore/Utilities/CheckpointConverter.h +++ b/src/cpu/VirtualFluidsCore/Utilities/CheckpointConverter.h @@ -8,14 +8,14 @@ #include <vector> class Grid3D; -class Communicator; +namespace vf::mpi {class Communicator;} //! \class UtilConvertor //! \brief Converts timestep data from MPIIORestartCoProcessor format into MPIIOMigrationCoProcessor format class CheckpointConverter { public: - CheckpointConverter(SPtr<Grid3D> grid, const std::string &path, SPtr<Communicator> comm); + CheckpointConverter(SPtr<Grid3D> grid, const std::string &path, std::shared_ptr<vf::mpi::Communicator> comm); virtual ~CheckpointConverter(); void convert(int step, int procCount); @@ -26,7 +26,7 @@ public: protected: std::string path; - SPtr<Communicator> comm; + std::shared_ptr<vf::mpi::Communicator> comm; SPtr<Grid3D> grid; private: diff --git a/src/cpu/VirtualFluidsCore/Visitors/CreateTransmittersHelper.cpp b/src/cpu/VirtualFluidsCore/Visitors/CreateTransmittersHelper.cpp index 89b76aa946a42d848b4bf9e5e4dcf67726b2404b..7602438a23f16295f8d518f70d5a036dac4515ec 100644 --- a/src/cpu/VirtualFluidsCore/Visitors/CreateTransmittersHelper.cpp +++ b/src/cpu/VirtualFluidsCore/Visitors/CreateTransmittersHelper.cpp @@ -50,7 +50,7 @@ CreateTransmittersHelper::CreateTransmittersHelper() = default; ////////////////////////////////////////////////////////////////////////// void CreateTransmittersHelper::createTransmitters(SPtr<Block3D> sblock, SPtr<Block3D> tblock, int dir, IBlock ib, TransmitterPtr &sender, TransmitterPtr &receiver, - SPtr<Communicator> comm, TransmitterType tType) + std::shared_ptr<vf::mpi::Communicator> comm, TransmitterType tType) { // SourceBlock int srcLevel = sblock->getLevel(); diff --git a/src/cpu/VirtualFluidsCore/Visitors/CreateTransmittersHelper.h b/src/cpu/VirtualFluidsCore/Visitors/CreateTransmittersHelper.h index 353bb31229841c7b61fea4d2a4d7fca272e39135..d51f6352a251fe360aaf2a8365c77315e099d4d2 100644 --- a/src/cpu/VirtualFluidsCore/Visitors/CreateTransmittersHelper.h +++ b/src/cpu/VirtualFluidsCore/Visitors/CreateTransmittersHelper.h @@ -35,7 +35,7 @@ #define CREATETRANSMITTERSHELPER_H #include "Block3D.h" -#include "Communicator.h" +#include <mpi/Communicator.h> #include "LBMSystem.h" @@ -61,7 +61,7 @@ public: public: CreateTransmittersHelper(); void createTransmitters(const SPtr<Block3D> sblock, const SPtr<Block3D> tblock, int dir, IBlock ib, - TransmitterPtr &sender, TransmitterPtr &receiver, SPtr<Communicator> comm, + TransmitterPtr &sender, TransmitterPtr &receiver, std::shared_ptr<vf::mpi::Communicator> comm, TransmitterType tType); protected: diff --git a/src/cpu/VirtualFluidsCore/Visitors/MetisPartitioningGridVisitor.cpp b/src/cpu/VirtualFluidsCore/Visitors/MetisPartitioningGridVisitor.cpp index 7b516fc75c608a1627edc9b75264d32bc660c59a..412e9347d707fe2e4ad733cf53419f18f86faf01 100644 --- a/src/cpu/VirtualFluidsCore/Visitors/MetisPartitioningGridVisitor.cpp +++ b/src/cpu/VirtualFluidsCore/Visitors/MetisPartitioningGridVisitor.cpp @@ -2,14 +2,14 @@ #include "MetisPartitioningGridVisitor.h" #include "Block3D.h" -#include "Communicator.h" +#include <mpi/Communicator.h> #include "D3Q27System.h" #include "Grid3D.h" #include <cmath> using namespace std; -MetisPartitioningGridVisitor::MetisPartitioningGridVisitor(SPtr<Communicator> comm, GraphType graphType, int numOfDirs, +MetisPartitioningGridVisitor::MetisPartitioningGridVisitor(std::shared_ptr<vf::mpi::Communicator> comm, GraphType graphType, int numOfDirs, MetisPartitioner::PartType partType, bool threads, int numberOfThreads) : Grid3DVisitor(), numberOfThreads(numberOfThreads), numOfDirs(numOfDirs), comm(comm), threads(threads), diff --git a/src/cpu/VirtualFluidsCore/Visitors/MetisPartitioningGridVisitor.h b/src/cpu/VirtualFluidsCore/Visitors/MetisPartitioningGridVisitor.h index d1bc5ba308ff798c21cc27cae02367f31b35fbac..c270d3ce389cc2697c1ac54178984ffa2f4d07a9 100644 --- a/src/cpu/VirtualFluidsCore/Visitors/MetisPartitioningGridVisitor.h +++ b/src/cpu/VirtualFluidsCore/Visitors/MetisPartitioningGridVisitor.h @@ -9,7 +9,7 @@ #include "Grid3DVisitor.h" #include "MetisPartitioner.h" -class Communicator; +namespace vf::mpi {class Communicator;} //////////////////////////////////////////////////////////////////////// //! \brief The class implements domain decomposition with METIS library @@ -32,7 +32,7 @@ public: //! \param numOfDirs - maximum number of neighbors for each process //! \param threads - on/off decomposition for threads //! \param numberOfThreads - number of threads - MetisPartitioningGridVisitor(SPtr<Communicator> comm, GraphType graphType, int numOfDirs, + MetisPartitioningGridVisitor(std::shared_ptr<vf::mpi::Communicator> comm, GraphType graphType, int numOfDirs, MetisPartitioner::PartType partType = MetisPartitioner::KWAY, bool threads = false, int numberOfThreads = 0); ~MetisPartitioningGridVisitor() override; @@ -52,7 +52,7 @@ protected: int numOfDirs; std::vector<int> blockID; std::vector<idx_t> parts; - SPtr<Communicator> comm; + std::shared_ptr<vf::mpi::Communicator> comm; int bundleRoot; int processRoot; int bundleID; diff --git a/src/cpu/VirtualFluidsCore/Visitors/RefineAroundGbObjectHelper.cpp b/src/cpu/VirtualFluidsCore/Visitors/RefineAroundGbObjectHelper.cpp index 88ff49408be67b02f9f56cf35287ba17f1216b33..c151ac90492bc7545f7d498fdfd2b3f9efbc9ab6 100644 --- a/src/cpu/VirtualFluidsCore/Visitors/RefineAroundGbObjectHelper.cpp +++ b/src/cpu/VirtualFluidsCore/Visitors/RefineAroundGbObjectHelper.cpp @@ -1,5 +1,5 @@ #include "RefineAroundGbObjectHelper.h" -#include "Communicator.h" +#include <mpi/Communicator.h> #include "OverlapBlockVisitor.h" #include "RatioBlockVisitor.h" #include "RatioSmoothBlockVisitor.h" @@ -11,7 +11,7 @@ RefineAroundGbObjectHelper::RefineAroundGbObjectHelper(SPtr<Grid3D> grid, int refineLevel, SPtr<D3Q27TriFaceMeshInteractor> objectIter, double startDistance, double stopDistance, - SPtr<Communicator> comm) + std::shared_ptr<vf::mpi::Communicator> comm) : grid(grid), refineLevel(refineLevel), objectIter(objectIter), startDistance(startDistance), stopDistance(stopDistance), comm(comm) { diff --git a/src/cpu/VirtualFluidsCore/Visitors/RefineAroundGbObjectHelper.h b/src/cpu/VirtualFluidsCore/Visitors/RefineAroundGbObjectHelper.h index 766c290a7605eb428449fe5d5f6215157a08e3d4..0421a963e6d57da5096370eed9721220c98939b4 100644 --- a/src/cpu/VirtualFluidsCore/Visitors/RefineAroundGbObjectHelper.h +++ b/src/cpu/VirtualFluidsCore/Visitors/RefineAroundGbObjectHelper.h @@ -4,7 +4,7 @@ #include <PointerDefinitions.h> class Grid3D; -class Communicator; +namespace vf::mpi {class Communicator;} class D3Q27TriFaceMeshInteractor; //! \brief Refine blocks on base of bounding boxes. @@ -20,7 +20,7 @@ public: //! \param startDistance start distance from geometry for refinement //! \param stopDistance stop distance from geometry for refinement RefineAroundGbObjectHelper(SPtr<Grid3D> grid, int maxRefineLevel, SPtr<D3Q27TriFaceMeshInteractor> objectIter, - double startDistance, double stopDistance, SPtr<Communicator> comm); + double startDistance, double stopDistance, std::shared_ptr<vf::mpi::Communicator> comm); virtual ~RefineAroundGbObjectHelper(); //! start refinement void refine(); @@ -30,7 +30,7 @@ private: SPtr<D3Q27TriFaceMeshInteractor> objectIter; int refineLevel; double startDistance, stopDistance; - SPtr<Communicator> comm; + std::shared_ptr<vf::mpi::Communicator> comm; }; #endif diff --git a/src/cpu/VirtualFluidsCore/Visitors/RefineCrossAndInsideGbObjectHelper.cpp b/src/cpu/VirtualFluidsCore/Visitors/RefineCrossAndInsideGbObjectHelper.cpp index 14ea2b073e43065d31cecc8b2893503d7fc0ed60..656457c0580739bd00783b3050fb2c460eaa5a14 100644 --- a/src/cpu/VirtualFluidsCore/Visitors/RefineCrossAndInsideGbObjectHelper.cpp +++ b/src/cpu/VirtualFluidsCore/Visitors/RefineCrossAndInsideGbObjectHelper.cpp @@ -1,6 +1,6 @@ #include "RefineCrossAndInsideGbObjectHelper.h" #include "CheckRatioBlockVisitor.h" -#include "Communicator.h" +#include <mpi/Communicator.h> #include "OverlapBlockVisitor.h" #include "RatioBlockVisitor.h" #include "RatioSmoothBlockVisitor.h" @@ -11,7 +11,7 @@ #include <Grid3D.h> RefineCrossAndInsideGbObjectHelper::RefineCrossAndInsideGbObjectHelper(SPtr<Grid3D> grid, int maxRefineLevel, - SPtr<Communicator> comm) + std::shared_ptr<vf::mpi::Communicator> comm) : grid(grid), maxRefineLevel(maxRefineLevel), comm(comm) { } diff --git a/src/cpu/VirtualFluidsCore/Visitors/RefineCrossAndInsideGbObjectHelper.h b/src/cpu/VirtualFluidsCore/Visitors/RefineCrossAndInsideGbObjectHelper.h index fd1fefe3d1e522d5fd3e60a97785d94590247bb0..d0a9ac44891519b3fd583f98a56e33dfd1e42122 100644 --- a/src/cpu/VirtualFluidsCore/Visitors/RefineCrossAndInsideGbObjectHelper.h +++ b/src/cpu/VirtualFluidsCore/Visitors/RefineCrossAndInsideGbObjectHelper.h @@ -4,7 +4,7 @@ #include <PointerDefinitions.h> #include <vector> -class Communicator; +namespace vf::mpi {class Communicator;} class Grid3D; class GbObject3D; @@ -17,7 +17,7 @@ public: //! Constructor //! \param grid a smart pointer to the grid object //! \param maxRefineLevel an integer for maximal refinement level - RefineCrossAndInsideGbObjectHelper(SPtr<Grid3D> grid, int maxRefineLevel, SPtr<Communicator> comm); + RefineCrossAndInsideGbObjectHelper(SPtr<Grid3D> grid, int maxRefineLevel, std::shared_ptr<vf::mpi::Communicator> comm); virtual ~RefineCrossAndInsideGbObjectHelper(); //! add geometric object //! \param object a smart pointer to bounding box @@ -31,7 +31,7 @@ private: std::vector<SPtr<GbObject3D>> objects; std::vector<int> levels; int maxRefineLevel; - SPtr<Communicator> comm; + std::shared_ptr<vf::mpi::Communicator> comm; }; #endif diff --git a/src/cpu/VirtualFluidsCore/Visitors/RenumberGridVisitor.cpp b/src/cpu/VirtualFluidsCore/Visitors/RenumberGridVisitor.cpp index 433e08cea74fcf7c67df0ee0119b34036e19de8c..fc9c5c203c5d631ae7e125f75d72d70e8502890d 100644 --- a/src/cpu/VirtualFluidsCore/Visitors/RenumberGridVisitor.cpp +++ b/src/cpu/VirtualFluidsCore/Visitors/RenumberGridVisitor.cpp @@ -4,7 +4,7 @@ #include "Grid3DSystem.h" //#include <mpi.h> -RenumberGridVisitor::RenumberGridVisitor(SPtr<Communicator> com) : comm(com) {} +RenumberGridVisitor::RenumberGridVisitor(std::shared_ptr<vf::mpi::Communicator> com) : comm(com) {} ////////////////////////////////////////////////////////////////////////// void RenumberGridVisitor::visit(SPtr<Grid3D> grid) diff --git a/src/cpu/VirtualFluidsCore/Visitors/RenumberGridVisitor.h b/src/cpu/VirtualFluidsCore/Visitors/RenumberGridVisitor.h index eabb0cafd06af9588b87dc479f4684393e6afb5c..993bccd1034d0fb648c2e05d77da380916816967 100644 --- a/src/cpu/VirtualFluidsCore/Visitors/RenumberGridVisitor.h +++ b/src/cpu/VirtualFluidsCore/Visitors/RenumberGridVisitor.h @@ -8,7 +8,7 @@ #ifndef RenumberGridVisitor_h #define RenumberGridVisitor_h -#include "Communicator.h" +#include <mpi/Communicator.h> #include "Grid3DVisitor.h" class Grid3D; @@ -19,14 +19,14 @@ class Grid3D; class RenumberGridVisitor : public Grid3DVisitor { public: - RenumberGridVisitor(SPtr<Communicator> com); + RenumberGridVisitor(std::shared_ptr<vf::mpi::Communicator> com); ~RenumberGridVisitor() override = default; void visit(SPtr<Grid3D> grid) override; private: - SPtr<Communicator> comm; + std::shared_ptr<vf::mpi::Communicator> comm; // static int counter; }; diff --git a/src/cpu/VirtualFluidsCore/Visitors/SetConnectorsBlockVisitor.h b/src/cpu/VirtualFluidsCore/Visitors/SetConnectorsBlockVisitor.h index 827a8263a3b4bf0f013dc7b1be7f597ce5ccb82e..bd28c23f9ec7bf43acbd37a532ce07652ae6ee93 100644 --- a/src/cpu/VirtualFluidsCore/Visitors/SetConnectorsBlockVisitor.h +++ b/src/cpu/VirtualFluidsCore/Visitors/SetConnectorsBlockVisitor.h @@ -41,7 +41,7 @@ #include "Grid3DSystem.h" #include "Grid3D.h" #include "CreateTransmittersHelper.h" -#include "Communicator.h" +#include <mpi/Communicator.h> #include "OneDistributionFullDirectConnector.h" #include "OneDistributionFullVectorConnector.h" #include "TwoDistributionsFullDirectConnector.h" @@ -58,20 +58,20 @@ public: using LocalConnector = T1; using RemoteConnector = T2; public: - SetConnectorsBlockVisitor(SPtr<Communicator> comm); + SetConnectorsBlockVisitor(std::shared_ptr<vf::mpi::Communicator> comm); ~SetConnectorsBlockVisitor() override; void visit(SPtr<Grid3D> grid, SPtr<Block3D> block) override; ////////////////////////////////////////////////////////////////////////// protected: void setSameLevelConnectors(SPtr<Grid3D> grid, SPtr<Block3D> block); void setRemoteConnectors(SPtr<Block3D> sblock, SPtr<Block3D> tblock, int dir); - SPtr<Communicator> comm; + std::shared_ptr<vf::mpi::Communicator> comm; int dirs; int gridRank; }; template <class T1, class T2> -SetConnectorsBlockVisitor<T1, T2>::SetConnectorsBlockVisitor(SPtr<Communicator> comm) +SetConnectorsBlockVisitor<T1, T2>::SetConnectorsBlockVisitor(std::shared_ptr<vf::mpi::Communicator> comm) : Block3DVisitor(0, Grid3DSystem::MAXLEVEL), comm(comm) { } diff --git a/src/cpu/VirtualFluidsCore/Visitors/SetInterpolationConnectorsBlockVisitor.cpp b/src/cpu/VirtualFluidsCore/Visitors/SetInterpolationConnectorsBlockVisitor.cpp index 8c0d4b93066eb69f8036cc80fab9254c7678b741..6a55ee5af55df96b4c1335976728ca7e08ee8ece 100644 --- a/src/cpu/VirtualFluidsCore/Visitors/SetInterpolationConnectorsBlockVisitor.cpp +++ b/src/cpu/VirtualFluidsCore/Visitors/SetInterpolationConnectorsBlockVisitor.cpp @@ -39,10 +39,10 @@ #include "Grid3DSystem.h" #include <basics/transmitter/TbTransmitterLocal.h> -#include "Communicator.h" +#include <mpi/Communicator.h> #include "InterpolationProcessor.h" -SetInterpolationConnectorsBlockVisitor::SetInterpolationConnectorsBlockVisitor(SPtr<Communicator> comm, LBMReal nue, SPtr<InterpolationProcessor> iProcessor) : +SetInterpolationConnectorsBlockVisitor::SetInterpolationConnectorsBlockVisitor(std::shared_ptr<vf::mpi::Communicator> comm, LBMReal nue, SPtr<InterpolationProcessor> iProcessor) : Block3DVisitor(0, Grid3DSystem::MAXLEVEL), comm(comm), nue(nue), diff --git a/src/cpu/VirtualFluidsCore/Visitors/SetInterpolationConnectorsBlockVisitor.h b/src/cpu/VirtualFluidsCore/Visitors/SetInterpolationConnectorsBlockVisitor.h index 972a878bf210d0532126c0c6fb481f3ed936db7a..7ae54b0b62cadbc58eb5b0cc804f00a977d47615 100644 --- a/src/cpu/VirtualFluidsCore/Visitors/SetInterpolationConnectorsBlockVisitor.h +++ b/src/cpu/VirtualFluidsCore/Visitors/SetInterpolationConnectorsBlockVisitor.h @@ -43,14 +43,14 @@ class Grid3D; class Block3D; -class Communicator; +namespace vf::mpi {class Communicator;} class InterpolationProcessor; //! \brief A class sets connectors between blocks. class SetInterpolationConnectorsBlockVisitor : public Block3DVisitor { public: - SetInterpolationConnectorsBlockVisitor(SPtr<Communicator> comm, LBMReal nue, SPtr<InterpolationProcessor> iProcessor); + SetInterpolationConnectorsBlockVisitor(std::shared_ptr<vf::mpi::Communicator> comm, LBMReal nue, SPtr<InterpolationProcessor> iProcessor); ~SetInterpolationConnectorsBlockVisitor() override; void visit(SPtr<Grid3D> grid, SPtr<Block3D> block) override; ////////////////////////////////////////////////////////////////////////// @@ -63,7 +63,7 @@ protected: CreateTransmittersHelper::TransmitterPtr &receiverCF, CreateTransmittersHelper::TransmitterPtr &senderFC, CreateTransmittersHelper::TransmitterPtr &receiverFC); - SPtr<Communicator> comm; + std::shared_ptr<vf::mpi::Communicator> comm; int gridRank; LBMReal nue; SPtr<InterpolationProcessor> iProcessor; diff --git a/src/cpu/VirtualFluidsCore/Visitors/ZoltanPartitioningGridVisitor.cpp b/src/cpu/VirtualFluidsCore/Visitors/ZoltanPartitioningGridVisitor.cpp index 9a148a4f9bb799240a5ad0ba087d4354b8d0342a..7d9f5e8d4e233c6f18aa5e95818b71143c3d3442 100644 --- a/src/cpu/VirtualFluidsCore/Visitors/ZoltanPartitioningGridVisitor.cpp +++ b/src/cpu/VirtualFluidsCore/Visitors/ZoltanPartitioningGridVisitor.cpp @@ -9,7 +9,7 @@ using namespace std; -ZoltanPartitioningGridVisitor::ZoltanPartitioningGridVisitor(SPtr<Communicator> comm, int numOfDirs, +ZoltanPartitioningGridVisitor::ZoltanPartitioningGridVisitor(std::shared_ptr<vf::mpi::Communicator> comm, int numOfDirs, int numOfLocalParts) : comm(comm), numOfDirs(numOfDirs), numOfLocalParts(numOfLocalParts) { diff --git a/src/cpu/VirtualFluidsCore/Visitors/ZoltanPartitioningGridVisitor.h b/src/cpu/VirtualFluidsCore/Visitors/ZoltanPartitioningGridVisitor.h index 4d9cd63c5c4c4a34bc8a1d5935b895fd9c5a2129..aeaf4d705c0b91cad482f87dff36ad6347363504 100644 --- a/src/cpu/VirtualFluidsCore/Visitors/ZoltanPartitioningGridVisitor.h +++ b/src/cpu/VirtualFluidsCore/Visitors/ZoltanPartitioningGridVisitor.h @@ -10,14 +10,14 @@ #if defined VF_ZOLTAN && defined VF_MPI -#include "Communicator.h" +#include <mpi/Communicator.h> #include "Grid3DVisitor.h" #include "ZoltanPartitioner.h" class ZoltanPartitioningGridVisitor : public Grid3DVisitor { public: - ZoltanPartitioningGridVisitor(SPtr<Communicator> comm, int numOfDirs, int numOfLocalParts = 1); + ZoltanPartitioningGridVisitor(std::shared_ptr<vf::mpi::Communicator> comm, int numOfDirs, int numOfLocalParts = 1); ~ZoltanPartitioningGridVisitor(); void visit(SPtr<Grid3D> grid); @@ -26,7 +26,7 @@ protected: void repartGrid(SPtr<Grid3D> grid, ZoltanPartitioner &zp); private: - SPtr<Communicator> comm; + std::shared_ptr<vf::mpi::Communicator> comm; int numOfDirs; int numOfLocalParts; ZoltanGraph *graph; diff --git a/src/cpu/simulationconfig/include/simulationconfig/Simulation.h b/src/cpu/simulationconfig/include/simulationconfig/Simulation.h index 4bf800c2375347ab7040424bdb2e4c53d5cc2bf8..63298db81741864b40c4b320fbe4bd72f688715c 100644 --- a/src/cpu/simulationconfig/include/simulationconfig/Simulation.h +++ b/src/cpu/simulationconfig/include/simulationconfig/Simulation.h @@ -4,13 +4,15 @@ #include <string> #include <memory> #include <set> + +#include <mpi/Communicator.h> + #include <geometry3d/GbPoint3D.h> #include <Interactors/Interactor3D.h> #include <BoundaryConditions/BCAdapter.h> #include <Visitors/BoundaryConditionsBlockVisitor.h> #include <CoProcessors/CoProcessor.h> #include <LBM/LBMUnitConverter.h> -#include <Parallel/Communicator.h> #include "KernelFactory.h" #include "AbstractLBMSystem.h" #include "KernelConfigStructs.h" @@ -24,7 +26,7 @@ private: std::shared_ptr<LBMKernel> lbmKernel; std::shared_ptr<AbstractLBMSystem> lbmSystem; - std::shared_ptr<Communicator> communicator; + std::shared_ptr<vf::mpi::Communicator> communicator; std::shared_ptr<Grid3D> grid; std::vector<std::shared_ptr<Interactor3D>> interactors; diff --git a/src/cpu/simulationconfig/src/Simulation.cpp b/src/cpu/simulationconfig/src/Simulation.cpp index f4fbad090fc60e424e777b4f601243eef8eb151e..ab818f5280628e51648e6d478dbb827b2bcc78ed 100644 --- a/src/cpu/simulationconfig/src/Simulation.cpp +++ b/src/cpu/simulationconfig/src/Simulation.cpp @@ -23,7 +23,7 @@ #include <LBM/CompressibleOffsetMomentsInterpolationProcessor.h> #include <LBM/LBMKernel.h> #include <LBM/LBMUnitConverter.h> -#include <Parallel/MPICommunicator.h> +#include <mpi/MPICommunicator.h> #include <Visitors/GenBlocksGridVisitor.h> #include <Visitors/InitDistributionsBlockVisitor.h> #include <Visitors/MetisPartitioningGridVisitor.h> @@ -36,7 +36,7 @@ Simulation::Simulation() { - this->communicator = MPICommunicator::getInstance(); + this->communicator = vf::mpi::MPICommunicator::getInstance(); this->grid = std::shared_ptr<Grid3D>(new Grid3D(communicator)); this->interactors = std::vector<std::shared_ptr<Interactor3D>>(); this->bcVisitor = BoundaryConditionsBlockVisitor(); diff --git a/src/cuda/CMakeLists.txt b/src/cuda/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..4d49cfedc903f3578b64916966405ea48bf28901 --- /dev/null +++ b/src/cuda/CMakeLists.txt @@ -0,0 +1,3 @@ +project(cuda LANGUAGES CUDA CXX) + +vf_add_library(NAME vf_cuda PUBLIC_LINK logger) diff --git a/src/cuda/CudaGrid.cpp b/src/cuda/CudaGrid.cpp new file mode 100644 index 0000000000000000000000000000000000000000..c7267972859f04931d9a69cfca073c7ac3267b9f --- /dev/null +++ b/src/cuda/CudaGrid.cpp @@ -0,0 +1,30 @@ +#include "CudaGrid.h" + +#include <logger/Logger.h> + +namespace vf::cuda +{ + +CudaGrid::CudaGrid(unsigned int numberOfThreads, unsigned int numberOfEntities) +{ + unsigned int Grid = (numberOfEntities / numberOfThreads) + 1; + unsigned int Grid1, Grid2; + if (Grid > 512) { + Grid1 = 512; + Grid2 = (Grid / Grid1) + 1; + } else { + Grid1 = 1; + Grid2 = Grid; + } + + grid = dim3(Grid1, Grid2); + threads = dim3(numberOfThreads, 1, 1); +} + +void CudaGrid::print() const +{ + VF_LOG_INFO("blocks: ({},{},{}), threads: ({},{},{})", grid.x, grid.y, grid.z, threads.x, threads.y, threads.z); +} + + +} diff --git a/src/cuda/CudaGrid.h b/src/cuda/CudaGrid.h new file mode 100644 index 0000000000000000000000000000000000000000..a9926c3861749f648da529f2b45554d13599a302 --- /dev/null +++ b/src/cuda/CudaGrid.h @@ -0,0 +1,24 @@ +#ifndef CUDA_GRID_H +#define CUDA_GRID_H + + +#include <cuda_runtime.h> + +namespace vf::cuda +{ + +struct CudaGrid +{ + dim3 threads; + dim3 grid; + + CudaGrid(unsigned int numberOfThreads, unsigned int numberOfEntities); + CudaGrid() = default; + + void print() const; +}; + + +} + +#endif diff --git a/src/gpu/VirtualFluids_GPU/LBM/CudaTimer.cpp b/src/cuda/CudaTimer.cpp similarity index 97% rename from src/gpu/VirtualFluids_GPU/LBM/CudaTimer.cpp rename to src/cuda/CudaTimer.cpp index 299f898aaaf69583a5cba76d824b01c73ace629d..97a2c0977058b712ab345f6d2c1299b3e2448198 100644 --- a/src/gpu/VirtualFluids_GPU/LBM/CudaTimer.cpp +++ b/src/cuda/CudaTimer.cpp @@ -1,5 +1,8 @@ #include "CudaTimer.h" +namespace vf::cuda +{ + void CudaTimer::createSdkTimer() { sdkCreateTimer(&sdkTimer); @@ -49,3 +52,5 @@ void CudaTimer::deleteEventTimer() checkCudaErrors(cudaEventDestroy(start_t)); checkCudaErrors(cudaEventDestroy(stop_t)); } + +} diff --git a/src/gpu/VirtualFluids_GPU/LBM/CudaTimer.h b/src/cuda/CudaTimer.h similarity index 88% rename from src/gpu/VirtualFluids_GPU/LBM/CudaTimer.h rename to src/cuda/CudaTimer.h index cb15eee9c8b7f529a10102c1a7331fa90a714724..51193c2f73959e31dab8661a952756f2d0882e06 100644 --- a/src/gpu/VirtualFluids_GPU/LBM/CudaTimer.h +++ b/src/cuda/CudaTimer.h @@ -1,11 +1,13 @@ -#ifndef CudaTimer_H -#define CudaTimer_H +#ifndef CUDA_CudaTimer_H +#define CUDA_CudaTimer_H #include <cuda_runtime.h> #include <helper_functions.h> #include <helper_cuda.h> +namespace vf::cuda +{ class CudaTimer { @@ -30,4 +32,6 @@ private: }; +} + #endif diff --git a/src/cuda/DeviceInfo.cpp b/src/cuda/DeviceInfo.cpp new file mode 100644 index 0000000000000000000000000000000000000000..20ea2c4f6ba098b17e444f55625a6791e46141e5 --- /dev/null +++ b/src/cuda/DeviceInfo.cpp @@ -0,0 +1,123 @@ +#include "DeviceInfo.h" + +#include <stdio.h> +#include <stdlib.h> + +#include <cuda_runtime.h> + +#include <logger/Logger.h> + +namespace vf::cuda +{ + +void verifyNumberOfDevices(int deviceId) +{ + int device_count = 0; + cudaError_t errorId = cudaGetDeviceCount(&device_count); + if(errorId != cudaSuccess) { + VF_LOG_CRITICAL("Error while accessing the device count: {}", cudaGetErrorString(errorId)); + } + if (deviceId > device_count) { + throw std::runtime_error("chosen gpudevice >= device_count ... exiting\n"); + } +} + +void verifyComputeCapability(int deviceId) +{ + cudaDeviceProp deviceProp; + cudaError_t errorId = cudaGetDeviceProperties(&deviceProp, deviceId); + + if(errorId != cudaSuccess){ + VF_LOG_CRITICAL("Error while accessing the device properties occurs: {}", cudaGetErrorString(errorId)); + } + + VF_LOG_INFO("[compute capability] = [{}.{}]\n", deviceProp.major, deviceProp.minor); + + if (deviceProp.major > 999) { + throw std::runtime_error("warning, CUDA Device Emulation (CPU) detected, exiting\n"); + } +} + +void setCudaDevice(int deviceId) +{ + // choose a cuda device for kernel execution + cudaError_t errorId = cudaSetDevice(deviceId); + if (errorId != cudaSuccess) { + VF_LOG_CRITICAL("Error while setting the device to {}: {}", deviceId, cudaGetErrorString(errorId)); + } else { + int device; + // double check that device was properly selected + errorId = cudaGetDevice(&device); + if(errorId != cudaSuccess) { + VF_LOG_CRITICAL("Error while getting the device: {}", cudaGetErrorString(errorId)); + } + } +} + +void verifyAndSetDevice(int deviceId) +{ + verifyNumberOfDevices(deviceId); + verifyComputeCapability(deviceId); + + setCudaDevice(deviceId); +} + + + +void printCudaInformation(int deviceId) +{ + cudaDeviceProp prop; + cudaError_t errorId = cudaGetDeviceProperties(&prop, deviceId); + + if(errorId != cudaSuccess){ + VF_LOG_CRITICAL("Error while accessing the device properties occurs: {}", cudaGetErrorString(errorId)); + } + + printf(" --- General Information for device %d ---\n", deviceId); + printf("Name: %s\n", prop.name); + printf("Compute capability: %d.%d\n", prop.major, prop.minor); + printf("Clock rate: %d\n", prop.clockRate); + printf("Device copy overlap: "); + if (prop.deviceOverlap) + printf("Enabled\n"); + else + printf("Disabled\n"); + printf("Kernel execition timeout : "); + if (prop.kernelExecTimeoutEnabled) + printf("Enabled\n"); + else + printf("Disabled\n"); + printf(" --- Memory Information for device %d ---\n", deviceId); + printf("Total global mem: %zu\n", prop.totalGlobalMem); + printf("Total constant Mem: %zu\n", prop.totalConstMem); + printf("Max mem pitch: %zu\n", prop.memPitch); + printf("Texture Alignment: %zu\n", prop.textureAlignment); + printf("max Texture 1D: %d\n", prop.maxTexture1D); + printf("max Texture 2D: %d, %d\n", prop.maxTexture2D[0], prop.maxTexture2D[1]); + printf("max Texture 3D: %d, %d, %d\n", prop.maxTexture3D[0], prop.maxTexture3D[1], prop.maxTexture3D[2]); + printf(" --- MP Information for device %d ---\n", deviceId); + printf("Multiprocessor count: %d\n", + prop.multiProcessorCount); + printf("Shared mem per mp: %zd\n", prop.sharedMemPerBlock); + printf("Registers per mp: %d\n", prop.regsPerBlock); + printf("Threads in warp: %d\n", prop.warpSize); + printf("Max threads per block: %d\n", + prop.maxThreadsPerBlock); + printf("Max thread dimensions: (%d, %d, %d)\n", + prop.maxThreadsDim[0], prop.maxThreadsDim[1], + prop.maxThreadsDim[2]); + printf("Max grid dimensions: (%d, %d, %d)\n", + prop.maxGridSize[0], prop.maxGridSize[1], + prop.maxGridSize[2]); + printf(" --- -------------------------------- ---\n"); + printf("\n"); + + cudaSetDevice(deviceId); + size_t free; + size_t total; + cudaMemGetInfo(&free, &total); + printf("Free: %zu Bytes, Total: %zu Bytes\n", free, total); + printf("Free: %zu MB, Total: %zu MB\n", free / 1000 / 1000, total / 1000 / 1000); +} + +} \ No newline at end of file diff --git a/src/cuda/DeviceInfo.h b/src/cuda/DeviceInfo.h new file mode 100644 index 0000000000000000000000000000000000000000..9a34824f38ecf5a7db035e87826b732325fdfddd --- /dev/null +++ b/src/cuda/DeviceInfo.h @@ -0,0 +1,13 @@ +#ifndef CUDA_DEVICEINFO_H +#define CUDA_DEVICEINFO_H + +namespace vf::cuda +{ + +void verifyAndSetDevice(int deviceId); + +void printCudaInformation(int deviceId); + +} + +#endif diff --git a/src/gpu/GksGpu/Analyzer/EnstrophyAnalyzer.cu b/src/gpu/GksGpu/Analyzer/EnstrophyAnalyzer.cu index 5a3dc76db1440fc641bd7c58cdce48b7996d63ee..346692bfdf8c8daf9a659a3a0ef04aa57f487545 100644 --- a/src/gpu/GksGpu/Analyzer/EnstrophyAnalyzer.cu +++ b/src/gpu/GksGpu/Analyzer/EnstrophyAnalyzer.cu @@ -59,6 +59,8 @@ bool EnstrophyAnalyzer::run(uint iter) this->enstrophyTimeSeries.push_back( EnstrophyTmp ); //*logging::out << logging::Logger::INFO_HIGH << "EKin = " << EKin << "\n"; + + return true; } //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/src/gpu/GksGpu/Analyzer/HeatFluxAnalyzer.cu b/src/gpu/GksGpu/Analyzer/HeatFluxAnalyzer.cu index 266d3b564d5a413f68fa27130b6a9f02eac54511..ed68f8d95a2a68c00ab53c2cd1037bbff43e0f5b 100644 --- a/src/gpu/GksGpu/Analyzer/HeatFluxAnalyzer.cu +++ b/src/gpu/GksGpu/Analyzer/HeatFluxAnalyzer.cu @@ -63,6 +63,8 @@ bool HeatFluxAnalyzer::run(uint iter, Parameters parameters) this->heatFluxTimeSeries.push_back( q / qIdeal ); if( iter % this->outputIter == 0 ) *logging::out << logging::Logger::INFO_HIGH << "q = " << q / qIdeal << "\n"; + + return true; } ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/src/gpu/GksGpu/Analyzer/TurbulenceAnalyzer.cu b/src/gpu/GksGpu/Analyzer/TurbulenceAnalyzer.cu index d05c47cd2309c6b2804f04dbd0c2214d3be388a3..5e896e03e7f02b63759f4ff6d42ca7f7f5e7bfa5 100644 --- a/src/gpu/GksGpu/Analyzer/TurbulenceAnalyzer.cu +++ b/src/gpu/GksGpu/Analyzer/TurbulenceAnalyzer.cu @@ -51,6 +51,8 @@ bool TurbulenceAnalyzer::run(uint iter, Parameters parameters) getLastCudaError("TurbulenceAnalyzer::run(uint iter, Parameters parameters)"); this->counter++; + + return true; } //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/src/gpu/GksGpu/BoundaryConditions/CreepingMassFlux.cu b/src/gpu/GksGpu/BoundaryConditions/CreepingMassFlux.cu index 2b8b8174fd96d335a82cd80586415fc598576678..fd55918246bd4aebb38f1ed8982d86e776eb7fbb 100644 --- a/src/gpu/GksGpu/BoundaryConditions/CreepingMassFlux.cu +++ b/src/gpu/GksGpu/BoundaryConditions/CreepingMassFlux.cu @@ -91,7 +91,7 @@ __host__ __device__ inline void boundaryConditionFunction(const DataBaseStruct& const uint startIndex, const uint index) { - uint ghostCellIdx = boundaryCondition.ghostCells [ startIndex + index ]; + // uint ghostCellIdx = boundaryCondition.ghostCells [ startIndex + index ]; uint domainCellIdx = boundaryCondition.domainCells[ startIndex + index ]; //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/src/gpu/GksGpu/BoundaryConditions/HeatFlux.cu b/src/gpu/GksGpu/BoundaryConditions/HeatFlux.cu index 3ecd1b6cd52c2210b0e67c48937f1db1b9420f2a..87f880bcf1001a012487f5df327566dfe1ded350 100644 --- a/src/gpu/GksGpu/BoundaryConditions/HeatFlux.cu +++ b/src/gpu/GksGpu/BoundaryConditions/HeatFlux.cu @@ -91,7 +91,7 @@ __host__ __device__ inline void boundaryConditionFunction(const DataBaseStruct& const uint startIndex, const uint index) { - uint ghostCellIdx = boundaryCondition.ghostCells [ startIndex + index ]; + // uint ghostCellIdx = boundaryCondition.ghostCells [ startIndex + index ]; uint domainCellIdx = boundaryCondition.domainCells[ startIndex + index ]; //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/src/gpu/GksGpu/BoundaryConditions/Inflow.cu b/src/gpu/GksGpu/BoundaryConditions/Inflow.cu index 21ab9829309e072fd5049026bfb74d79c4393acb..7f9b2777f5e75a5c79a2ee5f280871a021cf6c94 100644 --- a/src/gpu/GksGpu/BoundaryConditions/Inflow.cu +++ b/src/gpu/GksGpu/BoundaryConditions/Inflow.cu @@ -86,7 +86,7 @@ __host__ __device__ inline void boundaryConditionFunction(const DataBaseStruct& { uint ghostCellIdx = boundaryCondition.ghostCells [ startIndex + index ]; uint domainCellIdx = boundaryCondition.domainCells[ startIndex + index ]; - uint secondCellIdx = boundaryCondition.secondCells[ startIndex + index ]; + // uint secondCellIdx = boundaryCondition.secondCells[ startIndex + index ]; PrimitiveVariables ghostCellPrim; { diff --git a/src/gpu/GksGpu/BoundaryConditions/MassCompensation.cu b/src/gpu/GksGpu/BoundaryConditions/MassCompensation.cu index 4aaf406348754db851e1c45be542f158d7621b36..f6e69742635d594b2f0f1319642c51a5dde78a9e 100644 --- a/src/gpu/GksGpu/BoundaryConditions/MassCompensation.cu +++ b/src/gpu/GksGpu/BoundaryConditions/MassCompensation.cu @@ -91,7 +91,7 @@ __host__ __device__ inline void boundaryConditionFunction(const DataBaseStruct& const uint startIndex, const uint index) { - uint ghostCellIdx = boundaryCondition.ghostCells [ startIndex + index ]; + // uint ghostCellIdx = boundaryCondition.ghostCells [ startIndex + index ]; uint domainCellIdx = boundaryCondition.domainCells[ startIndex + index ]; //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/src/gpu/GksGpu/CMakeLists.txt b/src/gpu/GksGpu/CMakeLists.txt index da404e0209ed2c9f36ae323d2e6bd234fb6dfb96..5dbc533cc5f45c006c29a12242350f0433518bbf 100644 --- a/src/gpu/GksGpu/CMakeLists.txt +++ b/src/gpu/GksGpu/CMakeLists.txt @@ -1,3 +1,10 @@ project(GksGpu LANGUAGES CUDA CXX) -vf_add_library(PRIVATE_LINK basics GksMeshAdapter OpenMP::OpenMP_CXX MPI::MPI_CXX) +vf_add_library(PRIVATE_LINK basics lbmCuda GksMeshAdapter OpenMP::OpenMP_CXX MPI::MPI_CXX) + +target_include_directories(GksGpu PRIVATE "${VF_THIRD_DIR}/cuda_samples/") + +if (NOT MSVC) + target_compile_options(GksGpu PRIVATE "$<$<COMPILE_LANGUAGE:CXX>:-fPIC>") +endif() + diff --git a/src/gpu/GksGpu/CellProperties/CellProperties.cuh b/src/gpu/GksGpu/CellProperties/CellProperties.cuh index 1ce36e85baa70739d9a98abf6cb9d3b9bd1a25f8..08731b9f52cdc54cc41d5e239ac05ee6e88fecd7 100644 --- a/src/gpu/GksGpu/CellProperties/CellProperties.cuh +++ b/src/gpu/GksGpu/CellProperties/CellProperties.cuh @@ -4,9 +4,13 @@ #ifdef __CUDACC__ #include <cuda_runtime.h> #else +#ifndef __host__ #define __host__ +#endif +#ifndef __device__ #define __device__ #endif +#endif ////////////////////////////////////////////////////////////////////////// diff --git a/src/gpu/GksGpu/CellUpdate/Reaction.cuh b/src/gpu/GksGpu/CellUpdate/Reaction.cuh index 4bf317b2704d0111079fcb9888f62026265e6fd0..21ba61220fd7b81fbb53002ea090d278d228bb66 100644 --- a/src/gpu/GksGpu/CellUpdate/Reaction.cuh +++ b/src/gpu/GksGpu/CellUpdate/Reaction.cuh @@ -36,14 +36,14 @@ inline __host__ __device__ real getTurbulentViscosityDeardorff(const DataBaseStr real uHead = c1o2 * prim.U; { - uint neighborCellIndex = dataBase.cellToCell[CELL_TO_CELL(cellIndex, 0, dataBase.numberOfCells)]; + // uint neighborCellIndex = dataBase.cellToCell[CELL_TO_CELL(cellIndex, 0, dataBase.numberOfCells)]; readCellData(cellIndex, dataBase, neighborCons); neighborPrim = toPrimitiveVariables(neighborCons, parameters.K); uHead += c1o4 * neighborPrim.U; } { - uint neighborCellIndex = dataBase.cellToCell[CELL_TO_CELL(cellIndex, 1, dataBase.numberOfCells)]; + // uint neighborCellIndex = dataBase.cellToCell[CELL_TO_CELL(cellIndex, 1, dataBase.numberOfCells)]; readCellData(cellIndex, dataBase, neighborCons); neighborPrim = toPrimitiveVariables(neighborCons, parameters.K); @@ -57,14 +57,14 @@ inline __host__ __device__ real getTurbulentViscosityDeardorff(const DataBaseStr real vHead = c1o2 * prim.V; { - uint neighborCellIndex = dataBase.cellToCell[CELL_TO_CELL(cellIndex, 2, dataBase.numberOfCells)]; + // uint neighborCellIndex = dataBase.cellToCell[CELL_TO_CELL(cellIndex, 2, dataBase.numberOfCells)]; readCellData(cellIndex, dataBase, neighborCons); neighborPrim = toPrimitiveVariables(neighborCons, parameters.K); vHead += c1o4 * neighborPrim.V; } { - uint neighborCellIndex = dataBase.cellToCell[CELL_TO_CELL(cellIndex, 3, dataBase.numberOfCells)]; + // uint neighborCellIndex = dataBase.cellToCell[CELL_TO_CELL(cellIndex, 3, dataBase.numberOfCells)]; readCellData(cellIndex, dataBase, neighborCons); neighborPrim = toPrimitiveVariables(neighborCons, parameters.K); @@ -78,14 +78,14 @@ inline __host__ __device__ real getTurbulentViscosityDeardorff(const DataBaseStr real wHead = c1o2 * prim.W; { - uint neighborCellIndex = dataBase.cellToCell[CELL_TO_CELL(cellIndex, 4, dataBase.numberOfCells)]; + // uint neighborCellIndex = dataBase.cellToCell[CELL_TO_CELL(cellIndex, 4, dataBase.numberOfCells)]; readCellData(cellIndex, dataBase, neighborCons); neighborPrim = toPrimitiveVariables(neighborCons, parameters.K); wHead += c1o4 * neighborPrim.W; } { - uint neighborCellIndex = dataBase.cellToCell[CELL_TO_CELL(cellIndex, 5, dataBase.numberOfCells)]; + // uint neighborCellIndex = dataBase.cellToCell[CELL_TO_CELL(cellIndex, 5, dataBase.numberOfCells)]; readCellData(cellIndex, dataBase, neighborCons); neighborPrim = toPrimitiveVariables(neighborCons, parameters.K); diff --git a/src/gpu/GksGpu/DataBase/DataBase.cpp b/src/gpu/GksGpu/DataBase/DataBase.cpp index 21c51b7575fbb46870b6b0397fe01d954e6458be..46921a683de3dd9c322be2d89b4ca66f6fa07020 100644 --- a/src/gpu/GksGpu/DataBase/DataBase.cpp +++ b/src/gpu/GksGpu/DataBase/DataBase.cpp @@ -14,6 +14,10 @@ #include "GksMeshAdapter/GksMeshAdapter.h" #include "Communication/Communicator.h" +#include <lbm/constants/NumericConstants.h> + +using namespace vf::lbm::constant; + namespace GksGpu { DataBase::DataBase( std::string type ) diff --git a/src/gpu/GksGpu/FlowStateData/AccessDeviceData.cuh b/src/gpu/GksGpu/FlowStateData/AccessDeviceData.cuh index 3ff9848f15d57ab66ed5c8c6178df3afd1d4c581..2ad158173970c5bb36637643f621c729a8fcc37a 100644 --- a/src/gpu/GksGpu/FlowStateData/AccessDeviceData.cuh +++ b/src/gpu/GksGpu/FlowStateData/AccessDeviceData.cuh @@ -4,9 +4,13 @@ #ifdef __CUDACC__ #include <cuda_runtime.h> #else +#ifndef __host__ #define __host__ +#endif +#ifndef __device__ #define __device__ #endif +#endif #include "Core/DataTypes.h" #include "Core/RealConstants.h" diff --git a/src/gpu/GksGpu/FlowStateData/FlowStateData.cuh b/src/gpu/GksGpu/FlowStateData/FlowStateData.cuh index 3ec3a7c9e60cf60d14fec43eaa1d17792148fb15..3b7929b39b47761624fec7052becc55921990276 100644 --- a/src/gpu/GksGpu/FlowStateData/FlowStateData.cuh +++ b/src/gpu/GksGpu/FlowStateData/FlowStateData.cuh @@ -4,15 +4,22 @@ #ifdef __CUDACC__ #include <cuda_runtime.h> #else +#ifndef __host__ #define __host__ +#endif +#ifndef __device__ #define __device__ #endif +#endif #include "Core/DataTypes.h" -#include "Core/RealConstants.h" #include "Definitions/PassiveScalar.h" +#include <lbm/constants/NumericConstants.h> + +using namespace vf::lbm::constant; + namespace GksGpu { ////////////////////////////////////////////////////////////////////////// diff --git a/src/gpu/GksGpu/FlowStateData/FlowStateDataConversion.cuh b/src/gpu/GksGpu/FlowStateData/FlowStateDataConversion.cuh index c33f02ea3f9f4d13050c72b52b471b312a52b1c8..b7b759c99ffec6118a4173af098e0b372caf6ef7 100644 --- a/src/gpu/GksGpu/FlowStateData/FlowStateDataConversion.cuh +++ b/src/gpu/GksGpu/FlowStateData/FlowStateDataConversion.cuh @@ -4,9 +4,13 @@ #ifdef __CUDACC__ #include <cuda_runtime.h> #else +#ifndef __host__ #define __host__ +#endif +#ifndef __device__ #define __device__ #endif +#endif #include "Core/DataTypes.h" #include "Core/RealConstants.h" diff --git a/src/gpu/GksGpu/FlowStateData/HeatCapacities.cuh b/src/gpu/GksGpu/FlowStateData/HeatCapacities.cuh index 3002ed3ddc275ce9dda7499430153b7460e2452f..04a164aa327bed36cca2b8756c87dd1c7d9f0a64 100644 --- a/src/gpu/GksGpu/FlowStateData/HeatCapacities.cuh +++ b/src/gpu/GksGpu/FlowStateData/HeatCapacities.cuh @@ -1,12 +1,16 @@ //#ifndef HeatCapacities_H //#define HeatCapacities_H // -//#ifdef __CUDACC__ -//#include <cuda_runtime.h> -//#else -//#define __host__ -//#define __device__ -//#endif +// #ifdef __CUDACC__ +// #include <cuda_runtime.h> +// #else +// #ifndef __host__ +// #define __host__ +// #endif +// #ifndef __device__ +// #define __device__ +// #endif +// #endif // //#include "Core/DataTypes.h" //#include "Core/RealConstants.h" diff --git a/src/gpu/GksGpu/FlowStateData/ThermalDependencies.cuh b/src/gpu/GksGpu/FlowStateData/ThermalDependencies.cuh index 9f3a268a5d8a7e64d59b0c1b60eeec8d68423174..47eb261a089b9a1c8d7bb14bca864c334887d447 100644 --- a/src/gpu/GksGpu/FlowStateData/ThermalDependencies.cuh +++ b/src/gpu/GksGpu/FlowStateData/ThermalDependencies.cuh @@ -4,9 +4,13 @@ #ifdef __CUDACC__ #include <cuda_runtime.h> #else +#ifndef __host__ #define __host__ +#endif +#ifndef __device__ #define __device__ #endif +#endif #include <math.h> diff --git a/src/gpu/GksGpu/FluxComputation/FluxComputation.cu b/src/gpu/GksGpu/FluxComputation/FluxComputation.cu index 8c935863615eb1c3f117c87b6ba57e92a0061c0f..25ba5726bfd505518bf82b88accea1c3549c5b96 100644 --- a/src/gpu/GksGpu/FluxComputation/FluxComputation.cu +++ b/src/gpu/GksGpu/FluxComputation/FluxComputation.cu @@ -152,7 +152,7 @@ __host__ __device__ inline void fluxFunction(DataBaseStruct dataBase, Parameters { if( parameters.spongeLayerIdx == 0 ) { - real x = dataBase.faceCenter[VEC_X(faceIndex, dataBase.numberOfFaces)]; + // real x = dataBase.faceCenter[VEC_X(faceIndex, dataBase.numberOfFaces)]; real z = dataBase.faceCenter[VEC_Z(faceIndex, dataBase.numberOfFaces)]; real muNew = parameters.mu; @@ -168,7 +168,7 @@ __host__ __device__ inline void fluxFunction(DataBaseStruct dataBase, Parameters } if( parameters.spongeLayerIdx == 1 ) { - real x = dataBase.faceCenter[VEC_X(faceIndex, dataBase.numberOfFaces)]; + // real x = dataBase.faceCenter[VEC_X(faceIndex, dataBase.numberOfFaces)]; real z = dataBase.faceCenter[VEC_Z(faceIndex, dataBase.numberOfFaces)]; real muNew = parameters.mu; diff --git a/src/gpu/GksGpu/Output/VtkWriter.cpp b/src/gpu/GksGpu/Output/VtkWriter.cpp index a1a0ab9f62f275107e790a34c407c83adc09ab2d..234151c7df481e81e5dd68c9a4692831f7271f54 100644 --- a/src/gpu/GksGpu/Output/VtkWriter.cpp +++ b/src/gpu/GksGpu/Output/VtkWriter.cpp @@ -47,6 +47,8 @@ #include "FlowStateData/FlowStateDataConversion.cuh" #include "FlowStateData/AccessDeviceData.cuh" +namespace GksGpu { + void VtkWriter::write(std::shared_ptr<DataBase> dataBase, Parameters parameters, std::string filename) { *logging::out << logging::Logger::INFO_INTERMEDIATE << "Write " << filename << ".vtu" << " ... \n"; @@ -144,3 +146,5 @@ void VtkWriter::write(std::shared_ptr<DataBase> dataBase, Parameters parameters, *logging::out << logging::Logger::INFO_INTERMEDIATE << "done!\n"; } + +} diff --git a/src/gpu/GksGpu/Output/VtkWriter.h b/src/gpu/GksGpu/Output/VtkWriter.h index 0596fc7bd164050236b8db54a31ab7689a84d01f..679fae55b2db5ec418b389ca0840961ab8f80dde 100644 --- a/src/gpu/GksGpu/Output/VtkWriter.h +++ b/src/gpu/GksGpu/Output/VtkWriter.h @@ -38,9 +38,12 @@ #include "GksGpu_export.h" +namespace GksGpu { + struct DataBase; struct Parameters; + class GKSGPU_EXPORT VtkWriter { public: @@ -49,4 +52,6 @@ public: std::string filename ); }; +} + #endif \ No newline at end of file diff --git a/src/gpu/GksMeshAdapter/CMakeLists.txt b/src/gpu/GksMeshAdapter/CMakeLists.txt index cb00b3c016786c41ef5640eb362322bb0a3768f8..b9a2d12df4d0bee9396a706c6636b5f4056b2d3a 100644 --- a/src/gpu/GksMeshAdapter/CMakeLists.txt +++ b/src/gpu/GksMeshAdapter/CMakeLists.txt @@ -1,3 +1,3 @@ project(GksMeshAdapter LANGUAGES CUDA CXX) -vf_add_library(PRIVATE_LINK basics GridGenerator) +vf_add_library(PRIVATE_LINK basics GridGenerator lbmCuda) diff --git a/src/gpu/GksMeshAdapter/GksMeshAdapter.cpp b/src/gpu/GksMeshAdapter/GksMeshAdapter.cpp index 16f5c208565ff090cd2344348d5e47150babe84e..8d032dfeead2f582c5af2426c45b09ead33883cc 100644 --- a/src/gpu/GksMeshAdapter/GksMeshAdapter.cpp +++ b/src/gpu/GksMeshAdapter/GksMeshAdapter.cpp @@ -22,6 +22,10 @@ #include "MeshCell.h" #include "MeshFace.h" +#include <lbm/constants/NumericConstants.h> + +using namespace vf::lbm::constant; + using namespace vf::gpu; GksMeshAdapter::GksMeshAdapter(SPtr<MultipleGridBuilder> gridBuilder) @@ -518,7 +522,7 @@ void GksMeshAdapter::sortFaces() // sort into blocks //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - std::array<char, 3> orientations = {'x', 'y', 'z'}; + // std::array<char, 3> orientations = {'x', 'y', 'z'}; for( uint level = 0; level < this->gridBuilder->getNumberOfLevels(); level++ ) { @@ -527,17 +531,17 @@ void GksMeshAdapter::sortFaces() uint start = this->startOfFacesPerLevelXYZ [ 3 * level + idx]; uint end = start + this->numberOfFacesPerLevelXYZ[ 3 * level + idx]; - real xMax = (*std::max_element(this->faces.begin() + start, this->faces.begin() + end, [this](MeshFace lhs, MeshFace rhs) { return lhs.faceCenter.x < rhs.faceCenter.x; })).faceCenter.x; - real yMax = (*std::max_element(this->faces.begin() + start, this->faces.begin() + end, [this](MeshFace lhs, MeshFace rhs) { return lhs.faceCenter.y < rhs.faceCenter.y; })).faceCenter.y; - real zMax = (*std::max_element(this->faces.begin() + start, this->faces.begin() + end, [this](MeshFace lhs, MeshFace rhs) { return lhs.faceCenter.z < rhs.faceCenter.z; })).faceCenter.z; + // real xMax = (*std::max_element(this->faces.begin() + start, this->faces.begin() + end, [this](MeshFace lhs, MeshFace rhs) { return lhs.faceCenter.x < rhs.faceCenter.x; })).faceCenter.x; + // real yMax = (*std::max_element(this->faces.begin() + start, this->faces.begin() + end, [this](MeshFace lhs, MeshFace rhs) { return lhs.faceCenter.y < rhs.faceCenter.y; })).faceCenter.y; + // real zMax = (*std::max_element(this->faces.begin() + start, this->faces.begin() + end, [this](MeshFace lhs, MeshFace rhs) { return lhs.faceCenter.z < rhs.faceCenter.z; })).faceCenter.z; real xMin = (*std::min_element(this->faces.begin() + start, this->faces.begin() + end, [this](MeshFace lhs, MeshFace rhs) { return lhs.faceCenter.x < rhs.faceCenter.x; })).faceCenter.x; real yMin = (*std::min_element(this->faces.begin() + start, this->faces.begin() + end, [this](MeshFace lhs, MeshFace rhs) { return lhs.faceCenter.y < rhs.faceCenter.y; })).faceCenter.y; real zMin = (*std::min_element(this->faces.begin() + start, this->faces.begin() + end, [this](MeshFace lhs, MeshFace rhs) { return lhs.faceCenter.z < rhs.faceCenter.z; })).faceCenter.z; - real xRange = xMax - xMin; - real yRange = yMax - yMin; - real zRange = zMax - zMin; + // real xRange = xMax - xMin; + // real yRange = yMax - yMin; + // real zRange = zMax - zMin; uint blockDim = 8; diff --git a/src/gpu/GksVtkAdapter/CMakeLists.txt b/src/gpu/GksVtkAdapter/CMakeLists.txt index 644dc6defa101644338fc35211efa7eccabca3b0..fdc7a1eb56f548afc58e83ef7b0f7ad02ad12ea9 100644 --- a/src/gpu/GksVtkAdapter/CMakeLists.txt +++ b/src/gpu/GksVtkAdapter/CMakeLists.txt @@ -1,5 +1,5 @@ -vf_add_library(BUILDTYPE shared PRIVATE_LINK basics GksGpu) +vf_add_library(BUILDTYPE static PRIVATE_LINK basics GksGpu) include (${VF_CMAKE_DIR}/3rd/vtk.cmake) \ No newline at end of file diff --git a/src/gpu/GridGenerator/CMakeLists.txt b/src/gpu/GridGenerator/CMakeLists.txt index 844e933d5c053aaeef38085c5c5a9e01721ff6aa..07b6125d6ecd83dca59e20e7c286ebc2b8d14715 100644 --- a/src/gpu/GridGenerator/CMakeLists.txt +++ b/src/gpu/GridGenerator/CMakeLists.txt @@ -1,10 +1,7 @@ -project(GridGenerator LANGUAGES CUDA CXX) - +project(GridGenerator LANGUAGES CXX) vf_add_library(PRIVATE_LINK basics OpenMP::OpenMP_CXX) -vf_get_library_name(library_name) -set_target_properties(${library_name} PROPERTIES CUDA_SEPARABLE_COMPILATION ON) - -# we want to suppress all cuda warnings so far for this library. -target_compile_options(${library_name} PUBLIC $<$<COMPILE_LANGUAGE:CUDA>:-Xcudafe "-w" >) +if(NOT MSVC) + target_compile_options(GridGenerator PRIVATE "-Wno-strict-aliasing") +endif() \ No newline at end of file diff --git a/src/gpu/GridGenerator/StreetPointFinder/JunctionReader.cpp b/src/gpu/GridGenerator/StreetPointFinder/JunctionReader.cpp index 065d4ae646674992889d528a347b8172df98aec6..bac17264d1c00389bbefacc4063d7801e8f5baa7 100644 --- a/src/gpu/GridGenerator/StreetPointFinder/JunctionReader.cpp +++ b/src/gpu/GridGenerator/StreetPointFinder/JunctionReader.cpp @@ -1,3 +1,35 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids 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. +// +// VirtualFluids 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 VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file JunctionReader.cpp +//! \ingroup StreetPointFinder +//! \author Stephan Lenz +//======================================================================================= #include "JunctionReader.h" #include <fstream> diff --git a/src/gpu/GridGenerator/StreetPointFinder/JunctionReader.h b/src/gpu/GridGenerator/StreetPointFinder/JunctionReader.h index dea2a6a91028bbde0aab876e871e12dbbdac40d9..5b68b0357ea2432dfde6d167b27908fe1aa4348a 100644 --- a/src/gpu/GridGenerator/StreetPointFinder/JunctionReader.h +++ b/src/gpu/GridGenerator/StreetPointFinder/JunctionReader.h @@ -1,3 +1,35 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids 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. +// +// VirtualFluids 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 VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file JunctionReader.h +//! \ingroup StreetPointFinder +//! \author Stephan Lenz +//======================================================================================= #ifndef JUNCTIONREADER_H #define JUNCTIONREADER_H diff --git a/src/gpu/GridGenerator/StreetPointFinder/SinkReader.cpp b/src/gpu/GridGenerator/StreetPointFinder/SinkReader.cpp index 3c3e766898dd001c92206f945066b180ed2c19ad..1224f1bf7cad8e535e842426406aacc619dad314 100644 --- a/src/gpu/GridGenerator/StreetPointFinder/SinkReader.cpp +++ b/src/gpu/GridGenerator/StreetPointFinder/SinkReader.cpp @@ -1,3 +1,35 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids 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. +// +// VirtualFluids 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 VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file SinkReader.cpp +//! \ingroup StreetPointFinder +//! \author Stephan Lenz +//======================================================================================= #include "SinkReader.h" #include <fstream> diff --git a/src/gpu/GridGenerator/StreetPointFinder/SinkReader.h b/src/gpu/GridGenerator/StreetPointFinder/SinkReader.h index 115aea55257f8a2086098699e3d8fc24a8a1d1b5..ba28596b0eb63954eb5f7162c4849f863e15f657 100644 --- a/src/gpu/GridGenerator/StreetPointFinder/SinkReader.h +++ b/src/gpu/GridGenerator/StreetPointFinder/SinkReader.h @@ -1,3 +1,35 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids 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. +// +// VirtualFluids 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 VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file SinkReader.h +//! \ingroup StreetPointFinder +//! \author Stephan Lenz +//======================================================================================= #ifndef SINKREADER_H #define SINKREADER_H diff --git a/src/gpu/GridGenerator/StreetPointFinder/SourceReader.cpp b/src/gpu/GridGenerator/StreetPointFinder/SourceReader.cpp index e9cab08476f10a0f61860225b4d9771ef3166638..a3a62f942f96fa1faf9e49448ed3ae627d985273 100644 --- a/src/gpu/GridGenerator/StreetPointFinder/SourceReader.cpp +++ b/src/gpu/GridGenerator/StreetPointFinder/SourceReader.cpp @@ -1,3 +1,35 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids 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. +// +// VirtualFluids 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 VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file SourceReader.cpp +//! \ingroup StreetPointFinder +//! \author Stephan Lenz +//======================================================================================= #include "SourceReader.h" #include <fstream> diff --git a/src/gpu/GridGenerator/StreetPointFinder/SourceReader.h b/src/gpu/GridGenerator/StreetPointFinder/SourceReader.h index db95259ea91a60fc2c9ef1721272a4915374e646..f79c618d06ff9f72738c7b69767a8dd3c5443fac 100644 --- a/src/gpu/GridGenerator/StreetPointFinder/SourceReader.h +++ b/src/gpu/GridGenerator/StreetPointFinder/SourceReader.h @@ -1,3 +1,35 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids 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. +// +// VirtualFluids 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 VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file SourceReader.h +//! \ingroup StreetPointFinder +//! \author Stephan Lenz +//======================================================================================= #ifndef SOURCEREADER_H #define SOURCEREADER_H diff --git a/src/gpu/GridGenerator/StreetPointFinder/StreetPointFinder.cpp b/src/gpu/GridGenerator/StreetPointFinder/StreetPointFinder.cpp index 3a764dd353824df4dcd07aee2557ccc031648b6f..9fbd3933a5457e96d2d1aa01f1fadcf675be1980 100644 --- a/src/gpu/GridGenerator/StreetPointFinder/StreetPointFinder.cpp +++ b/src/gpu/GridGenerator/StreetPointFinder/StreetPointFinder.cpp @@ -1,3 +1,35 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids 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. +// +// VirtualFluids 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 VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file StreetPointFinder.cpp +//! \ingroup StreetPointFinder +//! \author Stephan Lenz +//======================================================================================= #include "StreetPointFinder.h" #include "Core/Logger/Logger.h" diff --git a/src/gpu/GridGenerator/StreetPointFinder/StreetPointFinder.h b/src/gpu/GridGenerator/StreetPointFinder/StreetPointFinder.h index 73d1e0de07c34188d879323a3a762a82f2ed4543..feb3618f64b0a6f757930772594878a6ca7c0144 100644 --- a/src/gpu/GridGenerator/StreetPointFinder/StreetPointFinder.h +++ b/src/gpu/GridGenerator/StreetPointFinder/StreetPointFinder.h @@ -1,3 +1,35 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids 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. +// +// VirtualFluids 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 VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file StreetPointFinder.h +//! \ingroup StreetPointFinder +//! \author Stephan Lenz +//======================================================================================= #ifndef StreetPointFinder_H #define StreetPointFinder_H diff --git a/src/gpu/GridGenerator/geometries/Arrow/Arrow.h b/src/gpu/GridGenerator/geometries/Arrow/Arrow.h index dfd006042c63a35236e0fab886a527a86fa84896..945f1e3a8af7bd14fb9c3a8d5d9d26ab7405a7b7 100644 --- a/src/gpu/GridGenerator/geometries/Arrow/Arrow.h +++ b/src/gpu/GridGenerator/geometries/Arrow/Arrow.h @@ -1,3 +1,35 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids 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. +// +// VirtualFluids 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 VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file Arrow.h +//! \ingroup geometries +//! \author Soeren Peters, Stephan Lenz +//======================================================================================= #ifndef Arrow_H #define Arrow_H diff --git a/src/gpu/GridGenerator/geometries/Arrow/ArrowImp.cpp b/src/gpu/GridGenerator/geometries/Arrow/ArrowImp.cpp index 28176b4f5657a2e5907fd1d308af7aba13330220..f7ee7330c6c57f076fd4f45c8bf7a3f0749df6a1 100644 --- a/src/gpu/GridGenerator/geometries/Arrow/ArrowImp.cpp +++ b/src/gpu/GridGenerator/geometries/Arrow/ArrowImp.cpp @@ -1,3 +1,35 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids 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. +// +// VirtualFluids 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 VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file ArrowImp.cpp +//! \ingroup geometries +//! \author Soeren Peters, Stephan Lenz +//======================================================================================= #include "ArrowImp.h" #include "../Vertex/Vertex.h" diff --git a/src/gpu/GridGenerator/geometries/Arrow/ArrowImp.h b/src/gpu/GridGenerator/geometries/Arrow/ArrowImp.h index 195223d9125c265905b6c47ee8dc09edb205f267..1fb509e0c6092dd3f00d4abf1849014191425db2 100644 --- a/src/gpu/GridGenerator/geometries/Arrow/ArrowImp.h +++ b/src/gpu/GridGenerator/geometries/Arrow/ArrowImp.h @@ -1,10 +1,41 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids 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. +// +// VirtualFluids 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 VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file ArrowImp.h +//! \ingroup geometries +//! \author Soeren Peters, Stephan Lenz +//======================================================================================= #ifndef ArrowImp_H #define ArrowImp_H #include <memory> #include "global.h" -#include "GridGenerator_export.h" #include "Arrow.h" diff --git a/src/gpu/GridGenerator/geometries/BoundingBox/BoundingBox.cu b/src/gpu/GridGenerator/geometries/BoundingBox/BoundingBox.cpp similarity index 65% rename from src/gpu/GridGenerator/geometries/BoundingBox/BoundingBox.cu rename to src/gpu/GridGenerator/geometries/BoundingBox/BoundingBox.cpp index 75ae002813541bfdb73b0f3dcc179270c31fa5df..1532e57e8cc4b0db93ed79c03074d7845ff9c87f 100644 --- a/src/gpu/GridGenerator/geometries/BoundingBox/BoundingBox.cu +++ b/src/gpu/GridGenerator/geometries/BoundingBox/BoundingBox.cpp @@ -1,3 +1,35 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids 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. +// +// VirtualFluids 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 VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file BoundingBox.cpp +//! \ingroup geometries +//! \author Soeren Peters, Stephan Lenz +//======================================================================================= #include "BoundingBox.h" #include "../Triangle/Triangle.h" @@ -10,18 +42,7 @@ BoundingBox::BoundingBox(real minX, real maxX, real minY, real maxY, real minZ, real maxZ) : minX(minX), maxX(maxX), minY(minY), maxY(maxY), minZ(minZ), maxZ(maxZ) {} - HOSTDEVICE BoundingBox::BoundingBox() : - minX(0), - maxX(0), - minY(0), - maxY(0), - minZ(0), - maxZ(0) {} - - BoundingBox::BoundingBox(const BoundingBox &t) : minX(t.minX), maxX(t.maxX), minY(t.minY), maxY(t.maxY), minZ(t.minZ), maxZ(t.maxZ) {} - - - CUDA_HOST BoundingBox BoundingBox::makeInvalidMinMaxBox() + BoundingBox BoundingBox::makeInvalidMinMaxBox() { BoundingBox box = BoundingBox(std::numeric_limits<real>::max(), std::numeric_limits<real>::lowest(), @@ -32,11 +53,11 @@ return box; } - void BoundingBox::setMinMax(const Triangle& t) + void BoundingBox::setMinMax(const Triangle &t) { real minX, maxX, minY, maxY, minZ, maxZ; t.setMinMax(minX, maxX, minY, maxY, minZ, maxZ); - if(minX < this->minX) + if (minX < this->minX) this->minX = minX; if (minY < this->minY) this->minY = minY; @@ -51,20 +72,18 @@ this->maxZ = maxZ; } - bool BoundingBox::intersect(const Triangle &t) const { - if (isInside(t.v1) || isInside(t.v2) || isInside(t.v3)) - return true; - return false; + if (isInside(t.v1) || isInside(t.v2) || isInside(t.v3)) + return true; + return false; } - bool BoundingBox::isInside(const Triangle &t) const { - if (isInside(t.v1) && isInside(t.v2) && isInside(t.v3)) - return true; - return false; + if (isInside(t.v1) && isInside(t.v2) && isInside(t.v3)) + return true; + return false; } bool BoundingBox::isInside(const real x, const real y, const real z) const @@ -157,7 +176,7 @@ } - CUDA_HOST bool BoundingBox::operator==(const BoundingBox &box) const + bool BoundingBox::operator==(const BoundingBox &box) const { return vf::Math::equal(minX, box.minX) && vf::Math::equal(maxX, box.maxX) diff --git a/src/gpu/GridGenerator/geometries/BoundingBox/BoundingBox.h b/src/gpu/GridGenerator/geometries/BoundingBox/BoundingBox.h index e1d4f24e450400154498f716bd1fa4042be795f6..2a495d3a4b7a4854079b62ba979baaea0d7db5f0 100644 --- a/src/gpu/GridGenerator/geometries/BoundingBox/BoundingBox.h +++ b/src/gpu/GridGenerator/geometries/BoundingBox/BoundingBox.h @@ -1,9 +1,40 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids 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. +// +// VirtualFluids 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 VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file BoundingBox.h +//! \ingroup geometries +//! \author Soeren Peters, Stephan Lenz +//======================================================================================= #ifndef BoundingBox_h #define BoundingBox_h #include <vector> -#include <cuda_runtime.h> -#include "GridGenerator_export.h" + #include "global.h" struct Vertex; @@ -21,23 +52,22 @@ public: real maxZ; BoundingBox(real minX, real maxX, real minY, real maxY, real minZ, real maxZ); - HOSTDEVICE BoundingBox(); - BoundingBox(const BoundingBox &t); + BoundingBox() = default; public: - CUDA_HOST static BoundingBox makeInvalidMinMaxBox(); + static BoundingBox makeInvalidMinMaxBox(); - void setMinMax(const Triangle& t); - void print() const; + void setMinMax(const Triangle &t); + void print() const; bool isInside(const Triangle &t) const; - bool isInside(const real x, const real y, const real z) const; - bool intersect(const Triangle &t) const; + bool isInside(const real x, const real y, const real z) const; + bool intersect(const Triangle &t) const; std::vector<std::vector<Vertex> > getIntersectionPoints(const BoundingBox &b) const; bool intersect(const BoundingBox &box) const; - CUDA_HOST bool operator==(const BoundingBox &box) const; + bool operator==(const BoundingBox &box) const; void extend(real delta); diff --git a/src/gpu/GridGenerator/geometries/Conglomerate/Conglomerate.cu b/src/gpu/GridGenerator/geometries/Conglomerate/Conglomerate.cpp similarity index 67% rename from src/gpu/GridGenerator/geometries/Conglomerate/Conglomerate.cu rename to src/gpu/GridGenerator/geometries/Conglomerate/Conglomerate.cpp index b87eba98c1ed10b6be0f70abf2093ff00f132050..331b928c6f5542584cffdcc1b17df7207981b8f8 100644 --- a/src/gpu/GridGenerator/geometries/Conglomerate/Conglomerate.cu +++ b/src/gpu/GridGenerator/geometries/Conglomerate/Conglomerate.cpp @@ -1,3 +1,35 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids 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. +// +// VirtualFluids 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 VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file Conglomerate.cpp +//! \ingroup geometries +//! \author Soeren Peters, Stephan Lenz +//======================================================================================= #include "Conglomerate.h" Conglomerate::Conglomerate() diff --git a/src/gpu/GridGenerator/geometries/Conglomerate/Conglomerate.h b/src/gpu/GridGenerator/geometries/Conglomerate/Conglomerate.h index cca1a85f5110514d560481e25cc55068569a3107..8cb26137d6ab4e4c52bed34aa1d044121ac4bf3d 100644 --- a/src/gpu/GridGenerator/geometries/Conglomerate/Conglomerate.h +++ b/src/gpu/GridGenerator/geometries/Conglomerate/Conglomerate.h @@ -1,9 +1,35 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ // +// This file is part of VirtualFluids. VirtualFluids 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. +// +// VirtualFluids 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 VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file Conglomerate.h +//! \ingroup geometries +//! \author Soeren Peters, Stephan Lenz +//======================================================================================= #ifndef CONGLOMERATE_H #define CONGLOMERATE_H @@ -16,16 +42,16 @@ class GRIDGENERATOR_EXPORT Conglomerate : public Object { public: - HOSTDEVICE Conglomerate(); - HOSTDEVICE virtual ~Conglomerate(); + Conglomerate(); + virtual ~Conglomerate(); - CUDA_HOST static SPtr<Conglomerate> makeShared(); + static SPtr<Conglomerate> makeShared(); - HOSTDEVICE void add(Object* object); - HOSTDEVICE void subtract(Object* objectStub); + void add(Object* object); + void subtract(Object* objectStub); - HOSTDEVICE Object* clone() const override; + Object* clone() const override; double getX1Centroid() override; double getX1Minimum() override; @@ -39,9 +65,9 @@ public: void scale(double delta) override; - HOSTDEVICE bool isPointInObject(const double& x1, const double& x2, const double& x3, const double& minOffset, const double& maxOffset) override; + bool isPointInObject(const double& x1, const double& x2, const double& x3, const double& minOffset, const double& maxOffset) override; - CUDA_HOST void findInnerNodes(SPtr<GridImp> grid) override; + void findInnerNodes(SPtr<GridImp> grid) override; protected: static double getMinimum(double val1, double val2); diff --git a/src/gpu/GridGenerator/geometries/Cuboid/Cuboid.cpp b/src/gpu/GridGenerator/geometries/Cuboid/Cuboid.cpp new file mode 100644 index 0000000000000000000000000000000000000000..7b0dbcdbdcbd679f1eb47ed5db7d828da8c31767 --- /dev/null +++ b/src/gpu/GridGenerator/geometries/Cuboid/Cuboid.cpp @@ -0,0 +1,147 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids 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. +// +// VirtualFluids 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 VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file Cuboid.cpp +//! \ingroup geometries +//! \author Soeren Peters, Stephan Lenz +//======================================================================================= +#include "Cuboid.h" + +#include "utilities/math/Math.h" + +Cuboid::Cuboid(const double& x1a,const double& x2a, const double& x3a, const double& x1b,const double& x2b, const double& x3b) + : minX1(x1a), minX2(x2a), minX3(x3a), maxX1(x1b), maxX2(x2b), maxX3(x3b) +{ + +} + +Cuboid::~Cuboid() +{ + +} + +Object* Cuboid::clone() const +{ + return new Cuboid(minX1, minX2, minX3, maxX1, maxX2, maxX3); +} + +double Cuboid::getX1Centroid() +{ + return getCenter(minX1, maxX1); +} + +double Cuboid::getX1Minimum() +{ + return getMinimum(minX1, maxX1); +} + +double Cuboid::getX1Maximum() +{ + return getMaximum(minX1, maxX1); +} + +double Cuboid::getX2Centroid() +{ + return getCenter(minX2, maxX2); +} + +double Cuboid::getX2Minimum() +{ + return getMinimum(minX2, maxX2); +} + +double Cuboid::getX2Maximum() +{ + return getMaximum(minX2, maxX2); +} + +double Cuboid::getX3Centroid() +{ + return getCenter(minX3, maxX3); +} + +double Cuboid::getX3Minimum() +{ + return getMinimum(minX3, maxX3); +} + +double Cuboid::getX3Maximum() +{ + return getMaximum(minX3, maxX3); +} + +double Cuboid::getCenter(double x1, double x2) +{ + return 0.5 * (x1 + x2); +} + +double Cuboid::getMinimum(double x1, double x2) +{ + return (x1 < x2 ? x1 : x2); +} + +double Cuboid::getMaximum(double x1, double x2) +{ + return (x1 > x2 ? x1 : x2); +} + +bool Cuboid::isPointInObject(const double& x1, const double& x2, const double& x3, const double& minOffset, const double& maxOffset) +{ + //false, if 'not in Object' or 'on Boundary'! + if (vf::Math::lessEqual( (real)x1, (real)this->getX1Minimum() + (real)minOffset)) return false; + if (vf::Math::lessEqual( (real)x2, (real)this->getX2Minimum() + (real)minOffset)) return false; + if (vf::Math::lessEqual( (real)x3, (real)this->getX3Minimum() + (real)minOffset)) return false; + if (vf::Math::greaterEqual((real)x1, (real)this->getX1Maximum() - (real)maxOffset)) return false; + if (vf::Math::greaterEqual((real)x2, (real)this->getX2Maximum() - (real)maxOffset)) return false; + if (vf::Math::greaterEqual((real)x3, (real)this->getX3Maximum() - (real)maxOffset)) return false; + + return true; +} + + +bool Cuboid::isOn(const real& coord, const real& plane1, const real& plane2) +{ + return vf::Math::equal(coord, plane1) || vf::Math::equal(coord, plane2); +} + +bool Cuboid::isBetween(const real& coord, const real& start, const real& end) +{ + return vf::Math::greaterEqual(coord, start) && vf::Math::lessEqual(coord, end); +} + + +void Cuboid::scale(double delta) +{ + this->minX1 -= delta; + this->minX2 -= delta; + this->minX3 -= delta; + + this->maxX1 += delta; + this->maxX2 += delta; + this->maxX3 += delta; +} diff --git a/src/gpu/GridGenerator/geometries/Cuboid/Cuboid.cu b/src/gpu/GridGenerator/geometries/Cuboid/Cuboid.cu deleted file mode 100644 index af7cb42c2ec428341145e22d6b58384ae152c5a1..0000000000000000000000000000000000000000 --- a/src/gpu/GridGenerator/geometries/Cuboid/Cuboid.cu +++ /dev/null @@ -1,115 +0,0 @@ -#include "Cuboid.h" - -#include "utilities/math/Math.h" - -Cuboid::Cuboid(const double& x1a,const double& x2a, const double& x3a, const double& x1b,const double& x2b, const double& x3b) - : minX1(x1a), minX2(x2a), minX3(x3a), maxX1(x1b), maxX2(x2b), maxX3(x3b) -{ - -} - -Cuboid::~Cuboid() -{ - -} - -Object* Cuboid::clone() const -{ - return new Cuboid(minX1, minX2, minX3, maxX1, maxX2, maxX3); -} - -double Cuboid::getX1Centroid() -{ - return getCenter(minX1, maxX1); -} - -double Cuboid::getX1Minimum() -{ - return getMinimum(minX1, maxX1); -} - -double Cuboid::getX1Maximum() -{ - return getMaximum(minX1, maxX1); -} - -double Cuboid::getX2Centroid() -{ - return getCenter(minX2, maxX2); -} - -double Cuboid::getX2Minimum() -{ - return getMinimum(minX2, maxX2); -} - -double Cuboid::getX2Maximum() -{ - return getMaximum(minX2, maxX2); -} - -double Cuboid::getX3Centroid() -{ - return getCenter(minX3, maxX3); -} - -double Cuboid::getX3Minimum() -{ - return getMinimum(minX3, maxX3); -} - -double Cuboid::getX3Maximum() -{ - return getMaximum(minX3, maxX3); -} - -double Cuboid::getCenter(double x1, double x2) -{ - return 0.5 * (x1 + x2); -} - -double Cuboid::getMinimum(double x1, double x2) -{ - return (x1 < x2 ? x1 : x2); -} - -double Cuboid::getMaximum(double x1, double x2) -{ - return (x1 > x2 ? x1 : x2); -} - -bool Cuboid::isPointInObject(const double& x1, const double& x2, const double& x3, const double& minOffset, const double& maxOffset) -{ - //false, if 'not in Object' or 'on Boundary'! - if (vf::Math::lessEqual(x1, this->getX1Minimum() + minOffset)) return false; - if (vf::Math::lessEqual(x2, this->getX2Minimum() + minOffset)) return false; - if (vf::Math::lessEqual(x3, this->getX3Minimum() + minOffset)) return false; - if (vf::Math::greaterEqual(x1, this->getX1Maximum() - maxOffset)) return false; - if (vf::Math::greaterEqual(x2, this->getX2Maximum() - maxOffset)) return false; - if (vf::Math::greaterEqual(x3, this->getX3Maximum() - maxOffset)) return false; - - return true; -} - - -bool Cuboid::isOn(const real& coord, const real& plane1, const real& plane2) -{ - return vf::Math::equal(coord, plane1) || vf::Math::equal(coord, plane2); -} - -bool Cuboid::isBetween(const real& coord, const real& start, const real& end) -{ - return vf::Math::greaterEqual(coord, start) && vf::Math::lessEqual(coord, end); -} - - -void Cuboid::scale(double delta) -{ - this->minX1 -= delta; - this->minX2 -= delta; - this->minX3 -= delta; - - this->maxX1 += delta; - this->maxX2 += delta; - this->maxX3 += delta; -} diff --git a/src/gpu/GridGenerator/geometries/Cuboid/Cuboid.h b/src/gpu/GridGenerator/geometries/Cuboid/Cuboid.h index 46202f07b77f997ce25068cf55b3515c28bd9636..0351bd3ed847f9702e3c64bce4dcef514804e23a 100644 --- a/src/gpu/GridGenerator/geometries/Cuboid/Cuboid.h +++ b/src/gpu/GridGenerator/geometries/Cuboid/Cuboid.h @@ -1,24 +1,49 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ // +// This file is part of VirtualFluids. VirtualFluids 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. +// +// VirtualFluids 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 VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file Cuboid.h +//! \ingroup geometries +//! \author Soeren Peters, Stephan Lenz +//======================================================================================= #ifndef CUBOID_H #define CUBOID_H #include "global.h" -#include "GridGenerator_export.h" #include "geometries/Object.h" class GRIDGENERATOR_EXPORT Cuboid : public Object { public: - HOSTDEVICE Cuboid(const double& minX1, const double& minX2, const double& minX3, const double& maxX1,const double& maxX2, const double& maxX3); - HOSTDEVICE virtual ~Cuboid(); + Cuboid(const double& minX1, const double& minX2, const double& minX3, const double& maxX1,const double& maxX2, const double& maxX3); + virtual ~Cuboid(); - HOSTDEVICE Object* clone() const override; + Object* clone() const override; double getX1Centroid() override; double getX1Minimum() override; @@ -32,7 +57,7 @@ public: void scale(double delta) override; - HOSTDEVICE bool isPointInObject(const double& x1, const double& x2, const double& x3, const double& minOffset, const double& maxOffset) override; + bool isPointInObject(const double& x1, const double& x2, const double& x3, const double& minOffset, const double& maxOffset) override; private: static double getCenter(double x1, double x2); diff --git a/src/gpu/GridGenerator/geometries/Object.cpp b/src/gpu/GridGenerator/geometries/Object.cpp new file mode 100644 index 0000000000000000000000000000000000000000..c162b3b1db8654f36a0fe6f3c20f79b34a157338 --- /dev/null +++ b/src/gpu/GridGenerator/geometries/Object.cpp @@ -0,0 +1,44 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids 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. +// +// VirtualFluids 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 VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file Object.cpp +//! \ingroup geometries +//! \author Soeren Peters, Stephan Lenz +//======================================================================================= +#include "Object.h" +#include "grid/GridImp.h" + +void Object::findInnerNodes(SPtr<GridImp> grid) +{ + grid->findInnerNodes(); +} + +int Object::getIntersection(const Vertex &P, const Vertex &direction, Vertex &pointOnObject, real &qVal) +{ + return 1; +} diff --git a/src/gpu/GridGenerator/geometries/Object.cu b/src/gpu/GridGenerator/geometries/Object.cu deleted file mode 100644 index a5167f7fb14970d520b7ebe4b92d4ae9a3dcc94b..0000000000000000000000000000000000000000 --- a/src/gpu/GridGenerator/geometries/Object.cu +++ /dev/null @@ -1,13 +0,0 @@ -#include "Object.h" -#include "grid/GridImp.h" -#include "grid/GridStrategy/GridStrategy.h" - -void Object::findInnerNodes(SPtr<GridImp> grid) -{ - grid->getGridStrategy()->findInnerNodes( grid ); -} - -CUDA_HOST int Object::getIntersection(const Vertex & P, const Vertex & direction, Vertex & pointOnObject, real & qVal) -{ - return 1; -} diff --git a/src/gpu/GridGenerator/geometries/Object.h b/src/gpu/GridGenerator/geometries/Object.h index e26ff324f27cf68a3d86afb35720af7c32671688..b92cca7992dcb06c1f230da8d8c9ce46bb7a3416 100644 --- a/src/gpu/GridGenerator/geometries/Object.h +++ b/src/gpu/GridGenerator/geometries/Object.h @@ -1,12 +1,38 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ // +// This file is part of VirtualFluids. VirtualFluids 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. +// +// VirtualFluids 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 VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file Object.h +//! \ingroup geometries +//! \author Soeren Peters, Stephan Lenz +//======================================================================================= #ifndef OBJECT_H #define OBJECT_H -#include "GridGenerator_export.h" + #include "grid/Cell.h" #include "global.h" @@ -17,8 +43,8 @@ struct Vertex; class GRIDGENERATOR_EXPORT Object { public: - HOSTDEVICE virtual ~Object() {} - HOSTDEVICE virtual Object* clone() const = 0; + virtual ~Object() {} + virtual Object* clone() const = 0; virtual double getX1Centroid() = 0; virtual double getX1Minimum() = 0; @@ -36,9 +62,9 @@ public: virtual void scale(double delta) = 0; - HOSTDEVICE virtual bool isPointInObject(const double& x1, const double& x2, const double& x3, const double& minOffset, const double& maxOffset) = 0; + virtual bool isPointInObject(const double& x1, const double& x2, const double& x3, const double& minOffset, const double& maxOffset) = 0; - HOSTDEVICE virtual bool isCellInObject(const Cell& cell) { + virtual bool isCellInObject(const Cell& cell) { for (const auto point : cell) { const bool isInObject = isPointInObject(point.x, point.y, point.z, 0.0, 0.0); @@ -48,9 +74,9 @@ public: return true; } - CUDA_HOST virtual void findInnerNodes(SPtr<GridImp> grid); + virtual void findInnerNodes(SPtr<GridImp> grid); - CUDA_HOST virtual int getIntersection(const Vertex &P, const Vertex &direction, Vertex &pointOnObject, real &qVal); + virtual int getIntersection(const Vertex &P, const Vertex &direction, Vertex &pointOnObject, real &qVal); }; diff --git a/src/gpu/GridGenerator/geometries/Sphere/Sphere.cu b/src/gpu/GridGenerator/geometries/Sphere/Sphere.cpp similarity index 57% rename from src/gpu/GridGenerator/geometries/Sphere/Sphere.cu rename to src/gpu/GridGenerator/geometries/Sphere/Sphere.cpp index 1b316ae74384b4e2f67decd6ab319e0f0d1db2cf..fa460bc021cdca1159f272e3bcb4d4dad50fc352 100644 --- a/src/gpu/GridGenerator/geometries/Sphere/Sphere.cu +++ b/src/gpu/GridGenerator/geometries/Sphere/Sphere.cpp @@ -1,7 +1,40 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids 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. +// +// VirtualFluids 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 VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file Sphere.cpp +//! \ingroup geometries +//! \author Soeren Peters, Stephan Lenz +//======================================================================================= #include "Sphere.h" #include <algorithm> // std::min #include <float.h> +#include <cmath> #include "geometries/Vertex/Vertex.h" @@ -91,7 +124,7 @@ void Sphere::scale(double delta) this->radius += delta; } -CUDA_HOST int Sphere::getIntersection(const Vertex & point, const Vertex & direction, Vertex & pointOnObject, real & qVal) +int Sphere::getIntersection(const Vertex & point, const Vertex & direction, Vertex & pointOnObject, real & qVal) { Vertex relativePoint( point.x - this->centerX, diff --git a/src/gpu/GridGenerator/geometries/Sphere/Sphere.h b/src/gpu/GridGenerator/geometries/Sphere/Sphere.h index 48a3cfb67a502e8537a6a5c0e2ea0f584c56583a..03b9ef9fd101f19dbaff7d4e4109000cce6e3c49 100644 --- a/src/gpu/GridGenerator/geometries/Sphere/Sphere.h +++ b/src/gpu/GridGenerator/geometries/Sphere/Sphere.h @@ -1,25 +1,50 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ // +// This file is part of VirtualFluids. VirtualFluids 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. +// +// VirtualFluids 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 VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file Sphere.h +//! \ingroup geometries +//! \author Soeren Peters, Stephan Lenz +//======================================================================================= #ifndef SPHERE_H #define SPHERE_H #include "global.h" -#include "GridGenerator_export.h" #include "geometries/Object.h" class GRIDGENERATOR_EXPORT Sphere : public Object { public: - HOSTDEVICE Sphere(const double& centerX, const double& centerY, const double& centerZ, const double& radius); - HOSTDEVICE virtual ~Sphere(); + Sphere(const double& centerX, const double& centerY, const double& centerZ, const double& radius); + virtual ~Sphere(); static SPtr<Sphere> makeShared(double centerX, double centerY, double centerZ, double radius); - HOSTDEVICE Object* clone() const override; + Object* clone() const override; double getX1Centroid() override; double getX1Minimum() override; @@ -31,12 +56,12 @@ public: double getX3Minimum() override; double getX3Maximum() override; - HOSTDEVICE bool isPointInObject(const double& x1, const double& x2, const double& x3, const double& minOffset, const double& maxOffset) override; + bool isPointInObject(const double& x1, const double& x2, const double& x3, const double& minOffset, const double& maxOffset) override; void scale(double delta) override; - CUDA_HOST int getIntersection(const Vertex &P, const Vertex &direction, Vertex &pointOnObject, real &qVal) override; + int getIntersection(const Vertex &P, const Vertex &direction, Vertex &pointOnObject, real &qVal) override; protected: diff --git a/src/gpu/GridGenerator/geometries/Triangle/Triangle.cu b/src/gpu/GridGenerator/geometries/Triangle/Triangle.cpp similarity index 60% rename from src/gpu/GridGenerator/geometries/Triangle/Triangle.cu rename to src/gpu/GridGenerator/geometries/Triangle/Triangle.cpp index 3ba2179a2b93d4249ec84100d8c62eefff2be86f..bf272b9e7f46c413ae6edce62c05d1be20d327de 100644 --- a/src/gpu/GridGenerator/geometries/Triangle/Triangle.cu +++ b/src/gpu/GridGenerator/geometries/Triangle/Triangle.cpp @@ -1,5 +1,36 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids 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. +// +// VirtualFluids 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 VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file Triangle.cpp +//! \ingroup geometries +//! \author Soeren Peters, Stephan Lenz +//======================================================================================= #include "Triangle.h" -#include "TriangleException.h" #include "utilities/math/Math.h" @@ -7,11 +38,11 @@ using namespace vf::gpu; -HOSTDEVICE Triangle::Triangle(Vertex &v1, Vertex &v2, Vertex &v3, Vertex &normal) : v1(v1), v2(v2), v3(v3), normal(normal), patchIndex(INVALID_INDEX) {} -HOSTDEVICE Triangle::Triangle(Vertex &v1, Vertex &v2, Vertex &v3) : v1(v1), v2(v2), v3(v3), patchIndex(INVALID_INDEX) { calcNormal(); } -HOSTDEVICE Triangle::Triangle(){} +Triangle::Triangle(Vertex &v1, Vertex &v2, Vertex &v3, Vertex &normal) : v1(v1), v2(v2), v3(v3), normal(normal), patchIndex(INVALID_INDEX) {} +Triangle::Triangle(Vertex &v1, Vertex &v2, Vertex &v3) : v1(v1), v2(v2), v3(v3), patchIndex(INVALID_INDEX) { calcNormal(); } +Triangle::Triangle(){} -HOSTDEVICE void Triangle::set(const Vertex &v1, const Vertex &v2, const Vertex &v3) +void Triangle::set(const Vertex &v1, const Vertex &v2, const Vertex &v3) { this->v1 = v1; this->v2 = v2; @@ -19,7 +50,7 @@ HOSTDEVICE void Triangle::set(const Vertex &v1, const Vertex &v2, const Vertex & this->calcNormal(); } -HOSTDEVICE void Triangle::set(int index, Vertex value) +void Triangle::set(int index, Vertex value) { if (index == 0) v1 = value; @@ -29,7 +60,7 @@ HOSTDEVICE void Triangle::set(int index, Vertex value) v3 = value; } -HOSTDEVICE Vertex Triangle::get(int index) +Vertex Triangle::get(int index) { if (index == 0) return v1; @@ -41,7 +72,7 @@ HOSTDEVICE Vertex Triangle::get(int index) return Vertex((real)-999999999999999, (real)-99999999999999, (real)-9999999999999); } -HOSTDEVICE void Triangle::calcNormal() +void Triangle::calcNormal() { Vertex edge1 = v2 - v1; Vertex edge2 = v3 - v1; @@ -49,27 +80,31 @@ HOSTDEVICE void Triangle::calcNormal() normal.normalize(); } -HOSTDEVICE void Triangle::initalLayerThickness(real delta) +void Triangle::initalLayerThickness(real delta) { - this->layerThickness = delta*(abs(this->normal.x) + abs(this->normal.y) + abs(this->normal.z)); + this->layerThickness = delta * (std::abs(this->normal.x) + std::abs(this->normal.y) + std::abs(this->normal.z)); } -HOSTDEVICE char Triangle::isUnderFace(const Vertex &point) const +char Triangle::isUnderFace(const Vertex &point) const { real s; - if (this->isUnterExtendedFace(point, s)) - if (this->isNotNextToFace(point)) - if (this->isUnderAngleToNeighbors(point)) - if (this->isNegativeDirectionBorder(point)) + if (this->isUnterExtendedFace(point, s)) { + if (this->isNotNextToFace(point)) { + if (this->isUnderAngleToNeighbors(point)) { + if (this->isNegativeDirectionBorder(point)) { return NEGATIVE_DIRECTION_BORDER; - else + } else { return INSIDE; - else + } + } else { return 4; - else + } + } else { return 3; + } + } if (this->isQNode(point, s)) @@ -78,36 +113,36 @@ HOSTDEVICE char Triangle::isUnderFace(const Vertex &point) const return FLUID; } -HOSTDEVICE bool Triangle::isUnterExtendedFace(const Vertex & point, real &s) const +bool Triangle::isUnterExtendedFace(const Vertex & point, real &s) const { s = this->getPerpedicularDistanceFrom(point); return ((vf::Math::greaterEqual(s, 0.0f)) && s < this->layerThickness); } -HOSTDEVICE real Triangle::getPerpedicularDistanceFrom(const Vertex &P) const +real Triangle::getPerpedicularDistanceFrom(const Vertex &P) const { Vertex v = P - v1; return (v * -1.0f) * normal; } -HOSTDEVICE Vertex Triangle::getPerpedicularPointFrom(const Vertex &P) const +Vertex Triangle::getPerpedicularPointFrom(const Vertex &P) const { return P + normal * getPerpedicularDistanceFrom(P); } -HOSTDEVICE bool Triangle::isQNode(const Vertex & point, const real &s) const +bool Triangle::isQNode(const Vertex & point, const real &s) const { return (s < 0 && vf::Math::lessEqual(-s, this->layerThickness)); //calculateQs(actualPoint, actualTriangle); } -HOSTDEVICE bool Triangle::isNegativeDirectionBorder(const Vertex &point) const +bool Triangle::isNegativeDirectionBorder(const Vertex &point) const { return normal.x < 0.0f || normal.y < 0.0f || normal.z < 0.0f; //return (sVector.x < 0.0f && sVector.y < 0.0f && sVector.z < 0.0f); } -HOSTDEVICE bool Triangle::isNotNextToFace(const Vertex &point) const +bool Triangle::isNotNextToFace(const Vertex &point) const { Vertex Pb = getPerpedicularPointFrom(point); @@ -126,7 +161,7 @@ HOSTDEVICE bool Triangle::isNotNextToFace(const Vertex &point) const return vf::Math::lessEqual(g1, 0.0f) && vf::Math::lessEqual(g2, 0.0f) && vf::Math::lessEqual(g3, 0.0f); } -HOSTDEVICE bool Triangle::isUnderAngleToNeighbors(const Vertex &point) const +bool Triangle::isUnderAngleToNeighbors(const Vertex &point) const { Vertex Pci[3]; this->getClosestPointsOnEdges(Pci, point); @@ -147,7 +182,7 @@ HOSTDEVICE bool Triangle::isUnderAngleToNeighbors(const Vertex &point) const return (vf::Math::lessEqual(betaAngles[0], alphaAngles[0], eps) && vf::Math::lessEqual(betaAngles[1], alphaAngles[1], eps) && vf::Math::lessEqual(betaAngles[2], alphaAngles[2], eps)); } -HOSTDEVICE void Triangle::getClosestPointsOnEdges(Vertex arr[], const Vertex &P) const +void Triangle::getClosestPointsOnEdges(Vertex arr[], const Vertex &P) const { Vertex Pc1, Pc2, Pc3; Vertex v4 = P - v1; @@ -235,7 +270,7 @@ bool Triangle::contains(const Vertex& v) const } -HOSTDEVICE int Triangle::getNumberOfCommonEdge(const Triangle &t2) const +int Triangle::getNumberOfCommonEdge(const Triangle &t2) const { int commonEdge = 0; if (t2.contains(v1)) @@ -250,7 +285,7 @@ HOSTDEVICE int Triangle::getNumberOfCommonEdge(const Triangle &t2) const } -HOSTDEVICE int Triangle::getTriangleIntersection(const Vertex &P, const Vertex &direction, Vertex &pointOnTri, real &qVal) const +int Triangle::getTriangleIntersection(const Vertex &P, const Vertex &direction, Vertex &pointOnTri, real &qVal) const { ///// taken from ///// //http://www.scratchapixel.com/lessons/3d-basic-rendering/ray-tracing-rendering-a-triangle/moller-trumbore-ray-triangle-intersection @@ -295,7 +330,7 @@ HOSTDEVICE int Triangle::getTriangleIntersection(const Vertex &P, const Vertex & return 0; } -HOSTDEVICE void Triangle::print() const +void Triangle::print() const { printf("v1: "); v1.print(); @@ -307,14 +342,14 @@ HOSTDEVICE void Triangle::print() const normal.print(); } -CUDA_HOST bool Triangle::operator==(const Triangle &t) const +bool Triangle::operator==(const Triangle &t) const { return v1 == t.v1 && v2 == t.v2 && v3 == t.v3 && vf::Math::equal(alphaAngles[0], t.alphaAngles[0]) && vf::Math::equal(alphaAngles[1], t.alphaAngles[1]) && vf::Math::equal(alphaAngles[2], t.alphaAngles[2]); } -HOSTDEVICE void Triangle::setMinMax(real &minX, real &maxX, real &minY, real &maxY, real &minZ, real &maxZ) const +void Triangle::setMinMax(real &minX, real &maxX, real &minY, real &maxY, real &minZ, real &maxZ) const { Vertex::setMinMax(minX, maxX, minY, maxY, minZ, maxZ, v1, v2, v3); } diff --git a/src/gpu/GridGenerator/geometries/Triangle/Triangle.h b/src/gpu/GridGenerator/geometries/Triangle/Triangle.h index 9c5a33895ed57ce4beaaf1c019a15766779b9942..0c62f2c0db5ced3c749c2ffd6196087192aab3df 100644 --- a/src/gpu/GridGenerator/geometries/Triangle/Triangle.h +++ b/src/gpu/GridGenerator/geometries/Triangle/Triangle.h @@ -1,10 +1,41 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids 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. +// +// VirtualFluids 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 VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file Triangle.h +//! \ingroup geometries +//! \author Soeren Peters, Stephan Lenz +//======================================================================================= #ifndef Triangle_h #define Triangle_h #include <memory> #include "global.h" -#include "GridGenerator_export.h" #include "geometries/Vertex/Vertex.h" class TriangleMemento; @@ -17,16 +48,16 @@ struct GRIDGENERATOR_EXPORT Triangle uint patchIndex; - HOSTDEVICE Triangle(Vertex &v1, Vertex &v2, Vertex &v3, Vertex &normal); - HOSTDEVICE Triangle(Vertex &v1, Vertex &v2, Vertex &v3); - HOSTDEVICE Triangle(); + Triangle(Vertex &v1, Vertex &v2, Vertex &v3, Vertex &normal); + Triangle(Vertex &v1, Vertex &v2, Vertex &v3); + Triangle(); - HOSTDEVICE void set(const Vertex &v1, const Vertex &v2, const Vertex &v3); - HOSTDEVICE void set(int index, Vertex value); - HOSTDEVICE Vertex get(int index); - HOSTDEVICE void calcNormal(); + void set(const Vertex &v1, const Vertex &v2, const Vertex &v3); + void set(int index, Vertex value); + Vertex get(int index); + void calcNormal(); - HOSTDEVICE void initalLayerThickness(real delta); + void initalLayerThickness(real delta); Vertex getCenterOfMass() const; @@ -36,28 +67,28 @@ struct GRIDGENERATOR_EXPORT Triangle int getCommonEdge(const Triangle &t2) const; bool contains(const Vertex& v)const; - HOSTDEVICE int getNumberOfCommonEdge(const Triangle &t2) const; - HOSTDEVICE int getTriangleIntersection(const Vertex &P, const Vertex &direction, Vertex &pointOnTri, real &qVal) const; - HOSTDEVICE void print() const; + int getNumberOfCommonEdge(const Triangle &t2) const; + int getTriangleIntersection(const Vertex &P, const Vertex &direction, Vertex &pointOnTri, real &qVal) const; + void print() const; - HOSTDEVICE char isUnderFace(const Vertex &point) const; + char isUnderFace(const Vertex &point) const; - HOSTDEVICE bool isUnterExtendedFace(const Vertex & point, real &s) const; - HOSTDEVICE bool isNotNextToFace(const Vertex &point) const; - HOSTDEVICE bool isUnderAngleToNeighbors(const Vertex &point) const; - HOSTDEVICE void getClosestPointsOnEdges(Vertex arr[], const Vertex &P) const; - HOSTDEVICE real getPerpedicularDistanceFrom(const Vertex &P) const; - HOSTDEVICE Vertex getPerpedicularPointFrom(const Vertex &P) const; - HOSTDEVICE bool isQNode(const Vertex & point, const real &s) const; - HOSTDEVICE bool isNegativeDirectionBorder(const Vertex & point) const; + bool isUnterExtendedFace(const Vertex & point, real &s) const; + bool isNotNextToFace(const Vertex &point) const; + bool isUnderAngleToNeighbors(const Vertex &point) const; + void getClosestPointsOnEdges(Vertex arr[], const Vertex &P) const; + real getPerpedicularDistanceFrom(const Vertex &P) const; + Vertex getPerpedicularPointFrom(const Vertex &P) const; + bool isQNode(const Vertex & point, const real &s) const; + bool isNegativeDirectionBorder(const Vertex & point) const; - CUDA_HOST bool operator==(const Triangle &t) const; + bool operator==(const Triangle &t) const; - CUDA_HOST TriangleMemento getState() const; - CUDA_HOST void setState(const TriangleMemento &memento); + TriangleMemento getState() const; + void setState(const TriangleMemento &memento); - HOSTDEVICE void setMinMax(real &minX, real &maxX, real &minY, real &maxY, real &minZ, real &maxZ) const; + void setMinMax(real &minX, real &maxX, real &minY, real &maxY, real &minZ, real &maxZ) const; }; #endif diff --git a/src/gpu/GridGenerator/geometries/Triangle/TriangleException.h b/src/gpu/GridGenerator/geometries/Triangle/TriangleException.h deleted file mode 100644 index 962a471b3afb80066047e80ab34601d8266c9937..0000000000000000000000000000000000000000 --- a/src/gpu/GridGenerator/geometries/Triangle/TriangleException.h +++ /dev/null @@ -1,69 +0,0 @@ -#ifndef meshGenExcpetion_h -#define meshGenExcpetion_h - -#include <exception> -#include <iostream> -#include <string> -#include <sstream> - -class meshGenExcpetion : public std::exception { -public: - virtual const char* what() const throw() = 0; -}; - -class nullVectorImpossibleToCalculateAngle : public meshGenExcpetion -{ - const char* what() const throw() { - std::ostringstream getNr; - getNr << "nullVectorImpossibleToCalculateAngle."; - return getNr.str().c_str(); - } -}; - -class calculateAngleWhenTrianglesHaveNoCommonEdge : public meshGenExcpetion -{ - const char* what() const throw() { - std::ostringstream getNr; - getNr << "Triangles have no common Edge."; - return getNr.str().c_str(); - } -}; - -class invalidTriangles : public meshGenExcpetion -{ - const char* what() const throw() { - std::ostringstream getNr; - getNr << "Triangles not valid."; - return getNr.str().c_str(); - } -}; - -class invalidDelta : public meshGenExcpetion -{ - const char* what() const throw() { - std::ostringstream getNr; - getNr << "Delta cant be < Null. To enable no changes change delta to 1.0."; - return getNr.str().c_str(); - } -}; - -class compareSameTriangleToFindNeighbor : public meshGenExcpetion -{ - const char* what() const throw() { - std::ostringstream getNr; - getNr << "Triangle Container function problem."; - return getNr.str().c_str(); - } -}; - -class normalFromTwoAdjacentTrianglesShowInOppositeDirection : public meshGenExcpetion -{ - const char* what() const throw() { - std::ostringstream getNr; - getNr << "STL broken, it is not allowed that two adjacent Triangles have a normal that shows in the opposite direction."; - return getNr.str().c_str(); - } -}; - - -#endif diff --git a/src/gpu/GridGenerator/geometries/TriangularMesh/TriangularMesh.cu b/src/gpu/GridGenerator/geometries/TriangularMesh/TriangularMesh.cpp similarity index 74% rename from src/gpu/GridGenerator/geometries/TriangularMesh/TriangularMesh.cu rename to src/gpu/GridGenerator/geometries/TriangularMesh/TriangularMesh.cpp index 31d8af624f35f1cc20ad1b8f627f5a56408f35f4..a11384887074aa6b42bff77dd8b7ee1ade8fc9e0 100644 --- a/src/gpu/GridGenerator/geometries/TriangularMesh/TriangularMesh.cu +++ b/src/gpu/GridGenerator/geometries/TriangularMesh/TriangularMesh.cpp @@ -1,3 +1,35 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids 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. +// +// VirtualFluids 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 VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file TriangularMesh.cpp +//! \ingroup geometries +//! \author Soeren Peters, Stephan Lenz +//======================================================================================= #include "TriangularMesh.h" #include "Core/Timer/Timer.h" @@ -96,12 +128,12 @@ void TriangularMesh::initalizeDataFromTriangles() this->triangles = triangleVec.data(); this->size = long(triangleVec.size()); - for (std::size_t i = 0; i < this->size; i++) { + for (std::size_t i = 0; i < (size_t)this->size; i++) { this->minmax.setMinMax(this->triangleVec[i]); } } -CUDA_HOST bool TriangularMesh::operator==(const TriangularMesh &geometry) const +bool TriangularMesh::operator==(const TriangularMesh &geometry) const { if (!(minmax == geometry.minmax)) return false; @@ -116,12 +148,12 @@ CUDA_HOST bool TriangularMesh::operator==(const TriangularMesh &geometry) const } -HOSTDEVICE GbTriFaceMesh3D* TriangularMesh::getGbTriFaceMesh3D() const +GbTriFaceMesh3D* TriangularMesh::getGbTriFaceMesh3D() const { return this->VF_GbTriFaceMesh3D.get(); } -CUDA_HOST GRIDGENERATOR_EXPORT void TriangularMesh::generateGbTriFaceMesh3D() +GRIDGENERATOR_EXPORT void TriangularMesh::generateGbTriFaceMesh3D() { if( this->VF_GbTriFaceMesh3D ) return; @@ -130,7 +162,7 @@ CUDA_HOST GRIDGENERATOR_EXPORT void TriangularMesh::generateGbTriFaceMesh3D() std::vector<GbTriFaceMesh3D::Vertex> *gbVertices = new std::vector<GbTriFaceMesh3D::Vertex>(this->triangleVec.size() * 3); std::vector<GbTriFaceMesh3D::TriFace> *gbTriangles = new std::vector<GbTriFaceMesh3D::TriFace>(this->triangleVec.size()); - for (int i = 0; i < this->triangleVec.size(); i++) + for (int i = 0; i < (int)this->triangleVec.size(); i++) { (*gbVertices)[i * 3] = GbTriFaceMesh3D::Vertex(triangles[i].v1.x, triangles[i].v1.y, triangles[i].v1.z); (*gbVertices)[i * 3 + 1] = GbTriFaceMesh3D::Vertex(triangles[i].v2.x, triangles[i].v2.y, triangles[i].v2.z); @@ -244,8 +276,8 @@ std::vector<Vertex> TriangularMesh::getAverrageNormalsPerVertex(std::vector<std: void TriangularMesh::eliminateTriangleswithIdenticialNormal(std::vector<Triangle> &triangles) { - for (int i = 0; i < triangles.size() - 1; i++) { - for (int j = i + 1; j < triangles.size(); j++) { + for (std::size_t i = 0; i < triangles.size() - 1; i++) { + for (std::size_t j = i + 1; j < triangles.size(); j++) { if (triangles[i].normal == triangles[j].normal) triangles.erase(triangles.begin() + i); } diff --git a/src/gpu/GridGenerator/geometries/TriangularMesh/TriangularMesh.h b/src/gpu/GridGenerator/geometries/TriangularMesh/TriangularMesh.h index fcb937f552e9d4ccb20b0c2cc15380918dc9b2e5..beb1c3a05b25904446e72a62196bcf6213fb0691 100644 --- a/src/gpu/GridGenerator/geometries/TriangularMesh/TriangularMesh.h +++ b/src/gpu/GridGenerator/geometries/TriangularMesh/TriangularMesh.h @@ -1,12 +1,42 @@ -#ifndef Geometry_h -#define Geometry_h +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids 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. +// +// VirtualFluids 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 VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file TriangularMesh.h +//! \ingroup geometries +//! \author Soeren Peters, Stephan Lenz, Martin Schoenherr +//======================================================================================= +#ifndef TriangularMesh_h +#define TriangularMesh_h #include <stdio.h> -#include <cuda_runtime.h> #include <vector> #include <string> #include <memory> -#include "GridGenerator_export.h" #include "global.h" #include "geometries/Triangle/Triangle.h" @@ -28,7 +58,7 @@ public: GRIDGENERATOR_EXPORT TriangularMesh(); GRIDGENERATOR_EXPORT TriangularMesh(const std::string& inputPath, const std::vector<uint> ignorePatches = std::vector<uint>()); GRIDGENERATOR_EXPORT TriangularMesh(const std::string& inputPath, const BoundingBox &box); - HOSTDEVICE GRIDGENERATOR_EXPORT ~TriangularMesh(); + GRIDGENERATOR_EXPORT ~TriangularMesh(); GRIDGENERATOR_EXPORT uint getNumberOfTriangles() const; @@ -42,13 +72,13 @@ public: SPtr<GbTriFaceMesh3D> VF_GbTriFaceMesh3D; - CUDA_HOST GRIDGENERATOR_EXPORT bool operator==(const TriangularMesh &geometry) const; + GRIDGENERATOR_EXPORT bool operator==(const TriangularMesh &geometry) const; GRIDGENERATOR_EXPORT void findNeighbors(); - HOSTDEVICE GRIDGENERATOR_EXPORT GbTriFaceMesh3D* getGbTriFaceMesh3D() const; + GRIDGENERATOR_EXPORT GbTriFaceMesh3D* getGbTriFaceMesh3D() const; - CUDA_HOST GRIDGENERATOR_EXPORT void generateGbTriFaceMesh3D(); + GRIDGENERATOR_EXPORT void generateGbTriFaceMesh3D(); private: @@ -58,7 +88,7 @@ private: static void eliminateTriangleswithIdenticialNormal(std::vector<Triangle> &triangles); public: - HOSTDEVICE Object* clone() const override; + Object* clone() const override; double getX1Centroid() override { throw "Not implemented in TriangularMesh"; } double getX1Minimum() override { return minmax.minX; } double getX1Maximum() override { return minmax.maxX; } @@ -69,7 +99,7 @@ public: double getX3Minimum() override { return minmax.minZ; } double getX3Maximum() override { return minmax.maxZ; } void scale(double delta) override; - HOSTDEVICE bool isPointInObject(const double& x1, const double& x2, const double& x3, const double& minOffset, + bool isPointInObject(const double& x1, const double& x2, const double& x3, const double& minOffset, const double& maxOffset) override { return false; } diff --git a/src/gpu/GridGenerator/geometries/TriangularMesh/TriangularMeshStrategy.cpp b/src/gpu/GridGenerator/geometries/TriangularMesh/TriangularMeshStrategy.cpp index 61a499a31a57a60f3c98bd4a7c600699cea77aa2..d9c1486e2ca9469d55174eca673f22f180a78294 100644 --- a/src/gpu/GridGenerator/geometries/TriangularMesh/TriangularMeshStrategy.cpp +++ b/src/gpu/GridGenerator/geometries/TriangularMesh/TriangularMeshStrategy.cpp @@ -1,3 +1,35 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids 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. +// +// VirtualFluids 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 VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file TriangularMeshStrategy.cpp +//! \ingroup geometries +//! \author Soeren Peters, Stephan Lenz +//======================================================================================= #include "TriangularMeshStrategy.h" #include "Core/Timer/Timer.h" @@ -248,7 +280,7 @@ void PointUnderTriangleStrategy::meshReverse(Triangle& triangle, GridImp* grid, } } -HOSTDEVICE void PointUnderTriangleStrategy::findInsideNodes(GridImp* grid, char innerType) +void PointUnderTriangleStrategy::findInsideNodes(GridImp* grid, char innerType) { bool foundInsideNode = true; while (foundInsideNode) @@ -259,7 +291,7 @@ HOSTDEVICE void PointUnderTriangleStrategy::findInsideNodes(GridImp* grid, char } } -HOSTDEVICE void PointUnderTriangleStrategy::setInsideNode(GridImp* grid, const uint &index, bool &insideNodeFound, char innerType) +void PointUnderTriangleStrategy::setInsideNode(GridImp* grid, const uint &index, bool &insideNodeFound, char innerType) { if (grid->isNode(index, NEGATIVE_DIRECTION_BORDER)) return; @@ -271,7 +303,7 @@ HOSTDEVICE void PointUnderTriangleStrategy::setInsideNode(GridImp* grid, const u } } -HOSTDEVICE void PointUnderTriangleStrategy::setNegativeDirBorderTo(GridImp* grid, const uint &index, char innerType) +void PointUnderTriangleStrategy::setNegativeDirBorderTo(GridImp* grid, const uint &index, char innerType) { if (grid->isNode(index, NEGATIVE_DIRECTION_BORDER)) grid->setNodeTo(index, innerType); diff --git a/src/gpu/GridGenerator/geometries/TriangularMesh/TriangularMeshStrategy.h b/src/gpu/GridGenerator/geometries/TriangularMesh/TriangularMeshStrategy.h index 98d852962310fb135a19fc57067d417b86994a2c..b98d531599ff897da0ad596a7d46e1393a456aac 100644 --- a/src/gpu/GridGenerator/geometries/TriangularMesh/TriangularMeshStrategy.h +++ b/src/gpu/GridGenerator/geometries/TriangularMesh/TriangularMeshStrategy.h @@ -1,8 +1,39 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids 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. +// +// VirtualFluids 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 VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file TriangularMeshStrategy.h +//! \ingroup geometries +//! \author Soeren Peters, Stephan Lenz +//======================================================================================= #ifndef TriangularMeshStrategy_H #define TriangularMeshStrategy_H #include "global.h" -#include "GridGenerator_export.h" class GridImp; class TriangularMesh; @@ -53,13 +84,13 @@ public: void doDiscretize(TriangularMesh* triangularMesh, GridImp* grid, char innerType, char outerType) override; private: - HOSTDEVICE void meshReverse(Triangle& triangle, GridImp* grid, char innerType); + void meshReverse(Triangle& triangle, GridImp* grid, char innerType); - HOSTDEVICE void findInsideNodes(GridImp* grid, char innerType); + void findInsideNodes(GridImp* grid, char innerType); - HOSTDEVICE void setInsideNode(GridImp* grid, const uint &index, bool &insideNodeFound, char innerType); + void setInsideNode(GridImp* grid, const uint &index, bool &insideNodeFound, char innerType); - HOSTDEVICE void setNegativeDirBorderTo(GridImp* grid, const uint &index, char innerType); + void setNegativeDirBorderTo(GridImp* grid, const uint &index, char innerType); }; diff --git a/src/gpu/GridGenerator/geometries/TriangularMesh/triangleNeighborFinder/TriangleNeighborFinder.cpp b/src/gpu/GridGenerator/geometries/TriangularMesh/triangleNeighborFinder/TriangleNeighborFinder.cpp index 4fc0e6dedc287ced661bbea5d1a1f6c30734c70b..08984d872ebf07cbe1d88658b48a7850077f188f 100644 --- a/src/gpu/GridGenerator/geometries/TriangularMesh/triangleNeighborFinder/TriangleNeighborFinder.cpp +++ b/src/gpu/GridGenerator/geometries/TriangularMesh/triangleNeighborFinder/TriangleNeighborFinder.cpp @@ -1,3 +1,35 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids 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. +// +// VirtualFluids 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 VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file TriangleNeighborFinder.cpp +//! \ingroup geometries +//! \author Soeren Peters, Stephan Lenz +//======================================================================================= #include "TriangleNeighborFinder.h" #include <omp.h> diff --git a/src/gpu/GridGenerator/geometries/TriangularMesh/triangleNeighborFinder/TriangleNeighborFinder.h b/src/gpu/GridGenerator/geometries/TriangularMesh/triangleNeighborFinder/TriangleNeighborFinder.h index be0ebc5d004bd8bff9b96d48d68064d134238afb..2b42ff3ad2dacaade3bbc8da4f6d4b3c61b14442 100644 --- a/src/gpu/GridGenerator/geometries/TriangularMesh/triangleNeighborFinder/TriangleNeighborFinder.h +++ b/src/gpu/GridGenerator/geometries/TriangularMesh/triangleNeighborFinder/TriangleNeighborFinder.h @@ -1,8 +1,39 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids 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. +// +// VirtualFluids 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 VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file TriangleNeighborFinder.h +//! \ingroup geometries +//! \author Soeren Peters, Stephan Lenz +//======================================================================================= #ifndef TriangleNeighborFinder_h #define TriangleNeighborFinder_h -#include "GridGenerator/global.h" -#include "GridGenerator_export.h" +#include "global.h" #include <vector> struct IDS { diff --git a/src/gpu/GridGenerator/geometries/TriangularMesh/triangleRefinement/TriangleRefinement.cpp b/src/gpu/GridGenerator/geometries/TriangularMesh/triangleRefinement/TriangleRefinement.cpp index d979839251d3e3efc2d610c29a5323f9560a6611..c1babac2324e80362c62c2b448cd1e309d7c5adf 100644 --- a/src/gpu/GridGenerator/geometries/TriangularMesh/triangleRefinement/TriangleRefinement.cpp +++ b/src/gpu/GridGenerator/geometries/TriangularMesh/triangleRefinement/TriangleRefinement.cpp @@ -1,3 +1,35 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids 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. +// +// VirtualFluids 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 VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file TriangleRefinement.cpp +//! \ingroup geometries +//! \author Soeren Peters, Stephan Lenz +//======================================================================================= #include "TriangleRefinement.h" #include <GridGenerator/geometries/Triangle/Triangle.h> diff --git a/src/gpu/GridGenerator/geometries/TriangularMesh/triangleRefinement/TriangleRefinement.h b/src/gpu/GridGenerator/geometries/TriangularMesh/triangleRefinement/TriangleRefinement.h index 2cd5045a12ef5267f0d1971f799a55cd081badbd..a9c5262fbf0ee701e26885fb54d96cd079038a87 100644 --- a/src/gpu/GridGenerator/geometries/TriangularMesh/triangleRefinement/TriangleRefinement.h +++ b/src/gpu/GridGenerator/geometries/TriangularMesh/triangleRefinement/TriangleRefinement.h @@ -1,3 +1,35 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids 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. +// +// VirtualFluids 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 VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file TriangleRefinement.h +//! \ingroup geometries +//! \author Soeren Peters, Stephan Lenz +//======================================================================================= #ifndef TriangleRefinement_h #define TriangleRefinement_h diff --git a/src/gpu/GridGenerator/geometries/Vertex/Vertex.cpp b/src/gpu/GridGenerator/geometries/Vertex/Vertex.cpp new file mode 100644 index 0000000000000000000000000000000000000000..100e88dda9567a43f90ea346260164b30f06e2c9 --- /dev/null +++ b/src/gpu/GridGenerator/geometries/Vertex/Vertex.cpp @@ -0,0 +1,195 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids 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. +// +// VirtualFluids 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 VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file Vertex.cpp +//! \ingroup geometries +//! \author Soeren Peters, Stephan Lenz +//======================================================================================= +#include "Vertex.h" + +#include "utilities/math/Math.h" + +Vertex::Vertex(real x, real y, real z) : x(x), y(y), z(z){} +Vertex::Vertex() { x = 0.0f; y = 0.0f; z = 0.0f; } + + real Vertex::getEuclideanDistanceTo(const Vertex &w) const +{ + return vf::Math::sqrtReal((x - w.x)*(x - w.x) + (y - w.y)*(y - w.y) + (z - w.z)*(z - w.z)); +} + +Vertex Vertex::operator-(const Vertex &v) const +{ + return Vertex(x - v.x, y - v.y, z - v.z); +} + +Vertex Vertex::operator+(const Vertex &v) const +{ + return Vertex(this->x + v.x, this->y + v.y, this->z + v.z); +} + +Vertex Vertex::operator*(const real& value) const +{ + return Vertex(value * this->x, value * this->y, value * this->z); +} + +Vertex Vertex::operator/(const real& value) const +{ + return *this * ((real)1.0 / value); +} + +real Vertex::operator*(const Vertex &w) const +{ + return x*w.x + y*w.y + z*w.z; +} + +struct Vertex Vertex::crossProduct(const Vertex &w) const +{ + real a = y*w.z - z*w.y; + real b = z*w.x - x*w.z; + real c = x*w.y - y*w.x; + return Vertex(a, b, c); +} + +real Vertex::length() const +{ + return vf::Math::sqrtReal(x * x + y * y + z * z); +} + +void Vertex::normalize() +{ + real len = length(); + + if (len > EPSILON) + { + real invLen = 1.0f / len; + x *= invLen; + y *= invLen; + z *= invLen; + } +} + +real Vertex::getMagnitude() const +{ + real temp = x*x + y*y + z*z; + return vf::Math::sqrtReal(temp); +} + +int Vertex::isEqual(const Vertex &w) const +{ + return vf::Math::equal(x, w.x) && vf::Math::equal(y, w.y) && vf::Math::equal(z, w.z); +} + +real Vertex::getInnerAngle(const Vertex &w) const +{ + if (isEqual(w)) + return 0.0; + if (this->getMagnitude() == 0 || w.getMagnitude() == 0) + return 0.0; + + real mag = this->getMagnitude() * w.getMagnitude(); + real skal = *this * w; + if (mag - std::abs(skal) < 0.0001) + return 0.0f; + return vf::Math::acosReal(skal / mag) * 180.0f / vf::Math::acosReal(-1.0f); // acos(-1.0f) = PI +} + +void Vertex::print() const +{ + printf("(%2.8f,%2.8f,%2.8f)\n", x, y, z); +} + +void Vertex::print(std::ostream &ost) const +{ + ost.write((char*)&x, 4); + ost.write((char*)&y, 4); + ost.write((char*)&z, 4); +} + +void Vertex::printFormatted(std::ostream &ost) const +{ + ost << x << " " << y << " " << z; +} + + + +bool Vertex::operator==(const Vertex &v) const +{ + return vf::Math::equal(x, v.x) && vf::Math::equal(y, v.y) && vf::Math::equal(z, v.z); +} + + +bool Vertex::isXbetween(real min, real max) const +{ + return x >= min && x <= max; +} + +bool Vertex::isYbetween(real min, real max) const +{ + return y >= min && y <= max; +} + +bool Vertex::isZbetween(real min, real max) const +{ + return z >= min && z <= max; +} + +void Vertex::setMinMax(real & minX, real & maxX, real & minY, real & maxY, real & minZ, real & maxZ, const Vertex & v1, const Vertex & v2, const Vertex & v3) +{ + calculateMinMax(v1.x, v2.x, v3.x, minX, maxX); + calculateMinMax(v1.y, v2.y, v3.y, minY, maxY); + calculateMinMax(v1.z, v2.z, v3.z, minZ, maxZ); +} + + +real getMinimum(const real &value1, const real &value2) +{ + return value1 < value2 ? value1 : value2; +} + +real getMaximum(const real &value1, const real &value2) +{ + return value1 > value2 ? value1 : value2; +} + + +void Vertex::calculateMinMax(const real &value1, const real &value2, const real &value3, real &min, real &max) +{ + + real newMinimum = value1; + newMinimum = getMinimum(value2, newMinimum); + newMinimum = getMinimum(value3, newMinimum); + + real newMaximum = value1; + newMaximum = getMaximum(value2, newMaximum); + newMaximum = getMaximum(value3, newMaximum); + + min = newMinimum; + max = newMaximum; +} + + diff --git a/src/gpu/GridGenerator/geometries/Vertex/Vertex.cu b/src/gpu/GridGenerator/geometries/Vertex/Vertex.cu deleted file mode 100644 index 875bd4c1d03013f3e33fb9c30f583b82feb6bcf6..0000000000000000000000000000000000000000 --- a/src/gpu/GridGenerator/geometries/Vertex/Vertex.cu +++ /dev/null @@ -1,178 +0,0 @@ -#include "Vertex.h" - -#include "utilities/math/Math.h" - -HOSTDEVICE Vertex::Vertex(real x, real y, real z) : x(x), y(y), z(z){} -HOSTDEVICE Vertex::Vertex() { x = 0.0f; y = 0.0f; z = 0.0f; } - -HOSTDEVICE Vertex::Vertex(const Vertex& v) -{ - this->x = v.x; - this->y = v.y; - this->z = v.z; -} - -HOSTDEVICE Vertex& Vertex::operator=(const Vertex& v) -{ - this->x = v.x; - this->y = v.y; - this->z = v.z; - return *this; -} - -HOSTDEVICE real Vertex::getEuclideanDistanceTo(const Vertex &w) const -{ - return vf::Math::sqrtReal((x - w.x)*(x - w.x) + (y - w.y)*(y - w.y) + (z - w.z)*(z - w.z)); -} - -HOSTDEVICE Vertex Vertex::operator-(const Vertex &v) const -{ - return Vertex(x - v.x, y - v.y, z - v.z); -} - -HOSTDEVICE Vertex Vertex::operator+(const Vertex &v) const -{ - return Vertex(this->x + v.x, this->y + v.y, this->z + v.z); -} - -HOSTDEVICE Vertex Vertex::operator*(const real& value) const -{ - return Vertex(value * this->x, value * this->y, value * this->z); -} - -HOSTDEVICE Vertex Vertex::operator/(const real& value) const -{ - return *this * (1.0 / value); -} - -HOSTDEVICE real Vertex::operator*(const Vertex &w) const -{ - return x*w.x + y*w.y + z*w.z; -} - -HOSTDEVICE struct Vertex Vertex::crossProduct(const Vertex &w) const -{ - real a = y*w.z - z*w.y; - real b = z*w.x - x*w.z; - real c = x*w.y - y*w.x; - return Vertex(a, b, c); -} - -HOSTDEVICE real Vertex::length() const -{ - return vf::Math::sqrtReal(x * x + y * y + z * z); -} - -HOSTDEVICE void Vertex::normalize() -{ - real len = length(); - - if (len > EPSILON) - { - real invLen = 1.0f / len; - x *= invLen; - y *= invLen; - z *= invLen; - } -} - -HOSTDEVICE real Vertex::getMagnitude() const -{ - real temp = x*x + y*y + z*z; - return vf::Math::sqrtReal(temp); -} - -HOSTDEVICE int Vertex::isEqual(const Vertex &w) const -{ - return vf::Math::equal(x, w.x) && vf::Math::equal(y, w.y) && vf::Math::equal(z, w.z); -} - -HOSTDEVICE real Vertex::getInnerAngle(const Vertex &w) const -{ - if (isEqual(w)) - return 0.0; - if (this->getMagnitude() == 0 || w.getMagnitude() == 0) - return 0.0; - - real mag = this->getMagnitude() * w.getMagnitude(); - real skal = *this * w; - if (mag - fabs(skal) < 0.0001) - return 0.0f; - return vf::Math::acosReal(skal / mag) * 180.0f / vf::Math::acosReal(-1.0f); // acos(-1.0f) = PI -} - -HOSTDEVICE void Vertex::print() const -{ - printf("(%2.8f,%2.8f,%2.8f)\n", x, y, z); -} - -CUDA_HOST void Vertex::print(std::ostream &ost) const -{ - ost.write((char*)&x, 4); - ost.write((char*)&y, 4); - ost.write((char*)&z, 4); -} - -CUDA_HOST void Vertex::printFormatted(std::ostream &ost) const -{ - ost << x << " " << y << " " << z; -} - - - -HOSTDEVICE bool Vertex::operator==(const Vertex &v) const -{ - return vf::Math::equal(x, v.x) && vf::Math::equal(y, v.y) && vf::Math::equal(z, v.z); -} - - -CUDA_HOST bool Vertex::isXbetween(real min, real max) const -{ - return x >= min && x <= max; -} - -CUDA_HOST bool Vertex::isYbetween(real min, real max) const -{ - return y >= min && y <= max; -} - -CUDA_HOST bool Vertex::isZbetween(real min, real max) const -{ - return z >= min && z <= max; -} - -HOSTDEVICE void Vertex::setMinMax(real & minX, real & maxX, real & minY, real & maxY, real & minZ, real & maxZ, const Vertex & v1, const Vertex & v2, const Vertex & v3) -{ - calculateMinMax(v1.x, v2.x, v3.x, minX, maxX); - calculateMinMax(v1.y, v2.y, v3.y, minY, maxY); - calculateMinMax(v1.z, v2.z, v3.z, minZ, maxZ); -} - - -HOSTDEVICE real getMinimum(const real &value1, const real &value2) -{ - return value1 < value2 ? value1 : value2; -} - -HOSTDEVICE real getMaximum(const real &value1, const real &value2) -{ - return value1 > value2 ? value1 : value2; -} - - -HOSTDEVICE void Vertex::calculateMinMax(const real &value1, const real &value2, const real &value3, real &min, real &max) -{ - - real newMinimum = value1; - newMinimum = getMinimum(value2, newMinimum); - newMinimum = getMinimum(value3, newMinimum); - - real newMaximum = value1; - newMaximum = getMaximum(value2, newMaximum); - newMaximum = getMaximum(value3, newMaximum); - - min = newMinimum; - max = newMaximum; -} - - diff --git a/src/gpu/GridGenerator/geometries/Vertex/Vertex.h b/src/gpu/GridGenerator/geometries/Vertex/Vertex.h index f1610b7e274e1c12c34772ef8a8d74da49ee9a81..ec5fc0f1ced64f7757de26deaf3053504e29d7c6 100644 --- a/src/gpu/GridGenerator/geometries/Vertex/Vertex.h +++ b/src/gpu/GridGenerator/geometries/Vertex/Vertex.h @@ -1,55 +1,79 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids 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. +// +// VirtualFluids 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 VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file Vertex.h +//! \ingroup geometries +//! \author Soeren Peters, Stephan Lenz +//======================================================================================= #ifndef VERTEX_H #define VERTEX_H #include <stdio.h> -#include <cuda_runtime.h> #include <memory> #include <ostream> #include "gpu/GridGenerator/global.h" -class VertexMemento; - struct GRIDGENERATOR_EXPORT Vertex { public: real x, y, z; - HOSTDEVICE Vertex(real x, real y, real z); - HOSTDEVICE Vertex(); - HOSTDEVICE Vertex(const Vertex& v); - HOSTDEVICE Vertex& operator=(const Vertex&); - HOSTDEVICE ~Vertex() {} - - HOSTDEVICE real getEuclideanDistanceTo(const Vertex &w) const; - HOSTDEVICE Vertex operator-(const Vertex &v) const; - HOSTDEVICE Vertex operator+(const Vertex &v) const; - HOSTDEVICE Vertex operator*(const real& value) const; - HOSTDEVICE Vertex operator/(const real& value) const; - - HOSTDEVICE real operator*(const Vertex &w) const; - HOSTDEVICE struct Vertex crossProduct(const Vertex &w) const; - HOSTDEVICE real length() const; - HOSTDEVICE void normalize(); - HOSTDEVICE real getMagnitude() const; - HOSTDEVICE int isEqual(const Vertex &w) const; - HOSTDEVICE real getInnerAngle(const Vertex &w) const; - - HOSTDEVICE bool operator==(const Vertex &v) const; - - CUDA_HOST VertexMemento getState() const; - CUDA_HOST void setState(const VertexMemento &memento); - - CUDA_HOST bool isXbetween(real min, real max) const; - CUDA_HOST bool isYbetween(real min, real max) const; - CUDA_HOST bool isZbetween(real min, real max) const; - - HOSTDEVICE static void setMinMax(real &minX, real &maxX, real &minY, real &maxY, real &minZ, real &maxZ, const Vertex &v1, const Vertex &v2, const Vertex &v3); - HOSTDEVICE static void calculateMinMax(const real &value1, const real &value2, const real &value3, real &min, real &max); - - HOSTDEVICE void print() const; - CUDA_HOST void print(std::ostream &ost) const; - CUDA_HOST void printFormatted(std::ostream &ost) const; + Vertex(real x, real y, real z); + Vertex(); + ~Vertex() {} + + real getEuclideanDistanceTo(const Vertex &w) const; + Vertex operator-(const Vertex &v) const; + Vertex operator+(const Vertex &v) const; + Vertex operator*(const real& value) const; + Vertex operator/(const real& value) const; + + real operator*(const Vertex &w) const; + struct Vertex crossProduct(const Vertex &w) const; + real length() const; + void normalize(); + real getMagnitude() const; + int isEqual(const Vertex &w) const; + real getInnerAngle(const Vertex &w) const; + + bool operator==(const Vertex &v) const; + + bool isXbetween(real min, real max) const; + bool isYbetween(real min, real max) const; + bool isZbetween(real min, real max) const; + + static void setMinMax(real &minX, real &maxX, real &minY, real &maxY, real &minZ, real &maxZ, const Vertex &v1, const Vertex &v2, const Vertex &v3); + static void calculateMinMax(const real &value1, const real &value2, const real &value3, real &min, real &max); + + void print() const; + void print(std::ostream &ost) const; + void printFormatted(std::ostream &ost) const; }; diff --git a/src/gpu/GridGenerator/geometries/VerticalCylinder/VerticalCylinder.cpp b/src/gpu/GridGenerator/geometries/VerticalCylinder/VerticalCylinder.cpp new file mode 100644 index 0000000000000000000000000000000000000000..89bcd50349fe1a7591c5a873b5924a0c8ce8c2f3 --- /dev/null +++ b/src/gpu/GridGenerator/geometries/VerticalCylinder/VerticalCylinder.cpp @@ -0,0 +1,122 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids 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. +// +// VirtualFluids 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 VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file VerticalCylinder.cpp +//! \ingroup geometries +//! \author Soeren Peters, Stephan Lenz +//======================================================================================= +#include "VerticalCylinder.h" + +VerticalCylinder::VerticalCylinder(const double& centerX, const double& centerY, const double& centerZ, const double& radius, const double& height) + : centerX(centerX), centerY(centerY), centerZ(centerZ), radius(radius), height(height) +{ + +} + +VerticalCylinder::~VerticalCylinder() +{ +} + +SPtr<VerticalCylinder> VerticalCylinder::makeShared(double centerX, double centerY, double centerZ, double radius, double height) +{ + return SPtr<VerticalCylinder>(new VerticalCylinder(centerX, centerY, centerZ, radius, height)); +} + +Object* VerticalCylinder::clone() const +{ + return new VerticalCylinder(centerX, centerY, centerZ, radius, height); +} + +double VerticalCylinder::getX1Centroid() +{ + return centerX; +} + +double VerticalCylinder::getX1Minimum() +{ + return centerX - radius; +} + +double VerticalCylinder::getX1Maximum() +{ + return centerX + radius; +} + +double VerticalCylinder::getX2Centroid() +{ + return centerY; +} + +double VerticalCylinder::getX2Minimum() +{ + return centerY - radius; +} + +double VerticalCylinder::getX2Maximum() +{ + return centerY + radius; +} + +double VerticalCylinder::getX3Centroid() +{ + return centerZ; +} + +double VerticalCylinder::getX3Minimum() +{ + return centerZ - 0.5 * height; +} + +double VerticalCylinder::getX3Maximum() +{ + return centerZ + 0.5 * height; +} + +bool VerticalCylinder::isPointInObject(const double& x1, const double& x2, const double& x3, const double& minOffset, const double& maxOffset) +{ + double offset = maxOffset; + if (x1 < centerX || x2 < centerY || x3 < centerZ) + offset = minOffset; + + + const double deltaX1 = x1 - centerX; + const double deltaX2 = x2 - centerY; + const double deltaX3 = x3 - centerZ; + + if( deltaX3 > 0.5 * height || deltaX3 < - 0.5 * height ) + return false; + + return (deltaX1*deltaX1 + deltaX2*deltaX2) < ((this->radius - offset) * (this->radius - offset)); +} + + +void VerticalCylinder::scale(double delta) +{ + this->radius += delta; + this->height += delta; +} diff --git a/src/gpu/GridGenerator/geometries/VerticalCylinder/VerticalCylinder.cu b/src/gpu/GridGenerator/geometries/VerticalCylinder/VerticalCylinder.cu deleted file mode 100644 index 16a2640c17b861c90e0610aa51ae4f25140853cf..0000000000000000000000000000000000000000 --- a/src/gpu/GridGenerator/geometries/VerticalCylinder/VerticalCylinder.cu +++ /dev/null @@ -1,90 +0,0 @@ -#include "VerticalCylinder.h" - -VerticalCylinder::VerticalCylinder(const double& centerX, const double& centerY, const double& centerZ, const double& radius, const double& height) - : centerX(centerX), centerY(centerY), centerZ(centerZ), radius(radius), height(height) -{ - -} - -VerticalCylinder::~VerticalCylinder() -{ -} - -SPtr<VerticalCylinder> VerticalCylinder::makeShared(double centerX, double centerY, double centerZ, double radius, double height) -{ - return SPtr<VerticalCylinder>(new VerticalCylinder(centerX, centerY, centerZ, radius, height)); -} - -Object* VerticalCylinder::clone() const -{ - return new VerticalCylinder(centerX, centerY, centerZ, radius, height); -} - -double VerticalCylinder::getX1Centroid() -{ - return centerX; -} - -double VerticalCylinder::getX1Minimum() -{ - return centerX - radius; -} - -double VerticalCylinder::getX1Maximum() -{ - return centerX + radius; -} - -double VerticalCylinder::getX2Centroid() -{ - return centerY; -} - -double VerticalCylinder::getX2Minimum() -{ - return centerY - radius; -} - -double VerticalCylinder::getX2Maximum() -{ - return centerY + radius; -} - -double VerticalCylinder::getX3Centroid() -{ - return centerZ; -} - -double VerticalCylinder::getX3Minimum() -{ - return centerZ - 0.5 * height; -} - -double VerticalCylinder::getX3Maximum() -{ - return centerZ + 0.5 * height; -} - -bool VerticalCylinder::isPointInObject(const double& x1, const double& x2, const double& x3, const double& minOffset, const double& maxOffset) -{ - double offset = maxOffset; - if (x1 < centerX || x2 < centerY || x3 < centerZ) - offset = minOffset; - - - const double deltaX1 = x1 - centerX; - const double deltaX2 = x2 - centerY; - const double deltaX3 = x3 - centerZ; - - if( deltaX3 > 0.5 * height || deltaX3 < - 0.5 * height ) - return false; - - return (deltaX1*deltaX1 + deltaX2*deltaX2) < ((this->radius - offset) * (this->radius - offset)); -} - - -void VerticalCylinder::scale(double delta) -{ - this->radius += delta; - this->height += delta; -} diff --git a/src/gpu/GridGenerator/geometries/VerticalCylinder/VerticalCylinder.h b/src/gpu/GridGenerator/geometries/VerticalCylinder/VerticalCylinder.h index e1ee6fc3dbfe3f4594e344c0cb54136bca8149a1..e995d2ba16eba17930401c99c260f81b9c6077b4 100644 --- a/src/gpu/GridGenerator/geometries/VerticalCylinder/VerticalCylinder.h +++ b/src/gpu/GridGenerator/geometries/VerticalCylinder/VerticalCylinder.h @@ -1,25 +1,50 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ // +// This file is part of VirtualFluids. VirtualFluids 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. +// +// VirtualFluids 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 VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file VerticalCylinder.h +//! \ingroup geometries +//! \author Soeren Peters, Stephan Lenz +//======================================================================================= #ifndef VERTICAL_CYLINDER_H #define VERTICAL_CYLINDER_H #include "global.h" -#include "GridGenerator_export.h" #include "geometries/Object.h" class GRIDGENERATOR_EXPORT VerticalCylinder : public Object { public: - HOSTDEVICE VerticalCylinder(const double& centerX, const double& centerY, const double& centerZ, const double& radius, const double& height); - HOSTDEVICE virtual ~VerticalCylinder(); + VerticalCylinder(const double& centerX, const double& centerY, const double& centerZ, const double& radius, const double& height); + virtual ~VerticalCylinder(); static SPtr<VerticalCylinder> makeShared(double centerX, double centerY, double centerZ, double radius, double height); - HOSTDEVICE Object* clone() const override; + Object* clone() const override; double getX1Centroid() override; double getX1Minimum() override; @@ -31,7 +56,7 @@ public: double getX3Minimum() override; double getX3Maximum() override; - HOSTDEVICE bool isPointInObject(const double& x1, const double& x2, const double& x3, const double& minOffset, const double& maxOffset) override; + bool isPointInObject(const double& x1, const double& x2, const double& x3, const double& minOffset, const double& maxOffset) override; void scale(double delta) override; diff --git a/src/gpu/GridGenerator/global.h b/src/gpu/GridGenerator/global.h index 3378265eaa60cd713f4d932f59eaa04f680b4543..19bedc95b9a767f30761279500c6b8c036509eba 100644 --- a/src/gpu/GridGenerator/global.h +++ b/src/gpu/GridGenerator/global.h @@ -1,3 +1,35 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids 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. +// +// VirtualFluids 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 VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file global.h +//! \ingroup GridGenerator +//! \author Soeren Peters +//======================================================================================= #ifndef global_h #define global_h @@ -8,6 +40,7 @@ #define MASTERRANK 0 + #include "GridGenerator_export.h" #include "PointerDefinitions.h" @@ -15,6 +48,4 @@ #include "Core/Logger/Logger.h" -#include "utilities/cuda/cudaDefines.h" - #endif diff --git a/src/gpu/GridGenerator/grid/BoundaryConditions/BoundaryCondition.cpp b/src/gpu/GridGenerator/grid/BoundaryConditions/BoundaryCondition.cpp index fb60958c61e6fa53a546a8b5783e313712897123..5102f60fc295aadf4323a4b332bf3dd8f7f21dbf 100644 --- a/src/gpu/GridGenerator/grid/BoundaryConditions/BoundaryCondition.cpp +++ b/src/gpu/GridGenerator/grid/BoundaryConditions/BoundaryCondition.cpp @@ -1,27 +1,64 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids 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. +// +// VirtualFluids 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 VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file BoundaryCondition.cpp +//! \ingroup grid +//! \author Soeren Peters, Stephan Lenz +//======================================================================================= #include "BoundaryCondition.h" #include <cmath> -#include "GridGenerator_export.h" + #include "grid/BoundaryConditions/Side.h" #include "grid/Grid.h" -bool BoundaryCondition::isSide( SideType side ) const +bool gg::BoundaryCondition::isSide( SideType side ) const { return this->side->whoAmI() == side; } -GRIDGENERATOR_EXPORT void VelocityBoundaryCondition::setVelocityProfile(SPtr<Grid> grid, std::function<void(real, real, real, real&, real&, real&)> velocityProfile) +////////////////////////////////////////////////////////////////////////// + +void VelocityBoundaryCondition::setVelocityProfile( + SPtr<Grid> grid, std::function<void(real, real, real, real &, real &, real &)> velocityProfile) { - for( uint index = 0; index < this->indices.size(); index++ ){ + for (uint index = 0; index < this->indices.size(); index++) { - real x, y, z; + real x, y, z; - grid->transIndexToCoords( this->indices[index], x, y, z ); + grid->transIndexToCoords(this->indices[index], x, y, z); - velocityProfile(x,y,z,this->vxList[index],this->vyList[index],this->vzList[index]); + velocityProfile(x, y, z, this->vxList[index], this->vyList[index], this->vzList[index]); } } +////////////////////////////////////////////////////////////////////////// + void GeometryBoundaryCondition::setTangentialVelocityForPatch(SPtr<Grid> grid, uint patch, real p1x, real p1y, real p1z, real p2x, real p2y, real p2z, @@ -69,3 +106,23 @@ void GeometryBoundaryCondition::setTangentialVelocityForPatch(SPtr<Grid> grid, u } } } + +////////////////////////////////////////////////////////////////////////// + +void StressBoundaryCondition::fillSamplingIndices(std::vector<SPtr<Grid> > grid, uint level, uint samplingOffset) +{ + + for( uint i = 0; i < this->indices.size(); i++ ) + { + real x, y, z; + grid[level]->transIndexToCoords(this->indices[i], x, y, z); + + real x_sampling = x + this->getNormalx(i)*samplingOffset*grid[level]->getDelta(); + real y_sampling = y + this->getNormaly(i)*samplingOffset*grid[level]->getDelta(); + real z_sampling = z + this->getNormalz(i)*samplingOffset*grid[level]->getDelta(); + + this->velocitySamplingIndices.push_back( grid[level]->transCoordToIndex(x_sampling, y_sampling, z_sampling) ); + } + +} + diff --git a/src/gpu/GridGenerator/grid/BoundaryConditions/BoundaryCondition.h b/src/gpu/GridGenerator/grid/BoundaryConditions/BoundaryCondition.h index 9da79497ca2825ab25f62c6e622ee852342cf25c..8ea4c7ea6e37be1fd5ef8dbd1685f55b1ad549e0 100644 --- a/src/gpu/GridGenerator/grid/BoundaryConditions/BoundaryCondition.h +++ b/src/gpu/GridGenerator/grid/BoundaryConditions/BoundaryCondition.h @@ -1,3 +1,35 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids 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. +// +// VirtualFluids 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 VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file BoundaryCondition.h +//! \ingroup grid +//! \author Soeren Peters, Stephan Lenz, Martin Schoenherr +//======================================================================================= #ifndef BoundaryCondition_H #define BoundaryCondition_H @@ -13,6 +45,8 @@ class Grid; class Side; enum class SideType; +namespace gg +{ class BoundaryCondition { public: @@ -20,20 +54,22 @@ public: std::vector<uint> indices; SPtr<Side> side; - std::vector<std::vector<real> > qs; + std::vector<std::vector<real>> qs; std::vector<uint> patches; virtual char getType() const = 0; - bool isSide( SideType side ) const; + bool isSide(SideType side) const; - real getQ( uint index, uint dir ){ return this->qs[index][dir]; } + real getQ(uint index, uint dir) { return this->qs[index][dir]; } }; +} + ////////////////////////////////////////////////////////////////////////// -class PressureBoundaryCondition : public BoundaryCondition +class PressureBoundaryCondition : public gg::BoundaryCondition { public: static SPtr<PressureBoundaryCondition> make(real rho) @@ -62,7 +98,118 @@ public: ////////////////////////////////////////////////////////////////////////// -class VelocityBoundaryCondition : public BoundaryCondition +class SlipBoundaryCondition : public gg::BoundaryCondition +{ +public: + static SPtr<SlipBoundaryCondition> make(real normalX, real normalY, real normalZ) + { + return SPtr<SlipBoundaryCondition>(new SlipBoundaryCondition(normalX, normalY, normalZ)); + } + + real normalX, normalY, normalZ; + std::vector<real> normalXList, normalYList, normalZList; +protected: + SlipBoundaryCondition(real normalX, real normalY, real normalZ) : normalX(normalX), normalY(normalY), normalZ(normalZ) { } + +public: + virtual char getType() const override + { + return vf::gpu::BC_SLIP; + } + + void fillSlipNormalLists() + { + for (uint index : this->indices) { + (void)index; + this->normalXList.push_back(normalX); + this->normalYList.push_back(normalY); + this->normalZList.push_back(normalZ); + } + } + + real getNormalx() { return this->normalX; } + real getNormaly() { return this->normalY; } + real getNormalz() { return this->normalZ; } + + real getNormalx(uint index) { return this->normalXList[index]; } + real getNormaly(uint index) { return this->normalYList[index]; } + real getNormalz(uint index) { return this->normalZList[index]; } +}; + +////////////////////////////////////////////////////////////////////////// + +class StressBoundaryCondition : public gg::BoundaryCondition +{ +public: + static SPtr<StressBoundaryCondition> make(real normalX, real normalY, real normalZ, uint samplingOffset, real z0) + { + return SPtr<StressBoundaryCondition>(new StressBoundaryCondition(normalX, normalY, normalZ, samplingOffset, z0)); + } + + real normalX, normalY, normalZ; + uint samplingOffset; + real z0; + std::vector<real> normalXList, normalYList, normalZList; + std::vector<uint> samplingOffsetList; + std::vector<real> z0List; + std::vector<uint> velocitySamplingIndices; + +protected: + StressBoundaryCondition(real normalX, real normalY, real normalZ, uint samplingOffset, real z0) : normalX(normalX), normalY(normalY), normalZ(normalZ), samplingOffset(samplingOffset), z0(z0){ } + +public: + virtual char getType() const override + { + return vf::gpu::BC_STRESS; + } + + void fillStressNormalLists() + { + for (uint index : this->indices) { + (void)index; + this->normalXList.push_back(normalX); + this->normalYList.push_back(normalY); + this->normalZList.push_back(normalZ); + } + } + + void fillZ0Lists() + { + for (uint index : this->indices) { + (void)index; + this->z0List.push_back(z0); + } + } + + void fillSamplingOffsetLists() + { + for (uint index : this->indices) { + (void)index; + this->samplingOffsetList.push_back(samplingOffset); + } + } + + real getNormalx() { return this->normalX; } + real getNormaly() { return this->normalY; } + real getNormalz() { return this->normalZ; } + + real getNormalx(uint index) { return this->normalXList[index]; } + real getNormaly(uint index) { return this->normalYList[index]; } + real getNormalz(uint index) { return this->normalZList[index]; } + + uint getSamplingOffset() { return this->samplingOffset; } + uint getSamplingOffset(uint index) { return this->samplingOffsetList[index]; } + + real getZ0() { return this->z0; } + real getZ0(uint index) { return this->z0List[index]; } + + void fillSamplingIndices(std::vector<SPtr<Grid> > grid, uint level, uint samplingOffset); + +}; + +////////////////////////////////////////////////////////////////////////// + +class VelocityBoundaryCondition : public gg ::BoundaryCondition { public: static SPtr<VelocityBoundaryCondition> make(real vx, real vy, real vz) @@ -98,8 +245,8 @@ public: real getVx(uint index) { return this->vxList[index]; } real getVy(uint index) { return this->vyList[index]; } real getVz(uint index) { return this->vzList[index]; } - - GRIDGENERATOR_EXPORT void setVelocityProfile( SPtr<Grid> grid, std::function<void(real,real,real,real&,real&,real&)> velocityProfile ); + + void setVelocityProfile( SPtr<Grid> grid, std::function<void(real,real,real,real&,real&,real&)> velocityProfile ); }; ////////////////////////////////////////////////////////////////////////// diff --git a/src/gpu/GridGenerator/grid/BoundaryConditions/Side.cpp b/src/gpu/GridGenerator/grid/BoundaryConditions/Side.cpp index 75cb8e23fca1a9643dbb7901f628b9e30cb1b4d7..6c7bf8ca1853826d83fb6a713ffe03716bd2cf9a 100644 --- a/src/gpu/GridGenerator/grid/BoundaryConditions/Side.cpp +++ b/src/gpu/GridGenerator/grid/BoundaryConditions/Side.cpp @@ -1,3 +1,35 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids 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. +// +// VirtualFluids 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 VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file Side.cpp +//! \ingroup grid +//! \author Soeren Peters, Stephan Lenz +//======================================================================================= #include "Side.h" #include "grid/BoundaryConditions/BoundaryCondition.h" @@ -6,7 +38,7 @@ #include "utilities/math/Math.h" -using namespace vf::gpu; +using namespace gg; void Side::addIndices(SPtr<Grid> grid, SPtr<BoundaryCondition> boundaryCondition, std::string coord, real constant, real startInner, real endInner, real startOuter, real endOuter) @@ -17,20 +49,22 @@ void Side::addIndices(SPtr<Grid> grid, SPtr<BoundaryCondition> boundaryCondition { const uint index = getIndex(grid, coord, constant, v1, v2); - if ((index != INVALID_INDEX) && ( grid->getFieldEntry(index) == FLUID - || grid->getFieldEntry(index) == FLUID_CFC - || grid->getFieldEntry(index) == FLUID_CFF - || grid->getFieldEntry(index) == FLUID_FCC - || grid->getFieldEntry(index) == FLUID_FCF ) ) + if ((index != INVALID_INDEX) && ( grid->getFieldEntry(index) == vf::gpu::FLUID + || grid->getFieldEntry(index) == vf::gpu::FLUID_CFC + || grid->getFieldEntry(index) == vf::gpu::FLUID_CFF + || grid->getFieldEntry(index) == vf::gpu::FLUID_FCC + || grid->getFieldEntry(index) == vf::gpu::FLUID_FCF )) { grid->setFieldEntry(index, boundaryCondition->getType()); boundaryCondition->indices.push_back(index); setPressureNeighborIndices(boundaryCondition, grid, index); + setStressSamplingIndices(boundaryCondition, grid, index); setQs(grid, boundaryCondition, index); boundaryCondition->patches.push_back(0); } + } } } @@ -59,6 +93,30 @@ void Side::setPressureNeighborIndices(SPtr<BoundaryCondition> boundaryCondition, } } +void Side::setStressSamplingIndices(SPtr<BoundaryCondition> boundaryCondition, SPtr<Grid> grid, const uint index) +{ + auto stressBoundaryCondition = std::dynamic_pointer_cast<StressBoundaryCondition>(boundaryCondition); + if (stressBoundaryCondition) + { + real x, y, z; + grid->transIndexToCoords(index, x, y, z); + + real nx = x; + real ny = y; + real nz = z; + + if (boundaryCondition->side->getCoordinate() == X_INDEX) + nx = -boundaryCondition->side->getDirection() * stressBoundaryCondition->samplingOffset * grid->getDelta() + x; + if (boundaryCondition->side->getCoordinate() == Y_INDEX) + ny = -boundaryCondition->side->getDirection() * stressBoundaryCondition->samplingOffset * grid->getDelta() + y; + if (boundaryCondition->side->getCoordinate() == Z_INDEX) + nz = -boundaryCondition->side->getDirection() * stressBoundaryCondition->samplingOffset * grid->getDelta() + z; + + uint samplingIndex = grid->transCoordToIndex(nx, ny, nz); + stressBoundaryCondition->velocitySamplingIndices.push_back(samplingIndex); + } +} + void Side::setQs(SPtr<Grid> grid, SPtr<BoundaryCondition> boundaryCondition, uint index) { @@ -76,32 +134,32 @@ void Side::setQs(SPtr<Grid> grid, SPtr<BoundaryCondition> boundaryCondition, uin real neighborZ = z + grid->getDirection()[dir * DIMENSION + 2] * grid->getDelta(); // correct neighbor coordinates in case of periodic boundaries - if( grid->getPeriodicityX() && grid->getFieldEntry( grid->transCoordToIndex( neighborX, y, z ) ) == STOPPER_OUT_OF_GRID_BOUNDARY ) + if( grid->getPeriodicityX() && grid->getFieldEntry( grid->transCoordToIndex( neighborX, y, z ) ) == vf::gpu::STOPPER_OUT_OF_GRID_BOUNDARY ) { if( neighborX > x ) neighborX = grid->getFirstFluidNode( coords, 0, grid->getStartX() ); else neighborX = grid->getLastFluidNode ( coords, 0, grid->getEndX() ); } - if( grid->getPeriodicityY() && grid->getFieldEntry( grid->transCoordToIndex( x, neighborY, z ) ) == STOPPER_OUT_OF_GRID_BOUNDARY ) + if( grid->getPeriodicityY() && grid->getFieldEntry( grid->transCoordToIndex( x, neighborY, z ) ) == vf::gpu::STOPPER_OUT_OF_GRID_BOUNDARY ) { if( neighborY > y ) neighborY = grid->getFirstFluidNode( coords, 1, grid->getStartY() ); else neighborY = grid->getLastFluidNode ( coords, 1, grid->getEndY() ); } - if( grid->getPeriodicityZ() && grid->getFieldEntry( grid->transCoordToIndex( x, y, neighborZ ) ) == STOPPER_OUT_OF_GRID_BOUNDARY ) + if( grid->getPeriodicityZ() && grid->getFieldEntry( grid->transCoordToIndex( x, y, neighborZ ) ) == vf::gpu::STOPPER_OUT_OF_GRID_BOUNDARY ) { if( neighborZ > z ) neighborZ = grid->getFirstFluidNode( coords, 2, grid->getStartZ() ); else neighborZ = grid->getLastFluidNode ( coords, 2, grid->getEndZ() ); } uint neighborIndex = grid->transCoordToIndex( neighborX, neighborY, neighborZ ); - - if( grid->getFieldEntry(neighborIndex) == STOPPER_OUT_OF_GRID_BOUNDARY || - grid->getFieldEntry(neighborIndex) == STOPPER_OUT_OF_GRID || - grid->getFieldEntry(neighborIndex) == STOPPER_SOLID ) + if( grid->getFieldEntry(neighborIndex) == vf::gpu::STOPPER_OUT_OF_GRID_BOUNDARY || + grid->getFieldEntry(neighborIndex) == vf::gpu::STOPPER_OUT_OF_GRID || + grid->getFieldEntry(neighborIndex) == vf::gpu::STOPPER_SOLID ) qNode[dir] = 0.5; else qNode[dir] = -1.0; + } boundaryCondition->qs.push_back(qNode); @@ -127,7 +185,7 @@ void Geometry::addIndices(std::vector<SPtr<Grid> > grids, uint level, SPtr<Bound for (uint index = 0; index < grids[level]->getSize(); index++) { - if (grids[level]->getFieldEntry(index) != BC_SOLID) + if (grids[level]->getFieldEntry(index) != vf::gpu::BC_SOLID) continue; for (int dir = 0; dir <= grids[level]->getEndDirection(); dir++) @@ -146,15 +204,15 @@ void Geometry::addIndices(std::vector<SPtr<Grid> > grids, uint level, SPtr<Bound uint neighborIndex = grids[level]->transCoordToIndex( x, y, z ); - if( qNode[dir] < -0.5 && ( grids[level]->getFieldEntry(neighborIndex) == STOPPER_OUT_OF_GRID_BOUNDARY || - grids[level]->getFieldEntry(neighborIndex) == STOPPER_OUT_OF_GRID || - grids[level]->getFieldEntry(neighborIndex) == STOPPER_SOLID ) ) + if( qNode[dir] < -0.5 && ( grids[level]->getFieldEntry(neighborIndex) == vf::gpu::STOPPER_OUT_OF_GRID_BOUNDARY || + grids[level]->getFieldEntry(neighborIndex) == vf::gpu::STOPPER_OUT_OF_GRID || + grids[level]->getFieldEntry(neighborIndex) == vf::gpu::STOPPER_SOLID ) ) qNode[dir] = 0.5; } geometryBoundaryCondition->indices.push_back(index); geometryBoundaryCondition->qs.push_back(qNode); - geometryBoundaryCondition->patches.push_back( grids[level]->getQPatch(index) ); + geometryBoundaryCondition->patches.push_back(grids[level]->getQPatch(index)); } } @@ -249,6 +307,6 @@ void PZ::addIndices(std::vector<SPtr<Grid> > grid, uint level, SPtr<BoundaryCond real coordinateNormal = grid[level]->getEndZ() - grid[level]->getDelta(); if( coordinateNormal < grid[0]->getEndZ() - grid[0]->getDelta() ) return; - + Side::addIndices(grid[level], boundaryCondition, "z", coordinateNormal, startInner, endInner, startOuter, endOuter); } diff --git a/src/gpu/GridGenerator/grid/BoundaryConditions/Side.h b/src/gpu/GridGenerator/grid/BoundaryConditions/Side.h index 13522cf2e9802f8bb4ad5f02ef0ca87fa1a56336..c9ffd40b0aa8fc2b8da8b4d85de60faea6927117 100644 --- a/src/gpu/GridGenerator/grid/BoundaryConditions/Side.h +++ b/src/gpu/GridGenerator/grid/BoundaryConditions/Side.h @@ -1,3 +1,35 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids 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. +// +// VirtualFluids 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 VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file Side.h +//! \ingroup grid +//! \author Soeren Peters, Stephan Lenz +//======================================================================================= #ifndef SIDE_H #define SIDE_H @@ -14,7 +46,11 @@ #define NEGATIVE_DIR -1 class Grid; + +namespace gg +{ class BoundaryCondition; +} class Side; @@ -29,8 +65,7 @@ class Side { public: virtual ~Side() = default; - - virtual void addIndices(std::vector<SPtr<Grid> > grid, uint level, SPtr<BoundaryCondition> boundaryCondition) = 0; + virtual void addIndices(std::vector<SPtr<Grid> > grid, uint level, SPtr<gg::BoundaryCondition> boundaryCondition) = 0; virtual int getCoordinate() const = 0; virtual int getDirection() const = 0; @@ -38,12 +73,14 @@ public: virtual SideType whoAmI() const = 0; protected: - static void addIndices(SPtr<Grid> grid, SPtr<BoundaryCondition> boundaryCondition, std::string coord, real constant, + static void addIndices(SPtr<Grid> grid, SPtr<gg::BoundaryCondition> boundaryCondition, std::string coord, real constant, real startInner, real endInner, real startOuter, real endOuter); - static void setPressureNeighborIndices(SPtr<BoundaryCondition> boundaryCondition, SPtr<Grid> grid, const uint index); + static void setPressureNeighborIndices(SPtr<gg::BoundaryCondition> boundaryCondition, SPtr<Grid> grid, const uint index); + + static void setStressSamplingIndices(SPtr<gg::BoundaryCondition> boundaryCondition, SPtr<Grid> grid, const uint index); - static void setQs(SPtr<Grid> grid, SPtr<BoundaryCondition> boundaryCondition, uint index); + static void setQs(SPtr<Grid> grid, SPtr<gg::BoundaryCondition> boundaryCondition, uint index); private: static uint getIndex(SPtr<Grid> grid, std::string coord, real constant, real v1, real v2); @@ -52,7 +89,7 @@ private: class Geometry : public Side { public: - void addIndices(std::vector<SPtr<Grid> > grid, uint level, SPtr<BoundaryCondition> boundaryCondition) override; + void addIndices(std::vector<SPtr<Grid> > grid, uint level, SPtr<gg::BoundaryCondition> boundaryCondition) override; int getCoordinate() const override { @@ -73,7 +110,7 @@ public: class MX : public Side { public: - void addIndices(std::vector<SPtr<Grid> > grid, uint level, SPtr<BoundaryCondition> boundaryCondition) override; + void addIndices(std::vector<SPtr<Grid> > grid, uint level, SPtr<gg::BoundaryCondition> boundaryCondition) override; int getCoordinate() const override { @@ -94,7 +131,7 @@ public: class PX : public Side { public: - void addIndices(std::vector<SPtr<Grid> > grid, uint level, SPtr<BoundaryCondition> boundaryCondition) override; + void addIndices(std::vector<SPtr<Grid> > grid, uint level, SPtr<gg::BoundaryCondition> boundaryCondition) override; int getCoordinate() const override { @@ -116,7 +153,7 @@ public: class MY : public Side { public: - void addIndices(std::vector<SPtr<Grid> > grid, uint level, SPtr<BoundaryCondition> boundaryCondition) override; + void addIndices(std::vector<SPtr<Grid> > grid, uint level, SPtr<gg::BoundaryCondition> boundaryCondition) override; int getCoordinate() const override { @@ -137,7 +174,7 @@ public: class PY : public Side { public: - void addIndices(std::vector<SPtr<Grid> > grid, uint level, SPtr<BoundaryCondition> boundaryCondition) override; + void addIndices(std::vector<SPtr<Grid> > grid, uint level, SPtr<gg::BoundaryCondition> boundaryCondition) override; int getCoordinate() const override { @@ -159,7 +196,7 @@ public: class MZ : public Side { public: - void addIndices(std::vector<SPtr<Grid> > grid, uint level, SPtr<BoundaryCondition> boundaryCondition) override; + void addIndices(std::vector<SPtr<Grid> > grid, uint level, SPtr<gg::BoundaryCondition> boundaryCondition) override; int getCoordinate() const override { @@ -180,7 +217,7 @@ public: class PZ : public Side { public: - void addIndices(std::vector<SPtr<Grid> > grid, uint level, SPtr<BoundaryCondition> boundaryCondition) override; + void addIndices(std::vector<SPtr<Grid> > grid, uint level, SPtr<gg::BoundaryCondition> boundaryCondition) override; int getCoordinate() const override { diff --git a/src/gpu/GridGenerator/grid/Cell.h b/src/gpu/GridGenerator/grid/Cell.h index 0d6c3e13d391a451201131eb27216102b3545077..f39bd4a7bb13be0d768e092276194e6bad16dcff 100644 --- a/src/gpu/GridGenerator/grid/Cell.h +++ b/src/gpu/GridGenerator/grid/Cell.h @@ -1,14 +1,44 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids 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. +// +// VirtualFluids 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 VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file Cell.h +//! \ingroup grid +//! \author Soeren Peters, Stephan Lenz +//======================================================================================= #ifndef CELL_H #define CELL_H #include "gpu/GridGenerator/global.h" -#include "gpu/GridGenerator/utilities/cuda/cudaDefines.h" - struct Point { - HOSTDEVICE Point() : x(0.0), y(0.0), z(0.0) {} - HOSTDEVICE Point(real x, real y, real z) : x(x), y(y), z(z) {} + Point() : x(0.0), y(0.0), z(0.0) {} + Point(real x, real y, real z) : x(x), y(y), z(z) {} real x, y, z; }; @@ -18,7 +48,7 @@ public: typedef Point* iterator; typedef const Point* const_iterator; - HOSTDEVICE Cell(real startX, real startY, real startZ, real delta) + Cell(real startX, real startY, real startZ, real delta) { points = new Point[size]; points[0] = Point(startX, startY, startZ); // 0,0,0 @@ -32,15 +62,15 @@ public: points[7] = Point(startX + delta, startY + delta, startZ + delta); // 1,1,1 } - HOSTDEVICE ~Cell() + ~Cell() { delete[] points; } - HOSTDEVICE iterator begin() { return &points[0]; } - HOSTDEVICE const_iterator begin() const { return &points[0]; } - HOSTDEVICE iterator end() { return &points[size]; } - HOSTDEVICE const_iterator end() const { return &points[size]; } + iterator begin() { return &points[0]; } + const_iterator begin() const { return &points[0]; } + iterator end() { return &points[size]; } + const_iterator end() const { return &points[size]; } private: Point* points; diff --git a/src/gpu/GridGenerator/grid/Field.cpp b/src/gpu/GridGenerator/grid/Field.cpp new file mode 100644 index 0000000000000000000000000000000000000000..ef038b3d227ff08f1ef71579f3df4546c61d3e5d --- /dev/null +++ b/src/gpu/GridGenerator/grid/Field.cpp @@ -0,0 +1,183 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids 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. +// +// VirtualFluids 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 VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file Field.cpp +//! \ingroup grid +//! \author Soeren Peters, Stephan Lenz, Martin Schoenherr +//======================================================================================= +#include "Field.h" + +#include "grid/NodeValues.h" + +using namespace vf::gpu; + +Field::Field(uint size) : size(size) +{ + +} + +void Field::allocateMemory() +{ + this->field = new char[this->size]; +} + +void Field::freeMemory() +{ + delete[] this->field; +} + +// --------------------------------------------------------- // +// Getter // +// --------------------------------------------------------- // +uint Field::getSize() const +{ + return this->size; +} + +char Field::getFieldEntry(uint index) const +{ + return this->field[index]; +} + +// --------------------------------------------------------- // +// Is // +// --------------------------------------------------------- // +bool Field::is(uint index, char type) const +{ + return field[index] == type; +} + +bool Field::isCoarseToFineNode(uint index) const +{ + return field[index] == FLUID_CFC; +} + +bool Field::isFineToCoarseNode(uint index) const +{ + return field[index] == FLUID_FCC; +} + +bool Field::isFluid(uint index) const +{ + const char type = field[index]; + return type == FLUID || type == FLUID_CFC || type == FLUID_CFF || type == FLUID_FCC || type == FLUID_FCF || isBoundaryConditionNode(index); +} + +bool Field::isFluidNodeOfSpecialInterest(uint index) const +{ + const char type = field[index]; + return isBoundaryConditionNode(index); +} + +bool Field::isInvalidSolid(uint index) const +{ + return field[index] == INVALID_SOLID; +} + +bool Field::isInvalidOutOfGrid(uint index) const +{ + return field[index] == INVALID_OUT_OF_GRID; +} + +bool Field::isInvalidCoarseUnderFine(uint index) const +{ + return field[index] == INVALID_COARSE_UNDER_FINE; +} + +bool Field::isStopperOutOfGrid(uint index) const +{ + return field[index] == STOPPER_OUT_OF_GRID; +} + +bool Field::isStopperCoarseUnderFine(uint index) const +{ + return field[index] == STOPPER_COARSE_UNDER_FINE; +} + +bool Field::isStopperSolid(uint index) const +{ + return field[index] == STOPPER_SOLID; +} + +bool Field::isStopper(uint index) const +{ + return isStopperOutOfGrid(index) || isStopperCoarseUnderFine(index) || isStopperSolid(index) || is(index, STOPPER_OUT_OF_GRID_BOUNDARY); +} + +bool Field::isQ(uint index) const +{ + return field[index] == Q_DEPRECATED; +} + +bool Field::isBoundaryConditionNode(uint index) const +{ + return field[index] == BC_SOLID || field[index] == BC_OUTFLOW || field[index] == BC_VELOCITY || field[index] == BC_PRESSURE || field[index] == BC_SLIP || field[index] == BC_STRESS; +} + +// --------------------------------------------------------- // +// Setter // +// --------------------------------------------------------- // +void Field::setFieldEntry(uint index, char val) +{ + this->field[index] = val; +} + +void Field::setFieldEntryToFluid(uint index) +{ + this->field[index] = FLUID; +} + +void Field::setFieldEntryToInvalidSolid(uint index) +{ + this->field[index] = INVALID_SOLID; +} + +void Field::setFieldEntryToStopperOutOfGrid(uint index) +{ + this->field[index] = STOPPER_OUT_OF_GRID; +} + +void Field::setFieldEntryToStopperOutOfGridBoundary(uint index) +{ + this->field[index] = STOPPER_OUT_OF_GRID_BOUNDARY; +} + +void Field::setFieldEntryToStopperCoarseUnderFine(uint index) +{ + this->field[index] = STOPPER_COARSE_UNDER_FINE; +} + +void Field::setFieldEntryToInvalidCoarseUnderFine(uint index) +{ + this->field[index] = INVALID_COARSE_UNDER_FINE; +} + +void Field::setFieldEntryToInvalidOutOfGrid(uint index) +{ + this->field[index] = INVALID_OUT_OF_GRID; +} diff --git a/src/gpu/GridGenerator/grid/Field.cu b/src/gpu/GridGenerator/grid/Field.cu deleted file mode 100644 index 7982a23be0fa62c7afefdb339a3eb0f1513528d2..0000000000000000000000000000000000000000 --- a/src/gpu/GridGenerator/grid/Field.cu +++ /dev/null @@ -1,162 +0,0 @@ -#include "Field.h" - -#include "grid/NodeValues.h" -#include "grid/GridStrategy/GridStrategy.h" - -using namespace vf::gpu; - -CUDA_HOST Field::Field(SPtr<GridStrategy> gridStrategy, uint size) : gridStrategy(gridStrategy), size(size) -{ - -} - -Field::Field() -{ - -} - -Field::~Field() -{ - -} - -CUDA_HOST void Field::allocateMemory() -{ - gridStrategy->allocateFieldMemory(this); -} - -CUDA_HOST void Field::freeMemory() -{ - gridStrategy->freeFieldMemory(this); -} - -// --------------------------------------------------------- // -// Getter // -// --------------------------------------------------------- // -HOSTDEVICE uint Field::getSize() const -{ - return this->size; -} - -HOSTDEVICE char Field::getFieldEntry(uint index) const -{ - return this->field[index]; -} - -// --------------------------------------------------------- // -// Is // -// --------------------------------------------------------- // -HOSTDEVICE bool Field::is(uint index, char type) const -{ - return field[index] == type; -} - -HOSTDEVICE bool Field::isCoarseToFineNode(uint index) const -{ - return field[index] == FLUID_CFC; -} - -HOSTDEVICE bool Field::isFineToCoarseNode(uint index) const -{ - return field[index] == FLUID_FCC; -} - -HOSTDEVICE bool Field::isFluid(uint index) const -{ - const char type = field[index]; - return type == FLUID || type == FLUID_CFC || type == FLUID_CFF || type == FLUID_FCC || type == FLUID_FCF || isBoundaryConditionNode(index); -} - -HOSTDEVICE bool Field::isFluidNodeOfSpecialInterest(uint index) const -{ - const char type = field[index]; - return isBoundaryConditionNode(index); -} - -HOSTDEVICE bool Field::isInvalidSolid(uint index) const -{ - return field[index] == INVALID_SOLID; -} - -HOSTDEVICE bool Field::isInvalidOutOfGrid(uint index) const -{ - return field[index] == INVALID_OUT_OF_GRID; -} - -HOSTDEVICE bool Field::isInvalidCoarseUnderFine(uint index) const -{ - return field[index] == INVALID_COARSE_UNDER_FINE; -} - -HOSTDEVICE bool Field::isStopperOutOfGrid(uint index) const -{ - return field[index] == STOPPER_OUT_OF_GRID; -} - -HOSTDEVICE bool Field::isStopperCoarseUnderFine(uint index) const -{ - return field[index] == STOPPER_COARSE_UNDER_FINE; -} - -HOSTDEVICE bool Field::isStopperSolid(uint index) const -{ - return field[index] == STOPPER_SOLID; -} - -HOSTDEVICE bool Field::isStopper(uint index) const -{ - return isStopperOutOfGrid(index) || isStopperCoarseUnderFine(index) || isStopperSolid(index) || is(index, STOPPER_OUT_OF_GRID_BOUNDARY); -} - -HOSTDEVICE bool Field::isQ(uint index) const -{ - return field[index] == Q_DEPRECATED; -} - -HOSTDEVICE bool Field::isBoundaryConditionNode(uint index) const -{ - return field[index] == BC_SOLID || field[index] == BC_OUTFLOW || field[index] == BC_VELOCITY || field[index] == BC_PRESSURE || field[index] == BC_SLIP; -} - -// --------------------------------------------------------- // -// Setter // -// --------------------------------------------------------- // -HOSTDEVICE void Field::setFieldEntry(uint index, char val) -{ - this->field[index] = val; -} - -HOSTDEVICE void Field::setFieldEntryToFluid(uint index) -{ - this->field[index] = FLUID; -} - -HOSTDEVICE void Field::setFieldEntryToInvalidSolid(uint index) -{ - this->field[index] = INVALID_SOLID; -} - -HOSTDEVICE void Field::setFieldEntryToStopperOutOfGrid(uint index) -{ - this->field[index] = STOPPER_OUT_OF_GRID; -} - -HOSTDEVICE void Field::setFieldEntryToStopperOutOfGridBoundary(uint index) -{ - this->field[index] = STOPPER_OUT_OF_GRID_BOUNDARY; -} - -HOSTDEVICE void Field::setFieldEntryToStopperCoarseUnderFine(uint index) -{ - this->field[index] = STOPPER_COARSE_UNDER_FINE; -} - -HOSTDEVICE void Field::setFieldEntryToInvalidCoarseUnderFine(uint index) -{ - this->field[index] = INVALID_COARSE_UNDER_FINE; -} - -HOSTDEVICE void Field::setFieldEntryToInvalidOutOfGrid(uint index) -{ - this->field[index] = INVALID_OUT_OF_GRID; -} diff --git a/src/gpu/GridGenerator/grid/Field.h b/src/gpu/GridGenerator/grid/Field.h index d2ad5ca782ff68f1983108609c7bb23e729985b0..329b587fe2b7b644e4f4b2263f5196f1f758ad4e 100644 --- a/src/gpu/GridGenerator/grid/Field.h +++ b/src/gpu/GridGenerator/grid/Field.h @@ -1,55 +1,80 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids 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. +// +// VirtualFluids 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 VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file Field.h +//! \ingroup grid +//! \author Soeren Peters, Stephan Lenz, Martin Schoenherr +//======================================================================================= #ifndef FIELD_H #define FIELD_H #include "gpu/GridGenerator/global.h" struct Vertex; -class GridStrategy; class GRIDGENERATOR_EXPORT Field : public enableSharedFromThis<Field> { public: - CUDA_HOST Field(SPtr<GridStrategy> gridStrategy, uint size); - HOSTDEVICE Field(); - HOSTDEVICE ~Field(); - CUDA_HOST void allocateMemory(); - CUDA_HOST void freeMemory(); - - HOSTDEVICE uint getSize() const; - HOSTDEVICE char getFieldEntry(uint index) const; - - HOSTDEVICE bool is(uint index, char type) const; - HOSTDEVICE bool isCoarseToFineNode(uint index) const; - HOSTDEVICE bool isFineToCoarseNode(uint index) const; - HOSTDEVICE bool isFluid(uint index) const; - HOSTDEVICE bool isFluidNodeOfSpecialInterest(uint index) const; - HOSTDEVICE bool isInvalidSolid(uint index) const; - HOSTDEVICE bool isQ(uint index) const; - HOSTDEVICE bool isBoundaryConditionNode(uint index) const; - HOSTDEVICE bool isInvalidCoarseUnderFine(uint index) const; - HOSTDEVICE bool isStopperOutOfGrid(uint index) const; - HOSTDEVICE bool isStopperCoarseUnderFine(uint index) const; - HOSTDEVICE bool isStopperSolid(uint index) const; - HOSTDEVICE bool isStopper(uint index) const; - HOSTDEVICE bool isInvalidOutOfGrid(uint index) const; - - HOSTDEVICE void setFieldEntry(uint index, char val); - HOSTDEVICE void setFieldEntryToFluid(uint index); - HOSTDEVICE void setFieldEntryToInvalidSolid(uint index); - HOSTDEVICE void setFieldEntryToStopperOutOfGrid(uint index); - HOSTDEVICE void setFieldEntryToStopperOutOfGridBoundary(uint index); - HOSTDEVICE void setFieldEntryToStopperCoarseUnderFine(uint index); - HOSTDEVICE void setFieldEntryToInvalidCoarseUnderFine(uint index); - HOSTDEVICE void setFieldEntryToInvalidOutOfGrid(uint index); + Field(uint size); + Field() = default; + void allocateMemory(); + void freeMemory(); -private: - SPtr<GridStrategy> gridStrategy; + uint getSize() const; + char getFieldEntry(uint index) const; + + bool is(uint index, char type) const; + bool isCoarseToFineNode(uint index) const; + bool isFineToCoarseNode(uint index) const; + bool isFluid(uint index) const; + bool isFluidNodeOfSpecialInterest(uint index) const; + bool isInvalidSolid(uint index) const; + bool isQ(uint index) const; + bool isBoundaryConditionNode(uint index) const; + bool isInvalidCoarseUnderFine(uint index) const; + bool isStopperOutOfGrid(uint index) const; + bool isStopperCoarseUnderFine(uint index) const; + bool isStopperSolid(uint index) const; + bool isStopper(uint index) const; + bool isInvalidOutOfGrid(uint index) const; + + void setFieldEntry(uint index, char val); + void setFieldEntryToFluid(uint index); + void setFieldEntryToInvalidSolid(uint index); + void setFieldEntryToStopperOutOfGrid(uint index); + void setFieldEntryToStopperOutOfGridBoundary(uint index); + void setFieldEntryToStopperCoarseUnderFine(uint index); + void setFieldEntryToInvalidCoarseUnderFine(uint index); + void setFieldEntryToInvalidOutOfGrid(uint index); +private: char *field; uint size; - - friend class GridGpuStrategy; - friend class GridCpuStrategy; }; #endif diff --git a/src/gpu/GridGenerator/grid/Grid.h b/src/gpu/GridGenerator/grid/Grid.h index 36d607bc06c759b3dc7a7d27dfacbe383283a24e..3f28120a5d969fcc5d7b2a3402a2169ff97c0cc3 100644 --- a/src/gpu/GridGenerator/grid/Grid.h +++ b/src/gpu/GridGenerator/grid/Grid.h @@ -1,3 +1,35 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids 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. +// +// VirtualFluids 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 VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file Grid.h +//! \ingroup grid +//! \author Soeren Peters, Stephan Lenz, Martin Sch�nherr +//======================================================================================= #ifndef GRID_H #define GRID_H @@ -12,7 +44,6 @@ class TriangularMesh; struct Vertex; struct Triangle; -class GridStrategy; class GridInterface; class Object; class BoundingBox; @@ -20,125 +51,122 @@ class BoundingBox; class GRIDGENERATOR_EXPORT Grid { public: - HOSTDEVICE virtual ~Grid() {} + virtual ~Grid() = default; - HOSTDEVICE virtual const Object* getObject() const = 0; + virtual const Object* getObject() const = 0; - HOSTDEVICE virtual real getDelta() const = 0; - HOSTDEVICE virtual uint getSparseSize() const = 0; - HOSTDEVICE virtual uint getSize() const = 0; + virtual real getDelta() const = 0; + virtual uint getSparseSize() const = 0; + virtual uint getSize() const = 0; - HOSTDEVICE virtual real getStartX() const = 0; - HOSTDEVICE virtual real getStartY() const = 0; - HOSTDEVICE virtual real getStartZ() const = 0; + virtual real getStartX() const = 0; + virtual real getStartY() const = 0; + virtual real getStartZ() const = 0; - HOSTDEVICE virtual real getEndX() const = 0; - HOSTDEVICE virtual real getEndY() const = 0; - HOSTDEVICE virtual real getEndZ() const = 0; + virtual real getEndX() const = 0; + virtual real getEndY() const = 0; + virtual real getEndZ() const = 0; - HOSTDEVICE virtual Vertex getMinimumOnNode(Vertex exact) const = 0; - HOSTDEVICE virtual Vertex getMaximumOnNode(Vertex exact) const = 0; + virtual Vertex getMinimumOnNode(Vertex exact) const = 0; + virtual Vertex getMaximumOnNode(Vertex exact) const = 0; - HOSTDEVICE virtual uint getNumberOfNodesX() const = 0; - HOSTDEVICE virtual uint getNumberOfNodesY() const = 0; - HOSTDEVICE virtual uint getNumberOfNodesZ() const = 0; + virtual uint getNumberOfNodesX() const = 0; + virtual uint getNumberOfNodesY() const = 0; + virtual uint getNumberOfNodesZ() const = 0; - HOSTDEVICE virtual uint getNumberOfNodesCF() const = 0; - HOSTDEVICE virtual uint getNumberOfNodesFC() const = 0; + virtual uint getNumberOfNodesCF() const = 0; + virtual uint getNumberOfNodesFC() const = 0; - HOSTDEVICE virtual int getSparseIndex(uint matrixIndex) const = 0; - HOSTDEVICE virtual char getFieldEntry(uint matrixIndex) const = 0; - HOSTDEVICE virtual void setFieldEntry(uint matrixIndex, char type) = 0; + virtual int getSparseIndex(uint matrixIndex) const = 0; + virtual char getFieldEntry(uint matrixIndex) const = 0; + virtual void setFieldEntry(uint matrixIndex, char type) = 0; - CUDA_HOST virtual void getGridInterfaceIndices(uint* iCellCfc, uint* iCellCff, uint* iCellFcc, uint* iCellFcf) const = 0; - CUDA_HOST virtual bool isSparseIndexInFluidNodeIndicesBorder(uint &sparseIndex) const = 0; + virtual void getGridInterfaceIndices(uint* iCellCfc, uint* iCellCff, uint* iCellFcc, uint* iCellFcf) const = 0; + virtual bool isSparseIndexInFluidNodeIndicesBorder(uint &sparseIndex) const = 0; - CUDA_HOST virtual int *getNeighborsX() const = 0; - CUDA_HOST virtual int *getNeighborsY() const = 0; - CUDA_HOST virtual int *getNeighborsZ() const = 0; - CUDA_HOST virtual int *getNeighborsNegative() const = 0; + virtual int *getNeighborsX() const = 0; + virtual int *getNeighborsY() const = 0; + virtual int *getNeighborsZ() const = 0; + virtual int *getNeighborsNegative() const = 0; - CUDA_HOST virtual uint* getCF_coarse() const = 0; - CUDA_HOST virtual uint* getCF_fine() const = 0; - CUDA_HOST virtual uint* getCF_offset() const = 0; + virtual uint *getCF_coarse() const = 0; + virtual uint *getCF_fine() const = 0; + virtual uint *getCF_offset() const = 0; - CUDA_HOST virtual uint* getFC_coarse() const = 0; - CUDA_HOST virtual uint* getFC_fine() const = 0; - CUDA_HOST virtual uint* getFC_offset() const = 0; + virtual uint *getFC_coarse() const = 0; + virtual uint *getFC_fine() const = 0; + virtual uint *getFC_offset() const = 0; - CUDA_HOST virtual real* getDistribution() const = 0; - CUDA_HOST virtual int* getDirection() const = 0; - CUDA_HOST virtual int getStartDirection() const = 0; - CUDA_HOST virtual int getEndDirection() const = 0; + virtual real *getDistribution() const = 0; + virtual int* getDirection() const = 0; + virtual int getStartDirection() const = 0; + virtual int getEndDirection() const = 0; - CUDA_HOST virtual void getNodeValues(real *xCoords, real *yCoords, real *zCoords, uint *neighborX, uint *neighborY, uint *neighborZ, uint *neighborNegative, uint *geo) const = 0; + virtual void getNodeValues(real *xCoords, real *yCoords, real *zCoords, uint *neighborX, uint *neighborY, uint *neighborZ, uint *neighborNegative, uint *geo) const = 0; - CUDA_HOST virtual SPtr<GridStrategy> getGridStrategy() const = 0; - HOSTDEVICE virtual void transIndexToCoords(uint index, real &x, real &y, real &z) const = 0; - HOSTDEVICE virtual uint transCoordToIndex(const real &x, const real &y, const real &z) const = 0; + virtual void transIndexToCoords(uint index, real &x, real &y, real &z) const = 0; + virtual uint transCoordToIndex(const real &x, const real &y, const real &z) const = 0; - CUDA_HOST virtual void inital(const SPtr<Grid> fineGrid, uint numberOfLayers) = 0; + virtual void inital(const SPtr<Grid> fineGrid, uint numberOfLayers) = 0; - CUDA_HOST virtual void setOddStart( bool xOddStart, bool yOddStart, bool zOddStart ) = 0; + virtual void setOddStart(bool xOddStart, bool yOddStart, bool zOddStart) = 0; - CUDA_HOST virtual void findGridInterface(SPtr<Grid> grid, LbmOrGks lbmOrGks) = 0; + virtual void findGridInterface(SPtr<Grid> grid, LbmOrGks lbmOrGks) = 0; - HOSTDEVICE virtual void repairGridInterfaceOnMultiGPU(SPtr<Grid> fineGrid) = 0; + virtual void repairGridInterfaceOnMultiGPU(SPtr<Grid> fineGrid) = 0; - CUDA_HOST virtual void limitToSubDomain(SPtr<BoundingBox> subDomainBox, LbmOrGks lbmOrGks) = 0; - - CUDA_HOST virtual void enableFindSolidBoundaryNodes() = 0; - CUDA_HOST virtual void enableComputeQs() = 0; + virtual void limitToSubDomain(SPtr<BoundingBox> subDomainBox, LbmOrGks lbmOrGks) = 0; - CUDA_HOST virtual void mesh(TriangularMesh& geometry) = 0; - CUDA_HOST virtual void mesh(Object* object) = 0; + virtual void enableFindSolidBoundaryNodes() = 0; + virtual void enableComputeQs() = 0; - CUDA_HOST virtual void closeNeedleCells() = 0; - CUDA_HOST virtual void closeNeedleCellsThinWall() = 0; + virtual void mesh(TriangularMesh &geometry) = 0; + virtual void mesh(Object *object) = 0; - CUDA_HOST virtual void findQs(Object* object) = 0; + virtual void closeNeedleCells() = 0; + virtual void closeNeedleCellsThinWall() = 0; - CUDA_HOST virtual void setPeriodicity(bool periodicityX, bool periodicityY, bool periodicityZ) = 0; - CUDA_HOST virtual void setPeriodicityX(bool periodicity) = 0; - CUDA_HOST virtual void setPeriodicityY(bool periodicity) = 0; - CUDA_HOST virtual void setPeriodicityZ(bool periodicity) = 0; + virtual void findQs(Object *object) = 0; - CUDA_HOST virtual bool getPeriodicityX() = 0; - CUDA_HOST virtual bool getPeriodicityY() = 0; - CUDA_HOST virtual bool getPeriodicityZ() = 0; + virtual void setPeriodicity(bool periodicityX, bool periodicityY, bool periodicityZ) = 0; + virtual void setPeriodicityX(bool periodicity) = 0; + virtual void setPeriodicityY(bool periodicity) = 0; + virtual void setPeriodicityZ(bool periodicity) = 0; - CUDA_HOST virtual void setEnableFixRefinementIntoTheWall( bool enableFixRefinementIntoTheWall ) = 0; + virtual bool getPeriodicityX() = 0; + virtual bool getPeriodicityY() = 0; + virtual bool getPeriodicityZ() = 0; - CUDA_HOST virtual void freeMemory() = 0; + virtual void setEnableFixRefinementIntoTheWall(bool enableFixRefinementIntoTheWall) = 0; + virtual void freeMemory() = 0; - HOSTDEVICE virtual bool nodeInCellIs(Cell& cell, char type) const = 0; + virtual bool nodeInCellIs(Cell& cell, char type) const = 0; - CUDA_HOST virtual void findSparseIndices(SPtr<Grid> fineGrid) = 0; + virtual void findSparseIndices(SPtr<Grid> fineGrid) = 0; - HOSTDEVICE virtual real getFirstFluidNode(real coords[3], int direction, real startCoord) const = 0; - HOSTDEVICE virtual real getLastFluidNode(real coords[3], int direction, real startCoord) const = 0; + virtual real getFirstFluidNode(real coords[3], int direction, real startCoord) const = 0; + virtual real getLastFluidNode(real coords[3], int direction, real startCoord) const = 0; - CUDA_HOST virtual uint getNumberOfSolidBoundaryNodes() const = 0; - CUDA_HOST virtual void setNumberOfSolidBoundaryNodes(uint numberOfSolidBoundaryNodes) = 0; + virtual uint getNumberOfSolidBoundaryNodes() const = 0; + virtual void setNumberOfSolidBoundaryNodes(uint numberOfSolidBoundaryNodes) = 0; - CUDA_HOST virtual real getQValue(const uint index, const uint dir) const = 0; - CUDA_HOST virtual uint getQPatch(const uint index) const = 0; + virtual real getQValue(const uint index, const uint dir) const = 0; + virtual uint getQPatch(const uint index) const = 0; - CUDA_HOST virtual void setInnerRegionFromFinerGrid( bool innerRegionFromFinerGrid ) = 0; + virtual void setInnerRegionFromFinerGrid(bool innerRegionFromFinerGrid) = 0; - CUDA_HOST virtual void setNumberOfLayers( uint numberOfLayers ) = 0; + virtual void setNumberOfLayers(uint numberOfLayers) = 0; virtual void findCommunicationIndices(int direction, SPtr<BoundingBox> subDomainBox, LbmOrGks lbmOrGks) = 0; - virtual uint getNumberOfSendNodes(int direction) = 0; - virtual uint getNumberOfReceiveNodes(int direction) = 0; - - virtual bool isSendNode(int index) const = 0; - virtual bool isReceiveNode(int index) const = 0; + virtual uint getNumberOfSendNodes(int direction) = 0; + virtual uint getNumberOfReceiveNodes(int direction) = 0; - virtual uint getSendIndex(int direction, uint index) = 0; - virtual uint getReceiveIndex(int direction, uint index) = 0; + virtual bool isSendNode(int index) const = 0; + virtual bool isReceiveNode(int index) const = 0; + virtual uint getSendIndex(int direction, uint index) = 0; + virtual uint getReceiveIndex(int direction, uint index) = 0; virtual void repairCommunicationIndices(int direction) = 0; diff --git a/src/gpu/GridGenerator/grid/GridBuilder/GridBuilder.h b/src/gpu/GridGenerator/grid/GridBuilder/GridBuilder.h index 3d516c6710d44d5c8da45c0f71e36ea21e6e9655..6fe296ebdc90902b7dfe10ef95b0238532c6dd3c 100644 --- a/src/gpu/GridGenerator/grid/GridBuilder/GridBuilder.h +++ b/src/gpu/GridGenerator/grid/GridBuilder/GridBuilder.h @@ -1,3 +1,35 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids 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. +// +// VirtualFluids 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 VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file GridBuilder.h +//! \ingroup grid +//! \author Soeren Peters, Stephan Lenz, Martin Sch�nherr +//======================================================================================= #ifndef GridBuilder_H #define GridBuilder_H @@ -28,7 +60,10 @@ class Grid; enum class SideType; +namespace gg +{ class BoundaryCondition; +} class GeometryBoundaryCondition; class GridBuilder @@ -43,10 +78,9 @@ public: virtual void getGridInformations(std::vector<int>& gridX, std::vector<int>& gridY, std::vector<int>& gridZ, std::vector<int>& distX, std::vector<int>& distY, std::vector<int>& distZ) = 0; virtual GRIDGENERATOR_EXPORT uint getNumberOfGridLevels() const = 0; - virtual void writeArrows(std::string fileName) const = 0; - virtual SPtr<Grid> getGrid(uint level) = 0; + virtual SPtr<Grid> getGrid(uint level) = 0; virtual unsigned int getNumberOfNodes(unsigned int level) const = 0; virtual void getNodeValues(real *xCoords, real *yCoords, real *zCoords, @@ -60,36 +94,46 @@ public: virtual void getOffsetFC(real* xOffCf, real* yOffCf, real* zOffCf, int level) = 0; virtual void getOffsetCF(real* xOffFc, real* yOffFc, real* zOffFc, int level) = 0; + virtual uint getSlipSize(int level) const = 0; + virtual void getSlipValues(real *normalX, real *normalY, real *normalZ, int *indices, int level) const = 0; + virtual void getSlipQs(real* qs[27], int level) const = 0; + + virtual uint getStressSize(int level) const = 0; + virtual void getStressValues(real *normalX, real *normalY, real *normalZ, + real* vx1, real* vy1, real* vz1, + real* vx, real* vy, real* vz, + int *indices, int* samplingIndices, int* samplingOffsets, real* z0, int level) const = 0; + virtual void getStressQs(real* qs[27], int level) const = 0; + virtual uint getVelocitySize(int level) const = 0; virtual void getVelocityValues(real* vx, real* vy, real* vz, int* indices, int level) const = 0; - virtual uint getPressureSize(int level) const = 0; - virtual void getPressureValues(real* rho, int* indices, int* neighborIndices, int level) const = 0; virtual void getVelocityQs(real* qs[27], int level) const = 0; - virtual void getPressureQs(real* qs[27], int level) const = 0; - virtual uint getGeometrySize(int level) const = 0; - virtual void getGeometryIndices(int* indices, int level) const = 0; - virtual void getGeometryQs(real* qs[27], int level) const = 0; - virtual bool hasGeometryValues() const = 0; - virtual void getGeometryValues(real* vx, real* vy, real* vz, int level) const = 0; + virtual uint getPressureSize(int level) const = 0; + virtual void getPressureValues(real *rho, int *indices, int *neighborIndices, int level) const = 0; + virtual void getPressureQs(real *qs[27], int level) const = 0; - virtual uint getCommunicationProcess(int direction) = 0; + virtual uint getGeometrySize(int level) const = 0; + virtual void getGeometryIndices(int *indices, int level) const = 0; + virtual void getGeometryQs(real *qs[27], int level) const = 0; + virtual bool hasGeometryValues() const = 0; + virtual void getGeometryValues(real *vx, real *vy, real *vz, int level) const = 0; - virtual SPtr<BoundaryCondition> getBoundaryCondition( SideType side, uint level ) const = 0; + virtual SPtr<gg::BoundaryCondition> getBoundaryCondition(SideType side, uint level) const = 0; - virtual SPtr<GeometryBoundaryCondition> getGeometryBoundaryCondition( uint level ) const = 0; + virtual SPtr<GeometryBoundaryCondition> getGeometryBoundaryCondition(uint level) const = 0; - virtual uint getNumberOfSendIndices( int direction, uint level ) = 0; - virtual uint getNumberOfReceiveIndices( int direction, uint level ) = 0; - virtual void getSendIndices( int* sendIndices, int direction, int level ) = 0; - virtual void getReceiveIndices( int* sendIndices, int direction, int level ) = 0; + virtual uint getCommunicationProcess(int direction) = 0; virtual uint getNumberOfFluidNodes(unsigned int level) const = 0; virtual void getFluidNodeIndices(uint *fluidNodeIndices, const int level) const = 0; virtual uint getNumberOfFluidNodesBorder(unsigned int level) const = 0; virtual void getFluidNodeIndicesBorder(uint *fluidNodeIndices, const int level) const = 0; + virtual uint getNumberOfSendIndices(int direction, uint level) = 0; + virtual uint getNumberOfReceiveIndices(int direction, uint level) = 0; + virtual void getSendIndices(int *sendIndices, int direction, int level) = 0; + virtual void getReceiveIndices(int *sendIndices, int direction, int level) = 0; }; -#endif - +#endif \ No newline at end of file diff --git a/src/gpu/GridGenerator/grid/GridBuilder/LevelGridBuilder.cpp b/src/gpu/GridGenerator/grid/GridBuilder/LevelGridBuilder.cpp index 13d9d22134ee1731e317a76c3e5d0a561c580547..4c1574fc02c01fa634915a5fb66dbd88064ccd80 100644 --- a/src/gpu/GridGenerator/grid/GridBuilder/LevelGridBuilder.cpp +++ b/src/gpu/GridGenerator/grid/GridBuilder/LevelGridBuilder.cpp @@ -1,3 +1,35 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids 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. +// +// VirtualFluids 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 VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file LevelGridBuilder.cpp +//! \ingroup grid +//! \author Soeren Peters, Stephan Lenz, Martin Sch�nherr +//======================================================================================= #include "LevelGridBuilder.h" #include <stdio.h> @@ -5,35 +37,30 @@ #include <algorithm> #include "geometries/Arrow/ArrowImp.h" -#include "geometries/Triangle/Triangle.h" #include "geometries/BoundingBox/BoundingBox.h" +#include "geometries/Triangle/Triangle.h" #include "geometries/TriangularMesh/TriangularMesh.h" #include "grid/BoundaryConditions/BoundaryCondition.h" #include "grid/BoundaryConditions/Side.h" -#include "grid/GridStrategy/GridGpuStrategy/GridGpuStrategy.h" -#include "grid/GridStrategy/GridCpuStrategy/GridCpuStrategy.h" -#include "grid/partition/Partition.h" -#include "grid/NodeValues.h" +#include "grid/Grid.h" #include "grid/GridFactory.h" #include "grid/GridInterface.h" -#include "grid/Grid.h" +#include "grid/NodeValues.h" #include "io/GridVTKWriter/GridVTKWriter.h" -#include "io/SimulationFileWriter/SimulationFileWriter.h" -#include "io/VTKWriterWrapper/UnstructuredGridWrapper.h" -#include "io/VTKWriterWrapper/PolyDataWriterWrapper.h" #include "io/QLineWriter.h" +#include "io/SimulationFileWriter/SimulationFileWriter.h" -#include "utilities/transformator/ArrowTransformator.h" #include "utilities/communication.h" +#include "utilities/transformator/ArrowTransformator.h" #define GEOFLUID 19 #define GEOSOLID 16 using namespace vf::gpu; -LevelGridBuilder::LevelGridBuilder(Device device, const std::string& d3qxx) : device(device), d3qxx(d3qxx) +LevelGridBuilder::LevelGridBuilder() { this->communicationProcesses[CommunicationDirections::MX] = INVALID_INDEX; this->communicationProcesses[CommunicationDirections::PX] = INVALID_INDEX; @@ -43,9 +70,45 @@ LevelGridBuilder::LevelGridBuilder(Device device, const std::string& d3qxx) : de this->communicationProcesses[CommunicationDirections::PZ] = INVALID_INDEX; } -std::shared_ptr<LevelGridBuilder> LevelGridBuilder::makeShared(Device device, const std::string& d3qxx) +std::shared_ptr<LevelGridBuilder> LevelGridBuilder::makeShared() +{ + return SPtr<LevelGridBuilder>(new LevelGridBuilder()); +} + +void LevelGridBuilder::setSlipBoundaryCondition(SideType sideType, real nomalX, real normalY, real normalZ) +{ + SPtr<SlipBoundaryCondition> slipBoundaryCondition = SlipBoundaryCondition::make(nomalX, normalY, normalZ); + + auto side = SideFactory::make(sideType); + + slipBoundaryCondition->side = side; + slipBoundaryCondition->side->addIndices(grids, 0, slipBoundaryCondition); + + slipBoundaryCondition->fillSlipNormalLists(); + boundaryConditions[0]->slipBoundaryConditions.push_back(slipBoundaryCondition); + + *logging::out << logging::Logger::INFO_INTERMEDIATE << "Set Slip BC on level " << 0 << " with " << (int)slipBoundaryCondition->indices.size() << "\n"; +} + +void LevelGridBuilder::setStressBoundaryCondition( SideType sideType, + real nomalX, real normalY, real normalZ, + uint samplingOffset, real z0) { - return SPtr<LevelGridBuilder>(new LevelGridBuilder(device, d3qxx)); + SPtr<StressBoundaryCondition> stressBoundaryCondition = StressBoundaryCondition::make(nomalX, normalY, normalZ, samplingOffset, z0); + + auto side = SideFactory::make(sideType); + + stressBoundaryCondition->side = side; + stressBoundaryCondition->side->addIndices(grids, 0, stressBoundaryCondition); + + stressBoundaryCondition->fillStressNormalLists(); + stressBoundaryCondition->fillSamplingOffsetLists(); + stressBoundaryCondition->fillZ0Lists(); + // stressBoundaryCondition->fillSamplingIndices(grids, 0, samplingOffset); //redundant with Side::setStressSamplingIndices but potentially a better approach for cases with complex geometries + + boundaryConditions[0]->stressBoundaryConditions.push_back(stressBoundaryCondition); + + *logging::out << logging::Logger::INFO_INTERMEDIATE << "Set Stress BC on level " << 0 << " with " << (int)stressBoundaryCondition->indices.size() << "\n"; } void LevelGridBuilder::setVelocityBoundaryCondition(SideType sideType, real vx, real vy, real vz) @@ -125,14 +188,16 @@ void LevelGridBuilder::setNoSlipBoundaryCondition(SideType sideType) noSlipBoundaryCondition->side = side; noSlipBoundaryCondition->side->addIndices(grids, level, noSlipBoundaryCondition); - boundaryConditions[level]->noSlipBoundaryConditions.push_back(noSlipBoundaryCondition); + noSlipBoundaryCondition->fillVelocityLists(); + + boundaryConditions[level]->velocityBoundaryConditions.push_back(noSlipBoundaryCondition); //now effectively just a wrapper for velocityBC with zero velocity. No distinction in Gridgenerator. } } GRIDGENERATOR_EXPORT void LevelGridBuilder::setEnableFixRefinementIntoTheWall(bool enableFixRefinementIntoTheWall) { - for( uint level = 0; level < this->grids.size(); level++ ) - grids[level]->setEnableFixRefinementIntoTheWall( enableFixRefinementIntoTheWall ); + for (uint level = 0; level < this->grids.size(); level++) + grids[level]->setEnableFixRefinementIntoTheWall(enableFixRefinementIntoTheWall); } GRIDGENERATOR_EXPORT void LevelGridBuilder::setCommunicationProcess(int direction, uint process) @@ -145,19 +210,6 @@ GRIDGENERATOR_EXPORT uint LevelGridBuilder::getCommunicationProcess(int directio return this->communicationProcesses[direction]; } - - -void LevelGridBuilder::copyDataFromGpu() -{ - for (const auto& grid : grids) - { - auto gridGpuStrategy = std::dynamic_pointer_cast<GridGpuStrategy>(grid->getGridStrategy()); - if(gridGpuStrategy) - gridGpuStrategy->copyDataFromGPU(std::static_pointer_cast<GridImp>(grid)); - } - -} - LevelGridBuilder::~LevelGridBuilder() { for (const auto& grid : grids) @@ -174,7 +226,7 @@ void LevelGridBuilder::getGridInformations(std::vector<int>& gridX, std::vector< std::vector<int>& gridZ, std::vector<int>& distX, std::vector<int>& distY, std::vector<int>& distZ) { - for (const auto& grid : grids) + for (const auto &grid : grids) { gridX.push_back(int(grid->getNumberOfNodesX())); gridY.push_back(int(grid->getNumberOfNodesY())); @@ -292,7 +344,6 @@ void LevelGridBuilder::getNodeValues(real *xCoords, real *yCoords, real *zCoords grids[level]->getNodeValues(xCoords, yCoords, zCoords, neighborX, neighborY, neighborZ, neighborNegative, geo); } -//TODO: add getSlipSize... GRIDGENERATOR_EXPORT void LevelGridBuilder::getFluidNodeIndices(uint *fluidNodeIndices, const int level) const { @@ -314,62 +365,126 @@ GRIDGENERATOR_EXPORT uint LevelGridBuilder::getNumberOfFluidNodesBorder(unsigned return grids[level]->getNumberOfFluidNodesBorder(); } -uint LevelGridBuilder::getVelocitySize(int level) const +uint LevelGridBuilder::getSlipSize(int level) const { uint size = 0; - for (auto boundaryCondition : boundaryConditions[level]->velocityBoundaryConditions) + for (auto boundaryCondition : boundaryConditions[level]->slipBoundaryConditions) { size += uint(boundaryCondition->indices.size()); } return size; } -//TODO: add getSlipIndices... - +void LevelGridBuilder::getSlipValues(real* normalX, real* normalY, real* normalZ, int* indices, int level) const +{ + int allIndicesCounter = 0; + for (auto boundaryCondition : boundaryConditions[level]->slipBoundaryConditions) + { + for (uint index = 0; index < boundaryCondition->indices.size(); index++) + { + indices[allIndicesCounter] = grids[level]->getSparseIndex(boundaryCondition->indices[index]) + 1; + + normalX[allIndicesCounter] = boundaryCondition->getNormalx(index); + normalY[allIndicesCounter] = boundaryCondition->getNormaly(index); + normalZ[allIndicesCounter] = boundaryCondition->getNormalz(index); + allIndicesCounter++; + } + } +} -void LevelGridBuilder::getVelocityValues(real* vx, real* vy, real* vz, int* indices, int level) const +void LevelGridBuilder::getSlipQs(real* qs[27], int level) const { int allIndicesCounter = 0; - for (auto boundaryCondition : boundaryConditions[level]->velocityBoundaryConditions) + for (auto boundaryCondition : boundaryConditions[level]->slipBoundaryConditions) { - for(std::size_t i = 0; i < boundaryCondition->indices.size(); i++) + for (uint index = 0; index < boundaryCondition->indices.size(); index++) { - indices[allIndicesCounter] = grids[level]->getSparseIndex(boundaryCondition->indices[i]) +1; - vx[allIndicesCounter] = (real)boundaryCondition->getVx((uint)i); - vy[allIndicesCounter] = (real)boundaryCondition->getVy((uint)i); - vz[allIndicesCounter] = (real)boundaryCondition->getVz((uint)i); + for (int dir = 0; dir <= grids[level]->getEndDirection(); dir++) + { + qs[dir][allIndicesCounter] = boundaryCondition->qs[index][dir]; + } allIndicesCounter++; } } } -uint LevelGridBuilder::getPressureSize(int level) const +uint LevelGridBuilder::getStressSize(int level) const { uint size = 0; - for (auto boundaryCondition : boundaryConditions[level]->pressureBoundaryConditions) + for (auto boundaryCondition : boundaryConditions[level]->stressBoundaryConditions) { size += uint(boundaryCondition->indices.size()); } return size; } -void LevelGridBuilder::getPressureValues(real* rho, int* indices, int* neighborIndices, int level) const +void LevelGridBuilder::getStressValues( real* normalX, real* normalY, real* normalZ, + real* vx, real* vy, real* vz, + real* vx1, real* vy1, real* vz1, + int* indices, int* samplingIndices, int* samplingOffset, real* z0, int level) const { + int allIndicesCounter = 0; - for (auto boundaryCondition : boundaryConditions[level]->pressureBoundaryConditions) + for (auto boundaryCondition : boundaryConditions[level]->stressBoundaryConditions) { - for (std::size_t i = 0; i < boundaryCondition->indices.size(); i++) + for (uint index = 0; index < boundaryCondition->indices.size(); index++) { - indices[allIndicesCounter] = grids[level]->getSparseIndex(boundaryCondition->indices[i]) + 1; + indices[allIndicesCounter] = grids[level]->getSparseIndex(boundaryCondition->indices[index]) + 1; + samplingIndices[allIndicesCounter] = grids[level]->getSparseIndex(boundaryCondition->velocitySamplingIndices[index]) + 1; - neighborIndices[allIndicesCounter] = grids[level]->getSparseIndex(boundaryCondition->neighborIndices[i]) + 1; + normalX[allIndicesCounter] = boundaryCondition->getNormalx(index); + normalY[allIndicesCounter] = boundaryCondition->getNormaly(index); + normalZ[allIndicesCounter] = boundaryCondition->getNormalz(index); - rho[allIndicesCounter] = boundaryCondition->rho; + samplingOffset[allIndicesCounter] = boundaryCondition->getSamplingOffset(index); + z0[allIndicesCounter] = boundaryCondition->getZ0(index); allIndicesCounter++; } } } +void LevelGridBuilder::getStressQs(real* qs[27], int level) const +{ + int allIndicesCounter = 0; + for (auto boundaryCondition : boundaryConditions[level]->stressBoundaryConditions) + { + for (uint index = 0; index < boundaryCondition->indices.size(); index++) + { + for (int dir = 0; dir <= grids[level]->getEndDirection(); dir++) + { + qs[dir][allIndicesCounter] = boundaryCondition->qs[index][dir]; + } + allIndicesCounter++; + } + } +} + +uint LevelGridBuilder::getVelocitySize(int level) const +{ + uint size = 0; + for (auto boundaryCondition : boundaryConditions[level]->velocityBoundaryConditions) + { + size += uint(boundaryCondition->indices.size()); + } + return size; +} + +void LevelGridBuilder::getVelocityValues(real* vx, real* vy, real* vz, int* indices, int level) const +{ + int allIndicesCounter = 0; + for (auto boundaryCondition : boundaryConditions[level]->velocityBoundaryConditions) + { + for(std::size_t i = 0; i < boundaryCondition->indices.size(); i++) + { + indices[allIndicesCounter] = grids[level]->getSparseIndex(boundaryCondition->indices[i]) +1; + + vx[allIndicesCounter] = boundaryCondition->getVx((uint)i); + vy[allIndicesCounter] = boundaryCondition->getVy((uint)i); + vz[allIndicesCounter] = boundaryCondition->getVz((uint)i); + allIndicesCounter++; + } + } +} void LevelGridBuilder::getVelocityQs(real* qs[27], int level) const { @@ -381,23 +496,34 @@ void LevelGridBuilder::getVelocityQs(real* qs[27], int level) const for (int dir = 0; dir <= grids[level]->getEndDirection(); dir++) { qs[dir][allIndicesCounter] = boundaryCondition->qs[index][dir]; + } + allIndicesCounter++; + } + } +} - //real x,y,z; - //grids[level]->transIndexToCoords( index, x, y, z ); +uint LevelGridBuilder::getPressureSize(int level) const +{ + uint size = 0; + for (auto boundaryCondition : boundaryConditions[level]->pressureBoundaryConditions) + { + size += uint(boundaryCondition->indices.size()); + } + return size; +} - //x += grids[level]->getDirection()[dir * DIMENSION + 0] * grids[level]->getDelta(); - //y += grids[level]->getDirection()[dir * DIMENSION + 1] * grids[level]->getDelta(); - //z += grids[level]->getDirection()[dir * DIMENSION + 2] * grids[level]->getDelta(); +void LevelGridBuilder::getPressureValues(real* rho, int* indices, int* neighborIndices, int level) const +{ + int allIndicesCounter = 0; + for (auto boundaryCondition : boundaryConditions[level]->pressureBoundaryConditions) + { + for (std::size_t i = 0; i < boundaryCondition->indices.size(); i++) + { + indices[allIndicesCounter] = grids[level]->getSparseIndex(boundaryCondition->indices[i]) + 1; - //uint neighborIndex = grids[level]->transCoordToIndex( x, y, z ); + neighborIndices[allIndicesCounter] = grids[level]->getSparseIndex(boundaryCondition->neighborIndices[i]) + 1; - //if( grids[level]->getFieldEntry(neighborIndex) == STOPPER_OUT_OF_GRID_BOUNDARY || - // grids[level]->getFieldEntry(neighborIndex) == STOPPER_OUT_OF_GRID || - // grids[level]->getFieldEntry(neighborIndex) == STOPPER_SOLID) - // qs[dir][allIndicesCounter] = 0.5; - //else - // qs[dir][allIndicesCounter] = -1.0; - } + rho[allIndicesCounter] = boundaryCondition->rho; allIndicesCounter++; } } @@ -413,29 +539,12 @@ void LevelGridBuilder::getPressureQs(real* qs[27], int level) const for (int dir = 0; dir <= grids[level]->getEndDirection(); dir++) { qs[dir][allIndicesCounter] = boundaryCondition->qs[index][dir]; - - //real x,y,z; - //grids[level]->transIndexToCoords( index, x, y, z ); - - //x += grids[level]->getDirection()[dir * DIMENSION + 0] * grids[level]->getDelta(); - //y += grids[level]->getDirection()[dir * DIMENSION + 1] * grids[level]->getDelta(); - //z += grids[level]->getDirection()[dir * DIMENSION + 2] * grids[level]->getDelta(); - - //uint neighborIndex = grids[level]->transCoordToIndex( x, y, z ); - - //if( grids[level]->getFieldEntry(neighborIndex) == STOPPER_OUT_OF_GRID_BOUNDARY || - // grids[level]->getFieldEntry(neighborIndex) == STOPPER_OUT_OF_GRID || - // grids[level]->getFieldEntry(neighborIndex) == STOPPER_SOLID) - // qs[dir][allIndicesCounter] = 0.5; - //else - // qs[dir][allIndicesCounter] = -1.0; } allIndicesCounter++; } } } - uint LevelGridBuilder::getGeometrySize(int level) const { if (boundaryConditions[level]->geometryBoundaryCondition) @@ -457,7 +566,6 @@ bool LevelGridBuilder::hasGeometryValues() const return geometryHasValues; } - void LevelGridBuilder::getGeometryValues(real* vx, real* vy, real* vz, int level) const { for (uint i = 0; i < boundaryConditions[level]->geometryBoundaryCondition->indices.size(); i++) @@ -468,7 +576,6 @@ void LevelGridBuilder::getGeometryValues(real* vx, real* vy, real* vz, int level } } - void LevelGridBuilder::getGeometryQs(real* qs[27], int level) const { for (std::size_t i = 0; i < boundaryConditions[level]->geometryBoundaryCondition->indices.size(); i++) @@ -480,28 +587,28 @@ void LevelGridBuilder::getGeometryQs(real* qs[27], int level) const } } - - - - void LevelGridBuilder::writeArrows(std::string fileName) const { QLineWriter::writeArrows(fileName, boundaryConditions[getNumberOfGridLevels() - 1]->geometryBoundaryCondition, grids[getNumberOfGridLevels() - 1]); } -GRIDGENERATOR_EXPORT SPtr<BoundaryCondition> LevelGridBuilder::getBoundaryCondition(SideType side, uint level) const +GRIDGENERATOR_EXPORT SPtr<gg::BoundaryCondition> LevelGridBuilder::getBoundaryCondition(SideType side, uint level) const { - for( auto bc : this->boundaryConditions[level]->pressureBoundaryConditions ) - if( bc->isSide(side) ) + for (auto bc : this->boundaryConditions[level]->slipBoundaryConditions) + if (bc->isSide(side)) return bc; - - for( auto bc : this->boundaryConditions[level]->velocityBoundaryConditions ) + + for (auto bc : this->boundaryConditions[level]->velocityBoundaryConditions) if( bc->isSide(side) ) return bc; + for (auto bc : this->boundaryConditions[level]->pressureBoundaryConditions) + if (bc->isSide(side)) + return bc; + auto bc = this->boundaryConditions[level]->geometryBoundaryCondition; - - if( bc && bc->isSide(side) ) + + if (bc && bc->isSide(side)) return bc; return nullptr; diff --git a/src/gpu/GridGenerator/grid/GridBuilder/LevelGridBuilder.h b/src/gpu/GridGenerator/grid/GridBuilder/LevelGridBuilder.h index f90bbe231a64a2d1c51536fd96fa69792c1348da..a11f0d20da1cb671dfcb073d85e4add1da9646fb 100644 --- a/src/gpu/GridGenerator/grid/GridBuilder/LevelGridBuilder.h +++ b/src/gpu/GridGenerator/grid/GridBuilder/LevelGridBuilder.h @@ -1,3 +1,35 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids 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. +// +// VirtualFluids 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 VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file LevelGridBuilder.h +//! \ingroup grid +//! \author Soeren Peters, Stephan Lenz, Martin Sch�nherr +//======================================================================================= #ifndef LEVEL_GRID_BUILDER_H #define LEVEL_GRID_BUILDER_H @@ -11,6 +43,7 @@ #include "gpu/GridGenerator/grid/GridBuilder/GridBuilder.h" #include "gpu/GridGenerator/grid/Grid.h" #include "gpu/GridGenerator/grid/GridInterface.h" +#include "gpu/GridGenerator/grid/NodeValues.h" struct Vertex; class Grid; @@ -18,10 +51,11 @@ class Transformator; class ArrowTransformator; class PolyDataWriterWrapper; class BoundingBox; -enum class Device; class Side; class VelocityBoundaryCondition; +class SlipBoundaryCondition; +class StressBoundaryCondition; class PressureBoundaryCondition; class GeometryBoundaryCondition; enum class SideType; @@ -31,22 +65,23 @@ enum class SideType; class LevelGridBuilder : public GridBuilder { protected: - GRIDGENERATOR_EXPORT LevelGridBuilder(Device device, const std::string& d3qxx); + GRIDGENERATOR_EXPORT LevelGridBuilder(); public: - GRIDGENERATOR_EXPORT static std::shared_ptr<LevelGridBuilder> makeShared(Device device, const std::string& d3qxx); + GRIDGENERATOR_EXPORT static std::shared_ptr<LevelGridBuilder> makeShared(); GRIDGENERATOR_EXPORT SPtr<Grid> getGrid(uint level) override; - GRIDGENERATOR_EXPORT void copyDataFromGpu(); GRIDGENERATOR_EXPORT virtual ~LevelGridBuilder(); + GRIDGENERATOR_EXPORT void setSlipBoundaryCondition(SideType sideType, real nomalX, real normalY, real normalZ); + GRIDGENERATOR_EXPORT void setStressBoundaryCondition(SideType sideType, real nomalX, real normalY, real normalZ, uint samplingOffset, real z0); GRIDGENERATOR_EXPORT void setVelocityBoundaryCondition(SideType sideType, real vx, real vy, real vz); GRIDGENERATOR_EXPORT void setPressureBoundaryCondition(SideType sideType, real rho); GRIDGENERATOR_EXPORT void setPeriodicBoundaryCondition(bool periodic_X, bool periodic_Y, bool periodic_Z); GRIDGENERATOR_EXPORT void setNoSlipBoundaryCondition(SideType sideType); - GRIDGENERATOR_EXPORT void setEnableFixRefinementIntoTheWall( bool enableFixRefinementIntoTheWall ); + GRIDGENERATOR_EXPORT void setEnableFixRefinementIntoTheWall(bool enableFixRefinementIntoTheWall); GRIDGENERATOR_EXPORT void setCommunicationProcess(int direction, uint process); @@ -67,23 +102,34 @@ public: GRIDGENERATOR_EXPORT virtual void getDimensions(int &nx, int &ny, int &nz, const int level) const override; + GRIDGENERATOR_EXPORT uint getSlipSize(int level) const override; + GRIDGENERATOR_EXPORT virtual void getSlipValues(real* normalX, real* normalY, real* normalZ, int* indices, int level) const override; + GRIDGENERATOR_EXPORT virtual void getSlipQs(real* qs[27], int level) const override; + + GRIDGENERATOR_EXPORT uint getStressSize(int level) const override; + GRIDGENERATOR_EXPORT virtual void getStressValues( real* normalX, real* normalY, real* normalZ, + real* vx, real* vy, real* vz, + real* vx1, real* vy1, real* vz1, + int* indices, int* samplingIndices, int* samplingOffsets, real* z0, int level) const override; + GRIDGENERATOR_EXPORT virtual void getStressQs(real* qs[27], int level) const override; + GRIDGENERATOR_EXPORT uint getVelocitySize(int level) const override; GRIDGENERATOR_EXPORT virtual void getVelocityValues(real* vx, real* vy, real* vz, int* indices, int level) const override; GRIDGENERATOR_EXPORT virtual void getVelocityQs(real* qs[27], int level) const override; + GRIDGENERATOR_EXPORT uint getPressureSize(int level) const override; GRIDGENERATOR_EXPORT void getPressureValues(real* rho, int* indices, int* neighborIndices, int level) const override; GRIDGENERATOR_EXPORT virtual void getPressureQs(real* qs[27], int level) const override; - GRIDGENERATOR_EXPORT virtual void getGeometryQs(real* qs[27], int level) const override; + GRIDGENERATOR_EXPORT virtual void getGeometryQs(real *qs[27], int level) const override; GRIDGENERATOR_EXPORT virtual uint getGeometrySize(int level) const override; - GRIDGENERATOR_EXPORT virtual void getGeometryIndices(int* indices, int level) const override; + GRIDGENERATOR_EXPORT virtual void getGeometryIndices(int *indices, int level) const override; GRIDGENERATOR_EXPORT virtual bool hasGeometryValues() const override; - GRIDGENERATOR_EXPORT virtual void getGeometryValues(real* vx, real* vy, real* vz, int level) const override; - + GRIDGENERATOR_EXPORT virtual void getGeometryValues(real *vx, real *vy, real *vz, int level) const override; GRIDGENERATOR_EXPORT void writeArrows(std::string fileName) const override; - GRIDGENERATOR_EXPORT SPtr<BoundaryCondition> getBoundaryCondition( SideType side, uint level ) const override; + GRIDGENERATOR_EXPORT SPtr<gg::BoundaryCondition> getBoundaryCondition( SideType side, uint level ) const override; GRIDGENERATOR_EXPORT SPtr<GeometryBoundaryCondition> getGeometryBoundaryCondition(uint level) const override; protected: @@ -91,16 +137,17 @@ protected: struct BoundaryConditions { - BoundaryConditions() : geometryBoundaryCondition(nullptr) {} + BoundaryConditions() {} - std::vector<SPtr<VelocityBoundaryCondition> > velocityBoundaryConditions; - std::vector<SPtr<PressureBoundaryCondition> > pressureBoundaryConditions; + std::vector<SPtr<SlipBoundaryCondition>> slipBoundaryConditions; - //TODO: add slip BC + std::vector<SPtr<StressBoundaryCondition>> stressBoundaryConditions; + std::vector<SPtr<VelocityBoundaryCondition>> velocityBoundaryConditions; + std::vector<SPtr<PressureBoundaryCondition>> pressureBoundaryConditions; - std::vector<SPtr<VelocityBoundaryCondition> > noSlipBoundaryConditions; + std::vector<SPtr<VelocityBoundaryCondition>> noSlipBoundaryConditions; SPtr<GeometryBoundaryCondition> geometryBoundaryCondition; }; @@ -108,7 +155,7 @@ protected: std::vector<std::shared_ptr<Grid> > grids; std::vector<SPtr<BoundaryConditions> > boundaryConditions; - + std::array<uint, 6> communicationProcesses; void checkLevel(int level); @@ -123,10 +170,6 @@ protected: Vertex getVertex(const int matrixIndex) const; -private: - Device device; - std::string d3qxx; - public: GRIDGENERATOR_EXPORT void getGridInformations(std::vector<int>& gridX, std::vector<int>& gridY, std::vector<int>& gridZ, std::vector<int>& distX, std::vector<int>& distY, @@ -141,10 +184,10 @@ public: GRIDGENERATOR_EXPORT void getOffsetFC(real* xOffCf, real* yOffCf, real* zOffCf, int level) override; GRIDGENERATOR_EXPORT void getOffsetCF(real* xOffFc, real* yOffFc, real* zOffFc, int level) override; - GRIDGENERATOR_EXPORT uint getNumberOfSendIndices( int direction, uint level ) override; - GRIDGENERATOR_EXPORT uint getNumberOfReceiveIndices( int direction, uint level ) override; - GRIDGENERATOR_EXPORT void getSendIndices( int* sendIndices, int direction, int level ) override; - GRIDGENERATOR_EXPORT void getReceiveIndices( int* sendIndices, int direction, int level ) override; + GRIDGENERATOR_EXPORT uint getNumberOfSendIndices(int direction, uint level) override; + GRIDGENERATOR_EXPORT uint getNumberOfReceiveIndices(int direction, uint level) override; + GRIDGENERATOR_EXPORT void getSendIndices(int *sendIndices, int direction, int level) override; + GRIDGENERATOR_EXPORT void getReceiveIndices(int *sendIndices, int direction, int level) override; }; #endif diff --git a/src/gpu/GridGenerator/grid/GridBuilder/MultipleGridBuilder.cpp b/src/gpu/GridGenerator/grid/GridBuilder/MultipleGridBuilder.cpp index fb9f2624dac8ef88662ae631eaa04344915eb587..0d903b9a4fdb067155dd6b9ee6c60257a63b3ad0 100644 --- a/src/gpu/GridGenerator/grid/GridBuilder/MultipleGridBuilder.cpp +++ b/src/gpu/GridGenerator/grid/GridBuilder/MultipleGridBuilder.cpp @@ -1,3 +1,35 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids 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. +// +// VirtualFluids 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 VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file MultipleGridBuilder.cpp +//! \ingroup grid +//! \author Soeren Peters, Stephan Lenz, Martin Sch�nherr +//======================================================================================= #include "MultipleGridBuilder.h" #include <sstream> @@ -14,11 +46,10 @@ #include "grid/Grid.h" #include "grid/GridFactory.h" -#include "io/STLReaderWriter/STLWriter.h" #include "io/GridVTKWriter/GridVTKWriter.h" +#include "io/STLReaderWriter/STLWriter.h" -MultipleGridBuilder::MultipleGridBuilder(SPtr<GridFactory> gridFactory, Device device, const std::string &d3qxx) : - LevelGridBuilder(device, d3qxx), gridFactory(gridFactory), solidObject(nullptr), numberOfLayersFine(12), numberOfLayersBetweenLevels(8), subDomainBox(nullptr) +MultipleGridBuilder::MultipleGridBuilder(SPtr<GridFactory> gridFactory) : LevelGridBuilder(), gridFactory(gridFactory), numberOfLayersFine(12), numberOfLayersBetweenLevels(8), subDomainBox(nullptr) { } @@ -60,9 +91,6 @@ void MultipleGridBuilder::addGeometry(Object* solidObject, uint level) auto gridShape = solidObject->clone(); gridShape->scale(4.0); - //TriangularMesh* triangularMesh = dynamic_cast<TriangularMesh*>(gridShape); - //STLWriter::writeSTL(triangularMesh->triangleVec, "D:/GRIDGENERATION/STL/bridge.stl"); - this->addGrid(gridShape, level); } @@ -124,7 +152,6 @@ void MultipleGridBuilder::addIntermediateGridsToList(uint levelDifference, uint { auto spacings = getSpacingFactors(levelDifference); - // start = startFine - SUM(nodesBetweenGrids * 2^i * dxfine) uint level = getNumberOfLevels(); for (int i = levelDifference - 1; i >= 0; i--) { @@ -166,7 +193,6 @@ void MultipleGridBuilder::addGridToListIfValid(SPtr<Grid> grid) addGridToList(grid); } - SPtr<Grid> MultipleGridBuilder::makeGrid(Object* gridShape, real startX, real startY, real startZ, real endX, real endY, real endZ, real delta, uint level) const { return gridFactory->makeGrid(gridShape, startX, startY, startZ, endX, endY, endZ, delta, level); @@ -366,6 +392,7 @@ bool MultipleGridBuilder::isGridInCoarseGrid(SPtr<Grid> grid) const vf::Math::lessEqual(grid->getEndZ(), grids[0]->getEndZ()); } + uint MultipleGridBuilder::getNumberOfLevels() const { return uint(grids.size()); @@ -577,7 +604,6 @@ GRIDGENERATOR_EXPORT void MultipleGridBuilder::setNumberOfLayers(uint numberOfLa this->numberOfLayersBetweenLevels = numberOfLayersBetweenLevels; } - void MultipleGridBuilder::emitNoCoarseGridExistsWarning() { *logging::out << logging::Logger::WARNING << "No Coarse grid was added before. Actual Grid is not added, please create coarse grid before.\n"; @@ -617,12 +643,6 @@ void MultipleGridBuilder::writeGridsToVtk(const std::string& path) const GridVTKWriter::writeGridToVTKXML(grids[level], ss.str()); - //if( level != 0 ) - // GridVTKWriter::writeInterpolationCellsToVTKXML(grids[level], grids[level-1], ss.str() + ".InterpolationCells"); - //else - // GridVTKWriter::writeInterpolationCellsToVTKXML(grids[level], nullptr , ss.str() + ".InterpolationCells"); - - //GridVTKWriter::writeSparseGridToVTK(grids[level], ss.str()); } } @@ -630,3 +650,4 @@ GRIDGENERATOR_EXPORT void MultipleGridBuilder::setSubDomainBox(SPtr<BoundingBox> { this->subDomainBox = subDomainBox; } + diff --git a/src/gpu/GridGenerator/grid/GridBuilder/MultipleGridBuilder.h b/src/gpu/GridGenerator/grid/GridBuilder/MultipleGridBuilder.h index 499f8542e915e0bab8d5e7ae1f753f16babded59..e28be0087b44d599a792f2f265d3286b650eca63 100644 --- a/src/gpu/GridGenerator/grid/GridBuilder/MultipleGridBuilder.h +++ b/src/gpu/GridGenerator/grid/GridBuilder/MultipleGridBuilder.h @@ -1,3 +1,35 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids 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. +// +// VirtualFluids 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 VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file MultipleGridBuilder.h +//! \ingroup grid +//! \author Soeren Peters, Stephan Lenz, Martin Schoenherr +//======================================================================================= #ifndef MULTIPLE_GRID_BUILDER_H #define MULTIPLE_GRID_BUILDER_H @@ -10,6 +42,7 @@ #include "grid/GridBuilder/LevelGridBuilder.h" #include "grid/GridFactory.h" +#include "grid/distributions/Distribution.h" class Object; class BoundingBox; @@ -17,17 +50,17 @@ class BoundingBox; class MultipleGridBuilder : public LevelGridBuilder { private: - GRIDGENERATOR_EXPORT MultipleGridBuilder(SPtr<GridFactory> gridFactory, Device device = Device::CPU, const std::string &d3qxx = "D3Q27"); + GRIDGENERATOR_EXPORT MultipleGridBuilder(SPtr<GridFactory> gridFactory); public: GRIDGENERATOR_EXPORT static SPtr<MultipleGridBuilder> makeShared(SPtr<GridFactory> gridFactory); GRIDGENERATOR_EXPORT void addCoarseGrid(real startX, real startY, real startZ, real endX, real endY, real endZ, real delta); - GRIDGENERATOR_EXPORT void addGrid(Object* gridShape); - GRIDGENERATOR_EXPORT void addGrid(Object* gridShape, uint levelFine); + GRIDGENERATOR_EXPORT void addGrid(Object *gridShape); + GRIDGENERATOR_EXPORT void addGrid(Object *gridShape, uint levelFine); - GRIDGENERATOR_EXPORT void addGeometry(Object* gridShape); - GRIDGENERATOR_EXPORT void addGeometry(Object* solidObject, uint level); + GRIDGENERATOR_EXPORT void addGeometry(Object *gridShape); + GRIDGENERATOR_EXPORT void addGeometry(Object *solidObject, uint level); GRIDGENERATOR_EXPORT uint getNumberOfLevels() const; GRIDGENERATOR_EXPORT real getDelta(uint level) const; @@ -45,7 +78,7 @@ public: GRIDGENERATOR_EXPORT void setNumberOfLayers( uint numberOfLayersFine, uint numberOfLayersBetweenLevels ); - GRIDGENERATOR_EXPORT void writeGridsToVtk(const std::string& path) const; + GRIDGENERATOR_EXPORT void writeGridsToVtk(const std::string &path) const; GRIDGENERATOR_EXPORT void setSubDomainBox(SPtr<BoundingBox> subDomainBox); @@ -55,26 +88,24 @@ private: bool coarseGridExists() const; bool isGridInCoarseGrid(SPtr<Grid> grid) const; - void addFineGridToList(uint level, Object* gridShape); - void addIntermediateGridsToList(uint levelDifference, uint levelFine, uint nodesBetweenGrids, Object* gridShape); + void addFineGridToList(uint level, Object *gridShape); + void addIntermediateGridsToList(uint levelDifference, uint levelFine, uint nodesBetweenGrids, Object *gridShape); void eraseGridsFromListIfInvalid(uint oldSize); void addGridToListIfValid(SPtr<Grid> grid); - std::array<real, 6> getStaggeredCoordinates(Object* gridShape, uint level, uint levelFine, bool& xOddStart, bool& yOddStart, bool& zOddStart) const; + std::array<real, 6> getStaggeredCoordinates(Object *gridShape, uint level, uint levelFine, bool &xOddStart, bool &yOddStart, bool &zOddStart) const; std::array<real, 6> getStaggeredCoordinates(real startX, real startY, real startZ, real endX, real endY, real endZ, real delta, uint level) const; std::array<real, 3> getOffset(real delta) const; std::vector<uint> getSpacingFactors(uint levelDifference) const; - SPtr<Grid> makeGrid(Object* gridShape, uint level, uint levelFine); - SPtr<Grid> makeGrid(Object* gridShape, real startX, real startY, real startZ, real endX, real endY, real endZ, real delta, uint level) const; + SPtr<Grid> makeGrid(Object *gridShape, uint level, uint levelFine); + SPtr<Grid> makeGrid(Object *gridShape, real startX, real startY, real startZ, real endX, real endY, real endZ, real delta, uint level) const; static void emitNoCoarseGridExistsWarning(); static void emitGridIsNotInCoarseGridWarning(); - //std::vector<SPtr<Grid> > grids; - SPtr<GridFactory> gridFactory; - Object* solidObject; + Object *solidObject = nullptr; uint numberOfLayersFine; uint numberOfLayersBetweenLevels; @@ -82,8 +113,7 @@ private: SPtr<BoundingBox> subDomainBox; public: - - GRIDGENERATOR_EXPORT void findCommunicationIndices( int direction, LbmOrGks lbmOrGks ); + GRIDGENERATOR_EXPORT void findCommunicationIndices(int direction, LbmOrGks lbmOrGks); // needed for CUDA Streams MultiGPU void findFluidNodes(bool splitDomain); diff --git a/src/gpu/GridGenerator/grid/GridFactory.cpp b/src/gpu/GridGenerator/grid/GridFactory.cpp deleted file mode 100644 index 3e2297c2105908c50485d1556c7060c9a3e15b74..0000000000000000000000000000000000000000 --- a/src/gpu/GridGenerator/grid/GridFactory.cpp +++ /dev/null @@ -1,4 +0,0 @@ -#include "GridFactory.h" - - - diff --git a/src/gpu/GridGenerator/grid/GridFactory.h b/src/gpu/GridGenerator/grid/GridFactory.h index b22d01ea12bbbc2cbf932d7b11eeb404dddffa58..53d358d5325390394f1d38694de605e5cc0d2f56 100644 --- a/src/gpu/GridGenerator/grid/GridFactory.h +++ b/src/gpu/GridGenerator/grid/GridFactory.h @@ -1,22 +1,45 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids 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. +// +// VirtualFluids 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 VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file GridFactory.h +//! \ingroup grid +//! \author Soeren Peters, Stephan Lenz +//======================================================================================= #ifndef GRID_FACTORY_H #define GRID_FACTORY_H #include "global.h" #include "geometries/Cuboid/Cuboid.h" -#include "geometries/Sphere/Sphere.h" #include "geometries/TriangularMesh/TriangularMeshStrategy.h" -#include "grid/GridStrategy/GridCpuStrategy/GridCpuStrategy.h" -#include "grid/GridStrategy/GridGpuStrategy/GridGpuStrategy.h" -#include "grid/distributions/Distribution.h" #include "grid/GridImp.h" -enum class Device -{ - CPU, GPU -}; - enum class TriangularMeshDiscretizationMethod { RAYCASTING, POINT_IN_OBJECT, POINT_UNDER_TRIANGLE @@ -30,44 +53,17 @@ public: return SPtr<GridFactory>(new GridFactory()); } -private: - GridFactory() - { - gridStrategy = SPtr<GridStrategy>(new GridCpuStrategy()); - triangularMeshDiscretizationStrategy = new RayCastingDiscretizationStrategy(); - } - -public: SPtr<Grid> makeGrid(Object* gridShape, real startX, real startY, real startZ, real endX, real endY, real endZ, real delta, uint level, const std::string& d3Qxx = "D3Q27") { - Distribution distribution = DistributionHelper::getDistribution(d3Qxx); - SPtr<GridImp> grid; + + grid = GridImp::makeShared(gridShape, startX, startY, startZ, endX, endY, endZ, delta, d3Qxx, level); - grid = GridImp::makeShared(gridShape, startX, startY, startZ, endX, endY, endZ, delta, gridStrategy, distribution, level); - - grid->setTriangularMeshDiscretizationStrategy(this->triangularMeshDiscretizationStrategy); + grid->setTriangularMeshDiscretizationStrategy(new PointInObjectDiscretizationStrategy()); return grid; } - - void setGridStrategy(Device device) - { - switch (device) - { - case Device::CPU: - gridStrategy = SPtr<GridStrategy>(new GridCpuStrategy()); break; - case Device::GPU: - gridStrategy = SPtr<GridStrategy>(new GridGpuStrategy()); break; - } - } - - void setGridStrategy(SPtr<GridStrategy> gridStrategy) - { - this->gridStrategy = gridStrategy; - } - void setTriangularMeshDiscretizationMethod(TriangularMeshDiscretizationMethod triangularMeshDiscretizationMethod) { switch (triangularMeshDiscretizationMethod) @@ -86,7 +82,6 @@ public: private: TriangularMeshDiscretizationStrategy* triangularMeshDiscretizationStrategy; - SPtr<GridStrategy> gridStrategy; }; diff --git a/src/gpu/GridGenerator/grid/GridImp.cu b/src/gpu/GridGenerator/grid/GridImp.cpp similarity index 74% rename from src/gpu/GridGenerator/grid/GridImp.cu rename to src/gpu/GridGenerator/grid/GridImp.cpp index 84d7b94dd6f204a45790b0bf86857258ede52620..aa2714e492e82b58d50353d458a5889392d3e8f6 100644 --- a/src/gpu/GridGenerator/grid/GridImp.cu +++ b/src/gpu/GridGenerator/grid/GridImp.cpp @@ -1,3 +1,35 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids 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. +// +// VirtualFluids 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 VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file GridImp.cpp +//! \ingroup grid +//! \author Soeren Peters, Stephan Lenz, Martin Schoenherr +//======================================================================================= #include "GridImp.h" #include <stdio.h> @@ -6,6 +38,7 @@ #include <omp.h> #include <sstream> # include <algorithm> +#include <cmath> #include "global.h" @@ -16,7 +49,6 @@ #include "geometries/TriangularMesh/TriangularMeshStrategy.h" #include "geometries/BoundingBox/BoundingBox.h" -#include "grid/GridStrategy/GridStrategy.h" #include "grid/distributions/Distribution.h" #include "grid/Field.h" #include "grid/GridInterface.h" @@ -27,12 +59,11 @@ #include "utilities/communication.h" #include "utilities/math/Math.h" -CONSTANT int DIRECTIONS[DIR_END_MAX][DIMENSION]; +int DIRECTIONS[DIR_END_MAX][DIMENSION]; using namespace vf::gpu; - -CUDA_HOST GridImp::GridImp(Object* object, real startX, real startY, real startZ, real endX, real endY, real endZ, real delta, SPtr<GridStrategy> gridStrategy, Distribution distribution, uint level) +GridImp::GridImp(Object* object, real startX, real startY, real startZ, real endX, real endY, real endZ, real delta, Distribution distribution, uint level) : object(object), startX(startX), startY(startY), @@ -41,7 +72,6 @@ CUDA_HOST GridImp::GridImp(Object* object, real startX, real startY, real startZ endY(endY), endZ(endZ), delta(delta), - gridStrategy(gridStrategy), distribution(distribution), level(level), periodicityX(false), @@ -64,9 +94,10 @@ CUDA_HOST GridImp::GridImp(Object* object, real startX, real startY, real startZ initalNumberOfNodesAndSize(); } -CUDA_HOST SPtr<GridImp> GridImp::makeShared(Object* object, real startX, real startY, real startZ, real endX, real endY, real endZ, real delta, SPtr<GridStrategy> gridStrategy, Distribution d, uint level) +SPtr<GridImp> GridImp::makeShared(Object* object, real startX, real startY, real startZ, real endX, real endY, real endZ, real delta, std::string d3Qxx, uint level) { - SPtr<GridImp> grid(new GridImp(object, startX, startY, startZ, endX, endY, endZ, delta, gridStrategy, d, level)); + Distribution distribution = DistributionHelper::getDistribution(d3Qxx); + SPtr<GridImp> grid(new GridImp(object, startX, startY, startZ, endX, endY, endZ, delta, distribution, level)); return grid; } @@ -77,25 +108,35 @@ void GridImp::initalNumberOfNodesAndSize() const real width = endY - startY; const real height = endZ - startZ; - nx = lround((length + delta) / delta); - ny = lround((width + delta) / delta); - nz = lround((height + delta) / delta); + nx = std::lround((length + delta) / delta); + ny = std::lround((width + delta) / delta); + nz = std::lround((height + delta) / delta); this->size = nx * ny * nz; this->sparseSize = size; distribution.setSize(size); - - this->numberOfSolidBoundaryNodes = 0; } -CUDA_HOST void GridImp::inital(const SPtr<Grid> fineGrid, uint numberOfLayers) +void GridImp::inital(const SPtr<Grid> fineGrid, uint numberOfLayers) { - field = Field(gridStrategy, size); + field = Field(size); field.allocateMemory(); - gridStrategy->allocateGridMemory(shared_from_this()); - + + this->neighborIndexX = new int[this->size]; + this->neighborIndexY = new int[this->size]; + this->neighborIndexZ = new int[this->size]; + this->neighborIndexNegative = new int[this->size]; + + this->sparseIndices = new int[this->size]; + + this->qIndices = new uint[this->size]; + for (uint i = 0; i < this->size; i++) + this->qIndices[i] = INVALID_INDEX; + *logging::out << logging::Logger::INFO_INTERMEDIATE << "Start initalNodesToOutOfGrid()\n"; - gridStrategy->initalNodesToOutOfGrid(shared_from_this()); +#pragma omp parallel for + for (int index = 0; index < (int)this->size; index++) + this->initalNodeToOutOfGrid(index); if( this->innerRegionFromFinerGrid ){ *logging::out << logging::Logger::INFO_INTERMEDIATE << "Start setInnerBasedOnFinerGrid()\n"; @@ -110,54 +151,81 @@ CUDA_HOST void GridImp::inital(const SPtr<Grid> fineGrid, uint numberOfLayers) this->addOverlap(); *logging::out << logging::Logger::INFO_INTERMEDIATE << "Start fixOddCells()\n"; - gridStrategy->fixOddCells( shared_from_this() ); +#pragma omp parallel for + for (int index = 0; index < (int)this->size; index++) + this->fixOddCell(index); if( enableFixRefinementIntoTheWall ) { *logging::out << logging::Logger::INFO_INTERMEDIATE << "Start fixRefinementIntoWall()\n"; - gridStrategy->fixRefinementIntoWall(shared_from_this()); +#pragma omp parallel for + for (int xIdx = 0; xIdx < (int)this->nx; xIdx++) { + for (uint yIdx = 0; yIdx < this->ny; yIdx++) { + this->fixRefinementIntoWall( xIdx, yIdx, 0 , 3 ); + this->fixRefinementIntoWall( xIdx, yIdx, this->nz - 1, -3 ); + } + } + +#pragma omp parallel for + for (int xIdx = 0; xIdx < (int)this->nx; xIdx++) { + for (uint zIdx = 0; zIdx < this->nz; zIdx++) { + this->fixRefinementIntoWall( xIdx, 0 , zIdx, 2 ); + this->fixRefinementIntoWall( xIdx, this->ny - 1, zIdx, -2 ); + } + } + +#pragma omp parallel for + for (int yIdx = 0; yIdx < (int)this->ny; yIdx++) { + for (uint zIdx = 0; zIdx < this->nz; zIdx++) { + this->fixRefinementIntoWall( 0 , yIdx, zIdx, 1 ); + this->fixRefinementIntoWall( this->nx - 1, yIdx, zIdx, -1 ); + } + } } *logging::out << logging::Logger::INFO_INTERMEDIATE << "Start findEndOfGridStopperNodes()\n"; - gridStrategy->findEndOfGridStopperNodes(shared_from_this()); - +#pragma omp parallel for + for (int index = 0; index < (int)this->size; index++) + this->findEndOfGridStopperNode(index); + *logging::out << logging::Logger::INFO_INTERMEDIATE << "Grid created: " << "from (" << this->startX << ", " << this->startY << ", " << this->startZ << ") to (" << this->endX << ", " << this->endY << ", " << this->endZ << ")\n" << "nodes: " << this->nx << " x " << this->ny << " x " << this->nz << " = " << this->size << "\n"; } -CUDA_HOST void GridImp::setOddStart(bool xOddStart, bool yOddStart, bool zOddStart) +void GridImp::setOddStart(bool xOddStart, bool yOddStart, bool zOddStart) { this->xOddStart = xOddStart; this->yOddStart = yOddStart; this->zOddStart = zOddStart; } -HOSTDEVICE void GridImp::initalNodeToOutOfGrid(uint index) -{ +void GridImp::initalNodeToOutOfGrid(uint index) { this->field.setFieldEntryToInvalidOutOfGrid(index); } -CUDA_HOST void GridImp::freeMemory() +void GridImp::freeMemory() { - gridStrategy->freeMemory(shared_from_this()); + if( this->neighborIndexX != nullptr ) { delete[] this->neighborIndexX; this->neighborIndexX = nullptr; } + if( this->neighborIndexY != nullptr ) { delete[] this->neighborIndexY; this->neighborIndexY = nullptr; } + if( this->neighborIndexZ != nullptr ) { delete[] this->neighborIndexZ; this->neighborIndexZ = nullptr; } + if( this->neighborIndexNegative != nullptr ) { delete[] this->neighborIndexNegative; this->neighborIndexNegative = nullptr; } + if( this->sparseIndices != nullptr ) { delete[] this->sparseIndices; this->sparseIndices = nullptr; } + if( this->qIndices != nullptr ) { delete[] this->qIndices; this->qIndices = nullptr; } + if( this->qValues != nullptr ) { delete[] this->qValues; this->qValues = nullptr; } + if( this->qPatches != nullptr ) { delete[] this->qPatches; this->qPatches = nullptr; } - gridStrategy->freeFieldMemory(&field); + field.freeMemory(); } -CUDA_HOST GridImp::GridImp() +void GridImp::findInnerNodes() { - //printf("Constructor\n"); - //this->print(); -} - -CUDA_HOST GridImp::~GridImp() -{ - //printf("Destructor\n"); - //this->print(); +#pragma omp parallel for + for (int index = 0; index < (int)this->size; index++) + this->findInnerNode(index); } -HOSTDEVICE void GridImp::findInnerNode(uint index) +void GridImp::findInnerNode(uint index) { this->sparseIndices[index] = index; @@ -180,7 +248,7 @@ HOSTDEVICE void GridImp::findInnerNode(uint index) } } -HOSTDEVICE void GridImp::discretize(Object* solidObject, char innerType, char outerType) +void GridImp::discretize(Object* solidObject, char innerType, char outerType) { #pragma omp parallel for for (int index = 0; index < (int)this->size; index++) @@ -216,7 +284,7 @@ bool GridImp::isInside(const Cell& cell) const // even even even // odd odd odd // -HOSTDEVICE Cell GridImp::getOddCellFromIndex(uint index) const +Cell GridImp::getOddCellFromIndex(uint index) const { real x, y, z; this->transIndexToCoords(index, x, y, z); @@ -240,7 +308,7 @@ HOSTDEVICE Cell GridImp::getOddCellFromIndex(uint index) const return Cell(xCellStart, yCellStart, zCellStart, delta); } -HOSTDEVICE void GridImp::setInnerBasedOnFinerGrid(const SPtr<Grid> fineGrid) +void GridImp::setInnerBasedOnFinerGrid(const SPtr<Grid> fineGrid) { for( uint index = 0; index < this->size; index++ ){ @@ -267,14 +335,20 @@ HOSTDEVICE void GridImp::setInnerBasedOnFinerGrid(const SPtr<Grid> fineGrid) } } -HOSTDEVICE void GridImp::addOverlap() +void GridImp::addOverlap() { for( uint layer = 0; layer < this->numberOfLayers; layer++ ){ - this->gridStrategy->addOverlap( shared_from_this() ); +#pragma omp parallel for + for (int index = 0; index < (int)this->size; index++) + this->setOverlapTmp(index); + +#pragma omp parallel for + for (int index = 0; index < (int)this->size; index++) + this->setOverlapFluid(index); } } -HOSTDEVICE void GridImp::setOverlapTmp( uint index ) +void GridImp::setOverlapTmp( uint index ) { if( this->field.is( index, INVALID_OUT_OF_GRID ) ){ @@ -284,14 +358,14 @@ HOSTDEVICE void GridImp::setOverlapTmp( uint index ) } } -HOSTDEVICE void GridImp::setOverlapFluid( uint index ) +void GridImp::setOverlapFluid( uint index ) { if( this->field.is( index, OVERLAP_TMP ) ){ this->field.setFieldEntry( index, FLUID ); } } -HOSTDEVICE void GridImp::fixRefinementIntoWall(uint xIndex, uint yIndex, uint zIndex, int dir) +void GridImp::fixRefinementIntoWall(uint xIndex, uint yIndex, uint zIndex, int dir) { real x = this->startX + this->delta * xIndex; @@ -311,7 +385,7 @@ HOSTDEVICE void GridImp::fixRefinementIntoWall(uint xIndex, uint yIndex, uint zI ////////////////////////////////////////////////////////////////////////// - real dx, dy, dz; + real dx{ 0.0 }, dy{ 0.0 }, dz{ 0.0 }; if ( dir == 1 ){ dx = this->delta; dy = 0.0; dz = 0.0; } else if ( dir == -1 ){ dx = - this->delta; dy = 0.0; dz = 0.0; } @@ -350,7 +424,7 @@ HOSTDEVICE void GridImp::fixRefinementIntoWall(uint xIndex, uint yIndex, uint zI } } -HOSTDEVICE void GridImp::findStopperNode(uint index) // deprecated +void GridImp::findStopperNode(uint index) // deprecated { if(isValidEndOfGridStopper(index)) this->field.setFieldEntryToStopperOutOfGrid(index); @@ -359,7 +433,7 @@ HOSTDEVICE void GridImp::findStopperNode(uint index) // deprecated this->field.setFieldEntry(index, STOPPER_SOLID); } -HOSTDEVICE void GridImp::findEndOfGridStopperNode(uint index) +void GridImp::findEndOfGridStopperNode(uint index) { if (isValidEndOfGridStopper(index)){ if( this->level != 0 ) @@ -367,18 +441,18 @@ HOSTDEVICE void GridImp::findEndOfGridStopperNode(uint index) else this->field.setFieldEntryToStopperOutOfGridBoundary(index); } - + if (isValidEndOfGridBoundaryStopper(index)) this->field.setFieldEntryToStopperOutOfGridBoundary(index); } -HOSTDEVICE void GridImp::findSolidStopperNode(uint index) +void GridImp::findSolidStopperNode(uint index) { if (isValidSolidStopper(index)) this->field.setFieldEntry(index, STOPPER_SOLID); } -HOSTDEVICE void GridImp::findBoundarySolidNode(uint index) +void GridImp::findBoundarySolidNode(uint index) { if (shouldBeBoundarySolidNode(index)) { @@ -388,7 +462,7 @@ HOSTDEVICE void GridImp::findBoundarySolidNode(uint index) } } -HOSTDEVICE void GridImp::fixOddCell(uint index) +void GridImp::fixOddCell(uint index) { Cell cell = getOddCellFromIndex(index); if (isOutSideOfGrid(cell)) @@ -397,7 +471,7 @@ HOSTDEVICE void GridImp::fixOddCell(uint index) setNodeTo(cell, FLUID); } -HOSTDEVICE bool GridImp::isOutSideOfGrid(Cell &cell) const +bool GridImp::isOutSideOfGrid(Cell &cell) const { for (const auto point : cell) { if (point.x < startX || point.x > endX @@ -408,7 +482,7 @@ HOSTDEVICE bool GridImp::isOutSideOfGrid(Cell &cell) const return false; } -HOSTDEVICE bool GridImp::contains(Cell &cell, char type) const +bool GridImp::contains(Cell &cell, char type) const { for (const auto point : cell) { uint index = transCoordToIndex(point.x, point.y, point.z); @@ -420,7 +494,7 @@ HOSTDEVICE bool GridImp::contains(Cell &cell, char type) const return false; } -HOSTDEVICE bool GridImp::cellContainsOnly(Cell &cell, char type) const +bool GridImp::cellContainsOnly(Cell &cell, char type) const { for (const auto point : cell) { uint index = transCoordToIndex(point.x, point.y, point.z); @@ -432,7 +506,7 @@ HOSTDEVICE bool GridImp::cellContainsOnly(Cell &cell, char type) const return true; } -HOSTDEVICE bool GridImp::cellContainsOnly(Cell &cell, char typeA, char typeB) const +bool GridImp::cellContainsOnly(Cell &cell, char typeA, char typeB) const { for (const auto point : cell) { uint index = transCoordToIndex(point.x, point.y, point.z); @@ -444,12 +518,12 @@ HOSTDEVICE bool GridImp::cellContainsOnly(Cell &cell, char typeA, char typeB) co return true; } -HOSTDEVICE const Object * GridImp::getObject() const +const Object * GridImp::getObject() const { return this->object; } -HOSTDEVICE void GridImp::setNodeTo(Cell &cell, char type) +void GridImp::setNodeTo(Cell &cell, char type) { for (const auto point : cell) { uint index = transCoordToIndex(point.x, point.y, point.z); @@ -459,61 +533,48 @@ HOSTDEVICE void GridImp::setNodeTo(Cell &cell, char type) } } -HOSTDEVICE void GridImp::setNodeTo(uint index, char type) +void GridImp::setNodeTo(uint index, char type) { if( index != INVALID_INDEX ) field.setFieldEntry(index, type); } -HOSTDEVICE bool GridImp::isNode(uint index, char type) const +bool GridImp::isNode(uint index, char type) const { if( index != INVALID_INDEX ) - return field.is(index, type); + return field.is(index, type); - return false; - // TODO: cannot throw on gpu: throw std::runtime_error("GridImp::isNode() -> index == INVALID_INDEX not supported."); + throw std::runtime_error("GridImp::isNode() -> index == INVALID_INDEX not supported."); } -HOSTDEVICE bool GridImp::isValidEndOfGridStopper(uint index) const +bool GridImp::isValidEndOfGridStopper(uint index) const { // Lenz: also includes corner stopper nodes if (!this->field.is(index, INVALID_OUT_OF_GRID)) return false; return hasNeighborOfType(index, FLUID); - - //previous version of S�ren P. - //return this->field.is(index, OUT_OF_GRID) && (nodeInNextCellIs(index, FLUID) || nodeInNextCellIs(index, FLUID_CFF)) - // || this->field.is(index, OUT_OF_GRID) && (nodeInPreviousCellIs(index, FLUID) || nodeInPreviousCellIs(index, FLUID_CFF)); } -HOSTDEVICE bool GridImp::isValidEndOfGridBoundaryStopper(uint index) const +bool GridImp::isValidEndOfGridBoundaryStopper(uint index) const { // Lenz: also includes corner stopper nodes if (!this->field.is(index, FLUID)) return false; return ! hasAllNeighbors(index); - - //previous version of S�ren P. - //return this->field.is(index, OUT_OF_GRID) && (nodeInNextCellIs(index, FLUID) || nodeInNextCellIs(index, FLUID_CFF)) - // || this->field.is(index, OUT_OF_GRID) && (nodeInPreviousCellIs(index, FLUID) || nodeInPreviousCellIs(index, FLUID_CFF)); } -HOSTDEVICE bool GridImp::isValidSolidStopper(uint index) const +bool GridImp::isValidSolidStopper(uint index) const { // Lenz: also includes corner stopper nodes if (!this->field.is(index, INVALID_SOLID)) return false; return hasNeighborOfType(index, FLUID); - - //previous version of S�ren P. - //return this->field.is(index, SOLID) && (nodeInNextCellIs(index, FLUID) || nodeInNextCellIs(index, FLUID_CFF)) - // || this->field.is(index, SOLID) && (nodeInPreviousCellIs(index, FLUID) || nodeInPreviousCellIs(index, FLUID_CFF)); } -HOSTDEVICE bool GridImp::shouldBeBoundarySolidNode(uint index) const +bool GridImp::shouldBeBoundarySolidNode(uint index) const { if (!this->field.is(index, FLUID)) return false; @@ -521,7 +582,7 @@ HOSTDEVICE bool GridImp::shouldBeBoundarySolidNode(uint index) const return hasNeighborOfType(index, STOPPER_SOLID); } -HOSTDEVICE bool GridImp::hasAllNeighbors(uint index) const +bool GridImp::hasAllNeighbors(uint index) const { // new version by Lenz, utilizes the range based for loop for all directions real x, y, z; @@ -535,7 +596,7 @@ HOSTDEVICE bool GridImp::hasAllNeighbors(uint index) const return true; } -HOSTDEVICE bool GridImp::hasNeighborOfType(uint index, char type) const +bool GridImp::hasNeighborOfType(uint index, char type) const { // new version by Lenz, utilizes the range based for loop for all directions real x, y, z; @@ -550,47 +611,9 @@ HOSTDEVICE bool GridImp::hasNeighborOfType(uint index, char type) const } return false; - - //real x, y, z; - //this->transIndexToCoords(index, x, y, z); - - //const real neighborX = x + this->delta > endX ? endX : x + this->delta; - //const real neighborY = y + this->delta > endY ? endY : y + this->delta; - //const real neighborZ = z + this->delta > endZ ? endZ : z + this->delta; - - //const real neighborMinusX = x - this->delta < startX ? startX : x - this->delta; - //const real neighborMinusY = y - this->delta < startY ? startY : y - this->delta; - //const real neighborMinusZ = z - this->delta < startZ ? startZ : z - this->delta; - - - //const uint indexMXY = transCoordToIndex(-neighborX, neighborY, z); - //const uint indexMYZ = transCoordToIndex(x, -neighborY, neighborZ); - //const uint indexMXZ = transCoordToIndex(-neighborX, y, neighborZ); - - //const uint indexXMY = transCoordToIndex(neighborX, -neighborY, z); - //const uint indexYMZ = transCoordToIndex(x, neighborY, -neighborZ); - //const uint indexXMZ = transCoordToIndex(neighborX, y, -neighborZ); - - //const uint indexMXYMZ = transCoordToIndex(-neighborX, neighborY, -neighborZ); - //const uint indexMXYZ = transCoordToIndex(-neighborX, neighborY, neighborZ); - //const uint indexMXMYZ = transCoordToIndex(-neighborX, -neighborY, neighborZ); - //const uint indexXMYMZ = transCoordToIndex(neighborX, -neighborY, -neighborZ); - //const uint indexXMYZ = transCoordToIndex(neighborX, -neighborY, neighborZ); - //const uint indexXYMZ = transCoordToIndex(neighborX, neighborY, -neighborZ); - - - - //return nodeInNextCellIs(index, type) || nodeInPreviousCellIs(index, type) || indexMXY || indexMYZ || indexMXZ || indexXMY || indexYMZ || indexXMZ - // || indexMXYMZ - // || indexMXYZ - // || indexMXMYZ - // || indexXMYMZ - // || indexXMYZ - // || indexXYMZ; - } -HOSTDEVICE bool GridImp::nodeInNextCellIs(int index, char type) const +bool GridImp::nodeInNextCellIs(int index, char type) const { real x, y, z; this->transIndexToCoords(index, x, y, z); @@ -621,7 +644,7 @@ HOSTDEVICE bool GridImp::nodeInNextCellIs(int index, char type) const || typeXZ || typeXYZ; } -HOSTDEVICE bool GridImp::nodeInPreviousCellIs(int index, char type) const +bool GridImp::nodeInPreviousCellIs(int index, char type) const { real x, y, z; this->transIndexToCoords(index, x, y, z); @@ -652,7 +675,7 @@ HOSTDEVICE bool GridImp::nodeInPreviousCellIs(int index, char type) const || typeXZ || typeXYZ; } -HOSTDEVICE bool GridImp::nodeInCellIs(Cell& cell, char type) const +bool GridImp::nodeInCellIs(Cell& cell, char type) const { for (const auto node : cell) { @@ -701,7 +724,7 @@ void GridImp::setNonStopperOutOfGridCellTo(uint index, char type) } -CUDA_HOST void GridImp::setPeriodicity(bool periodicityX, bool periodicityY, bool periodicityZ) +void GridImp::setPeriodicity(bool periodicityX, bool periodicityY, bool periodicityZ) { this->periodicityX = periodicityX; this->periodicityY = periodicityY; @@ -710,17 +733,17 @@ CUDA_HOST void GridImp::setPeriodicity(bool periodicityX, bool periodicityY, boo void GridImp::setPeriodicityX(bool periodicity) { - this->periodicityX = periodicityX; + this->periodicityX = periodicity; } void GridImp::setPeriodicityY(bool periodicity) { - this->periodicityY = periodicityY; + this->periodicityY = periodicity; } void GridImp::setPeriodicityZ(bool periodicity) { - this->periodicityZ = periodicityZ; + this->periodicityZ = periodicity; } bool GridImp::getPeriodicityX() @@ -743,7 +766,7 @@ void GridImp::setEnableFixRefinementIntoTheWall(bool enableFixRefinementIntoTheW this->enableFixRefinementIntoTheWall = enableFixRefinementIntoTheWall; } -HOSTDEVICE uint GridImp::transCoordToIndex(const real &x, const real &y, const real &z) const +uint GridImp::transCoordToIndex(const real &x, const real &y, const real &z) const { const uint xIndex = getXIndex(x); const uint yIndex = getYIndex(y); @@ -755,21 +778,21 @@ HOSTDEVICE uint GridImp::transCoordToIndex(const real &x, const real &y, const r return xIndex + nx * (yIndex + ny * zIndex); } -HOSTDEVICE void GridImp::transIndexToCoords(uint index, real &x, real &y, real &z) const +void GridImp::transIndexToCoords(uint index, real &x, real &y, real &z) const { if (index == INVALID_INDEX) printf("Function: transIndexToCoords. GridImp Index: %d, size: %d. Exit Program!\n", index, size); - x = index % nx; - y = (index / nx) % ny; - z = ((index / nx) / ny) % nz; + x = (real)(index % nx); + y = (real)((index / nx) % ny); + z = (real)(((index / nx) / ny) % nz); x = (x * delta) + startX; y = (y * delta) + startY; z = (z * delta) + startZ; } -CUDA_HOST uint GridImp::getLevel(real startDelta) const +uint GridImp::getLevel(real startDelta) const { uint level = 0; real delta = this->delta; @@ -781,50 +804,50 @@ CUDA_HOST uint GridImp::getLevel(real startDelta) const return level; } -CUDA_HOST uint GridImp::getLevel() const +uint GridImp::getLevel() const { return this->level; } -CUDA_HOST void GridImp::setTriangularMeshDiscretizationStrategy(TriangularMeshDiscretizationStrategy* triangularMeshDiscretizationStrategy) +void GridImp::setTriangularMeshDiscretizationStrategy(TriangularMeshDiscretizationStrategy* triangularMeshDiscretizationStrategy) { this->triangularMeshDiscretizationStrategy = triangularMeshDiscretizationStrategy; } -CUDA_HOST TriangularMeshDiscretizationStrategy * GridImp::getTriangularMeshDiscretizationStrategy() +TriangularMeshDiscretizationStrategy * GridImp::getTriangularMeshDiscretizationStrategy() { return this->triangularMeshDiscretizationStrategy; } -CUDA_HOST uint GridImp::getNumberOfSolidBoundaryNodes() const +uint GridImp::getNumberOfSolidBoundaryNodes() const { return this->numberOfSolidBoundaryNodes; } -CUDA_HOST void GridImp::setNumberOfSolidBoundaryNodes(uint numberOfSolidBoundaryNodes) +void GridImp::setNumberOfSolidBoundaryNodes(uint numberOfSolidBoundaryNodes) { if (numberOfSolidBoundaryNodes < INVALID_INDEX) this->numberOfSolidBoundaryNodes = numberOfSolidBoundaryNodes; } -CUDA_HOST real GridImp::getQValue(const uint index, const uint dir) const +real GridImp::getQValue(const uint index, const uint dir) const { const int qIndex = dir * this->numberOfSolidBoundaryNodes + this->qIndices[index]; return this->qValues[qIndex]; } -CUDA_HOST uint GridImp::getQPatch(const uint index) const +uint GridImp::getQPatch(const uint index) const { return this->qPatches[ this->qIndices[index] ]; } -CUDA_HOST void GridImp::setInnerRegionFromFinerGrid(bool innerRegionFromFinerGrid) +void GridImp::setInnerRegionFromFinerGrid(bool innerRegionFromFinerGrid) { this->innerRegionFromFinerGrid = innerRegionFromFinerGrid; } -CUDA_HOST void GridImp::setNumberOfLayers(uint numberOfLayers) +void GridImp::setNumberOfLayers(uint numberOfLayers) { this->numberOfLayers = numberOfLayers; } @@ -833,13 +856,39 @@ CUDA_HOST void GridImp::setNumberOfLayers(uint numberOfLayers) // Set Sparse Indices // // --------------------------------------------------------- // -CUDA_HOST void GridImp::findSparseIndices(SPtr<Grid> fineGrid) +void GridImp::findSparseIndices(SPtr<Grid> finerGrid) { - this->gridStrategy->findSparseIndices(shared_from_this(), std::static_pointer_cast<GridImp>(fineGrid)); + *logging::out << logging::Logger::INFO_INTERMEDIATE << "Find sparse indices..."; + auto fineGrid = std::static_pointer_cast<GridImp>(finerGrid); + + this->updateSparseIndices(); + +#pragma omp parallel for + for (int index = 0; index < (int)this->getSize(); index++) + this->setNeighborIndices(index); + + if (fineGrid) { + fineGrid->updateSparseIndices(); + this->findForGridInterfaceNewIndices(fineGrid); + } + + const uint newGridSize = this->getSparseSize(); + *logging::out << logging::Logger::INFO_INTERMEDIATE << "... done. new size: " << newGridSize + << ", delete nodes:" << this->getSize() - newGridSize << "\n"; } +void GridImp::findForGridInterfaceNewIndices(SPtr<GridImp> fineGrid) +{ +#pragma omp parallel for + for (int index = 0; index < (int)this->getNumberOfNodesCF(); index++) + this->gridInterface->findForGridInterfaceSparseIndexCF(this, fineGrid.get(), index); + +#pragma omp parallel for + for (int index = 0; index < (int)this->getNumberOfNodesFC(); index++) + this->gridInterface->findForGridInterfaceSparseIndexFC(this, fineGrid.get(), index); +} -CUDA_HOST void GridImp::updateSparseIndices() +void GridImp::updateSparseIndices() { int removedNodes = 0; int newIndex = 0; @@ -859,7 +908,7 @@ CUDA_HOST void GridImp::updateSparseIndices() sparseSize = size - removedNodes; } -CUDA_HOST void GridImp::findFluidNodeIndices(bool splitDomain) +void GridImp::findFluidNodeIndices(bool splitDomain) { // find sparse index of all fluid nodes this->fluidNodeIndices.clear(); @@ -906,7 +955,7 @@ void GridImp::findFluidNodeIndicesBorder() { this->fluidNodeIndicesBorder[i] = this->getSparseIndex(this->fluidNodeIndicesBorder[i])+1; } -HOSTDEVICE void GridImp::setNeighborIndices(uint index) +void GridImp::setNeighborIndices(uint index) { real x, y, z; this->transIndexToCoords(index, x, y, z); @@ -941,7 +990,7 @@ HOSTDEVICE void GridImp::setNeighborIndices(uint index) this->neighborIndexNegative[index] = neighborNegative; } -HOSTDEVICE void GridImp::setStopperNeighborCoords(uint index) +void GridImp::setStopperNeighborCoords(uint index) { real x, y, z; this->transIndexToCoords(index, x, y, z); @@ -964,7 +1013,7 @@ HOSTDEVICE void GridImp::setStopperNeighborCoords(uint index) } } -HOSTDEVICE void GridImp::getNeighborCoords(real &neighborX, real &neighborY, real &neighborZ, real x, real y, real z) const +void GridImp::getNeighborCoords(real &neighborX, real &neighborY, real &neighborZ, real x, real y, real z) const { real coords[3] = { x, y, z }; neighborX = getNeighborCoord(periodicityX, startX, coords, 0); @@ -972,7 +1021,7 @@ HOSTDEVICE void GridImp::getNeighborCoords(real &neighborX, real &neighborY, rea neighborZ = getNeighborCoord(periodicityZ, startZ, coords, 2); } -HOSTDEVICE real GridImp::getNeighborCoord(bool periodicity, real startCoord, real coords[3], int direction) const +real GridImp::getNeighborCoord(bool periodicity, real startCoord, real coords[3], int direction) const { if (periodicity) { @@ -980,11 +1029,6 @@ HOSTDEVICE real GridImp::getNeighborCoord(bool periodicity, real startCoord, rea neighborCoords[direction] = neighborCoords[direction] + delta; const int neighborIndex = this->transCoordToIndex(neighborCoords[0], neighborCoords[1], neighborCoords[2]); - //if(!field.isStopperOutOfGrid(neighborIndex) && !field.is(neighborIndex, STOPPER_OUT_OF_GRID_BOUNDARY) ) - // return coords[direction] + delta; - - //return getFirstFluidNode(coords, direction, startCoord); - ////////////////////////////////////////////////////////////////////////// if( field.is(neighborIndex, STOPPER_OUT_OF_GRID_BOUNDARY) ) @@ -997,7 +1041,7 @@ HOSTDEVICE real GridImp::getNeighborCoord(bool periodicity, real startCoord, rea return coords[direction] + delta; } -HOSTDEVICE void GridImp::getNegativeNeighborCoords(real &neighborX, real &neighborY, real &neighborZ, real x, real y, real z) const +void GridImp::getNegativeNeighborCoords(real &neighborX, real &neighborY, real &neighborZ, real x, real y, real z) const { real coords[3] = { x, y, z }; @@ -1006,13 +1050,13 @@ HOSTDEVICE void GridImp::getNegativeNeighborCoords(real &neighborX, real &neighb neighborZ = getNegativeNeighborCoord(periodicityZ, endZ, coords, 2); } -HOSTDEVICE real GridImp::getNegativeNeighborCoord(bool periodicity, real startCoord, real coords[3], int direction) const +real GridImp::getNegativeNeighborCoord(bool periodicity, real startCoord, real coords[3], int direction) const { if (periodicity) { real neighborCoords[3] = {coords[0], coords[1] , coords[2] }; neighborCoords[direction] = neighborCoords[direction] - delta; - const int neighborIndex = this->transCoordToIndex(neighborCoords[0], neighborCoords[1], neighborCoords[2]); + const uint neighborIndex = this->transCoordToIndex(neighborCoords[0], neighborCoords[1], neighborCoords[2]); if(neighborIndex != INVALID_INDEX && !field.isStopperOutOfGrid(neighborIndex) && !field.is(neighborIndex, STOPPER_OUT_OF_GRID_BOUNDARY) ) return coords[direction] - delta; @@ -1024,10 +1068,10 @@ HOSTDEVICE real GridImp::getNegativeNeighborCoord(bool periodicity, real startCo } -HOSTDEVICE real GridImp::getLastFluidNode(real coords[3], int direction, real startCoord) const +real GridImp::getLastFluidNode(real coords[3], int direction, real startCoord) const { coords[direction] = startCoord; - int index = this->transCoordToIndex(coords[0], coords[1], coords[2]); + uint index = this->transCoordToIndex(coords[0], coords[1], coords[2]); while (index != INVALID_INDEX && !field.isFluid(index)) { coords[direction] -= delta; @@ -1036,7 +1080,7 @@ HOSTDEVICE real GridImp::getLastFluidNode(real coords[3], int direction, real st return coords[direction]; } -HOSTDEVICE real GridImp::getFirstFluidNode(real coords[3], int direction, real startCoord) const +real GridImp::getFirstFluidNode(real coords[3], int direction, real startCoord) const { coords[direction] = startCoord; uint index = this->transCoordToIndex(coords[0], coords[1], coords[2]); @@ -1049,27 +1093,57 @@ HOSTDEVICE real GridImp::getFirstFluidNode(real coords[3], int direction, real s } -HOSTDEVICE int GridImp::getSparseIndex(const real &x, const real &y, const real &z) const +int GridImp::getSparseIndex(const real &x, const real &y, const real &z) const { const int matrixIndex = transCoordToIndex(x, y, z); return sparseIndices[matrixIndex]; } - // --------------------------------------------------------- // // Find Interface // // --------------------------------------------------------- // -CUDA_HOST void GridImp::findGridInterface(SPtr<Grid> finerGrid, LbmOrGks lbmOrGks) +void GridImp::findGridInterface(SPtr<Grid> finerGrid, LbmOrGks lbmOrGks) { - gridStrategy->findGridInterface(shared_from_this(), std::static_pointer_cast<GridImp>(finerGrid), lbmOrGks); + auto fineGrid = std::static_pointer_cast<GridImp>(finerGrid); + const auto coarseLevel = this->getLevel(); + const auto fineLevel = fineGrid->getLevel(); + + *logging::out << logging::Logger::INFO_INTERMEDIATE << "find interface level " << coarseLevel << " -> " + << fineLevel; + + this->gridInterface = new GridInterface(); + // TODO: this is stupid! concave refinements can easily have many more interface cells + const uint sizeCF = 10 * (fineGrid->nx * fineGrid->ny + fineGrid->ny * fineGrid->nz + fineGrid->nx * fineGrid->nz); + this->gridInterface->cf.coarse = new uint[sizeCF]; + this->gridInterface->cf.fine = new uint[sizeCF]; + this->gridInterface->cf.offset = new uint[sizeCF]; + this->gridInterface->fc.coarse = new uint[sizeCF]; + this->gridInterface->fc.fine = new uint[sizeCF]; + this->gridInterface->fc.offset = new uint[sizeCF]; + + for (uint index = 0; index < this->getSize(); index++) + this->findGridInterfaceCF(index, *fineGrid, lbmOrGks); + + for (uint index = 0; index < this->getSize(); index++) + this->findGridInterfaceFC(index, *fineGrid); + + for (uint index = 0; index < this->getSize(); index++) + this->findOverlapStopper(index, *fineGrid); + + if (lbmOrGks == GKS) { + for (uint index = 0; index < this->getSize(); index++) + this->findInvalidBoundaryNodes(index); + } + + *logging::out << logging::Logger::INFO_INTERMEDIATE << " ... done. \n"; } -HOSTDEVICE void GridImp::repairGridInterfaceOnMultiGPU(SPtr<Grid> fineGrid) +void GridImp::repairGridInterfaceOnMultiGPU(SPtr<Grid> fineGrid) { this->gridInterface->repairGridInterfaceOnMultiGPU( shared_from_this(), std::static_pointer_cast<GridImp>(fineGrid) ); } -CUDA_HOST void GridImp::limitToSubDomain(SPtr<BoundingBox> subDomainBox, LbmOrGks lbmOrGks) +void GridImp::limitToSubDomain(SPtr<BoundingBox> subDomainBox, LbmOrGks lbmOrGks) { for( uint index = 0; index < this->size; index++ ){ @@ -1108,11 +1182,9 @@ CUDA_HOST void GridImp::limitToSubDomain(SPtr<BoundingBox> subDomainBox, LbmOrGk this->setFieldEntry(index, INVALID_OUT_OF_GRID); } } - - //this->gridStrategy->findEndOfGridStopperNodes(shared_from_this()); } -HOSTDEVICE void GridImp::findGridInterfaceCF(uint index, GridImp& finerGrid, LbmOrGks lbmOrGks) +void GridImp::findGridInterfaceCF(uint index, GridImp& finerGrid, LbmOrGks lbmOrGks) { if (lbmOrGks == LBM) { @@ -1123,17 +1195,17 @@ HOSTDEVICE void GridImp::findGridInterfaceCF(uint index, GridImp& finerGrid, Lbm gridInterface->findInterfaceCF_GKS(index, this, &finerGrid); } -HOSTDEVICE void GridImp::findGridInterfaceFC(uint index, GridImp& finerGrid) +void GridImp::findGridInterfaceFC(uint index, GridImp& finerGrid) { gridInterface->findInterfaceFC(index, this, &finerGrid); } -HOSTDEVICE void GridImp::findOverlapStopper(uint index, GridImp& finerGrid) +void GridImp::findOverlapStopper(uint index, GridImp& finerGrid) { gridInterface->findOverlapStopper(index, this, &finerGrid); } -HOSTDEVICE void GridImp::findInvalidBoundaryNodes(uint index) +void GridImp::findInvalidBoundaryNodes(uint index) { gridInterface->findInvalidBoundaryNodes(index, this); } @@ -1141,28 +1213,35 @@ HOSTDEVICE void GridImp::findInvalidBoundaryNodes(uint index) // --------------------------------------------------------- // // Mesh Triangle // // --------------------------------------------------------- // -CUDA_HOST void GridImp::mesh(Object* object) +void GridImp::mesh(Object* object) { - TriangularMesh* triangularMesh = dynamic_cast<TriangularMesh*>(object); + TriangularMesh *triangularMesh = dynamic_cast<TriangularMesh *>(object); if (triangularMesh) triangularMeshDiscretizationStrategy->discretize(triangularMesh, this, INVALID_SOLID, FLUID); else - //gridStrategy->findInnerNodes(shared_from_this()); //TODO: adds INNERTYPE AND OUTERTYPE to findInnerNodes //new method for geometric primitives (not cell based) to be implemented this->discretize(object, INVALID_SOLID, FLUID); this->closeNeedleCells(); - gridStrategy->findSolidStopperNodes(shared_from_this()); - gridStrategy->findBoundarySolidNodes(shared_from_this()); + #pragma omp parallel for + for (int index = 0; index < (int)this->size; index++) + this->findSolidStopperNode(index); + + //#pragma omp parallel for + for (int index = 0; index < (int)this->size; index++) { + this->findBoundarySolidNode(index); + } } -CUDA_HOST void GridImp::mesh(TriangularMesh &triangularMesh) +void GridImp::mesh(TriangularMesh &triangularMesh) { const clock_t begin = clock(); - gridStrategy->mesh(shared_from_this(), triangularMesh); +#pragma omp parallel for + for (int i = 0; i < triangularMesh.size; i++) + this->mesh(triangularMesh.triangles[i]); const clock_t end = clock(); const real time = (real)(real(end - begin) / CLOCKS_PER_SEC); @@ -1170,7 +1249,7 @@ CUDA_HOST void GridImp::mesh(TriangularMesh &triangularMesh) *logging::out << logging::Logger::INFO_INTERMEDIATE << "time grid generation: " << time << "s\n"; } -HOSTDEVICE void GridImp::mesh(Triangle &triangle) +void GridImp::mesh(Triangle &triangle) { auto box = this->getBoundingBoxOnNodes(triangle); triangle.initalLayerThickness(getDelta()); @@ -1196,20 +1275,26 @@ HOSTDEVICE void GridImp::mesh(Triangle &triangle) } } -CUDA_HOST void GridImp::closeNeedleCells() +void GridImp::closeNeedleCells() { *logging::out << logging::Logger::INFO_INTERMEDIATE << "Start closeNeedleCells()\n"; uint numberOfClosedNeedleCells = 0; do{ - numberOfClosedNeedleCells = this->gridStrategy->closeNeedleCells( shared_from_this() ); + numberOfClosedNeedleCells = 0; +#pragma omp parallel for reduction(+ : numberOfClosedNeedleCells) + for (int index = 0; index < (int)this->size; index++) { + if (this->closeCellIfNeedle(index)) + numberOfClosedNeedleCells++; + } + *logging::out << logging::Logger::INFO_INTERMEDIATE << numberOfClosedNeedleCells << " cells closed!\n"; } while( numberOfClosedNeedleCells > 0 ); } -HOSTDEVICE bool GridImp::closeCellIfNeedle(uint index) +bool GridImp::closeCellIfNeedle(uint index) { if( !this->getField().is( index, FLUID ) ) return false; @@ -1231,38 +1316,32 @@ HOSTDEVICE bool GridImp::closeCellIfNeedle(uint index) return false; } -CUDA_HOST void GridImp::closeNeedleCellsThinWall() +void GridImp::closeNeedleCellsThinWall() { *logging::out << logging::Logger::INFO_INTERMEDIATE << "Start closeNeedleCellsThinWall()\n"; uint numberOfClosedNeedleCells = 0; do{ - numberOfClosedNeedleCells = this->gridStrategy->closeNeedleCellsThinWall( shared_from_this() ); + numberOfClosedNeedleCells = 0; +#pragma omp parallel for reduction(+ : numberOfClosedNeedleCells) + for (int index = 0; index < (int)this->size; index++) { + if (this->closeCellIfNeedleThinWall(index)) + numberOfClosedNeedleCells++; + } + *logging::out << logging::Logger::INFO_INTERMEDIATE << numberOfClosedNeedleCells << " cells closed!\n"; } while( numberOfClosedNeedleCells > 0 ); } -HOSTDEVICE bool GridImp::closeCellIfNeedleThinWall(uint index) +bool GridImp::closeCellIfNeedleThinWall(uint index) { if( !this->getField().is( index, BC_SOLID ) ) return false; real x, y, z; this->transIndexToCoords(index, x, y, z); - //bool noValidNeighborInX = !this->getField().is( this->transCoordToIndex( x + this->delta, y, z ) , FLUID ) && - // !this->getField().is( this->transCoordToIndex( x - this->delta, y, z ) , FLUID ); - //bool noValidNeighborInY = !this->getField().is( this->transCoordToIndex( x, y + this->delta, z ) , FLUID ) && - // !this->getField().is( this->transCoordToIndex( x, y - this->delta, z ) , FLUID ); - //bool noValidNeighborInZ = !this->getField().is( this->transCoordToIndex( x, y, z + this->delta ) , FLUID ) && - // !this->getField().is( this->transCoordToIndex( x, y, z - this->delta ) , FLUID ); - - //if( noValidNeighborInX && noValidNeighborInY && noValidNeighborInZ ){ - // this->setFieldEntry(index, STOPPER_SOLID); - // return true; - //} - if( !this->hasNeighborOfType(index, FLUID) ){ this->setFieldEntry(index, STOPPER_SOLID); return true; @@ -1273,7 +1352,7 @@ HOSTDEVICE bool GridImp::closeCellIfNeedleThinWall(uint index) -CUDA_HOST void GridImp::findQs(Object* object) //TODO: enable qs for primitive objects +void GridImp::findQs(Object* object) //TODO: enable qs for primitive objects { TriangularMesh* triangularMesh = dynamic_cast<TriangularMesh*>(object); if (triangularMesh) @@ -1282,15 +1361,31 @@ CUDA_HOST void GridImp::findQs(Object* object) //TODO: enable qs for primitive o findQsPrimitive(object); } -CUDA_HOST void GridImp::findQs(TriangularMesh &triangularMesh) +void GridImp::allocateQs() { - const clock_t begin = clock(); + this->qPatches = new uint[this->getNumberOfSolidBoundaryNodes()]; - if( this->qComputationStage == qComputationStageType::ComputeQs ){ - gridStrategy->allocateQs(shared_from_this()); - } + for (uint i = 0; i < this->getNumberOfSolidBoundaryNodes(); i++) + this->qPatches[i] = INVALID_INDEX; - gridStrategy->findQs(shared_from_this(), triangularMesh); + const uint numberOfQs = this->getNumberOfSolidBoundaryNodes() * (this->distribution.dir_end + 1); + this->qValues = new real[numberOfQs]; +#pragma omp parallel for + for (int i = 0; i < (int)numberOfQs; i++) + this->qValues[i] = -1.0; +} + +void GridImp::findQs(TriangularMesh &triangularMesh) +{ + const clock_t begin = clock(); + + if( this->qComputationStage == qComputationStageType::ComputeQs ) + allocateQs(); + + +#pragma omp parallel for + for (int i = 0; i < triangularMesh.size; i++) + this->findQs(triangularMesh.triangles[i]); const clock_t end = clock(); const real time = (real)(real(end - begin) / CLOCKS_PER_SEC); @@ -1298,7 +1393,7 @@ CUDA_HOST void GridImp::findQs(TriangularMesh &triangularMesh) *logging::out << logging::Logger::INFO_INTERMEDIATE << "time finding qs: " << time << "s\n"; } -HOSTDEVICE void GridImp::findQs(Triangle &triangle) +void GridImp::findQs(Triangle &triangle) { auto box = this->getBoundingBoxOnNodes(triangle); triangle.initalLayerThickness(getDelta()); @@ -1341,12 +1436,11 @@ HOSTDEVICE void GridImp::findQs(Triangle &triangle) } } -CUDA_HOST void GridImp::findQsPrimitive(Object * object) +void GridImp::findQsPrimitive(Object * object) { - if( this->qComputationStage == qComputationStageType::ComputeQs ){ - gridStrategy->allocateQs(shared_from_this()); - } + if( this->qComputationStage == qComputationStageType::ComputeQs ) + allocateQs(); for( int index = 0; index < (int)this->size; index++ ) @@ -1381,7 +1475,7 @@ CUDA_HOST void GridImp::findQsPrimitive(Object * object) } } -HOSTDEVICE void GridImp::calculateQs(const uint index, const Vertex &point, Object* object) const +void GridImp::calculateQs(const uint index, const Vertex &point, Object* object) const { Vertex pointOnTriangle, direction; @@ -1413,13 +1507,12 @@ HOSTDEVICE void GridImp::calculateQs(const uint index, const Vertex &point, Obje this->qPatches[ this->qIndices[index] ] = 0; - //printf("%d %f \n", this->qIndices[index], subdistance); } } } } -HOSTDEVICE bool GridImp::checkIfAtLeastOneValidQ(const uint index, const Vertex &point, Object* object) const +bool GridImp::checkIfAtLeastOneValidQ(const uint index, const Vertex &point, Object* object) const { Vertex pointOnTriangle, direction; @@ -1449,7 +1542,7 @@ HOSTDEVICE bool GridImp::checkIfAtLeastOneValidQ(const uint index, const Vertex return false; } -HOSTDEVICE void GridImp::setDebugPoint(uint index, int pointValue) +void GridImp::setDebugPoint(uint index, int pointValue) { if (field.isInvalidCoarseUnderFine(index) && pointValue == INVALID_SOLID) field.setFieldEntry(index, pointValue); @@ -1458,10 +1551,9 @@ HOSTDEVICE void GridImp::setDebugPoint(uint index, int pointValue) field.setFieldEntry(index, pointValue); } -HOSTDEVICE void GridImp::calculateQs(const Vertex &point, const Triangle &triangle) const // NOT USED !!!! +void GridImp::calculateQs(const Vertex &point, const Triangle &triangle) const // NOT USED !!!! { Vertex pointOnTriangle, direction; - //VertexInteger solid_node; real subdistance; int error; for (int i = distribution.dir_start; i <= distribution.dir_end; i++) @@ -1475,21 +1567,17 @@ HOSTDEVICE void GridImp::calculateQs(const Vertex &point, const Triangle &triang error = triangle.getTriangleIntersection(point, direction, pointOnTriangle, subdistance); - //real lengthDirection = sqrt(direction.x * direction.x + direction.y * direction.y + direction.z * direction.z); - subdistance /= /*lengthDirection **/ this->delta; + subdistance /= this->delta; if (error == 0 && subdistance < 1.0 && subdistance > 0.0) { - //solid_node = VertexInteger(actualPoint.x + direction.x, actualPoint.y + direction.y, actualPoint.z + direction.z); distribution.f[i*size + transCoordToIndex(point.x, point.y, point.z)] = subdistance; - //printf("Q%d %d: %2.8f \n", i, grid.transCoordToIndex(actualPoint), grid.d.f[index]); - } /*else - distribution.f[i*size + transCoordToIndex(point.x, point.y, point.z)] = -1.0;*/ + } } } -HOSTDEVICE void GridImp::calculateQs(const uint index, const Vertex &point, const Triangle &triangle) const +void GridImp::calculateQs(const uint index, const Vertex &point, const Triangle &triangle) const { Vertex pointOnTriangle, direction; real subdistance; @@ -1522,14 +1610,12 @@ HOSTDEVICE void GridImp::calculateQs(const uint index, const Vertex &point, cons this->qValues[i*this->numberOfSolidBoundaryNodes + this->qIndices[index]] = subdistance; this->qPatches[ this->qIndices[index] ] = triangle.patchIndex; - - //printf("%d %f \n", this->qIndices[index], subdistance); } } } } -HOSTDEVICE bool GridImp::checkIfAtLeastOneValidQ(const uint index, const Vertex & point, const Triangle & triangle) const +bool GridImp::checkIfAtLeastOneValidQ(const uint index, const Vertex & point, const Triangle & triangle) const { Vertex pointOnTriangle, direction; real subdistance; @@ -1571,7 +1657,6 @@ void GridImp::findCommunicationIndices(int direction, SPtr<BoundingBox> subDomai if( this->getFieldEntry(index) == INVALID_OUT_OF_GRID || this->getFieldEntry(index) == INVALID_SOLID || this->getFieldEntry(index) == INVALID_COARSE_UNDER_FINE || - //this->getFieldEntry(index) == STOPPER_SOLID || this->getFieldEntry(index) == STOPPER_OUT_OF_GRID || this->getFieldEntry(index) == STOPPER_COARSE_UNDER_FINE ) continue; @@ -1588,7 +1673,6 @@ void GridImp::findCommunicationIndices(int direction, SPtr<BoundingBox> subDomai } void GridImp::findCommunicationIndex( uint index, real coordinate, real limit, int direction ){ - // // negative direction get a negative sign real s = ( direction % 2 == 0 ) ? ( -1.0 ) : ( 1.0 ); @@ -1670,59 +1754,56 @@ void GridImp::repairCommunicationIndices(int direction) // --------------------------------------------------------- // // Getter // // --------------------------------------------------------- // -HOSTDEVICE int GridImp::getSparseIndex(uint matrixIndex) const +int GridImp::getSparseIndex(uint matrixIndex) const { return this->sparseIndices[matrixIndex]; } -CUDA_HOST real* GridImp::getDistribution() const +real* GridImp::getDistribution() const { return this->distribution.f; } -CUDA_HOST int* GridImp::getDirection() const +int* GridImp::getDirection() const { return this->distribution.dirs; } -CUDA_HOST int GridImp::getStartDirection() const +int GridImp::getStartDirection() const { return this->distribution.dir_start; } -CUDA_HOST int GridImp::getEndDirection() const +int GridImp::getEndDirection() const { return this->distribution.dir_end; } -HOSTDEVICE BoundingBox GridImp::getBoundingBoxOnNodes(Triangle &triangle) const +BoundingBox GridImp::getBoundingBoxOnNodes(Triangle &triangle) const { real minX, maxX, minY, maxY, minZ, maxZ; triangle.setMinMax(minX, maxX, minY, maxY, minZ, maxZ); - //const Vertex minOnNodes = getMinimumOnNode(Vertex(minX, minY, minZ)); - //const Vertex maxOnNodes = getMaximumOnNode(Vertex(maxX, maxY, maxZ)); - int minXIndex = lround(floor((minX - this->startX) / this->delta)) - 1; - int minYIndex = lround(floor((minY - this->startY) / this->delta)) - 1; - int minZIndex = lround(floor((minZ - this->startZ) / this->delta)) - 1; + int minXIndex = std::lround(floor((minX - this->startX) / this->delta)) - 1; + int minYIndex = std::lround(floor((minY - this->startY) / this->delta)) - 1; + int minZIndex = std::lround(floor((minZ - this->startZ) / this->delta)) - 1; - int maxXIndex = lround(ceil ((maxX - this->startX) / this->delta)) + 1; - int maxYIndex = lround(ceil ((maxY - this->startY) / this->delta)) + 1; - int maxZIndex = lround(ceil ((maxZ - this->startZ) / this->delta)) + 1; + int maxXIndex = std::lround(ceil((maxX - this->startX) / this->delta)) + 1; + int maxYIndex = std::lround(ceil((maxY - this->startY) / this->delta)) + 1; + int maxZIndex = std::lround(ceil((maxZ - this->startZ) / this->delta)) + 1; - minX = this->startX + minXIndex * this->delta; - minY = this->startY + minYIndex * this->delta; - minZ = this->startZ + minZIndex * this->delta; + minX = this->startX + minXIndex * this->delta; + minY = this->startY + minYIndex * this->delta; + minZ = this->startZ + minZIndex * this->delta; - maxX = this->startX + maxXIndex * this->delta; - maxY = this->startY + maxYIndex * this->delta; - maxZ = this->startZ + maxZIndex * this->delta; + maxX = this->startX + maxXIndex * this->delta; + maxY = this->startY + maxYIndex * this->delta; + maxZ = this->startZ + maxZIndex * this->delta; - //return BoundingBox(minOnNodes.x, maxOnNodes.x, minOnNodes.y, maxOnNodes.y, minOnNodes.z, maxOnNodes.z); - return BoundingBox( minX, maxX, minY, maxY, minZ, maxZ ); + return BoundingBox(minX, maxX, minY, maxY, minZ, maxZ); } -HOSTDEVICE Vertex GridImp::getMinimumOnNode(Vertex exact) const //deprecated +Vertex GridImp::getMinimumOnNode(Vertex exact) const // deprecated { const real minX = getMinimumOnNodes(exact.x, vf::Math::getDecimalPart(startX), delta); const real minY = getMinimumOnNodes(exact.y, vf::Math::getDecimalPart(startY), delta); @@ -1730,7 +1811,7 @@ HOSTDEVICE Vertex GridImp::getMinimumOnNode(Vertex exact) const //deprecated return Vertex(minX, minY, minZ); } -HOSTDEVICE real GridImp::getMinimumOnNodes(const real& minExact, const real& decimalStart, const real& delta) //deprecated +real GridImp::getMinimumOnNodes(const real &minExact, const real &decimalStart, const real &delta) // deprecated { real minNode = ceil(minExact - 1.0); minNode += decimalStart; @@ -1742,7 +1823,7 @@ HOSTDEVICE real GridImp::getMinimumOnNodes(const real& minExact, const real& dec return minNode; } -HOSTDEVICE Vertex GridImp::getMaximumOnNode(Vertex exact) const //deprecated +Vertex GridImp::getMaximumOnNode(Vertex exact) const // deprecated { const real maxX = getMaximumOnNodes(exact.x, vf::Math::getDecimalPart(startX), delta); const real maxY = getMaximumOnNodes(exact.y, vf::Math::getDecimalPart(startY), delta); @@ -1750,7 +1831,7 @@ HOSTDEVICE Vertex GridImp::getMaximumOnNode(Vertex exact) const //deprecated return Vertex(maxX, maxY, maxZ); } -HOSTDEVICE real GridImp::getMaximumOnNodes(const real& maxExact, const real& decimalStart, const real& delta) //deprecated +real GridImp::getMaximumOnNodes(const real &maxExact, const real &decimalStart, const real &delta) // deprecated { real maxNode = ceil(maxExact - 1.0); maxNode += decimalStart; @@ -1760,35 +1841,32 @@ HOSTDEVICE real GridImp::getMaximumOnNodes(const real& maxExact, const real& dec return maxNode; } -HOSTDEVICE uint GridImp::getXIndex(real x) const -{ - return lround((x - startX) / delta); - //return int((x - startX) / delta); +uint GridImp::getXIndex(real x) const +{ + return std::lround((x - startX) / delta); } -HOSTDEVICE uint GridImp::getYIndex(real y) const -{ - return lround((y - startY) / delta); - //return int((y - startY) / delta); +uint GridImp::getYIndex(real y) const +{ + return std::lround((y - startY) / delta); } -HOSTDEVICE uint GridImp::getZIndex(real z) const -{ - return lround((z - startZ) / delta); - //return int((z - startZ) / delta); +uint GridImp::getZIndex(real z) const +{ + return std::lround((z - startZ) / delta); } -HOSTDEVICE real GridImp::getDelta() const +real GridImp::getDelta() const { return delta; } -HOSTDEVICE uint GridImp::getSize() const +uint GridImp::getSize() const { return this->size; } -HOSTDEVICE uint GridImp::getSparseSize() const +uint GridImp::getSparseSize() const { return this->sparseSize; } @@ -1797,7 +1875,7 @@ HOSTDEVICE uint GridImp::getNumberOfFluidNodes() const { return (uint)this->fluidNodeIndices.size(); } -HOSTDEVICE Field GridImp::getField() const +Field GridImp::getField() const { return this->field; } @@ -1807,7 +1885,7 @@ char GridImp::getFieldEntry(uint index) const return this->field.getFieldEntry(index); } -HOSTDEVICE void GridImp::setFieldEntry(uint matrixIndex, char type) +void GridImp::setFieldEntry(uint matrixIndex, char type) { this->field.setFieldEntry(matrixIndex, type); } @@ -1858,11 +1936,6 @@ uint GridImp::getNumberOfNodesZ() const return nz; } -SPtr<GridStrategy> GridImp::getGridStrategy() const -{ - return gridStrategy; -} - int* GridImp::getNeighborsX() const { @@ -1884,7 +1957,6 @@ int* GridImp::getNeighborsNegative() const return this->neighborIndexNegative; } - uint GridImp::getNumberOfNodesCF() const { if(this->gridInterface) @@ -1909,7 +1981,7 @@ uint* GridImp::getCF_fine() const return this->gridInterface->cf.fine; } -CUDA_HOST uint * GridImp::getCF_offset() const +uint * GridImp::getCF_offset() const { return this->gridInterface->cf.offset; } @@ -1924,7 +1996,7 @@ uint* GridImp::getFC_fine() const return this->gridInterface->fc.fine; } -CUDA_HOST uint * GridImp::getFC_offset() const +uint * GridImp::getFC_offset() const { return this->gridInterface->fc.offset; } @@ -1952,7 +2024,7 @@ bool GridImp::isSparseIndexInFluidNodeIndicesBorder(uint &sparseIndex) const #define GEOFLUID 19 #define GEOSOLID 16 -CUDA_HOST void GridImp::getNodeValues(real *xCoords, real *yCoords, real *zCoords, uint *neighborX, uint *neighborY, uint *neighborZ, uint *neighborNegative, uint *geo) const +void GridImp::getNodeValues(real *xCoords, real *yCoords, real *zCoords, uint *neighborX, uint *neighborY, uint *neighborZ, uint *neighborNegative, uint *geo) const { xCoords[0] = 0; yCoords[0] = 0; @@ -1977,8 +2049,6 @@ CUDA_HOST void GridImp::getNodeValues(real *xCoords, real *yCoords, real *zCoord const uint neighborZIndex = uint(this->neighborIndexZ[i] + 1); const uint neighborNegativeIndex = uint(this->neighborIndexNegative[i] + 1); - const char type2 = this->field.getFieldEntry(i); - const uint type = uint(this->field.isFluid(i) ? GEOFLUID : GEOSOLID); xCoords[nodeNumber + 1] = x; @@ -2019,5 +2089,3 @@ void GridImp::print() const if(this->gridInterface) this->gridInterface->print(); } - - diff --git a/src/gpu/GridGenerator/grid/GridImp.h b/src/gpu/GridGenerator/grid/GridImp.h index 08c4f795b320cdd425e7d2c10c4d3173ecb6e83c..a2597b19539fd3eb7a2947cfab073918df112cea 100644 --- a/src/gpu/GridGenerator/grid/GridImp.h +++ b/src/gpu/GridGenerator/grid/GridImp.h @@ -1,3 +1,35 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids 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. +// +// VirtualFluids 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 VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file GridImp.h +//! \ingroup grid +//! \author Soeren Peters, Stephan Lenz, Martin Schoenherr +//======================================================================================= #ifndef GRID_IMP_H #define GRID_IMP_H @@ -15,7 +47,6 @@ class TriangularMesh; struct Vertex; struct Triangle; -class GridStrategy; class GridInterface; class Object; class BoundingBox; @@ -28,8 +59,8 @@ class TriangularMeshDiscretizationStrategy; #endif #endif -//GCC: warning #3156-D: extern declaration of the entity DIRECTIONS is treated as a static definition -extern CONSTANT int DIRECTIONS[DIR_END_MAX][DIMENSION]; +// GCC: warning #3156-D: extern declaration of the entity DIRECTIONS is treated as a static definition +extern int DIRECTIONS[DIR_END_MAX][DIMENSION]; #ifdef __GNUC__ #ifndef __clang__ @@ -39,31 +70,30 @@ extern CONSTANT int DIRECTIONS[DIR_END_MAX][DIMENSION]; class GRIDGENERATOR_EXPORT GridImp : public enableSharedFromThis<GridImp>, public Grid { -protected: - CUDA_HOST GridImp(); - CUDA_HOST GridImp(Object* object, real startX, real startY, real startZ, real endX, real endY, real endZ, real delta, SPtr<GridStrategy> gridStrategy, Distribution d, uint level); +private: + GridImp() = default; + GridImp(Object* object, real startX, real startY, real startZ, real endX, real endY, real endZ, real delta, Distribution d, uint level); public: - virtual HOSTDEVICE ~GridImp(); - static CUDA_HOST SPtr<GridImp> makeShared(Object* object, real startX, real startY, real startZ, real endX, real endY, real endZ, real delta, SPtr<GridStrategy> gridStrategy, Distribution d, uint level); + static SPtr<GridImp> makeShared(Object* object, real startX, real startY, real startZ, real endX, real endY, real endZ, real delta, std::string d3Qxx, uint level); private: - CUDA_HOST void initalNumberOfNodesAndSize(); - HOSTDEVICE Cell getOddCellFromIndex(uint index) const; - HOSTDEVICE bool isValidSolidStopper(uint index) const; - HOSTDEVICE bool shouldBeBoundarySolidNode(uint index) const; - HOSTDEVICE bool isValidEndOfGridStopper(uint index) const; - HOSTDEVICE bool isValidEndOfGridBoundaryStopper(uint index) const; - HOSTDEVICE bool isOutSideOfGrid(Cell &cell) const; - HOSTDEVICE bool contains(Cell &cell, char type) const; - HOSTDEVICE void setNodeTo(Cell &cell, char type); - - HOSTDEVICE bool nodeInPreviousCellIs(int index, char type) const; - HOSTDEVICE bool nodeInCellIs(Cell& cell, char type) const override; - - HOSTDEVICE uint getXIndex(real x) const; - HOSTDEVICE uint getYIndex(real y) const; - HOSTDEVICE uint getZIndex(real z) const; + void initalNumberOfNodesAndSize(); + Cell getOddCellFromIndex(uint index) const; + bool isValidSolidStopper(uint index) const; + bool shouldBeBoundarySolidNode(uint index) const; + bool isValidEndOfGridStopper(uint index) const; + bool isValidEndOfGridBoundaryStopper(uint index) const; + bool isOutSideOfGrid(Cell &cell) const; + bool contains(Cell &cell, char type) const; + void setNodeTo(Cell &cell, char type); + + bool nodeInPreviousCellIs(int index, char type) const; + bool nodeInCellIs(Cell& cell, char type) const override; + + uint getXIndex(real x) const; + uint getYIndex(real y) const; + uint getZIndex(real z) const; uint level; @@ -81,7 +111,7 @@ private: Field field; Object* object; - GridInterface* gridInterface; + GridInterface *gridInterface; int *neighborIndexX, *neighborIndexY, *neighborIndexZ, *neighborIndexNegative; int *sparseIndices; @@ -97,19 +127,18 @@ private: uint numberOfLayers; - SPtr<GridStrategy> gridStrategy; - TriangularMeshDiscretizationStrategy* triangularMeshDiscretizationStrategy; + TriangularMeshDiscretizationStrategy *triangularMeshDiscretizationStrategy; - uint numberOfSolidBoundaryNodes; + uint numberOfSolidBoundaryNodes = 0; bool enableFixRefinementIntoTheWall; public: - CUDA_HOST void inital(const SPtr<Grid> fineGrid, uint numberOfLayers) override; - CUDA_HOST void setOddStart( bool xOddStart, bool yOddStart, bool zOddStart ) override; - HOSTDEVICE void fixOddCell(uint index); + void inital(const SPtr<Grid> fineGrid, uint numberOfLayers) override; + void setOddStart(bool xOddStart, bool yOddStart, bool zOddStart) override; + void fixOddCell(uint index); - CUDA_HOST void setPeriodicity(bool periodicityX, bool periodicityY, bool periodicityZ) override; + void setPeriodicity(bool periodicityX, bool periodicityY, bool periodicityZ) override; void setPeriodicityX(bool periodicity) override; void setPeriodicityY(bool periodicity) override; void setPeriodicityZ(bool periodicity) override; @@ -118,168 +147,169 @@ public: bool getPeriodicityY() override; bool getPeriodicityZ() override; - void setEnableFixRefinementIntoTheWall( bool enableFixRefinementIntoTheWall ) override; + void setEnableFixRefinementIntoTheWall(bool enableFixRefinementIntoTheWall) override; + + void setCellTo(uint index, char type); + void setNonStopperOutOfGridCellTo(uint index, char type); - HOSTDEVICE void setCellTo(uint index, char type); - HOSTDEVICE void setNonStopperOutOfGridCellTo(uint index, char type); + uint transCoordToIndex(const real &x, const real &y, const real &z) const override; + void transIndexToCoords(uint index, real &x, real &y, real &z) const override; - HOSTDEVICE uint transCoordToIndex(const real &x, const real &y, const real &z) const override; - HOSTDEVICE void transIndexToCoords(uint index, real &x, real &y, real &z) const override; + virtual void findGridInterface(SPtr<Grid> grid, LbmOrGks lbmOrGks) override; - CUDA_HOST virtual void findGridInterface(SPtr<Grid> grid, LbmOrGks lbmOrGks) override; + void repairGridInterfaceOnMultiGPU(SPtr<Grid> fineGrid) override; - HOSTDEVICE void repairGridInterfaceOnMultiGPU(SPtr<Grid> fineGrid) override; + virtual void limitToSubDomain(SPtr<BoundingBox> subDomainBox, LbmOrGks lbmOrGks) override; - CUDA_HOST virtual void limitToSubDomain(SPtr<BoundingBox> subDomainBox, LbmOrGks lbmOrGks) override; + void freeMemory() override; - CUDA_HOST void freeMemory() override; + uint getLevel(real levelNull) const; + uint getLevel() const; - CUDA_HOST uint getLevel(real levelNull) const; - CUDA_HOST uint getLevel() const; - CUDA_HOST void setTriangularMeshDiscretizationStrategy(TriangularMeshDiscretizationStrategy* triangularMeshDiscretizationStrategy); - CUDA_HOST TriangularMeshDiscretizationStrategy* getTriangularMeshDiscretizationStrategy(); + void setTriangularMeshDiscretizationStrategy(TriangularMeshDiscretizationStrategy *triangularMeshDiscretizationStrategy); + TriangularMeshDiscretizationStrategy *getTriangularMeshDiscretizationStrategy(); - CUDA_HOST uint getNumberOfSolidBoundaryNodes() const override; - CUDA_HOST void setNumberOfSolidBoundaryNodes(uint numberOfSolidBoundaryNodes) override; + uint getNumberOfSolidBoundaryNodes() const override; + void setNumberOfSolidBoundaryNodes(uint numberOfSolidBoundaryNodes) override; - CUDA_HOST real getQValue(const uint index, const uint dir) const override; - CUDA_HOST uint getQPatch(const uint index) const override; + real getQValue(const uint index, const uint dir) const override; + uint getQPatch(const uint index) const override; - CUDA_HOST void setInnerRegionFromFinerGrid( bool innerRegionFromFinerGrid ) override; + void setInnerRegionFromFinerGrid(bool innerRegionFromFinerGrid) override; - CUDA_HOST void setNumberOfLayers( uint numberOfLayers ) override; + void setNumberOfLayers(uint numberOfLayers) override; public: Distribution distribution; - HOSTDEVICE void initalNodeToOutOfGrid(uint index); + void initalNodeToOutOfGrid(uint index); - HOSTDEVICE void findInnerNode(uint index); + void findInnerNodes(); + void findInnerNode(uint index); - HOSTDEVICE void discretize(Object* object, char innerType, char outerType); + void discretize(Object *object, char innerType, char outerType); - bool isInside(const Cell& cell) const; + bool isInside(const Cell &cell) const; - HOSTDEVICE void setInnerBasedOnFinerGrid(const SPtr<Grid> fineGrid); - - HOSTDEVICE void addOverlap(); - HOSTDEVICE void setOverlapTmp( uint index ); - HOSTDEVICE void setOverlapFluid( uint index ); - - HOSTDEVICE void fixRefinementIntoWall(uint xIndex, uint yIndex, uint zIndex, int dir); - HOSTDEVICE void findStopperNode(uint index); - HOSTDEVICE void findEndOfGridStopperNode(uint index); - HOSTDEVICE void findSolidStopperNode(uint index); - HOSTDEVICE void findBoundarySolidNode(uint index); - - HOSTDEVICE void findGridInterfaceCF(uint index, GridImp& finerGrid, LbmOrGks lbmOrGks); - HOSTDEVICE void findGridInterfaceFC(uint index, GridImp& finerGrid); - HOSTDEVICE void findOverlapStopper(uint index, GridImp& finerGrid); - HOSTDEVICE void findInvalidBoundaryNodes(uint index); - - HOSTDEVICE void setNodeTo(uint index, char type); - HOSTDEVICE bool isNode(uint index, char type) const; - HOSTDEVICE bool nodeInNextCellIs(int index, char type) const; - HOSTDEVICE bool hasAllNeighbors(uint index) const; - HOSTDEVICE bool hasNeighborOfType(uint index, char type)const; - HOSTDEVICE bool cellContainsOnly(Cell &cell, char type) const; - HOSTDEVICE bool cellContainsOnly(Cell &cell, char typeA, char typeB) const; - - HOSTDEVICE const Object* getObject() const override; - - HOSTDEVICE Field getField() const; - HOSTDEVICE char getFieldEntry(uint index) const override; - HOSTDEVICE void setFieldEntry(uint matrixIndex, char type) override; - - - HOSTDEVICE real getDelta() const override; - HOSTDEVICE uint getSize() const override; - HOSTDEVICE uint getSparseSize() const override; - HOSTDEVICE int getSparseIndex(uint matrixIndex) const override; - CUDA_HOST real* getDistribution() const override; - CUDA_HOST int* getDirection() const override; - CUDA_HOST int getStartDirection() const override; - CUDA_HOST int getEndDirection() const override; - - HOSTDEVICE Vertex getMinimumOnNode(Vertex exact) const override; - HOSTDEVICE Vertex getMaximumOnNode(Vertex exact) const override; - - HOSTDEVICE real getStartX() const override; - HOSTDEVICE real getStartY() const override; - HOSTDEVICE real getStartZ() const override; - HOSTDEVICE real getEndX() const override; - HOSTDEVICE real getEndY() const override; - HOSTDEVICE real getEndZ() const override; - HOSTDEVICE uint getNumberOfNodesX() const override; - HOSTDEVICE uint getNumberOfNodesY() const override; - HOSTDEVICE uint getNumberOfNodesZ() const override; - CUDA_HOST void getNodeValues(real *xCoords, real *yCoords, real *zCoords, uint *neighborX, uint *neighborY, uint *neighborZ, uint *neighborNegative, uint *geo) const override; - - HOSTDEVICE uint getNumberOfNodesCF() const override; - HOSTDEVICE uint getNumberOfNodesFC() const override; - CUDA_HOST void getGridInterfaceIndices(uint* iCellCfc, uint* iCellCff, uint* iCellFcc, uint* iCellFcf) const override; - CUDA_HOST static void getGridInterface(uint* gridInterfaceList, const uint* oldGridInterfaceList, uint size); - CUDA_HOST bool isSparseIndexInFluidNodeIndicesBorder(uint &sparseIndex) const override; - - int* getNeighborsX() const override; - int* getNeighborsY() const override; - int* getNeighborsZ() const override; - int* getNeighborsNegative() const override; + void setInnerBasedOnFinerGrid(const SPtr<Grid> fineGrid); + + void addOverlap(); + void setOverlapTmp(uint index); + void setOverlapFluid(uint index); - CUDA_HOST uint* getCF_coarse() const override; - CUDA_HOST uint* getCF_fine() const override; - CUDA_HOST uint* getCF_offset() const override; + void fixRefinementIntoWall(uint xIndex, uint yIndex, uint zIndex, int dir); + void findStopperNode(uint index); + void findEndOfGridStopperNode(uint index); + void findSolidStopperNode(uint index); + void findBoundarySolidNode(uint index); + void findGridInterfaceCF(uint index, GridImp &finerGrid, LbmOrGks lbmOrGks); + void findGridInterfaceFC(uint index, GridImp &finerGrid); + void findOverlapStopper(uint index, GridImp &finerGrid); + void findInvalidBoundaryNodes(uint index); - CUDA_HOST uint* getFC_coarse() const override; - CUDA_HOST uint* getFC_fine() const override; - CUDA_HOST uint* getFC_offset() const override; + void setNodeTo(uint index, char type); + bool isNode(uint index, char type) const; + bool nodeInNextCellIs(int index, char type) const; + bool hasAllNeighbors(uint index) const; + bool hasNeighborOfType(uint index, char type) const; + bool cellContainsOnly(Cell &cell, char type) const; + bool cellContainsOnly(Cell &cell, char typeA, char typeB) const; - SPtr<GridStrategy> getGridStrategy() const override; + const Object* getObject() const override; + Field getField() const; + char getFieldEntry(uint index) const override; + void setFieldEntry(uint matrixIndex, char type) override; - HOSTDEVICE void print() const; + real getDelta() const override; + uint getSize() const override; + uint getSparseSize() const override; + int getSparseIndex(uint matrixIndex) const override; + real* getDistribution() const override; + int* getDirection() const override; + int getStartDirection() const override; + int getEndDirection() const override; + + Vertex getMinimumOnNode(Vertex exact) const override; + Vertex getMaximumOnNode(Vertex exact) const override; + + real getStartX() const override; + real getStartY() const override; + real getStartZ() const override; + real getEndX() const override; + real getEndY() const override; + real getEndZ() const override; + uint getNumberOfNodesX() const override; + uint getNumberOfNodesY() const override; + uint getNumberOfNodesZ() const override; + void getNodeValues(real *xCoords, real *yCoords, real *zCoords, uint *neighborX, uint *neighborY, uint *neighborZ, uint *neighborNegative, uint *geo) const override; + + uint getNumberOfNodesCF() const override; + uint getNumberOfNodesFC() const override; + void getGridInterfaceIndices(uint *iCellCfc, uint *iCellCff, uint *iCellFcc, uint *iCellFcf) const override; + + static void getGridInterface(uint *gridInterfaceList, const uint *oldGridInterfaceList, uint size); + + bool isSparseIndexInFluidNodeIndicesBorder(uint &sparseIndex) const override; + + int *getNeighborsX() const override; + int* getNeighborsY() const override; + int* getNeighborsZ() const override; + int* getNeighborsNegative() const override; + + uint *getCF_coarse() const override; + uint *getCF_fine() const override; + uint *getCF_offset() const override; + + uint *getFC_coarse() const override; + uint *getFC_fine() const override; + uint *getFC_offset() const override; + + void print() const; public: - CUDA_HOST virtual void findSparseIndices(SPtr<Grid> fineGrid) override; + virtual void findSparseIndices(SPtr<Grid> fineGrid) override; - CUDA_HOST void updateSparseIndices(); - HOSTDEVICE void setNeighborIndices(uint index); - HOSTDEVICE real getFirstFluidNode(real coords[3], int direction, real startCoord) const override; - HOSTDEVICE real getLastFluidNode(real coords[3], int direction, real startCoord) const override; + void findForGridInterfaceNewIndices(SPtr<GridImp> fineGrid); + void updateSparseIndices(); + void setNeighborIndices(uint index); + real getFirstFluidNode(real coords[3], int direction, real startCoord) const override; + real getLastFluidNode(real coords[3], int direction, real startCoord) const override; private: - HOSTDEVICE void setStopperNeighborCoords(uint index); - HOSTDEVICE void getNeighborCoords(real &neighborX, real &neighborY, real &neighborZ, real x, real y, real z) const; - HOSTDEVICE real getNeighborCoord(bool periodicity, real endCoord, real coords[3], int direction) const; - HOSTDEVICE void getNegativeNeighborCoords(real &neighborX, real &neighborY, real &neighborZ, real x, real y, real z) const; - HOSTDEVICE real getNegativeNeighborCoord(bool periodicity, real endCoord, real coords[3], int direction) const; + void setStopperNeighborCoords(uint index); + void getNeighborCoords(real &neighborX, real &neighborY, real &neighborZ, real x, real y, real z) const; + real getNeighborCoord(bool periodicity, real endCoord, real coords[3], int direction) const; + void getNegativeNeighborCoords(real &neighborX, real &neighborY, real &neighborZ, real x, real y, real z) const; + real getNegativeNeighborCoord(bool periodicity, real endCoord, real coords[3], int direction) const; - HOSTDEVICE int getSparseIndex(const real &expectedX, const real &expectedY, const real &expectedZ) const; + int getSparseIndex(const real &expectedX, const real &expectedY, const real &expectedZ) const; - HOSTDEVICE static real getMinimumOnNodes(const real& minExact, const real& decimalStart, const real& delta); - HOSTDEVICE static real getMaximumOnNodes(const real& maxExact, const real& decimalStart, const real& delta); + static real getMinimumOnNodes(const real &minExact, const real &decimalStart, const real &delta); + static real getMaximumOnNodes(const real &maxExact, const real &decimalStart, const real &delta); public: - HOSTDEVICE BoundingBox getBoundingBoxOnNodes(Triangle &triangle) const; + BoundingBox getBoundingBoxOnNodes(Triangle &triangle) const; + + void mesh(Object *object) override; - CUDA_HOST void mesh(Object* object) override; + void mesh(TriangularMesh &geometry) override; + void mesh(Triangle &triangle); - CUDA_HOST void mesh(TriangularMesh &geometry) override; - HOSTDEVICE void mesh(Triangle &triangle); + void closeNeedleCells() override; + bool closeCellIfNeedle(uint index); - CUDA_HOST void closeNeedleCells() override; - HOSTDEVICE bool closeCellIfNeedle(uint index); + void closeNeedleCellsThinWall() override; + bool closeCellIfNeedleThinWall(uint index); - CUDA_HOST void closeNeedleCellsThinWall() override; - HOSTDEVICE bool closeCellIfNeedleThinWall(uint index); + void findQs(Object *object) override; + void findQs(TriangularMesh &triangularMesh); + void findQs(Triangle &triangle); - CUDA_HOST void findQs(Object* object) override; - CUDA_HOST void findQs(TriangularMesh &triangularMesh); - HOSTDEVICE void findQs(Triangle &triangle); + void findQsPrimitive(Object *object); - CUDA_HOST void findQsPrimitive(Object* object); private: enum class qComputationStageType{ @@ -288,23 +318,27 @@ private: } qComputationStage; public: - CUDA_HOST void enableFindSolidBoundaryNodes() override{ qComputationStage = qComputationStageType::FindSolidBoundaryNodes; } - CUDA_HOST void enableComputeQs() override{ qComputationStage = qComputationStageType::ComputeQs; } + void enableFindSolidBoundaryNodes() override + { + qComputationStage = qComputationStageType::FindSolidBoundaryNodes; + } + void enableComputeQs() override { qComputationStage = qComputationStageType::ComputeQs; } private: - HOSTDEVICE void setDebugPoint(uint index, int pointValue); - HOSTDEVICE void calculateQs(const Vertex &point, const Triangle &triangle) const; - HOSTDEVICE void calculateQs(const uint index, const Vertex &point, const Triangle &triangle) const; - CUDA_HOST void calculateQs(const uint index, const Vertex &point, Object* object) const; + void setDebugPoint(uint index, int pointValue); + void calculateQs(const Vertex &point, const Triangle &triangle) const; + void calculateQs(const uint index, const Vertex &point, const Triangle &triangle) const; + void calculateQs(const uint index, const Vertex &point, Object *object) const; - CUDA_HOST bool checkIfAtLeastOneValidQ(const uint index, const Vertex &point, const Triangle &triangle) const; + bool checkIfAtLeastOneValidQ(const uint index, const Vertex &point, const Triangle &triangle) const; - CUDA_HOST bool checkIfAtLeastOneValidQ(const uint index, const Vertex &point, Object* object) const; + bool checkIfAtLeastOneValidQ(const uint index, const Vertex &point, Object *object) const; -public: + void allocateQs(); +public: void findCommunicationIndices(int direction, SPtr<BoundingBox> subDomainBox, LbmOrGks lbmOrGks) override; - void findCommunicationIndex( uint index, real coordinate, real limit, int direction ); + void findCommunicationIndex(uint index, real coordinate, real limit, int direction); uint getNumberOfSendNodes(int direction) override; uint getNumberOfReceiveNodes(int direction) override; @@ -328,19 +362,13 @@ public: public: - - struct CommunicationIndices - { + struct CommunicationIndices { std::vector<uint> sendIndices; std::vector<uint> receiveIndices; }; std::array<CommunicationIndices, 6> communicationIndices; - -private: - friend class GridGpuStrategy; - friend class GridCpuStrategy; }; #endif diff --git a/src/gpu/GridGenerator/grid/GridInterface.cu b/src/gpu/GridGenerator/grid/GridInterface.cpp similarity index 83% rename from src/gpu/GridGenerator/grid/GridInterface.cu rename to src/gpu/GridGenerator/grid/GridInterface.cpp index 423f9788fe44e73c37c1c09c726596923737e871..47cb8ef9dd7c4704e420ca68888ce0d56c48a59e 100644 --- a/src/gpu/GridGenerator/grid/GridInterface.cu +++ b/src/gpu/GridGenerator/grid/GridInterface.cpp @@ -1,6 +1,39 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids 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. +// +// VirtualFluids 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 VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file GridInterface.cpp +//! \ingroup grid +//! \author Soeren Peters, Stephan Lenz +//======================================================================================= #include "GridInterface.h" #include <iostream> +#include <cstring> #include "grid/distributions/D3Q27.h" #include "grid/GridImp.h" @@ -132,7 +165,7 @@ void GridInterface::findInterfaceFC(const uint& indexOnCoarseGrid, GridImp* coar for (const auto dir : coarseGrid->distribution) { - const int neighborIndex = coarseGrid->transCoordToIndex(x + dir[0] * coarseGrid->getDelta(), y + dir[1] * coarseGrid->getDelta(), z + dir[2] * coarseGrid->getDelta()); + const uint neighborIndex = coarseGrid->transCoordToIndex(x + dir[0] * coarseGrid->getDelta(), y + dir[1] * coarseGrid->getDelta(), z + dir[2] * coarseGrid->getDelta()); if (neighborIndex != INVALID_INDEX) { const bool neighborBelongsToCoarseToFineInterpolationCell = coarseGrid->getField().isCoarseToFineNode(neighborIndex); @@ -163,7 +196,7 @@ void GridInterface::findOverlapStopper(const uint& indexOnCoarseGrid, GridImp* c if (indexOnFineGridFC == -1) return; - real x, y, z; + real x, y, z; coarseGrid->transIndexToCoords(indexOnCoarseGrid, x, y, z); bool neighborBelongsToFineToCoarseInterpolationCell = false; @@ -172,7 +205,7 @@ void GridInterface::findOverlapStopper(const uint& indexOnCoarseGrid, GridImp* c //if (dir[0] > 0 || dir[1] > 0 || dir[2] > 0) //only Esoteric Twist stopper, not perfectly implemented // continue; //should not be here, should be made conditional - const int neighborIndex = coarseGrid->transCoordToIndex(x + dir[0] * coarseGrid->getDelta(), y + dir[1] * coarseGrid->getDelta(), z + dir[2] * coarseGrid->getDelta()); + const uint neighborIndex = coarseGrid->transCoordToIndex(x + dir[0] * coarseGrid->getDelta(), y + dir[1] * coarseGrid->getDelta(), z + dir[2] * coarseGrid->getDelta()); neighborBelongsToFineToCoarseInterpolationCell = neighborIndex != INVALID_INDEX ? coarseGrid->getField().isFineToCoarseNode(neighborIndex) : false; if (neighborBelongsToFineToCoarseInterpolationCell) { @@ -256,7 +289,7 @@ void GridInterface::findForGridInterfaceSparseIndexFC(GridImp* coarseGrid, GridI findSparseIndex(fc.fine, fineGrid, index); } -CUDA_HOST void GRIDGENERATOR_EXPORT GridInterface::repairGridInterfaceOnMultiGPU(SPtr<GridImp> coarseGrid, SPtr<GridImp> fineGrid) +void GRIDGENERATOR_EXPORT GridInterface::repairGridInterfaceOnMultiGPU(SPtr<GridImp> coarseGrid, SPtr<GridImp> fineGrid) { { std::vector<uint> tmpCFC; @@ -332,7 +365,7 @@ void GridInterface::findSparseIndex(uint* indices, GridImp* grid, uint index) indices[index] = sparseIndex; } -HOSTDEVICE uint GridInterface::findOffsetCF(const uint& indexOnCoarseGrid, GridImp* coarseGrid, uint interfaceIndex) +uint GridInterface::findOffsetCF(const uint& indexOnCoarseGrid, GridImp* coarseGrid, uint interfaceIndex) { real x, y, z; coarseGrid->transIndexToCoords(indexOnCoarseGrid, x, y, z); @@ -367,7 +400,7 @@ HOSTDEVICE uint GridInterface::findOffsetCF(const uint& indexOnCoarseGrid, GridI return indexOnCoarseGrid; } -HOSTDEVICE uint GridInterface::findOffsetFC(const uint& indexOnFineGrid, GridImp* fineGrid, uint interfaceIndex) +uint GridInterface::findOffsetFC(const uint& indexOnFineGrid, GridImp* fineGrid, uint interfaceIndex) { real x, y, z; fineGrid->transIndexToCoords(indexOnFineGrid, x, y, z); diff --git a/src/gpu/GridGenerator/grid/GridInterface.h b/src/gpu/GridGenerator/grid/GridInterface.h index 2044fb494924046ac255ad1a1e7cc74496adae6e..b5f71317e7755a8b6bcfe3da084e0fc9155642f8 100644 --- a/src/gpu/GridGenerator/grid/GridInterface.h +++ b/src/gpu/GridGenerator/grid/GridInterface.h @@ -1,3 +1,35 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids 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. +// +// VirtualFluids 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 VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file GridInterface.h +//! \ingroup grid +//! \author Soeren Peters, Stephan Lenz +//======================================================================================= #ifndef GRID_INTERFACE_H #define GRID_INTERFACE_H @@ -8,26 +40,26 @@ class GridImp; class GridInterface { public: - HOSTDEVICE GRIDGENERATOR_EXPORT GridInterface(); - HOSTDEVICE GRIDGENERATOR_EXPORT ~GridInterface(); + GRIDGENERATOR_EXPORT GridInterface(); + GRIDGENERATOR_EXPORT ~GridInterface(); - HOSTDEVICE void GRIDGENERATOR_EXPORT findInterfaceCF(const uint& indexOnCoarseGrid, GridImp* coarseGrid, GridImp* fineGrid); - HOSTDEVICE void GRIDGENERATOR_EXPORT findBoundaryGridInterfaceCF(const uint& indexOnCoarseGrid, GridImp* coarseGrid, GridImp* fineGrid); + void GRIDGENERATOR_EXPORT findInterfaceCF(const uint& indexOnCoarseGrid, GridImp* coarseGrid, GridImp* fineGrid); + void GRIDGENERATOR_EXPORT findBoundaryGridInterfaceCF(const uint& indexOnCoarseGrid, GridImp* coarseGrid, GridImp* fineGrid); - HOSTDEVICE void GRIDGENERATOR_EXPORT findInterfaceCF_GKS(const uint& indexOnCoarseGrid, GridImp* coarseGrid, GridImp* fineGrid); + void GRIDGENERATOR_EXPORT findInterfaceCF_GKS(const uint& indexOnCoarseGrid, GridImp* coarseGrid, GridImp* fineGrid); - HOSTDEVICE void GRIDGENERATOR_EXPORT findInterfaceFC(const uint& indexOnCoarseGrid, GridImp* coarseGrid, GridImp* fineGrid); - HOSTDEVICE void GRIDGENERATOR_EXPORT findOverlapStopper(const uint& indexOnCoarseGrid, GridImp* coarseGrid, GridImp* fineGrid); + void GRIDGENERATOR_EXPORT findInterfaceFC(const uint& indexOnCoarseGrid, GridImp* coarseGrid, GridImp* fineGrid); + void GRIDGENERATOR_EXPORT findOverlapStopper(const uint& indexOnCoarseGrid, GridImp* coarseGrid, GridImp* fineGrid); - HOSTDEVICE void GRIDGENERATOR_EXPORT findInvalidBoundaryNodes(const uint& indexOnCoarseGrid, GridImp* coarseGrid); + void GRIDGENERATOR_EXPORT findInvalidBoundaryNodes(const uint& indexOnCoarseGrid, GridImp* coarseGrid); - HOSTDEVICE void GRIDGENERATOR_EXPORT findForGridInterfaceSparseIndexCF(GridImp* coarseGrid, GridImp* fineGrid, uint index); - HOSTDEVICE void GRIDGENERATOR_EXPORT findForGridInterfaceSparseIndexFC(GridImp* coarseGrid, GridImp* fineGrid, uint index); + void GRIDGENERATOR_EXPORT findForGridInterfaceSparseIndexCF(GridImp* coarseGrid, GridImp* fineGrid, uint index); + void GRIDGENERATOR_EXPORT findForGridInterfaceSparseIndexFC(GridImp* coarseGrid, GridImp* fineGrid, uint index); - CUDA_HOST void GRIDGENERATOR_EXPORT repairGridInterfaceOnMultiGPU(SPtr<GridImp> coarseGrid, SPtr<GridImp> fineGrid); + void GRIDGENERATOR_EXPORT repairGridInterfaceOnMultiGPU(SPtr<GridImp> coarseGrid, SPtr<GridImp> fineGrid); - HOSTDEVICE void GRIDGENERATOR_EXPORT print() const; + void GRIDGENERATOR_EXPORT print() const; struct Interface { @@ -38,16 +70,16 @@ public: private: - HOSTDEVICE uint getCoarseToFineIndexOnFineGrid(const uint& indexOnCoarseGrid, const GridImp* coarseGrid, const GridImp* fineGrid); - HOSTDEVICE bool isNeighborFineInvalid(real x, real y, real z, const GridImp* coarseGrid, const GridImp* fineGrid); + uint getCoarseToFineIndexOnFineGrid(const uint& indexOnCoarseGrid, const GridImp* coarseGrid, const GridImp* fineGrid); + bool isNeighborFineInvalid(real x, real y, real z, const GridImp* coarseGrid, const GridImp* fineGrid); - HOSTDEVICE uint getFineToCoarseIndexOnFineGrid(const uint& indexOnCoarseGrid, const GridImp* coarseGrid, const GridImp* fineGrid); + uint getFineToCoarseIndexOnFineGrid(const uint& indexOnCoarseGrid, const GridImp* coarseGrid, const GridImp* fineGrid); - HOSTDEVICE static void findSparseIndex(uint* indices, GridImp* grid, uint index); + static void findSparseIndex(uint* indices, GridImp* grid, uint index); - HOSTDEVICE uint findOffsetCF( const uint& indexOnCoarseGrid, GridImp* coarseGrid, uint interfaceIndex ); + uint findOffsetCF( const uint& indexOnCoarseGrid, GridImp* coarseGrid, uint interfaceIndex ); - HOSTDEVICE uint findOffsetFC( const uint& indexOnCoarseGrid, GridImp* coarseGrid, uint interfaceIndex ); + uint findOffsetFC( const uint& indexOnCoarseGrid, GridImp* coarseGrid, uint interfaceIndex ); }; diff --git a/src/gpu/GridGenerator/grid/GridStrategy/GridCpuStrategy/GridCpuStrategy.cpp b/src/gpu/GridGenerator/grid/GridStrategy/GridCpuStrategy/GridCpuStrategy.cpp deleted file mode 100644 index 3d5cda94a16f5948cd6fe60ab4aa8acf8ca7fadd..0000000000000000000000000000000000000000 --- a/src/gpu/GridGenerator/grid/GridStrategy/GridCpuStrategy/GridCpuStrategy.cpp +++ /dev/null @@ -1,291 +0,0 @@ -#include "GridCpuStrategy.h" - -#include <time.h> -#include <stdio.h> -#include <omp.h> -#include <vector> -#include <iostream> - -#include "geometries/TriangularMesh/TriangularMesh.h" - -#include "grid/distributions/Distribution.h" -#include "grid/GridInterface.h" -#include "grid/GridImp.h" -#include "grid/NodeValues.h" - -using namespace vf::gpu; - -void GridCpuStrategy::allocateGridMemory(SPtr<GridImp> grid) -{ - grid->neighborIndexX = new int[grid->size]; - grid->neighborIndexY = new int[grid->size]; - grid->neighborIndexZ = new int[grid->size]; - grid->neighborIndexNegative = new int[grid->size]; - - grid->sparseIndices = new int[grid->size]; - - grid->qIndices = new uint[grid->size]; - for (size_t i = 0; i < grid->size; i++) - grid->qIndices[i] = INVALID_INDEX; - - // unsigned long distributionSize = grid->size * (grid->distribution.dir_end + 1); - // real sizeInMB = distributionSize * sizeof(real) / (1024.f*1024.f); - - // //*logging::out << logging::Logger::LOW << "Allocating " << sizeInMB << " [MB] host memory for distributions.\n"; - - // grid->distribution.f = new real[distributionSize](); // automatic initialized with zeros - //for (uint index = 0; index < distributionSize; index++) grid->distribution.f[index] = -1.0; -} - -void GridCpuStrategy::allocateQs(SPtr<GridImp> grid) -{ - grid->qPatches = new uint[grid->getNumberOfSolidBoundaryNodes()]; - //grid->qPatches.resize( grid->getNumberOfSolidBoundaryNodes() ); - - for( uint i = 0; i < grid->getNumberOfSolidBoundaryNodes(); i++ ) - grid->qPatches[i] = INVALID_INDEX; - - const uint numberOfQs = grid->getNumberOfSolidBoundaryNodes() * (grid->distribution.dir_end + 1); - grid->qValues = new real[numberOfQs]; -#pragma omp parallel for - for (int i = 0; i < (int)numberOfQs; i++) - grid->qValues[i] = -1.0; -} - -void GridCpuStrategy::initalNodesToOutOfGrid(SPtr<GridImp> grid) -{ -#pragma omp parallel for - for (int index = 0; index < (int)grid->size; index++) - grid->initalNodeToOutOfGrid(index); -} - -void GridCpuStrategy::allocateFieldMemory(Field* field) -{ - field->field = new char[field->size]; -} - - -void GridCpuStrategy::findInnerNodes(SPtr<GridImp> grid) -{ -#pragma omp parallel for - for (int index = 0; index < (int)grid->size; index++) - grid->findInnerNode(index); -} - -void GridCpuStrategy::addOverlap(SPtr<GridImp> grid) -{ - -#pragma omp parallel for - for( int index = 0; index < (int)grid->size; index++ ) - grid->setOverlapTmp( index ); - -#pragma omp parallel for - for( int index = 0; index < (int)grid->size; index++ ) - grid->setOverlapFluid( index ); -} - - -void GridCpuStrategy::fixOddCells(SPtr<GridImp> grid) -{ -#pragma omp parallel for - for (int index = 0; index < (int)grid->size; index++) - grid->fixOddCell(index); -} - -void GridCpuStrategy::fixRefinementIntoWall(SPtr<GridImp> grid) -{ -#pragma omp parallel for - for (int xIdx = 0; xIdx < (int)grid->nx; xIdx++){ - for (uint yIdx = 0; yIdx < grid->ny; yIdx++){ - grid->fixRefinementIntoWall( xIdx, yIdx, 0 , 3 ); - grid->fixRefinementIntoWall( xIdx, yIdx, grid->nz-1, -3 ); - } - } - -#pragma omp parallel for - for (int xIdx = 0; xIdx < (int)grid->nx; xIdx++){ - for (uint zIdx = 0; zIdx < grid->nz; zIdx++){ - grid->fixRefinementIntoWall( xIdx, 0, zIdx, 2 ); - grid->fixRefinementIntoWall( xIdx, grid->ny-1, zIdx, -2 ); - } - } - -#pragma omp parallel for - for (int yIdx = 0; yIdx < (int)grid->ny; yIdx++){ - for (uint zIdx = 0; zIdx < grid->nz; zIdx++){ - grid->fixRefinementIntoWall( 0, yIdx, zIdx, 1 ); - grid->fixRefinementIntoWall( grid->nx-1, yIdx, zIdx, -1 ); - } - } -} - - -void GridCpuStrategy::findStopperNodes(SPtr<GridImp> grid) -{ -#pragma omp parallel for - for (int index = 0; index < (int)grid->size; index++) - grid->findStopperNode(index); -} - -void GridCpuStrategy::findEndOfGridStopperNodes(SPtr<GridImp> grid) -{ -#pragma omp parallel for - for (int index = 0; index < (int)grid->size; index++) - grid->findEndOfGridStopperNode(index); -} - -void GridCpuStrategy::findSolidStopperNodes(SPtr<GridImp> grid) -{ -#pragma omp parallel for - for (int index = 0; index < (int)grid->size; index++) - grid->findSolidStopperNode(index); -} - -void GridCpuStrategy::findBoundarySolidNodes(SPtr<GridImp> grid) -{ -//#pragma omp parallel for - for (int index = 0; index < (int)grid->size; index++) - { - grid->findBoundarySolidNode(index); - } -} - -void GridCpuStrategy::mesh(SPtr<GridImp> grid, TriangularMesh &geom) -{ -#pragma omp parallel for - for (int i = 0; i < geom.size; i++) - grid->mesh(geom.triangles[i]); -} - -uint GridCpuStrategy::closeNeedleCells(SPtr<GridImp> grid) -{ - uint numberOfClosedNeedleCells = 0; - -#pragma omp parallel for reduction(+:numberOfClosedNeedleCells) - for (int index = 0; index < (int)grid->size; index++) - { - if( grid->closeCellIfNeedle(index) ) - numberOfClosedNeedleCells++; - } - - return numberOfClosedNeedleCells; -} - -uint GridCpuStrategy::closeNeedleCellsThinWall(SPtr<GridImp> grid) -{ - uint numberOfClosedNeedleCells = 0; - -#pragma omp parallel for reduction(+:numberOfClosedNeedleCells) - for (int index = 0; index < (int)grid->size; index++) - { - if( grid->closeCellIfNeedleThinWall(index) ) - numberOfClosedNeedleCells++; - } - - return numberOfClosedNeedleCells; -} - -void GridCpuStrategy::findQs(SPtr<GridImp> grid, TriangularMesh &geom) -{ -#pragma omp parallel for - for (int i = 0; i < geom.size; i++) - grid->findQs(geom.triangles[i]); -} - - -void GridCpuStrategy::findGridInterface(SPtr<GridImp> grid, SPtr<GridImp> fineGrid, LbmOrGks lbmOrGks) -{ - const auto coarseLevel = grid->getLevel(); - const auto fineLevel = fineGrid->getLevel(); - - *logging::out << logging::Logger::INFO_INTERMEDIATE << "find interface level " << coarseLevel << " -> " << fineLevel; - - grid->gridInterface = new GridInterface(); - // TODO: this is stupid! concave refinements can easily have many more interface cells - const uint sizeCF = 10*(fineGrid->nx * fineGrid->ny + fineGrid->ny * fineGrid->nz + fineGrid->nx * fineGrid->nz); - grid->gridInterface->cf.coarse = new uint[sizeCF]; - grid->gridInterface->cf.fine = new uint[sizeCF]; - grid->gridInterface->cf.offset = new uint[sizeCF]; - grid->gridInterface->fc.coarse = new uint[sizeCF]; - grid->gridInterface->fc.fine = new uint[sizeCF]; - grid->gridInterface->fc.offset = new uint[sizeCF]; - - for (uint index = 0; index < grid->getSize(); index++) - grid->findGridInterfaceCF(index, *fineGrid, lbmOrGks); - - for (uint index = 0; index < grid->getSize(); index++) - grid->findGridInterfaceFC(index, *fineGrid); - - for (uint index = 0; index < grid->getSize(); index++) - grid->findOverlapStopper(index, *fineGrid); - - if( lbmOrGks == GKS ) - { - for (uint index = 0; index < grid->getSize(); index++) - grid->findInvalidBoundaryNodes(index); - } - - *logging::out << logging::Logger::INFO_INTERMEDIATE << " ... done. \n"; -} - -void GridCpuStrategy::findSparseIndices(SPtr<GridImp> coarseGrid, SPtr<GridImp> fineGrid) -{ - *logging::out << logging::Logger::INFO_INTERMEDIATE << "Find sparse indices..."; - - coarseGrid->updateSparseIndices(); - findForNeighborsNewIndices(coarseGrid); - if (fineGrid) - { - fineGrid->updateSparseIndices(); - findForGridInterfaceNewIndices(coarseGrid, fineGrid); - } - - const uint newGridSize = coarseGrid->getSparseSize(); - *logging::out << logging::Logger::INFO_INTERMEDIATE << "... done. new size: " << newGridSize << ", delete nodes:" << coarseGrid->getSize() - newGridSize << "\n"; -} - - -void GridCpuStrategy::findForNeighborsNewIndices(SPtr<GridImp> grid) -{ -#pragma omp parallel for - for (int index = 0; index < (int)grid->getSize(); index++) - grid->setNeighborIndices(index); -} - -void GridCpuStrategy::findForGridInterfaceNewIndices(SPtr<GridImp> grid, SPtr<GridImp> fineGrid) -{ -#pragma omp parallel for - for (int index = 0; index < (int)grid->getNumberOfNodesCF(); index++) - grid->gridInterface->findForGridInterfaceSparseIndexCF(grid.get(), fineGrid.get(), index); - -#pragma omp parallel for - for (int index = 0; index < (int)grid->getNumberOfNodesFC(); index++) - grid->gridInterface->findForGridInterfaceSparseIndexFC(grid.get(), fineGrid.get(), index); -} - - - -void GridCpuStrategy::freeFieldMemory(Field* field) -{ - delete[] field->field; -} - - - -void GridCpuStrategy::freeMemory(SPtr<GridImp> grid) -{ - //if(grid->gridInterface) - //delete grid->gridInterface; - - if( grid->neighborIndexX != nullptr ) { delete[] grid->neighborIndexX; grid->neighborIndexX = nullptr; } - if( grid->neighborIndexY != nullptr ) { delete[] grid->neighborIndexY; grid->neighborIndexY = nullptr; } - if( grid->neighborIndexZ != nullptr ) { delete[] grid->neighborIndexZ; grid->neighborIndexZ = nullptr; } - if( grid->neighborIndexNegative != nullptr ) { delete[] grid->neighborIndexNegative; grid->neighborIndexNegative = nullptr; } - if( grid->sparseIndices != nullptr ) { delete[] grid->sparseIndices; grid->sparseIndices = nullptr; } - if( grid->qIndices != nullptr ) { delete[] grid->qIndices; grid->qIndices = nullptr; } - if( grid->qValues != nullptr ) { delete[] grid->qValues; grid->qValues = nullptr; } - if( grid->qPatches != nullptr ) { delete[] grid->qPatches; grid->qPatches = nullptr; } - - //delete[] grid->distribution.f; -} - diff --git a/src/gpu/GridGenerator/grid/GridStrategy/GridCpuStrategy/GridCpuStrategy.h b/src/gpu/GridGenerator/grid/GridStrategy/GridCpuStrategy/GridCpuStrategy.h deleted file mode 100644 index af4b1791b0970f1f26483b46953ebc2512dd23bc..0000000000000000000000000000000000000000 --- a/src/gpu/GridGenerator/grid/GridStrategy/GridCpuStrategy/GridCpuStrategy.h +++ /dev/null @@ -1,55 +0,0 @@ -#ifndef GRID_CPU_STRATEGY_H -#define GRID_CPU_STRATEGY_H - -#include "global.h" - -#include "grid/GridStrategy/GridStrategy.h" - -class GridImp; -class TriangularMesh; - -class GRIDGENERATOR_EXPORT GridCpuStrategy : public GridStrategy -{ -public: - virtual ~GridCpuStrategy() {}; - - void allocateGridMemory(SPtr<GridImp> grid) override; - - void allocateQs(SPtr<GridImp> grid) override; - - void initalNodesToOutOfGrid(SPtr<GridImp> grid) override; - void fixOddCells(SPtr<GridImp> grid) override; - void findInnerNodes(SPtr<GridImp> grid) override; - void addOverlap(SPtr<GridImp> grid) override; - void fixRefinementIntoWall(SPtr<GridImp> grid) override; - void findStopperNodes(SPtr<GridImp> grid) override; - void findBoundarySolidNodes(SPtr<GridImp> grid) override; - void findEndOfGridStopperNodes(SPtr<GridImp> grid) override; - void findSolidStopperNodes(SPtr<GridImp> grid) override; - - void mesh(SPtr<GridImp> grid, TriangularMesh &geom) override; - - uint closeNeedleCells(SPtr<GridImp> grid) override; - uint closeNeedleCellsThinWall(SPtr<GridImp> grid) override; - - void findQs(SPtr<GridImp> grid, TriangularMesh &geom) override; - - void findGridInterface(SPtr<GridImp> grid, SPtr<GridImp> fineGrid, LbmOrGks lbmOrGks) override; - - void freeMemory(SPtr<GridImp> grid) override; - - - - virtual void copyDataFromGPU() {}; - -protected: - static void findForNeighborsNewIndices(SPtr<GridImp> grid); - static void findForGridInterfaceNewIndices(SPtr<GridImp> grid, SPtr<GridImp> fineGrid); -public: - void allocateFieldMemory(Field* field) override; - void freeFieldMemory(Field* field) override; - void findSparseIndices(SPtr<GridImp> coarseGrid, SPtr<GridImp> fineGrid) override; - -}; - -#endif \ No newline at end of file diff --git a/src/gpu/GridGenerator/grid/GridStrategy/GridGpuStrategy/GridGpuStrategy.cpp b/src/gpu/GridGenerator/grid/GridStrategy/GridGpuStrategy/GridGpuStrategy.cpp deleted file mode 100644 index a19daf22aba77480763c7c91f6bf29bb6ebacdd3..0000000000000000000000000000000000000000 --- a/src/gpu/GridGenerator/grid/GridStrategy/GridGpuStrategy/GridGpuStrategy.cpp +++ /dev/null @@ -1,430 +0,0 @@ -#include "GridGpuStrategy.h" - -#include "Core/Timer/Timer.h" - -#include "geometries/BoundingBox/BoundingBox.h" -#include "geometries/TriangularMesh/TriangularMesh.h" - -#include "grid/kernel/runGridKernelGPU.cuh" -#include "grid/distributions/Distribution.h" -#include "grid/GridImp.h" -#include "grid/GridInterface.h" - -#include "utilities/cuda/CudaErrorCheck.cu" -#include "utilities/cuda/LaunchParameter.cuh" - -void GridGpuStrategy::allocateGridMemory(SPtr<GridImp> grid) -{ - //printCudaInformation(0); - cudaSetDevice(0); - - this->allocDistribution(grid); - this->allocField(grid); - this->allocMatrixIndicesOnGPU(grid); - this->allocNeighborsIndices(grid); -} - -void GridGpuStrategy::allocateQs(SPtr<GridImp> grid) -{ -} - -void GridGpuStrategy::initalNodesToOutOfGrid(SPtr<GridImp> grid) -{ - -} - -void GridGpuStrategy::fixOddCells(SPtr<GridImp> grid) -{ -} - - - -void GridGpuStrategy::findInnerNodes(SPtr<GridImp> grid) -{ - //float time = runKernelInitalUniformGrid3d(LaunchParameter::make_2D1D_launchParameter(grid->size, 256), *grid.get()); -} - -void GridGpuStrategy::addOverlap(SPtr<GridImp> grid) -{ -} - -void GridGpuStrategy::fixRefinementIntoWall(SPtr<GridImp> grid) -{ -} - -void GridGpuStrategy::findStopperNodes(SPtr<GridImp> grid) -{ - -} - -void GridGpuStrategy::findBoundarySolidNodes(SPtr<GridImp> grid) -{ -} - -void GridGpuStrategy::findEndOfGridStopperNodes(SPtr<GridImp> grid) -{ - -} - -void GridGpuStrategy::findSolidStopperNodes(SPtr<GridImp> grid) -{ - -} - -void GridGpuStrategy::mesh(SPtr<GridImp> grid, TriangularMesh &geom) -{ - *logging::out << logging::Logger::INFO_INTERMEDIATE << "start meshing on GPU...\n"; - allocAndCopyTrianglesToGPU(geom); - - /*---------------------------------------------------------------------------------*/ - float time = runKernelToMesh(LaunchParameter::make_1D1D_launchParameter(geom.size, 256), *grid.get(), geom); - /*---------------------------------------------------------------------------------*/ - *logging::out << logging::Logger::INFO_INTERMEDIATE << "Time GPU build grid: " << time / 1000 << "sec\n"; - *logging::out << logging::Logger::INFO_INTERMEDIATE << "-------------------------------------------\n"; - - freeTrianglesFromGPU(geom); - -} - -uint GridGpuStrategy::closeNeedleCells(SPtr<GridImp> grid) -{ - return uint(); -} - -uint GridGpuStrategy::closeNeedleCellsThinWall(SPtr<GridImp> grid) -{ - return uint(); -} - - -void GridGpuStrategy::findQs(SPtr<GridImp> grid, TriangularMesh &geom) -{ - -} - - -void GridGpuStrategy::findGridInterface(SPtr<GridImp> grid, SPtr<GridImp> fineGrid, LbmOrGks lbmOrGks) -{ - //copyAndFreeFieldFromGPU(grid->getField()); - //copyAndFreeFieldFromGPU(fineGrid->getField()); - //copyAndFreeMatrixIndicesFromGPU(grid, grid->size); - //copyAndFreeMatrixIndicesFromGPU(fineGrid, fineGrid->getSize()); - - //grid->gridInterface = new GridInterface(); - //const uint sizeCF = fineGrid->nx * fineGrid->ny + fineGrid->ny * fineGrid->nz + fineGrid->nx * fineGrid->nz; - //grid->gridInterface->cf.coarse = new uint[sizeCF]; - //grid->gridInterface->cf.fine = new uint[sizeCF]; - //grid->gridInterface->fc.coarse = new uint[sizeCF]; - //grid->gridInterface->fc.fine = new uint[sizeCF]; - - ////for (uint index = 0; index < grid->getSize(); index++) - //// grid->findGridInterface(index, *fineGrid.get()); - - //uint *cfc; - //uint *cff; - //uint *fcc; - //uint *fcf; - - //CudaSafeCall(cudaMalloc(&cfc, sizeCF * sizeof(uint))); - //CudaSafeCall(cudaMalloc(&cff, sizeCF * sizeof(uint))); - //CudaSafeCall(cudaMalloc(&fcc, sizeCF * sizeof(uint))); - //CudaSafeCall(cudaMalloc(&fcf, sizeCF * sizeof(uint))); - - //CudaSafeCall(cudaMemcpy(cfc, grid->gridInterface->cf.coarse, grid->gridInterface->cf.numberOfEntries * sizeof(uint), cudaMemcpyHostToDevice)); - //CudaSafeCall(cudaMemcpy(cff, grid->gridInterface->cf.fine, grid->gridInterface->cf.numberOfEntries * sizeof(uint), cudaMemcpyHostToDevice)); - //CudaSafeCall(cudaMemcpy(fcc, grid->gridInterface->fc.coarse, grid->gridInterface->fc.numberOfEntries * sizeof(uint), cudaMemcpyHostToDevice)); - //CudaSafeCall(cudaMemcpy(fcf, grid->gridInterface->fc.fine, grid->gridInterface->fc.numberOfEntries * sizeof(uint), cudaMemcpyHostToDevice)); - - //grid->gridInterface->cf.coarse = cfc; - //grid->gridInterface->cf.fine = cff; - //grid->gridInterface->fc.coarse = fcc; - //grid->gridInterface->fc.fine = fcf; - - //GridInterface *gridInterface_d; - //CudaSafeCall(cudaMalloc(&gridInterface_d, sizeof(GridInterface))); - //CudaSafeCall(cudaMemcpy(gridInterface_d, grid->gridInterface, sizeof(GridInterface), cudaMemcpyHostToDevice)); - //grid->gridInterface = gridInterface_d; - //CudaCheckError(); - - - //grid->updateSparseIndices(); - - //allocAndCopyFieldToGPU(grid->getField()); - //allocAndCopyFieldToGPU(fineGrid->getField()); - //allocAndCopyMatrixIndicesToGPU(grid, grid->size); - //allocAndCopyMatrixIndicesToGPU(fineGrid, fineGrid->size); - - //float time = runKernelToFindNeighborsNewIndices(LaunchParameter::make_2D1D_launchParameter(grid->size, 256), *grid.get()); - //float time2 = runKernelToFindGridInterfaceNewIndices(LaunchParameter::make_2D1D_launchParameter(grid->size, 256), *grid.get()); - - //copyAndFreeGridInterfaceFromGPU(grid); - - - ////*logging::out << logging::Logger::INTERMEDIATE << "time find indices: " << time / 1000 << "sec\n"; -} - -//void GridGpuStrategy::deleteSolidNodes(SPtr<GridImp> grid) -//{ -// float time1 = runKernelSetToInvalid(LaunchParameter::make_2D1D_launchParameter(grid->size, 512), *grid.get()); -// -// copyAndFreeFieldFromGPU(grid->getField()); -// copyAndFreeMatrixIndicesFromGPU(grid, grid->size); -// -// grid->updateSparseIndices(); -// -// allocAndCopyFieldToGPU(grid->getField()); -// allocAndCopyMatrixIndicesToGPU(grid, grid->size); -// -// float time2 = runKernelFindIndices(LaunchParameter::make_2D1D_launchParameter(grid->size, 256), *grid.get()); -// *logging::out << logging::Logger::INFO_INTERMEDIATE << "time delete solid nodes: " << (time1 + time2) / 1000 << "sec\n"; -//} - - - -void GridGpuStrategy::freeMemory(SPtr<GridImp> grid) -{ - //delete[] grid->gridInterface->cf.coarse; - //delete[] grid->gridInterface->cf.fine; - - //delete[] grid->gridInterface->fc.coarse; - //delete[] grid->gridInterface->fc.fine; - - //delete grid->gridInterface; - - delete[] grid->neighborIndexX; - delete[] grid->neighborIndexY; - delete[] grid->neighborIndexZ; - delete[] grid->neighborIndexNegative; - delete[] grid->sparseIndices; - - delete[] grid->distribution.f; -} - - - -void GridGpuStrategy::copyDataFromGPU(SPtr<GridImp> grid) -{ - //copyAndFreeFieldFromGPU(grid->getField()); - //copyAndFreeNeighborsToCPU(grid); - //copyAndFreeMatrixIndicesFromGPU(grid, grid->size); - //copyAndFreeDistributiondFromGPU(grid); -} - -void GridGpuStrategy::allocField(SPtr<GridImp> grid) -{ - //int size_in_bytes = grid->size * sizeof(char); - //CudaSafeCall(cudaMalloc(grid->getField().field, size_in_bytes)); -} - - -void GridGpuStrategy::allocateFieldMemory(Field* field) -{ - long size = field->size * sizeof(char) / 1000 / 1000; - *logging::out << logging::Logger::INFO_INTERMEDIATE << "alloc on device for grid field: " << int(size) << " MB\n"; - - char *field_d; - CudaSafeCall(cudaMalloc(&field_d, field->size * sizeof(char))); - field->field = field_d; -} - -void GridGpuStrategy::freeFieldMemory(Field* field) -{ -} - -void GridGpuStrategy::findSparseIndices(SPtr<GridImp> coarseGrid, SPtr<GridImp> fineGrid) -{ -} - -// -//void GridWrapperGPU::markNodesToDeleteOutsideOfGeometry() -//{ -// int numberOfEdgeNodes = grid.ny * grid.nz; -// -// /*---------------------------------------------------------------------------------*/ -// float time = runKernelToMarkNodesToDeleteOutsideOfGeometry(LaunchParameter::make_1D1D_launchParameter(numberOfEdgeNodes, 256), grid); -// /*---------------------------------------------------------------------------------*/ -// -// *logging::out << logging::Logger::INTERMEDIATE << "mark nodes to delete: " << time / 1000 << "sec\n"; -// *logging::out << logging::Logger::INTERMEDIATE << "-------------------------------------------\n"; -//} - -/*#################################################################################*/ -/*--------------------------------private methods----------------------------------*/ -/*---------------------------------------------------------------------------------*/ - -void GridGpuStrategy::allocDistribution(SPtr<GridImp> grid) -{ - CudaSafeCall(cudaMemcpyToSymbol(DIRECTIONS, grid->distribution.dirs, grid->distribution.dir_end * DIMENSION * sizeof(int))); - CudaCheckError(); - - unsigned long long distributionSize = grid->size * (grid->distribution.dir_end + 1); - unsigned long long size_in_bytes = distributionSize * sizeof(real); - real sizeInMB = size_in_bytes / (1024.f*1024.f); - *logging::out << logging::Logger::INFO_INTERMEDIATE << "Allocating " << sizeInMB << " [MB] device memory for distributions.\n\n"; - - CudaSafeCall(cudaMalloc(&grid->distribution.f, size_in_bytes)); - CudaCheckError(); -} - -void GridGpuStrategy::allocNeighborsIndices(SPtr<GridImp> grid) -{ - int size_in_bytes_neighbors = grid->size * sizeof(int); - int *neighborIndexX, *neighborIndexY, *neighborIndexZ, *neighborIndexNegative;; - - CudaSafeCall(cudaMalloc(&neighborIndexX, size_in_bytes_neighbors)); - CudaSafeCall(cudaMalloc(&neighborIndexY, size_in_bytes_neighbors)); - CudaSafeCall(cudaMalloc(&neighborIndexZ, size_in_bytes_neighbors)); - CudaSafeCall(cudaMalloc(&neighborIndexNegative, size_in_bytes_neighbors)); - - grid->neighborIndexX = neighborIndexX; - grid->neighborIndexY = neighborIndexY; - grid->neighborIndexZ = neighborIndexZ; - grid->neighborIndexNegative = neighborIndexNegative; - - CudaCheckError(); -} - -void GridGpuStrategy::allocMatrixIndicesOnGPU(SPtr<GridImp> grid) -{ - int size_in_bytes_nodes_reduced = grid->size * sizeof(int); - int* indices_reduced_d; - CudaSafeCall(cudaMalloc(&indices_reduced_d, size_in_bytes_nodes_reduced)); - grid->sparseIndices = indices_reduced_d; - CudaCheckError(); -} - - -void GridGpuStrategy::allocAndCopyTrianglesToGPU(TriangularMesh &geom) -{ - *logging::out << logging::Logger::INFO_INTERMEDIATE << "start copying triangles ...\n"; - //clock_t begin = clock(); - int size_in_bytes_triangles = sizeof(Triangle)*geom.size; - real sizeInMB = size_in_bytes_triangles / (1024.f*1024.f); - - *logging::out << logging::Logger::INFO_INTERMEDIATE << "Allocating " << sizeInMB << " [MB] device memory for triangles.\n\n"; - - Triangle *triangles_d; - CudaSafeCall(cudaMalloc(&triangles_d, size_in_bytes_triangles)); - CudaSafeCall(cudaMemcpy(triangles_d, geom.triangles, size_in_bytes_triangles, cudaMemcpyHostToDevice)); - geom.triangles = triangles_d; - CudaCheckError(); - //clock_t end = clock(); - //real time = real(end - begin) / CLOCKS_PER_SEC; - //*logging::out << logging::Logger::INFO_INTERMEDIATE << "time copying triangles: " << time << "s\n"; - *logging::out << logging::Logger::INFO_INTERMEDIATE << "...copying triangles finish!\n\n"; -} - -void GridGpuStrategy::freeTrianglesFromGPU(const TriangularMesh &geom) -{ - CudaSafeCall(cudaFree(geom.triangles)); - CudaCheckError(); -} - -void GridGpuStrategy::allocAndCopyMatrixIndicesToGPU(SPtr<GridImp> grid, const uint& size) -{ - int size_in_bytes_nodes_reduced = size * sizeof(int); - int* indices_reduced_d; - CudaSafeCall(cudaMalloc(&indices_reduced_d, size_in_bytes_nodes_reduced)); - CudaSafeCall(cudaMemcpy(indices_reduced_d, grid->sparseIndices, size_in_bytes_nodes_reduced, cudaMemcpyHostToDevice)); - delete[] grid->sparseIndices; - grid->sparseIndices = indices_reduced_d; - CudaCheckError(); -} - -void GridGpuStrategy::allocAndCopyFieldToGPU(Field& field) -{ - int size_in_bytes_grid = field.getSize() * sizeof(char); - char* field_d; - CudaSafeCall(cudaMalloc(&field_d, size_in_bytes_grid)); - CudaSafeCall(cudaMemcpy(field_d, field.field, size_in_bytes_grid, cudaMemcpyHostToDevice)); - delete[] field.field; - field.field = field_d; - CudaCheckError(); -} - -void GridGpuStrategy::copyAndFreeFieldFromGPU(Field& field) -{ - char *field_h = new char[field.size]; - CudaSafeCall(cudaMemcpy(field_h, field.field, field.size * sizeof(char), cudaMemcpyDeviceToHost)); - CudaSafeCall(cudaFree(field.field)); - CudaCheckError(); - field.field = field_h; -} - -void GridGpuStrategy::copyAndFreeDistributiondFromGPU(SPtr<GridImp> grid) -{ - unsigned long long distributionSize = grid->size * (grid->distribution.dir_end + 1); - real *f_host = new real[distributionSize]; - CudaSafeCall(cudaMemcpy(f_host, grid->distribution.f, distributionSize * sizeof(real), cudaMemcpyDeviceToHost)); - CudaSafeCall(cudaFree(grid->distribution.f)); - CudaCheckError(); - grid->distribution.f = f_host; -} - - - -void GridGpuStrategy::copyAndFreeNeighborsToCPU(SPtr<GridImp> grid) -{ - int size_in_bytes_neighbors = grid->size * sizeof(int); - int *neighborIndexX_h, *neighborIndexY_h, *neighborIndexZ_h, *neighborIndexNegative_h; - neighborIndexX_h = new int[grid->size]; - neighborIndexY_h = new int[grid->size]; - neighborIndexZ_h = new int[grid->size]; - neighborIndexNegative_h = new int[grid->size]; - - CudaSafeCall(cudaMemcpy(neighborIndexX_h, grid->neighborIndexX, size_in_bytes_neighbors, cudaMemcpyDeviceToHost)); - CudaSafeCall(cudaMemcpy(neighborIndexY_h, grid->neighborIndexY, size_in_bytes_neighbors, cudaMemcpyDeviceToHost)); - CudaSafeCall(cudaMemcpy(neighborIndexZ_h, grid->neighborIndexZ, size_in_bytes_neighbors, cudaMemcpyDeviceToHost)); - CudaSafeCall(cudaMemcpy(neighborIndexNegative_h, grid->neighborIndexNegative, size_in_bytes_neighbors, cudaMemcpyDeviceToHost)); - - CudaSafeCall(cudaFree(grid->neighborIndexX)); - CudaSafeCall(cudaFree(grid->neighborIndexY)); - CudaSafeCall(cudaFree(grid->neighborIndexZ)); - CudaSafeCall(cudaFree(grid->neighborIndexNegative)); - - grid->neighborIndexX = neighborIndexX_h; - grid->neighborIndexY = neighborIndexY_h; - grid->neighborIndexZ = neighborIndexZ_h; - grid->neighborIndexNegative = neighborIndexNegative_h; - CudaCheckError(); -} - -void GridGpuStrategy::copyAndFreeMatrixIndicesFromGPU(SPtr<GridImp> grid, int size) -{ - int size_in_bytes_nodes_reduced = size * sizeof(int); - int *indices_reduced_h = new int[size]; - CudaSafeCall(cudaMemcpy(indices_reduced_h, grid->sparseIndices, size_in_bytes_nodes_reduced, cudaMemcpyDeviceToHost)); - CudaSafeCall(cudaFree(grid->sparseIndices)); - grid->sparseIndices = indices_reduced_h; - CudaCheckError(); -} - - -void GridGpuStrategy::copyAndFreeGridInterfaceFromGPU(SPtr<GridImp> grid) -{ - GridInterface *gridInterface = new GridInterface(); - CudaSafeCall(cudaMemcpy(gridInterface, grid->gridInterface, sizeof(GridInterface), cudaMemcpyDeviceToHost)); - - uint *cfc = new uint[gridInterface->cf.numberOfEntries]; - uint *cff = new uint[gridInterface->cf.numberOfEntries]; - uint *fcc = new uint[gridInterface->fc.numberOfEntries]; - uint *fcf = new uint[gridInterface->fc.numberOfEntries]; - - - CudaSafeCall(cudaMemcpy(cfc, gridInterface->cf.coarse, gridInterface->cf.numberOfEntries * sizeof(uint), cudaMemcpyDeviceToHost)); - CudaSafeCall(cudaMemcpy(cff, gridInterface->cf.fine, gridInterface->cf.numberOfEntries * sizeof(uint), cudaMemcpyDeviceToHost)); - CudaSafeCall(cudaMemcpy(fcc, gridInterface->fc.coarse, gridInterface->fc.numberOfEntries * sizeof(uint), cudaMemcpyDeviceToHost)); - CudaSafeCall(cudaMemcpy(fcf, gridInterface->fc.fine, gridInterface->fc.numberOfEntries * sizeof(uint), cudaMemcpyDeviceToHost)); - CudaSafeCall(cudaFree(gridInterface->cf.coarse)); - CudaSafeCall(cudaFree(gridInterface->cf.fine)); - CudaSafeCall(cudaFree(gridInterface->fc.coarse)); - CudaSafeCall(cudaFree(gridInterface->fc.fine)); - CudaSafeCall(cudaFree(grid->gridInterface)); - - grid->gridInterface = gridInterface; - grid->gridInterface->cf.coarse = cfc; - grid->gridInterface->cf.fine = cff; - grid->gridInterface->fc.coarse = fcc; - grid->gridInterface->fc.fine = fcf; - CudaCheckError(); -} diff --git a/src/gpu/GridGenerator/grid/GridStrategy/GridGpuStrategy/GridGpuStrategy.h b/src/gpu/GridGenerator/grid/GridStrategy/GridGpuStrategy/GridGpuStrategy.h deleted file mode 100644 index fb886824ad35e6657f49c23a3fc25e19aabf0783..0000000000000000000000000000000000000000 --- a/src/gpu/GridGenerator/grid/GridStrategy/GridGpuStrategy/GridGpuStrategy.h +++ /dev/null @@ -1,76 +0,0 @@ -#ifndef GRID_GPU_STRATEGY_H -#define GRID_GPU_STRATEGY_H - -#include "global.h" - -#include "grid/GridStrategy/GridStrategy.h" - -class BoundingBox; -class TriangularMesh; - -class GRIDGENERATOR_EXPORT GridGpuStrategy : public GridStrategy -{ -public: - virtual ~GridGpuStrategy() {}; - - void allocateGridMemory(SPtr<GridImp> grid) override; - - void allocateQs(SPtr<GridImp> grid) override; - - void initalNodesToOutOfGrid(SPtr<GridImp> grid) override; - void fixOddCells(SPtr<GridImp> grid) override; - void findInnerNodes(SPtr<GridImp> grid) override; - void addOverlap(SPtr<GridImp> grid) override; - void fixRefinementIntoWall(SPtr<GridImp> grid) override; - void findStopperNodes(SPtr<GridImp> grid) override; - void findBoundarySolidNodes(SPtr<GridImp> grid) override; - void findEndOfGridStopperNodes(SPtr<GridImp> grid) override; - void findSolidStopperNodes(SPtr<GridImp> grid) override; - - void mesh(SPtr<GridImp> grid, TriangularMesh &geom) override; - - uint closeNeedleCells(SPtr<GridImp> grid) override; - uint closeNeedleCellsThinWall(SPtr<GridImp> grid) override; - - void findQs(SPtr<GridImp> grid, TriangularMesh &geom) override; - - - void findGridInterface(SPtr<GridImp> grid, SPtr<GridImp> fineGrid, LbmOrGks lbmOrGks) override; - - void freeMemory(SPtr<GridImp> grid) override; - - - - void copyAndFreeGridInterfaceFromGPU(SPtr<GridImp> grid); - virtual void copyDataFromGPU(SPtr<GridImp> grid); - - //void markNodesToDeleteOutsideOfGeometry(); - -private: - void allocField(SPtr<GridImp> grid); - void allocDistribution(SPtr<GridImp> grid); - void allocNeighborsIndices(SPtr<GridImp> grid); - void allocMatrixIndicesOnGPU(SPtr<GridImp> grid); - - void allocAndCopyTrianglesToGPU(TriangularMesh &geom); - void freeTrianglesFromGPU(const TriangularMesh &geom); - - - void allocAndCopyMatrixIndicesToGPU(SPtr<GridImp> grid, const uint& size); - - void allocAndCopyFieldToGPU(Field& field); - void copyAndFreeFieldFromGPU(Field& field); - - void copyAndFreeDistributiondFromGPU(SPtr<GridImp> grid); - - void copyAndFreeNeighborsToCPU(SPtr<GridImp> grid); - void copyAndFreeMatrixIndicesFromGPU(SPtr<GridImp> grid, int size); - -public: - void allocateFieldMemory(Field* field) override; - void freeFieldMemory(Field* field) override; - void findSparseIndices(SPtr<GridImp> coarseGrid, SPtr<GridImp> fineGrid) override; - -}; - -#endif diff --git a/src/gpu/GridGenerator/grid/GridStrategy/GridStrategy.h b/src/gpu/GridGenerator/grid/GridStrategy/GridStrategy.h deleted file mode 100644 index 4bf735f90dab005241160266836b910e1c113cea..0000000000000000000000000000000000000000 --- a/src/gpu/GridGenerator/grid/GridStrategy/GridStrategy.h +++ /dev/null @@ -1,53 +0,0 @@ -#ifndef GRID_STRATEGY_H -#define GRID_STRATEGY_H - -#include "Core/LbmOrGks.h" - -#include "global.h" - -#include "grid/Field.h" - -struct Vertex; -class TriangularMesh; -class GridImp; - -class GRIDGENERATOR_EXPORT GridStrategy -{ -public: - virtual ~GridStrategy() {} - - virtual void allocateFieldMemory(Field* field) = 0; - virtual void freeFieldMemory(Field* field) = 0; - - virtual void allocateGridMemory(SPtr<GridImp> grid) = 0; - - virtual void allocateQs(SPtr<GridImp> grid) = 0; - - virtual void initalNodesToOutOfGrid(SPtr<GridImp> grid) = 0; - virtual void fixOddCells(SPtr<GridImp> grid) = 0; - virtual void findInnerNodes(SPtr<GridImp> grid) = 0; - virtual void addOverlap(SPtr<GridImp> grid) = 0; - - virtual void fixRefinementIntoWall(SPtr<GridImp> grid) = 0; - virtual void findStopperNodes(SPtr<GridImp> grid) = 0; - virtual void findBoundarySolidNodes(SPtr<GridImp> grid) = 0; - virtual void findEndOfGridStopperNodes(SPtr<GridImp> grid) = 0; - virtual void findSolidStopperNodes(SPtr<GridImp> grid) = 0; - - virtual void mesh(SPtr<GridImp> grid, TriangularMesh &geom) = 0; - - virtual uint closeNeedleCells(SPtr<GridImp> grid) = 0; - virtual uint closeNeedleCellsThinWall(SPtr<GridImp> grid) = 0; - - virtual void findQs(SPtr<GridImp> grid, TriangularMesh &geom) = 0; - - virtual void findGridInterface(SPtr<GridImp> grid, SPtr<GridImp> fineGrid, LbmOrGks lbmOrGks) = 0; - - virtual void findSparseIndices(SPtr<GridImp> coarseGrid, SPtr<GridImp> fineGrid) = 0; - - - virtual void freeMemory(SPtr<GridImp> grid) = 0; - -}; - -#endif diff --git a/src/gpu/GridGenerator/grid/NodeValues.h b/src/gpu/GridGenerator/grid/NodeValues.h index b5661f081873cbb9e632f76be97ba9bc409071ed..b8312b0673337d11b4bdf0b8052e89d92ce127ef 100644 --- a/src/gpu/GridGenerator/grid/NodeValues.h +++ b/src/gpu/GridGenerator/grid/NodeValues.h @@ -1,3 +1,35 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids 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. +// +// VirtualFluids 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 VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file NodeValues.h +//! \ingroup grid +//! \author Soeren Peters, Stephan Lenz, Martin Schoenherr +//======================================================================================= #ifndef NodeValues_H #define NodeValues_H @@ -14,34 +46,34 @@ static constexpr char FLUID_CFF = 2; static constexpr char FLUID_FCC = 3; static constexpr char FLUID_FCF = 4; -static constexpr char MULTI_GPU_SEND = 10; +static constexpr char MULTI_GPU_SEND = 10; static constexpr char MULTI_GPU_RECIEVE = 11; static constexpr char BC_PRESSURE = 20; static constexpr char BC_VELOCITY = 21; -static constexpr char BC_SOLID = 22; +static constexpr char BC_SOLID = 22; -static constexpr char BC_SLIP = 23; -static constexpr char BC_NOSLIP = 24; +static constexpr char BC_SLIP = 23; +static constexpr char BC_NOSLIP = 24; static constexpr char BC_OUTFLOW = 25; +static constexpr char BC_STRESS = 26; -static constexpr char STOPPER_OUT_OF_GRID = 30; -static constexpr char STOPPER_COARSE_UNDER_FINE = 31; -static constexpr char STOPPER_SOLID = 32; +static constexpr char STOPPER_OUT_OF_GRID = 30; +static constexpr char STOPPER_COARSE_UNDER_FINE = 31; +static constexpr char STOPPER_SOLID = 32; static constexpr char STOPPER_OUT_OF_GRID_BOUNDARY = 33; -static constexpr char INVALID_OUT_OF_GRID = 40; +static constexpr char INVALID_OUT_OF_GRID = 40; static constexpr char INVALID_COARSE_UNDER_FINE = 41; -static constexpr char INVALID_SOLID = 42; +static constexpr char INVALID_SOLID = 42; -//????WTF????? -static constexpr char INSIDE = 50; +static constexpr char INSIDE = 50; static constexpr char NEGATIVE_DIRECTION_BORDER = 51; -static constexpr char Q_DEPRECATED = 52; +static constexpr char Q_DEPRECATED = 52; static constexpr char OVERLAP_TMP = 60; -} -} +} // namespace gpu +} // namespace vf #endif diff --git a/src/gpu/GridGenerator/grid/distributions/D3Q13.h b/src/gpu/GridGenerator/grid/distributions/D3Q13.h deleted file mode 100644 index f314b970c2c6766ce367342ca649629d23131db6..0000000000000000000000000000000000000000 --- a/src/gpu/GridGenerator/grid/distributions/D3Q13.h +++ /dev/null @@ -1,70 +0,0 @@ -#ifndef D3Q13_H -#define D3Q13_H - -#define DIR_13_R 0 -#define DIR_13_NE 1 -#define DIR_13_SW 2 -#define DIR_13_SE 3 -#define DIR_13_NW 4 -#define DIR_13_TE 5 -#define DIR_13_BW 6 -#define DIR_13_BE 7 -#define DIR_13_TW 8 -#define DIR_13_TN 9 -#define DIR_13_BS 10 -#define DIR_13_BN 11 -#define DIR_13_TS 12 - -#define DIR_13_START 0 -#define DIR_13_END 12 - - -#define DIR_13_NE_X 1 -#define DIR_13_NE_Y 1 -#define DIR_13_NE_Z 0 - -#define DIR_13_SW_X -1 -#define DIR_13_SW_Y -1 -#define DIR_13_SW_Z 0 - -#define DIR_13_SE_X 1 -#define DIR_13_SE_Y -1 -#define DIR_13_SE_Z 0 - -#define DIR_13_NW_X -1 -#define DIR_13_NW_Y 1 -#define DIR_13_NW_Z 0 - -#define DIR_13_TE_X 1 -#define DIR_13_TE_Y 0 -#define DIR_13_TE_Z 1 - -#define DIR_13_BW_X -1 -#define DIR_13_BW_Y 0 -#define DIR_13_BW_Z -1 - -#define DIR_13_BE_X 1 -#define DIR_13_BE_Y 0 -#define DIR_13_BE_Z -1 - -#define DIR_13_TW_X -1 -#define DIR_13_TW_Y 0 -#define DIR_13_TW_Z 1 - -#define DIR_13_TN_X 0 -#define DIR_13_TN_Y 1 -#define DIR_13_TN_Z 1 - -#define DIR_13_BS_X 0 -#define DIR_13_BS_Y -1 -#define DIR_13_BS_Z -1 - -#define DIR_13_BN_X 0 -#define DIR_13_BN_Y 1 -#define DIR_13_BN_Z -1 - -#define DIR_13_TS_X 0 -#define DIR_13_TS_Y -1 -#define DIR_13_TS_Z 1 - -#endif diff --git a/src/gpu/GridGenerator/grid/distributions/D3Q19.h b/src/gpu/GridGenerator/grid/distributions/D3Q19.h deleted file mode 100644 index 3f48a3bb11f78d68b53fabcfa8ea8ff475a88f6d..0000000000000000000000000000000000000000 --- a/src/gpu/GridGenerator/grid/distributions/D3Q19.h +++ /dev/null @@ -1,100 +0,0 @@ -#ifndef D3Q19_H_ -#define D3Q19_H_ - -#define DIR_19_E 0 -#define DIR_19_W 1 -#define DIR_19_N 2 -#define DIR_19_S 3 -#define DIR_19_T 4 -#define DIR_19_B 5 -#define DIR_19_NE 6 -#define DIR_19_SW 7 -#define DIR_19_SE 8 -#define DIR_19_NW 9 -#define DIR_19_TE 10 -#define DIR_19_BW 11 -#define DIR_19_BE 12 -#define DIR_19_TW 13 -#define DIR_19_TN 14 -#define DIR_19_BS 15 -#define DIR_19_BN 16 -#define DIR_19_TS 17 -#define DIR_19_ZERO 18 - -#define DIR_19_START 0 -#define DIR_19_END 18 - - -#define DIR_19_E_X 1 -#define DIR_19_E_Y 0 -#define DIR_19_E_Z 0 - -#define DIR_19_W_X -1 -#define DIR_19_W_Y 0 -#define DIR_19_W_Z 0 - -#define DIR_19_N_X 0 -#define DIR_19_N_Y 1 -#define DIR_19_N_Z 0 - -#define DIR_19_S_X 0 -#define DIR_19_S_Y -1 -#define DIR_19_S_Z 0 - -#define DIR_19_T_X 0 -#define DIR_19_T_Y 0 -#define DIR_19_T_Z 1 - -#define DIR_19_B_X 0 -#define DIR_19_B_Y 0 -#define DIR_19_B_Z -1 - -#define DIR_19_NE_X 1 -#define DIR_19_NE_Y 1 -#define DIR_19_NE_Z 0 - -#define DIR_19_SW_X -1 -#define DIR_19_SW_Y -1 -#define DIR_19_SW_Z 0 - -#define DIR_19_SE_X 1 -#define DIR_19_SE_Y -1 -#define DIR_19_SE_Z 0 - -#define DIR_19_NW_X -1 -#define DIR_19_NW_Y 1 -#define DIR_19_NW_Z 0 - -#define DIR_19_TE_X 1 -#define DIR_19_TE_Y 0 -#define DIR_19_TE_Z 1 - -#define DIR_19_BW_X -1 -#define DIR_19_BW_Y 0 -#define DIR_19_BW_Z -1 - -#define DIR_19_BE_X 1 -#define DIR_19_BE_Y 0 -#define DIR_19_BE_Z -1 - -#define DIR_19_TW_X -1 -#define DIR_19_TW_Y 0 -#define DIR_19_TW_Z 1 - -#define DIR_19_TN_X 0 -#define DIR_19_TN_Y 1 -#define DIR_19_TN_Z 1 - -#define DIR_19_BS_X 0 -#define DIR_19_BS_Y -1 -#define DIR_19_BS_Z -1 - -#define DIR_19_BN_X 0 -#define DIR_19_BN_Y 1 -#define DIR_19_BN_Z -1 - -#define DIR_19_TS_X 0 -#define DIR_19_TS_Y -1 -#define DIR_19_TS_Z 1 - -#endif diff --git a/src/gpu/GridGenerator/grid/distributions/D3Q27.h b/src/gpu/GridGenerator/grid/distributions/D3Q27.h index b849b9e37f518e87a6d7249de476827cd83d7ae2..680fa88305b793934747d09113f284bfe96b4988 100644 --- a/src/gpu/GridGenerator/grid/distributions/D3Q27.h +++ b/src/gpu/GridGenerator/grid/distributions/D3Q27.h @@ -1,3 +1,35 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids 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. +// +// VirtualFluids 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 VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file D3Q27.h +//! \ingroup grid +//! \author Soeren Peters, Stephan Lenz +//======================================================================================= #ifndef D3Q27_H_ #define D3Q27_H_ diff --git a/src/gpu/GridGenerator/grid/distributions/D3Q7.h b/src/gpu/GridGenerator/grid/distributions/D3Q7.h index 6654cc1475d87875407d107ec9e300744831a7b9..f43aeb01c5ebf85f4b2f97e90f61585d4dd6da88 100644 --- a/src/gpu/GridGenerator/grid/distributions/D3Q7.h +++ b/src/gpu/GridGenerator/grid/distributions/D3Q7.h @@ -1,3 +1,35 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids 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. +// +// VirtualFluids 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 VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file D3Q7.h +//! \ingroup grid +//! \author Soeren Peters, Stephan Lenz +//======================================================================================= #ifndef D3Q7_H #define D3Q7_H diff --git a/src/gpu/GridGenerator/grid/distributions/Distribution.cpp b/src/gpu/GridGenerator/grid/distributions/Distribution.cpp index f23c545cd6cb88892724fec5afb29d2f454e96a2..b0200812631aeff1947a56f78cae4232bd4d3ee7 100644 --- a/src/gpu/GridGenerator/grid/distributions/Distribution.cpp +++ b/src/gpu/GridGenerator/grid/distributions/Distribution.cpp @@ -1,197 +1,43 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids 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. +// +// VirtualFluids 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 VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file Distribution.cpp +//! \ingroup grid +//! \author Soeren Peters, Stephan Lenz +//======================================================================================= #include "Distribution.h" #include <stdio.h> - -#include "grid/distributions/D3Q7.h" -#include "grid/distributions/D3Q13.h" -#include "grid/distributions/D3Q19.h" + #include "grid/distributions/D3Q27.h" #include "grid/Grid.h" -Distribution DistributionHelper::getDistribution7() -{ - Distribution d7; - d7.name = "D3Q7"; - d7.dir_start = DIR_7_START; - d7.dir_end = DIR_7_END; - - d7.dirs = new int[DIR_7_END * DIMENSION]; - - int dir_num = 0; - d7.dirs[dir_num++] = DIR_7_E_X; - d7.dirs[dir_num++] = DIR_7_E_Y; - d7.dirs[dir_num++] = DIR_7_E_Z; - - d7.dirs[dir_num++] = DIR_7_W_X; - d7.dirs[dir_num++] = DIR_7_W_Y; - d7.dirs[dir_num++] = DIR_7_W_Z; - - d7.dirs[dir_num++] = DIR_7_N_X; - d7.dirs[dir_num++] = DIR_7_N_Y; - d7.dirs[dir_num++] = DIR_7_N_Z; - - d7.dirs[dir_num++] = DIR_7_S_X; - d7.dirs[dir_num++] = DIR_7_S_Y; - d7.dirs[dir_num++] = DIR_7_S_Z; - - d7.dirs[dir_num++] = DIR_7_T_X; - d7.dirs[dir_num++] = DIR_7_T_Y; - d7.dirs[dir_num++] = DIR_7_T_Z; - - d7.dirs[dir_num++] = DIR_7_B_X; - d7.dirs[dir_num++] = DIR_7_B_Y; - d7.dirs[dir_num++] = DIR_7_B_Z; - - return d7; -} - -Distribution DistributionHelper::getDistribution13() -{ - Distribution d13; - d13.name = "D3Q13"; - d13.dir_start = DIR_13_START; - d13.dir_end = DIR_13_END; - - d13.dirs = new int[DIR_13_END * DIMENSION]; - - int dir_num = 0; - d13.dirs[dir_num++] = DIR_13_NE_X; - d13.dirs[dir_num++] = DIR_13_NE_Y; - d13.dirs[dir_num++] = DIR_13_NE_Z; - - d13.dirs[dir_num++] = DIR_13_SW_X; - d13.dirs[dir_num++] = DIR_13_SW_Y; - d13.dirs[dir_num++] = DIR_13_SW_Z; - - d13.dirs[dir_num++] = DIR_13_SE_X; - d13.dirs[dir_num++] = DIR_13_SE_Y; - d13.dirs[dir_num++] = DIR_13_SE_Z; - - d13.dirs[dir_num++] = DIR_13_NW_X; - d13.dirs[dir_num++] = DIR_13_NW_Y; - d13.dirs[dir_num++] = DIR_13_NW_Z; - - d13.dirs[dir_num++] = DIR_13_TE_X; - d13.dirs[dir_num++] = DIR_13_TE_Y; - d13.dirs[dir_num++] = DIR_13_TE_Z; - - d13.dirs[dir_num++] = DIR_13_BW_X; - d13.dirs[dir_num++] = DIR_13_BW_Y; - d13.dirs[dir_num++] = DIR_13_BW_Z; - - d13.dirs[dir_num++] = DIR_13_BE_X; - d13.dirs[dir_num++] = DIR_13_BE_Y; - d13.dirs[dir_num++] = DIR_13_BE_Z; - - d13.dirs[dir_num++] = DIR_13_TW_X; - d13.dirs[dir_num++] = DIR_13_TW_Y; - d13.dirs[dir_num++] = DIR_13_TW_Z; - - d13.dirs[dir_num++] = DIR_13_TN_X; - d13.dirs[dir_num++] = DIR_13_TN_Y; - d13.dirs[dir_num++] = DIR_13_TN_Z; - - d13.dirs[dir_num++] = DIR_13_BS_X; - d13.dirs[dir_num++] = DIR_13_BS_Y; - d13.dirs[dir_num++] = DIR_13_BS_Z; - - d13.dirs[dir_num++] = DIR_13_BN_X; - d13.dirs[dir_num++] = DIR_13_BN_Y; - d13.dirs[dir_num++] = DIR_13_BN_Z; - - d13.dirs[dir_num++] = DIR_13_TS_X; - d13.dirs[dir_num++] = DIR_13_TS_Y; - d13.dirs[dir_num++] = DIR_13_TS_Z; - - return d13; -} - -Distribution DistributionHelper::getDistribution19() -{ - Distribution d19; - d19.name = "D3Q19"; - d19.dir_start = DIR_19_START; - d19.dir_end = DIR_19_END; - - d19.dirs = new int[DIR_19_END * DIMENSION]; - - int dir_num = 0; - d19.dirs[dir_num++] = DIR_19_E_X; - d19.dirs[dir_num++] = DIR_19_E_Y; - d19.dirs[dir_num++] = DIR_19_E_Z; - - d19.dirs[dir_num++] = DIR_19_W_X; - d19.dirs[dir_num++] = DIR_19_W_Y; - d19.dirs[dir_num++] = DIR_19_W_Z; - - d19.dirs[dir_num++] = DIR_19_N_X; - d19.dirs[dir_num++] = DIR_19_N_Y; - d19.dirs[dir_num++] = DIR_19_N_Z; - - d19.dirs[dir_num++] = DIR_19_S_X; - d19.dirs[dir_num++] = DIR_19_S_Y; - d19.dirs[dir_num++] = DIR_19_S_Z; - - d19.dirs[dir_num++] = DIR_19_T_X; - d19.dirs[dir_num++] = DIR_19_T_Y; - d19.dirs[dir_num++] = DIR_19_T_Z; - - d19.dirs[dir_num++] = DIR_19_B_X; - d19.dirs[dir_num++] = DIR_19_B_Y; - d19.dirs[dir_num++] = DIR_19_B_Z; - - d19.dirs[dir_num++] = DIR_19_NE_X; - d19.dirs[dir_num++] = DIR_19_NE_Y; - d19.dirs[dir_num++] = DIR_19_NE_Z; - - d19.dirs[dir_num++] = DIR_19_SW_X; - d19.dirs[dir_num++] = DIR_19_SW_Y; - d19.dirs[dir_num++] = DIR_19_SW_Z; - - d19.dirs[dir_num++] = DIR_19_SE_X; - d19.dirs[dir_num++] = DIR_19_SE_Y; - d19.dirs[dir_num++] = DIR_19_SE_Z; - - d19.dirs[dir_num++] = DIR_19_NW_X; - d19.dirs[dir_num++] = DIR_19_NW_Y; - d19.dirs[dir_num++] = DIR_19_NW_Z; - - d19.dirs[dir_num++] = DIR_19_TE_X; - d19.dirs[dir_num++] = DIR_19_TE_Y; - d19.dirs[dir_num++] = DIR_19_TE_Z; - - d19.dirs[dir_num++] = DIR_19_BW_X; - d19.dirs[dir_num++] = DIR_19_BW_Y; - d19.dirs[dir_num++] = DIR_19_BW_Z; - - d19.dirs[dir_num++] = DIR_19_BE_X; - d19.dirs[dir_num++] = DIR_19_BE_Y; - d19.dirs[dir_num++] = DIR_19_BE_Z; - - d19.dirs[dir_num++] = DIR_19_TW_X; - d19.dirs[dir_num++] = DIR_19_TW_Y; - d19.dirs[dir_num++] = DIR_19_TW_Z; - - d19.dirs[dir_num++] = DIR_19_TN_X; - d19.dirs[dir_num++] = DIR_19_TN_Y; - d19.dirs[dir_num++] = DIR_19_TN_Z; - - d19.dirs[dir_num++] = DIR_19_BS_X; - d19.dirs[dir_num++] = DIR_19_BS_Y; - d19.dirs[dir_num++] = DIR_19_BS_Z; - - d19.dirs[dir_num++] = DIR_19_BN_X; - d19.dirs[dir_num++] = DIR_19_BN_Y; - d19.dirs[dir_num++] = DIR_19_BN_Z; - - d19.dirs[dir_num++] = DIR_19_TS_X; - d19.dirs[dir_num++] = DIR_19_TS_Y; - d19.dirs[dir_num++] = DIR_19_TS_Z; - - return d19; -} - Distribution DistributionHelper::getDistribution27() { Distribution d27; @@ -357,12 +203,6 @@ Distribution DistributionHelper::getDistribution27() Distribution DistributionHelper::getDistribution(std::string name) { - if (name == "D3Q7") - return getDistribution7(); - if (name == "D3Q13") - return getDistribution13(); - if (name == "D3Q19") - return getDistribution19(); if (name == "D3Q27") return getDistribution27(); diff --git a/src/gpu/GridGenerator/grid/distributions/Distribution.h b/src/gpu/GridGenerator/grid/distributions/Distribution.h index 04b7093aadd16cc755358d123a415fd5bb032703..7982abc235b020003526b10c885f4936bf661936 100644 --- a/src/gpu/GridGenerator/grid/distributions/Distribution.h +++ b/src/gpu/GridGenerator/grid/distributions/Distribution.h @@ -1,3 +1,35 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids 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. +// +// VirtualFluids 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 VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file Distribution.h +//! \ingroup grid +//! \author Soeren Peters, Stephan Lenz +//======================================================================================= #ifndef Distribution_H #define Distribution_H @@ -11,21 +43,21 @@ struct Direction { - HOSTDEVICE Direction() + Direction() { dir[0] = 0; dir[1] = 0; dir[2] = 0; } - HOSTDEVICE Direction(int dx, int dy, int dz) + Direction(int dx, int dy, int dz) { dir[0] = dx; dir[1] = dy; dir[2] = dz; } - HOSTDEVICE int operator[](uint dir) const + int operator[](uint dir) const { if (dir < 3) return this->dir[dir]; @@ -52,10 +84,10 @@ struct Distribution fSize = size * (dir_end + 1); } - HOSTDEVICE iterator begin() { return &directions[0]; } - HOSTDEVICE const_iterator begin() const { return &directions[0]; } - HOSTDEVICE iterator end() { return &directions[dir_end + 1]; } - HOSTDEVICE const_iterator end() const { return &directions[dir_end + 1]; } + iterator begin() { return &directions[0]; } + const_iterator begin() const { return &directions[0]; } + iterator end() { return &directions[dir_end + 1]; } + const_iterator end() const { return &directions[dir_end + 1]; } }; class Grid; @@ -63,9 +95,6 @@ class Grid; class GRIDGENERATOR_EXPORT DistributionHelper { public: - static Distribution getDistribution7(); - static Distribution getDistribution13(); - static Distribution getDistribution19(); static Distribution getDistribution27(); static Distribution getDistribution(std::string name); diff --git a/src/gpu/GridGenerator/grid/kernel/runGridKernelGPU.cu b/src/gpu/GridGenerator/grid/kernel/runGridKernelGPU.cu deleted file mode 100644 index ff137357b5bd7904253db372b37ca5d9e47bd102..0000000000000000000000000000000000000000 --- a/src/gpu/GridGenerator/grid/kernel/runGridKernelGPU.cu +++ /dev/null @@ -1,215 +0,0 @@ -#include "runGridKernelGPU.cuh" - -#include "utilities/cuda/cudaDefines.h" -#include "utilities/cuda/cudaKernelCall.h" -#include "utilities/cuda/LaunchParameter.cuh" -#include "grid/GridImp.h" -#include "geometries/TriangularMesh/TriangularMesh.h" - -GLOBAL void initalField(GridImp grid); -GLOBAL void runMeshing(GridImp grid, const TriangularMesh geom); - -GLOBAL void findGridInterface(GridImp grid, GridImp finerGrid); -GLOBAL void runKernelTomarkNodesToDeleteOutsideOfGeometry(GridImp grid); -GLOBAL void markNodesToDeleteOutsideOfGeometry(GridImp grid); -GLOBAL void findNeighborIndicesKernel(GridImp grid); -GLOBAL void setOverlapNodesToInvalid(GridImp grid, GridImp finderGrid); - -////////////////////////////////////////////////////////////////////////// - -float runKernelInitalUniformGrid3d(const LaunchParameter& para, GridImp &grid) -{ - return runKernel(initalField, para, grid); -} - -GLOBAL void initalField(GridImp grid) -{ - //TODO: outcomment because of nvlink warning caused by the new allocation in Cell(). - //uint index = LaunchParameter::getGlobalIdx_2D_1D(); - //if (index < grid.getSize()) - // grid.findInnerNode(index); -} - -////////////////////////////////////////////////////////////////////////// - -float runKernelToMesh(const LaunchParameter& para, GridImp &grid, const TriangularMesh &geom) -{ - return runKernel(runMeshing, para, grid, geom); -} - -GLOBAL void runMeshing(GridImp grid, const TriangularMesh geom) -{ - // TODO: outcomment because of nvlink warning caused by the new allocation in Cell(). - //unsigned int i = LaunchParameter::getGlobalIdx_1D_1D(); - //if (i < geom.size) - // grid.mesh(geom.triangles[i]); -} - -////////////////////////////////////////////////////////////////////////// - -float runKernelToMarkNodesToDeleteOutsideOfGeometry(const LaunchParameter& para, GridImp &grid) -{ - return runKernel(markNodesToDeleteOutsideOfGeometry, para, grid); -} - -GLOBAL void markNodesToDeleteOutsideOfGeometry(GridImp grid) -{ - //int numberOfEdgeNodes = grid.ny * grid.nz; - //unsigned int i = LaunchParameter::getGlobalIdx_1D_1D(); - - //if (i < numberOfEdgeNodes) - //{ - // int x = 0; - // int y = i % grid.ny; - // int z = i / grid.ny; - - // grid.setFieldEntryToSolid(grid.transCoordToIndex(x, y, z)); - - // while (grid.isFluid(i) && x < grid.nx - 1) - // { - // x += 1; - // grid.setFieldEntryToSolid(grid.transCoordToIndex(x, y, z)); - // } - //} - -} - - -////////////////////////////////////////////////////////////////////////// - -float runKernelSetOverlapNodesToInvalid(const LaunchParameter& para, GridImp &grid, GridImp &finerGrid) -{ - return runKernel(setOverlapNodesToInvalid, para, grid, finerGrid); -} - -GLOBAL void setOverlapNodesToInvalid(GridImp grid, GridImp finerGrid) -{ - // not up to date - //const uint index = LaunchParameter::getGlobalIdx_2D_1D(); - //if (index < grid.getSize()) - //grid.findGridInterfaceCF(index, finerGrid); -} - - - -/*#################################################################################*/ -/*---------------------------------find invalid nodes------------------------------*/ -/*---------------------------------------------------------------------------------*/ -GLOBAL void setInvalidNodes(GridImp grid, bool *foundInvalidNode); -/*---------------------------------------------------------------------------------*/ - -float runKernelSetToInvalid(const LaunchParameter& para, GridImp &grid) -{ - bool* foundInvalidNode_d; - bool* foundInvalidNode_h = new bool(); - *foundInvalidNode_h = true; - CudaSafeCall( cudaMalloc(&foundInvalidNode_d, sizeof(bool))); - CudaCheckError(); - cudaEvent_t start, stop; - cudaEventCreate(&start); - cudaEventCreate(&stop); - cudaEventRecord(start, 0); - - while (*foundInvalidNode_h) - { - *foundInvalidNode_h = false; - CudaSafeCall(cudaMemcpy(foundInvalidNode_d, foundInvalidNode_h, sizeof(bool), cudaMemcpyHostToDevice)); - setInvalidNodes << <para.blocks, para.threads >> >(grid, foundInvalidNode_d); - cudaDeviceSynchronize(); - CudaCheckError(); - - CudaSafeCall(cudaMemcpy(foundInvalidNode_h, foundInvalidNode_d, sizeof(bool), cudaMemcpyDeviceToHost)); - } - - cudaDeviceSynchronize(); - cudaEventRecord(stop, 0); - cudaEventSynchronize(stop); - float elapsedTime; - cudaEventElapsedTime(&elapsedTime, start, stop); - - cudaEventDestroy(start); - cudaEventDestroy(stop); - - CudaCheckError(); - cudaFree(foundInvalidNode_d); - delete foundInvalidNode_h; - - return elapsedTime; -} - - -GLOBAL void setInvalidNodes(GridImp grid, bool *foundInvalidNode) -{ - uint index = LaunchParameter::getGlobalIdx_2D_1D(); - //if (index < grid.getSize()) - //grid.setInsideNode(index, *foundInvalidNode); -} - - -/*#################################################################################*/ - -float runKernelFindIndices(const LaunchParameter& para, GridImp &grid) -{ - return runKernel(findNeighborIndicesKernel, para, grid); -} - -GLOBAL void findNeighborIndicesKernel(GridImp grid) -{ - uint index = LaunchParameter::getGlobalIdx_2D_1D(); - if (index < grid.getSize()) - grid.setNeighborIndices(index); -} - - -/*#################################################################################*/ - -float runKernelToFindGridInterface(const LaunchParameter& para, GridImp &grid, GridImp &finerGrid) -{ - return runKernel(findGridInterface, para, grid, finerGrid); -} - -GLOBAL void findGridInterface(GridImp grid, GridImp finerGrid) -{ - // not up to date - //uint index = LaunchParameter::getGlobalIdx_2D_1D(); - //if (index < grid.getSize()) - // grid.findGridInterfaceCF(index, finerGrid); -} -/*#################################################################################*/ - -GLOBAL void findNeighborsNewIndices(GridImp grid); -float runKernelToFindNeighborsNewIndices(const LaunchParameter& para, GridImp &grid) -{ - return runKernel(findNeighborsNewIndices, para, grid); -} - -GLOBAL void findNeighborsNewIndices(GridImp grid) -{ - unsigned int index = LaunchParameter::getGlobalIdx_2D_1D(); - if (index < grid.getSize()) - grid.setNeighborIndices(index); -} -/*#################################################################################*/ - -GLOBAL void findGridInterfaceNewIndicesFC(GridImp grid); -GLOBAL void findGridInterfaceNewIndicesCF(GridImp grid); -float runKernelToFindGridInterfaceNewIndices(const LaunchParameter& para, GridImp &grid) -{ - runKernel(findGridInterfaceNewIndicesCF, para, grid); - return runKernel(findGridInterfaceNewIndicesFC, para, grid); -} - - -GLOBAL void findGridInterfaceNewIndicesCF(GridImp grid) -{ - unsigned int index = LaunchParameter::getGlobalIdx_2D_1D(); - //if (index < grid.getNumberOfNodesCF()) - //grid.findForGridInterfaceSparseIndexCF(index); -} - -GLOBAL void findGridInterfaceNewIndicesFC(GridImp grid) -{ - unsigned int index = LaunchParameter::getGlobalIdx_2D_1D(); - //if (index < grid.getNumberOfNodesFC()) - // grid.findForGridInterfaceSparseIndexFCcoarse(index); -} diff --git a/src/gpu/GridGenerator/grid/kernel/runGridKernelGPU.cuh b/src/gpu/GridGenerator/grid/kernel/runGridKernelGPU.cuh deleted file mode 100644 index e63e4288182ce91e2b8c2fbbb26bb84bf8fb77a5..0000000000000000000000000000000000000000 --- a/src/gpu/GridGenerator/grid/kernel/runGridKernelGPU.cuh +++ /dev/null @@ -1,23 +0,0 @@ -#ifndef runGridKernelGPU_H -#define runGridKernelGPU_H - - -class Grid; -class GridImp; -class TriangularMesh; -class LaunchParameter; - -float runKernelInitalUniformGrid3d(const LaunchParameter& para, GridImp &grid); -float runKernelToMesh(const LaunchParameter& para, GridImp &grid, const TriangularMesh &geom); -float runKernelToMarkNodesToDeleteOutsideOfGeometry(const LaunchParameter& para, GridImp &grid); - -float runKernelToFindGridInterface(const LaunchParameter& para, GridImp &grid, GridImp &finerGrid); -float runKernelToFindNeighborsNewIndices(const LaunchParameter& para, GridImp &grid); -float runKernelToFindGridInterfaceNewIndices(const LaunchParameter& para, GridImp &grid); - - -float runKernelSetOverlapNodesToInvalid(const LaunchParameter& para, GridImp &grid, GridImp &finerGrid); -float runKernelSetToInvalid(const LaunchParameter& para, GridImp &grid); -float runKernelFindIndices(const LaunchParameter& para, GridImp &grid); - -#endif diff --git a/src/gpu/GridGenerator/grid/partition/Partition.cpp b/src/gpu/GridGenerator/grid/partition/Partition.cpp deleted file mode 100644 index 970599105e9363f37f930480f1874827672c86d2..0000000000000000000000000000000000000000 --- a/src/gpu/GridGenerator/grid/partition/Partition.cpp +++ /dev/null @@ -1,653 +0,0 @@ -//#include "Partition.h" -// -//#include "metis.h" -//#include <stdio.h> -//#include <iostream> -// -//#include <global.h> -//#include <GridGenerator/grid/Grid.h> -//#include <GridGenerator/geometries/Triangle/Triangle.h> -//#include <GridGenerator/geometries/Vertex/Vertex.h> -//#include <GridGenerator/geometries/BoundingBox/BoundingBox.h> -//#include <GridGenerator/io/GridVTKWriter/GridVTKWriter.h> -//#include <GridGenerator/io/VTKWriterWrapper/UnstructuredGridWrapper.h> -//#include <GridGenerator/utilities/Transformator/TransformatorImp.h> -// -//#include <utilities/logger/Logger.h> -// -//int Partition::calcEdgesFromGraph(SPtr<Grid> grid) -//{ -// int insideNeighbors = 6; -// int cornerNeighbors = 3; -// int outsideEdgesNeighbors = 4; -// int ousiteAreaNeighbors = 5; -// -// int corner = 8; -// int outsiteEdges = grid->getNumberOfNodesX() * 4 + grid->getNumberOfNodesY() * 4 + grid->getNumberOfNodesZ() * 4 - 24; -// int outsideArea = 2 * grid->getNumberOfNodesX()*grid->getNumberOfNodesY() + 2 * grid->getNumberOfNodesX()*grid->getNumberOfNodesZ() + 2 * grid->getNumberOfNodesY()*grid->getNumberOfNodesZ() - 8 * grid->getNumberOfNodesX() - 8 * grid->getNumberOfNodesY() - 8 * grid->getNumberOfNodesZ() + 24; -// int inside = grid->getSize() - corner - outsiteEdges - outsideArea; -// return inside * insideNeighbors + outsideArea * ousiteAreaNeighbors + outsiteEdges * outsideEdgesNeighbors + corner * cornerNeighbors; -//} -// -//void Partition::partitionGridMesh(SPtr<Grid> grid) -//{ -// printf("MESH\n"); -// -// idx_t nelements = (grid->getNumberOfNodesX() - 1) * (grid->getNumberOfNodesY() - 1) * (grid->getNumberOfNodesZ() - 1); -// idx_t nNodes = nelements * 8; -// idx_t nWeightsMesh = 1; -// idx_t nPartsMesh = 2; -// -// idx_t *partMeshNodes = new idx_t[nNodes]; -// idx_t *partMeshElements = new idx_t[nelements]; -// idx_t objval; -// -// // Indexes of starting points in adjacent array -// idx_t *eptr = new idx_t[nelements + 1]; -// -// for (int i = 0; i < nelements + 1; i++) { -// eptr[i] = i * 8; -// } -// -// // Adjacent vertices in consecutive index order -// idx_t *eind = new idx_t[nNodes]; -// -// real x, y, z, newX, newY, newZ; -// int nIndex; -// int numberNode = 0; -// for (unsigned int index = 0; index < grid->getSize(); index++) { -// grid->transIndexToCoords(index, x, y, z); -// -// newX = x + 1; -// newY = y + 1; -// newZ = z + 1; -// if (newX >= grid->getNumberOfNodesX() || newY >= grid->getNumberOfNodesY() || newZ >= grid->getNumberOfNodesZ()) -// continue; -// -// // self -// eind[numberNode] = index; -// numberNode++; -// -// //+x -// nIndex = grid->transCoordToIndex(newX, y, z); -// eind[numberNode] = nIndex; -// numberNode++; -// -// //x//+y -// nIndex = grid->transCoordToIndex(newX, newY, z); -// eind[numberNode] = nIndex; -// numberNode++; -// -// //+y -// nIndex = grid->transCoordToIndex(x, newY, z); -// eind[numberNode] = nIndex; -// numberNode++; -// -// //+z -// nIndex = grid->transCoordToIndex(x, y, newZ); -// eind[numberNode] = nIndex; -// numberNode++; -// -// //+z//+x -// nIndex = grid->transCoordToIndex(newX, y, newZ); -// eind[numberNode] = nIndex; -// numberNode++; -// -// //+z//+x//+y -// nIndex = grid->transCoordToIndex(newX, newY, newZ); -// eind[numberNode] = nIndex; -// numberNode++; -// -// //+z//+y -// nIndex = grid->transCoordToIndex(x, newY, newZ); -// eind[numberNode] = nIndex; -// numberNode++; -// -// } -// -// -// //for (int i = 0; i < nelements; i++) { -// // printf("element %d: ", i); -// // for (int v = eptr[i]; v < eptr[i + 1]; v++) { -// // printf("%d ", eind[v]); -// // } -// // printf("\n"); -// //} -// -// // Weights of vertices -// // if all weights are equal then can be set to NULL -// //idx_t vwgtMesh[nNodes * nWeightsMesh] = { 1, 1, 1, 1, 1, 1, 1, 1, 1 }; -// -// idx_t ncommon = 4; -// -// rstatus_et ret = (rstatus_et)METIS_PartMeshDual(&nelements, &nNodes, eptr, eind, -// NULL, NULL, &ncommon, &nPartsMesh, -// NULL, NULL, &objval, partMeshElements, partMeshNodes); -// -// std::cout << ret << std::endl; -// -// for (int part_i = 0; part_i < nelements; part_i++){ -// std::cout << part_i << " " << partMeshElements[part_i] << std::endl; -// } -// -// -// for (unsigned int part_i = 0; part_i < grid->getSize(); part_i++){ -// //grid->setFieldEntry(part_i, partMeshNodes[part_i]); -// } -// -// GridVTKWriter::writeSparseGridToVTK(grid, "../../../../metisGridMesh.vtk"); -// -// delete[] partMeshNodes; -// delete[] partMeshElements; -// delete[] eptr; -// delete[] eind; -//} -// -//void Partition::partitionGrid(SPtr<Grid> grid) { -// idx_t nVertices = grid->getSize(); -// idx_t nEdges = calcEdgesFromGraph(grid); -// idx_t nWeights = 1; -// idx_t nParts = 4; -// -// idx_t objval; -// idx_t* part = new idx_t[nVertices]; -// idx_t* xadj = new idx_t[nVertices + 1]; -// idx_t* adjncy = new idx_t[nEdges]; -// -// xadj[0] = 0; -// real x, y, z, newX, newY, newZ; -// int nIndex; -// int numberOfNeighbors = 0; -// int counter = 0; -// for (int index = 0; index < nVertices; index++) { -// grid->transIndexToCoords(index, x, y, z); -// //+x -// newX = x + 1; -// if (newX >= 0 && newX < grid->getNumberOfNodesX()) { -// nIndex = grid->transCoordToIndex(newX, y, z); -// adjncy[numberOfNeighbors] = nIndex; -// numberOfNeighbors++; -// } -// //-x -// newX = x - 1; -// if (newX >= 0 && newX < grid->getNumberOfNodesX()) { -// nIndex = grid->transCoordToIndex(newX, y, z); -// adjncy[numberOfNeighbors] = nIndex; -// numberOfNeighbors++; -// } -// -// //+y -// newY = y + 1; -// if (newY >= 0 && newY < grid->getNumberOfNodesY()) { -// nIndex = grid->transCoordToIndex(x, newY, z); -// adjncy[numberOfNeighbors] = nIndex; -// numberOfNeighbors++; -// } -// -// //-y -// newY = y - 1; -// if (newY >= 0 && newY < grid->getNumberOfNodesY()) { -// nIndex = grid->transCoordToIndex(x, newY, z); -// adjncy[numberOfNeighbors] = nIndex; -// numberOfNeighbors++; -// } -// -// //+z -// newZ = z + 1; -// if (newZ >= 0 && newZ < grid->getNumberOfNodesZ()) { -// nIndex = grid->transCoordToIndex(x, y, newZ); -// adjncy[numberOfNeighbors] = nIndex; -// numberOfNeighbors++; -// } -// -// //-z -// newZ = z - 1; -// if (newZ >= 0 && newZ < grid->getNumberOfNodesZ()) { -// nIndex = grid->transCoordToIndex(x, y, newZ); -// adjncy[numberOfNeighbors] = nIndex; -// numberOfNeighbors++; -// } -// xadj[index + 1] = numberOfNeighbors; -// } -// -// -// // Indexes of starting points in adjacent array -// //idx_t xadj[nVertices + 1] = { 0, 2, 5, 7, 9, 12, 14 }; -// -// // Adjacent vertices in consecutive index order -// //idx_t adjncy[2 * nEdges] = { 1, 3, 0, 4, 2, 1, 5, 0, 4, 3, 1, 5, 4, 2 }; -// -// -// //for (int index = 0; index < nVertices; index++) { -// // printf("vertexNachbarn von %d: ", index); -// // printf("Grenzen: %d - %d, ", xadj[index], xadj[index + 1]); -// // for (int v = xadj[index]; v < xadj[index + 1]; v++) { -// // printf("%d ", adjncy[v]); -// // } -// // printf("\n"); -// //} -// -// // Weights of vertices -// // if all weights are equal then can be set to NULL -// //idx_t* vwgt = new idx_t[nVertices * nWeights]; -// -// idx_t options[METIS_NOPTIONS]; -// METIS_SetDefaultOptions(options); -// -// options[METIS_OPTION_OBJTYPE] = METIS_OBJTYPE_CUT; //minimizing the edge-cut communication -// -// options[METIS_OPTION_NCUTS] = 1; // number of different partitioning //default 1 -// options[METIS_OPTION_CONTIG] = 1; // force contiguous partitions -// options[METIS_OPTION_DBGLVL] = 0; //print debugging information -// -// rstatus_et ret = (rstatus_et)METIS_PartGraphKway(&nVertices, &nWeights, xadj, adjncy, -// NULL, NULL, NULL, &nParts, NULL, -// NULL, options, &objval, part); -// -// std::cout << ret << std::endl; -// -// //for (unsigned part_i = 0; part_i < nVertices; part_i++){ -// // std::cout << part_i << " " << part[part_i] << std::endl; -// //} -// -// for (int part_i = 0; part_i < nVertices; part_i++){ -// //grid->setFieldEntry(part_i, part[part_i]); -// } -// -// GridVTKWriter::writeSparseGridToVTK(grid, "../../../../metisGridFineFourParts.vtk"); -//} -// -//std::vector<std::vector<int> > Partition::partitionBoxes(std::vector<std::vector<BoundingBox> > boxes, int processes, std::vector< std::shared_ptr<Transformator> > transformators) -//{ -// if (processes == 1){ -// std::vector<std::vector<int> > tasks; -// tasks.resize(processes); -// tasks[0].push_back(0); -// tasks[0].push_back(0); -// return tasks; -// } -// -// std::vector<idx_t> xadj; -// std::vector<idx_t> adjncy; -// -// int numberOfNeighbors = 0; -// xadj.push_back(0); -// for (int level = 0; level < boxes.size(); level++) { -// for (int i = 0; i < boxes[level].size(); i++) { -// -// BoundingBox box = boxes[level][i]; -// transformators[level]->transformGridToWorld(box); -// -// int index = i + (int)boxes[level].size() * level; -// for (int levelCompare = 0; levelCompare < boxes.size(); levelCompare++) { -// for (int iCompare = 0; iCompare < boxes[levelCompare].size(); iCompare++) { -// int indexCompare = iCompare + (int)boxes[levelCompare].size() * levelCompare; -// if (index == indexCompare) -// continue; -// -// BoundingBox boxCompare = boxes[levelCompare][iCompare]; -// transformators[level]->transformGridToWorld(boxCompare); -// if (box.intersect(boxCompare)) { -// adjncy.push_back(indexCompare); -// numberOfNeighbors++; -// } -// } -// } -// xadj.push_back(numberOfNeighbors); -// } -// } -// -// //logging::Logger::getInstance()->logTerminal("Metis Graph Structure:"); -// //for (int index = 0; index < xadj.size() - 1; index++) { -// // logging::Logger::getInstance()->logTerminal("vertex neighbor [" + SSTR(index) + "]"); -// // logging::Logger::getInstance()->logTerminal(" boundary: " + SSTR(xadj[index]) + " - " + SSTR(xadj[index + 1]) + ","); -// // for (int v = xadj[index]; v < xadj[index + 1]; v++) { -// // logging::Logger::getInstance()->logTerminal(SSTR(adjncy[v]) + " "); -// // } -// // logging::Logger::getInstance()->logTerminal("\n"); -// //} -// -// // Weights of vertices -// // if all weights are equal then can be set to NULL -// //idx_t* vwgt = new idx_t[nVertices * nWeights]; -// -// idx_t options[METIS_NOPTIONS]; -// METIS_SetDefaultOptions(options); -// -// options[METIS_OPTION_OBJTYPE] = METIS_OBJTYPE_CUT; //minimizing the edge-cut communication -// -// options[METIS_OPTION_NCUTS] = 1; // number of different partitioning //default 1 -// options[METIS_OPTION_CONTIG] = 1; // force contiguous partitions -// options[METIS_OPTION_DBGLVL] = 0; //print debugging information -// -// idx_t nVertices = (idx_t)xadj.size() - 1; -// idx_t nWeights = 1; -// idx_t nParts = processes; -// -// idx_t objval; -// idx_t* part = new idx_t[nVertices]; -// -// //rstatus_et ret = (rstatus_et)METIS_PartGraphKway(&nVertices, &nWeights, xadj.data(), adjncy.data(), -// // NULL, NULL, NULL, &nParts, NULL, -// // NULL, options, &objval, part); -// -// rstatus_et ret = (rstatus_et)METIS_PartGraphRecursive(&nVertices, &nWeights, xadj.data(), adjncy.data(), -// NULL, NULL, NULL, &nParts, NULL, -// NULL, options, &objval, part); -// -// if (ret == METIS_OK) -// *logging::out << logging::Logger::INFO_INTERMEDIATE << "Metis Status: OK\n"; -// -// -// -// for (int part_i = 0; part_i < nVertices; part_i++) -// *logging::out << logging::Logger::INFO_INTERMEDIATE << "Block: " << part_i << " - Partition: " << part[part_i] << "\n"; -// -// -// std::vector<std::vector<int> > tasks; -// tasks.resize(processes); -// -// for (int i = 0; i < nVertices; i++) { -// int x = i % boxes[0].size(); -// int level = (i - x) / (int)boxes[0].size(); -// tasks[part[i]].push_back(level); -// tasks[part[i]].push_back(x); -// } -// -// return tasks; -//} -// -//std::vector<BoundingBox> Partition::getProcessBoxes(const int numberOfProcesses, const int globalNx, const int globalNy, const int globalNz) -//{ -// std::vector<BoundingBox> boxes; -// BoundingBox b(0, globalNx, 0, globalNy, 0, globalNz); -// boxes.push_back(b); -// if (numberOfProcesses == 1) -// return boxes; -// -// bool splitX, splitY, splitZ; -// while (boxes.size() < numberOfProcesses) -// { -// findMaxBoxSize(boxes, splitX, splitY, splitZ); -// if (numberOfProcesses % 3 == 0) -// splitAllBoxesInThreePieces(boxes, splitX, splitY, splitZ); -// else -// splitAllBoxesInTwoPieces(boxes, splitX, splitY, splitZ); -// } -// return boxes; -//} -// -//std::vector<std::vector<Triangle> > Partition::getTrianglesPerProcess(std::vector<BoundingBox> &boxes, Triangle *triangles, int nTriangles) -//{ -// std::vector<Triangle> triangleVec; -// triangleVec.resize(nTriangles); -// for (int i = 0; i < nTriangles; i++) -// triangleVec[i] = triangles[i]; -// -// std::vector<std::vector<Triangle> > trianglesPerProcess; -// trianglesPerProcess.resize(boxes.size()); -// -// for (int j = 0; j < triangleVec.size(); j++) { -// for (int i = 0; i < boxes.size(); i++) { -// if (boxes[i].isInside(triangleVec[j])) { -// trianglesPerProcess[i].push_back(triangleVec[j]); -// triangleVec.erase(triangleVec.begin() + j); -// j--; -// break; -// } -// else if (boxes[i].intersect(triangleVec[j])) { -// //splitAndPushTriangle(boxes[i], trianglesPerProcess[i], triangleVec, j); -// trianglesPerProcess[i].push_back(triangleVec[j]); -// } -// } -// } -// return trianglesPerProcess; -//} -// -//void Partition::findMaxBoxSize(std::vector<BoundingBox> &boxes, bool &splitX, bool &splitY, bool &splitZ) -//{ -// int lengthX, lengthY, lengthZ; -// lengthX = boxes[0].maxX - boxes[0].minX; -// lengthY = boxes[0].maxY - boxes[0].minY; -// lengthZ = boxes[0].maxZ - boxes[0].minZ; -// -// splitX = true, splitY = false, splitZ = false; -// if (lengthX < lengthY){ -// splitX = splitZ = false; -// splitY = true; -// } -// else if (lengthY < lengthZ){ -// splitX = splitY = false; -// splitZ = true; -// } -//} -// -//void Partition::splitAllBoxesInThreePieces(std::vector<BoundingBox> &boxes, bool splitX, bool splitY, bool splitZ) -//{ -// std::vector<BoundingBox> boxesTemp; -// for (int i = 0; i < boxes.size(); i++) { -// if (splitX) { -// int newLengthX = (boxes[i].maxX - boxes[i].minX) / 3; -// BoundingBox splitBox1(boxes[i].minX, boxes[i].minX + newLengthX, boxes[i].minY, boxes[i].maxY, boxes[i].minZ, boxes[i].maxZ); -// BoundingBox splitBox2(boxes[i].minX, boxes[i].minX + newLengthX + newLengthX, boxes[i].minY, boxes[i].maxY, boxes[i].minZ, boxes[i].maxZ); -// BoundingBox splitBox3(boxes[i].minX + newLengthX + newLengthX, boxes[i].maxX, boxes[i].minY, boxes[i].maxY, boxes[i].minZ, boxes[i].maxZ); -// boxesTemp.push_back(splitBox1); -// boxesTemp.push_back(splitBox2); -// boxesTemp.push_back(splitBox3); -// } -// if (splitY) { -// int newLengthY = (boxes[i].maxY - boxes[i].minY) / 3; -// BoundingBox splitBox1(boxes[i].minX, boxes[i].maxX, boxes[i].minY, boxes[i].minY + newLengthY, boxes[i].minZ, boxes[i].maxZ); -// BoundingBox splitBox2(boxes[i].minX, boxes[i].maxX, boxes[i].minY + newLengthY, boxes[i].minY + newLengthY + newLengthY, boxes[i].minZ, boxes[i].maxZ); -// BoundingBox splitBox3(boxes[i].minX, boxes[i].maxX, boxes[i].minY + newLengthY + newLengthY, boxes[i].maxY, boxes[i].minZ, boxes[i].maxZ); -// boxesTemp.push_back(splitBox1); -// boxesTemp.push_back(splitBox2); -// boxesTemp.push_back(splitBox3); -// } -// if (splitZ) { -// int newLengthZ = (boxes[i].maxZ - boxes[i].minZ) / 3; -// BoundingBox splitBox1(boxes[i].minX, boxes[i].maxX, boxes[i].minY, boxes[i].maxY, boxes[i].minZ, boxes[i].minZ + newLengthZ); -// BoundingBox splitBox2(boxes[i].minX, boxes[i].maxX, boxes[i].minY, boxes[i].maxY, boxes[i].minZ + newLengthZ, boxes[i].minZ + newLengthZ + newLengthZ); -// BoundingBox splitBox3(boxes[i].minX, boxes[i].maxX, boxes[i].minY, boxes[i].maxY, boxes[i].minZ + newLengthZ + newLengthZ, boxes[i].maxZ); -// boxesTemp.push_back(splitBox1); -// boxesTemp.push_back(splitBox2); -// boxesTemp.push_back(splitBox3); -// } -// } -// boxes.clear(); -// boxes = boxesTemp; -//} -// -//void Partition::splitAllBoxesInTwoPieces(std::vector<BoundingBox> &boxes, bool splitX, bool splitY, bool splitZ) -//{ -// std::vector<BoundingBox> boxesTemp; -// for (int i = 0; i < boxes.size(); i++) { -// if (splitX) { -// int newLengthX = (boxes[i].maxX - boxes[i].minX) / 2; -// BoundingBox splitBox1(boxes[i].minX, boxes[i].minX + newLengthX, boxes[i].minY, boxes[i].maxY, boxes[i].minZ, boxes[i].maxZ); -// BoundingBox splitBox2(boxes[i].minX + newLengthX, boxes[i].maxX, boxes[i].minY, boxes[i].maxY, boxes[i].minZ, boxes[i].maxZ); -// boxesTemp.push_back(splitBox1); -// boxesTemp.push_back(splitBox2); -// } -// if (splitY) { -// int newLengthY = (boxes[i].maxY - boxes[i].minY) / 2; -// BoundingBox splitBox1(boxes[i].minX, boxes[i].maxX, boxes[i].minY, boxes[i].minY + newLengthY, boxes[i].minZ, boxes[i].maxZ); -// BoundingBox splitBox2(boxes[i].minX, boxes[i].maxX, boxes[i].minY + newLengthY, boxes[i].maxY, boxes[i].minZ, boxes[i].maxZ); -// boxesTemp.push_back(splitBox1); -// boxesTemp.push_back(splitBox2); -// } -// if (splitZ) { -// int newLengthZ = (boxes[i].maxZ - boxes[i].minZ) / 2; -// BoundingBox splitBox1(boxes[i].minX, boxes[i].maxX, boxes[i].minY, boxes[i].maxY, boxes[i].minZ, boxes[i].minZ + newLengthZ); -// BoundingBox splitBox2(boxes[i].minX, boxes[i].maxX, boxes[i].minY, boxes[i].maxY, boxes[i].minZ + newLengthZ, boxes[i].maxZ); -// boxesTemp.push_back(splitBox1); -// boxesTemp.push_back(splitBox2); -// } -// } -// boxes.clear(); -// boxes = boxesTemp; -//} -// -//std::vector<std::vector<Triangle> > Partition::splitTriangles(std::vector<Triangle> &triangleVec, std::vector<BoundingBox> boxes) -//{ -// std::vector<std::vector<Triangle> > trianglesPerProcess; -// trianglesPerProcess.resize(boxes.size()); -// -// for (int j = 0; j < triangleVec.size(); j++) { -// for (int i = 0; i < boxes.size(); i++) { -// if (boxes[i].isInside(triangleVec[j])) { -// trianglesPerProcess[i].push_back(triangleVec[j]); -// triangleVec.erase(triangleVec.begin() + j); -// j--; -// break; -// } -// else if (boxes[i].intersect(triangleVec[j])) { -// splitAndPushTriangle(boxes[i], trianglesPerProcess[i], triangleVec, j); -// //trianglesPerProcess[i].push_back(triangleVec[j]); -// } -// } -// } -// -// return trianglesPerProcess; -// -//} -// -// -// -//void Partition::splitAndPushTriangle(BoundingBox &box, std::vector<Triangle> &trianglesPerProcess, std::vector<Triangle> &triangleVec, int indexTriangle) -//{ -// Triangle triangleToSplit = triangleVec[indexTriangle]; -// //BoundingBox triangleBox = BoundingBox::makeExactBox(triangleToSplit); -// //std::vector<std::vector<Vertex> > intersectionsBox = box.getIntersectionPoints(triangleBox); -// -// //UnstructuredGridWriter writer; -// //double v1[3] = { triangleToSplit.v1.x, triangleToSplit.v1.y, triangleToSplit.v1.z }; -// //double v2[3] = { triangleToSplit.v2.x, triangleToSplit.v2.y, triangleToSplit.v2.z }; -// //double v3[3] = { triangleToSplit.v3.x, triangleToSplit.v3.y, triangleToSplit.v3.z }; -// //writer.addTriangle(v1, v2, v3); -// //double b[6] = { box.minX, box.maxX, box.minY, box.maxY, box.minZ, box.maxZ }; -// //writer.addBoundingBox(b); -// //double b2[6] = { triangleBox.minX, triangleBox.maxX, triangleBox.minY, triangleBox.maxY, triangleBox.minZ, triangleBox.maxZ }; -// //writer.addBoundingBox(b2); -// //writer.writeUnstructuredGridToFile("testIntersectionTriangle"); -// -// -// //for (int i = 0; i < intersectionsBox.size(); i++) { -// // if (intersectionsBox[i].size() == 0) -// // continue; -// -// // Vertex edge1 = intersectionsBox[i][0] - intersectionsBox[i][1]; -// // Vertex edge2 = intersectionsBox[i][1] - intersectionsBox[i][2]; -// // Vertex normal = edge1.crossProduct(edge2); -// // normal.normalize(); -// -// // Vertex point(intersectionsBox[i][0].x, intersectionsBox[i][0].y, intersectionsBox[i][0].z); -// // Vertex v4 = (triangleToSplit.v1 - point); -// // Vertex v5 = (triangleToSplit.v2 - point); -// // Vertex v6 = (triangleToSplit.v3 - point); -// -// // real d1 = v4 * normal; -// // real d2 = v5 * normal; -// // real d3 = v6 * normal; -// -// // // a to b crosses the clipping plane -// // if (d1 * d2 < 0.0f) -// // sliceTriangle(trianglesPerProcess, triangleVec, indexTriangle, triangleToSplit.v1, triangleToSplit.v2, triangleToSplit.v3, d1, d2, d3); -// -// // // a to c crosses the clipping plane -// // else if (d1 * d3 < 0.0f) -// // sliceTriangle(trianglesPerProcess, triangleVec, indexTriangle, triangleToSplit.v3, triangleToSplit.v1, triangleToSplit.v2, d3, d1, d2); -// -// // // b to c crosses the clipping plane -// // else if (d2 * d3 < 0.0f) -// // sliceTriangle(trianglesPerProcess, triangleVec, indexTriangle, triangleToSplit.v2, triangleToSplit.v3, triangleToSplit.v1, d2, d3, d1); -// //} -//} -// -// -//void Partition::sliceTriangle( -// std::vector<Triangle>& out, -// std::vector<Triangle>& triangleVec, -// int index, -// const Vertex& a, // First point on triangle, CCW order -// const Vertex& b, // Second point on triangle, CCW order -// const Vertex& c, // Third point on triangle, CCW order -// real d1, // Distance of point a to the splitting plane -// real d2, // Distance of point b to the splitting plane -// real d3 // Distance of point c to the splitting plane -// ) -//{ -// // Calculate the intersection point from a to b -// Vertex ab = a + ((b - a) * (d1 / (d1 - d2)) ); -// Triangle tri; -// -// if (d1 < 0.0f) -// { -// // b to c crosses the clipping plane -// if (d3 < 0.0f) -// { -// // Calculate intersection point from b to c -// Vertex bc = b + ((c - b) * (d2 / (d2 - d3))); -// -// tri.set(b, bc, ab); -// triangleVec.push_back(tri); -// -// tri.set(bc, c, a); -// triangleVec.push_back(tri); -// -// tri.set(ab, bc, a); -// triangleVec.push_back(tri); -// } -// -// // c to a crosses the clipping plane -// else -// { -// // Calculate intersection point from a to c -// Vertex ac = a + ((c - a) * (d1 / (d1 - d3))); -// -// tri.set(a, ab, ac); -// triangleVec.push_back(tri); -// -// tri.set(ab, b, c); -// triangleVec.push_back(tri); -// -// tri.set(ac, ab, c); -// triangleVec.push_back(tri); -// } -// } -// else -// { -// // c to a crosses the clipping plane -// if (d3 < 0.0f) -// { -// // Calculate intersection point from a to c -// Vertex ac = a + ((c - a) * (d1 / (d1 - d3))); -// -// tri.set(a, ab, ac); -// triangleVec.push_back(tri); -// -// tri.set(ac, ab, b); -// triangleVec.push_back(tri); -// -// tri.set(b, c, ac); -// triangleVec.push_back(tri); -// } -// -// // b to c crosses the clipping plane -// else -// { -// // Calculate intersection point from b to c -// Vertex bc = b + ((c - b) * (d2 / (d2 - d3))); -// -// tri.set(b, bc, ab); -// triangleVec.push_back(tri); -// -// tri.set(a, ab, bc); -// triangleVec.push_back(tri); -// -// tri.set(c, a, bc); -// triangleVec.push_back(tri); -// } -// } -//} -// diff --git a/src/gpu/GridGenerator/grid/partition/Partition.h b/src/gpu/GridGenerator/grid/partition/Partition.h deleted file mode 100644 index a45f7668b871f6910332de7262c6d407f32d1d7f..0000000000000000000000000000000000000000 --- a/src/gpu/GridGenerator/grid/partition/Partition.h +++ /dev/null @@ -1,45 +0,0 @@ -//#ifndef Partition_H -//#define Partition_H -// -//#include "global.h" -// -// -//#include <vector> -//#include <string> -//#include <memory> -// -//class BoundingBox; -//struct Triangle; -//struct Vertex; -//class Grid; -//class Transformator; -// -//class GRIDGENERATOR_EXPORT Partition -//{ -//public: -// static void partitionGridMesh(SPtr<Grid> grid); -// static void partitionGrid(SPtr<Grid> grid); -// -// static std::vector<BoundingBox > getProcessBoxes(const int numberOfProcesses, const int globalNx, const int globalNy, const int globalNz); -// static std::vector<std::vector<int> > partitionBoxes(std::vector<std::vector<BoundingBox> >, int processes, std::vector< std::shared_ptr<Transformator> > transformators); -// -// static std::vector<std::vector<Triangle> > getTrianglesPerProcess(std::vector<BoundingBox> &boxes, Triangle *triangles, int nTriangles); -// -// static std::vector<std::vector<Triangle> > splitTriangles(std::vector<Triangle> &triangleVec, std::vector<BoundingBox> boxes); -// -//private: -// Partition(){}; -// ~Partition(){}; -// -// static int calcEdgesFromGraph(SPtr<Grid> grid); -// -// static void splitAllBoxesInThreePieces(std::vector<BoundingBox> &boxes, bool splitX, bool splitY, bool splitZ); -// static void splitAllBoxesInTwoPieces(std::vector<BoundingBox> &boxes, bool splitX, bool splitY, bool splitZ); -// static void findMaxBoxSize(std::vector<BoundingBox> &boxes, bool &splitX, bool &splitY, bool &splitZ); -// -// static void splitAndPushTriangle(BoundingBox &box, std::vector<Triangle> &trianglesPerProcess, std::vector<Triangle> &triangleVec, int indexTriangle); -// static void sliceTriangle(std::vector<Triangle> &out, std::vector<Triangle>& triangleVec, int index, const Vertex& a, const Vertex& b, const Vertex& c, real d1, real d2, real d3); -// -//}; -// -//#endif diff --git a/src/gpu/GridGenerator/io/GridVTKWriter/GridVTKWriter.cpp b/src/gpu/GridGenerator/io/GridVTKWriter/GridVTKWriter.cpp index e3e8960d90403e8e523d668fe0f55ee13b73812f..35b3197ff7c3f37eb33809cc9a909f0085d2dffc 100644 --- a/src/gpu/GridGenerator/io/GridVTKWriter/GridVTKWriter.cpp +++ b/src/gpu/GridGenerator/io/GridVTKWriter/GridVTKWriter.cpp @@ -1,3 +1,35 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids 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. +// +// VirtualFluids 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 VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file GridVTKWriter.cpp +//! \ingroup io +//! \author Soeren Peters, Stephan Lenz +//======================================================================================= #define _CRT_SECURE_NO_DEPRECATE #include "GridVTKWriter.h" @@ -245,74 +277,6 @@ void GridVTKWriter::writeInterpolationCellsToVTKXML(SPtr<Grid> grid, SPtr<Grid> } WbWriterVtkXmlBinary::getInstance()->writeOctsWithCellData(name, nodes, cells, celldatanames, celldata); } -//deprecated -//void GridVTKWriter::writeGridToVTKXML(SPtr<Grid> grid, const std::string& name, WRITING_FORMAT format) -//{ -// std::vector<UbTupleFloat3> nodes; -// std::vector<UbTupleUInt8> cells; -// std::vector<std::string> nodedatanames; -// std::vector< std::vector<double> > nodedata; -// -// nodedatanames.push_back("types"); -// -// -// nodedata.resize(nodedatanames.size()); -// -// CbArray3D<int> nodeNumbers(grid->getNumberOfNodesX(), grid->getNumberOfNodesY(), grid->getNumberOfNodesZ(), -1); -// int nr = 0; -// -// for (real x = grid->getStartX(); x <= grid->getEndX(); x += grid->getDelta()) -// { -// for (real y = grid->getStartY(); y <= grid->getEndY(); y += grid->getDelta()) -// { -// for (real z = grid->getStartZ(); z <= grid->getEndZ(); z += grid->getDelta()) -// { -// const auto xTranslate = int((x - grid->getStartX()) / grid->getDelta()); -// const auto yTranslate = int((y - grid->getStartY()) / grid->getDelta()); -// const auto zTranslate = int((z - grid->getStartZ()) / grid->getDelta()); -// nodeNumbers(xTranslate, yTranslate, zTranslate) = nr++; -// nodes.push_back(UbTupleFloat3(float(x), float(y),float(z))); -// -// const char type = grid->getFieldEntry(grid->transCoordToIndex(x, y, z)); -// nodedata[0].push_back(type); -// } -// } -// } -// -// int SWB, SEB, NEB, NWB, SWT, SET, NET, NWT; -// for (real x = grid->getStartX(); x < grid->getEndX(); x += grid->getDelta()) -// { -// for (real y = grid->getStartY(); y < grid->getEndY(); y += grid->getDelta()) -// { -// for (real z = grid->getStartZ(); z < grid->getEndZ(); z += grid->getDelta()) -// { -// const auto xTranslate = int((x - grid->getStartX()) / grid->getDelta()); -// const auto yTranslate = int((y - grid->getStartY()) / grid->getDelta()); -// const auto zTranslate = int((z - grid->getStartZ()) / grid->getDelta()); -// -// if (!nodeNumbers.indicesInRange(xTranslate + 1, yTranslate +1, zTranslate +1)) // blame Lenz -// continue; -// -// if ((SWB = nodeNumbers(xTranslate, yTranslate, zTranslate)) >= 0 -// && (SEB = nodeNumbers(xTranslate + 1, yTranslate, zTranslate)) >= 0 -// && (NEB = nodeNumbers(xTranslate + 1, yTranslate + 1, zTranslate)) >= 0 -// && (NWB = nodeNumbers(xTranslate, yTranslate + 1, zTranslate)) >= 0 -// && (SWT = nodeNumbers(xTranslate, yTranslate, zTranslate + 1)) >= 0 -// && (SET = nodeNumbers(xTranslate + 1, yTranslate, zTranslate + 1)) >= 0 -// && (NET = nodeNumbers(xTranslate + 1, yTranslate + 1, zTranslate + 1)) >= 0 -// && (NWT = nodeNumbers(xTranslate, yTranslate + 1, zTranslate + 1)) >= 0) -// { -// Cell cell(x, y, z, grid->getDelta()); -// if(grid->nodeInCellIs(cell, OUT_OF_GRID) || grid->nodeInCellIs(cell, INVALID_NODE)) -// continue; -// -// cells.push_back(makeUbTuple(uint(SWB), uint(SEB), uint(NEB), uint(NWB), uint(SWT), uint(SET), uint(NET), uint(NWT))); -// } -// } -// } -// } -// WbWriterVtkXmlBinary::getInstance()->writeOctsWithNodeData(name, nodes, cells, nodedatanames, nodedata); -//} /*#################################################################################*/ diff --git a/src/gpu/GridGenerator/io/GridVTKWriter/GridVTKWriter.h b/src/gpu/GridGenerator/io/GridVTKWriter/GridVTKWriter.h index 43fe611459a2509ddb032cce993b171673fa407f..cf33df096a6e670b65f79831d59927e3d7cea389 100644 --- a/src/gpu/GridGenerator/io/GridVTKWriter/GridVTKWriter.h +++ b/src/gpu/GridGenerator/io/GridVTKWriter/GridVTKWriter.h @@ -1,3 +1,35 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids 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. +// +// VirtualFluids 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 VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file GridVTKWriter.h +//! \ingroup io +//! \author Soeren Peters, Stephan Lenz +//======================================================================================= #ifndef GridVTKWriter_h #define GridVTKWriter_h diff --git a/src/gpu/GridGenerator/io/QLineWriter.cpp b/src/gpu/GridGenerator/io/QLineWriter.cpp index 6df995b2d5ef73c7797234a61f78810666f675f0..29894e8d589fb59c1dbf57e08692dddfc03619a1 100644 --- a/src/gpu/GridGenerator/io/QLineWriter.cpp +++ b/src/gpu/GridGenerator/io/QLineWriter.cpp @@ -1,3 +1,35 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids 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. +// +// VirtualFluids 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 VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file QLineWriter.cpp +//! \ingroup io +//! \author Soeren Peters, Stephan Lenz +//======================================================================================= #include "QLineWriter.h" #include <vector> diff --git a/src/gpu/GridGenerator/io/QLineWriter.h b/src/gpu/GridGenerator/io/QLineWriter.h index 01596adbd026404db74d7029218d90171b3b09dc..c7fed1a8ff16e81398e18c7fdde347cd09a93452 100644 --- a/src/gpu/GridGenerator/io/QLineWriter.h +++ b/src/gpu/GridGenerator/io/QLineWriter.h @@ -1,3 +1,35 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids 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. +// +// VirtualFluids 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 VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file QLineWriter.h +//! \ingroup io +//! \author Soeren Peters, Stephan Lenz +//======================================================================================= #ifndef QLINEWRITER_H #define QLINEWRITER_H diff --git a/src/gpu/GridGenerator/io/STLReaderWriter/STLReader.cpp b/src/gpu/GridGenerator/io/STLReaderWriter/STLReader.cpp index 9c874456ff0956429fafb34cec9fff026a11cafb..d3eb221265b2f8c79d5aece8729585733c2d60e8 100644 --- a/src/gpu/GridGenerator/io/STLReaderWriter/STLReader.cpp +++ b/src/gpu/GridGenerator/io/STLReaderWriter/STLReader.cpp @@ -1,3 +1,35 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids 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. +// +// VirtualFluids 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 VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file STLReader.cpp +//! \ingroup io +//! \author Soeren Peters, Stephan Lenz +//======================================================================================= #define _CRT_SECURE_NO_DEPRECATE #include "STLReader.h" @@ -181,18 +213,17 @@ std::vector<Triangle> STLReader::readBinarySTL(const std::string& name) FILE *file = fopen(name.c_str(), mode.c_str()); char header_info[80] = ""; - auto read_values = fread(header_info, sizeof(char), 80, file); + size_t sizef = fread(header_info, sizeof(char), 80, file); char nTri[4]; - read_values = fread(nTri, sizeof(char), 4, file); + sizef = fread(nTri, sizeof(char), 4, file); unsigned long nTriLong = *((unsigned long*)nTri); *logging::out << logging::Logger::INFO_INTERMEDIATE << "Number of Triangles: " << nTriLong << "\n"; std::vector<Triangle> triangles; char facet[50]; for (unsigned int i = 0; i < nTriLong; i++){ - read_values = fread(facet, sizeof(char), 50, file); - (void) read_values; + sizef = fread(facet, sizeof(char), 50, file); Vertex normal = getVertexFromChar(facet); @@ -202,6 +233,7 @@ std::vector<Triangle> STLReader::readBinarySTL(const std::string& name) triangles.push_back(Triangle(p1, p2, p3, normal)); } + (void)sizef; fclose(file); return triangles; @@ -273,10 +305,10 @@ std::vector<Triangle> STLReader::readBinarySTL(const BoundingBox &box, const std char nTri[4]; unsigned long nTriLong; - auto read_values = fread(header_info, sizeof(char), 80, file); + size_t sizef = fread(header_info, sizeof(char), 80, file); - read_values = fread(nTri, sizeof(char), 4, file); + sizef = fread(nTri, sizeof(char), 4, file); nTriLong = *((unsigned long*)nTri); *logging::out << logging::Logger::INFO_INTERMEDIATE << "Number of Triangles complete geometry: " << nTriLong << "\n"; @@ -284,8 +316,7 @@ std::vector<Triangle> STLReader::readBinarySTL(const BoundingBox &box, const std char facet[50]; for (unsigned int i = 0; i < nTriLong; i++){ - read_values = fread(facet, sizeof(char), 50, file); - (void) read_values; + sizef = fread(facet, sizeof(char), 50, file); Vertex normal = getVertexFromChar(facet); @@ -300,7 +331,7 @@ std::vector<Triangle> STLReader::readBinarySTL(const BoundingBox &box, const std int size = (int)triangles.size(); *logging::out << logging::Logger::INFO_INTERMEDIATE << "Number of Triangles in process: " << size << "\n"; *logging::out << logging::Logger::INFO_INTERMEDIATE << "Complete reading STL file. \n"; - + (void)sizef; fclose(file); return triangles; diff --git a/src/gpu/GridGenerator/io/STLReaderWriter/STLReader.h b/src/gpu/GridGenerator/io/STLReaderWriter/STLReader.h index 3e7beef8c6b0d81c454d2ca6fec5fca5d0d7f6d4..333313727530ae551c76a76984cd63f6cd0f11ce 100644 --- a/src/gpu/GridGenerator/io/STLReaderWriter/STLReader.h +++ b/src/gpu/GridGenerator/io/STLReaderWriter/STLReader.h @@ -1,3 +1,35 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids 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. +// +// VirtualFluids 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 VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file STLReader.h +//! \ingroup io +//! \author Soeren Peters, Stephan Lenz +//======================================================================================= #ifndef STLReader_H #define STLReader_H diff --git a/src/gpu/GridGenerator/io/STLReaderWriter/STLWriter.cpp b/src/gpu/GridGenerator/io/STLReaderWriter/STLWriter.cpp index 36e099c61d495f7402c68e581e4c68e194dad6b4..e29320cbd6867e1ae5a65cf41623780cd83aead7 100644 --- a/src/gpu/GridGenerator/io/STLReaderWriter/STLWriter.cpp +++ b/src/gpu/GridGenerator/io/STLReaderWriter/STLWriter.cpp @@ -1,3 +1,35 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids 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. +// +// VirtualFluids 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 VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file STLWriter.cpp +//! \ingroup io +//! \author Soeren Peters, Stephan Lenz +//======================================================================================= #define _CRT_SECURE_NO_DEPRECATE #include "STLWriter.h" diff --git a/src/gpu/GridGenerator/io/STLReaderWriter/STLWriter.h b/src/gpu/GridGenerator/io/STLReaderWriter/STLWriter.h index c6185480237cf5a8dab0fc8c9b71044a420fd70c..4ba87fd82e147fd94507d5557a078f5c581c6d07 100644 --- a/src/gpu/GridGenerator/io/STLReaderWriter/STLWriter.h +++ b/src/gpu/GridGenerator/io/STLReaderWriter/STLWriter.h @@ -1,3 +1,35 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids 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. +// +// VirtualFluids 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 VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file STLWriter.h +//! \ingroup io +//! \author Soeren Peters, Stephan Lenz +//======================================================================================= #ifndef STLWriter_H #define STLWriter_H diff --git a/src/gpu/GridGenerator/io/SimulationFileWriter/SimulationFileNames.cpp b/src/gpu/GridGenerator/io/SimulationFileWriter/SimulationFileNames.cpp index 7cf2412a35ca15ac63ae36ad55dbed58cf9cec5a..34b6b1d3c30b15333afb0afeb5d35d2894e07e52 100644 --- a/src/gpu/GridGenerator/io/SimulationFileWriter/SimulationFileNames.cpp +++ b/src/gpu/GridGenerator/io/SimulationFileWriter/SimulationFileNames.cpp @@ -1,3 +1,35 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids 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. +// +// VirtualFluids 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 VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file SimulationFileNames.cpp +//! \ingroup io +//! \author Soeren Peters, Stephan Lenz +//======================================================================================= #include "SimulationFileNames.h" const std::string fileEnding = ".dat"; diff --git a/src/gpu/GridGenerator/io/SimulationFileWriter/SimulationFileNames.h b/src/gpu/GridGenerator/io/SimulationFileWriter/SimulationFileNames.h index fdc09047f7037d60df1f3de5c33be57137c06286..4be5b44bd4760764da672239052e17bd406316d3 100644 --- a/src/gpu/GridGenerator/io/SimulationFileWriter/SimulationFileNames.h +++ b/src/gpu/GridGenerator/io/SimulationFileWriter/SimulationFileNames.h @@ -1,3 +1,35 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids 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. +// +// VirtualFluids 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 VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file SimulationFileNames.h +//! \ingroup io +//! \author Soeren Peters, Stephan Lenz +//======================================================================================= #ifndef SimulationFileNames_H #define SimulationFileNames_H diff --git a/src/gpu/GridGenerator/io/SimulationFileWriter/SimulationFileWriter.cpp b/src/gpu/GridGenerator/io/SimulationFileWriter/SimulationFileWriter.cpp index 53ce24344ab430e0a65ada9c78506f4f0440ca8b..320a6e5fb7bb8e52a335722bca71d7d6a2a0c6de 100644 --- a/src/gpu/GridGenerator/io/SimulationFileWriter/SimulationFileWriter.cpp +++ b/src/gpu/GridGenerator/io/SimulationFileWriter/SimulationFileWriter.cpp @@ -1,3 +1,35 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids 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. +// +// VirtualFluids 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 VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file SimulationFileWriter.cpp +//! \ingroup io +//! \author Soeren Peters, Stephan Lenz +//======================================================================================= #define _CRT_SECURE_NO_DEPRECATE #include "SimulationFileWriter.h" @@ -514,7 +546,7 @@ void SimulationFileWriter::writeBoundaryQsFile(SPtr<GridBuilder> builder) SideType sides[] = {SideType::MX, SideType::PX, SideType::PZ, SideType::MZ, SideType::MY, SideType::PY, SideType::GEOMETRY}; - for (int side = 0; side < QFILES; side++) { + for (uint side = 0; side < QFILES; side++) { for (uint level = 0; level < builder->getNumberOfGridLevels(); level++) { @@ -575,7 +607,7 @@ void SimulationFileWriter::writeBoundaryShort(std::vector<real> boundary, int rb *valueStreams[rb] << "\n"; } -void SimulationFileWriter::writeBoundaryShort(SPtr<Grid> grid, SPtr<BoundaryCondition> boundaryCondition, uint side) +void SimulationFileWriter::writeBoundaryShort(SPtr<Grid> grid, SPtr<gg::BoundaryCondition> boundaryCondition, uint side) { uint numberOfBoundaryNodes = (uint)boundaryCondition->indices.size(); diff --git a/src/gpu/GridGenerator/io/SimulationFileWriter/SimulationFileWriter.h b/src/gpu/GridGenerator/io/SimulationFileWriter/SimulationFileWriter.h index 116c84b12365e8932dadd82180711bcaa9706928..4a4552f74b69949865e233014d74ac7168b36b31 100644 --- a/src/gpu/GridGenerator/io/SimulationFileWriter/SimulationFileWriter.h +++ b/src/gpu/GridGenerator/io/SimulationFileWriter/SimulationFileWriter.h @@ -1,3 +1,35 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids 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. +// +// VirtualFluids 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 VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file SimulationFileWriter.h +//! \ingroup io +//! \author Soeren Peters, Stephan Lenz +//======================================================================================= #ifndef SimulationFileWriter_H #define SimulationFileWriter_H @@ -15,7 +47,10 @@ class UnstructuredGridBuilder; class GridBuilder; class Grid; +namespace gg +{ class BoundaryCondition; +} enum class FILEFORMAT { @@ -51,7 +86,7 @@ private: static void fillRBForNode(int index, int direction, int directionSign, int rb, std::vector<std::vector<std::vector<real> > > &qs, SPtr<Grid> grid); static void writeBoundary(std::vector<real> boundary, int rb); static void writeBoundaryShort(std::vector<real> boundary, int rb); - static void writeBoundaryShort(SPtr<Grid> grid, SPtr<BoundaryCondition> boundaryCondition, uint side); + static void writeBoundaryShort(SPtr<Grid> grid, SPtr<gg::BoundaryCondition> boundaryCondition, uint side); static void writeCommunicationFiles(SPtr<GridBuilder> builder); diff --git a/src/gpu/GridGenerator/io/VTKWriterWrapper/PolyDataWriterWrapper.cpp b/src/gpu/GridGenerator/io/VTKWriterWrapper/PolyDataWriterWrapper.cpp deleted file mode 100644 index 3ce6742b1615e80e028b10b24870e593a3672819..0000000000000000000000000000000000000000 --- a/src/gpu/GridGenerator/io/VTKWriterWrapper/PolyDataWriterWrapper.cpp +++ /dev/null @@ -1,29 +0,0 @@ -//#include "PolyDataWriterWrapper.h" -// -//#include <VTKWriter/PolyDataWriter/PolyDataWriterImp.h> -// -//#include <GridGenerator/geometries/Arrow/Arrow.h> -//#include <GridGenerator/geometries/Vertex/Vertex.h> -// -// -//PolyDataWriterWrapper::PolyDataWriterWrapper() -//{ -// writer = std::shared_ptr<PolyDataWriter>(new PolyDataWriterImp()); -//} -// -//PolyDataWriterWrapper::~PolyDataWriterWrapper() -//{ -// -//} -// -//void PolyDataWriterWrapper::addVectorArrow(std::shared_ptr<const Arrow> arrow) -//{ -// double startPoint[] = { arrow->getStart()->x, arrow->getStart()->y, arrow->getStart()->z }; -// double endPoint[] = { arrow->getEnd()->x, arrow->getEnd()->y, arrow->getEnd()->z }; -// writer->addVectorArrow(startPoint, endPoint); -//} -// -//void PolyDataWriterWrapper::writePolyDataToFile(const std::string& filename) const -//{ -// writer->writePolyDataToFile(filename); -//} diff --git a/src/gpu/GridGenerator/io/VTKWriterWrapper/PolyDataWriterWrapper.h b/src/gpu/GridGenerator/io/VTKWriterWrapper/PolyDataWriterWrapper.h deleted file mode 100644 index c7b3829d65db5520ee0170897d46c540dedcdb24..0000000000000000000000000000000000000000 --- a/src/gpu/GridGenerator/io/VTKWriterWrapper/PolyDataWriterWrapper.h +++ /dev/null @@ -1,26 +0,0 @@ -//#ifndef PolyDataWriterWrapper_H -//#define PolyDataWriterWrapper_H -// -// -//#include <string> -//#include <memory> -// -//class PolyDataWriter; -//class Arrow; -// -//class PolyDataWriterWrapper -//{ -//public: -// GRIDGENERATOR_EXPORT PolyDataWriterWrapper(); -// GRIDGENERATOR_EXPORT ~PolyDataWriterWrapper(); -// -// GRIDGENERATOR_EXPORT virtual void addVectorArrow(std::shared_ptr<const Arrow> arrow); -// GRIDGENERATOR_EXPORT virtual void writePolyDataToFile(const std::string &filename) const; -// -//private: -// std::shared_ptr<PolyDataWriter> writer; -// -//}; -// -// -//#endif diff --git a/src/gpu/GridGenerator/io/VTKWriterWrapper/UnstructuredGridWrapper.cpp b/src/gpu/GridGenerator/io/VTKWriterWrapper/UnstructuredGridWrapper.cpp deleted file mode 100644 index b2de0057c2aa8effae238b1c1aba1805ec540939..0000000000000000000000000000000000000000 --- a/src/gpu/GridGenerator/io/VTKWriterWrapper/UnstructuredGridWrapper.cpp +++ /dev/null @@ -1,137 +0,0 @@ -//#define _CRT_SECURE_NO_DEPRECATE -//#include "UnstructuredGridWrapper.h" -//#include <iostream> -// -//#include <VTKWriter/UnstructuredGridWriter/UnstructuredGridWriter.h> -// -//#include <GridGenerator/geometries/Triangle/Triangle.h> -//#include <GridGenerator/geometries/Vertex/Vertex.h> -//#include <GridGenerator/geometries/BoundingBox/BoundingBox.h> -//#include <GridGenerator/grid/Grid.cuh> -// -//UnstructuredGridWrapper::UnstructuredGridWrapper() -//{ -//#ifndef __unix__ -// this->writer = new UnstructuredGridWriter(); -//#endif -//} -// -//UnstructuredGridWrapper::~UnstructuredGridWrapper() -//{ -//#ifndef __unix__ -// delete this->writer; -//#endif -//} -// -//void UnstructuredGridWrapper::addBoundingBox(double boundingBox[6], int type) -//{ -//#ifndef __unix__ -// this->writer->addBoundingBox(boundingBox, type); -//#endif -//} -// -//template <typename T> -//void UnstructuredGridWrapper::addBoundingBox(BoundingBox<T> box, int type) -//{ -//#ifndef __unix__ -// double b[6] = {box.minX,box.maxX,box.minY,box.maxY,box.minZ,box.maxZ }; -// this->writer->addBoundingBox(b, type); -//#endif -//} -// -//void UnstructuredGridWrapper::addVoxel(double node[3], double nodeNX[3], double nodeNY[3], double nodeNZ[3], double nodeNYNX[3], double nodeNZNY[3], double nodeNZNX[3], double nodeNZNYNX[3], int nodeTypes[8]) -//{ -//#ifndef __unix__ -// this->writer->addVoxel(node, nodeNX, nodeNY, nodeNZ, nodeNYNX, nodeNZNY, nodeNZNX, nodeNZNYNX, nodeTypes); -//#endif -//} -// -//void UnstructuredGridWrapper::addTriangle(double v1[3], double v2[3], double v3[3], int type[3]) -//{ -//#ifndef __unix__ -// this->writer->addTriangle(v1, v2, v3, type); -//#endif -//} -// -//void UnstructuredGridWrapper::addTriangle(Triangle t, int type[3]) -//{ -//#ifndef __unix__ -// double v1[3] = { t.v1.x, t.v1.y, t.v1.z }; -// double v2[3] = { t.v2.x, t.v2.y, t.v2.z }; -// double v3[3] = { t.v3.x, t.v3.y, t.v3.z }; -// -// this->writer->addTriangle(v1, v2, v3, type); -//#endif -//} -// -//void UnstructuredGridWrapper::addTriangles(std::vector<Triangle> triangles) -//{ -//#ifndef __unix__ -// for (int i = 0; i < triangles.size(); i++) { -// double v1[3] = { triangles[i].v1.x, triangles[i].v1.y, triangles[i].v1.z }; -// double v2[3] = { triangles[i].v2.x, triangles[i].v2.y, triangles[i].v2.z }; -// double v3[3] = { triangles[i].v3.x, triangles[i].v3.y, triangles[i].v3.z }; -// -// this->writer->addTriangle(v1, v2, v3, 0); -// } -//#endif -//} -// -//void UnstructuredGridWrapper::addGridPoints(double grid[], int nx, int ny, int nz) -//{ -//#ifndef __unix__ -// this->writer->addGridPoints(grid, nx, ny, nz); -//#endif -//} -// -//void UnstructuredGridWrapper::addGridPoint(int x, int y, int z, int type) -//{ -//#ifndef __unix__ -// this->writer->addGridPoint(x, y, z, type); -//#endif -//} -// -//void UnstructuredGridWrapper::addGridPoint(Vertex v, int type) -//{ -//#ifndef __unix__ -// this->writer->addGridPoint((int)v.x, (int)v.y, (int)v.z, type); -//#endif -//} -// -//void UnstructuredGridWrapper::writeUnstructuredGridToFile(std::string filename) -//{ -//#ifndef __unix__ -// std::string path = PATH_TO_DATA; -// filename = path + filename; -// this->writer->writeUnstructuredGridToFile(filename); -//#endif -//} -// -//void UnstructuredGridWrapper::displayUnstructuredGrid() -//{ -//#ifndef __unix__ -// this->writer->displayUnstructuredGrid(); -//#endif -//} -// -//void UnstructuredGridWrapper::displayUnstructuredGrid(std::string filename) -//{ -//#ifndef __unix__ -// std::string path = PATH_TO_DATA; -// filename = path + filename; -// this->writer->displayUnstructuredGrid(filename); -//#endif -//} -//template <typename T> -//void UnstructuredGridWrapper::writeBoxesToFile(std::vector<BoundingBox<T>> boxes, std::string name) -//{ -//#ifndef __unix__ -// UnstructuredGridWrapper writer; -// for (int i = 0; i < boxes.size(); i++) { -// writer.addBoundingBox(boxes[i], 0); -// } -// writer.writeUnstructuredGridToFile(name); -//#endif -//} -// -//template void UnstructuredGridWrapper::addBoundingBox(BoundingBox b, int type); diff --git a/src/gpu/GridGenerator/io/VTKWriterWrapper/UnstructuredGridWrapper.h b/src/gpu/GridGenerator/io/VTKWriterWrapper/UnstructuredGridWrapper.h deleted file mode 100644 index 6e13ba9ddfcb2ccce633f700ad04e0ec27642f4f..0000000000000000000000000000000000000000 --- a/src/gpu/GridGenerator/io/VTKWriterWrapper/UnstructuredGridWrapper.h +++ /dev/null @@ -1,53 +0,0 @@ -//#ifndef UnstructuredGridWrapper_H -//#define UnstructuredGridWrapper_H -// -// -//#include <string> -//#include <vector> -// -//class UnstructuredGridWriter; -//struct Triangle; -// -//template <class T> -//class BoundingBox; -//struct Vertex; -//class Grid; -// -//class GRIDGENERATOR_EXPORT UnstructuredGridWrapper -//{ -//public: -// UnstructuredGridWrapper(); -// ~UnstructuredGridWrapper(); -// -// void addBoundingBox(double boundingBox[6], int type); -// template <typename T> -// void addBoundingBox(BoundingBox<T> b, int type); -// void addVoxel(double node[3], double nodeNX[3], double nodeNY[3], double nodeNZ[3], -// double nodeNYNX[3], double nodeNZNY[3], double nodeNZNX[3], double nodeNZNYNX[3], int nodeTypes[8]); -// -// void addTriangle(double v1[3], double v2[3], double v3[3], int type[3]); -// void addTriangle(Triangle t, int type[3]); -// void addTriangles(std::vector<Triangle> triangles); -// -// void addGridPoints(double grid[], int nx, int ny, int nz); -// -// void addGridPoint(int x, int y, int z, int type); -// void addGridPoint(Vertex v, int type); -// -// void writeUnstructuredGridToFile(std::string filename); -// -// void displayUnstructuredGrid(); -// void displayUnstructuredGrid(std::string filename); -// -// template <typename T> -// static void writeBoxesToFile(std::vector<BoundingBox<T>>, std::string name); -// -//private: -//#ifndef __unix__ -// UnstructuredGridWriter *writer; -//#endif -// -//}; -// -// -//#endif diff --git a/src/gpu/GridGenerator/utilities/communication.h b/src/gpu/GridGenerator/utilities/communication.h index 23dbd0832cd17a0a22ac8bf6f58965bd9d6199c9..11a1085f6a21db1dfb26025514d8b3a9501fba5e 100644 --- a/src/gpu/GridGenerator/utilities/communication.h +++ b/src/gpu/GridGenerator/utilities/communication.h @@ -1,3 +1,35 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids 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. +// +// VirtualFluids 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 VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file Communication.h +//! \ingroup utilities +//! \author Soeren Peters, Stephan Lenz +//======================================================================================= #ifndef Communication_H #define Communication_H diff --git a/src/gpu/GridGenerator/utilities/cuda/CudaErrorCheck.cu b/src/gpu/GridGenerator/utilities/cuda/CudaErrorCheck.cu deleted file mode 100644 index 1d06e178332933a1dd88b1de7095de36601cd5ab..0000000000000000000000000000000000000000 --- a/src/gpu/GridGenerator/utilities/cuda/CudaErrorCheck.cu +++ /dev/null @@ -1,55 +0,0 @@ -#ifndef CudaErrorCheck_cu -#define CudaErrorCheck_cu - - -#include "cuda.h" -#include "cuda_runtime.h" -#include "device_launch_parameters.h" -#include <stdio.h> - -#define CUDA_ERROR_CHECK - -#define CudaSafeCall( err ) __cudaSafeCall( err, __FILE__, __LINE__ ) -#define CudaCheckError() __cudaCheckError( __FILE__, __LINE__ ) - -inline void __cudaSafeCall(cudaError err, const char *file, const int line) -{ -#ifdef CUDA_ERROR_CHECK - if (cudaSuccess != err) - { - fprintf(stderr, "cudaSafeCall() failed at %s:%i : %s\n", - file, line, cudaGetErrorString(err)); - exit(-1); - } -#endif - - return; -} - -inline void __cudaCheckError(const char *file, const int line) -{ -#ifdef CUDA_ERROR_CHECK - cudaError err = cudaGetLastError(); - if (cudaSuccess != err) - { - fprintf(stderr, "cudaCheckError() failed at %s\nline:%i : %s\n", - file, line, cudaGetErrorString(err)); - fprintf(stderr, "CudaError: %d\n", err); - exit(-1); - } - - // More careful checking. However, this will affect performance. - // Comment away if needed. - err = cudaDeviceSynchronize(); - if (cudaSuccess != err) - { - fprintf(stderr, "cudaCheckError() with sync failed at %s:%i : %s\n", - file, line, cudaGetErrorString(err)); - exit(-1); - } -#endif - - return; -} - -#endif diff --git a/src/gpu/GridGenerator/utilities/cuda/LaunchParameter.cu b/src/gpu/GridGenerator/utilities/cuda/LaunchParameter.cu deleted file mode 100644 index 8e7702ccde425f67a9755e4eebff82f63238ba11..0000000000000000000000000000000000000000 --- a/src/gpu/GridGenerator/utilities/cuda/LaunchParameter.cu +++ /dev/null @@ -1,50 +0,0 @@ -#include "LaunchParameter.cuh" - -#define MAXBLOCKSIZE 65535 - -CUDA_HOST LaunchParameter::LaunchParameter() -{ - -} - -CUDA_HOST LaunchParameter LaunchParameter::make_2D1D_launchParameter(int size, int threadDim) -{ - LaunchParameter para; - para.threads = dim3(threadDim, 1, 1); - - int blocks_ = (int)(ceil((size / ((real)threadDim)))); - para.blocks = dim3(blocks_, 1, 1); - - if (blocks_ > MAXBLOCKSIZE) { - blocks_ = (int)sqrt((double)blocks_); - para.blocks = dim3(blocks_, blocks_, 1); - } - return para; -} - -CUDA_HOST LaunchParameter LaunchParameter::make_1D1D_launchParameter(int size, int threadDim) -{ - LaunchParameter para; - para.threads = dim3(threadDim, 1, 1); - int blocks_ = (int)(ceil((real)size / (real)threadDim)); - para.blocks = dim3(blocks_, 1); - return para; -} - -DEVICE int LaunchParameter::getGlobalIdx_2D_1D() -{ - int blockId = blockIdx.y * gridDim.x + blockIdx.x; - int threadId = blockId * blockDim.x + threadIdx.x; - return threadId; -} - -DEVICE int LaunchParameter::getGlobalIdx_1D_1D() -{ - return blockIdx.x *blockDim.x + threadIdx.x; -} - -CUDA_HOST void LaunchParameter::print() const -{ - *logging::out << logging::Logger::INFO_INTERMEDIATE << "blocks: (" << blocks.x << ", " << blocks.y << ", " << blocks.z << ")" - << ", threads: (" << threads.x << ", " << threads.y << ", " << threads.z << ")\n"; -} diff --git a/src/gpu/GridGenerator/utilities/cuda/LaunchParameter.cuh b/src/gpu/GridGenerator/utilities/cuda/LaunchParameter.cuh deleted file mode 100644 index 20406fdb5f048d65a73dd55eec2dd3b31b11a76c..0000000000000000000000000000000000000000 --- a/src/gpu/GridGenerator/utilities/cuda/LaunchParameter.cuh +++ /dev/null @@ -1,29 +0,0 @@ -#ifndef kernelHelper_CUH -#define kernelHelper_CUH - -#include <cuda.h> -#include <cuda_runtime.h> -#include <device_launch_parameters.h> -#include <stdio.h> - -#include "global.h" - -class LaunchParameter -{ -public: - CUDA_HOST GRIDGENERATOR_EXPORT LaunchParameter(); - - CUDA_HOST GRIDGENERATOR_EXPORT static LaunchParameter make_2D1D_launchParameter(int size, int threadDim); - CUDA_HOST GRIDGENERATOR_EXPORT static LaunchParameter make_1D1D_launchParameter(int size, int threadDim); - - DEVICE static int getGlobalIdx_2D_1D(); - DEVICE static int getGlobalIdx_1D_1D(); - - CUDA_HOST void print() const; - - dim3 threads; - dim3 blocks; -}; - - -#endif diff --git a/src/gpu/GridGenerator/utilities/cuda/cudaDefines.h b/src/gpu/GridGenerator/utilities/cuda/cudaDefines.h deleted file mode 100644 index b20401ef493c16d413f41db91c42c102e63d7d2f..0000000000000000000000000000000000000000 --- a/src/gpu/GridGenerator/utilities/cuda/cudaDefines.h +++ /dev/null @@ -1,66 +0,0 @@ -#ifndef CUDA_DEFINES_H -#define CUDA_DEFINES_H - -#include <cuda_runtime.h> -#include <stdio.h> - -#define CUDA_HOST __host__ -#define DEVICE __device__ -#define GLOBAL __global__ -#define CONSTANT __constant__ - - -#define HOSTDEVICE CUDA_HOST DEVICE - -static void printCudaInformation(int i) { - cudaDeviceProp prop; - cudaGetDeviceProperties(&prop, i); - printf(" --- General Information for device %d ---\n", i); - printf("Name: %s\n", prop.name); - printf("Compute capability: %d.%d\n", prop.major, prop.minor); - printf("Clock rate: %d\n", prop.clockRate); - printf("Device copy overlap: "); - if (prop.deviceOverlap) - printf("Enabled\n"); - else - printf("Disabled\n"); - printf("Kernel execition timeout : "); - if (prop.kernelExecTimeoutEnabled) - printf("Enabled\n"); - else - printf("Disabled\n"); - printf(" --- Memory Information for device %d ---\n", i); - printf("Total global mem: %zu\n", prop.totalGlobalMem); - printf("Total constant Mem: %zu\n", prop.totalConstMem); - printf("Max mem pitch: %zu\n", prop.memPitch); - printf("Texture Alignment: %zu\n", prop.textureAlignment); - printf("max Texture 1D: %d\n", prop.maxTexture1D); - printf("max Texture 2D: %d, %d\n", prop.maxTexture2D[0], prop.maxTexture2D[1]); - printf("max Texture 3D: %d, %d, %d\n", prop.maxTexture3D[0], prop.maxTexture3D[1], prop.maxTexture3D[2]); - printf(" --- MP Information for device %d ---\n", i); - printf("Multiprocessor count: %d\n", - prop.multiProcessorCount); - printf("Shared mem per mp: %zd\n", prop.sharedMemPerBlock); - printf("Registers per mp: %d\n", prop.regsPerBlock); - printf("Threads in warp: %d\n", prop.warpSize); - printf("Max threads per block: %d\n", - prop.maxThreadsPerBlock); - printf("Max thread dimensions: (%d, %d, %d)\n", - prop.maxThreadsDim[0], prop.maxThreadsDim[1], - prop.maxThreadsDim[2]); - printf("Max grid dimensions: (%d, %d, %d)\n", - prop.maxGridSize[0], prop.maxGridSize[1], - prop.maxGridSize[2]); - printf(" --- -------------------------------- ---\n"); - printf("\n"); - - cudaSetDevice(i); - size_t free; - size_t total; - cudaMemGetInfo(&free, &total); - printf("Free: %zu Bytes, Total: %zu Bytes\n", free, total); - printf("Free: %zu MB, Total: %zu MB\n", free / 1000 / 1000, total / 1000 / 1000); - //cudaDeviceSetLimit(cudaLimitMallocHeapSize, free); -} - -#endif diff --git a/src/gpu/GridGenerator/utilities/cuda/cudaKernelCall.h b/src/gpu/GridGenerator/utilities/cuda/cudaKernelCall.h deleted file mode 100644 index 5911977428cda9acd5e2190a4b5c1579e08a211f..0000000000000000000000000000000000000000 --- a/src/gpu/GridGenerator/utilities/cuda/cudaKernelCall.h +++ /dev/null @@ -1,33 +0,0 @@ -#ifndef cudaKernelCall_H -#define cudaKernelCall_H - -#include "utilities/cuda/cudaDefines.h" -#include "utilities/cuda/CudaErrorCheck.cu" -#include "utilities/cuda/LaunchParameter.cuh" - -template<typename Functor, typename... TArgs> -CUDA_HOST float runKernel(Functor kernel, const LaunchParameter& para, TArgs... args) -{ - para.print(); - - cudaEvent_t start, stop; - cudaEventCreate(&start); - cudaEventCreate(&stop); - - cudaEventRecord(start, 0); - kernel << < para.blocks, para.threads >> >(args...); - CudaCheckError(); - cudaDeviceSynchronize(); - cudaEventRecord(stop, 0); - - cudaEventSynchronize(stop); - float elapsedTime; - cudaEventElapsedTime(&elapsedTime, start, stop); - cudaEventDestroy(start); - cudaEventDestroy(stop); - - return elapsedTime; -} - - -#endif diff --git a/src/gpu/GridGenerator/utilities/math/Math.cpp b/src/gpu/GridGenerator/utilities/math/Math.cpp new file mode 100644 index 0000000000000000000000000000000000000000..0f5f5cc8e05c9ce08a2854c0354371e18964610e --- /dev/null +++ b/src/gpu/GridGenerator/utilities/math/Math.cpp @@ -0,0 +1,83 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids 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. +// +// VirtualFluids 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 VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file Math.cpp +//! \ingroup utilities +//! \author Soeren Peters, Stephan Lenz +//======================================================================================= +#include "Math.h" + +#include <cmath> + + + +bool vf::Math::equal(const real& val1, const real& val2, real maxRelDiff) +{ + const real diff = std::fabs(val1 - val2); + const real val1_abs = std::fabs(val1); + const real val2_abs = std::fabs(val2); + + const real largest = (val2_abs > val1_abs) ? val2_abs : val1_abs; + if (diff <= largest * maxRelDiff) + return true; + return false; +} + +bool vf::Math::lessEqual(const real& val1, const real& val2, real maxRelDiff) +{ + if (val1 < val2 || equal(val1, val2, maxRelDiff)) + return true; + return false; +} + +bool vf::Math::greaterEqual(const real& val1, const real& val2, real maxRelDiff) +{ + if (val1 > val2 || equal(val1, val2, maxRelDiff)) + return true; + return false; +} + +real vf::Math::sqrtReal(const real& val) +{ +#ifdef VF_DOUBLE_ACCURACY + return sqrt(val); +#else + return sqrtf(val); +#endif +} + +real vf::Math::acosReal(const real& val) +{ +#ifdef VF_DOUBLE_ACCURACY + return acos(val); +#else + return acosf(val); +#endif +} + + diff --git a/src/gpu/GridGenerator/utilities/math/Math.cu b/src/gpu/GridGenerator/utilities/math/Math.cu deleted file mode 100644 index ef05bf52b5535682b65261d377f7efdb02af59e3..0000000000000000000000000000000000000000 --- a/src/gpu/GridGenerator/utilities/math/Math.cu +++ /dev/null @@ -1,51 +0,0 @@ -#include "Math.h" - -#include <cmath> - - - -HOSTDEVICE bool vf::Math::equal(const real& val1, const real& val2, real maxRelDiff) -{ - const real diff = std::fabs(val1 - val2); - const real val1_abs = std::fabs(val1); - const real val2_abs = std::fabs(val2); - - const real largest = (val2_abs > val1_abs) ? val2_abs : val1_abs; - if (diff <= largest * maxRelDiff) - return true; - return false; -} - -HOSTDEVICE bool vf::Math::lessEqual(const real& val1, const real& val2, real maxRelDiff) -{ - if (val1 < val2 || equal(val1, val2, maxRelDiff)) - return true; - return false; -} - -HOSTDEVICE bool vf::Math::greaterEqual(const real& val1, const real& val2, real maxRelDiff) -{ - if (val1 > val2 || equal(val1, val2, maxRelDiff)) - return true; - return false; -} - -HOSTDEVICE real vf::Math::sqrtReal(const real& val) -{ -#ifdef VF_DOUBLE_ACCURACY - return sqrt(val); -#else - return sqrtf(val); -#endif -} - -HOSTDEVICE real vf::Math::acosReal(const real& val) -{ -#ifdef VF_DOUBLE_ACCURACY - return acos(val); -#else - return acosf(val); -#endif -} - - diff --git a/src/gpu/GridGenerator/utilities/math/Math.h b/src/gpu/GridGenerator/utilities/math/Math.h index b47f03b07fbcd04cbd2e5337882aa197e33ca7b5..95b01e77561c8e9965ed64604395eda8ef4cc2f1 100644 --- a/src/gpu/GridGenerator/utilities/math/Math.h +++ b/src/gpu/GridGenerator/utilities/math/Math.h @@ -1,3 +1,35 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids 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. +// +// VirtualFluids 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 VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file Math.h +//! \ingroup utilities +//! \author Soeren Peters, Stephan Lenz +//======================================================================================= #ifndef CudaMath_H #define CudaMath_H @@ -5,8 +37,6 @@ #include "global.h" -#include "utilities/cuda/cudaDefines.h" - #define EPSILON FLT_EPSILON namespace vf @@ -14,14 +44,14 @@ namespace vf class GRIDGENERATOR_EXPORT Math { public: - HOSTDEVICE static bool equal(const real& val1, const real& val2, real maxRelDiff = EPSILON); - HOSTDEVICE static bool lessEqual(const real& val1, const real& val2, real maxRelDiff = EPSILON); - HOSTDEVICE static bool greaterEqual(const real& val1, const real& val2, real maxRelDiff = EPSILON); + static bool equal(const real& val1, const real& val2, real maxRelDiff = EPSILON); + static bool lessEqual(const real& val1, const real& val2, real maxRelDiff = EPSILON); + static bool greaterEqual(const real& val1, const real& val2, real maxRelDiff = EPSILON); - HOSTDEVICE static real sqrtReal(const real& val); - HOSTDEVICE static real acosReal(const real& val); + static real sqrtReal(const real& val); + static real acosReal(const real& val); - HOSTDEVICE static real getDecimalPart(real number) { + static real getDecimalPart(real number) { return number - real(int(number)); } }; diff --git a/src/gpu/GridGenerator/utilities/transformator/ArrowTransformator.cpp b/src/gpu/GridGenerator/utilities/transformator/ArrowTransformator.cpp index 7ec055c5973b1edbdd93cf912cfc17f44ab923ea..74a33c31b4b87edd736e9beea783075906772829 100644 --- a/src/gpu/GridGenerator/utilities/transformator/ArrowTransformator.cpp +++ b/src/gpu/GridGenerator/utilities/transformator/ArrowTransformator.cpp @@ -1,3 +1,35 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids 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. +// +// VirtualFluids 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 VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file ArrowTransformator.h +//! \ingroup utilities +//! \author Soeren Peters, Stephan Lenz +//======================================================================================= #include "ArrowTransformator.h" #include "utilities/transformator/TransformatorImp.h" diff --git a/src/gpu/GridGenerator/utilities/transformator/ArrowTransformator.h b/src/gpu/GridGenerator/utilities/transformator/ArrowTransformator.h index 186b66838c3aa7398a7fc8a494c3f41372c30727..ad80114945c9e9be4cc38afa46c493edc1c55b66 100644 --- a/src/gpu/GridGenerator/utilities/transformator/ArrowTransformator.h +++ b/src/gpu/GridGenerator/utilities/transformator/ArrowTransformator.h @@ -1,3 +1,35 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids 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. +// +// VirtualFluids 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 VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file ArrowTransformator.h +//! \ingroup utilities +//! \author Soeren Peters, Stephan Lenz +//======================================================================================= #ifndef ArrowTransformator_h #define ArrowTransformator_h diff --git a/src/gpu/GridGenerator/utilities/transformator/Transformator.cpp b/src/gpu/GridGenerator/utilities/transformator/Transformator.cpp index 4f59dc64856ac2e1023363ff6b6a1d1063893fe8..7e854c4baa21bb6d59834b2e099c5857389fd50c 100644 --- a/src/gpu/GridGenerator/utilities/transformator/Transformator.cpp +++ b/src/gpu/GridGenerator/utilities/transformator/Transformator.cpp @@ -1,3 +1,35 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids 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. +// +// VirtualFluids 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 VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file Transformator.cpp +//! \ingroup utilities +//! \author Soeren Peters, Stephan Lenz +//======================================================================================= #include "Transformator.h" #include "utilities/transformator/TransformatorImp.h" diff --git a/src/gpu/GridGenerator/utilities/transformator/Transformator.h b/src/gpu/GridGenerator/utilities/transformator/Transformator.h index 0f092ddb90ce0ea60aed6b17edc415596669422c..9510e818f3467bc4346fc9e8ece58a83c139e11d 100644 --- a/src/gpu/GridGenerator/utilities/transformator/Transformator.h +++ b/src/gpu/GridGenerator/utilities/transformator/Transformator.h @@ -1,3 +1,35 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids 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. +// +// VirtualFluids 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 VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file Transformator.h +//! \ingroup utilities +//! \author Soeren Peters, Stephan Lenz +//======================================================================================= #ifndef Transformator_h #define Transformator_h diff --git a/src/gpu/GridGenerator/utilities/transformator/TransformatorImp.cpp b/src/gpu/GridGenerator/utilities/transformator/TransformatorImp.cpp index 224dda4971cac288e9f354b772d42100c5cf4284..3c7a3b675104eabab89c59d481797ff41b2033c8 100644 --- a/src/gpu/GridGenerator/utilities/transformator/TransformatorImp.cpp +++ b/src/gpu/GridGenerator/utilities/transformator/TransformatorImp.cpp @@ -1,3 +1,35 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids 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. +// +// VirtualFluids 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 VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file TransformatorImp.cpp +//! \ingroup utilities +//! \author Soeren Peters, Stephan Lenz +//======================================================================================= #include "TransformatorImp.h" #include <memory> diff --git a/src/gpu/GridGenerator/utilities/transformator/TransformatorImp.h b/src/gpu/GridGenerator/utilities/transformator/TransformatorImp.h index 626abacaf1c75c406c7f8fbe830f86fa0d679adf..81ba5a25badc879aa501256ed67eed0a4b39961c 100644 --- a/src/gpu/GridGenerator/utilities/transformator/TransformatorImp.h +++ b/src/gpu/GridGenerator/utilities/transformator/TransformatorImp.h @@ -1,3 +1,35 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids 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. +// +// VirtualFluids 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 VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file TransformatorImp.h +//! \ingroup utilities +//! \author Soeren Peters, Stephan Lenz +//======================================================================================= #ifndef TransformatorImp_h #define TransformatorImp_h diff --git a/src/gpu/VirtualFluids_GPU/CMakeLists.txt b/src/gpu/VirtualFluids_GPU/CMakeLists.txt index 14bf4f6641f9b874788d3674b11fa6ca135f7564..53707fa381228e4d2ca380e3ba16f5bf0e5f2d38 100644 --- a/src/gpu/VirtualFluids_GPU/CMakeLists.txt +++ b/src/gpu/VirtualFluids_GPU/CMakeLists.txt @@ -5,14 +5,13 @@ if(MSVC) set(additional_libraries ws2_32 Traffic) # ws_32 throws an error on Phoenix endif() -vf_add_library(PUBLIC_LINK basics lbmCuda PRIVATE_LINK ${additional_libraries} GridGenerator MPI::MPI_CXX) - +vf_add_library(PUBLIC_LINK basics lbmCuda PRIVATE_LINK ${additional_libraries} GridGenerator MPI::MPI_CXX vf_cuda) #SET(TPN_WIN32 "/EHsc") #https://stackoverflow.com/questions/6832666/lnk2019-when-including-asio-headers-solution-generated-with-cmake #https://stackoverflow.com/questions/27442885/syntax-error-with-stdnumeric-limitsmax -set_target_properties(VirtualFluids_GPU PROPERTIES CUDA_SEPARABLE_COMPILATION ON) +set_target_properties(VirtualFluids_GPU PROPERTIES CUDA_SEPARABLE_COMPILATION ON POSITION_INDEPENDENT_CODE ON) vf_add_tests() diff --git a/src/gpu/VirtualFluids_GPU/Calculation/UpdateGrid27.cpp b/src/gpu/VirtualFluids_GPU/Calculation/UpdateGrid27.cpp index cd53553174ee74de2b3ff32b1ff0356ec79cc436..318d6522fb49172c2619c5cbb6aa92751a1b759e 100644 --- a/src/gpu/VirtualFluids_GPU/Calculation/UpdateGrid27.cpp +++ b/src/gpu/VirtualFluids_GPU/Calculation/UpdateGrid27.cpp @@ -1,4 +1,4 @@ -#include "Calculation/UpdateGrid27.h" +#include "UpdateGrid27.h" #include <cuda_runtime.h> #include <helper_cuda.h> #include "Calculation/DragLift.h" @@ -8,6 +8,7 @@ #include "Communication/ExchangeData27.h" #include "Kernel/Kernel.h" #include "Parameter/CudaStreamManager.h" +#include "GPU/TurbulentViscosity.h" void UpdateGrid27::updateGrid(int level, unsigned int t) { @@ -35,6 +36,9 @@ void UpdateGrid27::updateGrid(int level, unsigned int t) if (para->getUseWale()) calcMacroscopicQuantities(para.get(), level); + if (para->getUseTurbulentViscosity()) + calcTurbulentViscosity(para, level); + ////////////////////////////////////////////////////////////////////////// preCollisionBC(para.get(), cudaManager.get(), level, t); @@ -44,6 +48,10 @@ void UpdateGrid27::updateGrid(int level, unsigned int t) { (this->*refinementAndExchange)(level); } + + interactWithActuators(para, cudaManager, level, t); + + interactWithProbes(para, cudaManager, level, t); } void UpdateGrid27::refinementAndExchange_noRefinementAndExchange(int level) {} @@ -299,8 +307,6 @@ void prepareExchangeMultiGPUAfterFtoC(Parameter *para, int level, int streamInde void exchangeMultiGPU(Parameter *para, vf::gpu::Communicator *comm, CudaMemoryManager *cudaManager, int level, int streamIndex) { - // St. Lenz: exchange for post-collision data and pre-collision data are identical! - ////////////////////////////////////////////////////////////////////////// // 3D domain decomposition exchangeCollDataXGPU27AllNodes(para, comm, cudaManager, level, streamIndex); @@ -481,7 +487,6 @@ void postCollisionBC(Parameter* para, int level, unsigned int t) ////////////////////////////////////////////////////////////////////////// // S L I P ////////////////////////////////////////////////////////////////////////// - if (para->getParD(level)->kSlipQ > 0) { //QSlipDev27( para->getParD(level)->numberofthreads, para->getParD(level)->d0SP.f[0], para->getParD(level)->QSlip.k, @@ -493,10 +498,46 @@ void postCollisionBC(Parameter* para, int level, unsigned int t) QSlipDevComp27( para->getParD(level)->numberofthreads, para->getParD(level)->d0SP.f[0], para->getParD(level)->QSlip.k, para->getParD(level)->QSlip.q27[0], para->getParD(level)->kSlipQ, para->getParD(level)->omega, para->getParD(level)->neighborX_SP, para->getParD(level)->neighborY_SP, para->getParD(level)->neighborZ_SP, + para->getParD(level)->turbViscosity, para->getUseTurbulentViscosity(), para->getParD(level)->size_Mat_SP, para->getParD(level)->evenOrOdd); getLastCudaError("QSlipDev27 execution failed"); } + ////////////////////////////////////////////////////////////////////////// + // S T R E S S (wall model) + ////////////////////////////////////////////////////////////////////////// + if (para->getParD(level)->kStressQ > 0) + { + // QStressDevComp27( para->getParD(level)->numberofthreads, para->getParD(level)->d0SP.f[0], + // para->getParD(level)->QStress.k, para->getParD(level)->QStress.kN, + // para->getParD(level)->QStress.q27[0], para->getParD(level)->kStressQ, + // para->getParD(level)->omega, para->getParD(level)->turbViscosity, + // para->getParD(level)->vx_SP, para->getParD(level)->vy_SP, para->getParD(level)->vy_SP, + // para->getParD(level)->QStress.normalX, para->getParD(level)->QStress.normalY, para->getParD(level)->QStress.normalZ, + // para->getParD(level)->QStress.Vx, para->getParD(level)->QStress.Vy, para->getParD(level)->QStress.Vz, + // para->getParD(level)->QStress.Vx1, para->getParD(level)->QStress.Vy1, para->getParD(level)->QStress.Vz1, + // para->getParD(level)->wallModel.samplingOffset, para->getParD(level)->wallModel.z0, + // para->getHasWallModelMonitor(), para->getParD(level)->wallModel.u_star, + // para->getParD(level)->wallModel.Fx, para->getParD(level)->wallModel.Fy, para->getParD(level)->wallModel.Fz, + // para->getParD(level)->neighborX_SP, para->getParD(level)->neighborY_SP, para->getParD(level)->neighborZ_SP, + // para->getParD(level)->size_Mat_SP, para->getParD(level)->evenOrOdd); + // getLastCudaError("QStressDevComp27 execution failed"); + + BBStressDev27( para->getParD(level)->numberofthreads, para->getParD(level)->d0SP.f[0], + para->getParD(level)->QStress.k, para->getParD(level)->QStress.kN, + para->getParD(level)->QStress.q27[0], para->getParD(level)->kStressQ, + para->getParD(level)->vx_SP, para->getParD(level)->vy_SP, para->getParD(level)->vy_SP, + para->getParD(level)->QStress.normalX, para->getParD(level)->QStress.normalY, para->getParD(level)->QStress.normalZ, + para->getParD(level)->QStress.Vx, para->getParD(level)->QStress.Vy, para->getParD(level)->QStress.Vz, + para->getParD(level)->QStress.Vx1, para->getParD(level)->QStress.Vy1, para->getParD(level)->QStress.Vz1, + para->getParD(level)->wallModel.samplingOffset, para->getParD(level)->wallModel.z0, + para->getHasWallModelMonitor(), para->getParD(level)->wallModel.u_star, + para->getParD(level)->wallModel.Fx, para->getParD(level)->wallModel.Fy, para->getParD(level)->wallModel.Fz, + para->getParD(level)->neighborX_SP, para->getParD(level)->neighborY_SP, para->getParD(level)->neighborZ_SP, + para->getParD(level)->size_Mat_SP, para->getParD(level)->evenOrOdd); + getLastCudaError("BBStressDevice27 execution failed"); + } + ////////////////////////////////////////////////////////////////////////// // G E O M E T R Y ////////////////////////////////////////////////////////////////////////// @@ -1583,4 +1624,26 @@ void UpdateGrid27::chooseFunctionForRefinementAndExchange() this->refinementAndExchange = &UpdateGrid27::refinementAndExchange_noStreams_completeExchange; std::cout << "refinementAndExchange_noStreams_completeExchange()" << std::endl; } +} + +void interactWithActuators(Parameter* para, CudaMemoryManager* cudaManager, int level, unsigned int t) +{ + for( SPtr<PreCollisionInteractor> actuator: para->getActuators() ) + { + actuator->interact(para, cudaManager, level, t); + } +} + +void interactWithProbes(Parameter* para, CudaMemoryManager* cudaManager, int level, unsigned int t) +{ + for( SPtr<PreCollisionInteractor> probe: para->getProbes() ) + { + probe->interact(para, cudaManager, level, t); + } +} + +void calcTurbulentViscosity(Parameter* para, int level) +{ + if(para->getUseAMD()) + calcTurbulentViscosityAMD(para, level); } \ No newline at end of file diff --git a/src/gpu/VirtualFluids_GPU/Calculation/UpdateGrid27.h b/src/gpu/VirtualFluids_GPU/Calculation/UpdateGrid27.h index 086b39fcb2745cbd66467d1316c25482dd2ab323..ec96c905bce7bd99a5fda8f75a2303bc84362e16 100644 --- a/src/gpu/VirtualFluids_GPU/Calculation/UpdateGrid27.h +++ b/src/gpu/VirtualFluids_GPU/Calculation/UpdateGrid27.h @@ -84,4 +84,10 @@ extern "C" void coarseToFineWithStream(Parameter *para, int level, uint *iCellCF +extern "C" void calcTurbulentViscosity(Parameter* para, int level); + +extern "C" void interactWithActuators(Parameter* para, CudaMemoryManager* cudaManager, int level, unsigned int t); + +extern "C" void interactWithProbes(Parameter* para, CudaMemoryManager* cudaManager, int level, unsigned int t); + #endif diff --git a/src/gpu/VirtualFluids_GPU/Communication/Communicator.cpp b/src/gpu/VirtualFluids_GPU/Communication/Communicator.cpp index 2364070757ff5fbf65ffef6ad59365e669633b36..c347be4c91c7779a30a0a0fce71e3873a6a5d4ad 100644 --- a/src/gpu/VirtualFluids_GPU/Communication/Communicator.cpp +++ b/src/gpu/VirtualFluids_GPU/Communication/Communicator.cpp @@ -1,9 +1,9 @@ #include "Communicator.h" + #include <mpi.h> -#include <stdio.h> -#include <stdlib.h> #include <vector> -#include <string.h> + +#include <logger/Logger.h> #if defined (_WIN32) || defined (_WIN64) #include <Winsock2.h> @@ -12,13 +12,19 @@ #endif //lib for windows Ws2_32.lib -namespace vf -{ -namespace gpu +namespace vf::gpu { + Communicator::Communicator() { + int mpiInitialized = 0; // false + MPI_Initialized(&mpiInitialized); + if (!mpiInitialized) { + MPI_Init(NULL, NULL); + VF_LOG_TRACE("vf::gpu::Communicator(): MPI_Init"); + } + MPI_Comm_rank(MPI_COMM_WORLD, &PID); MPI_Comm_size(MPI_COMM_WORLD, &numprocs); @@ -29,21 +35,25 @@ Communicator::Communicator() // Get my position in this communicator, and my neighbors MPI_Cart_shift(comm1d, 0, 1, &nbrbottom, &nbrtop); } -// Crap by Martin Sch. -Communicator::Communicator(const int numberOfProcs) + +Communicator::~Communicator() { - MPI_Comm_rank(MPI_COMM_WORLD, &PID); - MPI_Comm_size(MPI_COMM_WORLD, &numprocs); - commGPU = MPI_COMM_WORLD; - requestGPU.resize(0); - rcount = 0; + // proof if MPI is finalized + int _mpiFinalized = 0; // false + MPI_Finalized(&_mpiFinalized); + if (!_mpiFinalized) { + MPI_Finalize(); + VF_LOG_TRACE("vf::gpu::~Communicator(): MPI_Finalize"); + } } -Communicator *Communicator::instanz = 0; -Communicator *Communicator::getInstanz() + + +// C++11 thread safe singelton implementation: +// https://stackoverflow.com/questions/1661529/is-meyers-implementation-of-the-singleton-pattern-thread-safe +Communicator& Communicator::getInstance() { - if (instanz == 0) - instanz = new Communicator(0); - return instanz; + static Communicator comm; + return comm; } void Communicator::exchngBottomToTop(float *sbuf, float *rbuf, int count) @@ -189,7 +199,7 @@ int Communicator::mapCudaDevice(const int &rank, const int &size, const std::vec counter++; } if (counter >= maxdev) { - fprintf(stderr, "More processes than GPUs!\n"); + VF_LOG_CRITICAL("More processes than GPUs!"); exit(1); } map[i] = devices[counter]; @@ -198,7 +208,7 @@ int Communicator::mapCudaDevice(const int &rank, const int &size, const std::vec MPI_Scatter(map, 1, MPI_UNSIGNED, &device, 1, MPI_UNSIGNED, 0, MPI_COMM_WORLD); - printf("Rank: %d runs on host: %s with GPU: %d\n", rank, hostname, device); + VF_LOG_INFO("Rank: {} runs on host: {} with GPU: {}", rank, hostname, device); free(map); free(host); @@ -217,9 +227,6 @@ std::vector<double> Communicator::gatherNUPS(double processNups) return std::vector<double>(); } -} // namespace GPU -} // namespace VF - void vf::gpu::Communicator::exchangeIndices(uint *rbuf, int count_r, int nb_rank_r, uint *sbuf, int count_s, int nb_rank_s) { @@ -231,4 +238,6 @@ void vf::gpu::Communicator::exchangeIndices(uint *rbuf, int count_r, int nb_rank //printf("exchangeIndices PID: %i, sendUintGPU: nb_rank_send: %i", this->getPID(), nb_rank_s); //fflush(stdout); MPI_Wait(&recv_request, MPI_STATUSES_IGNORE); -} \ No newline at end of file +} + +} // namespace vf::gpu diff --git a/src/gpu/VirtualFluids_GPU/Communication/Communicator.h b/src/gpu/VirtualFluids_GPU/Communication/Communicator.h index afa954cd7fc1993c543c2b4536c95c7e3ee25ca7..3308c6b3ae964144446777c62781c2c2ad3049cb 100644 --- a/src/gpu/VirtualFluids_GPU/Communication/Communicator.h +++ b/src/gpu/VirtualFluids_GPU/Communication/Communicator.h @@ -3,14 +3,11 @@ #include <vector> - - - #include <mpi.h> #include "VirtualFluids_GPU_export.h" -#include "LBM/LB.h" +#include <basics/Core/DataTypes.h> ////////////////////////////////// #ifdef VF_DOUBLE_ACCURACY @@ -21,17 +18,17 @@ ////////////////////////////////// -namespace vf -{ -namespace gpu +namespace vf::gpu { class VIRTUALFLUIDS_GPU_EXPORT Communicator { public: - static Communicator* getInstanz(); - static Communicator* getInstanz(const int numberOfProcs); + static Communicator& getInstance(); + Communicator(const Communicator&) = delete; + Communicator& operator=(const Communicator&) = delete; + void exchngBottomToTop(float* sbuf, float* rbuf, int count); void exchngTopToBottom(float* sbuf, float* rbuf, int count); void waitAll(); @@ -63,28 +60,23 @@ public: std::vector<double> gatherNUPS(double processNups); ////////////////////////////////////////////////////////////////////////// void exchangeIndices(uint *rbuf, int count_r, int nb_rank_r, uint *sbuf, int count_s, int nb_rank_s); - -protected: private: - static Communicator* instanz; - int numprocs, PID; - int nbrbottom, nbrtop; - MPI_Comm comm1d, commGPU; - MPI_Status status[4]; - MPI_Request request[4]; - ////////////////////////////////////////////////////////////////////////// - std::vector<MPI_Request> requestGPU; - int rcount; - ////////////////////////////////////////////////////////////////////////// - double starttime; - double endtime; - Communicator(); - Communicator(const int numberOfProcs); - Communicator(const Communicator&); + int numprocs, PID; + int nbrbottom, nbrtop; + MPI_Comm comm1d, commGPU; + MPI_Status status[4]; + MPI_Request request[4]; + ////////////////////////////////////////////////////////////////////////// + std::vector<MPI_Request> requestGPU; + int rcount; + ////////////////////////////////////////////////////////////////////////// + double starttime; + double endtime; + Communicator(); + ~Communicator(); }; -} // namespace GPU -} // namespace VF +} #endif diff --git a/src/gpu/VirtualFluids_GPU/Communication/ExchangeData27.cpp b/src/gpu/VirtualFluids_GPU/Communication/ExchangeData27.cpp index d1bedf5127470ca969b649ca8d73339400ff6aaa..b6ce0071f9254ecabde0b05bbdcf4b37c368c11f 100644 --- a/src/gpu/VirtualFluids_GPU/Communication/ExchangeData27.cpp +++ b/src/gpu/VirtualFluids_GPU/Communication/ExchangeData27.cpp @@ -412,7 +412,7 @@ void exchangeCollDataZGPU27(Parameter *para, vf::gpu::Communicator *comm, CudaMe //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //1D domain decomposition //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -void exchangePreCollDataGPU27(Parameter* para, vf::gpu::Communicator* comm, CudaMemoryManager* cudaManager, int level) +void exchangePreCollDataGPU27(Parameter* para, vf::gpu::Communicator& comm, CudaMemoryManager* cudaManager, int level) { for (unsigned int i = 0; i < (unsigned int)(para->getNumberOfProcessNeighbors(level, "send")); i++) { @@ -457,7 +457,7 @@ void exchangePreCollDataGPU27(Parameter* para, vf::gpu::Communicator* comm, Cuda //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -void exchangePostCollDataGPU27(Parameter* para, vf::gpu::Communicator* comm, CudaMemoryManager* cudaManager, int level) +void exchangePostCollDataGPU27(Parameter* para, vf::gpu::Communicator& comm, CudaMemoryManager* cudaManager, int level) { for (unsigned int i = 0; i < (unsigned int)(para->getNumberOfProcessNeighbors(level, "send")); i++) { @@ -496,57 +496,9 @@ void exchangePostCollDataGPU27(Parameter* para, vf::gpu::Communicator* comm, Cud ////////////////////////////////////////////////////////////////////////// } } -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - - ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -////3D domain decomposition -////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -//// X -////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -//void exchangePreCollDataXGPU27(Parameter* para, vf::gpu::Communicator* comm, int level) -//{ -// for (unsigned int i = 0; i < (unsigned int)(para->getNumberOfProcessNeighborsX(level, "send")); i++) -// { -// ////////////////////////////////////////////////////////////////////////// -// GetSendFsPreDev27(para->getParD(level)->d0SP.f[0], -// para->getParD(level)->sendProcessNeighborX[i].f[0], -// para->getParD(level)->sendProcessNeighborX[i].index, -// para->getParD(level)->sendProcessNeighborX[i].numberOfNodes, -// para->getParD(level)->neighborX_SP, -// para->getParD(level)->neighborY_SP, -// para->getParD(level)->neighborZ_SP, -// para->getParD(level)->size_Mat_SP, -// para->getParD(level)->evenOrOdd, -// para->getParD(level)->numberofthreads); -// ////////////////////////////////////////////////////////////////////////// -// para->cudaCopyProcessNeighborXFsDH(level, i); -// ////////////////////////////////////////////////////////////////////////// -// comm->exchngDataGPU(para->getParH(level)->sendProcessNeighborX[i].f[0], -// para->getParH(level)->sendProcessNeighborX[i].numberOfFs, -// para->getParH(level)->recvProcessNeighborX[i].f[0], -// para->getParH(level)->recvProcessNeighborX[i].numberOfFs, -// para->getParH(level)->sendProcessNeighborX[i].rankNeighbor); -// ////////////////////////////////////////////////////////////////////////// -// para->cudaCopyProcessNeighborXFsHD(level, i); -// ////////////////////////////////////////////////////////////////////////// -// SetRecvFsPreDev27(para->getParD(level)->d0SP.f[0], -// para->getParD(level)->recvProcessNeighborX[i].f[0], -// para->getParD(level)->recvProcessNeighborX[i].index, -// para->getParD(level)->recvProcessNeighborX[i].numberOfNodes, -// para->getParD(level)->neighborX_SP, -// para->getParD(level)->neighborY_SP, -// para->getParD(level)->neighborZ_SP, -// para->getParD(level)->size_Mat_SP, -// para->getParD(level)->evenOrOdd, -// para->getParD(level)->numberofthreads); -// ////////////////////////////////////////////////////////////////////////// -// } -//} -////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -//void exchangePostCollDataXGPU27(Parameter* para, vf::gpu::Communicator* comm, int level) +//void exchangePostCollDataXGPU27(Parameter* para, vf::gpu::Communicator& comm, int level) //{ // for (unsigned int i = 0; i < (unsigned int)(para->getNumberOfProcessNeighborsX(level, "send")); i++) // { @@ -593,7 +545,7 @@ void exchangePostCollDataGPU27(Parameter* para, vf::gpu::Communicator* comm, Cud ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //// Y ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -//void exchangePreCollDataYGPU27(Parameter* para, vf::gpu::Communicator* comm, int level) +//void exchangePreCollDataYGPU27(Parameter* para, vf::gpu::Communicator& comm, int level) //{ // for (unsigned int i = 0; i < (unsigned int)(para->getNumberOfProcessNeighborsY(level, "send")); i++) // { @@ -633,7 +585,7 @@ void exchangePostCollDataGPU27(Parameter* para, vf::gpu::Communicator* comm, Cud // } //} ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -//void exchangePostCollDataYGPU27(Parameter* para, vf::gpu::Communicator* comm, int level) +//void exchangePostCollDataYGPU27(Parameter* para, vf::gpu::Communicator& comm, int level) //{ // for (unsigned int i = 0; i < (unsigned int)(para->getNumberOfProcessNeighborsY(level, "send")); i++) // { @@ -680,7 +632,7 @@ void exchangePostCollDataGPU27(Parameter* para, vf::gpu::Communicator* comm, Cud ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //// Z ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -//void exchangePreCollDataZGPU27(Parameter* para, vf::gpu::Communicator* comm, int level) +//void exchangePreCollDataZGPU27(Parameter* para, vf::gpu::Communicator& comm, int level) //{ // for (unsigned int i = 0; i < (unsigned int)(para->getNumberOfProcessNeighborsZ(level, "send")); i++) // { @@ -720,7 +672,7 @@ void exchangePostCollDataGPU27(Parameter* para, vf::gpu::Communicator* comm, Cud // } //} ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -//void exchangePostCollDataZGPU27(Parameter* para, vf::gpu::Communicator* comm, int level) +//void exchangePostCollDataZGPU27(Parameter* para, vf::gpu::Communicator& comm, int level) //{ // for (unsigned int i = 0; i < (unsigned int)(para->getNumberOfProcessNeighborsZ(level, "send")); i++) // { @@ -815,7 +767,7 @@ void exchangePostCollDataGPU27(Parameter* para, vf::gpu::Communicator* comm, Cud //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // X //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -void exchangePreCollDataADXGPU27(Parameter* para, vf::gpu::Communicator* comm, CudaMemoryManager* cudaManager, int level) +void exchangePreCollDataADXGPU27(Parameter* para, vf::gpu::Communicator& comm, CudaMemoryManager* cudaManager, int level) { /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //copy Device to Host @@ -896,7 +848,7 @@ void exchangePreCollDataADXGPU27(Parameter* para, vf::gpu::Communicator* comm, C /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// } //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -void exchangePostCollDataADXGPU27(Parameter* para, vf::gpu::Communicator* comm, CudaMemoryManager* cudaManager, int level) +void exchangePostCollDataADXGPU27(Parameter* para, vf::gpu::Communicator& comm, CudaMemoryManager* cudaManager, int level) { /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //copy Device to Host @@ -984,7 +936,7 @@ void exchangePostCollDataADXGPU27(Parameter* para, vf::gpu::Communicator* comm, //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Y //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -void exchangePreCollDataADYGPU27(Parameter* para, vf::gpu::Communicator* comm, CudaMemoryManager* cudaManager, int level) +void exchangePreCollDataADYGPU27(Parameter* para, vf::gpu::Communicator& comm, CudaMemoryManager* cudaManager, int level) { /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //copy Device to Host @@ -1065,7 +1017,7 @@ void exchangePreCollDataADYGPU27(Parameter* para, vf::gpu::Communicator* comm, C /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// } //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -void exchangePostCollDataADYGPU27(Parameter* para, vf::gpu::Communicator* comm, CudaMemoryManager* cudaManager, int level) +void exchangePostCollDataADYGPU27(Parameter* para, vf::gpu::Communicator& comm, CudaMemoryManager* cudaManager, int level) { /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //copy Device to Host @@ -1153,7 +1105,7 @@ void exchangePostCollDataADYGPU27(Parameter* para, vf::gpu::Communicator* comm, //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Z //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -void exchangePreCollDataADZGPU27(Parameter* para, vf::gpu::Communicator* comm, CudaMemoryManager* cudaManager, int level) +void exchangePreCollDataADZGPU27(Parameter* para, vf::gpu::Communicator& comm, CudaMemoryManager* cudaManager, int level) { /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //copy Device to Host @@ -1234,7 +1186,7 @@ void exchangePreCollDataADZGPU27(Parameter* para, vf::gpu::Communicator* comm, C /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// } //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -void exchangePostCollDataADZGPU27(Parameter* para, vf::gpu::Communicator* comm, CudaMemoryManager* cudaManager, int level) +void exchangePostCollDataADZGPU27(Parameter* para, vf::gpu::Communicator& comm, CudaMemoryManager* cudaManager, int level) { /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //copy Device to Host @@ -1369,7 +1321,7 @@ void exchangePostCollDataADZGPU27(Parameter* para, vf::gpu::Communicator* comm, //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // X //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -void exchangeCollDataF3XGPU(Parameter* para, vf::gpu::Communicator* comm, CudaMemoryManager* cudaManager, int level) +void exchangeCollDataF3XGPU(Parameter* para, vf::gpu::Communicator& comm, CudaMemoryManager* cudaManager, int level) { /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //copy Device to Host @@ -1447,7 +1399,7 @@ void exchangeCollDataF3XGPU(Parameter* para, vf::gpu::Communicator* comm, CudaMe //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Y //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -void exchangeCollDataF3YGPU(Parameter* para, vf::gpu::Communicator* comm, CudaMemoryManager* cudaManager, int level) +void exchangeCollDataF3YGPU(Parameter* para, vf::gpu::Communicator& comm, CudaMemoryManager* cudaManager, int level) { /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //copy Device to Host @@ -1525,7 +1477,7 @@ void exchangeCollDataF3YGPU(Parameter* para, vf::gpu::Communicator* comm, CudaMe //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Z //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -void exchangeCollDataF3ZGPU(Parameter* para, vf::gpu::Communicator* comm, CudaMemoryManager* cudaManager, int level) +void exchangeCollDataF3ZGPU(Parameter* para, vf::gpu::Communicator& comm, CudaMemoryManager* cudaManager, int level) { /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //copy Device to Host @@ -1595,24 +1547,4 @@ void exchangeCollDataF3ZGPU(Parameter* para, vf::gpu::Communicator* comm, CudaMe } /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// } -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - - - - - - - - - - - - - - - - - - - +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// \ No newline at end of file diff --git a/src/gpu/VirtualFluids_GPU/DataStructureInitializer/GridProvider.cpp b/src/gpu/VirtualFluids_GPU/DataStructureInitializer/GridProvider.cpp index c3c9bc3d8064dab29a21cb6e814425ddc2020529..f914d71bb0a1a83e8fcd5d7ad2d8cd153b9403b0 100644 --- a/src/gpu/VirtualFluids_GPU/DataStructureInitializer/GridProvider.cpp +++ b/src/gpu/VirtualFluids_GPU/DataStructureInitializer/GridProvider.cpp @@ -92,6 +92,12 @@ void GridProvider::setInitalNodeValues(const int numberOfNodes, const int level) para->getParH(level)->gDyvz[j] = 0.0f; para->getParH(level)->gDzvz[j] = 0.0f; } + + if (para->getIsBodyForce()) { + para->getParH(level)->forceX_SP[j] = 0.0f; + para->getParH(level)->forceY_SP[j] = 0.0f; + para->getParH(level)->forceZ_SP[j] = 0.0f; + } } diff --git a/src/gpu/VirtualFluids_GPU/DataStructureInitializer/GridProvider.h b/src/gpu/VirtualFluids_GPU/DataStructureInitializer/GridProvider.h index 7ffe404cf50f2fdddecf7594da75d05595db19d4..524cfa766ec82802b216b33602e97516865c7f5d 100644 --- a/src/gpu/VirtualFluids_GPU/DataStructureInitializer/GridProvider.h +++ b/src/gpu/VirtualFluids_GPU/DataStructureInitializer/GridProvider.h @@ -8,8 +8,7 @@ #include "PointerDefinitions.h" #include "VirtualFluids_GPU_export.h" - -#include <gpu/GridGenerator/io/SimulationFileWriter/SimulationFileWriter.h> +#include "gpu/GridGenerator/io/SimulationFileWriter/SimulationFileWriter.h" class Parameter; class GridBuilder; diff --git a/src/gpu/VirtualFluids_GPU/DataStructureInitializer/GridReaderGenerator/GridGenerator.cpp b/src/gpu/VirtualFluids_GPU/DataStructureInitializer/GridReaderGenerator/GridGenerator.cpp index fe1ae5ba66c23e7fd2311f085327eb3b0a57a717..00472978816141081b91b4c2882ffe3aa2942828 100644 --- a/src/gpu/VirtualFluids_GPU/DataStructureInitializer/GridReaderGenerator/GridGenerator.cpp +++ b/src/gpu/VirtualFluids_GPU/DataStructureInitializer/GridReaderGenerator/GridGenerator.cpp @@ -64,8 +64,11 @@ void GridGenerator::allocArrays_CoordNeighborGeo() //cudaMemoryManager->cudaAllocF3SP(level); cudaMemoryManager->cudaAllocNeighborWSB(level); - if(para->getUseWale()) + if(para->getUseTurbulentViscosity()) cudaMemoryManager->cudaAllocTurbulentViscosity(level); + + if(para->getIsBodyForce()) + cudaMemoryManager->cudaAllocBodyForce(level); builder->getNodeValues( para->getParH(level)->coordX_SP, @@ -83,6 +86,8 @@ void GridGenerator::allocArrays_CoordNeighborGeo() cudaMemoryManager->cudaCopyNeighborWSB(level); cudaMemoryManager->cudaCopySP(level); cudaMemoryManager->cudaCopyCoord(level); + if(para->getIsBodyForce()) + cudaMemoryManager->cudaCopyBodyForce(level); //std::cout << verifyNeighborIndices(level); } @@ -128,6 +133,53 @@ void GridGenerator::allocArrays_BoundaryValues() cudaMemoryManager->cudaCopyPress(level); } } + + for (uint level = 0; level < builder->getNumberOfGridLevels(); level++) { + const auto numberOfSlipValues = int(builder->getSlipSize(level)); + + std::cout << "size slip level " << level << " : " << numberOfSlipValues << std::endl; + //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + para->getParH(level)->QSlip.kQ = numberOfSlipValues; + para->getParD(level)->QSlip.kQ = numberOfSlipValues; + para->getParH(level)->kSlipQ = numberOfSlipValues; + para->getParD(level)->kSlipQ = numberOfSlipValues; + para->getParH(level)->kSlipQread = numberOfSlipValues * para->getD3Qxx(); + para->getParD(level)->kSlipQread = numberOfSlipValues * para->getD3Qxx(); + if (numberOfSlipValues > 1) + { + cudaMemoryManager->cudaAllocSlipBC(level); + builder->getSlipValues(para->getParH(level)->QSlip.normalX, para->getParH(level)->QSlip.normalY, para->getParH(level)->QSlip.normalZ, para->getParH(level)->QSlip.k, level); + cudaMemoryManager->cudaCopySlipBC(level); + } + } + + for (uint level = 0; level < builder->getNumberOfGridLevels(); level++) { + const auto numberOfStressValues = int(builder->getStressSize(level)); + + std::cout << "size stress level " << level << " : " << numberOfStressValues << std::endl; + //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + para->getParH(level)->QStress.kQ = numberOfStressValues; + para->getParD(level)->QStress.kQ = numberOfStressValues; + para->getParH(level)->kStressQ = numberOfStressValues; + para->getParD(level)->kStressQ = numberOfStressValues; + para->getParH(level)->kStressQread = numberOfStressValues * para->getD3Qxx(); + para->getParD(level)->kStressQread = numberOfStressValues * para->getD3Qxx(); + + if (numberOfStressValues > 1) + { + cudaMemoryManager->cudaAllocStressBC(level); + cudaMemoryManager->cudaAllocWallModel(level, para->getHasWallModelMonitor()); + builder->getStressValues( para->getParH(level)->QStress.normalX, para->getParH(level)->QStress.normalY, para->getParH(level)->QStress.normalZ, + para->getParH(level)->QStress.Vx, para->getParH(level)->QStress.Vy, para->getParH(level)->QStress.Vz, + para->getParH(level)->QStress.Vx1, para->getParH(level)->QStress.Vy1, para->getParH(level)->QStress.Vz1, + para->getParH(level)->QStress.k, para->getParH(level)->QStress.kN, + para->getParH(level)->wallModel.samplingOffset, para->getParH(level)->wallModel.z0, + level); + + cudaMemoryManager->cudaCopyStressBC(level); + cudaMemoryManager->cudaCopyWallModel(level, para->getHasWallModelMonitor()); + } + } for (uint level = 0; level < builder->getNumberOfGridLevels(); level++) { @@ -153,18 +205,6 @@ void GridGenerator::allocArrays_BoundaryValues() builder->getVelocityValues(para->getParH(level)->Qinflow.Vx, para->getParH(level)->Qinflow.Vy, para->getParH(level)->Qinflow.Vz, para->getParH(level)->Qinflow.k, level); - - //for (int i = 0; i < numberOfVelocityValues; i++) - //{ - // std::cout << "index: " << para->getParH(level)->Qinflow.k[i]; - // std::cout << " (x,y,z)" << para->getParH(level)->coordX_SP[para->getParH(level)->Qinflow.k[i]]; - // std::cout << ", " << para->getParH(level)->coordY_SP[para->getParH(level)->Qinflow.k[i]]; - // std::cout << ", " << para->getParH(level)->coordZ_SP[para->getParH(level)->Qinflow.k[i]]; - // std::cout << " geo: " << para->getParH(level)->geoSP[para->getParH(level)->Qinflow.k[i]]; - // std::cout << std::endl; - //} - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// cudaMemoryManager->cudaCopyVeloBC(level); @@ -774,7 +814,97 @@ void GridGenerator::allocArrays_BoundaryQs() }//ende if }//ende oberste for schleife + for (uint i = 0; i < builder->getNumberOfGridLevels(); i++) { + int numberOfSlipValues = (int)builder->getSlipSize(i); + if (numberOfSlipValues > 0) + { + std::cout << "size Slip: " << i << " : " << numberOfSlipValues << std::endl; + //cout << "Groesse Pressure: " << i << " : " << temp1 << "MyID: " << para->getMyID() << endl; + //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //preprocessing + real* QQ = para->getParH(i)->QSlip.q27[0]; + unsigned int sizeQ = para->getParH(i)->QSlip.kQ; + QforBoundaryConditions Q; + Q.q27[dirE] = &QQ[dirE *sizeQ]; + Q.q27[dirW] = &QQ[dirW *sizeQ]; + Q.q27[dirN] = &QQ[dirN *sizeQ]; + Q.q27[dirS] = &QQ[dirS *sizeQ]; + Q.q27[dirT] = &QQ[dirT *sizeQ]; + Q.q27[dirB] = &QQ[dirB *sizeQ]; + Q.q27[dirNE] = &QQ[dirNE *sizeQ]; + Q.q27[dirSW] = &QQ[dirSW *sizeQ]; + Q.q27[dirSE] = &QQ[dirSE *sizeQ]; + Q.q27[dirNW] = &QQ[dirNW *sizeQ]; + Q.q27[dirTE] = &QQ[dirTE *sizeQ]; + Q.q27[dirBW] = &QQ[dirBW *sizeQ]; + Q.q27[dirBE] = &QQ[dirBE *sizeQ]; + Q.q27[dirTW] = &QQ[dirTW *sizeQ]; + Q.q27[dirTN] = &QQ[dirTN *sizeQ]; + Q.q27[dirBS] = &QQ[dirBS *sizeQ]; + Q.q27[dirBN] = &QQ[dirBN *sizeQ]; + Q.q27[dirTS] = &QQ[dirTS *sizeQ]; + Q.q27[dirZERO] = &QQ[dirZERO*sizeQ]; + Q.q27[dirTNE] = &QQ[dirTNE *sizeQ]; + Q.q27[dirTSW] = &QQ[dirTSW *sizeQ]; + Q.q27[dirTSE] = &QQ[dirTSE *sizeQ]; + Q.q27[dirTNW] = &QQ[dirTNW *sizeQ]; + Q.q27[dirBNE] = &QQ[dirBNE *sizeQ]; + Q.q27[dirBSW] = &QQ[dirBSW *sizeQ]; + Q.q27[dirBSE] = &QQ[dirBSE *sizeQ]; + Q.q27[dirBNW] = &QQ[dirBNW *sizeQ]; + + builder->getSlipQs(Q.q27, i); + //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + cudaMemoryManager->cudaCopySlipBC(i); + //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + }//ende if + }//ende oberste for schleife + for (uint i = 0; i < builder->getNumberOfGridLevels(); i++) { + int numberOfStressValues = (int)builder->getStressSize(i); + if (numberOfStressValues > 0) + { + std::cout << "size Stress: " << i << " : " << numberOfStressValues << std::endl; + //cout << "Groesse Pressure: " << i << " : " << temp1 << "MyID: " << para->getMyID() << endl; + //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //preprocessing + real* QQ = para->getParH(i)->QStress.q27[0]; + unsigned int sizeQ = para->getParH(i)->QStress.kQ; + QforBoundaryConditions Q; + Q.q27[dirE] = &QQ[dirE *sizeQ]; + Q.q27[dirW] = &QQ[dirW *sizeQ]; + Q.q27[dirN] = &QQ[dirN *sizeQ]; + Q.q27[dirS] = &QQ[dirS *sizeQ]; + Q.q27[dirT] = &QQ[dirT *sizeQ]; + Q.q27[dirB] = &QQ[dirB *sizeQ]; + Q.q27[dirNE] = &QQ[dirNE *sizeQ]; + Q.q27[dirSW] = &QQ[dirSW *sizeQ]; + Q.q27[dirSE] = &QQ[dirSE *sizeQ]; + Q.q27[dirNW] = &QQ[dirNW *sizeQ]; + Q.q27[dirTE] = &QQ[dirTE *sizeQ]; + Q.q27[dirBW] = &QQ[dirBW *sizeQ]; + Q.q27[dirBE] = &QQ[dirBE *sizeQ]; + Q.q27[dirTW] = &QQ[dirTW *sizeQ]; + Q.q27[dirTN] = &QQ[dirTN *sizeQ]; + Q.q27[dirBS] = &QQ[dirBS *sizeQ]; + Q.q27[dirBN] = &QQ[dirBN *sizeQ]; + Q.q27[dirTS] = &QQ[dirTS *sizeQ]; + Q.q27[dirZERO] = &QQ[dirZERO*sizeQ]; + Q.q27[dirTNE] = &QQ[dirTNE *sizeQ]; + Q.q27[dirTSW] = &QQ[dirTSW *sizeQ]; + Q.q27[dirTSE] = &QQ[dirTSE *sizeQ]; + Q.q27[dirTNW] = &QQ[dirTNW *sizeQ]; + Q.q27[dirBNE] = &QQ[dirBNE *sizeQ]; + Q.q27[dirBSW] = &QQ[dirBSW *sizeQ]; + Q.q27[dirBSE] = &QQ[dirBSE *sizeQ]; + Q.q27[dirBNW] = &QQ[dirBNW *sizeQ]; + + builder->getStressQs(Q.q27, i); + //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + cudaMemoryManager->cudaCopyStressBC(i); + //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + }//ende if + }//ende oberste for schleife for (uint i = 0; i < builder->getNumberOfGridLevels(); i++) { const auto numberOfVelocityNodes = int(builder->getVelocitySize(i)); diff --git a/src/gpu/VirtualFluids_GPU/GPU/CudaMemoryManager.cpp b/src/gpu/VirtualFluids_GPU/GPU/CudaMemoryManager.cpp index 140927be10537d592ec7f46550d2942caf206503..6efd3e4b1f91051e9609783298b56491abed731d 100644 --- a/src/gpu/VirtualFluids_GPU/GPU/CudaMemoryManager.cpp +++ b/src/gpu/VirtualFluids_GPU/GPU/CudaMemoryManager.cpp @@ -6,10 +6,12 @@ #include <Parameter/Parameter.h> #include "Parameter/CudaStreamManager.h" +#include "PreCollisionInteractor/ActuatorLine.h" +#include "PreCollisionInteractor/Probes/Probe.h" #include "Calculation/PorousMedia.h" -#include <lbm/constants/NumericConstants.h> +#include "lbm/constants/NumericConstants.h" void CudaMemoryManager::cudaAllocFull(int lev) { @@ -43,7 +45,7 @@ void CudaMemoryManager::cudaAllocCoord(int lev) checkCudaErrors( cudaMallocHost((void**) &(parameter->getParH(lev)->coordX_SP ), parameter->getParH(lev)->mem_size_real_SP )); checkCudaErrors( cudaMallocHost((void**) &(parameter->getParH(lev)->coordY_SP ), parameter->getParH(lev)->mem_size_real_SP )); checkCudaErrors( cudaMallocHost((void**) &(parameter->getParH(lev)->coordZ_SP ), parameter->getParH(lev)->mem_size_real_SP )); - //Device (spinning ship + upsala) + //Device (spinning ship + uppsala) checkCudaErrors( cudaMalloc((void**) &(parameter->getParD(lev)->coordX_SP ), parameter->getParH(lev)->mem_size_real_SP )); checkCudaErrors( cudaMalloc((void**) &(parameter->getParD(lev)->coordY_SP ), parameter->getParH(lev)->mem_size_real_SP )); checkCudaErrors( cudaMalloc((void**) &(parameter->getParD(lev)->coordZ_SP ), parameter->getParH(lev)->mem_size_real_SP )); @@ -70,7 +72,7 @@ void CudaMemoryManager::cudaAllocBodyForce(int lev) checkCudaErrors( cudaMallocHost((void**) &(parameter->getParH(lev)->forceX_SP ), parameter->getParH(lev)->mem_size_real_SP )); checkCudaErrors( cudaMallocHost((void**) &(parameter->getParH(lev)->forceY_SP ), parameter->getParH(lev)->mem_size_real_SP )); checkCudaErrors( cudaMallocHost((void**) &(parameter->getParH(lev)->forceZ_SP ), parameter->getParH(lev)->mem_size_real_SP )); - //Device (spinning ship) + //Device checkCudaErrors( cudaMalloc((void**) &(parameter->getParD(lev)->forceX_SP ), parameter->getParH(lev)->mem_size_real_SP )); checkCudaErrors( cudaMalloc((void**) &(parameter->getParD(lev)->forceY_SP ), parameter->getParH(lev)->mem_size_real_SP )); checkCudaErrors( cudaMalloc((void**) &(parameter->getParD(lev)->forceZ_SP ), parameter->getParH(lev)->mem_size_real_SP )); @@ -895,34 +897,35 @@ void CudaMemoryManager::cudaAllocTurbulentViscosity(int lev) //Host checkCudaErrors(cudaMallocHost((void**) &(parameter->getParH(lev)->turbViscosity), parameter->getParH(lev)->mem_size_real_SP)); //Debug - checkCudaErrors(cudaMallocHost((void**) &(parameter->getParH(lev)->gSij ), parameter->getParH(lev)->mem_size_real_SP)); - checkCudaErrors(cudaMallocHost((void**) &(parameter->getParH(lev)->gSDij), parameter->getParH(lev)->mem_size_real_SP)); - checkCudaErrors(cudaMallocHost((void**) &(parameter->getParH(lev)->gDxvx), parameter->getParH(lev)->mem_size_real_SP)); - checkCudaErrors(cudaMallocHost((void**) &(parameter->getParH(lev)->gDyvx), parameter->getParH(lev)->mem_size_real_SP)); - checkCudaErrors(cudaMallocHost((void**) &(parameter->getParH(lev)->gDzvx), parameter->getParH(lev)->mem_size_real_SP)); - checkCudaErrors(cudaMallocHost((void**) &(parameter->getParH(lev)->gDxvy), parameter->getParH(lev)->mem_size_real_SP)); - checkCudaErrors(cudaMallocHost((void**) &(parameter->getParH(lev)->gDyvy), parameter->getParH(lev)->mem_size_real_SP)); - checkCudaErrors(cudaMallocHost((void**) &(parameter->getParH(lev)->gDzvy), parameter->getParH(lev)->mem_size_real_SP)); - checkCudaErrors(cudaMallocHost((void**) &(parameter->getParH(lev)->gDxvz), parameter->getParH(lev)->mem_size_real_SP)); - checkCudaErrors(cudaMallocHost((void**) &(parameter->getParH(lev)->gDyvz), parameter->getParH(lev)->mem_size_real_SP)); - checkCudaErrors(cudaMallocHost((void**) &(parameter->getParH(lev)->gDzvz), parameter->getParH(lev)->mem_size_real_SP)); + // checkCudaErrors(cudaMallocHost((void**) &(parameter->getParH(lev)->gSij ), parameter->getParH(lev)->mem_size_real_SP)); + // checkCudaErrors(cudaMallocHost((void**) &(parameter->getParH(lev)->gSDij), parameter->getParH(lev)->mem_size_real_SP)); + // checkCudaErrors(cudaMallocHost((void**) &(parameter->getParH(lev)->gDxvx), parameter->getParH(lev)->mem_size_real_SP)); + // checkCudaErrors(cudaMallocHost((void**) &(parameter->getParH(lev)->gDyvx), parameter->getParH(lev)->mem_size_real_SP)); + // checkCudaErrors(cudaMallocHost((void**) &(parameter->getParH(lev)->gDzvx), parameter->getParH(lev)->mem_size_real_SP)); + // checkCudaErrors(cudaMallocHost((void**) &(parameter->getParH(lev)->gDxvy), parameter->getParH(lev)->mem_size_real_SP)); + // checkCudaErrors(cudaMallocHost((void**) &(parameter->getParH(lev)->gDyvy), parameter->getParH(lev)->mem_size_real_SP)); + // checkCudaErrors(cudaMallocHost((void**) &(parameter->getParH(lev)->gDzvy), parameter->getParH(lev)->mem_size_real_SP)); + // checkCudaErrors(cudaMallocHost((void**) &(parameter->getParH(lev)->gDxvz), parameter->getParH(lev)->mem_size_real_SP)); + // checkCudaErrors(cudaMallocHost((void**) &(parameter->getParH(lev)->gDyvz), parameter->getParH(lev)->mem_size_real_SP)); + // checkCudaErrors(cudaMallocHost((void**) &(parameter->getParH(lev)->gDzvz), parameter->getParH(lev)->mem_size_real_SP)); //Device checkCudaErrors(cudaMalloc((void**) &(parameter->getParD(lev)->turbViscosity), parameter->getParD(lev)->mem_size_real_SP)); //Debug - checkCudaErrors(cudaMalloc((void**) &(parameter->getParD(lev)->gSij ), parameter->getParD(lev)->mem_size_real_SP)); - checkCudaErrors(cudaMalloc((void**) &(parameter->getParD(lev)->gSDij), parameter->getParD(lev)->mem_size_real_SP)); - checkCudaErrors(cudaMalloc((void**) &(parameter->getParD(lev)->gDxvx), parameter->getParD(lev)->mem_size_real_SP)); - checkCudaErrors(cudaMalloc((void**) &(parameter->getParD(lev)->gDyvx), parameter->getParD(lev)->mem_size_real_SP)); - checkCudaErrors(cudaMalloc((void**) &(parameter->getParD(lev)->gDzvx), parameter->getParD(lev)->mem_size_real_SP)); - checkCudaErrors(cudaMalloc((void**) &(parameter->getParD(lev)->gDxvy), parameter->getParD(lev)->mem_size_real_SP)); - checkCudaErrors(cudaMalloc((void**) &(parameter->getParD(lev)->gDyvy), parameter->getParD(lev)->mem_size_real_SP)); - checkCudaErrors(cudaMalloc((void**) &(parameter->getParD(lev)->gDzvy), parameter->getParD(lev)->mem_size_real_SP)); - checkCudaErrors(cudaMalloc((void**) &(parameter->getParD(lev)->gDxvz), parameter->getParD(lev)->mem_size_real_SP)); - checkCudaErrors(cudaMalloc((void**) &(parameter->getParD(lev)->gDyvz), parameter->getParD(lev)->mem_size_real_SP)); - checkCudaErrors(cudaMalloc((void**) &(parameter->getParD(lev)->gDzvz), parameter->getParD(lev)->mem_size_real_SP)); - ////////////////////////////////////////////////////////////////////////// - double tmp = (double)parameter->getParH(lev)->mem_size_real_SP * 12.0; + // checkCudaErrors(cudaMalloc((void**) &(parameter->getParD(lev)->gSij ), parameter->getParD(lev)->mem_size_real_SP)); + // checkCudaErrors(cudaMalloc((void**) &(parameter->getParD(lev)->gSDij), parameter->getParD(lev)->mem_size_real_SP)); + // checkCudaErrors(cudaMalloc((void**) &(parameter->getParD(lev)->gDxvx), parameter->getParD(lev)->mem_size_real_SP)); + // checkCudaErrors(cudaMalloc((void**) &(parameter->getParD(lev)->gDyvx), parameter->getParD(lev)->mem_size_real_SP)); + // checkCudaErrors(cudaMalloc((void**) &(parameter->getParD(lev)->gDzvx), parameter->getParD(lev)->mem_size_real_SP)); + // checkCudaErrors(cudaMalloc((void**) &(parameter->getParD(lev)->gDxvy), parameter->getParD(lev)->mem_size_real_SP)); + // checkCudaErrors(cudaMalloc((void**) &(parameter->getParD(lev)->gDyvy), parameter->getParD(lev)->mem_size_real_SP)); + // checkCudaErrors(cudaMalloc((void**) &(parameter->getParD(lev)->gDzvy), parameter->getParD(lev)->mem_size_real_SP)); + // checkCudaErrors(cudaMalloc((void**) &(parameter->getParD(lev)->gDxvz), parameter->getParD(lev)->mem_size_real_SP)); + // checkCudaErrors(cudaMalloc((void**) &(parameter->getParD(lev)->gDyvz), parameter->getParD(lev)->mem_size_real_SP)); + // checkCudaErrors(cudaMalloc((void**) &(parameter->getParD(lev)->gDzvz), parameter->getParD(lev)->mem_size_real_SP)); + // ////////////////////////////////////////////////////////////////////////// + // double tmp = (double)parameter->getParH(lev)->mem_size_real_SP * 12.0; + double tmp = (double)parameter->getParH(lev)->mem_size_real_SP; setMemsizeGPU(tmp, false); } void CudaMemoryManager::cudaCopyTurbulentViscosityHD(int lev) @@ -930,50 +933,50 @@ void CudaMemoryManager::cudaCopyTurbulentViscosityHD(int lev) //copy host to device checkCudaErrors(cudaMemcpy(parameter->getParD(lev)->turbViscosity, parameter->getParH(lev)->turbViscosity, parameter->getParH(lev)->mem_size_real_SP, cudaMemcpyHostToDevice)); //Debug - checkCudaErrors(cudaMemcpy(parameter->getParD(lev)->gSij , parameter->getParH(lev)->gSij , parameter->getParH(lev)->mem_size_real_SP, cudaMemcpyHostToDevice)); - checkCudaErrors(cudaMemcpy(parameter->getParD(lev)->gSDij, parameter->getParH(lev)->gSDij, parameter->getParH(lev)->mem_size_real_SP, cudaMemcpyHostToDevice)); - checkCudaErrors(cudaMemcpy(parameter->getParD(lev)->gDxvx, parameter->getParH(lev)->gDxvx, parameter->getParH(lev)->mem_size_real_SP, cudaMemcpyHostToDevice)); - checkCudaErrors(cudaMemcpy(parameter->getParD(lev)->gDyvx, parameter->getParH(lev)->gDyvx, parameter->getParH(lev)->mem_size_real_SP, cudaMemcpyHostToDevice)); - checkCudaErrors(cudaMemcpy(parameter->getParD(lev)->gDzvx, parameter->getParH(lev)->gDzvx, parameter->getParH(lev)->mem_size_real_SP, cudaMemcpyHostToDevice)); - checkCudaErrors(cudaMemcpy(parameter->getParD(lev)->gDxvy, parameter->getParH(lev)->gDxvy, parameter->getParH(lev)->mem_size_real_SP, cudaMemcpyHostToDevice)); - checkCudaErrors(cudaMemcpy(parameter->getParD(lev)->gDyvy, parameter->getParH(lev)->gDyvy, parameter->getParH(lev)->mem_size_real_SP, cudaMemcpyHostToDevice)); - checkCudaErrors(cudaMemcpy(parameter->getParD(lev)->gDzvy, parameter->getParH(lev)->gDzvy, parameter->getParH(lev)->mem_size_real_SP, cudaMemcpyHostToDevice)); - checkCudaErrors(cudaMemcpy(parameter->getParD(lev)->gDxvz, parameter->getParH(lev)->gDxvz, parameter->getParH(lev)->mem_size_real_SP, cudaMemcpyHostToDevice)); - checkCudaErrors(cudaMemcpy(parameter->getParD(lev)->gDyvz, parameter->getParH(lev)->gDyvz, parameter->getParH(lev)->mem_size_real_SP, cudaMemcpyHostToDevice)); - checkCudaErrors(cudaMemcpy(parameter->getParD(lev)->gDzvz, parameter->getParH(lev)->gDzvz, parameter->getParH(lev)->mem_size_real_SP, cudaMemcpyHostToDevice)); + // checkCudaErrors(cudaMemcpy(parameter->getParD(lev)->gSij , parameter->getParH(lev)->gSij , parameter->getParH(lev)->mem_size_real_SP, cudaMemcpyHostToDevice)); + // checkCudaErrors(cudaMemcpy(parameter->getParD(lev)->gSDij, parameter->getParH(lev)->gSDij, parameter->getParH(lev)->mem_size_real_SP, cudaMemcpyHostToDevice)); + // checkCudaErrors(cudaMemcpy(parameter->getParD(lev)->gDxvx, parameter->getParH(lev)->gDxvx, parameter->getParH(lev)->mem_size_real_SP, cudaMemcpyHostToDevice)); + // checkCudaErrors(cudaMemcpy(parameter->getParD(lev)->gDyvx, parameter->getParH(lev)->gDyvx, parameter->getParH(lev)->mem_size_real_SP, cudaMemcpyHostToDevice)); + // checkCudaErrors(cudaMemcpy(parameter->getParD(lev)->gDzvx, parameter->getParH(lev)->gDzvx, parameter->getParH(lev)->mem_size_real_SP, cudaMemcpyHostToDevice)); + // checkCudaErrors(cudaMemcpy(parameter->getParD(lev)->gDxvy, parameter->getParH(lev)->gDxvy, parameter->getParH(lev)->mem_size_real_SP, cudaMemcpyHostToDevice)); + // checkCudaErrors(cudaMemcpy(parameter->getParD(lev)->gDyvy, parameter->getParH(lev)->gDyvy, parameter->getParH(lev)->mem_size_real_SP, cudaMemcpyHostToDevice)); + // checkCudaErrors(cudaMemcpy(parameter->getParD(lev)->gDzvy, parameter->getParH(lev)->gDzvy, parameter->getParH(lev)->mem_size_real_SP, cudaMemcpyHostToDevice)); + // checkCudaErrors(cudaMemcpy(parameter->getParD(lev)->gDxvz, parameter->getParH(lev)->gDxvz, parameter->getParH(lev)->mem_size_real_SP, cudaMemcpyHostToDevice)); + // checkCudaErrors(cudaMemcpy(parameter->getParD(lev)->gDyvz, parameter->getParH(lev)->gDyvz, parameter->getParH(lev)->mem_size_real_SP, cudaMemcpyHostToDevice)); + // checkCudaErrors(cudaMemcpy(parameter->getParD(lev)->gDzvz, parameter->getParH(lev)->gDzvz, parameter->getParH(lev)->mem_size_real_SP, cudaMemcpyHostToDevice)); } void CudaMemoryManager::cudaCopyTurbulentViscosityDH(int lev) { //copy device to host checkCudaErrors(cudaMemcpy(parameter->getParH(lev)->turbViscosity, parameter->getParD(lev)->turbViscosity, parameter->getParH(lev)->mem_size_real_SP, cudaMemcpyDeviceToHost)); //Debug - checkCudaErrors(cudaMemcpy(parameter->getParH(lev)->gSij , parameter->getParD(lev)->gSij , parameter->getParH(lev)->mem_size_real_SP, cudaMemcpyDeviceToHost)); - checkCudaErrors(cudaMemcpy(parameter->getParH(lev)->gSDij, parameter->getParD(lev)->gSDij, parameter->getParH(lev)->mem_size_real_SP, cudaMemcpyDeviceToHost)); - checkCudaErrors(cudaMemcpy(parameter->getParH(lev)->gDxvx, parameter->getParD(lev)->gDxvx, parameter->getParH(lev)->mem_size_real_SP, cudaMemcpyDeviceToHost)); - checkCudaErrors(cudaMemcpy(parameter->getParH(lev)->gDyvx, parameter->getParD(lev)->gDyvx, parameter->getParH(lev)->mem_size_real_SP, cudaMemcpyDeviceToHost)); - checkCudaErrors(cudaMemcpy(parameter->getParH(lev)->gDzvx, parameter->getParD(lev)->gDzvx, parameter->getParH(lev)->mem_size_real_SP, cudaMemcpyDeviceToHost)); - checkCudaErrors(cudaMemcpy(parameter->getParH(lev)->gDxvy, parameter->getParD(lev)->gDxvy, parameter->getParH(lev)->mem_size_real_SP, cudaMemcpyDeviceToHost)); - checkCudaErrors(cudaMemcpy(parameter->getParH(lev)->gDyvy, parameter->getParD(lev)->gDyvy, parameter->getParH(lev)->mem_size_real_SP, cudaMemcpyDeviceToHost)); - checkCudaErrors(cudaMemcpy(parameter->getParH(lev)->gDzvy, parameter->getParD(lev)->gDzvy, parameter->getParH(lev)->mem_size_real_SP, cudaMemcpyDeviceToHost)); - checkCudaErrors(cudaMemcpy(parameter->getParH(lev)->gDxvz, parameter->getParD(lev)->gDxvz, parameter->getParH(lev)->mem_size_real_SP, cudaMemcpyDeviceToHost)); - checkCudaErrors(cudaMemcpy(parameter->getParH(lev)->gDyvz, parameter->getParD(lev)->gDyvz, parameter->getParH(lev)->mem_size_real_SP, cudaMemcpyDeviceToHost)); - checkCudaErrors(cudaMemcpy(parameter->getParH(lev)->gDzvz, parameter->getParD(lev)->gDzvz, parameter->getParH(lev)->mem_size_real_SP, cudaMemcpyDeviceToHost)); + // checkCudaErrors(cudaMemcpy(parameter->getParH(lev)->gSij , parameter->getParD(lev)->gSij , parameter->getParH(lev)->mem_size_real_SP, cudaMemcpyDeviceToHost)); + // checkCudaErrors(cudaMemcpy(parameter->getParH(lev)->gSDij, parameter->getParD(lev)->gSDij, parameter->getParH(lev)->mem_size_real_SP, cudaMemcpyDeviceToHost)); + // checkCudaErrors(cudaMemcpy(parameter->getParH(lev)->gDxvx, parameter->getParD(lev)->gDxvx, parameter->getParH(lev)->mem_size_real_SP, cudaMemcpyDeviceToHost)); + // checkCudaErrors(cudaMemcpy(parameter->getParH(lev)->gDyvx, parameter->getParD(lev)->gDyvx, parameter->getParH(lev)->mem_size_real_SP, cudaMemcpyDeviceToHost)); + // checkCudaErrors(cudaMemcpy(parameter->getParH(lev)->gDzvx, parameter->getParD(lev)->gDzvx, parameter->getParH(lev)->mem_size_real_SP, cudaMemcpyDeviceToHost)); + // checkCudaErrors(cudaMemcpy(parameter->getParH(lev)->gDxvy, parameter->getParD(lev)->gDxvy, parameter->getParH(lev)->mem_size_real_SP, cudaMemcpyDeviceToHost)); + // checkCudaErrors(cudaMemcpy(parameter->getParH(lev)->gDyvy, parameter->getParD(lev)->gDyvy, parameter->getParH(lev)->mem_size_real_SP, cudaMemcpyDeviceToHost)); + // checkCudaErrors(cudaMemcpy(parameter->getParH(lev)->gDzvy, parameter->getParD(lev)->gDzvy, parameter->getParH(lev)->mem_size_real_SP, cudaMemcpyDeviceToHost)); + // checkCudaErrors(cudaMemcpy(parameter->getParH(lev)->gDxvz, parameter->getParD(lev)->gDxvz, parameter->getParH(lev)->mem_size_real_SP, cudaMemcpyDeviceToHost)); + // checkCudaErrors(cudaMemcpy(parameter->getParH(lev)->gDyvz, parameter->getParD(lev)->gDyvz, parameter->getParH(lev)->mem_size_real_SP, cudaMemcpyDeviceToHost)); + // checkCudaErrors(cudaMemcpy(parameter->getParH(lev)->gDzvz, parameter->getParD(lev)->gDzvz, parameter->getParH(lev)->mem_size_real_SP, cudaMemcpyDeviceToHost)); } void CudaMemoryManager::cudaFreeTurbulentViscosity(int lev) { checkCudaErrors(cudaFreeHost(parameter->getParH(lev)->turbViscosity)); //Debug - checkCudaErrors(cudaFreeHost(parameter->getParH(lev)->gSij )); - checkCudaErrors(cudaFreeHost(parameter->getParH(lev)->gSDij)); - checkCudaErrors(cudaFreeHost(parameter->getParH(lev)->gDxvx)); - checkCudaErrors(cudaFreeHost(parameter->getParH(lev)->gDyvx)); - checkCudaErrors(cudaFreeHost(parameter->getParH(lev)->gDzvx)); - checkCudaErrors(cudaFreeHost(parameter->getParH(lev)->gDxvy)); - checkCudaErrors(cudaFreeHost(parameter->getParH(lev)->gDyvy)); - checkCudaErrors(cudaFreeHost(parameter->getParH(lev)->gDzvy)); - checkCudaErrors(cudaFreeHost(parameter->getParH(lev)->gDxvz)); - checkCudaErrors(cudaFreeHost(parameter->getParH(lev)->gDyvz)); - checkCudaErrors(cudaFreeHost(parameter->getParH(lev)->gDzvz)); + // checkCudaErrors(cudaFreeHost(parameter->getParH(lev)->gSij )); + // checkCudaErrors(cudaFreeHost(parameter->getParH(lev)->gSDij)); + // checkCudaErrors(cudaFreeHost(parameter->getParH(lev)->gDxvx)); + // checkCudaErrors(cudaFreeHost(parameter->getParH(lev)->gDyvx)); + // checkCudaErrors(cudaFreeHost(parameter->getParH(lev)->gDzvx)); + // checkCudaErrors(cudaFreeHost(parameter->getParH(lev)->gDxvy)); + // checkCudaErrors(cudaFreeHost(parameter->getParH(lev)->gDyvy)); + // checkCudaErrors(cudaFreeHost(parameter->getParH(lev)->gDzvy)); + // checkCudaErrors(cudaFreeHost(parameter->getParH(lev)->gDxvz)); + // checkCudaErrors(cudaFreeHost(parameter->getParH(lev)->gDyvz)); + // checkCudaErrors(cudaFreeHost(parameter->getParH(lev)->gDzvz)); } //turbulence intensity void CudaMemoryManager::cudaAllocTurbulenceIntensity(int lev, uint size) @@ -1477,15 +1480,19 @@ void CudaMemoryManager::cudaAllocSlipBC(int lev) //Host checkCudaErrors( cudaMallocHost((void**) &(parameter->getParH(lev)->QSlip.q27[0]), parameter->getD3Qxx()*mem_size_Q_q )); checkCudaErrors( cudaMallocHost((void**) &(parameter->getParH(lev)->QSlip.k), mem_size_Q_k )); - //checkCudaErrors( cudaMallocHost((void**) &(parameter->getParH(lev)->QSlip.qread), mem_size_Q_q_read ));//Geller - //checkCudaErrors( cudaMallocHost((void**) &(parameter->getParH(lev)->QSlip.valueQ), mem_size_Q_value ));//Geller + checkCudaErrors( cudaMallocHost((void**) &(parameter->getParH(lev)->QSlip.normalX), mem_size_Q_q )); + checkCudaErrors( cudaMallocHost((void**) &(parameter->getParH(lev)->QSlip.normalY), mem_size_Q_q )); + checkCudaErrors( cudaMallocHost((void**) &(parameter->getParH(lev)->QSlip.normalZ), mem_size_Q_q )); //Device checkCudaErrors( cudaMalloc((void**) &(parameter->getParD(lev)->QSlip.q27[0]), parameter->getD3Qxx()* mem_size_Q_q )); checkCudaErrors( cudaMalloc((void**) &(parameter->getParD(lev)->QSlip.k), mem_size_Q_k )); + checkCudaErrors( cudaMalloc((void**) &(parameter->getParD(lev)->QSlip.normalX), mem_size_Q_q )); + checkCudaErrors( cudaMalloc((void**) &(parameter->getParD(lev)->QSlip.normalY), mem_size_Q_q )); + checkCudaErrors( cudaMalloc((void**) &(parameter->getParD(lev)->QSlip.normalZ), mem_size_Q_q )); ////////////////////////////////////////////////////////////////////////// - double tmp = (double)mem_size_Q_k + (double)parameter->getD3Qxx()*(double)mem_size_Q_q; + double tmp = (double)mem_size_Q_k + (double)parameter->getD3Qxx()*(double)mem_size_Q_q + 3.0*(double)mem_size_Q_q;; setMemsizeGPU(tmp, false); } void CudaMemoryManager::cudaCopySlipBC(int lev) @@ -1493,15 +1500,150 @@ void CudaMemoryManager::cudaCopySlipBC(int lev) unsigned int mem_size_Q_k = sizeof(int)*parameter->getParH(lev)->QSlip.kQ; unsigned int mem_size_Q_q = sizeof(real)*parameter->getParH(lev)->QSlip.kQ; - checkCudaErrors( cudaMemcpy(parameter->getParD(lev)->QSlip.q27[0], parameter->getParH(lev)->QSlip.q27[0], parameter->getD3Qxx()* mem_size_Q_q, cudaMemcpyHostToDevice)); - checkCudaErrors( cudaMemcpy(parameter->getParD(lev)->QSlip.k, parameter->getParH(lev)->QSlip.k, mem_size_Q_k, cudaMemcpyHostToDevice)); + checkCudaErrors( cudaMemcpy(parameter->getParD(lev)->QSlip.q27[0], parameter->getParH(lev)->QSlip.q27[0], parameter->getD3Qxx()* mem_size_Q_q, cudaMemcpyHostToDevice)); + checkCudaErrors( cudaMemcpy(parameter->getParD(lev)->QSlip.k, parameter->getParH(lev)->QSlip.k, mem_size_Q_k, cudaMemcpyHostToDevice)); + checkCudaErrors( cudaMemcpy(parameter->getParD(lev)->QSlip.normalX, parameter->getParH(lev)->QSlip.normalX, mem_size_Q_q, cudaMemcpyHostToDevice)); + checkCudaErrors( cudaMemcpy(parameter->getParD(lev)->QSlip.normalY, parameter->getParH(lev)->QSlip.normalY, mem_size_Q_q, cudaMemcpyHostToDevice)); + checkCudaErrors( cudaMemcpy(parameter->getParD(lev)->QSlip.normalZ, parameter->getParH(lev)->QSlip.normalZ, mem_size_Q_q, cudaMemcpyHostToDevice)); } void CudaMemoryManager::cudaFreeSlipBC(int lev) { checkCudaErrors( cudaFreeHost(parameter->getParH(lev)->QSlip.q27[0])); checkCudaErrors( cudaFreeHost(parameter->getParH(lev)->QSlip.k)); - //checkCudaErrors( cudaFreeHost(parameter->getParH(lev)->QSlip.valueQ)); - //checkCudaErrors( cudaFreeHost(parameter->getParH(lev)->QSlip.qread)); + checkCudaErrors( cudaFreeHost(parameter->getParH(lev)->QSlip.normalX)); + checkCudaErrors( cudaFreeHost(parameter->getParH(lev)->QSlip.normalY)); + checkCudaErrors( cudaFreeHost(parameter->getParH(lev)->QSlip.normalZ)); +} +//Stress +void CudaMemoryManager::cudaAllocStressBC(int lev) +{ + unsigned int mem_size_Q_k = sizeof(int)*parameter->getParH(lev)->QStress.kQ; + unsigned int mem_size_Q_q = sizeof(real)*parameter->getParH(lev)->QStress.kQ; + + //Host + checkCudaErrors( cudaMallocHost((void**) &(parameter->getParH(lev)->QStress.q27[0]), parameter->getD3Qxx()*mem_size_Q_q )); + checkCudaErrors( cudaMallocHost((void**) &(parameter->getParH(lev)->QStress.k), mem_size_Q_k )); + checkCudaErrors( cudaMallocHost((void**) &(parameter->getParH(lev)->QStress.kN), mem_size_Q_k )); + checkCudaErrors( cudaMallocHost((void**) &(parameter->getParH(lev)->QStress.normalX), mem_size_Q_q )); + checkCudaErrors( cudaMallocHost((void**) &(parameter->getParH(lev)->QStress.normalY), mem_size_Q_q )); + checkCudaErrors( cudaMallocHost((void**) &(parameter->getParH(lev)->QStress.normalZ), mem_size_Q_q )); + checkCudaErrors( cudaMallocHost((void**) &(parameter->getParH(lev)->QStress.Vx), mem_size_Q_q )); + checkCudaErrors( cudaMallocHost((void**) &(parameter->getParH(lev)->QStress.Vy), mem_size_Q_q )); + checkCudaErrors( cudaMallocHost((void**) &(parameter->getParH(lev)->QStress.Vz), mem_size_Q_q )); + checkCudaErrors( cudaMallocHost((void**) &(parameter->getParH(lev)->QStress.Vx1), mem_size_Q_q )); + checkCudaErrors( cudaMallocHost((void**) &(parameter->getParH(lev)->QStress.Vy1), mem_size_Q_q )); + checkCudaErrors( cudaMallocHost((void**) &(parameter->getParH(lev)->QStress.Vz1), mem_size_Q_q )); + + //Device + checkCudaErrors( cudaMalloc((void**) &(parameter->getParD(lev)->QStress.q27[0]), parameter->getD3Qxx()* mem_size_Q_q )); + checkCudaErrors( cudaMalloc((void**) &(parameter->getParD(lev)->QStress.k), mem_size_Q_k )); + checkCudaErrors( cudaMalloc((void**) &(parameter->getParD(lev)->QStress.kN), mem_size_Q_k )); + checkCudaErrors( cudaMalloc((void**) &(parameter->getParD(lev)->QStress.normalX), mem_size_Q_q )); + checkCudaErrors( cudaMalloc((void**) &(parameter->getParD(lev)->QStress.normalY), mem_size_Q_q )); + checkCudaErrors( cudaMalloc((void**) &(parameter->getParD(lev)->QStress.normalZ), mem_size_Q_q )); + checkCudaErrors( cudaMalloc((void**) &(parameter->getParD(lev)->QStress.Vx), mem_size_Q_q )); + checkCudaErrors( cudaMalloc((void**) &(parameter->getParD(lev)->QStress.Vy), mem_size_Q_q )); + checkCudaErrors( cudaMalloc((void**) &(parameter->getParD(lev)->QStress.Vz), mem_size_Q_q )); + checkCudaErrors( cudaMalloc((void**) &(parameter->getParD(lev)->QStress.Vx1), mem_size_Q_q )); + checkCudaErrors( cudaMalloc((void**) &(parameter->getParD(lev)->QStress.Vy1), mem_size_Q_q )); + checkCudaErrors( cudaMalloc((void**) &(parameter->getParD(lev)->QStress.Vz1), mem_size_Q_q )); + + ////////////////////////////////////////////////////////////////////////// + double tmp = 2*(double)mem_size_Q_k + (double)parameter->getD3Qxx()*(double)mem_size_Q_q + 9.0*(double)mem_size_Q_q; + setMemsizeGPU(tmp, false); +} +void CudaMemoryManager::cudaCopyStressBC(int lev) +{ + unsigned int mem_size_Q_k = sizeof(int)*parameter->getParH(lev)->QStress.kQ; + unsigned int mem_size_Q_q = sizeof(real)*parameter->getParH(lev)->QStress.kQ; + + checkCudaErrors( cudaMemcpy(parameter->getParD(lev)->QStress.q27[0], parameter->getParH(lev)->QStress.q27[0], parameter->getD3Qxx()* mem_size_Q_q, cudaMemcpyHostToDevice)); + checkCudaErrors( cudaMemcpy(parameter->getParD(lev)->QStress.k, parameter->getParH(lev)->QStress.k, mem_size_Q_k, cudaMemcpyHostToDevice)); + checkCudaErrors( cudaMemcpy(parameter->getParD(lev)->QStress.kN, parameter->getParH(lev)->QStress.kN, mem_size_Q_k, cudaMemcpyHostToDevice)); + checkCudaErrors( cudaMemcpy(parameter->getParD(lev)->QStress.normalX, parameter->getParH(lev)->QStress.normalX, mem_size_Q_q, cudaMemcpyHostToDevice)); + checkCudaErrors( cudaMemcpy(parameter->getParD(lev)->QStress.normalY, parameter->getParH(lev)->QStress.normalY, mem_size_Q_q, cudaMemcpyHostToDevice)); + checkCudaErrors( cudaMemcpy(parameter->getParD(lev)->QStress.normalZ, parameter->getParH(lev)->QStress.normalZ, mem_size_Q_q, cudaMemcpyHostToDevice)); + checkCudaErrors( cudaMemcpy(parameter->getParD(lev)->QStress.Vx, parameter->getParH(lev)->QStress.Vx, mem_size_Q_q, cudaMemcpyHostToDevice)); + checkCudaErrors( cudaMemcpy(parameter->getParD(lev)->QStress.Vy, parameter->getParH(lev)->QStress.Vy, mem_size_Q_q, cudaMemcpyHostToDevice)); + checkCudaErrors( cudaMemcpy(parameter->getParD(lev)->QStress.Vz, parameter->getParH(lev)->QStress.Vz, mem_size_Q_q, cudaMemcpyHostToDevice)); + checkCudaErrors( cudaMemcpy(parameter->getParD(lev)->QStress.Vx1, parameter->getParH(lev)->QStress.Vx1, mem_size_Q_q, cudaMemcpyHostToDevice)); + checkCudaErrors( cudaMemcpy(parameter->getParD(lev)->QStress.Vy1, parameter->getParH(lev)->QStress.Vy1, mem_size_Q_q, cudaMemcpyHostToDevice)); + checkCudaErrors( cudaMemcpy(parameter->getParD(lev)->QStress.Vz1, parameter->getParH(lev)->QStress.Vz1, mem_size_Q_q, cudaMemcpyHostToDevice)); + +} +void CudaMemoryManager::cudaFreeStressBC(int lev) +{ + checkCudaErrors( cudaFreeHost(parameter->getParH(lev)->QStress.q27[0])); + checkCudaErrors( cudaFreeHost(parameter->getParH(lev)->QStress.k)); + checkCudaErrors( cudaFreeHost(parameter->getParH(lev)->QStress.kN)); + checkCudaErrors( cudaFreeHost(parameter->getParH(lev)->QStress.normalX)); + checkCudaErrors( cudaFreeHost(parameter->getParH(lev)->QStress.normalY)); + checkCudaErrors( cudaFreeHost(parameter->getParH(lev)->QStress.normalZ)); + checkCudaErrors( cudaFreeHost(parameter->getParH(lev)->QStress.Vx)); + checkCudaErrors( cudaFreeHost(parameter->getParH(lev)->QStress.Vy)); + checkCudaErrors( cudaFreeHost(parameter->getParH(lev)->QStress.Vz)); + checkCudaErrors( cudaFreeHost(parameter->getParH(lev)->QStress.Vx1)); + checkCudaErrors( cudaFreeHost(parameter->getParH(lev)->QStress.Vy1)); + checkCudaErrors( cudaFreeHost(parameter->getParH(lev)->QStress.Vz1)); +} +// Wall model +void CudaMemoryManager::cudaAllocWallModel(int lev, bool hasWallModelMonitor) +{ + unsigned int mem_size_Q_k = sizeof(int)*parameter->getParH(lev)->QStress.kQ; + unsigned int mem_size_Q_q = sizeof(real)*parameter->getParH(lev)->QStress.kQ; + + //Host + checkCudaErrors( cudaMallocHost((void**) &(parameter->getParH(lev)->wallModel.samplingOffset), mem_size_Q_k )); + checkCudaErrors( cudaMallocHost((void**) &(parameter->getParH(lev)->wallModel.z0), mem_size_Q_q )); + if(hasWallModelMonitor) + { + checkCudaErrors( cudaMallocHost((void**) &(parameter->getParH(lev)->wallModel.u_star), mem_size_Q_q )); + checkCudaErrors( cudaMallocHost((void**) &(parameter->getParH(lev)->wallModel.Fx), mem_size_Q_q )); + checkCudaErrors( cudaMallocHost((void**) &(parameter->getParH(lev)->wallModel.Fy), mem_size_Q_q )); + checkCudaErrors( cudaMallocHost((void**) &(parameter->getParH(lev)->wallModel.Fz), mem_size_Q_q )); + } + + //Device + checkCudaErrors( cudaMalloc((void**) &(parameter->getParD(lev)->wallModel.samplingOffset), mem_size_Q_k)); + checkCudaErrors( cudaMalloc((void**) &(parameter->getParD(lev)->wallModel.z0), mem_size_Q_q)); + if(hasWallModelMonitor) + { + checkCudaErrors( cudaMalloc((void**) &(parameter->getParD(lev)->wallModel.u_star), mem_size_Q_q )); + checkCudaErrors( cudaMalloc((void**) &(parameter->getParD(lev)->wallModel.Fx), mem_size_Q_q )); + checkCudaErrors( cudaMalloc((void**) &(parameter->getParD(lev)->wallModel.Fy), mem_size_Q_q )); + checkCudaErrors( cudaMalloc((void**) &(parameter->getParD(lev)->wallModel.Fz), mem_size_Q_q )); + } + + ////////////////////////////////////////////////////////////////////////// + double tmp = (double)mem_size_Q_k + (double)mem_size_Q_q; + setMemsizeGPU(tmp, false); +} +void CudaMemoryManager::cudaCopyWallModel(int lev, bool hasWallModelMonitor) +{ + unsigned int mem_size_Q_k = sizeof(int)*parameter->getParH(lev)->QStress.kQ; + unsigned int mem_size_Q_q = sizeof(real)*parameter->getParH(lev)->QStress.kQ; + + checkCudaErrors( cudaMemcpy(parameter->getParD(lev)->wallModel.samplingOffset, parameter->getParH(lev)->wallModel.samplingOffset, mem_size_Q_k, cudaMemcpyHostToDevice)); + checkCudaErrors( cudaMemcpy(parameter->getParD(lev)->wallModel.z0, parameter->getParH(lev)->wallModel.z0, mem_size_Q_q, cudaMemcpyHostToDevice)); + if(hasWallModelMonitor) + { + checkCudaErrors( cudaMemcpy(parameter->getParD(lev)->wallModel.u_star, parameter->getParH(lev)->wallModel.u_star, mem_size_Q_k, cudaMemcpyHostToDevice)); + checkCudaErrors( cudaMemcpy(parameter->getParD(lev)->wallModel.Fx, parameter->getParH(lev)->wallModel.Fx, mem_size_Q_q, cudaMemcpyHostToDevice)); + checkCudaErrors( cudaMemcpy(parameter->getParD(lev)->wallModel.Fy, parameter->getParH(lev)->wallModel.Fy, mem_size_Q_q, cudaMemcpyHostToDevice)); + checkCudaErrors( cudaMemcpy(parameter->getParD(lev)->wallModel.Fz, parameter->getParH(lev)->wallModel.Fz, mem_size_Q_q, cudaMemcpyHostToDevice)); + } +} +void CudaMemoryManager::cudaFreeWallModel(int lev, bool hasWallModelMonitor) +{ + checkCudaErrors( cudaFreeHost(parameter->getParH(lev)->wallModel.samplingOffset)); + checkCudaErrors( cudaFreeHost(parameter->getParH(lev)->wallModel.z0)); + if(hasWallModelMonitor) + { + checkCudaErrors( cudaFreeHost(parameter->getParH(lev)->wallModel.u_star)); + checkCudaErrors( cudaFreeHost(parameter->getParH(lev)->wallModel.Fx)); + checkCudaErrors( cudaFreeHost(parameter->getParH(lev)->wallModel.Fy)); + checkCudaErrors( cudaFreeHost(parameter->getParH(lev)->wallModel.Fz)); + } } //Test roundoff error @@ -2814,6 +2956,311 @@ void CudaMemoryManager::cudaFreeFluidNodeIndicesBorder(int lev) { checkCudaErrors(cudaFreeHost(parameter->getParH(lev)->fluidNodeIndicesBorder)); } +//////////////////////////////////////////////////////////////////////////////////// +// ActuatorLine +/////////////////////////////////////////////////////////////////////////////// + +void CudaMemoryManager::cudaAllocBladeRadii(ActuatorLine* actuatorLine) +{ + checkCudaErrors( cudaMallocHost((void**) &actuatorLine->bladeRadiiH, sizeof(real)*actuatorLine->getNBladeNodes()) ); + + checkCudaErrors( cudaMalloc((void**) &actuatorLine->bladeRadiiD, sizeof(real)*actuatorLine->getNBladeNodes()) ); + + setMemsizeGPU(sizeof(real)*actuatorLine->getNBladeNodes(), false); +} + +void CudaMemoryManager::cudaCopyBladeRadiiHtoD(ActuatorLine* actuatorLine) +{ + checkCudaErrors( cudaMemcpy(actuatorLine->bladeRadiiD, actuatorLine->bladeRadiiH, sizeof(real)*actuatorLine->getNBladeNodes(), cudaMemcpyHostToDevice) ); +} + +void CudaMemoryManager::cudaCopyBladeRadiiDtoH(ActuatorLine* actuatorLine) +{ + checkCudaErrors( cudaMemcpy(actuatorLine->bladeRadiiH, actuatorLine->bladeRadiiD, sizeof(real)*actuatorLine->getNBladeNodes(), cudaMemcpyDeviceToHost) ); +} + +void CudaMemoryManager::cudaFreeBladeRadii(ActuatorLine* actuatorLine) +{ + checkCudaErrors( cudaFree(actuatorLine->bladeRadiiD) ); + + checkCudaErrors( cudaFreeHost(actuatorLine->bladeRadiiH) ); +} + +void CudaMemoryManager::cudaAllocBladeCoords(ActuatorLine* actuatorLine) +{ + checkCudaErrors( cudaMallocHost((void**) &actuatorLine->bladeCoordsXH, sizeof(real)*actuatorLine->getNNodes()) ); + checkCudaErrors( cudaMallocHost((void**) &actuatorLine->bladeCoordsYH, sizeof(real)*actuatorLine->getNNodes()) ); + checkCudaErrors( cudaMallocHost((void**) &actuatorLine->bladeCoordsZH, sizeof(real)*actuatorLine->getNNodes()) ); + + checkCudaErrors( cudaMalloc((void**) &actuatorLine->bladeCoordsXD, sizeof(real)*actuatorLine->getNNodes()) ); + checkCudaErrors( cudaMalloc((void**) &actuatorLine->bladeCoordsYD, sizeof(real)*actuatorLine->getNNodes()) ); + checkCudaErrors( cudaMalloc((void**) &actuatorLine->bladeCoordsZD, sizeof(real)*actuatorLine->getNNodes()) ); + + setMemsizeGPU(3.f*actuatorLine->getNNodes(), false); +} + +void CudaMemoryManager::cudaCopyBladeCoordsHtoD(ActuatorLine* actuatorLine) +{ + checkCudaErrors( cudaMemcpy(actuatorLine->bladeCoordsXD, actuatorLine->bladeCoordsXH, sizeof(real)*actuatorLine->getNNodes(), cudaMemcpyHostToDevice) ); + checkCudaErrors( cudaMemcpy(actuatorLine->bladeCoordsYD, actuatorLine->bladeCoordsYH, sizeof(real)*actuatorLine->getNNodes(), cudaMemcpyHostToDevice) ); + checkCudaErrors( cudaMemcpy(actuatorLine->bladeCoordsZD, actuatorLine->bladeCoordsZH, sizeof(real)*actuatorLine->getNNodes(), cudaMemcpyHostToDevice) ); +} + +void CudaMemoryManager::cudaCopyBladeCoordsDtoH(ActuatorLine* actuatorLine) +{ + checkCudaErrors( cudaMemcpy(actuatorLine->bladeCoordsXH, actuatorLine->bladeCoordsXD, sizeof(real)*actuatorLine->getNNodes(), cudaMemcpyDeviceToHost) ); + checkCudaErrors( cudaMemcpy(actuatorLine->bladeCoordsYH, actuatorLine->bladeCoordsYD, sizeof(real)*actuatorLine->getNNodes(), cudaMemcpyDeviceToHost) ); + checkCudaErrors( cudaMemcpy(actuatorLine->bladeCoordsZH, actuatorLine->bladeCoordsZD, sizeof(real)*actuatorLine->getNNodes(), cudaMemcpyDeviceToHost) ); +} + +void CudaMemoryManager::cudaFreeBladeCoords(ActuatorLine* actuatorLine) +{ + checkCudaErrors( cudaFree(actuatorLine->bladeCoordsXD) ); + checkCudaErrors( cudaFree(actuatorLine->bladeCoordsYD) ); + checkCudaErrors( cudaFree(actuatorLine->bladeCoordsZD) ); + + checkCudaErrors( cudaFreeHost(actuatorLine->bladeCoordsXH) ); + checkCudaErrors( cudaFreeHost(actuatorLine->bladeCoordsYH) ); + checkCudaErrors( cudaFreeHost(actuatorLine->bladeCoordsZH) ); +} + +void CudaMemoryManager::cudaAllocBladeIndices(ActuatorLine* actuatorLine) +{ + checkCudaErrors( cudaMallocHost((void**) &actuatorLine->bladeIndicesH, sizeof(uint)*actuatorLine->getNNodes()) ); + + checkCudaErrors( cudaMalloc((void**) &actuatorLine->bladeIndicesD, sizeof(uint)*actuatorLine->getNNodes()) ); + + setMemsizeGPU(sizeof(uint)*actuatorLine->getNNodes(), false); +} + +void CudaMemoryManager::cudaCopyBladeIndicesHtoD(ActuatorLine* actuatorLine) +{ + checkCudaErrors( cudaMemcpy(actuatorLine->bladeIndicesD, actuatorLine->bladeIndicesH, sizeof(uint)*actuatorLine->getNNodes(), cudaMemcpyHostToDevice) ); +} + +void CudaMemoryManager::cudaFreeBladeIndices(ActuatorLine* actuatorLine) +{ + checkCudaErrors( cudaFree(actuatorLine->bladeIndicesD) ); + + checkCudaErrors( cudaFreeHost(actuatorLine->bladeIndicesH) ); +} + +void CudaMemoryManager::cudaAllocBladeVelocities(ActuatorLine* actuatorLine) +{ + checkCudaErrors( cudaMallocHost((void**) &actuatorLine->bladeVelocitiesXH, sizeof(real)*actuatorLine->getNNodes()) ); + checkCudaErrors( cudaMallocHost((void**) &actuatorLine->bladeVelocitiesYH, sizeof(real)*actuatorLine->getNNodes()) ); + checkCudaErrors( cudaMallocHost((void**) &actuatorLine->bladeVelocitiesZH, sizeof(real)*actuatorLine->getNNodes()) ); + + checkCudaErrors( cudaMalloc((void**) &actuatorLine->bladeVelocitiesXD, sizeof(real)*actuatorLine->getNNodes()) ); + checkCudaErrors( cudaMalloc((void**) &actuatorLine->bladeVelocitiesYD, sizeof(real)*actuatorLine->getNNodes()) ); + checkCudaErrors( cudaMalloc((void**) &actuatorLine->bladeVelocitiesZD, sizeof(real)*actuatorLine->getNNodes()) ); + + setMemsizeGPU(3.*sizeof(real)*actuatorLine->getNNodes(), false); +} + +void CudaMemoryManager::cudaCopyBladeVelocitiesHtoD(ActuatorLine* actuatorLine) +{ + checkCudaErrors( cudaMemcpy(actuatorLine->bladeVelocitiesXD, actuatorLine->bladeVelocitiesXH, sizeof(real)*actuatorLine->getNNodes(), cudaMemcpyHostToDevice) ); + checkCudaErrors( cudaMemcpy(actuatorLine->bladeVelocitiesYD, actuatorLine->bladeVelocitiesYH, sizeof(real)*actuatorLine->getNNodes(), cudaMemcpyHostToDevice) ); + checkCudaErrors( cudaMemcpy(actuatorLine->bladeVelocitiesZD, actuatorLine->bladeVelocitiesZH, sizeof(real)*actuatorLine->getNNodes(), cudaMemcpyHostToDevice) ); +} + +void CudaMemoryManager::cudaCopyBladeVelocitiesDtoH(ActuatorLine* actuatorLine) +{ + checkCudaErrors( cudaMemcpy(actuatorLine->bladeVelocitiesXH, actuatorLine->bladeVelocitiesXD, sizeof(real)*actuatorLine->getNNodes(), cudaMemcpyDeviceToHost) ); + checkCudaErrors( cudaMemcpy(actuatorLine->bladeVelocitiesYH, actuatorLine->bladeVelocitiesYD, sizeof(real)*actuatorLine->getNNodes(), cudaMemcpyDeviceToHost) ); + checkCudaErrors( cudaMemcpy(actuatorLine->bladeVelocitiesZH, actuatorLine->bladeVelocitiesZD, sizeof(real)*actuatorLine->getNNodes(), cudaMemcpyDeviceToHost) ); +} + +void CudaMemoryManager::cudaFreeBladeVelocities(ActuatorLine* actuatorLine) +{ + checkCudaErrors( cudaFree(actuatorLine->bladeVelocitiesXD) ); + checkCudaErrors( cudaFree(actuatorLine->bladeVelocitiesYD) ); + checkCudaErrors( cudaFree(actuatorLine->bladeVelocitiesZD) ); + + checkCudaErrors( cudaFreeHost(actuatorLine->bladeVelocitiesXH) ); + checkCudaErrors( cudaFreeHost(actuatorLine->bladeVelocitiesYH) ); + checkCudaErrors( cudaFreeHost(actuatorLine->bladeVelocitiesZH) ); +} + +void CudaMemoryManager::cudaAllocBladeForces(ActuatorLine* actuatorLine) +{ + checkCudaErrors( cudaMallocHost((void**) &actuatorLine->bladeForcesXH, sizeof(real)*actuatorLine->getNNodes()) ); + checkCudaErrors( cudaMallocHost((void**) &actuatorLine->bladeForcesYH, sizeof(real)*actuatorLine->getNNodes()) ); + checkCudaErrors( cudaMallocHost((void**) &actuatorLine->bladeForcesZH, sizeof(real)*actuatorLine->getNNodes()) ); + + checkCudaErrors( cudaMalloc((void**) &actuatorLine->bladeForcesXD, sizeof(real)*actuatorLine->getNNodes()) ); + checkCudaErrors( cudaMalloc((void**) &actuatorLine->bladeForcesYD, sizeof(real)*actuatorLine->getNNodes()) ); + checkCudaErrors( cudaMalloc((void**) &actuatorLine->bladeForcesZD, sizeof(real)*actuatorLine->getNNodes()) ); + + setMemsizeGPU(3.*sizeof(real)*actuatorLine->getNNodes(), false); +} + +void CudaMemoryManager::cudaCopyBladeForcesHtoD(ActuatorLine* actuatorLine) +{ + checkCudaErrors( cudaMemcpy(actuatorLine->bladeForcesXD, actuatorLine->bladeForcesXH, sizeof(real)*actuatorLine->getNNodes(), cudaMemcpyHostToDevice) ); + checkCudaErrors( cudaMemcpy(actuatorLine->bladeForcesYD, actuatorLine->bladeForcesYH, sizeof(real)*actuatorLine->getNNodes(), cudaMemcpyHostToDevice) ); + checkCudaErrors( cudaMemcpy(actuatorLine->bladeForcesZD, actuatorLine->bladeForcesZH, sizeof(real)*actuatorLine->getNNodes(), cudaMemcpyHostToDevice) ); +} + +void CudaMemoryManager::cudaCopyBladeForcesDtoH(ActuatorLine* actuatorLine) +{ + checkCudaErrors( cudaMemcpy(actuatorLine->bladeForcesXH, actuatorLine->bladeForcesXD, sizeof(real)*actuatorLine->getNNodes(), cudaMemcpyDeviceToHost) ); + checkCudaErrors( cudaMemcpy(actuatorLine->bladeForcesYH, actuatorLine->bladeForcesYD, sizeof(real)*actuatorLine->getNNodes(), cudaMemcpyDeviceToHost) ); + checkCudaErrors( cudaMemcpy(actuatorLine->bladeForcesZH, actuatorLine->bladeForcesZD, sizeof(real)*actuatorLine->getNNodes(), cudaMemcpyDeviceToHost) ); +} + +void CudaMemoryManager::cudaFreeBladeForces(ActuatorLine* actuatorLine) +{ + checkCudaErrors( cudaFree(actuatorLine->bladeForcesXD) ); + checkCudaErrors( cudaFree(actuatorLine->bladeForcesYD) ); + checkCudaErrors( cudaFree(actuatorLine->bladeForcesZD) ); + + checkCudaErrors( cudaFreeHost(actuatorLine->bladeForcesXH) ); + checkCudaErrors( cudaFreeHost(actuatorLine->bladeForcesYH) ); + checkCudaErrors( cudaFreeHost(actuatorLine->bladeForcesZH) ); +} + +void CudaMemoryManager::cudaAllocSphereIndices(ActuatorLine* actuatorLine) +{ + checkCudaErrors( cudaMallocHost((void**) &(actuatorLine->boundingSphereIndicesH), sizeof(int)*actuatorLine->getNIndices())); + checkCudaErrors( cudaMalloc((void**) &(actuatorLine->boundingSphereIndicesD), sizeof(int)*actuatorLine->getNIndices())); + setMemsizeGPU(sizeof(int)*actuatorLine->getNIndices(), false); +} + +void CudaMemoryManager::cudaCopySphereIndicesHtoD(ActuatorLine* actuatorLine) +{ + checkCudaErrors( cudaMemcpy(actuatorLine->boundingSphereIndicesD, actuatorLine->boundingSphereIndicesH, sizeof(int)*actuatorLine->getNIndices(), cudaMemcpyHostToDevice) ); +} + +void CudaMemoryManager::cudaFreeSphereIndices(ActuatorLine* actuatorLine) +{ + checkCudaErrors( cudaFreeHost(actuatorLine->boundingSphereIndicesH) ); + checkCudaErrors( cudaFree(actuatorLine->boundingSphereIndicesD) ); +} + +//////////////////////////////////////////////////////////////////////////////////// +// Probe +/////////////////////////////////////////////////////////////////////////////// + +void CudaMemoryManager::cudaAllocProbeDistances(Probe* probe, int level) +{ + size_t tmp = sizeof(real)*probe->getProbeStruct(level)->nPoints; + + checkCudaErrors( cudaMallocHost((void**) &probe->getProbeStruct(level)->distXH, tmp) ); + checkCudaErrors( cudaMallocHost((void**) &probe->getProbeStruct(level)->distYH, tmp) ); + checkCudaErrors( cudaMallocHost((void**) &probe->getProbeStruct(level)->distZH, tmp) ); + + checkCudaErrors( cudaMalloc ((void**) &probe->getProbeStruct(level)->distXD, tmp) ); + checkCudaErrors( cudaMalloc ((void**) &probe->getProbeStruct(level)->distYD, tmp) ); + checkCudaErrors( cudaMalloc ((void**) &probe->getProbeStruct(level)->distZD, tmp) ); + setMemsizeGPU(3.f*tmp, false); +} +void CudaMemoryManager::cudaCopyProbeDistancesHtoD(Probe* probe, int level) +{ + size_t tmp = sizeof(real)*probe->getProbeStruct(level)->nPoints; + + checkCudaErrors( cudaMemcpy(probe->getProbeStruct(level)->distXD, probe->getProbeStruct(level)->distXH, tmp, cudaMemcpyHostToDevice) ); + checkCudaErrors( cudaMemcpy(probe->getProbeStruct(level)->distYD, probe->getProbeStruct(level)->distYH, tmp, cudaMemcpyHostToDevice) ); + checkCudaErrors( cudaMemcpy(probe->getProbeStruct(level)->distZD, probe->getProbeStruct(level)->distZH, tmp, cudaMemcpyHostToDevice) ); +} +void CudaMemoryManager::cudaCopyProbeDistancesDtoH(Probe* probe, int level) +{ + size_t tmp = sizeof(real)*probe->getProbeStruct(level)->nPoints; + + checkCudaErrors( cudaMemcpy(probe->getProbeStruct(level)->distXH, probe->getProbeStruct(level)->distXD, tmp, cudaMemcpyDeviceToHost) ); + checkCudaErrors( cudaMemcpy(probe->getProbeStruct(level)->distYH, probe->getProbeStruct(level)->distXD, tmp, cudaMemcpyDeviceToHost) ); + checkCudaErrors( cudaMemcpy(probe->getProbeStruct(level)->distZH, probe->getProbeStruct(level)->distXD, tmp, cudaMemcpyDeviceToHost) ); +} +void CudaMemoryManager::cudaFreeProbeDistances(Probe* probe, int level) +{ + checkCudaErrors( cudaFreeHost(probe->getProbeStruct(level)->distXH) ); + checkCudaErrors( cudaFreeHost(probe->getProbeStruct(level)->distYH) ); + checkCudaErrors( cudaFreeHost(probe->getProbeStruct(level)->distZH) ); + + checkCudaErrors( cudaFree (probe->getProbeStruct(level)->distXD) ); + checkCudaErrors( cudaFree (probe->getProbeStruct(level)->distYD) ); + checkCudaErrors( cudaFree (probe->getProbeStruct(level)->distZD) ); +} + +void CudaMemoryManager::cudaAllocProbeIndices(Probe* probe, int level) +{ + size_t tmp = sizeof(int)*probe->getProbeStruct(level)->nIndices; + checkCudaErrors( cudaMallocHost((void**) &probe->getProbeStruct(level)->pointIndicesH, tmp) ); + checkCudaErrors( cudaMalloc ((void**) &probe->getProbeStruct(level)->pointIndicesD, tmp) ); + setMemsizeGPU(1.f*tmp, false); +} +void CudaMemoryManager::cudaCopyProbeIndicesHtoD(Probe* probe, int level) +{ + checkCudaErrors( cudaMemcpy(probe->getProbeStruct(level)->pointIndicesD, probe->getProbeStruct(level)->pointIndicesH, sizeof(int)*probe->getProbeStruct(level)->nIndices, cudaMemcpyHostToDevice) ); +} +void CudaMemoryManager::cudaCopyProbeIndicesDtoH(Probe* probe, int level) +{ + checkCudaErrors( cudaMemcpy(probe->getProbeStruct(level)->pointIndicesH, probe->getProbeStruct(level)->pointIndicesD, sizeof(int)*probe->getProbeStruct(level)->nIndices, cudaMemcpyDeviceToHost) ); +} +void CudaMemoryManager::cudaFreeProbeIndices(Probe* probe, int level) +{ + checkCudaErrors( cudaFreeHost(probe->getProbeStruct(level)->pointIndicesH) ); + checkCudaErrors( cudaFree (probe->getProbeStruct(level)->pointIndicesD) ); +} + +void CudaMemoryManager::cudaAllocProbeQuantityArray(Probe* probe, int level) +{ + size_t tmp = sizeof(real)*probe->getProbeStruct(level)->nArrays*probe->getProbeStruct(level)->nPoints; + + checkCudaErrors( cudaMallocHost((void**) &probe->getProbeStruct(level)->quantitiesArrayH, tmp) ); + if(probe->getHasDeviceQuantityArray()) + { + checkCudaErrors( cudaMalloc ((void**) &probe->getProbeStruct(level)->quantitiesArrayD, tmp) ); + setMemsizeGPU(1.f*tmp, false); + } +} + +void CudaMemoryManager::cudaCopyProbeQuantityArrayHtoD(Probe* probe, int level) +{ + checkCudaErrors( cudaMemcpy(probe->getProbeStruct(level)->quantitiesArrayD, probe->getProbeStruct(level)->quantitiesArrayH, probe->getProbeStruct(level)->nArrays*sizeof(real)*probe->getProbeStruct(level)->nPoints, cudaMemcpyHostToDevice) ); +} +void CudaMemoryManager::cudaCopyProbeQuantityArrayDtoH(Probe* probe, int level) +{ + checkCudaErrors( cudaMemcpy(probe->getProbeStruct(level)->quantitiesArrayH, probe->getProbeStruct(level)->quantitiesArrayD, probe->getProbeStruct(level)->nArrays*sizeof(real)*probe->getProbeStruct(level)->nPoints, cudaMemcpyDeviceToHost) ); +} +void CudaMemoryManager::cudaFreeProbeQuantityArray(Probe* probe, int level) +{ + checkCudaErrors( cudaFreeHost(probe->getProbeStruct(level)->quantitiesArrayH) ); + if(probe->getHasDeviceQuantityArray()) + checkCudaErrors( cudaFree (probe->getProbeStruct(level)->quantitiesArrayD) ); +} + +void CudaMemoryManager::cudaAllocProbeQuantitiesAndOffsets(Probe* probe, int level) +{ + size_t tmpA = int(Statistic::LAST)*sizeof(int); + size_t tmpQ = int(Statistic::LAST)*sizeof(bool); + checkCudaErrors( cudaMallocHost((void**) &probe->getProbeStruct(level)->quantitiesH, tmpQ) ); + checkCudaErrors( cudaMalloc ((void**) &probe->getProbeStruct(level)->quantitiesD, tmpQ) ); + checkCudaErrors( cudaMallocHost((void**) &probe->getProbeStruct(level)->arrayOffsetsH, tmpA) ); + checkCudaErrors( cudaMalloc ((void**) &probe->getProbeStruct(level)->arrayOffsetsD, tmpA) ); + setMemsizeGPU(tmpA+tmpQ, false); +} + +void CudaMemoryManager::cudaCopyProbeQuantitiesAndOffsetsHtoD(Probe* probe, int level) +{ + checkCudaErrors( cudaMemcpy(probe->getProbeStruct(level)->quantitiesD, probe->getProbeStruct(level)->quantitiesH, int(Statistic::LAST)*sizeof(bool), cudaMemcpyHostToDevice) ); + checkCudaErrors( cudaMemcpy(probe->getProbeStruct(level)->arrayOffsetsD, probe->getProbeStruct(level)->arrayOffsetsH, int(Statistic::LAST)*sizeof(int), cudaMemcpyHostToDevice) ); +} + +void CudaMemoryManager::cudaCopyProbeQuantitiesAndOffsetsDtoH(Probe* probe, int level) +{ + checkCudaErrors( cudaMemcpy(probe->getProbeStruct(level)->quantitiesH, probe->getProbeStruct(level)->quantitiesD, int(Statistic::LAST)*sizeof(bool), cudaMemcpyDeviceToHost) ); + checkCudaErrors( cudaMemcpy(probe->getProbeStruct(level)->arrayOffsetsH, probe->getProbeStruct(level)->arrayOffsetsD, int(Statistic::LAST)*sizeof(int), cudaMemcpyDeviceToHost) ); +} +void CudaMemoryManager::cudaFreeProbeQuantitiesAndOffsets(Probe* probe, int level) +{ + checkCudaErrors( cudaFreeHost(probe->getProbeStruct(level)->quantitiesH) ); + checkCudaErrors( cudaFreeHost(probe->getProbeStruct(level)->arrayOffsetsH) ); + checkCudaErrors( cudaFree (probe->getProbeStruct(level)->quantitiesD) ); + checkCudaErrors( cudaFree (probe->getProbeStruct(level)->arrayOffsetsD) ); +} + @@ -2852,7 +3299,7 @@ void CudaMemoryManager::setMemsizeGPU(double admem, bool reset) double CudaMemoryManager::getMemsizeGPU() { - return memsizeGPU; + return this->memsizeGPU; } CudaMemoryManager::CudaMemoryManager(std::shared_ptr<Parameter> parameter) diff --git a/src/gpu/VirtualFluids_GPU/GPU/CudaMemoryManager.h b/src/gpu/VirtualFluids_GPU/GPU/CudaMemoryManager.h index 3d7d39d85138b2661960cbf822756421380bfd0c..2f580435c14807371907bdf3450364419dcf8735 100644 --- a/src/gpu/VirtualFluids_GPU/GPU/CudaMemoryManager.h +++ b/src/gpu/VirtualFluids_GPU/GPU/CudaMemoryManager.h @@ -18,6 +18,8 @@ class Parameter; class PorousMedia; +class ActuatorLine; +class Probe; class VIRTUALFLUIDS_GPU_EXPORT CudaMemoryManager { @@ -175,6 +177,14 @@ public: void cudaAllocSlipBC(int lev); void cudaCopySlipBC(int lev); void cudaFreeSlipBC(int lev); + + void cudaAllocStressBC(int lev); + void cudaCopyStressBC(int lev); + void cudaFreeStressBC(int lev); + + void cudaAllocWallModel(int lev, bool hasWallModelMonitor); + void cudaCopyWallModel(int lev, bool hasWallModelMonitor); + void cudaFreeWallModel(int lev, bool hasWallModelMonitor); void cudaAllocGeomValuesBC(int lev); void cudaCopyGeomValuesBC(int lev); @@ -340,18 +350,63 @@ public: void cudaFreeFluidNodeIndices(int lev); void cudaAllocFluidNodeIndicesBorder(int lev); void cudaCopyFluidNodeIndicesBorder(int lev); - void cudaFreeFluidNodeIndicesBorder(int lev); - - - - - + void cudaFreeFluidNodeIndicesBorder(int lev); + + // Actuator Line + void cudaAllocBladeRadii(ActuatorLine* actuatorLine); + void cudaCopyBladeRadiiHtoD(ActuatorLine* actuatorLine); + void cudaCopyBladeRadiiDtoH(ActuatorLine* actuatorLine); + void cudaFreeBladeRadii(ActuatorLine* actuatorLine); + + void cudaAllocBladeCoords(ActuatorLine* actuatorLine); + void cudaCopyBladeCoordsHtoD(ActuatorLine* actuatorLine); + void cudaCopyBladeCoordsDtoH(ActuatorLine* actuatorLine); + void cudaFreeBladeCoords(ActuatorLine* actuatorLine); + + void cudaAllocBladeIndices(ActuatorLine* actuatorLine); + void cudaCopyBladeIndicesHtoD(ActuatorLine* actuatorLine); + void cudaFreeBladeIndices(ActuatorLine* actuatorLine); + + void cudaAllocBladeVelocities(ActuatorLine* actuatorLine); + void cudaCopyBladeVelocitiesHtoD(ActuatorLine* actuatorLine); + void cudaCopyBladeVelocitiesDtoH(ActuatorLine* actuatorLine); + void cudaFreeBladeVelocities(ActuatorLine* actuatorLine); + + void cudaAllocBladeForces(ActuatorLine* actuatorLine); + void cudaCopyBladeForcesHtoD(ActuatorLine* actuatorLine); + void cudaCopyBladeForcesDtoH(ActuatorLine* actuatorLine); + void cudaFreeBladeForces(ActuatorLine* actuatorLine); + + void cudaAllocSphereIndices(ActuatorLine* actuatorLine); + void cudaCopySphereIndicesHtoD(ActuatorLine* actuatorLine); + void cudaFreeSphereIndices(ActuatorLine* actuatorLine); + + void cudaAllocProbeDistances(Probe* probe, int level); + void cudaCopyProbeDistancesHtoD(Probe* probe, int level); + void cudaCopyProbeDistancesDtoH(Probe* probe, int level); + void cudaFreeProbeDistances(Probe* probe, int level); + + void cudaAllocProbeIndices(Probe* probe, int level); + void cudaCopyProbeIndicesHtoD(Probe* probe, int level); + void cudaCopyProbeIndicesDtoH(Probe* probe, int level); + void cudaFreeProbeIndices(Probe* probe, int level); + + void cudaAllocProbeQuantityArray(Probe* probe, int level); + void cudaCopyProbeQuantityArrayHtoD(Probe* probe, int level); + void cudaCopyProbeQuantityArrayDtoH(Probe* probe, int level); + void cudaFreeProbeQuantityArray(Probe* probe, int level); + + void cudaAllocProbeQuantitiesAndOffsets(Probe* probe, int level); + void cudaCopyProbeQuantitiesAndOffsetsHtoD(Probe* probe, int level); + void cudaCopyProbeQuantitiesAndOffsetsDtoH(Probe* probe, int level); + void cudaFreeProbeQuantitiesAndOffsets(Probe* probe, int level); + private: CudaMemoryManager(std::shared_ptr<Parameter> parameter); CudaMemoryManager(const CudaMemoryManager&); std::shared_ptr<Parameter> parameter; - double memsizeGPU; + double memsizeGPU = 0.; }; #endif diff --git a/src/gpu/VirtualFluids_GPU/GPU/GPU_Interface.h b/src/gpu/VirtualFluids_GPU/GPU/GPU_Interface.h index 93e78c82bf149a5b5398f145dbed86cde2302ea5..18e26b87ce7831c6394b852a593b744b29f4afae 100644 --- a/src/gpu/VirtualFluids_GPU/GPU/GPU_Interface.h +++ b/src/gpu/VirtualFluids_GPU/GPU/GPU_Interface.h @@ -966,6 +966,8 @@ extern "C" void QSlipDevComp27(unsigned int numberOfThreads, unsigned int* neighborX, unsigned int* neighborY, unsigned int* neighborZ, + real* turbViscosity, + bool useTurbViscosity, unsigned int size_Mat, bool evenOrOdd); @@ -999,6 +1001,70 @@ extern "C" void QSlipNormDevComp27(unsigned int numberOfThreads, unsigned int size_Mat, bool evenOrOdd); +extern "C" void QStressDevComp27(unsigned int numberOfThreads, + real* DD, + int* k_Q, + int* k_N, + real* QQ, + unsigned int sizeQ, + real om1, + real* turbViscosity, + real* vx, + real* vy, + real* vz, + real* normalX, + real* normalY, + real* normalZ, + real* vx_el, + real* vy_el, + real* vz_el, + real* vx_w_mean, + real* vy_w_mean, + real* vz_w_mean, + int* samplingOffset, + real* z0, + bool hasWallModelMonitor, + real* u_star, + real* Fx, + real* Fy, + real* Fz, + unsigned int* neighborX, + unsigned int* neighborY, + unsigned int* neighborZ, + unsigned int size_Mat, + bool evenOrOdd); + +extern "C" void BBStressDev27( unsigned int numberOfThreads, + real* DD, + int* k_Q, + int* k_N, + real* QQ, + unsigned int sizeQ, + real* vx, + real* vy, + real* vz, + real* normalX, + real* normalY, + real* normalZ, + real* vx_el, + real* vy_el, + real* vz_el, + real* vx_w_mean, + real* vy_w_mean, + real* vz_w_mean, + int* samplingOffset, + real* z0, + bool hasWallModelMonitor, + real* u_star, + real* Fx, + real* Fy, + real* Fz, + unsigned int* neighborX, + unsigned int* neighborY, + unsigned int* neighborZ, + unsigned int size_Mat, + bool evenOrOdd); + extern "C" void QPressDev27(unsigned int numberOfThreads, int nx, int ny, diff --git a/src/gpu/VirtualFluids_GPU/GPU/GPU_Kernels.cuh b/src/gpu/VirtualFluids_GPU/GPU/GPU_Kernels.cuh index c1e4ce45b8e4ccf70f084eb7742fcf9d1bfdb47f..380f8d3871df7f459a9cc2c885bab0e82c01835d 100644 --- a/src/gpu/VirtualFluids_GPU/GPU/GPU_Kernels.cuh +++ b/src/gpu/VirtualFluids_GPU/GPU/GPU_Kernels.cuh @@ -916,6 +916,18 @@ extern "C" __global__ void QSlipDeviceComp27(real* DD, unsigned int size_Mat, bool evenOrOdd); +extern "C" __global__ void QSlipDeviceComp27TurbViscosity(real* DD, + int* k_Q, + real* QQ, + unsigned int sizeQ, + real om1, + unsigned int* neighborX, + unsigned int* neighborY, + unsigned int* neighborZ, + real* turbViscosity, + unsigned int size_Mat, + bool evenOrOdd); + extern "C" __global__ void QSlipGeomDeviceComp27(real* DD, int* k_Q, real* QQ, @@ -944,6 +956,69 @@ extern "C" __global__ void QSlipNormDeviceComp27(real* DD, unsigned int size_Mat, bool evenOrOdd); +// Stress BCs (wall model) +extern "C" __global__ void QStressDeviceComp27(real* DD, + int* k_Q, + int* k_N, + real* QQ, + unsigned int sizeQ, + real om1, + real* turbViscosity, + real* vx, + real* vy, + real* vz, + real* normalX, + real* normalY, + real* normalZ, + real* vx_bc, + real* vy_bc, + real* vz_bc, + real* vx1, + real* vy1, + real* vz1, + int* samplingOffset, + real* z0, + bool hasWallModelMonitor, + real* u_star_monitor, + real* Fx_monitor, + real* Fy_monitor, + real* Fz_monitor, + unsigned int* neighborX, + unsigned int* neighborY, + unsigned int* neighborZ, + unsigned int size_Mat, + bool evenOrOdd); + +extern "C" __global__ void BBStressDevice27( real* DD, + int* k_Q, + int* k_N, + real* QQ, + unsigned int sizeQ, + real* vx, + real* vy, + real* vz, + real* normalX, + real* normalY, + real* normalZ, + real* vx_bc, + real* vy_bc, + real* vz_bc, + real* vx1, + real* vy1, + real* vz1, + int* samplingOffset, + real* z0, + bool hasWallModelMonitor, + real* u_star_monitor, + real* Fx_monitor, + real* Fy_monitor, + real* Fz_monitor, + unsigned int* neighborX, + unsigned int* neighborY, + unsigned int* neighborZ, + unsigned int size_Mat, + bool evenOrOdd); + //Pressure BCs extern "C" __global__ void QPressDevice27(int inx, int iny, diff --git a/src/gpu/VirtualFluids_GPU/GPU/GeometryUtils.h b/src/gpu/VirtualFluids_GPU/GPU/GeometryUtils.h new file mode 100644 index 0000000000000000000000000000000000000000..da438ab0fdb04c8a83bd37700b4e4735970bcd7d --- /dev/null +++ b/src/gpu/VirtualFluids_GPU/GPU/GeometryUtils.h @@ -0,0 +1,203 @@ +#ifndef _GEOMETRYUTILS_H +#define _GEOMETRYUTILS_H + +__inline__ __host__ __device__ void getNeighborIndicesOfBSW( uint k, //index of BSW node + uint &ke, uint &kn, uint &kt, uint &kne, uint &kte,uint &ktn, uint &ktne, + uint* neighborX, uint* neighborY, uint* neighborZ) +{ + ke = neighborX[k]; + kn = neighborY[k]; + kt = neighborZ[k]; + kne = neighborY[ke]; + kte = neighborZ[ke]; + ktn = neighborZ[kn]; + ktne = neighborX[ktn]; +} + +__inline__ __host__ __device__ uint findNearestCellBSW(uint index, + real* coordsX, real* coordsY, real* coordsZ, + real posX, real posY, real posZ, + uint* neighborsX, uint* neighborsY, uint* neighborsZ, uint* neighborsWSB) +{ + uint new_index = index; + + while(coordsX[new_index] > posX && coordsY[new_index] > posY && coordsZ[new_index] > posZ ){ new_index = max(1, neighborsWSB[new_index]);} + + while(coordsX[new_index] > posX && coordsY[new_index] > posY ){ new_index = max(1, neighborsZ[neighborsWSB[new_index]]);} + while(coordsX[new_index] > posX && coordsZ[new_index] > posZ ){ new_index = max(1, neighborsY[neighborsWSB[new_index]]);} + while(coordsY[new_index] > posY && coordsZ[new_index] > posZ ){ new_index = max(1, neighborsX[neighborsWSB[new_index]]);} + + while(coordsX[new_index] > posX){ new_index = max(1, neighborsY[neighborsZ[neighborsWSB[new_index]]]);} + while(coordsY[new_index] > posY){ new_index = max(1, neighborsX[neighborsZ[neighborsWSB[new_index]]]);} + while(coordsZ[new_index] > posZ){ new_index = max(1, neighborsX[neighborsY[neighborsWSB[new_index]]]);} + + while(coordsX[new_index] < posX){ new_index = max(1, neighborsX[new_index]);} + while(coordsY[new_index] < posY){ new_index = max(1, neighborsY[new_index]);} + while(coordsZ[new_index] < posZ){ new_index = max(1, neighborsZ[new_index]);} + + return neighborsWSB[new_index]; +} + +__inline__ __host__ __device__ void getInterpolationWeights(real &dW, real &dE, real &dN, real &dS, real &dT, real &dB, + real tmpX, real tmpY, real tmpZ) +{ + dW = tmpX; + dE = 1.f - dW; + dS = tmpY; + dN = 1.f - dS; + dB = tmpZ; + dT = 1.f - dB; +} + +__inline__ __host__ __device__ real trilinearInterpolation( real dW, real dE, real dN, real dS, real dT, real dB, + uint k, uint ke, uint kn, uint kt, uint kne, uint kte, uint ktn, uint ktne, + real* quantity ) +{ + real interpolatedValue = ( dE*dN*dT*quantity[k] + dW*dN*dT*quantity[ke] + + dE*dS*dT*quantity[kn] + dW*dS*dT*quantity[kne] + + dE*dN*dB*quantity[kt] + dW*dN*dB*quantity[kte] + + dE*dS*dB*quantity[ktn] + dW*dS*dB*quantity[ktne] ); + return interpolatedValue; +} + +__inline__ __host__ __device__ void translate2D(real &posX, real &posY, real &newPosX, real &newPosY, real &translationX, real &translationY) +{ + newPosX = posX + translationX; + newPosY = posY + translationY; +} + +__inline__ __host__ __device__ void invTranslate2D(real &posX, real &posY, real &newPosX, real &newPosY, real &translationX, real &translationY) +{ + newPosX = posX - translationX; + newPosY = posY - translationY; +} + +__inline__ __host__ __device__ void translate3D(real &posX, real &posY, real &posZ, real &newPosX, real &newPosY, real &newPosZ, real &translationX, real &translationY, real &translationZ) +{ + newPosX = posX + translationX; + newPosY = posY + translationY; + newPosZ = posZ + translationZ; +} + +__inline__ __host__ __device__ void invTranslate3D(real &posX, real &posY, real &posZ, real &newPosX, real &newPosY, real &newPosZ, real &translationX, real &translationY, real &translationZ) +{ + newPosX = posX - translationX; + newPosY = posY - translationY; + newPosZ = posZ - translationZ; +} + +__inline__ __host__ __device__ void rotate2D(real &angle, real &posX, real &posY, real &newPosX, real &newPosY) +{ + newPosX = posX*cos(angle) - posY*sin(angle); + newPosY = posX*sin(angle) + posY*cos(angle); +} + +__inline__ __host__ __device__ void rotate2D(real &angle, real &posX, real &posY, real &newPosX, real &newPosY, real &originX, real &originY) +{ + real tmpX, tmpY; + invTranslate2D(posX, posY, newPosX, newPosY, originX, originY); + rotate2D(angle, newPosX, newPosY, tmpX, tmpY); + translate2D(tmpX, tmpY, newPosX, newPosY, originX, originY); +} + +__inline__ __host__ __device__ void invRotate2D(real &angle, real &posX, real &posY, real &newPosX, real &newPosY) +{ + newPosX = posX*cos(angle) + posY*sin(angle); + newPosY = -posX*sin(angle) + posY*cos(angle); +} + +__inline__ __host__ __device__ void invRotate2D(real &angle, real &posX, real &posY, real &newPosX, real &newPosY, real &originX, real &originY) +{ + real tmpX, tmpY; + invTranslate2D(posX, posY, newPosX, newPosY, originX, originY); + invRotate2D(angle, newPosX, newPosY, tmpX, tmpY); + translate2D(tmpX, tmpY, newPosX, newPosY, originX, originY); +} + +__inline__ __host__ __device__ void rotateAboutX3D(real &angle, real &posX, real &posY, real &posZ, real &newPosX, real &newPosY, real &newPosZ) +{ + newPosX = posX; + rotate2D(angle, posY, posZ, newPosY, newPosZ); +} + +__inline__ __host__ __device__ void rotateAboutX3D(real &angle, real &posX, real &posY, real &posZ, real &newPosX, real &newPosY, real &newPosZ, real &originX, real &originY, real &originZ) +{ + real tmpX, tmpY, tmpZ; + invTranslate3D(posX, posY, posZ, newPosX, newPosY, newPosZ, originX, originY, originZ); + rotateAboutX3D(angle, newPosX, newPosY, newPosZ, tmpX, tmpY, tmpZ); + translate3D(tmpX, tmpY, tmpZ, newPosX, newPosY, newPosZ, originX, originY, originZ); +} + +__inline__ __host__ __device__ void invRotateAboutX3D(real &angle, real &posX, real &posY, real &posZ, real &newPosX, real &newPosY, real &newPosZ) +{ + newPosX = posX; + invRotate2D(angle, posY, posZ, newPosY, newPosZ); +} + +__inline__ __host__ __device__ void invRotateAboutX3D(real &angle, real &posX, real &posY, real &posZ, real &newPosX, real &newPosY, real &newPosZ, real &originX, real &originY, real &originZ) +{ + real tmpX, tmpY, tmpZ; + invTranslate3D(posX, posY, posZ, newPosX, newPosY, newPosZ, originX, originY, originZ); + invRotateAboutX3D(angle, newPosX, newPosY, newPosZ, tmpX, tmpY, tmpZ); + translate3D(tmpX, tmpY, tmpZ, newPosX, newPosY, newPosZ, originX, originY, originZ); +} + +__inline__ __host__ __device__ void rotateAboutY3D(real &angle, real &posX, real &posY, real &posZ, real &newPosX, real &newPosY, real &newPosZ) +{ + newPosY = posY; + rotate2D(angle, posX, posZ, newPosX, newPosZ); +} + +__inline__ __host__ __device__ void rotateAboutY3D(real &angle, real &posX, real &posY, real &posZ, real &newPosX, real &newPosY, real &newPosZ, real &originX, real &originY, real &originZ) +{ + real tmpX, tmpY, tmpZ; + invTranslate3D(posX, posY, posZ, newPosX, newPosY, newPosZ, originX, originY, originZ); + rotateAboutY3D(angle, newPosX, newPosY, newPosZ, tmpX, tmpY, tmpZ); + translate3D(tmpX, tmpY, tmpZ, newPosX, newPosY, newPosZ, originX, originY, originZ); +} + +__inline__ __host__ __device__ void invRotateAboutY3D(real &angle, real &posX, real &posY, real &posZ, real &newPosX, real &newPosY, real &newPosZ) +{ + newPosY = posY; + invRotate2D(angle, posX, posZ, newPosX, newPosZ); +} + +__inline__ __host__ __device__ void invRotateAboutY3D(real &angle, real &posX, real &posY, real &posZ, real &newPosX, real &newPosY, real &newPosZ, real &originX, real &originY, real &originZ) +{ + real tmpX, tmpY, tmpZ; + invTranslate3D(posX, posY, posZ, newPosX, newPosY, newPosZ, originX, originY, originZ); + invRotateAboutY3D(angle, newPosX, newPosY, newPosZ, tmpX, tmpY, tmpZ); + translate3D(tmpX, tmpY, tmpZ, newPosX, newPosY, newPosZ, originX, originY, originZ); +} + + +__inline__ __host__ __device__ void rotateAboutZ3D(real &angle, real &posX, real &posY, real &posZ, real &newPosX, real &newPosY, real &newPosZ) +{ + newPosZ = posZ; + rotate2D(angle, posX, posY, newPosX, newPosY); +} + +__inline__ __host__ __device__ void rotateAboutZ3D(real &angle, real &posX, real &posY, real &posZ, real &newPosX, real &newPosY, real &newPosZ, real &originX, real &originY, real &originZ) +{ + real tmpX, tmpY, tmpZ; + invTranslate3D(posX, posY, posZ, newPosX, newPosY, newPosZ, originX, originY, originZ); + rotateAboutZ3D(angle, newPosX, newPosY, newPosZ, tmpX, tmpY, tmpZ); + translate3D(tmpX, tmpY, tmpZ, newPosX, newPosY, newPosZ, originX, originY, originZ); +} + +__inline__ __host__ __device__ void invRotateAboutZ3D(real &angle, real &posX, real &posY, real &posZ, real &newPosX, real &newPosY, real &newPosZ) +{ + newPosZ = posZ; + invRotate2D(angle, posX, posY, newPosX, newPosY); +} + +__inline__ __host__ __device__ void invRotateAboutZ3D(real &angle, real &posX, real &posY, real &posZ, real &newPosX, real &newPosY, real &newPosZ, real &originX, real &originY, real &originZ) +{ + real tmpX, tmpY, tmpZ; + invTranslate3D(posX, posY, posZ, newPosX, newPosY, newPosZ, originX, originY, originZ); + invRotateAboutZ3D(angle, newPosX, newPosY, newPosZ, tmpX, tmpY, tmpZ); + translate3D(tmpX, tmpY, tmpZ, newPosX, newPosY, newPosZ, originX, originY, originZ); +} + + +#endif \ No newline at end of file diff --git a/src/gpu/VirtualFluids_GPU/GPU/LBMKernel.cu b/src/gpu/VirtualFluids_GPU/GPU/LBMKernel.cu index d3bfb5d125028ac94a8bbdc87192351d90617989..627b78814051313a2d463c09153de416cc219363 100644 --- a/src/gpu/VirtualFluids_GPU/GPU/LBMKernel.cu +++ b/src/gpu/VirtualFluids_GPU/GPU/LBMKernel.cu @@ -3604,6 +3604,8 @@ extern "C" void QSlipDevComp27(unsigned int numberOfThreads, unsigned int* neighborX, unsigned int* neighborY, unsigned int* neighborZ, + real* turbViscosity, + bool useTurbViscosity, unsigned int size_Mat, bool evenOrOdd) { @@ -3621,7 +3623,24 @@ extern "C" void QSlipDevComp27(unsigned int numberOfThreads, } dim3 gridQ(Grid1, Grid2); dim3 threads(numberOfThreads, 1, 1 ); - + + if(useTurbViscosity) + { + QSlipDeviceComp27TurbViscosity<<< gridQ, threads >>> (DD, + k_Q, + QQ, + sizeQ, + om1, + neighborX, + neighborY, + neighborZ, + turbViscosity, + size_Mat, + evenOrOdd); + getLastCudaError("QSlipDeviceComp27TurbViscosity execution failed"); + } + else + { QSlipDeviceComp27<<< gridQ, threads >>> (DD, k_Q, QQ, @@ -3632,7 +3651,8 @@ extern "C" void QSlipDevComp27(unsigned int numberOfThreads, neighborZ, size_Mat, evenOrOdd); - getLastCudaError("QSlipDeviceComp27 execution failed"); + getLastCudaError("QSlipDeviceComp27 execution failed"); + } } ////////////////////////////////////////////////////////////////////////// extern "C" void QSlipGeomDevComp27(unsigned int numberOfThreads, @@ -3727,6 +3747,167 @@ extern "C" void QSlipNormDevComp27(unsigned int numberOfThreads, getLastCudaError("QSlipGeomDeviceComp27 execution failed"); } ////////////////////////////////////////////////////////////////////////// +extern "C" void QStressDevComp27(unsigned int numberOfThreads, + real* DD, + int* k_Q, + int* k_N, + real* QQ, + unsigned int sizeQ, + real om1, + real* turbViscosity, + real* vx, + real* vy, + real* vz, + real* normalX, + real* normalY, + real* normalZ, + real* vx_bc, + real* vy_bc, + real* vz_bc, + real* vx1, + real* vy1, + real* vz1, + int* samplingOffset, + real* z0, + bool hasWallModelMonitor, + real* u_star, + real* Fx, + real* Fy, + real* Fz, + unsigned int* neighborX, + unsigned int* neighborY, + unsigned int* neighborZ, + unsigned int size_Mat, + bool evenOrOdd) +{ + int Grid = (sizeQ / numberOfThreads)+1; + int Grid1, Grid2; + if (Grid>512) + { + Grid1 = 512; + Grid2 = (Grid/Grid1)+1; + } + else + { + Grid1 = 1; + Grid2 = Grid; + } + dim3 gridQ(Grid1, Grid2); + dim3 threads(numberOfThreads, 1, 1 ); + + QStressDeviceComp27<<< gridQ, threads >>> (DD, + k_Q, + k_N, + QQ, + sizeQ, + om1, + turbViscosity, + vx, + vy, + vz, + normalX, + normalY, + normalZ, + vx_bc, + vy_bc, + vz_bc, + vx1, + vy1, + vz1, + samplingOffset, + z0, + hasWallModelMonitor, + u_star, + Fx, + Fy, + Fz, + neighborX, + neighborY, + neighborZ, + size_Mat, + evenOrOdd); + getLastCudaError("QSlipDeviceComp27 execution failed"); +} + +////////////////////////////////////////////////////////////////////////// +extern "C" void BBStressDev27(unsigned int numberOfThreads, + real* DD, + int* k_Q, + int* k_N, + real* QQ, + unsigned int sizeQ, + real* vx, + real* vy, + real* vz, + real* normalX, + real* normalY, + real* normalZ, + real* vx_bc, + real* vy_bc, + real* vz_bc, + real* vx1, + real* vy1, + real* vz1, + int* samplingOffset, + real* z0, + bool hasWallModelMonitor, + real* u_star, + real* Fx, + real* Fy, + real* Fz, + unsigned int* neighborX, + unsigned int* neighborY, + unsigned int* neighborZ, + unsigned int size_Mat, + bool evenOrOdd) +{ + int Grid = (sizeQ / numberOfThreads)+1; + int Grid1, Grid2; + if (Grid>512) + { + Grid1 = 512; + Grid2 = (Grid/Grid1)+1; + } + else + { + Grid1 = 1; + Grid2 = Grid; + } + dim3 gridQ(Grid1, Grid2); + dim3 threads(numberOfThreads, 1, 1 ); + + BBStressDevice27<<< gridQ, threads >>> (DD, + k_Q, + k_N, + QQ, + sizeQ, + vx, + vy, + vz, + normalX, + normalY, + normalZ, + vx_bc, + vy_bc, + vz_bc, + vx1, + vy1, + vz1, + samplingOffset, + z0, + hasWallModelMonitor, + u_star, + Fx, + Fy, + Fz, + neighborX, + neighborY, + neighborZ, + size_Mat, + evenOrOdd); + getLastCudaError("BBStressDevice27 execution failed"); +} +////////////////////////////////////////////////////////////////////////// extern "C" void QPressDev27(unsigned int numberOfThreads, int nx, int ny, diff --git a/src/gpu/VirtualFluids_GPU/GPU/SlipBCs27.cu b/src/gpu/VirtualFluids_GPU/GPU/SlipBCs27.cu index fc792a2c3a0f7438f4ee0882988a39f7260f21be..e5c017e6b1941f0a7b53e23c70698ccaf7a18987 100644 --- a/src/gpu/VirtualFluids_GPU/GPU/SlipBCs27.cu +++ b/src/gpu/VirtualFluids_GPU/GPU/SlipBCs27.cu @@ -803,6 +803,7 @@ extern "C" __global__ void QSlipDeviceComp27(real* DD, unsigned int kbne = kb; unsigned int ktne = KQK; unsigned int kbsw = neighborZ[ksw]; + //////////////////////////////////////////////////////////////////////////////// real f_W = (D.f[dirE ])[ke ]; real f_E = (D.f[dirW ])[kw ]; @@ -1076,6 +1077,7 @@ extern "C" __global__ void QSlipDeviceComp27(real* DD, VeloZ = fac*vx3; if (x == true) VeloX = c0o1; if (z == true) VeloZ = c0o1; + // if (k==10000) printf("AFTER x: %u \t y: %u \t z: %u \n VeloX: %f \t VeloY: %f \t VeloZ: %f \n\n", x,y,z, VeloX,VeloY,VeloZ); feq=c1o54* (drho/*+three*( vx1 +vx3)*/+c9o2*( vx1 +vx3)*( vx1 +vx3) * (c1o1 + drho)-cu_sq); (D.f[dirBW])[kbw]=(c1o1-q)/(c1o1+q)*(f_TE-f_BW+(f_TE+f_BW-c2o1*feq*om1)/(c1o1-om1))*c1o2+(q*(f_TE+f_BW)-c6o1*c1o54*( VeloX+VeloZ))/(c1o1+q) - c1o54 * drho; //feq=c1over54* (drho+three*( vx1 +vx3)+c9over2*( vx1 +vx3)*( vx1 +vx3)-cu_sq); @@ -1318,7 +1320,673 @@ extern "C" __global__ void QSlipDeviceComp27(real* DD, } } //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////// +extern "C" __global__ void QSlipDeviceComp27TurbViscosity(real* DD, + int* k_Q, + real* QQ, + unsigned int sizeQ, + real om1, + unsigned int* neighborX, + unsigned int* neighborY, + unsigned int* neighborZ, + real* turbViscosity, + unsigned int size_Mat, + bool evenOrOdd) +{ + Distributions27 D; + if (evenOrOdd==true) + { + D.f[dirE ] = &DD[dirE *size_Mat]; + D.f[dirW ] = &DD[dirW *size_Mat]; + D.f[dirN ] = &DD[dirN *size_Mat]; + D.f[dirS ] = &DD[dirS *size_Mat]; + D.f[dirT ] = &DD[dirT *size_Mat]; + D.f[dirB ] = &DD[dirB *size_Mat]; + D.f[dirNE ] = &DD[dirNE *size_Mat]; + D.f[dirSW ] = &DD[dirSW *size_Mat]; + D.f[dirSE ] = &DD[dirSE *size_Mat]; + D.f[dirNW ] = &DD[dirNW *size_Mat]; + D.f[dirTE ] = &DD[dirTE *size_Mat]; + D.f[dirBW ] = &DD[dirBW *size_Mat]; + D.f[dirBE ] = &DD[dirBE *size_Mat]; + D.f[dirTW ] = &DD[dirTW *size_Mat]; + D.f[dirTN ] = &DD[dirTN *size_Mat]; + D.f[dirBS ] = &DD[dirBS *size_Mat]; + D.f[dirBN ] = &DD[dirBN *size_Mat]; + D.f[dirTS ] = &DD[dirTS *size_Mat]; + D.f[dirZERO] = &DD[dirZERO*size_Mat]; + D.f[dirTNE ] = &DD[dirTNE *size_Mat]; + D.f[dirTSW ] = &DD[dirTSW *size_Mat]; + D.f[dirTSE ] = &DD[dirTSE *size_Mat]; + D.f[dirTNW ] = &DD[dirTNW *size_Mat]; + D.f[dirBNE ] = &DD[dirBNE *size_Mat]; + D.f[dirBSW ] = &DD[dirBSW *size_Mat]; + D.f[dirBSE ] = &DD[dirBSE *size_Mat]; + D.f[dirBNW ] = &DD[dirBNW *size_Mat]; + } + else + { + D.f[dirW ] = &DD[dirE *size_Mat]; + D.f[dirE ] = &DD[dirW *size_Mat]; + D.f[dirS ] = &DD[dirN *size_Mat]; + D.f[dirN ] = &DD[dirS *size_Mat]; + D.f[dirB ] = &DD[dirT *size_Mat]; + D.f[dirT ] = &DD[dirB *size_Mat]; + D.f[dirSW ] = &DD[dirNE *size_Mat]; + D.f[dirNE ] = &DD[dirSW *size_Mat]; + D.f[dirNW ] = &DD[dirSE *size_Mat]; + D.f[dirSE ] = &DD[dirNW *size_Mat]; + D.f[dirBW ] = &DD[dirTE *size_Mat]; + D.f[dirTE ] = &DD[dirBW *size_Mat]; + D.f[dirTW ] = &DD[dirBE *size_Mat]; + D.f[dirBE ] = &DD[dirTW *size_Mat]; + D.f[dirBS ] = &DD[dirTN *size_Mat]; + D.f[dirTN ] = &DD[dirBS *size_Mat]; + D.f[dirTS ] = &DD[dirBN *size_Mat]; + D.f[dirBN ] = &DD[dirTS *size_Mat]; + D.f[dirZERO] = &DD[dirZERO*size_Mat]; + D.f[dirTNE ] = &DD[dirBSW *size_Mat]; + D.f[dirTSW ] = &DD[dirBNE *size_Mat]; + D.f[dirTSE ] = &DD[dirBNW *size_Mat]; + D.f[dirTNW ] = &DD[dirBSE *size_Mat]; + D.f[dirBNE ] = &DD[dirTSW *size_Mat]; + D.f[dirBSW ] = &DD[dirTNE *size_Mat]; + D.f[dirBSE ] = &DD[dirTNW *size_Mat]; + D.f[dirBNW ] = &DD[dirTSE *size_Mat]; + } + //////////////////////////////////////////////////////////////////////////////// + const unsigned x = threadIdx.x; // Globaler x-Index + const unsigned y = blockIdx.x; // Globaler y-Index + const unsigned z = blockIdx.y; // Globaler z-Index + + const unsigned nx = blockDim.x; + const unsigned ny = gridDim.x; + + const unsigned k = nx*(ny*z + y) + x; + ////////////////////////////////////////////////////////////////////////// + + if(k<sizeQ) + { + //////////////////////////////////////////////////////////////////////////////// + real *q_dirE, *q_dirW, *q_dirN, *q_dirS, *q_dirT, *q_dirB, + *q_dirNE, *q_dirSW, *q_dirSE, *q_dirNW, *q_dirTE, *q_dirBW, + *q_dirBE, *q_dirTW, *q_dirTN, *q_dirBS, *q_dirBN, *q_dirTS, + *q_dirTNE, *q_dirTSW, *q_dirTSE, *q_dirTNW, *q_dirBNE, *q_dirBSW, + *q_dirBSE, *q_dirBNW; + q_dirE = &QQ[dirE *sizeQ]; + q_dirW = &QQ[dirW *sizeQ]; + q_dirN = &QQ[dirN *sizeQ]; + q_dirS = &QQ[dirS *sizeQ]; + q_dirT = &QQ[dirT *sizeQ]; + q_dirB = &QQ[dirB *sizeQ]; + q_dirNE = &QQ[dirNE *sizeQ]; + q_dirSW = &QQ[dirSW *sizeQ]; + q_dirSE = &QQ[dirSE *sizeQ]; + q_dirNW = &QQ[dirNW *sizeQ]; + q_dirTE = &QQ[dirTE *sizeQ]; + q_dirBW = &QQ[dirBW *sizeQ]; + q_dirBE = &QQ[dirBE *sizeQ]; + q_dirTW = &QQ[dirTW *sizeQ]; + q_dirTN = &QQ[dirTN *sizeQ]; + q_dirBS = &QQ[dirBS *sizeQ]; + q_dirBN = &QQ[dirBN *sizeQ]; + q_dirTS = &QQ[dirTS *sizeQ]; + q_dirTNE = &QQ[dirTNE *sizeQ]; + q_dirTSW = &QQ[dirTSW *sizeQ]; + q_dirTSE = &QQ[dirTSE *sizeQ]; + q_dirTNW = &QQ[dirTNW *sizeQ]; + q_dirBNE = &QQ[dirBNE *sizeQ]; + q_dirBSW = &QQ[dirBSW *sizeQ]; + q_dirBSE = &QQ[dirBSE *sizeQ]; + q_dirBNW = &QQ[dirBNW *sizeQ]; + //////////////////////////////////////////////////////////////////////////////// + //index + unsigned int KQK = k_Q[k]; + unsigned int kzero= KQK; + unsigned int ke = KQK; + unsigned int kw = neighborX[KQK]; + unsigned int kn = KQK; + unsigned int ks = neighborY[KQK]; + unsigned int kt = KQK; + unsigned int kb = neighborZ[KQK]; + unsigned int ksw = neighborY[kw]; + unsigned int kne = KQK; + unsigned int kse = ks; + unsigned int knw = kw; + unsigned int kbw = neighborZ[kw]; + unsigned int kte = KQK; + unsigned int kbe = kb; + unsigned int ktw = kw; + unsigned int kbs = neighborZ[ks]; + unsigned int ktn = KQK; + unsigned int kbn = kb; + unsigned int kts = ks; + unsigned int ktse = ks; + unsigned int kbnw = kbw; + unsigned int ktnw = kw; + unsigned int kbse = kbs; + unsigned int ktsw = ksw; + unsigned int kbne = kb; + unsigned int ktne = KQK; + unsigned int kbsw = neighborZ[ksw]; + + //////////////////////////////////////////////////////////////////////////////// + real f_W = (D.f[dirE ])[ke ]; + real f_E = (D.f[dirW ])[kw ]; + real f_S = (D.f[dirN ])[kn ]; + real f_N = (D.f[dirS ])[ks ]; + real f_B = (D.f[dirT ])[kt ]; + real f_T = (D.f[dirB ])[kb ]; + real f_SW = (D.f[dirNE ])[kne ]; + real f_NE = (D.f[dirSW ])[ksw ]; + real f_NW = (D.f[dirSE ])[kse ]; + real f_SE = (D.f[dirNW ])[knw ]; + real f_BW = (D.f[dirTE ])[kte ]; + real f_TE = (D.f[dirBW ])[kbw ]; + real f_TW = (D.f[dirBE ])[kbe ]; + real f_BE = (D.f[dirTW ])[ktw ]; + real f_BS = (D.f[dirTN ])[ktn ]; + real f_TN = (D.f[dirBS ])[kbs ]; + real f_TS = (D.f[dirBN ])[kbn ]; + real f_BN = (D.f[dirTS ])[kts ]; + real f_BSW = (D.f[dirTNE ])[ktne ]; + real f_BNE = (D.f[dirTSW ])[ktsw ]; + real f_BNW = (D.f[dirTSE ])[ktse ]; + real f_BSE = (D.f[dirTNW ])[ktnw ]; + real f_TSW = (D.f[dirBNE ])[kbne ]; + real f_TNE = (D.f[dirBSW ])[kbsw ]; + real f_TNW = (D.f[dirBSE ])[kbse ]; + real f_TSE = (D.f[dirBNW ])[kbnw ]; + //////////////////////////////////////////////////////////////////////////////// + real vx1, vx2, vx3, drho, feq, q; + drho = f_TSE + f_TNW + f_TNE + f_TSW + f_BSE + f_BNW + f_BNE + f_BSW + + f_BN + f_TS + f_TN + f_BS + f_BE + f_TW + f_TE + f_BW + f_SE + f_NW + f_NE + f_SW + + f_T + f_B + f_N + f_S + f_E + f_W + ((D.f[dirZERO])[kzero]); + + vx1 = (((f_TSE - f_BNW) - (f_TNW - f_BSE)) + ((f_TNE - f_BSW) - (f_TSW - f_BNE)) + + ((f_BE - f_TW) + (f_TE - f_BW)) + ((f_SE - f_NW) + (f_NE - f_SW)) + + (f_E - f_W)) / (c1o1 + drho); + + + vx2 = ((-(f_TSE - f_BNW) + (f_TNW - f_BSE)) + ((f_TNE - f_BSW) - (f_TSW - f_BNE)) + + ((f_BN - f_TS) + (f_TN - f_BS)) + (-(f_SE - f_NW) + (f_NE - f_SW)) + + (f_N - f_S)) / (c1o1 + drho); + + vx3 = (((f_TSE - f_BNW) + (f_TNW - f_BSE)) + ((f_TNE - f_BSW) + (f_TSW - f_BNE)) + + (-(f_BN - f_TS) + (f_TN - f_BS)) + ((f_TE - f_BW) - (f_BE - f_TW)) + + (f_T - f_B)) / (c1o1 + drho); + + real cu_sq=c3o2*(vx1*vx1+vx2*vx2+vx3*vx3) * (c1o1 + drho); + + ////////////////////////////////////////////////////////////////////////// + if (evenOrOdd==false) + { + D.f[dirE ] = &DD[dirE *size_Mat]; + D.f[dirW ] = &DD[dirW *size_Mat]; + D.f[dirN ] = &DD[dirN *size_Mat]; + D.f[dirS ] = &DD[dirS *size_Mat]; + D.f[dirT ] = &DD[dirT *size_Mat]; + D.f[dirB ] = &DD[dirB *size_Mat]; + D.f[dirNE ] = &DD[dirNE *size_Mat]; + D.f[dirSW ] = &DD[dirSW *size_Mat]; + D.f[dirSE ] = &DD[dirSE *size_Mat]; + D.f[dirNW ] = &DD[dirNW *size_Mat]; + D.f[dirTE ] = &DD[dirTE *size_Mat]; + D.f[dirBW ] = &DD[dirBW *size_Mat]; + D.f[dirBE ] = &DD[dirBE *size_Mat]; + D.f[dirTW ] = &DD[dirTW *size_Mat]; + D.f[dirTN ] = &DD[dirTN *size_Mat]; + D.f[dirBS ] = &DD[dirBS *size_Mat]; + D.f[dirBN ] = &DD[dirBN *size_Mat]; + D.f[dirTS ] = &DD[dirTS *size_Mat]; + D.f[dirZERO] = &DD[dirZERO*size_Mat]; + D.f[dirTNE ] = &DD[dirTNE *size_Mat]; + D.f[dirTSW ] = &DD[dirTSW *size_Mat]; + D.f[dirTSE ] = &DD[dirTSE *size_Mat]; + D.f[dirTNW ] = &DD[dirTNW *size_Mat]; + D.f[dirBNE ] = &DD[dirBNE *size_Mat]; + D.f[dirBSW ] = &DD[dirBSW *size_Mat]; + D.f[dirBSE ] = &DD[dirBSE *size_Mat]; + D.f[dirBNW ] = &DD[dirBNW *size_Mat]; + } + else + { + D.f[dirW ] = &DD[dirE *size_Mat]; + D.f[dirE ] = &DD[dirW *size_Mat]; + D.f[dirS ] = &DD[dirN *size_Mat]; + D.f[dirN ] = &DD[dirS *size_Mat]; + D.f[dirB ] = &DD[dirT *size_Mat]; + D.f[dirT ] = &DD[dirB *size_Mat]; + D.f[dirSW ] = &DD[dirNE *size_Mat]; + D.f[dirNE ] = &DD[dirSW *size_Mat]; + D.f[dirNW ] = &DD[dirSE *size_Mat]; + D.f[dirSE ] = &DD[dirNW *size_Mat]; + D.f[dirBW ] = &DD[dirTE *size_Mat]; + D.f[dirTE ] = &DD[dirBW *size_Mat]; + D.f[dirTW ] = &DD[dirBE *size_Mat]; + D.f[dirBE ] = &DD[dirTW *size_Mat]; + D.f[dirBS ] = &DD[dirTN *size_Mat]; + D.f[dirTN ] = &DD[dirBS *size_Mat]; + D.f[dirTS ] = &DD[dirBN *size_Mat]; + D.f[dirBN ] = &DD[dirTS *size_Mat]; + D.f[dirZERO] = &DD[dirZERO*size_Mat]; + D.f[dirTNE ] = &DD[dirBSW *size_Mat]; + D.f[dirTSW ] = &DD[dirBNE *size_Mat]; + D.f[dirTSE ] = &DD[dirBNW *size_Mat]; + D.f[dirTNW ] = &DD[dirBSE *size_Mat]; + D.f[dirBNE ] = &DD[dirTSW *size_Mat]; + D.f[dirBSW ] = &DD[dirTNE *size_Mat]; + D.f[dirBSE ] = &DD[dirTNW *size_Mat]; + D.f[dirBNW ] = &DD[dirTSE *size_Mat]; + } + //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //Test + //(D.f[dirZERO])[k]=c1o10; + //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + real om_turb = om1 / (c1o1 + c3o1*om1*max(c0o1, turbViscosity[k_Q[k]])); + + real fac = c1o1;//c99o100; + real VeloX = fac*vx1; + real VeloY = fac*vx2; + real VeloZ = fac*vx3; + bool x = false; + bool y = false; + bool z = false; + + q = q_dirE[k]; + if (q>=c0o1 && q<=c1o1) + { + VeloX = c0o1; + VeloY = fac*vx2; + VeloZ = fac*vx3; + x = true; + feq=c2o27* (drho/*+three*( vx1 )*/+c9o2*( vx1 )*( vx1 ) * (c1o1 + drho)-cu_sq); + (D.f[dirW])[kw]=(c1o1-q)/(c1o1+q)*(f_E-f_W+(f_E+f_W-c2o1*feq*om_turb)/(c1o1-om_turb))*c1o2+(q*(f_E+f_W)-c6o1*c2o27*( VeloX ))/(c1o1+q) - c2o27 * drho; + //feq=c2over27* (drho+three*( vx1 )+c9over2*( vx1 )*( vx1 )-cu_sq); + //(D.f[dirW])[kw]=(one-q)/(one+q)*(f_E-feq*om1)/(one-om1)+(q*(f_E+f_W)-six*c2over27*( VeloX ))/(one+q); + //(D.f[dirW])[kw]=zero; + } + + q = q_dirW[k]; + if (q>=c0o1 && q<=c1o1) + { + VeloX = c0o1; + VeloY = fac*vx2; + VeloZ = fac*vx3; + x = true; + feq=c2o27* (drho/*+three*(-vx1 )*/+c9o2*(-vx1 )*(-vx1 ) * (c1o1 + drho)-cu_sq); + (D.f[dirE])[ke]=(c1o1-q)/(c1o1+q)*(f_W-f_E+(f_W+f_E-c2o1*feq*om_turb)/(c1o1-om_turb))*c1o2+(q*(f_W+f_E)-c6o1*c2o27*(-VeloX ))/(c1o1+q) - c2o27 * drho; + //feq=c2over27* (drho+three*(-vx1 )+c9over2*(-vx1 )*(-vx1 )-cu_sq); + //(D.f[dirE])[ke]=(one-q)/(one+q)*(f_W-feq*om_turb)/(one-om_turb)+(q*(f_W+f_E)-six*c2over27*(-VeloX ))/(one+q); + //(D.f[dirE])[ke]=zero; + } + + q = q_dirN[k]; + if (q>=c0o1 && q<=c1o1) + { + VeloX = fac*vx1; + VeloY = c0o1; + VeloZ = fac*vx3; + y = true; + feq=c2o27* (drho/*+three*( vx2 )*/+c9o2*( vx2 )*( vx2 ) * (c1o1 + drho)-cu_sq); + (D.f[dirS])[ks]=(c1o1-q)/(c1o1+q)*(f_N-f_S+(f_N+f_S-c2o1*feq*om_turb)/(c1o1-om_turb))*c1o2+(q*(f_N+f_S)-c6o1*c2o27*( VeloY ))/(c1o1+q) - c2o27 * drho; + //feq=c2over27* (drho+three*( vx2 )+c9over2*( vx2 )*( vx2 )-cu_sq); + //(D.f[dirS])[ks]=(one-q)/(one+q)*(f_N-feq*om_turb)/(one-om_turb)+(q*(f_N+f_S)-six*c2over27*( VeloY ))/(one+q); + //(D.f[dirS])[ks]=zero; + } + + q = q_dirS[k]; + if (q>=c0o1 && q<=c1o1) + { + VeloX = fac*vx1; + VeloY = c0o1; + VeloZ = fac*vx3; + y = true; + feq=c2o27* (drho/*+three*( -vx2 )*/+c9o2*( -vx2 )*( -vx2 ) * (c1o1 + drho)-cu_sq); + (D.f[dirN])[kn]=(c1o1-q)/(c1o1+q)*(f_S-f_N+(f_S+f_N-c2o1*feq*om_turb)/(c1o1-om_turb))*c1o2+(q*(f_S+f_N)-c6o1*c2o27*(-VeloY ))/(c1o1+q) - c2o27 * drho; + //feq=c2over27* (drho+three*( -vx2 )+c9over2*( -vx2 )*( -vx2 )-cu_sq); + //(D.f[dirN])[kn]=(one-q)/(one+q)*(f_S-feq*om_turb)/(one-om_turb)+(q*(f_S+f_N)-six*c2over27*(-VeloY ))/(one+q); + //(D.f[dirN])[kn]=zero; + } + + q = q_dirT[k]; + if (q>=c0o1 && q<=c1o1) + { + VeloX = fac*vx1; + VeloY = fac*vx2; + VeloZ = c0o1; + z = true; + feq=c2o27* (drho/*+three*( vx3)*/+c9o2*( vx3)*( vx3) * (c1o1 + drho)-cu_sq); + (D.f[dirB])[kb]=(c1o1-q)/(c1o1+q)*(f_T-f_B+(f_T+f_B-c2o1*feq*om_turb)/(c1o1-om_turb))*c1o2+(q*(f_T+f_B)-c6o1*c2o27*( VeloZ ))/(c1o1+q) - c2o27 * drho; + //feq=c2over27* (drho+three*( vx3)+c9over2*( vx3)*( vx3)-cu_sq); + //(D.f[dirB])[kb]=(one-q)/(one+q)*(f_T-feq*om_turb)/(one-om_turb)+(q*(f_T+f_B)-six*c2over27*( VeloZ ))/(one+q); + //(D.f[dirB])[kb]=one; + } + + q = q_dirB[k]; + if (q>=c0o1 && q<=c1o1) + { + VeloX = fac*vx1; + VeloY = fac*vx2; + VeloZ = c0o1; + z = true; + feq=c2o27* (drho/*+three*( -vx3)*/+c9o2*( -vx3)*( -vx3) * (c1o1 + drho)-cu_sq); + (D.f[dirT])[kt]=(c1o1-q)/(c1o1+q)*(f_B-f_T+(f_B+f_T-c2o1*feq*om_turb)/(c1o1-om_turb))*c1o2+(q*(f_B+f_T)-c6o1*c2o27*(-VeloZ ))/(c1o1+q) - c2o27 * drho; + //feq=c2over27* (drho+three*( -vx3)+c9over2*( -vx3)*( -vx3)-cu_sq); + //(D.f[dirT])[kt]=(one-q)/(one+q)*(f_B-feq*om_turb)/(one-om_turb)+(q*(f_B+f_T)-six*c2over27*(-VeloZ ))/(one+q); + //(D.f[dirT])[kt]=zero; + } + + q = q_dirNE[k]; + if (q>=c0o1 && q<=c1o1) + { + VeloX = fac*vx1; + VeloY = fac*vx2; + VeloZ = fac*vx3; + if (x == true) VeloX = c0o1; + if (y == true) VeloY = c0o1; + feq=c1o54* (drho/*+three*( vx1+vx2 )*/+c9o2*( vx1+vx2 )*( vx1+vx2 ) * (c1o1 + drho)-cu_sq); + (D.f[dirSW])[ksw]=(c1o1-q)/(c1o1+q)*(f_NE-f_SW+(f_NE+f_SW-c2o1*feq*om_turb)/(c1o1-om_turb))*c1o2+(q*(f_NE+f_SW)-c6o1*c1o54*(VeloX+VeloY))/(c1o1+q) - c1o54 * drho; + //feq=c1over54* (drho+three*( vx1+vx2 )+c9over2*( vx1+vx2 )*( vx1+vx2 )-cu_sq); + //(D.f[dirSW])[ksw]=(one-q)/(one+q)*(f_NE-feq*om_turb)/(one-om_turb)+(q*(f_NE+f_SW)-six*c1over54*(VeloX+VeloY))/(one+q); + //(D.f[dirSW])[ksw]=zero; + } + + q = q_dirSW[k]; + if (q>=c0o1 && q<=c1o1) + { + VeloX = fac*vx1; + VeloY = fac*vx2; + VeloZ = fac*vx3; + if (x == true) VeloX = c0o1; + if (y == true) VeloY = c0o1; + feq=c1o54* (drho/*+three*(-vx1-vx2 )*/+c9o2*(-vx1-vx2 )*(-vx1-vx2 ) * (c1o1 + drho)-cu_sq); + (D.f[dirNE])[kne]=(c1o1-q)/(c1o1+q)*(f_SW-f_NE+(f_SW+f_NE-c2o1*feq*om_turb)/(c1o1-om_turb))*c1o2+(q*(f_SW+f_NE)-c6o1*c1o54*(-VeloX-VeloY))/(c1o1+q) - c1o54 * drho; + //feq=c1over54* (drho+three*(-vx1-vx2 )+c9over2*(-vx1-vx2 )*(-vx1-vx2 )-cu_sq); + //(D.f[dirNE])[kne]=(one-q)/(one+q)*(f_SW-feq*om_turb)/(one-om_turb)+(q*(f_SW+f_NE)-six*c1over54*(-VeloX-VeloY))/(one+q); + //(D.f[dirNE])[kne]=zero; + } + + q = q_dirSE[k]; + if (q>=c0o1 && q<=c1o1) + { + VeloX = fac*vx1; + VeloY = fac*vx2; + VeloZ = fac*vx3; + if (x == true) VeloX = c0o1; + if (y == true) VeloY = c0o1; + feq=c1o54* (drho/*+three*( vx1-vx2 )*/+c9o2*( vx1-vx2 )*( vx1-vx2 ) * (c1o1 + drho)-cu_sq); + (D.f[dirNW])[knw]=(c1o1-q)/(c1o1+q)*(f_SE-f_NW+(f_SE+f_NW-c2o1*feq*om_turb)/(c1o1-om_turb))*c1o2+(q*(f_SE+f_NW)-c6o1*c1o54*( VeloX-VeloY))/(c1o1+q) - c1o54 * drho; + //feq=c1over54* (drho+three*( vx1-vx2 )+c9over2*( vx1-vx2 )*( vx1-vx2 )-cu_sq); + //(D.f[dirNW])[knw]=(one-q)/(one+q)*(f_SE-feq*om_turb)/(one-om_turb)+(q*(f_SE+f_NW)-six*c1over54*( VeloX-VeloY))/(one+q); + //(D.f[dirNW])[knw]=zero; + } + + q = q_dirNW[k]; + if (q>=c0o1 && q<=c1o1) + { + VeloX = fac*vx1; + VeloY = fac*vx2; + VeloZ = fac*vx3; + if (x == true) VeloX = c0o1; + if (y == true) VeloY = c0o1; + feq=c1o54* (drho/*+three*(-vx1+vx2 )*/+c9o2*(-vx1+vx2 )*(-vx1+vx2 ) * (c1o1 + drho)-cu_sq); + (D.f[dirSE])[kse]=(c1o1-q)/(c1o1+q)*(f_NW-f_SE+(f_NW+f_SE-c2o1*feq*om_turb)/(c1o1-om_turb))*c1o2+(q*(f_NW+f_SE)-c6o1*c1o54*(-VeloX+VeloY))/(c1o1+q) - c1o54 * drho; + //feq=c1over54* (drho+three*(-vx1+vx2 )+c9over2*(-vx1+vx2 )*(-vx1+vx2 )-cu_sq); + //(D.f[dirSE])[kse]=(one-q)/(one+q)*(f_NW-feq*om_turb)/(one-om_turb)+(q*(f_NW+f_SE)-six*c1over54*(-VeloX+VeloY))/(one+q); + //(D.f[dirSE])[kse]=zero; + } + + q = q_dirTE[k]; + if (q>=c0o1 && q<=c1o1) + { + VeloX = fac*vx1; + VeloY = fac*vx2; + VeloZ = fac*vx3; + if (x == true) VeloX = c0o1; + if (z == true) VeloZ = c0o1; + // if (k==10000) printf("AFTER x: %u \t y: %u \t z: %u \n VeloX: %f \t VeloY: %f \t VeloZ: %f \n\n", x,y,z, VeloX,VeloY,VeloZ); + feq=c1o54* (drho/*+three*( vx1 +vx3)*/+c9o2*( vx1 +vx3)*( vx1 +vx3) * (c1o1 + drho)-cu_sq); + (D.f[dirBW])[kbw]=(c1o1-q)/(c1o1+q)*(f_TE-f_BW+(f_TE+f_BW-c2o1*feq*om_turb)/(c1o1-om_turb))*c1o2+(q*(f_TE+f_BW)-c6o1*c1o54*( VeloX+VeloZ))/(c1o1+q) - c1o54 * drho; + //feq=c1over54* (drho+three*( vx1 +vx3)+c9over2*( vx1 +vx3)*( vx1 +vx3)-cu_sq); + //(D.f[dirBW])[kbw]=(one-q)/(one+q)*(f_TE-feq*om_turb)/(one-om_turb)+(q*(f_TE+f_BW)-six*c1over54*( VeloX+VeloZ))/(one+q); + //(D.f[dirBW])[kbw]=zero; + } + + q = q_dirBW[k]; + if (q>=c0o1 && q<=c1o1) + { + VeloX = fac*vx1; + VeloY = fac*vx2; + VeloZ = fac*vx3; + if (x == true) VeloX = c0o1; + if (z == true) VeloZ = c0o1; + feq=c1o54* (drho/*+three*(-vx1 -vx3)*/+c9o2*(-vx1 -vx3)*(-vx1 -vx3) * (c1o1 + drho)-cu_sq); + (D.f[dirTE])[kte]=(c1o1-q)/(c1o1+q)*(f_BW-f_TE+(f_BW+f_TE-c2o1*feq*om_turb)/(c1o1-om_turb))*c1o2+(q*(f_BW+f_TE)-c6o1*c1o54*(-VeloX-VeloZ))/(c1o1+q) - c1o54 * drho; + //feq=c1over54* (drho+three*(-vx1 -vx3)+c9over2*(-vx1 -vx3)*(-vx1 -vx3)-cu_sq); + //(D.f[dirTE])[kte]=(one-q)/(one+q)*(f_BW-feq*om_turb)/(one-om_turb)+(q*(f_BW+f_TE)-six*c1over54*(-VeloX-VeloZ))/(one+q); + //(D.f[dirTE])[kte]=zero; + } + + q = q_dirBE[k]; + if (q>=c0o1 && q<=c1o1) + { + VeloX = fac*vx1; + VeloY = fac*vx2; + VeloZ = fac*vx3; + if (x == true) VeloX = c0o1; + if (z == true) VeloZ = c0o1; + feq=c1o54* (drho/*+three*( vx1 -vx3)*/+c9o2*( vx1 -vx3)*( vx1 -vx3) * (c1o1 + drho)-cu_sq); + (D.f[dirTW])[ktw]=(c1o1-q)/(c1o1+q)*(f_BE-f_TW+(f_BE+f_TW-c2o1*feq*om_turb)/(c1o1-om_turb))*c1o2+(q*(f_BE+f_TW)-c6o1*c1o54*( VeloX-VeloZ))/(c1o1+q) - c1o54 * drho; + //feq=c1over54* (drho+three*( vx1 -vx3)+c9over2*( vx1 -vx3)*( vx1 -vx3)-cu_sq); + //(D.f[dirTW])[ktw]=(one-q)/(one+q)*(f_BE-feq*om_turb)/(one-om_turb)+(q*(f_BE+f_TW)-six*c1over54*( VeloX-VeloZ))/(one+q); + //(D.f[dirTW])[ktw]=zero; + } + + q = q_dirTW[k]; + if (q>=c0o1 && q<=c1o1) + { + VeloX = fac*vx1; + VeloY = fac*vx2; + VeloZ = fac*vx3; + if (x == true) VeloX = c0o1; + if (z == true) VeloZ = c0o1; + feq=c1o54* (drho/*+three*(-vx1 +vx3)*/+c9o2*(-vx1 +vx3)*(-vx1 +vx3) * (c1o1 + drho)-cu_sq); + (D.f[dirBE])[kbe]=(c1o1-q)/(c1o1+q)*(f_TW-f_BE+(f_TW+f_BE-c2o1*feq*om_turb)/(c1o1-om_turb))*c1o2+(q*(f_TW+f_BE)-c6o1*c1o54*(-VeloX+VeloZ))/(c1o1+q) - c1o54 * drho; + //feq=c1over54* (drho+three*(-vx1 +vx3)+c9over2*(-vx1 +vx3)*(-vx1 +vx3)-cu_sq); + //(D.f[dirBE])[kbe]=(one-q)/(one+q)*(f_TW-feq*om_turb)/(one-om_turb)+(q*(f_TW+f_BE)-six*c1over54*(-VeloX+VeloZ))/(one+q); + //(D.f[dirBE])[kbe]=zero; + } + + q = q_dirTN[k]; + if (q>=c0o1 && q<=c1o1) + { + VeloX = fac*vx1; + VeloY = fac*vx2; + VeloZ = fac*vx3; + if (y == true) VeloY = c0o1; + if (z == true) VeloZ = c0o1; + feq=c1o54* (drho/*+three*( vx2+vx3)*/+c9o2*( vx2+vx3)*( vx2+vx3) * (c1o1 + drho)-cu_sq); + (D.f[dirBS])[kbs]=(c1o1-q)/(c1o1+q)*(f_TN-f_BS+(f_TN+f_BS-c2o1*feq*om_turb)/(c1o1-om_turb))*c1o2+(q*(f_TN+f_BS)-c6o1*c1o54*( VeloY+VeloZ))/(c1o1+q) - c1o54 * drho; + //feq=c1over54* (drho+three*( vx2+vx3)+c9over2*( vx2+vx3)*( vx2+vx3)-cu_sq); + //(D.f[dirBS])[kbs]=(one-q)/(one+q)*(f_TN-feq*om_turb)/(one-om_turb)+(q*(f_TN+f_BS)-six*c1over54*( VeloY+VeloZ))/(one+q); + //(D.f[dirBS])[kbs]=zero; + } + + q = q_dirBS[k]; + if (q>=c0o1 && q<=c1o1) + { + VeloX = fac*vx1; + VeloY = fac*vx2; + VeloZ = fac*vx3; + if (y == true) VeloY = c0o1; + if (z == true) VeloZ = c0o1; + feq=c1o54* (drho/*+three*( -vx2-vx3)*/+c9o2*( -vx2-vx3)*( -vx2-vx3) * (c1o1 + drho)-cu_sq); + (D.f[dirTN])[ktn]=(c1o1-q)/(c1o1+q)*(f_BS-f_TN+(f_BS+f_TN-c2o1*feq*om_turb)/(c1o1-om_turb))*c1o2+(q*(f_BS+f_TN)-c6o1*c1o54*( -VeloY-VeloZ))/(c1o1+q) - c1o54 * drho; + //feq=c1over54* (drho+three*( -vx2-vx3)+c9over2*( -vx2-vx3)*( -vx2-vx3)-cu_sq); + //(D.f[dirTN])[ktn]=(one-q)/(one+q)*(f_BS-feq*om_turb)/(one-om_turb)+(q*(f_BS+f_TN)-six*c1over54*( -VeloY-VeloZ))/(one+q); + //(D.f[dirTN])[ktn]=zero; + } + + q = q_dirBN[k]; + if (q>=c0o1 && q<=c1o1) + { + VeloX = fac*vx1; + VeloY = fac*vx2; + VeloZ = fac*vx3; + if (y == true) VeloY = c0o1; + if (z == true) VeloZ = c0o1; + feq=c1o54* (drho/*+three*( vx2-vx3)*/+c9o2*( vx2-vx3)*( vx2-vx3) * (c1o1 + drho)-cu_sq); + (D.f[dirTS])[kts]=(c1o1-q)/(c1o1+q)*(f_BN-f_TS+(f_BN+f_TS-c2o1*feq*om_turb)/(c1o1-om_turb))*c1o2+(q*(f_BN+f_TS)-c6o1*c1o54*( VeloY-VeloZ))/(c1o1+q) - c1o54 * drho; + //feq=c1over54* (drho+three*( vx2-vx3)+c9over2*( vx2-vx3)*( vx2-vx3)-cu_sq); + //(D.f[dirTS])[kts]=(one-q)/(one+q)*(f_BN-feq*om_turb)/(one-om_turb)+(q*(f_BN+f_TS)-six*c1over54*( VeloY-VeloZ))/(one+q); + //(D.f[dirTS])[kts]=zero; + } + + q = q_dirTS[k]; + if (q>=c0o1 && q<=c1o1) + { + VeloX = fac*vx1; + VeloY = fac*vx2; + VeloZ = fac*vx3; + if (y == true) VeloY = c0o1; + if (z == true) VeloZ = c0o1; + feq=c1o54* (drho/*+three*( -vx2+vx3)*/+c9o2*( -vx2+vx3)*( -vx2+vx3) * (c1o1 + drho)-cu_sq); + (D.f[dirBN])[kbn]=(c1o1-q)/(c1o1+q)*(f_TS-f_BN+(f_TS+f_BN-c2o1*feq*om_turb)/(c1o1-om_turb))*c1o2+(q*(f_TS+f_BN)-c6o1*c1o54*( -VeloY+VeloZ))/(c1o1+q) - c1o54 * drho; + //feq=c1over54* (drho+three*( -vx2+vx3)+c9over2*( -vx2+vx3)*( -vx2+vx3)-cu_sq); + //(D.f[dirBN])[kbn]=(one-q)/(one+q)*(f_TS-feq*om_turb)/(one-om_turb)+(q*(f_TS+f_BN)-six*c1over54*( -VeloY+VeloZ))/(one+q); + //(D.f[dirBN])[kbn]=zero; + } + + q = q_dirTNE[k]; + if (q>=c0o1 && q<=c1o1) + { + VeloX = fac*vx1; + VeloY = fac*vx2; + VeloZ = fac*vx3; + if (x == true) VeloX = c0o1; + if (y == true) VeloY = c0o1; + if (z == true) VeloZ = c0o1; + feq=c1o216*(drho/*+three*( vx1+vx2+vx3)*/+c9o2*( vx1+vx2+vx3)*( vx1+vx2+vx3) * (c1o1 + drho)-cu_sq); + (D.f[dirBSW])[kbsw]=(c1o1-q)/(c1o1+q)*(f_TNE-f_BSW+(f_TNE+f_BSW-c2o1*feq*om_turb)/(c1o1-om_turb))*c1o2+(q*(f_TNE+f_BSW)-c6o1*c1o216*( VeloX+VeloY+VeloZ))/(c1o1+q) - c1o216 * drho; + //feq=c1over216*(drho+three*( vx1+vx2+vx3)+c9over2*( vx1+vx2+vx3)*( vx1+vx2+vx3)-cu_sq); + //(D.f[dirBSW])[kbsw]=(one-q)/(one+q)*(f_TNE-feq*om_turb)/(one-om_turb)+(q*(f_TNE+f_BSW)-six*c1over216*( VeloX+VeloY+VeloZ))/(one+q); + //(D.f[dirBSW])[kbsw]=zero; + } + + q = q_dirBSW[k]; + if (q>=c0o1 && q<=c1o1) + { + VeloX = fac*vx1; + VeloY = fac*vx2; + VeloZ = fac*vx3; + if (x == true) VeloX = c0o1; + if (y == true) VeloY = c0o1; + if (z == true) VeloZ = c0o1; + feq=c1o216*(drho/*+three*(-vx1-vx2-vx3)*/+c9o2*(-vx1-vx2-vx3)*(-vx1-vx2-vx3) * (c1o1 + drho)-cu_sq); + (D.f[dirTNE])[ktne]=(c1o1-q)/(c1o1+q)*(f_BSW-f_TNE+(f_BSW+f_TNE-c2o1*feq*om_turb)/(c1o1-om_turb))*c1o2+(q*(f_BSW+f_TNE)-c6o1*c1o216*(-VeloX-VeloY-VeloZ))/(c1o1+q) - c1o216 * drho; + //feq=c1over216*(drho+three*(-vx1-vx2-vx3)+c9over2*(-vx1-vx2-vx3)*(-vx1-vx2-vx3)-cu_sq); + //(D.f[dirTNE])[ktne]=(one-q)/(one+q)*(f_BSW-feq*om_turb)/(one-om_turb)+(q*(f_BSW+f_TNE)-six*c1over216*(-VeloX-VeloY-VeloZ))/(one+q); + //(D.f[dirTNE])[ktne]=zero; + } + + q = q_dirBNE[k]; + if (q>=c0o1 && q<=c1o1) + { + VeloX = fac*vx1; + VeloY = fac*vx2; + VeloZ = fac*vx3; + if (x == true) VeloX = c0o1; + if (y == true) VeloY = c0o1; + if (z == true) VeloZ = c0o1; + feq=c1o216*(drho/*+three*( vx1+vx2-vx3)*/+c9o2*( vx1+vx2-vx3)*( vx1+vx2-vx3) * (c1o1 + drho)-cu_sq); + (D.f[dirTSW])[ktsw]=(c1o1-q)/(c1o1+q)*(f_BNE-f_TSW+(f_BNE+f_TSW-c2o1*feq*om_turb)/(c1o1-om_turb))*c1o2+(q*(f_BNE+f_TSW)-c6o1*c1o216*( VeloX+VeloY-VeloZ))/(c1o1+q) - c1o216 * drho; + //feq=c1over216*(drho+three*( vx1+vx2-vx3)+c9over2*( vx1+vx2-vx3)*( vx1+vx2-vx3)-cu_sq); + //(D.f[dirTSW])[ktsw]=(one-q)/(one+q)*(f_BNE-feq*om_turb)/(one-om_turb)+(q*(f_BNE+f_TSW)-six*c1over216*( VeloX+VeloY-VeloZ))/(one+q); + //(D.f[dirTSW])[ktsw]=zero; + } + + q = q_dirTSW[k]; + if (q>=c0o1 && q<=c1o1) + { + VeloX = fac*vx1; + VeloY = fac*vx2; + VeloZ = fac*vx3; + if (x == true) VeloX = c0o1; + if (y == true) VeloY = c0o1; + if (z == true) VeloZ = c0o1; + feq=c1o216*(drho/*+three*(-vx1-vx2+vx3)*/+c9o2*(-vx1-vx2+vx3)*(-vx1-vx2+vx3) * (c1o1 + drho)-cu_sq); + (D.f[dirBNE])[kbne]=(c1o1-q)/(c1o1+q)*(f_TSW-f_BNE+(f_TSW+f_BNE-c2o1*feq*om_turb)/(c1o1-om_turb))*c1o2+(q*(f_TSW+f_BNE)-c6o1*c1o216*(-VeloX-VeloY+VeloZ))/(c1o1+q) - c1o216 * drho; + //feq=c1over216*(drho+three*(-vx1-vx2+vx3)+c9over2*(-vx1-vx2+vx3)*(-vx1-vx2+vx3)-cu_sq); + //(D.f[dirBNE])[kbne]=(one-q)/(one+q)*(f_TSW-feq*om_turb)/(one-om_turb)+(q*(f_TSW+f_BNE)-six*c1over216*(-VeloX-VeloY+VeloZ))/(one+q); + //(D.f[dirBNE])[kbne]=zero; + } + + q = q_dirTSE[k]; + if (q>=c0o1 && q<=c1o1) + { + VeloX = fac*vx1; + VeloY = fac*vx2; + VeloZ = fac*vx3; + if (x == true) VeloX = c0o1; + if (y == true) VeloY = c0o1; + if (z == true) VeloZ = c0o1; + feq=c1o216*(drho/*+three*( vx1-vx2+vx3)*/+c9o2*( vx1-vx2+vx3)*( vx1-vx2+vx3) * (c1o1 + drho)-cu_sq); + (D.f[dirBNW])[kbnw]=(c1o1-q)/(c1o1+q)*(f_TSE-f_BNW+(f_TSE+f_BNW-c2o1*feq*om_turb)/(c1o1-om_turb))*c1o2+(q*(f_TSE+f_BNW)-c6o1*c1o216*( VeloX-VeloY+VeloZ))/(c1o1+q) - c1o216 * drho; + //feq=c1over216*(drho+three*( vx1-vx2+vx3)+c9over2*( vx1-vx2+vx3)*( vx1-vx2+vx3)-cu_sq); + //(D.f[dirBNW])[kbnw]=(one-q)/(one+q)*(f_TSE-feq*om_turb)/(one-om_turb)+(q*(f_TSE+f_BNW)-six*c1over216*( VeloX-VeloY+VeloZ))/(one+q); + //(D.f[dirBNW])[kbnw]=zero; + } + + q = q_dirBNW[k]; + if (q>=c0o1 && q<=c1o1) + { + VeloX = fac*vx1; + VeloY = fac*vx2; + VeloZ = fac*vx3; + if (x == true) VeloX = c0o1; + if (y == true) VeloY = c0o1; + if (z == true) VeloZ = c0o1; + feq=c1o216*(drho/*+three*(-vx1+vx2-vx3)*/+c9o2*(-vx1+vx2-vx3)*(-vx1+vx2-vx3) * (c1o1 + drho)-cu_sq); + (D.f[dirTSE])[ktse]=(c1o1-q)/(c1o1+q)*(f_BNW-f_TSE+(f_BNW+f_TSE-c2o1*feq*om_turb)/(c1o1-om_turb))*c1o2+(q*(f_BNW+f_TSE)-c6o1*c1o216*(-VeloX+VeloY-VeloZ))/(c1o1+q) - c1o216 * drho; + //feq=c1over216*(drho+three*(-vx1+vx2-vx3)+c9over2*(-vx1+vx2-vx3)*(-vx1+vx2-vx3)-cu_sq); + //(D.f[dirTSE])[ktse]=(one-q)/(one+q)*(f_BNW-feq*om_turb)/(one-om_turb)+(q*(f_BNW+f_TSE)-six*c1over216*(-VeloX+VeloY-VeloZ))/(one+q); + //(D.f[dirTSE])[ktse]=zero; + } + + q = q_dirBSE[k]; + if (q>=c0o1 && q<=c1o1) + { + VeloX = fac*vx1; + VeloY = fac*vx2; + VeloZ = fac*vx3; + if (x == true) VeloX = c0o1; + if (y == true) VeloY = c0o1; + if (z == true) VeloZ = c0o1; + feq=c1o216*(drho/*+three*( vx1-vx2-vx3)*/+c9o2*( vx1-vx2-vx3)*( vx1-vx2-vx3) * (c1o1 + drho)-cu_sq); + (D.f[dirTNW])[ktnw]=(c1o1-q)/(c1o1+q)*(f_BSE-f_TNW+(f_BSE+f_TNW-c2o1*feq*om_turb)/(c1o1-om_turb))*c1o2+(q*(f_BSE+f_TNW)-c6o1*c1o216*( VeloX-VeloY-VeloZ))/(c1o1+q) - c1o216 * drho; + //feq=c1over216*(drho+three*( vx1-vx2-vx3)+c9over2*( vx1-vx2-vx3)*( vx1-vx2-vx3)-cu_sq); + //(D.f[dirTNW])[ktnw]=(one-q)/(one+q)*(f_BSE-feq*om_turb)/(one-om_turb)+(q*(f_BSE+f_TNW)-six*c1over216*( VeloX-VeloY-VeloZ))/(one+q); + //(D.f[dirTNW])[ktnw]=zero; + } + q = q_dirTNW[k]; + if (q>=c0o1 && q<=c1o1) + { + VeloX = fac*vx1; + VeloY = fac*vx2; + VeloZ = fac*vx3; + if (x == true) VeloX = c0o1; + if (y == true) VeloY = c0o1; + if (z == true) VeloZ = c0o1; + feq=c1o216*(drho/*+three*(-vx1+vx2+vx3)*/+c9o2*(-vx1+vx2+vx3)*(-vx1+vx2+vx3) * (c1o1 + drho)-cu_sq); + (D.f[dirBSE])[kbse]=(c1o1-q)/(c1o1+q)*(f_TNW-f_BSE+(f_TNW+f_BSE-c2o1*feq*om_turb)/(c1o1-om_turb))*c1o2+(q*(f_TNW+f_BSE)-c6o1*c1o216*(-VeloX+VeloY+VeloZ))/(c1o1+q) - c1o216 * drho; + //feq=c1over216*(drho+three*(-vx1+vx2+vx3)+c9over2*(-vx1+vx2+vx3)*(-vx1+vx2+vx3)-cu_sq); + //(D.f[dirBSE])[kbse]=(one-q)/(one+q)*(f_TNW-feq*om_turb)/(one-om_turb)+(q*(f_TNW+f_BSE)-six*c1over216*(-VeloX+VeloY+VeloZ))/(one+q); + //(D.f[dirBSE])[kbse]=zero; + } + } +} @@ -3109,48 +3777,3 @@ extern "C" __global__ void QSlipNormDeviceComp27(real* DD, } } //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - diff --git a/src/gpu/VirtualFluids_GPU/GPU/StressBCs27.cu b/src/gpu/VirtualFluids_GPU/GPU/StressBCs27.cu new file mode 100644 index 0000000000000000000000000000000000000000..99efb964dc1bdb3b64ce799c9c9e9f2c2abcf866 --- /dev/null +++ b/src/gpu/VirtualFluids_GPU/GPU/StressBCs27.cu @@ -0,0 +1,1661 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids 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. +// +// VirtualFluids 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 VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file StressBcs27.cu +//! \author Henrik Asmuth +//! \date 16/05/2022 +//! \brief Kernels for StressBC using the iMEM approach +//! +//! Both kernels prescribe a wall shear stress using the iMEM apprach (see, Asmuth et. al (2021), https://doi.org/10.1063/5.0065701) +//! QStressDeviceComp27 couples the iMEM to the single-node interpolated bounce-back. +//! BBStressDevice27 couples the iMEM to a simple bounce-back. +//! Note, that the iMEM function is currently only implemented for straight walls with z-normal and q=0.5. +//! Other wall models could be implemented in the iMEM by replacing the formulations from Monin-Obukhov similarity theory (MOST) +//! with other formulations, e.g., for smooth walls. +//! iMEM so far most extensively tested with BBStressDevice27, but QStressDeviceComp27 also seems to be stable and working. +//======================================================================================= + +#include "LBM/LB.h" +#include "LBM/D3Q27.h" +#include <lbm/constants/NumericConstants.h> + +using namespace vf::lbm::constant; + +////////////////////////////////////////////////////////////////////////////// +extern "C" __host__ __device__ __forceinline__ void iMEM(uint k, uint kN, + real* _wallNormalX, real* _wallNormalY, real* _wallNormalZ, + real* vx, real* vy, real* vz, + real* vx_el, real* vy_el, real* vz_el, //!>mean (temporally filtered) velocities at exchange location + real* vx_w_mean, real* vy_w_mean, real* vz_w_mean, //!>mean (temporally filtered) velocities at wall-adjactent node + real vx_w_inst, real vy_w_inst, real vz_w_inst, //!>instantaneous velocities at wall-adjactent node + real rho, + int* samplingOffset, + real q, + real forceFactor, //!>e.g., 1.0 for simple-bounce back, or (1+q) for interpolated single-node bounce-back as in Geier et al (2015) + real eps, //!>filter constant in temporal averaging + real* z0, //!>aerodynamic roughness length + bool hasWallModelMonitor, + real* u_star_monitor, + real wallMomentumX, real wallMomentumY, real wallMomentumZ, + real& wallVelocityX, real& wallVelocityY, real&wallVelocityZ) +{ + real wallNormalX = _wallNormalX[k]; + real wallNormalY = _wallNormalY[k]; + real wallNormalZ = _wallNormalZ[k]; + + //Sample velocity at exchange location and filter temporally + real _vx_el = eps*vx[kN]+(1.0-eps)*vx_el[k]; + real _vy_el = eps*vy[kN]+(1.0-eps)*vy_el[k]; + real _vz_el = eps*vz[kN]+(1.0-eps)*vz_el[k]; + vx_el[k] = _vx_el; + vy_el[k] = _vy_el; + vz_el[k] = _vz_el; + + //filter velocity at wall-adjacent node + real _vx_w_mean = eps*vx_w_inst+(1.0-eps)*vx_w_mean[k]; + real _vy_w_mean = eps*vy_w_inst+(1.0-eps)*vy_w_mean[k]; + real _vz_w_mean = eps*vz_w_inst+(1.0-eps)*vz_w_mean[k]; + vx_w_mean[k] = _vx_w_mean; + vy_w_mean[k] = _vy_w_mean; + vz_w_mean[k] = _vz_w_mean; + + //Subtract wall-normal velocity components + real vDotN_el = _vx_el*wallNormalX + _vy_el*wallNormalY + _vz_el*wallNormalZ; + _vx_el -= vDotN_el*wallNormalX; + _vy_el -= vDotN_el*wallNormalY; + _vz_el -= vDotN_el*wallNormalZ; + real vMag_el = sqrt( _vx_el*_vx_el + _vy_el*_vy_el + _vz_el*_vz_el ); + + real vDotN_w_mean = _vx_w_mean*wallNormalX + _vy_w_mean*wallNormalY + _vz_w_mean*wallNormalZ; + _vx_w_mean -= vDotN_w_mean*wallNormalX; + _vy_w_mean -= vDotN_w_mean*wallNormalY; + _vz_w_mean -= vDotN_w_mean*wallNormalZ; + real vMag_w_mean = sqrt( _vx_w_mean*_vx_w_mean + _vy_w_mean*_vy_w_mean + _vz_w_mean*_vz_w_mean ); + + real vDotN_w = vx_w_inst*wallNormalX + vy_w_inst*wallNormalY + vz_w_inst*wallNormalZ; + real _vx_w = vx_w_inst-vDotN_w*wallNormalX; + real _vy_w = vy_w_inst-vDotN_w*wallNormalY; + real _vz_w = vz_w_inst-vDotN_w*wallNormalZ; + + //Compute wall shear stress tau_w via MOST + real z = (real)samplingOffset[k] + 0.5; //assuming q=0.5, could be replaced by wall distance via wall normal + real kappa = 0.4; + real u_star = vMag_el*kappa/(log(z/z0[k])); + if(hasWallModelMonitor) u_star_monitor[k] = u_star; + real tau_w = u_star*u_star; //Note: this is actually tau_w/rho + real A = 1.0; //wall area (obviously 1 for grid aligned walls, can come from grid builder later for complex geometries) + + //Scale wall shear stress with near wall velocity, i.e., Schumann-Grötzbach (SG) approach + real F_w_x = (tau_w*A) * (_vx_w/vMag_w_mean);//(_vx_el/vMag_el) + real F_w_y = (tau_w*A) * (_vy_w/vMag_w_mean);//(_vy_el/vMag_el) + real F_w_z = (tau_w*A) * (_vz_w/vMag_w_mean);//(_vz_el/vMag_el) + // ^^^^^^^^^^^^--- old alternative: do not scale SG-like but only set direction via velocity at exchange location + + //Momentum to be applied via wall velocity + real wallMomDotN = wallMomentumX*wallNormalX+wallMomentumY*wallNormalY+wallMomentumZ*wallNormalZ; + real F_x = F_w_x - ( wallMomentumX - wallMomDotN*wallNormalX )/rho; + real F_y = F_w_y - ( wallMomentumY - wallMomDotN*wallNormalY )/rho; + real F_z = F_w_z - ( wallMomentumZ - wallMomDotN*wallNormalZ )/rho; + + //Compute wall velocity and clip (clipping only necessary for initial boundary layer development) + real clipWallVelo = 2.0; + real clipVx = clipWallVelo*_vx_el; + real clipVy = clipWallVelo*_vy_el; + real clipVz = clipWallVelo*_vz_el; + + wallVelocityX = clipVx > -clipVx? min(clipVx, max(-clipVx, -3.0*F_x*forceFactor)): max(clipVx, min(-clipVx, -3.0*F_x*forceFactor)); + wallVelocityY = clipVy > -clipVy? min(clipVy, max(-clipVy, -3.0*F_y*forceFactor)): max(clipVy, min(-clipVy, -3.0*F_y*forceFactor)); + wallVelocityZ = clipVz > -clipVz? min(clipVz, max(-clipVz, -3.0*F_z*forceFactor)): max(clipVz, min(-clipVz, -3.0*F_z*forceFactor)); +} + +////////////////////////////////////////////////////////////////////////////// +extern "C" __global__ void QStressDeviceComp27(real* DD, + int* k_Q, + int* k_N, + real* QQ, + unsigned int sizeQ, + real om1, + real* turbViscosity, + real* vx, + real* vy, + real* vz, + real* normalX, + real* normalY, + real* normalZ, + real* vx_el, + real* vy_el, + real* vz_el, + real* vx_w_mean, + real* vy_w_mean, + real* vz_w_mean, + int* samplingOffset, + real* z0, + bool hasWallModelMonitor, + real* u_star_monitor, + real* Fx_monitor, + real* Fy_monitor, + real* Fz_monitor, + unsigned int* neighborX, + unsigned int* neighborY, + unsigned int* neighborZ, + unsigned int size_Mat, + bool evenOrOdd) +{ + + bool printOut = false; + + Distributions27 D; + if (evenOrOdd==true)//get right array of post coll f's + { + D.f[dirE ] = &DD[dirE *size_Mat]; + D.f[dirW ] = &DD[dirW *size_Mat]; + D.f[dirN ] = &DD[dirN *size_Mat]; + D.f[dirS ] = &DD[dirS *size_Mat]; + D.f[dirT ] = &DD[dirT *size_Mat]; + D.f[dirB ] = &DD[dirB *size_Mat]; + D.f[dirNE ] = &DD[dirNE *size_Mat]; + D.f[dirSW ] = &DD[dirSW *size_Mat]; + D.f[dirSE ] = &DD[dirSE *size_Mat]; + D.f[dirNW ] = &DD[dirNW *size_Mat]; + D.f[dirTE ] = &DD[dirTE *size_Mat]; + D.f[dirBW ] = &DD[dirBW *size_Mat]; + D.f[dirBE ] = &DD[dirBE *size_Mat]; + D.f[dirTW ] = &DD[dirTW *size_Mat]; + D.f[dirTN ] = &DD[dirTN *size_Mat]; + D.f[dirBS ] = &DD[dirBS *size_Mat]; + D.f[dirBN ] = &DD[dirBN *size_Mat]; + D.f[dirTS ] = &DD[dirTS *size_Mat]; + D.f[dirZERO] = &DD[dirZERO*size_Mat]; + D.f[dirTNE ] = &DD[dirTNE *size_Mat]; + D.f[dirTSW ] = &DD[dirTSW *size_Mat]; + D.f[dirTSE ] = &DD[dirTSE *size_Mat]; + D.f[dirTNW ] = &DD[dirTNW *size_Mat]; + D.f[dirBNE ] = &DD[dirBNE *size_Mat]; + D.f[dirBSW ] = &DD[dirBSW *size_Mat]; + D.f[dirBSE ] = &DD[dirBSE *size_Mat]; + D.f[dirBNW ] = &DD[dirBNW *size_Mat]; + } + else + { + D.f[dirW ] = &DD[dirE *size_Mat]; + D.f[dirE ] = &DD[dirW *size_Mat]; + D.f[dirS ] = &DD[dirN *size_Mat]; + D.f[dirN ] = &DD[dirS *size_Mat]; + D.f[dirB ] = &DD[dirT *size_Mat]; + D.f[dirT ] = &DD[dirB *size_Mat]; + D.f[dirSW ] = &DD[dirNE *size_Mat]; + D.f[dirNE ] = &DD[dirSW *size_Mat]; + D.f[dirNW ] = &DD[dirSE *size_Mat]; + D.f[dirSE ] = &DD[dirNW *size_Mat]; + D.f[dirBW ] = &DD[dirTE *size_Mat]; + D.f[dirTE ] = &DD[dirBW *size_Mat]; + D.f[dirTW ] = &DD[dirBE *size_Mat]; + D.f[dirBE ] = &DD[dirTW *size_Mat]; + D.f[dirBS ] = &DD[dirTN *size_Mat]; + D.f[dirTN ] = &DD[dirBS *size_Mat]; + D.f[dirTS ] = &DD[dirBN *size_Mat]; + D.f[dirBN ] = &DD[dirTS *size_Mat]; + D.f[dirZERO] = &DD[dirZERO*size_Mat]; + D.f[dirTNE ] = &DD[dirBSW *size_Mat]; + D.f[dirTSW ] = &DD[dirBNE *size_Mat]; + D.f[dirTSE ] = &DD[dirBNW *size_Mat]; + D.f[dirTNW ] = &DD[dirBSE *size_Mat]; + D.f[dirBNE ] = &DD[dirTSW *size_Mat]; + D.f[dirBSW ] = &DD[dirTNE *size_Mat]; + D.f[dirBSE ] = &DD[dirTNW *size_Mat]; + D.f[dirBNW ] = &DD[dirTSE *size_Mat]; + } + //////////////////////////////////////////////////////////////////////////////// + const unsigned x = threadIdx.x; // Globaler x-Index + const unsigned y = blockIdx.x; // Globaler y-Index + const unsigned z = blockIdx.y; // Globaler z-Index + + const unsigned nx = blockDim.x; + const unsigned ny = gridDim.x; + + const unsigned k = nx*(ny*z + y) + x; + ////////////////////////////////////////////////////////////////////////// + + if(k<sizeQ/*kQ*/) + { + //////////////////////////////////////////////////////////////////////////////// + real *q_dirE, *q_dirW, *q_dirN, *q_dirS, *q_dirT, *q_dirB, + *q_dirNE, *q_dirSW, *q_dirSE, *q_dirNW, *q_dirTE, *q_dirBW, + *q_dirBE, *q_dirTW, *q_dirTN, *q_dirBS, *q_dirBN, *q_dirTS, + *q_dirTNE, *q_dirTSW, *q_dirTSE, *q_dirTNW, *q_dirBNE, *q_dirBSW, + *q_dirBSE, *q_dirBNW; + q_dirE = &QQ[dirE *sizeQ]; + q_dirW = &QQ[dirW *sizeQ]; + q_dirN = &QQ[dirN *sizeQ]; + q_dirS = &QQ[dirS *sizeQ]; + q_dirT = &QQ[dirT *sizeQ]; + q_dirB = &QQ[dirB *sizeQ]; + q_dirNE = &QQ[dirNE *sizeQ]; + q_dirSW = &QQ[dirSW *sizeQ]; + q_dirSE = &QQ[dirSE *sizeQ]; + q_dirNW = &QQ[dirNW *sizeQ]; + q_dirTE = &QQ[dirTE *sizeQ]; + q_dirBW = &QQ[dirBW *sizeQ]; + q_dirBE = &QQ[dirBE *sizeQ]; + q_dirTW = &QQ[dirTW *sizeQ]; + q_dirTN = &QQ[dirTN *sizeQ]; + q_dirBS = &QQ[dirBS *sizeQ]; + q_dirBN = &QQ[dirBN *sizeQ]; + q_dirTS = &QQ[dirTS *sizeQ]; + q_dirTNE = &QQ[dirTNE *sizeQ]; + q_dirTSW = &QQ[dirTSW *sizeQ]; + q_dirTSE = &QQ[dirTSE *sizeQ]; + q_dirTNW = &QQ[dirTNW *sizeQ]; + q_dirBNE = &QQ[dirBNE *sizeQ]; + q_dirBSW = &QQ[dirBSW *sizeQ]; + q_dirBSE = &QQ[dirBSE *sizeQ]; + q_dirBNW = &QQ[dirBNW *sizeQ]; + //////////////////////////////////////////////////////////////////////////////// + //index + unsigned int KQK = k_Q[k]; + unsigned int kzero= KQK; //get right adress of post-coll f's + unsigned int ke = KQK; + unsigned int kw = neighborX[KQK]; + unsigned int kn = KQK; + unsigned int ks = neighborY[KQK]; + unsigned int kt = KQK; + unsigned int kb = neighborZ[KQK]; + unsigned int ksw = neighborY[kw]; + unsigned int kne = KQK; + unsigned int kse = ks; + unsigned int knw = kw; + unsigned int kbw = neighborZ[kw]; + unsigned int kte = KQK; + unsigned int kbe = kb; + unsigned int ktw = kw; + unsigned int kbs = neighborZ[ks]; + unsigned int ktn = KQK; + unsigned int kbn = kb; + unsigned int kts = ks; + unsigned int ktse = ks; + unsigned int kbnw = kbw; + unsigned int ktnw = kw; + unsigned int kbse = kbs; + unsigned int ktsw = ksw; + unsigned int kbne = kb; + unsigned int ktne = KQK; + unsigned int kbsw = neighborZ[ksw]; + //////////////////////////////////////////////////////////////////////////////// + real f_E, f_W, f_N, f_S, f_T, f_B, f_NE, f_SW, f_SE, f_NW, f_TE, f_BW, f_BE, + f_TW, f_TN, f_BS, f_BN, f_TS, f_TNE, f_TSW, f_TSE, f_TNW, f_BNE, f_BSW, f_BSE, f_BNW; + + f_W = (D.f[dirE ])[ke ]; //post-coll f's + f_E = (D.f[dirW ])[kw ]; + f_S = (D.f[dirN ])[kn ]; + f_N = (D.f[dirS ])[ks ]; + f_B = (D.f[dirT ])[kt ]; + f_T = (D.f[dirB ])[kb ]; + f_SW = (D.f[dirNE ])[kne ]; + f_NE = (D.f[dirSW ])[ksw ]; + f_NW = (D.f[dirSE ])[kse ]; + f_SE = (D.f[dirNW ])[knw ]; + f_BW = (D.f[dirTE ])[kte ]; + f_TE = (D.f[dirBW ])[kbw ]; + f_TW = (D.f[dirBE ])[kbe ]; + f_BE = (D.f[dirTW ])[ktw ]; + f_BS = (D.f[dirTN ])[ktn ]; + f_TN = (D.f[dirBS ])[kbs ]; + f_TS = (D.f[dirBN ])[kbn ]; + f_BN = (D.f[dirTS ])[kts ]; + f_BSW = (D.f[dirTNE ])[ktne ]; + f_BNE = (D.f[dirTSW ])[ktsw ]; + f_BNW = (D.f[dirTSE ])[ktse ]; + f_BSE = (D.f[dirTNW ])[ktnw ]; + f_TSW = (D.f[dirBNE ])[kbne ]; + f_TNE = (D.f[dirBSW ])[kbsw ]; + f_TNW = (D.f[dirBSE ])[kbse ]; + f_TSE = (D.f[dirBNW ])[kbnw ]; + + //////////////////////////////////////////////////////////////////////////////// + real vx1, vx2, vx3, drho, feq, q; + drho = f_TSE + f_TNW + f_TNE + f_TSW + f_BSE + f_BNW + f_BNE + f_BSW + + f_BN + f_TS + f_TN + f_BS + f_BE + f_TW + f_TE + f_BW + f_SE + f_NW + f_NE + f_SW + + f_T + f_B + f_N + f_S + f_E + f_W + ((D.f[dirZERO])[kzero]); + + vx1 = (((f_TSE - f_BNW) - (f_TNW - f_BSE)) + ((f_TNE - f_BSW) - (f_TSW - f_BNE)) + + ((f_BE - f_TW) + (f_TE - f_BW)) + ((f_SE - f_NW) + (f_NE - f_SW)) + + (f_E - f_W)) / (c1o1 + drho); + + + vx2 = ((-(f_TSE - f_BNW) + (f_TNW - f_BSE)) + ((f_TNE - f_BSW) - (f_TSW - f_BNE)) + + ((f_BN - f_TS) + (f_TN - f_BS)) + (-(f_SE - f_NW) + (f_NE - f_SW)) + + (f_N - f_S)) / (c1o1 + drho); + + vx3 = (((f_TSE - f_BNW) + (f_TNW - f_BSE)) + ((f_TNE - f_BSW) + (f_TSW - f_BNE)) + + (-(f_BN - f_TS) + (f_TN - f_BS)) + ((f_TE - f_BW) - (f_BE - f_TW)) + + (f_T - f_B)) / (c1o1 + drho); + + real cu_sq=c3o2*(vx1*vx1+vx2*vx2+vx3*vx3) * (c1o1 + drho); + + real om_turb = om1 / (c1o1 + c3o1*om1*max(c0o1, turbViscosity[k_Q[k]])); + ////////////////////////////////////////////////////////////////////////// + if (evenOrOdd==false) //get adress where incoming f's should be written to + { + D.f[dirE ] = &DD[dirE *size_Mat]; + D.f[dirW ] = &DD[dirW *size_Mat]; + D.f[dirN ] = &DD[dirN *size_Mat]; + D.f[dirS ] = &DD[dirS *size_Mat]; + D.f[dirT ] = &DD[dirT *size_Mat]; + D.f[dirB ] = &DD[dirB *size_Mat]; + D.f[dirNE ] = &DD[dirNE *size_Mat]; + D.f[dirSW ] = &DD[dirSW *size_Mat]; + D.f[dirSE ] = &DD[dirSE *size_Mat]; + D.f[dirNW ] = &DD[dirNW *size_Mat]; + D.f[dirTE ] = &DD[dirTE *size_Mat]; + D.f[dirBW ] = &DD[dirBW *size_Mat]; + D.f[dirBE ] = &DD[dirBE *size_Mat]; + D.f[dirTW ] = &DD[dirTW *size_Mat]; + D.f[dirTN ] = &DD[dirTN *size_Mat]; + D.f[dirBS ] = &DD[dirBS *size_Mat]; + D.f[dirBN ] = &DD[dirBN *size_Mat]; + D.f[dirTS ] = &DD[dirTS *size_Mat]; + D.f[dirZERO] = &DD[dirZERO*size_Mat]; + D.f[dirTNE ] = &DD[dirTNE *size_Mat]; + D.f[dirTSW ] = &DD[dirTSW *size_Mat]; + D.f[dirTSE ] = &DD[dirTSE *size_Mat]; + D.f[dirTNW ] = &DD[dirTNW *size_Mat]; + D.f[dirBNE ] = &DD[dirBNE *size_Mat]; + D.f[dirBSW ] = &DD[dirBSW *size_Mat]; + D.f[dirBSE ] = &DD[dirBSE *size_Mat]; + D.f[dirBNW ] = &DD[dirBNW *size_Mat]; + } + else + { + D.f[dirW ] = &DD[dirE *size_Mat]; + D.f[dirE ] = &DD[dirW *size_Mat]; + D.f[dirS ] = &DD[dirN *size_Mat]; + D.f[dirN ] = &DD[dirS *size_Mat]; + D.f[dirB ] = &DD[dirT *size_Mat]; + D.f[dirT ] = &DD[dirB *size_Mat]; + D.f[dirSW ] = &DD[dirNE *size_Mat]; + D.f[dirNE ] = &DD[dirSW *size_Mat]; + D.f[dirNW ] = &DD[dirSE *size_Mat]; + D.f[dirSE ] = &DD[dirNW *size_Mat]; + D.f[dirBW ] = &DD[dirTE *size_Mat]; + D.f[dirTE ] = &DD[dirBW *size_Mat]; + D.f[dirTW ] = &DD[dirBE *size_Mat]; + D.f[dirBE ] = &DD[dirTW *size_Mat]; + D.f[dirBS ] = &DD[dirTN *size_Mat]; + D.f[dirTN ] = &DD[dirBS *size_Mat]; + D.f[dirTS ] = &DD[dirBN *size_Mat]; + D.f[dirBN ] = &DD[dirTS *size_Mat]; + D.f[dirZERO] = &DD[dirZERO*size_Mat]; + D.f[dirTNE ] = &DD[dirBSW *size_Mat]; + D.f[dirTSW ] = &DD[dirBNE *size_Mat]; + D.f[dirTSE ] = &DD[dirBNW *size_Mat]; + D.f[dirTNW ] = &DD[dirBSE *size_Mat]; + D.f[dirBNE ] = &DD[dirTSW *size_Mat]; + D.f[dirBSW ] = &DD[dirTNE *size_Mat]; + D.f[dirBSE ] = &DD[dirTNW *size_Mat]; + D.f[dirBNW ] = &DD[dirTSE *size_Mat]; + } + //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //Compute incoming f's with zero wall velocity + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + // incoming f's from bounce back + real f_E_in = 0.0, f_W_in = 0.0, f_N_in = 0.0, f_S_in = 0.0, f_T_in = 0.0, f_B_in = 0.0, f_NE_in = 0.0, f_SW_in = 0.0, f_SE_in = 0.0, f_NW_in = 0.0, f_TE_in = 0.0, f_BW_in = 0.0, f_BE_in = 0.0, f_TW_in = 0.0, f_TN_in = 0.0, f_BS_in = 0.0, f_BN_in = 0.0, f_TS_in = 0.0, f_TNE_in = 0.0, f_TSW_in = 0.0, f_TSE_in = 0.0, f_TNW_in = 0.0, f_BNE_in = 0.0, f_BSW_in = 0.0, f_BSE_in = 0.0, f_BNW_in = 0.0; + // momentum exchanged with wall at rest + real wallMomentumX = 0.0, wallMomentumY = 0.0, wallMomentumZ = 0.0; + + q = q_dirE[k]; + if (q>=c0o1 && q<=c1o1) + { + feq=c2o27* (drho/*+three*( vx1 )*/+c9o2*( vx1 )*( vx1 ) * (c1o1 + drho)-cu_sq); + f_W_in=(c1o1-q)/(c1o1+q)*(f_E-f_W+(f_E+f_W-c2o1*feq*om_turb)/(c1o1-om_turb))*c1o2+(q*(f_E+f_W))/(c1o1+q) - c2o27 * drho; + wallMomentumX += f_E+f_W_in; + } + + q = q_dirW[k]; + if (q>=c0o1 && q<=c1o1) + { + feq=c2o27* (drho/*+three*(-vx1 )*/+c9o2*(-vx1 )*(-vx1 ) * (c1o1 + drho)-cu_sq); + f_E_in=(c1o1-q)/(c1o1+q)*(f_W-f_E+(f_W+f_E-c2o1*feq*om_turb)/(c1o1-om_turb))*c1o2+(q*(f_W+f_E))/(c1o1+q) - c2o27 * drho; + wallMomentumX -= f_W+f_E_in; + } + + q = q_dirN[k]; + if (q>=c0o1 && q<=c1o1) + { + feq=c2o27* (drho/*+three*( vx2 )*/+c9o2*( vx2 )*( vx2 ) * (c1o1 + drho)-cu_sq); + f_S_in=(c1o1-q)/(c1o1+q)*(f_N-f_S+(f_N+f_S-c2o1*feq*om_turb)/(c1o1-om_turb))*c1o2+(q*(f_N+f_S))/(c1o1+q) - c2o27 * drho; + wallMomentumY += f_N+f_S_in; + } + + q = q_dirS[k]; + if (q>=c0o1 && q<=c1o1) + { + feq=c2o27* (drho/*+three*( -vx2 )*/+c9o2*( -vx2 )*( -vx2 ) * (c1o1 + drho)-cu_sq); + f_N_in=(c1o1-q)/(c1o1+q)*(f_S-f_N+(f_S+f_N-c2o1*feq*om_turb)/(c1o1-om_turb))*c1o2+(q*(f_S+f_N))/(c1o1+q) - c2o27 * drho; + wallMomentumY -= f_S+f_N_in; + } + + q = q_dirT[k]; + if (q>=c0o1 && q<=c1o1) + { + feq=c2o27* (drho/*+three*( vx3)*/+c9o2*( vx3)*( vx3) * (c1o1 + drho)-cu_sq); + f_B_in=(c1o1-q)/(c1o1+q)*(f_T-f_B+(f_T+f_B-c2o1*feq*om_turb)/(c1o1-om_turb))*c1o2+(q*(f_T+f_B))/(c1o1+q) - c2o27 * drho; + wallMomentumZ += f_T+f_B_in; + } + + q = q_dirB[k]; + if (q>=c0o1 && q<=c1o1) + { + feq=c2o27* (drho/*+three*( -vx3)*/+c9o2*( -vx3)*( -vx3) * (c1o1 + drho)-cu_sq); + f_T_in=(c1o1-q)/(c1o1+q)*(f_B-f_T+(f_B+f_T-c2o1*feq*om_turb)/(c1o1-om_turb))*c1o2+(q*(f_B+f_T))/(c1o1+q) - c2o27 * drho; + wallMomentumZ -= f_B+f_T_in; + } + + q = q_dirNE[k]; + if (q>=c0o1 && q<=c1o1) + { + feq=c1o54* (drho/*+three*( vx1+vx2 )*/+c9o2*( vx1+vx2 )*( vx1+vx2 ) * (c1o1 + drho)-cu_sq); + f_SW_in=(c1o1-q)/(c1o1+q)*(f_NE-f_SW+(f_NE+f_SW-c2o1*feq*om_turb)/(c1o1-om_turb))*c1o2+(q*(f_NE+f_SW))/(c1o1+q) - c1o54 * drho; + wallMomentumX += f_NE+f_SW_in; + wallMomentumY += f_NE+f_SW_in; + } + + q = q_dirSW[k]; + if (q>=c0o1 && q<=c1o1) + { + feq=c1o54* (drho/*+three*(-vx1-vx2 )*/+c9o2*(-vx1-vx2 )*(-vx1-vx2 ) * (c1o1 + drho)-cu_sq); + f_NE_in=(c1o1-q)/(c1o1+q)*(f_SW-f_NE+(f_SW+f_NE-c2o1*feq*om_turb)/(c1o1-om_turb))*c1o2+(q*(f_SW+f_NE))/(c1o1+q) - c1o54 * drho; + wallMomentumX -= f_SW+f_NE_in; + wallMomentumY -= f_SW+f_NE_in; + } + + q = q_dirSE[k]; + if (q>=c0o1 && q<=c1o1) + { + feq=c1o54* (drho/*+three*( vx1-vx2 )*/+c9o2*( vx1-vx2 )*( vx1-vx2 ) * (c1o1 + drho)-cu_sq); + f_NW_in=(c1o1-q)/(c1o1+q)*(f_SE-f_NW+(f_SE+f_NW-c2o1*feq*om_turb)/(c1o1-om_turb))*c1o2+(q*(f_SE+f_NW))/(c1o1+q) - c1o54 * drho; + wallMomentumX += f_SE+f_NW_in; + wallMomentumY -= f_SE+f_NW_in; + } + + q = q_dirNW[k]; + if (q>=c0o1 && q<=c1o1) + { + feq=c1o54* (drho/*+three*(-vx1+vx2 )*/+c9o2*(-vx1+vx2 )*(-vx1+vx2 ) * (c1o1 + drho)-cu_sq); + f_SE_in=(c1o1-q)/(c1o1+q)*(f_NW-f_SE+(f_NW+f_SE-c2o1*feq*om_turb)/(c1o1-om_turb))*c1o2+(q*(f_NW+f_SE))/(c1o1+q) - c1o54 * drho; + wallMomentumX -= f_NW+f_SE_in; + wallMomentumY += f_NW+f_SE_in; + } + + q = q_dirTE[k]; + if (q>=c0o1 && q<=c1o1) + { + feq=c1o54* (drho/*+three*( vx1 +vx3)*/+c9o2*( vx1 +vx3)*( vx1 +vx3) * (c1o1 + drho)-cu_sq); + f_BW_in=(c1o1-q)/(c1o1+q)*(f_TE-f_BW+(f_TE+f_BW-c2o1*feq*om_turb)/(c1o1-om_turb))*c1o2+(q*(f_TE+f_BW))/(c1o1+q) - c1o54 * drho; + wallMomentumX += f_TE+f_BW_in; + wallMomentumZ += f_TE+f_BW_in; + } + + q = q_dirBW[k]; + if (q>=c0o1 && q<=c1o1) + { + feq=c1o54* (drho/*+three*(-vx1 -vx3)*/+c9o2*(-vx1 -vx3)*(-vx1 -vx3) * (c1o1 + drho)-cu_sq); + f_TE_in=(c1o1-q)/(c1o1+q)*(f_BW-f_TE+(f_BW+f_TE-c2o1*feq*om_turb)/(c1o1-om_turb))*c1o2+(q*(f_BW+f_TE))/(c1o1+q) - c1o54 * drho; + wallMomentumX -= f_BW+f_TE_in; + wallMomentumZ -= f_BW+f_TE_in; + } + + q = q_dirBE[k]; + if (q>=c0o1 && q<=c1o1) + { + feq=c1o54* (drho/*+three*( vx1 -vx3)*/+c9o2*( vx1 -vx3)*( vx1 -vx3) * (c1o1 + drho)-cu_sq); + f_TW_in=(c1o1-q)/(c1o1+q)*(f_BE-f_TW+(f_BE+f_TW-c2o1*feq*om_turb)/(c1o1-om_turb))*c1o2+(q*(f_BE+f_TW))/(c1o1+q) - c1o54 * drho; + wallMomentumX += f_BE+f_TW_in; + wallMomentumZ -= f_BE+f_TW_in; + } + + q = q_dirTW[k]; + if (q>=c0o1 && q<=c1o1) + { + feq=c1o54* (drho/*+three*(-vx1 +vx3)*/+c9o2*(-vx1 +vx3)*(-vx1 +vx3) * (c1o1 + drho)-cu_sq); + f_BE_in=(c1o1-q)/(c1o1+q)*(f_TW-f_BE+(f_TW+f_BE-c2o1*feq*om_turb)/(c1o1-om_turb))*c1o2+(q*(f_TW+f_BE))/(c1o1+q) - c1o54 * drho; + wallMomentumX -= f_TW+f_BE_in; + wallMomentumZ += f_TW+f_BE_in; + } + + q = q_dirTN[k]; + if (q>=c0o1 && q<=c1o1) + { + feq=c1o54* (drho/*+three*( vx2+vx3)*/+c9o2*( vx2+vx3)*( vx2+vx3) * (c1o1 + drho)-cu_sq); + f_BS_in=(c1o1-q)/(c1o1+q)*(f_TN-f_BS+(f_TN+f_BS-c2o1*feq*om_turb)/(c1o1-om_turb))*c1o2+(q*(f_TN+f_BS))/(c1o1+q) - c1o54 * drho; + wallMomentumY += f_TN+f_BS_in; + wallMomentumZ += f_TN+f_BS_in; + } + + q = q_dirBS[k]; + if (q>=c0o1 && q<=c1o1) + { + feq=c1o54* (drho/*+three*( -vx2-vx3)*/+c9o2*( -vx2-vx3)*( -vx2-vx3) * (c1o1 + drho)-cu_sq); + f_TN_in=(c1o1-q)/(c1o1+q)*(f_BS-f_TN+(f_BS+f_TN-c2o1*feq*om_turb)/(c1o1-om_turb))*c1o2+(q*(f_BS+f_TN))/(c1o1+q) - c1o54 * drho; + wallMomentumY -= f_BS+f_TN_in; + wallMomentumZ -= f_BS+f_TN_in; + } + + q = q_dirBN[k]; + if (q>=c0o1 && q<=c1o1) + { + feq=c1o54* (drho/*+three*( vx2-vx3)*/+c9o2*( vx2-vx3)*( vx2-vx3) * (c1o1 + drho)-cu_sq); + f_TS_in=(c1o1-q)/(c1o1+q)*(f_BN-f_TS+(f_BN+f_TS-c2o1*feq*om_turb)/(c1o1-om_turb))*c1o2+(q*(f_BN+f_TS))/(c1o1+q) - c1o54 * drho; + wallMomentumY += f_BN+f_TS_in; + wallMomentumZ -= f_BN+f_TS_in; + } + + q = q_dirTS[k]; + if (q>=c0o1 && q<=c1o1) + { + feq=c1o54* (drho/*+three*( -vx2+vx3)*/+c9o2*( -vx2+vx3)*( -vx2+vx3) * (c1o1 + drho)-cu_sq); + f_BN_in=(c1o1-q)/(c1o1+q)*(f_TS-f_BN+(f_TS+f_BN-c2o1*feq*om_turb)/(c1o1-om_turb))*c1o2+(q*(f_TS+f_BN))/(c1o1+q) - c1o54 * drho; + wallMomentumY -= f_TS+f_BN_in; + wallMomentumZ += f_TS+f_BN_in; + } + + q = q_dirTNE[k]; + if (q>=c0o1 && q<=c1o1) + { + feq=c1o216*(drho/*+three*( vx1+vx2+vx3)*/+c9o2*( vx1+vx2+vx3)*( vx1+vx2+vx3) * (c1o1 + drho)-cu_sq); + f_BSW_in=(c1o1-q)/(c1o1+q)*(f_TNE-f_BSW+(f_TNE+f_BSW-c2o1*feq*om_turb)/(c1o1-om_turb))*c1o2+(q*(f_TNE+f_BSW))/(c1o1+q) - c1o216 * drho; + wallMomentumX += f_TNE+f_BSW_in; + wallMomentumY += f_TNE+f_BSW_in; + wallMomentumZ += f_TNE+f_BSW_in; + } + + q = q_dirBSW[k]; + if (q>=c0o1 && q<=c1o1) + { + feq=c1o216*(drho/*+three*(-vx1-vx2-vx3)*/+c9o2*(-vx1-vx2-vx3)*(-vx1-vx2-vx3) * (c1o1 + drho)-cu_sq); + f_TNE_in=(c1o1-q)/(c1o1+q)*(f_BSW-f_TNE+(f_BSW+f_TNE-c2o1*feq*om_turb)/(c1o1-om_turb))*c1o2+(q*(f_BSW+f_TNE))/(c1o1+q) - c1o216 * drho; + wallMomentumX -= f_BSW+f_TNE_in; + wallMomentumY -= f_BSW+f_TNE_in; + wallMomentumZ -= f_BSW+f_TNE_in; + } + + q = q_dirBNE[k]; + if (q>=c0o1 && q<=c1o1) + { + feq=c1o216*(drho/*+three*( vx1+vx2-vx3)*/+c9o2*( vx1+vx2-vx3)*( vx1+vx2-vx3) * (c1o1 + drho)-cu_sq); + f_TSW_in=(c1o1-q)/(c1o1+q)*(f_BNE-f_TSW+(f_BNE+f_TSW-c2o1*feq*om_turb)/(c1o1-om_turb))*c1o2+(q*(f_BNE+f_TSW))/(c1o1+q) - c1o216 * drho; + wallMomentumX += f_BNE+f_TSW_in; + wallMomentumY += f_BNE+f_TSW_in; + wallMomentumZ -= f_BNE+f_TSW_in; + } + + q = q_dirTSW[k]; + if (q>=c0o1 && q<=c1o1) + { + feq=c1o216*(drho/*+three*(-vx1-vx2+vx3)*/+c9o2*(-vx1-vx2+vx3)*(-vx1-vx2+vx3) * (c1o1 + drho)-cu_sq); + f_BNE_in=(c1o1-q)/(c1o1+q)*(f_TSW-f_BNE+(f_TSW+f_BNE-c2o1*feq*om_turb)/(c1o1-om_turb))*c1o2+(q*(f_TSW+f_BNE))/(c1o1+q) - c1o216 * drho; + wallMomentumX -= f_TSW+f_BNE_in; + wallMomentumY -= f_TSW+f_BNE_in; + wallMomentumZ += f_TSW+f_BNE_in; + } + + q = q_dirTSE[k]; + if (q>=c0o1 && q<=c1o1) + { + feq=c1o216*(drho/*+three*( vx1-vx2+vx3)*/+c9o2*( vx1-vx2+vx3)*( vx1-vx2+vx3) * (c1o1 + drho)-cu_sq); + f_BNW_in=(c1o1-q)/(c1o1+q)*(f_TSE-f_BNW+(f_TSE+f_BNW-c2o1*feq*om_turb)/(c1o1-om_turb))*c1o2+(q*(f_TSE+f_BNW))/(c1o1+q) - c1o216 * drho; + wallMomentumX += f_TSE+f_BNW_in; + wallMomentumY -= f_TSE+f_BNW_in; + wallMomentumZ += f_TSE+f_BNW_in; + } + + q = q_dirBNW[k]; + if (q>=c0o1 && q<=c1o1) + { + feq=c1o216*(drho/*+three*(-vx1+vx2-vx3)*/+c9o2*(-vx1+vx2-vx3)*(-vx1+vx2-vx3) * (c1o1 + drho)-cu_sq); + f_TSE_in=(c1o1-q)/(c1o1+q)*(f_BNW-f_TSE+(f_BNW+f_TSE-c2o1*feq*om_turb)/(c1o1-om_turb))*c1o2+(q*(f_BNW+f_TSE))/(c1o1+q) - c1o216 * drho; + wallMomentumX -= f_BNW+f_TSE_in; + wallMomentumY += f_BNW+f_TSE_in; + wallMomentumZ -= f_BNW+f_TSE_in; + } + + q = q_dirBSE[k]; + if (q>=c0o1 && q<=c1o1) + { + feq=c1o216*(drho/*+three*( vx1-vx2-vx3)*/+c9o2*( vx1-vx2-vx3)*( vx1-vx2-vx3) * (c1o1 + drho)-cu_sq); + f_TNW_in=(c1o1-q)/(c1o1+q)*(f_BSE-f_TNW+(f_BSE+f_TNW-c2o1*feq*om_turb)/(c1o1-om_turb))*c1o2+(q*(f_BSE+f_TNW))/(c1o1+q) - c1o216 * drho; + wallMomentumX += f_BSE+f_TNW_in; + wallMomentumY -= f_BSE+f_TNW_in; + wallMomentumZ -= f_BSE+f_TNW_in; + } + + q = q_dirTNW[k]; + if (q>=c0o1 && q<=c1o1) + { + feq=c1o216*(drho/*+three*(-vx1+vx2+vx3)*/+c9o2*(-vx1+vx2+vx3)*(-vx1+vx2+vx3) * (c1o1 + drho)-cu_sq); + f_BSE_in=(c1o1-q)/(c1o1+q)*(f_TNW-f_BSE+(f_TNW+f_BSE-c2o1*feq*om_turb)/(c1o1-om_turb))*c1o2+(q*(f_TNW+f_BSE))/(c1o1+q) - c1o216 * drho; + wallMomentumX -= f_TNW+f_BSE_in; + wallMomentumY += f_TNW+f_BSE_in; + wallMomentumZ += f_TNW+f_BSE_in; + } + + // //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // //Compute wall velocity + // //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + real VeloX=0.0, VeloY=0.0, VeloZ=0.0; + + q = 0.5f; + real eps = 0.001f; + + iMEM( k, k_N[k], + normalX, normalY, normalZ, + vx, vy, vz, + vx_el, vy_el, vz_el, + vx_w_mean, vy_w_mean, vz_w_mean, + vx1, vx2, vx3, + c1o1+drho, + samplingOffset, + q, + 1.0+q, + eps, + z0, + hasWallModelMonitor, + u_star_monitor, + wallMomentumX, wallMomentumY, wallMomentumZ, + VeloX, VeloY, VeloZ); + + // //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // //Add wall velocity and write f's + // //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + q = q_dirE[k]; + if (q>=c0o1 && q<=c1o1) + { + (D.f[dirW])[kw] = f_W_in - (c6o1*c2o27*( VeloX ))/(c1o1+q); + wallMomentumX += -(c6o1*c2o27*( VeloX ))/(c1o1+q); + } + + q = q_dirW[k]; + if (q>=c0o1 && q<=c1o1) + { + (D.f[dirE])[ke] = f_E_in - (c6o1*c2o27*(-VeloX ))/(c1o1+q); + wallMomentumX -= - (c6o1*c2o27*(-VeloX ))/(c1o1+q); + } + + q = q_dirN[k]; + if (q>=c0o1 && q<=c1o1) + { + (D.f[dirS])[ks] = f_S_in - (c6o1*c2o27*( VeloY ))/(c1o1+q); + wallMomentumY += - (c6o1*c2o27*( VeloY ))/(c1o1+q); + } + + q = q_dirS[k]; + if (q>=c0o1 && q<=c1o1) + { + (D.f[dirN])[kn] = f_N_in - (c6o1*c2o27*(-VeloY ))/(c1o1+q); + wallMomentumY -= -(c6o1*c2o27*(-VeloY ))/(c1o1+q); + } + + q = q_dirT[k]; + if (q>=c0o1 && q<=c1o1) + { + (D.f[dirB])[kb] = f_B_in - (c6o1*c2o27*( VeloZ ))/(c1o1+q); + wallMomentumZ += - (c6o1*c2o27*( VeloZ ))/(c1o1+q); + } + + q = q_dirB[k]; + if (q>=c0o1 && q<=c1o1) + { + (D.f[dirT])[kt] = f_T_in - (c6o1*c2o27*(-VeloZ ))/(c1o1+q); + wallMomentumZ -= -(c6o1*c2o27*(-VeloZ ))/(c1o1+q); + } + + q = q_dirNE[k]; + if (q>=c0o1 && q<=c1o1) + { + (D.f[dirSW])[ksw] = f_SW_in - (c6o1*c1o54*(VeloX+VeloY))/(c1o1+q); + wallMomentumX += -(c6o1*c1o54*(VeloX+VeloY))/(c1o1+q); + wallMomentumY += -(c6o1*c1o54*(VeloX+VeloY))/(c1o1+q); + } + + q = q_dirSW[k]; + if (q>=c0o1 && q<=c1o1) + { + (D.f[dirNE])[kne] = f_NE_in - (c6o1*c1o54*(-VeloX-VeloY))/(c1o1+q); + wallMomentumX -= - (c6o1*c1o54*(-VeloX-VeloY))/(c1o1+q); + wallMomentumY -= - (c6o1*c1o54*(-VeloX-VeloY))/(c1o1+q); + } + + q = q_dirSE[k]; + if (q>=c0o1 && q<=c1o1) + { + (D.f[dirNW])[knw] = f_NW_in - (c6o1*c1o54*( VeloX-VeloY))/(c1o1+q); + wallMomentumX += -(c6o1*c1o54*( VeloX-VeloY))/(c1o1+q); + wallMomentumY -= -(c6o1*c1o54*( VeloX-VeloY))/(c1o1+q); + } + + q = q_dirNW[k]; + if (q>=c0o1 && q<=c1o1) + { + (D.f[dirSE])[kse] = f_SE_in - (c6o1*c1o54*(-VeloX+VeloY))/(c1o1+q); + wallMomentumX -= - (c6o1*c1o54*(-VeloX+VeloY))/(c1o1+q); + wallMomentumY += - (c6o1*c1o54*(-VeloX+VeloY))/(c1o1+q); + } + + q = q_dirTE[k]; + if (q>=c0o1 && q<=c1o1) + { + (D.f[dirBW])[kbw] = f_BW_in - (c6o1*c1o54*( VeloX+VeloZ))/(c1o1+q); + wallMomentumX += - (c6o1*c1o54*( VeloX+VeloZ))/(c1o1+q); + wallMomentumZ += - (c6o1*c1o54*( VeloX+VeloZ))/(c1o1+q); + } + + q = q_dirBW[k]; + if (q>=c0o1 && q<=c1o1) + { + (D.f[dirTE])[kte] = f_TE_in - (c6o1*c1o54*(-VeloX-VeloZ))/(c1o1+q); + wallMomentumX -= - (c6o1*c1o54*(-VeloX-VeloZ))/(c1o1+q); + wallMomentumZ -= - (c6o1*c1o54*(-VeloX-VeloZ))/(c1o1+q); + } + + q = q_dirBE[k]; + if (q>=c0o1 && q<=c1o1) + { + (D.f[dirTW])[ktw] = f_TW_in - (c6o1*c1o54*( VeloX-VeloZ))/(c1o1+q); + wallMomentumX += - (c6o1*c1o54*( VeloX-VeloZ))/(c1o1+q); + wallMomentumZ -= - (c6o1*c1o54*( VeloX-VeloZ))/(c1o1+q); + } + + q = q_dirTW[k]; + if (q>=c0o1 && q<=c1o1) + { + (D.f[dirBE])[kbe] = f_BE_in - (c6o1*c1o54*(-VeloX+VeloZ))/(c1o1+q); + wallMomentumX -= - (c6o1*c1o54*(-VeloX+VeloZ))/(c1o1+q); + wallMomentumZ += - (c6o1*c1o54*(-VeloX+VeloZ))/(c1o1+q); + } + + q = q_dirTN[k]; + if (q>=c0o1 && q<=c1o1) + { + (D.f[dirBS])[kbs] = f_BS_in - (c6o1*c1o54*( VeloY+VeloZ))/(c1o1+q); + wallMomentumY += - (c6o1*c1o54*( VeloY+VeloZ))/(c1o1+q); + wallMomentumZ += - (c6o1*c1o54*( VeloY+VeloZ))/(c1o1+q); + } + + q = q_dirBS[k]; + if (q>=c0o1 && q<=c1o1) + { + (D.f[dirTN])[ktn] = f_TN_in - (c6o1*c1o54*( -VeloY-VeloZ))/(c1o1+q); + wallMomentumY -= - (c6o1*c1o54*( -VeloY-VeloZ))/(c1o1+q); + wallMomentumZ -= - (c6o1*c1o54*( -VeloY-VeloZ))/(c1o1+q); + } + + q = q_dirBN[k]; + if (q>=c0o1 && q<=c1o1) + { + (D.f[dirTS])[kts] = f_TS_in - (c6o1*c1o54*( VeloY-VeloZ))/(c1o1+q); + wallMomentumY += - (c6o1*c1o54*( VeloY-VeloZ))/(c1o1+q); + wallMomentumZ -= - (c6o1*c1o54*( VeloY-VeloZ))/(c1o1+q); + } + + q = q_dirTS[k]; + if (q>=c0o1 && q<=c1o1) + { + (D.f[dirBN])[kbn] = f_BN_in - (c6o1*c1o54*( -VeloY+VeloZ))/(c1o1+q); + wallMomentumY -= - (c6o1*c1o54*( -VeloY+VeloZ))/(c1o1+q); + wallMomentumZ += - (c6o1*c1o54*( -VeloY+VeloZ))/(c1o1+q); + } + + q = q_dirTNE[k]; + if (q>=c0o1 && q<=c1o1) + { + (D.f[dirBSW])[kbsw] = f_BSW_in - (c6o1*c1o216*( VeloX+VeloY+VeloZ))/(c1o1+q); + wallMomentumX += - (c6o1*c1o216*( VeloX+VeloY+VeloZ))/(c1o1+q); + wallMomentumY += - (c6o1*c1o216*( VeloX+VeloY+VeloZ))/(c1o1+q); + wallMomentumZ += - (c6o1*c1o216*( VeloX+VeloY+VeloZ))/(c1o1+q); + } + + q = q_dirBSW[k]; + if (q>=c0o1 && q<=c1o1) + { + (D.f[dirTNE])[ktne] = f_TNE_in - (c6o1*c1o216*(-VeloX-VeloY-VeloZ))/(c1o1+q); + wallMomentumX -= - (c6o1*c1o216*(-VeloX-VeloY-VeloZ))/(c1o1+q); + wallMomentumY -= - (c6o1*c1o216*(-VeloX-VeloY-VeloZ))/(c1o1+q); + wallMomentumZ -= - (c6o1*c1o216*(-VeloX-VeloY-VeloZ))/(c1o1+q); + } + + q = q_dirBNE[k]; + if (q>=c0o1 && q<=c1o1) + { + (D.f[dirTSW])[ktsw] = f_TSW_in - (c6o1*c1o216*( VeloX+VeloY-VeloZ))/(c1o1+q); + wallMomentumX += - (c6o1*c1o216*( VeloX+VeloY-VeloZ))/(c1o1+q); + wallMomentumY += - (c6o1*c1o216*( VeloX+VeloY-VeloZ))/(c1o1+q); + wallMomentumZ -= - (c6o1*c1o216*( VeloX+VeloY-VeloZ))/(c1o1+q); + } + + q = q_dirTSW[k]; + if (q>=c0o1 && q<=c1o1) + { + (D.f[dirBNE])[kbne] = f_BNE_in - (c6o1*c1o216*(-VeloX-VeloY+VeloZ))/(c1o1+q); + wallMomentumX -= - (c6o1*c1o216*(-VeloX-VeloY+VeloZ))/(c1o1+q); + wallMomentumY -= - (c6o1*c1o216*(-VeloX-VeloY+VeloZ))/(c1o1+q); + wallMomentumZ += - (c6o1*c1o216*(-VeloX-VeloY+VeloZ))/(c1o1+q); + } + + q = q_dirTSE[k]; + if (q>=c0o1 && q<=c1o1) + { + (D.f[dirBNW])[kbnw] = f_BNW_in - (c6o1*c1o216*( VeloX-VeloY+VeloZ))/(c1o1+q); + wallMomentumX += - (c6o1*c1o216*( VeloX-VeloY+VeloZ))/(c1o1+q); + wallMomentumY -= - (c6o1*c1o216*( VeloX-VeloY+VeloZ))/(c1o1+q); + wallMomentumZ += - (c6o1*c1o216*( VeloX-VeloY+VeloZ))/(c1o1+q); + } + + q = q_dirBNW[k]; + if (q>=c0o1 && q<=c1o1) + { + (D.f[dirTSE])[ktse] = f_TSE_in - (c6o1*c1o216*(-VeloX+VeloY-VeloZ))/(c1o1+q); + wallMomentumX -= - (c6o1*c1o216*(-VeloX+VeloY-VeloZ))/(c1o1+q); + wallMomentumY += - (c6o1*c1o216*(-VeloX+VeloY-VeloZ))/(c1o1+q); + wallMomentumZ -= - (c6o1*c1o216*(-VeloX+VeloY-VeloZ))/(c1o1+q); + } + + q = q_dirBSE[k]; + if (q>=c0o1 && q<=c1o1) + { + (D.f[dirTNW])[ktnw] = f_TNW_in - (c6o1*c1o216*( VeloX-VeloY-VeloZ))/(c1o1+q); + wallMomentumX += - (c6o1*c1o216*( VeloX-VeloY-VeloZ))/(c1o1+q); + wallMomentumY -= - (c6o1*c1o216*( VeloX-VeloY-VeloZ))/(c1o1+q); + wallMomentumZ -= - (c6o1*c1o216*( VeloX-VeloY-VeloZ))/(c1o1+q); + } + + q = q_dirTNW[k]; + if (q>=c0o1 && q<=c1o1) + { + (D.f[dirBSE])[kbse] = f_BSE_in - (c6o1*c1o216*(-VeloX+VeloY+VeloZ))/(c1o1+q); + wallMomentumX -= - (c6o1*c1o216*(-VeloX+VeloY+VeloZ))/(c1o1+q); + wallMomentumY += - (c6o1*c1o216*(-VeloX+VeloY+VeloZ))/(c1o1+q); + wallMomentumZ += - (c6o1*c1o216*(-VeloX+VeloY+VeloZ))/(c1o1+q); + } + + if(hasWallModelMonitor) + { + Fx_monitor[k] = wallMomentumX; + Fy_monitor[k] = wallMomentumY; + Fz_monitor[k] = wallMomentumZ; + } + + } +} + +////////////////////////////////////////////////////////////////////////////// +extern "C" __global__ void BBStressDevice27( real* DD, + int* k_Q, + int* k_N, + real* QQ, + unsigned int sizeQ, + real* vx, + real* vy, + real* vz, + real* normalX, + real* normalY, + real* normalZ, + real* vx_el, + real* vy_el, + real* vz_el, + real* vx_w_mean, + real* vy_w_mean, + real* vz_w_mean, + int* samplingOffset, + real* z0, + bool hasWallModelMonitor, + real* u_star_monitor, + real* Fx_monitor, + real* Fy_monitor, + real* Fz_monitor, + unsigned int* neighborX, + unsigned int* neighborY, + unsigned int* neighborZ, + unsigned int size_Mat, + bool evenOrOdd) +{ + Distributions27 D; + if (evenOrOdd==true) + { + D.f[dirE ] = &DD[dirE *size_Mat]; + D.f[dirW ] = &DD[dirW *size_Mat]; + D.f[dirN ] = &DD[dirN *size_Mat]; + D.f[dirS ] = &DD[dirS *size_Mat]; + D.f[dirT ] = &DD[dirT *size_Mat]; + D.f[dirB ] = &DD[dirB *size_Mat]; + D.f[dirNE ] = &DD[dirNE *size_Mat]; + D.f[dirSW ] = &DD[dirSW *size_Mat]; + D.f[dirSE ] = &DD[dirSE *size_Mat]; + D.f[dirNW ] = &DD[dirNW *size_Mat]; + D.f[dirTE ] = &DD[dirTE *size_Mat]; + D.f[dirBW ] = &DD[dirBW *size_Mat]; + D.f[dirBE ] = &DD[dirBE *size_Mat]; + D.f[dirTW ] = &DD[dirTW *size_Mat]; + D.f[dirTN ] = &DD[dirTN *size_Mat]; + D.f[dirBS ] = &DD[dirBS *size_Mat]; + D.f[dirBN ] = &DD[dirBN *size_Mat]; + D.f[dirTS ] = &DD[dirTS *size_Mat]; + D.f[dirZERO] = &DD[dirZERO*size_Mat]; + D.f[dirTNE ] = &DD[dirTNE *size_Mat]; + D.f[dirTSW ] = &DD[dirTSW *size_Mat]; + D.f[dirTSE ] = &DD[dirTSE *size_Mat]; + D.f[dirTNW ] = &DD[dirTNW *size_Mat]; + D.f[dirBNE ] = &DD[dirBNE *size_Mat]; + D.f[dirBSW ] = &DD[dirBSW *size_Mat]; + D.f[dirBSE ] = &DD[dirBSE *size_Mat]; + D.f[dirBNW ] = &DD[dirBNW *size_Mat]; + } + else + { + D.f[dirW ] = &DD[dirE *size_Mat]; + D.f[dirE ] = &DD[dirW *size_Mat]; + D.f[dirS ] = &DD[dirN *size_Mat]; + D.f[dirN ] = &DD[dirS *size_Mat]; + D.f[dirB ] = &DD[dirT *size_Mat]; + D.f[dirT ] = &DD[dirB *size_Mat]; + D.f[dirSW ] = &DD[dirNE *size_Mat]; + D.f[dirNE ] = &DD[dirSW *size_Mat]; + D.f[dirNW ] = &DD[dirSE *size_Mat]; + D.f[dirSE ] = &DD[dirNW *size_Mat]; + D.f[dirBW ] = &DD[dirTE *size_Mat]; + D.f[dirTE ] = &DD[dirBW *size_Mat]; + D.f[dirTW ] = &DD[dirBE *size_Mat]; + D.f[dirBE ] = &DD[dirTW *size_Mat]; + D.f[dirBS ] = &DD[dirTN *size_Mat]; + D.f[dirTN ] = &DD[dirBS *size_Mat]; + D.f[dirTS ] = &DD[dirBN *size_Mat]; + D.f[dirBN ] = &DD[dirTS *size_Mat]; + D.f[dirZERO] = &DD[dirZERO*size_Mat]; + D.f[dirTNE ] = &DD[dirBSW *size_Mat]; + D.f[dirTSW ] = &DD[dirBNE *size_Mat]; + D.f[dirTSE ] = &DD[dirBNW *size_Mat]; + D.f[dirTNW ] = &DD[dirBSE *size_Mat]; + D.f[dirBNE ] = &DD[dirTSW *size_Mat]; + D.f[dirBSW ] = &DD[dirTNE *size_Mat]; + D.f[dirBSE ] = &DD[dirTNW *size_Mat]; + D.f[dirBNW ] = &DD[dirTSE *size_Mat]; + } + //////////////////////////////////////////////////////////////////////////////// + const unsigned x = threadIdx.x; // Globaler x-Index + const unsigned y = blockIdx.x; // Globaler y-Index + const unsigned z = blockIdx.y; // Globaler z-Index + + const unsigned nx = blockDim.x; + const unsigned ny = gridDim.x; + + const unsigned k = nx*(ny*z + y) + x; + ////////////////////////////////////////////////////////////////////////// + + if(k<sizeQ) + { + //////////////////////////////////////////////////////////////////////////////// + real *q_dirE, *q_dirW, *q_dirN, *q_dirS, *q_dirT, *q_dirB, + *q_dirNE, *q_dirSW, *q_dirSE, *q_dirNW, *q_dirTE, *q_dirBW, + *q_dirBE, *q_dirTW, *q_dirTN, *q_dirBS, *q_dirBN, *q_dirTS, + *q_dirTNE, *q_dirTSW, *q_dirTSE, *q_dirTNW, *q_dirBNE, *q_dirBSW, + *q_dirBSE, *q_dirBNW; + q_dirE = &QQ[dirE *sizeQ]; + q_dirW = &QQ[dirW *sizeQ]; + q_dirN = &QQ[dirN *sizeQ]; + q_dirS = &QQ[dirS *sizeQ]; + q_dirT = &QQ[dirT *sizeQ]; + q_dirB = &QQ[dirB *sizeQ]; + q_dirNE = &QQ[dirNE *sizeQ]; + q_dirSW = &QQ[dirSW *sizeQ]; + q_dirSE = &QQ[dirSE *sizeQ]; + q_dirNW = &QQ[dirNW *sizeQ]; + q_dirTE = &QQ[dirTE *sizeQ]; + q_dirBW = &QQ[dirBW *sizeQ]; + q_dirBE = &QQ[dirBE *sizeQ]; + q_dirTW = &QQ[dirTW *sizeQ]; + q_dirTN = &QQ[dirTN *sizeQ]; + q_dirBS = &QQ[dirBS *sizeQ]; + q_dirBN = &QQ[dirBN *sizeQ]; + q_dirTS = &QQ[dirTS *sizeQ]; + q_dirTNE = &QQ[dirTNE *sizeQ]; + q_dirTSW = &QQ[dirTSW *sizeQ]; + q_dirTSE = &QQ[dirTSE *sizeQ]; + q_dirTNW = &QQ[dirTNW *sizeQ]; + q_dirBNE = &QQ[dirBNE *sizeQ]; + q_dirBSW = &QQ[dirBSW *sizeQ]; + q_dirBSE = &QQ[dirBSE *sizeQ]; + q_dirBNW = &QQ[dirBNW *sizeQ]; + //////////////////////////////////////////////////////////////////////////////// + //index + unsigned int KQK = k_Q[k]; + unsigned int kzero= KQK; + unsigned int ke = KQK; + unsigned int kw = neighborX[KQK]; + unsigned int kn = KQK; + unsigned int ks = neighborY[KQK]; + unsigned int kt = KQK; + unsigned int kb = neighborZ[KQK]; + unsigned int ksw = neighborY[kw]; + unsigned int kne = KQK; + unsigned int kse = ks; + unsigned int knw = kw; + unsigned int kbw = neighborZ[kw]; + unsigned int kte = KQK; + unsigned int kbe = kb; + unsigned int ktw = kw; + unsigned int kbs = neighborZ[ks]; + unsigned int ktn = KQK; + unsigned int kbn = kb; + unsigned int kts = ks; + unsigned int ktse = ks; + unsigned int kbnw = kbw; + unsigned int ktnw = kw; + unsigned int kbse = kbs; + unsigned int ktsw = ksw; + unsigned int kbne = kb; + unsigned int ktne = KQK; + unsigned int kbsw = neighborZ[ksw]; + + //////////////////////////////////////////////////////////////////////////////// + real f_E, f_W, f_N, f_S, f_T, f_B, f_NE, f_SW, f_SE, f_NW, f_TE, f_BW, f_BE, + f_TW, f_TN, f_BS, f_BN, f_TS, f_TNE, f_TSW, f_TSE, f_TNW, f_BNE, f_BSW, f_BSE, f_BNW; + + f_W = (D.f[dirE ])[ke ]; + f_E = (D.f[dirW ])[kw ]; + f_S = (D.f[dirN ])[kn ]; + f_N = (D.f[dirS ])[ks ]; + f_B = (D.f[dirT ])[kt ]; + f_T = (D.f[dirB ])[kb ]; + f_SW = (D.f[dirNE ])[kne ]; + f_NE = (D.f[dirSW ])[ksw ]; + f_NW = (D.f[dirSE ])[kse ]; + f_SE = (D.f[dirNW ])[knw ]; + f_BW = (D.f[dirTE ])[kte ]; + f_TE = (D.f[dirBW ])[kbw ]; + f_TW = (D.f[dirBE ])[kbe ]; + f_BE = (D.f[dirTW ])[ktw ]; + f_BS = (D.f[dirTN ])[ktn ]; + f_TN = (D.f[dirBS ])[kbs ]; + f_TS = (D.f[dirBN ])[kbn ]; + f_BN = (D.f[dirTS ])[kts ]; + f_BSW = (D.f[dirTNE ])[ktne ]; + f_BNE = (D.f[dirTSW ])[ktsw ]; + f_BNW = (D.f[dirTSE ])[ktse ]; + f_BSE = (D.f[dirTNW ])[ktnw ]; + f_TSW = (D.f[dirBNE ])[kbne ]; + f_TNE = (D.f[dirBSW ])[kbsw ]; + f_TNW = (D.f[dirBSE ])[kbse ]; + f_TSE = (D.f[dirBNW ])[kbnw ]; + + //////////////////////////////////////////////////////////////////////////////// + real vx1, vx2, vx3, drho; + drho = f_TSE + f_TNW + f_TNE + f_TSW + f_BSE + f_BNW + f_BNE + f_BSW + + f_BN + f_TS + f_TN + f_BS + f_BE + f_TW + f_TE + f_BW + f_SE + f_NW + f_NE + f_SW + + f_T + f_B + f_N + f_S + f_E + f_W + ((D.f[dirZERO])[kzero]); + + vx1 = (((f_TSE - f_BNW) - (f_TNW - f_BSE)) + ((f_TNE - f_BSW) - (f_TSW - f_BNE)) + + ((f_BE - f_TW) + (f_TE - f_BW)) + ((f_SE - f_NW) + (f_NE - f_SW)) + + (f_E - f_W)) / (c1o1 + drho); + + + vx2 = ((-(f_TSE - f_BNW) + (f_TNW - f_BSE)) + ((f_TNE - f_BSW) - (f_TSW - f_BNE)) + + ((f_BN - f_TS) + (f_TN - f_BS)) + (-(f_SE - f_NW) + (f_NE - f_SW)) + + (f_N - f_S)) / (c1o1 + drho); + + vx3 = (((f_TSE - f_BNW) + (f_TNW - f_BSE)) + ((f_TNE - f_BSW) + (f_TSW - f_BNE)) + + (-(f_BN - f_TS) + (f_TN - f_BS)) + ((f_TE - f_BW) - (f_BE - f_TW)) + + (f_T - f_B)) / (c1o1 + drho); + + ////////////////////////////////////////////////////////////////////////// + if (evenOrOdd==false) + { + D.f[dirE ] = &DD[dirE *size_Mat]; + D.f[dirW ] = &DD[dirW *size_Mat]; + D.f[dirN ] = &DD[dirN *size_Mat]; + D.f[dirS ] = &DD[dirS *size_Mat]; + D.f[dirT ] = &DD[dirT *size_Mat]; + D.f[dirB ] = &DD[dirB *size_Mat]; + D.f[dirNE ] = &DD[dirNE *size_Mat]; + D.f[dirSW ] = &DD[dirSW *size_Mat]; + D.f[dirSE ] = &DD[dirSE *size_Mat]; + D.f[dirNW ] = &DD[dirNW *size_Mat]; + D.f[dirTE ] = &DD[dirTE *size_Mat]; + D.f[dirBW ] = &DD[dirBW *size_Mat]; + D.f[dirBE ] = &DD[dirBE *size_Mat]; + D.f[dirTW ] = &DD[dirTW *size_Mat]; + D.f[dirTN ] = &DD[dirTN *size_Mat]; + D.f[dirBS ] = &DD[dirBS *size_Mat]; + D.f[dirBN ] = &DD[dirBN *size_Mat]; + D.f[dirTS ] = &DD[dirTS *size_Mat]; + D.f[dirZERO] = &DD[dirZERO*size_Mat]; + D.f[dirTNE ] = &DD[dirTNE *size_Mat]; + D.f[dirTSW ] = &DD[dirTSW *size_Mat]; + D.f[dirTSE ] = &DD[dirTSE *size_Mat]; + D.f[dirTNW ] = &DD[dirTNW *size_Mat]; + D.f[dirBNE ] = &DD[dirBNE *size_Mat]; + D.f[dirBSW ] = &DD[dirBSW *size_Mat]; + D.f[dirBSE ] = &DD[dirBSE *size_Mat]; + D.f[dirBNW ] = &DD[dirBNW *size_Mat]; + } + else + { + D.f[dirW ] = &DD[dirE *size_Mat]; + D.f[dirE ] = &DD[dirW *size_Mat]; + D.f[dirS ] = &DD[dirN *size_Mat]; + D.f[dirN ] = &DD[dirS *size_Mat]; + D.f[dirB ] = &DD[dirT *size_Mat]; + D.f[dirT ] = &DD[dirB *size_Mat]; + D.f[dirSW ] = &DD[dirNE *size_Mat]; + D.f[dirNE ] = &DD[dirSW *size_Mat]; + D.f[dirNW ] = &DD[dirSE *size_Mat]; + D.f[dirSE ] = &DD[dirNW *size_Mat]; + D.f[dirBW ] = &DD[dirTE *size_Mat]; + D.f[dirTE ] = &DD[dirBW *size_Mat]; + D.f[dirTW ] = &DD[dirBE *size_Mat]; + D.f[dirBE ] = &DD[dirTW *size_Mat]; + D.f[dirBS ] = &DD[dirTN *size_Mat]; + D.f[dirTN ] = &DD[dirBS *size_Mat]; + D.f[dirTS ] = &DD[dirBN *size_Mat]; + D.f[dirBN ] = &DD[dirTS *size_Mat]; + D.f[dirZERO] = &DD[dirZERO*size_Mat]; + D.f[dirTNE ] = &DD[dirBSW *size_Mat]; + D.f[dirTSW ] = &DD[dirBNE *size_Mat]; + D.f[dirTSE ] = &DD[dirBNW *size_Mat]; + D.f[dirTNW ] = &DD[dirBSE *size_Mat]; + D.f[dirBNE ] = &DD[dirTSW *size_Mat]; + D.f[dirBSW ] = &DD[dirTNE *size_Mat]; + D.f[dirBSE ] = &DD[dirTNW *size_Mat]; + D.f[dirBNW ] = &DD[dirTSE *size_Mat]; + } + //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + real f_E_in, f_W_in, f_N_in, f_S_in, f_T_in, f_B_in, f_NE_in, f_SW_in, f_SE_in, f_NW_in, f_TE_in, f_BW_in, f_BE_in, + f_TW_in, f_TN_in, f_BS_in, f_BN_in, f_TS_in, f_TNE_in, f_TSW_in, f_TSE_in, f_TNW_in, f_BNE_in, f_BSW_in, f_BSE_in, f_BNW_in; + + // momentum exchanged with wall at rest + real wallMomentumX = 0.0, wallMomentumY = 0.0, wallMomentumZ = 0.0; + + real q; + q = q_dirE[k]; + if (q>=c0o1 && q<=c1o1) + { + f_W_in=f_E; + wallMomentumX += f_E+f_W_in; + } + + q = q_dirW[k]; + if (q>=c0o1 && q<=c1o1) + { + f_E_in=f_W; + wallMomentumX -= f_W+f_E_in; + } + + q = q_dirN[k]; + if (q>=c0o1 && q<=c1o1) + { + f_S_in=f_N; + wallMomentumY += f_N+f_S_in; + } + + q = q_dirS[k]; + if (q>=c0o1 && q<=c1o1) + { + f_N_in=f_S; + wallMomentumY -= f_S+f_N_in; + } + + q = q_dirT[k]; + if (q>=c0o1 && q<=c1o1) + { + f_B_in=f_T; + wallMomentumZ += f_T+f_B_in; + } + + q = q_dirB[k]; + if (q>=c0o1 && q<=c1o1) + { + f_T_in=f_B; + wallMomentumZ -= f_B+f_T_in; + } + + q = q_dirNE[k]; + if (q>=c0o1 && q<=c1o1) + { + f_SW_in=f_NE; + wallMomentumX += f_NE+f_SW_in; + wallMomentumY += f_NE+f_SW_in; + } + + q = q_dirSW[k]; + if (q>=c0o1 && q<=c1o1) + { + f_NE_in=f_SW; + wallMomentumX -= f_SW+f_NE_in; + wallMomentumY -= f_SW+f_NE_in; + } + + q = q_dirSE[k]; + if (q>=c0o1 && q<=c1o1) + { + f_NW_in=f_SE; + wallMomentumX += f_SE+f_NW_in; + wallMomentumY -= f_SE+f_NW_in; + } + + q = q_dirNW[k]; + if (q>=c0o1 && q<=c1o1) + { + f_SE_in=f_NW; + wallMomentumX -= f_NW+f_SE_in; + wallMomentumY += f_NW+f_SE_in; + } + + q = q_dirTE[k]; + if (q>=c0o1 && q<=c1o1) + { + f_BW_in=f_TE; + wallMomentumX += f_TE+f_BW_in; + wallMomentumZ += f_TE+f_BW_in; + } + + q = q_dirBW[k]; + if (q>=c0o1 && q<=c1o1) + { + f_TE_in=f_BW; + wallMomentumX -= f_BW+f_TE_in; + wallMomentumZ -= f_BW+f_TE_in; + } + + q = q_dirBE[k]; + if (q>=c0o1 && q<=c1o1) + { + f_TW_in=f_BE; + wallMomentumX += f_BE+f_TW_in; + wallMomentumZ -= f_BE+f_TW_in; + } + + q = q_dirTW[k]; + if (q>=c0o1 && q<=c1o1) + { + f_BE_in=f_TW; + wallMomentumX -= f_TW+f_BE_in; + wallMomentumZ += f_TW+f_BE_in; + } + + q = q_dirTN[k]; + if (q>=c0o1 && q<=c1o1) + { + f_BS_in=f_TN; + wallMomentumY += f_TN+f_BS_in; + wallMomentumZ += f_TN+f_BS_in; + } + + q = q_dirBS[k]; + if (q>=c0o1 && q<=c1o1) + { + f_TN_in=f_BS; + wallMomentumY -= f_BS+f_TN_in; + wallMomentumZ -= f_BS+f_TN_in; + } + + q = q_dirBN[k]; + if (q>=c0o1 && q<=c1o1) + { + f_TS_in=f_BN; + wallMomentumY += f_BN+f_TS_in; + wallMomentumZ -= f_BN+f_TS_in; + } + + q = q_dirTS[k]; + if (q>=c0o1 && q<=c1o1) + { + f_BN_in=f_TS; + wallMomentumY -= f_TS+f_BN_in; + wallMomentumZ += f_TS+f_BN_in; + } + + q = q_dirTNE[k]; + if (q>=c0o1 && q<=c1o1) + { + f_BSW_in=f_TNE; + wallMomentumX += f_TNE+f_BSW_in; + wallMomentumY += f_TNE+f_BSW_in; + wallMomentumZ += f_TNE+f_BSW_in; + } + + q = q_dirBSW[k]; + if (q>=c0o1 && q<=c1o1) + { + f_TNE_in=f_BSW; + wallMomentumX -= f_BSW+f_TNE_in; + wallMomentumY -= f_BSW+f_TNE_in; + wallMomentumZ -= f_BSW+f_TNE_in; + } + + q = q_dirBNE[k]; + if (q>=c0o1 && q<=c1o1) + { + f_TSW_in=f_BNE; + wallMomentumX += f_BNE+f_TSW_in; + wallMomentumY += f_BNE+f_TSW_in; + wallMomentumZ -= f_BNE+f_TSW_in; + } + + q = q_dirTSW[k]; + if (q>=c0o1 && q<=c1o1) + { + f_BNE_in=f_TSW; + wallMomentumX -= f_TSW+f_BNE_in; + wallMomentumY -= f_TSW+f_BNE_in; + wallMomentumZ += f_TSW+f_BNE_in; + } + + q = q_dirTSE[k]; + if (q>=c0o1 && q<=c1o1) + { + f_BNW_in=f_TSE; + wallMomentumX += f_TSE+f_BNW_in; + wallMomentumY -= f_TSE+f_BNW_in; + wallMomentumZ += f_TSE+f_BNW_in; + } + + q = q_dirBNW[k]; + if (q>=c0o1 && q<=c1o1) + { + f_TSE_in=f_BNW; + wallMomentumX -= f_BNW+f_TSE_in; + wallMomentumY += f_BNW+f_TSE_in; + wallMomentumZ -= f_BNW+f_TSE_in; + } + + q = q_dirBSE[k]; + if (q>=c0o1 && q<=c1o1) + { + f_TNW_in=f_BSE; + wallMomentumX += f_BSE+f_TNW_in; + wallMomentumY -= f_BSE+f_TNW_in; + wallMomentumZ -= f_BSE+f_TNW_in; + } + + q = q_dirTNW[k]; + if (q>=c0o1 && q<=c1o1) + { + f_BSE_in=f_TNW; + wallMomentumX -= f_TNW+f_BSE_in; + wallMomentumY += f_TNW+f_BSE_in; + wallMomentumZ += f_TNW+f_BSE_in; + } + + //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // //Compute wall velocity + // //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + real VeloX=0.0, VeloY=0.0, VeloZ=0.0; + + q = 0.5f; + real eps = 0.001f; + + iMEM( k, k_N[k], + normalX, normalY, normalZ, + vx, vy, vz, + vx_el, vy_el, vz_el, + vx_w_mean, vy_w_mean, vz_w_mean, + vx1, vx2, vx3, + c1o1+drho, + samplingOffset, + q, + 1.0, + eps, + z0, + hasWallModelMonitor, + u_star_monitor, + wallMomentumX, wallMomentumY, wallMomentumZ, + VeloX, VeloY, VeloZ); + + // //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // //Add wall velocity and write f's + // //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + q = q_dirE[k]; + if (q>=c0o1 && q<=c1o1) + { + (D.f[dirW])[kw] = f_W_in - (c6o1*c2o27*( VeloX )); + wallMomentumX += -(c6o1*c2o27*( VeloX )); + } + + q = q_dirW[k]; + if (q>=c0o1 && q<=c1o1) + { + (D.f[dirE])[ke] = f_E_in - (c6o1*c2o27*(-VeloX )); + wallMomentumX -= - (c6o1*c2o27*(-VeloX )); + } + + q = q_dirN[k]; + if (q>=c0o1 && q<=c1o1) + { + (D.f[dirS])[ks] = f_S_in - (c6o1*c2o27*( VeloY )); + wallMomentumY += - (c6o1*c2o27*( VeloY )); + } + + q = q_dirS[k]; + if (q>=c0o1 && q<=c1o1) + { + (D.f[dirN])[kn] = f_N_in - (c6o1*c2o27*(-VeloY )); + wallMomentumY -= -(c6o1*c2o27*(-VeloY )); + } + + q = q_dirT[k]; + if (q>=c0o1 && q<=c1o1) + { + (D.f[dirB])[kb] = f_B_in - (c6o1*c2o27*( VeloZ )); + wallMomentumZ += - (c6o1*c2o27*( VeloZ )); + } + + q = q_dirB[k]; + if (q>=c0o1 && q<=c1o1) + { + (D.f[dirT])[kt] = f_T_in - (c6o1*c2o27*(-VeloZ )); + wallMomentumZ -= -(c6o1*c2o27*(-VeloZ )); + } + + q = q_dirNE[k]; + if (q>=c0o1 && q<=c1o1) + { + (D.f[dirSW])[ksw] = f_SW_in - (c6o1*c1o54*(VeloX+VeloY)); + wallMomentumX += -(c6o1*c1o54*(VeloX+VeloY)); + wallMomentumY += -(c6o1*c1o54*(VeloX+VeloY)); + } + + q = q_dirSW[k]; + if (q>=c0o1 && q<=c1o1) + { + (D.f[dirNE])[kne] = f_NE_in - (c6o1*c1o54*(-VeloX-VeloY)); + wallMomentumX -= - (c6o1*c1o54*(-VeloX-VeloY)); + wallMomentumY -= - (c6o1*c1o54*(-VeloX-VeloY)); + } + + q = q_dirSE[k]; + if (q>=c0o1 && q<=c1o1) + { + (D.f[dirNW])[knw] = f_NW_in - (c6o1*c1o54*( VeloX-VeloY)); + wallMomentumX += -(c6o1*c1o54*( VeloX-VeloY)); + wallMomentumY -= -(c6o1*c1o54*( VeloX-VeloY)); + } + + q = q_dirNW[k]; + if (q>=c0o1 && q<=c1o1) + { + (D.f[dirSE])[kse] = f_SE_in - (c6o1*c1o54*(-VeloX+VeloY)); + wallMomentumX -= - (c6o1*c1o54*(-VeloX+VeloY)); + wallMomentumY += - (c6o1*c1o54*(-VeloX+VeloY)); + } + + q = q_dirTE[k]; + if (q>=c0o1 && q<=c1o1) + { + (D.f[dirBW])[kbw] = f_BW_in - (c6o1*c1o54*( VeloX+VeloZ)); + wallMomentumX += - (c6o1*c1o54*( VeloX+VeloZ)); + wallMomentumZ += - (c6o1*c1o54*( VeloX+VeloZ)); + } + + q = q_dirBW[k]; + if (q>=c0o1 && q<=c1o1) + { + (D.f[dirTE])[kte] = f_TE_in - (c6o1*c1o54*(-VeloX-VeloZ)); + wallMomentumX -= - (c6o1*c1o54*(-VeloX-VeloZ)); + wallMomentumZ -= - (c6o1*c1o54*(-VeloX-VeloZ)); + } + + q = q_dirBE[k]; + if (q>=c0o1 && q<=c1o1) + { + (D.f[dirTW])[ktw] = f_TW_in - (c6o1*c1o54*( VeloX-VeloZ)); + wallMomentumX += - (c6o1*c1o54*( VeloX-VeloZ)); + wallMomentumZ -= - (c6o1*c1o54*( VeloX-VeloZ)); + } + + q = q_dirTW[k]; + if (q>=c0o1 && q<=c1o1) + { + (D.f[dirBE])[kbe] = f_BE_in - (c6o1*c1o54*(-VeloX+VeloZ)); + wallMomentumX -= - (c6o1*c1o54*(-VeloX+VeloZ)); + wallMomentumZ += - (c6o1*c1o54*(-VeloX+VeloZ)); + } + + q = q_dirTN[k]; + if (q>=c0o1 && q<=c1o1) + { + (D.f[dirBS])[kbs] = f_BS_in - (c6o1*c1o54*( VeloY+VeloZ)); + wallMomentumY += - (c6o1*c1o54*( VeloY+VeloZ)); + wallMomentumZ += - (c6o1*c1o54*( VeloY+VeloZ)); + } + + q = q_dirBS[k]; + if (q>=c0o1 && q<=c1o1) + { + (D.f[dirTN])[ktn] = f_TN_in - (c6o1*c1o54*( -VeloY-VeloZ)); + wallMomentumY -= - (c6o1*c1o54*( -VeloY-VeloZ)); + wallMomentumZ -= - (c6o1*c1o54*( -VeloY-VeloZ)); + } + + q = q_dirBN[k]; + if (q>=c0o1 && q<=c1o1) + { + (D.f[dirTS])[kts] = f_TS_in - (c6o1*c1o54*( VeloY-VeloZ)); + wallMomentumY += - (c6o1*c1o54*( VeloY-VeloZ)); + wallMomentumZ -= - (c6o1*c1o54*( VeloY-VeloZ)); + } + + q = q_dirTS[k]; + if (q>=c0o1 && q<=c1o1) + { + (D.f[dirBN])[kbn] = f_BN_in - (c6o1*c1o54*( -VeloY+VeloZ)); + wallMomentumY -= - (c6o1*c1o54*( -VeloY+VeloZ)); + wallMomentumZ += - (c6o1*c1o54*( -VeloY+VeloZ)); + } + + q = q_dirTNE[k]; + if (q>=c0o1 && q<=c1o1) + { + (D.f[dirBSW])[kbsw] = f_BSW_in - (c6o1*c1o216*( VeloX+VeloY+VeloZ)); + wallMomentumX += - (c6o1*c1o216*( VeloX+VeloY+VeloZ)); + wallMomentumY += - (c6o1*c1o216*( VeloX+VeloY+VeloZ)); + wallMomentumZ += - (c6o1*c1o216*( VeloX+VeloY+VeloZ)); + } + + q = q_dirBSW[k]; + if (q>=c0o1 && q<=c1o1) + { + (D.f[dirTNE])[ktne] = f_TNE_in - (c6o1*c1o216*(-VeloX-VeloY-VeloZ)); + wallMomentumX -= - (c6o1*c1o216*(-VeloX-VeloY-VeloZ)); + wallMomentumY -= - (c6o1*c1o216*(-VeloX-VeloY-VeloZ)); + wallMomentumZ -= - (c6o1*c1o216*(-VeloX-VeloY-VeloZ)); + } + + q = q_dirBNE[k]; + if (q>=c0o1 && q<=c1o1) + { + (D.f[dirTSW])[ktsw] = f_TSW_in - (c6o1*c1o216*( VeloX+VeloY-VeloZ)); + wallMomentumX += - (c6o1*c1o216*( VeloX+VeloY-VeloZ)); + wallMomentumY += - (c6o1*c1o216*( VeloX+VeloY-VeloZ)); + wallMomentumZ -= - (c6o1*c1o216*( VeloX+VeloY-VeloZ)); + } + + q = q_dirTSW[k]; + if (q>=c0o1 && q<=c1o1) + { + (D.f[dirBNE])[kbne] = f_BNE_in - (c6o1*c1o216*(-VeloX-VeloY+VeloZ)); + wallMomentumX -= - (c6o1*c1o216*(-VeloX-VeloY+VeloZ)); + wallMomentumY -= - (c6o1*c1o216*(-VeloX-VeloY+VeloZ)); + wallMomentumZ += - (c6o1*c1o216*(-VeloX-VeloY+VeloZ)); + } + + q = q_dirTSE[k]; + if (q>=c0o1 && q<=c1o1) + { + (D.f[dirBNW])[kbnw] = f_BNW_in - (c6o1*c1o216*( VeloX-VeloY+VeloZ)); + wallMomentumX += - (c6o1*c1o216*( VeloX-VeloY+VeloZ)); + wallMomentumY -= - (c6o1*c1o216*( VeloX-VeloY+VeloZ)); + wallMomentumZ += - (c6o1*c1o216*( VeloX-VeloY+VeloZ)); + } + + q = q_dirBNW[k]; + if (q>=c0o1 && q<=c1o1) + { + (D.f[dirTSE])[ktse] = f_TSE_in - (c6o1*c1o216*(-VeloX+VeloY-VeloZ)); + wallMomentumX -= - (c6o1*c1o216*(-VeloX+VeloY-VeloZ)); + wallMomentumY += - (c6o1*c1o216*(-VeloX+VeloY-VeloZ)); + wallMomentumZ -= - (c6o1*c1o216*(-VeloX+VeloY-VeloZ)); + } + + q = q_dirBSE[k]; + if (q>=c0o1 && q<=c1o1) + { + (D.f[dirTNW])[ktnw] = f_TNW_in - (c6o1*c1o216*( VeloX-VeloY-VeloZ)); + wallMomentumX += - (c6o1*c1o216*( VeloX-VeloY-VeloZ)); + wallMomentumY -= - (c6o1*c1o216*( VeloX-VeloY-VeloZ)); + wallMomentumZ -= - (c6o1*c1o216*( VeloX-VeloY-VeloZ)); + } + + q = q_dirTNW[k]; + if (q>=c0o1 && q<=c1o1) + { + (D.f[dirBSE])[kbse] = f_BSE_in - (c6o1*c1o216*(-VeloX+VeloY+VeloZ)); + wallMomentumX -= - (c6o1*c1o216*(-VeloX+VeloY+VeloZ)); + wallMomentumY += - (c6o1*c1o216*(-VeloX+VeloY+VeloZ)); + wallMomentumZ += - (c6o1*c1o216*(-VeloX+VeloY+VeloZ)); + } + + if(hasWallModelMonitor) + { + Fx_monitor[k] = wallMomentumX; + Fy_monitor[k] = wallMomentumY; + Fz_monitor[k] = wallMomentumZ; + } + + } +} +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// \ No newline at end of file diff --git a/src/gpu/VirtualFluids_GPU/GPU/TurbulentViscosity.cu b/src/gpu/VirtualFluids_GPU/GPU/TurbulentViscosity.cu new file mode 100644 index 0000000000000000000000000000000000000000..d510a4fe6f0f842d7882bef2eb4804461e986026 --- /dev/null +++ b/src/gpu/VirtualFluids_GPU/GPU/TurbulentViscosity.cu @@ -0,0 +1,93 @@ +#include "TurbulentViscosity.h" +#include "lbm/constants/NumericConstants.h" +#include "Parameter/Parameter.h" +#include "cuda/CudaGrid.h" +#include <cuda_runtime.h> +#include <helper_cuda.h> +#include "LBM/LB.h" + +using namespace vf::lbm::constant; + +extern "C" __host__ __device__ __forceinline__ void calcDerivatives(const uint& k, uint& kM, uint& kP, uint* typeOfGridNode, real* vx, real* vy, real* vz, real& dvx, real& dvy, real& dvz) +{ + bool fluidP = (typeOfGridNode[kP] == GEO_FLUID); + bool fluidM = (typeOfGridNode[kM] == GEO_FLUID); + real div = (fluidM & fluidP) ? c1o2 : c1o1; + + dvx = ((fluidP ? vx[kP] : vx[k])-(fluidM ? vx[kM] : vx[k]))*div; + dvy = ((fluidP ? vy[kP] : vy[k])-(fluidM ? vy[kM] : vy[k]))*div; + dvz = ((fluidP ? vz[kP] : vz[k])-(fluidM ? vz[kM] : vz[k]))*div; +} + +extern "C" __global__ void calcAMD(real* vx, + real* vy, + real* vz, + real* turbulentViscosity, + uint* neighborX, + uint* neighborY, + uint* neighborZ, + uint* neighborWSB, + uint* typeOfGridNode, + uint size_Mat, + real SGSConstant) +{ + + const uint x = threadIdx.x; + const uint y = blockIdx.x; + const uint z = blockIdx.y; + + const uint nx = blockDim.x; + const uint ny = gridDim.x; + + const uint k = nx*(ny*z + y) + x; + if(k >= size_Mat) return; + if(typeOfGridNode[k] != GEO_FLUID) return; + + uint kPx = neighborX[k]; + uint kPy = neighborY[k]; + uint kPz = neighborZ[k]; + uint kMxyz = neighborWSB[k]; + uint kMx = neighborZ[neighborY[kMxyz]]; + uint kMy = neighborZ[neighborX[kMxyz]]; + uint kMz = neighborY[neighborX[kMxyz]]; + + real dvxdx, dvxdy, dvxdz, + dvydx, dvydy, dvydz, + dvzdx, dvzdy, dvzdz; + + calcDerivatives(k, kMx, kPx, typeOfGridNode, vx, vy, vz, dvxdx, dvydx, dvzdx); + calcDerivatives(k, kMy, kPy, typeOfGridNode, vx, vy, vz, dvxdy, dvydy, dvzdy); + calcDerivatives(k, kMz, kPz, typeOfGridNode, vx, vy, vz, dvxdz, dvydz, dvzdz); + + real denominator = dvxdx*dvxdx + dvydx*dvydx + dvzdx*dvzdx + + dvxdy*dvxdy + dvydy*dvydy + dvzdy*dvzdy + + dvxdz*dvxdz + dvydz*dvydz + dvzdz*dvzdz; + real enumerator = (dvxdx*dvxdx + dvxdy*dvxdy + dvxdz*dvxdz) * dvxdx + + (dvydx*dvydx + dvydy*dvydy + dvydz*dvydz) * dvydy + + (dvzdx*dvzdx + dvzdy*dvzdy + dvzdz*dvzdz) * dvzdz + + (dvxdx*dvydx + dvxdy*dvydy + dvxdz*dvydz) * (dvxdy+dvydx) + + (dvxdx*dvzdx + dvxdy*dvzdy + dvxdz*dvzdz) * (dvxdz+dvzdx) + + (dvydx*dvzdx + dvydy*dvzdy + dvydz*dvzdz) * (dvydz+dvzdy); + + turbulentViscosity[k] = max(c0o1,-SGSConstant*enumerator)/denominator; +} + +extern "C" void calcTurbulentViscosityAMD(Parameter* para, int level) +{ + vf::cuda::CudaGrid grid = vf::cuda::CudaGrid(para->getParH(level)->numberofthreads, para->getParH(level)->size_Mat_SP); + calcAMD<<<grid.grid, grid.threads>>>( + para->getParD(level)->vx_SP, + para->getParD(level)->vy_SP, + para->getParD(level)->vz_SP, + para->getParD(level)->turbViscosity, + para->getParD(level)->neighborX_SP, + para->getParD(level)->neighborY_SP, + para->getParD(level)->neighborZ_SP, + para->getParD(level)->neighborWSB_SP, + para->getParD(level)->geoSP, + para->getParD(level)->size_Mat_SP, + para->getSGSConstant() + ); + getLastCudaError("calcAMD execution failed"); +} + \ No newline at end of file diff --git a/src/gpu/VirtualFluids_GPU/GPU/TurbulentViscosity.h b/src/gpu/VirtualFluids_GPU/GPU/TurbulentViscosity.h new file mode 100644 index 0000000000000000000000000000000000000000..293e61bcb39a1525b8fd19970aa9a1a2beea13f3 --- /dev/null +++ b/src/gpu/VirtualFluids_GPU/GPU/TurbulentViscosity.h @@ -0,0 +1,10 @@ +#ifndef TURBULENT_VISCOSITY_H_ +#define TURBULENT_VISCOSITY_H_ + +#include "Core/DataTypes.h" + +class Parameter; + +extern "C" void calcTurbulentViscosityAMD(Parameter* para, int level); + +#endif //TURBULENT_VISCOSITY_H_ \ No newline at end of file diff --git a/src/gpu/VirtualFluids_GPU/GPU/devCheck.cpp b/src/gpu/VirtualFluids_GPU/GPU/devCheck.cpp deleted file mode 100644 index dfe57620a06ff116bbd5a0d98828637057e5bc69..0000000000000000000000000000000000000000 --- a/src/gpu/VirtualFluids_GPU/GPU/devCheck.cpp +++ /dev/null @@ -1,57 +0,0 @@ -// _ ___ __ __________ _ __ ______________ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ / ___/ __ / / / / -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ / /___/ /_/ / / / / -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) / /_) / ____/ /__/ / -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ \____/_/ \_____/ -// -////////////////////////////////////////////////////////////////////////// -#include "devCheck.h" - -#include <stdio.h> -#include <stdlib.h> - -#include <cuda_runtime.h> - - -int devCheck(int gpudevice) -{ - int device_count = 0; - int device; // used with cudaGetDevice() to verify cudaSetDevice() - - // get the number of non-emulation devices detected - cudaGetDeviceCount(&device_count); - if (gpudevice > device_count) - { - printf("gpudevice >= device_count ... exiting\n"); - exit(1); - } - cudaError_t cudareturn; - cudaDeviceProp deviceProp; - - // cudaGetDeviceProperties() is also demonstrated in the deviceQuery/ example - // of the sdk projects directory - cudaGetDeviceProperties(&deviceProp, gpudevice); - printf("[compute capability] = [%d.%d]\n", - deviceProp.major, deviceProp.minor); - - if (deviceProp.major > 999) - { - printf("warning, CUDA Device Emulation (CPU) detected, exiting\n"); - exit(1); - } - - // choose a cuda device for kernel execution - cudareturn = cudaSetDevice(gpudevice); - if (cudareturn == cudaErrorInvalidDevice) - { - perror("cudaSetDevice returned cudaErrorInvalidDevice"); - } - else - { - // double check that device was properly selected - cudaGetDevice(&device); - //printf("cudaGetDevice()=%d\n",device); - return device; - } - return -1; -} diff --git a/src/gpu/VirtualFluids_GPU/GPU/devCheck.h b/src/gpu/VirtualFluids_GPU/GPU/devCheck.h deleted file mode 100644 index 6357e4ac51f35b71fe463646e8ca51f5b231ed9c..0000000000000000000000000000000000000000 --- a/src/gpu/VirtualFluids_GPU/GPU/devCheck.h +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef DEVCHECK_H -#define DEVCHECK_H - -int devCheck(int gpudevice); - -#endif \ No newline at end of file diff --git a/src/gpu/VirtualFluids_GPU/Kernel/KernelImp.h b/src/gpu/VirtualFluids_GPU/Kernel/KernelImp.h index ca41116e40608e970b771e583858ec0631651b1c..1fb3d51a293b98af5f6f7880b46195c060f1fc7e 100644 --- a/src/gpu/VirtualFluids_GPU/Kernel/KernelImp.h +++ b/src/gpu/VirtualFluids_GPU/Kernel/KernelImp.h @@ -5,7 +5,7 @@ #include <memory> -#include "Utilities/CudaGrid.h" +#include <cuda/CudaGrid.h> class CheckParameterStrategy; class Parameter; @@ -32,7 +32,7 @@ protected: std::vector<PreProcessorType> myPreProcessorTypes; KernelGroup myKernelGroup; - vf::gpu::CudaGrid cudaGrid; + vf::cuda::CudaGrid cudaGrid; std::unique_ptr<std::pair<dim3, dim3>> calcGridDimensions(unsigned int size_Mat, int numberOfThreads); }; diff --git a/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Compressible/BGKUnified/BGKUnified.cu b/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Compressible/BGKUnified/BGKUnified.cu index 4c82851996646590d8c246df5f940b58a308d52c..b86af5f876286599146190a1244a5bf21e2948fd 100644 --- a/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Compressible/BGKUnified/BGKUnified.cu +++ b/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Compressible/BGKUnified/BGKUnified.cu @@ -4,7 +4,6 @@ #include "Parameter/Parameter.h" #include "../RunLBMKernel.cuh" -#include "Kernel/Utilities/CudaGrid.h" #include <lbm/BGK.h> @@ -26,7 +25,7 @@ BGKUnified::BGKUnified(std::shared_ptr<Parameter> para, int level) myKernelGroup = BasicKernel; - this->cudaGrid = CudaGrid(para->getParD(level)->numberofthreads, para->getParD(level)->size_Mat_SP); + this->cudaGrid = cuda::CudaGrid(para->getParD(level)->numberofthreads, para->getParD(level)->size_Mat_SP); } diff --git a/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Compressible/CumulantK15Unified/CumulantK15Unified.cu b/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Compressible/CumulantK15Unified/CumulantK15Unified.cu index b6f5d21ccf909f1ce3bcf11a4558f4771d87d021..50f8d32f06ad25a4ab9d6f43ce5d908570d9b332 100644 --- a/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Compressible/CumulantK15Unified/CumulantK15Unified.cu +++ b/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Compressible/CumulantK15Unified/CumulantK15Unified.cu @@ -25,7 +25,7 @@ CumulantK15Unified::CumulantK15Unified(std::shared_ptr<Parameter> para, int leve myKernelGroup = BasicKernel; - this->cudaGrid = CudaGrid(para->getParD(level)->numberofthreads, para->getParD(level)->size_Mat_SP); + this->cudaGrid = cuda::CudaGrid(para->getParD(level)->numberofthreads, para->getParD(level)->size_Mat_SP); } void CumulantK15Unified::run() diff --git a/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Compressible/CumulantK17Unified/CumulantK17Unified.cu b/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Compressible/CumulantK17Unified/CumulantK17Unified.cu index 989fce0c5e797ef90d644845f6c502bee700f6e1..e6ab61260b2c20ea5aec868ed70d714a066f2539 100644 --- a/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Compressible/CumulantK17Unified/CumulantK17Unified.cu +++ b/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Compressible/CumulantK17Unified/CumulantK17Unified.cu @@ -4,7 +4,6 @@ #include "Parameter/Parameter.h" #include "../RunLBMKernel.cuh" -#include "Kernel/Utilities/CudaGrid.h" #include <lbm/CumulantChimera.h> @@ -25,7 +24,7 @@ CumulantK17Unified::CumulantK17Unified(std::shared_ptr<Parameter> para, int leve myKernelGroup = BasicKernel; - this->cudaGrid = CudaGrid(para->getParD(level)->numberofthreads, para->getParD(level)->size_Mat_SP); + this->cudaGrid = cuda::CudaGrid(para->getParD(level)->numberofthreads, para->getParD(level)->size_Mat_SP); } diff --git a/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Compressible/CumulantK17chim/CumulantK17CompChim.cu b/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Compressible/CumulantK17chim/CumulantK17CompChim.cu index a31505f33bcf8d1fda5f4feb28af5262baf1c4ac..a91008421d37643869dde3c7b398e12fd8778b63 100644 --- a/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Compressible/CumulantK17chim/CumulantK17CompChim.cu +++ b/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Compressible/CumulantK17chim/CumulantK17CompChim.cu @@ -23,7 +23,11 @@ void CumulantK17CompChim::run() para->getParD(level)->d0SP.f[0], para->getParD(level)->size_Mat_SP, level, + para->getIsBodyForce(), para->getForcesDev(), + para->getParD(level)->forceX_SP, + para->getParD(level)->forceY_SP, + para->getParD(level)->forceZ_SP, para->getQuadricLimitersDev(), para->getParD(level)->evenOrOdd); getLastCudaError("LB_Kernel_CumulantK17CompChim execution failed"); diff --git a/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Compressible/CumulantK17chim/CumulantK17CompChim_Device.cu b/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Compressible/CumulantK17chim/CumulantK17CompChim_Device.cu index 8c95f96730293446d0f066661e706270171270a8..2b26cd2b608fb2237002d9471f518a89d78ca32b 100644 --- a/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Compressible/CumulantK17chim/CumulantK17CompChim_Device.cu +++ b/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Compressible/CumulantK17chim/CumulantK17CompChim_Device.cu @@ -48,7 +48,11 @@ extern "C" __global__ void LB_Kernel_CumulantK17CompChim( real* distributions, int size_Mat, int level, + bool bodyForce, real* forces, + real* bodyForceX, + real* bodyForceY, + real* bodyForceZ, real* quadricLimiters, bool isEvenTimestep) { @@ -210,12 +214,25 @@ extern "C" __global__ void LB_Kernel_CumulantK17CompChim( for (size_t i = 1; i <= level; i++) { factor *= c2o1; } - real fx = forces[0] / factor; - real fy = forces[1] / factor; - real fz = forces[2] / factor; - vvx += fx * c1o2; - vvy += fy * c1o2; - vvz += fz * c1o2; + + real fx = forces[0]; + real fy = forces[1]; + real fz = forces[2]; + + if( bodyForce ){ + fx += bodyForceX[k]; + fy += bodyForceY[k]; + fz += bodyForceZ[k]; + + //Reset body force + bodyForceX[k] = 0.0f; + bodyForceY[k] = 0.0f; + bodyForceZ[k] = 0.0f; + } + + vvx += fx * c1o2 / factor; + vvy += fy * c1o2 / factor; + vvz += fz * c1o2 / factor; //////////////////////////////////////////////////////////////////////////////////// // calculate the square of velocities for this lattice node real vx2 = vvx * vvx; diff --git a/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Compressible/CumulantK17chim/CumulantK17CompChim_Device.cuh b/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Compressible/CumulantK17chim/CumulantK17CompChim_Device.cuh index 557bc08b17d36763fdb5f94980dd0e918fa29ac1..1d42d65f020dd7393321498666a298630883f6ad 100644 --- a/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Compressible/CumulantK17chim/CumulantK17CompChim_Device.cuh +++ b/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Compressible/CumulantK17chim/CumulantK17CompChim_Device.cuh @@ -13,7 +13,11 @@ extern "C" __global__ void LB_Kernel_CumulantK17CompChim( real* distributions, int size_Mat, int level, + bool bodyForce, real* forces, + real* bodyForceX, + real* bodyForceY, + real* bodyForceZ, real* quadricLimiters, bool isEvenTimestep); #endif diff --git a/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Compressible/RunLBMKernel.cuh b/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Compressible/RunLBMKernel.cuh index ecfdb8e38bc5da02a473b6f2e67340963ed8b38a..558b4f333e7c92b372a5097aa4917dd6d1230a34 100644 --- a/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Compressible/RunLBMKernel.cuh +++ b/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Compressible/RunLBMKernel.cuh @@ -41,7 +41,7 @@ __global__ void runKernel(KernelFunctor kernel, GPUKernelParameter kernelParamet DistributionWrapper distributionWrapper { kernelParameter.distributions, - kernelParameter.size_Mat, + (unsigned int)kernelParameter.size_Mat, kernelParameter.isEvenTimestep, k, kernelParameter.neighborX, diff --git a/src/gpu/VirtualFluids_GPU/Kernel/Kernels/TurbulentViscosityKernels/FluidFlow/Compressible/CumulantK17chim/TurbulentViscosityCumulantK17CompChim.cu b/src/gpu/VirtualFluids_GPU/Kernel/Kernels/TurbulentViscosityKernels/FluidFlow/Compressible/CumulantK17chim/TurbulentViscosityCumulantK17CompChim.cu new file mode 100644 index 0000000000000000000000000000000000000000..69b493af7739e0eb614c06938209b01dd561e819 --- /dev/null +++ b/src/gpu/VirtualFluids_GPU/Kernel/Kernels/TurbulentViscosityKernels/FluidFlow/Compressible/CumulantK17chim/TurbulentViscosityCumulantK17CompChim.cu @@ -0,0 +1,47 @@ +#include "TurbulentViscosityCumulantK17CompChim.h" +#include "cuda/CudaGrid.h" +#include "Parameter/Parameter.h" +#include "TurbulentViscosityCumulantK17CompChim_Device.cuh" + +std::shared_ptr<TurbulentViscosityCumulantK17CompChim> TurbulentViscosityCumulantK17CompChim::getNewInstance(std::shared_ptr<Parameter> para, int level) +{ + return std::shared_ptr<TurbulentViscosityCumulantK17CompChim>(new TurbulentViscosityCumulantK17CompChim(para,level)); +} + +void TurbulentViscosityCumulantK17CompChim::run() +{ + vf::cuda::CudaGrid grid = vf::cuda::CudaGrid(para->getParH(level)->numberofthreads, para->getParH(level)->size_Mat_SP); + + LB_Kernel_TurbulentViscosityCumulantK17CompChim <<< grid.grid, grid.threads >>>( + para->getParD(level)->omega, + para->getParD(level)->geoSP, + para->getParD(level)->neighborX_SP, + para->getParD(level)->neighborY_SP, + para->getParD(level)->neighborZ_SP, + para->getParD(level)->d0SP.f[0], + para->getParD(level)->rho_SP, + para->getParD(level)->vx_SP, + para->getParD(level)->vy_SP, + para->getParD(level)->vz_SP, + para->getParD(level)->turbViscosity, + (unsigned long)para->getParD(level)->size_Mat_SP, + level, + para->getIsBodyForce(), + para->getForcesDev(), + para->getParD(level)->forceX_SP, + para->getParD(level)->forceY_SP, + para->getParD(level)->forceZ_SP, + para->getQuadricLimitersDev(), + para->getParD(level)->evenOrOdd); + getLastCudaError("LB_Kernel_TurbulentViscosityCumulantK17CompChim execution failed"); +} + +TurbulentViscosityCumulantK17CompChim::TurbulentViscosityCumulantK17CompChim(std::shared_ptr<Parameter> para, int level) +{ + this->para = para; + this->level = level; + + myPreProcessorTypes.push_back(InitCompSP27); + + myKernelGroup = BasicKernel; +} \ No newline at end of file diff --git a/src/gpu/VirtualFluids_GPU/Kernel/Kernels/TurbulentViscosityKernels/FluidFlow/Compressible/CumulantK17chim/TurbulentViscosityCumulantK17CompChim.h b/src/gpu/VirtualFluids_GPU/Kernel/Kernels/TurbulentViscosityKernels/FluidFlow/Compressible/CumulantK17chim/TurbulentViscosityCumulantK17CompChim.h new file mode 100644 index 0000000000000000000000000000000000000000..d107700e59d657dc6da656037638a407ed0499a3 --- /dev/null +++ b/src/gpu/VirtualFluids_GPU/Kernel/Kernels/TurbulentViscosityKernels/FluidFlow/Compressible/CumulantK17chim/TurbulentViscosityCumulantK17CompChim.h @@ -0,0 +1,17 @@ +#ifndef TurbulentViscosityCUMULANT_K17_COMP_CHIM_H +#define TurbulentViscosityCUMULANT_K17_COMP_CHIM_H + +#include "Kernel/KernelImp.h" + +class TurbulentViscosityCumulantK17CompChim : public KernelImp +{ +public: + static std::shared_ptr<TurbulentViscosityCumulantK17CompChim> getNewInstance(std::shared_ptr< Parameter> para, int level); + void run(); + +private: + TurbulentViscosityCumulantK17CompChim(); + TurbulentViscosityCumulantK17CompChim(std::shared_ptr<Parameter> para, int level); +}; + +#endif diff --git a/src/gpu/VirtualFluids_GPU/Kernel/Kernels/TurbulentViscosityKernels/FluidFlow/Compressible/CumulantK17chim/TurbulentViscosityCumulantK17CompChim_Device.cu b/src/gpu/VirtualFluids_GPU/Kernel/Kernels/TurbulentViscosityKernels/FluidFlow/Compressible/CumulantK17chim/TurbulentViscosityCumulantK17CompChim_Device.cu new file mode 100644 index 0000000000000000000000000000000000000000..f2f02c6df050166259dc23f816b0c2829f85dc0c --- /dev/null +++ b/src/gpu/VirtualFluids_GPU/Kernel/Kernels/TurbulentViscosityKernels/FluidFlow/Compressible/CumulantK17chim/TurbulentViscosityCumulantK17CompChim_Device.cu @@ -0,0 +1,1597 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids 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. +// +// VirtualFluids 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 VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file TurbulentViscosityCumulantK17CompChim_Device.cu +//! \author Henry Korb, Henrik Asmuth +//! \date 16/05/2022 +//! \brief CumulantK17CompChim kernel by Martin Schönherr that inlcudes turbulent viscosity and other small mods. +//! +//! Additions to CumulantK17CompChim: +//! - can incorporate local body force +//! - when applying a local body force, the total round of error of forcing+bodyforce is saved and added in next time step +//! - uses turbulent viscosity that is computed in separate kernel (as of now AMD) +//! - saves macroscopic values (needed for instance for probes, AMD, and actuator models) +//! +//======================================================================================= +/* Device code */ +#include "LBM/LB.h" +#include "LBM/D3Q27.h" +#include <lbm/constants/NumericConstants.h> + +using namespace vf::lbm::constant; +#include "Kernel/ChimeraTransformation.h" + + +//////////////////////////////////////////////////////////////////////////////// +extern "C" __global__ void LB_Kernel_TurbulentViscosityCumulantK17CompChim( + real omega_in, + uint* typeOfGridNode, + uint* neighborX, + uint* neighborY, + uint* neighborZ, + real* distributions, + real* rho, + real* vx, + real* vy, + real* vz, + real* turbulentViscosity, + unsigned long size_Mat, + int level, + bool bodyForce, + real* forces, + real* bodyForceX, + real* bodyForceY, + real* bodyForceZ, + real* quadricLimiters, + bool isEvenTimestep) +{ + ////////////////////////////////////////////////////////////////////////// + //! Cumulant K17 Kernel is based on \ref + //! <a href="https://doi.org/10.1016/j.jcp.2017.05.040"><b>[ M. Geier et al. (2017), DOI:10.1016/j.jcp.2017.05.040 + //! ]</b></a> and \ref <a href="https://doi.org/10.1016/j.jcp.2017.07.004"><b>[ M. Geier et al. (2017), + //! DOI:10.1016/j.jcp.2017.07.004 ]</b></a> + //! + //! The cumulant kernel is executed in the following steps + //! + //////////////////////////////////////////////////////////////////////////////// + //! - Get node index coordinates from threadIdx, blockIdx, blockDim and gridDim. + //! + const unsigned x = threadIdx.x; + const unsigned y = blockIdx.x; + const unsigned z = blockIdx.y; + + const unsigned nx = blockDim.x; + const unsigned ny = gridDim.x; + + const unsigned k = nx * (ny * z + y) + x; + + ////////////////////////////////////////////////////////////////////////// + // run for all indices in size_Mat and fluid nodes + if ((k < size_Mat) && (typeOfGridNode[k] == GEO_FLUID)) { + ////////////////////////////////////////////////////////////////////////// + //! - Read distributions: style of reading and writing the distributions from/to stored arrays dependent on + //! timestep is based on the esoteric twist algorithm \ref <a + //! href="https://doi.org/10.3390/computation5020019"><b>[ M. Geier et al. (2017), + //! DOI:10.3390/computation5020019 ]</b></a> + //! + Distributions27 dist; + if (isEvenTimestep) { + dist.f[dirE] = &distributions[dirE * size_Mat]; + dist.f[dirW] = &distributions[dirW * size_Mat]; + dist.f[dirN] = &distributions[dirN * size_Mat]; + dist.f[dirS] = &distributions[dirS * size_Mat]; + dist.f[dirT] = &distributions[dirT * size_Mat]; + dist.f[dirB] = &distributions[dirB * size_Mat]; + dist.f[dirNE] = &distributions[dirNE * size_Mat]; + dist.f[dirSW] = &distributions[dirSW * size_Mat]; + dist.f[dirSE] = &distributions[dirSE * size_Mat]; + dist.f[dirNW] = &distributions[dirNW * size_Mat]; + dist.f[dirTE] = &distributions[dirTE * size_Mat]; + dist.f[dirBW] = &distributions[dirBW * size_Mat]; + dist.f[dirBE] = &distributions[dirBE * size_Mat]; + dist.f[dirTW] = &distributions[dirTW * size_Mat]; + dist.f[dirTN] = &distributions[dirTN * size_Mat]; + dist.f[dirBS] = &distributions[dirBS * size_Mat]; + dist.f[dirBN] = &distributions[dirBN * size_Mat]; + dist.f[dirTS] = &distributions[dirTS * size_Mat]; + dist.f[dirZERO] = &distributions[dirZERO * size_Mat]; + dist.f[dirTNE] = &distributions[dirTNE * size_Mat]; + dist.f[dirTSW] = &distributions[dirTSW * size_Mat]; + dist.f[dirTSE] = &distributions[dirTSE * size_Mat]; + dist.f[dirTNW] = &distributions[dirTNW * size_Mat]; + dist.f[dirBNE] = &distributions[dirBNE * size_Mat]; + dist.f[dirBSW] = &distributions[dirBSW * size_Mat]; + dist.f[dirBSE] = &distributions[dirBSE * size_Mat]; + dist.f[dirBNW] = &distributions[dirBNW * size_Mat]; + } else { + dist.f[dirW] = &distributions[dirE * size_Mat]; + dist.f[dirE] = &distributions[dirW * size_Mat]; + dist.f[dirS] = &distributions[dirN * size_Mat]; + dist.f[dirN] = &distributions[dirS * size_Mat]; + dist.f[dirB] = &distributions[dirT * size_Mat]; + dist.f[dirT] = &distributions[dirB * size_Mat]; + dist.f[dirSW] = &distributions[dirNE * size_Mat]; + dist.f[dirNE] = &distributions[dirSW * size_Mat]; + dist.f[dirNW] = &distributions[dirSE * size_Mat]; + dist.f[dirSE] = &distributions[dirNW * size_Mat]; + dist.f[dirBW] = &distributions[dirTE * size_Mat]; + dist.f[dirTE] = &distributions[dirBW * size_Mat]; + dist.f[dirTW] = &distributions[dirBE * size_Mat]; + dist.f[dirBE] = &distributions[dirTW * size_Mat]; + dist.f[dirBS] = &distributions[dirTN * size_Mat]; + dist.f[dirTN] = &distributions[dirBS * size_Mat]; + dist.f[dirTS] = &distributions[dirBN * size_Mat]; + dist.f[dirBN] = &distributions[dirTS * size_Mat]; + dist.f[dirZERO] = &distributions[dirZERO * size_Mat]; + dist.f[dirBSW] = &distributions[dirTNE * size_Mat]; + dist.f[dirBNE] = &distributions[dirTSW * size_Mat]; + dist.f[dirBNW] = &distributions[dirTSE * size_Mat]; + dist.f[dirBSE] = &distributions[dirTNW * size_Mat]; + dist.f[dirTSW] = &distributions[dirBNE * size_Mat]; + dist.f[dirTNE] = &distributions[dirBSW * size_Mat]; + dist.f[dirTNW] = &distributions[dirBSE * size_Mat]; + dist.f[dirTSE] = &distributions[dirBNW * size_Mat]; + } + //////////////////////////////////////////////////////////////////////////////// + //! - Set neighbor indices (necessary for indirect addressing) + uint kw = neighborX[k]; + uint ks = neighborY[k]; + uint kb = neighborZ[k]; + uint ksw = neighborY[kw]; + uint kbw = neighborZ[kw]; + uint kbs = neighborZ[ks]; + uint kbsw = neighborZ[ksw]; + //////////////////////////////////////////////////////////////////////////////////// + //! - Set local distributions + //! + real mfcbb = (dist.f[dirE])[k]; + real mfabb = (dist.f[dirW])[kw]; + real mfbcb = (dist.f[dirN])[k]; + real mfbab = (dist.f[dirS])[ks]; + real mfbbc = (dist.f[dirT])[k]; + real mfbba = (dist.f[dirB])[kb]; + real mfccb = (dist.f[dirNE])[k]; + real mfaab = (dist.f[dirSW])[ksw]; + real mfcab = (dist.f[dirSE])[ks]; + real mfacb = (dist.f[dirNW])[kw]; + real mfcbc = (dist.f[dirTE])[k]; + real mfaba = (dist.f[dirBW])[kbw]; + real mfcba = (dist.f[dirBE])[kb]; + real mfabc = (dist.f[dirTW])[kw]; + real mfbcc = (dist.f[dirTN])[k]; + real mfbaa = (dist.f[dirBS])[kbs]; + real mfbca = (dist.f[dirBN])[kb]; + real mfbac = (dist.f[dirTS])[ks]; + real mfbbb = (dist.f[dirZERO])[k]; + real mfccc = (dist.f[dirTNE])[k]; + real mfaac = (dist.f[dirTSW])[ksw]; + real mfcac = (dist.f[dirTSE])[ks]; + real mfacc = (dist.f[dirTNW])[kw]; + real mfcca = (dist.f[dirBNE])[kb]; + real mfaaa = (dist.f[dirBSW])[kbsw]; + real mfcaa = (dist.f[dirBSE])[kbs]; + real mfaca = (dist.f[dirBNW])[kbw]; + //////////////////////////////////////////////////////(unsigned long)////////////////////////////// + //! - Calculate density and velocity using pyramid summation for low round-off errors as in Eq. (J1)-(J3) \ref + //! <a href="https://doi.org/10.1016/j.camwa.2015.05.001"><b>[ M. Geier et al. (2015), + //! DOI:10.1016/j.camwa.2015.05.001 ]</b></a> + //! + real drho = ((((mfccc + mfaaa) + (mfaca + mfcac)) + ((mfacc + mfcaa) + (mfaac + mfcca))) + + (((mfbac + mfbca) + (mfbaa + mfbcc)) + ((mfabc + mfcba) + (mfaba + mfcbc)) + + ((mfacb + mfcab) + (mfaab + mfccb))) + + ((mfabb + mfcbb) + (mfbab + mfbcb) + (mfbba + mfbbc))) + + mfbbb; + + real rrho = c1o1 + drho; + real OOrho = c1o1 / rrho; + + real vvx = ((((mfccc - mfaaa) + (mfcac - mfaca)) + ((mfcaa - mfacc) + (mfcca - mfaac))) + + (((mfcba - mfabc) + (mfcbc - mfaba)) + ((mfcab - mfacb) + (mfccb - mfaab))) + (mfcbb - mfabb)) * + OOrho; + real vvy = ((((mfccc - mfaaa) + (mfaca - mfcac)) + ((mfacc - mfcaa) + (mfcca - mfaac))) + + (((mfbca - mfbac) + (mfbcc - mfbaa)) + ((mfacb - mfcab) + (mfccb - mfaab))) + (mfbcb - mfbab)) * + OOrho; + real vvz = ((((mfccc - mfaaa) + (mfcac - mfaca)) + ((mfacc - mfcaa) + (mfaac - mfcca))) + + (((mfbac - mfbca) + (mfbcc - mfbaa)) + ((mfabc - mfcba) + (mfcbc - mfaba))) + (mfbbc - mfbba)) * + OOrho; + + //////////////////////////////////////////////////////////////////////////////////// + //! - Add half of the acceleration (body force) to the velocity as in Eq. (42) \ref + //! <a href="https://doi.org/10.1016/j.camwa.2015.05.001"><b>[ M. Geier et al. (2015), + //! DOI:10.1016/j.camwa.2015.05.001 ]</b></a> + //! + real factor = c1o1; + for (size_t i = 1; i <= level; i++) { + factor *= c2o1; + } + + real fx = forces[0]; + real fy = forces[1]; + real fz = forces[2]; + + if( bodyForce ){ + fx += bodyForceX[k]; + fy += bodyForceY[k]; + fz += bodyForceZ[k]; + + real vx = vvx; + real vy = vvy; + real vz = vvz; + real acc_x = fx * c1o2 / factor; + real acc_y = fy * c1o2 / factor; + real acc_z = fz * c1o2 / factor; + + vvx += acc_x; + vvy += acc_y; + vvz += acc_z; + + // // Reset body force. To be used when not using round-off correction. + // bodyForceX[k] = 0.0f; + // bodyForceY[k] = 0.0f; + // bodyForceZ[k] = 0.0f; + + //////////////////////////////////////////////////////////////////////////////////// + //!> Round-off correction + //! + //!> Similar to Kahan summation algorithm (https://en.wikipedia.org/wiki/Kahan_summation_algorithm) + //!> Essentially computes the round-off error of the applied force and adds it in the next time step as a compensation. + //!> Seems to be necesseary at very high Re boundary layers, where the forcing and velocity can + //!> differ by several orders of magnitude. + //!> \note 16/05/2022: Testing, still ongoing! + //! + bodyForceX[k] = (acc_x-(vvx-vx))*factor*c2o1; + bodyForceY[k] = (acc_y-(vvy-vy))*factor*c2o1; + bodyForceZ[k] = (acc_z-(vvz-vz))*factor*c2o1; + } + else{ + vvx += fx * c1o2 / factor; + vvy += fy * c1o2 / factor; + vvz += fz * c1o2 / factor; + } + + + //////////////////////////////////////////////////////////////////////////////////// + // calculate the square of velocities for this lattice node + real vx2 = vvx * vvx; + real vy2 = vvy * vvy; + real vz2 = vvz * vvz; + //////////////////////////////////////////////////////////////////////////////////// + //! - Set relaxation limiters for third order cumulants to default value \f$ \lambda=0.001 \f$ according to + //! section 6 in \ref <a href="https://doi.org/10.1016/j.jcp.2017.05.040"><b>[ M. Geier et al. (2017), + //! DOI:10.1016/j.jcp.2017.05.040 ]</b></a> + //! + real wadjust; + real qudricLimitP = quadricLimiters[0]; + real qudricLimitM = quadricLimiters[1]; + real qudricLimitD = quadricLimiters[2]; + //////////////////////////////////////////////////////////////////////////////////// + //! - Chimera transform from well conditioned distributions to central moments as defined in Appendix J in \ref + //! <a href="https://doi.org/10.1016/j.camwa.2015.05.001"><b>[ M. Geier et al. (2015), + //! DOI:10.1016/j.camwa.2015.05.001 ]</b></a> see also Eq. (6)-(14) in \ref <a + //! href="https://doi.org/10.1016/j.jcp.2017.05.040"><b>[ M. Geier et al. (2017), DOI:10.1016/j.jcp.2017.05.040 + //! ]</b></a> + //! + //////////////////////////////////////////////////////////////////////////////////// + // Z - Dir + forwardInverseChimeraWithK(mfaaa, mfaab, mfaac, vvz, vz2, c36o1, c1o36); + forwardInverseChimeraWithK(mfaba, mfabb, mfabc, vvz, vz2, c9o1, c1o9); + forwardInverseChimeraWithK(mfaca, mfacb, mfacc, vvz, vz2, c36o1, c1o36); + forwardInverseChimeraWithK(mfbaa, mfbab, mfbac, vvz, vz2, c9o1, c1o9); + forwardInverseChimeraWithK(mfbba, mfbbb, mfbbc, vvz, vz2, c9o4, c4o9); + forwardInverseChimeraWithK(mfbca, mfbcb, mfbcc, vvz, vz2, c9o1, c1o9); + forwardInverseChimeraWithK(mfcaa, mfcab, mfcac, vvz, vz2, c36o1, c1o36); + forwardInverseChimeraWithK(mfcba, mfcbb, mfcbc, vvz, vz2, c9o1, c1o9); + forwardInverseChimeraWithK(mfcca, mfccb, mfccc, vvz, vz2, c36o1, c1o36); + + //////////////////////////////////////////////////////////////////////////////////// + // Y - Dir + forwardInverseChimeraWithK(mfaaa, mfaba, mfaca, vvy, vy2, c6o1, c1o6); + forwardChimera(mfaab, mfabb, mfacb, vvy, vy2); + forwardInverseChimeraWithK(mfaac, mfabc, mfacc, vvy, vy2, c18o1, c1o18); + forwardInverseChimeraWithK(mfbaa, mfbba, mfbca, vvy, vy2, c3o2, c2o3); + forwardChimera(mfbab, mfbbb, mfbcb, vvy, vy2); + forwardInverseChimeraWithK(mfbac, mfbbc, mfbcc, vvy, vy2, c9o2, c2o9); + forwardInverseChimeraWithK(mfcaa, mfcba, mfcca, vvy, vy2, c6o1, c1o6); + forwardChimera(mfcab, mfcbb, mfccb, vvy, vy2); + forwardInverseChimeraWithK(mfcac, mfcbc, mfccc, vvy, vy2, c18o1, c1o18); + + //////////////////////////////////////////////////////////////////////////////////// + // X - Dir + forwardInverseChimeraWithK(mfaaa, mfbaa, mfcaa, vvx, vx2, c1o1, c1o1); + forwardChimera(mfaba, mfbba, mfcba, vvx, vx2); + forwardInverseChimeraWithK(mfaca, mfbca, mfcca, vvx, vx2, c3o1, c1o3); + forwardChimera(mfaab, mfbab, mfcab, vvx, vx2); + forwardChimera(mfabb, mfbbb, mfcbb, vvx, vx2); + forwardChimera(mfacb, mfbcb, mfccb, vvx, vx2); + forwardInverseChimeraWithK(mfaac, mfbac, mfcac, vvx, vx2, c3o1, c1o3); + forwardChimera(mfabc, mfbbc, mfcbc, vvx, vx2); + forwardInverseChimeraWithK(mfacc, mfbcc, mfccc, vvx, vx2, c3o1, c1o9); + + //////////////////////////////////////////////////////////////////////////////////// + //! - Setting relaxation rates for non-hydrodynamic cumulants (default values). Variable names and equations + //! according to <a href="https://doi.org/10.1016/j.jcp.2017.05.040"><b>[ M. Geier et al. (2017), + //! DOI:10.1016/j.jcp.2017.05.040 ]</b></a> + //! => [NAME IN PAPER]=[NAME IN CODE]=[DEFAULT VALUE]. + //! - Trace of second order cumulants \f$ C_{200}+C_{020}+C_{002} \f$ used to adjust bulk + //! viscosity:\f$\omega_2=OxxPyyPzz=1.0 \f$. + //! - Third order cumulants \f$ C_{120}+C_{102}, C_{210}+C_{012}, C_{201}+C_{021} \f$: \f$ \omega_3=OxyyPxzz + //! \f$ set according to Eq. (111) with simplifications assuming \f$ \omega_2=1.0\f$. + //! - Third order cumulants \f$ C_{120}-C_{102}, C_{210}-C_{012}, C_{201}-C_{021} \f$: \f$ \omega_4 = OxyyMxzz + //! \f$ set according to Eq. (112) with simplifications assuming \f$ \omega_2 = 1.0\f$. + //! - Third order cumulants \f$ C_{111} \f$: \f$ \omega_5 = Oxyz \f$ set according to Eq. (113) with + //! simplifications assuming \f$ \omega_2 = 1.0\f$ (modify for different bulk viscosity). + //! - Fourth order cumulants \f$ C_{220}, C_{202}, C_{022}, C_{211}, C_{121}, C_{112} \f$: for simplification + //! all set to the same default value \f$ \omega_6=\omega_7=\omega_8=O4=1.0 \f$. + //! - Fifth order cumulants \f$ C_{221}, C_{212}, C_{122}\f$: \f$\omega_9=O5=1.0\f$. + //! - Sixth order cumulant \f$ C_{222}\f$: \f$\omega_{10}=O6=1.0\f$. + //! + //////////////////////////////////////////////////////////////////////////////////// + //! - Calculate modified omega with turbulent viscosity + //! + real omega = omega_in / (c1o1 + c3o1*omega_in*turbulentViscosity[k]); + //////////////////////////////////////////////////////////// + // 2. + real OxxPyyPzz = c1o1; + //////////////////////////////////////////////////////////// + // 3. + real OxyyPxzz = c8o1 * (-c2o1 + omega) * (c1o1 + c2o1 * omega) / (-c8o1 - c14o1 * omega + c7o1 * omega * omega); + real OxyyMxzz = + c8o1 * (-c2o1 + omega) * (-c7o1 + c4o1 * omega) / (c56o1 - c50o1 * omega + c9o1 * omega * omega); + real Oxyz = c24o1 * (-c2o1 + omega) * (-c2o1 - c7o1 * omega + c3o1 * omega * omega) / + (c48o1 + c152o1 * omega - c130o1 * omega * omega + c29o1 * omega * omega * omega); + //////////////////////////////////////////////////////////// + // 4. + real O4 = c1o1; + //////////////////////////////////////////////////////////// + // 5. + real O5 = c1o1; + //////////////////////////////////////////////////////////// + // 6. + real O6 = c1o1; + + //////////////////////////////////////////////////////////////////////////////////// + //! - A and B: parameters for fourth order convergence of the diffusion term according to Eq. (114) and (115) + //! <a href="https://doi.org/10.1016/j.jcp.2017.05.040"><b>[ M. Geier et al. (2017), + //! DOI:10.1016/j.jcp.2017.05.040 ]</b></a> with simplifications assuming \f$ \omega_2 = 1.0 \f$ (modify for + //! different bulk viscosity). + //! + real A = (c4o1 + c2o1 * omega - c3o1 * omega * omega) / (c2o1 - c7o1 * omega + c5o1 * omega * omega); + real B = (c4o1 + c28o1 * omega - c14o1 * omega * omega) / (c6o1 - c21o1 * omega + c15o1 * omega * omega); + + //////////////////////////////////////////////////////////////////////////////////// + //! - Compute cumulants from central moments according to Eq. (20)-(23) in + //! <a href="https://doi.org/10.1016/j.jcp.2017.05.040"><b>[ M. Geier et al. (2017), + //! DOI:10.1016/j.jcp.2017.05.040 ]</b></a> + //! + //////////////////////////////////////////////////////////// + // 4. + real CUMcbb = mfcbb - ((mfcaa + c1o3) * mfabb + c2o1 * mfbba * mfbab) * OOrho; + real CUMbcb = mfbcb - ((mfaca + c1o3) * mfbab + c2o1 * mfbba * mfabb) * OOrho; + real CUMbbc = mfbbc - ((mfaac + c1o3) * mfbba + c2o1 * mfbab * mfabb) * OOrho; + + real CUMcca = + mfcca - (((mfcaa * mfaca + c2o1 * mfbba * mfbba) + c1o3 * (mfcaa + mfaca)) * OOrho - c1o9 * (drho * OOrho)); + real CUMcac = + mfcac - (((mfcaa * mfaac + c2o1 * mfbab * mfbab) + c1o3 * (mfcaa + mfaac)) * OOrho - c1o9 * (drho * OOrho)); + real CUMacc = + mfacc - (((mfaac * mfaca + c2o1 * mfabb * mfabb) + c1o3 * (mfaac + mfaca)) * OOrho - c1o9 * (drho * OOrho)); + //////////////////////////////////////////////////////////// + // 5. + real CUMbcc = + mfbcc - ((mfaac * mfbca + mfaca * mfbac + c4o1 * mfabb * mfbbb + c2o1 * (mfbab * mfacb + mfbba * mfabc)) + + c1o3 * (mfbca + mfbac)) * + OOrho; + real CUMcbc = + mfcbc - ((mfaac * mfcba + mfcaa * mfabc + c4o1 * mfbab * mfbbb + c2o1 * (mfabb * mfcab + mfbba * mfbac)) + + c1o3 * (mfcba + mfabc)) * + OOrho; + real CUMccb = + mfccb - ((mfcaa * mfacb + mfaca * mfcab + c4o1 * mfbba * mfbbb + c2o1 * (mfbab * mfbca + mfabb * mfcba)) + + c1o3 * (mfacb + mfcab)) * + OOrho; + //////////////////////////////////////////////////////////// + // 6. + real CUMccc = mfccc + ((-c4o1 * mfbbb * mfbbb - (mfcaa * mfacc + mfaca * mfcac + mfaac * mfcca) - + c4o1 * (mfabb * mfcbb + mfbab * mfbcb + mfbba * mfbbc) - + c2o1 * (mfbca * mfbac + mfcba * mfabc + mfcab * mfacb)) * + OOrho + + (c4o1 * (mfbab * mfbab * mfaca + mfabb * mfabb * mfcaa + mfbba * mfbba * mfaac) + + c2o1 * (mfcaa * mfaca * mfaac) + c16o1 * mfbba * mfbab * mfabb) * + OOrho * OOrho - + c1o3 * (mfacc + mfcac + mfcca) * OOrho - c1o9 * (mfcaa + mfaca + mfaac) * OOrho + + (c2o1 * (mfbab * mfbab + mfabb * mfabb + mfbba * mfbba) + + (mfaac * mfaca + mfaac * mfcaa + mfaca * mfcaa) + c1o3 * (mfaac + mfaca + mfcaa)) * + OOrho * OOrho * c2o3 + + c1o27 * ((drho * drho - drho) * OOrho * OOrho)); + + //////////////////////////////////////////////////////////////////////////////////// + //! - Compute linear combinations of second and third order cumulants + //! + //////////////////////////////////////////////////////////// + // 2. + real mxxPyyPzz = mfcaa + mfaca + mfaac; + real mxxMyy = mfcaa - mfaca; + real mxxMzz = mfcaa - mfaac; + //////////////////////////////////////////////////////////// + // 3. + real mxxyPyzz = mfcba + mfabc; + real mxxyMyzz = mfcba - mfabc; + + real mxxzPyyz = mfcab + mfacb; + real mxxzMyyz = mfcab - mfacb; + + real mxyyPxzz = mfbca + mfbac; + real mxyyMxzz = mfbca - mfbac; + + //////////////////////////////////////////////////////////////////////////////////// + // incl. correction + //////////////////////////////////////////////////////////// + //! - Compute velocity gradients from second order cumulants according to Eq. (27)-(32) + //! <a href="https://doi.org/10.1016/j.jcp.2017.05.040"><b>[ M. Geier et al. (2017), + //! DOI:10.1016/j.jcp.2017.05.040 ]</b></a> Further explanations of the correction in viscosity in Appendix H of + //! <a href="https://doi.org/10.1016/j.camwa.2015.05.001"><b>[ M. Geier et al. (2015), + //! DOI:10.1016/j.camwa.2015.05.001 ]</b></a> Note that the division by rho is omitted here as we need rho times + //! the gradients later. + //! + real Dxy = -c3o1 * omega * mfbba; + real Dxz = -c3o1 * omega * mfbab; + real Dyz = -c3o1 * omega * mfabb; + real dxux = c1o2 * (-omega) * (mxxMyy + mxxMzz) + c1o2 * OxxPyyPzz * (mfaaa - mxxPyyPzz); + real dyuy = dxux + omega * c3o2 * mxxMyy; + real dzuz = dxux + omega * c3o2 * mxxMzz; + + //Smagorinsky for debugging + // if(true) + // { + // if(false && k==99976) + // { + // printf("dudz+dwdu: \t %1.14f \n", Dxz ); + // printf("dvdz+dudy: \t %1.14f \n", Dxy ); + // printf("dwdy+dvdz: \t %1.14f \n", Dyz ); + // printf("nu_t * dudz+dwdu: \t %1.14f \n", turbulentViscosity[k]*Dxz ); + // printf("nu_t * dvdz+dudy: \t %1.14f \n", turbulentViscosity[k]*Dxy ); + // printf("nu_t * dwdy+dvdz: \t %1.14f \n", turbulentViscosity[k]*Dyz ); + // } + // real Sbar = sqrt(c2o1*(dxux*dxux+dyuy*dyuy+dzuz*dzuz)+Dxy*Dxy+Dxz*Dxz+Dyz*Dyz); + // real Cs = 0.08f; + // turbulentViscosity[k] = Cs*Cs*Sbar; + // } + + //////////////////////////////////////////////////////////// + //! - Relaxation of second order cumulants with correction terms according to Eq. (33)-(35) in + //! <a href="https://doi.org/10.1016/j.jcp.2017.05.040"><b>[ M. Geier et al. (2017), + //! DOI:10.1016/j.jcp.2017.05.040 ]</b></a> + //! + mxxPyyPzz += + OxxPyyPzz * (mfaaa - mxxPyyPzz) - c3o1 * (c1o1 - c1o2 * OxxPyyPzz) * (vx2 * dxux + vy2 * dyuy + vz2 * dzuz); + mxxMyy += omega * (-mxxMyy) - c3o1 * (c1o1 + c1o2 * (-omega)) * (vx2 * dxux - vy2 * dyuy); + mxxMzz += omega * (-mxxMzz) - c3o1 * (c1o1 + c1o2 * (-omega)) * (vx2 * dxux - vz2 * dzuz); + + //////////////////////////////////////////////////////////////////////////////////// + ////no correction + // mxxPyyPzz += OxxPyyPzz*(mfaaa - mxxPyyPzz); + // mxxMyy += -(-omega) * (-mxxMyy); + // mxxMzz += -(-omega) * (-mxxMzz); + ////////////////////////////////////////////////////////////////////////// + mfabb += omega * (-mfabb); + mfbab += omega * (-mfbab); + mfbba += omega * (-mfbba); + + //////////////////////////////////////////////////////////////////////////////////// + // relax + ////////////////////////////////////////////////////////////////////////// + // incl. limiter + //! - Relaxation of third order cumulants including limiter according to Eq. (116)-(123) + //! <a href="https://doi.org/10.1016/j.jcp.2017.05.040"><b>[ M. Geier et al. (2017), + //! DOI:10.1016/j.jcp.2017.05.040 ]</b></a> + //! + wadjust = Oxyz + (c1o1 - Oxyz) * abs(mfbbb) / (abs(mfbbb) + qudricLimitD); + mfbbb += wadjust * (-mfbbb); + wadjust = OxyyPxzz + (c1o1 - OxyyPxzz) * abs(mxxyPyzz) / (abs(mxxyPyzz) + qudricLimitP); + mxxyPyzz += wadjust * (-mxxyPyzz); + wadjust = OxyyMxzz + (c1o1 - OxyyMxzz) * abs(mxxyMyzz) / (abs(mxxyMyzz) + qudricLimitM); + mxxyMyzz += wadjust * (-mxxyMyzz); + wadjust = OxyyPxzz + (c1o1 - OxyyPxzz) * abs(mxxzPyyz) / (abs(mxxzPyyz) + qudricLimitP); + mxxzPyyz += wadjust * (-mxxzPyyz); + wadjust = OxyyMxzz + (c1o1 - OxyyMxzz) * abs(mxxzMyyz) / (abs(mxxzMyyz) + qudricLimitM); + mxxzMyyz += wadjust * (-mxxzMyyz); + wadjust = OxyyPxzz + (c1o1 - OxyyPxzz) * abs(mxyyPxzz) / (abs(mxyyPxzz) + qudricLimitP); + mxyyPxzz += wadjust * (-mxyyPxzz); + wadjust = OxyyMxzz + (c1o1 - OxyyMxzz) * abs(mxyyMxzz) / (abs(mxyyMxzz) + qudricLimitM); + mxyyMxzz += wadjust * (-mxyyMxzz); + ////////////////////////////////////////////////////////////////////////// + // no limiter + // mfbbb += OxyyMxzz * (-mfbbb); + // mxxyPyzz += OxyyPxzz * (-mxxyPyzz); + // mxxyMyzz += OxyyMxzz * (-mxxyMyzz); + // mxxzPyyz += OxyyPxzz * (-mxxzPyyz); + // mxxzMyyz += OxyyMxzz * (-mxxzMyyz); + // mxyyPxzz += OxyyPxzz * (-mxyyPxzz); + // mxyyMxzz += OxyyMxzz * (-mxyyMxzz); + + //////////////////////////////////////////////////////////////////////////////////// + //! - Compute inverse linear combinations of second and third order cumulants + //! + mfcaa = c1o3 * (mxxMyy + mxxMzz + mxxPyyPzz); + mfaca = c1o3 * (-c2o1 * mxxMyy + mxxMzz + mxxPyyPzz); + mfaac = c1o3 * (mxxMyy - c2o1 * mxxMzz + mxxPyyPzz); + + mfcba = (mxxyMyzz + mxxyPyzz) * c1o2; + mfabc = (-mxxyMyzz + mxxyPyzz) * c1o2; + mfcab = (mxxzMyyz + mxxzPyyz) * c1o2; + mfacb = (-mxxzMyyz + mxxzPyyz) * c1o2; + mfbca = (mxyyMxzz + mxyyPxzz) * c1o2; + mfbac = (-mxyyMxzz + mxyyPxzz) * c1o2; + ////////////////////////////////////////////////////////////////////////// + + ////////////////////////////////////////////////////////////////////////// + // 4. + // no limiter + //! - Relax fourth order cumulants to modified equilibrium for fourth order convergence of diffusion according + //! to Eq. (43)-(48) <a href="https://doi.org/10.1016/j.jcp.2017.05.040"><b>[ M. Geier et al. (2017), + //! DOI:10.1016/j.jcp.2017.05.040 ]</b></a> + //! + CUMacc = -O4 * (c1o1 / omega - c1o2) * (dyuy + dzuz) * c2o3 * A + (c1o1 - O4) * (CUMacc); + CUMcac = -O4 * (c1o1 / omega - c1o2) * (dxux + dzuz) * c2o3 * A + (c1o1 - O4) * (CUMcac); + CUMcca = -O4 * (c1o1 / omega - c1o2) * (dyuy + dxux) * c2o3 * A + (c1o1 - O4) * (CUMcca); + CUMbbc = -O4 * (c1o1 / omega - c1o2) * Dxy * c1o3 * B + (c1o1 - O4) * (CUMbbc); + CUMbcb = -O4 * (c1o1 / omega - c1o2) * Dxz * c1o3 * B + (c1o1 - O4) * (CUMbcb); + CUMcbb = -O4 * (c1o1 / omega - c1o2) * Dyz * c1o3 * B + (c1o1 - O4) * (CUMcbb); + + ////////////////////////////////////////////////////////////////////////// + // 5. + CUMbcc += O5 * (-CUMbcc); + CUMcbc += O5 * (-CUMcbc); + CUMccb += O5 * (-CUMccb); + + ////////////////////////////////////////////////////////////////////////// + // 6. + CUMccc += O6 * (-CUMccc); + + //////////////////////////////////////////////////////////////////////////////////// + //! - Compute central moments from post collision cumulants according to Eq. (53)-(56) in + //! <a href="https://doi.org/10.1016/j.jcp.2017.05.040"><b>[ M. Geier et al. (2017), + //! DOI:10.1016/j.jcp.2017.05.040 ]</b></a> + //! + + ////////////////////////////////////////////////////////////////////////// + // 4. + mfcbb = CUMcbb + c1o3 * ((c3o1 * mfcaa + c1o1) * mfabb + c6o1 * mfbba * mfbab) * OOrho; + mfbcb = CUMbcb + c1o3 * ((c3o1 * mfaca + c1o1) * mfbab + c6o1 * mfbba * mfabb) * OOrho; + mfbbc = CUMbbc + c1o3 * ((c3o1 * mfaac + c1o1) * mfbba + c6o1 * mfbab * mfabb) * OOrho; + + mfcca = + CUMcca + + (((mfcaa * mfaca + c2o1 * mfbba * mfbba) * c9o1 + c3o1 * (mfcaa + mfaca)) * OOrho - (drho * OOrho)) * c1o9; + mfcac = + CUMcac + + (((mfcaa * mfaac + c2o1 * mfbab * mfbab) * c9o1 + c3o1 * (mfcaa + mfaac)) * OOrho - (drho * OOrho)) * c1o9; + mfacc = + CUMacc + + (((mfaac * mfaca + c2o1 * mfabb * mfabb) * c9o1 + c3o1 * (mfaac + mfaca)) * OOrho - (drho * OOrho)) * c1o9; + + ////////////////////////////////////////////////////////////////////////// + // 5. + mfbcc = CUMbcc + c1o3 * + (c3o1 * (mfaac * mfbca + mfaca * mfbac + c4o1 * mfabb * mfbbb + + c2o1 * (mfbab * mfacb + mfbba * mfabc)) + + (mfbca + mfbac)) * + OOrho; + mfcbc = CUMcbc + c1o3 * + (c3o1 * (mfaac * mfcba + mfcaa * mfabc + c4o1 * mfbab * mfbbb + + c2o1 * (mfabb * mfcab + mfbba * mfbac)) + + (mfcba + mfabc)) * + OOrho; + mfccb = CUMccb + c1o3 * + (c3o1 * (mfcaa * mfacb + mfaca * mfcab + c4o1 * mfbba * mfbbb + + c2o1 * (mfbab * mfbca + mfabb * mfcba)) + + (mfacb + mfcab)) * + OOrho; + + ////////////////////////////////////////////////////////////////////////// + // 6. + mfccc = CUMccc - ((-c4o1 * mfbbb * mfbbb - (mfcaa * mfacc + mfaca * mfcac + mfaac * mfcca) - + c4o1 * (mfabb * mfcbb + mfbab * mfbcb + mfbba * mfbbc) - + c2o1 * (mfbca * mfbac + mfcba * mfabc + mfcab * mfacb)) * + OOrho + + (c4o1 * (mfbab * mfbab * mfaca + mfabb * mfabb * mfcaa + mfbba * mfbba * mfaac) + + c2o1 * (mfcaa * mfaca * mfaac) + c16o1 * mfbba * mfbab * mfabb) * + OOrho * OOrho - + c1o3 * (mfacc + mfcac + mfcca) * OOrho - c1o9 * (mfcaa + mfaca + mfaac) * OOrho + + (c2o1 * (mfbab * mfbab + mfabb * mfabb + mfbba * mfbba) + + (mfaac * mfaca + mfaac * mfcaa + mfaca * mfcaa) + c1o3 * (mfaac + mfaca + mfcaa)) * + OOrho * OOrho * c2o3 + + c1o27 * ((drho * drho - drho) * OOrho * OOrho)); + + //////////////////////////////////////////////////////////////////////////////////// + //! - Add acceleration (body force) to first order cumulants according to Eq. (85)-(87) in + //! <a href="https://doi.org/10.1016/j.camwa.2015.05.001"><b>[ M. Geier et al. (2015), + //! DOI:10.1016/j.camwa.2015.05.001 ]</b></a> + //! + mfbaa = -mfbaa; + mfaba = -mfaba; + mfaab = -mfaab; + + + //Write to array here to distribute read/write + rho[k] = drho; + vx[k] = vvx; + vy[k] = vvy; + vz[k] = vvz; + + //////////////////////////////////////////////////////////////////////////////////// + //! - Chimera transform from central moments to well conditioned distributions as defined in Appendix J in + //! <a href="https://doi.org/10.1016/j.camwa.2015.05.001"><b>[ M. Geier et al. (2015), + //! DOI:10.1016/j.camwa.2015.05.001 ]</b></a> see also Eq. (88)-(96) in <a + //! href="https://doi.org/10.1016/j.jcp.2017.05.040"><b>[ M. Geier et al. (2017), DOI:10.1016/j.jcp.2017.05.040 + //! ]</b></a> + //! + //////////////////////////////////////////////////////////////////////////////////// + // X - Dir + backwardInverseChimeraWithK(mfaaa, mfbaa, mfcaa, vvx, vx2, c1o1, c1o1); + backwardChimera(mfaba, mfbba, mfcba, vvx, vx2); + backwardInverseChimeraWithK(mfaca, mfbca, mfcca, vvx, vx2, c3o1, c1o3); + backwardChimera(mfaab, mfbab, mfcab, vvx, vx2); + backwardChimera(mfabb, mfbbb, mfcbb, vvx, vx2); + backwardChimera(mfacb, mfbcb, mfccb, vvx, vx2); + backwardInverseChimeraWithK(mfaac, mfbac, mfcac, vvx, vx2, c3o1, c1o3); + backwardChimera(mfabc, mfbbc, mfcbc, vvx, vx2); + backwardInverseChimeraWithK(mfacc, mfbcc, mfccc, vvx, vx2, c9o1, c1o9); + + //////////////////////////////////////////////////////////////////////////////////// + // Y - Dir + backwardInverseChimeraWithK(mfaaa, mfaba, mfaca, vvy, vy2, c6o1, c1o6); + backwardChimera(mfaab, mfabb, mfacb, vvy, vy2); + backwardInverseChimeraWithK(mfaac, mfabc, mfacc, vvy, vy2, c18o1, c1o18); + backwardInverseChimeraWithK(mfbaa, mfbba, mfbca, vvy, vy2, c3o2, c2o3); + backwardChimera(mfbab, mfbbb, mfbcb, vvy, vy2); + backwardInverseChimeraWithK(mfbac, mfbbc, mfbcc, vvy, vy2, c9o2, c2o9); + backwardInverseChimeraWithK(mfcaa, mfcba, mfcca, vvy, vy2, c6o1, c1o6); + backwardChimera(mfcab, mfcbb, mfccb, vvy, vy2); + backwardInverseChimeraWithK(mfcac, mfcbc, mfccc, vvy, vy2, c18o1, c1o18); + + //////////////////////////////////////////////////////////////////////////////////// + // Z - Dir + backwardInverseChimeraWithK(mfaaa, mfaab, mfaac, vvz, vz2, c36o1, c1o36); + backwardInverseChimeraWithK(mfaba, mfabb, mfabc, vvz, vz2, c9o1, c1o9); + backwardInverseChimeraWithK(mfaca, mfacb, mfacc, vvz, vz2, c36o1, c1o36); + backwardInverseChimeraWithK(mfbaa, mfbab, mfbac, vvz, vz2, c9o1, c1o9); + backwardInverseChimeraWithK(mfbba, mfbbb, mfbbc, vvz, vz2, c9o4, c4o9); + backwardInverseChimeraWithK(mfbca, mfbcb, mfbcc, vvz, vz2, c9o1, c1o9); + backwardInverseChimeraWithK(mfcaa, mfcab, mfcac, vvz, vz2, c36o1, c1o36); + backwardInverseChimeraWithK(mfcba, mfcbb, mfcbc, vvz, vz2, c9o1, c1o9); + backwardInverseChimeraWithK(mfcca, mfccb, mfccc, vvz, vz2, c36o1, c1o36); + + //////////////////////////////////////////////////////////////////////////////////// + //! - Write distributions: style of reading and writing the distributions from/to + //! stored arrays dependent on timestep is based on the esoteric twist algorithm + //! <a href="https://doi.org/10.3390/computation5020019"><b>[ M. Geier et al. (2017), + //! DOI:10.3390/computation5020019 ]</b></a> + //! + (dist.f[dirE])[k] = mfabb; + (dist.f[dirW])[kw] = mfcbb; + (dist.f[dirN])[k] = mfbab; + (dist.f[dirS])[ks] = mfbcb; + (dist.f[dirT])[k] = mfbba; + (dist.f[dirB])[kb] = mfbbc; + (dist.f[dirNE])[k] = mfaab; + (dist.f[dirSW])[ksw] = mfccb; + (dist.f[dirSE])[ks] = mfacb; + (dist.f[dirNW])[kw] = mfcab; + (dist.f[dirTE])[k] = mfaba; + (dist.f[dirBW])[kbw] = mfcbc; + (dist.f[dirBE])[kb] = mfabc; + (dist.f[dirTW])[kw] = mfcba; + (dist.f[dirTN])[k] = mfbaa; + (dist.f[dirBS])[kbs] = mfbcc; + (dist.f[dirBN])[kb] = mfbac; + (dist.f[dirTS])[ks] = mfbca; + (dist.f[dirZERO])[k] = mfbbb; + (dist.f[dirTNE])[k] = mfaaa; + (dist.f[dirTSE])[ks] = mfaca; + (dist.f[dirBNE])[kb] = mfaac; + (dist.f[dirBSE])[kbs] = mfacc; + (dist.f[dirTNW])[kw] = mfcaa; + (dist.f[dirTSW])[ksw] = mfcca; + (dist.f[dirBNW])[kbw] = mfcac; + (dist.f[dirBSW])[kbsw] = mfccc; + + + } +} + + + + +//WORK IN PROGRESS: Incorporating DistributionWrapper in kernel..... + +// //======================================================================================= +// // ____ ____ __ ______ __________ __ __ __ __ +// // \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// // \ \ | | | | | |_) | | | | | | | / \ | | +// // \ \ | | | | | _ / | | | | | | / /\ \ | | +// // \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// // \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// // \ \ | | ________________________________________________________________ +// // \ \ | | | ______________________________________________________________| +// // \ \| | | | __ __ __ __ ______ _______ +// // \ | | |_____ | | | | | | | | | _ \ / _____) +// // \ | | _____| | | | | | | | | | | \ \ \_______ +// // \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// // \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// // +// // This file is part of VirtualFluids. VirtualFluids 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. +// // +// // VirtualFluids 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 VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// // +// //! \file TurbulentViscosityCumulantK17CompChim_Device.cu +// //! \author Henry Korb, Henrik Asmuth +// //! \date 16/05/2022 +// //! \brief CumulantK17CompChim kernel by Martin Schönherr that inlcudes turbulent viscosity and other small mods. +// //! +// //! Additions to CumulantK17CompChim: +// //! - can incorporate local body force +// //! - when applying a local body force, the total round of error of forcing+bodyforce is saved and added in next time step +// //! - uses turbulent viscosity that is computed in separate kernel (as of now AMD) +// //! - saves macroscopic values (needed for instance for probes, AMD, and actuator models) +// //! +// //======================================================================================= +// /* Device code */ +// #include "LBM/LB.h" +// #include "LBM/D3Q27.h" +// #include <lbm/constants/NumericConstants.h> + +// using namespace vf::lbm::constant; +// #include "Kernel/ChimeraTransformation.h" + +// #include "Kernel/Utilities/DistributionHelper.cuh" + +// #include "lbm/MacroscopicQuantities.h" + +// //////////////////////////////////////////////////////////////////////////////// +// extern "C" __global__ void LB_Kernel_TurbulentViscosityCumulantK17CompChim( +// real omega_in, +// uint* typeOfGridNode, +// uint* neighborX, +// uint* neighborY, +// uint* neighborZ, +// real* distributions, +// real* rho, +// real* vx, +// real* vy, +// real* vz, +// real* turbulentViscosity, +// unsigned long size_Mat, +// int level, +// bool bodyForce, +// real* forces, +// real* bodyForceX, +// real* bodyForceY, +// real* bodyForceZ, +// real* quadricLimiters, +// bool isEvenTimestep) +// { +// ////////////////////////////////////////////////////////////////////////// +// //! Cumulant K17 Kernel is based on \ref +// //! <a href="https://doi.org/10.1016/j.jcp.2017.05.040"><b>[ M. Geier et al. (2017), DOI:10.1016/j.jcp.2017.05.040 +// //! ]</b></a> and \ref <a href="https://doi.org/10.1016/j.jcp.2017.07.004"><b>[ M. Geier et al. (2017), +// //! DOI:10.1016/j.jcp.2017.07.004 ]</b></a> +// //! +// //! The cumulant kernel is executed in the following steps +// //! +// //////////////////////////////////////////////////////////////////////////////// +// //! - Get node index coordinates from threadIdx, blockIdx, blockDim and gridDim. +// //! + +// // const unsigned x = threadIdx.x; +// // const unsigned y = blockIdx.x; +// // const unsigned z = blockIdx.y; + +// // const unsigned nx = blockDim.x; +// // const unsigned ny = gridDim.x; + +// // const unsigned k = nx * (ny * z + y) + x; +// const unsigned k = vf::gpu::getNodeIndex(); +// ////////////////////////////////////////////////////////////////////////// +// // run for all indices in size_Mat and fluid nodes +// // if ((k < size_Mat) && (typeOfGridNode[k] == GEO_FLUID)) { +// if ((k < size_Mat) && vf::gpu::isValidFluidNode(typeOfGridNode[k])) { +// ////////////////////////////////////////////////////////////////////////// +// //! - Read distributions: style of reading and writing the distributions from/to stored arrays dependent on +// //! timestep is based on the esoteric twist algorithm \ref <a +// //! href="https://doi.org/10.3390/computation5020019"><b>[ M. Geier et al. (2017), +// //! DOI:10.3390/computation5020019 ]</b></a> +// //! + +// vf::gpu::DistributionWrapper distr_wrapper( distributions, size_Mat, +// isEvenTimestep, k, +// neighborX, neighborY, neighborZ); + +// Distributions27 dist; +// if (isEvenTimestep) { +// dist.f[dirE] = &distributions[dirE * size_Mat]; +// dist.f[dirW] = &distributions[dirW * size_Mat]; +// dist.f[dirN] = &distributions[dirN * size_Mat]; +// dist.f[dirS] = &distributions[dirS * size_Mat]; +// dist.f[dirT] = &distributions[dirT * size_Mat]; +// dist.f[dirB] = &distributions[dirB * size_Mat]; +// dist.f[dirNE] = &distributions[dirNE * size_Mat]; +// dist.f[dirSW] = &distributions[dirSW * size_Mat]; +// dist.f[dirSE] = &distributions[dirSE * size_Mat]; +// dist.f[dirNW] = &distributions[dirNW * size_Mat]; +// dist.f[dirTE] = &distributions[dirTE * size_Mat]; +// dist.f[dirBW] = &distributions[dirBW * size_Mat]; +// dist.f[dirBE] = &distributions[dirBE * size_Mat]; +// dist.f[dirTW] = &distributions[dirTW * size_Mat]; +// dist.f[dirTN] = &distributions[dirTN * size_Mat]; +// dist.f[dirBS] = &distributions[dirBS * size_Mat]; +// dist.f[dirBN] = &distributions[dirBN * size_Mat]; +// dist.f[dirTS] = &distributions[dirTS * size_Mat]; +// dist.f[dirZERO] = &distributions[dirZERO * size_Mat]; +// dist.f[dirTNE] = &distributions[dirTNE * size_Mat]; +// dist.f[dirTSW] = &distributions[dirTSW * size_Mat]; +// dist.f[dirTSE] = &distributions[dirTSE * size_Mat]; +// dist.f[dirTNW] = &distributions[dirTNW * size_Mat]; +// dist.f[dirBNE] = &distributions[dirBNE * size_Mat]; +// dist.f[dirBSW] = &distributions[dirBSW * size_Mat]; +// dist.f[dirBSE] = &distributions[dirBSE * size_Mat]; +// dist.f[dirBNW] = &distributions[dirBNW * size_Mat]; +// } else { +// dist.f[dirW] = &distributions[dirE * size_Mat]; +// dist.f[dirE] = &distributions[dirW * size_Mat]; +// dist.f[dirS] = &distributions[dirN * size_Mat]; +// dist.f[dirN] = &distributions[dirS * size_Mat]; +// dist.f[dirB] = &distributions[dirT * size_Mat]; +// dist.f[dirT] = &distributions[dirB * size_Mat]; +// dist.f[dirSW] = &distributions[dirNE * size_Mat]; +// dist.f[dirNE] = &distributions[dirSW * size_Mat]; +// dist.f[dirNW] = &distributions[dirSE * size_Mat]; +// dist.f[dirSE] = &distributions[dirNW * size_Mat]; +// dist.f[dirBW] = &distributions[dirTE * size_Mat]; +// dist.f[dirTE] = &distributions[dirBW * size_Mat]; +// dist.f[dirTW] = &distributions[dirBE * size_Mat]; +// dist.f[dirBE] = &distributions[dirTW * size_Mat]; +// dist.f[dirBS] = &distributions[dirTN * size_Mat]; +// dist.f[dirTN] = &distributions[dirBS * size_Mat]; +// dist.f[dirTS] = &distributions[dirBN * size_Mat]; +// dist.f[dirBN] = &distributions[dirTS * size_Mat]; +// dist.f[dirZERO] = &distributions[dirZERO * size_Mat]; +// dist.f[dirBSW] = &distributions[dirTNE * size_Mat]; +// dist.f[dirBNE] = &distributions[dirTSW * size_Mat]; +// dist.f[dirBNW] = &distributions[dirTSE * size_Mat]; +// dist.f[dirBSE] = &distributions[dirTNW * size_Mat]; +// dist.f[dirTSW] = &distributions[dirBNE * size_Mat]; +// dist.f[dirTNE] = &distributions[dirBSW * size_Mat]; +// dist.f[dirTNW] = &distributions[dirBSE * size_Mat]; +// dist.f[dirTSE] = &distributions[dirBNW * size_Mat]; +// } +// //////////////////////////////////////////////////////////////////////////////// +// //! - Set neighbor indices (necessary for indirect addressing) +// uint kw = neighborX[k]; +// uint ks = neighborY[k]; +// uint kb = neighborZ[k]; +// uint ksw = neighborY[kw]; +// uint kbw = neighborZ[kw]; +// uint kbs = neighborZ[ks]; +// uint kbsw = neighborZ[ksw]; +// //////////////////////////////////////////////////////////////////////////////////// +// //! - Set local distributions +// //! + +// // real mfcbb = distr_wrapper.distribution.f[dirE]; +// // real mfabb = distr_wrapper.distribution.f[dirW]; +// // real mfbcb = distr_wrapper.distribution.f[dirN]; +// // real mfbab = distr_wrapper.distribution.f[dirS]; +// // real mfbbc = distr_wrapper.distribution.f[dirT]; +// // real mfbba = distr_wrapper.distribution.f[dirB]; +// // real mfccb = distr_wrapper.distribution.f[dirNE]; +// // real mfaab = distr_wrapper.distribution.f[dirSW]; +// // real mfcab = distr_wrapper.distribution.f[dirSE]; +// // real mfacb = distr_wrapper.distribution.f[dirNW]; +// // real mfcbc = distr_wrapper.distribution.f[dirTE]; +// // real mfaba = distr_wrapper.distribution.f[dirBW]; +// // real mfcba = distr_wrapper.distribution.f[dirBE]; +// // real mfabc = distr_wrapper.distribution.f[dirTW]; +// // real mfbcc = distr_wrapper.distribution.f[dirTN]; +// // real mfbaa = distr_wrapper.distribution.f[dirBS]; +// // real mfbca = distr_wrapper.distribution.f[dirBN]; +// // real mfbac = distr_wrapper.distribution.f[dirTS]; +// // real mfbbb = distr_wrapper.distribution.f[dirZERO]; +// // real mfccc = distr_wrapper.distribution.f[dirTNE]; +// // real mfaac = distr_wrapper.distribution.f[dirTSW]; +// // real mfcac = distr_wrapper.distribution.f[dirTSE]; +// // real mfacc = distr_wrapper.distribution.f[dirTNW]; +// // real mfcca = distr_wrapper.distribution.f[dirBNE]; +// // real mfaaa = distr_wrapper.distribution.f[dirBSW]; +// // real mfcaa = distr_wrapper.distribution.f[dirBSE]; +// // real mfaca = distr_wrapper.distribution.f[dirBNW]; + + +// real mfcbb = (dist.f[dirE])[k]; +// real mfabb = (dist.f[dirW])[kw]; +// real mfbcb = (dist.f[dirN])[k]; +// real mfbab = (dist.f[dirS])[ks]; +// real mfbbc = (dist.f[dirT])[k]; +// real mfbba = (dist.f[dirB])[kb]; +// real mfccb = (dist.f[dirNE])[k]; +// real mfaab = (dist.f[dirSW])[ksw]; +// real mfcab = (dist.f[dirSE])[ks]; +// real mfacb = (dist.f[dirNW])[kw]; +// real mfcbc = (dist.f[dirTE])[k]; +// real mfaba = (dist.f[dirBW])[kbw]; +// real mfcba = (dist.f[dirBE])[kb]; +// real mfabc = (dist.f[dirTW])[kw]; +// real mfbcc = (dist.f[dirTN])[k]; +// real mfbaa = (dist.f[dirBS])[kbs]; +// real mfbca = (dist.f[dirBN])[kb]; +// real mfbac = (dist.f[dirTS])[ks]; +// real mfbbb = (dist.f[dirZERO])[k]; +// real mfccc = (dist.f[dirTNE])[k]; +// real mfaac = (dist.f[dirTSW])[ksw]; +// real mfcac = (dist.f[dirTSE])[ks]; +// real mfacc = (dist.f[dirTNW])[kw]; +// real mfcca = (dist.f[dirBNE])[kb]; +// real mfaaa = (dist.f[dirBSW])[kbsw]; +// real mfcaa = (dist.f[dirBSE])[kbs]; +// real mfaca = (dist.f[dirBNW])[kbw]; + +// //////////////////////////////////////////////////////(unsigned long)////////////////////////////// +// //! - Calculate density and velocity using pyramid summation for low round-off errors as in Eq. (J1)-(J3) \ref +// //! <a href="https://doi.org/10.1016/j.camwa.2015.05.001"><b>[ M. Geier et al. (2015), +// //! DOI:10.1016/j.camwa.2015.05.001 ]</b></a> +// //! +// // real drho = ((((mfccc + mfaaa) + (mfaca + mfcac)) + ((mfacc + mfcaa) + (mfaac + mfcca))) + +// // (((mfbac + mfbca) + (mfbaa + mfbcc)) + ((mfabc + mfcba) + (mfaba + mfcbc)) + +// // ((mfacb + mfcab) + (mfaab + mfccb))) + +// // ((mfabb + mfcbb) + (mfbab + mfbcb) + (mfbba + mfbbc))) + +// // mfbbb; +// real drho = vf::lbm::getDensity(distr_wrapper.distribution.f); + +// real rrho = c1o1 + drho; +// real OOrho = c1o1 / rrho; + +// // real vvx = ((((mfccc - mfaaa) + (mfcac - mfaca)) + ((mfcaa - mfacc) + (mfcca - mfaac))) + +// // (((mfcba - mfabc) + (mfcbc - mfaba)) + ((mfcab - mfacb) + (mfccb - mfaab))) + (mfcbb - mfabb)) * +// // OOrho; +// real vvx = vf::lbm::getCompressibleVelocityX1(distr_wrapper.distribution.f, drho); +// // real vvy = ((((mfccc - mfaaa) + (mfaca - mfcac)) + ((mfacc - mfcaa) + (mfcca - mfaac))) + +// // (((mfbca - mfbac) + (mfbcc - mfbaa)) + ((mfacb - mfcab) + (mfccb - mfaab))) + (mfbcb - mfbab)) * +// // OOrho; +// real vvy = vf::lbm::getCompressibleVelocityX2(distr_wrapper.distribution.f, drho); +// // real vvz = ((((mfccc - mfaaa) + (mfcac - mfaca)) + ((mfacc - mfcaa) + (mfaac - mfcca))) + +// // (((mfbac - mfbca) + (mfbcc - mfbaa)) + ((mfabc - mfcba) + (mfcbc - mfaba))) + (mfbbc - mfbba)) * +// // OOrho; +// real vvz = vf::lbm::getCompressibleVelocityX3(distr_wrapper.distribution.f, drho); +// // if(k==100000){printf("%f \t %f \t%f \t%f \n\n", drho, vvx, vvz, vvy);} +// //////////////////////////////////////////////////////////////////////////////////// +// //! - Add half of the acceleration (body force) to the velocity as in Eq. (42) \ref +// //! <a href="https://doi.org/10.1016/j.camwa.2015.05.001"><b>[ M. Geier et al. (2015), +// //! DOI:10.1016/j.camwa.2015.05.001 ]</b></a> +// //! +// real factor = c1o1; +// for (size_t i = 1; i <= level; i++) { +// factor *= c2o1; +// } + +// real fx = forces[0]; +// real fy = forces[1]; +// real fz = forces[2]; + +// if( bodyForce ){ +// fx += bodyForceX[k]; +// fy += bodyForceY[k]; +// fz += bodyForceZ[k]; + +// real vx = vvx; +// real vy = vvy; +// real vz = vvz; +// real acc_x = fx * c1o2 / factor; +// real acc_y = fy * c1o2 / factor; +// real acc_z = fz * c1o2 / factor; + +// vvx += acc_x; +// vvy += acc_y; +// vvz += acc_z; + +// // // Reset body force. To be used when not using round-off correction. +// // bodyForceX[k] = 0.0f; +// // bodyForceY[k] = 0.0f; +// // bodyForceZ[k] = 0.0f; + +// //////////////////////////////////////////////////////////////////////////////////// +// //!> Round-off correction +// //! +// //!> Similar to Kahan summation algorithm (https://en.wikipedia.org/wiki/Kahan_summation_algorithm) +// //!> Essentially computes the round-off error of the applied force and adds it in the next time step as a compensation. +// //!> Seems to be necesseary at very high Re boundary layers, where the forcing and velocity can +// //!> differ by several orders of magnitude. +// //!> \note 16/05/2022: Testing, still ongoing! +// //! +// bodyForceX[k] = (acc_x-(double)(vvx-vx))*factor*c2o1; +// bodyForceY[k] = (acc_y-(double)(vvy-vy))*factor*c2o1; +// bodyForceZ[k] = (acc_z-(double)(vvz-vz))*factor*c2o1; + +// } +// else{ +// vvx += fx * c1o2 / factor; +// vvy += fy * c1o2 / factor; +// vvz += fz * c1o2 / factor; +// } + + +// //////////////////////////////////////////////////////////////////////////////////// +// // calculate the square of velocities for this lattice node +// real vx2 = vvx * vvx; +// real vy2 = vvy * vvy; +// real vz2 = vvz * vvz; +// //////////////////////////////////////////////////////////////////////////////////// +// //! - Set relaxation limiters for third order cumulants to default value \f$ \lambda=0.001 \f$ according to +// //! section 6 in \ref <a href="https://doi.org/10.1016/j.jcp.2017.05.040"><b>[ M. Geier et al. (2017), +// //! DOI:10.1016/j.jcp.2017.05.040 ]</b></a> +// //! +// real wadjust; +// real qudricLimitP = quadricLimiters[0]; +// real qudricLimitM = quadricLimiters[1]; +// real qudricLimitD = quadricLimiters[2]; +// //////////////////////////////////////////////////////////////////////////////////// +// //! - Chimera transform from well conditioned distributions to central moments as defined in Appendix J in \ref +// //! <a href="https://doi.org/10.1016/j.camwa.2015.05.001"><b>[ M. Geier et al. (2015), +// //! DOI:10.1016/j.camwa.2015.05.001 ]</b></a> see also Eq. (6)-(14) in \ref <a +// //! href="https://doi.org/10.1016/j.jcp.2017.05.040"><b>[ M. Geier et al. (2017), DOI:10.1016/j.jcp.2017.05.040 +// //! ]</b></a> +// //! +// //////////////////////////////////////////////////////////////////////////////////// +// // Z - Dir +// forwardInverseChimeraWithK(mfaaa, mfaab, mfaac, vvz, vz2, c36o1, c1o36); +// forwardInverseChimeraWithK(mfaba, mfabb, mfabc, vvz, vz2, c9o1, c1o9); +// forwardInverseChimeraWithK(mfaca, mfacb, mfacc, vvz, vz2, c36o1, c1o36); +// forwardInverseChimeraWithK(mfbaa, mfbab, mfbac, vvz, vz2, c9o1, c1o9); +// forwardInverseChimeraWithK(mfbba, mfbbb, mfbbc, vvz, vz2, c9o4, c4o9); +// forwardInverseChimeraWithK(mfbca, mfbcb, mfbcc, vvz, vz2, c9o1, c1o9); +// forwardInverseChimeraWithK(mfcaa, mfcab, mfcac, vvz, vz2, c36o1, c1o36); +// forwardInverseChimeraWithK(mfcba, mfcbb, mfcbc, vvz, vz2, c9o1, c1o9); +// forwardInverseChimeraWithK(mfcca, mfccb, mfccc, vvz, vz2, c36o1, c1o36); + +// //////////////////////////////////////////////////////////////////////////////////// +// // Y - Dir +// forwardInverseChimeraWithK(mfaaa, mfaba, mfaca, vvy, vy2, c6o1, c1o6); +// forwardChimera(mfaab, mfabb, mfacb, vvy, vy2); +// forwardInverseChimeraWithK(mfaac, mfabc, mfacc, vvy, vy2, c18o1, c1o18); +// forwardInverseChimeraWithK(mfbaa, mfbba, mfbca, vvy, vy2, c3o2, c2o3); +// forwardChimera(mfbab, mfbbb, mfbcb, vvy, vy2); +// forwardInverseChimeraWithK(mfbac, mfbbc, mfbcc, vvy, vy2, c9o2, c2o9); +// forwardInverseChimeraWithK(mfcaa, mfcba, mfcca, vvy, vy2, c6o1, c1o6); +// forwardChimera(mfcab, mfcbb, mfccb, vvy, vy2); +// forwardInverseChimeraWithK(mfcac, mfcbc, mfccc, vvy, vy2, c18o1, c1o18); + +// //////////////////////////////////////////////////////////////////////////////////// +// // X - Dir +// forwardInverseChimeraWithK(mfaaa, mfbaa, mfcaa, vvx, vx2, c1o1, c1o1); +// forwardChimera(mfaba, mfbba, mfcba, vvx, vx2); +// forwardInverseChimeraWithK(mfaca, mfbca, mfcca, vvx, vx2, c3o1, c1o3); +// forwardChimera(mfaab, mfbab, mfcab, vvx, vx2); +// forwardChimera(mfabb, mfbbb, mfcbb, vvx, vx2); +// forwardChimera(mfacb, mfbcb, mfccb, vvx, vx2); +// forwardInverseChimeraWithK(mfaac, mfbac, mfcac, vvx, vx2, c3o1, c1o3); +// forwardChimera(mfabc, mfbbc, mfcbc, vvx, vx2); +// forwardInverseChimeraWithK(mfacc, mfbcc, mfccc, vvx, vx2, c3o1, c1o9); + +// //////////////////////////////////////////////////////////////////////////////////// +// //! - Setting relaxation rates for non-hydrodynamic cumulants (default values). Variable names and equations +// //! according to <a href="https://doi.org/10.1016/j.jcp.2017.05.040"><b>[ M. Geier et al. (2017), +// //! DOI:10.1016/j.jcp.2017.05.040 ]</b></a> +// //! => [NAME IN PAPER]=[NAME IN CODE]=[DEFAULT VALUE]. +// //! - Trace of second order cumulants \f$ C_{200}+C_{020}+C_{002} \f$ used to adjust bulk +// //! viscosity:\f$\omega_2=OxxPyyPzz=1.0 \f$. +// //! - Third order cumulants \f$ C_{120}+C_{102}, C_{210}+C_{012}, C_{201}+C_{021} \f$: \f$ \omega_3=OxyyPxzz +// //! \f$ set according to Eq. (111) with simplifications assuming \f$ \omega_2=1.0\f$. +// //! - Third order cumulants \f$ C_{120}-C_{102}, C_{210}-C_{012}, C_{201}-C_{021} \f$: \f$ \omega_4 = OxyyMxzz +// //! \f$ set according to Eq. (112) with simplifications assuming \f$ \omega_2 = 1.0\f$. +// //! - Third order cumulants \f$ C_{111} \f$: \f$ \omega_5 = Oxyz \f$ set according to Eq. (113) with +// //! simplifications assuming \f$ \omega_2 = 1.0\f$ (modify for different bulk viscosity). +// //! - Fourth order cumulants \f$ C_{220}, C_{202}, C_{022}, C_{211}, C_{121}, C_{112} \f$: for simplification +// //! all set to the same default value \f$ \omega_6=\omega_7=\omega_8=O4=1.0 \f$. +// //! - Fifth order cumulants \f$ C_{221}, C_{212}, C_{122}\f$: \f$\omega_9=O5=1.0\f$. +// //! - Sixth order cumulant \f$ C_{222}\f$: \f$\omega_{10}=O6=1.0\f$. +// //! +// //////////////////////////////////////////////////////////////////////////////////// +// //! - Calculate modified omega with turbulent viscosity +// //! +// real omega = omega_in / (c1o1 + c3o1*omega_in*turbulentViscosity[k]); +// //////////////////////////////////////////////////////////// +// // 2. +// real OxxPyyPzz = c1o1; +// //////////////////////////////////////////////////////////// +// // 3. +// real OxyyPxzz = c8o1 * (-c2o1 + omega) * (c1o1 + c2o1 * omega) / (-c8o1 - c14o1 * omega + c7o1 * omega * omega); +// real OxyyMxzz = +// c8o1 * (-c2o1 + omega) * (-c7o1 + c4o1 * omega) / (c56o1 - c50o1 * omega + c9o1 * omega * omega); +// real Oxyz = c24o1 * (-c2o1 + omega) * (-c2o1 - c7o1 * omega + c3o1 * omega * omega) / +// (c48o1 + c152o1 * omega - c130o1 * omega * omega + c29o1 * omega * omega * omega); +// //////////////////////////////////////////////////////////// +// // 4. +// real O4 = c1o1; +// //////////////////////////////////////////////////////////// +// // 5. +// real O5 = c1o1; +// //////////////////////////////////////////////////////////// +// // 6. +// real O6 = c1o1; + +// //////////////////////////////////////////////////////////////////////////////////// +// //! - A and B: parameters for fourth order convergence of the diffusion term according to Eq. (114) and (115) +// //! <a href="https://doi.org/10.1016/j.jcp.2017.05.040"><b>[ M. Geier et al. (2017), +// //! DOI:10.1016/j.jcp.2017.05.040 ]</b></a> with simplifications assuming \f$ \omega_2 = 1.0 \f$ (modify for +// //! different bulk viscosity). +// //! +// real A = (c4o1 + c2o1 * omega - c3o1 * omega * omega) / (c2o1 - c7o1 * omega + c5o1 * omega * omega); +// real B = (c4o1 + c28o1 * omega - c14o1 * omega * omega) / (c6o1 - c21o1 * omega + c15o1 * omega * omega); + +// //////////////////////////////////////////////////////////////////////////////////// +// //! - Compute cumulants from central moments according to Eq. (20)-(23) in +// //! <a href="https://doi.org/10.1016/j.jcp.2017.05.040"><b>[ M. Geier et al. (2017), +// //! DOI:10.1016/j.jcp.2017.05.040 ]</b></a> +// //! +// //////////////////////////////////////////////////////////// +// // 4. +// real CUMcbb = mfcbb - ((mfcaa + c1o3) * mfabb + c2o1 * mfbba * mfbab) * OOrho; +// real CUMbcb = mfbcb - ((mfaca + c1o3) * mfbab + c2o1 * mfbba * mfabb) * OOrho; +// real CUMbbc = mfbbc - ((mfaac + c1o3) * mfbba + c2o1 * mfbab * mfabb) * OOrho; + +// real CUMcca = +// mfcca - (((mfcaa * mfaca + c2o1 * mfbba * mfbba) + c1o3 * (mfcaa + mfaca)) * OOrho - c1o9 * (drho * OOrho)); +// real CUMcac = +// mfcac - (((mfcaa * mfaac + c2o1 * mfbab * mfbab) + c1o3 * (mfcaa + mfaac)) * OOrho - c1o9 * (drho * OOrho)); +// real CUMacc = +// mfacc - (((mfaac * mfaca + c2o1 * mfabb * mfabb) + c1o3 * (mfaac + mfaca)) * OOrho - c1o9 * (drho * OOrho)); +// //////////////////////////////////////////////////////////// +// // 5. +// real CUMbcc = +// mfbcc - ((mfaac * mfbca + mfaca * mfbac + c4o1 * mfabb * mfbbb + c2o1 * (mfbab * mfacb + mfbba * mfabc)) + +// c1o3 * (mfbca + mfbac)) * +// OOrho; +// real CUMcbc = +// mfcbc - ((mfaac * mfcba + mfcaa * mfabc + c4o1 * mfbab * mfbbb + c2o1 * (mfabb * mfcab + mfbba * mfbac)) + +// c1o3 * (mfcba + mfabc)) * +// OOrho; +// real CUMccb = +// mfccb - ((mfcaa * mfacb + mfaca * mfcab + c4o1 * mfbba * mfbbb + c2o1 * (mfbab * mfbca + mfabb * mfcba)) + +// c1o3 * (mfacb + mfcab)) * +// OOrho; +// //////////////////////////////////////////////////////////// +// // 6. +// real CUMccc = mfccc + ((-c4o1 * mfbbb * mfbbb - (mfcaa * mfacc + mfaca * mfcac + mfaac * mfcca) - +// c4o1 * (mfabb * mfcbb + mfbab * mfbcb + mfbba * mfbbc) - +// c2o1 * (mfbca * mfbac + mfcba * mfabc + mfcab * mfacb)) * +// OOrho + +// (c4o1 * (mfbab * mfbab * mfaca + mfabb * mfabb * mfcaa + mfbba * mfbba * mfaac) + +// c2o1 * (mfcaa * mfaca * mfaac) + c16o1 * mfbba * mfbab * mfabb) * +// OOrho * OOrho - +// c1o3 * (mfacc + mfcac + mfcca) * OOrho - c1o9 * (mfcaa + mfaca + mfaac) * OOrho + +// (c2o1 * (mfbab * mfbab + mfabb * mfabb + mfbba * mfbba) + +// (mfaac * mfaca + mfaac * mfcaa + mfaca * mfcaa) + c1o3 * (mfaac + mfaca + mfcaa)) * +// OOrho * OOrho * c2o3 + +// c1o27 * ((drho * drho - drho) * OOrho * OOrho)); + +// //////////////////////////////////////////////////////////////////////////////////// +// //! - Compute linear combinations of second and third order cumulants +// //! +// //////////////////////////////////////////////////////////// +// // 2. +// real mxxPyyPzz = mfcaa + mfaca + mfaac; +// real mxxMyy = mfcaa - mfaca; +// real mxxMzz = mfcaa - mfaac; +// //////////////////////////////////////////////////////////// +// // 3. +// real mxxyPyzz = mfcba + mfabc; +// real mxxyMyzz = mfcba - mfabc; + +// real mxxzPyyz = mfcab + mfacb; +// real mxxzMyyz = mfcab - mfacb; + +// real mxyyPxzz = mfbca + mfbac; +// real mxyyMxzz = mfbca - mfbac; + +// //////////////////////////////////////////////////////////////////////////////////// +// // incl. correction +// //////////////////////////////////////////////////////////// +// //! - Compute velocity gradients from second order cumulants according to Eq. (27)-(32) +// //! <a href="https://doi.org/10.1016/j.jcp.2017.05.040"><b>[ M. Geier et al. (2017), +// //! DOI:10.1016/j.jcp.2017.05.040 ]</b></a> Further explanations of the correction in viscosity in Appendix H of +// //! <a href="https://doi.org/10.1016/j.camwa.2015.05.001"><b>[ M. Geier et al. (2015), +// //! DOI:10.1016/j.camwa.2015.05.001 ]</b></a> Note that the division by rho is omitted here as we need rho times +// //! the gradients later. +// //! +// real Dxy = -c3o1 * omega * mfbba; +// real Dxz = -c3o1 * omega * mfbab; +// real Dyz = -c3o1 * omega * mfabb; +// real dxux = c1o2 * (-omega) * (mxxMyy + mxxMzz) + c1o2 * OxxPyyPzz * (mfaaa - mxxPyyPzz); +// real dyuy = dxux + omega * c3o2 * mxxMyy; +// real dzuz = dxux + omega * c3o2 * mxxMzz; + +// //Smagorinsky for debugging +// // if(true) +// // { +// // if(false && k==99976) +// // { +// // printf("dudz+dwdu: \t %1.14f \n", Dxz ); +// // printf("dvdz+dudy: \t %1.14f \n", Dxy ); +// // printf("dwdy+dvdz: \t %1.14f \n", Dyz ); +// // printf("nu_t * dudz+dwdu: \t %1.14f \n", turbulentViscosity[k]*Dxz ); +// // printf("nu_t * dvdz+dudy: \t %1.14f \n", turbulentViscosity[k]*Dxy ); +// // printf("nu_t * dwdy+dvdz: \t %1.14f \n", turbulentViscosity[k]*Dyz ); +// // } +// // real Sbar = sqrt(c2o1*(dxux*dxux+dyuy*dyuy+dzuz*dzuz)+Dxy*Dxy+Dxz*Dxz+Dyz*Dyz); +// // real Cs = 0.08f; +// // turbulentViscosity[k] = Cs*Cs*Sbar; +// // } + +// //////////////////////////////////////////////////////////// +// //! - Relaxation of second order cumulants with correction terms according to Eq. (33)-(35) in +// //! <a href="https://doi.org/10.1016/j.jcp.2017.05.040"><b>[ M. Geier et al. (2017), +// //! DOI:10.1016/j.jcp.2017.05.040 ]</b></a> +// //! +// mxxPyyPzz += +// OxxPyyPzz * (mfaaa - mxxPyyPzz) - c3o1 * (c1o1 - c1o2 * OxxPyyPzz) * (vx2 * dxux + vy2 * dyuy + vz2 * dzuz); +// mxxMyy += omega * (-mxxMyy) - c3o1 * (c1o1 + c1o2 * (-omega)) * (vx2 * dxux - vy2 * dyuy); +// mxxMzz += omega * (-mxxMzz) - c3o1 * (c1o1 + c1o2 * (-omega)) * (vx2 * dxux - vz2 * dzuz); + +// //////////////////////////////////////////////////////////////////////////////////// +// ////no correction +// // mxxPyyPzz += OxxPyyPzz*(mfaaa - mxxPyyPzz); +// // mxxMyy += -(-omega) * (-mxxMyy); +// // mxxMzz += -(-omega) * (-mxxMzz); +// ////////////////////////////////////////////////////////////////////////// +// mfabb += omega * (-mfabb); +// mfbab += omega * (-mfbab); +// mfbba += omega * (-mfbba); + +// //////////////////////////////////////////////////////////////////////////////////// +// // relax +// ////////////////////////////////////////////////////////////////////////// +// // incl. limiter +// //! - Relaxation of third order cumulants including limiter according to Eq. (116)-(123) +// //! <a href="https://doi.org/10.1016/j.jcp.2017.05.040"><b>[ M. Geier et al. (2017), +// //! DOI:10.1016/j.jcp.2017.05.040 ]</b></a> +// //! +// wadjust = Oxyz + (c1o1 - Oxyz) * abs(mfbbb) / (abs(mfbbb) + qudricLimitD); +// mfbbb += wadjust * (-mfbbb); +// wadjust = OxyyPxzz + (c1o1 - OxyyPxzz) * abs(mxxyPyzz) / (abs(mxxyPyzz) + qudricLimitP); +// mxxyPyzz += wadjust * (-mxxyPyzz); +// wadjust = OxyyMxzz + (c1o1 - OxyyMxzz) * abs(mxxyMyzz) / (abs(mxxyMyzz) + qudricLimitM); +// mxxyMyzz += wadjust * (-mxxyMyzz); +// wadjust = OxyyPxzz + (c1o1 - OxyyPxzz) * abs(mxxzPyyz) / (abs(mxxzPyyz) + qudricLimitP); +// mxxzPyyz += wadjust * (-mxxzPyyz); +// wadjust = OxyyMxzz + (c1o1 - OxyyMxzz) * abs(mxxzMyyz) / (abs(mxxzMyyz) + qudricLimitM); +// mxxzMyyz += wadjust * (-mxxzMyyz); +// wadjust = OxyyPxzz + (c1o1 - OxyyPxzz) * abs(mxyyPxzz) / (abs(mxyyPxzz) + qudricLimitP); +// mxyyPxzz += wadjust * (-mxyyPxzz); +// wadjust = OxyyMxzz + (c1o1 - OxyyMxzz) * abs(mxyyMxzz) / (abs(mxyyMxzz) + qudricLimitM); +// mxyyMxzz += wadjust * (-mxyyMxzz); +// ////////////////////////////////////////////////////////////////////////// +// // no limiter +// // mfbbb += OxyyMxzz * (-mfbbb); +// // mxxyPyzz += OxyyPxzz * (-mxxyPyzz); +// // mxxyMyzz += OxyyMxzz * (-mxxyMyzz); +// // mxxzPyyz += OxyyPxzz * (-mxxzPyyz); +// // mxxzMyyz += OxyyMxzz * (-mxxzMyyz); +// // mxyyPxzz += OxyyPxzz * (-mxyyPxzz); +// // mxyyMxzz += OxyyMxzz * (-mxyyMxzz); + +// //////////////////////////////////////////////////////////////////////////////////// +// //! - Compute inverse linear combinations of second and third order cumulants +// //! +// mfcaa = c1o3 * (mxxMyy + mxxMzz + mxxPyyPzz); +// mfaca = c1o3 * (-c2o1 * mxxMyy + mxxMzz + mxxPyyPzz); +// mfaac = c1o3 * (mxxMyy - c2o1 * mxxMzz + mxxPyyPzz); + +// mfcba = (mxxyMyzz + mxxyPyzz) * c1o2; +// mfabc = (-mxxyMyzz + mxxyPyzz) * c1o2; +// mfcab = (mxxzMyyz + mxxzPyyz) * c1o2; +// mfacb = (-mxxzMyyz + mxxzPyyz) * c1o2; +// mfbca = (mxyyMxzz + mxyyPxzz) * c1o2; +// mfbac = (-mxyyMxzz + mxyyPxzz) * c1o2; +// ////////////////////////////////////////////////////////////////////////// + +// ////////////////////////////////////////////////////////////////////////// +// // 4. +// // no limiter +// //! - Relax fourth order cumulants to modified equilibrium for fourth order convergence of diffusion according +// //! to Eq. (43)-(48) <a href="https://doi.org/10.1016/j.jcp.2017.05.040"><b>[ M. Geier et al. (2017), +// //! DOI:10.1016/j.jcp.2017.05.040 ]</b></a> +// //! +// CUMacc = -O4 * (c1o1 / omega - c1o2) * (dyuy + dzuz) * c2o3 * A + (c1o1 - O4) * (CUMacc); +// CUMcac = -O4 * (c1o1 / omega - c1o2) * (dxux + dzuz) * c2o3 * A + (c1o1 - O4) * (CUMcac); +// CUMcca = -O4 * (c1o1 / omega - c1o2) * (dyuy + dxux) * c2o3 * A + (c1o1 - O4) * (CUMcca); +// CUMbbc = -O4 * (c1o1 / omega - c1o2) * Dxy * c1o3 * B + (c1o1 - O4) * (CUMbbc); +// CUMbcb = -O4 * (c1o1 / omega - c1o2) * Dxz * c1o3 * B + (c1o1 - O4) * (CUMbcb); +// CUMcbb = -O4 * (c1o1 / omega - c1o2) * Dyz * c1o3 * B + (c1o1 - O4) * (CUMcbb); + +// ////////////////////////////////////////////////////////////////////////// +// // 5. +// CUMbcc += O5 * (-CUMbcc); +// CUMcbc += O5 * (-CUMcbc); +// CUMccb += O5 * (-CUMccb); + +// ////////////////////////////////////////////////////////////////////////// +// // 6. +// CUMccc += O6 * (-CUMccc); + +// //////////////////////////////////////////////////////////////////////////////////// +// //! - Compute central moments from post collision cumulants according to Eq. (53)-(56) in +// //! <a href="https://doi.org/10.1016/j.jcp.2017.05.040"><b>[ M. Geier et al. (2017), +// //! DOI:10.1016/j.jcp.2017.05.040 ]</b></a> +// //! + +// ////////////////////////////////////////////////////////////////////////// +// // 4. +// mfcbb = CUMcbb + c1o3 * ((c3o1 * mfcaa + c1o1) * mfabb + c6o1 * mfbba * mfbab) * OOrho; +// mfbcb = CUMbcb + c1o3 * ((c3o1 * mfaca + c1o1) * mfbab + c6o1 * mfbba * mfabb) * OOrho; +// mfbbc = CUMbbc + c1o3 * ((c3o1 * mfaac + c1o1) * mfbba + c6o1 * mfbab * mfabb) * OOrho; + +// mfcca = +// CUMcca + +// (((mfcaa * mfaca + c2o1 * mfbba * mfbba) * c9o1 + c3o1 * (mfcaa + mfaca)) * OOrho - (drho * OOrho)) * c1o9; +// mfcac = +// CUMcac + +// (((mfcaa * mfaac + c2o1 * mfbab * mfbab) * c9o1 + c3o1 * (mfcaa + mfaac)) * OOrho - (drho * OOrho)) * c1o9; +// mfacc = +// CUMacc + +// (((mfaac * mfaca + c2o1 * mfabb * mfabb) * c9o1 + c3o1 * (mfaac + mfaca)) * OOrho - (drho * OOrho)) * c1o9; + +// ////////////////////////////////////////////////////////////////////////// +// // 5. +// mfbcc = CUMbcc + c1o3 * +// (c3o1 * (mfaac * mfbca + mfaca * mfbac + c4o1 * mfabb * mfbbb + +// c2o1 * (mfbab * mfacb + mfbba * mfabc)) + +// (mfbca + mfbac)) * +// OOrho; +// mfcbc = CUMcbc + c1o3 * +// (c3o1 * (mfaac * mfcba + mfcaa * mfabc + c4o1 * mfbab * mfbbb + +// c2o1 * (mfabb * mfcab + mfbba * mfbac)) + +// (mfcba + mfabc)) * +// OOrho; +// mfccb = CUMccb + c1o3 * +// (c3o1 * (mfcaa * mfacb + mfaca * mfcab + c4o1 * mfbba * mfbbb + +// c2o1 * (mfbab * mfbca + mfabb * mfcba)) + +// (mfacb + mfcab)) * +// OOrho; + +// ////////////////////////////////////////////////////////////////////////// +// // 6. +// mfccc = CUMccc - ((-c4o1 * mfbbb * mfbbb - (mfcaa * mfacc + mfaca * mfcac + mfaac * mfcca) - +// c4o1 * (mfabb * mfcbb + mfbab * mfbcb + mfbba * mfbbc) - +// c2o1 * (mfbca * mfbac + mfcba * mfabc + mfcab * mfacb)) * +// OOrho + +// (c4o1 * (mfbab * mfbab * mfaca + mfabb * mfabb * mfcaa + mfbba * mfbba * mfaac) + +// c2o1 * (mfcaa * mfaca * mfaac) + c16o1 * mfbba * mfbab * mfabb) * +// OOrho * OOrho - +// c1o3 * (mfacc + mfcac + mfcca) * OOrho - c1o9 * (mfcaa + mfaca + mfaac) * OOrho + +// (c2o1 * (mfbab * mfbab + mfabb * mfabb + mfbba * mfbba) + +// (mfaac * mfaca + mfaac * mfcaa + mfaca * mfcaa) + c1o3 * (mfaac + mfaca + mfcaa)) * +// OOrho * OOrho * c2o3 + +// c1o27 * ((drho * drho - drho) * OOrho * OOrho)); + +// //////////////////////////////////////////////////////////////////////////////////// +// //! - Add acceleration (body force) to first order cumulants according to Eq. (85)-(87) in +// //! <a href="https://doi.org/10.1016/j.camwa.2015.05.001"><b>[ M. Geier et al. (2015), +// //! DOI:10.1016/j.camwa.2015.05.001 ]</b></a> +// //! +// mfbaa = -mfbaa; +// mfaba = -mfaba; +// mfaab = -mfaab; + + +// //Write to array here to distribute read/write +// rho[k] = drho; +// vx[k] = vvx; +// vy[k] = vvy; +// vz[k] = vvz; + +// //////////////////////////////////////////////////////////////////////////////////// +// //! - Chimera transform from central moments to well conditioned distributions as defined in Appendix J in +// //! <a href="https://doi.org/10.1016/j.camwa.2015.05.001"><b>[ M. Geier et al. (2015), +// //! DOI:10.1016/j.camwa.2015.05.001 ]</b></a> see also Eq. (88)-(96) in <a +// //! href="https://doi.org/10.1016/j.jcp.2017.05.040"><b>[ M. Geier et al. (2017), DOI:10.1016/j.jcp.2017.05.040 +// //! ]</b></a> +// //! +// //////////////////////////////////////////////////////////////////////////////////// +// // X - Dir +// backwardInverseChimeraWithK(mfaaa, mfbaa, mfcaa, vvx, vx2, c1o1, c1o1); +// backwardChimera(mfaba, mfbba, mfcba, vvx, vx2); +// backwardInverseChimeraWithK(mfaca, mfbca, mfcca, vvx, vx2, c3o1, c1o3); +// backwardChimera(mfaab, mfbab, mfcab, vvx, vx2); +// backwardChimera(mfabb, mfbbb, mfcbb, vvx, vx2); +// backwardChimera(mfacb, mfbcb, mfccb, vvx, vx2); +// backwardInverseChimeraWithK(mfaac, mfbac, mfcac, vvx, vx2, c3o1, c1o3); +// backwardChimera(mfabc, mfbbc, mfcbc, vvx, vx2); +// backwardInverseChimeraWithK(mfacc, mfbcc, mfccc, vvx, vx2, c9o1, c1o9); + +// //////////////////////////////////////////////////////////////////////////////////// +// // Y - Dir +// backwardInverseChimeraWithK(mfaaa, mfaba, mfaca, vvy, vy2, c6o1, c1o6); +// backwardChimera(mfaab, mfabb, mfacb, vvy, vy2); +// backwardInverseChimeraWithK(mfaac, mfabc, mfacc, vvy, vy2, c18o1, c1o18); +// backwardInverseChimeraWithK(mfbaa, mfbba, mfbca, vvy, vy2, c3o2, c2o3); +// backwardChimera(mfbab, mfbbb, mfbcb, vvy, vy2); +// backwardInverseChimeraWithK(mfbac, mfbbc, mfbcc, vvy, vy2, c9o2, c2o9); +// backwardInverseChimeraWithK(mfcaa, mfcba, mfcca, vvy, vy2, c6o1, c1o6); +// backwardChimera(mfcab, mfcbb, mfccb, vvy, vy2); +// backwardInverseChimeraWithK(mfcac, mfcbc, mfccc, vvy, vy2, c18o1, c1o18); + +// //////////////////////////////////////////////////////////////////////////////////// +// // Z - Dir +// backwardInverseChimeraWithK(mfaaa, mfaab, mfaac, vvz, vz2, c36o1, c1o36); +// backwardInverseChimeraWithK(mfaba, mfabb, mfabc, vvz, vz2, c9o1, c1o9); +// backwardInverseChimeraWithK(mfaca, mfacb, mfacc, vvz, vz2, c36o1, c1o36); +// backwardInverseChimeraWithK(mfbaa, mfbab, mfbac, vvz, vz2, c9o1, c1o9); +// backwardInverseChimeraWithK(mfbba, mfbbb, mfbbc, vvz, vz2, c9o4, c4o9); +// backwardInverseChimeraWithK(mfbca, mfbcb, mfbcc, vvz, vz2, c9o1, c1o9); +// backwardInverseChimeraWithK(mfcaa, mfcab, mfcac, vvz, vz2, c36o1, c1o36); +// backwardInverseChimeraWithK(mfcba, mfcbb, mfcbc, vvz, vz2, c9o1, c1o9); +// backwardInverseChimeraWithK(mfcca, mfccb, mfccc, vvz, vz2, c36o1, c1o36); + +// //////////////////////////////////////////////////////////////////////////////////// +// //! - Write distributions: style of reading and writing the distributions from/to +// //! stored arrays dependent on timestep is based on the esoteric twist algorithm +// //! <a href="https://doi.org/10.3390/computation5020019"><b>[ M. Geier et al. (2017), +// //! DOI:10.3390/computation5020019 ]</b></a> +// //! + + +// distr_wrapper.distribution.f[dirE] = mfabb; +// distr_wrapper.distribution.f[dirW] = mfcbb; +// distr_wrapper.distribution.f[dirN] = mfbab; +// distr_wrapper.distribution.f[dirS] = mfbcb; +// distr_wrapper.distribution.f[dirT] = mfbba; +// distr_wrapper.distribution.f[dirB] = mfbbc; +// distr_wrapper.distribution.f[dirNE] = mfaab; +// distr_wrapper.distribution.f[dirSW] = mfccb; +// distr_wrapper.distribution.f[dirSE] = mfacb; +// distr_wrapper.distribution.f[dirNW] = mfcab; +// distr_wrapper.distribution.f[dirTE] = mfaba; +// distr_wrapper.distribution.f[dirBW] = mfcbc; +// distr_wrapper.distribution.f[dirBE] = mfabc; +// distr_wrapper.distribution.f[dirTW] = mfcba; +// distr_wrapper.distribution.f[dirTN] = mfbaa; +// distr_wrapper.distribution.f[dirBS] = mfbcc; +// distr_wrapper.distribution.f[dirBN] = mfbac; +// distr_wrapper.distribution.f[dirTS] = mfbca; +// distr_wrapper.distribution.f[dirZERO] = mfbbb; +// distr_wrapper.distribution.f[dirTNE] = mfaaa; +// distr_wrapper.distribution.f[dirTSW] = mfaca; +// distr_wrapper.distribution.f[dirTSE] = mfaac; +// distr_wrapper.distribution.f[dirTNW] = mfacc; +// distr_wrapper.distribution.f[dirBNE] = mfcaa; +// distr_wrapper.distribution.f[dirBSW] = mfcca; +// distr_wrapper.distribution.f[dirBSE] = mfcac; +// distr_wrapper.distribution.f[dirBNW] = mfccc; + +// distr_wrapper.write(); +// if(k==100000) +// { +// printf("mfcbb \t %f \t %f\t %f\t %f\t %f\t %f\t %f\t %f\t %f\t %f\t %f\t %f\t %f\t %f\t %f\t %f\t %f\t %f\t %f\t %f\t %f\t %f\t %f\t %f\t %f\t %f\t %f \n\n", +// (dist.f[dirE])[k] , +// (dist.f[dirN])[k] , +// (dist.f[dirS])[ks] , +// (dist.f[dirT])[k] , +// (dist.f[dirB])[kb] , +// (dist.f[dirNE])[k] , +// (dist.f[dirSW])[ksw] , +// (dist.f[dirSE])[ks] , +// (dist.f[dirNW])[kw] , +// (dist.f[dirW])[kw] , +// (dist.f[dirTE])[k] , +// (dist.f[dirBW])[kbw] , +// (dist.f[dirBE])[kb] , +// (dist.f[dirTW])[kw] , +// (dist.f[dirTN])[k] , +// (dist.f[dirBS])[kbs] , +// (dist.f[dirBN])[kb] , +// (dist.f[dirTS])[ks] , +// (dist.f[dirZERO])[k] , +// (dist.f[dirTNE])[k] , +// (dist.f[dirTSE])[ks] , +// (dist.f[dirBNE])[kb] , +// (dist.f[dirBSE])[kbs] , +// (dist.f[dirTNW])[kw] , +// (dist.f[dirTSW])[ksw] , +// (dist.f[dirBNW])[kbw] , +// (dist.f[dirBSW])[kbsw]); +// } + +// (dist.f[dirE])[k] = mfabb; +// (dist.f[dirW])[kw] = mfcbb; +// (dist.f[dirN])[k] = mfbab; +// (dist.f[dirS])[ks] = mfbcb; +// (dist.f[dirT])[k] = mfbba; +// (dist.f[dirB])[kb] = mfbbc; +// (dist.f[dirNE])[k] = mfaab; +// (dist.f[dirSW])[ksw] = mfccb; +// (dist.f[dirSE])[ks] = mfacb; +// (dist.f[dirNW])[kw] = mfcab; +// (dist.f[dirTE])[k] = mfaba; +// (dist.f[dirBW])[kbw] = mfcbc; +// (dist.f[dirBE])[kb] = mfabc; +// (dist.f[dirTW])[kw] = mfcba; +// (dist.f[dirTN])[k] = mfbaa; +// (dist.f[dirBS])[kbs] = mfbcc; +// (dist.f[dirBN])[kb] = mfbac; +// (dist.f[dirTS])[ks] = mfbca; +// (dist.f[dirZERO])[k] = mfbbb; +// (dist.f[dirTNE])[k] = mfaaa; +// (dist.f[dirTSE])[ks] = mfaca; +// (dist.f[dirBNE])[kb] = mfaac; +// (dist.f[dirBSE])[kbs] = mfacc; +// (dist.f[dirTNW])[kw] = mfcaa; +// (dist.f[dirTSW])[ksw] = mfcca; +// (dist.f[dirBNW])[kbw] = mfcac; +// (dist.f[dirBSW])[kbsw] = mfccc; + +// if(k==100000) +// { +// printf("mfcbb \t %f \t %f\t %f\t %f\t %f\t %f\t %f\t %f\t %f\t %f\t %f\t %f\t %f\t %f\t %f\t %f\t %f\t %f\t %f\t %f\t %f\t %f\t %f\t %f\t %f\t %f\t %f \n\n\n", +// (dist.f[dirE])[k] , +// (dist.f[dirN])[k] , +// (dist.f[dirS])[ks] , +// (dist.f[dirT])[k] , +// (dist.f[dirB])[kb] , +// (dist.f[dirNE])[k] , +// (dist.f[dirSW])[ksw] , +// (dist.f[dirSE])[ks] , +// (dist.f[dirNW])[kw] , +// (dist.f[dirW])[kw] , +// (dist.f[dirTE])[k] , +// (dist.f[dirBW])[kbw] , +// (dist.f[dirBE])[kb] , +// (dist.f[dirTW])[kw] , +// (dist.f[dirTN])[k] , +// (dist.f[dirBS])[kbs] , +// (dist.f[dirBN])[kb] , +// (dist.f[dirTS])[ks] , +// (dist.f[dirZERO])[k] , +// (dist.f[dirTNE])[k] , +// (dist.f[dirTSE])[ks] , +// (dist.f[dirBNE])[kb] , +// (dist.f[dirBSE])[kbs] , +// (dist.f[dirTNW])[kw] , +// (dist.f[dirTSW])[ksw] , +// (dist.f[dirBNW])[kbw] , +// (dist.f[dirBSW])[kbsw]); +// } +// } +// } \ No newline at end of file diff --git a/src/gpu/VirtualFluids_GPU/Kernel/Kernels/TurbulentViscosityKernels/FluidFlow/Compressible/CumulantK17chim/TurbulentViscosityCumulantK17CompChim_Device.cuh b/src/gpu/VirtualFluids_GPU/Kernel/Kernels/TurbulentViscosityKernels/FluidFlow/Compressible/CumulantK17chim/TurbulentViscosityCumulantK17CompChim_Device.cuh new file mode 100644 index 0000000000000000000000000000000000000000..7f6738a9b6e39d63775a6490c1248f020fb4ccca --- /dev/null +++ b/src/gpu/VirtualFluids_GPU/Kernel/Kernels/TurbulentViscosityKernels/FluidFlow/Compressible/CumulantK17chim/TurbulentViscosityCumulantK17CompChim_Device.cuh @@ -0,0 +1,28 @@ +#ifndef LB_Kernel_TURBULENT_VISCOSITY_CUMULANT_K17_COMP_CHIM_H +#define LB_Kernel_TURBULENT_VISCOSITY_CUMULANT_K17_COMP_CHIM_H + +#include <DataTypes.h> +#include <curand.h> + +extern "C" __global__ void LB_Kernel_TurbulentViscosityCumulantK17CompChim( + real omega_in, + uint* typeOfGridNode, + uint* neighborX, + uint* neighborY, + uint* neighborZ, + real* distributions, + real* rho, + real* vx, + real* vy, + real* vz, + real* turbulentViscosity, + unsigned long size_Mat, + int level, + bool bodyForce, + real* forces, + real* bodyForceX, + real* bodyForceY, + real* bodyForceZ, + real* quadricLimiters, + bool isEvenTimestep); +#endif diff --git a/src/gpu/VirtualFluids_GPU/Kernel/Kernels/TurbulentViscosityKernels/FluidFlow/Compressible/TurbulentViscosityFluidFlowCompStrategy.cpp b/src/gpu/VirtualFluids_GPU/Kernel/Kernels/TurbulentViscosityKernels/FluidFlow/Compressible/TurbulentViscosityFluidFlowCompStrategy.cpp new file mode 100644 index 0000000000000000000000000000000000000000..f3615a89994f0ca1fafdc1eda905d3c3b615d478 --- /dev/null +++ b/src/gpu/VirtualFluids_GPU/Kernel/Kernels/TurbulentViscosityKernels/FluidFlow/Compressible/TurbulentViscosityFluidFlowCompStrategy.cpp @@ -0,0 +1,23 @@ +#include "TurbulentViscosityFluidFlowCompStrategy.h" + +#include "Parameter/Parameter.h" + +std::shared_ptr<TurbulentViscosityFluidFlowCompStrategy> TurbulentViscosityFluidFlowCompStrategy::getInstance() +{ + static std::shared_ptr<TurbulentViscosityFluidFlowCompStrategy> uniqueInstance; + if (!uniqueInstance) + uniqueInstance = std::shared_ptr<TurbulentViscosityFluidFlowCompStrategy>(new TurbulentViscosityFluidFlowCompStrategy()); + return uniqueInstance; +} + +bool TurbulentViscosityFluidFlowCompStrategy::checkParameter(std::shared_ptr<Parameter> para) +{ + if (!para->getUseTurbulentViscosity()) + return false; + else if (!para->getCompOn()) + return false; + else + return true; +} + +TurbulentViscosityFluidFlowCompStrategy::TurbulentViscosityFluidFlowCompStrategy() {} diff --git a/src/gpu/VirtualFluids_GPU/Kernel/Kernels/TurbulentViscosityKernels/FluidFlow/Compressible/TurbulentViscosityFluidFlowCompStrategy.h b/src/gpu/VirtualFluids_GPU/Kernel/Kernels/TurbulentViscosityKernels/FluidFlow/Compressible/TurbulentViscosityFluidFlowCompStrategy.h new file mode 100644 index 0000000000000000000000000000000000000000..95eff17777f7f0d1c3e05fe1b0d93892a88646a4 --- /dev/null +++ b/src/gpu/VirtualFluids_GPU/Kernel/Kernels/TurbulentViscosityKernels/FluidFlow/Compressible/TurbulentViscosityFluidFlowCompStrategy.h @@ -0,0 +1,18 @@ +#ifndef AMD_FLUID_FLOW_COMP_STRATEGY_H +#define AMD_FLUID_FLOW_COMP_STRATEGY_H + +#include "Kernel/Utilities/CheckParameterStrategy/CheckParameterStrategy.h" + + +class TurbulentViscosityFluidFlowCompStrategy : public CheckParameterStrategy +{ +public: + static std::shared_ptr<TurbulentViscosityFluidFlowCompStrategy> getInstance(); + + bool checkParameter(std::shared_ptr<Parameter> para); + +private: + TurbulentViscosityFluidFlowCompStrategy(); + +}; +#endif \ No newline at end of file diff --git a/src/gpu/VirtualFluids_GPU/Kernel/Utilities/CudaGrid.cpp b/src/gpu/VirtualFluids_GPU/Kernel/Utilities/CudaGrid.cpp deleted file mode 100644 index fa17bf449915eba509dbabbe71f556c19fa43bcf..0000000000000000000000000000000000000000 --- a/src/gpu/VirtualFluids_GPU/Kernel/Utilities/CudaGrid.cpp +++ /dev/null @@ -1,27 +0,0 @@ -#include "CudaGrid.h" - - - -namespace vf -{ -namespace gpu -{ - -CudaGrid::CudaGrid(unsigned int numberOfThreads, unsigned int size_matrix) -{ - int Grid = (size_matrix / numberOfThreads) + 1; - int Grid1, Grid2; - if (Grid > 512) { - Grid1 = 512; - Grid2 = (Grid / Grid1) + 1; - } else { - Grid1 = 1; - Grid2 = Grid; - } - - grid = dim3(Grid1, Grid2); - threads = dim3(numberOfThreads, 1, 1); -} - -} -} diff --git a/src/gpu/VirtualFluids_GPU/Kernel/Utilities/CudaGrid.h b/src/gpu/VirtualFluids_GPU/Kernel/Utilities/CudaGrid.h deleted file mode 100644 index 27a18a58843b0de064009ab0f837518e3bb44b9d..0000000000000000000000000000000000000000 --- a/src/gpu/VirtualFluids_GPU/Kernel/Utilities/CudaGrid.h +++ /dev/null @@ -1,25 +0,0 @@ -#ifndef GPU_CUDA_GRID_H -#define GPU_CUDA_GRID_H - - -#include <cuda_runtime.h> - -namespace vf -{ -namespace gpu -{ - - -struct CudaGrid -{ - dim3 threads; - dim3 grid; - - CudaGrid(unsigned int numberOfEntities, unsigned int threadsPerBlock); - CudaGrid() = default; -}; - -} -} - -#endif \ No newline at end of file diff --git a/src/gpu/VirtualFluids_GPU/Kernel/Utilities/KernelFactory/KernelFactoryImp.cpp b/src/gpu/VirtualFluids_GPU/Kernel/Utilities/KernelFactory/KernelFactoryImp.cpp index a293e24f7d813338280d24781d7421df23c7403c..6e9688f5724e347df53397eb3880b3758c236730 100644 --- a/src/gpu/VirtualFluids_GPU/Kernel/Utilities/KernelFactory/KernelFactoryImp.cpp +++ b/src/gpu/VirtualFluids_GPU/Kernel/Utilities/KernelFactory/KernelFactoryImp.cpp @@ -48,6 +48,9 @@ #include "Kernel/Kernels/WaleKernels/FluidFlow/Compressible/CumulantK15/WaleCumulantK15Comp.h" #include "Kernel/Kernels/WaleKernels/FluidFlow/Compressible/CumulantK15BySoniMalav/WaleBySoniMalavCumulantK15Comp.h" +//turbulent viscosity kernel +#include "Kernel/Kernels/TurbulentViscosityKernels/FluidFlow/Compressible/CumulantK17chim/TurbulentViscosityCumulantK17CompChim.h" + //strategies #include "Kernel/Kernels/BasicKernels/FluidFlow/Compressible/FluidFlowCompStrategy.h" #include "Kernel/Kernels/BasicKernels/FluidFlow/Incompressible/FluidFlowIncompStrategy.h" @@ -57,7 +60,7 @@ #include "Kernel/Kernels/BasicKernels/AdvectionDiffusion/Incompressible/Mod7/ADMod7IncompStrategy.h" #include "Kernel/Kernels/PorousMediaKernels/FluidFlow/Compressible/PMFluidFlowCompStrategy.h" #include "Kernel/Kernels/WaleKernels/FluidFlow/Compressible/WaleFluidFlowCompStrategy.h" - +#include "Kernel/Kernels/TurbulentViscosityKernels/FluidFlow/Compressible/TurbulentViscosityFluidFlowCompStrategy.h" std::shared_ptr<KernelFactoryImp> KernelFactoryImp::getInstance() { @@ -198,6 +201,10 @@ std::shared_ptr<Kernel> KernelFactoryImp::makeKernel(std::shared_ptr<Parameter> newKernel = WaleBySoniMalavCumulantK15Comp::getNewInstance(para, level);// || checkStrategy = WaleFluidFlowCompStrategy::getInstance(); // wale model } //=============== + else if (kernel == "TurbulentViscosityCumulantK17CompChim"){ // AMD model + newKernel = TurbulentViscosityCumulantK17CompChim::getNewInstance(para, level); // || + checkStrategy = TurbulentViscosityFluidFlowCompStrategy::getInstance(); // \/ + } else { throw std::runtime_error("KernelFactory does not know the KernelType."); } diff --git a/src/gpu/VirtualFluids_GPU/LBM/LB.h b/src/gpu/VirtualFluids_GPU/LBM/LB.h index a33b3b792cd451307825fd0b2c8716e942440582..17404fb959849663130c7de2a86764f198b9c32e 100644 --- a/src/gpu/VirtualFluids_GPU/LBM/LB.h +++ b/src/gpu/VirtualFluids_GPU/LBM/LB.h @@ -120,9 +120,13 @@ struct InitCondition bool calcMedian {false}; bool isConc {false}; bool isWale {false}; + bool isTurbulentViscosity {false}; + bool isAMD {false}; + real SGSConstant {0.0}; bool isMeasurePoints {false}; bool isInitNeq {false}; bool isGeoNormal, isInflowNormal, isOutflowNormal; + bool hasWallModelMonitor {false}; bool simulatePorousMedia {false}; bool streetVelocityFile {false}; }; @@ -183,7 +187,10 @@ typedef struct QforBC{ real* q19[19]; int kQ=0; int kArray; - real *Vx, *Vy, *Vz, *deltaVz, *RhoBC; + real *Vx, *Vy, *Vz; + real *Vx1, *Vy1, *Vz1; + real *deltaVz, *RhoBC; + real *normalX, *normalY, *normalZ; }QforBoundaryConditions; //BCTemp @@ -210,6 +217,17 @@ typedef struct TempPressforBC{ int kTemp=0; }TempPressforBoundaryConditions; +// Settings for wall model used in StressBC +typedef struct WMparas{ + real* z0; + int* samplingOffset; + bool hasMonitor; + real* u_star; + real* Fx; + real* Fy; + real* Fz; +}WallModelParameters; + //measurePoints typedef struct MeasP{ std::string name; diff --git a/src/gpu/VirtualFluids_GPU/LBM/Simulation.cpp b/src/gpu/VirtualFluids_GPU/LBM/Simulation.cpp index baf268b25e02e86522df749d4820a4e36ee0b99b..4f8c297c01062efcdee3c6857b1bb71cd11301af 100644 --- a/src/gpu/VirtualFluids_GPU/LBM/Simulation.cpp +++ b/src/gpu/VirtualFluids_GPU/LBM/Simulation.cpp @@ -11,7 +11,6 @@ #include "Parameter/Parameter.h" #include "Parameter/CudaStreamManager.h" #include "GPU/GPU_Interface.h" -#include "GPU/devCheck.h" #include "basics/utilities/UbFileOutputASCII.h" ////////////////////////////////////////////////////////////////////////// #include "Output/MeasurePointWriter.hpp" @@ -41,6 +40,8 @@ #include "Calculation/ForceCalculations.h" #include "Calculation/PorousMedia.h" ////////////////////////////////////////////////////////////////////////// +#include "Output/Timer.h" +////////////////////////////////////////////////////////////////////////// #include "Restart/RestartObject.h" ////////////////////////////////////////////////////////////////////////// #include "DataStructureInitializer/GridProvider.h" @@ -49,7 +50,15 @@ #include "PreProcessor/PreProcessorFactory/PreProcessorFactory.h" #include "Kernel/Kernel.h" +#include <cuda/DeviceInfo.h> + +#include <logger/Logger.h> + + +Simulation::Simulation(vf::gpu::Communicator& communicator) : communicator(communicator) +{ +} std::string getFileName(const std::string& fname, int step, int myID) { @@ -80,10 +89,9 @@ void Simulation::init(SPtr<Parameter> para, SPtr<GridProvider> gridProvider, std this->gridProvider = gridProvider; this->cudaManager = cudaManager; gridProvider->initalGridInformations(); - comm = vf::gpu::Communicator::getInstanz(); this->para = para; - devCheck(comm->mapCudaDevice(para->getMyID(), para->getNumprocs(), para->getDevices(), para->getMaxDev())); + vf::cuda::verifyAndSetDevice(communicator.mapCudaDevice(para->getMyID(), para->getNumprocs(), para->getDevices(), para->getMaxDev())); para->initLBMSimulationParameter(); @@ -135,6 +143,11 @@ void Simulation::init(SPtr<Parameter> para, SPtr<GridProvider> gridProvider, std output << "vis_ratio: " << para->getViscosityRatio() << "\n"; output << "u0_ratio: " << para->getVelocityRatio() << "\n"; output << "delta_rho: " << para->getDensityRatio() << "\n"; + output << "QuadricLimiters: " << para->getQuadricLimitersHost()[0] << "\t" + << para->getQuadricLimitersHost()[1] << "\t" + << para->getQuadricLimitersHost()[2] << "\n"; + if(para->getUseAMD()) + output << "AMD SGS model: " << para->getSGSConstant() << "\n"; ////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////// @@ -142,6 +155,14 @@ void Simulation::init(SPtr<Parameter> para, SPtr<GridProvider> gridProvider, std ////////////////////////////////////////////////////////////////////////// allocNeighborsOffsetsScalesAndBoundaries(gridProvider); + for( SPtr<PreCollisionInteractor> actuator: para->getActuators()){ + actuator->init(para.get(), gridProvider.get(), cudaManager.get()); + } + + for( SPtr<PreCollisionInteractor> probe: para->getProbes()){ + probe->init(para.get(), gridProvider.get(), cudaManager.get()); + } + ////////////////////////////////////////////////////////////////////////// //Kernel init ////////////////////////////////////////////////////////////////////////// @@ -267,7 +288,7 @@ void Simulation::init(SPtr<Parameter> para, SPtr<GridProvider> gridProvider, std ////////////////////////////////////////////////////////////////////////// //output << "define the Grid..." ; - //defineGrid(para, comm); + //defineGrid(para, communicator); ////allocateMemory(); //output << "done.\n"; @@ -416,15 +437,10 @@ void Simulation::bulk() void Simulation::run() { - double ftimeE, ftimeS, fnups, durchsatz; - float timerE, timerS; - timerE = 0.0f; - timerS = 0.0f; - ftimeE = 0.0f; - ftimeS = 0.0f; unsigned int t, t_prev; uint t_turbulenceIntensity = 0; unsigned int t_MP = 0; + ////////////////////////////////////////////////////////////////////////// para->setStepEnsight(0); @@ -442,21 +458,13 @@ void Simulation::run() } ////////////////////////////////////////////////////////////////////////// - //Timer SDK - StopWatchInterface *sdkTimer = NULL; - sdkCreateTimer(&sdkTimer); - sdkStartTimer(&sdkTimer); - //Timer Event - cudaEvent_t start_t, stop_t; - checkCudaErrors( cudaEventCreate(&start_t)); - checkCudaErrors( cudaEventCreate(&stop_t)); - checkCudaErrors( cudaEventRecord(start_t)); - t_prev = para->getTimeCalcMedStart(); - output << "Processing time (ms) \t Nups in Mio \t Durchsatz in GB/sec\n"; + output << "getMaxLevel = " << para->getMaxLevel() << "\n"; + + Timer* averageTimer = new Timer("Average performance"); + averageTimer->startTimer(); - output << "getMaxLevel = " << para->getMaxLevel() << "\n"; //////////////////////////////////////////////////////////////////////////////// // Time loop //////////////////////////////////////////////////////////////////////////////// @@ -562,14 +570,8 @@ void Simulation::run() //////////////////////////////////////////////////////////////////////////////// if(para->getDoCheckPoint() && para->getTimeDoCheckPoint()>0 && t%para->getTimeDoCheckPoint()==0 && t>0 && !para->overWritingRestart(t)) { + averageTimer->stopTimer(); ////////////////////////////////////////////////////////////////////////// - //Timer SDK - sdkStopTimer(&sdkTimer); - sdkResetTimer(&sdkTimer); - ////////////////////////////////////////////////////////////////////////// - //Timer Event - checkCudaErrors( cudaEventRecord(stop_t)); - checkCudaErrors( cudaEventSynchronize(stop_t)); if( para->getDoCheckPoint() ) { @@ -588,11 +590,7 @@ void Simulation::run() output << "\n fertig\n"; } ////////////////////////////////////////////////////////////////////////// - //Timer SDK - sdkStartTimer(&sdkTimer); - ////////////////////////////////////////////////////////////////////////// - //Timer Event - checkCudaErrors( cudaEventRecord(start_t)); + averageTimer->startTimer(); } ////////////////////////////////////////////////////////////////////////////// @@ -634,7 +632,7 @@ void Simulation::run() { MeasurePointWriter::writeMeasurePoints(para.get(), lev, j, t); } - MeasurePointWriter::calcAndWriteMeanAndFluctuations(para.get(), lev, t, para->getTStartOut()); + //MeasurePointWriter::calcAndWriteMeanAndFluctuations(para.get(), lev, t, para->getTStartOut()); } t_MP = 0; } @@ -698,7 +696,7 @@ void Simulation::run() //////////////////////////////////////////////////////////////////////////////// // File IO //////////////////////////////////////////////////////////////////////////////// - //comm->startTimer(); + //communicator->startTimer(); if(para->getTOut()>0 && t%para->getTOut()==0 && t>para->getTStartOut()) { ////////////////////////////////////////////////////////////////////////////////// @@ -706,36 +704,10 @@ void Simulation::run() //else para->getParD(0)->evenOrOdd=true; ////////////////////////////////////////////////////////////////////////////////// - - ////////////////////////////////////////////////////////////////////////// - //Timer SDK - checkCudaErrors(cudaDeviceSynchronize()); - sdkStopTimer(&sdkTimer); - timerS = sdkGetTimerValue(&sdkTimer); - sdkResetTimer(&sdkTimer); - ftimeS += timerS; - fnups = 0.0; - durchsatz = 0.0; - for (int lev=para->getCoarse(); lev <= para->getFine(); lev++) - { - fnups += 1000.0 * (t-para->getTStart()) * para->getParH(lev)->size_Mat_SP * pow(2.,lev) / (ftimeS*1.0E6); - durchsatz += (27.0+1.0) * 4.0 * 1000.0 * (t-para->getTStart()) * para->getParH(lev)->size_Mat_SP / (ftimeS*1.0E9); - } - output << timerS << " / " << ftimeS << " \t " << fnups << " \t " << durchsatz << "\n"; - ////////////////////////////////////////////////////////////////////////// - //Timer Event - checkCudaErrors( cudaEventRecord(stop_t)); - checkCudaErrors( cudaEventSynchronize(stop_t)); - checkCudaErrors( cudaEventElapsedTime( &timerE, start_t, stop_t)); - ftimeE += timerE; - fnups = 0.0; - durchsatz = 0.0; - for (int lev=para->getCoarse(); lev <= para->getFine(); lev++) - { - fnups += 1000.0 * (t-para->getTStart()) * para->getParH(lev)->size_Mat_SP * pow(2.,lev) / (ftimeE*1.0E6); - durchsatz += (27.0+1.0) * 4.0 * 1000.0 * (t-para->getTStart()) * para->getParH(lev)->size_Mat_SP / (ftimeE*1.0E9); - } - output << timerE << " / " << ftimeE << " \t " << fnups << " \t " << durchsatz << "\n"; + ////////////////////////////////////////////////////////////////////////// + averageTimer->stopTimer(); + averageTimer->outputPerformance(t, para.get()); + ////////////////////////////////////////////////////////////////////////// if( para->getPrintFiles() ) { @@ -1019,45 +991,12 @@ void Simulation::run() output << "done.\n"; //////////////////////////////////////////////////////////////////////// } - sdkStartTimer(&sdkTimer); - checkCudaErrors( cudaEventRecord(start_t)); + + //////////////////////////////////////////////////////////////////////// + averageTimer->startTimer(); } } - - ////////////////////////////////////////////////////////////////////////// - //Timer SDK - sdkStopTimer(&sdkTimer); - timerS = sdkGetTimerValue(&sdkTimer); - ftimeS += timerS; - fnups = 0.0; - durchsatz = 0.0; - for (int lev=para->getCoarse(); lev <= para->getFine(); lev++) - { - fnups += 1000.0 * (t-para->getTStart()) * para->getParH(lev)->size_Mat_SP * pow(2.,lev) / (ftimeS*1.0E6); - durchsatz += (27.0+1.0) * 4.0 * 1000.0 * (t-para->getTStart()) * para->getParH(lev)->size_Mat_SP / (ftimeS*1.0E9); - } - output << "Processing time: " << ftimeS << "(ms)\n"; - output << "Nups in Mio: " << fnups << "\n"; - output << "Durchsatz in GB/sec: " << durchsatz << "\n"; - ////////////////////////////////////////////////////////////////////////// - //Timer Event - checkCudaErrors( cudaEventRecord(stop_t)); - checkCudaErrors( cudaEventSynchronize(stop_t)); - checkCudaErrors( cudaEventElapsedTime( &timerE, start_t, stop_t )); - ftimeE += timerE; - fnups = 0.0; - durchsatz = 0.0; - for (int lev=para->getCoarse(); lev <= para->getFine(); lev++) - { - fnups += 1000.0 * (t-para->getTStart()) * para->getParH(lev)->size_Mat_SP * pow(2.,lev) / (ftimeE*1.0E6); - durchsatz += (27.0+1.0) * 4.0 * 1000.0 * (t-para->getTStart()) * para->getParH(lev)->size_Mat_SP / (ftimeE*1.0E9); - } - output << "Processing time: " << ftimeE << "(ms)\n"; - output << "Nups in Mio: " << fnups << "\n"; - output << "Durchsatz in GB/sec: " << durchsatz << "\n"; - ////////////////////////////////////////////////////////////////////////// - ////////////////////////////////////////////////////////////////////////// // When using multiple GPUs, get Nups of all processes if (para->getMaxDev() > 1) { @@ -1071,7 +1010,6 @@ void Simulation::run() output << "Sum of all processes: Nups in Mio: " << sum << "\n"; } } - ////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// //printDragLift(para); @@ -1111,11 +1049,7 @@ void Simulation::run() // MeasurePointWriter::writeMeasurePoints(para, lev, j, 0); // } //} - // ////////////////////////////////////////////////////////////////////////// - - checkCudaErrors(cudaEventDestroy(start_t)); - checkCudaErrors(cudaEventDestroy(stop_t)); - sdkDeleteTimer(&sdkTimer); + // ////////////////////////////////////////////////////////////////////////// } void Simulation::porousMedia() @@ -1394,8 +1328,13 @@ void Simulation::free() // Turbulence Intensity if (para->getCalcTurbulenceIntensity()) { cudaFreeTurbulenceIntensityArrays(para.get(), cudaManager.get()); + //PreCollisionInteractors + for( SPtr<PreCollisionInteractor> actuator: para->getActuators()){ + actuator->free(para.get(), cudaManager.get()); } - delete comm; - -} \ No newline at end of file + for( SPtr<PreCollisionInteractor> probe: para->getProbes()){ + probe->free(para.get(), cudaManager.get()); + } + ////////////////////////////////////////////////////////////////////////// +} diff --git a/src/gpu/VirtualFluids_GPU/LBM/Simulation.h b/src/gpu/VirtualFluids_GPU/LBM/Simulation.h index f11212edaee93a7051887c43e3135b256b2f8a48..44da6df66ef4038da51193c11f421f90a7984200 100644 --- a/src/gpu/VirtualFluids_GPU/LBM/Simulation.h +++ b/src/gpu/VirtualFluids_GPU/LBM/Simulation.h @@ -13,13 +13,7 @@ #include "VirtualFluids_GPU_export.h" -namespace vf -{ -namespace gpu -{ -class Communicator; -} -} +namespace vf::gpu { class Communicator; } class CudaMemoryManager; class Parameter; @@ -39,6 +33,7 @@ class UpdateGrid27; class VIRTUALFLUIDS_GPU_EXPORT Simulation { public: + Simulation(vf::gpu::Communicator& communicator); void run(); void init(SPtr<Parameter> para, SPtr<GridProvider> gridProvider, std::shared_ptr<DataWriter> dataWriter, std::shared_ptr<CudaMemoryManager> cudaManager); @@ -70,7 +65,7 @@ protected: LogWriter output; - vf::gpu::Communicator* comm; + vf::gpu::Communicator& communicator; SPtr<Parameter> para; SPtr<GridProvider> gridProvider; SPtr<DataWriter> dataWriter; diff --git a/src/gpu/VirtualFluids_GPU/Output/TimeStepTimer.cpp b/src/gpu/VirtualFluids_GPU/Output/TimeStepTimer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..78da4947d0c8196cda49fef754a3f44fc39d0a44 --- /dev/null +++ b/src/gpu/VirtualFluids_GPU/Output/TimeStepTimer.cpp @@ -0,0 +1,64 @@ +#include "helper_cuda.h" +#include <cuda_runtime.h> +#include "Core/DataTypes.h" +#include "UbScheduler.h" +#include "Parameter/Parameter.h" + +#include "Timer.h" +#include "TimeStepTimer.h" + +void TimeStepTimer::startTotalTimer (uint t){ if(t%this->tActivate==0) this->totalTimer->startTimer(); } +void TimeStepTimer::stopTotalTimer (uint t){ if(t%this->tActivate==0) this->totalTimer->stopTimer(); } +void TimeStepTimer::startCollisionTimer (uint t){ if(t%this->tActivate==0) this->collisionTimer->startTimer(); } +void TimeStepTimer::stopCollisionTimer (uint t){ if(t%this->tActivate==0) this->collisionTimer->stopTimer(); } +void TimeStepTimer::startPostCollisionBCTimer (uint t){ if(t%this->tActivate==0) this->postCollisionBCTimer->startTimer(); } +void TimeStepTimer::stopPostCollisionBCTimer (uint t){ if(t%this->tActivate==0) this->postCollisionBCTimer->stopTimer(); } +void TimeStepTimer::startPreCollisionBCTimer (uint t){ if(t%this->tActivate==0) this->preCollisionBCTimer->startTimer(); } +void TimeStepTimer::stopPreCollisionBCTimer (uint t){ if(t%this->tActivate==0) this->preCollisionBCTimer->stopTimer(); } +void TimeStepTimer::startEddyViscosityTimer (uint t){ if(t%this->tActivate==0) this->eddyViscosityTimer->startTimer(); } +void TimeStepTimer::stopEddyViscosityTimer (uint t){ if(t%this->tActivate==0) this->eddyViscosityTimer->stopTimer(); } +void TimeStepTimer::startActuatorTimer (uint t){ if(t%this->tActivate==0) this->actuatorTimer->startTimer(); } +void TimeStepTimer::stopActuatorTimer (uint t){ if(t%this->tActivate==0) this->actuatorTimer->stopTimer(); } +void TimeStepTimer::startProbeTimer (uint t){ if(t%this->tActivate==0) this->probeTimer->startTimer(); } +void TimeStepTimer::stopProbeTimer (uint t){ if(t%this->tActivate==0) this->probeTimer->stopTimer(); } +void TimeStepTimer::startExchangeTimer (uint t){ if(t%this->tActivate==0) this->exchangeTimer->startTimer(); } +void TimeStepTimer::stopExchangeTimer (uint t){ if(t%this->tActivate==0) this->exchangeTimer->stopTimer(); } + + +void TimeStepTimer::resetTimers(uint t) +{ + if(t%this->tActivate==0) + { + this->totalTimer->resetTimer(); + this->collisionTimer->resetTimer(); + this->postCollisionBCTimer->resetTimer(); + this->preCollisionBCTimer->resetTimer(); + this->eddyViscosityTimer->resetTimer(); + this->actuatorTimer->resetTimer(); + this->probeTimer->resetTimer(); + } +} + +void TimeStepTimer::outputPerformance(uint t, Parameter* para) +{ + if(t%this->tActivate==0) + { + + float tCollision = this->collisionTimer->getTotalElapsedTime(); + float tPostCollisionBC = this->postCollisionBCTimer->getTotalElapsedTime(); + float tPreCollisionBC = this->preCollisionBCTimer->getTotalElapsedTime(); + float tEddyViscosity = this->eddyViscosityTimer->getTotalElapsedTime(); + float tAcutator = this->actuatorTimer->getTotalElapsedTime(); + float tProbe = this->probeTimer->getTotalElapsedTime(); + float tExchange = this->exchangeTimer->getTotalElapsedTime(); + float tTotal = tCollision+tPostCollisionBC+tPreCollisionBC+tEddyViscosity+tAcutator+tProbe+tExchange; + + VF_LOG_INFO(" --- Collision \t {}%", (tCollision/tTotal)*100 ); + VF_LOG_INFO(" --- PostCollisionBCs \t {}%", (tPostCollisionBC/tTotal)*100 ); + VF_LOG_INFO(" --- PreCollisionBCs \t {}%", (tPreCollisionBC/tTotal)*100 ); + VF_LOG_INFO(" --- Eddy viscosity \t {}%", (tEddyViscosity/tTotal)*100 ); + VF_LOG_INFO(" --- Actuators \t {}%", (tAcutator/tTotal)*100 ); + VF_LOG_INFO(" --- Probes \t\t {}%", (tProbe/tTotal)*100 ); + VF_LOG_INFO(" --- Data exchange \t {}%", (tExchange/tTotal)*100 ); + } +} \ No newline at end of file diff --git a/src/gpu/VirtualFluids_GPU/Output/TimeStepTimer.h b/src/gpu/VirtualFluids_GPU/Output/TimeStepTimer.h new file mode 100644 index 0000000000000000000000000000000000000000..982d1ce56bfadb7eddfd3d34d8d6b01ac6f92233 --- /dev/null +++ b/src/gpu/VirtualFluids_GPU/Output/TimeStepTimer.h @@ -0,0 +1,59 @@ +#ifndef TIMESTEPTIMER_H +#define TIMESTEPTIMER_H + +#include "helper_cuda.h" +#include <cuda_runtime.h> +#include "Core/DataTypes.h" +#include "UbScheduler.h" +#include "Parameter/Parameter.h" + +#include "Timer.h" + +class TimeStepTimer +{ + public: + TimeStepTimer(std::string _name, uint _tActivate): name(_name), tActivate(_tActivate) + { + + }; + + ~TimeStepTimer(){}; + + void startTotalTimer (uint t); + void stopTotalTimer (uint t); + void startCollisionTimer (uint t); + void stopCollisionTimer (uint t); + void startPostCollisionBCTimer (uint t); + void stopPostCollisionBCTimer (uint t); + void startPreCollisionBCTimer (uint t); + void stopPreCollisionBCTimer (uint t); + void startEddyViscosityTimer (uint t); + void stopEddyViscosityTimer (uint t); + void startActuatorTimer (uint t); + void stopActuatorTimer (uint t); + void startProbeTimer (uint t); + void stopProbeTimer (uint t); + void startExchangeTimer (uint t); + void stopExchangeTimer (uint t); + + void resetTimers(uint t); + void outputPerformance(uint t, Parameter* para); + + private: + + Timer* totalTimer = new Timer("total"); + Timer* collisionTimer = new Timer("collision"); + Timer* postCollisionBCTimer = new Timer("postCollisionBC"); + Timer* preCollisionBCTimer = new Timer("preCollisionBC"); + Timer* eddyViscosityTimer = new Timer("eddyViscosity"); + Timer* actuatorTimer = new Timer("actuator"); + Timer* probeTimer = new Timer("probes"); + Timer* exchangeTimer = new Timer("exchange"); + + std::string name; + uint tActivate; +}; + + + +#endif \ No newline at end of file diff --git a/src/gpu/VirtualFluids_GPU/Output/Timer.cpp b/src/gpu/VirtualFluids_GPU/Output/Timer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..823364a22eca41517816c1fdb61dfdc96ef1d961 --- /dev/null +++ b/src/gpu/VirtualFluids_GPU/Output/Timer.cpp @@ -0,0 +1,51 @@ + +#include <iostream> +#include <cuda_runtime.h> +#include "UbScheduler.h" +#include "Timer.h" + + +void Timer::initTimer() +{ + cudaEventCreate(&this->start_t); + cudaEventCreate(&this->stop_t ); +} + +void Timer::startTimer() +{ + checkCudaErrors(cudaEventRecord(this->start_t)); +} + +void Timer::stopTimer() +{ + checkCudaErrors(cudaEventRecord(this->stop_t)); + checkCudaErrors(cudaEventSynchronize(this->stop_t)); + checkCudaErrors(cudaEventElapsedTime(&this->elapsedTime, this->start_t, this->stop_t)); + this->totalElapsedTime += this->elapsedTime; +} + +void Timer::resetTimer() +{ + this->elapsedTime = 0.0; + this->totalElapsedTime = 0.0; +} + +void Timer::outputPerformance(uint t, Parameter* para) +{ + real fnups = 0.0; + real bandwidth = 0.0; + + for (int lev=para->getCoarse(); lev <= para->getFine(); lev++) + { + fnups += 1000.0 * (t-para->getTStart()) * para->getParH(lev)->size_Mat_SP * pow(2.,lev) / (this->totalElapsedTime*1.0E6); + bandwidth += (27.0+1.0) * 4.0 * 1000.0 * (t-para->getTStart()) * para->getParH(lev)->size_Mat_SP / (this->totalElapsedTime*1.0E9); + } + + if(this->firstOutput) + { + VF_LOG_INFO(" --- {} --- Processing time (ms) \t Nups in Mio \t Bandwidth in GB/sec", this->name ); + this->firstOutput = false; + } + + VF_LOG_INFO(" --- {} --- {}/{} \t {} \t {}", this->name, this->elapsedTime, this->totalElapsedTime, fnups, bandwidth ); +} \ No newline at end of file diff --git a/src/gpu/VirtualFluids_GPU/Output/Timer.h b/src/gpu/VirtualFluids_GPU/Output/Timer.h new file mode 100644 index 0000000000000000000000000000000000000000..6432b347458e68a5089aea3de625017d6facd34b --- /dev/null +++ b/src/gpu/VirtualFluids_GPU/Output/Timer.h @@ -0,0 +1,47 @@ +#ifndef TIMER_H +#define TIMER_H + +#include "helper_cuda.h" +#include <cuda_runtime.h> +#include "Core/DataTypes.h" + +#include "UbScheduler.h" +#include "logger/Logger.h" +#include "Parameter/Parameter.h" + +class Timer +{ + public: + Timer(std::string _name): name(_name) + { + this->initTimer(); + }; + + ~Timer() + { + cudaEventDestroy(this->start_t); + cudaEventDestroy(this->stop_t); + }; + + void initTimer(); + void startTimer(); + void stopTimer(); + void resetTimer(); + void outputPerformance(uint t, Parameter* para); + + float getElapsedTime(){ return this->elapsedTime; } + float getTotalElapsedTime(){ return this->totalElapsedTime; } + + private: + + cudaEvent_t start_t, stop_t; + float elapsedTime = 0.0; + float totalElapsedTime = 0.0; + std::string name; + + bool firstOutput = true; +}; + + + +#endif \ No newline at end of file diff --git a/src/gpu/VirtualFluids_GPU/Parameter/Parameter.cpp b/src/gpu/VirtualFluids_GPU/Parameter/Parameter.cpp index bf31cc6d8c95453d1dd05d355a793d49e6864c4f..d38f533b0c6e99220f6f787e4318dbf00523e2b2 100644 --- a/src/gpu/VirtualFluids_GPU/Parameter/Parameter.cpp +++ b/src/gpu/VirtualFluids_GPU/Parameter/Parameter.cpp @@ -111,9 +111,15 @@ void Parameter::readConfigData(const vf::basics::ConfigurationFile &configData) ////////////////////////////////////////////////////////////////////////// if (configData.contains("UseMeasurePoints")) this->setUseMeasurePoints(configData.getValue<bool>("UseMeasurePoints")); - ////////////////////////////////////////////////////////////////////////// + ////////////////////////////////////////////////////////////////////////// if (configData.contains("UseWale")) this->setUseWale(configData.getValue<bool>("UseWale")); + ////////////////////////////////////////////////////////////////////////// + if (configData.contains("UseAMD")) + this->setUseAMD(configData.getValue<bool>("UseAMD")); + ////////////////////////////////////////////////////////////////////////// + if (configData.contains("SGSconstant")) + this->setSGSConstant(configData.getValue<real>("SGSconstant")); ////////////////////////////////////////////////////////////////////////// if (configData.contains("UseInitNeq")) this->setUseInitNeq(configData.getValue<bool>("UseInitNeq")); @@ -577,10 +583,26 @@ void Parameter::setForcing(real forcingX, real forcingY, real forcingZ) this->hostForcing[2] = forcingZ; } void Parameter::setQuadricLimiters(real quadricLimiterP, real quadricLimiterM, real quadricLimiterD) +{ + this->hostQuadricLimiters[0] = quadricLimiterP; + this->hostQuadricLimiters[1] = quadricLimiterM; + this->hostQuadricLimiters[2] = quadricLimiterD; +} +void Parameter::setPhi(real inPhi) +{ + Phi = inPhi; +} +void Parameter::setAngularVelocity(real inAngVel) +{ + angularVelocity = inAngVel; +} +void Parameter::setStepEnsight(unsigned int step) +{ + this->stepEnsight = step; +} +void Parameter::setOutputCount(unsigned int outputCount) { - this->hostQuadricLimiters[0] = quadricLimiterP; - this->hostQuadricLimiters[1] = quadricLimiterM; - this->hostQuadricLimiters[2] = quadricLimiterD; + this->outputCount = outputCount; } void Parameter::setPhi(real inPhi) { Phi = inPhi; } void Parameter::setAngularVelocity(real inAngVel) { angularVelocity = inAngVel; } @@ -672,6 +694,29 @@ void Parameter::setUseMeasurePoints(bool useMeasurePoints) { ic.isMeasurePoints void Parameter::setUseWale(bool useWale) { ic.isWale = useWale; } void Parameter::setUseInitNeq(bool useInitNeq) { ic.isInitNeq = useInitNeq; } void Parameter::setSimulatePorousMedia(bool simulatePorousMedia) { ic.simulatePorousMedia = simulatePorousMedia; } +void Parameter::setUseTurbulentViscosity(bool useTurbulentViscosity) +{ + ic.isTurbulentViscosity = useTurbulentViscosity; +} +void Parameter::setUseWale(bool useWale) +{ + ic.isWale = useWale; + if (useWale) setUseTurbulentViscosity(true); +} +void Parameter::setUseAMD(bool useAMD) +{ + ic.isAMD = useAMD; + if (useAMD) setUseTurbulentViscosity(true); +} +void Parameter::setSGSConstant(real SGSConstant) +{ + ic.SGSConstant = SGSConstant; +} +void Parameter::setHasWallModelMonitor(bool hasWallModelMonitor) +{ + ic.hasWallModelMonitor = hasWallModelMonitor; +} + void Parameter::setIsF3(bool isF3) { this->isF3 = isF3; } @@ -1515,4 +1560,4 @@ void Parameter::initProcessNeighborsAfterFtoCZ(int level) this->getParD(level)->recvProcessNeighborsAfterFtoCZ.resize( this->getParH(level)->recvProcessNeighborsAfterFtoCZ.size()); } -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// \ No newline at end of file diff --git a/src/gpu/VirtualFluids_GPU/Parameter/Parameter.h b/src/gpu/VirtualFluids_GPU/Parameter/Parameter.h index 940b2493f96a8eab73d07d6a19031d708bc865dd..a61a28452af92e863dac170ff666aa452f0e5e3f 100644 --- a/src/gpu/VirtualFluids_GPU/Parameter/Parameter.h +++ b/src/gpu/VirtualFluids_GPU/Parameter/Parameter.h @@ -40,6 +40,7 @@ #include "LBM/D3Q27.h" #include "LBM/LB.h" +#include "PreCollisionInteractor/PreCollisionInteractor.h" #include "VirtualFluids_GPU_export.h" @@ -199,9 +200,9 @@ struct LBMSimulationParameter unsigned int mem_size_kFC_off; // BC's//////////////////// - QforBoundaryConditions QWall, Qinflow, Qoutflow, QSlip; - unsigned int kQ = 0, kInflowQ = 0, kOutflowQ = 0, kSlipQ = 0; - unsigned int kQread, kInflowQread, kOutflowQread, kSlipQread; + QforBoundaryConditions QWall, Qinflow, Qoutflow, QSlip, QStress; + unsigned int kQ = 0, kInflowQ = 0, kOutflowQ = 0, kSlipQ = 0, kStressQ = 0; + unsigned int kQread, kInflowQread, kOutflowQread, kSlipQread, kStressQread; QforBoundaryConditions QpressX0, QpressX1, QpressY0, QpressY1, QpressZ0, QpressZ1; QforBoundaryConditions QPropeller; @@ -213,6 +214,9 @@ struct LBMSimulationParameter QforBoundaryConditions QInlet, QOutlet, QPeriodic; unsigned int kInletQread, kOutletQread; unsigned int kPressQ = 0, kPressQread; + + WallModelParameters wallModel; + // testRoundoffError Distributions27 kDistTestRE; @@ -491,6 +495,10 @@ public: void setStreetVelocityFile(bool streetVelocityFile); void setUseMeasurePoints(bool useMeasurePoints); void setUseWale(bool useWale); + void setUseTurbulentViscosity(bool useTurbulentViscosity); + void setUseAMD( bool useAMD); + void setSGSConstant( real SGSConstant); + void setHasWallModelMonitor(bool hasWallModelMonitor); void setUseInitNeq(bool useInitNeq); void setSimulatePorousMedia(bool simulatePorousMedia); void setIsF3(bool isF3); @@ -571,6 +579,11 @@ public: void setADKernel(std::string adKernel); + //adder + + void addActuator(SPtr<PreCollisionInteractor> actuator); + void addProbe(SPtr<PreCollisionInteractor> probes); + // getter double *getForcesDouble(); real *getForcesHost(); @@ -700,7 +713,10 @@ public: real getViscosityRatio(); real getVelocityRatio(); real getDensityRatio(); - real getPressRatio(); + real getPressRatio(); + real getTimeRatio(); + real getLengthRatio(); + real getForceRatio(); real getRealX(); real getRealY(); real getRe(); @@ -727,6 +743,8 @@ public: TempVelforBoundaryConditions *getTempVelD(); TempPressforBoundaryConditions *getTempPressH(); TempPressforBoundaryConditions *getTempPressD(); + std::vector<SPtr<PreCollisionInteractor>> getActuators(); + std::vector<SPtr<PreCollisionInteractor>> getProbes(); unsigned int getTimeDoCheckPoint(); unsigned int getTimeDoRestart(); bool getDoCheckPoint(); @@ -746,6 +764,10 @@ public: bool isStreetVelocityFile(); bool getUseMeasurePoints(); bool getUseWale(); + bool getUseTurbulentViscosity(); + bool getUseAMD(); + real getSGSConstant(); + bool getHasWallModelMonitor(); bool getUseInitNeq(); bool getSimulatePorousMedia(); bool getIsF3(); @@ -816,7 +838,7 @@ private: bool writeVeloASCII { false }; bool calcPlaneConc { false }; bool calcVelocityAndFluctuations{ false }; - bool isBodyForce; + bool isBodyForce { false }; int diffMod {27}; int maxlevel {0}; int coarse {0}; @@ -862,6 +884,10 @@ private: real angularVelocity; unsigned int startTurn; + // PreCollisionInteractors ////////////// + std::vector<SPtr<PreCollisionInteractor>> actuators; + std::vector<SPtr<PreCollisionInteractor>> probes; + // Step of Ensight writing// unsigned int stepEnsight; diff --git a/src/gpu/VirtualFluids_GPU/Parameter/parameterTest.cfg b/src/gpu/VirtualFluids_GPU/Parameter/parameterTest.cfg index 8b6a75ddabaf3a9a570d08982ddad6a00e7b41c5..af9cb2851acbb56c2235c66ddf96bab3dac0d39f 100644 --- a/src/gpu/VirtualFluids_GPU/Parameter/parameterTest.cfg +++ b/src/gpu/VirtualFluids_GPU/Parameter/parameterTest.cfg @@ -1,8 +1,8 @@ -# this two parameters need to be defined in each config file +# these two parameters need to be defined in each config file Path = /output/path GridPath = /path/to/grid -# optional parameter +# optional parameters NumberOfDevices = 2 Devices = 2 3 Prefix = MyPrefix diff --git a/src/gpu/VirtualFluids_GPU/PreCollisionInteractor/ActuatorLine.cu b/src/gpu/VirtualFluids_GPU/PreCollisionInteractor/ActuatorLine.cu new file mode 100644 index 0000000000000000000000000000000000000000..96b6ad9a66f329be9847f3acaab81d4144b4de13 --- /dev/null +++ b/src/gpu/VirtualFluids_GPU/PreCollisionInteractor/ActuatorLine.cu @@ -0,0 +1,423 @@ +#include "ActuatorLine.h" + +#include <cuda.h> +#include <cuda_runtime.h> +#include <helper_cuda.h> + +#include <cuda/CudaGrid.h> +#include "VirtualFluids_GPU/GPU/GeometryUtils.h" + +#include "Parameter/Parameter.h" +#include "DataStructureInitializer/GridProvider.h" +#include "GPU/CudaMemoryManager.h" + +__host__ __device__ __inline__ uint calcNode(uint bladeNode, uint nBladeNodes, uint blade, uint nBlades) +{ + return bladeNode+blade*nBladeNodes; +} + +__host__ __device__ __inline__ void calcBladeAndBladeNode(uint node, uint& bladeNode, uint nBladeNodes, uint& blade, uint nBlades) +{ + blade = node/nBladeNodes; + bladeNode = node - blade*nBladeNodes; +} + +__host__ __device__ __forceinline__ real distSqrd(real distX, real distY, real distZ) +{ + return distX*distX+distY*distY+distZ*distZ; +} + +__host__ __device__ __inline__ void rotateFromBladeToGlobal( + real& bladeCoordX_BF, real& bladeCoordY_BF, real& bladeCoordZ_BF, + real& bladeCoordX_GF, real& bladeCoordY_GF, real& bladeCoordZ_GF, + real& azimuth, real& yaw) +{ + real tmpX, tmpY, tmpZ; + + rotateAboutX3D(azimuth, bladeCoordX_BF, bladeCoordY_BF, bladeCoordZ_BF, tmpX, tmpY, tmpZ); + rotateAboutZ3D(yaw, tmpX, tmpY, tmpZ, bladeCoordX_GF, bladeCoordY_GF, bladeCoordZ_GF); + +} + +__host__ __device__ __inline__ void rotateFromGlobalToBlade( + real& bladeCoordX_BF, real& bladeCoordY_BF, real& bladeCoordZ_BF, + real& bladeCoordX_GF, real& bladeCoordY_GF, real& bladeCoordZ_GF, + real& azimuth, real& yaw) +{ + real tmpX, tmpY, tmpZ; + + invRotateAboutZ3D(yaw, bladeCoordX_GF, bladeCoordY_GF, bladeCoordZ_GF, tmpX, tmpY, tmpZ); + invRotateAboutX3D(azimuth, tmpX, tmpY, tmpZ, bladeCoordX_BF, bladeCoordY_BF, bladeCoordZ_BF); +} + +__global__ void interpolateVelocities(real* gridCoordsX, real* gridCoordsY, real* gridCoordsZ, + uint* neighborsX, uint* neighborsY, uint* neighborsZ, uint* neighborsWSB, + real* vx, real* vy, real* vz, + real* bladeCoordsX, real* bladeCoordsY, real* bladeCoordsZ, + real* bladeVelocitiesX, real* bladeVelocitiesY, real* bladeVelocitiesZ, + uint nBlades, uint nBladeNodes, + real azimuth, real yaw, real omega, + real turbPosX, real turbPosY, real turbPosZ, + uint* bladeIndices, real velocityRatio, real invDeltaX) +{ + const uint x = threadIdx.x; + const uint y = blockIdx.x; + const uint z = blockIdx.y; + + const uint nx = blockDim.x; + const uint ny = gridDim.x; + + const uint node = nx*(ny*z + y) + x; + + uint bladeNode, blade; + + calcBladeAndBladeNode(node, bladeNode, nBladeNodes, blade, nBlades); + + if(node>=nBladeNodes*nBlades) return; + + real bladeCoordX_BF = bladeCoordsX[node]; + real bladeCoordY_BF = bladeCoordsY[node]; + real bladeCoordZ_BF = bladeCoordsZ[node]; + + real bladeCoordX_GF, bladeCoordY_GF, bladeCoordZ_GF; + + real localAzimuth = azimuth+blade*c2Pi/nBlades; + + rotateFromBladeToGlobal(bladeCoordX_BF, bladeCoordY_BF, bladeCoordZ_BF, + bladeCoordX_GF, bladeCoordY_GF, bladeCoordZ_GF, + localAzimuth, yaw); + + bladeCoordX_GF += turbPosX; + bladeCoordY_GF += turbPosY; + bladeCoordZ_GF += turbPosZ; + + uint k, ke, kn, kt; + uint kne, kte, ktn, ktne; + + k = findNearestCellBSW(bladeIndices[node], + gridCoordsX, gridCoordsY, gridCoordsZ, + bladeCoordX_GF, bladeCoordY_GF, bladeCoordZ_GF, + neighborsX, neighborsY, neighborsZ, neighborsWSB); + + bladeIndices[node] = k; + + getNeighborIndicesOfBSW(k, ke, kn, kt, kne, kte, ktn, ktne, neighborsX, neighborsY, neighborsZ); + + real dW, dE, dN, dS, dT, dB; + + real distX = invDeltaX*(bladeCoordX_GF-gridCoordsX[k]); + real distY = invDeltaX*(bladeCoordY_GF-gridCoordsY[k]); + real distZ = invDeltaX*(bladeCoordZ_GF-gridCoordsZ[k]); + + getInterpolationWeights(dW, dE, dN, dS, dT, dB, distX, distY, distZ); + + real bladeVelX_GF = trilinearInterpolation(dW, dE, dN, dS, dT, dB, k, ke, kn, kt, kne, kte, ktn, ktne, vx)*velocityRatio; + real bladeVelY_GF = trilinearInterpolation(dW, dE, dN, dS, dT, dB, k, ke, kn, kt, kne, kte, ktn, ktne, vy)*velocityRatio; + real bladeVelZ_GF = trilinearInterpolation(dW, dE, dN, dS, dT, dB, k, ke, kn, kt, kne, kte, ktn, ktne, vz)*velocityRatio; + + real bladeVelX_BF, bladeVelY_BF, bladeVelZ_BF; + + rotateFromGlobalToBlade(bladeVelX_BF, bladeVelY_BF, bladeVelZ_BF, + bladeVelX_GF, bladeVelY_GF, bladeVelZ_GF, + localAzimuth, yaw); + + bladeVelocitiesX[node] = bladeVelX_BF; + bladeVelocitiesY[node] = bladeVelY_BF+omega*bladeCoordZ_BF; + bladeVelocitiesZ[node] = bladeVelZ_BF; +} + + +__global__ void applyBodyForces(real* gridCoordsX, real* gridCoordsY, real* gridCoordsZ, + real* gridForcesX, real* gridForcesY, real* gridForcesZ, + real* bladeCoordsX, real* bladeCoordsY, real* bladeCoordsZ, + real* bladeForcesX, real* bladeForcesY,real* bladeForcesZ, + uint nBlades, uint nBladeNodes, + real azimuth, real yaw, real omega, + real turbPosX, real turbPosY, real turbPosZ, + uint* gridIndices, uint nIndices, + real invEpsilonSqrd, real factorGaussian) +{ + const uint x = threadIdx.x; + const uint y = blockIdx.x; + const uint z = blockIdx.y; + + const uint nx = blockDim.x; + const uint ny = gridDim.x; + + const uint index = nx*(ny*z + y) + x; + + if(index>=nIndices) return; + + uint gridIndex = gridIndices[index]; + + real gridCoordX_RF = gridCoordsX[gridIndex] - turbPosX; + real gridCoordY_RF = gridCoordsY[gridIndex] - turbPosY; + real gridCoordZ_RF = gridCoordsZ[gridIndex] - turbPosZ; + + real gridForceX_RF = c0o1; + real gridForceY_RF = c0o1; + real gridForceZ_RF = c0o1; + + real dAzimuth = c2Pi/nBlades; + + for( uint blade=0; blade<nBlades; blade++) + { + real localAzimuth = azimuth+blade*dAzimuth; + + real gridCoordX_BF, gridCoordY_BF, gridCoordZ_BF; + + rotateFromGlobalToBlade(gridCoordX_BF, gridCoordY_BF, gridCoordZ_BF, + gridCoordX_RF, gridCoordY_RF, gridCoordZ_RF, + localAzimuth, yaw); + + for( uint bladeNode=0; bladeNode<nBladeNodes; bladeNode++) + { + uint node = calcNode(bladeNode, nBladeNodes, blade, nBlades); + + real eta = factorGaussian*exp(-distSqrd(bladeCoordsX[node]-gridCoordX_BF, bladeCoordsY[node]-gridCoordY_BF, bladeCoordsZ[node]-gridCoordZ_BF)*invEpsilonSqrd); + + real forceX_RF, forceY_RF, forceZ_RF; + + rotateFromBladeToGlobal(bladeForcesX[node], bladeForcesY[node], bladeForcesZ[node], + forceX_RF, forceY_RF, forceZ_RF, + localAzimuth, yaw); + + gridForceX_RF += forceX_RF*eta; + gridForceY_RF += forceY_RF*eta; + gridForceZ_RF += forceZ_RF*eta; + } + } + + atomicAdd(&gridForcesX[gridIndex], gridForceX_RF); + atomicAdd(&gridForcesY[gridIndex], gridForceY_RF); + atomicAdd(&gridForcesZ[gridIndex], gridForceZ_RF); +} + + +void ActuatorLine::init(Parameter* para, GridProvider* gridProvider, CudaMemoryManager* cudaManager) +{ + if(!para->getIsBodyForce()) throw std::runtime_error("try to allocate ActuatorLine but BodyForce is not set in Parameter."); + this->initBladeRadii(cudaManager); + this->initBladeCoords(cudaManager); + this->initBladeIndices(para, cudaManager); + this->initBladeVelocities(cudaManager); + this->initBladeForces(cudaManager); + this->initBoundingSphere(para, cudaManager); +} + + +void ActuatorLine::interact(Parameter* para, CudaMemoryManager* cudaManager, int level, unsigned int t) +{ + if (level != this->level) return; + + cudaManager->cudaCopyBladeCoordsHtoD(this); + + vf::cuda::CudaGrid bladeGrid = vf::cuda::CudaGrid(para->getParH(level)->numberofthreads, this->nNodes); + + interpolateVelocities<<< bladeGrid.grid, bladeGrid.threads >>>( + para->getParD(this->level)->coordX_SP, para->getParD(this->level)->coordY_SP, para->getParD(this->level)->coordZ_SP, + para->getParD(this->level)->neighborX_SP, para->getParD(this->level)->neighborY_SP, para->getParD(this->level)->neighborZ_SP, para->getParD(this->level)->neighborWSB_SP, + para->getParD(this->level)->vx_SP, para->getParD(this->level)->vy_SP, para->getParD(this->level)->vz_SP, + this->bladeCoordsXD, this->bladeCoordsYD, this->bladeCoordsZD, + this->bladeVelocitiesXD, this->bladeVelocitiesYD, this->bladeVelocitiesZD, + this->nBlades, this->nBladeNodes, + this->azimuth, this->yaw, this->omega, + this->turbinePosX, this->turbinePosY, this->turbinePosZ, + this->bladeIndicesD, para->getVelocityRatio(), this->invDeltaX); + + cudaManager->cudaCopyBladeVelocitiesDtoH(this); + + this->calcBladeForces(); + + cudaManager->cudaCopyBladeForcesHtoD(this); + + vf::cuda::CudaGrid sphereGrid = vf::cuda::CudaGrid(para->getParH(level)->numberofthreads, this->nIndices); + + applyBodyForces<<<sphereGrid.grid, sphereGrid.threads>>>( + para->getParD(this->level)->coordX_SP, para->getParD(this->level)->coordY_SP, para->getParD(this->level)->coordZ_SP, + para->getParD(this->level)->forceX_SP, para->getParD(this->level)->forceY_SP, para->getParD(this->level)->forceZ_SP, + this->bladeCoordsXD, this->bladeCoordsYD, this->bladeCoordsZD, + this->bladeForcesXD, this->bladeForcesYD, this->bladeForcesZD, + this->nBlades, this->nBladeNodes, + this->azimuth, this->yaw, this->omega, + this->turbinePosX, this->turbinePosY, this->turbinePosZ, + this->boundingSphereIndicesD, this->nIndices, + this->invEpsilonSqrd, this->factorGaussian); + + this->azimuth = fmod(this->azimuth+this->omega*this->deltaT,c2Pi); +} + + +void ActuatorLine::free(Parameter* para, CudaMemoryManager* cudaManager) +{ + cudaManager->cudaFreeBladeRadii(this); + cudaManager->cudaFreeBladeCoords(this); + cudaManager->cudaFreeBladeVelocities(this); + cudaManager->cudaFreeBladeForces(this); + cudaManager->cudaFreeBladeIndices(this); + cudaManager->cudaFreeSphereIndices(this); +} + + +void ActuatorLine::calcForcesEllipticWing() +{ + uint node; + real u_rel, v_rel, u_rel_sq; + real phi; + real Cl = c1o1; + real Cd = c0o1; + real c0 = c1o1; + + real c, Cn, Ct; + + for( uint blade=0; blade<this->nBlades; blade++) + { + for( uint bladeNode=0; bladeNode<this->nBladeNodes; bladeNode++) + { + node = calcNode(bladeNode, this->nBladeNodes, blade, this->nBlades); + + u_rel = this->bladeVelocitiesXH[node]; + v_rel = this->bladeVelocitiesYH[node]; + u_rel_sq = u_rel*u_rel+v_rel*v_rel; + phi = atan2(u_rel, v_rel); + + real tmp = c4o1*this->bladeRadiiH[bladeNode]/this->diameter-c1o1; + c = c0 * sqrt( c1o1- tmp*tmp ); + Cn = Cl*cos(phi)+Cd*sin(phi); + Ct = Cl*sin(phi)-Cd*cos(phi); + + this->bladeForcesXH[node] = -c1o2*u_rel_sq*c*this->density*Cn; + this->bladeForcesYH[node] = -c1o2*u_rel_sq*c*this->density*Ct; + this->bladeForcesZH[node] = c0o1; + } + } +} + +void ActuatorLine::calcBladeForces() +{ + this->calcForcesEllipticWing(); +} + +void ActuatorLine::initBladeRadii(CudaMemoryManager* cudaManager) +{ + cudaManager->cudaAllocBladeRadii(this); + + real dr = c1o2*this->diameter/this->nBladeNodes; + + for(uint node=0; node<this->nBladeNodes; node++) + { + this->bladeRadiiH[node] = dr*(node+1); + } + cudaManager->cudaCopyBladeRadiiHtoD(this); + + real dxOPiSqrtEps = pow(this->deltaX/(this->epsilon*sqrt(cPi)),c3o1); + this->factorGaussian = dr*dxOPiSqrtEps/this->forceRatio; +} + +void ActuatorLine::initBladeCoords(CudaMemoryManager* cudaManager) +{ + cudaManager->cudaAllocBladeCoords(this); + + for(uint blade=0; blade<this->nBlades; blade++) + { + for(uint bladeNode=0; bladeNode<this->nBladeNodes; bladeNode++) + { + uint node = calcNode(bladeNode, this->nBladeNodes, blade, this->nBlades); + + this->bladeCoordsXH[node] = c0o1; + this->bladeCoordsYH[node] = c0o1; + this->bladeCoordsZH[node] = this->bladeRadiiH[bladeNode]; + } + } + cudaManager->cudaCopyBladeCoordsHtoD(this); +} + +void ActuatorLine::initBladeVelocities(CudaMemoryManager* cudaManager) +{ + cudaManager->cudaAllocBladeVelocities(this); + + for(uint node=0; node<this->nNodes; node++) + { + this->bladeVelocitiesXH[node] = c0o1; + this->bladeVelocitiesYH[node] = c0o1; + this->bladeVelocitiesZH[node] = c0o1; + } + cudaManager->cudaCopyBladeVelocitiesHtoD(this); +} + +void ActuatorLine::initBladeForces(CudaMemoryManager* cudaManager) +{ + cudaManager->cudaAllocBladeForces(this); + + for(uint node=0; node<this->nNodes; node++) + { + this->bladeForcesXH[node] = c0o1; + this->bladeForcesYH[node] = c0o1; + this->bladeForcesZH[node] = c0o1; + } + cudaManager->cudaCopyBladeForcesHtoD(this); +} + +void ActuatorLine::initBladeIndices(Parameter* para, CudaMemoryManager* cudaManager) +{ + cudaManager->cudaAllocBladeIndices(this); + + for(uint node=0; node<this->nNodes; node++) + + { + this->bladeIndicesH[node] = 1; + } + cudaManager->cudaCopyBladeIndicesHtoD(this); +} + +void ActuatorLine::initBoundingSphere(Parameter* para, CudaMemoryManager* cudaManager) +{ + // Actuator line exists only on 1 level + std::vector<int> nodesInSphere; + real sphereRadius = c1o2*this->diameter+c4o1*this->epsilon; + real sphereRadiusSqrd = sphereRadius*sphereRadius; + + for (uint j = 1; j <= para->getParH(this->level)->size_Mat_SP; j++) + { + const real distX = para->getParH(this->level)->coordX_SP[j]-this->turbinePosX; + const real distY = para->getParH(this->level)->coordY_SP[j]-this->turbinePosY; + const real distZ = para->getParH(this->level)->coordZ_SP[j]-this->turbinePosZ; + if(distSqrd(distX,distY,distZ) < sphereRadiusSqrd) nodesInSphere.push_back(j); + } + + this->nIndices = uint(nodesInSphere.size()); + cudaManager->cudaAllocSphereIndices(this); + std::copy(nodesInSphere.begin(), nodesInSphere.end(), this->boundingSphereIndicesH); + cudaManager->cudaCopySphereIndicesHtoD(this); +} + +void ActuatorLine::setBladeCoords(real* _bladeCoordsX, real* _bladeCoordsY, real* _bladeCoordsZ) +{ + + for(uint node=0; node<this->nNodes; node++) + { + this->bladeCoordsXH[node] = _bladeCoordsX[node]; + this->bladeCoordsYH[node] = _bladeCoordsY[node]; + this->bladeCoordsZH[node] = _bladeCoordsZ[node]; + } +} + +void ActuatorLine::setBladeVelocities(real* _bladeVelocitiesX, real* _bladeVelocitiesY, real* _bladeVelocitiesZ) +{ + for(uint node=0; node<this->nNodes; node++) + { + this->bladeVelocitiesXH[node] = _bladeVelocitiesX[node]; + this->bladeVelocitiesYH[node] = _bladeVelocitiesY[node]; + this->bladeVelocitiesZH[node] = _bladeVelocitiesZ[node]; + } +} + +void ActuatorLine::setBladeForces(real* _bladeForcesX, real* _bladeForcesY, real* _bladeForcesZ) +{ + for(uint node=0; node<this->nNodes; node++) + { + this->bladeForcesXH[node] = _bladeForcesX[node]; + this->bladeForcesYH[node] = _bladeForcesY[node]; + this->bladeForcesZH[node] = _bladeForcesZ[node]; + } +} \ No newline at end of file diff --git a/src/gpu/VirtualFluids_GPU/PreCollisionInteractor/ActuatorLine.h b/src/gpu/VirtualFluids_GPU/PreCollisionInteractor/ActuatorLine.h new file mode 100644 index 0000000000000000000000000000000000000000..821261416402fbd271ddaf3a45119c0d3cb24779 --- /dev/null +++ b/src/gpu/VirtualFluids_GPU/PreCollisionInteractor/ActuatorLine.h @@ -0,0 +1,120 @@ +#ifndef ActuatorLine_H +#define ActuatorLine_H + +#include "PreCollisionInteractor.h" +#include "PointerDefinitions.h" +#include "VirtualFluids_GPU_export.h" +#include "lbm/constants/NumericConstants.h" + +class Parameter; +class GridProvider; + +using namespace vf::lbm::constant; +class VIRTUALFLUIDS_GPU_EXPORT ActuatorLine : public PreCollisionInteractor +{ +public: + ActuatorLine( + const uint _nBlades, + const real _density, + const uint _nBladeNodes, + const real _epsilon, + real _turbinePosX, real _turbinePosY, real _turbinePosZ, + const real _diameter, + int _level, + const real _deltaT, + const real _deltaX + ) : nBlades(_nBlades), + density(_density), + nBladeNodes(_nBladeNodes), + epsilon(_epsilon), + turbinePosX(_turbinePosX), turbinePosY(_turbinePosY), turbinePosZ(_turbinePosZ), + diameter(_diameter), + level(_level), + PreCollisionInteractor() + { + this->deltaT = _deltaT*exp2(-this->level); + this->deltaX = _deltaX*exp2(-this->level); + this->invDeltaX = c1o1/this->deltaX; + this->forceRatio = this->density*pow(this->deltaX,4)*pow(this->deltaT,-2); + this->invEpsilonSqrd = c1o1/(this->epsilon*this->epsilon); + this->nNodes = this->nBladeNodes*this->nBlades; + this->omega = c1o1; + this->azimuth = c0o1; + this->yaw = c0o1; + }; + + virtual ~ActuatorLine(){}; + + void init(Parameter* para, GridProvider* gridProvider, CudaMemoryManager* cudaManager) override; + void interact(Parameter* para, CudaMemoryManager* cudaManager, int level, uint t) override; + void free(Parameter* para, CudaMemoryManager* cudaManager) override; + void write(uint t); + + uint getNBladeNodes(){ return this->nBladeNodes; }; + uint getNBlades(){ return this->nBlades;}; + uint getNIndices(){ return this->nIndices; }; + uint getNNodes(){ return this->nNodes; }; + real getOmega(){ return this->omega; }; + real getAzimuth(){ return this->azimuth; }; + real getYaw(){ return this->yaw; }; + real getDensity(){ return this->density; }; + real getPositionX(){ return this->turbinePosX; }; + real getPositionY(){ return this->turbinePosY; }; + real getPositionZ(){ return this->turbinePosZ; }; + real* getBladeRadii(){ return this->bladeRadiiH; }; + real* getBladeCoordsX(){ return this->bladeCoordsXH; }; + real* getBladeCoordsY(){ return this->bladeCoordsYH; }; + real* getBladeCoordsZ(){ return this->bladeCoordsZH; }; + real* getBladeVelocitiesX(){ return this->bladeVelocitiesXH; }; + real* getBladeVelocitiesY(){ return this->bladeVelocitiesYH; }; + real* getBladeVelocitiesZ(){ return this->bladeVelocitiesZH; }; + real* getBladeForcesX(){ return this->bladeForcesXH; }; + real* getBladeForcesY(){ return this->bladeForcesYH; }; + real* getBladeForcesZ(){ return this->bladeForcesZH; }; + + void setOmega(real _omega){ this->omega = _omega; }; + void setAzimuth(real _azimuth){ this->azimuth = _azimuth; }; + void setYaw(real _yaw){ this->yaw = _yaw; }; + void setBladeCoords(real* _bladeCoordsX, real* _bladeCoordsY, real* _bladeCoordsZ); + void setBladeVelocities(real* _bladeVelocitiesX, real* _bladeVelocitiesY, real* _bladeVelocitiesZ); + void setBladeForces(real* _bladeForcesX, real* _bladeForcesY, real* _bladeForcesZ); + virtual void calcBladeForces(); + +private: + void initBoundingSphere(Parameter* para, CudaMemoryManager* cudaManager); + + void initBladeRadii(CudaMemoryManager* cudaManager); + void initBladeCoords(CudaMemoryManager* cudaManager); + void initBladeVelocities(CudaMemoryManager* cudaManager); + void initBladeForces(CudaMemoryManager* cudaManager); + void initBladeIndices(Parameter* para, CudaMemoryManager* cudaManager); + + void calcForcesEllipticWing(); + +public: + real* bladeRadiiH; + real* bladeRadiiD; + real* bladeCoordsXH, * bladeCoordsYH, * bladeCoordsZH; + real* bladeCoordsXD, * bladeCoordsYD, * bladeCoordsZD; + real* bladeVelocitiesXH, * bladeVelocitiesYH, * bladeVelocitiesZH; + real* bladeVelocitiesXD, * bladeVelocitiesYD, * bladeVelocitiesZD; + real* bladeForcesXH, * bladeForcesYH, * bladeForcesZH; + real* bladeForcesXD, * bladeForcesYD, * bladeForcesZD; + uint* bladeIndicesH; + uint* bladeIndicesD; + uint* boundingSphereIndicesH; + uint* boundingSphereIndicesD; + +private: + const real density; + real turbinePosX, turbinePosY, turbinePosZ; + real omega, azimuth, yaw, deltaT, deltaX, invDeltaX, forceRatio, factorGaussian, invEpsilonSqrd; + const real diameter; + const uint nBladeNodes; + const uint nBlades; + const real epsilon; // in m + const int level; + uint nIndices, nNodes; +}; + +#endif \ No newline at end of file diff --git a/src/gpu/VirtualFluids_GPU/PreCollisionInteractor/PreCollisionInteractor.h b/src/gpu/VirtualFluids_GPU/PreCollisionInteractor/PreCollisionInteractor.h new file mode 100644 index 0000000000000000000000000000000000000000..78b4d5e9ba148651e78c38758624de69dd08c47d --- /dev/null +++ b/src/gpu/VirtualFluids_GPU/PreCollisionInteractor/PreCollisionInteractor.h @@ -0,0 +1,41 @@ +#ifndef PreCollisionInteractor_H +#define PreCollisionInteractor_H + +#include <string> +#include <vector> + +#include "Core/DataTypes.h" +#include "PointerDefinitions.h" +#include "VirtualFluids_GPU_export.h" + +#include <cassert> + +class Parameter; +class GridProvider; +class CudaMemoryManager; + +class VIRTUALFLUIDS_GPU_EXPORT PreCollisionInteractor +{ +private: + SPtr<Parameter> para; + +protected: + PreCollisionInteractor() + { + this->updateInterval = 1; + } + +public: + virtual ~PreCollisionInteractor() + { + } + + virtual void init(Parameter *para, GridProvider *gridProvider, CudaMemoryManager *cudaManager) = 0; + virtual void interact(Parameter *para, CudaMemoryManager *cudaManager, int level, uint t) = 0; + virtual void free(Parameter *para, CudaMemoryManager *cudaManager) = 0; + +protected: + uint updateInterval; +}; + +#endif \ No newline at end of file diff --git a/src/gpu/VirtualFluids_GPU/PreCollisionInteractor/Probes/PlanarAverageProbe.cu b/src/gpu/VirtualFluids_GPU/PreCollisionInteractor/Probes/PlanarAverageProbe.cu new file mode 100644 index 0000000000000000000000000000000000000000..5ac087ccfec2dc71439054921c8500568c9c070d --- /dev/null +++ b/src/gpu/VirtualFluids_GPU/PreCollisionInteractor/Probes/PlanarAverageProbe.cu @@ -0,0 +1,457 @@ +#include "Probe.h" +#include "PlanarAverageProbe.h" + +#include <cuda/CudaGrid.h> + +#include <cuda.h> +#include <cuda_runtime.h> +#include <helper_cuda.h> + +#include <thrust/device_vector.h> +#include <thrust/reduce.h> +#include <thrust/device_ptr.h> +#include <thrust/inner_product.h> + +#include "Parameter/Parameter.h" +#include "DataStructureInitializer/GridProvider.h" +#include "GPU/CudaMemoryManager.h" + +#include <algorithm> + +/////////////////////////////////////////////////////////////////////////////////// +/// Functors for thrust reductions +/////////////////////////////////////////////////////////////////////////////////// + +template<typename T> +struct pow2 : public thrust::unary_function<T,T> +{ + __host__ __device__ T operator()(const T &x) const + { + return x * x; + } +}; + +template<typename T> +struct pow3 : public thrust::unary_function<T,T> +{ + __host__ __device__ T operator()(const T &x) const + { + return x * x * x; + } +}; + +template<typename T> +struct pow4 : public thrust::unary_function<T,T> +{ + __host__ __device__ T operator()(const T &x) const + { + return x * x * x * x; + } +}; + +struct nth_moment +{ + const float mean; + const int n; + + nth_moment(float _mean, int _n) : mean(_mean), n(_n) {} + + __host__ __device__ + float operator()(const float& x) const { + + real fluctuation = x-mean; + real moment = fluctuation; + for(int i = 1; i<n; i++) moment *= fluctuation; + + return moment; + } +}; + + +/////////////////////////////////////////////////////////////////////////////////// + +__global__ void moveIndicesInPosNormalDir( uint* pointIndices, uint nPoints, uint* neighborNormal, real* coordsX, real* coordsY, real* coordsZ ) +{ + const uint x = threadIdx.x; + const uint y = blockIdx.x; + const uint z = blockIdx.y; + + const uint nx = blockDim.x; + const uint ny = gridDim.x; + + const uint node = nx*(ny*z + y) + x; + + if(node>=nPoints) return; + + uint k = pointIndices[node]; + + pointIndices[node] = neighborNormal[k]; +} + +__global__ void moveIndicesInNegNormalDir( uint* pointIndices, uint nPoints, uint* neighborWSB, uint* neighborInplane1, uint* neighborInplane2, real* coordsX, real* coordsY, real* coordsZ ) +{ + const uint x = threadIdx.x; + const uint y = blockIdx.x; + const uint z = blockIdx.y; + + const uint nx = blockDim.x; + const uint ny = gridDim.x; + + const uint node = nx*(ny*z + y) + x; + + if(node>=nPoints) return; + + uint k = pointIndices[node]; + + pointIndices[node] = neighborWSB[neighborInplane1[neighborInplane2[k]]]; +} + +/////////////////////////////////////////////////////////////////////////////////// + +bool PlanarAverageProbe::isAvailableStatistic(Statistic _variable) +{ + bool isAvailable; + + switch (_variable) + { + case Statistic::Instantaneous: + case Statistic::Means: + case Statistic::Variances: + isAvailable = false; + break; + case Statistic::SpatialMeans: + case Statistic::SpatioTemporalMeans: + case Statistic::SpatialCovariances: + case Statistic::SpatioTemporalCovariances: + case Statistic::SpatialSkewness: + case Statistic::SpatioTemporalSkewness: + case Statistic::SpatialFlatness: + case Statistic::SpatioTemporalFlatness: + isAvailable = true; + break; + default: + isAvailable = false; + } + return isAvailable; +} + +/////////////////////////////////////////////////////////////////////////////////// +std::vector<PostProcessingVariable> PlanarAverageProbe::getPostProcessingVariables(Statistic statistic) +{ + std::vector<PostProcessingVariable> postProcessingVariables; + switch (statistic) + { + case Statistic::SpatialMeans: + postProcessingVariables.push_back( PostProcessingVariable("vx_spatMean", velocityRatio) ); + postProcessingVariables.push_back( PostProcessingVariable("vy_spatMean", this->velocityRatio) ); + postProcessingVariables.push_back( PostProcessingVariable("vz_spatMean", this->velocityRatio) ); + break; + case Statistic::SpatioTemporalMeans: + postProcessingVariables.push_back( PostProcessingVariable("vx_spatTmpMean", this->velocityRatio) ); + postProcessingVariables.push_back( PostProcessingVariable("vy_spatTmpMean", this->velocityRatio) ); + postProcessingVariables.push_back( PostProcessingVariable("vz_spatTmpMean", this->velocityRatio) ); + break; + case Statistic::SpatialCovariances: + postProcessingVariables.push_back( PostProcessingVariable("vxvx_spatMean", pow(this->velocityRatio, 2.0)) ); + postProcessingVariables.push_back( PostProcessingVariable("vyvy_spatMean", pow(this->velocityRatio, 2.0)) ); + postProcessingVariables.push_back( PostProcessingVariable("vzvz_spatMean", pow(this->velocityRatio, 2.0)) ); + postProcessingVariables.push_back( PostProcessingVariable("vxvy_spatMean", pow(this->velocityRatio, 2.0)) ); + postProcessingVariables.push_back( PostProcessingVariable("vxvz_spatMean", pow(this->velocityRatio, 2.0)) ); + postProcessingVariables.push_back( PostProcessingVariable("vyvz_spatMean", pow(this->velocityRatio, 2.0)) ); + break; + case Statistic::SpatioTemporalCovariances: + postProcessingVariables.push_back( PostProcessingVariable("vxvx_spatTmpMean", pow(this->velocityRatio, 2.0)) ); + postProcessingVariables.push_back( PostProcessingVariable("vyvy_spatTmpMean", pow(this->velocityRatio, 2.0)) ); + postProcessingVariables.push_back( PostProcessingVariable("vzvz_spatTmpMean", pow(this->velocityRatio, 2.0)) ); + postProcessingVariables.push_back( PostProcessingVariable("vxvy_spatTmpMean", pow(this->velocityRatio, 2.0)) ); + postProcessingVariables.push_back( PostProcessingVariable("vxvz_spatTmpMean", pow(this->velocityRatio, 2.0)) ); + postProcessingVariables.push_back( PostProcessingVariable("vyvz_spatTmpMean", pow(this->velocityRatio, 2.0)) ); + break; + case Statistic::SpatialSkewness: + postProcessingVariables.push_back( PostProcessingVariable("Sx_spatMean", 1.0) ); + postProcessingVariables.push_back( PostProcessingVariable("Sy_spatMean", 1.0) ); + postProcessingVariables.push_back( PostProcessingVariable("Sz_spatMean", 1.0) ); + break; + case Statistic::SpatioTemporalSkewness: + postProcessingVariables.push_back( PostProcessingVariable("Sx_spatTmpMean", 1.0) ); + postProcessingVariables.push_back( PostProcessingVariable("Sy_spatTmpMean", 1.0) ); + postProcessingVariables.push_back( PostProcessingVariable("Sz_spatTmpMean", 1.0) ); + break; + case Statistic::SpatialFlatness: + postProcessingVariables.push_back( PostProcessingVariable("Fx_spatMean", 1.0) ); + postProcessingVariables.push_back( PostProcessingVariable("Fy_spatMean", 1.0) ); + postProcessingVariables.push_back( PostProcessingVariable("Fz_spatMean", 1.0) ); + break; + case Statistic::SpatioTemporalFlatness: + postProcessingVariables.push_back( PostProcessingVariable("Fx_spatTmpMean", 1.0) ); + postProcessingVariables.push_back( PostProcessingVariable("Fy_spatTmpMean", 1.0) ); + postProcessingVariables.push_back( PostProcessingVariable("Fz_spatTmpMean", 1.0) ); + break; + + default: + printf("Statistic unavailable in PlanarAverageProbe\n"); + assert(false); + break; + } + return postProcessingVariables; +} + +/////////////////////////////////////////////////////////////////////////////////// + +void PlanarAverageProbe::findPoints(Parameter* para, GridProvider* gridProvider, std::vector<int>& probeIndices_level, + std::vector<real>& distX_level, std::vector<real>& distY_level, std::vector<real>& distZ_level, + std::vector<real>& pointCoordsX_level, std::vector<real>& pointCoordsY_level, std::vector<real>& pointCoordsZ_level, + int level) +{ + real dx = abs(para->getParH(level)->coordX_SP[1]-para->getParH(level)->coordX_SP[para->getParH(level)->neighborX_SP[1]]); + + real /* *pointCoordsInplane1_par, *pointCoordsInplane2_par,*/ *pointCoordsNormal_par; + std::vector<real> *pointCoordsInplane1, *pointCoordsInplane2, *pointCoordsNormal; + + if(this->planeNormal == 'x'){ + pointCoordsNormal = &pointCoordsX_level; + pointCoordsInplane1 = &pointCoordsY_level; + pointCoordsInplane2 = &pointCoordsZ_level; + pointCoordsNormal_par = para->getParH(level)->coordX_SP; + // pointCoordsInplane1_par = para->getParH(level)->coordY_SP; + // pointCoordsInplane2_par = para->getParH(level)->coordZ_SP; + } + if(this->planeNormal == 'y'){ + pointCoordsNormal = &pointCoordsY_level; + pointCoordsInplane1 = &pointCoordsX_level; + pointCoordsInplane2 = &pointCoordsZ_level; + pointCoordsNormal_par = para->getParH(level)->coordY_SP; + // pointCoordsInplane1_par = para->getParH(level)->coordX_SP; + // pointCoordsInplane2_par = para->getParH(level)->coordZ_SP; + } + if(this->planeNormal == 'z'){ + pointCoordsNormal = &pointCoordsZ_level; + pointCoordsInplane1 = &pointCoordsX_level; + pointCoordsInplane2 = &pointCoordsY_level; + pointCoordsNormal_par = para->getParH(level)->coordZ_SP; + // pointCoordsInplane1_par = para->getParH(level)->coordX_SP; + // pointCoordsInplane2_par = para->getParH(level)->coordY_SP; + } + + // Find all points along the normal direction + for(uint j=1; j<para->getParH(level)->size_Mat_SP; j++ ) + { + if(para->getParH(level)->geoSP[j] == GEO_FLUID) + { + if( std::find(pointCoordsNormal->begin(), pointCoordsNormal->end(), pointCoordsNormal_par[j]) == pointCoordsNormal->end()) + { + pointCoordsNormal->push_back( pointCoordsNormal_par[j] ); + pointCoordsInplane1->push_back(999999.); + pointCoordsInplane2->push_back(999999.); + } + } + } + std::sort(pointCoordsNormal->begin(), pointCoordsNormal->end()); + + // Find all pointCoords in the first plane + for(uint j=1; j<para->getParH(level)->size_Mat_SP; j++ ) + { + if( para->getParH(level)->geoSP[j] == GEO_FLUID && pointCoordsNormal_par[j] == pointCoordsNormal->at(0)) + { + //not needed in current state, might become relevant for two-point correlations + // pointCoordsNormal->push_back( pointCoordsNormal_par[j] ); + // pointCoordsInplane1->push_back( pointCoordsInplane1_par[j] ); + // pointCoordsInplane2->push_back( pointCoordsInplane2_par[j] ); + + probeIndices_level.push_back(j); + } + } +} + +/////////////////////////////////////////////////////////////////////////////////// + +void PlanarAverageProbe::calculateQuantities(SPtr<ProbeStruct> probeStruct, Parameter* para, uint t, int level) +{ + // Definition of normal and inplane directions for moveIndices kernels + uint *neighborNormal, *neighborInplane1, *neighborInplane2; + if( this->planeNormal == 'x' ) + { + neighborNormal = para->getParD(level)->neighborX_SP; + neighborInplane1 = para->getParD(level)->neighborY_SP; + neighborInplane2 = para->getParD(level)->neighborZ_SP; + } + if( this->planeNormal == 'y' ) + { + neighborNormal = para->getParD(level)->neighborY_SP; + neighborInplane1 = para->getParD(level)->neighborX_SP; + neighborInplane2 = para->getParD(level)->neighborZ_SP; + } + if( this->planeNormal == 'z' ) + { + neighborNormal = para->getParD(level)->neighborZ_SP; + neighborInplane1 = para->getParD(level)->neighborX_SP; + neighborInplane2 = para->getParD(level)->neighborY_SP; + } + + bool doTmpAveraging = (t>this->getTStartTmpAveraging()); + + // Pointer casts to use device arrays in thrust reductions + thrust::device_ptr<uint> indices_thrust = thrust::device_pointer_cast(probeStruct->pointIndicesD); + thrust::device_ptr<real> vx_thrust = thrust::device_pointer_cast(para->getParD(level)->vx_SP); + thrust::device_ptr<real> vy_thrust = thrust::device_pointer_cast(para->getParD(level)->vy_SP); + thrust::device_ptr<real> vz_thrust = thrust::device_pointer_cast(para->getParD(level)->vz_SP); + + real N = (real)probeStruct->nIndices; + real n = (real)probeStruct->vals; + uint nPoints = probeStruct->nPoints; + // Permutation iterators for direct iteration over the velocities of the planes + typedef thrust::device_vector<real>::iterator valIterator; + typedef thrust::device_vector<uint>::iterator indIterator; + thrust::permutation_iterator<valIterator, indIterator> vx_iter_begin(vx_thrust, indices_thrust); + thrust::permutation_iterator<valIterator, indIterator> vx_iter_end (vx_thrust, indices_thrust+probeStruct->nIndices); + thrust::permutation_iterator<valIterator, indIterator> vy_iter_begin(vy_thrust, indices_thrust); + thrust::permutation_iterator<valIterator, indIterator> vy_iter_end (vy_thrust, indices_thrust+probeStruct->nIndices); + thrust::permutation_iterator<valIterator, indIterator> vz_iter_begin(vz_thrust, indices_thrust); + thrust::permutation_iterator<valIterator, indIterator> vz_iter_end (vz_thrust, indices_thrust+probeStruct->nIndices); + + for( uint i=0; i<nPoints; i++ ) + { + uint node = this->isEvenTAvg? i : nPoints-1-i; // Note, loop moves in positive normal dir at even calls and in negative normal dir in odd calls + + if(probeStruct->quantitiesH[int(Statistic::SpatialMeans)]) + { + // Compute the instantaneous spatial means of the velocity moments + real spatMean_vx = thrust::reduce(vx_iter_begin, vx_iter_end)/N; + real spatMean_vy = thrust::reduce(vy_iter_begin, vy_iter_end)/N; + real spatMean_vz = thrust::reduce(vz_iter_begin, vz_iter_end)/N; + + uint arrOff = probeStruct->arrayOffsetsH[int(Statistic::SpatialMeans)]; + probeStruct->quantitiesArrayH[(arrOff+0)*nPoints+node] = spatMean_vx; + probeStruct->quantitiesArrayH[(arrOff+1)*nPoints+node] = spatMean_vy; + probeStruct->quantitiesArrayH[(arrOff+2)*nPoints+node] = spatMean_vz; + + if(probeStruct->quantitiesH[int(Statistic::SpatioTemporalMeans)] && doTmpAveraging) + { + uint arrOff = probeStruct->arrayOffsetsH[int(Statistic::SpatioTemporalMeans)]; + real spatTmpMean_vx_old = probeStruct->quantitiesArrayH[(arrOff+0)*nPoints+node]; + real spatTmpMean_vy_old = probeStruct->quantitiesArrayH[(arrOff+1)*nPoints+node]; + real spatTmpMean_vz_old = probeStruct->quantitiesArrayH[(arrOff+2)*nPoints+node]; + + probeStruct->quantitiesArrayH[(arrOff+0)*nPoints+node] += (spatMean_vx-spatTmpMean_vx_old)/n; + probeStruct->quantitiesArrayH[(arrOff+1)*nPoints+node] += (spatMean_vy-spatTmpMean_vy_old)/n; + probeStruct->quantitiesArrayH[(arrOff+2)*nPoints+node] += (spatMean_vz-spatTmpMean_vz_old)/n; + } + + if(probeStruct->quantitiesH[int(Statistic::SpatialCovariances)]) + { // <u_i' u_j'> = <u_i u_j> - <u_i>*<u_i> + real vx2 = thrust::transform_reduce(vx_iter_begin, vx_iter_end, pow2<real>(), 0.f, thrust::plus<real>())/N; + real vy2 = thrust::transform_reduce(vy_iter_begin, vy_iter_end, pow2<real>(), 0.f, thrust::plus<real>())/N; + real vz2 = thrust::transform_reduce(vz_iter_begin, vz_iter_end, pow2<real>(), 0.f, thrust::plus<real>())/N; + real vxvy = thrust::inner_product(vx_iter_begin, vx_iter_end, vy_iter_begin, 0.f)/N; + real vxvz = thrust::inner_product(vx_iter_begin, vx_iter_end, vz_iter_begin, 0.f)/N; + real vyvz = thrust::inner_product(vy_iter_begin, vy_iter_end, vz_iter_begin, 0.f)/N; + real spatMean_vxvx = vx2-spatMean_vx*spatMean_vx; + real spatMean_vyvy = vy2-spatMean_vy*spatMean_vy; + real spatMean_vzvz = vz2-spatMean_vz*spatMean_vz; + real spatMean_vxvy = vxvy-spatMean_vx*spatMean_vy; + real spatMean_vxvz = vxvz-spatMean_vx*spatMean_vz; + real spatMean_vyvz = vyvz-spatMean_vy*spatMean_vz; + + uint arrOff = probeStruct->arrayOffsetsH[int(Statistic::SpatialCovariances)]; + probeStruct->quantitiesArrayH[(arrOff+0)*nPoints+node] = spatMean_vxvx; + probeStruct->quantitiesArrayH[(arrOff+1)*nPoints+node] = spatMean_vyvy; + probeStruct->quantitiesArrayH[(arrOff+2)*nPoints+node] = spatMean_vzvz; + probeStruct->quantitiesArrayH[(arrOff+3)*nPoints+node] = spatMean_vxvy; + probeStruct->quantitiesArrayH[(arrOff+4)*nPoints+node] = spatMean_vxvz; + probeStruct->quantitiesArrayH[(arrOff+5)*nPoints+node] = spatMean_vyvz; + + if(probeStruct->quantitiesH[int(Statistic::SpatioTemporalCovariances)] && doTmpAveraging) + { + uint arrOff = probeStruct->arrayOffsetsH[int(Statistic::SpatioTemporalCovariances)]; + real spatTmpMean_vxvx_old = probeStruct->quantitiesArrayH[(arrOff+0)*nPoints+node]; + real spatTmpMean_vyvy_old = probeStruct->quantitiesArrayH[(arrOff+1)*nPoints+node]; + real spatTmpMean_vzvz_old = probeStruct->quantitiesArrayH[(arrOff+2)*nPoints+node]; + real spatTmpMean_vxvy_old = probeStruct->quantitiesArrayH[(arrOff+3)*nPoints+node]; + real spatTmpMean_vxvz_old = probeStruct->quantitiesArrayH[(arrOff+4)*nPoints+node]; + real spatTmpMean_vyvz_old = probeStruct->quantitiesArrayH[(arrOff+5)*nPoints+node]; + + probeStruct->quantitiesArrayH[(arrOff+0)*nPoints+node] += (spatMean_vxvx-spatTmpMean_vxvx_old)/n; + probeStruct->quantitiesArrayH[(arrOff+1)*nPoints+node] += (spatMean_vyvy-spatTmpMean_vyvy_old)/n; + probeStruct->quantitiesArrayH[(arrOff+2)*nPoints+node] += (spatMean_vzvz-spatTmpMean_vzvz_old)/n; + probeStruct->quantitiesArrayH[(arrOff+3)*nPoints+node] += (spatMean_vxvy-spatTmpMean_vxvy_old)/n; + probeStruct->quantitiesArrayH[(arrOff+4)*nPoints+node] += (spatMean_vxvz-spatTmpMean_vxvz_old)/n; + probeStruct->quantitiesArrayH[(arrOff+5)*nPoints+node] += (spatMean_vyvz-spatTmpMean_vyvz_old)/n; + } + + if(probeStruct->quantitiesH[int(Statistic::SpatialSkewness)]) + { // <u_i'^3> = <u_i^3> - <u_i>^3 - 3 <u_i> <u_i'^2> + // real vx3 = thrust::transform_reduce(vx_iter_begin, vx_iter_end, pow3<real>(), 0.f, thrust::plus<real>())/N; + // real vy3 = thrust::transform_reduce(vy_iter_begin, vy_iter_end, pow3<real>(), 0.f, thrust::plus<real>())/N; + // real vz3 = thrust::transform_reduce(vz_iter_begin, vz_iter_end, pow3<real>(), 0.f, thrust::plus<real>())/N; + real spatMean_vxvxvx = thrust::transform_reduce(vx_iter_begin, vx_iter_end, nth_moment(spatMean_vx, 3), 0.f, thrust::plus<real>())/N; + //vx3 - spatMean_vx*spatMean_vx*spatMean_vx - 3*spatMean_vx*spatMean_vxvx; -> alternative only using vx3, etc. but containing some bug. Potentially better in terms of round-off errors. + real spatMean_vyvyvy = thrust::transform_reduce(vy_iter_begin, vy_iter_end, nth_moment(spatMean_vy, 3), 0.f, thrust::plus<real>())/N; + //vy3 - spatMean_vy*spatMean_vy*spatMean_vy - 3*spatMean_vy*spatMean_vzvz; + real spatMean_vzvzvz = thrust::transform_reduce(vz_iter_begin, vz_iter_end, nth_moment(spatMean_vz, 3), 0.f, thrust::plus<real>())/N; + //vz3 - spatMean_vz*spatMean_vz*spatMean_vz - 3*spatMean_vz*spatMean_vzvz; + real spatMean_Sx = spatMean_vxvxvx/pow(spatMean_vxvx, 1.5f); + real spatMean_Sy = spatMean_vyvyvy/pow(spatMean_vyvy, 1.5f); + real spatMean_Sz = spatMean_vzvzvz/pow(spatMean_vzvz, 1.5f); + + uint arrOff = probeStruct->arrayOffsetsH[int(Statistic::SpatialSkewness)]; + probeStruct->quantitiesArrayH[(arrOff+0)*nPoints+node] = spatMean_Sx; + probeStruct->quantitiesArrayH[(arrOff+1)*nPoints+node] = spatMean_Sy; + probeStruct->quantitiesArrayH[(arrOff+2)*nPoints+node] = spatMean_Sz; + + if(probeStruct->quantitiesH[int(Statistic::SpatioTemporalSkewness)] && doTmpAveraging) + { + uint arrOff = probeStruct->arrayOffsetsH[int(Statistic::SpatioTemporalSkewness)]; + real spatTmpMean_Sx_old = probeStruct->quantitiesArrayH[(arrOff+0)*nPoints+node]; + real spatTmpMean_Sy_old = probeStruct->quantitiesArrayH[(arrOff+1)*nPoints+node]; + real spatTmpMean_Sz_old = probeStruct->quantitiesArrayH[(arrOff+2)*nPoints+node]; + + probeStruct->quantitiesArrayH[(arrOff+0)*nPoints+node] += (spatMean_Sx-spatTmpMean_Sx_old)/n; + probeStruct->quantitiesArrayH[(arrOff+1)*nPoints+node] += (spatMean_Sy-spatTmpMean_Sy_old)/n; + probeStruct->quantitiesArrayH[(arrOff+2)*nPoints+node] += (spatMean_Sz-spatTmpMean_Sz_old)/n; + } + + if(probeStruct->quantitiesH[int(Statistic::SpatialFlatness)]) + { // <u_i'^4> = <u_i^4> - <u_i>^4 - 6 <u_i>^2 <u_i'^2> - 4 <u> <u'^3> + // real vx4 = thrust::transform_reduce(vx_iter_begin, vx_iter_end, pow4<real>(), 0.f, thrust::plus<real>())/N; + // real vy4 = thrust::transform_reduce(vy_iter_begin, vy_iter_end, pow4<real>(), 0.f, thrust::plus<real>())/N; + // real vz4 = thrust::transform_reduce(vz_iter_begin, vz_iter_end, pow4<real>(), 0.f, thrust::plus<real>())/N; + real spatMean_vxvxvxvx = thrust::transform_reduce(vx_iter_begin, vx_iter_end, nth_moment(spatMean_vx, 4), 0.f, thrust::plus<real>())/N; //vx4 - spatMean_vx*spatMean_vx*spatMean_vx*spatMean_vx - 6*spatMean_vx*spatMean_vx*vx2 - 4*spatMean_vx*vx3; + real spatMean_vyvyvyvy = thrust::transform_reduce(vy_iter_begin, vy_iter_end, nth_moment(spatMean_vy, 4), 0.f, thrust::plus<real>())/N; //vy4 - spatMean_vy*spatMean_vy*spatMean_vy*spatMean_vy - 6*spatMean_vy*spatMean_vx*vy2 - 4*spatMean_vy*vy3; + real spatMean_vzvzvzvz = thrust::transform_reduce(vz_iter_begin, vz_iter_end, nth_moment(spatMean_vz, 4), 0.f, thrust::plus<real>())/N; //vz4 - spatMean_vz*spatMean_vz*spatMean_vz*spatMean_vz - 6*spatMean_vz*spatMean_vx*vz2 - 4*spatMean_vz*vz3; + real spatMean_Fx = spatMean_vxvxvxvx/(spatMean_vxvx*spatMean_vxvx); + real spatMean_Fy = spatMean_vyvyvyvy/(spatMean_vyvy*spatMean_vyvy); + real spatMean_Fz = spatMean_vzvzvzvz/(spatMean_vzvz*spatMean_vzvz); + + uint arrOff = probeStruct->arrayOffsetsH[int(Statistic::SpatialFlatness)]; + probeStruct->quantitiesArrayH[(arrOff+0)*nPoints+node] = spatMean_Fx; + probeStruct->quantitiesArrayH[(arrOff+1)*nPoints+node] = spatMean_Fy; + probeStruct->quantitiesArrayH[(arrOff+2)*nPoints+node] = spatMean_Fz; + + if(probeStruct->quantitiesH[int(Statistic::SpatioTemporalFlatness)] && doTmpAveraging) + { + uint arrOff = probeStruct->arrayOffsetsH[int(Statistic::SpatioTemporalFlatness)]; + real spatTmpMean_Fx_old = probeStruct->quantitiesArrayH[(arrOff+0)*nPoints+node]; + real spatTmpMean_Fy_old = probeStruct->quantitiesArrayH[(arrOff+1)*nPoints+node]; + real spatTmpMean_Fz_old = probeStruct->quantitiesArrayH[(arrOff+2)*nPoints+node]; + + probeStruct->quantitiesArrayH[(arrOff+0)*nPoints+node] += (spatMean_Fx-spatTmpMean_Fx_old)/n; + probeStruct->quantitiesArrayH[(arrOff+1)*nPoints+node] += (spatMean_Fy-spatTmpMean_Fy_old)/n; + probeStruct->quantitiesArrayH[(arrOff+2)*nPoints+node] += (spatMean_Fz-spatTmpMean_Fz_old)/n; + } + } + } + } + } + if(i<probeStruct->nPoints-1) + { + vf::cuda::CudaGrid grid = vf::cuda::CudaGrid(para->getParH(level)->numberofthreads, probeStruct->nIndices); + if(this->isEvenTAvg) + moveIndicesInPosNormalDir<<<grid.grid, grid.threads>>>( probeStruct->pointIndicesD, probeStruct->nIndices, neighborNormal, para->getParD(level)->coordX_SP, para->getParD(level)->coordY_SP, para->getParD(level)->coordZ_SP ); + else + moveIndicesInNegNormalDir<<<grid.grid, grid.threads>>>( probeStruct->pointIndicesD, probeStruct->nIndices, para->getParD(level)->neighborWSB_SP, neighborInplane1, neighborInplane2, para->getParD(level)->coordX_SP, para->getParD(level)->coordY_SP, para->getParD(level)->coordZ_SP ); + } + } + this->isEvenTAvg=!this->isEvenTAvg; + + getLastCudaError("PlanarAverageProbe::calculateQuantities execution failed"); +} diff --git a/src/gpu/VirtualFluids_GPU/PreCollisionInteractor/Probes/PlanarAverageProbe.h b/src/gpu/VirtualFluids_GPU/PreCollisionInteractor/Probes/PlanarAverageProbe.h new file mode 100644 index 0000000000000000000000000000000000000000..7054f5fc7e02453418285281a0ea9cf9c32dc0c0 --- /dev/null +++ b/src/gpu/VirtualFluids_GPU/PreCollisionInteractor/Probes/PlanarAverageProbe.h @@ -0,0 +1,97 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids 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. +// +// VirtualFluids 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 VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file PlanarAverageProbe.h +//! \author Henrik Asmuth +//! \date 13/05/2022 +//! \brief Probe computing statistics across planes spanning the entire domain +//! +//! Computes spatial statistics across x, y or z-normal planes defined by planeNormal. +//! The planes include all points of the domain at each respective position along that normal direction. +//! The spatial statistics can additionally be averaged in time. +//! +//======================================================================================= + +#ifndef PlanarAverageProbe_H +#define PlanarAverageProbe_H + +#include "Probe.h" + +__global__ void moveIndicesInNegNormalDir( uint* pointIndices, uint nPoints, uint* neighborWSB, uint* neighborInplane1, uint* neighborInplane2, real* coordsX, real* coordsY, real* coordsZ ); + +__global__ void moveIndicesInPosNormalDir( uint* pointIndices, uint nPoints, uint* neighborNormal, real* coordsX, real* coordsY, real* coordsZ ); + +/////////////////////////////////////////////////////////////////////////////////// + +class PlanarAverageProbe : public Probe +{ +public: + PlanarAverageProbe( + const std::string _probeName, + const std::string _outputPath, + uint _tStartAvg, + uint _tStartTmpAvg, + uint _tAvg, + uint _tStartOut, + uint _tOut, + char _planeNormal + ): Probe(_probeName, + _outputPath, + _tStartAvg, + _tStartTmpAvg, + _tAvg, + _tStartOut, + _tOut, + false, + false), + planeNormal(_planeNormal) + + { + assert(_planeNormal == 'x' || _planeNormal == 'y' || _planeNormal == 'z'); + } + + +private: + bool isAvailableStatistic(Statistic _variable) override; + + std::vector<PostProcessingVariable> getPostProcessingVariables(Statistic variable) override; + + void findPoints(Parameter* para, GridProvider* gridProvider, std::vector<int>& probeIndices_level, + std::vector<real>& distX_level, std::vector<real>& distY_level, std::vector<real>& distZ_level, + std::vector<real>& pointCoordsX_level, std::vector<real>& pointCoordsY_level, std::vector<real>& pointCoordsZ_level, + int level) override; + void calculateQuantities(SPtr<ProbeStruct> probeStruct, Parameter* para, uint t, int level) override; + +private: + real posX, posY, posZ; + real deltaX, deltaY, deltaZ; + char planeNormal; + bool isEvenTAvg = true; +}; + +#endif \ No newline at end of file diff --git a/src/gpu/VirtualFluids_GPU/PreCollisionInteractor/Probes/PlaneProbe.cu b/src/gpu/VirtualFluids_GPU/PreCollisionInteractor/Probes/PlaneProbe.cu new file mode 100644 index 0000000000000000000000000000000000000000..15f10d8203a5d688da7f6bd18a976eaad5776b5c --- /dev/null +++ b/src/gpu/VirtualFluids_GPU/PreCollisionInteractor/Probes/PlaneProbe.cu @@ -0,0 +1,110 @@ +#include "Probe.h" +#include "PlaneProbe.h" + +#include <cuda/CudaGrid.h> + +#include <cuda.h> +#include <cuda_runtime.h> +#include <helper_cuda.h> + +#include "Parameter/Parameter.h" +#include "DataStructureInitializer/GridProvider.h" +#include "GPU/CudaMemoryManager.h" + + +bool PlaneProbe::isAvailableStatistic(Statistic _variable) +{ + bool isAvailable; + switch (_variable) + { + case Statistic::Instantaneous: + case Statistic::Means: + case Statistic::Variances: + isAvailable = true; + break; + case Statistic::SpatialMeans: + case Statistic::SpatioTemporalMeans: + case Statistic::SpatialCovariances: + case Statistic::SpatioTemporalCovariances: + case Statistic::SpatialSkewness: + case Statistic::SpatioTemporalSkewness: + case Statistic::SpatialFlatness: + case Statistic::SpatioTemporalFlatness: + isAvailable = false; + break; + default: + isAvailable = false; + } + return isAvailable; +} + + +std::vector<PostProcessingVariable> PlaneProbe::getPostProcessingVariables(Statistic statistic) +{ + std::vector<PostProcessingVariable> postProcessingVariables; + switch (statistic) + { + case Statistic::Instantaneous: + postProcessingVariables.push_back( PostProcessingVariable("vx", this->velocityRatio) ); + postProcessingVariables.push_back( PostProcessingVariable("vy", this->velocityRatio) ); + postProcessingVariables.push_back( PostProcessingVariable("vz", this->velocityRatio) ); + postProcessingVariables.push_back( PostProcessingVariable("rho", this->densityRatio ) ); + break; + case Statistic::Means: + postProcessingVariables.push_back( PostProcessingVariable("vx_mean", this->velocityRatio) ); + postProcessingVariables.push_back( PostProcessingVariable("vy_mean", this->velocityRatio) ); + postProcessingVariables.push_back( PostProcessingVariable("vz_mean", this->velocityRatio) ); + postProcessingVariables.push_back( PostProcessingVariable("rho_mean", this->densityRatio ) ); + break; + case Statistic::Variances: + postProcessingVariables.push_back( PostProcessingVariable("vx_var", pow(this->velocityRatio, 2.0)) ); + postProcessingVariables.push_back( PostProcessingVariable("vy_var", pow(this->velocityRatio, 2.0)) ); + postProcessingVariables.push_back( PostProcessingVariable("vz_var", pow(this->velocityRatio, 2.0)) ); + postProcessingVariables.push_back( PostProcessingVariable("rho_var", pow(this->densityRatio, 2.0)) ); + break; + + default: + printf("Statistic unavailable in PlaneProbe\n"); + assert(false); + break; + } + return postProcessingVariables; +} + +void PlaneProbe::findPoints(Parameter* para, GridProvider* gridProvider, std::vector<int>& probeIndices_level, + std::vector<real>& distX_level, std::vector<real>& distY_level, std::vector<real>& distZ_level, + std::vector<real>& pointCoordsX_level, std::vector<real>& pointCoordsY_level, std::vector<real>& pointCoordsZ_level, + int level) +{ + real dx = abs(para->getParH(level)->coordX_SP[1]-para->getParH(level)->coordX_SP[para->getParH(level)->neighborX_SP[1]]); + for(uint j=1; j<para->getParH(level)->size_Mat_SP; j++ ) + { + real pointCoordX = para->getParH(level)->coordX_SP[j]; + real pointCoordY = para->getParH(level)->coordY_SP[j]; + real pointCoordZ = para->getParH(level)->coordZ_SP[j]; + real distX = pointCoordX - this->posX; + real distY = pointCoordY - this->posY; + real distZ = pointCoordZ - this->posZ; + + if( distX <= this->deltaX && distY <= this->deltaY && distZ <= this->deltaZ && + distX >=0.f && distY >=0.f && distZ >=0.f) + { + probeIndices_level.push_back(j); + distX_level.push_back( distX/dx ); + distY_level.push_back( distY/dx ); + distZ_level.push_back( distZ/dx ); + pointCoordsX_level.push_back( pointCoordX ); + pointCoordsY_level.push_back( pointCoordY ); + pointCoordsZ_level.push_back( pointCoordZ ); + } + } +} + +void PlaneProbe::calculateQuantities(SPtr<ProbeStruct> probeStruct, Parameter* para, uint t, int level) +{ + vf::cuda::CudaGrid grid = vf::cuda::CudaGrid(para->getParH(level)->numberofthreads, probeStruct->nPoints); + calcQuantitiesKernel<<<grid.grid, grid.threads>>>( probeStruct->pointIndicesD, probeStruct->nPoints, probeStruct->vals, + para->getParD(level)->vx_SP, para->getParD(level)->vy_SP, para->getParD(level)->vz_SP, para->getParD(level)->rho_SP, + para->getParD(level)->neighborX_SP, para->getParD(level)->neighborY_SP, para->getParD(level)->neighborZ_SP, + probeStruct->quantitiesD, probeStruct->arrayOffsetsD, probeStruct->quantitiesArrayD); +} \ No newline at end of file diff --git a/src/gpu/VirtualFluids_GPU/PreCollisionInteractor/Probes/PlaneProbe.h b/src/gpu/VirtualFluids_GPU/PreCollisionInteractor/Probes/PlaneProbe.h new file mode 100644 index 0000000000000000000000000000000000000000..3440c01020f9b3505be7148024e47373b76648ff --- /dev/null +++ b/src/gpu/VirtualFluids_GPU/PreCollisionInteractor/Probes/PlaneProbe.h @@ -0,0 +1,91 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids 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. +// +// VirtualFluids 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 VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file PlaneProbe.h +//! \author Henry Korb, Henrik Asmuth +//! \date 13/05/2022 +//! \brief Probe computing point-wise statistics for a set of points across a plane +//! +//! The set of points can be defined by providing a list or on an x-normal plane. +//! All statistics are temporal. +//! +//======================================================================================= + +#ifndef PlaneProbe_H +#define PlaneProbe_H + +#include "Probe.h" + +class PlaneProbe : public Probe +{ +public: + PlaneProbe( + const std::string _probeName, + const std::string _outputPath, + uint _tStartAvg, + uint _tAvg, + uint _tStartOut, + uint _tOut + ): Probe(_probeName, + _outputPath, + _tStartAvg, + 0, + _tAvg, + _tStartOut, + _tOut, + true, + false) + {} + + void setProbePlane(real _posX, real _posY, real _posZ, real _deltaX, real _deltaY, real _deltaZ) + { + this->posX = _posX; + this->posY = _posY; + this->posZ = _posZ; + this->deltaX = _deltaX; + this->deltaY = _deltaY; + this->deltaZ = _deltaZ; + } + +private: + bool isAvailableStatistic(Statistic _variable) override; + + std::vector<PostProcessingVariable> getPostProcessingVariables(Statistic variable) override; + + void findPoints(Parameter* para, GridProvider* gridProvider, std::vector<int>& probeIndices_level, + std::vector<real>& distX_level, std::vector<real>& distY_level, std::vector<real>& distZ_level, + std::vector<real>& pointCoordsX_level, std::vector<real>& pointCoordsY_level, std::vector<real>& pointCoordsZ_level, + int level) override; + void calculateQuantities(SPtr<ProbeStruct> probeStruct, Parameter* para, uint t, int level) override; + +private: + real posX, posY, posZ; + real deltaX, deltaY, deltaZ; +}; + +#endif \ No newline at end of file diff --git a/src/gpu/VirtualFluids_GPU/PreCollisionInteractor/Probes/PointProbe.cu b/src/gpu/VirtualFluids_GPU/PreCollisionInteractor/Probes/PointProbe.cu new file mode 100644 index 0000000000000000000000000000000000000000..7c0b5947a03330997678b55d7d8063685dca4e1c --- /dev/null +++ b/src/gpu/VirtualFluids_GPU/PreCollisionInteractor/Probes/PointProbe.cu @@ -0,0 +1,144 @@ +#include "Probe.h" +#include "PointProbe.h" + +#include <cuda.h> +#include <cuda_runtime.h> +#include <helper_cuda.h> + +#include <cuda/CudaGrid.h> + +#include "Parameter/Parameter.h" +#include "DataStructureInitializer/GridProvider.h" +#include "GPU/CudaMemoryManager.h" + +bool PointProbe::isAvailableStatistic(Statistic _variable) +{ + bool isAvailable; + switch (_variable) + { + case Statistic::Instantaneous: + case Statistic::Means: + case Statistic::Variances: + isAvailable = true; + break; + case Statistic::SpatialMeans: + case Statistic::SpatioTemporalMeans: + case Statistic::SpatialCovariances: + case Statistic::SpatioTemporalCovariances: + case Statistic::SpatialSkewness: + case Statistic::SpatioTemporalSkewness: + case Statistic::SpatialFlatness: + case Statistic::SpatioTemporalFlatness: + isAvailable = false; + break; + default: + isAvailable = false; + } + return isAvailable; +} + +std::vector<PostProcessingVariable> PointProbe::getPostProcessingVariables(Statistic statistic) +{ + std::vector<PostProcessingVariable> postProcessingVariables; + switch (statistic) + { + case Statistic::Instantaneous: + postProcessingVariables.push_back( PostProcessingVariable("vx", velocityRatio) ); + postProcessingVariables.push_back( PostProcessingVariable("vy", this->velocityRatio) ); + postProcessingVariables.push_back( PostProcessingVariable("vz", this->velocityRatio) ); + postProcessingVariables.push_back( PostProcessingVariable("rho", this->densityRatio ) ); + break; + case Statistic::Means: + postProcessingVariables.push_back( PostProcessingVariable("vx_mean", this->velocityRatio) ); + postProcessingVariables.push_back( PostProcessingVariable("vy_mean", this->velocityRatio) ); + postProcessingVariables.push_back( PostProcessingVariable("vz_mean", this->velocityRatio) ); + postProcessingVariables.push_back( PostProcessingVariable("rho_mean", this->densityRatio ) ); + break; + case Statistic::Variances: + postProcessingVariables.push_back( PostProcessingVariable("vx_var", pow(this->velocityRatio, 2.0)) ); + postProcessingVariables.push_back( PostProcessingVariable("vy_var", pow(this->velocityRatio, 2.0)) ); + postProcessingVariables.push_back( PostProcessingVariable("vz_var", pow(this->velocityRatio, 2.0)) ); + postProcessingVariables.push_back( PostProcessingVariable("rho_var", pow(this->densityRatio, 2.0)) ); + break; + + default: + printf("Statistic unavailable in PointProbe\n"); + assert(false); + break; + } + return postProcessingVariables; +} + +void PointProbe::findPoints(Parameter* para, GridProvider* gridProvider, std::vector<int>& probeIndices_level, + std::vector<real>& distX_level, std::vector<real>& distY_level, std::vector<real>& distZ_level, + std::vector<real>& pointCoordsX_level, std::vector<real>& pointCoordsY_level, std::vector<real>& pointCoordsZ_level, + int level) +{ + + real dx = abs(para->getParH(level)->coordX_SP[1]-para->getParH(level)->coordX_SP[para->getParH(level)->neighborX_SP[1]]); + for(uint j=1; j<para->getParH(level)->size_Mat_SP; j++ ) + { + for(uint point=0; point<this->pointCoordsX.size(); point++) + { + real pointCoordX = this->pointCoordsX[point]; + real pointCoordY = this->pointCoordsY[point]; + real pointCoordZ = this->pointCoordsZ[point]; + real distX = pointCoordX-para->getParH(level)->coordX_SP[j]; + real distY = pointCoordY-para->getParH(level)->coordY_SP[j]; + real distZ = pointCoordZ-para->getParH(level)->coordZ_SP[j]; + if( distX <=dx && distY <=dx && distZ <=dx && + distX >0.f && distY >0.f && distZ >0.f) + { + probeIndices_level.push_back(j); + distX_level.push_back( distX/dx ); + distY_level.push_back( distY/dx ); + distZ_level.push_back( distZ/dx ); + pointCoordsX_level.push_back( pointCoordX ); + pointCoordsY_level.push_back( pointCoordY ); + pointCoordsZ_level.push_back( pointCoordZ ); + } + } + } +} + +void PointProbe::calculateQuantities(SPtr<ProbeStruct> probeStruct, Parameter* para, uint t, int level) +{ + vf::cuda::CudaGrid grid = vf::cuda::CudaGrid(para->getParH(level)->numberofthreads, probeStruct->nPoints); + interpAndCalcQuantitiesKernel<<<grid.grid, grid.threads>>>( probeStruct->pointIndicesD, probeStruct->nPoints, probeStruct->vals, + probeStruct->distXD, probeStruct->distYD, probeStruct->distZD, + para->getParD(level)->vx_SP, para->getParD(level)->vy_SP, para->getParD(level)->vz_SP, para->getParD(level)->rho_SP, + para->getParD(level)->neighborX_SP, para->getParD(level)->neighborY_SP, para->getParD(level)->neighborZ_SP, + probeStruct->quantitiesD, probeStruct->arrayOffsetsD, probeStruct->quantitiesArrayD); +} + +void PointProbe::addProbePointsFromList(std::vector<real>& _pointCoordsX, std::vector<real>& _pointCoordsY, std::vector<real>& _pointCoordsZ) +{ + bool isSameLength = ( (_pointCoordsX.size()==_pointCoordsY.size()) && (_pointCoordsY.size()==_pointCoordsZ.size())); + assert("Probe: point lists have different lengths" && isSameLength); + this->pointCoordsX.insert(this->pointCoordsX.end(), _pointCoordsX.begin(), _pointCoordsX.end()); + this->pointCoordsY.insert(this->pointCoordsY.end(), _pointCoordsY.begin(), _pointCoordsY.end()); + this->pointCoordsZ.insert(this->pointCoordsZ.end(), _pointCoordsZ.begin(), _pointCoordsZ.end()); + printf("Added list of %u points \n", uint(_pointCoordsX.size()) ); +} + +void PointProbe::addProbePointsFromXNormalPlane(real pos_x, real pos0_y, real pos0_z, real pos1_y, real pos1_z, uint n_y, uint n_z) +{ + int delta_y = (pos1_y-pos0_y)/(n_y-1); + int delta_z = (pos1_z-pos0_z)/(n_z-1); + + this->pointCoordsX.reserve(this->pointCoordsX.size()+n_y*n_z); + this->pointCoordsY.reserve(this->pointCoordsY.size()+n_y*n_z); + this->pointCoordsZ.reserve(this->pointCoordsZ.size()+n_y*n_z); + + for(int n_y=0; n_y<n_y; n_y++) + { + for(int n_z=0; n_z<n_z; n_z++) + { + this->pointCoordsX.push_back(pos_x); + this->pointCoordsY.push_back(pos0_y+delta_y*n_y); + this->pointCoordsZ.push_back(pos0_z+delta_z*n_z); + } + } + printf("Added %u points \n", n_y*n_z); + +} \ No newline at end of file diff --git a/src/gpu/VirtualFluids_GPU/PreCollisionInteractor/Probes/PointProbe.h b/src/gpu/VirtualFluids_GPU/PreCollisionInteractor/Probes/PointProbe.h new file mode 100644 index 0000000000000000000000000000000000000000..6a6fbe76f089acfafc22672dd3e9d71bd193a3b3 --- /dev/null +++ b/src/gpu/VirtualFluids_GPU/PreCollisionInteractor/Probes/PointProbe.h @@ -0,0 +1,85 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids 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. +// +// VirtualFluids 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 VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file PointProbe.h +//! \author Henry Korb, Henrik Asmuth +//! \date 13/05/2022 +//! \brief Probe computing statistics for a set of points in space +//! +//! The set of points can be defined by providing a list or on an x-normal plane (the latter being somewhat redundant with PlaneProbe) +//! All statistics are temporal. +//! +//======================================================================================= + +#ifndef PointProbe_H +#define PointProbe_H + +#include "Probe.h" + +class PointProbe: public Probe +{ +public: + PointProbe( + const std::string _probeName, + const std::string _outputPath, + uint _tStartAvg, + uint _tAvg, + uint _tStartOut, + uint _tOut + ): Probe(_probeName, + _outputPath, + _tStartAvg, + 0, + _tAvg, + _tStartOut, + _tOut, + true, + false) + {} + + void addProbePointsFromList(std::vector<real>& _pointCoordsX, std::vector<real>& _pointCoordsY, std::vector<real>& _pointCoordsZ); + void addProbePointsFromXNormalPlane(real pos_x, real pos0_y, real pos0_z, real pos1_y, real pos1_z, uint n_y, uint n_z); + +private: + bool isAvailableStatistic(Statistic _variable) override; + + std::vector<PostProcessingVariable> getPostProcessingVariables(Statistic variable) override; + + void findPoints(Parameter* para, GridProvider* gridProvider, std::vector<int>& probeIndices_level, + std::vector<real>& distX_level, std::vector<real>& distY_level, std::vector<real>& distZ_level, + std::vector<real>& pointCoordsX_level, std::vector<real>& pointCoordsY_level, std::vector<real>& pointCoordsZ_level, + int level) override; + + void calculateQuantities(SPtr<ProbeStruct> probeStruct, Parameter* para, uint t, int level) override; + +private: + std::vector<real> pointCoordsX, pointCoordsY, pointCoordsZ; + +}; + +#endif \ No newline at end of file diff --git a/src/gpu/VirtualFluids_GPU/PreCollisionInteractor/Probes/Probe.cu b/src/gpu/VirtualFluids_GPU/PreCollisionInteractor/Probes/Probe.cu new file mode 100644 index 0000000000000000000000000000000000000000..17679f4ff5292f83f8a6758aa55e588db7042472 --- /dev/null +++ b/src/gpu/VirtualFluids_GPU/PreCollisionInteractor/Probes/Probe.cu @@ -0,0 +1,465 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids 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. +// +// VirtualFluids 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 VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file Probe.h +//! \author Henry Korb, Henrik Asmuth +//======================================================================================= + +#include "Probe.h" + +#include <cuda.h> +#include <cuda_runtime.h> +#include <helper_cuda.h> + +#include "VirtualFluids_GPU/GPU/GeometryUtils.h" +#include "basics/writer/WbWriterVtkXmlBinary.h" +#include <Core/StringUtilities/StringUtil.h> + +#include "Parameter/Parameter.h" +#include "DataStructureInitializer/GridProvider.h" +#include "GPU/CudaMemoryManager.h" + + +__device__ void calculatePointwiseQuantities(uint n, real* quantityArray, bool* quantities, uint* quantityArrayOffsets, uint nPoints, uint node, real vx, real vy, real vz, real rho) +{ + //"https://en.wikipedia.org/wiki/Algorithms_for_calculating_variance#Welford's_online_algorithm" + // also has extensions for higher order and covariances + real inv_n = 1/real(n); + + if(quantities[int(Statistic::Instantaneous)]) + { + uint arrOff = quantityArrayOffsets[int(Statistic::Instantaneous)]; + quantityArray[(arrOff+0)*nPoints+node] = vx; + quantityArray[(arrOff+1)*nPoints+node] = vy; + quantityArray[(arrOff+2)*nPoints+node] = vz; + quantityArray[(arrOff+3)*nPoints+node] = rho; + } + + if(quantities[int(Statistic::Means)]) + { + + uint arrOff = quantityArrayOffsets[int(Statistic::Means)]; + real vx_m_old = quantityArray[(arrOff+0)*nPoints+node]; + real vy_m_old = quantityArray[(arrOff+1)*nPoints+node]; + real vz_m_old = quantityArray[(arrOff+2)*nPoints+node]; + real rho_m_old = quantityArray[(arrOff+3)*nPoints+node]; + + real vx_m_new = ( (n-1)*vx_m_old + vx )*inv_n; + real vy_m_new = ( (n-1)*vy_m_old + vy )*inv_n; + real vz_m_new = ( (n-1)*vz_m_old + vz )*inv_n; + real rho_m_new = ( (n-1)*rho_m_old+ rho )*inv_n; + + quantityArray[(arrOff+0)*nPoints+node] = vx_m_new; + quantityArray[(arrOff+1)*nPoints+node] = vy_m_new; + quantityArray[(arrOff+2)*nPoints+node] = vz_m_new; + quantityArray[(arrOff+3)*nPoints+node] = rho_m_new; + + if(quantities[int(Statistic::Variances)]) + { + arrOff = quantityArrayOffsets[int(Statistic::Variances)]; + + real vx_var_old = quantityArray[(arrOff+0)*nPoints+node]; + real vy_var_old = quantityArray[(arrOff+1)*nPoints+node]; + real vz_var_old = quantityArray[(arrOff+2)*nPoints+node]; + real rho_var_old = quantityArray[(arrOff+3)*nPoints+node]; + + real vx_var_new = ( (n-1)*(vx_var_old )+(vx - vx_m_old )*(vx - vx_m_new ) )*inv_n; + real vy_var_new = ( (n-1)*(vy_var_old )+(vy - vy_m_old )*(vy - vy_m_new ) )*inv_n; + real vz_var_new = ( (n-1)*(vz_var_old )+(vz - vz_m_old )*(vz - vz_m_new ) )*inv_n; + real rho_var_new = ( (n-1)*(rho_var_old)+(rho - rho_m_old)*(rho - rho_m_new) )*inv_n; + + quantityArray[(arrOff+0)*nPoints+node] = vx_var_new; + quantityArray[(arrOff+1)*nPoints+node] = vy_var_new; + quantityArray[(arrOff+2)*nPoints+node] = vz_var_new; + quantityArray[(arrOff+3)*nPoints+node] = rho_var_new; + } + } +} + +__global__ void calcQuantitiesKernel( uint* pointIndices, + uint nPoints, uint n, + real* vx, real* vy, real* vz, real* rho, + uint* neighborX, uint* neighborY, uint* neighborZ, + bool* quantities, + uint* quantityArrayOffsets, real* quantityArray + ) +{ + const uint x = threadIdx.x; + const uint y = blockIdx.x; + const uint z = blockIdx.y; + + const uint nx = blockDim.x; + const uint ny = gridDim.x; + + const uint node = nx*(ny*z + y) + x; + + if(node>=nPoints) return; + + // Get indices of neighbor nodes. + // node referring to BSW cell as seen from probe point + uint k = pointIndices[node]; + real u_interpX, u_interpY, u_interpZ, rho_interp; + + u_interpX = vx[k]; + u_interpY = vy[k]; + u_interpZ = vz[k]; + rho_interp = rho[k]; + + calculatePointwiseQuantities(n, quantityArray, quantities, quantityArrayOffsets, nPoints, node, u_interpX, u_interpY, u_interpZ, rho_interp); + +} + +__global__ void interpAndCalcQuantitiesKernel( uint* pointIndices, + uint nPoints, uint n, + real* distX, real* distY, real* distZ, + real* vx, real* vy, real* vz, real* rho, + uint* neighborX, uint* neighborY, uint* neighborZ, + bool* quantities, + uint* quantityArrayOffsets, real* quantityArray + ) +{ + const uint x = threadIdx.x; + const uint y = blockIdx.x; + const uint z = blockIdx.y; + + const uint nx = blockDim.x; + const uint ny = gridDim.x; + + const uint node = nx*(ny*z + y) + x; + + if(node>=nPoints) return; + + // Get indices of neighbor nodes. + // node referring to BSW cell as seen from probe point + uint k = pointIndices[node]; + real u_interpX, u_interpY, u_interpZ, rho_interp; + + uint ke, kn, kt, kne, kte, ktn, ktne; + getNeighborIndicesOfBSW( k, ke, kn, kt, kne, kte, ktn, ktne, neighborX, neighborY, neighborZ); + + // Trilinear interpolation of macroscopic quantities to probe point + real dW, dE, dN, dS, dT, dB; + getInterpolationWeights(dW, dE, dN, dS, dT, dB, distX[node], distY[node], distZ[node]); + + u_interpX = trilinearInterpolation( dW, dE, dN, dS, dT, dB, k, ke, kn, kt, kne, kte, ktn, ktne, vx ); + u_interpY = trilinearInterpolation( dW, dE, dN, dS, dT, dB, k, ke, kn, kt, kne, kte, ktn, ktne, vy ); + u_interpZ = trilinearInterpolation( dW, dE, dN, dS, dT, dB, k, ke, kn, kt, kne, kte, ktn, ktne, vz ); + rho_interp = trilinearInterpolation( dW, dE, dN, dS, dT, dB, k, ke, kn, kt, kne, kte, ktn, ktne, rho ); + + calculatePointwiseQuantities(n, quantityArray, quantities, quantityArrayOffsets, nPoints, node, u_interpX, u_interpY, u_interpZ, rho_interp); + +} + +bool Probe::getHasDeviceQuantityArray(){ return this->hasDeviceQuantityArray; } + +void Probe::init(Parameter* para, GridProvider* gridProvider, CudaMemoryManager* cudaManager) +{ + this->velocityRatio = para->getVelocityRatio(); + this->densityRatio = para->getDensityRatio(); + this->forceRatio = para->getForceRatio(); + this->stressRatio = para->getDensityRatio()*pow(para->getVelocityRatio(), 2.0); + this->accelerationRatio = para->getVelocityRatio()/para->getTimeRatio(); + + probeParams.resize(para->getMaxLevel()+1); + + for(int level=0; level<=para->getMaxLevel(); level++) + { + std::vector<int> probeIndices_level; + std::vector<real> distX_level; + std::vector<real> distY_level; + std::vector<real> distZ_level; + std::vector<real> pointCoordsX_level; + std::vector<real> pointCoordsY_level; + std::vector<real> pointCoordsZ_level; + + this->findPoints(para, gridProvider, probeIndices_level, distX_level, distY_level, distZ_level, + pointCoordsX_level, pointCoordsY_level, pointCoordsZ_level, + level); + + this->addProbeStruct(cudaManager, probeIndices_level, + distX_level, distY_level, distZ_level, + pointCoordsX_level, pointCoordsY_level, pointCoordsZ_level, + level); + } +} + +void Probe::addProbeStruct(CudaMemoryManager* cudaManager, std::vector<int>& probeIndices, + std::vector<real>& distX, std::vector<real>& distY, std::vector<real>& distZ, + std::vector<real>& pointCoordsX, std::vector<real>& pointCoordsY, std::vector<real>& pointCoordsZ, + int level) +{ + probeParams[level] = SPtr<ProbeStruct>(new ProbeStruct); + probeParams[level]->vals = 1; + probeParams[level]->nPoints = uint(pointCoordsX.size()); // Note, need to have both nPoints and nIndices because they differ in PlanarAverage + probeParams[level]->nIndices = uint(probeIndices.size()); + + probeParams[level]->pointCoordsX = (real*)malloc(probeParams[level]->nPoints*sizeof(real)); + probeParams[level]->pointCoordsY = (real*)malloc(probeParams[level]->nPoints*sizeof(real)); + probeParams[level]->pointCoordsZ = (real*)malloc(probeParams[level]->nPoints*sizeof(real)); + + std::copy(pointCoordsX.begin(), pointCoordsX.end(), probeParams[level]->pointCoordsX); + std::copy(pointCoordsY.begin(), pointCoordsY.end(), probeParams[level]->pointCoordsY); + std::copy(pointCoordsZ.begin(), pointCoordsZ.end(), probeParams[level]->pointCoordsZ); + + // Note, dist only needed for kernels that do interpolate + if( distX.size()>0 && distY.size()>0 && distZ.size()>0 ) + { + probeParams[level]->hasDistances=true; + cudaManager->cudaAllocProbeDistances(this, level); + std::copy(distX.begin(), distX.end(), probeParams[level]->distXH); + std::copy(distY.begin(), distY.end(), probeParams[level]->distYH); + std::copy(distZ.begin(), distZ.end(), probeParams[level]->distZH); + cudaManager->cudaCopyProbeDistancesHtoD(this, level); + } + + cudaManager->cudaAllocProbeIndices(this, level); + std::copy(probeIndices.begin(), probeIndices.end(), probeParams[level]->pointIndicesH); + cudaManager->cudaCopyProbeIndicesHtoD(this, level); + + uint arrOffset = 0; + + cudaManager->cudaAllocProbeQuantitiesAndOffsets(this, level); + + for( int var=0; var<int(Statistic::LAST); var++) + { + if(this->quantities[var]) + { + probeParams[level]->quantitiesH[var] = true; + probeParams[level]->arrayOffsetsH[var] = arrOffset; + arrOffset += uint( this->getPostProcessingVariables(static_cast<Statistic>(var)).size() ); + } + } + + cudaManager->cudaCopyProbeQuantitiesAndOffsetsHtoD(this, level); + + probeParams[level]->nArrays = arrOffset; + + cudaManager->cudaAllocProbeQuantityArray(this, level); + + for(uint arr=0; arr<probeParams[level]->nArrays; arr++) + { + for( uint point=0; point<probeParams[level]->nPoints; point++) + { + probeParams[level]->quantitiesArrayH[arr*probeParams[level]->nPoints+point] = 0.0f; + } + } + if(this->hasDeviceQuantityArray) + cudaManager->cudaCopyProbeQuantityArrayHtoD(this, level); +} + +void Probe::interact(Parameter* para, CudaMemoryManager* cudaManager, int level, uint t) +{ + if(max(int(t) - int(this->tStartAvg), -1) % this->tAvg==0) + { + SPtr<ProbeStruct> probeStruct = this->getProbeStruct(level); + + this->calculateQuantities(probeStruct, para, t, level); + if(t>=this->tStartTmpAveraging) probeStruct->vals++; + } + + if(max(int(t) - int(this->tStartOut), -1) % this->tOut == 0) + { + if(this->hasDeviceQuantityArray) + cudaManager->cudaCopyProbeQuantityArrayDtoH(this, level); + this->write(para, level, t); + } +} + +void Probe::free(Parameter* para, CudaMemoryManager* cudaManager) +{ + for(int level=0; level<=para->getMaxLevel(); level++) + { + if(this->probeParams[level]->hasDistances) + cudaManager->cudaFreeProbeDistances(this, level); + cudaManager->cudaFreeProbeIndices(this, level); + cudaManager->cudaFreeProbeQuantityArray(this, level); + cudaManager->cudaFreeProbeQuantitiesAndOffsets(this, level); + } +} + +void Probe::addStatistic(Statistic variable) +{ + assert(this->isAvailableStatistic(variable)); + + this->quantities[int(variable)] = true; + switch(variable) + { + case Statistic::Variances: + this->addStatistic(Statistic::Means); break; + + default: break; + } +} + +void Probe::addAllAvailableStatistics() +{ + for( int var=0; var < int(Statistic::LAST); var++) + { + if(this->isAvailableStatistic(static_cast<Statistic>(var))) + this->addStatistic(static_cast<Statistic>(var)); + } +} + +void Probe::write(Parameter* para, int level, int t) +{ + int t_write = this->fileNameLU ? t: t/this->tOut; + + const uint numberOfParts = this->getProbeStruct(level)->nPoints / para->getlimitOfNodesForVTK() + 1; + + std::vector<std::string> fnames; + for (uint i = 1; i <= numberOfParts; i++) + { + std::string fname = this->probeName + "_bin_lev_" + StringUtil::toString<int>(level) + + "_ID_" + StringUtil::toString<int>(para->getMyID()) + + "_Part_" + StringUtil::toString<int>(i); + if(!this->outputTimeSeries) fname += "_t_" + StringUtil::toString<int>(t_write); + fname += ".vtk"; + fnames.push_back(fname); + this->fileNamesForCollectionFile.push_back(fname); + } + this->writeGridFiles(para, level, fnames, t); + + if(level == 0 && !this->outputTimeSeries) this->writeCollectionFile(para, t); +} + +void Probe::writeCollectionFile(Parameter* para, int t) +{ + int t_write = this->fileNameLU ? t: t/this->tOut; + std::string filename = this->probeName + "_bin_ID_" + StringUtil::toString<int>(para->getMyID()) + + "_t_" + StringUtil::toString<int>(t_write) + + ".vtk"; + + std::ofstream file; + + file.open(this->outputPath + "/" + filename + ".pvtu" ); + + ////////////////////////////////////////////////////////////////////////// + + file << "<VTKFile type=\"PUnstructuredGrid\" version=\"1.0\" byte_order=\"LittleEndian\" header_type=\"UInt64\">" << std::endl; + file << " <PUnstructuredGrid GhostLevel=\"1\">" << std::endl; + + file << " <PPointData>" << std::endl; + + for(std::string varName: this->getVarNames()) //TODO + { + file << " <DataArray type=\"Float64\" Name=\""<< varName << "\" /> " << std::endl; + } + file << " </PPointData>" << std::endl; + + file << " <PPoints>" << std::endl; + file << " <PDataArray type=\"Float32\" Name=\"Points\" NumberOfComponents=\"3\"/>" << std::endl; + file << " </PPoints>" << std::endl; + + for( auto& fname : this->fileNamesForCollectionFile ) + { + const auto filenameWithoutPath=fname.substr( fname.find_last_of('/') + 1 ); + file << " <Piece Source=\"" << filenameWithoutPath << ".bin.vtu\"/>" << std::endl; + } + + file << " </PUnstructuredGrid>" << std::endl; + file << "</VTKFile>" << std::endl; + + ////////////////////////////////////////////////////////////////////////// + + file.close(); + + this->fileNamesForCollectionFile.clear(); +} + +void Probe::writeGridFiles(Parameter* para, int level, std::vector<std::string>& fnames, int t) +{ + std::vector< UbTupleFloat3 > nodes; + std::vector< std::string > nodedatanames = this->getVarNames(); + + uint startpos = 0; + uint endpos = 0; + uint sizeOfNodes = 0; + std::vector< std::vector< double > > nodedata(nodedatanames.size()); + + SPtr<ProbeStruct> probeStruct = this->getProbeStruct(level); + + for (uint part = 0; part < fnames.size(); part++) + { + startpos = part * para->getlimitOfNodesForVTK(); + uint nDataPoints = this->outputTimeSeries? this->tProbe: probeStruct->nPoints; + sizeOfNodes = min(para->getlimitOfNodesForVTK(), nDataPoints - startpos); + endpos = startpos + sizeOfNodes; + + ////////////////////////////////////////////////////////////////////////// + nodes.resize(sizeOfNodes); + + for (uint pos = startpos; pos < endpos; pos++) + { + nodes[pos-startpos] = makeUbTuple( float(probeStruct->pointCoordsX[pos]), + float(probeStruct->pointCoordsY[pos]), + float(probeStruct->pointCoordsZ[pos])); + } + + for( auto it=nodedata.begin(); it!=nodedata.end(); it++) it->resize(sizeOfNodes); + + for( int var=0; var < int(Statistic::LAST); var++){ + if(this->quantities[var]) + { + Statistic statistic = static_cast<Statistic>(var); + real coeff; + + std::vector<PostProcessingVariable> postProcessingVariables = this->getPostProcessingVariables(statistic); + uint n_arrs = uint(postProcessingVariables.size()); + + uint arrOff = probeStruct->arrayOffsetsH[var]; + uint arrLen = probeStruct->nPoints; + + for(uint arr=0; arr<n_arrs; arr++) + { + coeff = postProcessingVariables[arr].conversionFactor; + + for (uint pos = startpos; pos < endpos; pos++) + { + nodedata[arrOff+arr][pos-startpos] = double(probeStruct->quantitiesArrayH[(arrOff+arr)*arrLen+pos]*coeff); + } + } + } + } + WbWriterVtkXmlBinary::getInstance()->writeNodesWithNodeData(this->outputPath + "/" + fnames[part], nodes, nodedatanames, nodedata); + } +} + +std::vector<std::string> Probe::getVarNames() +{ + std::vector<std::string> varNames; + for( int statistic=0; statistic < int(Statistic::LAST); statistic++) + { + if(this->quantities[statistic]) + { + std::vector<PostProcessingVariable> postProcessingVariables = this->getPostProcessingVariables(static_cast<Statistic>(statistic)); + for(int i = 0; i<postProcessingVariables.size(); i++) + varNames.push_back(postProcessingVariables[i].name); + } + } + return varNames; +} \ No newline at end of file diff --git a/src/gpu/VirtualFluids_GPU/PreCollisionInteractor/Probes/Probe.h b/src/gpu/VirtualFluids_GPU/PreCollisionInteractor/Probes/Probe.h new file mode 100644 index 0000000000000000000000000000000000000000..d030d0c7a7344a44933b8114b7cd39c7ade3bf30 --- /dev/null +++ b/src/gpu/VirtualFluids_GPU/PreCollisionInteractor/Probes/Probe.h @@ -0,0 +1,219 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids 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. +// +// VirtualFluids 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 VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file Probe.h +//! \author Henry Korb, Henrik Asmuth +//! \date 13/05/2022 +//! \brief Base class for probes called in UpdateGrid27 +//! +//! Any probe should be initiated in the app and added via para->addProbe( someProbe ) +//! Note, that all probes generally require that macroscopic variables have been updated in the +//! time step they are called in. Most collision kernels (atm, all except TurbulentViscosityCumulantK17CompChim ) +//! don't do this and would require an explicit call of calcMacroscopicQuantities. It does seem quite +//! inexpensive though to simply save vx, vy, etc., directly in the collider. +//! +//! \todo might have to adapt conversionFactors when using grid refinement +//======================================================================================= + +#ifndef Probe_H +#define Probe_H + +#include <cuda.h> + +#include "PreCollisionInteractor/PreCollisionInteractor.h" +#include "PointerDefinitions.h" + +//======================================================================================= +//! \note How to add new Statistics +//! Generally, the Statistic enum refers to the type of statistic to be calculated. +//! It then depends on the derived probe class, which of these statistics are available. +//! Some type of statistics are only suitable for a certain probe class, others might +//! simply not have been implemented, yet. +//! For the same reasons it is also probe-specific, for which quantities (e.g. velocities, rho, etc.) these statistics are computed. +//! The specific quantity (e.g., mean of vx, or variance of rho) is defined as PostProcessingVariable in getPostProcessingVariables of each respective probe. +//! PostProcessingVariable also holds the name and conversionFactor of the quantity that is required when writing the data to file +//! +//! To add new Statistics: +//! 1. Add enum here, LAST has to stay last +//! 2. For PointProbe and PlaneProbe: add the computation of the statistic in switch statement in calculatePointwiseQuantities. +//! 3. For PlanarAverageProbe and WallModelProbe: add the computation directly in calculateQuantities. +//! 4. In getPostProcessingVariables add the static in the switch statement and add the corresponding PostProcessingVariables +//! 5. Add Statistic to isAvailableStatistic of the respective probe +//! +//! When adding new quantities to existing statistics (e.g., add rho to PlanarAverageProbe which currently only computes stats of velocity) only do steps 2 to 4 +//! + +enum class Statistic{ + // Variables currently available in Point and Plane probe (all temporal pointwise statistics) + Instantaneous, + Means, + Variances, + + // Variables available in PlanarAverage probe and (partially) in WallModelProbe + // Spatial statistics are typically computed across fixed spatial subdomains, e.g. a plane of constant height + // Spatio-temporal statistics additionally average the spatial stats in time + SpatialMeans, + SpatioTemporalMeans, + SpatialCovariances, + SpatioTemporalCovariances, + SpatialSkewness, + SpatioTemporalSkewness, + SpatialFlatness, + SpatioTemporalFlatness, + LAST, +}; + +typedef struct PostProcessingVariable{ + std::string name; + real conversionFactor; + PostProcessingVariable( std::string _name, + real _conversionFactor): + name(_name), conversionFactor(_conversionFactor){}; +} PostProcessingVariable; + +struct ProbeStruct{ + uint nPoints, nIndices, nArrays, vals; + uint *pointIndicesH, *pointIndicesD; + real *pointCoordsX, *pointCoordsY, *pointCoordsZ; + bool hasDistances=false; + real *distXH, *distYH, *distZH, *distXD, *distYD, *distZD; + real *quantitiesArrayH, *quantitiesArrayD; + bool *quantitiesH, *quantitiesD; + uint *arrayOffsetsH, *arrayOffsetsD; +}; + +__global__ void calcQuantitiesKernel( uint* pointIndices, + uint nPoints, uint n, + real* vx, real* vy, real* vz, real* rho, + uint* neighborX, uint* neighborY, uint* neighborZ, + bool* quantities, + uint* quantityArrayOffsets, real* quantityArray + ); + +__global__ void interpAndCalcQuantitiesKernel( uint* pointIndices, + uint nPoints, uint n, + real* distX, real* distY, real* distZ, + real* vx, real* vy, real* vz, real* rho, + uint* neighborX, uint* neighborY, uint* neighborZ, + bool* quantities, + uint* quantityArrayOffsets, real* quantityArray + ); + + +class Probe : public PreCollisionInteractor +{ +public: + Probe( + const std::string _probeName, + const std::string _outputPath, + uint _tStartAvg, + uint _tStartTmpAvg, + uint _tAvg, + uint _tStartOut, + uint _tOut, + bool _hasDeviceQuantityArray, + bool _outputTimeSeries + ): probeName(_probeName), + outputPath(_outputPath), + tStartAvg(_tStartAvg), + tStartTmpAveraging(_tStartTmpAvg), + tAvg(_tAvg), + tStartOut(_tStartOut), + tOut(_tOut), + hasDeviceQuantityArray(_hasDeviceQuantityArray), + outputTimeSeries(_outputTimeSeries), + PreCollisionInteractor() + { + assert("Output starts before averaging!" && tStartOut>=tStartAvg); + } + + void init(Parameter* para, GridProvider* gridProvider, CudaMemoryManager* cudaManager) override; + void interact(Parameter* para, CudaMemoryManager* cudaManager, int level, uint t) override; + void free(Parameter* para, CudaMemoryManager* cudaManager) override; + + SPtr<ProbeStruct> getProbeStruct(int level){ return this->probeParams[level]; } + + void addStatistic(Statistic _variable); + void addAllAvailableStatistics(); + + bool getHasDeviceQuantityArray(); + uint getTStartTmpAveraging(){return this->tStartTmpAveraging;} + + void setFileNameToNOut(){this->fileNameLU = false;} + void setTStartTmpAveraging(uint _tStartTmpAveraging){this->tStartTmpAveraging = _tStartTmpAveraging;} + +private: + virtual bool isAvailableStatistic(Statistic _variable) = 0; + + virtual std::vector<PostProcessingVariable> getPostProcessingVariables(Statistic variable) = 0; + + virtual void findPoints(Parameter* para, GridProvider* gridProvider, std::vector<int>& probeIndices_level, + std::vector<real>& distX_level, std::vector<real>& distY_level, std::vector<real>& distZ_level, + std::vector<real>& pointCoordsX_level, std::vector<real>& pointCoordsY_level, std::vector<real>& pointCoordsZ_level, + int level) = 0; + void addProbeStruct(CudaMemoryManager* cudaManager, std::vector<int>& probeIndices, + std::vector<real>& distX, std::vector<real>& distY, std::vector<real>& distZ, + std::vector<real>& pointCoordsX, std::vector<real>& pointCoordsY, std::vector<real>& pointCoordsZ, + int level); + virtual void calculateQuantities(SPtr<ProbeStruct> probeStruct, Parameter* para, uint t, int level) = 0; + + void write(Parameter* para, int level, int t); + void writeCollectionFile(Parameter* para, int t); + void writeGridFiles(Parameter* para, int level, std::vector<std::string >& fnames, int t); + std::vector<std::string> getVarNames(); + +private: + const std::string probeName; + const std::string outputPath; + + std::vector<SPtr<ProbeStruct>> probeParams; + bool quantities[int(Statistic::LAST)] = {}; + bool hasDeviceQuantityArray; //!> flag initiating memCopy in Point and PlaneProbe. Other probes are only based on thrust reduce functions and therefore dont need explict memCopy in interact() + bool outputTimeSeries; //!> flag initiating overwrite of output vtk files, skipping collection files and limiting the length of the written data to the current time step (currently only used for WallModelProbe) + std::vector<std::string> fileNamesForCollectionFile; + std::vector<std::string> varNames; + + bool fileNameLU = true; //!> if true, written file name contains time step in LU, else is the number of the written probe files + +protected: + uint tStartAvg; + uint tStartTmpAveraging; //!> only non-zero in PlanarAverageProbe and WallModelProbe to switch on Spatio-temporal averaging (while only doing spatial averaging for t<tStartTmpAveraging) + uint tAvg; + uint tStartOut; + uint tOut; + + uint tProbe = 0; //!> counter for number of probe evaluations. Only used when outputting timeseries + + real velocityRatio; + real densityRatio; + real forceRatio; + real stressRatio; + real accelerationRatio; +}; + +#endif \ No newline at end of file diff --git a/src/gpu/VirtualFluids_GPU/PreCollisionInteractor/Probes/WallModelProbe.cu b/src/gpu/VirtualFluids_GPU/PreCollisionInteractor/Probes/WallModelProbe.cu new file mode 100644 index 0000000000000000000000000000000000000000..15327beef059f298ec7dacc663f4f986fb577c5a --- /dev/null +++ b/src/gpu/VirtualFluids_GPU/PreCollisionInteractor/Probes/WallModelProbe.cu @@ -0,0 +1,300 @@ +#include "Probe.h" +#include "WallModelProbe.h" + +#include <cuda/CudaGrid.h> + +#include <cuda.h> +#include <cuda_runtime.h> +#include <helper_cuda.h> + +#include <thrust/device_vector.h> +#include <thrust/reduce.h> +#include <thrust/device_ptr.h> +#include <thrust/inner_product.h> + +#include "Parameter/Parameter.h" +#include "DataStructureInitializer/GridProvider.h" +#include "GPU/CudaMemoryManager.h" + + +/////////////////////////////////////////////////////////////////////////////////// +/// Functors for thrust reductions +/////////////////////////////////////////////////////////////////////////////////// + +template<typename T> +struct pow2 : public thrust::unary_function<T,T> +{ + __host__ __device__ T operator()(const T &x) const + { + return x * x; + } +}; + +template<typename T> +struct pow3 : public thrust::unary_function<T,T> +{ + __host__ __device__ T operator()(const T &x) const + { + return x * x * x; + } +}; + +template<typename T> +struct pow4 : public thrust::unary_function<T,T> +{ + __host__ __device__ T operator()(const T &x) const + { + return x * x * x * x; + } +}; + +struct nth_moment +{ + const float mean; + const int n; + + nth_moment(float _mean, int _n) : mean(_mean), n(_n) {} + + __host__ __device__ + float operator()(const float& x) const { + + real fluctuation = x-mean; + real moment = fluctuation; + for(int i = 1; i<n; i++) moment *= fluctuation; + + return moment; + } +}; + + +/////////////////////////////////////////////////////////////////////////////////// +bool WallModelProbe::isAvailableStatistic(Statistic _variable) +{ + bool isAvailable; + + switch (_variable) + { + case Statistic::Instantaneous: + case Statistic::Means: + case Statistic::Variances: + isAvailable = false; + break; + case Statistic::SpatialMeans: + case Statistic::SpatioTemporalMeans: + isAvailable = true; + break; + case Statistic::SpatialCovariances: + case Statistic::SpatioTemporalCovariances: + case Statistic::SpatialSkewness: + case Statistic::SpatioTemporalSkewness: + case Statistic::SpatialFlatness: + case Statistic::SpatioTemporalFlatness: + isAvailable = false; + break; + default: + isAvailable = false; + } + return isAvailable; +} + +/////////////////////////////////////////////////////////////////////////////////// + +std::vector<PostProcessingVariable> WallModelProbe::getPostProcessingVariables(Statistic statistic) +{ + std::vector<PostProcessingVariable> postProcessingVariables; + switch (statistic) + { + case Statistic::SpatialMeans: + postProcessingVariables.push_back( PostProcessingVariable("vx_el_spatMean", this->velocityRatio) ); + postProcessingVariables.push_back( PostProcessingVariable("vy_el_spatMean", this->velocityRatio) ); + postProcessingVariables.push_back( PostProcessingVariable("vz_el_spatMean", this->velocityRatio) ); + postProcessingVariables.push_back( PostProcessingVariable("vx1_spatMean", this->velocityRatio) ); + postProcessingVariables.push_back( PostProcessingVariable("vy1_spatMean", this->velocityRatio) ); + postProcessingVariables.push_back( PostProcessingVariable("vz1_spatMean", this->velocityRatio) ); + postProcessingVariables.push_back( PostProcessingVariable("u_star_spatMean", this->velocityRatio) ); + postProcessingVariables.push_back( PostProcessingVariable("Fx_spatMean", this->outputStress? this->stressRatio: this->forceRatio) ); + postProcessingVariables.push_back( PostProcessingVariable("Fy_spatMean", this->outputStress? this->stressRatio: this->forceRatio) ); + postProcessingVariables.push_back( PostProcessingVariable("Fz_spatMean", this->outputStress? this->stressRatio: this->forceRatio) ); + if(this->evaluatePressureGradient) + { + postProcessingVariables.push_back( PostProcessingVariable("dpdx_spatMean", this->accelerationRatio) ); + postProcessingVariables.push_back( PostProcessingVariable("dpdy_spatMean", this->accelerationRatio) ); + postProcessingVariables.push_back( PostProcessingVariable("dpdz_spatMean", this->accelerationRatio) ); + } + break; + case Statistic::SpatioTemporalMeans: + postProcessingVariables.push_back( PostProcessingVariable("vx_el_spatTmpMean", this->velocityRatio) ); + postProcessingVariables.push_back( PostProcessingVariable("vy_el_spatTmpMean", this->velocityRatio) ); + postProcessingVariables.push_back( PostProcessingVariable("vz_el_spatTmpMean", this->velocityRatio) ); + postProcessingVariables.push_back( PostProcessingVariable("vx1_spatTmpMean", this->velocityRatio) ); + postProcessingVariables.push_back( PostProcessingVariable("vy1_spatTmpMean", this->velocityRatio) ); + postProcessingVariables.push_back( PostProcessingVariable("vz1_spatTmpMean", this->velocityRatio) ); + postProcessingVariables.push_back( PostProcessingVariable("u_star_spatTmpMean", this->velocityRatio) ); + postProcessingVariables.push_back( PostProcessingVariable("Fx_spatTmpMean", this->outputStress? this->stressRatio: this->forceRatio) ); + postProcessingVariables.push_back( PostProcessingVariable("Fy_spatTmpMean", this->outputStress? this->stressRatio: this->forceRatio) ); + postProcessingVariables.push_back( PostProcessingVariable("Fz_spatTmpMean", this->outputStress? this->stressRatio: this->forceRatio) ); + if(this->evaluatePressureGradient) + { + postProcessingVariables.push_back( PostProcessingVariable("dpdx_spatTmpMean", this->accelerationRatio) ); + postProcessingVariables.push_back( PostProcessingVariable("dpdy_spatTmpMean", this->accelerationRatio) ); + postProcessingVariables.push_back( PostProcessingVariable("dpdz_spatTmpMean", this->accelerationRatio) ); + } + break; + + default: + printf("Statistic unavailable in WallModelProbe\n"); + assert(false); + break; + } + return postProcessingVariables; +} + +/////////////////////////////////////////////////////////////////////////////////// + +void WallModelProbe::findPoints(Parameter* para, GridProvider* gridProvider, std::vector<int>& probeIndices_level, + std::vector<real>& distX_level, std::vector<real>& distY_level, std::vector<real>& distZ_level, + std::vector<real>& pointCoordsX_level, std::vector<real>& pointCoordsY_level, std::vector<real>& pointCoordsZ_level, + int level) +{ + assert( para->getParD(level)->kStressQ > 0 && para->gethasWallModelMonitor() ); + + real dt = para->getTimeRatio(); + uint nt = uint((para->getTEnd()-this->tStartAvg)/this->tAvg); + + for(uint t=0; t<nt; t++) + { + pointCoordsX_level.push_back(dt*(t*this->tAvg)+this->tStartAvg); // x coord will serve as time in this probe + pointCoordsY_level.push_back(0); + pointCoordsZ_level.push_back(0); + } + + if(this->evaluatePressureGradient) + { + assert(para->getIsBodyForce()); + // Find all fluid nodes + for(uint j=1; j<para->getParH(level)->size_Mat_SP; j++ ) + { + if( para->getParH(level)->geoSP[j] == GEO_FLUID) + { + probeIndices_level.push_back(j); + } + } + } +} + +/////////////////////////////////////////////////////////////////////////////////// + +void WallModelProbe::calculateQuantities(SPtr<ProbeStruct> probeStruct, Parameter* para, uint t, int level) +{ + bool doTmpAveraging = (t>this->getTStartTmpAveraging()); + + // Pointer casts to use device arrays in thrust reductions + thrust::device_ptr<real> u_el_thrust = thrust::device_pointer_cast(para->getParD(level)->QStress.Vx); + thrust::device_ptr<real> v_el_thrust = thrust::device_pointer_cast(para->getParD(level)->QStress.Vy); + thrust::device_ptr<real> w_el_thrust = thrust::device_pointer_cast(para->getParD(level)->QStress.Vz); + thrust::device_ptr<real> u1_thrust = thrust::device_pointer_cast(para->getParD(level)->QStress.Vx1); + thrust::device_ptr<real> v1_thrust = thrust::device_pointer_cast(para->getParD(level)->QStress.Vy1); + thrust::device_ptr<real> w1_thrust = thrust::device_pointer_cast(para->getParD(level)->QStress.Vz1); + thrust::device_ptr<real> u_star_thrust = thrust::device_pointer_cast(para->getParD(level)->wallModel.u_star); + thrust::device_ptr<real> Fx_thrust = thrust::device_pointer_cast(para->getParD(level)->wallModel.Fx); + thrust::device_ptr<real> Fy_thrust = thrust::device_pointer_cast(para->getParD(level)->wallModel.Fy); + thrust::device_ptr<real> Fz_thrust = thrust::device_pointer_cast(para->getParD(level)->wallModel.Fz); + thrust::device_ptr<real> dpdx_thrust = thrust::device_pointer_cast(para->getParD(level)->forceX_SP); + thrust::device_ptr<real> dpdy_thrust = thrust::device_pointer_cast(para->getParD(level)->forceY_SP); + thrust::device_ptr<real> dpdz_thrust = thrust::device_pointer_cast(para->getParD(level)->forceZ_SP); + + thrust::device_ptr<uint> indices_thrust = thrust::device_pointer_cast(probeStruct->pointIndicesD); + typedef thrust::device_vector<real>::iterator valIterator; + typedef thrust::device_vector<uint>::iterator indIterator; + thrust::permutation_iterator<valIterator, indIterator> dpdx_iter_begin(dpdx_thrust, indices_thrust); + thrust::permutation_iterator<valIterator, indIterator> dpdx_iter_end (dpdx_thrust, indices_thrust+probeStruct->nIndices); + thrust::permutation_iterator<valIterator, indIterator> dpdy_iter_begin(dpdy_thrust, indices_thrust); + thrust::permutation_iterator<valIterator, indIterator> dpdy_iter_end (dpdy_thrust, indices_thrust+probeStruct->nIndices); + thrust::permutation_iterator<valIterator, indIterator> dpdz_iter_begin(dpdz_thrust, indices_thrust); + thrust::permutation_iterator<valIterator, indIterator> dpdz_iter_end (dpdz_thrust, indices_thrust+probeStruct->nIndices); + + real N = para->getParD(level)->kStressQ; + real n = (real)probeStruct->vals; + int nPoints = probeStruct->nPoints; + + if(probeStruct->quantitiesH[int(Statistic::SpatialMeans)]) + { + // Compute the instantaneous spatial means of the velocity moments + real spatMean_u_el = thrust::reduce(u_el_thrust, u_el_thrust+N)/N; + real spatMean_v_el = thrust::reduce(v_el_thrust, v_el_thrust+N)/N; + real spatMean_w_el = thrust::reduce(w_el_thrust, w_el_thrust+N)/N; + real spatMean_u1 = thrust::reduce(u1_thrust, u1_thrust+N)/N; + real spatMean_v1 = thrust::reduce(v1_thrust, v1_thrust+N)/N; + real spatMean_w1 = thrust::reduce(w1_thrust, w1_thrust+N)/N; + real spatMean_u_star = thrust::reduce(u_star_thrust, u_star_thrust+N)/N; + real spatMean_Fx = thrust::reduce(Fx_thrust, Fx_thrust+N)/N; + real spatMean_Fy = thrust::reduce(Fy_thrust, Fy_thrust+N)/N; + real spatMean_Fz = thrust::reduce(Fz_thrust, Fz_thrust+N)/N; + + uint arrOff = probeStruct->arrayOffsetsH[int(Statistic::SpatialMeans)]; + probeStruct->quantitiesArrayH[(arrOff+0)*nPoints+tProbe] = spatMean_u_el; + probeStruct->quantitiesArrayH[(arrOff+1)*nPoints+tProbe] = spatMean_v_el; + probeStruct->quantitiesArrayH[(arrOff+2)*nPoints+tProbe] = spatMean_w_el; + probeStruct->quantitiesArrayH[(arrOff+3)*nPoints+tProbe] = spatMean_u1; + probeStruct->quantitiesArrayH[(arrOff+4)*nPoints+tProbe] = spatMean_v1; + probeStruct->quantitiesArrayH[(arrOff+5)*nPoints+tProbe] = spatMean_w1; + probeStruct->quantitiesArrayH[(arrOff+6)*nPoints+tProbe] = spatMean_u_star; + probeStruct->quantitiesArrayH[(arrOff+7)*nPoints+tProbe] = spatMean_Fx; + probeStruct->quantitiesArrayH[(arrOff+8)*nPoints+tProbe] = spatMean_Fy; + probeStruct->quantitiesArrayH[(arrOff+9)*nPoints+tProbe] = spatMean_Fz; + + real spatMean_dpdx; + real spatMean_dpdy; + real spatMean_dpdz; + if(this->evaluatePressureGradient) + { + real N_fluid = (real)probeStruct->nIndices; + spatMean_dpdx = thrust::reduce(dpdx_iter_begin, dpdx_iter_end)/N_fluid; + spatMean_dpdy = thrust::reduce(dpdy_iter_begin, dpdy_iter_end)/N_fluid; + spatMean_dpdz = thrust::reduce(dpdz_iter_begin, dpdz_iter_end)/N_fluid; + probeStruct->quantitiesArrayH[(arrOff+10)*nPoints+tProbe] = spatMean_dpdx; + probeStruct->quantitiesArrayH[(arrOff+11)*nPoints+tProbe] = spatMean_dpdy; + probeStruct->quantitiesArrayH[(arrOff+12)*nPoints+tProbe] = spatMean_dpdz; + } + + if(probeStruct->quantitiesH[int(Statistic::SpatioTemporalMeans)] && doTmpAveraging) + { + uint arrOff = probeStruct->arrayOffsetsH[int(Statistic::SpatioTemporalMeans)]; + real spatMean_u_el_old = probeStruct->quantitiesArrayH[(arrOff+0)*nPoints+tProbe-1]; + real spatMean_v_el_old = probeStruct->quantitiesArrayH[(arrOff+1)*nPoints+tProbe-1]; + real spatMean_w_el_old = probeStruct->quantitiesArrayH[(arrOff+2)*nPoints+tProbe-1]; + real spatMean_u1_old = probeStruct->quantitiesArrayH[(arrOff+3)*nPoints+tProbe-1]; + real spatMean_v1_old = probeStruct->quantitiesArrayH[(arrOff+4)*nPoints+tProbe-1]; + real spatMean_w1_old = probeStruct->quantitiesArrayH[(arrOff+5)*nPoints+tProbe-1]; + real spatMean_u_star_old = probeStruct->quantitiesArrayH[(arrOff+6)*nPoints+tProbe-1]; + real spatMean_Fx_old = probeStruct->quantitiesArrayH[(arrOff+7)*nPoints+tProbe-1]; + real spatMean_Fy_old = probeStruct->quantitiesArrayH[(arrOff+8)*nPoints+tProbe-1]; + real spatMean_Fz_old = probeStruct->quantitiesArrayH[(arrOff+9)*nPoints+tProbe-1]; + + probeStruct->quantitiesArrayH[(arrOff+0)*nPoints+tProbe] = spatMean_u_el_old + (spatMean_u_el-spatMean_u_el_old)/n; + probeStruct->quantitiesArrayH[(arrOff+1)*nPoints+tProbe] = spatMean_v_el_old + (spatMean_v_el-spatMean_v_el_old)/n; + probeStruct->quantitiesArrayH[(arrOff+2)*nPoints+tProbe] = spatMean_w_el_old + (spatMean_w_el-spatMean_w_el_old)/n; + probeStruct->quantitiesArrayH[(arrOff+3)*nPoints+tProbe] = spatMean_u1_old + (spatMean_u1-spatMean_u1_old)/n; + probeStruct->quantitiesArrayH[(arrOff+4)*nPoints+tProbe] = spatMean_v1_old + (spatMean_v1-spatMean_v1_old)/n; + probeStruct->quantitiesArrayH[(arrOff+5)*nPoints+tProbe] = spatMean_w1_old + (spatMean_w1-spatMean_w1_old)/n; + probeStruct->quantitiesArrayH[(arrOff+6)*nPoints+tProbe] = spatMean_u_star_old +(spatMean_u_star-spatMean_u_star_old)/n; + probeStruct->quantitiesArrayH[(arrOff+7)*nPoints+tProbe] = spatMean_Fx_old + (spatMean_Fx-spatMean_Fx_old)/n; + probeStruct->quantitiesArrayH[(arrOff+8)*nPoints+tProbe] = spatMean_Fy_old + (spatMean_Fy-spatMean_Fy_old)/n; + probeStruct->quantitiesArrayH[(arrOff+9)*nPoints+tProbe] = spatMean_Fz_old + (spatMean_Fz-spatMean_Fz_old)/n; + + if(this->evaluatePressureGradient) + { + real spatMean_dpdx_old = probeStruct->quantitiesArrayH[(arrOff+10)*nPoints+tProbe-1]; + real spatMean_dpdy_old = probeStruct->quantitiesArrayH[(arrOff+11)*nPoints+tProbe-1]; + real spatMean_dpdz_old = probeStruct->quantitiesArrayH[(arrOff+12)*nPoints+tProbe-1]; + probeStruct->quantitiesArrayH[(arrOff+10)*nPoints+tProbe] = spatMean_dpdx_old + (spatMean_dpdx-spatMean_dpdx_old)/n; + probeStruct->quantitiesArrayH[(arrOff+11)*nPoints+tProbe] = spatMean_dpdy_old + (spatMean_dpdy-spatMean_dpdy_old)/n; + probeStruct->quantitiesArrayH[(arrOff+12)*nPoints+tProbe] = spatMean_dpdz_old + (spatMean_dpdz-spatMean_dpdz_old)/n; + } + } + } + + this->tProbe += 1; + getLastCudaError("WallModelProbe::calculateQuantities execution failed"); +} + diff --git a/src/gpu/VirtualFluids_GPU/PreCollisionInteractor/Probes/WallModelProbe.h b/src/gpu/VirtualFluids_GPU/PreCollisionInteractor/Probes/WallModelProbe.h new file mode 100644 index 0000000000000000000000000000000000000000..d6464c5ca2aa60310cc6bb7ca0a210bc12e755ff --- /dev/null +++ b/src/gpu/VirtualFluids_GPU/PreCollisionInteractor/Probes/WallModelProbe.h @@ -0,0 +1,87 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids 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. +// +// VirtualFluids 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 VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file WallModelProbe.h +//! \author Henrik Asmuth +//! \date 13/05/2022 +//! \brief Probe computing statistics of all relevant wall model quantities used in the StressBC kernels +//! +//! Computes spatial statistics for all grid points of the StressBC +//! The spatial statistics can additionally be averaged in time. +//! +//======================================================================================= + +#ifndef WallModelProbe_H +#define WallModelProbe_H + +#include "Probe.h" + +/////////////////////////////////////////////////////////////////////////////////// + +class WallModelProbe : public Probe +{ +public: + WallModelProbe( + const std::string _probeName, + const std::string _outputPath, + uint _tStartAvg, + uint _tStartTmpAvg, + uint _tAvg, + uint _tStartOut, + uint _tOut + ): Probe(_probeName, + _outputPath, + _tStartAvg, + _tStartTmpAvg, + _tAvg, + _tStartOut, + _tOut, + false, + true){} + + + void setForceOutputToStress(bool _outputStress){ this->outputStress = _outputStress; } + void setEvaluatePressureGradient(bool _evalPressGrad){ this->evaluatePressureGradient = _evalPressGrad; } + +private: + bool isAvailableStatistic(Statistic _variable) override; + + std::vector<PostProcessingVariable> getPostProcessingVariables(Statistic variable) override; + + void findPoints(Parameter* para, GridProvider* gridProvider, std::vector<int>& probeIndices_level, + std::vector<real>& distX_level, std::vector<real>& distY_level, std::vector<real>& distZ_level, + std::vector<real>& pointCoordsX_level, std::vector<real>& pointCoordsY_level, std::vector<real>& pointCoordsZ_level, + int level) override; + void calculateQuantities(SPtr<ProbeStruct> probeStruct, Parameter* para, uint t, int level) override; + +private: + bool outputStress = false; //!> if true, output wall force is converted to a stress + bool evaluatePressureGradient = false; //!> if true, mean global pressure gradient will also be evaluated +}; + +#endif \ No newline at end of file diff --git a/src/lbm/CMakeLists.txt b/src/lbm/CMakeLists.txt index 6e9f76793825ccf4e4e9e921e9fd4b6ab3584707..afa90bdd3f95bb71cf7f1eda6407f9b38766072a 100644 --- a/src/lbm/CMakeLists.txt +++ b/src/lbm/CMakeLists.txt @@ -1,10 +1,12 @@ -project(lbm LANGUAGES CXX) +if(BUILD_VF_CPU) + project(lbm LANGUAGES CXX) -vf_add_library(NAME lbm PUBLIC_LINK basics) + vf_add_library(NAME lbm PUBLIC_LINK basics) + target_link_libraries(lbm PRIVATE project_warnings) -if(BUILD_VF_GPU) - add_subdirectory(cuda) + vf_add_tests() endif() - -vf_add_tests() +if(BUILD_VF_GPU OR BUILD_VF_GKS) + add_subdirectory(cuda) +endif() diff --git a/src/lbm/constants/NumericConstants.h b/src/lbm/constants/NumericConstants.h index 3d7c97a5b1adac97eafc36a49f9e4d968a854347..5f023276e84fba064ec9ae6823a9a96f1631bfec 100644 --- a/src/lbm/constants/NumericConstants.h +++ b/src/lbm/constants/NumericConstants.h @@ -118,6 +118,11 @@ static constexpr double c10eM30 = 1e-30; static constexpr double c10eM10 = 1e-10; static constexpr double smallSingle = 0.0000000002; +static constexpr double cPi = 3.1415926535; +static constexpr double c2Pi = 6.28318530717; +static constexpr double cPio180 = 1.74532925199e-2; +static constexpr double c180oPi = 57.2957795131; + #else static constexpr float c1o2 = 0.5f; static constexpr float c3o2 = 1.5f; @@ -227,6 +232,11 @@ static constexpr float c10eM30 = 1e-30f; static constexpr float c10eM10 = 1e-10f; static constexpr float smallSingle = 0.0000000002f; +static constexpr float cPi = 3.1415926535f; +static constexpr double c2Pi = 6.2831853071f; +static constexpr float cPio180 = 1.74532925199e-2f; +static constexpr float c180oPi = 57.2957795131f; + #endif } diff --git a/src/lbm/cuda/CMakeLists.txt b/src/lbm/cuda/CMakeLists.txt index be16988a480650cbab416652655af9766bcf8ec7..4142b7c3b1c46275c3257e3dfd657cc6b30c841d 100644 --- a/src/lbm/cuda/CMakeLists.txt +++ b/src/lbm/cuda/CMakeLists.txt @@ -4,9 +4,9 @@ project(lbmCuda LANGUAGES CUDA CXX) vf_add_library(NAME lbmCuda BUILDTYPE static PUBLIC_LINK basics FOLDER ../../lbm) -set_target_properties(lbmCuda PROPERTIES CUDA_SEPARABLE_COMPILATION ON) +set_target_properties(lbmCuda PROPERTIES CUDA_SEPARABLE_COMPILATION ON POSITION_INDEPENDENT_CODE ON) -set_source_files_properties(../KernelParameter.cpp PROPERTIES LANGUAGE CUDA) +set_source_files_properties(../KernelParameter.cpp PROPERTIES LANGUAGE CUDA) set_source_files_properties(../CumulantChimera.cpp PROPERTIES LANGUAGE CUDA) -set_source_files_properties(../BGK.cpp PROPERTIES LANGUAGE CUDA) \ No newline at end of file +set_source_files_properties(../BGK.cpp PROPERTIES LANGUAGE CUDA) diff --git a/src/logger/CMakeLists.txt b/src/logger/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..32cbdae2aaa40f11b12e1f3fe1629f47ba4ca195 --- /dev/null +++ b/src/logger/CMakeLists.txt @@ -0,0 +1,2 @@ + +vf_add_library(NAME logger PUBLIC_LINK spdlog PRIVATE_LINK project_warnings) diff --git a/src/logger/Logger.cpp b/src/logger/Logger.cpp new file mode 100644 index 0000000000000000000000000000000000000000..708e359c8430380dd57c404ed9b3c41f53dcb714 --- /dev/null +++ b/src/logger/Logger.cpp @@ -0,0 +1,54 @@ +#include "Logger.h" + +#include <spdlog/spdlog.h> +#include <spdlog/sinks/stdout_color_sinks.h> +#include <spdlog/sinks/daily_file_sink.h> +#include <spdlog/sinks/basic_file_sink.h> + +namespace vf::logging +{ + + std::string Logger::logPath = {"logs/"}; + + void Logger::initalizeLogger() + { + updateDefaultLogger(); + + // setting default log level to trace + // levels: trace < debug < info < warn < error < critical + spdlog::set_level(spdlog::level::trace); + + // setting the log pattern + // formatting is documented here: https://github.com/gabime/spdlog/wiki/3.-Custom-formatting + spdlog::set_pattern("[%Y-%m-%d %H:%M:%S.%e] [%^%l%$] %v"); + + // according to the flush policy https://github.com/gabime/spdlog/wiki/7.-Flush-policy + spdlog::flush_on(spdlog::level::info); + } + + + void Logger::changeLogPath(const std::string& path) + { + logPath = path; + + updateDefaultLogger(); + } + + + void Logger::updateDefaultLogger() + { + // initialize stdout sink with colored output + auto console_sink = std::make_shared<spdlog::sinks::stdout_color_sink_mt>(); + + // initialize daily file sink + // files will be written into "logs" folder relative to pwd. A new files is created at 0:00 o'clock. + auto daily_file_sink = std::make_shared<spdlog::sinks::daily_file_sink_mt>(logPath + "daily.txt", 0, 0); + + // initialize last run file sink + auto last_run_file_sink = std::make_shared<spdlog::sinks::basic_file_sink_mt>(logPath + "last_run.txt", true); + + // creating default logger with console and file sink + spdlog::set_default_logger(std::make_shared<spdlog::logger>("default", spdlog::sinks_init_list({console_sink, daily_file_sink, last_run_file_sink}))); + } + +} diff --git a/src/logger/Logger.h b/src/logger/Logger.h new file mode 100644 index 0000000000000000000000000000000000000000..adb7796135a989843ef8de1f778c9901f3ad17c8 --- /dev/null +++ b/src/logger/Logger.h @@ -0,0 +1,73 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids 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. +// +// VirtualFluids 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 VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \author Soeren Peters +//======================================================================================= +#ifndef VF_LOGGER_H +#define VF_LOGGER_H + +// VirtualFluids is using the spdlog logger https://github.com/gabime/spdlog +#include <spdlog/spdlog.h> +// To initialize spdlog initalizeLogger() must be called. +// spdlog supports 5 log level, which can be changed at runtime e.g.: +// spdlog::set_level(spdlog::level::debug) +// The default log level is set to trace. Supported levels: trace < debug < info < warning < critical +// +// The logging is realized in 3 different log sinks: +// 1. colorded console output +// 2. a daily log file +// 3. a log file from the last run of VirtualFluids +// The default file path is relativ to executed command logs/ +// File path can be changed via changeLogPath() + +#define VF_LOG_TRACE(...) spdlog::trace(__VA_ARGS__) +#define VF_LOG_DEBUG(...) spdlog::debug(__VA_ARGS__) +#define VF_LOG_INFO(...) spdlog::info(__VA_ARGS__) +#define VF_LOG_WARNING(...) spdlog::warn(__VA_ARGS__) +#define VF_LOG_CRITICAL(...) spdlog::critical(__VA_ARGS__) + + +namespace vf::logging +{ + class Logger + { + public: + // initalizing the above named logger + static void initalizeLogger(); + + // changing the path of the log files + static void changeLogPath(const std::string& path); + + private: + static void updateDefaultLogger(); + + static std::string logPath; + }; +} + +#endif diff --git a/src/mpi/CMakeLists.txt b/src/mpi/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..de1d58f5bd39e14742180b9cc6a77fb640d117f6 --- /dev/null +++ b/src/mpi/CMakeLists.txt @@ -0,0 +1,2 @@ + +vf_add_library(NAME mpi PUBLIC_LINK logger PRIVATE_LINK MPI::MPI_CXX basics) diff --git a/src/cpu/VirtualFluidsCore/Parallel/Communicator.cpp b/src/mpi/Communicator.cpp similarity index 91% rename from src/cpu/VirtualFluidsCore/Parallel/Communicator.cpp rename to src/mpi/Communicator.cpp index b7ea54267edb7126573e512a7593e3f3f4312bd6..937f4d819f67804380d807bfe5ef6048ff507058 100644 --- a/src/cpu/VirtualFluidsCore/Parallel/Communicator.cpp +++ b/src/mpi/Communicator.cpp @@ -34,12 +34,17 @@ #include "Communicator.h" #include <basics/utilities/UbException.h> -SPtr<Communicator> Communicator::instance = SPtr<Communicator>(); +namespace vf::mpi +{ +std::mutex Communicator::instantiation_mutex = std::mutex(); +std::shared_ptr<Communicator> Communicator::instance = std::shared_ptr<Communicator>(); ////////////////////////////////////////////////////////////////////////// -SPtr<Communicator> Communicator::getInstance() +std::shared_ptr<Communicator> Communicator::getInstance() { if (!instance) UB_THROW(UbException(UB_EXARGS, "Communicator isn't initialized correctly! You can not create a new instance " "of abstract Communicator class!")); return instance; } + +} diff --git a/src/cpu/VirtualFluidsCore/Parallel/Communicator.h b/src/mpi/Communicator.h similarity index 91% rename from src/cpu/VirtualFluidsCore/Parallel/Communicator.h rename to src/mpi/Communicator.h index 28ba705480a6291aac3d31b3341f93f73a35f829..bcec064a23801c7b597d91deb601b44a1d9c7a71 100644 --- a/src/cpu/VirtualFluidsCore/Parallel/Communicator.h +++ b/src/mpi/Communicator.h @@ -31,20 +31,29 @@ //! \author Konstantin Kutscher //======================================================================================= -#ifndef COMMUNICATOR_H -#define COMMUNICATOR_H +#ifndef MPI_COMMUNICATOR_H +#define MPI_COMMUNICATOR_H #include <string> #include <vector> +#include <memory> +#include <sstream> +#include <mutex> -#include <PointerDefinitions.h> + +namespace vf::mpi +{ //! \brief An abstract class for communication between processes in parallel computation class Communicator { public: + Communicator(const Communicator&) = delete; + Communicator & operator=(const Communicator& rhs) = delete; + static std::shared_ptr<Communicator> getInstance(); + virtual ~Communicator() = default; - static SPtr<Communicator> getInstance(); + virtual int getBundleID() = 0; virtual int getNumberOfBundles() = 0; virtual int getProcessID() = 0; @@ -84,9 +93,13 @@ public: virtual void broadcast(std::vector<long int> &values) = 0; protected: - Communicator() = default; - Communicator(const Communicator &) = default; - static SPtr<Communicator> instance; + Communicator() = default; + + static std::mutex instantiation_mutex; + + static std::shared_ptr<Communicator> instance; }; +} + #endif diff --git a/src/cpu/VirtualFluidsCore/Parallel/MPICommunicator.cpp b/src/mpi/MPICommunicator.cpp similarity index 95% rename from src/cpu/VirtualFluidsCore/Parallel/MPICommunicator.cpp rename to src/mpi/MPICommunicator.cpp index 4e5b5cb79ac01f730d5f1b92a8238605992d3825..4e7a155ef3b78f7daa0a582f84f2ef8af83886c8 100644 --- a/src/cpu/VirtualFluidsCore/Parallel/MPICommunicator.cpp +++ b/src/mpi/MPICommunicator.cpp @@ -5,11 +5,22 @@ #include <sstream> using namespace std; + +namespace vf::mpi +{ +std::shared_ptr<Communicator> MPICommunicator::getInstance() +{ + std::lock_guard<std::mutex> myLock(instantiation_mutex); + if (!instance){ + instance = std::shared_ptr<MPICommunicator>(new MPICommunicator); + } + return instance; +} ////////////////////////////////////////////////////////////////////////// MPICommunicator::MPICommunicator() { // proof if MPI is initialized - int mpiInitialized = (int)false; + int mpiInitialized = 0; // false MPI_Initialized(&mpiInitialized); if (!mpiInitialized) { MPI_Init(NULL, NULL); @@ -25,7 +36,7 @@ MPICommunicator::MPICommunicator() MPICommunicator::~MPICommunicator() { // proof if MPI is finalized - int _mpiFinalized = (int)false; + int _mpiFinalized = 0; // false MPI_Finalized(&_mpiFinalized); if (!_mpiFinalized) { MPI_Finalize(); @@ -33,13 +44,6 @@ MPICommunicator::~MPICommunicator() } } ////////////////////////////////////////////////////////////////////////// -SPtr<Communicator> MPICommunicator::getInstance() -{ - if (!Communicator::instance) - Communicator::instance = SPtr<Communicator>(new MPICommunicator()); - return Communicator::instance; -} -////////////////////////////////////////////////////////////////////////// void MPICommunicator::abort(int errorcode) { MPI_Abort(comm, errorcode); } //////////////////////////////////////////////////////////////////////////// vector<string> MPICommunicator::gather(const string &str) @@ -164,4 +168,7 @@ void MPICommunicator::broadcast(float &value) { broadcast<float>(value); } void MPICommunicator::broadcast(double &value) { broadcast<double>(value); } ////////////////////////////////////////////////////////////////////////// void MPICommunicator::broadcast(long int &value) { broadcast<long int>(value); } -#endif + +} + +#endif \ No newline at end of file diff --git a/src/cpu/VirtualFluidsCore/Parallel/MPICommunicator.h b/src/mpi/MPICommunicator.h similarity index 96% rename from src/cpu/VirtualFluidsCore/Parallel/MPICommunicator.h rename to src/mpi/MPICommunicator.h index cd63d8f1db9e27ab3572a26693355c88a303104f..96d7e3593acb6d94706c9842f176e96c7a0e8969 100644 --- a/src/cpu/VirtualFluidsCore/Parallel/MPICommunicator.h +++ b/src/mpi/MPICommunicator.h @@ -1,7 +1,7 @@ #if defined VF_MPI -#ifndef MPICOMMUNICATOR_H -#define MPICOMMUNICATOR_H +#ifndef MPI_MPICOMMUNICATOR_H +#define MPI_MPICOMMUNICATOR_H #include "Communicator.h" #include <PointerDefinitions.h> @@ -11,19 +11,20 @@ #include <string> #include <vector> +namespace vf::mpi +{ + //! \brief A class uses MPI library to communication. //! \details Support MPI communication. Implements singleton pattern. //! \author K. Kutscher - class MPICommunicator : public Communicator { -private: - MPICommunicator(); - MPICommunicator(const MPICommunicator &) = default; - public: + MPICommunicator(MPICommunicator const&) = delete; + MPICommunicator& operator=(MPICommunicator const&) = delete; + ~MPICommunicator() override; - static SPtr<Communicator> getInstance(); + static std::shared_ptr<Communicator> getInstance(); int getBundleID() override; int getNumberOfBundles() override; int getProcessID() override; @@ -75,6 +76,8 @@ public: void broadcast(T &value); private: + MPICommunicator(); + int numprocs, PID; MPI_Comm comm; int root; @@ -201,4 +204,6 @@ void MPICommunicator::broadcast(T &value) #endif +} + #endif diff --git a/src/cpu/VirtualFluidsCore/Parallel/NullCommunicator.cpp b/src/mpi/NullCommunicator.cpp similarity index 93% rename from src/cpu/VirtualFluidsCore/Parallel/NullCommunicator.cpp rename to src/mpi/NullCommunicator.cpp index d3846dfd36a765891936e45c80a62dcd88025c15..0f407d0dccab79b551e8671bcaa150f6aab36789 100644 --- a/src/cpu/VirtualFluidsCore/Parallel/NullCommunicator.cpp +++ b/src/mpi/NullCommunicator.cpp @@ -33,9 +33,17 @@ #include "NullCommunicator.h" -NullCommunicator::NullCommunicator() = default; -////////////////////////////////////////////////////////////////////////// -NullCommunicator::~NullCommunicator() = default; +namespace vf::mpi +{ + +// std::shared_ptr<Communicator> NullCommunicator::getInstance() +// { +// std::lock_guard<std::mutex> myLock(instantiation_mutex); +// if (!instance){ +// instance = std::shared_ptr<NullCommunicator>(new NullCommunicator); +// } +// return instance; +// } ////////////////////////////////////////////////////////////////////////// int NullCommunicator::getBundleID() { return 0; } ////////////////////////////////////////////////////////////////////////// @@ -62,3 +70,6 @@ void NullCommunicator::allGatherInts(std::vector<int> &svalues, std::vector<int> void NullCommunicator::sendSerializedObject(std::stringstream &ss, int target) {} ////////////////////////////////////////////////////////////////////////// void NullCommunicator::receiveSerializedObject(std::stringstream &ss, int source) {} + + +} diff --git a/src/cpu/VirtualFluidsCore/Parallel/NullCommunicator.h b/src/mpi/NullCommunicator.h similarity index 94% rename from src/cpu/VirtualFluidsCore/Parallel/NullCommunicator.h rename to src/mpi/NullCommunicator.h index 3dad3395a34b5d3a049c3b0bb8d960e924078324..1a3ba3eac5c840d8e6e6c474d7dec9dfe6be6750 100644 --- a/src/cpu/VirtualFluidsCore/Parallel/NullCommunicator.h +++ b/src/mpi/NullCommunicator.h @@ -31,20 +31,20 @@ //! \author Konstantin Kutscher //======================================================================================= -#ifndef NullCommunicator_H -#define NullCommunicator_H +#ifndef MPI_NullCommunicator_H +#define MPI_NullCommunicator_H #include "Communicator.h" -#include <PointerDefinitions.h> +namespace vf::mpi +{ //! \brief A class implements Communicator for shared memory. //! \details NullCommunicator is only a place-holder. It is only one process in shared memory. class NullCommunicator : public Communicator { public: - NullCommunicator(); - ~NullCommunicator() override; + // static std::shared_ptr<Communicator> getInstance(); int getBundleID() override; int getNumberOfBundles() override; int getProcessID() override; @@ -59,8 +59,9 @@ public: void sendSerializedObject(std::stringstream &ss, int target) override; void receiveSerializedObject(std::stringstream &ss, int source) override; -protected: -private: + }; +} + #endif