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/.gitignore b/.gitignore index df134f3d8f4289b954a8b3f7bfbc138b6be6f80e..8708a2906743e7953fd79b8277927031b1f6a32d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,11 +1,7 @@ # build directories -buildDev/ build/ -buildDev/ bin/ cmake-build-debug/ -MSVC2017/ -VS2017/ run/ # Python @@ -22,9 +18,7 @@ __pycache__/ # Simulation results output/ +logs/ # MacOS .DS_Store - -#Cluster -run/ diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index c5a86242d11893c2d1a7e876bee96665be2b0f3c..d2423ba9dc39c9d935c1d16b971396ce7d11e789 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,8 +1,12 @@ -image: irmb/virtualfluids-python-deps:latest +############################################################################### +## VirtualFluids CI Pipeline ## +############################################################################### +image: irmb/virtualfluids-python-deps-ubuntu20.04:latest stages: - build - build_python + - container_upload - test - benchmark - analyze @@ -33,27 +37,25 @@ stages: paths: - $BUILD_FOLDER - before_script: - - export CC=gcc - - export CXX=g++ + script: - export CCACHE_BASEDIR=$CI_PROJECT_DIR - export CCACHE_DIR=$CI_PROJECT_DIR/cache - - ccache -s - - - script: + - export CCACHE_COMPILERCHECK=content + - ccache --zero-stats + - ccache --show-stats - $CXX --version - $CC --version - cmake --version - mpirun --version - mkdir -p $CI_PROJECT_DIR/$BUILD_FOLDER - cd $CI_PROJECT_DIR/$BUILD_FOLDER - - cmake .. - --preset=all_make_ccache + - rm -r -f ./* + - cmake .. -LAH + --preset=all_make -DBUILD_WARNINGS_AS_ERRORS=ON -DCMAKE_CUDA_ARCHITECTURES=60 - - cmake . -LAH - make -j4 + - ccache --show-stats variables: BUILD_FOLDER: "build" @@ -62,8 +64,11 @@ stages: gcc_9: extends: .gnu_build_template -############################################################################### + before_script: + - export CC=gcc + - export CXX=g++ +############################################################################### clang_10: extends: .gnu_build_template @@ -71,42 +76,6 @@ clang_10: - export CC=clang - export CXX=clang++ - -############################################################################### -gcc_9_rebuild: - stage: build - - image: irmb/virtualfluids-deps-ubuntu20.04 - - tags: - - gpu - - linux - - before_script: - - export CCACHE_BASEDIR=$CI_PROJECT_DIR - - export CCACHE_DIR=$CI_PROJECT_DIR/cache - - ccache -s - - script: - - mkdir -p $CI_PROJECT_DIR/build - - cd $CI_PROJECT_DIR/build - - rm -r -f ./* - - cmake .. - --preset=all_make_ccache - -DBUILD_WARNINGS_AS_ERRORS=ON - -DCMAKE_CUDA_ARCHITECTURES=60 - - make -j4 2>&1 | tee gcc_warnings.txt - - ccache -s - - artifacts: - paths: - - build/gcc_warnings.txt - - cache: - key: "$CI_JOB_NAME-$CI_COMMIT_REF_SLUG" - paths: - - $CI_PROJECT_DIR/cache - ############################################################################### msvc_16: stage: build @@ -132,7 +101,7 @@ msvc_16: - cd $CI_PROJECT_DIR - md -force $env:BUILD_FOLDER - cd $env:BUILD_FOLDER - - cmake .. --preset=all_msvc -DBUILD_WARNINGS_AS_ERRORS=ON + - cmake .. --preset=all_msvc -DCMAKE_CUDA_ARCHITECTURES=61 -DBUILD_WARNINGS_AS_ERRORS=ON - MSBuild.exe VirtualFluids.sln /property:Configuration=$env:BUILD_CONFIGURATION /verbosity:minimal /maxcpucount:4 cache: @@ -145,33 +114,15 @@ msvc_16: paths: - $CI_PROJECT_DIR/$env:BUILD_FOLDER/ -############################################################################### -build_singularity_image: - stage: build - - tags: - - priviliged - - linux - - rules: - - if: $CI_COMMIT_TAG - - artifacts: - paths: - - Containers/VirtualFluidsOpenMPI.sif - - script: - - singularity build --fakeroot Containers/VirtualFluidsOpenMPI.sif Containers/VirtualFluidsOpenMPI.def - - ls -sh Containers/VirtualFluidsOpenMPI.sif - ############################################################################### ## Build Python ## ############################################################################### - gcc_9_python: stage: build_python + image: irmb/virtualfluids-python-deps-ubuntu20.04:latest + needs: ["gcc_9"] cache: @@ -190,7 +141,29 @@ gcc_9_python: - export CCACHE_DIR=$CI_PROJECT_DIR/cache script: - - python3 setup.py bdist_wheel + - python3 setup.py bdist_wheel build_ext --build-temp=build + +############################################################################### +## Container Upload ## +############################################################################### +build_singularity_image: + stage: container_upload + + image: irmb/virtualfluids-python-deps-ubuntu20.04:latest + + needs: + - gcc_9_python + + tags: + - linux + - privileged + + rules: + - if: $CI_COMMIT_TAG + + script: + - singularity build Containers/VirtualFluidsPython.sif Containers/VirtualFluidsPython.def + - singularity push --docker-username "${CI_REGISTRY_USER}" --docker-password "${CI_REGISTRY_PASSWORD}" Containers/VirtualFluidsPython.sif oras://"$CI_REGISTRY_IMAGE"/"$CI_PROJECT_NAME":"$CI_COMMIT_TAG" ############################################################################### ## Tests ## @@ -198,6 +171,8 @@ gcc_9_python: gcc_9_unit_tests: stage: test + image: irmb/virtualfluids-deps-ubuntu20.04:latest + needs: ["gcc_9"] before_script: @@ -228,6 +203,8 @@ 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: @@ -239,20 +216,63 @@ gcc_9_python_bindings_test: script: - python3 -m unittest discover -s Python -v +############################################################################### +gcc_9_python_slurm_test: + stage: test + + image: irmb/virtualfluids-python-deps-ubuntu20.04:latest + + needs: ["gcc_9_python"] + + rules: + - if: $PHOENIX_PRIVATE_KEY + + tags: + - linux + - privileged + + variables: + SSH_KEY: "$PHOENIX_PRIVATE_KEY" + HOST: "$PHOENIX_HOSTNAME" + USER: "$PHOENIX_USER" + + before_script: + - 'command -v ssh-agent >/dev/null || ( apt-get update -y && apt-get install openssh-client -y )' + - apt-get install -y rsync + - mkdir -p ~/.ssh + - chmod 700 ~/.ssh + - eval $(ssh-agent -s) + - echo "$SSH_KEY" | tr -d '\r' | ssh-add - + - echo $SSH_KEY >> ansible/private_key + - ssh-keyscan -t rsa $HOST >> ~/.ssh/known_hosts + - ssh $USER@$HOST "rm -rf output-*" + - ssh $USER@$HOST "rm -f *.out" + - pip3 install git+git://github.com/SvenMarcus/ssh-slurm-runner + + script: + - singularity build PoiseuilleTestContainer.sif Python/SlurmTests/poiseuille/PoiseuilleTestContainer.def + - scp PoiseuilleTestContainer.sif $USER@$HOST:PoiseuilleTestContainer.sif + - scp Python/SlurmTests/poiseuille/slurm.job $USER@$HOST:slurm.job + - python3 -m ssh_slurm_runner slurm.job --host $HOST --user $USER --keyfile ansible/private_key + - ssh $USER@$HOST "rm -rf output-*" + - ssh $USER@$HOST "rm -f *.out" + - ssh $USER@$HOST "rm PoiseuilleTestContainer.sif" + - ssh $USER@$HOST "rm slurm.job" + ############################################################################### ## Benchmark ## ############################################################################### nvidia_test: stage: benchmark + image: nvidia/cuda:11.1.1-devel-ubuntu20.04 + needs: [] tags: - gpu - linux - image: nvidia/cuda:11.1.1-devel-ubuntu20.04 - script: - echo NVIDIA_VISIBLE_DEVICES=${NVIDIA_VISIBLE_DEVICES} - nvidia-smi @@ -281,7 +301,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 @@ -297,6 +317,7 @@ gpu_numerical_tests: - $CI_PROJECT_DIR/cache artifacts: + expire_in: 1 hrs paths: - $CI_PROJECT_DIR/numerical_tests_gpu_results.txt @@ -373,11 +394,11 @@ include_what_you_use_clang_10: cppcheck: stage: analyze + image: irmb/virtualfluids-deps-ubuntu20.04 + only: - develop@irmb/VirtualFluids_dev - image: irmb/virtualfluids-deps-ubuntu20.04 - needs: [] before_script: @@ -389,11 +410,10 @@ cppcheck: - cd $CI_PROJECT_DIR - cppcheck --version - cppcheck src --enable=all --xml 2> cppcheck.xml - - cppcheck-htmlreport --file=cppcheck.xml --report-dir=html_report --source-dir=. artifacts: + expire_in: 1 week paths: - - html_report/ - cppcheck.xml ############################################################################### @@ -402,11 +422,11 @@ cppcheck: lizard: stage: analyze + image: irmb/virtualfluids-python-deps-ubuntu20.04:latest + only: - develop@irmb/VirtualFluids_dev - image: irmb/virtualfluids-python-deps-ubuntu20.04 - needs: [] before_script: @@ -421,6 +441,7 @@ lizard: - lizard -l cpp src/ > lizard.txt --warnings_only --ignore_warnings 400 artifacts: + expire_in: 1 week paths: - lizard.txt @@ -429,11 +450,11 @@ lizard: gcov_gcc_9: stage: analyze + image: irmb/virtualfluids-python-deps-ubuntu20.04:latest + only: - develop@irmb/VirtualFluids_dev - image: irmb/virtualfluids-python-deps-ubuntu20.04 - needs: [] before_script: @@ -456,9 +477,9 @@ gcov_gcc_9: - gcovr -r $CI_PROJECT_DIR -k build -f "src" --print-summary --html coverage/coverage.html --html-details --xml coverage/coverage.xml artifacts: + expire_in: 1 week paths: - coverage/ - - build/ reports: cobertura: coverage/coverage.xml @@ -473,13 +494,15 @@ gcov_gcc_9: clang-tidy: stage: analyze + image: irmb/virtualfluids-python-deps-ubuntu20.04:latest + only: - develop@irmb/VirtualFluids_dev - image: irmb/virtualfluids-python-deps-ubuntu20.04 - needs: [] + allow_failure: true + before_script: - run-clang-tidy -h @@ -494,16 +517,44 @@ clang-tidy: - run-clang-tidy -quiet > clangtidy.txt artifacts: + when: always + expire_in: 1 week paths: - build/clangtidy.txt - build/compile_commands.json + +############################################################################### +# doxgen +pages: + stage: analyze + + image: alpine + + only: + - develop@irmb/VirtualFluids_dev + + needs: [] + + script: + - apk update && apk add doxygen + - doxygen docs/Doxyfile + - mv docs/build/html/ public/ + + artifacts: + expire_in: 1 hrs + paths: + - public + + ############################################################################### ## Deploy ## ############################################################################### .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 )' - apt-get install -y rsync @@ -550,10 +601,10 @@ vf_wheel_to_jupyterhub: needs: ["gcc_9_python", "gcc_9_unit_tests", "gcc_9_python_bindings_test"] variables: - HOST: "finrod.irmb.bau.tu-bs.de" - SSH_KEY: "$SSH_PRIVATE_KEY_JUPYTER_HOST_AT_FINROD" - REMOTE_USER: "jupyter_host" - jupyter_host: "jupyter_host" + HOST: "gitlab-runner01.irmb.bau.tu-bs.de" + SSH_KEY: "$SSH_PRIVATE_KEY" + REMOTE_USER: "runner" + jupyter_host: "runner" script: - ansible-playbook -i ansible/hosts.cfg -u $REMOTE_USER ansible/playbook_jupyter_update.yml @@ -564,6 +615,9 @@ vf_wheel_to_jupyterhub: # This job only run on the development branch of the parent repository, not on forks! sonar-scanner: stage: deploy + + image: irmb/virtualfluids-python-deps-ubuntu20.04:latest + tags: - linux @@ -574,7 +628,7 @@ sonar-scanner: variables: SONAR_HOST_URL: "http://gitlab-runner01.irmb.bau.tu-bs.de/sonarqube/" - needs: ["cppcheck","clang-tidy","gcov_gcc_9","gcc_9_rebuild"] + needs: ["cppcheck","clang-tidy","gcov_gcc_9"] before_script: - cd /tmp @@ -596,9 +650,12 @@ sonar-scanner: ## Release ## ############################################################################### create_release: - image: registry.gitlab.com/gitlab-org/release-cli:latest stage: release + + image: registry.gitlab.com/gitlab-org/release-cli:latest + needs: ["build_singularity_image"] + rules: - if: $CI_COMMIT_TAG diff --git a/AUTHORS.md b/AUTHORS.md index aca25898d44f5d2f72ea8f018f54546197c301e1..00a5410811196462d6f808036be7feb5e74a102d 100644 --- a/AUTHORS.md +++ b/AUTHORS.md @@ -1,24 +1,25 @@ -AUTHORS -============ - +# AUTHORS VF has been developed essentially over the last fifteen years by various researchers at IRMB including (in alphabetical order): - -Dr. Benjamin Ahrenholz -M. Sc. Hussein Alihussein -Dr. Sebastian Bindick -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 -Dr. Jan Linxweiler -M. Sc. Sören Peters -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 +Dr. Benjamin Ahrenholz +M. Sc. Hussein Alihussein +Dr. Sebastian Bindick +B. Sc. Aileen Brendel +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 +Dr. Jan Linxweiler +B. Sc. Lennard Lux +B. Sc. Sven Marcus +M. Sc. Sören Peters +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 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 23d5029d2dff46076c27158e4f15d0375bf8565f..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 @@ -131,18 +132,18 @@ function(vf_add_library) ################################################################# ### ADD TARGET ### ################################################################# - IF(${ARG_BUILDTYPE} MATCHES binary) - ADD_EXECUTABLE(${library_name} ${MY_SRCS} ) + if(${ARG_BUILDTYPE} MATCHES binary) + add_executable(${library_name} ${MY_SRCS} ) groupTarget(${library_name} ${appFolder}) - ELSEIF(${ARG_BUILDTYPE} MATCHES shared) - ADD_LIBRARY(${library_name} SHARED ${MY_SRCS} ) + elseif(${ARG_BUILDTYPE} MATCHES shared) + add_library(${library_name} SHARED ${MY_SRCS} ) groupTarget(${library_name} ${libraryFolder}) - ELSEIF(${ARG_BUILDTYPE} MATCHES static) - ADD_LIBRARY(${library_name} STATIC ${MY_SRCS} ) + elseif(${ARG_BUILDTYPE} MATCHES static) + add_library(${library_name} STATIC ${MY_SRCS} ) groupTarget(${library_name} ${libraryFolder}) - ELSE() - MESSAGE(FATAL_ERROR "build_type=${ARG_BUILDTYPE} doesn't match BINARY, SHARED or STATIC") - ENDIF() + else() + message(FATAL_ERROR "build_type=${ARG_BUILDTYPE} doesn't match BINARY, SHARED or STATIC") + endif() # Set the output directory for build artifacts set_target_properties(${library_name} @@ -152,6 +153,24 @@ 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) + include(CheckIPOSupported) + check_ipo_supported(RESULT ipo_supported OUTPUT ipo_error LANGUAGES CXX) + + if( ipo_supported ) + status_lib("IPO / LTO enabled") + set_target_properties(${library_name} PROPERTIES INTERPROCEDURAL_OPTIMIZATION TRUE) + else() + status_lib("IPO / LTO not supported: <${ipo_error}>") + endif() + endif() + endif() + # clang-tidy if(BUILD_VF_CLANG_TIDY) find_program(CLANG_TIDY_PROGRAM NAMES clang-tidy) @@ -286,6 +305,7 @@ function(vf_add_tests) # link googlemock linkGMOCK() + # add the target to ctest gtest_add_tests(TARGET ${library_test_name}) endfunction() 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/CMake/cmake_config_files/MOLLOK.config.cmake b/CMake/cmake_config_files/MOLLOK.config.cmake index 4bb199d69dd2f88f786752374d244c643ca51d8a..03f83455175719ff5b0e786994213bbaa0fbd29e 100644 --- a/CMake/cmake_config_files/MOLLOK.config.cmake +++ b/CMake/cmake_config_files/MOLLOK.config.cmake @@ -5,9 +5,7 @@ ################################################################################# #SET TO CORRECT PATH: -SET(BOOST_ROOT "D:/libraries/boost_1_74_0" CACHE PATH "BOOST_ROOT") -SET(BOOST_LIBRARYDIR "D:/libraries/boost_1_74_0/stageMSVC64VS2019/lib" CACHE PATH "BOOST_LIBRARYDIR") -SET(CMAKE_CUDA_ARCHITECTURES 52) +SET(CMAKE_CUDA_ARCHITECTURES 86) SET(PATH_NUMERICAL_TESTS "D:/out/numericalTests/") LIST(APPEND VF_COMPILER_DEFINITION "PATH_NUMERICAL_TESTS=${PATH_NUMERICAL_TESTS}") diff --git a/CMake/cmake_config_files/TESLA03.config.cmake b/CMake/cmake_config_files/TESLA03.config.cmake index bf08ef36405df6090393f368e50e4e48795635af..91672511794eeb452f97a1aca952416c7e1179d5 100644 --- a/CMake/cmake_config_files/TESLA03.config.cmake +++ b/CMake/cmake_config_files/TESLA03.config.cmake @@ -19,3 +19,4 @@ SET(VTK_DIR "F:/Libraries/vtk/VTK-8.2.0/build" CACHE PATH "VTK directory overrid SET(PATH_NUMERICAL_TESTS "E:/temp/numericalTests/") LIST(APPEND VF_COMPILER_DEFINITION "PATH_NUMERICAL_TESTS=${PATH_NUMERICAL_TESTS}") +SET(CMAKE_CUDA_ARCHITECTURES 52) \ No newline at end of file diff --git a/CMake/compilerflags/GNU.cmake b/CMake/compilerflags/GNU.cmake index 3e67b79e9c84d29b51b2881b17e2b74f5510bbd2..8d54b52a434719a1e99aa705b121593973f3375a 100644 --- a/CMake/compilerflags/GNU.cmake +++ b/CMake/compilerflags/GNU.cmake @@ -38,6 +38,7 @@ list(APPEND CS_COMPILER_FLAGS_CXX "-Wno-unused-parameter") list(APPEND CS_COMPILER_FLAGS_CXX "-Wno-reorder") list(APPEND CS_COMPILER_FLAGS_CXX "-Wno-unknown-pragmas") list(APPEND CS_COMPILER_FLAGS_CXX "-Wno-cast-function-type") +list(APPEND CS_COMPILER_FLAGS_CXX "-Wno-strict-aliasing") ############################################################################################################# # linker options diff --git a/CMakeLists.txt b/CMakeLists.txt index 50e7a4fa6f8478d0818b7ded4000c0c406d2d97c..ba35020d9d893637d82d968b68116ff6a922e99a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,15 +6,20 @@ # |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ # ################################################################################# -# required cmake versions -# CMAKE 3.13: target_link_options -# CMAKE 3.15: CMAKE_MSVC_RUNTIME_LIBRARY -################################################################################# -cmake_minimum_required(VERSION 3.15..3.19 FATAL_ERROR) +cmake_minimum_required(VERSION 3.15..3.20 FATAL_ERROR) + +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) -project(VirtualFluids CXX) +if(NOT CMAKE_BUILD_TYPE) + set(CMAKE_BUILD_TYPE Release) +endif() +message(STATUS "CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}") -set(CMAKE_CXX_STANDARD 14) +set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) set_property(GLOBAL PROPERTY USE_FOLDERS ON) @@ -29,6 +34,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 ################################################################################# @@ -36,10 +46,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) @@ -51,6 +61,8 @@ option(BUILD_VF_INCLUDE_WHAT_YOU_USE "Add IWYU to the targets" OFF) option(BUILD_VF_CPPCHECK "Add cppcheck to the targets" OFF) option(BUILD_VF_COVERAGE "Add the -coverage compiler flag." OFF) +option(BUILD_CUDA_LTO "Enables the cuda link optimization." OFF) + option(BUILD_SHARED_LIBS "" OFF) option(BUILD_WARNINGS_AS_ERRORS "" OFF) @@ -69,6 +81,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) @@ -76,7 +97,7 @@ IF( BUILD_VF_DOUBLE_ACCURACY ) list(APPEND VF_COMPILER_DEFINITION VF_DOUBLE_ACCURACY) ENDIF() -if(BUILD_VF_GPU) +if(BUILD_VF_GPU OR BUILD_VF_GKS) include(CheckLanguage) check_language(CUDA) @@ -84,27 +105,56 @@ if(BUILD_VF_GPU) message(FATAL_ERROR "CUDA Compiler was requested but is not found on the system.") endif() - if(MSVC) - # With the MSVC compiler we got this warning: nvcc : The -std=c++14 flag is not supported with the configured host compiler. Flag will be ignored. - # But we build the c++ code with C++14. Until we have not a solution here, we set the standard to 11 here. - set(CMAKE_CUDA_STANDARD 11) - else() - set(CMAKE_CUDA_STANDARD 14) - endif() - + set(CMAKE_CUDA_STANDARD 17) set(CMAKE_CUDA_STANDARD_REQUIRED TRUE) + enable_language(CUDA) + if(NOT DEFINED CMAKE_CUDA_ARCHITECTURES) message(WARNING "CMAKE_CUDA_ARCHITECTURES was not defined and is set to 30 (CUDA support until 10.1 only).") set(CMAKE_CUDA_ARCHITECTURES 30) endif() - message("CUDA Architecture: ${CMAKE_CUDA_ARCHITECTURES}") + + if(BUILD_CUDA_LTO) + if(CMAKE_CUDA_ARCHITECTURES LESS 50) + message(FATAL_ERROR "CUDA Link time optimization requires CUDA 11.2 and CC 5.0.") + else() + + set(CMAKE_CUDA_FLAGS "-dlto -arch=sm_${CMAKE_CUDA_ARCHITECTURES}") + set(CMAKE_CUDA_ARCHITECTURES OFF) + + list(APPEND VF_COMPILER_DEFINITION BUILD_CUDA_LTO) + + endif() + endif() + + set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} --extended-lambda") + + 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) @@ -115,10 +165,28 @@ if(BUILD_USE_OPENMP) find_package(OpenMP REQUIRED) endif() -find_package(MPI REQUIRED) +if(BUILD_USE_MPI) + find_package(MPI REQUIRED) + list(APPEND VF_COMPILER_DEFINITION VF_MPI) +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) ################################################################################# @@ -127,6 +195,7 @@ add_subdirectory(src/basics) 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() diff --git a/CMakePresets.json b/CMakePresets.json index 6863446af85b177bb4dc99eed475aa52f4d50269..0f360fd303cdcad923b01d56df5c6d48ad62ca2c 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -1,133 +1,137 @@ { - "version": 1, - "cmakeMinimumRequired": { - "major": 3, - "minor": 19, - "patch": 0 - }, - "configurePresets": [ - { - "name": "default", - "hidden": true, - "binaryDir": "${sourceDir}/build/", - "cacheVariables": { - "BUILD_VF_UNIT_TESTS": "ON" - } - }, - { - "name": "default_make", - "inherits": "default", - "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", - "hidden": true, - "generator": "Visual Studio 16 2019", - "architecture": "x64" - }, - { - "name": "default_cpu", - "hidden": true, - "description": "CPU build of VirtualFluids", - "cacheVariables": { - "BUILD_VF_CPU": "ON" - } - }, - { - "name": "default_gpu", - "hidden": true, - "description": "GPU build of VirtualFluids", - "cacheVariables": { - "BUILD_VF_GPU": "ON" - } - }, - { - "name": "default_gpu_numerical_tests", - "inherits": ["default_gpu"], - "hidden": true, - "description": "GPU numerical tests of VirtualFluids", - "cacheVariables": { - "BUILD_VF_DOUBLE_ACCURACY": "ON", - "BUILD_NUMERIC_TESTS": "ON" - } - }, - { - "name": "default_all", - "hidden": true, - "description": "All build of VirtualFluids", - "inherits": ["default_cpu", "default_gpu"] - }, - { - "name": "cpu_make", - "inherits": ["default_make", "default_cpu"], - "displayName": "cpu make configuration" - }, - { - "name": "cpu_make_ccache", - "inherits": ["default_ccache_make", "default_cpu"], - "displayName": "cpu ccache make configuration" - }, - { - "name": "cpu_msvc", - "inherits": ["default_msvc", "default_cpu"], - "displayName": "cpu msvc configuration" - }, - { - "name": "gpu_make", - "inherits": ["default_make", "default_gpu"], - "displayName": "gpu make configuration" - }, - { - "name": "gpu_make_ccache", - "inherits": ["default_ccache_make", "default_gpu"], - "displayName": "gpu ccache make configuration" - }, - { - "name": "gpu_msvc", - "inherits": ["default_msvc", "default_gpu"], - "displayName": "gpu msvc configuration" - }, - { - "name": "all_make", - "inherits": ["default_make", "default_all"], - "displayName": "all make configuration" - }, - { - "name": "all_make_ccache", - "inherits": ["default_ccache_make", "default_all"], - "displayName": "all ccache make configuration" - }, - { - "name": "all_msvc", - "inherits": ["default_msvc", "default_all"], - "displayName": "all msvc configuration" - }, - { - "name": "gpu_numerical_tests_make", - "inherits": ["default_make", "default_gpu_numerical_tests"], - "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": ["default_msvc", "default_gpu_numerical_tests"], - "displayName": "gpu numerical tests msvc configuration" - } - ] + "version": 2, + "cmakeMinimumRequired": { + "major": 3, + "minor": 20, + "patch": 0 + }, + "configurePresets": [ + { + "name": "default", + "hidden": true, + "binaryDir": "${sourceDir}/build/", + "cacheVariables": { + "BUILD_VF_UNIT_TESTS": "ON" + } + }, + { + "name": "default_make", + "inherits": "default", + "hidden": true, + "generator": "Unix Makefiles" + }, + { + "name": "default_msvc", + "inherits": "default", + "hidden": true, + "generator": "Visual Studio 16 2019", + "architecture": "x64" + }, + { + "name": "default_cpu", + "hidden": true, + "description": "CPU build of VirtualFluids", + "cacheVariables": { + "BUILD_VF_CPU": "ON", + "BUILD_VF_DOUBLE_ACCURACY": "ON" + } + }, + { + "name": "default_gpu", + "hidden": true, + "description": "GPU build of VirtualFluids", + "cacheVariables": { + "BUILD_VF_GPU": "ON", + "BUILD_VF_DOUBLE_ACCURACY": "OFF" + } + }, + { + "name": "default_gpu_numerical_tests", + "inherits": [ + "default_gpu" + ], + "hidden": true, + "description": "GPU numerical tests of VirtualFluids", + "cacheVariables": { + "BUILD_VF_DOUBLE_ACCURACY": "ON", + "BUILD_NUMERIC_TESTS": "ON" + } + }, + { + "name": "default_all", + "hidden": true, + "description": "All build of VirtualFluids", + "inherits": [ + "default_cpu", + "default_gpu" + ], + "cacheVariables": { + "BUILD_VF_DOUBLE_ACCURACY": "ON" + } + }, + { + "name": "cpu_make", + "inherits": [ + "default_make", + "default_cpu" + ], + "displayName": "cpu make configuration" + }, + { + "name": "cpu_msvc", + "inherits": [ + "default_msvc", + "default_cpu" + ], + "displayName": "cpu msvc configuration" + }, + { + "name": "gpu_make", + "inherits": [ + "default_make", + "default_gpu" + ], + "displayName": "gpu make configuration" + }, + { + "name": "gpu_msvc", + "inherits": [ + "default_msvc", + "default_gpu" + ], + "displayName": "gpu msvc configuration" + }, + { + "name": "all_make", + "inherits": [ + "default_make", + "default_all" + ], + "displayName": "all make configuration" + }, + { + "name": "all_msvc", + "inherits": [ + "default_msvc", + "default_all" + ], + "displayName": "all msvc configuration" + }, + { + "name": "gpu_numerical_tests_make", + "inherits": [ + "default_make", + "default_gpu_numerical_tests" + ], + "displayName": "gpu numerical tests make configuration" + }, + { + "name": "gpu_numerical_tests_msvc", + "inherits": [ + "default_msvc", + "default_gpu_numerical_tests" + ], + "displayName": "gpu numerical tests msvc configuration" + } + ] } diff --git a/Containers/VirtualFluidsPython.def b/Containers/VirtualFluidsPython.def new file mode 100644 index 0000000000000000000000000000000000000000..d54066bc634cf25f4340b1e659eae72515467fa8 --- /dev/null +++ b/Containers/VirtualFluidsPython.def @@ -0,0 +1,33 @@ +BootStrap: docker +From: ubuntu:20.04 + +%files + Python Python + dist dist + + +%post + export DEBIAN_FRONTEND=noninteractive + apt-get update && \ + apt-get install -y \ + build-essential \ + cmake=3.16.3-1ubuntu1 \ + python3 \ + python3-dev \ + python3-pip \ + mpich \ + libomp-dev + + pip3 install setuptools wheel $(find dist/*.whl) + +%environment + export PYTHONPATH=/Python + +%runscript + python3 /Python/liddrivencavity/simulation.py + +%appenv poiseuille + export PYTHONPATH=Python + +%apprun poisueille + python3 /Python/poiseuille/poiseuille_hpc.py diff --git a/Python/SlurmTests/poiseuille/PoiseuilleTestContainer.def b/Python/SlurmTests/poiseuille/PoiseuilleTestContainer.def new file mode 100644 index 0000000000000000000000000000000000000000..a3836e7906b9be66ec79f68bf53ccc079db9d9ef --- /dev/null +++ b/Python/SlurmTests/poiseuille/PoiseuilleTestContainer.def @@ -0,0 +1,42 @@ +BootStrap: docker +From: ubuntu:20.04 + +%files + 3rdParty 3rdParty + apps apps + CMake CMake + Python Python + src src + CMakeLists.txt CMakeLists.txt + cpu.cmake cpu.cmake + gpu.cmake gpu.cmake + setup.py setup.py + pyproject.toml pyproject.toml + + +%post + export DEBIAN_FRONTEND=noninteractive + apt-get update && \ + apt-get install -y \ + build-essential \ + cmake=3.16.3-1ubuntu1 \ + python3 \ + python3-dev \ + python3-pip \ + mpich \ + libomp-dev \ + libgl1 + + pip3 install setuptools wheel numpy scipy pyvista + + export PYTHONPATH=Python + python3 /setup.py install + +%environment + export PYTHONPATH=/Python + +%apprun testcase + python3 /Python/SlurmTests/poiseuille/simulation_runner.py + +%apprun evaluate + python3 /Python/SlurmTests/poiseuille/evaluator.py \ No newline at end of file diff --git a/Python/SlurmTests/poiseuille/evaluator.py b/Python/SlurmTests/poiseuille/evaluator.py new file mode 100644 index 0000000000000000000000000000000000000000..74602846b67bb82f7e3c3d3ca3015fbe00a63041 --- /dev/null +++ b/Python/SlurmTests/poiseuille/evaluator.py @@ -0,0 +1,20 @@ +import numpy as np +import scipy.stats as stats +import errors +from SlurmTests.poiseuille.result_collector import collect_results +from SlurmTests.poiseuille.settings import Scaling + +analytical_results, numerical_results = collect_results() +normalized_l2_errors = [errors.normalized_l2_error(analytical, numerical) + for analytical, numerical in zip(analytical_results, numerical_results)] + +nodes_in_x3_per_run = [] +for simulation_run in range(0, 3): + grid_params, _, _, _ = Scaling.configuration_for_scale_level(simulation_run) + nodes_in_x3_per_run.append(grid_params.number_of_nodes_per_direction[2]) + +nodes_as_log = [np.log10(node) for node in nodes_in_x3_per_run] +l2_norms_as_log = [np.log10(l2) for l2 in normalized_l2_errors] +res = stats.linregress(nodes_as_log, l2_norms_as_log) + +assert res.slope <= -2, f"Expected slope of l2 error to be <= -2, but was {res.slope}" diff --git a/Python/SlurmTests/poiseuille/result_collector.py b/Python/SlurmTests/poiseuille/result_collector.py new file mode 100644 index 0000000000000000000000000000000000000000..06efa481c8c010647531426f2af2bec2c2d7eaee --- /dev/null +++ b/Python/SlurmTests/poiseuille/result_collector.py @@ -0,0 +1,73 @@ +from typing import Collection, List + +import pyvista as pv +from poiseuille.analytical import PoiseuilleSettings, poiseuille_at_heights +from vtk_utilities import vertical_column_from_mesh, get_values_from_indices +from SlurmTests.poiseuille.settings import Scaling + + +def get_output_file_name(output_folder, runtime_params): + timesteps = runtime_params.number_of_timesteps + file_name = f"{output_folder}/mq/mq{timesteps}/mq0_{timesteps}.bin.vtu" + + return file_name + + +def get_mesh_for_last_timestep(output_folder, runtime_params): + file_name_of_last_timestep = get_output_file_name(output_folder, runtime_params) + mesh_of_last_timestep = pv.read(file_name_of_last_timestep) + return mesh_of_last_timestep + + +def get_heights_from_indices(mesh, indices): + return [mesh.points[index][2] for index in indices] + + +def get_heights(output_folder, runtime_params): + mesh_of_last_timestep = get_mesh_for_last_timestep(output_folder, runtime_params) + column_indices = vertical_column_from_mesh(mesh_of_last_timestep) + heights = get_heights_from_indices(mesh_of_last_timestep, column_indices) + return heights + + +def get_numerical_results(runtime_params, output_folder): + mesh_of_last_timestep = get_mesh_for_last_timestep(output_folder, runtime_params) + velocities_in_x_direction = mesh_of_last_timestep.get_array("Vx") + column_indices = vertical_column_from_mesh(mesh_of_last_timestep) + numerical_results = get_values_from_indices(velocities_in_x_direction, column_indices) + + return numerical_results + + +def get_analytical_results(grid_params, physical_params, kernel, height_values): + channel_height = grid_params.number_of_nodes_per_direction[2] + settings = get_analytical_poiseuille_settings(channel_height, physical_params, kernel) + max_grid_height = channel_height * grid_params.node_distance + adjusted_height_values = [value / max_grid_height * channel_height for value in height_values] + analytical_results = poiseuille_at_heights(settings, adjusted_height_values) + return analytical_results + + +def get_analytical_poiseuille_settings(height, physical_params, kernel): + settings = PoiseuilleSettings() + settings.height = height + settings.viscosity = physical_params.lattice_viscosity + settings.density = 1 + settings.force = kernel.forcing_in_x1 + + return settings + + +def collect_results() -> (List[List[float]], List[List[float]]): + analytical_results = [] + numerical_results = [] + + for simulation_run in range(0, 3): + output_folder = f"output-{simulation_run}" + grid_params, physical_params, runtime_params, kernel = Scaling.configuration_for_scale_level(simulation_run) + heights = get_heights(output_folder, runtime_params) + analytical_results.append( + get_analytical_results(grid_params, physical_params, kernel, heights)) + numerical_results.append(get_numerical_results(runtime_params, output_folder)) + + return analytical_results, numerical_results diff --git a/Python/SlurmTests/poiseuille/settings.py b/Python/SlurmTests/poiseuille/settings.py new file mode 100644 index 0000000000000000000000000000000000000000..f75c2b1d7133323880dd5520de0a96cb8fa87860 --- /dev/null +++ b/Python/SlurmTests/poiseuille/settings.py @@ -0,0 +1,26 @@ +import os +from acousticscaling import OneDirectionalAcousticScaling +from pyfluids.kernel import LBMKernel, KernelType +from pyfluids.parameters import RuntimeParameters, GridParameters, PhysicalParameters + + +grid_params = GridParameters() +grid_params.node_distance = 1 +grid_params.number_of_nodes_per_direction = [1, 1, 16] +grid_params.blocks_per_direction = [1, 1, 4] +grid_params.periodic_boundary_in_x1 = True +grid_params.periodic_boundary_in_x2 = True + +physical_params = PhysicalParameters() +physical_params.lattice_viscosity = 1e-4 + +runtime_params = RuntimeParameters() +runtime_params.number_of_threads = int(os.environ["PYFLUIDS_NUM_THREADS"]) +runtime_params.number_of_timesteps = 4_000_000 +runtime_params.timestep_log_interval = 1_000_000 + +kernel = LBMKernel(KernelType.CompressibleCumulantFourthOrderViscosity) +kernel.use_forcing = True +kernel.forcing_in_x1 = 5e-10 + +Scaling = OneDirectionalAcousticScaling(grid_params, physical_params, runtime_params, kernel) diff --git a/Python/SlurmTests/poiseuille/simulation_runner.py b/Python/SlurmTests/poiseuille/simulation_runner.py new file mode 100644 index 0000000000000000000000000000000000000000..0b75de40b6a8f11ccd76f97f2ed9d709dc5362dd --- /dev/null +++ b/Python/SlurmTests/poiseuille/simulation_runner.py @@ -0,0 +1,19 @@ +import os + +from SlurmTests.poiseuille.settings import Scaling +from poiseuille.simulation import run_simulation +from pyfluids.writer import Writer, OutputFormat + + +scale_level = int(os.environ["PYFLUIDS_SCALE_LEVEL"]) +grid_params, physical_params, runtime_params, kernel = Scaling.configuration_for_scale_level(scale_level) + +writer = Writer() +writer.output_format = OutputFormat.BINARY +writer.output_path = "./output-" + str(scale_level) + +run_simulation(grid_params=grid_params, + physical_params=physical_params, + runtime_params=runtime_params, + kernel=kernel, + writer=writer) diff --git a/Python/SlurmTests/poiseuille/slurm.job b/Python/SlurmTests/poiseuille/slurm.job new file mode 100644 index 0000000000000000000000000000000000000000..488fc9a42f261d69a8212cff389721fdfb9cbf6e --- /dev/null +++ b/Python/SlurmTests/poiseuille/slurm.job @@ -0,0 +1,26 @@ +#!/bin/bash +#SBATCH -J PyFluidsTest +#SBATCH --nodes=1 +#SBATCH --ntasks-per-node=1 +#SBATCH --cpus-per-task=20 + +#SBATCH --mem-per-cpu=3000 +#SBATCH --time=07:00:00 +#SBATCH --partition=standard + +source $HOME/.bashrc + +echo "PyFluids Poiseuille Test Case" +echo "Number of tasks: ${SLURM_NTASKS}" + +export SINGULARITYENV_PYFLUIDS_SCALE_LEVEL=0 +export SINGULARITYENV_PYFLUIDS_NUM_THREADS=4 +srun singularity run --app testcase PoiseuilleTestContainer.sif + +export SINGULARITYENV_PYFLUIDS_SCALE_LEVEL=1 +srun singularity run --app testcase PoiseuilleTestContainer.sif + +export SINGULARITYENV_PYFLUIDS_SCALE_LEVEL=2 +srun singularity run --app testcase PoiseuilleTestContainer.sif + +srun singularity run --app evaluate PoiseuilleTestContainer.sif diff --git a/Python/acousticscaling.py b/Python/acousticscaling.py new file mode 100644 index 0000000000000000000000000000000000000000..50b81db064251fa269f29bf72a561567ddedafbc --- /dev/null +++ b/Python/acousticscaling.py @@ -0,0 +1,85 @@ +from pyfluids.kernel import LBMKernel +from pyfluids.parameters import GridParameters, PhysicalParameters, RuntimeParameters + + +class OneDirectionalAcousticScaling: + + def __init__(self, grid_parameters: GridParameters, + physical_parameters: PhysicalParameters, + runtime_parameters: RuntimeParameters, + kernel: LBMKernel): + self._grid_params = grid_parameters + self._physical_params = physical_parameters + self._runtime_params = runtime_parameters + self._kernel = kernel + + def configuration_for_scale_level(self, level: int = 1) -> (GridParameters, + PhysicalParameters, + RuntimeParameters, + LBMKernel): + if level < 0: + raise ValueError("level must be >= 0") + + grid_params = self.clone_grid_params_for_level(level) + physical_params = self.clone_physical_parameters(level) + runtime_params = self.clone_runtime_params_for_level(level) + kernel = self.clone_kernel_for_level(level) + + return grid_params, physical_params, runtime_params, kernel + + def clone_grid_params_for_level(self, level) -> GridParameters: + grid_params = GridParameters() + grid_params.reference_direction_index = self._grid_params.reference_direction_index + grid_params.periodic_boundary_in_x1 = self._grid_params.periodic_boundary_in_x1 + grid_params.periodic_boundary_in_x2 = self._grid_params.periodic_boundary_in_x2 + grid_params.periodic_boundary_in_x3 = self._grid_params.periodic_boundary_in_x3 + + grid_params.number_of_nodes_per_direction = list(self._grid_params.number_of_nodes_per_direction) + grid_params.blocks_per_direction = list(self._grid_params.blocks_per_direction) + grid_params.node_distance = self._grid_params.node_distance + + if level > 0: + grid_params.node_distance /= (level * 2) + grid_params.number_of_nodes_per_direction = [grid_params.number_of_nodes_per_direction[0], + grid_params.number_of_nodes_per_direction[1], + grid_params.number_of_nodes_per_direction[2] * (level * 2)] + + grid_params.blocks_per_direction = [grid_params.blocks_per_direction[0], + grid_params.blocks_per_direction[1], + grid_params.blocks_per_direction[2] * (level * 2)] + + return grid_params + + def clone_physical_parameters(self, level): + physical_params = PhysicalParameters() + physical_params.lattice_viscosity = self._physical_params.lattice_viscosity + + if level > 0: + physical_params.lattice_viscosity *= (level * 2) + + return physical_params + + def clone_runtime_params_for_level(self, level): + runtime_params = RuntimeParameters() + runtime_params.number_of_timesteps = self._runtime_params.number_of_timesteps + runtime_params.number_of_threads = self._runtime_params.number_of_threads + runtime_params.timestep_log_interval = self._runtime_params.timestep_log_interval + + if level > 0: + runtime_params.number_of_timesteps *= (level * 2) + + return runtime_params + + def clone_kernel_for_level(self, level): + kernel = LBMKernel(self._kernel.type) + kernel.use_forcing = self._kernel.use_forcing + kernel.forcing_in_x1 = self._kernel.forcing_in_x1 + kernel.forcing_in_x2 = self._kernel.forcing_in_x2 + kernel.forcing_in_x3 = self._kernel.forcing_in_x3 + + if level > 0: + kernel.forcing_in_x1 /= (level * 2) + kernel.forcing_in_x2 /= (level * 2) + kernel.forcing_in_x3 /= (level * 2) + + return kernel diff --git a/Python/norms.py b/Python/errors.py similarity index 96% rename from Python/norms.py rename to Python/errors.py index 78ae344591e4d91f28b9a98cf1e28ef447e2f62a..16e8c48ab9f0b7a46ed1372ef0b4d45738cccb1b 100644 --- a/Python/norms.py +++ b/Python/errors.py @@ -42,8 +42,8 @@ def mean_squared_error(real_values, numerical_values): return sum_of_squared_distances / num_values -def l2_norm_error(real_values, numerical_values): +def normalized_l2_error(real_values, numerical_values): sum_of_squared_distances = get_sum_of_squared_distances(real_values, numerical_values) sum_of_squared_real_values = sum(real_value ** 2 for real_value in real_values) - return math.sqrt(sum_of_squared_distances / sum_of_squared_real_values) \ No newline at end of file + return math.sqrt(sum_of_squared_distances / sum_of_squared_real_values) diff --git a/Python/poiseuille/analytical.py b/Python/poiseuille/analytical.py index bca1a3ff95c1f28bca68ebb0c14efee48a1a5984..33e67595d94c50a1eb98751b7f10df9a031800e8 100644 --- a/Python/poiseuille/analytical.py +++ b/Python/poiseuille/analytical.py @@ -1,39 +1,52 @@ from dataclasses import dataclass +@dataclass class PoiseuilleSettings: - - def __init__(self): - self.density = 1 - self.viscosity = 0.005 - self.height = 10 - self.length = 1 - self.pressure_in = 0 - self.pressure_out = 0 - self.force = 0 + density = 1 + viscosity = 0.005 + height = 10 + length = 1 + pressure_in = 0 + pressure_out = 0 + force = 0 def poiseuille_at_z(settings: PoiseuilleSettings, z: float): pressure_grad = ((settings.pressure_out - settings.pressure_in) / settings.length) - return (1 / settings.viscosity + return ((1 / settings.viscosity) * (- pressure_grad + settings.density * settings.force) - * z / 2 * (settings.height - z)) + * (z / 2) + * (settings.height - z)) def poiseuille_at_heights(settings: PoiseuilleSettings, heights): return [poiseuille_at_z(settings, z) for z in heights] -if __name__ == '__main__': - # h1 = [1, 2, 3, 4, 5, 6, 7, 8, 9] - # h2 = [0.5, 1, 1.5, 2, 2.5, 3, 3.5, 4, 4.5, 5, 6, 6.5, 7, 7.5, 8, 8.5, 9, 9.5] - settings = PoiseuilleSettings() - settings.force = 1e-8 - settings.height = 32 +def reynolds_number(settings: PoiseuilleSettings): + max_v = poiseuille_at_z(settings, settings.height / 2) + return max_v * settings.height / settings.viscosity - # print(max(poiseuille_at_heights(settings, h1))) - # print(max(poiseuille_at_heights(settings, h2))) - v = poiseuille_at_z(settings, 16) - print(v) \ No newline at end of file +if __name__ == '__main__': + sim_settings = PoiseuilleSettings() + + sim_settings.force = 2e-7 + sim_settings.viscosity = 1e-3 + sim_settings.height = 16 + print(f"v_max = ", poiseuille_at_z(sim_settings, sim_settings.height / 2)) + print(f"Re =", reynolds_number(sim_settings)) + + sim_settings.viscosity *= 2 + sim_settings.height *= 2 + sim_settings.force /= 2 + print(f"v_max = ", poiseuille_at_z(sim_settings, sim_settings.height / 2)) + print(f"Re =", reynolds_number(sim_settings)) + + sim_settings.viscosity *= 2 + sim_settings.height *= 2 + sim_settings.force /= 2 + print(f"v_max = ", poiseuille_at_z(sim_settings, sim_settings.height / 2)) + print(f"Re =", reynolds_number(sim_settings)) diff --git a/Python/poiseuille/simulation.py b/Python/poiseuille/simulation.py index f7f6d468f19820993c61b458b3b0138b8c886139..31ceb1ab9ef90fa4fd606bde4f47c45b8f7d7567 100644 --- a/Python/poiseuille/simulation.py +++ b/Python/poiseuille/simulation.py @@ -17,23 +17,30 @@ default_physical_params.lattice_viscosity = 0.005 default_runtime_params = RuntimeParameters() default_runtime_params.number_of_threads = 4 -default_runtime_params.number_of_timesteps = 100000 -default_runtime_params.timestep_log_interval = 10000 +default_runtime_params.number_of_timesteps = 10000 +default_runtime_params.timestep_log_interval = 1000 + +default_kernel = LBMKernel(KernelType.CompressibleCumulantFourthOrderViscosity) +default_kernel.use_forcing = True +default_kernel.forcing_in_x1 = 1e-8 + +default_writer = Writer() +default_writer.output_path = "./output" +default_writer.output_format = OutputFormat.BINARY + + +default_kernel = LBMKernel(KernelType.CompressibleCumulantFourthOrderViscosity) +default_kernel.use_forcing = True +default_kernel.forcing_in_x1 = 1e-8 def run_simulation(physical_params=default_physical_params, grid_params=default_grid_params, - runtime_params=default_runtime_params): + runtime_params=default_runtime_params, + kernel=default_kernel, + writer=default_writer): simulation = Simulation() - kernel = LBMKernel(KernelType.CompressibleCumulantFourthOrderViscosity) - kernel.use_forcing = True - kernel.forcing_in_x1 = 1e-8 - - writer = Writer() - writer.output_path = "./output" - writer.output_format = OutputFormat.BINARY - simulation.set_kernel_config(kernel) simulation.set_physical_parameters(physical_params) simulation.set_grid_parameters(grid_params) @@ -42,26 +49,26 @@ def run_simulation(physical_params=default_physical_params, no_slip_bc = NoSlipBoundaryCondition() - block_width = 3 * grid_params.node_distance + block_thickness = 3 * grid_params.node_distance simulation.add_object( GbCuboid3D( - grid_params.bounding_box.min_x1 - block_width, - grid_params.bounding_box.min_x2 - block_width, - grid_params.bounding_box.min_x3 - block_width, - grid_params.bounding_box.max_x1 + block_width, - grid_params.bounding_box.max_x2 + block_width, + grid_params.bounding_box.min_x1 - block_thickness, + grid_params.bounding_box.min_x2 - block_thickness, + grid_params.bounding_box.min_x3 - block_thickness, + grid_params.bounding_box.max_x1 + block_thickness, + grid_params.bounding_box.max_x2 + block_thickness, grid_params.bounding_box.min_x3), no_slip_bc, State.SOLID, "/geo/addWallZMin") simulation.add_object( GbCuboid3D( - grid_params.bounding_box.min_x1 - block_width, - grid_params.bounding_box.min_x2 - block_width, + grid_params.bounding_box.min_x1 - block_thickness, + grid_params.bounding_box.min_x2 - block_thickness, grid_params.bounding_box.max_x3, - grid_params.bounding_box.max_x1 + block_width, - grid_params.bounding_box.max_x2 + block_width, - grid_params.bounding_box.max_x3 + block_width), + grid_params.bounding_box.max_x1 + block_thickness, + grid_params.bounding_box.max_x2 + block_thickness, + grid_params.bounding_box.max_x3 + block_thickness), no_slip_bc, State.SOLID, "/geo/addWallZMax") diff --git a/Python/poiseuille/test_poiseuille_l2.py b/Python/poiseuille/test_poiseuille_l2.py index 508fda5d6f551d428d314ffbfa657b4b6b2a230a..39c8b6dffe05e3c352e7fd340857e43d8d5a3dc8 100644 --- a/Python/poiseuille/test_poiseuille_l2.py +++ b/Python/poiseuille/test_poiseuille_l2.py @@ -1,68 +1,90 @@ +import os import shutil 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 scipy import stats -from norms import l2_norm_error +from errors import normalized_l2_error from poiseuille.analytical import poiseuille_at_heights, PoiseuilleSettings from poiseuille.simulation import run_simulation from vtk_utilities import vertical_column_from_mesh, get_values_from_indices class TestPoiseuilleFlow(unittest.TestCase): + node_distances = [1, 0.5, 0.25] + number_of_nodes = [16, 32, 64] + number_of_timesteps = [2_500_000, 5_000_000, 10_000_000] + forcings = [1e-9, 5e-10, 2.5e-10] + viscosities = [1e-3, 2e-3, 4e-3] + + def zipped_settings(self): + return zip(self.node_distances, + self.number_of_nodes, + self.number_of_timesteps, + self.forcings, + self.viscosities) def test_poiseuille_flow(self): - self.skipTest("Skipping test! This test has not been implemented correctly yet") + self.skipTest("This test is not implemented correctly yet") plt.ion() - channel_height = 10 - number_of_nodes = [8, 16, 32] - number_of_timesteps = [10_000, 20_000, 40_000] - viscosities = [5e-3, 1e-2, 2e-2] - l2_norm_results = [] - physical_params = PhysicalParameters() runtime_params = RuntimeParameters() - runtime_params.number_of_threads = 4 - runtime_params.timestep_log_interval = 1000 - - for test_number, nodes_in_column in enumerate(number_of_nodes): - runtime_params.number_of_timesteps = number_of_timesteps[test_number] - physical_params.lattice_viscosity = viscosities[test_number] - delta_x = channel_height / nodes_in_column - grid_params = create_grid_params_with_nodes_in_column(nodes_in_column, delta_x) - l2_norm_result = get_l2_norm_for_simulation(grid_params, physical_params, runtime_params) - l2_norm_results.append(l2_norm_result) - - plt.plot(number_of_nodes, l2_norm_results) + runtime_params.number_of_threads = os.cpu_count() + runtime_params.timestep_log_interval = 10000 + + kernel = LBMKernel(KernelType.CompressibleCumulantFourthOrderViscosity) + kernel.use_forcing = True + + normalized_l2_errors = [] + for delta_x, nodes, timesteps, forcing, viscosity in self.zipped_settings(): + physical_params.lattice_viscosity = viscosity + runtime_params.number_of_timesteps = timesteps + kernel.forcing_in_x1 = forcing + + grid_params = create_grid_params_with_nodes_in_column(nodes, delta_x) + l2_error = get_l2_error_for_simulation(grid_params, physical_params, runtime_params, kernel) + normalized_l2_errors.append(l2_error) + + nodes_as_log = [np.log10(node) for node in self.number_of_nodes] + l2_norms_as_log = [np.log10(l2) for l2 in normalized_l2_errors] + res = stats.linregress(nodes_as_log, l2_norms_as_log) + + plt.xscale("log") + plt.yscale("log") + plt.plot(self.number_of_nodes, [np.power(10, res.intercept + res.slope * node) for node in nodes_as_log], 'r-') + plt.plot(self.number_of_nodes, normalized_l2_errors, "x:") plt.show() - self.assertTrue(l2_norm_results[1] <= l2_norm_results[0]) - self.assertTrue(l2_norm_results[2] <= l2_norm_results[1]) - - -def run_simulation_with_settings(grid_params, physical_params, runtime_params, output_folder): - remove_existing_output_directory(output_folder) - run_simulation(physical_params, grid_params, runtime_params) + print(normalized_l2_errors) + self.assertAlmostEqual(res.slope, -2, places=2) -def get_l2_norm_for_simulation(grid_params, physical_params, runtime_params): +def get_l2_error_for_simulation(grid_params, physical_params, runtime_params, kernel): output_folder = "./output" - run_simulation_with_settings(grid_params, physical_params, runtime_params, output_folder) + run_simulation_with_settings(grid_params, physical_params, runtime_params, kernel, output_folder) heights = get_heights(output_folder, runtime_params) - numerical_results = get_numerical_results(runtime_params, output_folder, heights) - analytical_results = get_analytical_results(physical_params, heights, grid_params.number_of_nodes_per_direction[2]) + numerical_results = get_numerical_results(runtime_params, output_folder) + analytical_results = get_analytical_results(grid_params, physical_params, kernel, heights) plt.plot(heights, numerical_results) plt.plot(heights, analytical_results) plt.legend(["numerical", "analytical"]) plt.show() - return l2_norm_error(analytical_results, numerical_results) + return normalized_l2_error(analytical_results, numerical_results) + + +def run_simulation_with_settings(grid_params, physical_params, runtime_params, kernel, output_folder): + shutil.rmtree(output_folder, ignore_errors=True) + run_simulation(physical_params, grid_params, runtime_params, kernel) def get_heights(output_folder, runtime_params): @@ -72,7 +94,7 @@ def get_heights(output_folder, runtime_params): return heights -def get_numerical_results(runtime_params, output_folder, heights): +def get_numerical_results(runtime_params, output_folder): mesh_of_last_timestep = get_mesh_for_last_timestep(output_folder, runtime_params) velocities_in_x_direction = mesh_of_last_timestep.get_array("Vx") column_indices = vertical_column_from_mesh(mesh_of_last_timestep) @@ -81,16 +103,12 @@ def get_numerical_results(runtime_params, output_folder, heights): return numerical_results -def calculate_analytical_results(physical_params, height_values, channel_height): - settings = get_analytical_poiseuille_settings(channel_height, physical_params) - max_height = max(height_values) - height_values = [value / max_height * channel_height for value in height_values] - analytical_results = poiseuille_at_heights(settings, height_values) - return analytical_results - - -def get_analytical_results(physical_params, heights, channel_height): - analytical_results = calculate_analytical_results(physical_params, heights, channel_height) +def get_analytical_results(grid_params, physical_params, kernel, height_values): + channel_height = grid_params.number_of_nodes_per_direction[2] + settings = get_analytical_poiseuille_settings(channel_height, physical_params, kernel) + max_grid_height = channel_height * grid_params.node_distance + adjusted_height_values = [value / max_grid_height * channel_height for value in height_values] + analytical_results = poiseuille_at_heights(settings, adjusted_height_values) return analytical_results @@ -100,18 +118,12 @@ def get_mesh_for_last_timestep(output_folder, runtime_params): return mesh_of_last_timestep -def remove_existing_output_directory(output_dir): - shutil.rmtree(output_dir, ignore_errors=True) - - -def get_analytical_poiseuille_settings(height, physical_params): +def get_analytical_poiseuille_settings(height, physical_params, kernel): settings = PoiseuilleSettings() settings.height = height settings.viscosity = physical_params.lattice_viscosity settings.density = 1 - settings.force = 1e-8 - - # print(settings) + settings.force = kernel.forcing_in_x1 return settings @@ -130,13 +142,10 @@ def get_heights_from_indices(mesh, indices): def create_grid_params_with_nodes_in_column(nodes_in_column, delta_x): grid_params = GridParameters() grid_params.node_distance = delta_x - grid_params.number_of_nodes_per_direction = [2, 2, nodes_in_column] - grid_params.blocks_per_direction = [1, 1, 6] + grid_params.number_of_nodes_per_direction = [1, 1, nodes_in_column] + grid_params.blocks_per_direction = [1, 1, 8] grid_params.periodic_boundary_in_x1 = True grid_params.periodic_boundary_in_x2 = True grid_params.periodic_boundary_in_x3 = False - print(f"GridParameters.node_distance = {grid_params.node_distance}") - print(f"GridParameters.number_of_nodes_per_direction = {grid_params.number_of_nodes_per_direction}") - return grid_params diff --git a/Python/requirements.txt b/Python/requirements.txt index ded26051abb63145842f304ba865dc8487a8be73..8628634d1b85ebc0b07328d563d479f35641be97 100644 --- a/Python/requirements.txt +++ b/Python/requirements.txt @@ -14,8 +14,10 @@ py==1.10.0 pyparsing==2.4.7 pytest==6.2.1 python-dateutil==2.8.1 -pyvista==0.27.4 +pyvista==0.28.1 +scipy==1.6.1 scooby==0.5.6 six==1.15.0 toml==0.10.2 +transforms3d==0.3.1 vtk==9.0.1 diff --git a/Python/tests/test_acousticscaling.py b/Python/tests/test_acousticscaling.py new file mode 100644 index 0000000000000000000000000000000000000000..2da5314529f9559f9ac316f2d1bb3f1a9d0e1211 --- /dev/null +++ b/Python/tests/test_acousticscaling.py @@ -0,0 +1,115 @@ +import unittest +from typing import List + +from pyfluids.kernel import LBMKernel, KernelType +from pyfluids.parameters import GridParameters, PhysicalParameters, RuntimeParameters + +from acousticscaling import OneDirectionalAcousticScaling + + +class OneDirectionalAcousticScalingTest(unittest.TestCase): + + def setUp(self) -> None: + self.grid_params = self.make_grid_params() + self.physical_params = self.make_physical_params() + self.runtime_params = self.make_runtime_params() + self.kernel = self.make_kernel() + + self.sut = OneDirectionalAcousticScaling(self.grid_params, self.physical_params, self.runtime_params, + self.kernel) + + def test_given_sim_parameters__when_scaling_level_zero__should_return_equal_sim_parameters(self): + factor = 1 + actual_params = self.sut.configuration_for_scale_level(0) + actual_grid_params = actual_params[0] + actual_physical_params = actual_params[factor] + actual_runtime_params = actual_params[2] + actual_kernel = actual_params[3] + + self.assert_parameters_scaled_by_factor(actual_grid_params, actual_kernel, + actual_physical_params, actual_runtime_params, factor) + + def test_given_sim_parameters__when_scaling_level_one__should_return_sim_parameters_scaled_by_two(self): + actual_params = self.sut.configuration_for_scale_level(1) + actual_grid_params = actual_params[0] + actual_physical_params = actual_params[1] + actual_runtime_params = actual_params[2] + actual_kernel = actual_params[3] + + self.assert_parameters_scaled_by_factor(actual_grid_params, actual_kernel, + actual_physical_params, actual_runtime_params, 2) + + def assert_parameters_scaled_by_factor(self, actual_grid_params, actual_kernel, + actual_physical_params, actual_runtime_params, factor): + self.assert_grid_params_scaled_by_factor(actual_grid_params, factor=factor) + self.assert_physical_params_scaled_by_factor(actual_physical_params, factor=factor) + self.assert_runtime_params_scaled_by_factor(actual_runtime_params, factor=factor) + self.assert_kernel_forcing_scaled_by_factor(actual_kernel, factor=factor) + + def assert_grid_params_scaled_by_factor(self, actual_grid_params: GridParameters, factor: int): + expected_nodes_per_direction = self.scaled_list(self.grid_params.number_of_nodes_per_direction, factor) + expected_blocks_per_direction = self.scaled_list(self.grid_params.blocks_per_direction, factor) + expected_node_distance = self.grid_params.node_distance / factor + self.assertEqual(expected_node_distance, actual_grid_params.node_distance) + self.assertEqual(expected_nodes_per_direction, actual_grid_params.number_of_nodes_per_direction) + self.assertEqual(expected_blocks_per_direction, actual_grid_params.blocks_per_direction) + self.assertEqual(self.grid_params.reference_direction_index, actual_grid_params.reference_direction_index) + self.assertEqual(self.grid_params.periodic_boundary_in_x1, actual_grid_params.periodic_boundary_in_x1) + self.assertEqual(self.grid_params.periodic_boundary_in_x2, actual_grid_params.periodic_boundary_in_x2) + self.assertEqual(self.grid_params.periodic_boundary_in_x3, actual_grid_params.periodic_boundary_in_x3) + + def assert_physical_params_scaled_by_factor(self, actual_params: PhysicalParameters, factor: int): + self.assertEqual(self.physical_params.lattice_viscosity * factor, actual_params.lattice_viscosity) + self.assertEqual(self.physical_params.bulk_viscosity_factor, actual_params.bulk_viscosity_factor) + + def assert_runtime_params_scaled_by_factor(self, actual_params: RuntimeParameters, factor: int): + self.assertEqual(self.runtime_params.number_of_timesteps * factor, actual_params.number_of_timesteps) + self.assertEqual(self.runtime_params.number_of_threads, actual_params.number_of_threads) + self.assertEqual(self.runtime_params.timestep_log_interval, actual_params.timestep_log_interval) + + def assert_kernel_forcing_scaled_by_factor(self, actual_kernel: LBMKernel, factor: int): + self.assertEqual(self.kernel.type, actual_kernel.type) + self.assertEqual(self.kernel.use_forcing, actual_kernel.use_forcing) + self.assertAlmostEqual(self.kernel.forcing_in_x1 / factor, actual_kernel.forcing_in_x1) + self.assertAlmostEqual(self.kernel.forcing_in_x2, actual_kernel.forcing_in_x2) + self.assertAlmostEqual(self.kernel.forcing_in_x3, actual_kernel.forcing_in_x3) + + @staticmethod + def scaled_list(list_to_scale: List[int], factor: int) -> List[int]: + return [list_to_scale[0], list_to_scale[1], list_to_scale[2] * factor] + + @staticmethod + def make_kernel(): + kernel = LBMKernel(KernelType.CompressibleCumulantFourthOrderViscosity) + kernel.use_forcing = True + kernel.forcing_in_x1 = 5e-10 + return kernel + + @staticmethod + def make_runtime_params(): + runtime_params = RuntimeParameters() + runtime_params.number_of_threads = 4 + runtime_params.number_of_timesteps = 4_000_000 + runtime_params.timestep_log_interval = 1_000_000 + return runtime_params + + @staticmethod + def make_physical_params(): + physical_params = PhysicalParameters() + physical_params.lattice_viscosity = 1e-4 + return physical_params + + @staticmethod + def make_grid_params(): + grid_params = GridParameters() + grid_params.node_distance = 1 + grid_params.number_of_nodes_per_direction = [1, 1, 16] + grid_params.blocks_per_direction = [1, 1, 16] + grid_params.periodic_boundary_in_x1 = True + grid_params.periodic_boundary_in_x2 = True + + return grid_params + + +if __name__ == '__main__': + unittest.main() diff --git a/Python/tests/test_boundaryconditions.py b/Python/tests/test_boundaryconditions.py new file mode 100644 index 0000000000000000000000000000000000000000..5a7d61f36337398fc5621540951f15b72262b17b --- /dev/null +++ b/Python/tests/test_boundaryconditions.py @@ -0,0 +1,61 @@ +import unittest +from pyfluids.boundaryconditions import * + + +class BoundaryConditionsTest(unittest.TestCase): + + def test__can_create_no_slip_bc(self): + """ + Should be able to create NoSlipBoundaryCondition + """ + sut = NoSlipBoundaryCondition() + + def test__can_create_velocity_bc(self): + """ + Should be able to create VelocityBoundaryCondition + """ + sut = VelocityBoundaryCondition() + + def test__can_create_velocity_bc_with_directions_function_and_time(self): + """ + Should be able to create VelocityBoundaryCondition with directions, function and start/end time + """ + from pymuparser import Parser + + parser = Parser() + parser.expression = "1" + sut = VelocityBoundaryCondition(True, True, True, parser, 0, 1) + + def test__can_create_velocity_bc_with_directions__function_per_direction__and__time(self): + """ + Should be able to create VelocityBoundaryCondition with directions, function per direction and start/end time + """ + from pymuparser import Parser + + f1 = Parser() + f1.expression = "1" + + f2 = Parser() + f2.expression = "1" + + f3 = Parser() + f3.expression = "1" + sut = VelocityBoundaryCondition(True, True, True, f1, f2, f3, 0, 1) + + def test__can_create_velocity_bc_with_speeds_and_times_per_direction(self): + """ + Should be able to create VelocityBoundaryCondition with speeds and start/end times per direction + """ + vx1, vx2, vx3 = 1, 2, 3 + start1, end1 = 0, 1 + start2, end2 = 1, 2 + start3, end3 = 2, 3 + + sut = VelocityBoundaryCondition(vx1, start1, end1, vx2, start2, end2, vx3, start3, end3) + + def test__can_create_non_reflecting_outflow(self): + """ + Should be able to create NonReflectingOutflow + """ + + sut = NonReflectingOutflow() diff --git a/Python/test_geometry.py b/Python/tests/test_geometry.py similarity index 100% rename from Python/test_geometry.py rename to Python/tests/test_geometry.py diff --git a/Python/test_kernel.py b/Python/tests/test_kernel.py similarity index 85% rename from Python/test_kernel.py rename to Python/tests/test_kernel.py index 5e5487903a279501b0acdba1ab192ac8dd381383..b1016f15308a77c9025787e061355819cbca3874 100644 --- a/Python/test_kernel.py +++ b/Python/tests/test_kernel.py @@ -51,3 +51,10 @@ class TestLBMKernel(unittest.TestCase): self.assertEqual(self.sut.forcing_in_x2, 8) self.assertEqual(self.sut.forcing_in_x3, 5) + def test_lbm_kernel__when_getting_type__should_equal_kernel_type_enum_value(self) -> None: + """ + WHEN getting the kernel type IT should equal the corresponding KernelType enum value + """ + + actual = self.sut.type + self.assertEqual(KernelType.BGK, actual) diff --git a/Python/vtk_utilities.py b/Python/vtk_utilities.py index e8c16ce02c85518edacde024a012c4ce261fbc14..14d13a40d85e669a463c0b5b31ca2a21e771af75 100644 --- a/Python/vtk_utilities.py +++ b/Python/vtk_utilities.py @@ -1,20 +1,29 @@ import math +from typing import List + import pyvista as pv def vertical_column_from_mesh(mesh): last_seen = math.inf relevant_indices = [] + first_x = 0 + first_y = 0 for index, point in enumerate(mesh.points): - if point[2] == last_seen: + if index == 0: + first_x = point[0] + first_y = point[1] + + if (point[0] != first_x or point[1] != first_y) and point[2] == last_seen: continue + relevant_indices.append(index) last_seen = point[2] return relevant_indices -def get_values_from_indices(array, indices): +def get_values_from_indices(array, indices) -> List[float]: return [array[index] for index in indices] diff --git a/README.md b/README.md index dcd9c19d6ed9a2254cb021904c3cfd982ad237e8..b9d60ed3d1955f2fe0728ca92d8ec7f6b8846a06 100644 --- a/README.md +++ b/README.md @@ -58,11 +58,11 @@ A GPU computation generates a the time series of output files directly in the ou ## Documentation -The doxygen generated documentation can be found [here](https://git.irmb.bau.tu-bs.de/doku/CPU). +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. +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/Applications.cmake b/apps/cpu/Applications.cmake index e8902e5ffbb3720365476afef50a4f3fbd0ddf76..210268968abe6fc0abf3eac0ba97e4310a9b4b32 100644 --- a/apps/cpu/Applications.cmake +++ b/apps/cpu/Applications.cmake @@ -9,7 +9,7 @@ add_subdirectory(${APPS_ROOT_CPU}/sphere) add_subdirectory(${APPS_ROOT_CPU}/FlowAroundCylinder) add_subdirectory(${APPS_ROOT_CPU}/LaminarTubeFlow) add_subdirectory(${APPS_ROOT_CPU}/MultiphaseDropletTest) - +add_subdirectory(${APPS_ROOT_CPU}/RisingBubble2D) #add_subdirectory(tests) #add_subdirectory(Applications/gridRf) #add_subdirectory(Applications/greenvortex) 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 547e654b35096e66e9400b16ad5a01be024ed2c5..7d5c0ec2f4fdf4627b87a32727925f62a3bc89e9 100644 --- a/apps/cpu/BoxBenchmark/bb.cpp +++ b/apps/cpu/BoxBenchmark/bb.cpp @@ -14,7 +14,7 @@ void run(string configname) { try { - ConfigurationFile config; + vf::basics::ConfigurationFile config; config.load(configname); string pathname = config.getValue<string>("pathname"); @@ -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 1ef1ad8f4ead0330620713fea61fb1ae51f5bbd5..4eb526cc75be39153f61cbc4d599a21bcc5394b4 100644 --- a/apps/cpu/CheckpointConverter/cpc.cpp +++ b/apps/cpu/CheckpointConverter/cpc.cpp @@ -10,14 +10,14 @@ void run(string configname) { try { - ConfigurationFile config; + vf::basics::ConfigurationFile config; config.load(configname); string path = config.getString("path"); 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 2ac32915a9348021acb2ff6e5ee70b24a8dedeb6..276fbe125b5b3cd0271542f7e9d8ab9f9abca518 100644 --- a/apps/cpu/CouetteFlow/cflow.cpp +++ b/apps/cpu/CouetteFlow/cflow.cpp @@ -10,7 +10,7 @@ void bflow(string configname) { try { - ConfigurationFile config; + vf::basics::ConfigurationFile config; config.load(configname); string pathname = config.getValue<string>("pathname"); @@ -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 7eb78c37ee35d99af6ac9ca665beba023896290f..850a531a9ac490ed195ad17ce298ca5cf027151a 100644 --- a/apps/cpu/DHIT/dhit.cpp +++ b/apps/cpu/DHIT/dhit.cpp @@ -12,7 +12,7 @@ void run(string configname) { //Sleep(30000); - ConfigurationFile config; + vf::basics::ConfigurationFile config; config.load(configname); string pathname = config.getString("pathname"); @@ -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 422c2dead86796d935fb73b8a16ebf94db53df71..7ddd135b2996c794e2802e235fdedc2a3013cdf3 100644 --- a/apps/cpu/DLR-F16-Porous/f16.cpp +++ b/apps/cpu/DLR-F16-Porous/f16.cpp @@ -53,7 +53,7 @@ void run(string configname) { try { - ConfigurationFile config; + vf::basics::ConfigurationFile config; config.load(configname); string pathOut = config.getValue<string>("pathOut"); @@ -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) @@ -207,7 +207,8 @@ void run(string configname) bcProc = SPtr<BCProcessor>(new ThinWallBCProcessor()); SPtr<LBMKernel> kernel = SPtr<LBMKernel>(new CompressibleCumulant4thOrderViscosityLBMKernel()); - //t = 21.8, P = 1.0145 atm, Relative Humidity = 45.8, Second Coefficient of Viscosity = 3120 //Ash, R. L., Zuckerwar, A. J., & Zheng, Z. (1991). Second coefficient of viscosity in air. + //t = 21.8, P = 1.0145 atm, Relative Humidity = 45.8, Second Coefficient of Viscosity = 3120 + //Ash, R. L., Zuckerwar, A. J., & Zheng, Z. (1991). Second coefficient of viscosity in air. double bulckViscosity = 3120 * nuLB; dynamicPointerCast<CompressibleCumulant4thOrderViscosityLBMKernel>(kernel)->setBulkViscosity(bulckViscosity); kernel->setBCProcessor(bcProc); diff --git a/apps/cpu/DLR-F16-Solid/f16.cpp b/apps/cpu/DLR-F16-Solid/f16.cpp index 99983c3c3fd4171e1feb0ea5635805e019a25d44..328da5dc54b5a2db751eb71ad1ce8810cb471470 100644 --- a/apps/cpu/DLR-F16-Solid/f16.cpp +++ b/apps/cpu/DLR-F16-Solid/f16.cpp @@ -10,7 +10,7 @@ void run(string configname) { try { - ConfigurationFile config; + vf::basics::ConfigurationFile config; config.load(configname); string pathOut = config.getValue<string>("pathOut"); @@ -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) @@ -169,7 +169,8 @@ void run(string configname) bcProc = SPtr<BCProcessor>(new BCProcessor()); SPtr<LBMKernel> kernel = SPtr<LBMKernel>(new CompressibleCumulant4thOrderViscosityLBMKernel()); - //t = 21.8, P = 1.0145 atm, Relative Humidity = 45.8, Second Coefficient of Viscosity = 3120 //Ash, R. L., Zuckerwar, A. J., & Zheng, Z. (1991). Second coefficient of viscosity in air. + //t = 21.8, P = 1.0145 atm, Relative Humidity = 45.8, Second Coefficient of Viscosity = 3120 + //Ash, R. L., Zuckerwar, A. J., & Zheng, Z. (1991). Second coefficient of viscosity in air. double bulckViscosity = 3120 * nuLB; dynamicPointerCast<CompressibleCumulant4thOrderViscosityLBMKernel>(kernel)->setBulkViscosity(bulckViscosity); diff --git a/apps/cpu/DLR-F16/f16.cpp b/apps/cpu/DLR-F16/f16.cpp index ca204d3807d8304dc15ca68b227a29d6ffed6f35..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; @@ -160,7 +160,7 @@ void run(string configname) try { - ConfigurationFile config; + vf::basics::ConfigurationFile config; config.load(configname); string pathOut = config.getValue<string>("pathOut"); @@ -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 3ae5f2ab511cdc1767d8497eb6a895055d5ddd48..2f470d17dbac3600b2c42acede2bba9e6c45f872 100644 --- a/apps/cpu/FlowAroundCylinder/cylinder.cpp +++ b/apps/cpu/FlowAroundCylinder/cylinder.cpp @@ -14,7 +14,7 @@ void run(string configname) //DEBUG/////////////////////////////////////// //Sleep(30000); ///////////////////////////////////////////// - ConfigurationFile config; + vf::basics::ConfigurationFile config; config.load(configname); string pathOut = config.getValue<string>("pathOut"); @@ -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 c448a5de53c96309be9e24ff4f507fee20a462c6..074e8c3aa9b338fa00db0718862d20c7e99f5e55 100644 --- a/apps/cpu/Hagen_Poiseuille_flow/pflow.cpp +++ b/apps/cpu/Hagen_Poiseuille_flow/pflow.cpp @@ -10,7 +10,7 @@ using namespace std; //{ // try // { -// ConfigurationFile config; +// vf::basics::ConfigurationFile config; // config.load(configname); // // string pathname = config.getString("pathname"); @@ -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) @@ -301,7 +301,7 @@ void pflowdp(string configname) { try { - ConfigurationFile config; + vf::basics::ConfigurationFile config; config.load(configname); string pathname = config.getValue<string>("pathname"); @@ -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; @@ -544,7 +544,7 @@ void pflowdp(string configname) intHelper.addInteractor(outflowInt); - //die Geschwindigkeit Randbedingung soll Ausflüß überdecken !!!!! + //die Geschwindigkeit Randbedingung soll Ausfl�� �berdecken !!!!! diff --git a/apps/cpu/Hagen_Poiseuille_flow2/pflow2.cpp b/apps/cpu/Hagen_Poiseuille_flow2/pflow2.cpp index 76124d72ecedbed258aa163dc72e7a1cadff2bcc..40bf20ecabe23637b6271edd6ac6c4fd951f4760 100644 --- a/apps/cpu/Hagen_Poiseuille_flow2/pflow2.cpp +++ b/apps/cpu/Hagen_Poiseuille_flow2/pflow2.cpp @@ -10,7 +10,7 @@ void pflowdp(string configname) { try { - ConfigurationFile config; + vf::basics::ConfigurationFile config; config.load(configname); string pathname = config.getString("pathname"); @@ -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 6de995e2af0510fcc19f985a1eb43214b1748090..8483883aca772693758b9f52fcee53c54b84a1d5 100644 --- a/apps/cpu/HerschelBulkleyModel/hbflow.cpp +++ b/apps/cpu/HerschelBulkleyModel/hbflow.cpp @@ -10,7 +10,7 @@ void bflow(string configname) { try { - ConfigurationFile config; + vf::basics::ConfigurationFile config; config.load(configname); string pathname = config.getValue<string>("pathname"); @@ -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 38affd7e570c78efe738e70c6a25a9a98ff3af65..f69bce237ec0518fb5148f60a0cdaed10230db8f 100644 --- a/apps/cpu/HerschelBulkleySphere/hbsphere.cpp +++ b/apps/cpu/HerschelBulkleySphere/hbsphere.cpp @@ -10,7 +10,7 @@ void bflow(string configname) { try { - ConfigurationFile config; + vf::basics::ConfigurationFile config; config.load(configname); string outputPath = config.getValue<string>("outputPath"); @@ -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 e2dc0f0e31483310bc119b26ce246aa8dfb7133c..eb7d705537e4307e4ca1066ac9d06dafb72449f4 100644 --- a/apps/cpu/JetBreakup/JetBreakup.cpp +++ b/apps/cpu/JetBreakup/JetBreakup.cpp @@ -10,7 +10,7 @@ void run(string configname) { try { - ConfigurationFile config; + vf::basics::ConfigurationFile config; config.load(configname); string pathname = config.getString("pathname"); @@ -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 c8c8e6cfd3cceba85af1e9a6938b1c55a2cb02f0..3c93a21516af5bd1342ad6b0118cb93fa13fdcaf 100644 --- a/apps/cpu/LaminarTubeFlow/ltf.cpp +++ b/apps/cpu/LaminarTubeFlow/ltf.cpp @@ -11,7 +11,7 @@ void run(string configname) { try { - ConfigurationFile config; + vf::basics::ConfigurationFile config; config.load(configname); string pathname = config.getValue<string>("pathname"); @@ -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); } } @@ -149,12 +151,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); @@ -238,19 +240,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); @@ -281,27 +283,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); @@ -330,10 +332,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) { @@ -349,19 +350,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 46297d526c76362e2d45e00ad5496c20dac2af99..533fb619c2bb82783b99110894079594b5ddba47 100644 --- a/apps/cpu/Multiphase/Multiphase (Droplet Test).cpp.backup +++ b/apps/cpu/Multiphase/Multiphase (Droplet Test).cpp.backup @@ -10,7 +10,7 @@ void run(string configname) { try { - ConfigurationFile config; + vf::basics::ConfigurationFile config; config.load(configname); string pathname = config.getString("pathname"); @@ -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 9f28008987968254edb46a1b7750155aad4f5ced..954d4b539411adb36ea47724ab612fcd8d70be87 100644 --- a/apps/cpu/Multiphase/Multiphase (Jet breakup on Phoenix).cpp.backup +++ b/apps/cpu/Multiphase/Multiphase (Jet breakup on Phoenix).cpp.backup @@ -10,7 +10,7 @@ void run(string configname) { try { - ConfigurationFile config; + vf::basics::ConfigurationFile config; config.load(configname); string pathname = config.getString("pathname"); @@ -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 964ae20fd6c83099600efa88d19eeb8a4a86bed3..77eb317e98ea019c983b3f150ca7f4c98d5a034a 100644 --- a/apps/cpu/Multiphase/Multiphase.cpp +++ b/apps/cpu/Multiphase/Multiphase.cpp @@ -12,7 +12,7 @@ void run(string configname) //Sleep(30000); - ConfigurationFile config; + vf::basics::ConfigurationFile config; config.load(configname); string pathname = config.getValue<string>("pathname"); @@ -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 b5a8a9eac55d2150f08e00a8ba6f215228bf135a..3362f66d5b07d1b94fd6c2623af58011ae425905 100644 --- a/apps/cpu/Multiphase/backup/Multiphase (Droplet Test).cpp +++ b/apps/cpu/Multiphase/backup/Multiphase (Droplet Test).cpp @@ -10,7 +10,7 @@ void run(string configname) { try { - ConfigurationFile config; + vf::basics::ConfigurationFile config; config.load(configname); string pathname = config.getString("pathname"); @@ -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 b4a6b34782a4bc8df00168d9d0a9130d19630755..5ed66edace35c61fa3244c445fa479db13ccec8f 100644 --- a/apps/cpu/Multiphase/backup/Multiphase (Final before automation).cpp +++ b/apps/cpu/Multiphase/backup/Multiphase (Final before automation).cpp @@ -10,7 +10,7 @@ void run(string configname) { try { - ConfigurationFile config; + vf::basics::ConfigurationFile config; config.load(configname); string pathname = config.getString("pathname"); @@ -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 33333fc0dba8d082574e766e39c9573adbdde450..a6355a2aa56e0bd85d919250e750427df7662284 100644 --- a/apps/cpu/Multiphase/backup/Multiphase (Flow Focusing).cpp +++ b/apps/cpu/Multiphase/backup/Multiphase (Flow Focusing).cpp @@ -10,7 +10,7 @@ void run(string configname) { try { - ConfigurationFile config; + vf::basics::ConfigurationFile config; config.load(configname); string pathname = config.getString("pathname"); @@ -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 9f28008987968254edb46a1b7750155aad4f5ced..954d4b539411adb36ea47724ab612fcd8d70be87 100644 --- a/apps/cpu/Multiphase/backup/Multiphase (Jet breakup on Phoenix).cpp +++ b/apps/cpu/Multiphase/backup/Multiphase (Jet breakup on Phoenix).cpp @@ -10,7 +10,7 @@ void run(string configname) { try { - ConfigurationFile config; + vf::basics::ConfigurationFile config; config.load(configname); string pathname = config.getString("pathname"); @@ -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 18651e4a5584a7eda7bd3aea4dc8789eb03e1d15..1af6f9a19754035d1e4cc1466d80fa0d77de52c7 100644 --- a/apps/cpu/Multiphase/backup/Multiphase (T-Junction).cpp +++ b/apps/cpu/Multiphase/backup/Multiphase (T-Junction).cpp @@ -10,7 +10,7 @@ void run(string configname) { try { - ConfigurationFile config; + vf::basics::ConfigurationFile config; config.load(configname); string pathname = config.getString("pathname"); @@ -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 a5d20b94a4a74331f55954088545df8f735faf71..51ba4463a32740f8b2e07391d1ab174ccb9e7095 100644 --- a/apps/cpu/Multiphase/backup/Multiphase (Thermal).cpp +++ b/apps/cpu/Multiphase/backup/Multiphase (Thermal).cpp @@ -10,7 +10,7 @@ void run(string configname) { try { - ConfigurationFile config; + vf::basics::ConfigurationFile config; config.load(configname); string pathname = config.getString("pathname"); @@ -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 5795ec61054dfa359fd4038ce7f8f1f263b6ee71..7e6dfd24a1ba90420891de57a7ba399d5c860e7d 100644 --- a/apps/cpu/Multiphase/backup/Multiphase (Tube).cpp +++ b/apps/cpu/Multiphase/backup/Multiphase (Tube).cpp @@ -10,7 +10,7 @@ void run(string configname) { try { - ConfigurationFile config; + vf::basics::ConfigurationFile config; config.load(configname); string pathname = config.getString("pathname"); @@ -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 eae4ab93de060157422f29ae9984078e298194d4..8b09c15f4f5eb829ca37fce160bbb86ebb92f19d 100644 --- a/apps/cpu/Multiphase/backup/Multiphase.cpp +++ b/apps/cpu/Multiphase/backup/Multiphase.cpp @@ -10,7 +10,7 @@ void run(string configname) { try { - ConfigurationFile config; + vf::basics::ConfigurationFile config; config.load(configname); string pathname = config.getString("pathname"); @@ -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 45113302277768605310543c6f66692e2f832c5e..a36636f23580261b26df8e4c93787a869bb55bb5 100644 --- a/apps/cpu/MultiphaseDropletTest/droplet.cpp +++ b/apps/cpu/MultiphaseDropletTest/droplet.cpp @@ -14,7 +14,7 @@ using namespace std; void run(string configname) { try { - ConfigurationFile config; + vf::basics::ConfigurationFile config; config.load(configname); string pathname = config.getValue<string>("pathname"); @@ -48,7 +48,7 @@ void run(string configname) bool newStart = config.getValue<bool>("newStart"); double rStep = config.getValue<double>("rStep"); - SPtr<Communicator> comm = MPICommunicator::getInstance(); + SPtr<vf::mpi::Communicator> comm = vf::mpi::MPICommunicator::getInstance(); int myid = comm->getProcessID(); if (myid == 0) @@ -142,7 +142,8 @@ void run(string configname) //kernel = SPtr<LBMKernel>(new MultiphaseScratchCumulantLBMKernel()); // kernel = SPtr<LBMKernel>(new MultiphaseCumulantLBMKernel()); - kernel = SPtr<LBMKernel>(new MultiphaseTwoPhaseFieldsPressureFilterLBMKernel()); + //kernel = SPtr<LBMKernel>(new MultiphaseTwoPhaseFieldsPressureFilterLBMKernel()); + kernel = SPtr<LBMKernel>(new MultiphasePressureFilterCompressibleAirLBMKernel()); mu::Parser fgr; fgr.SetExpr("-(rho-rho_l)*g_y"); @@ -182,7 +183,7 @@ void run(string configname) grid->setDeltaX(dx); grid->setBlockNX(blocknx[0], blocknx[1], blocknx[2]); grid->setPeriodicX1(true); - grid->setPeriodicX2(true); + grid->setPeriodicX2(false); grid->setPeriodicX3(true); grid->setGhostLayerWidth(2); @@ -348,10 +349,36 @@ void run(string configname) //TwoDistributionsSetConnectorsBlockVisitor setConnsVisitor(comm); //grid->accept(setConnsVisitor); - ThreeDistributionsDoubleGhostLayerSetConnectorsBlockVisitor setConnsVisitor(comm); + //ThreeDistributionsDoubleGhostLayerSetConnectorsBlockVisitor setConnsVisitor(comm); + //grid->accept(setConnsVisitor); + + TwoDistributionsDoubleGhostLayerSetConnectorsBlockVisitor setConnsVisitor(comm); grid->accept(setConnsVisitor); SPtr<UbScheduler> visSch(new UbScheduler(outTime)); + double t_ast, t; + t_ast = 2; + t = (int)(t_ast/std::sqrt(g_y/D)); + visSch->addSchedule(t,t,t); //t=2 + t_ast = 3; + t = (int)(t_ast/std::sqrt(g_y/D)); + visSch->addSchedule(t,t,t); //t=3 + t_ast = 4; + t = (int)(t_ast/std::sqrt(g_y/D)); + visSch->addSchedule(t,t,t); //t=4 + t_ast = 5; + t = (int)(t_ast/std::sqrt(g_y/D)); + visSch->addSchedule(t,t,t); //t=5 + t_ast = 6; + t = (int)(t_ast/std::sqrt(g_y/D)); + visSch->addSchedule(t,t,t); //t=6 + t_ast = 7; + t = (int)(t_ast/std::sqrt(g_y/D)); + visSch->addSchedule(t,t,t); //t=7 + t_ast = 9; + t = (int)(t_ast/std::sqrt(g_y/D)); + visSch->addSchedule(t,t,t); //t=9 + SPtr<WriteMultiphaseQuantitiesCoProcessor> pp(new WriteMultiphaseQuantitiesCoProcessor( grid, visSch, pathname, WbWriterVtkXmlBinary::getInstance(), conv, comm)); if(grid->getTimeStep() == 0) @@ -369,7 +396,6 @@ void run(string configname) calculator->addCoProcessor(rcp); - if (myid == 0) UBLOG(logINFO, "Simulation-start"); calculator->calculate(); @@ -377,8 +403,8 @@ void run(string configname) UBLOG(logINFO, "Simulation-end"); #if defined(__unix__) - if (!newStart) - { + //if (!newStart) + //{ if (myid == 0) { std::ofstream ostr(fileName); @@ -391,7 +417,7 @@ void run(string configname) system(str.c_str()); } //MPI_Barrier((MPI_Comm)comm->getNativeCommunicator()); - } + //} #endif } catch (std::exception &e) { diff --git a/apps/cpu/OrganPipe/OrganPipe.cpp b/apps/cpu/OrganPipe/OrganPipe.cpp index 2435b3567d5179da7375fceacdf641b05302d18b..ad6ec5a1d0892b60f699b74ee4101a9f4ad047e3 100644 --- a/apps/cpu/OrganPipe/OrganPipe.cpp +++ b/apps/cpu/OrganPipe/OrganPipe.cpp @@ -8,14 +8,14 @@ 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"); SPtr<LBMUnitConverter> conv = SPtr<LBMUnitConverter>(new LBMUnitConverter()); - ConfigurationFile config; + vf::basics::ConfigurationFile config; config.load(configname); bool newStart = config.getValue<bool>("newStart"); 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 f565aad1cdd83ad4d827068d10b55caf17f2b440..25f86a206466023439abafefbed503a9b4a9f23d 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/RisingBubble2D/CMakeLists.txt b/apps/cpu/RisingBubble2D/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..5741f1441d806d59a9efd1dd689e5ddba0e5eafc --- /dev/null +++ b/apps/cpu/RisingBubble2D/CMakeLists.txt @@ -0,0 +1,3 @@ +PROJECT(RisingBubble2D) + +vf_add_library(BUILDTYPE binary PRIVATE_LINK VirtualFluidsCore basics ${MPI_CXX_LIBRARIES} FILES RisingBubble2D.cpp ) diff --git a/apps/cpu/RisingBubble2D/RisingBubble2D.cfg b/apps/cpu/RisingBubble2D/RisingBubble2D.cfg new file mode 100644 index 0000000000000000000000000000000000000000..99d68f3d07471a033231b9b82b36d13d251b8bf2 --- /dev/null +++ b/apps/cpu/RisingBubble2D/RisingBubble2D.cfg @@ -0,0 +1,43 @@ +pathname = E:/Multiphase/RisingBubble2D_dr10 + +numOfThreads = 4 +availMem = 10e9 + +#Grid + +boundingBox = 0 160 0 320 0 3 +blocknx = 16 16 3 + +dx = 1 +refineLevel = 0 + +#Simulation +uLB = 0 #0.001#0.005#0.005 +Re = 35 +#Eotvos number +Eo = 10; +nuL = 1e-3 +nuG = 1e-3 +densityRatio = 10 +sigma = 1.0850694444444444e-06 #1e-10 #1e-6 # 1e-5 #4.66e-3 #surface tension 1e-4 ./. 1e-5 +interfaceThickness = 4.096 +radius = 40 +contactAngle = 110.0 +phi_L = 0.0 +phi_H = 1.0 +Phase-field Relaxation = 0.6 +Mobility = 0.056 # 0.01 ./. 0.08, fine correction of Phase-field Relaxation parameter, to activate it need to change in kernel tauH to tauH1 + + +logToFile = false + +newStart = false +restartStep = 50000 + +cpStart = 1000 +cpStep = 1000 + +outTime = 100 +endTime = 100000 + +rStep = 159990 #160000 \ No newline at end of file diff --git a/apps/cpu/RisingBubble2D/RisingBubble2D.cpp b/apps/cpu/RisingBubble2D/RisingBubble2D.cpp new file mode 100644 index 0000000000000000000000000000000000000000..9396801859f00916ca9e74b5592cc43e45a9b737 --- /dev/null +++ b/apps/cpu/RisingBubble2D/RisingBubble2D.cpp @@ -0,0 +1,452 @@ +#include <iostream> +#include <string> +#include <memory> + +#if defined(__unix__) +#include <stdio.h> +#include <stdlib.h> +#endif + +#include "VirtualFluids.h" + +using namespace std; + +void run(string configname) +{ + try { + vf::basics::ConfigurationFile config; + config.load(configname); + + string pathname = config.getValue<string>("pathname"); + int numOfThreads = config.getValue<int>("numOfThreads"); + vector<int> blocknx = config.getVector<int>("blocknx"); + vector<double> boundingBox = config.getVector<double>("boundingBox"); + double uLB = config.getValue<double>("uLB"); + double nuL = config.getValue<double>("nuL"); + double nuG = config.getValue<double>("nuG"); + double densityRatio = config.getValue<double>("densityRatio"); + double sigma = config.getValue<double>("sigma"); + int interfaceThickness = config.getValue<int>("interfaceThickness"); + double radius = config.getValue<double>("radius"); + double theta = config.getValue<double>("contactAngle"); + double phiL = config.getValue<double>("phi_L"); + double phiH = config.getValue<double>("phi_H"); + double tauH = config.getValue<double>("Phase-field Relaxation"); + double mob = config.getValue<double>("Mobility"); + + double endTime = config.getValue<double>("endTime"); + double outTime = config.getValue<double>("outTime"); + double availMem = config.getValue<double>("availMem"); + int refineLevel = config.getValue<int>("refineLevel"); + double Re = config.getValue<double>("Re"); + double Eo = config.getValue<double>("Eo"); + double dx = config.getValue<double>("dx"); + bool logToFile = config.getValue<bool>("logToFile"); + double restartStep = config.getValue<double>("restartStep"); + double cpStart = config.getValue<double>("cpStart"); + double cpStep = config.getValue<double>("cpStep"); + bool newStart = config.getValue<bool>("newStart"); + double rStep = config.getValue<double>("rStep"); + + std::shared_ptr<vf::mpi::Communicator> comm = vf::mpi::MPICommunicator::getInstance(); + int myid = comm->getProcessID(); + + if (myid == 0) + UBLOG(logINFO, "2D Rising Bubble: Start!"); + + if (logToFile) { +#if defined(__unix__) + if (myid == 0) { + const char *str = pathname.c_str(); + mkdir(str, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH); + } +#endif + + if (myid == 0) { + stringstream logFilename; + logFilename << pathname + "/logfile" + UbSystem::toString(UbSystem::getTimeStamp()) + ".txt"; + UbLog::output_policy::setStream(logFilename.str()); + } + } + + std::string fileName = "./LastTimeStep" + std::to_string((int)boundingBox[1]) + ".txt"; + +#if defined(__unix__) + double lastTimeStep = 0; + if (!newStart) + { + std::ifstream ifstr(fileName); + ifstr >> lastTimeStep; + restartStep = lastTimeStep; + if(endTime >= lastTimeStep) + endTime = lastTimeStep + rStep; + else + return; + } +#endif + + //Sleep(30000); + + // LBMReal dLB = 0; // = length[1] / dx; + LBMReal rhoLB = 0.0; + LBMReal nuLB = nuL; //(uLB*dLB) / Re; + + //diameter of circular droplet + LBMReal D = 2.0*radius; + + //density retio + LBMReal r_rho = densityRatio; + + //density of heavy fluid + LBMReal rho_h = 1.0; + //density of light fluid + LBMReal rho_l = rho_h / r_rho; + + //kinimatic viscosity + LBMReal nu_h = nuL; + //LBMReal nu_l = nuG; + //#dynamic viscosity + LBMReal mu_h = rho_h * nu_h; + + //gravity + LBMReal g_y = Re * Re * nu_h * nu_h / (D*D*D); + //Eotvos number + //LBMReal Eo = 100; + //surface tension + sigma = rho_h * 1000.0 * g_y * D * D / Eo; + + //g_y = 0; + + double beta = 12.0 * sigma / interfaceThickness; + double kappa = 1.5 * interfaceThickness * sigma; + + if (myid == 0) { + //UBLOG(logINFO, "uLb = " << uLB); + //UBLOG(logINFO, "rho = " << rhoLB); + UBLOG(logINFO, "D = " << D); + UBLOG(logINFO, "nuL = " << nuL); + UBLOG(logINFO, "nuG = " << nuG); + UBLOG(logINFO, "Re = " << Re); + UBLOG(logINFO, "Eo = " << Eo); + UBLOG(logINFO, "g_y = " << g_y); + UBLOG(logINFO, "sigma = " << sigma); + UBLOG(logINFO, "dx = " << dx); + UBLOG(logINFO, "Preprocess - start"); + } + + SPtr<LBMUnitConverter> conv(new LBMUnitConverter()); + + //const int baseLevel = 0; + + SPtr<LBMKernel> kernel; + + //kernel = SPtr<LBMKernel>(new MultiphaseScratchCumulantLBMKernel()); + // kernel = SPtr<LBMKernel>(new MultiphaseCumulantLBMKernel()); + //kernel = SPtr<LBMKernel>(new MultiphaseTwoPhaseFieldsPressureFilterLBMKernel()); + kernel = SPtr<LBMKernel>(new MultiphasePressureFilterLBMKernel()); + + mu::Parser fgr; + fgr.SetExpr("-rho*g_y"); + fgr.DefineConst("g_y", g_y); + + kernel->setWithForcing(true); + kernel->setForcingX1(0.0); + kernel->setForcingX2(fgr); + kernel->setForcingX3(0.0); + + kernel->setPhiL(phiL); + kernel->setPhiH(phiH); + kernel->setPhaseFieldRelaxation(tauH); + kernel->setMobility(mob); + kernel->setInterfaceWidth(interfaceThickness); + + + kernel->setCollisionFactorMultiphase(nuL, nuG); + kernel->setDensityRatio(densityRatio); + kernel->setMultiphaseModelParameters(beta, kappa); + kernel->setContactAngle(theta); + + SPtr<BCProcessor> bcProc(new BCProcessor()); + + kernel->setBCProcessor(bcProc); + + SPtr<BCAdapter> noSlipBCAdapter(new NoSlipBCAdapter()); + noSlipBCAdapter->setBcAlgorithm(SPtr<BCAlgorithm>(new MultiphaseNoSlipBCAlgorithm())); + SPtr<BCAdapter> slipBCAdapter(new SlipBCAdapter()); + noSlipBCAdapter->setBcAlgorithm(SPtr<BCAlgorithm>(new MultiphaseSlipBCAlgorithm())); + ////////////////////////////////////////////////////////////////////////////////// + // BC visitor + MultiphaseBoundaryConditionsBlockVisitor bcVisitor; + bcVisitor.addBC(noSlipBCAdapter); + bcVisitor.addBC(slipBCAdapter); + + SPtr<Grid3D> grid(new Grid3D(comm)); + grid->setDeltaX(dx); + grid->setBlockNX(blocknx[0], blocknx[1], blocknx[2]); + grid->setPeriodicX1(false); + grid->setPeriodicX2(false); + grid->setPeriodicX3(true); + grid->setGhostLayerWidth(2); + + SPtr<Grid3DVisitor> metisVisitor(new MetisPartitioningGridVisitor(comm, MetisPartitioningGridVisitor::LevelBased, D3Q27System::BSW, MetisPartitioner::RECURSIVE)); + + ////////////////////////////////////////////////////////////////////////// + // restart + SPtr<UbScheduler> rSch(new UbScheduler(cpStep, cpStart)); + //SPtr<MPIIORestartCoProcessor> rcp(new MPIIORestartCoProcessor(grid, rSch, pathname, comm)); + SPtr<MPIIOMigrationCoProcessor> rcp(new MPIIOMigrationCoProcessor(grid, rSch, metisVisitor, pathname, comm)); + //SPtr<MPIIOMigrationBECoProcessor> rcp(new MPIIOMigrationBECoProcessor(grid, rSch, pathname, comm)); + // rcp->setNu(nuLB); + // rcp->setNuLG(nuL, nuG); + // rcp->setDensityRatio(densityRatio); + + rcp->setLBMKernel(kernel); + rcp->setBCProcessor(bcProc); + ////////////////////////////////////////////////////////////////////////// + + if (newStart) { + + // bounding box + double g_minX1 = boundingBox[0]; + double g_minX2 = boundingBox[2]; + double g_minX3 = boundingBox[4]; + + double g_maxX1 = boundingBox[1]; + double g_maxX2 = boundingBox[3]; + double g_maxX3 = boundingBox[5]; + + // geometry + SPtr<GbObject3D> gridCube(new GbCuboid3D(g_minX1, g_minX2, g_minX3, g_maxX1, g_maxX2, g_maxX3)); + if (myid == 0) + GbSystem3D::writeGeoObject(gridCube.get(), pathname + "/geo/gridCube", + WbWriterVtkXmlBinary::getInstance()); + + + + GenBlocksGridVisitor genBlocks(gridCube); + grid->accept(genBlocks); + + double dx2 = 2.0 * dx; + GbCuboid3DPtr wallXmin(new GbCuboid3D(g_minX1 - dx2, g_minX2 - dx2, g_minX3 - dx2, g_minX1, g_maxX2 + dx2, g_maxX3 + dx2)); + GbSystem3D::writeGeoObject(wallXmin.get(), pathname + "/geo/wallXmin", WbWriterVtkXmlASCII::getInstance()); + GbCuboid3DPtr wallXmax(new GbCuboid3D(g_maxX1, g_minX2 - dx2, g_minX3 - dx2, g_maxX1 + dx2, g_maxX2 + dx2, g_maxX3 + dx2)); + GbSystem3D::writeGeoObject(wallXmax.get(), pathname + "/geo/wallXmax", WbWriterVtkXmlASCII::getInstance()); + + GbCuboid3DPtr wallYmin(new GbCuboid3D(g_minX1 - dx2, g_minX2 - dx2, g_minX3 - dx2, g_maxX1 + dx2, g_minX2, g_maxX3 + dx2)); + GbSystem3D::writeGeoObject(wallYmin.get(), pathname + "/geo/wallYmin", WbWriterVtkXmlASCII::getInstance()); + GbCuboid3DPtr wallYmax(new GbCuboid3D(g_minX1 - dx2, g_maxX2, g_minX3 - dx2, g_maxX1 + dx2, g_maxX2 + dx2, g_maxX3 + dx2)); + GbSystem3D::writeGeoObject(wallYmax.get(), pathname + "/geo/wallYmax", WbWriterVtkXmlASCII::getInstance()); + + SPtr<D3Q27Interactor> wallXminInt(new D3Q27Interactor(wallXmin, grid, noSlipBCAdapter, Interactor3D::SOLID)); + SPtr<D3Q27Interactor> wallXmaxInt(new D3Q27Interactor(wallXmax, grid, noSlipBCAdapter, Interactor3D::SOLID)); + + SPtr<D3Q27Interactor> wallYminInt(new D3Q27Interactor(wallYmin, grid, noSlipBCAdapter, Interactor3D::SOLID)); + SPtr<D3Q27Interactor> wallYmaxInt(new D3Q27Interactor(wallYmax, grid, noSlipBCAdapter, Interactor3D::SOLID)); + + SPtr<WriteBlocksCoProcessor> ppblocks(new WriteBlocksCoProcessor( + grid, SPtr<UbScheduler>(new UbScheduler(1)), pathname, WbWriterVtkXmlBinary::getInstance(), comm)); + + InteractorsHelper intHelper(grid, metisVisitor, true); + intHelper.addInteractor(wallXminInt); + intHelper.addInteractor(wallXmaxInt); + intHelper.addInteractor(wallYminInt); + intHelper.addInteractor(wallYmaxInt); + intHelper.selectBlocks(); + + ppblocks->process(0); + ppblocks.reset(); + + unsigned long long numberOfBlocks = (unsigned long long)grid->getNumberOfBlocks(); + int ghostLayer = 5; + unsigned long long numberOfNodesPerBlock = + (unsigned long long)(blocknx[0]) * (unsigned long long)(blocknx[1]) * (unsigned long long)(blocknx[2]); + unsigned long long numberOfNodes = numberOfBlocks * numberOfNodesPerBlock; + unsigned long long numberOfNodesPerBlockWithGhostLayer = + numberOfBlocks * (blocknx[0] + ghostLayer) * (blocknx[1] + ghostLayer) * (blocknx[2] + ghostLayer); + double needMemAll = + double(numberOfNodesPerBlockWithGhostLayer * (27 * sizeof(double) + sizeof(int) + sizeof(float) * 4)); + double needMem = needMemAll / double(comm->getNumberOfProcesses()); + + if (myid == 0) { + UBLOG(logINFO, "Number of blocks = " << numberOfBlocks); + UBLOG(logINFO, "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); + } + UBLOG(logINFO, "Necessary memory = " << needMemAll << " bytes"); + UBLOG(logINFO, "Necessary memory per process = " << needMem << " bytes"); + UBLOG(logINFO, "Available memory per process = " << availMem << " bytes"); + } + + MultiphaseSetKernelBlockVisitor kernelVisitor(kernel, nuL, nuG, densityRatio, beta, kappa, theta, availMem, + needMem); + + grid->accept(kernelVisitor); + + if (refineLevel > 0) { + SetUndefinedNodesBlockVisitor undefNodesVisitor; + grid->accept(undefNodesVisitor); + } + + + intHelper.setBC(); + + // initialization of distributions + LBMReal x1c = D; + LBMReal x2c = D; + LBMReal x3c = 1.5; + //LBMReal x3c = 2.5 * D; + mu::Parser fct1; + fct1.SetExpr("0.5+0.5*tanh(2*(sqrt((x1-x1c)^2+(x2-x2c)^2+(x3-x3c)^2)-radius)/interfaceThickness)"); + fct1.DefineConst("x1c", x1c); + fct1.DefineConst("x2c", x2c); + fct1.DefineConst("x3c", x3c); + fct1.DefineConst("radius", radius); + fct1.DefineConst("interfaceThickness", interfaceThickness); + + mu::Parser fct2; + fct2.SetExpr("0.5*uLB+uLB*0.5*tanh(2*(sqrt((x1-x1c)^2+(x2-x2c)^2+(x3-x3c)^2)-radius)/interfaceThickness)"); + //fct2.SetExpr("uLB"); + fct2.DefineConst("uLB", uLB); + fct2.DefineConst("x1c", x1c); + fct2.DefineConst("x2c", x2c); + fct2.DefineConst("x3c", x3c); + fct2.DefineConst("radius", radius); + fct2.DefineConst("interfaceThickness", interfaceThickness); + + //MultiphaseInitDistributionsBlockVisitor initVisitor(densityRatio); + MultiphaseVelocityFormInitDistributionsBlockVisitor initVisitor; + initVisitor.setPhi(fct1); + initVisitor.setVx1(fct2); + grid->accept(initVisitor); + + // boundary conditions grid + { + SPtr<UbScheduler> geoSch(new UbScheduler(1)); + SPtr<WriteBoundaryConditionsCoProcessor> ppgeo(new WriteBoundaryConditionsCoProcessor( + grid, geoSch, pathname, WbWriterVtkXmlBinary::getInstance(), comm)); + ppgeo->process(0); + ppgeo.reset(); + } + + if (myid == 0) + UBLOG(logINFO, "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); + } + + rcp->restart((int)restartStep); + grid->setTimeStep(restartStep); + + if (myid == 0) + UBLOG(logINFO, "Restart - end"); + } + + grid->accept(bcVisitor); + + //TwoDistributionsSetConnectorsBlockVisitor setConnsVisitor(comm); + //grid->accept(setConnsVisitor); + + //ThreeDistributionsDoubleGhostLayerSetConnectorsBlockVisitor setConnsVisitor(comm); + //grid->accept(setConnsVisitor); + + TwoDistributionsDoubleGhostLayerSetConnectorsBlockVisitor setConnsVisitor(comm); + grid->accept(setConnsVisitor); + + SPtr<UbScheduler> visSch(new UbScheduler(outTime)); + //double t_ast, t; + //t_ast = 2; + //t = (int)(t_ast/std::sqrt(g_y/D)); + //visSch->addSchedule(t,t,t); //t=2 + //t_ast = 3; + //t = (int)(t_ast/std::sqrt(g_y/D)); + //visSch->addSchedule(t,t,t); //t=3 + //t_ast = 4; + //t = (int)(t_ast/std::sqrt(g_y/D)); + //visSch->addSchedule(t,t,t); //t=4 + //t_ast = 5; + //t = (int)(t_ast/std::sqrt(g_y/D)); + //visSch->addSchedule(t,t,t); //t=5 + //t_ast = 6; + //t = (int)(t_ast/std::sqrt(g_y/D)); + //visSch->addSchedule(t,t,t); //t=6 + //t_ast = 7; + //t = (int)(t_ast/std::sqrt(g_y/D)); + //visSch->addSchedule(t,t,t); //t=7 + //t_ast = 9; + //t = (int)(t_ast/std::sqrt(g_y/D)); + //visSch->addSchedule(t,t,t); //t=9 + + SPtr<WriteMultiphaseQuantitiesCoProcessor> pp(new WriteMultiphaseQuantitiesCoProcessor( + grid, visSch, pathname, WbWriterVtkXmlBinary::getInstance(), conv, comm)); + if(grid->getTimeStep() == 0) + pp->process(0); + + SPtr<UbScheduler> nupsSch(new UbScheduler(10, 30, 100)); + SPtr<NUPSCounterCoProcessor> npr(new NUPSCounterCoProcessor(grid, nupsSch, numOfThreads, comm)); + + omp_set_num_threads(numOfThreads); + + SPtr<UbScheduler> stepGhostLayer(new UbScheduler(1)); + SPtr<Calculator> calculator(new BasicCalculator(grid, stepGhostLayer, endTime)); + calculator->addCoProcessor(npr); + calculator->addCoProcessor(pp); + calculator->addCoProcessor(rcp); + + + if (myid == 0) + UBLOG(logINFO, "Simulation-start"); + calculator->calculate(); + if (myid == 0) + UBLOG(logINFO, "Simulation-end"); + +#if defined(__unix__) + //if (!newStart) + //{ + if (myid == 0) + { + std::ofstream ostr(fileName); + ostr << endTime; + cout << "start sbatch\n"; + //system("./start.sh"); + //system("echo test!"); + std::string str = "sbatch startJob" + std::to_string((int)boundingBox[1]) + ".sh"; + //system("sbatch startJob512.sh"); + system(str.c_str()); + } + //MPI_Barrier((MPI_Comm)comm->getNativeCommunicator()); + //} +#endif + + } catch (std::exception &e) { + cerr << e.what() << endl << flush; + } catch (std::string &s) { + cerr << s << endl; + } catch (...) { + cerr << "unknown exception" << endl; + } +} +int main(int argc, char *argv[]) +{ + // Sleep(30000); + if (argv != NULL) { + if (argv[1] != NULL) { + run(string(argv[1])); + } else { + cout << "Configuration file is missing!" << endl; + } + } +} diff --git a/apps/cpu/Thermoplast/thermoplast.cpp b/apps/cpu/Thermoplast/thermoplast.cpp index 60057f28ea51fe10da93d07cfad9cf3f35d1411d..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,10 +194,10 @@ 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(); - ConfigurationFile config; + vf::basics::ConfigurationFile config; config.load(configname); vector<int> blocknx = config.getVector<int>("blocknx"); diff --git a/apps/cpu/ViskomatXL/viskomat.cpp b/apps/cpu/ViskomatXL/viskomat.cpp index c88840742d308cf7e2b50b4ff938920977733973..c29e8699d04cafaa654026ecba6a6e65c068240c 100644 --- a/apps/cpu/ViskomatXL/viskomat.cpp +++ b/apps/cpu/ViskomatXL/viskomat.cpp @@ -10,7 +10,7 @@ void bflow(string configname) { try { - ConfigurationFile config; + vf::basics::ConfigurationFile config; config.load(configname); string outputPath = config.getValue<string>("outputPath"); @@ -35,9 +35,9 @@ void bflow(string configname) double mu = config.getValue<double>("mu"); - ConfigurationFile viscosity; + vf::basics::ConfigurationFile viscosity; - SPtr<Communicator> comm = MPICommunicator::getInstance(); + std::shared_ptr<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 8745b732b04cd449c52ef23d9e8176a780a1ebbb..ecff1a453276444b706e31729012dea10597ac61 100644 --- a/apps/cpu/aperm/aperm.cpp +++ b/apps/cpu/aperm/aperm.cpp @@ -12,7 +12,7 @@ void run(string configname) { try { - ConfigurationFile config; + vf::basics::ConfigurationFile config; config.load(configname); string pathname = config.getString("pathname"); @@ -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 ce21e06c2d7713665596886c152c6e384f5003d2..54dfe45fd86ff791d3965632a21acac0a3284aea 100644 --- a/apps/cpu/aperm/aperm.cpp.old +++ b/apps/cpu/aperm/aperm.cpp.old @@ -12,7 +12,7 @@ void run(string configname) { try { - ConfigurationFile config; + vf::basics::ConfigurationFile config; config.load(configname); string pathname = config.getString("pathname"); @@ -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 0a4d41cfa3c136948cf88dc7f71dee2bb75bf3be..bd49f895a277a34608393a7cb53c0b6466526a95 100644 --- a/apps/cpu/aperm/aperm.cpp.old2 +++ b/apps/cpu/aperm/aperm.cpp.old2 @@ -12,7 +12,7 @@ void run(string configname) { try { - ConfigurationFile config; + vf::basics::ConfigurationFile config; config.load(configname); string pathname = config.getString("pathname"); @@ -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 388ca594cda49bd48e4f6eaf3ad8342b5f469ef9..d50e87437b5fa17353b0f8adb298ec91ecc9d964 100644 --- a/apps/cpu/bChannelA/bChannelA.cpp +++ b/apps/cpu/bChannelA/bChannelA.cpp @@ -87,7 +87,7 @@ void run(string configname) { try { - ConfigurationFile config; + vf::basics::ConfigurationFile config; config.load(configname); string pathOut = config.getValue<string>("pathOut"); @@ -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 8e3bb726e638fb1946e23d841e5c35aaa085d0cc..a73949c8cef45cfa1b576070cb004041f2ac7a0f 100644 --- a/apps/cpu/f16Test/f16test.cpp +++ b/apps/cpu/f16Test/f16test.cpp @@ -16,7 +16,7 @@ void run(string configname) { try { - ConfigurationFile config; + vf::basics::ConfigurationFile config; config.load(configname); string pathOut = config.getString("pathOut"); @@ -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 2f9297f3aa7749db7001ddf6f0ad8f1af8525ac5..0fe328df129ea3f64a135f74f51e425c8d33bd52 100644 --- a/apps/cpu/levels/levels.cpp +++ b/apps/cpu/levels/levels.cpp @@ -14,13 +14,13 @@ 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(); int root = comm->getRoot(); - ConfigurationFile config; + vf::basics::ConfigurationFile config; config.load(configname); string pathname = config.getValue<string>("path"); 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 a5c877bf68df10f3445849de6deac346772b058a..68902fdb7d0dcb74d3eb59d884a0619c8bb0cf6b 100644 --- a/apps/cpu/mirror/mirror.cpp +++ b/apps/cpu/mirror/mirror.cpp @@ -9,7 +9,7 @@ void run(string configname) { try { - ConfigurationFile config; + vf::basics::ConfigurationFile config; config.load(configname); string pathOut = config.getValue<string>("pathOut"); @@ -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 7874e2ea51a86663c29f9bc4d8847e832f6b139b..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 @@ -20,7 +20,7 @@ void run(string configname) { //UbLog::reportingLevel() = UbLog::logLevelFromString("DEBUG5"); - ConfigurationFile config; + vf::basics::ConfigurationFile config; config.load(configname); string pathOut = config.getString("pathOut"); diff --git a/apps/cpu/pChannel/pChannel.cpp b/apps/cpu/pChannel/pChannel.cpp index 85a34a51cd3712a679e380bbd014cfeeefb6e74d..c2b32108037389ddd18351ff7092cd3d680492ea 100644 --- a/apps/cpu/pChannel/pChannel.cpp +++ b/apps/cpu/pChannel/pChannel.cpp @@ -169,7 +169,7 @@ void run(string configname) { try { - ConfigurationFile config; + vf::basics::ConfigurationFile config; config.load(configname); string pathOut = config.getValue<string>("pathOut"); @@ -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 808b8cf49ec3c2f4c9c9fcaa725844ce08d9ca1f..f25a0c4c2e62d6b2b97ff338d567ef911bdc9d14 100644 --- a/apps/cpu/pChannel/pChannel.cpp.hlrn +++ b/apps/cpu/pChannel/pChannel.cpp.hlrn @@ -13,7 +13,7 @@ void run(string configname) { try { - ConfigurationFile config; + vf::basics::ConfigurationFile config; config.load(configname); string pathname = config.getString("pathname"); @@ -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 4cb2b6eb111e814479cef87ae4799e4467939c19..7fae63025a198a09af2a30da3776f940441dbcc2 100644 --- a/apps/cpu/perm/perm.cpp +++ b/apps/cpu/perm/perm.cpp @@ -9,7 +9,7 @@ void perm(string configname) { try { - ConfigurationFile config; + vf::basics::ConfigurationFile config; config.load(configname); string pathname = config.getValue<string>("pathname"); @@ -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 cf70525b8cc166b73a4dbf3af25e7aaf825bdcc8..70a11bdc77e01b34965e3cb09b6ac3c5b43d4f83 100644 --- a/apps/cpu/rheometer/rheometer.cpp +++ b/apps/cpu/rheometer/rheometer.cpp @@ -10,7 +10,7 @@ void bflow(string configname) { try { - ConfigurationFile config; + vf::basics::ConfigurationFile config; config.load(configname); string outputPath = config.getValue<string>("outputPath"); @@ -34,13 +34,13 @@ void bflow(string configname) double scaleFactor = config.getValue<double>("scaleFactor"); double resolution = config.getValue<double>("resolution"); - ConfigurationFile viscosity; + vf::basics::ConfigurationFile viscosity; viscosity.load(viscosityPath + "/viscosity.cfg"); double nuLB = viscosity.getValue<double>("nuLB"); //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 3f48efaf9beb105d0c1e06237165153ef3c6898c..c1eea3f960cf6b4b64757843d08d126e4fac14b9 100644 --- a/apps/cpu/screw/screw.cpp +++ b/apps/cpu/screw/screw.cpp @@ -14,7 +14,7 @@ int main(int argc, char* argv[]) return EXIT_FAILURE; } - ConfigurationFile config; + vf::basics::ConfigurationFile config; config.load(argv[1]); string pathname = config.getString("pathname"); @@ -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/CMakeLists.txt b/apps/cpu/sphere/CMakeLists.txt index d80737cdd94aa0b912a62acd69dcd30372f6fd82..8346e80d26800582c37090b208e846737e087d5d 100644 --- a/apps/cpu/sphere/CMakeLists.txt +++ b/apps/cpu/sphere/CMakeLists.txt @@ -1,6 +1,6 @@ ######################################################## ## C++ PROJECT ### ######################################################## -PROJECT(sphere) +PROJECT(sphere LANGUAGES CXX) vf_add_library(BUILDTYPE binary PRIVATE_LINK VirtualFluidsCore basics ${MPI_CXX_LIBRARIES} FILES sphere.cpp ) \ No newline at end of file diff --git a/apps/cpu/sphere/sphere.cpp b/apps/cpu/sphere/sphere.cpp index 310766ad05f6a3a1d8c08d8ead69c9f48bb6ce11..5ab9a2a70f59273c326d7757faf13e4e338c6614 100644 --- a/apps/cpu/sphere/sphere.cpp +++ b/apps/cpu/sphere/sphere.cpp @@ -9,11 +9,11 @@ void run(string configname) { try { - SPtr<Communicator> comm = MPICommunicator::getInstance(); + SPtr<vf::mpi::Communicator> comm = vf::mpi::MPICommunicator::getInstance(); int myid = comm->getProcessID(); - //ConfigurationFile config; + //vf::basics::ConfigurationFile config; //config.load(configname); //string pathname = config.getValue<string>("path"); 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 b881495912710982a9944f6274ed037595b1442a..aecdb3745f3da37c03b07eb7b103374a99df4302 100644 --- a/apps/cpu/teperm/teperm.cpp +++ b/apps/cpu/teperm/teperm.cpp @@ -14,7 +14,7 @@ void run(string configname) { try { - ConfigurationFile config; + vf::basics::ConfigurationFile config; config.load(configname); string pathname = config.getString("pathname"); @@ -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..be0ec6d5717e094dc9cb5ad478315813b9ee68e6 --- /dev/null +++ b/apps/gpu/LBM/ActuatorLine/ActuatorLine.cpp @@ -0,0 +1,250 @@ + +#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 uint timeStepOut = 500; +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 gridBuilder = MultipleGridBuilder::makeShared(); + + //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + 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->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( timeStepOut ); + para->setTEnd( uint(tEnd/dt) ); + + para->setIsBodyForce( true ); + + + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + gridBuilder->setVelocityBoundaryCondition(SideType::MX, velocityLB, 0.0, 0.0); + gridBuilder->setVelocityBoundaryCondition(SideType::PX, 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); + + //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + 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", 100, 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", 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..3b590b29f71f7e965828f3821608e0013fb281b1 --- /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/DrivenCavity/CMakeLists.txt b/apps/gpu/LBM/DrivenCavity/CMakeLists.txt index e4f62c0150c29f147dee0b99480d1fe28161511a..8384e1bc6fcfa3fd2514434b620b266e96b3626a 100644 --- a/apps/gpu/LBM/DrivenCavity/CMakeLists.txt +++ b/apps/gpu/LBM/DrivenCavity/CMakeLists.txt @@ -5,3 +5,5 @@ PROJECT(DrivenCavity LANGUAGES CUDA CXX) vf_add_library(BUILDTYPE binary PRIVATE_LINK basics VirtualFluids_GPU GridGenerator MPI::MPI_CXX FILES DrivenCavity.cpp) set_source_files_properties(DrivenCavity.cpp PROPERTIES LANGUAGE CUDA) + +set_target_properties(DrivenCavity PROPERTIES CUDA_SEPARABLE_COMPILATION ON) diff --git a/apps/gpu/LBM/DrivenCavity/DrivenCavity.cpp b/apps/gpu/LBM/DrivenCavity/DrivenCavity.cpp index a007636bce0e521a0001c6114d2e4dcde7b7c210..a660f23a776f3e9103c5190b468b41454d8a4f97 100644 --- a/apps/gpu/LBM/DrivenCavity/DrivenCavity.cpp +++ b/apps/gpu/LBM/DrivenCavity/DrivenCavity.cpp @@ -8,21 +8,20 @@ #include <fstream> #include <exception> #include <memory> - -#include "mpi.h" +#include <filesystem> ////////////////////////////////////////////////////////////////////////// #include "Core/DataTypes.h" #include "PointerDefinitions.h" -#include "Core/LbmOrGks.h" -#include "Core/Input/Input.h" #include "Core/StringUtilities/StringUtil.h" -#include "Core/Input/ConfigFileReader/ConfigFileReader.h" #include "Core/VectorTypes.h" -#include "Core/Logger/Logger.h" + +#include <basics/config/ConfigurationFile.h> + +#include <logger/Logger.h> ////////////////////////////////////////////////////////////////////////// @@ -96,8 +95,7 @@ const real dt = (real)1.0e-3; //0.5e-3; const uint nx = 64; -//std::string path("F:/Work/Computations/out/DrivenCavity/"); //LEGOLAS -std::string path("D:/out/DrivenCavity"); //Mollok +std::string path("."); std::string simulationName("DrivenCavityChim"); @@ -115,17 +113,7 @@ void multipleLevel(const std::string& configPath) logging::Logger::timeStamp(logging::Logger::ENABLE); 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); - - Communicator* comm = Communicator::getInstanz(); - SPtr<ConfigFileReader> configReader = ConfigFileReader::getNewInstance(); - - std::cout << configPath << std::endl; - SPtr<ConfigData> configData = configReader->readConfigFile(configPath.c_str()); + auto gridBuilder = MultipleGridBuilder::makeShared(); //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -153,8 +141,12 @@ void multipleLevel(const std::string& configPath) { //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + vf::gpu::Communicator& communicator = vf::gpu::Communicator::getInstance(); + + vf::basics::ConfigurationFile config; + config.load(configPath); - SPtr<Parameter> para = Parameter::make(configData, comm); + SPtr<Parameter> para = std::make_shared<Parameter>(config, communicator.getNummberOfProcess(), communicator.getPID()); //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -165,14 +157,13 @@ 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()); @@ -186,7 +177,7 @@ void multipleLevel(const std::string& configPath) para->setVelocityRatio(velocity/ velocityLB); - para->setMainKernel("CumulantK17CompChim"); + //para->setMainKernel("CumulantK17CompChim"); para->setInitialCondition([&](real coordX, real coordY, real coordZ, real &rho, real &vx, real &vy, real &vz) { rho = (real)0.0; @@ -213,7 +204,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(); @@ -341,44 +332,31 @@ void multipleLevel(const std::string& configPath) int main( int argc, char* argv[]) { - MPI_Init(&argc, &argv); - std::string str, str2; - if ( argv != NULL ) + try { - //str = static_cast<std::string>(argv[0]); - - try - { - ////////////////////////////////////////////////////////////////////////// - - std::string targetPath; - - targetPath = __FILE__; + vf::logging::Logger::initalizeLogger(); - targetPath = targetPath.substr(0, targetPath.find_last_of('/') + 1); + // assuming that the config files is stored parallel to this file. + std::filesystem::path filePath = __FILE__; + filePath.replace_filename("configDrivenCavity.txt"); - - - std::cout << targetPath << std::endl; - - multipleLevel(targetPath + "configDrivenCavity.txt"); - - ////////////////////////////////////////////////////////////////////////// - } - 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"; - } + 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/apps/gpu/LBM/DrivenCavity/configDrivenCavity.txt b/apps/gpu/LBM/DrivenCavity/configDrivenCavity.txt index a3d6622d50700e554dcf3429f0c51e07f5c83ead..246e6f72841c23957e85bb5d69a449af8d178822 100644 --- a/apps/gpu/LBM/DrivenCavity/configDrivenCavity.txt +++ b/apps/gpu/LBM/DrivenCavity/configDrivenCavity.txt @@ -9,6 +9,7 @@ ################################################## #Path="E:/DrivenCavity/results" #Path="F:/Work/Computations/out/DrivenCavity/" +Path = C:/out/ #Prefix="DrivenCavity" #WriteGrid=true ################################################## diff --git a/apps/gpu/LBM/WTG_RUB/CMakeLists.txt b/apps/gpu/LBM/WTG_RUB/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..606987dfb093c9c93bbd25bf5ff68fdc81311e1b --- /dev/null +++ b/apps/gpu/LBM/WTG_RUB/CMakeLists.txt @@ -0,0 +1,7 @@ +PROJECT(WTG_RUB LANGUAGES CUDA CXX) + +vf_add_library(BUILDTYPE binary PRIVATE_LINK basics VirtualFluids_GPU GridGenerator MPI::MPI_CXX FILES WTG_RUB.cpp) + +set_source_files_properties(WTG_RUB.cpp PROPERTIES LANGUAGE CUDA) + +set_target_properties(WTG_RUB PROPERTIES CUDA_SEPARABLE_COMPILATION ON) diff --git a/apps/gpu/LBM/WTG_RUB/WTG_RUB.cpp b/apps/gpu/LBM/WTG_RUB/WTG_RUB.cpp new file mode 100644 index 0000000000000000000000000000000000000000..88ec364ea0e7d6a9010d67dac26f4a442db45e8f --- /dev/null +++ b/apps/gpu/LBM/WTG_RUB/WTG_RUB.cpp @@ -0,0 +1,748 @@ +#define _USE_MATH_DEFINES +#include <math.h> +#include <string> +#include <sstream> +#include <iostream> +#include <stdexcept> +#include <fstream> +#include <exception> +#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 "GridGenerator/grid/GridBuilder/LevelGridBuilder.h" +#include "GridGenerator/grid/GridBuilder/MultipleGridBuilder.h" +#include "GridGenerator/grid/BoundaryConditions/Side.h" +#include "GridGenerator/grid/BoundaryConditions/BoundaryCondition.h" +#include "GridGenerator/grid/GridFactory.h" +#include "GridGenerator/geometries/TriangularMesh/TriangularMesh.h" +#include "GridGenerator/geometries/Conglomerate/Conglomerate.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/Kernel/Utilities/KernelFactory/KernelFactoryImp.h" +#include "VirtualFluids_GPU/PreProcessor/PreProcessorFactory/PreProcessorFactoryImp.h" + +#include "VirtualFluids_GPU/GPU/CudaMemoryManager.h" + +#include <logger/Logger.h> + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// +// U s e r s e t t i n g s +// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +LbmOrGks lbmOrGks = LBM; + +const real L = 1.0; + +const real velocity = 1.0; + +int variant = 1; +real rotationOfCity; +real z_offset = 0.0; // only if baseplate is in use (currently not!! not important) +int dataN; +std::vector<real> dataZ; +std::vector<real> dataVelocity; +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; + +std::string path("D:/out/WTG_RUB"); //Mollok +std::string inputPath("D:/out/WTG_RUB/input/"); + +const uint timeStepStartOut = 0; +const uint timeStepOut = 10000; +const uint timeStepEnd = 100000; + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +void convertMPFile(SPtr <MultipleGridBuilder> gridBuilder, real& phi, std::vector<real>& origin, bool& measureVeloProfilesOnly, uint& maxLevel); + +void addFineGrids(SPtr<MultipleGridBuilder> gridBuilder, uint &maxLevel, real &rotationOfCity); + +void readVelocityProfile(); + +std::string chooseVariation(); + +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 gridBuilder = MultipleGridBuilder::makeShared(); + + //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + real dx = 0; + real viscosityLB = (real)1.0e-03; + uint maxLevel = 1; + + if (setupDomain == 1) { + dx = (real)4; + maxLevel = 5; + viscosityLB = (real)3.75e-06; // LB units + } else if (setupDomain == 2) { + 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 + } + + real x_min = 0.0; + real x_max = 1250.0; + real y_min = 0.0; + real y_max = 190.0; + real z_min = 0.0 + z_offset; + real z_max = 160.0 + z_offset; + + //TriangularMesh *RubSTL = TriangularMesh::make(inputPath + "stl/Var02_0deg_FD_b.stl"); + TriangularMesh *RubSTL = TriangularMesh::make(inputPath + "stl/" + chooseVariation() + ".stl"); + std::vector<real> originOfCityXY = { 600.0, y_max / 2, z_offset }; + + //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // OPTIONS + + int maxLevelAtInflow = maxLevel; + // there are max. 3 levels (0,1,2) at inflow-/x_min-Side if maxLevel >= 3; OTHERWISE: maxLevel + if (maxLevel >= 3) + maxLevelAtInflow = 2; + + // 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 measureVeloProfilesOnly = false; + + // Two Components: true->DiffOn, false->DiffOff + 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; + //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + gridBuilder->addCoarseGrid(x_min, y_min, z_min, + x_max, y_max, z_max, dx); + + gridBuilder->setNumberOfLayers(0, 0); + + addFineGrids(gridBuilder, maxLevel, rotationOfCity); + + //// adding solid CityGeometry to gridbuilder + gridBuilder->addGeometry(RubSTL); + + 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 velocityLB = (real)0.0844; // LB units + + //const real vx = velocityLB / (real)sqrt(2.0); // LB units + //const real vy = velocityLB / (real)sqrt(2.0); // 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"; + + //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + para->setDevices(std::vector<uint>{(uint)0}); + + para->setOutputPath( path ); + para->setOutputPrefix( "Unified_" + simulationName ); + + para->setFName(para->getOutputPath() + "/" + para->getOutputPrefix()); + + para->setPrintFiles(true); + + para->setMaxLevel(maxLevel); + + para->setVelocity(velocityLB); + para->setViscosity(viscosityLB); + + para->setVelocityRatio(velocity/ velocityLB); + + para->setMainKernel("CumulantK17CompChim"); // CumulantK17Unified, CumulantK17CompChim + + para->setInitialCondition([&](real coordX, real coordY, real coordZ, real &rho, real &vx, real &vy, real &vz) { + rho = (real)0.0; + vx = (real)0.0; //(6 * velocityLB * coordZ * (L - coordZ) / (L * L)); + vy = (real)0.0; + vz = (real)0.0; + }); + + para->setTOut( timeStepOut ); + para->setTEnd( timeStepEnd ); + + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + gridBuilder->setVelocityBoundaryCondition(SideType::MX, velocityLB, 0.0, 0.0); + gridBuilder->setVelocityBoundaryCondition(SideType::PY, 0.0, 0.0, 0.0); + gridBuilder->setVelocityBoundaryCondition(SideType::MY, 0.0, 0.0, 0.0); + gridBuilder->setVelocityBoundaryCondition(SideType::PZ, 0.0, 0.0, 0.0); + gridBuilder->setVelocityBoundaryCondition(SideType::MZ, 0.0, 0.0, 0.0); + gridBuilder->setVelocityBoundaryCondition(SideType::GEOMETRY, 0.0, 0.0, 0.0); + + gridBuilder->setPressureBoundaryCondition(SideType::PX, 0.0); + + //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + readVelocityProfile(); + for (int level = 0; level <= maxLevelAtInflow; level++) { + auto inflowBC = std::dynamic_pointer_cast<VelocityBoundaryCondition>( + gridBuilder->getBoundaryCondition(SideType::MX, level)); + + // lambda function [capture list](parameter list){function body} + // for every z, loop is being run; + if (inflowBC) { + inflowBC->setVelocityProfile( + gridBuilder->getGrid(level), [&](real x, real y, real z, real &vx, real &vy, real &vz) { + int i; + for (i = 0; i < dataN; i++) { + if ((z < dataZ[i]) || (z == dataZ[i])) + break; + } // remembers i + + // if z is below current data point --> interpolation between previous and current datapoint + if (z < dataZ[i]) { + vx = velocityLB * (dataVelocity[i] + (dataVelocity[i + 1] - dataVelocity[i]) / + (dataZ[i + 1] - dataZ[i]) * (z - dataZ[i])); + } else if (z == dataZ[i]) { + vx = velocityLB * dataVelocity[i]; + } + + // vx << std::endl; vx = velocityLB; + vy = 0.0; + vz = 0.0; + }); + } + } + + // Resetting Velocity Profile (returning to intial state; do not combine with restart) + if (reset_flow) { + para->setInitialCondition([&](real x, real y, real z, real &rho, real &vx, real &vy, real &vz) { + int i; + for (i = 0; i < dataN; i++) { + if ((z < dataZ[i]) || (z == dataZ[i])) + break; + } + if (z < dataZ[i]) { + vx = velocityLB * 0.588 * + (dataVelocity[i] + + (dataVelocity[i + 1] - dataVelocity[i]) / (dataZ[i + 1] - dataZ[i]) * (z - dataZ[i])); + } else if (z == dataZ[i]) { + vx = velocityLB * 0.588 * dataVelocity[i]; + } + + // std::cout << "LINE : " << __LINE__ << "\tdataZ = " << dataZ[i] << "\tz = " << z << "\tvx = " << vx << + // std::endl; + + // vx = velocityLB; + vy = 0.0; + vz = 0.0; + rho = 0.0; + }); + } + + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // Intializing MeasurePoints + para->setUseMeasurePoints(useMP); + if (para->getUseMeasurePoints()) { + convertMPFile(gridBuilder, rotationOfCity, originOfCityXY, measureVeloProfilesOnly, maxLevel); + // Number log-Files for each MeasurePoint: numberOfMPFiles = timeStepEnd/ClockCycle + para->setclockCycleForMP(timeStepEnd); + // Number of logged Timesteps for each file + para->settimestepForMP(timeStepOut / 100); + // para->settimestepForMP(timeStepOut); + para->setmeasurePoints(inputPath + "measurePoints.dat"); + } + + + //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + SPtr<CudaMemoryManager> cudaMemoryManager = CudaMemoryManager::make(para); + + SPtr<GridProvider> gridGenerator = GridProvider::makeGridGenerator(gridBuilder, para, cudaMemoryManager); + + 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(); + +} + +void readVelocityProfile() +{ + // reads velocityProfile.txt, containing values for relative velocity (u_h) in relation to height (z). also fills + // dataZ,dataVelocity vectors + + std::ifstream inFile; + inFile.open(inputPath + "VeloProfile.txt"); + //inFile.open(inputPath + "velocityProfile.txt"); + + if (inFile.fail()) { + std::cerr << "Error opening File" << std::endl; + exit(1); + } + + int z; + real velocity; + + // read + inFile >> dataN; + for (int k = 0; k < dataN; k++) { + inFile >> z; + dataZ.push_back(z + z_offset); + + inFile >> velocity; + dataVelocity.push_back(velocity); + } + inFile.close(); +} + +void addFineGrids(SPtr<MultipleGridBuilder> gridBuilder, uint &maxLevel, real &rotationOfCity) +{ + if (setupDomain == 1) { + ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////*/ + // creates Cuboids (FG1 to FG3, lvl 1 to lvl 3) and add STLs (FG4 to FG5, lvl 4 to lvl 5) 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 + // FG3 -> dx = 5 mm; lvl 3 + // FG4 -> dx = 2,5 mm; lvl 4 + // FG5 -> dx = 1,25 mm; lvl 5 + // + // 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); + + // FineGrid Level 3 ->dx = 5 mm; lvl 3 + auto FG3_1 = new Cuboid(517, -20, -5 + z_offset, 665, 200, 30 + z_offset); + auto FG3_2 = new Cuboid(550, 58, -5 + z_offset, 650, 132, 40 + z_offset); + auto FG3 = new Conglomerate(); + FG3->add(FG3_1); + FG3->add(FG3_2); + + // Adding FineGrids 1 to 5 depending on maxLevel, FG4 and FG5 require different STL-files depending on + // rotationOfCity + if (maxLevel >= 1) { + gridBuilder->addGrid(FG1, 1); + if (maxLevel >= 2) { + gridBuilder->addGrid(FG2, 2); + if (maxLevel >= 3) { + gridBuilder->addGrid(FG3, 3); + if (maxLevel >= 4) { + if (rotationOfCity == 0.0) { + TriangularMesh *FG4 = TriangularMesh::make(inputPath + "stl/FG4_0deg.stl"); + gridBuilder->addGrid(FG4, 4); + } else { + TriangularMesh *FG4 = TriangularMesh::make(inputPath + "stl/FG4_63deg.stl"); + gridBuilder->addGrid(FG4, 4); + } + + if (maxLevel == 5) { + if (rotationOfCity == 0.0) { + TriangularMesh *FG5 = TriangularMesh::make(inputPath + "stl/FG5_0deg.stl"); + gridBuilder->addGrid(FG5, 5); + } else { + TriangularMesh *FG5 = TriangularMesh::make(inputPath + "stl/FG5_63deg.stl"); + gridBuilder->addGrid(FG5, 5); + } + } + } + } + } + } + } + else if (setupDomain == 2) { + ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////*/ + // creates Cuboids (FG1, lvl 1) and add STLs (FG2 to FG3, lvl 2 to lvl 3) depending on maxLevel + // and rotationOfCity; also adds FineGrids(FGs) to gridbuilder + // + // GridList(CG = coarse grid, fg = fine grid) + // CG -> dx = 1 cm; lvl 0 + // FG1 -> dx = 5 mm; lvl 1 + // FG2 -> dx = 2,5 mm; lvl 2 + // FG3 -> dx = 1,25 mm; lvl 3 + // + // FineGrid Level 1 -> dx = 5 mm; lvl 1 + //auto FG1_1 = new Cuboid(-20, -20, -5 + z_offset, 760, 200, 10 + z_offset); + auto FG1_1 = new Cuboid(-20, -20, -5 + z_offset, 760, 200, 20 + z_offset); + auto FG1_2 = new Cuboid(500, -20, 5 + z_offset, 680, 210, 50 + z_offset); + auto FG1 = new Conglomerate(); + FG1->add(FG1_1); + FG1->add(FG1_2); + + // Adding FineGrids 1 to 5 depending on maxLevel, FG4 and FG5 require different STL-files depending on + // rotationOfCity + if (maxLevel >= 1) { + gridBuilder->addGrid(FG1, 1); + if (maxLevel >= 2) { + if (rotationOfCity == 0.0) { + TriangularMesh *FG2 = TriangularMesh::make(inputPath + "stl/FG4_0deg.stl"); + gridBuilder->addGrid(FG2, 2); + } else { + TriangularMesh *FG2 = TriangularMesh::make(inputPath + "stl/FG4_63deg.stl"); + gridBuilder->addGrid(FG2, 2); + } + + if (maxLevel == 3) { + if (rotationOfCity == 0.0) { + TriangularMesh *FG3 = TriangularMesh::make(inputPath + "stl/FG5_0deg.stl"); + gridBuilder->addGrid(FG3, 3); + } else { + TriangularMesh *FG3 = TriangularMesh::make(inputPath + "stl/FG5_63deg.stl"); + gridBuilder->addGrid(FG3, 3); + } + } + } + } + } + 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 + // and rotationOfCity; also adds FineGrids(FGs) to gridbuilder + + // GridList(CG = coarse grid, fg = fine grid) + // CG -> dx = 1.6 cm; lvl 0 + // FG1 -> dx = 8.0 mm; lvl 1 + // FG2 -> dx = 4.0 mm; lvl 2 + // FG3 -> dx = 2.0 mm; lvl 3 + // 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); + + // 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(); + 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(); + FG2->add(FG2_1); + FG2->add(FG2_2); + + // Adding FineGrids 1 to 4 depending on maxLevel, FG3 and FG4 require different STL-files depending on + // rotationOfCity + if (maxLevel >= 1) { + gridBuilder->addGrid(FG1, 1); + if (maxLevel >= 2) { + gridBuilder->addGrid(FG2, 2); + if (maxLevel >= 3) { + if (rotationOfCity == 0.0) { + TriangularMesh *FG3 = TriangularMesh::make(inputPath + "stl/FG4_0deg.stl"); + gridBuilder->addGrid(FG3, 3); + } else { + TriangularMesh *FG3 = TriangularMesh::make(inputPath + "stl/FG4_63deg.stl"); + gridBuilder->addGrid(FG3, 3); + } + + if (maxLevel == 4) { + if (rotationOfCity == 0.0) { + TriangularMesh *FG4 = TriangularMesh::make(inputPath + "stl/FG5_0deg.stl"); + gridBuilder->addGrid(FG4, 4); + } else { + TriangularMesh *FG4 = TriangularMesh::make(inputPath + "stl/FG5_63deg.stl"); + gridBuilder->addGrid(FG4, 4); + } + } + } + } + } + } + + + +} + +void convertMPFile(SPtr<MultipleGridBuilder> gridBuilder, real &phi, std::vector<real> &originXY, bool &measureVeloProfilesOnly, uint &maxLevel) +{ + // File Reader&Writer for converting MP-Coordinates to Index: MeasurePoint placement requires "measurePoints.dat" + // with name, node-ID and level. This function can read a txt-File containing the name, X-Y-Z-Coordinates and level + // of measurePoints. After reading the txt-File and converting X-Y-Z to the node-ID, it writes "measurePoints.dat". + // Justification for this function: Human Readability and no changes in measurepoint core functions + + // File Opening Procedure + std::ifstream inFile; + if (measureVeloProfilesOnly) + inFile.open(inputPath + "measurePoints_veloProfiles.txt"); + else + inFile.open(inputPath + "measurePoints.txt"); + + // Check for error + if (inFile.fail()) { + std::cerr << "Error opening File" << std::endl; + exit(1); + } + + //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // Reading Procedure + std::cout << "phi in degrees:" << phi << std::endl; + phi = phi * M_PI / 180; + std::cout << "phi in radians:" << phi << std::endl; + + std::vector<std::string> MP_name; + std::vector<real> MP_X, MP_Y, MP_Z; + std::vector<int> MP_level, MP_k; + + std::string name; + real X, Y, Z; + uint level, numberOfMeasurePoints; + + inFile >> numberOfMeasurePoints; + std::cout << "numberOfMeasurePoints: " << numberOfMeasurePoints << " "; + std::cout << "Coordinates from File\n"; + for (uint k = 0; k < numberOfMeasurePoints; k++) { + inFile >> name; + MP_name.push_back(name); + std::cout << "Name: " << MP_name[k] << " "; + + inFile >> X; + MP_X.push_back(X); + std::cout << "\t\tX: " << MP_X[k] << " "; + + inFile >> Y; + MP_Y.push_back(Y); + std::cout << "\t\tY: " << MP_Y[k] << " "; + + inFile >> Z; + if (((variant > 3 && variant < 7) || (variant > 9 && variant <= 12)) && k == 14) + Z += 2.25; // account for angled roof + MP_Z.push_back(Z); + std::cout << "\t\tZ: " << MP_Z[k] + z_offset << " "; + + inFile >> level; + if (level > maxLevel) + level = maxLevel; + MP_level.push_back(level); + std::cout << "\t\tLevel: " << MP_level[k] << std::endl; + } + inFile.close(); + + //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + real X_temp, Y_temp; + // Transformation for phi radians around centre of city for MP[1..15] + if (!phi == 0) { + std::cout << "Calculating new Coordinates for MP01 to MP15 after Rotation of " << phi * 180 / M_PI + << "degrees (+: counter-clockwise / -: clockwise)\n"; + for (uint k = 0; k < 15; k++) { + X_temp = originXY[0] + (MP_X[k] - originXY[0]) * cos(phi) - (MP_Y[k] - originXY[1]) * sin(phi); + Y_temp = originXY[1] + (MP_X[k] - originXY[0]) * sin(phi) + (MP_Y[k] - originXY[1]) * cos(phi); + std::cout << "Name: " << MP_name[k] << " "; + std::cout << "\t\tX: " << X_temp << " "; + std::cout << "\t\tY: " << Y_temp << " "; + std::cout << "\t\tZ: " << MP_Z[k] << " " << std::endl; + + MP_X[k] = X_temp; + MP_Y[k] = Y_temp; + } + } + + //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // Coordinates to Index Procedure + // std::cout << "Converting Coordinates to Index..." << std::endl; + for (uint k = 0; k < numberOfMeasurePoints; k++) { + MP_k.push_back( + gridBuilder->getGrid(MP_level[k]) + ->getSparseIndex(gridBuilder->getGrid(MP_level[k])->transCoordToIndex(MP_X[k], MP_Y[k], MP_Z[k]))); + if (MP_k[k] == -1) { + std::cerr << "Error: Could not convert Coordinate to Sparse Index for MP " << k + 1 << std::endl; + } + std::cout << MP_name[k] << "\tID = " + << gridBuilder->getGrid(MP_level[k]) + ->getSparseIndex( + gridBuilder->getGrid(MP_level[k])->transCoordToIndex(MP_X[k], MP_Y[k], MP_Z[k])) + << std::endl; + // std::cout << "ID = " << + // gridBuilder->getGrid(0)->getSparseIndex(gridBuilder->getGrid(0)->transCoordToIndex(-0.500000, + // -0.500000, 9.500000)) << std::endl; + } + // std::cout << "Done Converting Coordinates to Index..." << std::endl; + + //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // Writing Procedure + // std::cout << "Writing new file..." << std::endl; + std::ofstream outFile(inputPath + "measurePoints.dat"); + + outFile << numberOfMeasurePoints << std::endl; + for (uint j = 0; j < numberOfMeasurePoints; j++) { + outFile << MP_name[j] << " " << MP_k[j] << " " << MP_level[j] << std::endl; + // std::cout << MP_name[j] << "\t" << MP_k[j] << "\t" << MP_level[j] << std::endl; + } + // std::cout << "Done writing new file..." << std::endl; + outFile.close(); + + //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +} + +std::string chooseVariation() +{ + switch (variant) { + case 1: + simulationName = "Var01_0deg_FD_a"; + break; + case 2: + simulationName = "Var02_0deg_FD_b"; + break; + case 3: + simulationName = "Var03_0deg_FD_c"; + break; + case 4: + simulationName = "Var04_0deg_SD_a"; + break; + case 5: + simulationName = "Var05_0deg_SD_b"; + break; + case 6: + simulationName = "Var06_0deg_SD_c"; + break; + case 7: + simulationName = "Var07_63deg_FD_a"; + break; + case 8: + simulationName = "Var08_63deg_FD_b"; + break; + case 9: + simulationName = "Var09_63deg_FD_c"; + break; + case 10: + simulationName = "Var10_63deg_SD_a"; + break; + case 11: + simulationName = "Var11_63deg_SD_b"; + break; + case 12: + simulationName = "Var12_63deg_SD_c"; + break; + default: + std::cerr << "Warning: no variant selected. Running with Default variant V01!" << std::endl; + simulationName = "Var01_0deg_FD_a"; + rotationOfCity = 0.0; + return simulationName; + } + + if ((0 < variant) && (variant <= 6)) + rotationOfCity = (real)0.0; + else if ((6 < variant) && (variant <= 12)) + rotationOfCity = (real)63.295; + + std::cout << "Variant selected. Simulation name is: " << simulationName << std::endl; + std::cout << "Rotation selected: " << rotationOfCity << std::endl; + + return simulationName; +} + + +int main( int argc, char* 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()); + } + 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/WTG_RUB/configDrivenCavity.txt b/apps/gpu/LBM/WTG_RUB/configDrivenCavity.txt new file mode 100644 index 0000000000000000000000000000000000000000..f6ff6c107d239c11d8c88566795f94ada7226085 --- /dev/null +++ b/apps/gpu/LBM/WTG_RUB/configDrivenCavity.txt @@ -0,0 +1,37 @@ +################################################## +#GPU Mapping +################################################## +#Devices="0 1 2 3" +#NumberOfDevices=4 + +################################################## +#informations for Writing +################################################## +#Path="E:/DrivenCavity/results" +#Path="F:/Work/Computations/out/DrivenCavity/" +Path="/" +#Prefix="DrivenCavity" +#WriteGrid=true +################################################## +#informations for reading +################################################## +#GridPath="E:/DrivenCavity/dummy" +GridPath="C:" + +################################################## +#number of grid levels +################################################## +#NOGL=1 + +################################################## +#LBM Version +################################################## +#D3Qxx=27 +#MainKernelName=CumulantAA2016CompSP27 + +################################################## +#simulation parameter +################################################## +#TimeEnd=100000 +#TimeOut=1000 +#TimeStartOut=0 \ No newline at end of file diff --git a/apps/gpu/LBM/metisTest/main.cpp b/apps/gpu/LBM/metisTest/main.cpp index fb5116d5d495aff7de0b7be852608f36b46fa78d..b5e2aa40a315004130bd5eed24b438e318d16ab7 100644 --- a/apps/gpu/LBM/metisTest/main.cpp +++ b/apps/gpu/LBM/metisTest/main.cpp @@ -51,6 +51,8 @@ #include "utilities/communication.h" #include "utilities/transformator/TransformatorImp.h" +using namespace vf::gpu; + std::string getGridPath(std::shared_ptr<Parameter> para, std::string Gridpath) { if (para->getNumprocs() == 1) diff --git a/cpu.cmake b/cpu.cmake index 397d54c3a142e2237804609754b5b18d7e069f70..bad575aa3854fb2be777e90bba9ea71fb2cbba5a 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() diff --git a/docs/cpu/Documentation/doxygen/VF_Doxyfile.dox b/docs/Doxyfile similarity index 75% rename from docs/cpu/Documentation/doxygen/VF_Doxyfile.dox rename to docs/Doxyfile index 7ac4685967b93ce3b8bcdc3969d11e27d5927799..e8b9a328ae81177aaf587d6203ea4882e9de169e 100644 --- a/docs/cpu/Documentation/doxygen/VF_Doxyfile.dox +++ b/docs/Doxyfile @@ -1,4 +1,4 @@ -# Doxyfile 1.8.6 +# Doxyfile 1.9.1 # This file describes the settings to be used by the documentation system # doxygen (www.doxygen.org) for a project. @@ -17,11 +17,11 @@ # Project related configuration options #--------------------------------------------------------------------------- -# This tag specifies the encoding used for all characters in the config file -# that follow. The default is UTF-8 which is also the encoding used for all text -# before the first occurrence of this tag. Doxygen uses libiconv (or the iconv -# built into libc) for the transcoding. See http://www.gnu.org/software/libiconv -# for the list of possible encodings. +# This tag specifies the encoding used for all characters in the configuration +# file that follow. The default is UTF-8 which is also the encoding used for all +# text before the first occurrence of this tag. Doxygen uses libiconv (or the +# iconv built into libc) for the transcoding. See +# https://www.gnu.org/software/libiconv/ for the list of possible encodings. # The default value is: UTF-8. DOXYFILE_ENCODING = UTF-8 @@ -38,29 +38,29 @@ PROJECT_NAME = VirtualFluids # could be handy for archiving the generated documentation or if some version # control system is used. -PROJECT_NUMBER = +PROJECT_NUMBER = 1.0 # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer a # quick idea about the purpose of the project. Keep the description short. -PROJECT_BRIEF = +PROJECT_BRIEF = "Parallel CFD LBM Solver" -# With the PROJECT_LOGO tag one can specify an logo or icon that is included in -# the documentation. The maximum height of the logo should not exceed 55 pixels -# and the maximum width should not exceed 200 pixels. Doxygen will copy the logo -# to the output directory. +# With the PROJECT_LOGO tag one can specify a logo or an icon that is included +# in the documentation. The maximum height of the logo should not exceed 55 +# pixels and the maximum width should not exceed 200 pixels. Doxygen will copy +# the logo to the output directory. -PROJECT_LOGO = D:/Projects/bFluid/source/doc/doxygen/logo.png +PROJECT_LOGO = docs/img/VF_logo.png # The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) path # into which the generated documentation will be written. If a relative path is # entered, it will be relative to the location where doxygen was started. If # left blank the current directory will be used. -OUTPUT_DIRECTORY = z:\VirtualFluids\Documentation +OUTPUT_DIRECTORY = docs/build/ -# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create 4096 sub- +# If the CREATE_SUBDIRS tag is set to YES then doxygen will create 4096 sub- # directories (in 2 levels) under the output directory of each output format and # will distribute the generated files over these directories. Enabling this # option can be useful when feeding doxygen a huge amount of source files, where @@ -70,6 +70,14 @@ OUTPUT_DIRECTORY = z:\VirtualFluids\Documentation CREATE_SUBDIRS = NO +# If the ALLOW_UNICODE_NAMES tag is set to YES, doxygen will allow non-ASCII +# characters to appear in the names of generated files. If set to NO, non-ASCII +# characters will be escaped, for example _xE3_x81_x84 will be used for Unicode +# U+3044. +# The default value is: NO. + +ALLOW_UNICODE_NAMES = NO + # The OUTPUT_LANGUAGE tag is used to specify the language in which all # documentation generated by doxygen is written. Doxygen will use this # information to generate all constant output in the proper language. @@ -85,14 +93,22 @@ CREATE_SUBDIRS = NO OUTPUT_LANGUAGE = English -# If the BRIEF_MEMBER_DESC tag is set to YES doxygen will include brief member +# The OUTPUT_TEXT_DIRECTION tag is used to specify the direction in which all +# documentation generated by doxygen is written. Doxygen will use this +# information to generate all generated output in the proper direction. +# Possible values are: None, LTR, RTL and Context. +# The default value is: None. + +OUTPUT_TEXT_DIRECTION = None + +# If the BRIEF_MEMBER_DESC tag is set to YES, doxygen will include brief member # descriptions after the members that are listed in the file and class # documentation (similar to Javadoc). Set to NO to disable this. # The default value is: YES. BRIEF_MEMBER_DESC = YES -# If the REPEAT_BRIEF tag is set to YES doxygen will prepend the brief +# If the REPEAT_BRIEF tag is set to YES, doxygen will prepend the brief # description of a member or function before the detailed description # # Note: If both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the @@ -137,7 +153,7 @@ ALWAYS_DETAILED_SEC = NO INLINE_INHERITED_MEMB = NO -# If the FULL_PATH_NAMES tag is set to YES doxygen will prepend the full path +# If the FULL_PATH_NAMES tag is set to YES, doxygen will prepend the full path # before files name in the file list and in the header files. If set to NO the # shortest path that makes the file name unique will be used # The default value is: YES. @@ -154,7 +170,7 @@ FULL_PATH_NAMES = YES # will be relative from the directory where doxygen is started. # This tag requires that the tag FULL_PATH_NAMES is set to YES. -STRIP_FROM_PATH = +STRIP_FROM_PATH = # The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of the # path mentioned in the documentation of a class, which tells the reader which @@ -163,7 +179,7 @@ STRIP_FROM_PATH = # specify the list of include paths that are normally passed to the compiler # using the -I flag. -STRIP_FROM_INC_PATH = +STRIP_FROM_INC_PATH = # If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter (but # less readable) file names. This can be useful is your file systems doesn't @@ -181,6 +197,16 @@ SHORT_NAMES = NO JAVADOC_AUTOBRIEF = NO +# If the JAVADOC_BANNER tag is set to YES then doxygen will interpret a line +# such as +# /*************** +# as being the beginning of a Javadoc-style comment "banner". If set to NO, the +# Javadoc-style will behave just like regular comments and it will not be +# interpreted by doxygen. +# The default value is: NO. + +JAVADOC_BANNER = NO + # If the QT_AUTOBRIEF tag is set to YES then doxygen will interpret the first # line (until the first dot) of a Qt-style comment as the brief description. If # set to NO, the Qt-style will behave just like regular Qt-style comments (thus @@ -201,15 +227,23 @@ QT_AUTOBRIEF = NO MULTILINE_CPP_IS_BRIEF = NO +# By default Python docstrings are displayed as preformatted text and doxygen's +# special commands cannot be used. By setting PYTHON_DOCSTRING to NO the +# doxygen's special commands can be used and the contents of the docstring +# documentation blocks is shown as doxygen documentation. +# The default value is: YES. + +PYTHON_DOCSTRING = YES + # If the INHERIT_DOCS tag is set to YES then an undocumented member inherits the # documentation from any documented member that it re-implements. # The default value is: YES. INHERIT_DOCS = YES -# If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce a -# new page for each member. If set to NO, the documentation of a member will be -# part of the file/class/namespace that contains it. +# If the SEPARATE_MEMBER_PAGES tag is set to YES then doxygen will produce a new +# page for each member. If set to NO, the documentation of a member will be part +# of the file/class/namespace that contains it. # The default value is: NO. SEPARATE_MEMBER_PAGES = NO @@ -228,15 +262,14 @@ TAB_SIZE = 4 # will allow you to put the command \sideeffect (or @sideeffect) in the # documentation, which will result in a user-defined paragraph with heading # "Side Effects:". You can put \n's in the value part of an alias to insert -# newlines. +# newlines (in the resulting output). You can put ^^ in the value part of an +# alias to insert a newline as if a physical newline was in the original file. +# When you need a literal { or } or , in the value part of an alias you have to +# escape them by means of a backslash (\), this can lead to conflicts with the +# commands \{ and \} for these it is advised to use the version @{ and @} or use +# a double escape (\\{ and \\}) -ALIASES = - -# This tag can be used to specify a number of word-keyword mappings (TCL only). -# A mapping has the form "name=value". For example adding "class=itcl::class" -# will allow you to use the command class in the itcl::class meaning. - -TCL_SUBST = +ALIASES = # Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C sources # only. Doxygen will then generate output that is more tailored for C. For @@ -244,7 +277,7 @@ TCL_SUBST = # members will be omitted, etc. # The default value is: NO. -OPTIMIZE_OUTPUT_FOR_C = NO +OPTIMIZE_OUTPUT_FOR_C = YES # Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java or # Python sources only. Doxygen will then generate output that is more tailored @@ -266,25 +299,40 @@ OPTIMIZE_FOR_FORTRAN = NO OPTIMIZE_OUTPUT_VHDL = NO +# Set the OPTIMIZE_OUTPUT_SLICE tag to YES if your project consists of Slice +# sources only. Doxygen will then generate output that is more tailored for that +# language. For instance, namespaces will be presented as modules, types will be +# separated into more groups, etc. +# The default value is: NO. + +OPTIMIZE_OUTPUT_SLICE = NO + # Doxygen selects the parser to use depending on the extension of the files it # parses. With this tag you can assign which parser to use for a given # extension. Doxygen has a built-in mapping, but you can override or extend it # using this tag. The format is ext=language, where ext is a file extension, and -# language is one of the parsers supported by doxygen: IDL, Java, Javascript, -# C#, C, C++, D, PHP, Objective-C, Python, Fortran, VHDL. For instance to make -# doxygen treat .inc files as Fortran files (default is PHP), and .f files as C -# (default is Fortran), use: inc=Fortran f=C. +# language is one of the parsers supported by doxygen: IDL, Java, JavaScript, +# Csharp (C#), C, C++, D, PHP, md (Markdown), Objective-C, Python, Slice, VHDL, +# Fortran (fixed format Fortran: FortranFixed, free formatted Fortran: +# FortranFree, unknown formatted Fortran: Fortran. In the later case the parser +# tries to guess whether the code is fixed or free formatted code, this is the +# default for Fortran type files). For instance to make doxygen treat .inc files +# as Fortran files (default is PHP), and .f files as C (default is Fortran), +# use: inc=Fortran f=C. # -# Note For files without extension you can use no_extension as a placeholder. +# Note: For files without extension you can use no_extension as a placeholder. # # Note that for custom extensions you also need to set FILE_PATTERNS otherwise -# the files are not read by doxygen. +# the files are not read by doxygen. When specifying no_extension you should add +# * to the FILE_PATTERNS. +# +# Note see also the list of default file extension mappings. -EXTENSION_MAPPING = +EXTENSION_MAPPING = # If the MARKDOWN_SUPPORT tag is enabled then doxygen pre-processes all comments # according to the Markdown format, which allows for more readable -# documentation. See http://daringfireball.net/projects/markdown/ for details. +# documentation. See https://daringfireball.net/projects/markdown/ for details. # The output of markdown processing is further processed by doxygen, so you can # mix doxygen, HTML, and XML commands with Markdown formatting. Disable only in # case of backward compatibilities issues. @@ -292,10 +340,19 @@ EXTENSION_MAPPING = MARKDOWN_SUPPORT = YES +# When the TOC_INCLUDE_HEADINGS tag is set to a non-zero value, all headings up +# to that level are automatically included in the table of contents, even if +# they do not have an id attribute. +# Note: This feature currently applies only to Markdown headings. +# Minimum value: 0, maximum value: 99, default value: 5. +# This tag requires that the tag MARKDOWN_SUPPORT is set to YES. + +TOC_INCLUDE_HEADINGS = 5 + # When enabled doxygen tries to link words that correspond to documented # classes, or namespaces to their corresponding documentation. Such a link can -# be prevented in individual cases by by putting a % sign in front of the word -# or globally by setting AUTOLINK_SUPPORT to NO. +# be prevented in individual cases by putting a % sign in front of the word or +# globally by setting AUTOLINK_SUPPORT to NO. # The default value is: YES. AUTOLINK_SUPPORT = YES @@ -317,7 +374,7 @@ BUILTIN_STL_SUPPORT = NO CPP_CLI_SUPPORT = NO # Set the SIP_SUPPORT tag to YES if your project consists of sip (see: -# http://www.riverbankcomputing.co.uk/software/sip/intro) sources only. Doxygen +# https://www.riverbankcomputing.com/software/sip/intro) sources only. Doxygen # will parse them like normal C++ but will assume all classes use public instead # of private inheritance when no explicit protection keyword is present. # The default value is: NO. @@ -335,13 +392,20 @@ SIP_SUPPORT = NO IDL_PROPERTY_SUPPORT = YES # If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC -# tag is set to YES, then doxygen will reuse the documentation of the first +# tag is set to YES then doxygen will reuse the documentation of the first # member in the group (if any) for the other members of the group. By default # all members of a group must be documented explicitly. # The default value is: NO. DISTRIBUTE_GROUP_DOC = NO +# If one adds a struct or class to a group and this option is enabled, then also +# any nested class or struct is added to the same group. By default this option +# is disabled and one has to add nested compounds explicitly via \ingroup. +# The default value is: NO. + +GROUP_NESTED_COMPOUNDS = NO + # Set the SUBGROUPING tag to YES to allow class member groups of the same type # (for instance a group of public functions) to be put as a subgroup of that # type (e.g. under the Public Functions section). Set it to NO to prevent @@ -396,11 +460,24 @@ TYPEDEF_HIDES_STRUCT = NO LOOKUP_CACHE_SIZE = 0 +# The NUM_PROC_THREADS specifies the number threads doxygen is allowed to use +# during processing. When set to 0 doxygen will based this on the number of +# cores available in the system. You can set it explicitly to a value larger +# than 0 to get more control over the balance between CPU load and processing +# speed. At this moment only the input processing can be done using multiple +# threads. Since this is still an experimental feature the default is set to 1, +# which efficively disables parallel processing. Please report any issues you +# encounter. Generating dot graphs in parallel is controlled by the +# DOT_NUM_THREADS setting. +# Minimum value: 0, maximum value: 32, default value: 1. + +NUM_PROC_THREADS = 1 + #--------------------------------------------------------------------------- # Build related configuration options #--------------------------------------------------------------------------- -# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in +# If the EXTRACT_ALL tag is set to YES, doxygen will assume all entities in # documentation are documented, even if no documentation was available. Private # class members and static file members will be hidden unless the # EXTRACT_PRIVATE respectively EXTRACT_STATIC tags are set to YES. @@ -410,35 +487,41 @@ LOOKUP_CACHE_SIZE = 0 EXTRACT_ALL = YES -# If the EXTRACT_PRIVATE tag is set to YES all private members of a class will +# If the EXTRACT_PRIVATE tag is set to YES, all private members of a class will # be included in the documentation. # The default value is: NO. EXTRACT_PRIVATE = NO -# If the EXTRACT_PACKAGE tag is set to YES all members with package or internal +# If the EXTRACT_PRIV_VIRTUAL tag is set to YES, documented private virtual +# methods of a class will be included in the documentation. +# The default value is: NO. + +EXTRACT_PRIV_VIRTUAL = NO + +# If the EXTRACT_PACKAGE tag is set to YES, all members with package or internal # scope will be included in the documentation. # The default value is: NO. EXTRACT_PACKAGE = NO -# If the EXTRACT_STATIC tag is set to YES all static members of a file will be +# If the EXTRACT_STATIC tag is set to YES, all static members of a file will be # included in the documentation. # The default value is: NO. EXTRACT_STATIC = NO -# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) defined -# locally in source files will be included in the documentation. If set to NO +# If the EXTRACT_LOCAL_CLASSES tag is set to YES, classes (and structs) defined +# locally in source files will be included in the documentation. If set to NO, # only classes defined in header files are included. Does not have any effect # for Java sources. # The default value is: YES. EXTRACT_LOCAL_CLASSES = YES -# This flag is only useful for Objective-C code. When set to YES local methods, +# This flag is only useful for Objective-C code. If set to YES, local methods, # which are defined in the implementation section but not in the interface are -# included in the documentation. If set to NO only methods in the interface are +# included in the documentation. If set to NO, only methods in the interface are # included. # The default value is: NO. @@ -453,6 +536,13 @@ EXTRACT_LOCAL_METHODS = NO EXTRACT_ANON_NSPACES = NO +# If this flag is set to YES, the name of an unnamed parameter in a declaration +# will be determined by the corresponding definition. By default unnamed +# parameters remain unnamed in the output. +# The default value is: YES. + +RESOLVE_UNNAMED_PARAMS = YES + # If the HIDE_UNDOC_MEMBERS tag is set to YES, doxygen will hide all # undocumented members inside documented classes or files. If set to NO these # members will be included in the various overviews, but no documentation @@ -463,21 +553,21 @@ HIDE_UNDOC_MEMBERS = NO # If the HIDE_UNDOC_CLASSES tag is set to YES, doxygen will hide all # undocumented classes that are normally visible in the class hierarchy. If set -# to NO these classes will be included in the various overviews. This option has -# no effect if EXTRACT_ALL is enabled. +# to NO, these classes will be included in the various overviews. This option +# has no effect if EXTRACT_ALL is enabled. # The default value is: NO. HIDE_UNDOC_CLASSES = NO # If the HIDE_FRIEND_COMPOUNDS tag is set to YES, doxygen will hide all friend -# (class|struct|union) declarations. If set to NO these declarations will be -# included in the documentation. +# declarations. If set to NO, these declarations will be included in the +# documentation. # The default value is: NO. HIDE_FRIEND_COMPOUNDS = NO # If the HIDE_IN_BODY_DOCS tag is set to YES, doxygen will hide any -# documentation blocks found inside the body of a function. If set to NO these +# documentation blocks found inside the body of a function. If set to NO, these # blocks will be appended to the function's detailed documentation block. # The default value is: NO. @@ -490,28 +580,46 @@ HIDE_IN_BODY_DOCS = NO INTERNAL_DOCS = NO -# If the CASE_SENSE_NAMES tag is set to NO then doxygen will only generate file -# names in lower-case letters. If set to YES upper-case letters are also -# allowed. This is useful if you have classes or files whose names only differ -# in case and if your file system supports case sensitive file names. Windows -# and Mac users are advised to set this option to NO. +# With the correct setting of option CASE_SENSE_NAMES doxygen will better be +# able to match the capabilities of the underlying filesystem. In case the +# filesystem is case sensitive (i.e. it supports files in the same directory +# whose names only differ in casing), the option must be set to YES to properly +# deal with such files in case they appear in the input. For filesystems that +# are not case sensitive the option should be be set to NO to properly deal with +# output files written for symbols that only differ in casing, such as for two +# classes, one named CLASS and the other named Class, and to also support +# references to files without having to specify the exact matching casing. On +# Windows (including Cygwin) and MacOS, users should typically set this option +# to NO, whereas on Linux or other Unix flavors it should typically be set to +# YES. # The default value is: system dependent. CASE_SENSE_NAMES = NO # If the HIDE_SCOPE_NAMES tag is set to NO then doxygen will show members with -# their full class and namespace scopes in the documentation. If set to YES the +# their full class and namespace scopes in the documentation. If set to YES, the # scope will be hidden. # The default value is: NO. HIDE_SCOPE_NAMES = NO +# If the HIDE_COMPOUND_REFERENCE tag is set to NO (default) then doxygen will +# append additional text to a page's title, such as Class Reference. If set to +# YES the compound reference will be hidden. +# The default value is: NO. + +HIDE_COMPOUND_REFERENCE= NO + # If the SHOW_INCLUDE_FILES tag is set to YES then doxygen will put a list of # the files that are included by a file in the documentation of that file. # The default value is: YES. SHOW_INCLUDE_FILES = YES +# If the SHOW_GROUPED_MEMB_INC tag is set to YES then Doxygen will add for each +# grouped member an include statement to the documentation, telling the reader +# which file to include in order to use the member. +# The default value is: NO. SHOW_GROUPED_MEMB_INC = NO @@ -529,14 +637,14 @@ INLINE_INFO = YES # If the SORT_MEMBER_DOCS tag is set to YES then doxygen will sort the # (detailed) documentation of file and class members alphabetically by member -# name. If set to NO the members will appear in declaration order. +# name. If set to NO, the members will appear in declaration order. # The default value is: YES. SORT_MEMBER_DOCS = YES # If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the brief # descriptions of file, namespace and class members alphabetically by member -# name. If set to NO the members will appear in declaration order. Note that +# name. If set to NO, the members will appear in declaration order. Note that # this will also influence the order of the classes in the class list. # The default value is: NO. @@ -581,27 +689,25 @@ SORT_BY_SCOPE_NAME = NO STRICT_PROTO_MATCHING = NO -# The GENERATE_TODOLIST tag can be used to enable ( YES) or disable ( NO) the -# todo list. This list is created by putting \todo commands in the -# documentation. +# The GENERATE_TODOLIST tag can be used to enable (YES) or disable (NO) the todo +# list. This list is created by putting \todo commands in the documentation. # The default value is: YES. GENERATE_TODOLIST = YES -# The GENERATE_TESTLIST tag can be used to enable ( YES) or disable ( NO) the -# test list. This list is created by putting \test commands in the -# documentation. +# The GENERATE_TESTLIST tag can be used to enable (YES) or disable (NO) the test +# list. This list is created by putting \test commands in the documentation. # The default value is: YES. GENERATE_TESTLIST = YES -# The GENERATE_BUGLIST tag can be used to enable ( YES) or disable ( NO) the bug +# The GENERATE_BUGLIST tag can be used to enable (YES) or disable (NO) the bug # list. This list is created by putting \bug commands in the documentation. # The default value is: YES. GENERATE_BUGLIST = YES -# The GENERATE_DEPRECATEDLIST tag can be used to enable ( YES) or disable ( NO) +# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or disable (NO) # the deprecated list. This list is created by putting \deprecated commands in # the documentation. # The default value is: YES. @@ -612,7 +718,7 @@ GENERATE_DEPRECATEDLIST= YES # sections, marked by \if <section_label> ... \endif and \cond <section_label> # ... \endcond blocks. -ENABLED_SECTIONS = +ENABLED_SECTIONS = # The MAX_INITIALIZER_LINES tag determines the maximum number of lines that the # initial value of a variable or macro / define can have for it to appear in the @@ -626,8 +732,8 @@ ENABLED_SECTIONS = MAX_INITIALIZER_LINES = 30 # Set the SHOW_USED_FILES tag to NO to disable the list of files generated at -# the bottom of the documentation of classes and structs. If set to YES the list -# will mention the files that were used to generate the documentation. +# the bottom of the documentation of classes and structs. If set to YES, the +# list will mention the files that were used to generate the documentation. # The default value is: YES. SHOW_USED_FILES = YES @@ -654,7 +760,7 @@ SHOW_NAMESPACES = YES # by doxygen. Whatever the program writes to standard output is used as the file # version. For an example see the documentation. -FILE_VERSION_FILTER = +FILE_VERSION_FILTER = # The LAYOUT_FILE tag can be used to specify a layout file which will be parsed # by doxygen. The layout file controls the global structure of the generated @@ -667,18 +773,17 @@ FILE_VERSION_FILTER = # DoxygenLayout.xml, doxygen will parse it automatically even if the LAYOUT_FILE # tag is left empty. -LAYOUT_FILE = +LAYOUT_FILE = # The CITE_BIB_FILES tag can be used to specify one or more bib files containing # the reference definitions. This must be a list of .bib files. The .bib # extension is automatically appended if omitted. This requires the bibtex tool -# to be installed. See also http://en.wikipedia.org/wiki/BibTeX for more info. +# to be installed. See also https://en.wikipedia.org/wiki/BibTeX for more info. # For LaTeX the style of the bibliography can be controlled using # LATEX_BIB_STYLE. To use this feature you need bibtex and perl available in the -# search path. Do not use file names with spaces, bibtex cannot handle them. See -# also \cite for info how to create references. +# search path. See also \cite for info how to create references. -CITE_BIB_FILES = +CITE_BIB_FILES = #--------------------------------------------------------------------------- # Configuration options related to warning and progress messages @@ -692,7 +797,7 @@ CITE_BIB_FILES = QUIET = NO # The WARNINGS tag can be used to turn on/off the warning messages that are -# generated to standard error ( stderr) by doxygen. If WARNINGS is set to YES +# generated to standard error (stderr) by doxygen. If WARNINGS is set to YES # this implies that the warnings are on. # # Tip: Turn warnings on while writing the documentation. @@ -700,7 +805,7 @@ QUIET = NO WARNINGS = YES -# If the WARN_IF_UNDOCUMENTED tag is set to YES, then doxygen will generate +# If the WARN_IF_UNDOCUMENTED tag is set to YES then doxygen will generate # warnings for undocumented members. If EXTRACT_ALL is set to YES then this flag # will automatically be disabled. # The default value is: YES. @@ -717,12 +822,22 @@ WARN_IF_DOC_ERROR = YES # This WARN_NO_PARAMDOC option can be enabled to get warnings for functions that # are documented, but have no documentation for their parameters or return -# value. If set to NO doxygen will only warn about wrong or incomplete parameter -# documentation, but not about the absence of documentation. +# value. If set to NO, doxygen will only warn about wrong or incomplete +# parameter documentation, but not about the absence of documentation. If +# EXTRACT_ALL is set to YES then this flag will automatically be disabled. # The default value is: NO. WARN_NO_PARAMDOC = NO +# If the WARN_AS_ERROR tag is set to YES then doxygen will immediately stop when +# a warning is encountered. If the WARN_AS_ERROR tag is set to FAIL_ON_WARNINGS +# then doxygen will continue running as if WARN_AS_ERROR tag is set to NO, but +# at the end of the doxygen process doxygen will return with a non-zero status. +# Possible values are: NO, YES and FAIL_ON_WARNINGS. +# The default value is: NO. + +WARN_AS_ERROR = NO + # The WARN_FORMAT tag determines the format of the warning messages that doxygen # can produce. The string should contain the $file, $line, and $text tags, which # will be replaced by the file and line number from which the warning originated @@ -737,7 +852,7 @@ WARN_FORMAT = "$file:$line: $text" # messages should be written. If left blank the output is written to standard # error (stderr). -WARN_LOGFILE = +WARN_LOGFILE = #--------------------------------------------------------------------------- # Configuration options related to the input files @@ -746,35 +861,44 @@ WARN_LOGFILE = # The INPUT tag is used to specify the files and/or directories that contain # documented source files. You may enter file names like myfile.cpp or # directories like /usr/src/myproject. Separate the files or directories with -# spaces. +# spaces. See also FILE_PATTERNS and EXTENSION_MAPPING # Note: If this tag is empty the current directory is searched. -INPUT = ../doc \ - ../../VirtualFluidsCore \ - ../../ThirdParty +INPUT = src/ # This tag can be used to specify the character encoding of the source files # that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses # libiconv (or the iconv built into libc) for the transcoding. See the libiconv -# documentation (see: http://www.gnu.org/software/libiconv) for the list of -# possible encodings. +# documentation (see: +# https://www.gnu.org/software/libiconv/) for the list of possible encodings. # The default value is: UTF-8. INPUT_ENCODING = UTF-8 # If the value of the INPUT tag contains directories, you can use the # FILE_PATTERNS tag to specify one or more wildcard patterns (like *.cpp and -# *.h) to filter out the source-files in the directories. If left blank the -# following patterns are tested:*.c, *.cc, *.cxx, *.cpp, *.c++, *.java, *.ii, -# *.ixx, *.ipp, *.i++, *.inl, *.idl, *.ddl, *.odl, *.h, *.hh, *.hxx, *.hpp, -# *.h++, *.cs, *.d, *.php, *.php4, *.php5, *.phtml, *.inc, *.m, *.markdown, -# *.md, *.mm, *.dox, *.py, *.f90, *.f, *.for, *.tcl, *.vhd, *.vhdl, *.ucf, -# *.qsf, *.as and *.js. +# *.h) to filter out the source-files in the directories. +# +# Note that for custom extensions or not directly supported extensions you also +# need to set EXTENSION_MAPPING for the extension otherwise the files are not +# read by doxygen. +# +# Note the list of default checked file patterns might differ from the list of +# default file extension mappings. +# +# If left blank the following patterns are tested:*.c, *.cc, *.cxx, *.cpp, +# *.c++, *.java, *.ii, *.ixx, *.ipp, *.i++, *.inl, *.idl, *.ddl, *.odl, *.h, +# *.hh, *.hxx, *.hpp, *.h++, *.cs, *.d, *.php, *.php4, *.php5, *.phtml, *.inc, +# *.m, *.markdown, *.md, *.mm, *.dox (to be provided as doxygen C comment), +# *.py, *.pyw, *.f90, *.f95, *.f03, *.f08, *.f18, *.f, *.for, *.vhd, *.vhdl, +# *.ucf, *.qsf and *.ice. FILE_PATTERNS = *.c \ *.cc \ *.cxx \ *.cpp \ + *.cuh \ + *.cu \ *.c++ \ *.d \ *.java \ @@ -819,7 +943,7 @@ RECURSIVE = YES # Note that relative paths are relative to the directory from which doxygen is # run. -EXCLUDE = +EXCLUDE = # The EXCLUDE_SYMLINKS tag can be used to select whether or not files or # directories that are symbolic links (a Unix file system feature) are excluded @@ -835,7 +959,7 @@ EXCLUDE_SYMLINKS = NO # Note that the wildcards are matched against the file with absolute path, so to # exclude all test directories for example use the pattern */test/* -EXCLUDE_PATTERNS = +EXCLUDE_PATTERNS = # The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names # (namespaces, classes, functions, etc.) that should be excluded from the @@ -846,13 +970,13 @@ EXCLUDE_PATTERNS = # Note that the wildcards are matched against the file with absolute path, so to # exclude all test directories use the pattern */test/* -EXCLUDE_SYMBOLS = +EXCLUDE_SYMBOLS = # The EXAMPLE_PATH tag can be used to specify one or more files or directories # that contain example code fragments that are included (see the \include # command). -EXAMPLE_PATH = +EXAMPLE_PATH = # If the value of the EXAMPLE_PATH tag contains directories, you can use the # EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp and @@ -872,7 +996,7 @@ EXAMPLE_RECURSIVE = NO # that contain images that are to be included in the documentation (see the # \image command). -IMAGE_PATH = +IMAGE_PATH = docs/img/ # The INPUT_FILTER tag can be used to specify a program that doxygen should # invoke to filter for each input file. Doxygen will invoke the filter program @@ -888,8 +1012,12 @@ IMAGE_PATH = # Note that the filter must not add or remove lines; it is applied before the # code is scanned, but not when the output code is generated. If lines are added # or removed, the anchors will not be placed correctly. +# +# Note that for custom extensions or not directly supported extensions you also +# need to set EXTENSION_MAPPING for the extension otherwise the files are not +# properly processed by doxygen. -INPUT_FILTER = +INPUT_FILTER = # The FILTER_PATTERNS tag can be used to specify filters on a per file pattern # basis. Doxygen will compare the file name with each pattern and apply the @@ -897,11 +1025,15 @@ INPUT_FILTER = # (like *.cpp=my_cpp_filter). See INPUT_FILTER for further information on how # filters are used. If the FILTER_PATTERNS tag is empty or if none of the # patterns match the file name, INPUT_FILTER is applied. +# +# Note that for custom extensions or not directly supported extensions you also +# need to set EXTENSION_MAPPING for the extension otherwise the files are not +# properly processed by doxygen. -FILTER_PATTERNS = +FILTER_PATTERNS = # If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using -# INPUT_FILTER ) will also be used to filter the input files that are used for +# INPUT_FILTER) will also be used to filter the input files that are used for # producing the source files to browse (i.e. when SOURCE_BROWSER is set to YES). # The default value is: NO. @@ -913,14 +1045,16 @@ FILTER_SOURCE_FILES = NO # *.ext= (so without naming a filter). # This tag requires that the tag FILTER_SOURCE_FILES is set to YES. -FILTER_SOURCE_PATTERNS = +FILTER_SOURCE_PATTERNS = # If the USE_MDFILE_AS_MAINPAGE tag refers to the name of a markdown file that # is part of the input, its contents will be placed on the main page # (index.html). This can be useful if you have a project on for instance GitHub # and want to reuse the introduction page also for the doxygen output. -USE_MDFILE_AS_MAINPAGE = main.md +INPUT += docs/img/VF_logo.png +INPUT += README.md +USE_MDFILE_AS_MAINPAGE = README.md #--------------------------------------------------------------------------- # Configuration options related to source browsing @@ -949,7 +1083,7 @@ INLINE_SOURCES = NO STRIP_CODE_COMMENTS = YES # If the REFERENCED_BY_RELATION tag is set to YES then for each documented -# function all documented functions referencing it will be listed. +# entity all documented functions referencing it will be listed. # The default value is: NO. REFERENCED_BY_RELATION = NO @@ -961,7 +1095,7 @@ REFERENCED_BY_RELATION = NO REFERENCES_RELATION = NO # If the REFERENCES_LINK_SOURCE tag is set to YES and SOURCE_BROWSER tag is set -# to YES, then the hyperlinks from functions in REFERENCES_RELATION and +# to YES then the hyperlinks from functions in REFERENCES_RELATION and # REFERENCED_BY_RELATION lists will link to the source code. Otherwise they will # link to the documentation. # The default value is: YES. @@ -981,12 +1115,12 @@ SOURCE_TOOLTIPS = YES # If the USE_HTAGS tag is set to YES then the references to source code will # point to the HTML generated by the htags(1) tool instead of doxygen built-in # source browser. The htags tool is part of GNU's global source tagging system -# (see http://www.gnu.org/software/global/global.html). You will need version +# (see https://www.gnu.org/software/global/global.html). You will need version # 4.8.6 or higher. # # To use it do the following: # - Install the latest version of global -# - Enable SOURCE_BROWSER and USE_HTAGS in the config file +# - Enable SOURCE_BROWSER and USE_HTAGS in the configuration file # - Make sure the INPUT points to the root of the source tree # - Run doxygen as normal # @@ -1008,25 +1142,6 @@ USE_HTAGS = NO VERBATIM_HEADERS = YES -# If the CLANG_ASSISTED_PARSING tag is set to YES, then doxygen will use the -# clang parser (see: http://clang.llvm.org/) for more acurate parsing at the -# cost of reduced performance. This can be particularly helpful with template -# rich C++ code for which doxygen's built-in parser lacks the necessary type -# information. -# Note: The availability of this option depends on whether or not doxygen was -# compiled with the --with-libclang option. -# The default value is: NO. - -CLANG_ASSISTED_PARSING = NO - -# If clang assisted parsing is enabled you can provide the compiler with command -# line options that you would normally use when invoking the compiler. Note that -# the include paths will already be set by doxygen for the files and directories -# specified with INPUT and INCLUDE_PATH. -# This tag requires that the tag CLANG_ASSISTED_PARSING is set to YES. - -CLANG_OPTIONS = - #--------------------------------------------------------------------------- # Configuration options related to the alphabetical class index #--------------------------------------------------------------------------- @@ -1038,26 +1153,19 @@ CLANG_OPTIONS = ALPHABETICAL_INDEX = YES -# The COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns in -# which the alphabetical index list will be split. -# Minimum value: 1, maximum value: 20, default value: 5. -# This tag requires that the tag ALPHABETICAL_INDEX is set to YES. - -COLS_IN_ALPHA_INDEX = 5 - # In case all classes in a project start with a common prefix, all classes will # be put under the same header in the alphabetical index. The IGNORE_PREFIX tag # can be used to specify a prefix (or a list of prefixes) that should be ignored # while generating the index headers. # This tag requires that the tag ALPHABETICAL_INDEX is set to YES. -IGNORE_PREFIX = +IGNORE_PREFIX = #--------------------------------------------------------------------------- # Configuration options related to the HTML output #--------------------------------------------------------------------------- -# If the GENERATE_HTML tag is set to YES doxygen will generate HTML output +# If the GENERATE_HTML tag is set to YES, doxygen will generate HTML output # The default value is: YES. GENERATE_HTML = YES @@ -1095,7 +1203,7 @@ HTML_FILE_EXTENSION = .html # of the possible markers and block names see the documentation. # This tag requires that the tag GENERATE_HTML is set to YES. -HTML_HEADER = +HTML_HEADER = # The HTML_FOOTER tag can be used to specify a user-defined HTML footer for each # generated HTML page. If the tag is left blank doxygen will generate a standard @@ -1105,7 +1213,7 @@ HTML_HEADER = # that doxygen normally uses. # This tag requires that the tag GENERATE_HTML is set to YES. -HTML_FOOTER = +HTML_FOOTER = # The HTML_STYLESHEET tag can be used to specify a user-defined cascading style # sheet that is used by each HTML page. It can be used to fine-tune the look of @@ -1117,18 +1225,20 @@ HTML_FOOTER = # obsolete. # This tag requires that the tag GENERATE_HTML is set to YES. -HTML_STYLESHEET = +HTML_STYLESHEET = -# The HTML_EXTRA_STYLESHEET tag can be used to specify an additional user- -# defined cascading style sheet that is included after the standard style sheets +# The HTML_EXTRA_STYLESHEET tag can be used to specify additional user-defined +# cascading style sheets that are included after the standard style sheets # created by doxygen. Using this option one can overrule certain style aspects. # This is preferred over using HTML_STYLESHEET since it does not replace the -# standard style sheet and is therefor more robust against future updates. -# Doxygen will copy the style sheet file to the output directory. For an example -# see the documentation. +# standard style sheet and is therefore more robust against future updates. +# Doxygen will copy the style sheet files to the output directory. +# Note: The order of the extra style sheet files is of importance (e.g. the last +# style sheet in the list overrules the setting of the previous ones in the +# list). For an example see the documentation. # This tag requires that the tag GENERATE_HTML is set to YES. -HTML_EXTRA_STYLESHEET = +HTML_EXTRA_STYLESHEET = # The HTML_EXTRA_FILES tag can be used to specify one or more extra images or # other source files which should be copied to the HTML output directory. Note @@ -1138,12 +1248,12 @@ HTML_EXTRA_STYLESHEET = # files will be copied as-is; there are no commands or markers available. # This tag requires that the tag GENERATE_HTML is set to YES. -HTML_EXTRA_FILES = +HTML_EXTRA_FILES = # The HTML_COLORSTYLE_HUE tag controls the color of the HTML output. Doxygen -# will adjust the colors in the stylesheet and background images according to +# will adjust the colors in the style sheet and background images according to # this color. Hue is specified as an angle on a colorwheel, see -# http://en.wikipedia.org/wiki/Hue for more information. For instance the value +# https://en.wikipedia.org/wiki/Hue for more information. For instance the value # 0 represents red, 60 is yellow, 120 is green, 180 is cyan, 240 is blue, 300 # purple, and 360 is red again. # Minimum value: 0, maximum value: 359, default value: 220. @@ -1172,12 +1282,24 @@ HTML_COLORSTYLE_GAMMA = 80 # If the HTML_TIMESTAMP tag is set to YES then the footer of each generated HTML # page will contain the date and time when the page was generated. Setting this -# to NO can help when comparing the output of multiple runs. -# The default value is: YES. +# to YES can help to show when doxygen was last run and thus if the +# documentation is up to date. +# The default value is: NO. # This tag requires that the tag GENERATE_HTML is set to YES. HTML_TIMESTAMP = YES +# If the HTML_DYNAMIC_MENUS tag is set to YES then the generated HTML +# documentation will contain a main index with vertical navigation menus that +# are dynamically created via JavaScript. If disabled, the navigation index will +# consists of multiple levels of tabs that are statically embedded in every HTML +# page. Disable this option to support browsers that do not have JavaScript, +# like the Qt help browser. +# The default value is: YES. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_DYNAMIC_MENUS = YES + # If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML # documentation will contain sections that can be hidden and shown after the # page has loaded. @@ -1201,13 +1323,14 @@ HTML_INDEX_NUM_ENTRIES = 100 # If the GENERATE_DOCSET tag is set to YES, additional index files will be # generated that can be used as input for Apple's Xcode 3 integrated development -# environment (see: http://developer.apple.com/tools/xcode/), introduced with -# OSX 10.5 (Leopard). To create a documentation set, doxygen will generate a -# Makefile in the HTML output directory. Running make will produce the docset in -# that directory and running make install will install the docset in +# environment (see: +# https://developer.apple.com/xcode/), introduced with OSX 10.5 (Leopard). To +# create a documentation set, doxygen will generate a Makefile in the HTML +# output directory. Running make will produce the docset in that directory and +# running make install will install the docset in # ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find it at -# startup. See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html -# for more information. +# startup. See https://developer.apple.com/library/archive/featuredarticles/Doxy +# genXcode/_index.html for more information. # The default value is: NO. # This tag requires that the tag GENERATE_HTML is set to YES. @@ -1246,8 +1369,8 @@ DOCSET_PUBLISHER_NAME = Publisher # If the GENERATE_HTMLHELP tag is set to YES then doxygen generates three # additional HTML index files: index.hhp, index.hhc, and index.hhk. The # index.hhp is a project file that can be read by Microsoft's HTML Help Workshop -# (see: http://www.microsoft.com/en-us/download/details.aspx?id=21138) on -# Windows. +# (see: +# https://www.microsoft.com/en-us/download/details.aspx?id=21138) on Windows. # # The HTML Help Workshop contains a compiler that can convert all HTML output # generated by doxygen into a single compiled HTML file (.chm). Compiled HTML @@ -1266,31 +1389,32 @@ GENERATE_HTMLHELP = NO # written to the html output directory. # This tag requires that the tag GENERATE_HTMLHELP is set to YES. -CHM_FILE = +CHM_FILE = # The HHC_LOCATION tag can be used to specify the location (absolute path -# including file name) of the HTML help compiler ( hhc.exe). If non-empty +# including file name) of the HTML help compiler (hhc.exe). If non-empty, # doxygen will try to run the HTML help compiler on the generated index.hhp. # The file has to be specified with full path. # This tag requires that the tag GENERATE_HTMLHELP is set to YES. -HHC_LOCATION = +HHC_LOCATION = -# The GENERATE_CHI flag controls if a separate .chi index file is generated ( -# YES) or that it should be included in the master .chm file ( NO). +# The GENERATE_CHI flag controls if a separate .chi index file is generated +# (YES) or that it should be included in the main .chm file (NO). # The default value is: NO. # This tag requires that the tag GENERATE_HTMLHELP is set to YES. GENERATE_CHI = NO -# The CHM_INDEX_ENCODING is used to encode HtmlHelp index ( hhk), content ( hhc) +# The CHM_INDEX_ENCODING is used to encode HtmlHelp index (hhk), content (hhc) # and project file content. # This tag requires that the tag GENERATE_HTMLHELP is set to YES. -CHM_INDEX_ENCODING = +CHM_INDEX_ENCODING = -# The BINARY_TOC flag controls whether a binary table of contents is generated ( -# YES) or a normal table of contents ( NO) in the .chm file. +# The BINARY_TOC flag controls whether a binary table of contents is generated +# (YES) or a normal table of contents (NO) in the .chm file. Furthermore it +# enables the Previous and Next buttons. # The default value is: NO. # This tag requires that the tag GENERATE_HTMLHELP is set to YES. @@ -1317,11 +1441,12 @@ GENERATE_QHP = NO # the HTML output folder. # This tag requires that the tag GENERATE_QHP is set to YES. -QCH_FILE = +QCH_FILE = # The QHP_NAMESPACE tag specifies the namespace to use when generating Qt Help # Project output. For more information please see Qt Help Project / Namespace -# (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#namespace). +# (see: +# https://doc.qt.io/archives/qt-4.8/qthelpproject.html#namespace). # The default value is: org.doxygen.Project. # This tag requires that the tag GENERATE_QHP is set to YES. @@ -1329,8 +1454,8 @@ QHP_NAMESPACE = org.doxygen.Project # The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating Qt # Help Project output. For more information please see Qt Help Project / Virtual -# Folders (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#virtual- -# folders). +# Folders (see: +# https://doc.qt.io/archives/qt-4.8/qthelpproject.html#virtual-folders). # The default value is: doc. # This tag requires that the tag GENERATE_QHP is set to YES. @@ -1338,33 +1463,33 @@ QHP_VIRTUAL_FOLDER = doc # If the QHP_CUST_FILTER_NAME tag is set, it specifies the name of a custom # filter to add. For more information please see Qt Help Project / Custom -# Filters (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#custom- -# filters). +# Filters (see: +# https://doc.qt.io/archives/qt-4.8/qthelpproject.html#custom-filters). # This tag requires that the tag GENERATE_QHP is set to YES. -QHP_CUST_FILTER_NAME = +QHP_CUST_FILTER_NAME = # The QHP_CUST_FILTER_ATTRS tag specifies the list of the attributes of the # custom filter to add. For more information please see Qt Help Project / Custom -# Filters (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#custom- -# filters). +# Filters (see: +# https://doc.qt.io/archives/qt-4.8/qthelpproject.html#custom-filters). # This tag requires that the tag GENERATE_QHP is set to YES. -QHP_CUST_FILTER_ATTRS = +QHP_CUST_FILTER_ATTRS = # The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this # project's filter section matches. Qt Help Project / Filter Attributes (see: -# http://qt-project.org/doc/qt-4.8/qthelpproject.html#filter-attributes). +# https://doc.qt.io/archives/qt-4.8/qthelpproject.html#filter-attributes). # This tag requires that the tag GENERATE_QHP is set to YES. -QHP_SECT_FILTER_ATTRS = +QHP_SECT_FILTER_ATTRS = -# The QHG_LOCATION tag can be used to specify the location of Qt's -# qhelpgenerator. If non-empty doxygen will try to run qhelpgenerator on the -# generated .qhp file. +# The QHG_LOCATION tag can be used to specify the location (absolute path +# including file name) of Qt's qhelpgenerator. If non-empty doxygen will try to +# run qhelpgenerator on the generated .qhp file. # This tag requires that the tag GENERATE_QHP is set to YES. -QHG_LOCATION = +QHG_LOCATION = # If the GENERATE_ECLIPSEHELP tag is set to YES, additional index files will be # generated, together with the HTML files, they form an Eclipse help plugin. To @@ -1403,7 +1528,7 @@ DISABLE_INDEX = NO # index structure (just like the one that is generated for HTML Help). For this # to work a browser that supports JavaScript, DHTML, CSS and frames is required # (i.e. any modern browser). Windows users are probably better off using the -# HTML help feature. Via custom stylesheets (see HTML_EXTRA_STYLESHEET) one can +# HTML help feature. Via custom style sheets (see HTML_EXTRA_STYLESHEET) one can # further fine-tune the look of the index. As an example, the default style # sheet generated by doxygen has an example that shows how to put an image at # the root of the tree instead of the PROJECT_NAME. Since the tree basically has @@ -1431,13 +1556,24 @@ ENUM_VALUES_PER_LINE = 4 TREEVIEW_WIDTH = 250 -# When the EXT_LINKS_IN_WINDOW option is set to YES doxygen will open links to +# If the EXT_LINKS_IN_WINDOW option is set to YES, doxygen will open links to # external symbols imported via tag files in a separate window. # The default value is: NO. # This tag requires that the tag GENERATE_HTML is set to YES. EXT_LINKS_IN_WINDOW = NO +# If the HTML_FORMULA_FORMAT option is set to svg, doxygen will use the pdf2svg +# tool (see https://github.com/dawbarton/pdf2svg) or inkscape (see +# https://inkscape.org) to generate formulas as SVG images instead of PNGs for +# the HTML output. These images will generally look nicer at scaled resolutions. +# Possible values are: png (the default) and svg (looks nicer but requires the +# pdf2svg or inkscape tool). +# The default value is: png. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_FORMULA_FORMAT = png + # Use this tag to change the font size of LaTeX formulas included as images in # the HTML documentation. When you change the font size after a successful # doxygen run you need to manually remove any form_*.png images from the HTML @@ -1447,7 +1583,7 @@ EXT_LINKS_IN_WINDOW = NO FORMULA_FONTSIZE = 10 -# Use the FORMULA_TRANPARENT tag to determine whether or not the images +# Use the FORMULA_TRANSPARENT tag to determine whether or not the images # generated for formulas are transparent PNGs. Transparent PNGs are not # supported properly for IE 6.0, but are supported on all modern browsers. # @@ -1458,9 +1594,15 @@ FORMULA_FONTSIZE = 10 FORMULA_TRANSPARENT = YES +# The FORMULA_MACROFILE can contain LaTeX \newcommand and \renewcommand commands +# to create new LaTeX commands to be used in formulas as building blocks. See +# the section "Including formulas" for details. + +FORMULA_MACROFILE = + # Enable the USE_MATHJAX option to render LaTeX formulas using MathJax (see -# http://www.mathjax.org) which uses client side Javascript for the rendering -# instead of using prerendered bitmaps. Use this if you do not have LaTeX +# https://www.mathjax.org) which uses client side JavaScript for the rendering +# instead of using pre-rendered bitmaps. Use this if you do not have LaTeX # installed or if you want to formulas look prettier in the HTML output. When # enabled you may also need to install MathJax separately and configure the path # to it using the MATHJAX_RELPATH option. @@ -1471,7 +1613,7 @@ USE_MATHJAX = NO # When MathJax is enabled you can set the default output format to be used for # the MathJax output. See the MathJax site (see: -# http://docs.mathjax.org/en/latest/output.html) for more details. +# http://docs.mathjax.org/en/v2.7-latest/output.html) for more details. # Possible values are: HTML-CSS (which is slower, but has the best # compatibility), NativeMML (i.e. MathML) and SVG. # The default value is: HTML-CSS. @@ -1486,8 +1628,8 @@ MATHJAX_FORMAT = HTML-CSS # MATHJAX_RELPATH should be ../mathjax. The default value points to the MathJax # Content Delivery Network so you can quickly see the result without installing # MathJax. However, it is strongly recommended to install a local copy of -# MathJax from http://www.mathjax.org before deployment. -# The default value is: http://cdn.mathjax.org/mathjax/latest. +# MathJax from https://www.mathjax.org before deployment. +# The default value is: https://cdn.jsdelivr.net/npm/mathjax@2. # This tag requires that the tag USE_MATHJAX is set to YES. MATHJAX_RELPATH = http://cdn.mathjax.org/mathjax/latest @@ -1497,15 +1639,16 @@ MATHJAX_RELPATH = http://cdn.mathjax.org/mathjax/latest # MATHJAX_EXTENSIONS = TeX/AMSmath TeX/AMSsymbols # This tag requires that the tag USE_MATHJAX is set to YES. -MATHJAX_EXTENSIONS = +MATHJAX_EXTENSIONS = # The MATHJAX_CODEFILE tag can be used to specify a file with javascript pieces # of code that will be used on startup of the MathJax code. See the MathJax site -# (see: http://docs.mathjax.org/en/latest/output.html) for more details. For an +# (see: +# http://docs.mathjax.org/en/v2.7-latest/output.html) for more details. For an # example see the documentation. # This tag requires that the tag USE_MATHJAX is set to YES. -MATHJAX_CODEFILE = +MATHJAX_CODEFILE = # When the SEARCHENGINE tag is enabled doxygen will generate a search box for # the HTML output. The underlying search engine uses javascript and DHTML and @@ -1529,12 +1672,12 @@ MATHJAX_CODEFILE = SEARCHENGINE = YES # When the SERVER_BASED_SEARCH tag is enabled the search engine will be -# implemented using a web server instead of a web client using Javascript. There -# are two flavours of web server based searching depending on the -# EXTERNAL_SEARCH setting. When disabled, doxygen will generate a PHP script for -# searching and an index file used by the script. When EXTERNAL_SEARCH is -# enabled the indexing and searching needs to be provided by external tools. See -# the section "External Indexing and Searching" for details. +# implemented using a web server instead of a web client using JavaScript. There +# are two flavors of web server based searching depending on the EXTERNAL_SEARCH +# setting. When disabled, doxygen will generate a PHP script for searching and +# an index file used by the script. When EXTERNAL_SEARCH is enabled the indexing +# and searching needs to be provided by external tools. See the section +# "External Indexing and Searching" for details. # The default value is: NO. # This tag requires that the tag SEARCHENGINE is set to YES. @@ -1546,9 +1689,10 @@ SERVER_BASED_SEARCH = NO # external search engine pointed to by the SEARCHENGINE_URL option to obtain the # search results. # -# Doxygen ships with an example indexer ( doxyindexer) and search engine +# Doxygen ships with an example indexer (doxyindexer) and search engine # (doxysearch.cgi) which are based on the open source search engine library -# Xapian (see: http://xapian.org/). +# Xapian (see: +# https://xapian.org/). # # See the section "External Indexing and Searching" for details. # The default value is: NO. @@ -1559,13 +1703,14 @@ EXTERNAL_SEARCH = NO # The SEARCHENGINE_URL should point to a search engine hosted by a web server # which will return the search results when EXTERNAL_SEARCH is enabled. # -# Doxygen ships with an example indexer ( doxyindexer) and search engine +# Doxygen ships with an example indexer (doxyindexer) and search engine # (doxysearch.cgi) which are based on the open source search engine library -# Xapian (see: http://xapian.org/). See the section "External Indexing and -# Searching" for details. +# Xapian (see: +# https://xapian.org/). See the section "External Indexing and Searching" for +# details. # This tag requires that the tag SEARCHENGINE is set to YES. -SEARCHENGINE_URL = +SEARCHENGINE_URL = # When SERVER_BASED_SEARCH and EXTERNAL_SEARCH are both enabled the unindexed # search data is written to a file for indexing by an external tool. With the @@ -1581,7 +1726,7 @@ SEARCHDATA_FILE = searchdata.xml # projects and redirect the results back to the right project. # This tag requires that the tag SEARCHENGINE is set to YES. -EXTERNAL_SEARCH_ID = +EXTERNAL_SEARCH_ID = # The EXTRA_SEARCH_MAPPINGS tag can be used to enable searching through doxygen # projects other than the one defined by this configuration file, but that are @@ -1591,13 +1736,13 @@ EXTERNAL_SEARCH_ID = # EXTRA_SEARCH_MAPPINGS = tagname1=loc1 tagname2=loc2 ... # This tag requires that the tag SEARCHENGINE is set to YES. -EXTRA_SEARCH_MAPPINGS = +EXTRA_SEARCH_MAPPINGS = #--------------------------------------------------------------------------- # Configuration options related to the LaTeX output #--------------------------------------------------------------------------- -# If the GENERATE_LATEX tag is set to YES doxygen will generate LaTeX output. +# If the GENERATE_LATEX tag is set to YES, doxygen will generate LaTeX output. # The default value is: YES. GENERATE_LATEX = NO @@ -1613,22 +1758,36 @@ LATEX_OUTPUT = latex # The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be # invoked. # -# Note that when enabling USE_PDFLATEX this option is only used for generating -# bitmaps for formulas in the HTML output, but not in the Makefile that is -# written to the output directory. -# The default file is: latex. +# Note that when not enabling USE_PDFLATEX the default is latex when enabling +# USE_PDFLATEX the default is pdflatex and when in the later case latex is +# chosen this is overwritten by pdflatex. For specific output languages the +# default can have been set differently, this depends on the implementation of +# the output language. # This tag requires that the tag GENERATE_LATEX is set to YES. LATEX_CMD_NAME = latex # The MAKEINDEX_CMD_NAME tag can be used to specify the command name to generate # index for LaTeX. +# Note: This tag is used in the Makefile / make.bat. +# See also: LATEX_MAKEINDEX_CMD for the part in the generated output file +# (.tex). # The default file is: makeindex. # This tag requires that the tag GENERATE_LATEX is set to YES. MAKEINDEX_CMD_NAME = makeindex -# If the COMPACT_LATEX tag is set to YES doxygen generates more compact LaTeX +# The LATEX_MAKEINDEX_CMD tag can be used to specify the command name to +# generate index for LaTeX. In case there is no backslash (\) as first character +# it will be automatically added in the LaTeX code. +# Note: This tag is used in the generated output file (.tex). +# See also: MAKEINDEX_CMD_NAME for the part in the Makefile / make.bat. +# The default value is: makeindex. +# This tag requires that the tag GENERATE_LATEX is set to YES. + +LATEX_MAKEINDEX_CMD = makeindex + +# If the COMPACT_LATEX tag is set to YES, doxygen generates more compact LaTeX # documents. This may be useful for small projects and may help to save some # trees in general. # The default value is: NO. @@ -1646,13 +1805,16 @@ COMPACT_LATEX = NO PAPER_TYPE = a4 # The EXTRA_PACKAGES tag can be used to specify one or more LaTeX package names -# that should be included in the LaTeX output. To get the times font for -# instance you can specify -# EXTRA_PACKAGES=times +# that should be included in the LaTeX output. The package can be specified just +# by its name or with the correct syntax as to be used with the LaTeX +# \usepackage command. To get the times font for instance you can specify : +# EXTRA_PACKAGES=times or EXTRA_PACKAGES={times} +# To use the option intlimits with the amsmath package you can specify: +# EXTRA_PACKAGES=[intlimits]{amsmath} # If left blank no extra packages will be included. # This tag requires that the tag GENERATE_LATEX is set to YES. -EXTRA_PACKAGES = +EXTRA_PACKAGES = # The LATEX_HEADER tag can be used to specify a personal LaTeX header for the # generated LaTeX document. The header should contain everything until the first @@ -1662,22 +1824,35 @@ EXTRA_PACKAGES = # # Note: Only use a user-defined header if you know what you are doing! The # following commands have a special meaning inside the header: $title, -# $datetime, $date, $doxygenversion, $projectname, $projectnumber. Doxygen will -# replace them by respectively the title of the page, the current date and time, -# only the current date, the version number of doxygen, the project name (see -# PROJECT_NAME), or the project number (see PROJECT_NUMBER). +# $datetime, $date, $doxygenversion, $projectname, $projectnumber, +# $projectbrief, $projectlogo. Doxygen will replace $title with the empty +# string, for the replacement values of the other commands the user is referred +# to HTML_HEADER. # This tag requires that the tag GENERATE_LATEX is set to YES. -LATEX_HEADER = +LATEX_HEADER = # The LATEX_FOOTER tag can be used to specify a personal LaTeX footer for the # generated LaTeX document. The footer should contain everything after the last -# chapter. If it is left blank doxygen will generate a standard footer. +# chapter. If it is left blank doxygen will generate a standard footer. See +# LATEX_HEADER for more information on how to generate a default footer and what +# special commands can be used inside the footer. # # Note: Only use a user-defined footer if you know what you are doing! # This tag requires that the tag GENERATE_LATEX is set to YES. -LATEX_FOOTER = +LATEX_FOOTER = + +# The LATEX_EXTRA_STYLESHEET tag can be used to specify additional user-defined +# LaTeX style sheets that are included after the standard style sheets created +# by doxygen. Using this option one can overrule certain style aspects. Doxygen +# will copy the style sheet files to the output directory. +# Note: The order of the extra style sheet files is of importance (e.g. the last +# style sheet in the list overrules the setting of the previous ones in the +# list). +# This tag requires that the tag GENERATE_LATEX is set to YES. + +LATEX_EXTRA_STYLESHEET = # The LATEX_EXTRA_FILES tag can be used to specify one or more extra images or # other source files which should be copied to the LATEX_OUTPUT output @@ -1685,7 +1860,7 @@ LATEX_FOOTER = # markers available. # This tag requires that the tag GENERATE_LATEX is set to YES. -LATEX_EXTRA_FILES = +LATEX_EXTRA_FILES = # If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated is # prepared for conversion to PDF (using ps2pdf or pdflatex). The PDF file will @@ -1696,9 +1871,11 @@ LATEX_EXTRA_FILES = PDF_HYPERLINKS = YES -# If the LATEX_PDFLATEX tag is set to YES, doxygen will use pdflatex to generate -# the PDF file directly from the LaTeX files. Set this option to YES to get a -# higher quality PDF documentation. +# If the USE_PDFLATEX tag is set to YES, doxygen will use the engine as +# specified with LATEX_CMD_NAME to generate the PDF file directly from the LaTeX +# files. Set this option to YES, to get a higher quality PDF documentation. +# +# See also section LATEX_CMD_NAME for selecting the engine. # The default value is: YES. # This tag requires that the tag GENERATE_LATEX is set to YES. @@ -1732,17 +1909,33 @@ LATEX_SOURCE_CODE = NO # The LATEX_BIB_STYLE tag can be used to specify the style to use for the # bibliography, e.g. plainnat, or ieeetr. See -# http://en.wikipedia.org/wiki/BibTeX and \cite for more info. +# https://en.wikipedia.org/wiki/BibTeX and \cite for more info. # The default value is: plain. # This tag requires that the tag GENERATE_LATEX is set to YES. LATEX_BIB_STYLE = plain +# If the LATEX_TIMESTAMP tag is set to YES then the footer of each generated +# page will contain the date and time when the page was generated. Setting this +# to NO can help when comparing the output of multiple runs. +# The default value is: NO. +# This tag requires that the tag GENERATE_LATEX is set to YES. + +LATEX_TIMESTAMP = NO + +# The LATEX_EMOJI_DIRECTORY tag is used to specify the (relative or absolute) +# path from which the emoji images will be read. If a relative path is entered, +# it will be relative to the LATEX_OUTPUT directory. If left blank the +# LATEX_OUTPUT directory will be used. +# This tag requires that the tag GENERATE_LATEX is set to YES. + +LATEX_EMOJI_DIRECTORY = + #--------------------------------------------------------------------------- # Configuration options related to the RTF output #--------------------------------------------------------------------------- -# If the GENERATE_RTF tag is set to YES doxygen will generate RTF output. The +# If the GENERATE_RTF tag is set to YES, doxygen will generate RTF output. The # RTF output is optimized for Word 97 and may not look too pretty with other RTF # readers/editors. # The default value is: NO. @@ -1757,7 +1950,7 @@ GENERATE_RTF = NO RTF_OUTPUT = rtf -# If the COMPACT_RTF tag is set to YES doxygen generates more compact RTF +# If the COMPACT_RTF tag is set to YES, doxygen generates more compact RTF # documents. This may be useful for small projects and may help to save some # trees in general. # The default value is: NO. @@ -1777,28 +1970,38 @@ COMPACT_RTF = NO RTF_HYPERLINKS = NO -# Load stylesheet definitions from file. Syntax is similar to doxygen's config -# file, i.e. a series of assignments. You only have to provide replacements, -# missing definitions are set to their default value. +# Load stylesheet definitions from file. Syntax is similar to doxygen's +# configuration file, i.e. a series of assignments. You only have to provide +# replacements, missing definitions are set to their default value. # # See also section "Doxygen usage" for information on how to generate the # default style sheet that doxygen normally uses. # This tag requires that the tag GENERATE_RTF is set to YES. -RTF_STYLESHEET_FILE = +RTF_STYLESHEET_FILE = # Set optional variables used in the generation of an RTF document. Syntax is -# similar to doxygen's config file. A template extensions file can be generated -# using doxygen -e rtf extensionFile. +# similar to doxygen's configuration file. A template extensions file can be +# generated using doxygen -e rtf extensionFile. +# This tag requires that the tag GENERATE_RTF is set to YES. + +RTF_EXTENSIONS_FILE = + +# If the RTF_SOURCE_CODE tag is set to YES then doxygen will include source code +# with syntax highlighting in the RTF output. +# +# Note that which sources are shown also depends on other settings such as +# SOURCE_BROWSER. +# The default value is: NO. # This tag requires that the tag GENERATE_RTF is set to YES. -RTF_EXTENSIONS_FILE = +RTF_SOURCE_CODE = NO #--------------------------------------------------------------------------- # Configuration options related to the man page output #--------------------------------------------------------------------------- -# If the GENERATE_MAN tag is set to YES doxygen will generate man pages for +# If the GENERATE_MAN tag is set to YES, doxygen will generate man pages for # classes and files. # The default value is: NO. @@ -1822,6 +2025,13 @@ MAN_OUTPUT = man MAN_EXTENSION = .3 +# The MAN_SUBDIR tag determines the name of the directory created within +# MAN_OUTPUT in which the man pages are placed. If defaults to man followed by +# MAN_EXTENSION with the initial . removed. +# This tag requires that the tag GENERATE_MAN is set to YES. + +MAN_SUBDIR = + # If the MAN_LINKS tag is set to YES and doxygen generates man output, then it # will generate one additional man file for each entity documented in the real # man page(s). These additional files only source the real man page, but without @@ -1835,7 +2045,7 @@ MAN_LINKS = NO # Configuration options related to the XML output #--------------------------------------------------------------------------- -# If the GENERATE_XML tag is set to YES doxygen will generate an XML file that +# If the GENERATE_XML tag is set to YES, doxygen will generate an XML file that # captures the structure of the code including all documentation. # The default value is: NO. @@ -1849,19 +2059,7 @@ GENERATE_XML = NO XML_OUTPUT = xml -# The XML_SCHEMA tag can be used to specify a XML schema, which can be used by a -# validating XML parser to check the syntax of the XML files. -# This tag requires that the tag GENERATE_XML is set to YES. - -XML_SCHEMA = - -# The XML_DTD tag can be used to specify a XML DTD, which can be used by a -# validating XML parser to check the syntax of the XML files. -# This tag requires that the tag GENERATE_XML is set to YES. - -XML_DTD = - -# If the XML_PROGRAMLISTING tag is set to YES doxygen will dump the program +# If the XML_PROGRAMLISTING tag is set to YES, doxygen will dump the program # listings (including syntax highlighting and cross-referencing information) to # the XML output. Note that enabling this will significantly increase the size # of the XML output. @@ -1870,11 +2068,18 @@ XML_DTD = XML_PROGRAMLISTING = YES +# If the XML_NS_MEMB_FILE_SCOPE tag is set to YES, doxygen will include +# namespace members in file scope as well, matching the HTML output. +# The default value is: NO. +# This tag requires that the tag GENERATE_XML is set to YES. + +XML_NS_MEMB_FILE_SCOPE = NO + #--------------------------------------------------------------------------- # Configuration options related to the DOCBOOK output #--------------------------------------------------------------------------- -# If the GENERATE_DOCBOOK tag is set to YES doxygen will generate Docbook files +# If the GENERATE_DOCBOOK tag is set to YES, doxygen will generate Docbook files # that can be used to generate PDF. # The default value is: NO. @@ -1888,14 +2093,23 @@ GENERATE_DOCBOOK = NO DOCBOOK_OUTPUT = docbook +# If the DOCBOOK_PROGRAMLISTING tag is set to YES, doxygen will include the +# program listings (including syntax highlighting and cross-referencing +# information) to the DOCBOOK output. Note that enabling this will significantly +# increase the size of the DOCBOOK output. +# The default value is: NO. +# This tag requires that the tag GENERATE_DOCBOOK is set to YES. + +DOCBOOK_PROGRAMLISTING = NO + #--------------------------------------------------------------------------- # Configuration options for the AutoGen Definitions output #--------------------------------------------------------------------------- -# If the GENERATE_AUTOGEN_DEF tag is set to YES doxygen will generate an AutoGen -# Definitions (see http://autogen.sf.net) file that captures the structure of -# the code including all documentation. Note that this feature is still -# experimental and incomplete at the moment. +# If the GENERATE_AUTOGEN_DEF tag is set to YES, doxygen will generate an +# AutoGen Definitions (see http://autogen.sourceforge.net/) file that captures +# the structure of the code including all documentation. Note that this feature +# is still experimental and incomplete at the moment. # The default value is: NO. GENERATE_AUTOGEN_DEF = NO @@ -1904,7 +2118,7 @@ GENERATE_AUTOGEN_DEF = NO # Configuration options related to the Perl module output #--------------------------------------------------------------------------- -# If the GENERATE_PERLMOD tag is set to YES doxygen will generate a Perl module +# If the GENERATE_PERLMOD tag is set to YES, doxygen will generate a Perl module # file that captures the structure of the code including all documentation. # # Note that this feature is still experimental and incomplete at the moment. @@ -1912,7 +2126,7 @@ GENERATE_AUTOGEN_DEF = NO GENERATE_PERLMOD = NO -# If the PERLMOD_LATEX tag is set to YES doxygen will generate the necessary +# If the PERLMOD_LATEX tag is set to YES, doxygen will generate the necessary # Makefile rules, Perl scripts and LaTeX code to be able to generate PDF and DVI # output from the Perl module output. # The default value is: NO. @@ -1920,9 +2134,9 @@ GENERATE_PERLMOD = NO PERLMOD_LATEX = NO -# If the PERLMOD_PRETTY tag is set to YES the Perl module output will be nicely +# If the PERLMOD_PRETTY tag is set to YES, the Perl module output will be nicely # formatted so it can be parsed by a human reader. This is useful if you want to -# understand what is going on. On the other hand, if this tag is set to NO the +# understand what is going on. On the other hand, if this tag is set to NO, the # size of the Perl module output will be much smaller and Perl will parse it # just the same. # The default value is: YES. @@ -1936,20 +2150,20 @@ PERLMOD_PRETTY = YES # overwrite each other's variables. # This tag requires that the tag GENERATE_PERLMOD is set to YES. -PERLMOD_MAKEVAR_PREFIX = +PERLMOD_MAKEVAR_PREFIX = #--------------------------------------------------------------------------- # Configuration options related to the preprocessor #--------------------------------------------------------------------------- -# If the ENABLE_PREPROCESSING tag is set to YES doxygen will evaluate all +# If the ENABLE_PREPROCESSING tag is set to YES, doxygen will evaluate all # C-preprocessor directives found in the sources and include files. # The default value is: YES. ENABLE_PREPROCESSING = YES -# If the MACRO_EXPANSION tag is set to YES doxygen will expand all macro names -# in the source code. If set to NO only conditional compilation will be +# If the MACRO_EXPANSION tag is set to YES, doxygen will expand all macro names +# in the source code. If set to NO, only conditional compilation will be # performed. Macro expansion can be done in a controlled way by setting # EXPAND_ONLY_PREDEF to YES. # The default value is: NO. @@ -1965,7 +2179,7 @@ MACRO_EXPANSION = YES EXPAND_ONLY_PREDEF = YES -# If the SEARCH_INCLUDES tag is set to YES the includes files in the +# If the SEARCH_INCLUDES tag is set to YES, the include files in the # INCLUDE_PATH will be searched if a #include is found. # The default value is: YES. # This tag requires that the tag ENABLE_PREPROCESSING is set to YES. @@ -1977,7 +2191,7 @@ SEARCH_INCLUDES = YES # preprocessor. # This tag requires that the tag SEARCH_INCLUDES is set to YES. -INCLUDE_PATH = +INCLUDE_PATH = # You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard # patterns (like *.h and *.hpp) to filter out the header-files in the @@ -1985,7 +2199,7 @@ INCLUDE_PATH = # used. # This tag requires that the tag ENABLE_PREPROCESSING is set to YES. -INCLUDE_FILE_PATTERNS = +INCLUDE_FILE_PATTERNS = # The PREDEFINED tag can be used to specify one or more macro names that are # defined before the preprocessor is started (similar to the -D option of e.g. @@ -2007,12 +2221,12 @@ PREDEFINED = VF_FETOL \ # definition found in the source code. # This tag requires that the tag ENABLE_PREPROCESSING is set to YES. -EXPAND_AS_DEFINED = +EXPAND_AS_DEFINED = # If the SKIP_FUNCTION_MACROS tag is set to YES then doxygen's preprocessor will -# remove all refrences to function-like macros that are alone on a line, have an -# all uppercase name, and do not end with a semicolon. Such function macros are -# typically used for boiler-plate code, and will confuse the parser if not +# remove all references to function-like macros that are alone on a line, have +# an all uppercase name, and do not end with a semicolon. Such function macros +# are typically used for boiler-plate code, and will confuse the parser if not # removed. # The default value is: YES. # This tag requires that the tag ENABLE_PREPROCESSING is set to YES. @@ -2032,49 +2246,44 @@ SKIP_FUNCTION_MACROS = YES # where loc1 and loc2 can be relative or absolute paths or URLs. See the # section "Linking to external documentation" for more information about the use # of tag files. -# Note: Each tag file must have an unique name (where the name does NOT include +# Note: Each tag file must have a unique name (where the name does NOT include # the path). If a tag file is not located in the directory in which doxygen is # run, you must also specify the path to the tagfile here. -TAGFILES = +TAGFILES = # When a file name is specified after GENERATE_TAGFILE, doxygen will create a # tag file that is based on the input files it reads. See section "Linking to # external documentation" for more information about the usage of tag files. -GENERATE_TAGFILE = +GENERATE_TAGFILE = -# If the ALLEXTERNALS tag is set to YES all external class will be listed in the -# class index. If set to NO only the inherited external classes will be listed. +# If the ALLEXTERNALS tag is set to YES, all external class will be listed in +# the class index. If set to NO, only the inherited external classes will be +# listed. # The default value is: NO. ALLEXTERNALS = NO -# If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed in -# the modules index. If set to NO, only the current project's groups will be +# If the EXTERNAL_GROUPS tag is set to YES, all external groups will be listed +# in the modules index. If set to NO, only the current project's groups will be # listed. # The default value is: YES. EXTERNAL_GROUPS = YES -# If the EXTERNAL_PAGES tag is set to YES all external pages will be listed in +# If the EXTERNAL_PAGES tag is set to YES, all external pages will be listed in # the related pages index. If set to NO, only the current project's pages will # be listed. # The default value is: YES. EXTERNAL_PAGES = YES -# The PERL_PATH should be the absolute path and name of the perl script -# interpreter (i.e. the result of 'which perl'). -# The default file (with absolute path) is: /usr/bin/perl. - -PERL_PATH = /usr/bin/perl - #--------------------------------------------------------------------------- # Configuration options related to the dot tool #--------------------------------------------------------------------------- -# If the CLASS_DIAGRAMS tag is set to YES doxygen will generate a class diagram +# If the CLASS_DIAGRAMS tag is set to YES, doxygen will generate a class diagram # (in HTML and LaTeX) for classes with base or super classes. Setting the tag to # NO turns the diagrams off. Note that this option also works with HAVE_DOT # disabled, but it is recommended to install and use dot, since it yields more @@ -2083,23 +2292,14 @@ PERL_PATH = /usr/bin/perl CLASS_DIAGRAMS = YES -# You can define message sequence charts within doxygen comments using the \msc -# command. Doxygen will then run the mscgen tool (see: -# http://www.mcternan.me.uk/mscgen/)) to produce the chart and insert it in the -# documentation. The MSCGEN_PATH tag allows you to specify the directory where -# the mscgen tool resides. If left empty the tool is assumed to be found in the -# default search path. - -MSCGEN_PATH = - # You can include diagrams made with dia in doxygen documentation. Doxygen will # then run dia to produce the diagram and insert it in the documentation. The # DIA_PATH tag allows you to specify the directory where the dia binary resides. # If left empty dia is assumed to be found in the default search path. -DIA_PATH = +DIA_PATH = -# If set to YES, the inheritance and collaboration graphs will hide inheritance +# If set to YES the inheritance and collaboration graphs will hide inheritance # and usage relations if the target is undocumented or is not a class. # The default value is: YES. @@ -2124,7 +2324,7 @@ HAVE_DOT = NO DOT_NUM_THREADS = 0 -# When you want a differently looking font n the dot files that doxygen +# When you want a differently looking font in the dot files that doxygen # generates you can specify the font name using DOT_FONTNAME. You need to make # sure dot is able to find the font, which can be done by putting it in a # standard location or by setting the DOTFONTPATH environment variable or by @@ -2146,7 +2346,7 @@ DOT_FONTSIZE = 10 # the path where dot can find it using this tag. # This tag requires that the tag HAVE_DOT is set to YES. -DOT_FONTPATH = +DOT_FONTPATH = # If the CLASS_GRAPH tag is set to YES then doxygen will generate a graph for # each documented class showing the direct and indirect inheritance relations. @@ -2172,7 +2372,7 @@ COLLABORATION_GRAPH = YES GROUP_GRAPHS = YES -# If the UML_LOOK tag is set to YES doxygen will generate inheritance and +# If the UML_LOOK tag is set to YES, doxygen will generate inheritance and # collaboration diagrams in a style similar to the OMG's Unified Modeling # Language. # The default value is: NO. @@ -2189,10 +2389,32 @@ UML_LOOK = NO # but if the number exceeds 15, the total amount of fields shown is limited to # 10. # Minimum value: 0, maximum value: 100, default value: 10. -# This tag requires that the tag HAVE_DOT is set to YES. +# This tag requires that the tag UML_LOOK is set to YES. UML_LIMIT_NUM_FIELDS = 10 +# If the DOT_UML_DETAILS tag is set to NO, doxygen will show attributes and +# methods without types and arguments in the UML graphs. If the DOT_UML_DETAILS +# tag is set to YES, doxygen will add type and arguments for attributes and +# methods in the UML graphs. If the DOT_UML_DETAILS tag is set to NONE, doxygen +# will not generate fields with class member information in the UML graphs. The +# class diagrams will look similar to the default class diagrams but using UML +# notation for the relationships. +# Possible values are: NO, YES and NONE. +# The default value is: NO. +# This tag requires that the tag UML_LOOK is set to YES. + +DOT_UML_DETAILS = NO + +# The DOT_WRAP_THRESHOLD tag can be used to set the maximum number of characters +# to display on a single line. If the actual line length exceeds this threshold +# significantly it will wrapped across multiple lines. Some heuristics are apply +# to avoid ugly line breaks. +# Minimum value: 0, maximum value: 1000, default value: 17. +# This tag requires that the tag HAVE_DOT is set to YES. + +DOT_WRAP_THRESHOLD = 17 + # If the TEMPLATE_RELATIONS tag is set to YES then the inheritance and # collaboration graphs will show the relations between templates and their # instances. @@ -2224,7 +2446,8 @@ INCLUDED_BY_GRAPH = YES # # Note that enabling this option will significantly increase the time of a run. # So in most cases it will be better to enable call graphs for selected -# functions only using the \callgraph command. +# functions only using the \callgraph command. Disabling a call graph can be +# accomplished by means of the command \hidecallgraph. # The default value is: NO. # This tag requires that the tag HAVE_DOT is set to YES. @@ -2235,7 +2458,8 @@ CALL_GRAPH = NO # # Note that enabling this option will significantly increase the time of a run. # So in most cases it will be better to enable caller graphs for selected -# functions only using the \callergraph command. +# functions only using the \callergraph command. Disabling a caller graph can be +# accomplished by means of the command \hidecallergraph. # The default value is: NO. # This tag requires that the tag HAVE_DOT is set to YES. @@ -2258,11 +2482,15 @@ GRAPHICAL_HIERARCHY = YES DIRECTORY_GRAPH = YES # The DOT_IMAGE_FORMAT tag can be used to set the image format of the images -# generated by dot. +# generated by dot. For an explanation of the image formats see the section +# output formats in the documentation of the dot tool (Graphviz (see: +# http://www.graphviz.org/)). # Note: If you choose svg you need to set HTML_FILE_EXTENSION to xhtml in order # to make the SVG files visible in IE 9+ (other browsers do not have this # requirement). -# Possible values are: png, jpg, gif and svg. +# Possible values are: png, jpg, gif, svg, png:gd, png:gd:gd, png:cairo, +# png:cairo:gd, png:cairo:cairo, png:cairo:gdiplus, png:gdiplus and +# png:gdiplus:gdiplus. # The default value is: png. # This tag requires that the tag HAVE_DOT is set to YES. @@ -2284,26 +2512,44 @@ INTERACTIVE_SVG = NO # found. If left blank, it is assumed the dot tool can be found in the path. # This tag requires that the tag HAVE_DOT is set to YES. -DOT_PATH = +DOT_PATH = # The DOTFILE_DIRS tag can be used to specify one or more directories that # contain dot files that are included in the documentation (see the \dotfile # command). # This tag requires that the tag HAVE_DOT is set to YES. -DOTFILE_DIRS = +DOTFILE_DIRS = # The MSCFILE_DIRS tag can be used to specify one or more directories that # contain msc files that are included in the documentation (see the \mscfile # command). -MSCFILE_DIRS = +MSCFILE_DIRS = # The DIAFILE_DIRS tag can be used to specify one or more directories that # contain dia files that are included in the documentation (see the \diafile # command). -DIAFILE_DIRS = +DIAFILE_DIRS = + +# When using plantuml, the PLANTUML_JAR_PATH tag should be used to specify the +# path where java can find the plantuml.jar file. If left blank, it is assumed +# PlantUML is not used or called during a preprocessing step. Doxygen will +# generate a warning when it encounters a \startuml command in this case and +# will not generate output for the diagram. + +PLANTUML_JAR_PATH = + +# When using plantuml, the PLANTUML_CFG_FILE tag can be used to specify a +# configuration file for plantuml. + +PLANTUML_CFG_FILE = + +# When using plantuml, the specified paths are searched for files specified by +# the !include statement in a plantuml block. + +PLANTUML_INCLUDE_PATH = # The DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of nodes # that will be shown in the graph. If the number of nodes in a graph becomes @@ -2341,7 +2587,7 @@ MAX_DOT_GRAPH_DEPTH = 0 DOT_TRANSPARENT = NO -# Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output +# Set the DOT_MULTI_TARGETS tag to YES to allow dot to generate multiple output # files in one run (i.e. multiple -o and -T options on the command line). This # makes dot run faster, but since only newer versions of dot (>1.8.10) support # this, this feature is disabled by default. @@ -2358,9 +2604,11 @@ DOT_MULTI_TARGETS = NO GENERATE_LEGEND = YES -# If the DOT_CLEANUP tag is set to YES doxygen will remove the intermediate dot +# If the DOT_CLEANUP tag is set to YES, doxygen will remove the intermediate # files that are used to generate the various graphs. +# +# Note: This setting is not only used for dot files but also for msc and +# plantuml temporary files. # The default value is: YES. -# This tag requires that the tag HAVE_DOT is set to YES. DOT_CLEANUP = YES diff --git a/docs/cpu/Documentation/doc.h b/docs/cpu/Documentation/doc.h deleted file mode 100644 index 0c6c4c6c30e7bc1a8691b52fa1555f2ea3d4d16b..0000000000000000000000000000000000000000 --- a/docs/cpu/Documentation/doc.h +++ /dev/null @@ -1,31 +0,0 @@ -//index page for doxygen - -/*! \mainpage - * - * \section intro_sec Introduction - * <i>VirtualFluids</i> is an adaptive, parallel Lattice-Boltzmann flow solver - * which is comprised of various cores - * and use second order accurate compact interpolation at the interfaces, - * coupling grids of different resolutions. - * The software framework is based on object-oriented technology and uses tree-like data structures. - * These data structures are also suitable for hierarchical parallelization using a combination of PThreads and MPI and dynamic load balancing. - * - * \section install_sec Installation - * - * \subsection step1 Step 1: CMake - * Download and install <a href="http://www.cmake.org/">CMake</a>. - * If you have Windows OS oder X-Windows for Linux/Unix start <i>cmake-gui</i>. - * If you work in terminal start <i>ccmake</i>. - * \subsection step2 Step 2: project configuration - * You need set a path for <i>VirtualFluids</i> source code. It is allays <i>source</i> directory at the end of path. - * E.g. c:/vf/source. You need also set a path to build binaries. If you click <b>Configure</b> button start a project wizard and you can choose a compiler. - * Set <b>Grouped</b> and <b>Advanced</b> check boxes in CMake. In the group <i>USE</i> you have follow important options: - * \li USE_BOND - using an agent based communication framework for fault tolerance BOND - * \li USE_METIS - using a domain decomposition tool METIS - * \li USE_MPI - using MPI for distributed memory parallelization - * \li USE_YAML - using YAML - * \li USE_ZOLTAN - using domain decomposition tool ZOLTAN - * There are externals library and you need additionally compile them. - * \subsection step3 Step 4: project compilation - * Compile you project with suitable compiler. - */ \ No newline at end of file diff --git a/docs/cpu/Documentation/doc/install.html b/docs/cpu/Documentation/doc/install.html deleted file mode 100644 index 0c4cfd3b3a94a47d2bd7c0de756def3f6501ff1a..0000000000000000000000000000000000000000 --- a/docs/cpu/Documentation/doc/install.html +++ /dev/null @@ -1,18 +0,0 @@ -\section install_sec Installation - -\subsection step1 Step 1: CMake -Download and install <a href="http://www.cmake.org/">CMake</a>. -If you have Windows OS oder X-Windows for Linux/Unix start <i>cmake-gui</i>. -If you work in terminal start <i>ccmake</i>. -\subsection step2 Step 2: project configuration -You need set a path for <i>VirtualFluids</i> source code. It is allays <i>source</i> directory at the end of path. -E.g. c:/vf/source. You need also set a path to build binaries. If you click <b>Configure</b> button start a project wizard and you can choose a compiler. -Set <b>Grouped</b> and <b>Advanced</b> check boxes in CMake. In the group <i>USE</i> you have follow important options: -\li USE_BOND - using an agent based communication framework for fault tolerance BOND -\li USE_METIS - using a domain decomposition tool METIS -\li USE_MPI - using MPI for distributed memory parallelization -\li USE_YAML - using YAML -\li USE_ZOLTAN - using domain decomposition tool ZOLTAN -There are externals library and you need additionally compile them. -\subsection step3 Step 4: project compilation -Compile you project with suitable compiler. diff --git a/docs/cpu/Documentation/doc/intstall.md b/docs/cpu/Documentation/doc/intstall.md deleted file mode 100644 index 912aea1bb142486445049dd3a1ae08b151ca344f..0000000000000000000000000000000000000000 --- a/docs/cpu/Documentation/doc/intstall.md +++ /dev/null @@ -1,18 +0,0 @@ -# Installation {#installation} -## Step 1: CMake -Download and install [CMake](http://www.cmake.org). -If you have Windows OS oder X-Windows for Linux/Unix start *cmake-gui*. -If you work in terminal start *ccmake*. -## Step 2: project configuration -You need set a path for *VirtualFluids* source code. It is allays *source* directory at the end of path. -E.g. *c:/vf/source*. You need also set a path to build binaries. E.g. *c:/vf/bin*. If you click **Configure** button start a project wizard and you can choose a compiler. -Set **Grouped** and **Advanced** check boxes in CMake. In the group *USE* you have follow important options: -* USE_BOND - using an agent based communication framework for fault tolerance BOND -* USE_METIS - using a domain decomposition tool METIS -* USE_MPI - using MPI for distributed memory parallelization -* USE_YAML - using YAML -* USE_ZOLTAN - using domain decomposition tool ZOLTAN - -There are externals library and you need additionally compile them. -## Step 4: project compilation -Compile you project with suitable compiler \ No newline at end of file diff --git a/docs/cpu/Documentation/doc/main.md b/docs/cpu/Documentation/doc/main.md deleted file mode 100644 index 1b04aeb7f44f4c80bbe71e6f839b90850dfca222..0000000000000000000000000000000000000000 --- a/docs/cpu/Documentation/doc/main.md +++ /dev/null @@ -1,11 +0,0 @@ -# Introduction {#mainpage} - -## Introduction -*VirtualFluids* is an adaptive, parallel Lattice-Boltzmann flow solver -which is comprised of various cores -and use second order accurate compact interpolation at the interfaces, -coupling grids of different resolutions. -The software framework is based on object-oriented technology and uses tree-like data structures. -These data structures are also suitable for hierarchical parallelization using a combination of PThreads and MPI and dynamic load balancing. - -[Installation](md__d_1__projects__virtual_fluids_source__documentation_doc_intstall.html) diff --git a/docs/cpu/Documentation/doxygen/logo.png b/docs/cpu/Documentation/doxygen/logo.png deleted file mode 100644 index 61253fbec8bf6a1617f19f8629de5ebc4f0f02e6..0000000000000000000000000000000000000000 Binary files a/docs/cpu/Documentation/doxygen/logo.png and /dev/null differ diff --git a/docs/cpu/Documentation/doxygen/start.html b/docs/cpu/Documentation/doxygen/start.html deleted file mode 100644 index 215fb59dc23071c4001359ff551109c8232b33d4..0000000000000000000000000000000000000000 --- a/docs/cpu/Documentation/doxygen/start.html +++ /dev/null @@ -1 +0,0 @@ -<meta http-equiv="refresh" content="0; URL=html/index.html"> \ No newline at end of file diff --git a/gpu.cmake b/gpu.cmake index b982a1abf933a241e81bea71865184764f847311..ead5e26bca299819513e4f7639d5431d8973c927 100644 --- a/gpu.cmake +++ b/gpu.cmake @@ -1,5 +1,3 @@ - - if(BUILD_NUMERIC_TESTS) set(CMAKE_CXX_STANDARD 17) endif() @@ -40,9 +38,11 @@ IF (BUILD_VF_GPU) #add_subdirectory(targets/apps/LBM/BaselMultiGPU) add_subdirectory(apps/gpu/LBM/DrivenCavity) + add_subdirectory(apps/gpu/LBM/WTG_RUB) #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/ActuatorLine) ELSE() MESSAGE( STATUS "exclude Virtual Fluids GPU." ) ENDIF() @@ -136,4 +136,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/metadata.xml b/metadata.xml new file mode 100644 index 0000000000000000000000000000000000000000..7cbae3ae7e1d5d7d48af2f0e5577253a89f953f5 --- /dev/null +++ b/metadata.xml @@ -0,0 +1,204 @@ +<?xml version="1.0" encoding="UTF-8"?> +<resource xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://datacite.org/schema/kernel-4" xsi:schemaLocation="http://datacite.org/schema/kernel-4 http://schema.datacite.org/meta/kernel-4.3/metadata.xsd"> + <identifier identifierType="DOI">PLACEHOLDER</identifier> + <titles> + <title xml:lang="en">VirtualFluids</title> + </titles> + <language>en</language> + <creators> + <creator> + <creatorName nameType="Personal">Krafczyk, Manfred</creatorName> + <givenName>Manfred</givenName> + <familyName>Krafczyk</familyName> + <nameIdentifier nameIdentifierScheme="ORCID">0000-0002-8509-0871</nameIdentifier> + <affiliation xml:lang="de">TU Braunschweig</affiliation> + <affiliation xml:lang="de">Institut für rechnergestützte Modellierung im Bauingenieurwesen</affiliation> + </creator> + <creator> + <creatorName nameType="Organizational">Institut für rechnergestützte Modellierung im Bauingenieurwesen</creatorName> + <affiliation xml:lang="de">TU Braunschweig</affiliation> + </creator> + </creators> + <publisher xml:lang="de">Institut für rechnergestützte Modellierung im Bauingenieurwesen</publisher> + <publicationYear>2021</publicationYear> + <resourceType resourceTypeGeneral="Software">Computational Fluid Dynamics Solver</resourceType> + <subjects> + <subject subjectScheme="DDC" schemeURI="https://www.oclc.org/en/dewey.html">532 Fluid Mechanics, liquid mechanics</subject> + </subjects> + <contributors> + <contributor contributorType="Researcher"> + <contributorName>Ahrenholz, Benjamin</contributorName> + <givenName>Benjamin</givenName> + <familyName>Ahrenholz</familyName> + </contributor> + + <contributor contributorType="Researcher"> + <contributorName>Alihussein, Hussein</contributorName> + <givenName>Hussein</givenName> + <familyName>Alihussein</familyName> + <nameIdentifier nameIdentifierScheme="ORCID" schemeURI="http://orcid.org/">0000-0003-3656-7028</nameIdentifier> + <affiliation xml:lang="de">TU Braunschweig</affiliation> + <affiliation xml:lang="en">Institut für rechnergestützte Modellierung im Bauingenieurwesen</affiliation> + </contributor> + + <contributor contributorType="Researcher"> + <contributorName>Bindick, Sebastian</contributorName> + <givenName>Sebastian</givenName> + <familyName>Bindick</familyName> + </contributor> + + <contributor contributorType="Researcher"> + <contributorName>Brendel, Aileen</contributorName> + <givenName>Aileen</givenName> + <familyName>Brendel</familyName> + </contributor> + + <contributor contributorType="Researcher"> + <contributorName>Geier, Martin</contributorName> + <givenName>Martin</givenName> + <familyName>Geier</familyName> + <nameIdentifier nameIdentifierScheme="ORCID" schemeURI="http://orcid.org/">0000-0002-8367-9412</nameIdentifier> + <affiliation xml:lang="de">TU Braunschweig</affiliation> + <affiliation xml:lang="en">Institut für rechnergestützte Modellierung im Bauingenieurwesen</affiliation> + </contributor> + + <contributor contributorType="Researcher"> + <contributorName>Geller, Sebastian</contributorName> + <givenName>Sebastian</givenName> + <familyName>Geller</familyName> + </contributor> + + <contributor contributorType="Researcher"> + <contributorName>Goraki Fard, Ehsan</contributorName> + <givenName>Ehsan</givenName> + <familyName>Goraki Fard</familyName> + </contributor> + + <contributor contributorType="Researcher"> + <contributorName>Hegewald, Jan</contributorName> + <givenName>Jan</givenName> + <familyName>Hegewald</familyName> + </contributor> + + <contributor contributorType="Researcher"> + <contributorName>Janßen, Christian</contributorName> + <givenName>Christian</givenName> + <familyName>Janßen</familyName> + </contributor> + + <contributor contributorType="Researcher"> + <contributorName>Kutscher, Konstantin</contributorName> + <givenName>Konstantin</givenName> + <familyName>Kutscher</familyName> + <nameIdentifier nameIdentifierScheme="ORCID" schemeURI="http://orcid.org/">0000-0002-1099-1608</nameIdentifier> + <affiliation xml:lang="de">TU Braunschweig</affiliation> + <affiliation xml:lang="en">Institut für rechnergestützte Modellierung im Bauingenieurwesen</affiliation> + </contributor> + + <contributor contributorType="Researcher"> + <contributorName>Lenz, Stephan</contributorName> + <givenName>Stephan</givenName> + <familyName>Lenz</familyName> + </contributor> + + <contributor contributorType="Researcher"> + <contributorName>Linxweiler, Jan</contributorName> + <givenName>Jan</givenName> + <familyName>Linxweiler</familyName> + <nameIdentifier nameIdentifierScheme="ORCID" schemeURI="http://orcid.org/">0000-0002-2755-5087</nameIdentifier> + <affiliation xml:lang="de">TU Braunschweig</affiliation> + <affiliation xml:lang="en">Institut für rechnergestützte Modellierung im Bauingenieurwesen</affiliation> + </contributor> + + <contributor contributorType="Researcher"> + <contributorName>Lux, Lennard</contributorName> + <givenName>Lennard</givenName> + <familyName>Lux</familyName> + </contributor> + + <contributor contributorType="Researcher"> + <contributorName>Marcus, Sven</contributorName> + <givenName>Sven</givenName> + <familyName>Marcus</familyName> + <nameIdentifier nameIdentifierScheme="ORCID" schemeURI="http://orcid.org/">0000-0003-3689-2162</nameIdentifier> + <affiliation xml:lang="de">TU Braunschweig</affiliation> + <affiliation xml:lang="en">Universitätsbibliothek Braunschweig</affiliation> + </contributor> + + <contributor contributorType="Researcher"> + <contributorName>Peters, Sören</contributorName> + <givenName>Sören</givenName> + <familyName>Peters</familyName> + <affiliation xml:lang="de">TU Braunschweig</affiliation> + <affiliation xml:lang="en">Institut für rechnergestützte Modellierung im Bauingenieurwesen</affiliation> + </contributor> + + <contributor contributorType="Researcher"> + <contributorName>Safari, Hesameddin</contributorName> + <givenName>Hesameddin</givenName> + <familyName>Safari</familyName> + </contributor> + + <contributor contributorType="Researcher"> + <contributorName>Schönherr, Martin</contributorName> + <givenName>Martin</givenName> + <familyName>Schönherr</familyName> + <nameIdentifier nameIdentifierScheme="ORCID" schemeURI="http://orcid.org/">0000-0002-4774-1776</nameIdentifier> + <affiliation xml:lang="de">TU Braunschweig</affiliation> + <affiliation xml:lang="en">Institut für rechnergestützte Modellierung im Bauingenieurwesen</affiliation> + </contributor> + + <contributor contributorType="Researcher"> + <contributorName>Stiebler, Maik</contributorName> + <givenName>Maik</givenName> + <familyName>Stiebler</familyName> + </contributor> + + <contributor contributorType="Researcher"> + <contributorName>Textor, Sören</contributorName> + <givenName>Sören</givenName> + <familyName>Textor</familyName> + </contributor> + + <contributor contributorType="Researcher"> + <contributorName>Tölke, Jonas</contributorName> + <givenName>Jonas</givenName> + <familyName>Tölke</familyName> + </contributor> + + <contributor contributorType="Researcher"> + <contributorName>Uphoff, Sonja</contributorName> + <givenName>Sonja</givenName> + <familyName>Uphoff</familyName> + </contributor> + + <contributor contributorType="Researcher"> + <contributorName>Wellmann, Anna</contributorName> + <givenName>Anna</givenName> + <familyName>Wellmann</familyName> + </contributor> + </contributors> + <dates> + <date dateType="Created">2000</date> + </dates> + <formats> + <format>text/x-c</format> + <format>text/x-h</format> + <format>text/x-script.python</format> + </formats> + <relatedIdentifiers> + <relatedIdentifier relatedIdentifierType="URL" relationType="Requires" resourceTypeGeneral="Software">https://www.open-mpi.org/software/ompi/v4.1/</relatedIdentifier> + <relatedIdentifier relatedIdentifierType="URL" relationType="IsCompiledBy" resourceTypeGeneral="Software">https://cmake.org</relatedIdentifier> + <relatedIdentifier relatedIdentifierType="URL" relationType="IsCompiledBy" resourceTypeGeneral="Software">https://gcc.gnu.org</relatedIdentifier> + <relatedIdentifier relatedIdentifierType="URL" relationType="IsCompiledBy" resourceTypeGeneral="Software">https://clang.llvm.org</relatedIdentifier> + <relatedIdentifier relatedIdentifierType="URL" relationType="IsCompiledBy" resourceTypeGeneral="Software">https://visualstudio.microsoft.com/vs/features/cplusplus/</relatedIdentifier> + </relatedIdentifiers> + <rightsList> + <rights xml:lang="en" schemeURI="https://spdx.org/licenses/" rightsIdentifierScheme="SPDX" rightsIdentifier="GPL-3.0-only" rightsURI="https://www.gnu.org/licenses/gpl-3.0-standalone.html">GNU General Public License Version 3</rights> + </rightsList> + <descriptions> + <description descriptionType="Abstract"> + 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. + </description> + </descriptions> +</resource> diff --git a/setup.py b/setup.py index 6f4ff71b014dbafa8800af234cf715f5207fb2a8..ffe6663be9561a209945b91bb396254b703ae892 100644 --- a/setup.py +++ b/setup.py @@ -10,11 +10,17 @@ from distutils.version import LooseVersion 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_VF_UNIT_TESTS:BOOL=ON", + "-DBUILD_WARNINGS_AS_ERRORS=OFF" ] diff --git a/sonar-project.properties b/sonar-project.properties index 7f31fa97101d3002aa47096831206cf9768a85b5..a25bb1af8070f0ea5b75f67e624211f38fef38bf 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -27,8 +27,6 @@ sonar.cxx.clangtidy.reportPath=build/clangtidy.txt sonar.cxx.jsonCompilationDatabase=build/compile_commands.json -sonar.cxx.gcc.reportPath=build/gcc_warnings.txt - #sonar.cxx.valgrind.reportPath sonar.cxx.funccomplexity.threshold=10 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/Input/ConfigData/ConfigData.h b/src/basics/Core/Input/ConfigData/ConfigData.h deleted file mode 100644 index 44d50557608817bff889ba9aa4316861d8ce2bca..0000000000000000000000000000000000000000 --- a/src/basics/Core/Input/ConfigData/ConfigData.h +++ /dev/null @@ -1,185 +0,0 @@ -#ifndef CONFIGDATA_H -#define CONFIGDATA_H - -#include "../../DataTypes.h" - -#include <memory> -#include <vector> - -class ConfigData -{ -public: - virtual ~ConfigData() = default; - - virtual real getViscosity() = 0; - virtual uint getNumberOfDevices() = 0; - virtual std::vector<uint> getDevices() = 0; - virtual std::string getOutputPath() = 0; - virtual std::string getPrefix() = 0; - virtual std::string getGridPath() = 0; - virtual bool getPrintOutputFiles() = 0; - virtual bool getGeometryValues() = 0; - virtual bool getCalc2ndOrderMoments() = 0; - virtual bool getCalc3rdOrderMoments() = 0; - virtual bool getCalcHighOrderMoments() = 0; - virtual bool getReadGeo() = 0; - virtual bool getCalcMedian() = 0; - virtual bool getCalcDragLift() = 0; - virtual bool getCalcCp() = 0; - virtual bool getWriteVeloASCIIfiles() = 0; - virtual bool getCalcPlaneConc() = 0; - virtual bool getConcFile() = 0; - virtual bool getStreetVelocityFile() = 0; - virtual bool getUseMeasurePoints() = 0; - virtual bool getUseWale() = 0; - virtual bool getUseInitNeq() = 0; - virtual bool getSimulatePorousMedia() = 0; - virtual uint getD3Qxx() = 0; - virtual uint getTEnd() = 0; - virtual uint getTOut() = 0; - virtual uint getTStartOut() = 0; - virtual uint getTimeCalcMedStart() = 0; - virtual uint getTimeCalcMedEnd() = 0; - virtual uint getPressInID() = 0; - virtual uint getPressOutID() = 0; - virtual uint getPressInZ() = 0; - virtual uint getPressOutZ() = 0; - virtual bool getDiffOn() = 0; - virtual uint getDiffMod() = 0; - virtual real getDiffusivity() = 0; - virtual real getTemperatureInit() = 0; - virtual real getTemperatureBC() = 0; - virtual real getVelocity() = 0; - virtual real getViscosityRatio() = 0; - virtual real getVelocityRatio() = 0; - virtual real getDensityRatio() = 0; - virtual real getPressRatio() = 0; - virtual real getRealX() = 0; - virtual real getRealY() = 0; - virtual real getFactorPressBC() = 0; - virtual std::string getGeometryFileC() = 0; - virtual std::string getGeometryFileM() = 0; - virtual std::string getGeometryFileF() = 0; - virtual uint getClockCycleForMP() = 0; - virtual uint getTimestepForMP() = 0; - virtual real getForcingX() = 0; - virtual real getForcingY() = 0; - virtual real getForcingZ() = 0; - virtual real getQuadricLimiterP() = 0; - virtual real getQuadricLimiterM() = 0; - virtual real getQuadricLimiterD() = 0; - virtual bool getCalcParticles() = 0; - virtual int getParticleBasicLevel() = 0; - virtual int getParticleInitLevel() = 0; - virtual int getNumberOfParticles() = 0; - virtual real getStartXHotWall() = 0; - virtual real getEndXHotWall() = 0; - virtual std::vector<std::string> getPossNeighborFilesX() = 0; - virtual std::vector<std::string> getPossNeighborFilesY() = 0; - virtual std::vector<std::string> getPossNeighborFilesZ() = 0; - // virtual std::vector<std::string> getPossNeighborFilesX() = 0; - // virtual std::vector<std::string> getPossNeighborFilesY() = 0; - // virtual std::vector<std::string> getPossNeighborFilesZ() = 0; - virtual int getTimeDoCheckPoint() = 0; - virtual int getTimeDoRestart() = 0; - virtual bool getDoCheckPoint() = 0; - virtual bool getDoRestart() = 0; - virtual uint getMaxLevel() = 0; - virtual std::vector<int> getGridX() = 0; - virtual std::vector<int> getGridY() = 0; - virtual std::vector<int> getGridZ() = 0; - virtual std::vector<int> getDistX() = 0; - virtual std::vector<int> getDistY() = 0; - virtual std::vector<int> getDistZ() = 0; - virtual std::vector<bool> getNeedInterface() = 0; - virtual std::string getMainKernel() = 0; - virtual bool getMultiKernelOn() = 0; - virtual std::vector<int> getMultiKernelLevel() = 0; - virtual std::vector<std::string> getMultiKernelName() = 0; - - virtual bool isViscosityInConfigFile() = 0; - virtual bool isNumberOfDevicesInConfigFile() = 0; - virtual bool isDevicesInConfigFile() = 0; - virtual bool isOutputPathInConfigFile() = 0; - virtual bool isPrefixInConfigFile() = 0; - virtual bool isGridPathInConfigFile() = 0; - virtual bool isPrintOutputFilesInConfigFile() = 0; - virtual bool isGeometryValuesInConfigFile() = 0; - virtual bool isCalc2ndOrderMomentsInConfigFile() = 0; - virtual bool isCalc3rdOrderMomentsInConfigFile() = 0; - virtual bool isCalcHighOrderMomentsInConfigFile() = 0; - virtual bool isReadGeoInConfigFile() = 0; - virtual bool isCalcMedianInConfigFile() = 0; - virtual bool isCalcDragLiftInConfigFile() = 0; - virtual bool isCalcCpInConfigFile() = 0; - virtual bool isWriteVeloASCIIfilesInConfigFile() = 0; - virtual bool isCalcPlaneConcInConfigFile() = 0; - virtual bool isConcFileInConfigFile() = 0; - virtual bool isStreetVelocityFileInConfigFile() = 0; - virtual bool isUseMeasurePointsInConfigFile() = 0; - virtual bool isUseWaleInConfigFile() = 0; - virtual bool isUseInitNeqInConfigFile() = 0; - virtual bool isSimulatePorousMediaInConfigFile() = 0; - virtual bool isD3QxxInConfigFile() = 0; - virtual bool isTEndInConfigFile() = 0; - virtual bool isTOutInConfigFile() = 0; - virtual bool isTStartOutInConfigFile() = 0; - virtual bool isTimeCalcMedStartInConfigFile() = 0; - virtual bool isTimeCalcMedEndInConfigFile() = 0; - virtual bool isPressInIDInConfigFile() = 0; - virtual bool isPressOutIDInConfigFile() = 0; - virtual bool isPressInZInConfigFile() = 0; - virtual bool isPressOutZInConfigFile() = 0; - virtual bool isDiffOnInConfigFile() = 0; - virtual bool isDiffModInConfigFile() = 0; - virtual bool isDiffusivityInConfigFile() = 0; - virtual bool isTemperatureInitInConfigFile() = 0; - virtual bool isTemperatureBCInConfigFile() = 0; - // virtual bool isViscosityInConfigFile() = 0; - virtual bool isVelocityInConfigFile() = 0; - virtual bool isViscosityRatioInConfigFile() = 0; - virtual bool isVelocityRatioInConfigFile() = 0; - virtual bool isDensityRatioInConfigFile() = 0; - virtual bool isPressRatioInConfigFile() = 0; - virtual bool isRealXInConfigFile() = 0; - virtual bool isRealYInConfigFile() = 0; - virtual bool isFactorPressBCInConfigFile() = 0; - virtual bool isGeometryFileCInConfigFile() = 0; - virtual bool isGeometryFileMInConfigFile() = 0; - virtual bool isGeometryFileFInConfigFile() = 0; - virtual bool isClockCycleForMPInConfigFile() = 0; - virtual bool isTimestepForMPInConfigFile() = 0; - virtual bool isForcingXInConfigFile() = 0; - virtual bool isForcingYInConfigFile() = 0; - virtual bool isForcingZInConfigFile() = 0; - virtual bool isQuadricLimiterPInConfigFile() = 0; - virtual bool isQuadricLimiterMInConfigFile() = 0; - virtual bool isQuadricLimiterDInConfigFile() = 0; - virtual bool isCalcParticlesInConfigFile() = 0; - virtual bool isParticleBasicLevelInConfigFile() = 0; - virtual bool isParticleInitLevelInConfigFile() = 0; - virtual bool isNumberOfParticlesInConfigFile() = 0; - virtual bool isNeighborWSBInConfigFile() = 0; - virtual bool isStartXHotWallInConfigFile() = 0; - virtual bool isEndXHotWallInConfigFile() = 0; - virtual bool isPossNeighborFilesXInConfigFile() = 0; - virtual bool isPossNeighborFilesYInConfigFile() = 0; - virtual bool isPossNeighborFilesZInConfigFile() = 0; - virtual bool isTimeDoCheckPointInConfigFile() = 0; - virtual bool isTimeDoRestartInConfigFile() = 0; - virtual bool isDoCheckPointInConfigFile() = 0; - virtual bool isDoRestartInConfigFile() = 0; - virtual bool isMaxLevelInConfigFile() = 0; - virtual bool isGridXInConfigFile() = 0; - virtual bool isGridYInConfigFile() = 0; - virtual bool isGridZInConfigFile() = 0; - virtual bool isDistXInConfigFile() = 0; - virtual bool isDistYInConfigFile() = 0; - virtual bool isDistZInConfigFile() = 0; - virtual bool isNeedInterfaceInConfigFile() = 0; - virtual bool isMainKernelInConfigFile() = 0; - virtual bool isMultiKernelOnInConfigFile() = 0; - virtual bool isMultiKernelLevelInConfigFile() = 0; - virtual bool isMultiKernelNameInConfigFile() = 0; -}; -#endif diff --git a/src/basics/Core/Input/ConfigData/ConfigDataImp.cpp b/src/basics/Core/Input/ConfigData/ConfigDataImp.cpp deleted file mode 100644 index 0c53b32829eb989667b93fc7df156525267e930b..0000000000000000000000000000000000000000 --- a/src/basics/Core/Input/ConfigData/ConfigDataImp.cpp +++ /dev/null @@ -1,834 +0,0 @@ -#include "ConfigDataImp.h" - -std::shared_ptr<ConfigDataImp> ConfigDataImp::getNewInstance() -{ - return std::shared_ptr<ConfigDataImp>(new ConfigDataImp()); -} - -real ConfigDataImp::getViscosity() { return this->viscosity; } - -uint ConfigDataImp::getNumberOfDevices() { return this->numberOfDevices; } - -std::vector<uint> ConfigDataImp::getDevices() { return this->devices; } - -std::string ConfigDataImp::getOutputPath() { return this->outputPath; } - -std::string ConfigDataImp::getPrefix() { return this->prefix; } - -std::string ConfigDataImp::getGridPath() { return this->gridPath; } - -bool ConfigDataImp::getPrintOutputFiles() { return this->printOutputFiles; } - -bool ConfigDataImp::getGeometryValues() { return this->geometryValues; } - -bool ConfigDataImp::getCalc2ndOrderMoments() { return this->calc2ndOrderMoments; } - -bool ConfigDataImp::getCalc3rdOrderMoments() { return this->calc3rdOrderMoments; } - -bool ConfigDataImp::getCalcHighOrderMoments() { return this->calcHighOrderMoments; } - -bool ConfigDataImp::getReadGeo() { return this->readGeo; } - -bool ConfigDataImp::getCalcMedian() { return this->calcMedian; } - -bool ConfigDataImp::getCalcDragLift() { return this->calcDragLift; } - -bool ConfigDataImp::getCalcCp() { return this->calcCp; } - -bool ConfigDataImp::getWriteVeloASCIIfiles() { return this->writeVeloASCIIfiles; } - -bool ConfigDataImp::getCalcPlaneConc() { return this->calcPlaneConc; } - -bool ConfigDataImp::getConcFile() { return this->concFile; } - -bool ConfigDataImp::getStreetVelocityFile() { return this->streetVelocityFile; } - -bool ConfigDataImp::getUseMeasurePoints() { return this->useMeasurePoints; } - -bool ConfigDataImp::getUseWale() { return this->useWale; } - -bool ConfigDataImp::getUseInitNeq() { return this->useInitNeq; } - -bool ConfigDataImp::getSimulatePorousMedia() { return this->simulatePorousMedia; } - -uint ConfigDataImp::getD3Qxx() { return this->d3Qxx; } - -uint ConfigDataImp::getTEnd() { return this->tEnd; } - -uint ConfigDataImp::getTOut() { return this->tOut; } - -uint ConfigDataImp::getTStartOut() { return this->tStartOut; } - -uint ConfigDataImp::getTimeCalcMedStart() { return this->timeCalcMedStart; } - -uint ConfigDataImp::getTimeCalcMedEnd() { return this->timeCalcMedEnd; } - -uint ConfigDataImp::getPressInID() { return this->pressInID; } - -uint ConfigDataImp::getPressOutID() { return this->pressOutID; } - -uint ConfigDataImp::getPressInZ() { return this->pressInZ; } - -uint ConfigDataImp::getPressOutZ() { return this->pressOutZ; } - -bool ConfigDataImp::getDiffOn() { return this->diffOn; } - -uint ConfigDataImp::getDiffMod() { return this->diffMod; } - -real ConfigDataImp::getDiffusivity() { return this->diffusivity; } - -real ConfigDataImp::getTemperatureInit() { return this->temperatureInit; } - -real ConfigDataImp::getTemperatureBC() { return this->temperatureBC; } - -real ConfigDataImp::getVelocity() { return this->velocity; } - -real ConfigDataImp::getViscosityRatio() { return this->viscosityRatio; } - -real ConfigDataImp::getVelocityRatio() { return this->velocityRatio; } - -real ConfigDataImp::getDensityRatio() { return this->densityRatio; } - -real ConfigDataImp::getPressRatio() { return this->pressRatio; } - -real ConfigDataImp::getRealX() { return this->realX; } - -real ConfigDataImp::getRealY() { return this->realY; } - -real ConfigDataImp::getFactorPressBC() { return this->factorPressBC; } - -std::string ConfigDataImp::getGeometryFileC() { return this->geometryFileC; } - -std::string ConfigDataImp::getGeometryFileM() { return this->geometryFileM; } - -std::string ConfigDataImp::getGeometryFileF() { return this->geometryFileF; } - -uint ConfigDataImp::getClockCycleForMP() { return this->clockCycleForMP; } - -uint ConfigDataImp::getTimestepForMP() { return this->timestepForMP; } - -real ConfigDataImp::getForcingX() { return this->forcingX; } - -real ConfigDataImp::getForcingY() { return this->forcingY; } - -real ConfigDataImp::getForcingZ() { return this->forcingZ; } - -real ConfigDataImp::getQuadricLimiterP() { return this->quadricLimiterP; } - -real ConfigDataImp::getQuadricLimiterM() { return this->quadricLimiterM; } - -real ConfigDataImp::getQuadricLimiterD() { return this->quadricLimiterD; } - -bool ConfigDataImp::getCalcParticles() { return this->calcParticles; } - -int ConfigDataImp::getParticleBasicLevel() { return this->particleBasicLevel; } - -int ConfigDataImp::getParticleInitLevel() { return this->particleInitLevel; } - -int ConfigDataImp::getNumberOfParticles() { return this->numberOfParticles; } - -real ConfigDataImp::getStartXHotWall() { return this->startXHotWall; } - -real ConfigDataImp::getEndXHotWall() { return this->endXHotWall; } - -std::vector<std::string> ConfigDataImp::getPossNeighborFilesX() { return this->possNeighborFilesX; } - -std::vector<std::string> ConfigDataImp::getPossNeighborFilesY() { return this->possNeighborFilesY; } - -std::vector<std::string> ConfigDataImp::getPossNeighborFilesZ() { return this->possNeighborFilesZ; } - -int ConfigDataImp::getTimeDoCheckPoint() { return this->timeDoCheckPoint; } - -int ConfigDataImp::getTimeDoRestart() { return this->timeDoRestart; } - -bool ConfigDataImp::getDoCheckPoint() { return this->doCheckPoint; } - -bool ConfigDataImp::getDoRestart() { return this->doRestart; } - -uint ConfigDataImp::getMaxLevel() { return this->maxLevel; } - -std::vector<int> ConfigDataImp::getGridX() { return this->gridX; } - -std::vector<int> ConfigDataImp::getGridY() { return this->gridY; } - -std::vector<int> ConfigDataImp::getGridZ() { return this->gridZ; } - -std::vector<int> ConfigDataImp::getDistX() { return this->distX; } - -std::vector<int> ConfigDataImp::getDistY() { return this->distY; } - -std::vector<int> ConfigDataImp::getDistZ() { return this->distZ; } - -std::vector<bool> ConfigDataImp::getNeedInterface() { return this->needInterface; } - -std::string ConfigDataImp::getMainKernel() { return this->mainKernel; } - -bool ConfigDataImp::getMultiKernelOn() { return this->multiKernelOn; } - -std::vector<int> ConfigDataImp::getMultiKernelLevel() { return this->multiKernelLevel; } - -std::vector<std::string> ConfigDataImp::getMultiKernelName() { return this->multiKernelName; } - -void ConfigDataImp::setViscosity(real viscosity) -{ - this->viscosity = viscosity; - this->isViscosity = true; -} - -void ConfigDataImp::setNumberOfDevices(uint numberOfDevices) -{ - this->numberOfDevices = numberOfDevices; - this->isNumberOfDevices = true; -} - -void ConfigDataImp::setDevices(std::vector<uint> devices) -{ - this->devices = devices; - this->isDevices = true; -} - -void ConfigDataImp::setOutputPath(std::string outputPath) -{ - this->outputPath = outputPath; - this->isOutputPath = true; -} - -void ConfigDataImp::setPrefix(std::string prefix) -{ - this->prefix = prefix; - this->isPrefix = true; -} - -void ConfigDataImp::setGridPath(std::string gridPath) -{ - this->gridPath = gridPath; - this->isGridPath = true; -} - -void ConfigDataImp::setPrintOutputFiles(bool printOutputFiles) -{ - this->printOutputFiles = printOutputFiles; - this->isPrintOutputFiles = true; -} - -void ConfigDataImp::setGeometryValues(bool geometryValues) -{ - this->geometryValues = geometryValues; - this->isGeometryValues = true; -} - -void ConfigDataImp::setCalc2ndOrderMoments(bool calc2ndOrderMoments) -{ - this->calc2ndOrderMoments = calc2ndOrderMoments; - this->isCalc2ndOrderMoments = true; -} - -void ConfigDataImp::setCalc3rdOrderMoments(bool calc3rdOrderMoments) -{ - this->calc3rdOrderMoments = calc3rdOrderMoments; - this->isCalc3rdOrderMoments = true; -} - -void ConfigDataImp::setCalcHighOrderMoments(bool calcHighOrderMoments) -{ - this->calcHighOrderMoments = calcHighOrderMoments; - this->isCalcHighOrderMoments = true; -} - -void ConfigDataImp::setReadGeo(bool readGeo) -{ - this->readGeo = readGeo; - this->isReadGeo = true; -} - -void ConfigDataImp::setCalcMedian(bool calcMedian) -{ - this->calcMedian = calcMedian; - this->isCalcMedian = true; -} - -void ConfigDataImp::setCalcDragLift(bool calcDragLift) -{ - this->calcDragLift = calcDragLift; - this->isCalcDragLift = true; -} - -void ConfigDataImp::setCalcCp(bool calcCp) -{ - this->calcCp = calcCp; - this->isCalcCp = true; -} - -void ConfigDataImp::setWriteVeloASCIIfiles(bool writeVeloASCIIfiles) -{ - this->writeVeloASCIIfiles = writeVeloASCIIfiles; - this->isWriteVeloASCII = true; -} - -void ConfigDataImp::setCalcPlaneConc(bool calcPlaneConc) -{ - this->calcPlaneConc = calcPlaneConc; - this->isCalcPlaneConc = true; -} - -void ConfigDataImp::setConcFile(bool concFile) -{ - this->concFile = concFile; - this->isConcFile = true; -} - -void ConfigDataImp::setStreetVelocityFile(bool streetVelocityFile) -{ - this->streetVelocityFile = streetVelocityFile; - this->isStreetVelocityFile = true; -} - -void ConfigDataImp::setUseMeasurePoints(bool useMeasurePoints) -{ - this->useMeasurePoints = useMeasurePoints; - this->isUseMeasurePoints = true; -} - -void ConfigDataImp::setUseWale(bool useWale) -{ - this->useWale = useWale; - this->isUseWale = true; -} - -void ConfigDataImp::setUseInitNeq(bool useInitNeq) -{ - this->useInitNeq = useInitNeq; - this->isUseInitNeq = true; -} - -void ConfigDataImp::setSimulatePorousMedia(bool simulatePorousMedia) -{ - this->simulatePorousMedia = simulatePorousMedia; - this->isSimulatePorousMedia = true; -} - -void ConfigDataImp::setD3Qxx(uint d3Qxx) -{ - this->d3Qxx = d3Qxx; - this->isD3Qxx = true; -} - -void ConfigDataImp::setTEnd(uint tEnd) -{ - this->tEnd = tEnd; - this->isTEnd = true; -} - -void ConfigDataImp::setTOut(uint tOut) -{ - this->tOut = tOut; - this->isTOut = true; -} - -void ConfigDataImp::setTStartOut(uint tStartOut) -{ - this->tStartOut = tStartOut; - this->isTStartOut = true; -} - -void ConfigDataImp::setTimeCalcMedStart(uint timeCalcMedStart) -{ - this->timeCalcMedStart = timeCalcMedStart; - this->isTimeCalcMedStart = true; -} - -void ConfigDataImp::setTimeCalcMedEnd(uint timeCalcMedEnd) -{ - this->timeCalcMedEnd = timeCalcMedEnd; - this->isTimeCalcMedEnd = true; -} - -void ConfigDataImp::setPressInID(uint pressInID) -{ - this->pressInID = pressInID; - this->isPressInID = true; -} - -void ConfigDataImp::setPressOutID(uint pressOutID) -{ - this->pressOutID = pressOutID; - this->isPressOutID = true; -} - -void ConfigDataImp::setPressInZ(uint pressInZ) -{ - this->pressInZ = pressInZ; - this->isPressInZ = true; -} - -void ConfigDataImp::setPressOutZ(uint pressOutZ) -{ - this->pressOutZ = pressOutZ; - this->isPressOutZ = true; -} - -void ConfigDataImp::setDiffOn(bool diffOn) -{ - this->diffOn = diffOn; - this->isDiffOn = true; -} - -void ConfigDataImp::setDiffMod(uint diffMod) -{ - this->diffMod = diffMod; - this->isDiffMod = true; -} - -void ConfigDataImp::setDiffusivity(real diffusivity) -{ - this->diffusivity = diffusivity; - this->isDiffusivity = true; -} - -void ConfigDataImp::setTemperatureInit(real temperatureInit) -{ - this->temperatureInit = temperatureInit; - this->isTemperatureInit = true; -} - -void ConfigDataImp::setTemperatureBC(real temperatureBC) -{ - this->temperatureBC = temperatureBC; - this->isTemperatureBC = true; -} - -// void ConfigDataImp::setViscosity(real viscosity) -//{ -// this->viscosity = viscosity; -// this->isViscosity = true; -//} - -void ConfigDataImp::setVelocity(real velocity) -{ - this->velocity = velocity; - this->isVelocity = true; -} - -void ConfigDataImp::setViscosityRatio(real viscosityRatio) -{ - this->viscosityRatio = viscosityRatio; - this->isViscosityRatio = true; -} - -void ConfigDataImp::setVelocityRatio(real velocityRatio) -{ - this->velocityRatio = velocityRatio; - this->isVelocityRatio = true; -} - -void ConfigDataImp::setDensityRatio(real densityRatio) -{ - this->densityRatio = densityRatio; - this->isDensityRatio = true; -} - -void ConfigDataImp::setPressRatio(real pressRatio) -{ - this->pressRatio = pressRatio; - this->isPressRatio = true; -} - -void ConfigDataImp::setRealX(real realX) -{ - this->realX = realX; - this->isRealX = true; -} - -void ConfigDataImp::setRealY(real realY) -{ - this->realY = realY; - this->isRealY = true; -} - -void ConfigDataImp::setFactorPressBC(real factorPressBC) -{ - this->factorPressBC = factorPressBC; - this->isFactorPressBC = true; -} - -void ConfigDataImp::setGeometryFileC(std::string geometryFileC) -{ - this->geometryFileC = geometryFileC; - this->isGeometryFileC = true; -} - -void ConfigDataImp::setGeometryFileM(std::string geometryFileM) -{ - this->geometryFileM = geometryFileM; - this->isGeometryFileM = true; -} - -void ConfigDataImp::setGeometryFileF(std::string geometryFileF) -{ - this->geometryFileF = geometryFileF; - this->isGeometryFileF = true; -} - -void ConfigDataImp::setClockCycleForMP(uint clockCycleForMP) -{ - this->clockCycleForMP = clockCycleForMP; - this->isClockCycleForMP = true; -} - -void ConfigDataImp::setTimestepForMP(uint timestepForMP) -{ - this->timestepForMP = timestepForMP; - this->isTimestepForMP = true; -} - -void ConfigDataImp::setForcingX(real forcingX) -{ - this->forcingX = forcingX; - this->isForcingX = true; -} - -void ConfigDataImp::setForcingY(real forcingY) -{ - this->forcingY = forcingY; - this->isForcingY = true; -} - -void ConfigDataImp::setForcingZ(real forcingZ) -{ - this->forcingZ = forcingZ; - this->isForcingZ = true; -} - -void ConfigDataImp::setQuadricLimiterP(real quadricLimiterP) -{ - this->quadricLimiterP = quadricLimiterP; - this->isQuadricLimiterP = true; -} - -void ConfigDataImp::setQuadricLimiterM(real quadricLimiterM) -{ - this->quadricLimiterM = quadricLimiterM; - this->isQuadricLimiterM = true; -} - -void ConfigDataImp::setQuadricLimiterD(real quadricLimiterD) -{ - this->quadricLimiterD = quadricLimiterD; - this->isQuadricLimiterD = true; -} - -void ConfigDataImp::setCalcParticles(bool calcParticles) -{ - this->calcParticles = calcParticles; - this->isCalcParticles = true; -} - -void ConfigDataImp::setParticleBasicLevel(int particleBasicLevel) -{ - this->particleBasicLevel = particleBasicLevel; - this->isParticleBasicLevel = true; -} - -void ConfigDataImp::setParticleInitLevel(int particleInitLevel) -{ - this->particleInitLevel = particleInitLevel; - this->isParticleInitLevel = true; -} - -void ConfigDataImp::setNumberOfParticles(int numberOfParticles) -{ - this->numberOfParticles = numberOfParticles; - this->isNumberOfParticles = true; -} - -void ConfigDataImp::setStartXHotWall(real startXHotWall) -{ - this->startXHotWall = startXHotWall; - this->isStartXHotWall = true; -} - -void ConfigDataImp::setEndXHotWall(real endXHotWall) -{ - this->endXHotWall = endXHotWall; - this->isEndXHotWall = true; -} - -void ConfigDataImp::setPossNeighborFilesX(const std::vector<std::string> &possNeighborFilesX) -{ - this->possNeighborFilesX = possNeighborFilesX; - this->isPossNeighborFilesX = true; -} - -void ConfigDataImp::setPossNeighborFilesY(const std::vector<std::string> &possNeighborFilesY) -{ - this->possNeighborFilesY = possNeighborFilesY; - this->isPossNeighborFilesY = true; -} - -void ConfigDataImp::setPossNeighborFilesZ(const std::vector<std::string> &possNeighborFilesZ) -{ - this->possNeighborFilesZ = possNeighborFilesZ; - this->isPossNeighborFilesZ = true; -} - -void ConfigDataImp::setTimeDoCheckPoint(int timeDoCheckPoint) -{ - this->timeDoCheckPoint = timeDoCheckPoint; - this->isTimeDoCheckPoint = true; -} - -void ConfigDataImp::setTimeDoRestart(int timeDoRestart) -{ - this->timeDoRestart = timeDoRestart; - this->isTimeDoRestart = true; -} - -void ConfigDataImp::setDoCheckPoint(bool doCheckPoint) -{ - this->doCheckPoint = doCheckPoint; - this->isDoCheckPoint = true; -} - -void ConfigDataImp::setDoRestart(bool doRestart) -{ - this->doRestart = doRestart; - this->isDoRestart = true; -} - -void ConfigDataImp::setMaxLevel(uint maxLevel) -{ - this->maxLevel = maxLevel; - this->isMaxLevel = true; -} - -void ConfigDataImp::setGridX(const std::vector<int> &gridX) -{ - this->gridX = gridX; - this->isGridX = true; -} - -void ConfigDataImp::setGridY(const std::vector<int> &gridY) -{ - this->gridY = gridY; - this->isGridY = true; -} - -void ConfigDataImp::setGridZ(const std::vector<int> &gridZ) -{ - this->gridZ = gridZ; - this->isGridZ = true; -} - -void ConfigDataImp::setDistX(const std::vector<int> &distX) -{ - this->distX = distX; - this->isDistX = true; -} - -void ConfigDataImp::setDistY(const std::vector<int> &distY) -{ - this->distY = distY; - this->isDistY = true; -} - -void ConfigDataImp::setDistZ(const std::vector<int> &distZ) -{ - this->distZ = distZ; - this->isDistZ = true; -} - -void ConfigDataImp::setNeedInterface(const std::vector<bool> &needInterface) -{ - this->needInterface = needInterface; - this->isNeedInterface = true; -} - -void ConfigDataImp::setMainKernel(const std::string &mainKernel) -{ - this->mainKernel = mainKernel; - this->isMainKernel = true; -} - -void ConfigDataImp::setMultiKernelOn(bool multiKernelOn) -{ - this->multiKernelOn = multiKernelOn; - this->isMultiKernelOn = true; -} - -void ConfigDataImp::setMultiKernelLevel(const std::vector<int> &multiKernelLevel) -{ - this->multiKernelLevel = multiKernelLevel; - this->isMultiKernelLevel = true; -} - -void ConfigDataImp::setMultiKernelName(const std::vector<std::string> &multiKernelName) -{ - this->multiKernelName = multiKernelName; - this->isMultiKernelName = true; -} - -bool ConfigDataImp::isCalc2ndOrderMomentsInConfigFile() { return this->isCalc2ndOrderMoments; } - -bool ConfigDataImp::isCalc3rdOrderMomentsInConfigFile() { return this->isCalc2ndOrderMoments; } - -bool ConfigDataImp::isCalcHighOrderMomentsInConfigFile() { return this->isCalcHighOrderMoments; } - -bool ConfigDataImp::isReadGeoInConfigFile() { return this->isReadGeo; } - -bool ConfigDataImp::isCalcMedianInConfigFile() { return this->isCalcMedian; } - -bool ConfigDataImp::isCalcDragLiftInConfigFile() { return this->isCalcDragLift; } - -bool ConfigDataImp::isCalcCpInConfigFile() { return this->isCalcCp; } - -bool ConfigDataImp::isWriteVeloASCIIfilesInConfigFile() { return this->isWriteVeloASCII; } - -bool ConfigDataImp::isCalcPlaneConcInConfigFile() { return this->isCalcPlaneConc; } - -bool ConfigDataImp::isConcFileInConfigFile() { return this->isConcFile; } - -bool ConfigDataImp::isStreetVelocityFileInConfigFile() { return this->isStreetVelocityFile; } - -bool ConfigDataImp::isUseMeasurePointsInConfigFile() { return this->isUseMeasurePoints; } - -bool ConfigDataImp::isUseWaleInConfigFile() { return this->isUseWale; } - -bool ConfigDataImp::isUseInitNeqInConfigFile() { return this->isUseInitNeq; } - -bool ConfigDataImp::isSimulatePorousMediaInConfigFile() { return this->isSimulatePorousMedia; } - -bool ConfigDataImp::isD3QxxInConfigFile() { return this->isD3Qxx; } - -bool ConfigDataImp::isTEndInConfigFile() { return this->isTEnd; } - -bool ConfigDataImp::isTOutInConfigFile() { return this->isTOut; } - -bool ConfigDataImp::isTStartOutInConfigFile() { return this->isTStartOut; } - -bool ConfigDataImp::isTimeCalcMedStartInConfigFile() { return this->isTimeCalcMedStart; } - -bool ConfigDataImp::isTimeCalcMedEndInConfigFile() { return this->isTimeCalcMedEnd; } - -bool ConfigDataImp::isPressInIDInConfigFile() { return this->isPressInID; } - -bool ConfigDataImp::isPressOutIDInConfigFile() { return this->isPressOutID; } - -bool ConfigDataImp::isPressInZInConfigFile() { return this->isPressInZ; } - -bool ConfigDataImp::isPressOutZInConfigFile() { return this->isPressOutZ; } - -bool ConfigDataImp::isDiffOnInConfigFile() { return this->isDiffOn; } - -bool ConfigDataImp::isDiffModInConfigFile() { return this->isDiffMod; } - -bool ConfigDataImp::isDiffusivityInConfigFile() { return this->isDiffusivity; } - -bool ConfigDataImp::isTemperatureInitInConfigFile() { return this->isTemperatureInit; } - -bool ConfigDataImp::isTemperatureBCInConfigFile() { return this->isTemperatureBC; } - -bool ConfigDataImp::isViscosityInConfigFile() { return this->isViscosity; } - -bool ConfigDataImp::isNumberOfDevicesInConfigFile() { return this->isNumberOfDevices; } - -bool ConfigDataImp::isDevicesInConfigFile() { return this->isDevices; } - -bool ConfigDataImp::isOutputPathInConfigFile() { return this->isOutputPath; } - -bool ConfigDataImp::isPrefixInConfigFile() { return this->isPrefix; } - -bool ConfigDataImp::isGridPathInConfigFile() { return this->isGridPath; } - -bool ConfigDataImp::isPrintOutputFilesInConfigFile() { return this->isPrintOutputFiles; } - -bool ConfigDataImp::isGeometryValuesInConfigFile() { return this->isGeometryValues; } - -bool ConfigDataImp::isVelocityInConfigFile() { return this->isVelocity; } - -bool ConfigDataImp::isViscosityRatioInConfigFile() { return this->isViscosityRatio; } - -bool ConfigDataImp::isVelocityRatioInConfigFile() { return this->isVelocityRatio; } - -bool ConfigDataImp::isDensityRatioInConfigFile() { return this->isDensityRatio; } - -bool ConfigDataImp::isPressRatioInConfigFile() { return this->isPressRatio; } - -bool ConfigDataImp::isRealXInConfigFile() { return this->isRealX; } - -bool ConfigDataImp::isRealYInConfigFile() { return this->isRealY; } - -bool ConfigDataImp::isFactorPressBCInConfigFile() { return this->isFactorPressBC; } - -bool ConfigDataImp::isGeometryFileCInConfigFile() { return this->isGeometryFileC; } - -bool ConfigDataImp::isGeometryFileMInConfigFile() { return this->isGeometryFileM; } - -bool ConfigDataImp::isGeometryFileFInConfigFile() { return this->isGeometryFileF; } - -bool ConfigDataImp::isClockCycleForMPInConfigFile() { return this->isClockCycleForMP; } - -bool ConfigDataImp::isTimestepForMPInConfigFile() { return this->isTimestepForMP; } - -bool ConfigDataImp::isForcingXInConfigFile() { return this->isForcingX; } - -bool ConfigDataImp::isForcingYInConfigFile() { return this->isForcingY; } - -bool ConfigDataImp::isForcingZInConfigFile() { return this->isForcingZ; } - -bool ConfigDataImp::isQuadricLimiterPInConfigFile() { return this->isQuadricLimiterP; } - -bool ConfigDataImp::isQuadricLimiterMInConfigFile() { return this->isQuadricLimiterM; } - -bool ConfigDataImp::isQuadricLimiterDInConfigFile() { return this->isQuadricLimiterD; } - -bool ConfigDataImp::isCalcParticlesInConfigFile() { return this->isCalcParticles; } - -bool ConfigDataImp::isParticleBasicLevelInConfigFile() { return this->isParticleBasicLevel; } - -bool ConfigDataImp::isParticleInitLevelInConfigFile() { return this->isParticleInitLevel; } - -bool ConfigDataImp::isNumberOfParticlesInConfigFile() { return this->isNumberOfParticles; } - -bool ConfigDataImp::isNeighborWSBInConfigFile() { return this->isNeighborWSB; } - -bool ConfigDataImp::isStartXHotWallInConfigFile() { return this->isStartXHotWall; } - -bool ConfigDataImp::isEndXHotWallInConfigFile() { return this->isEndXHotWall; } - -bool ConfigDataImp::isPossNeighborFilesXInConfigFile() { return this->isPossNeighborFilesX; } - -bool ConfigDataImp::isPossNeighborFilesYInConfigFile() { return this->isPossNeighborFilesY; } - -bool ConfigDataImp::isPossNeighborFilesZInConfigFile() { return this->isPossNeighborFilesZ; } - -bool ConfigDataImp::isTimeDoCheckPointInConfigFile() { return this->isTimeDoCheckPoint; } - -bool ConfigDataImp::isTimeDoRestartInConfigFile() { return this->isTimeDoCheckPoint; } - -bool ConfigDataImp::isDoCheckPointInConfigFile() { return this->isDoCheckPoint; } - -bool ConfigDataImp::isDoRestartInConfigFile() { return this->isDoRestart; } - -bool ConfigDataImp::isMaxLevelInConfigFile() { return this->isMaxLevel; } - -bool ConfigDataImp::isGridXInConfigFile() { return this->isGridX; } - -bool ConfigDataImp::isGridYInConfigFile() { return this->isGridY; } - -bool ConfigDataImp::isGridZInConfigFile() { return this->isGridZ; } - -bool ConfigDataImp::isDistXInConfigFile() { return this->isDistX; } - -bool ConfigDataImp::isDistYInConfigFile() { return this->isDistY; } - -bool ConfigDataImp::isDistZInConfigFile() { return this->isDistZ; } - -bool ConfigDataImp::isNeedInterfaceInConfigFile() { return this->isNeedInterface; } - -bool ConfigDataImp::isMainKernelInConfigFile() { return this->isMainKernel; } - -bool ConfigDataImp::isMultiKernelOnInConfigFile() { return this->isMultiKernelOn; } - -bool ConfigDataImp::isMultiKernelLevelInConfigFile() { return this->isMultiKernelLevel; } - -bool ConfigDataImp::isMultiKernelNameInConfigFile() { return this->isMultiKernelName; } diff --git a/src/basics/Core/Input/ConfigData/ConfigDataImp.h b/src/basics/Core/Input/ConfigData/ConfigDataImp.h deleted file mode 100644 index 511ac4be166c7e43885209f144f0cdac6821c6f1..0000000000000000000000000000000000000000 --- a/src/basics/Core/Input/ConfigData/ConfigDataImp.h +++ /dev/null @@ -1,447 +0,0 @@ -#ifndef CONFIGDATAIMP_H -#define CONFIGDATAIMP_H - -#include "ConfigData.h" - -#include <memory> -#include <string> - -class ConfigDataImp : public ConfigData -{ -public: - static std::shared_ptr<ConfigDataImp> getNewInstance(); - - real getViscosity() override; - uint getNumberOfDevices() override; - std::vector<uint> getDevices() override; - std::string getOutputPath() override; - std::string getPrefix() override; - std::string getGridPath() override; - bool getPrintOutputFiles() override; - bool getGeometryValues() override; - bool getCalc2ndOrderMoments() override; - bool getCalc3rdOrderMoments() override; - bool getCalcHighOrderMoments() override; - bool getReadGeo() override; - bool getCalcMedian() override; - bool getCalcDragLift() override; - bool getCalcCp() override; - bool getWriteVeloASCIIfiles() override; - bool getCalcPlaneConc() override; - bool getConcFile() override; - bool getStreetVelocityFile() override; - bool getUseMeasurePoints() override; - bool getUseWale() override; - bool getUseInitNeq() override; - bool getSimulatePorousMedia() override; - uint getD3Qxx() override; - uint getTEnd() override; - uint getTOut() override; - uint getTStartOut() override; - uint getTimeCalcMedStart() override; - uint getTimeCalcMedEnd() override; - uint getPressInID() override; - uint getPressOutID() override; - uint getPressInZ() override; - uint getPressOutZ() override; - bool getDiffOn() override; - uint getDiffMod() override; - real getDiffusivity() override; - real getTemperatureInit() override; - real getTemperatureBC() override; - real getVelocity() override; - real getViscosityRatio() override; - real getVelocityRatio() override; - real getDensityRatio() override; - real getPressRatio() override; - real getRealX() override; - real getRealY() override; - real getFactorPressBC() override; - std::string getGeometryFileC() override; - std::string getGeometryFileM() override; - std::string getGeometryFileF() override; - uint getClockCycleForMP() override; - uint getTimestepForMP() override; - real getForcingX() override; - real getForcingY() override; - real getForcingZ() override; - real getQuadricLimiterP() override; - real getQuadricLimiterM() override; - real getQuadricLimiterD() override; - bool getCalcParticles() override; - int getParticleBasicLevel() override; - int getParticleInitLevel() override; - int getNumberOfParticles() override; - real getStartXHotWall() override; - real getEndXHotWall() override; - std::vector<std::string> getPossNeighborFilesX() override; - std::vector<std::string> getPossNeighborFilesY() override; - std::vector<std::string> getPossNeighborFilesZ() override; - // std::vector<std::string> getPossNeighborFilesX(); - // std::vector<std::string> getPossNeighborFilesY(); - // std::vector<std::string> getPossNeighborFilesZ(); - int getTimeDoCheckPoint() override; - int getTimeDoRestart() override; - bool getDoCheckPoint() override; - bool getDoRestart() override; - uint getMaxLevel() override; - std::vector<int> getGridX() override; - std::vector<int> getGridY() override; - std::vector<int> getGridZ() override; - std::vector<int> getDistX() override; - std::vector<int> getDistY() override; - std::vector<int> getDistZ() override; - std::vector<bool> getNeedInterface() override; - std::string getMainKernel() override; - bool getMultiKernelOn() override; - std::vector<int> getMultiKernelLevel() override; - std::vector<std::string> getMultiKernelName() override; - - void setViscosity(real viscosity); - void setNumberOfDevices(uint numberOfDevices); - void setDevices(std::vector<uint> devices); - void setOutputPath(std::string outputPath); - void setPrefix(std::string prefix); - void setGridPath(std::string gridPath); - void setPrintOutputFiles(bool printOutputFiles); - void setGeometryValues(bool geometryValues); - void setCalc2ndOrderMoments(bool calc2ndOrderMoments); - void setCalc3rdOrderMoments(bool calc3rdOrderMoments); - void setCalcHighOrderMoments(bool calcHighOrderMoment); - void setReadGeo(bool readGeo); - void setCalcMedian(bool calcMedian); - void setCalcDragLift(bool calcDragLift); - void setCalcCp(bool calcCp); - void setWriteVeloASCIIfiles(bool writeVeloASCIIfiles); - void setCalcPlaneConc(bool calcPlaneConc); - void setConcFile(bool concFile); - void setStreetVelocityFile(bool streetVelocityFile); - void setUseMeasurePoints(bool useMeasurePoints); - void setUseWale(bool useWale); - void setUseInitNeq(bool useInitNeq); - void setSimulatePorousMedia(bool simulatePorousMedia); - void setD3Qxx(uint d3Qxx); - void setTEnd(uint tEnd); - void setTOut(uint tOut); - void setTStartOut(uint tStartOut); - void setTimeCalcMedStart(uint timeCalcMedStart); - void setTimeCalcMedEnd(uint timeCalcMedEnd); - void setPressInID(uint pressInID); - void setPressOutID(uint pressOutID); - void setPressInZ(uint pressInZ); - void setPressOutZ(uint pressOutZ); - void setDiffOn(bool diffOn); - void setDiffMod(uint diffMod); - void setDiffusivity(real diffusivity); - void setTemperatureInit(real temperatureInit); - void setTemperatureBC(real temperatureBC); - // void setViscosity(real viscosity); - void setVelocity(real velocity); - void setViscosityRatio(real viscosityRatio); - void setVelocityRatio(real velocityRatio); - void setDensityRatio(real fensityRatio); - void setPressRatio(real pressRatio); - void setRealX(real realX); - void setRealY(real realY); - void setFactorPressBC(real factorPressBC); - void setGeometryFileC(std::string geometryFileC); - void setGeometryFileM(std::string geometryFileM); - void setGeometryFileF(std::string geometryFileF); - void setClockCycleForMP(uint clockCycleForMP); - void setTimestepForMP(uint timestepForMP); - void setForcingX(real forcingX); - void setForcingY(real forcingY); - void setForcingZ(real forcingZ); - void setQuadricLimiterP(real quadricLimiterP); - void setQuadricLimiterM(real quadricLimiterM); - void setQuadricLimiterD(real quadricLimiterD); - void setCalcParticles(bool calcParticles); - void setParticleBasicLevel(int particleBasicLevel); - void setParticleInitLevel(int particleInitLevel); - void setNumberOfParticles(int numberOfParticles); - void setStartXHotWall(real startXHotWall); - void setEndXHotWall(real endXHotWall); - void setPossNeighborFilesX(const std::vector<std::string> &possNeighborFilesX); - void setPossNeighborFilesY(const std::vector<std::string> &possNeighborFilesY); - void setPossNeighborFilesZ(const std::vector<std::string> &possNeighborFilesZ); - // void setPossNeighborFilesX(std::vector<std::string> possNeighborFilesX); - // void setPossNeighborFilesY(std::vector<std::string> possNeighborFilesY); - // void setPossNeighborFilesZ(std::vector<std::string> possNeighborFilesZ); - void setTimeDoCheckPoint(int timeDoCheckPoint); - void setTimeDoRestart(int timeDoRestart); - void setDoCheckPoint(bool doCheckPoint); - void setDoRestart(bool doRestart); - void setMaxLevel(uint maxLevel); - void setGridX(const std::vector<int> &gridX); - void setGridY(const std::vector<int> &gridY); - void setGridZ(const std::vector<int> &gridZ); - void setDistX(const std::vector<int> &distX); - void setDistY(const std::vector<int> &distY); - void setDistZ(const std::vector<int> &distZ); - void setNeedInterface(const std::vector<bool> &needInterface); - void setMainKernel(const std::string &mainKernel); - void setMultiKernelOn(bool multiKernelOn); - void setMultiKernelLevel(const std::vector<int> &multiKernelLevel); - void setMultiKernelName(const std::vector<std::string> &multiKernelName); - - bool isViscosityInConfigFile() override; - bool isNumberOfDevicesInConfigFile() override; - bool isDevicesInConfigFile() override; - bool isOutputPathInConfigFile() override; - bool isPrefixInConfigFile() override; - bool isGridPathInConfigFile() override; - bool isPrintOutputFilesInConfigFile() override; - bool isGeometryValuesInConfigFile() override; - bool isCalc2ndOrderMomentsInConfigFile() override; - bool isCalc3rdOrderMomentsInConfigFile() override; - bool isCalcHighOrderMomentsInConfigFile() override; - bool isReadGeoInConfigFile() override; - bool isCalcMedianInConfigFile() override; - bool isCalcDragLiftInConfigFile() override; - bool isCalcCpInConfigFile() override; - bool isWriteVeloASCIIfilesInConfigFile() override; - bool isCalcPlaneConcInConfigFile() override; - bool isConcFileInConfigFile() override; - bool isStreetVelocityFileInConfigFile() override; - bool isUseMeasurePointsInConfigFile() override; - bool isUseWaleInConfigFile() override; - bool isUseInitNeqInConfigFile() override; - bool isSimulatePorousMediaInConfigFile() override; - bool isD3QxxInConfigFile() override; - bool isTEndInConfigFile() override; - bool isTOutInConfigFile() override; - bool isTStartOutInConfigFile() override; - bool isTimeCalcMedStartInConfigFile() override; - bool isTimeCalcMedEndInConfigFile() override; - bool isPressInIDInConfigFile() override; - bool isPressOutIDInConfigFile() override; - bool isPressInZInConfigFile() override; - bool isPressOutZInConfigFile() override; - bool isDiffOnInConfigFile() override; - bool isDiffModInConfigFile() override; - bool isDiffusivityInConfigFile() override; - bool isTemperatureInitInConfigFile() override; - bool isTemperatureBCInConfigFile() override; - // bool isViscosityInConfigFile(); - bool isVelocityInConfigFile() override; - bool isViscosityRatioInConfigFile() override; - bool isVelocityRatioInConfigFile() override; - bool isDensityRatioInConfigFile() override; - bool isPressRatioInConfigFile() override; - bool isRealXInConfigFile() override; - bool isRealYInConfigFile() override; - bool isFactorPressBCInConfigFile() override; - bool isGeometryFileCInConfigFile() override; - bool isGeometryFileMInConfigFile() override; - bool isGeometryFileFInConfigFile() override; - bool isClockCycleForMPInConfigFile() override; - bool isTimestepForMPInConfigFile() override; - bool isForcingXInConfigFile() override; - bool isForcingYInConfigFile() override; - bool isForcingZInConfigFile() override; - bool isQuadricLimiterPInConfigFile() override; - bool isQuadricLimiterMInConfigFile() override; - bool isQuadricLimiterDInConfigFile() override; - bool isCalcParticlesInConfigFile() override; - bool isParticleBasicLevelInConfigFile() override; - bool isParticleInitLevelInConfigFile() override; - bool isNumberOfParticlesInConfigFile() override; - bool isNeighborWSBInConfigFile() override; - bool isStartXHotWallInConfigFile() override; - bool isEndXHotWallInConfigFile() override; - bool isPossNeighborFilesXInConfigFile() override; - bool isPossNeighborFilesYInConfigFile() override; - bool isPossNeighborFilesZInConfigFile() override; - bool isTimeDoCheckPointInConfigFile() override; - bool isTimeDoRestartInConfigFile() override; - bool isDoCheckPointInConfigFile() override; - bool isDoRestartInConfigFile() override; - bool isMaxLevelInConfigFile() override; - bool isGridXInConfigFile() override; - bool isGridYInConfigFile() override; - bool isGridZInConfigFile() override; - bool isDistXInConfigFile() override; - bool isDistYInConfigFile() override; - bool isDistZInConfigFile() override; - bool isNeedInterfaceInConfigFile() override; - bool isMainKernelInConfigFile() override; - bool isMultiKernelOnInConfigFile() override; - bool isMultiKernelLevelInConfigFile() override; - bool isMultiKernelNameInConfigFile() override; - -private: - ConfigDataImp() = default; - - real viscosity { 0. }; - uint numberOfDevices { 0 }; - std::vector<uint> devices; - std::string outputPath; - std::string prefix; - std::string gridPath; - bool printOutputFiles { false }; - bool geometryValues { false }; - bool calc2ndOrderMoments { false }; - bool calc3rdOrderMoments { false }; - bool calcHighOrderMoments { false }; - bool readGeo { false }; - bool calcMedian { false }; - bool calcDragLift { false }; - bool calcCp { false }; - bool writeVeloASCIIfiles { false }; - bool calcPlaneConc { false }; - bool concFile { false }; - bool streetVelocityFile { false }; - bool useMeasurePoints { false }; - bool useWale { false }; - bool useInitNeq { false }; - bool simulatePorousMedia { false }; - uint d3Qxx { 0 }; - uint tEnd { 0 }; - uint tOut { 0 }; - uint tStartOut { 0 }; - uint timeCalcMedStart { 0 }; - uint timeCalcMedEnd { 0 }; - uint pressInID { 0 }; - uint pressOutID { 0 }; - uint pressInZ { 0 }; - uint pressOutZ { 0 }; - bool diffOn { false }; - uint diffMod { 0 }; - real diffusivity { 0. }; - real temperatureInit { 0. }; - real temperatureBC { 0. }; - // real viscosity { 0 }; - real velocity { 0. }; - real viscosityRatio { 0. }; - real velocityRatio { 0. }; - real densityRatio { 0. }; - real pressRatio { 0. }; - real realX { 0. }; - real realY { 0. }; - real factorPressBC { 0. }; - std::string geometryFileC; - std::string geometryFileM; - std::string geometryFileF; - uint clockCycleForMP { 0 }; - uint timestepForMP { 0 }; - real forcingX { 0. }; - real forcingY { 0. }; - real forcingZ { 0. }; - real quadricLimiterP { 0. }; - real quadricLimiterM { 0. }; - real quadricLimiterD { 0. }; - bool calcParticles { false }; - int particleBasicLevel { 0 }; - int particleInitLevel { 0 }; - int numberOfParticles { 0 }; - real startXHotWall { 0. }; - real endXHotWall { 0. }; - std::vector<std::string> possNeighborFilesX; - std::vector<std::string> possNeighborFilesY; - std::vector<std::string> possNeighborFilesZ; - // std::vector<std::string> possNeighborFilesX; - // std::vector<std::string> possNeighborFilesY; - // std::vector<std::string> possNeighborFilesZ; - int timeDoCheckPoint { 0 }; - int timeDoRestart { 0 }; - bool doCheckPoint{ false }; - bool doRestart{ false }; - int maxLevel { 0 }; - std::vector<int> gridX; - std::vector<int> gridY; - std::vector<int> gridZ; - std::vector<int> distX; - std::vector<int> distY; - std::vector<int> distZ; - std::vector<bool> needInterface; - std::string mainKernel; - bool multiKernelOn{ false }; - std::vector<int> multiKernelLevel; - std::vector<std::string> multiKernelName; - - bool isViscosity { false }; - bool isNumberOfDevices {false}; - bool isDevices { false }; - bool isOutputPath { false }; - bool isPrefix { false }; - bool isGridPath { false }; - bool isPrintOutputFiles { false }; - bool isGeometryValues { false }; - bool isCalc2ndOrderMoments { false }; - bool isCalc3rdOrderMoments { false }; - bool isCalcHighOrderMoments { false }; - bool isReadGeo { false }; - bool isCalcMedian { false }; - bool isCalcDragLift { false }; - bool isCalcCp { false }; - bool isWriteVeloASCII { false }; - bool isCalcPlaneConc { false }; - bool isConcFile { false }; - bool isStreetVelocityFile { false }; - bool isUseMeasurePoints { false }; - bool isUseWale { false }; - bool isUseInitNeq { false }; - bool isSimulatePorousMedia { false }; - bool isD3Qxx { false }; - bool isTEnd { false }; - bool isTOut { false }; - bool isTStartOut { false }; - bool isTimeCalcMedStart { false }; - bool isTimeCalcMedEnd { false }; - bool isPressInID { false }; - bool isPressOutID { false }; - bool isPressInZ { false }; - bool isPressOutZ { false }; - bool isDiffOn { false }; - bool isDiffMod { false }; - bool isDiffusivity { false }; - bool isTemperatureInit { false }; - bool isTemperatureBC { false }; - // bool isViscosity { false }; - bool isVelocity { false }; - bool isViscosityRatio { false }; - bool isVelocityRatio { false }; - bool isDensityRatio { false }; - bool isPressRatio { false }; - bool isRealX { false }; - bool isRealY { false }; - bool isFactorPressBC { false }; - bool isGeometryFileC { false }; - bool isGeometryFileM { false }; - bool isGeometryFileF { false }; - bool isClockCycleForMP { false }; - bool isTimestepForMP { false }; - bool isForcingX { false }; - bool isForcingY { false }; - bool isForcingZ { false }; - bool isQuadricLimiterP { false }; - bool isQuadricLimiterM { false }; - bool isQuadricLimiterD { false }; - bool isCalcParticles { false }; - bool isParticleBasicLevel { false }; - bool isParticleInitLevel { false }; - bool isNumberOfParticles { false }; - bool isNeighborWSB { false }; - bool isStartXHotWall { false }; - bool isEndXHotWall { false }; - bool isPossNeighborFilesX { false }; - bool isPossNeighborFilesY { false }; - bool isPossNeighborFilesZ { false }; - bool isTimeDoCheckPoint { false }; - bool isTimeDoRestart { false }; - bool isDoCheckPoint { false }; - bool isDoRestart { false }; - bool isMaxLevel { false }; - bool isGridX { false }; - bool isGridY { false }; - bool isGridZ { false }; - bool isDistX { false }; - bool isDistY { false }; - bool isDistZ { false }; - bool isNeedInterface { false }; - bool isMainKernel { false }; - bool isMultiKernelOn { false }; - bool isMultiKernelLevel { false }; - bool isMultiKernelName { false }; -}; -#endif diff --git a/src/basics/Core/Input/ConfigFileReader/ConfigFileReader.cpp b/src/basics/Core/Input/ConfigFileReader/ConfigFileReader.cpp deleted file mode 100644 index 8fdb9fe1bc7f5dfe10dbfb522a87a4a3187dd60b..0000000000000000000000000000000000000000 --- a/src/basics/Core/Input/ConfigFileReader/ConfigFileReader.cpp +++ /dev/null @@ -1,262 +0,0 @@ -#include "ConfigFileReader.h" -#include "../../StringUtilities/StringUtil.h" -#include "../ConfigData/ConfigDataImp.h" -#include "../Input.h" - -#include <fstream> -#include <iostream> - -std::shared_ptr<ConfigFileReader> ConfigFileReader::getNewInstance() -{ - return std::shared_ptr<ConfigFileReader>(new ConfigFileReader()); -} - -std::shared_ptr<ConfigData> ConfigFileReader::readConfigFile(const char* filePath) const -{ - std::cout << filePath << std::endl; - std::shared_ptr<ConfigDataImp> data = ConfigDataImp::getNewInstance(); - std::ifstream stream; - stream.open(filePath, std::ios::in); - if (stream.fail()) - throw std::runtime_error("can not open config file!"); - std::unique_ptr<input::Input> input = input::Input::makeInput(stream, "config"); - - if (input->getValue("NumberOfDevices") != "") - data->setNumberOfDevices(StringUtil::toInt(input->getValue("NumberOfDevices"))); - - if (input->getValue("Devices") != "") - data->setDevices(StringUtil::toUintVector(input->getValue("Devices"))); - - if (input->getValue("Path") != "") - data->setOutputPath(input->getValue("Path")); - - if (input->getValue("Prefix") != "") - data->setPrefix(input->getValue("Prefix")); - - if (input->getValue("GridPath") != "") - data->setGridPath(input->getValue("GridPath")); - else { - std::cout << "GridPath has to be defined!" << std::endl; - exit(1); - } - - if (input->getValue("WriteGrid") != "") - data->setPrintOutputFiles(StringUtil::toBool(input->getValue("WriteGrid"))); - - if (input->getValue("GeometryValues") != "") - data->setGeometryValues(StringUtil::toBool(input->getValue("GeometryValues"))); - - if (input->getValue("calc2ndOrderMoments") != "") - data->setCalc2ndOrderMoments(StringUtil::toBool(input->getValue("calc2ndOrderMoments"))); - - if (input->getValue("calc3rdOrderMoments") != "") - data->setCalc3rdOrderMoments(StringUtil::toBool(input->getValue("calc3rdOrderMoments"))); - - if (input->getValue("calcHigherOrderMoments") != "") - data->setCalcHighOrderMoments(StringUtil::toBool(input->getValue("calcHigherOrderMoments"))); - - if (input->getValue("ReadGeometry") != "") - data->setReadGeo(StringUtil::toBool(input->getValue("ReadGeometry"))); - - if (input->getValue("calcMedian") != "") - data->setCalcMedian(StringUtil::toBool(input->getValue("calcMedian"))); - - if (input->getValue("UseConcFile") != "") - data->setConcFile(StringUtil::toBool(input->getValue("UseConcFile"))); - - if (input->getValue("UseStreetVelocityFile") != "") - data->setStreetVelocityFile(StringUtil::toBool(input->getValue("UseStreetVelocityFile"))); - - if (input->getValue("UseMeasurePoints") != "") - data->setUseMeasurePoints(StringUtil::toBool(input->getValue("UseMeasurePoints"))); - - if (input->getValue("UseWale") != "") - data->setUseWale(StringUtil::toBool(input->getValue("UseWale"))); - - if (input->getValue("UseInitNeq") != "") - data->setUseInitNeq(StringUtil::toBool(input->getValue("UseInitNeq"))); - - if (input->getValue("SimulatePorousMedia") != "") - data->setSimulatePorousMedia(StringUtil::toBool(input->getValue("SimulatePorousMedia"))); - - if (input->getValue("D3Qxx") != "") - data->setD3Qxx(StringUtil::toInt(input->getValue("D3Qxx"))); - - if (input->getValue("TimeEnd") != "") - data->setTEnd(StringUtil::toInt(input->getValue("TimeEnd"))); - - if (input->getValue("TimeOut") != "") - data->setTOut(StringUtil::toInt(input->getValue("TimeOut"))); - - if (input->getValue("TimeStartOut") != "") - data->setTStartOut(StringUtil::toInt(input->getValue("TimeStartOut"))); - - if (input->getValue("TimeStartCalcMedian") != "") - data->setTimeCalcMedStart(StringUtil::toInt(input->getValue("TimeStartCalcMedian"))); - - if (input->getValue("TimeEndCalcMedian") != "") - data->setTimeCalcMedEnd(StringUtil::toInt(input->getValue("TimeEndCalcMedian"))); - - if (input->getValue("PressInID") != "") - data->setPressInID(StringUtil::toInt(input->getValue("PressInID"))); - - if (input->getValue("PressOutID") != "") - data->setPressOutID(StringUtil::toInt(input->getValue("PressOutID"))); - - if (input->getValue("PressInZ") != "") - data->setPressInZ(StringUtil::toInt(input->getValue("PressInZ"))); - - if (input->getValue("PressOutZ") != "") - data->setPressOutZ(StringUtil::toInt(input->getValue("PressOutZ"))); - ////////////////////////////////////////////////////////////////////////// - if (input->getValue("DiffOn") != "") - data->setDiffOn(StringUtil::toBool(input->getValue("DiffOn"))); - - if (input->getValue("DiffMod") != "") - data->setDiffMod(StringUtil::toInt(input->getValue("DiffMod"))); - - if (input->getValue("Diffusivity") != "") - data->setDiffusivity(StringUtil::toFloat(input->getValue("Diffusivity"))); - - if (input->getValue("Temp") != "") - data->setTemperatureInit(StringUtil::toFloat(input->getValue("Temp"))); - - if (input->getValue("TempBC") != "") - data->setTemperatureBC(StringUtil::toFloat(input->getValue("TempBC"))); - ////////////////////////////////////////////////////////////////////////// - if (input->getValue("Viscosity_LB") != "") - data->setViscosity(StringUtil::toFloat(input->getValue("Viscosity_LB"))); - - if (input->getValue("Velocity_LB") != "") - data->setVelocity(StringUtil::toFloat(input->getValue("Velocity_LB"))); - - if (input->getValue("Viscosity_Ratio_World_to_LB") != "") - data->setViscosityRatio(StringUtil::toFloat(input->getValue("Viscosity_Ratio_World_to_LB"))); - - if (input->getValue("Velocity_Ratio_World_to_LB") != "") - data->setVelocityRatio(StringUtil::toFloat(input->getValue("Velocity_Ratio_World_to_LB"))); - - if (input->getValue("Density_Ratio_World_to_LB") != "") - data->setDensityRatio(StringUtil::toFloat(input->getValue("Density_Ratio_World_to_LB"))); - - if (input->getValue("Delta_Press") != "") - data->setPressRatio(StringUtil::toFloat(input->getValue("Delta_Press"))); - - if (input->getValue("SliceRealX") != "") - data->setRealX(StringUtil::toFloat(input->getValue("SliceRealX"))); - - if (input->getValue("SliceRealY") != "") - data->setRealY(StringUtil::toFloat(input->getValue("SliceRealY"))); - - if (input->getValue("FactorPressBC") != "") - data->setFactorPressBC(StringUtil::toFloat(input->getValue("FactorPressBC"))); - - if (input->getValue("GeometryC") != "") - data->setGeometryFileC(input->getValue("GeometryC")); - - if (input->getValue("GeometryM") != "") - data->setGeometryFileM(input->getValue("GeometryM")); - - if (input->getValue("GeometryF") != "") - data->setGeometryFileF(input->getValue("GeometryF")); - ////////////////////////////////////////////////////////////////////////// - if (input->getValue("measureClockCycle") != "") - data->setClockCycleForMP(StringUtil::toInt(input->getValue("measureClockCycle"))); - - if (input->getValue("measureTimestep") != "") - data->setTimestepForMP(StringUtil::toInt(input->getValue("measureTimestep"))); - ////////////////////////////////////////////////////////////////////////// - // Forcing - if (input->getValue("ForcingX") != "") - data->setForcingX(StringUtil::toFloat(input->getValue("ForcingX"))); - if (input->getValue("ForcingY") != "") - data->setForcingY(StringUtil::toFloat(input->getValue("ForcingY"))); - if (input->getValue("ForcingZ") != "") - data->setForcingZ(StringUtil::toFloat(input->getValue("ForcingZ"))); - ////////////////////////////////////////////////////////////////////////// - // Quadric Limiters - if (input->getValue("QuadricLimiterP") != "") - data->setQuadricLimiterP(StringUtil::toFloat(input->getValue("QuadricLimiterP"))); - if (input->getValue("QuadricLimiterM") != "") - data->setQuadricLimiterM(StringUtil::toFloat(input->getValue("QuadricLimiterM"))); - if (input->getValue("QuadricLimiterD") != "") - data->setQuadricLimiterD(StringUtil::toFloat(input->getValue("QuadricLimiterD"))); - ////////////////////////////////////////////////////////////////////////// - // Particles - if (input->getValue("calcParticles") != "") - data->setCalcParticles(StringUtil::toBool(input->getValue("calcParticles"))); - - if (input->getValue("baseLevel") != "") - data->setParticleBasicLevel(StringUtil::toInt(input->getValue("baseLevel"))); - - if (input->getValue("initLevel") != "") - data->setParticleInitLevel(StringUtil::toInt(input->getValue("initLevel"))); - - if (input->getValue("numberOfParticles") != "") - data->setNumberOfParticles(StringUtil::toInt(input->getValue("numberOfParticles"))); - - if (input->getValue("startXHotWall") != "") - data->setStartXHotWall(real(StringUtil::toDouble(input->getValue("startXHotWall")))); - - if (input->getValue("endXHotWall") != "") - data->setEndXHotWall(real(StringUtil::toDouble(input->getValue("endXHotWall")))); - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - // Restart - if (input->getValue("TimeDoCheckPoint") != "") - data->setTimeDoCheckPoint(StringUtil::toInt(input->getValue("TimeDoCheckPoint"))); - - if (input->getValue("TimeDoRestart") != "") - data->setTimeDoRestart(StringUtil::toInt(input->getValue("TimeDoRestart"))); - - if (input->getValue("DoCheckPoint") != "") - data->setDoCheckPoint(StringUtil::toBool(input->getValue("DoCheckPoint"))); - - if (input->getValue("DoRestart") != "") - data->setDoRestart(StringUtil::toBool(input->getValue("DoRestart"))); - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - if (input->getValue("NOGL") != "") - data->setMaxLevel(StringUtil::toInt(input->getValue("NOGL"))); - - if (input->getValue("GridX") != "") - data->setGridX(StringUtil::toIntVector(input->getValue("GridX"))); - - if (input->getValue("GridY") != "") - data->setGridY(StringUtil::toIntVector(input->getValue("GridY"))); - - if (input->getValue("GridZ") != "") - data->setGridZ(StringUtil::toIntVector(input->getValue("GridZ"))); - - if (input->getValue("DistX") != "") - data->setDistX(StringUtil::toIntVector(input->getValue("DistX"))); - - if (input->getValue("DistY") != "") - data->setDistY(StringUtil::toIntVector(input->getValue("DistY"))); - - if (input->getValue("DistZ") != "") - data->setDistZ(StringUtil::toIntVector(input->getValue("DistZ"))); - - if (input->getValue("NeedInterface") != "") - data->setNeedInterface(StringUtil::toBoolVector(input->getValue("NeedInterface"))); - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - // Kernel - if (input->getValue("MainKernelName") != "") - data->setMainKernel(input->getValue("MainKernelName")); - - if (input->getValue("MultiKernelOn") != "") - data->setMultiKernelOn(StringUtil::toBool(input->getValue("MultiKernelOn"))); - - if (input->getValue("MultiKernelLevel") != "") - data->setMultiKernelLevel(StringUtil::toIntVector(input->getValue("MultiKernelLevel"))); - - if (input->getValue("MultiKernelName") != "") - data->setMultiKernelName(StringUtil::toStringVector(input->getValue("MultiKernelName"))); - - if (StringUtil::toStringVector(input->getValue("MultiKernelName")).size() != - StringUtil::toIntVector(input->getValue("MultiKernelLevel")).size()) { - std::cout << "MultiKernelName and MultiKernelLevel has to be of same size!" << std::endl; - exit(1); - } - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - return data; -} diff --git a/src/basics/Core/Input/ConfigFileReader/ConfigFileReader.h b/src/basics/Core/Input/ConfigFileReader/ConfigFileReader.h deleted file mode 100644 index 77c93ebfa4ba8564188d8e4a5442963382cf91e3..0000000000000000000000000000000000000000 --- a/src/basics/Core/Input/ConfigFileReader/ConfigFileReader.h +++ /dev/null @@ -1,22 +0,0 @@ -#ifndef CONFIGFILEREADER_H -#define CONFIGFILEREADER_H - - -#include <memory> -#include <string> - -#include "basics_export.h" - -class ConfigData; - -class ConfigFileReader -{ -public: - BASICS_EXPORT static std::shared_ptr<ConfigFileReader> getNewInstance(); - - BASICS_EXPORT std::shared_ptr<ConfigData> readConfigFile(const char* filePath) const; - -private: - ConfigFileReader() = default; -}; -#endif diff --git a/src/basics/Core/Input/ConfigInput/ConfigInput.cpp b/src/basics/Core/Input/ConfigInput/ConfigInput.cpp deleted file mode 100644 index 1fdff1e8794b5cb58f6b1a8a2e97a536531df829..0000000000000000000000000000000000000000 --- a/src/basics/Core/Input/ConfigInput/ConfigInput.cpp +++ /dev/null @@ -1,222 +0,0 @@ -#include "ConfigInput.h" -#include <algorithm> -#include <cerrno> -#include <iostream> -#include <sstream> -#include <string> - -#define COMMENT '#' - -namespace input -{ -// Trim the given characters from the beginning and end of a string. -// the default is to trim whitespace. If the string is empty or contains -// only the trim characters, an empty string is returned. -std::string trim(const std::string &instring, const std::string &trimstring = std::string(" \t\n")) -{ - if (trimstring.size() == 0) - return instring; - std::string temp = ""; - std::string::size_type begpos = instring.find_first_not_of(trimstring); - if (begpos == std::string::npos) { - return temp; - } else { - std::string::size_type endpos = instring.find_last_not_of(trimstring); - temp = instring.substr(begpos, endpos - begpos + 1); - } - return temp; -} - -ConfigInput::ConfigInput(std::istream &stream) : stream(stream) -{ - while (!stream.eof()) - this->setTokenValuePair(); -} - -ConfigInput::~ConfigInput() = default; - -bool ConfigInput::hasValue(const std::string &key) const -{ - bool valueFound = false; - std::string keyCopy = key; - this->makeLower(keyCopy); - if (configEntries.find(keyCopy.c_str()) != configEntries.end()) - valueFound = true; - - return valueFound; -} - -std::string ConfigInput::getValue(const std::string &key) -{ - std::string keyCopy = key; - this->makeLower(keyCopy); - if (configEntries.find(keyCopy.c_str()) != configEntries.end()) - return (*configEntries.find(keyCopy.c_str())).second; - return ""; -} - -////////////////////////////////////////////////////////////////////////// -// private methods // -////////////////////////////////////////////////////////////////////////// - -void ConfigInput::makeLower(std::string &value) const -{ - for (size_t i = 0; i < value.size(); i++) - value[i] = tolower(value[i]); -} - -void ConfigInput::setTokenValuePair() -{ - this->eatWhiteAndComments(true); - - std::string token; - if (!this->setToken(token)) - return; - - std::string value; - this->setValue(value); - - configEntries.insert(String_Pair(token, value)); -} - -bool ConfigInput::setToken(std::string &token) -{ - char tokenChar[1024]; - bool foundEqualSign = false; - int charIndex = 0; - - this->findToken(foundEqualSign, tokenChar, charIndex); - - if (!isToken(charIndex, foundEqualSign)) - return false; - - this->nullTerminate(tokenChar, charIndex); - token = tokenChar; - makeLower(token); - return true; -} - -void ConfigInput::findToken(bool &foundEqualSign, char *token, int &i) -{ - char ch; - while (!(stream.get(ch)).fail()) { - if ((ch != '\t')) { - if ((ch == '=') || (ch == ' ') || (ch == '\n') || (ch == '\r') || (ch == '\t')) { - foundEqualSign = true; - break; - } - token[i++] = ch; - } - } -} - -bool ConfigInput::isToken(int charIndex, bool foundEqualSign) -{ - if (charIndex == 0) { - configEntries.insert(String_Pair("", "")); - return false; - } - - if (!foundEqualSign && !advanceToEqualSignOnLine()) { - configEntries.insert(String_Pair("", "")); - return false; - } - return true; -} - -void ConfigInput::setValue(std::string &value) -{ - int charIndex = 0; - char valueChar[1024]; - this->findValue(charIndex, valueChar); - - if (charIndex == 0) - value = ""; - else { - this->nullTerminate(valueChar, charIndex); - value = valueChar; - value = trim(value); - this->stripLeadingAndTrailingQuotes(value); - } -} - -int ConfigInput::findValue(int &charIndex, char *value) -{ - char ch; - char c = eatWhiteAndComments(false); - if (c != '\n') { - charIndex = 0; - while (!(stream.get(ch)).fail()) { - if ((ch == '\t') || (ch == '\r') || (ch == '\n') || (ch == '#')) { - while (ch != '\n') { - if (stream.get(ch).fail()) - break; - } - break; - } else { - value[charIndex++] = ch; - } - } - } - return charIndex; -} - -void ConfigInput::stripLeadingAndTrailingQuotes(std::string &m_value) -{ - if (m_value[0] == '"') - m_value = m_value.substr(1); - if (m_value[m_value.length() - 1] == '"') - m_value = m_value.substr(0, m_value.length() - 1); -} - -void ConfigInput::nullTerminate(char *value, int &i) { value[i++] = '\0'; } - -bool ConfigInput::advanceToEqualSignOnLine() -{ - char ch; - bool foundEqual = false; - while (!(stream.get(ch)).fail()) { - if (isNewLine(ch) || isCarriageReturn(ch)) - break; - if (isEqualSign(ch)) { - foundEqual = true; - break; - } - } - return foundEqual; -} - -char ConfigInput::eatWhiteAndComments(bool traverseNewlines) -{ - char ch; - bool isComment = false; - - while (!(stream.get(ch)).fail()) { - if (isCommentSign(ch)) - isComment = true; - else if (isNewLine(ch)) { - isComment = false; - if (!traverseNewlines) - return (ch); - } else if (isRegularChar(isComment, ch)) { - stream.putback(ch); - return 0; - } - } - return 0; -} - -bool ConfigInput::isRegularChar(bool isComment, char ch) -{ - return (!isComment) && (ch != ' ') && (ch != '\t') && (ch != '\r'); -} - -bool ConfigInput::isCommentSign(char ch) { return ch == COMMENT; } - -bool ConfigInput::isEqualSign(char ch) { return ch == '='; } - -bool ConfigInput::isNewLine(char ch) { return ch == '\n'; } - -bool ConfigInput::isCarriageReturn(char ch) { return ch == '\r'; } - -} // namespace input diff --git a/src/basics/Core/Input/ConfigInput/ConfigInput.h b/src/basics/Core/Input/ConfigInput/ConfigInput.h deleted file mode 100644 index aee9242ca7cb63ac259fe27869c0d4f9d5036b05..0000000000000000000000000000000000000000 --- a/src/basics/Core/Input/ConfigInput/ConfigInput.h +++ /dev/null @@ -1,48 +0,0 @@ -#ifndef ConfigInput_H -#define ConfigInput_H -#include <istream> -#include <list> -#include <map> -#include <memory> -#include <string> -#include <vector> - -#include "../Input.h" -#include "basics_export.h" - -namespace input -{ -class ConfigInput : public Input -{ -public: - BASICS_EXPORT ConfigInput(std::istream &stream); - BASICS_EXPORT ~ConfigInput() override; - - BASICS_EXPORT bool hasValue(const std::string &key) const override; - BASICS_EXPORT std::string getValue(const std::string &key) override; - -protected: - virtual void setTokenValuePair(); - void setValue(std::string &value); - bool setToken(std::string &token); - bool isToken(int charIndex, bool foundEqualSign); - int findValue(int &charIndex, char *value); - void stripLeadingAndTrailingQuotes(std::string &m_value); - void nullTerminate(char *token, int &i); - void findToken(bool &foundEqualSign, char *token, int &i); - char eatWhiteAndComments(bool traverse_newlines = true); - bool isRegularChar(bool isComment, char ch); - bool isNewLine(char ch); - bool isCommentSign(char ch); - bool advanceToEqualSignOnLine(); - bool isCarriageReturn(char ch); - bool isEqualSign(char ch); - void makeLower(std::string &instring) const; - -protected: - std::istream &stream; - using String_Pair = std::pair<std::string, std::string>; - std::map<std::string, std::string> configEntries; -}; -} // namespace input -#endif diff --git a/src/basics/Core/Input/Input.cpp b/src/basics/Core/Input/Input.cpp deleted file mode 100644 index f971dd2260d97c28c6e84f60d9b0415eb971ea16..0000000000000000000000000000000000000000 --- a/src/basics/Core/Input/Input.cpp +++ /dev/null @@ -1,24 +0,0 @@ -#include "Input.h" - -#include <memory> - -#ifdef BUILD_JSONCPP -#include "JsonInput/JsonInput.h" -#endif - -#include "ConfigInput/ConfigInput.h" - -namespace input -{ - -std::unique_ptr<input::Input> Input::makeInput(std::istream &stream, const std::string & /*inputType*/) -{ -#ifdef BUILD_JSONCPP - if (inputType == "json") - return std::unique_ptr<Input>(new JsonInput(stream)); -#endif - - return std::make_unique<ConfigInput>(stream); -} - -} // namespace input diff --git a/src/basics/Core/Input/Input.h b/src/basics/Core/Input/Input.h deleted file mode 100644 index 3b07b8b32d99293c3216e1a14dc9df9fc9688bea..0000000000000000000000000000000000000000 --- a/src/basics/Core/Input/Input.h +++ /dev/null @@ -1,24 +0,0 @@ -#ifndef Input_H -#define Input_H - -#include "basics_export.h" - -#include <istream> -#include <memory> -#include <string> - -namespace input -{ -class Input -{ -public: - static BASICS_EXPORT std::unique_ptr<Input> makeInput(std::istream &stream, const std::string &inputType); - - virtual ~Input() = default; - - virtual bool hasValue(const std::string &key) const = 0; - virtual std::string getValue(const std::string &key) = 0; -}; -} // namespace input - -#endif diff --git a/src/basics/Core/Input/JsonInput/JsonInput.cpp b/src/basics/Core/Input/JsonInput/JsonInput.cpp deleted file mode 100644 index 34a1d154a386d267c4d086e28b5f7e5f64c302cc..0000000000000000000000000000000000000000 --- a/src/basics/Core/Input/JsonInput/JsonInput.cpp +++ /dev/null @@ -1,67 +0,0 @@ -#ifdef BUILD_JSONCPP - -#include "JsonInput.h" - -#include <fstream> -#include <iterator> -#include <sstream> -#include <string> -#include <vector> - -namespace input -{ -template <typename Out> -void split(const std::string &s, char delim, Out result) -{ - std::stringstream ss; - ss.str(s); - std::string item; - while (std::getline(ss, item, delim)) { - *(result++) = item; - } -} - -std::vector<std::string> split(const std::string &s, char delim) -{ - std::vector<std::string> elems; - split(s, delim, std::back_inserter(elems)); - return elems; -} - -JsonInput::JsonInput(std::istream &stream) -{ - Json::Reader reader; - reader.parse(stream, jsonValue); -} - -bool JsonInput::hasValue(const std::string &key) const -{ - auto keys = split(key, ' '); - - if (keys.size() == 1 && !jsonValue[keys[0]].isNull()) - return true; - else if (keys.size() == 2 && !jsonValue[keys[0]][keys[1]].isNull()) - return true; - else if (keys.size() == 3 && !jsonValue[keys[0]][keys[1]][keys[2]].isNull()) - return true; - else - return false; -} - -std::string JsonInput::getValue(const std::string &key) -{ - auto keys = split(key, ' '); - - if (keys.size() == 1) - return jsonValue[keys[0]].asString(); - else if (keys.size() == 2) - return jsonValue[keys[0]][keys[1]].asString(); - else if (keys.size() == 3) - return jsonValue[keys[0]][keys[1]][keys[2]].asString(); - else - return ""; -} - -} // namespace input - -#endif diff --git a/src/basics/Core/Input/JsonInput/JsonInput.h b/src/basics/Core/Input/JsonInput/JsonInput.h deleted file mode 100644 index 8a33e99bfe2904caff82349caaf2579049892b15..0000000000000000000000000000000000000000 --- a/src/basics/Core/Input/JsonInput/JsonInput.h +++ /dev/null @@ -1,30 +0,0 @@ -#ifdef BUILD_JSONCPP - -#ifndef JsonInput_H -#define JsonInput_H - -#include <json/json.h> -#include <string> - -#include "basics_export.h" - -#include "../Input.h" - -namespace input -{ -class JsonInput : public Input -{ -public: - BASICS_EXPORT JsonInput(std::istream &stream); - - BASICS_EXPORT virtual bool hasValue(const std::string &key) const override; - BASICS_EXPORT virtual std::string getValue(const std::string &key) override; - -private: - Json::Value jsonValue; -}; -} // namespace input - -#endif - -#endif 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 d353a341c9f75d58d11ede3048f3cb0521be40b3..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 3109112b299e5ac169d9f536a4d4e66b7970cff2..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 @@ -20,7 +52,7 @@ #include "RealConstants.h" struct BASICS_EXPORT Vec3 { - real x{ c0o1 }, y{ c0o1 }, z{ c0o1 }; + real x{ 0. }, y{ 0. }, z{ 0. }; __host__ __device__ Vec3(real x, real y, real z) : x(x), y(y), z(z) {} Vec3() = default; 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 12ce32ab032579976d3b3f97d53e5ae4a2584f78..f988c52f7e381b988830a4506c72e77221c177d9 100644 --- a/src/basics/basics/utilities/UbFileInputASCII.cpp +++ b/src/basics/basics/utilities/UbFileInputASCII.cpp @@ -1,3 +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 UbFileInputASCII.cpp +//! \ingroup utilities +//! \author Soeren Freudiger, Sebastian Geller +//======================================================================================= +#include <algorithm> #include <basics/utilities/UbFileInputASCII.h> #include <cstring> @@ -138,7 +171,7 @@ bool UbFileInputASCII::containsString(const string &var) } /*==========================================================*/ int UbFileInputASCII::readIntegerAfterString(const string &var) -// last change [10.3.2004] at [9:46] +// last change [29.6.2021] at [13:52] // suchts in einer Datei nach varname und gibt den dahinter stehenden int-Wert zurueck // z.B. timesteps 9 { @@ -155,14 +188,16 @@ 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 - strcpy(line, (line + strlen(var.c_str()))); // zeile um "varname" kuerzen - while ((line[0] == ' ') || (line[0] == '\t')) - strcpy(line, (line + 1)); // Whitespaces entfernen + 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(), '\t'), temp.end()); // remove tabs - return (atoi(line)); // Umwandlung in int + return std::stoi(temp); } /*==========================================================*/ -// last change [10.3.2004] at [9:46] +// last change [29.6.2021] at [13:52] // sucht in einer Datei nach varname und gibt den dahinter stehenden int-Wert zurueck // z.B. nue 9.5 double UbFileInputASCII::readDoubleAfterString(const string &var) @@ -181,14 +216,16 @@ 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 - strcpy(line, (line + strlen(var.c_str()))); // zeile um "varname" kuerzen - while ((line[0] == ' ') || (line[0] == '\t')) - strcpy(line, (line + 1)); // Whitespaces entfernen + 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(), '\t'), temp.end()); // remove tabs - return (atof(line)); // Umwandlung in double + return std::stod(temp); } /*==========================================================*/ -// [9.9.2002] +// last change [29.6.2021] at [13:52] // liefert string-Wert der hinter dem uebergebenen char feld in der datei infile steht // zudem wird der wert in die uebergebene variable value uebertragen (falls man das ergebniss als char benoetig) string UbFileInputASCII::readStringAfterString(const string &var) //,char *value) @@ -207,15 +244,13 @@ 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 - strcpy(line, (line + strlen(var.c_str()))); // zeile um "varname" kuerzen - while ((line[0] == ' ') || (line[0] == '\t')) - strcpy(line, (line + 1)); // Whitespaces entfernen + std::string temp{ line }; + temp = temp.substr(var.size()); // zeile um "varname" kuerzen - char *p; - p = strtok(line, " "); // schneidet alles "ab und inklusive space " nach namen ab - p = strtok(line, "\t"); // schneidet alles "ab und inklusive tab " nach namen ab + 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 static_cast<string>(p); // Umwandlung in string + return temp; } /*==========================================================*/ // last change [10.3.2004] at [9:46] 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/UbFileInputASCIITest.cfg b/src/basics/basics/utilities/UbFileInputASCIITest.cfg new file mode 100644 index 0000000000000000000000000000000000000000..294d58cd2eae2819366e4f9cb2e49195e4fd518a --- /dev/null +++ b/src/basics/basics/utilities/UbFileInputASCIITest.cfg @@ -0,0 +1 @@ +test = 1 diff --git a/src/basics/basics/utilities/UbFileInputASCIITest.cpp b/src/basics/basics/utilities/UbFileInputASCIITest.cpp new file mode 100644 index 0000000000000000000000000000000000000000..87cb5ce58eb359239d3c3e29babf04e600edc64c --- /dev/null +++ b/src/basics/basics/utilities/UbFileInputASCIITest.cpp @@ -0,0 +1,18 @@ +#include <gmock/gmock.h> +#include <filesystem> + +#include <basics/utilities/UbFileInputASCII.h> + + +TEST(UbFileInputASCIITest, readIntegerAfterString) +{ + // assuming that the config files is stored parallel to this file. + std::filesystem::path filePath = __FILE__; + filePath.replace_filename("UbFileInputASCIITest.cfg"); + + UbFileInputASCII sut {filePath.string()}; + + const int actual = sut.readIntegerAfterString("test ="); + + EXPECT_THAT(actual, testing::Eq(1)); +} 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/config/ConfigurationFile.cpp b/src/basics/config/ConfigurationFile.cpp new file mode 100644 index 0000000000000000000000000000000000000000..026d13e15486c46a7056e061ea075a03c9c06f9f --- /dev/null +++ b/src/basics/config/ConfigurationFile.cpp @@ -0,0 +1,133 @@ +#include "ConfigurationFile.h" + + +#include <map> +#include <vector> +#include <sstream> +#include <string> +#include <fstream> +#include <iostream> +#include <stdlib.h> + +#include <basics/basics/utilities/UbException.h> + + +namespace vf::basics +{ + +void ConfigurationFile::clear() +{ + data.clear(); +} +////////////////////////////////////////////////////////////////////////// +bool ConfigurationFile::load(const std::string& file) +{ + std::ifstream inFile(file.c_str()); + + if (!inFile.good()) + { + UB_THROW(UbException(UB_EXARGS, "Cannot read configuration file "+file+"!")); + } + + while (inFile.good() && ! inFile.eof()) + { + std::string line; + getline(inFile, line); + + // filter out comments + if (!line.empty()) + { + size_t pos = line.find('#'); + + if (pos != std::string::npos) + { + line = line.substr(0, pos); + } + } + + // split line into key and value + if (!line.empty()) + { + size_t pos = line.find('='); + + if (pos != std::string::npos) + { + std::string key = trim(line.substr(0, pos)); + std::string value = trim(line.substr(pos + 1)); + + if (!key.empty() && !value.empty()) + { + data[key] = value; + } + } + } + } + + return true; +} + +////////////////////////////////////////////////////////////////////////// +template<> +bool ConfigurationFile::fromString<bool>(const std::string& str) const +{ + return str == "true"; +} + +////////////////////////////////////////////////////////////////////////// +bool ConfigurationFile::contains(const std::string& key) const +{ + return data.find(key) != data.end(); +} +////////////////////////////////////////////////////////////////////////// +std::string ConfigurationFile::getString(const std::string& key) const +{ + std::map<std::string, std::string>::const_iterator iter = data.find(key); + + if (iter != data.end()) + { + std::string value = iter->second; + return value; + } + else + { + UB_THROW(UbException(UB_EXARGS, "The parameter \"" + key + "\" is missing!")); + } +} +////////////////////////////////////////////////////////////////////////// +std::string ConfigurationFile::trim(const std::string& str) +{ + size_t first = str.find_first_not_of(" \t\n\r"); + + if (first != std::string::npos) + { + size_t last = str.find_last_not_of(" \t\n\r"); + + return str.substr(first, last - first + 1); + } + else + { + return ""; + } +} +////////////////////////////////////////////////////////////////////////// +void ConfigurationFile::split(std::vector<std::string>& lst, const std::string& input, const std::string& separators, bool remove_empty) const +{ + std::ostringstream word; + for (size_t n = 0; n < input.size(); ++n) + { + if (std::string::npos == separators.find(input[n])) + word << input[n]; + else + { + if (!word.str().empty() || !remove_empty) + lst.push_back(word.str()); + word.str(""); + } + } + if (!word.str().empty() || !remove_empty) + lst.push_back(word.str()); +} +////////////////////////////////////////////////////////////////////////// + + +} diff --git a/src/cpu/VirtualFluidsCore/Utilities/ConfigurationFile.hpp b/src/basics/config/ConfigurationFile.h similarity index 54% rename from src/cpu/VirtualFluidsCore/Utilities/ConfigurationFile.hpp rename to src/basics/config/ConfigurationFile.h index 5c8050826f0ac580f83fc29e51da883469d8d6e2..ef7e7c9f06f94cabb3ba9cbefe95c8ee75736958 100644 --- a/src/cpu/VirtualFluidsCore/Utilities/ConfigurationFile.hpp +++ b/src/basics/config/ConfigurationFile.h @@ -1,5 +1,5 @@ -#ifndef Configuration_h__ -#define Configuration_h__ +#ifndef BASICS_CONFIGURATIONFILE_H +#define BASICS_CONFIGURATIONFILE_H #include <map> #include <vector> @@ -9,6 +9,8 @@ #include <iostream> #include <stdlib.h> +#include <basics/basics/utilities/UbException.h> + //! \brief Simple configuration file //! \details The Configuration class presented here can read and keep values of any configuration file written in a format like this: //!# @@ -37,6 +39,11 @@ //! //! \author Konstantin Kutscher + +namespace vf::basics +{ + + class ConfigurationFile { public: @@ -75,96 +82,6 @@ private: }; -// ---------------------------------- -// method implementations -// ---------------------------------- - -void ConfigurationFile::clear() -{ - data.clear(); -} -////////////////////////////////////////////////////////////////////////// -bool ConfigurationFile::load(const std::string& file) -{ - std::ifstream inFile(file.c_str()); - - if (!inFile.good()) - { - UB_THROW(UbException(UB_EXARGS, "Cannot read configuration file "+file+"!")); - } - - while (inFile.good() && ! inFile.eof()) - { - std::string line; - getline(inFile, line); - - // filter out comments - if (!line.empty()) - { - size_t pos = line.find('#'); - - if (pos != std::string::npos) - { - line = line.substr(0, pos); - } - } - - // split line into key and value - if (!line.empty()) - { - size_t pos = line.find('='); - - if (pos != std::string::npos) - { - std::string key = trim(line.substr(0, pos)); - std::string value = trim(line.substr(pos + 1)); - - if (!key.empty() && !value.empty()) - { - data[key] = value; - } - } - } - } - - return true; -} -////////////////////////////////////////////////////////////////////////// -bool ConfigurationFile::contains(const std::string& key) const -{ - return data.find(key) != data.end(); -} -////////////////////////////////////////////////////////////////////////// -std::string ConfigurationFile::getString(const std::string& key) const -{ - std::map<std::string, std::string>::const_iterator iter = data.find(key); - - if (iter != data.end()) - { - std::string value = iter->second; - return value; - } - else - { - UB_THROW(UbException(UB_EXARGS, "The parameter \"" + key + "\" is missing!")); - } -} -////////////////////////////////////////////////////////////////////////// -std::string ConfigurationFile::trim(const std::string& str) -{ - size_t first = str.find_first_not_of(" \t\n\r"); - - if (first != std::string::npos) - { - size_t last = str.find_last_not_of(" \t\n\r"); - - return str.substr(first, last - first + 1); - } - else - { - return ""; - } -} ////////////////////////////////////////////////////////////////////////// template<class T> std::vector<T> ConfigurationFile::getVector(const std::string& key) const @@ -183,38 +100,18 @@ std::vector<T> ConfigurationFile::getVector(const std::string& key) const return v; } ////////////////////////////////////////////////////////////////////////// -void ConfigurationFile::split(std::vector<std::string>& lst, const std::string& input, const std::string& separators, bool remove_empty) const -{ - std::ostringstream word; - for (size_t n = 0; n < input.size(); ++n) - { - if (std::string::npos == separators.find(input[n])) - word << input[n]; - else - { - if (!word.str().empty() || !remove_empty) - lst.push_back(word.str()); - word.str(""); - } - } - if (!word.str().empty() || !remove_empty) - lst.push_back(word.str()); -} -////////////////////////////////////////////////////////////////////////// template<class T> T ConfigurationFile::fromString(const std::string& str) const { - //boolean hack - if (str == "true") - return true; - else if (str == "false") - return false; - ////////////// std::istringstream stream(str); T t; stream >> t; return t; } + +template<> +bool ConfigurationFile::fromString<bool>(const std::string& str) const; + ////////////////////////////////////////////////////////////////////////// template<class T> T ConfigurationFile::getValue(const std::string& key) const @@ -225,7 +122,7 @@ T ConfigurationFile::getValue(const std::string& key) const { bFlag = true; } - + std::istringstream iss(str); T x; iss >> x; @@ -240,4 +137,7 @@ T ConfigurationFile::getValue(const std::string& key) const return x; } -#endif // Configuration_h__ + +} + +#endif 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 92442dd542840595d1ddf07f86e9add0a083c965..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> @@ -1112,22 +1143,23 @@ void GbTriFaceMesh3D::readMeshFromSTLFileBinary(string filename, bool removeRedu } char title[80]; int nFaces; - fread(title, 80, 1, f); - fread((void *)&nFaces, 4, 1, f); + 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) { - fread((void *)&v[j], sizeof(float), 1, f); + sizef = fread((void *)&v[j], sizeof(float), 1, f); } - fread((void *)&uint16, sizeof(unsigned short), 1, f); // spacer between successive faces + 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 ba4b3b420e7ac25c79b870d6472716e392409437..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 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 7edd56779f580063c0b95cfc6d6ff452d7954883..a7e4e798bc68d14967d1351bcb011bdca51ff84f 100644 --- a/src/cpu/VirtualFluids.h +++ b/src/cpu/VirtualFluids.h @@ -40,8 +40,15 @@ #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> #include <basics/container/CbArray4D.h> @@ -137,6 +144,7 @@ #include <BoundaryConditions/MultiphaseNonReflectingOutflowBCAlgorithm.h> #include <BoundaryConditions/MultiphaseVelocityBCAdapter.h> #include <BoundaryConditions/MultiphaseVelocityBCAlgorithm.h> +#include <BoundaryConditions/MultiphaseSlipBCAlgorithm.h> #include <Connectors/Block3DConnector.h> //#include <Connectors/Block3DConnectorFactory.h> @@ -247,6 +255,8 @@ #include <LBM/MultiphaseTwoPhaseFieldsCumulantLBMKernel.h> #include <LBM/MultiphaseTwoPhaseFieldsVelocityCumulantLBMKernel.h> #include <LBM/MultiphaseTwoPhaseFieldsPressureFilterLBMKernel.h> +#include <LBM/MultiphasePressureFilterLBMKernel.h> +#include <LBM/MultiphasePressureFilterCompressibleAirLBMKernel.h> @@ -284,17 +294,13 @@ #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> #include <Utilities/ChangeRandomQs.hpp> #include <Utilities/CheckpointConverter.h> -#include <Utilities/ConfigurationFile.hpp> #include <Utilities/MathUtil.hpp> #include <Utilities/MemoryUtil.h> #include <Utilities/VoxelMatrixUtil.hpp> diff --git a/src/cpu/VirtualFluidsCore/CMakeLists.txt b/src/cpu/VirtualFluidsCore/CMakeLists.txt index 09766e266935ed1c7d89223c0713363f4df5edcf..15cdceffd99515f84d60c4b6169e2da7e74ecfc3 100644 --- a/src/cpu/VirtualFluidsCore/CMakeLists.txt +++ b/src/cpu/VirtualFluidsCore/CMakeLists.txt @@ -25,7 +25,7 @@ if(BUILD_USE_OPENMP) list(APPEND VF_LIBRARIES OpenMP::OpenMP_CXX) endif() -vf_add_library(BUILDTYPE static PUBLIC_LINK basics muparser MPI::MPI_CXX ${VF_LIBRARIES}) +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 34df7bd4b0030ace10efd8a16ae383beeee72d84..fee4aaf3f413d260aeeebc824469466ca6c475a9 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), torqueX1global(0), torqueX2global(0), torqueX3global(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), torqueX1global(0), torqueX2global(0), torqueX3global(0) { if (comm->getProcessID() == comm->getRoot()) { diff --git a/src/cpu/VirtualFluidsCore/CoProcessors/CalculateTorqueCoProcessor.h b/src/cpu/VirtualFluidsCore/CoProcessors/CalculateTorqueCoProcessor.h index 2b6651e6699c7a2bbf46dbcf44212ccbc2ec8dbe..872bccdc4c1098bb3d33c0efe6c996e96152439e 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 torqueX1global; double torqueX2global; 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 c9252eb243697e62e0092adc4dd88ec2e38973ce..cb2fd908ff78803e4262ae64e906b8dad3c14dff 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 1ef3f3bc0eed0a9ca9ecd14a019edd0cdd0729db..70bde9e97c2928f7c91a347653dbcfaff9c5e501 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"); @@ -203,7 +203,8 @@ void MPIIOCoProcessor::writeBlocks(int step) if (rc != MPI_SUCCESS) throw UbException(UB_EXARGS, "couldn't open file " + filename); - double start, finish; + double start {0.}; + double finish {0.}; MPI_Offset write_offset = (MPI_Offset)(size * sizeof(int)); if (comm->isRoot()) { @@ -240,7 +241,9 @@ void MPIIOCoProcessor::readBlocks(int step) UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / 1073741824.0 << " GB"); } - double start, finish; + + double start {0.}; + double finish {0.}; if (comm->isRoot()) start = MPI_Wtime(); 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 8e1aa0f522a783dba8a006ab31db53fb6baa7655..384150ed680329aaad2ecf871f57a70ee2a177e2 100644 --- a/src/cpu/VirtualFluidsCore/CoProcessors/MPIIOMigrationBECoProcessor.cpp +++ b/src/cpu/VirtualFluidsCore/CoProcessors/MPIIOMigrationBECoProcessor.cpp @@ -3,14 +3,14 @@ #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" #include "DataSet3D.h" #include "Grid3D.h" #include "LBMKernel.h" -#include "MetisPartitioningGridVisitor.h" +#include "Grid3DVisitor.h" #include "PointerDefinitions.h" #include "RenumberGridVisitor.h" #include "UbFileInputASCII.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, SPtr<Grid3DVisitor> mV, const std::string &path, SPtr<Communicator> comm) +MPIIOMigrationBECoProcessor::MPIIOMigrationBECoProcessor(SPtr<Grid3D> grid, SPtr<UbScheduler> s, SPtr<Grid3DVisitor> mV, 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)); @@ -114,7 +114,7 @@ void MPIIOMigrationBECoProcessor::writeDataSet(int step) } dataSetParam dataSetParamStr1, dataSetParamStr2, dataSetParamStr3; - int firstGlobalID; + int firstGlobalID {0}; std::vector<double> doubleValuesArrayF; // double-values (arrays of f's) in all blocks Fdistribution std::vector<double> doubleValuesArrayH1; // double-values (arrays of f's) in all blocks H1distribution std::vector<double> doubleValuesArrayH2; // double-values (arrays of f's) in all blocks H2distribution @@ -289,7 +289,9 @@ void MPIIOMigrationBECoProcessor::writeDataSet(int step) UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / 1073741824.0 << " GB"); } - double start, finish; + + double start {0.}; + double finish {0.}; if (comm->isRoot()) start = MPI_Wtime(); @@ -415,7 +417,7 @@ void MPIIOMigrationBECoProcessor::write4DArray(int step, Arrays arrayType, std:: blocksCount += static_cast<int>(blocksVector[level].size()); } - int firstGlobalID; + int firstGlobalID {0}; std::vector<double> doubleValuesArray; // double-values of the data array in all blocks dataSetParam dataSetParamStr; bool firstBlock = true; @@ -486,7 +488,9 @@ void MPIIOMigrationBECoProcessor::write4DArray(int step, Arrays arrayType, std:: MPI_Type_contiguous(doubleCountInBlock, MPI_DOUBLE, &dataSetDoubleType); MPI_Type_commit(&dataSetDoubleType); - double start, finish; + + double start {0.}; + double finish {0.}; if (comm->isRoot()) start = MPI_Wtime(); @@ -532,7 +536,7 @@ void MPIIOMigrationBECoProcessor::write3DArray(int step, Arrays arrayType, std:: blocksCount += static_cast<int>(blocksVector[level].size()); } - int firstGlobalID; + int firstGlobalID {0}; std::vector<double> doubleValuesArray; // double-values of the data array in all blocks dataSetParam dataSetParamStr; bool firstBlock = true; @@ -598,7 +602,9 @@ void MPIIOMigrationBECoProcessor::write3DArray(int step, Arrays arrayType, std:: MPI_Type_contiguous(doubleCountInBlock, MPI_DOUBLE, &dataSetDoubleType); MPI_Type_commit(&dataSetDoubleType); - double start, finish; + + double start {0.}; + double finish {0.}; if (comm->isRoot()) start = MPI_Wtime(); @@ -738,7 +744,9 @@ void MPIIOMigrationBECoProcessor::writeBoundaryConds(int step) UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / 1073741824.0 << " GB"); } - double start, finish; + + double start {0.}; + double finish {0.}; if (comm->isRoot()) start = MPI_Wtime(); @@ -1019,7 +1027,9 @@ void MPIIOMigrationBECoProcessor::readDataSet(int step) int indexB = rank * blocksPerProcess; // the first "my" block int indexE = indexB + int(myBlocksCount); // the latest "my" block - double start, finish; + + double start {0.}; + double finish {0.}; if (comm->isRoot()) start = MPI_Wtime(); @@ -1292,7 +1302,9 @@ void MPIIOMigrationBECoProcessor::readArray(int step, Arrays arrType, std::strin UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / 1073741824.0 << " GB"); } - double start, finish; + + double start {0.}; + double finish {0.}; if (comm->isRoot()) start = MPI_Wtime(); @@ -1446,7 +1458,9 @@ void MPIIOMigrationBECoProcessor::readBoundaryConds(int step) UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / 1073741824.0 << " GB"); } - double start, finish; + + double start {0.}; + double finish {0.}; if (comm->isRoot()) start = MPI_Wtime(); diff --git a/src/cpu/VirtualFluidsCore/CoProcessors/MPIIOMigrationBECoProcessor.h b/src/cpu/VirtualFluidsCore/CoProcessors/MPIIOMigrationBECoProcessor.h index ee8766eebaa5e3baa41ddb35270cdbfe4670db1f..5fbfea3717a2a8f30b9e22dca1e8f0c5e8729a2b 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; class Grid3DVisitor; @@ -31,7 +31,8 @@ class MPIIOMigrationBECoProcessor : public MPIIOCoProcessor }; public: - MPIIOMigrationBECoProcessor(SPtr<Grid3D> grid, SPtr<UbScheduler> s, SPtr<Grid3DVisitor> mV, const std::string &path, SPtr<Communicator> comm); + MPIIOMigrationBECoProcessor(SPtr<Grid3D> grid, SPtr<UbScheduler> s, SPtr<Grid3DVisitor> mV, const std::string &path, + std::shared_ptr<vf::mpi::Communicator> comm); ~MPIIOMigrationBECoProcessor() override; //! Each timestep writes the grid into the files void process(double step) override; @@ -78,10 +79,6 @@ public: void blocksExchange(int tagN, int ind1, int ind2, int doubleCountInBlock, std::vector<double> &pV, std::vector<double> *rawDataReceive); -protected: - // std::string path; - // SPtr<Communicator> comm; - private: // MPI_Datatype gridParamType, block3dType; // MPI_Datatype dataSetType, dataSetSmallType; @@ -98,6 +95,7 @@ private: double nuL; double nuG; double densityRatio; + }; #endif diff --git a/src/cpu/VirtualFluidsCore/CoProcessors/MPIIOMigrationCoProcessor.cpp b/src/cpu/VirtualFluidsCore/CoProcessors/MPIIOMigrationCoProcessor.cpp index 7992bc08f1a9afaed8eba5d4f3d96c1137cbf89f..ca64b0e48c9a6fa4a159e73eb66e8d97159ffd88 100644 --- a/src/cpu/VirtualFluidsCore/CoProcessors/MPIIOMigrationCoProcessor.cpp +++ b/src/cpu/VirtualFluidsCore/CoProcessors/MPIIOMigrationCoProcessor.cpp @@ -3,14 +3,14 @@ #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" #include "DataSet3D.h" #include "Grid3D.h" #include "LBMKernel.h" -#include "MetisPartitioningGridVisitor.h" +#include "Grid3DVisitor.h" #include "PointerDefinitions.h" #include "RenumberBlockVisitor.h" #include "UbFileInputASCII.h" @@ -22,7 +22,7 @@ using namespace MPIIODataStructures; -MPIIOMigrationCoProcessor::MPIIOMigrationCoProcessor(SPtr<Grid3D> grid, SPtr<UbScheduler> s, SPtr<Grid3DVisitor> mV, const std::string &path, SPtr<Communicator> comm) +MPIIOMigrationCoProcessor::MPIIOMigrationCoProcessor(SPtr<Grid3D> grid, SPtr<UbScheduler> s, SPtr<Grid3DVisitor> mV, const std::string &path, std::shared_ptr<vf::mpi::Communicator> comm) : MPIIOCoProcessor(grid, s, path, comm) { memset(&boundCondParamStr, 0, sizeof(boundCondParamStr)); @@ -328,7 +328,8 @@ void MPIIOMigrationCoProcessor::writeDataSet(int step) UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / 1073741824.0 << " GB"); } - double start, finish; + double start {0.}; + double finish {0.}; if (comm->isRoot()) start = MPI_Wtime(); @@ -541,7 +542,9 @@ void MPIIOMigrationCoProcessor::write4DArray(int step, Arrays arrayType, std::st UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / 1073741824.0 << " GB"); } - double start, finish; + + double start {0.}; + double finish {0.}; if (comm->isRoot()) start = MPI_Wtime(); @@ -666,7 +669,9 @@ void MPIIOMigrationCoProcessor::write3DArray(int step, Arrays arrayType, std::st UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / 1073741824.0 << " GB"); } - double start, finish; + + double start {0.}; + double finish {0.}; if (comm->isRoot()) start = MPI_Wtime(); @@ -823,7 +828,9 @@ void MPIIOMigrationCoProcessor::writeBoundaryConds(int step) UBLOG(logINFO, "Physical Memory currently used by current process: "<< Utilities::getPhysMemUsedByMe() / 1073741824.0 << " GB"); } - double start, finish; + + double start {0.}; + double finish {0.}; if (comm->isRoot()) start = MPI_Wtime(); @@ -934,7 +941,9 @@ void MPIIOMigrationCoProcessor::readDataSet(int step) UBLOG(logINFO, "MPIIOMigrationCoProcessor::readDataSet start MPI IO rank = " << rank); UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / 1073741824.0 << " GB"); } - double start, finish; + + double start {0.}; + double finish {0.}; if (comm->isRoot()) start = MPI_Wtime(); @@ -1217,7 +1226,9 @@ void MPIIOMigrationCoProcessor::readArray(int step, Arrays arrType, std::string UBLOG(logINFO, "MPIIOMigrationCoProcessor::readArray start MPI IO rank = " << rank); UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / 1073741824.0 << " GB"); } - double start, finish; + + double start {0.}; + double finish {0.}; if (comm->isRoot()) start = MPI_Wtime(); @@ -1367,7 +1378,9 @@ void MPIIOMigrationCoProcessor::readBoundaryConds(int step) UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / 1073741824.0 << " GB"); } - double start, finish; + + double start {0.}; + double finish {0.}; if (comm->isRoot()) start = MPI_Wtime(); diff --git a/src/cpu/VirtualFluidsCore/CoProcessors/MPIIOMigrationCoProcessor.h b/src/cpu/VirtualFluidsCore/CoProcessors/MPIIOMigrationCoProcessor.h index b2a0b029db37c4b1c6b81bf206316b03d36ab01b..b822b783edd3628f947aadf20d6dc6109e9e3c31 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; class Grid3DVisitor; @@ -31,7 +31,7 @@ public: PressureField = 9 }; - MPIIOMigrationCoProcessor(SPtr<Grid3D> grid, SPtr<UbScheduler> s, SPtr<Grid3DVisitor> mV, const std::string &path, SPtr<Communicator> comm); + MPIIOMigrationCoProcessor(SPtr<Grid3D> grid, SPtr<UbScheduler> s, SPtr<Grid3DVisitor> mV, 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,10 +73,6 @@ public: void clearAllFiles(int step); // void setNu(double nu); -protected: - // std::string path; - // SPtr<Communicator> comm; - private: // MPI_Datatype gridParamType, block3dType; MPI_Datatype dataSetType, dataSetSmallType, dataSetDoubleType; @@ -85,7 +81,6 @@ private: MPIIODataStructures::boundCondParam boundCondParamStr; SPtr<LBMKernel> lbmKernel; SPtr<BCProcessor> bcProcessor; - // double nue; SPtr<Grid3DVisitor> metisVisitor; }; diff --git a/src/cpu/VirtualFluidsCore/CoProcessors/MPIIORestartCoProcessor.cpp b/src/cpu/VirtualFluidsCore/CoProcessors/MPIIORestartCoProcessor.cpp index 4f7abd24116767d3fc73cedb6399d0bfbf4e0ace..90f393d0f83ad610da21b803a8c15a445a7811dc 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)); @@ -351,7 +351,9 @@ void MPIIORestartCoProcessor::writeDataSet(int step) } } - double start, finish; + + double start {0.}; + double finish {0.}; if (comm->isRoot()) start = MPI_Wtime(); @@ -557,7 +559,9 @@ void MPIIORestartCoProcessor::writeAverageDensityArray(int step) } } - double start, finish; + + double start {0.}; + double finish {0.}; if (comm->isRoot()) start = MPI_Wtime(); @@ -692,7 +696,9 @@ void MPIIORestartCoProcessor::writeAverageVelocityArray(int step) } } - double start, finish; + + double start {0.}; + double finish {0.}; if (comm->isRoot()) start = MPI_Wtime(); @@ -828,7 +834,9 @@ void MPIIORestartCoProcessor::writeAverageFluktuationsArray(int step) } } - double start, finish; + + double start {0.}; + double finish {0.}; if (comm->isRoot()) start = MPI_Wtime(); @@ -965,7 +973,9 @@ void MPIIORestartCoProcessor::writeAverageTripleArray(int step) } } - double start, finish; + + double start {0.}; + double finish {0.}; if (comm->isRoot()) start = MPI_Wtime(); @@ -1102,7 +1112,9 @@ void MPIIORestartCoProcessor::writeShearStressValArray(int step) } } - double start, finish; + + double start {0.}; + double finish {0.}; if (comm->isRoot()) start = MPI_Wtime(); @@ -1240,7 +1252,9 @@ void MPIIORestartCoProcessor::writeRelaxationFactor(int step) } } - double start, finish; + + double start {0.}; + double finish {0.}; if (comm->isRoot()) start = MPI_Wtime(); @@ -1379,7 +1393,9 @@ void MPIIORestartCoProcessor::writePhaseField(int step, int fieldN) } } - double start, finish; + + double start {0.}; + double finish {0.}; if (comm->isRoot()) start = MPI_Wtime(); @@ -1569,7 +1585,9 @@ void MPIIORestartCoProcessor::writeBoundaryConds(int step) UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / 1073741824.0 << " GB"); } - double start, finish; + + double start {0.}; + double finish {0.}; if (comm->isRoot()) start = MPI_Wtime(); @@ -1658,7 +1676,9 @@ void MPIIORestartCoProcessor::readDataSet(int step) UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / 1073741824.0 << " GB"); } - double start, finish; + + double start {0.}; + double finish {0.}; if (comm->isRoot()) start = MPI_Wtime(); @@ -1908,7 +1928,9 @@ void MPIIORestartCoProcessor::readAverageDensityArray(int step) UBLOG(logINFO, "MPIIORestartCoProcessor::readAverageDensityArray start MPI IO rank = " << rank); UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / 1073741824.0 << " GB"); } - double start, finish; + + double start {0.}; + double finish {0.}; if (comm->isRoot()) start = MPI_Wtime(); @@ -2007,7 +2029,9 @@ void MPIIORestartCoProcessor::readAverageVelocityArray(int step) UBLOG(logINFO, "MPIIORestartCoProcessor::readAverageVelocityArray start MPI IO rank = " << rank); UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / 1073741824.0 << " GB"); } - double start, finish; + + double start {0.}; + double finish {0.}; if (comm->isRoot()) start = MPI_Wtime(); @@ -2104,7 +2128,9 @@ void MPIIORestartCoProcessor::readAverageFluktuationsArray(int step) UBLOG(logINFO, "MPIIORestartCoProcessor::readAverageFluktuationsArray start MPI IO rank = " << rank); UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / 1073741824.0 << " GB"); } - double start, finish; + + double start {0.}; + double finish {0.}; if (comm->isRoot()) start = MPI_Wtime(); @@ -2202,7 +2228,9 @@ void MPIIORestartCoProcessor::readAverageTripleArray(int step) UBLOG(logINFO, "MPIIORestartCoProcessor::readAverageTripleArray start MPI IO rank = " << rank); UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / 1073741824.0 << " GB"); } - double start, finish; + + double start {0.}; + double finish {0.}; if (comm->isRoot()) start = MPI_Wtime(); @@ -2299,7 +2327,9 @@ void MPIIORestartCoProcessor::readShearStressValArray(int step) UBLOG(logINFO, "MPIIORestartCoProcessor::readShearStressValArray start MPI IO rank = " << rank); UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / 1073741824.0 << " GB"); } - double start, finish; + + double start {0.}; + double finish {0.}; if (comm->isRoot()) start = MPI_Wtime(); @@ -2396,7 +2426,9 @@ void MPIIORestartCoProcessor::readRelaxationFactor(int step) UBLOG(logINFO, "MPIIORestartCoProcessor::readRelaxationFactor start MPI IO rank = " << rank); UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / 1073741824.0 << " GB"); } - double start, finish; + + double start {0.}; + double finish {0.}; if (comm->isRoot()) start = MPI_Wtime(); @@ -2493,7 +2525,9 @@ void MPIIORestartCoProcessor::readPhaseField(int step, int fieldN) UBLOG(logINFO, "MPIIORestartCoProcessor::readPhaseField start MPI IO rank = " << rank); UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / 1073741824.0 << " GB"); } - double start, finish; + + double start {0.}; + double finish {0.}; if (comm->isRoot()) start = MPI_Wtime(); @@ -2598,7 +2632,9 @@ void MPIIORestartCoProcessor::readBoundaryConds(int step) UBLOG(logINFO, "MPIIORestartCoProcessor::readBoundaryConds start MPI IO rank = " << rank); UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / 1073741824.0 << " GB"); } - double start, finish; + + double start {0.}; + double finish {0.}; if (comm->isRoot()) start = MPI_Wtime(); diff --git a/src/cpu/VirtualFluidsCore/CoProcessors/MPIIORestartCoProcessor.h b/src/cpu/VirtualFluidsCore/CoProcessors/MPIIORestartCoProcessor.h index 57f559769a06d9a87a968ada73fbaba712da789b..beae84af94809e4ffb84fffa19d637afec53f188 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; @@ -60,10 +60,6 @@ public: //! The function truncates the data files void clearAllFiles(int step); -protected: - // std::string path; - // SPtr<Communicator> comm; - private: // MPI_Datatype gridParamType, block3dType; MPI_Datatype dataSetType, dataSetSmallType, dataSetDoubleType; 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 b350f441b3b237032ca24cd4a3743c3cf629a89e..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(); @@ -42,8 +42,8 @@ void PressureCoefficientCoProcessor::collectData(double step) ////////////////////////////////////////////////////////////////////////// void PressureCoefficientCoProcessor::calculateRho() { - double f[D3Q27System::ENDF + 1]; - double vx1, vx2, vx3, rho; + LBMReal f[D3Q27System::ENDF + 1]; + LBMReal vx1, vx2, vx3, rho; std::vector<double> values; std::vector<double> rvalues; 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 700722238b8b8a1ca99ec86b06025e51fd0e258c..d2874876ee9b36b9a17a6c4dcf88c4c7d0e948cb 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), @@ -384,7 +384,7 @@ void TimeAveragedValuesCoProcessor::calculateAverageValues(double timeSteps) maxX2 -= 2; maxX3 -= 2; - LBMReal rho, ux, uy, uz, uxx, uzz, uyy, uxy, uxz, uyz, rhof; + LBMReal rho {0.}, ux {0.}, uy {0.}, uz {0.}, uxx {0.}, uzz {0.}, uyy {0.}, uxy {0.}, uxz {0.}, uyz {0.}, rhof {0.}; for (int ix3 = minX3; ix3 <= maxX3; ix3++) { for (int ix2 = minX2; ix2 <= maxX2; ix2++) { 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/WriteMacroscopicQuantitiesPlusMassCoProcessor.cpp b/src/cpu/VirtualFluidsCore/CoProcessors/WriteMacroscopicQuantitiesPlusMassCoProcessor.cpp index f67750dd7fbb8624c8c3cdd91d7812d0d3cb2913..c71a12ee6d7bc17297cca377712b9a6b479bb336 100644 --- a/src/cpu/VirtualFluidsCore/CoProcessors/WriteMacroscopicQuantitiesPlusMassCoProcessor.cpp +++ b/src/cpu/VirtualFluidsCore/CoProcessors/WriteMacroscopicQuantitiesPlusMassCoProcessor.cpp @@ -52,7 +52,7 @@ WriteMacroscopicQuantitiesPlusMassCoProcessor::WriteMacroscopicQuantitiesPlusMas 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/WriteMacroscopicQuantitiesPlusMassCoProcessor.h b/src/cpu/VirtualFluidsCore/CoProcessors/WriteMacroscopicQuantitiesPlusMassCoProcessor.h index b617c912add82810379f140ecd918085a6270be2..07f1a12676902e5964fcb0127203c1b527c89778 100644 --- a/src/cpu/VirtualFluidsCore/CoProcessors/WriteMacroscopicQuantitiesPlusMassCoProcessor.h +++ b/src/cpu/VirtualFluidsCore/CoProcessors/WriteMacroscopicQuantitiesPlusMassCoProcessor.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 WriteMacroscopicQuantitiesPlusMassCoProcessor(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); ~WriteMacroscopicQuantitiesPlusMassCoProcessor() 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 37eb51038c535fb2d6769f9252928a97aff5916a..fc993d95808036d1645e7b1f43fff40336f63641 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/Connectors/TwoDistributionsDoubleGhostLayerFullDirectConnector.cpp b/src/cpu/VirtualFluidsCore/Connectors/TwoDistributionsDoubleGhostLayerFullDirectConnector.cpp new file mode 100644 index 0000000000000000000000000000000000000000..3d0ca3f043225faf0d2831b47ffa35fa27c4d89f --- /dev/null +++ b/src/cpu/VirtualFluidsCore/Connectors/TwoDistributionsDoubleGhostLayerFullDirectConnector.cpp @@ -0,0 +1,315 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// 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 TwoDistributionsDoubleGhostLayerFullDirectConnector.cpp +//! \ingroup Connectors +//! \author Konstantin Kutscher +//======================================================================================= + +#include "TwoDistributionsDoubleGhostLayerFullDirectConnector.h" +#include "LBMKernel.h" +#include "DataSet3D.h" + +TwoDistributionsDoubleGhostLayerFullDirectConnector::TwoDistributionsDoubleGhostLayerFullDirectConnector(SPtr<Block3D> from, SPtr<Block3D> to, int sendDir) + : FullDirectConnector(from, to, sendDir) +{ + +} +////////////////////////////////////////////////////////////////////////// +void TwoDistributionsDoubleGhostLayerFullDirectConnector::init() +{ + FullDirectConnector::init(); + + fFrom =dynamicPointerCast<EsoTwist3D>(from.lock()->getKernel()->getDataSet()->getFdistributions()); + fTo = dynamicPointerCast<EsoTwist3D>(to.lock()->getKernel()->getDataSet()->getFdistributions()); + hFrom = dynamicPointerCast<EsoTwist3D>(from.lock()->getKernel()->getDataSet()->getHdistributions()); + hTo = dynamicPointerCast<EsoTwist3D>(to.lock()->getKernel()->getDataSet()->getHdistributions()); + pressureFrom = from.lock()->getKernel()->getDataSet()->getPressureField(); + pressureTo = to.lock()->getKernel()->getDataSet()->getPressureField(); +} +////////////////////////////////////////////////////////////////////////// +void TwoDistributionsDoubleGhostLayerFullDirectConnector::sendVectors() +{ + updatePointers(); + exchangeData(); +} +////////////////////////////////////////////////////////////////////////// +void TwoDistributionsDoubleGhostLayerFullDirectConnector::exchangeData() +{ + //////////////////////////////////////////////////////////// + // relation between ghost layer and regular nodes + // maxX1m3 maxX1m2 ... minX1p2 minX1p3 - regular nodes + // minX1 minX1p1 ... maxX1m1 maxX1 - ghost layer + //////////////////////////////////////////////////////////// + + int minX1 = 0; + int minX1p1 = minX1 + 1; + int minX1p2 = minX1 + 2; + int minX1p3 = minX1 + 3; + int maxX1m1 = maxX1 - 1; + int maxX1m2 = maxX1 - 2; + int maxX1m3 = maxX1 - 3; + + int minX2 = 0; + int minX2p1 = minX2 + 1; + int minX2p2 = minX2 + 2; + int minX2p3 = minX2 + 3; + int maxX2m1 = maxX2 - 1; + int maxX2m2 = maxX2 - 2; + int maxX2m3 = maxX2 - 3; + + int minX3 = 0; + int minX3p1 = minX3 + 1; + int minX3p2 = minX3 + 2; + int minX3p3 = minX3 + 3; + int maxX3m1 = maxX3 - 1; + int maxX3m2 = maxX3 - 2; + int maxX3m3 = maxX3 - 3; + + // EAST + if (sendDir == D3Q27System::E) { + for (int x3 = minX3p2; x3 <= maxX3m2; x3++) { + for (int x2 = minX2p2; x2 <= maxX2m2; x2++) { + exchangeData(maxX1m3, x2, x3, minX1, x2, x3); + exchangeData(maxX1m2, x2, x3, minX1p1, x2, x3); + } + } + } + // WEST + else if (sendDir == D3Q27System::W) { + for (int x3 = minX3p2; x3 <= maxX3m2; x3++) { + for (int x2 = minX2p2; x2 <= maxX2m2; x2++) { + exchangeData(minX1p3, x2, x3, maxX1, x2, x3); + exchangeData(minX1p2, x2, x3, maxX1m1, x2, x3); + } + } + } + // NORTH + else if (sendDir == D3Q27System::N) { + for (int x3 = minX3p2; x3 <= maxX3m2; x3++) { + for (int x1 = minX1p2; x1 <= maxX1m2; x1++) { + exchangeData(x1, maxX2m3, x3, x1, minX2, x3); + exchangeData(x1, maxX2m2, x3, x1, minX2p1, x3); + } + } + } + // SOUTH + else if (sendDir == D3Q27System::S) { + for (int x3 = minX3p2; x3 <= maxX3m2; x3++) { + for (int x1 = minX1p2; x1 <= maxX1m2; x1++) { + exchangeData(x1, minX2p3, x3, x1, maxX2, x3); + exchangeData(x1, minX2p2, x3, x1, maxX2m1, x3); + } + } + } + + // TOP + else if (sendDir == D3Q27System::T) { + for (int x2 = minX2p2; x2 <= maxX2m2; x2++) { + for (int x1 = minX1p2; x1 <= maxX1m2; x1++) { + exchangeData(x1, x2, maxX3m3, x1, x2, minX3); + exchangeData(x1, x2, maxX3m2, x1, x2, minX3p1); + } + } + } + // BOTTOM + else if (sendDir == D3Q27System::B) { + for (int x2 = minX2p2; x2 <= maxX2m2; x2++) { + for (int x1 = minX1p2; x1 <= maxX1m2; x1++) { + exchangeData(x1, x2, minX3p3, x1, x2, maxX3); + exchangeData(x1, x2, minX3p2, x1, x2, maxX3m1); + } + } + } + // NORTHEAST + else if (sendDir == D3Q27System::NE) { + for (int x3 = minX3p2; x3 <= maxX3m2; x3++) { + exchangeData(maxX1m3, maxX2m3, x3, minX1, minX2, x3); + exchangeData(maxX1m2, maxX2m2, x3, minX1p1, minX2p1, x3); + exchangeData(maxX1m3, maxX2m2, x3, minX1, minX2p1, x3); + exchangeData(maxX1m2, maxX2m3, x3, minX1p1, minX2, x3); + } + } + // NORTHWEST + else if (sendDir == D3Q27System::NW) { + for (int x3 = minX3p2; x3 <= maxX3m2; x3++) { + exchangeData(minX1p3, maxX2m3, x3, maxX1, minX2, x3); + exchangeData(minX1p2, maxX2m2, x3, maxX1m1, minX2p1, x3); + exchangeData(minX1p3, maxX2m2, x3, maxX1, minX2p1, x3); + exchangeData(minX1p2, maxX2m3, x3, maxX1m1, minX2, x3); + } + } + // SOUTHWEST + else if (sendDir == D3Q27System::SW) { + for (int x3 = minX3p2; x3 <= maxX3m2; x3++) { + exchangeData(minX1p3, minX2p3, x3, maxX1, maxX2, x3); + exchangeData(minX1p2, minX2p2, x3, maxX1m1, maxX2m1, x3); + exchangeData(minX1p3, minX2p2, x3, maxX1, maxX2m1, x3); + exchangeData(minX1p2, minX2p3, x3, maxX1m1, maxX2, x3); + } + } + // SOUTHEAST + else if (sendDir == D3Q27System::SE) { + for (int x3 = minX3p2; x3 <= maxX3m2; x3++) { + exchangeData(maxX1m3, minX2p3, x3, minX1, maxX2, x3); + exchangeData(maxX1m2, minX2p2, x3, minX1p1, maxX2m1, x3); + exchangeData(maxX1m3, minX2p2, x3, minX1, maxX2m1, x3); + exchangeData(maxX1m2, minX2p3, x3, minX1p1, maxX2, x3); + } + } else if (sendDir == D3Q27System::TE) + for (int x2 = minX2p2; x2 <= maxX2m2; x2++) { + exchangeData(maxX1m3, x2, maxX3m3, minX1, x2, minX3); + exchangeData(maxX1m2, x2, maxX3m2, minX1p1, x2, minX3p1); + exchangeData(maxX1m3, x2, maxX3m2, minX1, x2, minX3p1); + exchangeData(maxX1m2, x2, maxX3m3, minX1p1, x2, minX3); + } + else if (sendDir == D3Q27System::BW) + for (int x2 = minX2p2; x2 <= maxX2m2; x2++) { + exchangeData(minX1p3, x2, minX3p3, maxX1, x2, maxX3); + exchangeData(minX1p2, x2, minX3p2, maxX1m1, x2, maxX3m1); + exchangeData(minX1p3, x2, minX3p2, maxX1, x2, maxX3m1); + exchangeData(minX1p2, x2, minX3p3, maxX1m1, x2, maxX3); + } + else if (sendDir == D3Q27System::BE) + for (int x2 = minX2p2; x2 <= maxX2m2; x2++) { + exchangeData(maxX1m3, x2, minX3p3, minX1, x2, maxX3); + exchangeData(maxX1m2, x2, minX3p2, minX1p1, x2, maxX3m1); + exchangeData(maxX1m3, x2, minX3p2, minX1, x2, maxX3m1); + exchangeData(maxX1m2, x2, minX3p3, minX1p1, x2, maxX3); + } + else if (sendDir == D3Q27System::TW) + for (int x2 = minX2p2; x2 <= maxX2m2; x2++) { + exchangeData(minX1p3, x2, maxX3m3, maxX1, x2, minX3); + exchangeData(minX1p2, x2, maxX3m2, maxX1m1, x2, minX3p1); + exchangeData(minX1p3, x2, maxX3m2, maxX1, x2, minX3p1); + exchangeData(minX1p2, x2, maxX3m3, maxX1m1, x2, minX3); + } + else if (sendDir == D3Q27System::TN) + for (int x1 = minX1p2; x1 <= maxX1m2; x1++) { + exchangeData(x1, maxX2m3, maxX3m3, x1, minX2, minX3); + exchangeData(x1, maxX2m2, maxX3m2, x1, minX2p1, minX3p1); + exchangeData(x1, maxX2m3, maxX3m2, x1, minX2, minX3p1); + exchangeData(x1, maxX2m2, maxX3m3, x1, minX2p1, minX3); + } + else if (sendDir == D3Q27System::BS) + for (int x1 = minX1p2; x1 <= maxX1m2; x1++) { + exchangeData(x1, minX2p3, minX3p3, x1, maxX2, maxX3); + exchangeData(x1, minX2p2, minX3p2, x1, maxX2m1, maxX3m1); + exchangeData(x1, minX2p3, minX3p2, x1, maxX2, maxX3m1); + exchangeData(x1, minX2p2, minX3p3, x1, maxX2m1, maxX3); + } + else if (sendDir == D3Q27System::BN) + for (int x1 = minX1p2; x1 <= maxX1m2; x1++) { + exchangeData(x1, maxX2m3, minX3p3, x1, minX2, maxX3); + exchangeData(x1, maxX2m2, minX3p2, x1, minX2p1, maxX3m1); + exchangeData(x1, maxX2m3, minX3p2, x1, minX2, maxX3m1); + exchangeData(x1, maxX2m2, minX3p3, x1, minX2p1, maxX3); + } + else if (sendDir == D3Q27System::TS) + for (int x1 = minX1p2; x1 <= maxX1m2; x1++) { + exchangeData(x1, minX2p3, maxX3m3, x1, maxX2, minX3); + exchangeData(x1, minX2p2, maxX3m2, x1, maxX2m1, minX3p1); + exchangeData(x1, minX2p3, maxX3m2, x1, maxX2, minX3p1); + exchangeData(x1, minX2p2, maxX3m3, x1, maxX2m1, minX3); + } + else if (sendDir == D3Q27System::TSW) { + exchangeData(minX1p3, minX2p3, maxX3m3, maxX1, maxX2, minX3); + exchangeData(minX1p2, minX2p2, maxX3m2, maxX1m1, maxX2m1, minX3p1); + exchangeData(minX1p3, minX2p2, maxX3m2, maxX1, maxX2m1, minX3p1); + exchangeData(minX1p2, minX2p3, maxX3m2, maxX1m1, maxX2, minX3p1); + exchangeData(minX1p2, minX2p2, maxX3m3, maxX1m1, maxX2m1, minX3); + exchangeData(minX1p3, minX2p3, maxX3m2, maxX1, maxX2, minX3p1); + exchangeData(minX1p3, minX2p2, maxX3m3, maxX1, maxX2m1, minX3); + exchangeData(minX1p2, minX2p3, maxX3m3, maxX1m1, maxX2, minX3); + } else if (sendDir == D3Q27System::TSE) { + exchangeData(maxX1m3, minX1p3, maxX3m3, minX1, maxX2, minX3); + exchangeData(maxX1m2, minX1p2, maxX3m2, minX1p1, maxX2m1, minX3p1); + exchangeData(maxX1m3, minX1p2, maxX3m2, minX1, maxX2m1, minX3p1); + exchangeData(maxX1m2, minX1p3, maxX3m2, minX1p1, maxX2, minX3p1); + exchangeData(maxX1m2, minX1p2, maxX3m3, minX1p1, maxX2m1, minX3); + exchangeData(maxX1m3, minX1p3, maxX3m2, minX1, maxX2, minX3p1); + exchangeData(maxX1m3, minX1p2, maxX3m3, minX1, maxX2m1, minX3); + exchangeData(maxX1m2, minX1p3, maxX3m3, minX1p1, maxX2, minX3); + } else if (sendDir == D3Q27System::TNW) { + exchangeData(minX1p3, maxX2m3, maxX3m3, maxX1, minX2, minX3); + exchangeData(minX1p2, maxX2m2, maxX3m2, maxX1m1, minX2p1, minX3p1); + exchangeData(minX1p3, maxX2m2, maxX3m2, maxX1, minX2p1, minX3p1); + exchangeData(minX1p2, maxX2m3, maxX3m2, maxX1m1, minX2, minX3p1); + exchangeData(minX1p2, maxX2m2, maxX3m3, maxX1m1, minX2p1, minX3); + exchangeData(minX1p3, maxX2m3, maxX3m2, maxX1, minX2, minX3p1); + exchangeData(minX1p3, maxX2m2, maxX3m3, maxX1, minX2p1, minX3); + exchangeData(minX1p2, maxX2m3, maxX3m3, maxX1m1, minX2, minX3); + } else if (sendDir == D3Q27System::TNE) { + exchangeData(maxX1m3, maxX2m3, maxX3m3, minX1, minX2, minX3); + exchangeData(maxX1m2, maxX2m2, maxX3m2, minX1p1, minX2p1, minX3p1); + exchangeData(maxX1m3, maxX2m2, maxX3m2, minX1, minX2p1, minX3p1); + exchangeData(maxX1m2, maxX2m3, maxX3m2, minX1p1, minX2, minX3p1); + exchangeData(maxX1m2, maxX2m2, maxX3m3, minX1p1, minX2p1, minX3); + exchangeData(maxX1m3, maxX2m3, maxX3m2, minX1, minX2, minX3p1); + exchangeData(maxX1m3, maxX2m2, maxX3m3, minX1, minX2p1, minX3); + exchangeData(maxX1m2, maxX2m3, maxX3m3, minX1p1, minX2, minX3); + } else if (sendDir == D3Q27System::BSW) { + exchangeData(minX1p3, minX2p3, minX3p3, maxX1, maxX2, maxX3); + exchangeData(minX1p2, minX2p2, minX3p2, maxX1m1, maxX2m1, maxX3m1); + exchangeData(minX1p3, minX2p2, minX3p2, maxX1, maxX2m1, maxX3m1); + exchangeData(minX1p2, minX2p3, minX3p2, maxX1m1, maxX2, maxX3m1); + exchangeData(minX1p2, minX2p2, minX3p3, maxX1m1, maxX2m1, maxX3); + exchangeData(minX1p3, minX2p3, minX3p2, maxX1, maxX2, maxX3m1); + exchangeData(minX1p3, minX2p2, minX3p3, maxX1, maxX2m1, maxX3); + exchangeData(minX1p2, minX2p3, minX3p3, maxX1m1, maxX2, maxX3); + } else if (sendDir == D3Q27System::BSE) { + exchangeData(maxX1m3, minX2p3, minX3p3, minX1, maxX2, maxX3); + exchangeData(maxX1m2, minX2p2, minX3p2, minX1p1, maxX2m1, maxX3m1); + exchangeData(maxX1m3, minX2p2, minX3p2, minX1, maxX2m1, maxX3m1); + exchangeData(maxX1m2, minX2p3, minX3p2, minX1p1, maxX2, maxX3m1); + exchangeData(maxX1m2, minX2p2, minX3p3, minX1p1, maxX2m1, maxX3); + exchangeData(maxX1m3, minX2p3, minX3p2, minX1, maxX2, maxX3m1); + exchangeData(maxX1m3, minX2p2, minX3p3, minX1, maxX2m1, maxX3); + exchangeData(maxX1m2, minX2p3, minX3p3, minX1p1, maxX2, maxX3); + } else if (sendDir == D3Q27System::BNW) { + exchangeData(minX1p3, maxX2m3, minX3p3, maxX1, minX2, maxX3); + exchangeData(minX1p2, maxX2m2, minX3p2, maxX1m1, minX2p1, maxX3m1); + exchangeData(minX1p3, maxX2m2, minX3p2, maxX1, minX2p1, maxX3m1); + exchangeData(minX1p2, maxX2m3, minX3p2, maxX1m1, minX2, maxX3m1); + exchangeData(minX1p2, maxX2m2, minX3p3, maxX1m1, minX2p1, maxX3); + exchangeData(minX1p3, maxX2m3, minX3p2, maxX1, minX2, maxX3m1); + exchangeData(minX1p3, maxX2m2, minX3p3, maxX1, minX2p1, maxX3); + exchangeData(minX1p2, maxX2m3, minX3p3, maxX1m1, minX2, maxX3); + } else if (sendDir == D3Q27System::BNE) { + exchangeData(maxX1m3, maxX2m3, minX3p3, minX1, minX2, maxX3); + exchangeData(maxX1m2, maxX2m2, minX3p2, minX1p1, minX2p1, maxX3m1); + exchangeData(maxX1m3, maxX2m2, minX3p2, minX1, minX2p1, maxX3m1); + exchangeData(maxX1m2, maxX2m3, minX3p2, minX1p1, minX2, maxX3m1); + exchangeData(maxX1m2, maxX2m2, minX3p3, minX1p1, minX2p1, maxX3); + exchangeData(maxX1m3, maxX2m3, minX3p2, minX1, minX2, maxX3m1); + exchangeData(maxX1m3, maxX2m2, minX3p3, minX1, minX2p1, maxX3); + exchangeData(maxX1m2, maxX2m3, minX3p3, minX1p1, minX2, maxX3); + } else + UB_THROW(UbException(UB_EXARGS, "unknown dir")); + +} diff --git a/src/cpu/VirtualFluidsCore/Connectors/TwoDistributionsDoubleGhostLayerFullDirectConnector.h b/src/cpu/VirtualFluidsCore/Connectors/TwoDistributionsDoubleGhostLayerFullDirectConnector.h new file mode 100644 index 0000000000000000000000000000000000000000..bc431f9f3bbb16587df76355c395fff780137b22 --- /dev/null +++ b/src/cpu/VirtualFluidsCore/Connectors/TwoDistributionsDoubleGhostLayerFullDirectConnector.h @@ -0,0 +1,167 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// 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 TwoDistributionsDoubleGhostLayerFullDirectConnector.h +//! \ingroup Connectors +//! \author Konstantin Kutscher +//======================================================================================= + +#ifndef TwoDistributionsDoubleGhostLayerFullDirectConnector_H +#define TwoDistributionsDoubleGhostLayerFullDirectConnector_H + +#include "FullDirectConnector.h" +#include "Block3D.h" +#include "D3Q27System.h" +#include "D3Q27EsoTwist3DSplittedVector.h" +#include "basics/container/CbArray3D.h" +#include "basics/container/CbArray4D.h" +#include "DataSet3D.h" + +//! \brief Exchange data between blocks. +//! \details Connector send and receive full distributions between two blocks in shared memory. + +class TwoDistributionsDoubleGhostLayerFullDirectConnector : public FullDirectConnector +{ +public: + TwoDistributionsDoubleGhostLayerFullDirectConnector(SPtr<Block3D> from, SPtr<Block3D> to, int sendDir); + void init() override; + void sendVectors() override; + +protected: + inline void updatePointers() override; + void exchangeData() override; + inline void exchangeData(int x1From, int x2From, int x3From, int x1To, int x2To, int x3To) override; + +private: + CbArray4D <LBMReal, IndexerX4X3X2X1>::CbArray4DPtr localDistributionsFromf; + CbArray4D <LBMReal, IndexerX4X3X2X1>::CbArray4DPtr nonLocalDistributionsFromf; + CbArray3D <LBMReal, IndexerX3X2X1>::CbArray3DPtr zeroDistributionsFromf; + + CbArray4D <LBMReal, IndexerX4X3X2X1>::CbArray4DPtr localDistributionsTof; + CbArray4D <LBMReal, IndexerX4X3X2X1>::CbArray4DPtr nonLocalDistributionsTof; + CbArray3D <LBMReal, IndexerX3X2X1>::CbArray3DPtr zeroDistributionsTof; + + CbArray4D <LBMReal, IndexerX4X3X2X1>::CbArray4DPtr localDistributionsFromh; + CbArray4D <LBMReal, IndexerX4X3X2X1>::CbArray4DPtr nonLocalDistributionsFromh; + CbArray3D <LBMReal, IndexerX3X2X1>::CbArray3DPtr zeroDistributionsFromh; + + CbArray4D <LBMReal, IndexerX4X3X2X1>::CbArray4DPtr localDistributionsToh; + CbArray4D <LBMReal, IndexerX4X3X2X1>::CbArray4DPtr nonLocalDistributionsToh; + CbArray3D <LBMReal, IndexerX3X2X1>::CbArray3DPtr zeroDistributionsToh; + + SPtr<EsoTwist3D> fFrom, hFrom; + SPtr<EsoTwist3D> fTo, hTo; + + SPtr<PressureFieldArray3D> pressureFrom, pressureTo; +}; +////////////////////////////////////////////////////////////////////////// +inline void TwoDistributionsDoubleGhostLayerFullDirectConnector::updatePointers() +{ + localDistributionsFromf = dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(this->fFrom)->getLocalDistributions(); + nonLocalDistributionsFromf = dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(this->fFrom)->getNonLocalDistributions(); + zeroDistributionsFromf = dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(this->fFrom)->getZeroDistributions(); + + localDistributionsTof = dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(this->fTo)->getLocalDistributions(); + nonLocalDistributionsTof = dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(this->fTo)->getNonLocalDistributions(); + zeroDistributionsTof = dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(this->fTo)->getZeroDistributions(); + + localDistributionsFromh = dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(this->hFrom)->getLocalDistributions(); + nonLocalDistributionsFromh = dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(this->hFrom)->getNonLocalDistributions(); + zeroDistributionsFromh = dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(this->hFrom)->getZeroDistributions(); + + localDistributionsToh = dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(this->hTo)->getLocalDistributions(); + nonLocalDistributionsToh = dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(this->hTo)->getNonLocalDistributions(); + zeroDistributionsToh = dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(this->hTo)->getZeroDistributions(); +} +////////////////////////////////////////////////////////////////////////// +inline void TwoDistributionsDoubleGhostLayerFullDirectConnector::exchangeData(int x1From, int x2From, int x3From, int x1To, int x2To, int x3To) +{ + (*this->localDistributionsTof)(D3Q27System::ET_E, x1To, x2To, x3To) = (*this->localDistributionsFromf)(D3Q27System::ET_E, x1From, x2From, x3From); + (*this->localDistributionsTof)(D3Q27System::ET_N, x1To, x2To, x3To) = (*this->localDistributionsFromf)(D3Q27System::ET_N, x1From, x2From, x3From); + (*this->localDistributionsTof)(D3Q27System::ET_T, x1To, x2To, x3To) = (*this->localDistributionsFromf)(D3Q27System::ET_T, x1From, x2From, x3From); + (*this->localDistributionsTof)(D3Q27System::ET_NE, x1To, x2To, x3To) = (*this->localDistributionsFromf)(D3Q27System::ET_NE, x1From, x2From, x3From); + (*this->localDistributionsTof)(D3Q27System::ET_NW, x1To + 1, x2To, x3To) = (*this->localDistributionsFromf)(D3Q27System::ET_NW, x1From + 1, x2From, x3From); + (*this->localDistributionsTof)(D3Q27System::ET_TE, x1To, x2To, x3To) = (*this->localDistributionsFromf)(D3Q27System::ET_TE, x1From, x2From, x3From); + (*this->localDistributionsTof)(D3Q27System::ET_TW, x1To + 1, x2To, x3To) = (*this->localDistributionsFromf)(D3Q27System::ET_TW, x1From + 1, x2From, x3From); + (*this->localDistributionsTof)(D3Q27System::ET_TN, x1To, x2To, x3To) = (*this->localDistributionsFromf)(D3Q27System::ET_TN, x1From, x2From, x3From); + (*this->localDistributionsTof)(D3Q27System::ET_TS, x1To, x2To + 1, x3To) = (*this->localDistributionsFromf)(D3Q27System::ET_TS, x1From, x2From + 1, x3From); + (*this->localDistributionsTof)(D3Q27System::ET_TNE, x1To, x2To, x3To) = (*this->localDistributionsFromf)(D3Q27System::ET_TNE, x1From, x2From, x3From); + (*this->localDistributionsTof)(D3Q27System::ET_TNW, x1To + 1, x2To, x3To) = (*this->localDistributionsFromf)(D3Q27System::ET_TNW, x1From + 1, x2From, x3From); + (*this->localDistributionsTof)(D3Q27System::ET_TSE, x1To, x2To + 1, x3To) = (*this->localDistributionsFromf)(D3Q27System::ET_TSE, x1From, x2From + 1, x3From); + (*this->localDistributionsTof)(D3Q27System::ET_TSW, x1To + 1, x2To + 1, x3To) = (*this->localDistributionsFromf)(D3Q27System::ET_TSW, x1From + 1, x2From + 1, x3From); + + (*this->nonLocalDistributionsTof)(D3Q27System::ET_W, x1To + 1, x2To, x3To) = (*this->nonLocalDistributionsFromf)(D3Q27System::ET_W, x1From + 1, x2From, x3From); + (*this->nonLocalDistributionsTof)(D3Q27System::ET_S, x1To, x2To + 1, x3To) = (*this->nonLocalDistributionsFromf)(D3Q27System::ET_S, x1From, x2From + 1, x3From); + (*this->nonLocalDistributionsTof)(D3Q27System::ET_B, x1To, x2To, x3To + 1) = (*this->nonLocalDistributionsFromf)(D3Q27System::ET_B, x1From, x2From, x3From + 1); + (*this->nonLocalDistributionsTof)(D3Q27System::ET_SW, x1To + 1, x2To + 1, x3To) = (*this->nonLocalDistributionsFromf)(D3Q27System::ET_SW, x1From + 1, x2From + 1, x3From); + (*this->nonLocalDistributionsTof)(D3Q27System::ET_SE, x1To, x2To + 1, x3To) = (*this->nonLocalDistributionsFromf)(D3Q27System::ET_SE, x1From, x2From + 1, x3From); + (*this->nonLocalDistributionsTof)(D3Q27System::ET_BW, x1To + 1, x2To, x3To + 1) = (*this->nonLocalDistributionsFromf)(D3Q27System::ET_BW, x1From + 1, x2From, x3From + 1); + (*this->nonLocalDistributionsTof)(D3Q27System::ET_BE, x1To, x2To, x3To + 1) = (*this->nonLocalDistributionsFromf)(D3Q27System::ET_BE, x1From, x2From, x3From + 1); + (*this->nonLocalDistributionsTof)(D3Q27System::ET_BS, x1To, x2To + 1, x3To + 1) = (*this->nonLocalDistributionsFromf)(D3Q27System::ET_BS, x1From, x2From + 1, x3From + 1); + (*this->nonLocalDistributionsTof)(D3Q27System::ET_BN, x1To, x2To, x3To + 1) = (*this->nonLocalDistributionsFromf)(D3Q27System::ET_BN, x1From, x2From, x3From + 1); + (*this->nonLocalDistributionsTof)(D3Q27System::ET_BSW, x1To + 1, x2To + 1, x3To + 1) = (*this->nonLocalDistributionsFromf)(D3Q27System::ET_BSW, x1From + 1, x2From + 1, x3From + 1); + (*this->nonLocalDistributionsTof)(D3Q27System::ET_BSE, x1To, x2To + 1, x3To + 1) = (*this->nonLocalDistributionsFromf)(D3Q27System::ET_BSE, x1From, x2From + 1, x3From + 1); + (*this->nonLocalDistributionsTof)(D3Q27System::ET_BNW, x1To + 1, x2To, x3To + 1) = (*this->nonLocalDistributionsFromf)(D3Q27System::ET_BNW, x1From + 1, x2From, x3From + 1); + (*this->nonLocalDistributionsTof)(D3Q27System::ET_BNE, x1To, x2To, x3To + 1) = (*this->nonLocalDistributionsFromf)(D3Q27System::ET_BNE, x1From, x2From, x3From + 1); + + (*this->zeroDistributionsTof)(x1To, x2To, x3To) = (*this->zeroDistributionsFromf)(x1From, x2From, x3From); + + + (*this->localDistributionsToh)(D3Q27System::ET_E, x1To, x2To, x3To) = (*this->localDistributionsFromh)(D3Q27System::ET_E, x1From, x2From, x3From); + (*this->localDistributionsToh)(D3Q27System::ET_N, x1To, x2To, x3To) = (*this->localDistributionsFromh)(D3Q27System::ET_N, x1From, x2From, x3From); + (*this->localDistributionsToh)(D3Q27System::ET_T, x1To, x2To, x3To) = (*this->localDistributionsFromh)(D3Q27System::ET_T, x1From, x2From, x3From); + (*this->localDistributionsToh)(D3Q27System::ET_NE, x1To, x2To, x3To) = (*this->localDistributionsFromh)(D3Q27System::ET_NE, x1From, x2From, x3From); + (*this->localDistributionsToh)(D3Q27System::ET_NW, x1To + 1, x2To, x3To) = (*this->localDistributionsFromh)(D3Q27System::ET_NW, x1From + 1, x2From, x3From); + (*this->localDistributionsToh)(D3Q27System::ET_TE, x1To, x2To, x3To) = (*this->localDistributionsFromh)(D3Q27System::ET_TE, x1From, x2From, x3From); + (*this->localDistributionsToh)(D3Q27System::ET_TW, x1To + 1, x2To, x3To) = (*this->localDistributionsFromh)(D3Q27System::ET_TW, x1From + 1, x2From, x3From); + (*this->localDistributionsToh)(D3Q27System::ET_TN, x1To, x2To, x3To) = (*this->localDistributionsFromh)(D3Q27System::ET_TN, x1From, x2From, x3From); + (*this->localDistributionsToh)(D3Q27System::ET_TS, x1To, x2To + 1, x3To) = (*this->localDistributionsFromh)(D3Q27System::ET_TS, x1From, x2From + 1, x3From); + (*this->localDistributionsToh)(D3Q27System::ET_TNE, x1To, x2To, x3To) = (*this->localDistributionsFromh)(D3Q27System::ET_TNE, x1From, x2From, x3From); + (*this->localDistributionsToh)(D3Q27System::ET_TNW, x1To + 1, x2To, x3To) = (*this->localDistributionsFromh)(D3Q27System::ET_TNW, x1From + 1, x2From, x3From); + (*this->localDistributionsToh)(D3Q27System::ET_TSE, x1To, x2To + 1, x3To) = (*this->localDistributionsFromh)(D3Q27System::ET_TSE, x1From, x2From + 1, x3From); + (*this->localDistributionsToh)(D3Q27System::ET_TSW, x1To + 1, x2To + 1, x3To) = (*this->localDistributionsFromh)(D3Q27System::ET_TSW, x1From + 1, x2From + 1, x3From); + + (*this->nonLocalDistributionsToh)(D3Q27System::ET_W, x1To + 1, x2To, x3To) = (*this->nonLocalDistributionsFromh)(D3Q27System::ET_W, x1From + 1, x2From, x3From); + (*this->nonLocalDistributionsToh)(D3Q27System::ET_S, x1To, x2To + 1, x3To) = (*this->nonLocalDistributionsFromh)(D3Q27System::ET_S, x1From, x2From + 1, x3From); + (*this->nonLocalDistributionsToh)(D3Q27System::ET_B, x1To, x2To, x3To + 1) = (*this->nonLocalDistributionsFromh)(D3Q27System::ET_B, x1From, x2From, x3From + 1); + (*this->nonLocalDistributionsToh)(D3Q27System::ET_SW, x1To + 1, x2To + 1, x3To) = (*this->nonLocalDistributionsFromh)(D3Q27System::ET_SW, x1From + 1, x2From + 1, x3From); + (*this->nonLocalDistributionsToh)(D3Q27System::ET_SE, x1To, x2To + 1, x3To) = (*this->nonLocalDistributionsFromh)(D3Q27System::ET_SE, x1From, x2From + 1, x3From); + (*this->nonLocalDistributionsToh)(D3Q27System::ET_BW, x1To + 1, x2To, x3To + 1) = (*this->nonLocalDistributionsFromh)(D3Q27System::ET_BW, x1From + 1, x2From, x3From + 1); + (*this->nonLocalDistributionsToh)(D3Q27System::ET_BE, x1To, x2To, x3To + 1) = (*this->nonLocalDistributionsFromh)(D3Q27System::ET_BE, x1From, x2From, x3From + 1); + (*this->nonLocalDistributionsToh)(D3Q27System::ET_BS, x1To, x2To + 1, x3To + 1) = (*this->nonLocalDistributionsFromh)(D3Q27System::ET_BS, x1From, x2From + 1, x3From + 1); + (*this->nonLocalDistributionsToh)(D3Q27System::ET_BN, x1To, x2To, x3To + 1) = (*this->nonLocalDistributionsFromh)(D3Q27System::ET_BN, x1From, x2From, x3From + 1); + (*this->nonLocalDistributionsToh)(D3Q27System::ET_BSW, x1To + 1, x2To + 1, x3To + 1) = (*this->nonLocalDistributionsFromh)(D3Q27System::ET_BSW, x1From + 1, x2From + 1, x3From + 1); + (*this->nonLocalDistributionsToh)(D3Q27System::ET_BSE, x1To, x2To + 1, x3To + 1) = (*this->nonLocalDistributionsFromh)(D3Q27System::ET_BSE, x1From, x2From + 1, x3From + 1); + (*this->nonLocalDistributionsToh)(D3Q27System::ET_BNW, x1To + 1, x2To, x3To + 1) = (*this->nonLocalDistributionsFromh)(D3Q27System::ET_BNW, x1From + 1, x2From, x3From + 1); + (*this->nonLocalDistributionsToh)(D3Q27System::ET_BNE, x1To, x2To, x3To + 1) = (*this->nonLocalDistributionsFromh)(D3Q27System::ET_BNE, x1From, x2From, x3From + 1); + + (*this->zeroDistributionsToh)(x1To, x2To, x3To) = (*this->zeroDistributionsFromh)(x1From, x2From, x3From); + + (*this->pressureTo)(x1To, x2To, x3To) = (*this->pressureFrom)(x1From, x2From, x3From); +} +#endif \ No newline at end of file diff --git a/src/cpu/VirtualFluidsCore/Connectors/TwoDistributionsDoubleGhostLayerFullVectorConnector.cpp b/src/cpu/VirtualFluidsCore/Connectors/TwoDistributionsDoubleGhostLayerFullVectorConnector.cpp new file mode 100644 index 0000000000000000000000000000000000000000..b831cb840b3de012c1df35efd237e3e0c3f81056 --- /dev/null +++ b/src/cpu/VirtualFluidsCore/Connectors/TwoDistributionsDoubleGhostLayerFullVectorConnector.cpp @@ -0,0 +1,615 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// 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 TwoDistributionsDoubleGhostLayerFullVectorConnector.cpp +//! \ingroup Connectors +//! \author Konstantin Kutscher +//======================================================================================= + +#include "TwoDistributionsDoubleGhostLayerFullVectorConnector.h" +#include "Block3D.h" +#include "LBMKernel.h" +#include "EsoTwist3D.h" +#include "DataSet3D.h" + +////////////////////////////////////////////////////////////////////////// +TwoDistributionsDoubleGhostLayerFullVectorConnector::TwoDistributionsDoubleGhostLayerFullVectorConnector(SPtr<Block3D> block, + VectorTransmitterPtr sender, + VectorTransmitterPtr receiver, int sendDir) + : FullVectorConnector(block, sender, receiver, sendDir) +{ + if (!block || !sender || !receiver) + UB_THROW(UbException(UB_EXARGS, "sender or receiver == NULL!!")); + +} +////////////////////////////////////////////////////////////////////////// +void TwoDistributionsDoubleGhostLayerFullVectorConnector::init() +{ + FullVectorConnector::init(); + + fDis = dynamicPointerCast<EsoTwist3D>(block.lock()->getKernel()->getDataSet()->getFdistributions()); + hDis = dynamicPointerCast<EsoTwist3D>(block.lock()->getKernel()->getDataSet()->getHdistributions()); + pressure = block.lock()->getKernel()->getDataSet()->getPressureField(); + + int anz = 2*27+1; + switch (sendDir) + { + case D3Q27System::REST: UB_THROW(UbException(UB_EXARGS, "ZERO not allowed")); break; + case D3Q27System::E: + case D3Q27System::W: sender->getData().resize(maxX2*maxX3*anz*2, 0.0); break; + case D3Q27System::N: + case D3Q27System::S: sender->getData().resize(maxX1*maxX3*anz*2, 0.0); break; + case D3Q27System::T: + case D3Q27System::B: sender->getData().resize(maxX1*maxX2*anz*2, 0.0); break; + + case D3Q27System::NE: + case D3Q27System::SW: + case D3Q27System::SE: + case D3Q27System::NW: sender->getData().resize(maxX3*anz*4, 0.0); break; + + case D3Q27System::TE: + case D3Q27System::BW: + case D3Q27System::BE: + case D3Q27System::TW: sender->getData().resize(maxX2*anz*4, 0.0); break; + + case D3Q27System::TN: + case D3Q27System::BS: + case D3Q27System::BN: + case D3Q27System::TS: sender->getData().resize(maxX1*anz*4, 0.0); break; + + case D3Q27System::TNE: + case D3Q27System::BSW: + case D3Q27System::BNE: + case D3Q27System::TSW: + case D3Q27System::TSE: + case D3Q27System::BNW: + case D3Q27System::BSE: + case D3Q27System::TNW: sender->getData().resize(anz*8, 0.0); break; + + default: UB_THROW(UbException(UB_EXARGS, "unknown sendDir")); + } +} +////////////////////////////////////////////////////////////////////////// +void TwoDistributionsDoubleGhostLayerFullVectorConnector::fillSendVectors() +{ + updatePointers(); + fillData(); +} +//////////////////////////////////////////////////////////////////////// +void TwoDistributionsDoubleGhostLayerFullVectorConnector::fillData() +{ + //////////////////////////////////////////////////////////// + // relation between ghost layer and regular nodes + // maxX1m3 maxX1m2 ... minX1p2 minX1p3 - regular nodes + // minX1 minX1p1 ... maxX1m1 maxX1 - ghost layer + //////////////////////////////////////////////////////////// + + int minX1 = 0; + //int minX1p1 = minX1 + 1; + int minX1p2 = minX1 + 2; + int minX1p3 = minX1 + 3; + //int maxX1m1 = maxX1 - 1; + int maxX1m2 = maxX1 - 2; + int maxX1m3 = maxX1 - 3; + + int minX2 = 0; + //int minX2p1 = minX2 + 1; + int minX2p2 = minX2 + 2; + int minX2p3 = minX2 + 3; + //int maxX2m1 = maxX2 - 1; + int maxX2m2 = maxX2 - 2; + int maxX2m3 = maxX2 - 3; + + int minX3 = 0; + //int minX3p1 = minX3 + 1; + int minX3p2 = minX3 + 2; + int minX3p3 = minX3 + 3; + //int maxX3m1 = maxX3 - 1; + int maxX3m2 = maxX3 - 2; + int maxX3m3 = maxX3 - 3; + + vector_type &sdata = sender->getData(); + + int index = 0; + // EAST + if (sendDir == D3Q27System::E) { + for (int x3 = minX3p2; x3 <= maxX3m2; x3++) { + for (int x2 = minX2p2; x2 <= maxX2m2; x2++) { + fillData(sdata, index, maxX1m3, x2, x3); + fillData(sdata, index, maxX1m2, x2, x3); + } + } + } + // WEST + else if (sendDir == D3Q27System::W) { + for (int x3 = minX3p2; x3 <= maxX3m2; x3++) { + for (int x2 = minX2p2; x2 <= maxX2m2; x2++) { + fillData(sdata, index, minX1p3, x2, x3); + fillData(sdata, index, minX1p2, x2, x3); + } + } + } + // NORTH + else if (sendDir == D3Q27System::N) { + for (int x3 = minX3p2; x3 <= maxX3m2; x3++) { + for (int x1 = minX1p2; x1 <= maxX1m2; x1++) { + fillData(sdata, index, x1, maxX2m3, x3); + fillData(sdata, index, x1, maxX2m2, x3); + } + } + } + // SOUTH + else if (sendDir == D3Q27System::S) { + for (int x3 = minX3p2; x3 <= maxX3m2; x3++) { + for (int x1 = minX1p2; x1 <= maxX1m2; x1++) { + fillData(sdata, index, x1, minX2p3, x3); + fillData(sdata, index, x1, minX2p2, x3); + } + } + } + + // TOP + else if (sendDir == D3Q27System::T) { + for (int x2 = minX2p2; x2 <= maxX2m2; x2++) { + for (int x1 = minX1p2; x1 <= maxX1m2; x1++) { + fillData(sdata, index, x1, x2, maxX3m3); + fillData(sdata, index, x1, x2, maxX3m2); + } + } + } + // BOTTOM + else if (sendDir == D3Q27System::B) { + for (int x2 = minX2p2; x2 <= maxX2m2; x2++) { + for (int x1 = minX1p2; x1 <= maxX1m2; x1++) { + fillData(sdata, index, x1, x2, minX3p3); + fillData(sdata, index, x1, x2, minX3p2); + } + } + } + // NORTHEAST + else if (sendDir == D3Q27System::NE) { + for (int x3 = minX3p2; x3 <= maxX3m2; x3++) { + fillData(sdata, index, maxX1m3, maxX2m3, x3); + fillData(sdata, index, maxX1m2, maxX2m2, x3); + fillData(sdata, index, maxX1m3, maxX2m2, x3); + fillData(sdata, index, maxX1m2, maxX2m3, x3); + } + } + // NORTHWEST + else if (sendDir == D3Q27System::NW) { + for (int x3 = minX3p2; x3 <= maxX3m2; x3++) { + fillData(sdata, index, minX1p3, maxX2m3, x3); + fillData(sdata, index, minX1p2, maxX2m2, x3); + fillData(sdata, index, minX1p3, maxX2m2, x3); + fillData(sdata, index, minX1p2, maxX2m3, x3); + } + } + // SOUTHWEST + else if (sendDir == D3Q27System::SW) { + for (int x3 = minX3p2; x3 <= maxX3m2; x3++) { + fillData(sdata, index, minX1p3, minX2p3, x3); + fillData(sdata, index, minX1p2, minX2p2, x3); + fillData(sdata, index, minX1p3, minX2p2, x3); + fillData(sdata, index, minX1p2, minX2p3, x3); + } + } + // SOUTHEAST + else if (sendDir == D3Q27System::SE) { + for (int x3 = minX3p2; x3 <= maxX3m2; x3++) { + fillData(sdata, index, maxX1m3, minX2p3, x3); + fillData(sdata, index, maxX1m2, minX2p2, x3); + fillData(sdata, index, maxX1m3, minX2p2, x3); + fillData(sdata, index, maxX1m2, minX2p3, x3); + } + } else if (sendDir == D3Q27System::TE) + for (int x2 = minX2p2; x2 <= maxX2m2; x2++) { + fillData(sdata, index, maxX1m3, x2, maxX3m3); + fillData(sdata, index, maxX1m2, x2, maxX3m2); + fillData(sdata, index, maxX1m3, x2, maxX3m2); + fillData(sdata, index, maxX1m2, x2, maxX3m3); + } + else if (sendDir == D3Q27System::BW) + for (int x2 = minX2p2; x2 <= maxX2m2; x2++) { + fillData(sdata, index, minX1p3, x2, minX3p3); + fillData(sdata, index, minX1p2, x2, minX3p2); + fillData(sdata, index, minX1p3, x2, minX3p2); + fillData(sdata, index, minX1p2, x2, minX3p3); + } + else if (sendDir == D3Q27System::BE) + for (int x2 = minX2p2; x2 <= maxX2m2; x2++) { + fillData(sdata, index, maxX1m3, x2, minX3p3); + fillData(sdata, index, maxX1m2, x2, minX3p2); + fillData(sdata, index, maxX1m3, x2, minX3p2); + fillData(sdata, index, maxX1m2, x2, minX3p3); + } + else if (sendDir == D3Q27System::TW) + for (int x2 = minX2p2; x2 <= maxX2m2; x2++) { + fillData(sdata, index, minX1p3, x2, maxX3m3); + fillData(sdata, index, minX1p2, x2, maxX3m2); + fillData(sdata, index, minX1p3, x2, maxX3m2); + fillData(sdata, index, minX1p2, x2, maxX3m3); + } + else if (sendDir == D3Q27System::TN) + for (int x1 = minX1p2; x1 <= maxX1m2; x1++) { + fillData(sdata, index, x1, maxX2m3, maxX3m3); + fillData(sdata, index, x1, maxX2m2, maxX3m2); + fillData(sdata, index, x1, maxX2m3, maxX3m2); + fillData(sdata, index, x1, maxX2m2, maxX3m3); + } + else if (sendDir == D3Q27System::BS) + for (int x1 = minX1p2; x1 <= maxX1m2; x1++) { + fillData(sdata, index, x1, minX2p3, minX3p3); + fillData(sdata, index, x1, minX2p2, minX3p2); + fillData(sdata, index, x1, minX2p3, minX3p2); + fillData(sdata, index, x1, minX2p2, minX3p3); + } + else if (sendDir == D3Q27System::BN) + for (int x1 = minX1p2; x1 <= maxX1m2; x1++) { + fillData(sdata, index, x1, maxX2m3, minX3p3); + fillData(sdata, index, x1, maxX2m2, minX3p2); + fillData(sdata, index, x1, maxX2m3, minX3p2); + fillData(sdata, index, x1, maxX2m2, minX3p3); + } + else if (sendDir == D3Q27System::TS) + for (int x1 = minX1p2; x1 <= maxX1m2; x1++) { + fillData(sdata, index, x1, minX2p3, maxX3m3); + fillData(sdata, index, x1, minX2p2, maxX3m2); + fillData(sdata, index, x1, minX2p3, maxX3m2); + fillData(sdata, index, x1, minX2p2, maxX3m3); + } + else if (sendDir == D3Q27System::TSW) { + fillData(sdata, index, minX1p3, minX2p3, maxX3m3); + fillData(sdata, index, minX1p2, minX2p2, maxX3m2); + fillData(sdata, index, minX1p3, minX2p2, maxX3m2); + fillData(sdata, index, minX1p2, minX2p3, maxX3m2); + fillData(sdata, index, minX1p2, minX2p2, maxX3m3); + fillData(sdata, index, minX1p3, minX2p3, maxX3m2); + fillData(sdata, index, minX1p3, minX2p2, maxX3m3); + fillData(sdata, index, minX1p2, minX2p3, maxX3m3); + } else if (sendDir == D3Q27System::TSE) { + fillData(sdata, index, maxX1m3, minX1p3, maxX3m3); + fillData(sdata, index, maxX1m2, minX1p2, maxX3m2); + fillData(sdata, index, maxX1m3, minX1p2, maxX3m2); + fillData(sdata, index, maxX1m2, minX1p3, maxX3m2); + fillData(sdata, index, maxX1m2, minX1p2, maxX3m3); + fillData(sdata, index, maxX1m3, minX1p3, maxX3m2); + fillData(sdata, index, maxX1m3, minX1p2, maxX3m3); + fillData(sdata, index, maxX1m2, minX1p3, maxX3m3); + } else if (sendDir == D3Q27System::TNW) { + fillData(sdata, index, minX1p3, maxX2m3, maxX3m3); + fillData(sdata, index, minX1p2, maxX2m2, maxX3m2); + fillData(sdata, index, minX1p3, maxX2m2, maxX3m2); + fillData(sdata, index, minX1p2, maxX2m3, maxX3m2); + fillData(sdata, index, minX1p2, maxX2m2, maxX3m3); + fillData(sdata, index, minX1p3, maxX2m3, maxX3m2); + fillData(sdata, index, minX1p3, maxX2m2, maxX3m3); + fillData(sdata, index, minX1p2, maxX2m3, maxX3m3); + } else if (sendDir == D3Q27System::TNE) { + fillData(sdata, index, maxX1m3, maxX2m3, maxX3m3); + fillData(sdata, index, maxX1m2, maxX2m2, maxX3m2); + fillData(sdata, index, maxX1m3, maxX2m2, maxX3m2); + fillData(sdata, index, maxX1m2, maxX2m3, maxX3m2); + fillData(sdata, index, maxX1m2, maxX2m2, maxX3m3); + fillData(sdata, index, maxX1m3, maxX2m3, maxX3m2); + fillData(sdata, index, maxX1m3, maxX2m2, maxX3m3); + fillData(sdata, index, maxX1m2, maxX2m3, maxX3m3); + } else if (sendDir == D3Q27System::BSW) { + fillData(sdata, index, minX1p3, minX2p3, minX3p3); + fillData(sdata, index, minX1p2, minX2p2, minX3p2); + fillData(sdata, index, minX1p3, minX2p2, minX3p2); + fillData(sdata, index, minX1p2, minX2p3, minX3p2); + fillData(sdata, index, minX1p2, minX2p2, minX3p3); + fillData(sdata, index, minX1p3, minX2p3, minX3p2); + fillData(sdata, index, minX1p3, minX2p2, minX3p3); + fillData(sdata, index, minX1p2, minX2p3, minX3p3); + } else if (sendDir == D3Q27System::BSE) { + fillData(sdata, index, maxX1m3, minX2p3, minX3p3); + fillData(sdata, index, maxX1m2, minX2p2, minX3p2); + fillData(sdata, index, maxX1m3, minX2p2, minX3p2); + fillData(sdata, index, maxX1m2, minX2p3, minX3p2); + fillData(sdata, index, maxX1m2, minX2p2, minX3p3); + fillData(sdata, index, maxX1m3, minX2p3, minX3p2); + fillData(sdata, index, maxX1m3, minX2p2, minX3p3); + fillData(sdata, index, maxX1m2, minX2p3, minX3p3); + } else if (sendDir == D3Q27System::BNW) { + fillData(sdata, index, minX1p3, maxX2m3, minX3p3); + fillData(sdata, index, minX1p2, maxX2m2, minX3p2); + fillData(sdata, index, minX1p3, maxX2m2, minX3p2); + fillData(sdata, index, minX1p2, maxX2m3, minX3p2); + fillData(sdata, index, minX1p2, maxX2m2, minX3p3); + fillData(sdata, index, minX1p3, maxX2m3, minX3p2); + fillData(sdata, index, minX1p3, maxX2m2, minX3p3); + fillData(sdata, index, minX1p2, maxX2m3, minX3p3); + } else if (sendDir == D3Q27System::BNE) { + fillData(sdata, index, maxX1m3, maxX2m3, minX3p3); + fillData(sdata, index, maxX1m2, maxX2m2, minX3p2); + fillData(sdata, index, maxX1m3, maxX2m2, minX3p2); + fillData(sdata, index, maxX1m2, maxX2m3, minX3p2); + fillData(sdata, index, maxX1m2, maxX2m2, minX3p3); + fillData(sdata, index, maxX1m3, maxX2m3, minX3p2); + fillData(sdata, index, maxX1m3, maxX2m2, minX3p3); + fillData(sdata, index, maxX1m2, maxX2m3, minX3p3); + } else + UB_THROW(UbException(UB_EXARGS, "unknown dir")); +} +//////////////////////////////////////////////////////////////////////// +void TwoDistributionsDoubleGhostLayerFullVectorConnector::distributeReceiveVectors() +{ + updatePointers(); + distributeData(); +} +//////////////////////////////////////////////////////////////////////// +void TwoDistributionsDoubleGhostLayerFullVectorConnector::distributeData() +{ + vector_type &rdata = receiver->getData(); + + int index = 0; + //////////////////////////////////////////////////////////// + // relation between ghost layer and regular nodes + // maxX1m3 maxX1m2 ... minX1p2 minX1p3 - regular nodes + // minX1 minX1p1 ... maxX1m1 maxX1 - ghost layer + //////////////////////////////////////////////////////////// + + int minX1 = 0; + int minX1p1 = minX1 + 1; + int minX1p2 = minX1 + 2; + //int minX1p3 = minX1 + 3; + int maxX1m1 = maxX1 - 1; + int maxX1m2 = maxX1 - 2; + //int maxX1m3 = maxX1 - 3; + + int minX2 = 0; + int minX2p1 = minX2 + 1; + int minX2p2 = minX2 + 2; + //int minX2p3 = minX2 + 3; + int maxX2m1 = maxX2 - 1; + int maxX2m2 = maxX2 - 2; + //int maxX2m3 = maxX2 - 3; + + int minX3 = 0; + int minX3p1 = minX3 + 1; + int minX3p2 = minX3 + 2; + //int minX3p3 = minX3 + 3; + int maxX3m1 = maxX3 - 1; + int maxX3m2 = maxX3 - 2; + //int maxX3m3 = maxX3 - 3; + + if (sendDir == D3Q27System::W) { + for (int x3 = minX3p2; x3 <= maxX3m2; x3++) { + for (int x2 = minX2p2; x2 <= maxX2m2; x2++) { + distributeData(rdata, index, minX1, x2, x3); + distributeData(rdata, index, minX1p1, x2, x3); + } + } + } + else if (sendDir == D3Q27System::E) { + for (int x3 = minX3p2; x3 <= maxX3m2; x3++) { + for (int x2 = minX2p2; x2 <= maxX2m2; x2++) { + distributeData(rdata, index, maxX1, x2, x3); + distributeData(rdata, index, maxX1m1, x2, x3); + } + } + } + else if (sendDir == D3Q27System::S) { + for (int x3 = minX3p2; x3 <= maxX3m2; x3++) { + for (int x1 = minX1p2; x1 <= maxX1m2; x1++) { + distributeData(rdata, index, x1, minX2, x3); + distributeData(rdata, index, x1, minX2p1, x3); + } + } + } + else if (sendDir == D3Q27System::N) { + for (int x3 = minX3p2; x3 <= maxX3m2; x3++) { + for (int x1 = minX1p2; x1 <= maxX1m2; x1++) { + distributeData(rdata, index, x1, maxX2, x3); + distributeData(rdata, index, x1, maxX2m1, x3); + } + } + } + else if (sendDir == D3Q27System::B) { + for (int x2 = minX2p2; x2 <= maxX2m2; x2++) { + for (int x1 = minX1p2; x1 <= maxX1m2; x1++) { + distributeData(rdata, index, x1, x2, minX3); + distributeData(rdata, index, x1, x2, minX3p1); + } + } + } + else if (sendDir == D3Q27System::T) { + for (int x2 = minX2p2; x2 <= maxX2m2; x2++) { + for (int x1 = minX1p2; x1 <= maxX1m2; x1++) { + distributeData(rdata, index, x1, x2, maxX3); + distributeData(rdata, index, x1, x2, maxX3m1); + } + } + } + else if (sendDir == D3Q27System::SW) { + for (int x3 = minX3p2; x3 <= maxX3m2; x3++) { + distributeData(rdata, index, minX1, minX2, x3); + distributeData(rdata, index, minX1p1, minX2p1, x3); + distributeData(rdata, index, minX1, minX2p1, x3); + distributeData(rdata, index, minX1p1, minX2, x3); + } + } + else if (sendDir == D3Q27System::SE) { + for (int x3 = minX3p2; x3 <= maxX3m2; x3++) { + distributeData(rdata, index, maxX1, minX2, x3); + distributeData(rdata, index, maxX1m1, minX2p1, x3); + distributeData(rdata, index, maxX1, minX2p1, x3); + distributeData(rdata, index, maxX1m1, minX2, x3); + } + } + else if (sendDir == D3Q27System::NE) { + for (int x3 = minX3p2; x3 <= maxX3m2; x3++) { + distributeData(rdata, index, maxX1, maxX2, x3); + distributeData(rdata, index, maxX1m1, maxX2m1, x3); + distributeData(rdata, index, maxX1, maxX2m1, x3); + distributeData(rdata, index, maxX1m1, maxX2, x3); + } + } + else if (sendDir == D3Q27System::NW) { + for (int x3 = minX3p2; x3 <= maxX3m2; x3++) { + distributeData(rdata, index, minX1, maxX2, x3); + distributeData(rdata, index, minX1p1, maxX2m1, x3); + distributeData(rdata, index, minX1, maxX2m1, x3); + distributeData(rdata, index, minX1p1, maxX2, x3); + } + } else if (sendDir == D3Q27System::BW) + for (int x2 = minX2p2; x2 <= maxX2m2; x2++) { + distributeData(rdata, index, minX1, x2, minX3); + distributeData(rdata, index, minX1p1, x2, minX3p1); + distributeData(rdata, index, minX1, x2, minX3p1); + distributeData(rdata, index, minX1p1, x2, minX3); + } + else if (sendDir == D3Q27System::TE) + for (int x2 = minX2p2; x2 <= maxX2m2; x2++) { + distributeData(rdata, index, maxX1, x2, maxX3); + distributeData(rdata, index, maxX1m1, x2, maxX3m1); + distributeData(rdata, index, maxX1, x2, maxX3m1); + distributeData(rdata, index, maxX1m1, x2, maxX3); + } + else if (sendDir == D3Q27System::TW) + for (int x2 = minX2p2; x2 <= maxX2m2; x2++) { + distributeData(rdata, index, minX1, x2, maxX3); + distributeData(rdata, index, minX1p1, x2, maxX3m1); + distributeData(rdata, index, minX1, x2, maxX3m1); + distributeData(rdata, index, minX1p1, x2, maxX3); + } + else if (sendDir == D3Q27System::BE) + for (int x2 = minX2p2; x2 <= maxX2m2; x2++) { + distributeData(rdata, index, maxX1, x2, minX3); + distributeData(rdata, index, maxX1m1, x2, minX3p1); + distributeData(rdata, index, maxX1, x2, minX3p1); + distributeData(rdata, index, maxX1m1, x2, minX3); + } + else if (sendDir == D3Q27System::BS) + for (int x1 = minX1p2; x1 <= maxX1m2; x1++) { + distributeData(rdata, index, x1, minX2, minX3); + distributeData(rdata, index, x1, minX2p1, minX3p1); + distributeData(rdata, index, x1, minX2, minX3p1); + distributeData(rdata, index, x1, minX2p1, minX3); + } + else if (sendDir == D3Q27System::TN) + for (int x1 = minX1p2; x1 <= maxX1m2; x1++) { + distributeData(rdata, index, x1, maxX2, maxX3); + distributeData(rdata, index, x1, maxX2m1, maxX3m1); + distributeData(rdata, index, x1, maxX2, maxX3m1); + distributeData(rdata, index, x1, maxX2m1, maxX3); + } + else if (sendDir == D3Q27System::TS) + for (int x1 = minX1p2; x1 <= maxX1m2; x1++) { + distributeData(rdata, index, x1, minX2, maxX3); + distributeData(rdata, index, x1, minX2p1, maxX3m1); + distributeData(rdata, index, x1, minX2, maxX3m1); + distributeData(rdata, index, x1, minX2p1, maxX3); + } + else if (sendDir == D3Q27System::BN) + for (int x1 = minX1p2; x1 <= maxX1m2; x1++) { + distributeData(rdata, index, x1, maxX2, minX3); + distributeData(rdata, index, x1, maxX2m1, minX3p1); + distributeData(rdata, index, x1, maxX2, minX3p1); + distributeData(rdata, index, x1, maxX2m1, minX3); + } + else if (sendDir == D3Q27System::BNE) { + distributeData(rdata, index, maxX1, maxX2, minX3); + distributeData(rdata, index, maxX1m1, maxX2m1, minX3p1); + distributeData(rdata, index, maxX1, maxX2m1, minX3p1); + distributeData(rdata, index, maxX1m1, maxX2, minX3p1); + distributeData(rdata, index, maxX1m1, maxX2m1, minX3); + distributeData(rdata, index, maxX1, maxX2, minX3p1); + distributeData(rdata, index, maxX1, maxX2m1, minX3); + distributeData(rdata, index, maxX1m1, maxX2, minX3); + } else if (sendDir == D3Q27System::BNW) { + distributeData(rdata, index, minX1, maxX2, minX3); + distributeData(rdata, index, minX1p1, maxX2m1, minX3p1); + distributeData(rdata, index, minX1, maxX2m1, minX3p1); + distributeData(rdata, index, minX1p1, maxX2, minX3p1); + distributeData(rdata, index, minX1p1, maxX2m1, minX3); + distributeData(rdata, index, minX1, maxX2, minX3p1); + distributeData(rdata, index, minX1, maxX2m1, minX3); + distributeData(rdata, index, minX1p1, maxX2, minX3); + } else if (sendDir == D3Q27System::BSE) { + distributeData(rdata, index, maxX1, minX2, minX3); + distributeData(rdata, index, maxX1m1, minX2p1, minX3p1); + distributeData(rdata, index, maxX1, minX2p1, minX3p1); + distributeData(rdata, index, maxX1m1, minX2, minX3p1); + distributeData(rdata, index, maxX1m1, minX2p1, minX3); + distributeData(rdata, index, maxX1, minX2, minX3p1); + distributeData(rdata, index, maxX1, minX2p1, minX3); + distributeData(rdata, index, maxX1m1, minX2, minX3); + } else if (sendDir == D3Q27System::BSW) { + distributeData(rdata, index, minX1, minX2, minX3); + distributeData(rdata, index, minX1p1, minX2p1, minX3p1); + distributeData(rdata, index, minX1, minX2p1, minX3p1); + distributeData(rdata, index, minX1p1, minX2, minX3p1); + distributeData(rdata, index, minX1p1, minX2p1, minX3); + distributeData(rdata, index, minX1, minX2, minX3p1); + distributeData(rdata, index, minX1, minX2p1, minX3); + distributeData(rdata, index, minX1p1, minX2, minX3); + } else if (sendDir == D3Q27System::TNE) { + distributeData(rdata, index, maxX1, maxX2, maxX3); + distributeData(rdata, index, maxX1m1, maxX2m1, maxX3m1); + distributeData(rdata, index, maxX1, maxX2m1, maxX3m1); + distributeData(rdata, index, maxX1m1, maxX2, maxX3m1); + distributeData(rdata, index, maxX1m1, maxX2m1, maxX3); + distributeData(rdata, index, maxX1, maxX2, maxX3m1); + distributeData(rdata, index, maxX1, maxX2m1, maxX3); + distributeData(rdata, index, maxX1m1, maxX2, maxX3); + } else if (sendDir == D3Q27System::TNW) { + distributeData(rdata, index, minX1, maxX2, maxX3); + distributeData(rdata, index, minX1p1, maxX2m1, maxX3m1); + distributeData(rdata, index, minX1, maxX2m1, maxX3m1); + distributeData(rdata, index, minX1p1, maxX2, maxX3m1); + distributeData(rdata, index, minX1p1, maxX2m1, maxX3); + distributeData(rdata, index, minX1, maxX2, maxX3m1); + distributeData(rdata, index, minX1, maxX2m1, maxX3); + distributeData(rdata, index, minX1p1, maxX2, maxX3); + } else if (sendDir == D3Q27System::TSE) { + distributeData(rdata, index, maxX1, minX2, maxX3); + distributeData(rdata, index, maxX1m1, minX2p1, maxX3m1); + distributeData(rdata, index, maxX1, minX2p1, maxX3m1); + distributeData(rdata, index, maxX1m1, minX2, maxX3m1); + distributeData(rdata, index, maxX1m1, minX2p1, maxX3); + distributeData(rdata, index, maxX1, minX2, maxX3m1); + distributeData(rdata, index, maxX1, minX2p1, maxX3); + distributeData(rdata, index, maxX1m1, minX2, maxX3); + } else if (sendDir == D3Q27System::TSW) { + distributeData(rdata, index, minX1, minX2, maxX3); + distributeData(rdata, index, minX1p1, minX2p1, maxX3m1); + distributeData(rdata, index, minX1, minX2p1, maxX3m1); + distributeData(rdata, index, minX1p1, minX2, maxX3m1); + distributeData(rdata, index, minX1p1, minX2p1, maxX3); + distributeData(rdata, index, minX1, minX2, maxX3m1); + distributeData(rdata, index, minX1, minX2p1, maxX3); + distributeData(rdata, index, minX1p1, minX2, maxX3); + } else + UB_THROW(UbException(UB_EXARGS, "unknown dir")); + +} +////////////////////////////////////////////////////////////////////////// + + diff --git a/src/cpu/VirtualFluidsCore/Connectors/TwoDistributionsDoubleGhostLayerFullVectorConnector.h b/src/cpu/VirtualFluidsCore/Connectors/TwoDistributionsDoubleGhostLayerFullVectorConnector.h new file mode 100644 index 0000000000000000000000000000000000000000..508c9e90a2bced8560dcda6098d0fb4aea8b4d9a --- /dev/null +++ b/src/cpu/VirtualFluidsCore/Connectors/TwoDistributionsDoubleGhostLayerFullVectorConnector.h @@ -0,0 +1,232 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// 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 TwoDistributionsDoubleGhostLayerFullVectorConnector.h +//! \ingroup Connectors +//! \author Konstantin Kutscher +//======================================================================================= + +#ifndef TwoDistributionsDoubleGhostLayerFullVectorConnector_H +#define TwoDistributionsDoubleGhostLayerFullVectorConnector_H + +#include <vector> + +#include "FullVectorConnector.h" +#include "D3Q27System.h" +#include "D3Q27EsoTwist3DSplittedVector.h" +#include "basics/container/CbArray3D.h" +#include "basics/container/CbArray4D.h" +#include "DataSet3D.h" + +class EsoTwist3D; +class Block3D; + +//daten werden in einen vector (dieser befindet sich im transmitter) kopiert +//der vector wird via transmitter uebertragen +//transmitter kann ein lokal, MPI, RCG, CTL oder was auch immer fuer ein +//transmitter sein, der von Transmitter abgeleitet ist ;-) +class TwoDistributionsDoubleGhostLayerFullVectorConnector : public FullVectorConnector +{ +public: + TwoDistributionsDoubleGhostLayerFullVectorConnector(SPtr<Block3D> block, VectorTransmitterPtr sender, VectorTransmitterPtr receiver, int sendDir); + + void init() override; + + void fillSendVectors() override; + void distributeReceiveVectors() override; + +protected: + inline void updatePointers() override; + void fillData() override; + void distributeData() override; + inline void fillData(vector_type &sdata, int &index, int x1, int x2, int x3) override; + inline void distributeData(vector_type &rdata, int &index, int x1, int x2, int x3) override; + +private: + CbArray4D <LBMReal, IndexerX4X3X2X1>::CbArray4DPtr localDistributions; + CbArray4D <LBMReal, IndexerX4X3X2X1>::CbArray4DPtr nonLocalDistributions; + CbArray3D <LBMReal, IndexerX3X2X1>::CbArray3DPtr zeroDistributions; + + SPtr<EsoTwist3D> fDis; + + CbArray4D <LBMReal, IndexerX4X3X2X1>::CbArray4DPtr localHdistributions; + CbArray4D <LBMReal, IndexerX4X3X2X1>::CbArray4DPtr nonLocalHdistributions; + CbArray3D <LBMReal, IndexerX3X2X1>::CbArray3DPtr zeroHdistributions; + + SPtr<EsoTwist3D> hDis; + + SPtr<PressureFieldArray3D> pressure; + +}; +////////////////////////////////////////////////////////////////////////// +inline void TwoDistributionsDoubleGhostLayerFullVectorConnector::updatePointers() +{ + localDistributions = dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(this->fDis)->getLocalDistributions(); + nonLocalDistributions = dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(this->fDis)->getNonLocalDistributions(); + zeroDistributions = dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(this->fDis)->getZeroDistributions(); + + localHdistributions = dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(this->hDis)->getLocalDistributions(); + nonLocalHdistributions = dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(this->hDis)->getNonLocalDistributions(); + zeroHdistributions = dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(this->hDis)->getZeroDistributions(); +} +////////////////////////////////////////////////////////////////////////// +inline void TwoDistributionsDoubleGhostLayerFullVectorConnector::fillData(vector_type& sdata, int& index, int x1, int x2, int x3) +{ + sdata[index++] = (*this->localDistributions)(D3Q27System::ET_E, x1, x2, x3); + sdata[index++] = (*this->localDistributions)(D3Q27System::ET_N, x1, x2, x3); + sdata[index++] = (*this->localDistributions)(D3Q27System::ET_T, x1, x2, x3); + sdata[index++] = (*this->localDistributions)(D3Q27System::ET_NE, x1, x2, x3); + sdata[index++] = (*this->localDistributions)(D3Q27System::ET_NW, x1 + 1, x2, x3); + sdata[index++] = (*this->localDistributions)(D3Q27System::ET_TE, x1, x2, x3); + sdata[index++] = (*this->localDistributions)(D3Q27System::ET_TW, x1 + 1, x2, x3); + sdata[index++] = (*this->localDistributions)(D3Q27System::ET_TN, x1, x2, x3); + sdata[index++] = (*this->localDistributions)(D3Q27System::ET_TS, x1, x2 + 1, x3); + sdata[index++] = (*this->localDistributions)(D3Q27System::ET_TNE, x1, x2, x3); + sdata[index++] = (*this->localDistributions)(D3Q27System::ET_TNW, x1 + 1, x2, x3); + sdata[index++] = (*this->localDistributions)(D3Q27System::ET_TSE, x1, x2 + 1, x3); + sdata[index++] = (*this->localDistributions)(D3Q27System::ET_TSW, x1 + 1, x2 + 1, x3); + + sdata[index++] = (*this->nonLocalDistributions)(D3Q27System::ET_W, x1 + 1, x2, x3); + sdata[index++] = (*this->nonLocalDistributions)(D3Q27System::ET_S, x1, x2 + 1, x3); + sdata[index++] = (*this->nonLocalDistributions)(D3Q27System::ET_B, x1, x2, x3 + 1); + sdata[index++] = (*this->nonLocalDistributions)(D3Q27System::ET_SW, x1 + 1, x2 + 1, x3); + sdata[index++] = (*this->nonLocalDistributions)(D3Q27System::ET_SE, x1, x2 + 1, x3); + sdata[index++] = (*this->nonLocalDistributions)(D3Q27System::ET_BW, x1 + 1, x2, x3 + 1); + sdata[index++] = (*this->nonLocalDistributions)(D3Q27System::ET_BE, x1, x2, x3 + 1); + sdata[index++] = (*this->nonLocalDistributions)(D3Q27System::ET_BS, x1, x2 + 1, x3 + 1); + sdata[index++] = (*this->nonLocalDistributions)(D3Q27System::ET_BN, x1, x2, x3 + 1); + sdata[index++] = (*this->nonLocalDistributions)(D3Q27System::ET_BSW, x1 + 1, x2 + 1, x3 + 1); + sdata[index++] = (*this->nonLocalDistributions)(D3Q27System::ET_BSE, x1, x2 + 1, x3 + 1); + sdata[index++] = (*this->nonLocalDistributions)(D3Q27System::ET_BNW, x1 + 1, x2, x3 + 1); + sdata[index++] = (*this->nonLocalDistributions)(D3Q27System::ET_BNE, x1, x2, x3 + 1); + + sdata[index++] = (*this->zeroDistributions)(x1, x2, x3); + + + sdata[index++] = (*this->localHdistributions)(D3Q27System::ET_E, x1, x2, x3); + sdata[index++] = (*this->localHdistributions)(D3Q27System::ET_N, x1, x2, x3); + sdata[index++] = (*this->localHdistributions)(D3Q27System::ET_T, x1, x2, x3); + sdata[index++] = (*this->localHdistributions)(D3Q27System::ET_NE, x1, x2, x3); + sdata[index++] = (*this->localHdistributions)(D3Q27System::ET_NW, x1 + 1, x2, x3); + sdata[index++] = (*this->localHdistributions)(D3Q27System::ET_TE, x1, x2, x3); + sdata[index++] = (*this->localHdistributions)(D3Q27System::ET_TW, x1 + 1, x2, x3); + sdata[index++] = (*this->localHdistributions)(D3Q27System::ET_TN, x1, x2, x3); + sdata[index++] = (*this->localHdistributions)(D3Q27System::ET_TS, x1, x2 + 1, x3); + sdata[index++] = (*this->localHdistributions)(D3Q27System::ET_TNE, x1, x2, x3); + sdata[index++] = (*this->localHdistributions)(D3Q27System::ET_TNW, x1 + 1, x2, x3); + sdata[index++] = (*this->localHdistributions)(D3Q27System::ET_TSE, x1, x2 + 1, x3); + sdata[index++] = (*this->localHdistributions)(D3Q27System::ET_TSW, x1 + 1, x2 + 1, x3); + + sdata[index++] = (*this->nonLocalHdistributions)(D3Q27System::ET_W, x1 + 1, x2, x3); + sdata[index++] = (*this->nonLocalHdistributions)(D3Q27System::ET_S, x1, x2 + 1, x3); + sdata[index++] = (*this->nonLocalHdistributions)(D3Q27System::ET_B, x1, x2, x3 + 1); + sdata[index++] = (*this->nonLocalHdistributions)(D3Q27System::ET_SW, x1 + 1, x2 + 1, x3); + sdata[index++] = (*this->nonLocalHdistributions)(D3Q27System::ET_SE, x1, x2 + 1, x3); + sdata[index++] = (*this->nonLocalHdistributions)(D3Q27System::ET_BW, x1 + 1, x2, x3 + 1); + sdata[index++] = (*this->nonLocalHdistributions)(D3Q27System::ET_BE, x1, x2, x3 + 1); + sdata[index++] = (*this->nonLocalHdistributions)(D3Q27System::ET_BS, x1, x2 + 1, x3 + 1); + sdata[index++] = (*this->nonLocalHdistributions)(D3Q27System::ET_BN, x1, x2, x3 + 1); + sdata[index++] = (*this->nonLocalHdistributions)(D3Q27System::ET_BSW, x1 + 1, x2 + 1, x3 + 1); + sdata[index++] = (*this->nonLocalHdistributions)(D3Q27System::ET_BSE, x1, x2 + 1, x3 + 1); + sdata[index++] = (*this->nonLocalHdistributions)(D3Q27System::ET_BNW, x1 + 1, x2, x3 + 1); + sdata[index++] = (*this->nonLocalHdistributions)(D3Q27System::ET_BNE, x1, x2, x3 + 1); + + sdata[index++] = (*this->zeroHdistributions)(x1, x2, x3); + + sdata[index++] = (*this->pressure)(x1, x2, x3); +} +////////////////////////////////////////////////////////////////////////// +inline void TwoDistributionsDoubleGhostLayerFullVectorConnector::distributeData(vector_type& rdata, int& index, int x1, int x2, int x3) +{ + (*this->localDistributions)(D3Q27System::ET_E, x1, x2, x3) = rdata[index++]; + (*this->localDistributions)(D3Q27System::ET_N, x1, x2, x3) = rdata[index++]; + (*this->localDistributions)(D3Q27System::ET_T, x1, x2, x3) = rdata[index++]; + (*this->localDistributions)(D3Q27System::ET_NE, x1, x2, x3) = rdata[index++]; + (*this->localDistributions)(D3Q27System::ET_NW, x1 + 1, x2, x3) = rdata[index++]; + (*this->localDistributions)(D3Q27System::ET_TE, x1, x2, x3) = rdata[index++]; + (*this->localDistributions)(D3Q27System::ET_TW, x1 + 1, x2, x3) = rdata[index++]; + (*this->localDistributions)(D3Q27System::ET_TN, x1, x2, x3) = rdata[index++]; + (*this->localDistributions)(D3Q27System::ET_TS, x1, x2 + 1, x3) = rdata[index++]; + (*this->localDistributions)(D3Q27System::ET_TNE, x1, x2, x3) = rdata[index++]; + (*this->localDistributions)(D3Q27System::ET_TNW, x1 + 1, x2, x3) = rdata[index++]; + (*this->localDistributions)(D3Q27System::ET_TSE, x1, x2 + 1, x3) = rdata[index++]; + (*this->localDistributions)(D3Q27System::ET_TSW, x1 + 1, x2 + 1, x3) = rdata[index++]; + + (*this->nonLocalDistributions)(D3Q27System::ET_W, x1 + 1, x2, x3) = rdata[index++]; + (*this->nonLocalDistributions)(D3Q27System::ET_S, x1, x2 + 1, x3) = rdata[index++]; + (*this->nonLocalDistributions)(D3Q27System::ET_B, x1, x2, x3 + 1) = rdata[index++]; + (*this->nonLocalDistributions)(D3Q27System::ET_SW, x1 + 1, x2 + 1, x3) = rdata[index++]; + (*this->nonLocalDistributions)(D3Q27System::ET_SE, x1, x2 + 1, x3) = rdata[index++]; + (*this->nonLocalDistributions)(D3Q27System::ET_BW, x1 + 1, x2, x3 + 1) = rdata[index++]; + (*this->nonLocalDistributions)(D3Q27System::ET_BE, x1, x2, x3 + 1) = rdata[index++]; + (*this->nonLocalDistributions)(D3Q27System::ET_BS, x1, x2 + 1, x3 + 1) = rdata[index++]; + (*this->nonLocalDistributions)(D3Q27System::ET_BN, x1, x2, x3 + 1) = rdata[index++]; + (*this->nonLocalDistributions)(D3Q27System::ET_BSW, x1 + 1, x2 + 1, x3 + 1) = rdata[index++]; + (*this->nonLocalDistributions)(D3Q27System::ET_BSE, x1, x2 + 1, x3 + 1) = rdata[index++]; + (*this->nonLocalDistributions)(D3Q27System::ET_BNW, x1 + 1, x2, x3 + 1) = rdata[index++]; + (*this->nonLocalDistributions)(D3Q27System::ET_BNE, x1, x2, x3 + 1) = rdata[index++]; + + (*this->zeroDistributions)(x1, x2, x3) = rdata[index++]; + + + (*this->localHdistributions)(D3Q27System::ET_E, x1, x2, x3) = rdata[index++]; + (*this->localHdistributions)(D3Q27System::ET_N, x1, x2, x3) = rdata[index++]; + (*this->localHdistributions)(D3Q27System::ET_T, x1, x2, x3) = rdata[index++]; + (*this->localHdistributions)(D3Q27System::ET_NE, x1, x2, x3) = rdata[index++]; + (*this->localHdistributions)(D3Q27System::ET_NW, x1 + 1, x2, x3) = rdata[index++]; + (*this->localHdistributions)(D3Q27System::ET_TE, x1, x2, x3) = rdata[index++]; + (*this->localHdistributions)(D3Q27System::ET_TW, x1 + 1, x2, x3) = rdata[index++]; + (*this->localHdistributions)(D3Q27System::ET_TN, x1, x2, x3) = rdata[index++]; + (*this->localHdistributions)(D3Q27System::ET_TS, x1, x2 + 1, x3) = rdata[index++]; + (*this->localHdistributions)(D3Q27System::ET_TNE, x1, x2, x3) = rdata[index++]; + (*this->localHdistributions)(D3Q27System::ET_TNW, x1 + 1, x2, x3) = rdata[index++]; + (*this->localHdistributions)(D3Q27System::ET_TSE, x1, x2 + 1, x3) = rdata[index++]; + (*this->localHdistributions)(D3Q27System::ET_TSW, x1 + 1, x2 + 1, x3) = rdata[index++]; + + (*this->nonLocalHdistributions)(D3Q27System::ET_W, x1 + 1, x2, x3) = rdata[index++]; + (*this->nonLocalHdistributions)(D3Q27System::ET_S, x1, x2 + 1, x3) = rdata[index++]; + (*this->nonLocalHdistributions)(D3Q27System::ET_B, x1, x2, x3 + 1) = rdata[index++]; + (*this->nonLocalHdistributions)(D3Q27System::ET_SW, x1 + 1, x2 + 1, x3) = rdata[index++]; + (*this->nonLocalHdistributions)(D3Q27System::ET_SE, x1, x2 + 1, x3) = rdata[index++]; + (*this->nonLocalHdistributions)(D3Q27System::ET_BW, x1 + 1, x2, x3 + 1) = rdata[index++]; + (*this->nonLocalHdistributions)(D3Q27System::ET_BE, x1, x2, x3 + 1) = rdata[index++]; + (*this->nonLocalHdistributions)(D3Q27System::ET_BS, x1, x2 + 1, x3 + 1) = rdata[index++]; + (*this->nonLocalHdistributions)(D3Q27System::ET_BN, x1, x2, x3 + 1) = rdata[index++]; + (*this->nonLocalHdistributions)(D3Q27System::ET_BSW, x1 + 1, x2 + 1, x3 + 1) = rdata[index++]; + (*this->nonLocalHdistributions)(D3Q27System::ET_BSE, x1, x2 + 1, x3 + 1) = rdata[index++]; + (*this->nonLocalHdistributions)(D3Q27System::ET_BNW, x1 + 1, x2, x3 + 1) = rdata[index++]; + (*this->nonLocalHdistributions)(D3Q27System::ET_BNE, x1, x2, x3 + 1) = rdata[index++]; + + (*this->zeroHdistributions)(x1, x2, x3) = rdata[index++]; + + (*this->pressure)(x1, x2, x3) = rdata[index++]; +} + + +#endif + diff --git a/src/cpu/VirtualFluidsCore/Grid/Grid3D.cpp b/src/cpu/VirtualFluidsCore/Grid/Grid3D.cpp index 361b06a5dd1c549b059cc1db87b7d9c1ce384f5b..41235087e4d48f81c1581e39dd8c0a3a54a7779a 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) @@ -2309,7 +2309,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 5e1eb0da8de21a500b750777db7a1a7cd7f8d050..0d6794c9e855430242a0a4a14a21ea9b90b118fb 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; @@ -64,8 +64,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 @@ -94,7 +94,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 6739e5599c4c21fc1d91b8144686631fede40913..38e5be2e5d35a51f79cb1da8ff7ce9b8b5589656 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 daed493b9cc1afddbd92acabcd551da0f463ea26..9c52f5e0469ce5b6c6e08136f25d3c027d36bdbd 100644 --- a/src/cpu/VirtualFluidsCore/LBM/CumulantK17LBMKernel.cpp +++ b/src/cpu/VirtualFluidsCore/LBM/CumulantK17LBMKernel.cpp @@ -39,6 +39,7 @@ #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 10cfd49264bb829eac1fc6b9bedeee3b6eace265..3052f50e3e48925ed21a3c3af68cc2d247c88a02 100644 --- a/src/cpu/VirtualFluidsCore/LBM/CumulantK17LBMKernel.h +++ b/src/cpu/VirtualFluidsCore/LBM/CumulantK17LBMKernel.h @@ -144,4 +144,4 @@ inline void CumulantK17LBMKernel::backwardChimera(LBMReal& mfa, LBMReal& mfb, LB mfa = ma; } -#endif // CumulantK17LBMKernel_h__ \ No newline at end of file +#endif // CumulantK17LBMKernel_h__ diff --git a/src/cpu/VirtualFluidsCore/LBM/CumulantK17LBMKernelUnified.cpp b/src/cpu/VirtualFluidsCore/LBM/CumulantK17LBMKernelUnified.cpp new file mode 100644 index 0000000000000000000000000000000000000000..2bdc7ce97be90a45b2bebb3dca53f3eb609bec3b --- /dev/null +++ b/src/cpu/VirtualFluidsCore/LBM/CumulantK17LBMKernelUnified.cpp @@ -0,0 +1,337 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// 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 CumulantK17LBMKernel.cpp +//! \ingroup LBM +//! \author Konstantin Kutscher, Martin Geier +//======================================================================================= +#include <lbm/KernelParameter.h> +#include <lbm/CumulantChimera.h> +#include <lbm/constants/D3Q27.h> + +#include "CumulantK17LBMKernelUnified.h" +#include "D3Q27System.h" +#include "D3Q27EsoTwist3DSplittedVector.h" +#include <cmath> +#include "DataSet3D.h" +#include "LBMKernel.h" +#include "Block3D.h" +#include "BCArray3D.h" + + +//#define PROOF_CORRECTNESS + +using namespace UbMath; + +////////////////////////////////////////////////////////////////////////// +CumulantK17LBMKernelUnified::CumulantK17LBMKernelUnified() +{ + this->compressible = true; +} +////////////////////////////////////////////////////////////////////////// +void CumulantK17LBMKernelUnified::initDataSet() +{ + SPtr<DistributionArray3D> d(new D3Q27EsoTwist3DSplittedVector(nx[0] + 2, nx[1] + 2, nx[2] + 2, -999.9)); + dataSet->setFdistributions(d); +} +////////////////////////////////////////////////////////////////////////// +SPtr<LBMKernel> CumulantK17LBMKernelUnified::clone() +{ + SPtr<LBMKernel> kernel(new CumulantK17LBMKernelUnified()); + kernel->setNX(nx); + std::dynamic_pointer_cast<CumulantK17LBMKernelUnified>(kernel)->initDataSet(); + kernel->setCollisionFactor(this->collFactor); + kernel->setBCProcessor(bcProcessor->clone(kernel)); + kernel->setWithForcing(withForcing); + kernel->setForcingX1(muForcingX1); + kernel->setForcingX2(muForcingX2); + kernel->setForcingX3(muForcingX3); + kernel->setIndex(ix1, ix2, ix3); + kernel->setDeltaT(deltaT); + kernel->setBlock(block.lock()); + + return kernel; +} +////////////////////////////////////////////////////////////////////////// +void CumulantK17LBMKernelUnified::calculate(int step) +{ + ////////////////////////////////////////////////////////////////////////// + //! Cumulant K17 Kernel is based on + //! <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 + //! <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 thredIdx, blockIdx, blockDim and gridDim. + //! + + using namespace std; + + //initializing of forcing stuff + if (withForcing) + { + muForcingX1.DefineVar("x1", &muX1); muForcingX1.DefineVar("x2", &muX2); muForcingX1.DefineVar("x3", &muX3); + muForcingX2.DefineVar("x1", &muX1); muForcingX2.DefineVar("x2", &muX2); muForcingX2.DefineVar("x3", &muX3); + muForcingX3.DefineVar("x1", &muX1); muForcingX3.DefineVar("x2", &muX2); muForcingX3.DefineVar("x3", &muX3); + + muDeltaT = deltaT; + + muForcingX1.DefineVar("dt", &muDeltaT); + muForcingX2.DefineVar("dt", &muDeltaT); + muForcingX3.DefineVar("dt", &muDeltaT); + + muNu = (1.0 / 3.0) * (1.0 / collFactor - 1.0 / 2.0); + + muForcingX1.DefineVar("nu", &muNu); + muForcingX2.DefineVar("nu", &muNu); + muForcingX3.DefineVar("nu", &muNu); + } + ///////////////////////////////////// + + localDistributions = dynamic_pointer_cast<D3Q27EsoTwist3DSplittedVector>(dataSet->getFdistributions())->getLocalDistributions(); + nonLocalDistributions = dynamic_pointer_cast<D3Q27EsoTwist3DSplittedVector>(dataSet->getFdistributions())->getNonLocalDistributions(); + restDistributions = dynamic_pointer_cast<D3Q27EsoTwist3DSplittedVector>(dataSet->getFdistributions())->getZeroDistributions(); + + SPtr<BCArray3D> bcArray = this->getBCProcessor()->getBCArray(); + + const int bcArrayMaxX1 = (int)bcArray->getNX1(); + const int bcArrayMaxX2 = (int)bcArray->getNX2(); + const int bcArrayMaxX3 = (int)bcArray->getNX3(); + + int minX1 = ghostLayerWidth; + int minX2 = ghostLayerWidth; + int minX3 = ghostLayerWidth; + int maxX1 = bcArrayMaxX1 - ghostLayerWidth; + int maxX2 = bcArrayMaxX2 - ghostLayerWidth; + int maxX3 = bcArrayMaxX3 - ghostLayerWidth; + + LBMReal omega = collFactor; + + for (int x3 = minX3; x3 < maxX3; x3++) + { + for (int x2 = minX2; x2 < maxX2; x2++) + { + for (int x1 = minX1; x1 < maxX1; x1++) + { + if (!bcArray->isSolid(x1, x2, x3) && !bcArray->isUndefined(x1, x2, x3)) + { + int x1p = x1 + 1; + int x2p = x2 + 1; + int x3p = x3 + 1; + ////////////////////////////////////////////////////////////////////////// + ////////////////////////////////////////////////////////////////////////// + //! - Read 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> + //! + //////////////////////////////////////////////////////////////////////////// + ////////////////////////////////////////////////////////////////////////// + + //E N T + //c c c + ////////// + //W S B + //a a a + + //Rest is b + + //mfxyz + //a - negative + //b - null + //c - positive + + // a b c + //-1 0 1 + + LBMReal mfcbb = (*this->localDistributions)(D3Q27System::ET_E, x1, x2, x3); + LBMReal mfbcb = (*this->localDistributions)(D3Q27System::ET_N, x1, x2, x3); + LBMReal mfbbc = (*this->localDistributions)(D3Q27System::ET_T, x1, x2, x3); + LBMReal mfccb = (*this->localDistributions)(D3Q27System::ET_NE, x1, x2, x3); + LBMReal mfacb = (*this->localDistributions)(D3Q27System::ET_NW, x1p, x2, x3); + LBMReal mfcbc = (*this->localDistributions)(D3Q27System::ET_TE, x1, x2, x3); + LBMReal mfabc = (*this->localDistributions)(D3Q27System::ET_TW, x1p, x2, x3); + LBMReal mfbcc = (*this->localDistributions)(D3Q27System::ET_TN, x1, x2, x3); + LBMReal mfbac = (*this->localDistributions)(D3Q27System::ET_TS, x1, x2p, x3); + LBMReal mfccc = (*this->localDistributions)(D3Q27System::ET_TNE, x1, x2, x3); + LBMReal mfacc = (*this->localDistributions)(D3Q27System::ET_TNW, x1p, x2, x3); + LBMReal mfcac = (*this->localDistributions)(D3Q27System::ET_TSE, x1, x2p, x3); + LBMReal mfaac = (*this->localDistributions)(D3Q27System::ET_TSW, x1p, x2p, x3); + + LBMReal mfabb = (*this->nonLocalDistributions)(D3Q27System::ET_W, x1p, x2, x3); + LBMReal mfbab = (*this->nonLocalDistributions)(D3Q27System::ET_S, x1, x2p, x3); + LBMReal mfbba = (*this->nonLocalDistributions)(D3Q27System::ET_B, x1, x2, x3p); + LBMReal mfaab = (*this->nonLocalDistributions)(D3Q27System::ET_SW, x1p, x2p, x3); + LBMReal mfcab = (*this->nonLocalDistributions)(D3Q27System::ET_SE, x1, x2p, x3); + LBMReal mfaba = (*this->nonLocalDistributions)(D3Q27System::ET_BW, x1p, x2, x3p); + LBMReal mfcba = (*this->nonLocalDistributions)(D3Q27System::ET_BE, x1, x2, x3p); + LBMReal mfbaa = (*this->nonLocalDistributions)(D3Q27System::ET_BS, x1, x2p, x3p); + LBMReal mfbca = (*this->nonLocalDistributions)(D3Q27System::ET_BN, x1, x2, x3p); + LBMReal mfaaa = (*this->nonLocalDistributions)(D3Q27System::ET_BSW, x1p, x2p, x3p); + LBMReal mfcaa = (*this->nonLocalDistributions)(D3Q27System::ET_BSE, x1, x2p, x3p); + LBMReal mfaca = (*this->nonLocalDistributions)(D3Q27System::ET_BNW, x1p, x2, x3p); + LBMReal mfcca = (*this->nonLocalDistributions)(D3Q27System::ET_BNE, x1, x2, x3p); + + LBMReal mfbbb = (*this->restDistributions)(x1, x2, x3); + + + LBMReal forces[3] = {0., 0., 0.}; + if (withForcing) + { + muX1 = static_cast<double>(x1 - 1 + ix1 * maxX1); + muX2 = static_cast<double>(x2 - 1 + ix2 * maxX2); + muX3 = static_cast<double>(x3 - 1 + ix3 * maxX3); + + forcingX1 = muForcingX1.Eval(); + forcingX2 = muForcingX2.Eval(); + forcingX3 = muForcingX3.Eval(); + + forces[0] = forcingX1 * deltaT; + forces[1] = forcingX2 * deltaT; + forces[2] = forcingX3 * deltaT; + } + + vf::lbm::Distribution27 distribution; + + distribution.f[vf::lbm::dir::PZZ] = mfcbb; + distribution.f[vf::lbm::dir::MZZ] = mfabb; + distribution.f[vf::lbm::dir::ZPZ] = mfbcb; + distribution.f[vf::lbm::dir::ZMZ] = mfbab; + distribution.f[vf::lbm::dir::ZZP] = mfbbc; + distribution.f[vf::lbm::dir::ZZM] = mfbba; + distribution.f[vf::lbm::dir::PPZ] = mfccb; + distribution.f[vf::lbm::dir::MMZ] = mfaab; + distribution.f[vf::lbm::dir::PMZ] = mfcab; + distribution.f[vf::lbm::dir::MPZ] = mfacb; + distribution.f[vf::lbm::dir::PZP] = mfcbc; + distribution.f[vf::lbm::dir::MZM] = mfaba; + distribution.f[vf::lbm::dir::PZM] = mfcba; + distribution.f[vf::lbm::dir::MZP] = mfabc; + distribution.f[vf::lbm::dir::ZPP] = mfbcc; + distribution.f[vf::lbm::dir::ZMM] = mfbaa; + distribution.f[vf::lbm::dir::ZPM] = mfbca; + distribution.f[vf::lbm::dir::ZMP] = mfbac; + distribution.f[vf::lbm::dir::PPP] = mfccc; + distribution.f[vf::lbm::dir::MPP] = mfacc; + distribution.f[vf::lbm::dir::PMP] = mfcac; + distribution.f[vf::lbm::dir::MMP] = mfaac; + distribution.f[vf::lbm::dir::PPM] = mfcca; + distribution.f[vf::lbm::dir::MPM] = mfaca; + distribution.f[vf::lbm::dir::PMM] = mfcaa; + distribution.f[vf::lbm::dir::MMM] = mfaaa; + distribution.f[vf::lbm::dir::ZZZ] = mfbbb; + + vf::lbm::KernelParameter parameter {distribution, omega, forces}; + vf::lbm::cumulantChimera(parameter, vf::lbm::setRelaxationRatesK17); + + mfcbb = distribution.f[vf::lbm::dir::PZZ]; + mfabb = distribution.f[vf::lbm::dir::MZZ]; + mfbcb = distribution.f[vf::lbm::dir::ZPZ]; + mfbab = distribution.f[vf::lbm::dir::ZMZ]; + mfbbc = distribution.f[vf::lbm::dir::ZZP]; + mfbba = distribution.f[vf::lbm::dir::ZZM]; + mfccb = distribution.f[vf::lbm::dir::PPZ]; + mfaab = distribution.f[vf::lbm::dir::MMZ]; + mfcab = distribution.f[vf::lbm::dir::PMZ]; + mfacb = distribution.f[vf::lbm::dir::MPZ]; + mfcbc = distribution.f[vf::lbm::dir::PZP]; + mfaba = distribution.f[vf::lbm::dir::MZM]; + mfcba = distribution.f[vf::lbm::dir::PZM]; + mfabc = distribution.f[vf::lbm::dir::MZP]; + mfbcc = distribution.f[vf::lbm::dir::ZPP]; + mfbaa = distribution.f[vf::lbm::dir::ZMM]; + mfbca = distribution.f[vf::lbm::dir::ZPM]; + mfbac = distribution.f[vf::lbm::dir::ZMP]; + mfccc = distribution.f[vf::lbm::dir::PPP]; + mfacc = distribution.f[vf::lbm::dir::MPP]; + mfcac = distribution.f[vf::lbm::dir::PMP]; + mfaac = distribution.f[vf::lbm::dir::MMP]; + mfcca = distribution.f[vf::lbm::dir::PPM]; + mfaca = distribution.f[vf::lbm::dir::MPM]; + mfcaa = distribution.f[vf::lbm::dir::PMM]; + mfaaa = distribution.f[vf::lbm::dir::MMM]; + mfbbb = distribution.f[vf::lbm::dir::ZZZ]; + + ////////////////////////////////////////////////////////////////////////// + //proof correctness + ////////////////////////////////////////////////////////////////////////// +#ifdef PROOF_CORRECTNESS + LBMReal drho_post = (mfaaa + mfaac + mfaca + mfcaa + mfacc + mfcac + mfccc + mfcca) + + (mfaab + mfacb + mfcab + mfccb) + (mfaba + mfabc + mfcba + mfcbc) + (mfbaa + mfbac + mfbca + mfbcc) + + (mfabb + mfcbb) + (mfbab + mfbcb) + (mfbba + mfbbc) + mfbbb; + LBMReal dif = distribution.getDensity_() - drho_post; +#ifdef SINGLEPRECISION + if (dif > 10.0E-7 || dif < -10.0E-7) +#else + if (dif > 10.0E-15 || dif < -10.0E-15) +#endif + { + UB_THROW(UbException(UB_EXARGS, "rho=" + UbSystem::toString(distribution.getDensity_()) + ", rho_post=" + UbSystem::toString(drho_post) + + " dif=" + UbSystem::toString(dif) + + " rho is not correct for node " + UbSystem::toString(x1) + "," + UbSystem::toString(x2) + "," + UbSystem::toString(x3) + + " in " + block.lock()->toString() + " step = " + UbSystem::toString(step))); + } +#endif + + (*this->localDistributions)(D3Q27System::ET_E, x1, x2, x3) = mfcbb; + (*this->localDistributions)(D3Q27System::ET_N, x1, x2, x3) = mfbcb; + (*this->localDistributions)(D3Q27System::ET_T, x1, x2, x3) = mfbbc; + (*this->localDistributions)(D3Q27System::ET_NE, x1, x2, x3) = mfccb; + (*this->localDistributions)(D3Q27System::ET_NW, x1p, x2, x3) = mfacb; + (*this->localDistributions)(D3Q27System::ET_TE, x1, x2, x3) = mfcbc; + (*this->localDistributions)(D3Q27System::ET_TW, x1p, x2, x3) = mfabc; + (*this->localDistributions)(D3Q27System::ET_TN, x1, x2, x3) = mfbcc; + (*this->localDistributions)(D3Q27System::ET_TS, x1, x2p, x3) = mfbac; + (*this->localDistributions)(D3Q27System::ET_TNE, x1, x2, x3) = mfccc; + (*this->localDistributions)(D3Q27System::ET_TNW, x1p, x2, x3) = mfacc; + (*this->localDistributions)(D3Q27System::ET_TSE, x1, x2p, x3) = mfcac; + (*this->localDistributions)(D3Q27System::ET_TSW, x1p, x2p, x3) = mfaac; + + (*this->nonLocalDistributions)(D3Q27System::ET_W, x1p, x2, x3) = mfabb; + (*this->nonLocalDistributions)(D3Q27System::ET_S, x1, x2p, x3) = mfbab; + (*this->nonLocalDistributions)(D3Q27System::ET_B, x1, x2, x3p) = mfbba; + (*this->nonLocalDistributions)(D3Q27System::ET_SW, x1p, x2p, x3) = mfaab; + (*this->nonLocalDistributions)(D3Q27System::ET_SE, x1, x2p, x3) = mfcab; + (*this->nonLocalDistributions)(D3Q27System::ET_BW, x1p, x2, x3p) = mfaba; + (*this->nonLocalDistributions)(D3Q27System::ET_BE, x1, x2, x3p) = mfcba; + (*this->nonLocalDistributions)(D3Q27System::ET_BS, x1, x2p, x3p) = mfbaa; + (*this->nonLocalDistributions)(D3Q27System::ET_BN, x1, x2, x3p) = mfbca; + (*this->nonLocalDistributions)(D3Q27System::ET_BSW, x1p, x2p, x3p) = mfaaa; + (*this->nonLocalDistributions)(D3Q27System::ET_BSE, x1, x2p, x3p) = mfcaa; + (*this->nonLocalDistributions)(D3Q27System::ET_BNW, x1p, x2, x3p) = mfaca; + (*this->nonLocalDistributions)(D3Q27System::ET_BNE, x1, x2, x3p) = mfcca; + (*this->restDistributions)(x1, x2, x3) = mfbbb; + ////////////////////////////////////////////////////////////////////////// + + } + } + } + } +} +////////////////////////////////////////////////////////////////////////// + diff --git a/src/cpu/VirtualFluidsCore/LBM/CumulantK17LBMKernelUnified.h b/src/cpu/VirtualFluidsCore/LBM/CumulantK17LBMKernelUnified.h new file mode 100644 index 0000000000000000000000000000000000000000..175fdd4cba2a0c8ce47248f5de6672f34dda0cc3 --- /dev/null +++ b/src/cpu/VirtualFluidsCore/LBM/CumulantK17LBMKernelUnified.h @@ -0,0 +1,77 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// 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 CumulantK17LBMKernel.h +//! \ingroup LBM +//! \author Konstantin Kutscher, Martin Geier +//======================================================================================= + +#ifndef CumulantK17LBMKernelUnified_h__ +#define CumulantK17LBMKernelUnified_h__ + +#include "LBMKernel.h" +#include "BCProcessor.h" +#include "D3Q27System.h" +#include "basics/utilities/UbTiming.h" +#include "basics/container/CbArray4D.h" +#include "basics/container/CbArray3D.h" + +//! \brief Compressible cumulant LBM kernel. +//! \details LBM implementation that use Cascaded Cumulant Lattice Boltzmann method for D3Q27 model +//! +//! The model is publisched in +//! <a href="http://dx.doi.org/10.1016/j.jcp.2017.05.040"><b>[ Geier et al., (2017), 10.1016/j.jcp.2017.05.040]</b></a>, +//! <a href="http://dx.doi.org/10.1016/j.jcp.2017.07.004"><b>[ Geier et al., (2017), 10.1016/j.jcp.2017.07.004]</b></a> +//! +class CumulantK17LBMKernelUnified : public LBMKernel +{ +public: + CumulantK17LBMKernelUnified(); + ~CumulantK17LBMKernelUnified() = default; + void calculate(int step) override; + SPtr<LBMKernel> clone() override; + double getCalculationTime() override { return .0; } + +protected: + virtual void initDataSet(); + LBMReal f[D3Q27System::ENDF + 1]; + + CbArray4D<LBMReal, IndexerX4X3X2X1>::CbArray4DPtr localDistributions; + CbArray4D<LBMReal, IndexerX4X3X2X1>::CbArray4DPtr nonLocalDistributions; + CbArray3D<LBMReal, IndexerX3X2X1>::CbArray3DPtr restDistributions; + + mu::value_type muX1, muX2, muX3; + mu::value_type muDeltaT; + mu::value_type muNu; + LBMReal forcingX1; + LBMReal forcingX2; + LBMReal forcingX3; +}; + + +#endif // CumulantK17LBMKernel_h__ \ No newline at end of file diff --git a/src/cpu/VirtualFluidsCore/LBM/D3Q27System.cpp b/src/cpu/VirtualFluidsCore/LBM/D3Q27System.cpp index 5e88242fa23bdf37386f4f4d293ed7c2c33750ee..105603b35d043799672a58fda83ba503af70b703 100644 --- a/src/cpu/VirtualFluidsCore/LBM/D3Q27System.cpp +++ b/src/cpu/VirtualFluidsCore/LBM/D3Q27System.cpp @@ -1,5 +1,7 @@ #include "D3Q27System.h" +#include "lbm/MacroscopicQuantities.h" + namespace D3Q27System { using namespace UbMath; @@ -18,4 +20,31 @@ const int INVDIR[] = { INV_E, INV_W, INV_N, INV_S, INV_T, INV_B, INV INV_NW, INV_TE, INV_BW, INV_BE, INV_TW, INV_TN, INV_BS, INV_BN, INV_TS, INV_TNE, INV_TNW, INV_TSE, INV_TSW, INV_BNE, INV_BNW, INV_BSE, INV_BSW }; + + + +LBMReal getDensity(const LBMReal *const &f /*[27]*/) +{ + return vf::lbm::getDensity(f); +} + +LBMReal getIncompVelocityX1(const LBMReal *const &f /*[27]*/) +{ + return vf::lbm::getIncompressibleVelocityX1(f); +} + +LBMReal getIncompVelocityX2(const LBMReal *const &f /*[27]*/) +{ + return vf::lbm::getIncompressibleVelocityX2(f); +} + +LBMReal getIncompVelocityX3(const LBMReal *const &f /*[27]*/) +{ + return vf::lbm::getIncompressibleVelocityX3(f); +} + + + + + } // namespace D3Q27System \ No newline at end of file diff --git a/src/cpu/VirtualFluidsCore/LBM/D3Q27System.h b/src/cpu/VirtualFluidsCore/LBM/D3Q27System.h index 8f8c376459ce0b9bd4d0b7691655c173a6d4e149..04fe8a819b143db8cc935fc893faa514805060a6 100644 --- a/src/cpu/VirtualFluidsCore/LBM/D3Q27System.h +++ b/src/cpu/VirtualFluidsCore/LBM/D3Q27System.h @@ -42,6 +42,7 @@ #include "UbException.h" #include "UbMath.h" + //! \brief namespace for global system-functions namespace D3Q27System { @@ -147,36 +148,21 @@ static const int ET_BNW = 11; static const int ET_TSW = 12; static const int ET_BNE = 12; + ////////////////////////////////////////////////////////////////////////// // MACROSCOPIC VALUES /*=====================================================================*/ -static LBMReal getDensity(const LBMReal *const &f /*[27]*/) -{ - return ((f[TNE] + f[BSW]) + (f[TSE] + f[BNW])) + ((f[BSE] + f[TNW]) + (f[TSW] + f[BNE])) + - (((f[NE] + f[SW]) + (f[SE] + f[NW])) + ((f[TE] + f[BW]) + (f[BE] + f[TW])) + - ((f[BN] + f[TS]) + (f[TN] + f[BS]))) + - ((f[E] + f[W]) + (f[N] + f[S]) + (f[T] + f[B])) + f[REST]; -} +LBMReal getDensity(const LBMReal *const &f /*[27]*/); /*=====================================================================*/ static LBMReal getPressure(const LBMReal *const &f /*[27]*/) { return REAL_CAST(UbMath::c1o3) * getDensity(f); } /*=====================================================================*/ -static LBMReal getIncompVelocityX1(const LBMReal *const &f /*[27]*/) -{ - return ((((f[TNE] - f[BSW]) + (f[TSE] - f[BNW])) + ((f[BSE] - f[TNW]) + (f[BNE] - f[TSW]))) + - (((f[BE] - f[TW]) + (f[TE] - f[BW])) + ((f[SE] - f[NW]) + (f[NE] - f[SW]))) + (f[E] - f[W])); -} +LBMReal getIncompVelocityX1(const LBMReal *const &f /*[27]*/); /*=====================================================================*/ -static LBMReal getIncompVelocityX2(const LBMReal *const &f /*[27]*/) -{ - return ((((f[TNE] - f[BSW]) + (f[BNW] - f[TSE])) + ((f[TNW] - f[BSE]) + (f[BNE] - f[TSW]))) + - (((f[BN] - f[TS]) + (f[TN] - f[BS])) + ((f[NW] - f[SE]) + (f[NE] - f[SW]))) + (f[N] - f[S])); -} +LBMReal getIncompVelocityX2(const LBMReal *const &f /*[27]*/); /*=====================================================================*/ -static LBMReal getIncompVelocityX3(const LBMReal *const &f /*[27]*/) -{ - return ((((f[TNE] - f[BSW]) + (f[TSE] - f[BNW])) + ((f[TNW] - f[BSE]) + (f[TSW] - f[BNE]))) + - (((f[TS] - f[BN]) + (f[TN] - f[BS])) + ((f[TW] - f[BE]) + (f[TE] - f[BW]))) + (f[T] - f[B])); -} +LBMReal getIncompVelocityX3(const LBMReal *const &f /*[27]*/); + + /*=====================================================================*/ static void calcDensity(const LBMReal *const &f /*[27]*/, LBMReal &rho) { diff --git a/src/cpu/VirtualFluidsCore/LBM/ILBMKernel.h b/src/cpu/VirtualFluidsCore/LBM/ILBMKernel.h index 4dbe8eee09a37c0c220f47619b72bade2e6ec527..bde61d9d314b61327ff8f8a2a71d2864d50cc7f5 100644 --- a/src/cpu/VirtualFluidsCore/LBM/ILBMKernel.h +++ b/src/cpu/VirtualFluidsCore/LBM/ILBMKernel.h @@ -36,6 +36,8 @@ #include <PointerDefinitions.h> +#include "LBMSystem.h" + class BCProcessor; class DataSet3D; @@ -57,7 +59,7 @@ public: virtual void setCollisionFactor(double collFactor) = 0; virtual bool isInsideOfDomain(const int &x1, const int &x2, const int &x3) const = 0; virtual int getGhostLayerWidth() const = 0; - virtual double getDeltaT() const = 0; + virtual LBMReal getDeltaT() const = 0; virtual bool getWithForcing() const = 0; }; diff --git a/src/cpu/VirtualFluidsCore/LBM/LBMKernel.cpp b/src/cpu/VirtualFluidsCore/LBM/LBMKernel.cpp index 92a475c1ea4de06abb3f66bf42924273904f84cc..3c588e1506d8649149daad5588e2290c0832334a 100644 --- a/src/cpu/VirtualFluidsCore/LBM/LBMKernel.cpp +++ b/src/cpu/VirtualFluidsCore/LBM/LBMKernel.cpp @@ -202,13 +202,13 @@ void LBMKernel::setDensityRatio(double densityRatio) { this->densityRatio = dens ////////////////////////////////////////////////////////////////////////// double LBMKernel::getDensityRatio() const { return densityRatio; } ////////////////////////////////////////////////////////////////////////// -void LBMKernel::setMultiphaseModelParameters(double beta, double kappa) +void LBMKernel::setMultiphaseModelParameters(LBMReal beta, LBMReal kappa) { this->beta = beta; this->kappa = kappa; } ////////////////////////////////////////////////////////////////////////// -void LBMKernel::getMultiphaseModelParameters(double &beta, double &kappa) +void LBMKernel::getMultiphaseModelParameters(LBMReal &beta, LBMReal &kappa) { beta = this->beta; kappa = this->kappa; diff --git a/src/cpu/VirtualFluidsCore/LBM/LBMKernel.h b/src/cpu/VirtualFluidsCore/LBM/LBMKernel.h index 2c65e4d761cff39e638eb9c66d73a489b387b70c..39205287bff9997bb6531940354395d9786abc97 100644 --- a/src/cpu/VirtualFluidsCore/LBM/LBMKernel.h +++ b/src/cpu/VirtualFluidsCore/LBM/LBMKernel.h @@ -53,6 +53,7 @@ public: public: LBMKernel(); + virtual ~LBMKernel() = default; virtual SPtr<LBMKernel> clone() = 0; @@ -117,8 +118,8 @@ public: double getCollisionFactorG() const; void setDensityRatio(double densityRatio); double getDensityRatio() const; - void setMultiphaseModelParameters(double beta, double kappa); - void getMultiphaseModelParameters(double &beta, double &kappa); + void setMultiphaseModelParameters(LBMReal beta, LBMReal kappa); + void getMultiphaseModelParameters(LBMReal &beta, LBMReal &kappa); void setContactAngle(double contactAngle); double getContactAngle() const; void setPhiL(double phiL); diff --git a/src/cpu/VirtualFluidsCore/LBM/LBMSystem.h b/src/cpu/VirtualFluidsCore/LBM/LBMSystem.h index d24775aef0fbe6822fbdc03d42e2acfeb3021430..14b4d223b2e07e3dbca9947cefd89de045bfb3cf 100644 --- a/src/cpu/VirtualFluidsCore/LBM/LBMSystem.h +++ b/src/cpu/VirtualFluidsCore/LBM/LBMSystem.h @@ -37,6 +37,8 @@ #include <iostream> #include <string> +#include "basics/Core/DataTypes.h" + //! \brief namespace for global system-functions namespace LBMSystem @@ -45,10 +47,10 @@ namespace LBMSystem //#define SINGLEPRECISION #ifdef SINGLEPRECISION -typedef float real; +//using real = float; #define REAL_CAST(x) ((LBMSystem::real)(x)) #else -using real = double; +//using real = double; #define REAL_CAST(x) (x) #endif @@ -82,6 +84,7 @@ static real calcOmega2(real viscosity, real deltaT) { return REAL_CAST(1.0 / (4. } // namespace LBMSystem // some typedefs for global namespace -using LBMReal = LBMSystem::real; +//using LBMReal = LBMSystem::real; +using LBMReal = real; #endif diff --git a/src/cpu/VirtualFluidsCore/LBM/MultiphasePressureFilterCompressibleAirLBMKernel.cpp b/src/cpu/VirtualFluidsCore/LBM/MultiphasePressureFilterCompressibleAirLBMKernel.cpp new file mode 100644 index 0000000000000000000000000000000000000000..01fb23625afbf4700c337cf6ee7194a46f0bc895 --- /dev/null +++ b/src/cpu/VirtualFluidsCore/LBM/MultiphasePressureFilterCompressibleAirLBMKernel.cpp @@ -0,0 +1,1669 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// 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 MultiphasePressureFilterCompressibleAirLBMKernel.cpp +//! \ingroup LBMKernel +//! \author M. Geier, K. Kutscher, Hesameddin Safari +//======================================================================================= + +#include "MultiphasePressureFilterCompressibleAirLBMKernel.h" +#include "BCArray3D.h" +#include "Block3D.h" +#include "D3Q27EsoTwist3DSplittedVector.h" +#include "D3Q27System.h" +#include "DataSet3D.h" +#include "LBMKernel.h" +#include <cmath> + +#define PROOF_CORRECTNESS + +////////////////////////////////////////////////////////////////////////// +MultiphasePressureFilterCompressibleAirLBMKernel::MultiphasePressureFilterCompressibleAirLBMKernel() { this->compressible = false; } +////////////////////////////////////////////////////////////////////////// +void MultiphasePressureFilterCompressibleAirLBMKernel::initDataSet() +{ + SPtr<DistributionArray3D> f(new D3Q27EsoTwist3DSplittedVector( nx[0] + 4, nx[1] + 4, nx[2] + 4, -999.9)); + SPtr<DistributionArray3D> h(new D3Q27EsoTwist3DSplittedVector( nx[0] + 4, nx[1] + 4, nx[2] + 4, -999.9)); // For phase-field + + SPtr<PhaseFieldArray3D> divU1(new PhaseFieldArray3D( nx[0] + 4, nx[1] + 4, nx[2] + 4, 0.0)); + CbArray3D<LBMReal, IndexerX3X2X1>::CbArray3DPtr pressure(new CbArray3D<LBMReal, IndexerX3X2X1>( nx[0] + 4, nx[1] + 4, nx[2] + 4, 0.0)); + pressureOld = CbArray3D<LBMReal, IndexerX3X2X1>::CbArray3DPtr(new CbArray3D<LBMReal, IndexerX3X2X1>(nx[0] + 4, nx[1] + 4, nx[2] + 4, 0.0)); + dataSet->setFdistributions(f); + dataSet->setHdistributions(h); // For phase-field + dataSet->setPhaseField(divU1); + dataSet->setPressureField(pressure); + + phaseField = CbArray3D<LBMReal, IndexerX3X2X1>::CbArray3DPtr(new CbArray3D<LBMReal, IndexerX3X2X1>(nx[0] + 4, nx[1] + 4, nx[2] + 4, -999.0)); + + divU = CbArray3D<LBMReal, IndexerX3X2X1>::CbArray3DPtr(new CbArray3D<LBMReal, IndexerX3X2X1>(nx[0] + 4, nx[1] + 4, nx[2] + 4, 0.0)); +} +////////////////////////////////////////////////////////////////////////// +SPtr<LBMKernel> MultiphasePressureFilterCompressibleAirLBMKernel::clone() +{ + SPtr<LBMKernel> kernel(new MultiphasePressureFilterCompressibleAirLBMKernel()); + kernel->setNX(nx); + dynamicPointerCast<MultiphasePressureFilterCompressibleAirLBMKernel>(kernel)->initDataSet(); + kernel->setCollisionFactorMultiphase(this->collFactorL, this->collFactorG); + kernel->setDensityRatio(this->densityRatio); + kernel->setMultiphaseModelParameters(this->beta, this->kappa); + kernel->setContactAngle(this->contactAngle); + kernel->setPhiL(this->phiL); + kernel->setPhiH(this->phiH); + kernel->setPhaseFieldRelaxation(this->tauH); + kernel->setMobility(this->mob); + kernel->setInterfaceWidth(this->interfaceWidth); + + kernel->setBCProcessor(bcProcessor->clone(kernel)); + kernel->setWithForcing(withForcing); + kernel->setForcingX1(muForcingX1); + kernel->setForcingX2(muForcingX2); + kernel->setForcingX3(muForcingX3); + kernel->setIndex(ix1, ix2, ix3); + kernel->setDeltaT(deltaT); + kernel->setGhostLayerWidth(2); + dynamicPointerCast<MultiphasePressureFilterCompressibleAirLBMKernel>(kernel)->initForcing(); + + return kernel; +} +////////////////////////////////////////////////////////////////////////// +void MultiphasePressureFilterCompressibleAirLBMKernel::forwardInverseChimeraWithKincompressible(LBMReal& mfa, LBMReal& mfb, LBMReal& mfc, LBMReal vv, LBMReal v2, LBMReal Kinverse, LBMReal K, LBMReal oneMinusRho) { + using namespace UbMath; + LBMReal m2 = mfa + mfc; + LBMReal m1 = mfc - mfa; + LBMReal m0 = m2 + mfb; + mfa = m0; + m0 *= Kinverse; + m0 += oneMinusRho; + mfb = (m1 * Kinverse - m0 * vv) * K; + mfc = ((m2 - c2 * m1 * vv) * Kinverse + v2 * m0) * K; +} + +//////////////////////////////////////////////////////////////////////////////// +void MultiphasePressureFilterCompressibleAirLBMKernel::backwardInverseChimeraWithKincompressible(LBMReal& mfa, LBMReal& mfb, LBMReal& mfc, LBMReal vv, LBMReal v2, LBMReal Kinverse, LBMReal K, LBMReal oneMinusRho) { + using namespace UbMath; + LBMReal m0 = (((mfc - mfb) * c1o2 + mfb * vv) * Kinverse + (mfa * Kinverse + oneMinusRho) * (v2 - vv) * c1o2) * K; + LBMReal m1 = (((mfa - mfc) - c2 * mfb * vv) * Kinverse + (mfa * Kinverse + oneMinusRho) * (-v2)) * K; + mfc = (((mfc + mfb) * c1o2 + mfb * vv) * Kinverse + (mfa * Kinverse + oneMinusRho) * (v2 + vv) * c1o2) * K; + mfa = m0; + mfb = m1; +} + + +//////////////////////////////////////////////////////////////////////////////// +void MultiphasePressureFilterCompressibleAirLBMKernel::forwardChimera(LBMReal& mfa, LBMReal& mfb, LBMReal& mfc, LBMReal vv, LBMReal v2) { + using namespace UbMath; + LBMReal m1 = (mfa + mfc) + mfb; + LBMReal m2 = mfc - mfa; + mfc = (mfc + mfa) + (v2 * m1 - c2 * vv * m2); + mfb = m2 - vv * m1; + mfa = m1; +} + + +void MultiphasePressureFilterCompressibleAirLBMKernel::backwardChimera(LBMReal& mfa, LBMReal& mfb, LBMReal& mfc, LBMReal vv, LBMReal v2) { + using namespace UbMath; + LBMReal ma = (mfc + mfa * (v2 - vv)) * c1o2 + mfb * (vv - c1o2); + LBMReal mb = ((mfa - mfc) - mfa * v2) - c2 * mfb * vv; + mfc = (mfc + mfa * (v2 + vv)) * c1o2 + mfb * (vv + c1o2); + mfb = mb; + mfa = ma; +} + + +void MultiphasePressureFilterCompressibleAirLBMKernel::calculate(int step) +{ + using namespace D3Q27System; + using namespace UbMath; + + forcingX1 = 0.0; + forcingX2 = 0.0; + forcingX3 = 0.0; + + LBMReal oneOverInterfaceScale = c4 / interfaceWidth; //1.0;//1.5; + ///////////////////////////////////// + + localDistributionsF = dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(dataSet->getFdistributions())->getLocalDistributions(); + nonLocalDistributionsF = dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(dataSet->getFdistributions())->getNonLocalDistributions(); + zeroDistributionsF = dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(dataSet->getFdistributions())->getZeroDistributions(); + + localDistributionsH1 = dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(dataSet->getHdistributions())->getLocalDistributions(); + nonLocalDistributionsH1 = dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(dataSet->getHdistributions())->getNonLocalDistributions(); + zeroDistributionsH1 = dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(dataSet->getHdistributions())->getZeroDistributions(); + + CbArray3D<LBMReal, IndexerX3X2X1>::CbArray3DPtr pressure = dataSet->getPressureField(); + + SPtr<BCArray3D> bcArray = this->getBCProcessor()->getBCArray(); + + const int bcArrayMaxX1 = (int)bcArray->getNX1(); + const int bcArrayMaxX2 = (int)bcArray->getNX2(); + const int bcArrayMaxX3 = (int)bcArray->getNX3(); + + int minX1 = ghostLayerWidth; + int minX2 = ghostLayerWidth; + int minX3 = ghostLayerWidth; + int maxX1 = bcArrayMaxX1 - ghostLayerWidth; + int maxX2 = bcArrayMaxX2 - ghostLayerWidth; + int maxX3 = bcArrayMaxX3 - ghostLayerWidth; + + for (int x3 = minX3-ghostLayerWidth; x3 < maxX3+ghostLayerWidth; x3++) { + for (int x2 = minX2-ghostLayerWidth; x2 < maxX2+ghostLayerWidth; x2++) { + for (int x1 = minX1-ghostLayerWidth; x1 < maxX1+ghostLayerWidth; x1++) { + if (!bcArray->isSolid(x1, x2, x3) && !bcArray->isUndefined(x1, x2, x3)) { + int x1p = x1 + 1; + int x2p = x2 + 1; + int x3p = x3 + 1; + + LBMReal mfcbb = (*this->localDistributionsH1)(D3Q27System::ET_E, x1, x2, x3); + LBMReal mfbcb = (*this->localDistributionsH1)(D3Q27System::ET_N, x1, x2, x3); + LBMReal mfbbc = (*this->localDistributionsH1)(D3Q27System::ET_T, x1, x2, x3); + LBMReal mfccb = (*this->localDistributionsH1)(D3Q27System::ET_NE, x1, x2, x3); + LBMReal mfacb = (*this->localDistributionsH1)(D3Q27System::ET_NW, x1p, x2, x3); + LBMReal mfcbc = (*this->localDistributionsH1)(D3Q27System::ET_TE, x1, x2, x3); + LBMReal mfabc = (*this->localDistributionsH1)(D3Q27System::ET_TW, x1p, x2, x3); + LBMReal mfbcc = (*this->localDistributionsH1)(D3Q27System::ET_TN, x1, x2, x3); + LBMReal mfbac = (*this->localDistributionsH1)(D3Q27System::ET_TS, x1, x2p, x3); + LBMReal mfccc = (*this->localDistributionsH1)(D3Q27System::ET_TNE, x1, x2, x3); + LBMReal mfacc = (*this->localDistributionsH1)(D3Q27System::ET_TNW, x1p, x2, x3); + LBMReal mfcac = (*this->localDistributionsH1)(D3Q27System::ET_TSE, x1, x2p, x3); + LBMReal mfaac = (*this->localDistributionsH1)(D3Q27System::ET_TSW, x1p, x2p, x3); + LBMReal mfabb = (*this->nonLocalDistributionsH1)(D3Q27System::ET_W, x1p, x2, x3); + LBMReal mfbab = (*this->nonLocalDistributionsH1)(D3Q27System::ET_S, x1, x2p, x3); + LBMReal mfbba = (*this->nonLocalDistributionsH1)(D3Q27System::ET_B, x1, x2, x3p); + LBMReal mfaab = (*this->nonLocalDistributionsH1)(D3Q27System::ET_SW, x1p, x2p, x3); + LBMReal mfcab = (*this->nonLocalDistributionsH1)(D3Q27System::ET_SE, x1, x2p, x3); + LBMReal mfaba = (*this->nonLocalDistributionsH1)(D3Q27System::ET_BW, x1p, x2, x3p); + LBMReal mfcba = (*this->nonLocalDistributionsH1)(D3Q27System::ET_BE, x1, x2, x3p); + LBMReal mfbaa = (*this->nonLocalDistributionsH1)(D3Q27System::ET_BS, x1, x2p, x3p); + LBMReal mfbca = (*this->nonLocalDistributionsH1)(D3Q27System::ET_BN, x1, x2, x3p); + LBMReal mfaaa = (*this->nonLocalDistributionsH1)(D3Q27System::ET_BSW, x1p, x2p, x3p); + LBMReal mfcaa = (*this->nonLocalDistributionsH1)(D3Q27System::ET_BSE, x1, x2p, x3p); + LBMReal mfaca = (*this->nonLocalDistributionsH1)(D3Q27System::ET_BNW, x1p, x2, x3p); + LBMReal mfcca = (*this->nonLocalDistributionsH1)(D3Q27System::ET_BNE, x1, x2, x3p); + + LBMReal mfbbb = (*this->zeroDistributionsH1)(x1, x2, x3); + (*phaseField)(x1, x2, x3) = (((mfaaa + mfccc) + (mfaca + mfcac)) + ((mfaac + mfcca) + (mfcaa + mfacc)) ) + + (((mfaab + mfacb) + (mfcab + mfccb)) + ((mfaba + mfabc) + (mfcba + mfcbc)) + + ((mfbaa + mfbac) + (mfbca + mfbcc))) + ((mfabb + mfcbb) + + (mfbab + mfbcb) + (mfbba + mfbbc)) + mfbbb; + + ////// read F-distributions for velocity formalism + + mfcbb = (*this->localDistributionsF)(D3Q27System::ET_E, x1, x2, x3); + mfbcb = (*this->localDistributionsF)(D3Q27System::ET_N, x1, x2, x3); + mfbbc = (*this->localDistributionsF)(D3Q27System::ET_T, x1, x2, x3); + mfccb = (*this->localDistributionsF)(D3Q27System::ET_NE, x1, x2, x3); + mfacb = (*this->localDistributionsF)(D3Q27System::ET_NW, x1p, x2, x3); + mfcbc = (*this->localDistributionsF)(D3Q27System::ET_TE, x1, x2, x3); + mfabc = (*this->localDistributionsF)(D3Q27System::ET_TW, x1p, x2, x3); + mfbcc = (*this->localDistributionsF)(D3Q27System::ET_TN, x1, x2, x3); + mfbac = (*this->localDistributionsF)(D3Q27System::ET_TS, x1, x2p, x3); + mfccc = (*this->localDistributionsF)(D3Q27System::ET_TNE, x1, x2, x3); + mfacc = (*this->localDistributionsF)(D3Q27System::ET_TNW, x1p, x2, x3); + mfcac = (*this->localDistributionsF)(D3Q27System::ET_TSE, x1, x2p, x3); + mfaac = (*this->localDistributionsF)(D3Q27System::ET_TSW, x1p, x2p, x3); + mfabb = (*this->nonLocalDistributionsF)(D3Q27System::ET_W, x1p, x2, x3); + mfbab = (*this->nonLocalDistributionsF)(D3Q27System::ET_S, x1, x2p, x3); + mfbba = (*this->nonLocalDistributionsF)(D3Q27System::ET_B, x1, x2, x3p); + mfaab = (*this->nonLocalDistributionsF)(D3Q27System::ET_SW, x1p, x2p, x3); + mfcab = (*this->nonLocalDistributionsF)(D3Q27System::ET_SE, x1, x2p, x3); + mfaba = (*this->nonLocalDistributionsF)(D3Q27System::ET_BW, x1p, x2, x3p); + mfcba = (*this->nonLocalDistributionsF)(D3Q27System::ET_BE, x1, x2, x3p); + mfbaa = (*this->nonLocalDistributionsF)(D3Q27System::ET_BS, x1, x2p, x3p); + mfbca = (*this->nonLocalDistributionsF)(D3Q27System::ET_BN, x1, x2, x3p); + mfaaa = (*this->nonLocalDistributionsF)(D3Q27System::ET_BSW, x1p, x2p, x3p); + mfcaa = (*this->nonLocalDistributionsF)(D3Q27System::ET_BSE, x1, x2p, x3p); + mfaca = (*this->nonLocalDistributionsF)(D3Q27System::ET_BNW, x1p, x2, x3p); + mfcca = (*this->nonLocalDistributionsF)(D3Q27System::ET_BNE, x1, x2, x3p); + + mfbbb = (*this->zeroDistributionsF)(x1, x2, x3); + + LBMReal rhoH = 1.0; + LBMReal rhoL = 1.0 / densityRatio; + + LBMReal rhoToPhi = (rhoH - rhoL) / (phiH - phiL); + + LBMReal drho = (mfaaa + mfaac + mfaca + mfcaa + mfacc + mfcac + mfccc + mfcca) + + (mfaab + mfacb + mfcab + mfccb) + (mfaba + mfabc + mfcba + mfcbc) + (mfbaa + mfbac + mfbca + mfbcc) + + (mfabb + mfcbb) + (mfbab + mfbcb) + (mfbba + mfbbc) + mfbbb; + + LBMReal rho = rhoH + rhoToPhi * ((*phaseField)(x1, x2, x3) - phiH); //Incompressible + //LBMReal rho = rhoH + rhoToPhi * ((*pressure)(x1, x2, x3) - phiH); //wrong? + //! variable density -> TRANSFER! + //LBMReal rho = rhoH * ((*phaseField)(x1, x2, x3)) + rhoL * ((*phaseField2)(x1, x2, x3)); + + (*pressureOld)(x1, x2, x3) = (*pressure)(x1, x2, x3) + rho * c1o3 * drho; + + //(*pressure)(x1, x2, x3) = (((*phaseField)(x1, x2, x3)) + ((*phaseField2)(x1, x2, x3)) - c1) * c1o3; + ////!!!!!! relplace by pointer swap! + //(*pressureOld)(x1, x2, x3) = (*pressure)(x1, x2, x3); + } + } + } + } + + LBMReal collFactorM; + + ////Periodic Filter + for (int x3 = minX3-1; x3 <= maxX3; x3++) { + for (int x2 = minX2-1; x2 <= maxX2; x2++) { + for (int x1 = minX1-1; x1 <= maxX1; x1++) { + if (!bcArray->isSolid(x1, x2, x3) && !bcArray->isUndefined(x1, x2, x3)) { + + LBMReal sum = 0.; + + ///Version for boundaries + for (int xx = -1; xx <= 1; xx++) { + //int xxx = (xx+x1 <= maxX1) ? ((xx + x1 > 0) ? xx + x1 : maxX1) : 0; + int xxx = xx + x1; + + for (int yy = -1; yy <= 1; yy++) { + //int yyy = (yy+x2 <= maxX2) ?( (yy + x2 > 0) ? yy + x2 : maxX2) : 0; + int yyy = yy + x2; + + for (int zz = -1; zz <= 1; zz++) { + //int zzz = (zz+x3 <= maxX3) ? zzz = ((zz + x3 > 0) ? zz + x3 : maxX3 ): 0; + int zzz = zz + x3; + + if (!bcArray->isSolid(xxx, yyy, zzz) && !bcArray->isUndefined(xxx, yyy, zzz)) { + sum+= 64.0/(216.0*(c1+c3*abs(xx))* (c1 + c3 * abs(yy))* (c1 + c3 * abs(zz)))*(*pressureOld)(xxx, yyy, zzz); + } + else{ sum+= 64.0 / (216.0 * (c1 + c3 * abs(xx)) * (c1 + c3 * abs(yy)) * (c1 + c3 * abs(zz))) * (*pressureOld)(x1, x2, x3); + } + + + } + } + } + (*pressure)(x1, x2, x3) = sum; + } + } + } + } + + ////!filter + + for (int x3 = minX3; x3 < maxX3; x3++) { + for (int x2 = minX2; x2 < maxX2; x2++) { + for (int x1 = minX1; x1 < maxX1; x1++) { + if (!bcArray->isSolid(x1, x2, x3) && !bcArray->isUndefined(x1, x2, x3)) { + int x1p = x1 + 1; + int x2p = x2 + 1; + int x3p = x3 + 1; + + ////////////////////////////////////////////////////////////////////////// + // Read distributions and phase field + //////////////////////////////////////////////////////////////////////////// + ////////////////////////////////////////////////////////////////////////// + + // E N T + // c c c + ////////// + // W S B + // a a a + + // Rest ist b + + // mfxyz + // a - negative + // b - null + // c - positive + + // a b c + //-1 0 1 + + findNeighbors(phaseField, x1, x2, x3); + + LBMReal mfcbb = (*this->localDistributionsF)(D3Q27System::ET_E, x1, x2, x3); + LBMReal mfbcb = (*this->localDistributionsF)(D3Q27System::ET_N, x1, x2, x3); + LBMReal mfbbc = (*this->localDistributionsF)(D3Q27System::ET_T, x1, x2, x3); + LBMReal mfccb = (*this->localDistributionsF)(D3Q27System::ET_NE, x1, x2, x3); + LBMReal mfacb = (*this->localDistributionsF)(D3Q27System::ET_NW, x1p, x2, x3); + LBMReal mfcbc = (*this->localDistributionsF)(D3Q27System::ET_TE, x1, x2, x3); + LBMReal mfabc = (*this->localDistributionsF)(D3Q27System::ET_TW, x1p, x2, x3); + LBMReal mfbcc = (*this->localDistributionsF)(D3Q27System::ET_TN, x1, x2, x3); + LBMReal mfbac = (*this->localDistributionsF)(D3Q27System::ET_TS, x1, x2p, x3); + LBMReal mfccc = (*this->localDistributionsF)(D3Q27System::ET_TNE, x1, x2, x3); + LBMReal mfacc = (*this->localDistributionsF)(D3Q27System::ET_TNW, x1p, x2, x3); + LBMReal mfcac = (*this->localDistributionsF)(D3Q27System::ET_TSE, x1, x2p, x3); + LBMReal mfaac = (*this->localDistributionsF)(D3Q27System::ET_TSW, x1p, x2p, x3); + LBMReal mfabb = (*this->nonLocalDistributionsF)(D3Q27System::ET_W, x1p, x2, x3); + LBMReal mfbab = (*this->nonLocalDistributionsF)(D3Q27System::ET_S, x1, x2p, x3); + LBMReal mfbba = (*this->nonLocalDistributionsF)(D3Q27System::ET_B, x1, x2, x3p); + LBMReal mfaab = (*this->nonLocalDistributionsF)(D3Q27System::ET_SW, x1p, x2p, x3); + LBMReal mfcab = (*this->nonLocalDistributionsF)(D3Q27System::ET_SE, x1, x2p, x3); + LBMReal mfaba = (*this->nonLocalDistributionsF)(D3Q27System::ET_BW, x1p, x2, x3p); + LBMReal mfcba = (*this->nonLocalDistributionsF)(D3Q27System::ET_BE, x1, x2, x3p); + LBMReal mfbaa = (*this->nonLocalDistributionsF)(D3Q27System::ET_BS, x1, x2p, x3p); + LBMReal mfbca = (*this->nonLocalDistributionsF)(D3Q27System::ET_BN, x1, x2, x3p); + LBMReal mfaaa = (*this->nonLocalDistributionsF)(D3Q27System::ET_BSW, x1p, x2p, x3p); + LBMReal mfcaa = (*this->nonLocalDistributionsF)(D3Q27System::ET_BSE, x1, x2p, x3p); + LBMReal mfaca = (*this->nonLocalDistributionsF)(D3Q27System::ET_BNW, x1p, x2, x3p); + LBMReal mfcca = (*this->nonLocalDistributionsF)(D3Q27System::ET_BNE, x1, x2, x3p); + + LBMReal mfbbb = (*this->zeroDistributionsF)(x1, x2, x3); + + LBMReal rhoH = 1.0; + LBMReal rhoL = 1.0 / densityRatio; + + LBMReal rhoToPhi = (rhoH - rhoL) / (phiH - phiL); + + LBMReal dX1_phi = gradX1_phi(); + LBMReal dX2_phi = gradX2_phi(); + LBMReal dX3_phi = gradX3_phi(); + + LBMReal denom = sqrt(dX1_phi * dX1_phi + dX2_phi * dX2_phi + dX3_phi * dX3_phi) + 1e-9; + LBMReal normX1 = dX1_phi / denom; + LBMReal normX2 = dX2_phi / denom; + LBMReal normX3 = dX3_phi / denom; + + + + collFactorM = collFactorL + (collFactorL - collFactorG) * (phi[REST] - phiH) / (phiH - phiL); + + + LBMReal mu = 2 * beta * phi[REST] * (phi[REST] - 1) * (2 * phi[REST] - 1) - kappa * nabla2_phi(); + + //----------- Calculating Macroscopic Values ------------- + LBMReal rho = rhoH + rhoToPhi * (phi[REST] - phiH); //Incompressible + //LBMReal rho = rhoL + (rhoH - rhoL) * phi[REST] + (one - phi[REST]) * (*pressure)(x1, x2, x3) * three; //compressible + + LBMReal m0, m1, m2; + LBMReal rhoRef=c1; + + LBMReal vvx = ((((mfccc - mfaaa) + (mfcac - mfaca)) + ((mfcaa - mfacc) + (mfcca - mfaac))) + + (((mfcba - mfabc) + (mfcbc - mfaba)) + ((mfcab - mfacb) + (mfccb - mfaab))) + + (mfcbb - mfabb))/rhoRef; + LBMReal vvy = ((((mfccc - mfaaa) + (mfaca - mfcac)) + ((mfacc - mfcaa) + (mfcca - mfaac))) + + (((mfbca - mfbac) + (mfbcc - mfbaa)) + ((mfacb - mfcab) + (mfccb - mfaab))) + + (mfbcb - mfbab))/rhoRef; + LBMReal vvz = ((((mfccc - mfaaa) + (mfcac - mfaca)) + ((mfacc - mfcaa) + (mfaac - mfcca))) + + (((mfbac - mfbca) + (mfbcc - mfbaa)) + ((mfabc - mfcba) + (mfcbc - mfaba))) + + (mfbbc - mfbba))/rhoRef; + + LBMReal gradPx = 0.0; + LBMReal gradPy = 0.0; + LBMReal gradPz = 0.0; + for (int dir1 = -1; dir1 <= 1; dir1++) { + for (int dir2 = -1; dir2 <= 1; dir2++) { + int yyy = x2 + dir1; + int zzz = x3 + dir2; + if (!bcArray->isSolid(x1-1, yyy, zzz) && !bcArray->isUndefined(x1-1, yyy, zzz)) { + gradPx -= (*pressure)(x1 - 1, yyy, zzz) * c2o9 / ((c1 + c3 * abs(dir1)) * (c1 + c3 * abs(dir2))); + } + else { + gradPx -= (*pressure)(x1, x2, x3) * c2o9 / ((c1 + c3 * abs(dir1)) * (c1 + c3 * abs(dir2))); + } + if (!bcArray->isSolid(x1 + 1, yyy, zzz) && !bcArray->isUndefined(x1 + 1, yyy, zzz)) { + gradPx += (*pressure)(x1 + 1, yyy, zzz) * c2o9 / ((c1 + c3 * abs(dir1)) * (c1 + c3 * abs(dir2))); + } + else { + gradPx += (*pressure)(x1, x2, x3) * c2o9 / ((c1 + c3 * abs(dir1)) * (c1 + c3 * abs(dir2))); + } + + int xxx = x1 + dir1; + if (!bcArray->isSolid(xxx, x2-1, zzz) && !bcArray->isUndefined(xxx, x2-1, zzz)) { + gradPy -= (*pressure)(xxx, x2-1, zzz) * c2o9 / ((c1 + c3 * abs(dir1)) * (c1 + c3 * abs(dir2))); + } + else { + gradPy -= (*pressure)(x1, x2, x3) * c2o9 / ((c1 + c3 * abs(dir1)) * (c1 + c3 * abs(dir2))); + } + if (!bcArray->isSolid(xxx, x2+1, zzz) && !bcArray->isUndefined(xxx, x2+1, zzz)) { + gradPy += (*pressure)(xxx, x2+1, zzz) * c2o9 / ((c1 + c3 * abs(dir1)) * (c1 + c3 * abs(dir2))); + } + else { + gradPy += (*pressure)(x1, x2, x3) * c2o9 / ((c1 + c3 * abs(dir1)) * (c1 + c3 * abs(dir2))); + } + + yyy = x2 + dir2; + if (!bcArray->isSolid(xxx, yyy, x3-1) && !bcArray->isUndefined(xxx, yyy, x3-1)) { + gradPz -= (*pressure)(xxx, yyy, x3-1) * c2o9 / ((c1 + c3 * abs(dir1)) * (c1 + c3 * abs(dir2))); + } + else { + gradPz -= (*pressure)(x1, x2, x3) * c2o9 / ((c1 + c3 * abs(dir1)) * (c1 + c3 * abs(dir2))); + } + if (!bcArray->isSolid(xxx, yyy, x3+1) && !bcArray->isUndefined(xxx, yyy, x3+1)) { + gradPz += (*pressure)(xxx, yyy, x3+1) * c2o9 / ((c1 + c3 * abs(dir1)) * (c1 + c3 * abs(dir2))); + } + else { + gradPz += (*pressure)(x1, x2, x3) * c2o9 / ((c1 + c3 * abs(dir1)) * (c1 + c3 * abs(dir2))); + } + + } + } + + //Viscosity increase by pressure gradient + LBMReal errPhi = (((1.0 - phi[REST]) * (phi[REST]) * oneOverInterfaceScale)- denom); + //LBMReal limVis = 0.0000001*10;//0.01; + // collFactorM =collFactorM/(c1+limVis*(errPhi*errPhi)*collFactorM); + // collFactorM = (collFactorM < 1.8) ? 1.8 : collFactorM; + errPhi = errPhi * errPhi* errPhi * errPhi * errPhi * errPhi; + //collFactorM = collFactorM + (1.8 - collFactorM) * errPhi / (errPhi + limVis); + + //3.0 * ((WEIGTH[TNE] * (((phi2[TNE] - phi2[BSW]) - (phi2[BSE] - phi2[TNW])) + ((phi2[TSE] - phi2[BNW]) - (phi2[BNE] - phi2[TSW]))) + //+WEIGTH[NE] * (((phi2[TE] - phi2[BW]) - (phi2[BE] - phi2[TW])) + ((phi2[TS] - phi2[BN]) + (phi2[TN] - phi2[BS])))) + + //+WEIGTH[N] * (phi2[T] - phi2[B])); + + muRho = rho; + + forcingX1 = muForcingX1.Eval()/rho - gradPx/rho; + forcingX2 = muForcingX2.Eval()/rho - gradPy/rho; + forcingX3 = muForcingX3.Eval()/rho - gradPz/rho; + + vvx += forcingX1 * deltaT * 0.5; // X + vvy += forcingX2 * deltaT * 0.5; // Y + vvz += forcingX3 * deltaT * 0.5; // Z + + ///surface tension force + vvx += mu * dX1_phi * c1o2 / rho; + vvy += mu * dX2_phi * c1o2 / rho ; + vvz += mu * dX3_phi * c1o2 / rho; + + LBMReal vx2; + LBMReal vy2; + LBMReal vz2; + vx2 = vvx * vvx; + vy2 = vvy * vvy; + vz2 = vvz * vvz; + /////////////////////////////////////////////////////////////////////////////////////////// + LBMReal oMdrho; + + + oMdrho = mfccc + mfaaa; + m0 = mfaca + mfcac; + m1 = mfacc + mfcaa; + m2 = mfaac + mfcca; + oMdrho += m0; + m1 += m2; + oMdrho += m1; + m0 = mfbac + mfbca; + m1 = mfbaa + mfbcc; + m0 += m1; + m1 = mfabc + mfcba; + m2 = mfaba + mfcbc; + m1 += m2; + m0 += m1; + m1 = mfacb + mfcab; + m2 = mfaab + mfccb; + m1 += m2; + m0 += m1; + oMdrho += m0; + m0 = mfabb + mfcbb; + m1 = mfbab + mfbcb; + m2 = mfbba + mfbbc; + m0 += m1 + m2; + m0 += mfbbb; //hat gefehlt + oMdrho = (rhoRef - (oMdrho + m0))/rhoRef;// 12.03.21 check derivation!!!! + + //////////////////////////////////////////////////////////////////////////////////// + LBMReal wadjust; + LBMReal qudricLimit = 0.01; + //////////////////////////////////////////////////////////////////////////////////// + //Hin + //////////////////////////////////////////////////////////////////////////////////// + // mit 1/36, 1/9, 1/36, 1/9, 4/9, 1/9, 1/36, 1/9, 1/36 Konditionieren + //////////////////////////////////////////////////////////////////////////////////// + // Z - Dir + m2 = mfaaa + mfaac; + m1 = mfaac - mfaaa; + m0 = m2 + mfaab; + mfaaa = m0; + m0 += c1o36 * oMdrho; + mfaab = m1 - m0 * vvz; + mfaac = m2 - 2. * m1 * vvz + vz2 * m0; + //////////////////////////////////////////////////////////////////////////////////// + m2 = mfaba + mfabc; + m1 = mfabc - mfaba; + m0 = m2 + mfabb; + mfaba = m0; + m0 += c1o9 * oMdrho; + mfabb = m1 - m0 * vvz; + mfabc = m2 - 2. * m1 * vvz + vz2 * m0; + //////////////////////////////////////////////////////////////////////////////////// + m2 = mfaca + mfacc; + m1 = mfacc - mfaca; + m0 = m2 + mfacb; + mfaca = m0; + m0 += c1o36 * oMdrho; + mfacb = m1 - m0 * vvz; + mfacc = m2 - 2. * m1 * vvz + vz2 * m0; + //////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////////// + m2 = mfbaa + mfbac; + m1 = mfbac - mfbaa; + m0 = m2 + mfbab; + mfbaa = m0; + m0 += c1o9 * oMdrho; + mfbab = m1 - m0 * vvz; + mfbac = m2 - 2. * m1 * vvz + vz2 * m0; + //////////////////////////////////////////////////////////////////////////////////// + m2 = mfbba + mfbbc; + m1 = mfbbc - mfbba; + m0 = m2 + mfbbb; + mfbba = m0; + m0 += c4o9 * oMdrho; + mfbbb = m1 - m0 * vvz; + mfbbc = m2 - 2. * m1 * vvz + vz2 * m0; + //////////////////////////////////////////////////////////////////////////////////// + m2 = mfbca + mfbcc; + m1 = mfbcc - mfbca; + m0 = m2 + mfbcb; + mfbca = m0; + m0 += c1o9 * oMdrho; + mfbcb = m1 - m0 * vvz; + mfbcc = m2 - 2. * m1 * vvz + vz2 * m0; + //////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////////// + m2 = mfcaa + mfcac; + m1 = mfcac - mfcaa; + m0 = m2 + mfcab; + mfcaa = m0; + m0 += c1o36 * oMdrho; + mfcab = m1 - m0 * vvz; + mfcac = m2 - 2. * m1 * vvz + vz2 * m0; + //////////////////////////////////////////////////////////////////////////////////// + m2 = mfcba + mfcbc; + m1 = mfcbc - mfcba; + m0 = m2 + mfcbb; + mfcba = m0; + m0 += c1o9 * oMdrho; + mfcbb = m1 - m0 * vvz; + mfcbc = m2 - 2. * m1 * vvz + vz2 * m0; + //////////////////////////////////////////////////////////////////////////////////// + m2 = mfcca + mfccc; + m1 = mfccc - mfcca; + m0 = m2 + mfccb; + mfcca = m0; + m0 += c1o36 * oMdrho; + mfccb = m1 - m0 * vvz; + mfccc = m2 - 2. * m1 * vvz + vz2 * m0; + //////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////////// + // mit 1/6, 0, 1/18, 2/3, 0, 2/9, 1/6, 0, 1/18 Konditionieren + //////////////////////////////////////////////////////////////////////////////////// + // Y - Dir + m2 = mfaaa + mfaca; + m1 = mfaca - mfaaa; + m0 = m2 + mfaba; + mfaaa = m0; + m0 += c1o6 * oMdrho; + mfaba = m1 - m0 * vvy; + mfaca = m2 - 2. * m1 * vvy + vy2 * m0; + //////////////////////////////////////////////////////////////////////////////////// + m2 = mfaab + mfacb; + m1 = mfacb - mfaab; + m0 = m2 + mfabb; + mfaab = m0; + mfabb = m1 - m0 * vvy; + mfacb = m2 - 2. * m1 * vvy + vy2 * m0; + //////////////////////////////////////////////////////////////////////////////////// + m2 = mfaac + mfacc; + m1 = mfacc - mfaac; + m0 = m2 + mfabc; + mfaac = m0; + m0 += c1o18 * oMdrho; + mfabc = m1 - m0 * vvy; + mfacc = m2 - 2. * m1 * vvy + vy2 * m0; + //////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////////// + m2 = mfbaa + mfbca; + m1 = mfbca - mfbaa; + m0 = m2 + mfbba; + mfbaa = m0; + m0 += c2o3 * oMdrho; + mfbba = m1 - m0 * vvy; + mfbca = m2 - 2. * m1 * vvy + vy2 * m0; + //////////////////////////////////////////////////////////////////////////////////// + m2 = mfbab + mfbcb; + m1 = mfbcb - mfbab; + m0 = m2 + mfbbb; + mfbab = m0; + mfbbb = m1 - m0 * vvy; + mfbcb = m2 - 2. * m1 * vvy + vy2 * m0; + //////////////////////////////////////////////////////////////////////////////////// + m2 = mfbac + mfbcc; + m1 = mfbcc - mfbac; + m0 = m2 + mfbbc; + mfbac = m0; + m0 += c2o9 * oMdrho; + mfbbc = m1 - m0 * vvy; + mfbcc = m2 - 2. * m1 * vvy + vy2 * m0; + //////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////////// + m2 = mfcaa + mfcca; + m1 = mfcca - mfcaa; + m0 = m2 + mfcba; + mfcaa = m0; + m0 += c1o6 * oMdrho; + mfcba = m1 - m0 * vvy; + mfcca = m2 - 2. * m1 * vvy + vy2 * m0; + //////////////////////////////////////////////////////////////////////////////////// + m2 = mfcab + mfccb; + m1 = mfccb - mfcab; + m0 = m2 + mfcbb; + mfcab = m0; + mfcbb = m1 - m0 * vvy; + mfccb = m2 - 2. * m1 * vvy + vy2 * m0; + //////////////////////////////////////////////////////////////////////////////////// + m2 = mfcac + mfccc; + m1 = mfccc - mfcac; + m0 = m2 + mfcbc; + mfcac = m0; + m0 += c1o18 * oMdrho; + mfcbc = m1 - m0 * vvy; + mfccc = m2 - 2. * m1 * vvy + vy2 * m0; + //////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////////// + // mit 1, 0, 1/3, 0, 0, 0, 1/3, 0, 1/9 Konditionieren + //////////////////////////////////////////////////////////////////////////////////// + // X - Dir + m2 = mfaaa + mfcaa; + m1 = mfcaa - mfaaa; + m0 = m2 + mfbaa; + mfaaa = m0; + m0 += 1. * oMdrho; + mfbaa = m1 - m0 * vvx; + mfcaa = m2 - 2. * m1 * vvx + vx2 * m0; + //////////////////////////////////////////////////////////////////////////////////// + m2 = mfaba + mfcba; + m1 = mfcba - mfaba; + m0 = m2 + mfbba; + mfaba = m0; + mfbba = m1 - m0 * vvx; + mfcba = m2 - 2. * m1 * vvx + vx2 * m0; + //////////////////////////////////////////////////////////////////////////////////// + m2 = mfaca + mfcca; + m1 = mfcca - mfaca; + m0 = m2 + mfbca; + mfaca = m0; + m0 += c1o3 * oMdrho; + mfbca = m1 - m0 * vvx; + mfcca = m2 - 2. * m1 * vvx + vx2 * m0; + //////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////////// + m2 = mfaab + mfcab; + m1 = mfcab - mfaab; + m0 = m2 + mfbab; + mfaab = m0; + mfbab = m1 - m0 * vvx; + mfcab = m2 - 2. * m1 * vvx + vx2 * m0; + //////////////////////////////////////////////////////////////////////////////////// + m2 = mfabb + mfcbb; + m1 = mfcbb - mfabb; + m0 = m2 + mfbbb; + mfabb = m0; + mfbbb = m1 - m0 * vvx; + mfcbb = m2 - 2. * m1 * vvx + vx2 * m0; + //////////////////////////////////////////////////////////////////////////////////// + m2 = mfacb + mfccb; + m1 = mfccb - mfacb; + m0 = m2 + mfbcb; + mfacb = m0; + mfbcb = m1 - m0 * vvx; + mfccb = m2 - 2. * m1 * vvx + vx2 * m0; + //////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////////// + m2 = mfaac + mfcac; + m1 = mfcac - mfaac; + m0 = m2 + mfbac; + mfaac = m0; + m0 += c1o3 * oMdrho; + mfbac = m1 - m0 * vvx; + mfcac = m2 - 2. * m1 * vvx + vx2 * m0; + //////////////////////////////////////////////////////////////////////////////////// + m2 = mfabc + mfcbc; + m1 = mfcbc - mfabc; + m0 = m2 + mfbbc; + mfabc = m0; + mfbbc = m1 - m0 * vvx; + mfcbc = m2 - 2. * m1 * vvx + vx2 * m0; + //////////////////////////////////////////////////////////////////////////////////// + m2 = mfacc + mfccc; + m1 = mfccc - mfacc; + m0 = m2 + mfbcc; + mfacc = m0; + m0 += c1o9 * oMdrho; + mfbcc = m1 - m0 * vvx; + mfccc = m2 - 2. * m1 * vvx + vx2 * m0; + //////////////////////////////////////////////////////////////////////////////////// + // Cumulants + //////////////////////////////////////////////////////////////////////////////////// + + // mfaaa = 0.0; + LBMReal OxxPyyPzz = 1.; //omega2 or bulk viscosity + // LBMReal OxyyPxzz = 1.;//-s9;//2+s9;// + // LBMReal OxyyMxzz = 1.;//2+s9;// + LBMReal O4 = 1.; + LBMReal O5 = 1.; + LBMReal O6 = 1.; + + /////fourth order parameters; here only for test. Move out of loop! + + LBMReal OxyyPxzz = 8.0 * (collFactorM - 2.0) * (OxxPyyPzz * (3.0 * collFactorM - 1.0) - 5.0 * collFactorM) / (8.0 * (5.0 - 2.0 * collFactorM) * collFactorM + OxxPyyPzz * (8.0 + collFactorM * (9.0 * collFactorM - 26.0))); + LBMReal OxyyMxzz = 8.0 * (collFactorM - 2.0) * (collFactorM + OxxPyyPzz * (3.0 * collFactorM - 7.0)) / (OxxPyyPzz * (56.0 - 42.0 * collFactorM + 9.0 * collFactorM * collFactorM) - 8.0 * collFactorM); + // LBMReal Oxyz = 24.0 * (collFactorM - 2.0) * (4.0 * collFactorM * collFactorM + collFactorM * OxxPyyPzz * (18.0 - 13.0 * collFactorM) + OxxPyyPzz * OxxPyyPzz * (2.0 + collFactorM * (6.0 * collFactorM - 11.0))) / (16.0 * collFactorM * collFactorM * (collFactorM - 6.0) - 2.0 * collFactorM * OxxPyyPzz * (216.0 + 5.0 * collFactorM * (9.0 * collFactorM - 46.0)) + OxxPyyPzz * OxxPyyPzz * (collFactorM * (3.0 * collFactorM - 10.0) * (15.0 * collFactorM - 28.0) - 48.0)); + LBMReal A = (4.0 * collFactorM * collFactorM + 2.0 * collFactorM * OxxPyyPzz * (collFactorM - 6.0) + OxxPyyPzz * OxxPyyPzz * (collFactorM * (10.0 - 3.0 * collFactorM) - 4.0)) / ((collFactorM - OxxPyyPzz) * (OxxPyyPzz * (2.0 + 3.0 * collFactorM) - 8.0 * collFactorM)); + //FIXME: warning C4459: declaration of 'B' hides global declaration (message : see declaration of 'D3Q27System::B' ) + LBMReal BB = (4.0 * collFactorM * OxxPyyPzz * (9.0 * collFactorM - 16.0) - 4.0 * collFactorM * collFactorM - 2.0 * OxxPyyPzz * OxxPyyPzz * (2.0 + 9.0 * collFactorM * (collFactorM - 2.0))) / (3.0 * (collFactorM - OxxPyyPzz) * (OxxPyyPzz * (2.0 + 3.0 * collFactorM) - 8.0 * collFactorM)); + + + //Cum 4. + //LBMReal CUMcbb = mfcbb - ((mfcaa + c1o3 * oMdrho) * mfabb + 2. * mfbba * mfbab); // till 18.05.2015 + //LBMReal CUMbcb = mfbcb - ((mfaca + c1o3 * oMdrho) * mfbab + 2. * mfbba * mfabb); // till 18.05.2015 + //LBMReal CUMbbc = mfbbc - ((mfaac + c1o3 * oMdrho) * mfbba + 2. * mfbab * mfabb); // till 18.05.2015 + + LBMReal CUMcbb = mfcbb - ((mfcaa + c1o3) * mfabb + 2. * mfbba * mfbab); + LBMReal CUMbcb = mfbcb - ((mfaca + c1o3) * mfbab + 2. * mfbba * mfabb); + LBMReal CUMbbc = mfbbc - ((mfaac + c1o3) * mfbba + 2. * mfbab * mfabb); + + LBMReal CUMcca = mfcca - ((mfcaa * mfaca + 2. * mfbba * mfbba) + c1o3 * (mfcaa + mfaca) * oMdrho + c1o9 * (oMdrho - c1) * oMdrho); + LBMReal CUMcac = mfcac - ((mfcaa * mfaac + 2. * mfbab * mfbab) + c1o3 * (mfcaa + mfaac) * oMdrho + c1o9 * (oMdrho - c1) * oMdrho); + LBMReal CUMacc = mfacc - ((mfaac * mfaca + 2. * mfabb * mfabb) + c1o3 * (mfaac + mfaca) * oMdrho + c1o9 * (oMdrho - c1) * oMdrho); + + //Cum 5. + LBMReal CUMbcc = mfbcc - (mfaac * mfbca + mfaca * mfbac + 4. * mfabb * mfbbb + 2. * (mfbab * mfacb + mfbba * mfabc)) - c1o3 * (mfbca + mfbac) * oMdrho; + LBMReal CUMcbc = mfcbc - (mfaac * mfcba + mfcaa * mfabc + 4. * mfbab * mfbbb + 2. * (mfabb * mfcab + mfbba * mfbac)) - c1o3 * (mfcba + mfabc) * oMdrho; + LBMReal CUMccb = mfccb - (mfcaa * mfacb + mfaca * mfcab + 4. * mfbba * mfbbb + 2. * (mfbab * mfbca + mfabb * mfcba)) - c1o3 * (mfacb + mfcab) * oMdrho; + + //Cum 6. + LBMReal CUMccc = mfccc + ((-4. * mfbbb * mfbbb + - (mfcaa * mfacc + mfaca * mfcac + mfaac * mfcca) + - 4. * (mfabb * mfcbb + mfbab * mfbcb + mfbba * mfbbc) + - 2. * (mfbca * mfbac + mfcba * mfabc + mfcab * mfacb)) + + (4. * (mfbab * mfbab * mfaca + mfabb * mfabb * mfcaa + mfbba * mfbba * mfaac) + + 2. * (mfcaa * mfaca * mfaac) + + 16. * mfbba * mfbab * mfabb) + - c1o3 * (mfacc + mfcac + mfcca) * oMdrho - c1o9 * oMdrho * oMdrho + - c1o9 * (mfcaa + mfaca + mfaac) * oMdrho * (1. - 2. * oMdrho) - c1o27 * oMdrho * oMdrho * (-2. * oMdrho) + + (2. * (mfbab * mfbab + mfabb * mfabb + mfbba * mfbba) + + (mfaac * mfaca + mfaac * mfcaa + mfaca * mfcaa)) * c2o3 * oMdrho) + c1o27 * oMdrho; + + //2. + // linear combinations + LBMReal mxxPyyPzz = mfcaa + mfaca + mfaac; + + // LBMReal mfaaaS = (mfaaa * (-4 - 3 * OxxPyyPzz * (-1 + rho)) + 6 * mxxPyyPzz * OxxPyyPzz * (-1 + rho)) / (-4 + 3 * OxxPyyPzz * (-1 + rho)); + mxxPyyPzz -= mfaaa ;//12.03.21 shifted by mfaaa + //mxxPyyPzz-=(mfaaa+mfaaaS)*c1o2;//12.03.21 shifted by mfaaa + LBMReal mxxMyy = mfcaa - mfaca; + LBMReal mxxMzz = mfcaa - mfaac; + + LBMReal dxux = -c1o2 * collFactorM * (mxxMyy + mxxMzz) + c1o2 * OxxPyyPzz * (/*mfaaa*/ -mxxPyyPzz); + LBMReal dyuy = dxux + collFactorM * c3o2 * mxxMyy; + LBMReal dzuz = dxux + collFactorM * c3o2 * mxxMzz; + + LBMReal Dxy = -three * collFactorM * mfbba; + LBMReal Dxz = -three * collFactorM * mfbab; + LBMReal Dyz = -three * collFactorM * mfabb; + + //relax + mxxPyyPzz += OxxPyyPzz * (/*mfaaa*/ - mxxPyyPzz) - 3. * (1. - c1o2 * OxxPyyPzz) * (vx2 * dxux + vy2 * dyuy + vz2 * dzuz); + mxxMyy += collFactorM * (-mxxMyy) - 3. * (1. - c1o2 * collFactorM) * (vx2 * dxux - vy2 * dyuy); + mxxMzz += collFactorM * (-mxxMzz) - 3. * (1. - c1o2 * collFactorM) * (vx2 * dxux - vz2 * dzuz); + + mfabb += collFactorM * (-mfabb); + mfbab += collFactorM * (-mfbab); + mfbba += collFactorM * (-mfbba); + + ////updated pressure + //mfaaa += (dX1_phi * vvx + dX2_phi * vvy + dX3_phi * vvz) * correctionScaling; + mfaaa = 0.0; // Pressure elimination as in standard velocity model + // mfaaa += (rho - c1) * (dxux + dyuy + dzuz); + + mxxPyyPzz += mfaaa; // 12.03.21 shifted by mfaaa + + // mxxPyyPzz += (mfaaa + mfaaaS) * c1o2; + //mfaaa = mfaaaS; + // linear combinations back + mfcaa = c1o3 * (mxxMyy + mxxMzz + mxxPyyPzz); + mfaca = c1o3 * (-2. * mxxMyy + mxxMzz + mxxPyyPzz); + mfaac = c1o3 * (mxxMyy - 2. * mxxMzz + mxxPyyPzz); + + //3. + // linear combinations + LBMReal mxxyPyzz = mfcba + mfabc; + LBMReal mxxyMyzz = mfcba - mfabc; + + LBMReal mxxzPyyz = mfcab + mfacb; + LBMReal mxxzMyyz = mfcab - mfacb; + + LBMReal mxyyPxzz = mfbca + mfbac; + LBMReal mxyyMxzz = mfbca - mfbac; + + //relax + wadjust = OxyyMxzz + (1. - OxyyMxzz) * fabs(mfbbb) / (fabs(mfbbb) + qudricLimit); + mfbbb += wadjust * (-mfbbb); + wadjust = OxyyPxzz + (1. - OxyyPxzz) * fabs(mxxyPyzz) / (fabs(mxxyPyzz) + qudricLimit); + mxxyPyzz += wadjust * (-mxxyPyzz); + wadjust = OxyyMxzz + (1. - OxyyMxzz) * fabs(mxxyMyzz) / (fabs(mxxyMyzz) + qudricLimit); + mxxyMyzz += wadjust * (-mxxyMyzz); + wadjust = OxyyPxzz + (1. - OxyyPxzz) * fabs(mxxzPyyz) / (fabs(mxxzPyyz) + qudricLimit); + mxxzPyyz += wadjust * (-mxxzPyyz); + wadjust = OxyyMxzz + (1. - OxyyMxzz) * fabs(mxxzMyyz) / (fabs(mxxzMyyz) + qudricLimit); + mxxzMyyz += wadjust * (-mxxzMyyz); + wadjust = OxyyPxzz + (1. - OxyyPxzz) * fabs(mxyyPxzz) / (fabs(mxyyPxzz) + qudricLimit); + mxyyPxzz += wadjust * (-mxyyPxzz); + wadjust = OxyyMxzz + (1. - OxyyMxzz) * fabs(mxyyMxzz) / (fabs(mxyyMxzz) + qudricLimit); + mxyyMxzz += wadjust * (-mxyyMxzz); + + // linear combinations back + 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. + CUMacc = -O4 * (one / collFactorM - c1o2) * (dyuy + dzuz) * c2o3 * A + (one - O4) * (CUMacc); + CUMcac = -O4 * (one / collFactorM - c1o2) * (dxux + dzuz) * c2o3 * A + (one - O4) * (CUMcac); + CUMcca = -O4 * (one / collFactorM - c1o2) * (dyuy + dxux) * c2o3 * A + (one - O4) * (CUMcca); + CUMbbc = -O4 * (one / collFactorM - c1o2) * Dxy * c1o3 * BB + (one - O4) * (CUMbbc); + CUMbcb = -O4 * (one / collFactorM - c1o2) * Dxz * c1o3 * BB + (one - O4) * (CUMbcb); + CUMcbb = -O4 * (one / collFactorM - c1o2) * Dyz * c1o3 * BB + (one - O4) * (CUMcbb); + + //5. + CUMbcc += O5 * (-CUMbcc); + CUMcbc += O5 * (-CUMcbc); + CUMccb += O5 * (-CUMccb); + + //6. + CUMccc += O6 * (-CUMccc); + + //back cumulants to central moments + //4. + //mfcbb = CUMcbb + ((mfcaa + c1o3 * oMdrho) * mfabb + 2. * mfbba * mfbab); // till 18.05.2015 + //mfbcb = CUMbcb + ((mfaca + c1o3 * oMdrho) * mfbab + 2. * mfbba * mfabb); // till 18.05.2015 + //mfbbc = CUMbbc + ((mfaac + c1o3 * oMdrho) * mfbba + 2. * mfbab * mfabb); // till 18.05.2015 + + mfcbb = CUMcbb + ((mfcaa + c1o3) * mfabb + 2. * mfbba * mfbab); + mfbcb = CUMbcb + ((mfaca + c1o3) * mfbab + 2. * mfbba * mfabb); + mfbbc = CUMbbc + ((mfaac + c1o3) * mfbba + 2. * mfbab * mfabb); + + mfcca = CUMcca + (mfcaa * mfaca + 2. * mfbba * mfbba) + c1o3 * (mfcaa + mfaca) * oMdrho + c1o9 * (oMdrho - c1) * oMdrho; + mfcac = CUMcac + (mfcaa * mfaac + 2. * mfbab * mfbab) + c1o3 * (mfcaa + mfaac) * oMdrho + c1o9 * (oMdrho - c1) * oMdrho; + mfacc = CUMacc + (mfaac * mfaca + 2. * mfabb * mfabb) + c1o3 * (mfaac + mfaca) * oMdrho + c1o9 * (oMdrho - c1) * oMdrho; + + //5. + mfbcc = CUMbcc + (mfaac * mfbca + mfaca * mfbac + 4. * mfabb * mfbbb + 2. * (mfbab * mfacb + mfbba * mfabc)) + c1o3 * (mfbca + mfbac) * oMdrho; + mfcbc = CUMcbc + (mfaac * mfcba + mfcaa * mfabc + 4. * mfbab * mfbbb + 2. * (mfabb * mfcab + mfbba * mfbac)) + c1o3 * (mfcba + mfabc) * oMdrho; + mfccb = CUMccb + (mfcaa * mfacb + mfaca * mfcab + 4. * mfbba * mfbbb + 2. * (mfbab * mfbca + mfabb * mfcba)) + c1o3 * (mfacb + mfcab) * oMdrho; + + //6. + mfccc = CUMccc - ((-4. * mfbbb * mfbbb + - (mfcaa * mfacc + mfaca * mfcac + mfaac * mfcca) + - 4. * (mfabb * mfcbb + mfbac * mfbca + mfbba * mfbbc) + - 2. * (mfbca * mfbac + mfcba * mfabc + mfcab * mfacb)) + + (4. * (mfbab * mfbab * mfaca + mfabb * mfabb * mfcaa + mfbba * mfbba * mfaac) + + 2. * (mfcaa * mfaca * mfaac) + + 16. * mfbba * mfbab * mfabb) + - c1o3 * (mfacc + mfcac + mfcca) * oMdrho - c1o9 * oMdrho * oMdrho + - c1o9 * (mfcaa + mfaca + mfaac) * oMdrho * (1. - 2. * oMdrho) - c1o27 * oMdrho * oMdrho * (-2. * oMdrho) + + (2. * (mfbab * mfbab + mfabb * mfabb + mfbba * mfbba) + + (mfaac * mfaca + mfaac * mfcaa + mfaca * mfcaa)) * c2o3 * oMdrho) - c1o27 * oMdrho; + + + //////// + + + //////////////////////////////////////////////////////////////////////////////////// + //forcing + mfbaa = -mfbaa; + mfaba = -mfaba; + mfaab = -mfaab; + ////////////////////////////////////////////////////////////////////////////////////// + mfbaa += c1o3 * (c1 / collFactorM - c1o2) * rhoToPhi * (2 * dxux * dX1_phi + Dxy * dX2_phi + Dxz * dX3_phi) / (rho); + mfaba += c1o3 * (c1 / collFactorM - c1o2) * rhoToPhi * (Dxy * dX1_phi + 2 * dyuy * dX2_phi + Dyz * dX3_phi) / (rho); + mfaab += c1o3 * (c1 / collFactorM - c1o2) * rhoToPhi * (Dxz * dX1_phi + Dyz * dX2_phi + 2 * dyuy * dX3_phi) / (rho); + //////////////////////////////////////////////////////////////////////////////////// + //back + //////////////////////////////////////////////////////////////////////////////////// + //mit 1, 0, 1/3, 0, 0, 0, 1/3, 0, 1/9 Konditionieren + //////////////////////////////////////////////////////////////////////////////////// + // Z - Dir + m0 = mfaac * c1o2 + mfaab * (vvz - c1o2) + (mfaaa + 1. * oMdrho) * (vz2 - vvz) * c1o2; + m1 = -mfaac - 2. * mfaab * vvz + mfaaa * (1. - vz2) - 1. * oMdrho * vz2; + m2 = mfaac * c1o2 + mfaab * (vvz + c1o2) + (mfaaa + 1. * oMdrho) * (vz2 + vvz) * c1o2; + mfaaa = m0; + mfaab = m1; + mfaac = m2; + //////////////////////////////////////////////////////////////////////////////////// + m0 = mfabc * c1o2 + mfabb * (vvz - c1o2) + mfaba * (vz2 - vvz) * c1o2; + m1 = -mfabc - 2. * mfabb * vvz + mfaba * (1. - vz2); + m2 = mfabc * c1o2 + mfabb * (vvz + c1o2) + mfaba * (vz2 + vvz) * c1o2; + mfaba = m0; + mfabb = m1; + mfabc = m2; + //////////////////////////////////////////////////////////////////////////////////// + m0 = mfacc * c1o2 + mfacb * (vvz - c1o2) + (mfaca + c1o3 * oMdrho) * (vz2 - vvz) * c1o2; + m1 = -mfacc - 2. * mfacb * vvz + mfaca * (1. - vz2) - c1o3 * oMdrho * vz2; + m2 = mfacc * c1o2 + mfacb * (vvz + c1o2) + (mfaca + c1o3 * oMdrho) * (vz2 + vvz) * c1o2; + mfaca = m0; + mfacb = m1; + mfacc = m2; + //////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////////// + m0 = mfbac * c1o2 + mfbab * (vvz - c1o2) + mfbaa * (vz2 - vvz) * c1o2; + m1 = -mfbac - 2. * mfbab * vvz + mfbaa * (1. - vz2); + m2 = mfbac * c1o2 + mfbab * (vvz + c1o2) + mfbaa * (vz2 + vvz) * c1o2; + mfbaa = m0; + mfbab = m1; + mfbac = m2; + /////////b////////////////////////////////////////////////////////////////////////// + m0 = mfbbc * c1o2 + mfbbb * (vvz - c1o2) + mfbba * (vz2 - vvz) * c1o2; + m1 = -mfbbc - 2. * mfbbb * vvz + mfbba * (1. - vz2); + m2 = mfbbc * c1o2 + mfbbb * (vvz + c1o2) + mfbba * (vz2 + vvz) * c1o2; + mfbba = m0; + mfbbb = m1; + mfbbc = m2; + /////////b////////////////////////////////////////////////////////////////////////// + m0 = mfbcc * c1o2 + mfbcb * (vvz - c1o2) + mfbca * (vz2 - vvz) * c1o2; + m1 = -mfbcc - 2. * mfbcb * vvz + mfbca * (1. - vz2); + m2 = mfbcc * c1o2 + mfbcb * (vvz + c1o2) + mfbca * (vz2 + vvz) * c1o2; + mfbca = m0; + mfbcb = m1; + mfbcc = m2; + //////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////////// + m0 = mfcac * c1o2 + mfcab * (vvz - c1o2) + (mfcaa + c1o3 * oMdrho) * (vz2 - vvz) * c1o2; + m1 = -mfcac - 2. * mfcab * vvz + mfcaa * (1. - vz2) - c1o3 * oMdrho * vz2; + m2 = mfcac * c1o2 + mfcab * (vvz + c1o2) + (mfcaa + c1o3 * oMdrho) * (vz2 + vvz) * c1o2; + mfcaa = m0; + mfcab = m1; + mfcac = m2; + /////////c////////////////////////////////////////////////////////////////////////// + m0 = mfcbc * c1o2 + mfcbb * (vvz - c1o2) + mfcba * (vz2 - vvz) * c1o2; + m1 = -mfcbc - 2. * mfcbb * vvz + mfcba * (1. - vz2); + m2 = mfcbc * c1o2 + mfcbb * (vvz + c1o2) + mfcba * (vz2 + vvz) * c1o2; + mfcba = m0; + mfcbb = m1; + mfcbc = m2; + /////////c////////////////////////////////////////////////////////////////////////// + m0 = mfccc * c1o2 + mfccb * (vvz - c1o2) + (mfcca + c1o9 * oMdrho) * (vz2 - vvz) * c1o2; + m1 = -mfccc - 2. * mfccb * vvz + mfcca * (1. - vz2) - c1o9 * oMdrho * vz2; + m2 = mfccc * c1o2 + mfccb * (vvz + c1o2) + (mfcca + c1o9 * oMdrho) * (vz2 + vvz) * c1o2; + mfcca = m0; + mfccb = m1; + mfccc = m2; + //////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////////// + //mit 1/6, 2/3, 1/6, 0, 0, 0, 1/18, 2/9, 1/18 Konditionieren + //////////////////////////////////////////////////////////////////////////////////// + // Y - Dir + m0 = mfaca * c1o2 + mfaba * (vvy - c1o2) + (mfaaa + c1o6 * oMdrho) * (vy2 - vvy) * c1o2; + m1 = -mfaca - 2. * mfaba * vvy + mfaaa * (1. - vy2) - c1o6 * oMdrho * vy2; + m2 = mfaca * c1o2 + mfaba * (vvy + c1o2) + (mfaaa + c1o6 * oMdrho) * (vy2 + vvy) * c1o2; + mfaaa = m0; + mfaba = m1; + mfaca = m2; + //////////////////////////////////////////////////////////////////////////////////// + m0 = mfacb * c1o2 + mfabb * (vvy - c1o2) + (mfaab + c2o3 * oMdrho) * (vy2 - vvy) * c1o2; + m1 = -mfacb - 2. * mfabb * vvy + mfaab * (1. - vy2) - c2o3 * oMdrho * vy2; + m2 = mfacb * c1o2 + mfabb * (vvy + c1o2) + (mfaab + c2o3 * oMdrho) * (vy2 + vvy) * c1o2; + mfaab = m0; + mfabb = m1; + mfacb = m2; + //////////////////////////////////////////////////////////////////////////////////// + m0 = mfacc * c1o2 + mfabc * (vvy - c1o2) + (mfaac + c1o6 * oMdrho) * (vy2 - vvy) * c1o2; + m1 = -mfacc - 2. * mfabc * vvy + mfaac * (1. - vy2) - c1o6 * oMdrho * vy2; + m2 = mfacc * c1o2 + mfabc * (vvy + c1o2) + (mfaac + c1o6 * oMdrho) * (vy2 + vvy) * c1o2; + mfaac = m0; + mfabc = m1; + mfacc = m2; + //////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////////// + m0 = mfbca * c1o2 + mfbba * (vvy - c1o2) + mfbaa * (vy2 - vvy) * c1o2; + m1 = -mfbca - 2. * mfbba * vvy + mfbaa * (1. - vy2); + m2 = mfbca * c1o2 + mfbba * (vvy + c1o2) + mfbaa * (vy2 + vvy) * c1o2; + mfbaa = m0; + mfbba = m1; + mfbca = m2; + /////////b////////////////////////////////////////////////////////////////////////// + m0 = mfbcb * c1o2 + mfbbb * (vvy - c1o2) + mfbab * (vy2 - vvy) * c1o2; + m1 = -mfbcb - 2. * mfbbb * vvy + mfbab * (1. - vy2); + m2 = mfbcb * c1o2 + mfbbb * (vvy + c1o2) + mfbab * (vy2 + vvy) * c1o2; + mfbab = m0; + mfbbb = m1; + mfbcb = m2; + /////////b////////////////////////////////////////////////////////////////////////// + m0 = mfbcc * c1o2 + mfbbc * (vvy - c1o2) + mfbac * (vy2 - vvy) * c1o2; + m1 = -mfbcc - 2. * mfbbc * vvy + mfbac * (1. - vy2); + m2 = mfbcc * c1o2 + mfbbc * (vvy + c1o2) + mfbac * (vy2 + vvy) * c1o2; + mfbac = m0; + mfbbc = m1; + mfbcc = m2; + //////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////////// + m0 = mfcca * c1o2 + mfcba * (vvy - c1o2) + (mfcaa + c1o18 * oMdrho) * (vy2 - vvy) * c1o2; + m1 = -mfcca - 2. * mfcba * vvy + mfcaa * (1. - vy2) - c1o18 * oMdrho * vy2; + m2 = mfcca * c1o2 + mfcba * (vvy + c1o2) + (mfcaa + c1o18 * oMdrho) * (vy2 + vvy) * c1o2; + mfcaa = m0; + mfcba = m1; + mfcca = m2; + /////////c////////////////////////////////////////////////////////////////////////// + m0 = mfccb * c1o2 + mfcbb * (vvy - c1o2) + (mfcab + c2o9 * oMdrho) * (vy2 - vvy) * c1o2; + m1 = -mfccb - 2. * mfcbb * vvy + mfcab * (1. - vy2) - c2o9 * oMdrho * vy2; + m2 = mfccb * c1o2 + mfcbb * (vvy + c1o2) + (mfcab + c2o9 * oMdrho) * (vy2 + vvy) * c1o2; + mfcab = m0; + mfcbb = m1; + mfccb = m2; + /////////c////////////////////////////////////////////////////////////////////////// + m0 = mfccc * c1o2 + mfcbc * (vvy - c1o2) + (mfcac + c1o18 * oMdrho) * (vy2 - vvy) * c1o2; + m1 = -mfccc - 2. * mfcbc * vvy + mfcac * (1. - vy2) - c1o18 * oMdrho * vy2; + m2 = mfccc * c1o2 + mfcbc * (vvy + c1o2) + (mfcac + c1o18 * oMdrho) * (vy2 + vvy) * c1o2; + mfcac = m0; + mfcbc = m1; + mfccc = m2; + //////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////////// + //mit 1/36, 1/9, 1/36, 1/9, 4/9, 1/9, 1/36, 1/9, 1/36 Konditionieren + //////////////////////////////////////////////////////////////////////////////////// + // X - Dir + m0 = mfcaa * c1o2 + mfbaa * (vvx - c1o2) + (mfaaa + c1o36 * oMdrho) * (vx2 - vvx) * c1o2; + m1 = -mfcaa - 2. * mfbaa * vvx + mfaaa * (1. - vx2) - c1o36 * oMdrho * vx2; + m2 = mfcaa * c1o2 + mfbaa * (vvx + c1o2) + (mfaaa + c1o36 * oMdrho) * (vx2 + vvx) * c1o2; + mfaaa = m0; + mfbaa = m1; + mfcaa = m2; + //////////////////////////////////////////////////////////////////////////////////// + m0 = mfcba * c1o2 + mfbba * (vvx - c1o2) + (mfaba + c1o9 * oMdrho) * (vx2 - vvx) * c1o2; + m1 = -mfcba - 2. * mfbba * vvx + mfaba * (1. - vx2) - c1o9 * oMdrho * vx2; + m2 = mfcba * c1o2 + mfbba * (vvx + c1o2) + (mfaba + c1o9 * oMdrho) * (vx2 + vvx) * c1o2; + mfaba = m0; + mfbba = m1; + mfcba = m2; + //////////////////////////////////////////////////////////////////////////////////// + m0 = mfcca * c1o2 + mfbca * (vvx - c1o2) + (mfaca + c1o36 * oMdrho) * (vx2 - vvx) * c1o2; + m1 = -mfcca - 2. * mfbca * vvx + mfaca * (1. - vx2) - c1o36 * oMdrho * vx2; + m2 = mfcca * c1o2 + mfbca * (vvx + c1o2) + (mfaca + c1o36 * oMdrho) * (vx2 + vvx) * c1o2; + mfaca = m0; + mfbca = m1; + mfcca = m2; + //////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////////// + m0 = mfcab * c1o2 + mfbab * (vvx - c1o2) + (mfaab + c1o9 * oMdrho) * (vx2 - vvx) * c1o2; + m1 = -mfcab - 2. * mfbab * vvx + mfaab * (1. - vx2) - c1o9 * oMdrho * vx2; + m2 = mfcab * c1o2 + mfbab * (vvx + c1o2) + (mfaab + c1o9 * oMdrho) * (vx2 + vvx) * c1o2; + mfaab = m0; + mfbab = m1; + mfcab = m2; + ///////////b//////////////////////////////////////////////////////////////////////// + m0 = mfcbb * c1o2 + mfbbb * (vvx - c1o2) + (mfabb + c4o9 * oMdrho) * (vx2 - vvx) * c1o2; + m1 = -mfcbb - 2. * mfbbb * vvx + mfabb * (1. - vx2) - c4o9 * oMdrho * vx2; + m2 = mfcbb * c1o2 + mfbbb * (vvx + c1o2) + (mfabb + c4o9 * oMdrho) * (vx2 + vvx) * c1o2; + mfabb = m0; + mfbbb = m1; + mfcbb = m2; + ///////////b//////////////////////////////////////////////////////////////////////// + m0 = mfccb * c1o2 + mfbcb * (vvx - c1o2) + (mfacb + c1o9 * oMdrho) * (vx2 - vvx) * c1o2; + m1 = -mfccb - 2. * mfbcb * vvx + mfacb * (1. - vx2) - c1o9 * oMdrho * vx2; + m2 = mfccb * c1o2 + mfbcb * (vvx + c1o2) + (mfacb + c1o9 * oMdrho) * (vx2 + vvx) * c1o2; + mfacb = m0; + mfbcb = m1; + mfccb = m2; + //////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////////// + m0 = mfcac * c1o2 + mfbac * (vvx - c1o2) + (mfaac + c1o36 * oMdrho) * (vx2 - vvx) * c1o2; + m1 = -mfcac - 2. * mfbac * vvx + mfaac * (1. - vx2) - c1o36 * oMdrho * vx2; + m2 = mfcac * c1o2 + mfbac * (vvx + c1o2) + (mfaac + c1o36 * oMdrho) * (vx2 + vvx) * c1o2; + mfaac = m0; + mfbac = m1; + mfcac = m2; + ///////////c//////////////////////////////////////////////////////////////////////// + m0 = mfcbc * c1o2 + mfbbc * (vvx - c1o2) + (mfabc + c1o9 * oMdrho) * (vx2 - vvx) * c1o2; + m1 = -mfcbc - 2. * mfbbc * vvx + mfabc * (1. - vx2) - c1o9 * oMdrho * vx2; + m2 = mfcbc * c1o2 + mfbbc * (vvx + c1o2) + (mfabc + c1o9 * oMdrho) * (vx2 + vvx) * c1o2; + mfabc = m0; + mfbbc = m1; + mfcbc = m2; + ///////////c//////////////////////////////////////////////////////////////////////// + m0 = mfccc * c1o2 + mfbcc * (vvx - c1o2) + (mfacc + c1o36 * oMdrho) * (vx2 - vvx) * c1o2; + m1 = -mfccc - 2. * mfbcc * vvx + mfacc * (1. - vx2) - c1o36 * oMdrho * vx2; + m2 = mfccc * c1o2 + mfbcc * (vvx + c1o2) + (mfacc + c1o36 * oMdrho) * (vx2 + vvx) * c1o2; + mfacc = m0; + mfbcc = m1; + mfccc = m2; + + ////////////////////////////////////////////////////////////////////////// + //proof correctness + ////////////////////////////////////////////////////////////////////////// + //#ifdef PROOF_CORRECTNESS + LBMReal rho_post = (mfaaa + mfaac + mfaca + mfcaa + mfacc + mfcac + mfccc + mfcca) + + (mfaab + mfacb + mfcab + mfccb) + (mfaba + mfabc + mfcba + mfcbc) + (mfbaa + mfbac + mfbca + mfbcc) + + (mfabb + mfcbb) + (mfbab + mfbcb) + (mfbba + mfbbc) + mfbbb; + // //LBMReal dif = fabs(drho - rho_post); + // LBMReal dif = drho + (dX1_phi * vvx + dX2_phi * vvy + dX3_phi * vvz) * correctionScaling - rho_post; + //#ifdef SINGLEPRECISION + // if (dif > 10.0E-7 || dif < -10.0E-7) + //#else + // if (dif > 10.0E-15 || dif < -10.0E-15) + //#endif + // { + // UB_THROW(UbException(UB_EXARGS, "drho=" + UbSystem::toString(drho) + ", rho_post=" + UbSystem::toString(rho_post) + // + " dif=" + UbSystem::toString(dif) + // + " drho is not correct for node " + UbSystem::toString(x1) + "," + UbSystem::toString(x2) + "," + UbSystem::toString(x3))); + // //UBLOG(logERROR,"LBMKernelETD3Q27CCLB::collideAll(): drho is not correct for node "+UbSystem::toString(x1)+","+UbSystem::toString(x2)+","+UbSystem::toString(x3)); + // //exit(EXIT_FAILURE); + // } + //#endif + + if (UbMath::isNaN(rho_post) || UbMath::isInfinity(rho_post)) + UB_THROW(UbException( + UB_EXARGS, "rho_post is not a number (nan or -1.#IND) or infinity number -1.#INF, node=" + UbSystem::toString(x1) + "," + + UbSystem::toString(x2) + "," + UbSystem::toString(x3))); + + ////////////////////////////////////////////////////////////////////////// + //write distribution + ////////////////////////////////////////////////////////////////////////// + (*this->localDistributionsF)(D3Q27System::ET_E, x1, x2, x3) = mfabb ;//* rho * c1o3; + (*this->localDistributionsF)(D3Q27System::ET_N, x1, x2, x3) = mfbab ;//* rho * c1o3; + (*this->localDistributionsF)(D3Q27System::ET_T, x1, x2, x3) = mfbba ;//* rho * c1o3; + (*this->localDistributionsF)(D3Q27System::ET_NE, x1, x2, x3) = mfaab ;//* rho * c1o3; + (*this->localDistributionsF)(D3Q27System::ET_NW, x1p, x2, x3) = mfcab ;//* rho * c1o3; + (*this->localDistributionsF)(D3Q27System::ET_TE, x1, x2, x3) = mfaba ;//* rho * c1o3; + (*this->localDistributionsF)(D3Q27System::ET_TW, x1p, x2, x3) = mfcba ;//* rho * c1o3; + (*this->localDistributionsF)(D3Q27System::ET_TN, x1, x2, x3) = mfbaa ;//* rho * c1o3; + (*this->localDistributionsF)(D3Q27System::ET_TS, x1, x2p, x3) = mfbca ;//* rho * c1o3; + (*this->localDistributionsF)(D3Q27System::ET_TNE, x1, x2, x3) = mfaaa ;//* rho * c1o3; + (*this->localDistributionsF)(D3Q27System::ET_TNW, x1p, x2, x3) = mfcaa ;//* rho * c1o3; + (*this->localDistributionsF)(D3Q27System::ET_TSE, x1, x2p, x3) = mfaca ;//* rho * c1o3; + (*this->localDistributionsF)(D3Q27System::ET_TSW, x1p, x2p, x3) = mfcca ;//* rho * c1o3; + (*this->nonLocalDistributionsF)(D3Q27System::ET_W, x1p, x2, x3) = mfcbb ;//* rho * c1o3; + (*this->nonLocalDistributionsF)(D3Q27System::ET_S, x1, x2p, x3) = mfbcb ;//* rho * c1o3; + (*this->nonLocalDistributionsF)(D3Q27System::ET_B, x1, x2, x3p) = mfbbc ;//* rho * c1o3; + (*this->nonLocalDistributionsF)(D3Q27System::ET_SW, x1p, x2p, x3) = mfccb ;//* rho * c1o3; + (*this->nonLocalDistributionsF)(D3Q27System::ET_SE, x1, x2p, x3) = mfacb ;//* rho * c1o3; + (*this->nonLocalDistributionsF)(D3Q27System::ET_BW, x1p, x2, x3p) = mfcbc ;//* rho * c1o3; + (*this->nonLocalDistributionsF)(D3Q27System::ET_BE, x1, x2, x3p) = mfabc ;//* rho * c1o3; + (*this->nonLocalDistributionsF)(D3Q27System::ET_BS, x1, x2p, x3p) = mfbcc ;//* rho * c1o3; + (*this->nonLocalDistributionsF)(D3Q27System::ET_BN, x1, x2, x3p) = mfbac ;//* rho * c1o3; + (*this->nonLocalDistributionsF)(D3Q27System::ET_BSW, x1p, x2p, x3p) = mfccc ;//* rho * c1o3; + (*this->nonLocalDistributionsF)(D3Q27System::ET_BSE, x1, x2p, x3p) = mfacc ;//* rho * c1o3; + (*this->nonLocalDistributionsF)(D3Q27System::ET_BNW, x1p, x2, x3p) = mfcac ;//* rho * c1o3; + (*this->nonLocalDistributionsF)(D3Q27System::ET_BNE, x1, x2, x3p) = mfaac ;//* rho * c1o3; + + (*this->zeroDistributionsF)(x1, x2, x3) = mfbbb;// *rho* c1o3; + // !Old Kernel +///////////////////// P H A S E - F I E L D S O L V E R +//////////////////////////////////////////// +/////CUMULANT PHASE-FIELD + LBMReal omegaD =1.0/( 3.0 * mob + 0.5); + { + mfcbb = (*this->localDistributionsH1)(D3Q27System::ET_E, x1, x2, x3); + mfbcb = (*this->localDistributionsH1)(D3Q27System::ET_N, x1, x2, x3); + mfbbc = (*this->localDistributionsH1)(D3Q27System::ET_T, x1, x2, x3); + mfccb = (*this->localDistributionsH1)(D3Q27System::ET_NE, x1, x2, x3); + mfacb = (*this->localDistributionsH1)(D3Q27System::ET_NW, x1p, x2, x3); + mfcbc = (*this->localDistributionsH1)(D3Q27System::ET_TE, x1, x2, x3); + mfabc = (*this->localDistributionsH1)(D3Q27System::ET_TW, x1p, x2, x3); + mfbcc = (*this->localDistributionsH1)(D3Q27System::ET_TN, x1, x2, x3); + mfbac = (*this->localDistributionsH1)(D3Q27System::ET_TS, x1, x2p, x3); + mfccc = (*this->localDistributionsH1)(D3Q27System::ET_TNE, x1, x2, x3); + mfacc = (*this->localDistributionsH1)(D3Q27System::ET_TNW, x1p, x2, x3); + mfcac = (*this->localDistributionsH1)(D3Q27System::ET_TSE, x1, x2p, x3); + mfaac = (*this->localDistributionsH1)(D3Q27System::ET_TSW, x1p, x2p, x3); + mfabb = (*this->nonLocalDistributionsH1)(D3Q27System::ET_W, x1p, x2, x3); + mfbab = (*this->nonLocalDistributionsH1)(D3Q27System::ET_S, x1, x2p, x3); + mfbba = (*this->nonLocalDistributionsH1)(D3Q27System::ET_B, x1, x2, x3p); + mfaab = (*this->nonLocalDistributionsH1)(D3Q27System::ET_SW, x1p, x2p, x3); + mfcab = (*this->nonLocalDistributionsH1)(D3Q27System::ET_SE, x1, x2p, x3); + mfaba = (*this->nonLocalDistributionsH1)(D3Q27System::ET_BW, x1p, x2, x3p); + mfcba = (*this->nonLocalDistributionsH1)(D3Q27System::ET_BE, x1, x2, x3p); + mfbaa = (*this->nonLocalDistributionsH1)(D3Q27System::ET_BS, x1, x2p, x3p); + mfbca = (*this->nonLocalDistributionsH1)(D3Q27System::ET_BN, x1, x2, x3p); + mfaaa = (*this->nonLocalDistributionsH1)(D3Q27System::ET_BSW, x1p, x2p, x3p); + mfcaa = (*this->nonLocalDistributionsH1)(D3Q27System::ET_BSE, x1, x2p, x3p); + mfaca = (*this->nonLocalDistributionsH1)(D3Q27System::ET_BNW, x1p, x2, x3p); + mfcca = (*this->nonLocalDistributionsH1)(D3Q27System::ET_BNE, x1, x2, x3p); + mfbbb = (*this->zeroDistributionsH1)(x1, x2, x3); + + + //////////////////////////////////////////////////////////////////////////////////// + //! - 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> + //! + //////////////////////////////////////////////////////////////////////////////////// + // second component + LBMReal concentration = + ((((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; + //////////////////////////////////////////////////////////////////////////////////// + LBMReal oneMinusRho = c1- concentration; + + LBMReal cx = + ((((mfccc - mfaaa) + (mfcac - mfaca)) + ((mfcaa - mfacc) + (mfcca - mfaac))) + + (((mfcba - mfabc) + (mfcbc - mfaba)) + ((mfcab - mfacb) + (mfccb - mfaab))) + + (mfcbb - mfabb)); + LBMReal cy = + ((((mfccc - mfaaa) + (mfaca - mfcac)) + ((mfacc - mfcaa) + (mfcca - mfaac))) + + (((mfbca - mfbac) + (mfbcc - mfbaa)) + ((mfacb - mfcab) + (mfccb - mfaab))) + + (mfbcb - mfbab)); + LBMReal cz = + ((((mfccc - mfaaa) + (mfcac - mfaca)) + ((mfacc - mfcaa) + (mfaac - mfcca))) + + (((mfbac - mfbca) + (mfbcc - mfbaa)) + ((mfabc - mfcba) + (mfcbc - mfaba))) + + (mfbbc - mfbba)); + + //////////////////////////////////////////////////////////////////////////////////// + // calculate the square of velocities for this lattice node + LBMReal cx2 = cx * cx; + LBMReal cy2 = cy * cy; + LBMReal cz2 = cz * cz; + //////////////////////////////////////////////////////////////////////////////////// + //! - 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 + forwardInverseChimeraWithKincompressible(mfaaa, mfaab, mfaac, cz, cz2, c36, c1o36, oneMinusRho); + forwardInverseChimeraWithKincompressible(mfaba, mfabb, mfabc, cz, cz2, c9, c1o9, oneMinusRho); + forwardInverseChimeraWithKincompressible(mfaca, mfacb, mfacc, cz, cz2, c36, c1o36, oneMinusRho); + forwardInverseChimeraWithKincompressible(mfbaa, mfbab, mfbac, cz, cz2, c9, c1o9, oneMinusRho); + forwardInverseChimeraWithKincompressible(mfbba, mfbbb, mfbbc, cz, cz2, c9o4, c4o9, oneMinusRho); + forwardInverseChimeraWithKincompressible(mfbca, mfbcb, mfbcc, cz, cz2, c9, c1o9, oneMinusRho); + forwardInverseChimeraWithKincompressible(mfcaa, mfcab, mfcac, cz, cz2, c36, c1o36, oneMinusRho); + forwardInverseChimeraWithKincompressible(mfcba, mfcbb, mfcbc, cz, cz2, c9, c1o9, oneMinusRho); + forwardInverseChimeraWithKincompressible(mfcca, mfccb, mfccc, cz, cz2, c36, c1o36, oneMinusRho); + + //////////////////////////////////////////////////////////////////////////////////// + // Y - Dir + forwardInverseChimeraWithKincompressible(mfaaa, mfaba, mfaca, cy, cy2, c6, c1o6, oneMinusRho); + forwardChimera(mfaab, mfabb, mfacb, cy, cy2); + forwardInverseChimeraWithKincompressible(mfaac, mfabc, mfacc, cy, cy2, c18, c1o18, oneMinusRho); + forwardInverseChimeraWithKincompressible(mfbaa, mfbba, mfbca, cy, cy2, c3o2, c2o3, oneMinusRho); + forwardChimera(mfbab, mfbbb, mfbcb, cy, cy2); + forwardInverseChimeraWithKincompressible(mfbac, mfbbc, mfbcc, cy, cy2, c9o2, c2o9, oneMinusRho); + forwardInverseChimeraWithKincompressible(mfcaa, mfcba, mfcca, cy, cy2, c6, c1o6, oneMinusRho); + forwardChimera(mfcab, mfcbb, mfccb, cy, cy2); + forwardInverseChimeraWithKincompressible(mfcac, mfcbc, mfccc, cy, cy2, c18, c1o18, oneMinusRho); + + //////////////////////////////////////////////////////////////////////////////////// + // X - Dir + forwardInverseChimeraWithKincompressible(mfaaa, mfbaa, mfcaa, cx, cx2, c1, c1, oneMinusRho); + forwardChimera(mfaba, mfbba, mfcba, cx, cx2); + forwardInverseChimeraWithKincompressible(mfaca, mfbca, mfcca, cx, cx2, c3, c1o3, oneMinusRho); + forwardChimera(mfaab, mfbab, mfcab, cx, cx2); + forwardChimera(mfabb, mfbbb, mfcbb, cx, cx2); + forwardChimera(mfacb, mfbcb, mfccb, cx, cx2); + forwardInverseChimeraWithKincompressible(mfaac, mfbac, mfcac, cx, cx2, c3, c1o3, oneMinusRho); + forwardChimera(mfabc, mfbbc, mfcbc, cx, cx2); + forwardInverseChimeraWithKincompressible(mfacc, mfbcc, mfccc, cx, cx2, c3, c1o9, oneMinusRho); + + //////////////////////////////////////////////////////////////////////////////////// + //! - experimental Cumulant ... to be published ... hopefully + //! + + // linearized orthogonalization of 3rd order central moments + LBMReal Mabc = mfabc - mfaba * c1o3; + LBMReal Mbca = mfbca - mfbaa * c1o3; + LBMReal Macb = mfacb - mfaab * c1o3; + LBMReal Mcba = mfcba - mfaba * c1o3; + LBMReal Mcab = mfcab - mfaab * c1o3; + LBMReal Mbac = mfbac - mfbaa * c1o3; + // linearized orthogonalization of 5th order central moments + LBMReal Mcbc = mfcbc - mfaba * c1o9; + LBMReal Mbcc = mfbcc - mfbaa * c1o9; + LBMReal Mccb = mfccb - mfaab * c1o9; + + // collision of 1st order moments + cx = cx * (c1 - omegaD) + omegaD * vvx * concentration + + normX1 * (c1 - 0.5 * omegaD) * (1.0 - phi[REST]) * (phi[REST]) * c1o3 * oneOverInterfaceScale; + cy = cy * (c1 - omegaD) + omegaD * vvy * concentration + + normX2 * (c1 - 0.5 * omegaD) * (1.0 - phi[REST]) * (phi[REST]) * c1o3 * oneOverInterfaceScale; + cz = cz * (c1 - omegaD) + omegaD * vvz * concentration + + normX3 * (c1 - 0.5 * omegaD) * (1.0 - phi[REST]) * (phi[REST]) * c1o3 * oneOverInterfaceScale; + + cx2 = cx * cx; + cy2 = cy * cy; + cz2 = cz * cz; + + // equilibration of 2nd order moments + mfbba = zeroReal; + mfbab = zeroReal; + mfabb = zeroReal; + + mfcaa = c1o3 * concentration; + mfaca = c1o3 * concentration; + mfaac = c1o3 * concentration; + + // equilibration of 3rd order moments + Mabc = zeroReal; + Mbca = zeroReal; + Macb = zeroReal; + Mcba = zeroReal; + Mcab = zeroReal; + Mbac = zeroReal; + mfbbb = zeroReal; + + // from linearized orthogonalization 3rd order central moments to central moments + mfabc = Mabc + mfaba * c1o3; + mfbca = Mbca + mfbaa * c1o3; + mfacb = Macb + mfaab * c1o3; + mfcba = Mcba + mfaba * c1o3; + mfcab = Mcab + mfaab * c1o3; + mfbac = Mbac + mfbaa * c1o3; + + // equilibration of 4th order moments + mfacc = c1o9 * concentration; + mfcac = c1o9 * concentration; + mfcca = c1o9 * concentration; + + mfcbb = zeroReal; + mfbcb = zeroReal; + mfbbc = zeroReal; + + // equilibration of 5th order moments + Mcbc = zeroReal; + Mbcc = zeroReal; + Mccb = zeroReal; + + // from linearized orthogonalization 5th order central moments to central moments + mfcbc = Mcbc + mfaba * c1o9; + mfbcc = Mbcc + mfbaa * c1o9; + mfccb = Mccb + mfaab * c1o9; + + // equilibration of 6th order moment + mfccc = c1o27 * concentration; + + //////////////////////////////////////////////////////////////////////////////////// + //! - 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 + backwardInverseChimeraWithKincompressible(mfaaa, mfbaa, mfcaa, cx, cx2, c1, c1, oneMinusRho); + backwardChimera(mfaba, mfbba, mfcba, cx, cx2); + backwardInverseChimeraWithKincompressible(mfaca, mfbca, mfcca, cx, cx2, c3, c1o3, oneMinusRho); + backwardChimera(mfaab, mfbab, mfcab, cx, cx2); + backwardChimera(mfabb, mfbbb, mfcbb, cx, cx2); + backwardChimera(mfacb, mfbcb, mfccb, cx, cx2); + backwardInverseChimeraWithKincompressible(mfaac, mfbac, mfcac, cx, cx2, c3, c1o3, oneMinusRho); + backwardChimera(mfabc, mfbbc, mfcbc, cx, cx2); + backwardInverseChimeraWithKincompressible(mfacc, mfbcc, mfccc, cx, cx2, c9, c1o9, oneMinusRho); + + //////////////////////////////////////////////////////////////////////////////////// + // Y - Dir + backwardInverseChimeraWithKincompressible(mfaaa, mfaba, mfaca, cy, cy2, c6, c1o6, oneMinusRho); + backwardChimera(mfaab, mfabb, mfacb, cy, cy2); + backwardInverseChimeraWithKincompressible(mfaac, mfabc, mfacc, cy, cy2, c18, c1o18, oneMinusRho); + backwardInverseChimeraWithKincompressible(mfbaa, mfbba, mfbca, cy, cy2, c3o2, c2o3, oneMinusRho); + backwardChimera(mfbab, mfbbb, mfbcb, cy, cy2); + backwardInverseChimeraWithKincompressible(mfbac, mfbbc, mfbcc, cy, cy2, c9o2, c2o9, oneMinusRho); + backwardInverseChimeraWithKincompressible(mfcaa, mfcba, mfcca, cy, cy2, c6, c1o6, oneMinusRho); + backwardChimera(mfcab, mfcbb, mfccb, cy, cy2); + backwardInverseChimeraWithKincompressible(mfcac, mfcbc, mfccc, cy, cy2, c18, c1o18, oneMinusRho); + + //////////////////////////////////////////////////////////////////////////////////// + // Z - Dir + backwardInverseChimeraWithKincompressible(mfaaa, mfaab, mfaac, cz, cz2, c36, c1o36, oneMinusRho); + backwardInverseChimeraWithKincompressible(mfaba, mfabb, mfabc, cz, cz2, c9, c1o9, oneMinusRho); + backwardInverseChimeraWithKincompressible(mfaca, mfacb, mfacc, cz, cz2, c36, c1o36, oneMinusRho); + backwardInverseChimeraWithKincompressible(mfbaa, mfbab, mfbac, cz, cz2, c9, c1o9, oneMinusRho); + backwardInverseChimeraWithKincompressible(mfbba, mfbbb, mfbbc, cz, cz2, c9o4, c4o9, oneMinusRho); + backwardInverseChimeraWithKincompressible(mfbca, mfbcb, mfbcc, cz, cz2, c9, c1o9, oneMinusRho); + backwardInverseChimeraWithKincompressible(mfcaa, mfcab, mfcac, cz, cz2, c36, c1o36, oneMinusRho); + backwardInverseChimeraWithKincompressible(mfcba, mfcbb, mfcbc, cz, cz2, c9, c1o9, oneMinusRho); + backwardInverseChimeraWithKincompressible(mfcca, mfccb, mfccc, cz, cz2, c36, c1o36, oneMinusRho); + + + + (*this->localDistributionsH1)(D3Q27System::ET_E, x1, x2, x3) = mfabb; + (*this->localDistributionsH1)(D3Q27System::ET_N, x1, x2, x3) = mfbab; + (*this->localDistributionsH1)(D3Q27System::ET_T, x1, x2, x3) = mfbba; + (*this->localDistributionsH1)(D3Q27System::ET_NE, x1, x2, x3) = mfaab; + (*this->localDistributionsH1)(D3Q27System::ET_NW, x1p, x2, x3) = mfcab; + (*this->localDistributionsH1)(D3Q27System::ET_TE, x1, x2, x3) = mfaba; + (*this->localDistributionsH1)(D3Q27System::ET_TW, x1p, x2, x3) = mfcba; + (*this->localDistributionsH1)(D3Q27System::ET_TN, x1, x2, x3) = mfbaa; + (*this->localDistributionsH1)(D3Q27System::ET_TS, x1, x2p, x3) = mfbca; + (*this->localDistributionsH1)(D3Q27System::ET_TNE, x1, x2, x3) = mfaaa; + (*this->localDistributionsH1)(D3Q27System::ET_TNW, x1p, x2, x3) = mfcaa; + (*this->localDistributionsH1)(D3Q27System::ET_TSE, x1, x2p, x3) = mfaca; + (*this->localDistributionsH1)(D3Q27System::ET_TSW, x1p, x2p, x3) = mfcca; + + (*this->nonLocalDistributionsH1)(D3Q27System::ET_W, x1p, x2, x3 ) = mfcbb; + (*this->nonLocalDistributionsH1)(D3Q27System::ET_S, x1, x2p, x3 ) = mfbcb; + (*this->nonLocalDistributionsH1)(D3Q27System::ET_B, x1, x2, x3p) = mfbbc; + (*this->nonLocalDistributionsH1)(D3Q27System::ET_SW, x1p, x2p, x3 ) = mfccb; + (*this->nonLocalDistributionsH1)(D3Q27System::ET_SE, x1, x2p, x3 ) = mfacb; + (*this->nonLocalDistributionsH1)(D3Q27System::ET_BW, x1p, x2, x3p) = mfcbc; + (*this->nonLocalDistributionsH1)(D3Q27System::ET_BE, x1, x2, x3p) = mfabc; + (*this->nonLocalDistributionsH1)(D3Q27System::ET_BS, x1, x2p, x3p) = mfbcc; + (*this->nonLocalDistributionsH1)(D3Q27System::ET_BN, x1, x2, x3p) = mfbac; + (*this->nonLocalDistributionsH1)(D3Q27System::ET_BSW, x1p, x2p, x3p) = mfccc; + (*this->nonLocalDistributionsH1)(D3Q27System::ET_BSE, x1, x2p, x3p) = mfacc; + (*this->nonLocalDistributionsH1)(D3Q27System::ET_BNW, x1p, x2, x3p) = mfcac; + (*this->nonLocalDistributionsH1)(D3Q27System::ET_BNE, x1, x2, x3p) = mfaac; + + (*this->zeroDistributionsH1)(x1,x2,x3) = mfbbb; + } + } + } + } + } +} +////////////////////////////////////////////////////////////////////////// + +LBMReal MultiphasePressureFilterCompressibleAirLBMKernel::gradX1_phi() +{ + using namespace D3Q27System; + return 3.0* ((WEIGTH[TNE] * (((phi[TNE] - phi[BSW]) + (phi[BSE] - phi[TNW])) + ((phi[TSE] - phi[BNW]) + (phi[BNE] - phi[TSW]))) + + WEIGTH[NE] * (((phi[TE] - phi[BW]) + (phi[BE] - phi[TW])) + ((phi[SE] - phi[NW]) + (phi[NE] - phi[SW])))) + + +WEIGTH[N] * (phi[E] - phi[W])); +} + +LBMReal MultiphasePressureFilterCompressibleAirLBMKernel::gradX2_phi() +{ + using namespace D3Q27System; + return 3.0 * ((WEIGTH[TNE] * (((phi[TNE] - phi[BSW]) - (phi[BSE] - phi[TNW])) + ((phi[BNE] - phi[TSW])- (phi[TSE] - phi[BNW]))) + + WEIGTH[NE] * (((phi[TN] - phi[BS]) + (phi[BN] - phi[TS])) + ((phi[NE] - phi[SW])- (phi[SE] - phi[NW])))) + + +WEIGTH[N] * (phi[N] - phi[S])); +} + +LBMReal MultiphasePressureFilterCompressibleAirLBMKernel::gradX3_phi() +{ + using namespace D3Q27System; + return 3.0 * ((WEIGTH[TNE] * (((phi[TNE] - phi[BSW]) - (phi[BSE] - phi[TNW])) + ((phi[TSE] - phi[BNW]) - (phi[BNE] - phi[TSW]))) + + WEIGTH[NE] * (((phi[TE] - phi[BW]) - (phi[BE] - phi[TW])) + ((phi[TS] - phi[BN]) + (phi[TN] - phi[BS])))) + + +WEIGTH[N] * (phi[T] - phi[B])); +} + +LBMReal MultiphasePressureFilterCompressibleAirLBMKernel::gradX1_phi2() +{ + using namespace D3Q27System; + return 3.0 * ((WEIGTH[TNE] * (((phi2[TNE] - phi2[BSW]) + (phi2[BSE] - phi2[TNW])) + ((phi2[TSE] - phi2[BNW]) + (phi2[BNE] - phi2[TSW]))) + + WEIGTH[NE] * (((phi2[TE] - phi2[BW]) + (phi2[BE] - phi2[TW])) + ((phi2[SE] - phi2[NW]) + (phi2[NE] - phi2[SW])))) + + +WEIGTH[N] * (phi2[E] - phi2[W])); +} + +LBMReal MultiphasePressureFilterCompressibleAirLBMKernel::gradX2_phi2() +{ + using namespace D3Q27System; + return 3.0 * ((WEIGTH[TNE] * (((phi2[TNE] - phi2[BSW]) - (phi2[BSE] - phi2[TNW])) + ((phi2[BNE] - phi2[TSW]) - (phi2[TSE] - phi2[BNW]))) + + WEIGTH[NE] * (((phi2[TN] - phi2[BS]) + (phi2[BN] - phi2[TS])) + ((phi2[NE] - phi2[SW]) - (phi2[SE] - phi2[NW])))) + + +WEIGTH[N] * (phi2[N] - phi2[S])); +} + +LBMReal MultiphasePressureFilterCompressibleAirLBMKernel::gradX3_phi2() +{ + using namespace D3Q27System; + return 3.0 * ((WEIGTH[TNE] * (((phi2[TNE] - phi2[BSW]) - (phi2[BSE] - phi2[TNW])) + ((phi2[TSE] - phi2[BNW]) - (phi2[BNE] - phi2[TSW]))) + + WEIGTH[NE] * (((phi2[TE] - phi2[BW]) - (phi2[BE] - phi2[TW])) + ((phi2[TS] - phi2[BN]) + (phi2[TN] - phi2[BS])))) + + +WEIGTH[N] * (phi2[T] - phi2[B])); +} + +LBMReal MultiphasePressureFilterCompressibleAirLBMKernel::nabla2_phi() +{ + using namespace D3Q27System; + LBMReal sum = 0.0; + sum += WEIGTH[TNE] * ((((phi[TNE] - phi[REST]) + (phi[BSW] - phi[REST])) + ((phi[TSW] - phi[REST]) + (phi[BNE] - phi[REST]))) + + (((phi[TNW] - phi[REST]) + (phi[BSE] - phi[REST])) + ((phi[TSE] - phi[REST]) + (phi[BNW] - phi[REST])))); + sum += WEIGTH[TN] * ( + (((phi[TN] - phi[REST]) + (phi[BS] - phi[REST])) + ((phi[TS] - phi[REST]) + (phi[BN] - phi[REST]))) + + (((phi[TE] - phi[REST]) + (phi[BW] - phi[REST])) + ((phi[TW] - phi[REST]) + (phi[BE] - phi[REST]))) + + (((phi[NE] - phi[REST]) + (phi[SW] - phi[REST])) + ((phi[NW] - phi[REST]) + (phi[SE] - phi[REST]))) + ); + sum += WEIGTH[T] * ( + ((phi[T] - phi[REST]) + (phi[B] - phi[REST])) + + ((phi[N] - phi[REST]) + (phi[S] - phi[REST])) + + ((phi[E] - phi[REST]) + (phi[W] - phi[REST])) + ); + + return 6.0 * sum; +} + +void MultiphasePressureFilterCompressibleAirLBMKernel::computePhasefield() +{ + using namespace D3Q27System; + SPtr<DistributionArray3D> distributionsH = dataSet->getHdistributions(); + + int minX1 = ghostLayerWidth; + int minX2 = ghostLayerWidth; + int minX3 = ghostLayerWidth; + int maxX1 = (int)distributionsH->getNX1() - ghostLayerWidth; + int maxX2 = (int)distributionsH->getNX2() - ghostLayerWidth; + int maxX3 = (int)distributionsH->getNX3() - ghostLayerWidth; + + //------------- Computing the phase-field ------------------ + for (int x3 = minX3; x3 < maxX3; x3++) { + for (int x2 = minX2; x2 < maxX2; x2++) { + for (int x1 = minX1; x1 < maxX1; x1++) { + // if(!bcArray->isSolid(x1,x2,x3) && !bcArray->isUndefined(x1,x2,x3)) + { + int x1p = x1 + 1; + int x2p = x2 + 1; + int x3p = x3 + 1; + + h[E] = (*this->localDistributionsH1)(D3Q27System::ET_E, x1, x2, x3); + h[N] = (*this->localDistributionsH1)(D3Q27System::ET_N, x1, x2, x3); + h[T] = (*this->localDistributionsH1)(D3Q27System::ET_T, x1, x2, x3); + h[NE] = (*this->localDistributionsH1)(D3Q27System::ET_NE, x1, x2, x3); + h[NW] = (*this->localDistributionsH1)(D3Q27System::ET_NW, x1p, x2, x3); + h[TE] = (*this->localDistributionsH1)(D3Q27System::ET_TE, x1, x2, x3); + h[TW] = (*this->localDistributionsH1)(D3Q27System::ET_TW, x1p, x2, x3); + h[TN] = (*this->localDistributionsH1)(D3Q27System::ET_TN, x1, x2, x3); + h[TS] = (*this->localDistributionsH1)(D3Q27System::ET_TS, x1, x2p, x3); + h[TNE] = (*this->localDistributionsH1)(D3Q27System::ET_TNE, x1, x2, x3); + h[TNW] = (*this->localDistributionsH1)(D3Q27System::ET_TNW, x1p, x2, x3); + h[TSE] = (*this->localDistributionsH1)(D3Q27System::ET_TSE, x1, x2p, x3); + h[TSW] = (*this->localDistributionsH1)(D3Q27System::ET_TSW, x1p, x2p, x3); + + h[W] = (*this->nonLocalDistributionsH1)(D3Q27System::ET_W, x1p, x2, x3); + h[S] = (*this->nonLocalDistributionsH1)(D3Q27System::ET_S, x1, x2p, x3); + h[B] = (*this->nonLocalDistributionsH1)(D3Q27System::ET_B, x1, x2, x3p); + h[SW] = (*this->nonLocalDistributionsH1)(D3Q27System::ET_SW, x1p, x2p, x3); + h[SE] = (*this->nonLocalDistributionsH1)(D3Q27System::ET_SE, x1, x2p, x3); + h[BW] = (*this->nonLocalDistributionsH1)(D3Q27System::ET_BW, x1p, x2, x3p); + h[BE] = (*this->nonLocalDistributionsH1)(D3Q27System::ET_BE, x1, x2, x3p); + h[BS] = (*this->nonLocalDistributionsH1)(D3Q27System::ET_BS, x1, x2p, x3p); + h[BN] = (*this->nonLocalDistributionsH1)(D3Q27System::ET_BN, x1, x2, x3p); + h[BSW] = (*this->nonLocalDistributionsH1)(D3Q27System::ET_BSW, x1p, x2p, x3p); + h[BSE] = (*this->nonLocalDistributionsH1)(D3Q27System::ET_BSE, x1, x2p, x3p); + h[BNW] = (*this->nonLocalDistributionsH1)(D3Q27System::ET_BNW, x1p, x2, x3p); + h[BNE] = (*this->nonLocalDistributionsH1)(D3Q27System::ET_BNE, x1, x2, x3p); + + h[REST] = (*this->zeroDistributionsH1)(x1, x2, x3); + } + } + } + } +} + +void MultiphasePressureFilterCompressibleAirLBMKernel::findNeighbors(CbArray3D<LBMReal, IndexerX3X2X1>::CbArray3DPtr ph, int x1, int x2, + int x3) +{ + using namespace D3Q27System; + + SPtr<BCArray3D> bcArray = this->getBCProcessor()->getBCArray(); + + phi[REST] = (*ph)(x1, x2, x3); + + + for (int k = FSTARTDIR; k <= FENDDIR; k++) { + + if (!bcArray->isSolid(x1 + DX1[k], x2 + DX2[k], x3 + DX3[k])) { + phi[k] = (*ph)(x1 + DX1[k], x2 + DX2[k], x3 + DX3[k]); + } else { + phi[k] = 0.0; + } + } +} + +void MultiphasePressureFilterCompressibleAirLBMKernel::findNeighbors2(CbArray3D<LBMReal, IndexerX3X2X1>::CbArray3DPtr ph, int x1, int x2, + int x3) +{ + using namespace D3Q27System; + + SPtr<BCArray3D> bcArray = this->getBCProcessor()->getBCArray(); + + phi2[REST] = (*ph)(x1, x2, x3); + + + for (int k = FSTARTDIR; k <= FENDDIR; k++) { + + if (!bcArray->isSolid(x1 + DX1[k], x2 + DX2[k], x3 + DX3[k])) { + phi2[k] = (*ph)(x1 + DX1[k], x2 + DX2[k], x3 + DX3[k]); + } + else { + phi2[k] = 0.0; + } + } +} + +void MultiphasePressureFilterCompressibleAirLBMKernel::swapDistributions() +{ + LBMKernel::swapDistributions(); + dataSet->getHdistributions()->swap(); +} + +void MultiphasePressureFilterCompressibleAirLBMKernel::initForcing() +{ + muForcingX1.DefineVar("x1", &muX1); muForcingX1.DefineVar("x2", &muX2); muForcingX1.DefineVar("x3", &muX3); + muForcingX2.DefineVar("x1", &muX1); muForcingX2.DefineVar("x2", &muX2); muForcingX2.DefineVar("x3", &muX3); + muForcingX3.DefineVar("x1", &muX1); muForcingX3.DefineVar("x2", &muX2); muForcingX3.DefineVar("x3", &muX3); + + muDeltaT = deltaT; + + muForcingX1.DefineVar("dt", &muDeltaT); + muForcingX2.DefineVar("dt", &muDeltaT); + muForcingX3.DefineVar("dt", &muDeltaT); + + muNu = (1.0 / 3.0) * (1.0 / collFactor - 1.0 / 2.0); + + muForcingX1.DefineVar("nu", &muNu); + muForcingX2.DefineVar("nu", &muNu); + muForcingX3.DefineVar("nu", &muNu); + + muForcingX1.DefineVar("rho",&muRho); + muForcingX2.DefineVar("rho",&muRho); + muForcingX3.DefineVar("rho",&muRho); + +} diff --git a/src/cpu/VirtualFluidsCore/LBM/MultiphasePressureFilterCompressibleAirLBMKernel.h b/src/cpu/VirtualFluidsCore/LBM/MultiphasePressureFilterCompressibleAirLBMKernel.h new file mode 100644 index 0000000000000000000000000000000000000000..e15f29e0434c0d5f59977226cab91455f2a39f70 --- /dev/null +++ b/src/cpu/VirtualFluidsCore/LBM/MultiphasePressureFilterCompressibleAirLBMKernel.h @@ -0,0 +1,116 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// 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 MultiphasePressureFilterCompressibleAirLBMKernel.h +//! \ingroup LBMKernel +//! \author M. Geier, K. Kutscher, Hesameddin Safari +//======================================================================================= + +#ifndef MultiphasePressureFilterCompressibleAirLBMKernel_H +#define MultiphasePressureFilterCompressibleAirLBMKernel_H + +#include "LBMKernel.h" +#include "BCProcessor.h" +#include "D3Q27System.h" +#include "basics/utilities/UbTiming.h" +#include "basics/container/CbArray4D.h" +#include "basics/container/CbArray3D.h" + +//! \brief Multiphase Cascaded Cumulant LBM kernel. +//! \details CFD solver that use Cascaded Cumulant Lattice Boltzmann method for D3Q27 model +//! \author M. Geier, K. Kutscher, Hesameddin Safari +class MultiphasePressureFilterCompressibleAirLBMKernel : public LBMKernel +{ +public: + MultiphasePressureFilterCompressibleAirLBMKernel(); + virtual ~MultiphasePressureFilterCompressibleAirLBMKernel(void) = default; + void calculate(int step) override; + SPtr<LBMKernel> clone() override; + + + ///refactor + //CbArray3D<LBMReal, IndexerX3X2X1>::CbArray3DPtr pressure; + + + double getCalculationTime() override { return .0; } +protected: + virtual void initDataSet(); + void swapDistributions() override; + + void initForcing(); + + void forwardInverseChimeraWithKincompressible(LBMReal& mfa, LBMReal& mfb, LBMReal& mfc, LBMReal vv, LBMReal v2, LBMReal Kinverse, LBMReal K, LBMReal oneMinusRho); + void backwardInverseChimeraWithKincompressible(LBMReal& mfa, LBMReal& mfb, LBMReal& mfc, LBMReal vv, LBMReal v2, LBMReal Kinverse, LBMReal K, LBMReal oneMinusRho); + void forwardChimera(LBMReal& mfa, LBMReal& mfb, LBMReal& mfc, LBMReal vv, LBMReal v2); + void backwardChimera(LBMReal& mfa, LBMReal& mfb, LBMReal& mfc, LBMReal vv, LBMReal v2); + + LBMReal f1[D3Q27System::ENDF+1]; + + CbArray4D<LBMReal,IndexerX4X3X2X1>::CbArray4DPtr localDistributionsF; + CbArray4D<LBMReal,IndexerX4X3X2X1>::CbArray4DPtr nonLocalDistributionsF; + CbArray3D<LBMReal,IndexerX3X2X1>::CbArray3DPtr zeroDistributionsF; + + CbArray4D<LBMReal,IndexerX4X3X2X1>::CbArray4DPtr localDistributionsH1; + CbArray4D<LBMReal,IndexerX4X3X2X1>::CbArray4DPtr nonLocalDistributionsH1; + CbArray3D<LBMReal,IndexerX3X2X1>::CbArray3DPtr zeroDistributionsH1; + + CbArray3D<LBMReal, IndexerX3X2X1>::CbArray3DPtr pressureOld; + + CbArray3D<LBMReal, IndexerX3X2X1>::CbArray3DPtr phaseField; + CbArray3D<LBMReal, IndexerX3X2X1>::CbArray3DPtr divU; + + LBMReal h [D3Q27System::ENDF+1]; + LBMReal h2[D3Q27System::ENDF + 1]; + LBMReal g [D3Q27System::ENDF+1]; + LBMReal phi[D3Q27System::ENDF+1]; + LBMReal phi2[D3Q27System::ENDF + 1]; + LBMReal pr1[D3Q27System::ENDF+1]; + LBMReal phi_cutoff[D3Q27System::ENDF+1]; + + LBMReal gradX1_phi(); + LBMReal gradX2_phi(); + LBMReal gradX3_phi(); + LBMReal gradX1_phi2(); + LBMReal gradX2_phi2(); + LBMReal gradX3_phi2(); + void computePhasefield(); + void findNeighbors(CbArray3D<LBMReal,IndexerX3X2X1>::CbArray3DPtr ph /*Phase-Field*/, int x1, int x2, int x3); + void findNeighbors2(CbArray3D<LBMReal, IndexerX3X2X1>::CbArray3DPtr ph, int x1, int x2, int x3); + + LBMReal nabla2_phi(); + + mu::value_type muX1,muX2,muX3; + mu::value_type muDeltaT; + mu::value_type muNu; + mu::value_type muRho; + LBMReal forcingX1; + LBMReal forcingX2; + LBMReal forcingX3; +}; + +#endif diff --git a/src/cpu/VirtualFluidsCore/LBM/MultiphasePressureFilterLBMKernel.cpp b/src/cpu/VirtualFluidsCore/LBM/MultiphasePressureFilterLBMKernel.cpp new file mode 100644 index 0000000000000000000000000000000000000000..240027f329b49a570f35bd9a2b83b4eebfe5632f --- /dev/null +++ b/src/cpu/VirtualFluidsCore/LBM/MultiphasePressureFilterLBMKernel.cpp @@ -0,0 +1,1667 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// 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 MultiphasePressureFilterLBMKernel.cpp +//! \ingroup LBMKernel +//! \author M. Geier, K. Kutscher, Hesameddin Safari +//======================================================================================= + +#include "MultiphasePressureFilterLBMKernel.h" +#include "BCArray3D.h" +#include "Block3D.h" +#include "D3Q27EsoTwist3DSplittedVector.h" +#include "D3Q27System.h" +#include "DataSet3D.h" +#include "LBMKernel.h" +#include <cmath> + +#define PROOF_CORRECTNESS + +////////////////////////////////////////////////////////////////////////// +MultiphasePressureFilterLBMKernel::MultiphasePressureFilterLBMKernel() { this->compressible = false; } +////////////////////////////////////////////////////////////////////////// +void MultiphasePressureFilterLBMKernel::initDataSet() +{ + SPtr<DistributionArray3D> f(new D3Q27EsoTwist3DSplittedVector( nx[0] + 4, nx[1] + 4, nx[2] + 4, -999.9)); + SPtr<DistributionArray3D> h(new D3Q27EsoTwist3DSplittedVector( nx[0] + 4, nx[1] + 4, nx[2] + 4, -999.9)); // For phase-field + + SPtr<PhaseFieldArray3D> divU1(new PhaseFieldArray3D( nx[0] + 4, nx[1] + 4, nx[2] + 4, 0.0)); + CbArray3D<LBMReal, IndexerX3X2X1>::CbArray3DPtr pressure(new CbArray3D<LBMReal, IndexerX3X2X1>( nx[0] + 4, nx[1] + 4, nx[2] + 4, 0.0)); + pressureOld = CbArray3D<LBMReal, IndexerX3X2X1>::CbArray3DPtr(new CbArray3D<LBMReal, IndexerX3X2X1>(nx[0] + 4, nx[1] + 4, nx[2] + 4, 0.0)); + dataSet->setFdistributions(f); + dataSet->setHdistributions(h); // For phase-field + dataSet->setPhaseField(divU1); + dataSet->setPressureField(pressure); + + phaseField = CbArray3D<LBMReal, IndexerX3X2X1>::CbArray3DPtr(new CbArray3D<LBMReal, IndexerX3X2X1>(nx[0] + 4, nx[1] + 4, nx[2] + 4, -999.0)); + + divU = CbArray3D<LBMReal, IndexerX3X2X1>::CbArray3DPtr(new CbArray3D<LBMReal, IndexerX3X2X1>(nx[0] + 4, nx[1] + 4, nx[2] + 4, 0.0)); +} +////////////////////////////////////////////////////////////////////////// +SPtr<LBMKernel> MultiphasePressureFilterLBMKernel::clone() +{ + SPtr<LBMKernel> kernel(new MultiphasePressureFilterLBMKernel()); + kernel->setNX(nx); + dynamicPointerCast<MultiphasePressureFilterLBMKernel>(kernel)->initDataSet(); + kernel->setCollisionFactorMultiphase(this->collFactorL, this->collFactorG); + kernel->setDensityRatio(this->densityRatio); + kernel->setMultiphaseModelParameters(this->beta, this->kappa); + kernel->setContactAngle(this->contactAngle); + kernel->setPhiL(this->phiL); + kernel->setPhiH(this->phiH); + kernel->setPhaseFieldRelaxation(this->tauH); + kernel->setMobility(this->mob); + kernel->setInterfaceWidth(this->interfaceWidth); + + kernel->setBCProcessor(bcProcessor->clone(kernel)); + kernel->setWithForcing(withForcing); + kernel->setForcingX1(muForcingX1); + kernel->setForcingX2(muForcingX2); + kernel->setForcingX3(muForcingX3); + kernel->setIndex(ix1, ix2, ix3); + kernel->setDeltaT(deltaT); + kernel->setGhostLayerWidth(2); + dynamicPointerCast<MultiphasePressureFilterLBMKernel>(kernel)->initForcing(); + + return kernel; +} +////////////////////////////////////////////////////////////////////////// +void MultiphasePressureFilterLBMKernel::forwardInverseChimeraWithKincompressible(LBMReal& mfa, LBMReal& mfb, LBMReal& mfc, LBMReal vv, LBMReal v2, LBMReal Kinverse, LBMReal K, LBMReal oneMinusRho) { + using namespace UbMath; + LBMReal m2 = mfa + mfc; + LBMReal m1 = mfc - mfa; + LBMReal m0 = m2 + mfb; + mfa = m0; + m0 *= Kinverse; + m0 += oneMinusRho; + mfb = (m1 * Kinverse - m0 * vv) * K; + mfc = ((m2 - c2 * m1 * vv) * Kinverse + v2 * m0) * K; +} + +//////////////////////////////////////////////////////////////////////////////// +void MultiphasePressureFilterLBMKernel::backwardInverseChimeraWithKincompressible(LBMReal& mfa, LBMReal& mfb, LBMReal& mfc, LBMReal vv, LBMReal v2, LBMReal Kinverse, LBMReal K, LBMReal oneMinusRho) { + using namespace UbMath; + LBMReal m0 = (((mfc - mfb) * c1o2 + mfb * vv) * Kinverse + (mfa * Kinverse + oneMinusRho) * (v2 - vv) * c1o2) * K; + LBMReal m1 = (((mfa - mfc) - c2 * mfb * vv) * Kinverse + (mfa * Kinverse + oneMinusRho) * (-v2)) * K; + mfc = (((mfc + mfb) * c1o2 + mfb * vv) * Kinverse + (mfa * Kinverse + oneMinusRho) * (v2 + vv) * c1o2) * K; + mfa = m0; + mfb = m1; +} + + +//////////////////////////////////////////////////////////////////////////////// +void MultiphasePressureFilterLBMKernel::forwardChimera(LBMReal& mfa, LBMReal& mfb, LBMReal& mfc, LBMReal vv, LBMReal v2) { + using namespace UbMath; + LBMReal m1 = (mfa + mfc) + mfb; + LBMReal m2 = mfc - mfa; + mfc = (mfc + mfa) + (v2 * m1 - c2 * vv * m2); + mfb = m2 - vv * m1; + mfa = m1; +} + + +void MultiphasePressureFilterLBMKernel::backwardChimera(LBMReal& mfa, LBMReal& mfb, LBMReal& mfc, LBMReal vv, LBMReal v2) { + using namespace UbMath; + LBMReal ma = (mfc + mfa * (v2 - vv)) * c1o2 + mfb * (vv - c1o2); + LBMReal mb = ((mfa - mfc) - mfa * v2) - c2 * mfb * vv; + mfc = (mfc + mfa * (v2 + vv)) * c1o2 + mfb * (vv + c1o2); + mfb = mb; + mfa = ma; +} + + +void MultiphasePressureFilterLBMKernel::calculate(int step) +{ + using namespace D3Q27System; + using namespace UbMath; + + forcingX1 = 0.0; + forcingX2 = 0.0; + forcingX3 = 0.0; + + LBMReal oneOverInterfaceScale = c4 / interfaceWidth; //1.0;//1.5; + ///////////////////////////////////// + + localDistributionsF = dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(dataSet->getFdistributions())->getLocalDistributions(); + nonLocalDistributionsF = dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(dataSet->getFdistributions())->getNonLocalDistributions(); + zeroDistributionsF = dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(dataSet->getFdistributions())->getZeroDistributions(); + + localDistributionsH1 = dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(dataSet->getHdistributions())->getLocalDistributions(); + nonLocalDistributionsH1 = dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(dataSet->getHdistributions())->getNonLocalDistributions(); + zeroDistributionsH1 = dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(dataSet->getHdistributions())->getZeroDistributions(); + + CbArray3D<LBMReal, IndexerX3X2X1>::CbArray3DPtr pressure = dataSet->getPressureField(); + + SPtr<BCArray3D> bcArray = this->getBCProcessor()->getBCArray(); + + const int bcArrayMaxX1 = (int)bcArray->getNX1(); + const int bcArrayMaxX2 = (int)bcArray->getNX2(); + const int bcArrayMaxX3 = (int)bcArray->getNX3(); + + int minX1 = ghostLayerWidth; + int minX2 = ghostLayerWidth; + int minX3 = ghostLayerWidth; + int maxX1 = bcArrayMaxX1 - ghostLayerWidth; + int maxX2 = bcArrayMaxX2 - ghostLayerWidth; + int maxX3 = bcArrayMaxX3 - ghostLayerWidth; + + for (int x3 = minX3-ghostLayerWidth; x3 < maxX3+ghostLayerWidth; x3++) { + for (int x2 = minX2-ghostLayerWidth; x2 < maxX2+ghostLayerWidth; x2++) { + for (int x1 = minX1-ghostLayerWidth; x1 < maxX1+ghostLayerWidth; x1++) { + if (!bcArray->isSolid(x1, x2, x3) && !bcArray->isUndefined(x1, x2, x3)) { + int x1p = x1 + 1; + int x2p = x2 + 1; + int x3p = x3 + 1; + + LBMReal mfcbb = (*this->localDistributionsH1)(D3Q27System::ET_E, x1, x2, x3); + LBMReal mfbcb = (*this->localDistributionsH1)(D3Q27System::ET_N, x1, x2, x3); + LBMReal mfbbc = (*this->localDistributionsH1)(D3Q27System::ET_T, x1, x2, x3); + LBMReal mfccb = (*this->localDistributionsH1)(D3Q27System::ET_NE, x1, x2, x3); + LBMReal mfacb = (*this->localDistributionsH1)(D3Q27System::ET_NW, x1p, x2, x3); + LBMReal mfcbc = (*this->localDistributionsH1)(D3Q27System::ET_TE, x1, x2, x3); + LBMReal mfabc = (*this->localDistributionsH1)(D3Q27System::ET_TW, x1p, x2, x3); + LBMReal mfbcc = (*this->localDistributionsH1)(D3Q27System::ET_TN, x1, x2, x3); + LBMReal mfbac = (*this->localDistributionsH1)(D3Q27System::ET_TS, x1, x2p, x3); + LBMReal mfccc = (*this->localDistributionsH1)(D3Q27System::ET_TNE, x1, x2, x3); + LBMReal mfacc = (*this->localDistributionsH1)(D3Q27System::ET_TNW, x1p, x2, x3); + LBMReal mfcac = (*this->localDistributionsH1)(D3Q27System::ET_TSE, x1, x2p, x3); + LBMReal mfaac = (*this->localDistributionsH1)(D3Q27System::ET_TSW, x1p, x2p, x3); + LBMReal mfabb = (*this->nonLocalDistributionsH1)(D3Q27System::ET_W, x1p, x2, x3); + LBMReal mfbab = (*this->nonLocalDistributionsH1)(D3Q27System::ET_S, x1, x2p, x3); + LBMReal mfbba = (*this->nonLocalDistributionsH1)(D3Q27System::ET_B, x1, x2, x3p); + LBMReal mfaab = (*this->nonLocalDistributionsH1)(D3Q27System::ET_SW, x1p, x2p, x3); + LBMReal mfcab = (*this->nonLocalDistributionsH1)(D3Q27System::ET_SE, x1, x2p, x3); + LBMReal mfaba = (*this->nonLocalDistributionsH1)(D3Q27System::ET_BW, x1p, x2, x3p); + LBMReal mfcba = (*this->nonLocalDistributionsH1)(D3Q27System::ET_BE, x1, x2, x3p); + LBMReal mfbaa = (*this->nonLocalDistributionsH1)(D3Q27System::ET_BS, x1, x2p, x3p); + LBMReal mfbca = (*this->nonLocalDistributionsH1)(D3Q27System::ET_BN, x1, x2, x3p); + LBMReal mfaaa = (*this->nonLocalDistributionsH1)(D3Q27System::ET_BSW, x1p, x2p, x3p); + LBMReal mfcaa = (*this->nonLocalDistributionsH1)(D3Q27System::ET_BSE, x1, x2p, x3p); + LBMReal mfaca = (*this->nonLocalDistributionsH1)(D3Q27System::ET_BNW, x1p, x2, x3p); + LBMReal mfcca = (*this->nonLocalDistributionsH1)(D3Q27System::ET_BNE, x1, x2, x3p); + + LBMReal mfbbb = (*this->zeroDistributionsH1)(x1, x2, x3); + (*phaseField)(x1, x2, x3) = (((mfaaa + mfccc) + (mfaca + mfcac)) + ((mfaac + mfcca) + (mfcaa + mfacc)) ) + + (((mfaab + mfacb) + (mfcab + mfccb)) + ((mfaba + mfabc) + (mfcba + mfcbc)) + + ((mfbaa + mfbac) + (mfbca + mfbcc))) + ((mfabb + mfcbb) + + (mfbab + mfbcb) + (mfbba + mfbbc)) + mfbbb; + + ////// read F-distributions for velocity formalism + + mfcbb = (*this->localDistributionsF)(D3Q27System::ET_E, x1, x2, x3); + mfbcb = (*this->localDistributionsF)(D3Q27System::ET_N, x1, x2, x3); + mfbbc = (*this->localDistributionsF)(D3Q27System::ET_T, x1, x2, x3); + mfccb = (*this->localDistributionsF)(D3Q27System::ET_NE, x1, x2, x3); + mfacb = (*this->localDistributionsF)(D3Q27System::ET_NW, x1p, x2, x3); + mfcbc = (*this->localDistributionsF)(D3Q27System::ET_TE, x1, x2, x3); + mfabc = (*this->localDistributionsF)(D3Q27System::ET_TW, x1p, x2, x3); + mfbcc = (*this->localDistributionsF)(D3Q27System::ET_TN, x1, x2, x3); + mfbac = (*this->localDistributionsF)(D3Q27System::ET_TS, x1, x2p, x3); + mfccc = (*this->localDistributionsF)(D3Q27System::ET_TNE, x1, x2, x3); + mfacc = (*this->localDistributionsF)(D3Q27System::ET_TNW, x1p, x2, x3); + mfcac = (*this->localDistributionsF)(D3Q27System::ET_TSE, x1, x2p, x3); + mfaac = (*this->localDistributionsF)(D3Q27System::ET_TSW, x1p, x2p, x3); + mfabb = (*this->nonLocalDistributionsF)(D3Q27System::ET_W, x1p, x2, x3); + mfbab = (*this->nonLocalDistributionsF)(D3Q27System::ET_S, x1, x2p, x3); + mfbba = (*this->nonLocalDistributionsF)(D3Q27System::ET_B, x1, x2, x3p); + mfaab = (*this->nonLocalDistributionsF)(D3Q27System::ET_SW, x1p, x2p, x3); + mfcab = (*this->nonLocalDistributionsF)(D3Q27System::ET_SE, x1, x2p, x3); + mfaba = (*this->nonLocalDistributionsF)(D3Q27System::ET_BW, x1p, x2, x3p); + mfcba = (*this->nonLocalDistributionsF)(D3Q27System::ET_BE, x1, x2, x3p); + mfbaa = (*this->nonLocalDistributionsF)(D3Q27System::ET_BS, x1, x2p, x3p); + mfbca = (*this->nonLocalDistributionsF)(D3Q27System::ET_BN, x1, x2, x3p); + mfaaa = (*this->nonLocalDistributionsF)(D3Q27System::ET_BSW, x1p, x2p, x3p); + mfcaa = (*this->nonLocalDistributionsF)(D3Q27System::ET_BSE, x1, x2p, x3p); + mfaca = (*this->nonLocalDistributionsF)(D3Q27System::ET_BNW, x1p, x2, x3p); + mfcca = (*this->nonLocalDistributionsF)(D3Q27System::ET_BNE, x1, x2, x3p); + + mfbbb = (*this->zeroDistributionsF)(x1, x2, x3); + + LBMReal rhoH = 1.0; + LBMReal rhoL = 1.0 / densityRatio; + + LBMReal rhoToPhi = (rhoH - rhoL) / (phiH - phiL); + + LBMReal drho = (mfaaa + mfaac + mfaca + mfcaa + mfacc + mfcac + mfccc + mfcca) + + (mfaab + mfacb + mfcab + mfccb) + (mfaba + mfabc + mfcba + mfcbc) + (mfbaa + mfbac + mfbca + mfbcc) + + (mfabb + mfcbb) + (mfbab + mfbcb) + (mfbba + mfbbc) + mfbbb; + + LBMReal rho = rhoH + rhoToPhi * ((*phaseField)(x1, x2, x3) - phiH); + //! variable density -> TRANSFER! + //LBMReal rho = rhoH * ((*phaseField)(x1, x2, x3)) + rhoL * ((*phaseField2)(x1, x2, x3)); + + (*pressureOld)(x1, x2, x3) = (*pressure)(x1, x2, x3) + rho * c1o3 * drho; + + //(*pressure)(x1, x2, x3) = (((*phaseField)(x1, x2, x3)) + ((*phaseField2)(x1, x2, x3)) - c1) * c1o3; + ////!!!!!! relplace by pointer swap! + //(*pressureOld)(x1, x2, x3) = (*pressure)(x1, x2, x3); + } + } + } + } + + LBMReal collFactorM; + + ////Periodic Filter + for (int x3 = minX3-1; x3 <= maxX3; x3++) { + for (int x2 = minX2-1; x2 <= maxX2; x2++) { + for (int x1 = minX1-1; x1 <= maxX1; x1++) { + if (!bcArray->isSolid(x1, x2, x3) && !bcArray->isUndefined(x1, x2, x3)) { + + LBMReal sum = 0.; + + ///Version for boundaries + for (int xx = -1; xx <= 1; xx++) { + //int xxx = (xx+x1 <= maxX1) ? ((xx + x1 > 0) ? xx + x1 : maxX1) : 0; + int xxx = xx + x1; + + for (int yy = -1; yy <= 1; yy++) { + //int yyy = (yy+x2 <= maxX2) ?( (yy + x2 > 0) ? yy + x2 : maxX2) : 0; + int yyy = yy + x2; + + for (int zz = -1; zz <= 1; zz++) { + //int zzz = (zz+x3 <= maxX3) ? zzz = ((zz + x3 > 0) ? zz + x3 : maxX3 ): 0; + int zzz = zz + x3; + + if (!bcArray->isSolid(xxx, yyy, zzz) && !bcArray->isUndefined(xxx, yyy, zzz)) { + sum+= 64.0/(216.0*(c1+c3*abs(xx))* (c1 + c3 * abs(yy))* (c1 + c3 * abs(zz)))*(*pressureOld)(xxx, yyy, zzz); + } + else{ sum+= 64.0 / (216.0 * (c1 + c3 * abs(xx)) * (c1 + c3 * abs(yy)) * (c1 + c3 * abs(zz))) * (*pressureOld)(x1, x2, x3); + } + + + } + } + } + (*pressure)(x1, x2, x3) = sum; + } + } + } + } + + ////!filter + + for (int x3 = minX3; x3 < maxX3; x3++) { + for (int x2 = minX2; x2 < maxX2; x2++) { + for (int x1 = minX1; x1 < maxX1; x1++) { + if (!bcArray->isSolid(x1, x2, x3) && !bcArray->isUndefined(x1, x2, x3)) { + int x1p = x1 + 1; + int x2p = x2 + 1; + int x3p = x3 + 1; + + ////////////////////////////////////////////////////////////////////////// + // Read distributions and phase field + //////////////////////////////////////////////////////////////////////////// + ////////////////////////////////////////////////////////////////////////// + + // E N T + // c c c + ////////// + // W S B + // a a a + + // Rest ist b + + // mfxyz + // a - negative + // b - null + // c - positive + + // a b c + //-1 0 1 + + findNeighbors(phaseField, x1, x2, x3); + + LBMReal mfcbb = (*this->localDistributionsF)(D3Q27System::ET_E, x1, x2, x3); + LBMReal mfbcb = (*this->localDistributionsF)(D3Q27System::ET_N, x1, x2, x3); + LBMReal mfbbc = (*this->localDistributionsF)(D3Q27System::ET_T, x1, x2, x3); + LBMReal mfccb = (*this->localDistributionsF)(D3Q27System::ET_NE, x1, x2, x3); + LBMReal mfacb = (*this->localDistributionsF)(D3Q27System::ET_NW, x1p, x2, x3); + LBMReal mfcbc = (*this->localDistributionsF)(D3Q27System::ET_TE, x1, x2, x3); + LBMReal mfabc = (*this->localDistributionsF)(D3Q27System::ET_TW, x1p, x2, x3); + LBMReal mfbcc = (*this->localDistributionsF)(D3Q27System::ET_TN, x1, x2, x3); + LBMReal mfbac = (*this->localDistributionsF)(D3Q27System::ET_TS, x1, x2p, x3); + LBMReal mfccc = (*this->localDistributionsF)(D3Q27System::ET_TNE, x1, x2, x3); + LBMReal mfacc = (*this->localDistributionsF)(D3Q27System::ET_TNW, x1p, x2, x3); + LBMReal mfcac = (*this->localDistributionsF)(D3Q27System::ET_TSE, x1, x2p, x3); + LBMReal mfaac = (*this->localDistributionsF)(D3Q27System::ET_TSW, x1p, x2p, x3); + LBMReal mfabb = (*this->nonLocalDistributionsF)(D3Q27System::ET_W, x1p, x2, x3); + LBMReal mfbab = (*this->nonLocalDistributionsF)(D3Q27System::ET_S, x1, x2p, x3); + LBMReal mfbba = (*this->nonLocalDistributionsF)(D3Q27System::ET_B, x1, x2, x3p); + LBMReal mfaab = (*this->nonLocalDistributionsF)(D3Q27System::ET_SW, x1p, x2p, x3); + LBMReal mfcab = (*this->nonLocalDistributionsF)(D3Q27System::ET_SE, x1, x2p, x3); + LBMReal mfaba = (*this->nonLocalDistributionsF)(D3Q27System::ET_BW, x1p, x2, x3p); + LBMReal mfcba = (*this->nonLocalDistributionsF)(D3Q27System::ET_BE, x1, x2, x3p); + LBMReal mfbaa = (*this->nonLocalDistributionsF)(D3Q27System::ET_BS, x1, x2p, x3p); + LBMReal mfbca = (*this->nonLocalDistributionsF)(D3Q27System::ET_BN, x1, x2, x3p); + LBMReal mfaaa = (*this->nonLocalDistributionsF)(D3Q27System::ET_BSW, x1p, x2p, x3p); + LBMReal mfcaa = (*this->nonLocalDistributionsF)(D3Q27System::ET_BSE, x1, x2p, x3p); + LBMReal mfaca = (*this->nonLocalDistributionsF)(D3Q27System::ET_BNW, x1p, x2, x3p); + LBMReal mfcca = (*this->nonLocalDistributionsF)(D3Q27System::ET_BNE, x1, x2, x3p); + + LBMReal mfbbb = (*this->zeroDistributionsF)(x1, x2, x3); + + LBMReal rhoH = 1.0; + LBMReal rhoL = 1.0 / densityRatio; + + LBMReal rhoToPhi = (rhoH - rhoL) / (phiH - phiL); + + LBMReal dX1_phi = gradX1_phi(); + LBMReal dX2_phi = gradX2_phi(); + LBMReal dX3_phi = gradX3_phi(); + + LBMReal denom = sqrt(dX1_phi * dX1_phi + dX2_phi * dX2_phi + dX3_phi * dX3_phi) + 1e-9; + LBMReal normX1 = dX1_phi / denom; + LBMReal normX2 = dX2_phi / denom; + LBMReal normX3 = dX3_phi / denom; + + + + collFactorM = collFactorL + (collFactorL - collFactorG) * (phi[REST] - phiH) / (phiH - phiL); + + + LBMReal mu = 2 * beta * phi[REST] * (phi[REST] - 1) * (2 * phi[REST] - 1) - kappa * nabla2_phi(); + + //----------- Calculating Macroscopic Values ------------- + LBMReal rho = rhoH + rhoToPhi * (phi[REST] - phiH); + + LBMReal m0, m1, m2; + LBMReal rhoRef=c1; + + LBMReal vvx = ((((mfccc - mfaaa) + (mfcac - mfaca)) + ((mfcaa - mfacc) + (mfcca - mfaac))) + + (((mfcba - mfabc) + (mfcbc - mfaba)) + ((mfcab - mfacb) + (mfccb - mfaab))) + + (mfcbb - mfabb))/rhoRef; + LBMReal vvy = ((((mfccc - mfaaa) + (mfaca - mfcac)) + ((mfacc - mfcaa) + (mfcca - mfaac))) + + (((mfbca - mfbac) + (mfbcc - mfbaa)) + ((mfacb - mfcab) + (mfccb - mfaab))) + + (mfbcb - mfbab))/rhoRef; + LBMReal vvz = ((((mfccc - mfaaa) + (mfcac - mfaca)) + ((mfacc - mfcaa) + (mfaac - mfcca))) + + (((mfbac - mfbca) + (mfbcc - mfbaa)) + ((mfabc - mfcba) + (mfcbc - mfaba))) + + (mfbbc - mfbba))/rhoRef; + + LBMReal gradPx = 0.0; + LBMReal gradPy = 0.0; + LBMReal gradPz = 0.0; + for (int dir1 = -1; dir1 <= 1; dir1++) { + for (int dir2 = -1; dir2 <= 1; dir2++) { + int yyy = x2 + dir1; + int zzz = x3 + dir2; + if (!bcArray->isSolid(x1-1, yyy, zzz) && !bcArray->isUndefined(x1-1, yyy, zzz)) { + gradPx -= (*pressure)(x1 - 1, yyy, zzz) * c2o9 / ((c1 + c3 * abs(dir1)) * (c1 + c3 * abs(dir2))); + } + else { + gradPx -= (*pressure)(x1, x2, x3) * c2o9 / ((c1 + c3 * abs(dir1)) * (c1 + c3 * abs(dir2))); + } + if (!bcArray->isSolid(x1 + 1, yyy, zzz) && !bcArray->isUndefined(x1 + 1, yyy, zzz)) { + gradPx += (*pressure)(x1 + 1, yyy, zzz) * c2o9 / ((c1 + c3 * abs(dir1)) * (c1 + c3 * abs(dir2))); + } + else { + gradPx += (*pressure)(x1, x2, x3) * c2o9 / ((c1 + c3 * abs(dir1)) * (c1 + c3 * abs(dir2))); + } + + int xxx = x1 + dir1; + if (!bcArray->isSolid(xxx, x2-1, zzz) && !bcArray->isUndefined(xxx, x2-1, zzz)) { + gradPy -= (*pressure)(xxx, x2-1, zzz) * c2o9 / ((c1 + c3 * abs(dir1)) * (c1 + c3 * abs(dir2))); + } + else { + gradPy -= (*pressure)(x1, x2, x3) * c2o9 / ((c1 + c3 * abs(dir1)) * (c1 + c3 * abs(dir2))); + } + if (!bcArray->isSolid(xxx, x2+1, zzz) && !bcArray->isUndefined(xxx, x2+1, zzz)) { + gradPy += (*pressure)(xxx, x2+1, zzz) * c2o9 / ((c1 + c3 * abs(dir1)) * (c1 + c3 * abs(dir2))); + } + else { + gradPy += (*pressure)(x1, x2, x3) * c2o9 / ((c1 + c3 * abs(dir1)) * (c1 + c3 * abs(dir2))); + } + + yyy = x2 + dir2; + if (!bcArray->isSolid(xxx, yyy, x3-1) && !bcArray->isUndefined(xxx, yyy, x3-1)) { + gradPz -= (*pressure)(xxx, yyy, x3-1) * c2o9 / ((c1 + c3 * abs(dir1)) * (c1 + c3 * abs(dir2))); + } + else { + gradPz -= (*pressure)(x1, x2, x3) * c2o9 / ((c1 + c3 * abs(dir1)) * (c1 + c3 * abs(dir2))); + } + if (!bcArray->isSolid(xxx, yyy, x3+1) && !bcArray->isUndefined(xxx, yyy, x3+1)) { + gradPz += (*pressure)(xxx, yyy, x3+1) * c2o9 / ((c1 + c3 * abs(dir1)) * (c1 + c3 * abs(dir2))); + } + else { + gradPz += (*pressure)(x1, x2, x3) * c2o9 / ((c1 + c3 * abs(dir1)) * (c1 + c3 * abs(dir2))); + } + + } + } + + //Viscosity increase by pressure gradient + LBMReal errPhi = (((1.0 - phi[REST]) * (phi[REST]) * oneOverInterfaceScale)- denom); + //LBMReal limVis = 0.0000001*10;//0.01; + // collFactorM =collFactorM/(c1+limVis*(errPhi*errPhi)*collFactorM); + // collFactorM = (collFactorM < 1.8) ? 1.8 : collFactorM; + errPhi = errPhi * errPhi* errPhi * errPhi * errPhi * errPhi; + //collFactorM = collFactorM + (1.8 - collFactorM) * errPhi / (errPhi + limVis); + + //3.0 * ((WEIGTH[TNE] * (((phi2[TNE] - phi2[BSW]) - (phi2[BSE] - phi2[TNW])) + ((phi2[TSE] - phi2[BNW]) - (phi2[BNE] - phi2[TSW]))) + //+WEIGTH[NE] * (((phi2[TE] - phi2[BW]) - (phi2[BE] - phi2[TW])) + ((phi2[TS] - phi2[BN]) + (phi2[TN] - phi2[BS])))) + + //+WEIGTH[N] * (phi2[T] - phi2[B])); + + muRho = rho; + + forcingX1 = muForcingX1.Eval()/rho - gradPx/rho; + forcingX2 = muForcingX2.Eval()/rho - gradPy/rho; + forcingX3 = muForcingX3.Eval()/rho - gradPz/rho; + + vvx += forcingX1 * deltaT * 0.5; // X + vvy += forcingX2 * deltaT * 0.5; // Y + vvz += forcingX3 * deltaT * 0.5; // Z + + ///surface tension force + vvx += mu * dX1_phi * c1o2 / rho; + vvy += mu * dX2_phi * c1o2 / rho ; + vvz += mu * dX3_phi * c1o2 / rho; + + LBMReal vx2; + LBMReal vy2; + LBMReal vz2; + vx2 = vvx * vvx; + vy2 = vvy * vvy; + vz2 = vvz * vvz; + /////////////////////////////////////////////////////////////////////////////////////////// + LBMReal oMdrho; + + + oMdrho = mfccc + mfaaa; + m0 = mfaca + mfcac; + m1 = mfacc + mfcaa; + m2 = mfaac + mfcca; + oMdrho += m0; + m1 += m2; + oMdrho += m1; + m0 = mfbac + mfbca; + m1 = mfbaa + mfbcc; + m0 += m1; + m1 = mfabc + mfcba; + m2 = mfaba + mfcbc; + m1 += m2; + m0 += m1; + m1 = mfacb + mfcab; + m2 = mfaab + mfccb; + m1 += m2; + m0 += m1; + oMdrho += m0; + m0 = mfabb + mfcbb; + m1 = mfbab + mfbcb; + m2 = mfbba + mfbbc; + m0 += m1 + m2; + m0 += mfbbb; //hat gefehlt + oMdrho = (rhoRef - (oMdrho + m0))/rhoRef;// 12.03.21 check derivation!!!! + + //////////////////////////////////////////////////////////////////////////////////// + LBMReal wadjust; + LBMReal qudricLimit = 0.01; + //////////////////////////////////////////////////////////////////////////////////// + //Hin + //////////////////////////////////////////////////////////////////////////////////// + // mit 1/36, 1/9, 1/36, 1/9, 4/9, 1/9, 1/36, 1/9, 1/36 Konditionieren + //////////////////////////////////////////////////////////////////////////////////// + // Z - Dir + m2 = mfaaa + mfaac; + m1 = mfaac - mfaaa; + m0 = m2 + mfaab; + mfaaa = m0; + m0 += c1o36 * oMdrho; + mfaab = m1 - m0 * vvz; + mfaac = m2 - 2. * m1 * vvz + vz2 * m0; + //////////////////////////////////////////////////////////////////////////////////// + m2 = mfaba + mfabc; + m1 = mfabc - mfaba; + m0 = m2 + mfabb; + mfaba = m0; + m0 += c1o9 * oMdrho; + mfabb = m1 - m0 * vvz; + mfabc = m2 - 2. * m1 * vvz + vz2 * m0; + //////////////////////////////////////////////////////////////////////////////////// + m2 = mfaca + mfacc; + m1 = mfacc - mfaca; + m0 = m2 + mfacb; + mfaca = m0; + m0 += c1o36 * oMdrho; + mfacb = m1 - m0 * vvz; + mfacc = m2 - 2. * m1 * vvz + vz2 * m0; + //////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////////// + m2 = mfbaa + mfbac; + m1 = mfbac - mfbaa; + m0 = m2 + mfbab; + mfbaa = m0; + m0 += c1o9 * oMdrho; + mfbab = m1 - m0 * vvz; + mfbac = m2 - 2. * m1 * vvz + vz2 * m0; + //////////////////////////////////////////////////////////////////////////////////// + m2 = mfbba + mfbbc; + m1 = mfbbc - mfbba; + m0 = m2 + mfbbb; + mfbba = m0; + m0 += c4o9 * oMdrho; + mfbbb = m1 - m0 * vvz; + mfbbc = m2 - 2. * m1 * vvz + vz2 * m0; + //////////////////////////////////////////////////////////////////////////////////// + m2 = mfbca + mfbcc; + m1 = mfbcc - mfbca; + m0 = m2 + mfbcb; + mfbca = m0; + m0 += c1o9 * oMdrho; + mfbcb = m1 - m0 * vvz; + mfbcc = m2 - 2. * m1 * vvz + vz2 * m0; + //////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////////// + m2 = mfcaa + mfcac; + m1 = mfcac - mfcaa; + m0 = m2 + mfcab; + mfcaa = m0; + m0 += c1o36 * oMdrho; + mfcab = m1 - m0 * vvz; + mfcac = m2 - 2. * m1 * vvz + vz2 * m0; + //////////////////////////////////////////////////////////////////////////////////// + m2 = mfcba + mfcbc; + m1 = mfcbc - mfcba; + m0 = m2 + mfcbb; + mfcba = m0; + m0 += c1o9 * oMdrho; + mfcbb = m1 - m0 * vvz; + mfcbc = m2 - 2. * m1 * vvz + vz2 * m0; + //////////////////////////////////////////////////////////////////////////////////// + m2 = mfcca + mfccc; + m1 = mfccc - mfcca; + m0 = m2 + mfccb; + mfcca = m0; + m0 += c1o36 * oMdrho; + mfccb = m1 - m0 * vvz; + mfccc = m2 - 2. * m1 * vvz + vz2 * m0; + //////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////////// + // mit 1/6, 0, 1/18, 2/3, 0, 2/9, 1/6, 0, 1/18 Konditionieren + //////////////////////////////////////////////////////////////////////////////////// + // Y - Dir + m2 = mfaaa + mfaca; + m1 = mfaca - mfaaa; + m0 = m2 + mfaba; + mfaaa = m0; + m0 += c1o6 * oMdrho; + mfaba = m1 - m0 * vvy; + mfaca = m2 - 2. * m1 * vvy + vy2 * m0; + //////////////////////////////////////////////////////////////////////////////////// + m2 = mfaab + mfacb; + m1 = mfacb - mfaab; + m0 = m2 + mfabb; + mfaab = m0; + mfabb = m1 - m0 * vvy; + mfacb = m2 - 2. * m1 * vvy + vy2 * m0; + //////////////////////////////////////////////////////////////////////////////////// + m2 = mfaac + mfacc; + m1 = mfacc - mfaac; + m0 = m2 + mfabc; + mfaac = m0; + m0 += c1o18 * oMdrho; + mfabc = m1 - m0 * vvy; + mfacc = m2 - 2. * m1 * vvy + vy2 * m0; + //////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////////// + m2 = mfbaa + mfbca; + m1 = mfbca - mfbaa; + m0 = m2 + mfbba; + mfbaa = m0; + m0 += c2o3 * oMdrho; + mfbba = m1 - m0 * vvy; + mfbca = m2 - 2. * m1 * vvy + vy2 * m0; + //////////////////////////////////////////////////////////////////////////////////// + m2 = mfbab + mfbcb; + m1 = mfbcb - mfbab; + m0 = m2 + mfbbb; + mfbab = m0; + mfbbb = m1 - m0 * vvy; + mfbcb = m2 - 2. * m1 * vvy + vy2 * m0; + //////////////////////////////////////////////////////////////////////////////////// + m2 = mfbac + mfbcc; + m1 = mfbcc - mfbac; + m0 = m2 + mfbbc; + mfbac = m0; + m0 += c2o9 * oMdrho; + mfbbc = m1 - m0 * vvy; + mfbcc = m2 - 2. * m1 * vvy + vy2 * m0; + //////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////////// + m2 = mfcaa + mfcca; + m1 = mfcca - mfcaa; + m0 = m2 + mfcba; + mfcaa = m0; + m0 += c1o6 * oMdrho; + mfcba = m1 - m0 * vvy; + mfcca = m2 - 2. * m1 * vvy + vy2 * m0; + //////////////////////////////////////////////////////////////////////////////////// + m2 = mfcab + mfccb; + m1 = mfccb - mfcab; + m0 = m2 + mfcbb; + mfcab = m0; + mfcbb = m1 - m0 * vvy; + mfccb = m2 - 2. * m1 * vvy + vy2 * m0; + //////////////////////////////////////////////////////////////////////////////////// + m2 = mfcac + mfccc; + m1 = mfccc - mfcac; + m0 = m2 + mfcbc; + mfcac = m0; + m0 += c1o18 * oMdrho; + mfcbc = m1 - m0 * vvy; + mfccc = m2 - 2. * m1 * vvy + vy2 * m0; + //////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////////// + // mit 1, 0, 1/3, 0, 0, 0, 1/3, 0, 1/9 Konditionieren + //////////////////////////////////////////////////////////////////////////////////// + // X - Dir + m2 = mfaaa + mfcaa; + m1 = mfcaa - mfaaa; + m0 = m2 + mfbaa; + mfaaa = m0; + m0 += 1. * oMdrho; + mfbaa = m1 - m0 * vvx; + mfcaa = m2 - 2. * m1 * vvx + vx2 * m0; + //////////////////////////////////////////////////////////////////////////////////// + m2 = mfaba + mfcba; + m1 = mfcba - mfaba; + m0 = m2 + mfbba; + mfaba = m0; + mfbba = m1 - m0 * vvx; + mfcba = m2 - 2. * m1 * vvx + vx2 * m0; + //////////////////////////////////////////////////////////////////////////////////// + m2 = mfaca + mfcca; + m1 = mfcca - mfaca; + m0 = m2 + mfbca; + mfaca = m0; + m0 += c1o3 * oMdrho; + mfbca = m1 - m0 * vvx; + mfcca = m2 - 2. * m1 * vvx + vx2 * m0; + //////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////////// + m2 = mfaab + mfcab; + m1 = mfcab - mfaab; + m0 = m2 + mfbab; + mfaab = m0; + mfbab = m1 - m0 * vvx; + mfcab = m2 - 2. * m1 * vvx + vx2 * m0; + //////////////////////////////////////////////////////////////////////////////////// + m2 = mfabb + mfcbb; + m1 = mfcbb - mfabb; + m0 = m2 + mfbbb; + mfabb = m0; + mfbbb = m1 - m0 * vvx; + mfcbb = m2 - 2. * m1 * vvx + vx2 * m0; + //////////////////////////////////////////////////////////////////////////////////// + m2 = mfacb + mfccb; + m1 = mfccb - mfacb; + m0 = m2 + mfbcb; + mfacb = m0; + mfbcb = m1 - m0 * vvx; + mfccb = m2 - 2. * m1 * vvx + vx2 * m0; + //////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////////// + m2 = mfaac + mfcac; + m1 = mfcac - mfaac; + m0 = m2 + mfbac; + mfaac = m0; + m0 += c1o3 * oMdrho; + mfbac = m1 - m0 * vvx; + mfcac = m2 - 2. * m1 * vvx + vx2 * m0; + //////////////////////////////////////////////////////////////////////////////////// + m2 = mfabc + mfcbc; + m1 = mfcbc - mfabc; + m0 = m2 + mfbbc; + mfabc = m0; + mfbbc = m1 - m0 * vvx; + mfcbc = m2 - 2. * m1 * vvx + vx2 * m0; + //////////////////////////////////////////////////////////////////////////////////// + m2 = mfacc + mfccc; + m1 = mfccc - mfacc; + m0 = m2 + mfbcc; + mfacc = m0; + m0 += c1o9 * oMdrho; + mfbcc = m1 - m0 * vvx; + mfccc = m2 - 2. * m1 * vvx + vx2 * m0; + //////////////////////////////////////////////////////////////////////////////////// + // Cumulants + //////////////////////////////////////////////////////////////////////////////////// + + // mfaaa = 0.0; + LBMReal OxxPyyPzz = 1.; //omega2 or bulk viscosity + // LBMReal OxyyPxzz = 1.;//-s9;//2+s9;// + // LBMReal OxyyMxzz = 1.;//2+s9;// + LBMReal O4 = 1.; + LBMReal O5 = 1.; + LBMReal O6 = 1.; + + /////fourth order parameters; here only for test. Move out of loop! + + LBMReal OxyyPxzz = 8.0 * (collFactorM - 2.0) * (OxxPyyPzz * (3.0 * collFactorM - 1.0) - 5.0 * collFactorM) / (8.0 * (5.0 - 2.0 * collFactorM) * collFactorM + OxxPyyPzz * (8.0 + collFactorM * (9.0 * collFactorM - 26.0))); + LBMReal OxyyMxzz = 8.0 * (collFactorM - 2.0) * (collFactorM + OxxPyyPzz * (3.0 * collFactorM - 7.0)) / (OxxPyyPzz * (56.0 - 42.0 * collFactorM + 9.0 * collFactorM * collFactorM) - 8.0 * collFactorM); + // LBMReal Oxyz = 24.0 * (collFactorM - 2.0) * (4.0 * collFactorM * collFactorM + collFactorM * OxxPyyPzz * (18.0 - 13.0 * collFactorM) + OxxPyyPzz * OxxPyyPzz * (2.0 + collFactorM * (6.0 * collFactorM - 11.0))) / (16.0 * collFactorM * collFactorM * (collFactorM - 6.0) - 2.0 * collFactorM * OxxPyyPzz * (216.0 + 5.0 * collFactorM * (9.0 * collFactorM - 46.0)) + OxxPyyPzz * OxxPyyPzz * (collFactorM * (3.0 * collFactorM - 10.0) * (15.0 * collFactorM - 28.0) - 48.0)); + LBMReal A = (4.0 * collFactorM * collFactorM + 2.0 * collFactorM * OxxPyyPzz * (collFactorM - 6.0) + OxxPyyPzz * OxxPyyPzz * (collFactorM * (10.0 - 3.0 * collFactorM) - 4.0)) / ((collFactorM - OxxPyyPzz) * (OxxPyyPzz * (2.0 + 3.0 * collFactorM) - 8.0 * collFactorM)); + //FIXME: warning C4459: declaration of 'B' hides global declaration (message : see declaration of 'D3Q27System::B' ) + LBMReal BB = (4.0 * collFactorM * OxxPyyPzz * (9.0 * collFactorM - 16.0) - 4.0 * collFactorM * collFactorM - 2.0 * OxxPyyPzz * OxxPyyPzz * (2.0 + 9.0 * collFactorM * (collFactorM - 2.0))) / (3.0 * (collFactorM - OxxPyyPzz) * (OxxPyyPzz * (2.0 + 3.0 * collFactorM) - 8.0 * collFactorM)); + + + //Cum 4. + //LBMReal CUMcbb = mfcbb - ((mfcaa + c1o3 * oMdrho) * mfabb + 2. * mfbba * mfbab); // till 18.05.2015 + //LBMReal CUMbcb = mfbcb - ((mfaca + c1o3 * oMdrho) * mfbab + 2. * mfbba * mfabb); // till 18.05.2015 + //LBMReal CUMbbc = mfbbc - ((mfaac + c1o3 * oMdrho) * mfbba + 2. * mfbab * mfabb); // till 18.05.2015 + + LBMReal CUMcbb = mfcbb - ((mfcaa + c1o3) * mfabb + 2. * mfbba * mfbab); + LBMReal CUMbcb = mfbcb - ((mfaca + c1o3) * mfbab + 2. * mfbba * mfabb); + LBMReal CUMbbc = mfbbc - ((mfaac + c1o3) * mfbba + 2. * mfbab * mfabb); + + LBMReal CUMcca = mfcca - ((mfcaa * mfaca + 2. * mfbba * mfbba) + c1o3 * (mfcaa + mfaca) * oMdrho + c1o9 * (oMdrho - c1) * oMdrho); + LBMReal CUMcac = mfcac - ((mfcaa * mfaac + 2. * mfbab * mfbab) + c1o3 * (mfcaa + mfaac) * oMdrho + c1o9 * (oMdrho - c1) * oMdrho); + LBMReal CUMacc = mfacc - ((mfaac * mfaca + 2. * mfabb * mfabb) + c1o3 * (mfaac + mfaca) * oMdrho + c1o9 * (oMdrho - c1) * oMdrho); + + //Cum 5. + LBMReal CUMbcc = mfbcc - (mfaac * mfbca + mfaca * mfbac + 4. * mfabb * mfbbb + 2. * (mfbab * mfacb + mfbba * mfabc)) - c1o3 * (mfbca + mfbac) * oMdrho; + LBMReal CUMcbc = mfcbc - (mfaac * mfcba + mfcaa * mfabc + 4. * mfbab * mfbbb + 2. * (mfabb * mfcab + mfbba * mfbac)) - c1o3 * (mfcba + mfabc) * oMdrho; + LBMReal CUMccb = mfccb - (mfcaa * mfacb + mfaca * mfcab + 4. * mfbba * mfbbb + 2. * (mfbab * mfbca + mfabb * mfcba)) - c1o3 * (mfacb + mfcab) * oMdrho; + + //Cum 6. + LBMReal CUMccc = mfccc + ((-4. * mfbbb * mfbbb + - (mfcaa * mfacc + mfaca * mfcac + mfaac * mfcca) + - 4. * (mfabb * mfcbb + mfbab * mfbcb + mfbba * mfbbc) + - 2. * (mfbca * mfbac + mfcba * mfabc + mfcab * mfacb)) + + (4. * (mfbab * mfbab * mfaca + mfabb * mfabb * mfcaa + mfbba * mfbba * mfaac) + + 2. * (mfcaa * mfaca * mfaac) + + 16. * mfbba * mfbab * mfabb) + - c1o3 * (mfacc + mfcac + mfcca) * oMdrho - c1o9 * oMdrho * oMdrho + - c1o9 * (mfcaa + mfaca + mfaac) * oMdrho * (1. - 2. * oMdrho) - c1o27 * oMdrho * oMdrho * (-2. * oMdrho) + + (2. * (mfbab * mfbab + mfabb * mfabb + mfbba * mfbba) + + (mfaac * mfaca + mfaac * mfcaa + mfaca * mfcaa)) * c2o3 * oMdrho) + c1o27 * oMdrho; + + //2. + // linear combinations + LBMReal mxxPyyPzz = mfcaa + mfaca + mfaac; + + // LBMReal mfaaaS = (mfaaa * (-4 - 3 * OxxPyyPzz * (-1 + rho)) + 6 * mxxPyyPzz * OxxPyyPzz * (-1 + rho)) / (-4 + 3 * OxxPyyPzz * (-1 + rho)); + mxxPyyPzz -= mfaaa ;//12.03.21 shifted by mfaaa + //mxxPyyPzz-=(mfaaa+mfaaaS)*c1o2;//12.03.21 shifted by mfaaa + LBMReal mxxMyy = mfcaa - mfaca; + LBMReal mxxMzz = mfcaa - mfaac; + + LBMReal dxux = -c1o2 * collFactorM * (mxxMyy + mxxMzz) + c1o2 * OxxPyyPzz * (/*mfaaa*/ -mxxPyyPzz); + LBMReal dyuy = dxux + collFactorM * c3o2 * mxxMyy; + LBMReal dzuz = dxux + collFactorM * c3o2 * mxxMzz; + + LBMReal Dxy = -three * collFactorM * mfbba; + LBMReal Dxz = -three * collFactorM * mfbab; + LBMReal Dyz = -three * collFactorM * mfabb; + + //relax + mxxPyyPzz += OxxPyyPzz * (/*mfaaa*/ - mxxPyyPzz) - 3. * (1. - c1o2 * OxxPyyPzz) * (vx2 * dxux + vy2 * dyuy + vz2 * dzuz); + mxxMyy += collFactorM * (-mxxMyy) - 3. * (1. - c1o2 * collFactorM) * (vx2 * dxux - vy2 * dyuy); + mxxMzz += collFactorM * (-mxxMzz) - 3. * (1. - c1o2 * collFactorM) * (vx2 * dxux - vz2 * dzuz); + + mfabb += collFactorM * (-mfabb); + mfbab += collFactorM * (-mfbab); + mfbba += collFactorM * (-mfbba); + + ////updated pressure + //mfaaa += (dX1_phi * vvx + dX2_phi * vvy + dX3_phi * vvz) * correctionScaling; + mfaaa = 0.0; // Pressure elimination as in standard velocity model + // mfaaa += (rho - c1) * (dxux + dyuy + dzuz); + + mxxPyyPzz += mfaaa; // 12.03.21 shifted by mfaaa + + // mxxPyyPzz += (mfaaa + mfaaaS) * c1o2; + //mfaaa = mfaaaS; + // linear combinations back + mfcaa = c1o3 * (mxxMyy + mxxMzz + mxxPyyPzz); + mfaca = c1o3 * (-2. * mxxMyy + mxxMzz + mxxPyyPzz); + mfaac = c1o3 * (mxxMyy - 2. * mxxMzz + mxxPyyPzz); + + //3. + // linear combinations + LBMReal mxxyPyzz = mfcba + mfabc; + LBMReal mxxyMyzz = mfcba - mfabc; + + LBMReal mxxzPyyz = mfcab + mfacb; + LBMReal mxxzMyyz = mfcab - mfacb; + + LBMReal mxyyPxzz = mfbca + mfbac; + LBMReal mxyyMxzz = mfbca - mfbac; + + //relax + wadjust = OxyyMxzz + (1. - OxyyMxzz) * fabs(mfbbb) / (fabs(mfbbb) + qudricLimit); + mfbbb += wadjust * (-mfbbb); + wadjust = OxyyPxzz + (1. - OxyyPxzz) * fabs(mxxyPyzz) / (fabs(mxxyPyzz) + qudricLimit); + mxxyPyzz += wadjust * (-mxxyPyzz); + wadjust = OxyyMxzz + (1. - OxyyMxzz) * fabs(mxxyMyzz) / (fabs(mxxyMyzz) + qudricLimit); + mxxyMyzz += wadjust * (-mxxyMyzz); + wadjust = OxyyPxzz + (1. - OxyyPxzz) * fabs(mxxzPyyz) / (fabs(mxxzPyyz) + qudricLimit); + mxxzPyyz += wadjust * (-mxxzPyyz); + wadjust = OxyyMxzz + (1. - OxyyMxzz) * fabs(mxxzMyyz) / (fabs(mxxzMyyz) + qudricLimit); + mxxzMyyz += wadjust * (-mxxzMyyz); + wadjust = OxyyPxzz + (1. - OxyyPxzz) * fabs(mxyyPxzz) / (fabs(mxyyPxzz) + qudricLimit); + mxyyPxzz += wadjust * (-mxyyPxzz); + wadjust = OxyyMxzz + (1. - OxyyMxzz) * fabs(mxyyMxzz) / (fabs(mxyyMxzz) + qudricLimit); + mxyyMxzz += wadjust * (-mxyyMxzz); + + // linear combinations back + 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. + CUMacc = -O4 * (one / collFactorM - c1o2) * (dyuy + dzuz) * c2o3 * A + (one - O4) * (CUMacc); + CUMcac = -O4 * (one / collFactorM - c1o2) * (dxux + dzuz) * c2o3 * A + (one - O4) * (CUMcac); + CUMcca = -O4 * (one / collFactorM - c1o2) * (dyuy + dxux) * c2o3 * A + (one - O4) * (CUMcca); + CUMbbc = -O4 * (one / collFactorM - c1o2) * Dxy * c1o3 * BB + (one - O4) * (CUMbbc); + CUMbcb = -O4 * (one / collFactorM - c1o2) * Dxz * c1o3 * BB + (one - O4) * (CUMbcb); + CUMcbb = -O4 * (one / collFactorM - c1o2) * Dyz * c1o3 * BB + (one - O4) * (CUMcbb); + + //5. + CUMbcc += O5 * (-CUMbcc); + CUMcbc += O5 * (-CUMcbc); + CUMccb += O5 * (-CUMccb); + + //6. + CUMccc += O6 * (-CUMccc); + + //back cumulants to central moments + //4. + //mfcbb = CUMcbb + ((mfcaa + c1o3 * oMdrho) * mfabb + 2. * mfbba * mfbab); // till 18.05.2015 + //mfbcb = CUMbcb + ((mfaca + c1o3 * oMdrho) * mfbab + 2. * mfbba * mfabb); // till 18.05.2015 + //mfbbc = CUMbbc + ((mfaac + c1o3 * oMdrho) * mfbba + 2. * mfbab * mfabb); // till 18.05.2015 + + mfcbb = CUMcbb + ((mfcaa + c1o3) * mfabb + 2. * mfbba * mfbab); + mfbcb = CUMbcb + ((mfaca + c1o3) * mfbab + 2. * mfbba * mfabb); + mfbbc = CUMbbc + ((mfaac + c1o3) * mfbba + 2. * mfbab * mfabb); + + mfcca = CUMcca + (mfcaa * mfaca + 2. * mfbba * mfbba) + c1o3 * (mfcaa + mfaca) * oMdrho + c1o9 * (oMdrho - c1) * oMdrho; + mfcac = CUMcac + (mfcaa * mfaac + 2. * mfbab * mfbab) + c1o3 * (mfcaa + mfaac) * oMdrho + c1o9 * (oMdrho - c1) * oMdrho; + mfacc = CUMacc + (mfaac * mfaca + 2. * mfabb * mfabb) + c1o3 * (mfaac + mfaca) * oMdrho + c1o9 * (oMdrho - c1) * oMdrho; + + //5. + mfbcc = CUMbcc + (mfaac * mfbca + mfaca * mfbac + 4. * mfabb * mfbbb + 2. * (mfbab * mfacb + mfbba * mfabc)) + c1o3 * (mfbca + mfbac) * oMdrho; + mfcbc = CUMcbc + (mfaac * mfcba + mfcaa * mfabc + 4. * mfbab * mfbbb + 2. * (mfabb * mfcab + mfbba * mfbac)) + c1o3 * (mfcba + mfabc) * oMdrho; + mfccb = CUMccb + (mfcaa * mfacb + mfaca * mfcab + 4. * mfbba * mfbbb + 2. * (mfbab * mfbca + mfabb * mfcba)) + c1o3 * (mfacb + mfcab) * oMdrho; + + //6. + mfccc = CUMccc - ((-4. * mfbbb * mfbbb + - (mfcaa * mfacc + mfaca * mfcac + mfaac * mfcca) + - 4. * (mfabb * mfcbb + mfbac * mfbca + mfbba * mfbbc) + - 2. * (mfbca * mfbac + mfcba * mfabc + mfcab * mfacb)) + + (4. * (mfbab * mfbab * mfaca + mfabb * mfabb * mfcaa + mfbba * mfbba * mfaac) + + 2. * (mfcaa * mfaca * mfaac) + + 16. * mfbba * mfbab * mfabb) + - c1o3 * (mfacc + mfcac + mfcca) * oMdrho - c1o9 * oMdrho * oMdrho + - c1o9 * (mfcaa + mfaca + mfaac) * oMdrho * (1. - 2. * oMdrho) - c1o27 * oMdrho * oMdrho * (-2. * oMdrho) + + (2. * (mfbab * mfbab + mfabb * mfabb + mfbba * mfbba) + + (mfaac * mfaca + mfaac * mfcaa + mfaca * mfcaa)) * c2o3 * oMdrho) - c1o27 * oMdrho; + + + //////// + + + //////////////////////////////////////////////////////////////////////////////////// + //forcing + mfbaa = -mfbaa; + mfaba = -mfaba; + mfaab = -mfaab; + ////////////////////////////////////////////////////////////////////////////////////// + mfbaa += c1o3 * (c1 / collFactorM - c1o2) * rhoToPhi * (2 * dxux * dX1_phi + Dxy * dX2_phi + Dxz * dX3_phi) / (rho); + mfaba += c1o3 * (c1 / collFactorM - c1o2) * rhoToPhi * (Dxy * dX1_phi + 2 * dyuy * dX2_phi + Dyz * dX3_phi) / (rho); + mfaab += c1o3 * (c1 / collFactorM - c1o2) * rhoToPhi * (Dxz * dX1_phi + Dyz * dX2_phi + 2 * dyuy * dX3_phi) / (rho); + //////////////////////////////////////////////////////////////////////////////////// + //back + //////////////////////////////////////////////////////////////////////////////////// + //mit 1, 0, 1/3, 0, 0, 0, 1/3, 0, 1/9 Konditionieren + //////////////////////////////////////////////////////////////////////////////////// + // Z - Dir + m0 = mfaac * c1o2 + mfaab * (vvz - c1o2) + (mfaaa + 1. * oMdrho) * (vz2 - vvz) * c1o2; + m1 = -mfaac - 2. * mfaab * vvz + mfaaa * (1. - vz2) - 1. * oMdrho * vz2; + m2 = mfaac * c1o2 + mfaab * (vvz + c1o2) + (mfaaa + 1. * oMdrho) * (vz2 + vvz) * c1o2; + mfaaa = m0; + mfaab = m1; + mfaac = m2; + //////////////////////////////////////////////////////////////////////////////////// + m0 = mfabc * c1o2 + mfabb * (vvz - c1o2) + mfaba * (vz2 - vvz) * c1o2; + m1 = -mfabc - 2. * mfabb * vvz + mfaba * (1. - vz2); + m2 = mfabc * c1o2 + mfabb * (vvz + c1o2) + mfaba * (vz2 + vvz) * c1o2; + mfaba = m0; + mfabb = m1; + mfabc = m2; + //////////////////////////////////////////////////////////////////////////////////// + m0 = mfacc * c1o2 + mfacb * (vvz - c1o2) + (mfaca + c1o3 * oMdrho) * (vz2 - vvz) * c1o2; + m1 = -mfacc - 2. * mfacb * vvz + mfaca * (1. - vz2) - c1o3 * oMdrho * vz2; + m2 = mfacc * c1o2 + mfacb * (vvz + c1o2) + (mfaca + c1o3 * oMdrho) * (vz2 + vvz) * c1o2; + mfaca = m0; + mfacb = m1; + mfacc = m2; + //////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////////// + m0 = mfbac * c1o2 + mfbab * (vvz - c1o2) + mfbaa * (vz2 - vvz) * c1o2; + m1 = -mfbac - 2. * mfbab * vvz + mfbaa * (1. - vz2); + m2 = mfbac * c1o2 + mfbab * (vvz + c1o2) + mfbaa * (vz2 + vvz) * c1o2; + mfbaa = m0; + mfbab = m1; + mfbac = m2; + /////////b////////////////////////////////////////////////////////////////////////// + m0 = mfbbc * c1o2 + mfbbb * (vvz - c1o2) + mfbba * (vz2 - vvz) * c1o2; + m1 = -mfbbc - 2. * mfbbb * vvz + mfbba * (1. - vz2); + m2 = mfbbc * c1o2 + mfbbb * (vvz + c1o2) + mfbba * (vz2 + vvz) * c1o2; + mfbba = m0; + mfbbb = m1; + mfbbc = m2; + /////////b////////////////////////////////////////////////////////////////////////// + m0 = mfbcc * c1o2 + mfbcb * (vvz - c1o2) + mfbca * (vz2 - vvz) * c1o2; + m1 = -mfbcc - 2. * mfbcb * vvz + mfbca * (1. - vz2); + m2 = mfbcc * c1o2 + mfbcb * (vvz + c1o2) + mfbca * (vz2 + vvz) * c1o2; + mfbca = m0; + mfbcb = m1; + mfbcc = m2; + //////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////////// + m0 = mfcac * c1o2 + mfcab * (vvz - c1o2) + (mfcaa + c1o3 * oMdrho) * (vz2 - vvz) * c1o2; + m1 = -mfcac - 2. * mfcab * vvz + mfcaa * (1. - vz2) - c1o3 * oMdrho * vz2; + m2 = mfcac * c1o2 + mfcab * (vvz + c1o2) + (mfcaa + c1o3 * oMdrho) * (vz2 + vvz) * c1o2; + mfcaa = m0; + mfcab = m1; + mfcac = m2; + /////////c////////////////////////////////////////////////////////////////////////// + m0 = mfcbc * c1o2 + mfcbb * (vvz - c1o2) + mfcba * (vz2 - vvz) * c1o2; + m1 = -mfcbc - 2. * mfcbb * vvz + mfcba * (1. - vz2); + m2 = mfcbc * c1o2 + mfcbb * (vvz + c1o2) + mfcba * (vz2 + vvz) * c1o2; + mfcba = m0; + mfcbb = m1; + mfcbc = m2; + /////////c////////////////////////////////////////////////////////////////////////// + m0 = mfccc * c1o2 + mfccb * (vvz - c1o2) + (mfcca + c1o9 * oMdrho) * (vz2 - vvz) * c1o2; + m1 = -mfccc - 2. * mfccb * vvz + mfcca * (1. - vz2) - c1o9 * oMdrho * vz2; + m2 = mfccc * c1o2 + mfccb * (vvz + c1o2) + (mfcca + c1o9 * oMdrho) * (vz2 + vvz) * c1o2; + mfcca = m0; + mfccb = m1; + mfccc = m2; + //////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////////// + //mit 1/6, 2/3, 1/6, 0, 0, 0, 1/18, 2/9, 1/18 Konditionieren + //////////////////////////////////////////////////////////////////////////////////// + // Y - Dir + m0 = mfaca * c1o2 + mfaba * (vvy - c1o2) + (mfaaa + c1o6 * oMdrho) * (vy2 - vvy) * c1o2; + m1 = -mfaca - 2. * mfaba * vvy + mfaaa * (1. - vy2) - c1o6 * oMdrho * vy2; + m2 = mfaca * c1o2 + mfaba * (vvy + c1o2) + (mfaaa + c1o6 * oMdrho) * (vy2 + vvy) * c1o2; + mfaaa = m0; + mfaba = m1; + mfaca = m2; + //////////////////////////////////////////////////////////////////////////////////// + m0 = mfacb * c1o2 + mfabb * (vvy - c1o2) + (mfaab + c2o3 * oMdrho) * (vy2 - vvy) * c1o2; + m1 = -mfacb - 2. * mfabb * vvy + mfaab * (1. - vy2) - c2o3 * oMdrho * vy2; + m2 = mfacb * c1o2 + mfabb * (vvy + c1o2) + (mfaab + c2o3 * oMdrho) * (vy2 + vvy) * c1o2; + mfaab = m0; + mfabb = m1; + mfacb = m2; + //////////////////////////////////////////////////////////////////////////////////// + m0 = mfacc * c1o2 + mfabc * (vvy - c1o2) + (mfaac + c1o6 * oMdrho) * (vy2 - vvy) * c1o2; + m1 = -mfacc - 2. * mfabc * vvy + mfaac * (1. - vy2) - c1o6 * oMdrho * vy2; + m2 = mfacc * c1o2 + mfabc * (vvy + c1o2) + (mfaac + c1o6 * oMdrho) * (vy2 + vvy) * c1o2; + mfaac = m0; + mfabc = m1; + mfacc = m2; + //////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////////// + m0 = mfbca * c1o2 + mfbba * (vvy - c1o2) + mfbaa * (vy2 - vvy) * c1o2; + m1 = -mfbca - 2. * mfbba * vvy + mfbaa * (1. - vy2); + m2 = mfbca * c1o2 + mfbba * (vvy + c1o2) + mfbaa * (vy2 + vvy) * c1o2; + mfbaa = m0; + mfbba = m1; + mfbca = m2; + /////////b////////////////////////////////////////////////////////////////////////// + m0 = mfbcb * c1o2 + mfbbb * (vvy - c1o2) + mfbab * (vy2 - vvy) * c1o2; + m1 = -mfbcb - 2. * mfbbb * vvy + mfbab * (1. - vy2); + m2 = mfbcb * c1o2 + mfbbb * (vvy + c1o2) + mfbab * (vy2 + vvy) * c1o2; + mfbab = m0; + mfbbb = m1; + mfbcb = m2; + /////////b////////////////////////////////////////////////////////////////////////// + m0 = mfbcc * c1o2 + mfbbc * (vvy - c1o2) + mfbac * (vy2 - vvy) * c1o2; + m1 = -mfbcc - 2. * mfbbc * vvy + mfbac * (1. - vy2); + m2 = mfbcc * c1o2 + mfbbc * (vvy + c1o2) + mfbac * (vy2 + vvy) * c1o2; + mfbac = m0; + mfbbc = m1; + mfbcc = m2; + //////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////////// + m0 = mfcca * c1o2 + mfcba * (vvy - c1o2) + (mfcaa + c1o18 * oMdrho) * (vy2 - vvy) * c1o2; + m1 = -mfcca - 2. * mfcba * vvy + mfcaa * (1. - vy2) - c1o18 * oMdrho * vy2; + m2 = mfcca * c1o2 + mfcba * (vvy + c1o2) + (mfcaa + c1o18 * oMdrho) * (vy2 + vvy) * c1o2; + mfcaa = m0; + mfcba = m1; + mfcca = m2; + /////////c////////////////////////////////////////////////////////////////////////// + m0 = mfccb * c1o2 + mfcbb * (vvy - c1o2) + (mfcab + c2o9 * oMdrho) * (vy2 - vvy) * c1o2; + m1 = -mfccb - 2. * mfcbb * vvy + mfcab * (1. - vy2) - c2o9 * oMdrho * vy2; + m2 = mfccb * c1o2 + mfcbb * (vvy + c1o2) + (mfcab + c2o9 * oMdrho) * (vy2 + vvy) * c1o2; + mfcab = m0; + mfcbb = m1; + mfccb = m2; + /////////c////////////////////////////////////////////////////////////////////////// + m0 = mfccc * c1o2 + mfcbc * (vvy - c1o2) + (mfcac + c1o18 * oMdrho) * (vy2 - vvy) * c1o2; + m1 = -mfccc - 2. * mfcbc * vvy + mfcac * (1. - vy2) - c1o18 * oMdrho * vy2; + m2 = mfccc * c1o2 + mfcbc * (vvy + c1o2) + (mfcac + c1o18 * oMdrho) * (vy2 + vvy) * c1o2; + mfcac = m0; + mfcbc = m1; + mfccc = m2; + //////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////////// + //mit 1/36, 1/9, 1/36, 1/9, 4/9, 1/9, 1/36, 1/9, 1/36 Konditionieren + //////////////////////////////////////////////////////////////////////////////////// + // X - Dir + m0 = mfcaa * c1o2 + mfbaa * (vvx - c1o2) + (mfaaa + c1o36 * oMdrho) * (vx2 - vvx) * c1o2; + m1 = -mfcaa - 2. * mfbaa * vvx + mfaaa * (1. - vx2) - c1o36 * oMdrho * vx2; + m2 = mfcaa * c1o2 + mfbaa * (vvx + c1o2) + (mfaaa + c1o36 * oMdrho) * (vx2 + vvx) * c1o2; + mfaaa = m0; + mfbaa = m1; + mfcaa = m2; + //////////////////////////////////////////////////////////////////////////////////// + m0 = mfcba * c1o2 + mfbba * (vvx - c1o2) + (mfaba + c1o9 * oMdrho) * (vx2 - vvx) * c1o2; + m1 = -mfcba - 2. * mfbba * vvx + mfaba * (1. - vx2) - c1o9 * oMdrho * vx2; + m2 = mfcba * c1o2 + mfbba * (vvx + c1o2) + (mfaba + c1o9 * oMdrho) * (vx2 + vvx) * c1o2; + mfaba = m0; + mfbba = m1; + mfcba = m2; + //////////////////////////////////////////////////////////////////////////////////// + m0 = mfcca * c1o2 + mfbca * (vvx - c1o2) + (mfaca + c1o36 * oMdrho) * (vx2 - vvx) * c1o2; + m1 = -mfcca - 2. * mfbca * vvx + mfaca * (1. - vx2) - c1o36 * oMdrho * vx2; + m2 = mfcca * c1o2 + mfbca * (vvx + c1o2) + (mfaca + c1o36 * oMdrho) * (vx2 + vvx) * c1o2; + mfaca = m0; + mfbca = m1; + mfcca = m2; + //////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////////// + m0 = mfcab * c1o2 + mfbab * (vvx - c1o2) + (mfaab + c1o9 * oMdrho) * (vx2 - vvx) * c1o2; + m1 = -mfcab - 2. * mfbab * vvx + mfaab * (1. - vx2) - c1o9 * oMdrho * vx2; + m2 = mfcab * c1o2 + mfbab * (vvx + c1o2) + (mfaab + c1o9 * oMdrho) * (vx2 + vvx) * c1o2; + mfaab = m0; + mfbab = m1; + mfcab = m2; + ///////////b//////////////////////////////////////////////////////////////////////// + m0 = mfcbb * c1o2 + mfbbb * (vvx - c1o2) + (mfabb + c4o9 * oMdrho) * (vx2 - vvx) * c1o2; + m1 = -mfcbb - 2. * mfbbb * vvx + mfabb * (1. - vx2) - c4o9 * oMdrho * vx2; + m2 = mfcbb * c1o2 + mfbbb * (vvx + c1o2) + (mfabb + c4o9 * oMdrho) * (vx2 + vvx) * c1o2; + mfabb = m0; + mfbbb = m1; + mfcbb = m2; + ///////////b//////////////////////////////////////////////////////////////////////// + m0 = mfccb * c1o2 + mfbcb * (vvx - c1o2) + (mfacb + c1o9 * oMdrho) * (vx2 - vvx) * c1o2; + m1 = -mfccb - 2. * mfbcb * vvx + mfacb * (1. - vx2) - c1o9 * oMdrho * vx2; + m2 = mfccb * c1o2 + mfbcb * (vvx + c1o2) + (mfacb + c1o9 * oMdrho) * (vx2 + vvx) * c1o2; + mfacb = m0; + mfbcb = m1; + mfccb = m2; + //////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////////// + m0 = mfcac * c1o2 + mfbac * (vvx - c1o2) + (mfaac + c1o36 * oMdrho) * (vx2 - vvx) * c1o2; + m1 = -mfcac - 2. * mfbac * vvx + mfaac * (1. - vx2) - c1o36 * oMdrho * vx2; + m2 = mfcac * c1o2 + mfbac * (vvx + c1o2) + (mfaac + c1o36 * oMdrho) * (vx2 + vvx) * c1o2; + mfaac = m0; + mfbac = m1; + mfcac = m2; + ///////////c//////////////////////////////////////////////////////////////////////// + m0 = mfcbc * c1o2 + mfbbc * (vvx - c1o2) + (mfabc + c1o9 * oMdrho) * (vx2 - vvx) * c1o2; + m1 = -mfcbc - 2. * mfbbc * vvx + mfabc * (1. - vx2) - c1o9 * oMdrho * vx2; + m2 = mfcbc * c1o2 + mfbbc * (vvx + c1o2) + (mfabc + c1o9 * oMdrho) * (vx2 + vvx) * c1o2; + mfabc = m0; + mfbbc = m1; + mfcbc = m2; + ///////////c//////////////////////////////////////////////////////////////////////// + m0 = mfccc * c1o2 + mfbcc * (vvx - c1o2) + (mfacc + c1o36 * oMdrho) * (vx2 - vvx) * c1o2; + m1 = -mfccc - 2. * mfbcc * vvx + mfacc * (1. - vx2) - c1o36 * oMdrho * vx2; + m2 = mfccc * c1o2 + mfbcc * (vvx + c1o2) + (mfacc + c1o36 * oMdrho) * (vx2 + vvx) * c1o2; + mfacc = m0; + mfbcc = m1; + mfccc = m2; + + ////////////////////////////////////////////////////////////////////////// + //proof correctness + ////////////////////////////////////////////////////////////////////////// + //#ifdef PROOF_CORRECTNESS + LBMReal rho_post = (mfaaa + mfaac + mfaca + mfcaa + mfacc + mfcac + mfccc + mfcca) + + (mfaab + mfacb + mfcab + mfccb) + (mfaba + mfabc + mfcba + mfcbc) + (mfbaa + mfbac + mfbca + mfbcc) + + (mfabb + mfcbb) + (mfbab + mfbcb) + (mfbba + mfbbc) + mfbbb; + // //LBMReal dif = fabs(drho - rho_post); + // LBMReal dif = drho + (dX1_phi * vvx + dX2_phi * vvy + dX3_phi * vvz) * correctionScaling - rho_post; + //#ifdef SINGLEPRECISION + // if (dif > 10.0E-7 || dif < -10.0E-7) + //#else + // if (dif > 10.0E-15 || dif < -10.0E-15) + //#endif + // { + // UB_THROW(UbException(UB_EXARGS, "drho=" + UbSystem::toString(drho) + ", rho_post=" + UbSystem::toString(rho_post) + // + " dif=" + UbSystem::toString(dif) + // + " drho is not correct for node " + UbSystem::toString(x1) + "," + UbSystem::toString(x2) + "," + UbSystem::toString(x3))); + // //UBLOG(logERROR,"LBMKernelETD3Q27CCLB::collideAll(): drho is not correct for node "+UbSystem::toString(x1)+","+UbSystem::toString(x2)+","+UbSystem::toString(x3)); + // //exit(EXIT_FAILURE); + // } + //#endif + + if (UbMath::isNaN(rho_post) || UbMath::isInfinity(rho_post)) + UB_THROW(UbException( + UB_EXARGS, "rho_post is not a number (nan or -1.#IND) or infinity number -1.#INF, node=" + UbSystem::toString(x1) + "," + + UbSystem::toString(x2) + "," + UbSystem::toString(x3))); + + ////////////////////////////////////////////////////////////////////////// + //write distribution + ////////////////////////////////////////////////////////////////////////// + (*this->localDistributionsF)(D3Q27System::ET_E, x1, x2, x3) = mfabb ;//* rho * c1o3; + (*this->localDistributionsF)(D3Q27System::ET_N, x1, x2, x3) = mfbab ;//* rho * c1o3; + (*this->localDistributionsF)(D3Q27System::ET_T, x1, x2, x3) = mfbba ;//* rho * c1o3; + (*this->localDistributionsF)(D3Q27System::ET_NE, x1, x2, x3) = mfaab ;//* rho * c1o3; + (*this->localDistributionsF)(D3Q27System::ET_NW, x1p, x2, x3) = mfcab ;//* rho * c1o3; + (*this->localDistributionsF)(D3Q27System::ET_TE, x1, x2, x3) = mfaba ;//* rho * c1o3; + (*this->localDistributionsF)(D3Q27System::ET_TW, x1p, x2, x3) = mfcba ;//* rho * c1o3; + (*this->localDistributionsF)(D3Q27System::ET_TN, x1, x2, x3) = mfbaa ;//* rho * c1o3; + (*this->localDistributionsF)(D3Q27System::ET_TS, x1, x2p, x3) = mfbca ;//* rho * c1o3; + (*this->localDistributionsF)(D3Q27System::ET_TNE, x1, x2, x3) = mfaaa ;//* rho * c1o3; + (*this->localDistributionsF)(D3Q27System::ET_TNW, x1p, x2, x3) = mfcaa ;//* rho * c1o3; + (*this->localDistributionsF)(D3Q27System::ET_TSE, x1, x2p, x3) = mfaca ;//* rho * c1o3; + (*this->localDistributionsF)(D3Q27System::ET_TSW, x1p, x2p, x3) = mfcca ;//* rho * c1o3; + (*this->nonLocalDistributionsF)(D3Q27System::ET_W, x1p, x2, x3) = mfcbb ;//* rho * c1o3; + (*this->nonLocalDistributionsF)(D3Q27System::ET_S, x1, x2p, x3) = mfbcb ;//* rho * c1o3; + (*this->nonLocalDistributionsF)(D3Q27System::ET_B, x1, x2, x3p) = mfbbc ;//* rho * c1o3; + (*this->nonLocalDistributionsF)(D3Q27System::ET_SW, x1p, x2p, x3) = mfccb ;//* rho * c1o3; + (*this->nonLocalDistributionsF)(D3Q27System::ET_SE, x1, x2p, x3) = mfacb ;//* rho * c1o3; + (*this->nonLocalDistributionsF)(D3Q27System::ET_BW, x1p, x2, x3p) = mfcbc ;//* rho * c1o3; + (*this->nonLocalDistributionsF)(D3Q27System::ET_BE, x1, x2, x3p) = mfabc ;//* rho * c1o3; + (*this->nonLocalDistributionsF)(D3Q27System::ET_BS, x1, x2p, x3p) = mfbcc ;//* rho * c1o3; + (*this->nonLocalDistributionsF)(D3Q27System::ET_BN, x1, x2, x3p) = mfbac ;//* rho * c1o3; + (*this->nonLocalDistributionsF)(D3Q27System::ET_BSW, x1p, x2p, x3p) = mfccc ;//* rho * c1o3; + (*this->nonLocalDistributionsF)(D3Q27System::ET_BSE, x1, x2p, x3p) = mfacc ;//* rho * c1o3; + (*this->nonLocalDistributionsF)(D3Q27System::ET_BNW, x1p, x2, x3p) = mfcac ;//* rho * c1o3; + (*this->nonLocalDistributionsF)(D3Q27System::ET_BNE, x1, x2, x3p) = mfaac ;//* rho * c1o3; + + (*this->zeroDistributionsF)(x1, x2, x3) = mfbbb;// *rho* c1o3; + // !Old Kernel +///////////////////// P H A S E - F I E L D S O L V E R +//////////////////////////////////////////// +/////CUMULANT PHASE-FIELD + LBMReal omegaD =1.0/( 3.0 * mob + 0.5); + { + mfcbb = (*this->localDistributionsH1)(D3Q27System::ET_E, x1, x2, x3); + mfbcb = (*this->localDistributionsH1)(D3Q27System::ET_N, x1, x2, x3); + mfbbc = (*this->localDistributionsH1)(D3Q27System::ET_T, x1, x2, x3); + mfccb = (*this->localDistributionsH1)(D3Q27System::ET_NE, x1, x2, x3); + mfacb = (*this->localDistributionsH1)(D3Q27System::ET_NW, x1p, x2, x3); + mfcbc = (*this->localDistributionsH1)(D3Q27System::ET_TE, x1, x2, x3); + mfabc = (*this->localDistributionsH1)(D3Q27System::ET_TW, x1p, x2, x3); + mfbcc = (*this->localDistributionsH1)(D3Q27System::ET_TN, x1, x2, x3); + mfbac = (*this->localDistributionsH1)(D3Q27System::ET_TS, x1, x2p, x3); + mfccc = (*this->localDistributionsH1)(D3Q27System::ET_TNE, x1, x2, x3); + mfacc = (*this->localDistributionsH1)(D3Q27System::ET_TNW, x1p, x2, x3); + mfcac = (*this->localDistributionsH1)(D3Q27System::ET_TSE, x1, x2p, x3); + mfaac = (*this->localDistributionsH1)(D3Q27System::ET_TSW, x1p, x2p, x3); + mfabb = (*this->nonLocalDistributionsH1)(D3Q27System::ET_W, x1p, x2, x3); + mfbab = (*this->nonLocalDistributionsH1)(D3Q27System::ET_S, x1, x2p, x3); + mfbba = (*this->nonLocalDistributionsH1)(D3Q27System::ET_B, x1, x2, x3p); + mfaab = (*this->nonLocalDistributionsH1)(D3Q27System::ET_SW, x1p, x2p, x3); + mfcab = (*this->nonLocalDistributionsH1)(D3Q27System::ET_SE, x1, x2p, x3); + mfaba = (*this->nonLocalDistributionsH1)(D3Q27System::ET_BW, x1p, x2, x3p); + mfcba = (*this->nonLocalDistributionsH1)(D3Q27System::ET_BE, x1, x2, x3p); + mfbaa = (*this->nonLocalDistributionsH1)(D3Q27System::ET_BS, x1, x2p, x3p); + mfbca = (*this->nonLocalDistributionsH1)(D3Q27System::ET_BN, x1, x2, x3p); + mfaaa = (*this->nonLocalDistributionsH1)(D3Q27System::ET_BSW, x1p, x2p, x3p); + mfcaa = (*this->nonLocalDistributionsH1)(D3Q27System::ET_BSE, x1, x2p, x3p); + mfaca = (*this->nonLocalDistributionsH1)(D3Q27System::ET_BNW, x1p, x2, x3p); + mfcca = (*this->nonLocalDistributionsH1)(D3Q27System::ET_BNE, x1, x2, x3p); + mfbbb = (*this->zeroDistributionsH1)(x1, x2, x3); + + + //////////////////////////////////////////////////////////////////////////////////// + //! - 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> + //! + //////////////////////////////////////////////////////////////////////////////////// + // second component + LBMReal concentration = + ((((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; + //////////////////////////////////////////////////////////////////////////////////// + LBMReal oneMinusRho = c1- concentration; + + LBMReal cx = + ((((mfccc - mfaaa) + (mfcac - mfaca)) + ((mfcaa - mfacc) + (mfcca - mfaac))) + + (((mfcba - mfabc) + (mfcbc - mfaba)) + ((mfcab - mfacb) + (mfccb - mfaab))) + + (mfcbb - mfabb)); + LBMReal cy = + ((((mfccc - mfaaa) + (mfaca - mfcac)) + ((mfacc - mfcaa) + (mfcca - mfaac))) + + (((mfbca - mfbac) + (mfbcc - mfbaa)) + ((mfacb - mfcab) + (mfccb - mfaab))) + + (mfbcb - mfbab)); + LBMReal cz = + ((((mfccc - mfaaa) + (mfcac - mfaca)) + ((mfacc - mfcaa) + (mfaac - mfcca))) + + (((mfbac - mfbca) + (mfbcc - mfbaa)) + ((mfabc - mfcba) + (mfcbc - mfaba))) + + (mfbbc - mfbba)); + + //////////////////////////////////////////////////////////////////////////////////// + // calculate the square of velocities for this lattice node + LBMReal cx2 = cx * cx; + LBMReal cy2 = cy * cy; + LBMReal cz2 = cz * cz; + //////////////////////////////////////////////////////////////////////////////////// + //! - 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 + forwardInverseChimeraWithKincompressible(mfaaa, mfaab, mfaac, cz, cz2, c36, c1o36, oneMinusRho); + forwardInverseChimeraWithKincompressible(mfaba, mfabb, mfabc, cz, cz2, c9, c1o9, oneMinusRho); + forwardInverseChimeraWithKincompressible(mfaca, mfacb, mfacc, cz, cz2, c36, c1o36, oneMinusRho); + forwardInverseChimeraWithKincompressible(mfbaa, mfbab, mfbac, cz, cz2, c9, c1o9, oneMinusRho); + forwardInverseChimeraWithKincompressible(mfbba, mfbbb, mfbbc, cz, cz2, c9o4, c4o9, oneMinusRho); + forwardInverseChimeraWithKincompressible(mfbca, mfbcb, mfbcc, cz, cz2, c9, c1o9, oneMinusRho); + forwardInverseChimeraWithKincompressible(mfcaa, mfcab, mfcac, cz, cz2, c36, c1o36, oneMinusRho); + forwardInverseChimeraWithKincompressible(mfcba, mfcbb, mfcbc, cz, cz2, c9, c1o9, oneMinusRho); + forwardInverseChimeraWithKincompressible(mfcca, mfccb, mfccc, cz, cz2, c36, c1o36, oneMinusRho); + + //////////////////////////////////////////////////////////////////////////////////// + // Y - Dir + forwardInverseChimeraWithKincompressible(mfaaa, mfaba, mfaca, cy, cy2, c6, c1o6, oneMinusRho); + forwardChimera(mfaab, mfabb, mfacb, cy, cy2); + forwardInverseChimeraWithKincompressible(mfaac, mfabc, mfacc, cy, cy2, c18, c1o18, oneMinusRho); + forwardInverseChimeraWithKincompressible(mfbaa, mfbba, mfbca, cy, cy2, c3o2, c2o3, oneMinusRho); + forwardChimera(mfbab, mfbbb, mfbcb, cy, cy2); + forwardInverseChimeraWithKincompressible(mfbac, mfbbc, mfbcc, cy, cy2, c9o2, c2o9, oneMinusRho); + forwardInverseChimeraWithKincompressible(mfcaa, mfcba, mfcca, cy, cy2, c6, c1o6, oneMinusRho); + forwardChimera(mfcab, mfcbb, mfccb, cy, cy2); + forwardInverseChimeraWithKincompressible(mfcac, mfcbc, mfccc, cy, cy2, c18, c1o18, oneMinusRho); + + //////////////////////////////////////////////////////////////////////////////////// + // X - Dir + forwardInverseChimeraWithKincompressible(mfaaa, mfbaa, mfcaa, cx, cx2, c1, c1, oneMinusRho); + forwardChimera(mfaba, mfbba, mfcba, cx, cx2); + forwardInverseChimeraWithKincompressible(mfaca, mfbca, mfcca, cx, cx2, c3, c1o3, oneMinusRho); + forwardChimera(mfaab, mfbab, mfcab, cx, cx2); + forwardChimera(mfabb, mfbbb, mfcbb, cx, cx2); + forwardChimera(mfacb, mfbcb, mfccb, cx, cx2); + forwardInverseChimeraWithKincompressible(mfaac, mfbac, mfcac, cx, cx2, c3, c1o3, oneMinusRho); + forwardChimera(mfabc, mfbbc, mfcbc, cx, cx2); + forwardInverseChimeraWithKincompressible(mfacc, mfbcc, mfccc, cx, cx2, c3, c1o9, oneMinusRho); + + //////////////////////////////////////////////////////////////////////////////////// + //! - experimental Cumulant ... to be published ... hopefully + //! + + // linearized orthogonalization of 3rd order central moments + LBMReal Mabc = mfabc - mfaba * c1o3; + LBMReal Mbca = mfbca - mfbaa * c1o3; + LBMReal Macb = mfacb - mfaab * c1o3; + LBMReal Mcba = mfcba - mfaba * c1o3; + LBMReal Mcab = mfcab - mfaab * c1o3; + LBMReal Mbac = mfbac - mfbaa * c1o3; + // linearized orthogonalization of 5th order central moments + LBMReal Mcbc = mfcbc - mfaba * c1o9; + LBMReal Mbcc = mfbcc - mfbaa * c1o9; + LBMReal Mccb = mfccb - mfaab * c1o9; + + // collision of 1st order moments + cx = cx * (c1 - omegaD) + omegaD * vvx * concentration + + normX1 * (c1 - 0.5 * omegaD) * (1.0 - phi[REST]) * (phi[REST]) * c1o3 * oneOverInterfaceScale; + cy = cy * (c1 - omegaD) + omegaD * vvy * concentration + + normX2 * (c1 - 0.5 * omegaD) * (1.0 - phi[REST]) * (phi[REST]) * c1o3 * oneOverInterfaceScale; + cz = cz * (c1 - omegaD) + omegaD * vvz * concentration + + normX3 * (c1 - 0.5 * omegaD) * (1.0 - phi[REST]) * (phi[REST]) * c1o3 * oneOverInterfaceScale; + + cx2 = cx * cx; + cy2 = cy * cy; + cz2 = cz * cz; + + // equilibration of 2nd order moments + mfbba = zeroReal; + mfbab = zeroReal; + mfabb = zeroReal; + + mfcaa = c1o3 * concentration; + mfaca = c1o3 * concentration; + mfaac = c1o3 * concentration; + + // equilibration of 3rd order moments + Mabc = zeroReal; + Mbca = zeroReal; + Macb = zeroReal; + Mcba = zeroReal; + Mcab = zeroReal; + Mbac = zeroReal; + mfbbb = zeroReal; + + // from linearized orthogonalization 3rd order central moments to central moments + mfabc = Mabc + mfaba * c1o3; + mfbca = Mbca + mfbaa * c1o3; + mfacb = Macb + mfaab * c1o3; + mfcba = Mcba + mfaba * c1o3; + mfcab = Mcab + mfaab * c1o3; + mfbac = Mbac + mfbaa * c1o3; + + // equilibration of 4th order moments + mfacc = c1o9 * concentration; + mfcac = c1o9 * concentration; + mfcca = c1o9 * concentration; + + mfcbb = zeroReal; + mfbcb = zeroReal; + mfbbc = zeroReal; + + // equilibration of 5th order moments + Mcbc = zeroReal; + Mbcc = zeroReal; + Mccb = zeroReal; + + // from linearized orthogonalization 5th order central moments to central moments + mfcbc = Mcbc + mfaba * c1o9; + mfbcc = Mbcc + mfbaa * c1o9; + mfccb = Mccb + mfaab * c1o9; + + // equilibration of 6th order moment + mfccc = c1o27 * concentration; + + //////////////////////////////////////////////////////////////////////////////////// + //! - 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 + backwardInverseChimeraWithKincompressible(mfaaa, mfbaa, mfcaa, cx, cx2, c1, c1, oneMinusRho); + backwardChimera(mfaba, mfbba, mfcba, cx, cx2); + backwardInverseChimeraWithKincompressible(mfaca, mfbca, mfcca, cx, cx2, c3, c1o3, oneMinusRho); + backwardChimera(mfaab, mfbab, mfcab, cx, cx2); + backwardChimera(mfabb, mfbbb, mfcbb, cx, cx2); + backwardChimera(mfacb, mfbcb, mfccb, cx, cx2); + backwardInverseChimeraWithKincompressible(mfaac, mfbac, mfcac, cx, cx2, c3, c1o3, oneMinusRho); + backwardChimera(mfabc, mfbbc, mfcbc, cx, cx2); + backwardInverseChimeraWithKincompressible(mfacc, mfbcc, mfccc, cx, cx2, c9, c1o9, oneMinusRho); + + //////////////////////////////////////////////////////////////////////////////////// + // Y - Dir + backwardInverseChimeraWithKincompressible(mfaaa, mfaba, mfaca, cy, cy2, c6, c1o6, oneMinusRho); + backwardChimera(mfaab, mfabb, mfacb, cy, cy2); + backwardInverseChimeraWithKincompressible(mfaac, mfabc, mfacc, cy, cy2, c18, c1o18, oneMinusRho); + backwardInverseChimeraWithKincompressible(mfbaa, mfbba, mfbca, cy, cy2, c3o2, c2o3, oneMinusRho); + backwardChimera(mfbab, mfbbb, mfbcb, cy, cy2); + backwardInverseChimeraWithKincompressible(mfbac, mfbbc, mfbcc, cy, cy2, c9o2, c2o9, oneMinusRho); + backwardInverseChimeraWithKincompressible(mfcaa, mfcba, mfcca, cy, cy2, c6, c1o6, oneMinusRho); + backwardChimera(mfcab, mfcbb, mfccb, cy, cy2); + backwardInverseChimeraWithKincompressible(mfcac, mfcbc, mfccc, cy, cy2, c18, c1o18, oneMinusRho); + + //////////////////////////////////////////////////////////////////////////////////// + // Z - Dir + backwardInverseChimeraWithKincompressible(mfaaa, mfaab, mfaac, cz, cz2, c36, c1o36, oneMinusRho); + backwardInverseChimeraWithKincompressible(mfaba, mfabb, mfabc, cz, cz2, c9, c1o9, oneMinusRho); + backwardInverseChimeraWithKincompressible(mfaca, mfacb, mfacc, cz, cz2, c36, c1o36, oneMinusRho); + backwardInverseChimeraWithKincompressible(mfbaa, mfbab, mfbac, cz, cz2, c9, c1o9, oneMinusRho); + backwardInverseChimeraWithKincompressible(mfbba, mfbbb, mfbbc, cz, cz2, c9o4, c4o9, oneMinusRho); + backwardInverseChimeraWithKincompressible(mfbca, mfbcb, mfbcc, cz, cz2, c9, c1o9, oneMinusRho); + backwardInverseChimeraWithKincompressible(mfcaa, mfcab, mfcac, cz, cz2, c36, c1o36, oneMinusRho); + backwardInverseChimeraWithKincompressible(mfcba, mfcbb, mfcbc, cz, cz2, c9, c1o9, oneMinusRho); + backwardInverseChimeraWithKincompressible(mfcca, mfccb, mfccc, cz, cz2, c36, c1o36, oneMinusRho); + + + + (*this->localDistributionsH1)(D3Q27System::ET_E, x1, x2, x3) = mfabb; + (*this->localDistributionsH1)(D3Q27System::ET_N, x1, x2, x3) = mfbab; + (*this->localDistributionsH1)(D3Q27System::ET_T, x1, x2, x3) = mfbba; + (*this->localDistributionsH1)(D3Q27System::ET_NE, x1, x2, x3) = mfaab; + (*this->localDistributionsH1)(D3Q27System::ET_NW, x1p, x2, x3) = mfcab; + (*this->localDistributionsH1)(D3Q27System::ET_TE, x1, x2, x3) = mfaba; + (*this->localDistributionsH1)(D3Q27System::ET_TW, x1p, x2, x3) = mfcba; + (*this->localDistributionsH1)(D3Q27System::ET_TN, x1, x2, x3) = mfbaa; + (*this->localDistributionsH1)(D3Q27System::ET_TS, x1, x2p, x3) = mfbca; + (*this->localDistributionsH1)(D3Q27System::ET_TNE, x1, x2, x3) = mfaaa; + (*this->localDistributionsH1)(D3Q27System::ET_TNW, x1p, x2, x3) = mfcaa; + (*this->localDistributionsH1)(D3Q27System::ET_TSE, x1, x2p, x3) = mfaca; + (*this->localDistributionsH1)(D3Q27System::ET_TSW, x1p, x2p, x3) = mfcca; + + (*this->nonLocalDistributionsH1)(D3Q27System::ET_W, x1p, x2, x3 ) = mfcbb; + (*this->nonLocalDistributionsH1)(D3Q27System::ET_S, x1, x2p, x3 ) = mfbcb; + (*this->nonLocalDistributionsH1)(D3Q27System::ET_B, x1, x2, x3p) = mfbbc; + (*this->nonLocalDistributionsH1)(D3Q27System::ET_SW, x1p, x2p, x3 ) = mfccb; + (*this->nonLocalDistributionsH1)(D3Q27System::ET_SE, x1, x2p, x3 ) = mfacb; + (*this->nonLocalDistributionsH1)(D3Q27System::ET_BW, x1p, x2, x3p) = mfcbc; + (*this->nonLocalDistributionsH1)(D3Q27System::ET_BE, x1, x2, x3p) = mfabc; + (*this->nonLocalDistributionsH1)(D3Q27System::ET_BS, x1, x2p, x3p) = mfbcc; + (*this->nonLocalDistributionsH1)(D3Q27System::ET_BN, x1, x2, x3p) = mfbac; + (*this->nonLocalDistributionsH1)(D3Q27System::ET_BSW, x1p, x2p, x3p) = mfccc; + (*this->nonLocalDistributionsH1)(D3Q27System::ET_BSE, x1, x2p, x3p) = mfacc; + (*this->nonLocalDistributionsH1)(D3Q27System::ET_BNW, x1p, x2, x3p) = mfcac; + (*this->nonLocalDistributionsH1)(D3Q27System::ET_BNE, x1, x2, x3p) = mfaac; + + (*this->zeroDistributionsH1)(x1,x2,x3) = mfbbb; + } + } + } + } + } +} +////////////////////////////////////////////////////////////////////////// + +LBMReal MultiphasePressureFilterLBMKernel::gradX1_phi() +{ + using namespace D3Q27System; + return 3.0* ((WEIGTH[TNE] * (((phi[TNE] - phi[BSW]) + (phi[BSE] - phi[TNW])) + ((phi[TSE] - phi[BNW]) + (phi[BNE] - phi[TSW]))) + + WEIGTH[NE] * (((phi[TE] - phi[BW]) + (phi[BE] - phi[TW])) + ((phi[SE] - phi[NW]) + (phi[NE] - phi[SW])))) + + +WEIGTH[N] * (phi[E] - phi[W])); +} + +LBMReal MultiphasePressureFilterLBMKernel::gradX2_phi() +{ + using namespace D3Q27System; + return 3.0 * ((WEIGTH[TNE] * (((phi[TNE] - phi[BSW]) - (phi[BSE] - phi[TNW])) + ((phi[BNE] - phi[TSW])- (phi[TSE] - phi[BNW]))) + + WEIGTH[NE] * (((phi[TN] - phi[BS]) + (phi[BN] - phi[TS])) + ((phi[NE] - phi[SW])- (phi[SE] - phi[NW])))) + + +WEIGTH[N] * (phi[N] - phi[S])); +} + +LBMReal MultiphasePressureFilterLBMKernel::gradX3_phi() +{ + using namespace D3Q27System; + return 3.0 * ((WEIGTH[TNE] * (((phi[TNE] - phi[BSW]) - (phi[BSE] - phi[TNW])) + ((phi[TSE] - phi[BNW]) - (phi[BNE] - phi[TSW]))) + + WEIGTH[NE] * (((phi[TE] - phi[BW]) - (phi[BE] - phi[TW])) + ((phi[TS] - phi[BN]) + (phi[TN] - phi[BS])))) + + +WEIGTH[N] * (phi[T] - phi[B])); +} + +LBMReal MultiphasePressureFilterLBMKernel::gradX1_phi2() +{ + using namespace D3Q27System; + return 3.0 * ((WEIGTH[TNE] * (((phi2[TNE] - phi2[BSW]) + (phi2[BSE] - phi2[TNW])) + ((phi2[TSE] - phi2[BNW]) + (phi2[BNE] - phi2[TSW]))) + + WEIGTH[NE] * (((phi2[TE] - phi2[BW]) + (phi2[BE] - phi2[TW])) + ((phi2[SE] - phi2[NW]) + (phi2[NE] - phi2[SW])))) + + +WEIGTH[N] * (phi2[E] - phi2[W])); +} + +LBMReal MultiphasePressureFilterLBMKernel::gradX2_phi2() +{ + using namespace D3Q27System; + return 3.0 * ((WEIGTH[TNE] * (((phi2[TNE] - phi2[BSW]) - (phi2[BSE] - phi2[TNW])) + ((phi2[BNE] - phi2[TSW]) - (phi2[TSE] - phi2[BNW]))) + + WEIGTH[NE] * (((phi2[TN] - phi2[BS]) + (phi2[BN] - phi2[TS])) + ((phi2[NE] - phi2[SW]) - (phi2[SE] - phi2[NW])))) + + +WEIGTH[N] * (phi2[N] - phi2[S])); +} + +LBMReal MultiphasePressureFilterLBMKernel::gradX3_phi2() +{ + using namespace D3Q27System; + return 3.0 * ((WEIGTH[TNE] * (((phi2[TNE] - phi2[BSW]) - (phi2[BSE] - phi2[TNW])) + ((phi2[TSE] - phi2[BNW]) - (phi2[BNE] - phi2[TSW]))) + + WEIGTH[NE] * (((phi2[TE] - phi2[BW]) - (phi2[BE] - phi2[TW])) + ((phi2[TS] - phi2[BN]) + (phi2[TN] - phi2[BS])))) + + +WEIGTH[N] * (phi2[T] - phi2[B])); +} + +LBMReal MultiphasePressureFilterLBMKernel::nabla2_phi() +{ + using namespace D3Q27System; + LBMReal sum = 0.0; + sum += WEIGTH[TNE] * ((((phi[TNE] - phi[REST]) + (phi[BSW] - phi[REST])) + ((phi[TSW] - phi[REST]) + (phi[BNE] - phi[REST]))) + + (((phi[TNW] - phi[REST]) + (phi[BSE] - phi[REST])) + ((phi[TSE] - phi[REST]) + (phi[BNW] - phi[REST])))); + sum += WEIGTH[TN] * ( + (((phi[TN] - phi[REST]) + (phi[BS] - phi[REST])) + ((phi[TS] - phi[REST]) + (phi[BN] - phi[REST]))) + + (((phi[TE] - phi[REST]) + (phi[BW] - phi[REST])) + ((phi[TW] - phi[REST]) + (phi[BE] - phi[REST]))) + + (((phi[NE] - phi[REST]) + (phi[SW] - phi[REST])) + ((phi[NW] - phi[REST]) + (phi[SE] - phi[REST]))) + ); + sum += WEIGTH[T] * ( + ((phi[T] - phi[REST]) + (phi[B] - phi[REST])) + + ((phi[N] - phi[REST]) + (phi[S] - phi[REST])) + + ((phi[E] - phi[REST]) + (phi[W] - phi[REST])) + ); + + return 6.0 * sum; +} + +void MultiphasePressureFilterLBMKernel::computePhasefield() +{ + using namespace D3Q27System; + SPtr<DistributionArray3D> distributionsH = dataSet->getHdistributions(); + + int minX1 = ghostLayerWidth; + int minX2 = ghostLayerWidth; + int minX3 = ghostLayerWidth; + int maxX1 = (int)distributionsH->getNX1() - ghostLayerWidth; + int maxX2 = (int)distributionsH->getNX2() - ghostLayerWidth; + int maxX3 = (int)distributionsH->getNX3() - ghostLayerWidth; + + //------------- Computing the phase-field ------------------ + for (int x3 = minX3; x3 < maxX3; x3++) { + for (int x2 = minX2; x2 < maxX2; x2++) { + for (int x1 = minX1; x1 < maxX1; x1++) { + // if(!bcArray->isSolid(x1,x2,x3) && !bcArray->isUndefined(x1,x2,x3)) + { + int x1p = x1 + 1; + int x2p = x2 + 1; + int x3p = x3 + 1; + + h[E] = (*this->localDistributionsH1)(D3Q27System::ET_E, x1, x2, x3); + h[N] = (*this->localDistributionsH1)(D3Q27System::ET_N, x1, x2, x3); + h[T] = (*this->localDistributionsH1)(D3Q27System::ET_T, x1, x2, x3); + h[NE] = (*this->localDistributionsH1)(D3Q27System::ET_NE, x1, x2, x3); + h[NW] = (*this->localDistributionsH1)(D3Q27System::ET_NW, x1p, x2, x3); + h[TE] = (*this->localDistributionsH1)(D3Q27System::ET_TE, x1, x2, x3); + h[TW] = (*this->localDistributionsH1)(D3Q27System::ET_TW, x1p, x2, x3); + h[TN] = (*this->localDistributionsH1)(D3Q27System::ET_TN, x1, x2, x3); + h[TS] = (*this->localDistributionsH1)(D3Q27System::ET_TS, x1, x2p, x3); + h[TNE] = (*this->localDistributionsH1)(D3Q27System::ET_TNE, x1, x2, x3); + h[TNW] = (*this->localDistributionsH1)(D3Q27System::ET_TNW, x1p, x2, x3); + h[TSE] = (*this->localDistributionsH1)(D3Q27System::ET_TSE, x1, x2p, x3); + h[TSW] = (*this->localDistributionsH1)(D3Q27System::ET_TSW, x1p, x2p, x3); + + h[W] = (*this->nonLocalDistributionsH1)(D3Q27System::ET_W, x1p, x2, x3); + h[S] = (*this->nonLocalDistributionsH1)(D3Q27System::ET_S, x1, x2p, x3); + h[B] = (*this->nonLocalDistributionsH1)(D3Q27System::ET_B, x1, x2, x3p); + h[SW] = (*this->nonLocalDistributionsH1)(D3Q27System::ET_SW, x1p, x2p, x3); + h[SE] = (*this->nonLocalDistributionsH1)(D3Q27System::ET_SE, x1, x2p, x3); + h[BW] = (*this->nonLocalDistributionsH1)(D3Q27System::ET_BW, x1p, x2, x3p); + h[BE] = (*this->nonLocalDistributionsH1)(D3Q27System::ET_BE, x1, x2, x3p); + h[BS] = (*this->nonLocalDistributionsH1)(D3Q27System::ET_BS, x1, x2p, x3p); + h[BN] = (*this->nonLocalDistributionsH1)(D3Q27System::ET_BN, x1, x2, x3p); + h[BSW] = (*this->nonLocalDistributionsH1)(D3Q27System::ET_BSW, x1p, x2p, x3p); + h[BSE] = (*this->nonLocalDistributionsH1)(D3Q27System::ET_BSE, x1, x2p, x3p); + h[BNW] = (*this->nonLocalDistributionsH1)(D3Q27System::ET_BNW, x1p, x2, x3p); + h[BNE] = (*this->nonLocalDistributionsH1)(D3Q27System::ET_BNE, x1, x2, x3p); + + h[REST] = (*this->zeroDistributionsH1)(x1, x2, x3); + } + } + } + } +} + +void MultiphasePressureFilterLBMKernel::findNeighbors(CbArray3D<LBMReal, IndexerX3X2X1>::CbArray3DPtr ph, int x1, int x2, + int x3) +{ + using namespace D3Q27System; + + SPtr<BCArray3D> bcArray = this->getBCProcessor()->getBCArray(); + + phi[REST] = (*ph)(x1, x2, x3); + + + for (int k = FSTARTDIR; k <= FENDDIR; k++) { + + if (!bcArray->isSolid(x1 + DX1[k], x2 + DX2[k], x3 + DX3[k])) { + phi[k] = (*ph)(x1 + DX1[k], x2 + DX2[k], x3 + DX3[k]); + } else { + phi[k] = 0.0; + } + } +} + +void MultiphasePressureFilterLBMKernel::findNeighbors2(CbArray3D<LBMReal, IndexerX3X2X1>::CbArray3DPtr ph, int x1, int x2, + int x3) +{ + using namespace D3Q27System; + + SPtr<BCArray3D> bcArray = this->getBCProcessor()->getBCArray(); + + phi2[REST] = (*ph)(x1, x2, x3); + + + for (int k = FSTARTDIR; k <= FENDDIR; k++) { + + if (!bcArray->isSolid(x1 + DX1[k], x2 + DX2[k], x3 + DX3[k])) { + phi2[k] = (*ph)(x1 + DX1[k], x2 + DX2[k], x3 + DX3[k]); + } + else { + phi2[k] = 0.0; + } + } +} + +void MultiphasePressureFilterLBMKernel::swapDistributions() +{ + LBMKernel::swapDistributions(); + dataSet->getHdistributions()->swap(); +} + +void MultiphasePressureFilterLBMKernel::initForcing() +{ + muForcingX1.DefineVar("x1", &muX1); muForcingX1.DefineVar("x2", &muX2); muForcingX1.DefineVar("x3", &muX3); + muForcingX2.DefineVar("x1", &muX1); muForcingX2.DefineVar("x2", &muX2); muForcingX2.DefineVar("x3", &muX3); + muForcingX3.DefineVar("x1", &muX1); muForcingX3.DefineVar("x2", &muX2); muForcingX3.DefineVar("x3", &muX3); + + muDeltaT = deltaT; + + muForcingX1.DefineVar("dt", &muDeltaT); + muForcingX2.DefineVar("dt", &muDeltaT); + muForcingX3.DefineVar("dt", &muDeltaT); + + muNu = (1.0 / 3.0) * (1.0 / collFactor - 1.0 / 2.0); + + muForcingX1.DefineVar("nu", &muNu); + muForcingX2.DefineVar("nu", &muNu); + muForcingX3.DefineVar("nu", &muNu); + + muForcingX1.DefineVar("rho",&muRho); + muForcingX2.DefineVar("rho",&muRho); + muForcingX3.DefineVar("rho",&muRho); + +} diff --git a/src/cpu/VirtualFluidsCore/LBM/MultiphasePressureFilterLBMKernel.h b/src/cpu/VirtualFluidsCore/LBM/MultiphasePressureFilterLBMKernel.h new file mode 100644 index 0000000000000000000000000000000000000000..84984ec9efed2d66d1b3a9157740a7cfcbd032d7 --- /dev/null +++ b/src/cpu/VirtualFluidsCore/LBM/MultiphasePressureFilterLBMKernel.h @@ -0,0 +1,116 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// 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 MultiphasePressureFilterLBMKernel.h +//! \ingroup LBMKernel +//! \author M. Geier, K. Kutscher, Hesameddin Safari +//======================================================================================= + +#ifndef MultiphasePressureFilterLBMKernel_H +#define MultiphasePressureFilterLBMKernel_H + +#include "LBMKernel.h" +#include "BCProcessor.h" +#include "D3Q27System.h" +#include "basics/utilities/UbTiming.h" +#include "basics/container/CbArray4D.h" +#include "basics/container/CbArray3D.h" + +//! \brief Multiphase Cascaded Cumulant LBM kernel. +//! \details CFD solver that use Cascaded Cumulant Lattice Boltzmann method for D3Q27 model +//! \author M. Geier, K. Kutscher, Hesameddin Safari +class MultiphasePressureFilterLBMKernel : public LBMKernel +{ +public: + MultiphasePressureFilterLBMKernel(); + virtual ~MultiphasePressureFilterLBMKernel(void) = default; + void calculate(int step) override; + SPtr<LBMKernel> clone() override; + + + ///refactor + //CbArray3D<LBMReal, IndexerX3X2X1>::CbArray3DPtr pressure; + + + double getCalculationTime() override { return .0; } +protected: + virtual void initDataSet(); + void swapDistributions() override; + + void initForcing(); + + void forwardInverseChimeraWithKincompressible(LBMReal& mfa, LBMReal& mfb, LBMReal& mfc, LBMReal vv, LBMReal v2, LBMReal Kinverse, LBMReal K, LBMReal oneMinusRho); + void backwardInverseChimeraWithKincompressible(LBMReal& mfa, LBMReal& mfb, LBMReal& mfc, LBMReal vv, LBMReal v2, LBMReal Kinverse, LBMReal K, LBMReal oneMinusRho); + void forwardChimera(LBMReal& mfa, LBMReal& mfb, LBMReal& mfc, LBMReal vv, LBMReal v2); + void backwardChimera(LBMReal& mfa, LBMReal& mfb, LBMReal& mfc, LBMReal vv, LBMReal v2); + + LBMReal f1[D3Q27System::ENDF+1]; + + CbArray4D<LBMReal,IndexerX4X3X2X1>::CbArray4DPtr localDistributionsF; + CbArray4D<LBMReal,IndexerX4X3X2X1>::CbArray4DPtr nonLocalDistributionsF; + CbArray3D<LBMReal,IndexerX3X2X1>::CbArray3DPtr zeroDistributionsF; + + CbArray4D<LBMReal,IndexerX4X3X2X1>::CbArray4DPtr localDistributionsH1; + CbArray4D<LBMReal,IndexerX4X3X2X1>::CbArray4DPtr nonLocalDistributionsH1; + CbArray3D<LBMReal,IndexerX3X2X1>::CbArray3DPtr zeroDistributionsH1; + + CbArray3D<LBMReal, IndexerX3X2X1>::CbArray3DPtr pressureOld; + + CbArray3D<LBMReal, IndexerX3X2X1>::CbArray3DPtr phaseField; + CbArray3D<LBMReal, IndexerX3X2X1>::CbArray3DPtr divU; + + LBMReal h [D3Q27System::ENDF+1]; + LBMReal h2[D3Q27System::ENDF + 1]; + LBMReal g [D3Q27System::ENDF+1]; + LBMReal phi[D3Q27System::ENDF+1]; + LBMReal phi2[D3Q27System::ENDF + 1]; + LBMReal pr1[D3Q27System::ENDF+1]; + LBMReal phi_cutoff[D3Q27System::ENDF+1]; + + LBMReal gradX1_phi(); + LBMReal gradX2_phi(); + LBMReal gradX3_phi(); + LBMReal gradX1_phi2(); + LBMReal gradX2_phi2(); + LBMReal gradX3_phi2(); + void computePhasefield(); + void findNeighbors(CbArray3D<LBMReal,IndexerX3X2X1>::CbArray3DPtr ph /*Phase-Field*/, int x1, int x2, int x3); + void findNeighbors2(CbArray3D<LBMReal, IndexerX3X2X1>::CbArray3DPtr ph, int x1, int x2, int x3); + + LBMReal nabla2_phi(); + + mu::value_type muX1,muX2,muX3; + mu::value_type muDeltaT; + mu::value_type muNu; + mu::value_type muRho; + LBMReal forcingX1; + LBMReal forcingX2; + LBMReal forcingX3; +}; + +#endif diff --git a/src/cpu/VirtualFluidsCore/LBM/MultiphaseTwoPhaseFieldsPressureFilterLBMKernel.cpp b/src/cpu/VirtualFluidsCore/LBM/MultiphaseTwoPhaseFieldsPressureFilterLBMKernel.cpp index 0336735044237b25557ba5bd2804d7358d16c018..179fc6f4d398be89481336af0c753b699828d2ee 100644 --- a/src/cpu/VirtualFluidsCore/LBM/MultiphaseTwoPhaseFieldsPressureFilterLBMKernel.cpp +++ b/src/cpu/VirtualFluidsCore/LBM/MultiphaseTwoPhaseFieldsPressureFilterLBMKernel.cpp @@ -310,11 +310,11 @@ void MultiphaseTwoPhaseFieldsPressureFilterLBMKernel::calculate(int step) + (mfaab + mfacb + mfcab + mfccb) + (mfaba + mfabc + mfcba + mfcbc) + (mfbaa + mfbac + mfbca + mfbcc) + (mfabb + mfcbb) + (mfbab + mfbcb) + (mfbba + mfbbc) + mfbbb; - LBMReal rho = rhoH + rhoToPhi * ((*pressure)(x1, x2, x3) - phiH); + LBMReal rho = rhoH + rhoToPhi * ((*phaseField)(x1, x2, x3) - phiH); //! variable density -> TRANSFER! //LBMReal rho = rhoH * ((*phaseField)(x1, x2, x3)) + rhoL * ((*phaseField2)(x1, x2, x3)); - (*pressure)(x1, x2, x3) = (*pressure)(x1, x2, x3) + rho * c1o3 * drho; + (*pressureOld)(x1, x2, x3) = (*pressure)(x1, x2, x3) + rho * c1o3 * drho; //(*pressure)(x1, x2, x3) = (((*phaseField)(x1, x2, x3)) + ((*phaseField2)(x1, x2, x3)) - c1) * c1o3; ////!!!!!! relplace by pointer swap! @@ -444,16 +444,16 @@ void MultiphaseTwoPhaseFieldsPressureFilterLBMKernel::calculate(int step) int zzz = zz + x3; if (!bcArray->isSolid(xxx, yyy, zzz) && !bcArray->isUndefined(xxx, yyy, zzz)) { - sum+= 64.0/(216.0*(c1+c3*abs(xx))* (c1 + c3 * abs(yy))* (c1 + c3 * abs(zz)))*(*pressure)(xxx, yyy, zzz); + sum+= 64.0/(216.0*(c1+c3*abs(xx))* (c1 + c3 * abs(yy))* (c1 + c3 * abs(zz)))*(*pressureOld)(xxx, yyy, zzz); } - else{ sum+= 64.0 / (216.0 * (c1 + c3 * abs(xx)) * (c1 + c3 * abs(yy)) * (c1 + c3 * abs(zz))) * (*pressure)(x1, x2, x3); + else{ sum+= 64.0 / (216.0 * (c1 + c3 * abs(xx)) * (c1 + c3 * abs(yy)) * (c1 + c3 * abs(zz))) * (*pressureOld)(x1, x2, x3); } } } } - (*pressureOld)(x1, x2, x3) = sum; + (*pressure)(x1, x2, x3) = sum; @@ -463,17 +463,17 @@ void MultiphaseTwoPhaseFieldsPressureFilterLBMKernel::calculate(int step) } //#pragma omp parallel for - for (int x3 = minX3-1; x3 <= maxX3; x3++) { - for (int x2 = minX2-1; x2 <= maxX2; x2++) { - for (int x1 = minX1-1; x1 <= maxX1; x1++) { - if (!bcArray->isSolid(x1, x2, x3) && !bcArray->isUndefined(x1, x2, x3)) { - ///filter! - - (*pressure)(x1, x2, x3) = (*pressureOld)(x1, x2, x3); - } - } - } - } + // for (int x3 = minX3-1; x3 <= maxX3; x3++) { + // for (int x2 = minX2-1; x2 <= maxX2; x2++) { + // for (int x1 = minX1-1; x1 <= maxX1; x1++) { + // if (!bcArray->isSolid(x1, x2, x3) && !bcArray->isUndefined(x1, x2, x3)) { + // ///filter! + + // (*pressure)(x1, x2, x3) = (*pressureOld)(x1, x2, x3); + // } + // } + // } + // } ////!filter 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/Parallel/MetisPartitioner.cpp b/src/cpu/VirtualFluidsCore/Parallel/MetisPartitioner.cpp index 93776668460650d5b7015f57cb00fe303277a3a7..51d74e3bf1b5d5109904e1fa581bcff366fad505 100644 --- a/src/cpu/VirtualFluidsCore/Parallel/MetisPartitioner.cpp +++ b/src/cpu/VirtualFluidsCore/Parallel/MetisPartitioner.cpp @@ -24,7 +24,7 @@ void MetisPartitioner::setMetisOptions(int option, idx_t value) { options[option ////////////////////////////////////////////////////////////////////////// int MetisPartitioner::partition(int nofParts, MetisPartitioner::PartType ptype) { - int rc; + int rc {0}; idx_t nvtxs = (idx_t)xadj.size() - 1; // number of nodes idx_t ncon = (idx_t)vwgt.size() / nvtxs; // number Of node constraints; part.resize(nvtxs); diff --git a/src/cpu/VirtualFluidsCore/Utilities/CheckpointConverter.cpp b/src/cpu/VirtualFluidsCore/Utilities/CheckpointConverter.cpp index caad0f726762e3ffafe2b657516bd305de61b603..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"); @@ -77,7 +77,7 @@ CheckpointConverter::CheckpointConverter(SPtr<Grid3D> grid, const std::string &p //--------------------------------------- MPI_Datatype typesDataSetRead[3] = { MPI_DOUBLE, MPI_INT, MPI_CHAR }; - int blocksDataSetRead[3] = { 5, 5, 2 }; + int blocksDataSetRead[3] = { 3, 5, 2 }; MPI_Aint offsetsDataSetRead[3], lbDataSetRead, extentDataSetRead; offsetsDataSetRead[0] = 0; @@ -93,7 +93,7 @@ CheckpointConverter::CheckpointConverter(SPtr<Grid3D> grid, const std::string &p //----------------------------------------------------------------------- MPI_Datatype typesDataSetWrite[3] = { MPI_DOUBLE, MPI_INT, MPI_CHAR }; - int blocksDataSetWrite[3] = { 5, 2, 2 }; + int blocksDataSetWrite[3] = { 2, 2, 2 }; MPI_Aint offsetsDataSetWrite[3], lbDataSetWrite, extentDataSetWrite; offsetsDataSetWrite[0] = 0; @@ -133,7 +133,9 @@ void CheckpointConverter::convert(int step, int procCount) void CheckpointConverter::convertBlocks(int step, int procCount) { - double start, finish; + + double start {0.}; + double finish {0.}; start = MPI_Wtime(); // file to read from @@ -147,7 +149,8 @@ void CheckpointConverter::convertBlocks(int step, int procCount) MPI_File file_handlerW; UbSystem::makeDirectory(path + "/mig/mpi_io_cp/mpi_io_cp_" + UbSystem::toString(step)); std::string filenameW = path + "/mig/mpi_io_cp/mpi_io_cp_" + UbSystem::toString(step) + "/cpBlocks.bin"; - int rcW = MPI_File_open(MPI_COMM_WORLD, filenameW.c_str(), MPI_MODE_CREATE | MPI_MODE_WRONLY, MPI_INFO_NULL, &file_handlerW); + int rcW = MPI_File_open(MPI_COMM_WORLD, filenameW.c_str(), MPI_MODE_CREATE | MPI_MODE_WRONLY, MPI_INFO_NULL, + &file_handlerW); if (rcW != MPI_SUCCESS) throw UbException(UB_EXARGS, "couldn't open file " + filenameW); @@ -158,21 +161,21 @@ void CheckpointConverter::convertBlocks(int step, int procCount) GridParam *gridParameters = new GridParam; // calculate the read offset - procCount = 1; // readBlocks and writeBlocks in both MPIIORestartCoProcessor and MPIIOMigrationCoProcessor have size == 1! + procCount = + 1; // readBlocks and writeBlocks in both MPIIORestartCoProcessor and MPIIOMigrationCoProcessor have size == 1! MPI_Offset read_offset = (MPI_Offset)(procCount * sizeof(int)); // read parameters of the grid and blocks MPI_File_read_at(file_handlerR, read_offset, gridParameters, 1, gridParamType, MPI_STATUS_IGNORE); - MPI_File_read_at(file_handlerR, (MPI_Offset)(read_offset + sizeof(GridParam)), &block3dArray[0], blocksCount, block3dType, MPI_STATUS_IGNORE); + MPI_File_read_at(file_handlerR, (MPI_Offset)(read_offset + sizeof(GridParam)), &block3dArray[0], blocksCount, + block3dType, MPI_STATUS_IGNORE); // clear the grid std::vector<SPtr<Block3D>> blocksVector[25]; int minInitLevel = this->grid->getCoarsestInitializedLevel(); - if (minInitLevel > -1) - { + if (minInitLevel > -1) { int maxInitLevel = this->grid->getFinestInitializedLevel(); - for (int level = minInitLevel; level <= maxInitLevel; level++) - { + for (int level = minInitLevel; level <= maxInitLevel; level++) { grid->getBlocks(level, blocksVector[level]); for (SPtr<Block3D> block : blocksVector[level]) // blocks of the current level grid->deleteBlock(block); @@ -232,9 +235,9 @@ void CheckpointConverter::convertBlocks(int step, int procCount) grid->setPeriodicX3(gridParameters->periodicX3); // regenerate blocks - for (int n = 0; n < blocksCount; n++) - { - SPtr<Block3D> block(new Block3D(block3dArray[n].x1, block3dArray[n].x2, block3dArray[n].x3, block3dArray[n].level)); + for (int n = 0; n < blocksCount; n++) { + SPtr<Block3D> block( + new Block3D(block3dArray[n].x1, block3dArray[n].x2, block3dArray[n].x3, block3dArray[n].level)); block->setActive(block3dArray[n].active); block->setBundle(block3dArray[n].bundle); block->setRank(block3dArray[n].rank); @@ -254,8 +257,7 @@ void CheckpointConverter::convertBlocks(int step, int procCount) // refresh globalID in all the blocks SPtr<Block3D> block; - for (int n = 0; n < blocksCount; n++) - { + for (int n = 0; n < blocksCount; n++) { block = grid->getBlock(block3dArray[n].x1, block3dArray[n].x2, block3dArray[n].x3, block3dArray[n].level); block3dArray[n].globalID = block->getGlobalID(); } @@ -265,7 +267,8 @@ void CheckpointConverter::convertBlocks(int step, int procCount) MPI_File_write_at(file_handlerW, 0, &blocksCount, 1, MPI_INT, MPI_STATUS_IGNORE); MPI_File_write_at(file_handlerW, write_offset, gridParameters, 1, gridParamType, MPI_STATUS_IGNORE); - MPI_File_write_at(file_handlerW, (MPI_Offset)(write_offset + sizeof(GridParam)), &block3dArray[0], blocksCount, block3dType, MPI_STATUS_IGNORE); + MPI_File_write_at(file_handlerW, (MPI_Offset)(write_offset + sizeof(GridParam)), &block3dArray[0], blocksCount, + block3dType, MPI_STATUS_IGNORE); MPI_File_close(&file_handlerR); MPI_File_close(&file_handlerW); @@ -281,32 +284,22 @@ void CheckpointConverter::convertDataSet(int step, int procCount) { // file to read from MPI_File file_handlerR; - std::string filenameR = path + "/mpi_io_cp/mpi_io_cp_" + UbSystem::toString(step) + "/cpDataSetF.bin"; + std::string filenameR = path + "/mpi_io_cp/mpi_io_cp_" + UbSystem::toString(step) + "/cpDataSet.bin"; int rcR = MPI_File_open(MPI_COMM_WORLD, filenameR.c_str(), MPI_MODE_RDONLY, MPI_INFO_NULL, &file_handlerR); if (rcR != MPI_SUCCESS) throw UbException(UB_EXARGS, "couldn't open file " + filenameR); // file to write to MPI_File file_handlerW; - std::string filenameW = path + "/mig/mpi_io_cp/mpi_io_cp_" + UbSystem::toString(step) + "/cpDataSetF.bin"; - int rcW = MPI_File_open(MPI_COMM_WORLD, filenameW.c_str(), MPI_MODE_CREATE | MPI_MODE_WRONLY, MPI_INFO_NULL, &file_handlerW); + std::string filenameW = path + "/mig/mpi_io_cp/mpi_io_cp_" + UbSystem::toString(step) + "/cpDataSet.bin"; + int rcW = MPI_File_open(MPI_COMM_WORLD, filenameW.c_str(), MPI_MODE_CREATE | MPI_MODE_WRONLY, MPI_INFO_NULL, + &file_handlerW); if (rcW != MPI_SUCCESS) throw UbException(UB_EXARGS, "couldn't open file " + filenameW); - MPI_File file_handlerR1; - std::string filenameR1 = path + "/mpi_io_cp/mpi_io_cp_" + UbSystem::toString(step) + "/cpDataSetH1.bin"; - rcR = MPI_File_open(MPI_COMM_WORLD, filenameR1.c_str(), MPI_MODE_RDONLY, MPI_INFO_NULL, &file_handlerR1); - if (rcR != MPI_SUCCESS) - throw UbException(UB_EXARGS, "couldn't open file " + filenameR1); - - MPI_File file_handlerW1; - std::string filenameW1 = path + "/mig/mpi_io_cp/mpi_io_cp_" + UbSystem::toString(step) + "/cpDataSetH1.bin"; - rcW = MPI_File_open(MPI_COMM_WORLD, filenameW1.c_str(), MPI_MODE_CREATE | MPI_MODE_WRONLY, MPI_INFO_NULL, &file_handlerW1); - if (rcW != MPI_SUCCESS) - throw UbException(UB_EXARGS, "couldn't open file " + filenameW1); - - MPI_Offset fsize; - double start, finish; + + double start {0.}; + double finish {0.}; start = MPI_Wtime(); int blocksCount = 0; @@ -315,21 +308,22 @@ void CheckpointConverter::convertDataSet(int step, int procCount) DataSetMigration *dataSetWriteArray; size_t doubleCountInBlock; std::vector<double> doubleValuesArray; - std::vector<double> doubleValuesArrayH1; // double-values in all blocks H1distributions size_t sizeofOneDataSet; // calculate the read offset MPI_Offset read_offset = (MPI_Offset)(procCount * sizeof(int)); MPI_Offset write_offset; - for (int pc = 0; pc < procCount; pc++) - { + for (int pc = 0; pc < procCount; pc++) { // read count of blocks and parameters of data arrays MPI_File_read_at(file_handlerR, (MPI_Offset)(pc * sizeof(int)), &blocksCount, 1, MPI_INT, MPI_STATUS_IGNORE); MPI_File_read_at(file_handlerR, read_offset, &dataSetParamStr1, 1, dataSetParamType, MPI_STATUS_IGNORE); - MPI_File_read_at(file_handlerR, (MPI_Offset)(read_offset + sizeof(dataSetParam)), &dataSetParamStr2, 1, dataSetParamType, MPI_STATUS_IGNORE); - MPI_File_read_at(file_handlerR, (MPI_Offset)(read_offset + 2 * sizeof(dataSetParam)), &dataSetParamStr3, 1, dataSetParamType, MPI_STATUS_IGNORE); - doubleCountInBlock = dataSetParamStr1.nx[0] * dataSetParamStr1.nx[1] * dataSetParamStr1.nx[2] * dataSetParamStr1.nx[3] + + MPI_File_read_at(file_handlerR, (MPI_Offset)(read_offset + sizeof(dataSetParam)), &dataSetParamStr2, 1, + dataSetParamType, MPI_STATUS_IGNORE); + MPI_File_read_at(file_handlerR, (MPI_Offset)(read_offset + 2 * sizeof(dataSetParam)), &dataSetParamStr3, 1, + dataSetParamType, MPI_STATUS_IGNORE); + doubleCountInBlock = + dataSetParamStr1.nx[0] * dataSetParamStr1.nx[1] * dataSetParamStr1.nx[2] * dataSetParamStr1.nx[3] + dataSetParamStr2.nx[0] * dataSetParamStr2.nx[1] * dataSetParamStr2.nx[2] * dataSetParamStr2.nx[3] + dataSetParamStr3.nx[0] * dataSetParamStr3.nx[1] * dataSetParamStr3.nx[2] * dataSetParamStr3.nx[3]; @@ -337,77 +331,56 @@ void CheckpointConverter::convertDataSet(int step, int procCount) dataSetWriteArray = new DataSetMigration[blocksCount]; doubleValuesArray.resize(blocksCount * doubleCountInBlock); - MPI_Type_contiguous(int(doubleCountInBlock), MPI_DOUBLE, &dataSetDoubleType); - MPI_Type_commit(&dataSetDoubleType); - // read data MPI_File_read_at(file_handlerR, (MPI_Offset)(read_offset + 3 * sizeof(dataSetParam)), dataSetReadArray, blocksCount, dataSetTypeRead, MPI_STATUS_IGNORE); - MPI_File_read_at(file_handlerR, (MPI_Offset)(read_offset + 3 * sizeof(dataSetParam) + blocksCount * sizeof(DataSetRestart)), - &doubleValuesArray[0], blocksCount, dataSetDoubleType, MPI_STATUS_IGNORE); + MPI_File_read_at(file_handlerR, + (MPI_Offset)(read_offset + 3 * sizeof(dataSetParam) + blocksCount * sizeof(DataSetRestart)), + &doubleValuesArray[0], int(blocksCount * doubleCountInBlock), MPI_DOUBLE, MPI_STATUS_IGNORE); // offset to read the data of the next process - read_offset = read_offset + (MPI_Offset)(3 * sizeof(dataSetParam) + blocksCount * (sizeof(DataSetRestart) + doubleCountInBlock * sizeof(double))); + read_offset = + read_offset + (MPI_Offset)(3 * sizeof(dataSetParam) + + blocksCount * (sizeof(DataSetRestart) + doubleCountInBlock * sizeof(double))); // write parameters of data arrays MPI_File_write_at(file_handlerW, (MPI_Offset)0, &dataSetParamStr1, 1, dataSetParamType, MPI_STATUS_IGNORE); - MPI_File_write_at(file_handlerW, (MPI_Offset)(sizeof(dataSetParam)), &dataSetParamStr2, 1, dataSetParamType, MPI_STATUS_IGNORE); - MPI_File_write_at(file_handlerW, (MPI_Offset)(2 * sizeof(dataSetParam)), &dataSetParamStr3, 1, dataSetParamType, MPI_STATUS_IGNORE); + MPI_File_write_at(file_handlerW, (MPI_Offset)(sizeof(dataSetParam)), &dataSetParamStr2, 1, dataSetParamType, + MPI_STATUS_IGNORE); + MPI_File_write_at(file_handlerW, (MPI_Offset)(2 * sizeof(dataSetParam)), &dataSetParamStr3, 1, dataSetParamType, + MPI_STATUS_IGNORE); sizeofOneDataSet = sizeof(DataSetMigration) + doubleCountInBlock * sizeof(double); // write blocks and their data arrays - for (int nb = 0; nb < blocksCount; nb++) - { - SPtr<Block3D> block = grid->getBlock(dataSetReadArray[nb].x1, dataSetReadArray[nb].x2, dataSetReadArray[nb].x3, dataSetReadArray[nb].level); + for (int nb = 0; nb < blocksCount; nb++) { + SPtr<Block3D> block = grid->getBlock(dataSetReadArray[nb].x1, dataSetReadArray[nb].x2, + dataSetReadArray[nb].x3, dataSetReadArray[nb].level); dataSetWriteArray[nb].globalID = block->getGlobalID(); dataSetWriteArray[nb].ghostLayerWidth = dataSetReadArray[nb].ghostLayerWidth; dataSetWriteArray[nb].collFactor = dataSetReadArray[nb].collFactor; dataSetWriteArray[nb].deltaT = dataSetReadArray[nb].deltaT; dataSetWriteArray[nb].compressible = dataSetReadArray[nb].compressible; dataSetWriteArray[nb].withForcing = dataSetReadArray[nb].withForcing; - dataSetWriteArray[nb].collFactorL = dataSetReadArray[nb].collFactorL; // for Multiphase model - dataSetWriteArray[nb].collFactorG = dataSetReadArray[nb].collFactorG; // for Multiphase model - dataSetWriteArray[nb].densityRatio = dataSetReadArray[nb].densityRatio;// for Multiphase model +// dataSetWriteArray[nb].densityRatio = dataSetReadArray[nb].densityRatio; write_offset = (MPI_Offset)(3 * sizeof(dataSetParam) + dataSetWriteArray[nb].globalID * sizeofOneDataSet); - MPI_File_write_at(file_handlerW, write_offset, &dataSetWriteArray[nb], 1, dataSetTypeWrite, MPI_STATUS_IGNORE); + MPI_File_write_at(file_handlerW, write_offset, &dataSetWriteArray[nb], 1, dataSetTypeWrite, + MPI_STATUS_IGNORE); MPI_File_write_at(file_handlerW, (MPI_Offset)(write_offset + sizeof(DataSetMigration)), - &doubleValuesArray[nb * doubleCountInBlock], 1, dataSetDoubleType, MPI_STATUS_IGNORE); + &doubleValuesArray[nb * doubleCountInBlock], int(doubleCountInBlock), MPI_DOUBLE, + MPI_STATUS_IGNORE); } - //-------------------------------------- H1 ----------------------------- - MPI_File_get_size(file_handlerR1, &fsize); - if (fsize > 0) - { - doubleValuesArrayH1.resize(blocksCount * doubleCountInBlock); - MPI_File_read_at(file_handlerR1, read_offset, &doubleValuesArrayH1[0], blocksCount, dataSetDoubleType, MPI_STATUS_IGNORE); - - sizeofOneDataSet = doubleCountInBlock * sizeof(double); - - for (int nb = 0; nb < blocksCount; nb++) - { - write_offset = (MPI_Offset)(dataSetWriteArray[nb].globalID * sizeofOneDataSet); - MPI_File_write_at(file_handlerW1, write_offset, &doubleValuesArrayH1[nb * doubleCountInBlock], 1, dataSetDoubleType, MPI_STATUS_IGNORE); - } - - } - - MPI_Type_free(&dataSetDoubleType); - delete[] dataSetReadArray; delete[] dataSetWriteArray; } - MPI_File_close(&file_handlerR1); - MPI_File_sync(file_handlerW1); - MPI_File_close(&file_handlerW1); - MPI_File_close(&file_handlerR); + MPI_File_sync(file_handlerW); MPI_File_close(&file_handlerW); -//-------------------------------------------------------------------------------- DSArraysPresence arrPresence; MPI_File file_handler1; std::string filename1 = path + "/mpi_io_cp/mpi_io_cp_" + UbSystem::toString(step) + "/cpArrays.bin"; @@ -431,22 +404,28 @@ void CheckpointConverter::convertDataSet(int step, int procCount) std::string filenameWW = path + "/mig/mpi_io_cp/mpi_io_cp_" + UbSystem::toString(step); if (arrPresence.isAverageDensityArrayPresent) - convert___Array(step, procCount, filenameRR + "/cpAverageDensityArray.bin", filenameWW + "/cpAverageDensityArray.bin"); + convert___Array(step, procCount, filenameRR + "/cpAverageDensityArray.bin", + filenameWW + "/cpAverageDensityArray.bin"); if (arrPresence.isAverageVelocityArrayPresent) - convert___Array(step, procCount, filenameRR + "/cpAverageVelocityArray.bin", filenameWW + "/cpAverageVelocityArray.bin"); + convert___Array(step, procCount, filenameRR + "/cpAverageVelocityArray.bin", + filenameWW + "/cpAverageVelocityArray.bin"); if (arrPresence.isAverageFluktuationsArrayPresent) - convert___Array(step, procCount, filenameRR + "/cpAverageFluktuationsArray.bin", filenameWW + "/cpAverageFluktuationsArray.bin"); + convert___Array(step, procCount, filenameRR + "/cpAverageFluktuationsArray.bin", + filenameWW + "/cpAverageFluktuationsArray.bin"); if (arrPresence.isAverageTripleArrayPresent) - convert___Array(step, procCount, filenameRR + "/cpAverageTripleArray.bin", filenameWW + "/cpAverageTripleArray.bin"); + convert___Array(step, procCount, filenameRR + "/cpAverageTripleArray.bin", + filenameWW + "/cpAverageTripleArray.bin"); if (arrPresence.isShearStressValArrayPresent) - convert___Array(step, procCount, filenameRR + "/cpShearStressValArray.bin", filenameWW + "/cpShearStressValArray.bin"); + convert___Array(step, procCount, filenameRR + "/cpShearStressValArray.bin", + filenameWW + "/cpShearStressValArray.bin"); if (arrPresence.isRelaxationFactorPresent) - convert___Array(step, procCount, filenameRR + "/cpRelaxationFactor.bin", filenameWW + "/cpRelaxationFactor.bin"); + convert___Array(step, procCount, filenameRR + "/cpRelaxationFactor.bin", + filenameWW + "/cpRelaxationFactor.bin"); finish = MPI_Wtime(); UBLOG(logINFO, "UtilConvertor::convertDataSet time: " << finish - start << " s"); @@ -454,7 +433,9 @@ void CheckpointConverter::convertDataSet(int step, int procCount) void CheckpointConverter::convert___Array(int /*step*/, int procCount, std::string filenameR, std::string filenameW) { - double start, finish; + + double start {0.}; + double finish {0.}; if (comm->isRoot()) start = MPI_Wtime(); @@ -464,7 +445,8 @@ void CheckpointConverter::convert___Array(int /*step*/, int procCount, std::stri throw UbException(UB_EXARGS, "couldn't open file " + filenameR); MPI_File file_handlerW; - int rcW = MPI_File_open(MPI_COMM_WORLD, filenameW.c_str(), MPI_MODE_CREATE | MPI_MODE_WRONLY, MPI_INFO_NULL, &file_handlerW); + int rcW = MPI_File_open(MPI_COMM_WORLD, filenameW.c_str(), MPI_MODE_CREATE | MPI_MODE_WRONLY, MPI_INFO_NULL, + &file_handlerW); if (rcW != MPI_SUCCESS) throw UbException(UB_EXARGS, "couldn't open file " + filenameW); @@ -481,29 +463,32 @@ void CheckpointConverter::convert___Array(int /*step*/, int procCount, std::stri MPI_Offset write_offset; size_t sizeofOneDataSet; - for (int pc = 0; pc < procCount; pc++) - { + for (int pc = 0; pc < procCount; pc++) { MPI_File_read_at(file_handlerR, (MPI_Offset)(pc * sizeof(int)), &blocksCount, 1, MPI_INT, MPI_STATUS_IGNORE); MPI_File_read_at(file_handlerR, read_offset, &dataSetParamStr, 1, dataSetParamType, MPI_STATUS_IGNORE); dataSetSmallReadArray = new DataSetSmallRestart[blocksCount]; dataSetSmallWriteArray = new DataSetSmallMigration[blocksCount]; - doubleCountInBlock = dataSetParamStr.nx[0] * dataSetParamStr.nx[1] * dataSetParamStr.nx[2] * dataSetParamStr.nx[3]; + doubleCountInBlock = + dataSetParamStr.nx[0] * dataSetParamStr.nx[1] * dataSetParamStr.nx[2] * dataSetParamStr.nx[3]; doubleValuesArray.resize(blocksCount * doubleCountInBlock); - MPI_File_read_at(file_handlerR, (MPI_Offset)(read_offset + sizeof(dataSetParam)), dataSetSmallReadArray, blocksCount * 4, MPI_INT, MPI_STATUS_IGNORE); + MPI_File_read_at(file_handlerR, (MPI_Offset)(read_offset + sizeof(dataSetParam)), dataSetSmallReadArray, + blocksCount * 4, MPI_INT, MPI_STATUS_IGNORE); if (doubleCountInBlock > 0) - MPI_File_read_at(file_handlerR, (MPI_Offset)(read_offset + sizeof(dataSetParam) + blocksCount * sizeof(DataSetSmallRestart)), + MPI_File_read_at( + file_handlerR, + (MPI_Offset)(read_offset + sizeof(dataSetParam) + blocksCount * sizeof(DataSetSmallRestart)), &doubleValuesArray[0], blocksCount * doubleCountInBlock, MPI_DOUBLE, MPI_STATUS_IGNORE); - read_offset = read_offset + sizeof(dataSetParam) + blocksCount * (sizeof(DataSetSmallRestart) + doubleCountInBlock * sizeof(double)); + read_offset = read_offset + sizeof(dataSetParam) + + blocksCount * (sizeof(DataSetSmallRestart) + doubleCountInBlock * sizeof(double)); sizeofOneDataSet = sizeof(DataSetSmallMigration) + doubleCountInBlock * sizeof(double); MPI_File_write_at(file_handlerW, 0, &dataSetParamStr, 1, dataSetParamType, MPI_STATUS_IGNORE); - for (int nb = 0; nb < blocksCount; nb++) - { + for (int nb = 0; nb < blocksCount; nb++) { SPtr<Block3D> block = grid->getBlock(dataSetSmallReadArray[nb].x1, dataSetSmallReadArray[nb].x2, dataSetSmallReadArray[nb].x3, dataSetSmallReadArray[nb].level); dataSetSmallWriteArray[nb].globalID = block->getGlobalID(); @@ -511,7 +496,8 @@ void CheckpointConverter::convert___Array(int /*step*/, int procCount, std::stri write_offset = (MPI_Offset)(sizeof(dataSetParam) + dataSetSmallWriteArray[nb].globalID * sizeofOneDataSet); MPI_File_write_at(file_handlerW, write_offset, &dataSetSmallWriteArray[nb], 1, MPI_INT, MPI_STATUS_IGNORE); MPI_File_write_at(file_handlerW, (MPI_Offset)(write_offset + sizeof(DataSetSmallMigration)), - &doubleValuesArray[nb * doubleCountInBlock], doubleCountInBlock, MPI_DOUBLE, MPI_STATUS_IGNORE); + &doubleValuesArray[nb * doubleCountInBlock], doubleCountInBlock, MPI_DOUBLE, + MPI_STATUS_IGNORE); } delete[] dataSetSmallReadArray; @@ -538,11 +524,13 @@ void CheckpointConverter::convertBC(int step, int procCount) // file to write to MPI_File file_handlerW; std::string filenameW = path + "/mig/mpi_io_cp/mpi_io_cp_" + UbSystem::toString(step) + "/cpBC.bin"; - int rcW = MPI_File_open(MPI_COMM_WORLD, filenameW.c_str(), MPI_MODE_CREATE | MPI_MODE_WRONLY, MPI_INFO_NULL, &file_handlerW); + int rcW = MPI_File_open(MPI_COMM_WORLD, filenameW.c_str(), MPI_MODE_CREATE | MPI_MODE_WRONLY, MPI_INFO_NULL, + &file_handlerW); if (rcW != MPI_SUCCESS) throw UbException(UB_EXARGS, "couldn't open file " + filenameW); - double start, finish; + double start {0.}; + double finish {0.}; if (comm->isRoot()) start = MPI_Wtime(); @@ -565,8 +553,7 @@ void CheckpointConverter::convertBC(int step, int procCount) MPI_Offset write_offset = (MPI_Offset)(sizeof(boundCondParam) + grid->getNumberOfBlocks() * sizeof(size_t)); MPI_Offset write_offsetIndex; - for (int pc = 0; pc < procCount; pc++) - { + for (int pc = 0; pc < procCount; pc++) { read_offset = (MPI_Offset)(pc * (3 * sizeof(int) + sizeof(boundCondParam))); // read count of blocks @@ -594,10 +581,15 @@ void CheckpointConverter::convertBC(int step, int procCount) MPI_File_read_at(file_handlerR, read_offset1, bcAddReadArray, blocksCount * 6, MPI_INT, MPI_STATUS_IGNORE); MPI_File_read_at(file_handlerR, (MPI_Offset)(read_offset1 + blocksCount * sizeof(BCAddRestart)), &bcArray[0], dataCount1000, boundCondType1000, MPI_STATUS_IGNORE); - MPI_File_read_at(file_handlerR, (MPI_Offset)(read_offset1 + blocksCount * sizeof(BCAddRestart) + dataCount * sizeof(BoundaryCondition)), - &intArray1[0], blocksCount * boundCondParamStr.bcindexmatrixCount, MPI_INT, MPI_STATUS_IGNORE); - MPI_File_read_at(file_handlerR, (MPI_Offset)(read_offset1 + blocksCount * sizeof(BCAddRestart) + dataCount * sizeof(BoundaryCondition) + - blocksCount * boundCondParamStr.bcindexmatrixCount * sizeof(int)), &intArray2[0], dataCount2, MPI_INT, MPI_STATUS_IGNORE); + MPI_File_read_at( + file_handlerR, + (MPI_Offset)(read_offset1 + blocksCount * sizeof(BCAddRestart) + dataCount * sizeof(BoundaryCondition)), + &intArray1[0], blocksCount * boundCondParamStr.bcindexmatrixCount, MPI_INT, MPI_STATUS_IGNORE); + MPI_File_read_at(file_handlerR, + (MPI_Offset)(read_offset1 + blocksCount * sizeof(BCAddRestart) + + dataCount * sizeof(BoundaryCondition) + + blocksCount * boundCondParamStr.bcindexmatrixCount * sizeof(int)), + &intArray2[0], dataCount2, MPI_INT, MPI_STATUS_IGNORE); // offset to read the data of the next process read_offset1 = read_offset1 + blocksCount * sizeof(BCAddRestart) + dataCount * sizeof(BoundaryCondition) + @@ -608,12 +600,14 @@ void CheckpointConverter::convertBC(int step, int procCount) indexBC = 0; indexC = 0; // write blocks and their BC data arrays - for (int nb = 0; nb < blocksCount; nb++) - { - SPtr<Block3D> block = grid->getBlock(bcAddReadArray[nb].x1, bcAddReadArray[nb].x2, bcAddReadArray[nb].x3, bcAddReadArray[nb].level); + for (int nb = 0; nb < blocksCount; nb++) { + SPtr<Block3D> block = grid->getBlock(bcAddReadArray[nb].x1, bcAddReadArray[nb].x2, bcAddReadArray[nb].x3, + bcAddReadArray[nb].level); bcAddWriteArray[nb].globalID = block->getGlobalID(); - bcAddWriteArray[nb].boundCond_count = bcAddReadArray[nb].boundCond_count; // how many BoundaryConditions in this block - bcAddWriteArray[nb].indexContainer_count = bcAddReadArray[nb].indexContainer_count; // how many indexContainer-values in this block + bcAddWriteArray[nb].boundCond_count = + bcAddReadArray[nb].boundCond_count; // how many BoundaryConditions in this block + bcAddWriteArray[nb].indexContainer_count = + bcAddReadArray[nb].indexContainer_count; // how many indexContainer-values in this block write_offsetIndex = (MPI_Offset)(sizeof(boundCondParam) + bcAddWriteArray[nb].globalID * sizeof(size_t)); MPI_File_write_at(file_handlerW, write_offsetIndex, &write_offset, 1, MPI_LONG_LONG_INT, MPI_STATUS_IGNORE); @@ -625,16 +619,24 @@ void CheckpointConverter::convertBC(int step, int procCount) indexBC += bcAddWriteArray[nb].boundCond_count; if (boundCondParamStr.bcindexmatrixCount > 0) - MPI_File_write_at(file_handlerW, (MPI_Offset)(write_offset + sizeof(BCAddMigration) + bcAddWriteArray[nb].boundCond_count * sizeof(BoundaryCondition)), - &intArray1[nb * boundCondParamStr.bcindexmatrixCount], boundCondParamStr.bcindexmatrixCount, MPI_INT, MPI_STATUS_IGNORE); + MPI_File_write_at(file_handlerW, + (MPI_Offset)(write_offset + sizeof(BCAddMigration) + + bcAddWriteArray[nb].boundCond_count * sizeof(BoundaryCondition)), + &intArray1[nb * boundCondParamStr.bcindexmatrixCount], + boundCondParamStr.bcindexmatrixCount, MPI_INT, MPI_STATUS_IGNORE); if (bcAddWriteArray[nb].indexContainer_count > 0) - MPI_File_write_at(file_handlerW, (MPI_Offset)(write_offset + sizeof(BCAddMigration) + bcAddWriteArray[nb].boundCond_count * sizeof(BoundaryCondition) + - boundCondParamStr.bcindexmatrixCount * sizeof(int)), &intArray2[indexC], bcAddWriteArray[nb].indexContainer_count, MPI_INT, MPI_STATUS_IGNORE); + MPI_File_write_at(file_handlerW, + (MPI_Offset)(write_offset + sizeof(BCAddMigration) + + bcAddWriteArray[nb].boundCond_count * sizeof(BoundaryCondition) + + boundCondParamStr.bcindexmatrixCount * sizeof(int)), + &intArray2[indexC], bcAddWriteArray[nb].indexContainer_count, MPI_INT, + MPI_STATUS_IGNORE); indexC += bcAddWriteArray[nb].indexContainer_count; write_offset += sizeof(BCAddMigration) + bcAddWriteArray[nb].boundCond_count * sizeof(BoundaryCondition) + - boundCondParamStr.bcindexmatrixCount * sizeof(int) + bcAddWriteArray[nb].indexContainer_count * sizeof(int); + boundCondParamStr.bcindexmatrixCount * sizeof(int) + + bcAddWriteArray[nb].indexContainer_count * sizeof(int); } delete[] bcAddReadArray; diff --git a/src/cpu/VirtualFluidsCore/Utilities/CheckpointConverter.h b/src/cpu/VirtualFluidsCore/Utilities/CheckpointConverter.h index 294081a4fe6265a1aa8ef74c5ec79cb8a13efedf..6d5b3c686dbbc2d688df1b59dedba9c696c2959d 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 c9fa88791e23f35fafa14fb2e20272f0bae04b56..42ed287c6d9ddfe30e38dce3a05814c385cdefd0 100644 --- a/src/cpu/VirtualFluidsCore/Visitors/SetConnectorsBlockVisitor.h +++ b/src/cpu/VirtualFluidsCore/Visitors/SetConnectorsBlockVisitor.h @@ -41,14 +41,16 @@ #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" #include "TwoDistributionsFullVectorConnector.h" +#include "TwoDistributionsDoubleGhostLayerFullDirectConnector.h" +#include "TwoDistributionsDoubleGhostLayerFullVectorConnector.h" #include "ThreeDistributionsFullDirectConnector.h" -#include "ThreeDistributionsDoubleGhostLayerFullDirectConnector.h" #include "ThreeDistributionsFullVectorConnector.h" +#include "ThreeDistributionsDoubleGhostLayerFullDirectConnector.h" #include "ThreeDistributionsDoubleGhostLayerFullVectorConnector.h" #include <basics/transmitter/TbTransmitterLocal.h> @@ -60,20 +62,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) { } @@ -159,6 +161,7 @@ void SetConnectorsBlockVisitor<T1, T2>::setRemoteConnectors(SPtr<Block3D> sblock using OneDistributionSetConnectorsBlockVisitor = SetConnectorsBlockVisitor<OneDistributionFullDirectConnector, OneDistributionFullVectorConnector>; using TwoDistributionsSetConnectorsBlockVisitor = SetConnectorsBlockVisitor<TwoDistributionsFullDirectConnector, TwoDistributionsFullVectorConnector>; +using TwoDistributionsDoubleGhostLayerSetConnectorsBlockVisitor = SetConnectorsBlockVisitor<TwoDistributionsDoubleGhostLayerFullDirectConnector, TwoDistributionsDoubleGhostLayerFullVectorConnector>; using ThreeDistributionsSetConnectorsBlockVisitor = SetConnectorsBlockVisitor<ThreeDistributionsFullDirectConnector, ThreeDistributionsFullVectorConnector>; using ThreeDistributionsDoubleGhostLayerSetConnectorsBlockVisitor = SetConnectorsBlockVisitor<ThreeDistributionsDoubleGhostLayerFullDirectConnector, ThreeDistributionsDoubleGhostLayerFullVectorConnector>; diff --git a/src/cpu/VirtualFluidsCore/Visitors/SetInterpolationConnectorsBlockVisitor.cpp b/src/cpu/VirtualFluidsCore/Visitors/SetInterpolationConnectorsBlockVisitor.cpp index 8a83a0c6df6c0b81dfdd98025aca7c8a92959562..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), @@ -343,7 +343,7 @@ void SetInterpolationConnectorsBlockVisitor::setInterpolationConnectors(SPtr<Blo if(fBlockNE) fBlockNERank = fBlockNE->getRank(); int cBlockRank = cBlock->getRank(); - LBMReal omegaF; + LBMReal omegaF {0.0}; if(fBlockSW) omegaF =LBMSystem::calcCollisionFactor(nue, fBlockSW->getLevel()); if(fBlockNW) omegaF =LBMSystem::calcCollisionFactor(nue, fBlockNW->getLevel()); if(fBlockSE) omegaF =LBMSystem::calcCollisionFactor(nue, fBlockSE->getLevel()); 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/pythonbindings/CMakeLists.txt b/src/cpu/pythonbindings/CMakeLists.txt index 4c728febe0e669fa308d45158c7fae4ce3762c05..3b4e7e5a1506899710dc03ea275c0d4ac1cff66d 100644 --- a/src/cpu/pythonbindings/CMakeLists.txt +++ b/src/cpu/pythonbindings/CMakeLists.txt @@ -12,4 +12,5 @@ target_compile_definitions(pymuparser PRIVATE VF_METIS VF_MPI) target_link_libraries(pyfluids PRIVATE simulationconfig VirtualFluidsCore muparser basics) target_link_libraries(pymuparser PRIVATE muparser) - +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/src/cpu/pythonbindings/src/VirtualfluidsModule.cpp b/src/cpu/pythonbindings/src/VirtualfluidsModule.cpp index 61c6005b9fbdd1108d9ffff374763cad95a5c40e..564dc1838d48a92340fa5491779177b299bcb270 100644 --- a/src/cpu/pythonbindings/src/VirtualfluidsModule.cpp +++ b/src/cpu/pythonbindings/src/VirtualfluidsModule.cpp @@ -6,14 +6,17 @@ #include "submodules/simulationparameters.cpp" #include "submodules/writer.cpp" -namespace py = pybind11; - -PYBIND11_MODULE(pyfluids, m) +namespace py_bindings { - makeBoundaryConditionsModule(m); - makeSimulationModule(m); - makeGeometryModule(m); - makeKernelModule(m); - makeParametersModule(m); - makeWriterModule(m); + namespace py = pybind11; + + PYBIND11_MODULE(pyfluids, m) + { + boundaryconditions::makeModule(m); + simulation::makeModule(m); + geometry::makeModule(m); + kernel::makeModule(m); + parameters::makeModule(m); + writer::makeModule(m); + } } \ No newline at end of file diff --git a/src/cpu/pythonbindings/src/submodules/boundaryconditions.cpp b/src/cpu/pythonbindings/src/submodules/boundaryconditions.cpp index ef8b923fd9aa2feea9c81da686df38cb891a4f84..3bff7bc069ca20fe1c0cf3d1847b9714e0381505 100644 --- a/src/cpu/pythonbindings/src/submodules/boundaryconditions.cpp +++ b/src/cpu/pythonbindings/src/submodules/boundaryconditions.cpp @@ -7,56 +7,58 @@ #include <BoundaryConditions/VelocityBCAdapter.h> #include <BoundaryConditions/NoSlipBCAlgorithm.h> #include <BoundaryConditions/VelocityBCAlgorithm.h> +#include <BoundaryConditions/HighViscosityNoSlipBCAlgorithm.h> -namespace py = pybind11; -using namespace py::literals; +namespace boundaryconditions +{ + namespace py = pybind11; + using namespace py::literals; -template<class Adapter> -using py_bc_class = py::class_<Adapter, BCAdapter, std::shared_ptr<Adapter>>; + 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, typename ...Args> -std::shared_ptr<Adapter> create(Args... args) -{ - auto adapter = std::make_shared<Adapter>(args...); - adapter->setBcAlgorithm(std::make_shared<Algorithm>()); - return adapter; -} + template<class adapter, class algorithm> + using bc_class = py::class_<PyBoundaryCondition<adapter, algorithm>, BCAdapter, + std::shared_ptr<PyBoundaryCondition<adapter, algorithm>>>; -template<class Algorithm> -void add_constructors_to_velocity_bc(py_bc_class<VelocityBCAdapter> &cls) -{ - auto firstConstructor = &create<VelocityBCAdapter, Algorithm, bool &, bool &, bool &, mu::Parser &, double &, double &>; - auto secondConstructor = &create<VelocityBCAdapter, Algorithm, - bool &, bool &, bool &, mu::Parser &, mu::Parser &, mu::Parser &, double &, double &>; - auto thirdConstructor = &create<VelocityBCAdapter, Algorithm, - double &, double &, double &, double &, double &, double &, double &, double &, double &>; - - cls.def(py::init(&create<VelocityBCAdapter, Algorithm>)) - .def(py::init(firstConstructor), - "vx1"_a, "vx2"_a, "vx3"_a, "function"_a, "start_time"_a, "end_time"_a) - .def(py::init(secondConstructor), - "vx1"_a, "vx2"_a, "vx3"_a, - "function_vx1"_a, "function_vx2"_a, "function_vx2"_a, - "start_time"_a, "end_time"_a) - .def(py::init(thirdConstructor), - "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); -} - -void makeBoundaryConditionsModule(py::module_ &parentModule) -{ - py::module_ bcModule = parentModule.def_submodule("boundaryconditions"); + void makeModule(py::module_ &parentModule) + { + py::module_ bcModule = parentModule.def_submodule("boundaryconditions"); + + auto _ = py::class_<BCAdapter, std::shared_ptr<BCAdapter>>(bcModule, "BCAdapter"); - py::class_<BCAdapter, std::shared_ptr<BCAdapter>>(bcModule, "BCAdapter"); + bc_class<NoSlipBCAdapter, NoSlipBCAlgorithm>(bcModule, "NoSlipBoundaryCondition") + .def(py::init()); - py_bc_class<NoSlipBCAdapter>(bcModule, "NoSlipBoundaryCondition") - .def(py::init(&create<NoSlipBCAdapter, NoSlipBCAlgorithm>)); + bc_class<NoSlipBCAdapter, HighViscosityNoSlipBCAlgorithm>(bcModule, "HighViscosityNoSlipBoundaryCondition") + .def(py::init()); - auto velocityBoundaryCondition = py_bc_class<VelocityBCAdapter>(bcModule, "VelocityBoundaryCondition"); - add_constructors_to_velocity_bc<VelocityBCAlgorithm>(velocityBoundaryCondition); + 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); - py_bc_class<DensityBCAdapter>(bcModule, "DensityBoundaryCondition") - .def(py::init(&create<DensityBCAdapter, NonReflectingOutflowBCAlgorithm>)); -} + bc_class<DensityBCAdapter, NonReflectingOutflowBCAlgorithm>(bcModule, "NonReflectingOutflow") + .def(py::init()); + } +} \ No newline at end of file diff --git a/src/cpu/pythonbindings/src/submodules/geometry.cpp b/src/cpu/pythonbindings/src/submodules/geometry.cpp index 884ced7b92ddae8a30a8f482e4b22dcbfa37beec..b7ff4dd761258d41687589d2dd89c3479093753e 100644 --- a/src/cpu/pythonbindings/src/submodules/geometry.cpp +++ b/src/cpu/pythonbindings/src/submodules/geometry.cpp @@ -5,76 +5,80 @@ #include <geometry3d/GbLine3D.h> #include <Interactors/Interactor3D.h> -namespace py = pybind11; -template<class GeoObject> -using py_geometry = py::class_<GeoObject, GbObject3D, std::shared_ptr<GeoObject>>; - -std::string GbPoint3D_repr_(const GbPoint3D &instance) +namespace geometry { - std::ostringstream stream; - stream << "<GbPoint3D" - << " x1: " << instance.getX1Coordinate() - << " x2: " << instance.getX2Coordinate() - << " x3: " << instance.getX3Coordinate() << ">"; + namespace py = pybind11; - return stream.str(); -} + template<class GeoObject> + using py_geometry = py::class_<GeoObject, GbObject3D, std::shared_ptr<GeoObject>>; -void makeGeometryModule(py::module_ &parentModule) -{ - py::module geometry = parentModule.def_submodule("geometry"); + 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::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<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__", [&](const GbPoint3D &instance) - { return GbPoint3D_repr_(instance); }); + 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<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_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); + } - 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/src/cpu/pythonbindings/src/submodules/kernel.cpp b/src/cpu/pythonbindings/src/submodules/kernel.cpp index 0e2e23c8c6a8ff56ea01c277e9825e7eb78c5c02..fb291790632cc2041410f60a14fca8d966283343 100644 --- a/src/cpu/pythonbindings/src/submodules/kernel.cpp +++ b/src/cpu/pythonbindings/src/submodules/kernel.cpp @@ -3,39 +3,43 @@ #include <simulationconfig/KernelFactory.h> #include <simulationconfig/KernelConfigStructs.h> - -namespace py = pybind11; - - -void makeKernelModule(py::module_ &parentModule) +namespace kernel { - 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("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; + 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(); + }); + } - return stream.str(); - }); } \ No newline at end of file diff --git a/src/cpu/pythonbindings/src/submodules/simulationconfig.cpp b/src/cpu/pythonbindings/src/submodules/simulationconfig.cpp index a525691bdf8dd9a4a0a3994b607816fba509c7a5..60af4e36af4dca67e9262dd9f5ee1f46d5b7bb58 100644 --- a/src/cpu/pythonbindings/src/submodules/simulationconfig.cpp +++ b/src/cpu/pythonbindings/src/submodules/simulationconfig.cpp @@ -1,18 +1,22 @@ #include <pybind11/pybind11.h> #include <simulationconfig/Simulation.h> -namespace py = pybind11; - -void makeSimulationModule(py::module_ &parentModule) +namespace simulation { - 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); + 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/src/cpu/pythonbindings/src/submodules/simulationparameters.cpp b/src/cpu/pythonbindings/src/submodules/simulationparameters.cpp index f59d1c0ec0473c537f0cc334044bcd113f822687..acc272f2ee412cfbafd9007b4b18610cfd0a1e9b 100644 --- a/src/cpu/pythonbindings/src/submodules/simulationparameters.cpp +++ b/src/cpu/pythonbindings/src/submodules/simulationparameters.cpp @@ -3,54 +3,57 @@ #include <complex> #include <simulationconfig/SimulationParameters.h> -namespace py = pybind11; - -void makeParametersModule(py::module_ &parentModule) +namespace parameters { - 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); - + 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/src/cpu/pythonbindings/src/submodules/writer.cpp b/src/cpu/pythonbindings/src/submodules/writer.cpp index 40819e4766eb30a442967067f954fef5508a4707..d5ec527a27caf63d9a3066c51e1f675b307fe0b2 100644 --- a/src/cpu/pythonbindings/src/submodules/writer.cpp +++ b/src/cpu/pythonbindings/src/submodules/writer.cpp @@ -1,18 +1,21 @@ #include <pybind11/pybind11.h> #include <simulationconfig/WriterConfiguration.h> -namespace py = pybind11; - -void makeWriterModule(py::module_ &parentModule) +namespace writer { - py::module writerModule = parentModule.def_submodule("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::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); + 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/src/cpu/simulationconfig/CMakeLists.txt b/src/cpu/simulationconfig/CMakeLists.txt index 2e5e7f2eb9cba467e1ecbe3ec9cea13b3a3f322d..95ee969a049fd65cfadc6cc95d814e788a02aa8e 100644 --- a/src/cpu/simulationconfig/CMakeLists.txt +++ b/src/cpu/simulationconfig/CMakeLists.txt @@ -1,20 +1,8 @@ -cmake_minimum_required(VERSION 3.1) project(simulationconfig) -set(VFBUILDER_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/include) -file(GLOB HEADERS - ${VFBUILDER_INCLUDE_DIR}/simulationconfig/*.h - ${VFBUILDER_INCLUDE_DIR}/simulationconfig/boundaryconditions/*.h) +vf_add_library(NAME simulationconfig PUBLIC_LINK VirtualFluidsCore basics muparser) -file(GLOB SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp) - -add_library(simulationconfig STATIC ${SRC} ${HEADERS}) - -set_target_properties(simulationconfig PROPERTIES CXX_STANDARD 14 POSITION_INDEPENDENT_CODE ON) - -target_include_directories(simulationconfig PUBLIC ${VFBUILDER_INCLUDE_DIR}) -target_link_libraries(simulationconfig PRIVATE VirtualFluidsCore basics muparser) -target_compile_definitions(simulationconfig PRIVATE VF_METIS VF_MPI) -target_include_directories(simulationconfig PUBLIC ${CMAKE_BINARY_DIR}) +set_target_properties(simulationconfig PROPERTIES POSITION_INDEPENDENT_CODE ON) +target_include_directories(simulationconfig PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include) diff --git a/src/cpu/simulationconfig/include/simulationconfig/AbstractLBMSystem.h b/src/cpu/simulationconfig/include/simulationconfig/AbstractLBMSystem.h index 0c3ac72db2d3cb3488860227171f2fd27600c028..156649c6fd3c060117e8247efab2765f56f7c77b 100644 --- a/src/cpu/simulationconfig/include/simulationconfig/AbstractLBMSystem.h +++ b/src/cpu/simulationconfig/include/simulationconfig/AbstractLBMSystem.h @@ -7,6 +7,8 @@ class AbstractLBMSystem { public: + virtual ~AbstractLBMSystem() = default; + virtual int getNumberOfDirections() = 0; virtual std::shared_ptr<Interactor3D> makeInteractor() = 0; diff --git a/src/cpu/simulationconfig/include/simulationconfig/KernelFactory.h b/src/cpu/simulationconfig/include/simulationconfig/KernelFactory.h index 6b151d96f9c538bcfbf3aeb693afd56e36e6cf35..6f984849bea91a832d0d778107feacb3cfdbdca6 100644 --- a/src/cpu/simulationconfig/include/simulationconfig/KernelFactory.h +++ b/src/cpu/simulationconfig/include/simulationconfig/KernelFactory.h @@ -20,6 +20,7 @@ public: }; KernelFactory() = default; + virtual ~KernelFactory() = default; std::shared_ptr<LBMKernel> makeKernel(KernelType kernelType); diff --git a/src/cpu/simulationconfig/include/simulationconfig/Simulation.h b/src/cpu/simulationconfig/include/simulationconfig/Simulation.h index 47f8b0e6ef1c844a70efcf0faedd5cbcdb7dbc05..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; @@ -63,7 +65,9 @@ public: void run(); private: - std::shared_ptr<GbObject3D> makeSimulationBoundingBox() const; + bool isMainProcess(); + + std::shared_ptr<GbObject3D> makeSimulationBoundingBox(); void writeBlocksToFile() const; @@ -84,6 +88,12 @@ private: void setKernelForcing(const std::shared_ptr<LBMKernel> &kernel, std::shared_ptr<LBMUnitConverter> &converter) const; + + void setConnectors(); + + void initializeDistributions(); + + std::shared_ptr<CoProcessor> makeNupsCoProcessor() const; }; #endif \ No newline at end of file diff --git a/src/cpu/simulationconfig/src/Simulation.cpp b/src/cpu/simulationconfig/src/Simulation.cpp index 6d80a1cfa2cc62d2575d1e8f67193b879f217b90..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(); @@ -65,6 +65,8 @@ Simulation::addObject(const std::shared_ptr<GbObject3D> &object, const std::shar const bool is_in = registeredAdapters.find(bcAdapter) != registeredAdapters.end(); if (!is_in) addBCAdapter(bcAdapter); this->interactors.push_back(lbmSystem->makeInteractor(object, this->grid, bcAdapter, state)); + if (communicator->getProcessID() != 0) return; + GbSystem3D::writeGeoObject(object, writerConfig.outputPath + folderPath, writerConfig.getWriter()); } @@ -99,19 +101,20 @@ void Simulation::run() grid->setPeriodicX2(gridParameters->periodicBoundaryInX2); grid->setPeriodicX3(gridParameters->periodicBoundaryInX3); - int &numberOfNodesInReferenceDirection = gridParameters->numberOfNodesPerDirection[gridParameters->referenceDirectionIndex]; + //int &numberOfNodesInReferenceDirection = gridParameters->numberOfNodesPerDirection[gridParameters->referenceDirectionIndex]; std::shared_ptr<LBMUnitConverter> converter = makeLBMUnitConverter(); int &nodesInX1 = gridParameters->numberOfNodesPerDirection[0]; int &nodesInX2 = gridParameters->numberOfNodesPerDirection[1]; int &nodesInX3 = gridParameters->numberOfNodesPerDirection[2]; - logSimulationData(nodesInX1, nodesInX2, nodesInX3); + + if (isMainProcess()) + logSimulationData(nodesInX1, nodesInX2, nodesInX3); setBlockSize(nodesInX1, nodesInX2, nodesInX3); auto gridCube = makeSimulationBoundingBox(); generateBlockGrid(gridCube); - setKernelForcing(lbmKernel, converter); setBoundaryConditionProcessor(lbmKernel); @@ -125,55 +128,44 @@ void Simulation::run() intHelper.selectBlocks(); - int numberOfProcesses = communicator->getNumberOfProcesses(); SetKernelBlockVisitor kernelVisitor(lbmKernel, physicalParameters->latticeViscosity, numberOfProcesses); grid->accept(kernelVisitor); intHelper.setBC(); - double bulkViscosity = physicalParameters->latticeViscosity * physicalParameters->bulkViscosityFactor; - //auto iProcessor = std::make_shared<CompressibleOffsetMomentsInterpolationProcessor>(); - //iProcessor->setBulkViscosity(physicalParameters->latticeViscosity, bulkViscosity); - - //SetConnectorsBlockVisitor setConnsVisitor(communicator, true, - // lbmSystem->getNumberOfDirections(), - // physicalParameters->latticeViscosity, iProcessor); - OneDistributionSetConnectorsBlockVisitor setConnsVisitor(communicator); - grid->accept(setConnsVisitor); - - InitDistributionsBlockVisitor initVisitor; - grid->accept(initVisitor); - grid->accept(setConnsVisitor); + writeBlocksToFile(); // important: run this after metis & intHelper.selectBlocks() + setConnectors(); + initializeDistributions(); grid->accept(bcVisitor); - writeBoundaryConditions(); - // important: run this after metis & intHelper.selectBlocks() - writeBlocksToFile(); + +#ifdef _OPENMP + omp_set_num_threads(simulationParameters->numberOfThreads); + if (isMainProcess()) + UBLOG(logINFO, "OpenMP is set to run with " << simulationParameters->numberOfThreads << " threads") +#endif auto visualizationScheduler = std::make_shared<UbScheduler>(simulationParameters->timeStepLogInterval); auto mqCoProcessor = makeMacroscopicQuantitiesCoProcessor(converter, visualizationScheduler); - std::shared_ptr<UbScheduler> nupsScheduler(new UbScheduler(100, 100)); - std::shared_ptr<CoProcessor> nupsCoProcessor( - new NUPSCounterCoProcessor(grid, nupsScheduler, simulationParameters->numberOfThreads, communicator)); - - -#ifdef _OPENMP - omp_set_num_threads(simulationParameters->numberOfThreads); - UBLOG(logINFO, "OpenMP is set to run with " << omp_get_num_threads() << " threads") -#endif + auto nupsCoProcessor = makeNupsCoProcessor(); auto calculator = std::make_shared<BasicCalculator>(grid, visualizationScheduler, simulationParameters->numberOfTimeSteps); calculator->addCoProcessor(nupsCoProcessor); calculator->addCoProcessor(mqCoProcessor); - UBLOG(logINFO, "Simulation-start") + if (isMainProcess()) UBLOG(logINFO, "Simulation-start") calculator->calculate(); - UBLOG(logINFO, "Simulation-end") + if (isMainProcess()) UBLOG(logINFO, "Simulation-end") +} + +bool Simulation::isMainProcess() +{ + return communicator->getProcessID() == 0; } void @@ -224,18 +216,7 @@ Simulation::makeLBMUnitConverter() return std::make_shared<LBMUnitConverter>(); } -std::shared_ptr<CoProcessor> -Simulation::makeMacroscopicQuantitiesCoProcessor(const std::shared_ptr<LBMUnitConverter> &converter, - const std::shared_ptr<UbScheduler> &visualizationScheduler) const -{ - auto mqCoProcessor = std::make_shared<WriteMacroscopicQuantitiesCoProcessor>(grid, visualizationScheduler, - writerConfig.outputPath, - writerConfig.getWriter(), - converter, - communicator); - mqCoProcessor->process(0); - return mqCoProcessor; -} + void Simulation::writeBoundaryConditions() const { @@ -248,8 +229,9 @@ void Simulation::writeBoundaryConditions() const void Simulation::writeBlocksToFile() const { UBLOG(logINFO, "Write block grid to VTK-file") + auto scheduler = std::make_shared<UbScheduler>(1); auto ppblocks = std::make_shared<WriteBlocksCoProcessor>(grid, - std::make_shared<UbScheduler>(1), + scheduler, writerConfig.outputPath, writerConfig.getWriter(), communicator); @@ -258,17 +240,56 @@ void Simulation::writeBlocksToFile() const } std::shared_ptr<GbObject3D> -Simulation::makeSimulationBoundingBox() const +Simulation::makeSimulationBoundingBox() { auto box = gridParameters->boundingBox(); + auto gridCube = std::make_shared<GbCuboid3D>(box->minX1, box->minX2, box->minX3, box->maxX1, box->maxX2, + box->maxX3); - UBLOG(logINFO, "Bounding box dimensions = [(" - << box->minX1 << ", " << box->minX2 << ", " << box->minX3 << "); (" - << box->maxX1 << ", " << box->maxX2 << ", " << box->maxX3 << ")]") + if (isMainProcess()) + { + UBLOG(logINFO, "Bounding box dimensions = [(" + << box->minX1 << ", " << box->minX2 << ", " << box->minX3 << "); (" + << box->maxX1 << ", " << box->maxX2 << ", " << box->maxX3 << ")]") + + GbSystem3D::writeGeoObject(gridCube.get(), writerConfig.outputPath + "/geo/gridCube", writerConfig.getWriter()); + } - auto gridCube = std::make_shared<GbCuboid3D>(box->minX1, box->minX2, box->minX3, box->maxX1, box->maxX2, box->maxX3); - GbSystem3D::writeGeoObject(gridCube.get(), writerConfig.outputPath + "/geo/gridCube", writerConfig.getWriter()); return gridCube; } +void Simulation::setConnectors() +{ + OneDistributionSetConnectorsBlockVisitor setConnsVisitor(communicator); + grid->accept(setConnsVisitor); +} + +void Simulation::initializeDistributions() +{ + InitDistributionsBlockVisitor initVisitor; + grid->accept(initVisitor); +} + +std::shared_ptr<CoProcessor> +Simulation::makeMacroscopicQuantitiesCoProcessor(const std::shared_ptr<LBMUnitConverter> &converter, + const std::shared_ptr<UbScheduler> &visualizationScheduler) const +{ + auto mqCoProcessor = std::make_shared<WriteMacroscopicQuantitiesCoProcessor>(grid, visualizationScheduler, + writerConfig.outputPath, + writerConfig.getWriter(), + converter, + communicator); + mqCoProcessor->process(0); + return mqCoProcessor; +} + +std::shared_ptr<CoProcessor> Simulation::makeNupsCoProcessor() const +{ + auto scheduler = std::make_shared<UbScheduler>(100, 100); + return std::make_shared<NUPSCounterCoProcessor>(grid, scheduler, + simulationParameters->numberOfThreads, + communicator); +} + + Simulation::~Simulation() = default; diff --git a/src/cuda/CMakeLists.txt b/src/cuda/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..b3b37b213cab4bf0e562438264d5fea6eb4dc7b3 --- /dev/null +++ b/src/cuda/CMakeLists.txt @@ -0,0 +1,3 @@ +project(cuda LANGUAGES CUDA CXX) + +vf_add_library(NAME 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 93% rename from src/gpu/VirtualFluids_GPU/LBM/CudaTimer.cpp rename to src/cuda/CudaTimer.cpp index d5459376a85c72de30b9b5de83c5d0075b28e5f0..97a2c0977058b712ab345f6d2c1299b3e2448198 100644 --- a/src/gpu/VirtualFluids_GPU/LBM/CudaTimer.cpp +++ b/src/cuda/CudaTimer.cpp @@ -1,11 +1,7 @@ #include "CudaTimer.h" -CudaTimer::CudaTimer() +namespace vf::cuda { - sdkTimer = 0; - ftimeE = 0.0f; - ftimeS = 0.0f; -} void CudaTimer::createSdkTimer() { @@ -56,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 80% rename from src/gpu/VirtualFluids_GPU/LBM/CudaTimer.h rename to src/cuda/CudaTimer.h index c77f5eafa48d9179baafe0ff0b89bc8629c8e067..51193c2f73959e31dab8661a952756f2d0882e06 100644 --- a/src/gpu/VirtualFluids_GPU/LBM/CudaTimer.h +++ b/src/cuda/CudaTimer.h @@ -1,17 +1,17 @@ -#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 { public: - CudaTimer(); - void createSdkTimer(); void startSdkTimer(); void stopSdkTimer(float &timeSinceLastStop,double &totalTime); @@ -24,12 +24,14 @@ public: private: StopWatchInterface *sdkTimer; - double ftimeS; + double ftimeS = {0.0}; cudaEvent_t stop_t; cudaEvent_t start_t; - double ftimeE; + double ftimeE {0.0}; }; +} + #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/BoundaryCondition.cpp b/src/gpu/GksGpu/BoundaryConditions/BoundaryCondition.cpp index 1fca7d9b3bbf26bcec8c13876a760b6758f92670..fb1ddb1ff7db9d1b6da0115a25aab87f029537fc 100644 --- a/src/gpu/GksGpu/BoundaryConditions/BoundaryCondition.cpp +++ b/src/gpu/GksGpu/BoundaryConditions/BoundaryCondition.cpp @@ -11,6 +11,8 @@ #include "DataBase/DataBaseAllocator.h" #include "DataBase/DataBaseStruct.h" +using namespace vf::gpu; + namespace GksGpu{ BoundaryCondition::BoundaryCondition( SPtr<DataBase> dataBase ) 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 2d2641e36ae26c0581f8de2563bcbcce8be619fa..8d032dfeead2f582c5af2426c45b09ead33883cc 100644 --- a/src/gpu/GksMeshAdapter/GksMeshAdapter.cpp +++ b/src/gpu/GksMeshAdapter/GksMeshAdapter.cpp @@ -22,6 +22,12 @@ #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) : gridBuilder(gridBuilder) {} @@ -516,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++ ) { @@ -525,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/GksMeshAdapter/MeshCell.cpp b/src/gpu/GksMeshAdapter/MeshCell.cpp index 65a931c84deca244abf78e100bb838dd9c1870f3..349d308ee498e89f9705091c72d3ca7013bf3d4e 100644 --- a/src/gpu/GksMeshAdapter/MeshCell.cpp +++ b/src/gpu/GksMeshAdapter/MeshCell.cpp @@ -34,6 +34,8 @@ #include "GridGenerator/grid/NodeValues.h" +using namespace vf::gpu; + MeshCell::MeshCell(){ level = INVALID_INDEX; 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 29d77897ac4e6138057ec2b4f13f5f942bdb0e01..07b6125d6ecd83dca59e20e7c286ebc2b8d14715 100644 --- a/src/gpu/GridGenerator/CMakeLists.txt +++ b/src/gpu/GridGenerator/CMakeLists.txt @@ -1,16 +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) - -# according to linker error when building static libraries. -# https://stackoverflow.com/questions/50033435/cmake-cuda-separate-compilation-static-lib-link-error-on-windows-but-not-on-ubun -if (NOT BUILD_SHARED_LIBRARY) - set_target_properties(${library_name} PROPERTIES CUDA_RESOLVE_DEVICE_SYMBOLS ON) -endif() - -# 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 23d7c92ab826a7b560c248c4ca51cca831e5ca1f..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" @@ -13,6 +45,8 @@ #include "grid/Grid.h" #include "grid/NodeValues.h" +using namespace vf::gpu; + Street::Street(real xStartCell, real yStartCell, real xEndCell, real yEndCell, real dx) { real length = std::sqrt((xEndCell - xStartCell)*(xEndCell - xStartCell) 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..ef145b7def48803b7e2d043f7a5862ee21f954c4 100644 --- a/src/gpu/GridGenerator/geometries/Arrow/ArrowImp.h +++ b/src/gpu/GridGenerator/geometries/Arrow/ArrowImp.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 ArrowImp.h +//! \ingroup geometries +//! \author Soeren Peters, Stephan Lenz +//======================================================================================= #ifndef ArrowImp_H #define ArrowImp_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..e64a202ca9bcd5a33fcc9ba85e7bd35fa67a1d4e --- /dev/null +++ b/src/gpu/GridGenerator/geometries/Cuboid/Cuboid.cpp @@ -0,0 +1,153 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// 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/Point/Point.h b/src/gpu/GridGenerator/geometries/Point/Point.h deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 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..ba5821f5bfed5b4d25c1ee3c5abecb168db462e7 100644 --- a/src/gpu/GridGenerator/geometries/Sphere/Sphere.h +++ b/src/gpu/GridGenerator/geometries/Sphere/Sphere.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 Sphere.h +//! \ingroup geometries +//! \author Soeren Peters, Stephan Lenz +//======================================================================================= #ifndef SPHERE_H #define SPHERE_H @@ -14,12 +40,12 @@ 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 +57,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 59% rename from src/gpu/GridGenerator/geometries/Triangle/Triangle.cu rename to src/gpu/GridGenerator/geometries/Triangle/Triangle.cpp index f38eff75ad156daac4d44ce869485319ce305d17..bf272b9e7f46c413ae6edce62c05d1be20d327de 100644 --- a/src/gpu/GridGenerator/geometries/Triangle/Triangle.cu +++ b/src/gpu/GridGenerator/geometries/Triangle/Triangle.cpp @@ -1,15 +1,48 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// 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" #include "grid/NodeValues.h" -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(){} +using namespace vf::gpu; -HOSTDEVICE void Triangle::set(const Vertex &v1, const Vertex &v2, const Vertex &v3) +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(){} + +void Triangle::set(const Vertex &v1, const Vertex &v2, const Vertex &v3) { this->v1 = v1; this->v2 = v2; @@ -17,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; @@ -27,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; @@ -39,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; @@ -47,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)) @@ -76,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); @@ -124,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); @@ -145,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; @@ -233,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)) @@ -248,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 @@ -293,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(); @@ -305,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..0017d2f71145f2608976a95018816bf81cef44b7 100644 --- a/src/gpu/GridGenerator/geometries/Triangle/Triangle.h +++ b/src/gpu/GridGenerator/geometries/Triangle/Triangle.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 Triangle.h +//! \ingroup geometries +//! \author Soeren Peters, Stephan Lenz +//======================================================================================= #ifndef Triangle_h #define Triangle_h @@ -17,16 +49,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 +68,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 4fcf93ef44912ce36aafd026992f77f088774f4e..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" @@ -15,6 +47,8 @@ #include "utilities/transformator/TransformatorImp.h" +using namespace vf::gpu; + TriangularMesh* TriangularMesh::make(const std::string& fileName, const std::vector<uint> ignorePatches) { @@ -94,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; @@ -114,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; @@ -128,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); @@ -242,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..2d31de98bf1f5530ada555e548ac6bb40e5e51b7 100644 --- a/src/gpu/GridGenerator/geometries/TriangularMesh/TriangularMesh.h +++ b/src/gpu/GridGenerator/geometries/TriangularMesh/TriangularMesh.h @@ -1,8 +1,39 @@ -#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> @@ -28,7 +59,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 +73,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 +89,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 +100,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 e3b5a7c4f0c92cb3f31df4fd0cd4697a7000a34d..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" @@ -10,6 +42,8 @@ #include "grid/GridImp.h" #include "grid/NodeValues.h" +using namespace vf::gpu; + void TriangularMeshDiscretizationStrategy::removeOddBoundaryCellNodes(GridImp* grid) { #pragma omp parallel for @@ -246,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) @@ -257,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; @@ -269,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..573a464844ac769ebd1127c666481b87f363099f 100644 --- a/src/gpu/GridGenerator/geometries/TriangularMesh/TriangularMeshStrategy.h +++ b/src/gpu/GridGenerator/geometries/TriangularMesh/TriangularMeshStrategy.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 TriangularMeshStrategy.h +//! \ingroup geometries +//! \author Soeren Peters, Stephan Lenz +//======================================================================================= #ifndef TriangularMeshStrategy_H #define TriangularMeshStrategy_H @@ -53,13 +85,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..b0dda279c5f95a621b5875e78b5cdb7479b98a54 100644 --- a/src/gpu/GridGenerator/geometries/TriangularMesh/triangleNeighborFinder/TriangleNeighborFinder.h +++ b/src/gpu/GridGenerator/geometries/TriangularMesh/triangleNeighborFinder/TriangleNeighborFinder.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 TriangleNeighborFinder.h +//! \ingroup geometries +//! \author Soeren Peters, Stephan Lenz +//======================================================================================= #ifndef TriangleNeighborFinder_h #define TriangleNeighborFinder_h 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 cabbc21c92113b490d31b6e6ae9ad834b41fd44b..7b27d853f652459143699204c59a5843de6eaf39 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 "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..24d9383bf5628e46b1d634874f79ceb73eaa6cae 100644 --- a/src/gpu/GridGenerator/geometries/VerticalCylinder/VerticalCylinder.h +++ b/src/gpu/GridGenerator/geometries/VerticalCylinder/VerticalCylinder.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 VerticalCylinder.h +//! \ingroup geometries +//! \author Soeren Peters, Stephan Lenz +//======================================================================================= #ifndef VERTICAL_CYLINDER_H #define VERTICAL_CYLINDER_H @@ -14,12 +40,12 @@ 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 +57,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..8930bdf3b165b4e0dbb497773fd0b6cf6ec6f8f7 100644 --- a/src/gpu/GridGenerator/grid/BoundaryConditions/BoundaryCondition.cpp +++ b/src/gpu/GridGenerator/grid/BoundaryConditions/BoundaryCondition.cpp @@ -1,24 +1,57 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// 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]); } } diff --git a/src/gpu/GridGenerator/grid/BoundaryConditions/BoundaryCondition.h b/src/gpu/GridGenerator/grid/BoundaryConditions/BoundaryCondition.h index dd3837e4d12b4064b4499c5d9cdca4d7ad84c643..9ae5f09e208e92213ca90ff75f095eddd5dbeaf1 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) @@ -51,7 +87,7 @@ protected: public: char getType() const override { - return BC_PRESSURE; + return vf::gpu::BC_PRESSURE; } real getRho() @@ -62,7 +98,47 @@ 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 VelocityBoundaryCondition : public gg ::BoundaryCondition { public: static SPtr<VelocityBoundaryCondition> make(real vx, real vy, real vz) @@ -78,7 +154,7 @@ protected: public: virtual char getType() const override { - return BC_VELOCITY; + return vf::gpu::BC_VELOCITY; } void fillVelocityLists() @@ -98,8 +174,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 ); }; ////////////////////////////////////////////////////////////////////////// @@ -119,7 +195,7 @@ private: public: char getType() const override { - return BC_SOLID; + return vf::gpu::BC_SOLID; } void setVelocityForPatch( uint patch, real vx, real vy, real vz ){ diff --git a/src/gpu/GridGenerator/grid/BoundaryConditions/Side.cpp b/src/gpu/GridGenerator/grid/BoundaryConditions/Side.cpp index 00ac6b3ddf7ac4d63dbdbf299d56f8126d6abdc6..02d61a83456090a3b96b207de5761b70d9b30fca 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,6 +38,8 @@ #include "utilities/math/Math.h" +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) { @@ -15,11 +49,11 @@ 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); @@ -67,36 +101,15 @@ void Side::setQs(SPtr<Grid> grid, SPtr<BoundaryCondition> boundaryCondition, uin real x,y,z; grid->transIndexToCoords( index, x, y, z ); - real coords[3] = {x,y,z}; - - real neighborX = x + grid->getDirection()[dir * DIMENSION + 0] * grid->getDelta(); - real neighborY = y + grid->getDirection()[dir * DIMENSION + 1] * grid->getDelta(); - 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( neighborX > x ) neighborX = grid->getFirstFluidNode( coords, 0, grid->getStartX() ); - else neighborX = grid->getLastFluidNode ( coords, 0, grid->getEndX() ); - } + x += grid->getDirection()[dir * DIMENSION + 0] * grid->getDelta(); + y += grid->getDirection()[dir * DIMENSION + 1] * grid->getDelta(); + z += grid->getDirection()[dir * DIMENSION + 2] * grid->getDelta(); - if( grid->getPeriodicityY() && grid->getFieldEntry( grid->transCoordToIndex( x, neighborY, z ) ) == STOPPER_OUT_OF_GRID_BOUNDARY ) - { - if( neighborY > y ) neighborY = grid->getFirstFluidNode( coords, 1, grid->getStartY() ); - else neighborY = grid->getLastFluidNode ( coords, 1, grid->getEndY() ); - } + uint neighborIndex = grid->transCoordToIndex( x, y, z ); - if( grid->getPeriodicityZ() && grid->getFieldEntry( grid->transCoordToIndex( x, y, neighborZ ) ) == 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; @@ -117,47 +130,6 @@ uint Side::getIndex(SPtr<Grid> grid, std::string coord, real constant, real v1, } -void Geometry::addIndices(std::vector<SPtr<Grid> > grids, uint level, SPtr<BoundaryCondition> boundaryCondition) -{ - auto geometryBoundaryCondition = std::dynamic_pointer_cast<GeometryBoundaryCondition>(boundaryCondition); - - std::vector<real> qNode(grids[level]->getEndDirection() + 1); - - for (uint index = 0; index < grids[level]->getSize(); index++) - { - if (grids[level]->getFieldEntry(index) != BC_SOLID) - continue; - - for (int dir = 0; dir <= grids[level]->getEndDirection(); dir++) - { - const real q = grids[level]->getQValue(index, dir); - - qNode[dir] = q; - - // also the neighbor if any Qs are required - 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( 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 ) ) - qNode[dir] = 0.5; - } - - geometryBoundaryCondition->indices.push_back(index); - geometryBoundaryCondition->qs.push_back(qNode); - geometryBoundaryCondition->patches.push_back( grids[level]->getQPatch(index) ); - } -} - - - void MX::addIndices(std::vector<SPtr<Grid> > grid, uint level, SPtr<BoundaryCondition> boundaryCondition) { real startInner = grid[level]->getStartY(); diff --git a/src/gpu/GridGenerator/grid/BoundaryConditions/Side.h b/src/gpu/GridGenerator/grid/BoundaryConditions/Side.h index 13522cf2e9802f8bb4ad5f02ef0ca87fa1a56336..260bc18967296e63cc21fc0454c86cdcb65e8719 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,42 +73,21 @@ 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 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); }; -class Geometry : public Side -{ -public: - void addIndices(std::vector<SPtr<Grid> > grid, uint level, SPtr<BoundaryCondition> boundaryCondition) override; - - int getCoordinate() const override - { - return X_INDEX; - } - - int getDirection() const override - { - return NEGATIVE_DIR; - } - - SideType whoAmI() const override - { - return SideType::GEOMETRY; - } -}; - 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 +108,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 +130,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 +151,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 +173,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 +194,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 { @@ -219,7 +233,7 @@ public: case SideType::PZ: return SPtr<Side>(new PZ()); case SideType::GEOMETRY: - return SPtr<Side>(new Geometry()); + throw std::runtime_error("SideFactory::make() - SideType::GEOMETRY not supported."); default: throw std::runtime_error("SideFactory::make() - SideType not valid."); } diff --git a/src/gpu/GridGenerator/grid/Cell.h b/src/gpu/GridGenerator/grid/Cell.h index 845e02eaa66a5b2327b5a2ba63b1227962ab8f61..a7a64917025742217be88e7ebe1ccc9e669fc7c0 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 "global.h" -#include "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..d8ac2a80ea6fc5da879c5378aac2eab70016ff72 --- /dev/null +++ b/src/gpu/GridGenerator/grid/Field.cpp @@ -0,0 +1,177 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// 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::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; +} + +// --------------------------------------------------------- // +// 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 9107e3942e1795d3c32ed9ffb200a6dac7c91bac..0000000000000000000000000000000000000000 --- a/src/gpu/GridGenerator/grid/Field.cu +++ /dev/null @@ -1,154 +0,0 @@ -#include "Field.h" - -#include "grid/NodeValues.h" -#include "grid/GridStrategy/GridStrategy.h" - -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::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 f79797afab158f0f80d515f2aa38ed8b91438dc2..002c8c108bd405f4077cd2779f5e59232135ace9 100644 --- a/src/gpu/GridGenerator/grid/Field.h +++ b/src/gpu/GridGenerator/grid/Field.h @@ -1,54 +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 Field.h +//! \ingroup grid +//! \author Soeren Peters, Stephan Lenz, Martin Schoenherr +//======================================================================================= #ifndef FIELD_H #define FIELD_H #include "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 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 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 f6c17551e170a78376b5e0d4075895c710651ead..3407b23c1efbb4143d06ded7880c26d7c0eb6599 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,121 +51,119 @@ 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; + virtual void getGridInterfaceIndices(uint* iCellCfc, uint* iCellCff, uint* iCellFcc, uint* iCellFcf) 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 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 uint getSendIndex(int direction, uint index) = 0; + virtual uint getReceiveIndex(int direction, uint index) = 0; virtual void repairCommunicationInices(int direction) = 0; diff --git a/src/gpu/GridGenerator/grid/GridBuilder/GridBuilder.h b/src/gpu/GridGenerator/grid/GridBuilder/GridBuilder.h index 8136bd38d97820955be5b1210293b6abcd4b64ff..57290025c3f6e48554e1dafe9bd101ae237b3288 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 @@ -5,7 +37,7 @@ #include <string> #include <memory> -#include "global.h" +#include "GridGenerator/global.h" #define GEOMQS 6 #define INLETQS 0 @@ -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,30 +94,34 @@ 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 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 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 diff --git a/src/gpu/GridGenerator/grid/GridBuilder/LevelGridBuilder.cpp b/src/gpu/GridGenerator/grid/GridBuilder/LevelGridBuilder.cpp index 1a81f71fbda0ecd5a87c86f82fa06f89aab0e151..20c285c13aa2c7644fc1ac6ea6a87b5d8dc7f72c 100644 --- a/src/gpu/GridGenerator/grid/GridBuilder/LevelGridBuilder.cpp +++ b/src/gpu/GridGenerator/grid/GridBuilder/LevelGridBuilder.cpp @@ -1,36 +1,65 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// 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> #include <iostream> #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 -LevelGridBuilder::LevelGridBuilder(Device device, const std::string& d3qxx) : device(device), d3qxx(d3qxx) +using namespace vf::gpu; + +LevelGridBuilder::LevelGridBuilder() { this->communicationProcesses[CommunicationDirections::MX] = INVALID_INDEX; this->communicationProcesses[CommunicationDirections::PX] = INVALID_INDEX; @@ -40,33 +69,41 @@ 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) { - return SPtr<LevelGridBuilder>(new LevelGridBuilder(device, d3qxx)); + 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::setVelocityBoundaryCondition(SideType sideType, real vx, real vy, real vz) { - if (sideType == SideType::GEOMETRY) - setVelocityGeometryBoundaryCondition(vx, vy, vz); - else - { - for (uint level = 0; level < getNumberOfGridLevels(); level++) - { - SPtr<VelocityBoundaryCondition> velocityBoundaryCondition = VelocityBoundaryCondition::make(vx, vy, vz); + SPtr<VelocityBoundaryCondition> velocityBoundaryCondition = VelocityBoundaryCondition::make(vx, vy, vz); - auto side = SideFactory::make(sideType); + auto side = SideFactory::make(sideType); - velocityBoundaryCondition->side = side; - velocityBoundaryCondition->side->addIndices(grids, level, velocityBoundaryCondition); + velocityBoundaryCondition->side = side; + velocityBoundaryCondition->side->addIndices(grids, 0, velocityBoundaryCondition); - velocityBoundaryCondition->fillVelocityLists(); + velocityBoundaryCondition->fillVelocityLists(); - boundaryConditions[level]->velocityBoundaryConditions.push_back(velocityBoundaryCondition); + boundaryConditions[0]->velocityBoundaryConditions.push_back(velocityBoundaryCondition); - *logging::out << logging::Logger::INFO_INTERMEDIATE << "Set Velocity BC on level " << level << " with " << (int)velocityBoundaryCondition->indices.size() <<"\n"; - } - } + *logging::out << logging::Logger::INFO_INTERMEDIATE << "Set Velocity BC on level " << 0 << " with " << (int)velocityBoundaryCondition->indices.size() <<"\n"; } void LevelGridBuilder::setVelocityGeometryBoundaryCondition(real vx, real vy, real vz) @@ -128,8 +165,8 @@ void LevelGridBuilder::setNoSlipBoundaryCondition(SideType sideType) 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) @@ -142,19 +179,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) @@ -171,7 +195,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())); @@ -290,66 +314,77 @@ void LevelGridBuilder::getNodeValues(real *xCoords, real *yCoords, real *zCoords grids[level]->getNodeValues(xCoords, yCoords, zCoords, neighborX, neighborY, neighborZ, neighborNegative, geo); } -//TODO: add getSlipSize... - -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::getVelocitySize(int level) const { uint size = 0; - for (auto boundaryCondition : boundaryConditions[level]->pressureBoundaryConditions) + for (auto boundaryCondition : boundaryConditions[level]->velocityBoundaryConditions) { size += uint(boundaryCondition->indices.size()); } return size; } -void LevelGridBuilder::getPressureValues(real* rho, int* indices, int* neighborIndices, int level) const +void LevelGridBuilder::getVelocityValues(real* vx, real* vy, real* vz, int* indices, int level) const { int allIndicesCounter = 0; - for (auto boundaryCondition : boundaryConditions[level]->pressureBoundaryConditions) + for (auto boundaryCondition : boundaryConditions[level]->velocityBoundaryConditions) { - for (std::size_t i = 0; i < boundaryCondition->indices.size(); i++) + for(std::size_t i = 0; i < boundaryCondition->indices.size(); i++) { - indices[allIndicesCounter] = grids[level]->getSparseIndex(boundaryCondition->indices[i]) + 1; - - neighborIndices[allIndicesCounter] = grids[level]->getSparseIndex(boundaryCondition->neighborIndices[i]) + 1; + indices[allIndicesCounter] = grids[level]->getSparseIndex(boundaryCondition->indices[i]) +1; - rho[allIndicesCounter] = boundaryCondition->rho; + 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 { int allIndicesCounter = 0; @@ -360,23 +395,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++; } } @@ -392,29 +438,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) @@ -436,7 +465,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++) @@ -447,7 +475,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++) @@ -459,28 +486,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 8bfb201c54689411a1c4ea56617f7f009dfb4b4f..f2325435d99140f33eee9844c13908de87788558 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 @@ -10,7 +42,6 @@ #include "grid/GridBuilder/GridBuilder.h" #include "grid/Grid.h" -#include "grid/GridInterface.h" #include "grid/NodeValues.h" struct Vertex; @@ -19,10 +50,10 @@ class Transformator; class ArrowTransformator; class PolyDataWriterWrapper; class BoundingBox; -enum class Device; class Side; class VelocityBoundaryCondition; +class SlipBoundaryCondition; class PressureBoundaryCondition; class GeometryBoundaryCondition; enum class SideType; @@ -32,22 +63,22 @@ 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 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); @@ -55,7 +86,6 @@ public: GRIDGENERATOR_EXPORT virtual std::shared_ptr<Grid> getGrid(int level, int box); - GRIDGENERATOR_EXPORT virtual unsigned int getNumberOfNodes(unsigned int level) const override; @@ -65,23 +95,27 @@ 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 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: @@ -89,14 +123,13 @@ protected: struct BoundaryConditions { - BoundaryConditions() : geometryBoundaryCondition(nullptr) {} - - std::vector<SPtr<VelocityBoundaryCondition> > velocityBoundaryConditions; - std::vector<SPtr<PressureBoundaryCondition> > pressureBoundaryConditions; + BoundaryConditions() {} - //TODO: add slip BC + std::vector<SPtr<SlipBoundaryCondition>> slipBoundaryConditions; + std::vector<SPtr<VelocityBoundaryCondition>> velocityBoundaryConditions; + std::vector<SPtr<PressureBoundaryCondition>> pressureBoundaryConditions; std::vector<SPtr<VelocityBoundaryCondition> > noSlipBoundaryConditions; @@ -106,7 +139,7 @@ protected: std::vector<std::shared_ptr<Grid> > grids; std::vector<SPtr<BoundaryConditions> > boundaryConditions; - + std::array<uint, 6> communicationProcesses; void checkLevel(int level); @@ -121,10 +154,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, @@ -139,11 +168,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 bd8bcbd4d0a059acede4e95fa8f06d102904351f..565a02a2807ef15679bf08fa001ea9a03f78ca4e 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,18 +46,17 @@ #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() : LevelGridBuilder(), numberOfLayersFine(12), numberOfLayersBetweenLevels(8), subDomainBox(nullptr) { } -SPtr<MultipleGridBuilder> MultipleGridBuilder::makeShared(SPtr<GridFactory> gridFactory) +SPtr<MultipleGridBuilder> MultipleGridBuilder::makeShared() { - return SPtr<MultipleGridBuilder>(new MultipleGridBuilder(gridFactory)); + return SPtr<MultipleGridBuilder>(new MultipleGridBuilder()); } void MultipleGridBuilder::addCoarseGrid(real startX, real startY, real startZ, real endX, real endY, real endZ, real delta) @@ -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,10 +193,9 @@ 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); + return GridImp::makeShared(gridShape, startX, startY, startZ, endX, endY, endZ, delta, "D3Q27", level); } bool MultipleGridBuilder::coarseGridExists() const @@ -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"; @@ -609,12 +635,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()); } } @@ -622,3 +642,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 8fa61f8484c77d539331697e22b383176cdd19f4..839e0036bbc6b0f5d28bec5da3a0abe637b7adca 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 @@ -9,7 +41,7 @@ #include "global.h" #include "grid/GridBuilder/LevelGridBuilder.h" -#include "grid/GridFactory.h" +#include "grid/distributions/Distribution.h" class Object; class BoundingBox; @@ -17,17 +49,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(); public: - GRIDGENERATOR_EXPORT static SPtr<MultipleGridBuilder> makeShared(SPtr<GridFactory> gridFactory); + GRIDGENERATOR_EXPORT static SPtr<MultipleGridBuilder> makeShared(); 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 +77,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 +87,23 @@ 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 +111,7 @@ private: SPtr<BoundingBox> subDomainBox; public: - - GRIDGENERATOR_EXPORT void findCommunicationIndices( int direction, LbmOrGks lbmOrGks ); + GRIDGENERATOR_EXPORT void findCommunicationIndices(int direction, LbmOrGks lbmOrGks); }; #endif 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..b525596fa670a026d60b1297c75ef69c46b23498 100644 --- a/src/gpu/GridGenerator/grid/GridFactory.h +++ b/src/gpu/GridGenerator/grid/GridFactory.h @@ -1,22 +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 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,63 +52,10 @@ 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, gridStrategy, distribution, level); - - grid->setTriangularMeshDiscretizationStrategy(this->triangularMeshDiscretizationStrategy); - - 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; - } + return GridImp::makeShared(gridShape, startX, startY, startZ, endX, endY, endZ, delta, d3Qxx, level); } - - void setGridStrategy(SPtr<GridStrategy> gridStrategy) - { - this->gridStrategy = gridStrategy; - } - - void setTriangularMeshDiscretizationMethod(TriangularMeshDiscretizationMethod triangularMeshDiscretizationMethod) - { - switch (triangularMeshDiscretizationMethod) - { - case TriangularMeshDiscretizationMethod::POINT_UNDER_TRIANGLE: - triangularMeshDiscretizationStrategy = new PointUnderTriangleStrategy(); - break; - case TriangularMeshDiscretizationMethod::RAYCASTING: - triangularMeshDiscretizationStrategy = new RayCastingDiscretizationStrategy(); - break; - case TriangularMeshDiscretizationMethod::POINT_IN_OBJECT: - triangularMeshDiscretizationStrategy = new PointInObjectDiscretizationStrategy(); - break; - } - } - -private: - TriangularMeshDiscretizationStrategy* triangularMeshDiscretizationStrategy; - SPtr<GridStrategy> gridStrategy; }; diff --git a/src/gpu/GridGenerator/grid/GridImp.cu b/src/gpu/GridGenerator/grid/GridImp.cpp similarity index 73% rename from src/gpu/GridGenerator/grid/GridImp.cu rename to src/gpu/GridGenerator/grid/GridImp.cpp index cd835ee1c512d23969aa2d448a3c18b5a5179ed8..efe62002ac6ea00e90e63a7253324b44a77d5b9c 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> @@ -5,6 +37,7 @@ #include <iostream> #include <omp.h> #include <sstream> +#include <cmath> #include "global.h" @@ -15,7 +48,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" @@ -26,10 +58,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), @@ -38,7 +71,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), @@ -61,9 +93,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; } @@ -74,25 +107,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"; @@ -107,54 +150,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()); - - gridStrategy->freeFieldMemory(&field); -} + 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; } -CUDA_HOST GridImp::GridImp() -{ - //printf("Constructor\n"); - //this->print(); + field.freeMemory(); } -CUDA_HOST GridImp::~GridImp() +void GridImp::findInnerNodes() { - //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; @@ -177,7 +247,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++) @@ -213,7 +283,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); @@ -237,7 +307,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++ ){ @@ -264,14 +334,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 ) ){ @@ -281,14 +357,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; @@ -308,7 +384,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; } @@ -347,7 +423,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); @@ -356,7 +432,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 ) @@ -369,13 +445,13 @@ HOSTDEVICE void GridImp::findEndOfGridStopperNode(uint 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)) { @@ -385,7 +461,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)) @@ -394,7 +470,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 @@ -405,7 +481,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); @@ -417,7 +493,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); @@ -429,7 +505,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); @@ -441,12 +517,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); @@ -456,61 +532,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; @@ -518,7 +581,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; @@ -532,7 +595,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; @@ -547,47 +610,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); @@ -618,7 +643,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); @@ -649,7 +674,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) { @@ -698,7 +723,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; @@ -707,17 +732,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() @@ -740,7 +765,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); @@ -752,21 +777,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; @@ -778,50 +803,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; } @@ -830,13 +855,28 @@ 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(); + } + + const uint newGridSize = this->getSparseSize(); + *logging::out << logging::Logger::INFO_INTERMEDIATE << "... done. new size: " << newGridSize + << ", delete nodes:" << this->getSize() - newGridSize << "\n"; } -CUDA_HOST void GridImp::updateSparseIndices() +void GridImp::updateSparseIndices() { int removedNodes = 0; int newIndex = 0; @@ -856,7 +896,7 @@ CUDA_HOST void GridImp::updateSparseIndices() sparseSize = size - removedNodes; } -HOSTDEVICE void GridImp::setNeighborIndices(uint index) +void GridImp::setNeighborIndices(uint index) { real x, y, z; this->transIndexToCoords(index, x, y, z); @@ -891,7 +931,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); @@ -914,7 +954,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); @@ -922,7 +962,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) { @@ -930,11 +970,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) ) @@ -947,7 +982,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 }; @@ -956,13 +991,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; @@ -974,10 +1009,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; @@ -986,7 +1021,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]); @@ -999,27 +1034,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++ ){ @@ -1058,11 +1123,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) { @@ -1073,17 +1136,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); } @@ -1091,28 +1154,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); 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); @@ -1120,7 +1190,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()); @@ -1146,20 +1216,25 @@ 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() ); +#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; @@ -1181,38 +1256,31 @@ 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() ); +#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; @@ -1223,7 +1291,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) @@ -1232,15 +1300,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); @@ -1248,7 +1332,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()); @@ -1291,12 +1375,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++ ) @@ -1331,7 +1414,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; @@ -1369,7 +1452,7 @@ HOSTDEVICE void GridImp::calculateQs(const uint index, const Vertex &point, Obje } } -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; @@ -1399,7 +1482,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); @@ -1408,10 +1491,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++) @@ -1425,21 +1507,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; @@ -1472,14 +1550,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; @@ -1521,7 +1597,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; @@ -1538,7 +1613,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 ); @@ -1599,59 +1673,56 @@ void GridImp::repairCommunicationInices(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); @@ -1659,7 +1730,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; @@ -1671,7 +1742,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); @@ -1679,7 +1750,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; @@ -1689,40 +1760,37 @@ 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; } -HOSTDEVICE Field GridImp::getField() const +Field GridImp::getField() const { return this->field; } @@ -1732,7 +1800,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); } @@ -1783,11 +1851,6 @@ uint GridImp::getNumberOfNodesZ() const return nz; } -SPtr<GridStrategy> GridImp::getGridStrategy() const -{ - return gridStrategy; -} - int* GridImp::getNeighborsX() const { @@ -1809,7 +1872,6 @@ int* GridImp::getNeighborsNegative() const return this->neighborIndexNegative; } - uint GridImp::getNumberOfNodesCF() const { if(this->gridInterface) @@ -1834,7 +1896,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; } @@ -1849,7 +1911,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; } @@ -1871,7 +1933,7 @@ void GridImp::getGridInterface(uint* gridInterfaceList, const uint* oldGridInter #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; @@ -1896,8 +1958,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; @@ -1920,4 +1980,4 @@ void GridImp::print() const endX, endY, endZ, size, delta); if(this->gridInterface) this->gridInterface->print(); -} +} \ No newline at end of file diff --git a/src/gpu/GridGenerator/grid/GridImp.h b/src/gpu/GridGenerator/grid/GridImp.h index 314020d0e6a271d0761d6935f8e55c5c7ea6bade..7d44b0bb58168a6bf4da87ad94cf5a8f533002ed 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 Schönherr +//======================================================================================= #ifndef GRID_IMP_H #define GRID_IMP_H @@ -15,55 +47,53 @@ class TriangularMesh; struct Vertex; struct Triangle; -class GridStrategy; class GridInterface; class Object; class BoundingBox; class TriangularMeshDiscretizationStrategy; #ifdef __GNUC__ - #ifndef __clang__ - #pragma push - #pragma diag_suppress = 3156 - #endif +#ifndef __clang__ +#pragma push +#pragma diag_suppress = 3156 +#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__ - #pragma pop - #endif +#ifndef __clang__ +#pragma pop +#endif #endif class GRIDGENERATOR_EXPORT GridImp : public enableSharedFromThis<GridImp>, public Grid { private: - 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); + 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; @@ -94,19 +124,18 @@ private: uint numberOfLayers; - SPtr<GridStrategy> gridStrategy; - TriangularMeshDiscretizationStrategy* triangularMeshDiscretizationStrategy; + TriangularMeshDiscretizationStrategy *triangularMeshDiscretizationStrategy; - uint numberOfSolidBoundaryNodes; + uint numberOfSolidBoundaryNodes; 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; @@ -115,192 +144,190 @@ public: bool getPeriodicityY() override; bool getPeriodicityZ() override; - void setEnableFixRefinementIntoTheWall( bool enableFixRefinementIntoTheWall ) override; + void setEnableFixRefinementIntoTheWall(bool enableFixRefinementIntoTheWall) override; - HOSTDEVICE void setCellTo(uint index, char type); - HOSTDEVICE void setNonStopperOutOfGridCellTo(uint index, char type); + void setCellTo(uint index, char type); + void setNonStopperOutOfGridCellTo(uint index, char type); - 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; + 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; - CUDA_HOST virtual void findGridInterface(SPtr<Grid> grid, LbmOrGks lbmOrGks) override; + virtual void findGridInterface(SPtr<Grid> grid, LbmOrGks lbmOrGks) override; - HOSTDEVICE void repairGridInterfaceOnMultiGPU(SPtr<Grid> fineGrid) override; + void repairGridInterfaceOnMultiGPU(SPtr<Grid> fineGrid) override; - CUDA_HOST virtual void limitToSubDomain(SPtr<BoundingBox> subDomainBox, LbmOrGks lbmOrGks) override; + virtual void limitToSubDomain(SPtr<BoundingBox> subDomainBox, LbmOrGks lbmOrGks) override; - CUDA_HOST void freeMemory() override; + void freeMemory() override; - CUDA_HOST uint getLevel(real levelNull) const; - CUDA_HOST uint getLevel() const; - CUDA_HOST void setTriangularMeshDiscretizationStrategy(TriangularMeshDiscretizationStrategy* triangularMeshDiscretizationStrategy); - CUDA_HOST TriangularMeshDiscretizationStrategy* getTriangularMeshDiscretizationStrategy(); + uint getLevel(real levelNull) const; + uint getLevel() const; - CUDA_HOST uint getNumberOfSolidBoundaryNodes() const override; - CUDA_HOST void setNumberOfSolidBoundaryNodes(uint numberOfSolidBoundaryNodes) override; + void setTriangularMeshDiscretizationStrategy(TriangularMeshDiscretizationStrategy *triangularMeshDiscretizationStrategy); + TriangularMeshDiscretizationStrategy *getTriangularMeshDiscretizationStrategy(); - CUDA_HOST real getQValue(const uint index, const uint dir) const override; - CUDA_HOST uint getQPatch(const uint index) const override; + uint getNumberOfSolidBoundaryNodes() const override; + void setNumberOfSolidBoundaryNodes(uint numberOfSolidBoundaryNodes) override; - CUDA_HOST void setInnerRegionFromFinerGrid( bool innerRegionFromFinerGrid ) override; + real getQValue(const uint index, const uint dir) const override; + uint getQPatch(const uint index) const override; - CUDA_HOST void setNumberOfLayers( uint numberOfLayers ) override; + void setInnerRegionFromFinerGrid(bool innerRegionFromFinerGrid) 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); - - int* getNeighborsX() const override; - int* getNeighborsY() const override; - int* getNeighborsZ() const override; - int* getNeighborsNegative() const override; + void setInnerBasedOnFinerGrid(const SPtr<Grid> fineGrid); - CUDA_HOST uint* getCF_coarse() const override; - CUDA_HOST uint* getCF_fine() const override; - CUDA_HOST uint* getCF_offset() const override; + void addOverlap(); + void setOverlapTmp(uint index); + void setOverlapFluid(uint index); + 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); - CUDA_HOST uint* getFC_coarse() const override; - CUDA_HOST uint* getFC_fine() const override; - CUDA_HOST uint* getFC_offset() const override; + void findGridInterfaceCF(uint index, GridImp &finerGrid, LbmOrGks lbmOrGks); + void findGridInterfaceFC(uint index, GridImp &finerGrid); + void findOverlapStopper(uint index, GridImp &finerGrid); + void findInvalidBoundaryNodes(uint index); - SPtr<GridStrategy> getGridStrategy() 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; + const Object* getObject() const override; - HOSTDEVICE void print() const; + Field getField() const; + char getFieldEntry(uint index) const override; + void setFieldEntry(uint matrixIndex, char type) override; + 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); + + 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 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; - CUDA_HOST void mesh(Object* object) override; + void mesh(Object *object) override; - CUDA_HOST void mesh(TriangularMesh &geometry) override; - HOSTDEVICE void mesh(Triangle &triangle); + void mesh(TriangularMesh &geometry) override; + void mesh(Triangle &triangle); - CUDA_HOST void closeNeedleCells() override; - HOSTDEVICE bool closeCellIfNeedle(uint index); + void closeNeedleCells() override; + bool closeCellIfNeedle(uint index); - CUDA_HOST void closeNeedleCellsThinWall() override; - HOSTDEVICE bool closeCellIfNeedleThinWall(uint index); + void closeNeedleCellsThinWall() override; + bool closeCellIfNeedleThinWall(uint index); - CUDA_HOST void findQs(Object* object) override; - CUDA_HOST void findQs(TriangularMesh &triangularMesh); - HOSTDEVICE void findQs(Triangle &triangle); + void findQs(Object *object) override; + void findQs(TriangularMesh &triangularMesh); + void findQs(Triangle &triangle); - CUDA_HOST void findQsPrimitive(Object* object); -private: + void findQsPrimitive(Object *object); - enum class qComputationStageType{ - FindSolidBoundaryNodes, - ComputeQs - } qComputationStage; +private: + enum class qComputationStageType { FindSolidBoundaryNodes, ComputeQs } 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; @@ -311,19 +338,13 @@ public: void repairCommunicationInices(int direction) override; 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 ec88c3b4afed654999cc6f6be16005a020cd0cd7..47cb8ef9dd7c4704e420ca68888ce0d56c48a59e 100644 --- a/src/gpu/GridGenerator/grid/GridInterface.cu +++ b/src/gpu/GridGenerator/grid/GridInterface.cpp @@ -1,12 +1,47 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// 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" #include "grid/Field.h" #include "grid/NodeValues.h" +using namespace vf::gpu; + GridInterface::GridInterface() { @@ -130,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); @@ -161,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; @@ -170,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) { @@ -254,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; @@ -330,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); @@ -365,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 d0f04ea3451b3044c349aa0e27d2f7c6e567128c..303d79d4995ea04fe30b2a004c5738bf9c926cf2 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 34fbe03eb121c33fa01069d9498e833c6435510d..0000000000000000000000000000000000000000 --- a/src/gpu/GridGenerator/grid/GridStrategy/GridCpuStrategy/GridCpuStrategy.cpp +++ /dev/null @@ -1,289 +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" - -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 b393356ae488bfc29ff6bf756e2898846545255f..c726fdf85c8199633e118d8f8a5365ee658d4e6a 100644 --- a/src/gpu/GridGenerator/grid/NodeValues.h +++ b/src/gpu/GridGenerator/grid/NodeValues.h @@ -1,39 +1,78 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// 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 -#define FLUID 0 +namespace vf +{ +namespace gpu +{ -#define FLUID_CFC 1 -#define FLUID_CFF 2 +static constexpr char FLUID = 0; -#define FLUID_FCC 3 -#define FLUID_FCF 4 +static constexpr char FLUID_CFC = 1; +static constexpr char FLUID_CFF = 2; -#define MULTI_GPU_SEND 10 -#define MULTI_GPU_RECIEVE 11 +static constexpr char FLUID_FCC = 3; +static constexpr char FLUID_FCF = 4; -#define BC_PRESSURE 20 -#define BC_VELOCITY 21 -#define BC_SOLID 22 +static constexpr char MULTI_GPU_SEND = 10; +static constexpr char MULTI_GPU_RECIEVE = 11; -#define BC_SLIP 23 -#define BC_NOSLIP 24 -#define BC_OUTFLOW 25 +static constexpr char BC_PRESSURE = 20; +static constexpr char BC_VELOCITY = 21; +static constexpr char BC_SOLID = 22; -#define STOPPER_OUT_OF_GRID 30 -#define STOPPER_COARSE_UNDER_FINE 31 -#define STOPPER_SOLID 32 -#define STOPPER_OUT_OF_GRID_BOUNDARY 33 +static constexpr char BC_SLIP = 23; +static constexpr char BC_NOSLIP = 24; +static constexpr char BC_OUTFLOW = 25; -#define INVALID_OUT_OF_GRID 40 -#define INVALID_COARSE_UNDER_FINE 41 -#define INVALID_SOLID 42 +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; -//????WTF????? -#define INSIDE 50 -#define NEGATIVE_DIRECTION_BORDER 51 -#define Q_DEPRECATED 52 +static constexpr char INVALID_OUT_OF_GRID = 40; +static constexpr char INVALID_COARSE_UNDER_FINE = 41; +static constexpr char INVALID_SOLID = 42; -#define OVERLAP_TMP 60 +static constexpr char INSIDE = 50; +static constexpr char NEGATIVE_DIRECTION_BORDER = 51; +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 b05b5db3652ee952ff083db560ed8316688819c9..abc6d8105c9daeb83f4e31478a55942f48bf5e65 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 19e3cef186781a7f0a411307afb976072078f07b..2c8624732d70e52ac24d843888548bdaf5585686 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" @@ -15,6 +47,8 @@ #include "grid/NodeValues.h" #include "grid/Cell.h" +using namespace vf::gpu; + FILE* GridVTKWriter::file = nullptr; WRITING_FORMAT GridVTKWriter::format = WRITING_FORMAT::ASCII; @@ -239,74 +273,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 3f41f66ae70ae669d406deb3bc110f0f2047ab82..173f79c184c0a455ffd5b27cae59e07fa6dd4fa6 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,17 +213,17 @@ std::vector<Triangle> STLReader::readBinarySTL(const std::string& name) FILE *file = fopen(name.c_str(), mode.c_str()); char header_info[80] = ""; - fread(header_info, sizeof(char), 80, file); + size_t sizef = fread(header_info, sizeof(char), 80, file); char nTri[4]; - 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++){ - fread(facet, sizeof(char), 50, file); + sizef = fread(facet, sizeof(char), 50, file); Vertex normal = getVertexFromChar(facet); @@ -201,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; @@ -272,10 +305,10 @@ std::vector<Triangle> STLReader::readBinarySTL(const BoundingBox &box, const std char nTri[4]; unsigned long nTriLong; - fread(header_info, sizeof(char), 80, file); + size_t sizef = fread(header_info, sizeof(char), 80, file); - 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"; @@ -283,7 +316,7 @@ std::vector<Triangle> STLReader::readBinarySTL(const BoundingBox &box, const std char facet[50]; for (unsigned int i = 0; i < nTriLong; i++){ - fread(facet, sizeof(char), 50, file); + sizef = fread(facet, sizeof(char), 50, file); Vertex normal = getVertexFromChar(facet); @@ -298,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 f3a66f69a06463ad528d6c00a7a36f5a234db19c..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" @@ -19,6 +51,8 @@ #include "utilities/communication.h" +using namespace vf::gpu; + /*#################################################################################*/ /*---------------------------------public methods----------------------------------*/ /*---------------------------------------------------------------------------------*/ @@ -512,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++) { @@ -573,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 eb10c9c107bb8e777e6f9a5d7bb4a57d021266fe..d5d2a377b33697704b86f8b78987fd0af75be415 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 ce1bb9d921f114b3d06143901355c56ab24b77fd..116e987664ba14b83054c823ff9cf6505fccf769 100644 --- a/src/gpu/VirtualFluids_GPU/CMakeLists.txt +++ b/src/gpu/VirtualFluids_GPU/CMakeLists.txt @@ -5,10 +5,19 @@ if(MSVC) set(additional_libraries ws2_32 Traffic) # ws_32 throws an error on Phoenix endif() -vf_add_library(PRIVATE_LINK ${additional_libraries} GridGenerator basics MPI::MPI_CXX) +vf_add_library(PUBLIC_LINK basics lbmCuda PRIVATE_LINK ${additional_libraries} GridGenerator MPI::MPI_CXX 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) + + vf_add_tests() + +if(BUILD_VF_UNIT_TESTS) + set_target_properties(VirtualFluids_GPUTests PROPERTIES CUDA_SEPARABLE_COMPILATION ON) + set_source_files_properties(Kernel/Utilities/DistributionHelperTests.cpp PROPERTIES LANGUAGE CUDA) +endif() diff --git a/src/gpu/VirtualFluids_GPU/Calculation/CalcMedian.cpp b/src/gpu/VirtualFluids_GPU/Calculation/CalcMedian.cpp index 066c55b9f30bd7537dfb829f3b953fb8a99a2cae..1adb709c5eb4f391756d455a53717a0d9cf72858 100644 --- a/src/gpu/VirtualFluids_GPU/Calculation/CalcMedian.cpp +++ b/src/gpu/VirtualFluids_GPU/Calculation/CalcMedian.cpp @@ -74,7 +74,7 @@ void allocMedianAD(Parameter* para, CudaMemoryManager* cudaManager) { for (int lev = para->getCoarse(); lev <= para->getFine(); lev++) { - para->cudaAllocMedianOutAD(lev); + cudaManager->cudaAllocMedianOutAD(lev); for (unsigned int i = 0; i < para->getParH(lev)->size_Mat_SP; i++) { para->getParH(lev)->vx_SP_Med_Out[i] = (real)0.0; diff --git a/src/gpu/VirtualFluids_GPU/Calculation/UpdateGrid27.cpp b/src/gpu/VirtualFluids_GPU/Calculation/UpdateGrid27.cpp index 45323203a1d540ddd630c9e7751a4340329e0da9..a061b83547c0ddf6bb67a4b48b8b6ee3503a8e58 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,8 +8,11 @@ #include "Communication/ExchangeData27.h" #include "Kernel/Kernel.h" +void interactWithActuators(Parameter* para, CudaMemoryManager* cudaManager, int level, unsigned int t); +void interactWithProbes(Parameter* para, CudaMemoryManager* cudaManager, int level, unsigned int t); + void updateGrid27(Parameter* para, - Communicator* comm, + vf::gpu::Communicator& comm, CudaMemoryManager* cudaManager, std::vector<std::shared_ptr<PorousMedia>>& pm, int level, @@ -59,6 +62,10 @@ void updateGrid27(Parameter* para, coarseToFine(para, level); } + + interactWithActuators(para, cudaManager, level, t); + + interactWithProbes(para, cudaManager, level, t); } void collision(Parameter* para, std::vector<std::shared_ptr<PorousMedia>>& pm, int level, unsigned int t, std::vector < SPtr< Kernel>>& kernels) @@ -149,7 +156,7 @@ void collisionAdvectionDiffusion(Parameter* para, int level) } } -void exchangeMultiGPU(Parameter* para, Communicator* comm, CudaMemoryManager* cudaManager, int level) +void exchangeMultiGPU(Parameter* para, vf::gpu::Communicator& comm, CudaMemoryManager* cudaManager, int level) { if (para->getNumprocs() > 1) { @@ -336,13 +343,21 @@ void postCollisionBC(Parameter* para, int level, unsigned int t) // para->getParD(level)->size_Mat_SP, para->getParD(level)->evenOrOdd); //getLastCudaError("QDevComp27 (Geom) execution failed"); - QVelDevComp27(para->getParD(level)->numberofthreads, para->getParD(level)->nx, para->getParD(level)->ny, - para->getParD(level)->QGeom.Vx, para->getParD(level)->QGeom.Vy, para->getParD(level)->QGeom.Vz, - para->getParD(level)->d0SP.f[0], para->getParD(level)->QGeom.k, para->getParD(level)->QGeom.q27[0], - para->getParD(level)->QGeom.kQ, para->getParD(level)->QGeom.kQ, para->getParD(level)->omega, - 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("QVelDevComp27 execution failed"); + //QVelDevComp27(para->getParD(level)->numberofthreads, para->getParD(level)->nx, para->getParD(level)->ny, + // para->getParD(level)->QGeom.Vx, para->getParD(level)->QGeom.Vy, para->getParD(level)->QGeom.Vz, + // para->getParD(level)->d0SP.f[0], para->getParD(level)->QGeom.k, para->getParD(level)->QGeom.q27[0], + // para->getParD(level)->QGeom.kQ, para->getParD(level)->QGeom.kQ, para->getParD(level)->omega, + // 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("QVelDevComp27 execution failed"); + + QVelDevCompZeroPress27( para->getParD(0)->numberofthreads, para->getParD(0)->nx, para->getParD(0)->ny, + para->getParD(0)->QGeom.Vx, para->getParD(0)->QGeom.Vy, para->getParD(0)->QGeom.Vz, + para->getParD(0)->d0SP.f[0], para->getParD(0)->QGeom.k, para->getParD(0)->QGeom.q27[0], + para->getParD(0)->QGeom.kQ, para->getParD(0)->QGeom.kQ, para->getParD(0)->omega, + para->getParD(0)->neighborX_SP, para->getParD(0)->neighborY_SP, para->getParD(0)->neighborZ_SP, + para->getParD(0)->size_Mat_SP, para->getParD(0)->evenOrOdd); + getLastCudaError("QVelDevCompZeroPress27 execution failed"); //QDev3rdMomentsComp27( para->getParD(level)->numberofthreads, para->getParD(level)->nx, para->getParD(level)->ny, // para->getParD(level)->d0SP.f[0], para->getParD(level)->QGeom.k, para->getParD(level)->QGeom.q27[0], @@ -1251,3 +1266,19 @@ void coarseToFine(Parameter* para, int level) } } + +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); + } +} \ 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 5d404e612c9e5ce9211245ac776f517278be4532..ac0d13d6454e4002117dc2874df98172f8e79a30 100644 --- a/src/gpu/VirtualFluids_GPU/Calculation/UpdateGrid27.h +++ b/src/gpu/VirtualFluids_GPU/Calculation/UpdateGrid27.h @@ -11,7 +11,7 @@ class Kernel; extern "C" void updateGrid27(Parameter* para, - Communicator* comm, + vf::gpu::Communicator& comm, CudaMemoryManager* cudaManager, std::vector<std::shared_ptr<PorousMedia>>& pm, int level, @@ -24,7 +24,7 @@ extern "C" void collisionPorousMedia(Parameter* para, std::vector<std::shared_pt extern "C" void collisionAdvectionDiffusion(Parameter* para, int level); -extern "C" void exchangeMultiGPU(Parameter* para, Communicator* comm, CudaMemoryManager* cudaManager, int level); +extern "C" void exchangeMultiGPU(Parameter* para, vf::gpu::Communicator& comm, CudaMemoryManager* cudaManager, int level); extern "C" void postCollisionBC(Parameter* para, int level, unsigned int t); diff --git a/src/gpu/VirtualFluids_GPU/Communication/Communicator.cpp b/src/gpu/VirtualFluids_GPU/Communication/Communicator.cpp index df1aa298c925857a615602de7459f23d36fec2ec..2743f454e321bf21cb4d0b7fd08aab8600a2bee8 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,233 +12,207 @@ #endif //lib for windows Ws2_32.lib +namespace vf::gpu +{ + Communicator::Communicator() { - MPI_Comm_rank(MPI_COMM_WORLD, &PID); - MPI_Comm_size(MPI_COMM_WORLD, &numprocs); + int mpiInitialized = 0; // false + MPI_Initialized(&mpiInitialized); + if (!mpiInitialized) { + MPI_Init(NULL, NULL); + VF_LOG_TRACE("vf::gpu::Communicator(): MPI_Init"); + } - //Get a new communicator for a decomposition of the domain - int isperiodic[1]={0}; - MPI_Cart_create( MPI_COMM_WORLD, 1, &numprocs, isperiodic, 1, &comm1d); + MPI_Comm_rank(MPI_COMM_WORLD, &PID); + MPI_Comm_size(MPI_COMM_WORLD, &numprocs); - //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) -{ - MPI_Comm_rank(MPI_COMM_WORLD, &PID); - MPI_Comm_size(MPI_COMM_WORLD, &numprocs); - commGPU = MPI_COMM_WORLD; - requestGPU.resize(0); - rcount = 0; + // Get a new communicator for a decomposition of the domain + int isperiodic[1] = { 0 }; + MPI_Cart_create(MPI_COMM_WORLD, 1, &numprocs, isperiodic, 1, &comm1d); + + // Get my position in this communicator, and my neighbors + MPI_Cart_shift(comm1d, 0, 1, &nbrbottom, &nbrtop); } -Communicator* Communicator::instanz = 0; -Communicator* Communicator::getInstanz() + +Communicator::~Communicator() { - if( instanz == 0 ) - instanz = new Communicator(0); - return instanz; + // proof if MPI is finalized + int _mpiFinalized = 0; // false + MPI_Finalized(&_mpiFinalized); + if (!_mpiFinalized) { + MPI_Finalize(); + VF_LOG_TRACE("vf::gpu::~Communicator(): MPI_Finalize"); + } } -void Communicator::exchngBottomToTop(float* sbuf, float* rbuf, int count) + +// C++11 thread safe singelton implementation: +// https://stackoverflow.com/questions/1661529/is-meyers-implementation-of-the-singleton-pattern-thread-safe +Communicator& Communicator::getInstance() { - MPI_Sendrecv(sbuf, count, MPI_FLOAT, - nbrtop, 0, - rbuf, count, MPI_FLOAT, - nbrbottom, 0, comm1d, status); + static Communicator comm; + return comm; } -void Communicator::exchngTopToBottom(float* sbuf, float* rbuf, int count) + +void Communicator::exchngBottomToTop(float *sbuf, float *rbuf, int count) { - MPI_Sendrecv(sbuf, count, MPI_FLOAT, - nbrbottom, 0, - rbuf, count, MPI_FLOAT, - nbrtop, 0, comm1d, status); + MPI_Sendrecv(sbuf, count, MPI_FLOAT, nbrtop, 0, rbuf, count, MPI_FLOAT, nbrbottom, 0, comm1d, status); } -void Communicator::waitAll() +void Communicator::exchngTopToBottom(float *sbuf, float *rbuf, int count) { - MPI_Waitall(4, request, status); + MPI_Sendrecv(sbuf, count, MPI_FLOAT, nbrbottom, 0, rbuf, count, MPI_FLOAT, nbrtop, 0, comm1d, status); } -void Communicator::exchngData( float* sbuf_t, float* rbuf_t, float* sbuf_b, float* rbuf_b, int count ) +void Communicator::waitAll() { MPI_Waitall(4, request, status); } +void Communicator::exchngData(float *sbuf_t, float *rbuf_t, float *sbuf_b, float *rbuf_b, int count) { - MPI_Sendrecv(sbuf_t, count, MPI_FLOAT, nbrtop, 0, rbuf_t, count, MPI_FLOAT, nbrbottom, 0, comm1d, status); - MPI_Sendrecv(sbuf_b, count, MPI_FLOAT, nbrbottom, 0, rbuf_b, count, MPI_FLOAT, nbrtop, 0, comm1d, status); + MPI_Sendrecv(sbuf_t, count, MPI_FLOAT, nbrtop, 0, rbuf_t, count, MPI_FLOAT, nbrbottom, 0, comm1d, status); + MPI_Sendrecv(sbuf_b, count, MPI_FLOAT, nbrbottom, 0, rbuf_b, count, MPI_FLOAT, nbrtop, 0, comm1d, status); } -void Communicator::exchngDataNB( float* sbuf_t, int count_st, float* rbuf_t, int count_rt, float* sbuf_b, int count_sb, float* rbuf_b, int count_rb ) +void Communicator::exchngDataNB(float *sbuf_t, int count_st, float *rbuf_t, int count_rt, float *sbuf_b, int count_sb, + float *rbuf_b, int count_rb) { - MPI_Irecv(rbuf_t, count_rt, MPI_FLOAT, nbrbottom, 0, comm1d, &request[0]); - MPI_Irecv(rbuf_b, count_rb, MPI_FLOAT, nbrtop, 0, comm1d, &request[1]); - MPI_Isend(sbuf_t, count_st, MPI_FLOAT, nbrtop, 0, comm1d, &request[2]); - MPI_Isend(sbuf_b, count_sb, MPI_FLOAT, nbrbottom, 0, comm1d, &request[3]); - MPI_Waitall(4, request, status); + MPI_Irecv(rbuf_t, count_rt, MPI_FLOAT, nbrbottom, 0, comm1d, &request[0]); + MPI_Irecv(rbuf_b, count_rb, MPI_FLOAT, nbrtop, 0, comm1d, &request[1]); + MPI_Isend(sbuf_t, count_st, MPI_FLOAT, nbrtop, 0, comm1d, &request[2]); + MPI_Isend(sbuf_b, count_sb, MPI_FLOAT, nbrbottom, 0, comm1d, &request[3]); + MPI_Waitall(4, request, status); } ////////////////////////////////////////////////////////////////////////// -//Crap by Martin Sch. -void Communicator::exchngDataGPU( real* sbuf, int count_s, real* rbuf, int count_r, int nb_rank ) +// Crap by Martin Sch. +void Communicator::exchngDataGPU(real *sbuf, int count_s, real *rbuf, int count_r, int nb_rank) { - MPI_Status MSstatus; - MPI_Send(sbuf, count_s, MPI_Type_GPU, nb_rank, 0, commGPU); - MPI_Recv(rbuf, count_r, MPI_Type_GPU, nb_rank, 0, commGPU, &MSstatus); - ////test only - please don't use - //MPI_Sendrecv(sbuf, count_s, MPI_Type_GPU, nb_rank, 0, rbuf, count_r, MPI_Type_GPU, nb_rank, 0, comm1d, MPI_STATUSES_IGNORE); + MPI_Status MSstatus; + MPI_Send(sbuf, count_s, MPI_Type_GPU, nb_rank, 0, commGPU); + MPI_Recv(rbuf, count_r, MPI_Type_GPU, nb_rank, 0, commGPU, &MSstatus); + ////test only - please don't use + // MPI_Sendrecv(sbuf, count_s, MPI_Type_GPU, nb_rank, 0, rbuf, count_r, MPI_Type_GPU, nb_rank, 0, comm1d, + // MPI_STATUSES_IGNORE); } -void Communicator::sendRecvGPU( real* sbuf, int count_s, real* rbuf, int count_r, int nb_rank ) +void Communicator::sendRecvGPU(real *sbuf, int count_s, real *rbuf, int count_r, int nb_rank) { - //test only - please don't use - MPI_Sendrecv(sbuf, count_s, MPI_Type_GPU, nb_rank, 0, rbuf, count_r, MPI_Type_GPU, nb_rank, 0, commGPU, MPI_STATUSES_IGNORE); + // test only - please don't use + MPI_Sendrecv(sbuf, count_s, MPI_Type_GPU, nb_rank, 0, rbuf, count_r, MPI_Type_GPU, nb_rank, 0, commGPU, + MPI_STATUSES_IGNORE); } -void Communicator::nbRecvDataGPU( real* rbuf, int count_r, int nb_rank ) +void Communicator::nbRecvDataGPU(real *rbuf, int count_r, int nb_rank) { - //printf("\n Start Recv Rank: %d, neighbor Rank: %d, request = %d \n", PID, nb_rank, (int)requestGPU.size()); - //fflush(stdout); + // printf("\n Start Recv Rank: %d, neighbor Rank: %d, request = %d \n", PID, nb_rank, (int)requestGPU.size()); + // fflush(stdout); - requestGPU.push_back(0); - MPI_Irecv(rbuf, count_r, MPI_Type_GPU, nb_rank, 0, commGPU, &requestGPU[rcount]); - rcount++; + requestGPU.push_back(0); + MPI_Irecv(rbuf, count_r, MPI_Type_GPU, nb_rank, 0, commGPU, &requestGPU[rcount]); + rcount++; - //printf("\n End Recv - Rank: %d , neighbor Rank: %d \n", PID, nb_rank); - //fflush(stdout); + // printf("\n End Recv - Rank: %d , neighbor Rank: %d \n", PID, nb_rank); + // fflush(stdout); } -void Communicator::nbSendDataGPU( real* sbuf, int count_s, int nb_rank ) +void Communicator::nbSendDataGPU(real *sbuf, int count_s, int nb_rank) { - //printf("\n Start Send Rank: %d, neighbor Rank: %d, request = %d \n", PID, nb_rank, (int)requestGPU.size()); - //fflush(stdout); + // printf("\n Start Send Rank: %d, neighbor Rank: %d, request = %d \n", PID, nb_rank, (int)requestGPU.size()); + // fflush(stdout); - requestGPU.push_back(0); - MPI_Isend(sbuf, count_s, MPI_Type_GPU, nb_rank, 0, commGPU, &requestGPU[rcount]); - rcount++; + requestGPU.push_back(0); + MPI_Isend(sbuf, count_s, MPI_Type_GPU, nb_rank, 0, commGPU, &requestGPU[rcount]); + rcount++; - //printf("\n End Send - Rank: %d , neighbor Rank: %d \n", PID, nb_rank); - //fflush(stdout); + // printf("\n End Send - Rank: %d , neighbor Rank: %d \n", PID, nb_rank); + // fflush(stdout); } void Communicator::waitallGPU() { - //printf("\n Start Waitall Rank: %d, request = %d \n", PID, (int)requestGPU.size()); - //fflush(stdout); - if(requestGPU.size() > 0) - { - MPI_Waitall(static_cast<int>(requestGPU.size()), &requestGPU[0], MPI_STATUSES_IGNORE); - requestGPU.resize(0); - rcount = 0; - } - //printf("\n End Waitall \n"); - //fflush(stdout); + // printf("\n Start Waitall Rank: %d, request = %d \n", PID, (int)requestGPU.size()); + // fflush(stdout); + if (requestGPU.size() > 0) { + MPI_Waitall(static_cast<int>(requestGPU.size()), &requestGPU[0], MPI_STATUSES_IGNORE); + requestGPU.resize(0); + rcount = 0; + } + // printf("\n End Waitall \n"); + // fflush(stdout); } -void Communicator::sendDataGPU( real* sbuf, int count_s, int nb_rank ) +void Communicator::sendDataGPU(real *sbuf, int count_s, int nb_rank) { - MPI_Send(sbuf, count_s, MPI_Type_GPU, nb_rank, 0, commGPU); -} -void Communicator::waitGPU(int id) -{ - MPI_Wait(&requestGPU[id], MPI_STATUSES_IGNORE); + MPI_Send(sbuf, count_s, MPI_Type_GPU, nb_rank, 0, commGPU); } +void Communicator::waitGPU(int id) { MPI_Wait(&requestGPU[id], MPI_STATUSES_IGNORE); } void Communicator::resetRequest() { - if(requestGPU.size() > 0) - { - requestGPU.resize(0); - rcount = 0; - } + if (requestGPU.size() > 0) { + requestGPU.resize(0); + rcount = 0; + } } void Communicator::barrierGPU() { - //printf("\n Start Waitall Rank: %d, request = %d \n", PID, (int)requestGPU.size()); - //fflush(stdout); - if(requestGPU.size() > 0) - { - MPI_Barrier(commGPU); - } - //printf("\n End Waitall \n"); - //fflush(stdout); -} -void Communicator::barrier() -{ - MPI_Barrier(commGPU); + // printf("\n Start Waitall Rank: %d, request = %d \n", PID, (int)requestGPU.size()); + // fflush(stdout); + if (requestGPU.size() > 0) { + MPI_Barrier(commGPU); + } + // printf("\n End Waitall \n"); + // fflush(stdout); } +void Communicator::barrier() { MPI_Barrier(commGPU); } ////////////////////////////////////////////////////////////////////////// -void Communicator::exchngDataGeo( int* sbuf_t, int* rbuf_t, int* sbuf_b, int* rbuf_b, int count ) -{ - MPI_Irecv(rbuf_t, count, MPI_INT, nbrbottom, 0, comm1d, &request[0]); - MPI_Irecv(rbuf_b, count, MPI_INT, nbrtop, 0, comm1d, &request[1]); - MPI_Isend(sbuf_t, count, MPI_INT, nbrtop, 0, comm1d, &request[2]); - MPI_Isend(sbuf_b, count, MPI_INT, nbrbottom, 0, comm1d, &request[3]); - MPI_Waitall(4, request, status); +void Communicator::exchngDataGeo(int *sbuf_t, int *rbuf_t, int *sbuf_b, int *rbuf_b, int count) +{ + MPI_Irecv(rbuf_t, count, MPI_INT, nbrbottom, 0, comm1d, &request[0]); + MPI_Irecv(rbuf_b, count, MPI_INT, nbrtop, 0, comm1d, &request[1]); + MPI_Isend(sbuf_t, count, MPI_INT, nbrtop, 0, comm1d, &request[2]); + MPI_Isend(sbuf_b, count, MPI_INT, nbrbottom, 0, comm1d, &request[3]); + MPI_Waitall(4, request, status); +} +int Communicator::getPID() const { return PID; } +int Communicator::getNummberOfProcess() const { return numprocs; } +int Communicator::getNeighbourTop() { return nbrtop; } +int Communicator::getNeighbourBottom() { return nbrbottom; } +MPI_Comm Communicator::getCommunicator() { return comm1d; } +void Communicator::startTimer() { starttime = MPI_Wtime(); } +void Communicator::stopTimer() { endtime = MPI_Wtime(); } +double Communicator::getTime() { return endtime - starttime; } +void Communicator::distributeGeometry(unsigned int *dataRoot, unsigned int *dataNode, int dataSizePerNode) +{ + MPI_Scatter(dataRoot, dataSizePerNode, MPI_UNSIGNED, dataNode, dataSizePerNode, MPI_UNSIGNED, 0, MPI_COMM_WORLD); +} +int Communicator::mapCudaDevice(const int &rank, const int &size, const std::vector<unsigned int> &devices, + const int &maxdev) +{ + int device = -1; + char *host = (char *)malloc(sizeof(char) * size * 255); + unsigned int *map = (unsigned int *)malloc(sizeof(unsigned int) * size); + + char hostname[255]; + gethostname(hostname, 254); + hostname[254] = 0; + + MPI_Gather(hostname, 255, MPI_BYTE, host, 255, MPI_BYTE, 0, MPI_COMM_WORLD); + + int i, j; + if (rank == 0) { + for (i = 0; i < size; i++) { + int counter = 0; + for (j = 0; j < i; j++) { + if (strcmp(&host[i * 255], &host[j * 255]) == 0) + counter++; + } + if (counter >= maxdev) { + VF_LOG_CRITICAL("More processes than GPUs!"); + exit(1); + } + map[i] = devices[counter]; + } + } + + MPI_Scatter(map, 1, MPI_UNSIGNED, &device, 1, MPI_UNSIGNED, 0, MPI_COMM_WORLD); + + VF_LOG_INFO("Rank: {} runs on host: {} with GPU: {}", rank, hostname, device); + + free(map); + free(host); + return device; } -int Communicator::getPID() -{ - return PID; -} -int Communicator::getNummberOfProcess() -{ - return numprocs; -} -int Communicator::getNeighbourTop() -{ - return nbrtop; -} -int Communicator::getNeighbourBottom() -{ - return nbrbottom; -} -MPI_Comm Communicator::getCommunicator() -{ - return comm1d; -} -void Communicator::startTimer() -{ - starttime = MPI_Wtime(); -} -void Communicator::stopTimer() -{ - endtime = MPI_Wtime(); -} -double Communicator::getTime() -{ - return endtime - starttime; -} -void Communicator::distributeGeometry(unsigned int* dataRoot, unsigned int* dataNode, int dataSizePerNode) -{ - MPI_Scatter(dataRoot, dataSizePerNode, MPI_UNSIGNED, dataNode, dataSizePerNode, MPI_UNSIGNED, 0, MPI_COMM_WORLD); -} -int Communicator::mapCudaDevice(const int &rank, const int &size, const std::vector<unsigned int> &devices, const int &maxdev) -{ - int device = -1; - char *host = (char*)malloc(sizeof(char)*size*255); - unsigned int *map = (unsigned int*)malloc(sizeof(unsigned int)*size); - - char hostname[255]; - gethostname(hostname, 254); - hostname[254] = 0; - - MPI_Gather(hostname, 255, MPI_BYTE, host, 255, MPI_BYTE, 0, MPI_COMM_WORLD); - - int i, j; - if(rank == 0) - { - for(i = 0; i < size; i++) - { - int counter = 0; - for(j = 0; j < i; j++) - { - if(strcmp(&host[i*255], &host[j*255]) == 0) - counter++; - } - if(counter >= maxdev) - { - fprintf(stderr,"More processes than GPUs!\n"); - exit(1); - } - map[i] = devices[counter]; - } - } - - 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); - free(map); - free(host); - return device; } diff --git a/src/gpu/VirtualFluids_GPU/Communication/Communicator.h b/src/gpu/VirtualFluids_GPU/Communication/Communicator.h index b584bc88081727ad1e298796ed45f1b05039c4f9..256dde87e8ff6b3a8c7abcae0ac31466cc68ba95 100644 --- a/src/gpu/VirtualFluids_GPU/Communication/Communicator.h +++ b/src/gpu/VirtualFluids_GPU/Communication/Communicator.h @@ -1,15 +1,13 @@ -#ifndef COMMUNICATOR_H -#define COMMUNICATOR_H +#ifndef COMMUNICATOR_GPU_H +#define COMMUNICATOR_GPU_H #include <vector> - - #include <mpi.h> #include "VirtualFluids_GPU_export.h" -#include "LBM/LB.h" +#include <basics/Core/DataTypes.h> ////////////////////////////////// #ifdef VF_DOUBLE_ACCURACY @@ -20,43 +18,46 @@ ////////////////////////////////// +namespace vf::gpu +{ + class VIRTUALFLUIDS_GPU_EXPORT Communicator { public: - static Communicator* getInstanz(); - static Communicator* getInstanz(const int numberOfProcs); - void exchngBottomToTop(float* sbuf, float* rbuf, int count); - void exchngTopToBottom(float* sbuf, float* rbuf, int count); - void waitAll(); - void distributeGeometry(unsigned int* dataRoot, unsigned int* dataNode, int dataSizePerNode); - int getPID(); - int getNummberOfProcess(); - int getNeighbourTop(); - int getNeighbourBottom(); - void exchngData(float* sbuf_t, float* rbuf_t, float* sbuf_b, float* rbuf_b, int count); - void exchngDataNB(float* sbuf_t, int count_st, float* rbuf_t, int count_rt, float* sbuf_b, int count_sb, float* rbuf_b, int count_rb); - ////////////////////////////////////////////////////////////////////////// - void exchngDataGPU(real* sbuf, int count_s, real* rbuf, int count_r, int nb_rank); - void sendRecvGPU(real* sbuf, int count_s, real* rbuf, int count_r, int nb_rank); - void nbRecvDataGPU( real* rbuf, int count_r, int nb_rank ); - void nbSendDataGPU( real* sbuf, int count_s, int nb_rank ); - void waitallGPU(); - void sendDataGPU( real* sbuf, int count_s, int nb_rank ); - void waitGPU(int id); - void resetRequest(); - void barrierGPU(); - void barrier(); - ////////////////////////////////////////////////////////////////////////// - void exchngDataGeo(int* sbuf_t, int* rbuf_t, int* sbuf_b, int* rbuf_b, int count); - MPI_Comm getCommunicator(); - void startTimer(); - void stopTimer(); - double getTime(); - int mapCudaDevice(const int &rank, const int &size, const std::vector<unsigned int> &devices, const int &maxdev); -protected: + 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(); + void distributeGeometry(unsigned int* dataRoot, unsigned int* dataNode, int dataSizePerNode); + int getPID() const; + int getNummberOfProcess() const; + int getNeighbourTop(); + int getNeighbourBottom(); + void exchngData(float* sbuf_t, float* rbuf_t, float* sbuf_b, float* rbuf_b, int count); + void exchngDataNB(float* sbuf_t, int count_st, float* rbuf_t, int count_rt, float* sbuf_b, int count_sb, float* rbuf_b, int count_rb); + ////////////////////////////////////////////////////////////////////////// + void exchngDataGPU(real* sbuf, int count_s, real* rbuf, int count_r, int nb_rank); + void sendRecvGPU(real* sbuf, int count_s, real* rbuf, int count_r, int nb_rank); + void nbRecvDataGPU( real* rbuf, int count_r, int nb_rank ); + void nbSendDataGPU( real* sbuf, int count_s, int nb_rank ); + void waitallGPU(); + void sendDataGPU( real* sbuf, int count_s, int nb_rank ); + void waitGPU(int id); + void resetRequest(); + void barrierGPU(); + void barrier(); + ////////////////////////////////////////////////////////////////////////// + void exchngDataGeo(int* sbuf_t, int* rbuf_t, int* sbuf_b, int* rbuf_b, int count); + MPI_Comm getCommunicator(); + void startTimer(); + void stopTimer(); + double getTime(); + int mapCudaDevice(const int &rank, const int &size, const std::vector<unsigned int> &devices, const int &maxdev); private: - static Communicator* instanz; int numprocs, PID; int nbrbottom, nbrtop; MPI_Comm comm1d, commGPU; @@ -69,9 +70,10 @@ private: double starttime; double endtime; Communicator(); - Communicator(const int numberOfProcs); - Communicator(const Communicator&); + ~Communicator(); }; +} + #endif diff --git a/src/gpu/VirtualFluids_GPU/Communication/ExchangeData27.cpp b/src/gpu/VirtualFluids_GPU/Communication/ExchangeData27.cpp index 7b4f4f45181e5b4e89f05d66525ab99b7020648f..d91e86c3140bb08aa2d8ef28d7cc147b23a2b804 100644 --- a/src/gpu/VirtualFluids_GPU/Communication/ExchangeData27.cpp +++ b/src/gpu/VirtualFluids_GPU/Communication/ExchangeData27.cpp @@ -7,7 +7,7 @@ //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // X //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -void exchangePreCollDataXGPU27(Parameter* para, Communicator* comm, CudaMemoryManager* cudaManager, int level) +void exchangePreCollDataXGPU27(Parameter* para, vf::gpu::Communicator& comm, CudaMemoryManager* cudaManager, int level) { /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //copy Device to Host @@ -30,7 +30,7 @@ void exchangePreCollDataXGPU27(Parameter* para, Communicator* comm, CudaMemoryMa //start non blocking MPI receive for (unsigned int i = 0; i < (unsigned int)(para->getNumberOfProcessNeighborsX(level, "send")); i++) { - comm->nbRecvDataGPU(para->getParH(level)->recvProcessNeighborX[i].f[0], + comm.nbRecvDataGPU(para->getParH(level)->recvProcessNeighborX[i].f[0], para->getParH(level)->recvProcessNeighborX[i].numberOfFs, para->getParH(level)->recvProcessNeighborX[i].rankNeighbor); } @@ -38,7 +38,7 @@ void exchangePreCollDataXGPU27(Parameter* para, Communicator* comm, CudaMemoryMa ////start non blocking MPI send //for (unsigned int i = 0; i < (unsigned int)(para->getNumberOfProcessNeighborsX(level, "send")); i++) //{ - // comm->nbSendDataGPU(para->getParH(level)->sendProcessNeighborX[i].f[0], + // comm.nbSendDataGPU(para->getParH(level)->sendProcessNeighborX[i].f[0], // para->getParH(level)->sendProcessNeighborX[i].numberOfFs, // para->getParH(level)->sendProcessNeighborX[i].rankNeighbor); //} @@ -46,13 +46,13 @@ void exchangePreCollDataXGPU27(Parameter* para, Communicator* comm, CudaMemoryMa ////Waitall //if (0 < (unsigned int)(para->getNumberOfProcessNeighborsX(level, "send"))) //{ - // comm->waitallGPU(); + // comm.waitallGPU(); //} ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //start blocking MPI send for (unsigned int i = 0; i < (unsigned int)(para->getNumberOfProcessNeighborsX(level, "send")); i++) { - comm->sendDataGPU(para->getParH(level)->sendProcessNeighborX[i].f[0], + comm.sendDataGPU(para->getParH(level)->sendProcessNeighborX[i].f[0], para->getParH(level)->sendProcessNeighborX[i].numberOfFs, para->getParH(level)->sendProcessNeighborX[i].rankNeighbor); } @@ -60,13 +60,13 @@ void exchangePreCollDataXGPU27(Parameter* para, Communicator* comm, CudaMemoryMa //Wait for (unsigned int i = 0; i < (unsigned int)(para->getNumberOfProcessNeighborsX(level, "send")); i++) { - comm->waitGPU(i); + comm.waitGPU(i); } /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //reset the request array if (0 < (unsigned int)(para->getNumberOfProcessNeighborsX(level, "send"))) { - comm->resetRequest(); + comm.resetRequest(); } /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //copy Host to Device @@ -88,7 +88,7 @@ void exchangePreCollDataXGPU27(Parameter* para, Communicator* comm, CudaMemoryMa /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// } //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -void exchangePostCollDataXGPU27(Parameter* para, Communicator* comm, CudaMemoryManager* cudaManager, int level) +void exchangePostCollDataXGPU27(Parameter* para, vf::gpu::Communicator& comm, CudaMemoryManager* cudaManager, int level) { /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //copy Device to Host @@ -111,7 +111,7 @@ void exchangePostCollDataXGPU27(Parameter* para, Communicator* comm, CudaMemoryM //start non blocking MPI receive for (unsigned int i = 0; i < (unsigned int)(para->getNumberOfProcessNeighborsX(level, "send")); i++) { - comm->nbRecvDataGPU(para->getParH(level)->recvProcessNeighborX[i].f[0], + comm.nbRecvDataGPU(para->getParH(level)->recvProcessNeighborX[i].f[0], para->getParH(level)->recvProcessNeighborX[i].numberOfFs, para->getParH(level)->recvProcessNeighborX[i].rankNeighbor); } @@ -119,7 +119,7 @@ void exchangePostCollDataXGPU27(Parameter* para, Communicator* comm, CudaMemoryM ////start non blocking MPI send //for (unsigned int i = 0; i < (unsigned int)(para->getNumberOfProcessNeighborsX(level, "send")); i++) //{ - // comm->nbSendDataGPU(para->getParH(level)->sendProcessNeighborX[i].f[0], + // comm.nbSendDataGPU(para->getParH(level)->sendProcessNeighborX[i].f[0], // para->getParH(level)->sendProcessNeighborX[i].numberOfFs, // para->getParH(level)->sendProcessNeighborX[i].rankNeighbor); //} @@ -127,13 +127,13 @@ void exchangePostCollDataXGPU27(Parameter* para, Communicator* comm, CudaMemoryM ////Waitall //if (0 < (unsigned int)(para->getNumberOfProcessNeighborsX(level, "send"))) //{ - // comm->waitallGPU(); + // comm.waitallGPU(); //} ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //start blocking MPI send for (unsigned int i = 0; i < (unsigned int)(para->getNumberOfProcessNeighborsX(level, "send")); i++) { - comm->sendDataGPU(para->getParH(level)->sendProcessNeighborX[i].f[0], + comm.sendDataGPU(para->getParH(level)->sendProcessNeighborX[i].f[0], para->getParH(level)->sendProcessNeighborX[i].numberOfFs, para->getParH(level)->sendProcessNeighborX[i].rankNeighbor); } @@ -141,13 +141,13 @@ void exchangePostCollDataXGPU27(Parameter* para, Communicator* comm, CudaMemoryM //Wait for (unsigned int i = 0; i < (unsigned int)(para->getNumberOfProcessNeighborsX(level, "send")); i++) { - comm->waitGPU(i); + comm.waitGPU(i); } /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //reset the request array if (0 < (unsigned int)(para->getNumberOfProcessNeighborsX(level, "send"))) { - comm->resetRequest(); + comm.resetRequest(); } /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //copy Host to Device @@ -176,7 +176,7 @@ void exchangePostCollDataXGPU27(Parameter* para, Communicator* comm, CudaMemoryM //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Y //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -void exchangePreCollDataYGPU27(Parameter* para, Communicator* comm, CudaMemoryManager* cudaManager, int level) +void exchangePreCollDataYGPU27(Parameter* para, vf::gpu::Communicator& comm, CudaMemoryManager* cudaManager, int level) { /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //copy Device to Host @@ -199,7 +199,7 @@ void exchangePreCollDataYGPU27(Parameter* para, Communicator* comm, CudaMemoryMa //start non blocking MPI receive for (unsigned int i = 0; i < (unsigned int)(para->getNumberOfProcessNeighborsY(level, "send")); i++) { - comm->nbRecvDataGPU(para->getParH(level)->recvProcessNeighborY[i].f[0], + comm.nbRecvDataGPU(para->getParH(level)->recvProcessNeighborY[i].f[0], para->getParH(level)->recvProcessNeighborY[i].numberOfFs, para->getParH(level)->recvProcessNeighborY[i].rankNeighbor); } @@ -207,7 +207,7 @@ void exchangePreCollDataYGPU27(Parameter* para, Communicator* comm, CudaMemoryMa ////start non blocking MPI send //for (unsigned int i = 0; i < (unsigned int)(para->getNumberOfProcessNeighborsY(level, "send")); i++) //{ - // comm->nbSendDataGPU(para->getParH(level)->sendProcessNeighborY[i].f[0], + // comm.nbSendDataGPU(para->getParH(level)->sendProcessNeighborY[i].f[0], // para->getParH(level)->sendProcessNeighborY[i].numberOfFs, // para->getParH(level)->sendProcessNeighborY[i].rankNeighbor); //} @@ -215,13 +215,13 @@ void exchangePreCollDataYGPU27(Parameter* para, Communicator* comm, CudaMemoryMa ////Waitall //if (0 < (unsigned int)(para->getNumberOfProcessNeighborsY(level, "send"))) //{ - // comm->waitallGPU(); + // comm.waitallGPU(); //} ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //start blocking MPI send for (unsigned int i = 0; i < (unsigned int)(para->getNumberOfProcessNeighborsY(level, "send")); i++) { - comm->sendDataGPU(para->getParH(level)->sendProcessNeighborY[i].f[0], + comm.sendDataGPU(para->getParH(level)->sendProcessNeighborY[i].f[0], para->getParH(level)->sendProcessNeighborY[i].numberOfFs, para->getParH(level)->sendProcessNeighborY[i].rankNeighbor); } @@ -229,13 +229,13 @@ void exchangePreCollDataYGPU27(Parameter* para, Communicator* comm, CudaMemoryMa //Wait for (unsigned int i = 0; i < (unsigned int)(para->getNumberOfProcessNeighborsY(level, "send")); i++) { - comm->waitGPU(i); + comm.waitGPU(i); } /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //reset the request array if (0 < (unsigned int)(para->getNumberOfProcessNeighborsY(level, "send"))) { - comm->resetRequest(); + comm.resetRequest(); } /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //copy Host to Device @@ -257,7 +257,7 @@ void exchangePreCollDataYGPU27(Parameter* para, Communicator* comm, CudaMemoryMa /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// } //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -void exchangePostCollDataYGPU27(Parameter* para, Communicator* comm, CudaMemoryManager* cudaManager, int level) +void exchangePostCollDataYGPU27(Parameter* para, vf::gpu::Communicator& comm, CudaMemoryManager* cudaManager, int level) { /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //copy Device to Host @@ -280,7 +280,7 @@ void exchangePostCollDataYGPU27(Parameter* para, Communicator* comm, CudaMemoryM //start non blocking MPI receive for (unsigned int i = 0; i < (unsigned int)(para->getNumberOfProcessNeighborsY(level, "send")); i++) { - comm->nbRecvDataGPU(para->getParH(level)->recvProcessNeighborY[i].f[0], + comm.nbRecvDataGPU(para->getParH(level)->recvProcessNeighborY[i].f[0], para->getParH(level)->recvProcessNeighborY[i].numberOfFs, para->getParH(level)->recvProcessNeighborY[i].rankNeighbor); } @@ -288,7 +288,7 @@ void exchangePostCollDataYGPU27(Parameter* para, Communicator* comm, CudaMemoryM ////start non blocking MPI send //for (unsigned int i = 0; i < (unsigned int)(para->getNumberOfProcessNeighborsY(level, "send")); i++) //{ - // comm->nbSendDataGPU(para->getParH(level)->sendProcessNeighborY[i].f[0], + // comm.nbSendDataGPU(para->getParH(level)->sendProcessNeighborY[i].f[0], // para->getParH(level)->sendProcessNeighborY[i].numberOfFs, // para->getParH(level)->sendProcessNeighborY[i].rankNeighbor); //} @@ -296,13 +296,13 @@ void exchangePostCollDataYGPU27(Parameter* para, Communicator* comm, CudaMemoryM ////Waitall //if (0 < (unsigned int)(para->getNumberOfProcessNeighborsY(level, "send"))) //{ - // comm->waitallGPU(); + // comm.waitallGPU(); //} ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //start blocking MPI send for (unsigned int i = 0; i < (unsigned int)(para->getNumberOfProcessNeighborsY(level, "send")); i++) { - comm->sendDataGPU(para->getParH(level)->sendProcessNeighborY[i].f[0], + comm.sendDataGPU(para->getParH(level)->sendProcessNeighborY[i].f[0], para->getParH(level)->sendProcessNeighborY[i].numberOfFs, para->getParH(level)->sendProcessNeighborY[i].rankNeighbor); } @@ -310,13 +310,13 @@ void exchangePostCollDataYGPU27(Parameter* para, Communicator* comm, CudaMemoryM //Wait for (unsigned int i = 0; i < (unsigned int)(para->getNumberOfProcessNeighborsY(level, "send")); i++) { - comm->waitGPU(i); + comm.waitGPU(i); } /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //reset the request array if (0 < (unsigned int)(para->getNumberOfProcessNeighborsY(level, "send"))) { - comm->resetRequest(); + comm.resetRequest(); } /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //copy Host to Device @@ -345,7 +345,7 @@ void exchangePostCollDataYGPU27(Parameter* para, Communicator* comm, CudaMemoryM //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Z //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -void exchangePreCollDataZGPU27(Parameter* para, Communicator* comm, CudaMemoryManager* cudaManager, int level) +void exchangePreCollDataZGPU27(Parameter* para, vf::gpu::Communicator& comm, CudaMemoryManager* cudaManager, int level) { /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //copy Device to Host @@ -368,7 +368,7 @@ void exchangePreCollDataZGPU27(Parameter* para, Communicator* comm, CudaMemoryMa //start non blocking MPI receive for (unsigned int i = 0; i < (unsigned int)(para->getNumberOfProcessNeighborsZ(level, "send")); i++) { - comm->nbRecvDataGPU(para->getParH(level)->recvProcessNeighborZ[i].f[0], + comm.nbRecvDataGPU(para->getParH(level)->recvProcessNeighborZ[i].f[0], para->getParH(level)->recvProcessNeighborZ[i].numberOfFs, para->getParH(level)->recvProcessNeighborZ[i].rankNeighbor); } @@ -376,7 +376,7 @@ void exchangePreCollDataZGPU27(Parameter* para, Communicator* comm, CudaMemoryMa ////start non blocking MPI send //for (unsigned int i = 0; i < (unsigned int)(para->getNumberOfProcessNeighborsZ(level, "send")); i++) //{ - // comm->nbSendDataGPU(para->getParH(level)->sendProcessNeighborZ[i].f[0], + // comm.nbSendDataGPU(para->getParH(level)->sendProcessNeighborZ[i].f[0], // para->getParH(level)->sendProcessNeighborZ[i].numberOfFs, // para->getParH(level)->sendProcessNeighborZ[i].rankNeighbor); //} @@ -384,13 +384,13 @@ void exchangePreCollDataZGPU27(Parameter* para, Communicator* comm, CudaMemoryMa ////Waitall //if (0 < (unsigned int)(para->getNumberOfProcessNeighborsZ(level, "send"))) //{ - // comm->waitallGPU(); + // comm.waitallGPU(); //} ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //start blocking MPI send for (unsigned int i = 0; i < (unsigned int)(para->getNumberOfProcessNeighborsZ(level, "send")); i++) { - comm->sendDataGPU(para->getParH(level)->sendProcessNeighborZ[i].f[0], + comm.sendDataGPU(para->getParH(level)->sendProcessNeighborZ[i].f[0], para->getParH(level)->sendProcessNeighborZ[i].numberOfFs, para->getParH(level)->sendProcessNeighborZ[i].rankNeighbor); } @@ -398,13 +398,13 @@ void exchangePreCollDataZGPU27(Parameter* para, Communicator* comm, CudaMemoryMa //Wait for (unsigned int i = 0; i < (unsigned int)(para->getNumberOfProcessNeighborsZ(level, "send")); i++) { - comm->waitGPU(i); + comm.waitGPU(i); } /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //reset the request array if (0 < (unsigned int)(para->getNumberOfProcessNeighborsZ(level, "send"))) { - comm->resetRequest(); + comm.resetRequest(); } /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //copy Host to Device @@ -426,7 +426,7 @@ void exchangePreCollDataZGPU27(Parameter* para, Communicator* comm, CudaMemoryMa /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// } //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -void exchangePostCollDataZGPU27(Parameter* para, Communicator* comm, CudaMemoryManager* cudaManager, int level) +void exchangePostCollDataZGPU27(Parameter* para, vf::gpu::Communicator& comm, CudaMemoryManager* cudaManager, int level) { /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //copy Device to Host @@ -449,7 +449,7 @@ void exchangePostCollDataZGPU27(Parameter* para, Communicator* comm, CudaMemoryM //start non blocking MPI receive for (unsigned int i = 0; i < (unsigned int)(para->getNumberOfProcessNeighborsZ(level, "send")); i++) { - comm->nbRecvDataGPU(para->getParH(level)->recvProcessNeighborZ[i].f[0], + comm.nbRecvDataGPU(para->getParH(level)->recvProcessNeighborZ[i].f[0], para->getParH(level)->recvProcessNeighborZ[i].numberOfFs, para->getParH(level)->recvProcessNeighborZ[i].rankNeighbor); } @@ -457,7 +457,7 @@ void exchangePostCollDataZGPU27(Parameter* para, Communicator* comm, CudaMemoryM ////start non blocking MPI send //for (unsigned int i = 0; i < (unsigned int)(para->getNumberOfProcessNeighborsZ(level, "send")); i++) //{ - // comm->nbSendDataGPU(para->getParH(level)->sendProcessNeighborZ[i].f[0], + // comm.nbSendDataGPU(para->getParH(level)->sendProcessNeighborZ[i].f[0], // para->getParH(level)->sendProcessNeighborZ[i].numberOfFs, // para->getParH(level)->sendProcessNeighborZ[i].rankNeighbor); //} @@ -465,13 +465,13 @@ void exchangePostCollDataZGPU27(Parameter* para, Communicator* comm, CudaMemoryM ////Waitall //if (0 < (unsigned int)(para->getNumberOfProcessNeighborsZ(level, "send"))) //{ - // comm->waitallGPU(); + // comm.waitallGPU(); //} ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //start blocking MPI send for (unsigned int i = 0; i < (unsigned int)(para->getNumberOfProcessNeighborsZ(level, "send")); i++) { - comm->sendDataGPU(para->getParH(level)->sendProcessNeighborZ[i].f[0], + comm.sendDataGPU(para->getParH(level)->sendProcessNeighborZ[i].f[0], para->getParH(level)->sendProcessNeighborZ[i].numberOfFs, para->getParH(level)->sendProcessNeighborZ[i].rankNeighbor); } @@ -479,13 +479,13 @@ void exchangePostCollDataZGPU27(Parameter* para, Communicator* comm, CudaMemoryM //Wait for (unsigned int i = 0; i < (unsigned int)(para->getNumberOfProcessNeighborsZ(level, "send")); i++) { - comm->waitGPU(i); + comm.waitGPU(i); } /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //reset the request array if (0 < (unsigned int)(para->getNumberOfProcessNeighborsZ(level, "send"))) { - comm->resetRequest(); + comm.resetRequest(); } /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //copy Host to Device @@ -529,7 +529,7 @@ void exchangePostCollDataZGPU27(Parameter* para, Communicator* comm, CudaMemoryM //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //1D domain decomposition //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -void exchangePreCollDataGPU27(Parameter* para, 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++) { @@ -547,7 +547,7 @@ void exchangePreCollDataGPU27(Parameter* para, Communicator* comm, CudaMemoryMan ////////////////////////////////////////////////////////////////////////// cudaManager->cudaCopyProcessNeighborFsDH(level, i); ////////////////////////////////////////////////////////////////////////// - comm->exchngDataGPU(para->getParH(level)->sendProcessNeighbor[i].f[0], + comm.exchngDataGPU(para->getParH(level)->sendProcessNeighbor[i].f[0], para->getParH(level)->sendProcessNeighbor[i].numberOfFs, para->getParH(level)->recvProcessNeighbor[i].f[0], para->getParH(level)->recvProcessNeighbor[i].numberOfFs, @@ -574,7 +574,7 @@ void exchangePreCollDataGPU27(Parameter* para, Communicator* comm, CudaMemoryMan //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -void exchangePostCollDataGPU27(Parameter* para, 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++) { @@ -592,7 +592,7 @@ void exchangePostCollDataGPU27(Parameter* para, Communicator* comm, CudaMemoryMa ////////////////////////////////////////////////////////////////////////// cudaManager->cudaCopyProcessNeighborFsDH(level, i); ////////////////////////////////////////////////////////////////////////// - comm->exchngDataGPU(para->getParH(level)->sendProcessNeighbor[i].f[0], + comm.exchngDataGPU(para->getParH(level)->sendProcessNeighbor[i].f[0], para->getParH(level)->sendProcessNeighbor[i].numberOfFs, para->getParH(level)->recvProcessNeighbor[i].f[0], para->getParH(level)->recvProcessNeighbor[i].numberOfFs, @@ -623,7 +623,7 @@ void exchangePostCollDataGPU27(Parameter* para, Communicator* comm, CudaMemoryMa ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //// X ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -//void exchangePreCollDataXGPU27(Parameter* para, Communicator* comm, int level) +//void exchangePreCollDataXGPU27(Parameter* para, vf::gpu::Communicator& comm, int level) //{ // for (unsigned int i = 0; i < (unsigned int)(para->getNumberOfProcessNeighborsX(level, "send")); i++) // { @@ -641,7 +641,7 @@ void exchangePostCollDataGPU27(Parameter* para, Communicator* comm, CudaMemoryMa // ////////////////////////////////////////////////////////////////////////// // para->cudaCopyProcessNeighborXFsDH(level, i); // ////////////////////////////////////////////////////////////////////////// -// comm->exchngDataGPU(para->getParH(level)->sendProcessNeighborX[i].f[0], +// 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, @@ -663,7 +663,7 @@ void exchangePostCollDataGPU27(Parameter* para, Communicator* comm, CudaMemoryMa // } //} ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -//void exchangePostCollDataXGPU27(Parameter* para, 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++) // { @@ -681,7 +681,7 @@ void exchangePostCollDataGPU27(Parameter* para, Communicator* comm, CudaMemoryMa // ////////////////////////////////////////////////////////////////////////// // para->cudaCopyProcessNeighborXFsDH(level, i); // ////////////////////////////////////////////////////////////////////////// -// comm->exchngDataGPU(para->getParH(level)->sendProcessNeighborX[i].f[0], +// 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, @@ -710,7 +710,7 @@ void exchangePostCollDataGPU27(Parameter* para, Communicator* comm, CudaMemoryMa ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //// Y ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -//void exchangePreCollDataYGPU27(Parameter* para, 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++) // { @@ -728,7 +728,7 @@ void exchangePostCollDataGPU27(Parameter* para, Communicator* comm, CudaMemoryMa // ////////////////////////////////////////////////////////////////////////// // para->cudaCopyProcessNeighborYFsDH(level, i); // ////////////////////////////////////////////////////////////////////////// -// comm->exchngDataGPU(para->getParH(level)->sendProcessNeighborY[i].f[0], +// comm.exchngDataGPU(para->getParH(level)->sendProcessNeighborY[i].f[0], // para->getParH(level)->sendProcessNeighborY[i].numberOfFs, // para->getParH(level)->recvProcessNeighborY[i].f[0], // para->getParH(level)->recvProcessNeighborY[i].numberOfFs, @@ -750,7 +750,7 @@ void exchangePostCollDataGPU27(Parameter* para, Communicator* comm, CudaMemoryMa // } //} ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -//void exchangePostCollDataYGPU27(Parameter* para, 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++) // { @@ -768,7 +768,7 @@ void exchangePostCollDataGPU27(Parameter* para, Communicator* comm, CudaMemoryMa // ////////////////////////////////////////////////////////////////////////// // para->cudaCopyProcessNeighborYFsDH(level, i); // ////////////////////////////////////////////////////////////////////////// -// comm->exchngDataGPU(para->getParH(level)->sendProcessNeighborY[i].f[0], +// comm.exchngDataGPU(para->getParH(level)->sendProcessNeighborY[i].f[0], // para->getParH(level)->sendProcessNeighborY[i].numberOfFs, // para->getParH(level)->recvProcessNeighborY[i].f[0], // para->getParH(level)->recvProcessNeighborY[i].numberOfFs, @@ -797,7 +797,7 @@ void exchangePostCollDataGPU27(Parameter* para, Communicator* comm, CudaMemoryMa ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //// Z ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -//void exchangePreCollDataZGPU27(Parameter* para, 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++) // { @@ -815,7 +815,7 @@ void exchangePostCollDataGPU27(Parameter* para, Communicator* comm, CudaMemoryMa // ////////////////////////////////////////////////////////////////////////// // para->cudaCopyProcessNeighborZFsDH(level, i); // ////////////////////////////////////////////////////////////////////////// -// comm->exchngDataGPU(para->getParH(level)->sendProcessNeighborZ[i].f[0], +// comm.exchngDataGPU(para->getParH(level)->sendProcessNeighborZ[i].f[0], // para->getParH(level)->sendProcessNeighborZ[i].numberOfFs, // para->getParH(level)->recvProcessNeighborZ[i].f[0], // para->getParH(level)->recvProcessNeighborZ[i].numberOfFs, @@ -837,7 +837,7 @@ void exchangePostCollDataGPU27(Parameter* para, Communicator* comm, CudaMemoryMa // } //} ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -//void exchangePostCollDataZGPU27(Parameter* para, 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++) // { @@ -855,7 +855,7 @@ void exchangePostCollDataGPU27(Parameter* para, Communicator* comm, CudaMemoryMa // ////////////////////////////////////////////////////////////////////////// // para->cudaCopyProcessNeighborZFsDH(level, i); // ////////////////////////////////////////////////////////////////////////// -// comm->exchngDataGPU(para->getParH(level)->sendProcessNeighborZ[i].f[0], +// comm.exchngDataGPU(para->getParH(level)->sendProcessNeighborZ[i].f[0], // para->getParH(level)->sendProcessNeighborZ[i].numberOfFs, // para->getParH(level)->recvProcessNeighborZ[i].f[0], // para->getParH(level)->recvProcessNeighborZ[i].numberOfFs, @@ -932,7 +932,7 @@ void exchangePostCollDataGPU27(Parameter* para, Communicator* comm, CudaMemoryMa //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // X //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -void exchangePreCollDataADXGPU27(Parameter* para, Communicator* comm, CudaMemoryManager* cudaManager, int level) +void exchangePreCollDataADXGPU27(Parameter* para, vf::gpu::Communicator& comm, CudaMemoryManager* cudaManager, int level) { /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //copy Device to Host @@ -955,7 +955,7 @@ void exchangePreCollDataADXGPU27(Parameter* para, Communicator* comm, CudaMemory //start non blocking MPI receive for (unsigned int i = 0; i < (unsigned int)(para->getNumberOfProcessNeighborsX(level, "send")); i++) { - comm->nbRecvDataGPU(para->getParH(level)->recvProcessNeighborADX[i].f[0], + comm.nbRecvDataGPU(para->getParH(level)->recvProcessNeighborADX[i].f[0], para->getParH(level)->recvProcessNeighborADX[i].numberOfFs, para->getParH(level)->recvProcessNeighborADX[i].rankNeighbor); } @@ -963,7 +963,7 @@ void exchangePreCollDataADXGPU27(Parameter* para, Communicator* comm, CudaMemory ////start non blocking MPI send //for (unsigned int i = 0; i < (unsigned int)(para->getNumberOfProcessNeighborsX(level, "send")); i++) //{ - // comm->nbSendDataGPU(para->getParH(level)->sendProcessNeighborADX[i].f[0], + // comm.nbSendDataGPU(para->getParH(level)->sendProcessNeighborADX[i].f[0], // para->getParH(level)->sendProcessNeighborADX[i].numberOfFs, // para->getParH(level)->sendProcessNeighborADX[i].rankNeighbor); //} @@ -971,13 +971,13 @@ void exchangePreCollDataADXGPU27(Parameter* para, Communicator* comm, CudaMemory ////Waitall //if (0 < (unsigned int)(para->getNumberOfProcessNeighborsX(level, "send"))) //{ - // comm->waitallGPU(); + // comm.waitallGPU(); //} ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //start blocking MPI send for (unsigned int i = 0; i < (unsigned int)(para->getNumberOfProcessNeighborsX(level, "send")); i++) { - comm->sendDataGPU(para->getParH(level)->sendProcessNeighborADX[i].f[0], + comm.sendDataGPU(para->getParH(level)->sendProcessNeighborADX[i].f[0], para->getParH(level)->sendProcessNeighborADX[i].numberOfFs, para->getParH(level)->sendProcessNeighborADX[i].rankNeighbor); } @@ -985,13 +985,13 @@ void exchangePreCollDataADXGPU27(Parameter* para, Communicator* comm, CudaMemory //Wait for (unsigned int i = 0; i < (unsigned int)(para->getNumberOfProcessNeighborsX(level, "send")); i++) { - comm->waitGPU(i); + comm.waitGPU(i); } /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //reset the request array if (0 < (unsigned int)(para->getNumberOfProcessNeighborsX(level, "send"))) { - comm->resetRequest(); + comm.resetRequest(); } /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //copy Host to Device @@ -1013,7 +1013,7 @@ void exchangePreCollDataADXGPU27(Parameter* para, Communicator* comm, CudaMemory /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// } //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -void exchangePostCollDataADXGPU27(Parameter* para, Communicator* comm, CudaMemoryManager* cudaManager, int level) +void exchangePostCollDataADXGPU27(Parameter* para, vf::gpu::Communicator& comm, CudaMemoryManager* cudaManager, int level) { /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //copy Device to Host @@ -1036,7 +1036,7 @@ void exchangePostCollDataADXGPU27(Parameter* para, Communicator* comm, CudaMemor //start non blocking MPI receive for (unsigned int i = 0; i < (unsigned int)(para->getNumberOfProcessNeighborsX(level, "send")); i++) { - comm->nbRecvDataGPU(para->getParH(level)->recvProcessNeighborADX[i].f[0], + comm.nbRecvDataGPU(para->getParH(level)->recvProcessNeighborADX[i].f[0], para->getParH(level)->recvProcessNeighborADX[i].numberOfFs, para->getParH(level)->recvProcessNeighborADX[i].rankNeighbor); } @@ -1044,7 +1044,7 @@ void exchangePostCollDataADXGPU27(Parameter* para, Communicator* comm, CudaMemor ////start non blocking MPI send //for (unsigned int i = 0; i < (unsigned int)(para->getNumberOfProcessNeighborsX(level, "send")); i++) //{ - // comm->nbSendDataGPU(para->getParH(level)->sendProcessNeighborADX[i].f[0], + // comm.nbSendDataGPU(para->getParH(level)->sendProcessNeighborADX[i].f[0], // para->getParH(level)->sendProcessNeighborADX[i].numberOfFs, // para->getParH(level)->sendProcessNeighborADX[i].rankNeighbor); //} @@ -1052,13 +1052,13 @@ void exchangePostCollDataADXGPU27(Parameter* para, Communicator* comm, CudaMemor ////Waitall //if (0 < (unsigned int)(para->getNumberOfProcessNeighborsX(level, "send"))) //{ - // comm->waitallGPU(); + // comm.waitallGPU(); //} ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //start blocking MPI send for (unsigned int i = 0; i < (unsigned int)(para->getNumberOfProcessNeighborsX(level, "send")); i++) { - comm->sendDataGPU(para->getParH(level)->sendProcessNeighborADX[i].f[0], + comm.sendDataGPU(para->getParH(level)->sendProcessNeighborADX[i].f[0], para->getParH(level)->sendProcessNeighborADX[i].numberOfFs, para->getParH(level)->sendProcessNeighborADX[i].rankNeighbor); } @@ -1066,13 +1066,13 @@ void exchangePostCollDataADXGPU27(Parameter* para, Communicator* comm, CudaMemor //Wait for (unsigned int i = 0; i < (unsigned int)(para->getNumberOfProcessNeighborsX(level, "send")); i++) { - comm->waitGPU(i); + comm.waitGPU(i); } /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //reset the request array if (0 < (unsigned int)(para->getNumberOfProcessNeighborsX(level, "send"))) { - comm->resetRequest(); + comm.resetRequest(); } /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //copy Host to Device @@ -1101,7 +1101,7 @@ void exchangePostCollDataADXGPU27(Parameter* para, Communicator* comm, CudaMemor //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Y //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -void exchangePreCollDataADYGPU27(Parameter* para, Communicator* comm, CudaMemoryManager* cudaManager, int level) +void exchangePreCollDataADYGPU27(Parameter* para, vf::gpu::Communicator& comm, CudaMemoryManager* cudaManager, int level) { /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //copy Device to Host @@ -1124,7 +1124,7 @@ void exchangePreCollDataADYGPU27(Parameter* para, Communicator* comm, CudaMemory //start non blocking MPI receive for (unsigned int i = 0; i < (unsigned int)(para->getNumberOfProcessNeighborsY(level, "send")); i++) { - comm->nbRecvDataGPU(para->getParH(level)->recvProcessNeighborADY[i].f[0], + comm.nbRecvDataGPU(para->getParH(level)->recvProcessNeighborADY[i].f[0], para->getParH(level)->recvProcessNeighborADY[i].numberOfFs, para->getParH(level)->recvProcessNeighborADY[i].rankNeighbor); } @@ -1132,7 +1132,7 @@ void exchangePreCollDataADYGPU27(Parameter* para, Communicator* comm, CudaMemory ////start non blocking MPI send //for (unsigned int i = 0; i < (unsigned int)(para->getNumberOfProcessNeighborsY(level, "send")); i++) //{ - // comm->nbSendDataGPU(para->getParH(level)->sendProcessNeighborADY[i].f[0], + // comm.nbSendDataGPU(para->getParH(level)->sendProcessNeighborADY[i].f[0], // para->getParH(level)->sendProcessNeighborADY[i].numberOfFs, // para->getParH(level)->sendProcessNeighborADY[i].rankNeighbor); //} @@ -1140,13 +1140,13 @@ void exchangePreCollDataADYGPU27(Parameter* para, Communicator* comm, CudaMemory ////Waitall //if (0 < (unsigned int)(para->getNumberOfProcessNeighborsY(level, "send"))) //{ - // comm->waitallGPU(); + // comm.waitallGPU(); //} ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //start blocking MPI send for (unsigned int i = 0; i < (unsigned int)(para->getNumberOfProcessNeighborsY(level, "send")); i++) { - comm->sendDataGPU(para->getParH(level)->sendProcessNeighborADY[i].f[0], + comm.sendDataGPU(para->getParH(level)->sendProcessNeighborADY[i].f[0], para->getParH(level)->sendProcessNeighborADY[i].numberOfFs, para->getParH(level)->sendProcessNeighborADY[i].rankNeighbor); } @@ -1154,13 +1154,13 @@ void exchangePreCollDataADYGPU27(Parameter* para, Communicator* comm, CudaMemory //Wait for (unsigned int i = 0; i < (unsigned int)(para->getNumberOfProcessNeighborsY(level, "send")); i++) { - comm->waitGPU(i); + comm.waitGPU(i); } /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //reset the request array if (0 < (unsigned int)(para->getNumberOfProcessNeighborsY(level, "send"))) { - comm->resetRequest(); + comm.resetRequest(); } /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //copy Host to Device @@ -1182,7 +1182,7 @@ void exchangePreCollDataADYGPU27(Parameter* para, Communicator* comm, CudaMemory /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// } //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -void exchangePostCollDataADYGPU27(Parameter* para, Communicator* comm, CudaMemoryManager* cudaManager, int level) +void exchangePostCollDataADYGPU27(Parameter* para, vf::gpu::Communicator& comm, CudaMemoryManager* cudaManager, int level) { /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //copy Device to Host @@ -1205,7 +1205,7 @@ void exchangePostCollDataADYGPU27(Parameter* para, Communicator* comm, CudaMemor //start non blocking MPI receive for (unsigned int i = 0; i < (unsigned int)(para->getNumberOfProcessNeighborsY(level, "send")); i++) { - comm->nbRecvDataGPU(para->getParH(level)->recvProcessNeighborADY[i].f[0], + comm.nbRecvDataGPU(para->getParH(level)->recvProcessNeighborADY[i].f[0], para->getParH(level)->recvProcessNeighborADY[i].numberOfFs, para->getParH(level)->recvProcessNeighborADY[i].rankNeighbor); } @@ -1213,7 +1213,7 @@ void exchangePostCollDataADYGPU27(Parameter* para, Communicator* comm, CudaMemor ////start non blocking MPI send //for (unsigned int i = 0; i < (unsigned int)(para->getNumberOfProcessNeighborsY(level, "send")); i++) //{ - // comm->nbSendDataGPU(para->getParH(level)->sendProcessNeighborADY[i].f[0], + // comm.nbSendDataGPU(para->getParH(level)->sendProcessNeighborADY[i].f[0], // para->getParH(level)->sendProcessNeighborADY[i].numberOfFs, // para->getParH(level)->sendProcessNeighborADY[i].rankNeighbor); //} @@ -1221,13 +1221,13 @@ void exchangePostCollDataADYGPU27(Parameter* para, Communicator* comm, CudaMemor ////Waitall //if (0 < (unsigned int)(para->getNumberOfProcessNeighborsY(level, "send"))) //{ - // comm->waitallGPU(); + // comm.waitallGPU(); //} ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //start blocking MPI send for (unsigned int i = 0; i < (unsigned int)(para->getNumberOfProcessNeighborsY(level, "send")); i++) { - comm->sendDataGPU(para->getParH(level)->sendProcessNeighborADY[i].f[0], + comm.sendDataGPU(para->getParH(level)->sendProcessNeighborADY[i].f[0], para->getParH(level)->sendProcessNeighborADY[i].numberOfFs, para->getParH(level)->sendProcessNeighborADY[i].rankNeighbor); } @@ -1235,13 +1235,13 @@ void exchangePostCollDataADYGPU27(Parameter* para, Communicator* comm, CudaMemor //Wait for (unsigned int i = 0; i < (unsigned int)(para->getNumberOfProcessNeighborsY(level, "send")); i++) { - comm->waitGPU(i); + comm.waitGPU(i); } /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //reset the request array if (0 < (unsigned int)(para->getNumberOfProcessNeighborsY(level, "send"))) { - comm->resetRequest(); + comm.resetRequest(); } /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //copy Host to Device @@ -1270,7 +1270,7 @@ void exchangePostCollDataADYGPU27(Parameter* para, Communicator* comm, CudaMemor //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Z //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -void exchangePreCollDataADZGPU27(Parameter* para, Communicator* comm, CudaMemoryManager* cudaManager, int level) +void exchangePreCollDataADZGPU27(Parameter* para, vf::gpu::Communicator& comm, CudaMemoryManager* cudaManager, int level) { /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //copy Device to Host @@ -1293,7 +1293,7 @@ void exchangePreCollDataADZGPU27(Parameter* para, Communicator* comm, CudaMemory //start non blocking MPI receive for (unsigned int i = 0; i < (unsigned int)(para->getNumberOfProcessNeighborsZ(level, "send")); i++) { - comm->nbRecvDataGPU(para->getParH(level)->recvProcessNeighborADZ[i].f[0], + comm.nbRecvDataGPU(para->getParH(level)->recvProcessNeighborADZ[i].f[0], para->getParH(level)->recvProcessNeighborADZ[i].numberOfFs, para->getParH(level)->recvProcessNeighborADZ[i].rankNeighbor); } @@ -1301,7 +1301,7 @@ void exchangePreCollDataADZGPU27(Parameter* para, Communicator* comm, CudaMemory ////start non blocking MPI send //for (unsigned int i = 0; i < (unsigned int)(para->getNumberOfProcessNeighborsZ(level, "send")); i++) //{ - // comm->nbSendDataGPU(para->getParH(level)->sendProcessNeighborADZ[i].f[0], + // comm.nbSendDataGPU(para->getParH(level)->sendProcessNeighborADZ[i].f[0], // para->getParH(level)->sendProcessNeighborADZ[i].numberOfFs, // para->getParH(level)->sendProcessNeighborADZ[i].rankNeighbor); //} @@ -1309,13 +1309,13 @@ void exchangePreCollDataADZGPU27(Parameter* para, Communicator* comm, CudaMemory ////Waitall //if (0 < (unsigned int)(para->getNumberOfProcessNeighborsZ(level, "send"))) //{ - // comm->waitallGPU(); + // comm.waitallGPU(); //} ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //start blocking MPI send for (unsigned int i = 0; i < (unsigned int)(para->getNumberOfProcessNeighborsZ(level, "send")); i++) { - comm->sendDataGPU(para->getParH(level)->sendProcessNeighborADZ[i].f[0], + comm.sendDataGPU(para->getParH(level)->sendProcessNeighborADZ[i].f[0], para->getParH(level)->sendProcessNeighborADZ[i].numberOfFs, para->getParH(level)->sendProcessNeighborADZ[i].rankNeighbor); } @@ -1323,13 +1323,13 @@ void exchangePreCollDataADZGPU27(Parameter* para, Communicator* comm, CudaMemory //Wait for (unsigned int i = 0; i < (unsigned int)(para->getNumberOfProcessNeighborsZ(level, "send")); i++) { - comm->waitGPU(i); + comm.waitGPU(i); } /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //reset the request array if (0 < (unsigned int)(para->getNumberOfProcessNeighborsZ(level, "send"))) { - comm->resetRequest(); + comm.resetRequest(); } /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //copy Host to Device @@ -1351,7 +1351,7 @@ void exchangePreCollDataADZGPU27(Parameter* para, Communicator* comm, CudaMemory /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// } //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -void exchangePostCollDataADZGPU27(Parameter* para, Communicator* comm, CudaMemoryManager* cudaManager, int level) +void exchangePostCollDataADZGPU27(Parameter* para, vf::gpu::Communicator& comm, CudaMemoryManager* cudaManager, int level) { /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //copy Device to Host @@ -1374,7 +1374,7 @@ void exchangePostCollDataADZGPU27(Parameter* para, Communicator* comm, CudaMemor //start non blocking MPI receive for (unsigned int i = 0; i < (unsigned int)(para->getNumberOfProcessNeighborsZ(level, "send")); i++) { - comm->nbRecvDataGPU(para->getParH(level)->recvProcessNeighborADZ[i].f[0], + comm.nbRecvDataGPU(para->getParH(level)->recvProcessNeighborADZ[i].f[0], para->getParH(level)->recvProcessNeighborADZ[i].numberOfFs, para->getParH(level)->recvProcessNeighborADZ[i].rankNeighbor); } @@ -1382,7 +1382,7 @@ void exchangePostCollDataADZGPU27(Parameter* para, Communicator* comm, CudaMemor ////start non blocking MPI send //for (unsigned int i = 0; i < (unsigned int)(para->getNumberOfProcessNeighborsZ(level, "send")); i++) //{ - // comm->nbSendDataGPU(para->getParH(level)->sendProcessNeighborADZ[i].f[0], + // comm.nbSendDataGPU(para->getParH(level)->sendProcessNeighborADZ[i].f[0], // para->getParH(level)->sendProcessNeighborADZ[i].numberOfFs, // para->getParH(level)->sendProcessNeighborADZ[i].rankNeighbor); //} @@ -1390,13 +1390,13 @@ void exchangePostCollDataADZGPU27(Parameter* para, Communicator* comm, CudaMemor ////Waitall //if (0 < (unsigned int)(para->getNumberOfProcessNeighborsZ(level, "send"))) //{ - // comm->waitallGPU(); + // comm.waitallGPU(); //} ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //start blocking MPI send for (unsigned int i = 0; i < (unsigned int)(para->getNumberOfProcessNeighborsZ(level, "send")); i++) { - comm->sendDataGPU(para->getParH(level)->sendProcessNeighborADZ[i].f[0], + comm.sendDataGPU(para->getParH(level)->sendProcessNeighborADZ[i].f[0], para->getParH(level)->sendProcessNeighborADZ[i].numberOfFs, para->getParH(level)->sendProcessNeighborADZ[i].rankNeighbor); } @@ -1404,13 +1404,13 @@ void exchangePostCollDataADZGPU27(Parameter* para, Communicator* comm, CudaMemor //Wait for (unsigned int i = 0; i < (unsigned int)(para->getNumberOfProcessNeighborsZ(level, "send")); i++) { - comm->waitGPU(i); + comm.waitGPU(i); } /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //reset the request array if (0 < (unsigned int)(para->getNumberOfProcessNeighborsZ(level, "send"))) { - comm->resetRequest(); + comm.resetRequest(); } /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //copy Host to Device @@ -1486,7 +1486,7 @@ void exchangePostCollDataADZGPU27(Parameter* para, Communicator* comm, CudaMemor //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // X //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -void exchangeCollDataF3XGPU(Parameter* para, Communicator* comm, CudaMemoryManager* cudaManager, int level) +void exchangeCollDataF3XGPU(Parameter* para, vf::gpu::Communicator& comm, CudaMemoryManager* cudaManager, int level) { /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //copy Device to Host @@ -1510,7 +1510,7 @@ void exchangeCollDataF3XGPU(Parameter* para, Communicator* comm, CudaMemoryManag //start non blocking MPI receive for (unsigned int i = 0; i < (unsigned int)(para->getNumberOfProcessNeighborsX(level, "send")); i++) { - comm->nbRecvDataGPU( + comm.nbRecvDataGPU( para->getParH(level)->recvProcessNeighborF3X[i].g[0], para->getParH(level)->recvProcessNeighborF3X[i].numberOfGs, para->getParH(level)->recvProcessNeighborF3X[i].rankNeighbor); @@ -1519,7 +1519,7 @@ void exchangeCollDataF3XGPU(Parameter* para, Communicator* comm, CudaMemoryManag //start blocking MPI send for (unsigned int i = 0; i < (unsigned int)(para->getNumberOfProcessNeighborsX(level, "send")); i++) { - comm->sendDataGPU( + comm.sendDataGPU( para->getParH(level)->sendProcessNeighborF3X[i].g[0], para->getParH(level)->sendProcessNeighborF3X[i].numberOfGs, para->getParH(level)->sendProcessNeighborF3X[i].rankNeighbor); @@ -1528,13 +1528,13 @@ void exchangeCollDataF3XGPU(Parameter* para, Communicator* comm, CudaMemoryManag //Wait for (unsigned int i = 0; i < (unsigned int)(para->getNumberOfProcessNeighborsX(level, "send")); i++) { - comm->waitGPU(i); + comm.waitGPU(i); } /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //reset the request array if (0 < (unsigned int)(para->getNumberOfProcessNeighborsX(level, "send"))) { - comm->resetRequest(); + comm.resetRequest(); } /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //copy Host to Device @@ -1564,7 +1564,7 @@ void exchangeCollDataF3XGPU(Parameter* para, Communicator* comm, CudaMemoryManag //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Y //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -void exchangeCollDataF3YGPU(Parameter* para, Communicator* comm, CudaMemoryManager* cudaManager, int level) +void exchangeCollDataF3YGPU(Parameter* para, vf::gpu::Communicator& comm, CudaMemoryManager* cudaManager, int level) { /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //copy Device to Host @@ -1588,7 +1588,7 @@ void exchangeCollDataF3YGPU(Parameter* para, Communicator* comm, CudaMemoryManag //start non blocking MPI receive for (unsigned int i = 0; i < (unsigned int)(para->getNumberOfProcessNeighborsY(level, "send")); i++) { - comm->nbRecvDataGPU( + comm.nbRecvDataGPU( para->getParH(level)->recvProcessNeighborF3Y[i].g[0], para->getParH(level)->recvProcessNeighborF3Y[i].numberOfGs, para->getParH(level)->recvProcessNeighborF3Y[i].rankNeighbor); @@ -1597,7 +1597,7 @@ void exchangeCollDataF3YGPU(Parameter* para, Communicator* comm, CudaMemoryManag //start blocking MPI send for (unsigned int i = 0; i < (unsigned int)(para->getNumberOfProcessNeighborsY(level, "send")); i++) { - comm->sendDataGPU( + comm.sendDataGPU( para->getParH(level)->sendProcessNeighborF3Y[i].g[0], para->getParH(level)->sendProcessNeighborF3Y[i].numberOfGs, para->getParH(level)->sendProcessNeighborF3Y[i].rankNeighbor); @@ -1606,13 +1606,13 @@ void exchangeCollDataF3YGPU(Parameter* para, Communicator* comm, CudaMemoryManag //Wait for (unsigned int i = 0; i < (unsigned int)(para->getNumberOfProcessNeighborsY(level, "send")); i++) { - comm->waitGPU(i); + comm.waitGPU(i); } /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //reset the request array if (0 < (unsigned int)(para->getNumberOfProcessNeighborsY(level, "send"))) { - comm->resetRequest(); + comm.resetRequest(); } /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //copy Host to Device @@ -1642,7 +1642,7 @@ void exchangeCollDataF3YGPU(Parameter* para, Communicator* comm, CudaMemoryManag //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Z //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -void exchangeCollDataF3ZGPU(Parameter* para, Communicator* comm, CudaMemoryManager* cudaManager, int level) +void exchangeCollDataF3ZGPU(Parameter* para, vf::gpu::Communicator& comm, CudaMemoryManager* cudaManager, int level) { /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //copy Device to Host @@ -1666,7 +1666,7 @@ void exchangeCollDataF3ZGPU(Parameter* para, Communicator* comm, CudaMemoryManag //start non blocking MPI receive for (unsigned int i = 0; i < (unsigned int)(para->getNumberOfProcessNeighborsZ(level, "send")); i++) { - comm->nbRecvDataGPU( + comm.nbRecvDataGPU( para->getParH(level)->recvProcessNeighborF3Z[i].g[0], para->getParH(level)->recvProcessNeighborF3Z[i].numberOfGs, para->getParH(level)->recvProcessNeighborF3Z[i].rankNeighbor); @@ -1675,7 +1675,7 @@ void exchangeCollDataF3ZGPU(Parameter* para, Communicator* comm, CudaMemoryManag //start blocking MPI send for (unsigned int i = 0; i < (unsigned int)(para->getNumberOfProcessNeighborsZ(level, "send")); i++) { - comm->sendDataGPU( + comm.sendDataGPU( para->getParH(level)->sendProcessNeighborF3Z[i].g[0], para->getParH(level)->sendProcessNeighborF3Z[i].numberOfGs, para->getParH(level)->sendProcessNeighborF3Z[i].rankNeighbor); @@ -1684,13 +1684,13 @@ void exchangeCollDataF3ZGPU(Parameter* para, Communicator* comm, CudaMemoryManag //Wait for (unsigned int i = 0; i < (unsigned int)(para->getNumberOfProcessNeighborsZ(level, "send")); i++) { - comm->waitGPU(i); + comm.waitGPU(i); } /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //reset the request array if (0 < (unsigned int)(para->getNumberOfProcessNeighborsZ(level, "send"))) { - comm->resetRequest(); + comm.resetRequest(); } /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //copy Host to Device diff --git a/src/gpu/VirtualFluids_GPU/Communication/ExchangeData27.h b/src/gpu/VirtualFluids_GPU/Communication/ExchangeData27.h index 0547dac4296896b69e50973befd759680f048076..82662cdc55e8b0ff5f4afe7d31a6563579b45559 100644 --- a/src/gpu/VirtualFluids_GPU/Communication/ExchangeData27.h +++ b/src/gpu/VirtualFluids_GPU/Communication/ExchangeData27.h @@ -9,31 +9,31 @@ ////////////////////////////////////////////////////////////////////////// //1D domain decomposition -extern "C" void exchangePreCollDataGPU27(Parameter* para, Communicator* comm, CudaMemoryManager* cudaManager, int level); -extern "C" void exchangePostCollDataGPU27(Parameter* para, Communicator* comm, CudaMemoryManager* cudaManager, int level); +extern "C" void exchangePreCollDataGPU27(Parameter* para, vf::gpu::Communicator& comm, CudaMemoryManager* cudaManager, int level); +extern "C" void exchangePostCollDataGPU27(Parameter* para, vf::gpu::Communicator& comm, CudaMemoryManager* cudaManager, int level); ////////////////////////////////////////////////////////////////////////// //3D domain decomposition -extern "C" void exchangePreCollDataXGPU27(Parameter* para, Communicator* comm, CudaMemoryManager* cudaManager, int level); -extern "C" void exchangePreCollDataYGPU27(Parameter* para, Communicator* comm, CudaMemoryManager* cudaManager, int level); -extern "C" void exchangePreCollDataZGPU27(Parameter* para, Communicator* comm, CudaMemoryManager* cudaManager, int level); -extern "C" void exchangePostCollDataXGPU27(Parameter* para, Communicator* comm, CudaMemoryManager* cudaManager, int level); -extern "C" void exchangePostCollDataYGPU27(Parameter* para, Communicator* comm, CudaMemoryManager* cudaManager, int level); -extern "C" void exchangePostCollDataZGPU27(Parameter* para, Communicator* comm, CudaMemoryManager* cudaManager, int level); +extern "C" void exchangePreCollDataXGPU27(Parameter* para, vf::gpu::Communicator& comm, CudaMemoryManager* cudaManager, int level); +extern "C" void exchangePreCollDataYGPU27(Parameter* para, vf::gpu::Communicator& comm, CudaMemoryManager* cudaManager, int level); +extern "C" void exchangePreCollDataZGPU27(Parameter* para, vf::gpu::Communicator& comm, CudaMemoryManager* cudaManager, int level); +extern "C" void exchangePostCollDataXGPU27(Parameter* para, vf::gpu::Communicator& comm, CudaMemoryManager* cudaManager, int level); +extern "C" void exchangePostCollDataYGPU27(Parameter* para, vf::gpu::Communicator& comm, CudaMemoryManager* cudaManager, int level); +extern "C" void exchangePostCollDataZGPU27(Parameter* para, vf::gpu::Communicator& comm, CudaMemoryManager* cudaManager, int level); ////////////////////////////////////////////////////////////////////////// //3D domain decomposition convection diffusion -extern "C" void exchangePreCollDataADXGPU27(Parameter* para, Communicator* comm, CudaMemoryManager* cudaManager, int level); -extern "C" void exchangePreCollDataADYGPU27(Parameter* para, Communicator* comm, CudaMemoryManager* cudaManager, int level); -extern "C" void exchangePreCollDataADZGPU27(Parameter* para, Communicator* comm, CudaMemoryManager* cudaManager, int level); -extern "C" void exchangePostCollDataADXGPU27(Parameter* para, Communicator* comm, CudaMemoryManager* cudaManager, int level); -extern "C" void exchangePostCollDataADYGPU27(Parameter* para, Communicator* comm, CudaMemoryManager* cudaManager, int level); -extern "C" void exchangePostCollDataADZGPU27(Parameter* para, Communicator* comm, CudaMemoryManager* cudaManager, int level); +extern "C" void exchangePreCollDataADXGPU27(Parameter* para, vf::gpu::Communicator& comm, CudaMemoryManager* cudaManager, int level); +extern "C" void exchangePreCollDataADYGPU27(Parameter* para, vf::gpu::Communicator& comm, CudaMemoryManager* cudaManager, int level); +extern "C" void exchangePreCollDataADZGPU27(Parameter* para, vf::gpu::Communicator& comm, CudaMemoryManager* cudaManager, int level); +extern "C" void exchangePostCollDataADXGPU27(Parameter* para, vf::gpu::Communicator& comm, CudaMemoryManager* cudaManager, int level); +extern "C" void exchangePostCollDataADYGPU27(Parameter* para, vf::gpu::Communicator& comm, CudaMemoryManager* cudaManager, int level); +extern "C" void exchangePostCollDataADZGPU27(Parameter* para, vf::gpu::Communicator& comm, CudaMemoryManager* cudaManager, int level); ////////////////////////////////////////////////////////////////////////// //3D domain decomposition F3 - K18/K20 -extern "C" void exchangeCollDataF3XGPU( Parameter* para, Communicator* comm, CudaMemoryManager* cudaManager, int level); -extern "C" void exchangeCollDataF3YGPU( Parameter* para, Communicator* comm, CudaMemoryManager* cudaManager, int level); -extern "C" void exchangeCollDataF3ZGPU( Parameter* para, Communicator* comm, CudaMemoryManager* cudaManager, int level); +extern "C" void exchangeCollDataF3XGPU( Parameter* para, vf::gpu::Communicator& comm, CudaMemoryManager* cudaManager, int level); +extern "C" void exchangeCollDataF3YGPU( Parameter* para, vf::gpu::Communicator& comm, CudaMemoryManager* cudaManager, int level); +extern "C" void exchangeCollDataF3ZGPU( Parameter* para, vf::gpu::Communicator& comm, CudaMemoryManager* cudaManager, int level); ////////////////////////////////////////////////////////////////////////// -extern "C" void barrierGPU(Communicator* comm); +extern "C" void barrierGPU(vf::gpu::Communicator& comm); ////////////////////////////////////////////////////////////////////////// #endif diff --git a/src/gpu/VirtualFluids_GPU/DataStructureInitializer/GridProvider.cpp b/src/gpu/VirtualFluids_GPU/DataStructureInitializer/GridProvider.cpp index 2b2a2e68d0980b4d3aa4b27a04bd8ce703704a05..f21ee67a1054f6395b84377cbb71c3b2ff9ceaec 100644 --- a/src/gpu/VirtualFluids_GPU/DataStructureInitializer/GridProvider.cpp +++ b/src/gpu/VirtualFluids_GPU/DataStructureInitializer/GridProvider.cpp @@ -81,6 +81,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; + } } @@ -118,6 +124,12 @@ void GridProvider::allocAndCopyForcing() { cudaMemoryManager->cudaAllocForcing(); cudaMemoryManager->cudaCopyForcingToDevice(); + + for (int level = para->getCoarse(); level <= para->getFine(); level++) + { + cudaMemoryManager->cudaAllocLevelForcing(level); + cudaMemoryManager->cudaCopyLevelForcingToDevice(level); + } } void GridProvider::allocAndCopyQuadricLimiters() diff --git a/src/gpu/VirtualFluids_GPU/DataStructureInitializer/GridReaderFiles/BoundaryQs.cpp b/src/gpu/VirtualFluids_GPU/DataStructureInitializer/GridReaderFiles/BoundaryQs.cpp index a0539073347f999e680a9d96ac3d02fee65d7bec..ab266e499fbe9aae16eef29c8bd35b67019323f3 100644 --- a/src/gpu/VirtualFluids_GPU/DataStructureInitializer/GridReaderFiles/BoundaryQs.cpp +++ b/src/gpu/VirtualFluids_GPU/DataStructureInitializer/GridReaderFiles/BoundaryQs.cpp @@ -166,13 +166,26 @@ unsigned int BoundaryQs::getLevel() } -void BoundaryQs::setValues(real** q27, unsigned int level) const +void BoundaryQs::setValuesInVector(std::vector<std::vector<std::vector<real>>> &q27, unsigned int level) const +{ + for (std::size_t column = 0; column < values[level].size(); column++) + for (std::size_t index = 0; index < values[level][column].size(); index++) + q27[level][column].push_back(values[level][column][index]); +} + +void BoundaryQs::setValues(real **q27, unsigned int level) const { for (std::size_t column = 0; column < values[level].size(); column++) for (std::size_t index = 0; index < values[level][column].size(); index++) q27[column][index] = values[level][column][index]; } +void BoundaryQs::setIndexInVector(std::vector<std::vector<int>> &data, unsigned int level) const +{ + for (std::size_t index = 0; index < indices[level].size(); index++) + data[level].push_back(indices[level][index]); +} + void BoundaryQs::setIndex(int *data, unsigned int level) const { for (std::size_t index = 0; index < indices[level].size(); index++) diff --git a/src/gpu/VirtualFluids_GPU/DataStructureInitializer/GridReaderFiles/BoundaryQs.h b/src/gpu/VirtualFluids_GPU/DataStructureInitializer/GridReaderFiles/BoundaryQs.h index daefd2cac6bce4b35e52d915b265be5fd6bd4f99..804051824b5c8ca01809c78e58034eb06d45874e 100644 --- a/src/gpu/VirtualFluids_GPU/DataStructureInitializer/GridReaderFiles/BoundaryQs.h +++ b/src/gpu/VirtualFluids_GPU/DataStructureInitializer/GridReaderFiles/BoundaryQs.h @@ -32,7 +32,9 @@ private: void init_Binary(); public: - void setIndex(int *indices, unsigned int level) const; + void setIndexInVector(std::vector<std::vector<int>> &data, unsigned int level) const; + void setValuesInVector(std::vector<std::vector<std::vector<real>>> &q27, unsigned int level) const; + void setIndex(int *indices, unsigned int level) const; void setValues(real** q27, unsigned int level) const; void getQs(std::vector<std::vector<std::vector<real> > > &qs); void getIndices(std::vector<std::vector<uint> > &indices); diff --git a/src/gpu/VirtualFluids_GPU/DataStructureInitializer/GridReaderFiles/GridReader.cpp b/src/gpu/VirtualFluids_GPU/DataStructureInitializer/GridReaderFiles/GridReader.cpp index 49de1d53a3bc0e64907906e2c87409c34cb8ba85..940dbfa617ccd06f5d7b77527cc78b618062240a 100644 --- a/src/gpu/VirtualFluids_GPU/DataStructureInitializer/GridReaderFiles/GridReader.cpp +++ b/src/gpu/VirtualFluids_GPU/DataStructureInitializer/GridReaderFiles/GridReader.cpp @@ -61,10 +61,11 @@ void GridReader::allocArrays_CoordNeighborGeo() CoordNeighborGeoV coordX(para->getcoordX(), binaer, true); CoordNeighborGeoV coordY(para->getcoordY(), binaer, true); CoordNeighborGeoV coordZ(para->getcoordZ(), binaer, true); - neighX = std::shared_ptr<CoordNeighborGeoV>(new CoordNeighborGeoV(para->getneighborX(), binaer, false)); - neighY = std::shared_ptr<CoordNeighborGeoV>(new CoordNeighborGeoV(para->getneighborY(), binaer, false)); - neighZ = std::shared_ptr<CoordNeighborGeoV>(new CoordNeighborGeoV(para->getneighborZ(), binaer, false)); - CoordNeighborGeoV geoV(para->getgeoVec(), binaer, false); + neighX = std::shared_ptr<CoordNeighborGeoV>(new CoordNeighborGeoV(para->getneighborX(), binaer, false)); + neighY = std::shared_ptr<CoordNeighborGeoV>(new CoordNeighborGeoV(para->getneighborY(), binaer, false)); + neighZ = std::shared_ptr<CoordNeighborGeoV>(new CoordNeighborGeoV(para->getneighborZ(), binaer, false)); + neighWSB = std::shared_ptr<CoordNeighborGeoV>(new CoordNeighborGeoV(para->getneighborWSB(), binaer, false)); + CoordNeighborGeoV geoV(para->getgeoVec(), binaer, false); uint maxLevel = coordX.getLevel(); std::cout << "Number of Level: " << maxLevel + 1 << std::endl; @@ -81,19 +82,20 @@ void GridReader::allocArrays_CoordNeighborGeo() cudaMemoryManager->cudaAllocCoord(level); cudaMemoryManager->cudaAllocSP(level); - cudaMemoryManager->cudaAllocF3SP(level); + //cudaMemoryManager->cudaAllocF3SP(level); cudaMemoryManager->cudaAllocNeighborWSB(level); if (para->getUseWale()) cudaMemoryManager->cudaAllocTurbulentViscosity(level); - coordX.initalCoords(para->getParH(level)->coordX_SP, level); - coordY.initalCoords(para->getParH(level)->coordY_SP, level); - coordZ.initalCoords(para->getParH(level)->coordZ_SP, level); - neighX->initalNeighbors(para->getParH(level)->neighborX_SP, level); - neighY->initalNeighbors(para->getParH(level)->neighborY_SP, level); - neighZ->initalNeighbors(para->getParH(level)->neighborZ_SP, level); - geoV.initalNeighbors(para->getParH(level)->geoSP, level); + coordX.initalCoords( para->getParH(level)->coordX_SP, level); + coordY.initalCoords( para->getParH(level)->coordY_SP, level); + coordZ.initalCoords( para->getParH(level)->coordZ_SP, level); + neighX->initalNeighbors( para->getParH(level)->neighborX_SP, level); + neighY->initalNeighbors( para->getParH(level)->neighborY_SP, level); + neighZ->initalNeighbors( para->getParH(level)->neighborZ_SP, level); + neighWSB->initalNeighbors(para->getParH(level)->neighborWSB_SP, level); + geoV.initalNeighbors( para->getParH(level)->geoSP, level); rearrangeGeometry(para.get(), level); setInitalNodeValues(numberOfNodesPerLevel, level); @@ -113,13 +115,26 @@ void GridReader::allocArrays_BoundaryValues() this->setChannelBoundaryCondition(); int level = BC_Values[0]->getLevel(); + for (int i = 0; i <= level; i++) { + velocityX_BCvalues.push_back(std::vector<real>()); + velocityY_BCvalues.push_back(std::vector<real>()); + velocityZ_BCvalues.push_back(std::vector<real>()); + velocityQs.push_back(std::vector<std::vector<real>>()); + velocityIndex.push_back(std::vector<int>()); + for (int j = 0; j < para->getD3Qxx(); j++) { + velocityQs[i].push_back(std::vector<real>()); + } + } + for (uint i = 0; i < channelBoundaryConditions.size(); i++) { - setVelocityValues(i); - setPressureValues(i); - setOutflowValues(i); + if ( this->channelBoundaryConditions[i] == "velocity") { fillVelocityVectors(i); } + else if (this->channelBoundaryConditions[i] == "pressure") { setPressureValues(i); } + else if (this->channelBoundaryConditions[i] == "outflow") { setOutflowValues(i); } } + setVelocityValues(); + initalValuesDomainDecompostion(level); } @@ -229,37 +244,59 @@ void GridReader::setPressRhoBC(int sizePerLevel, int level, int channelSide) con } -void GridReader::setVelocityValues(int channelSide) const +void GridReader::fillVelocityVectors(int channelSide) { - for (unsigned int level = 0; level <= BC_Values[channelSide]->getLevel(); level++) + for (unsigned int level = 0; level <= BC_Values[channelSide]->getLevel(); level++) { - int sizePerLevel = BC_Values[channelSide]->getSize(level); - setVelocitySizePerLevel(level, sizePerLevel); + const int sizePerLevel = BC_Values[channelSide]->getSize(level); if (sizePerLevel > 1) { - std::cout << "size velocity level " << level << " : " << sizePerLevel << std::endl; + // set local vectors per side and level + real *veloX_ValuesPerSide = new real[sizePerLevel]; + real *veloY_ValuesPerSide = new real[sizePerLevel]; + real *veloZ_ValuesPerSide = new real[sizePerLevel]; + + std::cout << "size velocity level " << level << " : " << sizePerLevel << std::endl; + BC_Values[channelSide]->setVelocityValues(veloX_ValuesPerSide, veloY_ValuesPerSide, veloZ_ValuesPerSide, level); + + for (int i = 0; i < sizePerLevel; i++) { + this->velocityX_BCvalues[level].push_back(veloX_ValuesPerSide[i]); + this->velocityY_BCvalues[level].push_back(veloY_ValuesPerSide[i]); + this->velocityZ_BCvalues[level].push_back(veloZ_ValuesPerSide[i]); + } + + delete[] veloX_ValuesPerSide; + delete[] veloY_ValuesPerSide; + delete[] veloZ_ValuesPerSide; + } + } - cudaMemoryManager->cudaAllocVeloBC(level); - setVelocity(level, sizePerLevel, channelSide); - cudaMemoryManager->cudaCopyVeloBC(level); - } - } } -void GridReader::setVelocity(int level, int sizePerLevel, int channelSide) const -{ - BC_Values[channelSide]->setVelocityValues(para->getParH(level)->Qinflow.Vx, para->getParH(level)->Qinflow.Vy, para->getParH(level)->Qinflow.Vz, level); +void GridReader::setVelocityValues() { + for (int level = 0; level < (int)(velocityX_BCvalues.size()); level++) { + + int sizePerLevel = (int) velocityX_BCvalues[level].size(); + std::cout << "complete size velocity level " << level << " : " << sizePerLevel << std::endl; + setVelocitySizePerLevel(level, sizePerLevel); + + if (sizePerLevel > 1) { + cudaMemoryManager->cudaAllocVeloBC(level); + setVelocity(level, sizePerLevel); + cudaMemoryManager->cudaCopyVeloBC(level); + } + } +} +void GridReader::setVelocity(int level, int sizePerLevel) const +{ for (int index = 0; index < sizePerLevel; index++) { - para->getParH(level)->Qinflow.Vx[index] = para->getParH(level)->Qinflow.Vx[index] / para->getVelocityRatio(); - para->getParH(level)->Qinflow.Vy[index] = para->getParH(level)->Qinflow.Vy[index] / para->getVelocityRatio(); - para->getParH(level)->Qinflow.Vz[index] = para->getParH(level)->Qinflow.Vz[index] / para->getVelocityRatio(); - //para->getParH(level)->Qinflow.Vx[index] = para->getVelocity();//0.035; - //para->getParH(level)->Qinflow.Vy[index] = 0.0;//para->getVelocity();//0.0; - //para->getParH(level)->Qinflow.Vz[index] = 0.0; + para->getParH(level)->Qinflow.Vx[index] = this->velocityX_BCvalues[level][index] / para->getVelocityRatio(); + para->getParH(level)->Qinflow.Vy[index] = this->velocityY_BCvalues[level][index] / para->getVelocityRatio(); + para->getParH(level)->Qinflow.Vz[index] = this->velocityZ_BCvalues[level][index] / para->getVelocityRatio(); } } @@ -514,12 +551,19 @@ void GridReader::allocArrays_BoundaryQs() for (std::size_t i = 0; i < channelBoundaryConditions.size(); i++) { - if (this->channelBoundaryConditions[i] == "noSlip") { setNoSlipQs(BC_Qs[i]); } + if ( this->channelBoundaryConditions[i] == "noSlip" ) { setNoSlipQs(BC_Qs[i]); } else if (this->channelBoundaryConditions[i] == "velocity") { setVelocityQs(BC_Qs[i]); } - else if (this->channelBoundaryConditions[i] == "pressure") { setPressQs(BC_Qs[i]); } - else if (this->channelBoundaryConditions[i] == "outflow") { setOutflowQs(BC_Qs[i]); } + else if (this->channelBoundaryConditions[i] == "pressure") { setPressQs(BC_Qs[i]); } + else if (this->channelBoundaryConditions[i] == "outflow" ) { setOutflowQs(BC_Qs[i]); } } + for (int lev = 0; lev < (int)(velocityIndex.size()); lev++) { + if (velocityIndex[lev].size() > 1) { + copyVectorsToQStruct(velocityQs[lev], velocityIndex[lev], para->getParH(lev)->Qinflow); + cudaMemoryManager->cudaCopyVeloBC(lev); + } + } + std::shared_ptr<BoundaryQs> obj_geomQ = std::shared_ptr<BoundaryQs>(new BoundaryQs(para->getgeomBoundaryBcQs(), para, "geo", false)); if (para->getIsGeo()) setGeoQs(obj_geomQ); @@ -544,15 +588,14 @@ void GridReader::setPressQs(std::shared_ptr<BoundaryQs> boundaryQ) const } } -void GridReader::setVelocityQs(std::shared_ptr<BoundaryQs> boundaryQ) const +void GridReader::setVelocityQs(std::shared_ptr<BoundaryQs> boundaryQ) { for (unsigned int level = 0; level <= boundaryQ->getLevel(); level++) { if (hasQs(boundaryQ, level)) { this->printQSize("velocity", boundaryQ, level); - this->initalQStruct(para->getParH(level)->Qinflow, boundaryQ, level); - cudaMemoryManager->cudaCopyVeloBC(level); + this->initalVectorForQStruct(velocityQs, velocityIndex, boundaryQ, level); } } } @@ -613,7 +656,34 @@ void GridReader::modifyQElement(std::shared_ptr<BoundaryQs> boundaryQ, unsigned /*------------------------------------------------------------------------------------------------*/ /*---------------------------------------private q methods----------------------------------------*/ /*------------------------------------------------------------------------------------------------*/ -void GridReader::initalQStruct(QforBoundaryConditions& Q, std::shared_ptr<BoundaryQs> boundaryQ, unsigned int level) const +void GridReader::initalVectorForQStruct(std::vector<std::vector<std::vector<real>>> &Qs, std::vector<std::vector<int>> &index, + std::shared_ptr<BoundaryQs> boundaryQ, unsigned int level) const +{ + boundaryQ->setValuesInVector(Qs, level); + boundaryQ->setIndexInVector(index, level); +} + +void GridReader::copyVectorsToQStruct(std::vector<std::vector<real>> &Qs, + std::vector<int> &index, QforBoundaryConditions &Q) const +{ + QforBoundaryConditions qTemp; + this->setQ27Size(qTemp, Q.q27[0], Q.kQ); + + uint sizeOfValues = (uint)index.size(); + + for (int direction = 0; direction < para->getD3Qxx(); direction++) { + for (size_t indexQ = 0; indexQ < sizeOfValues; indexQ++) { + qTemp.q27[direction][indexQ] = Qs[direction][indexQ]; + } + } + + for (size_t indexQ = 0; indexQ < sizeOfValues; indexQ++) { + Q.k[indexQ] = index[indexQ]; + } +} + +void GridReader::initalQStruct(QforBoundaryConditions &Q, std::shared_ptr<BoundaryQs> boundaryQ, + unsigned int level) const { QforBoundaryConditions qTemp; this->setQ27Size(qTemp, Q.q27[0], Q.kQ); @@ -628,7 +698,25 @@ bool GridReader::hasQs(std::shared_ptr<BoundaryQs> boundaryQ, unsigned int level void GridReader::initalGridInformations() { + int maxLevel = para->getMaxLevel(); + std::vector<int> gridX, gridY, gridZ; + std::vector<int> distX, distY, distZ; + + for (int i = 0; i <= maxLevel; i++) { + gridX.push_back(0); + gridY.push_back(0); + gridZ.push_back(0); + distX.push_back(0); + distY.push_back(0); + distZ.push_back(0); + } + para->setGridX(gridX); + para->setGridY(gridY); + para->setGridZ(gridZ); + para->setDistX(distX); + para->setDistY(distY); + para->setDistZ(distZ); } void GridReader::setQ27Size(QforBoundaryConditions &Q, real* QQ, unsigned int sizeQ) const diff --git a/src/gpu/VirtualFluids_GPU/DataStructureInitializer/GridReaderFiles/GridReader.h b/src/gpu/VirtualFluids_GPU/DataStructureInitializer/GridReaderFiles/GridReader.h index aafe0d1cb732af656fe861e7cab93af4e0ae078b..f7a4c43062da79d39c43e6822688c51ad55e7442 100644 --- a/src/gpu/VirtualFluids_GPU/DataStructureInitializer/GridReaderFiles/GridReader.h +++ b/src/gpu/VirtualFluids_GPU/DataStructureInitializer/GridReaderFiles/GridReader.h @@ -26,6 +26,13 @@ private: std::shared_ptr<CoordNeighborGeoV> neighX, neighY, neighZ, neighWSB; std::vector<std::shared_ptr<BoundaryValues> > BC_Values; + std::vector<std::vector<real>> velocityX_BCvalues, velocityY_BCvalues, velocityZ_BCvalues; + std::vector<std::vector<std::vector<real>>> velocityQs; + std::vector<std::vector<int>> velocityIndex; + + std::vector<std::vector<real>> pressureBCvalues; + std::vector<std::vector<real>> outflowBCvalues; + public: GridReader(FILEFORMAT format, std::shared_ptr<Parameter> para, std::shared_ptr<CudaMemoryManager> cudaManager); ~GridReader(); @@ -50,21 +57,27 @@ private: void setPressureValues(int channelSide) const; void setPressRhoBC(int sizePerLevel, int level, int channelSide) const; - void setVelocityValues(int channelSide) const; - void setVelocity(int level, int sizePerLevel, int channelSide) const; + void fillVelocityVectors(int channelSide); + void setVelocityValues(); + void setVelocity(int level, int sizePerLevel) const; void setOutflowValues(int channelSide) const; void setOutflow(int level, int sizePerLevel, int channelSide) const; - void setPressQs(std::shared_ptr<BoundaryQs> boundaryQ) const; - void setVelocityQs(std::shared_ptr<BoundaryQs> boundaryQ) const; + //void fillVelocityQVectors(int channelSide); + void setPressQs(std::shared_ptr<BoundaryQs> boundaryQ) const; + void setVelocityQs(std::shared_ptr<BoundaryQs> boundaryQ); void setOutflowQs(std::shared_ptr<BoundaryQs> boundaryQ) const; void setNoSlipQs(std::shared_ptr<BoundaryQs> boundaryQ) const; void setGeoQs(std::shared_ptr<BoundaryQs> boundaryQ) const; void modifyQElement(std::shared_ptr<BoundaryQs> boundaryQ, unsigned int level) const; - void initalQStruct(QforBoundaryConditions& Q, std::shared_ptr<BoundaryQs> boundaryQ, unsigned int level) const; + void initalVectorForQStruct(std::vector<std::vector<std::vector<real>>> &Qs, std::vector<std::vector<int>> &index, + std::shared_ptr<BoundaryQs> boundaryQ, unsigned int level) const; + void copyVectorsToQStruct(std::vector<std::vector<real>> &Qs, std::vector<int> &index, + QforBoundaryConditions &Q) const; + void initalQStruct(QforBoundaryConditions &Q, std::shared_ptr<BoundaryQs> boundaryQ, unsigned int level) const; void printQSize(std::string bc, std::shared_ptr<BoundaryQs> boundaryQ, unsigned int level) const; void setSizeNoSlip(std::shared_ptr<BoundaryQs> boundaryQ, unsigned int level) const; void setSizeGeoQs(std::shared_ptr<BoundaryQs> boundaryQ, unsigned int level) const; diff --git a/src/gpu/VirtualFluids_GPU/DataStructureInitializer/GridReaderGenerator/GridGenerator.cpp b/src/gpu/VirtualFluids_GPU/DataStructureInitializer/GridReaderGenerator/GridGenerator.cpp index 2582e6918bd105d81964aba56dcdb661b59025bf..6edd22963d51404eaf683be77b74e1bba543881c 100644 --- a/src/gpu/VirtualFluids_GPU/DataStructureInitializer/GridReaderGenerator/GridGenerator.cpp +++ b/src/gpu/VirtualFluids_GPU/DataStructureInitializer/GridReaderGenerator/GridGenerator.cpp @@ -58,11 +58,14 @@ void GridGenerator::allocArrays_CoordNeighborGeo() cudaMemoryManager->cudaAllocCoord(level); cudaMemoryManager->cudaAllocSP(level); - para->cudaAllocF3SP(level); + //cudaMemoryManager->cudaAllocF3SP(level); cudaMemoryManager->cudaAllocNeighborWSB(level); if(para->getUseWale()) cudaMemoryManager->cudaAllocTurbulentViscosity(level); + + if(para->getIsBodyForce()) + cudaMemoryManager->cudaAllocBodyForce(level); builder->getNodeValues( para->getParH(level)->coordX_SP, @@ -80,6 +83,8 @@ void GridGenerator::allocArrays_CoordNeighborGeo() cudaMemoryManager->cudaCopyNeighborWSB(level); cudaMemoryManager->cudaCopySP(level); cudaMemoryManager->cudaCopyCoord(level); + if(para->getIsBodyForce()) + cudaMemoryManager->cudaCopyBodyForce(level); //std::cout << verifyNeighborIndices(level); } @@ -102,9 +107,9 @@ void GridGenerator::allocArrays_BoundaryValues() para->getParD(level)->kPressQread = numberOfPressureValues * para->getD3Qxx(); if (numberOfPressureValues > 1) { - para->cudaAllocPress(level); + cudaMemoryManager->cudaAllocPress(level); builder->getPressureValues(para->getParH(level)->QPress.RhoBC, para->getParH(level)->QPress.k, para->getParH(level)->QPress.kN, level); - para->cudaCopyPress(level); + cudaMemoryManager->cudaCopyPress(level); } } @@ -127,7 +132,7 @@ void GridGenerator::allocArrays_BoundaryValues() if (numberOfVelocityValues > 1) { //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - para->cudaAllocVeloBC(level); + cudaMemoryManager->cudaAllocVeloBC(level); //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// builder->getVelocityValues(para->getParH(level)->Qinflow.Vx, para->getParH(level)->Qinflow.Vy, para->getParH(level)->Qinflow.Vz, para->getParH(level)->Qinflow.k, level); @@ -146,7 +151,7 @@ void GridGenerator::allocArrays_BoundaryValues() //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - para->cudaCopyVeloBC(level); + cudaMemoryManager->cudaCopyVeloBC(level); //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // advection - diffusion stuff @@ -157,7 +162,7 @@ void GridGenerator::allocArrays_BoundaryValues() std::cout << "getTemperatureInit = " << para->getTemperatureInit() << std::endl; std::cout << "getTemperatureBC = " << para->getTemperatureBC() << std::endl; ////////////////////////////////////////////////////////////////////////// - para->cudaAllocTempVeloBC(level); + cudaMemoryManager->cudaAllocTempVeloBC(level); //cout << "nach alloc " << endl; ////////////////////////////////////////////////////////////////////////// for (int m = 0; m < numberOfVelocityValues; m++) @@ -169,7 +174,7 @@ void GridGenerator::allocArrays_BoundaryValues() } ////////////////////////////////////////////////////////////////////////// //cout << "vor copy " << endl; - para->cudaCopyTempVeloBCHD(level); + cudaMemoryManager->cudaCopyTempVeloBCHD(level); //cout << "nach copy " << endl; ////////////////////////////////////////////////////////////////////////// } @@ -191,7 +196,7 @@ void GridGenerator::allocArrays_BoundaryValues() { //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - para->cudaAllocGeomValuesBC(i); + cudaMemoryManager->cudaAllocGeomValuesBC(i); //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //Indexarray @@ -219,7 +224,7 @@ void GridGenerator::allocArrays_BoundaryValues() // para->getParH(i)->QGeom.Vz[m] = 0.0f; //} ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - para->cudaCopyGeomValuesBC(i); + cudaMemoryManager->cudaCopyGeomValuesBC(i); ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //// advection - diffusion stuff //if (para->getDiffOn()==true){ @@ -671,7 +676,7 @@ void GridGenerator::allocArrays_BoundaryQs() para->getParD(i)->TempPress.kTemp = numberOfPressureValues; std::cout << "Groesse TempPress.kTemp = " << para->getParH(i)->TempPress.kTemp << std::endl; ////////////////////////////////////////////////////////////////////////// - para->cudaAllocTempPressBC(i); + cudaMemoryManager->cudaAllocTempPressBC(i); //cout << "nach alloc" << endl; ////////////////////////////////////////////////////////////////////////// for (int m = 0; m < numberOfPressureValues; m++) @@ -682,12 +687,12 @@ void GridGenerator::allocArrays_BoundaryQs() } ////////////////////////////////////////////////////////////////////////// //cout << "vor copy" << endl; - para->cudaCopyTempPressBCHD(i); + cudaMemoryManager->cudaCopyTempPressBCHD(i); //cout << "nach copy" << endl; ////////////////////////////////////////////////////////////////////////// } //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - para->cudaCopyPress(i); + cudaMemoryManager->cudaCopyPress(i); //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// }//ende if }//ende oberste for schleife @@ -743,7 +748,7 @@ void GridGenerator::allocArrays_BoundaryQs() std::cout << "getTemperatureInit = " << para->getTemperatureInit() << std::endl; std::cout << "getTemperatureBC = " << para->getTemperatureBC() << std::endl; ////////////////////////////////////////////////////////////////////////// - para->cudaAllocTempVeloBC(i); + cudaMemoryManager->cudaAllocTempVeloBC(i); //cout << "nach alloc " << std::endl; ////////////////////////////////////////////////////////////////////////// for (int m = 0; m < numberOfVelocityNodes; m++) @@ -755,11 +760,11 @@ void GridGenerator::allocArrays_BoundaryQs() } ////////////////////////////////////////////////////////////////////////// //cout << "vor copy " << std::endl; - para->cudaCopyTempVeloBCHD(i); + cudaMemoryManager->cudaCopyTempVeloBCHD(i); //cout << "nach copy " << std::endl; ////////////////////////////////////////////////////////////////////////// } - para->cudaCopyVeloBC(i); + cudaMemoryManager->cudaCopyVeloBC(i); } } @@ -777,7 +782,7 @@ void GridGenerator::allocArrays_BoundaryQs() //para->getParH(i)->QGeom.kQ = temp4; //para->getParD(i)->QGeom.kQ = para->getParH(i)->QGeom.kQ; //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - para->cudaAllocGeomBC(i); + cudaMemoryManager->cudaAllocGeomBC(i); //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////// @@ -840,7 +845,7 @@ void GridGenerator::allocArrays_BoundaryQs() para->getParD(i)->Temp.kTemp = numberOfGeometryNodes; std::cout << "Groesse Temp.kTemp = " << para->getParH(i)->Temp.kTemp << std::endl; ////////////////////////////////////////////////////////////////////////// - para->cudaAllocTempNoSlipBC(i); + cudaMemoryManager->cudaAllocTempNoSlipBC(i); ////////////////////////////////////////////////////////////////////////// for (int m = 0; m < numberOfGeometryNodes; m++) { @@ -848,11 +853,11 @@ void GridGenerator::allocArrays_BoundaryQs() para->getParH(i)->Temp.k[m] = para->getParH(i)->QGeom.k[m]; } ////////////////////////////////////////////////////////////////////////// - para->cudaCopyTempNoSlipBCHD(i); + cudaMemoryManager->cudaCopyTempNoSlipBCHD(i); ////////////////////////////////////////////////////////////////////////// } //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - para->cudaCopyGeomBC(i); + cudaMemoryManager->cudaCopyGeomBC(i); //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// } } diff --git a/src/gpu/VirtualFluids_GPU/GPU/AdvecDiffBCs27.cu b/src/gpu/VirtualFluids_GPU/GPU/AdvecDiffBCs27.cu index 6e67ecda71969b19061d92cff8f6d0eb241f4138..0643e59cc3052d1cfb67b5c3e59ed531d54625de 100644 --- a/src/gpu/VirtualFluids_GPU/GPU/AdvecDiffBCs27.cu +++ b/src/gpu/VirtualFluids_GPU/GPU/AdvecDiffBCs27.cu @@ -1,7 +1,10 @@ /* Device code */ #include "LBM/LB.h" #include "LBM/D3Q27.h" -#include "Core/RealConstants.h" + +#include <lbm/constants/NumericConstants.h> + +using namespace vf::lbm::constant; ////////////////////////////////////////////////////////////////////////////// extern "C" __global__ void QADPress7( int inx, diff --git a/src/gpu/VirtualFluids_GPU/GPU/CP27.cu b/src/gpu/VirtualFluids_GPU/GPU/CP27.cu index afaf110ad69a1f7337ffb6fc69126dec20e7cc28..289152f17d4d149837e1c592718b3385a7f79969 100644 --- a/src/gpu/VirtualFluids_GPU/GPU/CP27.cu +++ b/src/gpu/VirtualFluids_GPU/GPU/CP27.cu @@ -1,7 +1,9 @@ /* Device code */ #include "LBM/LB.h" #include "LBM/D3Q27.h" -#include "Core/RealConstants.h" +#include <lbm/constants/NumericConstants.h> + +using namespace vf::lbm::constant; //////////////////////////////////////////////////////////////////////////////// extern "C" __global__ void CalcCP27(real* DD, diff --git a/src/gpu/VirtualFluids_GPU/GPU/Calc2ndMoments27.cu b/src/gpu/VirtualFluids_GPU/GPU/Calc2ndMoments27.cu index 2e0a0e4892f554ed9201483c3c7c73034795e6f2..337e518c70462fbfbc1fafcfe7a5c34186f74849 100644 --- a/src/gpu/VirtualFluids_GPU/GPU/Calc2ndMoments27.cu +++ b/src/gpu/VirtualFluids_GPU/GPU/Calc2ndMoments27.cu @@ -1,7 +1,9 @@ /* Device code */ #include "LBM/LB.h" #include "LBM/D3Q27.h" -#include "Core/RealConstants.h" +#include <lbm/constants/NumericConstants.h> + +using namespace vf::lbm::constant; //////////////////////////////////////////////////////////////////////////////// diff --git a/src/gpu/VirtualFluids_GPU/GPU/CalcMac27.cu b/src/gpu/VirtualFluids_GPU/GPU/CalcMac27.cu index 69c0b88596f185812c5cb30fac47daca8d820ddf..ce6e034d1c1eee57e062b736cfcea97e07306f3c 100644 --- a/src/gpu/VirtualFluids_GPU/GPU/CalcMac27.cu +++ b/src/gpu/VirtualFluids_GPU/GPU/CalcMac27.cu @@ -8,7 +8,14 @@ /* Device code */ #include "LBM/LB.h" #include "LBM/D3Q27.h" -#include "Core/RealConstants.h" +#include <lbm/constants/NumericConstants.h> + +using namespace vf::lbm::constant; + +#include "lbm/MacroscopicQuantities.h" + +#include "../Kernel/Utilities/DistributionHelper.cuh" + //////////////////////////////////////////////////////////////////////////////// extern "C" __global__ void LBCalcMac27( real* vxD, @@ -20,196 +27,41 @@ extern "C" __global__ void LBCalcMac27( real* vxD, unsigned int* neighborY, unsigned int* neighborZ, unsigned int size_Mat, - real* DD, - bool evenOrOdd) + real* distributions, + bool isEvenTimestep) { - 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]; - } - //////////////////////////////////////////////////////////////////////////////// - unsigned int k; // Zugriff auf arrays im device - // - unsigned int tx = threadIdx.x; // Thread index = lokaler i index - unsigned int by = blockIdx.x; // Block index x - unsigned int bz = blockIdx.y; // Block index y - unsigned int x = tx + STARTOFFX; // Globaler x-Index - unsigned int y = by + STARTOFFY; // Globaler y-Index - unsigned int z = bz + STARTOFFZ; // Globaler z-Index - - const unsigned sizeX = blockDim.x; - const unsigned sizeY = gridDim.x; - const unsigned nx = sizeX + 2 * STARTOFFX; - const unsigned ny = sizeY + 2 * STARTOFFY; - - k = nx*(ny*z + y) + x; - ////////////////////////////////////////////////////////////////////////// - //index - unsigned int kzero= k; - unsigned int ke = k; - unsigned int kw = neighborX[k]; - unsigned int kn = k; - unsigned int ks = neighborY[k]; - unsigned int kt = k; - unsigned int kb = neighborZ[k]; - unsigned int ksw = neighborY[kw]; - unsigned int kne = k; - unsigned int kse = ks; - unsigned int knw = kw; - unsigned int kbw = neighborZ[kw]; - unsigned int kte = k; - unsigned int kbe = kb; - unsigned int ktw = kw; - unsigned int kbs = neighborZ[ks]; - unsigned int ktn = k; - 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 = k; - unsigned int kbsw = neighborZ[ksw]; - //unsigned int nxny = nx*ny; - //unsigned int kzero= k; - //unsigned int ke = k; - //unsigned int kw = k + 1; - //unsigned int kn = k; - //unsigned int ks = k + nx; - //unsigned int kt = k; - //unsigned int kb = k + nxny; - //unsigned int ksw = k + nx + 1; - //unsigned int kne = k; - //unsigned int kse = k + nx; - //unsigned int knw = k + 1; - //unsigned int kbw = k + nxny + 1; - //unsigned int kte = k; - //unsigned int kbe = k + nxny; - //unsigned int ktw = k + 1; - //unsigned int kbs = k + nxny + nx; - //unsigned int ktn = k; - //unsigned int kbn = k + nxny; - //unsigned int kts = k + nx; - //unsigned int ktse = k + nx; - //unsigned int kbnw = k + nxny + 1; - //unsigned int ktnw = k + 1; - //unsigned int kbse = k + nxny + nx; - //unsigned int ktsw = k + nx + 1; - //unsigned int kbne = k + nxny; - //unsigned int ktne = k; - //unsigned int kbsw = k + nxny + nx + 1; - ////////////////////////////////////////////////////////////////////////// + const unsigned int tx = threadIdx.x; // Thread index = lokaler i index + const unsigned int by = blockIdx.x; // Block index x + const unsigned int bz = blockIdx.y; // Block index y + const unsigned int x = tx + STARTOFFX; // Globaler x-Index + const unsigned int y = by + STARTOFFY; // Globaler y-Index + const unsigned int z = bz + STARTOFFZ; // Globaler z-Index + + const unsigned nx = blockDim.x + 2 * STARTOFFX; + const unsigned ny = gridDim.x + 2 * STARTOFFY; + + const unsigned int k = nx*(ny*z + y) + x; // Zugriff auf arrays im device + + + if(k >= size_Mat) + return; + + if(!vf::gpu::isValidFluidNode(geoD[k])) + return; + rhoD[k] = c0o1; vxD[k] = c0o1; vyD[k] = c0o1; vzD[k] = c0o1; - if(geoD[k] == GEO_FLUID) - { - rhoD[k] = (D.f[dirE ])[ke ]+ (D.f[dirW ])[kw ]+ - (D.f[dirN ])[kn ]+ (D.f[dirS ])[ks ]+ - (D.f[dirT ])[kt ]+ (D.f[dirB ])[kb ]+ - (D.f[dirNE ])[kne ]+ (D.f[dirSW ])[ksw ]+ - (D.f[dirSE ])[kse ]+ (D.f[dirNW ])[knw ]+ - (D.f[dirTE ])[kte ]+ (D.f[dirBW ])[kbw ]+ - (D.f[dirBE ])[kbe ]+ (D.f[dirTW ])[ktw ]+ - (D.f[dirTN ])[ktn ]+ (D.f[dirBS ])[kbs ]+ - (D.f[dirBN ])[kbn ]+ (D.f[dirTS ])[kts ]+ - (D.f[dirZERO])[kzero]+ - (D.f[dirTNE ])[ktne]+ (D.f[dirTSW ])[ktsw]+ - (D.f[dirTSE ])[ktse]+ (D.f[dirTNW ])[ktnw]+ - (D.f[dirBNE ])[kbne]+ (D.f[dirBSW ])[kbsw]+ - (D.f[dirBSE ])[kbse]+ (D.f[dirBNW ])[kbnw]; - - vxD[k] = (D.f[dirE ])[ke ]- (D.f[dirW ])[kw ]+ - (D.f[dirNE ])[kne ]- (D.f[dirSW ])[ksw ]+ - (D.f[dirSE ])[kse ]- (D.f[dirNW ])[knw ]+ - (D.f[dirTE ])[kte ]- (D.f[dirBW ])[kbw ]+ - (D.f[dirBE ])[kbe ]- (D.f[dirTW ])[ktw ]+ - (D.f[dirTNE ])[ktne]- (D.f[dirTSW ])[ktsw]+ - (D.f[dirTSE ])[ktse]- (D.f[dirTNW ])[ktnw]+ - (D.f[dirBNE ])[kbne]- (D.f[dirBSW ])[kbsw]+ - (D.f[dirBSE ])[kbse]- (D.f[dirBNW ])[kbnw]; - - vyD[k] = (D.f[dirN ])[kn ]- (D.f[dirS ])[ks ]+ - (D.f[dirNE ])[kne ]- (D.f[dirSW ])[ksw ]- - (D.f[dirSE ])[kse ]+ (D.f[dirNW ])[knw ]+ - (D.f[dirTN ])[ktn ]- (D.f[dirBS ])[kbs ]+ - (D.f[dirBN ])[kbn ]- (D.f[dirTS ])[kts ]+ - (D.f[dirTNE ])[ktne]- (D.f[dirTSW ])[ktsw]- - (D.f[dirTSE ])[ktse]+ (D.f[dirTNW ])[ktnw]+ - (D.f[dirBNE ])[kbne]- (D.f[dirBSW ])[kbsw]- - (D.f[dirBSE ])[kbse]+ (D.f[dirBNW ])[kbnw]; - - vzD[k] = (D.f[dirT ])[kt ]- (D.f[dirB ])[kb ]+ - (D.f[dirTE ])[kte ]- (D.f[dirBW ])[kbw ]- - (D.f[dirBE ])[kbe ]+ (D.f[dirTW ])[ktw ]+ - (D.f[dirTN ])[ktn ]- (D.f[dirBS ])[kbs ]- - (D.f[dirBN ])[kbn ]+ (D.f[dirTS ])[kts ]+ - (D.f[dirTNE ])[ktne]+ (D.f[dirTSW ])[ktsw]+ - (D.f[dirTSE ])[ktse]+ (D.f[dirTNW ])[ktnw]- - (D.f[dirBNE ])[kbne]- (D.f[dirBSW ])[kbsw]- - (D.f[dirBSE ])[kbse]- (D.f[dirBNW ])[kbnw]; - } + vf::gpu::DistributionWrapper distr_wrapper(distributions, size_Mat, isEvenTimestep, k, neighborX, neighborY, neighborZ); + const auto& distribution = distr_wrapper.distribution; + + rhoD[k] = vf::lbm::getDensity(distribution.f); + vxD[k] = vf::lbm::getIncompressibleVelocityX1(distribution.f); + vyD[k] = vf::lbm::getIncompressibleVelocityX2(distribution.f); + vzD[k] = vf::lbm::getIncompressibleVelocityX3(distribution.f); + } @@ -410,251 +262,37 @@ extern "C" __global__ void LBCalcMacSP27( real* vxD, } - - - - - - - - - - - - - - - - - - - - - - - - - - //////////////////////////////////////////////////////////////////////////////// -extern "C" __global__ void LBCalcMacCompSP27( real* vxD, - real* vyD, - real* vzD, - real* rhoD, - real* pressD, - unsigned int* geoD, - unsigned int* neighborX, - unsigned int* neighborY, - unsigned int* neighborZ, - unsigned int size_Mat, - real* DD, - bool evenOrOdd) +extern "C" __global__ void LBCalcMacCompSP27(real *vxD, real *vyD, real *vzD, real *rhoD, real *pressD, + unsigned int *geoD, unsigned int *neighborX, unsigned int *neighborY, + unsigned int *neighborZ, unsigned int size_Mat, real *distributions, + bool isEvenTimestep) { - 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<size_Mat) - { - ////////////////////////////////////////////////////////////////////////// - //index - unsigned int kzero= k; - unsigned int ke = k; - unsigned int kw = neighborX[k]; - unsigned int kn = k; - unsigned int ks = neighborY[k]; - unsigned int kt = k; - unsigned int kb = neighborZ[k]; - unsigned int ksw = neighborY[kw]; - unsigned int kne = k; - unsigned int kse = ks; - unsigned int knw = kw; - unsigned int kbw = neighborZ[kw]; - unsigned int kte = k; - unsigned int kbe = kb; - unsigned int ktw = kw; - unsigned int kbs = neighborZ[ks]; - unsigned int ktn = k; - 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 = k; - unsigned int kbsw = neighborZ[ksw]; - ////////////////////////////////////////////////////////////////////////// - pressD[k] = c0o1; - rhoD[k] = c0o1; - vxD[k] = c0o1; - vyD[k] = c0o1; - vzD[k] = c0o1; - - if(geoD[k] == GEO_FLUID || geoD[k] == GEO_PM_0 || geoD[k] == GEO_PM_1 || geoD[k] == GEO_PM_2) - { - rhoD[k] = (D.f[dirE ])[ke ]+ (D.f[dirW ])[kw ]+ - (D.f[dirN ])[kn ]+ (D.f[dirS ])[ks ]+ - (D.f[dirT ])[kt ]+ (D.f[dirB ])[kb ]+ - (D.f[dirNE ])[kne ]+ (D.f[dirSW ])[ksw ]+ - (D.f[dirSE ])[kse ]+ (D.f[dirNW ])[knw ]+ - (D.f[dirTE ])[kte ]+ (D.f[dirBW ])[kbw ]+ - (D.f[dirBE ])[kbe ]+ (D.f[dirTW ])[ktw ]+ - (D.f[dirTN ])[ktn ]+ (D.f[dirBS ])[kbs ]+ - (D.f[dirBN ])[kbn ]+ (D.f[dirTS ])[kts ]+ - (D.f[dirZERO])[kzero]+ - (D.f[dirTNE ])[ktne]+ (D.f[dirTSW ])[ktsw]+ - (D.f[dirTSE ])[ktse]+ (D.f[dirTNW ])[ktnw]+ - (D.f[dirBNE ])[kbne]+ (D.f[dirBSW ])[kbsw]+ - (D.f[dirBSE ])[kbse]+ (D.f[dirBNW ])[kbnw]; + const unsigned k = vf::gpu::getNodeIndex(); - vxD[k] = ((D.f[dirE ])[ke ]- (D.f[dirW ])[kw ]+ - (D.f[dirNE ])[kne ]- (D.f[dirSW ])[ksw ]+ - (D.f[dirSE ])[kse ]- (D.f[dirNW ])[knw ]+ - (D.f[dirTE ])[kte ]- (D.f[dirBW ])[kbw ]+ - (D.f[dirBE ])[kbe ]- (D.f[dirTW ])[ktw ]+ - (D.f[dirTNE ])[ktne]- (D.f[dirTSW ])[ktsw]+ - (D.f[dirTSE ])[ktse]- (D.f[dirTNW ])[ktnw]+ - (D.f[dirBNE ])[kbne]- (D.f[dirBSW ])[kbsw]+ - (D.f[dirBSE ])[kbse]- (D.f[dirBNW ])[kbnw]) / (c1o1 + rhoD[k]); + if(k >= size_Mat) + return; - vyD[k] = ((D.f[dirN ])[kn ]- (D.f[dirS ])[ks ]+ - (D.f[dirNE ])[kne ]- (D.f[dirSW ])[ksw ]- - (D.f[dirSE ])[kse ]+ (D.f[dirNW ])[knw ]+ - (D.f[dirTN ])[ktn ]- (D.f[dirBS ])[kbs ]+ - (D.f[dirBN ])[kbn ]- (D.f[dirTS ])[kts ]+ - (D.f[dirTNE ])[ktne]- (D.f[dirTSW ])[ktsw]- - (D.f[dirTSE ])[ktse]+ (D.f[dirTNW ])[ktnw]+ - (D.f[dirBNE ])[kbne]- (D.f[dirBSW ])[kbsw]- - (D.f[dirBSE ])[kbse]+ (D.f[dirBNW ])[kbnw]) / (c1o1 + rhoD[k]); + if (!vf::gpu::isValidFluidNode(geoD[k])) + return; - vzD[k] = ((D.f[dirT ])[kt ]- (D.f[dirB ])[kb ]+ - (D.f[dirTE ])[kte ]- (D.f[dirBW ])[kbw ]- - (D.f[dirBE ])[kbe ]+ (D.f[dirTW ])[ktw ]+ - (D.f[dirTN ])[ktn ]- (D.f[dirBS ])[kbs ]- - (D.f[dirBN ])[kbn ]+ (D.f[dirTS ])[kts ]+ - (D.f[dirTNE ])[ktne]+ (D.f[dirTSW ])[ktsw]+ - (D.f[dirTSE ])[ktse]+ (D.f[dirTNW ])[ktnw]- - (D.f[dirBNE ])[kbne]- (D.f[dirBSW ])[kbsw]- - (D.f[dirBSE ])[kbse]- (D.f[dirBNW ])[kbnw]) / (c1o1 + rhoD[k]); + pressD[k] = c0o1; + rhoD[k] = c0o1; + vxD[k] = c0o1; + vyD[k] = c0o1; + vzD[k] = c0o1; - pressD[k] = ((D.f[dirE ])[ke ]+ (D.f[dirW ])[kw ]+ - (D.f[dirN ])[kn ]+ (D.f[dirS ])[ks ]+ - (D.f[dirT ])[kt ]+ (D.f[dirB ])[kb ]+ - c2o1*( - (D.f[dirNE ])[kne ]+ (D.f[dirSW ])[ksw ]+ - (D.f[dirSE ])[kse ]+ (D.f[dirNW ])[knw ]+ - (D.f[dirTE ])[kte ]+ (D.f[dirBW ])[kbw ]+ - (D.f[dirBE ])[kbe ]+ (D.f[dirTW ])[ktw ]+ - (D.f[dirTN ])[ktn ]+ (D.f[dirBS ])[kbs ]+ - (D.f[dirBN ])[kbn ]+ (D.f[dirTS ])[kts ])+ - c3o1*( - (D.f[dirTNE ])[ktne]+ (D.f[dirTSW ])[ktsw]+ - (D.f[dirTSE ])[ktse]+ (D.f[dirTNW ])[ktnw]+ - (D.f[dirBNE ])[kbne]+ (D.f[dirBSW ])[kbsw]+ - (D.f[dirBSE ])[kbse]+ (D.f[dirBNW ])[kbnw])- - rhoD[k]-(vxD[k] * vxD[k] + vyD[k] * vyD[k] + vzD[k] * vzD[k]) * (c1o1+rhoD[k])) * c1o2+rhoD[k]; // times zero for incompressible case - //achtung op hart gesetzt Annahme op = 1 ; ^^^^(1.0/op-0.5)=0.5 + vf::gpu::DistributionWrapper distr_wrapper(distributions, size_Mat, isEvenTimestep, k, neighborX, neighborY, + neighborZ); + const auto &distribution = distr_wrapper.distribution; - } - } + rhoD[k] = vf::lbm::getDensity(distribution.f); + vxD[k] = vf::lbm::getCompressibleVelocityX1(distribution.f, rhoD[k]); + vyD[k] = vf::lbm::getCompressibleVelocityX2(distribution.f, rhoD[k]); + vzD[k] = vf::lbm::getCompressibleVelocityX3(distribution.f, rhoD[k]); + pressD[k] = vf::lbm::getPressure(distribution.f, rhoD[k], vxD[k], vyD[k], vzD[k]); } - - - - - - - - - - - - - - - - - - - - - - - - - - //////////////////////////////////////////////////////////////////////////////// extern "C" __global__ void LBCalcMacThS7( real* Conc, unsigned int* geoD, diff --git a/src/gpu/VirtualFluids_GPU/GPU/Cascade27.cu b/src/gpu/VirtualFluids_GPU/GPU/Cascade27.cu index 0301d858839d2dde4677a8784bd1dd70cc08cbd8..5c3a12551c2cffdd0b75ce283d9ee584a7c4b808 100644 --- a/src/gpu/VirtualFluids_GPU/GPU/Cascade27.cu +++ b/src/gpu/VirtualFluids_GPU/GPU/Cascade27.cu @@ -1,7 +1,9 @@ /* Device code */ #include "LBM/LB.h" #include "LBM/D3Q27.h" -#include "Core/RealConstants.h" +#include <lbm/constants/NumericConstants.h> + +using namespace vf::lbm::constant; #include "math.h" //////////////////////////////////////////////////////////////////////////////// diff --git a/src/gpu/VirtualFluids_GPU/GPU/CudaMemoryManager.cpp b/src/gpu/VirtualFluids_GPU/GPU/CudaMemoryManager.cpp index bc414530f64193223e63e673412c67bfc6aef745..7074a222b7f90003d4db62dcded33fb582b5d2bb 100644 --- a/src/gpu/VirtualFluids_GPU/GPU/CudaMemoryManager.cpp +++ b/src/gpu/VirtualFluids_GPU/GPU/CudaMemoryManager.cpp @@ -5,6 +5,12 @@ #include <math.h> #include <Parameter/Parameter.h> +#include <PreCollisionInteractor/ActuatorLine.h> +#include <PreCollisionInteractor/Probes/Probe.h> + +#include "Calculation/PorousMedia.h" + +#include <lbm/constants/NumericConstants.h> void CudaMemoryManager::cudaAllocFull(int lev) { @@ -38,7 +44,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 )); @@ -65,7 +71,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 )); @@ -248,7 +254,7 @@ void CudaMemoryManager::cudaAllocOutflowBC(int lev) checkCudaErrors( cudaMalloc((void**) &(parameter->getParD(lev)->Qoutflow.RhoBC), mem_size_outflow_Q_q )); ////////////////////////////////////////////////////////////////////////// - double tmp = (double)mem_size_outflow_Q_k + 2. * (double)mem_size_outflow_Q_q + (double)parameter->getD3Qxx()*(double)mem_size_outflow_Q_q; + double tmp = (double)mem_size_outflow_Q_q + 2. * (double)mem_size_outflow_Q_k + (double)parameter->getD3Qxx()*(double)mem_size_outflow_Q_q; setMemsizeGPU(tmp, false); } void CudaMemoryManager::cudaCopyOutflowBC(int lev) @@ -387,7 +393,7 @@ void CudaMemoryManager::cudaAllocForcing() //Device checkCudaErrors( cudaMalloc((void**) ¶meter->forcingD, mem_size)); ////////////////////////////////////////////////////////////////////////// - double tmp = (real)mem_size; + double tmp = (double)mem_size; setMemsizeGPU(tmp, false); } void CudaMemoryManager::cudaCopyForcingToDevice() @@ -404,6 +410,44 @@ void CudaMemoryManager::cudaFreeForcing() { checkCudaErrors( cudaFreeHost(parameter->getForcesHost())); } + +void CudaMemoryManager::cudaAllocLevelForcing(int level) +{ + real fx_t{ 1. }, fy_t{ 1. }, fz_t{ 1. }; + for (int i = 0; i < level; i++) { + fx_t *= vf::lbm::constant::c2o1; + fy_t *= vf::lbm::constant::c2o1; + fz_t *= vf::lbm::constant::c2o1; + } + + const unsigned int mem_size = sizeof(real) * 3; + + //Host + checkCudaErrors( cudaMallocHost((void**) &(parameter->getParH(level)->forcing), mem_size)); + parameter->getParH(level)->forcing[0] = parameter->forcingH[0] / fx_t; + parameter->getParH(level)->forcing[1] = parameter->forcingH[1] / fy_t; + parameter->getParH(level)->forcing[2] = parameter->forcingH[2] / fz_t; + + //Device + checkCudaErrors( cudaMalloc((void**) ¶meter->getParD(level)->forcing, mem_size)); + ////////////////////////////////////////////////////////////////////////// + const double tmp = (double)mem_size; + setMemsizeGPU(tmp, false); +} + +void CudaMemoryManager::cudaCopyLevelForcingToDevice(int level) +{ + unsigned int mem_size = sizeof(real) * 3; + checkCudaErrors( cudaMemcpy(parameter->getParD(level)->forcing, parameter->getParH(level)->forcing, mem_size, cudaMemcpyHostToDevice)); +} + +void CudaMemoryManager::cudaFreeLevelForcing(int level) +{ + checkCudaErrors( cudaFreeHost(parameter->getParH(level)->forcing)); + checkCudaErrors( cudaFree(parameter->getParD(level)->forcing)); +} + + //quadric Limiters void CudaMemoryManager::cudaAllocQuadricLimiters() { @@ -416,7 +460,7 @@ void CudaMemoryManager::cudaAllocQuadricLimiters() //Device checkCudaErrors( cudaMalloc((void**) ¶meter->quadricLimitersD, mem_size)); ////////////////////////////////////////////////////////////////////////// - double tmp = (real)mem_size; + double tmp = (double)mem_size; setMemsizeGPU(tmp, false); } void CudaMemoryManager::cudaCopyQuadricLimitersToDevice() @@ -436,15 +480,15 @@ void CudaMemoryManager::cudaFreeQuadricLimiters() void CudaMemoryManager::cudaAllocProcessNeighborX(int lev, unsigned int processNeighbor) { //Host - checkCudaErrors( cudaMallocHost((void**) &(parameter->getParH(lev)->sendProcessNeighborX[processNeighbor].index ), parameter->getParH(lev)->sendProcessNeighborX[processNeighbor].memsizeIndex )); + checkCudaErrors( cudaMallocHost((void**) &(parameter->getParH(lev)->sendProcessNeighborX[processNeighbor].index ), parameter->getParH(lev)->sendProcessNeighborX[processNeighbor].memsizeIndex )); checkCudaErrors( cudaMallocHost((void**) &(parameter->getParH(lev)->sendProcessNeighborX[processNeighbor].f[0] ), parameter->getD3Qxx() * parameter->getParH(lev)->sendProcessNeighborX[processNeighbor].memsizeFs )); - checkCudaErrors( cudaMallocHost((void**) &(parameter->getParH(lev)->recvProcessNeighborX[processNeighbor].index ), parameter->getParH(lev)->recvProcessNeighborX[processNeighbor].memsizeIndex )); + checkCudaErrors( cudaMallocHost((void**) &(parameter->getParH(lev)->recvProcessNeighborX[processNeighbor].index ), parameter->getParH(lev)->recvProcessNeighborX[processNeighbor].memsizeIndex )); checkCudaErrors( cudaMallocHost((void**) &(parameter->getParH(lev)->recvProcessNeighborX[processNeighbor].f[0] ), parameter->getD3Qxx() * parameter->getParH(lev)->recvProcessNeighborX[processNeighbor].memsizeFs )); //Device - checkCudaErrors( cudaMalloc((void**) &(parameter->getParD(lev)->sendProcessNeighborX[processNeighbor].index ), parameter->getParD(lev)->sendProcessNeighborX[processNeighbor].memsizeIndex )); + checkCudaErrors( cudaMalloc((void**) &(parameter->getParD(lev)->sendProcessNeighborX[processNeighbor].index ), parameter->getParD(lev)->sendProcessNeighborX[processNeighbor].memsizeIndex )); checkCudaErrors( cudaMalloc((void**) &(parameter->getParD(lev)->sendProcessNeighborX[processNeighbor].f[0] ), parameter->getD3Qxx() * parameter->getParD(lev)->sendProcessNeighborX[processNeighbor].memsizeFs )); - checkCudaErrors( cudaMalloc((void**) &(parameter->getParD(lev)->recvProcessNeighborX[processNeighbor].index ), parameter->getParD(lev)->recvProcessNeighborX[processNeighbor].memsizeIndex )); + checkCudaErrors( cudaMalloc((void**) &(parameter->getParD(lev)->recvProcessNeighborX[processNeighbor].index ), parameter->getParD(lev)->recvProcessNeighborX[processNeighbor].memsizeIndex )); checkCudaErrors( cudaMalloc((void**) &(parameter->getParD(lev)->recvProcessNeighborX[processNeighbor].f[0] ), parameter->getD3Qxx() * parameter->getParD(lev)->recvProcessNeighborX[processNeighbor].memsizeFs )); //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -491,15 +535,15 @@ void CudaMemoryManager::cudaFreeProcessNeighborX(int lev, unsigned int processNe void CudaMemoryManager::cudaAllocProcessNeighborY(int lev, unsigned int processNeighbor) { //Host - checkCudaErrors( cudaMallocHost((void**) &(parameter->getParH(lev)->sendProcessNeighborY[processNeighbor].index ), parameter->getParH(lev)->sendProcessNeighborY[processNeighbor].memsizeIndex )); + checkCudaErrors( cudaMallocHost((void**) &(parameter->getParH(lev)->sendProcessNeighborY[processNeighbor].index ), parameter->getParH(lev)->sendProcessNeighborY[processNeighbor].memsizeIndex )); checkCudaErrors( cudaMallocHost((void**) &(parameter->getParH(lev)->sendProcessNeighborY[processNeighbor].f[0] ), parameter->getD3Qxx() * parameter->getParH(lev)->sendProcessNeighborY[processNeighbor].memsizeFs )); - checkCudaErrors( cudaMallocHost((void**) &(parameter->getParH(lev)->recvProcessNeighborY[processNeighbor].index ), parameter->getParH(lev)->recvProcessNeighborY[processNeighbor].memsizeIndex )); + checkCudaErrors( cudaMallocHost((void**) &(parameter->getParH(lev)->recvProcessNeighborY[processNeighbor].index ), parameter->getParH(lev)->recvProcessNeighborY[processNeighbor].memsizeIndex )); checkCudaErrors( cudaMallocHost((void**) &(parameter->getParH(lev)->recvProcessNeighborY[processNeighbor].f[0] ), parameter->getD3Qxx() * parameter->getParH(lev)->recvProcessNeighborY[processNeighbor].memsizeFs )); //Device - checkCudaErrors( cudaMalloc((void**) &(parameter->getParD(lev)->sendProcessNeighborY[processNeighbor].index ), parameter->getParD(lev)->sendProcessNeighborY[processNeighbor].memsizeIndex )); + checkCudaErrors( cudaMalloc((void**) &(parameter->getParD(lev)->sendProcessNeighborY[processNeighbor].index ), parameter->getParD(lev)->sendProcessNeighborY[processNeighbor].memsizeIndex )); checkCudaErrors( cudaMalloc((void**) &(parameter->getParD(lev)->sendProcessNeighborY[processNeighbor].f[0] ), parameter->getD3Qxx() * parameter->getParD(lev)->sendProcessNeighborY[processNeighbor].memsizeFs )); - checkCudaErrors( cudaMalloc((void**) &(parameter->getParD(lev)->recvProcessNeighborY[processNeighbor].index ), parameter->getParD(lev)->recvProcessNeighborY[processNeighbor].memsizeIndex )); + checkCudaErrors( cudaMalloc((void**) &(parameter->getParD(lev)->recvProcessNeighborY[processNeighbor].index ), parameter->getParD(lev)->recvProcessNeighborY[processNeighbor].memsizeIndex )); checkCudaErrors( cudaMalloc((void**) &(parameter->getParD(lev)->recvProcessNeighborY[processNeighbor].f[0] ), parameter->getD3Qxx() * parameter->getParD(lev)->recvProcessNeighborY[processNeighbor].memsizeFs )); //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -546,15 +590,15 @@ void CudaMemoryManager::cudaFreeProcessNeighborY(int lev, unsigned int processNe void CudaMemoryManager::cudaAllocProcessNeighborZ(int lev, unsigned int processNeighbor) { //Host - checkCudaErrors( cudaMallocHost((void**) &(parameter->getParH(lev)->sendProcessNeighborZ[processNeighbor].index ), parameter->getParH(lev)->sendProcessNeighborZ[processNeighbor].memsizeIndex )); + checkCudaErrors( cudaMallocHost((void**) &(parameter->getParH(lev)->sendProcessNeighborZ[processNeighbor].index ), parameter->getParH(lev)->sendProcessNeighborZ[processNeighbor].memsizeIndex )); checkCudaErrors( cudaMallocHost((void**) &(parameter->getParH(lev)->sendProcessNeighborZ[processNeighbor].f[0] ), parameter->getD3Qxx() * parameter->getParH(lev)->sendProcessNeighborZ[processNeighbor].memsizeFs )); - checkCudaErrors( cudaMallocHost((void**) &(parameter->getParH(lev)->recvProcessNeighborZ[processNeighbor].index ), parameter->getParH(lev)->recvProcessNeighborZ[processNeighbor].memsizeIndex )); + checkCudaErrors( cudaMallocHost((void**) &(parameter->getParH(lev)->recvProcessNeighborZ[processNeighbor].index ), parameter->getParH(lev)->recvProcessNeighborZ[processNeighbor].memsizeIndex )); checkCudaErrors( cudaMallocHost((void**) &(parameter->getParH(lev)->recvProcessNeighborZ[processNeighbor].f[0] ), parameter->getD3Qxx() * parameter->getParH(lev)->recvProcessNeighborZ[processNeighbor].memsizeFs )); //Device - checkCudaErrors( cudaMalloc((void**) &(parameter->getParD(lev)->sendProcessNeighborZ[processNeighbor].index ), parameter->getParD(lev)->sendProcessNeighborZ[processNeighbor].memsizeIndex )); + checkCudaErrors( cudaMalloc((void**) &(parameter->getParD(lev)->sendProcessNeighborZ[processNeighbor].index ), parameter->getParD(lev)->sendProcessNeighborZ[processNeighbor].memsizeIndex )); checkCudaErrors( cudaMalloc((void**) &(parameter->getParD(lev)->sendProcessNeighborZ[processNeighbor].f[0] ), parameter->getD3Qxx() * parameter->getParD(lev)->sendProcessNeighborZ[processNeighbor].memsizeFs )); - checkCudaErrors( cudaMalloc((void**) &(parameter->getParD(lev)->recvProcessNeighborZ[processNeighbor].index ), parameter->getParD(lev)->recvProcessNeighborZ[processNeighbor].memsizeIndex )); + checkCudaErrors( cudaMalloc((void**) &(parameter->getParD(lev)->recvProcessNeighborZ[processNeighbor].index ), parameter->getParD(lev)->recvProcessNeighborZ[processNeighbor].memsizeIndex )); checkCudaErrors( cudaMalloc((void**) &(parameter->getParD(lev)->recvProcessNeighborZ[processNeighbor].f[0] ), parameter->getD3Qxx() * parameter->getParD(lev)->recvProcessNeighborZ[processNeighbor].memsizeFs )); //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -831,7 +875,7 @@ void CudaMemoryManager::cudaAllocTurbulentViscosity(int lev) 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; + double tmp = (double)parameter->getParH(lev)->mem_size_real_SP * 12.0; setMemsizeGPU(tmp, false); } void CudaMemoryManager::cudaCopyTurbulentViscosityHD(int lev) @@ -1166,19 +1210,19 @@ void CudaMemoryManager::cudaAllocGeomNormals(int lev) //Host checkCudaErrors( cudaMallocHost((void**) &(parameter->getParH(lev)->QGeomNormalX.q27[0]), parameter->getD3Qxx()*mem_size_Q_q )); - checkCudaErrors( cudaMallocHost((void**) &(parameter->getParH(lev)->QGeomNormalX.k), mem_size_Q_k )); + checkCudaErrors( cudaMallocHost((void**) &(parameter->getParH(lev)->QGeomNormalX.k), mem_size_Q_k )); checkCudaErrors( cudaMallocHost((void**) &(parameter->getParH(lev)->QGeomNormalY.q27[0]), parameter->getD3Qxx()*mem_size_Q_q )); - checkCudaErrors( cudaMallocHost((void**) &(parameter->getParH(lev)->QGeomNormalY.k), mem_size_Q_k )); + checkCudaErrors( cudaMallocHost((void**) &(parameter->getParH(lev)->QGeomNormalY.k), mem_size_Q_k )); checkCudaErrors( cudaMallocHost((void**) &(parameter->getParH(lev)->QGeomNormalZ.q27[0]), parameter->getD3Qxx()*mem_size_Q_q )); - checkCudaErrors( cudaMallocHost((void**) &(parameter->getParH(lev)->QGeomNormalZ.k), mem_size_Q_k )); + checkCudaErrors( cudaMallocHost((void**) &(parameter->getParH(lev)->QGeomNormalZ.k), mem_size_Q_k )); //Device checkCudaErrors( cudaMalloc((void**) &(parameter->getParD(lev)->QGeomNormalX.q27[0]), parameter->getD3Qxx()* mem_size_Q_q )); - checkCudaErrors( cudaMalloc((void**) &(parameter->getParD(lev)->QGeomNormalX.k), mem_size_Q_k )); + checkCudaErrors( cudaMalloc((void**) &(parameter->getParD(lev)->QGeomNormalX.k), mem_size_Q_k )); checkCudaErrors( cudaMalloc((void**) &(parameter->getParD(lev)->QGeomNormalY.q27[0]), parameter->getD3Qxx()* mem_size_Q_q )); - checkCudaErrors( cudaMalloc((void**) &(parameter->getParD(lev)->QGeomNormalY.k), mem_size_Q_k )); + checkCudaErrors( cudaMalloc((void**) &(parameter->getParD(lev)->QGeomNormalY.k), mem_size_Q_k )); checkCudaErrors( cudaMalloc((void**) &(parameter->getParD(lev)->QGeomNormalZ.q27[0]), parameter->getD3Qxx()* mem_size_Q_q )); - checkCudaErrors( cudaMalloc((void**) &(parameter->getParD(lev)->QGeomNormalZ.k), mem_size_Q_k )); + checkCudaErrors( cudaMalloc((void**) &(parameter->getParD(lev)->QGeomNormalZ.k), mem_size_Q_k )); ////////////////////////////////////////////////////////////////////////// double tmp = 3.0 * (double)mem_size_Q_k + 3.0 * (double)parameter->getD3Qxx()*(double)mem_size_Q_q; @@ -1213,19 +1257,19 @@ void CudaMemoryManager::cudaAllocInflowNormals(int lev) //Host checkCudaErrors( cudaMallocHost((void**) &(parameter->getParH(lev)->QInflowNormalX.q27[0]), parameter->getD3Qxx()*mem_size_Q_q )); - checkCudaErrors( cudaMallocHost((void**) &(parameter->getParH(lev)->QInflowNormalX.k), mem_size_Q_k )); + checkCudaErrors( cudaMallocHost((void**) &(parameter->getParH(lev)->QInflowNormalX.k), mem_size_Q_k )); checkCudaErrors( cudaMallocHost((void**) &(parameter->getParH(lev)->QInflowNormalY.q27[0]), parameter->getD3Qxx()*mem_size_Q_q )); - checkCudaErrors( cudaMallocHost((void**) &(parameter->getParH(lev)->QInflowNormalY.k), mem_size_Q_k )); + checkCudaErrors( cudaMallocHost((void**) &(parameter->getParH(lev)->QInflowNormalY.k), mem_size_Q_k )); checkCudaErrors( cudaMallocHost((void**) &(parameter->getParH(lev)->QInflowNormalZ.q27[0]), parameter->getD3Qxx()*mem_size_Q_q )); - checkCudaErrors( cudaMallocHost((void**) &(parameter->getParH(lev)->QInflowNormalZ.k), mem_size_Q_k )); + checkCudaErrors( cudaMallocHost((void**) &(parameter->getParH(lev)->QInflowNormalZ.k), mem_size_Q_k )); //Device checkCudaErrors( cudaMalloc((void**) &(parameter->getParD(lev)->QInflowNormalX.q27[0]), parameter->getD3Qxx()* mem_size_Q_q )); - checkCudaErrors( cudaMalloc((void**) &(parameter->getParD(lev)->QInflowNormalX.k), mem_size_Q_k )); + checkCudaErrors( cudaMalloc((void**) &(parameter->getParD(lev)->QInflowNormalX.k), mem_size_Q_k )); checkCudaErrors( cudaMalloc((void**) &(parameter->getParD(lev)->QInflowNormalY.q27[0]), parameter->getD3Qxx()* mem_size_Q_q )); - checkCudaErrors( cudaMalloc((void**) &(parameter->getParD(lev)->QInflowNormalY.k), mem_size_Q_k )); + checkCudaErrors( cudaMalloc((void**) &(parameter->getParD(lev)->QInflowNormalY.k), mem_size_Q_k )); checkCudaErrors( cudaMalloc((void**) &(parameter->getParD(lev)->QInflowNormalZ.q27[0]), parameter->getD3Qxx()* mem_size_Q_q )); - checkCudaErrors( cudaMalloc((void**) &(parameter->getParD(lev)->QInflowNormalZ.k), mem_size_Q_k )); + checkCudaErrors( cudaMalloc((void**) &(parameter->getParD(lev)->QInflowNormalZ.k), mem_size_Q_k )); ////////////////////////////////////////////////////////////////////////// double tmp = 3.0 * (double)mem_size_Q_k + 3.0 * (double)parameter->getD3Qxx()*(double)mem_size_Q_q; @@ -1260,19 +1304,19 @@ void CudaMemoryManager::cudaAllocOutflowNormals(int lev) //Host checkCudaErrors( cudaMallocHost((void**) &(parameter->getParH(lev)->QOutflowNormalX.q27[0]), parameter->getD3Qxx()*mem_size_Q_q )); - checkCudaErrors( cudaMallocHost((void**) &(parameter->getParH(lev)->QOutflowNormalX.k), mem_size_Q_k )); + checkCudaErrors( cudaMallocHost((void**) &(parameter->getParH(lev)->QOutflowNormalX.k), mem_size_Q_k )); checkCudaErrors( cudaMallocHost((void**) &(parameter->getParH(lev)->QOutflowNormalY.q27[0]), parameter->getD3Qxx()*mem_size_Q_q )); - checkCudaErrors( cudaMallocHost((void**) &(parameter->getParH(lev)->QOutflowNormalY.k), mem_size_Q_k )); + checkCudaErrors( cudaMallocHost((void**) &(parameter->getParH(lev)->QOutflowNormalY.k), mem_size_Q_k )); checkCudaErrors( cudaMallocHost((void**) &(parameter->getParH(lev)->QOutflowNormalZ.q27[0]), parameter->getD3Qxx()*mem_size_Q_q )); - checkCudaErrors( cudaMallocHost((void**) &(parameter->getParH(lev)->QOutflowNormalZ.k), mem_size_Q_k )); + checkCudaErrors( cudaMallocHost((void**) &(parameter->getParH(lev)->QOutflowNormalZ.k), mem_size_Q_k )); //Device checkCudaErrors( cudaMalloc((void**) &(parameter->getParD(lev)->QOutflowNormalX.q27[0]), parameter->getD3Qxx()* mem_size_Q_q )); - checkCudaErrors( cudaMalloc((void**) &(parameter->getParD(lev)->QOutflowNormalX.k), mem_size_Q_k )); + checkCudaErrors( cudaMalloc((void**) &(parameter->getParD(lev)->QOutflowNormalX.k), mem_size_Q_k )); checkCudaErrors( cudaMalloc((void**) &(parameter->getParD(lev)->QOutflowNormalY.q27[0]), parameter->getD3Qxx()* mem_size_Q_q )); - checkCudaErrors( cudaMalloc((void**) &(parameter->getParD(lev)->QOutflowNormalY.k), mem_size_Q_k )); + checkCudaErrors( cudaMalloc((void**) &(parameter->getParD(lev)->QOutflowNormalY.k), mem_size_Q_k )); checkCudaErrors( cudaMalloc((void**) &(parameter->getParD(lev)->QOutflowNormalZ.q27[0]), parameter->getD3Qxx()* mem_size_Q_q )); - checkCudaErrors( cudaMalloc((void**) &(parameter->getParD(lev)->QOutflowNormalZ.k), mem_size_Q_k )); + checkCudaErrors( cudaMalloc((void**) &(parameter->getParD(lev)->QOutflowNormalZ.k), mem_size_Q_k )); ////////////////////////////////////////////////////////////////////////// double tmp = 3.0 * (double)mem_size_Q_k + 3.0 * (double)parameter->getD3Qxx()*(double)mem_size_Q_q; @@ -1309,13 +1353,13 @@ 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.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 //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.k), mem_size_Q_k )); ////////////////////////////////////////////////////////////////////////// double tmp = (double)mem_size_Q_k + (double)parameter->getD3Qxx()*(double)mem_size_Q_q; @@ -1346,7 +1390,7 @@ void CudaMemoryManager::cudaAllocTestRE(int lev, unsigned int size) //Device checkCudaErrors( cudaMalloc((void**) &(parameter->getParD(lev)->kDistTestRE.f[0]), (1+parameter->getD3Qxx())*mem_size)); ////////////////////////////////////////////////////////////////////////// - double tmp = (double)size; + double tmp = (double)((1. + parameter->getD3Qxx()) * mem_size); setMemsizeGPU(tmp, false); } void CudaMemoryManager::cudaCopyTestREtoDevice(int lev, unsigned int size) @@ -1552,18 +1596,18 @@ void CudaMemoryManager::cudaFreeVeloPropeller(int lev) void CudaMemoryManager::cudaAllocMeasurePointsIndex(int lev) { //Host - checkCudaErrors( cudaMallocHost((void**) &(parameter->getParH(lev)->kMP), parameter->getParH(lev)->memSizeIntkMP )); + checkCudaErrors( cudaMallocHost((void**) &(parameter->getParH(lev)->kMP), parameter->getParH(lev)->memSizeIntkMP )); checkCudaErrors( cudaMallocHost((void**) &(parameter->getParH(lev)->VxMP), parameter->getParH(lev)->memSizerealkMP )); checkCudaErrors( cudaMallocHost((void**) &(parameter->getParH(lev)->VyMP), parameter->getParH(lev)->memSizerealkMP )); checkCudaErrors( cudaMallocHost((void**) &(parameter->getParH(lev)->VzMP), parameter->getParH(lev)->memSizerealkMP )); - checkCudaErrors( cudaMallocHost((void**) &(parameter->getParH(lev)->RhoMP), parameter->getParH(lev)->memSizerealkMP )); + checkCudaErrors( cudaMallocHost((void**) &(parameter->getParH(lev)->RhoMP), parameter->getParH(lev)->memSizerealkMP )); //Device - checkCudaErrors( cudaMalloc((void**) &(parameter->getParD(lev)->kMP), parameter->getParD(lev)->memSizeIntkMP )); + checkCudaErrors( cudaMalloc((void**) &(parameter->getParD(lev)->kMP), parameter->getParD(lev)->memSizeIntkMP )); checkCudaErrors( cudaMalloc((void**) &(parameter->getParD(lev)->VxMP), parameter->getParD(lev)->memSizerealkMP )); checkCudaErrors( cudaMalloc((void**) &(parameter->getParD(lev)->VyMP), parameter->getParD(lev)->memSizerealkMP )); checkCudaErrors( cudaMalloc((void**) &(parameter->getParD(lev)->VzMP), parameter->getParD(lev)->memSizerealkMP )); - checkCudaErrors( cudaMalloc((void**) &(parameter->getParD(lev)->RhoMP), parameter->getParD(lev)->memSizerealkMP )); + checkCudaErrors( cudaMalloc((void**) &(parameter->getParD(lev)->RhoMP), parameter->getParD(lev)->memSizerealkMP )); ////////////////////////////////////////////////////////////////////////// double tmp = (double)parameter->getParH(lev)->memSizeIntkMP + 4. * (double)parameter->getParH(lev)->memSizerealkMP; @@ -1615,17 +1659,17 @@ void CudaMemoryManager::cudaAllocDragLift(int lev, int numofelem) unsigned int mem_size = sizeof(double)*numofelem; //Host - checkCudaErrors( cudaMallocHost((void**) &(parameter->getParH(lev)->DragPreX), mem_size )); - checkCudaErrors( cudaMallocHost((void**) &(parameter->getParH(lev)->DragPreY), mem_size )); - checkCudaErrors( cudaMallocHost((void**) &(parameter->getParH(lev)->DragPreZ), mem_size )); + checkCudaErrors( cudaMallocHost((void**) &(parameter->getParH(lev)->DragPreX), mem_size )); + checkCudaErrors( cudaMallocHost((void**) &(parameter->getParH(lev)->DragPreY), mem_size )); + checkCudaErrors( cudaMallocHost((void**) &(parameter->getParH(lev)->DragPreZ), mem_size )); checkCudaErrors( cudaMallocHost((void**) &(parameter->getParH(lev)->DragPostX), mem_size )); checkCudaErrors( cudaMallocHost((void**) &(parameter->getParH(lev)->DragPostY), mem_size )); checkCudaErrors( cudaMallocHost((void**) &(parameter->getParH(lev)->DragPostZ), mem_size )); //Device - checkCudaErrors( cudaMalloc((void**) &(parameter->getParD(lev)->DragPreX), mem_size )); - checkCudaErrors( cudaMalloc((void**) &(parameter->getParD(lev)->DragPreY), mem_size )); - checkCudaErrors( cudaMalloc((void**) &(parameter->getParD(lev)->DragPreZ), mem_size )); + checkCudaErrors( cudaMalloc((void**) &(parameter->getParD(lev)->DragPreX), mem_size )); + checkCudaErrors( cudaMalloc((void**) &(parameter->getParD(lev)->DragPreY), mem_size )); + checkCudaErrors( cudaMalloc((void**) &(parameter->getParD(lev)->DragPreZ), mem_size )); checkCudaErrors( cudaMalloc((void**) &(parameter->getParD(lev)->DragPostX), mem_size )); checkCudaErrors( cudaMalloc((void**) &(parameter->getParD(lev)->DragPostY), mem_size )); checkCudaErrors( cudaMalloc((void**) &(parameter->getParD(lev)->DragPostZ), mem_size )); @@ -1674,7 +1718,7 @@ void CudaMemoryManager::cudaAlloc2ndMoments(int lev, int numofelem) checkCudaErrors( cudaMalloc((void**) &(parameter->getParD(lev)->kxxMzzFromfcNEQ), mem_size )); ////////////////////////////////////////////////////////////////////////// - double tmp = 5. * (real)mem_size; + double tmp = 5. * (double)mem_size; setMemsizeGPU(tmp, false); } void CudaMemoryManager::cudaCopy2ndMoments(int lev, int numofelem) @@ -1719,7 +1763,7 @@ void CudaMemoryManager::cudaAlloc3rdMoments(int lev, int numofelem) checkCudaErrors( cudaMalloc((void**) &(parameter->getParD(lev)->CUMcab ), mem_size )); ////////////////////////////////////////////////////////////////////////// - double tmp = 7. * (real)mem_size; + double tmp = 7. * (double)mem_size; setMemsizeGPU(tmp, false); } void CudaMemoryManager::cudaCopy3rdMoments(int lev, int numofelem) @@ -1774,7 +1818,7 @@ void CudaMemoryManager::cudaAllocHigherMoments(int lev, int numofelem) checkCudaErrors( cudaMalloc((void**) &(parameter->getParD(lev)->CUMccc ), mem_size )); ////////////////////////////////////////////////////////////////////////// - double tmp = 7. * (real)mem_size; + double tmp = 10. * (double)mem_size; setMemsizeGPU(tmp, false); } void CudaMemoryManager::cudaCopyHigherMoments(int lev, int numofelem) @@ -1821,7 +1865,7 @@ void CudaMemoryManager::cudaAllocForceVelo(int lev, int numofelem) checkCudaErrors( cudaMalloc((void**) &(parameter->getParD(lev)->VzForce ), mem_size )); ////////////////////////////////////////////////////////////////////////// - double tmp = 3. * (real)mem_size; + double tmp = 3. * (double)mem_size; setMemsizeGPU(tmp, false); } void CudaMemoryManager::cudaCopyForceVelo(int lev, int numofelem) @@ -1992,8 +2036,12 @@ void CudaMemoryManager::cudaAllocParticles(int lev) checkCudaErrors( cudaMalloc((void**) &(parameter->getParD(lev)->plp.hot), parameter->getParD(lev)->plp.memSizeBoolBC )); ////////////////////////////////////////////////////////////////////////// - double tmp = (double)parameter->getParD(lev)->plp.memSizerealAll * (double)9.0 + (double)parameter->getParD(lev)->plp.memSizeID * (double)2.0 + (double)parameter->getParD(lev)->plp.memSizeTimestep - + (double)parameter->getParD(lev)->plp.memSizeBool + (double)parameter->getParD(lev)->plp.memSizeBoolBC; + double tmp = + (double)parameter->getParD(lev)->plp.memSizerealAll * (double)9.0 + + (double)parameter->getParD(lev)->plp.memSizeID * (double)2.0 + + (double)parameter->getParD(lev)->plp.memSizeTimestep + + (double)parameter->getParD(lev)->plp.memSizeBool + + (double)parameter->getParD(lev)->plp.memSizeBoolBC; setMemsizeGPU(tmp, false); } void CudaMemoryManager::cudaCopyParticles(int lev) @@ -2033,6 +2081,9 @@ void CudaMemoryManager::cudaAllocRandomValues() { //Device checkCudaErrors( cudaMalloc((void**)(parameter->getRandomState()), (sizeof(curandState)*parameter->getParD(parameter->getFine())->plp.numberOfParticles) )); + ////////////////////////////////////////////////////////////////////////// + double tmp = (double)(sizeof(curandState) * parameter->getParD(parameter->getFine())->plp.numberOfParticles); + setMemsizeGPU(tmp, false); } ////////////////////////////////////////////////////////////////////////// //porous media @@ -2078,6 +2129,9 @@ void CudaMemoryManager::cudaAllocConc(int lev) checkCudaErrors( cudaMallocHost((void**) &(parameter->getParH(lev)->Conc), parameter->getParH(lev)->mem_size_real_SP)); //Device checkCudaErrors( cudaMalloc((void**) &(parameter->getParD(lev)->Conc), parameter->getParD(lev)->mem_size_real_SP)); + ////////////////////////////////////////////////////////////////////////// + double tmp = (double)parameter->getParH(lev)->mem_size_real_SP; + setMemsizeGPU(tmp, false); } void CudaMemoryManager::cudaCopyConcDH(int lev) { @@ -2103,6 +2157,9 @@ void CudaMemoryManager::cudaAllocTempFs(int lev) { checkCudaErrors( cudaMalloc((void**) &(parameter->getParD(lev)->d27.f[0]), parameter->getDiffMod()*parameter->getParH(lev)->mem_size_real_SP)); } + ////////////////////////////////////////////////////////////////////////// + double tmp = (double)(parameter->getDiffMod() * parameter->getParH(lev)->mem_size_real_SP); + setMemsizeGPU(tmp, false); } ////////////////////////////////////////////////////////////////////////// void CudaMemoryManager::cudaAllocTempPressBC(int lev) @@ -2119,7 +2176,9 @@ void CudaMemoryManager::cudaAllocTempPressBC(int lev) checkCudaErrors( cudaMalloc((void**) ¶meter->getParD(lev)->TempPress.temp, mem_size_TempPress_q)); checkCudaErrors( cudaMalloc((void**) ¶meter->getParD(lev)->TempPress.velo, mem_size_TempPress_q)); checkCudaErrors( cudaMalloc((void**) ¶meter->getParD(lev)->TempPress.k, mem_size_TempPress_k)); - + ////////////////////////////////////////////////////////////////////////// + double tmp = (double)(2.0 * mem_size_TempPress_q) + (double)(mem_size_TempPress_k); + setMemsizeGPU(tmp, false); } void CudaMemoryManager::cudaCopyTempPressBCHD(int lev) { @@ -2154,6 +2213,9 @@ void CudaMemoryManager::cudaAllocTempVeloBC(int lev) checkCudaErrors( cudaMalloc((void**) ¶meter->getParD(lev)->TempVel.tempPulse, mem_size_TempVel_q)); checkCudaErrors( cudaMalloc((void**) ¶meter->getParD(lev)->TempVel.velo, mem_size_TempVel_q)); checkCudaErrors( cudaMalloc((void**) ¶meter->getParD(lev)->TempVel.k, mem_size_TempVel_k)); + ////////////////////////////////////////////////////////////////////////// + double tmp = (double)(3.0 * mem_size_TempVel_q) + (double)(mem_size_TempVel_k); + setMemsizeGPU(tmp, false); } void CudaMemoryManager::cudaCopyTempVeloBCHD(int lev) { @@ -2186,7 +2248,9 @@ void CudaMemoryManager::cudaAllocTempNoSlipBC(int lev) // Device Memory checkCudaErrors( cudaMalloc((void**) ¶meter->getParD(lev)->Temp.temp, mem_size_Temp_q)); checkCudaErrors( cudaMalloc((void**) ¶meter->getParD(lev)->Temp.k, mem_size_Temp_k)); - + ////////////////////////////////////////////////////////////////////////// + double tmp = (double)(mem_size_Temp_q) + (double)(mem_size_Temp_k); + setMemsizeGPU(tmp, false); } void CudaMemoryManager::cudaCopyTempNoSlipBCHD(int lev) { @@ -2286,6 +2350,26 @@ void CudaMemoryManager::cudaFreeConcFile(int lev) checkCudaErrors( cudaFreeHost(parameter->getParH(lev)->concIndex)); } ////////////////////////////////////////////////////////////////////////// +void CudaMemoryManager::cudaAllocMedianOutAD(int lev) +{ + //Host + checkCudaErrors(cudaMallocHost((void**) &(parameter->getParH(lev)->rho_SP_Med_Out), parameter->getParH(lev)->mem_size_real_SP)); + checkCudaErrors(cudaMallocHost((void**) &(parameter->getParH(lev)->vx_SP_Med_Out), parameter->getParH(lev)->mem_size_real_SP)); + checkCudaErrors(cudaMallocHost((void**) &(parameter->getParH(lev)->vy_SP_Med_Out), parameter->getParH(lev)->mem_size_real_SP)); + checkCudaErrors(cudaMallocHost((void**) &(parameter->getParH(lev)->vz_SP_Med_Out), parameter->getParH(lev)->mem_size_real_SP)); + checkCudaErrors(cudaMallocHost((void**) &(parameter->getParH(lev)->press_SP_Med_Out), parameter->getParH(lev)->mem_size_real_SP)); + checkCudaErrors(cudaMallocHost((void**) &(parameter->getParH(lev)->Conc_Med_Out), parameter->getParH(lev)->mem_size_real_SP)); +} +void CudaMemoryManager::cudaFreeMedianOutAD(int lev) +{ + checkCudaErrors(cudaFreeHost(parameter->getParH(lev)->vx_SP_Med_Out)); + checkCudaErrors(cudaFreeHost(parameter->getParH(lev)->vy_SP_Med_Out)); + checkCudaErrors(cudaFreeHost(parameter->getParH(lev)->vz_SP_Med_Out)); + checkCudaErrors(cudaFreeHost(parameter->getParH(lev)->rho_SP_Med_Out)); + checkCudaErrors(cudaFreeHost(parameter->getParH(lev)->press_SP_Med_Out)); + checkCudaErrors(cudaFreeHost(parameter->getParH(lev)->Conc_Med_Out)); +} + ////////////////////////////////////////////////////////////////////////// //Process Neighbors @@ -2293,20 +2377,23 @@ void CudaMemoryManager::cudaFreeConcFile(int lev) void CudaMemoryManager::cudaAllocProcessNeighbor(int lev, unsigned int processNeighbor) { //Host - checkCudaErrors( cudaMallocHost((void**) &(parameter->getParH(lev)->sendProcessNeighbor[processNeighbor].index ), parameter->getParH(lev)->sendProcessNeighbor[processNeighbor].memsizeIndex )); + checkCudaErrors( cudaMallocHost((void**) &(parameter->getParH(lev)->sendProcessNeighbor[processNeighbor].index ), parameter->getParH(lev)->sendProcessNeighbor[processNeighbor].memsizeIndex )); checkCudaErrors( cudaMallocHost((void**) &(parameter->getParH(lev)->sendProcessNeighbor[processNeighbor].f[0] ), parameter->getD3Qxx() * parameter->getParH(lev)->sendProcessNeighbor[processNeighbor].memsizeFs )); - checkCudaErrors( cudaMallocHost((void**) &(parameter->getParH(lev)->recvProcessNeighbor[processNeighbor].index ), parameter->getParH(lev)->recvProcessNeighbor[processNeighbor].memsizeIndex )); + checkCudaErrors( cudaMallocHost((void**) &(parameter->getParH(lev)->recvProcessNeighbor[processNeighbor].index ), parameter->getParH(lev)->recvProcessNeighbor[processNeighbor].memsizeIndex )); checkCudaErrors( cudaMallocHost((void**) &(parameter->getParH(lev)->recvProcessNeighbor[processNeighbor].f[0] ), parameter->getD3Qxx() * parameter->getParH(lev)->recvProcessNeighbor[processNeighbor].memsizeFs )); //Device - checkCudaErrors( cudaMalloc((void**) &(parameter->getParD(lev)->sendProcessNeighbor[processNeighbor].index ), parameter->getParD(lev)->sendProcessNeighbor[processNeighbor].memsizeIndex )); + checkCudaErrors( cudaMalloc((void**) &(parameter->getParD(lev)->sendProcessNeighbor[processNeighbor].index ), parameter->getParD(lev)->sendProcessNeighbor[processNeighbor].memsizeIndex )); checkCudaErrors( cudaMalloc((void**) &(parameter->getParD(lev)->sendProcessNeighbor[processNeighbor].f[0] ), parameter->getD3Qxx() * parameter->getParD(lev)->sendProcessNeighbor[processNeighbor].memsizeFs )); - checkCudaErrors( cudaMalloc((void**) &(parameter->getParD(lev)->recvProcessNeighbor[processNeighbor].index ), parameter->getParD(lev)->recvProcessNeighbor[processNeighbor].memsizeIndex )); + checkCudaErrors( cudaMalloc((void**) &(parameter->getParD(lev)->recvProcessNeighbor[processNeighbor].index ), parameter->getParD(lev)->recvProcessNeighbor[processNeighbor].memsizeIndex )); checkCudaErrors( cudaMalloc((void**) &(parameter->getParD(lev)->recvProcessNeighbor[processNeighbor].f[0] ), parameter->getD3Qxx() * parameter->getParD(lev)->recvProcessNeighbor[processNeighbor].memsizeFs )); //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - double tmp = (double)parameter->getParH(lev)->sendProcessNeighbor[processNeighbor].memsizeIndex + (double)parameter->getD3Qxx()*(double)parameter->getParH(lev)->sendProcessNeighbor[processNeighbor].memsizeFs + - (double)parameter->getParH(lev)->recvProcessNeighbor[processNeighbor].memsizeIndex + (double)parameter->getD3Qxx()*(double)parameter->getParH(lev)->recvProcessNeighbor[processNeighbor].memsizeFs; + double tmp = + (double)parameter->getParH(lev)->sendProcessNeighbor[processNeighbor].memsizeIndex + + (double)parameter->getD3Qxx()*(double)parameter->getParH(lev)->sendProcessNeighbor[processNeighbor].memsizeFs + + (double)parameter->getParH(lev)->recvProcessNeighbor[processNeighbor].memsizeIndex + + (double)parameter->getD3Qxx()*(double)parameter->getParH(lev)->recvProcessNeighbor[processNeighbor].memsizeFs; setMemsizeGPU(tmp, false); //printf("memsize GPU for neighbors %f \n",tmp/1000000.0); } @@ -2363,8 +2450,11 @@ void CudaMemoryManager::cudaAllocProcessNeighborADX(int lev, unsigned int proces checkCudaErrors( cudaMalloc((void**) &(parameter->getParD(lev)->recvProcessNeighborADX[processNeighbor].f[0] ), parameter->getDiffMod() * parameter->getParD(lev)->recvProcessNeighborADX[processNeighbor].memsizeFs )); //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - double tmp = (double)parameter->getParH(lev)->sendProcessNeighborADX[processNeighbor].memsizeIndex + (double)parameter->getDiffMod()*(double)parameter->getParH(lev)->sendProcessNeighborADX[processNeighbor].memsizeFs + - (double)parameter->getParH(lev)->recvProcessNeighborADX[processNeighbor].memsizeIndex + (double)parameter->getDiffMod()*(double)parameter->getParH(lev)->recvProcessNeighborADX[processNeighbor].memsizeFs; + double tmp = + (double)parameter->getParH(lev)->sendProcessNeighborADX[processNeighbor].memsizeIndex + + (double)parameter->getDiffMod()*(double)parameter->getParH(lev)->sendProcessNeighborADX[processNeighbor].memsizeFs + + (double)parameter->getParH(lev)->recvProcessNeighborADX[processNeighbor].memsizeIndex + + (double)parameter->getDiffMod()*(double)parameter->getParH(lev)->recvProcessNeighborADX[processNeighbor].memsizeFs; setMemsizeGPU(tmp, false); //printf("memsize GPU for neighbors %f \n",tmp/1000000.0); } @@ -2406,20 +2496,23 @@ void CudaMemoryManager::cudaFreeProcessNeighborADX(int lev, unsigned int process void CudaMemoryManager::cudaAllocProcessNeighborADY(int lev, unsigned int processNeighbor) { //Host - checkCudaErrors( cudaMallocHost((void**) &(parameter->getParH(lev)->sendProcessNeighborADY[processNeighbor].index ), parameter->getParH(lev)->sendProcessNeighborADY[processNeighbor].memsizeIndex )); + checkCudaErrors( cudaMallocHost((void**) &(parameter->getParH(lev)->sendProcessNeighborADY[processNeighbor].index ), parameter->getParH(lev)->sendProcessNeighborADY[processNeighbor].memsizeIndex )); checkCudaErrors( cudaMallocHost((void**) &(parameter->getParH(lev)->sendProcessNeighborADY[processNeighbor].f[0] ), parameter->getDiffMod() * parameter->getParH(lev)->sendProcessNeighborADY[processNeighbor].memsizeFs )); - checkCudaErrors( cudaMallocHost((void**) &(parameter->getParH(lev)->recvProcessNeighborADY[processNeighbor].index ), parameter->getParH(lev)->recvProcessNeighborADY[processNeighbor].memsizeIndex )); + checkCudaErrors( cudaMallocHost((void**) &(parameter->getParH(lev)->recvProcessNeighborADY[processNeighbor].index ), parameter->getParH(lev)->recvProcessNeighborADY[processNeighbor].memsizeIndex )); checkCudaErrors( cudaMallocHost((void**) &(parameter->getParH(lev)->recvProcessNeighborADY[processNeighbor].f[0] ), parameter->getDiffMod() * parameter->getParH(lev)->recvProcessNeighborADY[processNeighbor].memsizeFs )); //Device - checkCudaErrors( cudaMalloc((void**) &(parameter->getParD(lev)->sendProcessNeighborADY[processNeighbor].index ), parameter->getParD(lev)->sendProcessNeighborADY[processNeighbor].memsizeIndex )); + checkCudaErrors( cudaMalloc((void**) &(parameter->getParD(lev)->sendProcessNeighborADY[processNeighbor].index ), parameter->getParD(lev)->sendProcessNeighborADY[processNeighbor].memsizeIndex )); checkCudaErrors( cudaMalloc((void**) &(parameter->getParD(lev)->sendProcessNeighborADY[processNeighbor].f[0] ), parameter->getDiffMod() * parameter->getParD(lev)->sendProcessNeighborADY[processNeighbor].memsizeFs )); - checkCudaErrors( cudaMalloc((void**) &(parameter->getParD(lev)->recvProcessNeighborADY[processNeighbor].index ), parameter->getParD(lev)->recvProcessNeighborADY[processNeighbor].memsizeIndex )); + checkCudaErrors( cudaMalloc((void**) &(parameter->getParD(lev)->recvProcessNeighborADY[processNeighbor].index ), parameter->getParD(lev)->recvProcessNeighborADY[processNeighbor].memsizeIndex )); checkCudaErrors( cudaMalloc((void**) &(parameter->getParD(lev)->recvProcessNeighborADY[processNeighbor].f[0] ), parameter->getDiffMod() * parameter->getParD(lev)->recvProcessNeighborADY[processNeighbor].memsizeFs )); //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - double tmp = (double)parameter->getParH(lev)->sendProcessNeighborADY[processNeighbor].memsizeIndex + (double)parameter->getDiffMod()*(double)parameter->getParH(lev)->sendProcessNeighborADY[processNeighbor].memsizeFs + - (double)parameter->getParH(lev)->recvProcessNeighborADY[processNeighbor].memsizeIndex + (double)parameter->getDiffMod()*(double)parameter->getParH(lev)->recvProcessNeighborADY[processNeighbor].memsizeFs; + double tmp = + (double)parameter->getParH(lev)->sendProcessNeighborADY[processNeighbor].memsizeIndex + + (double)parameter->getDiffMod()*(double)parameter->getParH(lev)->sendProcessNeighborADY[processNeighbor].memsizeFs + + (double)parameter->getParH(lev)->recvProcessNeighborADY[processNeighbor].memsizeIndex + + (double)parameter->getDiffMod()*(double)parameter->getParH(lev)->recvProcessNeighborADY[processNeighbor].memsizeFs; setMemsizeGPU(tmp, false); //printf("memsize GPU for neighbors %f \n",tmp/1000000.0); } @@ -2461,20 +2554,23 @@ void CudaMemoryManager::cudaFreeProcessNeighborADY(int lev, unsigned int process void CudaMemoryManager::cudaAllocProcessNeighborADZ(int lev, unsigned int processNeighbor) { //Host - checkCudaErrors( cudaMallocHost((void**) &(parameter->getParH(lev)->sendProcessNeighborADZ[processNeighbor].index ), parameter->getParH(lev)->sendProcessNeighborADZ[processNeighbor].memsizeIndex )); + checkCudaErrors( cudaMallocHost((void**) &(parameter->getParH(lev)->sendProcessNeighborADZ[processNeighbor].index ), parameter->getParH(lev)->sendProcessNeighborADZ[processNeighbor].memsizeIndex )); checkCudaErrors( cudaMallocHost((void**) &(parameter->getParH(lev)->sendProcessNeighborADZ[processNeighbor].f[0] ), parameter->getDiffMod() * parameter->getParH(lev)->sendProcessNeighborADZ[processNeighbor].memsizeFs )); - checkCudaErrors( cudaMallocHost((void**) &(parameter->getParH(lev)->recvProcessNeighborADZ[processNeighbor].index ), parameter->getParH(lev)->recvProcessNeighborADZ[processNeighbor].memsizeIndex )); + checkCudaErrors( cudaMallocHost((void**) &(parameter->getParH(lev)->recvProcessNeighborADZ[processNeighbor].index ), parameter->getParH(lev)->recvProcessNeighborADZ[processNeighbor].memsizeIndex )); checkCudaErrors( cudaMallocHost((void**) &(parameter->getParH(lev)->recvProcessNeighborADZ[processNeighbor].f[0] ), parameter->getDiffMod() * parameter->getParH(lev)->recvProcessNeighborADZ[processNeighbor].memsizeFs )); //Device - checkCudaErrors( cudaMalloc((void**) &(parameter->getParD(lev)->sendProcessNeighborADZ[processNeighbor].index ), parameter->getParD(lev)->sendProcessNeighborADZ[processNeighbor].memsizeIndex )); + checkCudaErrors( cudaMalloc((void**) &(parameter->getParD(lev)->sendProcessNeighborADZ[processNeighbor].index ), parameter->getParD(lev)->sendProcessNeighborADZ[processNeighbor].memsizeIndex )); checkCudaErrors( cudaMalloc((void**) &(parameter->getParD(lev)->sendProcessNeighborADZ[processNeighbor].f[0] ), parameter->getDiffMod() * parameter->getParD(lev)->sendProcessNeighborADZ[processNeighbor].memsizeFs )); - checkCudaErrors( cudaMalloc((void**) &(parameter->getParD(lev)->recvProcessNeighborADZ[processNeighbor].index ), parameter->getParD(lev)->recvProcessNeighborADZ[processNeighbor].memsizeIndex )); + checkCudaErrors( cudaMalloc((void**) &(parameter->getParD(lev)->recvProcessNeighborADZ[processNeighbor].index ), parameter->getParD(lev)->recvProcessNeighborADZ[processNeighbor].memsizeIndex )); checkCudaErrors( cudaMalloc((void**) &(parameter->getParD(lev)->recvProcessNeighborADZ[processNeighbor].f[0] ), parameter->getDiffMod() * parameter->getParD(lev)->recvProcessNeighborADZ[processNeighbor].memsizeFs )); //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - double tmp = (double)parameter->getParH(lev)->sendProcessNeighborADZ[processNeighbor].memsizeIndex + (double)parameter->getDiffMod()*(double)parameter->getParH(lev)->sendProcessNeighborADZ[processNeighbor].memsizeFs + - (double)parameter->getParH(lev)->recvProcessNeighborADZ[processNeighbor].memsizeIndex + (double)parameter->getDiffMod()*(double)parameter->getParH(lev)->recvProcessNeighborADZ[processNeighbor].memsizeFs; + double tmp = + (double)parameter->getParH(lev)->sendProcessNeighborADZ[processNeighbor].memsizeIndex + + (double)parameter->getDiffMod()*(double)parameter->getParH(lev)->sendProcessNeighborADZ[processNeighbor].memsizeFs + + (double)parameter->getParH(lev)->recvProcessNeighborADZ[processNeighbor].memsizeIndex + + (double)parameter->getDiffMod()*(double)parameter->getParH(lev)->recvProcessNeighborADZ[processNeighbor].memsizeFs; setMemsizeGPU(tmp, false); //printf("memsize GPU for neighbors %f \n",tmp/1000000.0); } @@ -2549,10 +2645,306 @@ void CudaMemoryManager::cudaFree2ndOrderDerivitivesIsoTest(int lev) checkCudaErrors(cudaFreeHost(parameter->getParH(lev)->dzzUz)); } +//////////////////////////////////////////////////////////////////////////////////// +// 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->getNumberOfNodes()) ); + checkCudaErrors( cudaMallocHost((void**) &actuatorLine->bladeCoordsYH, sizeof(real)*actuatorLine->getNumberOfNodes()) ); + checkCudaErrors( cudaMallocHost((void**) &actuatorLine->bladeCoordsZH, sizeof(real)*actuatorLine->getNumberOfNodes()) ); + + checkCudaErrors( cudaMalloc((void**) &actuatorLine->bladeCoordsXD, sizeof(real)*actuatorLine->getNumberOfNodes()) ); + checkCudaErrors( cudaMalloc((void**) &actuatorLine->bladeCoordsYD, sizeof(real)*actuatorLine->getNumberOfNodes()) ); + checkCudaErrors( cudaMalloc((void**) &actuatorLine->bladeCoordsZD, sizeof(real)*actuatorLine->getNumberOfNodes()) ); + + setMemsizeGPU(3.f*actuatorLine->getNumberOfNodes(), false); +} +void CudaMemoryManager::cudaCopyBladeCoordsHtoD(ActuatorLine* actuatorLine) +{ + checkCudaErrors( cudaMemcpy(actuatorLine->bladeCoordsXD, actuatorLine->bladeCoordsXH, sizeof(real)*actuatorLine->getNumberOfNodes(), cudaMemcpyHostToDevice) ); + checkCudaErrors( cudaMemcpy(actuatorLine->bladeCoordsYD, actuatorLine->bladeCoordsYH, sizeof(real)*actuatorLine->getNumberOfNodes(), cudaMemcpyHostToDevice) ); + checkCudaErrors( cudaMemcpy(actuatorLine->bladeCoordsZD, actuatorLine->bladeCoordsZH, sizeof(real)*actuatorLine->getNumberOfNodes(), cudaMemcpyHostToDevice) ); +} +void CudaMemoryManager::cudaCopyBladeCoordsDtoH(ActuatorLine* actuatorLine) +{ + checkCudaErrors( cudaMemcpy(actuatorLine->bladeCoordsXH, actuatorLine->bladeCoordsXD, sizeof(real)*actuatorLine->getNumberOfNodes(), cudaMemcpyDeviceToHost) ); + checkCudaErrors( cudaMemcpy(actuatorLine->bladeCoordsYH, actuatorLine->bladeCoordsYD, sizeof(real)*actuatorLine->getNumberOfNodes(), cudaMemcpyDeviceToHost) ); + checkCudaErrors( cudaMemcpy(actuatorLine->bladeCoordsZH, actuatorLine->bladeCoordsZD, sizeof(real)*actuatorLine->getNumberOfNodes(), 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->getNumberOfNodes()) ); + + checkCudaErrors( cudaMalloc((void**) &actuatorLine->bladeIndicesD, sizeof(uint)*actuatorLine->getNumberOfNodes()) ); + + setMemsizeGPU(sizeof(uint)*actuatorLine->getNumberOfNodes(), false); +} + +void CudaMemoryManager::cudaCopyBladeIndicesHtoD(ActuatorLine* actuatorLine) +{ + checkCudaErrors( cudaMemcpy(actuatorLine->bladeIndicesD, actuatorLine->bladeIndicesH, sizeof(uint)*actuatorLine->getNumberOfNodes(), 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->getNumberOfNodes()) ); + checkCudaErrors( cudaMallocHost((void**) &actuatorLine->bladeVelocitiesYH, sizeof(real)*actuatorLine->getNumberOfNodes()) ); + checkCudaErrors( cudaMallocHost((void**) &actuatorLine->bladeVelocitiesZH, sizeof(real)*actuatorLine->getNumberOfNodes()) ); + + checkCudaErrors( cudaMalloc((void**) &actuatorLine->bladeVelocitiesXD, sizeof(real)*actuatorLine->getNumberOfNodes()) ); + checkCudaErrors( cudaMalloc((void**) &actuatorLine->bladeVelocitiesYD, sizeof(real)*actuatorLine->getNumberOfNodes()) ); + checkCudaErrors( cudaMalloc((void**) &actuatorLine->bladeVelocitiesZD, sizeof(real)*actuatorLine->getNumberOfNodes()) ); + + setMemsizeGPU(3.*sizeof(real)*actuatorLine->getNumberOfNodes(), false); +} + +void CudaMemoryManager::cudaCopyBladeVelocitiesHtoD(ActuatorLine* actuatorLine) +{ + checkCudaErrors( cudaMemcpy(actuatorLine->bladeVelocitiesXD, actuatorLine->bladeVelocitiesXH, sizeof(real)*actuatorLine->getNumberOfNodes(), cudaMemcpyHostToDevice) ); + checkCudaErrors( cudaMemcpy(actuatorLine->bladeVelocitiesYD, actuatorLine->bladeVelocitiesYH, sizeof(real)*actuatorLine->getNumberOfNodes(), cudaMemcpyHostToDevice) ); + checkCudaErrors( cudaMemcpy(actuatorLine->bladeVelocitiesZD, actuatorLine->bladeVelocitiesZH, sizeof(real)*actuatorLine->getNumberOfNodes(), cudaMemcpyHostToDevice) ); +} + +void CudaMemoryManager::cudaCopyBladeVelocitiesDtoH(ActuatorLine* actuatorLine) +{ + checkCudaErrors( cudaMemcpy(actuatorLine->bladeVelocitiesXH, actuatorLine->bladeVelocitiesXD, sizeof(real)*actuatorLine->getNumberOfNodes(), cudaMemcpyDeviceToHost) ); + checkCudaErrors( cudaMemcpy(actuatorLine->bladeVelocitiesYH, actuatorLine->bladeVelocitiesYD, sizeof(real)*actuatorLine->getNumberOfNodes(), cudaMemcpyDeviceToHost) ); + checkCudaErrors( cudaMemcpy(actuatorLine->bladeVelocitiesZH, actuatorLine->bladeVelocitiesZD, sizeof(real)*actuatorLine->getNumberOfNodes(), 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->getNumberOfNodes()) ); + checkCudaErrors( cudaMallocHost((void**) &actuatorLine->bladeForcesYH, sizeof(real)*actuatorLine->getNumberOfNodes()) ); + checkCudaErrors( cudaMallocHost((void**) &actuatorLine->bladeForcesZH, sizeof(real)*actuatorLine->getNumberOfNodes()) ); + + checkCudaErrors( cudaMalloc((void**) &actuatorLine->bladeForcesXD, sizeof(real)*actuatorLine->getNumberOfNodes()) ); + checkCudaErrors( cudaMalloc((void**) &actuatorLine->bladeForcesYD, sizeof(real)*actuatorLine->getNumberOfNodes()) ); + checkCudaErrors( cudaMalloc((void**) &actuatorLine->bladeForcesZD, sizeof(real)*actuatorLine->getNumberOfNodes()) ); + + setMemsizeGPU(3.*sizeof(real)*actuatorLine->getNumberOfNodes(), false); +} + +void CudaMemoryManager::cudaCopyBladeForcesHtoD(ActuatorLine* actuatorLine) +{ + checkCudaErrors( cudaMemcpy(actuatorLine->bladeForcesXD, actuatorLine->bladeForcesXH, sizeof(real)*actuatorLine->getNumberOfNodes(), cudaMemcpyHostToDevice) ); + checkCudaErrors( cudaMemcpy(actuatorLine->bladeForcesYD, actuatorLine->bladeForcesYH, sizeof(real)*actuatorLine->getNumberOfNodes(), cudaMemcpyHostToDevice) ); + checkCudaErrors( cudaMemcpy(actuatorLine->bladeForcesZD, actuatorLine->bladeForcesZH, sizeof(real)*actuatorLine->getNumberOfNodes(), cudaMemcpyHostToDevice) ); +} + +void CudaMemoryManager::cudaCopyBladeForcesDtoH(ActuatorLine* actuatorLine) +{ + checkCudaErrors( cudaMemcpy(actuatorLine->bladeForcesXH, actuatorLine->bladeForcesXD, sizeof(real)*actuatorLine->getNumberOfNodes(), cudaMemcpyDeviceToHost) ); + checkCudaErrors( cudaMemcpy(actuatorLine->bladeForcesYH, actuatorLine->bladeForcesYD, sizeof(real)*actuatorLine->getNumberOfNodes(), cudaMemcpyDeviceToHost) ); + checkCudaErrors( cudaMemcpy(actuatorLine->bladeForcesZH, actuatorLine->bladeForcesZD, sizeof(real)*actuatorLine->getNumberOfNodes(), 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->getNumberOfIndices())); + checkCudaErrors( cudaMalloc((void**) &(actuatorLine->boundingSphereIndicesD), sizeof(int)*actuatorLine->getNumberOfIndices())); + setMemsizeGPU(sizeof(int)*actuatorLine->getNumberOfIndices(), false); +} + +void CudaMemoryManager::cudaCopySphereIndicesHtoD(ActuatorLine* actuatorLine) +{ + checkCudaErrors( cudaMemcpy(actuatorLine->boundingSphereIndicesD, actuatorLine->boundingSphereIndicesH, sizeof(int)*actuatorLine->getNumberOfIndices(), 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)->nPoints; + 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)->nPoints, cudaMemcpyHostToDevice) ); +} +void CudaMemoryManager::cudaCopyProbeIndicesDtoH(Probe* probe, int level) +{ + checkCudaErrors( cudaMemcpy(probe->getProbeStruct(level)->pointIndicesH, probe->getProbeStruct(level)->pointIndicesD, sizeof(int)*probe->getProbeStruct(level)->nPoints, 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) ); + 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) ); + checkCudaErrors( cudaFree (probe->getProbeStruct(level)->quantitiesArrayD) ); +} + +void CudaMemoryManager::cudaAllocProbeQuantitiesAndOffsets(Probe* probe, int level) +{ + size_t tmpA = int(PostProcessingVariable::LAST)*sizeof(int); + size_t tmpQ = int(PostProcessingVariable::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(PostProcessingVariable::LAST)*sizeof(bool), cudaMemcpyHostToDevice) ); + checkCudaErrors( cudaMemcpy(probe->getProbeStruct(level)->arrayOffsetsD, probe->getProbeStruct(level)->arrayOffsetsH, int(PostProcessingVariable::LAST)*sizeof(int), cudaMemcpyHostToDevice) ); +} + +void CudaMemoryManager::cudaCopyProbeQuantitiesAndOffsetsDtoH(Probe* probe, int level) +{ + checkCudaErrors( cudaMemcpy(probe->getProbeStruct(level)->quantitiesH, probe->getProbeStruct(level)->quantitiesD, int(PostProcessingVariable::LAST)*sizeof(bool), cudaMemcpyDeviceToHost) ); + checkCudaErrors( cudaMemcpy(probe->getProbeStruct(level)->arrayOffsetsH, probe->getProbeStruct(level)->arrayOffsetsD, int(PostProcessingVariable::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) ); +} diff --git a/src/gpu/VirtualFluids_GPU/GPU/CudaMemoryManager.h b/src/gpu/VirtualFluids_GPU/GPU/CudaMemoryManager.h index f96b93ba39ed9c37efa7922373d91d30f0cb5eb8..1d1311bf18da4538b323a99a0c8a4c341dda5e62 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 { @@ -78,6 +80,10 @@ public: void cudaCopyForcingToHost(); void cudaFreeForcing(); + void cudaAllocLevelForcing(int level); + void cudaCopyLevelForcingToDevice(int level); + void cudaFreeLevelForcing(int level); + void cudaAllocQuadricLimiters(); void cudaCopyQuadricLimitersToDevice(); void cudaFreeQuadricLimiters(); @@ -135,6 +141,9 @@ public: void cudaAllocMedianOut(int lev); void cudaFreeMedianOut(int lev); + + void cudaAllocMedianOutAD(int lev); + void cudaFreeMedianOutAD(int lev); void cudaAllocInterfaceCF(int lev); void cudaCopyInterfaceCF(int lev); @@ -315,13 +324,54 @@ public: void cudaCopyProcessNeighborADZIndex(int lev, unsigned int processNeighbor); void cudaFreeProcessNeighborADZ(int lev, unsigned int processNeighbor); - - - - - - - + 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&); diff --git a/src/gpu/VirtualFluids_GPU/GPU/Cumulant27.cu b/src/gpu/VirtualFluids_GPU/GPU/Cumulant27.cu index 0da46c500c13a0ef8f3d48bf74a3eee272c530b6..14c9b77ed2236ea517062944e37297747c5c3718 100644 --- a/src/gpu/VirtualFluids_GPU/GPU/Cumulant27.cu +++ b/src/gpu/VirtualFluids_GPU/GPU/Cumulant27.cu @@ -8,7 +8,9 @@ /* Device code */ #include "LBM/LB.h" #include "LBM/D3Q27.h" -#include "Core/RealConstants.h" +#include <lbm/constants/NumericConstants.h> + +using namespace vf::lbm::constant; #include "math.h" //////////////////////////////////////////////////////////////////////////////// diff --git a/src/gpu/VirtualFluids_GPU/GPU/Cumulant27chim.cu b/src/gpu/VirtualFluids_GPU/GPU/Cumulant27chim.cu index b6d77f648e81c73b6ee472b62e18f7b98c83676e..9dc75cfa6019a29350263f9a554aa9a489566cfa 100644 --- a/src/gpu/VirtualFluids_GPU/GPU/Cumulant27chim.cu +++ b/src/gpu/VirtualFluids_GPU/GPU/Cumulant27chim.cu @@ -1,961 +1,919 @@ -// _ ___ __ __________ _ __ ______________ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ / ___/ __ / / / / -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ / /___/ /_/ / / / / -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) / /_) / ____/ /__/ / -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ \____/_/ \_____/ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ // -////////////////////////////////////////////////////////////////////////// +// 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 Cumulant27chim.cu +//! \ingroup GPU +//! \author Martin Schoenherr +//======================================================================================= /* Device code */ #include "LBM/LB.h" #include "LBM/D3Q27.h" -#include "Core/RealConstants.h" -#include "math.h" - - -//////////////////////////////////////////////////////////////////////////////// -inline __device__ void forwardInverseChimeraWithK(real &mfa, real &mfb, real &mfc, real vv, real v2, real Kinverse, real K) { - real m2 = mfa + mfc; - real m1 = mfc - mfa; - real m0 = m2 + mfb; - mfa = m0; - m0 *= Kinverse; - m0 += c1o1; - mfb = (m1*Kinverse - m0 * vv) * K; - mfc = ((m2 - c2o1* m1 * vv)*Kinverse + v2 * m0) * K; -} - -inline __device__ void backwardInverseChimeraWithK(real &mfa, real &mfb, real &mfc, real vv, real v2, real Kinverse, real K) { - real m0 = (((mfc - mfb) * c1o2 + mfb * vv)*Kinverse + (mfa*Kinverse + c1o1) * (v2 - vv) * c1o2) * K; - real m1 = (((mfa - mfc) - c2o1 * mfb * vv)*Kinverse + (mfa*Kinverse + c1o1) * ( -v2)) * K; - mfc = (((mfc + mfb) * c1o2 + mfb * vv)*Kinverse + (mfa*Kinverse + c1o1) * (v2 + vv) * c1o2) * K; - mfa = m0; - mfb = m1; -} -//////////////////////////////////////////////////////////////////////////////// - - - - - -inline __device__ void forwardChimeraWithK(real &mfa, real &mfb, real &mfc, real vv, real v2, real K) { - - real m2 = mfa + mfc; - real m1 = mfc - mfa; - real m0 = m2 + mfb; - mfa = m0; - //m0 += K; - mfb = (m1 - K*vv) - m0 * vv; - mfc = ((m2 - c2o1* m1 * vv) + v2*K) + v2 * m0; - //m0 += K; - //mfb = m1 - m0 * vv; - //mfc = m2 - two* m1 * vv + v2 * m0; -} - -inline __device__ void forwardChimera(real &mfa, real &mfb, real &mfc, real vv, real v2) { - real m1 = (mfa + mfc) + mfb; - real m2 = mfc - mfa; - mfc = (mfc + mfa) + (v2*m1 - c2o1*vv*m2); - mfb = m2 - vv*m1; - mfa = m1; -} - - -inline __device__ void backwardChimera(real &mfa, real &mfb, real &mfc, real vv, real v2) { - real ma = (mfc + mfa*(v2 - vv))*c1o2 + mfb*(vv - c1o2); - real mb = ((mfa - mfc) - mfa*v2) - c2o1*mfb*vv; - mfc = (mfc + mfa*(v2 + vv))*c1o2 + mfb*(vv + c1o2); - mfb = mb; - mfa = ma; -} - - -inline __device__ void backwardChimeraWithK(real &mfa, real &mfb, real &mfc, real vv, real v2, real K) { - real m0 = (mfc - mfb)* c1o2 + mfb * (vv)+(mfa + K) * (v2 - vv) * c1o2; - real m1 = (mfa - mfc) - c2o1* mfb * vv + (mfa + K) * (-v2); - mfc = (mfc + mfb)* c1o2 + mfb * (vv)+(mfa + K) * (v2 + vv) * c1o2; - mfa = m0; - mfb = m1; - -} - - +#include <lbm/constants/NumericConstants.h> +using namespace vf::lbm::constant; +#include "math.h" +#include <lbm/Chimera.h> //////////////////////////////////////////////////////////////////////////////// extern "C" __global__ void Cumulant_One_preconditioned_errorDiffusion_chim_Comp_SP_27( - real omega, - unsigned int* bcMatD, - unsigned int* neighborX, - unsigned int* neighborY, - unsigned int* neighborZ, - real* DDStart, - int size_Mat, - int level, - real* forces, - bool EvenOrOdd) + real omega, + unsigned int* bcMatD, + unsigned int* neighborX, + unsigned int* neighborY, + unsigned int* neighborZ, + real* DDStart, + int size_Mat, + int level, + real* forces, + bool EvenOrOdd) { - //////////////////////////////////////////////////////////////////////////////// - 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<size_Mat) - { - //////////////////////////////////////////////////////////////////////////////// - unsigned int BC; - BC = bcMatD[k]; - - if (BC >= GEO_FLUID/*(BC != GEO_SOLID) && (BC != GEO_VOID)*/) - { - Distributions27 D; - if (EvenOrOdd == true) - { - D.f[dirE] = &DDStart[dirE *size_Mat]; - D.f[dirW] = &DDStart[dirW *size_Mat]; - D.f[dirN] = &DDStart[dirN *size_Mat]; - D.f[dirS] = &DDStart[dirS *size_Mat]; - D.f[dirT] = &DDStart[dirT *size_Mat]; - D.f[dirB] = &DDStart[dirB *size_Mat]; - D.f[dirNE] = &DDStart[dirNE *size_Mat]; - D.f[dirSW] = &DDStart[dirSW *size_Mat]; - D.f[dirSE] = &DDStart[dirSE *size_Mat]; - D.f[dirNW] = &DDStart[dirNW *size_Mat]; - D.f[dirTE] = &DDStart[dirTE *size_Mat]; - D.f[dirBW] = &DDStart[dirBW *size_Mat]; - D.f[dirBE] = &DDStart[dirBE *size_Mat]; - D.f[dirTW] = &DDStart[dirTW *size_Mat]; - D.f[dirTN] = &DDStart[dirTN *size_Mat]; - D.f[dirBS] = &DDStart[dirBS *size_Mat]; - D.f[dirBN] = &DDStart[dirBN *size_Mat]; - D.f[dirTS] = &DDStart[dirTS *size_Mat]; - D.f[dirZERO] = &DDStart[dirZERO*size_Mat]; - D.f[dirTNE] = &DDStart[dirTNE *size_Mat]; - D.f[dirTSW] = &DDStart[dirTSW *size_Mat]; - D.f[dirTSE] = &DDStart[dirTSE *size_Mat]; - D.f[dirTNW] = &DDStart[dirTNW *size_Mat]; - D.f[dirBNE] = &DDStart[dirBNE *size_Mat]; - D.f[dirBSW] = &DDStart[dirBSW *size_Mat]; - D.f[dirBSE] = &DDStart[dirBSE *size_Mat]; - D.f[dirBNW] = &DDStart[dirBNW *size_Mat]; - } - else - { - D.f[dirW] = &DDStart[dirE *size_Mat]; - D.f[dirE] = &DDStart[dirW *size_Mat]; - D.f[dirS] = &DDStart[dirN *size_Mat]; - D.f[dirN] = &DDStart[dirS *size_Mat]; - D.f[dirB] = &DDStart[dirT *size_Mat]; - D.f[dirT] = &DDStart[dirB *size_Mat]; - D.f[dirSW] = &DDStart[dirNE *size_Mat]; - D.f[dirNE] = &DDStart[dirSW *size_Mat]; - D.f[dirNW] = &DDStart[dirSE *size_Mat]; - D.f[dirSE] = &DDStart[dirNW *size_Mat]; - D.f[dirBW] = &DDStart[dirTE *size_Mat]; - D.f[dirTE] = &DDStart[dirBW *size_Mat]; - D.f[dirTW] = &DDStart[dirBE *size_Mat]; - D.f[dirBE] = &DDStart[dirTW *size_Mat]; - D.f[dirBS] = &DDStart[dirTN *size_Mat]; - D.f[dirTN] = &DDStart[dirBS *size_Mat]; - D.f[dirTS] = &DDStart[dirBN *size_Mat]; - D.f[dirBN] = &DDStart[dirTS *size_Mat]; - D.f[dirZERO] = &DDStart[dirZERO*size_Mat]; - D.f[dirBSW] = &DDStart[dirTNE *size_Mat]; - D.f[dirBNE] = &DDStart[dirTSW *size_Mat]; - D.f[dirBNW] = &DDStart[dirTSE *size_Mat]; - D.f[dirBSE] = &DDStart[dirTNW *size_Mat]; - D.f[dirTSW] = &DDStart[dirBNE *size_Mat]; - D.f[dirTNE] = &DDStart[dirBSW *size_Mat]; - D.f[dirTNW] = &DDStart[dirBSE *size_Mat]; - D.f[dirTSE] = &DDStart[dirBNW *size_Mat]; - } - - //////////////////////////////////////////////////////////////////////////////// - //index - //unsigned int kzero= k; - //unsigned int ke = k; - unsigned int kw = neighborX[k]; - //unsigned int kn = k; - unsigned int ks = neighborY[k]; - //unsigned int kt = k; - unsigned int kb = neighborZ[k]; - unsigned int ksw = neighborY[kw]; - //unsigned int kne = k; - //unsigned int kse = ks; - //unsigned int knw = kw; - unsigned int kbw = neighborZ[kw]; - //unsigned int kte = k; - //unsigned int kbe = kb; - //unsigned int ktw = kw; - unsigned int kbs = neighborZ[ks]; - //unsigned int ktn = k; - //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 = k; - unsigned int kbsw = neighborZ[ksw]; - - - - ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - real mfcbb = (D.f[dirE])[k];//[ke ];// + c2over27 ;(D.f[dirE ])[k ];//ke - real mfabb = (D.f[dirW])[kw];//[kw ];// + c2over27 ;(D.f[dirW ])[kw ]; - real mfbcb = (D.f[dirN])[k];//[kn ];// + c2over27 ;(D.f[dirN ])[k ];//kn - real mfbab = (D.f[dirS])[ks];//[ks ];// + c2over27 ;(D.f[dirS ])[ks ]; - real mfbbc = (D.f[dirT])[k];//[kt ];// + c2over27 ;(D.f[dirT ])[k ];//kt - real mfbba = (D.f[dirB])[kb];//[kb ];// + c2over27 ;(D.f[dirB ])[kb ]; - real mfccb = (D.f[dirNE])[k];//[kne ];// + c1over54 ;(D.f[dirNE ])[k ];//kne - real mfaab = (D.f[dirSW])[ksw];//[ksw ];// + c1over54 ;(D.f[dirSW ])[ksw]; - real mfcab = (D.f[dirSE])[ks];//[kse ];// + c1over54 ;(D.f[dirSE ])[ks ];//kse - real mfacb = (D.f[dirNW])[kw];//[knw ];// + c1over54 ;(D.f[dirNW ])[kw ];//knw - real mfcbc = (D.f[dirTE])[k];//[kte ];// + c1over54 ;(D.f[dirTE ])[k ];//kte - real mfaba = (D.f[dirBW])[kbw];//[kbw ];// + c1over54 ;(D.f[dirBW ])[kbw]; - real mfcba = (D.f[dirBE])[kb];//[kbe ];// + c1over54 ;(D.f[dirBE ])[kb ];//kbe - real mfabc = (D.f[dirTW])[kw];//[ktw ];// + c1over54 ;(D.f[dirTW ])[kw ];//ktw - real mfbcc = (D.f[dirTN])[k];//[ktn ];// + c1over54 ;(D.f[dirTN ])[k ];//ktn - real mfbaa = (D.f[dirBS])[kbs];//[kbs ];// + c1over54 ;(D.f[dirBS ])[kbs]; - real mfbca = (D.f[dirBN])[kb];//[kbn ];// + c1over54 ;(D.f[dirBN ])[kb ];//kbn - real mfbac = (D.f[dirTS])[ks];//[kts ];// + c1over54 ;(D.f[dirTS ])[ks ];//kts - real mfbbb = (D.f[dirZERO])[k];//[kzero];// + c8over27 ;(D.f[dirZERO])[k ];//kzero - real mfccc = (D.f[dirTNE])[k];//[ktne ];// + c1over216;(D.f[dirTNE ])[k ];//ktne - real mfaac = (D.f[dirTSW])[ksw];//[ktsw ];// + c1over216;(D.f[dirTSW ])[ksw];//ktsw - real mfcac = (D.f[dirTSE])[ks];//[ktse ];// + c1over216;(D.f[dirTSE ])[ks ];//ktse - real mfacc = (D.f[dirTNW])[kw];//[ktnw ];// + c1over216;(D.f[dirTNW ])[kw ];//ktnw - real mfcca = (D.f[dirBNE])[kb];//[kbne ];// + c1over216;(D.f[dirBNE ])[kb ];//kbne - real mfaaa = (D.f[dirBSW])[kbsw];//[kbsw ];// + c1over216;(D.f[dirBSW ])[kbsw]; - real mfcaa = (D.f[dirBSE])[kbs];//[kbse ];// + c1over216;(D.f[dirBSE ])[kbs];//kbse - real mfaca = (D.f[dirBNW])[kbw];//[kbnw ];// + c1over216;(D.f[dirBNW ])[kbw];//kbnw - //////////////////////////////////////////////////////////////////////////////////// - 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 rho = c1o1 + drho; - //////////////////////////////////////////////////////////////////////////////////// - real vvx = ((((mfccc - mfaaa) + (mfcac - mfaca)) + ((mfcaa - mfacc) + (mfcca - mfaac))) + - (((mfcba - mfabc) + (mfcbc - mfaba)) + ((mfcab - mfacb) + (mfccb - mfaab))) + - (mfcbb - mfabb)) / rho; - real vvy = ((((mfccc - mfaaa) + (mfaca - mfcac)) + ((mfacc - mfcaa) + (mfcca - mfaac))) + - (((mfbca - mfbac) + (mfbcc - mfbaa)) + ((mfacb - mfcab) + (mfccb - mfaab))) + - (mfbcb - mfbab)) / rho; - real vvz = ((((mfccc - mfaaa) + (mfcac - mfaca)) + ((mfacc - mfcaa) + (mfaac - mfcca))) + - (((mfbac - mfbca) + (mfbcc - mfbaa)) + ((mfabc - mfcba) + (mfcbc - mfaba))) + - (mfbbc - mfbba)) / rho; - //////////////////////////////////////////////////////////////////////////////////// - //the force be with you - real fx = forces[0] / (pow((double)c2o1, (double)level)); //zero;//0.0032653/(pow(two,level)); //0.000000005;//(two/1600000.0) / 120.0; // - real fy = forces[1] / (pow((double)c2o1, (double)level)); //zero; - real fz = forces[2] / (pow((double)c2o1, (double)level)); //zero; - vvx += fx*c1o2; - vvy += fy*c1o2; - vvz += fz*c1o2; - //////////////////////////////////////////////////////////////////////////////////// - //real omega = omega_in; - //////////////////////////////////////////////////////////////////////////////////// - //fast - //real oMdrho = c1o1; // comp special - //real m0, m1, m2; - real vx2; - real vy2; - real vz2; - vx2 = vvx*vvx; - vy2 = vvy*vvy; - vz2 = vvz*vvz; - //////////////////////////////////////////////////////////////////////////////////// - //real wadjust; - //real qudricLimitP = c1o100;// * 0.0001f; - //real qudricLimitM = c1o100;// * 0.0001f; - //real qudricLimitD = c1o100;// * 0.001f; - //real s9 = minusomega; - //test - //s9 = 0.; - - - ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - real EQcbb = c0o1; - real EQabb = c0o1; - real EQbcb = c0o1; - real EQbab = c0o1; - real EQbbc = c0o1; - real EQbba = c0o1; - real EQccb = c0o1; - real EQaab = c0o1; - real EQcab = c0o1; - real EQacb = c0o1; - real EQcbc = c0o1; - real EQaba = c0o1; - real EQcba = c0o1; - real EQabc = c0o1; - real EQbcc = c0o1; - real EQbaa = c0o1; - real EQbca = c0o1; - real EQbac = c0o1; - real EQbbb = c0o1; - real EQccc = drho * c1o27; - real EQaac = drho * c1o3; - real EQcac = drho * c1o9; - real EQacc = drho * c1o9; - real EQcca = drho * c1o9; - real EQaaa = drho; - real EQcaa = drho * c1o3; - real EQaca = drho * c1o3; - //////////////////////////////////////////////////////////////////////////////////// - backwardChimeraWithK(EQaaa, EQaab, EQaac, vvz, vz2, c1o1); - backwardChimeraWithK(EQaca, EQacb, EQacc, vvz, vz2, c1o3); - /////////////////////////////////////////////////////////// - EQcaa = EQaca; EQcab = EQacb; EQcac = EQacc; - /////////////////////////////////////////////////////////// - backwardChimeraWithK(EQcca, EQccb, EQccc, vvz, vz2, c1o9); - - backwardChimeraWithK(EQaaa, EQaba, EQaca, vvy, vy2, c1o6); - backwardChimeraWithK(EQaab, EQabb, EQacb, vvy, vy2, c2o3); - backwardChimeraWithK(EQaac, EQabc, EQacc, vvy, vy2, c1o6); - backwardChimeraWithK(EQcaa, EQcba, EQcca, vvy, vy2, c1o18); - backwardChimeraWithK(EQcab, EQcbb, EQccb, vvy, vy2, c2o9); - backwardChimeraWithK(EQcac, EQcbc, EQccc, vvy, vy2, c1o18); - - backwardChimeraWithK(EQaaa, EQbaa, EQcaa, vvx, vx2, c1o36); - backwardChimeraWithK(EQaab, EQbab, EQcab, vvx, vx2, c1o9); - backwardChimeraWithK(EQaac, EQbac, EQcac, vvx, vx2, c1o36); - backwardChimeraWithK(EQaba, EQbba, EQcba, vvx, vx2, c1o9); - backwardChimeraWithK(EQabb, EQbbb, EQcbb, vvx, vx2, c4o9); - backwardChimeraWithK(EQabc, EQbbc, EQcbc, vvx, vx2, c1o9); - backwardChimeraWithK(EQaca, EQbca, EQcca, vvx, vx2, c1o36); - backwardChimeraWithK(EQacb, EQbcb, EQccb, vvx, vx2, c1o9); - backwardChimeraWithK(EQacc, EQbcc, EQccc, vvx, vx2, c1o36); - - //////////////////////////////////////////////////////////////////////////////////// - //Pre-condition - mfcbb -= EQcbb; - mfabb -= EQabb; - mfbcb -= EQbcb; - mfbab -= EQbab; - mfbbc -= EQbbc; - mfbba -= EQbba; - mfccb -= EQccb; - mfaab -= EQaab; - mfcab -= EQcab; - mfacb -= EQacb; - mfcbc -= EQcbc; - mfaba -= EQaba; - mfcba -= EQcba; - mfabc -= EQabc; - mfbcc -= EQbcc; - mfbaa -= EQbaa; - mfbca -= EQbca; - mfbac -= EQbac; - mfbbb -= EQbbb; - mfccc -= EQccc; - mfaac -= EQaac; - mfcac -= EQcac; - mfacc -= EQacc; - mfcca -= EQcca; - mfaaa -= EQaaa; - mfcaa -= EQcaa; - mfaca -= EQaca; - - //////////////////////////////////////////////////////////////////////////////////// - //Hin - //////////////////////////////////////////////////////////////////////////////////// - forwardChimera(mfaaa, mfaab, mfaac, vvz, vz2); - forwardChimera(mfaba, mfabb, mfabc, vvz, vz2); - forwardChimera(mfaca, mfacb, mfacc, vvz, vz2); - forwardChimera(mfbaa, mfbab, mfbac, vvz, vz2); - forwardChimera(mfbba, mfbbb, mfbbc, vvz, vz2); - forwardChimera(mfbca, mfbcb, mfbcc, vvz, vz2); - forwardChimera(mfcaa, mfcab, mfcac, vvz, vz2); - forwardChimera(mfcba, mfcbb, mfcbc, vvz, vz2); - forwardChimera(mfcca, mfccb, mfccc, vvz, vz2); - - forwardChimera(mfaaa, mfaba, mfaca, vvy, vy2); - forwardChimera(mfaab, mfabb, mfacb, vvy, vy2); - forwardChimera(mfaac, mfabc, mfacc, vvy, vy2); - forwardChimera(mfbaa, mfbba, mfbca, vvy, vy2); - forwardChimera(mfbab, mfbbb, mfbcb, vvy, vy2); - forwardChimera(mfbac, mfbbc, mfbcc, vvy, vy2); - forwardChimera(mfcaa, mfcba, mfcca, vvy, vy2); - forwardChimera(mfcab, mfcbb, mfccb, vvy, vy2); - forwardChimera(mfcac, mfcbc, mfccc, vvy, vy2); - - forwardChimera(mfaaa, mfbaa, mfcaa, vvx, vx2); - forwardChimera(mfaab, mfbab, mfcab, vvx, vx2); - forwardChimera(mfaac, mfbac, mfcac, vvx, vx2); - forwardChimera(mfaba, mfbba, mfcba, vvx, vx2); - forwardChimera(mfabb, mfbbb, mfcbb, vvx, vx2); - forwardChimera(mfabc, mfbbc, mfcbc, vvx, vx2); - forwardChimera(mfaca, mfbca, mfcca, vvx, vx2); - forwardChimera(mfacb, mfbcb, mfccb, vvx, vx2); - forwardChimera(mfacc, mfbcc, mfccc, vvx, vx2); - - ////////////////////////////////////////////////////////////////////////////////////// - ////Hin - ////////////////////////////////////////////////////////////////////////////////////// - //// mit 1/36, 1/9, 1/36, 1/9, 4/9, 1/9, 1/36, 1/9, 1/36 Konditionieren - ////////////////////////////////////////////////////////////////////////////////////// - //// Z - Dir - //forwardChimeraWithK(mfaaa, mfaab, mfaac, vvz, vz2, c1o36); - ////////////////////////////////////////////////////////////////////////////////////// - //forwardChimeraWithK(mfaba, mfabb, mfabc, vvz, vz2, c1o9); - ////////////////////////////////////////////////////////////////////////////////////// - //forwardChimeraWithK(mfaca, mfacb, mfacc, vvz, vz2, c1o36); - ////////////////////////////////////////////////////////////////////////////////////// - ////////////////////////////////////////////////////////////////////////////////////// - //forwardChimeraWithK(mfbaa, mfbab, mfbac, vvz, vz2, c1o9); - ////////////////////////////////////////////////////////////////////////////////////// - //forwardChimeraWithK(mfbba, mfbbb, mfbbc, vvz, vz2, c4o9); - ////////////////////////////////////////////////////////////////////////////////////// - //forwardChimeraWithK(mfbca, mfbcb, mfbcc, vvz, vz2, c1o9); - ////////////////////////////////////////////////////////////////////////////////////// - ////////////////////////////////////////////////////////////////////////////////////// - //forwardChimeraWithK(mfcaa, mfcab, mfcac, vvz, vz2, c1o36); - ////////////////////////////////////////////////////////////////////////////////////// - //forwardChimeraWithK(mfcba, mfcbb, mfcbc, vvz, vz2, c1o9); - ////////////////////////////////////////////////////////////////////////////////////// - //forwardChimeraWithK(mfcca, mfccb, mfccc, vvz, vz2, c1o36); - ////////////////////////////////////////////////////////////////////////////////////// - ////////////////////////////////////////////////////////////////////////////////////// - //// mit 1/6, 0, 1/18, 2/3, 0, 2/9, 1/6, 0, 1/18 Konditionieren - ////////////////////////////////////////////////////////////////////////////////////// - //// Y - Dir - //forwardChimeraWithK(mfaaa, mfaba, mfaca, vvy, vy2, c1o6); - ////////////////////////////////////////////////////////////////////////////////////// - //forwardChimera(mfaab, mfabb, mfacb, vvy, vy2); - ////////////////////////////////////////////////////////////////////////////////////// - //forwardChimeraWithK(mfaac, mfabc, mfacc, vvy, vy2, c1o18); - ////////////////////////////////////////////////////////////////////////////////////// - ////////////////////////////////////////////////////////////////////////////////////// - //forwardChimeraWithK(mfbaa, mfbba, mfbca, vvy, vy2, c2o3); - ////////////////////////////////////////////////////////////////////////////////////// - //forwardChimera(mfbab, mfbbb, mfbcb, vvy, vy2); - ////////////////////////////////////////////////////////////////////////////////////// - //forwardChimeraWithK(mfbac, mfbbc, mfbcc, vvy, vy2, c2o9); - ////////////////////////////////////////////////////////////////////////////////////// - ////////////////////////////////////////////////////////////////////////////////////// - //forwardChimeraWithK(mfcaa, mfcba, mfcca, vvy, vy2, c1o6); - ////////////////////////////////////////////////////////////////////////////////////// - //forwardChimera(mfcab, mfcbb, mfccb, vvy, vy2); - ////////////////////////////////////////////////////////////////////////////////////// - //forwardChimeraWithK(mfcac, mfcbc, mfccc, vvy, vy2, c1o18); - ////////////////////////////////////////////////////////////////////////////////////// - ////////////////////////////////////////////////////////////////////////////////////// - //// mit 1, 0, 1/3, 0, 0, 0, 1/3, 0, 1/9 Konditionieren - ////////////////////////////////////////////////////////////////////////////////////// - //// X - Dir - //forwardChimeraWithK(mfaaa, mfbaa, mfcaa, vvx, vx2, one); - ////////////////////////////////////////////////////////////////////////////////////// - //forwardChimera(mfaba, mfbba, mfcba, vvx, vx2); - ////////////////////////////////////////////////////////////////////////////////////// - //forwardChimeraWithK(mfaca, mfbca, mfcca, vvx, vx2, c1o3); - ////////////////////////////////////////////////////////////////////////////////////// - ////////////////////////////////////////////////////////////////////////////////////// - //forwardChimera(mfaab, mfbab, mfcab, vvx, vx2); - ////////////////////////////////////////////////////////////////////////////////////// - //forwardChimera(mfabb, mfbbb, mfcbb, vvx, vx2); - ////////////////////////////////////////////////////////////////////////////////////// - //forwardChimera(mfacb, mfbcb, mfccb, vvx, vx2); - ////////////////////////////////////////////////////////////////////////////////////// - ////////////////////////////////////////////////////////////////////////////////////// - //forwardChimeraWithK(mfaac, mfbac, mfcac, vvx, vx2, c1o3); - ////////////////////////////////////////////////////////////////////////////////////// - //forwardChimera(mfabc, mfbbc, mfcbc, vvx, vx2); - ////////////////////////////////////////////////////////////////////////////////////// - //forwardChimeraWithK(mfacc, mfbcc, mfccc, vvx, vx2, c1o9); - ////////////////////////////////////////////////////////////////////////////////////// - ////////////////////////////////////////////////////////////////////////////////////// - - - //////////////////////////////////////////////////////////////////////////////////// - // Cumulants - //////////////////////////////////////////////////////////////////////////////////// - real OxxPyyPzz = c1o1; //omega; // one; //set the bulk viscosity one is high / two is very low and zero is (too) high - - //////////////////////////////////////////////////////////// - //3. - ////////////////////////////// - real OxyyPxzz = c1o1; - real OxyyMxzz = c1o1; - //real Oxyz = c1o1; - //////////////////////////////////////////////////////////// - //4. - ////////////////////////////// - real O4 = c1o1; - //////////////////////////////////////////////////////////// - //5. - ////////////////////////////// - real O5 = c1o1; - //////////////////////////////////////////////////////////// - //6. - ////////////////////////////// - real O6 = c1o1; - //////////////////////////////////////////////////////////// - - - //central moments to cumulants - //4. - real CUMcbb = mfcbb - ((mfcaa + c1o3) * mfabb + c2o1 * mfbba * mfbab) / rho; - real CUMbcb = mfbcb - ((mfaca + c1o3) * mfbab + c2o1 * mfbba * mfabb) / rho; - real CUMbbc = mfbbc - ((mfaac + c1o3) * mfbba + c2o1 * mfbab * mfabb) / rho; - - real CUMcca = mfcca - (((mfcaa * mfaca + c2o1 * mfbba * mfbba) + c1o3 * (mfcaa + mfaca)) / rho - c1o9*(drho / rho)); - real CUMcac = mfcac - (((mfcaa * mfaac + c2o1 * mfbab * mfbab) + c1o3 * (mfcaa + mfaac)) / rho - c1o9*(drho / rho)); - real CUMacc = mfacc - (((mfaac * mfaca + c2o1 * mfabb * mfabb) + c1o3 * (mfaac + mfaca)) / rho - c1o9*(drho / rho)); - - //5. - real CUMbcc = mfbcc - ((mfaac * mfbca + mfaca * mfbac + c4o1 * mfabb * mfbbb + c2o1 * (mfbab * mfacb + mfbba * mfabc)) + c1o3 * (mfbca + mfbac)) / rho; - real CUMcbc = mfcbc - ((mfaac * mfcba + mfcaa * mfabc + c4o1 * mfbab * mfbbb + c2o1 * (mfabb * mfcab + mfbba * mfbac)) + c1o3 * (mfcba + mfabc)) / rho; - real CUMccb = mfccb - ((mfcaa * mfacb + mfaca * mfcab + c4o1 * mfbba * mfbbb + c2o1 * (mfbab * mfbca + mfabb * mfcba)) + c1o3 * (mfacb + mfcab)) / rho; - - //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)) / rho - + (c4o1 * (mfbab * mfbab * mfaca + mfabb * mfabb * mfcaa + mfbba * mfbba * mfaac) - + c2o1 * (mfcaa * mfaca * mfaac) - + c16o1 * mfbba * mfbab * mfabb) / (rho * rho) - - c1o3 * (mfacc + mfcac + mfcca) / rho - - c1o9 * (mfcaa + mfaca + mfaac) / rho - + (c2o1 * (mfbab * mfbab + mfabb * mfabb + mfbba * mfbba) - + (mfaac * mfaca + mfaac * mfcaa + mfaca * mfcaa) + c1o3 *(mfaac + mfaca + mfcaa)) / (rho * rho) * c2o3 - + c1o27*((drho * drho - drho) / (rho*rho))); - - - - - //2. - // linear combinations - real mxxPyyPzz = mfcaa + mfaca + mfaac; - real mxxMyy = mfcaa - mfaca; - real mxxMzz = mfcaa - mfaac; - - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //incl. correction (hat noch nicht so gut funktioniert...Optimierungsbedarf??) - { - real dxux = c1o2 * (-omega) *(mxxMyy + mxxMzz) + c1o2 * OxxPyyPzz * (mfaaa - mxxPyyPzz); - real dyuy = dxux + omega * c3o2 * mxxMyy; - real dzuz = dxux + omega * c3o2 * mxxMzz; - - //relax - mxxPyyPzz += OxxPyyPzz*(mfaaa - mxxPyyPzz) - c3o1 * (c1o1 - c1o2 * OxxPyyPzz) * (vx2 * dxux + vy2 * dyuy + vz2 * dzuz);//-magicBulk*OxxPyyPzz; - 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);//-magicBulk*OxxPyyPzz; - //mxxMyy += -(-omega) * (-mxxMyy); - //mxxMzz += -(-omega) * (-mxxMzz); - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - mfabb += omega * (-mfabb); - mfbab += omega * (-mfbab); - mfbba += omega * (-mfbba); - - ////////////////////////////////////////////////////////////////////////// - - // linear combinations back - mfcaa = c1o3 * (mxxMyy + mxxMzz + mxxPyyPzz); - mfaca = c1o3 * (-c2o1* mxxMyy + mxxMzz + mxxPyyPzz); - mfaac = c1o3 * (mxxMyy - c2o1* mxxMzz + mxxPyyPzz); - - //3. - // linear combinations - - real mxxyPyzz = mfcba + mfabc; - real mxxyMyzz = mfcba - mfabc; - - real mxxzPyyz = mfcab + mfacb; - real mxxzMyyz = mfcab - mfacb; - - real mxyyPxzz = mfbca + mfbac; - real mxyyMxzz = mfbca - mfbac; - - //relax - ////////////////////////////////////////////////////////////////////////// - mfbbb += OxyyMxzz * (-mfbbb); - mxxyPyzz += OxyyPxzz * (-mxxyPyzz); - mxxyMyzz += OxyyMxzz * (-mxxyMyzz); - mxxzPyyz += OxyyPxzz * (-mxxzPyyz); - mxxzMyyz += OxyyMxzz * (-mxxzMyyz); - mxyyPxzz += OxyyPxzz * (-mxyyPxzz); - mxyyMxzz += OxyyMxzz * (-mxyyMxzz); - ////////////////////////////////////////////////////////////////////////// - - 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. - ////////////////////////////////////////////////////////////////////////// - CUMacc += O4 * (-CUMacc); - CUMcac += O4 * (-CUMcac); - CUMcca += O4 * (-CUMcca); - - CUMbbc += O4 * (-CUMbbc); - CUMbcb += O4 * (-CUMbcb); - CUMcbb += O4 * (-CUMcbb); - ////////////////////////////////////////////////////////////////////////// - - - //5. - CUMbcc += O5 * (-CUMbcc); - CUMcbc += O5 * (-CUMcbc); - CUMccb += O5 * (-CUMccb); - - //6. - CUMccc += O6 * (-CUMccc); - - - - //back cumulants to central moments - //4. - mfcbb = CUMcbb + ((mfcaa + c1o3) * mfabb + c2o1 * mfbba * mfbab) / rho; - mfbcb = CUMbcb + ((mfaca + c1o3) * mfbab + c2o1 * mfbba * mfabb) / rho; - mfbbc = CUMbbc + ((mfaac + c1o3) * mfbba + c2o1 * mfbab * mfabb) / rho; - - mfcca = CUMcca + (((mfcaa * mfaca + c2o1 * mfbba * mfbba) + c1o3 * (mfcaa + mfaca)) / rho - c1o9*(drho / rho)); - mfcac = CUMcac + (((mfcaa * mfaac + c2o1 * mfbab * mfbab) + c1o3 * (mfcaa + mfaac)) / rho - c1o9*(drho / rho)); - mfacc = CUMacc + (((mfaac * mfaca + c2o1 * mfabb * mfabb) + c1o3 * (mfaac + mfaca)) / rho - c1o9*(drho / rho)); - - //5. - mfbcc = CUMbcc + ((mfaac * mfbca + mfaca * mfbac + c4o1 * mfabb * mfbbb + c2o1 * (mfbab * mfacb + mfbba * mfabc)) + c1o3 * (mfbca + mfbac)) / rho; - mfcbc = CUMcbc + ((mfaac * mfcba + mfcaa * mfabc + c4o1 * mfbab * mfbbb + c2o1 * (mfabb * mfcab + mfbba * mfbac)) + c1o3 * (mfcba + mfabc)) / rho; - mfccb = CUMccb + ((mfcaa * mfacb + mfaca * mfcab + c4o1 * mfbba * mfbbb + c2o1 * (mfbab * mfbca + mfabb * mfcba)) + c1o3 * (mfacb + mfcab)) / rho; - - //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)) / rho - + (c4o1 * (mfbab * mfbab * mfaca + mfabb * mfabb * mfcaa + mfbba * mfbba * mfaac) - + c2o1 * (mfcaa * mfaca * mfaac) - + c16o1 * mfbba * mfbab * mfabb) / (rho * rho) - - c1o3 * (mfacc + mfcac + mfcca) / rho - - c1o9 * (mfcaa + mfaca + mfaac) / rho - + (c2o1 * (mfbab * mfbab + mfabb * mfabb + mfbba * mfbba) - + (mfaac * mfaca + mfaac * mfcaa + mfaca * mfcaa) + c1o3 *(mfaac + mfaca + mfcaa)) / (rho * rho) * c2o3 - + c1o27*((drho * drho - drho) / (rho*rho))); - - //////////////////////////////////////////////////////////////////////////////////// - //the force be with you - mfbaa = -mfbaa; - mfaba = -mfaba; - mfaab = -mfaab; - //////////////////////////////////////////////////////////////////////////////////// - - - //////////////////////////////////////////////////////////////////////////////////// - //back - //////////////////////////////////////////////////////////////////////////////////// - backwardChimera(mfaaa, mfaab, mfaac, vvz, vz2); - backwardChimera(mfaba, mfabb, mfabc, vvz, vz2); - backwardChimera(mfaca, mfacb, mfacc, vvz, vz2); - backwardChimera(mfbaa, mfbab, mfbac, vvz, vz2); - backwardChimera(mfbba, mfbbb, mfbbc, vvz, vz2); - backwardChimera(mfbca, mfbcb, mfbcc, vvz, vz2); - backwardChimera(mfcaa, mfcab, mfcac, vvz, vz2); - backwardChimera(mfcba, mfcbb, mfcbc, vvz, vz2); - backwardChimera(mfcca, mfccb, mfccc, vvz, vz2); - - backwardChimera(mfaaa, mfaba, mfaca, vvy, vy2); - backwardChimera(mfaab, mfabb, mfacb, vvy, vy2); - backwardChimera(mfaac, mfabc, mfacc, vvy, vy2); - backwardChimera(mfbaa, mfbba, mfbca, vvy, vy2); - backwardChimera(mfbab, mfbbb, mfbcb, vvy, vy2); - backwardChimera(mfbac, mfbbc, mfbcc, vvy, vy2); - backwardChimera(mfcaa, mfcba, mfcca, vvy, vy2); - backwardChimera(mfcab, mfcbb, mfccb, vvy, vy2); - backwardChimera(mfcac, mfcbc, mfccc, vvy, vy2); - - backwardChimera(mfaaa, mfbaa, mfcaa, vvx, vx2); - backwardChimera(mfaab, mfbab, mfcab, vvx, vx2); - backwardChimera(mfaac, mfbac, mfcac, vvx, vx2); - backwardChimera(mfaba, mfbba, mfcba, vvx, vx2); - backwardChimera(mfabb, mfbbb, mfcbb, vvx, vx2); - backwardChimera(mfabc, mfbbc, mfcbc, vvx, vx2); - backwardChimera(mfaca, mfbca, mfcca, vvx, vx2); - backwardChimera(mfacb, mfbcb, mfccb, vvx, vx2); - backwardChimera(mfacc, mfbcc, mfccc, vvx, vx2); - - //////////////////////////////////////////////////////////////////////////////////// - //mfcbb += EQcbb; - //mfabb += EQabb; - //mfbcb += EQbcb; - //mfbab += EQbab; - //mfbbc += EQbbc; - //mfbba += EQbba; - //mfccb += EQccb; - //mfaab += EQaab; - //mfcab += EQcab; - //mfacb += EQacb; - //mfcbc += EQcbc; - //mfaba += EQaba; - //mfcba += EQcba; - //mfabc += EQabc; - //mfbcc += EQbcc; - //mfbaa += EQbaa; - //mfbca += EQbca; - //mfbac += EQbac; - //mfbbb += EQbbb; - //mfccc += EQccc; - //mfaac += EQaac; - //mfcac += EQcac; - //mfacc += EQacc; - //mfcca += EQcca; - //mfaaa += EQaaa; - //mfcaa += EQcaa; - //mfaca += EQaca; - //////////////////////////////////////////////////////////////////////////////////// - ////Error diffusion - real fTEMP = mfbbb + EQbbb; - real delta0 = mfbbb - (fTEMP - EQbbb); - delta0 *= c1o4; - mfbbb = fTEMP; - - - fTEMP = mfcbb + EQcbb; - real deltacbb = mfcbb - (fTEMP - EQcbb); - mfcbb = fTEMP; - //mfcbb+=EQcbb; - - fTEMP = mfabb + EQabb; - real deltaabb = mfabb - (fTEMP - EQabb); - mfabb = fTEMP; - //mfabb+=EQabb; - - fTEMP = mfbcb + EQbcb; - real deltabcb = mfbcb - (fTEMP - EQbcb); - mfbcb = fTEMP; - //mfbcb+=EQbcb; - - fTEMP = mfbab + EQbab; - real deltabab = mfbab - (fTEMP - EQbab); - mfbab = fTEMP; - //mfbab+=EQbab; - - fTEMP = mfbbc + EQbbc; - real deltabbc = mfbbc - (fTEMP - EQbbc); - mfbbc = fTEMP; - //mfbbc+=EQbbc; - - fTEMP = mfbba + EQbba; - real deltabba = mfbba - (fTEMP - EQbba); - mfbba = fTEMP; - //mfbba+=EQbba; - - EQccb += (delta0 + c1o2*(deltacbb + deltabcb)); - fTEMP = mfccb + EQccb; - real deltaccb = mfccb - (fTEMP - EQccb); - mfccb = fTEMP; - //mfccb+=EQccb+(delta0+c1o2*(deltacbb+deltabcb)); - - EQaab += (delta0 + c1o2*(deltaabb + deltabab)); - fTEMP = mfaab + EQaab; - real deltaaab = mfaab - (fTEMP - EQaab); - mfaab = fTEMP; - //mfaab+=EQaab+(delta0+c1o2*(deltaabb+deltabab)); - - EQcab += (delta0 + c1o2*(deltacbb + deltabab)); - fTEMP = mfcab + EQcab; - real deltacab = mfcab - (fTEMP - EQcab); - mfcab = fTEMP; - //mfcab+=EQcab+(delta0+c1o2*(deltacbb+deltabab)); - - EQacb += (delta0 + c1o2*(deltaabb + deltabcb)); - fTEMP = mfacb + EQacb; - real deltaacb = mfacb - (fTEMP - EQacb); - mfacb = fTEMP; - //mfacb+=EQacb+(delta0+c1o2*(deltaabb+deltabcb)); - - EQcbc += (delta0 + c1o2*(deltacbb + deltabbc)); - fTEMP = mfcbc + EQcbc; - real deltacbc = mfcbc - (fTEMP - EQcbc); - mfcbc = fTEMP; - //mfcbc+=EQcbc+(delta0+c1o2*(deltacbb+deltabbc)); - - EQaba += (delta0 + c1o2*(deltaabb + deltabba)); - fTEMP = mfaba + EQaba; - real deltaaba = mfaba - (fTEMP - EQaba); - mfaba = fTEMP; - //mfaba+=EQaba+(delta0+c1o2*(deltaabb+deltabba)); - - EQcba += (delta0 + c1o2*(deltacbb + deltabba)); - fTEMP = mfcba + EQcba; - real deltacba = mfcba - (fTEMP - EQcba); - mfcba = fTEMP; - //mfcba+=EQcba+(delta0+c1o2*(deltacbb+deltabba)); - - EQabc += (delta0 + c1o2*(deltaabb + deltabbc)); - fTEMP = mfabc + EQabc; - real deltaabc = mfabc - (fTEMP - EQabc); - mfabc = fTEMP; - //mfabc+=EQabc+(delta0+c1o2*(deltaabb+deltabbc)); - - EQbcc += (delta0 + c1o2*(deltabcb + deltabbc)); - fTEMP = mfbcc + EQbcc; - real deltabcc = mfbcc - (fTEMP - EQbcc); - mfbcc = fTEMP; - //mfbcc+=EQbcc+(delta0+c1o2*(deltabcb+deltabbc)); - - EQbaa += (delta0 + c1o2*(deltabab + deltabba)); - fTEMP = mfbaa + EQbaa; - real deltabaa = mfbaa - (fTEMP - EQbaa); - mfbaa = fTEMP; - //mfbaa+=EQbaa+(delta0+c1o2*(deltabab+deltabba)); - - EQbca += (delta0 + c1o2*(deltabcb + deltabba)); - fTEMP = mfbca + EQbca; - real deltabca = mfbca - (fTEMP - EQbca); - mfbca = fTEMP; - //mfbca+=EQbca+(delta0+c1o2*(deltabcb+deltabba)); - - EQbac += (delta0 + c1o2*(deltabab + deltabbc)); - fTEMP = mfbac + EQbac; - real deltabac = mfbac - (fTEMP - EQbac); - mfbac = fTEMP; - //mfbac+=EQbac+(delta0+c1o2*(deltabab+deltabbc)); - - mfccc += EQccc - (delta0 + c1o4*(deltacbb + deltabcb + deltabbc) - c1o2*(deltabcc + deltacbc + deltaccb)); - mfaac += EQaac - (delta0 + c1o4*(deltaabb + deltabab + deltabbc) - c1o2*(deltabac + deltaabc + deltaaab)); - mfcac += EQcac - (delta0 + c1o4*(deltacbb + deltabab + deltabbc) - c1o2*(deltabac + deltacbc + deltacab)); - mfacc += EQacc - (delta0 + c1o4*(deltaabb + deltabcb + deltabbc) - c1o2*(deltabcc + deltaabc + deltaacb)); - mfcca += EQcca - (delta0 + c1o4*(deltacbb + deltabcb + deltabba) - c1o2*(deltabca + deltacba + deltaccb)); - mfaaa += EQaaa - (delta0 + c1o4*(deltaabb + deltabab + deltabba) - c1o2*(deltabaa + deltaaba + deltaaab)); - mfcaa += EQcaa - (delta0 + c1o4*(deltacbb + deltabab + deltabba) - c1o2*(deltabaa + deltacba + deltacab)); - mfaca += EQaca - (delta0 + c1o4*(deltaabb + deltabcb + deltabba) - c1o2*(deltabca + deltaaba + deltaacb)); - - - - ////////////////////////////////////////////////////////////////////////////////////// - ////back - ////////////////////////////////////////////////////////////////////////////////////// - ////mit 1, 0, 1/3, 0, 0, 0, 1/3, 0, 1/9 Konditionieren - ////////////////////////////////////////////////////////////////////////////////////// - //// Z - Dir - //backwardChimeraWithK(mfaaa, mfaab, mfaac, vvz, vz2, one); - ////////////////////////////////////////////////////////////////////////////////////// - //backwardChimera(mfaba, mfabb, mfabc, vvz, vz2); - ////////////////////////////////////////////////////////////////////////////////////// - //backwardChimeraWithK(mfaca, mfacb, mfacc, vvz, vz2, c1o3); - ////////////////////////////////////////////////////////////////////////////////////// - ////////////////////////////////////////////////////////////////////////////////////// - //backwardChimera(mfbaa, mfbab, mfbac, vvz, vz2); - ///////////b////////////////////////////////////////////////////////////////////////// - //backwardChimera(mfbba, mfbbb, mfbbc, vvz, vz2); - ///////////b////////////////////////////////////////////////////////////////////////// - //backwardChimera(mfbca, mfbcb, mfbcc, vvz, vz2); - ////////////////////////////////////////////////////////////////////////////////////// - ////////////////////////////////////////////////////////////////////////////////////// - //backwardChimeraWithK(mfcaa, mfcab, mfcac, vvz, vz2, c1o3); - ///////////c////////////////////////////////////////////////////////////////////////// - //backwardChimera(mfcba, mfcbb, mfcbc, vvz, vz2); - ///////////c////////////////////////////////////////////////////////////////////////// - //backwardChimeraWithK(mfcca, mfccb, mfccc, vvz, vz2, c1o9); - ////////////////////////////////////////////////////////////////////////////////////// - ////////////////////////////////////////////////////////////////////////////////////// - ////mit 1/6, 2/3, 1/6, 0, 0, 0, 1/18, 2/9, 1/18 Konditionieren - ////////////////////////////////////////////////////////////////////////////////////// - //// Y - Dir - //backwardChimeraWithK(mfaaa, mfaba, mfaca, vvy, vy2, c1o6); - ////////////////////////////////////////////////////////////////////////////////////// - //backwardChimeraWithK(mfaab, mfabb, mfacb, vvy, vy2, c2o3); - ////////////////////////////////////////////////////////////////////////////////////// - //backwardChimeraWithK(mfaac, mfabc, mfacc, vvy, vy2, c1o6); - ////////////////////////////////////////////////////////////////////////////////////// - ////////////////////////////////////////////////////////////////////////////////////// - //backwardChimera(mfbaa, mfbba, mfbca, vvz, vz2); - ///////////b////////////////////////////////////////////////////////////////////////// - //backwardChimera(mfbab, mfbbb, mfbcb, vvz, vz2); - ///////////b////////////////////////////////////////////////////////////////////////// - //backwardChimera(mfbac, mfbbc, mfbcc, vvz, vz2); - ////////////////////////////////////////////////////////////////////////////////////// - ////////////////////////////////////////////////////////////////////////////////////// - //backwardChimeraWithK(mfcaa, mfcba, mfcca, vvy, vy2, c1o18); - ///////////c////////////////////////////////////////////////////////////////////////// - //backwardChimeraWithK(mfcab, mfcbb, mfccb, vvy, vy2, c2o9); - ///////////c////////////////////////////////////////////////////////////////////////// - //backwardChimeraWithK(mfcac, mfcbc, mfccc, vvy, vy2, c1o18); - ////////////////////////////////////////////////////////////////////////////////////// - ////////////////////////////////////////////////////////////////////////////////////// - ////mit 1/36, 1/9, 1/36, 1/9, 4/9, 1/9, 1/36, 1/9, 1/36 Konditionieren - ////////////////////////////////////////////////////////////////////////////////////// - //// X - Dir - //backwardChimeraWithK(mfaaa, mfbaa, mfcaa, vvx, vx2, c1o36); - ////////////////////////////////////////////////////////////////////////////////////// - //backwardChimeraWithK(mfaba, mfbba, mfcba, vvx, vx2, c1o9); - ////////////////////////////////////////////////////////////////////////////////////// - //backwardChimeraWithK(mfaca, mfbca, mfcca, vvx, vx2, c1o36); - ////////////////////////////////////////////////////////////////////////////////////// - ////////////////////////////////////////////////////////////////////////////////////// - //backwardChimeraWithK(mfaab, mfbab, mfcab, vvx, vx2, c1o9); - /////////////b//////////////////////////////////////////////////////////////////////// - //backwardChimeraWithK(mfabb, mfbbb, mfcbb, vvx, vx2, c4o9); - /////////////b//////////////////////////////////////////////////////////////////////// - //backwardChimeraWithK(mfacb, mfbcb, mfccb, vvx, vx2, c1o9); - ////////////////////////////////////////////////////////////////////////////////////// - ////////////////////////////////////////////////////////////////////////////////////// - //backwardChimeraWithK(mfaac, mfbac, mfcac, vvx, vx2, c1o36); - /////////////c//////////////////////////////////////////////////////////////////////// - //backwardChimeraWithK(mfabc, mfbbc, mfcbc, vvx, vx2, c1o9); - /////////////c//////////////////////////////////////////////////////////////////////// - //backwardChimeraWithK(mfacc, mfbcc, mfccc, vvx, vx2, c1o36); - ////////////////////////////////////////////////////////////////////////////////////// - - //////////////////////////////////////////////////////////////////////////////////////// - //real drhoPost = - // ((((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; - //mfbbb += drho - drhoPost; - //////////////////////////////////////////////////////////////////////////////////// - (D.f[dirE])[k] = mfabb;//(D.f[ dirE ])[ke ] = mfabb;// - c2over27 ; (D.f[ dirE ])[k ] - (D.f[dirW])[kw] = mfcbb;//(D.f[ dirW ])[kw ] = mfcbb;// - c2over27 ; (D.f[ dirW ])[kw ] - (D.f[dirN])[k] = mfbab;//(D.f[ dirN ])[kn ] = mfbab;// - c2over27 ; (D.f[ dirN ])[k ] - (D.f[dirS])[ks] = mfbcb;//(D.f[ dirS ])[ks ] = mfbcb;// - c2over27 ; (D.f[ dirS ])[ks ] - (D.f[dirT])[k] = mfbba;//(D.f[ dirT ])[kt ] = mfbba;// - c2over27 ; (D.f[ dirT ])[k ] - (D.f[dirB])[kb] = mfbbc;//(D.f[ dirB ])[kb ] = mfbbc;// - c2over27 ; (D.f[ dirB ])[kb ] - (D.f[dirNE])[k] = mfaab;//(D.f[ dirNE ])[kne ] = mfaab;// - c1over54 ; (D.f[ dirNE ])[k ] - (D.f[dirSW])[ksw] = mfccb;//(D.f[ dirSW ])[ksw ] = mfccb;// - c1over54 ; (D.f[ dirSW ])[ksw ] - (D.f[dirSE])[ks] = mfacb;//(D.f[ dirSE ])[kse ] = mfacb;// - c1over54 ; (D.f[ dirSE ])[ks ] - (D.f[dirNW])[kw] = mfcab;//(D.f[ dirNW ])[knw ] = mfcab;// - c1over54 ; (D.f[ dirNW ])[kw ] - (D.f[dirTE])[k] = mfaba;//(D.f[ dirTE ])[kte ] = mfaba;// - c1over54 ; (D.f[ dirTE ])[k ] - (D.f[dirBW])[kbw] = mfcbc;//(D.f[ dirBW ])[kbw ] = mfcbc;// - c1over54 ; (D.f[ dirBW ])[kbw ] - (D.f[dirBE])[kb] = mfabc;//(D.f[ dirBE ])[kbe ] = mfabc;// - c1over54 ; (D.f[ dirBE ])[kb ] - (D.f[dirTW])[kw] = mfcba;//(D.f[ dirTW ])[ktw ] = mfcba;// - c1over54 ; (D.f[ dirTW ])[kw ] - (D.f[dirTN])[k] = mfbaa;//(D.f[ dirTN ])[ktn ] = mfbaa;// - c1over54 ; (D.f[ dirTN ])[k ] - (D.f[dirBS])[kbs] = mfbcc;//(D.f[ dirBS ])[kbs ] = mfbcc;// - c1over54 ; (D.f[ dirBS ])[kbs ] - (D.f[dirBN])[kb] = mfbac;//(D.f[ dirBN ])[kbn ] = mfbac;// - c1over54 ; (D.f[ dirBN ])[kb ] - (D.f[dirTS])[ks] = mfbca;//(D.f[ dirTS ])[kts ] = mfbca;// - c1over54 ; (D.f[ dirTS ])[ks ] - (D.f[dirZERO])[k] = mfbbb;//(D.f[ dirZERO])[kzero] = mfbbb;// - c8over27 ; (D.f[ dirZERO])[k ] - (D.f[dirTNE])[k] = mfaaa;//(D.f[ dirTNE ])[ktne ] = mfaaa;// - c1over216; (D.f[ dirTNE ])[k ] - (D.f[dirTSE])[ks] = mfaca;//(D.f[ dirTSE ])[ktse ] = mfaca;// - c1over216; (D.f[ dirTSE ])[ks ] - (D.f[dirBNE])[kb] = mfaac;//(D.f[ dirBNE ])[kbne ] = mfaac;// - c1over216; (D.f[ dirBNE ])[kb ] - (D.f[dirBSE])[kbs] = mfacc;//(D.f[ dirBSE ])[kbse ] = mfacc;// - c1over216; (D.f[ dirBSE ])[kbs ] - (D.f[dirTNW])[kw] = mfcaa;//(D.f[ dirTNW ])[ktnw ] = mfcaa;// - c1over216; (D.f[ dirTNW ])[kw ] - (D.f[dirTSW])[ksw] = mfcca;//(D.f[ dirTSW ])[ktsw ] = mfcca;// - c1over216; (D.f[ dirTSW ])[ksw ] - (D.f[dirBNW])[kbw] = mfcac;//(D.f[ dirBNW ])[kbnw ] = mfcac;// - c1over216; (D.f[ dirBNW ])[kbw ] - (D.f[dirBSW])[kbsw] = mfccc;//(D.f[ dirBSW ])[kbsw ] = mfccc;// - c1over216; (D.f[ dirBSW ])[kbsw] - //////////////////////////////////////////////////////////////////////////////////// - } - } + //////////////////////////////////////////////////////////////////////////////// + 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<size_Mat) + { + //////////////////////////////////////////////////////////////////////////////// + unsigned int BC; + BC = bcMatD[k]; + + if (BC >= GEO_FLUID/*(BC != GEO_SOLID) && (BC != GEO_VOID)*/) + { + Distributions27 D; + if (EvenOrOdd == true) + { + D.f[dirE] = &DDStart[dirE *size_Mat]; + D.f[dirW] = &DDStart[dirW *size_Mat]; + D.f[dirN] = &DDStart[dirN *size_Mat]; + D.f[dirS] = &DDStart[dirS *size_Mat]; + D.f[dirT] = &DDStart[dirT *size_Mat]; + D.f[dirB] = &DDStart[dirB *size_Mat]; + D.f[dirNE] = &DDStart[dirNE *size_Mat]; + D.f[dirSW] = &DDStart[dirSW *size_Mat]; + D.f[dirSE] = &DDStart[dirSE *size_Mat]; + D.f[dirNW] = &DDStart[dirNW *size_Mat]; + D.f[dirTE] = &DDStart[dirTE *size_Mat]; + D.f[dirBW] = &DDStart[dirBW *size_Mat]; + D.f[dirBE] = &DDStart[dirBE *size_Mat]; + D.f[dirTW] = &DDStart[dirTW *size_Mat]; + D.f[dirTN] = &DDStart[dirTN *size_Mat]; + D.f[dirBS] = &DDStart[dirBS *size_Mat]; + D.f[dirBN] = &DDStart[dirBN *size_Mat]; + D.f[dirTS] = &DDStart[dirTS *size_Mat]; + D.f[dirZERO] = &DDStart[dirZERO*size_Mat]; + D.f[dirTNE] = &DDStart[dirTNE *size_Mat]; + D.f[dirTSW] = &DDStart[dirTSW *size_Mat]; + D.f[dirTSE] = &DDStart[dirTSE *size_Mat]; + D.f[dirTNW] = &DDStart[dirTNW *size_Mat]; + D.f[dirBNE] = &DDStart[dirBNE *size_Mat]; + D.f[dirBSW] = &DDStart[dirBSW *size_Mat]; + D.f[dirBSE] = &DDStart[dirBSE *size_Mat]; + D.f[dirBNW] = &DDStart[dirBNW *size_Mat]; + } + else + { + D.f[dirW] = &DDStart[dirE *size_Mat]; + D.f[dirE] = &DDStart[dirW *size_Mat]; + D.f[dirS] = &DDStart[dirN *size_Mat]; + D.f[dirN] = &DDStart[dirS *size_Mat]; + D.f[dirB] = &DDStart[dirT *size_Mat]; + D.f[dirT] = &DDStart[dirB *size_Mat]; + D.f[dirSW] = &DDStart[dirNE *size_Mat]; + D.f[dirNE] = &DDStart[dirSW *size_Mat]; + D.f[dirNW] = &DDStart[dirSE *size_Mat]; + D.f[dirSE] = &DDStart[dirNW *size_Mat]; + D.f[dirBW] = &DDStart[dirTE *size_Mat]; + D.f[dirTE] = &DDStart[dirBW *size_Mat]; + D.f[dirTW] = &DDStart[dirBE *size_Mat]; + D.f[dirBE] = &DDStart[dirTW *size_Mat]; + D.f[dirBS] = &DDStart[dirTN *size_Mat]; + D.f[dirTN] = &DDStart[dirBS *size_Mat]; + D.f[dirTS] = &DDStart[dirBN *size_Mat]; + D.f[dirBN] = &DDStart[dirTS *size_Mat]; + D.f[dirZERO] = &DDStart[dirZERO*size_Mat]; + D.f[dirBSW] = &DDStart[dirTNE *size_Mat]; + D.f[dirBNE] = &DDStart[dirTSW *size_Mat]; + D.f[dirBNW] = &DDStart[dirTSE *size_Mat]; + D.f[dirBSE] = &DDStart[dirTNW *size_Mat]; + D.f[dirTSW] = &DDStart[dirBNE *size_Mat]; + D.f[dirTNE] = &DDStart[dirBSW *size_Mat]; + D.f[dirTNW] = &DDStart[dirBSE *size_Mat]; + D.f[dirTSE] = &DDStart[dirBNW *size_Mat]; + } + + //////////////////////////////////////////////////////////////////////////////// + //index + //unsigned int kzero= k; + //unsigned int ke = k; + unsigned int kw = neighborX[k]; + //unsigned int kn = k; + unsigned int ks = neighborY[k]; + //unsigned int kt = k; + unsigned int kb = neighborZ[k]; + unsigned int ksw = neighborY[kw]; + //unsigned int kne = k; + //unsigned int kse = ks; + //unsigned int knw = kw; + unsigned int kbw = neighborZ[kw]; + //unsigned int kte = k; + //unsigned int kbe = kb; + //unsigned int ktw = kw; + unsigned int kbs = neighborZ[ks]; + //unsigned int ktn = k; + //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 = k; + unsigned int kbsw = neighborZ[ksw]; + + + + ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + real mfcbb = (D.f[dirE])[k];//[ke ];// + c2over27 ;(D.f[dirE ])[k ];//ke + real mfabb = (D.f[dirW])[kw];//[kw ];// + c2over27 ;(D.f[dirW ])[kw ]; + real mfbcb = (D.f[dirN])[k];//[kn ];// + c2over27 ;(D.f[dirN ])[k ];//kn + real mfbab = (D.f[dirS])[ks];//[ks ];// + c2over27 ;(D.f[dirS ])[ks ]; + real mfbbc = (D.f[dirT])[k];//[kt ];// + c2over27 ;(D.f[dirT ])[k ];//kt + real mfbba = (D.f[dirB])[kb];//[kb ];// + c2over27 ;(D.f[dirB ])[kb ]; + real mfccb = (D.f[dirNE])[k];//[kne ];// + c1over54 ;(D.f[dirNE ])[k ];//kne + real mfaab = (D.f[dirSW])[ksw];//[ksw ];// + c1over54 ;(D.f[dirSW ])[ksw]; + real mfcab = (D.f[dirSE])[ks];//[kse ];// + c1over54 ;(D.f[dirSE ])[ks ];//kse + real mfacb = (D.f[dirNW])[kw];//[knw ];// + c1over54 ;(D.f[dirNW ])[kw ];//knw + real mfcbc = (D.f[dirTE])[k];//[kte ];// + c1over54 ;(D.f[dirTE ])[k ];//kte + real mfaba = (D.f[dirBW])[kbw];//[kbw ];// + c1over54 ;(D.f[dirBW ])[kbw]; + real mfcba = (D.f[dirBE])[kb];//[kbe ];// + c1over54 ;(D.f[dirBE ])[kb ];//kbe + real mfabc = (D.f[dirTW])[kw];//[ktw ];// + c1over54 ;(D.f[dirTW ])[kw ];//ktw + real mfbcc = (D.f[dirTN])[k];//[ktn ];// + c1over54 ;(D.f[dirTN ])[k ];//ktn + real mfbaa = (D.f[dirBS])[kbs];//[kbs ];// + c1over54 ;(D.f[dirBS ])[kbs]; + real mfbca = (D.f[dirBN])[kb];//[kbn ];// + c1over54 ;(D.f[dirBN ])[kb ];//kbn + real mfbac = (D.f[dirTS])[ks];//[kts ];// + c1over54 ;(D.f[dirTS ])[ks ];//kts + real mfbbb = (D.f[dirZERO])[k];//[kzero];// + c8over27 ;(D.f[dirZERO])[k ];//kzero + real mfccc = (D.f[dirTNE])[k];//[ktne ];// + c1over216;(D.f[dirTNE ])[k ];//ktne + real mfaac = (D.f[dirTSW])[ksw];//[ktsw ];// + c1over216;(D.f[dirTSW ])[ksw];//ktsw + real mfcac = (D.f[dirTSE])[ks];//[ktse ];// + c1over216;(D.f[dirTSE ])[ks ];//ktse + real mfacc = (D.f[dirTNW])[kw];//[ktnw ];// + c1over216;(D.f[dirTNW ])[kw ];//ktnw + real mfcca = (D.f[dirBNE])[kb];//[kbne ];// + c1over216;(D.f[dirBNE ])[kb ];//kbne + real mfaaa = (D.f[dirBSW])[kbsw];//[kbsw ];// + c1over216;(D.f[dirBSW ])[kbsw]; + real mfcaa = (D.f[dirBSE])[kbs];//[kbse ];// + c1over216;(D.f[dirBSE ])[kbs];//kbse + real mfaca = (D.f[dirBNW])[kbw];//[kbnw ];// + c1over216;(D.f[dirBNW ])[kbw];//kbnw + //////////////////////////////////////////////////////////////////////////////////// + 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 rho = c1o1 + drho; + //////////////////////////////////////////////////////////////////////////////////// + real vvx = ((((mfccc - mfaaa) + (mfcac - mfaca)) + ((mfcaa - mfacc) + (mfcca - mfaac))) + + (((mfcba - mfabc) + (mfcbc - mfaba)) + ((mfcab - mfacb) + (mfccb - mfaab))) + + (mfcbb - mfabb)) / rho; + real vvy = ((((mfccc - mfaaa) + (mfaca - mfcac)) + ((mfacc - mfcaa) + (mfcca - mfaac))) + + (((mfbca - mfbac) + (mfbcc - mfbaa)) + ((mfacb - mfcab) + (mfccb - mfaab))) + + (mfbcb - mfbab)) / rho; + real vvz = ((((mfccc - mfaaa) + (mfcac - mfaca)) + ((mfacc - mfcaa) + (mfaac - mfcca))) + + (((mfbac - mfbca) + (mfbcc - mfbaa)) + ((mfabc - mfcba) + (mfcbc - mfaba))) + + (mfbbc - mfbba)) / rho; + //////////////////////////////////////////////////////////////////////////////////// + //the force be with you + real fx = forces[0] / (pow((double)c2o1, (double)level)); //zero;//0.0032653/(pow(two,level)); //0.000000005;//(two/1600000.0) / 120.0; // + real fy = forces[1] / (pow((double)c2o1, (double)level)); //zero; + real fz = forces[2] / (pow((double)c2o1, (double)level)); //zero; + vvx += fx*c1o2; + vvy += fy*c1o2; + vvz += fz*c1o2; + //////////////////////////////////////////////////////////////////////////////////// + //real omega = omega_in; + //////////////////////////////////////////////////////////////////////////////////// + //fast + //real oMdrho = c1o1; // comp special + //real m0, m1, m2; + real vx2; + real vy2; + real vz2; + vx2 = vvx*vvx; + vy2 = vvy*vvy; + vz2 = vvz*vvz; + //////////////////////////////////////////////////////////////////////////////////// + //real wadjust; + //real qudricLimitP = c1o100;// * 0.0001f; + //real qudricLimitM = c1o100;// * 0.0001f; + //real qudricLimitD = c1o100;// * 0.001f; + //real s9 = minusomega; + //test + //s9 = 0.; + + + ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + real EQcbb = c0o1; + real EQabb = c0o1; + real EQbcb = c0o1; + real EQbab = c0o1; + real EQbbc = c0o1; + real EQbba = c0o1; + real EQccb = c0o1; + real EQaab = c0o1; + real EQcab = c0o1; + real EQacb = c0o1; + real EQcbc = c0o1; + real EQaba = c0o1; + real EQcba = c0o1; + real EQabc = c0o1; + real EQbcc = c0o1; + real EQbaa = c0o1; + real EQbca = c0o1; + real EQbac = c0o1; + real EQbbb = c0o1; + real EQccc = drho * c1o27; + real EQaac = drho * c1o3; + real EQcac = drho * c1o9; + real EQacc = drho * c1o9; + real EQcca = drho * c1o9; + real EQaaa = drho; + real EQcaa = drho * c1o3; + real EQaca = drho * c1o3; + //////////////////////////////////////////////////////////////////////////////////// + vf::lbm::backwardChimeraWithK(EQaaa, EQaab, EQaac, vvz, vz2, c1o1); + vf::lbm::backwardChimeraWithK(EQaca, EQacb, EQacc, vvz, vz2, c1o3); + /////////////////////////////////////////////////////////// + EQcaa = EQaca; EQcab = EQacb; EQcac = EQacc; + /////////////////////////////////////////////////////////// + vf::lbm::backwardChimeraWithK(EQcca, EQccb, EQccc, vvz, vz2, c1o9); + + vf::lbm::backwardChimeraWithK(EQaaa, EQaba, EQaca, vvy, vy2, c1o6); + vf::lbm::backwardChimeraWithK(EQaab, EQabb, EQacb, vvy, vy2, c2o3); + vf::lbm::backwardChimeraWithK(EQaac, EQabc, EQacc, vvy, vy2, c1o6); + vf::lbm::backwardChimeraWithK(EQcaa, EQcba, EQcca, vvy, vy2, c1o18); + vf::lbm::backwardChimeraWithK(EQcab, EQcbb, EQccb, vvy, vy2, c2o9); + vf::lbm::backwardChimeraWithK(EQcac, EQcbc, EQccc, vvy, vy2, c1o18); + + vf::lbm::backwardChimeraWithK(EQaaa, EQbaa, EQcaa, vvx, vx2, c1o36); + vf::lbm::backwardChimeraWithK(EQaab, EQbab, EQcab, vvx, vx2, c1o9); + vf::lbm::backwardChimeraWithK(EQaac, EQbac, EQcac, vvx, vx2, c1o36); + vf::lbm::backwardChimeraWithK(EQaba, EQbba, EQcba, vvx, vx2, c1o9); + vf::lbm::backwardChimeraWithK(EQabb, EQbbb, EQcbb, vvx, vx2, c4o9); + vf::lbm::backwardChimeraWithK(EQabc, EQbbc, EQcbc, vvx, vx2, c1o9); + vf::lbm::backwardChimeraWithK(EQaca, EQbca, EQcca, vvx, vx2, c1o36); + vf::lbm::backwardChimeraWithK(EQacb, EQbcb, EQccb, vvx, vx2, c1o9); + vf::lbm::backwardChimeraWithK(EQacc, EQbcc, EQccc, vvx, vx2, c1o36); + + //////////////////////////////////////////////////////////////////////////////////// + //Pre-condition + mfcbb -= EQcbb; + mfabb -= EQabb; + mfbcb -= EQbcb; + mfbab -= EQbab; + mfbbc -= EQbbc; + mfbba -= EQbba; + mfccb -= EQccb; + mfaab -= EQaab; + mfcab -= EQcab; + mfacb -= EQacb; + mfcbc -= EQcbc; + mfaba -= EQaba; + mfcba -= EQcba; + mfabc -= EQabc; + mfbcc -= EQbcc; + mfbaa -= EQbaa; + mfbca -= EQbca; + mfbac -= EQbac; + mfbbb -= EQbbb; + mfccc -= EQccc; + mfaac -= EQaac; + mfcac -= EQcac; + mfacc -= EQacc; + mfcca -= EQcca; + mfaaa -= EQaaa; + mfcaa -= EQcaa; + mfaca -= EQaca; + + //////////////////////////////////////////////////////////////////////////////////// + //Hin + //////////////////////////////////////////////////////////////////////////////////// + vf::lbm::forwardChimera(mfaaa, mfaab, mfaac, vvz, vz2); + vf::lbm::forwardChimera(mfaba, mfabb, mfabc, vvz, vz2); + vf::lbm::forwardChimera(mfaca, mfacb, mfacc, vvz, vz2); + vf::lbm::forwardChimera(mfbaa, mfbab, mfbac, vvz, vz2); + vf::lbm::forwardChimera(mfbba, mfbbb, mfbbc, vvz, vz2); + vf::lbm::forwardChimera(mfbca, mfbcb, mfbcc, vvz, vz2); + vf::lbm::forwardChimera(mfcaa, mfcab, mfcac, vvz, vz2); + vf::lbm::forwardChimera(mfcba, mfcbb, mfcbc, vvz, vz2); + vf::lbm::forwardChimera(mfcca, mfccb, mfccc, vvz, vz2); + + vf::lbm::forwardChimera(mfaaa, mfaba, mfaca, vvy, vy2); + vf::lbm::forwardChimera(mfaab, mfabb, mfacb, vvy, vy2); + vf::lbm::forwardChimera(mfaac, mfabc, mfacc, vvy, vy2); + vf::lbm::forwardChimera(mfbaa, mfbba, mfbca, vvy, vy2); + vf::lbm::forwardChimera(mfbab, mfbbb, mfbcb, vvy, vy2); + vf::lbm::forwardChimera(mfbac, mfbbc, mfbcc, vvy, vy2); + vf::lbm::forwardChimera(mfcaa, mfcba, mfcca, vvy, vy2); + vf::lbm::forwardChimera(mfcab, mfcbb, mfccb, vvy, vy2); + vf::lbm::forwardChimera(mfcac, mfcbc, mfccc, vvy, vy2); + + vf::lbm::forwardChimera(mfaaa, mfbaa, mfcaa, vvx, vx2); + vf::lbm::forwardChimera(mfaab, mfbab, mfcab, vvx, vx2); + vf::lbm::forwardChimera(mfaac, mfbac, mfcac, vvx, vx2); + vf::lbm::forwardChimera(mfaba, mfbba, mfcba, vvx, vx2); + vf::lbm::forwardChimera(mfabb, mfbbb, mfcbb, vvx, vx2); + vf::lbm::forwardChimera(mfabc, mfbbc, mfcbc, vvx, vx2); + vf::lbm::forwardChimera(mfaca, mfbca, mfcca, vvx, vx2); + vf::lbm::forwardChimera(mfacb, mfbcb, mfccb, vvx, vx2); + vf::lbm::forwardChimera(mfacc, mfbcc, mfccc, vvx, vx2); + + ////////////////////////////////////////////////////////////////////////////////////// + ////Hin + ////////////////////////////////////////////////////////////////////////////////////// + //// mit 1/36, 1/9, 1/36, 1/9, 4/9, 1/9, 1/36, 1/9, 1/36 Konditionieren + ////////////////////////////////////////////////////////////////////////////////////// + //// Z - Dir + //forwardChimeraWithK(mfaaa, mfaab, mfaac, vvz, vz2, c1o36); + ////////////////////////////////////////////////////////////////////////////////////// + //forwardChimeraWithK(mfaba, mfabb, mfabc, vvz, vz2, c1o9); + ////////////////////////////////////////////////////////////////////////////////////// + //forwardChimeraWithK(mfaca, mfacb, mfacc, vvz, vz2, c1o36); + ////////////////////////////////////////////////////////////////////////////////////// + ////////////////////////////////////////////////////////////////////////////////////// + //forwardChimeraWithK(mfbaa, mfbab, mfbac, vvz, vz2, c1o9); + ////////////////////////////////////////////////////////////////////////////////////// + //forwardChimeraWithK(mfbba, mfbbb, mfbbc, vvz, vz2, c4o9); + ////////////////////////////////////////////////////////////////////////////////////// + //forwardChimeraWithK(mfbca, mfbcb, mfbcc, vvz, vz2, c1o9); + ////////////////////////////////////////////////////////////////////////////////////// + ////////////////////////////////////////////////////////////////////////////////////// + //forwardChimeraWithK(mfcaa, mfcab, mfcac, vvz, vz2, c1o36); + ////////////////////////////////////////////////////////////////////////////////////// + //forwardChimeraWithK(mfcba, mfcbb, mfcbc, vvz, vz2, c1o9); + ////////////////////////////////////////////////////////////////////////////////////// + //forwardChimeraWithK(mfcca, mfccb, mfccc, vvz, vz2, c1o36); + ////////////////////////////////////////////////////////////////////////////////////// + ////////////////////////////////////////////////////////////////////////////////////// + //// mit 1/6, 0, 1/18, 2/3, 0, 2/9, 1/6, 0, 1/18 Konditionieren + ////////////////////////////////////////////////////////////////////////////////////// + //// Y - Dir + //forwardChimeraWithK(mfaaa, mfaba, mfaca, vvy, vy2, c1o6); + ////////////////////////////////////////////////////////////////////////////////////// + //forwardChimera(mfaab, mfabb, mfacb, vvy, vy2); + ////////////////////////////////////////////////////////////////////////////////////// + //forwardChimeraWithK(mfaac, mfabc, mfacc, vvy, vy2, c1o18); + ////////////////////////////////////////////////////////////////////////////////////// + ////////////////////////////////////////////////////////////////////////////////////// + //forwardChimeraWithK(mfbaa, mfbba, mfbca, vvy, vy2, c2o3); + ////////////////////////////////////////////////////////////////////////////////////// + //forwardChimera(mfbab, mfbbb, mfbcb, vvy, vy2); + ////////////////////////////////////////////////////////////////////////////////////// + //forwardChimeraWithK(mfbac, mfbbc, mfbcc, vvy, vy2, c2o9); + ////////////////////////////////////////////////////////////////////////////////////// + ////////////////////////////////////////////////////////////////////////////////////// + //forwardChimeraWithK(mfcaa, mfcba, mfcca, vvy, vy2, c1o6); + ////////////////////////////////////////////////////////////////////////////////////// + //forwardChimera(mfcab, mfcbb, mfccb, vvy, vy2); + ////////////////////////////////////////////////////////////////////////////////////// + //forwardChimeraWithK(mfcac, mfcbc, mfccc, vvy, vy2, c1o18); + ////////////////////////////////////////////////////////////////////////////////////// + ////////////////////////////////////////////////////////////////////////////////////// + //// mit 1, 0, 1/3, 0, 0, 0, 1/3, 0, 1/9 Konditionieren + ////////////////////////////////////////////////////////////////////////////////////// + //// X - Dir + //forwardChimeraWithK(mfaaa, mfbaa, mfcaa, vvx, vx2, one); + ////////////////////////////////////////////////////////////////////////////////////// + //forwardChimera(mfaba, mfbba, mfcba, vvx, vx2); + ////////////////////////////////////////////////////////////////////////////////////// + //forwardChimeraWithK(mfaca, mfbca, mfcca, vvx, vx2, c1o3); + ////////////////////////////////////////////////////////////////////////////////////// + ////////////////////////////////////////////////////////////////////////////////////// + //forwardChimera(mfaab, mfbab, mfcab, vvx, vx2); + ////////////////////////////////////////////////////////////////////////////////////// + //forwardChimera(mfabb, mfbbb, mfcbb, vvx, vx2); + ////////////////////////////////////////////////////////////////////////////////////// + //forwardChimera(mfacb, mfbcb, mfccb, vvx, vx2); + ////////////////////////////////////////////////////////////////////////////////////// + ////////////////////////////////////////////////////////////////////////////////////// + //forwardChimeraWithK(mfaac, mfbac, mfcac, vvx, vx2, c1o3); + ////////////////////////////////////////////////////////////////////////////////////// + //forwardChimera(mfabc, mfbbc, mfcbc, vvx, vx2); + ////////////////////////////////////////////////////////////////////////////////////// + //forwardChimeraWithK(mfacc, mfbcc, mfccc, vvx, vx2, c1o9); + ////////////////////////////////////////////////////////////////////////////////////// + ////////////////////////////////////////////////////////////////////////////////////// + + + //////////////////////////////////////////////////////////////////////////////////// + // Cumulants + //////////////////////////////////////////////////////////////////////////////////// + real OxxPyyPzz = c1o1; //omega; // one; //set the bulk viscosity one is high / two is very low and zero is (too) high + + //////////////////////////////////////////////////////////// + //3. + ////////////////////////////// + real OxyyPxzz = c1o1; + real OxyyMxzz = c1o1; + //real Oxyz = c1o1; + //////////////////////////////////////////////////////////// + //4. + ////////////////////////////// + real O4 = c1o1; + //////////////////////////////////////////////////////////// + //5. + ////////////////////////////// + real O5 = c1o1; + //////////////////////////////////////////////////////////// + //6. + ////////////////////////////// + real O6 = c1o1; + //////////////////////////////////////////////////////////// + + + //central moments to cumulants + //4. + real CUMcbb = mfcbb - ((mfcaa + c1o3) * mfabb + c2o1 * mfbba * mfbab) / rho; + real CUMbcb = mfbcb - ((mfaca + c1o3) * mfbab + c2o1 * mfbba * mfabb) / rho; + real CUMbbc = mfbbc - ((mfaac + c1o3) * mfbba + c2o1 * mfbab * mfabb) / rho; + + real CUMcca = mfcca - (((mfcaa * mfaca + c2o1 * mfbba * mfbba) + c1o3 * (mfcaa + mfaca)) / rho - c1o9*(drho / rho)); + real CUMcac = mfcac - (((mfcaa * mfaac + c2o1 * mfbab * mfbab) + c1o3 * (mfcaa + mfaac)) / rho - c1o9*(drho / rho)); + real CUMacc = mfacc - (((mfaac * mfaca + c2o1 * mfabb * mfabb) + c1o3 * (mfaac + mfaca)) / rho - c1o9*(drho / rho)); + + //5. + real CUMbcc = mfbcc - ((mfaac * mfbca + mfaca * mfbac + c4o1 * mfabb * mfbbb + c2o1 * (mfbab * mfacb + mfbba * mfabc)) + c1o3 * (mfbca + mfbac)) / rho; + real CUMcbc = mfcbc - ((mfaac * mfcba + mfcaa * mfabc + c4o1 * mfbab * mfbbb + c2o1 * (mfabb * mfcab + mfbba * mfbac)) + c1o3 * (mfcba + mfabc)) / rho; + real CUMccb = mfccb - ((mfcaa * mfacb + mfaca * mfcab + c4o1 * mfbba * mfbbb + c2o1 * (mfbab * mfbca + mfabb * mfcba)) + c1o3 * (mfacb + mfcab)) / rho; + + //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)) / rho + + (c4o1 * (mfbab * mfbab * mfaca + mfabb * mfabb * mfcaa + mfbba * mfbba * mfaac) + + c2o1 * (mfcaa * mfaca * mfaac) + + c16o1 * mfbba * mfbab * mfabb) / (rho * rho) + - c1o3 * (mfacc + mfcac + mfcca) / rho + - c1o9 * (mfcaa + mfaca + mfaac) / rho + + (c2o1 * (mfbab * mfbab + mfabb * mfabb + mfbba * mfbba) + + (mfaac * mfaca + mfaac * mfcaa + mfaca * mfcaa) + c1o3 *(mfaac + mfaca + mfcaa)) / (rho * rho) * c2o3 + + c1o27*((drho * drho - drho) / (rho*rho))); + + + + + //2. + // linear combinations + real mxxPyyPzz = mfcaa + mfaca + mfaac; + real mxxMyy = mfcaa - mfaca; + real mxxMzz = mfcaa - mfaac; + + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //incl. correction (hat noch nicht so gut funktioniert...Optimierungsbedarf??) + { + real dxux = c1o2 * (-omega) *(mxxMyy + mxxMzz) + c1o2 * OxxPyyPzz * (mfaaa - mxxPyyPzz); + real dyuy = dxux + omega * c3o2 * mxxMyy; + real dzuz = dxux + omega * c3o2 * mxxMzz; + + //relax + mxxPyyPzz += OxxPyyPzz*(mfaaa - mxxPyyPzz) - c3o1 * (c1o1 - c1o2 * OxxPyyPzz) * (vx2 * dxux + vy2 * dyuy + vz2 * dzuz);//-magicBulk*OxxPyyPzz; + 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);//-magicBulk*OxxPyyPzz; + //mxxMyy += -(-omega) * (-mxxMyy); + //mxxMzz += -(-omega) * (-mxxMzz); + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + mfabb += omega * (-mfabb); + mfbab += omega * (-mfbab); + mfbba += omega * (-mfbba); + + ////////////////////////////////////////////////////////////////////////// + + // linear combinations back + mfcaa = c1o3 * (mxxMyy + mxxMzz + mxxPyyPzz); + mfaca = c1o3 * (-c2o1* mxxMyy + mxxMzz + mxxPyyPzz); + mfaac = c1o3 * (mxxMyy - c2o1* mxxMzz + mxxPyyPzz); + + //3. + // linear combinations + + real mxxyPyzz = mfcba + mfabc; + real mxxyMyzz = mfcba - mfabc; + + real mxxzPyyz = mfcab + mfacb; + real mxxzMyyz = mfcab - mfacb; + + real mxyyPxzz = mfbca + mfbac; + real mxyyMxzz = mfbca - mfbac; + + //relax + ////////////////////////////////////////////////////////////////////////// + mfbbb += OxyyMxzz * (-mfbbb); + mxxyPyzz += OxyyPxzz * (-mxxyPyzz); + mxxyMyzz += OxyyMxzz * (-mxxyMyzz); + mxxzPyyz += OxyyPxzz * (-mxxzPyyz); + mxxzMyyz += OxyyMxzz * (-mxxzMyyz); + mxyyPxzz += OxyyPxzz * (-mxyyPxzz); + mxyyMxzz += OxyyMxzz * (-mxyyMxzz); + ////////////////////////////////////////////////////////////////////////// + + 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. + ////////////////////////////////////////////////////////////////////////// + CUMacc += O4 * (-CUMacc); + CUMcac += O4 * (-CUMcac); + CUMcca += O4 * (-CUMcca); + + CUMbbc += O4 * (-CUMbbc); + CUMbcb += O4 * (-CUMbcb); + CUMcbb += O4 * (-CUMcbb); + ////////////////////////////////////////////////////////////////////////// + + + //5. + CUMbcc += O5 * (-CUMbcc); + CUMcbc += O5 * (-CUMcbc); + CUMccb += O5 * (-CUMccb); + + //6. + CUMccc += O6 * (-CUMccc); + + + + //back cumulants to central moments + //4. + mfcbb = CUMcbb + ((mfcaa + c1o3) * mfabb + c2o1 * mfbba * mfbab) / rho; + mfbcb = CUMbcb + ((mfaca + c1o3) * mfbab + c2o1 * mfbba * mfabb) / rho; + mfbbc = CUMbbc + ((mfaac + c1o3) * mfbba + c2o1 * mfbab * mfabb) / rho; + + mfcca = CUMcca + (((mfcaa * mfaca + c2o1 * mfbba * mfbba) + c1o3 * (mfcaa + mfaca)) / rho - c1o9*(drho / rho)); + mfcac = CUMcac + (((mfcaa * mfaac + c2o1 * mfbab * mfbab) + c1o3 * (mfcaa + mfaac)) / rho - c1o9*(drho / rho)); + mfacc = CUMacc + (((mfaac * mfaca + c2o1 * mfabb * mfabb) + c1o3 * (mfaac + mfaca)) / rho - c1o9*(drho / rho)); + + //5. + mfbcc = CUMbcc + ((mfaac * mfbca + mfaca * mfbac + c4o1 * mfabb * mfbbb + c2o1 * (mfbab * mfacb + mfbba * mfabc)) + c1o3 * (mfbca + mfbac)) / rho; + mfcbc = CUMcbc + ((mfaac * mfcba + mfcaa * mfabc + c4o1 * mfbab * mfbbb + c2o1 * (mfabb * mfcab + mfbba * mfbac)) + c1o3 * (mfcba + mfabc)) / rho; + mfccb = CUMccb + ((mfcaa * mfacb + mfaca * mfcab + c4o1 * mfbba * mfbbb + c2o1 * (mfbab * mfbca + mfabb * mfcba)) + c1o3 * (mfacb + mfcab)) / rho; + + //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)) / rho + + (c4o1 * (mfbab * mfbab * mfaca + mfabb * mfabb * mfcaa + mfbba * mfbba * mfaac) + + c2o1 * (mfcaa * mfaca * mfaac) + + c16o1 * mfbba * mfbab * mfabb) / (rho * rho) + - c1o3 * (mfacc + mfcac + mfcca) / rho + - c1o9 * (mfcaa + mfaca + mfaac) / rho + + (c2o1 * (mfbab * mfbab + mfabb * mfabb + mfbba * mfbba) + + (mfaac * mfaca + mfaac * mfcaa + mfaca * mfcaa) + c1o3 *(mfaac + mfaca + mfcaa)) / (rho * rho) * c2o3 + + c1o27*((drho * drho - drho) / (rho*rho))); + + //////////////////////////////////////////////////////////////////////////////////// + //the force be with you + mfbaa = -mfbaa; + mfaba = -mfaba; + mfaab = -mfaab; + //////////////////////////////////////////////////////////////////////////////////// + + + //////////////////////////////////////////////////////////////////////////////////// + //back + //////////////////////////////////////////////////////////////////////////////////// + vf::lbm::backwardChimera(mfaaa, mfaab, mfaac, vvz, vz2); + vf::lbm::backwardChimera(mfaba, mfabb, mfabc, vvz, vz2); + vf::lbm::backwardChimera(mfaca, mfacb, mfacc, vvz, vz2); + vf::lbm::backwardChimera(mfbaa, mfbab, mfbac, vvz, vz2); + vf::lbm::backwardChimera(mfbba, mfbbb, mfbbc, vvz, vz2); + vf::lbm::backwardChimera(mfbca, mfbcb, mfbcc, vvz, vz2); + vf::lbm::backwardChimera(mfcaa, mfcab, mfcac, vvz, vz2); + vf::lbm::backwardChimera(mfcba, mfcbb, mfcbc, vvz, vz2); + vf::lbm::backwardChimera(mfcca, mfccb, mfccc, vvz, vz2); + + vf::lbm::backwardChimera(mfaaa, mfaba, mfaca, vvy, vy2); + vf::lbm::backwardChimera(mfaab, mfabb, mfacb, vvy, vy2); + vf::lbm::backwardChimera(mfaac, mfabc, mfacc, vvy, vy2); + vf::lbm::backwardChimera(mfbaa, mfbba, mfbca, vvy, vy2); + vf::lbm::backwardChimera(mfbab, mfbbb, mfbcb, vvy, vy2); + vf::lbm::backwardChimera(mfbac, mfbbc, mfbcc, vvy, vy2); + vf::lbm::backwardChimera(mfcaa, mfcba, mfcca, vvy, vy2); + vf::lbm::backwardChimera(mfcab, mfcbb, mfccb, vvy, vy2); + vf::lbm::backwardChimera(mfcac, mfcbc, mfccc, vvy, vy2); + + vf::lbm::backwardChimera(mfaaa, mfbaa, mfcaa, vvx, vx2); + vf::lbm::backwardChimera(mfaab, mfbab, mfcab, vvx, vx2); + vf::lbm::backwardChimera(mfaac, mfbac, mfcac, vvx, vx2); + vf::lbm::backwardChimera(mfaba, mfbba, mfcba, vvx, vx2); + vf::lbm::backwardChimera(mfabb, mfbbb, mfcbb, vvx, vx2); + vf::lbm::backwardChimera(mfabc, mfbbc, mfcbc, vvx, vx2); + vf::lbm::backwardChimera(mfaca, mfbca, mfcca, vvx, vx2); + vf::lbm::backwardChimera(mfacb, mfbcb, mfccb, vvx, vx2); + vf::lbm::backwardChimera(mfacc, mfbcc, mfccc, vvx, vx2); + + //////////////////////////////////////////////////////////////////////////////////// + //mfcbb += EQcbb; + //mfabb += EQabb; + //mfbcb += EQbcb; + //mfbab += EQbab; + //mfbbc += EQbbc; + //mfbba += EQbba; + //mfccb += EQccb; + //mfaab += EQaab; + //mfcab += EQcab; + //mfacb += EQacb; + //mfcbc += EQcbc; + //mfaba += EQaba; + //mfcba += EQcba; + //mfabc += EQabc; + //mfbcc += EQbcc; + //mfbaa += EQbaa; + //mfbca += EQbca; + //mfbac += EQbac; + //mfbbb += EQbbb; + //mfccc += EQccc; + //mfaac += EQaac; + //mfcac += EQcac; + //mfacc += EQacc; + //mfcca += EQcca; + //mfaaa += EQaaa; + //mfcaa += EQcaa; + //mfaca += EQaca; + //////////////////////////////////////////////////////////////////////////////////// + ////Error diffusion + real fTEMP = mfbbb + EQbbb; + real delta0 = mfbbb - (fTEMP - EQbbb); + delta0 *= c1o4; + mfbbb = fTEMP; + + + fTEMP = mfcbb + EQcbb; + real deltacbb = mfcbb - (fTEMP - EQcbb); + mfcbb = fTEMP; + //mfcbb+=EQcbb; + + fTEMP = mfabb + EQabb; + real deltaabb = mfabb - (fTEMP - EQabb); + mfabb = fTEMP; + //mfabb+=EQabb; + + fTEMP = mfbcb + EQbcb; + real deltabcb = mfbcb - (fTEMP - EQbcb); + mfbcb = fTEMP; + //mfbcb+=EQbcb; + + fTEMP = mfbab + EQbab; + real deltabab = mfbab - (fTEMP - EQbab); + mfbab = fTEMP; + //mfbab+=EQbab; + + fTEMP = mfbbc + EQbbc; + real deltabbc = mfbbc - (fTEMP - EQbbc); + mfbbc = fTEMP; + //mfbbc+=EQbbc; + + fTEMP = mfbba + EQbba; + real deltabba = mfbba - (fTEMP - EQbba); + mfbba = fTEMP; + //mfbba+=EQbba; + + EQccb += (delta0 + c1o2*(deltacbb + deltabcb)); + fTEMP = mfccb + EQccb; + real deltaccb = mfccb - (fTEMP - EQccb); + mfccb = fTEMP; + //mfccb+=EQccb+(delta0+c1o2*(deltacbb+deltabcb)); + + EQaab += (delta0 + c1o2*(deltaabb + deltabab)); + fTEMP = mfaab + EQaab; + real deltaaab = mfaab - (fTEMP - EQaab); + mfaab = fTEMP; + //mfaab+=EQaab+(delta0+c1o2*(deltaabb+deltabab)); + + EQcab += (delta0 + c1o2*(deltacbb + deltabab)); + fTEMP = mfcab + EQcab; + real deltacab = mfcab - (fTEMP - EQcab); + mfcab = fTEMP; + //mfcab+=EQcab+(delta0+c1o2*(deltacbb+deltabab)); + + EQacb += (delta0 + c1o2*(deltaabb + deltabcb)); + fTEMP = mfacb + EQacb; + real deltaacb = mfacb - (fTEMP - EQacb); + mfacb = fTEMP; + //mfacb+=EQacb+(delta0+c1o2*(deltaabb+deltabcb)); + + EQcbc += (delta0 + c1o2*(deltacbb + deltabbc)); + fTEMP = mfcbc + EQcbc; + real deltacbc = mfcbc - (fTEMP - EQcbc); + mfcbc = fTEMP; + //mfcbc+=EQcbc+(delta0+c1o2*(deltacbb+deltabbc)); + + EQaba += (delta0 + c1o2*(deltaabb + deltabba)); + fTEMP = mfaba + EQaba; + real deltaaba = mfaba - (fTEMP - EQaba); + mfaba = fTEMP; + //mfaba+=EQaba+(delta0+c1o2*(deltaabb+deltabba)); + + EQcba += (delta0 + c1o2*(deltacbb + deltabba)); + fTEMP = mfcba + EQcba; + real deltacba = mfcba - (fTEMP - EQcba); + mfcba = fTEMP; + //mfcba+=EQcba+(delta0+c1o2*(deltacbb+deltabba)); + + EQabc += (delta0 + c1o2*(deltaabb + deltabbc)); + fTEMP = mfabc + EQabc; + real deltaabc = mfabc - (fTEMP - EQabc); + mfabc = fTEMP; + //mfabc+=EQabc+(delta0+c1o2*(deltaabb+deltabbc)); + + EQbcc += (delta0 + c1o2*(deltabcb + deltabbc)); + fTEMP = mfbcc + EQbcc; + real deltabcc = mfbcc - (fTEMP - EQbcc); + mfbcc = fTEMP; + //mfbcc+=EQbcc+(delta0+c1o2*(deltabcb+deltabbc)); + + EQbaa += (delta0 + c1o2*(deltabab + deltabba)); + fTEMP = mfbaa + EQbaa; + real deltabaa = mfbaa - (fTEMP - EQbaa); + mfbaa = fTEMP; + //mfbaa+=EQbaa+(delta0+c1o2*(deltabab+deltabba)); + + EQbca += (delta0 + c1o2*(deltabcb + deltabba)); + fTEMP = mfbca + EQbca; + real deltabca = mfbca - (fTEMP - EQbca); + mfbca = fTEMP; + //mfbca+=EQbca+(delta0+c1o2*(deltabcb+deltabba)); + + EQbac += (delta0 + c1o2*(deltabab + deltabbc)); + fTEMP = mfbac + EQbac; + real deltabac = mfbac - (fTEMP - EQbac); + mfbac = fTEMP; + //mfbac+=EQbac+(delta0+c1o2*(deltabab+deltabbc)); + + mfccc += EQccc - (delta0 + c1o4*(deltacbb + deltabcb + deltabbc) - c1o2*(deltabcc + deltacbc + deltaccb)); + mfaac += EQaac - (delta0 + c1o4*(deltaabb + deltabab + deltabbc) - c1o2*(deltabac + deltaabc + deltaaab)); + mfcac += EQcac - (delta0 + c1o4*(deltacbb + deltabab + deltabbc) - c1o2*(deltabac + deltacbc + deltacab)); + mfacc += EQacc - (delta0 + c1o4*(deltaabb + deltabcb + deltabbc) - c1o2*(deltabcc + deltaabc + deltaacb)); + mfcca += EQcca - (delta0 + c1o4*(deltacbb + deltabcb + deltabba) - c1o2*(deltabca + deltacba + deltaccb)); + mfaaa += EQaaa - (delta0 + c1o4*(deltaabb + deltabab + deltabba) - c1o2*(deltabaa + deltaaba + deltaaab)); + mfcaa += EQcaa - (delta0 + c1o4*(deltacbb + deltabab + deltabba) - c1o2*(deltabaa + deltacba + deltacab)); + mfaca += EQaca - (delta0 + c1o4*(deltaabb + deltabcb + deltabba) - c1o2*(deltabca + deltaaba + deltaacb)); + + + + ////////////////////////////////////////////////////////////////////////////////////// + ////back + ////////////////////////////////////////////////////////////////////////////////////// + ////mit 1, 0, 1/3, 0, 0, 0, 1/3, 0, 1/9 Konditionieren + ////////////////////////////////////////////////////////////////////////////////////// + //// Z - Dir + //backwardChimeraWithK(mfaaa, mfaab, mfaac, vvz, vz2, one); + ////////////////////////////////////////////////////////////////////////////////////// + //backwardChimera(mfaba, mfabb, mfabc, vvz, vz2); + ////////////////////////////////////////////////////////////////////////////////////// + //backwardChimeraWithK(mfaca, mfacb, mfacc, vvz, vz2, c1o3); + ////////////////////////////////////////////////////////////////////////////////////// + ////////////////////////////////////////////////////////////////////////////////////// + //backwardChimera(mfbaa, mfbab, mfbac, vvz, vz2); + ///////////b////////////////////////////////////////////////////////////////////////// + //backwardChimera(mfbba, mfbbb, mfbbc, vvz, vz2); + ///////////b////////////////////////////////////////////////////////////////////////// + //backwardChimera(mfbca, mfbcb, mfbcc, vvz, vz2); + ////////////////////////////////////////////////////////////////////////////////////// + ////////////////////////////////////////////////////////////////////////////////////// + //backwardChimeraWithK(mfcaa, mfcab, mfcac, vvz, vz2, c1o3); + ///////////c////////////////////////////////////////////////////////////////////////// + //backwardChimera(mfcba, mfcbb, mfcbc, vvz, vz2); + ///////////c////////////////////////////////////////////////////////////////////////// + //backwardChimeraWithK(mfcca, mfccb, mfccc, vvz, vz2, c1o9); + ////////////////////////////////////////////////////////////////////////////////////// + ////////////////////////////////////////////////////////////////////////////////////// + ////mit 1/6, 2/3, 1/6, 0, 0, 0, 1/18, 2/9, 1/18 Konditionieren + ////////////////////////////////////////////////////////////////////////////////////// + //// Y - Dir + //backwardChimeraWithK(mfaaa, mfaba, mfaca, vvy, vy2, c1o6); + ////////////////////////////////////////////////////////////////////////////////////// + //backwardChimeraWithK(mfaab, mfabb, mfacb, vvy, vy2, c2o3); + ////////////////////////////////////////////////////////////////////////////////////// + //backwardChimeraWithK(mfaac, mfabc, mfacc, vvy, vy2, c1o6); + ////////////////////////////////////////////////////////////////////////////////////// + ////////////////////////////////////////////////////////////////////////////////////// + //backwardChimera(mfbaa, mfbba, mfbca, vvz, vz2); + ///////////b////////////////////////////////////////////////////////////////////////// + //backwardChimera(mfbab, mfbbb, mfbcb, vvz, vz2); + ///////////b////////////////////////////////////////////////////////////////////////// + //backwardChimera(mfbac, mfbbc, mfbcc, vvz, vz2); + ////////////////////////////////////////////////////////////////////////////////////// + ////////////////////////////////////////////////////////////////////////////////////// + //backwardChimeraWithK(mfcaa, mfcba, mfcca, vvy, vy2, c1o18); + ///////////c////////////////////////////////////////////////////////////////////////// + //backwardChimeraWithK(mfcab, mfcbb, mfccb, vvy, vy2, c2o9); + ///////////c////////////////////////////////////////////////////////////////////////// + //backwardChimeraWithK(mfcac, mfcbc, mfccc, vvy, vy2, c1o18); + ////////////////////////////////////////////////////////////////////////////////////// + ////////////////////////////////////////////////////////////////////////////////////// + ////mit 1/36, 1/9, 1/36, 1/9, 4/9, 1/9, 1/36, 1/9, 1/36 Konditionieren + ////////////////////////////////////////////////////////////////////////////////////// + //// X - Dir + //backwardChimeraWithK(mfaaa, mfbaa, mfcaa, vvx, vx2, c1o36); + ////////////////////////////////////////////////////////////////////////////////////// + //backwardChimeraWithK(mfaba, mfbba, mfcba, vvx, vx2, c1o9); + ////////////////////////////////////////////////////////////////////////////////////// + //backwardChimeraWithK(mfaca, mfbca, mfcca, vvx, vx2, c1o36); + ////////////////////////////////////////////////////////////////////////////////////// + ////////////////////////////////////////////////////////////////////////////////////// + //backwardChimeraWithK(mfaab, mfbab, mfcab, vvx, vx2, c1o9); + /////////////b//////////////////////////////////////////////////////////////////////// + //backwardChimeraWithK(mfabb, mfbbb, mfcbb, vvx, vx2, c4o9); + /////////////b//////////////////////////////////////////////////////////////////////// + //backwardChimeraWithK(mfacb, mfbcb, mfccb, vvx, vx2, c1o9); + ////////////////////////////////////////////////////////////////////////////////////// + ////////////////////////////////////////////////////////////////////////////////////// + //backwardChimeraWithK(mfaac, mfbac, mfcac, vvx, vx2, c1o36); + /////////////c//////////////////////////////////////////////////////////////////////// + //backwardChimeraWithK(mfabc, mfbbc, mfcbc, vvx, vx2, c1o9); + /////////////c//////////////////////////////////////////////////////////////////////// + //backwardChimeraWithK(mfacc, mfbcc, mfccc, vvx, vx2, c1o36); + ////////////////////////////////////////////////////////////////////////////////////// + + //////////////////////////////////////////////////////////////////////////////////////// + //real drhoPost = + // ((((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; + //mfbbb += drho - drhoPost; + //////////////////////////////////////////////////////////////////////////////////// + (D.f[dirE])[k] = mfabb;//(D.f[ dirE ])[ke ] = mfabb;// - c2over27 ; (D.f[ dirE ])[k ] + (D.f[dirW])[kw] = mfcbb;//(D.f[ dirW ])[kw ] = mfcbb;// - c2over27 ; (D.f[ dirW ])[kw ] + (D.f[dirN])[k] = mfbab;//(D.f[ dirN ])[kn ] = mfbab;// - c2over27 ; (D.f[ dirN ])[k ] + (D.f[dirS])[ks] = mfbcb;//(D.f[ dirS ])[ks ] = mfbcb;// - c2over27 ; (D.f[ dirS ])[ks ] + (D.f[dirT])[k] = mfbba;//(D.f[ dirT ])[kt ] = mfbba;// - c2over27 ; (D.f[ dirT ])[k ] + (D.f[dirB])[kb] = mfbbc;//(D.f[ dirB ])[kb ] = mfbbc;// - c2over27 ; (D.f[ dirB ])[kb ] + (D.f[dirNE])[k] = mfaab;//(D.f[ dirNE ])[kne ] = mfaab;// - c1over54 ; (D.f[ dirNE ])[k ] + (D.f[dirSW])[ksw] = mfccb;//(D.f[ dirSW ])[ksw ] = mfccb;// - c1over54 ; (D.f[ dirSW ])[ksw ] + (D.f[dirSE])[ks] = mfacb;//(D.f[ dirSE ])[kse ] = mfacb;// - c1over54 ; (D.f[ dirSE ])[ks ] + (D.f[dirNW])[kw] = mfcab;//(D.f[ dirNW ])[knw ] = mfcab;// - c1over54 ; (D.f[ dirNW ])[kw ] + (D.f[dirTE])[k] = mfaba;//(D.f[ dirTE ])[kte ] = mfaba;// - c1over54 ; (D.f[ dirTE ])[k ] + (D.f[dirBW])[kbw] = mfcbc;//(D.f[ dirBW ])[kbw ] = mfcbc;// - c1over54 ; (D.f[ dirBW ])[kbw ] + (D.f[dirBE])[kb] = mfabc;//(D.f[ dirBE ])[kbe ] = mfabc;// - c1over54 ; (D.f[ dirBE ])[kb ] + (D.f[dirTW])[kw] = mfcba;//(D.f[ dirTW ])[ktw ] = mfcba;// - c1over54 ; (D.f[ dirTW ])[kw ] + (D.f[dirTN])[k] = mfbaa;//(D.f[ dirTN ])[ktn ] = mfbaa;// - c1over54 ; (D.f[ dirTN ])[k ] + (D.f[dirBS])[kbs] = mfbcc;//(D.f[ dirBS ])[kbs ] = mfbcc;// - c1over54 ; (D.f[ dirBS ])[kbs ] + (D.f[dirBN])[kb] = mfbac;//(D.f[ dirBN ])[kbn ] = mfbac;// - c1over54 ; (D.f[ dirBN ])[kb ] + (D.f[dirTS])[ks] = mfbca;//(D.f[ dirTS ])[kts ] = mfbca;// - c1over54 ; (D.f[ dirTS ])[ks ] + (D.f[dirZERO])[k] = mfbbb;//(D.f[ dirZERO])[kzero] = mfbbb;// - c8over27 ; (D.f[ dirZERO])[k ] + (D.f[dirTNE])[k] = mfaaa;//(D.f[ dirTNE ])[ktne ] = mfaaa;// - c1over216; (D.f[ dirTNE ])[k ] + (D.f[dirTSE])[ks] = mfaca;//(D.f[ dirTSE ])[ktse ] = mfaca;// - c1over216; (D.f[ dirTSE ])[ks ] + (D.f[dirBNE])[kb] = mfaac;//(D.f[ dirBNE ])[kbne ] = mfaac;// - c1over216; (D.f[ dirBNE ])[kb ] + (D.f[dirBSE])[kbs] = mfacc;//(D.f[ dirBSE ])[kbse ] = mfacc;// - c1over216; (D.f[ dirBSE ])[kbs ] + (D.f[dirTNW])[kw] = mfcaa;//(D.f[ dirTNW ])[ktnw ] = mfcaa;// - c1over216; (D.f[ dirTNW ])[kw ] + (D.f[dirTSW])[ksw] = mfcca;//(D.f[ dirTSW ])[ktsw ] = mfcca;// - c1over216; (D.f[ dirTSW ])[ksw ] + (D.f[dirBNW])[kbw] = mfcac;//(D.f[ dirBNW ])[kbnw ] = mfcac;// - c1over216; (D.f[ dirBNW ])[kbw ] + (D.f[dirBSW])[kbsw] = mfccc;//(D.f[ dirBSW ])[kbsw ] = mfccc;// - c1over216; (D.f[ dirBSW ])[kbsw] + //////////////////////////////////////////////////////////////////////////////////// + } + } } //////////////////////////////////////////////////////////////////////////////// @@ -1000,758 +958,758 @@ extern "C" __global__ void Cumulant_One_preconditioned_errorDiffusion_chim_Comp_ //////////////////////////////////////////////////////////////////////////////// extern "C" __global__ void Cumulant_One_preconditioned_chim_Comp_SP_27( - real omega, - unsigned int* bcMatD, - unsigned int* neighborX, - unsigned int* neighborY, - unsigned int* neighborZ, - real* DDStart, - int size_Mat, - int level, - real* forces, - bool EvenOrOdd) + real omega, + unsigned int* bcMatD, + unsigned int* neighborX, + unsigned int* neighborY, + unsigned int* neighborZ, + real* DDStart, + int size_Mat, + int level, + real* forces, + bool EvenOrOdd) { - //////////////////////////////////////////////////////////////////////////////// - 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<size_Mat) - { - //////////////////////////////////////////////////////////////////////////////// - unsigned int BC; - BC = bcMatD[k]; - - if (BC >= GEO_FLUID/*(BC != GEO_SOLID) && (BC != GEO_VOID)*/) - { - Distributions27 D; - if (EvenOrOdd == true) - { - D.f[dirE] = &DDStart[dirE *size_Mat]; - D.f[dirW] = &DDStart[dirW *size_Mat]; - D.f[dirN] = &DDStart[dirN *size_Mat]; - D.f[dirS] = &DDStart[dirS *size_Mat]; - D.f[dirT] = &DDStart[dirT *size_Mat]; - D.f[dirB] = &DDStart[dirB *size_Mat]; - D.f[dirNE] = &DDStart[dirNE *size_Mat]; - D.f[dirSW] = &DDStart[dirSW *size_Mat]; - D.f[dirSE] = &DDStart[dirSE *size_Mat]; - D.f[dirNW] = &DDStart[dirNW *size_Mat]; - D.f[dirTE] = &DDStart[dirTE *size_Mat]; - D.f[dirBW] = &DDStart[dirBW *size_Mat]; - D.f[dirBE] = &DDStart[dirBE *size_Mat]; - D.f[dirTW] = &DDStart[dirTW *size_Mat]; - D.f[dirTN] = &DDStart[dirTN *size_Mat]; - D.f[dirBS] = &DDStart[dirBS *size_Mat]; - D.f[dirBN] = &DDStart[dirBN *size_Mat]; - D.f[dirTS] = &DDStart[dirTS *size_Mat]; - D.f[dirZERO] = &DDStart[dirZERO*size_Mat]; - D.f[dirTNE] = &DDStart[dirTNE *size_Mat]; - D.f[dirTSW] = &DDStart[dirTSW *size_Mat]; - D.f[dirTSE] = &DDStart[dirTSE *size_Mat]; - D.f[dirTNW] = &DDStart[dirTNW *size_Mat]; - D.f[dirBNE] = &DDStart[dirBNE *size_Mat]; - D.f[dirBSW] = &DDStart[dirBSW *size_Mat]; - D.f[dirBSE] = &DDStart[dirBSE *size_Mat]; - D.f[dirBNW] = &DDStart[dirBNW *size_Mat]; - } - else - { - D.f[dirW] = &DDStart[dirE *size_Mat]; - D.f[dirE] = &DDStart[dirW *size_Mat]; - D.f[dirS] = &DDStart[dirN *size_Mat]; - D.f[dirN] = &DDStart[dirS *size_Mat]; - D.f[dirB] = &DDStart[dirT *size_Mat]; - D.f[dirT] = &DDStart[dirB *size_Mat]; - D.f[dirSW] = &DDStart[dirNE *size_Mat]; - D.f[dirNE] = &DDStart[dirSW *size_Mat]; - D.f[dirNW] = &DDStart[dirSE *size_Mat]; - D.f[dirSE] = &DDStart[dirNW *size_Mat]; - D.f[dirBW] = &DDStart[dirTE *size_Mat]; - D.f[dirTE] = &DDStart[dirBW *size_Mat]; - D.f[dirTW] = &DDStart[dirBE *size_Mat]; - D.f[dirBE] = &DDStart[dirTW *size_Mat]; - D.f[dirBS] = &DDStart[dirTN *size_Mat]; - D.f[dirTN] = &DDStart[dirBS *size_Mat]; - D.f[dirTS] = &DDStart[dirBN *size_Mat]; - D.f[dirBN] = &DDStart[dirTS *size_Mat]; - D.f[dirZERO] = &DDStart[dirZERO*size_Mat]; - D.f[dirBSW] = &DDStart[dirTNE *size_Mat]; - D.f[dirBNE] = &DDStart[dirTSW *size_Mat]; - D.f[dirBNW] = &DDStart[dirTSE *size_Mat]; - D.f[dirBSE] = &DDStart[dirTNW *size_Mat]; - D.f[dirTSW] = &DDStart[dirBNE *size_Mat]; - D.f[dirTNE] = &DDStart[dirBSW *size_Mat]; - D.f[dirTNW] = &DDStart[dirBSE *size_Mat]; - D.f[dirTSE] = &DDStart[dirBNW *size_Mat]; - } - - //////////////////////////////////////////////////////////////////////////////// - //index - //unsigned int kzero= k; - //unsigned int ke = k; - unsigned int kw = neighborX[k]; - //unsigned int kn = k; - unsigned int ks = neighborY[k]; - //unsigned int kt = k; - unsigned int kb = neighborZ[k]; - unsigned int ksw = neighborY[kw]; - //unsigned int kne = k; - //unsigned int kse = ks; - //unsigned int knw = kw; - unsigned int kbw = neighborZ[kw]; - //unsigned int kte = k; - //unsigned int kbe = kb; - //unsigned int ktw = kw; - unsigned int kbs = neighborZ[ks]; - //unsigned int ktn = k; - //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 = k; - unsigned int kbsw = neighborZ[ksw]; - - - - ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - real mfcbb = (D.f[dirE])[k];//[ke ];// + c2over27 ;(D.f[dirE ])[k ];//ke - real mfabb = (D.f[dirW])[kw];//[kw ];// + c2over27 ;(D.f[dirW ])[kw ]; - real mfbcb = (D.f[dirN])[k];//[kn ];// + c2over27 ;(D.f[dirN ])[k ];//kn - real mfbab = (D.f[dirS])[ks];//[ks ];// + c2over27 ;(D.f[dirS ])[ks ]; - real mfbbc = (D.f[dirT])[k];//[kt ];// + c2over27 ;(D.f[dirT ])[k ];//kt - real mfbba = (D.f[dirB])[kb];//[kb ];// + c2over27 ;(D.f[dirB ])[kb ]; - real mfccb = (D.f[dirNE])[k];//[kne ];// + c1over54 ;(D.f[dirNE ])[k ];//kne - real mfaab = (D.f[dirSW])[ksw];//[ksw ];// + c1over54 ;(D.f[dirSW ])[ksw]; - real mfcab = (D.f[dirSE])[ks];//[kse ];// + c1over54 ;(D.f[dirSE ])[ks ];//kse - real mfacb = (D.f[dirNW])[kw];//[knw ];// + c1over54 ;(D.f[dirNW ])[kw ];//knw - real mfcbc = (D.f[dirTE])[k];//[kte ];// + c1over54 ;(D.f[dirTE ])[k ];//kte - real mfaba = (D.f[dirBW])[kbw];//[kbw ];// + c1over54 ;(D.f[dirBW ])[kbw]; - real mfcba = (D.f[dirBE])[kb];//[kbe ];// + c1over54 ;(D.f[dirBE ])[kb ];//kbe - real mfabc = (D.f[dirTW])[kw];//[ktw ];// + c1over54 ;(D.f[dirTW ])[kw ];//ktw - real mfbcc = (D.f[dirTN])[k];//[ktn ];// + c1over54 ;(D.f[dirTN ])[k ];//ktn - real mfbaa = (D.f[dirBS])[kbs];//[kbs ];// + c1over54 ;(D.f[dirBS ])[kbs]; - real mfbca = (D.f[dirBN])[kb];//[kbn ];// + c1over54 ;(D.f[dirBN ])[kb ];//kbn - real mfbac = (D.f[dirTS])[ks];//[kts ];// + c1over54 ;(D.f[dirTS ])[ks ];//kts - real mfbbb = (D.f[dirZERO])[k];//[kzero];// + c8over27 ;(D.f[dirZERO])[k ];//kzero - real mfccc = (D.f[dirTNE])[k];//[ktne ];// + c1over216;(D.f[dirTNE ])[k ];//ktne - real mfaac = (D.f[dirTSW])[ksw];//[ktsw ];// + c1over216;(D.f[dirTSW ])[ksw];//ktsw - real mfcac = (D.f[dirTSE])[ks];//[ktse ];// + c1over216;(D.f[dirTSE ])[ks ];//ktse - real mfacc = (D.f[dirTNW])[kw];//[ktnw ];// + c1over216;(D.f[dirTNW ])[kw ];//ktnw - real mfcca = (D.f[dirBNE])[kb];//[kbne ];// + c1over216;(D.f[dirBNE ])[kb ];//kbne - real mfaaa = (D.f[dirBSW])[kbsw];//[kbsw ];// + c1over216;(D.f[dirBSW ])[kbsw]; - real mfcaa = (D.f[dirBSE])[kbs];//[kbse ];// + c1over216;(D.f[dirBSE ])[kbs];//kbse - real mfaca = (D.f[dirBNW])[kbw];//[kbnw ];// + c1over216;(D.f[dirBNW ])[kbw];//kbnw - //////////////////////////////////////////////////////////////////////////////////// - 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 rho = c1o1 + drho; - //////////////////////////////////////////////////////////////////////////////////// - real vvx = ((((mfccc - mfaaa) + (mfcac - mfaca)) + ((mfcaa - mfacc) + (mfcca - mfaac))) + - (((mfcba - mfabc) + (mfcbc - mfaba)) + ((mfcab - mfacb) + (mfccb - mfaab))) + - (mfcbb - mfabb)) / rho; - real vvy = ((((mfccc - mfaaa) + (mfaca - mfcac)) + ((mfacc - mfcaa) + (mfcca - mfaac))) + - (((mfbca - mfbac) + (mfbcc - mfbaa)) + ((mfacb - mfcab) + (mfccb - mfaab))) + - (mfbcb - mfbab)) / rho; - real vvz = ((((mfccc - mfaaa) + (mfcac - mfaca)) + ((mfacc - mfcaa) + (mfaac - mfcca))) + - (((mfbac - mfbca) + (mfbcc - mfbaa)) + ((mfabc - mfcba) + (mfcbc - mfaba))) + - (mfbbc - mfbba)) / rho; - //////////////////////////////////////////////////////////////////////////////////// - //the force be with you - real fx = forces[0] / (pow((double)c2o1, (double)level)); //zero;//0.0032653/(pow(two,level)); //0.000000005;//(two/1600000.0) / 120.0; // - real fy = forces[1] / (pow((double)c2o1, (double)level)); //zero; - real fz = forces[2] / (pow((double)c2o1, (double)level)); //zero; - vvx += fx*c1o2; - vvy += fy*c1o2; - vvz += fz*c1o2; - //////////////////////////////////////////////////////////////////////////////////// - //real omega = omega_in; - //////////////////////////////////////////////////////////////////////////////////// - //fast - //real oMdrho = c1o1; // comp special - //real m0, m1, m2; - real vx2; - real vy2; - real vz2; - vx2 = vvx*vvx; - vy2 = vvy*vvy; - vz2 = vvz*vvz; - //////////////////////////////////////////////////////////////////////////////////// - //real wadjust; - //real qudricLimitP = c1o100;// * 0.0001f; - //real qudricLimitM = c1o100;// * 0.0001f; - //real qudricLimitD = c1o100;// * 0.001f; - //real s9 = minusomega; - //test - //s9 = 0.; - - - ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - real EQcbb = c0o1; - real EQabb = c0o1; - real EQbcb = c0o1; - real EQbab = c0o1; - real EQbbc = c0o1; - real EQbba = c0o1; - real EQccb = c0o1; - real EQaab = c0o1; - real EQcab = c0o1; - real EQacb = c0o1; - real EQcbc = c0o1; - real EQaba = c0o1; - real EQcba = c0o1; - real EQabc = c0o1; - real EQbcc = c0o1; - real EQbaa = c0o1; - real EQbca = c0o1; - real EQbac = c0o1; - real EQbbb = c0o1; - real EQccc = drho * c1o27; - real EQaac = drho * c1o3; - real EQcac = drho * c1o9; - real EQacc = drho * c1o9; - real EQcca = drho * c1o9; - real EQaaa = drho; - real EQcaa = drho * c1o3; - real EQaca = drho * c1o3; - //////////////////////////////////////////////////////////////////////////////////// - backwardChimeraWithK(EQaaa, EQaab, EQaac, vvz, vz2, c1o1); - backwardChimeraWithK(EQaca, EQacb, EQacc, vvz, vz2, c1o3); - /////////////////////////////////////////////////////////// - EQcaa = EQaca; EQcab = EQacb; EQcac = EQacc; - /////////////////////////////////////////////////////////// - backwardChimeraWithK(EQcca, EQccb, EQccc, vvz, vz2, c1o9); - - backwardChimeraWithK(EQaaa, EQaba, EQaca, vvy, vy2, c1o6); - backwardChimeraWithK(EQaab, EQabb, EQacb, vvy, vy2, c2o3); - backwardChimeraWithK(EQaac, EQabc, EQacc, vvy, vy2, c1o6); - backwardChimeraWithK(EQcaa, EQcba, EQcca, vvy, vy2, c1o18); - backwardChimeraWithK(EQcab, EQcbb, EQccb, vvy, vy2, c2o9); - backwardChimeraWithK(EQcac, EQcbc, EQccc, vvy, vy2, c1o18); - - backwardChimeraWithK(EQaaa, EQbaa, EQcaa, vvx, vx2, c1o36); - backwardChimeraWithK(EQaab, EQbab, EQcab, vvx, vx2, c1o9); - backwardChimeraWithK(EQaac, EQbac, EQcac, vvx, vx2, c1o36); - backwardChimeraWithK(EQaba, EQbba, EQcba, vvx, vx2, c1o9); - backwardChimeraWithK(EQabb, EQbbb, EQcbb, vvx, vx2, c4o9); - backwardChimeraWithK(EQabc, EQbbc, EQcbc, vvx, vx2, c1o9); - backwardChimeraWithK(EQaca, EQbca, EQcca, vvx, vx2, c1o36); - backwardChimeraWithK(EQacb, EQbcb, EQccb, vvx, vx2, c1o9); - backwardChimeraWithK(EQacc, EQbcc, EQccc, vvx, vx2, c1o36); - - //////////////////////////////////////////////////////////////////////////////////// - //Pre-condition - mfcbb -= EQcbb; - mfabb -= EQabb; - mfbcb -= EQbcb; - mfbab -= EQbab; - mfbbc -= EQbbc; - mfbba -= EQbba; - mfccb -= EQccb; - mfaab -= EQaab; - mfcab -= EQcab; - mfacb -= EQacb; - mfcbc -= EQcbc; - mfaba -= EQaba; - mfcba -= EQcba; - mfabc -= EQabc; - mfbcc -= EQbcc; - mfbaa -= EQbaa; - mfbca -= EQbca; - mfbac -= EQbac; - mfbbb -= EQbbb; - mfccc -= EQccc; - mfaac -= EQaac; - mfcac -= EQcac; - mfacc -= EQacc; - mfcca -= EQcca; - mfaaa -= EQaaa; - mfcaa -= EQcaa; - mfaca -= EQaca; - - //////////////////////////////////////////////////////////////////////////////////// - //Hin - //////////////////////////////////////////////////////////////////////////////////// - forwardChimera(mfaaa, mfaab, mfaac, vvz, vz2); - forwardChimera(mfaba, mfabb, mfabc, vvz, vz2); - forwardChimera(mfaca, mfacb, mfacc, vvz, vz2); - forwardChimera(mfbaa, mfbab, mfbac, vvz, vz2); - forwardChimera(mfbba, mfbbb, mfbbc, vvz, vz2); - forwardChimera(mfbca, mfbcb, mfbcc, vvz, vz2); - forwardChimera(mfcaa, mfcab, mfcac, vvz, vz2); - forwardChimera(mfcba, mfcbb, mfcbc, vvz, vz2); - forwardChimera(mfcca, mfccb, mfccc, vvz, vz2); - - forwardChimera(mfaaa, mfaba, mfaca, vvy, vy2); - forwardChimera(mfaab, mfabb, mfacb, vvy, vy2); - forwardChimera(mfaac, mfabc, mfacc, vvy, vy2); - forwardChimera(mfbaa, mfbba, mfbca, vvy, vy2); - forwardChimera(mfbab, mfbbb, mfbcb, vvy, vy2); - forwardChimera(mfbac, mfbbc, mfbcc, vvy, vy2); - forwardChimera(mfcaa, mfcba, mfcca, vvy, vy2); - forwardChimera(mfcab, mfcbb, mfccb, vvy, vy2); - forwardChimera(mfcac, mfcbc, mfccc, vvy, vy2); - - forwardChimera(mfaaa, mfbaa, mfcaa, vvx, vx2); - forwardChimera(mfaab, mfbab, mfcab, vvx, vx2); - forwardChimera(mfaac, mfbac, mfcac, vvx, vx2); - forwardChimera(mfaba, mfbba, mfcba, vvx, vx2); - forwardChimera(mfabb, mfbbb, mfcbb, vvx, vx2); - forwardChimera(mfabc, mfbbc, mfcbc, vvx, vx2); - forwardChimera(mfaca, mfbca, mfcca, vvx, vx2); - forwardChimera(mfacb, mfbcb, mfccb, vvx, vx2); - forwardChimera(mfacc, mfbcc, mfccc, vvx, vx2); - - ////////////////////////////////////////////////////////////////////////////////////// - ////Hin - ////////////////////////////////////////////////////////////////////////////////////// - //// mit 1/36, 1/9, 1/36, 1/9, 4/9, 1/9, 1/36, 1/9, 1/36 Konditionieren - ////////////////////////////////////////////////////////////////////////////////////// - //// Z - Dir - //forwardChimeraWithK(mfaaa, mfaab, mfaac, vvz, vz2, c1o36); - ////////////////////////////////////////////////////////////////////////////////////// - //forwardChimeraWithK(mfaba, mfabb, mfabc, vvz, vz2, c1o9); - ////////////////////////////////////////////////////////////////////////////////////// - //forwardChimeraWithK(mfaca, mfacb, mfacc, vvz, vz2, c1o36); - ////////////////////////////////////////////////////////////////////////////////////// - ////////////////////////////////////////////////////////////////////////////////////// - //forwardChimeraWithK(mfbaa, mfbab, mfbac, vvz, vz2, c1o9); - ////////////////////////////////////////////////////////////////////////////////////// - //forwardChimeraWithK(mfbba, mfbbb, mfbbc, vvz, vz2, c4o9); - ////////////////////////////////////////////////////////////////////////////////////// - //forwardChimeraWithK(mfbca, mfbcb, mfbcc, vvz, vz2, c1o9); - ////////////////////////////////////////////////////////////////////////////////////// - ////////////////////////////////////////////////////////////////////////////////////// - //forwardChimeraWithK(mfcaa, mfcab, mfcac, vvz, vz2, c1o36); - ////////////////////////////////////////////////////////////////////////////////////// - //forwardChimeraWithK(mfcba, mfcbb, mfcbc, vvz, vz2, c1o9); - ////////////////////////////////////////////////////////////////////////////////////// - //forwardChimeraWithK(mfcca, mfccb, mfccc, vvz, vz2, c1o36); - ////////////////////////////////////////////////////////////////////////////////////// - ////////////////////////////////////////////////////////////////////////////////////// - //// mit 1/6, 0, 1/18, 2/3, 0, 2/9, 1/6, 0, 1/18 Konditionieren - ////////////////////////////////////////////////////////////////////////////////////// - //// Y - Dir - //forwardChimeraWithK(mfaaa, mfaba, mfaca, vvy, vy2, c1o6); - ////////////////////////////////////////////////////////////////////////////////////// - //forwardChimera(mfaab, mfabb, mfacb, vvy, vy2); - ////////////////////////////////////////////////////////////////////////////////////// - //forwardChimeraWithK(mfaac, mfabc, mfacc, vvy, vy2, c1o18); - ////////////////////////////////////////////////////////////////////////////////////// - ////////////////////////////////////////////////////////////////////////////////////// - //forwardChimeraWithK(mfbaa, mfbba, mfbca, vvy, vy2, c2o3); - ////////////////////////////////////////////////////////////////////////////////////// - //forwardChimera(mfbab, mfbbb, mfbcb, vvy, vy2); - ////////////////////////////////////////////////////////////////////////////////////// - //forwardChimeraWithK(mfbac, mfbbc, mfbcc, vvy, vy2, c2o9); - ////////////////////////////////////////////////////////////////////////////////////// - ////////////////////////////////////////////////////////////////////////////////////// - //forwardChimeraWithK(mfcaa, mfcba, mfcca, vvy, vy2, c1o6); - ////////////////////////////////////////////////////////////////////////////////////// - //forwardChimera(mfcab, mfcbb, mfccb, vvy, vy2); - ////////////////////////////////////////////////////////////////////////////////////// - //forwardChimeraWithK(mfcac, mfcbc, mfccc, vvy, vy2, c1o18); - ////////////////////////////////////////////////////////////////////////////////////// - ////////////////////////////////////////////////////////////////////////////////////// - //// mit 1, 0, 1/3, 0, 0, 0, 1/3, 0, 1/9 Konditionieren - ////////////////////////////////////////////////////////////////////////////////////// - //// X - Dir - //forwardChimeraWithK(mfaaa, mfbaa, mfcaa, vvx, vx2, one); - ////////////////////////////////////////////////////////////////////////////////////// - //forwardChimera(mfaba, mfbba, mfcba, vvx, vx2); - ////////////////////////////////////////////////////////////////////////////////////// - //forwardChimeraWithK(mfaca, mfbca, mfcca, vvx, vx2, c1o3); - ////////////////////////////////////////////////////////////////////////////////////// - ////////////////////////////////////////////////////////////////////////////////////// - //forwardChimera(mfaab, mfbab, mfcab, vvx, vx2); - ////////////////////////////////////////////////////////////////////////////////////// - //forwardChimera(mfabb, mfbbb, mfcbb, vvx, vx2); - ////////////////////////////////////////////////////////////////////////////////////// - //forwardChimera(mfacb, mfbcb, mfccb, vvx, vx2); - ////////////////////////////////////////////////////////////////////////////////////// - ////////////////////////////////////////////////////////////////////////////////////// - //forwardChimeraWithK(mfaac, mfbac, mfcac, vvx, vx2, c1o3); - ////////////////////////////////////////////////////////////////////////////////////// - //forwardChimera(mfabc, mfbbc, mfcbc, vvx, vx2); - ////////////////////////////////////////////////////////////////////////////////////// - //forwardChimeraWithK(mfacc, mfbcc, mfccc, vvx, vx2, c1o9); - ////////////////////////////////////////////////////////////////////////////////////// - ////////////////////////////////////////////////////////////////////////////////////// - - - //////////////////////////////////////////////////////////////////////////////////// - // Cumulants - //////////////////////////////////////////////////////////////////////////////////// - real OxxPyyPzz = c1o1; //omega; // one; //set the bulk viscosity one is high / two is very low and zero is (too) high - - //////////////////////////////////////////////////////////// - //3. - ////////////////////////////// - real OxyyPxzz = c1o1; - real OxyyMxzz = c1o1; - //real Oxyz = c1o1; - //////////////////////////////////////////////////////////// - //4. - ////////////////////////////// - real O4 = c1o1; - //////////////////////////////////////////////////////////// - //5. - ////////////////////////////// - real O5 = c1o1; - //////////////////////////////////////////////////////////// - //6. - ////////////////////////////// - real O6 = c1o1; - //////////////////////////////////////////////////////////// - - - //central moments to cumulants - //4. - real CUMcbb = mfcbb - ((mfcaa + c1o3) * mfabb + c2o1 * mfbba * mfbab) / rho; - real CUMbcb = mfbcb - ((mfaca + c1o3) * mfbab + c2o1 * mfbba * mfabb) / rho; - real CUMbbc = mfbbc - ((mfaac + c1o3) * mfbba + c2o1 * mfbab * mfabb) / rho; - - real CUMcca = mfcca - (((mfcaa * mfaca + c2o1 * mfbba * mfbba) + c1o3 * (mfcaa + mfaca)) / rho - c1o9*(drho / rho)); - real CUMcac = mfcac - (((mfcaa * mfaac + c2o1 * mfbab * mfbab) + c1o3 * (mfcaa + mfaac)) / rho - c1o9*(drho / rho)); - real CUMacc = mfacc - (((mfaac * mfaca + c2o1 * mfabb * mfabb) + c1o3 * (mfaac + mfaca)) / rho - c1o9*(drho / rho)); - - //5. - real CUMbcc = mfbcc - ((mfaac * mfbca + mfaca * mfbac + c4o1 * mfabb * mfbbb + c2o1 * (mfbab * mfacb + mfbba * mfabc)) + c1o3 * (mfbca + mfbac)) / rho; - real CUMcbc = mfcbc - ((mfaac * mfcba + mfcaa * mfabc + c4o1 * mfbab * mfbbb + c2o1 * (mfabb * mfcab + mfbba * mfbac)) + c1o3 * (mfcba + mfabc)) / rho; - real CUMccb = mfccb - ((mfcaa * mfacb + mfaca * mfcab + c4o1 * mfbba * mfbbb + c2o1 * (mfbab * mfbca + mfabb * mfcba)) + c1o3 * (mfacb + mfcab)) / rho; - - //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)) / rho - + (c4o1 * (mfbab * mfbab * mfaca + mfabb * mfabb * mfcaa + mfbba * mfbba * mfaac) - + c2o1 * (mfcaa * mfaca * mfaac) - + c16o1 * mfbba * mfbab * mfabb) / (rho * rho) - - c1o3 * (mfacc + mfcac + mfcca) / rho - - c1o9 * (mfcaa + mfaca + mfaac) / rho - + (c2o1 * (mfbab * mfbab + mfabb * mfabb + mfbba * mfbba) - + (mfaac * mfaca + mfaac * mfcaa + mfaca * mfcaa) + c1o3 *(mfaac + mfaca + mfcaa)) / (rho * rho) * c2o3 - + c1o27*((drho * drho - drho) / (rho*rho))); - - - - - //2. - // linear combinations - real mxxPyyPzz = mfcaa + mfaca + mfaac; - real mxxMyy = mfcaa - mfaca; - real mxxMzz = mfcaa - mfaac; - - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //incl. correction (hat noch nicht so gut funktioniert...Optimierungsbedarf??) - { - real dxux = c1o2 * (-omega) *(mxxMyy + mxxMzz) + c1o2 * OxxPyyPzz * (mfaaa - mxxPyyPzz); - real dyuy = dxux + omega * c3o2 * mxxMyy; - real dzuz = dxux + omega * c3o2 * mxxMzz; - - //relax - mxxPyyPzz += OxxPyyPzz*(mfaaa - mxxPyyPzz) - c3o1 * (c1o1 - c1o2 * OxxPyyPzz) * (vx2 * dxux + vy2 * dyuy + vz2 * dzuz);//-magicBulk*OxxPyyPzz; - 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);//-magicBulk*OxxPyyPzz; - //mxxMyy += -(-omega) * (-mxxMyy); - //mxxMzz += -(-omega) * (-mxxMzz); - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - mfabb += omega * (-mfabb); - mfbab += omega * (-mfbab); - mfbba += omega * (-mfbba); - - ////////////////////////////////////////////////////////////////////////// - - // linear combinations back - mfcaa = c1o3 * (mxxMyy + mxxMzz + mxxPyyPzz); - mfaca = c1o3 * (-c2o1* mxxMyy + mxxMzz + mxxPyyPzz); - mfaac = c1o3 * (mxxMyy - c2o1* mxxMzz + mxxPyyPzz); - - //3. - // linear combinations - - real mxxyPyzz = mfcba + mfabc; - real mxxyMyzz = mfcba - mfabc; - - real mxxzPyyz = mfcab + mfacb; - real mxxzMyyz = mfcab - mfacb; - - real mxyyPxzz = mfbca + mfbac; - real mxyyMxzz = mfbca - mfbac; - - //relax - ////////////////////////////////////////////////////////////////////////// - mfbbb += OxyyMxzz * (-mfbbb); - mxxyPyzz += OxyyPxzz * (-mxxyPyzz); - mxxyMyzz += OxyyMxzz * (-mxxyMyzz); - mxxzPyyz += OxyyPxzz * (-mxxzPyyz); - mxxzMyyz += OxyyMxzz * (-mxxzMyyz); - mxyyPxzz += OxyyPxzz * (-mxyyPxzz); - mxyyMxzz += OxyyMxzz * (-mxyyMxzz); - ////////////////////////////////////////////////////////////////////////// - - 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. - ////////////////////////////////////////////////////////////////////////// - CUMacc += O4 * (-CUMacc); - CUMcac += O4 * (-CUMcac); - CUMcca += O4 * (-CUMcca); - - CUMbbc += O4 * (-CUMbbc); - CUMbcb += O4 * (-CUMbcb); - CUMcbb += O4 * (-CUMcbb); - ////////////////////////////////////////////////////////////////////////// - - - //5. - CUMbcc += O5 * (-CUMbcc); - CUMcbc += O5 * (-CUMcbc); - CUMccb += O5 * (-CUMccb); - - //6. - CUMccc += O6 * (-CUMccc); - - - - //back cumulants to central moments - //4. - mfcbb = CUMcbb + ((mfcaa + c1o3) * mfabb + c2o1 * mfbba * mfbab) / rho; - mfbcb = CUMbcb + ((mfaca + c1o3) * mfbab + c2o1 * mfbba * mfabb) / rho; - mfbbc = CUMbbc + ((mfaac + c1o3) * mfbba + c2o1 * mfbab * mfabb) / rho; - - mfcca = CUMcca + (((mfcaa * mfaca + c2o1 * mfbba * mfbba) + c1o3 * (mfcaa + mfaca)) / rho - c1o9*(drho / rho)); - mfcac = CUMcac + (((mfcaa * mfaac + c2o1 * mfbab * mfbab) + c1o3 * (mfcaa + mfaac)) / rho - c1o9*(drho / rho)); - mfacc = CUMacc + (((mfaac * mfaca + c2o1 * mfabb * mfabb) + c1o3 * (mfaac + mfaca)) / rho - c1o9*(drho / rho)); - - //5. - mfbcc = CUMbcc + ((mfaac * mfbca + mfaca * mfbac + c4o1 * mfabb * mfbbb + c2o1 * (mfbab * mfacb + mfbba * mfabc)) + c1o3 * (mfbca + mfbac)) / rho; - mfcbc = CUMcbc + ((mfaac * mfcba + mfcaa * mfabc + c4o1 * mfbab * mfbbb + c2o1 * (mfabb * mfcab + mfbba * mfbac)) + c1o3 * (mfcba + mfabc)) / rho; - mfccb = CUMccb + ((mfcaa * mfacb + mfaca * mfcab + c4o1 * mfbba * mfbbb + c2o1 * (mfbab * mfbca + mfabb * mfcba)) + c1o3 * (mfacb + mfcab)) / rho; - - //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)) / rho - + (c4o1 * (mfbab * mfbab * mfaca + mfabb * mfabb * mfcaa + mfbba * mfbba * mfaac) - + c2o1 * (mfcaa * mfaca * mfaac) - + c16o1 * mfbba * mfbab * mfabb) / (rho * rho) - - c1o3 * (mfacc + mfcac + mfcca) / rho - - c1o9 * (mfcaa + mfaca + mfaac) / rho - + (c2o1 * (mfbab * mfbab + mfabb * mfabb + mfbba * mfbba) - + (mfaac * mfaca + mfaac * mfcaa + mfaca * mfcaa) + c1o3 *(mfaac + mfaca + mfcaa)) / (rho * rho) * c2o3 - + c1o27*((drho * drho - drho) / (rho*rho))); - - //////////////////////////////////////////////////////////////////////////////////// - //the force be with you - mfbaa = -mfbaa; - mfaba = -mfaba; - mfaab = -mfaab; - //////////////////////////////////////////////////////////////////////////////////// - - - //////////////////////////////////////////////////////////////////////////////////// - //back - //////////////////////////////////////////////////////////////////////////////////// - backwardChimera(mfaaa, mfaab, mfaac, vvz, vz2); - backwardChimera(mfaba, mfabb, mfabc, vvz, vz2); - backwardChimera(mfaca, mfacb, mfacc, vvz, vz2); - backwardChimera(mfbaa, mfbab, mfbac, vvz, vz2); - backwardChimera(mfbba, mfbbb, mfbbc, vvz, vz2); - backwardChimera(mfbca, mfbcb, mfbcc, vvz, vz2); - backwardChimera(mfcaa, mfcab, mfcac, vvz, vz2); - backwardChimera(mfcba, mfcbb, mfcbc, vvz, vz2); - backwardChimera(mfcca, mfccb, mfccc, vvz, vz2); - - backwardChimera(mfaaa, mfaba, mfaca, vvy, vy2); - backwardChimera(mfaab, mfabb, mfacb, vvy, vy2); - backwardChimera(mfaac, mfabc, mfacc, vvy, vy2); - backwardChimera(mfbaa, mfbba, mfbca, vvy, vy2); - backwardChimera(mfbab, mfbbb, mfbcb, vvy, vy2); - backwardChimera(mfbac, mfbbc, mfbcc, vvy, vy2); - backwardChimera(mfcaa, mfcba, mfcca, vvy, vy2); - backwardChimera(mfcab, mfcbb, mfccb, vvy, vy2); - backwardChimera(mfcac, mfcbc, mfccc, vvy, vy2); - - backwardChimera(mfaaa, mfbaa, mfcaa, vvx, vx2); - backwardChimera(mfaab, mfbab, mfcab, vvx, vx2); - backwardChimera(mfaac, mfbac, mfcac, vvx, vx2); - backwardChimera(mfaba, mfbba, mfcba, vvx, vx2); - backwardChimera(mfabb, mfbbb, mfcbb, vvx, vx2); - backwardChimera(mfabc, mfbbc, mfcbc, vvx, vx2); - backwardChimera(mfaca, mfbca, mfcca, vvx, vx2); - backwardChimera(mfacb, mfbcb, mfccb, vvx, vx2); - backwardChimera(mfacc, mfbcc, mfccc, vvx, vx2); - - //////////////////////////////////////////////////////////////////////////////////// - mfcbb+=EQcbb; - mfabb+=EQabb; - mfbcb+=EQbcb; - mfbab+=EQbab; - mfbbc+=EQbbc; - mfbba+=EQbba; - mfccb+=EQccb; - mfaab+=EQaab; - mfcab+=EQcab; - mfacb+=EQacb; - mfcbc+=EQcbc; - mfaba+=EQaba; - mfcba+=EQcba; - mfabc+=EQabc; - mfbcc+=EQbcc; - mfbaa+=EQbaa; - mfbca+=EQbca; - mfbac+=EQbac; - mfbbb+=EQbbb; - mfccc+=EQccc; - mfaac+=EQaac; - mfcac+=EQcac; - mfacc+=EQacc; - mfcca+=EQcca; - mfaaa+=EQaaa; - mfcaa+=EQcaa; - mfaca+=EQaca; - - - ////////////////////////////////////////////////////////////////////////////////////// - ////back - ////////////////////////////////////////////////////////////////////////////////////// - ////mit 1, 0, 1/3, 0, 0, 0, 1/3, 0, 1/9 Konditionieren - ////////////////////////////////////////////////////////////////////////////////////// - //// Z - Dir - //backwardChimeraWithK(mfaaa, mfaab, mfaac, vvz, vz2, one); - ////////////////////////////////////////////////////////////////////////////////////// - //backwardChimera(mfaba, mfabb, mfabc, vvz, vz2); - ////////////////////////////////////////////////////////////////////////////////////// - //backwardChimeraWithK(mfaca, mfacb, mfacc, vvz, vz2, c1o3); - ////////////////////////////////////////////////////////////////////////////////////// - ////////////////////////////////////////////////////////////////////////////////////// - //backwardChimera(mfbaa, mfbab, mfbac, vvz, vz2); - ///////////b////////////////////////////////////////////////////////////////////////// - //backwardChimera(mfbba, mfbbb, mfbbc, vvz, vz2); - ///////////b////////////////////////////////////////////////////////////////////////// - //backwardChimera(mfbca, mfbcb, mfbcc, vvz, vz2); - ////////////////////////////////////////////////////////////////////////////////////// - ////////////////////////////////////////////////////////////////////////////////////// - //backwardChimeraWithK(mfcaa, mfcab, mfcac, vvz, vz2, c1o3); - ///////////c////////////////////////////////////////////////////////////////////////// - //backwardChimera(mfcba, mfcbb, mfcbc, vvz, vz2); - ///////////c////////////////////////////////////////////////////////////////////////// - //backwardChimeraWithK(mfcca, mfccb, mfccc, vvz, vz2, c1o9); - ////////////////////////////////////////////////////////////////////////////////////// - ////////////////////////////////////////////////////////////////////////////////////// - ////mit 1/6, 2/3, 1/6, 0, 0, 0, 1/18, 2/9, 1/18 Konditionieren - ////////////////////////////////////////////////////////////////////////////////////// - //// Y - Dir - //backwardChimeraWithK(mfaaa, mfaba, mfaca, vvy, vy2, c1o6); - ////////////////////////////////////////////////////////////////////////////////////// - //backwardChimeraWithK(mfaab, mfabb, mfacb, vvy, vy2, c2o3); - ////////////////////////////////////////////////////////////////////////////////////// - //backwardChimeraWithK(mfaac, mfabc, mfacc, vvy, vy2, c1o6); - ////////////////////////////////////////////////////////////////////////////////////// - ////////////////////////////////////////////////////////////////////////////////////// - //backwardChimera(mfbaa, mfbba, mfbca, vvz, vz2); - ///////////b////////////////////////////////////////////////////////////////////////// - //backwardChimera(mfbab, mfbbb, mfbcb, vvz, vz2); - ///////////b////////////////////////////////////////////////////////////////////////// - //backwardChimera(mfbac, mfbbc, mfbcc, vvz, vz2); - ////////////////////////////////////////////////////////////////////////////////////// - ////////////////////////////////////////////////////////////////////////////////////// - //backwardChimeraWithK(mfcaa, mfcba, mfcca, vvy, vy2, c1o18); - ///////////c////////////////////////////////////////////////////////////////////////// - //backwardChimeraWithK(mfcab, mfcbb, mfccb, vvy, vy2, c2o9); - ///////////c////////////////////////////////////////////////////////////////////////// - //backwardChimeraWithK(mfcac, mfcbc, mfccc, vvy, vy2, c1o18); - ////////////////////////////////////////////////////////////////////////////////////// - ////////////////////////////////////////////////////////////////////////////////////// - ////mit 1/36, 1/9, 1/36, 1/9, 4/9, 1/9, 1/36, 1/9, 1/36 Konditionieren - ////////////////////////////////////////////////////////////////////////////////////// - //// X - Dir - //backwardChimeraWithK(mfaaa, mfbaa, mfcaa, vvx, vx2, c1o36); - ////////////////////////////////////////////////////////////////////////////////////// - //backwardChimeraWithK(mfaba, mfbba, mfcba, vvx, vx2, c1o9); - ////////////////////////////////////////////////////////////////////////////////////// - //backwardChimeraWithK(mfaca, mfbca, mfcca, vvx, vx2, c1o36); - ////////////////////////////////////////////////////////////////////////////////////// - ////////////////////////////////////////////////////////////////////////////////////// - //backwardChimeraWithK(mfaab, mfbab, mfcab, vvx, vx2, c1o9); - /////////////b//////////////////////////////////////////////////////////////////////// - //backwardChimeraWithK(mfabb, mfbbb, mfcbb, vvx, vx2, c4o9); - /////////////b//////////////////////////////////////////////////////////////////////// - //backwardChimeraWithK(mfacb, mfbcb, mfccb, vvx, vx2, c1o9); - ////////////////////////////////////////////////////////////////////////////////////// - ////////////////////////////////////////////////////////////////////////////////////// - //backwardChimeraWithK(mfaac, mfbac, mfcac, vvx, vx2, c1o36); - /////////////c//////////////////////////////////////////////////////////////////////// - //backwardChimeraWithK(mfabc, mfbbc, mfcbc, vvx, vx2, c1o9); - /////////////c//////////////////////////////////////////////////////////////////////// - //backwardChimeraWithK(mfacc, mfbcc, mfccc, vvx, vx2, c1o36); - ////////////////////////////////////////////////////////////////////////////////////// - - ////////////////////////////////////////////////////////////////////////////////////// - real drhoPost = - ((((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; - mfbbb += drho - drhoPost; - //////////////////////////////////////////////////////////////////////////////////// - (D.f[dirE])[k] = mfabb;//(D.f[ dirE ])[ke ] = mfabb;// - c2over27 ; (D.f[ dirE ])[k ] - (D.f[dirW])[kw] = mfcbb;//(D.f[ dirW ])[kw ] = mfcbb;// - c2over27 ; (D.f[ dirW ])[kw ] - (D.f[dirN])[k] = mfbab;//(D.f[ dirN ])[kn ] = mfbab;// - c2over27 ; (D.f[ dirN ])[k ] - (D.f[dirS])[ks] = mfbcb;//(D.f[ dirS ])[ks ] = mfbcb;// - c2over27 ; (D.f[ dirS ])[ks ] - (D.f[dirT])[k] = mfbba;//(D.f[ dirT ])[kt ] = mfbba;// - c2over27 ; (D.f[ dirT ])[k ] - (D.f[dirB])[kb] = mfbbc;//(D.f[ dirB ])[kb ] = mfbbc;// - c2over27 ; (D.f[ dirB ])[kb ] - (D.f[dirNE])[k] = mfaab;//(D.f[ dirNE ])[kne ] = mfaab;// - c1over54 ; (D.f[ dirNE ])[k ] - (D.f[dirSW])[ksw] = mfccb;//(D.f[ dirSW ])[ksw ] = mfccb;// - c1over54 ; (D.f[ dirSW ])[ksw ] - (D.f[dirSE])[ks] = mfacb;//(D.f[ dirSE ])[kse ] = mfacb;// - c1over54 ; (D.f[ dirSE ])[ks ] - (D.f[dirNW])[kw] = mfcab;//(D.f[ dirNW ])[knw ] = mfcab;// - c1over54 ; (D.f[ dirNW ])[kw ] - (D.f[dirTE])[k] = mfaba;//(D.f[ dirTE ])[kte ] = mfaba;// - c1over54 ; (D.f[ dirTE ])[k ] - (D.f[dirBW])[kbw] = mfcbc;//(D.f[ dirBW ])[kbw ] = mfcbc;// - c1over54 ; (D.f[ dirBW ])[kbw ] - (D.f[dirBE])[kb] = mfabc;//(D.f[ dirBE ])[kbe ] = mfabc;// - c1over54 ; (D.f[ dirBE ])[kb ] - (D.f[dirTW])[kw] = mfcba;//(D.f[ dirTW ])[ktw ] = mfcba;// - c1over54 ; (D.f[ dirTW ])[kw ] - (D.f[dirTN])[k] = mfbaa;//(D.f[ dirTN ])[ktn ] = mfbaa;// - c1over54 ; (D.f[ dirTN ])[k ] - (D.f[dirBS])[kbs] = mfbcc;//(D.f[ dirBS ])[kbs ] = mfbcc;// - c1over54 ; (D.f[ dirBS ])[kbs ] - (D.f[dirBN])[kb] = mfbac;//(D.f[ dirBN ])[kbn ] = mfbac;// - c1over54 ; (D.f[ dirBN ])[kb ] - (D.f[dirTS])[ks] = mfbca;//(D.f[ dirTS ])[kts ] = mfbca;// - c1over54 ; (D.f[ dirTS ])[ks ] - (D.f[dirZERO])[k] = mfbbb;//(D.f[ dirZERO])[kzero] = mfbbb;// - c8over27 ; (D.f[ dirZERO])[k ] - (D.f[dirTNE])[k] = mfaaa;//(D.f[ dirTNE ])[ktne ] = mfaaa;// - c1over216; (D.f[ dirTNE ])[k ] - (D.f[dirTSE])[ks] = mfaca;//(D.f[ dirTSE ])[ktse ] = mfaca;// - c1over216; (D.f[ dirTSE ])[ks ] - (D.f[dirBNE])[kb] = mfaac;//(D.f[ dirBNE ])[kbne ] = mfaac;// - c1over216; (D.f[ dirBNE ])[kb ] - (D.f[dirBSE])[kbs] = mfacc;//(D.f[ dirBSE ])[kbse ] = mfacc;// - c1over216; (D.f[ dirBSE ])[kbs ] - (D.f[dirTNW])[kw] = mfcaa;//(D.f[ dirTNW ])[ktnw ] = mfcaa;// - c1over216; (D.f[ dirTNW ])[kw ] - (D.f[dirTSW])[ksw] = mfcca;//(D.f[ dirTSW ])[ktsw ] = mfcca;// - c1over216; (D.f[ dirTSW ])[ksw ] - (D.f[dirBNW])[kbw] = mfcac;//(D.f[ dirBNW ])[kbnw ] = mfcac;// - c1over216; (D.f[ dirBNW ])[kbw ] - (D.f[dirBSW])[kbsw] = mfccc;//(D.f[ dirBSW ])[kbsw ] = mfccc;// - c1over216; (D.f[ dirBSW ])[kbsw] - //////////////////////////////////////////////////////////////////////////////////// - } - } + //////////////////////////////////////////////////////////////////////////////// + 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<size_Mat) + { + //////////////////////////////////////////////////////////////////////////////// + unsigned int BC; + BC = bcMatD[k]; + + if (BC >= GEO_FLUID/*(BC != GEO_SOLID) && (BC != GEO_VOID)*/) + { + Distributions27 D; + if (EvenOrOdd == true) + { + D.f[dirE] = &DDStart[dirE *size_Mat]; + D.f[dirW] = &DDStart[dirW *size_Mat]; + D.f[dirN] = &DDStart[dirN *size_Mat]; + D.f[dirS] = &DDStart[dirS *size_Mat]; + D.f[dirT] = &DDStart[dirT *size_Mat]; + D.f[dirB] = &DDStart[dirB *size_Mat]; + D.f[dirNE] = &DDStart[dirNE *size_Mat]; + D.f[dirSW] = &DDStart[dirSW *size_Mat]; + D.f[dirSE] = &DDStart[dirSE *size_Mat]; + D.f[dirNW] = &DDStart[dirNW *size_Mat]; + D.f[dirTE] = &DDStart[dirTE *size_Mat]; + D.f[dirBW] = &DDStart[dirBW *size_Mat]; + D.f[dirBE] = &DDStart[dirBE *size_Mat]; + D.f[dirTW] = &DDStart[dirTW *size_Mat]; + D.f[dirTN] = &DDStart[dirTN *size_Mat]; + D.f[dirBS] = &DDStart[dirBS *size_Mat]; + D.f[dirBN] = &DDStart[dirBN *size_Mat]; + D.f[dirTS] = &DDStart[dirTS *size_Mat]; + D.f[dirZERO] = &DDStart[dirZERO*size_Mat]; + D.f[dirTNE] = &DDStart[dirTNE *size_Mat]; + D.f[dirTSW] = &DDStart[dirTSW *size_Mat]; + D.f[dirTSE] = &DDStart[dirTSE *size_Mat]; + D.f[dirTNW] = &DDStart[dirTNW *size_Mat]; + D.f[dirBNE] = &DDStart[dirBNE *size_Mat]; + D.f[dirBSW] = &DDStart[dirBSW *size_Mat]; + D.f[dirBSE] = &DDStart[dirBSE *size_Mat]; + D.f[dirBNW] = &DDStart[dirBNW *size_Mat]; + } + else + { + D.f[dirW] = &DDStart[dirE *size_Mat]; + D.f[dirE] = &DDStart[dirW *size_Mat]; + D.f[dirS] = &DDStart[dirN *size_Mat]; + D.f[dirN] = &DDStart[dirS *size_Mat]; + D.f[dirB] = &DDStart[dirT *size_Mat]; + D.f[dirT] = &DDStart[dirB *size_Mat]; + D.f[dirSW] = &DDStart[dirNE *size_Mat]; + D.f[dirNE] = &DDStart[dirSW *size_Mat]; + D.f[dirNW] = &DDStart[dirSE *size_Mat]; + D.f[dirSE] = &DDStart[dirNW *size_Mat]; + D.f[dirBW] = &DDStart[dirTE *size_Mat]; + D.f[dirTE] = &DDStart[dirBW *size_Mat]; + D.f[dirTW] = &DDStart[dirBE *size_Mat]; + D.f[dirBE] = &DDStart[dirTW *size_Mat]; + D.f[dirBS] = &DDStart[dirTN *size_Mat]; + D.f[dirTN] = &DDStart[dirBS *size_Mat]; + D.f[dirTS] = &DDStart[dirBN *size_Mat]; + D.f[dirBN] = &DDStart[dirTS *size_Mat]; + D.f[dirZERO] = &DDStart[dirZERO*size_Mat]; + D.f[dirBSW] = &DDStart[dirTNE *size_Mat]; + D.f[dirBNE] = &DDStart[dirTSW *size_Mat]; + D.f[dirBNW] = &DDStart[dirTSE *size_Mat]; + D.f[dirBSE] = &DDStart[dirTNW *size_Mat]; + D.f[dirTSW] = &DDStart[dirBNE *size_Mat]; + D.f[dirTNE] = &DDStart[dirBSW *size_Mat]; + D.f[dirTNW] = &DDStart[dirBSE *size_Mat]; + D.f[dirTSE] = &DDStart[dirBNW *size_Mat]; + } + + //////////////////////////////////////////////////////////////////////////////// + //index + //unsigned int kzero= k; + //unsigned int ke = k; + unsigned int kw = neighborX[k]; + //unsigned int kn = k; + unsigned int ks = neighborY[k]; + //unsigned int kt = k; + unsigned int kb = neighborZ[k]; + unsigned int ksw = neighborY[kw]; + //unsigned int kne = k; + //unsigned int kse = ks; + //unsigned int knw = kw; + unsigned int kbw = neighborZ[kw]; + //unsigned int kte = k; + //unsigned int kbe = kb; + //unsigned int ktw = kw; + unsigned int kbs = neighborZ[ks]; + //unsigned int ktn = k; + //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 = k; + unsigned int kbsw = neighborZ[ksw]; + + + + ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + real mfcbb = (D.f[dirE])[k];//[ke ];// + c2over27 ;(D.f[dirE ])[k ];//ke + real mfabb = (D.f[dirW])[kw];//[kw ];// + c2over27 ;(D.f[dirW ])[kw ]; + real mfbcb = (D.f[dirN])[k];//[kn ];// + c2over27 ;(D.f[dirN ])[k ];//kn + real mfbab = (D.f[dirS])[ks];//[ks ];// + c2over27 ;(D.f[dirS ])[ks ]; + real mfbbc = (D.f[dirT])[k];//[kt ];// + c2over27 ;(D.f[dirT ])[k ];//kt + real mfbba = (D.f[dirB])[kb];//[kb ];// + c2over27 ;(D.f[dirB ])[kb ]; + real mfccb = (D.f[dirNE])[k];//[kne ];// + c1over54 ;(D.f[dirNE ])[k ];//kne + real mfaab = (D.f[dirSW])[ksw];//[ksw ];// + c1over54 ;(D.f[dirSW ])[ksw]; + real mfcab = (D.f[dirSE])[ks];//[kse ];// + c1over54 ;(D.f[dirSE ])[ks ];//kse + real mfacb = (D.f[dirNW])[kw];//[knw ];// + c1over54 ;(D.f[dirNW ])[kw ];//knw + real mfcbc = (D.f[dirTE])[k];//[kte ];// + c1over54 ;(D.f[dirTE ])[k ];//kte + real mfaba = (D.f[dirBW])[kbw];//[kbw ];// + c1over54 ;(D.f[dirBW ])[kbw]; + real mfcba = (D.f[dirBE])[kb];//[kbe ];// + c1over54 ;(D.f[dirBE ])[kb ];//kbe + real mfabc = (D.f[dirTW])[kw];//[ktw ];// + c1over54 ;(D.f[dirTW ])[kw ];//ktw + real mfbcc = (D.f[dirTN])[k];//[ktn ];// + c1over54 ;(D.f[dirTN ])[k ];//ktn + real mfbaa = (D.f[dirBS])[kbs];//[kbs ];// + c1over54 ;(D.f[dirBS ])[kbs]; + real mfbca = (D.f[dirBN])[kb];//[kbn ];// + c1over54 ;(D.f[dirBN ])[kb ];//kbn + real mfbac = (D.f[dirTS])[ks];//[kts ];// + c1over54 ;(D.f[dirTS ])[ks ];//kts + real mfbbb = (D.f[dirZERO])[k];//[kzero];// + c8over27 ;(D.f[dirZERO])[k ];//kzero + real mfccc = (D.f[dirTNE])[k];//[ktne ];// + c1over216;(D.f[dirTNE ])[k ];//ktne + real mfaac = (D.f[dirTSW])[ksw];//[ktsw ];// + c1over216;(D.f[dirTSW ])[ksw];//ktsw + real mfcac = (D.f[dirTSE])[ks];//[ktse ];// + c1over216;(D.f[dirTSE ])[ks ];//ktse + real mfacc = (D.f[dirTNW])[kw];//[ktnw ];// + c1over216;(D.f[dirTNW ])[kw ];//ktnw + real mfcca = (D.f[dirBNE])[kb];//[kbne ];// + c1over216;(D.f[dirBNE ])[kb ];//kbne + real mfaaa = (D.f[dirBSW])[kbsw];//[kbsw ];// + c1over216;(D.f[dirBSW ])[kbsw]; + real mfcaa = (D.f[dirBSE])[kbs];//[kbse ];// + c1over216;(D.f[dirBSE ])[kbs];//kbse + real mfaca = (D.f[dirBNW])[kbw];//[kbnw ];// + c1over216;(D.f[dirBNW ])[kbw];//kbnw + //////////////////////////////////////////////////////////////////////////////////// + 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 rho = c1o1 + drho; + //////////////////////////////////////////////////////////////////////////////////// + real vvx = ((((mfccc - mfaaa) + (mfcac - mfaca)) + ((mfcaa - mfacc) + (mfcca - mfaac))) + + (((mfcba - mfabc) + (mfcbc - mfaba)) + ((mfcab - mfacb) + (mfccb - mfaab))) + + (mfcbb - mfabb)) / rho; + real vvy = ((((mfccc - mfaaa) + (mfaca - mfcac)) + ((mfacc - mfcaa) + (mfcca - mfaac))) + + (((mfbca - mfbac) + (mfbcc - mfbaa)) + ((mfacb - mfcab) + (mfccb - mfaab))) + + (mfbcb - mfbab)) / rho; + real vvz = ((((mfccc - mfaaa) + (mfcac - mfaca)) + ((mfacc - mfcaa) + (mfaac - mfcca))) + + (((mfbac - mfbca) + (mfbcc - mfbaa)) + ((mfabc - mfcba) + (mfcbc - mfaba))) + + (mfbbc - mfbba)) / rho; + //////////////////////////////////////////////////////////////////////////////////// + //the force be with you + real fx = forces[0] / (pow((double)c2o1, (double)level)); //zero;//0.0032653/(pow(two,level)); //0.000000005;//(two/1600000.0) / 120.0; // + real fy = forces[1] / (pow((double)c2o1, (double)level)); //zero; + real fz = forces[2] / (pow((double)c2o1, (double)level)); //zero; + vvx += fx*c1o2; + vvy += fy*c1o2; + vvz += fz*c1o2; + //////////////////////////////////////////////////////////////////////////////////// + //real omega = omega_in; + //////////////////////////////////////////////////////////////////////////////////// + //fast + //real oMdrho = c1o1; // comp special + //real m0, m1, m2; + real vx2; + real vy2; + real vz2; + vx2 = vvx*vvx; + vy2 = vvy*vvy; + vz2 = vvz*vvz; + //////////////////////////////////////////////////////////////////////////////////// + //real wadjust; + //real qudricLimitP = c1o100;// * 0.0001f; + //real qudricLimitM = c1o100;// * 0.0001f; + //real qudricLimitD = c1o100;// * 0.001f; + //real s9 = minusomega; + //test + //s9 = 0.; + + + ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + real EQcbb = c0o1; + real EQabb = c0o1; + real EQbcb = c0o1; + real EQbab = c0o1; + real EQbbc = c0o1; + real EQbba = c0o1; + real EQccb = c0o1; + real EQaab = c0o1; + real EQcab = c0o1; + real EQacb = c0o1; + real EQcbc = c0o1; + real EQaba = c0o1; + real EQcba = c0o1; + real EQabc = c0o1; + real EQbcc = c0o1; + real EQbaa = c0o1; + real EQbca = c0o1; + real EQbac = c0o1; + real EQbbb = c0o1; + real EQccc = drho * c1o27; + real EQaac = drho * c1o3; + real EQcac = drho * c1o9; + real EQacc = drho * c1o9; + real EQcca = drho * c1o9; + real EQaaa = drho; + real EQcaa = drho * c1o3; + real EQaca = drho * c1o3; + //////////////////////////////////////////////////////////////////////////////////// + vf::lbm::backwardChimeraWithK(EQaaa, EQaab, EQaac, vvz, vz2, c1o1); + vf::lbm::backwardChimeraWithK(EQaca, EQacb, EQacc, vvz, vz2, c1o3); + /////////////////////////////////////////////////////////// + EQcaa = EQaca; EQcab = EQacb; EQcac = EQacc; + /////////////////////////////////////////////////////////// + vf::lbm::backwardChimeraWithK(EQcca, EQccb, EQccc, vvz, vz2, c1o9); + + vf::lbm::backwardChimeraWithK(EQaaa, EQaba, EQaca, vvy, vy2, c1o6); + vf::lbm::backwardChimeraWithK(EQaab, EQabb, EQacb, vvy, vy2, c2o3); + vf::lbm::backwardChimeraWithK(EQaac, EQabc, EQacc, vvy, vy2, c1o6); + vf::lbm::backwardChimeraWithK(EQcaa, EQcba, EQcca, vvy, vy2, c1o18); + vf::lbm::backwardChimeraWithK(EQcab, EQcbb, EQccb, vvy, vy2, c2o9); + vf::lbm::backwardChimeraWithK(EQcac, EQcbc, EQccc, vvy, vy2, c1o18); + + vf::lbm::backwardChimeraWithK(EQaaa, EQbaa, EQcaa, vvx, vx2, c1o36); + vf::lbm::backwardChimeraWithK(EQaab, EQbab, EQcab, vvx, vx2, c1o9); + vf::lbm::backwardChimeraWithK(EQaac, EQbac, EQcac, vvx, vx2, c1o36); + vf::lbm::backwardChimeraWithK(EQaba, EQbba, EQcba, vvx, vx2, c1o9); + vf::lbm::backwardChimeraWithK(EQabb, EQbbb, EQcbb, vvx, vx2, c4o9); + vf::lbm::backwardChimeraWithK(EQabc, EQbbc, EQcbc, vvx, vx2, c1o9); + vf::lbm::backwardChimeraWithK(EQaca, EQbca, EQcca, vvx, vx2, c1o36); + vf::lbm::backwardChimeraWithK(EQacb, EQbcb, EQccb, vvx, vx2, c1o9); + vf::lbm::backwardChimeraWithK(EQacc, EQbcc, EQccc, vvx, vx2, c1o36); + + //////////////////////////////////////////////////////////////////////////////////// + //Pre-condition + mfcbb -= EQcbb; + mfabb -= EQabb; + mfbcb -= EQbcb; + mfbab -= EQbab; + mfbbc -= EQbbc; + mfbba -= EQbba; + mfccb -= EQccb; + mfaab -= EQaab; + mfcab -= EQcab; + mfacb -= EQacb; + mfcbc -= EQcbc; + mfaba -= EQaba; + mfcba -= EQcba; + mfabc -= EQabc; + mfbcc -= EQbcc; + mfbaa -= EQbaa; + mfbca -= EQbca; + mfbac -= EQbac; + mfbbb -= EQbbb; + mfccc -= EQccc; + mfaac -= EQaac; + mfcac -= EQcac; + mfacc -= EQacc; + mfcca -= EQcca; + mfaaa -= EQaaa; + mfcaa -= EQcaa; + mfaca -= EQaca; + + //////////////////////////////////////////////////////////////////////////////////// + //Hin + //////////////////////////////////////////////////////////////////////////////////// + vf::lbm::forwardChimera(mfaaa, mfaab, mfaac, vvz, vz2); + vf::lbm::forwardChimera(mfaba, mfabb, mfabc, vvz, vz2); + vf::lbm::forwardChimera(mfaca, mfacb, mfacc, vvz, vz2); + vf::lbm::forwardChimera(mfbaa, mfbab, mfbac, vvz, vz2); + vf::lbm::forwardChimera(mfbba, mfbbb, mfbbc, vvz, vz2); + vf::lbm::forwardChimera(mfbca, mfbcb, mfbcc, vvz, vz2); + vf::lbm::forwardChimera(mfcaa, mfcab, mfcac, vvz, vz2); + vf::lbm::forwardChimera(mfcba, mfcbb, mfcbc, vvz, vz2); + vf::lbm::forwardChimera(mfcca, mfccb, mfccc, vvz, vz2); + + vf::lbm::forwardChimera(mfaaa, mfaba, mfaca, vvy, vy2); + vf::lbm::forwardChimera(mfaab, mfabb, mfacb, vvy, vy2); + vf::lbm::forwardChimera(mfaac, mfabc, mfacc, vvy, vy2); + vf::lbm::forwardChimera(mfbaa, mfbba, mfbca, vvy, vy2); + vf::lbm::forwardChimera(mfbab, mfbbb, mfbcb, vvy, vy2); + vf::lbm::forwardChimera(mfbac, mfbbc, mfbcc, vvy, vy2); + vf::lbm::forwardChimera(mfcaa, mfcba, mfcca, vvy, vy2); + vf::lbm::forwardChimera(mfcab, mfcbb, mfccb, vvy, vy2); + vf::lbm::forwardChimera(mfcac, mfcbc, mfccc, vvy, vy2); + + vf::lbm::forwardChimera(mfaaa, mfbaa, mfcaa, vvx, vx2); + vf::lbm::forwardChimera(mfaab, mfbab, mfcab, vvx, vx2); + vf::lbm::forwardChimera(mfaac, mfbac, mfcac, vvx, vx2); + vf::lbm::forwardChimera(mfaba, mfbba, mfcba, vvx, vx2); + vf::lbm::forwardChimera(mfabb, mfbbb, mfcbb, vvx, vx2); + vf::lbm::forwardChimera(mfabc, mfbbc, mfcbc, vvx, vx2); + vf::lbm::forwardChimera(mfaca, mfbca, mfcca, vvx, vx2); + vf::lbm::forwardChimera(mfacb, mfbcb, mfccb, vvx, vx2); + vf::lbm::forwardChimera(mfacc, mfbcc, mfccc, vvx, vx2); + + ////////////////////////////////////////////////////////////////////////////////////// + ////Hin + ////////////////////////////////////////////////////////////////////////////////////// + //// mit 1/36, 1/9, 1/36, 1/9, 4/9, 1/9, 1/36, 1/9, 1/36 Konditionieren + ////////////////////////////////////////////////////////////////////////////////////// + //// Z - Dir + //forwardChimeraWithK(mfaaa, mfaab, mfaac, vvz, vz2, c1o36); + ////////////////////////////////////////////////////////////////////////////////////// + //forwardChimeraWithK(mfaba, mfabb, mfabc, vvz, vz2, c1o9); + ////////////////////////////////////////////////////////////////////////////////////// + //forwardChimeraWithK(mfaca, mfacb, mfacc, vvz, vz2, c1o36); + ////////////////////////////////////////////////////////////////////////////////////// + ////////////////////////////////////////////////////////////////////////////////////// + //forwardChimeraWithK(mfbaa, mfbab, mfbac, vvz, vz2, c1o9); + ////////////////////////////////////////////////////////////////////////////////////// + //forwardChimeraWithK(mfbba, mfbbb, mfbbc, vvz, vz2, c4o9); + ////////////////////////////////////////////////////////////////////////////////////// + //forwardChimeraWithK(mfbca, mfbcb, mfbcc, vvz, vz2, c1o9); + ////////////////////////////////////////////////////////////////////////////////////// + ////////////////////////////////////////////////////////////////////////////////////// + //forwardChimeraWithK(mfcaa, mfcab, mfcac, vvz, vz2, c1o36); + ////////////////////////////////////////////////////////////////////////////////////// + //forwardChimeraWithK(mfcba, mfcbb, mfcbc, vvz, vz2, c1o9); + ////////////////////////////////////////////////////////////////////////////////////// + //forwardChimeraWithK(mfcca, mfccb, mfccc, vvz, vz2, c1o36); + ////////////////////////////////////////////////////////////////////////////////////// + ////////////////////////////////////////////////////////////////////////////////////// + //// mit 1/6, 0, 1/18, 2/3, 0, 2/9, 1/6, 0, 1/18 Konditionieren + ////////////////////////////////////////////////////////////////////////////////////// + //// Y - Dir + //forwardChimeraWithK(mfaaa, mfaba, mfaca, vvy, vy2, c1o6); + ////////////////////////////////////////////////////////////////////////////////////// + //forwardChimera(mfaab, mfabb, mfacb, vvy, vy2); + ////////////////////////////////////////////////////////////////////////////////////// + //forwardChimeraWithK(mfaac, mfabc, mfacc, vvy, vy2, c1o18); + ////////////////////////////////////////////////////////////////////////////////////// + ////////////////////////////////////////////////////////////////////////////////////// + //forwardChimeraWithK(mfbaa, mfbba, mfbca, vvy, vy2, c2o3); + ////////////////////////////////////////////////////////////////////////////////////// + //forwardChimera(mfbab, mfbbb, mfbcb, vvy, vy2); + ////////////////////////////////////////////////////////////////////////////////////// + //forwardChimeraWithK(mfbac, mfbbc, mfbcc, vvy, vy2, c2o9); + ////////////////////////////////////////////////////////////////////////////////////// + ////////////////////////////////////////////////////////////////////////////////////// + //forwardChimeraWithK(mfcaa, mfcba, mfcca, vvy, vy2, c1o6); + ////////////////////////////////////////////////////////////////////////////////////// + //forwardChimera(mfcab, mfcbb, mfccb, vvy, vy2); + ////////////////////////////////////////////////////////////////////////////////////// + //forwardChimeraWithK(mfcac, mfcbc, mfccc, vvy, vy2, c1o18); + ////////////////////////////////////////////////////////////////////////////////////// + ////////////////////////////////////////////////////////////////////////////////////// + //// mit 1, 0, 1/3, 0, 0, 0, 1/3, 0, 1/9 Konditionieren + ////////////////////////////////////////////////////////////////////////////////////// + //// X - Dir + //forwardChimeraWithK(mfaaa, mfbaa, mfcaa, vvx, vx2, one); + ////////////////////////////////////////////////////////////////////////////////////// + //forwardChimera(mfaba, mfbba, mfcba, vvx, vx2); + ////////////////////////////////////////////////////////////////////////////////////// + //forwardChimeraWithK(mfaca, mfbca, mfcca, vvx, vx2, c1o3); + ////////////////////////////////////////////////////////////////////////////////////// + ////////////////////////////////////////////////////////////////////////////////////// + //forwardChimera(mfaab, mfbab, mfcab, vvx, vx2); + ////////////////////////////////////////////////////////////////////////////////////// + //forwardChimera(mfabb, mfbbb, mfcbb, vvx, vx2); + ////////////////////////////////////////////////////////////////////////////////////// + //forwardChimera(mfacb, mfbcb, mfccb, vvx, vx2); + ////////////////////////////////////////////////////////////////////////////////////// + ////////////////////////////////////////////////////////////////////////////////////// + //forwardChimeraWithK(mfaac, mfbac, mfcac, vvx, vx2, c1o3); + ////////////////////////////////////////////////////////////////////////////////////// + //forwardChimera(mfabc, mfbbc, mfcbc, vvx, vx2); + ////////////////////////////////////////////////////////////////////////////////////// + //forwardChimeraWithK(mfacc, mfbcc, mfccc, vvx, vx2, c1o9); + ////////////////////////////////////////////////////////////////////////////////////// + ////////////////////////////////////////////////////////////////////////////////////// + + + //////////////////////////////////////////////////////////////////////////////////// + // Cumulants + //////////////////////////////////////////////////////////////////////////////////// + real OxxPyyPzz = c1o1; //omega; // one; //set the bulk viscosity one is high / two is very low and zero is (too) high + + //////////////////////////////////////////////////////////// + //3. + ////////////////////////////// + real OxyyPxzz = c1o1; + real OxyyMxzz = c1o1; + //real Oxyz = c1o1; + //////////////////////////////////////////////////////////// + //4. + ////////////////////////////// + real O4 = c1o1; + //////////////////////////////////////////////////////////// + //5. + ////////////////////////////// + real O5 = c1o1; + //////////////////////////////////////////////////////////// + //6. + ////////////////////////////// + real O6 = c1o1; + //////////////////////////////////////////////////////////// + + + //central moments to cumulants + //4. + real CUMcbb = mfcbb - ((mfcaa + c1o3) * mfabb + c2o1 * mfbba * mfbab) / rho; + real CUMbcb = mfbcb - ((mfaca + c1o3) * mfbab + c2o1 * mfbba * mfabb) / rho; + real CUMbbc = mfbbc - ((mfaac + c1o3) * mfbba + c2o1 * mfbab * mfabb) / rho; + + real CUMcca = mfcca - (((mfcaa * mfaca + c2o1 * mfbba * mfbba) + c1o3 * (mfcaa + mfaca)) / rho - c1o9*(drho / rho)); + real CUMcac = mfcac - (((mfcaa * mfaac + c2o1 * mfbab * mfbab) + c1o3 * (mfcaa + mfaac)) / rho - c1o9*(drho / rho)); + real CUMacc = mfacc - (((mfaac * mfaca + c2o1 * mfabb * mfabb) + c1o3 * (mfaac + mfaca)) / rho - c1o9*(drho / rho)); + + //5. + real CUMbcc = mfbcc - ((mfaac * mfbca + mfaca * mfbac + c4o1 * mfabb * mfbbb + c2o1 * (mfbab * mfacb + mfbba * mfabc)) + c1o3 * (mfbca + mfbac)) / rho; + real CUMcbc = mfcbc - ((mfaac * mfcba + mfcaa * mfabc + c4o1 * mfbab * mfbbb + c2o1 * (mfabb * mfcab + mfbba * mfbac)) + c1o3 * (mfcba + mfabc)) / rho; + real CUMccb = mfccb - ((mfcaa * mfacb + mfaca * mfcab + c4o1 * mfbba * mfbbb + c2o1 * (mfbab * mfbca + mfabb * mfcba)) + c1o3 * (mfacb + mfcab)) / rho; + + //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)) / rho + + (c4o1 * (mfbab * mfbab * mfaca + mfabb * mfabb * mfcaa + mfbba * mfbba * mfaac) + + c2o1 * (mfcaa * mfaca * mfaac) + + c16o1 * mfbba * mfbab * mfabb) / (rho * rho) + - c1o3 * (mfacc + mfcac + mfcca) / rho + - c1o9 * (mfcaa + mfaca + mfaac) / rho + + (c2o1 * (mfbab * mfbab + mfabb * mfabb + mfbba * mfbba) + + (mfaac * mfaca + mfaac * mfcaa + mfaca * mfcaa) + c1o3 *(mfaac + mfaca + mfcaa)) / (rho * rho) * c2o3 + + c1o27*((drho * drho - drho) / (rho*rho))); + + + + + //2. + // linear combinations + real mxxPyyPzz = mfcaa + mfaca + mfaac; + real mxxMyy = mfcaa - mfaca; + real mxxMzz = mfcaa - mfaac; + + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //incl. correction (hat noch nicht so gut funktioniert...Optimierungsbedarf??) + { + real dxux = c1o2 * (-omega) *(mxxMyy + mxxMzz) + c1o2 * OxxPyyPzz * (mfaaa - mxxPyyPzz); + real dyuy = dxux + omega * c3o2 * mxxMyy; + real dzuz = dxux + omega * c3o2 * mxxMzz; + + //relax + mxxPyyPzz += OxxPyyPzz*(mfaaa - mxxPyyPzz) - c3o1 * (c1o1 - c1o2 * OxxPyyPzz) * (vx2 * dxux + vy2 * dyuy + vz2 * dzuz);//-magicBulk*OxxPyyPzz; + 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);//-magicBulk*OxxPyyPzz; + //mxxMyy += -(-omega) * (-mxxMyy); + //mxxMzz += -(-omega) * (-mxxMzz); + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + mfabb += omega * (-mfabb); + mfbab += omega * (-mfbab); + mfbba += omega * (-mfbba); + + ////////////////////////////////////////////////////////////////////////// + + // linear combinations back + mfcaa = c1o3 * (mxxMyy + mxxMzz + mxxPyyPzz); + mfaca = c1o3 * (-c2o1* mxxMyy + mxxMzz + mxxPyyPzz); + mfaac = c1o3 * (mxxMyy - c2o1* mxxMzz + mxxPyyPzz); + + //3. + // linear combinations + + real mxxyPyzz = mfcba + mfabc; + real mxxyMyzz = mfcba - mfabc; + + real mxxzPyyz = mfcab + mfacb; + real mxxzMyyz = mfcab - mfacb; + + real mxyyPxzz = mfbca + mfbac; + real mxyyMxzz = mfbca - mfbac; + + //relax + ////////////////////////////////////////////////////////////////////////// + mfbbb += OxyyMxzz * (-mfbbb); + mxxyPyzz += OxyyPxzz * (-mxxyPyzz); + mxxyMyzz += OxyyMxzz * (-mxxyMyzz); + mxxzPyyz += OxyyPxzz * (-mxxzPyyz); + mxxzMyyz += OxyyMxzz * (-mxxzMyyz); + mxyyPxzz += OxyyPxzz * (-mxyyPxzz); + mxyyMxzz += OxyyMxzz * (-mxyyMxzz); + ////////////////////////////////////////////////////////////////////////// + + 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. + ////////////////////////////////////////////////////////////////////////// + CUMacc += O4 * (-CUMacc); + CUMcac += O4 * (-CUMcac); + CUMcca += O4 * (-CUMcca); + + CUMbbc += O4 * (-CUMbbc); + CUMbcb += O4 * (-CUMbcb); + CUMcbb += O4 * (-CUMcbb); + ////////////////////////////////////////////////////////////////////////// + + + //5. + CUMbcc += O5 * (-CUMbcc); + CUMcbc += O5 * (-CUMcbc); + CUMccb += O5 * (-CUMccb); + + //6. + CUMccc += O6 * (-CUMccc); + + + + //back cumulants to central moments + //4. + mfcbb = CUMcbb + ((mfcaa + c1o3) * mfabb + c2o1 * mfbba * mfbab) / rho; + mfbcb = CUMbcb + ((mfaca + c1o3) * mfbab + c2o1 * mfbba * mfabb) / rho; + mfbbc = CUMbbc + ((mfaac + c1o3) * mfbba + c2o1 * mfbab * mfabb) / rho; + + mfcca = CUMcca + (((mfcaa * mfaca + c2o1 * mfbba * mfbba) + c1o3 * (mfcaa + mfaca)) / rho - c1o9*(drho / rho)); + mfcac = CUMcac + (((mfcaa * mfaac + c2o1 * mfbab * mfbab) + c1o3 * (mfcaa + mfaac)) / rho - c1o9*(drho / rho)); + mfacc = CUMacc + (((mfaac * mfaca + c2o1 * mfabb * mfabb) + c1o3 * (mfaac + mfaca)) / rho - c1o9*(drho / rho)); + + //5. + mfbcc = CUMbcc + ((mfaac * mfbca + mfaca * mfbac + c4o1 * mfabb * mfbbb + c2o1 * (mfbab * mfacb + mfbba * mfabc)) + c1o3 * (mfbca + mfbac)) / rho; + mfcbc = CUMcbc + ((mfaac * mfcba + mfcaa * mfabc + c4o1 * mfbab * mfbbb + c2o1 * (mfabb * mfcab + mfbba * mfbac)) + c1o3 * (mfcba + mfabc)) / rho; + mfccb = CUMccb + ((mfcaa * mfacb + mfaca * mfcab + c4o1 * mfbba * mfbbb + c2o1 * (mfbab * mfbca + mfabb * mfcba)) + c1o3 * (mfacb + mfcab)) / rho; + + //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)) / rho + + (c4o1 * (mfbab * mfbab * mfaca + mfabb * mfabb * mfcaa + mfbba * mfbba * mfaac) + + c2o1 * (mfcaa * mfaca * mfaac) + + c16o1 * mfbba * mfbab * mfabb) / (rho * rho) + - c1o3 * (mfacc + mfcac + mfcca) / rho + - c1o9 * (mfcaa + mfaca + mfaac) / rho + + (c2o1 * (mfbab * mfbab + mfabb * mfabb + mfbba * mfbba) + + (mfaac * mfaca + mfaac * mfcaa + mfaca * mfcaa) + c1o3 *(mfaac + mfaca + mfcaa)) / (rho * rho) * c2o3 + + c1o27*((drho * drho - drho) / (rho*rho))); + + //////////////////////////////////////////////////////////////////////////////////// + //the force be with you + mfbaa = -mfbaa; + mfaba = -mfaba; + mfaab = -mfaab; + //////////////////////////////////////////////////////////////////////////////////// + + + //////////////////////////////////////////////////////////////////////////////////// + //back + //////////////////////////////////////////////////////////////////////////////////// + vf::lbm::backwardChimera(mfaaa, mfaab, mfaac, vvz, vz2); + vf::lbm::backwardChimera(mfaba, mfabb, mfabc, vvz, vz2); + vf::lbm::backwardChimera(mfaca, mfacb, mfacc, vvz, vz2); + vf::lbm::backwardChimera(mfbaa, mfbab, mfbac, vvz, vz2); + vf::lbm::backwardChimera(mfbba, mfbbb, mfbbc, vvz, vz2); + vf::lbm::backwardChimera(mfbca, mfbcb, mfbcc, vvz, vz2); + vf::lbm::backwardChimera(mfcaa, mfcab, mfcac, vvz, vz2); + vf::lbm::backwardChimera(mfcba, mfcbb, mfcbc, vvz, vz2); + vf::lbm::backwardChimera(mfcca, mfccb, mfccc, vvz, vz2); + + vf::lbm::backwardChimera(mfaaa, mfaba, mfaca, vvy, vy2); + vf::lbm::backwardChimera(mfaab, mfabb, mfacb, vvy, vy2); + vf::lbm::backwardChimera(mfaac, mfabc, mfacc, vvy, vy2); + vf::lbm::backwardChimera(mfbaa, mfbba, mfbca, vvy, vy2); + vf::lbm::backwardChimera(mfbab, mfbbb, mfbcb, vvy, vy2); + vf::lbm::backwardChimera(mfbac, mfbbc, mfbcc, vvy, vy2); + vf::lbm::backwardChimera(mfcaa, mfcba, mfcca, vvy, vy2); + vf::lbm::backwardChimera(mfcab, mfcbb, mfccb, vvy, vy2); + vf::lbm::backwardChimera(mfcac, mfcbc, mfccc, vvy, vy2); + + vf::lbm::backwardChimera(mfaaa, mfbaa, mfcaa, vvx, vx2); + vf::lbm::backwardChimera(mfaab, mfbab, mfcab, vvx, vx2); + vf::lbm::backwardChimera(mfaac, mfbac, mfcac, vvx, vx2); + vf::lbm::backwardChimera(mfaba, mfbba, mfcba, vvx, vx2); + vf::lbm::backwardChimera(mfabb, mfbbb, mfcbb, vvx, vx2); + vf::lbm::backwardChimera(mfabc, mfbbc, mfcbc, vvx, vx2); + vf::lbm::backwardChimera(mfaca, mfbca, mfcca, vvx, vx2); + vf::lbm::backwardChimera(mfacb, mfbcb, mfccb, vvx, vx2); + vf::lbm::backwardChimera(mfacc, mfbcc, mfccc, vvx, vx2); + + //////////////////////////////////////////////////////////////////////////////////// + mfcbb+=EQcbb; + mfabb+=EQabb; + mfbcb+=EQbcb; + mfbab+=EQbab; + mfbbc+=EQbbc; + mfbba+=EQbba; + mfccb+=EQccb; + mfaab+=EQaab; + mfcab+=EQcab; + mfacb+=EQacb; + mfcbc+=EQcbc; + mfaba+=EQaba; + mfcba+=EQcba; + mfabc+=EQabc; + mfbcc+=EQbcc; + mfbaa+=EQbaa; + mfbca+=EQbca; + mfbac+=EQbac; + mfbbb+=EQbbb; + mfccc+=EQccc; + mfaac+=EQaac; + mfcac+=EQcac; + mfacc+=EQacc; + mfcca+=EQcca; + mfaaa+=EQaaa; + mfcaa+=EQcaa; + mfaca+=EQaca; + + + ////////////////////////////////////////////////////////////////////////////////////// + ////back + ////////////////////////////////////////////////////////////////////////////////////// + ////mit 1, 0, 1/3, 0, 0, 0, 1/3, 0, 1/9 Konditionieren + ////////////////////////////////////////////////////////////////////////////////////// + //// Z - Dir + //backwardChimeraWithK(mfaaa, mfaab, mfaac, vvz, vz2, one); + ////////////////////////////////////////////////////////////////////////////////////// + //backwardChimera(mfaba, mfabb, mfabc, vvz, vz2); + ////////////////////////////////////////////////////////////////////////////////////// + //backwardChimeraWithK(mfaca, mfacb, mfacc, vvz, vz2, c1o3); + ////////////////////////////////////////////////////////////////////////////////////// + ////////////////////////////////////////////////////////////////////////////////////// + //backwardChimera(mfbaa, mfbab, mfbac, vvz, vz2); + ///////////b////////////////////////////////////////////////////////////////////////// + //backwardChimera(mfbba, mfbbb, mfbbc, vvz, vz2); + ///////////b////////////////////////////////////////////////////////////////////////// + //backwardChimera(mfbca, mfbcb, mfbcc, vvz, vz2); + ////////////////////////////////////////////////////////////////////////////////////// + ////////////////////////////////////////////////////////////////////////////////////// + //backwardChimeraWithK(mfcaa, mfcab, mfcac, vvz, vz2, c1o3); + ///////////c////////////////////////////////////////////////////////////////////////// + //backwardChimera(mfcba, mfcbb, mfcbc, vvz, vz2); + ///////////c////////////////////////////////////////////////////////////////////////// + //backwardChimeraWithK(mfcca, mfccb, mfccc, vvz, vz2, c1o9); + ////////////////////////////////////////////////////////////////////////////////////// + ////////////////////////////////////////////////////////////////////////////////////// + ////mit 1/6, 2/3, 1/6, 0, 0, 0, 1/18, 2/9, 1/18 Konditionieren + ////////////////////////////////////////////////////////////////////////////////////// + //// Y - Dir + //backwardChimeraWithK(mfaaa, mfaba, mfaca, vvy, vy2, c1o6); + ////////////////////////////////////////////////////////////////////////////////////// + //backwardChimeraWithK(mfaab, mfabb, mfacb, vvy, vy2, c2o3); + ////////////////////////////////////////////////////////////////////////////////////// + //backwardChimeraWithK(mfaac, mfabc, mfacc, vvy, vy2, c1o6); + ////////////////////////////////////////////////////////////////////////////////////// + ////////////////////////////////////////////////////////////////////////////////////// + //backwardChimera(mfbaa, mfbba, mfbca, vvz, vz2); + ///////////b////////////////////////////////////////////////////////////////////////// + //backwardChimera(mfbab, mfbbb, mfbcb, vvz, vz2); + ///////////b////////////////////////////////////////////////////////////////////////// + //backwardChimera(mfbac, mfbbc, mfbcc, vvz, vz2); + ////////////////////////////////////////////////////////////////////////////////////// + ////////////////////////////////////////////////////////////////////////////////////// + //backwardChimeraWithK(mfcaa, mfcba, mfcca, vvy, vy2, c1o18); + ///////////c////////////////////////////////////////////////////////////////////////// + //backwardChimeraWithK(mfcab, mfcbb, mfccb, vvy, vy2, c2o9); + ///////////c////////////////////////////////////////////////////////////////////////// + //backwardChimeraWithK(mfcac, mfcbc, mfccc, vvy, vy2, c1o18); + ////////////////////////////////////////////////////////////////////////////////////// + ////////////////////////////////////////////////////////////////////////////////////// + ////mit 1/36, 1/9, 1/36, 1/9, 4/9, 1/9, 1/36, 1/9, 1/36 Konditionieren + ////////////////////////////////////////////////////////////////////////////////////// + //// X - Dir + //backwardChimeraWithK(mfaaa, mfbaa, mfcaa, vvx, vx2, c1o36); + ////////////////////////////////////////////////////////////////////////////////////// + //backwardChimeraWithK(mfaba, mfbba, mfcba, vvx, vx2, c1o9); + ////////////////////////////////////////////////////////////////////////////////////// + //backwardChimeraWithK(mfaca, mfbca, mfcca, vvx, vx2, c1o36); + ////////////////////////////////////////////////////////////////////////////////////// + ////////////////////////////////////////////////////////////////////////////////////// + //backwardChimeraWithK(mfaab, mfbab, mfcab, vvx, vx2, c1o9); + /////////////b//////////////////////////////////////////////////////////////////////// + //backwardChimeraWithK(mfabb, mfbbb, mfcbb, vvx, vx2, c4o9); + /////////////b//////////////////////////////////////////////////////////////////////// + //backwardChimeraWithK(mfacb, mfbcb, mfccb, vvx, vx2, c1o9); + ////////////////////////////////////////////////////////////////////////////////////// + ////////////////////////////////////////////////////////////////////////////////////// + //backwardChimeraWithK(mfaac, mfbac, mfcac, vvx, vx2, c1o36); + /////////////c//////////////////////////////////////////////////////////////////////// + //backwardChimeraWithK(mfabc, mfbbc, mfcbc, vvx, vx2, c1o9); + /////////////c//////////////////////////////////////////////////////////////////////// + //backwardChimeraWithK(mfacc, mfbcc, mfccc, vvx, vx2, c1o36); + ////////////////////////////////////////////////////////////////////////////////////// + + ////////////////////////////////////////////////////////////////////////////////////// + real drhoPost = + ((((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; + mfbbb += drho - drhoPost; + //////////////////////////////////////////////////////////////////////////////////// + (D.f[dirE])[k] = mfabb;//(D.f[ dirE ])[ke ] = mfabb;// - c2over27 ; (D.f[ dirE ])[k ] + (D.f[dirW])[kw] = mfcbb;//(D.f[ dirW ])[kw ] = mfcbb;// - c2over27 ; (D.f[ dirW ])[kw ] + (D.f[dirN])[k] = mfbab;//(D.f[ dirN ])[kn ] = mfbab;// - c2over27 ; (D.f[ dirN ])[k ] + (D.f[dirS])[ks] = mfbcb;//(D.f[ dirS ])[ks ] = mfbcb;// - c2over27 ; (D.f[ dirS ])[ks ] + (D.f[dirT])[k] = mfbba;//(D.f[ dirT ])[kt ] = mfbba;// - c2over27 ; (D.f[ dirT ])[k ] + (D.f[dirB])[kb] = mfbbc;//(D.f[ dirB ])[kb ] = mfbbc;// - c2over27 ; (D.f[ dirB ])[kb ] + (D.f[dirNE])[k] = mfaab;//(D.f[ dirNE ])[kne ] = mfaab;// - c1over54 ; (D.f[ dirNE ])[k ] + (D.f[dirSW])[ksw] = mfccb;//(D.f[ dirSW ])[ksw ] = mfccb;// - c1over54 ; (D.f[ dirSW ])[ksw ] + (D.f[dirSE])[ks] = mfacb;//(D.f[ dirSE ])[kse ] = mfacb;// - c1over54 ; (D.f[ dirSE ])[ks ] + (D.f[dirNW])[kw] = mfcab;//(D.f[ dirNW ])[knw ] = mfcab;// - c1over54 ; (D.f[ dirNW ])[kw ] + (D.f[dirTE])[k] = mfaba;//(D.f[ dirTE ])[kte ] = mfaba;// - c1over54 ; (D.f[ dirTE ])[k ] + (D.f[dirBW])[kbw] = mfcbc;//(D.f[ dirBW ])[kbw ] = mfcbc;// - c1over54 ; (D.f[ dirBW ])[kbw ] + (D.f[dirBE])[kb] = mfabc;//(D.f[ dirBE ])[kbe ] = mfabc;// - c1over54 ; (D.f[ dirBE ])[kb ] + (D.f[dirTW])[kw] = mfcba;//(D.f[ dirTW ])[ktw ] = mfcba;// - c1over54 ; (D.f[ dirTW ])[kw ] + (D.f[dirTN])[k] = mfbaa;//(D.f[ dirTN ])[ktn ] = mfbaa;// - c1over54 ; (D.f[ dirTN ])[k ] + (D.f[dirBS])[kbs] = mfbcc;//(D.f[ dirBS ])[kbs ] = mfbcc;// - c1over54 ; (D.f[ dirBS ])[kbs ] + (D.f[dirBN])[kb] = mfbac;//(D.f[ dirBN ])[kbn ] = mfbac;// - c1over54 ; (D.f[ dirBN ])[kb ] + (D.f[dirTS])[ks] = mfbca;//(D.f[ dirTS ])[kts ] = mfbca;// - c1over54 ; (D.f[ dirTS ])[ks ] + (D.f[dirZERO])[k] = mfbbb;//(D.f[ dirZERO])[kzero] = mfbbb;// - c8over27 ; (D.f[ dirZERO])[k ] + (D.f[dirTNE])[k] = mfaaa;//(D.f[ dirTNE ])[ktne ] = mfaaa;// - c1over216; (D.f[ dirTNE ])[k ] + (D.f[dirTSE])[ks] = mfaca;//(D.f[ dirTSE ])[ktse ] = mfaca;// - c1over216; (D.f[ dirTSE ])[ks ] + (D.f[dirBNE])[kb] = mfaac;//(D.f[ dirBNE ])[kbne ] = mfaac;// - c1over216; (D.f[ dirBNE ])[kb ] + (D.f[dirBSE])[kbs] = mfacc;//(D.f[ dirBSE ])[kbse ] = mfacc;// - c1over216; (D.f[ dirBSE ])[kbs ] + (D.f[dirTNW])[kw] = mfcaa;//(D.f[ dirTNW ])[ktnw ] = mfcaa;// - c1over216; (D.f[ dirTNW ])[kw ] + (D.f[dirTSW])[ksw] = mfcca;//(D.f[ dirTSW ])[ktsw ] = mfcca;// - c1over216; (D.f[ dirTSW ])[ksw ] + (D.f[dirBNW])[kbw] = mfcac;//(D.f[ dirBNW ])[kbnw ] = mfcac;// - c1over216; (D.f[ dirBNW ])[kbw ] + (D.f[dirBSW])[kbsw] = mfccc;//(D.f[ dirBSW ])[kbsw ] = mfccc;// - c1over216; (D.f[ dirBSW ])[kbsw] + //////////////////////////////////////////////////////////////////////////////////// + } + } } //////////////////////////////////////////////////////////////////////////////// @@ -1796,483 +1754,483 @@ extern "C" __global__ void Cumulant_One_preconditioned_chim_Comp_SP_27( //////////////////////////////////////////////////////////////////////////////// extern "C" __global__ void Cumulant_One_chim_Comp_SP_27( - real omega, - unsigned int* bcMatD, - unsigned int* neighborX, - unsigned int* neighborY, - unsigned int* neighborZ, - real* DDStart, - int size_Mat, - int level, - real* forces, - bool EvenOrOdd) + real omega, + unsigned int* bcMatD, + unsigned int* neighborX, + unsigned int* neighborY, + unsigned int* neighborZ, + real* DDStart, + int size_Mat, + int level, + real* forces, + bool EvenOrOdd) { - //////////////////////////////////////////////////////////////////////////////// - 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<size_Mat) - { - //////////////////////////////////////////////////////////////////////////////// - unsigned int BC; - BC = bcMatD[k]; - - if (BC >= GEO_FLUID/*(BC != GEO_SOLID) && (BC != GEO_VOID)*/) - { - Distributions27 D; - if (EvenOrOdd == true) - { - D.f[dirE ] = &DDStart[dirE *size_Mat]; - D.f[dirW ] = &DDStart[dirW *size_Mat]; - D.f[dirN ] = &DDStart[dirN *size_Mat]; - D.f[dirS ] = &DDStart[dirS *size_Mat]; - D.f[dirT ] = &DDStart[dirT *size_Mat]; - D.f[dirB ] = &DDStart[dirB *size_Mat]; - D.f[dirNE ] = &DDStart[dirNE *size_Mat]; - D.f[dirSW ] = &DDStart[dirSW *size_Mat]; - D.f[dirSE ] = &DDStart[dirSE *size_Mat]; - D.f[dirNW ] = &DDStart[dirNW *size_Mat]; - D.f[dirTE ] = &DDStart[dirTE *size_Mat]; - D.f[dirBW ] = &DDStart[dirBW *size_Mat]; - D.f[dirBE ] = &DDStart[dirBE *size_Mat]; - D.f[dirTW ] = &DDStart[dirTW *size_Mat]; - D.f[dirTN ] = &DDStart[dirTN *size_Mat]; - D.f[dirBS ] = &DDStart[dirBS *size_Mat]; - D.f[dirBN ] = &DDStart[dirBN *size_Mat]; - D.f[dirTS ] = &DDStart[dirTS *size_Mat]; - D.f[dirZERO] = &DDStart[dirZERO*size_Mat]; - D.f[dirTNE ] = &DDStart[dirTNE *size_Mat]; - D.f[dirTSW ] = &DDStart[dirTSW *size_Mat]; - D.f[dirTSE ] = &DDStart[dirTSE *size_Mat]; - D.f[dirTNW ] = &DDStart[dirTNW *size_Mat]; - D.f[dirBNE ] = &DDStart[dirBNE *size_Mat]; - D.f[dirBSW ] = &DDStart[dirBSW *size_Mat]; - D.f[dirBSE ] = &DDStart[dirBSE *size_Mat]; - D.f[dirBNW ] = &DDStart[dirBNW *size_Mat]; - } - else - { - D.f[dirW ] = &DDStart[dirE *size_Mat]; - D.f[dirE ] = &DDStart[dirW *size_Mat]; - D.f[dirS ] = &DDStart[dirN *size_Mat]; - D.f[dirN ] = &DDStart[dirS *size_Mat]; - D.f[dirB ] = &DDStart[dirT *size_Mat]; - D.f[dirT ] = &DDStart[dirB *size_Mat]; - D.f[dirSW ] = &DDStart[dirNE *size_Mat]; - D.f[dirNE ] = &DDStart[dirSW *size_Mat]; - D.f[dirNW ] = &DDStart[dirSE *size_Mat]; - D.f[dirSE ] = &DDStart[dirNW *size_Mat]; - D.f[dirBW ] = &DDStart[dirTE *size_Mat]; - D.f[dirTE ] = &DDStart[dirBW *size_Mat]; - D.f[dirTW ] = &DDStart[dirBE *size_Mat]; - D.f[dirBE ] = &DDStart[dirTW *size_Mat]; - D.f[dirBS ] = &DDStart[dirTN *size_Mat]; - D.f[dirTN ] = &DDStart[dirBS *size_Mat]; - D.f[dirTS ] = &DDStart[dirBN *size_Mat]; - D.f[dirBN ] = &DDStart[dirTS *size_Mat]; - D.f[dirZERO] = &DDStart[dirZERO*size_Mat]; - D.f[dirBSW ] = &DDStart[dirTNE *size_Mat]; - D.f[dirBNE ] = &DDStart[dirTSW *size_Mat]; - D.f[dirBNW ] = &DDStart[dirTSE *size_Mat]; - D.f[dirBSE ] = &DDStart[dirTNW *size_Mat]; - D.f[dirTSW ] = &DDStart[dirBNE *size_Mat]; - D.f[dirTNE ] = &DDStart[dirBSW *size_Mat]; - D.f[dirTNW ] = &DDStart[dirBSE *size_Mat]; - D.f[dirTSE ] = &DDStart[dirBNW *size_Mat]; - } - //////////////////////////////////////////////////////////////////////////////// - //index - unsigned int kw = neighborX[k]; - unsigned int ks = neighborY[k]; - unsigned int kb = neighborZ[k]; - unsigned int ksw = neighborY[kw]; - unsigned int kbw = neighborZ[kw]; - unsigned int kbs = neighborZ[ks]; - unsigned int kbsw = neighborZ[ksw]; - //////////////////////////////////////////////////////////////////////////////////// - real mfcbb = (D.f[dirE ])[k ]; - real mfabb = (D.f[dirW ])[kw ]; - real mfbcb = (D.f[dirN ])[k ]; - real mfbab = (D.f[dirS ])[ks ]; - real mfbbc = (D.f[dirT ])[k ]; - real mfbba = (D.f[dirB ])[kb ]; - real mfccb = (D.f[dirNE ])[k ]; - real mfaab = (D.f[dirSW ])[ksw ]; - real mfcab = (D.f[dirSE ])[ks ]; - real mfacb = (D.f[dirNW ])[kw ]; - real mfcbc = (D.f[dirTE ])[k ]; - real mfaba = (D.f[dirBW ])[kbw ]; - real mfcba = (D.f[dirBE ])[kb ]; - real mfabc = (D.f[dirTW ])[kw ]; - real mfbcc = (D.f[dirTN ])[k ]; - real mfbaa = (D.f[dirBS ])[kbs ]; - real mfbca = (D.f[dirBN ])[kb ]; - real mfbac = (D.f[dirTS ])[ks ]; - real mfbbb = (D.f[dirZERO])[k ]; - real mfccc = (D.f[dirTNE ])[k ]; - real mfaac = (D.f[dirTSW ])[ksw ]; - real mfcac = (D.f[dirTSE ])[ks ]; - real mfacc = (D.f[dirTNW ])[kw ]; - real mfcca = (D.f[dirBNE ])[kb ]; - real mfaaa = (D.f[dirBSW ])[kbsw]; - real mfcaa = (D.f[dirBSE ])[kbs ]; - real mfaca = (D.f[dirBNW ])[kbw ]; - //////////////////////////////////////////////////////////////////////////////////// - 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 rho = c1o1 + drho; - real OOrho = c1o1 / rho; - //////////////////////////////////////////////////////////////////////////////////// - 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; - //////////////////////////////////////////////////////////////////////////////////// - //the force be with you - real fx = forces[0] / (pow((double)c2o1, (double)level)); //zero;//0.0032653/(pow(two,level)); //0.000000005;//(two/1600000.0) / 120.0; // - real fy = forces[1] / (pow((double)c2o1, (double)level)); //zero; - real fz = forces[2] / (pow((double)c2o1, (double)level)); //zero; - vvx += fx*c1o2; - vvy += fy*c1o2; - vvz += fz*c1o2; - //////////////////////////////////////////////////////////////////////////////////// - //real omega = omega_in; - //////////////////////////////////////////////////////////////////////////////////// - //fast - //real oMdrho = c1o1; // comp special - //real m0, m1, m2; - real vx2; - real vy2; - real vz2; - vx2 = vvx*vvx; - vy2 = vvy*vvy; - vz2 = vvz*vvz; - //////////////////////////////////////////////////////////////////////////////////// - //real wadjust; - //real qudricLimitP = c1o100;// * 0.0001f; - //real qudricLimitM = c1o100;// * 0.0001f; - //real qudricLimitD = c1o100;// * 0.001f; - //////////////////////////////////////////////////////////////////////////////////// - //Hin - //////////////////////////////////////////////////////////////////////////////////// - // mit 1/36, 1/9, 1/36, 1/9, 4/9, 1/9, 1/36, 1/9, 1/36 Konditionieren - //////////////////////////////////////////////////////////////////////////////////// - // Z - Dir - forwardInverseChimeraWithK(mfaaa, mfaab, mfaac, vvz, vz2, 36.0f, c1o36); - forwardInverseChimeraWithK(mfaba, mfabb, mfabc, vvz, vz2, 9.0f , c1o9 ); - forwardInverseChimeraWithK(mfaca, mfacb, mfacc, vvz, vz2, 36.0f, c1o36); - forwardInverseChimeraWithK(mfbaa, mfbab, mfbac, vvz, vz2, 9.0f , c1o9 ); - forwardInverseChimeraWithK(mfbba, mfbbb, mfbbc, vvz, vz2, 2.25f, c4o9 ); - forwardInverseChimeraWithK(mfbca, mfbcb, mfbcc, vvz, vz2, 9.0f , c1o9 ); - forwardInverseChimeraWithK(mfcaa, mfcab, mfcac, vvz, vz2, 36.0f, c1o36); - forwardInverseChimeraWithK(mfcba, mfcbb, mfcbc, vvz, vz2, 9.0f , c1o9 ); - forwardInverseChimeraWithK(mfcca, mfccb, mfccc, vvz, vz2, 36.0f, c1o36); - - //////////////////////////////////////////////////////////////////////////////////// - // mit 1/6, 0, 1/18, 2/3, 0, 2/9, 1/6, 0, 1/18 Konditionieren - //////////////////////////////////////////////////////////////////////////////////// - // Y - Dir - forwardInverseChimeraWithK(mfaaa, mfaba, mfaca, vvy, vy2, 6.0f , c1o6 ); - forwardChimera( mfaab, mfabb, mfacb, vvy, vy2); - forwardInverseChimeraWithK(mfaac, mfabc, mfacc, vvy, vy2, 18.0f, c1o18); - forwardInverseChimeraWithK(mfbaa, mfbba, mfbca, vvy, vy2, 1.5f , c2o3 ); - forwardChimera( mfbab, mfbbb, mfbcb, vvy, vy2); - forwardInverseChimeraWithK(mfbac, mfbbc, mfbcc, vvy, vy2, 4.5f , c2o9 ); - forwardInverseChimeraWithK(mfcaa, mfcba, mfcca, vvy, vy2, 6.0f , c1o6 ); - forwardChimera( mfcab, mfcbb, mfccb, vvy, vy2); - forwardInverseChimeraWithK(mfcac, mfcbc, mfccc, vvy, vy2, 18.0f, c1o18); - - //////////////////////////////////////////////////////////////////////////////////// - // mit 1, 0, 1/3, 0, 0, 0, 1/3, 0, 1/9 Konditionieren - //////////////////////////////////////////////////////////////////////////////////// - // X - Dir - forwardInverseChimeraWithK(mfaaa, mfbaa, mfcaa, vvx, vx2, c1o1, c1o1); - forwardChimera( mfaba, mfbba, mfcba, vvx, vx2); - forwardInverseChimeraWithK(mfaca, mfbca, mfcca, vvx, vx2, 3.0f, 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, 3.0f, c1o3); - forwardChimera( mfabc, mfbbc, mfcbc, vvx, vx2); - forwardInverseChimeraWithK(mfacc, mfbcc, mfccc, vvx, vx2, 9.0f, c1o9); - - //////////////////////////////////////////////////////////////////////////////////// - // Cumulants - //////////////////////////////////////////////////////////////////////////////////// - real OxxPyyPzz = c1o1; - //////////////////////////////////////////////////////////// - //3. - ////////////////////////////// - real OxyyPxzz = c1o1; - real OxyyMxzz = c1o1; - //real Oxyz = c1o1; - //////////////////////////////////////////////////////////// - //4. - ////////////////////////////// - real O4 = c1o1; - //////////////////////////////////////////////////////////// - //5. - ////////////////////////////// - real O5 = c1o1; - //////////////////////////////////////////////////////////// - //6. - ////////////////////////////// - real O6 = c1o1; - //////////////////////////////////////////////////////////// - - - //central moments to cumulants - //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 )); - - - //2. - // linear combinations - real mxxPyyPzz = mfcaa + mfaca + mfaac; - real mxxMyy = mfcaa - mfaca; - real mxxMzz = mfcaa - mfaac; - - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //incl. correction (hat noch nicht so gut funktioniert...Optimierungsbedarf??) - { - real dxux = c1o2 * (-omega) *(mxxMyy + mxxMzz) + c1o2 * OxxPyyPzz * (mfaaa - mxxPyyPzz); - real dyuy = dxux + omega * c3o2 * mxxMyy; - real dzuz = dxux + omega * c3o2 * mxxMzz; - - //relax - mxxPyyPzz += OxxPyyPzz*(mfaaa - mxxPyyPzz)- c3o1 * (c1o1 - c1o2 * OxxPyyPzz) * (vx2 * dxux + vy2 * dyuy + vz2 * dzuz);//-magicBulk*OxxPyyPzz; - 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);//-magicBulk*OxxPyyPzz; - //mxxMyy += -(-omega) * (-mxxMyy); - //mxxMzz += -(-omega) * (-mxxMzz); - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - mfabb += omega * (-mfabb); - mfbab += omega * (-mfbab); - mfbba += omega * (-mfbba); - - ////////////////////////////////////////////////////////////////////////// - - // linear combinations back - mfcaa = c1o3 * (mxxMyy + mxxMzz + mxxPyyPzz); - mfaca = c1o3 * (-c2o1* mxxMyy + mxxMzz + mxxPyyPzz); - mfaac = c1o3 * (mxxMyy - c2o1* mxxMzz + mxxPyyPzz); - - //3. - // linear combinations - - real mxxyPyzz = mfcba + mfabc; - real mxxyMyzz = mfcba - mfabc; - - real mxxzPyyz = mfcab + mfacb; - real mxxzMyyz = mfcab - mfacb; - - real mxyyPxzz = mfbca + mfbac; - real mxyyMxzz = mfbca - mfbac; - - //relax - ////////////////////////////////////////////////////////////////////////// - mfbbb += OxyyMxzz * (-mfbbb); - mxxyPyzz += OxyyPxzz * (-mxxyPyzz); - mxxyMyzz += OxyyMxzz * (-mxxyMyzz); - mxxzPyyz += OxyyPxzz * (-mxxzPyyz); - mxxzMyyz += OxyyMxzz * (-mxxzMyyz); - mxyyPxzz += OxyyPxzz * (-mxyyPxzz); - mxyyMxzz += OxyyMxzz * (-mxyyMxzz); - ////////////////////////////////////////////////////////////////////////// - - 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. - ////////////////////////////////////////////////////////////////////////// - CUMacc += O4 * (-CUMacc); - CUMcac += O4 * (-CUMcac); - CUMcca += O4 * (-CUMcca); - - CUMbbc += O4 * (-CUMbbc); - CUMbcb += O4 * (-CUMbcb); - CUMcbb += O4 * (-CUMcbb); - ////////////////////////////////////////////////////////////////////////// - - - //5. - CUMbcc += O5 * (-CUMbcc); - CUMcbc += O5 * (-CUMcbc); - CUMccb += O5 * (-CUMccb); - - //6. - CUMccc += O6 * (-CUMccc); - - - - //back cumulants to central moments - //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 )); - - //////////////////////////////////////////////////////////////////////////////////// - //the force be with you - mfbaa = -mfbaa; - mfaba = -mfaba; - mfaab = -mfaab; - //////////////////////////////////////////////////////////////////////////////////// - - - //////////////////////////////////////////////////////////////////////////////////// - //back - //////////////////////////////////////////////////////////////////////////////////// - //mit 1, 0, 1/3, 0, 0, 0, 1/3, 0, 1/9 Konditionieren - //////////////////////////////////////////////////////////////////////////////////// - // X - Dir - backwardInverseChimeraWithK(mfaaa, mfbaa, mfcaa, vvx, vx2, c1o1, c1o1); - backwardChimera( mfaba, mfbba, mfcba, vvx, vx2); - backwardInverseChimeraWithK(mfaca, mfbca, mfcca, vvx, vx2, 3.0f, 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, 3.0f, c1o3); - backwardChimera( mfabc, mfbbc, mfcbc, vvx, vx2); - backwardInverseChimeraWithK(mfacc, mfbcc, mfccc, vvx, vx2, 9.0f, c1o9); - - //////////////////////////////////////////////////////////////////////////////////// - //mit 1/6, 2/3, 1/6, 0, 0, 0, 1/18, 2/9, 1/18 Konditionieren - //////////////////////////////////////////////////////////////////////////////////// - // Y - Dir - backwardInverseChimeraWithK(mfaaa, mfaba, mfaca, vvy, vy2, 6.0f , c1o6 ); - backwardChimera( mfaab, mfabb, mfacb, vvy, vy2); - backwardInverseChimeraWithK(mfaac, mfabc, mfacc, vvy, vy2, 18.0f, c1o18); - backwardInverseChimeraWithK(mfbaa, mfbba, mfbca, vvy, vy2, 1.5f , c2o3 ); - backwardChimera( mfbab, mfbbb, mfbcb, vvy, vy2); - backwardInverseChimeraWithK(mfbac, mfbbc, mfbcc, vvy, vy2, 4.5f , c2o9 ); - backwardInverseChimeraWithK(mfcaa, mfcba, mfcca, vvy, vy2, 6.0f , c1o6 ); - backwardChimera( mfcab, mfcbb, mfccb, vvy, vy2); - backwardInverseChimeraWithK(mfcac, mfcbc, mfccc, vvy, vy2, 18.0f, c1o18); - - //////////////////////////////////////////////////////////////////////////////////// - //mit 1/36, 1/9, 1/36, 1/9, 4/9, 1/9, 1/36, 1/9, 1/36 Konditionieren - //////////////////////////////////////////////////////////////////////////////////// - // Z - Dir - backwardInverseChimeraWithK(mfaaa, mfaab, mfaac, vvz, vz2, 36.0f, c1o36); - backwardInverseChimeraWithK(mfaba, mfabb, mfabc, vvz, vz2, 9.0f , c1o9 ); - backwardInverseChimeraWithK(mfaca, mfacb, mfacc, vvz, vz2, 36.0f, c1o36); - backwardInverseChimeraWithK(mfbaa, mfbab, mfbac, vvz, vz2, 9.0f , c1o9 ); - backwardInverseChimeraWithK(mfbba, mfbbb, mfbbc, vvz, vz2, 2.25f, c4o9 ); - backwardInverseChimeraWithK(mfbca, mfbcb, mfbcc, vvz, vz2, 9.0f , c1o9 ); - backwardInverseChimeraWithK(mfcaa, mfcab, mfcac, vvz, vz2, 36.0f, c1o36); - backwardInverseChimeraWithK(mfcba, mfcbb, mfcbc, vvz, vz2, 9.0f , c1o9 ); - backwardInverseChimeraWithK(mfcca, mfccb, mfccc, vvz, vz2, 36.0f, c1o36); - - ////////////////////////////////////////////////////////////////////////////////////// - real drhoPost = - ((((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; - mfbbb += drho - drhoPost; - //////////////////////////////////////////////////////////////////////////////////// - (D.f[dirE ])[k ] = mfabb; - (D.f[dirW ])[kw ] = mfcbb; - (D.f[dirN ])[k ] = mfbab; - (D.f[dirS ])[ks ] = mfbcb; - (D.f[dirT ])[k ] = mfbba; - (D.f[dirB ])[kb ] = mfbbc; - (D.f[dirNE ])[k ] = mfaab; - (D.f[dirSW ])[ksw ] = mfccb; - (D.f[dirSE ])[ks ] = mfacb; - (D.f[dirNW ])[kw ] = mfcab; - (D.f[dirTE ])[k ] = mfaba; - (D.f[dirBW ])[kbw ] = mfcbc; - (D.f[dirBE ])[kb ] = mfabc; - (D.f[dirTW ])[kw ] = mfcba; - (D.f[dirTN ])[k ] = mfbaa; - (D.f[dirBS ])[kbs ] = mfbcc; - (D.f[dirBN ])[kb ] = mfbac; - (D.f[dirTS ])[ks ] = mfbca; - (D.f[dirZERO])[k ] = mfbbb; - (D.f[dirTNE ])[k ] = mfaaa; - (D.f[dirTSE ])[ks ] = mfaca; - (D.f[dirBNE ])[kb ] = mfaac; - (D.f[dirBSE ])[kbs ] = mfacc; - (D.f[dirTNW ])[kw ] = mfcaa; - (D.f[dirTSW ])[ksw ] = mfcca; - (D.f[dirBNW ])[kbw ] = mfcac; - (D.f[dirBSW ])[kbsw] = mfccc; - } - } + //////////////////////////////////////////////////////////////////////////////// + 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<size_Mat) + { + //////////////////////////////////////////////////////////////////////////////// + unsigned int BC; + BC = bcMatD[k]; + + if (BC >= GEO_FLUID/*(BC != GEO_SOLID) && (BC != GEO_VOID)*/) + { + Distributions27 D; + if (EvenOrOdd == true) + { + D.f[dirE ] = &DDStart[dirE *size_Mat]; + D.f[dirW ] = &DDStart[dirW *size_Mat]; + D.f[dirN ] = &DDStart[dirN *size_Mat]; + D.f[dirS ] = &DDStart[dirS *size_Mat]; + D.f[dirT ] = &DDStart[dirT *size_Mat]; + D.f[dirB ] = &DDStart[dirB *size_Mat]; + D.f[dirNE ] = &DDStart[dirNE *size_Mat]; + D.f[dirSW ] = &DDStart[dirSW *size_Mat]; + D.f[dirSE ] = &DDStart[dirSE *size_Mat]; + D.f[dirNW ] = &DDStart[dirNW *size_Mat]; + D.f[dirTE ] = &DDStart[dirTE *size_Mat]; + D.f[dirBW ] = &DDStart[dirBW *size_Mat]; + D.f[dirBE ] = &DDStart[dirBE *size_Mat]; + D.f[dirTW ] = &DDStart[dirTW *size_Mat]; + D.f[dirTN ] = &DDStart[dirTN *size_Mat]; + D.f[dirBS ] = &DDStart[dirBS *size_Mat]; + D.f[dirBN ] = &DDStart[dirBN *size_Mat]; + D.f[dirTS ] = &DDStart[dirTS *size_Mat]; + D.f[dirZERO] = &DDStart[dirZERO*size_Mat]; + D.f[dirTNE ] = &DDStart[dirTNE *size_Mat]; + D.f[dirTSW ] = &DDStart[dirTSW *size_Mat]; + D.f[dirTSE ] = &DDStart[dirTSE *size_Mat]; + D.f[dirTNW ] = &DDStart[dirTNW *size_Mat]; + D.f[dirBNE ] = &DDStart[dirBNE *size_Mat]; + D.f[dirBSW ] = &DDStart[dirBSW *size_Mat]; + D.f[dirBSE ] = &DDStart[dirBSE *size_Mat]; + D.f[dirBNW ] = &DDStart[dirBNW *size_Mat]; + } + else + { + D.f[dirW ] = &DDStart[dirE *size_Mat]; + D.f[dirE ] = &DDStart[dirW *size_Mat]; + D.f[dirS ] = &DDStart[dirN *size_Mat]; + D.f[dirN ] = &DDStart[dirS *size_Mat]; + D.f[dirB ] = &DDStart[dirT *size_Mat]; + D.f[dirT ] = &DDStart[dirB *size_Mat]; + D.f[dirSW ] = &DDStart[dirNE *size_Mat]; + D.f[dirNE ] = &DDStart[dirSW *size_Mat]; + D.f[dirNW ] = &DDStart[dirSE *size_Mat]; + D.f[dirSE ] = &DDStart[dirNW *size_Mat]; + D.f[dirBW ] = &DDStart[dirTE *size_Mat]; + D.f[dirTE ] = &DDStart[dirBW *size_Mat]; + D.f[dirTW ] = &DDStart[dirBE *size_Mat]; + D.f[dirBE ] = &DDStart[dirTW *size_Mat]; + D.f[dirBS ] = &DDStart[dirTN *size_Mat]; + D.f[dirTN ] = &DDStart[dirBS *size_Mat]; + D.f[dirTS ] = &DDStart[dirBN *size_Mat]; + D.f[dirBN ] = &DDStart[dirTS *size_Mat]; + D.f[dirZERO] = &DDStart[dirZERO*size_Mat]; + D.f[dirBSW ] = &DDStart[dirTNE *size_Mat]; + D.f[dirBNE ] = &DDStart[dirTSW *size_Mat]; + D.f[dirBNW ] = &DDStart[dirTSE *size_Mat]; + D.f[dirBSE ] = &DDStart[dirTNW *size_Mat]; + D.f[dirTSW ] = &DDStart[dirBNE *size_Mat]; + D.f[dirTNE ] = &DDStart[dirBSW *size_Mat]; + D.f[dirTNW ] = &DDStart[dirBSE *size_Mat]; + D.f[dirTSE ] = &DDStart[dirBNW *size_Mat]; + } + //////////////////////////////////////////////////////////////////////////////// + //index + unsigned int kw = neighborX[k]; + unsigned int ks = neighborY[k]; + unsigned int kb = neighborZ[k]; + unsigned int ksw = neighborY[kw]; + unsigned int kbw = neighborZ[kw]; + unsigned int kbs = neighborZ[ks]; + unsigned int kbsw = neighborZ[ksw]; + //////////////////////////////////////////////////////////////////////////////////// + real mfcbb = (D.f[dirE ])[k ]; + real mfabb = (D.f[dirW ])[kw ]; + real mfbcb = (D.f[dirN ])[k ]; + real mfbab = (D.f[dirS ])[ks ]; + real mfbbc = (D.f[dirT ])[k ]; + real mfbba = (D.f[dirB ])[kb ]; + real mfccb = (D.f[dirNE ])[k ]; + real mfaab = (D.f[dirSW ])[ksw ]; + real mfcab = (D.f[dirSE ])[ks ]; + real mfacb = (D.f[dirNW ])[kw ]; + real mfcbc = (D.f[dirTE ])[k ]; + real mfaba = (D.f[dirBW ])[kbw ]; + real mfcba = (D.f[dirBE ])[kb ]; + real mfabc = (D.f[dirTW ])[kw ]; + real mfbcc = (D.f[dirTN ])[k ]; + real mfbaa = (D.f[dirBS ])[kbs ]; + real mfbca = (D.f[dirBN ])[kb ]; + real mfbac = (D.f[dirTS ])[ks ]; + real mfbbb = (D.f[dirZERO])[k ]; + real mfccc = (D.f[dirTNE ])[k ]; + real mfaac = (D.f[dirTSW ])[ksw ]; + real mfcac = (D.f[dirTSE ])[ks ]; + real mfacc = (D.f[dirTNW ])[kw ]; + real mfcca = (D.f[dirBNE ])[kb ]; + real mfaaa = (D.f[dirBSW ])[kbsw]; + real mfcaa = (D.f[dirBSE ])[kbs ]; + real mfaca = (D.f[dirBNW ])[kbw ]; + //////////////////////////////////////////////////////////////////////////////////// + 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 rho = c1o1 + drho; + real OOrho = c1o1 / rho; + //////////////////////////////////////////////////////////////////////////////////// + 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; + //////////////////////////////////////////////////////////////////////////////////// + //the force be with you + real fx = forces[0] / (pow((double)c2o1, (double)level)); //zero;//0.0032653/(pow(two,level)); //0.000000005;//(two/1600000.0) / 120.0; // + real fy = forces[1] / (pow((double)c2o1, (double)level)); //zero; + real fz = forces[2] / (pow((double)c2o1, (double)level)); //zero; + vvx += fx*c1o2; + vvy += fy*c1o2; + vvz += fz*c1o2; + //////////////////////////////////////////////////////////////////////////////////// + //real omega = omega_in; + //////////////////////////////////////////////////////////////////////////////////// + //fast + //real oMdrho = c1o1; // comp special + //real m0, m1, m2; + real vx2; + real vy2; + real vz2; + vx2 = vvx*vvx; + vy2 = vvy*vvy; + vz2 = vvz*vvz; + //////////////////////////////////////////////////////////////////////////////////// + //real wadjust; + //real qudricLimitP = c1o100;// * 0.0001f; + //real qudricLimitM = c1o100;// * 0.0001f; + //real qudricLimitD = c1o100;// * 0.001f; + //////////////////////////////////////////////////////////////////////////////////// + //Hin + //////////////////////////////////////////////////////////////////////////////////// + // mit 1/36, 1/9, 1/36, 1/9, 4/9, 1/9, 1/36, 1/9, 1/36 Konditionieren + //////////////////////////////////////////////////////////////////////////////////// + // Z - Dir + vf::lbm::forwardInverseChimeraWithK(mfaaa, mfaab, mfaac, vvz, vz2, 36.0f, c1o36); + vf::lbm::forwardInverseChimeraWithK(mfaba, mfabb, mfabc, vvz, vz2, 9.0f , c1o9 ); + vf::lbm::forwardInverseChimeraWithK(mfaca, mfacb, mfacc, vvz, vz2, 36.0f, c1o36); + vf::lbm::forwardInverseChimeraWithK(mfbaa, mfbab, mfbac, vvz, vz2, 9.0f , c1o9 ); + vf::lbm::forwardInverseChimeraWithK(mfbba, mfbbb, mfbbc, vvz, vz2, 2.25f, c4o9 ); + vf::lbm::forwardInverseChimeraWithK(mfbca, mfbcb, mfbcc, vvz, vz2, 9.0f , c1o9 ); + vf::lbm::forwardInverseChimeraWithK(mfcaa, mfcab, mfcac, vvz, vz2, 36.0f, c1o36); + vf::lbm::forwardInverseChimeraWithK(mfcba, mfcbb, mfcbc, vvz, vz2, 9.0f , c1o9 ); + vf::lbm::forwardInverseChimeraWithK(mfcca, mfccb, mfccc, vvz, vz2, 36.0f, c1o36); + + //////////////////////////////////////////////////////////////////////////////////// + // mit 1/6, 0, 1/18, 2/3, 0, 2/9, 1/6, 0, 1/18 Konditionieren + //////////////////////////////////////////////////////////////////////////////////// + // Y - Dir + vf::lbm::forwardInverseChimeraWithK(mfaaa, mfaba, mfaca, vvy, vy2, 6.0f , c1o6 ); + vf::lbm::forwardChimera( mfaab, mfabb, mfacb, vvy, vy2); + vf::lbm::forwardInverseChimeraWithK(mfaac, mfabc, mfacc, vvy, vy2, 18.0f, c1o18); + vf::lbm::forwardInverseChimeraWithK(mfbaa, mfbba, mfbca, vvy, vy2, 1.5f , c2o3 ); + vf::lbm::forwardChimera( mfbab, mfbbb, mfbcb, vvy, vy2); + vf::lbm::forwardInverseChimeraWithK(mfbac, mfbbc, mfbcc, vvy, vy2, 4.5f , c2o9 ); + vf::lbm::forwardInverseChimeraWithK(mfcaa, mfcba, mfcca, vvy, vy2, 6.0f , c1o6 ); + vf::lbm::forwardChimera( mfcab, mfcbb, mfccb, vvy, vy2); + vf::lbm::forwardInverseChimeraWithK(mfcac, mfcbc, mfccc, vvy, vy2, 18.0f, c1o18); + + //////////////////////////////////////////////////////////////////////////////////// + // mit 1, 0, 1/3, 0, 0, 0, 1/3, 0, 1/9 Konditionieren + //////////////////////////////////////////////////////////////////////////////////// + // X - Dir + vf::lbm::forwardInverseChimeraWithK(mfaaa, mfbaa, mfcaa, vvx, vx2, c1o1, c1o1); + vf::lbm::forwardChimera( mfaba, mfbba, mfcba, vvx, vx2); + vf::lbm::forwardInverseChimeraWithK(mfaca, mfbca, mfcca, vvx, vx2, 3.0f, c1o3); + vf::lbm::forwardChimera( mfaab, mfbab, mfcab, vvx, vx2); + vf::lbm::forwardChimera( mfabb, mfbbb, mfcbb, vvx, vx2); + vf::lbm::forwardChimera( mfacb, mfbcb, mfccb, vvx, vx2); + vf::lbm::forwardInverseChimeraWithK(mfaac, mfbac, mfcac, vvx, vx2, 3.0f, c1o3); + vf::lbm::forwardChimera( mfabc, mfbbc, mfcbc, vvx, vx2); + vf::lbm::forwardInverseChimeraWithK(mfacc, mfbcc, mfccc, vvx, vx2, 9.0f, c1o9); + + //////////////////////////////////////////////////////////////////////////////////// + // Cumulants + //////////////////////////////////////////////////////////////////////////////////// + real OxxPyyPzz = c1o1; + //////////////////////////////////////////////////////////// + //3. + ////////////////////////////// + real OxyyPxzz = c1o1; + real OxyyMxzz = c1o1; + //real Oxyz = c1o1; + //////////////////////////////////////////////////////////// + //4. + ////////////////////////////// + real O4 = c1o1; + //////////////////////////////////////////////////////////// + //5. + ////////////////////////////// + real O5 = c1o1; + //////////////////////////////////////////////////////////// + //6. + ////////////////////////////// + real O6 = c1o1; + //////////////////////////////////////////////////////////// + + + //central moments to cumulants + //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 )); + + + //2. + // linear combinations + real mxxPyyPzz = mfcaa + mfaca + mfaac; + real mxxMyy = mfcaa - mfaca; + real mxxMzz = mfcaa - mfaac; + + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //incl. correction (hat noch nicht so gut funktioniert...Optimierungsbedarf??) + { + real dxux = c1o2 * (-omega) *(mxxMyy + mxxMzz) + c1o2 * OxxPyyPzz * (mfaaa - mxxPyyPzz); + real dyuy = dxux + omega * c3o2 * mxxMyy; + real dzuz = dxux + omega * c3o2 * mxxMzz; + + //relax + mxxPyyPzz += OxxPyyPzz*(mfaaa - mxxPyyPzz)- c3o1 * (c1o1 - c1o2 * OxxPyyPzz) * (vx2 * dxux + vy2 * dyuy + vz2 * dzuz);//-magicBulk*OxxPyyPzz; + 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);//-magicBulk*OxxPyyPzz; + //mxxMyy += -(-omega) * (-mxxMyy); + //mxxMzz += -(-omega) * (-mxxMzz); + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + mfabb += omega * (-mfabb); + mfbab += omega * (-mfbab); + mfbba += omega * (-mfbba); + + ////////////////////////////////////////////////////////////////////////// + + // linear combinations back + mfcaa = c1o3 * (mxxMyy + mxxMzz + mxxPyyPzz); + mfaca = c1o3 * (-c2o1* mxxMyy + mxxMzz + mxxPyyPzz); + mfaac = c1o3 * (mxxMyy - c2o1* mxxMzz + mxxPyyPzz); + + //3. + // linear combinations + + real mxxyPyzz = mfcba + mfabc; + real mxxyMyzz = mfcba - mfabc; + + real mxxzPyyz = mfcab + mfacb; + real mxxzMyyz = mfcab - mfacb; + + real mxyyPxzz = mfbca + mfbac; + real mxyyMxzz = mfbca - mfbac; + + //relax + ////////////////////////////////////////////////////////////////////////// + mfbbb += OxyyMxzz * (-mfbbb); + mxxyPyzz += OxyyPxzz * (-mxxyPyzz); + mxxyMyzz += OxyyMxzz * (-mxxyMyzz); + mxxzPyyz += OxyyPxzz * (-mxxzPyyz); + mxxzMyyz += OxyyMxzz * (-mxxzMyyz); + mxyyPxzz += OxyyPxzz * (-mxyyPxzz); + mxyyMxzz += OxyyMxzz * (-mxyyMxzz); + ////////////////////////////////////////////////////////////////////////// + + 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. + ////////////////////////////////////////////////////////////////////////// + CUMacc += O4 * (-CUMacc); + CUMcac += O4 * (-CUMcac); + CUMcca += O4 * (-CUMcca); + + CUMbbc += O4 * (-CUMbbc); + CUMbcb += O4 * (-CUMbcb); + CUMcbb += O4 * (-CUMcbb); + ////////////////////////////////////////////////////////////////////////// + + + //5. + CUMbcc += O5 * (-CUMbcc); + CUMcbc += O5 * (-CUMcbc); + CUMccb += O5 * (-CUMccb); + + //6. + CUMccc += O6 * (-CUMccc); + + + + //back cumulants to central moments + //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 )); + + //////////////////////////////////////////////////////////////////////////////////// + //the force be with you + mfbaa = -mfbaa; + mfaba = -mfaba; + mfaab = -mfaab; + //////////////////////////////////////////////////////////////////////////////////// + + + //////////////////////////////////////////////////////////////////////////////////// + //back + //////////////////////////////////////////////////////////////////////////////////// + //mit 1, 0, 1/3, 0, 0, 0, 1/3, 0, 1/9 Konditionieren + //////////////////////////////////////////////////////////////////////////////////// + // X - Dir + vf::lbm::backwardInverseChimeraWithK(mfaaa, mfbaa, mfcaa, vvx, vx2, c1o1, c1o1); + vf::lbm::backwardChimera( mfaba, mfbba, mfcba, vvx, vx2); + vf::lbm::backwardInverseChimeraWithK(mfaca, mfbca, mfcca, vvx, vx2, 3.0f, c1o3); + vf::lbm::backwardChimera( mfaab, mfbab, mfcab, vvx, vx2); + vf::lbm::backwardChimera( mfabb, mfbbb, mfcbb, vvx, vx2); + vf::lbm::backwardChimera( mfacb, mfbcb, mfccb, vvx, vx2); + vf::lbm::backwardInverseChimeraWithK(mfaac, mfbac, mfcac, vvx, vx2, 3.0f, c1o3); + vf::lbm::backwardChimera( mfabc, mfbbc, mfcbc, vvx, vx2); + vf::lbm::backwardInverseChimeraWithK(mfacc, mfbcc, mfccc, vvx, vx2, 9.0f, c1o9); + + //////////////////////////////////////////////////////////////////////////////////// + //mit 1/6, 2/3, 1/6, 0, 0, 0, 1/18, 2/9, 1/18 Konditionieren + //////////////////////////////////////////////////////////////////////////////////// + // Y - Dir + vf::lbm::backwardInverseChimeraWithK(mfaaa, mfaba, mfaca, vvy, vy2, 6.0f , c1o6 ); + vf::lbm::backwardChimera( mfaab, mfabb, mfacb, vvy, vy2); + vf::lbm::backwardInverseChimeraWithK(mfaac, mfabc, mfacc, vvy, vy2, 18.0f, c1o18); + vf::lbm::backwardInverseChimeraWithK(mfbaa, mfbba, mfbca, vvy, vy2, 1.5f , c2o3 ); + vf::lbm::backwardChimera( mfbab, mfbbb, mfbcb, vvy, vy2); + vf::lbm::backwardInverseChimeraWithK(mfbac, mfbbc, mfbcc, vvy, vy2, 4.5f , c2o9 ); + vf::lbm::backwardInverseChimeraWithK(mfcaa, mfcba, mfcca, vvy, vy2, 6.0f , c1o6 ); + vf::lbm::backwardChimera( mfcab, mfcbb, mfccb, vvy, vy2); + vf::lbm::backwardInverseChimeraWithK(mfcac, mfcbc, mfccc, vvy, vy2, 18.0f, c1o18); + + //////////////////////////////////////////////////////////////////////////////////// + //mit 1/36, 1/9, 1/36, 1/9, 4/9, 1/9, 1/36, 1/9, 1/36 Konditionieren + //////////////////////////////////////////////////////////////////////////////////// + // Z - Dir + vf::lbm::backwardInverseChimeraWithK(mfaaa, mfaab, mfaac, vvz, vz2, 36.0f, c1o36); + vf::lbm::backwardInverseChimeraWithK(mfaba, mfabb, mfabc, vvz, vz2, 9.0f , c1o9 ); + vf::lbm::backwardInverseChimeraWithK(mfaca, mfacb, mfacc, vvz, vz2, 36.0f, c1o36); + vf::lbm::backwardInverseChimeraWithK(mfbaa, mfbab, mfbac, vvz, vz2, 9.0f , c1o9 ); + vf::lbm::backwardInverseChimeraWithK(mfbba, mfbbb, mfbbc, vvz, vz2, 2.25f, c4o9 ); + vf::lbm::backwardInverseChimeraWithK(mfbca, mfbcb, mfbcc, vvz, vz2, 9.0f , c1o9 ); + vf::lbm::backwardInverseChimeraWithK(mfcaa, mfcab, mfcac, vvz, vz2, 36.0f, c1o36); + vf::lbm::backwardInverseChimeraWithK(mfcba, mfcbb, mfcbc, vvz, vz2, 9.0f , c1o9 ); + vf::lbm::backwardInverseChimeraWithK(mfcca, mfccb, mfccc, vvz, vz2, 36.0f, c1o36); + + ////////////////////////////////////////////////////////////////////////////////////// + real drhoPost = + ((((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; + mfbbb += drho - drhoPost; + //////////////////////////////////////////////////////////////////////////////////// + (D.f[dirE ])[k ] = mfabb; + (D.f[dirW ])[kw ] = mfcbb; + (D.f[dirN ])[k ] = mfbab; + (D.f[dirS ])[ks ] = mfbcb; + (D.f[dirT ])[k ] = mfbba; + (D.f[dirB ])[kb ] = mfbbc; + (D.f[dirNE ])[k ] = mfaab; + (D.f[dirSW ])[ksw ] = mfccb; + (D.f[dirSE ])[ks ] = mfacb; + (D.f[dirNW ])[kw ] = mfcab; + (D.f[dirTE ])[k ] = mfaba; + (D.f[dirBW ])[kbw ] = mfcbc; + (D.f[dirBE ])[kb ] = mfabc; + (D.f[dirTW ])[kw ] = mfcba; + (D.f[dirTN ])[k ] = mfbaa; + (D.f[dirBS ])[kbs ] = mfbcc; + (D.f[dirBN ])[kb ] = mfbac; + (D.f[dirTS ])[ks ] = mfbca; + (D.f[dirZERO])[k ] = mfbbb; + (D.f[dirTNE ])[k ] = mfaaa; + (D.f[dirTSE ])[ks ] = mfaca; + (D.f[dirBNE ])[kb ] = mfaac; + (D.f[dirBSE ])[kbs ] = mfacc; + (D.f[dirTNW ])[kw ] = mfcaa; + (D.f[dirTSW ])[ksw ] = mfcca; + (D.f[dirBNW ])[kbw ] = mfcac; + (D.f[dirBSW ])[kbsw] = mfccc; + } + } } //////////////////////////////////////////////////////////////////////////////// diff --git a/src/gpu/VirtualFluids_GPU/GPU/Cumulant_F3_27.cu b/src/gpu/VirtualFluids_GPU/GPU/Cumulant_F3_27.cu index 6b23233363be8f7b74f27ccafcfa9c7404713da2..8763482321aaa1c1dc5f21794192a5227a8f377b 100644 --- a/src/gpu/VirtualFluids_GPU/GPU/Cumulant_F3_27.cu +++ b/src/gpu/VirtualFluids_GPU/GPU/Cumulant_F3_27.cu @@ -8,7 +8,9 @@ /* Device code */ #include "LBM/LB.h" #include "LBM/D3Q27.h" -#include "Core/RealConstants.h" +#include <lbm/constants/NumericConstants.h> + +using namespace vf::lbm::constant; #include "math.h" ///////////////////////////////////////////////////////////////////////////////// diff --git a/src/gpu/VirtualFluids_GPU/GPU/DragLift27.cu b/src/gpu/VirtualFluids_GPU/GPU/DragLift27.cu index f48d6a2a5851208d33513fde1e2259dc29c1698c..7fb12d17784fb13c2e11dd7dedb7521444be11c2 100644 --- a/src/gpu/VirtualFluids_GPU/GPU/DragLift27.cu +++ b/src/gpu/VirtualFluids_GPU/GPU/DragLift27.cu @@ -1,7 +1,9 @@ /* Device code */ #include "LBM/LB.h" #include "LBM/D3Q27.h" -#include "Core/RealConstants.h" +#include <lbm/constants/NumericConstants.h> + +using namespace vf::lbm::constant; //////////////////////////////////////////////////////////////////////////////// extern "C" __global__ void DragLiftPost27( real* DD, diff --git a/src/gpu/VirtualFluids_GPU/GPU/EnstrophyAnalyzer.cu b/src/gpu/VirtualFluids_GPU/GPU/EnstrophyAnalyzer.cu index 5380ce071a1f1e101d9ae97aeca3373de73cb3de..a020d3dfd904b0425296b48e867c07e7bad4dd58 100644 --- a/src/gpu/VirtualFluids_GPU/GPU/EnstrophyAnalyzer.cu +++ b/src/gpu/VirtualFluids_GPU/GPU/EnstrophyAnalyzer.cu @@ -18,7 +18,9 @@ #include "Parameter/Parameter.h" // includes, kernels #include "GPU/GPU_Kernels.cuh" -#include "Core/RealConstants.h" +#include <lbm/constants/NumericConstants.h> + +using namespace vf::lbm::constant; __global__ void enstrophyKernel ( real* veloX, real* veloY, real* veloZ, real* rho, uint* neighborX, uint* neighborY, uint* neighborZ, uint* neighborWSB, uint* geo, real* enstrophy, uint* isFluid, uint size_Mat ); diff --git a/src/gpu/VirtualFluids_GPU/GPU/ExchangeData27.cu b/src/gpu/VirtualFluids_GPU/GPU/ExchangeData27.cu index 8ff384a9c7fcffb2040fe5402f89907333a04c19..980b39042c8d1bf4d47e22af94494480d32db60c 100644 --- a/src/gpu/VirtualFluids_GPU/GPU/ExchangeData27.cu +++ b/src/gpu/VirtualFluids_GPU/GPU/ExchangeData27.cu @@ -1,7 +1,9 @@ /* Device code */ #include "LBM/LB.h" #include "LBM/D3Q27.h" -#include "Core/RealConstants.h" +#include <lbm/constants/NumericConstants.h> + +using namespace vf::lbm::constant; //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// extern "C" __global__ void getSendFsPost27(real* DD, diff --git a/src/gpu/VirtualFluids_GPU/GPU/GPU_Interface.h b/src/gpu/VirtualFluids_GPU/GPU/GPU_Interface.h index 3589bcea15dd73771ff0f7579401e65da7010389..dfdbac44d197e55e3e78eb794692fd9443cb7ab6 100644 --- a/src/gpu/VirtualFluids_GPU/GPU/GPU_Interface.h +++ b/src/gpu/VirtualFluids_GPU/GPU/GPU_Interface.h @@ -131,6 +131,7 @@ extern "C" void KernelKumNewSP27( unsigned int numberOfThreads, int size_Mat, bool EvenOrOdd); + extern "C" void CumulantOnePreconditionedErrorDiffusionChimCompSP27( unsigned int numberOfThreads, real s9, diff --git a/src/gpu/VirtualFluids_GPU/GPU/GPU_Kernels.cuh b/src/gpu/VirtualFluids_GPU/GPU/GPU_Kernels.cuh index b41724df488f7aea97ed5e9e2bcf9282ff6bc370..288db43e7bcd36dc4d187982b86178d345601094 100644 --- a/src/gpu/VirtualFluids_GPU/GPU/GPU_Kernels.cuh +++ b/src/gpu/VirtualFluids_GPU/GPU/GPU_Kernels.cuh @@ -140,7 +140,6 @@ extern "C" __global__ void LB_Kernel_Kum_Comp_SP_27(real s9, int size_Mat, bool EvenOrOdd); - extern "C" __global__ void Cumulant_One_preconditioned_errorDiffusion_chim_Comp_SP_27( real omega, unsigned int* bcMatD, 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/Init27.cu b/src/gpu/VirtualFluids_GPU/GPU/Init27.cu index c428913b86332e69914ce5ed8092db5ad6b324a4..7b3426b0117a4f36da0088727f31422839edbebc 100644 --- a/src/gpu/VirtualFluids_GPU/GPU/Init27.cu +++ b/src/gpu/VirtualFluids_GPU/GPU/Init27.cu @@ -1,7 +1,9 @@ /* Device code */ #include "LBM/LB.h" #include "LBM/D3Q27.h" -#include "Core/RealConstants.h" +#include <lbm/constants/NumericConstants.h> + +using namespace vf::lbm::constant; //////////////////////////////////////////////////////////////////////////////// extern "C" __global__ void LBInit27( int myid, diff --git a/src/gpu/VirtualFluids_GPU/GPU/KineticEnergyAnalyzer.cu b/src/gpu/VirtualFluids_GPU/GPU/KineticEnergyAnalyzer.cu index e6e5c9b11447028b3f9b79e9ce551cb7d3d7e841..42e424062ffb3b13e1e787ceece30a05eb5527e2 100644 --- a/src/gpu/VirtualFluids_GPU/GPU/KineticEnergyAnalyzer.cu +++ b/src/gpu/VirtualFluids_GPU/GPU/KineticEnergyAnalyzer.cu @@ -19,7 +19,9 @@ #include "Parameter/Parameter.h" // includes, kernels #include "GPU/GPU_Kernels.cuh" -#include "Core/RealConstants.h" +#include <lbm/constants/NumericConstants.h> + +using namespace vf::lbm::constant; __global__ void kineticEnergyKernel (real* vx, real* vy, real* vz, real* rho, uint* neighborX, uint* neighborY, uint* neighborZ, uint* neighborWSB, uint* geo, real* kineticEnergy, uint* isFluid, uint size_Mat); diff --git a/src/gpu/VirtualFluids_GPU/GPU/LBMKernel.cu b/src/gpu/VirtualFluids_GPU/GPU/LBMKernel.cu index 41bde987cb1b5f517c6303226966bfd5909702a2..8b80e5ea9dbed3deef4c4332b2d43bf62ba9e48b 100644 --- a/src/gpu/VirtualFluids_GPU/GPU/LBMKernel.cu +++ b/src/gpu/VirtualFluids_GPU/GPU/LBMKernel.cu @@ -30,7 +30,7 @@ extern "C" void KernelCas27( unsigned int grid_nx, dim3 threads ( grid_nx, 1, 1 ); dim3 grid ( grid_ny, grid_nz ); // Gitter fuer Kollision und Propagation - LB_Kernel_Casc27<< < grid, threads >>>( s9, + LB_Kernel_Casc27<<< grid, threads >>>( s9, bcMatD, neighborX, neighborY, @@ -353,6 +353,7 @@ extern "C" void KernelKumNewCompSP27(unsigned int numberOfThreads, // EvenOrOdd); //getLastCudaError("LB_Kernel_Kum_New_Comp_SP_27 execution failed"); } + ////////////////////////////////////////////////////////////////////////// extern "C" void CumulantOnePreconditionedErrorDiffusionChimCompSP27(unsigned int numberOfThreads, real s9, @@ -3324,21 +3325,21 @@ extern "C" void QVelDevCompZeroPress27( unsigned int numberOfThreads, unsigned int size_Mat, bool evenOrOdd) { - int Grid = kArray / numberOfThreads; - //int Grid = (kQ / numberOfThreads)+1; - //int Grid1, Grid2; - //if (Grid>512) - //{ - // Grid1 = 512; - // Grid2 = (Grid/Grid1)+1; - //} - //else - //{ - // Grid1 = 1; - // Grid2 = Grid; - //} - //dim3 gridQ(Grid1, Grid2); - dim3 gridQ(Grid, 1, 1); + //int Grid = kArray / numberOfThreads; + 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 gridQ(Grid, 1, 1); dim3 threads(numberOfThreads, 1, 1 ); QVelDeviceCompZeroPress27<<< gridQ, threads >>> ( nx, @@ -3357,7 +3358,7 @@ extern "C" void QVelDevCompZeroPress27( unsigned int numberOfThreads, neighborZ, size_Mat, evenOrOdd); - getLastCudaError("QVelDeviceComp27 execution failed"); + getLastCudaError("QVelDeviceCompZeroPress27 execution failed"); } ////////////////////////////////////////////////////////////////////////// extern "C" void QVelDevIncompHighNu27(unsigned int numberOfThreads, diff --git a/src/gpu/VirtualFluids_GPU/GPU/NoSlipBCs27.cu b/src/gpu/VirtualFluids_GPU/GPU/NoSlipBCs27.cu index 72f10554242b2743074e36720758e6f305013b54..9c8392ff01859c42fe180d2127ada52a703abfdc 100644 --- a/src/gpu/VirtualFluids_GPU/GPU/NoSlipBCs27.cu +++ b/src/gpu/VirtualFluids_GPU/GPU/NoSlipBCs27.cu @@ -8,7 +8,9 @@ /* Device code */ #include "LBM/LB.h" #include "LBM/D3Q27.h" -#include "Core/RealConstants.h" +#include <lbm/constants/NumericConstants.h> + +using namespace vf::lbm::constant; ////////////////////////////////////////////////////////////////////////////// extern "C" __global__ void QDevice3rdMomentsComp27( int inx, @@ -2428,7 +2430,7 @@ extern "C" __global__ void QDevice27(int inx, real cu_sq=c3o2*(vx1*vx1+vx2*vx2+vx3*vx3); - //böser lecktest + //b�ser lecktest //q = q_dirE[k]; // if (q>=zero && q<=one) // { diff --git a/src/gpu/VirtualFluids_GPU/GPU/Particles.cu b/src/gpu/VirtualFluids_GPU/GPU/Particles.cu index f81d3f4e813a0753627e1ddf2808e799fbbe0738..a286434d805c0b60de2b36b61e5ebe65c7a45d11 100644 --- a/src/gpu/VirtualFluids_GPU/GPU/Particles.cu +++ b/src/gpu/VirtualFluids_GPU/GPU/Particles.cu @@ -1,7 +1,9 @@ /* Device code */ #include "LBM/LB.h" #include "LBM/D3Q27.h" -#include "Core/RealConstants.h" +#include <lbm/constants/NumericConstants.h> + +using namespace vf::lbm::constant; ////////////////////////////////////////////////////////////////////////////// diff --git a/src/gpu/VirtualFluids_GPU/GPU/PressBCs27.cu b/src/gpu/VirtualFluids_GPU/GPU/PressBCs27.cu index 149daf632f2e1a1ece46c0524228d157658745af..4d647cdd1f5cbefc2423fa9b95ecde29c3c89dbb 100644 --- a/src/gpu/VirtualFluids_GPU/GPU/PressBCs27.cu +++ b/src/gpu/VirtualFluids_GPU/GPU/PressBCs27.cu @@ -1,7 +1,9 @@ /* Device code */ #include "LBM/LB.h" #include "LBM/D3Q27.h" -#include "Core/RealConstants.h" +#include <lbm/constants/NumericConstants.h> + +using namespace vf::lbm::constant; //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// extern "C" __global__ void QInflowScaleByPressDevice27( real* rhoBC, diff --git a/src/gpu/VirtualFluids_GPU/GPU/Random.cu b/src/gpu/VirtualFluids_GPU/GPU/Random.cu index dae40e1b42561e54268950b817b0e35496356d77..702021f8145f2456a0d405814615b56d7d575422 100644 --- a/src/gpu/VirtualFluids_GPU/GPU/Random.cu +++ b/src/gpu/VirtualFluids_GPU/GPU/Random.cu @@ -1,7 +1,9 @@ /* Device code */ #include "LBM/LB.h" #include "LBM/D3Q27.h" -#include "Core/RealConstants.h" +#include <lbm/constants/NumericConstants.h> + +using namespace vf::lbm::constant; //random numbers #include <curand.h> #include <curand_kernel.h> diff --git a/src/gpu/VirtualFluids_GPU/GPU/ScaleCF27.cu b/src/gpu/VirtualFluids_GPU/GPU/ScaleCF27.cu index 43f06fb0f8dce6c5983f0123a49d73111bad396a..8be2edf3eecb512623572f925b20d0dd8682585d 100644 --- a/src/gpu/VirtualFluids_GPU/GPU/ScaleCF27.cu +++ b/src/gpu/VirtualFluids_GPU/GPU/ScaleCF27.cu @@ -8,7 +8,9 @@ /* Device code */ #include "LBM/LB.h" #include "LBM/D3Q27.h" -#include "Core/RealConstants.h" +#include <lbm/constants/NumericConstants.h> + +using namespace vf::lbm::constant; ////////////////////////////////////////////////////////////////////////// extern "C" __global__ void scaleCF_0817_comp_27( real* DC, diff --git a/src/gpu/VirtualFluids_GPU/GPU/ScaleCF_F3_27.cu b/src/gpu/VirtualFluids_GPU/GPU/ScaleCF_F3_27.cu index 0b4c4aae603c714756546ae29b0865840ea62774..5bafb27d28a94491d78c7d7572c959d6ec0cfb21 100644 --- a/src/gpu/VirtualFluids_GPU/GPU/ScaleCF_F3_27.cu +++ b/src/gpu/VirtualFluids_GPU/GPU/ScaleCF_F3_27.cu @@ -8,7 +8,9 @@ /* Device code */ #include "LBM/LB.h" #include "LBM/D3Q27.h" -#include "Core/RealConstants.h" +#include <lbm/constants/NumericConstants.h> + +using namespace vf::lbm::constant; ////////////////////////////////////////////////////////////////////////// extern "C" __global__ void scaleCF_comp_D3Q27F3_2018(real* DC, diff --git a/src/gpu/VirtualFluids_GPU/GPU/ScaleFC27.cu b/src/gpu/VirtualFluids_GPU/GPU/ScaleFC27.cu index 4b085a7d6ba9cd2e509adf8ff89fa6cc84664cbf..06d5086cc7f57c8245517f922662e8eea4571d05 100644 --- a/src/gpu/VirtualFluids_GPU/GPU/ScaleFC27.cu +++ b/src/gpu/VirtualFluids_GPU/GPU/ScaleFC27.cu @@ -8,7 +8,9 @@ /* Device code */ #include "LBM/LB.h" #include "LBM/D3Q27.h" -#include "Core/RealConstants.h" +#include <lbm/constants/NumericConstants.h> + +using namespace vf::lbm::constant; ////////////////////////////////////////////////////////////////////////// extern "C" __global__ void scaleFC_0817_comp_27( real* DC, diff --git a/src/gpu/VirtualFluids_GPU/GPU/ScaleFC_F3_27.cu b/src/gpu/VirtualFluids_GPU/GPU/ScaleFC_F3_27.cu index 3cccd8cb1f496f141b871cc5e5a2b244e44bd9de..efb0bf523b74bcbf17c8030ca53aaa127bca96e8 100644 --- a/src/gpu/VirtualFluids_GPU/GPU/ScaleFC_F3_27.cu +++ b/src/gpu/VirtualFluids_GPU/GPU/ScaleFC_F3_27.cu @@ -8,7 +8,9 @@ /* Device code */ #include "LBM/LB.h" #include "LBM/D3Q27.h" -#include "Core/RealConstants.h" +#include <lbm/constants/NumericConstants.h> + +using namespace vf::lbm::constant; ////////////////////////////////////////////////////////////////////////// extern "C" __global__ void scaleFC_comp_D3Q27F3_2018(real* DC, diff --git a/src/gpu/VirtualFluids_GPU/GPU/SchlafferBCs27.cu b/src/gpu/VirtualFluids_GPU/GPU/SchlafferBCs27.cu index 8fa1ff3a1e7251809fc663842d0e6b414f2af05e..9a28050cdb80d90de2746db83716dd52ece04ad6 100644 --- a/src/gpu/VirtualFluids_GPU/GPU/SchlafferBCs27.cu +++ b/src/gpu/VirtualFluids_GPU/GPU/SchlafferBCs27.cu @@ -1,7 +1,9 @@ /* Device code */ #include "LBM/LB.h" #include "LBM/D3Q27.h" -#include "Core/RealConstants.h" +#include <lbm/constants/NumericConstants.h> + +using namespace vf::lbm::constant; //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// extern "C" __global__ void PressSchlaff27(real* rhoBC, diff --git a/src/gpu/VirtualFluids_GPU/GPU/SetForcing27.cu b/src/gpu/VirtualFluids_GPU/GPU/SetForcing27.cu index fe8d74439592e7833cfc4274d36d8189854689e9..baad61888971dfcbaf6c04f8af60d09f9d433dd6 100644 --- a/src/gpu/VirtualFluids_GPU/GPU/SetForcing27.cu +++ b/src/gpu/VirtualFluids_GPU/GPU/SetForcing27.cu @@ -1,7 +1,9 @@ /* Device code */ #include "LBM/LB.h" #include "LBM/D3Q27.h" -#include "Core/RealConstants.h" +#include <lbm/constants/NumericConstants.h> + +using namespace vf::lbm::constant; //////////////////////////////////////////////////////////////////////////////// extern "C" __global__ void GetVeloforForcing27( real* DD, diff --git a/src/gpu/VirtualFluids_GPU/GPU/SlipBCs27.cu b/src/gpu/VirtualFluids_GPU/GPU/SlipBCs27.cu index 30540769f2641e47d7e44a1542165487c8e2724c..fc792a2c3a0f7438f4ee0882988a39f7260f21be 100644 --- a/src/gpu/VirtualFluids_GPU/GPU/SlipBCs27.cu +++ b/src/gpu/VirtualFluids_GPU/GPU/SlipBCs27.cu @@ -1,7 +1,9 @@ /* Device code */ #include "LBM/LB.h" #include "LBM/D3Q27.h" -#include "Core/RealConstants.h" +#include <lbm/constants/NumericConstants.h> + +using namespace vf::lbm::constant; ////////////////////////////////////////////////////////////////////////////// extern "C" __global__ void QSlipDevice27(real* DD, diff --git a/src/gpu/VirtualFluids_GPU/GPU/ThinWallBCs27.cu b/src/gpu/VirtualFluids_GPU/GPU/ThinWallBCs27.cu index 78e6f08dc523453214f0ec827a6db82c16b70d98..715a94cbf60e3f93737826da455fb232f1cd8f5d 100644 --- a/src/gpu/VirtualFluids_GPU/GPU/ThinWallBCs27.cu +++ b/src/gpu/VirtualFluids_GPU/GPU/ThinWallBCs27.cu @@ -9,7 +9,9 @@ /* Device code */ #include "LBM/LB.h" #include "LBM/D3Q27.h" -#include "Core/RealConstants.h" +#include <lbm/constants/NumericConstants.h> + +using namespace vf::lbm::constant; ///////////////////////////////////////////////////////////////////////// extern "C" __global__ void QVelDeviceCompThinWallsPartOne27( diff --git a/src/gpu/VirtualFluids_GPU/GPU/VelocityBCs27.cu b/src/gpu/VirtualFluids_GPU/GPU/VelocityBCs27.cu index f3288175c61888e6125c7159df9be099d3b7f2c4..e7f25874dca46df4a803f5c9e30a20bc480a3a10 100644 --- a/src/gpu/VirtualFluids_GPU/GPU/VelocityBCs27.cu +++ b/src/gpu/VirtualFluids_GPU/GPU/VelocityBCs27.cu @@ -9,7 +9,9 @@ /* Device code */ #include "LBM/LB.h" #include "LBM/D3Q27.h" -#include "Core/RealConstants.h" +#include <lbm/constants/NumericConstants.h> + +using namespace vf::lbm::constant; ////////////////////////////////////////////////////////////////////////////// extern "C" __global__ void QVelDeviceCompPlusSlip27(int inx, diff --git a/src/gpu/VirtualFluids_GPU/GPU/WaleCumulant27.cu b/src/gpu/VirtualFluids_GPU/GPU/WaleCumulant27.cu index d39e229c49fb14265132fc74d5bb3ba01ea59576..e911a716ce74c3f4ff8c323a733269dc7d260dc7 100644 --- a/src/gpu/VirtualFluids_GPU/GPU/WaleCumulant27.cu +++ b/src/gpu/VirtualFluids_GPU/GPU/WaleCumulant27.cu @@ -1,7 +1,9 @@ /* Device code */ #include "LBM/LB.h" #include "LBM/D3Q27.h" -#include "Core/RealConstants.h" +#include <lbm/constants/NumericConstants.h> + +using namespace vf::lbm::constant; #include "math.h" diff --git a/src/gpu/VirtualFluids_GPU/GPU/WallFunction.cu b/src/gpu/VirtualFluids_GPU/GPU/WallFunction.cu index 44319be27246c5b771e92d2b40d4812a88007980..20ef490ceb6224aef693ec0374d457fd2a4b9cde 100644 --- a/src/gpu/VirtualFluids_GPU/GPU/WallFunction.cu +++ b/src/gpu/VirtualFluids_GPU/GPU/WallFunction.cu @@ -1,7 +1,9 @@ /* Device code */ #include "LBM/LB.h" #include "LBM/D3Q27.h" -#include "Core/RealConstants.h" +#include <lbm/constants/NumericConstants.h> + +using namespace vf::lbm::constant; ////////////////////////////////////////////////////////////////////////////// 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/Init/DefineGrid.cpp b/src/gpu/VirtualFluids_GPU/Init/DefineGrid.cpp deleted file mode 100644 index ef718cd294c6f7ce8fd6ceb050398d19e2c15964..0000000000000000000000000000000000000000 --- a/src/gpu/VirtualFluids_GPU/Init/DefineGrid.cpp +++ /dev/null @@ -1,444 +0,0 @@ -#include "Init/DefineGrid.h" -#include "Init/ReadGeometry.h" -#include "Temperature/FindTemperature.h" -#include "FindInterface/FindInterface.h" -#include <cuda_runtime.h> -#include <helper_cuda.h> - -//////////////////////////////////////////////////////////////////////////////// -void defineGrid(Parameter* para, Communicator* comm, CudaMemoryManager* cudaManager) -{ - for (int lev=para->getFine(); lev >= para->getCoarse(); lev--) - { - /////////////////////////////////////////////////////////////////////////////////////////////////// - // Allocate Host Memory - /////////////////////////////////////////////////////////////////////////////////////////////////// - cudaManager->cudaAllocFull(lev); - /////////////////////////////////////////////////////////////////////////////////////////////////// - if (para->getDiffOn()==true) - { - checkCudaErrors( cudaMallocHost((void**) &(para->getParH(lev)->Conc_Full ), para->getParH(lev)->mem_size_real)); - } - /////////////////////////////////////////////////////////////////////////////////////////////////// - if (lev==para->getCoarse()) - { - /////////////////////////////////////////////////////////////////////////////////////////////////// - if (para->getReadGeo()==true) - { - std::cout << "read geometry...\n" ; - readGeometry(para, comm, lev, para->getGeometryFileC()); - std::cout << "done.\n"; - } - /////////////////////////////////////////////////////////////////////////////////////////////////// - for (unsigned int k=0; k<para->getParH(lev)->nz; k++) - { - for (unsigned int j=0; j<para->getParH(lev)->ny; j++) - { - for (unsigned int i=0; i<para->getParH(lev)->nx; i++) - { - int m = para->getParH(lev)->nx*(para->getParH(lev)->ny*k + j) + i; - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - if (para->getReadGeo()==true) - { - if ( i <= STARTOFFX || i >= para->getParH(lev)->gridNX + STARTOFFX - 1 - || j <= STARTOFFY || j >= para->getParH(lev)->gridNY + STARTOFFY - 1 - || k <= STARTOFFZ || k >= para->getParH(lev)->gridNZ + STARTOFFZ - 1 ) - { - para->getParH(lev)->geo[m] = GEO_VOID; - } - //else if ( (k >= STARTOFFZ +1) && (k <= STARTOFFZ + 20) ) - //{ - // para->getParH(lev)->geo[m] = GEO_FLUID; - //} - } - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - else - { - //////////////////////////////////////////////////////////////////////////////////////////////// - //Test - ////unsigned int centerX = para->getParH(lev)->gridNX / 2 + STARTOFFX; - ////unsigned int centerY = para->getParH(lev)->gridNY / 2 + STARTOFFY; - ////unsigned int centerZ = para->getParH(lev)->gridNZ / 4 + STARTOFFZ; - //real centerX = para->getParH(lev)->gridNX / 2. + STARTOFFX - 0.5; - //real centerY = para->getParH(lev)->gridNY / 2. + STARTOFFY - 0.5; - //real centerZ = para->getParH(lev)->gridNZ / 4. + STARTOFFZ - 0.5; - //real radius = para->getParH(lev)->gridNY / 10.;//2.56f; - //////unsigned int distSq = (centerX-i)*(centerX-i)+(centerY-j)*(centerY-j); - ////unsigned int distSq = (centerX-i)*(centerX-i)+(centerY-j)*(centerY-j)+(centerZ-k)*(centerZ-k); - //real distSq = (centerX-i)*(centerX-i)+(centerY-j)*(centerY-j)+(centerZ-k)*(centerZ-k); - //real radiSq = radius*radius; - //////////////////////////////////////////////////////////////////////////////////////////////// - - if ( i < STARTOFFX || i > para->getParH(lev)->gridNX + STARTOFFX - 1 - || j < STARTOFFY || j > para->getParH(lev)->gridNY + STARTOFFY - 1 - || k < STARTOFFZ || k > para->getParH(lev)->gridNZ + STARTOFFZ - 1 ) - { - para->getParH(lev)->geo[m] = GEO_VOID; - if (para->getDiffOn()==true) - { - para->getParH(lev)->Conc_Full[m] = 0.0; - } - } - //else if ( j == STARTOFFY || j == para->getParH(lev)->gridNY + STARTOFFY - 1 ) - //{ - // para->getParH(lev)->geo[m] = GEO_SOLID; - // if (ic.diffOn==true) - // { - // para->getParH(lev)->Conc_Full[m] = 0.0; - // } - //} - //else if ( k == STARTOFFZ || k == para->getParH(lev)->gridNZ + STARTOFFZ - 1) - //{ - // para->getParH(lev)->geo[m] = GEO_SOLID; - // if (ic.diffOn==true) - // { - // para->getParH(lev)->Conc_Full[m] = 0.0; - // } - //} - //else if ( i == STARTOFFX+1 || i == para->getParH(lev)->gridNX + STARTOFFX - 2 ) - //{ - // para->getParH(lev)->geo[m] = GEO_VELO; - // if (ic.diffOn==true) - // { - // para->getParH(lev)->Conc_Full[m] = 0.0; - // } - //} - //else if ((i >= para->getParH(lev+1)->XdistKn + STARTOFFX + 3) && (i <= (para->getParH(lev+1)->XdistKn + para->getParH(lev+1)->gridNX / 2) + STARTOFFX - 3) && - // (j >= para->getParH(lev+1)->YdistKn + STARTOFFY + 3) && (j <= (para->getParH(lev+1)->YdistKn + para->getParH(lev+1)->gridNY / 2) + STARTOFFY - 3) && - // (k >= para->getParH(lev+1)->ZdistKn + STARTOFFZ /*+ 3*/) && (k <= (para->getParH(lev+1)->ZdistKn + para->getParH(lev+1)->gridNZ / 2) + STARTOFFZ - 3) ) - //{ - // para->getParH(lev)->geo[m] = GEO_VOID; - // if (para->getDiffOn()==true) - // { - // para->getParH(lev)->Conc_Full[m] = 0.0; - // } - //} - //else if ((i >= para->getParH(lev)->gridNX / 4 + STARTOFFX + 4) && (i <= (para->getParH(lev)->gridNX * 3 / 4) + STARTOFFX - 4) && - // (j >= para->getParH(lev)->gridNY / 4 + STARTOFFY + 4) && (j <= (para->getParH(lev)->gridNY * 3 / 4) + STARTOFFY - 4) && - // (k >= para->getParH(lev)->gridNZ / 8 + STARTOFFZ + 4) && (k <= (para->getParH(lev)->gridNZ * 5 / 8) + STARTOFFZ - 4) && maxlevel>1) - //{ - // para->getParH(lev)->geo[m] = GEO_SOLID; - // if (ic.diffOn==true) - // { - // para->getParH(lev)->Conc_Full[m] = 0.0; - // } - //} - //else if (distSq < /*>*/ radiSq) - //{ - // para->getParH(lev)->geo[m] = GEO_SOLID; - // if (ic.diffOn==true) - // { - // para->getParH(lev)->Conc_Full[m] = 0.0; - // } - //} - //else if ( i <= STARTOFFX + 30 && i >=STARTOFFX + 20 - // && j <= STARTOFFY + 30 && j >=STARTOFFY + 20 - // && k <= STARTOFFZ + 30 && k >=STARTOFFZ + 20 ) - //{ - // para->getParH(lev)->geo[m] = GEO_FLUID; - // para->getParH(lev)->Conc_Full[m] = 1.0; - //} - //else if ( i <= STARTOFFX + 30 && i >=STARTOFFX + 20 - // && j <= STARTOFFY + 30 && j >=STARTOFFY + 20 - // && k <= STARTOFFZ + 30 && k >=STARTOFFZ + 20 ) - //{ - // para->getParH(lev)->geo[m] = GEO_FLUID; - // para->getParH(lev)->Conc_Full[m] = 1.0; - //} - else - { - para->getParH(lev)->geo[m] = GEO_FLUID; - if (para->getDiffOn()==true) - { - para->getParH(lev)->Conc_Full[m] = (real)para->getTemperatureInit(); - } - } - //if (i == STARTOFFZ) - //{ - // para->getParH(lev)->geo[m] = GEO_SOLID; - // if (para->getDiffOn()==true) - // { - // para->getParH(lev)->Conc_Full[m] = 0.0; - // } - //} - - } - para->getParH(lev)->k[m] = 0; - } - } - } - } - else if (lev==para->getFine() && para->getMaxLevel()>=1) - { - for (unsigned int k=0; k<para->getParH(lev)->nz; k++) - { - for (unsigned int j=0; j<para->getParH(lev)->ny; j++) - { - for (unsigned int i=0; i<para->getParH(lev)->nx; i++) - { - //unsigned int centerX = para->getParH(lev)->gridNX / 2 + STARTOFFX; - //unsigned int centerY = para->getParH(lev)->gridNY / 2 + STARTOFFY; - //unsigned int centerZ = para->getParH(lev)->gridNZ / 2 + STARTOFFZ; - //real radius = para->getParH(lev)->gridNY / 5.f;//2.56f; - //real centerX = para->getParH(lev)->gridNX / 2.f + STARTOFFX - 0.5f; - //real centerY = para->getParH(lev)->gridNY / 2.f + STARTOFFY - 0.5f; - //real centerZ = para->getParH(lev)->gridNZ / 2.f + STARTOFFZ - 0.5f; - //real radius = para->getParH(lev)->gridNY / 5.f;//2.56f; - - int m = para->getParH(lev)->nx*(para->getParH(lev)->ny*k + j) + i; - - ////unsigned int distSq = (centerX-i)*(centerX-i)+(centerY-j)*(centerY-j)+(centerZ-k)*(centerZ-k); - //real distSq = (centerX-i)*(centerX-i)+(centerY-j)*(centerY-j)+(centerZ-k)*(centerZ-k); - //real radiSq = radius*radius; - - //diff stuff - //real mradsq = (real)((real)i-(STARTOFFX + 30)) * (real)((real)i-(STARTOFFX + 30)) + (real)((real)j-(STARTOFFY + 30)) * (real)((real)j-(STARTOFFY + 30)) +(real) ((real)k-(STARTOFFZ + 30)) * (real) ((real)k-(STARTOFFZ + 30)); - - if ( i < STARTOFFX || i > para->getParH(lev)->gridNX + STARTOFFX - 1 - || j < STARTOFFY || j > para->getParH(lev)->gridNY + STARTOFFY - 1 - || k < STARTOFFZ || k > para->getParH(lev)->gridNZ + STARTOFFZ - 1 ) - { - para->getParH(lev)->geo[m] = GEO_VOID; - if (para->getDiffOn()==true) - { - para->getParH(lev)->Conc_Full[m] = 0.0; - } - } - //else if (i = STARTOFFX) - //{ - // para->getParH(lev)->geo[m] = GEO_SOLID; - // if (ic.diffOn==true) - // { - // para->getParH(lev)->Conc_Full[m] = 0.0; - // } - //} - //else if ((i > STARTOFFX ) && (i <= para->getParH(lev)->gridNX + STARTOFFX - 38) && - // (j >= 19 + STARTOFFY) && (j <= para->getParH(lev)->gridNY + STARTOFFY - 19) && - // (k >= 30 + STARTOFFZ) && (k <= para->getParH(lev)->gridNZ + STARTOFFZ - 30) ) - //{ - // para->getParH(lev)->geo[m] = GEO_SOLID; - // if (ic.diffOn==true) - // { - // para->getParH(lev)->Conc_Full[m] = 0.0; - // } - //} - //else if ((i >= STARTOFFX ) && (i <= (para->getParH(lev)->gridNX * 4 / 8) + STARTOFFX) && - // (j >= para->getParH(lev)->gridNY / 4 + STARTOFFY) && (j <= (para->getParH(lev)->gridNY * 3 / 4) + STARTOFFY) && - // (k >= para->getParH(lev)->gridNZ * 8 / 20 + STARTOFFZ) && (k <= (para->getParH(lev)->gridNZ * 12 / 20) + STARTOFFZ) ) - //{ - // para->getParH(lev)->geo[m] = GEO_SOLID; - // if (ic.diffOn==true) - // { - // para->getParH(lev)->Conc_Full[m] = 0.0; - // } - //} - ////diff stuff - //else if ( mradsq < 100.f ) - //{ - // para->getParH(lev)->geo[m] = GEO_FLUID; - // if (ic.diffOn==true) - // { - // para->getParH(lev)->Conc_Full[m] = 1.0f - mradsq * 0.01f; - // } - //} - //else if ( i <= STARTOFFX + 30 && i >=STARTOFFX + 20 - // && j <= STARTOFFY + 30 && j >=STARTOFFY + 20 - // && k <= STARTOFFZ + 30 && k >=STARTOFFZ + 20 ) - //{ - // para->getParH(lev)->geo[m] = GEO_FLUID; - // para->getParH(lev)->Conc_Full[m] = 1.0; - //} - //else if (distSq < radiSq) - //{ - // para->getParH(lev)->geo[m] = GEO_SOLID; - // if (ic.diffOn==true) - // { - // para->getParH(lev)->Conc_Full[m] = 0.0; - // } - //} - else - { - para->getParH(lev)->geo[m] = GEO_FLUID; - if (para->getDiffOn()==true) - { - para->getParH(lev)->Conc_Full[m] = 0.0; - } - } - //if (i == STARTOFFX) - //{ - // para->getParH(lev)->geo[m] = GEO_SOLID; - // if (ic.diffOn==true) - // { - // para->getParH(lev)->Conc_Full[m] = 0.0; - // } - //} - if (k == STARTOFFZ) - { - para->getParH(lev)->geo[m] = GEO_SOLID; - if (para->getDiffOn()==true) - { - para->getParH(lev)->Conc_Full[m] = 0.0; - } - } - - - para->getParH(lev)->k[m] = 0; - } - } - } - } - else if( lev > para->getCoarse() && lev < para->getFine() ) - { - for (unsigned int k=0; k<para->getParH(lev)->nz; k++) - { - for (unsigned int j=0; j<para->getParH(lev)->ny; j++) - { - for (unsigned int i=0; i<para->getParH(lev)->nx; i++) - { - int m = para->getParH(lev)->nx*(para->getParH(lev)->ny*k + j) + i; - - if ( i < STARTOFFX || i > para->getParH(lev)->gridNX + STARTOFFX - 1 - || j < STARTOFFY || j > para->getParH(lev)->gridNY + STARTOFFY - 1 - || k < STARTOFFZ || k > para->getParH(lev)->gridNZ + STARTOFFZ - 1 ) - { - para->getParH(lev)->geo[m] = GEO_VOID; - if (para->getDiffOn()==true) - { - para->getParH(lev)->Conc_Full[m] = 0.0; - } - } - else if ((i >= para->getParH(lev+1)->XdistKn + STARTOFFX + 3) && (i <= (para->getParH(lev+1)->XdistKn + para->getParH(lev+1)->gridNX / 2) + STARTOFFX - 3) && - (j >= para->getParH(lev+1)->YdistKn + STARTOFFY + 3) && (j <= (para->getParH(lev+1)->YdistKn + para->getParH(lev+1)->gridNY / 2) + STARTOFFY - 3) && - (k >= para->getParH(lev+1)->ZdistKn + STARTOFFZ + 3) && (k <= (para->getParH(lev+1)->ZdistKn + para->getParH(lev+1)->gridNZ / 2) + STARTOFFZ - 3) ) - { - para->getParH(lev)->geo[m] = GEO_VOID; - if (para->getDiffOn()==true) - { - para->getParH(lev)->Conc_Full[m] = 0.0; - } - } - //else if (i = STARTOFFX) - //{ - // para->getParH(lev)->geo[m] = GEO_SOLID; - // if (ic.diffOn==true) - // { - // para->getParH(lev)->Conc_Full[m] = 0.0; - // } - //} - //else if ((i >= para->getParH(lev)->gridNX / 4 + STARTOFFX + 3) && (i <= (para->getParH(lev)->gridNX * 3 / 4) + STARTOFFX - 3) && - // (j >= para->getParH(lev)->gridNY / 4 + STARTOFFY + 3) && (j <= (para->getParH(lev)->gridNY * 3 / 4) + STARTOFFY - 3) && - // (k >= para->getParH(lev)->gridNZ / 8 + STARTOFFZ + 3) && (k <= (para->getParH(lev)->gridNZ * 5 / 8) + STARTOFFZ - 3) ) - //{ - // para->getParH(lev)->geo[m] = GEO_SOLID; - //} - else - { - para->getParH(lev)->geo[m] = GEO_FLUID; - if (para->getDiffOn()==true) - { - para->getParH(lev)->Conc_Full[m] = 0.0; - } - } - if (i == STARTOFFX) - { - para->getParH(lev)->geo[m] = GEO_SOLID; - if (para->getDiffOn()==true) - { - para->getParH(lev)->Conc_Full[m] = 0.0; - } - } - para->getParH(lev)->k[m] = 0; - } - } - } - } - - //std::cout << "read geoFull..." ; - //readVFgeoFull(para, "D:/temp/gpuBenchmarkCylinder/GPU/geoFull.dat"); - //std::cout << "done.\n"; - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //Buffer GEO - //geo_sbuf_t.setSize(1,para->getParH(0)->sizePlaneXY); - //geo_rbuf_t.setSize(1,para->getParH(0)->sizePlaneXY); - //geo_sbuf_b.setSize(1,para->getParH(0)->sizePlaneXY); - //geo_rbuf_b.setSize(1,para->getParH(0)->sizePlaneXY); - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //Exchange GEO - //if (numprocs>1) - //{ - // exchangeDataGeo(lev); - //} - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - para->setSizeMatSparse(lev); - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - cudaManager->cudaAllocSP(lev); - //F3 - cudaManager->cudaAllocF3SP(lev); - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //Buffer - //sbuf_t.setSize(27,para->getParH(0)->sizePlaneST); - //rbuf_t.setSize(27,para->getParH(0)->sizePlaneRT); - //sbuf_b.setSize(27,para->getParH(0)->sizePlaneSB); - //rbuf_b.setSize(27,para->getParH(0)->sizePlaneRB); - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - if (para->getDiffOn()==true) - { - cudaManager->cudaAllocConc(lev); - } - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - para->fillSparse(lev); - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - cudaManager->cudaCopySP(lev); - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - if (para->getDiffOn()==true) - { - std::cout << "Maikes Thermo-Stuff...\n" ; - initTemperatur(para, cudaManager, lev);//thermostuff(lev); - std::cout << "done.\n"; - } - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - if ( lev < para->getFine() && para->getMaxLevel()>=1) - { - ////////////////////////////////////////////////////////////////////////////////////////////////////// - cudaManager->cudaAllocInterfaceCF(lev); - cudaManager->cudaAllocInterfaceFC(lev); - cudaManager->cudaAllocInterfaceOffCF(lev); - cudaManager->cudaAllocInterfaceOffFC(lev); - ////////////////////////////////////////////////////////////////////////////////////////////////////// - //Find Interpolation Interface - ////////////////////////////////////////////////////////////////////////////////////////////////////// - std::cout << "Anzahl der CF-Interpolationzellen vorher:" << para->getParH(lev)->K_CF << "\n"; - std::cout << "Anzahl der FC-Interpolationzellen vorher:" << para->getParH(lev)->K_FC << "\n"; - ////////////////////////////////////////////////////////////////////////////////////////////////////// - interpolation(para->getParH(lev)->intCF, para->getParH(lev)->intFC, - para->getParH(lev)->gridNX, para->getParH(lev)->gridNY, para->getParH(lev)->gridNZ, - para->getParH(lev+1)->gridNX, para->getParH(lev+1)->gridNY, para->getParH(lev+1)->gridNZ, - para->getParH(lev+1)->XdistKn, para->getParH(lev+1)->YdistKn, para->getParH(lev+1)->ZdistKn, - para->getParH(lev)->k, para->getParH(lev+1)->k, para->getParH(lev)->need_interface, - para->getParH(lev)->offCF, para->getParH(lev)->offFC); - ////////////////////////////////////////////////////////////////////////////////////////////////////// - std::cout << "Anzahl der CF-Interpolationzellen nachher:" << para->getParH(lev)->intCF.kCF << "\n"; - std::cout << "Anzahl der FC-Interpolationzellen nachher:" << para->getParH(lev)->intFC.kFC << "\n"; - ////////////////////////////////////////////////////////////////////////////////////////////////////// - //Test - //for (int test = 0; test < para->getParH(lev)->intCF.kCF; test++) - //{ - // para->getParH(lev)->offCF.xOffCF[test] = -para->getParH(lev)->offCF.xOffCF[test]; - // para->getParH(lev)->offCF.yOffCF[test] = -para->getParH(lev)->offCF.yOffCF[test]; - // para->getParH(lev)->offCF.zOffCF[test] = -para->getParH(lev)->offCF.zOffCF[test]; - //} - ////////////////////////////////////////////////////////////////////////////////////////////////////// - cudaManager->cudaCopyInterfaceCF(lev); - cudaManager->cudaCopyInterfaceFC(lev); - cudaManager->cudaCopyInterfaceOffCF(lev); - cudaManager->cudaCopyInterfaceOffFC(lev); - ////////////////////////////////////////////////////////////////////////////////////////////////////// - } - } - //////////////////////////////////////////////////////////////////////////////////////////////////////// - //if (para->getMyID() == para->getPressInID()) setSizeOfPlane(para, 0, para->getPressInZ()); - //else if(para->getMyID() == para->getPressOutID()) setSizeOfPlane(para, 0, para->getPressOutZ()); - //////////////////////////////////////////////////////////////////////////////////////////////////////// - -} diff --git a/src/gpu/VirtualFluids_GPU/Init/DefineGrid.h b/src/gpu/VirtualFluids_GPU/Init/DefineGrid.h deleted file mode 100644 index 3b8d18adf0cf0f3169fb2e3e108d58a670d9fd9c..0000000000000000000000000000000000000000 --- a/src/gpu/VirtualFluids_GPU/Init/DefineGrid.h +++ /dev/null @@ -1,11 +0,0 @@ -#ifndef DEFINE_GRID_H -#define DEFINE_GRID_H - -#include "LBM/LB.h" -#include "Parameter/Parameter.h" -#include "Communication/Communicator.h" -#include "GPU/CudaMemoryManager.h" - -extern "C" void defineGrid(Parameter* para, Communicator* comm, CudaMemoryManager* cudaManager); - -#endif diff --git a/src/gpu/VirtualFluids_GPU/Init/InitLattice.cpp b/src/gpu/VirtualFluids_GPU/Init/InitLattice.cpp index c5969ba6e2588012ab80cb041be89d72e9fab9f0..e2b7b34d75e901a468ae7f222ca9e0490cdbf4f8 100644 --- a/src/gpu/VirtualFluids_GPU/Init/InitLattice.cpp +++ b/src/gpu/VirtualFluids_GPU/Init/InitLattice.cpp @@ -1,86 +1,72 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// 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 InitLattice.h +//! \ingroup Init +//! \author Martin Schoenherr +//======================================================================================= #include "Init/InitLattice.h" -#include <cuda_runtime.h> -#include <helper_cuda.h> -#include "Parameter/Parameter.h" +#include "GPU/CudaMemoryManager.h" #include "GPU/GPU_Interface.h" -#include "Temperature/FindTemperature.h" +#include "Parameter/Parameter.h" #include "PreProcessor/PreProcessor.h" -#include "GPU/CudaMemoryManager.h" +#include "Temperature/FindTemperature.h" + -//////////////////////////////////////////////////////////////////////////////// void initLattice(SPtr<Parameter> para, SPtr<PreProcessor> preProcessor, SPtr<CudaMemoryManager> cudaManager) { - for (int lev=para->getFine(); lev >= para->getCoarse(); lev--) - { - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - preProcessor->init(para, lev); + for (int lev = para->getFine(); lev >= para->getCoarse(); lev--) { + preProcessor->init(para, lev); + + CalcMacCompSP27( + para->getParD(lev)->vx_SP, para->getParD(lev)->vy_SP, para->getParD(lev)->vz_SP, para->getParD(lev)->rho_SP, + para->getParD(lev)->press_SP, para->getParD(lev)->geoSP, para->getParD(lev)->neighborX_SP, + para->getParD(lev)->neighborY_SP, para->getParD(lev)->neighborZ_SP, para->getParD(lev)->size_Mat_SP, + para->getParD(lev)->numberofthreads, para->getParD(lev)->d0SP.f[0], para->getParD(lev)->evenOrOdd); + + if (para->getCalcMedian()) { + constexpr uint tdiff = 1; + CalcMacMedSP27(para->getParD(lev)->vx_SP_Med, para->getParD(lev)->vy_SP_Med, para->getParD(lev)->vz_SP_Med, + para->getParD(lev)->rho_SP_Med, para->getParD(lev)->press_SP_Med, para->getParD(lev)->geoSP, + para->getParD(lev)->neighborX_SP, para->getParD(lev)->neighborY_SP, + para->getParD(lev)->neighborZ_SP, tdiff, para->getParD(lev)->size_Mat_SP, + para->getParD(lev)->numberofthreads, para->getParD(lev)->evenOrOdd); + } + // advection - diffusion + if (para->getDiffOn()) { + + cudaManager->cudaAllocConc(lev); - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //CalcMacSP27(para->getParD(lev)->vx_SP, - // para->getParD(lev)->vy_SP, - // para->getParD(lev)->vz_SP, - // para->getParD(lev)->rho_SP, - // para->getParD(lev)->press_SP, - // para->getParD(lev)->geoSP, - // para->getParD(lev)->neighborX_SP, - // para->getParD(lev)->neighborY_SP, - // para->getParD(lev)->neighborZ_SP, - // para->getParD(lev)->size_Mat_SP, - // para->getParD(lev)->numberofthreads, - // para->getParD(lev)->d0SP.f[0], - // para->getParD(lev)->evenOrOdd); - //getLastCudaError("Kernel CalcMacSP27 execution failed"); - CalcMacCompSP27(para->getParD(lev)->vx_SP, - para->getParD(lev)->vy_SP, - para->getParD(lev)->vz_SP, - para->getParD(lev)->rho_SP, - para->getParD(lev)->press_SP, - para->getParD(lev)->geoSP, - para->getParD(lev)->neighborX_SP, - para->getParD(lev)->neighborY_SP, - para->getParD(lev)->neighborZ_SP, - para->getParD(lev)->size_Mat_SP, - para->getParD(lev)->numberofthreads, - para->getParD(lev)->d0SP.f[0], - para->getParD(lev)->evenOrOdd); - getLastCudaError("Kernel execution failed"); - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - if (para->getCalcMedian()) - { - unsigned int tdiff = 1; - CalcMacMedSP27( para->getParD(lev)->vx_SP_Med, - para->getParD(lev)->vy_SP_Med, - para->getParD(lev)->vz_SP_Med, - para->getParD(lev)->rho_SP_Med, - para->getParD(lev)->press_SP_Med, - para->getParD(lev)->geoSP, - para->getParD(lev)->neighborX_SP, - para->getParD(lev)->neighborY_SP, - para->getParD(lev)->neighborZ_SP, - tdiff, - para->getParD(lev)->size_Mat_SP, - para->getParD(lev)->numberofthreads, - para->getParD(lev)->evenOrOdd); - getLastCudaError("CalcMacMedSP27 execution failed"); - } - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - // advection - diffusion stuff - if (para->getDiffOn()==true){ - //malloc - //printf("vor cudaAllocConc\n"); - cudaManager->cudaAllocConc(lev); - //define init conc/temp - //printf("vor Schleife\n"); - for (unsigned int i = 0; i < para->getParH(lev)->size_Mat_SP; i++) - { - para->getParH(lev)->Conc[i] = para->getTemperatureInit(); - } - //malloc and init fs - //printf("vor initTemperatur\n"); - initTemperatur(para.get(), cudaManager.get(), lev); - } - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + for (unsigned int i = 0; i < para->getParH(lev)->size_Mat_SP; i++) { + para->getParH(lev)->Conc[i] = para->getTemperatureInit(); + } + initTemperatur(para.get(), cudaManager.get(), lev); + } } } diff --git a/src/gpu/VirtualFluids_GPU/Init/InitLattice.h b/src/gpu/VirtualFluids_GPU/Init/InitLattice.h index 4e781f96eead293631a8e1dcf3b5acf556cadb25..e69386b78f607a861d56f5dbca657ea482971e12 100644 --- a/src/gpu/VirtualFluids_GPU/Init/InitLattice.h +++ b/src/gpu/VirtualFluids_GPU/Init/InitLattice.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 InitLattice.h +//! \ingroup Init +//! \author Martin Schoenherr +//======================================================================================= #ifndef INIT_LATTICE_H #define INIT_LATTICE_H diff --git a/src/gpu/VirtualFluids_GPU/Init/PositionReader.cpp b/src/gpu/VirtualFluids_GPU/Init/PositionReader.cpp new file mode 100644 index 0000000000000000000000000000000000000000..034016b8177394f698ba71252a148bb71655d210 --- /dev/null +++ b/src/gpu/VirtualFluids_GPU/Init/PositionReader.cpp @@ -0,0 +1,213 @@ +#include "PositionReader.h" + +#include "Parameter/Parameter.h" + +#include <basics/utilities/UbFileInputASCII.h> + + +////////////////////////////////////////////////////////////////////////// +void PositionReader::readFilePropellerCylinderForAlloc(Parameter* para) +{ + UbFileInputASCII in(para->getpropellerCylinder()); + int test = 0, count = 0; + int maxlevel = in.readInteger(); + in.readLine(); + + for (int level = 0; level < maxlevel; level++) + { + para->getParH(level)->QPropeller.kQ = in.readInteger(); + para->getParD(level)->QPropeller.kQ = para->getParH(level)->QPropeller.kQ; + in.readLine(); + if (level == para->getFine()) + { + for(int u=0; u<para->getParH(level)->QPropeller.kQ; u++) + { + test = in.readInteger(); + if (para->getParH(level)->geoSP[test] == GEO_FLUID) + { + count++; + } + //////////////////////////////////////////////////////////////////////// + //for(unsigned int ix3=0; ix3<para->getParH(level)->nz; ix3++) + //{ + // for(unsigned int ix2=0; ix2<para->getParH(level)->ny; ix2++) + // { + // for(unsigned int ix1=0; ix1<para->getParH(level)->nx; ix1++) + // { + // unsigned int m = para->getParH(level)->nx*(para->getParH(level)->ny*ix3 + ix2) + ix1; + // if (para->getParH(level)->k[m] == test) + // { + // if(para->getParH(level)->geo[m] == 1) + // { + // count++; + // } + // } + // } + // } + //} + //count++; + //////////////////////////////////////////////////////////////////////// + in.readDouble(); + in.readDouble(); + in.readDouble(); + in.readLine(); + } + } + else + { + for(int u=0; u<para->getParH(level)->QPropeller.kQ; u++) + { + in.readInteger(); + in.readDouble(); + in.readDouble(); + in.readDouble(); + in.readLine(); + } + } + para->getParH(level)->QPropeller.kQ = count; + para->getParD(level)->QPropeller.kQ = para->getParH(level)->QPropeller.kQ; + } +} +////////////////////////////////////////////////////////////////////////// + + +////////////////////////////////////////////////////////////////////////// +void PositionReader::readFilePropellerCylinder(Parameter* para) +{ + UbFileInputASCII in(para->getpropellerCylinder()); + int test = 0, count = 0; + int maxlevel = in.readInteger(); + in.readLine(); + + for (int level = 0; level < maxlevel; level++) + { + int allnodes = in.readInteger(); + in.readLine(); + if (level == para->getFine()) + { + for(int u=0; u<allnodes; u++) + { + test = in.readInteger(); + //////////////////////////////////////////////////////////////////////// + if (para->getParH(level)->geoSP[test] == GEO_FLUID) + { + para->getParH(level)->QPropeller.k[count] = test; + para->getParH(level)->QPropeller.Vx[count] = (real)in.readDouble(); + para->getParH(level)->QPropeller.Vy[count] = (real)in.readDouble(); + para->getParH(level)->QPropeller.Vz[count] = (real)in.readDouble(); + para->getParH(level)->QPropeller.RhoBC[count] = 0.0f; + count++; + } + else + { + in.readDouble(); + in.readDouble(); + in.readDouble(); + } + //para->getParH(level)->QPropeller.k[count] = test; + //para->getParH(level)->QPropeller.Vx[count] = (real)in.readDouble(); + //para->getParH(level)->QPropeller.Vy[count] = (real)in.readDouble(); + //para->getParH(level)->QPropeller.Vz[count] = (real)in.readDouble(); + //para->getParH(level)->QPropeller.Vx[count] = 0.07f; + //para->getParH(level)->QPropeller.Vy[count] = 0.0f; + //para->getParH(level)->QPropeller.Vz[count] = 0.0f; + in.readLine(); + } + } + else + { + for(int u=0; u<allnodes; u++) + { + in.readInteger(); + in.readDouble(); + in.readDouble(); + in.readDouble(); + in.readLine(); + } + } + printf("allnodes = %d, count = %d\n", allnodes, count); + } +} +////////////////////////////////////////////////////////////////////////// + + +////////////////////////////////////////////////////////////////////////// +void PositionReader::definePropellerQs(Parameter* para) +{ + ////////////////////////////////////////////////////////////////// + //preprocessing + real* QQ = para->getParH(para->getFine())->QPropeller.q27[0]; + unsigned int sizeQ = para->getParH(para->getFine())->QPropeller.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]; + ////////////////////////////////////////////////////////////////// + for(int u=0; u<para->getParH(para->getFine())->QPropeller.kQ; u++) + { + for (int dir = dirE; dir<=dirBSW; dir++) + { + if ((dir==dirE) || + (dir==dirNE) || (dir==dirSE) || (dir==dirTE) || (dir==dirBE) || + (dir==dirTNE)|| (dir==dirBNE)|| (dir==dirTSE)|| (dir==dirBSE)) + { + Q.q27[dir][u] = 1.0f; + } + else + { + Q.q27[dir][u] = -1.0f; + } + } + } + ////////////////////////////////////////////////////////////////// +} +////////////////////////////////////////////////////////////////////////// + + +////////////////////////////////////////////////////////////////////////// +void PositionReader::readMeasurePoints( Parameter* para ) +{ + UbFileInputASCII in(para->getmeasurePoints()); + int numberOfAllNodes = in.readInteger(); + in.readLine(); + int tempLevel; + MeasurePoints tempMP; + //printf("done, init the values...\n"); + for (int u = 0; u < numberOfAllNodes; u++) + { + tempMP.name = in.readString(); + //printf("done, read the name...\n"); + tempMP.k = in.readInteger(); + //printf("done, read k...\n"); + tempLevel = in.readInteger(); + //printf("done, read level...\n"); + in.readLine(); + //printf("done, read the values...\n"); + para->getParH(tempLevel)->MP.push_back(tempMP); + //printf("done, put it into a vector...\n"); + } +} diff --git a/src/gpu/VirtualFluids_GPU/Init/PositionReader.h b/src/gpu/VirtualFluids_GPU/Init/PositionReader.h new file mode 100644 index 0000000000000000000000000000000000000000..b12a17c8148f4b5b1d5b656e0c9ea04d88eee89f --- /dev/null +++ b/src/gpu/VirtualFluids_GPU/Init/PositionReader.h @@ -0,0 +1,15 @@ +#ifndef POSITION_READER_H +#define POSITION_READER_H + +class Parameter; + +class PositionReader +{ +public: + static void readFilePropellerCylinderForAlloc(Parameter* para); + static void readFilePropellerCylinder(Parameter* para); + static void definePropellerQs(Parameter* para); + static void readMeasurePoints(Parameter* para); +}; + +#endif \ No newline at end of file diff --git a/src/gpu/VirtualFluids_GPU/Init/ReadGeometry.cpp b/src/gpu/VirtualFluids_GPU/Init/ReadGeometry.cpp deleted file mode 100644 index b52e4eb64ab6f4582d4a5c079eac4aac5199356e..0000000000000000000000000000000000000000 --- a/src/gpu/VirtualFluids_GPU/Init/ReadGeometry.cpp +++ /dev/null @@ -1,43 +0,0 @@ -#include "Init/ReadGeometry.h" - -//////////////////////////////////////////////////////////////////////////////// -void readGeometry(Parameter* para, Communicator* comm, int lev, std::string geometryFile) -{ - int dataSizePerGPU = para->getParH(lev)->gridNX * para->getParH(lev)->gridNY * para->getParH(lev)->gridNZ; - unsigned int dataSizeTotal = para->getParH(lev)->gridNX * para->getParH(lev)->gridNY * para->getParH(lev)->gridNZ * para->getNumprocs(); - unsigned int * dataRoot = NULL; - - unsigned int m, l; - if(para->getMyID() == 0) // Are we the root node? - { - dataRoot = new unsigned int[dataSizeTotal]; - VtkGeometryReader::readFile(geometryFile, dataRoot); - } - - std::cout << "dataSizePerGPU size: " << dataSizePerGPU << "\n"; - - unsigned int *dataGPU = new unsigned int[dataSizePerGPU]; - - std::cout << "distributeGeometry: start \n"; - comm->distributeGeometry(dataRoot, dataGPU, dataSizePerGPU); - std::cout << "distributeGeometry: end \n"; - - l=0; - for(unsigned int k=STARTOFFZ ; k < para->getParH(lev)->gridNZ + STARTOFFZ ; k++) - { - for(unsigned int j=STARTOFFY ; j < para->getParH(lev)->gridNY + STARTOFFY ; j++) - { - for(unsigned int i=STARTOFFX ; i < para->getParH(lev)->gridNX + STARTOFFX ; i++) - { - m = para->getParH(lev)->nx* (para->getParH(lev)->ny * k + j) + i; - para->getParH(lev)->geo[m] = dataGPU[l]; - l++; - } - } - } - - if(para->getMyID() == 0) - delete [] dataRoot; - - delete [] dataGPU; -} diff --git a/src/gpu/VirtualFluids_GPU/Init/ReadGeometry.h b/src/gpu/VirtualFluids_GPU/Init/ReadGeometry.h deleted file mode 100644 index 26c070fa4431a602a1af522516163673adfd3565..0000000000000000000000000000000000000000 --- a/src/gpu/VirtualFluids_GPU/Init/ReadGeometry.h +++ /dev/null @@ -1,12 +0,0 @@ -#ifndef READ_GEOMETRY_H -#define READ_GEOMETRY_H - -#include "Parameter/Parameter.h" -#include "Communication/Communicator.h" -#include "Input/VtkGeometryReader.h" - -#include <iostream> - -extern "C" void readGeometry(Parameter* para, Communicator* comm, int lev, std::string geometryFile); - -#endif diff --git a/src/gpu/VirtualFluids_GPU/Init/SetParameter.cpp b/src/gpu/VirtualFluids_GPU/Init/SetParameter.cpp deleted file mode 100644 index 08fd70961a8a9d0e89526113156e00bb41281dbb..0000000000000000000000000000000000000000 --- a/src/gpu/VirtualFluids_GPU/Init/SetParameter.cpp +++ /dev/null @@ -1,260 +0,0 @@ -//#include "Init/SetParameter.h" -//#include "Interface_OpenFOAM/Interface.h" -// -////////////////////////////////////////////////////////////////////////////////// -//void setParameters(Parameter* para, Communicator* comm, std::string &cstr) -//{ -// ConfigFile cf(cstr.c_str()); -// if ( !cf.read() ) -// { -// std::string exceptionText = "Unable to read configuration file\n"; -// throw exceptionText; -// } -// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// para->setMaxDev( StringUtil::toInt(cf.getValue( "NumberOfDevices" ))); -// para->setMyID( comm->getPID()); -// para->setNumprocs( comm->getNummberOfProcess()); -// para->setDevices( StringUtil::toVector<int>(cf.getValue( "Devices" ))); -// devCheck( comm->mapCudaDevice(para->getMyID(), para->getNumprocs(), para->getDevices(), para->getMaxDev())); -// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// std::string _path = cf.getValue( "Path" ); -// std::string _prefix = cf.getValue( "Prefix" ); -// std::string _gridpath = cf.getValue( "GridPath" ); -// std::string gridPath = getGridPath(para, _gridpath); -// para->setOutputPath( _path); -// para->setOutputPrefix( _prefix); -// para->setFName( _path + "/" + _prefix); -// para->setPrintFiles( false); -// para->setPrintFiles( StringUtil::toBool( cf.getValue( "WriteGrid" ))); -// para->setGeometryValues( StringUtil::toBool( cf.getValue( "GeometryValues" ))); -// para->setCalc2ndOrderMoments( StringUtil::toBool( cf.getValue( "calc2ndOrderMoments" ))); -// para->setCalc3rdOrderMoments( StringUtil::toBool( cf.getValue( "calc3rdOrderMoments" ))); -// para->setCalcHighOrderMoments(StringUtil::toBool( cf.getValue( "calcHigherOrderMoments" ))); -// para->setReadGeo( StringUtil::toBool( cf.getValue( "ReadGeometry" ))); -// para->setCalcMedian( StringUtil::toBool( cf.getValue( "calcMedian" ))); -// para->setConcFile( StringUtil::toBool( cf.getValue( "UseConcFile" ))); -// para->setUseMeasurePoints( StringUtil::toBool( cf.getValue( "UseMeasurePoints"))); -// para->setUseWale( StringUtil::toBool( cf.getValue( "UseWale" ))); -// para->setSimulatePorousMedia( StringUtil::toBool( cf.getValue( "SimulatePorousMedia" ))); -// para->setD3Qxx( StringUtil::toInt( cf.getValue( "D3Qxx" ))); -// para->setMaxLevel( StringUtil::toInt( cf.getValue( "NOGL" ))); -// para->setTEnd( StringUtil::toInt( cf.getValue( "TimeEnd" ))); -// para->setTOut( StringUtil::toInt( cf.getValue( "TimeOut" ))); -// para->setTStartOut( StringUtil::toInt( cf.getValue( "TimeStartOut"))); -// para->setTimeCalcMedStart( StringUtil::toInt( cf.getValue( "TimeStartCalcMedian" ))); -// para->setTimeCalcMedEnd( StringUtil::toInt( cf.getValue( "TimeEndCalcMedian" ))); -// para->setPressInID( StringUtil::toInt( cf.getValue( "PressInID" ))); -// para->setPressOutID( StringUtil::toInt( cf.getValue( "PressOutID" ))); -// para->setPressInZ( StringUtil::toInt( cf.getValue( "PressInZ" ))); -// para->setPressOutZ( StringUtil::toInt( cf.getValue( "PressOutZ" ))); -// ////////////////////////////////////////////////////////////////////////// -// para->setDiffOn( StringUtil::toBool( cf.getValue( "DiffOn" ))); -// para->setDiffMod( StringUtil::toInt( cf.getValue( "DiffMod" ))); -// para->setDiffusivity( StringUtil::toFloat(cf.getValue( "Diffusivity" ))); -// para->setTemperatureInit( StringUtil::toFloat(cf.getValue( "Temp" ))); -// para->setTemperatureBC( StringUtil::toFloat(cf.getValue( "TempBC" ))); -// ////////////////////////////////////////////////////////////////////////// -// para->setViscosity( StringUtil::toFloat(cf.getValue( "Viscosity_LB" ))); -// para->setVelocity( StringUtil::toFloat(cf.getValue( "Velocity_LB" ))); -// para->setViscosityRatio( StringUtil::toFloat(cf.getValue( "Viscosity_Ratio_World_to_LB" ))); -// para->setVelocityRatio( StringUtil::toFloat(cf.getValue( "Velocity_Ratio_World_to_LB" ))); -// para->setDensityRatio( StringUtil::toFloat(cf.getValue( "Density_Ratio_World_to_LB" ))); -// para->setPressRatio( StringUtil::toFloat(cf.getValue( "Delta_Press" ))); -// para->setRealX( StringUtil::toFloat(cf.getValue( "SliceRealX" ))); -// para->setRealY( StringUtil::toFloat(cf.getValue( "SliceRealY" ))); -// para->setFactorPressBC( StringUtil::toFloat(cf.getValue( "dfpbc" ))); -// para->setGeometryFileC( cf.getValue( "GeometryC" )); -// para->setGeometryFileM( cf.getValue( "GeometryM" )); -// para->setGeometryFileF( cf.getValue( "GeometryF" )); -// ////////////////////////////////////////////////////////////////////////// -// para->setgeoVec( gridPath + cf.getValue( "geoVec" )); -// para->setcoordX( gridPath + cf.getValue( "coordX" )); -// para->setcoordY( gridPath + cf.getValue( "coordY" )); -// para->setcoordZ( gridPath + cf.getValue( "coordZ" )); -// para->setneighborX( gridPath + cf.getValue( "neighborX" )); -// para->setneighborY( gridPath + cf.getValue( "neighborY" )); -// para->setneighborZ( gridPath + cf.getValue( "neighborZ" )); -// para->setscaleCFC( gridPath + cf.getValue( "scaleCFC" )); -// para->setscaleCFF( gridPath + cf.getValue( "scaleCFF" )); -// para->setscaleFCC( gridPath + cf.getValue( "scaleFCC" )); -// para->setscaleFCF( gridPath + cf.getValue( "scaleFCF" )); -// para->setscaleOffsetCF( gridPath + cf.getValue( "scaleOffsetCF" )); -// para->setscaleOffsetFC( gridPath + cf.getValue( "scaleOffsetFC" )); -// para->setgeomBoundaryBcQs( gridPath + cf.getValue( "geomBoundaryBcQs" )); -// para->setgeomBoundaryBcValues(gridPath + cf.getValue( "geomBoundaryBcValues" )); -// para->setinletBcQs( gridPath + cf.getValue( "inletBcQs" )); -// para->setinletBcValues( gridPath + cf.getValue( "inletBcValues" )); -// para->setoutletBcQs( gridPath + cf.getValue( "outletBcQs" )); -// para->setoutletBcValues( gridPath + cf.getValue( "outletBcValues" )); -// para->settopBcQs( gridPath + cf.getValue( "topBcQs" )); -// para->settopBcValues( gridPath + cf.getValue( "topBcValues" )); -// para->setbottomBcQs( gridPath + cf.getValue( "bottomBcQs" )); -// para->setbottomBcValues( gridPath + cf.getValue( "bottomBcValues" )); -// para->setfrontBcQs( gridPath + cf.getValue( "frontBcQs" )); -// para->setfrontBcValues( gridPath + cf.getValue( "frontBcValues" )); -// para->setbackBcQs( gridPath + cf.getValue( "backBcQs" )); -// para->setbackBcValues( gridPath + cf.getValue( "backBcValues" )); -// para->setnumberNodes( gridPath + cf.getValue( "numberNodes" )); -// para->setLBMvsSI( gridPath + cf.getValue( "LBMvsSI" )); -// //////////////////////////////gridPath + //////////////////////////////////////////// -// para->setmeasurePoints( gridPath + cf.getValue( "measurePoints" )); -// para->setpropellerValues( gridPath + cf.getValue( "propellerValues" )); -// para->setclockCycleForMP( StringUtil::toFloat(cf.getValue( "measureClockCycle" ))); -// para->settimestepForMP( StringUtil::toInt(cf.getValue( "measureTimestep" ))); -// para->setcpTop( gridPath + cf.getValue( "cpTop" )); -// para->setcpBottom( gridPath + cf.getValue( "cpBottom" )); -// para->setcpBottom2( gridPath + cf.getValue( "cpBottom2" )); -// para->setConcentration( gridPath + cf.getValue( "Concentration" )); -// ////////////////////////////////////////////////////////////////////////// -// //Normals - Geometry -// para->setgeomBoundaryNormalX( gridPath + cf.getValue( "geomBoundaryNormalX" )); -// para->setgeomBoundaryNormalY( gridPath + cf.getValue( "geomBoundaryNormalY" )); -// para->setgeomBoundaryNormalZ( gridPath + cf.getValue( "geomBoundaryNormalZ" )); -// //Normals - Inlet -// para->setInflowBoundaryNormalX( gridPath + cf.getValue( "inletBoundaryNormalX" )); -// para->setInflowBoundaryNormalY( gridPath + cf.getValue( "inletBoundaryNormalY" )); -// para->setInflowBoundaryNormalZ( gridPath + cf.getValue( "inletBoundaryNormalZ" )); -// //Normals - Outlet -// para->setOutflowBoundaryNormalX( gridPath + cf.getValue( "outletBoundaryNormalX" )); -// para->setOutflowBoundaryNormalY( gridPath + cf.getValue( "outletBoundaryNormalY" )); -// para->setOutflowBoundaryNormalZ( gridPath + cf.getValue( "outletBoundaryNormalZ" )); -// ////////////////////////////////////////////////////////////////////////// -// //Forcing -// para->setForcing(StringUtil::toFloat(cf.getValue( "ForcingX")), StringUtil::toFloat(cf.getValue( "ForcingY")), StringUtil::toFloat(cf.getValue( "ForcingZ"))); -// ////////////////////////////////////////////////////////////////////////// -// //Particles -// para->setCalcParticles( StringUtil::toBool( cf.getValue( "calcParticles" ))); -// para->setParticleBasicLevel(StringUtil::toInt( cf.getValue( "baseLevel" ))); -// para->setParticleInitLevel( StringUtil::toInt( cf.getValue( "initLevel" ))); -// para->setNumberOfParticles( StringUtil::toInt( cf.getValue( "numberOfParticles" ))); -// para->setneighborWSB( gridPath + cf.getValue( "neighborWSB" )); -// para->setStartXHotWall( StringUtil::toDouble(cf.getValue("startXHotWall" ))); -// para->setEndXHotWall( StringUtil::toDouble(cf.getValue("endXHotWall" ))); -// ////////////////////////////////////////////////////////////////////////// -// //for Multi GPU -// if (para->getNumprocs()>1) -// { -// //////////////////////////////////////////////////////////////////////////// -// ////1D domain decomposition -// //std::vector<std::string> sendProcNeighbors; -// //std::vector<std::string> recvProcNeighbors; -// //for (int i = 0; i<para->getNumprocs();i++) -// //{ -// // sendProcNeighbors.push_back(gridPath + StringUtil::toString(i) + "s.dat"); -// // recvProcNeighbors.push_back(gridPath + StringUtil::toString(i) + "r.dat"); -// //} -// //para->setPossNeighborFiles(sendProcNeighbors, "send"); -// //para->setPossNeighborFiles(recvProcNeighbors, "recv"); -// ////////////////////////////////////////////////////////////////////////// -// //3D domain decomposition -// std::vector<std::string> sendProcNeighborsX, sendProcNeighborsY, sendProcNeighborsZ; -// std::vector<std::string> recvProcNeighborsX, recvProcNeighborsY, recvProcNeighborsZ; -// for (int i = 0; i<para->getNumprocs();i++) -// { -// sendProcNeighborsX.push_back(gridPath + StringUtil::toString(i) + "Xs.dat"); -// sendProcNeighborsY.push_back(gridPath + StringUtil::toString(i) + "Ys.dat"); -// sendProcNeighborsZ.push_back(gridPath + StringUtil::toString(i) + "Zs.dat"); -// recvProcNeighborsX.push_back(gridPath + StringUtil::toString(i) + "Xr.dat"); -// recvProcNeighborsY.push_back(gridPath + StringUtil::toString(i) + "Yr.dat"); -// recvProcNeighborsZ.push_back(gridPath + StringUtil::toString(i) + "Zr.dat"); -// } -// para->setPossNeighborFilesX(sendProcNeighborsX, "send"); -// para->setPossNeighborFilesY(sendProcNeighborsY, "send"); -// para->setPossNeighborFilesZ(sendProcNeighborsZ, "send"); -// para->setPossNeighborFilesX(recvProcNeighborsX, "recv"); -// para->setPossNeighborFilesY(recvProcNeighborsY, "recv"); -// para->setPossNeighborFilesZ(recvProcNeighborsZ, "recv"); -// } -// ////////////////////////////////////////////////////////////////////////// -// //para->setkFull( cf.getValue( "kFull" )); -// //para->setgeoFull( cf.getValue( "geoFull" )); -// //para->setnoSlipBcPos( cf.getValue( "noSlipBcPos" )); -// //para->setnoSlipBcQs( cf.getValue( "noSlipBcQs" )); -// //para->setnoSlipBcValues( cf.getValue( "noSlipBcValues" )); -// //para->setnoSlipBcValue( cf.getValue( "noSlipBcValue" )); -// //para->setslipBcPos( cf.getValue( "slipBcPos" )); -// //para->setslipBcQs( cf.getValue( "slipBcQs" )); -// //para->setslipBcValue( cf.getValue( "slipBcValue" )); -// //para->setpressBcPos( cf.getValue( "pressBcPos" )); -// //para->setpressBcQs( cf.getValue( "pressBcQs" )); -// //para->setpressBcValues( cf.getValue( "pressBcValues" )); -// //para->setpressBcValue( cf.getValue( "pressBcValue" )); -// //para->setvelBcQs( cf.getValue( "velBcQs" )); -// //para->setvelBcValues( cf.getValue( "velBcValues" )); -// //para->setpropellerCylinder( cf.getValue( "propellerCylinder" )); -// //para->setpropellerQs( cf.getValue( "propellerQs" )); -// //para->setwallBcQs( cf.getValue( "wallBcQs" )); -// //para->setwallBcValues( cf.getValue( "wallBcValues" )); -// //para->setperiodicBcQs( cf.getValue( "periodicBcQs" )); -// //para->setperiodicBcValues( cf.getValue( "periodicBcValues" )); -// //cout << "Try this: " << para->getgeomBoundaryBcValues() << endl; -// -// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// //Restart -// para->setTimeDoCheckPoint( StringUtil::toInt( cf.getValue( "TimeDoCheckPoint" ))); -// para->setTimeDoRestart( StringUtil::toInt( cf.getValue( "TimeDoRestart" ))); -// para->setDoCheckPoint( StringUtil::toBool( cf.getValue( "DoCheckPoint" ))); -// para->setDoRestart( StringUtil::toBool( cf.getValue( "DoRestart" ))); -// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// para->setGridX( StringUtil::toVector<int>(cf.getValue( "GridX" ))); //GridX = StringUtil::toVector<int>(cf.getValue( "GridX" )); -// para->setGridY( StringUtil::toVector<int>(cf.getValue( "GridY" ))); //GridY = StringUtil::toVector<int>(cf.getValue( "GridY" )); -// para->setGridZ( StringUtil::toVector<int>(cf.getValue( "GridZ" ))); //GridZ = StringUtil::toVector<int>(cf.getValue( "GridZ" )); -// para->setDistX( StringUtil::toVector<int>(cf.getValue( "DistX" ))); //DistX = StringUtil::toVector<int>(cf.getValue( "DistX" )); -// para->setDistY( StringUtil::toVector<int>(cf.getValue( "DistY" ))); //DistY = StringUtil::toVector<int>(cf.getValue( "DistY" )); -// para->setDistZ( StringUtil::toVector<int>(cf.getValue( "DistZ" ))); //DistZ = StringUtil::toVector<int>(cf.getValue( "DistZ" )); -// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// para->setNeedInterface( StringUtil::toVector<bool>(cf.getValue( "NeedInterface" ))); -// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// Interface *config = new Interface(false); -// config->setDimensions(para); -// config->setBoundingBox(para); -// delete config; -// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// para->initParameter(); -// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// para->setRe(para->getVelocity() * (real)1.0 / para->getViscosity()); -// para->setPhi((real) 0.0); -// para->setlimitOfNodesForVTK(30000000); //max 30 Million nodes per VTK file -// if (para->getDoRestart()) -// { -// para->setStartTurn(para->getTimeDoRestart()); -// } -// else -// { -// para->setStartTurn((unsigned int)0); //100000 -// } -// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -//} -// -// -// -// -// -// -// -// -// -// -// -// -// -// -// -// -// -// -////////////////////////////////////////////////////////////////////////////////// -//std::string getGridPath(Parameter* para, std::string Gridpath) -//{ -// if(para->getNumprocs()==1) -// { -// return Gridpath + "/"; -// } -// else -// { -// return Gridpath + "/" + StringUtil::toString(para->getMyID()) + "/"; -// } -// -//} -////////////////////////////////////////////////////////////////////////////////// -// diff --git a/src/gpu/VirtualFluids_GPU/Init/SetParameter.h b/src/gpu/VirtualFluids_GPU/Init/SetParameter.h deleted file mode 100644 index 9fad54f04740f69122d74ef7e8c32b3af69af208..0000000000000000000000000000000000000000 --- a/src/gpu/VirtualFluids_GPU/Init/SetParameter.h +++ /dev/null @@ -1,15 +0,0 @@ -//#ifndef SET_PARAMETER_H -//#define SET_PARAMETER_H -// -//#include "Parameter/Parameter.h" -//#include "Input/ConfigFile.h" -//#include "Utilities/StringUtil.hpp" -//#include "GPU/devCheck.h" -//#include "Communication/Communicator.h" -// -//#include <iostream> -// -//void setParameters(Parameter* para, Communicator* comm, std::string &cstr); -//std::string getGridPath(Parameter* para, std::string Gridpath); -// -//#endif diff --git a/src/gpu/VirtualFluids_GPU/Init/VfReader.cpp b/src/gpu/VirtualFluids_GPU/Init/VfReader.cpp index 89d214186f9bf7140e2689bc522d21f19c7603a0..aa94cb658764c4648e30811255312afd26c92cc4 100644 --- a/src/gpu/VirtualFluids_GPU/Init/VfReader.cpp +++ b/src/gpu/VirtualFluids_GPU/Init/VfReader.cpp @@ -1,284 +1,10 @@ #include "Init/VfReader.h" +#include "Parameter/Parameter.h" +#include "Communication/Communicator.h" +#include "Init/PositionReader.h" #include "GPU/CudaMemoryManager.h" -//////////////////////////////////////////////////////////////////////////////// -void readVFkFull(Parameter* para, CudaMemoryManager* cudaManager, const std::string geometryFile) -{ - kFullReader::readFileForAlloc(geometryFile, para); - - for (int lev = 0; lev <= para->getMaxLevel(); lev++) - { - cudaManager->cudaAllocFull(lev); - ////////////////////////////////////////////////////////////////////////// - for(unsigned int ix3=0; ix3<para->getParH(lev)->nz; ix3++) - { - for(unsigned int ix2=0; ix2<para->getParH(lev)->ny; ix2++) - { - for(unsigned int ix1=0; ix1<para->getParH(lev)->nx; ix1++) - { - unsigned int m = para->getParH(lev)->nx*(para->getParH(lev)->ny*ix3 + ix2) + ix1; - para->getParH(lev)->k[m] = 0; - para->getParH(lev)->geo[m] = 16; - } - } - } - } - - kFullReader::readFile(geometryFile, para); -} -//////////////////////////////////////////////////////////////////////////////// - - - -//////////////////////////////////////////////////////////////////////////////// -void readVFgeoFull(Parameter* para, const std::string geometryFile) -{ - kFullReader::readGeoFull(geometryFile, para); - - ////////////////////////////////////////////////////////////////////////// - //for (int lev = 0; lev <= para->getMaxLevel(); lev++) - //{ - // for(unsigned int ix3=0; ix3<para->getParH(lev)->nz; ix3++) - // { - // for(unsigned int ix2=0; ix2<para->getParH(lev)->ny; ix2++) - // { - // for(unsigned int ix1=0; ix1<para->getParH(lev)->nx; ix1++) - // { - // unsigned int m = para->getParH(lev)->nx*(para->getParH(lev)->ny*ix3 + ix2) + ix1; - // if (para->getParH(lev)->geo[m] == 0 || para->getParH(lev)->geo[m] == 15) - // { - // para->getParH(lev)->geo[m] = 16; - // } - // } - // } - // } - //} -} -//////////////////////////////////////////////////////////////////////////////// - - - -//////////////////////////////////////////////////////////////////////////////// -void readVecSP(Parameter* para, CudaMemoryManager* cudaManager) -{ - PositionReader::readFileForAlloc(para->getgeoVec(), para); - - //alloc - for (int lev = 0; lev <= para->getMaxLevel(); lev++) - { - cudaManager->cudaAllocSP(lev); - } - - //geoSP - PositionReader::readFile(para->getgeoVec(), "geoVec", para); - //neighborX - PositionReader::readFile(para->getneighborX(), "neighborX", para); - //neighborY - PositionReader::readFile(para->getneighborY(), "neighborY", para); - //neighborZ - PositionReader::readFile(para->getneighborZ(), "neighborZ", para); - - //Copy Host -> Device - for(int lev = 0; lev <= para->getMaxLevel(); lev++) - { - for(unsigned int u=0; u<para->getParH(lev)->size_Mat_SP; u++) - { - para->getParH(lev)->rho_SP[u] = 0.01f;//+ lev/100.f; - para->getParH(lev)->vx_SP[u] = 0.0f;//+ lev/100.f; - para->getParH(lev)->vy_SP[u] = 0.0f;//+ lev/100.f; - para->getParH(lev)->vz_SP[u] = 0.0f;//+ lev/100.f; - para->getParH(lev)->press_SP[u] = 0.0f;//+ lev/100.f; - //Median - para->getParH(lev)->rho_SP_Med[u] = 0.0f; - para->getParH(lev)->vx_SP_Med[u] = 0.0f; - para->getParH(lev)->vy_SP_Med[u] = 0.0f; - para->getParH(lev)->vz_SP_Med[u] = 0.0f; - para->getParH(lev)->press_SP_Med[u] = 0.0f; - } - cudaManager->cudaCopySP(lev); - } -} -//////////////////////////////////////////////////////////////////////////////// - - - -//////////////////////////////////////////////////////////////////////////////// -void readInterfaceCF(Parameter* para, CudaMemoryManager* cudaManager) -{ - PositionReader::readFileInterfaceForAlloc(para->getscaleCFC(), "CF", para); - - //alloc - for (int lev = 0; lev < para->getMaxLevel(); lev++) - { - cudaManager->cudaAllocInterfaceCF(lev); - } - - //Scale Coarse to Fine - Coarse - PositionReader::readFileInterface(para->getscaleCFC(), "CFC", para); - //Scale Coarse to Fine - Fine - PositionReader::readFileInterface(para->getscaleCFF(), "CFF", para); - - //Copy Host -> Device - for (int lev = 0; lev < para->getMaxLevel(); lev++) - { - cudaManager->cudaCopyInterfaceCF(lev); - } -} -//////////////////////////////////////////////////////////////////////////////// - - - -//////////////////////////////////////////////////////////////////////////////// -void readInterfaceFC(Parameter* para, CudaMemoryManager* cudaManager) -{ - PositionReader::readFileInterfaceForAlloc(para->getscaleFCC(), "FC", para); - - //alloc - for (int lev = 0; lev < para->getMaxLevel(); lev++) - { - cudaManager->cudaAllocInterfaceFC(lev); - } - - //Scale Fine to Coarse - Coarse - PositionReader::readFileInterface(para->getscaleFCC(), "FCC", para); - //Scale Fine to Coarse - Fine - PositionReader::readFileInterface(para->getscaleFCF(), "FCF", para); - - //Copy Host -> Device - for (int lev = 0; lev < para->getMaxLevel(); lev++) - { - cudaManager->cudaCopyInterfaceFC(lev); - } -} -//////////////////////////////////////////////////////////////////////////////// - - - -//////////////////////////////////////////////////////////////////////////////// -void readInterfaceOffCF(Parameter* para, CudaMemoryManager* cudaManager, const std::string geometryFile) -{ - PositionReader::readFileInterfaceOffsetForAlloc(geometryFile, "CF", para); - - for (int lev = 0; lev < para->getMaxLevel(); lev++) - { - cudaManager->cudaAllocInterfaceOffCF(lev); - } - - PositionReader::readFileInterfaceOffset(geometryFile, "CF", para); - - for (int lev = 0; lev < para->getMaxLevel(); lev++) - { - cudaManager->cudaCopyInterfaceOffCF(lev); - } -} -//////////////////////////////////////////////////////////////////////////////// - - - -//////////////////////////////////////////////////////////////////////////////// -void readInterfaceOffFC(Parameter* para, CudaMemoryManager* cudaManager, const std::string geometryFile) -{ - PositionReader::readFileInterfaceOffsetForAlloc(geometryFile, "FC", para); - - for (int lev = 0; lev < para->getMaxLevel(); lev++) - { - cudaManager->cudaAllocInterfaceOffFC(lev); - } - - PositionReader::readFileInterfaceOffset(geometryFile, "FC", para); - - for (int lev = 0; lev < para->getMaxLevel(); lev++) - { - cudaManager->cudaCopyInterfaceOffFC(lev); - } -} -//////////////////////////////////////////////////////////////////////////////// - - - -//////////////////////////////////////////////////////////////////////////////// -void readNoSlipBc(Parameter* para, CudaMemoryManager* cudaManager) -{ - PositionReader::readFileNoSlipBcForAlloc(para->getnoSlipBcPos(), para); - PositionReader::readFileNoSlipBcQreadForAlloc(para->getnoSlipBcQs(), para); - - for (int lev = 0; lev <= para->getMaxLevel(); lev++) - { - cudaManager->cudaAllocWallBC(lev); - } - - PositionReader::readFileNoSlipBcPos(para->getnoSlipBcPos(), para); - PositionReader::readFileNoSlipBcValue(para->getnoSlipBcValue(), para); - PositionReader::readFileNoSlipBcQs(para->getnoSlipBcQs(), para); - - PositionReader::findQs(para); - - for (int lev = 0; lev <= para->getMaxLevel(); lev++) - { - cudaManager->cudaCopyWallBC(lev); - } -} -//////////////////////////////////////////////////////////////////////////////// - - - -//////////////////////////////////////////////////////////////////////////////// -void readSlipBc(Parameter* para, CudaMemoryManager* cudaManager) -{ - PositionReader::readFileSlipBcForAlloc(para->getslipBcPos(), para); - PositionReader::readFileSlipBcQreadForAlloc(para->getslipBcQs(), para); - - for (int lev = 0; lev <= para->getMaxLevel(); lev++) - { - cudaManager->cudaAllocSlipBC(lev); - } - - PositionReader::readFileSlipBcPos(para->getslipBcPos(), para); - PositionReader::readFileSlipBcValue(para->getslipBcValue(), para); - PositionReader::readFileSlipBcQs(para->getslipBcQs(), para); - - PositionReader::findSlipQs(para); - - for (int lev = 0; lev <= para->getMaxLevel(); lev++) - { - cudaManager->cudaCopySlipBC(lev); - } -} -//////////////////////////////////////////////////////////////////////////////// - - - -//////////////////////////////////////////////////////////////////////////////// -void readPressBc(Parameter* para, CudaMemoryManager* cudaManager) -{ - PositionReader::readFilePressBcForAlloc(para->getpressBcPos(), para); - PositionReader::readFilePressBcQreadForAlloc(para->getpressBcQs(), para); - - for (int lev = 0; lev <= para->getMaxLevel(); lev++) - { - cudaManager->cudaAllocPress(lev); - } - //only Coarse - //para->cudaAllocPress(para->getCoarse()); - - PositionReader::readFilePressBcPos(para->getpressBcPos(), para); - PositionReader::readFilePressBcValue(para->getpressBcValue(), para); - PositionReader::readFilePressBcQs(para->getpressBcQs(), para); - - PositionReader::findPressQs(para); - - for (int lev = 0; lev <= para->getMaxLevel(); lev++) - { - cudaManager->cudaCopyPress(lev); - } - //only Coarse - //para->cudaCopyPress(para->getCoarse()); -} -//////////////////////////////////////////////////////////////////////////////// - - - //////////////////////////////////////////////////////////////////////////////// void readPropellerCylinder(Parameter* para, CudaMemoryManager* cudaManager) { @@ -291,9 +17,6 @@ void readPropellerCylinder(Parameter* para, CudaMemoryManager* cudaManager) cudaManager->cudaCopyVeloPropeller(para->getFine()); } -//////////////////////////////////////////////////////////////////////////////// - - //////////////////////////////////////////////////////////////////////////////// void readMeasurePoints(Parameter* para, CudaMemoryManager* cudaManager) diff --git a/src/gpu/VirtualFluids_GPU/Init/VfReader.h b/src/gpu/VirtualFluids_GPU/Init/VfReader.h index 614c269d36c9a50f329ddbd8a2bef8d473a0769f..c7d95e8e769b5b7536c471af90073c314f5b3e94 100644 --- a/src/gpu/VirtualFluids_GPU/Init/VfReader.h +++ b/src/gpu/VirtualFluids_GPU/Init/VfReader.h @@ -1,38 +1,13 @@ #ifndef VF_READER_H #define VF_READER_H -#include "Parameter/Parameter.h" -#include "Communication/Communicator.h" -#include "Input/kFullReader.h" -#include "Input/PositionReader.h" -//#include "GPU/GPU_Interface.h" - -#include <iostream> class CudaMemoryManager; +class Parameter; -extern "C" void readVFkFull(Parameter* para, CudaMemoryManager* cudaManager, const std::string geometryFile); - -extern "C" void readVFgeoFull(Parameter* para, const std::string geometryFile); - -extern "C" void readVecSP(Parameter* para, CudaMemoryManager* cudaManager); - -extern "C" void readInterfaceCF(Parameter* para, CudaMemoryManager* cudaManager); - -extern "C" void readInterfaceFC(Parameter* para, CudaMemoryManager* cudaManager); - -extern "C" void readInterfaceOffCF(Parameter* para, CudaMemoryManager* cudaManager, const std::string geometryFile); - -extern "C" void readInterfaceOffFC(Parameter* para, CudaMemoryManager* cudaManager, const std::string geometryFile); - -extern "C" void readNoSlipBc(Parameter* para, CudaMemoryManager* cudaManager); - -extern "C" void readSlipBc(Parameter* para, CudaMemoryManager* cudaManager); - -extern "C" void readPressBc(Parameter* para, CudaMemoryManager* cudaManager); -extern "C" void readPropellerCylinder(Parameter* para, CudaMemoryManager* cudaManager); +void readPropellerCylinder(Parameter* para, CudaMemoryManager* cudaManager); -extern "C" void readMeasurePoints(Parameter* para, CudaMemoryManager* cudaManager); +void readMeasurePoints(Parameter* para, CudaMemoryManager* cudaManager); #endif diff --git a/src/gpu/VirtualFluids_GPU/Input/ConfigFile.cpp b/src/gpu/VirtualFluids_GPU/Input/ConfigFile.cpp deleted file mode 100644 index cfe4da2c7381fbcd5998a91eee2c662601dff554..0000000000000000000000000000000000000000 --- a/src/gpu/VirtualFluids_GPU/Input/ConfigFile.cpp +++ /dev/null @@ -1,198 +0,0 @@ -#include "ConfigFile.h" -#include <errno.h> -#include <algorithm> -#include <sstream> -#include <iostream> -#include <string> - -#include "Core/StringUtilities/StringUtil.h" - - -ConfigFile::ConfigFile( const char *strConfigFile ) -{ - if ( strConfigFile ) - m_sConfigFile = strConfigFile; -} -ConfigFile::~ConfigFile() -{ -} -bool ConfigFile::read() -{ - m_in.open(m_sConfigFile.c_str(),std::ios::in); - if (m_in.fail()) - { - return false; - } - while (!m_in.eof()) - { - //-------------------------------------------------------- - // Get a token and value. - // This gives values to member vars: m_token and m_value. - //---------------------------------------------------------- - get_token_and_value(); - if ( m_token.length() ) - m_ConfigEntries.insert( String_Pair(m_token, m_value) ); - } - m_in.close(); - return true; -} -void ConfigFile::get_token_and_value(void) -{ - char token[1024]; - char ch; - bool found_equal=false; - int i=0; - eat_white_and_comments(); - while(!(m_in.get(ch)).fail()) - { - if ((ch != '\t')) - { - if ( (ch == '=') || (ch == ' ') || (ch == '\n') || (ch == '\r') || - (ch == '\t')) - { - if (ch == '=')found_equal=true; - break; - } - token[i++]=ch; - } - } - if (i==0) - { - // It didn�t find a token, in this case. - m_token=""; - m_value=""; - return; - } - // Null-terminate the token that was found. - token[i++]='\0'; - m_token = token; - makeLower(m_token); - // Advance to the equal sign, if need be. - if (!found_equal) - { - if (!advance_to_equal_sign_on_line()) - { - // The token had no value. - m_token=""; - m_value=""; - return; - } - } - // Get the token�s value. - i=0; - char c = eat_white_and_comments(false); - if ( c != '\n' ) - { - i=0; - while(!(m_in.get(ch)).fail()) - { - if ((ch == '\t') || (ch == '\r') || (ch == '\n') || (ch == '#') ) - { - while (ch!='\n') - { - if (m_in.get(ch).fail()) break; - } - break; - } - else - { - token[i++]=ch; - } - } - } - if (i==0) - { - // This token had no value. - m_value=""; - } - else - { - token[i++]='\0'; - m_value=token; - // Remove leading/trailing spaces. - m_value = StringUtil::trim(m_value); - // Strip leading and trailing quotes, if there are any. - if ( m_value[0] == '"' ) - m_value = m_value.substr( 1 ); - if ( m_value[ m_value.length() -1 ] == '"' ) - m_value = m_value.substr( 0, m_value.length()-1 ); - } -} -bool ConfigFile::advance_to_equal_sign_on_line() -{ - char ch; - bool found_equal=false; - while ( !(m_in.get(ch)).fail() ) - { - if ((ch=='\r')||(ch=='\n')) break; - if (ch == '=') - { - found_equal=true; - break; - } - } - return found_equal; -} -char ConfigFile::eat_white_and_comments(bool traverse_newlines) -{ - char ch; - bool in_comment; - in_comment = false; - while (!(m_in.get(ch)).fail()) - { - if (ch == '#') - in_comment = true; - else if (ch == '\n') - { - in_comment = false; - if (!traverse_newlines) - { - return(ch); // Stop eating. - } - } - else if ((!in_comment) && (ch != ' ') && - (ch != '\t') && (ch != '\r')) - { - m_in.putback(ch); - return 0; - } - } - return 0; -} -void ConfigFile::makeLower(std::string &instring) -{ - for(unsigned i=0; i < instring.size(); - i++) - { - instring[i] = tolower(instring[i]); - } -} -bool ConfigFile::hasValue( const char *key ) -{ - bool bRet = false; - std::string sKey = key; - makeLower( sKey ); - if ( m_ConfigEntries.find( sKey.c_str() ) != m_ConfigEntries.end() ) - { - bRet = true; - } - return bRet; -} -std::string ConfigFile::getValue( const char *key ) -{ - std::string sKey = key; - makeLower( sKey ); - if ( m_ConfigEntries.find( sKey.c_str() ) != m_ConfigEntries.end() ) - { - std::map<std::string, std::string>::iterator iter; - iter = m_ConfigEntries.find(sKey.c_str()); - return (*iter).second; - } - return ""; -} -void ConfigFile::setValue( const char *key, const char *value ) -{ - std::string sKey = key; - makeLower( sKey ); - m_ConfigEntries[sKey] = value; -} \ No newline at end of file diff --git a/src/gpu/VirtualFluids_GPU/Input/ConfigFile.h b/src/gpu/VirtualFluids_GPU/Input/ConfigFile.h deleted file mode 100644 index 6df713326b72c23827b2c0eb426d7e7deb5a9e85..0000000000000000000000000000000000000000 --- a/src/gpu/VirtualFluids_GPU/Input/ConfigFile.h +++ /dev/null @@ -1,31 +0,0 @@ -#ifndef CONFIGFILE_H -#define CONFIGFILE_H -#include <string> -#include <vector> -#include <fstream> -#include <map> -#include <list> - -class ConfigFile -{ -public: - ConfigFile(const char *strFileName); - virtual ~ConfigFile(void); - bool read(void); - bool hasValue( const char *key ); - std::string getValue( const char *key ); - void setValue( const char *key, const char *value ); -protected: - virtual void get_token_and_value(); - virtual char eat_white_and_comments(bool traverse_newlines=true); - virtual bool advance_to_equal_sign_on_line(); - virtual void makeLower(std::string &instring); -protected: - std::fstream m_in; - std::string m_token; - std::string m_value; - std::string m_sConfigFile; - typedef std::pair <std::string, std::string> String_Pair; - std::map<std::string, std::string> m_ConfigEntries; -}; -#endif diff --git a/src/gpu/VirtualFluids_GPU/Input/PositionReader.cpp b/src/gpu/VirtualFluids_GPU/Input/PositionReader.cpp deleted file mode 100644 index b2a942c9a36590b589cab7eacd0b299f76fd7f2c..0000000000000000000000000000000000000000 --- a/src/gpu/VirtualFluids_GPU/Input/PositionReader.cpp +++ /dev/null @@ -1,1183 +0,0 @@ -#include "PositionReader.h" - -#include "basics/utilities/UbFileInputASCII.h" - -// static const int E = dirE; //static const int E = 0; -// static const int W = dirW; //static const int W = 1; -// static const int N = dirN; //static const int N = 2; -// static const int S = dirS; //static const int S = 3; -// static const int T = dirT; //static const int T = 4; -// static const int B = dirB; //static const int B = 5; -// static const int NE = dirNE; //static const int NE = 6; -// static const int SW = dirSW; //static const int SW = 7; -// static const int SE = dirSE; //static const int SE = 8; -// static const int NW = dirNW; //static const int NW = 9; -// static const int TE = dirTE; //static const int TE = 10; -// static const int BW = dirBW; //static const int BW = 11; -// static const int BE = dirBE; //static const int BE = 12; -// static const int TW = dirTW; //static const int TW = 13; -// static const int TN = dirTN; //static const int TN = 14; -// static const int BS = dirBS; //static const int BS = 15; -// static const int BN = dirBN; //static const int BN = 16; -// static const int TS = dirTS; //static const int TS = 17; -// static const int TNE = dirTNE; //static const int TNE = 18; -// static const int TNW = dirTNW; //static const int TNW = 19; -// static const int TSE = dirTSE; //static const int TSE = 20; -// static const int TSW = dirTSW; //static const int TSW = 21; -// static const int BNE = dirBNE; //static const int BNE = 22; -// static const int BNW = dirBNW; //static const int BNW = 23; -// static const int BSE = dirBSE; //static const int BSE = 24; -// static const int BSW = dirBSW; //static const int BSW = 25; -// static const int ZERO = dirZERO; //static const int ZERO = 26; - - -static const int INV_E = dirE; //= W; -static const int INV_W = dirW; //= E; -static const int INV_N = dirN; //= S; -static const int INV_S = dirS; //= N; -static const int INV_T = dirT; //= B; -static const int INV_B = dirB; //= T; -static const int INV_NE = dirNE; //= SW; -static const int INV_SW = dirSW; //= NE; -static const int INV_SE = dirSE; //= NW; -static const int INV_NW = dirNW; //= SE; -static const int INV_TE = dirTE; //= BW; -static const int INV_BW = dirBW; //= TE; -static const int INV_BE = dirBE; //= TW; -static const int INV_TW = dirTW; //= BE; -static const int INV_TN = dirTN; //= BS; -static const int INV_BS = dirBS; //= TN; -static const int INV_BN = dirBN; //= TS; -static const int INV_TS = dirTS; //= BN; -static const int INV_TNE = dirTNE; //= BSW; -static const int INV_TNW = dirTNW; //= BSE; -static const int INV_TSE = dirTSE; //= BNW; -static const int INV_TSW = dirTSW; //= BNE; -static const int INV_BNE = dirBNE; //= TSW; -static const int INV_BNW = dirBNW; //= TSE; -static const int INV_BSE = dirBSE; //= TNW; -static const int INV_BSW = dirBSW; //= TNE; -static const int INV_ZERO= dirZERO; //= ZERO; - -//static const int INVDIR[ENDDIR+1]; - -const int INVDIR[] = { INV_E, - INV_W, - INV_N, - INV_S, - INV_T, - INV_B, - INV_NE, - INV_SW, - INV_SE, - INV_NW, - INV_TE, - INV_BW, - INV_BE, - INV_TW, - INV_TN, - INV_BS, - INV_BN, - INV_TS, //alt Bezug neu - INV_BNE, //INV_TNE = BSW = 25 = dirTSW = TSW = INV_BNE - INV_TSE, //INV_TNW = BSE = 24 = dirBNW = BNW = INV_TSE - INV_BSE, //INV_TSE = BNW = 23 = dirTNW = TNW = INV_BSE - INV_TNW, //INV_TSW = BNE = 22 = dirBSE = BSE = INV_TNW - INV_BNW, //INV_BNE = TSW = 21 = dirTSE = TSE = INV_BNW - INV_TSW, //INV_BNW = TSE = 20 = dirBNE = BNE = INV_TSW - INV_BSW, //INV_BSE = TNW = 19 = dirTNE = TNE = INV_BSW - INV_ZERO, //INV_BSW = TNE = 18 = dirZERO = ZERO= INV_ZERO - INV_TNE}; //INV_ZERO= ZERO = 26 = dirBSW = BSW = INV_TNE - -static const int optionDigits = 2; //--> 2 bits f�r secondary Option -static const long long maxOptionVal = ( 1<<optionDigits ) - 1; //2^3-1 -> 7 -//float q[27]; -long long noslipBoundaryFlags; - - -////////////////////////////////////////////////////////////////////////// -void PositionReader::readFileForAlloc(const std::string fileName, Parameter* para) -{ - UbFileInputASCII in(fileName); - int maxlevel = in.readInteger(); - in.readLine(); - - for (int level = 0; level <= maxlevel; level++) - { - //Host - para->getParH(level)->size_Mat_SP = in.readInteger(); - para->getParH(level)->mem_size_real_SP = sizeof(real ) * para->getParH(level)->size_Mat_SP; - para->getParH(level)->mem_size_int_SP = sizeof(unsigned int) * para->getParH(level)->size_Mat_SP; - //Device - para->getParD(level)->size_Mat_SP = para->getParH(level)->size_Mat_SP; - para->getParD(level)->mem_size_int_SP = sizeof(unsigned int) * para->getParD(level)->size_Mat_SP; - para->getParD(level)->mem_size_real_SP = sizeof(real ) * para->getParD(level)->size_Mat_SP; - - in.readLine(); - for(unsigned int u = /*1*/0; u<para->getParH(level)->size_Mat_SP; u++) - { - in.readInteger(); - } - in.readLine(); - } -} -////////////////////////////////////////////////////////////////////////// - - -////////////////////////////////////////////////////////////////////////// -void PositionReader::readFile(const std::string fileName, std::string Type, Parameter* para) -{ - UbFileInputASCII in(fileName); - int maxlevel = in.readInteger(); - in.readLine(); - - if (Type == "geoVec") - { - for (int level = 0; level <= maxlevel; level++) - { - in.readInteger(); - in.readLine(); - for(unsigned int u = 0; u<para->getParH(level)->size_Mat_SP; u++) - { - para->getParH(level)->geoSP[u] = in.readInteger(); - } - in.readLine(); - } - } - else if (Type == "neighborX") - { - for (int level = 0; level <= maxlevel; level++) - { - in.readInteger(); - in.readLine(); - for(unsigned int u = 0; u<para->getParH(level)->size_Mat_SP; u++) - { - //para->getParH(level)->neighborZ_SP[u] = in.readInteger(); - para->getParH(level)->neighborX_SP[u] = in.readInteger(); - } - in.readLine(); - } - } - else if (Type == "neighborY") - { - for (int level = 0; level <= maxlevel; level++) - { - in.readInteger(); - in.readLine(); - for(unsigned int u = 0; u<para->getParH(level)->size_Mat_SP; u++) - { - para->getParH(level)->neighborY_SP[u] = in.readInteger(); - } - in.readLine(); - } - } - else if (Type == "neighborZ") - { - for (int level = 0; level <= maxlevel; level++) - { - in.readInteger(); - in.readLine(); - for(unsigned int u = /*1*/0; u<para->getParH(level)->size_Mat_SP; u++) - { - //para->getParH(level)->neighborX_SP[u] = in.readInteger(); - para->getParH(level)->neighborZ_SP[u] = in.readInteger(); - } - in.readLine(); - } - } -} -////////////////////////////////////////////////////////////////////////// - - -////////////////////////////////////////////////////////////////////////// -void PositionReader::readFileInterfaceForAlloc(const std::string fileName, std::string Type, Parameter* para) -{ - UbFileInputASCII in(fileName); - int maxlevel = in.readInteger(); - in.readLine(); - unsigned int test = 0; - - for (int level = 0; level < maxlevel; level++) - { - if (Type == "CF") - { - para->getParH(level)->K_CF = in.readInteger(); - para->getParD(level)->K_CF = para->getParH(level)->K_CF; - para->getParH(level)->intCF.kCF = para->getParH(level)->K_CF; - para->getParD(level)->intCF.kCF = para->getParH(level)->K_CF; - para->getParH(level)->mem_size_kCF = sizeof(unsigned int) * para->getParH(level)->K_CF; - para->getParD(level)->mem_size_kCF = sizeof(unsigned int) * para->getParD(level)->K_CF; - in.readLine(); - for(unsigned int u=0; u<para->getParH(level)->K_CF; u++) - { - test = in.readInteger(); - if (test>=para->getParH(level)->size_Mat_SP) - { - printf("CF: das geht doch nicht!!!"); - } - } - } - else if (Type == "FC") - { - para->getParH(level)->K_FC = in.readInteger(); - para->getParD(level)->K_FC = para->getParH(level)->K_FC; - para->getParH(level)->intFC.kFC = para->getParH(level)->K_FC; - para->getParD(level)->intFC.kFC = para->getParH(level)->K_FC; - para->getParH(level)->mem_size_kFC = sizeof(unsigned int) * para->getParH(level)->K_FC; - para->getParD(level)->mem_size_kFC = sizeof(unsigned int) * para->getParD(level)->K_FC; - in.readLine(); - for(unsigned int u=0; u<para->getParH(level)->K_FC; u++) - { - test = in.readInteger(); - if (test>=para->getParH(level)->size_Mat_SP) - { - printf("FC: das geht doch nicht!!!"); - } - } - } - - in.readLine(); - } -} -////////////////////////////////////////////////////////////////////////// - - -////////////////////////////////////////////////////////////////////////// -void PositionReader::readFileInterface(const std::string fileName, std::string Type, Parameter* para) -{ - UbFileInputASCII in(fileName); - int maxlevel = in.readInteger(); - in.readLine(); - - if (Type == "CFC") - { - for (int level = 0; level < maxlevel; level++) - { - in.readInteger(); - in.readLine(); - for(unsigned int u=0; u<para->getParH(level)->K_CF; u++) - { - para->getParH(level)->intCF.ICellCFC[u] = in.readInteger(); - } - in.readLine(); - } - } - else if (Type == "CFF") - { - for (int level = 0; level < maxlevel; level++) - { - in.readInteger(); - in.readLine(); - for(unsigned int u=0; u<para->getParH(level)->K_CF; u++) - { - para->getParH(level)->intCF.ICellCFF[u] = in.readInteger(); - } - in.readLine(); - } - } - else if (Type == "FCC") - { - for (int level = 0; level < maxlevel; level++) - { - in.readInteger(); - in.readLine(); - for(unsigned int u=0; u<para->getParH(level)->K_FC; u++) - { - para->getParH(level)->intFC.ICellFCC[u] = in.readInteger(); - } - in.readLine(); - } - } - else if (Type == "FCF") - { - for (int level = 0; level < maxlevel; level++) - { - in.readInteger(); - in.readLine(); - for(unsigned int u=0; u<para->getParH(level)->K_FC; u++) - { - para->getParH(level)->intFC.ICellFCF[u] = in.readInteger(); - } - in.readLine(); - } - } -} -////////////////////////////////////////////////////////////////////////// - - -////////////////////////////////////////////////////////////////////////// -void PositionReader::readFileInterfaceOffsetForAlloc(const std::string fileName, std::string Type, Parameter* para) -{ - UbFileInputASCII in(fileName); - int maxlevel = in.readInteger(); - in.readLine(); - - for (int level = 0; level < maxlevel; level++) - { - if (Type == "CF") - { - para->getParH(level)->K_CF = in.readInteger(); - para->getParD(level)->K_CF = para->getParH(level)->K_CF; - para->getParH(level)->intCF.kCF = para->getParH(level)->K_CF; - para->getParD(level)->intCF.kCF = para->getParH(level)->K_CF; - para->getParH(level)->mem_size_kCF_off = sizeof(real) * para->getParH(level)->K_CF; - para->getParD(level)->mem_size_kCF_off = sizeof(real) * para->getParD(level)->K_CF; - in.readLine(); - for(unsigned int u=0; u<para->getParH(level)->K_CF; u++) - { - in.readDouble(); - in.readDouble(); - in.readDouble(); - } - } - else if (Type == "FC") - { - para->getParH(level)->K_FC = in.readInteger(); - para->getParD(level)->K_FC = para->getParH(level)->K_FC; - para->getParH(level)->intFC.kFC = para->getParH(level)->K_FC; - para->getParD(level)->intFC.kFC = para->getParH(level)->K_FC; - para->getParH(level)->mem_size_kFC_off = sizeof(real) * para->getParH(level)->K_FC; - para->getParD(level)->mem_size_kFC_off = sizeof(real) * para->getParD(level)->K_FC; - in.readLine(); - for(unsigned int u=0; u<para->getParH(level)->K_FC; u++) - { - //in.readInteger(); - in.readDouble(); - in.readDouble(); - in.readDouble(); - } - } - - in.readLine(); - } -} -////////////////////////////////////////////////////////////////////////// - - -////////////////////////////////////////////////////////////////////////// -void PositionReader::readFileInterfaceOffset(const std::string fileName, std::string Type, Parameter* para) -{ - UbFileInputASCII in(fileName); - int maxlevel = in.readInteger(); - in.readLine(); - - if (Type == "CF") - { - for (int level = 0; level < maxlevel; level++) - { - in.readInteger(); - in.readLine(); - for(unsigned int u=0; u<para->getParH(level)->K_CF; u++) - { - para->getParH(level)->offCF.xOffCF[u] = (real)in.readDouble(); - para->getParH(level)->offCF.yOffCF[u] = (real)in.readDouble(); - para->getParH(level)->offCF.zOffCF[u] = (real)in.readDouble(); - } - in.readLine(); - } - } - else if (Type == "FC") - { - for (int level = 0; level < maxlevel; level++) - { - in.readInteger(); - in.readLine(); - for(unsigned int u=0; u<para->getParH(level)->K_FC; u++) - { - //para->getParH(level)->offFC.xOffFC[u] = 0.0; - //para->getParH(level)->offFC.yOffFC[u] = 0.0; - //para->getParH(level)->offFC.zOffFC[u] = 0.0; - //in.readInteger(); - para->getParH(level)->offFC.xOffFC[u] = (real)in.readDouble(); - para->getParH(level)->offFC.yOffFC[u] = (real)in.readDouble(); - para->getParH(level)->offFC.zOffFC[u] = (real)in.readDouble(); - } - in.readLine(); - } - } -} -////////////////////////////////////////////////////////////////////////// - - -////////////////////////////////////////////////////////////////////////// -void PositionReader::readFileNoSlipBcForAlloc(const std::string fileName, Parameter* para) -{ - UbFileInputASCII in(fileName); - int maxlevel = in.readInteger(); - in.readLine(); - - for (int level = 0; level < maxlevel; level++) - { - para->getParH(level)->kQ = in.readInteger(); - para->getParD(level)->kQ = para->getParH(level)->kQ; - para->getParH(level)->QWall.kQ = para->getParH(level)->kQ; - para->getParD(level)->QWall.kQ = para->getParH(level)->kQ; - in.readLine(); - for(unsigned int u=0; u<para->getParH(level)->kQ; u++) - { - in.readInteger(); - } - in.readLine(); - } -} -////////////////////////////////////////////////////////////////////////// - - -////////////////////////////////////////////////////////////////////////// -void PositionReader::readFileNoSlipBcQreadForAlloc(const std::string fileName, Parameter* para) -{ - UbFileInputASCII in(fileName); - int maxlevel = in.readInteger(); - in.readLine(); - - for (int level = 0; level < maxlevel; level++) - { - para->getParH(level)->kQread = in.readInteger(); - para->getParD(level)->kQread = para->getParH(level)->kQread; - in.readLine(); - for(unsigned int u=0; u<para->getParH(level)->kQread; u++) - { - in.readFloat(); - } - in.readLine(); - } -} -////////////////////////////////////////////////////////////////////////// - - -////////////////////////////////////////////////////////////////////////// -void PositionReader::readFileNoSlipBcPos(const std::string fileName, Parameter* para) -{ - UbFileInputASCII in(fileName); - int maxlevel = in.readInteger(); - in.readLine(); - - for (int level = 0; level < maxlevel; level++) - { - in.readInteger(); - in.readLine(); - for(unsigned int u=0; u<para->getParH(level)->kQ; u++) - { - para->getParH(level)->QWall.k[u] = in.readInteger(); - } - in.readLine(); - } -} -////////////////////////////////////////////////////////////////////////// - - -////////////////////////////////////////////////////////////////////////// -void PositionReader::readFileNoSlipBcQs(const std::string fileName, Parameter* para) -{ - UbFileInputASCII in(fileName); - real test; - int maxlevel = in.readInteger(); - in.readLine(); - - for (int level = 0; level < maxlevel; level++) - { - in.readInteger(); - in.readLine(); - for(unsigned int u=0; u<para->getParH(level)->kQread; u++) - { - test = (real)in.readFloat(); - //if (test <= 0. && test >= -1.) - //{ - // test = -0.5; - //} - //else if (test >= 0. && test <= 1.) - //{ - // test = 0.5; - //} - //else - //{ - // test = 100.; - //} - - ////T�ST -> shit - //para->getParH(level)->QWall.qread[u] = 0.5f; - //orig - para->getParH(level)->QWall.qread[u] = test; - //para->getParH(level)->QWall.qread[u] = (real)in.readFloat(); - } - in.readLine(); - } -} -////////////////////////////////////////////////////////////////////////// - - -////////////////////////////////////////////////////////////////////////// -void PositionReader::readFileNoSlipBcValue(const std::string fileName, Parameter* para) -{ - UbFileInputASCII in(fileName); - int maxlevel = in.readInteger(); - in.readLine(); - - for (int level = 0; level < maxlevel; level++) - { - in.readInteger(); - in.readLine(); - for(unsigned int u=0; u<para->getParH(level)->kQ; u++) - { - para->getParH(level)->QWall.valueQ[u] = in.readLongLong(); - } - in.readLine(); - } -} -////////////////////////////////////////////////////////////////////////// - - -////////////////////////////////////////////////////////////////////////// -void PositionReader::findQs(Parameter* para) -{ - for (int lev = 0; lev <= para->getMaxLevel(); lev++) - { - ////////////////////////////////////////////////////////////////// - //preprocessing - real* QQ = para->getParH(lev)->QWall.q27[0]; - unsigned int sizeQ = para->getParH(lev)->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]; - ////////////////////////////////////////////////////////////////// - //set all to -1.0 - for(unsigned int u=0; u<para->getParH(lev)->kQ; u++) - { - for (int dir = dirE; dir<=dirBSW; dir++) - { - Q.q27[dir][u] = -1.0f; - } - } - ////////////////////////////////////////////////////////////////// - //find q-directions - unsigned int v = 0; - for(unsigned int u=0; u<para->getParH(lev)->kQ; u++) - { - noslipBoundaryFlags = para->getParH(lev)->QWall.valueQ[u]; - //noSlipBoundaryValueVec[level].push_back(bc->getNoSlipBoundary()); - for(int dir=dirE;dir<=dirBSW;dir++) - { - if(( ( noslipBoundaryFlags>>(optionDigits*dir) ) & maxOptionVal ) != 0 /*hasNoSlipBoundaryFlag(dir)*/) - { - Q.q27[INVDIR[dir]][u] = para->getParH(lev)->QWall.qread[v]; - //noSlipBoundaryQsVec[level].push_back(bc->getQ(LBMD3Q27System::INVDIR[dir])); - v++; - } - } - } - } -} -////////////////////////////////////////////////////////////////////////// - - -////////////////////////////////////////////////////////////////////////// -void PositionReader::readFileSlipBcForAlloc(const std::string fileName, Parameter* para) -{ - UbFileInputASCII in(fileName); - int maxlevel = in.readInteger(); - in.readLine(); - - for (int level = 0; level < maxlevel; level++) - { - para->getParH(level)->kSlipQ = in.readInteger(); - para->getParD(level)->kSlipQ = para->getParH(level)->kSlipQ; - para->getParH(level)->QSlip.kQ = para->getParH(level)->kSlipQ; - para->getParD(level)->QSlip.kQ = para->getParH(level)->kSlipQ; - in.readLine(); - for(unsigned int u=0; u<para->getParH(level)->kSlipQ; u++) - { - in.readInteger(); - } - in.readLine(); - } -} -////////////////////////////////////////////////////////////////////////// - - -////////////////////////////////////////////////////////////////////////// -void PositionReader::readFileSlipBcQreadForAlloc(const std::string fileName, Parameter* para) -{ - UbFileInputASCII in(fileName); - int maxlevel = in.readInteger(); - in.readLine(); - - for (int level = 0; level < maxlevel; level++) - { - para->getParH(level)->kSlipQread = in.readInteger(); - para->getParD(level)->kSlipQread = para->getParH(level)->kSlipQread; - in.readLine(); - for(unsigned int u=0; u<para->getParH(level)->kSlipQread; u++) - { - in.readFloat(); - } - in.readLine(); - } -} -////////////////////////////////////////////////////////////////////////// - - -////////////////////////////////////////////////////////////////////////// -void PositionReader::readFileSlipBcPos(const std::string fileName, Parameter* para) -{ - UbFileInputASCII in(fileName); - int maxlevel = in.readInteger(); - in.readLine(); - - for (int level = 0; level < maxlevel; level++) - { - in.readInteger(); - in.readLine(); - for(unsigned int u=0; u<para->getParH(level)->kSlipQ; u++) - { - para->getParH(level)->QSlip.k[u] = in.readInteger(); - } - in.readLine(); - } -} -////////////////////////////////////////////////////////////////////////// - - -////////////////////////////////////////////////////////////////////////// -void PositionReader::readFileSlipBcQs(const std::string fileName, Parameter* para) -{ - UbFileInputASCII in(fileName); - int maxlevel = in.readInteger(); - in.readLine(); - - for (int level = 0; level < maxlevel; level++) - { - in.readInteger(); - in.readLine(); - for(unsigned int u=0; u<para->getParH(level)->kSlipQread; u++) - { - para->getParH(level)->QSlip.qread[u] = (real)in.readFloat(); - } - in.readLine(); - } -} -////////////////////////////////////////////////////////////////////////// - - -////////////////////////////////////////////////////////////////////////// -void PositionReader::readFileSlipBcValue(const std::string fileName, Parameter* para) -{ - UbFileInputASCII in(fileName); - int maxlevel = in.readInteger(); - in.readLine(); - - for (int level = 0; level < maxlevel; level++) - { - in.readInteger(); - in.readLine(); - for(unsigned int u=0; u<para->getParH(level)->kSlipQ; u++) - { - para->getParH(level)->QSlip.valueQ[u] = in.readLongLong(); - } - in.readLine(); - } -} -////////////////////////////////////////////////////////////////////////// - - -////////////////////////////////////////////////////////////////////////// -void PositionReader::findSlipQs(Parameter* para) -{ - for (int lev = 0; lev <= para->getMaxLevel(); lev++) - { - ////////////////////////////////////////////////////////////////// - //preprocessing - real* QQ = para->getParH(lev)->QSlip.q27[0]; - unsigned int sizeQ = para->getParH(lev)->kSlipQ; - 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]; - ////////////////////////////////////////////////////////////////// - //set all to -1.0 - for(unsigned int u=0; u<para->getParH(lev)->kSlipQ; u++) - { - for (int dir = dirE; dir<=dirBSW; dir++) - { - Q.q27[dir][u] = -1.0f; - } - } - ////////////////////////////////////////////////////////////////// - //find q-directions - unsigned int v = 0; - for(unsigned int u=0; u<para->getParH(lev)->kSlipQ; u++) - { - noslipBoundaryFlags = para->getParH(lev)->QSlip.valueQ[u]; - for(int dir=dirE;dir<=dirBSW;dir++) - { - if(( ( noslipBoundaryFlags>>(optionDigits*dir) ) & maxOptionVal ) != 0 ) - { - Q.q27[INVDIR[dir]][u] = para->getParH(lev)->QSlip.qread[v]; - v++; - } - } - } - } -} -////////////////////////////////////////////////////////////////////////// - - -////////////////////////////////////////////////////////////////////////// -void PositionReader::readFilePressBcForAlloc(const std::string fileName, Parameter* para) -{ - UbFileInputASCII in(fileName); - int maxlevel = in.readInteger(); - int test = 1; - in.readLine(); - - for (int level = 0; level < maxlevel; level++) - { - test = in.readInteger(); - //if (test==0) - //{ - // printf("testlevel = %d\n", level); - // //continue; - //} - para->getParH(level)->kPressQ = test; - para->getParD(level)->kPressQ = para->getParH(level)->kPressQ; - para->getParH(level)->QPress.kQ = para->getParH(level)->kPressQ; - para->getParD(level)->QPress.kQ = para->getParH(level)->kPressQ; - in.readLine(); - for(unsigned int u=0; u<para->getParH(level)->kPressQ; u++) - { - in.readInteger(); - } - in.readLine(); - } -} -////////////////////////////////////////////////////////////////////////// - - -////////////////////////////////////////////////////////////////////////// -void PositionReader::readFilePressBcQreadForAlloc(const std::string fileName, Parameter* para) -{ - UbFileInputASCII in(fileName); - int maxlevel = in.readInteger(); - int test = 1; - in.readLine(); - - for (int level = 0; level < maxlevel; level++) - { - test = in.readInteger(); - //if (test==0) - //{ - // printf("testlevel1 = %d\n", level); - // //continue; - //} - para->getParH(level)->kPressQread = test; - para->getParD(level)->kPressQread = para->getParH(level)->kPressQread; - in.readLine(); - for(unsigned int u=0; u<para->getParH(level)->kPressQread; u++) - { - in.readFloat(); - } - in.readLine(); - } -} -////////////////////////////////////////////////////////////////////////// - - -////////////////////////////////////////////////////////////////////////// -void PositionReader::readFilePressBcPos(const std::string fileName, Parameter* para) -{ - UbFileInputASCII in(fileName); - int maxlevel = in.readInteger(); - in.readLine(); - - for (int level = 0; level < maxlevel; level++) - { - in.readInteger(); - in.readLine(); - for(unsigned int u=0; u<para->getParH(level)->kPressQ; u++) - { - if (u==0) - { - para->getParH(level)->QPress.k[u] = in.readInteger();//0; - /*in.readInteger();*/ - } - else - { - para->getParH(level)->QPress.k[u] = in.readInteger(); - } - //setRhoBC - para->getParH(level)->QPress.RhoBC[u] = (real)0.f; - } - in.readLine(); - } -} -////////////////////////////////////////////////////////////////////////// - - -////////////////////////////////////////////////////////////////////////// -void PositionReader::readFilePressBcQs(const std::string fileName, Parameter* para) -{ - UbFileInputASCII in(fileName); - int maxlevel = in.readInteger(); - in.readLine(); - - for (int level = 0; level < maxlevel; level++) - { - in.readInteger(); - in.readLine(); - for(unsigned int u=0; u<para->getParH(level)->kPressQread; u++) - { - para->getParH(level)->QPress.qread[u] = (real)in.readFloat(); - } - in.readLine(); - } -} -////////////////////////////////////////////////////////////////////////// - - -////////////////////////////////////////////////////////////////////////// -void PositionReader::readFilePressBcValue(const std::string fileName, Parameter* para) -{ - UbFileInputASCII in(fileName); - int maxlevel = in.readInteger(); - in.readLine(); - - for (int level = 0; level < maxlevel; level++) - { - in.readInteger(); - in.readLine(); - for(unsigned int u=0; u<para->getParH(level)->kPressQ; u++) - { - para->getParH(level)->QPress.valueQ[u] = in.readLongLong(); - } - in.readLine(); - } -} -////////////////////////////////////////////////////////////////////////// - - -////////////////////////////////////////////////////////////////////////// -void PositionReader::findPressQs(Parameter* para) -{ - for (int lev = 0; lev <= para->getMaxLevel(); lev++) - { - ////////////////////////////////////////////////////////////////// - //preprocessing - real* QQ = para->getParH(lev)->QPress.q27[0]; - unsigned int sizeQ = para->getParH(lev)->kPressQ; - 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]; - ////////////////////////////////////////////////////////////////// - //set all to -1.0 - for(unsigned int u=0; u<para->getParH(lev)->kPressQ; u++) - { - for (int dir = dirE; dir<=dirBSW; dir++) - { - Q.q27[dir][u] = -1.0f; - } - } - ////////////////////////////////////////////////////////////////// - //find q-directions - unsigned int v = 0; - for(unsigned int u=0; u<para->getParH(lev)->kPressQ; u++) - { - noslipBoundaryFlags = para->getParH(lev)->QPress.valueQ[u]; - for(int dir=dirE;dir<=dirBSW;dir++) - { - if(( ( noslipBoundaryFlags>>(optionDigits*dir) ) & maxOptionVal ) != 0 ) - { - Q.q27[INVDIR[dir]][u] = para->getParH(lev)->QPress.qread[v]; - v++; - } - } - } - } -} -////////////////////////////////////////////////////////////////////////// - - -////////////////////////////////////////////////////////////////////////// -void PositionReader::readFilePropellerCylinderForAlloc(Parameter* para) -{ - UbFileInputASCII in(para->getpropellerCylinder()); - int test = 0, count = 0; - int maxlevel = in.readInteger(); - in.readLine(); - - for (int level = 0; level < maxlevel; level++) - { - para->getParH(level)->QPropeller.kQ = in.readInteger(); - para->getParD(level)->QPropeller.kQ = para->getParH(level)->QPropeller.kQ; - in.readLine(); - if (level == para->getFine()) - { - for(int u=0; u<para->getParH(level)->QPropeller.kQ; u++) - { - test = in.readInteger(); - if (para->getParH(level)->geoSP[test] == GEO_FLUID) - { - count++; - } - //////////////////////////////////////////////////////////////////////// - //for(unsigned int ix3=0; ix3<para->getParH(level)->nz; ix3++) - //{ - // for(unsigned int ix2=0; ix2<para->getParH(level)->ny; ix2++) - // { - // for(unsigned int ix1=0; ix1<para->getParH(level)->nx; ix1++) - // { - // unsigned int m = para->getParH(level)->nx*(para->getParH(level)->ny*ix3 + ix2) + ix1; - // if (para->getParH(level)->k[m] == test) - // { - // if(para->getParH(level)->geo[m] == 1) - // { - // count++; - // } - // } - // } - // } - //} - //count++; - //////////////////////////////////////////////////////////////////////// - in.readDouble(); - in.readDouble(); - in.readDouble(); - in.readLine(); - } - } - else - { - for(int u=0; u<para->getParH(level)->QPropeller.kQ; u++) - { - in.readInteger(); - in.readDouble(); - in.readDouble(); - in.readDouble(); - in.readLine(); - } - } - para->getParH(level)->QPropeller.kQ = count; - para->getParD(level)->QPropeller.kQ = para->getParH(level)->QPropeller.kQ; - } -} -////////////////////////////////////////////////////////////////////////// - - -////////////////////////////////////////////////////////////////////////// -void PositionReader::readFilePropellerCylinder(Parameter* para) -{ - UbFileInputASCII in(para->getpropellerCylinder()); - int test = 0, count = 0; - int maxlevel = in.readInteger(); - in.readLine(); - - for (int level = 0; level < maxlevel; level++) - { - int allnodes = in.readInteger(); - in.readLine(); - if (level == para->getFine()) - { - for(int u=0; u<allnodes; u++) - { - test = in.readInteger(); - //////////////////////////////////////////////////////////////////////// - if (para->getParH(level)->geoSP[test] == GEO_FLUID) - { - para->getParH(level)->QPropeller.k[count] = test; - para->getParH(level)->QPropeller.Vx[count] = (real)in.readDouble(); - para->getParH(level)->QPropeller.Vy[count] = (real)in.readDouble(); - para->getParH(level)->QPropeller.Vz[count] = (real)in.readDouble(); - para->getParH(level)->QPropeller.RhoBC[count] = 0.0f; - count++; - } - else - { - in.readDouble(); - in.readDouble(); - in.readDouble(); - } - //para->getParH(level)->QPropeller.k[count] = test; - //para->getParH(level)->QPropeller.Vx[count] = (real)in.readDouble(); - //para->getParH(level)->QPropeller.Vy[count] = (real)in.readDouble(); - //para->getParH(level)->QPropeller.Vz[count] = (real)in.readDouble(); - //para->getParH(level)->QPropeller.Vx[count] = 0.07f; - //para->getParH(level)->QPropeller.Vy[count] = 0.0f; - //para->getParH(level)->QPropeller.Vz[count] = 0.0f; - in.readLine(); - } - } - else - { - for(int u=0; u<allnodes; u++) - { - in.readInteger(); - in.readDouble(); - in.readDouble(); - in.readDouble(); - in.readLine(); - } - } - printf("allnodes = %d, count = %d\n", allnodes, count); - } -} -////////////////////////////////////////////////////////////////////////// - - -////////////////////////////////////////////////////////////////////////// -void PositionReader::definePropellerQs(Parameter* para) -{ - ////////////////////////////////////////////////////////////////// - //preprocessing - real* QQ = para->getParH(para->getFine())->QPropeller.q27[0]; - unsigned int sizeQ = para->getParH(para->getFine())->QPropeller.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]; - ////////////////////////////////////////////////////////////////// - for(int u=0; u<para->getParH(para->getFine())->QPropeller.kQ; u++) - { - for (int dir = dirE; dir<=dirBSW; dir++) - { - if ((dir==dirE) || - (dir==dirNE) || (dir==dirSE) || (dir==dirTE) || (dir==dirBE) || - (dir==dirTNE)|| (dir==dirBNE)|| (dir==dirTSE)|| (dir==dirBSE)) - { - Q.q27[dir][u] = 1.0f; - } - else - { - Q.q27[dir][u] = -1.0f; - } - } - } - ////////////////////////////////////////////////////////////////// -} -////////////////////////////////////////////////////////////////////////// - - -////////////////////////////////////////////////////////////////////////// -void PositionReader::readMeasurePoints( Parameter* para ) -{ - UbFileInputASCII in(para->getmeasurePoints()); - int numberOfAllNodes = in.readInteger(); - in.readLine(); - int tempLevel; - MeasurePoints tempMP; - //printf("done, init the values...\n"); - for (int u = 0; u < numberOfAllNodes; u++) - { - tempMP.name = in.readString(); - //printf("done, read the name...\n"); - tempMP.k = in.readInteger(); - //printf("done, read k...\n"); - tempLevel = in.readInteger(); - //printf("done, read level...\n"); - in.readLine(); - //printf("done, read the values...\n"); - para->getParH(tempLevel)->MP.push_back(tempMP); - //printf("done, put it into a vector...\n"); - } -} -////////////////////////////////////////////////////////////////////////// - - -////////////////////////////////////////////////////////////////////////// - - diff --git a/src/gpu/VirtualFluids_GPU/Input/PositionReader.h b/src/gpu/VirtualFluids_GPU/Input/PositionReader.h deleted file mode 100644 index 610d2fb5e1e8d225d56931c023ea3855d89bef4b..0000000000000000000000000000000000000000 --- a/src/gpu/VirtualFluids_GPU/Input/PositionReader.h +++ /dev/null @@ -1,44 +0,0 @@ -#ifndef POSITION_READER_H -#define POSITION_READER_H - -#include <string> -#include "Parameter/Parameter.h" - -class PositionReader -{ -public: - PositionReader(){} - ~PositionReader(){} - static void readFileForAlloc(const std::string fileName, Parameter* para); - static void readFile(const std::string fileName, std::string Type, Parameter* para); - static void readFileInterfaceForAlloc(const std::string fileName, std::string Type, Parameter* para); - static void readFileInterface(const std::string fileName, std::string Type, Parameter* para); - static void readFileInterfaceOffsetForAlloc(const std::string fileName, std::string Type, Parameter* para); - static void readFileInterfaceOffset(const std::string fileName, std::string Type, Parameter* para); - static void readFileNoSlipBcForAlloc(const std::string fileName, Parameter* para); - static void readFileNoSlipBcQreadForAlloc(const std::string fileName, Parameter* para); - static void readFileNoSlipBcPos(const std::string fileName, Parameter* para); - static void readFileNoSlipBcQs(const std::string fileName, Parameter* para); - static void readFileNoSlipBcValue(const std::string fileName, Parameter* para); - static void findQs(Parameter* para); - static void readFileSlipBcForAlloc(const std::string fileName, Parameter* para); - static void readFileSlipBcQreadForAlloc(const std::string fileName, Parameter* para); - static void readFileSlipBcPos(const std::string fileName, Parameter* para); - static void readFileSlipBcQs(const std::string fileName, Parameter* para); - static void readFileSlipBcValue(const std::string fileName, Parameter* para); - static void findSlipQs(Parameter* para); - static void readFilePressBcForAlloc(const std::string fileName, Parameter* para); - static void readFilePressBcQreadForAlloc(const std::string fileName, Parameter* para); - static void readFilePressBcPos(const std::string fileName, Parameter* para); - static void readFilePressBcQs(const std::string fileName, Parameter* para); - static void readFilePressBcValue(const std::string fileName, Parameter* para); - static void findPressQs(Parameter* para); - static void readFilePropellerCylinderForAlloc(Parameter* para); - static void readFilePropellerCylinder(Parameter* para); - static void definePropellerQs(Parameter* para); - static void readMeasurePoints(Parameter* para); -protected: -private: -}; - -#endif \ No newline at end of file diff --git a/src/gpu/VirtualFluids_GPU/Input/VtkGeometryReader.cpp b/src/gpu/VirtualFluids_GPU/Input/VtkGeometryReader.cpp deleted file mode 100644 index 39cbde1d8020d05fafa65253639da4c63a931628..0000000000000000000000000000000000000000 --- a/src/gpu/VirtualFluids_GPU/Input/VtkGeometryReader.cpp +++ /dev/null @@ -1,106 +0,0 @@ -#include "VtkGeometryReader.h" - -#include "basics/utilities/UbFileInputASCII.h" - -void VtkGeometryReader::readFile(const std::string& fileName, unsigned int* geoMat) -{ - UbFileInputASCII in(fileName); - - //in.readLine(); - //in.readLine(); - //in.readLine(); - //in.readLine(); - //in.readString(); - //int itsNX1 = in.readInteger(); - //int itsNX2 = in.readInteger(); - //int itsNX3 = in.readInteger(); - //int nn = itsNX1 * itsNX2 * itsNX3; - //in.readLine(); - //in.readString(); - //in.readInteger(); - //in.readString(); - //in.readLine(); - - //for(int k=0 ; k<itsNX3 ; k++){ - // for(int j=0 ; j<itsNX2 ; j++){ - // for(int i=0 ; i<itsNX1 ; i++){ - // //float x = i;//(j&0x1)^(k&0x1) + i*2; - // //float y = j; - // //float z = k; - // in.readFloat(); - // in.readFloat(); - // in.readFloat(); - // in.readLine(); - // } - // } - //} - - - //in.readString(); - //in.readInteger(); - //in.readLine(); - - //in.readLine(); - //in.readLine(); - - //for(int k=0 ; k<itsNX3 ; k++){ - // for(int j=0 ; j<itsNX2 ; j++){ - // for(int i=0 ; i<itsNX1 ; i++){ - // int m = itsNX1*(itsNX2*k + j) + i; - // geoMat[m] = in.readInteger(); - // in.readLine(); - // } - // } - //} - //int nn = itsNX1 * itsNX2 * itsNX3; - in.readLine(); - in.readLine(); - in.readLine(); - in.readLine(); - in.readString(); - unsigned int itsNX1 = in.readInteger(); - unsigned int itsNX2 = in.readInteger(); - unsigned int itsNX3 = in.readInteger(); - //int nn = itsNX1 * itsNX2 * itsNX3; - - std::cout << "NX = " << itsNX1 << "\n"; - std::cout << "NY = " << itsNX2 << "\n"; - std::cout << "NZ = " << itsNX3 << "\n"; - - in.readLine(); - in.readString(); - in.readDouble(); - in.readDouble(); - in.readDouble(); - //in.readInteger(); - //in.readInteger(); - //in.readInteger(); - in.readLine(); - in.readString(); - in.readDouble(); - in.readDouble(); - in.readDouble(); - in.readLine(); - in.readString(); - in.readInteger(); - in.readLine(); - in.readLine(); - in.readLine(); - - for(unsigned int k=0 ; k<itsNX3 ; k++){ - for(unsigned int j=0 ; j<itsNX2 ; j++){ - for(unsigned int i=0 ; i<itsNX1 ; i++){ - //int m = nx*(ny*k + j) + i; - //in.readInteger( itsGeoMatrix(i,j,k) ); - //in.readLine(); - unsigned int m = itsNX1*(itsNX2*k + j) + i; - geoMat[m] = in.readInteger(); - //if (i==0 && j==0 && k>50 && k<60) - //{ - // std::cout << "Read = " << geoMat[m] << "\n"; - //} - } - } - } - -} \ No newline at end of file diff --git a/src/gpu/VirtualFluids_GPU/Input/VtkGeometryReader.h b/src/gpu/VirtualFluids_GPU/Input/VtkGeometryReader.h deleted file mode 100644 index 15cabf8db9510071ec0b7c4a259f6d1647c0760d..0000000000000000000000000000000000000000 --- a/src/gpu/VirtualFluids_GPU/Input/VtkGeometryReader.h +++ /dev/null @@ -1,33 +0,0 @@ -#ifndef VTKGEOMETRYREADER_H -#define VTKGEOMETRYREADER_H - -#include <string> - -/** -* @file -* @author Kostyantyn Kucher <k.kucher@gmx.net> -* @version 1.0 -* -* @section LICENSE -* -* @section DESCRIPTION -* -* Read geometry from VTK Lagacy File -* geometry is integer values for node types difinition -* respectively -* SOLID = -* FLUID = -* -*/ - -class VtkGeometryReader -{ -public: - VtkGeometryReader(){} - ~VtkGeometryReader(){} - static void readFile(const std::string& fileName, unsigned int* geoMat); -protected: -private: -}; - -#endif \ No newline at end of file diff --git a/src/gpu/VirtualFluids_GPU/Input/kFullReader.cpp b/src/gpu/VirtualFluids_GPU/Input/kFullReader.cpp deleted file mode 100644 index 69f20d48dbbe833b5d0cdf808dc057ef2b871cd4..0000000000000000000000000000000000000000 --- a/src/gpu/VirtualFluids_GPU/Input/kFullReader.cpp +++ /dev/null @@ -1,121 +0,0 @@ -#include "kFullReader.h" - -#include "basics/utilities/UbFileInputASCII.h" - -void kFullReader::readFileForAlloc(const std::string fileName, Parameter* para) -{ - UbFileInputASCII in(fileName); - - int maxlevel = in.readInteger(); - in.readLine(); - - for (int level = 0; level <= maxlevel; level++) - { - int nodeNumberX1 = in.readInteger() - (2 * level); - int nodeNumberX2 = in.readInteger() - (2 * level); - int nodeNumberX3 = in.readInteger() - (2 * level); - para->getParH(level)->gridNX = nodeNumberX1; - para->getParH(level)->gridNY = nodeNumberX2; - para->getParH(level)->gridNZ = nodeNumberX3; - para->getParD(level)->gridNX = para->getParH(level)->gridNX; - para->getParD(level)->gridNY = para->getParH(level)->gridNY; - para->getParD(level)->gridNZ = para->getParH(level)->gridNZ; - - //weitere Werte setzen - para->getParH(level)->nx = para->getParH(level)->gridNX + 2 * STARTOFFX; - para->getParH(level)->ny = para->getParH(level)->gridNY + 2 * STARTOFFY; - para->getParH(level)->nz = para->getParH(level)->gridNZ + 2 * STARTOFFZ; - para->getParH(level)->size_Mat = para->getParH(level)->nx * para->getParH(level)->ny * para->getParH(level)->nz; - para->getParH(level)->mem_size_int = sizeof(unsigned int) * para->getParH(level)->size_Mat; - // - para->getParD(level)->nx = para->getParD(level)->gridNX + 2 * STARTOFFX; - para->getParD(level)->ny = para->getParD(level)->gridNY + 2 * STARTOFFY; - para->getParD(level)->nz = para->getParD(level)->gridNZ + 2 * STARTOFFZ; - para->getParD(level)->size_Mat = para->getParD(level)->nx * para->getParD(level)->ny * para->getParD(level)->nz; - para->getParD(level)->mem_size_int = sizeof(unsigned int) * para->getParD(level)->size_Mat; - - - in.readLine(); - for(unsigned int ix3=STARTOFFZ - level; ix3<para->getParH(level)->gridNZ + STARTOFFZ + level ; ix3++) - { - for(unsigned int ix2=STARTOFFY - level; ix2<para->getParH(level)->gridNY + STARTOFFY + level ; ix2++) - { - for(unsigned int ix1=STARTOFFX - level; ix1<para->getParH(level)->gridNX + STARTOFFX + level ; ix1++) - { - in.readInteger(); - } - } - } - in.readLine(); - } //end levelloop -} - -void kFullReader::readFile(const std::string fileName, Parameter* para) -{ - UbFileInputASCII in(fileName); - - int maxlevel = in.readInteger(); - in.readLine(); - - for (int level = 0; level <= maxlevel; level++) - { - in.readInteger(); - in.readInteger(); - in.readInteger(); - - in.readLine(); - for(unsigned int ix3=STARTOFFZ - level; ix3<para->getParH(level)->gridNZ + STARTOFFZ + level; ix3++) - { - for(unsigned int ix2=STARTOFFY - level; ix2<para->getParH(level)->gridNY + STARTOFFY + level; ix2++) - { - for(unsigned int ix1=STARTOFFX - level; ix1<para->getParH(level)->gridNX + STARTOFFX + level; ix1++) - { - unsigned int m = para->getParH(level)->nx*(para->getParH(level)->ny*ix3 + ix2) + ix1; - para->getParH(level)->k[m] = in.readInteger();//+1;//!!achtung + 1 - } - } - } - in.readLine(); - } //end levelloop -} - - -//GEO-FULL -void kFullReader::readGeoFull(const std::string fileName, Parameter* para) -{ - UbFileInputASCII in(fileName); - int test = 0; - int maxlevel = in.readInteger(); - in.readLine(); - - for (int level = 0; level <= maxlevel; level++) - { - in.readInteger(); - in.readInteger(); - in.readInteger(); - - in.readLine(); - for(unsigned int ix3=STARTOFFZ - level; ix3<para->getParH(level)->gridNZ + STARTOFFZ + level; ix3++) - { - for(unsigned int ix2=STARTOFFY - level; ix2<para->getParH(level)->gridNY + STARTOFFY + level; ix2++) - { - for(unsigned int ix1=STARTOFFX - level; ix1<para->getParH(level)->gridNX + STARTOFFX + level; ix1++) - { - unsigned int m = para->getParH(level)->nx*(para->getParH(level)->ny*ix3 + ix2) + ix1; - test = in.readInteger(); - if (test == 7) - { - test = 1; - } - else if (test != 1)//??? - { - test = 16; - } - para->getParH(level)->geo[m] = test; - //para->getParH(level)->geo[m] = in.readInteger();//+1;//!!achtung + 1 - } - } - } - in.readLine(); - } //end levelloop -} \ No newline at end of file diff --git a/src/gpu/VirtualFluids_GPU/Input/kFullReader.h b/src/gpu/VirtualFluids_GPU/Input/kFullReader.h deleted file mode 100644 index 35298de2b3ac11eef49e675ebf9149def1a07932..0000000000000000000000000000000000000000 --- a/src/gpu/VirtualFluids_GPU/Input/kFullReader.h +++ /dev/null @@ -1,19 +0,0 @@ -#ifndef KFULL_READER_H -#define KFULL_READER_H - -#include <string> -#include "Parameter/Parameter.h" - -class kFullReader -{ -public: - kFullReader(){} - ~kFullReader(){} - static void readFile(const std::string fileName, Parameter* para); - static void readFileForAlloc(const std::string fileName, Parameter* para); - static void readGeoFull(const std::string fileName, Parameter* para); -protected: -private: -}; - -#endif \ No newline at end of file diff --git a/src/gpu/VirtualFluids_GPU/Kernel/ChimeraTransformation.h b/src/gpu/VirtualFluids_GPU/Kernel/ChimeraTransformation.h index 40fab9d729c278dee2e89e34433d74061bd9813e..f7822d63fa0efd34b27773dffdeebddf521a8792 100644 --- a/src/gpu/VirtualFluids_GPU/Kernel/ChimeraTransformation.h +++ b/src/gpu/VirtualFluids_GPU/Kernel/ChimeraTransformation.h @@ -1,7 +1,9 @@ #ifndef CHIMERA_TRANSFORMATION_H #define CHIMERA_TRANSFORMATION_H -#include "Core/RealConstants.h" +#include <lbm/constants/NumericConstants.h> + +using namespace vf::lbm::constant; //////////////////////////////////////////////////////////////////////////////// //! \brief forward chimera transformation \ref forwardInverseChimeraWithK diff --git a/src/gpu/VirtualFluids_GPU/Kernel/Kernel.h b/src/gpu/VirtualFluids_GPU/Kernel/Kernel.h index 8932dadb3f92256cba279121193f94dbabdc0a6d..4b54277ddd405eb619191895065af9bb3b780063 100644 --- a/src/gpu/VirtualFluids_GPU/Kernel/Kernel.h +++ b/src/gpu/VirtualFluids_GPU/Kernel/Kernel.h @@ -1,26 +1,21 @@ -#ifndef KERNEL_H -#define KERNEL_H +#ifndef GPU_KERNEL_H +#define GPU_KERNEL_H -#include <DataTypes.h> - -#include <cuda_runtime.h> -#include <helper_functions.h> -#include <helper_cuda.h> +#include <vector> #include "Kernel/Utilities/KernelGroup.h" #include "PreProcessor/PreProcessorType.h" -#include <vector> - +#include <helper_cuda.h> class Kernel { public: - virtual ~Kernel() = default; - virtual void run() = 0; + virtual ~Kernel() = default; + virtual void run() = 0; - virtual bool checkParameter() = 0; - virtual std::vector<PreProcessorType> getPreProcessorTypes() = 0; - virtual KernelGroup getKernelGroup() = 0; + virtual bool checkParameter() = 0; + virtual std::vector<PreProcessorType> getPreProcessorTypes() = 0; + virtual KernelGroup getKernelGroup() = 0; }; -#endif \ No newline at end of file +#endif diff --git a/src/gpu/VirtualFluids_GPU/Kernel/KernelImp.cpp b/src/gpu/VirtualFluids_GPU/Kernel/KernelImp.cpp index 6d06d4c9175c7935bb609c2e342b29c50c42846d..5e4c5aa08e37e88008da13466bfeed6893ec94f6 100644 --- a/src/gpu/VirtualFluids_GPU/Kernel/KernelImp.cpp +++ b/src/gpu/VirtualFluids_GPU/Kernel/KernelImp.cpp @@ -2,26 +2,26 @@ #include "Kernel/Utilities/CheckParameterStrategy/CheckParameterStrategy.h" -bool KernelImp::checkParameter() -{ - return checkStrategy->checkParameter(para); +bool KernelImp::checkParameter() +{ + return checkStrategy->checkParameter(para); } -std::vector<PreProcessorType> KernelImp::getPreProcessorTypes() -{ - return myPreProcessorTypes; +std::vector<PreProcessorType> KernelImp::getPreProcessorTypes() +{ + return myPreProcessorTypes; } -KernelGroup KernelImp::getKernelGroup() -{ - return myKernelGroup; +KernelGroup KernelImp::getKernelGroup() +{ + return myKernelGroup; } void KernelImp::setCheckParameterStrategy(std::shared_ptr<CheckParameterStrategy> strategy) { - this->checkStrategy = strategy; + this->checkStrategy = strategy; } -KernelImp::KernelImp() -{ -} +KernelImp::KernelImp(std::shared_ptr<Parameter> para, int level) : para(para), level(level) {} + +KernelImp::KernelImp() {} \ 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 f902a7aaec82acd1eb0a55e97f5a4f31f4334575..47f689b7b3c88a6c7591454909cc6875384908c1 100644 --- a/src/gpu/VirtualFluids_GPU/Kernel/KernelImp.h +++ b/src/gpu/VirtualFluids_GPU/Kernel/KernelImp.h @@ -5,28 +5,33 @@ #include <memory> +#include <cuda/CudaGrid.h> + class CheckParameterStrategy; class Parameter; class KernelImp : public Kernel { public: - virtual void run() = 0; + virtual void run() = 0; - bool checkParameter(); - std::vector<PreProcessorType> getPreProcessorTypes(); - KernelGroup getKernelGroup(); + bool checkParameter(); + std::vector<PreProcessorType> getPreProcessorTypes(); + KernelGroup getKernelGroup(); - void setCheckParameterStrategy(std::shared_ptr<CheckParameterStrategy> strategy); + void setCheckParameterStrategy(std::shared_ptr<CheckParameterStrategy> strategy); protected: - KernelImp(); + KernelImp(std::shared_ptr<Parameter> para, int level); + KernelImp(); - std::shared_ptr< Parameter> para; - std::shared_ptr<CheckParameterStrategy> checkStrategy; - int level; - std::vector<PreProcessorType> myPreProcessorTypes; - KernelGroup myKernelGroup; + std::shared_ptr<Parameter> para; + std::shared_ptr<CheckParameterStrategy> checkStrategy; + int level; + std::vector<PreProcessorType> myPreProcessorTypes; + KernelGroup myKernelGroup; + vf::cuda::CudaGrid cudaGrid; }; -#endif \ No newline at end of file + +#endif diff --git a/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/AdvectionDiffusion/Compressible/Mod27/ADComp27/ADComp27_Device.cu b/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/AdvectionDiffusion/Compressible/Mod27/ADComp27/ADComp27_Device.cu index 34c71db68f102d989e590994fbe88bdcae8e1bb8..3ad149064a7f7a52a514f66066d179897591eb7f 100644 --- a/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/AdvectionDiffusion/Compressible/Mod27/ADComp27/ADComp27_Device.cu +++ b/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/AdvectionDiffusion/Compressible/Mod27/ADComp27/ADComp27_Device.cu @@ -1,6 +1,8 @@ #include "LBM/LB.h" #include "LBM/D3Q27.h" -#include "Core/RealConstants.h" +#include <lbm/constants/NumericConstants.h> + +using namespace vf::lbm::constant; #include "math.h" extern "C" __global__ void LB_KERNEL_AD_COMP_27(real diffusivity, diff --git a/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/AdvectionDiffusion/Compressible/Mod7/ADComp7/ADComp7_Device.cu b/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/AdvectionDiffusion/Compressible/Mod7/ADComp7/ADComp7_Device.cu index 15ecdd4764127a68cdc6b07e1a69a3294399416c..d5de82af54673e4e50af7c5639759ac9f1b105a0 100644 --- a/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/AdvectionDiffusion/Compressible/Mod7/ADComp7/ADComp7_Device.cu +++ b/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/AdvectionDiffusion/Compressible/Mod7/ADComp7/ADComp7_Device.cu @@ -1,6 +1,8 @@ #include "LBM/LB.h" #include "LBM/D3Q27.h" -#include "Core/RealConstants.h" +#include <lbm/constants/NumericConstants.h> + +using namespace vf::lbm::constant; #include "math.h" extern "C" __global__ void LB_Kernel_AD_Comp_7(real diffusivity, diff --git a/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/AdvectionDiffusion/Incompressible/Mod27/ADIncomp27/ADIncomp27_Device.cu b/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/AdvectionDiffusion/Incompressible/Mod27/ADIncomp27/ADIncomp27_Device.cu index 0daf75c0a47bca0c26918b77e92ab442cdc9ccf4..d9586b2eb599c451226482c1d3502104ad864d8f 100644 --- a/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/AdvectionDiffusion/Incompressible/Mod27/ADIncomp27/ADIncomp27_Device.cu +++ b/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/AdvectionDiffusion/Incompressible/Mod27/ADIncomp27/ADIncomp27_Device.cu @@ -1,6 +1,8 @@ #include "LBM/LB.h" #include "LBM/D3Q27.h" -#include "Core/RealConstants.h" +#include <lbm/constants/NumericConstants.h> + +using namespace vf::lbm::constant; #include "math.h" extern "C" __global__ void LB_Kernel_AD_Incomp_27(real diffusivity, diff --git a/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/AdvectionDiffusion/Incompressible/Mod7/ADIncomp7/ADIncomp7_Device.cu b/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/AdvectionDiffusion/Incompressible/Mod7/ADIncomp7/ADIncomp7_Device.cu index 43d02e0f1fb7282efb4a1f7ee3c00d33d8a68f4a..7ae4535d028b4da4fe53681219ef90705f990d06 100644 --- a/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/AdvectionDiffusion/Incompressible/Mod7/ADIncomp7/ADIncomp7_Device.cu +++ b/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/AdvectionDiffusion/Incompressible/Mod7/ADIncomp7/ADIncomp7_Device.cu @@ -1,6 +1,8 @@ #include "LBM/LB.h" #include "LBM/D3Q27.h" -#include "Core/RealConstants.h" +#include <lbm/constants/NumericConstants.h> + +using namespace vf::lbm::constant; #include "math.h" extern "C" __global__ void LB_Kernel_AD_Incomp_7(real diffusivity, diff --git a/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Compressible/BGK/BGKCompSP27_Device.cu b/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Compressible/BGK/BGKCompSP27_Device.cu index 717007d8436ecd735afe187fba99875822b19a44..c40397041a70ad99525bc2947724ed8de1b7121a 100644 --- a/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Compressible/BGK/BGKCompSP27_Device.cu +++ b/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Compressible/BGK/BGKCompSP27_Device.cu @@ -1,6 +1,8 @@ #include "LBM/LB.h" #include "LBM/D3Q27.h" -#include "Core/RealConstants.h" +#include <lbm/constants/NumericConstants.h> + +using namespace vf::lbm::constant; #include "math.h" diff --git a/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Compressible/BGKPlus/BGKPlusCompSP27_Device.cu b/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Compressible/BGKPlus/BGKPlusCompSP27_Device.cu index 9f2822f384dd66feb5c49cb239e33e238a67d28c..25138592cc9d602e66f0b22ae565fadcce44f27d 100644 --- a/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Compressible/BGKPlus/BGKPlusCompSP27_Device.cu +++ b/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Compressible/BGKPlus/BGKPlusCompSP27_Device.cu @@ -1,6 +1,8 @@ #include "LBM/LB.h" #include "LBM/D3Q27.h" -#include "Core/RealConstants.h" +#include <lbm/constants/NumericConstants.h> + +using namespace vf::lbm::constant; #include "math.h" extern "C" __global__ void LB_Kernel_BGK_Plus_Comp_SP_27( 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 new file mode 100644 index 0000000000000000000000000000000000000000..b86af5f876286599146190a1244a5bf21e2948fd --- /dev/null +++ b/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Compressible/BGKUnified/BGKUnified.cu @@ -0,0 +1,55 @@ +#include "BGKUnified.h" + +#include <stdexcept> + +#include "Parameter/Parameter.h" +#include "../RunLBMKernel.cuh" + +#include <lbm/BGK.h> + + +namespace vf +{ +namespace gpu +{ + + +BGKUnified::BGKUnified(std::shared_ptr<Parameter> para, int level) + : KernelImp(para, level) +{ +#ifndef BUILD_CUDA_LTO + throw std::invalid_argument("To use the BKGUnified kernel, pass -DBUILD_CUDA_LTO=ON to cmake. Requires: CUDA 11.2 & cc 5.0"); +#endif + + myPreProcessorTypes.push_back(InitCompSP27); + + myKernelGroup = BasicKernel; + + this->cudaGrid = cuda::CudaGrid(para->getParD(level)->numberofthreads, para->getParD(level)->size_Mat_SP); +} + + +void BGKUnified::run() +{ + GPUKernelParameter kernelParameter{ 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], + (int)para->getParD(level)->size_Mat_SP, + nullptr, /* forces not used in bgk kernel */ + para->getParD(level)->evenOrOdd }; + + auto lambda = [] __device__(lbm::KernelParameter parameter) { + return lbm::bgk(parameter); + }; + + runKernel<<<cudaGrid.grid, cudaGrid.threads>>>(lambda, kernelParameter); + + getLastCudaError("LB_Kernel_BGKUnified execution failed"); +} + + +} +} diff --git a/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Compressible/BGKUnified/BGKUnified.h b/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Compressible/BGKUnified/BGKUnified.h new file mode 100644 index 0000000000000000000000000000000000000000..762eaaa5935bd01fa6ae002521a40e45cd239dfd --- /dev/null +++ b/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Compressible/BGKUnified/BGKUnified.h @@ -0,0 +1,22 @@ +#ifndef GPU_BKGUnified_H +#define GPU_BKGUnified_H + +#include "Kernel/KernelImp.h" + +namespace vf +{ +namespace gpu +{ + +class BGKUnified : public KernelImp +{ +public: + BGKUnified(std::shared_ptr<Parameter> para, int level); + + void run(); +}; + +} +} + +#endif diff --git a/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Compressible/Cascade/CascadeCompSP27_Device.cu b/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Compressible/Cascade/CascadeCompSP27_Device.cu index d093a32022d63f125ed6d2ef4c24de01a41cedab..b024c2627235ffdbd34fa8234b88497b083074cf 100644 --- a/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Compressible/Cascade/CascadeCompSP27_Device.cu +++ b/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Compressible/Cascade/CascadeCompSP27_Device.cu @@ -1,6 +1,8 @@ #include "LBM/LB.h" #include "LBM/D3Q27.h" -#include "Core/RealConstants.h" +#include <lbm/constants/NumericConstants.h> + +using namespace vf::lbm::constant; #include "math.h" extern "C" __global__ void LB_Kernel_Cascade_Comp_SP_27(real omega, diff --git a/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Compressible/Cumulant/CumulantCompSP27_Device.cu b/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Compressible/Cumulant/CumulantCompSP27_Device.cu index dd5196fee8b21e96b98540c140110d7e4fb31a29..e76926b49b44eecd4b42a074e529d6f4af2936ea 100644 --- a/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Compressible/Cumulant/CumulantCompSP27_Device.cu +++ b/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Compressible/Cumulant/CumulantCompSP27_Device.cu @@ -1,6 +1,8 @@ #include "LBM/LB.h" #include "LBM/D3Q27.h" -#include "Core/RealConstants.h" +#include <lbm/constants/NumericConstants.h> + +using namespace vf::lbm::constant; #include "math.h" extern "C" __global__ void LB_Kernel_Cum_Comp_SP_27(real omega, diff --git a/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Compressible/CumulantAll4/CumulantAll4CompSP27_Device.cu b/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Compressible/CumulantAll4/CumulantAll4CompSP27_Device.cu index 99f7a4c034b4912e1ee2ce8f15f23e2ad5c459ac..599892c2fb170e3cba2b12356cbfbf1497a94edd 100644 --- a/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Compressible/CumulantAll4/CumulantAll4CompSP27_Device.cu +++ b/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Compressible/CumulantAll4/CumulantAll4CompSP27_Device.cu @@ -2,7 +2,9 @@ #include "LBM/LB.h" #include "LBM/D3Q27.h" -#include "Core/RealConstants.h" +#include <lbm/constants/NumericConstants.h> + +using namespace vf::lbm::constant; #include "math.h" extern "C" __global__ void LB_Kernel_Cumulant_D3Q27All4( real omega, @@ -231,7 +233,7 @@ extern "C" __global__ void LB_Kernel_Cumulant_D3Q27All4( real omega, // mfbbc-mfbba; //////////////////////////////////////////////////////////////////////////////////// // oMdrho assembler style -------> faaaaaastaaaa - // or much sloooowaaaa ... it depändssssss on sadaku + // or much sloooowaaaa ... it dep�ndssssss on sadaku real m0, m1, m2; //real oMdrho; //{ diff --git a/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Compressible/CumulantK15/CumulantK15Comp_Device.cu b/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Compressible/CumulantK15/CumulantK15Comp_Device.cu index 4fb90b7093e9608cb5dce616e56f79d90f540067..7349be5847c2ea936f7d999a4ce91aee02c17973 100644 --- a/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Compressible/CumulantK15/CumulantK15Comp_Device.cu +++ b/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Compressible/CumulantK15/CumulantK15Comp_Device.cu @@ -1,6 +1,8 @@ #include "LBM/LB.h" #include "LBM/D3Q27.h" -#include "Core/RealConstants.h" +#include <lbm/constants/NumericConstants.h> + +using namespace vf::lbm::constant; #include "math.h" extern "C" __global__ void LB_Kernel_CumulantK15Comp(real omega, @@ -227,7 +229,7 @@ extern "C" __global__ void LB_Kernel_CumulantK15Comp(real omega, // mfbbc-mfbba; //////////////////////////////////////////////////////////////////////////////////// // oMdrho assembler style -------> faaaaaastaaaa - // or much sloooowaaaa ... it depändssssss on sadaku + // or much sloooowaaaa ... it dep�ndssssss on sadaku real m0, m1, m2; //real oMdrho; //{ diff --git a/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Compressible/CumulantK15/CumulantK15Comp_Device.cuh b/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Compressible/CumulantK15/CumulantK15Comp_Device.cuh index 6a8eede33bc210eacad184afb42a7011dd684708..208fbec553507812bfe4339577734292b248c027 100644 --- a/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Compressible/CumulantK15/CumulantK15Comp_Device.cuh +++ b/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Compressible/CumulantK15/CumulantK15Comp_Device.cuh @@ -14,4 +14,4 @@ extern "C" __global__ void LB_Kernel_CumulantK15Comp( real omega, int level, real* forces, bool EvenOrOdd); -#endif \ No newline at end of file +#endif \ No newline at end of file diff --git a/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Compressible/CumulantK15Bulk/CumulantK15BulkComp_Device.cu b/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Compressible/CumulantK15Bulk/CumulantK15BulkComp_Device.cu index 1a0efdf8e4e70633f4b0052763813e0639e387d3..986e8163964bef6a62f1884f4e949f0b590ab859 100644 --- a/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Compressible/CumulantK15Bulk/CumulantK15BulkComp_Device.cu +++ b/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Compressible/CumulantK15Bulk/CumulantK15BulkComp_Device.cu @@ -1,6 +1,8 @@ #include "LBM/LB.h" #include "LBM/D3Q27.h" -#include "Core/RealConstants.h" +#include <lbm/constants/NumericConstants.h> + +using namespace vf::lbm::constant; #include "math.h" extern "C" __global__ void LB_Kernel_CumulantK15BulkComp(real omega, @@ -227,7 +229,7 @@ extern "C" __global__ void LB_Kernel_CumulantK15BulkComp(real omega, // mfbbc-mfbba; //////////////////////////////////////////////////////////////////////////////////// // oMdrho assembler style -------> faaaaaastaaaa - // or much sloooowaaaa ... it depändssssss on sadaku + // or much sloooowaaaa ... it dep�ndssssss on sadaku real m0, m1, m2; real vx2; real vy2; diff --git a/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Compressible/CumulantK15Sponge/CumulantK15SpongeComp_Device.cu b/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Compressible/CumulantK15Sponge/CumulantK15SpongeComp_Device.cu index 3a916bb894c0e22facefb995f4391d4f3cd27a49..c8be85d2ef05725b12a4b2e37bd262c430717723 100644 --- a/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Compressible/CumulantK15Sponge/CumulantK15SpongeComp_Device.cu +++ b/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Compressible/CumulantK15Sponge/CumulantK15SpongeComp_Device.cu @@ -1,6 +1,8 @@ #include "LBM/LB.h" #include "LBM/D3Q27.h" -#include "Core/RealConstants.h" +#include <lbm/constants/NumericConstants.h> + +using namespace vf::lbm::constant; #include "math.h" extern "C" __global__ void LB_Kernel_CumulantK15SpongeComp(real omegaIn, 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 new file mode 100644 index 0000000000000000000000000000000000000000..50f8d32f06ad25a4ab9d6f43ce5d908570d9b332 --- /dev/null +++ b/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Compressible/CumulantK15Unified/CumulantK15Unified.cu @@ -0,0 +1,54 @@ +#include "CumulantK15Unified.h" + +#include <stdexcept> + +#include "../RunLBMKernel.cuh" + +#include "Parameter/Parameter.h" + +#include <lbm/CumulantChimera.h> + +namespace vf +{ +namespace gpu +{ + +CumulantK15Unified::CumulantK15Unified(std::shared_ptr<Parameter> para, int level) + : KernelImp(para, level) +{ +#ifndef BUILD_CUDA_LTO + throw std::invalid_argument( + "To use the CumulantK15Unified kernel, pass -DBUILD_CUDA_LTO=ON to cmake. Requires: CUDA 11.2 & cc 5.0"); +#endif + + myPreProcessorTypes.push_back(InitCompSP27); + + myKernelGroup = BasicKernel; + + this->cudaGrid = cuda::CudaGrid(para->getParD(level)->numberofthreads, para->getParD(level)->size_Mat_SP); +} + +void CumulantK15Unified::run() +{ + GPUKernelParameter kernelParameter{ 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], + (int)para->getParD(level)->size_Mat_SP, + para->getParD(level)->forcing, + para->getParD(level)->evenOrOdd }; + + auto lambda = [] __device__(lbm::KernelParameter parameter) { + return lbm::cumulantChimera(parameter, lbm::setRelaxationRatesK15); + }; + + vf::gpu::runKernel<<<cudaGrid.grid, cudaGrid.threads>>>(lambda, kernelParameter); + + getLastCudaError("LB_Kernel_CumulantK15Comp execution failed"); +} + + +} +} \ No newline at end of file diff --git a/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Compressible/CumulantK15Unified/CumulantK15Unified.h b/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Compressible/CumulantK15Unified/CumulantK15Unified.h new file mode 100644 index 0000000000000000000000000000000000000000..8756253950484e00773af89327589c3d8f157729 --- /dev/null +++ b/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Compressible/CumulantK15Unified/CumulantK15Unified.h @@ -0,0 +1,21 @@ +#ifndef CUMULANT_K15_UNIFIED_COMP_H +#define CUMULANT_K15_UNIFIED_COMP_H + +#include "Kernel/KernelImp.h" + +namespace vf +{ +namespace gpu +{ +class CumulantK15Unified : public KernelImp +{ +public: + CumulantK15Unified(std::shared_ptr<Parameter> para, int level); + + void run(); +}; + +} +} + +#endif diff --git a/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Compressible/CumulantK17/CumulantK17Comp_Device.cu b/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Compressible/CumulantK17/CumulantK17Comp_Device.cu index 9ccd7dcb4ede3a493fe6c2621b03a515544bec96..4c20e465596a747389743b6658edecc9b3887f33 100644 --- a/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Compressible/CumulantK17/CumulantK17Comp_Device.cu +++ b/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Compressible/CumulantK17/CumulantK17Comp_Device.cu @@ -1,6 +1,8 @@ #include "LBM/LB.h" #include "LBM/D3Q27.h" -#include "Core/RealConstants.h" +#include <lbm/constants/NumericConstants.h> + +using namespace vf::lbm::constant; #include "math.h" @@ -229,7 +231,7 @@ extern "C" __global__ void LB_Kernel_CumulantK17Comp(real omega, // mfbbc-mfbba; //////////////////////////////////////////////////////////////////////////////////// // oMdrho assembler style -------> faaaaaastaaaa - // or much sloooowaaaa ... it depändssssss on sadaku + // or much sloooowaaaa ... it dep�ndssssss on sadaku real m0, m1, m2; //real oMdrho; //{ diff --git a/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Compressible/CumulantK17Bulk/CumulantK17BulkComp_Device.cu b/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Compressible/CumulantK17Bulk/CumulantK17BulkComp_Device.cu index 147b814a3c603637c8bb721e3fe96a7b6f2ce8ba..0e10a2d9540fd00d231f3d27ea4bf535949b8838 100644 --- a/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Compressible/CumulantK17Bulk/CumulantK17BulkComp_Device.cu +++ b/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Compressible/CumulantK17Bulk/CumulantK17BulkComp_Device.cu @@ -1,6 +1,8 @@ #include "LBM/LB.h" #include "LBM/D3Q27.h" -#include "Core/RealConstants.h" +#include <lbm/constants/NumericConstants.h> + +using namespace vf::lbm::constant; #include "math.h" extern "C" __global__ void LB_Kernel_CumulantK17BulkComp(real omega, 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 new file mode 100644 index 0000000000000000000000000000000000000000..e6ab61260b2c20ea5aec868ed70d714a066f2539 --- /dev/null +++ b/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Compressible/CumulantK17Unified/CumulantK17Unified.cu @@ -0,0 +1,55 @@ +#include "CumulantK17Unified.h" + +#include <stdexcept> + +#include "Parameter/Parameter.h" +#include "../RunLBMKernel.cuh" + +#include <lbm/CumulantChimera.h> + +namespace vf +{ +namespace gpu +{ + + +CumulantK17Unified::CumulantK17Unified(std::shared_ptr<Parameter> para, int level) + : KernelImp(para, level) +{ +#ifndef BUILD_CUDA_LTO + throw std::invalid_argument("To use the CumulantK17Unified kernel, pass -DBUILD_CUDA_LTO=ON to cmake. Requires: CUDA 11.2 & cc 5.0"); +#endif + + myPreProcessorTypes.push_back(InitCompSP27); + + myKernelGroup = BasicKernel; + + this->cudaGrid = cuda::CudaGrid(para->getParD(level)->numberofthreads, para->getParD(level)->size_Mat_SP); +} + + + +void CumulantK17Unified::run() +{ + GPUKernelParameter kernelParameter{ 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], + (int)para->getParD(level)->size_Mat_SP, + para->getParD(level)->forcing, + para->getParD(level)->evenOrOdd }; + + auto lambda = [] __device__(lbm::KernelParameter parameter) { + return lbm::cumulantChimera(parameter, lbm::setRelaxationRatesK17); + }; + + runKernel<<<cudaGrid.grid, cudaGrid.threads>>>(lambda, kernelParameter); + + getLastCudaError("LB_Kernel_CumulantK17Unified execution failed"); +} + + +} +} diff --git a/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Compressible/CumulantK17Unified/CumulantK17Unified.h b/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Compressible/CumulantK17Unified/CumulantK17Unified.h new file mode 100644 index 0000000000000000000000000000000000000000..af8470b717ad7a98e7a3fcd507976353d9e8bd41 --- /dev/null +++ b/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Compressible/CumulantK17Unified/CumulantK17Unified.h @@ -0,0 +1,23 @@ +#ifndef CUMULANT_K17_UNIFIED_H +#define CUMULANT_K17_UNIFIED_H + +#include "Kernel/KernelImp.h" + +namespace vf +{ +namespace gpu +{ + + +class CumulantK17Unified : public KernelImp +{ +public: + CumulantK17Unified(std::shared_ptr<Parameter> para, int level); + + void run(); +}; + +} +} + +#endif 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 38df36655e3705d26d3ee9614970cde9d2fdc87b..b97b2778440b7d1ab32b3d0e9bb002a48df03134 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 @@ -37,7 +37,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 6b316deb8736609ce73133754face5f82524e2d2..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 @@ -33,7 +33,9 @@ /* Device code */ #include "LBM/LB.h" #include "LBM/D3Q27.h" -#include "Core/RealConstants.h" +#include <lbm/constants/NumericConstants.h> + +using namespace vf::lbm::constant; #include "Kernel/ChimeraTransformation.h" //////////////////////////////////////////////////////////////////////////////// @@ -46,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) { @@ -208,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/CumulantK18/CumulantK18Comp_Device.cu b/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Compressible/CumulantK18/CumulantK18Comp_Device.cu index 2249e5857cb8c5d28b53658c25bbb9c3fc3e62c0..8d5b10b1ecf7076147dec425823233ba97fa11b8 100644 --- a/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Compressible/CumulantK18/CumulantK18Comp_Device.cu +++ b/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Compressible/CumulantK18/CumulantK18Comp_Device.cu @@ -1,6 +1,8 @@ #include "LBM/LB.h" #include "LBM/D3Q27.h" -#include "Core/RealConstants.h" +#include <lbm/constants/NumericConstants.h> + +using namespace vf::lbm::constant; #include "math.h" extern "C" __global__ void LB_Kernel_CumulantK18Comp( diff --git a/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Compressible/CumulantK20/CumulantK20Comp_Device.cu b/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Compressible/CumulantK20/CumulantK20Comp_Device.cu index 9edae07fabf8f2c18fb86055574b153e960d8dec..959a9e6d748deed1f2b509ae86b65f4ebbbdc1c1 100644 --- a/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Compressible/CumulantK20/CumulantK20Comp_Device.cu +++ b/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Compressible/CumulantK20/CumulantK20Comp_Device.cu @@ -1,6 +1,8 @@ #include "LBM/LB.h" #include "LBM/D3Q27.h" -#include "Core/RealConstants.h" +#include <lbm/constants/NumericConstants.h> + +using namespace vf::lbm::constant; #include "math.h" extern "C" __global__ void LB_Kernel_CumulantK20Comp( diff --git a/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Compressible/FluidFlowCompStrategy.h b/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Compressible/FluidFlowCompStrategy.h index 5bdf2e9bb0f00e3e2ae3642baa42545079f93c2c..c9a6675bd7a4b82442c55b23bac6f9b49b811938 100644 --- a/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Compressible/FluidFlowCompStrategy.h +++ b/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Compressible/FluidFlowCompStrategy.h @@ -15,4 +15,4 @@ private: FluidFlowCompStrategy(); }; -#endif \ No newline at end of file +#endif diff --git a/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Compressible/MRT/MRTCompSP27_Device.cu b/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Compressible/MRT/MRTCompSP27_Device.cu index 87984a4d963631462b3efac0f31667667ea1c96c..9bde8228fdab4a572496bb1e0478efe2cd9dedfa 100644 --- a/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Compressible/MRT/MRTCompSP27_Device.cu +++ b/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Compressible/MRT/MRTCompSP27_Device.cu @@ -1,6 +1,8 @@ #include "LBM/LB.h" #include "LBM/D3Q27.h" -#include "Core/RealConstants.h" +#include <lbm/constants/NumericConstants.h> + +using namespace vf::lbm::constant; #include "math.h" extern "C" __global__ void LB_Kernel_MRT_Comp_SP_27(real omega, 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 new file mode 100644 index 0000000000000000000000000000000000000000..ecfdb8e38bc5da02a473b6f2e67340963ed8b38a --- /dev/null +++ b/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Compressible/RunLBMKernel.cuh @@ -0,0 +1,61 @@ +#ifndef GPU_CUMULANT_KERNEL_H +#define GPU_CUMULANT_KERNEL_H + + +#include <DataTypes.h> +#include <cuda_runtime.h> + +#include <lbm/KernelParameter.h> + +#include "Kernel/Utilities/DistributionHelper.cuh" + +namespace vf +{ +namespace gpu +{ + + +struct GPUKernelParameter +{ + real omega; + unsigned int* typeOfGridNode; + unsigned int* neighborX; + unsigned int* neighborY; + unsigned int* neighborZ; + real* distributions; + int size_Mat; + real* forces; + bool isEvenTimestep; +}; + +template<typename KernelFunctor> +__global__ void runKernel(KernelFunctor kernel, GPUKernelParameter kernelParameter) +{ + const uint k = getNodeIndex(); + + if(k >= kernelParameter.size_Mat) + return; + + if (!isValidFluidNode(kernelParameter.typeOfGridNode[k])) + return; + + DistributionWrapper distributionWrapper { + kernelParameter.distributions, + kernelParameter.size_Mat, + kernelParameter.isEvenTimestep, + k, + kernelParameter.neighborX, + kernelParameter.neighborY, + kernelParameter.neighborZ + }; + + lbm::KernelParameter parameter {distributionWrapper.distribution, kernelParameter.omega, kernelParameter.forces}; + kernel(parameter); + + distributionWrapper.write(); +} + +} +} + +#endif \ No newline at end of file diff --git a/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Incompressible/BGK/BGKIncompSP27_Device.cu b/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Incompressible/BGK/BGKIncompSP27_Device.cu index 3869fc27108d17ba2f04d1bc9192a25d3aa2aab8..138b17170fc80b6f30c48f19111032d760915293 100644 --- a/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Incompressible/BGK/BGKIncompSP27_Device.cu +++ b/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Incompressible/BGK/BGKIncompSP27_Device.cu @@ -1,6 +1,8 @@ #include "LBM/LB.h" #include "LBM/D3Q27.h" -#include "Core/RealConstants.h" +#include <lbm/constants/NumericConstants.h> + +using namespace vf::lbm::constant; #include "math.h" extern "C" __global__ void LB_Kernel_BGK_Incomp_SP_27(real omega, diff --git a/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Incompressible/BGKPlus/BGKPlusIncompSP27_Device.cu b/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Incompressible/BGKPlus/BGKPlusIncompSP27_Device.cu index e82de30a7d8484e50b8ce9099138845ac773af79..deb8d94dc631c1dfaabddbf97b568d82ab47ebf6 100644 --- a/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Incompressible/BGKPlus/BGKPlusIncompSP27_Device.cu +++ b/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Incompressible/BGKPlus/BGKPlusIncompSP27_Device.cu @@ -1,6 +1,8 @@ #include "LBM/LB.h" #include "LBM/D3Q27.h" -#include "Core/RealConstants.h" +#include <lbm/constants/NumericConstants.h> + +using namespace vf::lbm::constant; #include "math.h" extern "C" __global__ void LB_Kernel_BGK_Plus_Incomp_SP_27(real omega, diff --git a/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Incompressible/Cascade/CascadeIncompSP27_Device.cu b/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Incompressible/Cascade/CascadeIncompSP27_Device.cu index 649bd0fc3503f7809e0c0b9f72f86f59a68d26f8..025729760d975e04bb51214f59715c0cd8c8685f 100644 --- a/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Incompressible/Cascade/CascadeIncompSP27_Device.cu +++ b/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Incompressible/Cascade/CascadeIncompSP27_Device.cu @@ -1,6 +1,8 @@ #include "LBM/LB.h" #include "LBM/D3Q27.h" -#include "Core/RealConstants.h" +#include <lbm/constants/NumericConstants.h> + +using namespace vf::lbm::constant; #include "math.h" extern "C" __global__ void LB_Kernel_Cascade_Incomp_SP_27(real omega, diff --git a/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Incompressible/Cumulant1hSP27/Cumulant1hIncompSP27_Device.cu b/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Incompressible/Cumulant1hSP27/Cumulant1hIncompSP27_Device.cu index f8f8b1cedf78145382ed911d07a3590adee4c687..84bf396c47301fe80cca36294a869c0bdd87f9e6 100644 --- a/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Incompressible/Cumulant1hSP27/Cumulant1hIncompSP27_Device.cu +++ b/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Incompressible/Cumulant1hSP27/Cumulant1hIncompSP27_Device.cu @@ -1,6 +1,8 @@ #include "LBM/LB.h" #include "LBM/D3Q27.h" -#include "Core/RealConstants.h" +#include <lbm/constants/NumericConstants.h> + +using namespace vf::lbm::constant; #include "math.h" extern "C" __global__ void LB_Kernel_Cum_1h_Incomp_SP_27(real omega, @@ -226,7 +228,7 @@ extern "C" __global__ void LB_Kernel_Cum_1h_Incomp_SP_27(real omega, // mfbbc-mfbba; //////////////////////////////////////////////////////////////////////////////////// // oMdrho assembler style -------> faaaaaastaaaa - // or much sloooowaaaa ... it depändssssss on sadaku + // or much sloooowaaaa ... it dep�ndssssss on sadaku real m0, m1, m2; //real oMdrho; //{ diff --git a/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Incompressible/CumulantIsoSP27/CumulantIsoIncompSP27_Device.cu b/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Incompressible/CumulantIsoSP27/CumulantIsoIncompSP27_Device.cu index 4baf5ffddc9e2db77c78d62d244054245b930d3e..753bb0be77c2e269e77e84f12ccf52be71059eb3 100644 --- a/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Incompressible/CumulantIsoSP27/CumulantIsoIncompSP27_Device.cu +++ b/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Incompressible/CumulantIsoSP27/CumulantIsoIncompSP27_Device.cu @@ -1,6 +1,8 @@ #include "LBM/LB.h" #include "LBM/D3Q27.h" -#include "Core/RealConstants.h" +#include <lbm/constants/NumericConstants.h> + +using namespace vf::lbm::constant; #include "math.h" extern "C" __global__ void LB_Kernel_Cum_IsoTest_Incomp_SP_27(real omega, @@ -183,7 +185,7 @@ extern "C" __global__ void LB_Kernel_Cum_IsoTest_Incomp_SP_27(real omega, // mfbbc-mfbba; //////////////////////////////////////////////////////////////////////////////////// // oMdrho assembler style -------> faaaaaastaaaa - // or much sloooowaaaa ... it depändssssss on sadaku + // or much sloooowaaaa ... it dep�ndssssss on sadaku real m0, m1, m2; //real oMdrho; //{ diff --git a/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Incompressible/CumulantK15/CumulantK15Incomp_Device.cu b/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Incompressible/CumulantK15/CumulantK15Incomp_Device.cu index 1aece78752106eccdf5a9c0ab22985eceb58fd27..9c8ca3a6802add72614b58771e6104ab68fa01ec 100644 --- a/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Incompressible/CumulantK15/CumulantK15Incomp_Device.cu +++ b/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Incompressible/CumulantK15/CumulantK15Incomp_Device.cu @@ -1,6 +1,8 @@ #include "LBM/LB.h" #include "LBM/D3Q27.h" -#include "Core/RealConstants.h" +#include <lbm/constants/NumericConstants.h> + +using namespace vf::lbm::constant; #include "math.h" extern "C" __global__ void LB_Kernel_CumulantK15Incomp(real omega, diff --git a/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Incompressible/MRT/MRTIncompSP27_Device.cu b/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Incompressible/MRT/MRTIncompSP27_Device.cu index 97b5e96aae03c2d881689026665e84ca00c2a349..be2b2333ab7375b5c8b851d705b562fce87f1d2a 100644 --- a/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Incompressible/MRT/MRTIncompSP27_Device.cu +++ b/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Incompressible/MRT/MRTIncompSP27_Device.cu @@ -1,6 +1,8 @@ #include "LBM/LB.h" #include "LBM/D3Q27.h" -#include "Core/RealConstants.h" +#include <lbm/constants/NumericConstants.h> + +using namespace vf::lbm::constant; #include "math.h" extern "C" __global__ void LB_Kernel_MRT_Incomp_SP_27(real omega, diff --git a/src/gpu/VirtualFluids_GPU/Kernel/Kernels/PorousMediaKernels/FluidFlow/Compressible/CumulantOne/PMCumulantOneCompSP27_Device.cu b/src/gpu/VirtualFluids_GPU/Kernel/Kernels/PorousMediaKernels/FluidFlow/Compressible/CumulantOne/PMCumulantOneCompSP27_Device.cu index 734b71e7a4b227b90f83587f47c1357a6d44e85a..2f42b717259aeab052be08b6ef6485771734ad98 100644 --- a/src/gpu/VirtualFluids_GPU/Kernel/Kernels/PorousMediaKernels/FluidFlow/Compressible/CumulantOne/PMCumulantOneCompSP27_Device.cu +++ b/src/gpu/VirtualFluids_GPU/Kernel/Kernels/PorousMediaKernels/FluidFlow/Compressible/CumulantOne/PMCumulantOneCompSP27_Device.cu @@ -1,6 +1,8 @@ #include "LBM/LB.h" #include "LBM/D3Q27.h" -#include "Core/RealConstants.h" +#include <lbm/constants/NumericConstants.h> + +using namespace vf::lbm::constant; #include "math.h" extern "C" __global__ void LB_Kernel_PM_Cum_One_Comp_SP_27(real omega, diff --git a/src/gpu/VirtualFluids_GPU/Kernel/Kernels/WaleKernels/FluidFlow/Compressible/CumulantK15/WaleCumulantK15Comp_Device.cu b/src/gpu/VirtualFluids_GPU/Kernel/Kernels/WaleKernels/FluidFlow/Compressible/CumulantK15/WaleCumulantK15Comp_Device.cu index a23d1c480b31befbe1ece6b83b20fa415c94a0e7..23c4d72d23a42977cf44cce8bcd622e9edc66968 100644 --- a/src/gpu/VirtualFluids_GPU/Kernel/Kernels/WaleKernels/FluidFlow/Compressible/CumulantK15/WaleCumulantK15Comp_Device.cu +++ b/src/gpu/VirtualFluids_GPU/Kernel/Kernels/WaleKernels/FluidFlow/Compressible/CumulantK15/WaleCumulantK15Comp_Device.cu @@ -1,6 +1,8 @@ #include "LBM/LB.h" #include "LBM/D3Q27.h" -#include "Core/RealConstants.h" +#include <lbm/constants/NumericConstants.h> + +using namespace vf::lbm::constant; #include "math.h" extern "C" __global__ void LB_Kernel_WaleCumulantK15Comp( @@ -421,7 +423,7 @@ extern "C" __global__ void LB_Kernel_WaleCumulantK15Comp( //nuTurb = pow(delta, two) * pow(SumSDsq, c3o2) / (pow(SumSsq, c5o2) + pow(SumSDsq, c5o4) + smallSingle); //pow //nuTurb = (delta * delta) * (real)pow((double)SumSDsq, 1.5) / ((real)pow((double)SumSsq, 2.5) + (real)pow((double)SumSDsq, 1.25) + smallSingle); //SMversion// nuTurb = (delta * delta) * (real)pow((double)SumSDsq, 0.25) / - ((real)pow(((real)pow((double)SumSsq, 0.5) / ((real)pow((double)SumSDsq, 0.25) + c10eM10)), 5.0) + c1o1); //SMversion2// + ((real)pow(((double)pow((double)SumSsq, 0.5) / ((real)pow((double)SumSDsq, 0.25) + c10eM10)), 5.0) + c1o1); //SMversion2// ///////////////////////////////// //nuTurb = rho * powf(delta, two) * powf(SumSd*SumSd, c3o2) / (powf(SumS*SumS, c5o2) + powf(SumSd*SumSd, c5o4)); //nuTurb = powf(delta, two) * powf(SumSd*SumSd, c3o2) / (powf(SumS*SumS, c5o2) + powf(SumSd*SumSd, c5o4)); diff --git a/src/gpu/VirtualFluids_GPU/Kernel/Kernels/WaleKernels/FluidFlow/Compressible/CumulantK15BySoniMalav/WaleBySoniMalavCumulantK15Comp_Device.cu b/src/gpu/VirtualFluids_GPU/Kernel/Kernels/WaleKernels/FluidFlow/Compressible/CumulantK15BySoniMalav/WaleBySoniMalavCumulantK15Comp_Device.cu index 7d3e1fab7d01b8a4d2b546e6227279f5ed46431f..a791e1114ddad8b2bc2e7eaa3ac5d9690fd3e11a 100644 --- a/src/gpu/VirtualFluids_GPU/Kernel/Kernels/WaleKernels/FluidFlow/Compressible/CumulantK15BySoniMalav/WaleBySoniMalavCumulantK15Comp_Device.cu +++ b/src/gpu/VirtualFluids_GPU/Kernel/Kernels/WaleKernels/FluidFlow/Compressible/CumulantK15BySoniMalav/WaleBySoniMalavCumulantK15Comp_Device.cu @@ -1,6 +1,8 @@ #include "LBM/LB.h" #include "LBM/D3Q27.h" -#include "Core/RealConstants.h" +#include <lbm/constants/NumericConstants.h> + +using namespace vf::lbm::constant; #include "math.h" extern "C" __global__ void LB_Kernel_WaleBySoniMalavCumulantK15Comp( diff --git a/src/gpu/VirtualFluids_GPU/Kernel/Kernels/WaleKernels/FluidFlow/Compressible/CumulantK17/WaleCumulantK17Comp_Device.cu b/src/gpu/VirtualFluids_GPU/Kernel/Kernels/WaleKernels/FluidFlow/Compressible/CumulantK17/WaleCumulantK17Comp_Device.cu index 91e91bc0ff5e1582eab279c77e9fa0b419ce06ea..0ff953e261d7c726a360b5952ac5b58c32c96791 100644 --- a/src/gpu/VirtualFluids_GPU/Kernel/Kernels/WaleKernels/FluidFlow/Compressible/CumulantK17/WaleCumulantK17Comp_Device.cu +++ b/src/gpu/VirtualFluids_GPU/Kernel/Kernels/WaleKernels/FluidFlow/Compressible/CumulantK17/WaleCumulantK17Comp_Device.cu @@ -1,6 +1,8 @@ #include "LBM/LB.h" #include "LBM/D3Q27.h" -#include "Core/RealConstants.h" +#include <lbm/constants/NumericConstants.h> + +using namespace vf::lbm::constant; #include "math.h" extern "C" __global__ void LB_Kernel_WaleCumulantK17Comp( @@ -422,7 +424,7 @@ extern "C" __global__ void LB_Kernel_WaleCumulantK17Comp( //nuTurb = pow(delta, two) * pow(SumSDsq, c3o2) / (pow(SumSsq, c5o2) + pow(SumSDsq, c5o4) + smallSingle); //pow //nuTurb = (delta * delta) * (real)pow((double)SumSDsq, 1.5) / ((real)pow((double)SumSsq, 2.5) + (real)pow((double)SumSDsq, 1.25) + smallSingle); //SMversion// nuTurb = (delta * delta) * (real)pow((double)SumSDsq, 0.25) / - ((real)pow(((real)pow((double)SumSsq, 0.5) / ((real)pow((double)SumSDsq, 0.25) + c10eM10)), 5.0) + c1o1); //SMversion2// + ((real)pow(((double)pow((double)SumSsq, 0.5) / ((real)pow((double)SumSDsq, 0.25) + c10eM10)), 5.0) + c1o1); //SMversion2// ///////////////////////////////// //nuTurb = rho * powf(delta, two) * powf(SumSd*SumSd, c3o2) / (powf(SumS*SumS, c5o2) + powf(SumSd*SumSd, c5o4)); //nuTurb = powf(delta, two) * powf(SumSd*SumSd, c3o2) / (powf(SumS*SumS, c5o2) + powf(SumSd*SumSd, c5o4)); diff --git a/src/gpu/VirtualFluids_GPU/Kernel/Kernels/WaleKernels/FluidFlow/Compressible/CumulantK17Debug/WaleCumulantK17DebugComp_Device.cu b/src/gpu/VirtualFluids_GPU/Kernel/Kernels/WaleKernels/FluidFlow/Compressible/CumulantK17Debug/WaleCumulantK17DebugComp_Device.cu index b0e0b65064e2395f5049eeb2df3b8260125fbf4e..9d4efb2ab81a30d27a7909212e8c35847fded3ea 100644 --- a/src/gpu/VirtualFluids_GPU/Kernel/Kernels/WaleKernels/FluidFlow/Compressible/CumulantK17Debug/WaleCumulantK17DebugComp_Device.cu +++ b/src/gpu/VirtualFluids_GPU/Kernel/Kernels/WaleKernels/FluidFlow/Compressible/CumulantK17Debug/WaleCumulantK17DebugComp_Device.cu @@ -1,6 +1,8 @@ #include "LBM/LB.h" #include "LBM/D3Q27.h" -#include "Core/RealConstants.h" +#include <lbm/constants/NumericConstants.h> + +using namespace vf::lbm::constant; #include "math.h" extern "C" __global__ void LB_Kernel_WaleCumulantK17DebugComp( diff --git a/src/gpu/VirtualFluids_GPU/Kernel/Utilities/DistributionHelper.cu b/src/gpu/VirtualFluids_GPU/Kernel/Utilities/DistributionHelper.cu new file mode 100644 index 0000000000000000000000000000000000000000..2b9203bf96be89fb328cbbe221994dffed481e14 --- /dev/null +++ b/src/gpu/VirtualFluids_GPU/Kernel/Utilities/DistributionHelper.cu @@ -0,0 +1,168 @@ +#include "DistributionHelper.cuh" + +#include <cuda_runtime.h> + +#include "LBM/D3Q27.h" + +#include <lbm/constants/NumericConstants.h> +#include <lbm/constants/D3Q27.h> + +namespace vf +{ +namespace gpu +{ + +__device__ __host__ DistributionReferences27 getDistributionReferences27(real *distributions, unsigned int size_Mat, bool isEvenTimestep) +{ + DistributionReferences27 distribution_references; + + if (isEvenTimestep) { + distribution_references.f[dirE] = &distributions[dirE * size_Mat]; + distribution_references.f[dirW] = &distributions[dirW * size_Mat]; + distribution_references.f[dirN] = &distributions[dirN * size_Mat]; + distribution_references.f[dirS] = &distributions[dirS * size_Mat]; + distribution_references.f[dirT] = &distributions[dirT * size_Mat]; + distribution_references.f[dirB] = &distributions[dirB * size_Mat]; + distribution_references.f[dirNE] = &distributions[dirNE * size_Mat]; + distribution_references.f[dirSW] = &distributions[dirSW * size_Mat]; + distribution_references.f[dirSE] = &distributions[dirSE * size_Mat]; + distribution_references.f[dirNW] = &distributions[dirNW * size_Mat]; + distribution_references.f[dirTE] = &distributions[dirTE * size_Mat]; + distribution_references.f[dirBW] = &distributions[dirBW * size_Mat]; + distribution_references.f[dirBE] = &distributions[dirBE * size_Mat]; + distribution_references.f[dirTW] = &distributions[dirTW * size_Mat]; + distribution_references.f[dirTN] = &distributions[dirTN * size_Mat]; + distribution_references.f[dirBS] = &distributions[dirBS * size_Mat]; + distribution_references.f[dirBN] = &distributions[dirBN * size_Mat]; + distribution_references.f[dirTS] = &distributions[dirTS * size_Mat]; + distribution_references.f[dirREST] = &distributions[dirREST * size_Mat]; + distribution_references.f[dirTNE] = &distributions[dirTNE * size_Mat]; + distribution_references.f[dirTSW] = &distributions[dirTSW * size_Mat]; + distribution_references.f[dirTSE] = &distributions[dirTSE * size_Mat]; + distribution_references.f[dirTNW] = &distributions[dirTNW * size_Mat]; + distribution_references.f[dirBNE] = &distributions[dirBNE * size_Mat]; + distribution_references.f[dirBSW] = &distributions[dirBSW * size_Mat]; + distribution_references.f[dirBSE] = &distributions[dirBSE * size_Mat]; + distribution_references.f[dirBNW] = &distributions[dirBNW * size_Mat]; + } else { + distribution_references.f[dirW] = &distributions[dirE * size_Mat]; + distribution_references.f[dirE] = &distributions[dirW * size_Mat]; + distribution_references.f[dirS] = &distributions[dirN * size_Mat]; + distribution_references.f[dirN] = &distributions[dirS * size_Mat]; + distribution_references.f[dirB] = &distributions[dirT * size_Mat]; + distribution_references.f[dirT] = &distributions[dirB * size_Mat]; + distribution_references.f[dirSW] = &distributions[dirNE * size_Mat]; + distribution_references.f[dirNE] = &distributions[dirSW * size_Mat]; + distribution_references.f[dirNW] = &distributions[dirSE * size_Mat]; + distribution_references.f[dirSE] = &distributions[dirNW * size_Mat]; + distribution_references.f[dirBW] = &distributions[dirTE * size_Mat]; + distribution_references.f[dirTE] = &distributions[dirBW * size_Mat]; + distribution_references.f[dirTW] = &distributions[dirBE * size_Mat]; + distribution_references.f[dirBE] = &distributions[dirTW * size_Mat]; + distribution_references.f[dirBS] = &distributions[dirTN * size_Mat]; + distribution_references.f[dirTN] = &distributions[dirBS * size_Mat]; + distribution_references.f[dirTS] = &distributions[dirBN * size_Mat]; + distribution_references.f[dirBN] = &distributions[dirTS * size_Mat]; + distribution_references.f[dirREST] = &distributions[dirREST * size_Mat]; + distribution_references.f[dirBSW] = &distributions[dirTNE * size_Mat]; + distribution_references.f[dirBNE] = &distributions[dirTSW * size_Mat]; + distribution_references.f[dirBNW] = &distributions[dirTSE * size_Mat]; + distribution_references.f[dirBSE] = &distributions[dirTNW * size_Mat]; + distribution_references.f[dirTSW] = &distributions[dirBNE * size_Mat]; + distribution_references.f[dirTNE] = &distributions[dirBSW * size_Mat]; + distribution_references.f[dirTNW] = &distributions[dirBSE * size_Mat]; + distribution_references.f[dirTSE] = &distributions[dirBNW * size_Mat]; + } + return distribution_references; +} + +__device__ DistributionWrapper::DistributionWrapper(real *distributions, unsigned int size_Mat, bool isEvenTimestep, + uint k, uint *neighborX, uint *neighborY, uint *neighborZ) + : distribution_references(getDistributionReferences27(distributions, size_Mat, isEvenTimestep)), k(k), kw(neighborX[k]), ks(neighborY[k]), + kb(neighborZ[k]), ksw(neighborY[kw]), kbw(neighborZ[kw]), kbs(neighborZ[ks]), kbsw(neighborZ[ksw]) +{ + read(); +} + +__device__ void DistributionWrapper::read() +{ + distribution.f[vf::lbm::dir::PZZ] = (distribution_references.f[dirE])[k]; + distribution.f[vf::lbm::dir::MZZ] = (distribution_references.f[dirW])[kw]; + distribution.f[vf::lbm::dir::ZPZ] = (distribution_references.f[dirN])[k]; + distribution.f[vf::lbm::dir::ZMZ] = (distribution_references.f[dirS])[ks]; + distribution.f[vf::lbm::dir::ZZP] = (distribution_references.f[dirT])[k]; + distribution.f[vf::lbm::dir::ZZM] = (distribution_references.f[dirB])[kb]; + distribution.f[vf::lbm::dir::PPZ] = (distribution_references.f[dirNE])[k]; + distribution.f[vf::lbm::dir::MMZ] = (distribution_references.f[dirSW])[ksw]; + distribution.f[vf::lbm::dir::PMZ] = (distribution_references.f[dirSE])[ks]; + distribution.f[vf::lbm::dir::MPZ] = (distribution_references.f[dirNW])[kw]; + distribution.f[vf::lbm::dir::PZP] = (distribution_references.f[dirTE])[k]; + distribution.f[vf::lbm::dir::MZM] = (distribution_references.f[dirBW])[kbw]; + distribution.f[vf::lbm::dir::PZM] = (distribution_references.f[dirBE])[kb]; + distribution.f[vf::lbm::dir::MZP] = (distribution_references.f[dirTW])[kw]; + distribution.f[vf::lbm::dir::ZPP] = (distribution_references.f[dirTN])[k]; + distribution.f[vf::lbm::dir::ZMM] = (distribution_references.f[dirBS])[kbs]; + distribution.f[vf::lbm::dir::ZPM] = (distribution_references.f[dirBN])[kb]; + distribution.f[vf::lbm::dir::ZMP] = (distribution_references.f[dirTS])[ks]; + distribution.f[vf::lbm::dir::PPP] = (distribution_references.f[dirTNE])[k]; + distribution.f[vf::lbm::dir::MPP] = (distribution_references.f[dirTNW])[kw]; + distribution.f[vf::lbm::dir::PMP] = (distribution_references.f[dirTSE])[ks]; + distribution.f[vf::lbm::dir::MMP] = (distribution_references.f[dirTSW])[ksw]; + distribution.f[vf::lbm::dir::PPM] = (distribution_references.f[dirBNE])[kb]; + distribution.f[vf::lbm::dir::MPM] = (distribution_references.f[dirBNW])[kbw]; + distribution.f[vf::lbm::dir::PMM] = (distribution_references.f[dirBSE])[kbs]; + distribution.f[vf::lbm::dir::MMM] = (distribution_references.f[dirBSW])[kbsw]; + distribution.f[vf::lbm::dir::ZZZ] = (distribution_references.f[dirREST])[k]; +} + +__device__ void DistributionWrapper::write() +{ + (distribution_references.f[dirE])[k] = distribution.f[vf::lbm::dir::PZZ]; + (distribution_references.f[dirW])[kw] = distribution.f[vf::lbm::dir::MZZ]; + (distribution_references.f[dirN])[k] = distribution.f[vf::lbm::dir::ZPZ]; + (distribution_references.f[dirS])[ks] = distribution.f[vf::lbm::dir::ZMZ]; + (distribution_references.f[dirT])[k] = distribution.f[vf::lbm::dir::ZZP]; + (distribution_references.f[dirB])[kb] = distribution.f[vf::lbm::dir::ZZM]; + (distribution_references.f[dirNE])[k] = distribution.f[vf::lbm::dir::PPZ]; + (distribution_references.f[dirSW])[ksw] = distribution.f[vf::lbm::dir::MMZ]; + (distribution_references.f[dirSE])[ks] = distribution.f[vf::lbm::dir::PMZ]; + (distribution_references.f[dirNW])[kw] = distribution.f[vf::lbm::dir::MPZ]; + (distribution_references.f[dirTE])[k] = distribution.f[vf::lbm::dir::PZP]; + (distribution_references.f[dirBW])[kbw] = distribution.f[vf::lbm::dir::MZM]; + (distribution_references.f[dirBE])[kb] = distribution.f[vf::lbm::dir::PZM]; + (distribution_references.f[dirTW])[kw] = distribution.f[vf::lbm::dir::MZP]; + (distribution_references.f[dirTN])[k] = distribution.f[vf::lbm::dir::ZPP]; + (distribution_references.f[dirBS])[kbs] = distribution.f[vf::lbm::dir::ZMM]; + (distribution_references.f[dirBN])[kb] = distribution.f[vf::lbm::dir::ZPM]; + (distribution_references.f[dirTS])[ks] = distribution.f[vf::lbm::dir::ZMP]; + (distribution_references.f[dirTNE])[k] = distribution.f[vf::lbm::dir::PPP]; + (distribution_references.f[dirTNW])[kw] = distribution.f[vf::lbm::dir::MPP]; + (distribution_references.f[dirTSE])[ks] = distribution.f[vf::lbm::dir::PMP]; + (distribution_references.f[dirTSW])[ksw] = distribution.f[vf::lbm::dir::MMP]; + (distribution_references.f[dirBNE])[kb] = distribution.f[vf::lbm::dir::PPM]; + (distribution_references.f[dirBNW])[kbw] = distribution.f[vf::lbm::dir::MPM]; + (distribution_references.f[dirBSE])[kbs] = distribution.f[vf::lbm::dir::PMM]; + (distribution_references.f[dirBSW])[kbsw] = distribution.f[vf::lbm::dir::MMM]; + (distribution_references.f[dirREST])[k] = distribution.f[vf::lbm::dir::ZZZ]; +} + +__device__ unsigned int getNodeIndex() +{ + 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; + + return nx * (ny * z + y) + x; +} + +__device__ bool isValidFluidNode(uint nodeType) +{ + return (nodeType == GEO_FLUID || nodeType == GEO_PM_0 || nodeType == GEO_PM_1 || nodeType == GEO_PM_2); +} + + +} // namespace gpu +} // namespace vf diff --git a/src/gpu/VirtualFluids_GPU/Kernel/Utilities/DistributionHelper.cuh b/src/gpu/VirtualFluids_GPU/Kernel/Utilities/DistributionHelper.cuh new file mode 100644 index 0000000000000000000000000000000000000000..6b38cac75c99680c71420533455dd060195b6c87 --- /dev/null +++ b/src/gpu/VirtualFluids_GPU/Kernel/Utilities/DistributionHelper.cuh @@ -0,0 +1,98 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// 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 Cumulant27chim.cu +//! \ingroup GPU +//! \author Martin Schoenherr, Soeren Peters +//======================================================================================= +#ifndef DISTRIBUTUION_HELPER_CUH +#define DISTRIBUTUION_HELPER_CUH + +#include "LBM/LB.h" + +#include <lbm/KernelParameter.h> + +namespace vf +{ +namespace gpu +{ + +/** +* Getting references to the 27 directions. +* @params distributions 1D real* array containing all data (number of elements = 27 * matrix_size) +* @params matrix_size number of discretizations nodes +* @params isEvenTimestep: stored data dependent on timestep is based on the esoteric twist algorithm +* @return a data struct containing the addresses to the 27 directions within the 1D distribution array +*/ +__device__ __host__ DistributionReferences27 getDistributionReferences27(real* distributions, unsigned int matrix_size, bool isEvenTimestep); + + +/** +* Holds the references to all directions and the concrete distributions for a single node. +* After instantiation the distributions are read to the member "distribution" from "distribution_references". +* After computation the data can be written back to "distribution_references". +*/ +struct DistributionWrapper +{ + __device__ DistributionWrapper( + real* distributions, + unsigned int size_Mat, + bool isEvenTimestep, + uint k, + uint* neighborX, + uint* neighborY, + uint* neighborZ); + + __device__ void read(); + + __device__ void write(); + + // origin distributions to read from and write to after computation + DistributionReferences27 distribution_references; + + // distribution pass to kernel computation + vf::lbm::Distribution27 distribution; + + const uint k; + const uint kw; + const uint ks; + const uint kb; + const uint ksw; + const uint kbw; + const uint kbs; + const uint kbsw; +}; + +__device__ unsigned int getNodeIndex(); + +__device__ bool isValidFluidNode(uint nodeType); + +} +} + +#endif diff --git a/src/gpu/VirtualFluids_GPU/Kernel/Utilities/DistributionHelperTests.cpp b/src/gpu/VirtualFluids_GPU/Kernel/Utilities/DistributionHelperTests.cpp new file mode 100644 index 0000000000000000000000000000000000000000..46d3fe890fd2f412251044cce6ade51f08ba0185 --- /dev/null +++ b/src/gpu/VirtualFluids_GPU/Kernel/Utilities/DistributionHelperTests.cpp @@ -0,0 +1,93 @@ +#include <gmock/gmock.h> + +#include "DistributionHelper.cuh" + +#include "LBM/D3Q27.h" + + +auto RealEq = [](auto value) { +#ifdef VF_DOUBLE_ACCURACY + return testing::DoubleEq(value); +#else + return testing::FloatEq(value); +#endif +}; + + +TEST(DistributionHelperTests, getPointerToDistribution_WhenEvenTimeStep_ShouldBeEqualToInput) +{ + real distributions_in[27]; + for (int i = 0; i < 27; i++) + distributions_in[i] = i; + const uint size_Mat = 1; + const bool isEvenTimeStep = true; + + Distributions27 distribution_out = vf::gpu::getDistributionReferences27(distributions_in, size_Mat, isEvenTimeStep); + + EXPECT_THAT(*distribution_out.f[dirE], RealEq(distributions_in[dirE])); + EXPECT_THAT(*distribution_out.f[dirW], RealEq(distributions_in[dirW])); + EXPECT_THAT(*distribution_out.f[dirN], RealEq(distributions_in[dirN])); + EXPECT_THAT(*distribution_out.f[dirS], RealEq(distributions_in[dirS])); + EXPECT_THAT(*distribution_out.f[dirT], RealEq(distributions_in[dirT])); + EXPECT_THAT(*distribution_out.f[dirB], RealEq(distributions_in[dirB])); + EXPECT_THAT(*distribution_out.f[dirNE], RealEq(distributions_in[dirNE])); + EXPECT_THAT(*distribution_out.f[dirSW], RealEq(distributions_in[dirSW])); + EXPECT_THAT(*distribution_out.f[dirSE], RealEq(distributions_in[dirSE])); + EXPECT_THAT(*distribution_out.f[dirNW], RealEq(distributions_in[dirNW])); + EXPECT_THAT(*distribution_out.f[dirTE], RealEq(distributions_in[dirTE])); + EXPECT_THAT(*distribution_out.f[dirBW], RealEq(distributions_in[dirBW])); + EXPECT_THAT(*distribution_out.f[dirBE], RealEq(distributions_in[dirBE])); + EXPECT_THAT(*distribution_out.f[dirTW], RealEq(distributions_in[dirTW])); + EXPECT_THAT(*distribution_out.f[dirTN], RealEq(distributions_in[dirTN])); + EXPECT_THAT(*distribution_out.f[dirBS], RealEq(distributions_in[dirBS])); + EXPECT_THAT(*distribution_out.f[dirBN], RealEq(distributions_in[dirBN])); + EXPECT_THAT(*distribution_out.f[dirTS], RealEq(distributions_in[dirTS])); + EXPECT_THAT(*distribution_out.f[dirREST], RealEq(distributions_in[dirREST])); + EXPECT_THAT(*distribution_out.f[dirTNE], RealEq(distributions_in[dirTNE])); + EXPECT_THAT(*distribution_out.f[dirTSW], RealEq(distributions_in[dirTSW])); + EXPECT_THAT(*distribution_out.f[dirTSE], RealEq(distributions_in[dirTSE])); + EXPECT_THAT(*distribution_out.f[dirTNW], RealEq(distributions_in[dirTNW])); + EXPECT_THAT(*distribution_out.f[dirBNE], RealEq(distributions_in[dirBNE])); + EXPECT_THAT(*distribution_out.f[dirBSW], RealEq(distributions_in[dirBSW])); + EXPECT_THAT(*distribution_out.f[dirBSE], RealEq(distributions_in[dirBSE])); + EXPECT_THAT(*distribution_out.f[dirBNW], RealEq(distributions_in[dirBNW])); +} + +TEST(DistributionHelperTests, getPointerToDistribution_WhenOddTimeStep_ShouldBeSwapped) +{ + real distributions_in[27]; + for (int i = 0; i < 27; i++) + distributions_in[i] = i; + const int size_Mat = 1; + const bool isEvenTimeStep = false; + + Distributions27 distribution_out = vf::gpu::getDistributionReferences27(distributions_in, size_Mat, isEvenTimeStep); + + EXPECT_THAT(*distribution_out.f[dirW], RealEq(distributions_in[dirE])); + EXPECT_THAT(*distribution_out.f[dirE], RealEq(distributions_in[dirW])); + EXPECT_THAT(*distribution_out.f[dirS], RealEq(distributions_in[dirN])); + EXPECT_THAT(*distribution_out.f[dirN], RealEq(distributions_in[dirS])); + EXPECT_THAT(*distribution_out.f[dirB], RealEq(distributions_in[dirT])); + EXPECT_THAT(*distribution_out.f[dirT], RealEq(distributions_in[dirB])); + EXPECT_THAT(*distribution_out.f[dirSW], RealEq(distributions_in[dirNE])); + EXPECT_THAT(*distribution_out.f[dirNE], RealEq(distributions_in[dirSW])); + EXPECT_THAT(*distribution_out.f[dirNW], RealEq(distributions_in[dirSE])); + EXPECT_THAT(*distribution_out.f[dirSE], RealEq(distributions_in[dirNW])); + EXPECT_THAT(*distribution_out.f[dirBW], RealEq(distributions_in[dirTE])); + EXPECT_THAT(*distribution_out.f[dirTE], RealEq(distributions_in[dirBW])); + EXPECT_THAT(*distribution_out.f[dirTW], RealEq(distributions_in[dirBE])); + EXPECT_THAT(*distribution_out.f[dirBE], RealEq(distributions_in[dirTW])); + EXPECT_THAT(*distribution_out.f[dirBS], RealEq(distributions_in[dirTN])); + EXPECT_THAT(*distribution_out.f[dirTN], RealEq(distributions_in[dirBS])); + EXPECT_THAT(*distribution_out.f[dirTS], RealEq(distributions_in[dirBN])); + EXPECT_THAT(*distribution_out.f[dirBN], RealEq(distributions_in[dirTS])); + EXPECT_THAT(*distribution_out.f[dirREST], RealEq(distributions_in[dirREST])); + EXPECT_THAT(*distribution_out.f[dirBSW], RealEq(distributions_in[dirTNE])); + EXPECT_THAT(*distribution_out.f[dirBNE], RealEq(distributions_in[dirTSW])); + EXPECT_THAT(*distribution_out.f[dirBNW], RealEq(distributions_in[dirTSE])); + EXPECT_THAT(*distribution_out.f[dirBSE], RealEq(distributions_in[dirTNW])); + EXPECT_THAT(*distribution_out.f[dirTSW], RealEq(distributions_in[dirBNE])); + EXPECT_THAT(*distribution_out.f[dirTNE], RealEq(distributions_in[dirBSW])); + EXPECT_THAT(*distribution_out.f[dirTNW], RealEq(distributions_in[dirBSE])); + EXPECT_THAT(*distribution_out.f[dirTSE], RealEq(distributions_in[dirBNW])); +} diff --git a/src/gpu/VirtualFluids_GPU/Kernel/Utilities/KernelFactory/KernelFactoryImp.cpp b/src/gpu/VirtualFluids_GPU/Kernel/Utilities/KernelFactory/KernelFactoryImp.cpp index b0d167974275a227b99da6a0ac8e32e1f2976c13..5f63df1c9afc17a62a9a47ce82401ebba4453872 100644 --- a/src/gpu/VirtualFluids_GPU/Kernel/Utilities/KernelFactory/KernelFactoryImp.cpp +++ b/src/gpu/VirtualFluids_GPU/Kernel/Utilities/KernelFactory/KernelFactoryImp.cpp @@ -4,16 +4,19 @@ //LBM kernel (compressible) #include "Kernel/Kernels/BasicKernels/FluidFlow/Compressible/BGK/BGKCompSP27.h" +#include "Kernel/Kernels/BasicKernels/FluidFlow/Compressible/BGKUnified/BGKUnified.h" #include "Kernel/Kernels/BasicKernels/FluidFlow/Compressible/BGKPlus/BGKPlusCompSP27.h" #include "Kernel/Kernels/BasicKernels/FluidFlow/Compressible/Cascade/CascadeCompSP27.h" #include "Kernel/Kernels/BasicKernels/FluidFlow/Compressible/Cumulant/CumulantCompSP27.h" #include "Kernel/Kernels/BasicKernels/FluidFlow/Compressible/CumulantK17/CumulantK17Comp.h" +#include "Kernel/Kernels/BasicKernels/FluidFlow/Compressible/CumulantK17Unified/CumulantK17Unified.h" #include "Kernel/Kernels/BasicKernels/FluidFlow/Compressible/CumulantK17chim/CumulantK17CompChim.h" #include "Kernel/Kernels/BasicKernels/FluidFlow/Compressible/CumulantK17Bulk/CumulantK17BulkComp.h" #include "Kernel/Kernels/BasicKernels/FluidFlow/Compressible/CumulantAll4/CumulantAll4CompSP27.h" #include "Kernel/Kernels/BasicKernels/FluidFlow/Compressible/CumulantK18/CumulantK18Comp.h" #include "Kernel/Kernels/BasicKernels/FluidFlow/Compressible/CumulantK20/CumulantK20Comp.h" #include "Kernel/Kernels/BasicKernels/FluidFlow/Compressible/CumulantK15/CumulantK15Comp.h" +#include "Kernel/Kernels/BasicKernels/FluidFlow/Compressible/CumulantK15Unified/CumulantK15Unified.h" #include "Kernel/Kernels/BasicKernels/FluidFlow/Compressible/CumulantK15Bulk/CumulantK15BulkComp.h" #include "Kernel/Kernels/BasicKernels/FluidFlow/Compressible/CumulantK15Sponge/CumulantK15SpongeComp.h" #include "Kernel/Kernels/BasicKernels/FluidFlow/Compressible/MRT/MRTCompSP27.h" @@ -96,13 +99,17 @@ void KernelFactoryImp::setKernelAtLevel(std::vector<std::shared_ptr<Kernel>> ker std::shared_ptr<Kernel> KernelFactoryImp::makeKernel(std::shared_ptr<Parameter> para, std::string kernel, int level) { + printf("Instantiating Kernel: %s\n", kernel.c_str()); std::shared_ptr<KernelImp> newKernel; std::shared_ptr<CheckParameterStrategy> checkStrategy; - if ( kernel == "BGKCompSP27") { - newKernel = BGKCompSP27::getNewInstance(para, level); // compressible - checkStrategy = FluidFlowCompStrategy::getInstance(); // || - } else if (kernel == "BGKPlusCompSP27") { // \/ + if (kernel == "BGKCompSP27") { + newKernel = BGKCompSP27::getNewInstance(para, level); // compressible + checkStrategy = FluidFlowCompStrategy::getInstance(); // || + } else if (kernel == "BGKUnified") { // \/ + newKernel = std::make_shared<vf::gpu::BGKUnified>(para, level); + checkStrategy = FluidFlowCompStrategy::getInstance(); + } else if (kernel == "BGKPlusCompSP27") { newKernel = BGKPlusCompSP27::getNewInstance(para, level); checkStrategy = FluidFlowCompStrategy::getInstance(); } else if (kernel == "MRTCompSP27") { @@ -117,6 +124,12 @@ std::shared_ptr<Kernel> KernelFactoryImp::makeKernel(std::shared_ptr<Parameter> } else if (kernel == "CumulantK17Comp") { newKernel = CumulantK17Comp::getNewInstance(para, level); checkStrategy = FluidFlowCompStrategy::getInstance(); + } else if (kernel == "CumulantK15Unified") { + newKernel = std::make_shared<vf::gpu::CumulantK15Unified>(para, level); + checkStrategy = FluidFlowCompStrategy::getInstance(); + } else if (kernel == "CumulantK17Unified") { + newKernel = std::make_shared<vf::gpu::CumulantK17Unified>(para, level); + checkStrategy = FluidFlowCompStrategy::getInstance(); } else if (kernel == "CumulantK17BulkComp") { newKernel = CumulantK17BulkComp::getNewInstance(para, level); checkStrategy = FluidFlowCompStrategy::getInstance(); diff --git a/src/gpu/VirtualFluids_GPU/LBM/D3Q27.h b/src/gpu/VirtualFluids_GPU/LBM/D3Q27.h index 546dccd463a96ad3173517d09f222acde11e2448..5e769b603e7c6677b7f9e1189f5c4fe27051f795 100644 --- a/src/gpu/VirtualFluids_GPU/LBM/D3Q27.h +++ b/src/gpu/VirtualFluids_GPU/LBM/D3Q27.h @@ -21,6 +21,7 @@ #define dirBN /*f17*/ 16 #define dirTS /*f18*/ 17 #define dirZERO /*f0 */ 18 +#define dirREST /*f0 */ 18 #define dirTNE /*f */ 19 #define dirBNE /*f */ 20 diff --git a/src/gpu/VirtualFluids_GPU/LBM/LB.h b/src/gpu/VirtualFluids_GPU/LBM/LB.h index f5f91738739b95f897a1192cb7c1d77a6cfea9cb..a33b3b792cd451307825fd0b2c8716e942440582 100644 --- a/src/gpu/VirtualFluids_GPU/LBM/LB.h +++ b/src/gpu/VirtualFluids_GPU/LBM/LB.h @@ -44,31 +44,42 @@ #define INTERFACE_T 4 #define INTERFACE_B 5 -////////////////////////////////////////////////////////////////////////// -// precision (change between double and float) -// + #include "Core/DataTypes.h" -////////////////////////////////////////////////////////////////////////// #include <string> #include <vector> -// Initial condition -typedef struct InitCond{ + +struct InitCondition +{ real Re; - real factorPressBC; - real Diffusivity, Temp, TempBC; - real RealX, RealY; - int numprocs, myid, maxdev; - unsigned int tend, tout, tStartOut, tCalcMedStart, tCalcMedEnd, tDoCheckPoint, tDoRestart; - unsigned int PressInID, PressOutID; - unsigned int PressInZ, PressOutZ; - std::vector<uint> devices; + real factorPressBC {1.0}; + real Diffusivity {0.001}; + real Temp {0.0}; + real TempBC {1.0}; + real RealX {1.0}; + real RealY {1.0}; + int numprocs {1}; + int myid {0}; + int maxdev {1}; + uint tDoCheckPoint {0}; + uint tDoRestart {0}; + uint tCalcMedStart {0}; + uint tCalcMedEnd {10}; + uint tend {10}; + uint tout {1}; + uint tStartOut {0}; + uint PressInID {0}; + uint PressOutID {0}; + uint PressInZ {1}; + uint PressOutZ {2}; + std::vector<uint> devices {1, 0}; // one device with ID = 0 std::vector<int> GridX, GridY, GridZ, DistX, DistY, DistZ; std::vector<real> scaleLBMtoSI, translateLBMtoSI; std::vector<real> minCoordX, minCoordY, minCoordZ, maxCoordX, maxCoordY, maxCoordZ; - std::vector<bool> NeedInterface; - std::string fname, oPath, oPrefix; + std::string fname, oPath; + std::string oPrefix {"MyFile"}; std::string geometryFileC, geometryFileM, geometryFileF; std::string kFull, geoFull, geoVec, coordX, coordY, coordZ, neighborX, neighborY, neighborZ, neighborWSB, scaleCFC, scaleCFF, scaleFCC, scaleFCF, scaleOffsetCF, scaleOffsetFC; std::string noSlipBcPos, noSlipBcQs, noSlipBcValue; @@ -89,16 +100,32 @@ typedef struct InitCond{ std::string cpTop, cpBottom, cpBottom2; std::string concentration, streetVelocity; std::string geomNormalX, geomNormalY, geomNormalZ, inflowNormalX, inflowNormalY, inflowNormalZ, outflowNormalX, outflowNormalY, outflowNormalZ; - unsigned int timeStepForMP; - real clockCycleForMP; - real vis, vis_ratio; - real u0, u0_ratio; - real delta_rho, delta_press; - bool printFiles, readGeo, doRestart, doCheckPoint, isGeo, isProp, isCp, calcMedian, GeometryValues, isConc, is2ndOrderMoments, is3rdOrderMoments, isHighOrderMoments, isWale, isMeasurePoints, isInitNeq; + uint timeStepForMP {10}; + real clockCycleForMP {1.0}; + real vis {0.001}; + real vis_ratio {1.0}; + real u0 {0.01}; + real u0_ratio {1.0}; + real delta_rho {0.0}; + real delta_press {1.0}; + bool printFiles {false}; + bool doRestart {false}; + bool doCheckPoint {false}; + bool readGeo {false}; + bool isGeo, isProp, isCp; + bool GeometryValues {false}; + bool is2ndOrderMoments {false}; + bool is3rdOrderMoments {false}; + bool isHighOrderMoments {false}; + bool calcMedian {false}; + bool isConc {false}; + bool isWale {false}; + bool isMeasurePoints {false}; + bool isInitNeq {false}; bool isGeoNormal, isInflowNormal, isOutflowNormal; - bool simulatePorousMedia; - bool streetVelocityFile; -} InitCondition; + bool simulatePorousMedia {false}; + bool streetVelocityFile {false}; +}; //Interface Cells typedef struct ICellCF{ @@ -144,7 +171,7 @@ typedef struct Distri19{ // Distribution functions f 27 typedef struct Distri27{ real* f[27]; -} Distributions27; +} Distributions27, DistributionReferences27; //Q for second order BCs typedef struct QforBC{ diff --git a/src/gpu/VirtualFluids_GPU/LBM/Simulation.cpp b/src/gpu/VirtualFluids_GPU/LBM/Simulation.cpp index c378276191e57720ea65999da56a9ca83f401a13..737b4edad35eee4829065b89fc1b12eb2c43ef4d 100644 --- a/src/gpu/VirtualFluids_GPU/LBM/Simulation.cpp +++ b/src/gpu/VirtualFluids_GPU/LBM/Simulation.cpp @@ -1,17 +1,17 @@ #include "Simulation.h" + +#include <stdio.h> +#include <vector> + +#include <helper_timer.h> + #include "LBM/LB.h" #include "Communication/Communicator.h" #include "Communication/ExchangeData27.h" #include "Parameter/Parameter.h" #include "GPU/GPU_Interface.h" -#include "GPU/devCheck.h" #include "basics/utilities/UbFileOutputASCII.h" ////////////////////////////////////////////////////////////////////////// -#include "Input/ConfigFile.h" -#include "Input/VtkGeometryReader.h" -#include "Input/kFullReader.h" -#include "Input/PositionReader.h" -////////////////////////////////////////////////////////////////////////// #include "Output/MeasurePointWriter.hpp" #include "Output/AnalysisData.hpp" #include "Output/InterfaceDebugWriter.hpp" @@ -21,8 +21,6 @@ #include "Core/StringUtilities/StringUtil.h" ////////////////////////////////////////////////////////////////////////// #include "Init/InitLattice.h" -#include "Init/DefineGrid.h" -#include "Init/SetParameter.h" #include "Init/VfReader.h" ////////////////////////////////////////////////////////////////////////// #include "FindQ/FindQ.h" @@ -47,8 +45,16 @@ #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) { return std::string(fname + "_Restart_" + UbSystem::toString(myID) + "_" + UbSystem::toString(step)); @@ -78,21 +84,18 @@ void Simulation::init(SPtr<Parameter> para, SPtr<GridProvider> gridProvider, std this->gridProvider = gridProvider; this->cudaManager = cudaManager; gridProvider->initalGridInformations(); - comm = Communicator::getInstanz(); this->para = para; - para->setMyID(comm->getPID()); - para->setNumprocs(comm->getNummberOfProcess()); - 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(); gridProvider->allocAndCopyForcing(); gridProvider->allocAndCopyQuadricLimiters(); gridProvider->setDimensions(); gridProvider->setBoundingBox(); - para->initParameter(); para->setRe(para->getVelocity() * (real)1.0 / para->getViscosity()); - para->setPhi((real) 0.0); para->setlimitOfNodesForVTK(30000000); //max 30 Million nodes per VTK file if (para->getDoRestart()) para->setStartTurn(para->getTimeDoRestart()); @@ -133,6 +136,13 @@ void Simulation::init(SPtr<Parameter> para, SPtr<GridProvider> gridProvider, std gridProvider->allocArrays_BoundaryQs(); gridProvider->allocArrays_OffsetScale(); + 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 @@ -251,7 +261,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"; @@ -414,7 +424,7 @@ void Simulation::run() //////////////////////////////////////////////////////////////////////////////// for(t=para->getTStart();t<=para->getTEnd();t++) { - updateGrid27(para.get(), comm, cudaManager.get(), pm, 0, t, kernels); + updateGrid27(para.get(), communicator, cudaManager.get(), pm, 0, t, kernels); //////////////////////////////////////////////////////////////////////////////// //Particles @@ -429,7 +439,7 @@ void Simulation::run() // run Analyzers for kinetic energy and enstrophy for TGV in 3D // these analyzers only work on level 0 //////////////////////////////////////////////////////////////////////////////// - if( this->kineticEnergyAnalyzer || this->enstrophyAnalyzer ) exchangeMultiGPU(para.get(), comm, cudaManager.get(), 0); + if( this->kineticEnergyAnalyzer || this->enstrophyAnalyzer ) exchangeMultiGPU(para.get(), communicator, cudaManager.get(), 0); if( this->kineticEnergyAnalyzer ) this->kineticEnergyAnalyzer->run(t); if( this->enstrophyAnalyzer ) this->enstrophyAnalyzer->run(t); @@ -559,7 +569,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; } @@ -623,7 +633,7 @@ void Simulation::run() //////////////////////////////////////////////////////////////////////////////// // File IO //////////////////////////////////////////////////////////////////////////////// - //comm->startTimer(); + //communicator->startTimer(); if(para->getTOut()>0 && t%para->getTOut()==0 && t>para->getTStartOut()) { ////////////////////////////////////////////////////////////////////////////////// @@ -669,7 +679,7 @@ void Simulation::run() { ////////////////////////////////////////////////////////////////////////// //exchange data for valid post process - exchangeMultiGPU(para.get(), comm, cudaManager.get(), lev); + exchangeMultiGPU(para.get(), communicator, cudaManager.get(), lev); ////////////////////////////////////////////////////////////////////////// //if (para->getD3Qxx()==19) //{ @@ -1283,7 +1293,13 @@ void Simulation::free() } } ////////////////////////////////////////////////////////////////////////// + //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 7a91331a76e565f9240e3a51ae45a88c753e9ee1..72c86140258b01aec3b3ed00d59c271f1824d514 100644 --- a/src/gpu/VirtualFluids_GPU/LBM/Simulation.h +++ b/src/gpu/VirtualFluids_GPU/LBM/Simulation.h @@ -5,16 +5,16 @@ #include <vector> #include <PointerDefinitions.h> - - #include "Output/LogWriter.hpp" #include "GPU/KineticEnergyAnalyzer.h" #include "GPU/EnstrophyAnalyzer.h" #include "Utilities/Buffer2D.hpp" #include "LBM/LB.h" + #include "VirtualFluids_GPU_export.h" -class Communicator; +namespace vf::gpu { class Communicator; } + class CudaMemoryManager; class Parameter; class GridProvider; @@ -32,6 +32,7 @@ class TrafficMovementFactory; 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); void free(); @@ -61,7 +62,7 @@ protected: LogWriter output; - Communicator* comm; + vf::gpu::Communicator& communicator; SPtr<Parameter> para; SPtr<GridProvider> gridProvider; SPtr<DataWriter> dataWriter; diff --git a/src/gpu/VirtualFluids_GPU/Parameter/Parameter.cpp b/src/gpu/VirtualFluids_GPU/Parameter/Parameter.cpp index 89a50c7272d42516fe23824f7686284773a6fbe0..2aa00708e5a440f99fe341374dd668a5e764bbdb 100644 --- a/src/gpu/VirtualFluids_GPU/Parameter/Parameter.cpp +++ b/src/gpu/VirtualFluids_GPU/Parameter/Parameter.cpp @@ -1,3369 +1,562 @@ -// _ ___ __ __________ _ __ ______________ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ / ___/ __ / / / / -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ / /___/ /_/ / / / / -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) / /_) / ____/ /__/ / -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ \____/_/ \_____/ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ // -////////////////////////////////////////////////////////////////////////// -#include "Parameter.h" - -//#include <cuda_runtime.h> -//#include <helper_cuda.h> -// -#include <stdio.h> -#include <stdlib.h> -#include <math.h> - - -#include "Core/Input/ConfigData/ConfigData.h" -#include "Core/StringUtilities/StringUtil.h" -#include "Communication/Communicator.h" -//#ifdef WIN32 -// #include <Winsock2.h> -//#endif -//lib for windows Ws2_32.lib - - -SPtr<Parameter> Parameter::make() -{ - return SPtr<Parameter>(new Parameter()); -} - -SPtr<Parameter> Parameter::make(SPtr<ConfigData> configData, Communicator* comm) -{ - return SPtr<Parameter>(new Parameter(configData, comm)); -} - -Parameter::Parameter() -{ -} -Parameter::Parameter(SPtr<ConfigData> configData, Communicator* comm) -{ - ////////////////////////////////////////////////////////////////////////// - this->setNumprocs(comm->getNummberOfProcess()); - this->setMyID(comm->getPID()); - ////////////////////////////////////////////////////////////////////////// - if (configData->isNumberOfDevicesInConfigFile()) - this->setMaxDev(configData->getNumberOfDevices()); - else - this->setMaxDev((int)1); - ////////////////////////////////////////////////////////////////////////// - if (configData->isDevicesInConfigFile()) - this->setDevices(configData->getDevices()); - else - this->setDevices(std::vector<uint>{(uint)0}); - ////////////////////////////////////////////////////////////////////////// - if (configData->isOutputPathInConfigFile()) - this->setOutputPath(configData->getOutputPath()); - else - this->setOutputPath("C:/Output/"); - ////////////////////////////////////////////////////////////////////////// - if (configData->isPrefixInConfigFile()) - this->setOutputPrefix(configData->getPrefix()); - else - this->setOutputPrefix("MyFile"); - ////////////////////////////////////////////////////////////////////////// - if (configData->isPrintOutputFilesInConfigFile()) - this->setPrintFiles(configData->getPrintOutputFiles()); - else - this->setPrintFiles(false); - ////////////////////////////////////////////////////////////////////////// - if (configData->isGeometryValuesInConfigFile()) - this->setGeometryValues(configData->getGeometryValues()); - else - this->setGeometryValues(false); - ////////////////////////////////////////////////////////////////////////// - if (configData->isCalc2ndOrderMomentsInConfigFile()) - this->setCalc2ndOrderMoments(configData->getCalc2ndOrderMoments()); - else - this->setCalc2ndOrderMoments(false); - ////////////////////////////////////////////////////////////////////////// - if (configData->isCalc3rdOrderMomentsInConfigFile()) - this->setCalc3rdOrderMoments(configData->getCalc3rdOrderMoments()); - else - this->setCalc3rdOrderMoments(false); - ////////////////////////////////////////////////////////////////////////// - if (configData->isCalcHighOrderMomentsInConfigFile()) - this->setCalcHighOrderMoments(configData->getCalcHighOrderMoments()); - else - this->setCalcHighOrderMoments(false); - ////////////////////////////////////////////////////////////////////////// - if (configData->isCalcMedianInConfigFile()) - this->setCalcMedian(configData->getCalcMedian()); - else - this->setCalcMedian(false); - ////////////////////////////////////////////////////////////////////////// - if (configData->isCalcDragLiftInConfigFile()) - this->setCalcDragLift(configData->getCalcDragLift()); - else - this->setCalcDragLift(false); - ////////////////////////////////////////////////////////////////////////// - if (configData->isCalcCpInConfigFile()) - this->setCalcCp(configData->getCalcCp()); - else - this->setCalcCp(false); - ////////////////////////////////////////////////////////////////////////// - if (configData->isWriteVeloASCIIfilesInConfigFile()) - this->setWriteVeloASCIIfiles(configData->getWriteVeloASCIIfiles()); - else - this->setWriteVeloASCIIfiles(false); - ////////////////////////////////////////////////////////////////////////// - if (configData->isCalcPlaneConcInConfigFile()) - this->setCalcPlaneConc(configData->getCalcPlaneConc()); - else - this->setCalcPlaneConc(false); - ////////////////////////////////////////////////////////////////////////// - if (configData->isConcFileInConfigFile()) - this->setConcFile(configData->getConcFile()); - else - this->setConcFile(false); - ////////////////////////////////////////////////////////////////////////// - if (configData->isStreetVelocityFileInConfigFile()) - this->setStreetVelocityFile(configData->getStreetVelocityFile()); - else - this->setStreetVelocityFile(false); - ////////////////////////////////////////////////////////////////////////// - if (configData->isUseMeasurePointsInConfigFile()) - this->setUseMeasurePoints(configData->getUseMeasurePoints()); - else - this->setUseMeasurePoints(false); - ////////////////////////////////////////////////////////////////////////// - if (configData->isUseWaleInConfigFile()) - this->setUseWale(configData->getUseWale()); - else - this->setUseWale(false); - ////////////////////////////////////////////////////////////////////////// - if (configData->isUseInitNeqInConfigFile()) - this->setUseInitNeq(configData->getUseInitNeq()); - else - this->setUseInitNeq(false); - ////////////////////////////////////////////////////////////////////////// - if (configData->isSimulatePorousMediaInConfigFile()) - this->setSimulatePorousMedia(configData->getSimulatePorousMedia()); - else - this->setSimulatePorousMedia(false); - ////////////////////////////////////////////////////////////////////////// - if (configData->isD3QxxInConfigFile()) - this->setD3Qxx(configData->getD3Qxx()); - else - this->setD3Qxx((int)27); - ////////////////////////////////////////////////////////////////////////// - if (configData->isTEndInConfigFile()) - this->setTEnd(configData->getTEnd()); - else - this->setTEnd((uint)10); - ////////////////////////////////////////////////////////////////////////// - if (configData->isTOutInConfigFile()) - this->setTOut(configData->getTOut()); - else - this->setTOut((uint)1); - ////////////////////////////////////////////////////////////////////////// - if (configData->isTStartOutInConfigFile()) - this->setTStartOut(configData->getTStartOut()); - else - this->setTStartOut((uint)0); - ////////////////////////////////////////////////////////////////////////// - if (configData->isTimeCalcMedStartInConfigFile()) - this->setTimeCalcMedStart(configData->getTimeCalcMedStart()); - else - this->setTimeCalcMedStart((int)0); - ////////////////////////////////////////////////////////////////////////// - if (configData->isTimeCalcMedEndInConfigFile()) - this->setTimeCalcMedEnd(configData->getTimeCalcMedEnd()); - else - this->setTimeCalcMedEnd((int)10); - ////////////////////////////////////////////////////////////////////////// - if (configData->isPressInIDInConfigFile()) - this->setPressInID(configData->getPressInID()); - else - this->setPressInID((uint)0); - ////////////////////////////////////////////////////////////////////////// - if (configData->isPressOutIDInConfigFile()) - this->setPressOutID(configData->getPressOutID()); - else - this->setPressOutID((uint)0); - ////////////////////////////////////////////////////////////////////////// - if (configData->isPressInZInConfigFile()) - this->setPressInZ(configData->getPressInZ()); - else - this->setPressInZ((uint)1); - ////////////////////////////////////////////////////////////////////////// - if (configData->isPressOutZInConfigFile()) - this->setPressOutZ(configData->getPressOutZ()); - else - this->setPressOutZ((uint)2); - ////////////////////////////////////////////////////////////////////////// - //second component - if (configData->isDiffOnInConfigFile()) - this->setDiffOn(configData->getDiffOn()); - else - this->setDiffOn(false); - - if (configData->isDiffModInConfigFile()) - this->setDiffMod(configData->getDiffMod()); - else - this->setDiffMod((int)27); - - if (configData->isDiffusivityInConfigFile()) - this->setDiffusivity(configData->getDiffusivity()); - else - this->setDiffusivity((real)0.001); - - if (configData->isTemperatureInitInConfigFile()) - this->setTemperatureInit(configData->getTemperatureInit()); - else - this->setTemperatureInit((real)0.0); - - if (configData->isTemperatureBCInConfigFile()) - this->setTemperatureBC(configData->getTemperatureBC()); - else - this->setTemperatureBC((real)1.0); - ////////////////////////////////////////////////////////////////////////// - if (configData->isViscosityInConfigFile()) - this->setViscosity(configData->getViscosity()); - else - this->setViscosity((real)0.001); - ////////////////////////////////////////////////////////////////////////// - if (configData->isVelocityInConfigFile()) - this->setVelocity(configData->getVelocity()); - else - this->setVelocity((real)0.01); - ////////////////////////////////////////////////////////////////////////// - if (configData->isViscosityRatioInConfigFile()) - this->setViscosityRatio(configData->getViscosityRatio()); - else - this->setViscosityRatio((real)1.0); - ////////////////////////////////////////////////////////////////////////// - if (configData->isVelocityRatioInConfigFile()) - this->setVelocityRatio(configData->getVelocityRatio()); - else - this->setVelocityRatio((real)1.0); - ////////////////////////////////////////////////////////////////////////// - if (configData->isDensityRatioInConfigFile()) - this->setDensityRatio(configData->getDensityRatio()); - else - this->setDensityRatio((real)1.0); - ////////////////////////////////////////////////////////////////////////// - if (configData->isPressRatioInConfigFile()) - this->setPressRatio(configData->getPressRatio()); - else - this->setPressRatio((real)1.0); - ////////////////////////////////////////////////////////////////////////// - if (configData->isRealXInConfigFile()) - this->setRealX(configData->getRealX()); - else - this->setRealX((real)1.0); - ////////////////////////////////////////////////////////////////////////// - if (configData->isRealYInConfigFile()) - this->setRealY(configData->getRealY()); - else - this->setRealY((real)1.0); - ////////////////////////////////////////////////////////////////////////// - if (configData->isFactorPressBCInConfigFile()) - this->setFactorPressBC(configData->getFactorPressBC()); - else - this->setFactorPressBC((real)1.0); - ////////////////////////////////////////////////////////////////////////// - //read Geometry (STL) - if (configData->isReadGeoInConfigFile()) - this->setReadGeo(configData->getReadGeo()); - else - this->setReadGeo(false); - - if (configData->isGeometryFileCInConfigFile()) - this->setGeometryFileC(configData->getGeometryFileC()); - else if (this->getReadGeo()) - { - std::cout << "GeometryFileC has to be defined!" << std::endl; - exit(1); - } - else - this->setGeometryFileC(""); - - if (configData->isGeometryFileMInConfigFile()) - this->setGeometryFileM(configData->getGeometryFileM()); - else if (this->getReadGeo()) - { - std::cout << "GeometryFileM has to be defined!" << std::endl; - exit(1); - } - else - this->setGeometryFileM(""); - - if (configData->isGeometryFileFInConfigFile()) - this->setGeometryFileF(configData->getGeometryFileF()); - else if (this->getReadGeo()) - { - std::cout << "GeometryFileF has to be defined!" << std::endl; - exit(1); - } - else - this->setGeometryFileF(""); - ////////////////////////////////////////////////////////////////////////// - if (configData->isClockCycleForMPInConfigFile()) - this->setclockCycleForMP(configData->getClockCycleForMP()); - else - this->setclockCycleForMP((real)1.0); - - if (configData->isTimestepForMPInConfigFile()) - this->settimestepForMP(configData->getTimestepForMP()); - else - this->settimestepForMP((uint)10); - ////////////////////////////////////////////////////////////////////////// - std::string gridPath = ""; - if (configData->isGridPathInConfigFile()) - gridPath = configData->getGridPath(); - else - { - std::cout << "GridPath has to be defined!" << std::endl; - exit(1); - } - - if (this->getNumprocs() == 1) - gridPath += "/"; - else - gridPath += "/" + StringUtil::toString(this->getMyID()) + "/"; - ////////////////////////////////////////////////////////////////////////// - this->setFName(this->getOutputPath() + "/" + this->getOutputPrefix()); - ////////////////////////////////////////////////////////////////////////// - this->setgeoVec( gridPath + "geoVec.dat"); - this->setcoordX( gridPath + "coordX.dat"); - this->setcoordY( gridPath + "coordY.dat"); - this->setcoordZ( gridPath + "coordZ.dat"); - this->setneighborX( gridPath + "neighborX.dat"); - this->setneighborY( gridPath + "neighborY.dat"); - this->setneighborZ( gridPath + "neighborZ.dat"); - this->setneighborWSB( gridPath + "neighborWSB.dat"); - this->setscaleCFC( gridPath + "scaleCFC.dat"); - this->setscaleCFF( gridPath + "scaleCFF.dat"); - this->setscaleFCC( gridPath + "scaleFCC.dat"); - this->setscaleFCF( gridPath + "scaleFCF.dat"); - this->setscaleOffsetCF( gridPath + "offsetVecCF.dat"); - this->setscaleOffsetFC( gridPath + "offsetVecFC.dat"); - this->setgeomBoundaryBcQs( gridPath + "geomBoundaryQs.dat"); - this->setgeomBoundaryBcValues( gridPath + "geomBoundaryValues.dat"); - this->setinletBcQs( gridPath + "inletBoundaryQs.dat"); - this->setinletBcValues( gridPath + "inletBoundaryValues.dat"); - this->setoutletBcQs( gridPath + "outletBoundaryQs.dat"); - this->setoutletBcValues( gridPath + "outletBoundaryValues.dat"); - this->settopBcQs( gridPath + "topBoundaryQs.dat"); - this->settopBcValues( gridPath + "topBoundaryValues.dat"); - this->setbottomBcQs( gridPath + "bottomBoundaryQs.dat"); - this->setbottomBcValues( gridPath + "bottomBoundaryValues.dat"); - this->setfrontBcQs( gridPath + "frontBoundaryQs.dat"); - this->setfrontBcValues( gridPath + "frontBoundaryValues.dat"); - this->setbackBcQs( gridPath + "backBoundaryQs.dat"); - this->setbackBcValues( gridPath + "backBoundaryValues.dat"); - this->setnumberNodes( gridPath + "numberNodes.dat"); - this->setLBMvsSI( gridPath + "LBMvsSI.dat"); - this->setmeasurePoints( gridPath + "measurePoints.dat"); - this->setpropellerValues( gridPath + "propellerValues.dat"); - this->setcpTop( gridPath + "cpTop.dat"); - this->setcpBottom( gridPath + "cpBottom.dat"); - this->setcpBottom2( gridPath + "cpBottom2.dat"); - this->setConcentration( gridPath + "conc.dat"); - this->setStreetVelocity( gridPath + "streetVector.dat"); - ////////////////////////////////////////////////////////////////////////// - //Normals - Geometry - this->setgeomBoundaryNormalX(gridPath + "geomBoundaryNormalX.dat"); - this->setgeomBoundaryNormalY(gridPath + "geomBoundaryNormalY.dat"); - this->setgeomBoundaryNormalZ(gridPath + "geomBoundaryNormalZ.dat"); - //Normals - Inlet - this->setInflowBoundaryNormalX(gridPath + "inletBoundaryNormalX.dat"); - this->setInflowBoundaryNormalY(gridPath + "inletBoundaryNormalY.dat"); - this->setInflowBoundaryNormalZ(gridPath + "inletBoundaryNormalZ.dat"); - //Normals - Outlet - this->setOutflowBoundaryNormalX(gridPath + "outletBoundaryNormalX.dat"); - this->setOutflowBoundaryNormalY(gridPath + "outletBoundaryNormalY.dat"); - this->setOutflowBoundaryNormalZ(gridPath + "outletBoundaryNormalZ.dat"); - ////////////////////////////////////////////////////////////////////////// - //Forcing - real forcingX = 0.0; - real forcingY = 0.0; - real forcingZ = 0.0; - - if (configData->isForcingXInConfigFile()) - forcingX = configData->getForcingX(); - if (configData->isForcingYInConfigFile()) - forcingY = configData->getForcingY(); - if (configData->isForcingZInConfigFile()) - forcingZ = configData->getForcingZ(); - - this->setForcing(forcingX, forcingY, forcingZ); - ////////////////////////////////////////////////////////////////////////// - //quadricLimiters - real quadricLimiterP = (real)0.01; - real quadricLimiterM = (real)0.01; - real quadricLimiterD = (real)0.01; - - if (configData->isQuadricLimiterPInConfigFile()) - quadricLimiterP = configData->getQuadricLimiterP(); - if (configData->isQuadricLimiterMInConfigFile()) - quadricLimiterM = configData->getQuadricLimiterM(); - if (configData->isQuadricLimiterDInConfigFile()) - quadricLimiterD = configData->getQuadricLimiterD(); - - this->setQuadricLimiters(quadricLimiterP, quadricLimiterM, quadricLimiterD); - ////////////////////////////////////////////////////////////////////////// - //Particles - if (configData->isCalcParticlesInConfigFile()) - this->setCalcParticles(configData->getCalcParticles()); - else - this->setCalcParticles(false); - - if (configData->isParticleBasicLevelInConfigFile()) - this->setParticleBasicLevel(configData->getParticleBasicLevel()); - else - this->setParticleBasicLevel((int)0); - - if (configData->isParticleInitLevelInConfigFile()) - this->setParticleInitLevel(configData->getParticleInitLevel()); - else - this->setParticleInitLevel((int)0); - - if (configData->isNumberOfParticlesInConfigFile()) - this->setNumberOfParticles(configData->getNumberOfParticles()); - else - this->setNumberOfParticles((int)0); - - if (configData->isStartXHotWallInConfigFile()) - this->setStartXHotWall(configData->getStartXHotWall()); - else - this->setStartXHotWall((real)0); - - if (configData->isEndXHotWallInConfigFile()) - this->setEndXHotWall(configData->getEndXHotWall()); - else - this->setEndXHotWall((real)0); - ////////////////////////////////////////////////////////////////////////// - //for Multi GPU - if (this->getNumprocs() > 1) - { - ////////////////////////////////////////////////////////////////////////// - //3D domain decomposition - std::vector<std::string> sendProcNeighborsX, sendProcNeighborsY, sendProcNeighborsZ; - std::vector<std::string> recvProcNeighborsX, recvProcNeighborsY, recvProcNeighborsZ; - for (int i = 0; i < this->getNumprocs(); i++) - { - sendProcNeighborsX.push_back(gridPath + StringUtil::toString(i) + "Xs.dat"); - sendProcNeighborsY.push_back(gridPath + StringUtil::toString(i) + "Ys.dat"); - sendProcNeighborsZ.push_back(gridPath + StringUtil::toString(i) + "Zs.dat"); - recvProcNeighborsX.push_back(gridPath + StringUtil::toString(i) + "Xr.dat"); - recvProcNeighborsY.push_back(gridPath + StringUtil::toString(i) + "Yr.dat"); - recvProcNeighborsZ.push_back(gridPath + StringUtil::toString(i) + "Zr.dat"); - } - this->setPossNeighborFilesX(sendProcNeighborsX, "send"); - this->setPossNeighborFilesY(sendProcNeighborsY, "send"); - this->setPossNeighborFilesZ(sendProcNeighborsZ, "send"); - this->setPossNeighborFilesX(recvProcNeighborsX, "recv"); - this->setPossNeighborFilesY(recvProcNeighborsY, "recv"); - this->setPossNeighborFilesZ(recvProcNeighborsZ, "recv"); - } - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //Restart - if (configData->isTimeDoCheckPointInConfigFile()) - this->setTimeDoCheckPoint(configData->getTimeDoCheckPoint()); - else - this->setTimeDoCheckPoint((uint)0); - - if (configData->isTimeDoRestartInConfigFile()) - this->setTimeDoRestart(configData->getTimeDoRestart()); - else - this->setTimeDoRestart((uint)0); - - if (configData->isDoCheckPointInConfigFile()) - this->setDoCheckPoint(configData->getDoCheckPoint()); - else - this->setDoCheckPoint(false); - - if (configData->isDoRestartInConfigFile()) - this->setDoRestart(configData->getDoRestart()); - else - this->setDoRestart(false); - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - if (configData->isMaxLevelInConfigFile()) - this->setMaxLevel(configData->getMaxLevel()); - else - this->setMaxLevel((int)1); - - if (configData->isGridXInConfigFile()) - this->setGridX(configData->getGridX()); - else - this->setGridX(std::vector<int>(this->getMaxLevel()+1, 32)); - - if (configData->isGridYInConfigFile()) - this->setGridY(configData->getGridY()); - else - this->setGridY(std::vector<int>(this->getMaxLevel()+1, 32)); - - if (configData->isGridZInConfigFile()) - this->setGridZ(configData->getGridZ()); - else - this->setGridZ(std::vector<int>(this->getMaxLevel()+1, 32)); - - if (configData->isDistXInConfigFile()) - this->setDistX(configData->getDistX()); - else - this->setDistX(std::vector<int>(this->getMaxLevel()+1, 32)); - - if (configData->isDistYInConfigFile()) - this->setDistY(configData->getDistY()); - else - this->setDistY(std::vector<int>(this->getMaxLevel()+1, 32)); - - if (configData->isDistZInConfigFile()) - this->setDistZ(configData->getDistZ()); - else - this->setDistZ(std::vector<int>(this->getMaxLevel()+1, 32)); - - if (configData->isNeedInterfaceInConfigFile()) - this->setNeedInterface(configData->getNeedInterface()); - else - this->setNeedInterface(std::vector<bool>(6, true)); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - // Kernel - if (configData->isMainKernelInConfigFile()) - this->setMainKernel(configData->getMainKernel()); - else - this->setMainKernel("CumulantK15Comp"); - - if (configData->isMultiKernelOnInConfigFile()) - this->setMultiKernelOn(configData->getMultiKernelOn()); - else - this->setMultiKernelOn(false); - - if (configData->isMultiKernelLevelInConfigFile()) - this->setMultiKernelLevel(configData->getMultiKernelLevel()); - else if (this->getMultiKernelOn()) - { - std::vector<int> tmp; - for (int i = 0; i < this->getMaxLevel()+1; i++) - { - tmp.push_back(i); - } - this->setMultiKernelLevel(tmp); - } - else - this->setMultiKernelLevel(std::vector<int>(0)); - - if (configData->isMultiKernelNameInConfigFile()) { - std::vector<std::string> kernels; - for (std::size_t i = 0; i < configData->getMultiKernelName().size(); i++) { - kernels.push_back(configData->getMultiKernelName().at(i)); - } - this->setMultiKernel(kernels); - } - else if (this->getMultiKernelOn()) - { - std::vector<std::string> tmp; - for (int i = 0; i < this->getMaxLevel()+1; i++) - { - tmp.push_back("CumulantK15Comp"); - } - this->setMultiKernel(tmp); - } - else { - std::vector<std::string> tmp; - this->setMultiKernel(tmp); - } - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -} -Parameter::~Parameter() -{ -} -Parameter* Parameter::instanz = 0; -Parameter* Parameter::getInstanz() -{ - if( instanz == 0 ) - instanz = new Parameter(); - return instanz; -} -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -//init-method -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -void Parameter::initParameter() -{ - factor_gridNZ = 2; - coarse = 0; - fine = this->maxlevel; - parH.resize(this->maxlevel+1); - parD.resize(this->maxlevel+1); - - //host - for (int i = coarse; i <= fine; i++) - { - parH[i] = new ParameterStruct; - parH[i]->numberofthreads = 64;// 128; - parH[i]->gridNX = getGridX().at(i); - parH[i]->gridNY = getGridY().at(i); - parH[i]->gridNZ = getGridZ().at(i); - parH[i]->vis = ic.vis*pow(2.f,i); - parH[i]->diffusivity = ic.Diffusivity*pow(2.f,i); - parH[i]->omega = 1.0f/(3.0f*parH[i]->vis+0.5f);//omega :-) not s9 = -1.0f/(3.0f*parH[i]->vis+0.5f);// - parH[i]->nx = parH[i]->gridNX + 2 * STARTOFFX; - parH[i]->ny = parH[i]->gridNY + 2 * STARTOFFY; - parH[i]->nz = parH[i]->gridNZ + 2 * STARTOFFZ; - parH[i]->size_Mat = parH[i]->nx * parH[i]->ny * parH[i]->nz; - parH[i]->sizePlaneXY = parH[i]->nx * parH[i]->ny; - parH[i]->sizePlaneYZ = parH[i]->ny * parH[i]->nz; - parH[i]->sizePlaneXZ = parH[i]->nx * parH[i]->nz; - parH[i]->mem_size_real = sizeof(real ) * parH[i]->size_Mat; - parH[i]->mem_size_int = sizeof(unsigned int) * parH[i]->size_Mat; - parH[i]->mem_size_bool = sizeof(bool ) * parH[i]->size_Mat; - parH[i]->mem_size_real_yz = sizeof(real ) * parH[i]->ny * parH[i]->nz; - parH[i]->evenOrOdd = true; - parH[i]->startz = parH[i]->gridNZ * ic.myid; - parH[i]->endz = parH[i]->gridNZ * ic.myid + parH[i]->gridNZ; - parH[i]->Lx = (real)((1.f*parH[i]->gridNX - 1.f)/(pow(2.f,i))); - parH[i]->Ly = (real)((1.f*parH[i]->gridNY - 1.f)/(pow(2.f,i))); - parH[i]->Lz = (real)((1.f*parH[i]->gridNZ - 1.f)/(pow(2.f,i))); - parH[i]->dx = (real)(1.f/(pow(2.f,i))); - parH[i]->XdistKn = getDistX().at(i); - parH[i]->YdistKn = getDistY().at(i); - parH[i]->ZdistKn = getDistZ().at(i); - if (i==coarse) - { - parH[i]->distX = (real)getDistX().at(i); - parH[i]->distY = (real)getDistY().at(i); - parH[i]->distZ = (real)getDistZ().at(i); - parH[i]->mTtoWx = (real)1.0f; - parH[i]->mTtoWy = (real)1.0f; - parH[i]->mTtoWz = (real)1.0f; - parH[i]->cTtoWx = (real)0.0f; - parH[i]->cTtoWy = (real)0.0f; - parH[i]->cTtoWz = (real)0.0f; - ////MGs Trafo/////////////////////////////////////////////////////////////// - //parH[i]->cStartx = (real)parH[i]->XdistKn; - //parH[i]->cStarty = (real)parH[i]->XdistKn; - //parH[i]->cStartz = (real)parH[i]->XdistKn; - //////////////////////////////////////////////////////////////////////////// - } - else - { - //Geller - parH[i]->distX = ((real)getDistX().at(i) + 0.25f) * parH[i-1]->dx; - parH[i]->distY = ((real)getDistY().at(i) + 0.25f) * parH[i-1]->dx; - parH[i]->distZ = ((real)getDistZ().at(i) + 0.25f) * parH[i-1]->dx; - //parH[i]->distX = ((real)getDistX().at(i) + 0.25f) * parH[i-1]->dx + parH[i-1]->distX; - //parH[i]->distY = ((real)getDistY().at(i) + 0.25f) * parH[i-1]->dx + parH[i-1]->distY; - //parH[i]->distZ = ((real)getDistZ().at(i) + 0.25f) * parH[i-1]->dx + parH[i-1]->distZ; - parH[i]->mTtoWx = (real)pow(0.5f,i); - parH[i]->mTtoWy = (real)pow(0.5f,i); - parH[i]->mTtoWz = (real)pow(0.5f,i); - parH[i]->cTtoWx = (real)(STARTOFFX/2.f + (parH[i]->gridNX+1.f)/4.f); //funzt nur fuer zwei level - parH[i]->cTtoWy = (real)(STARTOFFY/2.f + (parH[i]->gridNY+1.f)/4.f); //funzt nur fuer zwei level - parH[i]->cTtoWz = (real)(STARTOFFZ/2.f + (parH[i]->gridNZ+1.f)/4.f); //funzt nur fuer zwei level - ////MGs Trafo/////////////////////////////////////////////////////////////// - //parH[i]->cStartx = (real)parH[i]->XdistKn; - //parH[i]->cStarty = (real)parH[i]->XdistKn; - //parH[i]->cStartz = (real)parH[i]->XdistKn; - //////////////////////////////////////////////////////////////////////////// - } - parH[i]->need_interface[INTERFACE_E]=getNeedInterface().at(INTERFACE_E); - parH[i]->need_interface[INTERFACE_W]=getNeedInterface().at(INTERFACE_W); - parH[i]->need_interface[INTERFACE_N]=getNeedInterface().at(INTERFACE_N); - parH[i]->need_interface[INTERFACE_S]=getNeedInterface().at(INTERFACE_S); - parH[i]->need_interface[INTERFACE_T]=getNeedInterface().at(INTERFACE_T); - parH[i]->need_interface[INTERFACE_B]=getNeedInterface().at(INTERFACE_B); - } - - //device - for (int i = coarse; i <= fine; i++) - { - parD[i] = new ParameterStruct; - parD[i]->numberofthreads = parH[i]->numberofthreads; - parD[i]->gridNX = parH[i]->gridNX; - parD[i]->gridNY = parH[i]->gridNY; - parD[i]->gridNZ = parH[i]->gridNZ; - parD[i]->vis = parH[i]->vis; - parD[i]->diffusivity = parH[i]->diffusivity; - parD[i]->omega = parH[i]->omega; - parD[i]->nx = parH[i]->nx; - parD[i]->ny = parH[i]->ny; - parD[i]->nz = parH[i]->nz; - parD[i]->size_Mat = parH[i]->size_Mat; - parD[i]->sizePlaneXY = parH[i]->sizePlaneXY; - parD[i]->sizePlaneYZ = parH[i]->sizePlaneYZ; - parD[i]->sizePlaneXZ = parH[i]->sizePlaneXZ; - parD[i]->mem_size_real = sizeof(real ) * parD[i]->size_Mat; - parD[i]->mem_size_int = sizeof(unsigned int) * parD[i]->size_Mat; - parD[i]->mem_size_bool = sizeof(bool ) * parD[i]->size_Mat; - parD[i]->mem_size_real_yz = sizeof(real ) * parD[i]->ny * parD[i]->nz; - parD[i]->evenOrOdd = parH[i]->evenOrOdd; - parD[i]->startz = parH[i]->startz; - parD[i]->endz = parH[i]->endz; - parD[i]->Lx = parH[i]->Lx; - parD[i]->Ly = parH[i]->Ly; - parD[i]->Lz = parH[i]->Lz; - parD[i]->dx = parH[i]->dx; - parD[i]->XdistKn = parH[i]->XdistKn; - parD[i]->YdistKn = parH[i]->YdistKn; - parD[i]->ZdistKn = parH[i]->ZdistKn; - parD[i]->distX = parH[i]->distX; - parD[i]->distY = parH[i]->distY; - parD[i]->distZ = parH[i]->distZ; - } - - //Interface - //comment out for geller - //for (int i = coarse; i < fine; i++) - //{ - // initInterfaceParameter(i); - //} -} -void Parameter::setSizeMatSparse(int level) -{ - parH[level]->size_Mat_SP = 1; - parD[level]->size_Mat_SP = 1; - parH[level]->sizePlaneSB = 0; - parH[level]->sizePlaneST = 0; - parH[level]->sizePlaneRB = 0; - parH[level]->sizePlaneRT = 0; - parH[level]->isSetSendB = false; - parH[level]->isSetSendT = false; - parH[level]->isSetRecvB = false; - parH[level]->isSetRecvT = false; - unsigned int mm[8]; - - for (unsigned int k=1; k<parH[level]->gridNZ + 2 * STARTOFFZ - 1; k++) - { - for (unsigned int j=1; j<parH[level]->gridNY + 2 * STARTOFFY - 1; j++) - { - for (unsigned int i=1; i<parH[level]->gridNX + 2 * STARTOFFX - 1; i++) - { - mm[0]= parH[level]->nx*(parH[level]->ny*k + j) + i; - mm[1]= mm[0] -1; //W - mm[2]= mm[0] -parH[level]->nx-1; //SW - mm[3]= mm[0] -parH[level]->nx; //S - mm[4]= mm[0]-(parH[level]->nx*parH[level]->ny); //B - mm[5]= mm[0]-(parH[level]->nx*parH[level]->ny) -1; //BW - mm[6]= mm[0]-(parH[level]->nx*parH[level]->ny)-parH[level]->nx; //BS - mm[7]= mm[0]-(parH[level]->nx*parH[level]->ny)-parH[level]->nx-1; //BSW - - if ( parH[level]->geo[mm[0]] != GEO_VOID || - parH[level]->geo[mm[1]] != GEO_VOID || - parH[level]->geo[mm[2]] != GEO_VOID || - parH[level]->geo[mm[3]] != GEO_VOID || - parH[level]->geo[mm[4]] != GEO_VOID || - parH[level]->geo[mm[5]] != GEO_VOID || - parH[level]->geo[mm[6]] != GEO_VOID || - parH[level]->geo[mm[7]] != GEO_VOID ) - { - ////////////////////////////////////////////////////////////////////////// - //add some stuff for the data exchange between the GPUs ////////////////// - if (k == STARTOFFZ) - { - parH[level]->sizePlaneSB += 1; - if (parH[level]->isSetSendB == false) - { - parH[level]->startB = mm[0]; - parH[level]->isSetSendB = true; - } - } - else if (k == parH[level]->gridNZ + STARTOFFZ - 1) - { - parH[level]->sizePlaneST += 1; - if (parH[level]->isSetSendT == false) - { - parH[level]->startT = mm[0]; - parH[level]->isSetSendT = true; - } - } - else if (k == parH[level]->gridNZ + STARTOFFZ) - { - parH[level]->sizePlaneRB += 1; - if (parH[level]->isSetRecvB == false) - { - parH[level]->endB = mm[0]; - parH[level]->isSetRecvB = true; - } - } - else if (k == STARTOFFZ-1) - { - parH[level]->sizePlaneRT += 1; - if (parH[level]->isSetRecvT == false) - { - parH[level]->endT = mm[0]; - parH[level]->isSetRecvT = true; - } - } - ////////////////////////////////////////////////////////////////////////// - parH[level]->k[mm[0]] = parH[level]->size_Mat_SP; - parH[level]->size_Mat_SP = parH[level]->size_Mat_SP + 1; - parD[level]->size_Mat_SP = parD[level]->size_Mat_SP + 1; - } - else parH[level]->k[mm[0]] = 0; - } - } - } - parH[level]->mem_size_real_SP = sizeof(real ) * parH[level]->size_Mat_SP; - parH[level]->mem_size_int_SP = sizeof(unsigned int) * parH[level]->size_Mat_SP; - parD[level]->mem_size_real_SP = sizeof(real ) * parD[level]->size_Mat_SP; - parD[level]->mem_size_int_SP = sizeof(unsigned int) * parD[level]->size_Mat_SP; -} -void Parameter::fillSparse(int level) -{ - //nsigned int li = ((parH[level]->gridNX+STARTOFFX-2)-(STARTOFFX+1)-1); - //unsigned int lj = ((parH[level]->gridNY+STARTOFFY-2)-(STARTOFFY+1)-1); - // real globalX, globalY, globalZ; - - real PI = 3.141592653589793238462643383279f; - - for (unsigned int k=1; k<parH[level]->gridNZ + 2 * STARTOFFZ - 1; k++) - { - for (unsigned int j=1; j<parH[level]->gridNY + 2 * STARTOFFY - 1; j++) - { - for (unsigned int i=1; i<parH[level]->gridNX + 2 * STARTOFFX - 1; i++) - { - int m = parH[level]->nx*(parH[level]->ny*k + j) + i; - if ((k < parH[level]->gridNZ + 2 * STARTOFFZ - 2) && (j < parH[level]->gridNY + 2 * STARTOFFY - 2) && (i < parH[level]->gridNX + 2 * STARTOFFX - 2)) - { - if ((X1PERIODIC == true) && (level==coarse) && (i==parH[level]->gridNX + STARTOFFX - 1)) - { - int mm = parH[level]->nx*(parH[level]->ny*k + j) + STARTOFFX; - parH[level]->neighborX_SP[parH[level]->k[m]] = parH[level]->k[mm]; - } - else - { - parH[level]->neighborX_SP[parH[level]->k[m]] = parH[level]->k[m+1]; - } - if ((X2PERIODIC == true) && (level==coarse) && (j==parH[level]->gridNY + STARTOFFY - 1)) - { - int mm = parH[level]->nx*(parH[level]->ny*k + STARTOFFY) + i; - parH[level]->neighborY_SP[parH[level]->k[m]] = parH[level]->k[mm]; - } - else - { - parH[level]->neighborY_SP[parH[level]->k[m]] = parH[level]->k[m+parH[level]->nx]; - } - if ((X3PERIODIC == true) && (level==coarse) && (k==parH[level]->gridNZ + STARTOFFZ - 1)) - { - int mm = parH[level]->nx*(parH[level]->ny*STARTOFFZ + j) + i; - parH[level]->neighborZ_SP[parH[level]->k[m]] = parH[level]->k[mm]; - } - else - { - parH[level]->neighborZ_SP[parH[level]->k[m]] = parH[level]->k[m+(parH[level]->nx*parH[level]->ny)]; - } - } - parH[level]->geoSP[parH[level]->k[m]] = parH[level]->geo[m]; - //////////////////////////////////////////////////////////////////////////// - ////Coordinates - //parH[level]->coordX_SP[parH[level]->k[m]] = i; - //parH[level]->coordY_SP[parH[level]->k[m]] = j; - //parH[level]->coordZ_SP[parH[level]->k[m]] = k; - //////////////////////////////////////////////////////////////////////////// - if (diffOn==true) - { - parH[level]->Conc[parH[level]->k[m]] = parH[level]->Conc_Full[m]; - } - //////////////////////////////////////////////////////////////////////////// - ////set pressure in the middle of the fine grid - //if (level == getFine()) - //{ - // if( i == parH[level]->gridNX/2 + STARTOFFX - // && j == parH[level]->gridNY/2 + STARTOFFY - // && k == parH[level]->gridNZ/2 + STARTOFFZ) - // parH[level]->rho_SP[parH[level]->k[m]] = (real)0.1f; - // else - // parH[level]->rho_SP[parH[level]->k[m]] = (real)0.0f; - //} - //else - //{ - // parH[level]->rho_SP[parH[level]->k[m]] = (real)0.0f; - //} - // globalX = TrafoXtoWorld(i,level); - // globalY = TrafoYtoWorld(j,level); - // globalZ = TrafoZtoWorld(k,level); - //without setting a pressure - parH[level]->rho_SP[parH[level]->k[m]] = (real)0.0f; //parH[level]->Conc_Full[m];//bitte schnell wieder entfernen!!! - ////////////////////////////////////////////////////////////////////////// - parH[level]->vx_SP[parH[level]->k[m]] = (real)0.0f; - //parH[level]->vx_SP[parH[level]->k[m]] = u0/3.0; - parH[level]->vy_SP[parH[level]->k[m]] = (real)0.0f; - //parH[level]->vy_SP[parH[level]->k[m]] = u0/3.0; - parH[level]->vz_SP[parH[level]->k[m]] = (real)0.0f; - //parH[level]->vz_SP[parH[level]->k[m]] = u0/3.0; - //parH[level]->vz_SP[parH[level]->k[m]] = (real)(u0*2.f)*((-4.f*globalX*globalX + parH[level]->gridNX*(-2.f - 4.f*STARTOFFX) - 4.f*(-1.5f + STARTOFFX)*(0.5f + STARTOFFX) + globalX*(-4.f + 4.f*parH[level]->gridNX + 8.f*STARTOFFX))*(-4.f*globalY*globalY + parH[level]->gridNY*(-2.f - 4.f*STARTOFFY) - 4.f*(-1.5f + STARTOFFY)*(0.5f + STARTOFFY) + globalY*(-4.f + 4.f*parH[level]->gridNY + 8.f*STARTOFFY)))/((2.f - parH[level]->gridNX)*(2.f - parH[level]->gridNX)*(2.f - parH[level]->gridNY)*(2.f - parH[level]->gridNY)); - //parH[level]->vz_SP[parH[level]->k[m]] = (real)(u0*2.f)*((-4.f*i*i + parH[level]->gridNX*(-2.f - 4.f*STARTOFFX) - 4.f*(-1.5f + STARTOFFX)*(0.5f + STARTOFFX) + i*(-4.f + 4.f*parH[level]->gridNX + 8.f*STARTOFFX))*(-4.f*j*j + parH[level]->gridNY*(-2.f - 4.f*STARTOFFY) - 4.f*(-1.5f + STARTOFFY)*(0.5f + STARTOFFY) + j*(-4.f + 4.f*parH[level]->gridNY + 8.f*STARTOFFY)))/((2.f - parH[level]->gridNX)*(2.f - parH[level]->gridNX)*(2.f - parH[level]->gridNY)*(2.f - parH[level]->gridNY)); - //parH[level]->vz_SP[parH[level]->k[m]] = (real)(16.f*(u0*2.f)*(i-(STARTOFFX+1)-0.5f)*(li-1.5f-(i-(STARTOFFX+1)))*(j-(STARTOFFY+1)-0.5f)*(lj-1.5f-(j-(STARTOFFY+1))))/(li*lj*li*lj);//(16.f*(u0*2.f)*i*j*(parH[level]->nx-i)*(parH[level]->ny-j))/(parH[level]->nx*parH[level]->nx*parH[level]->ny*parH[level]->ny); //u0; - ////////////////////////////////////////////////////////////////////////// - ////gerade - //parH[level]->vx_SP[parH[level]->k[m]] = (real)((32. * 32. * 3.) / (1000.*(real)parH[level]->gridNX));//(real)parH[level]->gridNX / (real)1000 * 3.0; - //parH[level]->vy_SP[parH[level]->k[m]] = (real)((getVelocity() * sin(2.0 * i / parH[level]->gridNX * PI) * cos(2.0 * k / parH[level]->gridNZ * PI)) * (32. / (real)parH[level]->gridNX)); - //parH[level]->vz_SP[parH[level]->k[m]] = (real)0.0f; - //schraeg x - // parH[level]->vx_SP[parH[level]->k[m]] = (real)((32. * 32. * 3.)/(1000.*(real)parH[level]->gridNX) + (getVelocity() * cos((2.0 * k / parH[level]->gridNZ * PI) + (2.0 * i / parH[level]->gridNX * PI)))); - // parH[level]->vy_SP[parH[level]->k[m]] = (real)0.0; - // parH[level]->vz_SP[parH[level]->k[m]] = (real)(getVelocity() * cos((2.0 * k / parH[level]->gridNZ * PI) + (2.0 * i / parH[level]->gridNX * PI))); - //schraeg z - //parH[level]->vx_SP[parH[level]->k[m]] = (real)(getVelocity() * std::cos((2.0 * k / parH[level]->gridNZ * PI) + (2.0 * i / parH[level]->gridNX * PI))); - //parH[level]->vy_SP[parH[level]->k[m]] = (real)0.0; - //parH[level]->vz_SP[parH[level]->k[m]] = (real)((32. * 32. * 3.)/(1000.*(real)parH[level]->gridNZ) + (getVelocity() * std::cos((2.0 * k / parH[level]->gridNZ * PI) + (2.0 * i / parH[level]->gridNX * PI)))); - - //Taylor Green Vortex uniform - parH[level]->rho_SP[parH[level]->k[m]] = (real)((getVelocity()*getVelocity())*3.0/4.0*(cos((i)*4.0*PI/(real)parH[level]->gridNX)+cos((k)*4.0*PI/(real)parH[level]->gridNZ)))*(real)(parH[level]->gridNZ)/(real)(parH[level]->gridNX); - //inkl. ueberlagerter Geschwindigkeit - // parH[level]->vx_SP[parH[level]->k[m]] = (real)((32. * 32. * 3.)/(1000.*(real)parH[level]->gridNX) + getVelocity()*sin(((i)*2.0*PI/(real)parH[level]->gridNX))*cos((k)*2.0*PI/(real)parH[level]->gridNZ)); - parH[level]->vx_SP[parH[level]->k[m]] = (real)((32. * 32. * 3.)/(1000. * 32.) * getVelocity() / 0.001 + getVelocity()*sin(((i)*2.0*PI/(real)parH[level]->gridNX))*cos((k)*2.0*PI/(real)parH[level]->gridNZ)); - //ohne ueberlagerter Geschwindigkeit - // parH[level]->vx_SP[parH[level]->k[m]] = (real)(getVelocity()*sin(((i)*2.0*PI/(real)parH[level]->gridNX))*cos((k)*2.0*PI/(real)parH[level]->gridNZ)); - parH[level]->vy_SP[parH[level]->k[m]] = (real)0.0; - parH[level]->vz_SP[parH[level]->k[m]] = (real)(-getVelocity()*cos(((i)*2.0*PI/(real)parH[level]->gridNX))*sin((k)*2.0*PI/(real)parH[level]->gridNZ))*(real)(parH[level]->gridNZ)/(real)(parH[level]->gridNX); - - //Kernel Fix Test - //parH[level]->vx_SP[parH[level]->k[m]] = (real)((32. * 32. * 3.)/(1000.*(real)parH[level]->gridNX) + (getVelocity() * std::cos((2.0 * k / parH[level]->gridNZ * PI) + (2.0 * i / parH[level]->gridNX * PI)))); - //parH[level]->vy_SP[parH[level]->k[m]] = (real)0.0; - //parH[level]->vz_SP[parH[level]->k[m]] = (real)(getVelocity() * std::cos((2.0 * k / parH[level]->gridNZ * PI) + (2.0 * i / parH[level]->gridNX * PI))); - ////parH[level]->vx_SP[parH[level]->k[m]] = (real)(getVelocity() * std::cos((2.0 * k / parH[level]->gridNZ * PI) + (2.0 * i / parH[level]->gridNX * PI))); - ////parH[level]->vy_SP[parH[level]->k[m]] = (real)0.0; - ////parH[level]->vz_SP[parH[level]->k[m]] = (real)((32. * 32. * 3.)/(1000.*(real)parH[level]->gridNZ) + (getVelocity() * std::cos((2.0 * k / parH[level]->gridNZ * PI) + (2.0 * i / parH[level]->gridNX * PI)))); - ////////////////////////////////////////////////////////////////////////// - //Taylor Green Vortex - //InitglobalX = TrafoXtoMGsWorld(i,level); - //InitglobalY = TrafoYtoMGsWorld(j,level); - //InitglobalZ = TrafoZtoMGsWorld(k,level); - //parH[level]->rho_SP[parH[level]->k[m]] = (real)((u0*u0)*3.f/4.f*(cos((InitglobalX)*4.f*PI/parH[level]->gridNX)+cos((InitglobalY)*4.f*PI/parH[level]->gridNY))); - //parH[level]->vx_SP[parH[level]->k[m]] = (real)( u0*sin(((InitglobalX)*2.f*PI/parH[level]->gridNX))*cos((InitglobalY)*2.f*PI/parH[level]->gridNY)); - //parH[level]->vy_SP[parH[level]->k[m]] = (real)(-u0*cos(((InitglobalX)*2.f*PI/parH[level]->gridNX))*sin((InitglobalY)*2.f*PI/parH[level]->gridNY)); - //parH[level]->vz_SP[parH[level]->k[m]] = (real)0.0f; - ////////////////////////////////////////////////////////////////////////// - } - } - } - parH[level]->neighborX_SP[parH[level]->k[0]] = 0; - parH[level]->neighborY_SP[parH[level]->k[0]] = 0; - parH[level]->neighborZ_SP[parH[level]->k[0]] = 0; - parH[level]->geoSP[ parH[level]->k[0]] = GEO_VOID; - parH[level]->rho_SP[ parH[level]->k[0]] = (real)0.f; - parH[level]->vx_SP[ parH[level]->k[0]] = (real)0.f; - parH[level]->vy_SP[ parH[level]->k[0]] = (real)0.f; - parH[level]->vz_SP[ parH[level]->k[0]] = (real)0.f; - //////////////////////////////////////////////////////////////////////////// - ////Coordinates - //parH[level]->coordX_SP[parH[level]->k[0]] = 0; - //parH[level]->coordY_SP[parH[level]->k[0]] = 0; - //parH[level]->coordZ_SP[parH[level]->k[0]] = 0; - //////////////////////////////////////////////////////////////////////////// -} -void Parameter::copyMeasurePointsArrayToVector(int lev) -{ - int valuesPerClockCycle = (int)(getclockCycleForMP()/getTimestepForMP()); - for(int i = 0; i < (int)parH[lev]->MP.size(); i++) - { - for(int j = 0; j < valuesPerClockCycle; j++) - { - int index = i*valuesPerClockCycle+j; - parH[lev]->MP[i].Vx.push_back(parH[lev]->VxMP[index]); - parH[lev]->MP[i].Vy.push_back(parH[lev]->VyMP[index]); - parH[lev]->MP[i].Vz.push_back(parH[lev]->VzMP[index]); - parH[lev]->MP[i].Rho.push_back(parH[lev]->RhoMP[index]); - } - } -} -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -//cuda-alloc-methods -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -//full -void Parameter::cudaAllocFull(int lev) -{ - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->geo ), parH[lev]->mem_size_int )); - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->k ), parH[lev]->mem_size_int )); -} -void Parameter::cudaFreeFull(int lev) -{ - checkCudaErrors( cudaFreeHost(parH[lev]->geo )); - checkCudaErrors( cudaFreeHost(parH[lev]->k )); -} -//coord -void Parameter::cudaAllocCoord(int lev) -{ - //Host - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->coordX_SP ), parH[lev]->mem_size_real_SP )); - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->coordY_SP ), parH[lev]->mem_size_real_SP )); - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->coordZ_SP ), parH[lev]->mem_size_real_SP )); - //Device (spinning ship) - checkCudaErrors( cudaMalloc((void**) &(parD[lev]->coordX_SP ), parH[lev]->mem_size_real_SP )); - checkCudaErrors( cudaMalloc((void**) &(parD[lev]->coordY_SP ), parH[lev]->mem_size_real_SP )); - checkCudaErrors( cudaMalloc((void**) &(parD[lev]->coordZ_SP ), parH[lev]->mem_size_real_SP )); - ////////////////////////////////////////////////////////////////////////// - double tmp = 3. * (double)parH[lev]->mem_size_real_SP; - setMemsizeGPU(tmp, false); - //printf("Coord = %f MB",tmp/1000000.); -} -void Parameter::cudaCopyCoord(int lev) -{ - //copy host to device - checkCudaErrors( cudaMemcpy(parD[lev]->coordX_SP, parH[lev]->coordX_SP, parH[lev]->mem_size_real_SP , cudaMemcpyHostToDevice)); - checkCudaErrors( cudaMemcpy(parD[lev]->coordY_SP, parH[lev]->coordY_SP, parH[lev]->mem_size_real_SP , cudaMemcpyHostToDevice)); - checkCudaErrors( cudaMemcpy(parD[lev]->coordZ_SP, parH[lev]->coordZ_SP, parH[lev]->mem_size_real_SP , cudaMemcpyHostToDevice)); -} -void Parameter::cudaFreeCoord(int lev) -{ - checkCudaErrors( cudaFreeHost(parH[lev]->coordX_SP )); - checkCudaErrors( cudaFreeHost(parH[lev]->coordY_SP )); - checkCudaErrors( cudaFreeHost(parH[lev]->coordZ_SP )); -} -//print -void Parameter::cudaCopyPrint(int lev) -{ - checkCudaErrors( cudaMemcpy(parH[lev]->vx_SP , parD[lev]->vx_SP , parH[lev]->mem_size_real_SP , cudaMemcpyDeviceToHost)); - checkCudaErrors( cudaMemcpy(parH[lev]->vy_SP , parD[lev]->vy_SP , parH[lev]->mem_size_real_SP , cudaMemcpyDeviceToHost)); - checkCudaErrors( cudaMemcpy(parH[lev]->vz_SP , parD[lev]->vz_SP , parH[lev]->mem_size_real_SP , cudaMemcpyDeviceToHost)); - checkCudaErrors( cudaMemcpy(parH[lev]->rho_SP , parD[lev]->rho_SP , parH[lev]->mem_size_real_SP , cudaMemcpyDeviceToHost)); - checkCudaErrors( cudaMemcpy(parH[lev]->press_SP, parD[lev]->press_SP, parH[lev]->mem_size_real_SP , cudaMemcpyDeviceToHost)); -} -void Parameter::cudaCopyMedianPrint(int lev) -{ - checkCudaErrors( cudaMemcpy(parH[lev]->vx_SP_Med , parD[lev]->vx_SP_Med , parH[lev]->mem_size_real_SP , cudaMemcpyDeviceToHost)); - checkCudaErrors( cudaMemcpy(parH[lev]->vy_SP_Med , parD[lev]->vy_SP_Med , parH[lev]->mem_size_real_SP , cudaMemcpyDeviceToHost)); - checkCudaErrors( cudaMemcpy(parH[lev]->vz_SP_Med , parD[lev]->vz_SP_Med , parH[lev]->mem_size_real_SP , cudaMemcpyDeviceToHost)); - checkCudaErrors( cudaMemcpy(parH[lev]->rho_SP_Med , parD[lev]->rho_SP_Med , parH[lev]->mem_size_real_SP , cudaMemcpyDeviceToHost)); - checkCudaErrors( cudaMemcpy(parH[lev]->press_SP_Med, parD[lev]->press_SP_Med, parH[lev]->mem_size_real_SP , cudaMemcpyDeviceToHost)); -} -void Parameter::cudaCopyMedianADPrint(int lev) -{ - checkCudaErrors( cudaMemcpy(parH[lev]->vx_SP_Med , parD[lev]->vx_SP_Med , parH[lev]->mem_size_real_SP , cudaMemcpyDeviceToHost)); - checkCudaErrors( cudaMemcpy(parH[lev]->vy_SP_Med , parD[lev]->vy_SP_Med , parH[lev]->mem_size_real_SP , cudaMemcpyDeviceToHost)); - checkCudaErrors( cudaMemcpy(parH[lev]->vz_SP_Med , parD[lev]->vz_SP_Med , parH[lev]->mem_size_real_SP , cudaMemcpyDeviceToHost)); - checkCudaErrors( cudaMemcpy(parH[lev]->rho_SP_Med , parD[lev]->rho_SP_Med , parH[lev]->mem_size_real_SP , cudaMemcpyDeviceToHost)); - checkCudaErrors( cudaMemcpy(parH[lev]->press_SP_Med, parD[lev]->press_SP_Med, parH[lev]->mem_size_real_SP , cudaMemcpyDeviceToHost)); - checkCudaErrors( cudaMemcpy(parH[lev]->Conc_Med , parD[lev]->Conc_Med , parH[lev]->mem_size_real_SP , cudaMemcpyDeviceToHost)); -} -//sparse -void Parameter::cudaAllocSP(int lev) -{ - //Host - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->geoSP ), parH[lev]->mem_size_int_SP )); - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->neighborX_SP ), parH[lev]->mem_size_int_SP )); - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->neighborY_SP ), parH[lev]->mem_size_int_SP )); - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->neighborZ_SP ), parH[lev]->mem_size_int_SP )); - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->rho_SP ), parH[lev]->mem_size_real_SP)); - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->vx_SP ), parH[lev]->mem_size_real_SP)); - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->vy_SP ), parH[lev]->mem_size_real_SP)); - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->vz_SP ), parH[lev]->mem_size_real_SP)); - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->press_SP ), parH[lev]->mem_size_real_SP)); - //Device - checkCudaErrors( cudaMalloc((void**) &(parD[lev]->geoSP ), parD[lev]->mem_size_int_SP )); - checkCudaErrors( cudaMalloc((void**) &(parD[lev]->neighborX_SP ), parD[lev]->mem_size_int_SP )); - checkCudaErrors( cudaMalloc((void**) &(parD[lev]->neighborY_SP ), parD[lev]->mem_size_int_SP )); - checkCudaErrors( cudaMalloc((void**) &(parD[lev]->neighborZ_SP ), parD[lev]->mem_size_int_SP )); - checkCudaErrors( cudaMalloc((void**) &(parD[lev]->rho_SP ), parD[lev]->mem_size_real_SP)); - checkCudaErrors( cudaMalloc((void**) &(parD[lev]->vx_SP ), parD[lev]->mem_size_real_SP)); - checkCudaErrors( cudaMalloc((void**) &(parD[lev]->vy_SP ), parD[lev]->mem_size_real_SP)); - checkCudaErrors( cudaMalloc((void**) &(parD[lev]->vz_SP ), parD[lev]->mem_size_real_SP)); - checkCudaErrors( cudaMalloc((void**) &(parD[lev]->press_SP ), parD[lev]->mem_size_real_SP)); - checkCudaErrors( cudaMalloc((void**) &(parD[lev]->d0SP.f[0] ), (unsigned long long)getD3Qxx()*(unsigned long long)parD[lev]->mem_size_real_SP)); - ////////////////////////////////////////////////////////////////////////// - //double tmp = 4. * (double)parH[lev]->mem_size_int_SP + 10. * (double)parH[lev]->mem_size_real_SP + (double)getD3Qxx() * (double)parH[lev]->mem_size_real_SP; - double tmp = 4. * (double)parH[lev]->mem_size_int_SP + 5. * (double)parH[lev]->mem_size_real_SP + (double)getD3Qxx() * (double)parH[lev]->mem_size_real_SP; - setMemsizeGPU(tmp, false); - - //int test = sizeof(int); - //printf("\n sizeof int = %d \n",test); - - //printf("AlocSP = %f MB \n",tmp/1000000.); - //int test = sizeof(float*); - //printf("float* = %d \n",test); - //unsigned long long test2 = (unsigned long long)getD3Qxx()*(unsigned long long)parD[lev]->mem_size_real_SP; - //test2 = test2 / 1000000000; - //printf("test2 = %d \n",test2); -} -void Parameter::cudaCopySP(int lev) -{ - //copy host to device - checkCudaErrors( cudaMemcpy(parD[lev]->geoSP , parH[lev]->geoSP , parH[lev]->mem_size_int_SP , cudaMemcpyHostToDevice)); - checkCudaErrors( cudaMemcpy(parD[lev]->neighborX_SP, parH[lev]->neighborX_SP, parH[lev]->mem_size_int_SP , cudaMemcpyHostToDevice)); - checkCudaErrors( cudaMemcpy(parD[lev]->neighborY_SP, parH[lev]->neighborY_SP, parH[lev]->mem_size_int_SP , cudaMemcpyHostToDevice)); - checkCudaErrors( cudaMemcpy(parD[lev]->neighborZ_SP, parH[lev]->neighborZ_SP, parH[lev]->mem_size_int_SP , cudaMemcpyHostToDevice)); - checkCudaErrors( cudaMemcpy(parD[lev]->rho_SP , parH[lev]->rho_SP , parH[lev]->mem_size_real_SP , cudaMemcpyHostToDevice)); - checkCudaErrors( cudaMemcpy(parD[lev]->vx_SP , parH[lev]->vx_SP , parH[lev]->mem_size_real_SP , cudaMemcpyHostToDevice)); - checkCudaErrors( cudaMemcpy(parD[lev]->vy_SP , parH[lev]->vy_SP , parH[lev]->mem_size_real_SP , cudaMemcpyHostToDevice)); - checkCudaErrors( cudaMemcpy(parD[lev]->vz_SP , parH[lev]->vz_SP , parH[lev]->mem_size_real_SP , cudaMemcpyHostToDevice)); - checkCudaErrors( cudaMemcpy(parD[lev]->press_SP , parH[lev]->press_SP , parH[lev]->mem_size_real_SP , cudaMemcpyHostToDevice)); -} -void Parameter::cudaFreeSP(int lev) -{ - checkCudaErrors( cudaFreeHost(parH[lev]->geoSP )); - checkCudaErrors( cudaFreeHost(parH[lev]->vx_SP )); - checkCudaErrors( cudaFreeHost(parH[lev]->vy_SP )); - checkCudaErrors( cudaFreeHost(parH[lev]->vz_SP )); - checkCudaErrors( cudaFreeHost(parH[lev]->rho_SP )); - checkCudaErrors( cudaFreeHost(parH[lev]->press_SP )); - checkCudaErrors( cudaFreeHost(parH[lev]->neighborX_SP)); - checkCudaErrors( cudaFreeHost(parH[lev]->neighborY_SP)); - checkCudaErrors( cudaFreeHost(parH[lev]->neighborZ_SP)); -} -//F3 -void Parameter::cudaAllocF3SP(int lev) -{ - //Device - checkCudaErrors(cudaMalloc((void**) &(parD[lev]->g6.g[0]), (unsigned long long)6*(unsigned long long)parD[lev]->mem_size_real_SP)); - ////////////////////////////////////////////////////////////////////////// - double tmp = (double)6 * (double)parH[lev]->mem_size_real_SP; - setMemsizeGPU(tmp, false); -} -//negative neighbor (WSB) -void Parameter::cudaAllocNeighborWSB(int lev) -{ - //Host - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->neighborWSB_SP ), parH[lev]->mem_size_int_SP )); - //Device - checkCudaErrors( cudaMalloc((void**) &(parD[lev]->neighborWSB_SP ), parD[lev]->mem_size_int_SP )); - ////////////////////////////////////////////////////////////////////////// - double tmp = (double)parH[lev]->mem_size_int_SP; - setMemsizeGPU(tmp, false); -} -void Parameter::cudaCopyNeighborWSB(int lev) -{ - //copy host to device - checkCudaErrors( cudaMemcpy(parD[lev]->neighborWSB_SP, parH[lev]->neighborWSB_SP, parH[lev]->mem_size_int_SP , cudaMemcpyHostToDevice)); -} -void Parameter::cudaFreeNeighborWSB(int lev) -{ - checkCudaErrors( cudaFreeHost(parH[lev]->neighborWSB_SP)); -} -//turbulent viscosity -void Parameter::cudaAllocTurbulentViscosity(int lev) -{ - //Host - checkCudaErrors(cudaMallocHost((void**) &(parH[lev]->turbViscosity), parH[lev]->mem_size_real_SP)); - //Debug - checkCudaErrors(cudaMallocHost((void**) &(parH[lev]->gSij ), parH[lev]->mem_size_real_SP)); - checkCudaErrors(cudaMallocHost((void**) &(parH[lev]->gSDij), parH[lev]->mem_size_real_SP)); - checkCudaErrors(cudaMallocHost((void**) &(parH[lev]->gDxvx), parH[lev]->mem_size_real_SP)); - checkCudaErrors(cudaMallocHost((void**) &(parH[lev]->gDyvx), parH[lev]->mem_size_real_SP)); - checkCudaErrors(cudaMallocHost((void**) &(parH[lev]->gDzvx), parH[lev]->mem_size_real_SP)); - checkCudaErrors(cudaMallocHost((void**) &(parH[lev]->gDxvy), parH[lev]->mem_size_real_SP)); - checkCudaErrors(cudaMallocHost((void**) &(parH[lev]->gDyvy), parH[lev]->mem_size_real_SP)); - checkCudaErrors(cudaMallocHost((void**) &(parH[lev]->gDzvy), parH[lev]->mem_size_real_SP)); - checkCudaErrors(cudaMallocHost((void**) &(parH[lev]->gDxvz), parH[lev]->mem_size_real_SP)); - checkCudaErrors(cudaMallocHost((void**) &(parH[lev]->gDyvz), parH[lev]->mem_size_real_SP)); - checkCudaErrors(cudaMallocHost((void**) &(parH[lev]->gDzvz), parH[lev]->mem_size_real_SP)); - - //Device - checkCudaErrors(cudaMalloc((void**) &(parD[lev]->turbViscosity), parD[lev]->mem_size_real_SP)); - //Debug - checkCudaErrors(cudaMalloc((void**) &(parD[lev]->gSij ), parD[lev]->mem_size_real_SP)); - checkCudaErrors(cudaMalloc((void**) &(parD[lev]->gSDij), parD[lev]->mem_size_real_SP)); - checkCudaErrors(cudaMalloc((void**) &(parD[lev]->gDxvx), parD[lev]->mem_size_real_SP)); - checkCudaErrors(cudaMalloc((void**) &(parD[lev]->gDyvx), parD[lev]->mem_size_real_SP)); - checkCudaErrors(cudaMalloc((void**) &(parD[lev]->gDzvx), parD[lev]->mem_size_real_SP)); - checkCudaErrors(cudaMalloc((void**) &(parD[lev]->gDxvy), parD[lev]->mem_size_real_SP)); - checkCudaErrors(cudaMalloc((void**) &(parD[lev]->gDyvy), parD[lev]->mem_size_real_SP)); - checkCudaErrors(cudaMalloc((void**) &(parD[lev]->gDzvy), parD[lev]->mem_size_real_SP)); - checkCudaErrors(cudaMalloc((void**) &(parD[lev]->gDxvz), parD[lev]->mem_size_real_SP)); - checkCudaErrors(cudaMalloc((void**) &(parD[lev]->gDyvz), parD[lev]->mem_size_real_SP)); - checkCudaErrors(cudaMalloc((void**) &(parD[lev]->gDzvz), parD[lev]->mem_size_real_SP)); - ////////////////////////////////////////////////////////////////////////// - double tmp = (double)parH[lev]->mem_size_real_SP; - setMemsizeGPU(tmp, false); -} -void Parameter::cudaCopyTurbulentViscosityHD(int lev) -{ - //copy host to device - checkCudaErrors(cudaMemcpy(parD[lev]->turbViscosity, parH[lev]->turbViscosity, parH[lev]->mem_size_real_SP, cudaMemcpyHostToDevice)); - //Debug - checkCudaErrors(cudaMemcpy(parD[lev]->gSij , parH[lev]->gSij , parH[lev]->mem_size_real_SP, cudaMemcpyHostToDevice)); - checkCudaErrors(cudaMemcpy(parD[lev]->gSDij, parH[lev]->gSDij, parH[lev]->mem_size_real_SP, cudaMemcpyHostToDevice)); - checkCudaErrors(cudaMemcpy(parD[lev]->gDxvx, parH[lev]->gDxvx, parH[lev]->mem_size_real_SP, cudaMemcpyHostToDevice)); - checkCudaErrors(cudaMemcpy(parD[lev]->gDyvx, parH[lev]->gDyvx, parH[lev]->mem_size_real_SP, cudaMemcpyHostToDevice)); - checkCudaErrors(cudaMemcpy(parD[lev]->gDzvx, parH[lev]->gDzvx, parH[lev]->mem_size_real_SP, cudaMemcpyHostToDevice)); - checkCudaErrors(cudaMemcpy(parD[lev]->gDxvy, parH[lev]->gDxvy, parH[lev]->mem_size_real_SP, cudaMemcpyHostToDevice)); - checkCudaErrors(cudaMemcpy(parD[lev]->gDyvy, parH[lev]->gDyvy, parH[lev]->mem_size_real_SP, cudaMemcpyHostToDevice)); - checkCudaErrors(cudaMemcpy(parD[lev]->gDzvy, parH[lev]->gDzvy, parH[lev]->mem_size_real_SP, cudaMemcpyHostToDevice)); - checkCudaErrors(cudaMemcpy(parD[lev]->gDxvz, parH[lev]->gDxvz, parH[lev]->mem_size_real_SP, cudaMemcpyHostToDevice)); - checkCudaErrors(cudaMemcpy(parD[lev]->gDyvz, parH[lev]->gDyvz, parH[lev]->mem_size_real_SP, cudaMemcpyHostToDevice)); - checkCudaErrors(cudaMemcpy(parD[lev]->gDzvz, parH[lev]->gDzvz, parH[lev]->mem_size_real_SP, cudaMemcpyHostToDevice)); -} -void Parameter::cudaCopyTurbulentViscosityDH(int lev) -{ - //copy device to host - checkCudaErrors(cudaMemcpy(parH[lev]->turbViscosity, parD[lev]->turbViscosity, parH[lev]->mem_size_real_SP, cudaMemcpyDeviceToHost)); - //Debug - checkCudaErrors(cudaMemcpy(parH[lev]->gSij , parD[lev]->gSij , parH[lev]->mem_size_real_SP, cudaMemcpyDeviceToHost)); - checkCudaErrors(cudaMemcpy(parH[lev]->gSDij, parD[lev]->gSDij, parH[lev]->mem_size_real_SP, cudaMemcpyDeviceToHost)); - checkCudaErrors(cudaMemcpy(parH[lev]->gDxvx, parD[lev]->gDxvx, parH[lev]->mem_size_real_SP, cudaMemcpyDeviceToHost)); - checkCudaErrors(cudaMemcpy(parH[lev]->gDyvx, parD[lev]->gDyvx, parH[lev]->mem_size_real_SP, cudaMemcpyDeviceToHost)); - checkCudaErrors(cudaMemcpy(parH[lev]->gDzvx, parD[lev]->gDzvx, parH[lev]->mem_size_real_SP, cudaMemcpyDeviceToHost)); - checkCudaErrors(cudaMemcpy(parH[lev]->gDxvy, parD[lev]->gDxvy, parH[lev]->mem_size_real_SP, cudaMemcpyDeviceToHost)); - checkCudaErrors(cudaMemcpy(parH[lev]->gDyvy, parD[lev]->gDyvy, parH[lev]->mem_size_real_SP, cudaMemcpyDeviceToHost)); - checkCudaErrors(cudaMemcpy(parH[lev]->gDzvy, parD[lev]->gDzvy, parH[lev]->mem_size_real_SP, cudaMemcpyDeviceToHost)); - checkCudaErrors(cudaMemcpy(parH[lev]->gDxvz, parD[lev]->gDxvz, parH[lev]->mem_size_real_SP, cudaMemcpyDeviceToHost)); - checkCudaErrors(cudaMemcpy(parH[lev]->gDyvz, parD[lev]->gDyvz, parH[lev]->mem_size_real_SP, cudaMemcpyDeviceToHost)); - checkCudaErrors(cudaMemcpy(parH[lev]->gDzvz, parD[lev]->gDzvz, parH[lev]->mem_size_real_SP, cudaMemcpyDeviceToHost)); -} -void Parameter::cudaFreeTurbulentViscosity(int lev) -{ - checkCudaErrors(cudaFreeHost(parH[lev]->turbViscosity)); - //Debug - checkCudaErrors(cudaFreeHost(parH[lev]->gSij )); - checkCudaErrors(cudaFreeHost(parH[lev]->gSDij)); - checkCudaErrors(cudaFreeHost(parH[lev]->gDxvx)); - checkCudaErrors(cudaFreeHost(parH[lev]->gDyvx)); - checkCudaErrors(cudaFreeHost(parH[lev]->gDzvx)); - checkCudaErrors(cudaFreeHost(parH[lev]->gDxvy)); - checkCudaErrors(cudaFreeHost(parH[lev]->gDyvy)); - checkCudaErrors(cudaFreeHost(parH[lev]->gDzvy)); - checkCudaErrors(cudaFreeHost(parH[lev]->gDxvz)); - checkCudaErrors(cudaFreeHost(parH[lev]->gDyvz)); - checkCudaErrors(cudaFreeHost(parH[lev]->gDzvz)); -} -//median -void Parameter::cudaAllocMedianSP(int lev) -{ - //Host - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->rho_SP_Med ), parH[lev]->mem_size_real_SP)); - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->vx_SP_Med ), parH[lev]->mem_size_real_SP)); - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->vy_SP_Med ), parH[lev]->mem_size_real_SP)); - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->vz_SP_Med ), parH[lev]->mem_size_real_SP)); - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->press_SP_Med ), parH[lev]->mem_size_real_SP)); - //Device - checkCudaErrors( cudaMalloc((void**) &(parD[lev]->rho_SP_Med ), parD[lev]->mem_size_real_SP)); - checkCudaErrors( cudaMalloc((void**) &(parD[lev]->vx_SP_Med ), parD[lev]->mem_size_real_SP)); - checkCudaErrors( cudaMalloc((void**) &(parD[lev]->vy_SP_Med ), parD[lev]->mem_size_real_SP)); - checkCudaErrors( cudaMalloc((void**) &(parD[lev]->vz_SP_Med ), parD[lev]->mem_size_real_SP)); - checkCudaErrors( cudaMalloc((void**) &(parD[lev]->press_SP_Med ), parD[lev]->mem_size_real_SP)); - ////////////////////////////////////////////////////////////////////////// - double tmp = 5. * (double)parH[lev]->mem_size_real_SP; - setMemsizeGPU(tmp, false); -} -void Parameter::cudaCopyMedianSP(int lev) -{ - //copy host to device - checkCudaErrors( cudaMemcpy(parD[lev]->rho_SP_Med , parH[lev]->rho_SP_Med , parH[lev]->mem_size_real_SP , cudaMemcpyHostToDevice)); - checkCudaErrors( cudaMemcpy(parD[lev]->vx_SP_Med , parH[lev]->vx_SP_Med , parH[lev]->mem_size_real_SP , cudaMemcpyHostToDevice)); - checkCudaErrors( cudaMemcpy(parD[lev]->vy_SP_Med , parH[lev]->vy_SP_Med , parH[lev]->mem_size_real_SP , cudaMemcpyHostToDevice)); - checkCudaErrors( cudaMemcpy(parD[lev]->vz_SP_Med , parH[lev]->vz_SP_Med , parH[lev]->mem_size_real_SP , cudaMemcpyHostToDevice)); - checkCudaErrors( cudaMemcpy(parD[lev]->press_SP_Med, parH[lev]->press_SP_Med, parH[lev]->mem_size_real_SP , cudaMemcpyHostToDevice)); -} -void Parameter::cudaFreeMedianSP(int lev) -{ - checkCudaErrors( cudaFreeHost(parH[lev]->vx_SP_Med )); - checkCudaErrors( cudaFreeHost(parH[lev]->vy_SP_Med )); - checkCudaErrors( cudaFreeHost(parH[lev]->vz_SP_Med )); - checkCudaErrors( cudaFreeHost(parH[lev]->rho_SP_Med )); - checkCudaErrors( cudaFreeHost(parH[lev]->press_SP_Med)); -} -void Parameter::cudaAllocMedianOut(int lev) -{ - //Host - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->rho_SP_Med_Out ), parH[lev]->mem_size_real_SP)); - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->vx_SP_Med_Out ), parH[lev]->mem_size_real_SP)); - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->vy_SP_Med_Out ), parH[lev]->mem_size_real_SP)); - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->vz_SP_Med_Out ), parH[lev]->mem_size_real_SP)); - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->press_SP_Med_Out ), parH[lev]->mem_size_real_SP)); -} -void Parameter::cudaFreeMedianOut(int lev) -{ - checkCudaErrors( cudaFreeHost(parH[lev]->vx_SP_Med_Out )); - checkCudaErrors( cudaFreeHost(parH[lev]->vy_SP_Med_Out )); - checkCudaErrors( cudaFreeHost(parH[lev]->vz_SP_Med_Out )); - checkCudaErrors( cudaFreeHost(parH[lev]->rho_SP_Med_Out )); - checkCudaErrors( cudaFreeHost(parH[lev]->press_SP_Med_Out)); -} -//median Advection-Diffusion -void Parameter::cudaAllocMedianAD(int lev) -{ - //Host - checkCudaErrors(cudaMallocHost((void**) &(parH[lev]->rho_SP_Med), parH[lev]->mem_size_real_SP)); - checkCudaErrors(cudaMallocHost((void**) &(parH[lev]->vx_SP_Med), parH[lev]->mem_size_real_SP)); - checkCudaErrors(cudaMallocHost((void**) &(parH[lev]->vy_SP_Med), parH[lev]->mem_size_real_SP)); - checkCudaErrors(cudaMallocHost((void**) &(parH[lev]->vz_SP_Med), parH[lev]->mem_size_real_SP)); - checkCudaErrors(cudaMallocHost((void**) &(parH[lev]->press_SP_Med), parH[lev]->mem_size_real_SP)); - checkCudaErrors(cudaMallocHost((void**) &(parH[lev]->Conc_Med), parH[lev]->mem_size_real_SP)); - //Device - checkCudaErrors(cudaMalloc((void**) &(parD[lev]->rho_SP_Med), parD[lev]->mem_size_real_SP)); - checkCudaErrors(cudaMalloc((void**) &(parD[lev]->vx_SP_Med), parD[lev]->mem_size_real_SP)); - checkCudaErrors(cudaMalloc((void**) &(parD[lev]->vy_SP_Med), parD[lev]->mem_size_real_SP)); - checkCudaErrors(cudaMalloc((void**) &(parD[lev]->vz_SP_Med), parD[lev]->mem_size_real_SP)); - checkCudaErrors(cudaMalloc((void**) &(parD[lev]->press_SP_Med), parD[lev]->mem_size_real_SP)); - checkCudaErrors(cudaMalloc((void**) &(parD[lev]->Conc_Med), parD[lev]->mem_size_real_SP)); - ////////////////////////////////////////////////////////////////////////// - double tmp = 6. * (double)parH[lev]->mem_size_real_SP; - setMemsizeGPU(tmp, false); -} -void Parameter::cudaCopyMedianAD(int lev) -{ - //copy host to device - checkCudaErrors(cudaMemcpy(parD[lev]->rho_SP_Med, parH[lev]->rho_SP_Med, parH[lev]->mem_size_real_SP, cudaMemcpyHostToDevice)); - checkCudaErrors(cudaMemcpy(parD[lev]->vx_SP_Med, parH[lev]->vx_SP_Med, parH[lev]->mem_size_real_SP, cudaMemcpyHostToDevice)); - checkCudaErrors(cudaMemcpy(parD[lev]->vy_SP_Med, parH[lev]->vy_SP_Med, parH[lev]->mem_size_real_SP, cudaMemcpyHostToDevice)); - checkCudaErrors(cudaMemcpy(parD[lev]->vz_SP_Med, parH[lev]->vz_SP_Med, parH[lev]->mem_size_real_SP, cudaMemcpyHostToDevice)); - checkCudaErrors(cudaMemcpy(parD[lev]->press_SP_Med, parH[lev]->press_SP_Med, parH[lev]->mem_size_real_SP, cudaMemcpyHostToDevice)); - checkCudaErrors(cudaMemcpy(parD[lev]->Conc_Med, parH[lev]->Conc_Med, parH[lev]->mem_size_real_SP, cudaMemcpyHostToDevice)); -} -void Parameter::cudaFreeMedianAD(int lev) -{ - checkCudaErrors(cudaFreeHost(parH[lev]->vx_SP_Med)); - checkCudaErrors(cudaFreeHost(parH[lev]->vy_SP_Med)); - checkCudaErrors(cudaFreeHost(parH[lev]->vz_SP_Med)); - checkCudaErrors(cudaFreeHost(parH[lev]->rho_SP_Med)); - checkCudaErrors(cudaFreeHost(parH[lev]->press_SP_Med)); - checkCudaErrors(cudaFreeHost(parH[lev]->Conc_Med)); -} -void Parameter::cudaAllocMedianOutAD(int lev) -{ - //Host - checkCudaErrors(cudaMallocHost((void**) &(parH[lev]->rho_SP_Med_Out), parH[lev]->mem_size_real_SP)); - checkCudaErrors(cudaMallocHost((void**) &(parH[lev]->vx_SP_Med_Out), parH[lev]->mem_size_real_SP)); - checkCudaErrors(cudaMallocHost((void**) &(parH[lev]->vy_SP_Med_Out), parH[lev]->mem_size_real_SP)); - checkCudaErrors(cudaMallocHost((void**) &(parH[lev]->vz_SP_Med_Out), parH[lev]->mem_size_real_SP)); - checkCudaErrors(cudaMallocHost((void**) &(parH[lev]->press_SP_Med_Out), parH[lev]->mem_size_real_SP)); - checkCudaErrors(cudaMallocHost((void**) &(parH[lev]->Conc_Med_Out), parH[lev]->mem_size_real_SP)); -} -void Parameter::cudaFreeMedianOutAD(int lev) -{ - checkCudaErrors(cudaFreeHost(parH[lev]->vx_SP_Med_Out)); - checkCudaErrors(cudaFreeHost(parH[lev]->vy_SP_Med_Out)); - checkCudaErrors(cudaFreeHost(parH[lev]->vz_SP_Med_Out)); - checkCudaErrors(cudaFreeHost(parH[lev]->rho_SP_Med_Out)); - checkCudaErrors(cudaFreeHost(parH[lev]->press_SP_Med_Out)); - checkCudaErrors(cudaFreeHost(parH[lev]->Conc_Med_Out)); -} - -//Interface CF -void Parameter::cudaAllocInterfaceCF(int lev) -{ - //Host - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->intCF.ICellCFC), parH[lev]->mem_size_kCF )); - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->intCF.ICellCFF), parH[lev]->mem_size_kCF )); - //Device - checkCudaErrors( cudaMalloc((void**) &(parD[lev]->intCF.ICellCFC), parD[lev]->mem_size_kCF )); - checkCudaErrors( cudaMalloc((void**) &(parD[lev]->intCF.ICellCFF), parD[lev]->mem_size_kCF )); - ////////////////////////////////////////////////////////////////////////// - double tmp = 2. * (double)parH[lev]->mem_size_kCF; - setMemsizeGPU(tmp, false); -} -void Parameter::cudaCopyInterfaceCF(int lev) -{ - checkCudaErrors( cudaMemcpy(parD[lev]->intCF.ICellCFC, parH[lev]->intCF.ICellCFC, parH[lev]->mem_size_kCF, cudaMemcpyHostToDevice)); - checkCudaErrors( cudaMemcpy(parD[lev]->intCF.ICellCFF, parH[lev]->intCF.ICellCFF, parH[lev]->mem_size_kCF, cudaMemcpyHostToDevice)); -} -void Parameter::cudaFreeInterfaceCF(int lev) -{ - checkCudaErrors( cudaFreeHost(parH[lev]->intCF.ICellCFC)); - checkCudaErrors( cudaFreeHost(parH[lev]->intCF.ICellCFF)); -} -//Interface FC -void Parameter::cudaAllocInterfaceFC(int lev) -{ - //Host - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->intFC.ICellFCF), parH[lev]->mem_size_kFC )); - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->intFC.ICellFCC), parH[lev]->mem_size_kFC )); - //Device - checkCudaErrors( cudaMalloc((void**) &(parD[lev]->intFC.ICellFCF), parD[lev]->mem_size_kFC )); - checkCudaErrors( cudaMalloc((void**) &(parD[lev]->intFC.ICellFCC), parD[lev]->mem_size_kFC )); - ////////////////////////////////////////////////////////////////////////// - double tmp = 2. * (double)parH[lev]->mem_size_kFC; - setMemsizeGPU(tmp, false); -} -void Parameter::cudaCopyInterfaceFC(int lev) -{ - checkCudaErrors( cudaMemcpy(parD[lev]->intFC.ICellFCF, parH[lev]->intFC.ICellFCF, parH[lev]->mem_size_kFC, cudaMemcpyHostToDevice)); - checkCudaErrors( cudaMemcpy(parD[lev]->intFC.ICellFCC, parH[lev]->intFC.ICellFCC, parH[lev]->mem_size_kFC, cudaMemcpyHostToDevice)); -} -void Parameter::cudaFreeInterfaceFC(int lev) -{ - checkCudaErrors( cudaFreeHost(parH[lev]->intFC.ICellFCF)); - checkCudaErrors( cudaFreeHost(parH[lev]->intFC.ICellFCC)); -} -//Interface Offset CF -void Parameter::cudaAllocInterfaceOffCF(int lev) -{ - //Host - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->offCF.xOffCF), parH[lev]->mem_size_kCF_off )); - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->offCF.yOffCF), parH[lev]->mem_size_kCF_off )); - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->offCF.zOffCF), parH[lev]->mem_size_kCF_off )); - getLastCudaError("Allocate host memory"); - //Device - checkCudaErrors( cudaMalloc((void**) &(parD[lev]->offCF.xOffCF), parD[lev]->mem_size_kCF_off )); - checkCudaErrors( cudaMalloc((void**) &(parD[lev]->offCF.yOffCF), parD[lev]->mem_size_kCF_off )); - checkCudaErrors( cudaMalloc((void**) &(parD[lev]->offCF.zOffCF), parD[lev]->mem_size_kCF_off )); - getLastCudaError("Allocate device memory"); - ////////////////////////////////////////////////////////////////////////// - double tmp = 3. * (double)parH[lev]->mem_size_kCF_off; - setMemsizeGPU(tmp, false); -} -void Parameter::cudaCopyInterfaceOffCF(int lev) -{ - checkCudaErrors( cudaMemcpy(parD[lev]->offCF.xOffCF, parH[lev]->offCF.xOffCF, parH[lev]->mem_size_kCF_off, cudaMemcpyHostToDevice)); - checkCudaErrors( cudaMemcpy(parD[lev]->offCF.yOffCF, parH[lev]->offCF.yOffCF, parH[lev]->mem_size_kCF_off, cudaMemcpyHostToDevice)); - checkCudaErrors( cudaMemcpy(parD[lev]->offCF.zOffCF, parH[lev]->offCF.zOffCF, parH[lev]->mem_size_kCF_off, cudaMemcpyHostToDevice)); - getLastCudaError("Copy host memory to device"); -} -void Parameter::cudaFreeInterfaceOffCF(int lev) -{ - checkCudaErrors( cudaFreeHost(parH[lev]->offCF.xOffCF)); - checkCudaErrors( cudaFreeHost(parH[lev]->offCF.yOffCF)); - checkCudaErrors( cudaFreeHost(parH[lev]->offCF.zOffCF)); -} -//Interface Offset FC -void Parameter::cudaAllocInterfaceOffFC(int lev) -{ - //Host - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->offFC.xOffFC), parH[lev]->mem_size_kFC_off )); - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->offFC.yOffFC), parH[lev]->mem_size_kFC_off )); - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->offFC.zOffFC), parH[lev]->mem_size_kFC_off )); - getLastCudaError("Allocate host memory"); - //Device - checkCudaErrors( cudaMalloc((void**) &(parD[lev]->offFC.xOffFC), parD[lev]->mem_size_kFC_off )); - checkCudaErrors( cudaMalloc((void**) &(parD[lev]->offFC.yOffFC), parD[lev]->mem_size_kFC_off )); - checkCudaErrors( cudaMalloc((void**) &(parD[lev]->offFC.zOffFC), parD[lev]->mem_size_kFC_off )); - getLastCudaError("Allocate device memory"); - ////////////////////////////////////////////////////////////////////////// - double tmp = 3. * (double)parH[lev]->mem_size_kFC_off; - setMemsizeGPU(tmp, false); -} -void Parameter::cudaCopyInterfaceOffFC(int lev) -{ - checkCudaErrors( cudaMemcpy(parD[lev]->offFC.xOffFC, parH[lev]->offFC.xOffFC, parH[lev]->mem_size_kFC_off, cudaMemcpyHostToDevice)); - checkCudaErrors( cudaMemcpy(parD[lev]->offFC.yOffFC, parH[lev]->offFC.yOffFC, parH[lev]->mem_size_kFC_off, cudaMemcpyHostToDevice)); - checkCudaErrors( cudaMemcpy(parD[lev]->offFC.zOffFC, parH[lev]->offFC.zOffFC, parH[lev]->mem_size_kFC_off, cudaMemcpyHostToDevice)); - getLastCudaError("Copy host memory to device"); -} -void Parameter::cudaFreeInterfaceOffFC(int lev) -{ - checkCudaErrors( cudaFreeHost(parH[lev]->offFC.xOffFC)); - checkCudaErrors( cudaFreeHost(parH[lev]->offFC.yOffFC)); - checkCudaErrors( cudaFreeHost(parH[lev]->offFC.zOffFC)); -} - -//Velo -void Parameter::cudaAllocVeloBC(int lev) -{ - unsigned int mem_size_inflow_Q_k = sizeof(int)*parH[lev]->Qinflow.kArray; - unsigned int mem_size_inflow_Q_q = sizeof(real)*parH[lev]->Qinflow.kArray; - //unsigned int mem_size_inflow_Q_k = sizeof(int)*parH[lev]->Qinflow.kQ; - //unsigned int mem_size_inflow_Q_q = sizeof(real)*parH[lev]->Qinflow.kQ; - - //Host - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->Qinflow.q27[0]), getD3Qxx()*mem_size_inflow_Q_q )); - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->Qinflow.k), mem_size_inflow_Q_k )); - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->Qinflow.Vx), mem_size_inflow_Q_q )); - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->Qinflow.Vy), mem_size_inflow_Q_q )); - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->Qinflow.Vz), mem_size_inflow_Q_q )); - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->Qinflow.deltaVz), mem_size_inflow_Q_q )); - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->Qinflow.RhoBC), mem_size_inflow_Q_q )); - - //Device - checkCudaErrors( cudaMalloc((void**) &(parD[lev]->Qinflow.q27[0]), getD3Qxx()*mem_size_inflow_Q_q )); - checkCudaErrors( cudaMalloc((void**) &(parD[lev]->Qinflow.k), mem_size_inflow_Q_k )); - checkCudaErrors( cudaMalloc((void**) &(parD[lev]->Qinflow.Vx), mem_size_inflow_Q_q )); - checkCudaErrors( cudaMalloc((void**) &(parD[lev]->Qinflow.Vy), mem_size_inflow_Q_q )); - checkCudaErrors( cudaMalloc((void**) &(parD[lev]->Qinflow.Vz), mem_size_inflow_Q_q )); - checkCudaErrors( cudaMalloc((void**) &(parD[lev]->Qinflow.deltaVz), mem_size_inflow_Q_q )); - - ////////////////////////////////////////////////////////////////////////// - double tmp = (double)mem_size_inflow_Q_k + 4. * (double)mem_size_inflow_Q_q + (double)getD3Qxx() * (double)mem_size_inflow_Q_q; - setMemsizeGPU(tmp, false); -} -void Parameter::cudaCopyVeloBC(int lev) -{ - unsigned int mem_size_inflow_Q_k = sizeof(int)*parH[lev]->Qinflow.kArray; - unsigned int mem_size_inflow_Q_q = sizeof(real)*parH[lev]->Qinflow.kArray; - //unsigned int mem_size_inflow_Q_k = sizeof(int)*parH[lev]->Qinflow.kQ; - //unsigned int mem_size_inflow_Q_q = sizeof(real)*parH[lev]->Qinflow.kQ; - - checkCudaErrors( cudaMemcpy(parD[lev]->Qinflow.q27[0], parH[lev]->Qinflow.q27[0], getD3Qxx()* mem_size_inflow_Q_q, cudaMemcpyHostToDevice)); - checkCudaErrors( cudaMemcpy(parD[lev]->Qinflow.k, parH[lev]->Qinflow.k, mem_size_inflow_Q_k, cudaMemcpyHostToDevice)); - checkCudaErrors( cudaMemcpy(parD[lev]->Qinflow.Vx, parH[lev]->Qinflow.Vx, mem_size_inflow_Q_q, cudaMemcpyHostToDevice)); - checkCudaErrors( cudaMemcpy(parD[lev]->Qinflow.Vy, parH[lev]->Qinflow.Vy, mem_size_inflow_Q_q, cudaMemcpyHostToDevice)); - checkCudaErrors( cudaMemcpy(parD[lev]->Qinflow.Vz, parH[lev]->Qinflow.Vz, mem_size_inflow_Q_q, cudaMemcpyHostToDevice)); - checkCudaErrors( cudaMemcpy(parD[lev]->Qinflow.deltaVz, parH[lev]->Qinflow.deltaVz, mem_size_inflow_Q_q, cudaMemcpyHostToDevice)); - -} -void Parameter::cudaFreeVeloBC(int lev) -{ - checkCudaErrors( cudaFreeHost(parH[lev]->Qinflow.q27[0] )); - checkCudaErrors( cudaFreeHost(parH[lev]->Qinflow.k )); - checkCudaErrors( cudaFreeHost(parH[lev]->Qinflow.Vx )); - checkCudaErrors( cudaFreeHost(parH[lev]->Qinflow.Vy )); - checkCudaErrors( cudaFreeHost(parH[lev]->Qinflow.Vz )); - checkCudaErrors( cudaFreeHost(parH[lev]->Qinflow.deltaVz)); -} -//Press -void Parameter::cudaAllocOutflowBC(int lev) -{ - unsigned int mem_size_outflow_Q_k = sizeof(int)*parH[lev]->Qoutflow.kQ; - unsigned int mem_size_outflow_Q_q = sizeof(real)*parH[lev]->Qoutflow.kQ; - - //Host - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->Qoutflow.q27[0]), getD3Qxx()*mem_size_outflow_Q_q )); - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->Qoutflow.k), mem_size_outflow_Q_k )); - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->Qoutflow.kN), mem_size_outflow_Q_k )); - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->Qoutflow.RhoBC), mem_size_outflow_Q_q )); - - //Device - checkCudaErrors( cudaMalloc((void**) &(parD[lev]->Qoutflow.q27[0]), getD3Qxx()* mem_size_outflow_Q_q )); - checkCudaErrors( cudaMalloc((void**) &(parD[lev]->Qoutflow.k), mem_size_outflow_Q_k )); - checkCudaErrors( cudaMalloc((void**) &(parD[lev]->Qoutflow.kN), mem_size_outflow_Q_k )); - checkCudaErrors( cudaMalloc((void**) &(parD[lev]->Qoutflow.RhoBC), mem_size_outflow_Q_q )); - - ////////////////////////////////////////////////////////////////////////// - double tmp = (double)mem_size_outflow_Q_k + 2. * (double)mem_size_outflow_Q_q + (double)getD3Qxx()*(double)mem_size_outflow_Q_q; - setMemsizeGPU(tmp, false); -} -void Parameter::cudaCopyOutflowBC(int lev) -{ - unsigned int mem_size_outflow_Q_k = sizeof(int)*parH[lev]->Qoutflow.kQ; - unsigned int mem_size_outflow_Q_q = sizeof(real)*parH[lev]->Qoutflow.kQ; - - checkCudaErrors( cudaMemcpy(parD[lev]->Qoutflow.q27[0], parH[lev]->Qoutflow.q27[0], getD3Qxx()* mem_size_outflow_Q_q, cudaMemcpyHostToDevice)); - checkCudaErrors( cudaMemcpy(parD[lev]->Qoutflow.k, parH[lev]->Qoutflow.k, mem_size_outflow_Q_k, cudaMemcpyHostToDevice)); - checkCudaErrors( cudaMemcpy(parD[lev]->Qoutflow.kN, parH[lev]->Qoutflow.kN, mem_size_outflow_Q_k, cudaMemcpyHostToDevice)); - checkCudaErrors( cudaMemcpy(parD[lev]->Qoutflow.RhoBC, parH[lev]->Qoutflow.RhoBC, mem_size_outflow_Q_q, cudaMemcpyHostToDevice)); -} -void Parameter::cudaFreeOutflowBC(int lev) -{ - checkCudaErrors( cudaFreeHost(parH[lev]->Qoutflow.q27[0] )); - checkCudaErrors( cudaFreeHost(parH[lev]->Qoutflow.k )); - checkCudaErrors( cudaFreeHost(parH[lev]->Qoutflow.kN )); - checkCudaErrors( cudaFreeHost(parH[lev]->Qoutflow.RhoBC )); -} -//Inlet -void Parameter::cudaAllocInlet(int lev) -{ - unsigned int mem_size_inlet_Q_k = sizeof(int)*parH[lev]->QInlet.kQ; - unsigned int mem_size_inlet_Q_q = sizeof(real)*parH[lev]->QInlet.kQ; - - //Host - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->QInlet.q27[0]), getD3Qxx()*mem_size_inlet_Q_q )); - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->QInlet.k), mem_size_inlet_Q_k )); - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->QInlet.kN), mem_size_inlet_Q_k )); - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->QInlet.RhoBC), mem_size_inlet_Q_q )); - - //Device - checkCudaErrors( cudaMalloc((void**) &(parD[lev]->QInlet.q27[0]), getD3Qxx()* mem_size_inlet_Q_q )); - checkCudaErrors( cudaMalloc((void**) &(parD[lev]->QInlet.k), mem_size_inlet_Q_k )); - checkCudaErrors( cudaMalloc((void**) &(parD[lev]->QInlet.kN), mem_size_inlet_Q_k )); - checkCudaErrors( cudaMalloc((void**) &(parD[lev]->QInlet.RhoBC), mem_size_inlet_Q_q )); - - ////////////////////////////////////////////////////////////////////////// - double tmp = 2. * (double)mem_size_inlet_Q_k + (double)mem_size_inlet_Q_q + (double)getD3Qxx()*(double)mem_size_inlet_Q_q; - setMemsizeGPU(tmp, false); -} -void Parameter::cudaCopyInlet(int lev) -{ - unsigned int mem_size_inlet_Q_k = sizeof(int)*parH[lev]->QInlet.kQ; - unsigned int mem_size_inlet_Q_q = sizeof(real)*parH[lev]->QInlet.kQ; - - checkCudaErrors( cudaMemcpy(parD[lev]->QInlet.q27[0], parH[lev]->QInlet.q27[0], getD3Qxx()* mem_size_inlet_Q_q, cudaMemcpyHostToDevice)); - checkCudaErrors( cudaMemcpy(parD[lev]->QInlet.k, parH[lev]->QInlet.k, mem_size_inlet_Q_k, cudaMemcpyHostToDevice)); - checkCudaErrors( cudaMemcpy(parD[lev]->QInlet.kN, parH[lev]->QInlet.kN, mem_size_inlet_Q_k, cudaMemcpyHostToDevice)); - checkCudaErrors( cudaMemcpy(parD[lev]->QInlet.RhoBC, parH[lev]->QInlet.RhoBC, mem_size_inlet_Q_q, cudaMemcpyHostToDevice)); -} -void Parameter::cudaFreeInlet(int lev) -{ - checkCudaErrors( cudaFreeHost(parH[lev]->QInlet.q27[0] )); - checkCudaErrors( cudaFreeHost(parH[lev]->QInlet.k )); - checkCudaErrors( cudaFreeHost(parH[lev]->QInlet.kN )); - checkCudaErrors( cudaFreeHost(parH[lev]->QInlet.RhoBC )); -} -//Outlet -void Parameter::cudaAllocOutlet(int lev) -{ - unsigned int mem_size_outlet_Q_k = sizeof(int)*parH[lev]->QOutlet.kQ; - unsigned int mem_size_outlet_Q_q = sizeof(real)*parH[lev]->QOutlet.kQ; - - //Host - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->QOutlet.q27[0]), getD3Qxx()*mem_size_outlet_Q_q )); - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->QOutlet.k), mem_size_outlet_Q_k )); - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->QOutlet.kN), mem_size_outlet_Q_k )); - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->QOutlet.RhoBC), mem_size_outlet_Q_q )); - - //Device - checkCudaErrors( cudaMalloc((void**) &(parD[lev]->QOutlet.q27[0]), getD3Qxx()* mem_size_outlet_Q_q )); - checkCudaErrors( cudaMalloc((void**) &(parD[lev]->QOutlet.k), mem_size_outlet_Q_k )); - checkCudaErrors( cudaMalloc((void**) &(parD[lev]->QOutlet.kN), mem_size_outlet_Q_k )); - checkCudaErrors( cudaMalloc((void**) &(parD[lev]->QOutlet.RhoBC), mem_size_outlet_Q_q )); - - ////////////////////////////////////////////////////////////////////////// - double tmp = 2. * (double)mem_size_outlet_Q_k + (double)mem_size_outlet_Q_q + (double)getD3Qxx()*(double)mem_size_outlet_Q_q; - setMemsizeGPU(tmp, false); -} -void Parameter::cudaCopyOutlet(int lev) -{ - unsigned int mem_size_outlet_Q_k = sizeof(int)*parH[lev]->QOutlet.kQ; - unsigned int mem_size_outlet_Q_q = sizeof(real)*parH[lev]->QOutlet.kQ; - - checkCudaErrors( cudaMemcpy(parD[lev]->QOutlet.q27[0], parH[lev]->QOutlet.q27[0], getD3Qxx()* mem_size_outlet_Q_q, cudaMemcpyHostToDevice)); - checkCudaErrors( cudaMemcpy(parD[lev]->QOutlet.k, parH[lev]->QOutlet.k, mem_size_outlet_Q_k, cudaMemcpyHostToDevice)); - checkCudaErrors( cudaMemcpy(parD[lev]->QOutlet.kN, parH[lev]->QOutlet.kN, mem_size_outlet_Q_k, cudaMemcpyHostToDevice)); - checkCudaErrors( cudaMemcpy(parD[lev]->QOutlet.RhoBC, parH[lev]->QOutlet.RhoBC, mem_size_outlet_Q_q, cudaMemcpyHostToDevice)); -} -void Parameter::cudaFreeOutlet(int lev) -{ - checkCudaErrors( cudaFreeHost(parH[lev]->QOutlet.q27[0] )); - checkCudaErrors( cudaFreeHost(parH[lev]->QOutlet.k )); - checkCudaErrors( cudaFreeHost(parH[lev]->QOutlet.kN )); - checkCudaErrors( cudaFreeHost(parH[lev]->QOutlet.RhoBC )); -} -//Wall -void Parameter::cudaAllocWallBC(int lev) -{ - unsigned int mem_size_Q_k = sizeof(int)*parH[lev]->QWall.kQ; - unsigned int mem_size_Q_q = sizeof(real)*parH[lev]->QWall.kQ; - unsigned int mem_size_Q_value = sizeof(long long)*parH[lev]->QWall.kQ; //Geller - unsigned int mem_size_Q_q_read = sizeof(real)*parH[lev]->kQread; //Geller - - //Host - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->QWall.q27[0]), getD3Qxx()*mem_size_Q_q )); - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->QWall.k), mem_size_Q_k )); - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->QWall.qread), mem_size_Q_q_read ));//Geller - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->QWall.valueQ), mem_size_Q_value ));//Geller - - //Device - checkCudaErrors( cudaMalloc((void**) &(parD[lev]->QWall.q27[0]), getD3Qxx()* mem_size_Q_q )); - checkCudaErrors( cudaMalloc((void**) &(parD[lev]->QWall.k), mem_size_Q_k )); - - ////////////////////////////////////////////////////////////////////////// - double tmp = (double)mem_size_Q_k + (double)getD3Qxx()*(double)mem_size_Q_q; - setMemsizeGPU(tmp, false); -} -void Parameter::cudaCopyWallBC(int lev) -{ - unsigned int mem_size_Q_k = sizeof(int)*parH[lev]->QWall.kQ; - unsigned int mem_size_Q_q = sizeof(real)*parH[lev]->QWall.kQ; - - checkCudaErrors( cudaMemcpy(parD[lev]->QWall.q27[0], parH[lev]->QWall.q27[0], getD3Qxx()* mem_size_Q_q, cudaMemcpyHostToDevice)); - checkCudaErrors( cudaMemcpy(parD[lev]->QWall.k, parH[lev]->QWall.k, mem_size_Q_k, cudaMemcpyHostToDevice)); -} -void Parameter::cudaFreeWallBC(int lev) -{ - checkCudaErrors( cudaFreeHost(parH[lev]->QWall.q27[0])); - checkCudaErrors( cudaFreeHost(parH[lev]->QWall.k)); - checkCudaErrors( cudaFreeHost(parH[lev]->QWall.valueQ)); - checkCudaErrors( cudaFreeHost(parH[lev]->QWall.qread)); -} -//Geometrie -void Parameter::cudaAllocGeomBC(int lev) -{ - unsigned int mem_size_Q_k = sizeof(int)*parH[lev]->QGeom.kQ; - unsigned int mem_size_Q_q = sizeof(real)*parH[lev]->QGeom.kQ; - - //Host - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->QGeom.q27[0]), getD3Qxx()*mem_size_Q_q )); - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->QGeom.k), mem_size_Q_k )); - - //Device - checkCudaErrors( cudaMalloc((void**) &(parD[lev]->QGeom.q27[0]), getD3Qxx()* mem_size_Q_q )); - checkCudaErrors( cudaMalloc((void**) &(parD[lev]->QGeom.k), mem_size_Q_k )); - - ////////////////////////////////////////////////////////////////////////// - double tmp = (double)mem_size_Q_k + (double)getD3Qxx()*(double)mem_size_Q_q; - setMemsizeGPU(tmp, false); -} -void Parameter::cudaCopyGeomBC(int lev) -{ - unsigned int mem_size_Q_k = sizeof(int)*parH[lev]->QGeom.kQ; - unsigned int mem_size_Q_q = sizeof(real)*parH[lev]->QGeom.kQ; - - checkCudaErrors( cudaMemcpy(parD[lev]->QGeom.q27[0], parH[lev]->QGeom.q27[0], getD3Qxx()* mem_size_Q_q, cudaMemcpyHostToDevice)); - checkCudaErrors( cudaMemcpy(parD[lev]->QGeom.k, parH[lev]->QGeom.k, mem_size_Q_k, cudaMemcpyHostToDevice)); -} -void Parameter::cudaFreeGeomBC(int lev) -{ - checkCudaErrors( cudaFreeHost(parH[lev]->QGeom.q27[0])); - checkCudaErrors( cudaFreeHost(parH[lev]->QGeom.k)); -} -//Geometrie inkl. Values -void Parameter::cudaAllocGeomValuesBC(int lev) -{ - unsigned int mem_size_Q_q = sizeof(real)*parH[lev]->QGeom.kQ; - - //Host - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->QGeom.Vx), mem_size_Q_q )); - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->QGeom.Vy), mem_size_Q_q )); - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->QGeom.Vz), mem_size_Q_q )); - - //Device - checkCudaErrors( cudaMalloc((void**) &(parD[lev]->QGeom.Vx), mem_size_Q_q )); - checkCudaErrors( cudaMalloc((void**) &(parD[lev]->QGeom.Vy), mem_size_Q_q )); - checkCudaErrors( cudaMalloc((void**) &(parD[lev]->QGeom.Vz), mem_size_Q_q )); - - ////////////////////////////////////////////////////////////////////////// - double tmp = 3. * (double)mem_size_Q_q; - setMemsizeGPU(tmp, false); -} -void Parameter::cudaCopyGeomValuesBC(int lev) -{ - unsigned int mem_size_Q_q = sizeof(real)*parH[lev]->QGeom.kQ; - - checkCudaErrors( cudaMemcpy(parD[lev]->QGeom.Vx, parH[lev]->QGeom.Vx, mem_size_Q_q, cudaMemcpyHostToDevice)); - checkCudaErrors( cudaMemcpy(parD[lev]->QGeom.Vy, parH[lev]->QGeom.Vy, mem_size_Q_q, cudaMemcpyHostToDevice)); - checkCudaErrors( cudaMemcpy(parD[lev]->QGeom.Vz, parH[lev]->QGeom.Vz, mem_size_Q_q, cudaMemcpyHostToDevice)); -} -void Parameter::cudaFreeGeomValuesBC(int lev) -{ - checkCudaErrors( cudaFreeHost(parH[lev]->QGeom.Vx)); - checkCudaErrors( cudaFreeHost(parH[lev]->QGeom.Vy)); - checkCudaErrors( cudaFreeHost(parH[lev]->QGeom.Vz)); -} -//Geometrie inkl. Normale fuer Slip -void Parameter::cudaAllocGeomNormals(int lev) -{ - unsigned int mem_size_Q_k = sizeof(int)*parH[lev]->QGeomNormalX.kQ; - unsigned int mem_size_Q_q = sizeof(real)*parH[lev]->QGeomNormalX.kQ; - - //Host - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->QGeomNormalX.q27[0]), getD3Qxx()*mem_size_Q_q )); - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->QGeomNormalX.k), mem_size_Q_k )); - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->QGeomNormalY.q27[0]), getD3Qxx()*mem_size_Q_q )); - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->QGeomNormalY.k), mem_size_Q_k )); - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->QGeomNormalZ.q27[0]), getD3Qxx()*mem_size_Q_q )); - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->QGeomNormalZ.k), mem_size_Q_k )); - - //Device - checkCudaErrors( cudaMalloc((void**) &(parD[lev]->QGeomNormalX.q27[0]), getD3Qxx()* mem_size_Q_q )); - checkCudaErrors( cudaMalloc((void**) &(parD[lev]->QGeomNormalX.k), mem_size_Q_k )); - checkCudaErrors( cudaMalloc((void**) &(parD[lev]->QGeomNormalY.q27[0]), getD3Qxx()* mem_size_Q_q )); - checkCudaErrors( cudaMalloc((void**) &(parD[lev]->QGeomNormalY.k), mem_size_Q_k )); - checkCudaErrors( cudaMalloc((void**) &(parD[lev]->QGeomNormalZ.q27[0]), getD3Qxx()* mem_size_Q_q )); - checkCudaErrors( cudaMalloc((void**) &(parD[lev]->QGeomNormalZ.k), mem_size_Q_k )); - - ////////////////////////////////////////////////////////////////////////// - double tmp = 3.0 * (double)mem_size_Q_k + 3.0 * (double)getD3Qxx()*(double)mem_size_Q_q; - setMemsizeGPU(tmp, false); -} -void Parameter::cudaCopyGeomNormals(int lev) -{ - unsigned int mem_size_Q_k = sizeof(int)*parH[lev]->QGeomNormalX.kQ; - unsigned int mem_size_Q_q = sizeof(real)*parH[lev]->QGeomNormalX.kQ; - - checkCudaErrors( cudaMemcpy(parD[lev]->QGeomNormalX.q27[0], parH[lev]->QGeomNormalX.q27[0], getD3Qxx()* mem_size_Q_q, cudaMemcpyHostToDevice)); - checkCudaErrors( cudaMemcpy(parD[lev]->QGeomNormalX.k, parH[lev]->QGeomNormalX.k, mem_size_Q_k, cudaMemcpyHostToDevice)); - checkCudaErrors( cudaMemcpy(parD[lev]->QGeomNormalY.q27[0], parH[lev]->QGeomNormalY.q27[0], getD3Qxx()* mem_size_Q_q, cudaMemcpyHostToDevice)); - checkCudaErrors( cudaMemcpy(parD[lev]->QGeomNormalY.k, parH[lev]->QGeomNormalY.k, mem_size_Q_k, cudaMemcpyHostToDevice)); - checkCudaErrors( cudaMemcpy(parD[lev]->QGeomNormalZ.q27[0], parH[lev]->QGeomNormalZ.q27[0], getD3Qxx()* mem_size_Q_q, cudaMemcpyHostToDevice)); - checkCudaErrors( cudaMemcpy(parD[lev]->QGeomNormalZ.k, parH[lev]->QGeomNormalZ.k, mem_size_Q_k, cudaMemcpyHostToDevice)); -} -void Parameter::cudaFreeGeomNormals(int lev) -{ - checkCudaErrors( cudaFreeHost(parH[lev]->QGeomNormalX.q27[0])); - checkCudaErrors( cudaFreeHost(parH[lev]->QGeomNormalX.k)); - checkCudaErrors( cudaFreeHost(parH[lev]->QGeomNormalY.q27[0])); - checkCudaErrors( cudaFreeHost(parH[lev]->QGeomNormalY.k)); - checkCudaErrors( cudaFreeHost(parH[lev]->QGeomNormalZ.q27[0])); - checkCudaErrors( cudaFreeHost(parH[lev]->QGeomNormalZ.k)); -} -//Geometrie inkl. Normale fuer Inflow -void Parameter::cudaAllocInflowNormals(int lev) -{ - unsigned int mem_size_Q_k = sizeof(int)*parH[lev]->QInflowNormalX.kQ; - unsigned int mem_size_Q_q = sizeof(real)*parH[lev]->QInflowNormalX.kQ; - - //Host - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->QInflowNormalX.q27[0]), getD3Qxx()*mem_size_Q_q )); - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->QInflowNormalX.k), mem_size_Q_k )); - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->QInflowNormalY.q27[0]), getD3Qxx()*mem_size_Q_q )); - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->QInflowNormalY.k), mem_size_Q_k )); - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->QInflowNormalZ.q27[0]), getD3Qxx()*mem_size_Q_q )); - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->QInflowNormalZ.k), mem_size_Q_k )); - - //Device - checkCudaErrors( cudaMalloc((void**) &(parD[lev]->QInflowNormalX.q27[0]), getD3Qxx()* mem_size_Q_q )); - checkCudaErrors( cudaMalloc((void**) &(parD[lev]->QInflowNormalX.k), mem_size_Q_k )); - checkCudaErrors( cudaMalloc((void**) &(parD[lev]->QInflowNormalY.q27[0]), getD3Qxx()* mem_size_Q_q )); - checkCudaErrors( cudaMalloc((void**) &(parD[lev]->QInflowNormalY.k), mem_size_Q_k )); - checkCudaErrors( cudaMalloc((void**) &(parD[lev]->QInflowNormalZ.q27[0]), getD3Qxx()* mem_size_Q_q )); - checkCudaErrors( cudaMalloc((void**) &(parD[lev]->QInflowNormalZ.k), mem_size_Q_k )); - - ////////////////////////////////////////////////////////////////////////// - double tmp = 3.0 * (double)mem_size_Q_k + 3.0 * (double)getD3Qxx()*(double)mem_size_Q_q; - setMemsizeGPU(tmp, false); -} -void Parameter::cudaCopyInflowNormals(int lev) -{ - unsigned int mem_size_Q_k = sizeof(int)*parH[lev]->QInflowNormalX.kQ; - unsigned int mem_size_Q_q = sizeof(real)*parH[lev]->QInflowNormalX.kQ; - - checkCudaErrors( cudaMemcpy(parD[lev]->QInflowNormalX.q27[0], parH[lev]->QInflowNormalX.q27[0], getD3Qxx()* mem_size_Q_q, cudaMemcpyHostToDevice)); - checkCudaErrors( cudaMemcpy(parD[lev]->QInflowNormalX.k, parH[lev]->QInflowNormalX.k, mem_size_Q_k, cudaMemcpyHostToDevice)); - checkCudaErrors( cudaMemcpy(parD[lev]->QInflowNormalY.q27[0], parH[lev]->QInflowNormalY.q27[0], getD3Qxx()* mem_size_Q_q, cudaMemcpyHostToDevice)); - checkCudaErrors( cudaMemcpy(parD[lev]->QInflowNormalY.k, parH[lev]->QInflowNormalY.k, mem_size_Q_k, cudaMemcpyHostToDevice)); - checkCudaErrors( cudaMemcpy(parD[lev]->QInflowNormalZ.q27[0], parH[lev]->QInflowNormalZ.q27[0], getD3Qxx()* mem_size_Q_q, cudaMemcpyHostToDevice)); - checkCudaErrors( cudaMemcpy(parD[lev]->QInflowNormalZ.k, parH[lev]->QInflowNormalZ.k, mem_size_Q_k, cudaMemcpyHostToDevice)); -} -void Parameter::cudaFreeInflowNormals(int lev) -{ - checkCudaErrors( cudaFreeHost(parH[lev]->QInflowNormalX.q27[0])); - checkCudaErrors( cudaFreeHost(parH[lev]->QInflowNormalX.k)); - checkCudaErrors( cudaFreeHost(parH[lev]->QInflowNormalY.q27[0])); - checkCudaErrors( cudaFreeHost(parH[lev]->QInflowNormalY.k)); - checkCudaErrors( cudaFreeHost(parH[lev]->QInflowNormalZ.q27[0])); - checkCudaErrors( cudaFreeHost(parH[lev]->QInflowNormalZ.k)); -} -//Geometrie inkl. Normale fuer Outflow -void Parameter::cudaAllocOutflowNormals(int lev) -{ - unsigned int mem_size_Q_k = sizeof(int)*parH[lev]->QOutflowNormalX.kQ; - unsigned int mem_size_Q_q = sizeof(real)*parH[lev]->QOutflowNormalX.kQ; - - //Host - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->QOutflowNormalX.q27[0]), getD3Qxx()*mem_size_Q_q )); - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->QOutflowNormalX.k), mem_size_Q_k )); - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->QOutflowNormalY.q27[0]), getD3Qxx()*mem_size_Q_q )); - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->QOutflowNormalY.k), mem_size_Q_k )); - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->QOutflowNormalZ.q27[0]), getD3Qxx()*mem_size_Q_q )); - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->QOutflowNormalZ.k), mem_size_Q_k )); - - //Device - checkCudaErrors( cudaMalloc((void**) &(parD[lev]->QOutflowNormalX.q27[0]), getD3Qxx()* mem_size_Q_q )); - checkCudaErrors( cudaMalloc((void**) &(parD[lev]->QOutflowNormalX.k), mem_size_Q_k )); - checkCudaErrors( cudaMalloc((void**) &(parD[lev]->QOutflowNormalY.q27[0]), getD3Qxx()* mem_size_Q_q )); - checkCudaErrors( cudaMalloc((void**) &(parD[lev]->QOutflowNormalY.k), mem_size_Q_k )); - checkCudaErrors( cudaMalloc((void**) &(parD[lev]->QOutflowNormalZ.q27[0]), getD3Qxx()* mem_size_Q_q )); - checkCudaErrors( cudaMalloc((void**) &(parD[lev]->QOutflowNormalZ.k), mem_size_Q_k )); - - ////////////////////////////////////////////////////////////////////////// - double tmp = 3.0 * (double)mem_size_Q_k + 3.0 * (double)getD3Qxx()*(double)mem_size_Q_q; - setMemsizeGPU(tmp, false); -} -void Parameter::cudaCopyOutflowNormals(int lev) -{ - unsigned int mem_size_Q_k = sizeof(int)*parH[lev]->QOutflowNormalX.kQ; - unsigned int mem_size_Q_q = sizeof(real)*parH[lev]->QOutflowNormalX.kQ; - - checkCudaErrors( cudaMemcpy(parD[lev]->QOutflowNormalX.q27[0], parH[lev]->QOutflowNormalX.q27[0], getD3Qxx()* mem_size_Q_q, cudaMemcpyHostToDevice)); - checkCudaErrors( cudaMemcpy(parD[lev]->QOutflowNormalX.k, parH[lev]->QOutflowNormalX.k, mem_size_Q_k, cudaMemcpyHostToDevice)); - checkCudaErrors( cudaMemcpy(parD[lev]->QOutflowNormalY.q27[0], parH[lev]->QOutflowNormalY.q27[0], getD3Qxx()* mem_size_Q_q, cudaMemcpyHostToDevice)); - checkCudaErrors( cudaMemcpy(parD[lev]->QOutflowNormalY.k, parH[lev]->QOutflowNormalY.k, mem_size_Q_k, cudaMemcpyHostToDevice)); - checkCudaErrors( cudaMemcpy(parD[lev]->QOutflowNormalZ.q27[0], parH[lev]->QOutflowNormalZ.q27[0], getD3Qxx()* mem_size_Q_q, cudaMemcpyHostToDevice)); - checkCudaErrors( cudaMemcpy(parD[lev]->QOutflowNormalZ.k, parH[lev]->QOutflowNormalZ.k, mem_size_Q_k, cudaMemcpyHostToDevice)); -} -void Parameter::cudaFreeOutflowNormals(int lev) -{ - checkCudaErrors( cudaFreeHost(parH[lev]->QOutflowNormalX.q27[0])); - checkCudaErrors( cudaFreeHost(parH[lev]->QOutflowNormalX.k)); - checkCudaErrors( cudaFreeHost(parH[lev]->QOutflowNormalY.q27[0])); - checkCudaErrors( cudaFreeHost(parH[lev]->QOutflowNormalY.k)); - checkCudaErrors( cudaFreeHost(parH[lev]->QOutflowNormalZ.q27[0])); - checkCudaErrors( cudaFreeHost(parH[lev]->QOutflowNormalZ.k)); -} -//Slip -void Parameter::cudaAllocSlipBC(int lev) -{ - unsigned int mem_size_Q_k = sizeof(int)*parH[lev]->QSlip.kQ; - unsigned int mem_size_Q_q = sizeof(real)*parH[lev]->QSlip.kQ; - //unsigned int mem_size_Q_value = sizeof(long long)*parH[lev]->QSlip.kQ; //Geller - //unsigned int mem_size_Q_q_read = sizeof(real)*parH[lev]->kSlipQread; //Geller - - //Host - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->QSlip.q27[0]), getD3Qxx()*mem_size_Q_q )); - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->QSlip.k), mem_size_Q_k )); - //checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->QSlip.qread), mem_size_Q_q_read ));//Geller - //checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->QSlip.valueQ), mem_size_Q_value ));//Geller - - //Device - checkCudaErrors( cudaMalloc((void**) &(parD[lev]->QSlip.q27[0]), getD3Qxx()* mem_size_Q_q )); - checkCudaErrors( cudaMalloc((void**) &(parD[lev]->QSlip.k), mem_size_Q_k )); - - ////////////////////////////////////////////////////////////////////////// - double tmp = (double)mem_size_Q_k + (double)getD3Qxx()*(double)mem_size_Q_q; - setMemsizeGPU(tmp, false); -} -void Parameter::cudaCopySlipBC(int lev) -{ - unsigned int mem_size_Q_k = sizeof(int)*parH[lev]->QSlip.kQ; - unsigned int mem_size_Q_q = sizeof(real)*parH[lev]->QSlip.kQ; - - checkCudaErrors( cudaMemcpy(parD[lev]->QSlip.q27[0], parH[lev]->QSlip.q27[0], getD3Qxx()* mem_size_Q_q, cudaMemcpyHostToDevice)); - checkCudaErrors( cudaMemcpy(parD[lev]->QSlip.k, parH[lev]->QSlip.k, mem_size_Q_k, cudaMemcpyHostToDevice)); -} -void Parameter::cudaFreeSlipBC(int lev) -{ - checkCudaErrors( cudaFreeHost(parH[lev]->QSlip.q27[0])); - checkCudaErrors( cudaFreeHost(parH[lev]->QSlip.k)); - //checkCudaErrors( cudaFreeHost(parH[lev]->QSlip.valueQ)); - //checkCudaErrors( cudaFreeHost(parH[lev]->QSlip.qread)); -} -//Press (no Geller) -void Parameter::cudaAllocPress(int lev) -{ - unsigned int mem_size_Q_k = sizeof(int)*parH[lev]->QPress.kQ; - unsigned int mem_size_Q_q = sizeof(real)*parH[lev]->QPress.kQ; - //unsigned int mem_size_Q_value = sizeof(long long)*parH[lev]->QPress.kQ; //Geller - //unsigned int mem_size_Q_q_read = sizeof(real)*parH[lev]->kPressQread; //Geller - - //Host - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->QPress.q27[0]), getD3Qxx()*mem_size_Q_q )); - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->QPress.k), mem_size_Q_k )); - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->QPress.kN), mem_size_Q_k )); - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->QPress.RhoBC), mem_size_Q_q )); - //checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->QPress.qread), mem_size_Q_q_read ));//Geller - //checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->QPress.valueQ), mem_size_Q_value ));//Geller - - //Device - checkCudaErrors( cudaMalloc((void**) &(parD[lev]->QPress.q27[0]), getD3Qxx()* mem_size_Q_q )); - checkCudaErrors( cudaMalloc((void**) &(parD[lev]->QPress.k), mem_size_Q_k )); - checkCudaErrors( cudaMalloc((void**) &(parD[lev]->QPress.kN), mem_size_Q_k )); - checkCudaErrors( cudaMalloc((void**) &(parD[lev]->QPress.RhoBC), mem_size_Q_q )); - - ////////////////////////////////////////////////////////////////////////// - double tmp = 2. * (double)mem_size_Q_k + (double)mem_size_Q_q + (double)getD3Qxx()*(double)mem_size_Q_q; - setMemsizeGPU(tmp, false); -} -void Parameter::cudaCopyPress(int lev) -{ - unsigned int mem_size_Q_k = sizeof(int)*parH[lev]->QPress.kQ; - unsigned int mem_size_Q_q = sizeof(real)*parH[lev]->QPress.kQ; - - checkCudaErrors( cudaMemcpy(parD[lev]->QPress.q27[0], parH[lev]->QPress.q27[0], getD3Qxx()* mem_size_Q_q, cudaMemcpyHostToDevice)); - checkCudaErrors( cudaMemcpy(parD[lev]->QPress.k, parH[lev]->QPress.k, mem_size_Q_k, cudaMemcpyHostToDevice)); - checkCudaErrors( cudaMemcpy(parD[lev]->QPress.kN, parH[lev]->QPress.kN, mem_size_Q_k, cudaMemcpyHostToDevice)); - checkCudaErrors( cudaMemcpy(parD[lev]->QPress.RhoBC, parH[lev]->QPress.RhoBC, mem_size_Q_q, cudaMemcpyHostToDevice)); -} -void Parameter::cudaFreePress(int lev) -{ - checkCudaErrors( cudaFreeHost(parH[lev]->QPress.q27[0])); - checkCudaErrors( cudaFreeHost(parH[lev]->QPress.k)); - checkCudaErrors( cudaFreeHost(parH[lev]->QPress.kN)); - checkCudaErrors( cudaFreeHost(parH[lev]->QPress.RhoBC)); - //checkCudaErrors( cudaFreeHost(parH[lev]->QPress.valueQ));//Geller - //checkCudaErrors( cudaFreeHost(parH[lev]->QPress.qread));//Geller -} -//Test roundoff error -void Parameter::cudaAllocTestRE(int lev, unsigned int size) -{ - unsigned int mem_size = sizeof(real)*size; - //Host - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->kDistTestRE.f[0]), (1+getD3Qxx())*mem_size)); - //Device - checkCudaErrors( cudaMalloc((void**) &(parD[lev]->kDistTestRE.f[0]), (1+getD3Qxx())*mem_size)); - ////////////////////////////////////////////////////////////////////////// - double tmp = (double)size; - setMemsizeGPU(tmp, false); -} -void Parameter::cudaCopyTestREtoDevice(int lev, unsigned int size) -{ - unsigned int mem_size = sizeof(real)*size; - checkCudaErrors( cudaMemcpy(parD[lev]->kDistTestRE.f[0], parH[lev]->kDistTestRE.f[0], (1+getD3Qxx())*mem_size, cudaMemcpyHostToDevice)); -} -void Parameter::cudaCopyTestREtoHost(int lev, unsigned int size) -{ - unsigned int mem_size = sizeof(real)*size; - checkCudaErrors( cudaMemcpy(parH[lev]->kDistTestRE.f[0], parD[lev]->kDistTestRE.f[0], (1+getD3Qxx())*mem_size, cudaMemcpyDeviceToHost)); -} -void Parameter::cudaFreeTestRE(int lev) -{ - checkCudaErrors( cudaFreeHost(parH[lev]->kDistTestRE.f[0])); -} -//PressX0 = X-inflow -void Parameter::cudaAllocPressX0(int lev) -{ - unsigned int mem_size_Q_k = sizeof(int)*parH[lev]->QpressX0.kQ; - unsigned int mem_size_Q_q = sizeof(real)*parH[lev]->QpressX0.kQ; - - //Host - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->QpressX0.q27[0]), getD3Qxx()*mem_size_Q_q )); - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->QpressX0.k), mem_size_Q_k )); - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->QpressX0.kN), mem_size_Q_k )); - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->QpressX0.Vx), mem_size_Q_q )); - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->QpressX0.Vy), mem_size_Q_q )); - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->QpressX0.Vz), mem_size_Q_q )); - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->QpressX0.RhoBC), mem_size_Q_q )); - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->QpressX0.deltaVz), mem_size_Q_q )); - - //Device - checkCudaErrors( cudaMalloc((void**) &(parD[lev]->QpressX0.q27[0]), getD3Qxx()* mem_size_Q_q )); - checkCudaErrors( cudaMalloc((void**) &(parD[lev]->QpressX0.k), mem_size_Q_k )); - checkCudaErrors( cudaMalloc((void**) &(parD[lev]->QpressX0.kN), mem_size_Q_k )); - checkCudaErrors( cudaMalloc((void**) &(parD[lev]->QpressX0.Vx), mem_size_Q_q )); - checkCudaErrors( cudaMalloc((void**) &(parD[lev]->QpressX0.Vy), mem_size_Q_q )); - checkCudaErrors( cudaMalloc((void**) &(parD[lev]->QpressX0.Vz), mem_size_Q_q )); - checkCudaErrors( cudaMalloc((void**) &(parD[lev]->QpressX0.RhoBC), mem_size_Q_q )); - checkCudaErrors( cudaMalloc((void**) &(parD[lev]->QpressX0.deltaVz), mem_size_Q_q )); - - ////////////////////////////////////////////////////////////////////////// - double tmp = 2. * (double)mem_size_Q_k + 5. * (double)mem_size_Q_q + (double)getD3Qxx()*(double)mem_size_Q_q; - setMemsizeGPU(tmp, false); -} -void Parameter::cudaCopyPressX0(int lev) -{ - unsigned int mem_size_Q_k = sizeof(int)*parH[lev]->QpressX0.kQ; - unsigned int mem_size_Q_q = sizeof(real)*parH[lev]->QpressX0.kQ; - - checkCudaErrors( cudaMemcpy(parD[lev]->QpressX0.q27[0], parH[lev]->QpressX0.q27[0], getD3Qxx()* mem_size_Q_q, cudaMemcpyHostToDevice)); - checkCudaErrors( cudaMemcpy(parD[lev]->QpressX0.k, parH[lev]->QpressX0.k, mem_size_Q_k, cudaMemcpyHostToDevice)); - checkCudaErrors( cudaMemcpy(parD[lev]->QpressX0.kN, parH[lev]->QpressX0.kN, mem_size_Q_k, cudaMemcpyHostToDevice)); - checkCudaErrors( cudaMemcpy(parD[lev]->QpressX0.Vx, parH[lev]->QpressX0.Vx, mem_size_Q_q, cudaMemcpyHostToDevice)); - checkCudaErrors( cudaMemcpy(parD[lev]->QpressX0.Vy, parH[lev]->QpressX0.Vy, mem_size_Q_q, cudaMemcpyHostToDevice)); - checkCudaErrors( cudaMemcpy(parD[lev]->QpressX0.Vz, parH[lev]->QpressX0.Vz, mem_size_Q_q, cudaMemcpyHostToDevice)); - checkCudaErrors( cudaMemcpy(parD[lev]->QpressX0.RhoBC, parH[lev]->QpressX0.RhoBC, mem_size_Q_q, cudaMemcpyHostToDevice)); - checkCudaErrors( cudaMemcpy(parD[lev]->QpressX0.deltaVz, parH[lev]->QpressX0.deltaVz, mem_size_Q_q, cudaMemcpyHostToDevice)); -} -void Parameter::cudaFreePressX0(int lev) -{ - checkCudaErrors( cudaFreeHost(parH[lev]->QpressX0.q27[0] )); - checkCudaErrors( cudaFreeHost(parH[lev]->QpressX0.k )); - checkCudaErrors( cudaFreeHost(parH[lev]->QpressX0.kN )); - checkCudaErrors( cudaFreeHost(parH[lev]->QpressX0.Vx )); - checkCudaErrors( cudaFreeHost(parH[lev]->QpressX0.Vy )); - checkCudaErrors( cudaFreeHost(parH[lev]->QpressX0.Vz )); - checkCudaErrors( cudaFreeHost(parH[lev]->QpressX0.RhoBC )); - checkCudaErrors( cudaFreeHost(parH[lev]->QpressX0.deltaVz)); -} -//PressX1 = X-outflow -void Parameter::cudaAllocPressX1(int lev) -{ - unsigned int mem_size_Q_k = sizeof(int)*parH[lev]->QpressX1.kQ; - unsigned int mem_size_Q_q = sizeof(real)*parH[lev]->QpressX1.kQ; - - //Host - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->QpressX1.q27[0]), getD3Qxx()*mem_size_Q_q )); - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->QpressX1.k), mem_size_Q_k )); - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->QpressX1.kN), mem_size_Q_k )); - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->QpressX1.Vx), mem_size_Q_q )); - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->QpressX1.Vy), mem_size_Q_q )); - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->QpressX1.Vz), mem_size_Q_q )); - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->QpressX1.RhoBC), mem_size_Q_q )); - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->QpressX1.deltaVz), mem_size_Q_q )); - - //Device - checkCudaErrors( cudaMalloc((void**) &(parD[lev]->QpressX1.q27[0]), getD3Qxx()* mem_size_Q_q )); - checkCudaErrors( cudaMalloc((void**) &(parD[lev]->QpressX1.k), mem_size_Q_k )); - checkCudaErrors( cudaMalloc((void**) &(parD[lev]->QpressX1.kN), mem_size_Q_k )); - checkCudaErrors( cudaMalloc((void**) &(parD[lev]->QpressX1.Vx), mem_size_Q_q )); - checkCudaErrors( cudaMalloc((void**) &(parD[lev]->QpressX1.Vy), mem_size_Q_q )); - checkCudaErrors( cudaMalloc((void**) &(parD[lev]->QpressX1.Vz), mem_size_Q_q )); - checkCudaErrors( cudaMalloc((void**) &(parD[lev]->QpressX1.RhoBC), mem_size_Q_q )); - checkCudaErrors( cudaMalloc((void**) &(parD[lev]->QpressX1.deltaVz), mem_size_Q_q )); - - ////////////////////////////////////////////////////////////////////////// - double tmp = 2. * (double)mem_size_Q_k + 5. * (double)mem_size_Q_q + (double)getD3Qxx()*(double)mem_size_Q_q; - setMemsizeGPU(tmp, false); -} -void Parameter::cudaCopyPressX1(int lev) -{ - unsigned int mem_size_Q_k = sizeof(int)*parH[lev]->QpressX1.kQ; - unsigned int mem_size_Q_q = sizeof(real)*parH[lev]->QpressX1.kQ; - - checkCudaErrors( cudaMemcpy(parD[lev]->QpressX1.q27[0], parH[lev]->QpressX1.q27[0], getD3Qxx()* mem_size_Q_q, cudaMemcpyHostToDevice)); - checkCudaErrors( cudaMemcpy(parD[lev]->QpressX1.k, parH[lev]->QpressX1.k, mem_size_Q_k, cudaMemcpyHostToDevice)); - checkCudaErrors( cudaMemcpy(parD[lev]->QpressX1.kN, parH[lev]->QpressX1.kN, mem_size_Q_k, cudaMemcpyHostToDevice)); - checkCudaErrors( cudaMemcpy(parD[lev]->QpressX1.Vx, parH[lev]->QpressX1.Vx, mem_size_Q_q, cudaMemcpyHostToDevice)); - checkCudaErrors( cudaMemcpy(parD[lev]->QpressX1.Vy, parH[lev]->QpressX1.Vy, mem_size_Q_q, cudaMemcpyHostToDevice)); - checkCudaErrors( cudaMemcpy(parD[lev]->QpressX1.Vz, parH[lev]->QpressX1.Vz, mem_size_Q_q, cudaMemcpyHostToDevice)); - checkCudaErrors( cudaMemcpy(parD[lev]->QpressX1.RhoBC, parH[lev]->QpressX1.RhoBC, mem_size_Q_q, cudaMemcpyHostToDevice)); - checkCudaErrors( cudaMemcpy(parD[lev]->QpressX1.deltaVz, parH[lev]->QpressX1.deltaVz, mem_size_Q_q, cudaMemcpyHostToDevice)); -} -void Parameter::cudaFreePressX1(int lev) -{ - checkCudaErrors( cudaFreeHost(parH[lev]->QpressX1.q27[0] )); - checkCudaErrors( cudaFreeHost(parH[lev]->QpressX1.k )); - checkCudaErrors( cudaFreeHost(parH[lev]->QpressX1.kN )); - checkCudaErrors( cudaFreeHost(parH[lev]->QpressX1.Vx )); - checkCudaErrors( cudaFreeHost(parH[lev]->QpressX1.Vy )); - checkCudaErrors( cudaFreeHost(parH[lev]->QpressX1.Vz )); - checkCudaErrors( cudaFreeHost(parH[lev]->QpressX1.RhoBC )); - checkCudaErrors( cudaFreeHost(parH[lev]->QpressX1.deltaVz)); -} -//Propeller Velocity -void Parameter::cudaAllocVeloPropeller(int lev) -{ - unsigned int mem_size_Propeller_k = sizeof(int)*parH[lev]->QPropeller.kQ; - unsigned int mem_size_Propeller_q = sizeof(real)*parH[lev]->QPropeller.kQ; - - //Host - //checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->QPropeller.q27[0]), getD3Qxx()*mem_size_Propeller_q )); - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->QPropeller.k), mem_size_Propeller_k )); - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->QPropeller.Vx), mem_size_Propeller_q )); - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->QPropeller.Vy), mem_size_Propeller_q )); - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->QPropeller.Vz), mem_size_Propeller_q )); - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->QPropeller.RhoBC), mem_size_Propeller_q )); - - //Device - //checkCudaErrors( cudaMalloc((void**) &(parD[lev]->QPropeller.q27[0]), getD3Qxx()*mem_size_Propeller_q )); - checkCudaErrors( cudaMalloc((void**) &(parD[lev]->QPropeller.k), mem_size_Propeller_k )); - checkCudaErrors( cudaMalloc((void**) &(parD[lev]->QPropeller.Vx), mem_size_Propeller_q )); - checkCudaErrors( cudaMalloc((void**) &(parD[lev]->QPropeller.Vy), mem_size_Propeller_q )); - checkCudaErrors( cudaMalloc((void**) &(parD[lev]->QPropeller.Vz), mem_size_Propeller_q )); - checkCudaErrors( cudaMalloc((void**) &(parD[lev]->QPropeller.RhoBC), mem_size_Propeller_q )); - - ////////////////////////////////////////////////////////////////////////// - double tmp = (double)mem_size_Propeller_k + 4. * (double)mem_size_Propeller_q; - setMemsizeGPU(tmp, false); -} -void Parameter::cudaCopyVeloPropeller(int lev) -{ - unsigned int mem_size_Propeller_k = sizeof(int)*parH[lev]->QPropeller.kQ; - unsigned int mem_size_Propeller_q = sizeof(real)*parH[lev]->QPropeller.kQ; - - //checkCudaErrors( cudaMemcpy(parD[lev]->QPropeller.q27[0], parH[lev]->QPropeller.q27[0], getD3Qxx()* mem_size_Propeller_q, cudaMemcpyHostToDevice)); - checkCudaErrors( cudaMemcpy(parD[lev]->QPropeller.k, parH[lev]->QPropeller.k, mem_size_Propeller_k, cudaMemcpyHostToDevice)); - checkCudaErrors( cudaMemcpy(parD[lev]->QPropeller.Vx, parH[lev]->QPropeller.Vx, mem_size_Propeller_q, cudaMemcpyHostToDevice)); - checkCudaErrors( cudaMemcpy(parD[lev]->QPropeller.Vy, parH[lev]->QPropeller.Vy, mem_size_Propeller_q, cudaMemcpyHostToDevice)); - checkCudaErrors( cudaMemcpy(parD[lev]->QPropeller.Vz, parH[lev]->QPropeller.Vz, mem_size_Propeller_q, cudaMemcpyHostToDevice)); - checkCudaErrors( cudaMemcpy(parD[lev]->QPropeller.RhoBC, parH[lev]->QPropeller.RhoBC, mem_size_Propeller_q, cudaMemcpyHostToDevice)); -} -void Parameter::cudaFreeVeloPropeller(int lev) -{ - //checkCudaErrors( cudaFreeHost(parH[lev]->QPropeller.q27[0] )); - checkCudaErrors( cudaFreeHost(parH[lev]->QPropeller.k )); - checkCudaErrors( cudaFreeHost(parH[lev]->QPropeller.Vx )); - checkCudaErrors( cudaFreeHost(parH[lev]->QPropeller.Vy )); - checkCudaErrors( cudaFreeHost(parH[lev]->QPropeller.Vz )); - checkCudaErrors( cudaFreeHost(parH[lev]->QPropeller.RhoBC )); -} -//Measure Points -//void Parameter::cudaAllocMeasurePoints(int lev, int i) -//{ -// //Host -// checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->MP[i].Vx), parH[lev]->memSizerealMP )); -// checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->MP[i].Vy), parH[lev]->memSizerealMP )); -// checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->MP[i].Vz), parH[lev]->memSizerealMP )); -// checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->MP[i].Rho), parH[lev]->memSizerealMP )); -// -// //Device -// checkCudaErrors( cudaMalloc((void**) &(parD[lev]->MP[i].Vx), parD[lev]->memSizerealMP )); -// checkCudaErrors( cudaMalloc((void**) &(parD[lev]->MP[i].Vy), parD[lev]->memSizerealMP )); -// checkCudaErrors( cudaMalloc((void**) &(parD[lev]->MP[i].Vz), parD[lev]->memSizerealMP )); -// checkCudaErrors( cudaMalloc((void**) &(parD[lev]->MP[i].Rho), parD[lev]->memSizerealMP )); -//} -//void Parameter::cudaCopyMeasurePoints(int lev, int i) -//{ -// checkCudaErrors( cudaMemcpy(parD[lev]->MP[i].Vx, parH[lev]->MP[i].Vx, parH[lev]->memSizerealMP, cudaMemcpyHostToDevice)); -// checkCudaErrors( cudaMemcpy(parD[lev]->MP[i].Vy, parH[lev]->MP[i].Vy, parH[lev]->memSizerealMP, cudaMemcpyHostToDevice)); -// checkCudaErrors( cudaMemcpy(parD[lev]->MP[i].Vz, parH[lev]->MP[i].Vz, parH[lev]->memSizerealMP, cudaMemcpyHostToDevice)); -// checkCudaErrors( cudaMemcpy(parD[lev]->MP[i].Rho, parH[lev]->MP[i].Rho, parH[lev]->memSizerealMP, cudaMemcpyHostToDevice)); -//} -//void Parameter::cudaFreeMeasurePoints(int lev, int i) -//{ -// checkCudaErrors( cudaFreeHost(parH[lev]->MP[i].Vx )); -// checkCudaErrors( cudaFreeHost(parH[lev]->MP[i].Vy )); -// checkCudaErrors( cudaFreeHost(parH[lev]->MP[i].Vz )); -// checkCudaErrors( cudaFreeHost(parH[lev]->MP[i].Rho )); -//} -void Parameter::cudaAllocMeasurePointsIndex(int lev) -{ - //Host - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->kMP), parH[lev]->memSizeIntkMP )); - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->VxMP), parH[lev]->memSizerealkMP )); - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->VyMP), parH[lev]->memSizerealkMP )); - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->VzMP), parH[lev]->memSizerealkMP )); - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->RhoMP), parH[lev]->memSizerealkMP )); - - //Device - checkCudaErrors( cudaMalloc((void**) &(parD[lev]->kMP), parD[lev]->memSizeIntkMP )); - checkCudaErrors( cudaMalloc((void**) &(parD[lev]->VxMP), parD[lev]->memSizerealkMP )); - checkCudaErrors( cudaMalloc((void**) &(parD[lev]->VyMP), parD[lev]->memSizerealkMP )); - checkCudaErrors( cudaMalloc((void**) &(parD[lev]->VzMP), parD[lev]->memSizerealkMP )); - checkCudaErrors( cudaMalloc((void**) &(parD[lev]->RhoMP), parD[lev]->memSizerealkMP )); - - ////////////////////////////////////////////////////////////////////////// - double tmp = (double)parH[lev]->memSizeIntkMP + 4. * (double)parH[lev]->memSizerealkMP; - setMemsizeGPU(tmp, false); -} -void Parameter::cudaCopyMeasurePointsIndex(int lev) -{ - checkCudaErrors( cudaMemcpy(parD[lev]->kMP, parH[lev]->kMP, parH[lev]->memSizeIntkMP, cudaMemcpyHostToDevice)); - checkCudaErrors( cudaMemcpy(parD[lev]->VxMP, parH[lev]->VxMP, parH[lev]->memSizerealkMP, cudaMemcpyHostToDevice)); - checkCudaErrors( cudaMemcpy(parD[lev]->VyMP, parH[lev]->VyMP, parH[lev]->memSizerealkMP, cudaMemcpyHostToDevice)); - checkCudaErrors( cudaMemcpy(parD[lev]->VzMP, parH[lev]->VzMP, parH[lev]->memSizerealkMP, cudaMemcpyHostToDevice)); - checkCudaErrors( cudaMemcpy(parD[lev]->RhoMP, parH[lev]->RhoMP, parH[lev]->memSizerealkMP, cudaMemcpyHostToDevice)); -} -void Parameter::cudaCopyMeasurePointsToHost(int lev) -{ - checkCudaErrors( cudaMemcpy(parH[lev]->kMP, parD[lev]->kMP, parH[lev]->memSizeIntkMP, cudaMemcpyDeviceToHost)); - checkCudaErrors( cudaMemcpy(parH[lev]->VxMP, parD[lev]->VxMP, parH[lev]->memSizerealkMP, cudaMemcpyDeviceToHost)); - checkCudaErrors( cudaMemcpy(parH[lev]->VyMP, parD[lev]->VyMP, parH[lev]->memSizerealkMP, cudaMemcpyDeviceToHost)); - checkCudaErrors( cudaMemcpy(parH[lev]->VzMP, parD[lev]->VzMP, parH[lev]->memSizerealkMP, cudaMemcpyDeviceToHost)); - checkCudaErrors( cudaMemcpy(parH[lev]->RhoMP, parD[lev]->RhoMP, parH[lev]->memSizerealkMP, cudaMemcpyDeviceToHost)); -} -void Parameter::cudaFreeMeasurePointsIndex(int lev) -{ - checkCudaErrors( cudaFreeHost(parH[lev]->kMP)); - checkCudaErrors( cudaFreeHost(parH[lev]->VxMP)); - checkCudaErrors( cudaFreeHost(parH[lev]->VyMP)); - checkCudaErrors( cudaFreeHost(parH[lev]->VzMP)); - checkCudaErrors( cudaFreeHost(parH[lev]->RhoMP)); -} -void Parameter::cudaAllocFsForCheckPointAndRestart(int lev) -{ - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->d0SP.f[0] ), (unsigned long long)getD3Qxx()*(unsigned long long)parH[lev]->mem_size_real_SP)); -} -void Parameter::cudaCopyFsForRestart(int lev) -{ - checkCudaErrors( cudaMemcpy(parD[lev]->d0SP.f[0], parH[lev]->d0SP.f[0], (unsigned long long)getD3Qxx()*(unsigned long long)parH[lev]->mem_size_real_SP , cudaMemcpyHostToDevice)); -} -void Parameter::cudaCopyFsForCheckPoint(int lev) -{ - checkCudaErrors( cudaMemcpy(parH[lev]->d0SP.f[0], parD[lev]->d0SP.f[0], (unsigned long long)getD3Qxx()*(unsigned long long)parH[lev]->mem_size_real_SP , cudaMemcpyDeviceToHost)); -} -void Parameter::cudaFreeFsForCheckPointAndRestart(int lev) -{ - checkCudaErrors( cudaFreeHost(parH[lev]->d0SP.f[0])); -} -//DragLift -void Parameter::cudaAllocDragLift(int lev, int numofelem) -{ - unsigned int mem_size = sizeof(double)*numofelem; - - //Host - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->DragPreX), mem_size )); - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->DragPreY), mem_size )); - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->DragPreZ), mem_size )); - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->DragPostX), mem_size )); - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->DragPostY), mem_size )); - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->DragPostZ), mem_size )); - - //Device - checkCudaErrors( cudaMalloc((void**) &(parD[lev]->DragPreX), mem_size )); - checkCudaErrors( cudaMalloc((void**) &(parD[lev]->DragPreY), mem_size )); - checkCudaErrors( cudaMalloc((void**) &(parD[lev]->DragPreZ), mem_size )); - checkCudaErrors( cudaMalloc((void**) &(parD[lev]->DragPostX), mem_size )); - checkCudaErrors( cudaMalloc((void**) &(parD[lev]->DragPostY), mem_size )); - checkCudaErrors( cudaMalloc((void**) &(parD[lev]->DragPostZ), mem_size )); - - ////////////////////////////////////////////////////////////////////////// - double tmp = 6. * (double)mem_size; - setMemsizeGPU(tmp, false); -} -void Parameter::cudaCopyDragLift(int lev, int numofelem) -{ - unsigned int mem_size = sizeof(double)*numofelem; - - checkCudaErrors( cudaMemcpy(parH[lev]->DragPreX, parD[lev]->DragPreX, mem_size, cudaMemcpyDeviceToHost)); - checkCudaErrors( cudaMemcpy(parH[lev]->DragPreY, parD[lev]->DragPreY, mem_size, cudaMemcpyDeviceToHost)); - checkCudaErrors( cudaMemcpy(parH[lev]->DragPreZ, parD[lev]->DragPreZ, mem_size, cudaMemcpyDeviceToHost)); - checkCudaErrors( cudaMemcpy(parH[lev]->DragPostX, parD[lev]->DragPostX, mem_size, cudaMemcpyDeviceToHost)); - checkCudaErrors( cudaMemcpy(parH[lev]->DragPostY, parD[lev]->DragPostY, mem_size, cudaMemcpyDeviceToHost)); - checkCudaErrors( cudaMemcpy(parH[lev]->DragPostZ, parD[lev]->DragPostZ, mem_size, cudaMemcpyDeviceToHost)); -} -void Parameter::cudaFreeDragLift(int lev) -{ - checkCudaErrors( cudaFreeHost(parH[lev]->DragPreX)); - checkCudaErrors( cudaFreeHost(parH[lev]->DragPreY)); - checkCudaErrors( cudaFreeHost(parH[lev]->DragPreZ)); - checkCudaErrors( cudaFreeHost(parH[lev]->DragPostX)); - checkCudaErrors( cudaFreeHost(parH[lev]->DragPostY)); - checkCudaErrors( cudaFreeHost(parH[lev]->DragPostZ)); -} -//2ndMoments -void Parameter::cudaAlloc2ndMoments(int lev, int numofelem) -{ - unsigned int mem_size = sizeof(real)*numofelem; - - //Host - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->kxyFromfcNEQ ), mem_size )); - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->kyzFromfcNEQ ), mem_size )); - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->kxzFromfcNEQ ), mem_size )); - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->kxxMyyFromfcNEQ), mem_size )); - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->kxxMzzFromfcNEQ), mem_size )); - - //Device - checkCudaErrors( cudaMalloc((void**) &(parD[lev]->kxyFromfcNEQ ), mem_size )); - checkCudaErrors( cudaMalloc((void**) &(parD[lev]->kyzFromfcNEQ ), mem_size )); - checkCudaErrors( cudaMalloc((void**) &(parD[lev]->kxzFromfcNEQ ), mem_size )); - checkCudaErrors( cudaMalloc((void**) &(parD[lev]->kxxMyyFromfcNEQ), mem_size )); - checkCudaErrors( cudaMalloc((void**) &(parD[lev]->kxxMzzFromfcNEQ), mem_size )); - - ////////////////////////////////////////////////////////////////////////// - double tmp = 5. * (real)mem_size; - setMemsizeGPU(tmp, false); -} -void Parameter::cudaCopy2ndMoments(int lev, int numofelem) -{ - unsigned int mem_size = sizeof(real)*numofelem; - - checkCudaErrors( cudaMemcpy(parH[lev]->kxyFromfcNEQ , parD[lev]->kxyFromfcNEQ , mem_size, cudaMemcpyDeviceToHost)); - checkCudaErrors( cudaMemcpy(parH[lev]->kyzFromfcNEQ , parD[lev]->kyzFromfcNEQ , mem_size, cudaMemcpyDeviceToHost)); - checkCudaErrors( cudaMemcpy(parH[lev]->kxzFromfcNEQ , parD[lev]->kxzFromfcNEQ , mem_size, cudaMemcpyDeviceToHost)); - checkCudaErrors( cudaMemcpy(parH[lev]->kxxMyyFromfcNEQ, parD[lev]->kxxMyyFromfcNEQ, mem_size, cudaMemcpyDeviceToHost)); - checkCudaErrors( cudaMemcpy(parH[lev]->kxxMzzFromfcNEQ, parD[lev]->kxxMzzFromfcNEQ, mem_size, cudaMemcpyDeviceToHost)); -} -void Parameter::cudaFree2ndMoments(int lev) -{ - checkCudaErrors( cudaFreeHost(parH[lev]->kxyFromfcNEQ )); - checkCudaErrors( cudaFreeHost(parH[lev]->kyzFromfcNEQ )); - checkCudaErrors( cudaFreeHost(parH[lev]->kxzFromfcNEQ )); - checkCudaErrors( cudaFreeHost(parH[lev]->kxxMyyFromfcNEQ)); - checkCudaErrors( cudaFreeHost(parH[lev]->kxxMzzFromfcNEQ)); -} -//3rdMoments -void Parameter::cudaAlloc3rdMoments(int lev, int numofelem) -{ - unsigned int mem_size = sizeof(real)*numofelem; - - //Host - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->CUMbbb ), mem_size )); - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->CUMabc ), mem_size )); - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->CUMbac ), mem_size )); - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->CUMbca ), mem_size )); - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->CUMcba ), mem_size )); - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->CUMacb ), mem_size )); - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->CUMcab ), mem_size )); - - //Device - checkCudaErrors( cudaMalloc((void**) &(parD[lev]->CUMbbb ), mem_size )); - checkCudaErrors( cudaMalloc((void**) &(parD[lev]->CUMabc ), mem_size )); - checkCudaErrors( cudaMalloc((void**) &(parD[lev]->CUMbac ), mem_size )); - checkCudaErrors( cudaMalloc((void**) &(parD[lev]->CUMbca ), mem_size )); - checkCudaErrors( cudaMalloc((void**) &(parD[lev]->CUMcba ), mem_size )); - checkCudaErrors( cudaMalloc((void**) &(parD[lev]->CUMacb ), mem_size )); - checkCudaErrors( cudaMalloc((void**) &(parD[lev]->CUMcab ), mem_size )); - - ////////////////////////////////////////////////////////////////////////// - double tmp = 7. * (real)mem_size; - setMemsizeGPU(tmp, false); -} -void Parameter::cudaCopy3rdMoments(int lev, int numofelem) -{ - unsigned int mem_size = sizeof(real)*numofelem; - - checkCudaErrors( cudaMemcpy(parH[lev]->CUMbbb, parD[lev]->CUMbbb, mem_size, cudaMemcpyDeviceToHost)); - checkCudaErrors( cudaMemcpy(parH[lev]->CUMabc, parD[lev]->CUMabc, mem_size, cudaMemcpyDeviceToHost)); - checkCudaErrors( cudaMemcpy(parH[lev]->CUMbac, parD[lev]->CUMbac, mem_size, cudaMemcpyDeviceToHost)); - checkCudaErrors( cudaMemcpy(parH[lev]->CUMbca, parD[lev]->CUMbca, mem_size, cudaMemcpyDeviceToHost)); - checkCudaErrors( cudaMemcpy(parH[lev]->CUMcba, parD[lev]->CUMcba, mem_size, cudaMemcpyDeviceToHost)); - checkCudaErrors( cudaMemcpy(parH[lev]->CUMacb, parD[lev]->CUMacb, mem_size, cudaMemcpyDeviceToHost)); - checkCudaErrors( cudaMemcpy(parH[lev]->CUMcab, parD[lev]->CUMcab, mem_size, cudaMemcpyDeviceToHost)); -} -void Parameter::cudaFree3rdMoments(int lev) -{ - checkCudaErrors( cudaFreeHost(parH[lev]->CUMbbb )); - checkCudaErrors( cudaFreeHost(parH[lev]->CUMabc )); - checkCudaErrors( cudaFreeHost(parH[lev]->CUMbac )); - checkCudaErrors( cudaFreeHost(parH[lev]->CUMbca )); - checkCudaErrors( cudaFreeHost(parH[lev]->CUMcba )); - checkCudaErrors( cudaFreeHost(parH[lev]->CUMacb )); - checkCudaErrors( cudaFreeHost(parH[lev]->CUMcab )); -} -//higher order moments -void Parameter::cudaAllocHigherMoments(int lev, int numofelem) -{ - unsigned int mem_size = sizeof(real)*numofelem; - - //Host - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->CUMcbb ), mem_size )); - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->CUMbcb ), mem_size )); - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->CUMbbc ), mem_size )); - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->CUMcca ), mem_size )); - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->CUMcac ), mem_size )); - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->CUMacc ), mem_size )); - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->CUMbcc ), mem_size )); - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->CUMcbc ), mem_size )); - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->CUMccb ), mem_size )); - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->CUMccc ), mem_size )); - - //Device - checkCudaErrors( cudaMalloc((void**) &(parD[lev]->CUMcbb ), mem_size )); - checkCudaErrors( cudaMalloc((void**) &(parD[lev]->CUMbcb ), mem_size )); - checkCudaErrors( cudaMalloc((void**) &(parD[lev]->CUMbbc ), mem_size )); - checkCudaErrors( cudaMalloc((void**) &(parD[lev]->CUMcca ), mem_size )); - checkCudaErrors( cudaMalloc((void**) &(parD[lev]->CUMcac ), mem_size )); - checkCudaErrors( cudaMalloc((void**) &(parD[lev]->CUMacc ), mem_size )); - checkCudaErrors( cudaMalloc((void**) &(parD[lev]->CUMbcc ), mem_size )); - checkCudaErrors( cudaMalloc((void**) &(parD[lev]->CUMcbc ), mem_size )); - checkCudaErrors( cudaMalloc((void**) &(parD[lev]->CUMccb ), mem_size )); - checkCudaErrors( cudaMalloc((void**) &(parD[lev]->CUMccc ), mem_size )); - - ////////////////////////////////////////////////////////////////////////// - double tmp = 7. * (real)mem_size; - setMemsizeGPU(tmp, false); -} -void Parameter::cudaCopyHigherMoments(int lev, int numofelem) -{ - unsigned int mem_size = sizeof(real)*numofelem; - - checkCudaErrors( cudaMemcpy(parH[lev]->CUMcbb, parD[lev]->CUMcbb, mem_size, cudaMemcpyDeviceToHost)); - checkCudaErrors( cudaMemcpy(parH[lev]->CUMbcb, parD[lev]->CUMbcb, mem_size, cudaMemcpyDeviceToHost)); - checkCudaErrors( cudaMemcpy(parH[lev]->CUMbbc, parD[lev]->CUMbbc, mem_size, cudaMemcpyDeviceToHost)); - checkCudaErrors( cudaMemcpy(parH[lev]->CUMcca, parD[lev]->CUMcca, mem_size, cudaMemcpyDeviceToHost)); - checkCudaErrors( cudaMemcpy(parH[lev]->CUMcac, parD[lev]->CUMcac, mem_size, cudaMemcpyDeviceToHost)); - checkCudaErrors( cudaMemcpy(parH[lev]->CUMacc, parD[lev]->CUMacc, mem_size, cudaMemcpyDeviceToHost)); - checkCudaErrors( cudaMemcpy(parH[lev]->CUMbcc, parD[lev]->CUMbcc, mem_size, cudaMemcpyDeviceToHost)); - checkCudaErrors( cudaMemcpy(parH[lev]->CUMcbc, parD[lev]->CUMcbc, mem_size, cudaMemcpyDeviceToHost)); - checkCudaErrors( cudaMemcpy(parH[lev]->CUMccb, parD[lev]->CUMccb, mem_size, cudaMemcpyDeviceToHost)); - checkCudaErrors( cudaMemcpy(parH[lev]->CUMccc, parD[lev]->CUMccc, mem_size, cudaMemcpyDeviceToHost)); -} -void Parameter::cudaFreeHigherMoments(int lev) -{ - checkCudaErrors( cudaFreeHost(parH[lev]->CUMcbb )); - checkCudaErrors( cudaFreeHost(parH[lev]->CUMbcb )); - checkCudaErrors( cudaFreeHost(parH[lev]->CUMbbc )); - checkCudaErrors( cudaFreeHost(parH[lev]->CUMcca )); - checkCudaErrors( cudaFreeHost(parH[lev]->CUMcac )); - checkCudaErrors( cudaFreeHost(parH[lev]->CUMacc )); - checkCudaErrors( cudaFreeHost(parH[lev]->CUMbcc )); - checkCudaErrors( cudaFreeHost(parH[lev]->CUMcbc )); - checkCudaErrors( cudaFreeHost(parH[lev]->CUMccb )); - checkCudaErrors( cudaFreeHost(parH[lev]->CUMccc )); -} -//Velcities to fit the Forcing -void Parameter::cudaAllocForceVelo(int lev, int numofelem) -{ - unsigned int mem_size = sizeof(real)*numofelem; - - //Host - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->VxForce ), mem_size )); - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->VyForce ), mem_size )); - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->VzForce ), mem_size )); - - //Device - checkCudaErrors( cudaMalloc((void**) &(parD[lev]->VxForce ), mem_size )); - checkCudaErrors( cudaMalloc((void**) &(parD[lev]->VyForce ), mem_size )); - checkCudaErrors( cudaMalloc((void**) &(parD[lev]->VzForce ), mem_size )); - - ////////////////////////////////////////////////////////////////////////// - double tmp = 3. * (real)mem_size; - setMemsizeGPU(tmp, false); -} -void Parameter::cudaCopyForceVelo(int lev, int numofelem) -{ - unsigned int mem_size = sizeof(real)*numofelem; - - checkCudaErrors( cudaMemcpy(parH[lev]->VxForce , parD[lev]->VxForce , mem_size, cudaMemcpyDeviceToHost)); - checkCudaErrors( cudaMemcpy(parH[lev]->VyForce , parD[lev]->VyForce , mem_size, cudaMemcpyDeviceToHost)); - checkCudaErrors( cudaMemcpy(parH[lev]->VzForce , parD[lev]->VzForce , mem_size, cudaMemcpyDeviceToHost)); -} -void Parameter::cudaFreeForceVelo(int lev) -{ - checkCudaErrors( cudaFreeHost(parH[lev]->VxForce )); - checkCudaErrors( cudaFreeHost(parH[lev]->VyForce )); - checkCudaErrors( cudaFreeHost(parH[lev]->VzForce )); -} -//Forcing -void Parameter::cudaAllocForcing() -{ - unsigned int mem_size = sizeof(real) * 3; - //Host - checkCudaErrors( cudaMallocHost((void**) &(this->forcingH ), mem_size)); - //Device - checkCudaErrors( cudaMalloc( (void**) &(this->forcingD ), mem_size)); - ////////////////////////////////////////////////////////////////////////// - double tmp = (real)mem_size; - setMemsizeGPU(tmp, false); -} -void Parameter::cudaCopyForcingToDevice() -{ - unsigned int mem_size = sizeof(real) * 3; - checkCudaErrors( cudaMemcpy(this->forcingD, this->forcingH , mem_size, cudaMemcpyHostToDevice)); -} -void Parameter::cudaCopyForcingToHost() -{ - unsigned int mem_size = sizeof(real) * 3; - checkCudaErrors( cudaMemcpy(this->forcingH, this->forcingD , mem_size, cudaMemcpyDeviceToHost)); -} -void Parameter::cudaFreeForcing() -{ - checkCudaErrors( cudaFreeHost(this->forcingH)); -} -//cp Top -void Parameter::cudaAllocCpTop(int lev) -{ - unsigned int mem_size_double = sizeof(double) * parH[lev]->numberOfPointsCpTop; - unsigned int mem_size_int = sizeof(unsigned int) * parH[lev]->numberOfPointsCpTop; - - //Host - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->cpPressTop), mem_size_double )); - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->cpTopIndex), mem_size_int )); - - //Device - checkCudaErrors( cudaMalloc((void**) &(parD[lev]->cpPressTop), mem_size_double )); - checkCudaErrors( cudaMalloc((void**) &(parD[lev]->cpTopIndex), mem_size_int )); - - ////////////////////////////////////////////////////////////////////////// - double tmp = (double)mem_size_double + (double)mem_size_int; - setMemsizeGPU(tmp, false); -} -void Parameter::cudaCopyCpTopInit(int lev) -{ - unsigned int mem_size_double = sizeof(double) * parH[lev]->numberOfPointsCpTop; - unsigned int mem_size_int = sizeof(unsigned int) * parH[lev]->numberOfPointsCpTop; - - checkCudaErrors( cudaMemcpy(parD[lev]->cpPressTop, parH[lev]->cpPressTop, mem_size_double, cudaMemcpyHostToDevice)); - checkCudaErrors( cudaMemcpy(parD[lev]->cpTopIndex, parH[lev]->cpTopIndex, mem_size_int, cudaMemcpyHostToDevice)); -} -void Parameter::cudaCopyCpTop(int lev) -{ - unsigned int mem_size_double = sizeof(double) * parH[lev]->numberOfPointsCpTop; - //unsigned int mem_size_int = sizeof(unsigned int) * parH[lev]->numberOfPointsCpTop; - - checkCudaErrors( cudaMemcpy(parH[lev]->cpPressTop, parD[lev]->cpPressTop, mem_size_double, cudaMemcpyDeviceToHost)); - //checkCudaErrors( cudaMemcpy(parH[lev]->cpTopIndex, parD[lev]->cpTopIndex, mem_size_int, cudaMemcpyDeviceToHost)); -} -void Parameter::cudaFreeCpTop(int lev) -{ - checkCudaErrors( cudaFreeHost(parH[lev]->cpPressTop)); - checkCudaErrors( cudaFreeHost(parH[lev]->cpTopIndex)); -} -//cp Bottom -void Parameter::cudaAllocCpBottom(int lev) -{ - unsigned int mem_size_double = sizeof(double) * parH[lev]->numberOfPointsCpBottom; - unsigned int mem_size_int = sizeof(unsigned int) * parH[lev]->numberOfPointsCpBottom; - - //Host - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->cpPressBottom), mem_size_double )); - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->cpBottomIndex), mem_size_int )); - - //Device - checkCudaErrors( cudaMalloc((void**) &(parD[lev]->cpPressBottom), mem_size_double )); - checkCudaErrors( cudaMalloc((void**) &(parD[lev]->cpBottomIndex), mem_size_int )); - - ////////////////////////////////////////////////////////////////////////// - double tmp = (double)mem_size_double + (double)mem_size_int; - setMemsizeGPU(tmp, false); -} -void Parameter::cudaCopyCpBottomInit(int lev) -{ - unsigned int mem_size_double = sizeof(double) * parH[lev]->numberOfPointsCpBottom; - unsigned int mem_size_int = sizeof(unsigned int) * parH[lev]->numberOfPointsCpBottom; - - checkCudaErrors( cudaMemcpy(parD[lev]->cpPressBottom, parH[lev]->cpPressBottom, mem_size_double, cudaMemcpyHostToDevice)); - checkCudaErrors( cudaMemcpy(parD[lev]->cpBottomIndex, parH[lev]->cpBottomIndex, mem_size_int, cudaMemcpyHostToDevice)); -} -void Parameter::cudaCopyCpBottom(int lev) -{ - unsigned int mem_size_double = sizeof(double) * parH[lev]->numberOfPointsCpBottom; - //unsigned int mem_size_int = sizeof(unsigned int) * parH[lev]->numberOfPointsCpBottom; - - checkCudaErrors( cudaMemcpy(parH[lev]->cpPressBottom, parD[lev]->cpPressBottom, mem_size_double, cudaMemcpyDeviceToHost)); - //checkCudaErrors( cudaMemcpy(parH[lev]->cpBottomIndex, parD[lev]->cpBottomIndex, mem_size_int, cudaMemcpyDeviceToHost)); -} -void Parameter::cudaFreeCpBottom(int lev) -{ - checkCudaErrors( cudaFreeHost(parH[lev]->cpPressBottom)); - checkCudaErrors( cudaFreeHost(parH[lev]->cpBottomIndex)); -} -//cp Bottom 2 -void Parameter::cudaAllocCpBottom2(int lev) -{ - unsigned int mem_size_double = sizeof(double) * parH[lev]->numberOfPointsCpBottom2; - unsigned int mem_size_int = sizeof(unsigned int) * parH[lev]->numberOfPointsCpBottom2; - - //Host - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->cpPressBottom2), mem_size_double )); - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->cpBottom2Index), mem_size_int )); - - //Device - checkCudaErrors( cudaMalloc((void**) &(parD[lev]->cpPressBottom2), mem_size_double )); - checkCudaErrors( cudaMalloc((void**) &(parD[lev]->cpBottom2Index), mem_size_int )); - - ////////////////////////////////////////////////////////////////////////// - double tmp = (double)mem_size_double + (double)mem_size_int; - setMemsizeGPU(tmp, false); -} -void Parameter::cudaCopyCpBottom2Init(int lev) -{ - unsigned int mem_size_double = sizeof(double) * parH[lev]->numberOfPointsCpBottom2; - unsigned int mem_size_int = sizeof(unsigned int) * parH[lev]->numberOfPointsCpBottom2; - - checkCudaErrors( cudaMemcpy(parD[lev]->cpPressBottom2, parH[lev]->cpPressBottom2, mem_size_double, cudaMemcpyHostToDevice)); - checkCudaErrors( cudaMemcpy(parD[lev]->cpBottom2Index, parH[lev]->cpBottom2Index, mem_size_int, cudaMemcpyHostToDevice)); -} -void Parameter::cudaCopyCpBottom2(int lev) -{ - unsigned int mem_size_double = sizeof(double) * parH[lev]->numberOfPointsCpBottom2; - - checkCudaErrors( cudaMemcpy(parH[lev]->cpPressBottom2, parD[lev]->cpPressBottom2, mem_size_double, cudaMemcpyDeviceToHost)); -} -void Parameter::cudaFreeCpBottom2(int lev) -{ - checkCudaErrors( cudaFreeHost(parH[lev]->cpPressBottom2)); - checkCudaErrors( cudaFreeHost(parH[lev]->cpBottom2Index)); -} -////////////////////////////////////////////////////////////////////////// -//particles -void Parameter::cudaAllocParticles(int lev) -{ - //Host - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->plp.coordXlocal), parH[lev]->plp.memSizerealAll )); - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->plp.coordYlocal), parH[lev]->plp.memSizerealAll )); - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->plp.coordZlocal), parH[lev]->plp.memSizerealAll )); - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->plp.coordXabsolut), parH[lev]->plp.memSizerealAll )); - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->plp.coordYabsolut), parH[lev]->plp.memSizerealAll )); - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->plp.coordZabsolut), parH[lev]->plp.memSizerealAll )); - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->plp.veloX), parH[lev]->plp.memSizerealAll )); - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->plp.veloY), parH[lev]->plp.memSizerealAll )); - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->plp.veloZ), parH[lev]->plp.memSizerealAll )); - //checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->plp.randomLocationInit), parH[lev]->plp.memSizereal )); - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->plp.ID), parH[lev]->plp.memSizeID )); - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->plp.cellBaseID), parH[lev]->plp.memSizeID )); - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->plp.timestep), parH[lev]->plp.memSizeTimestep )); - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->plp.stuck), parH[lev]->plp.memSizeBool )); - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->plp.hot), parH[lev]->plp.memSizeBoolBC )); - - //Device - checkCudaErrors( cudaMalloc((void**) &(parD[lev]->plp.coordXlocal), parD[lev]->plp.memSizerealAll )); - checkCudaErrors( cudaMalloc((void**) &(parD[lev]->plp.coordYlocal), parD[lev]->plp.memSizerealAll )); - checkCudaErrors( cudaMalloc((void**) &(parD[lev]->plp.coordZlocal), parD[lev]->plp.memSizerealAll )); - checkCudaErrors( cudaMalloc((void**) &(parD[lev]->plp.coordXabsolut), parD[lev]->plp.memSizerealAll )); - checkCudaErrors( cudaMalloc((void**) &(parD[lev]->plp.coordYabsolut), parD[lev]->plp.memSizerealAll )); - checkCudaErrors( cudaMalloc((void**) &(parD[lev]->plp.coordZabsolut), parD[lev]->plp.memSizerealAll )); - checkCudaErrors( cudaMalloc((void**) &(parD[lev]->plp.veloX), parD[lev]->plp.memSizerealAll )); - checkCudaErrors( cudaMalloc((void**) &(parD[lev]->plp.veloY), parD[lev]->plp.memSizerealAll )); - checkCudaErrors( cudaMalloc((void**) &(parD[lev]->plp.veloZ), parD[lev]->plp.memSizerealAll )); - //checkCudaErrors( cudaMalloc((void**) &(parD[lev]->plp.randomLocationInit), parD[lev]->plp.memSizereal )); - checkCudaErrors( cudaMalloc((void**) &(parD[lev]->plp.ID), parD[lev]->plp.memSizeID )); - checkCudaErrors( cudaMalloc((void**) &(parD[lev]->plp.cellBaseID), parD[lev]->plp.memSizeID )); - checkCudaErrors( cudaMalloc((void**) &(parD[lev]->plp.timestep), parD[lev]->plp.memSizeTimestep )); - checkCudaErrors( cudaMalloc((void**) &(parD[lev]->plp.stuck), parD[lev]->plp.memSizeBool )); - checkCudaErrors( cudaMalloc((void**) &(parD[lev]->plp.hot), parD[lev]->plp.memSizeBoolBC )); - - ////////////////////////////////////////////////////////////////////////// - double tmp = (double)parD[lev]->plp.memSizerealAll * (double)9.0 + (double)parD[lev]->plp.memSizeID * (double)2.0 + (double)parD[lev]->plp.memSizeTimestep - + (double)parD[lev]->plp.memSizeBool + (double)parD[lev]->plp.memSizeBoolBC; - setMemsizeGPU(tmp, false); -} -void Parameter::cudaCopyParticles(int lev) -{ - checkCudaErrors( cudaMemcpy(parH[lev]->plp.coordXlocal, parD[lev]->plp.coordXlocal, parH[lev]->plp.memSizerealAll, cudaMemcpyDeviceToHost)); - checkCudaErrors( cudaMemcpy(parH[lev]->plp.coordYlocal, parD[lev]->plp.coordYlocal, parH[lev]->plp.memSizerealAll, cudaMemcpyDeviceToHost)); - checkCudaErrors( cudaMemcpy(parH[lev]->plp.coordZlocal, parD[lev]->plp.coordZlocal, parH[lev]->plp.memSizerealAll, cudaMemcpyDeviceToHost)); - checkCudaErrors( cudaMemcpy(parH[lev]->plp.coordXabsolut, parD[lev]->plp.coordXabsolut, parH[lev]->plp.memSizerealAll, cudaMemcpyDeviceToHost)); - checkCudaErrors( cudaMemcpy(parH[lev]->plp.coordYabsolut, parD[lev]->plp.coordYabsolut, parH[lev]->plp.memSizerealAll, cudaMemcpyDeviceToHost)); - checkCudaErrors( cudaMemcpy(parH[lev]->plp.coordZabsolut, parD[lev]->plp.coordZabsolut, parH[lev]->plp.memSizerealAll, cudaMemcpyDeviceToHost)); - checkCudaErrors( cudaMemcpy(parH[lev]->plp.veloX, parD[lev]->plp.veloX, parH[lev]->plp.memSizerealAll, cudaMemcpyDeviceToHost)); - checkCudaErrors( cudaMemcpy(parH[lev]->plp.veloY, parD[lev]->plp.veloY, parH[lev]->plp.memSizerealAll, cudaMemcpyDeviceToHost)); - checkCudaErrors( cudaMemcpy(parH[lev]->plp.veloZ, parD[lev]->plp.veloZ, parH[lev]->plp.memSizerealAll, cudaMemcpyDeviceToHost)); - //checkCudaErrors( cudaMemcpy(parH[lev]->plp.randomLocationInit, parD[lev]->plp.randomLocationInit, parH[lev]->plp.memSizereal, cudaMemcpyDeviceToHost)); - checkCudaErrors( cudaMemcpy(parH[lev]->plp.ID, parD[lev]->plp.ID, parH[lev]->plp.memSizeID, cudaMemcpyDeviceToHost)); - checkCudaErrors( cudaMemcpy(parH[lev]->plp.cellBaseID, parD[lev]->plp.cellBaseID, parH[lev]->plp.memSizeID, cudaMemcpyDeviceToHost)); - checkCudaErrors( cudaMemcpy(parH[lev]->plp.timestep, parD[lev]->plp.timestep, parH[lev]->plp.memSizeTimestep, cudaMemcpyDeviceToHost)); -} -void Parameter::cudaFreeParticles(int lev) -{ - checkCudaErrors( cudaFreeHost(parH[lev]->plp.coordXlocal) ); - checkCudaErrors( cudaFreeHost(parH[lev]->plp.coordYlocal) ); - checkCudaErrors( cudaFreeHost(parH[lev]->plp.coordZlocal) ); - checkCudaErrors( cudaFreeHost(parH[lev]->plp.coordXabsolut) ); - checkCudaErrors( cudaFreeHost(parH[lev]->plp.coordYabsolut) ); - checkCudaErrors( cudaFreeHost(parH[lev]->plp.coordZabsolut) ); - checkCudaErrors( cudaFreeHost(parH[lev]->plp.veloX) ); - checkCudaErrors( cudaFreeHost(parH[lev]->plp.veloY) ); - checkCudaErrors( cudaFreeHost(parH[lev]->plp.veloZ) ); - //checkCudaErrors( cudaFreeHost(parH[lev]->plp.randomLocationInit)); - checkCudaErrors( cudaFreeHost(parH[lev]->plp.ID) ); - checkCudaErrors( cudaFreeHost(parH[lev]->plp.cellBaseID) ); - checkCudaErrors( cudaFreeHost(parH[lev]->plp.timestep) ); -} -//random values -void Parameter::cudaAllocRandomValues() -{ - //Device - checkCudaErrors( cudaMalloc((void**)&(this->devState), (sizeof(curandState)*parD[getFine()]->plp.numberOfParticles) )); -} -////////////////////////////////////////////////////////////////////////// -//porous media -void Parameter::cudaAllocPorousMedia(PorousMedia* pm, int lev) -{ - unsigned int mem_size_IDsPM = sizeof(unsigned int)*pm->getSizePM(); - unsigned int *tmpIDHost, *tmpIDDevice; - //std::cout << "cudaMallocHost" << endl; - //Host - checkCudaErrors(cudaMallocHost((void**) &(tmpIDHost), mem_size_IDsPM)); - - //std::cout << "cudaMalloc" << endl; - //Device - checkCudaErrors(cudaMalloc((void**) &(tmpIDDevice), mem_size_IDsPM)); - - //std::cout << "set Host and Device arrays PM" << endl; - ////////////////////////////////////////////////////////////////////////// - pm->setHostNodeIDsPM(tmpIDHost); - pm->setDeviceNodeIDsPM(tmpIDDevice); - ////////////////////////////////////////////////////////////////////////// - double tmp = (double)mem_size_IDsPM; - setMemsizeGPU(tmp, false); -} -void Parameter::cudaCopyPorousMedia(PorousMedia* pm, int lev) -{ - unsigned int mem_size_IDsPM = sizeof(unsigned int)*pm->getSizePM(); - unsigned int *tmpIDHost = pm->getHostNodeIDsPM(); - unsigned int *tmpIDDevice = pm->getDeviceNodeIDsPM(); - ////////////////////////////////////////////////////////////////////////// - checkCudaErrors(cudaMemcpy(tmpIDDevice, tmpIDHost, mem_size_IDsPM, cudaMemcpyHostToDevice)); - ////////////////////////////////////////////////////////////////////////// - pm->setDeviceNodeIDsPM(tmpIDDevice); -} -void Parameter::cudaFreePorousMedia(PorousMedia* pm, int lev) -{ - checkCudaErrors(cudaFreeHost(pm->getHostNodeIDsPM())); -} -////////////////////////////////////////////////////////////////////////// -//advection diffusion -void Parameter::cudaAllocConc(int lev) -{ - //Host - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->Conc), parH[lev]->mem_size_real_SP)); - //Device - checkCudaErrors( cudaMalloc((void**) &(parD[lev]->Conc), parD[lev]->mem_size_real_SP)); - ////////////////////////////////////////////////////////////////////////// - double tmp = (double)parH[lev]->mem_size_real_SP; - setMemsizeGPU(tmp, false); -} -void Parameter::cudaCopyConcDH(int lev) -{ - printf("Rank = %d \n", getMyID()); - checkCudaErrors( cudaMemcpy(parH[lev]->Conc, parD[lev]->Conc, parH[lev]->mem_size_real_SP , cudaMemcpyDeviceToHost)); -} -void Parameter::cudaCopyConcHD(int lev) -{ - checkCudaErrors( cudaMemcpy(parD[lev]->Conc, parH[lev]->Conc, parH[lev]->mem_size_real_SP, cudaMemcpyHostToDevice)); -} -void Parameter::cudaFreeConc(int lev) -{ - checkCudaErrors( cudaFreeHost(parH[lev]->Conc)); -} -////////////////////////////////////////////////////////////////////////// -void Parameter::cudaAllocTempFs(int lev) -{ - //Device - if (getDiffMod() == 7) - { - checkCudaErrors( cudaMalloc((void**) &(parD[lev]->d7.f[0]), getDiffMod()*parH[lev]->mem_size_real_SP)); - } - else if (getDiffMod() == 27) - { - checkCudaErrors( cudaMalloc((void**) &(parD[lev]->d27.f[0]), getDiffMod()*parH[lev]->mem_size_real_SP)); - } - ////////////////////////////////////////////////////////////////////////// - double tmp = (double)(getDiffMod()*parH[lev]->mem_size_real_SP); - setMemsizeGPU(tmp, false); -} -////////////////////////////////////////////////////////////////////////// -void Parameter::cudaAllocTempPressBC(int lev) -{ - unsigned int mem_size_TempPress_k = sizeof(int)*parH[lev]->TempPress.kTemp; - unsigned int mem_size_TempPress_q = sizeof(real)*parH[lev]->TempPress.kTemp; - - // Host Memory - checkCudaErrors( cudaMallocHost((void**) &parH[lev]->TempPress.temp, mem_size_TempPress_q )); - checkCudaErrors( cudaMallocHost((void**) &parH[lev]->TempPress.velo, mem_size_TempPress_q )); - checkCudaErrors( cudaMallocHost((void**) &parH[lev]->TempPress.k, mem_size_TempPress_k )); - - // Device Memory - checkCudaErrors( cudaMalloc((void**) &parD[lev]->TempPress.temp, mem_size_TempPress_q)); - checkCudaErrors( cudaMalloc((void**) &parD[lev]->TempPress.velo, mem_size_TempPress_q)); - checkCudaErrors( cudaMalloc((void**) &parD[lev]->TempPress.k, mem_size_TempPress_k)); - -} -void Parameter::cudaCopyTempPressBCHD(int lev) -{ - unsigned int mem_size_TempPress_k = sizeof(int)*parH[lev]->TempPress.kTemp; - unsigned int mem_size_TempPress_q = sizeof(real)*parH[lev]->TempPress.kTemp; - - checkCudaErrors( cudaMemcpy(parD[lev]->TempPress.temp, parH[lev]->TempPress.temp, mem_size_TempPress_q, cudaMemcpyHostToDevice)); - checkCudaErrors( cudaMemcpy(parD[lev]->TempPress.velo, parH[lev]->TempPress.velo, mem_size_TempPress_q, cudaMemcpyHostToDevice)); - checkCudaErrors( cudaMemcpy(parD[lev]->TempPress.k, parH[lev]->TempPress.k, mem_size_TempPress_k, cudaMemcpyHostToDevice)); -} -void Parameter::cudaFreeTempPressBC(int lev) -{ - checkCudaErrors( cudaFreeHost(parH[lev]->TempPress.temp)); - checkCudaErrors( cudaFreeHost(parH[lev]->TempPress.velo)); - checkCudaErrors( cudaFreeHost(parH[lev]->TempPress.k )); -} -////////////////////////////////////////////////////////////////////////// -void Parameter::cudaAllocTempVeloBC(int lev) -{ - unsigned int mem_size_TempVel_k = sizeof(int)*parH[lev]->TempVel.kTemp; - unsigned int mem_size_TempVel_q = sizeof(real)*parH[lev]->TempVel.kTemp; - - printf("mem_size_TempVel_k = %d, mem_size_TempVel_q = %d \n", mem_size_TempVel_k, mem_size_TempVel_q); - // Host Memory - checkCudaErrors( cudaMallocHost((void**) &parH[lev]->TempVel.temp, mem_size_TempVel_q )); - checkCudaErrors( cudaMallocHost((void**) &parH[lev]->TempVel.tempPulse, mem_size_TempVel_q )); - checkCudaErrors( cudaMallocHost((void**) &parH[lev]->TempVel.velo, mem_size_TempVel_q )); - checkCudaErrors( cudaMallocHost((void**) &parH[lev]->TempVel.k, mem_size_TempVel_k )); - - // Device Memory - checkCudaErrors( cudaMalloc((void**) &parD[lev]->TempVel.temp, mem_size_TempVel_q)); - checkCudaErrors( cudaMalloc((void**) &parD[lev]->TempVel.tempPulse, mem_size_TempVel_q)); - checkCudaErrors( cudaMalloc((void**) &parD[lev]->TempVel.velo, mem_size_TempVel_q)); - checkCudaErrors( cudaMalloc((void**) &parD[lev]->TempVel.k, mem_size_TempVel_k)); - ////////////////////////////////////////////////////////////////////////// - double tmp = (double)(mem_size_TempVel_q * 3.0 + mem_size_TempVel_k); - setMemsizeGPU(tmp, false); - -} -void Parameter::cudaCopyTempVeloBCHD(int lev) -{ - unsigned int mem_size_TempVel_k = sizeof(int)*parH[lev]->TempVel.kTemp; - unsigned int mem_size_TempVel_q = sizeof(real)*parH[lev]->TempVel.kTemp; - - printf("mem_size_TempVel_k = %d, mem_size_TempVel_q = %d \n", mem_size_TempVel_k, mem_size_TempVel_q); - checkCudaErrors( cudaMemcpy(parD[lev]->TempVel.temp, parH[lev]->TempVel.temp, mem_size_TempVel_q, cudaMemcpyHostToDevice)); - checkCudaErrors( cudaMemcpy(parD[lev]->TempVel.tempPulse, parH[lev]->TempVel.tempPulse, mem_size_TempVel_q, cudaMemcpyHostToDevice)); - checkCudaErrors( cudaMemcpy(parD[lev]->TempVel.velo, parH[lev]->TempVel.velo, mem_size_TempVel_q, cudaMemcpyHostToDevice)); - checkCudaErrors( cudaMemcpy(parD[lev]->TempVel.k, parH[lev]->TempVel.k, mem_size_TempVel_k, cudaMemcpyHostToDevice)); -} -void Parameter::cudaFreeTempVeloBC(int lev) -{ - checkCudaErrors( cudaFreeHost(parH[lev]->TempVel.temp )); - checkCudaErrors( cudaFreeHost(parH[lev]->TempVel.tempPulse)); - checkCudaErrors( cudaFreeHost(parH[lev]->TempVel.velo )); - checkCudaErrors( cudaFreeHost(parH[lev]->TempVel.k )); -} -////////////////////////////////////////////////////////////////////////// -void Parameter::cudaAllocTempNoSlipBC(int lev) -{ - unsigned int mem_size_Temp_k = sizeof(int)*parH[lev]->Temp.kTemp; - unsigned int mem_size_Temp_q = sizeof(real)*parH[lev]->Temp.kTemp; - - // Host Memory - checkCudaErrors( cudaMallocHost((void**) &parH[lev]->Temp.temp, mem_size_Temp_q )); - checkCudaErrors( cudaMallocHost((void**) &parH[lev]->Temp.k, mem_size_Temp_k )); - - // Device Memory - checkCudaErrors( cudaMalloc((void**) &parD[lev]->Temp.temp, mem_size_Temp_q)); - checkCudaErrors( cudaMalloc((void**) &parD[lev]->Temp.k, mem_size_Temp_k)); - ////////////////////////////////////////////////////////////////////////// - double tmp = (double)(mem_size_Temp_q + mem_size_Temp_k); - setMemsizeGPU(tmp, false); - -} -void Parameter::cudaCopyTempNoSlipBCHD(int lev) -{ - unsigned int mem_size_Temp_k = sizeof(int)*parH[lev]->Temp.kTemp; - unsigned int mem_size_Temp_q = sizeof(real)*parH[lev]->Temp.kTemp; - - checkCudaErrors( cudaMemcpy(parD[lev]->Temp.temp, parH[lev]->Temp.temp, mem_size_Temp_q, cudaMemcpyHostToDevice)); - checkCudaErrors( cudaMemcpy(parD[lev]->Temp.k, parH[lev]->Temp.k, mem_size_Temp_k, cudaMemcpyHostToDevice)); -} -void Parameter::cudaFreeTempNoSlipBC(int lev) -{ - checkCudaErrors( cudaFreeHost(parH[lev]->Temp.temp)); - checkCudaErrors( cudaFreeHost(parH[lev]->Temp.k )); -} -//PlaneConc -void Parameter::cudaAllocPlaneConcIn(int lev, int numofelem) -{ - unsigned int mem_size = sizeof(real)*numofelem; - //Host - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->ConcPlaneIn), mem_size )); - //Device - checkCudaErrors( cudaMalloc((void**) &(parD[lev]->ConcPlaneIn), mem_size )); - ////////////////////////////////////////////////////////////////////////// - double tmp = (double)mem_size; - setMemsizeGPU(tmp, false); -} -void Parameter::cudaCopyPlaneConcIn(int lev, int numofelem) -{ - unsigned int mem_size = sizeof(real)*numofelem; - checkCudaErrors( cudaMemcpy(parH[lev]->ConcPlaneIn, parD[lev]->ConcPlaneIn, mem_size, cudaMemcpyDeviceToHost)); -} -////////////////////////////////////////////////////////////////////////// -void Parameter::cudaAllocPlaneConcOut1(int lev, int numofelem) -{ - unsigned int mem_size = sizeof(real)*numofelem; - //Host - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->ConcPlaneOut1), mem_size )); - //Device - checkCudaErrors( cudaMalloc((void**) &(parD[lev]->ConcPlaneOut1), mem_size )); - ////////////////////////////////////////////////////////////////////////// - double tmp = (double)mem_size; - setMemsizeGPU(tmp, false); -} -void Parameter::cudaCopyPlaneConcOut1(int lev, int numofelem) -{ - unsigned int mem_size = sizeof(real)*numofelem; - checkCudaErrors( cudaMemcpy(parH[lev]->ConcPlaneOut1, parD[lev]->ConcPlaneOut1, mem_size, cudaMemcpyDeviceToHost)); -} -////////////////////////////////////////////////////////////////////////// -void Parameter::cudaAllocPlaneConcOut2(int lev, int numofelem) -{ - unsigned int mem_size = sizeof(real)*numofelem; - //Host - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->ConcPlaneOut2), mem_size )); - //Device - checkCudaErrors( cudaMalloc((void**) &(parD[lev]->ConcPlaneOut2), mem_size )); - - ////////////////////////////////////////////////////////////////////////// - double tmp = (double)mem_size; - setMemsizeGPU(tmp, false); -} -void Parameter::cudaCopyPlaneConcOut2(int lev, int numofelem) -{ - unsigned int mem_size = sizeof(real)*numofelem; - checkCudaErrors( cudaMemcpy(parH[lev]->ConcPlaneOut2, parD[lev]->ConcPlaneOut2, mem_size, cudaMemcpyDeviceToHost)); -} -void Parameter::cudaFreePlaneConc(int lev) -{ - checkCudaErrors( cudaFreeHost(parH[lev]->ConcPlaneIn)); - checkCudaErrors( cudaFreeHost(parH[lev]->ConcPlaneOut1)); - checkCudaErrors( cudaFreeHost(parH[lev]->ConcPlaneOut2)); -} -////////////////////////////////////////////////////////////////////////// -//concentration file -void Parameter::cudaAllocConcFile(int lev) -{ - unsigned int mem_size_int = sizeof(unsigned int) * parH[lev]->numberOfPointsConc; - unsigned int mem_size_real = sizeof(real) * parH[lev]->numberOfPointsConc; - - //Host - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->concIndex), mem_size_int )); - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->concentration), mem_size_real )); - - //Device - checkCudaErrors( cudaMalloc((void**) &(parD[lev]->concIndex), mem_size_int )); - checkCudaErrors( cudaMalloc((void**) &(parD[lev]->concentration), mem_size_real )); - - ////////////////////////////////////////////////////////////////////////// - double tmp = (double)mem_size_int + (double)mem_size_real; - setMemsizeGPU(tmp, false); -} -void Parameter::cudaCopyConcFile(int lev) -{ - unsigned int mem_size_int = sizeof(unsigned int) * parH[lev]->numberOfPointsConc; - unsigned int mem_size_real = sizeof(real) * parH[lev]->numberOfPointsConc; +// 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 Parameter.h +//! \ingroup Parameter +//! \author Martin Schoenherr +//======================================================================================= +#include "Parameter.h" - checkCudaErrors( cudaMemcpy(parD[lev]->concIndex, parH[lev]->concIndex, mem_size_int, cudaMemcpyHostToDevice)); - checkCudaErrors( cudaMemcpy(parD[lev]->concentration, parH[lev]->concentration, mem_size_real, cudaMemcpyHostToDevice)); -} +#include <stdio.h> +#include <stdlib.h> +#include <math.h> -void Parameter::cudaCopyConcs(int lev) -{ - unsigned int mem_size_real = sizeof(real) * parH[lev]->numberOfPointsConc; +#include <curand_kernel.h> - checkCudaErrors(cudaMemcpy(parD[lev]->concentration, parH[lev]->concentration, mem_size_real, cudaMemcpyHostToDevice)); -} +#include "Core/StringUtilities/StringUtil.h" -void Parameter::cudaFreeConcFile(int lev) -{ - checkCudaErrors( cudaFreeHost(parH[lev]->concIndex )); - checkCudaErrors( cudaFreeHost(parH[lev]->concentration )); +#include <basics/config/ConfigurationFile.h> + + + +Parameter::Parameter(const vf::basics::ConfigurationFile &configData, int numberOfProcesses, int myId) +{ + ic.numprocs = numberOfProcesses; + ic.myid = myId; + + readConfigData(configData); + //initLBMSimulationParameter(); +} + +void Parameter::readConfigData(const vf::basics::ConfigurationFile &configData) +{ + if (configData.contains("NumberOfDevices")) + this->setMaxDev(configData.getValue<int>("NumberOfDevices")); + + ////////////////////////////////////////////////////////////////////////// + if (configData.contains("Devices")) + this->setDevices(configData.getVector<uint>("Devices")); + ////////////////////////////////////////////////////////////////////////// + if (configData.contains("Path")) + this->setOutputPath(configData.getValue<std::string>("Path")); + else + throw std::runtime_error("<Path> need to be defined in config file!"); + + ////////////////////////////////////////////////////////////////////////// + if (configData.contains("Prefix")) + this->setOutputPrefix(configData.getValue<std::string>("Prefix")); + ////////////////////////////////////////////////////////////////////////// + if (configData.contains("WriteGrid")) + this->setPrintFiles(configData.getValue<bool>("WriteGrid")); + ////////////////////////////////////////////////////////////////////////// + if (configData.contains("GeometryValues")) + this->setGeometryValues(configData.getValue<bool>("GeometryValues")); + ////////////////////////////////////////////////////////////////////////// + if (configData.contains("calc2ndOrderMoments")) + this->setCalc2ndOrderMoments(configData.getValue<bool>("calc2ndOrderMoments")); + ////////////////////////////////////////////////////////////////////////// + if (configData.contains("calc3rdOrderMoments")) + this->setCalc3rdOrderMoments(configData.getValue<bool>("calc3rdOrderMoments")); + ////////////////////////////////////////////////////////////////////////// + if (configData.contains("calcHigherOrderMoments")) + this->setCalcHighOrderMoments(configData.getValue<bool>("calcHigherOrderMoments")); + ////////////////////////////////////////////////////////////////////////// + if (configData.contains("calcMedian")) + this->setCalcMedian(configData.getValue<bool>("calcMedian")); + ////////////////////////////////////////////////////////////////////////// + if (configData.contains("calcCp")) + this->calcCp = configData.getValue<bool>("calcCp"); + ////////////////////////////////////////////////////////////////////////// + if (configData.contains("calcDrafLift")) + this->calcDragLift = configData.getValue<bool>("calcDrafLift"); + ////////////////////////////////////////////////////////////////////////// + if (configData.contains("writeVeloASCIIfiles")) + this->writeVeloASCII = configData.getValue<bool>("writeVeloASCIIfiles"); + ////////////////////////////////////////////////////////////////////////// + if (configData.contains("calcPlaneConc")) + this->calcPlaneConc = configData.getValue<bool>("calcPlaneConc"); + ////////////////////////////////////////////////////////////////////////// + if (configData.contains("UseConcFile")) + this->setConcFile(configData.getValue<bool>("UseConcFile")); + ////////////////////////////////////////////////////////////////////////// + if (configData.contains("UseStreetVelocityFile")) + this->setStreetVelocityFile(configData.getValue<bool>("UseStreetVelocityFile")); + ////////////////////////////////////////////////////////////////////////// + if (configData.contains("UseMeasurePoints")) + this->setUseMeasurePoints(configData.getValue<bool>("UseMeasurePoints")); + ////////////////////////////////////////////////////////////////////////// + if (configData.contains("UseWale")) + this->setUseWale(configData.getValue<bool>("UseWale")); + ////////////////////////////////////////////////////////////////////////// + if (configData.contains("UseInitNeq")) + this->setUseInitNeq(configData.getValue<bool>("UseInitNeq")); + ////////////////////////////////////////////////////////////////////////// + if (configData.contains("SimulatePorousMedia")) + this->setSimulatePorousMedia(configData.getValue<bool>("SimulatePorousMedia")); + ////////////////////////////////////////////////////////////////////////// + if (configData.contains("D3Qxx")) + this->setD3Qxx(configData.getValue<int>("D3Qxx")); + ////////////////////////////////////////////////////////////////////////// + if (configData.contains("TimeEnd")) + this->setTEnd(configData.getValue<int>("TimeEnd")); + ////////////////////////////////////////////////////////////////////////// + if (configData.contains("TimeOut")) + this->setTOut(configData.getValue<int>("TimeOut")); + ////////////////////////////////////////////////////////////////////////// + if (configData.contains("TimeStartOut")) + this->setTStartOut(configData.getValue<int>("TimeStartOut")); + ////////////////////////////////////////////////////////////////////////// + if (configData.contains("TimeStartCalcMedian")) + this->setTimeCalcMedStart(configData.getValue<int>("TimeStartCalcMedian")); + ////////////////////////////////////////////////////////////////////////// + if (configData.contains("TimeEndCalcMedian")) + this->setTimeCalcMedEnd(configData.getValue<int>("TimeEndCalcMedian")); + ////////////////////////////////////////////////////////////////////////// + if (configData.contains("PressInID")) + this->setPressInID(configData.getValue<int>("PressInID")); + ////////////////////////////////////////////////////////////////////////// + if (configData.contains("PressOutID")) + this->setPressOutID(configData.getValue<int>("PressOutID")); + ////////////////////////////////////////////////////////////////////////// + if (configData.contains("PressInZ")) + this->setPressInZ(configData.getValue<int>("PressInZ")); + ////////////////////////////////////////////////////////////////////////// + if (configData.contains("PressOutZ")) + this->setPressOutZ(configData.getValue<int>("PressOutZ")); + + ////////////////////////////////////////////////////////////////////////// + //second component + if (configData.contains("DiffOn")) + this->setDiffOn(configData.getValue<bool>("DiffOn")); + ////////////////////////////////////////////////////////////////////////// + if (configData.contains("DiffMod")) + this->setDiffMod(configData.getValue<int>("DiffMod")); + ////////////////////////////////////////////////////////////////////////// + if (configData.contains("Diffusivity")) + this->setDiffusivity(configData.getValue<real>("Diffusivity")); + ////////////////////////////////////////////////////////////////////////// + if (configData.contains("Temp")) + this->setTemperatureInit(configData.getValue<real>("Temp")); + ////////////////////////////////////////////////////////////////////////// + if (configData.contains("TempBC")) + this->setTemperatureBC(configData.getValue<real>("TempBC")); + + ////////////////////////////////////////////////////////////////////////// + if (configData.contains("Viscosity_LB")) + this->setViscosity(configData.getValue<real>("Viscosity_LB")); + ////////////////////////////////////////////////////////////////////////// + if (configData.contains("Velocity_LB")) + this->setVelocity(configData.getValue<real>("Velocity_LB")); + ////////////////////////////////////////////////////////////////////////// + if (configData.contains("Viscosity_Ratio_World_to_LB")) + this->setViscosityRatio(configData.getValue<real>("Viscosity_Ratio_World_to_LB")); + ////////////////////////////////////////////////////////////////////////// + if (configData.contains("Velocity_Ratio_World_to_LB")) + this->setVelocityRatio(configData.getValue<real>("Velocity_Ratio_World_to_LB")); + // ////////////////////////////////////////////////////////////////////////// + if (configData.contains("Density_Ratio_World_to_LB")) + this->setDensityRatio(configData.getValue<real>("Density_Ratio_World_to_LB")); + + if (configData.contains("Delta_Press")) + this->setPressRatio(configData.getValue<real>("Delta_Press")); + + ////////////////////////////////////////////////////////////////////////// + if (configData.contains("SliceRealX")) + this->setRealX(configData.getValue<real>("SliceRealX")); + ////////////////////////////////////////////////////////////////////////// + if (configData.contains("SliceRealY")) + this->setRealY(configData.getValue<real>("SliceRealY")); + ////////////////////////////////////////////////////////////////////////// + if (configData.contains("FactorPressBC")) + this->setFactorPressBC(configData.getValue<real>("FactorPressBC")); + + ////////////////////////////////////////////////////////////////////////// + //read Geometry (STL) + if (configData.contains("ReadGeometry")) + this->setReadGeo(configData.getValue<bool>("ReadGeometry")); + + if (configData.contains("GeometryC")) + this->setGeometryFileC(configData.getValue<std::string>("GeometryC")); + else if (this->getReadGeo()) + throw std::runtime_error("readGeo is true, GeometryC has to be set as well!"); + + if (configData.contains("GeometryM")) + this->setGeometryFileM(configData.getValue<std::string>("GeometryM")); + else if (this->getReadGeo()) + throw std::runtime_error("readGeo is true, GeometryM has to be set as well!"); + + if (configData.contains("GeometryF")) + this->setGeometryFileF(configData.getValue<std::string>("GeometryF")); + else if (this->getReadGeo()) + throw std::runtime_error("readGeo is true, GeometryF has to be set as well!"); + + ////////////////////////////////////////////////////////////////////////// + if (configData.contains("measureClockCycle")) + this->setclockCycleForMP(configData.getValue<real>("measureClockCycle")); + + if (configData.contains("measureTimestep")) + this->settimestepForMP(configData.getValue<uint>("measureTimestep")); + + ////////////////////////////////////////////////////////////////////////// + + std::string gridPath{ "" }; + if (configData.contains("GridPath")) + gridPath = configData.getValue<std::string>("GridPath"); + else + throw std::runtime_error("GridPath has to be defined in config file!"); + + if (this->getNumprocs() == 1) + gridPath += "/"; + else + gridPath += "/" + StringUtil::toString(this->getMyID()) + "/"; + + // ////////////////////////////////////////////////////////////////////////// + this->setFName(this->getOutputPath() + "/" + this->getOutputPrefix()); + ////////////////////////////////////////////////////////////////////////// + this->setgeoVec(gridPath + "geoVec.dat"); + this->setcoordX(gridPath + "coordX.dat"); + this->setcoordY(gridPath + "coordY.dat"); + this->setcoordZ(gridPath + "coordZ.dat"); + this->setneighborX(gridPath + "neighborX.dat"); + this->setneighborY(gridPath + "neighborY.dat"); + this->setneighborZ(gridPath + "neighborZ.dat"); + this->setneighborWSB(gridPath + "neighborWSB.dat"); + this->setscaleCFC(gridPath + "scaleCFC.dat"); + this->setscaleCFF(gridPath + "scaleCFF.dat"); + this->setscaleFCC(gridPath + "scaleFCC.dat"); + this->setscaleFCF(gridPath + "scaleFCF.dat"); + this->setscaleOffsetCF(gridPath + "offsetVecCF.dat"); + this->setscaleOffsetFC(gridPath + "offsetVecFC.dat"); + this->setgeomBoundaryBcQs(gridPath + "geomBoundaryQs.dat"); + this->setgeomBoundaryBcValues(gridPath + "geomBoundaryValues.dat"); + this->setinletBcQs(gridPath + "inletBoundaryQs.dat"); + this->setinletBcValues(gridPath + "inletBoundaryValues.dat"); + this->setoutletBcQs(gridPath + "outletBoundaryQs.dat"); + this->setoutletBcValues(gridPath + "outletBoundaryValues.dat"); + this->settopBcQs(gridPath + "topBoundaryQs.dat"); + this->settopBcValues(gridPath + "topBoundaryValues.dat"); + this->setbottomBcQs(gridPath + "bottomBoundaryQs.dat"); + this->setbottomBcValues(gridPath + "bottomBoundaryValues.dat"); + this->setfrontBcQs(gridPath + "frontBoundaryQs.dat"); + this->setfrontBcValues(gridPath + "frontBoundaryValues.dat"); + this->setbackBcQs(gridPath + "backBoundaryQs.dat"); + this->setbackBcValues(gridPath + "backBoundaryValues.dat"); + this->setnumberNodes(gridPath + "numberNodes.dat"); + this->setLBMvsSI(gridPath + "LBMvsSI.dat"); + this->setmeasurePoints(gridPath + "measurePoints.dat"); + this->setpropellerValues(gridPath + "propellerValues.dat"); + this->setcpTop(gridPath + "cpTop.dat"); + this->setcpBottom(gridPath + "cpBottom.dat"); + this->setcpBottom2(gridPath + "cpBottom2.dat"); + this->setConcentration(gridPath + "conc.dat"); + this->setStreetVelocity(gridPath + "streetVector.dat"); + ////////////////////////////////////////////////////////////////////////// + // Normals - Geometry + this->setgeomBoundaryNormalX(gridPath + "geomBoundaryNormalX.dat"); + this->setgeomBoundaryNormalY(gridPath + "geomBoundaryNormalY.dat"); + this->setgeomBoundaryNormalZ(gridPath + "geomBoundaryNormalZ.dat"); + // Normals - Inlet + this->setInflowBoundaryNormalX(gridPath + "inletBoundaryNormalX.dat"); + this->setInflowBoundaryNormalY(gridPath + "inletBoundaryNormalY.dat"); + this->setInflowBoundaryNormalZ(gridPath + "inletBoundaryNormalZ.dat"); + // Normals - Outlet + this->setOutflowBoundaryNormalX(gridPath + "outletBoundaryNormalX.dat"); + this->setOutflowBoundaryNormalY(gridPath + "outletBoundaryNormalY.dat"); + this->setOutflowBoundaryNormalZ(gridPath + "outletBoundaryNormalZ.dat"); + ////////////////////////////////////////////////////////////////////////// + // //Forcing + real forcingX = 0.0; + real forcingY = 0.0; + real forcingZ = 0.0; + + if (configData.contains("ForcingX")) + forcingX = configData.getValue<real>("ForcingX"); + if (configData.contains("ForcingY")) + forcingY = configData.getValue<real>("ForcingY"); + if (configData.contains("ForcingZ")) + forcingZ = configData.getValue<real>("ForcingZ"); + + this->setForcing(forcingX, forcingY, forcingZ); + ////////////////////////////////////////////////////////////////////////// + // quadricLimiters + real quadricLimiterP = (real)0.01; + real quadricLimiterM = (real)0.01; + real quadricLimiterD = (real)0.01; + + if (configData.contains("QuadricLimiterP")) + quadricLimiterP = configData.getValue<real>("QuadricLimiterP"); + if (configData.contains("QuadricLimiterM")) + quadricLimiterM = configData.getValue<real>("QuadricLimiterM"); + if (configData.contains("QuadricLimiterD")) + quadricLimiterD = configData.getValue<real>("QuadricLimiterD"); + + this->setQuadricLimiters(quadricLimiterP, quadricLimiterM, quadricLimiterD); + ////////////////////////////////////////////////////////////////////////// + // Particles + if (configData.contains("calcParticles")) + this->setCalcParticles(configData.getValue<bool>("calcParticles")); + + if (configData.contains("baseLevel")) + this->setParticleBasicLevel(configData.getValue<int>("baseLevel")); + + if (configData.contains("initLevel")) + this->setParticleInitLevel(configData.getValue<int>("initLevel")); + + if (configData.contains("numberOfParticles")) + this->setNumberOfParticles(configData.getValue<int>("numberOfParticles")); + + if (configData.contains("startXHotWall")) + this->setStartXHotWall(configData.getValue<real>("startXHotWall")); + + if (configData.contains("endXHotWall")) + this->setEndXHotWall(configData.getValue<real>("endXHotWall")); + ////////////////////////////////////////////////////////////////////////// + // for Multi GPU + if (this->getNumprocs() > 1) { + ////////////////////////////////////////////////////////////////////////// + // 3D domain decomposition + std::vector<std::string> sendProcNeighborsX, sendProcNeighborsY, sendProcNeighborsZ; + std::vector<std::string> recvProcNeighborsX, recvProcNeighborsY, recvProcNeighborsZ; + for (int i = 0; i < this->getNumprocs(); i++) { + sendProcNeighborsX.push_back(gridPath + StringUtil::toString(i) + "Xs.dat"); + sendProcNeighborsY.push_back(gridPath + StringUtil::toString(i) + "Ys.dat"); + sendProcNeighborsZ.push_back(gridPath + StringUtil::toString(i) + "Zs.dat"); + recvProcNeighborsX.push_back(gridPath + StringUtil::toString(i) + "Xr.dat"); + recvProcNeighborsY.push_back(gridPath + StringUtil::toString(i) + "Yr.dat"); + recvProcNeighborsZ.push_back(gridPath + StringUtil::toString(i) + "Zr.dat"); + } + this->setPossNeighborFilesX(sendProcNeighborsX, "send"); + this->setPossNeighborFilesY(sendProcNeighborsY, "send"); + this->setPossNeighborFilesZ(sendProcNeighborsZ, "send"); + this->setPossNeighborFilesX(recvProcNeighborsX, "recv"); + this->setPossNeighborFilesY(recvProcNeighborsY, "recv"); + this->setPossNeighborFilesZ(recvProcNeighborsZ, "recv"); + } + + //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // Restart + if (configData.contains("TimeDoCheckPoint")) + this->setTimeDoCheckPoint(configData.getValue<uint>("TimeDoCheckPoint")); + + if (configData.contains("TimeDoRestart")) + this->setTimeDoRestart(configData.getValue<uint>("TimeDoRestart")); + + if (configData.contains("DoCheckPoint")) + this->setDoCheckPoint(configData.getValue<bool>("DoCheckPoint")); + + if (configData.contains("DoRestart")) + this->setDoRestart(configData.getValue<bool>("DoRestart")); + //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + if (configData.contains("NOGL")) + setMaxLevel(configData.getValue<int>("NOGL")); + + this->setGridX(std::vector<int>(this->getMaxLevel() + 1, 32)); + this->setGridY(std::vector<int>(this->getMaxLevel() + 1, 32)); + this->setGridZ(std::vector<int>(this->getMaxLevel() + 1, 32)); + + this->setDistX(std::vector<int>(this->getMaxLevel() + 1, 32)); + this->setDistY(std::vector<int>(this->getMaxLevel() + 1, 32)); + this->setDistZ(std::vector<int>(this->getMaxLevel() + 1, 32)); + + if (configData.contains("GridX")) + this->setGridX(configData.getVector<int>("GridX")); + + if (configData.contains("GridY")) + this->setGridY(configData.getVector<int>("GridY")); + + if (configData.contains("GridZ")) + this->setGridZ(configData.getVector<int>("GridZ")); + + if (configData.contains("DistX")) + this->setDistX(configData.getVector<int>("DistX")); + + if (configData.contains("DistY")) + this->setDistY(configData.getVector<int>("DistY")); + + if (configData.contains("DistZ")) + this->setDistZ(configData.getVector<int>("DistZ")); + + //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // Kernel + if (configData.contains("MainKernelName")) + this->setMainKernel(configData.getValue<std::string>("MainKernelName")); + + if (configData.contains("MultiKernelOn")) + this->setMultiKernelOn(configData.getValue<bool>("MultiKernelOn")); + + if (configData.contains("MultiKernelLevel")) + this->setMultiKernelLevel(configData.getVector<int>("MultiKernelLevel")); + else if (this->getMultiKernelOn()) { + std::vector<int> tmp; + for (int i = 0; i < this->getMaxLevel() + 1; i++) { + tmp.push_back(i); + } + this->setMultiKernelLevel(tmp); + } + + if (configData.contains("MultiKernelName")) + this->setMultiKernel(configData.getVector<std::string>("MultiKernelName")); + else if (this->getMultiKernelOn()) { + std::vector<std::string> tmp; + for (int i = 0; i < this->getMaxLevel() + 1; i++) { + tmp.push_back("CumulantK17Comp"); + } + this->setMultiKernel(tmp); + } } -////////////////////////////////////////////////////////////////////////// -//street X and Y velocity fractions -void Parameter::cudaAllocStreetVelocityFractions(int lev) -{ - unsigned int mem_size_real = sizeof(real) * parH[lev]->numberOfStreetNodes; - unsigned int mem_size_int = sizeof(int) * parH[lev]->numberOfStreetNodes; - //printf("\nnumberOfStreetNodes = %d\n", parH[lev]->numberOfStreetNodes); - - //Host - checkCudaErrors(cudaMallocHost((void**) &(parH[lev]->streetFractionXvelocity), mem_size_real)); - checkCudaErrors(cudaMallocHost((void**) &(parH[lev]->streetFractionYvelocity), mem_size_real)); - checkCudaErrors(cudaMallocHost((void**) &(parH[lev]->naschVelocity ), mem_size_int )); - //Device - checkCudaErrors(cudaMalloc((void**) &(parD[lev]->streetFractionXvelocity), mem_size_real)); - checkCudaErrors(cudaMalloc((void**) &(parD[lev]->streetFractionYvelocity), mem_size_real)); - checkCudaErrors(cudaMalloc((void**) &(parD[lev]->naschVelocity ), mem_size_int )); - - ////////////////////////////////////////////////////////////////////////// - double tmp = 2.0 * (double)mem_size_real + (double)mem_size_int; - setMemsizeGPU(tmp, false); -} -void Parameter::cudaCopyStreetVelocityFractions(int lev) +void Parameter::initLBMSimulationParameter() { - unsigned int mem_size_real = sizeof(real) * parH[lev]->numberOfStreetNodes; - unsigned int mem_size_int = sizeof(int) * parH[lev]->numberOfStreetNodes; - - checkCudaErrors(cudaMemcpy(parD[lev]->streetFractionXvelocity, parH[lev]->streetFractionXvelocity, mem_size_real, cudaMemcpyHostToDevice)); - checkCudaErrors(cudaMemcpy(parD[lev]->streetFractionYvelocity, parH[lev]->streetFractionYvelocity, mem_size_real, cudaMemcpyHostToDevice)); - checkCudaErrors(cudaMemcpy(parD[lev]->naschVelocity, parH[lev]->naschVelocity, mem_size_int, cudaMemcpyHostToDevice)); -} + //host + for (int i = coarse; i <= fine; i++) + { + parH[i] = std::make_shared<LBMSimulationParameter>(); + parH[i]->numberofthreads = 64;// 128; + parH[i]->gridNX = getGridX().at(i); + parH[i]->gridNY = getGridY().at(i); + parH[i]->gridNZ = getGridZ().at(i); + parH[i]->vis = ic.vis*pow(2.f,i); + parH[i]->diffusivity = ic.Diffusivity*pow(2.f,i); + parH[i]->omega = 1.0f/(3.0f*parH[i]->vis+0.5f);//omega :-) not s9 = -1.0f/(3.0f*parH[i]->vis+0.5f);// + parH[i]->nx = parH[i]->gridNX + 2 * STARTOFFX; + parH[i]->ny = parH[i]->gridNY + 2 * STARTOFFY; + parH[i]->nz = parH[i]->gridNZ + 2 * STARTOFFZ; + parH[i]->size_Mat = parH[i]->nx * parH[i]->ny * parH[i]->nz; + parH[i]->sizePlaneXY = parH[i]->nx * parH[i]->ny; + parH[i]->sizePlaneYZ = parH[i]->ny * parH[i]->nz; + parH[i]->sizePlaneXZ = parH[i]->nx * parH[i]->nz; + parH[i]->mem_size_real = sizeof(real ) * parH[i]->size_Mat; + parH[i]->mem_size_int = sizeof(unsigned int) * parH[i]->size_Mat; + parH[i]->mem_size_bool = sizeof(bool ) * parH[i]->size_Mat; + parH[i]->mem_size_real_yz = sizeof(real ) * parH[i]->ny * parH[i]->nz; + parH[i]->evenOrOdd = true; + parH[i]->startz = parH[i]->gridNZ * ic.myid; + parH[i]->endz = parH[i]->gridNZ * ic.myid + parH[i]->gridNZ; + parH[i]->Lx = (real)((1.f*parH[i]->gridNX - 1.f)/(pow(2.f,i))); + parH[i]->Ly = (real)((1.f*parH[i]->gridNY - 1.f)/(pow(2.f,i))); + parH[i]->Lz = (real)((1.f*parH[i]->gridNZ - 1.f)/(pow(2.f,i))); + parH[i]->dx = (real)(1.f/(pow(2.f,i))); + parH[i]->XdistKn = getDistX().at(i); + parH[i]->YdistKn = getDistY().at(i); + parH[i]->ZdistKn = getDistZ().at(i); + if (i == coarse) + { + parH[i]->distX = (real)getDistX().at(i); + parH[i]->distY = (real)getDistY().at(i); + parH[i]->distZ = (real)getDistZ().at(i); + parH[i]->mTtoWx = (real)1.0f; + parH[i]->mTtoWy = (real)1.0f; + parH[i]->mTtoWz = (real)1.0f; + parH[i]->cTtoWx = (real)0.0f; + parH[i]->cTtoWy = (real)0.0f; + parH[i]->cTtoWz = (real)0.0f; + ////MGs Trafo/////////////////////////////////////////////////////////////// + //parH[i]->cStartx = (real)parH[i]->XdistKn; + //parH[i]->cStarty = (real)parH[i]->XdistKn; + //parH[i]->cStartz = (real)parH[i]->XdistKn; + //////////////////////////////////////////////////////////////////////////// + } + else + { + //Geller + parH[i]->distX = ((real)getDistX().at(i) + 0.25f) * parH[i-1]->dx; + parH[i]->distY = ((real)getDistY().at(i) + 0.25f) * parH[i-1]->dx; + parH[i]->distZ = ((real)getDistZ().at(i) + 0.25f) * parH[i-1]->dx; + //parH[i]->distX = ((real)getDistX().at(i) + 0.25f) * parH[i-1]->dx + parH[i-1]->distX; + //parH[i]->distY = ((real)getDistY().at(i) + 0.25f) * parH[i-1]->dx + parH[i-1]->distY; + //parH[i]->distZ = ((real)getDistZ().at(i) + 0.25f) * parH[i-1]->dx + parH[i-1]->distZ; + parH[i]->mTtoWx = (real)pow(0.5f,i); + parH[i]->mTtoWy = (real)pow(0.5f,i); + parH[i]->mTtoWz = (real)pow(0.5f,i); + parH[i]->cTtoWx = (real)(STARTOFFX/2.f + (parH[i]->gridNX+1.f)/4.f); //funzt nur fuer zwei level + parH[i]->cTtoWy = (real)(STARTOFFY/2.f + (parH[i]->gridNY+1.f)/4.f); //funzt nur fuer zwei level + parH[i]->cTtoWz = (real)(STARTOFFZ/2.f + (parH[i]->gridNZ+1.f)/4.f); //funzt nur fuer zwei level + ////MGs Trafo/////////////////////////////////////////////////////////////// + //parH[i]->cStartx = (real)parH[i]->XdistKn; + //parH[i]->cStarty = (real)parH[i]->XdistKn; + //parH[i]->cStartz = (real)parH[i]->XdistKn; + //////////////////////////////////////////////////////////////////////////// + } + } -void Parameter::cudaFreeStreetVelocityFractions(int lev) -{ - checkCudaErrors(cudaFreeHost(parH[lev]->streetFractionXvelocity)); - checkCudaErrors(cudaFreeHost(parH[lev]->streetFractionYvelocity)); - checkCudaErrors(cudaFreeHost(parH[lev]->naschVelocity)); + //device + for (int i = coarse; i <= fine; i++) + { + parD[i] = std::make_shared<LBMSimulationParameter>(); + parD[i]->numberofthreads = parH[i]->numberofthreads; + parD[i]->gridNX = parH[i]->gridNX; + parD[i]->gridNY = parH[i]->gridNY; + parD[i]->gridNZ = parH[i]->gridNZ; + parD[i]->vis = parH[i]->vis; + parD[i]->diffusivity = parH[i]->diffusivity; + parD[i]->omega = parH[i]->omega; + parD[i]->nx = parH[i]->nx; + parD[i]->ny = parH[i]->ny; + parD[i]->nz = parH[i]->nz; + parD[i]->size_Mat = parH[i]->size_Mat; + parD[i]->sizePlaneXY = parH[i]->sizePlaneXY; + parD[i]->sizePlaneYZ = parH[i]->sizePlaneYZ; + parD[i]->sizePlaneXZ = parH[i]->sizePlaneXZ; + parD[i]->mem_size_real = sizeof(real ) * parD[i]->size_Mat; + parD[i]->mem_size_int = sizeof(unsigned int) * parD[i]->size_Mat; + parD[i]->mem_size_bool = sizeof(bool ) * parD[i]->size_Mat; + parD[i]->mem_size_real_yz = sizeof(real ) * parD[i]->ny * parD[i]->nz; + parD[i]->evenOrOdd = parH[i]->evenOrOdd; + parD[i]->startz = parH[i]->startz; + parD[i]->endz = parH[i]->endz; + parD[i]->Lx = parH[i]->Lx; + parD[i]->Ly = parH[i]->Ly; + parD[i]->Lz = parH[i]->Lz; + parD[i]->dx = parH[i]->dx; + parD[i]->XdistKn = parH[i]->XdistKn; + parD[i]->YdistKn = parH[i]->YdistKn; + parD[i]->ZdistKn = parH[i]->ZdistKn; + parD[i]->distX = parH[i]->distX; + parD[i]->distY = parH[i]->distY; + parD[i]->distZ = parH[i]->distZ; + } } -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// -//Process Neighbors -//1D domain decomposition -void Parameter::cudaAllocProcessNeighbor(int lev, unsigned int processNeighbor) +void Parameter::copyMeasurePointsArrayToVector(int lev) { - //Host - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->sendProcessNeighbor[processNeighbor].index ), parH[lev]->sendProcessNeighbor[processNeighbor].memsizeIndex )); - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->sendProcessNeighbor[processNeighbor].f[0] ), getD3Qxx() * parH[lev]->sendProcessNeighbor[processNeighbor].memsizeFs )); - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->recvProcessNeighbor[processNeighbor].index ), parH[lev]->recvProcessNeighbor[processNeighbor].memsizeIndex )); - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->recvProcessNeighbor[processNeighbor].f[0] ), getD3Qxx() * parH[lev]->recvProcessNeighbor[processNeighbor].memsizeFs )); - - //Device - checkCudaErrors( cudaMalloc((void**) &(parD[lev]->sendProcessNeighbor[processNeighbor].index ), parD[lev]->sendProcessNeighbor[processNeighbor].memsizeIndex )); - checkCudaErrors( cudaMalloc((void**) &(parD[lev]->sendProcessNeighbor[processNeighbor].f[0] ), getD3Qxx() * parD[lev]->sendProcessNeighbor[processNeighbor].memsizeFs )); - checkCudaErrors( cudaMalloc((void**) &(parD[lev]->recvProcessNeighbor[processNeighbor].index ), parD[lev]->recvProcessNeighbor[processNeighbor].memsizeIndex )); - checkCudaErrors( cudaMalloc((void**) &(parD[lev]->recvProcessNeighbor[processNeighbor].f[0] ), getD3Qxx() * parD[lev]->recvProcessNeighbor[processNeighbor].memsizeFs )); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - double tmp = (double)parH[lev]->sendProcessNeighbor[processNeighbor].memsizeIndex + (double)getD3Qxx()*(double)parH[lev]->sendProcessNeighbor[processNeighbor].memsizeFs + - (double)parH[lev]->recvProcessNeighbor[processNeighbor].memsizeIndex + (double)getD3Qxx()*(double)parH[lev]->recvProcessNeighbor[processNeighbor].memsizeFs; - setMemsizeGPU(tmp, false); - //printf("memsize GPU for neighbors %f \n",tmp/1000000.0); -} -void Parameter::cudaCopyProcessNeighborIndex(int lev, unsigned int processNeighbor) -{ - //copy send Index - checkCudaErrors( cudaMemcpy(parD[lev]->sendProcessNeighbor[processNeighbor].index, - parH[lev]->sendProcessNeighbor[processNeighbor].index, - parH[lev]->sendProcessNeighbor[processNeighbor].memsizeIndex, - cudaMemcpyHostToDevice)); - //copy recv Index - checkCudaErrors( cudaMemcpy(parD[lev]->recvProcessNeighbor[processNeighbor].index, - parH[lev]->recvProcessNeighbor[processNeighbor].index, - parH[lev]->recvProcessNeighbor[processNeighbor].memsizeIndex, - cudaMemcpyHostToDevice)); -} -void Parameter::cudaCopyProcessNeighborFsHD(int lev, unsigned int processNeighbor) -{ - checkCudaErrors( cudaMemcpy(parD[lev]->recvProcessNeighbor[processNeighbor].f[0], - parH[lev]->recvProcessNeighbor[processNeighbor].f[0], - getD3Qxx() * parD[lev]->recvProcessNeighbor[processNeighbor].memsizeFs, - cudaMemcpyHostToDevice)); -} -void Parameter::cudaCopyProcessNeighborFsDH(int lev, unsigned int processNeighbor) -{ - checkCudaErrors( cudaMemcpy(parH[lev]->sendProcessNeighbor[processNeighbor].f[0], - parD[lev]->sendProcessNeighbor[processNeighbor].f[0], - getD3Qxx() * parD[lev]->sendProcessNeighbor[processNeighbor].memsizeFs, - cudaMemcpyDeviceToHost)); -} -void Parameter::cudaFreeProcessNeighbor(int lev, unsigned int processNeighbor) -{ - checkCudaErrors( cudaFreeHost(parH[lev]->sendProcessNeighbor[processNeighbor].index )); - checkCudaErrors( cudaFreeHost(parH[lev]->sendProcessNeighbor[processNeighbor].f[0] )); - checkCudaErrors( cudaFreeHost(parH[lev]->recvProcessNeighbor[processNeighbor].index )); - checkCudaErrors( cudaFreeHost(parH[lev]->recvProcessNeighbor[processNeighbor].f[0] )); -} -//////////////////////////////////////////////////////////////////////////////////// -// 3D domain decomposition -// X ///////////////////////////////////////////////////////////////////////////// -void Parameter::cudaAllocProcessNeighborX(int lev, unsigned int processNeighbor) -{ - //Host - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->sendProcessNeighborX[processNeighbor].index ), parH[lev]->sendProcessNeighborX[processNeighbor].memsizeIndex )); - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->sendProcessNeighborX[processNeighbor].f[0] ), getD3Qxx() * parH[lev]->sendProcessNeighborX[processNeighbor].memsizeFs )); - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->recvProcessNeighborX[processNeighbor].index ), parH[lev]->recvProcessNeighborX[processNeighbor].memsizeIndex )); - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->recvProcessNeighborX[processNeighbor].f[0] ), getD3Qxx() * parH[lev]->recvProcessNeighborX[processNeighbor].memsizeFs )); - - //Device - checkCudaErrors( cudaMalloc((void**) &(parD[lev]->sendProcessNeighborX[processNeighbor].index ), parD[lev]->sendProcessNeighborX[processNeighbor].memsizeIndex )); - checkCudaErrors( cudaMalloc((void**) &(parD[lev]->sendProcessNeighborX[processNeighbor].f[0] ), getD3Qxx() * parD[lev]->sendProcessNeighborX[processNeighbor].memsizeFs )); - checkCudaErrors( cudaMalloc((void**) &(parD[lev]->recvProcessNeighborX[processNeighbor].index ), parD[lev]->recvProcessNeighborX[processNeighbor].memsizeIndex )); - checkCudaErrors( cudaMalloc((void**) &(parD[lev]->recvProcessNeighborX[processNeighbor].f[0] ), getD3Qxx() * parD[lev]->recvProcessNeighborX[processNeighbor].memsizeFs )); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - double tmp = (double)parH[lev]->sendProcessNeighborX[processNeighbor].memsizeIndex + (double)getD3Qxx()*(double)parH[lev]->sendProcessNeighborX[processNeighbor].memsizeFs + - (double)parH[lev]->recvProcessNeighborX[processNeighbor].memsizeIndex + (double)getD3Qxx()*(double)parH[lev]->recvProcessNeighborX[processNeighbor].memsizeFs; - setMemsizeGPU(tmp, false); - //printf("memsize GPU for neighbors %f \n",tmp/1000000.0); -} -void Parameter::cudaCopyProcessNeighborXIndex(int lev, unsigned int processNeighbor) -{ - //copy send Index - checkCudaErrors( cudaMemcpy(parD[lev]->sendProcessNeighborX[processNeighbor].index, - parH[lev]->sendProcessNeighborX[processNeighbor].index, - parH[lev]->sendProcessNeighborX[processNeighbor].memsizeIndex, - cudaMemcpyHostToDevice)); - //copy recv Index - checkCudaErrors( cudaMemcpy(parD[lev]->recvProcessNeighborX[processNeighbor].index, - parH[lev]->recvProcessNeighborX[processNeighbor].index, - parH[lev]->recvProcessNeighborX[processNeighbor].memsizeIndex, - cudaMemcpyHostToDevice)); -} -void Parameter::cudaCopyProcessNeighborXFsHD(int lev, unsigned int processNeighbor) -{ - checkCudaErrors( cudaMemcpy(parD[lev]->recvProcessNeighborX[processNeighbor].f[0], - parH[lev]->recvProcessNeighborX[processNeighbor].f[0], - getD3Qxx() * parD[lev]->recvProcessNeighborX[processNeighbor].memsizeFs, - cudaMemcpyHostToDevice)); -} -void Parameter::cudaCopyProcessNeighborXFsDH(int lev, unsigned int processNeighbor) -{ - checkCudaErrors( cudaMemcpy(parH[lev]->sendProcessNeighborX[processNeighbor].f[0], - parD[lev]->sendProcessNeighborX[processNeighbor].f[0], - getD3Qxx() * parD[lev]->sendProcessNeighborX[processNeighbor].memsizeFs, - cudaMemcpyDeviceToHost)); -} -void Parameter::cudaFreeProcessNeighborX(int lev, unsigned int processNeighbor) -{ - checkCudaErrors( cudaFreeHost(parH[lev]->sendProcessNeighborX[processNeighbor].index )); - checkCudaErrors( cudaFreeHost(parH[lev]->sendProcessNeighborX[processNeighbor].f[0] )); - checkCudaErrors( cudaFreeHost(parH[lev]->recvProcessNeighborX[processNeighbor].index )); - checkCudaErrors( cudaFreeHost(parH[lev]->recvProcessNeighborX[processNeighbor].f[0] )); -} -// Y ///////////////////////////////////////////////////////////////////////////// -void Parameter::cudaAllocProcessNeighborY(int lev, unsigned int processNeighbor) -{ - //Host - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->sendProcessNeighborY[processNeighbor].index ), parH[lev]->sendProcessNeighborY[processNeighbor].memsizeIndex )); - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->sendProcessNeighborY[processNeighbor].f[0] ), getD3Qxx() * parH[lev]->sendProcessNeighborY[processNeighbor].memsizeFs )); - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->recvProcessNeighborY[processNeighbor].index ), parH[lev]->recvProcessNeighborY[processNeighbor].memsizeIndex )); - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->recvProcessNeighborY[processNeighbor].f[0] ), getD3Qxx() * parH[lev]->recvProcessNeighborY[processNeighbor].memsizeFs )); - - //Device - checkCudaErrors( cudaMalloc((void**) &(parD[lev]->sendProcessNeighborY[processNeighbor].index ), parD[lev]->sendProcessNeighborY[processNeighbor].memsizeIndex )); - checkCudaErrors( cudaMalloc((void**) &(parD[lev]->sendProcessNeighborY[processNeighbor].f[0] ), getD3Qxx() * parD[lev]->sendProcessNeighborY[processNeighbor].memsizeFs )); - checkCudaErrors( cudaMalloc((void**) &(parD[lev]->recvProcessNeighborY[processNeighbor].index ), parD[lev]->recvProcessNeighborY[processNeighbor].memsizeIndex )); - checkCudaErrors( cudaMalloc((void**) &(parD[lev]->recvProcessNeighborY[processNeighbor].f[0] ), getD3Qxx() * parD[lev]->recvProcessNeighborY[processNeighbor].memsizeFs )); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - double tmp = (double)parH[lev]->sendProcessNeighborY[processNeighbor].memsizeIndex + (double)getD3Qxx()*(double)parH[lev]->sendProcessNeighborY[processNeighbor].memsizeFs + - (double)parH[lev]->recvProcessNeighborY[processNeighbor].memsizeIndex + (double)getD3Qxx()*(double)parH[lev]->recvProcessNeighborY[processNeighbor].memsizeFs; - setMemsizeGPU(tmp, false); - //printf("memsize GPU for neighbors %f \n",tmp/1000000.0); -} -void Parameter::cudaCopyProcessNeighborYIndex(int lev, unsigned int processNeighbor) -{ - //copy send Index - checkCudaErrors( cudaMemcpy(parD[lev]->sendProcessNeighborY[processNeighbor].index, - parH[lev]->sendProcessNeighborY[processNeighbor].index, - parH[lev]->sendProcessNeighborY[processNeighbor].memsizeIndex, - cudaMemcpyHostToDevice)); - //copy recv Index - checkCudaErrors( cudaMemcpy(parD[lev]->recvProcessNeighborY[processNeighbor].index, - parH[lev]->recvProcessNeighborY[processNeighbor].index, - parH[lev]->recvProcessNeighborY[processNeighbor].memsizeIndex, - cudaMemcpyHostToDevice)); -} -void Parameter::cudaCopyProcessNeighborYFsHD(int lev, unsigned int processNeighbor) -{ - checkCudaErrors( cudaMemcpy(parD[lev]->recvProcessNeighborY[processNeighbor].f[0], - parH[lev]->recvProcessNeighborY[processNeighbor].f[0], - getD3Qxx() * parD[lev]->recvProcessNeighborY[processNeighbor].memsizeFs, - cudaMemcpyHostToDevice)); -} -void Parameter::cudaCopyProcessNeighborYFsDH(int lev, unsigned int processNeighbor) -{ - checkCudaErrors( cudaMemcpy(parH[lev]->sendProcessNeighborY[processNeighbor].f[0], - parD[lev]->sendProcessNeighborY[processNeighbor].f[0], - getD3Qxx() * parD[lev]->sendProcessNeighborY[processNeighbor].memsizeFs, - cudaMemcpyDeviceToHost)); -} -void Parameter::cudaFreeProcessNeighborY(int lev, unsigned int processNeighbor) -{ - checkCudaErrors( cudaFreeHost(parH[lev]->sendProcessNeighborY[processNeighbor].index )); - checkCudaErrors( cudaFreeHost(parH[lev]->sendProcessNeighborY[processNeighbor].f[0] )); - checkCudaErrors( cudaFreeHost(parH[lev]->recvProcessNeighborY[processNeighbor].index )); - checkCudaErrors( cudaFreeHost(parH[lev]->recvProcessNeighborY[processNeighbor].f[0] )); -} -// Z ///////////////////////////////////////////////////////////////////////////// -void Parameter::cudaAllocProcessNeighborZ(int lev, unsigned int processNeighbor) -{ - //Host - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->sendProcessNeighborZ[processNeighbor].index ), parH[lev]->sendProcessNeighborZ[processNeighbor].memsizeIndex )); - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->sendProcessNeighborZ[processNeighbor].f[0] ), getD3Qxx() * parH[lev]->sendProcessNeighborZ[processNeighbor].memsizeFs )); - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->recvProcessNeighborZ[processNeighbor].index ), parH[lev]->recvProcessNeighborZ[processNeighbor].memsizeIndex )); - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->recvProcessNeighborZ[processNeighbor].f[0] ), getD3Qxx() * parH[lev]->recvProcessNeighborZ[processNeighbor].memsizeFs )); - - //Device - checkCudaErrors( cudaMalloc((void**) &(parD[lev]->sendProcessNeighborZ[processNeighbor].index ), parD[lev]->sendProcessNeighborZ[processNeighbor].memsizeIndex )); - checkCudaErrors( cudaMalloc((void**) &(parD[lev]->sendProcessNeighborZ[processNeighbor].f[0] ), getD3Qxx() * parD[lev]->sendProcessNeighborZ[processNeighbor].memsizeFs )); - checkCudaErrors( cudaMalloc((void**) &(parD[lev]->recvProcessNeighborZ[processNeighbor].index ), parD[lev]->recvProcessNeighborZ[processNeighbor].memsizeIndex )); - checkCudaErrors( cudaMalloc((void**) &(parD[lev]->recvProcessNeighborZ[processNeighbor].f[0] ), getD3Qxx() * parD[lev]->recvProcessNeighborZ[processNeighbor].memsizeFs )); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - double tmp = (double)parH[lev]->sendProcessNeighborZ[processNeighbor].memsizeIndex + (double)getD3Qxx()*(double)parH[lev]->sendProcessNeighborZ[processNeighbor].memsizeFs + - (double)parH[lev]->recvProcessNeighborZ[processNeighbor].memsizeIndex + (double)getD3Qxx()*(double)parH[lev]->recvProcessNeighborZ[processNeighbor].memsizeFs; - setMemsizeGPU(tmp, false); - //printf("memsize GPU for neighbors %f \n",tmp/1000000.0); -} -void Parameter::cudaCopyProcessNeighborZIndex(int lev, unsigned int processNeighbor) -{ - //copy send Index - checkCudaErrors( cudaMemcpy(parD[lev]->sendProcessNeighborZ[processNeighbor].index, - parH[lev]->sendProcessNeighborZ[processNeighbor].index, - parH[lev]->sendProcessNeighborZ[processNeighbor].memsizeIndex, - cudaMemcpyHostToDevice)); - //copy recv Index - checkCudaErrors( cudaMemcpy(parD[lev]->recvProcessNeighborZ[processNeighbor].index, - parH[lev]->recvProcessNeighborZ[processNeighbor].index, - parH[lev]->recvProcessNeighborZ[processNeighbor].memsizeIndex, - cudaMemcpyHostToDevice)); -} -void Parameter::cudaCopyProcessNeighborZFsHD(int lev, unsigned int processNeighbor) -{ - checkCudaErrors( cudaMemcpy(parD[lev]->recvProcessNeighborZ[processNeighbor].f[0], - parH[lev]->recvProcessNeighborZ[processNeighbor].f[0], - getD3Qxx() * parD[lev]->recvProcessNeighborZ[processNeighbor].memsizeFs, - cudaMemcpyHostToDevice)); -} -void Parameter::cudaCopyProcessNeighborZFsDH(int lev, unsigned int processNeighbor) -{ - checkCudaErrors( cudaMemcpy(parH[lev]->sendProcessNeighborZ[processNeighbor].f[0], - parD[lev]->sendProcessNeighborZ[processNeighbor].f[0], - getD3Qxx() * parD[lev]->sendProcessNeighborZ[processNeighbor].memsizeFs, - cudaMemcpyDeviceToHost)); -} -void Parameter::cudaFreeProcessNeighborZ(int lev, unsigned int processNeighbor) -{ - checkCudaErrors( cudaFreeHost(parH[lev]->sendProcessNeighborZ[processNeighbor].index )); - checkCudaErrors( cudaFreeHost(parH[lev]->sendProcessNeighborZ[processNeighbor].f[0] )); - checkCudaErrors( cudaFreeHost(parH[lev]->recvProcessNeighborZ[processNeighbor].index )); - checkCudaErrors( cudaFreeHost(parH[lev]->recvProcessNeighborZ[processNeighbor].f[0] )); -} -//////////////////////////////////////////////////////////////////////////////////// -// 3D domain decomposition convection diffusion -// X ///////////////////////////////////////////////////////////////////////////// -void Parameter::cudaAllocProcessNeighborADX(int lev, unsigned int processNeighbor) -{ - //Host - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->sendProcessNeighborADX[processNeighbor].index ), parH[lev]->sendProcessNeighborADX[processNeighbor].memsizeIndex )); - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->sendProcessNeighborADX[processNeighbor].f[0] ), getDiffMod() * parH[lev]->sendProcessNeighborADX[processNeighbor].memsizeFs )); - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->recvProcessNeighborADX[processNeighbor].index ), parH[lev]->recvProcessNeighborADX[processNeighbor].memsizeIndex )); - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->recvProcessNeighborADX[processNeighbor].f[0] ), getDiffMod() * parH[lev]->recvProcessNeighborADX[processNeighbor].memsizeFs )); - - //Device - checkCudaErrors( cudaMalloc((void**) &(parD[lev]->sendProcessNeighborADX[processNeighbor].index ), parD[lev]->sendProcessNeighborADX[processNeighbor].memsizeIndex )); - checkCudaErrors( cudaMalloc((void**) &(parD[lev]->sendProcessNeighborADX[processNeighbor].f[0] ), getDiffMod() * parD[lev]->sendProcessNeighborADX[processNeighbor].memsizeFs )); - checkCudaErrors( cudaMalloc((void**) &(parD[lev]->recvProcessNeighborADX[processNeighbor].index ), parD[lev]->recvProcessNeighborADX[processNeighbor].memsizeIndex )); - checkCudaErrors( cudaMalloc((void**) &(parD[lev]->recvProcessNeighborADX[processNeighbor].f[0] ), getDiffMod() * parD[lev]->recvProcessNeighborADX[processNeighbor].memsizeFs )); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - double tmp = (double)parH[lev]->sendProcessNeighborADX[processNeighbor].memsizeIndex + (double)getDiffMod()*(double)parH[lev]->sendProcessNeighborADX[processNeighbor].memsizeFs + - (double)parH[lev]->recvProcessNeighborADX[processNeighbor].memsizeIndex + (double)getDiffMod()*(double)parH[lev]->recvProcessNeighborADX[processNeighbor].memsizeFs; - setMemsizeGPU(tmp, false); - //printf("memsize GPU for neighbors %f \n",tmp/1000000.0); -} -void Parameter::cudaCopyProcessNeighborADXIndex(int lev, unsigned int processNeighbor) -{ - //copy send Index - checkCudaErrors( cudaMemcpy(parD[lev]->sendProcessNeighborADX[processNeighbor].index, - parH[lev]->sendProcessNeighborADX[processNeighbor].index, - parH[lev]->sendProcessNeighborADX[processNeighbor].memsizeIndex, - cudaMemcpyHostToDevice)); - //copy recv Index - checkCudaErrors( cudaMemcpy(parD[lev]->recvProcessNeighborADX[processNeighbor].index, - parH[lev]->recvProcessNeighborADX[processNeighbor].index, - parH[lev]->recvProcessNeighborADX[processNeighbor].memsizeIndex, - cudaMemcpyHostToDevice)); -} -void Parameter::cudaCopyProcessNeighborADXFsHD(int lev, unsigned int processNeighbor) -{ - checkCudaErrors( cudaMemcpy(parD[lev]->recvProcessNeighborADX[processNeighbor].f[0], - parH[lev]->recvProcessNeighborADX[processNeighbor].f[0], - getDiffMod() * parD[lev]->recvProcessNeighborADX[processNeighbor].memsizeFs, - cudaMemcpyHostToDevice)); -} -void Parameter::cudaCopyProcessNeighborADXFsDH(int lev, unsigned int processNeighbor) -{ - checkCudaErrors( cudaMemcpy(parH[lev]->sendProcessNeighborADX[processNeighbor].f[0], - parD[lev]->sendProcessNeighborADX[processNeighbor].f[0], - getDiffMod() * parD[lev]->sendProcessNeighborADX[processNeighbor].memsizeFs, - cudaMemcpyDeviceToHost)); -} -void Parameter::cudaFreeProcessNeighborADX(int lev, unsigned int processNeighbor) -{ - checkCudaErrors( cudaFreeHost(parH[lev]->sendProcessNeighborADX[processNeighbor].index )); - checkCudaErrors( cudaFreeHost(parH[lev]->sendProcessNeighborADX[processNeighbor].f[0] )); - checkCudaErrors( cudaFreeHost(parH[lev]->recvProcessNeighborADX[processNeighbor].index )); - checkCudaErrors( cudaFreeHost(parH[lev]->recvProcessNeighborADX[processNeighbor].f[0] )); -} -// Y ///////////////////////////////////////////////////////////////////////////// -void Parameter::cudaAllocProcessNeighborADY(int lev, unsigned int processNeighbor) -{ - //Host - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->sendProcessNeighborADY[processNeighbor].index ), parH[lev]->sendProcessNeighborADY[processNeighbor].memsizeIndex )); - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->sendProcessNeighborADY[processNeighbor].f[0] ), getDiffMod() * parH[lev]->sendProcessNeighborADY[processNeighbor].memsizeFs )); - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->recvProcessNeighborADY[processNeighbor].index ), parH[lev]->recvProcessNeighborADY[processNeighbor].memsizeIndex )); - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->recvProcessNeighborADY[processNeighbor].f[0] ), getDiffMod() * parH[lev]->recvProcessNeighborADY[processNeighbor].memsizeFs )); - - //Device - checkCudaErrors( cudaMalloc((void**) &(parD[lev]->sendProcessNeighborADY[processNeighbor].index ), parD[lev]->sendProcessNeighborADY[processNeighbor].memsizeIndex )); - checkCudaErrors( cudaMalloc((void**) &(parD[lev]->sendProcessNeighborADY[processNeighbor].f[0] ), getDiffMod() * parD[lev]->sendProcessNeighborADY[processNeighbor].memsizeFs )); - checkCudaErrors( cudaMalloc((void**) &(parD[lev]->recvProcessNeighborADY[processNeighbor].index ), parD[lev]->recvProcessNeighborADY[processNeighbor].memsizeIndex )); - checkCudaErrors( cudaMalloc((void**) &(parD[lev]->recvProcessNeighborADY[processNeighbor].f[0] ), getDiffMod() * parD[lev]->recvProcessNeighborADY[processNeighbor].memsizeFs )); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - double tmp = (double)parH[lev]->sendProcessNeighborADY[processNeighbor].memsizeIndex + (double)getDiffMod()*(double)parH[lev]->sendProcessNeighborADY[processNeighbor].memsizeFs + - (double)parH[lev]->recvProcessNeighborADY[processNeighbor].memsizeIndex + (double)getDiffMod()*(double)parH[lev]->recvProcessNeighborADY[processNeighbor].memsizeFs; - setMemsizeGPU(tmp, false); - //printf("memsize GPU for neighbors %f \n",tmp/1000000.0); -} -void Parameter::cudaCopyProcessNeighborADYIndex(int lev, unsigned int processNeighbor) -{ - //copy send Index - checkCudaErrors( cudaMemcpy(parD[lev]->sendProcessNeighborADY[processNeighbor].index, - parH[lev]->sendProcessNeighborADY[processNeighbor].index, - parH[lev]->sendProcessNeighborADY[processNeighbor].memsizeIndex, - cudaMemcpyHostToDevice)); - //copy recv Index - checkCudaErrors( cudaMemcpy(parD[lev]->recvProcessNeighborADY[processNeighbor].index, - parH[lev]->recvProcessNeighborADY[processNeighbor].index, - parH[lev]->recvProcessNeighborADY[processNeighbor].memsizeIndex, - cudaMemcpyHostToDevice)); -} -void Parameter::cudaCopyProcessNeighborADYFsHD(int lev, unsigned int processNeighbor) -{ - checkCudaErrors( cudaMemcpy(parD[lev]->recvProcessNeighborADY[processNeighbor].f[0], - parH[lev]->recvProcessNeighborADY[processNeighbor].f[0], - getDiffMod() * parD[lev]->recvProcessNeighborADY[processNeighbor].memsizeFs, - cudaMemcpyHostToDevice)); -} -void Parameter::cudaCopyProcessNeighborADYFsDH(int lev, unsigned int processNeighbor) -{ - checkCudaErrors( cudaMemcpy(parH[lev]->sendProcessNeighborADY[processNeighbor].f[0], - parD[lev]->sendProcessNeighborADY[processNeighbor].f[0], - getDiffMod() * parD[lev]->sendProcessNeighborADY[processNeighbor].memsizeFs, - cudaMemcpyDeviceToHost)); -} -void Parameter::cudaFreeProcessNeighborADY(int lev, unsigned int processNeighbor) -{ - checkCudaErrors( cudaFreeHost(parH[lev]->sendProcessNeighborADY[processNeighbor].index )); - checkCudaErrors( cudaFreeHost(parH[lev]->sendProcessNeighborADY[processNeighbor].f[0] )); - checkCudaErrors( cudaFreeHost(parH[lev]->recvProcessNeighborADY[processNeighbor].index )); - checkCudaErrors( cudaFreeHost(parH[lev]->recvProcessNeighborADY[processNeighbor].f[0] )); -} -// Z ///////////////////////////////////////////////////////////////////////////// -void Parameter::cudaAllocProcessNeighborADZ(int lev, unsigned int processNeighbor) -{ - //Host - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->sendProcessNeighborADZ[processNeighbor].index ), parH[lev]->sendProcessNeighborADZ[processNeighbor].memsizeIndex )); - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->sendProcessNeighborADZ[processNeighbor].f[0] ), getDiffMod() * parH[lev]->sendProcessNeighborADZ[processNeighbor].memsizeFs )); - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->recvProcessNeighborADZ[processNeighbor].index ), parH[lev]->recvProcessNeighborADZ[processNeighbor].memsizeIndex )); - checkCudaErrors( cudaMallocHost((void**) &(parH[lev]->recvProcessNeighborADZ[processNeighbor].f[0] ), getDiffMod() * parH[lev]->recvProcessNeighborADZ[processNeighbor].memsizeFs )); - - //Device - checkCudaErrors( cudaMalloc((void**) &(parD[lev]->sendProcessNeighborADZ[processNeighbor].index ), parD[lev]->sendProcessNeighborADZ[processNeighbor].memsizeIndex )); - checkCudaErrors( cudaMalloc((void**) &(parD[lev]->sendProcessNeighborADZ[processNeighbor].f[0] ), getDiffMod() * parD[lev]->sendProcessNeighborADZ[processNeighbor].memsizeFs )); - checkCudaErrors( cudaMalloc((void**) &(parD[lev]->recvProcessNeighborADZ[processNeighbor].index ), parD[lev]->recvProcessNeighborADZ[processNeighbor].memsizeIndex )); - checkCudaErrors( cudaMalloc((void**) &(parD[lev]->recvProcessNeighborADZ[processNeighbor].f[0] ), getDiffMod() * parD[lev]->recvProcessNeighborADZ[processNeighbor].memsizeFs )); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - double tmp = (double)parH[lev]->sendProcessNeighborADZ[processNeighbor].memsizeIndex + (double)getDiffMod()*(double)parH[lev]->sendProcessNeighborADZ[processNeighbor].memsizeFs + - (double)parH[lev]->recvProcessNeighborADZ[processNeighbor].memsizeIndex + (double)getDiffMod()*(double)parH[lev]->recvProcessNeighborADZ[processNeighbor].memsizeFs; - setMemsizeGPU(tmp, false); - //printf("memsize GPU for neighbors %f \n",tmp/1000000.0); -} -void Parameter::cudaCopyProcessNeighborADZIndex(int lev, unsigned int processNeighbor) -{ - //copy send Index - checkCudaErrors( cudaMemcpy(parD[lev]->sendProcessNeighborADZ[processNeighbor].index, - parH[lev]->sendProcessNeighborADZ[processNeighbor].index, - parH[lev]->sendProcessNeighborADZ[processNeighbor].memsizeIndex, - cudaMemcpyHostToDevice)); - //copy recv Index - checkCudaErrors( cudaMemcpy(parD[lev]->recvProcessNeighborADZ[processNeighbor].index, - parH[lev]->recvProcessNeighborADZ[processNeighbor].index, - parH[lev]->recvProcessNeighborADZ[processNeighbor].memsizeIndex, - cudaMemcpyHostToDevice)); -} -void Parameter::cudaCopyProcessNeighborADZFsHD(int lev, unsigned int processNeighbor) -{ - checkCudaErrors( cudaMemcpy(parD[lev]->recvProcessNeighborADZ[processNeighbor].f[0], - parH[lev]->recvProcessNeighborADZ[processNeighbor].f[0], - getDiffMod() * parD[lev]->recvProcessNeighborADZ[processNeighbor].memsizeFs, - cudaMemcpyHostToDevice)); -} -void Parameter::cudaCopyProcessNeighborADZFsDH(int lev, unsigned int processNeighbor) -{ - checkCudaErrors( cudaMemcpy(parH[lev]->sendProcessNeighborADZ[processNeighbor].f[0], - parD[lev]->sendProcessNeighborADZ[processNeighbor].f[0], - getDiffMod() * parD[lev]->sendProcessNeighborADZ[processNeighbor].memsizeFs, - cudaMemcpyDeviceToHost)); -} -void Parameter::cudaFreeProcessNeighborADZ(int lev, unsigned int processNeighbor) -{ - checkCudaErrors( cudaFreeHost(parH[lev]->sendProcessNeighborADZ[processNeighbor].index )); - checkCudaErrors( cudaFreeHost(parH[lev]->sendProcessNeighborADZ[processNeighbor].f[0] )); - checkCudaErrors( cudaFreeHost(parH[lev]->recvProcessNeighborADZ[processNeighbor].index )); - checkCudaErrors( cudaFreeHost(parH[lev]->recvProcessNeighborADZ[processNeighbor].f[0] )); + int valuesPerClockCycle = (int)(getclockCycleForMP()/getTimestepForMP()); + for(int i = 0; i < (int)parH[lev]->MP.size(); i++) + { + for(int j = 0; j < valuesPerClockCycle; j++) + { + int index = i*valuesPerClockCycle+j; + parH[lev]->MP[i].Vx.push_back(parH[lev]->VxMP[index]); + parH[lev]->MP[i].Vy.push_back(parH[lev]->VyMP[index]); + parH[lev]->MP[i].Vz.push_back(parH[lev]->VzMP[index]); + parH[lev]->MP[i].Rho.push_back(parH[lev]->RhoMP[index]); + } + } } -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -3423,7 +616,10 @@ void Parameter::setD3Qxx(int d3qxx) } void Parameter::setMaxLevel(int maxlevel) { - this->maxlevel = maxlevel-1; + this->maxlevel = maxlevel-1; + this->fine = this->maxlevel; + parH.resize(this->maxlevel + 1); + parD.resize(this->maxlevel + 1); } void Parameter::setParticleBasicLevel(int pbl) { @@ -3603,10 +799,6 @@ void Parameter::setGeometryFileF(std::string GeometryFileF) { ic.geometryFileF = GeometryFileF; } -void Parameter::setNeedInterface(std::vector<bool> NeedInterface) -{ - ic.NeedInterface = NeedInterface; -} void Parameter::setRe(real Re) { ic.Re = Re; @@ -4297,6 +1489,18 @@ void Parameter::setADKernel(std::string adKernel) //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//add-methods +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +void Parameter::addActuator(SPtr<PreCollisionInteractor> actuator) +{ + actuators.push_back(actuator); +} +void Parameter::addProbe(SPtr<PreCollisionInteractor> probe) +{ + probes.push_back(probe); +} + //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //get-methods @@ -4357,11 +1561,11 @@ unsigned int Parameter::getStartTurn() { return startTurn; } -ParameterStruct* Parameter::getParD(int level) +std::shared_ptr<LBMSimulationParameter> Parameter::getParD(int level) { return parD[level]; } -ParameterStruct* Parameter::getParH(int level) +std::shared_ptr<LBMSimulationParameter> Parameter::getParH(int level) { return parH[level]; } @@ -4555,6 +1759,18 @@ real Parameter::getPressRatio() { return ic.delta_press; } +real Parameter::getTimeRatio() +{ + return this->getViscosityRatio()*pow(this->getVelocityRatio(),-2); +} +real Parameter::getLengthRatio() +{ + return this->getViscosityRatio()/this->getVelocityRatio(); +} +real Parameter::getForceRatio() +{ + return this->getDensityRatio()*pow(this->getViscosityRatio(),2); +} real Parameter::getRealX() { return ic.RealX; @@ -4607,10 +1823,6 @@ std::string Parameter::getGeometryFileF() { return ic.geometryFileF; } -std::vector<bool> Parameter::getNeedInterface() -{ - return ic.NeedInterface; -} real Parameter::getRe() { return ic.Re; @@ -4699,6 +1911,14 @@ TempPressforBoundaryConditions* Parameter::getTempPressD() { return this->TempPressD; } +std::vector<SPtr<PreCollisionInteractor>> Parameter::getActuators() +{ + return actuators; +} +std::vector<SPtr<PreCollisionInteractor>> Parameter::getProbes() +{ + return probes; +} //unsigned int Parameter::getkInflowQ() //{ // return this->kInflowQ; @@ -5050,16 +2270,9 @@ bool Parameter::getIsProp() { return ic.isProp; } -bool Parameter::overWritingRestart(unsigned int t) +bool Parameter::overWritingRestart(uint t) { - if (t == getTimeDoRestart()) - { - return true; - } - else - { - return false; - } + return t == getTimeDoRestart(); } unsigned int Parameter::getTimestepForMP() { @@ -5241,7 +2454,7 @@ std::vector< int> Parameter::getMultiKernelLevel() { return multiKernelLevel; } -std::vector< std::string> Parameter::getMultiKernel() +std::vector<std::string> Parameter::getMultiKernel() { return multiKernel; } @@ -5261,65 +2474,6 @@ std::function<void(real,real,real,real&,real&,real&,real&)>& Parameter::getIniti return this->initialCondition; } -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -//private methods -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -void Parameter::initInterfaceParameter(int level) -{ - /////////////////////////////////////////////////////////////////////////////////////////////////// - //host - parH[level]->K_CF = 0; - parH[level]->K_FC = 0; - if (parH[level]->need_interface[INTERFACE_E]==true) - { - parH[level]->K_CF += ( parH[level+1]->gridNY /2)*( parH[level+1]->gridNZ /2); - parH[level]->K_FC += ((parH[level+1]->gridNY-6)/2)*((parH[level+1]->gridNZ-6)/2); - } - if (parH[level]->need_interface[INTERFACE_W]==true) - { - parH[level]->K_CF += ( parH[level+1]->gridNY /2)*( parH[level+1]->gridNZ /2); - parH[level]->K_FC += ((parH[level+1]->gridNY-6)/2)*((parH[level+1]->gridNZ-6)/2); - } - if (parH[level]->need_interface[INTERFACE_N]==true) - { - parH[level]->K_CF += ( parH[level+1]->gridNX /2)*( parH[level+1]->gridNZ /2); - parH[level]->K_FC += ((parH[level+1]->gridNX-6)/2)*((parH[level+1]->gridNZ-6)/2); - } - if (parH[level]->need_interface[INTERFACE_S]==true) - { - parH[level]->K_CF += ( parH[level+1]->gridNX /2)*( parH[level+1]->gridNZ /2); - parH[level]->K_FC += ((parH[level+1]->gridNX-6)/2)*((parH[level+1]->gridNZ-6)/2); - } - if (parH[level]->need_interface[INTERFACE_T]==true) - { - parH[level]->K_CF += ( parH[level+1]->gridNY /2)*( parH[level+1]->gridNX /2); - parH[level]->K_FC += ((parH[level+1]->gridNY-6)/2)*((parH[level+1]->gridNX-6)/2); - } - if (parH[level]->need_interface[INTERFACE_B]==true) - { - parH[level]->K_CF += ( parH[level+1]->gridNY /2)*( parH[level+1]->gridNX /2); - parH[level]->K_FC += ((parH[level+1]->gridNY-6)/2)*((parH[level+1]->gridNX-6)/2); - } - //parH[level]->K_CF = (( parH[level+1]->gridNY /2)*( parH[level+1]->gridNZ /2)*2)+ - // (( parH[level+1]->gridNX /2)*( parH[level+1]->gridNZ /2)*2)+ - // (( parH[level+1]->gridNY /2)*( parH[level+1]->gridNX /2)*2); - //parH[level]->K_FC = (((parH[level+1]->gridNY-6)/2)*((parH[level+1]->gridNZ-6)/2)*2)+ - // (((parH[level+1]->gridNX-6)/2)*((parH[level+1]->gridNZ-6)/2)*2)+ - // (((parH[level+1]->gridNY-6)/2)*((parH[level+1]->gridNX-6)/2)*2); - parH[level]->mem_size_kCF = sizeof(unsigned int)*parH[level]->K_CF; - parH[level]->mem_size_kFC = sizeof(unsigned int)*parH[level]->K_FC; - parH[level]->mem_size_kCF_off = sizeof(real)*parH[level]->K_CF; - parH[level]->mem_size_kFC_off = sizeof(real)*parH[level]->K_FC; - /////////////////////////////////////////////////////////////////////////////////////////////////// - //device - parD[level]->K_CF = parH[level]->K_CF; - parD[level]->K_FC = parH[level]->K_FC; - parD[level]->mem_size_kCF = parH[level]->mem_size_kCF; - parD[level]->mem_size_kFC = parH[level]->mem_size_kFC; - parD[level]->mem_size_kCF_off = parH[level]->mem_size_kCF_off; - parD[level]->mem_size_kFC_off = parH[level]->mem_size_kFC_off; - /////////////////////////////////////////////////////////////////////////////////////////////////// -} real Parameter::TrafoXtoWorld(int CoordX, int level) { return (parH[level]->mTtoWx*CoordX+parH[level]->cTtoWx); diff --git a/src/gpu/VirtualFluids_GPU/Parameter/Parameter.h b/src/gpu/VirtualFluids_GPU/Parameter/Parameter.h index 3c09f5f0fabd855125987098ac8b7cb2e08ca605..06161934b52e35c2a0932277a651bbdc102424a8 100644 --- a/src/gpu/VirtualFluids_GPU/Parameter/Parameter.h +++ b/src/gpu/VirtualFluids_GPU/Parameter/Parameter.h @@ -1,1096 +1,854 @@ -// _ ___ __ __________ _ __ ______________ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ / ___/ __ / / / / -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ / /___/ /_/ / / / / -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) / /_) / ____/ /__/ / -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ \____/_/ \_____/ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ // -////////////////////////////////////////////////////////////////////////// -#ifndef PARAMETER_H -#define PARAMETER_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 Parameter.h +//! \ingroup Parameter +//! \author Martin Schoenherr +//======================================================================================= +#ifndef GPU_PARAMETER_H +#define GPU_PARAMETER_H #include <vector> +#include <string> +#include <memory> #include <functional> -#include "LBM/LB.h" -#include "LBM/D3Q27.h" -#include "Calculation/PorousMedia.h" -//#include "Output/LogWriter.hpp" -#include <cuda_runtime.h> -#include <helper_cuda.h> -//random numbers -#include <curand.h> -#include <curand_kernel.h> -#include "PointerDefinitions.h" +#include "LBM/D3Q27.h" +#include "LBM/LB.h" +#include "PreCollisionInteractor/PreCollisionInteractor.h" #include "VirtualFluids_GPU_export.h" -class ConfigData; -class Communicator; - -//struct -struct ParameterStruct{ - bool evenOrOdd; - unsigned int numberofthreads; - - //distributions/////////// - //Distributions19 d0; - Distributions27 d0; - Distributions27 d0SP; - - //distributions F3//////// - Distributions6 g6; - - //thermo////////////////// - Distributions7 d7; - Distributions27 d27; - real *Conc, *Conc_Full; - real diffusivity; - //BC NoSlip - TempforBoundaryConditions Temp; - //BC Velocity - TempVelforBoundaryConditions TempVel; - //BC Pressure - TempPressforBoundaryConditions TempPress; - //Plane Conc - real *ConcPlaneIn, *ConcPlaneOut1, *ConcPlaneOut2; - std::vector<double> PlaneConcVectorIn, PlaneConcVectorOut1, PlaneConcVectorOut2; - - //trafo/////////////////// - real mTtoWx, mTtoWy, mTtoWz; - real cTtoWx, cTtoWy, cTtoWz; - - //MGstrafo//////////////// - real cStartx, cStarty, cStartz; - real cFx, cFy, cFz; - - //geo///////////////////// - int *geo; - unsigned int *geoSP; - - //k/////////////////////// - unsigned int *k; - - //neighbor//////////////// - //unsigned int *neighborX, *neighborY, *neighborZ; - unsigned int *neighborX_SP, *neighborY_SP, *neighborZ_SP, *neighborWSB_SP; - - //coordinates//////////// - //unsigned int *coordX_SP, *coordY_SP, *coordZ_SP; - real *coordX_SP, *coordY_SP, *coordZ_SP; - - //body forces//////////// - real *forceX_SP, *forceY_SP, *forceZ_SP; - - //vel parab/////////////// - real *vParab; - - // turbulent viscosity /// - real *turbViscosity; - real *gSij, *gSDij, *gDxvx, *gDyvx, *gDzvx, *gDxvy, *gDyvy, *gDzvy, *gDxvz, *gDyvz, *gDzvz; //DebugInformation - - //macroscopic values////// - real *vx, *vy, *vz, *rho; - real *vx_SP, *vy_SP, *vz_SP, *rho_SP, *press_SP; - real vis, omega; - - //derivations for iso test - real *dxxUx, *dyyUy, *dzzUz; - - //median-macro-values///// - real *vx_SP_Med, *vy_SP_Med, *vz_SP_Med, *rho_SP_Med, *press_SP_Med; - real *vx_SP_Med_Out, *vy_SP_Med_Out, *vz_SP_Med_Out, *rho_SP_Med_Out, *press_SP_Med_Out; - //Advection-Diffusion - real *Conc_Med, *Conc_Med_Out; - - //grid//////////////////// - unsigned int nx, ny, nz; - unsigned int gridNX, gridNY, gridNZ; - - //size of matrix////////// - unsigned int size_Mat; - unsigned int sizePlaneXY, sizePlaneYZ, sizePlaneXZ; - - //size of sparse matrix////////// - unsigned int size_Mat_SP; - unsigned int size_Array_SP; - - //size of Plane btw. 2 GPUs////// - unsigned int sizePlaneSB, sizePlaneRB, startB, endB; - unsigned int sizePlaneST, sizePlaneRT, startT, endT; - bool isSetSendB, isSetRecvB, isSetSendT, isSetRecvT; - int *SendT, *SendB, *RecvT, *RecvB; - - //size of Plane for PressMess - unsigned int sizePlanePress, startP; - unsigned int sizePlanePressIN, startPIN; - unsigned int sizePlanePressOUT, startPOUT; - bool isSetPress; - - //memsizeSP///////////////// - unsigned int mem_size_real_SP; - unsigned int mem_size_int_SP; - - //memsize///////////////// - unsigned int mem_size_real; - unsigned int mem_size_int; - unsigned int mem_size_bool; - unsigned int mem_size_real_yz; - - //print/////////////////// - unsigned int startz, endz; - real Lx,Ly,Lz,dx; - real distX, distY, distZ; - - //interface//////////////// - bool need_interface[6]; - unsigned int XdistKn, YdistKn, ZdistKn; - InterpolationCellCF intCF; - InterpolationCellFC intFC; - unsigned int K_CF; - unsigned int K_FC; - unsigned int mem_size_kCF; - unsigned int mem_size_kFC; - - //offset////////////////// - OffsetCF offCF; - OffsetFC offFC; - unsigned int mem_size_kCF_off; - 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 QpressX0,QpressX1,QpressY0,QpressY1,QpressZ0,QpressZ1; - QforBoundaryConditions QPropeller; - QforBoundaryConditions QPress; - QforBoundaryConditions QGeom; - QforBoundaryConditions QGeomNormalX, QGeomNormalY, QGeomNormalZ; - QforBoundaryConditions QInflowNormalX, QInflowNormalY, QInflowNormalZ; - QforBoundaryConditions QOutflowNormalX, QOutflowNormalY, QOutflowNormalZ; - QforBoundaryConditions QInlet, QOutlet, QPeriodic; - unsigned int kInletQread, kOutletQread; - unsigned int kPressQ=0, kPressQread; - //testRoundoffError - Distributions27 kDistTestRE; - - ////////////////////////////////////////////////////////////////////////// - //velocities to fit the force - real *VxForce, *VyForce, *VzForce; - ////////////////////////////////////////////////////////////////////////// - - //Measure Points///////// - std::vector<MeasurePoints> MP; - unsigned int* kMP; - real* VxMP; - real* VyMP; - real* VzMP; - real* RhoMP; - unsigned int memSizerealkMP, memSizeIntkMP, numberOfPointskMP; - unsigned int numberOfValuesMP; - - //Drag Lift////////////// - double *DragPreX, *DragPostX; - double *DragPreY, *DragPostY; - double *DragPreZ, *DragPostZ; - std::vector<double> DragXvector; - std::vector<double> DragYvector; - std::vector<double> DragZvector; - - //2ndMoments//////////// - real *kxyFromfcNEQ, *kyzFromfcNEQ, *kxzFromfcNEQ, *kxxMyyFromfcNEQ, *kxxMzzFromfcNEQ; - - //3rdMoments//////////// - real *CUMbbb, *CUMabc, *CUMbac, *CUMbca, *CUMcba, *CUMacb, *CUMcab; - - //HigherMoments///////// - real *CUMcbb, *CUMbcb, *CUMbbc, *CUMcca, *CUMcac, *CUMacc, *CUMbcc, *CUMcbc, *CUMccb, *CUMccc; - - //CpTop///////////////// - int *cpTopIndex; - double *cpPressTop; - unsigned int numberOfPointsCpTop; - std::vector< std::vector< double > > cpTop; - std::vector< double > pressMirror; - std::vector< bool > isOutsideInterface; - unsigned int numberOfPointsPressWindow; - - - //CpBottom///////////// - int *cpBottomIndex; - double *cpPressBottom; - unsigned int numberOfPointsCpBottom; - std::vector< std::vector< double > > cpBottom; - - //CpBottom2//////////// - int *cpBottom2Index; - double *cpPressBottom2; - unsigned int numberOfPointsCpBottom2; - std::vector< std::vector< double > > cpBottom2; - - //Concentration//////// - int *concIndex; - real *concentration; - unsigned int numberOfPointsConc; - - //street X and Y velocity fractions/////// - real *streetFractionXvelocity; - real *streetFractionYvelocity; - int *naschVelocity; - uint numberOfStreetNodes; - - //deltaPhi - real deltaPhi; - - //////////////////////////////////////////////////////////////////////////// - //particles - PathLineParticles plp; - //////////////////////////////////////////////////////////////////////////// - - //////////////////////////////////////////////////////////////////////////// - //1D domain decomposition - std::vector< ProcessNeighbor27 > sendProcessNeighbor; - std::vector< ProcessNeighbor27 > recvProcessNeighbor; - /////////////////////////////////////////////////////// - //3D domain decomposition - std::vector< ProcessNeighbor27 > sendProcessNeighborX; - std::vector< ProcessNeighbor27 > sendProcessNeighborY; - std::vector< ProcessNeighbor27 > sendProcessNeighborZ; - std::vector< ProcessNeighbor27 > recvProcessNeighborX; - std::vector< ProcessNeighbor27 > recvProcessNeighborY; - std::vector< ProcessNeighbor27 > recvProcessNeighborZ; - /////////////////////////////////////////////////////// - //3D domain decomposition convection diffusion - std::vector< ProcessNeighbor27 > sendProcessNeighborADX; - std::vector< ProcessNeighbor27 > sendProcessNeighborADY; - std::vector< ProcessNeighbor27 > sendProcessNeighborADZ; - std::vector< ProcessNeighbor27 > recvProcessNeighborADX; - std::vector< ProcessNeighbor27 > recvProcessNeighborADY; - std::vector< ProcessNeighbor27 > recvProcessNeighborADZ; - /////////////////////////////////////////////////////// - //3D domain decomposition F3 - std::vector< ProcessNeighborF3 > sendProcessNeighborF3X; - std::vector< ProcessNeighborF3 > sendProcessNeighborF3Y; - std::vector< ProcessNeighborF3 > sendProcessNeighborF3Z; - std::vector< ProcessNeighborF3 > recvProcessNeighborF3X; - std::vector< ProcessNeighborF3 > recvProcessNeighborF3Y; - std::vector< ProcessNeighborF3 > recvProcessNeighborF3Z; - //////////////////////////////////////////////////////////////////////////// + +struct curandStateXORWOW; +typedef struct curandStateXORWOW curandState; +namespace vf +{ +namespace basics +{ +class ConfigurationFile; +} +} + +//! \struct LBMSimulationParameter +//! \brief struct holds and manages the LB-parameter of the simulation +//! \brief For this purpose it holds structures and pointer for host and device data, respectively. +struct LBMSimulationParameter +{ + bool evenOrOdd; + unsigned int numberofthreads; + + // distributions/////////// + // Distributions19 d0; + Distributions27 d0; + Distributions27 d0SP; + + // distributions F3//////// + Distributions6 g6; + + // thermo////////////////// + Distributions7 d7; + Distributions27 d27; + real *Conc, *Conc_Full; + real diffusivity; + // BC NoSlip + TempforBoundaryConditions Temp; + // BC Velocity + TempVelforBoundaryConditions TempVel; + // BC Pressure + TempPressforBoundaryConditions TempPress; + // Plane Conc + real *ConcPlaneIn, *ConcPlaneOut1, *ConcPlaneOut2; + std::vector<double> PlaneConcVectorIn, PlaneConcVectorOut1, PlaneConcVectorOut2; + + // trafo/////////////////// + real mTtoWx, mTtoWy, mTtoWz; + real cTtoWx, cTtoWy, cTtoWz; + + // MGstrafo//////////////// + real cStartx, cStarty, cStartz; + real cFx, cFy, cFz; + + // geo///////////////////// + int *geo; + unsigned int *geoSP; + + // k/////////////////////// + unsigned int *k; + + // neighbor//////////////// + // unsigned int *neighborX, *neighborY, *neighborZ; + unsigned int *neighborX_SP, *neighborY_SP, *neighborZ_SP, *neighborWSB_SP; + + // coordinates//////////// + // unsigned int *coordX_SP, *coordY_SP, *coordZ_SP; + real *coordX_SP, *coordY_SP, *coordZ_SP; + + // body forces//////////// + real *forceX_SP, *forceY_SP, *forceZ_SP; + + // vel parab/////////////// + real *vParab; + + // turbulent viscosity /// + real *turbViscosity; + real *gSij, *gSDij, *gDxvx, *gDyvx, *gDzvx, *gDxvy, *gDyvy, *gDzvy, *gDxvz, *gDyvz, *gDzvz; // DebugInformation + + // macroscopic values////// + real *vx, *vy, *vz, *rho; + real *vx_SP, *vy_SP, *vz_SP, *rho_SP, *press_SP; + real vis, omega; + + // derivations for iso test + real *dxxUx, *dyyUy, *dzzUz; + + // median-macro-values///// + real *vx_SP_Med, *vy_SP_Med, *vz_SP_Med, *rho_SP_Med, *press_SP_Med; + real *vx_SP_Med_Out, *vy_SP_Med_Out, *vz_SP_Med_Out, *rho_SP_Med_Out, *press_SP_Med_Out; + // Advection-Diffusion + real *Conc_Med, *Conc_Med_Out; + + // grid//////////////////// + unsigned int nx, ny, nz; + unsigned int gridNX, gridNY, gridNZ; + + // size of matrix////////// + unsigned int size_Mat; + unsigned int sizePlaneXY, sizePlaneYZ, sizePlaneXZ; + + // size of sparse matrix////////// + unsigned int size_Mat_SP; + unsigned int size_Array_SP; + + // size of Plane btw. 2 GPUs////// + unsigned int sizePlaneSB, sizePlaneRB, startB, endB; + unsigned int sizePlaneST, sizePlaneRT, startT, endT; + bool isSetSendB, isSetRecvB, isSetSendT, isSetRecvT; + int *SendT, *SendB, *RecvT, *RecvB; + + // size of Plane for PressMess + unsigned int sizePlanePress, startP; + unsigned int sizePlanePressIN, startPIN; + unsigned int sizePlanePressOUT, startPOUT; + bool isSetPress; + + // memsizeSP///////////////// + unsigned int mem_size_real_SP; + unsigned int mem_size_int_SP; + + // memsize///////////////// + unsigned int mem_size_real; + unsigned int mem_size_int; + unsigned int mem_size_bool; + unsigned int mem_size_real_yz; + + // print/////////////////// + unsigned int startz, endz; + real Lx, Ly, Lz, dx; + real distX, distY, distZ; + + // interface//////////////// + bool need_interface[6]; + unsigned int XdistKn, YdistKn, ZdistKn; + InterpolationCellCF intCF; + InterpolationCellFC intFC; + unsigned int K_CF; + unsigned int K_FC; + unsigned int mem_size_kCF; + unsigned int mem_size_kFC; + + // offset////////////////// + OffsetCF offCF; + OffsetFC offFC; + unsigned int mem_size_kCF_off; + 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 QpressX0, QpressX1, QpressY0, QpressY1, QpressZ0, QpressZ1; + QforBoundaryConditions QPropeller; + QforBoundaryConditions QPress; + QforBoundaryConditions QGeom; + QforBoundaryConditions QGeomNormalX, QGeomNormalY, QGeomNormalZ; + QforBoundaryConditions QInflowNormalX, QInflowNormalY, QInflowNormalZ; + QforBoundaryConditions QOutflowNormalX, QOutflowNormalY, QOutflowNormalZ; + QforBoundaryConditions QInlet, QOutlet, QPeriodic; + unsigned int kInletQread, kOutletQread; + unsigned int kPressQ = 0, kPressQread; + // testRoundoffError + Distributions27 kDistTestRE; + + ////////////////////////////////////////////////////////////////////////// + // velocities to fit the force + real *VxForce, *VyForce, *VzForce; + ////////////////////////////////////////////////////////////////////////// + real *forcing; + + // Measure Points///////// + std::vector<MeasurePoints> MP; + unsigned int *kMP; + real *VxMP; + real *VyMP; + real *VzMP; + real *RhoMP; + unsigned int memSizerealkMP, memSizeIntkMP, numberOfPointskMP; + unsigned int numberOfValuesMP; + + // Drag Lift////////////// + double *DragPreX, *DragPostX; + double *DragPreY, *DragPostY; + double *DragPreZ, *DragPostZ; + std::vector<double> DragXvector; + std::vector<double> DragYvector; + std::vector<double> DragZvector; + + // 2ndMoments//////////// + real *kxyFromfcNEQ, *kyzFromfcNEQ, *kxzFromfcNEQ, *kxxMyyFromfcNEQ, *kxxMzzFromfcNEQ; + + // 3rdMoments//////////// + real *CUMbbb, *CUMabc, *CUMbac, *CUMbca, *CUMcba, *CUMacb, *CUMcab; + + // HigherMoments///////// + real *CUMcbb, *CUMbcb, *CUMbbc, *CUMcca, *CUMcac, *CUMacc, *CUMbcc, *CUMcbc, *CUMccb, *CUMccc; + + // CpTop///////////////// + int *cpTopIndex; + double *cpPressTop; + unsigned int numberOfPointsCpTop; + std::vector<std::vector<double>> cpTop; + std::vector<double> pressMirror; + std::vector<bool> isOutsideInterface; + unsigned int numberOfPointsPressWindow; + + // CpBottom///////////// + int *cpBottomIndex; + double *cpPressBottom; + unsigned int numberOfPointsCpBottom; + std::vector<std::vector<double>> cpBottom; + + // CpBottom2//////////// + int *cpBottom2Index; + double *cpPressBottom2; + unsigned int numberOfPointsCpBottom2; + std::vector<std::vector<double>> cpBottom2; + + // Concentration//////// + int *concIndex; + real *concentration; + unsigned int numberOfPointsConc; + + // street X and Y velocity fractions/////// + real *streetFractionXvelocity; + real *streetFractionYvelocity; + int *naschVelocity; + uint numberOfStreetNodes; + + // deltaPhi + real deltaPhi; + + //////////////////////////////////////////////////////////////////////////// + // particles + PathLineParticles plp; + //////////////////////////////////////////////////////////////////////////// + + //////////////////////////////////////////////////////////////////////////// + // 1D domain decomposition + std::vector<ProcessNeighbor27> sendProcessNeighbor; + std::vector<ProcessNeighbor27> recvProcessNeighbor; + /////////////////////////////////////////////////////// + // 3D domain decomposition + std::vector<ProcessNeighbor27> sendProcessNeighborX; + std::vector<ProcessNeighbor27> sendProcessNeighborY; + std::vector<ProcessNeighbor27> sendProcessNeighborZ; + std::vector<ProcessNeighbor27> recvProcessNeighborX; + std::vector<ProcessNeighbor27> recvProcessNeighborY; + std::vector<ProcessNeighbor27> recvProcessNeighborZ; + /////////////////////////////////////////////////////// + // 3D domain decomposition convection diffusion + std::vector<ProcessNeighbor27> sendProcessNeighborADX; + std::vector<ProcessNeighbor27> sendProcessNeighborADY; + std::vector<ProcessNeighbor27> sendProcessNeighborADZ; + std::vector<ProcessNeighbor27> recvProcessNeighborADX; + std::vector<ProcessNeighbor27> recvProcessNeighborADY; + std::vector<ProcessNeighbor27> recvProcessNeighborADZ; + /////////////////////////////////////////////////////// + // 3D domain decomposition F3 + std::vector<ProcessNeighborF3> sendProcessNeighborF3X; + std::vector<ProcessNeighborF3> sendProcessNeighborF3Y; + std::vector<ProcessNeighborF3> sendProcessNeighborF3Z; + std::vector<ProcessNeighborF3> recvProcessNeighborF3X; + std::vector<ProcessNeighborF3> recvProcessNeighborF3Y; + std::vector<ProcessNeighborF3> recvProcessNeighborF3Z; + //////////////////////////////////////////////////////////////////////////// }; class VIRTUALFLUIDS_GPU_EXPORT Parameter { public: - //////////////////////////////////////////////////////////////////////////// - ////really ugly...should be in private... - //Parameter(); - //////////////////////////////////////////////////////////////////////////// - static SPtr<Parameter> make(); - static SPtr<Parameter> make(SPtr<ConfigData> configData, Communicator* comm); - - - static Parameter* getInstanz(); - ParameterStruct* getParH(int level); - ParameterStruct* getParD(int level); - void initParameter(); - void fillSparse(int level); - - //measure points - void copyMeasurePointsArrayToVector(int lev); - - //alloc - void cudaAllocFull(int lev); - void cudaFreeFull(int lev); - - void cudaAllocCoord(int lev); - void cudaCopyCoord(int lev); - void cudaFreeCoord(int lev); - - void cudaCopyPrint(int lev); - void cudaCopyMedianPrint(int lev); - void cudaCopyMedianADPrint(int lev); - - void cudaAllocSP(int lev); - void cudaCopySP(int lev); - void cudaFreeSP(int lev); - - void cudaAllocF3SP(int lev); - - void cudaAllocNeighborWSB(int lev); - void cudaCopyNeighborWSB(int lev); - void cudaFreeNeighborWSB(int lev); - - void cudaAllocTurbulentViscosity(int lev); - void cudaCopyTurbulentViscosityHD(int lev); - void cudaCopyTurbulentViscosityDH(int lev); - void cudaFreeTurbulentViscosity(int lev); - - void cudaAllocMedianSP(int lev); - void cudaCopyMedianSP(int lev); - void cudaFreeMedianSP(int lev); - void cudaAllocMedianOut(int lev); - void cudaFreeMedianOut(int lev); - - void cudaAllocMedianAD(int lev); - void cudaCopyMedianAD(int lev); - void cudaFreeMedianAD(int lev); - void cudaAllocMedianOutAD(int lev); - void cudaFreeMedianOutAD(int lev); - - void cudaAllocInterfaceCF(int lev); - void cudaCopyInterfaceCF(int lev); - void cudaFreeInterfaceCF(int lev); - void cudaAllocInterfaceFC(int lev); - void cudaCopyInterfaceFC(int lev); - void cudaFreeInterfaceFC(int lev); - void cudaAllocInterfaceOffCF(int lev); - void cudaCopyInterfaceOffCF(int lev); - void cudaFreeInterfaceOffCF(int lev); - void cudaAllocInterfaceOffFC(int lev); - void cudaCopyInterfaceOffFC(int lev); - void cudaFreeInterfaceOffFC(int lev); - - void cudaAllocVeloBC(int lev); - void cudaCopyVeloBC(int lev); - void cudaFreeVeloBC(int lev); - void cudaAllocOutflowBC(int lev); - void cudaCopyOutflowBC(int lev); - void cudaFreeOutflowBC(int lev); - void cudaAllocWallBC(int lev); - void cudaCopyWallBC(int lev); - void cudaFreeWallBC(int lev); - void cudaAllocSlipBC(int lev); - void cudaCopySlipBC(int lev); - void cudaFreeSlipBC(int lev); - - void cudaAllocGeomValuesBC(int lev); - void cudaCopyGeomValuesBC(int lev); - void cudaFreeGeomValuesBC(int lev); - void cudaAllocGeomBC(int lev); - void cudaCopyGeomBC(int lev); - void cudaFreeGeomBC(int lev); - //Normals - void cudaAllocGeomNormals(int lev); - void cudaCopyGeomNormals(int lev); - void cudaFreeGeomNormals(int lev); - void cudaAllocInflowNormals(int lev); - void cudaCopyInflowNormals(int lev); - void cudaFreeInflowNormals(int lev); - void cudaAllocOutflowNormals(int lev); - void cudaCopyOutflowNormals(int lev); - void cudaFreeOutflowNormals(int lev); - - void cudaAllocPress(int lev); - void cudaCopyPress(int lev); - void cudaFreePress(int lev); - void cudaAllocTestRE(int lev, unsigned int size); - void cudaCopyTestREtoDevice(int lev, unsigned int size); - void cudaCopyTestREtoHost(int lev, unsigned int size); - void cudaFreeTestRE(int lev); - - void cudaAllocCpTop(int lev); - void cudaCopyCpTopInit(int lev); - void cudaCopyCpTop(int lev); - void cudaFreeCpTop(int lev); - - void cudaAllocCpBottom(int lev); - void cudaCopyCpBottomInit(int lev); - void cudaCopyCpBottom(int lev); - void cudaFreeCpBottom(int lev); - - void cudaAllocCpBottom2(int lev); - void cudaCopyCpBottom2Init(int lev); - void cudaCopyCpBottom2(int lev); - void cudaFreeCpBottom2(int lev); - - void cudaAllocConcFile(int lev); - void cudaCopyConcFile(int lev); - void cudaCopyConcs(int lev); - void cudaFreeConcFile(int lev); - - void cudaAllocStreetVelocityFractions(int lev); - void cudaCopyStreetVelocityFractions(int lev); - void cudaFreeStreetVelocityFractions(int lev); - - void cudaAllocInlet(int lev); - void cudaCopyInlet(int lev); - void cudaFreeInlet(int lev); - void cudaAllocOutlet(int lev); - void cudaCopyOutlet(int lev); - void cudaFreeOutlet(int lev); - - - void cudaAllocPressX0(int lev); - void cudaCopyPressX0(int lev); - void cudaFreePressX0(int lev); - void cudaAllocPressX1(int lev); - void cudaCopyPressX1(int lev); - void cudaFreePressX1(int lev); - - void cudaAllocVeloPropeller(int lev); - void cudaCopyVeloPropeller(int lev); - void cudaFreeVeloPropeller(int lev); - - void cudaAllocMeasurePoints(int lev, int i); - void cudaCopyMeasurePoints(int lev, int i); - void cudaFreeMeasurePoints(int lev, int i); - void cudaAllocMeasurePointsIndex(int lev); - void cudaCopyMeasurePointsIndex(int lev); - void cudaCopyMeasurePointsToHost(int lev); - void cudaFreeMeasurePointsIndex(int lev); - - void cudaAllocFsForCheckPointAndRestart(int lev); - void cudaCopyFsForRestart(int lev); - void cudaCopyFsForCheckPoint(int lev); - void cudaFreeFsForCheckPointAndRestart(int lev); - - void cudaAllocDragLift(int lev, int numofelem); - void cudaCopyDragLift(int lev, int numofelem); - void cudaFreeDragLift(int lev); - - void cudaAlloc2ndMoments(int lev, int numofelem); - void cudaCopy2ndMoments(int lev, int numofelem); - void cudaFree2ndMoments(int lev); - - void cudaAlloc3rdMoments(int lev, int numofelem); - void cudaCopy3rdMoments(int lev, int numofelem); - void cudaFree3rdMoments(int lev); - - void cudaAllocHigherMoments(int lev, int numofelem); - void cudaCopyHigherMoments(int lev, int numofelem); - void cudaFreeHigherMoments(int lev); - - void cudaAllocForceVelo(int lev, int numofelem); - void cudaCopyForceVelo(int lev, int numofelem); - void cudaFreeForceVelo(int lev); - - void cudaAllocForcing(); - void cudaCopyForcingToDevice(); - void cudaCopyForcingToHost(); - void cudaFreeForcing(); - - ////////////////////////////////////////////////////////////////////////// - //Particles - void cudaAllocParticles(int lev); - void cudaCopyParticles(int lev); - void cudaFreeParticles(int lev); - //random value - void cudaAllocRandomValues(); - ////////////////////////////////////////////////////////////////////////// - - - ////////////////////////////////////////////////////////////////////////// - //Porous Media - void cudaAllocPorousMedia(PorousMedia* pm, int lev); - void cudaCopyPorousMedia(PorousMedia* pm, int lev); - void cudaFreePorousMedia(PorousMedia* pm, int lev); - ////////////////////////////////////////////////////////////////////////// - - - ////////////////////////////////////////////////////////////////////////// - //Temperature - void cudaAllocConc(int lev); - void cudaCopyConcDH(int lev); - void cudaCopyConcHD(int lev); - void cudaFreeConc(int lev); - ////////////////////////////////////////////////////////////////////////// - void cudaAllocTempFs(int lev); - ////////////////////////////////////////////////////////////////////////// - void cudaAllocTempPressBC(int lev); - void cudaCopyTempPressBCHD(int lev); - void cudaFreeTempPressBC(int lev); - ////////////////////////////////////////////////////////////////////////// - void cudaAllocTempVeloBC(int lev); - void cudaCopyTempVeloBCHD(int lev); - void cudaFreeTempVeloBC(int lev); - ////////////////////////////////////////////////////////////////////////// - void cudaAllocTempNoSlipBC(int lev); - void cudaCopyTempNoSlipBCHD(int lev); - void cudaFreeTempNoSlipBC(int lev); - ////////////////////////////////////////////////////////////////////////// - void cudaAllocPlaneConcIn(int lev, int numofelem); - void cudaCopyPlaneConcIn(int lev, int numofelem); - void cudaAllocPlaneConcOut1(int lev, int numofelem); - void cudaCopyPlaneConcOut1(int lev, int numofelem); - void cudaAllocPlaneConcOut2(int lev, int numofelem); - void cudaCopyPlaneConcOut2(int lev, int numofelem); - void cudaFreePlaneConc(int lev); - ////////////////////////////////////////////////////////////////////////// - - - ////////////////////////////////////////////////////////////////////////// - //1D domain decomposition - void cudaAllocProcessNeighbor(int lev, unsigned int processNeighbor); - void cudaCopyProcessNeighborFsHD(int lev, unsigned int processNeighbor); - void cudaCopyProcessNeighborFsDH(int lev, unsigned int processNeighbor); - void cudaCopyProcessNeighborIndex(int lev, unsigned int processNeighbor); - void cudaFreeProcessNeighbor(int lev, unsigned int processNeighbor); - ////////////////////////////////////////////////////////////////////////// - //3D domain decomposition - void cudaAllocProcessNeighborX(int lev, unsigned int processNeighbor); - void cudaCopyProcessNeighborXFsHD(int lev, unsigned int processNeighbor); - void cudaCopyProcessNeighborXFsDH(int lev, unsigned int processNeighbor); - void cudaCopyProcessNeighborXIndex(int lev, unsigned int processNeighbor); - void cudaFreeProcessNeighborX(int lev, unsigned int processNeighbor); - // - void cudaAllocProcessNeighborY(int lev, unsigned int processNeighbor); - void cudaCopyProcessNeighborYFsHD(int lev, unsigned int processNeighbor); - void cudaCopyProcessNeighborYFsDH(int lev, unsigned int processNeighbor); - void cudaCopyProcessNeighborYIndex(int lev, unsigned int processNeighbor); - void cudaFreeProcessNeighborY(int lev, unsigned int processNeighbor); - // - void cudaAllocProcessNeighborZ(int lev, unsigned int processNeighbor); - void cudaCopyProcessNeighborZFsHD(int lev, unsigned int processNeighbor); - void cudaCopyProcessNeighborZFsDH(int lev, unsigned int processNeighbor); - void cudaCopyProcessNeighborZIndex(int lev, unsigned int processNeighbor); - void cudaFreeProcessNeighborZ(int lev, unsigned int processNeighbor); - ////////////////////////////////////////////////////////////////////////// - //3D domain decomposition convection diffusion - void cudaAllocProcessNeighborADX(int lev, unsigned int processNeighbor); - void cudaCopyProcessNeighborADXFsHD(int lev, unsigned int processNeighbor); - void cudaCopyProcessNeighborADXFsDH(int lev, unsigned int processNeighbor); - void cudaCopyProcessNeighborADXIndex(int lev, unsigned int processNeighbor); - void cudaFreeProcessNeighborADX(int lev, unsigned int processNeighbor); - // - void cudaAllocProcessNeighborADY(int lev, unsigned int processNeighbor); - void cudaCopyProcessNeighborADYFsHD(int lev, unsigned int processNeighbor); - void cudaCopyProcessNeighborADYFsDH(int lev, unsigned int processNeighbor); - void cudaCopyProcessNeighborADYIndex(int lev, unsigned int processNeighbor); - void cudaFreeProcessNeighborADY(int lev, unsigned int processNeighbor); - // - void cudaAllocProcessNeighborADZ(int lev, unsigned int processNeighbor); - void cudaCopyProcessNeighborADZFsHD(int lev, unsigned int processNeighbor); - void cudaCopyProcessNeighborADZFsDH(int lev, unsigned int processNeighbor); - void cudaCopyProcessNeighborADZIndex(int lev, unsigned int processNeighbor); - void cudaFreeProcessNeighborADZ(int lev, unsigned int processNeighbor); - ////////////////////////////////////////////////////////////////////////// - - - - - - ////////////////////////////////////////////////////////////////////////// - //setter - void setForcing(real forcingX, real forcingY, real forcingZ); - void setQuadricLimiters(real quadricLimiterP, real quadricLimiterM, real quadricLimiterD); - void setPhi(real inPhi); - void setAngularVelocity(real inAngVel); - void setStepEnsight(unsigned int step); - void setOutputCount(unsigned int outputCount); - void setlimitOfNodesForVTK(unsigned int limitOfNodesForVTK); - void setStartTurn(unsigned int inStartTurn); - void setSizeMatSparse(int level); - void setDiffOn(bool isDiff); - void setCompOn(bool isComp); - void setDiffMod(int DiffMod); - void setDiffusivity(real Diffusivity); - void setD3Qxx(int d3qxx); - void setMaxLevel(int maxlevel); - void setParticleBasicLevel(int pbl); - void setParticleInitLevel(int pil); - void setNumberOfParticles(int nop); - void setCalcParticles(bool calcParticles); - void setStartXHotWall(real startXHotWall); - void setEndXHotWall(real endXHotWall); - void setTEnd(unsigned int tend); - void setTOut(unsigned int tout); - void setTStartOut(unsigned int tStartOut); - void setTimestepOfCoarseLevel(unsigned int timestep); - void setCalcMedian(bool calcMedian); - void setCalcDragLift(bool calcDragLift); - void setCalcCp(bool calcCp); - void setWriteVeloASCIIfiles(bool writeVeloASCII); - void setCalcPlaneConc(bool calcPlaneConc); - void setTimeCalcMedStart(int CalcMedStart); - void setTimeCalcMedEnd(int CalcMedEnd); - void setMaxDev(int maxdev); - void setMyID(int myid); - void setNumprocs(int numprocs); - void setPressInID(unsigned int PressInID); - void setPressOutID(unsigned int PressOutID); - void setPressInZ(unsigned int PressInZ); - void setPressOutZ(unsigned int PressOutZ); - void settimestepForMP(unsigned int timestepForMP); - void setOutputPath(std::string oPath); - void setOutputPrefix(std::string oPrefix); - void setFName(std::string fname); - void setGeometryFileC(std::string GeometryFileC); - void setGeometryFileM(std::string GeometryFileM); - void setGeometryFileF(std::string GeometryFileF); - void setkFull(std::string kFull); - void setgeoFull(std::string geoFull); - void setgeoVec(std::string geoVec); - void setcoordX(std::string coordX); - void setcoordY(std::string coordY); - void setcoordZ(std::string coordZ); - void setneighborX(std::string neighborX); - void setneighborY(std::string neighborY); - void setneighborZ(std::string neighborZ); - void setneighborWSB(std::string neighborWSB); - void setscaleCFC(std::string scaleCFC); - void setscaleCFF(std::string scaleCFF); - void setscaleFCC(std::string scaleFCC); - void setscaleFCF(std::string scaleFCF); - void setscaleOffsetCF(std::string scaleOffsetCF); - void setscaleOffsetFC(std::string scaleOffsetFC); - void setgeomBoundaryBcQs(std::string geomBoundaryBcQs); - void setgeomBoundaryBcValues(std::string geomBoundaryBcValues); - void setnoSlipBcPos(std::string noSlipBcPos); - void setnoSlipBcQs(std::string noSlipBcQs); - void setnoSlipBcValue(std::string noSlipBcValue); - void setnoSlipBcValues(std::string noSlipBcValues); - void setslipBcPos(std::string slipBcPos); - void setslipBcQs(std::string slipBcQs); - void setslipBcValue(std::string slipBcValue); - void setpressBcPos(std::string pressBcPos); - void setpressBcQs(std::string pressBcQs); - void setpressBcValue(std::string pressBcValue); - void setpressBcValues(std::string pressBcValues); - void setvelBcQs(std::string velBcQs); - void setvelBcValues(std::string velBcValues); - void setinletBcQs(std::string inletBcQs); - void setinletBcValues(std::string inletBcValues); - void setoutletBcQs(std::string outletBcQs); - void setoutletBcValues(std::string outletBcValues); - void settopBcQs(std::string topBcQs); - void settopBcValues(std::string topBcValues); - void setbottomBcQs(std::string bottomBcQs); - void setbottomBcValues(std::string bottomBcValues); - void setfrontBcQs(std::string frontBcQs); - void setfrontBcValues(std::string frontBcValues); - void setbackBcQs(std::string backBcQs); - void setbackBcValues(std::string backBcValues); - void setwallBcQs(std::string wallBcQs); - void setwallBcValues(std::string wallBcValues); - void setperiodicBcQs(std::string periodicBcQs); - void setperiodicBcValues(std::string periodicBcValues); - void setpropellerCylinder(std::string propellerCylinder); - void setpropellerValues(std::string propellerValues); - void setpropellerQs(std::string propellerQs); - void setmeasurePoints(std::string measurePoints); - void setnumberNodes(std::string numberNodes); - void setLBMvsSI(std::string LBMvsSI); - void setcpTop(std::string cpTop); - void setcpBottom(std::string cpBottom); - void setcpBottom2(std::string cpBottom2); - void setConcentration(std::string concFile); - void setStreetVelocity(std::string streetVelocity); - void setPrintFiles(bool printfiles); - void setReadGeo(bool readGeo); - void setTemperatureInit(real Temp); - void setTemperatureBC(real TempBC); - void setViscosity(real Viscosity); - void setVelocity(real Velocity); - void setViscosityRatio(real ViscosityRatio); - void setVelocityRatio(real VelocityRatio); - void setDensityRatio(real DensityRatio); - void setPressRatio(real PressRatio); - void setRealX(real RealX); - void setRealY(real RealY); - void setRe(real Re); - void setFactorPressBC(real factorPressBC); - void setIsGeo(bool isGeo); - void setIsGeoNormal(bool isGeoNormal); - void setIsInflowNormal(bool isInflowNormal); - void setIsOutflowNormal(bool isOutflowNormal); - void setIsProp(bool isProp); - void setIsCp(bool isCp); - void setConcFile(bool concFile); - void setStreetVelocityFile(bool streetVelocityFile); - void setUseMeasurePoints(bool useMeasurePoints); - void setUseWale(bool useWale); - void setUseInitNeq(bool useInitNeq); - void setSimulatePorousMedia(bool simulatePorousMedia); - void setIsF3(bool isF3); + Parameter(const vf::basics::ConfigurationFile &configData, int numberOfProcesses, int myId); + void initLBMSimulationParameter(); + + std::shared_ptr<LBMSimulationParameter> getParH(int level); + std::shared_ptr<LBMSimulationParameter> getParD(int level); + + void copyMeasurePointsArrayToVector(int lev); + + ////////////////////////////////////////////////////////////////////////// + // setter + void setForcing(real forcingX, real forcingY, real forcingZ); + void setQuadricLimiters(real quadricLimiterP, real quadricLimiterM, real quadricLimiterD); + void setPhi(real inPhi); + void setAngularVelocity(real inAngVel); + void setStepEnsight(unsigned int step); + void setOutputCount(unsigned int outputCount); + void setlimitOfNodesForVTK(unsigned int limitOfNodesForVTK); + void setStartTurn(unsigned int inStartTurn); + void setDiffOn(bool isDiff); + void setCompOn(bool isComp); + void setDiffMod(int DiffMod); + void setDiffusivity(real Diffusivity); + void setD3Qxx(int d3qxx); + void setMaxLevel(int maxlevel); + void setParticleBasicLevel(int pbl); + void setParticleInitLevel(int pil); + void setNumberOfParticles(int nop); + void setCalcParticles(bool calcParticles); + void setStartXHotWall(real startXHotWall); + void setEndXHotWall(real endXHotWall); + void setTEnd(unsigned int tend); + void setTOut(unsigned int tout); + void setTStartOut(unsigned int tStartOut); + void setTimestepOfCoarseLevel(unsigned int timestep); + void setCalcMedian(bool calcMedian); + void setCalcDragLift(bool calcDragLift); + void setCalcCp(bool calcCp); + void setWriteVeloASCIIfiles(bool writeVeloASCII); + void setCalcPlaneConc(bool calcPlaneConc); + void setTimeCalcMedStart(int CalcMedStart); + void setTimeCalcMedEnd(int CalcMedEnd); + void setMaxDev(int maxdev); + void setMyID(int myid); + void setNumprocs(int numprocs); + void setPressInID(unsigned int PressInID); + void setPressOutID(unsigned int PressOutID); + void setPressInZ(unsigned int PressInZ); + void setPressOutZ(unsigned int PressOutZ); + void settimestepForMP(unsigned int timestepForMP); + void setOutputPath(std::string oPath); + void setOutputPrefix(std::string oPrefix); + void setFName(std::string fname); + void setGeometryFileC(std::string GeometryFileC); + void setGeometryFileM(std::string GeometryFileM); + void setGeometryFileF(std::string GeometryFileF); + void setkFull(std::string kFull); + void setgeoFull(std::string geoFull); + void setgeoVec(std::string geoVec); + void setcoordX(std::string coordX); + void setcoordY(std::string coordY); + void setcoordZ(std::string coordZ); + void setneighborX(std::string neighborX); + void setneighborY(std::string neighborY); + void setneighborZ(std::string neighborZ); + void setneighborWSB(std::string neighborWSB); + void setscaleCFC(std::string scaleCFC); + void setscaleCFF(std::string scaleCFF); + void setscaleFCC(std::string scaleFCC); + void setscaleFCF(std::string scaleFCF); + void setscaleOffsetCF(std::string scaleOffsetCF); + void setscaleOffsetFC(std::string scaleOffsetFC); + void setgeomBoundaryBcQs(std::string geomBoundaryBcQs); + void setgeomBoundaryBcValues(std::string geomBoundaryBcValues); + void setnoSlipBcPos(std::string noSlipBcPos); + void setnoSlipBcQs(std::string noSlipBcQs); + void setnoSlipBcValue(std::string noSlipBcValue); + void setnoSlipBcValues(std::string noSlipBcValues); + void setslipBcPos(std::string slipBcPos); + void setslipBcQs(std::string slipBcQs); + void setslipBcValue(std::string slipBcValue); + void setpressBcPos(std::string pressBcPos); + void setpressBcQs(std::string pressBcQs); + void setpressBcValue(std::string pressBcValue); + void setpressBcValues(std::string pressBcValues); + void setvelBcQs(std::string velBcQs); + void setvelBcValues(std::string velBcValues); + void setinletBcQs(std::string inletBcQs); + void setinletBcValues(std::string inletBcValues); + void setoutletBcQs(std::string outletBcQs); + void setoutletBcValues(std::string outletBcValues); + void settopBcQs(std::string topBcQs); + void settopBcValues(std::string topBcValues); + void setbottomBcQs(std::string bottomBcQs); + void setbottomBcValues(std::string bottomBcValues); + void setfrontBcQs(std::string frontBcQs); + void setfrontBcValues(std::string frontBcValues); + void setbackBcQs(std::string backBcQs); + void setbackBcValues(std::string backBcValues); + void setwallBcQs(std::string wallBcQs); + void setwallBcValues(std::string wallBcValues); + void setperiodicBcQs(std::string periodicBcQs); + void setperiodicBcValues(std::string periodicBcValues); + void setpropellerCylinder(std::string propellerCylinder); + void setpropellerValues(std::string propellerValues); + void setpropellerQs(std::string propellerQs); + void setmeasurePoints(std::string measurePoints); + void setnumberNodes(std::string numberNodes); + void setLBMvsSI(std::string LBMvsSI); + void setcpTop(std::string cpTop); + void setcpBottom(std::string cpBottom); + void setcpBottom2(std::string cpBottom2); + void setConcentration(std::string concFile); + void setStreetVelocity(std::string streetVelocity); + void setPrintFiles(bool printfiles); + void setReadGeo(bool readGeo); + void setTemperatureInit(real Temp); + void setTemperatureBC(real TempBC); + void setViscosity(real Viscosity); + void setVelocity(real Velocity); + void setViscosityRatio(real ViscosityRatio); + void setVelocityRatio(real VelocityRatio); + void setDensityRatio(real DensityRatio); + void setPressRatio(real PressRatio); + void setRealX(real RealX); + void setRealY(real RealY); + void setRe(real Re); + void setFactorPressBC(real factorPressBC); + void setIsGeo(bool isGeo); + void setIsGeoNormal(bool isGeoNormal); + void setIsInflowNormal(bool isInflowNormal); + void setIsOutflowNormal(bool isOutflowNormal); + void setIsProp(bool isProp); + void setIsCp(bool isCp); + void setConcFile(bool concFile); + void setStreetVelocityFile(bool streetVelocityFile); + void setUseMeasurePoints(bool useMeasurePoints); + void setUseWale(bool useWale); + void setUseInitNeq(bool useInitNeq); + void setSimulatePorousMedia(bool simulatePorousMedia); + void setIsF3(bool isF3); void setIsBodyForce(bool isBodyForce); - void setclockCycleForMP(real clockCycleForMP); - void setDevices(std::vector<uint> devices); - void setGridX(std::vector<int> GridX); - void setGridY(std::vector<int> GridY); - void setGridZ(std::vector<int> GridZ); - void setDistX(std::vector<int> DistX); - void setDistY(std::vector<int> DistY); - void setDistZ(std::vector<int> DistZ); - void setScaleLBMtoSI(std::vector<real> scaleLBMtoSI); - void setTranslateLBMtoSI(std::vector<real> translateLBMtoSI); - void setMinCoordX(std::vector<real> MinCoordX); - void setMinCoordY(std::vector<real> MinCoordY); - void setMinCoordZ(std::vector<real> MinCoordZ); - void setMaxCoordX(std::vector<real> MaxCoordX); - void setMaxCoordY(std::vector<real> MaxCoordY); - void setMaxCoordZ(std::vector<real> MaxCoordZ); - void setNeedInterface(std::vector<bool> NeedInterface); - void setTempH(TempforBoundaryConditions* TempH); - void setTempD(TempforBoundaryConditions* TempD); - void setTempVelH(TempVelforBoundaryConditions* TempVelH); - void setTempVelD(TempVelforBoundaryConditions* TempVelD); - void setTempPressH(TempPressforBoundaryConditions* TempPressH); - void setTempPressD(TempPressforBoundaryConditions* TempPressD); - void setTimeDoCheckPoint(unsigned int tDoCheckPoint); - void setTimeDoRestart(unsigned int tDoRestart); - void setDoCheckPoint(bool doCheckPoint); - void setDoRestart(bool doRestart); - void setObj(std::string str, bool isObj); - void setGeometryValues(bool GeometryValues); - void setCalc2ndOrderMoments(bool is2ndOrderMoments); - void setCalc3rdOrderMoments(bool is3rdOrderMoments); - void setCalcHighOrderMoments(bool isHighOrderMoments); - void setMemsizeGPU(double admem, bool reset); - //1D domain decomposition - void setPossNeighborFiles(std::vector<std::string> possNeighborFiles, std::string sor); - void setNumberOfProcessNeighbors(unsigned int numberOfProcessNeighbors, int level, std::string sor); - void setIsNeighbor(bool isNeighbor); - //3D domain decomposition - void setPossNeighborFilesX(std::vector<std::string> possNeighborFiles, std::string sor); - void setPossNeighborFilesY(std::vector<std::string> possNeighborFiles, std::string sor); - void setPossNeighborFilesZ(std::vector<std::string> possNeighborFiles, std::string sor); - void setNumberOfProcessNeighborsX(unsigned int numberOfProcessNeighbors, int level, std::string sor); - void setNumberOfProcessNeighborsY(unsigned int numberOfProcessNeighbors, int level, std::string sor); - void setNumberOfProcessNeighborsZ(unsigned int numberOfProcessNeighbors, int level, std::string sor); - void setIsNeighborX(bool isNeighbor); - void setIsNeighborY(bool isNeighbor); - void setIsNeighborZ(bool isNeighbor); - //void setkInflowQ(unsigned int kInflowQ); - //void setkOutflowQ(unsigned int kOutflowQ); - //void setQinflowH(QforBoundaryConditions* QinflowH); - //void setQinflowD(QforBoundaryConditions* QinflowD); - //void setQoutflowH(QforBoundaryConditions* QoutflowH); - //void setQoutflowD(QforBoundaryConditions* QoutflowD); - //Normals - void setgeomBoundaryNormalX(std::string geomNormalX); - void setgeomBoundaryNormalY(std::string geomNormalY); - void setgeomBoundaryNormalZ(std::string geomNormalZ); - void setInflowBoundaryNormalX(std::string inflowNormalX); - void setInflowBoundaryNormalY(std::string inflowNormalY); - void setInflowBoundaryNormalZ(std::string inflowNormalZ); - void setOutflowBoundaryNormalX(std::string outflowNormalX); - void setOutflowBoundaryNormalY(std::string outflowNormalY); - void setOutflowBoundaryNormalZ(std::string outflowNormalZ); - //Kernel + void setclockCycleForMP(real clockCycleForMP); + void setDevices(std::vector<uint> devices); + void setGridX(std::vector<int> GridX); + void setGridY(std::vector<int> GridY); + void setGridZ(std::vector<int> GridZ); + void setDistX(std::vector<int> DistX); + void setDistY(std::vector<int> DistY); + void setDistZ(std::vector<int> DistZ); + void setScaleLBMtoSI(std::vector<real> scaleLBMtoSI); + void setTranslateLBMtoSI(std::vector<real> translateLBMtoSI); + void setMinCoordX(std::vector<real> MinCoordX); + void setMinCoordY(std::vector<real> MinCoordY); + void setMinCoordZ(std::vector<real> MinCoordZ); + void setMaxCoordX(std::vector<real> MaxCoordX); + void setMaxCoordY(std::vector<real> MaxCoordY); + void setMaxCoordZ(std::vector<real> MaxCoordZ); + void setTempH(TempforBoundaryConditions *TempH); + void setTempD(TempforBoundaryConditions *TempD); + void setTempVelH(TempVelforBoundaryConditions *TempVelH); + void setTempVelD(TempVelforBoundaryConditions *TempVelD); + void setTempPressH(TempPressforBoundaryConditions *TempPressH); + void setTempPressD(TempPressforBoundaryConditions *TempPressD); + void setTimeDoCheckPoint(unsigned int tDoCheckPoint); + void setTimeDoRestart(unsigned int tDoRestart); + void setDoCheckPoint(bool doCheckPoint); + void setDoRestart(bool doRestart); + void setObj(std::string str, bool isObj); + void setGeometryValues(bool GeometryValues); + void setCalc2ndOrderMoments(bool is2ndOrderMoments); + void setCalc3rdOrderMoments(bool is3rdOrderMoments); + void setCalcHighOrderMoments(bool isHighOrderMoments); + void setMemsizeGPU(double admem, bool reset); + // 1D domain decomposition + void setPossNeighborFiles(std::vector<std::string> possNeighborFiles, std::string sor); + void setNumberOfProcessNeighbors(unsigned int numberOfProcessNeighbors, int level, std::string sor); + void setIsNeighbor(bool isNeighbor); + // 3D domain decomposition + void setPossNeighborFilesX(std::vector<std::string> possNeighborFiles, std::string sor); + void setPossNeighborFilesY(std::vector<std::string> possNeighborFiles, std::string sor); + void setPossNeighborFilesZ(std::vector<std::string> possNeighborFiles, std::string sor); + void setNumberOfProcessNeighborsX(unsigned int numberOfProcessNeighbors, int level, std::string sor); + void setNumberOfProcessNeighborsY(unsigned int numberOfProcessNeighbors, int level, std::string sor); + void setNumberOfProcessNeighborsZ(unsigned int numberOfProcessNeighbors, int level, std::string sor); + void setIsNeighborX(bool isNeighbor); + void setIsNeighborY(bool isNeighbor); + void setIsNeighborZ(bool isNeighbor); + // void setkInflowQ(unsigned int kInflowQ); + // void setkOutflowQ(unsigned int kOutflowQ); + // void setQinflowH(QforBoundaryConditions* QinflowH); + // void setQinflowD(QforBoundaryConditions* QinflowD); + // void setQoutflowH(QforBoundaryConditions* QoutflowH); + // void setQoutflowD(QforBoundaryConditions* QoutflowD); + // Normals + void setgeomBoundaryNormalX(std::string geomNormalX); + void setgeomBoundaryNormalY(std::string geomNormalY); + void setgeomBoundaryNormalZ(std::string geomNormalZ); + void setInflowBoundaryNormalX(std::string inflowNormalX); + void setInflowBoundaryNormalY(std::string inflowNormalY); + void setInflowBoundaryNormalZ(std::string inflowNormalZ); + void setOutflowBoundaryNormalX(std::string outflowNormalX); + void setOutflowBoundaryNormalY(std::string outflowNormalY); + void setOutflowBoundaryNormalZ(std::string outflowNormalZ); + // Kernel void setMainKernel(std::string kernel); - void setMultiKernelOn(bool isOn); - void setMultiKernelLevel(std::vector<int> kernelLevel); + void setMultiKernelOn(bool isOn); + void setMultiKernelLevel(std::vector<int> kernelLevel); void setMultiKernel(std::vector<std::string> kernel); - void setADKernel(std::string adKernel); - - //getter - double* getForcesDouble(); - real* getForcesHost(); - real* getForcesDev(); - double* getQuadricLimitersDouble(); - real* getQuadricLimitersHost(); - real* getQuadricLimitersDev(); - real getPhi(); - real getAngularVelocity(); - real getStartXHotWall(); - real getEndXHotWall(); - unsigned int getStepEnsight(); - unsigned int getOutputCount(); - unsigned int getlimitOfNodesForVTK(); - unsigned int getStartTurn(); - bool getEvenOrOdd(int level); - bool getDiffOn(); - bool getCompOn(); - bool getPrintFiles(); - bool getReadGeo(); - bool getCalcMedian(); - bool getCalcDragLift(); - bool getCalcCp(); - bool getCalcParticle(); - bool getWriteVeloASCIIfiles(); - bool getCalcPlaneConc(); - int getFine(); - int getCoarse(); - int getParticleBasicLevel(); - int getParticleInitLevel(); - int getNumberOfParticles(); - int getDiffMod(); - int getFactorNZ(); - int getD3Qxx(); - int getMaxLevel(); - int getTimeCalcMedStart(); - int getTimeCalcMedEnd(); - int getMaxDev(); - int getMyID(); - int getNumprocs(); - std::string getOutputPath(); - std::string getOutputPrefix(); - std::string getFName(); - std::string getGeometryFileC(); - std::string getGeometryFileM(); - std::string getGeometryFileF(); - std::string getkFull(); - std::string getgeoFull(); - std::string getgeoVec(); - std::string getcoordX(); - std::string getcoordY(); - std::string getcoordZ(); - std::string getneighborX(); - std::string getneighborY(); - std::string getneighborZ(); - std::string getneighborWSB(); - std::string getscaleCFC(); - std::string getscaleCFF(); - std::string getscaleFCC(); - std::string getscaleFCF(); - std::string getscaleOffsetCF(); - std::string getscaleOffsetFC(); - std::string getgeomBoundaryBcQs(); - std::string getgeomBoundaryBcValues(); - std::string getnoSlipBcPos(); - std::string getnoSlipBcQs(); - std::string getnoSlipBcValue(); - std::string getnoSlipBcValues(); - std::string getslipBcPos(); - std::string getslipBcQs(); - std::string getslipBcValue(); - std::string getpressBcPos(); - std::string getpressBcQs(); - std::string getpressBcValue(); - std::string getpressBcValues(); - std::string getvelBcQs(); - std::string getvelBcValues(); - std::string getinletBcQs(); - std::string getinletBcValues(); - std::string getoutletBcQs(); - std::string getoutletBcValues(); - std::string gettopBcQs(); - std::string gettopBcValues(); - std::string getbottomBcQs(); - std::string getbottomBcValues(); - std::string getfrontBcQs(); - std::string getfrontBcValues(); - std::string getbackBcQs(); - std::string getbackBcValues(); - std::string getwallBcQs(); - std::string getwallBcValues(); - std::string getperiodicBcQs(); - std::string getperiodicBcValues(); - std::string getpropellerQs(); - std::string getpropellerCylinder(); - std::string getpropellerValues(); - std::string getmeasurePoints(); - std::string getnumberNodes(); - std::string getLBMvsSI(); - std::string getcpTop(); - std::string getcpBottom(); - std::string getcpBottom2(); - std::string getConcentration(); - std::string getStreetVelocityFilePath(); - unsigned int getPressInID(); - unsigned int getPressOutID(); - unsigned int getPressInZ(); - unsigned int getPressOutZ(); - unsigned int getMemSizereal(int level); - unsigned int getMemSizeInt(int level); - unsigned int getMemSizeBool(int level); - unsigned int getMemSizerealYZ(int level); - unsigned int getSizeMat(int level); - unsigned int getTStart(); - unsigned int getTInit(); - unsigned int getTEnd(); - unsigned int getTOut(); - unsigned int getTStartOut(); - unsigned int getTimestepForMP(); - unsigned int getTimestepOfCoarseLevel(); - real getDiffusivity(); - real getTemperatureInit(); - real getTemperatureBC(); - real getViscosity(); - real getVelocity(); - real getViscosityRatio(); - real getVelocityRatio(); - real getDensityRatio(); - real getPressRatio(); - real getRealX(); - real getRealY(); - real getRe(); - real getFactorPressBC(); - real getclockCycleForMP(); - std::vector<uint> getDevices(); - std::vector<int> getGridX(); - std::vector<int> getGridY(); - std::vector<int> getGridZ(); - std::vector<int> getDistX(); - std::vector<int> getDistY(); - std::vector<int> getDistZ(); - std::vector<real> getScaleLBMtoSI(); - std::vector<real> getTranslateLBMtoSI(); - std::vector<real> getMinCoordX(); - std::vector<real> getMinCoordY(); - std::vector<real> getMinCoordZ(); - std::vector<real> getMaxCoordX(); - std::vector<real> getMaxCoordY(); - std::vector<real> getMaxCoordZ(); - std::vector<bool> getNeedInterface(); - TempforBoundaryConditions* getTempH(); - TempforBoundaryConditions* getTempD(); - TempVelforBoundaryConditions* getTempVelH(); - TempVelforBoundaryConditions* getTempVelD(); - TempPressforBoundaryConditions* getTempPressH(); - TempPressforBoundaryConditions* getTempPressD(); - unsigned int getTimeDoCheckPoint(); - unsigned int getTimeDoRestart(); - bool getDoCheckPoint(); - bool getDoRestart(); - bool overWritingRestart(unsigned int t); - bool getIsGeo(); - bool getIsGeoNormal(); - bool getIsInflowNormal(); - bool getIsOutflowNormal(); - bool getIsProp(); - bool getIsCp(); - bool getIsGeometryValues(); - bool getCalc2ndOrderMoments(); - bool getCalc3rdOrderMoments(); - bool getCalcHighOrderMoments(); - bool getConcFile(); - bool isStreetVelocityFile(); - bool getUseMeasurePoints(); - bool getUseWale(); - bool getUseInitNeq(); - bool getSimulatePorousMedia(); - bool getIsF3(); + void setADKernel(std::string adKernel); + + //adder + + void addActuator(SPtr<PreCollisionInteractor> actuator); + void addProbe(SPtr<PreCollisionInteractor> probes); + + // getter + double *getForcesDouble(); + real *getForcesHost(); + real *getForcesDev(); + double *getQuadricLimitersDouble(); + real *getQuadricLimitersHost(); + real *getQuadricLimitersDev(); + real getPhi(); + real getAngularVelocity(); + real getStartXHotWall(); + real getEndXHotWall(); + unsigned int getStepEnsight(); + unsigned int getOutputCount(); + unsigned int getlimitOfNodesForVTK(); + unsigned int getStartTurn(); + bool getEvenOrOdd(int level); + bool getDiffOn(); + bool getCompOn(); + bool getPrintFiles(); + bool getReadGeo(); + bool getCalcMedian(); + bool getCalcDragLift(); + bool getCalcCp(); + bool getCalcParticle(); + bool getWriteVeloASCIIfiles(); + bool getCalcPlaneConc(); + int getFine(); + int getCoarse(); + int getParticleBasicLevel(); + int getParticleInitLevel(); + int getNumberOfParticles(); + int getDiffMod(); + int getFactorNZ(); + int getD3Qxx(); + int getMaxLevel(); + int getTimeCalcMedStart(); + int getTimeCalcMedEnd(); + int getMaxDev(); + int getMyID(); + int getNumprocs(); + std::string getOutputPath(); + std::string getOutputPrefix(); + std::string getFName(); + std::string getGeometryFileC(); + std::string getGeometryFileM(); + std::string getGeometryFileF(); + std::string getkFull(); + std::string getgeoFull(); + std::string getgeoVec(); + std::string getcoordX(); + std::string getcoordY(); + std::string getcoordZ(); + std::string getneighborX(); + std::string getneighborY(); + std::string getneighborZ(); + std::string getneighborWSB(); + std::string getscaleCFC(); + std::string getscaleCFF(); + std::string getscaleFCC(); + std::string getscaleFCF(); + std::string getscaleOffsetCF(); + std::string getscaleOffsetFC(); + std::string getgeomBoundaryBcQs(); + std::string getgeomBoundaryBcValues(); + std::string getnoSlipBcPos(); + std::string getnoSlipBcQs(); + std::string getnoSlipBcValue(); + std::string getnoSlipBcValues(); + std::string getslipBcPos(); + std::string getslipBcQs(); + std::string getslipBcValue(); + std::string getpressBcPos(); + std::string getpressBcQs(); + std::string getpressBcValue(); + std::string getpressBcValues(); + std::string getvelBcQs(); + std::string getvelBcValues(); + std::string getinletBcQs(); + std::string getinletBcValues(); + std::string getoutletBcQs(); + std::string getoutletBcValues(); + std::string gettopBcQs(); + std::string gettopBcValues(); + std::string getbottomBcQs(); + std::string getbottomBcValues(); + std::string getfrontBcQs(); + std::string getfrontBcValues(); + std::string getbackBcQs(); + std::string getbackBcValues(); + std::string getwallBcQs(); + std::string getwallBcValues(); + std::string getperiodicBcQs(); + std::string getperiodicBcValues(); + std::string getpropellerQs(); + std::string getpropellerCylinder(); + std::string getpropellerValues(); + std::string getmeasurePoints(); + std::string getnumberNodes(); + std::string getLBMvsSI(); + std::string getcpTop(); + std::string getcpBottom(); + std::string getcpBottom2(); + std::string getConcentration(); + std::string getStreetVelocityFilePath(); + unsigned int getPressInID(); + unsigned int getPressOutID(); + unsigned int getPressInZ(); + unsigned int getPressOutZ(); + unsigned int getMemSizereal(int level); + unsigned int getMemSizeInt(int level); + unsigned int getMemSizeBool(int level); + unsigned int getMemSizerealYZ(int level); + unsigned int getSizeMat(int level); + unsigned int getTStart(); + unsigned int getTInit(); + unsigned int getTEnd(); + unsigned int getTOut(); + unsigned int getTStartOut(); + unsigned int getTimestepForMP(); + unsigned int getTimestepOfCoarseLevel(); + real getDiffusivity(); + real getTemperatureInit(); + real getTemperatureBC(); + real getViscosity(); + real getVelocity(); + real getViscosityRatio(); + real getVelocityRatio(); + real getDensityRatio(); + real getPressRatio(); + real getTimeRatio(); + real getLengthRatio(); + real getForceRatio(); + real getRealX(); + real getRealY(); + real getRe(); + real getFactorPressBC(); + real getclockCycleForMP(); + std::vector<uint> getDevices(); + std::vector<int> getGridX(); + std::vector<int> getGridY(); + std::vector<int> getGridZ(); + std::vector<int> getDistX(); + std::vector<int> getDistY(); + std::vector<int> getDistZ(); + std::vector<real> getScaleLBMtoSI(); + std::vector<real> getTranslateLBMtoSI(); + std::vector<real> getMinCoordX(); + std::vector<real> getMinCoordY(); + std::vector<real> getMinCoordZ(); + std::vector<real> getMaxCoordX(); + std::vector<real> getMaxCoordY(); + std::vector<real> getMaxCoordZ(); + TempforBoundaryConditions *getTempH(); + TempforBoundaryConditions *getTempD(); + TempVelforBoundaryConditions *getTempVelH(); + TempVelforBoundaryConditions *getTempVelD(); + TempPressforBoundaryConditions *getTempPressH(); + TempPressforBoundaryConditions *getTempPressD(); + std::vector<SPtr<PreCollisionInteractor>> getActuators(); + std::vector<SPtr<PreCollisionInteractor>> getProbes(); + unsigned int getTimeDoCheckPoint(); + unsigned int getTimeDoRestart(); + bool getDoCheckPoint(); + bool getDoRestart(); + bool overWritingRestart(unsigned int t); + bool getIsGeo(); + bool getIsGeoNormal(); + bool getIsInflowNormal(); + bool getIsOutflowNormal(); + bool getIsProp(); + bool getIsCp(); + bool getIsGeometryValues(); + bool getCalc2ndOrderMoments(); + bool getCalc3rdOrderMoments(); + bool getCalcHighOrderMoments(); + bool getConcFile(); + bool isStreetVelocityFile(); + bool getUseMeasurePoints(); + bool getUseWale(); + bool getUseInitNeq(); + bool getSimulatePorousMedia(); + bool getIsF3(); bool getIsBodyForce(); - double getMemsizeGPU(); - //1D domain decomposition - std::vector<std::string> getPossNeighborFiles(std::string sor); - unsigned int getNumberOfProcessNeighbors(int level, std::string sor); - bool getIsNeighbor(); - //3D domain decomposition - std::vector<std::string> getPossNeighborFilesX(std::string sor); - std::vector<std::string> getPossNeighborFilesY(std::string sor); - std::vector<std::string> getPossNeighborFilesZ(std::string sor); - unsigned int getNumberOfProcessNeighborsX(int level, std::string sor); - unsigned int getNumberOfProcessNeighborsY(int level, std::string sor); - unsigned int getNumberOfProcessNeighborsZ(int level, std::string sor); - bool getIsNeighborX(); - bool getIsNeighborY(); - bool getIsNeighborZ(); - //Normals - std::string getgeomBoundaryNormalX(); - std::string getgeomBoundaryNormalY(); - std::string getgeomBoundaryNormalZ(); - std::string getInflowBoundaryNormalX(); - std::string getInflowBoundaryNormalY(); - std::string getInflowBoundaryNormalZ(); - std::string getOutflowBoundaryNormalX(); - std::string getOutflowBoundaryNormalY(); - std::string getOutflowBoundaryNormalZ(); - //CUDA random number - curandState* getRandomState(); - //Kernel + double getMemsizeGPU(); + // 1D domain decomposition + std::vector<std::string> getPossNeighborFiles(std::string sor); + unsigned int getNumberOfProcessNeighbors(int level, std::string sor); + bool getIsNeighbor(); + // 3D domain decomposition + std::vector<std::string> getPossNeighborFilesX(std::string sor); + std::vector<std::string> getPossNeighborFilesY(std::string sor); + std::vector<std::string> getPossNeighborFilesZ(std::string sor); + unsigned int getNumberOfProcessNeighborsX(int level, std::string sor); + unsigned int getNumberOfProcessNeighborsY(int level, std::string sor); + unsigned int getNumberOfProcessNeighborsZ(int level, std::string sor); + bool getIsNeighborX(); + bool getIsNeighborY(); + bool getIsNeighborZ(); + // Normals + std::string getgeomBoundaryNormalX(); + std::string getgeomBoundaryNormalY(); + std::string getgeomBoundaryNormalZ(); + std::string getInflowBoundaryNormalX(); + std::string getInflowBoundaryNormalY(); + std::string getInflowBoundaryNormalZ(); + std::string getOutflowBoundaryNormalX(); + std::string getOutflowBoundaryNormalY(); + std::string getOutflowBoundaryNormalZ(); + // CUDA random number + curandState *getRandomState(); + // Kernel std::string getMainKernel(); - bool getMultiKernelOn(); - std::vector<int> getMultiKernelLevel(); + bool getMultiKernelOn(); + std::vector<int> getMultiKernelLevel(); std::vector<std::string> getMultiKernel(); - std::string getADKernel(); - - ~Parameter(); + std::string getADKernel(); - public: - //Forcing/////////////// - real *forcingH, *forcingD; - double hostForcing[3]; + // Forcing/////////////// + real *forcingH, *forcingD; + double hostForcing[3]; ////////////////////////////////////////////////////////////////////////// // limiters real *quadricLimitersH, *quadricLimitersD; double hostQuadricLimiters[3]; - //////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////// // initial condition - void setInitialCondition(std::function<void(real,real,real,real&,real&,real&,real&)> initialCondition); - std::function<void(real,real,real,real&,real&,real&,real&)>& getInitialCondition(); + void setInitialCondition(std::function<void(real, real, real, real &, real &, real &, real &)> initialCondition); + std::function<void(real, real, real, real &, real &, real &, real &)> &getInitialCondition(); -protected: + std::vector<std::shared_ptr<LBMSimulationParameter>> parH = std::vector<std::shared_ptr<LBMSimulationParameter>>(1); + std::vector<std::shared_ptr<LBMSimulationParameter>> parD = std::vector<std::shared_ptr<LBMSimulationParameter>>(1); private: - static Parameter* instanz; - bool compOn; - bool diffOn; - bool isF3; - bool calcDragLift, calcCp; - bool writeVeloASCII; - bool calcPlaneConc; - bool isBodyForce; - int diffMod; - int coarse, fine, maxlevel; - int factor_gridNZ; - int D3Qxx; - InitCondition ic; - double memsizeGPU; - unsigned int limitOfNodesForVTK; - unsigned int outputCount; - unsigned int timestep; - - - //Kernel - std::string mainKernel; - bool multiKernelOn; - std::vector<int> multiKernelLevel; + void readConfigData(const vf::basics::ConfigurationFile &configData); + + bool compOn { false }; + bool diffOn { false }; + bool isF3 { false }; + bool calcDragLift { false }; + bool calcCp { false }; + bool writeVeloASCII { false }; + bool calcPlaneConc { false }; + bool isBodyForce { false }; + int diffMod {27}; + int maxlevel {0}; + int coarse {0}; + int fine {0}; + int factor_gridNZ {2}; + int D3Qxx {27}; + InitCondition ic; + double memsizeGPU; + unsigned int limitOfNodesForVTK; + unsigned int outputCount; + unsigned int timestep; + + // Kernel + std::string mainKernel { "CumulantK17Comp" }; + bool multiKernelOn { false }; + std::vector<int> multiKernelLevel; std::vector<std::string> multiKernel; - std::string adKernel; - - ////////////////////////////////////////////////////////////////////////// - //particles - int particleBasicLevel, particleInitLevel; - int numberOfParticles; - bool calcParticles; - real stickToSolid; - real startXHotWall, endXHotWall; - ////////////////////////////////////////////////////////////////////////// - //CUDA random number generation - curandState* devState; - ////////////////////////////////////////////////////////////////////////// - - //Temperature - TempforBoundaryConditions *TempH, *TempD; - //Temperature Velocity - TempVelforBoundaryConditions *TempVelH, *TempVelD; - //Temperature Pressure - TempPressforBoundaryConditions *TempPressH, *TempPressD; - - //Drehung/////////////// - real Phi, angularVelocity; - unsigned int startTurn; - - //Step of Ensight writing// - unsigned int stepEnsight; - - std::vector<ParameterStruct*> parH; - std::vector<ParameterStruct*> parD; - //LogWriter output; - - Parameter(); - Parameter(SPtr<ConfigData> configData, Communicator* comm); - Parameter(const Parameter&); - void initInterfaceParameter(int level); - real TrafoXtoWorld(int CoordX, int level); - real TrafoYtoWorld(int CoordY, int level); - real TrafoZtoWorld(int CoordZ, int level); + std::string adKernel; + + ////////////////////////////////////////////////////////////////////////// + // particles + int particleBasicLevel {0}; + int particleInitLevel {0}; + int numberOfParticles {0}; + bool calcParticles {false}; + real startXHotWall {(real)0.0}; + real endXHotWall {(real)0.0}; + ////////////////////////////////////////////////////////////////////////// + // CUDA random number generation + curandState *devState; + ////////////////////////////////////////////////////////////////////////// + + // Temperature + TempforBoundaryConditions *TempH, *TempD; + // Temperature Velocity + TempVelforBoundaryConditions *TempVelH, *TempVelD; + // Temperature Pressure + TempPressforBoundaryConditions *TempPressH, *TempPressD; + + // Drehung/////////////// + real Phi {0.0}; + real angularVelocity; + unsigned int startTurn; + + // PreCollisionInteractors ////////////// + std::vector<SPtr<PreCollisionInteractor>> actuators; + std::vector<SPtr<PreCollisionInteractor>> probes; + + // Step of Ensight writing// + unsigned int stepEnsight; + + real TrafoXtoWorld(int CoordX, int level); + real TrafoYtoWorld(int CoordY, int level); + real TrafoZtoWorld(int CoordZ, int level); + public: - real TrafoXtoMGsWorld(int CoordX, int level); - real TrafoYtoMGsWorld(int CoordY, int level); - real TrafoZtoMGsWorld(int CoordZ, int level); + real TrafoXtoMGsWorld(int CoordX, int level); + real TrafoYtoMGsWorld(int CoordY, int level); + real TrafoZtoMGsWorld(int CoordZ, int level); + private: - //Multi GPGPU/////////////// - //1D domain decomposition - std::vector<std::string> possNeighborFilesSend; - std::vector<std::string> possNeighborFilesRecv; - bool isNeigbor; - //3D domain decomposition - std::vector<std::string> possNeighborFilesSendX, possNeighborFilesSendY, possNeighborFilesSendZ; - std::vector<std::string> possNeighborFilesRecvX, possNeighborFilesRecvY, possNeighborFilesRecvZ; - bool isNeigborX, isNeigborY, isNeigborZ; - - //////////////////////////////////////////////////////////////////////////// + // Multi GPGPU/////////////// + // 1D domain decomposition + std::vector<std::string> possNeighborFilesSend; + std::vector<std::string> possNeighborFilesRecv; + bool isNeigbor; + // 3D domain decomposition + std::vector<std::string> possNeighborFilesSendX, possNeighborFilesSendY, possNeighborFilesSendZ; + std::vector<std::string> possNeighborFilesRecvX, possNeighborFilesRecvY, possNeighborFilesRecvZ; + bool isNeigborX, isNeigborY, isNeigborZ; + + //////////////////////////////////////////////////////////////////////////// // initial condition - std::function<void(real,real,real,real&,real&,real&,real&)> initialCondition; + std::function<void(real, real, real, real &, real &, real &, real &)> initialCondition; }; #endif - diff --git a/src/gpu/VirtualFluids_GPU/Parameter/ParameterTest.cpp b/src/gpu/VirtualFluids_GPU/Parameter/ParameterTest.cpp new file mode 100644 index 0000000000000000000000000000000000000000..aa0551632e566768aaa9b087c072f665d6f7bc3d --- /dev/null +++ b/src/gpu/VirtualFluids_GPU/Parameter/ParameterTest.cpp @@ -0,0 +1,158 @@ +#include <gmock/gmock.h> + +#include <iostream> +#include <string> +#include <filesystem> + +#include "Parameter.h" +#include <basics/config/ConfigurationFile.h> + + +auto RealEq = [](auto value) { +#ifdef VF_DOUBLE_ACCURACY + return testing::DoubleEq(value); +#else + return testing::FloatEq(value); +#endif +}; + + +TEST(ParameterTest, passingEmptyFileWithoutPath_ShouldThrow) +{ + // assuming that the config files is stored parallel to this file. + std::filesystem::path filePath = __FILE__; + filePath.replace_filename("parameterTest_emptyfile.cfg"); + + vf::basics::ConfigurationFile config; + config.load(filePath.string()); + + EXPECT_THROW(Parameter para(config, 1, 0), std::runtime_error); +} + +// TODO: test setPossNeighborFilesX +// TODO: test default values + +TEST(ParameterTest, check_all_Parameter_CanBePassedToConstructor) +{ + // assuming that the config files is stored parallel to this file. + std::filesystem::path filePath = __FILE__; + filePath.replace_filename("parameterTest.cfg"); + + vf::basics::ConfigurationFile config; + config.load(filePath.string()); + + Parameter para(config, 1, 0); + + // this two parameters need to be defined in each config file + EXPECT_THAT(para.getOutputPath(), testing::Eq("/output/path")); + EXPECT_THAT(para.getgeoVec(), testing::Eq("/path/to/grid/geoVec.dat")); + // ... all grid files could be tested as well + + // test optional parameter + EXPECT_THAT(para.getMaxDev(), testing::Eq(2)); + EXPECT_THAT(para.getDevices(), testing::ElementsAreArray({2,3})); + EXPECT_THAT(para.getOutputPrefix(), testing::Eq("MyPrefix")); + EXPECT_THAT(para.getPrintFiles(), testing::Eq(true)); + EXPECT_THAT(para.getIsGeometryValues(), testing::Eq(true)); + EXPECT_THAT(para.getCalc2ndOrderMoments(), testing::Eq(true)); + EXPECT_THAT(para.getCalc3rdOrderMoments(), testing::Eq(true)); + EXPECT_THAT(para.getCalcHighOrderMoments(), testing::Eq(true)); + EXPECT_THAT(para.getCalcMedian(), testing::Eq(true)); + EXPECT_THAT(para.getCalcCp(), testing::Eq(true)); + EXPECT_THAT(para.getCalcDragLift(), testing::Eq(true)); + EXPECT_THAT(para.getWriteVeloASCIIfiles(), testing::Eq(true)); + EXPECT_THAT(para.getCalcPlaneConc(), testing::Eq(true)); + EXPECT_THAT(para.getConcFile(), testing::Eq(true)); + EXPECT_THAT(para.isStreetVelocityFile(), testing::Eq(true)); + EXPECT_THAT(para.getUseMeasurePoints(), testing::Eq(true)); + EXPECT_THAT(para.getUseWale(), testing::Eq(true)); + EXPECT_THAT(para.getUseInitNeq(), testing::Eq(true)); + EXPECT_THAT(para.getSimulatePorousMedia(), testing::Eq(true)); + + EXPECT_THAT(para.getD3Qxx(), testing::Eq(99)); + EXPECT_THAT(para.getTEnd(), testing::Eq(33)); + EXPECT_THAT(para.getTOut(), testing::Eq(22)); + EXPECT_THAT(para.getTStartOut(), testing::Eq(11)); + EXPECT_THAT(para.getTimeCalcMedStart(), testing::Eq(22)); + EXPECT_THAT(para.getTimeCalcMedEnd(), testing::Eq(44)); + EXPECT_THAT(para.getPressInID(), testing::Eq(25)); + EXPECT_THAT(para.getPressOutID(), testing::Eq(26)); + EXPECT_THAT(para.getPressInZ(), testing::Eq(27)); + EXPECT_THAT(para.getPressOutZ(), testing::Eq(28)); + + EXPECT_THAT(para.getDiffOn(), testing::Eq(true)); + EXPECT_THAT(para.getDiffMod(), testing::Eq(99)); + EXPECT_THAT(para.getDiffusivity(), RealEq(1.11)); + EXPECT_THAT(para.getTemperatureInit(), RealEq(2.22)); + EXPECT_THAT(para.getTemperatureBC(), RealEq(3.33)); + + EXPECT_THAT(para.getViscosity(), RealEq(4.44)); + EXPECT_THAT(para.getVelocity(), RealEq(5.55)); + EXPECT_THAT(para.getViscosityRatio(), RealEq(6.66)); + EXPECT_THAT(para.getVelocityRatio(), RealEq(7.77)); + EXPECT_THAT(para.getDensityRatio(), RealEq(8.88)); + EXPECT_THAT(para.getPressRatio(), RealEq(9.99)); + + EXPECT_THAT(para.getRealX(), RealEq(0.1)); + EXPECT_THAT(para.getRealY(), RealEq(0.2)); + EXPECT_THAT(para.getFactorPressBC(), RealEq(0.3)); + + EXPECT_THAT(para.getReadGeo(), testing::Eq(true)); + EXPECT_THAT(para.getGeometryFileC(), testing::Eq("/pass/to/c")); + EXPECT_THAT(para.getGeometryFileM(), testing::Eq("/pass/to/m")); + EXPECT_THAT(para.getGeometryFileF(), testing::Eq("/pass/to/f")); + + EXPECT_THAT(para.getclockCycleForMP(), RealEq(0.4)); + EXPECT_THAT(para.getTimestepForMP(), testing::Eq(4)); + + std::vector<real> forces {2.0,2.1,2.2}; + double* forces_actual = para.getForcesDouble(); + for (size_t i = 0; i < forces.size(); ++i) { + EXPECT_THAT((real)forces_actual[i], RealEq(forces[i])); + } + + std::vector<real> limiters {3.0,3.1,3.2}; + double* limiters_actual = para.getQuadricLimitersDouble(); + for (size_t i = 0; i < limiters.size(); ++i) { + EXPECT_THAT((real)limiters_actual[i], RealEq(limiters[i])); + } + + EXPECT_THAT(para.getCalcParticle(), testing::Eq(true)); + EXPECT_THAT(para.getParticleBasicLevel(), testing::Eq(1)); + EXPECT_THAT(para.getParticleInitLevel(), testing::Eq(2)); + EXPECT_THAT(para.getNumberOfParticles(), testing::Eq(1111)); + EXPECT_THAT(para.getStartXHotWall(), RealEq(4.1)); + EXPECT_THAT(para.getEndXHotWall(), RealEq(4.2)); + + EXPECT_THAT(para.getTimeDoCheckPoint(), testing::Eq(33)); + EXPECT_THAT(para.getTimeDoRestart(), testing::Eq(44)); + EXPECT_THAT(para.getDoCheckPoint(), testing::Eq(true)); + EXPECT_THAT(para.getDoRestart(), testing::Eq(true)); + EXPECT_THAT(para.getMaxLevel(), testing::Eq(1)); // NOGL - 1 + + EXPECT_THAT(para.getGridX(), testing::ElementsAreArray({100, 101})); + EXPECT_THAT(para.getGridY(), testing::ElementsAreArray({200, 201})); + EXPECT_THAT(para.getGridZ(), testing::ElementsAreArray({300, 301})); + EXPECT_THAT(para.getDistX(), testing::ElementsAreArray({400, 401})); + EXPECT_THAT(para.getDistY(), testing::ElementsAreArray({500, 501})); + EXPECT_THAT(para.getDistZ(), testing::ElementsAreArray({600, 601})); + + EXPECT_THAT(para.getMainKernel(), testing::Eq("KernelName")); + EXPECT_THAT(para.getMultiKernelOn(), testing::Eq(true)); + EXPECT_THAT(para.getMultiKernelLevel(), testing::ElementsAreArray({3, 2, 1})); + + std::vector<std::string> kernel {"Kernel1", "Kernel2", "Kernel3"}; + auto kernel_actual = para.getMultiKernel(); + for (size_t i = 0; i < kernel.size(); ++i) { + EXPECT_THAT(kernel_actual[i], testing::Eq(kernel[i])); + } + + + EXPECT_THAT(para.getCoarse(), testing::Eq(0)); + EXPECT_THAT(para.getFine(), testing::Eq(1)); // NOGL - 1 + EXPECT_THAT(para.parH.size(), testing::Eq(2)); + EXPECT_THAT(para.parD.size(), testing::Eq(2)); +} + + + diff --git a/src/gpu/VirtualFluids_GPU/Parameter/parameterTest.cfg b/src/gpu/VirtualFluids_GPU/Parameter/parameterTest.cfg new file mode 100644 index 0000000000000000000000000000000000000000..8b6a75ddabaf3a9a570d08982ddad6a00e7b41c5 --- /dev/null +++ b/src/gpu/VirtualFluids_GPU/Parameter/parameterTest.cfg @@ -0,0 +1,93 @@ +# this two parameters need to be defined in each config file +Path = /output/path +GridPath = /path/to/grid + +# optional parameter +NumberOfDevices = 2 +Devices = 2 3 +Prefix = MyPrefix +WriteGrid = true +GeometryValues = true +calc2ndOrderMoments = true +calc3rdOrderMoments = true +calcHigherOrderMoments = true +calcMedian = true +calcCp = true +calcDrafLift = true +writeVeloASCIIfiles = true +calcPlaneConc = true +UseConcFile = true +UseStreetVelocityFile = true +UseMeasurePoints = true +UseWale = true +UseInitNeq = true +SimulatePorousMedia = true + +D3Qxx = 99 +TimeEnd = 33 +TimeOut = 22 +TimeStartOut = 11 +TimeStartCalcMedian = 22 +TimeEndCalcMedian = 44 +PressInID = 25 +PressOutID = 26 +PressInZ = 27 +PressOutZ = 28 + +DiffOn = true +DiffMod = 99 +Diffusivity = 1.11 +Temp = 2.22 +TempBC = 3.33 + +Viscosity_LB = 4.44 +Velocity_LB = 5.55 +Viscosity_Ratio_World_to_LB = 6.66 +Velocity_Ratio_World_to_LB = 7.77 +Density_Ratio_World_to_LB = 8.88 +Delta_Press = 9.99 + +SliceRealX = 0.1 +SliceRealY = 0.2 +FactorPressBC = 0.3 + +ReadGeometry = true +GeometryC = /pass/to/c +GeometryM = /pass/to/m +GeometryF = /pass/to/f + +measureClockCycle = 0.4 +measureTimestep = 4 + +ForcingX = 2.0 +ForcingY = 2.1 +ForcingZ = 2.2 + +QuadricLimiterP = 3.0 +QuadricLimiterM = 3.1 +QuadricLimiterD = 3.2 + +calcParticles = true +baseLevel = 1 +initLevel = 2 +numberOfParticles = 1111 +startXHotWall = 4.1 +endXHotWall = 4.2 + +TimeDoCheckPoint = 33 +TimeDoRestart = 44 +DoCheckPoint = true +DoRestart = true +NOGL = 2 + +GridX = 100 101 +GridY = 200 201 +GridZ = 300 301 +DistX = 400 401 +DistY = 500 501 +DistZ = 600 601 + +MainKernelName = KernelName +MultiKernelOn = true +MultiKernelLevel = 3 2 1 +MultiKernelName = Kernel1 Kernel2 Kernel3 \ No newline at end of file diff --git a/src/gpu/GridGenerator/geometries/Point/Point.cpp b/src/gpu/VirtualFluids_GPU/Parameter/parameterTest_emptyfile.cfg similarity index 100% rename from src/gpu/GridGenerator/geometries/Point/Point.cpp rename to src/gpu/VirtualFluids_GPU/Parameter/parameterTest_emptyfile.cfg diff --git a/src/gpu/VirtualFluids_GPU/PreCollisionInteractor/ActuatorLine.cu b/src/gpu/VirtualFluids_GPU/PreCollisionInteractor/ActuatorLine.cu new file mode 100644 index 0000000000000000000000000000000000000000..a66474d4fdc13617fde27bef04a2ca30cf005281 --- /dev/null +++ b/src/gpu/VirtualFluids_GPU/PreCollisionInteractor/ActuatorLine.cu @@ -0,0 +1,383 @@ +#include "ActuatorLine.h" + +#include <cuda.h> +#include <cuda_runtime.h> +#include <helper_cuda.h> + +#include <cuda/CudaGrid.h> +#include "lbm/constants/NumericConstants.h" +#include "VirtualFluids_GPU/GPU/GeometryUtils.h" + +#include "Parameter/Parameter.h" +#include "DataStructureInitializer/GridProvider.h" +#include "GPU/CudaMemoryManager.h" + +__host__ __device__ __inline__ real calcGaussian3D(real posX, real posY, real posZ, real destX, real destY, real destZ, real epsilon) +{ + real distX = destX-posX; + real distY = destY-posY; + real distZ = destZ-posZ; + real dist = sqrt(distX*distX+distY*distY+distZ*distZ); + return pow(epsilon,-3)*pow(vf::lbm::constant::cPi,-1.5f)*exp(-pow(dist/epsilon,2)); +} + + +__global__ void interpolateVelocities(real* gridCoordsX, real* gridCoordsY, real* gridCoordsZ, + uint* neighborsX, uint* neighborsY, uint* neighborsZ, + uint* neighborsWSB, + real* vx, real* vy, real* vz, + uint numberOfIndices, + real* bladeCoordsX, real* bladeCoordsY, real* bladeCoordsZ, + real* bladeVelocitiesX, real* bladeVelocitiesY, real* bladeVelocitiesZ, + uint* bladeIndices, uint numberOfNodes) +{ + 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>=numberOfNodes) return; + + real bladePosX = bladeCoordsX[node]; + real bladePosY = bladeCoordsY[node]; + real bladePosZ = bladeCoordsZ[node]; + + uint old_index = bladeIndices[node]; + + uint k, ke, kn, kt; + uint kne, kte, ktn, ktne; + + k = findNearestCellBSW(old_index, + gridCoordsX, gridCoordsY, gridCoordsZ, + bladePosX, bladePosY, bladePosZ, + 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 invDeltaX = 1.f/(gridCoordsX[ktne]-gridCoordsX[k]); + real distX = invDeltaX*(gridCoordsX[ktne]-bladePosX); + real distY = invDeltaX*(gridCoordsY[ktne]-bladePosY); + real distZ = invDeltaX*(gridCoordsZ[ktne]-bladePosZ); + + getInterpolationWeights(dW, dE, dN, dS, dT, dB, + distX, distY, distZ); + + bladeVelocitiesX[node] = trilinearInterpolation(dW, dE, dN, dS, dT, dB, k, ke, kn, kt, kne, kte, ktn, ktne, vx); + bladeVelocitiesY[node] = trilinearInterpolation(dW, dE, dN, dS, dT, dB, k, ke, kn, kt, kne, kte, ktn, ktne, vy); + bladeVelocitiesZ[node] = trilinearInterpolation(dW, dE, dN, dS, dT, dB, k, ke, kn, kt, kne, kte, ktn, ktne, vz); + +} + + +__global__ void applyBodyForces(real* gridCoordsX, real* gridCoordsY, real* gridCoordsZ, + real* gridForcesX, real* gridForcesY, real* gridForcesZ, + uint* gridIndices, uint numberOfIndices, + real* bladeCoordsX, real* bladeCoordsY, real* bladeCoordsZ, + real* bladeForcesX, real* bladeForcesY,real* bladeForcesZ, + real* bladeRadii, + real radius, + uint nBlades, uint nBladeNodes, + real epsilon, real delta_x) +{ + 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>=numberOfIndices) return; + + int gridIndex = gridIndices[index]; + + real posX = gridCoordsX[gridIndex]; + real posY = gridCoordsY[gridIndex]; + real posZ = gridCoordsZ[gridIndex]; + + real fXYZ_X = 0.0f; + real fXYZ_Y = 0.0f; + real fXYZ_Z = 0.0f; + + real eta = 0.0f; + + real delta_x_cubed = pow(delta_x,3); + + for( uint blade=0; blade<nBlades; blade++) + { + real last_r = 0.0f; + real r = 0.0f; + + for( uint bladeNode=0; bladeNode<nBladeNodes; bladeNode++) + { + int node = bladeNode+blade*nBladeNodes; + eta = calcGaussian3D(posX, posY, posZ, bladeCoordsX[node], bladeCoordsY[node], bladeCoordsZ[node], epsilon)*delta_x_cubed; + r = bladeRadii[bladeNode]; + + fXYZ_X += bladeForcesX[node]*(r-last_r)*eta; + fXYZ_Y += bladeForcesY[node]*(r-last_r)*eta; + fXYZ_Z += bladeForcesZ[node]*(r-last_r)*eta; + + last_r = r; + } + + fXYZ_X += bladeForcesX[nBladeNodes-1]*(radius-last_r)*eta; + fXYZ_Y += bladeForcesY[nBladeNodes-1]*(radius-last_r)*eta; + fXYZ_Z += bladeForcesZ[nBladeNodes-1]*(radius-last_r)*eta; + } + + gridForcesX[gridIndex] = fXYZ_X; + gridForcesY[gridIndex] = fXYZ_Y; + gridForcesZ[gridIndex] = fXYZ_Z; +} + + +void ActuatorLine::init(Parameter* para, GridProvider* gridProvider, CudaMemoryManager* cudaManager) +{ + 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); + + uint numberOfThreads = para->getParH(level)->numberofthreads; + vf::cuda::CudaGrid bladeGrid = vf::cuda::CudaGrid(numberOfThreads, this->numberOfNodes); + + 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->numberOfIndices, + this->bladeCoordsXD, this->bladeCoordsYD, this->bladeCoordsZD, + this->bladeVelocitiesXD, this->bladeVelocitiesYD, this->bladeVelocitiesZD, + this->bladeIndicesD, this->numberOfNodes); + + cudaManager->cudaCopyBladeVelocitiesDtoH(this); + + if(true) + { + this->calcForcesEllipticWing(para); + } + + cudaManager->cudaCopyBladeForcesHtoD(this); + + vf::cuda::CudaGrid sphereGrid = vf::cuda::CudaGrid(numberOfThreads, this->numberOfIndices); + + 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->boundingSphereIndicesD, this->numberOfIndices, + this->bladeCoordsXD, this->bladeCoordsYD, this->bladeCoordsZD, + this->bladeForcesXD, this->bladeForcesYD, this->bladeForcesZD, + this->bladeRadiiD, + this->diameter*0.5f, + this->nBlades, this->nBladeNodes, + this->epsilon, this->delta_x); + + real dazimuth = this->omega*this->delta_t; + + this->azimuth += dazimuth; + this->rotateBlades(dazimuth); +} + + +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(Parameter* para) +{ + real localAzimuth; + uint node; + real uXYZ_X, uXYZ_Y, uXYZ_Z; + real uRTZ_X, uRTZ_Y, uRTZ_Z; + real fXYZ_X, fXYZ_Y, fXYZ_Z; + real fRTZ_X, fRTZ_Y, fRTZ_Z; + real r; + real u_rel, v_rel, u_rel_sq; + real phi; + real Cl = 1.f; + real Cd = 0.f; + real c0 = 1.f; + + real c, Cn, Ct; + + real forceRatio = this->density*pow(this->delta_x,4)*pow(this->delta_t,-2); + + for( uint blade=0; blade<this->nBlades; blade++) + { + localAzimuth = this->azimuth+2*blade*vf::lbm::constant::cPi/this->nBlades; + for( uint bladeNode=0; bladeNode<this->nBladeNodes; bladeNode++) + { + node = bladeNode+blade*this->nBladeNodes; + uXYZ_X = this->bladeVelocitiesXH[node]*para->getVelocityRatio(); + uXYZ_Y = this->bladeVelocitiesYH[node]*para->getVelocityRatio(); + uXYZ_Z = this->bladeVelocitiesZH[node]*para->getVelocityRatio(); + + invRotateAboutX3D(localAzimuth, uXYZ_X, uXYZ_Y, uXYZ_Z, uRTZ_X, uRTZ_Y, uRTZ_Z); + r = this->bladeRadiiH[bladeNode]; + + u_rel = uRTZ_X; + v_rel = uRTZ_Y+this->omega*r; + u_rel_sq = u_rel*u_rel+v_rel*v_rel; + phi = atan2(u_rel, v_rel); + + c = c0 * sqrt( 1.f- pow(4.f*r/this->diameter-1.f, 2.f) ); + Cn = Cl*cos(phi)+Cd*sin(phi); + Ct = -Cl*sin(phi)+Cd*cos(phi); + + fRTZ_X = 0.5f*u_rel_sq*c*this->density*Cn; + fRTZ_Y = 0.5f*u_rel_sq*c*this->density*Ct; + fRTZ_Z = 0.0; + + rotateAboutX3D(localAzimuth, fRTZ_X, fRTZ_Y, fRTZ_Z, fXYZ_X, fXYZ_Y, fXYZ_Z); + + this->bladeForcesXH[node] = fXYZ_X/forceRatio; + this->bladeForcesYH[node] = fXYZ_Y/forceRatio; + this->bladeForcesZH[node] = fXYZ_Z/forceRatio; + } + } +} + +void ActuatorLine::rotateBlades(real angle) +{ + for(uint node=0; node<this->nBladeNodes*this->nBlades; node++) + { + real oldCoordX = this->bladeCoordsXH[node]; + real oldCoordY = this->bladeCoordsYH[node]; + real oldCoordZ = this->bladeCoordsZH[node]; + + real newCoordX, newCoordY, newCoordZ; + rotateAboutX3D(angle, oldCoordX, oldCoordY, oldCoordZ, newCoordX, newCoordY, newCoordZ, this->turbinePosX, this->turbinePosY, this->turbinePosZ); + + this->bladeCoordsYH[node] = newCoordX; + this->bladeCoordsYH[node] = newCoordY; + this->bladeCoordsZH[node] = newCoordZ; + } +} + +void ActuatorLine::initBladeRadii(CudaMemoryManager* cudaManager) +{ + cudaManager->cudaAllocBladeRadii(this); + + real dx = 0.5f*this->diameter/this->nBladeNodes; + for(uint node=0; node<this->nBladeNodes; node++) + { + this->bladeRadiiH[node] = dx*(node+1); + } + cudaManager->cudaCopyBladeRadiiHtoD(this); +} + +void ActuatorLine::initBladeCoords(CudaMemoryManager* cudaManager) +{ + cudaManager->cudaAllocBladeCoords(this); + + for( uint blade=0; blade<this->nBlades; blade++) + { + real localAzimuth = this->azimuth+(2*vf::lbm::constant::cPi/this->nBlades)*blade; + for(uint node=0; node<this->nBladeNodes; node++) + { + real coordX, coordY, coordZ; + real x,y,z; + x = 0.f; + y = 0.f; + z = this->bladeRadiiH[node]; + rotateAboutX3D(localAzimuth, x, y, z, coordX, coordY, coordZ); + this->bladeCoordsXH[node+this->nBladeNodes*blade] = coordX+this->turbinePosX; + this->bladeCoordsYH[node+this->nBladeNodes*blade] = coordY+this->turbinePosY; + this->bladeCoordsZH[node+this->nBladeNodes*blade] = coordZ+this->turbinePosZ; + } + } + cudaManager->cudaCopyBladeCoordsHtoD(this); +} + +void ActuatorLine::initBladeVelocities(CudaMemoryManager* cudaManager) +{ + cudaManager->cudaAllocBladeVelocities(this); + + for(uint node=0; node<this->numberOfNodes; node++) + { + this->bladeVelocitiesXH[node] = 0.f; + this->bladeVelocitiesYH[node] = 0.f; + this->bladeVelocitiesZH[node] = 0.f; + } + cudaManager->cudaCopyBladeVelocitiesHtoD(this); +} + +void ActuatorLine::initBladeForces(CudaMemoryManager* cudaManager) +{ + cudaManager->cudaAllocBladeForces(this); + + for(uint node=0; node<this->numberOfNodes; node++) + { + this->bladeForcesXH[node] = 0.f; + this->bladeForcesYH[node] = 0.f; + this->bladeForcesZH[node] = 0.f; + } + cudaManager->cudaCopyBladeForcesHtoD(this); +} + +void ActuatorLine::initBladeIndices(Parameter* para, CudaMemoryManager* cudaManager) +{ + cudaManager->cudaAllocBladeIndices(this); + + real* coordsX = para->getParH(this->level)->coordX_SP; + real* coordsY = para->getParH(this->level)->coordY_SP; + real* coordsZ = para->getParH(this->level)->coordZ_SP; + + for(uint node=0; node<this->numberOfNodes; node++) + { + this->bladeIndicesH[node] = findNearestCellBSW(1, coordsX, coordsY, coordsZ, + this->bladeCoordsXH[node], this->bladeCoordsYH[node], this->bladeCoordsZH[node], + para->getParH(this->level)->neighborX_SP, para->getParH(this->level)->neighborY_SP, para->getParH(this->level)->neighborZ_SP, + para->getParH(this->level)->neighborWSB_SP); + + } + cudaManager->cudaCopyBladeIndicesHtoD(this); +} + +void ActuatorLine::initBoundingSphere(Parameter* para, CudaMemoryManager* cudaManager) +{ + // Actuator line exists only on 1 level + std::vector<int> nodesInSphere; + + for (uint j = 1; j <= para->getParH(this->level)->size_Mat_SP; j++) + { + const real coordX = para->getParH(this->level)->coordX_SP[j]; + const real coordY = para->getParH(this->level)->coordY_SP[j]; + const real coordZ = para->getParH(this->level)->coordZ_SP[j]; + const real dist = sqrt(pow(coordX-this->turbinePosX,2)+pow(coordY-this->turbinePosY,2)+pow(coordZ-this->turbinePosZ,2)); + + if(dist < 0.6*this->diameter) nodesInSphere.push_back(j); + } + + this->numberOfIndices = uint(nodesInSphere.size()); + cudaManager->cudaAllocSphereIndices(this); + std::copy(nodesInSphere.begin(), nodesInSphere.end(), this->boundingSphereIndicesH); + cudaManager->cudaCopySphereIndicesHtoD(this); +} \ 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..f0de6c8e01b2f4cfc0421f02b1a75308512e34e8 --- /dev/null +++ b/src/gpu/VirtualFluids_GPU/PreCollisionInteractor/ActuatorLine.h @@ -0,0 +1,109 @@ +#ifndef ActuatorLine_H +#define ActuatorLine_H + +#include "PreCollisionInteractor.h" +#include "PointerDefinitions.h" + +class Parameter; +class GridProvider; + +class 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 _delta_t, + const real _delta_x + ) : nBlades(_nBlades), + density(_density), + nBladeNodes(_nBladeNodes), + epsilon(_epsilon), + turbinePosX(_turbinePosX), turbinePosY(_turbinePosY), turbinePosZ(_turbinePosZ), + diameter(_diameter), + level(_level), + delta_x(_delta_x), + PreCollisionInteractor() + { + this->delta_t = _delta_t/pow(2,this->level); + this->delta_x = _delta_x/pow(2,this->level); + this->numberOfNodes = this->nBladeNodes*this->nBlades; + this->omega = 1.0f; + this->azimuth = 0.0f; + + } + + virtual ~ActuatorLine() + { + + } + + void init(Parameter* para, GridProvider* gridProvider, CudaMemoryManager* cudaManager); + void interact(Parameter* para, CudaMemoryManager* cudaManager, int level, uint t); + void free(Parameter* para, CudaMemoryManager* cudaManager); + void write(uint t); + + uint getNBladeNodes(){return this->nBladeNodes;}; + uint getNBlades(){return this->nBlades;}; + uint getNumberOfIndices(){return this->numberOfIndices;}; + uint getNumberOfNodes(){return this->numberOfNodes;}; + 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;}; + +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(Parameter* para); + void rotateBlades(real angle); + + void writeBladeCoords(uint t); + void writeBladeForces(uint t); + void writeBladeVelocities(uint t); + + +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, delta_t, delta_x; + const real diameter; + const uint nBladeNodes; + const uint nBlades; + const real epsilon; // in m + const int level; + uint numberOfIndices; + uint numberOfNodes; + }; + +#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/PlaneProbe.cu b/src/gpu/VirtualFluids_GPU/PreCollisionInteractor/Probes/PlaneProbe.cu new file mode 100644 index 0000000000000000000000000000000000000000..cf03d639add0c883793c6ffad041e7b6da6d98d3 --- /dev/null +++ b/src/gpu/VirtualFluids_GPU/PreCollisionInteractor/Probes/PlaneProbe.cu @@ -0,0 +1,51 @@ +#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" + +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, int level) +{ + vf::cuda::CudaGrid grid = vf::cuda::CudaGrid(para->getParH(level)->numberofthreads, probeStruct->nPoints); + interpQuantities<<<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, false); + +} \ 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..6f6af68fc2e4b5d93502d9890a29cc4838ac6042 --- /dev/null +++ b/src/gpu/VirtualFluids_GPU/PreCollisionInteractor/Probes/PlaneProbe.h @@ -0,0 +1,42 @@ +#ifndef PlaneProbe_H +#define PlaneProbe_H + +#include "Probe.h" + +class PlaneProbe : public Probe +{ +public: + PlaneProbe( + const std::string _probeName, + uint _tStartAvg, + uint _tStartOut, + uint _tOut + ): Probe(_probeName, + _tStartAvg, + _tStartOut, + _tOut) + {} + + 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: + 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, 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..76467d8da942cb189516571db66a473e5c4c32d5 --- /dev/null +++ b/src/gpu/VirtualFluids_GPU/PreCollisionInteractor/Probes/PointProbe.cu @@ -0,0 +1,86 @@ +#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" + +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, int level) +{ + vf::cuda::CudaGrid grid = vf::cuda::CudaGrid(para->getParH(level)->numberofthreads, probeStruct->nPoints); + + interpQuantities<<<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, true); +} + +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..917d2cf8c4f4606fc297491782bbc92dc621cf0e --- /dev/null +++ b/src/gpu/VirtualFluids_GPU/PreCollisionInteractor/Probes/PointProbe.h @@ -0,0 +1,36 @@ +#ifndef PointProbe_H +#define PointProbe_H + +#include "Probe.h" + +class PointProbe: public Probe +{ +public: + PointProbe( + const std::string _probeName, + uint _tStartAvg, + uint _tStartOut, + uint _tOut + ): Probe(_probeName, + _tStartAvg, + _tStartOut, + _tOut) + {} + + 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: + 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, 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..e798f433270777f8d718218e91306f980b20e9ca --- /dev/null +++ b/src/gpu/VirtualFluids_GPU/PreCollisionInteractor/Probes/Probe.cu @@ -0,0 +1,408 @@ +#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" + + +std::vector<std::string> getPostProcessingVariableNames(PostProcessingVariable variable) +{ + std::vector<std::string> varNames; + switch (variable) + { + case PostProcessingVariable::Means: + varNames.push_back("vx_mean"); + varNames.push_back("vy_mean"); + varNames.push_back("vz_mean"); + varNames.push_back("rho_mean"); + break; + case PostProcessingVariable::Variances: + varNames.push_back("vx_var"); + varNames.push_back("vy_var"); + varNames.push_back("vz_var"); + varNames.push_back("rho_var"); + break; + default: + break; + } + return varNames; +} + +__device__ void calculateQuantities(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(PostProcessingVariable::Means)]) + { + + uint arrOff = quantityArrayOffsets[int(PostProcessingVariable::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(PostProcessingVariable::Variances)]) + { + arrOff = quantityArrayOffsets[int(PostProcessingVariable::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 interpQuantities( 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, + bool interpolate + ) +{ + 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; + + if(interpolate) + { + 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 ); + } + else + { + u_interpX = vx[k]; + u_interpY = vy[k]; + u_interpZ = vz[k]; + rho_interp = rho[k]; + } + + calculateQuantities(n, quantityArray, quantities, quantityArrayOffsets, nPoints, node, u_interpX, u_interpY, u_interpZ, rho_interp); + +} + + +void Probe::init(Parameter* para, GridProvider* gridProvider, CudaMemoryManager* cudaManager) +{ + + 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, pointCoordsX_level, pointCoordsX_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(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); + + // Might have to catch nPoints=0 ?!?! + cudaManager->cudaAllocProbeDistances(this, level); + cudaManager->cudaAllocProbeIndices(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); + std::copy(probeIndices.begin(), probeIndices.end(), probeParams[level]->pointIndicesH); + + cudaManager->cudaCopyProbeDistancesHtoD(this, level); + cudaManager->cudaCopyProbeIndicesHtoD(this, level); + + uint arrOffset = 0; + + cudaManager->cudaAllocProbeQuantitiesAndOffsets(this, level); + + for( int var=0; var<int(PostProcessingVariable::LAST); var++){ + if(this->quantities[var]) + { + + probeParams[level]->quantitiesH[var] = true; + probeParams[level]->arrayOffsetsH[var] = arrOffset; + arrOffset += uint(getPostProcessingVariableNames(static_cast<PostProcessingVariable>(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; + } + } + cudaManager->cudaCopyProbeQuantityArrayHtoD(this, level); +} + + +void Probe::interact(Parameter* para, CudaMemoryManager* cudaManager, int level, uint t) +{ + + if(t>this->tStartAvg) + { + SPtr<ProbeStruct> probeStruct = this->getProbeStruct(level); + + this->calculateQuantities(probeStruct, para, level); + probeStruct->vals++; + + if(max(int(t) - int(this->tStartOut), -1) % this->tOut == 0) + { + cudaManager->cudaCopyProbeQuantityArrayDtoH(this, level); + + this->write(para, level, t); + } + + } +} + +void Probe::free(Parameter* para, CudaMemoryManager* cudaManager) +{ + for(int level=0; level<=para->getMaxLevel(); level++) + { + cudaManager->cudaFreeProbeDistances(this, level); + cudaManager->cudaFreeProbeIndices(this, level); + cudaManager->cudaFreeProbeQuantityArray(this, level); + cudaManager->cudaFreeProbeQuantitiesAndOffsets(this, level); + } +} + + + +void Probe::addPostProcessingVariable(PostProcessingVariable variable) +{ + this->quantities[int(variable)] = true; + switch(variable) + { + case PostProcessingVariable::Variances: + this->addPostProcessingVariable(PostProcessingVariable::Means); break; + default: break; + } +} + +void Probe::write(Parameter* para, int level, int t) +{ + 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) + + "_t_" + StringUtil::toString<int>(t) + + ".vtk"; + fnames.push_back(fname); + this->fileNamesForCollectionFile.push_back(fname); + } + this->writeGridFiles(para, level, fnames, t); + + if(level == 0) this->writeCollectionFile(para, t); +} + +void Probe::writeCollectionFile(Parameter* para, int t) +{ + std::string filename = this->probeName + "_bin_ID_" + StringUtil::toString<int>(para->getMyID()) + + "_t_" + StringUtil::toString<int>(t) + + ".vtk"; + + std::ofstream file; + + file.open( 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()) + { + 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(); + sizeOfNodes = min(para->getlimitOfNodesForVTK(), probeStruct->nPoints - 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(PostProcessingVariable::LAST); var++){ + if(this->quantities[var]) + { + PostProcessingVariable quantity = static_cast<PostProcessingVariable>(var); + real coeff; + uint n_arrs = uint(getPostProcessingVariableNames(quantity).size()); + + switch(quantity) + { + case PostProcessingVariable::Means: + coeff = para->getVelocityRatio(); + break; + case PostProcessingVariable::Variances: + coeff = pow(para->getVelocityRatio(),2); + break; + default: break; + } + + uint arrOff = probeStruct->arrayOffsetsH[var]; + uint arrLen = probeStruct->nPoints; + + for(uint arr=0; arr<n_arrs; arr++) + { + for (uint pos = startpos; pos < endpos; pos++) + { + nodedata[arrOff+arr][pos-startpos] = double(probeStruct->quantitiesArrayH[(arrOff+arr)*arrLen+pos]*coeff); + } + } + }} + WbWriterVtkXmlBinary::getInstance()->writeNodesWithNodeData(fnames[part], nodes, nodedatanames, nodedata); + } +} + +std::vector<std::string> Probe::getVarNames() +{ + std::vector<std::string> varNames; + for( int var=0; var < int(PostProcessingVariable::LAST); var++){ + if(this->quantities[var]) + { + std::vector<std::string> names = getPostProcessingVariableNames(static_cast<PostProcessingVariable>(var)); + varNames.insert(varNames.end(), names.begin(), names.end()); + }} + return varNames; +} + 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..8223411ffc45fdac8b3ba038f97eeb899dd3d94d --- /dev/null +++ b/src/gpu/VirtualFluids_GPU/PreCollisionInteractor/Probes/Probe.h @@ -0,0 +1,94 @@ +#ifndef Probe_H +#define Probe_H + +#include <cuda.h> + +#include "PreCollisionInteractor/PreCollisionInteractor.h" +#include "PointerDefinitions.h" + +enum class PostProcessingVariable{ + // HowTo add new PostProcessingVariable: Add enum here, LAST has to stay last + // In interpQuantities add computation of quantity in switch statement + // In writeGridFiles add lb->rw conversion factor + // In getPostProcessingVariableNames add names + // If new quantity depends on other quantities i.e. mean, catch in addPostProcessingVariable + Means, + Variances, + LAST, +}; + +struct ProbeStruct{ + uint nPoints, nArrays, vals; + uint *pointIndicesH, *pointIndicesD; + real *pointCoordsX, *pointCoordsY, *pointCoordsZ; + real *distXH, *distYH, *distZH, *distXD, *distYD, *distZD; + real *quantitiesArrayH, *quantitiesArrayD; + bool *quantitiesH, *quantitiesD; + uint *arrayOffsetsH, *arrayOffsetsD; +}; + +__global__ void interpQuantities( 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, + bool interpolate + ); + + +class Probe : public PreCollisionInteractor +{ +public: + Probe( + const std::string _probeName, + uint _tStartAvg, + uint _tStartOut, + uint _tOut + ): probeName(_probeName), + tStartAvg(_tStartAvg), + tStartOut(_tStartOut), + tOut(_tOut), + PreCollisionInteractor() + { + assert("Output starts before averaging!" && tStartOut>=tStartAvg); + } + void init(Parameter* para, GridProvider* gridProvider, CudaMemoryManager* cudaManager); + void interact(Parameter* para, CudaMemoryManager* cudaManager, int level, uint t); + void free(Parameter* para, CudaMemoryManager* cudaManager); + + SPtr<ProbeStruct> getProbeStruct(int level){ return this->probeParams[level]; } + + void addPostProcessingVariable(PostProcessingVariable _variable); + +private: + 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, 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; + + std::vector<SPtr<ProbeStruct>> probeParams; + bool quantities[int(PostProcessingVariable::LAST)]; + std::vector<std::string> fileNamesForCollectionFile; + std::vector<std::string> varNames; + + uint tStartAvg; + uint tStartOut; + uint tOut; +}; + +#endif \ No newline at end of file diff --git a/src/gpu/VirtualFluids_GPU/PreProcessor/PreProcessorStrategy/InitCompAD27/InitCompAD27_Device.cu b/src/gpu/VirtualFluids_GPU/PreProcessor/PreProcessorStrategy/InitCompAD27/InitCompAD27_Device.cu index 95f912c815e5fe561aa0247c44c07ed534920ea5..dfe1ccd23d8da075fa627231f1548ba5370f115b 100644 --- a/src/gpu/VirtualFluids_GPU/PreProcessor/PreProcessorStrategy/InitCompAD27/InitCompAD27_Device.cu +++ b/src/gpu/VirtualFluids_GPU/PreProcessor/PreProcessorStrategy/InitCompAD27/InitCompAD27_Device.cu @@ -1,6 +1,8 @@ #include "LBM/LB.h" #include "LBM/D3Q27.h" -#include "Core/RealConstants.h" +#include <lbm/constants/NumericConstants.h> + +using namespace vf::lbm::constant; #include "math.h" extern "C" __global__ void LB_Init_Comp_AD_27(unsigned int* neighborX, diff --git a/src/gpu/VirtualFluids_GPU/PreProcessor/PreProcessorStrategy/InitCompAD7/InitCompAD7_Device.cu b/src/gpu/VirtualFluids_GPU/PreProcessor/PreProcessorStrategy/InitCompAD7/InitCompAD7_Device.cu index 3d518a361a8dba30ac79325add530f14468602e2..6b4058f4bbbeacabb91f3cd5ba55f616565afb23 100644 --- a/src/gpu/VirtualFluids_GPU/PreProcessor/PreProcessorStrategy/InitCompAD7/InitCompAD7_Device.cu +++ b/src/gpu/VirtualFluids_GPU/PreProcessor/PreProcessorStrategy/InitCompAD7/InitCompAD7_Device.cu @@ -1,6 +1,8 @@ #include "LBM/LB.h" #include "LBM/D3Q27.h" -#include "Core/RealConstants.h" +#include <lbm/constants/NumericConstants.h> + +using namespace vf::lbm::constant; #include "math.h" extern "C" __global__ void LB_Init_Comp_AD_7(unsigned int* neighborX, diff --git a/src/gpu/VirtualFluids_GPU/PreProcessor/PreProcessorStrategy/InitCompSP27/InitCompSP27_Device.cu b/src/gpu/VirtualFluids_GPU/PreProcessor/PreProcessorStrategy/InitCompSP27/InitCompSP27_Device.cu index 6ecedde3ddf8e2a324680e3cbd0d48151fec1bd3..a411f5be08df855df141f202acd01de2a3e99cae 100644 --- a/src/gpu/VirtualFluids_GPU/PreProcessor/PreProcessorStrategy/InitCompSP27/InitCompSP27_Device.cu +++ b/src/gpu/VirtualFluids_GPU/PreProcessor/PreProcessorStrategy/InitCompSP27/InitCompSP27_Device.cu @@ -1,6 +1,8 @@ #include "LBM/LB.h" #include "LBM/D3Q27.h" -#include "Core/RealConstants.h" +#include <lbm/constants/NumericConstants.h> + +using namespace vf::lbm::constant; #include "math.h" #include <stdio.h> diff --git a/src/gpu/VirtualFluids_GPU/PreProcessor/PreProcessorStrategy/InitF3/InitF3_Device.cu b/src/gpu/VirtualFluids_GPU/PreProcessor/PreProcessorStrategy/InitF3/InitF3_Device.cu index 3024af8bafa1bc0c6b593bbfef3dda84d2c2f3ab..f69224e726eb9570642a9a1c09c20362c364256c 100644 --- a/src/gpu/VirtualFluids_GPU/PreProcessor/PreProcessorStrategy/InitF3/InitF3_Device.cu +++ b/src/gpu/VirtualFluids_GPU/PreProcessor/PreProcessorStrategy/InitF3/InitF3_Device.cu @@ -1,6 +1,8 @@ #include "LBM/LB.h" #include "LBM/D3Q27.h" -#include "Core/RealConstants.h" +#include <lbm/constants/NumericConstants.h> + +using namespace vf::lbm::constant; #include "math.h" diff --git a/src/gpu/VirtualFluids_GPU/PreProcessor/PreProcessorStrategy/InitIncompAD27/InitIncompAD27_Device.cu b/src/gpu/VirtualFluids_GPU/PreProcessor/PreProcessorStrategy/InitIncompAD27/InitIncompAD27_Device.cu index 714db3eac01fc156e36a6be49557effd5a9ed393..f304201bf82fe7b84b6e558dfe65ef780c9cd25f 100644 --- a/src/gpu/VirtualFluids_GPU/PreProcessor/PreProcessorStrategy/InitIncompAD27/InitIncompAD27_Device.cu +++ b/src/gpu/VirtualFluids_GPU/PreProcessor/PreProcessorStrategy/InitIncompAD27/InitIncompAD27_Device.cu @@ -1,6 +1,8 @@ #include "LBM/LB.h" #include "LBM/D3Q27.h" -#include "Core/RealConstants.h" +#include <lbm/constants/NumericConstants.h> + +using namespace vf::lbm::constant; #include "math.h" extern "C" __global__ void LB_Init_Incomp_AD_27(unsigned int* neighborX, diff --git a/src/gpu/VirtualFluids_GPU/PreProcessor/PreProcessorStrategy/InitIncompAD7/InitIncompAD7_Device.cu b/src/gpu/VirtualFluids_GPU/PreProcessor/PreProcessorStrategy/InitIncompAD7/InitIncompAD7_Device.cu index 369abed49ddea3dc86fb044584ed5d14de69b442..3a2730c8d116542e06338eb94430c2ee24e75404 100644 --- a/src/gpu/VirtualFluids_GPU/PreProcessor/PreProcessorStrategy/InitIncompAD7/InitIncompAD7_Device.cu +++ b/src/gpu/VirtualFluids_GPU/PreProcessor/PreProcessorStrategy/InitIncompAD7/InitIncompAD7_Device.cu @@ -1,6 +1,8 @@ #include "LBM/LB.h" #include "LBM/D3Q27.h" -#include "Core/RealConstants.h" +#include <lbm/constants/NumericConstants.h> + +using namespace vf::lbm::constant; #include "math.h" extern "C" __global__ void LB_Init_Incomp_AD_7(unsigned int* neighborX, diff --git a/src/gpu/VirtualFluids_GPU/PreProcessor/PreProcessorStrategy/InitSP27/InitSP27_Device.cu b/src/gpu/VirtualFluids_GPU/PreProcessor/PreProcessorStrategy/InitSP27/InitSP27_Device.cu index 3d4b9790e2cfaf19a5a29c6325a60d06d4e46733..ad55c17528b2348536846a8769848f17eeb6244a 100644 --- a/src/gpu/VirtualFluids_GPU/PreProcessor/PreProcessorStrategy/InitSP27/InitSP27_Device.cu +++ b/src/gpu/VirtualFluids_GPU/PreProcessor/PreProcessorStrategy/InitSP27/InitSP27_Device.cu @@ -1,6 +1,8 @@ #include "LBM/LB.h" #include "LBM/D3Q27.h" -#include "Core/RealConstants.h" +#include <lbm/constants/NumericConstants.h> + +using namespace vf::lbm::constant; #include "math.h" extern "C" __global__ void LB_Init_SP_27(unsigned int* neighborX, diff --git a/src/gpu/VirtualFluids_GPU/Restart/RestartObjectTests.cpp b/src/gpu/VirtualFluids_GPU/Restart/RestartObjectTests.cpp index a9b485ab25871066c201e631b97022bc6f7e08fb..c30f514c60ba1af2fb852ed8a68b36121ebced04 100644 --- a/src/gpu/VirtualFluids_GPU/Restart/RestartObjectTests.cpp +++ b/src/gpu/VirtualFluids_GPU/Restart/RestartObjectTests.cpp @@ -8,7 +8,7 @@ void saveAndLoad() { std::shared_ptr<RestartObject> write_object = std::make_shared<Type>(); - write_object->fs = std::vector<std::vector<float>> { + write_object->fs = std::vector<std::vector<real>> { { 1,2,3 }, { 4,5,6 } }; diff --git a/src/gpu/VirtualFluids_GPU/Temperature/FindQTemp.cpp b/src/gpu/VirtualFluids_GPU/Temperature/FindQTemp.cpp index c5f391e5a75bb59ce599a603b7c824a387f4615f..c2fd7b995b5b9fe28981ed9a11caf8bf6464e292 100644 --- a/src/gpu/VirtualFluids_GPU/Temperature/FindQTemp.cpp +++ b/src/gpu/VirtualFluids_GPU/Temperature/FindQTemp.cpp @@ -261,7 +261,8 @@ void findTemp(Parameter* para) int ex[6]={ 1, -1, 0, 0, 0, 0}; int ey[6]={ 0, 0, 1, -1, 0, 0}; int ez[6]={ 0, 0, 0, 0, 1, -1}; - real ON[7]; + + real ON[7] = {0, 0, 0, 0, 0, 0, 0}; //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// unsigned int i, j, k, m, mm, l; int nx = para->getParH(para->getCoarse())->nx; diff --git a/src/gpu/VirtualFluids_GPU/Temperature/FindTemperature.cpp b/src/gpu/VirtualFluids_GPU/Temperature/FindTemperature.cpp index e975d23b635db862ff97712987f885d9c9db5e87..906bdb57255513a4dd76df6eee6789a34ef2a816 100644 --- a/src/gpu/VirtualFluids_GPU/Temperature/FindTemperature.cpp +++ b/src/gpu/VirtualFluids_GPU/Temperature/FindTemperature.cpp @@ -10,20 +10,15 @@ #include <helper_cuda.h> #include "GPU/CudaMemoryManager.h" +#include "GPU/GPU_Interface.h" +#include "Parameter/Parameter.h" +#include "Temperature/FindQTemp.h" void initTemperatur(Parameter* para, CudaMemoryManager* cudaManager, int lev) { - printf("innerhalb initTemperatur\n"); - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - // alloc F's - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - cudaManager->cudaAllocTempFs(lev); - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //copy host to device - cudaManager->cudaCopyConcHD(lev); - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + cudaManager->cudaAllocTempFs(lev); + + cudaManager->cudaCopyConcHD(lev); if (para->getDiffMod() == 7) { @@ -40,7 +35,6 @@ void initTemperatur(Parameter* para, CudaMemoryManager* cudaManager, int lev) //InitThS7(); getLastCudaError("Kernel execution failed"); //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //printf("nach InitThS7 2\n"); //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// CalcMacThS7(para->getParD(lev)->Conc, @@ -85,20 +79,10 @@ void initTemperatur(Parameter* para, CudaMemoryManager* cudaManager, int lev) //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// } - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //copy device to host cudaManager->cudaCopyConcDH(lev); - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// } -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - - - - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// void findTempSim(Parameter* para, CudaMemoryManager* cudaManager) { findKforTemp(para); @@ -109,15 +93,8 @@ void findTempSim(Parameter* para, CudaMemoryManager* cudaManager) cudaManager->cudaCopyTempNoSlipBCHD(para->getCoarse()); } -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - - - - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// void findTempVelSim(Parameter* para, CudaMemoryManager* cudaManager) { findKforTempVel(para); @@ -128,15 +105,8 @@ void findTempVelSim(Parameter* para, CudaMemoryManager* cudaManager) cudaManager->cudaCopyTempVeloBCHD(para->getCoarse()); } -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - - - - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// void findTempPressSim(Parameter* para, CudaMemoryManager* cudaManager) { findKforTempPress(para); @@ -147,4 +117,3 @@ void findTempPressSim(Parameter* para, CudaMemoryManager* cudaManager) cudaManager->cudaCopyTempPressBCHD(para->getCoarse()); } -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/src/gpu/VirtualFluids_GPU/Temperature/FindTemperature.h b/src/gpu/VirtualFluids_GPU/Temperature/FindTemperature.h index 4520e157dfe82f05d8168bcb935918559147c007..cfd36f90884008c0a27ce873b3edad31cd94112c 100644 --- a/src/gpu/VirtualFluids_GPU/Temperature/FindTemperature.h +++ b/src/gpu/VirtualFluids_GPU/Temperature/FindTemperature.h @@ -1,19 +1,18 @@ #ifndef FIND_TEMPERATURE_H #define FIND_TEMPERATURE_H -#include "LBM/LB.h" -#include "GPU/GPU_Interface.h" -#include "Parameter/Parameter.h" -#include "Temperature/FindQTemp.h" class CudaMemoryManager; +class Parameter; -extern "C" void initTemperatur(Parameter* para, CudaMemoryManager* cudaManager, int lev); -extern "C" void findTempSim(Parameter* para, CudaMemoryManager* cudaManager); - -extern "C" void findTempVelSim(Parameter* para, CudaMemoryManager* cudaManager); - -extern "C" void findTempPressSim(Parameter* para, CudaMemoryManager* cudaManager); +void initTemperatur(Parameter* para, CudaMemoryManager* cudaManager, int lev); + +void findTempSim(Parameter* para, CudaMemoryManager* cudaManager); + +void findTempVelSim(Parameter* para, CudaMemoryManager* cudaManager); + +void findTempPressSim(Parameter* para, CudaMemoryManager* cudaManager); + #endif diff --git a/src/gpu/VirtualFluids_GPU/Utilities/EnumMapper/EnumMapperImp.h b/src/gpu/VirtualFluids_GPU/Utilities/EnumMapper/EnumMapperImp.h deleted file mode 100644 index 6e7238a0a64893a4e479d5a8173a6a643e03956b..0000000000000000000000000000000000000000 --- a/src/gpu/VirtualFluids_GPU/Utilities/EnumMapper/EnumMapperImp.h +++ /dev/null @@ -1,52 +0,0 @@ -#ifndef ENUM_MAPPER_IMP_H -#define ENUM_MAPPER_IMP_H - -#include <map> -#include <string> -#include <stdexcept> - -template <typename T> -class EnumMapperImp -{ -public: - std::string getString(T enumeration); - T getEnum(std::string name); - void addEnum(T enumeration, std::string name); - -private: - std::map< T, std::string> enumMap; - std::map< std::string, T> stringMap; - -}; -#endif - -template<typename T> -inline std::string EnumMapperImp<T>::getString(T enumeration) -{ - typename std::map< T, std::string>::iterator it; - it = enumMap.find(enumeration); - if (it == enumMap.end()) { - throw std::runtime_error("Enumeration is not registered."); - } - else - return it->second; -} - -template<typename T> -inline T EnumMapperImp<T>::getEnum(std::string name) -{ - typename std::map< std::string, T>::iterator it; - it = stringMap.find(name); - if (it == stringMap.end()) { - throw std::runtime_error("String is not registered."); - } - else - return it->second; -} - -template<typename T> -inline void EnumMapperImp<T>::addEnum(T enumeration, std::string name) -{ - enumMap.insert(std::pair< T, std::string>(enumeration, name)); - stringMap.insert(std::pair< std::string, T>(name, enumeration)); -} diff --git a/src/lbm/BGK.cpp b/src/lbm/BGK.cpp new file mode 100644 index 0000000000000000000000000000000000000000..fa3af6777a0492687768dd4945cbf1e9b186f514 --- /dev/null +++ b/src/lbm/BGK.cpp @@ -0,0 +1,140 @@ +#include "BGK.h" + + +#include <basics/Core/DataTypes.h> +#include <basics/Core/RealConstants.h> + +#include "constants/NumericConstants.h" +#include "constants/D3Q27.h" + +#include "MacroscopicQuantities.h" + +namespace vf +{ +namespace lbm +{ + +using namespace constant; + + + +__host__ __device__ void bgk(KernelParameter parameter) +{ + auto& distribution = parameter.distribution; + const auto omega = parameter.omega; + + //////////////////////////////////////////////////////////////////////////////////// + //! - Read 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> + //! + real mfcbb = distribution.f[dir::PZZ]; + real mfabb = distribution.f[dir::MZZ]; + real mfbcb = distribution.f[dir::ZPZ]; + real mfbab = distribution.f[dir::ZMZ]; + real mfbbc = distribution.f[dir::ZZP]; + real mfbba = distribution.f[dir::ZZM]; + real mfccb = distribution.f[dir::PPZ]; + real mfaab = distribution.f[dir::MMZ]; + real mfcab = distribution.f[dir::PMZ]; + real mfacb = distribution.f[dir::MPZ]; + real mfcbc = distribution.f[dir::PZP]; + real mfaba = distribution.f[dir::MZM]; + real mfcba = distribution.f[dir::PZM]; + real mfabc = distribution.f[dir::MZP]; + real mfbcc = distribution.f[dir::ZPP]; + real mfbaa = distribution.f[dir::ZMM]; + real mfbca = distribution.f[dir::ZPM]; + real mfbac = distribution.f[dir::ZMP]; + real mfccc = distribution.f[dir::PPP]; + real mfacc = distribution.f[dir::MPP]; + real mfcac = distribution.f[dir::PMP]; + real mfaac = distribution.f[dir::MMP]; + real mfcca = distribution.f[dir::PPM]; + real mfaca = distribution.f[dir::MPM]; + real mfcaa = distribution.f[dir::PMM]; + real mfaaa = distribution.f[dir::MMM]; + real mfbbb = distribution.f[dir::ZZZ]; + + + //////////////////////////////////////////////////////////////////////////////////// + //! - Acquire macroscopic quantities + const real drho = getDensity(distribution.f); + const real rho = c1o1 + drho; + const real OOrho = constant::c1o1 / (constant::c1o1 + drho); + + const real vvx = getIncompressibleVelocityX1(distribution.f) * OOrho; + const real vvy = getIncompressibleVelocityX2(distribution.f) * OOrho; + const real vvz = getIncompressibleVelocityX3(distribution.f) * OOrho; + + + //////////////////////////////////////////////////////////////////////////////////// + //! - BGK computation + const real cusq = c3o2*(vvx*vvx + vvy*vvy + vvz*vvz); + + mfbbb = mfbbb *(c1o1 + (-omega)) - (-omega)* c8o27* (drho - rho * cusq); + mfcbb = mfcbb *(c1o1 + (-omega)) - (-omega)* c2o27* (drho + rho * (c3o1*(vvx)+c9o2*(vvx)*(vvx)-cusq)); + mfabb = mfabb *(c1o1 + (-omega)) - (-omega)* c2o27* (drho + rho * (c3o1*(-vvx) + c9o2*(-vvx)*(-vvx) - cusq)); + mfbcb = mfbcb *(c1o1 + (-omega)) - (-omega)* c2o27* (drho + rho * (c3o1*(vvy)+c9o2*(vvy)*(vvy)-cusq)); + mfbab = mfbab *(c1o1 + (-omega)) - (-omega)* c2o27* (drho + rho * (c3o1*(-vvy) + c9o2*(-vvy)*(-vvy) - cusq)); + mfbbc = mfbbc *(c1o1 + (-omega)) - (-omega)* c2o27* (drho + rho * (c3o1*(vvz)+c9o2*(vvz)*(vvz)-cusq)); + mfbba = mfbba *(c1o1 + (-omega)) - (-omega)* c2o27* (drho + rho * (c3o1*(-vvz) + c9o2*(-vvz)*(-vvz) - cusq)); + mfccb = mfccb *(c1o1 + (-omega)) - (-omega)* c1o54* (drho + rho * (c3o1*(vvx + vvy) + c9o2*(vvx + vvy)*(vvx + vvy) - cusq)); + mfaab = mfaab *(c1o1 + (-omega)) - (-omega)* c1o54* (drho + rho * (c3o1*(-vvx - vvy) + c9o2*(-vvx - vvy)*(-vvx - vvy) - cusq)); + mfcab = mfcab *(c1o1 + (-omega)) - (-omega)* c1o54* (drho + rho * (c3o1*(vvx - vvy) + c9o2*(vvx - vvy)*(vvx - vvy) - cusq)); + mfacb = mfacb *(c1o1 + (-omega)) - (-omega)* c1o54* (drho + rho * (c3o1*(-vvx + vvy) + c9o2*(-vvx + vvy)*(-vvx + vvy) - cusq)); + mfcbc = mfcbc *(c1o1 + (-omega)) - (-omega)* c1o54* (drho + rho * (c3o1*(vvx + vvz) + c9o2*(vvx + vvz)*(vvx + vvz) - cusq)); + mfaba = mfaba *(c1o1 + (-omega)) - (-omega)* c1o54* (drho + rho * (c3o1*(-vvx - vvz) + c9o2*(-vvx - vvz)*(-vvx - vvz) - cusq)); + mfcba = mfcba *(c1o1 + (-omega)) - (-omega)* c1o54* (drho + rho * (c3o1*(vvx - vvz) + c9o2*(vvx - vvz)*(vvx - vvz) - cusq)); + mfabc = mfabc *(c1o1 + (-omega)) - (-omega)* c1o54* (drho + rho * (c3o1*(-vvx + vvz) + c9o2*(-vvx + vvz)*(-vvx + vvz) - cusq)); + mfbcc = mfbcc *(c1o1 + (-omega)) - (-omega)* c1o54* (drho + rho * (c3o1*(vvy + vvz) + c9o2*(vvy + vvz)*(vvy + vvz) - cusq)); + mfbaa = mfbaa *(c1o1 + (-omega)) - (-omega)* c1o54* (drho + rho * (c3o1*(-vvy - vvz) + c9o2*(-vvy - vvz)*(-vvy - vvz) - cusq)); + mfbca = mfbca *(c1o1 + (-omega)) - (-omega)* c1o54* (drho + rho * (c3o1*(vvy - vvz) + c9o2*(vvy - vvz)*(vvy - vvz) - cusq)); + mfbac = mfbac *(c1o1 + (-omega)) - (-omega)* c1o54* (drho + rho * (c3o1*(-vvy + vvz) + c9o2*(-vvy + vvz)*(-vvy + vvz) - cusq)); + mfccc = mfccc *(c1o1 + (-omega)) - (-omega)* c1o216*(drho + rho * (c3o1*(vvx + vvy + vvz) + c9o2*(vvx + vvy + vvz)*(vvx + vvy + vvz) - cusq)); + mfaaa = mfaaa *(c1o1 + (-omega)) - (-omega)* c1o216*(drho + rho * (c3o1*(-vvx - vvy - vvz) + c9o2*(-vvx - vvy - vvz)*(-vvx - vvy - vvz) - cusq)); + mfcca = mfcca *(c1o1 + (-omega)) - (-omega)* c1o216*(drho + rho * (c3o1*(vvx + vvy - vvz) + c9o2*(vvx + vvy - vvz)*(vvx + vvy - vvz) - cusq)); + mfaac = mfaac *(c1o1 + (-omega)) - (-omega)* c1o216*(drho + rho * (c3o1*(-vvx - vvy + vvz) + c9o2*(-vvx - vvy + vvz)*(-vvx - vvy + vvz) - cusq)); + mfcac = mfcac *(c1o1 + (-omega)) - (-omega)* c1o216*(drho + rho * (c3o1*(vvx - vvy + vvz) + c9o2*(vvx - vvy + vvz)*(vvx - vvy + vvz) - cusq)); + mfaca = mfaca *(c1o1 + (-omega)) - (-omega)* c1o216*(drho + rho * (c3o1*(-vvx + vvy - vvz) + c9o2*(-vvx + vvy - vvz)*(-vvx + vvy - vvz) - cusq)); + mfcaa = mfcaa *(c1o1 + (-omega)) - (-omega)* c1o216*(drho + rho * (c3o1*(vvx - vvy - vvz) + c9o2*(vvx - vvy - vvz)*(vvx - vvy - vvz) - cusq)); + mfacc = mfacc *(c1o1 + (-omega)) - (-omega)* c1o216*(drho + rho * (c3o1*(-vvx + vvy + vvz) + c9o2*(-vvx + vvy + vvz)*(-vvx + vvy + vvz) - cusq)); + + //////////////////////////////////////////////////////////////////////////////////// + //! - 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> + //! + distribution.f[dir::MZZ] = mfcbb; + distribution.f[dir::PZZ] = mfabb; + distribution.f[dir::ZMZ] = mfbcb; + distribution.f[dir::ZPZ] = mfbab; + distribution.f[dir::ZZM] = mfbbc; + distribution.f[dir::ZZP] = mfbba; + distribution.f[dir::MMZ] = mfccb; + distribution.f[dir::PPZ] = mfaab; + distribution.f[dir::MPZ] = mfcab; + distribution.f[dir::PMZ] = mfacb; + distribution.f[dir::MZM] = mfcbc; + distribution.f[dir::PZP] = mfaba; + distribution.f[dir::MZP] = mfcba; + distribution.f[dir::PZM] = mfabc; + distribution.f[dir::ZMM] = mfbcc; + distribution.f[dir::ZPP] = mfbaa; + distribution.f[dir::ZMP] = mfbca; + distribution.f[dir::ZPM] = mfbac; + distribution.f[dir::MMM] = mfccc; + distribution.f[dir::PMM] = mfacc; + distribution.f[dir::MPM] = mfcac; + distribution.f[dir::PPM] = mfaac; + distribution.f[dir::MMP] = mfcca; + distribution.f[dir::PMP] = mfaca; + distribution.f[dir::MPP] = mfcaa; + distribution.f[dir::PPP] = mfaaa; + distribution.f[dir::ZZZ] = mfbbb; +} + + +} +} + diff --git a/src/lbm/BGK.h b/src/lbm/BGK.h new file mode 100644 index 0000000000000000000000000000000000000000..2c82f5bd445ee008954add02fd0d6d6093364e90 --- /dev/null +++ b/src/lbm/BGK.h @@ -0,0 +1,24 @@ +#ifndef LBM_BGK_H +#define LBM_BGK_H + +#ifndef __host__ +#define __host__ +#endif +#ifndef __device__ +#define __device__ +#endif + +#include <basics/Core/DataTypes.h> + +#include "KernelParameter.h" + +namespace vf +{ +namespace lbm +{ + +__host__ __device__ void bgk(KernelParameter parameter); + +} +} +#endif diff --git a/src/lbm/CMakeLists.txt b/src/lbm/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..afa90bdd3f95bb71cf7f1eda6407f9b38766072a --- /dev/null +++ b/src/lbm/CMakeLists.txt @@ -0,0 +1,12 @@ +if(BUILD_VF_CPU) + project(lbm LANGUAGES CXX) + + vf_add_library(NAME lbm PUBLIC_LINK basics) + target_link_libraries(lbm PRIVATE project_warnings) + + vf_add_tests() +endif() + +if(BUILD_VF_GPU OR BUILD_VF_GKS) + add_subdirectory(cuda) +endif() diff --git a/src/lbm/Chimera.h b/src/lbm/Chimera.h new file mode 100644 index 0000000000000000000000000000000000000000..6ffa0918aac4e6303efe4db82aa98ee645dc63e8 --- /dev/null +++ b/src/lbm/Chimera.h @@ -0,0 +1,121 @@ +#ifndef LBM_CHIMERA_H +#define LBM_CHIMERA_H + +#ifndef __host__ +#define __host__ +#endif +#ifndef __device__ +#define __device__ +#endif + +#include <basics/Core/DataTypes.h> + +#include <lbm/constants/NumericConstants.h> + +namespace vf +{ +namespace lbm +{ + +using namespace constant; + +//////////////////////////////////////////////////////////////////////////////// +//! \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. +//////////////////////////////////////////////////////////////////////////////// +inline __host__ __device__ void forwardInverseChimeraWithK(real &mfa, real &mfb, real &mfc, real vv, + real v2, real Kinverse, real K) +{ + const real m2 = mfa + mfc; + const real m1 = mfc - mfa; + real m0 = m2 + mfb; + + mfa = m0; + m0 *= Kinverse; + m0 += c1o1; + mfb = (m1 * Kinverse - m0 * vv) * K; + mfc = ((m2 - c2o1 * m1 * vv) * Kinverse + v2 * m0) * K; +} + +//////////////////////////////////////////////////////////////////////////////// +//! \brief backward chimera transformation \ref backwardInverseChimeraWithK +//! 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> +//! ] Modified for lower round-off errors. +//////////////////////////////////////////////////////////////////////////////// +inline __host__ __device__ void backwardInverseChimeraWithK(real &mfa, real &mfb, real &mfc, real vv, + real v2, real Kinverse, real K) +{ + const real m0 = (((mfc - mfb) * c1o2 + mfb * vv) * Kinverse + (mfa * Kinverse + c1o1) * (v2 - vv) * c1o2) * K; + const real m1 = (((mfa - mfc) - c2o1 * mfb * vv) * Kinverse + (mfa * Kinverse + c1o1) * (-v2)) * K; + + mfc = (((mfc + mfb) * c1o2 + mfb * vv) * Kinverse + (mfa * Kinverse + c1o1) * (v2 + vv) * c1o2) * K; + mfa = m0; + mfb = m1; +} + +//////////////////////////////////////////////////////////////////////////////// +//! \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. +//! Modified for lower round-off errors. +//////////////////////////////////////////////////////////////////////////////// +inline __host__ __device__ void forwardChimera(real &mfa, real &mfb, real &mfc, real vv, real v2) +{ + const real m1 = (mfa + mfc) + mfb; + const real m2 = mfc - mfa; + + mfc = (mfc + mfa) + (v2 * m1 - c2o1 * vv * m2); + mfb = m2 - vv * m1; + mfa = m1; +} + +//////////////////////////////////////////////////////////////////////////////// +//! \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. +//! Modified for lower round-off errors. +//////////////////////////////////////////////////////////////////////////////// +inline __host__ __device__ void backwardChimera(real &mfa, real &mfb, real &mfc, real vv, real v2) +{ + const real ma = (mfc + mfa * (v2 - vv)) * c1o2 + mfb * (vv - c1o2); + const real mb = ((mfa - mfc) - mfa * v2) - c2o1 * mfb * vv; + + mfc = (mfc + mfa * (v2 + vv)) * c1o2 + mfb * (vv + c1o2); + mfb = mb; + mfa = ma; +} + + +inline __host__ __device__ void forwardChimeraWithK(real &mfa, real &mfb, real &mfc, real vv, real v2, real K) +{ + + const real m2 = mfa + mfc; + const real m1 = mfc - mfa; + const real m0 = m2 + mfb; + mfa = m0; + //m0 += K; + mfb = (m1 - K*vv) - m0 * vv; + mfc = ((m2 - c2o1* m1 * vv) + v2*K) + v2 * m0; + //m0 += K; + //mfb = m1 - m0 * vv; + //mfc = m2 - two* m1 * vv + v2 * m0; +} + + +inline __host__ __device__ void backwardChimeraWithK(real &mfa, real &mfb, real &mfc, real vv, real v2, real K) +{ + const real m0 = (mfc - mfb)* c1o2 + mfb * (vv)+(mfa + K) * (v2 - vv) * c1o2; + const real m1 = (mfa - mfc) - c2o1* mfb * vv + (mfa + K) * (-v2); + mfc = (mfc + mfb)* c1o2 + mfb * (vv)+(mfa + K) * (v2 + vv) * c1o2; + mfa = m0; + mfb = m1; +} + +} +} +#endif diff --git a/src/lbm/ChimeraTests.cpp b/src/lbm/ChimeraTests.cpp new file mode 100644 index 0000000000000000000000000000000000000000..01abbe82764c276f53a4cdd479d333536199c3a9 --- /dev/null +++ b/src/lbm/ChimeraTests.cpp @@ -0,0 +1,133 @@ +#include <gmock/gmock.h> + +#include "Chimera.h" + +#ifdef VF_DOUBLE_ACCURACY +#define REAL_EQ(a) testing::DoubleEq(a) +#else +#define REAL_EQ(a) testing::FloatEq(a) +#endif + +/* +* InverseChimeraWithK +*/ +TEST(ChimeraTest, forwardInverseChimeraWithK) +{ + real mfa = 1; + real mfb = 1; + real mfc = 1; + + const real vv = 1.; + const real v2 = 1.; + + const real K = 1.; + const real Kinverse = 1 / K; + + vf::lbm::forwardInverseChimeraWithK(mfa, mfb, mfc, vv, v2, K, Kinverse); + + EXPECT_THAT(mfa, REAL_EQ(3.)); // mfa + mfb + mfc + EXPECT_THAT(mfb, REAL_EQ(-4.)); // -(mfa + mfb + mfc + 1) + EXPECT_THAT(mfc, REAL_EQ(6.)); // (mfa + mfc) + (mfa + mfb + mfc + 1) +} + + +TEST(ChimeraTest, backwardInverseChimeraWithK) +{ + // starting with the result values from the test above. + real mfa = 3.; + real mfb = -4.; + real mfc = 6.; + + const real vv = 1.; + const real v2 = 1.; + + const real K = 1.; + const real Kinverse = 1 / K; + + vf::lbm::backwardInverseChimeraWithK(mfa, mfb, mfc, vv, v2, K, Kinverse); + + // resulting in the start values from the test above. + EXPECT_THAT(mfa, REAL_EQ(1.)); + EXPECT_THAT(mfb, REAL_EQ(1.)); + EXPECT_THAT(mfc, REAL_EQ(1.)); +} + +/* +* Chimera +*/ +TEST(ChimeraTest, forwardChimera) +{ + real mfa = 1; + real mfb = 1; + real mfc = 1; + + const real vv = 1.; + const real v2 = 1.; + + vf::lbm::forwardChimera(mfa, mfb, mfc, vv, v2); + + EXPECT_THAT(mfa, REAL_EQ(3.)); // mfa + mfb + mfc + EXPECT_THAT(mfb, REAL_EQ(-3.)); // -(mfa + mfb + mfc) + EXPECT_THAT(mfc, REAL_EQ(5.)); // (mfa + mfc) + (mfa + mfb + mfc) +} + + +TEST(ChimeraTest, backwardChimera) +{ + // starting with the result values from the test above. + real mfa = 3.; + real mfb = -3.; + real mfc = 5.; + + const real vv = 1.; + const real v2 = 1.; + + vf::lbm::backwardChimera(mfa, mfb, mfc, vv, v2); + + // resulting in the start values from the test above. + EXPECT_THAT(mfa, REAL_EQ(1.)); + EXPECT_THAT(mfb, REAL_EQ(1.)); + EXPECT_THAT(mfc, REAL_EQ(1.)); +} + +/* +* ChimeraWithK +*/ +TEST(ChimeraTest, forwardChimeraWithK) +{ + real mfa = 1; + real mfb = 1; + real mfc = 1; + + const real vv = 1.; + const real v2 = 1.; + + const real K = 1.; + + vf::lbm::forwardChimeraWithK(mfa, mfb, mfc, vv, v2, K); + + EXPECT_THAT(mfa, REAL_EQ(3.)); // mfa + mfb + mfc + EXPECT_THAT(mfb, REAL_EQ(-4.)); // -(mfa + mfb + mfc) + EXPECT_THAT(mfc, REAL_EQ(6.)); // (mfa + mfc) + (mfa + mfb + mfc) +} + + +TEST(ChimeraTest, backwardChimeraWithK) +{ + // starting with the result values from the test above. + real mfa = 3.; + real mfb = -4.; + real mfc = 6.; + + const real vv = 1.; + const real v2 = 1.; + + const real K = 1.; + + vf::lbm::backwardChimeraWithK(mfa, mfb, mfc, vv, v2, K); + + // resulting in the start values from the test above. + EXPECT_THAT(mfa, REAL_EQ(1.)); + EXPECT_THAT(mfb, REAL_EQ(1.)); + EXPECT_THAT(mfc, REAL_EQ(1.)); +} diff --git a/src/lbm/CumulantChimera.cpp b/src/lbm/CumulantChimera.cpp new file mode 100644 index 0000000000000000000000000000000000000000..65dc9b1f82f409447fda54fc0bc5f460533aad1b --- /dev/null +++ b/src/lbm/CumulantChimera.cpp @@ -0,0 +1,453 @@ +#include "CumulantChimera.h" + +#include <cmath> + +#include <basics/Core/DataTypes.h> +#include <basics/Core/RealConstants.h> + +#include "constants/NumericConstants.h" +#include "constants/D3Q27.h" + +#include "Chimera.h" +#include "MacroscopicQuantities.h" + +namespace vf +{ +namespace lbm +{ + +using namespace constant; + + +//////////////////////////////////////////////////////////////////////////////////// +//! - 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$. +////////////////////////////////////////////////////////////////////////// +__host__ __device__ void setRelaxationRatesK17(real omega, real &OxxPyyPzz, real &OxyyPxzz, real &OxyyMxzz, real &Oxyz, + real &O4, real &O5, real &O6) +{ + OxxPyyPzz = c1o1; + + OxyyPxzz = c8o1 * (-c2o1 + omega) * (c1o1 + c2o1 * omega) / (-c8o1 - c14o1 * omega + c7o1 * omega * omega); + OxyyMxzz = c8o1 * (-c2o1 + omega) * (-c7o1 + c4o1 * omega) / (c56o1 - c50o1 * omega + c9o1 * omega * omega); + Oxyz = c24o1 * (-c2o1 + omega) * (-c2o1 - c7o1 * omega + c3o1 * omega * omega) / + (c48o1 + c152o1 * omega - c130o1 * omega * omega + c29o1 * omega * omega * omega); + + O4 = c1o1; + + O5 = c1o1; + + O6 = c1o1; +} + + +__host__ __device__ void setRelaxationRatesK15(real omega, real &OxxPyyPzz, real &OxyyPxzz, real &OxyyMxzz, real &Oxyz, + real &O4, real &O5, real &O6) +{ + OxxPyyPzz = c1o1; + + OxyyPxzz = c1o1; + OxyyMxzz = c1o1; + Oxyz = c1o1; + + O4 = c1o1; + + O5 = c1o1; + + O6 = c1o1; +} + +////////////////////////////////////////////////////////////////////////// +//! 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> +////////////////////////////////////////////////////////////////////////// +__host__ __device__ void cumulantChimera(KernelParameter parameter, RelaxationRatesFunctor setRelaxationRates) +{ + auto& distribution = parameter.distribution; + const auto omega = parameter.omega; + const auto* forces = parameter.forces; + + //////////////////////////////////////////////////////////////////////////////////// + //! - Read 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> + //! + real mfcbb = distribution.f[dir::PZZ]; + real mfabb = distribution.f[dir::MZZ]; + real mfbcb = distribution.f[dir::ZPZ]; + real mfbab = distribution.f[dir::ZMZ]; + real mfbbc = distribution.f[dir::ZZP]; + real mfbba = distribution.f[dir::ZZM]; + real mfccb = distribution.f[dir::PPZ]; + real mfaab = distribution.f[dir::MMZ]; + real mfcab = distribution.f[dir::PMZ]; + real mfacb = distribution.f[dir::MPZ]; + real mfcbc = distribution.f[dir::PZP]; + real mfaba = distribution.f[dir::MZM]; + real mfcba = distribution.f[dir::PZM]; + real mfabc = distribution.f[dir::MZP]; + real mfbcc = distribution.f[dir::ZPP]; + real mfbaa = distribution.f[dir::ZMM]; + real mfbca = distribution.f[dir::ZPM]; + real mfbac = distribution.f[dir::ZMP]; + real mfccc = distribution.f[dir::PPP]; + real mfacc = distribution.f[dir::MPP]; + real mfcac = distribution.f[dir::PMP]; + real mfaac = distribution.f[dir::MMP]; + real mfcca = distribution.f[dir::PPM]; + real mfaca = distribution.f[dir::MPM]; + real mfcaa = distribution.f[dir::PMM]; + real mfaaa = distribution.f[dir::MMM]; + real mfbbb = distribution.f[dir::ZZZ]; + + + const real drho = getDensity(distribution.f); + const real OOrho = c1o1 / (c1o1 + drho); + + //////////////////////////////////////////////////////////////////////////////////// + //! - 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> + //! + const real vvx = getIncompressibleVelocityX1(distribution.f) * OOrho + forces[0] * c1o2; + const real vvy = getIncompressibleVelocityX2(distribution.f) * OOrho + forces[0] * c1o2; + const real vvz = getIncompressibleVelocityX3(distribution.f) * OOrho + forces[0] * c1o2; + + //////////////////////////////////////////////////////////////////////////////////// + // calculate the square of velocities for this lattice node + const real vx2 = vvx*vvx; + const real vy2 = vvy*vvy; + const real vz2 = vvz*vvz; + + //////////////////////////////////////////////////////////////////////////////////// + //! - 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 + vf::lbm::forwardInverseChimeraWithK(mfaaa, mfaab, mfaac, vvz, vz2, c36o1, c1o36); + vf::lbm::forwardInverseChimeraWithK(mfaba, mfabb, mfabc, vvz, vz2, c9o1, c1o9); + vf::lbm::forwardInverseChimeraWithK(mfaca, mfacb, mfacc, vvz, vz2, c36o1, c1o36); + vf::lbm::forwardInverseChimeraWithK(mfbaa, mfbab, mfbac, vvz, vz2, c9o1, c1o9); + vf::lbm::forwardInverseChimeraWithK(mfbba, mfbbb, mfbbc, vvz, vz2, c9o4, c4o9); + vf::lbm::forwardInverseChimeraWithK(mfbca, mfbcb, mfbcc, vvz, vz2, c9o1, c1o9); + vf::lbm::forwardInverseChimeraWithK(mfcaa, mfcab, mfcac, vvz, vz2, c36o1, c1o36); + vf::lbm::forwardInverseChimeraWithK(mfcba, mfcbb, mfcbc, vvz, vz2, c9o1, c1o9); + vf::lbm::forwardInverseChimeraWithK(mfcca, mfccb, mfccc, vvz, vz2, c36o1, c1o36); + //////////////////////////////////////////////////////////////////////////////////// + // Y - Dir + vf::lbm::forwardInverseChimeraWithK(mfaaa, mfaba, mfaca, vvy, vy2, c6o1, c1o6); + vf::lbm::forwardChimera( mfaab, mfabb, mfacb, vvy, vy2); + vf::lbm::forwardInverseChimeraWithK(mfaac, mfabc, mfacc, vvy, vy2, c18o1, c1o18); + vf::lbm::forwardInverseChimeraWithK(mfbaa, mfbba, mfbca, vvy, vy2, c3o2, c2o3); + vf::lbm::forwardChimera( mfbab, mfbbb, mfbcb, vvy, vy2); + vf::lbm::forwardInverseChimeraWithK(mfbac, mfbbc, mfbcc, vvy, vy2, c9o2, c2o9); + vf::lbm::forwardInverseChimeraWithK(mfcaa, mfcba, mfcca, vvy, vy2, c6o1, c1o6); + vf::lbm::forwardChimera( mfcab, mfcbb, mfccb, vvy, vy2); + vf::lbm::forwardInverseChimeraWithK(mfcac, mfcbc, mfccc, vvy, vy2, c18o1, c1o18); + //////////////////////////////////////////////////////////////////////////////////// + // X - Dir + vf::lbm::forwardInverseChimeraWithK(mfaaa, mfbaa, mfcaa, vvx, vx2, c1o1, c1o1); + vf::lbm::forwardChimera( mfaba, mfbba, mfcba, vvx, vx2); + vf::lbm::forwardInverseChimeraWithK(mfaca, mfbca, mfcca, vvx, vx2, c3o1, c1o3); + vf::lbm::forwardChimera( mfaab, mfbab, mfcab, vvx, vx2); + vf::lbm::forwardChimera( mfabb, mfbbb, mfcbb, vvx, vx2); + vf::lbm::forwardChimera( mfacb, mfbcb, mfccb, vvx, vx2); + vf::lbm::forwardInverseChimeraWithK(mfaac, mfbac, mfcac, vvx, vx2, c3o1, c1o3); + vf::lbm::forwardChimera( mfabc, mfbbc, mfcbc, vvx, vx2); + vf::lbm::forwardInverseChimeraWithK(mfacc, mfbcc, mfccc, vvx, vx2, c3o1, c1o9); + + //////////////////////////////////////////////////////////////////////////////////// + //! - Setting relaxation rates for non-hydrodynamic cumulants (default values). Variable names and equations + real OxxPyyPzz; + real OxyyPxzz; + real OxyyMxzz; + real Oxyz; + real O4; + real O5; + real O6; + + setRelaxationRates(omega, OxxPyyPzz, OxyyPxzz, OxyyMxzz, Oxyz, O4, O5, O6); + + //////////////////////////////////////////////////////////////////////////////////// + //! - 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). + //! + const real A = (c4o1 + c2o1*omega - c3o1*omega*omega) / (c2o1 - c7o1*omega + c5o1*omega*omega); + const 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. + //! + const real Dxy = -c3o1*omega*mfbba; + const real Dxz = -c3o1*omega*mfbab; + const real Dyz = -c3o1*omega*mfabb; + const real dxux = c1o2 * (-omega) *(mxxMyy + mxxMzz) + c1o2 * OxxPyyPzz * (mfaaa - mxxPyyPzz); + const real dyuy = dxux + omega * c3o2 * mxxMyy; + const real dzuz = dxux + omega * c3o2 * mxxMzz; + //////////////////////////////////////////////////////////// + //! - 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 + //! Set relaxation limiters for third order cumulants to default value \f$ \lambda=0.001 \f$ according to section 6 in \ref + //! - 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> + //! + + const real qudricLimitP = c1o100; + const real qudricLimitM = c1o100; + const real qudricLimitD = c1o100; + + real wadjust = Oxyz + (c1o1 - Oxyz)*abs_internal(mfbbb) / (abs_internal(mfbbb) + qudricLimitD); + mfbbb += wadjust * (-mfbbb); + wadjust = OxyyPxzz + (c1o1 - OxyyPxzz)*abs_internal(mxxyPyzz) / (abs_internal(mxxyPyzz) + qudricLimitP); + mxxyPyzz += wadjust * (-mxxyPyzz); + wadjust = OxyyMxzz + (c1o1 - OxyyMxzz)*abs_internal(mxxyMyzz) / (abs_internal(mxxyMyzz) + qudricLimitM); + mxxyMyzz += wadjust * (-mxxyMyzz); + wadjust = OxyyPxzz + (c1o1 - OxyyPxzz)*abs_internal(mxxzPyyz) / (abs_internal(mxxzPyyz) + qudricLimitP); + mxxzPyyz += wadjust * (-mxxzPyyz); + wadjust = OxyyMxzz + (c1o1 - OxyyMxzz)*abs_internal(mxxzMyyz) / (abs_internal(mxxzMyyz) + qudricLimitM); + mxxzMyyz += wadjust * (-mxxzMyyz); + wadjust = OxyyPxzz + (c1o1 - OxyyPxzz)*abs_internal(mxyyPxzz) / (abs_internal(mxyyPxzz) + qudricLimitP); + mxyyPxzz += wadjust * (-mxyyPxzz); + wadjust = OxyyMxzz + (c1o1 - OxyyMxzz)*abs_internal(mxyyMxzz) / (abs_internal(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; + //////////////////////////////////////////////////////////////////////////////////// + //! - 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 + vf::lbm::backwardInverseChimeraWithK(mfaaa, mfbaa, mfcaa, vvx, vx2, c1o1, c1o1); + vf::lbm::backwardChimera( mfaba, mfbba, mfcba, vvx, vx2); + vf::lbm::backwardInverseChimeraWithK(mfaca, mfbca, mfcca, vvx, vx2, c3o1, c1o3); + vf::lbm::backwardChimera( mfaab, mfbab, mfcab, vvx, vx2); + vf::lbm::backwardChimera( mfabb, mfbbb, mfcbb, vvx, vx2); + vf::lbm::backwardChimera( mfacb, mfbcb, mfccb, vvx, vx2); + vf::lbm::backwardInverseChimeraWithK(mfaac, mfbac, mfcac, vvx, vx2, c3o1, c1o3); + vf::lbm::backwardChimera( mfabc, mfbbc, mfcbc, vvx, vx2); + vf::lbm::backwardInverseChimeraWithK(mfacc, mfbcc, mfccc, vvx, vx2, c9o1, c1o9); + //////////////////////////////////////////////////////////////////////////////////// + // Y - Dir + vf::lbm::backwardInverseChimeraWithK(mfaaa, mfaba, mfaca, vvy, vy2, c6o1, c1o6); + vf::lbm::backwardChimera( mfaab, mfabb, mfacb, vvy, vy2); + vf::lbm::backwardInverseChimeraWithK(mfaac, mfabc, mfacc, vvy, vy2, c18o1, c1o18); + vf::lbm::backwardInverseChimeraWithK(mfbaa, mfbba, mfbca, vvy, vy2, c3o2, c2o3); + vf::lbm::backwardChimera( mfbab, mfbbb, mfbcb, vvy, vy2); + vf::lbm::backwardInverseChimeraWithK(mfbac, mfbbc, mfbcc, vvy, vy2, c9o2, c2o9); + vf::lbm::backwardInverseChimeraWithK(mfcaa, mfcba, mfcca, vvy, vy2, c6o1, c1o6); + vf::lbm::backwardChimera( mfcab, mfcbb, mfccb, vvy, vy2); + vf::lbm::backwardInverseChimeraWithK(mfcac, mfcbc, mfccc, vvy, vy2, c18o1, c1o18); + //////////////////////////////////////////////////////////////////////////////////// + // Z - Dir + vf::lbm::backwardInverseChimeraWithK(mfaaa, mfaab, mfaac, vvz, vz2, c36o1, c1o36); + vf::lbm::backwardInverseChimeraWithK(mfaba, mfabb, mfabc, vvz, vz2, c9o1, c1o9); + vf::lbm::backwardInverseChimeraWithK(mfaca, mfacb, mfacc, vvz, vz2, c36o1, c1o36); + vf::lbm::backwardInverseChimeraWithK(mfbaa, mfbab, mfbac, vvz, vz2, c9o1, c1o9); + vf::lbm::backwardInverseChimeraWithK(mfbba, mfbbb, mfbbc, vvz, vz2, c9o4, c4o9); + vf::lbm::backwardInverseChimeraWithK(mfbca, mfbcb, mfbcc, vvz, vz2, c9o1, c1o9); + vf::lbm::backwardInverseChimeraWithK(mfcaa, mfcab, mfcac, vvz, vz2, c36o1, c1o36); + vf::lbm::backwardInverseChimeraWithK(mfcba, mfcbb, mfcbc, vvz, vz2, c9o1, c1o9); + vf::lbm::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> + //! + distribution.f[dir::MZZ] = mfcbb; + distribution.f[dir::PZZ] = mfabb; + distribution.f[dir::ZMZ] = mfbcb; + distribution.f[dir::ZPZ] = mfbab; + distribution.f[dir::ZZM] = mfbbc; + distribution.f[dir::ZZP] = mfbba; + distribution.f[dir::MMZ] = mfccb; + distribution.f[dir::PPZ] = mfaab; + distribution.f[dir::MPZ] = mfcab; + distribution.f[dir::PMZ] = mfacb; + distribution.f[dir::MZM] = mfcbc; + distribution.f[dir::PZP] = mfaba; + distribution.f[dir::MZP] = mfcba; + distribution.f[dir::PZM] = mfabc; + distribution.f[dir::ZMM] = mfbcc; + distribution.f[dir::ZPP] = mfbaa; + distribution.f[dir::ZMP] = mfbca; + distribution.f[dir::ZPM] = mfbac; + distribution.f[dir::MMM] = mfccc; + distribution.f[dir::PMM] = mfacc; + distribution.f[dir::MPM] = mfcac; + distribution.f[dir::PPM] = mfaac; + distribution.f[dir::MMP] = mfcca; + distribution.f[dir::PMP] = mfaca; + distribution.f[dir::MPP] = mfcaa; + distribution.f[dir::PPP] = mfaaa; + distribution.f[dir::ZZZ] = mfbbb; +} + + +} +} + diff --git a/src/lbm/CumulantChimera.h b/src/lbm/CumulantChimera.h new file mode 100644 index 0000000000000000000000000000000000000000..e8740c7d3f5b988a6fdc5c3b16ab6a90e0a28b83 --- /dev/null +++ b/src/lbm/CumulantChimera.h @@ -0,0 +1,34 @@ +#ifndef LBM_CUMULANT_CHIMERA_H +#define LBM_CUMULANT_CHIMERA_H + +#ifndef __host__ +#define __host__ +#endif +#ifndef __device__ +#define __device__ +#endif + +#include <basics/Core/DataTypes.h> + +#include "KernelParameter.h" + +namespace vf +{ +namespace lbm +{ + +__host__ __device__ void setRelaxationRatesK17(real omega, real &OxxPyyPzz, real &OxyyPxzz, real &OxyyMxzz, real &Oxyz, + real &O4, real &O5, real &O6); + +__host__ __device__ void setRelaxationRatesK15(real omega, real &OxxPyyPzz, real &OxyyPxzz, real &OxyyMxzz, real &Oxyz, + real &O4, real &O5, real &O6); + +using RelaxationRatesFunctor = void(*)(real omega, real &OxxPyyPzz, real &OxyyPxzz, real &OxyyMxzz, real &Oxyz, + real &O4, real &O5, real &O6); + + +__host__ __device__ void cumulantChimera(KernelParameter parameter, RelaxationRatesFunctor setRelaxationRates); + +} +} +#endif diff --git a/src/lbm/KernelParameter.cpp b/src/lbm/KernelParameter.cpp new file mode 100644 index 0000000000000000000000000000000000000000..e039214d218ef19f35e8adf927f36d3a6f1aa355 --- /dev/null +++ b/src/lbm/KernelParameter.cpp @@ -0,0 +1,33 @@ +#include "KernelParameter.h" + +#include <cmath> + +#include "MacroscopicQuantities.h" + + +namespace vf +{ +namespace lbm +{ + + + +inline __host__ __device__ real Distribution27::getDensity_() const +{ + return getDensity(f); +} + + + +__host__ __device__ real abs_internal(real value) +{ +#ifdef __CUDA_ARCH__ + return ::abs(value); +#else + return std::abs(value); +#endif +} + + +} +} diff --git a/src/lbm/KernelParameter.h b/src/lbm/KernelParameter.h new file mode 100644 index 0000000000000000000000000000000000000000..95226628110637f3794c8a1f7e6f6c1f6dda937b --- /dev/null +++ b/src/lbm/KernelParameter.h @@ -0,0 +1,43 @@ +#ifndef LBM_KERNEL_PARAMETER_H +#define LBM_KERNEL_PARAMETER_H + +#ifndef __host__ +#define __host__ +#endif +#ifndef __device__ +#define __device__ +#endif + +#include <basics/Core/DataTypes.h> + + +namespace vf +{ +namespace lbm +{ + +struct Distribution27 +{ + real f[27]; + + __host__ __device__ real getDensity_() const; +}; + + +__host__ __device__ real abs_internal(real value); + + +struct KernelParameter +{ + Distribution27& distribution; + real omega; + real* forces; +}; + + + + +} +} + +#endif diff --git a/src/lbm/MacroscopicQuantities.h b/src/lbm/MacroscopicQuantities.h new file mode 100644 index 0000000000000000000000000000000000000000..c37791294ff5b4edad21795f4ce0a32a18c5d236 --- /dev/null +++ b/src/lbm/MacroscopicQuantities.h @@ -0,0 +1,98 @@ +#ifndef LBM_CALCMAC_H +#define LBM_CALCMAC_H + +#ifndef __host__ +#define __host__ +#endif +#ifndef __device__ +#define __device__ +#endif + +#include <basics/Core/DataTypes.h> + +#include "constants/NumericConstants.h" +#include "constants/D3Q27.h" + +namespace vf +{ +namespace lbm +{ + +//////////////////////////////////////////////////////////////////////////////////// +//! - 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> +//! + +inline __host__ __device__ real getDensity(const real *const &f /*[27]*/) +{ + return ((f[dir::TNE] + f[dir::BSW]) + (f[dir::TSE] + f[dir::BNW])) + ((f[dir::BSE] + f[dir::TNW]) + (f[dir::TSW] + f[dir::BNE])) + + (((f[dir::NE] + f[dir::SW]) + (f[dir::SE] + f[dir::NW])) + ((f[dir::TE] + f[dir::BW]) + (f[dir::BE] + f[dir::TW])) + + ((f[dir::BN] + f[dir::TS]) + (f[dir::TN] + f[dir::BS]))) + + ((f[dir::E] + f[dir::W]) + (f[dir::N] + f[dir::S]) + (f[dir::T] + f[dir::B])) + f[dir::REST]; +} + +/* +* Incompressible Macroscopic Quantities +*/ +inline __host__ __device__ real getIncompressibleVelocityX1(const real *const &f /*[27]*/) +{ + return ((((f[dir::TNE] - f[dir::BSW]) + (f[dir::TSE] - f[dir::BNW])) + ((f[dir::BSE] - f[dir::TNW]) + (f[dir::BNE] - f[dir::TSW]))) + + (((f[dir::BE] - f[dir::TW]) + (f[dir::TE] - f[dir::BW])) + ((f[dir::SE] - f[dir::NW]) + (f[dir::NE] - f[dir::SW]))) + (f[dir::E] - f[dir::W])); +} + + +inline __host__ __device__ real getIncompressibleVelocityX2(const real *const &f /*[27]*/) +{ + return ((((f[dir::TNE] - f[dir::BSW]) + (f[dir::BNW] - f[dir::TSE])) + ((f[dir::TNW] - f[dir::BSE]) + (f[dir::BNE] - f[dir::TSW]))) + + (((f[dir::BN] - f[dir::TS]) + (f[dir::TN] - f[dir::BS])) + ((f[dir::NW] - f[dir::SE]) + (f[dir::NE] - f[dir::SW]))) + (f[dir::N] - f[dir::S])); +} + + +inline __host__ __device__ real getIncompressibleVelocityX3(const real *const &f /*[27]*/) +{ + return ((((f[dir::TNE] - f[dir::BSW]) + (f[dir::TSE] - f[dir::BNW])) + ((f[dir::TNW] - f[dir::BSE]) + (f[dir::TSW] - f[dir::BNE]))) + + (((f[dir::TS] - f[dir::BN]) + (f[dir::TN] - f[dir::BS])) + ((f[dir::TW] - f[dir::BE]) + (f[dir::TE] - f[dir::BW]))) + (f[dir::T] - f[dir::B])); +} + + + +/* +* Compressible Macroscopic Quantities +*/ +inline __host__ __device__ real getCompressibleVelocityX1(const real *const &f27, const real& rho) +{ + return getIncompressibleVelocityX1(f27) / (rho + constant::c1o1); +} + + +inline __host__ __device__ real getCompressibleVelocityX2(const real *const &f27, const real& rho) +{ + return getIncompressibleVelocityX2(f27) / (rho + constant::c1o1); +} + + +inline __host__ __device__ real getCompressibleVelocityX3(const real *const &f27, const real& rho) +{ + return getIncompressibleVelocityX3(f27) / (rho + constant::c1o1); +} + +/* +* Pressure +*/ +inline __host__ __device__ real getPressure(const real *const &f27, const real& rho, const real& vx, const real& vy, const real& vz) +{ + return (f27[dir::E] + f27[dir::W] + f27[dir::N] + f27[dir::S] + f27[dir::T] + f27[dir::B] + + constant::c2o1 * (f27[dir::NE] + f27[dir::SW] + f27[dir::SE] + f27[dir::NW] + f27[dir::TE] + + f27[dir::BW] + f27[dir::BE] + f27[dir::TW] + f27[dir::TN] + f27[dir::BS] + + f27[dir::BN] + f27[dir::TS]) + + constant::c3o1 * (f27[dir::TNE] + f27[dir::TSW] + f27[dir::TSE] + f27[dir::TNW] + + f27[dir::BNE] + f27[dir::BSW] + f27[dir::BSE] + f27[dir::BNW]) - + rho - (vx * vx + vy * vy + vz * vz) * (constant::c1o1 + rho)) * + constant::c1o2 + rho; // times zero for incompressible case + // Attention: op defined directly to op = 1 ; ^^^^(1.0/op-0.5)=0.5 +} + +} +} + +#endif diff --git a/src/lbm/MacroscopicQuantitiesTests.cpp b/src/lbm/MacroscopicQuantitiesTests.cpp new file mode 100644 index 0000000000000000000000000000000000000000..52f89943a3e6a99fcab13eba22de9959229a289d --- /dev/null +++ b/src/lbm/MacroscopicQuantitiesTests.cpp @@ -0,0 +1,71 @@ +#include <gmock/gmock.h> + +#include "MacroscopicQuantities.h" +#include "constants/D3Q27.h" + + +/* +* given distributions, which are all one. +*/ +real f[27] = {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}; + +using namespace vf::lbm; + + +TEST(MacroscopicQuantitiesTest, check_density) +{ + const double density = getDensity(f); + + const double expected_density = 27.; + ASSERT_THAT(density, testing::DoubleEq(expected_density)); +} + +TEST(MacroscopicQuantitiesTest, whenFsAreEqual_velocityInEachDirectionShouldBeZero) +{ + const double velocityX1 = getIncompressibleVelocityX1(f); + const double velocityX2 = getIncompressibleVelocityX2(f); + const double velocityX3 = getIncompressibleVelocityX3(f); + + const double expected_velocity = 0.; + EXPECT_THAT(velocityX1, testing::DoubleEq(expected_velocity)); + EXPECT_THAT(velocityX2, testing::DoubleEq(expected_velocity)); + EXPECT_THAT(velocityX3, testing::DoubleEq(expected_velocity)); +} + +TEST(MacroscopicQuantitiesTest, givenAllFsAreOne_when_Eis2_velocityInX1ShouldBeOne) +{ + f[dir::E] = 2.; + + const double velocityX1 = getIncompressibleVelocityX1(f); + const double velocityX2 = getIncompressibleVelocityX2(f); + const double velocityX3 = getIncompressibleVelocityX3(f); + + const double expected_velocity_x1 = 1.; + const double expected_velocity_x2 = 0.; + const double expected_velocity_x3 = 0.; + + EXPECT_THAT(velocityX1, testing::DoubleEq(expected_velocity_x1)); + EXPECT_THAT(velocityX2, testing::DoubleEq(expected_velocity_x2)); + EXPECT_THAT(velocityX3, testing::DoubleEq(expected_velocity_x3)); +} + +TEST(MacroscopicQuantitiesTest, givenAllFsAreOne_when_Nis2_velocityInX2ShouldBeOne) +{ + f[dir::N] = 2.; + + const double velocity = getIncompressibleVelocityX2(f); + + const double expected_velocity = 1.; + ASSERT_THAT(velocity, testing::DoubleEq(expected_velocity)); +} + + +TEST(MacroscopicQuantitiesTest, givenAllFsAreOne_when_Tis2_velocityInX3ShouldBeOne) +{ + f[dir::T] = 2.; + + const double velocity = getIncompressibleVelocityX3(f); + + const double expected_velocity = 1.; + ASSERT_THAT(velocity, testing::DoubleEq(expected_velocity)); +} diff --git a/src/lbm/constants/D3Q27.h b/src/lbm/constants/D3Q27.h new file mode 100644 index 0000000000000000000000000000000000000000..0b2cbfdd44e84af590fa2c2be4bf319cbfd4c815 --- /dev/null +++ b/src/lbm/constants/D3Q27.h @@ -0,0 +1,71 @@ +#ifndef LBM_D3Q27_H +#define LBM_D3Q27_H + +namespace vf +{ +namespace lbm +{ +namespace dir +{ + +static constexpr int E = 0; +static constexpr int W = 1; +static constexpr int N = 2; +static constexpr int S = 3; +static constexpr int T = 4; +static constexpr int B = 5; +static constexpr int NE = 6; +static constexpr int SW = 7; +static constexpr int SE = 8; +static constexpr int NW = 9; +static constexpr int TE = 10; +static constexpr int BW = 11; +static constexpr int BE = 12; +static constexpr int TW = 13; +static constexpr int TN = 14; +static constexpr int BS = 15; +static constexpr int BN = 16; +static constexpr int TS = 17; +static constexpr int TNE = 18; +static constexpr int TNW = 19; +static constexpr int TSE = 20; +static constexpr int TSW = 21; +static constexpr int BNE = 22; +static constexpr int BNW = 23; +static constexpr int BSE = 24; +static constexpr int BSW = 25; +static constexpr int REST = 26; + +static constexpr int PZZ = 0; +static constexpr int MZZ = 1; +static constexpr int ZPZ = 2; +static constexpr int ZMZ = 3; +static constexpr int ZZP = 4; +static constexpr int ZZM = 5; +static constexpr int PPZ = 6; +static constexpr int MMZ = 7; +static constexpr int PMZ = 8; +static constexpr int MPZ = 9; +static constexpr int PZP = 10; +static constexpr int MZM = 11; +static constexpr int PZM = 12; +static constexpr int MZP = 13; +static constexpr int ZPP = 14; +static constexpr int ZMM = 15; +static constexpr int ZPM = 16; +static constexpr int ZMP = 17; +static constexpr int PPP = 18; +static constexpr int MPP = 19; +static constexpr int PMP = 20; +static constexpr int MMP = 21; +static constexpr int PPM = 22; +static constexpr int MPM = 23; +static constexpr int PMM = 24; +static constexpr int MMM = 25; +static constexpr int ZZZ = 26; + +} +} +} + +#endif diff --git a/src/lbm/constants/NumericConstants.h b/src/lbm/constants/NumericConstants.h new file mode 100644 index 0000000000000000000000000000000000000000..5c7556ceb4ccb711e2d2b6777e03a52e35fc1f19 --- /dev/null +++ b/src/lbm/constants/NumericConstants.h @@ -0,0 +1,244 @@ +#ifndef REAL_CONSTANT_H +#define REAL_CONSTANT_H + + +namespace vf +{ +namespace lbm +{ +namespace constant +{ + +#ifdef VF_DOUBLE_ACCURACY +static constexpr double c1o2 = 0.5; +static constexpr double c3o2 = 1.5; +static constexpr double c1o3 = 0.333333333333333; +static constexpr double c2o3 = 0.666666666666667; +static constexpr double c1o4 = 0.25; +static constexpr double c3o4 = 0.75; +static constexpr double c1o6 = 0.166666666666667; +static constexpr double c1o7 = 0.142857142857143; +static constexpr double c1o8 = 0.125; +static constexpr double c1o9 = 0.111111111111111; +static constexpr double c2o9 = 0.222222222222222; +static constexpr double c4o9 = 0.444444444444444; +static constexpr double c1o10 = 0.1; +static constexpr double c1o12 = 0.083333333333333; +static constexpr double c1o16 = 0.0625; +static constexpr double c3o16 = 0.1875; +static constexpr double c9o16 = 0.5625; +static constexpr double c1o18 = 0.055555555555556; +static constexpr double c1o20 = 0.05; +static constexpr double c19o20 = 0.95; +static constexpr double c21o20 = 1.05; +static constexpr double c1o24 = 0.041666666666667; +static constexpr double c1o27 = 0.037037037037037; +static constexpr double c3o32 = 0.09375; +static constexpr double c4o32 = 0.125; +static constexpr double c1o36 = 0.027777777777778; +static constexpr double c1o48 = 0.020833333333333; +static constexpr double c1o64 = 0.015625; +static constexpr double c3o64 = 0.046875; +static constexpr double c9o64 = 0.140625; +static constexpr double c27o64 = 0.421875; +static constexpr double c1o66 = 0.015151515151515; +static constexpr double c1o72 = 0.013888888888889; +static constexpr double c1o264 = 0.003787878787879; +static constexpr double c8o27 = 0.296296296296296; +static constexpr double c2o27 = 0.074074074074074; +static constexpr double c1o54 = 0.018518518518519; +static constexpr double c1o100 = 0.01; +static constexpr double c99o100 = 0.99; +static constexpr double c1o126 = 0.007936507936508; +static constexpr double c1o216 = 0.004629629629630; +static constexpr double c5o4 = 1.25; +static constexpr double c9o4 = 2.25; +static constexpr double c5o2 = 2.5; +static constexpr double c9o2 = 4.5; + +static constexpr double c0o1 = 0.; +static constexpr double c1o1 = 1.; +static constexpr double c2o1 = 2.; +static constexpr double c3o1 = 3.; +static constexpr double c4o1 = 4.; +static constexpr double c5o1 = 5.; +static constexpr double c6o1 = 6.; +static constexpr double c7o1 = 7.; +static constexpr double c8o1 = 8.; +static constexpr double c9o1 = 9.; +static constexpr double c10o1 = 10.; +static constexpr double c11o1 = 11.; +static constexpr double c12o1 = 12.; +static constexpr double c13o1 = 13.; +static constexpr double c14o1 = 14.; +static constexpr double c15o1 = 15.; +static constexpr double c16o1 = 16.; +static constexpr double c17o1 = 17.; +static constexpr double c18o1 = 18.; +static constexpr double c21o1 = 21.; +static constexpr double c24o1 = 24.; +static constexpr double c25o1 = 25.; +static constexpr double c26o1 = 26.; +static constexpr double c27o1 = 27.; +static constexpr double c28o1 = 28.; +static constexpr double c29o1 = 29.; +static constexpr double c30o1 = 30.; +static constexpr double c32o1 = 32.; +static constexpr double c33o1 = 33.; +static constexpr double c34o1 = 34.; +static constexpr double c36o1 = 36.; +static constexpr double c40o1 = 40.; +static constexpr double c42o1 = 42.; +static constexpr double c46o1 = 46.; +static constexpr double c48o1 = 48.; +static constexpr double c50o1 = 50.; +static constexpr double c52o1 = 52.; +static constexpr double c54o1 = 54.; +static constexpr double c56o1 = 56.; +static constexpr double c64o1 = 64.; +static constexpr double c66o1 = 66.; +static constexpr double c68o1 = 68.; +static constexpr double c69o1 = 69.; +static constexpr double c72o1 = 72.; +static constexpr double c84o1 = 84.; +static constexpr double c88o1 = 88.; +static constexpr double c96o1 = 96.; +static constexpr double c100o1 = 10.; +static constexpr double c130o1 = 13.; +static constexpr double c152o1 = 15.; +static constexpr double c166o1 = 16.; +static constexpr double c195o1 = 19.; +static constexpr double c216o1 = 21.; +static constexpr double c264o1 = 26.; +static constexpr double c290o1 = 29.; +static constexpr double c367o1 = 36.; + +static constexpr double Op0000002 = 0.0000002; +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 cPio180 = 1.74532925199e-2; +static constexpr double c180oPi = 57.2957795131; + +#else +static constexpr float c1o2 = 0.5f; +static constexpr float c3o2 = 1.5f; +static constexpr float c1o3 = (1.0f / 3.0f); +static constexpr float c2o3 = (2.0f / 3.0f); +static constexpr float c1o4 = 0.25f; +static constexpr float c3o4 = 0.75f; +static constexpr float c1o6 = (1.0f / 6.0f); +static constexpr float c1o7 = (1.0f / 7.0f); +static constexpr float c1o8 = 0.125f; +static constexpr float c1o9 = (1.0f / 9.0f); +static constexpr float c2o9 = (2.0f / 9.0f); +static constexpr float c4o9 = (4.0f / 9.0f); +static constexpr float c1o10 = 0.1f; +static constexpr float c1o12 = (1.0f / 12.0f); +static constexpr float c1o16 = 0.0625f; +static constexpr float c3o16 = 0.1875f; +static constexpr float c9o16 = 0.5625f; +static constexpr float c1o18 = (1.0f / 18.0f); +static constexpr float c1o20 = 0.05f; +static constexpr float c19o20 = 0.95f; +static constexpr float c21o20 = 1.05f; +static constexpr float c1o24 = (1.0f / 24.0f); +static constexpr float c1o27 = (1.0f / 27.0f); +static constexpr float c3o32 = 0.09375f; +static constexpr float c4o32 = 0.125f; +static constexpr float c1o36 = (1.0f / 36.0f); +static constexpr float c1o48 = (1.0f / 48.0f); +static constexpr float c1o64 = 0.015625f; +static constexpr float c3o64 = 0.046875f; +static constexpr float c9o64 = 0.140625f; +static constexpr float c27o64 = 0.421875f; +static constexpr float c1o66 = (1.0f / 66.0f); +static constexpr float c1o72 = (1.0f / 72.0f); +static constexpr float c1o264 = (1.0f / 264.0f); +static constexpr float c8o27 = (8.0f / 27.0f); +static constexpr float c2o27 = (2.0f / 27.0f); +static constexpr float c1o54 = (1.0f / 54.0f); +static constexpr float c1o100 = 0.01f; +static constexpr float c99o100 = 0.99f; +static constexpr float c1o126 = (1.0f / 126.0f); +static constexpr float c1o216 = (1.0f / 216.0f); +static constexpr float c5o4 = 1.25f; +static constexpr float c9o4 = 2.25f; +static constexpr float c5o2 = 2.5f; +static constexpr float c9o2 = 4.5f; + +static constexpr float c0o1 = 0.f; +static constexpr float c1o1 = 1.f; +static constexpr float c2o1 = 2.f; +static constexpr float c3o1 = 3.f; +static constexpr float c4o1 = 4.f; +static constexpr float c5o1 = 5.f; +static constexpr float c6o1 = 6.f; +static constexpr float c7o1 = 7.f; +static constexpr float c8o1 = 8.f; +static constexpr float c9o1 = 9.f; +static constexpr float c10o1 = 10.f; +static constexpr float c11o1 = 11.f; +static constexpr float c12o1 = 12.f; +static constexpr float c13o1 = 13.f; +static constexpr float c14o1 = 14.f; +static constexpr float c15o1 = 15.f; +static constexpr float c16o1 = 16.f; +static constexpr float c17o1 = 17.f; +static constexpr float c18o1 = 18.f; +static constexpr float c21o1 = 21.f; +static constexpr float c24o1 = 24.f; +static constexpr float c25o1 = 25.f; +static constexpr float c26o1 = 26.f; +static constexpr float c27o1 = 27.f; +static constexpr float c28o1 = 28.f; +static constexpr float c29o1 = 29.f; +static constexpr float c30o1 = 30.f; +static constexpr float c32o1 = 32.f; +static constexpr float c33o1 = 33.f; +static constexpr float c34o1 = 34.f; +static constexpr float c36o1 = 36.f; +static constexpr float c40o1 = 40.f; +static constexpr float c42o1 = 42.f; +static constexpr float c46o1 = 46.f; +static constexpr float c48o1 = 48.f; +static constexpr float c50o1 = 50.f; +static constexpr float c52o1 = 52.f; +static constexpr float c54o1 = 54.f; +static constexpr float c56o1 = 56.f; +static constexpr float c64o1 = 64.f; +static constexpr float c66o1 = 66.f; +static constexpr float c68o1 = 68.f; +static constexpr float c69o1 = 69.f; +static constexpr float c72o1 = 72.f; +static constexpr float c84o1 = 84.f; +static constexpr float c88o1 = 88.f; +static constexpr float c96o1 = 96.f; +static constexpr float c100o1 = 100.0f; +static constexpr float c130o1 = 130.0f; +static constexpr float c152o1 = 152.0f; +static constexpr float c166o1 = 166.0f; +static constexpr float c195o1 = 195.0f; +static constexpr float c216o1 = 216.0f; +static constexpr float c264o1 = 264.0f; +static constexpr float c290o1 = 290.0f; +static constexpr float c367o1 = 367.0f; + +static constexpr float Op0000002 = 0.0000002f; +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 float cPio180 = 1.74532925199e-2f; +static constexpr float c180oPi = 57.2957795131f; + +#endif + +} +} +} + +#endif diff --git a/src/lbm/cuda/CMakeLists.txt b/src/lbm/cuda/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..3a88d91648b960915279fc4f133f6b60047149bf --- /dev/null +++ b/src/lbm/cuda/CMakeLists.txt @@ -0,0 +1,12 @@ +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_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) 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 19ad23a537ce580f11bc107dcede0cad64f69fc3..941bdac8f03d64184c17966ada27111193bbfa2d 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 &) {} - 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; @@ -208,4 +211,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